PageRenderTime 67ms CodeModel.GetById 31ms RepoModel.GetById 1ms app.codeStats 0ms

/code/war/js/student.js

https://code.google.com/p/teammatespes/
JavaScript | 1582 lines | 1123 code | 265 blank | 194 comment | 180 complexity | 41f3197f87e987addb8e9f595304e879 MD5 | raw file
  1. // AJAX
  2. var xmlhttp = new getXMLObject();
  3. // DISPLAY
  4. var DISPLAY_COURSE_DELETED = "The course has been deleted.";
  5. var DISPLAY_COURSE_ARCHIVED = "The course has been archived.";
  6. var DISPLAY_COURSE_UNARCHIVED = "The course has been unarchived.";
  7. var DISPLAY_EVALUATION_DEADLINEPASSED = "The evaluation deadline has passed.";
  8. var DISPLAY_EVALUATION_SUBMITTED = "The evaluation has been submitted.";
  9. var DISPLAY_FIELDS_EMPTY = "<FONT color=\"red\">Please fill in all the relevant fields.</font>";
  10. var DISPLAY_LOADING = "<img src=images/ajax-loader.gif /><br />";
  11. var DISPLAY_SERVERERROR = "Connection to the server has timed out. Please refresh the page.";
  12. var DISPLAY_STUDENT_GOOGLEIDEXISTSINCOURSE = "<FONT color=\"red\">You are already registered in the course.</font>";
  13. var DISPLAY_STUDENT_JOINEDCOURSE = "You have successfully joined the course.";
  14. var DISPLAY_STUDENT_REGISTRATIONKEYINVALID = "<FONT color=\"red\">Registration key is invalid.</font>";
  15. var DISPLAY_STUDENT_REGISTRATIONKEYTAKEN = "<FONT color=\"red\">Registration key has been taken by another student.</font>";
  16. // DIV
  17. var DIV_COURSE_INFORMATION = "studentCourseInformation";
  18. var DIV_COURSE_MANAGEMENT = "studentCourseManagement";
  19. var DIV_COURSE_TABLE = "studentCourseTable";
  20. var DIV_EVALUATION_INFORMATION = "studentEvaluationInformation";
  21. var DIV_EVALUATION_PAST = "studentPastEvaluations";
  22. var DIV_EVALUATION_PENDING = "studentPendingEvaluations";
  23. var DIV_EVALUATION_RESULTS = "studentEvaluationResults";
  24. var DIV_EVALUATION_SUBMISSIONS = "studentEvaluationSubmissions";
  25. var DIV_EVALUATION_SUBMISSIONBUTTONS = "studentEvaluationSubmissionButtons";
  26. var DIV_HEADER_OPERATION = "headerOperation";
  27. var DIV_STATUS = "statusMessage";
  28. var DIV_TOPOFPAGE = "topOfPage";
  29. // GLOBAL VARIABLES FOR GUI
  30. var courseSort = { ID:0, name:1 }
  31. var courseSortStatus = courseSort.name;
  32. var courseViewArchived = { show:0, hide:1 }
  33. var courseViewArchivedStatus = courseViewArchived.hide;
  34. var evaluationSort = { courseID:0, name:1 }
  35. var evaluationSortStatus = evaluationSort.courseID;
  36. // MESSAGES
  37. var MSG_EVALUATION_DEADLINEPASSED = "evaluation deadline passed";
  38. var MSG_STUDENT_COURSEJOINED = "course joined";
  39. var MSG_STUDENT_GOOGLEIDEXISTSINCOURSE = "googleid exists in course";
  40. var MSG_STUDENT_REGISTRATIONKEYINVALID = "registration key invalid";
  41. var MSG_STUDENT_REGISTRATIONKEYTAKEN = "registration key taken";
  42. // OPERATIONS
  43. var OPERATION_STUDENT_ARCHIVECOURSE = "student_archivecourse";
  44. var OPERATION_STUDENT_DELETECOURSE = "student_deletecourse";
  45. var OPERATION_STUDENT_GETCOURSE = "student_getcourse";
  46. var OPERATION_STUDENT_GETCOURSELIST = "student_getcourselist";
  47. var OPERATION_STUDENT_GETPASTEVALUATIONLIST = "student_getpastevaluationlist";
  48. var OPERATION_STUDENT_GETPENDINGEVALUATIONLIST = "student_getpendingevaluationlist";
  49. var OPERATION_STUDENT_GETSUBMISSIONLIST = "student_getsubmissionlist";
  50. var OPERATION_STUDENT_GETSUBMISSIONRESULTSLIST = "student_getsubmissionresultslist";
  51. var OPERATION_STUDENT_JOINCOURSE = "student_joincourse";
  52. var OPERATION_STUDENT_LOGOUT = "student_logout";
  53. var OPERATION_STUDENT_SUBMITEVALUATION = "student_submitevaluation";
  54. var OPERATION_STUDENT_UNARCHIVECOURSE = "student_unarchivecourse";
  55. // PARAMETERS
  56. var COURSE_COORDINATORNAME = "coordinatorname";
  57. var COURSE_ID = "courseid";
  58. var COURSE_NAME = "coursename";
  59. var COURSE_STATUS = "coursestatus";
  60. var EVALUATION_COMMENTSENABLED = "commentsstatus";
  61. var EVALUATION_DEADLINE = "deadline";
  62. var EVALUATION_DEADLINETIME = "deadlinetime";
  63. var EVALUATION_GRACEPERIOD = "graceperiod";
  64. var EVALUATION_INSTRUCTIONS = "instr";
  65. var EVALUATION_NAME = "evaluationname";
  66. var EVALUATION_PUBLISHED = "published";
  67. var EVALUATION_START = "start";
  68. var EVALUATION_STARTTIME = "starttime";
  69. var EVALUATION_TIMEZONE = "timezone";
  70. var STUDENT_COMMENTSTOSTUDENT = "commentstostudent";
  71. var STUDENT_EMAIL = "email";
  72. var STUDENT_FROMSTUDENT = "fromemail";
  73. var STUDENT_FROMSTUDENTCOMMENTS = "fromstudentcomments";
  74. var STUDENT_FROMSTUDENTNAME = "fromname";
  75. var STUDENT_JUSTIFICATION = "justification";
  76. var STUDENT_NAME = "name";
  77. var STUDENT_NUMBEROFSUBMISSIONS = "numberofsubmissions";
  78. var STUDENT_POINTS = "points";
  79. var STUDENT_POINTSBUMPRATIO = "pointsbumpratio";
  80. var STUDENT_REGKEY = "regkey";
  81. var STUDENT_TEAMMATE = "teammate";
  82. var STUDENT_TEAMMATES = "teammates";
  83. var STUDENT_TEAMNAME = "teamname";
  84. var STUDENT_TOSTUDENT = "toemail";
  85. var STUDENT_TOSTUDENTCOMMENTS = "tostudentcomments";
  86. var STUDENT_TOSTUDENTNAME = "toname";
  87. /*
  88. * Returns
  89. *
  90. * 0: successful
  91. * 1: server error
  92. *
  93. */
  94. function archiveCourse(courseID)
  95. {
  96. if(xmlhttp)
  97. {
  98. xmlhttp.open("POST","teammates",false);
  99. xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;");
  100. xmlhttp.send("operation=" + OPERATION_STUDENT_ARCHIVECOURSE + "&" + COURSE_ID + "=" + encodeURIComponent(courseID));
  101. return handleArchiveCourse();
  102. }
  103. }
  104. function clearAllDisplay()
  105. {
  106. document.getElementById(DIV_COURSE_INFORMATION).innerHTML = "";
  107. document.getElementById(DIV_COURSE_MANAGEMENT).innerHTML = "";
  108. document.getElementById(DIV_COURSE_TABLE).innerHTML = "";
  109. document.getElementById(DIV_EVALUATION_INFORMATION).innerHTML = "";
  110. document.getElementById(DIV_EVALUATION_PAST).innerHTML = "";
  111. document.getElementById(DIV_EVALUATION_PENDING).innerHTML = "";
  112. document.getElementById(DIV_EVALUATION_RESULTS).innerHTML = "";
  113. document.getElementById(DIV_EVALUATION_SUBMISSIONBUTTONS).innerHTML = "";
  114. document.getElementById(DIV_EVALUATION_SUBMISSIONS).innerHTML = "";
  115. document.getElementById(DIV_HEADER_OPERATION).innerHTML = "";
  116. document.getElementById(DIV_STATUS).innerHTML = "";
  117. document.getElementById(DIV_TOPOFPAGE).innerHTML = "";
  118. }
  119. function compileSubmissionsIntoSummaryList(submissionList)
  120. {
  121. var summaryList = new Array();
  122. var exists = false;
  123. var toStudent;
  124. var toStudentName;
  125. var toStudentComments;
  126. var totalPoints;
  127. var totalPointGivers;
  128. var claimedPoints;
  129. var teamName;
  130. var average;
  131. var difference;
  132. var submitted;
  133. var pointsBumpRatio;
  134. var count = 0;
  135. for(loop = 0; loop < submissionList.length; loop++)
  136. {
  137. exists = false;
  138. submitted = false;
  139. for(x = 0; x < summaryList.length; x++)
  140. {
  141. if(summaryList[x].toStudent == submissionList[loop].toStudent)
  142. {
  143. exists = true;
  144. }
  145. }
  146. if(exists == false)
  147. {
  148. toStudent = submissionList[loop].toStudent;
  149. toStudentName = submissionList[loop].toStudentName;
  150. toStudentComments = submissionList[loop].toStudentComments;
  151. teamName = submissionList[loop].teamName;
  152. totalPoints = 0;
  153. totalPointGivers = 0;
  154. for(y = loop; y < submissionList.length; y++)
  155. {
  156. if(submissionList[y].toStudent == toStudent)
  157. {
  158. if(submissionList[y].fromStudent == toStudent)
  159. {
  160. if(submissionList[y].points == -999 || submissionList[y].points == -101)
  161. {
  162. claimedPoints = "N/A";
  163. }
  164. else
  165. {
  166. // Should not alter student's own claimed points for student's view
  167. claimedPoints = submissionList[y].points;
  168. }
  169. if(submissionList[y].points != -999)
  170. {
  171. submitted = true;
  172. }
  173. }
  174. else
  175. {
  176. if(submissionList[y].points != -999 && submissionList[y].points != -101)
  177. {
  178. totalPoints += submissionList[y].points * submissionList[y].pointsBumpRatio;
  179. totalPointGivers++;
  180. }
  181. }
  182. }
  183. }
  184. if(totalPointGivers != 0)
  185. {
  186. average = Math.round(totalPoints / totalPointGivers);
  187. }
  188. else
  189. {
  190. average = "N/A";
  191. }
  192. if(claimedPoints != "N/A" && average != "N/A")
  193. {
  194. difference = Math.round(average-claimedPoints);
  195. }
  196. else
  197. {
  198. difference = "N/A";
  199. }
  200. summaryList[count++] = { toStudent:toStudent, toStudentName:toStudentName, teamName:teamName,
  201. average:average, difference:difference, toStudentComments:toStudentComments, submitted:submitted,
  202. claimedPoints:claimedPoints};
  203. }
  204. }
  205. // Find normalizing points bump ratio for averages
  206. var teamsNormalized = new Array();
  207. count = 0;
  208. for(loop = 0; loop < summaryList.length; loop++)
  209. {
  210. // Reset variables
  211. exists = false;
  212. totalPoints = 0;
  213. totalGivers = 0;
  214. pointsBumpRatio = 0;
  215. // Check if the team is added
  216. for(y = 0; y < teamsNormalized.length; y++)
  217. {
  218. if(summaryList[loop].teamName == teamsNormalized[y].teamName)
  219. {
  220. exists = true;
  221. break;
  222. }
  223. }
  224. if(exists == false)
  225. {
  226. // Tabulate the perceived scores
  227. for(y = loop; y < summaryList.length; y++)
  228. {
  229. if(summaryList[y].teamName == summaryList[loop].teamName && summaryList[y].average != "N/A")
  230. {
  231. totalPoints += summaryList[y].average;
  232. totalGivers += 1;
  233. }
  234. }
  235. if(totalGivers != 0)
  236. {
  237. pointsBumpRatio = totalGivers * 100 / totalPoints;
  238. // Store the bump ratio
  239. teamsNormalized[count++] = {pointsBumpRatio:pointsBumpRatio, teamName:teamName};
  240. }
  241. }
  242. }
  243. // Do the normalization
  244. for(loop = 0; loop < teamsNormalized.length; loop++)
  245. {
  246. for(y = 0; y < summaryList.length; y++)
  247. {
  248. if(summaryList[y].teamName == teamsNormalized[loop].teamName && summaryList[y].average != "N/A")
  249. {
  250. summaryList[y].average = Math.round(summaryList[y].average * teamsNormalized[loop].pointsBumpRatio);
  251. if(summaryList[y].claimedPoints != "N/A")
  252. {
  253. summaryList[y].difference = Math.round(summaryList[y].average-summaryList[y].claimedPoints);
  254. }
  255. else
  256. {
  257. summaryList[y].difference = "N/A";
  258. }
  259. }
  260. }
  261. }
  262. return summaryList;
  263. }
  264. function convertDateToDDMMYYYY(date)
  265. {
  266. var string;
  267. if(date.getDate() < 10)
  268. {
  269. string = "0" + date.getDate();
  270. }
  271. else
  272. {
  273. string = date.getDate();
  274. }
  275. string = string + "/";
  276. if(date.getMonth()+1 < 10)
  277. {
  278. string = string + "0" + (date.getMonth()+1);
  279. }
  280. else
  281. {
  282. string = string + (date.getMonth()+1);
  283. }
  284. string = string + "/" + date.getFullYear();
  285. return string;
  286. }
  287. function convertDateToHHMM(date)
  288. {
  289. var string;
  290. if(date.getHours() < 10)
  291. {
  292. string = "0" + date.getHours();
  293. }
  294. else
  295. {
  296. string = "" + date.getHours();
  297. }
  298. if(date.getMinutes() < 10)
  299. {
  300. string = string + "0" + date.getMinutes();
  301. }
  302. else
  303. {
  304. string = string + date.getMinutes();
  305. }
  306. return string;
  307. }
  308. function displayCourseInformation(courseID)
  309. {
  310. clearAllDisplay();
  311. doGetCourse(courseID);
  312. }
  313. function displayCoursesTab()
  314. {
  315. clearAllDisplay();
  316. setStatusMessage(DISPLAY_LOADING);
  317. printJoinCourse();
  318. doGetCourseList();
  319. document.getElementById(DIV_TOPOFPAGE).scrollIntoView(true);
  320. }
  321. function displayEvaluationsTab()
  322. {
  323. clearAllDisplay();
  324. setStatusMessage(DISPLAY_LOADING);
  325. doGetPendingEvaluationList();
  326. doGetPastEvaluationList();
  327. clearStatusMessage();
  328. document.getElementById(DIV_TOPOFPAGE).scrollIntoView(true);
  329. }
  330. function displayEvaluationSubmission(evaluationList, loop)
  331. {
  332. var courseID = evaluationList[loop].courseID;
  333. var courseName = evaluationList[loop].courseName;
  334. var evaluationName = evaluationList[loop].name;
  335. var instructions = evaluationList[loop].instructions;
  336. var start = evaluationList[loop].start;
  337. var deadline = evaluationList[loop].deadline;
  338. var gracePeriod = evaluationList[loop].gracePeriod;
  339. var commentsEnabled = evaluationList[loop].commentsEnabled;
  340. clearAllDisplay();
  341. printEvaluationHeader(courseID, evaluationName, start, deadline, gracePeriod, instructions, commentsEnabled);
  342. doGetSubmissionList(courseID, evaluationName, commentsEnabled);
  343. document.getElementById(DIV_TOPOFPAGE).scrollIntoView(true);
  344. }
  345. function displayEvaluationResults(evaluationList, loop)
  346. {
  347. var courseID = evaluationList[loop].courseID;
  348. var courseName = evaluationList[loop].courseName;
  349. var evaluationName = evaluationList[loop].name;
  350. var instructions = evaluationList[loop].instructions;
  351. var start = evaluationList[loop].start;
  352. var deadline = evaluationList[loop].deadline;
  353. var gracePeriod = evaluationList[loop].gracePeriod;
  354. var commentsEnabled = evaluationList[loop].commentsEnabled;
  355. clearAllDisplay();
  356. doGetSubmissionResultsList(courseID, evaluationName, start, deadline);
  357. document.getElementById(DIV_TOPOFPAGE).scrollIntoView(true);
  358. }
  359. //function displayEvaluationPoints(points){
  360. //
  361. // delta = null;
  362. //
  363. // if(points > 100){
  364. // delta = points - 100;
  365. // return "Equal Share + " + delta + "%";
  366. // }
  367. // else if(points < 100){
  368. // delta = 100 - points;
  369. // return "Equal Share - " + delta + "%";
  370. // }
  371. // else {
  372. // return "Equal Share";
  373. // }
  374. //
  375. //}
  376. function doArchiveCourse(courseID)
  377. {
  378. setStatusMessage(DISPLAY_LOADING);
  379. var results = archiveCourse(courseID);
  380. if(results == 0)
  381. {
  382. doGetCourseList();
  383. setStatusMessage(DISPLAY_COURSE_ARCHIVED);
  384. }
  385. else
  386. {
  387. alert(DISPLAY_SERVERERROR);
  388. }
  389. }
  390. function doGetCompletedEvaluation(courseID, name)
  391. {
  392. setStatusMessage(DISPLAY_LOADING);
  393. var results = getEvaluation(courseID, name);
  394. }
  395. function doGetCourse(courseID)
  396. {
  397. setStatusMessage(DISPLAY_LOADING);
  398. var results = getCourse(courseID);
  399. if(results != 1)
  400. {
  401. printCourseStudentForm(results);
  402. }
  403. else
  404. {
  405. alert(DISPLAY_SERVERERROR);
  406. }
  407. }
  408. function doGetCourseList()
  409. {
  410. setStatusMessage(DISPLAY_LOADING);
  411. var results = getCourseList();
  412. clearStatusMessage();
  413. if(results != 1)
  414. {
  415. // toggleSortCoursesByID calls printCourseList too
  416. printCourseList(results, STUDENT);
  417. if(courseSortStatus == courseSort.name)
  418. {
  419. toggleSortCoursesByName(results);
  420. }
  421. else
  422. {
  423. toggleSortCoursesByID(results);
  424. }
  425. }
  426. else
  427. {
  428. alert(DISPLAY_SERVERERROR);
  429. }
  430. }
  431. function doGetPastEvaluationList()
  432. {
  433. setStatusMessage(DISPLAY_LOADING);
  434. var results = getPastEvaluationList();
  435. clearStatusMessage();
  436. if(results != 1)
  437. {
  438. printPastEvaluationList(results);
  439. // Toggle calls printPastEvaluationList too
  440. if(evaluationSortStatus == evaluationSort.name)
  441. {
  442. toggleSortPastEvaluationsByName(results);
  443. }
  444. else
  445. {
  446. toggleSortPastEvaluationsByCourseID(results);
  447. }
  448. }
  449. else
  450. {
  451. alert(DISPLAY_SERVERERROR);
  452. }
  453. }
  454. function doGetPendingEvaluationList()
  455. {
  456. setStatusMessage(DISPLAY_LOADING);
  457. var results = getPendingEvaluationList();
  458. clearStatusMessage();
  459. if(results != 1)
  460. {
  461. printPendingEvaluationList(results);
  462. }
  463. else
  464. {
  465. alert(DISPLAY_SERVERERROR);
  466. }
  467. }
  468. function doGetSubmissionList(courseID, evaluationName, commentsEnabled)
  469. {
  470. setStatusMessage(DISPLAY_LOADING);
  471. var results = getSubmissionList(courseID, evaluationName);
  472. clearStatusMessage();
  473. if(results != 1)
  474. {
  475. printSubmissionForm(results, commentsEnabled);
  476. }
  477. else
  478. {
  479. alert(DISPLAY_SERVERERROR);
  480. }
  481. }
  482. function doGetSubmissionResultsList(courseID, evaluationName, start, deadline)
  483. {
  484. setStatusMessage(DISPLAY_LOADING);
  485. var results = getSubmissionResultsList(courseID, evaluationName);
  486. clearStatusMessage();
  487. if(results != 1)
  488. {
  489. printEvaluationResultStudentForm(compileSubmissionsIntoSummaryList(results), results, start, deadline);
  490. }
  491. else
  492. {
  493. alert(DISPLAY_SERVERERROR);
  494. }
  495. }
  496. function doJoinCourse(registrationKey)
  497. {
  498. setStatusMessage(DISPLAY_LOADING);
  499. var results = joinCourse(registrationKey);
  500. displayCoursesTab();
  501. if(results == 0)
  502. {
  503. setStatusMessage(DISPLAY_STUDENT_JOINEDCOURSE);
  504. }
  505. else if(results == 1)
  506. {
  507. alert(DISPLAY_SERVERERROR);
  508. }
  509. else if(results == 2)
  510. {
  511. setStatusMessage(DISPLAY_STUDENT_GOOGLEIDEXISTSINCOURSE);
  512. }
  513. else if(results == 3)
  514. {
  515. setStatusMessage(DISPLAY_STUDENT_REGISTRATIONKEYINVALID);
  516. }
  517. else if(results == 4)
  518. {
  519. setStatusMessage(DISPLAY_STUDENT_REGISTRATIONKEYTAKEN);
  520. }
  521. }
  522. function doLeaveCourse(courseID)
  523. {
  524. setStatusMessage(DISPLAY_LOADING);
  525. var results = leaveCourse(courseID);
  526. if(results == 0)
  527. {
  528. doGetCourseList();
  529. setStatusMessage(DISPLAY_COURSE_DELETED);
  530. }
  531. else
  532. {
  533. alert(DISPLAY_SERVERERROR);
  534. }
  535. }
  536. function doSubmitEvaluation(form, length, commentsEnabled)
  537. {
  538. setStatusMessage(DISPLAY_LOADING);
  539. var submissionList = extractSubmissionList(form, length);
  540. var results = submitEvaluation(submissionList, commentsEnabled);
  541. if(results == 0)
  542. {
  543. displayEvaluationsTab();
  544. setStatusMessage(DISPLAY_EVALUATION_SUBMITTED);
  545. }
  546. else if(results == 2)
  547. {
  548. displayEvaluationsTab();
  549. setStatusMessage(DISPLAY_EVALUATION_DEADLINEPASSED);
  550. }
  551. else if(results == 3)
  552. {
  553. setStatusMessage(DISPLAY_FIELDS_EMPTY);
  554. }
  555. else
  556. {
  557. alert(DISPLAY_SERVERERROR);
  558. }
  559. }
  560. function doUnarchiveCourse(courseID)
  561. {
  562. setStatusMessage(DISPLAY_LOADING);
  563. var results = unarchiveCourse(courseID);
  564. if(results == 0)
  565. {
  566. doGetCourseList();
  567. setStatusMessage(DISPLAY_COURSE_UNARCHIVED);
  568. }
  569. else
  570. {
  571. alert(DISPLAY_SERVERERROR);
  572. }
  573. }
  574. function extractSubmissionList(form, length)
  575. {
  576. var submissionList = [];
  577. var fromStudent;
  578. var toStudent;
  579. var courseID;
  580. var evaluationName;
  581. var teamName;
  582. var points;
  583. var justification;
  584. var commentsToStudent;
  585. var counter = 0;
  586. var len = length * 8;
  587. for(loop = 0; loop < len; loop++)
  588. {
  589. fromStudent = form.elements[loop++].value;
  590. toStudent = form.elements[loop++].value;
  591. courseID = form.elements[loop++].value;
  592. evaluationName = form.elements[loop++].value;
  593. teamName = form.elements[loop++].value;
  594. points = form.elements[loop++].value;
  595. if(form.elements[loop].disabled == false)
  596. {
  597. justification = form.elements[loop++].value;
  598. }
  599. else
  600. {
  601. justification = "";
  602. loop++;
  603. }
  604. if(form.elements[loop].disabled == false)
  605. {
  606. commentsToStudent = form.elements[loop].value;
  607. }
  608. else
  609. {
  610. commentsToStudent = "";
  611. }
  612. submissionList[counter++] = {fromStudent:fromStudent, toStudent:toStudent, courseID:courseID,
  613. evaluationName:evaluationName, teamName:teamName, points:points,
  614. justification:justification, commentsToStudent:commentsToStudent};
  615. }
  616. return submissionList;
  617. }
  618. /*
  619. * Returns
  620. *
  621. * course: successful
  622. * 1: server error
  623. *
  624. */
  625. function getCourse(courseID)
  626. {
  627. if(xmlhttp)
  628. {
  629. xmlhttp.open("POST","teammates",false);
  630. xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;");
  631. xmlhttp.send("operation=" + OPERATION_STUDENT_GETCOURSE + "&" + COURSE_ID + "=" + encodeURIComponent(courseID));
  632. return handleGetCourse();
  633. }
  634. }
  635. /*
  636. * Returns
  637. *
  638. * courseList: successful
  639. * 1: server error
  640. *
  641. */
  642. function getCourseList()
  643. {
  644. if(xmlhttp)
  645. {
  646. xmlhttp.open("POST","teammates",false);
  647. xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;");
  648. xmlhttp.send("operation=" + OPERATION_STUDENT_GETCOURSELIST);
  649. return handleGetCourseList();
  650. }
  651. }
  652. function getDateWithTimeZoneOffset(timeZone)
  653. {
  654. var now = new Date();
  655. // Convert local time zone to ms
  656. var nowTime = now.getTime();
  657. // Obtain local time zone offset
  658. var localOffset = now.getTimezoneOffset() * 60000;
  659. // Obtain UTC time
  660. var UTC = nowTime + localOffset;
  661. // Add the time zone of evaluation
  662. var nowMilliS = UTC + (timeZone * 60 * 60 * 1000);
  663. now.setTime(nowMilliS);
  664. return now;
  665. }
  666. /*
  667. * Returns
  668. *
  669. * evaluationList: successful
  670. * 1: server error
  671. *
  672. */
  673. function getPastEvaluationList()
  674. {
  675. if(xmlhttp)
  676. {
  677. xmlhttp.open("POST","teammates",false);
  678. xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;");
  679. xmlhttp.send("operation=" + OPERATION_STUDENT_GETPASTEVALUATIONLIST);
  680. return handleGetEvaluationList();
  681. }
  682. }
  683. /*
  684. * Returns
  685. *
  686. * evaluationList: successful
  687. * 1: server error
  688. *
  689. */
  690. function getPendingEvaluationList()
  691. {
  692. if(xmlhttp)
  693. {
  694. xmlhttp.open("POST","teammates",false);
  695. xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;");
  696. xmlhttp.send("operation=" + OPERATION_STUDENT_GETPENDINGEVALUATIONLIST);
  697. return handleGetEvaluationList();
  698. }
  699. }
  700. /*
  701. * Returns
  702. *
  703. * submissionList: successful
  704. * 1: server error
  705. *
  706. */
  707. function getSubmissionList(courseID, evaluationName)
  708. {
  709. if(xmlhttp)
  710. {
  711. xmlhttp.open("POST","teammates",false);
  712. xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;");
  713. xmlhttp.send("operation=" + OPERATION_STUDENT_GETSUBMISSIONLIST + "&" + COURSE_ID + "=" +
  714. encodeURIComponent(courseID) + "&" + EVALUATION_NAME + "=" + encodeURIComponent(evaluationName));
  715. return handleGetSubmissionList();
  716. }
  717. }
  718. /*
  719. * Returns
  720. *
  721. * submissionList: successful
  722. * 1: server error
  723. *
  724. */
  725. function getSubmissionResultsList(courseID, evaluationName)
  726. {
  727. if(xmlhttp)
  728. {
  729. xmlhttp.open("POST","teammates",false);
  730. xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;");
  731. xmlhttp.send("operation=" + OPERATION_STUDENT_GETSUBMISSIONRESULTSLIST + "&" + COURSE_ID + "=" +
  732. encodeURIComponent(courseID) + "&" + EVALUATION_NAME + "=" + encodeURIComponent(evaluationName));
  733. return handleGetSubmissionResultsList();
  734. }
  735. }
  736. function getXMLObject()
  737. {
  738. var xmlHttp = false;
  739. try {
  740. xmlHttp = new ActiveXObject("Msxml2.XMLHTTP")
  741. }
  742. catch (e) {
  743. try {
  744. xmlHttp = new ActiveXObject("Microsoft.XMLHTTP")
  745. }
  746. catch (e2) {
  747. xmlHttp = false
  748. }
  749. }
  750. if (!xmlHttp && typeof XMLHttpRequest != 'undefined') {
  751. xmlHttp = new XMLHttpRequest();
  752. }
  753. return xmlHttp;
  754. }
  755. /*
  756. * Returns
  757. *
  758. * 0: successful
  759. * 1: server error
  760. *
  761. */
  762. function handleArchiveCourse()
  763. {
  764. if(xmlhttp.status == 200)
  765. {
  766. return 0;
  767. }
  768. else
  769. {
  770. return 1;
  771. }
  772. }
  773. /*
  774. * Returns
  775. *
  776. * course: successful
  777. * 1: server error
  778. *
  779. */
  780. function handleGetCourse()
  781. {
  782. if (xmlhttp.status == 200)
  783. {
  784. clearStatusMessage();
  785. var course = xmlhttp.responseXML.getElementsByTagName("coursedetails")[0];
  786. var courseID = course.getElementsByTagName(COURSE_ID)[0].firstChild.nodeValue;
  787. var courseName = course.getElementsByTagName(COURSE_NAME)[0].firstChild.nodeValue;
  788. var coordinatorName = course.getElementsByTagName(COURSE_COORDINATORNAME)[0].firstChild.nodeValue;
  789. var studentTeamName = course.getElementsByTagName(STUDENT_TEAMNAME)[0].firstChild.nodeValue;
  790. var studentName = course.getElementsByTagName(STUDENT_NAME)[0].firstChild.nodeValue;
  791. var studentEmail = course.getElementsByTagName(STUDENT_EMAIL)[0].firstChild.nodeValue;
  792. var teammates = course.getElementsByTagName(STUDENT_TEAMMATES)[0];
  793. var teammateList = new Array();
  794. var len = teammates.childNodes.length;
  795. for(var x = 0; x < len; x++)
  796. {
  797. teammateList[x] = teammates.getElementsByTagName(STUDENT_TEAMMATE)[x].firstChild.nodeValue;
  798. }
  799. var course = {courseID:courseID, courseName:courseName, coordinatorName:coordinatorName,
  800. studentTeamName:studentTeamName, studentName:studentName, studentEmail:studentEmail, teammateList:teammateList};
  801. return course;
  802. }
  803. else
  804. {
  805. return 1;
  806. }
  807. }
  808. /*
  809. * Returns
  810. *
  811. * courseList: successful
  812. * 1: server error
  813. *
  814. */
  815. function handleGetCourseList()
  816. {
  817. if (xmlhttp.status == 200)
  818. {
  819. var courses = xmlhttp.responseXML.getElementsByTagName("courses")[0];
  820. var courseList = new Array();
  821. if(courses != null)
  822. {
  823. var course;
  824. var id;
  825. var name;
  826. var teamName;
  827. var status;
  828. var len = courses.childNodes.length;
  829. for(loop = 0; loop < len; loop++)
  830. {
  831. course = courses.childNodes[loop];
  832. ID = course.getElementsByTagName(COURSE_ID)[0].firstChild.nodeValue;
  833. name = course.getElementsByTagName(COURSE_NAME)[0].firstChild.nodeValue;
  834. teamName = course.getElementsByTagName(STUDENT_TEAMNAME)[0].firstChild.nodeValue;
  835. status = course.getElementsByTagName(COURSE_STATUS)[0].firstChild.nodeValue;
  836. courseList[loop] = {ID:ID, name:name, teamName:teamName, status:status};
  837. }
  838. }
  839. return courseList;
  840. }
  841. else
  842. {
  843. return 1;
  844. }
  845. }
  846. /*
  847. * Returns
  848. *
  849. * evaluationList: successful
  850. * 1: server error
  851. *
  852. */
  853. function handleGetEvaluationList()
  854. {
  855. if(xmlhttp.status == 200)
  856. {
  857. var evaluations = xmlhttp.responseXML.getElementsByTagName("evaluations")[0];
  858. var evaluationList = [];
  859. var evaluation;
  860. var courseID;
  861. var name;
  862. var startString;
  863. var start;
  864. var deadlineString;
  865. var deadline;
  866. var timeZone;
  867. var gracePeriod;
  868. var instructions;
  869. var commentsEnabled;
  870. var published;
  871. var len = evaluations.childNodes.length;
  872. for(loop = 0; loop < len; loop++)
  873. {
  874. evaluation = evaluations.childNodes[loop];
  875. courseID = evaluation.getElementsByTagName(COURSE_ID)[0].firstChild.nodeValue;
  876. name = evaluation.getElementsByTagName(EVALUATION_NAME)[0].firstChild.nodeValue;
  877. startString = evaluation.getElementsByTagName(EVALUATION_START)[0].firstChild.nodeValue;
  878. deadlineString = evaluation.getElementsByTagName(EVALUATION_DEADLINE)[0].firstChild.nodeValue;
  879. timeZone = evaluation.getElementsByTagName(EVALUATION_TIMEZONE)[0].firstChild.nodeValue;
  880. gracePeriod = evaluation.getElementsByTagName(EVALUATION_GRACEPERIOD)[0].firstChild.nodeValue;
  881. instructions = evaluation.getElementsByTagName(EVALUATION_INSTRUCTIONS)[0].firstChild.nodeValue;
  882. commentsEnabled = (evaluation.getElementsByTagName(EVALUATION_COMMENTSENABLED)[0].firstChild.nodeValue == "true");
  883. published = (evaluation.getElementsByTagName(EVALUATION_PUBLISHED)[0].firstChild.nodeValue == "true");
  884. deadline = new Date(deadlineString);
  885. start = new Date(startString);
  886. evaluationList[loop] = {courseID:courseID, name:name, start:start, deadline:deadline, timeZone:timeZone,
  887. gracePeriod:gracePeriod, instructions:instructions, commentsEnabled:commentsEnabled,
  888. published:published};
  889. }
  890. return evaluationList;
  891. }
  892. else
  893. {
  894. return 1;
  895. }
  896. }
  897. /*
  898. * Returns
  899. *
  900. * submissionList: successful
  901. * 1: server error
  902. *
  903. */
  904. function handleGetSubmissionList()
  905. {
  906. if(xmlhttp.status == 200)
  907. {
  908. var submissions = xmlhttp.responseXML.getElementsByTagName("submissions")[0];
  909. var submissionList = new Array();
  910. var submission;
  911. var fromStudentName;
  912. var toStudentName;
  913. var fromStudent;
  914. var toStudent;
  915. var courseID;
  916. var evaluationName;
  917. var teamName;
  918. var points;
  919. var justification;
  920. var commentsToStudent;
  921. if(submissions != null)
  922. {
  923. var len = submissions.childNodes.length;
  924. for(loop = 0; loop < len; loop++)
  925. {
  926. submission = submissions.childNodes[loop];
  927. fromStudentName = submission.getElementsByTagName(STUDENT_FROMSTUDENTNAME)[0].firstChild.nodeValue;
  928. fromStudent = submission.getElementsByTagName(STUDENT_FROMSTUDENT)[0].firstChild.nodeValue;
  929. toStudentName = submission.getElementsByTagName(STUDENT_TOSTUDENTNAME)[0].firstChild.nodeValue;
  930. toStudent = submission.getElementsByTagName(STUDENT_TOSTUDENT)[0].firstChild.nodeValue;
  931. courseID = submission.getElementsByTagName(COURSE_ID)[0].firstChild.nodeValue;
  932. evaluationName = submission.getElementsByTagName(EVALUATION_NAME)[0].firstChild.nodeValue;
  933. teamName = submission.getElementsByTagName(STUDENT_TEAMNAME)[0].firstChild.nodeValue;
  934. points = parseInt(submission.getElementsByTagName(STUDENT_POINTS)[0].firstChild.nodeValue);
  935. justification = submission.getElementsByTagName(STUDENT_JUSTIFICATION)[0].firstChild.nodeValue;
  936. commentsToStudent = submission.getElementsByTagName(STUDENT_COMMENTSTOSTUDENT)[0].firstChild.nodeValue;
  937. submissionList[loop] = {fromStudentName:fromStudentName, toStudentName:toStudentName,
  938. fromStudent:fromStudent, toStudent:toStudent, courseID:courseID,
  939. evaluationName:evaluationName, teamName:teamName, justification:justification,
  940. commentsToStudent:commentsToStudent, points:points};
  941. }
  942. }
  943. return submissionList;
  944. }
  945. else
  946. {
  947. return 1;
  948. }
  949. }
  950. /*
  951. * Returns
  952. *
  953. * submissionList: successful
  954. * 1: server error
  955. *
  956. */
  957. function handleGetSubmissionResultsList()
  958. {
  959. if(xmlhttp.status == 200)
  960. {
  961. var submissions = xmlhttp.responseXML.getElementsByTagName("submissions")[0];
  962. var submissionList = new Array();
  963. var submission;
  964. var fromStudentName;
  965. var toStudentName;
  966. var fromStudent;
  967. var toStudent;
  968. var fromStudentComments;
  969. var toStudentComments;
  970. var courseID;
  971. var evaluationName;
  972. var teamName;
  973. var points;
  974. var pointsBumpRatio;
  975. var justification;
  976. var commentsToStudent;
  977. if(submissions != null)
  978. {
  979. var len = submissions.childNodes.length;
  980. for(loop = 0; loop < len; loop++)
  981. {
  982. submission = submissions.childNodes[loop];
  983. fromStudentName = submission.getElementsByTagName(STUDENT_FROMSTUDENTNAME)[0].firstChild.nodeValue;
  984. fromStudent = submission.getElementsByTagName(STUDENT_FROMSTUDENT)[0].firstChild.nodeValue;
  985. toStudentName = submission.getElementsByTagName(STUDENT_TOSTUDENTNAME)[0].firstChild.nodeValue;
  986. toStudent = submission.getElementsByTagName(STUDENT_TOSTUDENT)[0].firstChild.nodeValue;
  987. fromStudentComments = submission.getElementsByTagName(STUDENT_FROMSTUDENTCOMMENTS)[0].firstChild.nodeValue;
  988. toStudentComments = submission.getElementsByTagName(STUDENT_TOSTUDENTCOMMENTS)[0].firstChild.nodeValue;
  989. courseID = submission.getElementsByTagName(COURSE_ID)[0].firstChild.nodeValue;
  990. evaluationName = submission.getElementsByTagName(EVALUATION_NAME)[0].firstChild.nodeValue;
  991. teamName = submission.getElementsByTagName(STUDENT_TEAMNAME)[0].firstChild.nodeValue;
  992. points = parseInt(submission.getElementsByTagName(STUDENT_POINTS)[0].firstChild.nodeValue);
  993. pointsBumpRatio = parseFloat(submission.getElementsByTagName(STUDENT_POINTSBUMPRATIO)[0].firstChild.nodeValue);
  994. justification = submission.getElementsByTagName(STUDENT_JUSTIFICATION)[0].firstChild.nodeValue;
  995. commentsToStudent = submission.getElementsByTagName(STUDENT_COMMENTSTOSTUDENT)[0].firstChild.nodeValue;
  996. submissionList[loop] = {fromStudentName:fromStudentName, toStudentName:toStudentName,
  997. fromStudent:fromStudent, toStudent:toStudent, courseID:courseID,
  998. evaluationName:evaluationName, teamName:teamName, justification:justification,
  999. commentsToStudent:commentsToStudent, points:points, pointsBumpRatio:pointsBumpRatio,
  1000. fromStudentComments:fromStudentComments, toStudentComments:toStudentComments};
  1001. }
  1002. }
  1003. return submissionList;
  1004. }
  1005. else
  1006. {
  1007. return 1;
  1008. }
  1009. }
  1010. /*
  1011. * Returns
  1012. *
  1013. * 0: successful
  1014. * 1: server error
  1015. * 2: google ID already exists in course
  1016. * 3: registration key invalid
  1017. * 4: registration key taken
  1018. *
  1019. */
  1020. function handleJoinCourse()
  1021. {
  1022. if (xmlhttp.status == 200)
  1023. {
  1024. var status = xmlhttp.responseXML.getElementsByTagName("status")[0];
  1025. if(status != null)
  1026. {
  1027. var message = status.firstChild.nodeValue;
  1028. if(message == MSG_STUDENT_COURSEJOINED)
  1029. {
  1030. return 0;
  1031. }
  1032. else if(message == MSG_STUDENT_GOOGLEIDEXISTSINCOURSE)
  1033. {
  1034. return 2;
  1035. }
  1036. else if(message == MSG_STUDENT_REGISTRATIONKEYINVALID)
  1037. {
  1038. return 3;
  1039. }
  1040. else
  1041. {
  1042. return 4;
  1043. }
  1044. }
  1045. }
  1046. else
  1047. {
  1048. return 1;
  1049. }
  1050. }
  1051. /*
  1052. * Returns
  1053. *
  1054. * 0: successful
  1055. * 1: server error
  1056. *
  1057. */
  1058. function handleLeaveCourse()
  1059. {
  1060. if(xmlhttp)
  1061. {
  1062. return 0;
  1063. }
  1064. else
  1065. {
  1066. return 1;
  1067. }
  1068. }
  1069. function handleLogout()
  1070. {
  1071. if (xmlhttp.status == 200)
  1072. {
  1073. var url = xmlhttp.responseXML.getElementsByTagName("url")[0];
  1074. window.location = url.firstChild.nodeValue;
  1075. }
  1076. }
  1077. /*
  1078. * Returns
  1079. *
  1080. * 0: successful
  1081. * 1: server error
  1082. * 2: deadline passed
  1083. *
  1084. */
  1085. function handleSubmitEvaluation()
  1086. {
  1087. if(xmlhttp.status == 200)
  1088. {
  1089. var status = xmlhttp.responseXML.getElementsByTagName("status")[0];
  1090. var message;
  1091. if(status != null)
  1092. {
  1093. message = status.firstChild.nodeValue;
  1094. if(message == MSG_EVALUATION_DEADLINEPASSED)
  1095. {
  1096. return 2;
  1097. }
  1098. else
  1099. {
  1100. return 0;
  1101. }
  1102. }
  1103. }
  1104. else
  1105. {
  1106. return 1;
  1107. }
  1108. }
  1109. /*
  1110. * Returns
  1111. *
  1112. * 0: successful
  1113. * 1: server error
  1114. *
  1115. */
  1116. function handleUnarchiveCourse()
  1117. {
  1118. if(xmlhttp.status == 200)
  1119. {
  1120. return 0;
  1121. }
  1122. else
  1123. {
  1124. return 1;
  1125. }
  1126. }
  1127. /*
  1128. * Returns
  1129. *
  1130. * 0: successful
  1131. * 1: server error
  1132. * 2: google ID already exists in course
  1133. * 3: registration key invalid
  1134. *
  1135. */
  1136. function joinCourse(registrationKey)
  1137. {
  1138. if(xmlhttp)
  1139. {
  1140. xmlhttp.open("POST","teammates",false);
  1141. xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;");
  1142. xmlhttp.send("operation=" + OPERATION_STUDENT_JOINCOURSE + "&" + STUDENT_REGKEY + "=" +
  1143. encodeURIComponent(registrationKey));
  1144. return handleJoinCourse();
  1145. }
  1146. }
  1147. /*
  1148. * Returns
  1149. *
  1150. * 0: successful
  1151. * 1: server error
  1152. *
  1153. */
  1154. function leaveCourse(courseID)
  1155. {
  1156. if(xmlhttp)
  1157. {
  1158. xmlhttp.open("POST","teammates",false);
  1159. xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;");
  1160. xmlhttp.send("operation=" + OPERATION_STUDENT_DELETECOURSE + "&" + COURSE_ID + "=" + encodeURIComponent(courseID));
  1161. return handleLeaveCourse();
  1162. }
  1163. }
  1164. function logout()
  1165. {
  1166. if(xmlhttp)
  1167. {
  1168. xmlhttp.open("POST","teammates",false);
  1169. xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;");
  1170. xmlhttp.send("operation=" + OPERATION_STUDENT_LOGOUT);
  1171. }
  1172. handleLogout();
  1173. }
  1174. function populateEvaluationSubmissionForm(form, submissionList, commentsEnabled)
  1175. {
  1176. var counter = 0;
  1177. var submissionListLength = submissionList.length;
  1178. for(loop = 0; loop < submissionListLength; loop++)
  1179. {
  1180. counter += 5;
  1181. form.elements[counter++].value = parseInt(submissionList[loop].points);
  1182. form.elements[counter++].value = submissionList[loop].justification;
  1183. if(commentsEnabled == true)
  1184. {
  1185. form.elements[counter++].value = submissionList[loop].commentsToStudent;
  1186. }
  1187. else
  1188. {
  1189. counter += 1;
  1190. }
  1191. }
  1192. }
  1193. function sortByCourseID(a, b)
  1194. {
  1195. var x = a.courseID.toLowerCase();
  1196. var y = b.courseID.toLowerCase();
  1197. return ((x < y) ? -1 : ((x > y) ? 1 : 0));
  1198. }
  1199. function sortByCourseName(a, b)
  1200. {
  1201. var x = a.name.toLowerCase();
  1202. var y = b.name.toLowerCase();
  1203. return ((x < y) ? -1 : ((x > y) ? 1 : 0));
  1204. }
  1205. function sortByID(a, b)
  1206. {
  1207. var x = a.ID.toLowerCase();
  1208. var y = b.ID.toLowerCase();
  1209. return ((x < y) ? -1 : ((x > y) ? 1 : 0));
  1210. }
  1211. function sortByName(a, b)
  1212. {
  1213. var x = a.name.toLowerCase();
  1214. var y = b.name.toLowerCase();
  1215. return ((x < y) ? -1 : ((x > y) ? 1 : 0));
  1216. }
  1217. /*
  1218. * Returns
  1219. *
  1220. * 0: successful
  1221. * 1: server error
  1222. * 2: deadline passed
  1223. * 3: fields missing
  1224. * 4: fields too long
  1225. *
  1226. */
  1227. function submitEvaluation(submissionList, commentsEnabled)
  1228. {
  1229. var submissionListLength = submissionList.length;
  1230. for(loop = 0; loop < submissionListLength; loop++)
  1231. {
  1232. if(submissionList[loop].justification == "" || (submissionList[loop].commentsToStudent == "" &&
  1233. commentsEnabled == true))
  1234. {
  1235. return 3;
  1236. }
  1237. if(submissionList[loop].justification.length > 50000 || submissionList[loop].commentsToStudent.length > 50000)
  1238. {
  1239. return 4;
  1240. }
  1241. }
  1242. var request = "operation=" + OPERATION_STUDENT_SUBMITEVALUATION + "&" + STUDENT_NUMBEROFSUBMISSIONS +
  1243. "=" + submissionList.length + "&" + COURSE_ID + "=" + submissionList[0].courseID +
  1244. "&" + EVALUATION_NAME + "=" + submissionList[0].evaluationName +
  1245. "&" + STUDENT_TEAMNAME + "=" + submissionList[0].teamName;
  1246. for(loop = 0; loop < submissionListLength; loop++)
  1247. {
  1248. request = request + "&" + STUDENT_FROMSTUDENT + loop + "=" +
  1249. encodeURIComponent(submissionList[loop].fromStudent) + "&" +
  1250. STUDENT_TOSTUDENT + loop + "=" +
  1251. encodeURIComponent(submissionList[loop].toStudent) + "&" +
  1252. STUDENT_POINTS + loop + "=" +
  1253. encodeURIComponent(submissionList[loop].points) + "&" +
  1254. STUDENT_JUSTIFICATION + loop + "=" +
  1255. encodeURIComponent(submissionList[loop].justification) + "&" +
  1256. STUDENT_COMMENTSTOSTUDENT + loop + "=" +
  1257. encodeURIComponent(submissionList[loop].commentsToStudent);
  1258. }
  1259. if(xmlhttp)
  1260. {
  1261. xmlhttp.open("POST","teammates",false);
  1262. xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;");
  1263. xmlhttp.send(request);
  1264. }
  1265. return handleSubmitEvaluation();
  1266. }
  1267. function toggleLeaveCourseConfirmation(courseID) {
  1268. var s = confirm("Are you sure you want to leave the course " + courseID + "?");
  1269. if (s == true) {
  1270. doLeaveCourse(courseID);
  1271. } else {
  1272. clearStatusMessage();
  1273. }
  1274. document.getElementById(DIV_STATUS).innerHTML = output;
  1275. document.getElementById(DIV_COURSE_MANAGEMENT).scrollIntoView(true);
  1276. }
  1277. function toggleSortCoursesByID(courseList) {
  1278. printCourseList(courseList.sort(sortByID), STUDENT);
  1279. courseSortStatus = courseSort.ID;
  1280. document.getElementById("button_sortcourseid").setAttribute("class", "buttonSortAscending");
  1281. }
  1282. function toggleSortCoursesByName(courseList) {
  1283. printCourseList(courseList.sort(sortByCourseName), STUDENT);
  1284. courseSortStatus = courseSort.name;
  1285. document.getElementById("button_sortcoursename").setAttribute("class", "buttonSortAscending");
  1286. }
  1287. function toggleSortPastEvaluationsByCourseID(evaluationList) {
  1288. printPastEvaluationList(evaluationList.sort(sortByCourseID));
  1289. evaluationSortStatus = evaluationSort.courseID;
  1290. document.getElementById("button_sortcourseid").setAttribute("class", "buttonSortAscending");
  1291. }
  1292. function toggleSortPastEvaluationsByName(evaluationList) {
  1293. printPastEvaluationList(evaluationList.sort(sortByName));
  1294. evaluationSortStatus = evaluationSort.name;
  1295. document.getElementById("button_sortname").setAttribute("class", "buttonSortAscending");
  1296. }
  1297. /*
  1298. * Returns
  1299. *
  1300. * 0: successful
  1301. * 1: server error
  1302. *
  1303. */
  1304. function unarchiveCourse(courseID) {
  1305. if (xmlhttp) {
  1306. xmlhttp.open("POST","teammates",false);
  1307. xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;");
  1308. xmlhttp.send("operation=" + OPERATION_STUDENT_UNARCHIVECOURSE + "&" + COURSE_ID + "=" + encodeURIComponent(courseID));
  1309. return handleUnarchiveCourse();
  1310. }
  1311. }
  1312. window.onload = function() {
  1313. initializetooltip();
  1314. displayCoursesTab();
  1315. }
  1316. // DynamicDrive JS mouse-hover
  1317. document.onmousemove = positiontip