PageRenderTime 66ms CodeModel.GetById 22ms RepoModel.GetById 1ms app.codeStats 0ms

/code/war/js/atd.js

https://code.google.com/p/teammatespes/
JavaScript | 2613 lines | 2003 code | 331 blank | 279 comment | 213 complexity | 2a0180e6820571cac231316064298752 MD5 | raw file

Large files files are truncated, but you can click here to view the full file

  1. // AJAX
  2. var xmlhttp = new getXMLObject();
  3. //OPERATIONS
  4. var OPERATION_ADMINISTRATOR_LOGOUT = "administrator_logout";
  5. var OPERATION_COORDINATOR_ADDCOURSE = "coordinator_addcourse";
  6. var OPERATION_COORDINATOR_ADDEVALUATION = "coordinator_addevaluation";
  7. var OPERATION_COORDINATOR_ARCHIVECOURSE = "coordinator_archivecourse";
  8. var OPERATION_COORDINATOR_ARCHIVEEVALUATION = "coordinator_archiveevaluation";
  9. var OPERATION_COORDINATOR_DELETEALLSTUDENTS = "coordinator_deleteallstudents";
  10. var OPERATION_COORDINATOR_DELETECOURSE = "coordinator_deletecourse";
  11. var OPERATION_COORDINATOR_DELETEEVALUATION = "coordinator_deleteevaluation";
  12. var OPERATION_COORDINATOR_DELETESTUDENT = "coordinator_deletestudent";
  13. var OPERATION_COORDINATOR_EDITEVALUATION = "coordinator_editevaluation";
  14. var OPERATION_COORDINATOR_EDITEVALUATIONRESULTS = "coordinator_editevaluationresults";
  15. var OPERATION_COORDINATOR_EDITSTUDENT = "coordinator_editstudent";
  16. var OPERATION_COORDINATOR_ENROLSTUDENTS = "coordinator_enrolstudents";
  17. var OPERATION_COORDINATOR_GETCOURSE = "coordinator_getcourse";
  18. var OPERATION_COORDINATOR_GETCOURSELIST = "coordinator_getcourselist";
  19. var OPERATION_COORDINATOR_GETEVALUATIONLIST = "coordinator_getevaluationlist";
  20. var OPERATION_COORDINATOR_GETSTUDENTLIST = "coordinator_getstudentlist";
  21. var OPERATION_COORDINATOR_GETSUBMISSIONLIST = "coordinator_getsubmissionlist";
  22. var OPERATION_COORDINATOR_INFORMSTUDENTSOFEVALUATIONCHANGES = "coordinator_informstudentsofevaluationchanges";
  23. var OPERATION_COORDINATOR_LOGOUT = "coordinator_logout";
  24. var OPERATION_COORDINATOR_PUBLISHEVALUATION = "coordinator_publishevaluation";
  25. var OPERATION_COORDINATOR_REMINDSTUDENTS = "coordinator_remindstudents";
  26. var OPERATION_COORDINATOR_SENDREGISTRATIONKEY = "coordinator_sendregistrationkey";
  27. var OPERATION_COORDINATOR_SENDREGISTRATIONKEYS = "coordinator_sendregistrationkeys";
  28. var OPERATION_COORDINATOR_UNARCHIVECOURSE = "coordinator_unarchivecourse";
  29. var OPERATION_COORDINATOR_UNARCHIVEEVALUATION = "coordinator_unarchiveevaluation";
  30. var OPERATION_STUDENT_ARCHIVECOURSE = "student_archivecourse";
  31. var OPERATION_STUDENT_DELETECOURSE = "student_deletecourse";
  32. var OPERATION_STUDENT_GETCOURSE = "student_getcourse";
  33. var OPERATION_STUDENT_GETCOURSELIST = "student_getcourselist";
  34. var OPERATION_STUDENT_GETPASTEVALUATIONLIST = "student_getpastevaluationlist";
  35. var OPERATION_STUDENT_GETPENDINGEVALUATIONLIST = "student_getpendingevaluationlist";
  36. var OPERATION_STUDENT_GETSUBMISSIONLIST = "student_getsubmissionlist";
  37. var OPERATION_STUDENT_GETSUBMISSIONRESULTSLIST = "student_getsubmissionresultslist";
  38. var OPERATION_STUDENT_JOINCOURSE = "student_joincourse";
  39. var OPERATION_STUDENT_LOGOUT = "student_logout";
  40. var OPERATION_STUDENT_SUBMITEVALUATION = "student_submitevaluation";
  41. var OPERATION_STUDENT_UNARCHIVECOURSE = "student_unarchivecourse";
  42. //PARAMETERS
  43. var COURSE_ID = "courseid";
  44. var COURSE_NAME = "coursename";
  45. var COURSE_NUMBEROFTEAMS = "coursenumberofteams";
  46. var COURSE_STATUS = "coursestatus";
  47. var EVALUATION_ACTIVATED = "activated";
  48. var EVALUATION_ARCHIVED = "evaluationarchived";
  49. var EVALUATION_COMMENTSENABLED = "commentsstatus";
  50. var EVALUATION_DEADLINE = "deadline";
  51. var EVALUATION_DEADLINETIME = "deadlinetime";
  52. var EVALUATION_GRACEPERIOD = "graceperiod";
  53. var EVALUATION_INSTRUCTIONS = "instr";
  54. var EVALUATION_NAME = "evaluationname";
  55. var EVALUATION_NUMBEROFCOMPLETEDEVALUATIONS = "numberofevaluations";
  56. var EVALUATION_NUMBEROFEVALUATIONS = "numberofcompletedevaluations";
  57. var EVALUATION_PUBLISHED = "published";
  58. var EVALUATION_START = "start";
  59. var EVALUATION_STARTTIME = "starttime";
  60. var EVALUATION_TIMEZONE = "timezone";
  61. var EVALUATION_TYPE = "evaluationtype";
  62. var STUDENT_COMMENTS = "comments";
  63. var STUDENT_COMMENTSEDITED = "commentsedited";
  64. var STUDENT_COMMENTSTOSTUDENT = "commentstostudent";
  65. var STUDENT_COURSEID = "courseid";
  66. var STUDENT_EDITCOMMENTS = "editcomments";
  67. var STUDENT_EDITEMAIL = "editemail";
  68. var STUDENT_EDITGOOGLEID = "editgoogleid";
  69. var STUDENT_EDITNAME = "editname";
  70. var STUDENT_EDITTEAMNAME = "editteamname";
  71. var STUDENT_EMAIL = "email";
  72. var STUDENT_FROMSTUDENT = "fromemail";
  73. var STUDENT_FROMSTUDENTCOMMENTS = "fromstudentcomments";
  74. var STUDENT_FROMSTUDENTNAME = "fromname";
  75. var STUDENT_ID = "id";
  76. var STUDENT_INFORMATION = "information";
  77. var STUDENT_JUSTIFICATION = "justification";
  78. var STUDENT_NAME = "name";
  79. var STUDENT_NAMEEDITED = "nameedited";
  80. var STUDENT_NUMBEROFSUBMISSIONS = "numberofsubmissions";
  81. var STUDENT_POINTS = "points";
  82. var STUDENT_POINTSBUMPRATIO = "pointsbumpratio";
  83. var STUDENT_REGKEY = "regkey";
  84. var STUDENT_STATUS = "status";
  85. var STUDENT_TEAMNAME = "teamname";
  86. var STUDENT_TEAMNAMEEDITED = "teamnameedited";
  87. var STUDENT_TOSTUDENT = "toemail";
  88. var STUDENT_TOSTUDENTCOMMENTS = "tostudentcomments";
  89. var STUDENT_TOSTUDENTNAME = "toname";
  90. // MESSAGES
  91. var MSG_COURSE_EXISTS = "course exists";
  92. var MSG_COURSE_NOTEAMS = "course has no teams";
  93. var MSG_EVALUATION_ADDED = "evaluation added";
  94. var MSG_EVALUATION_DEADLINEPASSED = "evaluation deadline passed";
  95. var MSG_EVALUATION_EDITED = "evaluation edited";
  96. var MSG_EVALUATION_EXISTS = "evaluation exists";
  97. var MSG_EVALUATION_UNABLETOCHANGETEAMS = "evaluation ongoing unable to change teams";
  98. var MSG_STUDENT_COURSEJOINED = "course joined";
  99. var MSG_STUDENT_GOOGLEIDEXISTSINCOURSE = "googleid exists in course";
  100. var MSG_STUDENT_REGISTRATIONKEYINVALID = "registration key invalid";
  101. var MSG_STUDENT_REGISTRATIONKEYTAKEN = "registration key taken";
  102. // GLOBAL VARIABLE
  103. var courseID = "ATD-TESTING.1.2.3";
  104. var courseName = "ATD TESTING IN PROGRESS";
  105. var evaluationName = "ATD TEST";
  106. /*
  107. * Returns
  108. *
  109. * 0: successful
  110. * 1: server error
  111. * 2: field(s) empty
  112. * 3: courseID invalid
  113. * 4: name invalid
  114. * 5: course exists
  115. *
  116. */
  117. function addCourse(courseID, courseName)
  118. {
  119. if(xmlhttp)
  120. {
  121. courseID = trim(courseID);
  122. courseName = trim(courseName);
  123. if(courseID == "" || courseName == "")
  124. {
  125. return 2;
  126. }
  127. else if(!isCourseIDValid(courseID))
  128. {
  129. return 3;
  130. }
  131. else if(!isCourseNameValid(courseName))
  132. {
  133. return 4;
  134. }
  135. else
  136. {
  137. xmlhttp.open("POST","teammates",false);
  138. xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;");
  139. xmlhttp.send("operation=" + OPERATION_COORDINATOR_ADDCOURSE + "&" + COURSE_ID + "=" + encodeURIComponent(courseID) +
  140. "&" + COURSE_NAME + "=" + encodeURIComponent(courseName));
  141. var results = handleAddCourse();
  142. return results;
  143. }
  144. }
  145. }
  146. /*
  147. * Returns
  148. *
  149. * 0: successful
  150. * 1: server error
  151. * 2: fields empty
  152. * 3: evaluation name invalid
  153. * 4: evaluation schedule invalid
  154. * 5: evaluation exists
  155. * 6: course has no teams
  156. *
  157. */
  158. function addEvaluation(courseID, name, instructions, commentsEnabled, start, startTime, deadline, deadlineTime, timeZone, gracePeriod)
  159. {
  160. if(courseID == "" || name == "" || start == "" || startTime == "" || deadline == "" || deadlineTime == "" ||
  161. timeZone == "" || gracePeriod == "" || instructions == "")
  162. {
  163. return 2;
  164. }
  165. else if(!isEvaluationNameValid(name))
  166. {
  167. return 3;
  168. }
  169. else if(!isAddEvaluationScheduleValid(start, startTime, deadline, deadlineTime))
  170. {
  171. return 4;
  172. }
  173. else
  174. {
  175. xmlhttp.open("POST","teammates",false);
  176. xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;");
  177. xmlhttp.send("operation=" + OPERATION_COORDINATOR_ADDEVALUATION + "&" + COURSE_ID + "=" + encodeURIComponent(courseID) +
  178. "&" + EVALUATION_NAME + "=" + encodeURIComponent(name) + "&" + EVALUATION_DEADLINE + "=" + encodeURIComponent(deadline) +
  179. "&" + EVALUATION_DEADLINETIME + "=" + encodeURIComponent(deadlineTime) +
  180. "&" + EVALUATION_INSTRUCTIONS + "=" + encodeURIComponent(instructions) + "&" +
  181. EVALUATION_START + "=" + encodeURIComponent(start) + "&" + EVALUATION_STARTTIME + "=" +
  182. encodeURIComponent(startTime) + "&" + EVALUATION_GRACEPERIOD + "=" + encodeURIComponent(gracePeriod) +
  183. "&" + EVALUATION_TIMEZONE + "=" + encodeURIComponent(timeZone) +
  184. "&" + EVALUATION_COMMENTSENABLED + "=" + encodeURIComponent(commentsEnabled));
  185. return handleAddEvaluation();
  186. }
  187. }
  188. function cleanUp()
  189. {
  190. if(xmlhttp)
  191. {
  192. xmlhttp.open("POST","teammates",false);
  193. xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;");
  194. xmlhttp.send("operation=" + OPERATION_ADMINISTRATOR_CLEANUP + "&" + COURSE_ID + "=" + encodeURIComponent(courseID));
  195. }
  196. }
  197. function clearATD()
  198. {
  199. deleteCourse(courseID);
  200. }
  201. function convertDateFromDDMMYYYYToMMDDYYYY(dateString)
  202. {
  203. var newDateString = dateString.substring(3,5) + "/" + dateString.substring(0,2) + "/" +
  204. dateString.substring(6,10);
  205. return newDateString;
  206. }
  207. function convertDateToDDMMYYYY(date)
  208. {
  209. var string;
  210. if(date.getDate() < 10)
  211. {
  212. string = "0" + date.getDate();
  213. }
  214. else
  215. {
  216. string = date.getDate();
  217. }
  218. string = string + "/";
  219. if(date.getMonth()+1 < 10)
  220. {
  221. string = string + "0" + (date.getMonth()+1);
  222. }
  223. else
  224. {
  225. string = string + (date.getMonth()+1);
  226. }
  227. string = string + "/" + date.getFullYear();
  228. return string;
  229. }
  230. function convertDateToHHMM(date)
  231. {
  232. var string;
  233. if(date.getHours() < 10)
  234. {
  235. string = "0" + date.getHours();
  236. }
  237. else
  238. {
  239. string = "" + date.getHours();
  240. }
  241. if(date.getMinutes() < 10)
  242. {
  243. string = string + "0" + date.getMinutes();
  244. }
  245. else
  246. {
  247. string = string + date.getMinutes();
  248. }
  249. return string;
  250. }
  251. function createEnrollmentInput(studentList)
  252. {
  253. var input = "";
  254. for(var x = 0; x < studentList.length; x++)
  255. {
  256. if(x % 2 == 0)
  257. {
  258. if(comments == "")
  259. {
  260. input = input + studentList[x].name + "\t" + studentList[x].email + "\t"
  261. + studentList[x].teamName + "\n";
  262. }
  263. else
  264. {
  265. input = input + studentList[x].name + "\t" + studentList[x].email + "\t"
  266. + studentList[x].teamName + "\t" + studentList[x].comments + "\n";
  267. }
  268. }
  269. else
  270. {
  271. if(comments == "")
  272. {
  273. input = input + studentList[x].name + "|" + studentList[x].email + "|"
  274. + studentList[x].teamName + "\n";
  275. }
  276. else
  277. {
  278. input = input + studentList[x].name + "|" + studentList[x].email + "|"
  279. + studentList[x].teamName + "|" + studentList[x].comments + "\n";
  280. }
  281. }
  282. }
  283. return input;
  284. }
  285. function createInvalidCourseList()
  286. {
  287. var courseList = new Array();
  288. var ID;
  289. var name;
  290. ID = "Invalid>";
  291. name = "Valid name";
  292. courseList[0] = {ID:ID, name:name};
  293. ID = "InvalidIDthisistoolongtobeacourseidomgveryveryveryverylong";
  294. name = "Valid";
  295. courseList[1] = {ID:ID, name:name};
  296. ID = "ValidID";
  297. name = "Invalid name this might be a tad too long to be a valid course name";
  298. courseList[2] = {ID:ID, name:name};
  299. ID = "Invalid%";
  300. name = "Valid Name";
  301. courseList[3] = {ID:ID, name:name};
  302. ID = "Invalid\"\"";
  303. name = "Valid Name";
  304. courseList[4] = {ID:ID, name:name};
  305. ID = "Invalid'";
  306. name = "Valid Name :;";
  307. courseList[5] = {ID:ID, name:name};
  308. ID = "Invalid@";
  309. name = "Valid Name :;";
  310. courseList[6] = {ID:ID, name:name};
  311. ID = "";
  312. name = "Valid Name :;";
  313. courseList[7] = {ID:ID, name:name};
  314. ID = "Invalid space";
  315. name = "Valid Name :;";
  316. courseList[8] = {ID:ID, name:name};
  317. ID = "<b>Invalid";
  318. name = "Valid Name :;";
  319. courseList[9] = {ID:ID, name:name};
  320. ID = "<b>Invalid";
  321. name = "";
  322. courseList[10] = {ID:ID, name:name};
  323. return courseList;
  324. }
  325. function createInvalidEvaluationList()
  326. {
  327. var name;
  328. var instructions;
  329. var commentsEnabled;
  330. var start;
  331. var startTime;
  332. var deadline;
  333. var deadlineTime;
  334. var gracePeriod;
  335. var evaluationList = new Array();
  336. name = "Invalid Name This is Way too Long to be an Evaluation Name";
  337. instructions = "Valid instructions ' &s <hi>";
  338. commentsEnabled = "true";
  339. start = "01/01/2018";
  340. startTime = "0100";
  341. deadline = "01/01/2018";
  342. deadlineTime = "2359";
  343. gracePeriod = "10";
  344. evaluationList[0] = { name:name, instructions:instructions, commentsEnabled:commentsEnabled, start:start,
  345. startTime:startTime, deadline:deadline, deadlineTime:deadlineTime, gracePeriod:gracePeriod};
  346. name = "<hi> '";
  347. instructions = "Valid instructions ' &s <hi> dwdwadw wadwadawdwaaaaaawaaaaaaaaaaa";
  348. commentsEnabled = "false";
  349. start = "01/01/2018";
  350. startTime = "0100";
  351. deadline = "01/01/2018";
  352. deadlineTime = "2359";
  353. gracePeriod = "10";
  354. evaluationList[1] = { name:name, instructions:instructions, commentsEnabled:commentsEnabled, start:start,
  355. startTime:startTime, deadline:deadline, deadlineTime:deadlineTime, gracePeriod:gracePeriod};
  356. name = "%s invalid";
  357. instructions = "Valid instructions ' &s <hi>";
  358. commentsEnabled = "false";
  359. start = "01/01/2018";
  360. startTime = "0100";
  361. deadline = "01/01/2018";
  362. deadlineTime = "2359";
  363. gracePeriod = "10";
  364. evaluationList[2] = { name:name, instructions:instructions, commentsEnabled:commentsEnabled, start:start,
  365. startTime:startTime, deadline:deadline, deadlineTime:deadlineTime, gracePeriod:gracePeriod};
  366. name = "Valid Name11";
  367. instructions = "Valid instructions ' &s <hi>";
  368. commentsEnabled = "false";
  369. start = "01/12/2018";
  370. startTime = "0100";
  371. deadline = "01/01/2018";
  372. deadlineTime = "2359";
  373. gracePeriod = "5";
  374. evaluationList[3] = { name:name, instructions:instructions, commentsEnabled:commentsEnabled, start:start,
  375. startTime:startTime, deadline:deadline, deadlineTime:deadlineTime, gracePeriod:gracePeriod};
  376. name = "Valid Name22";
  377. instructions = "Valid instructions ' &s <hi>";
  378. commentsEnabled = "true";
  379. start = "21/11/2018";
  380. startTime = "0100";
  381. deadline = "10/01/2018";
  382. deadlineTime = "2359";
  383. gracePeriod = "30";
  384. evaluationList[4] = { name:name, instructions:instructions, commentsEnabled:commentsEnabled, start:start,
  385. startTime:startTime, deadline:deadline, deadlineTime:deadlineTime, gracePeriod:gracePeriod};
  386. name = "Valid Name33";
  387. instructions = "Valid instructions ' &s <hi>";
  388. commentsEnabled = "false";
  389. start = "21/11/2019";
  390. startTime = "1100";
  391. deadline = "21/11/2019";
  392. deadlineTime = "1000";
  393. gracePeriod = "25";
  394. evaluationList[5] = { name:name, instructions:instructions, commentsEnabled:commentsEnabled, start:start,
  395. startTime:startTime, deadline:deadline, deadlineTime:deadlineTime, gracePeriod:gracePeriod};
  396. name = "Valid Name44";
  397. instructions = "Valid instructions ' &s <hi>";
  398. commentsEnabled = "false";
  399. start = "21/11/2019";
  400. startTime = "1100";
  401. deadline = "21/11/2019";
  402. deadlineTime = "1100";
  403. gracePeriod = "20";
  404. evaluationList[6] = { name:name, instructions:instructions, commentsEnabled:commentsEnabled, start:start,
  405. startTime:startTime, deadline:deadline, deadlineTime:deadlineTime, gracePeriod:gracePeriod};
  406. /* PHANTOM
  407. name = "Valid Name";
  408. instructions = "Valid instructionsk k' &s <hi>";
  409. commentsEnabled = "false";
  410. start = "22/01/2017";
  411. startTime = "0100";
  412. deadline = "21/01/2017";
  413. deadlineTime = "2359";
  414. gracePeriod = "10";
  415. evaluationList[7] = { name:name, instructions:instructions, commentsEnabled:commentsEnabled, start:start,
  416. startTime:startTime, deadline:deadline, deadlineTime:deadlineTime, gracePeriod:gracePeriod};
  417. */
  418. return evaluationList;
  419. }
  420. function createInvalidStudentList()
  421. {
  422. var studentList = new Array();
  423. name = "Name is longer than forty two forty two forty two characters";
  424. email = "validemail@gmail.com";
  425. teamName = "Good Team";
  426. comments = "";
  427. studentList[0] = {name:name, teamName:teamName, email:email, comments:comments};
  428. name = "Name has % chars";
  429. email = "validemail@gmail.com";
  430. teamName = "Good Team";
  431. comments = "";
  432. studentList[1] = {name:name, teamName:teamName, email:email, comments:comments};
  433. name = "Name has <b> chars";
  434. email = "validemail@gmail.com";
  435. teamName = "Good Team";
  436. comments = "Good comments";
  437. studentList[2] = {name:name, teamName:teamName, email:email, comments:comments};
  438. name = "Name has &d chars";
  439. email = "validemail@gmail.com";
  440. teamName = "Good Team";
  441. comments = "Good comments";
  442. studentList[3] = {name:name, teamName:teamName, email:email, comments:comments};
  443. name = "Name has &d chars";
  444. email = "validemail@gmail.com";
  445. teamName = "Good Team";
  446. comments = "Good comments";
  447. studentList[4] = {name:name, teamName:teamName, email:email, comments:comments};
  448. name = "Name has ^%@ chars";
  449. email = "validemail@gmail.com";
  450. teamName = "Good Team";
  451. comments = "";
  452. studentList[5] = {name:name, teamName:teamName, email:email, comments:comments};
  453. name = "Good Name";
  454. email = "emailhasnoatgmail.com";
  455. teamName = "Good Team";
  456. comments = "";
  457. studentList[6] = {name:name, teamName:teamName, email:email, comments:comments};
  458. name = "Good Name";
  459. email = "emailiswaytoolongmorethanfortycharacters@gmailveryveryverylong.com";
  460. teamName = "Good Team";
  461. comments = "Good Comments";
  462. studentList[7] = {name:name, teamName:teamName, email:email, comments:comments};
  463. name = "Good Name";
  464. email = "emailhas;@gmail.com";
  465. teamName = "Good Team";
  466. comments = "Good Comments";
  467. studentList[8] = {name:name, teamName:teamName, email:email, comments:comments};
  468. name = "Good Name";
  469. email = "emailhasa space@gmail.com";
  470. teamName = "Good Team";
  471. comments = "";
  472. studentList[9] = {name:name, teamName:teamName, email:email, comments:comments};
  473. name = "Good Name";
  474. email = "emailhasadollarsign@gmail$.com";
  475. teamName = "Good Team";
  476. comments = "";
  477. studentList[10] = {name:name, teamName:teamName, email:email, comments:comments};
  478. name = "Good Name";
  479. email = "validemail@gmail.com";
  480. teamName = "Team Name has more than twenty five characters which is a lot";
  481. comments = "Good comments";
  482. studentList[11] = {name:name, teamName:teamName, email:email, comments:comments};
  483. name = "Bad ' Name";
  484. email = "emailiswaytoolongmorethanfortycharacters@gmailveryveryverylong.com";
  485. teamName = "Good Team";
  486. comments = "Good Comments";
  487. studentList[12] = {name:name, teamName:teamName, email:email, comments:comments};
  488. name = "Good Name";
  489. email = "emailiswaytoolongmorethanfortycharacters@gmailveryveryverylong.com";
  490. teamName = "Team Name has more than twenty five characters which is a lot";
  491. comments = "Good Comments";
  492. studentList[13] = {name:name, teamName:teamName, email:email, comments:comments};
  493. name = "Bad \" Name";
  494. email = "validemail@gmail.com";
  495. teamName = "Team Name has more than twenty five characters which is a lot";
  496. comments = "";
  497. studentList[14] = {name:name, email:email, teamName:teamName, comments:comments};
  498. return studentList;
  499. }
  500. function createValidCourseList()
  501. {
  502. var courseList = new Array();
  503. var ID;
  504. var name;
  505. ID = "Valid-ID";
  506. name = "<b>Valid name</b>";
  507. courseList[0] = {ID:ID, name:name};
  508. ID = "ValidID-12345678901";
  509. name = "Valid name 1234567890123456789";
  510. courseList[1] = {ID:ID, name:name};
  511. ID = "ValidID.11-";
  512. name = "Valid name 1234567890123456789";
  513. courseList[2] = {ID:ID, name:name};
  514. return courseList;
  515. }
  516. function createValidEvaluationList()
  517. {
  518. var name;
  519. var instructions;
  520. var commentsEnabled;
  521. var start;
  522. var startTime;
  523. var deadline;
  524. var deadlineTime;
  525. var gracePeriod;
  526. // Make sure evaluation names differ
  527. var evaluationList = new Array();
  528. name = "Valid Name1";
  529. instructions = "Valid instructions ' &s <hi>";
  530. commentsEnabled = "true";
  531. start = "01/01/2019";
  532. startTime = "0100";
  533. deadline = "01/03/2019";
  534. deadlineTime = "2359";
  535. gracePeriod = "10";
  536. evaluationList[0] = { name:name, instructions:instructions, commentsEnabled:commentsEnabled, start:start,
  537. startTime:startTime, deadline:deadline, deadlineTime:deadlineTime, gracePeriod:gracePeriod};
  538. name = "Valid Name2";
  539. instructions = "Valid instructions ' &s <hi>";
  540. commentsEnabled = "false";
  541. start = "01/01/2019";
  542. startTime = "0100";
  543. deadline = "02/01/2019";
  544. deadlineTime = "2359";
  545. gracePeriod = "10";
  546. evaluationList[1] = { name:name, instructions:instructions, commentsEnabled:commentsEnabled, start:start,
  547. startTime:startTime, deadline:deadline, deadlineTime:deadlineTime, gracePeriod:gracePeriod};
  548. name = "Valid Name3";
  549. instructions = "Valid instructions ' &s <hi>";
  550. commentsEnabled = "true";
  551. start = "20/01/2019";
  552. startTime = "0100";
  553. deadline = "02/02/2019";
  554. deadlineTime = "2359";
  555. gracePeriod = "10";
  556. evaluationList[2] = { name:name, instructions:instructions, commentsEnabled:commentsEnabled, start:start,
  557. startTime:startTime, deadline:deadline, deadlineTime:deadlineTime, gracePeriod:gracePeriod};
  558. name = "Valid Name4";
  559. instructions = "Valid instructions ' &s <hi>";
  560. commentsEnabled = "true";
  561. start = "20/03/2018";
  562. startTime = "0100";
  563. deadline = "02/02/2019";
  564. deadlineTime = "2359";
  565. gracePeriod = "30";
  566. evaluationList[3] = { name:name, instructions:instructions, commentsEnabled:commentsEnabled, start:start,
  567. startTime:startTime, deadline:deadline, deadlineTime:deadlineTime, gracePeriod:gracePeriod};
  568. name = "Valid Name5";
  569. instructions = "Valid instructions ' &s <hi>";
  570. commentsEnabled = "false";
  571. start = "20/03/2018";
  572. startTime = "0100";
  573. deadline = "20/03/2019";
  574. deadlineTime = "2359";
  575. gracePeriod = "15";
  576. evaluationList[4] = { name:name, instructions:instructions, commentsEnabled:commentsEnabled, start:start,
  577. startTime:startTime, deadline:deadline, deadlineTime:deadlineTime, gracePeriod:gracePeriod};
  578. name = "Valid Name6";
  579. instructions = "Valid instructions ' &s <hi>";
  580. commentsEnabled = "true";
  581. start = "20/01/2018";
  582. startTime = "2300";
  583. deadline = "20/01/2018";
  584. deadlineTime = "2359";
  585. gracePeriod = "20";
  586. evaluationList[5] = { name:name, instructions:instructions, commentsEnabled:commentsEnabled, start:start,
  587. startTime:startTime, deadline:deadline, deadlineTime:deadlineTime, gracePeriod:gracePeriod};
  588. return evaluationList;
  589. }
  590. function createValidStudentList(numberOfStudents)
  591. {
  592. var studentList = new Array();
  593. for(var x = 0; x < numberOfStudents; x++)
  594. {
  595. name = "Good Name-.," + x;
  596. email = "validemail" + x + "@gmail.com";
  597. teamName = "Good Team" + (x%40);
  598. if(x%2 == 0)
  599. {
  600. comments = "Good Comments" + x;
  601. }
  602. else
  603. {
  604. comments = "";
  605. }
  606. googleID = "";
  607. studentList[x] = {name:name, email:email, teamName:teamName, googleID:googleID, comments:comments};
  608. }
  609. return studentList;
  610. }
  611. /*
  612. * Returns
  613. *
  614. * 0: successful
  615. * 1: server error
  616. */
  617. function deleteAllStudents(courseID)
  618. {
  619. if(xmlhttp)
  620. {
  621. xmlhttp.open("POST","teammates",false);
  622. xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;");
  623. xmlhttp.send("operation=" + OPERATION_COORDINATOR_DELETEALLSTUDENTS + "&" + COURSE_ID + "=" + encodeURIComponent(courseID));
  624. return handleDeleteAllStudents(courseID);
  625. }
  626. }
  627. /*
  628. * Returns
  629. *
  630. * 0: successful
  631. * 1: server error
  632. *
  633. */
  634. function deleteCourse(courseID)
  635. {
  636. if(xmlhttp)
  637. {
  638. xmlhttp.open("POST","teammates",false);
  639. xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;");
  640. xmlhttp.send("operation=" + OPERATION_COORDINATOR_DELETECOURSE + "&" + COURSE_ID + "=" + encodeURIComponent(courseID));
  641. return handleDeleteCourse();
  642. }
  643. }
  644. /*
  645. * Returns
  646. *
  647. * 0: successful
  648. * 1: server error
  649. *
  650. */
  651. function deleteEvaluation(courseID, name)
  652. {
  653. if(xmlhttp)
  654. {
  655. xmlhttp.open("POST","teammates",false);
  656. xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;");
  657. xmlhttp.send("operation=" + OPERATION_COORDINATOR_DELETEEVALUATION + "&" + COURSE_ID + "="
  658. + encodeURIComponent(courseID) + "&" + EVALUATION_NAME + "=" + encodeURIComponent(name));
  659. return handleDeleteEvaluation();
  660. }
  661. }
  662. /*
  663. * Returns
  664. *
  665. * 0: successful
  666. * 1: server error
  667. */
  668. function deleteStudent(courseID, studentEmail)
  669. {
  670. if(xmlhttp)
  671. {
  672. xmlhttp.open("POST","teammates",false);
  673. xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;");
  674. xmlhttp.send("operation=" + OPERATION_COORDINATOR_DELETESTUDENT + "&" + COURSE_ID + "=" +
  675. encodeURIComponent(courseID) + "&" + STUDENT_EMAIL + "=" + encodeURIComponent(studentEmail));
  676. return handleDeleteStudent();
  677. }
  678. }
  679. /*
  680. * Returns
  681. *
  682. * 0: successful
  683. * 1: server error
  684. * 2: deadline passed
  685. * 3: fields missing
  686. *
  687. */
  688. function editEvaluationResults(submissionList, commentsEnabled)
  689. {
  690. for(loop = 0; loop < submissionList.length; loop++)
  691. {
  692. if(submissionList[loop].commentsToStudent == "" && commentsEnabled == true)
  693. {
  694. return 2;
  695. }
  696. if(submissionList[loop].justification == "")
  697. {
  698. return 2;
  699. }
  700. if( submissionList[loop].points == -999)
  701. {
  702. return 2;
  703. }
  704. if(!commentsEnabled)
  705. {
  706. submissionList[loop].commentsToStudent = "";
  707. }
  708. }
  709. var request = "operation=" + OPERATION_COORDINATOR_EDITEVALUATIONRESULTS + "&" + STUDENT_NUMBEROFSUBMISSIONS +
  710. "=" + submissionList.length + "&" + COURSE_ID + "=" + submissionList[0].courseID +
  711. "&" + EVALUATION_NAME + "=" + submissionList[0].evaluationName +
  712. "&" + STUDENT_TEAMNAME + "=" + submissionList[0].teamName;
  713. for(loop = 0; loop < submissionList.length; loop++)
  714. {
  715. request = request + "&" + STUDENT_FROMSTUDENT + loop + "=" +
  716. encodeURIComponent(submissionList[loop].fromStudent) + "&" +
  717. STUDENT_TOSTUDENT + loop + "=" +
  718. encodeURIComponent(submissionList[loop].toStudent) + "&" +
  719. STUDENT_POINTS + loop + "=" +
  720. encodeURIComponent(submissionList[loop].points) + "&" +
  721. STUDENT_JUSTIFICATION + loop + "=" +
  722. encodeURIComponent(submissionList[loop].justification) + "&" +
  723. STUDENT_COMMENTSTOSTUDENT + loop + "=" +
  724. encodeURIComponent(submissionList[loop].commentsToStudent);
  725. }
  726. if(xmlhttp)
  727. {
  728. xmlhttp.open("POST","teammates",false);
  729. xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;");
  730. xmlhttp.send(request);
  731. return handleEditEvaluationResults();
  732. }
  733. }
  734. /*
  735. * Returns
  736. *
  737. * 0: successful
  738. * 1: server error
  739. * 2: unable to change teams
  740. *
  741. */
  742. function editStudent(courseID, email, editName, editTeamName, editEmail, editGoogleID, editComments)
  743. {
  744. editName = trim(editName);
  745. editTeamName = trim(editTeamName);
  746. editEmail = trim(editEmail);
  747. editGoogleID = trim(editGoogleID);
  748. if(isEditStudentInputValid(editName, editTeamName, editEmail, editGoogleID))
  749. {
  750. if(xmlhttp)
  751. {
  752. xmlhttp.open("POST","teammates",false);
  753. xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;");
  754. xmlhttp.send("operation=" + OPERATION_COORDINATOR_EDITSTUDENT + "&" + COURSE_ID + "=" +
  755. encodeURIComponent(courseID) + "&" + STUDENT_EMAIL + "=" + encodeURIComponent(email) +
  756. "&" + STUDENT_EDITNAME + "=" + encodeURIComponent(editName) + "&" + STUDENT_EDITTEAMNAME + "=" + encodeURIComponent(editTeamName) +
  757. "&" + STUDENT_EDITEMAIL + "=" + encodeURIComponent(editEmail) + "&" + STUDENT_EDITGOOGLEID + "=" + encodeURIComponent(editGoogleID) +
  758. "&" + STUDENT_EDITCOMMENTS + "=" + encodeURIComponent(editComments));
  759. return handleEditStudent();
  760. }
  761. }
  762. }
  763. function editStudentListNameTeamComments(studentList)
  764. {
  765. for(var x = 0; x < studentList.length; x++)
  766. {
  767. if(x % 2 == 0)
  768. {
  769. studentList[x].name = studentList[x].name + x;
  770. }
  771. if(x % 3 == 0)
  772. {
  773. studentList[x].teamName = studentList[x].teamName + x;
  774. }
  775. if(x % 4 == 0)
  776. {
  777. studentList[x].comments = studentList[x].comments + x;
  778. }
  779. }
  780. return studentList;
  781. }
  782. function editStudentListNameTeamCommentsGoogleIDEmail(studentList)
  783. {
  784. for(var x = 0; x < studentList.length; x++)
  785. {
  786. if(x % 2 == 0)
  787. {
  788. studentList[x].name = studentList[x].name + x;
  789. }
  790. if(x % 3 == 0)
  791. {
  792. studentList[x].teamName = studentList[x].teamName + x;
  793. }
  794. if(x % 4 == 0)
  795. {
  796. studentList[x].comments = studentList[x].comments + x;
  797. }
  798. if(x % 5 == 0)
  799. {
  800. studentList[x].googleID = studentList[x].googleID + x;
  801. }
  802. if(x % 6 == 0)
  803. {
  804. studentList[x].email = x + studentList[x].email;
  805. }
  806. }
  807. return studentList;
  808. }
  809. /*
  810. * Returns
  811. *
  812. * reports: successful
  813. * 1: server error
  814. * 2: input empty
  815. * 3: input invalid
  816. *
  817. */
  818. function enrolStudents(input, courseID)
  819. {
  820. input = replaceAll(input,"|","\t");
  821. if(xmlhttp)
  822. {
  823. // Remove trailing "\n"
  824. if(input.lastIndexOf("\n") == input.length-1)
  825. {
  826. input = input.substring(0, input.length-1);
  827. }
  828. if(input == "")
  829. {
  830. return 2;
  831. }
  832. else if(isEnrollmentInputValid(input))
  833. {
  834. xmlhttp.open("POST","teammates",false);
  835. xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;");
  836. xmlhttp.send("operation=" + OPERATION_COORDINATOR_ENROLSTUDENTS + "&" + STUDENT_INFORMATION
  837. + "=" + encodeURIComponent(input) + "&" + COURSE_ID + "=" + encodeURIComponent(courseID));
  838. return handleEnrolStudents();
  839. }
  840. else
  841. {
  842. return 3;
  843. }
  844. }
  845. }
  846. /*
  847. * Returns
  848. *
  849. * courseList: successful
  850. * 1: server error
  851. *
  852. */
  853. function getCourseList()
  854. {
  855. if(xmlhttp)
  856. {
  857. xmlhttp.open("POST","teammates",false);
  858. xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;");
  859. xmlhttp.send("operation=" + OPERATION_COORDINATOR_GETCOURSELIST);
  860. return handleGetCourseList();
  861. }
  862. }
  863. /*
  864. * Returns
  865. *
  866. * evaluationList: successful
  867. * 1: server error
  868. *
  869. */
  870. function getEvaluationList()
  871. {
  872. if(xmlhttp)
  873. {
  874. OPERATION_CURRENT = OPERATION_COORDINATOR_GETEVALUATIONLIST;
  875. xmlhttp.open("POST","teammates",false);
  876. xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;");
  877. xmlhttp.send("operation=" + OPERATION_COORDINATOR_GETEVALUATIONLIST);
  878. return handleGetEvaluationList();
  879. }
  880. }
  881. /*
  882. * Returns
  883. *
  884. * studentList: successful
  885. * 1: server error
  886. *
  887. */
  888. function getStudentList(courseID)
  889. {
  890. if(xmlhttp)
  891. {
  892. xmlhttp.open("POST","teammates",false);
  893. xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;");
  894. xmlhttp.send("operation=" + OPERATION_COORDINATOR_GETSTUDENTLIST + "&" + COURSE_ID + "=" + encodeURIComponent(courseID));
  895. return handleGetStudentList();
  896. }
  897. }
  898. /*
  899. * Returns
  900. *
  901. * submissionList: successful
  902. * 1: server error
  903. *
  904. */
  905. function getSubmissionList(courseID, evaluationName)
  906. {
  907. if(xmlhttp)
  908. {
  909. xmlhttp.open("POST","teammates",false);
  910. xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;");
  911. xmlhttp.send("operation=" + OPERATION_COORDINATOR_GETSUBMISSIONLIST + "&" + COURSE_ID + "=" +
  912. encodeURIComponent(courseID) + "&" + EVALUATION_NAME + "=" + encodeURIComponent(evaluationName));
  913. return handleGetSubmissionList();
  914. }
  915. }
  916. // IMPORTANT: DUE TO SAME FUNCTION NAME IN BOTH COORDINATOR AND STUDENT JS FILES, THE GETSUBMISSIONLIST
  917. // AND HANDLEGETSUBMISSIONLIST FUNCTIONS FOR STUDENTS HAVE BEEN RENAMED WITH A POSTFIX OF "Student".
  918. // MOREOVER, PLEASE EDIT THE METHOD TO CALL THE CORRECT HANDLER FUNCTION
  919. /*
  920. * Returns
  921. *
  922. * submissionList: successful
  923. * 1: server error
  924. *
  925. */
  926. function getSubmissionListStudent(courseID, evaluationName)
  927. {
  928. if(xmlhttp)
  929. {
  930. xmlhttp.open("POST","teammates",false);
  931. xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;");
  932. xmlhttp.send("operation=" + OPERATION_STUDENT_GETSUBMISSIONLIST + "&" + COURSE_ID + "=" +
  933. encodeURIComponent(courseID) + "&" + EVALUATION_NAME + "=" + encodeURIComponent(evaluationName));
  934. return handleGetSubmissionListStudent();
  935. }
  936. }
  937. /*
  938. * Returns
  939. *
  940. * submissionList: successful
  941. * 1: server error
  942. *
  943. */
  944. function getSubmissionResultsList(courseID, evaluationName)
  945. {
  946. if(xmlhttp)
  947. {
  948. xmlhttp.open("POST","teammates",false);
  949. xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;");
  950. xmlhttp.send("operation=" + OPERATION_STUDENT_GETSUBMISSIONRESULTSLIST + "&" + COURSE_ID + "=" +
  951. encodeURIComponent(courseID) + "&" + EVALUATION_NAME + "=" + encodeURIComponent(evaluationName));
  952. return handleGetSubmissionResultsList();
  953. }
  954. }
  955. function getXMLObject()
  956. {
  957. var xmlHttp = false;
  958. try {
  959. xmlHttp = new ActiveXObject("Msxml2.XMLHTTP")
  960. }
  961. catch (e) {
  962. try {
  963. xmlHttp = new ActiveXObject("Microsoft.XMLHTTP")
  964. }
  965. catch (e2) {
  966. xmlHttp = false
  967. }
  968. }
  969. if (!xmlHttp && typeof XMLHttpRequest != 'undefined') {
  970. xmlHttp = new XMLHttpRequest();
  971. }
  972. return xmlHttp;
  973. }
  974. /*
  975. * Returns
  976. *
  977. * 0: successful
  978. * 1: server error
  979. * 5: course exists
  980. *
  981. */
  982. function handleAddCourse()
  983. {
  984. if (xmlhttp.status == 200)
  985. {
  986. var status = xmlhttp.responseXML.getElementsByTagName("status")[0];
  987. var message;
  988. if(status != null)
  989. {
  990. var message = status.firstChild.nodeValue;
  991. if(message == MSG_COURSE_EXISTS)
  992. {
  993. return 5;
  994. }
  995. else
  996. {
  997. return 0;
  998. }
  999. }
  1000. }
  1001. else
  1002. {
  1003. return 1;
  1004. }
  1005. }
  1006. /*
  1007. * Returns
  1008. *
  1009. * 0: successful
  1010. * 1: server error
  1011. * 5: evaluation exists
  1012. * 6: course has no teams
  1013. *
  1014. */
  1015. function handleAddEvaluation()
  1016. {
  1017. if (xmlhttp.status == 200)
  1018. {
  1019. var status = xmlhttp.responseXML.getElementsByTagName("status")[0];
  1020. var message;
  1021. if(status != null)
  1022. {
  1023. var message = status.firstChild.nodeValue;
  1024. if(message == MSG_EVALUATION_EXISTS)
  1025. {
  1026. return 5;
  1027. }
  1028. else if(message == MSG_COURSE_NOTEAMS)
  1029. {
  1030. return 6;
  1031. }
  1032. else
  1033. {
  1034. return 0;
  1035. }
  1036. }
  1037. }
  1038. else
  1039. {
  1040. return 1;
  1041. }
  1042. }
  1043. /*
  1044. * Returns
  1045. *
  1046. * 0: successful
  1047. * 1: server error
  1048. *
  1049. */
  1050. function handleDeleteAllStudents(courseID)
  1051. {
  1052. if(xmlhttp)
  1053. {
  1054. return 0;
  1055. }
  1056. else
  1057. {
  1058. return 1;
  1059. }
  1060. }
  1061. /*
  1062. * Returns
  1063. *
  1064. * 0: successful
  1065. * 1: server error
  1066. *
  1067. */
  1068. function handleDeleteCourse()
  1069. {
  1070. if(xmlhttp)
  1071. {
  1072. return 0;
  1073. }
  1074. else
  1075. {
  1076. return 1;
  1077. }
  1078. }
  1079. /*
  1080. * Returns
  1081. *
  1082. * 0: successful
  1083. * 1: server error
  1084. *
  1085. */
  1086. function handleDeleteEvaluation()
  1087. {
  1088. if(xmlhttp)
  1089. {
  1090. return 0;
  1091. }
  1092. else
  1093. {
  1094. return 1;
  1095. }
  1096. }
  1097. /*
  1098. * Returns
  1099. *
  1100. * 0: successful
  1101. * 1: server error
  1102. *
  1103. */
  1104. function handleDeleteStudent()
  1105. {
  1106. if(xmlhttp.status == 200)
  1107. {
  1108. return 0;
  1109. }
  1110. else
  1111. {
  1112. return 1;
  1113. }
  1114. }
  1115. /*
  1116. * Returns
  1117. *
  1118. * 0: successful
  1119. * 1: server error
  1120. *
  1121. */
  1122. function handleEditEvaluationResults()
  1123. {
  1124. if(xmlhttp.status == 200)
  1125. {
  1126. return 0;
  1127. }
  1128. else
  1129. {
  1130. return 1;
  1131. }
  1132. }
  1133. /*
  1134. * Returns
  1135. *
  1136. * 0: successful
  1137. * 1: server error
  1138. * 2: unable to change teams
  1139. *
  1140. */
  1141. function handleEditStudent()
  1142. {
  1143. if (xmlhttp.status == 200)
  1144. {
  1145. var status = xmlhttp.responseXML.getElementsByTagName("status")[0];
  1146. if(status != null)
  1147. {
  1148. var message = status.firstChild.nodeValue;
  1149. if(message == MSG_EVALUATION_UNABLETOCHANGETEAMS)
  1150. {
  1151. return 2;
  1152. }
  1153. else
  1154. {
  1155. return 0;
  1156. }
  1157. }
  1158. }
  1159. else
  1160. {
  1161. return 1;
  1162. }
  1163. }
  1164. /*
  1165. * Returns
  1166. *
  1167. * reports: successful
  1168. * 1: server error
  1169. *
  1170. */
  1171. function handleEnrolStudents()
  1172. {
  1173. if (xmlhttp.status == 200)
  1174. {
  1175. var enrollmentReports = xmlhttp.responseXML.getElementsByTagName("enrollmentreports")[0];
  1176. if(enrollmentReports != null)
  1177. {
  1178. var enrollmentReport;
  1179. var studentName;
  1180. var studentEmail;
  1181. var status;
  1182. var nameEdited;
  1183. var teamNameEdited;
  1184. var commentsEdited;
  1185. var reports = [];
  1186. for(loop = 0; loop < enrollmentReports.childNodes.length; loop++)
  1187. {
  1188. enrollmentReport = enrollmentReports.childNodes[loop];
  1189. studentName = enrollmentReport.getElementsByTagName(STUDENT_NAME)[0].firstChild.nodeValue;
  1190. studentEmail = enrollmentReport.getElementsByTagName(STUDENT_EMAIL)[0].firstChild.nodeValue;
  1191. status = enrollmentReport.getElementsByTagName(STUDENT_STATUS)[0].firstChild.nodeValue;
  1192. nameEdited = enrollmentReport.getElementsByTagName(STUDENT_NAMEEDITED)[0].firstChild.nodeValue;
  1193. teamNameEdited = enrollmentReport.getElementsByTagName(STUDENT_TEAMNAMEEDITED)[0].firstChild.nodeValue;
  1194. commentsEdited = enrollmentReport.getElementsByTagName(STUDENT_COMMENTSEDITED)[0].firstChild.nodeValue;
  1195. enrollmentReport = {studentName:studentName, studentEmail:studentEmail,
  1196. nameEdited:nameEdited, teamNameEdited:teamNameEdited, commentsEdited:commentsEdited, status:status};
  1197. reports.push(enrollmentReport);
  1198. }
  1199. }
  1200. return reports;
  1201. }
  1202. else
  1203. {
  1204. return 1;
  1205. }
  1206. }
  1207. /*
  1208. * Returns
  1209. *
  1210. * courseList: successful
  1211. * 1: server error
  1212. *
  1213. */
  1214. function handleGetCourseList()
  1215. {
  1216. if (xmlhttp.status == 200)
  1217. {
  1218. var courses = xmlhttp.responseXML.getElementsByTagName("courses")[0];
  1219. var courseList = new Array();
  1220. if(courses != null)
  1221. {
  1222. var course;
  1223. var ID;
  1224. var name;
  1225. var numberOfTeams;
  1226. var status;
  1227. for(loop = 0; loop < courses.childNodes.length; loop++)
  1228. {
  1229. course = courses.childNodes[loop];
  1230. ID = course.getElementsByTagName(COURSE_ID)[0].firstChild.nodeValue;
  1231. name = course.getElementsByTagName(COURSE_NAME)[0].firstChild.nodeValue;
  1232. numberOfTeams = course.getElementsByTagName(COURSE_NUMBEROFTEAMS)[0].firstChild.nodeValue;
  1233. status = course.getElementsByTagName(COURSE_STATUS)[0].firstChild.nodeValue;
  1234. courseList[loop] = {ID:ID, name:name, numberOfTeams:numberOfTeams, status:status};
  1235. }
  1236. }
  1237. return courseList;
  1238. }
  1239. else
  1240. {
  1241. return 1;
  1242. }
  1243. }
  1244. /*
  1245. * Returns
  1246. *
  1247. * evaluationList: successful
  1248. * 1: server error
  1249. *
  1250. */
  1251. function handleGetEvaluationList()
  1252. {
  1253. if (xmlhttp.status == 200)
  1254. {
  1255. var evaluations = xmlhttp.responseXML.getElementsByTagName("evaluations")[0];
  1256. var evaluationList = new Array();
  1257. var now = new Date();
  1258. var evaluation;
  1259. var courseID;
  1260. var name;
  1261. var commentsEnabled;
  1262. var instructions;
  1263. var start;
  1264. var deadline;
  1265. var gracePeriod;
  1266. var numberOfCompletedEvaluations;
  1267. var numberOfEvaluations;
  1268. var published;
  1269. var status;
  1270. var activated;
  1271. if(evaluations != null)
  1272. {
  1273. for(loop = 0; loop < evaluations.childNodes.length; loop++)
  1274. {
  1275. evaluation = evaluations.childNodes[loop];
  1276. courseID = evaluation.getElementsByTagName(COURSE_ID)[0].firstChild.nodeValue;
  1277. name = evaluation.getElementsByTagName(EVALUATION_NAME)[0].firstChild.nodeValue;
  1278. commentsEnabled = (evaluation.getElementsByTagName(EVALUATION_COMMENTSENABLED)[0].firstChild.nodeValue.toLowerCase() == "true");
  1279. instructions = evaluation.getElementsByTagName(EVALUATION_INSTRUCTIONS)[0].firstChild.nodeValue;
  1280. start = new Date(evaluation.getElementsByTagName(EVALUATION_START)[0].firstChild.nodeValue);
  1281. deadline = new Date(evaluation.getElementsByTagName(EVALUATION_DEADLINE)[0].firstChild.nodeValue);
  1282. timeZone = parseFloat(evaluation.getElementsByTagName(EVALUATION_TIMEZONE)[0].firstChild.nodeValue);
  1283. gracePeriod = parseInt(evaluation.getElementsByTagName(EVALUATION_GRACEPERIOD)[0].firstChild.nodeValue);
  1284. published = (evaluation.getElementsByTagName(EVALUATION_PUBLISHED)[0].firstChild.nodeValue.toLowerCase() == "true");
  1285. activated = (evaluation.getElementsByTagName(EVALUATION_ACTIVATED)[0].firstChild.nodeValue.toLowerCase() == "true");
  1286. numberOfCompletedEvaluations = parseInt(evaluation.getElementsByTagName(EVALUATION_NUMBEROFCOMPLETEDEVALUATIONS)[0].firstChild.nodeValue);
  1287. numberOfEvaluations = parseInt(evaluation.getElementsByTagName(EVALUATION_NUMBEROFEVALUATIONS)[0].firstChild.nodeValue);
  1288. // Convert local time zone to ms
  1289. var nowTime = now.getTime();
  1290. // Obtain local time zone offset
  1291. var localOffset = now.getTimezoneOffset() * 60000;
  1292. // Obtain UTC time
  1293. var UTC = nowTime + localOffset;
  1294. // Add the time zone of evaluation
  1295. var nowMilliS = UTC + (timeZone * 60 * 60 * 1000);
  1296. now.setTime(nowMilliS);
  1297. // Check if evaluation should be open or closed
  1298. if(now > start && deadline > now)
  1299. {
  1300. status = "OPEN";
  1301. }
  1302. else if(now > deadline || activated)
  1303. {
  1304. status = "CLOSED";
  1305. }
  1306. else if (now < start && !activated)
  1307. {
  1308. status = "AWAITING";
  1309. }
  1310. if(published == true)
  1311. {
  1312. status = "PUBLISHED";
  1313. }
  1314. evaluationList[loop] = { courseID:courseID, name:name, commentsEnabled:commentsEnabled, instructions:instructions,
  1315. start:start, deadline:deadline, timeZone:timeZone, gracePeriod:gracePeriod, published:published,
  1316. published:published, activated:activated, numberOfCompletedEvaluations:numberOfCompletedEvaluations,
  1317. numberOfEvaluations:numberOfEvaluations, status:status};
  1318. }
  1319. }
  1320. return evaluationList;
  1321. }
  1322. else
  1323. {
  1324. 1;
  1325. }
  1326. }
  1327. /*
  1328. * Returns
  1329. *
  1330. * studentList: successful
  1331. * 1: server error
  1332. *
  1333. */
  1334. function handleGetStudentList()
  1335. {
  1336. if (xmlhttp.status == 200)
  1337. {
  1338. var students = xmlhttp.responseXML.getElementsByTagName("students")[0];
  1339. var studentList = new Array();
  1340. var student;
  1341. var name;
  1342. var teamName;
  1343. var email;
  1344. var registrationKey;
  1345. var comments;
  1346. var courseID;
  1347. var googleID;
  1348. for(var loop = 0; loop < students.childNodes.length; loop++)
  1349. {
  1350. student = students.childNodes[loop];
  1351. name = student.getElementsByTagName(STUDENT_NAME)[0].firstChild.nodeValue;
  1352. teamName = student.getElementsByTagName(STUDENT_TEAMNAME)[0].firstChild.nodeValue;
  1353. email = student.getElementsByTagName(STUDENT_EMAIL)[0].firstChild.nodeValue;
  1354. registrationKey = student.getElementsByTagName(STUDENT_REGKEY)[0].firstChild.nodeValue;
  1355. googleID = student.getElementsByTagName(STUDENT_ID)[0].firstChild.nodeValue;
  1356. comments = student.getElementsByTagName(STUDENT_COMMENTS)[0].firstChild.nodeValue;
  1357. courseID = student.getElementsByTagName(STUDENT_COURSEID)[0].firstChild.nodeValue;
  1358. studentList[loop] = {name:name, teamName:teamName, email:email, registrationKey:registrationKey, googleID:googleID,
  1359. comments:comments, courseID:courseID};
  1360. }
  1361. return studentList;
  1362. }
  1363. else
  1364. {
  1365. return 1;
  1366. }
  1367. }
  1368. /*
  1369. * Returns
  1370. *
  1371. * submissionList: successful
  1372. * 1: server error
  1373. *
  1374. */
  1375. function handleGetSubmissionList()
  1376. {
  1377. if(xmlhttp.status == 200)
  1378. {
  1379. var submissions = xmlhttp.responseXML.getElementsByTagName("submissions")[0];
  1380. var submissionList = new Array();
  1381. var submission;
  1382. var fromStudentName;
  1383. var toStudentName;
  1384. var fromStudent;
  1385. var toStudent;
  1386. var fromStudentComments;
  1387. var toStudentComments;
  1388. var courseID;
  1389. var evaluationName;
  1390. var teamName;
  1391. var points;
  1392. var pointsBumpRatio;
  1393. var justification;
  1394. var commentsToStudent;
  1395. if(submissions != null)
  1396. {
  1397. for(loop = 0; loop < submissions.childNodes.length; loop++)
  1398. {
  1399. submission = submissions.childNodes[loop];
  1400. fromStudentName = submission.getElementsByTagName(STUDENT_FROMSTUDENTNAME)[0].firstChild.nodeValue;
  1401. fromStudent = submission.getElementsByTagName(STUDENT_FROMSTUDENT)[0].firstChild.nodeValue;
  1402. toStudentName = submission.getElementsByTagName(STUDENT_TOSTUDENTNAME)[0].firstChild.nodeValue;
  1403. toStudent = submission.getElementsByTagName(STUDENT_TOSTUDENT)[0].firstChild.nodeValue;
  1404. fromStudentComments = submission.getElementsByTagName(STUDENT_FROMSTUDENTCOMMENTS)[0].firstChild.nodeValue;
  1405. toStudentComments = submission.getElementsByTagName(STUDENT_TOSTUDENTCOMMENTS)[0].firstChild.nodeValue;
  1406. courseID = submission.getElementsByTagName(COURSE_ID)[0].firstChild.nodeValue;
  1407. evaluationName = submission.getElementsByTagName(EVALUATION_NAME)[0].firstChild.nodeValue;
  1408. teamName = submission.getElementsByTagName(STUDENT_TEAMNAME)[0].firstChild.nodeValue;
  1409. points = parseInt(submission.getElementsByTagName(STUDENT_POINTS)[0].firstChild.nodeValue);
  1410. pointsBumpRatio = parseFloat(submission.getElementsByTagName(STUDENT_POINTSBUMPRATIO)[0].firstChild.nodeValue);
  1411. justification = submission.getElementsByTagName(STUDENT_JUSTIFICATION)[0].firstChild.nodeValue;
  1412. commentsToStudent = submission.getElementsByTagName(STUDENT_COMMENTSTOSTUDENT)[0].firstChild.nodeValue;
  1413. submissionList[loop] = {fromStudentName:fromStudentName, toStudentName:toStudentName,
  1414. fromStudent:fromStudent, toStudent:toStudent, courseID:courseID,
  1415. evaluationName:evaluationName, teamName:teamName, justification:justification,
  1416. commentsToStudent:commentsToStudent, points:points, pointsBumpRatio:pointsBumpRatio,
  1417. fromStudentComments:fromStudentComments, toStudentComments:toStudentComments};
  1418. }
  1419. }
  1420. return submissionList;
  1421. }
  1422. else
  1423. {
  1424. return 1;
  1425. }
  1426. }
  1427. /*
  1428. * Returns
  1429. *
  1430. * submissionList: successful
  1431. * 1: server error
  1432. *
  1433. */
  1434. function handleGetSubmissionListStudent()
  1435. {
  1436. if(xmlhttp.status == 200)
  1437. {
  1438. var submissions = xmlhttp.responseXML.getElementsByTagName("submissions")[0];
  1439. var submissionList = new Array();
  1440. var submission;
  1441. var fromStudentName;
  1442. var toStudentName;
  1443. var fromStudent;
  1444. var toStudent;
  1445. var courseID;
  1446. var evaluationName;
  1447. var teamName;
  1448. var points;
  1449. var justification;
  1450. var commentsToStudent;
  1451. if(submissions != null)
  1452. {
  1453. for(loop = 0; loop < submissions.childNodes.length; loop++)
  1454. {
  1455. submission = submissions.childNodes[loop];
  1456. fromStudentName = submission.getElementsByTagName(STUDENT_FROMSTUDENTNAME)[0].firstChild.nodeValue;
  1457. fromStudent = submission.getElementsByTagName(STUDENT_FROMSTUDENT)[0].firstChild.nodeValue;
  1458. toStudentName = submission.getElementsByTagName(STUDENT_TOSTUDENTNAME)[0].firstChild.nodeValue;
  1459. toStudent = submission.getElementsByTagName(STUDENT_TOSTUDENT)[0].firstChild.nodeValue;
  1460. courseID = submission.getElementsByTagName(COURSE_ID)[0].firstChild.nodeValue;
  1461. evaluationName = submission.getElementsByTagName(EVALUATION_NAME)[0].firstChild.nodeValue;
  1462. teamName = submission.getElementsByTagName(STUDENT_TEAMNAME)[0].firstChild.nodeValue;
  1463. points = parseInt(submission.getElementsByTagName(STUDENT_POINTS)[0].firstChild.nodeValue);
  1464. justification = submission.getElementsByTagName(STUDENT_JUSTIFICATION)[0].firstChild.nodeValue;
  1465. commentsToStudent = submission.getElementsByTagName(STUDENT_COMMENTSTOSTUDENT)[0].firstChild.nodeValue;
  1466. submissionList[loop] = {fromStudentName:fromStudentName, toStudentName:toStudentName,
  1467. fromStudent:fromStudent, toStudent:toStudent, courseID:courseID,
  1468. evaluationName:evaluationName, teamName:teamName, justification:justification,
  1469. commentsToStudent:commentsToStudent, points:points};
  1470. }
  1471. }
  1472. return submissionList;
  1473. }
  1474. else
  1475. {
  1476. return 1;
  1477. }
  1478. }
  1479. /*
  1480. * Returns
  1481. *
  1482. * submissionList: successful
  1483. * 1: server error
  1484. *
  1485. */
  1486. function handleGetSubmissionResultsList()
  1487. {
  1488. if(xmlhttp.status == 200)
  1489. {
  1490. var submissions = xmlhttp.responseXML.getElementsByTagName("submissions")[0];
  1491. var submissionList = new Array();
  1492. var submission;
  1493. var fromStudentName;
  1494. var toStudentName;
  1495. var fromStudent;
  1496. var toStudent;
  1497. var fromStudentComments;
  1498. var toStudentComments;
  1499. var courseID;
  1500. var evaluationName;
  1501. var teamName;
  1502. var points;
  1503. var pointsBumpRatio;
  1504. var justification;
  1505. var commentsToStudent;
  1506. if(submissions != null)
  1507. {
  1508. for(loop = 0; loop < submissions.childNodes.length; loop++)
  1509. {
  1510. submission = submissions.childNodes[loop];
  1511. fromStudentName = submission.getElementsByTagName(STUDENT_FROMSTUDENTNAME)[0].firstChild.nodeValue;
  1512. fromStudent = submission.getElementsByTagName(STUDENT_FROMSTUDENT)[0].firstChild.nodeValue;
  1513. toStudentName = submission.getElementsByTagName(STUDENT_TOSTUDENTNAME)[0].firstChild.nodeValue;
  1514. toStudent = submission.getElementsByTagName(STUDENT_TOSTUDENT)[0].firstChild.nodeValue;
  1515. fromStudentComments = submission.getElementsByTagName(STUDENT_FROMSTUDENTCOMMENTS)[0].firstChild.nodeValue;
  1516. toStudentComments = submission.getElementsByTagName(STUDENT_TOSTUDENTCOMMENTS)[0].firstChild.nodeValue;
  1517. courseID = submission.getElementsByTagName(COURSE_ID)[0].firstChild.nodeValue;
  1518. evaluationName = submission.getElementsByTagName(EVALUATION_NAME)[0].firstChild.nodeValue;
  1519. teamName = submission.getElementsByTagName(STUDENT_TEAMNAME)[0].firstChild.nodeValue;
  1520. points = parseInt(submission.getElementsByTagName(STUDENT_POINTS)[0].firstChild.nodeValue);
  1521. pointsBumpRatio = parseFloat(submission.getElementsByTagName(STUDENT_POINTSBUMPRATIO)[0].firstChild.nodeValue);
  1522. justification = submission.getElementsByTagName(STUDENT_JUSTIFICATION)[0].firstChild.nodeValue;
  1523. commentsToStudent = submission.getElementsByTagName(STUDENT_COMMENTSTOSTUDENT)[0].firstChild.nodeValue;
  1524. submissionList[loop] = {fromStudentName:fromStudentName, toStudentName:toStudentName,
  1525. fromStudent:fromStudent, toStudent:toStudent, courseID:courseID,
  1526. evaluationName:evaluationName, teamName:teamName, justification:justification,
  1527. commentsToStudent:commentsToStudent, points:points, pointsBumpRatio:pointsBumpRatio,
  1528. fromStudentComments:fromStudentComments, toStudentComments:toStudentComments};
  1529. }
  1530. }
  1531. return submissionList;
  1532. }
  1533. else
  1534. {
  1535. return 1;
  1536. }
  1537. }
  1538. /*
  1539. * Returns
  1540. *
  1541. * 0: successful
  1542. * 1: server error
  1543. * 2: google ID already exists in course
  1544. * 3: registration key invalid
  1545. * 4: registration key taken
  1546. *
  1547. */
  1548. function handleJoi

Large files files are truncated, but you can click here to view the full file