Advertisement
Guest User

post job controller

a guest
Feb 11th, 2016
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 25.35 KB | None | 0 0
  1.  
  2. function newPostJobCtrl($scope,toastr, $rootScope, $location, $routeParams, $sessionStorage, $http, $window, HackerRank, md5) {
  3.  
  4. $scope.WorkTypeoptions = [{
  5. name: 'Full Time'
  6. }, {
  7. name: 'Part Time'
  8. }, {
  9. name: 'Casual'
  10. }, {
  11. name: 'Temp'
  12. }, {
  13. name: 'Contract'
  14. }];
  15. /* ------------------------------------- These are the interview packages ------------------------- */
  16. /* for sales and retail - store manager */
  17. $scope.storeManagerPackageName = 'Store Manager';
  18. $scope.storeManagerVideoInterview = [
  19. {Question: 'How would you teach a colleague how to close the register?', fromPackage: true},
  20. {Question: 'What’s the most important decision you make every day as a store manager?', fromPackage: true},
  21. {Question: 'What is your opinion on being friends with your coworkers?', fromPackage: true},
  22. {Question: 'What would you do if you had an employee who was frequently late?', fromPackage: true},
  23. {Question: 'A product is selling well at our competitors’ stores but not at our store. Why do youthink this is?', fromPackage: true}
  24. ]
  25. /* For UX Designer */
  26. $scope.UXDesignerPackageName = 'UX Designer';
  27. $scope.UXDesignerVideoInterview = [
  28. {Question: 'Talk to us about your studies. Have you studied design?', fromPackage: true},
  29. {Question: 'Do you specialise in wireframing and functionality design, or graphic design? Whichdo you prefer?', fromPackage: true},
  30. {Question: 'How would you define user experience UX design?', fromPackage: true},
  31. {Question: 'Tell us a bit about how you undertake user testing?', fromPackage: true},
  32. {Question: 'How do you decide when a design is done?', fromPackage: true}
  33. ]
  34. /* For UI Designer */
  35. $scope.UIDesignerPackageName = 'UI Designer';
  36. $scope.UIDesignerVideoInterview = [
  37. {Question: 'Do you have a side project you’d like to talk to us about?', fromPackage: true},
  38. {Question: 'What kind of usability testing methods have you applied in your projects?', fromPackage: true},
  39. {Question: 'How would you define user interface UI design?', fromPackage: true},
  40. {Question: 'Can you describe a time when the requirements changed in the middle of a projectand how you handled that?', fromPackage: true},
  41. {Question: 'How do you decide when a design is done?', fromPackage: true}
  42. ]
  43. /* For Front End Web Developer */
  44. $scope.FrontEndPackageName = 'Front End Web Developer';
  45. $scope.FrontEndVideoInterview = [
  46. {Question: 'Which HTTP status codes classes are used to designate success, client error andserver error respectively?', fromPackage: true},
  47. {Question: 'When would you use GET and POST requests?', fromPackage: true},
  48. {Question: 'What can you do to improve page performance?', fromPackage: true},
  49. {Question: 'Describe a project you have previously worked on.', fromPackage: true},
  50. {Question: 'Describe the same-origin policy as part of the web browser security model. Give acouple of practical limitations it may pose.', fromPackage: true}
  51. ]
  52. /* For Java Developer */
  53. $scope.JavaDeveloperName = 'Java Developer';
  54. $scope.JavaDeveloperVideoInterview = [
  55. {Question: 'Is Java a statically or dynamically typed language?', fromPackage: true},
  56. {Question: 'What is JVM? Why is Java called the ‘Platform Independent ProgrammingLanguage’?', fromPackage: true},
  57. {Question: 'What do we mean by polymorphism, inheritance and encapsulation?', fromPackage: true},
  58. {Question: 'What is the difference between an abstract class and an interface and when would you use one over the other?', fromPackage: true},
  59. {Question: 'Describe a Java-related project you have previously worked on.', fromPackage: true}
  60. ]
  61. /* For Data Scientist (Analysis) */
  62. $scope.DataScientistAnalysisPackageName = 'Data Scientist (Analysis)';
  63. $scope.DataScientistAnalysisVideoInterview = [
  64. {Question: 'What is a confidence interval and why is it useful?', fromPackage: true},
  65. {Question: 'What is the difference between statistical independence and correlation?', fromPackage: true},
  66. {Question: 'What is conditional probability? What is Bayes’ Theorem? Why is it useful in practice?', fromPackage: true},
  67. {Question: 'How do we know if we have collected enough data to train a model?', fromPackage: true},
  68. {Question: 'Explain why we have training, test and validation data sets and how they are used effectively?', fromPackage: true}
  69. ]
  70. /* For Data Scientist (Coding) */
  71. $scope.DataScientistCodingName = 'Data Scientist (Coding)';
  72. $scope.DataScientistCodingVideoInterview = [
  73. {Question: 'How would you train and deploy a logistic regression model? A recommender system?', fromPackage: true},
  74. {Question: 'How would you sort a large list of numbers?', fromPackage: true},
  75. {Question: 'What is hashing? Give an example of when you might want to use it', fromPackage: true},
  76. {Question: 'Can you perform logistic regression with Excel? If yes, how can it be done? Would the result be good?', fromPackage: true},
  77. {Question: 'What is dynamic programming? What is recursion?', fromPackage: true}
  78. ]
  79. /* For Senior Ruby Developer */
  80. $scope.SeniorRubyDeveloperName = 'Senior Ruby Developer';
  81. $scope.SeniorRubyDeveloperVideoInterview = [
  82. {Question: 'What constitutes a good unit test and what a functional one?', fromPackage: true},
  83. {Question: 'How would you sort a large list of numbers in Ruby?', fromPackage: true},
  84. {Question: 'How is a block different from a Proc?', fromPackage: true},
  85. {Question: 'When do you think is the best time in a project’s lifecycle, to set up its test infrastructure?', fromPackage: true},
  86. {Question: 'What do you expect to find in a regression test suite and why?', fromPackage: true}
  87. ]
  88. /* For Junior Accountant */
  89. $scope.JuniorAccountantName = 'Junior Accountant';
  90. $scope.JuniorAccountantVideoInterview = [
  91. {Question: 'Describe your familiarity with accounting standards such as FASB and GAAP', fromPackage: true},
  92. {Question: 'How would you set up an internal control system for processing invoices? Which accounting software programs have you used?', fromPackage: true},
  93. {Question: 'How do you stay motivated while doing repetitive tasks? Describe an accounting process that you developed or improved.', fromPackage: true},
  94. {Question: 'When do you think is the best time in a project’s lifecycle, to set up its test infrastructure?', fromPackage: true},
  95. {Question: 'What are your goals? Why these goals and how do you plan to meet them?', fromPackage: true}
  96. ]
  97. $scope.totalInterviewPackages = [
  98. {"name": 'Store Manager', "packages": [
  99. {VideoInterview: $scope.storeManagerVideoInterview},
  100. {name: 'Store Manager'}
  101. ] },
  102. {"name": 'UX Designer', "packages": [
  103. {VideoInterview: $scope.UXDesignerVideoInterview},
  104. {name: 'UX Designer'}
  105. ] },
  106. {"name": 'UI Designer', "packages": [
  107. {VideoInterview: $scope.UIDesignerVideoInterview},
  108. {name: 'UI Designer'}
  109. ] },
  110. {"name": 'Front End Web Developer', "packages": [
  111. {VideoInterview: $scope.FrontEndVideoInterview},
  112. {name: 'Front End Web Developer'}
  113. ] },
  114. {"name": 'Java Developer', "packages": [
  115. {VideoInterview: $scope.JavaDeveloperVideoInterview},
  116. {name: 'Java Developer'}
  117. ] },
  118. {"name": 'Data Scientist (Analysis)', "packages": [
  119. {VideoInterview: $scope.DataScientistAnalysisVideoInterview},
  120. {name: 'Data Scientist (Analysis)'}
  121. ] },
  122. {"name": 'Data Scientist (Coding)', "packages": [
  123. {VideoInterview: $scope.DataScientistCodingVideoInterview},
  124. {name: 'Data Scientist (Coding)'}
  125. ] },
  126. {"name": 'Senior Ruby Developer', "packages": [
  127. {VideoInterview: $scope.SeniorRubyDeveloperVideoInterview},
  128. {name: 'Senior Ruby Developer'}
  129. ] },
  130. {"name": 'Junior Accountant', "packages": [
  131. {VideoInterview: $scope.JuniorAccountantVideoInterview},
  132. {name: 'Junior Accountant'}
  133. ] }
  134. ];
  135.  
  136. $scope.$storage = $sessionStorage;
  137. $scope.interviewDescription = '';
  138. $scope.changeInterviewPackage = function (type){
  139. toastr.success('video interview questions successfully updated', 'Questions Updated');
  140. $scope.interviewPackage = type;
  141. for (var i=0; i<$scope.totalInterviewPackages.length; i++){
  142. if($scope.totalInterviewPackages[i].name == $scope.interviewPackage){
  143. console.log($scope.totalInterviewPackages[i].packages[0]);
  144. console.log($scope.totalInterviewPackages[i].packages[0].VideoInterview);
  145. $scope.CustomQuestions = $scope.totalInterviewPackages[i].packages[0].VideoInterview;
  146. for( var x =0; x<$scope.CustomQuestions.length; x++){
  147. if($scope.CustomQuestions[x].fromInterview ==true){
  148. $scope.CustomQuestions.splice($scope.CustomQuestions.indexOf($scope.CustomQuestions[x]), 1);
  149. }
  150. }
  151. // $scope.nameIntern = $scope.interviewPackage;
  152. }
  153. }
  154. }
  155. $scope.statesRegionsList = $rootScope.statesRegions;
  156. $scope.saveJobToSession = function() {
  157. $scope.$storage.jobInProgress = [{
  158. name: $scope.nameIntern,
  159. employerName: $rootScope.EmployerName,
  160. location: $scope.Location,
  161. country: $scope.selectedCountry,
  162. state: $scope.selectedStatesRegion,
  163. suburb: $scope.Suburb,
  164. postcode: $scope.postcode,
  165. deadline: $scope.Deadline,
  166. startDate: $scope.startDate,
  167. industry: $scope.selectedIndustry,
  168. Remuneration: $scope.Remuneration,
  169. worktype: $scope.selectedOptionWorkType,
  170. Description: $scope.Description,
  171. CustomVideoQuestion: $scope.CustomQuestions,
  172. selectedTests: $scope.selectedHackerRankTests,
  173. suggested: $scope.selection,
  174. VideoDuration: $scope.toDoVideoTime,
  175. AptitudeQuestions: $scope.RealStudentTasks,
  176. ratings: $scope.ratings,
  177. comments: $scope.comments,
  178. multiple: $scope.RealMultiple,
  179. NumberCorrect: $scope.todoNumberCorrect,
  180. indeed: $scope.indeed,
  181. workible: $scope.workible,
  182. seek: $scope.seek,
  183. interviewDescription: $scope.interviewDescription,
  184. interviewPackage: $scope.interviewPackage
  185. }];
  186. }
  187. /* slide up and down for interview pages */
  188. $scope.technologyChevron= true;
  189. $scope.salesRetailChevron = true;
  190. $scope.accountingChevron = true;
  191. $scope.toggleInterviewPackages = function(type){
  192. if(type == 'technology'){
  193. $(".technology-list").slideToggle();
  194. $scope.technologyChevron = !$scope.technologyChevron;
  195. } else if(type == 'sales and retail'){
  196. $(".sales-and-retail-list").slideToggle();
  197. $scope.salesRetailChevron = ! $scope.salesRetailChevron;
  198. } else if(type == 'accounting'){
  199. $(".accounting-list").slideToggle();
  200. $scope.accountingChevron = !$scope.accountingChevron;
  201. }
  202.  
  203. };
  204. $scope.toStepOne = function() {
  205. $location.path('/post-job-step-one');
  206. $scope.saveJobToSession();
  207. };
  208.  
  209. $scope.toStepTwo = function() {
  210. $location.path('/post-job-step-two');
  211. $scope.saveJobToSession();
  212. };
  213.  
  214. $scope.toStepThree = function() {
  215. $location.path('/post-job-step-three');
  216. $scope.saveJobToSession();
  217. };
  218.  
  219. $scope.toStepFour = function() {
  220. $location.path('/post-job-step-four');
  221. $scope.saveJobToSession();
  222. };
  223.  
  224. $scope.jobInProgress = $scope.$storage.jobInProgress || [{}];
  225.  
  226. $scope.ButtonSubmitted = 'false';
  227. $scope.submitted = false;
  228.  
  229. // Step one variables
  230. $scope.nameIntern = $scope.jobInProgress[0].name || '';
  231. $scope.Location = $scope.jobInProgress[0].location || '';
  232. $scope.Description = $scope.jobInProgress[0].Description || '';
  233. $scope.Deadline = $scope.jobInProgress[0].deadline || '';
  234. $scope.Remuneration = $scope.jobInProgress[0].Remuneration || '';
  235. $scope.WorkType = $scope.jobInProgress[0].WorkType || '';
  236. $scope.Deadline = $scope.jobInProgress[0].deadline || '';
  237. $scope.FullPart = $scope.jobInProgress[0].FullPart || '';
  238. $scope.startDate = $scope.jobInProgress[0].startDate|| '';
  239. $scope.Suburb = $scope.jobInProgress[0].suburb || '';
  240. $scope.postcode = $scope.jobInProgress[0].postcode || '';
  241. console.log($scope.jobInProgress[0].suburb);
  242. console.log($scope.jobInProgress[0].name);
  243. console.log( $scope.jobInProgress[0].country);
  244. console.log($scope.jobInProgress[0].state);
  245. console.log($scope.jobInProgress[0].WorkType);
  246. for ( var i=0; i<$rootScope.CountryList.length; i++){
  247. if($scope.jobInProgress[0].country ==undefined){
  248. $scope.jobInProgress[0].country = $rootScope.CountryList[13];
  249. }
  250. else if($scope.jobInProgress[0].country.name == $rootScope.CountryList[i].name){
  251. $scope.jobInProgress[0].country = $rootScope.CountryList[i];
  252. }
  253. }
  254. for ( var i=0; i<$rootScope.statesRegions.length; i++){
  255. if($scope.jobInProgress[0].state ==undefined){
  256. $scope.jobInProgress[0].state = $rootScope.statesRegions[0];
  257. }else if($scope.jobInProgress[0].state.name == $rootScope.statesRegions[i].name){
  258. $scope.jobInProgress[0].state = $rootScope.statesRegions[i];
  259. }
  260. }
  261. for ( var i=0; i< $rootScope.industryList.length; i++){
  262. if($scope.jobInProgress[0].industry ==undefined){
  263. $scope.jobInProgress[0].industry = $scope.industryList[0];
  264. }else if($scope.jobInProgress[0].industry.name == $rootScope.industryList[i].name){
  265. $scope.jobInProgress[0].industry = $rootScope.industryList[i];
  266. }
  267. }
  268. for ( var i=0; i<$scope.WorkTypeoptions.length; i++){
  269. if($scope.jobInProgress[0].worktype == undefined){
  270. $scope.jobInProgress[0].worktype = $scope.WorkTypeoptions[0];
  271. }else if($scope.jobInProgress[0].worktype.name == $scope.WorkTypeoptions[i].name){
  272. $scope.jobInProgress[0].worktype = $scope.WorkTypeoptions[i];
  273. }
  274. }
  275. $scope.selectedCountry = $scope.jobInProgress[0].country || $rootScope.CountryList[13];
  276. $scope.selectedStatesRegion = $scope.jobInProgress[0].state || $rootScope.statesRegions[0];
  277. $scope.selectedIndustry = $scope.jobInProgress[0].industry || $rootScope.industryList[0];
  278. $scope.selectedOptionWorkType = $scope.jobInProgress[0].worktype || $scope.WorkTypeoptions[0];
  279.  
  280. // Step two questions
  281. $scope.todoNumberCorrect = $scope.jobInProgress[0].NumberCorrect;
  282. $scope.RealStudentTasks = $scope.jobInProgress[0].AptitudeQuestions || [];
  283. $scope.selectedHackerRankTests = $scope.jobInProgress[0].selectedTests || [];
  284. $scope.todoTextTasks = '';
  285. $scope.removeTasks = function(TaskObject) {
  286. $scope.RealStudentTasks.splice($scope.RealStudentTasks.indexOf(TaskObject), 1);
  287. };
  288. $scope.RealMultiple = $scope.jobInProgress[0].multiple || [];
  289. $scope.multiplequestion = '';
  290. $scope.questionA = '';
  291. $scope.questionB = '';
  292. $scope.questionC = '';
  293. $scope.questionD = '';
  294. $scope.correctAnswer = '';
  295. $scope.toggleMultiple = function(multiple) {
  296. if(multiple.displayPlus == true){
  297. multiple.displayPlus = false;
  298. } else {
  299. multiple.displayPlus = true;
  300. }
  301. $("." + multiple.uniqueClass).slideToggle();
  302. }
  303. $scope.hackerRankLinkName = 'Retreive HackerRank Tests';
  304.  
  305. // Step three variables
  306. $scope.QuestionType = 0;
  307. $scope.AddOrEdit = 0;
  308. $scope.toDoVideoTime = $scope.jobInProgress[0].VideoDuration || 45;
  309. $scope.CustomQuestions = $scope.jobInProgress[0].CustomVideoQuestion || [];
  310. $scope.toDoVideoQuestions = '';
  311.  
  312. /* rating video questions */
  313. $scope.ratings = $scope.jobInProgress[0].ratings || [];
  314. $scope.todoTextRatings = '';
  315. $scope.FormSubmitted = false;
  316.  
  317. /* video comment questions */
  318. $scope.comments = $scope.jobInProgress[0].comments || [] ;
  319. $scope.todoTextComments = '';
  320.  
  321. //Step four variables (integrations).
  322. $scope.indeed = $scope.jobInProgress[0].indeed || '';
  323. $scope.workible = $scope.jobInProgress[0].workible || '';
  324. $scope.seek = $scope.jobInProgress[0].seek || '';
  325.  
  326. // create job functions
  327. $scope.submitForm = function() {
  328. if($scope.indeed =='indeed'){
  329. $scope.jobInProgress[0].indeed = 'indeed';
  330. }
  331. if($scope.workible == 'workible'){
  332. $scope.jobInProgress[0].workible = 'workible';
  333. }
  334. if($scope.seek == 'seek'){
  335. $scope.jobInProgress[0].seek = 'seek';
  336. }
  337. if ($rootScope.CurrentJobs == undefined) {
  338. $rootScope.CurrentJobs = [];
  339. }
  340. $scope.submitted = false;
  341. $http.post('CreateRealJob.php', {
  342. "data": $scope.jobInProgress
  343. }).
  344. success(function(data, status) {
  345. $rootScope.CurrentJobs.push({
  346. name: $scope.nameIntern,
  347. employerName: $rootScope.EmployerName,
  348. location: $scope.Location,
  349. country: $scope.selectedCountry.name,
  350. state: $scope.selectedStatesRegion.name,
  351. suburb: $scope.Suburb,
  352. deadline: $scope.Deadline,
  353. startDate: $scope.startDate,
  354. industry: $scope.selectedIndustry.name,
  355. Remuneration: $scope.Remuneration,
  356. worktype: $scope.selectedOptionWorkType.name,
  357. Description: $scope.Description,
  358. CustomVideoQuestion: $scope.CustomQuestions,
  359. suggested: $scope.selection,
  360. VideoDuration: $scope.toDoVideoTime,
  361. AptitudeQuestions: $scope.RealStudentTasks,
  362. ratings: $scope.ratings,
  363. comments: $scope.comments,
  364. multiple: $scope.RealMultiple,
  365. NumberCorrect: $scope.todoNumberCorrect,
  366. indeed: $scope.indeed,
  367. workible: $scope.workible,
  368. seek: $scope.seek,
  369. Students: [],
  370. selectedTests: $scope.selectedHackerRankTests
  371. });
  372. $scope.$storage = [];
  373. $sessionStorage.$reset();
  374. $rootScope.CurrentJobName = $scope.nameIntern;
  375. $rootScope.NoJobsPosted = false;
  376. if (_isNotMobile == false) {
  377. $location.path('current-jobs');
  378. } else {
  379. //console.log(data);
  380. $window.location.href = 'employer-tracker/' + data;
  381. }
  382. }).error(function(data, status) {
  383. $scope.data = data || "Request failed";
  384. $scope.status = status;
  385. });
  386. };
  387. // fruits
  388. $scope.fruits = ['What are your strengths?', 'Tell me about an accomplishment you are most proud of.', 'Tell me about a time you made a mistake.', 'Tell me how you handled a difficult situation.',
  389. 'Tell me about a time when you disagreed with your boss.', 'What are some of your leadership experiences?', 'What can you offer us that someone else can not?',
  390. 'Describe yourself.'
  391. ];
  392. // http://www.forbes.com/sites/jacquelynsmith/2013/01/11/how-to-ace-the-50-most-common-interview-questions/
  393. // selected fruits
  394. $scope.selection = $scope.jobInProgress[0].suggested || [];
  395.  
  396. $scope.AddToVideo = function() {
  397. if ($scope.toDoVideoQuestions != '' && ($scope.selection.length + $scope.CustomQuestions.length) < 10) {
  398. $scope.CustomQuestions.push({
  399. Question: $scope.toDoVideoQuestions,
  400. Video_intern: $routeParams.id
  401. });
  402. $scope.toDoVideoQuestions = '';
  403. }
  404. };
  405.  
  406. $scope.PreEdit = function(Custom) {
  407. $scope.toDoVideoQuestions = Custom.Question;
  408. $scope.QuestionIndex = $scope.CustomQuestions.indexOf(Custom);
  409. $scope.AddOrEdit = 1;
  410. };
  411. $scope.EditVideo = function() {
  412. $scope.CustomQuestions[$scope.QuestionIndex] = {
  413. Question: $scope.toDoVideoQuestions
  414. };
  415. $scope.toDoVideoQuestions = '';
  416. $scope.AddOrEdit = 0;
  417. };
  418. $scope.CancelEdit = function() {
  419. $scope.toDoVideoQuestions = '';
  420. $scope.AddOrEdit = 0;
  421. $scope.QuestionIndex = -1;
  422. };
  423. $scope.DeleteQuestion = function(Custom) {
  424. $scope.CustomQuestions.splice($scope.CustomQuestions.indexOf(Custom), 1);
  425. };
  426. $scope.SuggestedHeader = function() {
  427. if ($scope.QuestionType == 1) {
  428. return 'resp-tab-item resp-tab-active';
  429. } else {
  430. return 'resp-tab-item';
  431. }
  432. };
  433. $scope.CustomHeader = function() {
  434. if ($scope.QuestionType == 0) {
  435. return 'resp-tab-item resp-tab-active';
  436. } else {
  437. return 'resp-tab-item';
  438. }
  439. };
  440.  
  441.  
  442. // toggle selection for a given fruit by name
  443. $scope.toggleSelection = function toggleSelection(fruitName) {
  444. var idx = $scope.selection.indexOf(fruitName);
  445.  
  446. // is currently selected
  447. if (idx > -1) {
  448. $scope.selection.splice(idx, 1);
  449. }
  450.  
  451. // is newly selected
  452. else {
  453. if (($scope.selection.length + $scope.CustomQuestions.length) < 10) {
  454. $scope.selection.push(fruitName);
  455. }
  456. }
  457. };
  458.  
  459. $scope.addTodoMultiple = function() {
  460. console.log('testing should work');
  461. console.log($scope.correctAnswer);
  462. if ($scope.multiplequestion != '' && $scope.questionA != '' && $scope.questionB != '' && $scope.questionC != '' && $scope.questionD != '' && $scope.correctAnswer != '') {
  463. $scope.str = md5.createHash($scope.multiplequestion);
  464. $scope.RealMultiple.push({
  465. question: $scope.multiplequestion,
  466. questionA: $scope.questionA,
  467. questionB: $scope.questionB,
  468. questionC: $scope.questionC,
  469. questionD: $scope.questionD,
  470. correctAnswer: $scope.correctAnswer,
  471. displayPlus: true,
  472. uniqueClass: $scope.str
  473. });
  474. $scope.multiplequestion = '';
  475. $scope.questionA = '';
  476. $scope.questionB = '';
  477. $scope.questionC = '';
  478. $scope.questionD = '';
  479. $scope.correctAnswer = '';
  480. }
  481.  
  482. };
  483. $scope.getHackerRankTests = function() {
  484. $scope.hackerRankLinkName = "Retreiving ...";
  485. $scope.retreiving = true;
  486. $scope.hackerRankTokenMessage = null;
  487.  
  488. HackerRank.getTests($rootScope.UserId).then(function(response) {
  489. $scope.hackerRankLinkName = "Retreive HackerRank Tests";
  490. $scope.retreiving = false;
  491.  
  492. if (response.data.data != null) {
  493. $scope.tests = response.data.data.filter(function(el, index, arr) {
  494. for (var i = 0; i < $scope.selectedHackerRankTests.length; i++) {
  495. if ($scope.selectedHackerRankTests[i].test_id === el.id) {
  496. return false;
  497. }
  498. }
  499. return true;
  500. });
  501. } else {
  502. $scope.tests = response.data.data;
  503. }
  504.  
  505. if ($scope.tests == null) {
  506. HackerRank.getAccount($rootScope.UserId).then(function(response) {
  507. $scope.hackerRankAccessToken = response.data.access_token;
  508. if (!$scope.hackerRankAccessToken) {
  509. $scope.hackerRankTokenMessage = "Access Token Issue";
  510. } else {
  511. $scope.hackerRankTokenMessage = "No Tests Found";
  512. }
  513. console.log($scope.hackerRankTokenMessage);
  514. });
  515. }
  516. });
  517. };
  518. $scope.addHackerRankTest = function(test) {
  519. $scope.selectedHackerRankTests.push({
  520. url: test.url,
  521. test_id: test.id,
  522. name: test.name,
  523. questions_count: test.questions_count,
  524. duration: test.duration
  525. });
  526. $scope.tests = $scope.tests.filter(function(element, index, array) {
  527. if (element.id === test.id) {
  528. return false;
  529. } else {
  530. return true;
  531. }
  532. });
  533. };
  534.  
  535. $scope.removeHackerRankTest = function(test) {
  536. if ($scope.tests)
  537. $scope.tests.push({
  538. url: test.url,
  539. id: test.test_id,
  540. name: test.name,
  541. questions_count: test.questions_count,
  542. duration: test.duration
  543. });
  544. $scope.selectedHackerRankTests = $scope.selectedHackerRankTests.filter(function(element, index, array) {
  545. if (element.test_id === test.test_id) {
  546. return false;
  547. } else {
  548. return true;
  549. }
  550. });
  551.  
  552. }
  553. $scope.removeMultiple = function(TaskObject) {
  554. $scope.RealMultiple.splice($scope.RealMultiple.indexOf(TaskObject), 1);
  555. };
  556. $scope.addTodoTasks = function() {
  557. if ($scope.todoTextTasks != '') {
  558. $scope.RealStudentTasks.push({
  559. attribute_name: $scope.todoTextTasks
  560. });
  561. console.log($scope.RealStudentTasks[$scope.RealStudentTasks.length - 1]);
  562. $scope.todoTextTasks = '';
  563. }
  564. };
  565.  
  566. $scope.removeRating = function(TaskObject) {
  567. $scope.ratings.splice($scope.ratings.indexOf(TaskObject), 1);
  568. };
  569. $scope.addTodoRatings = function() {
  570. if ($scope.todoTextRatings != '') {
  571. $scope.ratings.push({
  572. criteria: $scope.todoTextRatings
  573. });
  574. console.log($scope.ratings[$scope.ratings.length - 1]);
  575. $scope.todoTextRatings = '';
  576. }
  577. };
  578.  
  579. $scope.removeComments = function(TaskObject) {
  580. $scope.comments.splice($scope.comments.indexOf(TaskObject), 1);
  581. };
  582. $scope.addTodoComments = function() {
  583. if ($scope.todoTextComments != '') {
  584. $scope.comments.push({
  585. criteria: $scope.todoTextComments
  586. });
  587. console.log($scope.comments[$scope.comments.length - 1]);
  588. $scope.todoTextComments = '';
  589. }
  590. };
  591. $scope.viewProfile = function() {
  592. $location.path('edit-business-profile');
  593. }
  594. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement