/code/war/js/atd.js
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
- // AJAX
- var xmlhttp = new getXMLObject();
-
- //OPERATIONS
- var OPERATION_ADMINISTRATOR_LOGOUT = "administrator_logout";
-
- var OPERATION_COORDINATOR_ADDCOURSE = "coordinator_addcourse";
- var OPERATION_COORDINATOR_ADDEVALUATION = "coordinator_addevaluation";
- var OPERATION_COORDINATOR_ARCHIVECOURSE = "coordinator_archivecourse";
- var OPERATION_COORDINATOR_ARCHIVEEVALUATION = "coordinator_archiveevaluation";
- var OPERATION_COORDINATOR_DELETEALLSTUDENTS = "coordinator_deleteallstudents";
- var OPERATION_COORDINATOR_DELETECOURSE = "coordinator_deletecourse";
- var OPERATION_COORDINATOR_DELETEEVALUATION = "coordinator_deleteevaluation";
- var OPERATION_COORDINATOR_DELETESTUDENT = "coordinator_deletestudent";
- var OPERATION_COORDINATOR_EDITEVALUATION = "coordinator_editevaluation";
- var OPERATION_COORDINATOR_EDITEVALUATIONRESULTS = "coordinator_editevaluationresults";
- var OPERATION_COORDINATOR_EDITSTUDENT = "coordinator_editstudent";
- var OPERATION_COORDINATOR_ENROLSTUDENTS = "coordinator_enrolstudents";
- var OPERATION_COORDINATOR_GETCOURSE = "coordinator_getcourse";
- var OPERATION_COORDINATOR_GETCOURSELIST = "coordinator_getcourselist";
- var OPERATION_COORDINATOR_GETEVALUATIONLIST = "coordinator_getevaluationlist";
- var OPERATION_COORDINATOR_GETSTUDENTLIST = "coordinator_getstudentlist";
- var OPERATION_COORDINATOR_GETSUBMISSIONLIST = "coordinator_getsubmissionlist";
- var OPERATION_COORDINATOR_INFORMSTUDENTSOFEVALUATIONCHANGES = "coordinator_informstudentsofevaluationchanges";
- var OPERATION_COORDINATOR_LOGOUT = "coordinator_logout";
- var OPERATION_COORDINATOR_PUBLISHEVALUATION = "coordinator_publishevaluation";
- var OPERATION_COORDINATOR_REMINDSTUDENTS = "coordinator_remindstudents";
- var OPERATION_COORDINATOR_SENDREGISTRATIONKEY = "coordinator_sendregistrationkey";
- var OPERATION_COORDINATOR_SENDREGISTRATIONKEYS = "coordinator_sendregistrationkeys";
- var OPERATION_COORDINATOR_UNARCHIVECOURSE = "coordinator_unarchivecourse";
- var OPERATION_COORDINATOR_UNARCHIVEEVALUATION = "coordinator_unarchiveevaluation";
-
- var OPERATION_STUDENT_ARCHIVECOURSE = "student_archivecourse";
- var OPERATION_STUDENT_DELETECOURSE = "student_deletecourse";
- var OPERATION_STUDENT_GETCOURSE = "student_getcourse";
- var OPERATION_STUDENT_GETCOURSELIST = "student_getcourselist";
- var OPERATION_STUDENT_GETPASTEVALUATIONLIST = "student_getpastevaluationlist";
- var OPERATION_STUDENT_GETPENDINGEVALUATIONLIST = "student_getpendingevaluationlist";
- var OPERATION_STUDENT_GETSUBMISSIONLIST = "student_getsubmissionlist";
- var OPERATION_STUDENT_GETSUBMISSIONRESULTSLIST = "student_getsubmissionresultslist";
- var OPERATION_STUDENT_JOINCOURSE = "student_joincourse";
- var OPERATION_STUDENT_LOGOUT = "student_logout";
- var OPERATION_STUDENT_SUBMITEVALUATION = "student_submitevaluation";
- var OPERATION_STUDENT_UNARCHIVECOURSE = "student_unarchivecourse";
-
- //PARAMETERS
- var COURSE_ID = "courseid";
- var COURSE_NAME = "coursename";
- var COURSE_NUMBEROFTEAMS = "coursenumberofteams";
- var COURSE_STATUS = "coursestatus";
-
- var EVALUATION_ACTIVATED = "activated";
- var EVALUATION_ARCHIVED = "evaluationarchived";
- var EVALUATION_COMMENTSENABLED = "commentsstatus";
- var EVALUATION_DEADLINE = "deadline";
- var EVALUATION_DEADLINETIME = "deadlinetime";
- var EVALUATION_GRACEPERIOD = "graceperiod";
- var EVALUATION_INSTRUCTIONS = "instr";
- var EVALUATION_NAME = "evaluationname";
- var EVALUATION_NUMBEROFCOMPLETEDEVALUATIONS = "numberofevaluations";
- var EVALUATION_NUMBEROFEVALUATIONS = "numberofcompletedevaluations";
- var EVALUATION_PUBLISHED = "published";
- var EVALUATION_START = "start";
- var EVALUATION_STARTTIME = "starttime";
- var EVALUATION_TIMEZONE = "timezone";
- var EVALUATION_TYPE = "evaluationtype";
-
- var STUDENT_COMMENTS = "comments";
- var STUDENT_COMMENTSEDITED = "commentsedited";
- var STUDENT_COMMENTSTOSTUDENT = "commentstostudent";
- var STUDENT_COURSEID = "courseid";
- var STUDENT_EDITCOMMENTS = "editcomments";
- var STUDENT_EDITEMAIL = "editemail";
- var STUDENT_EDITGOOGLEID = "editgoogleid";
- var STUDENT_EDITNAME = "editname";
- var STUDENT_EDITTEAMNAME = "editteamname";
- var STUDENT_EMAIL = "email";
- var STUDENT_FROMSTUDENT = "fromemail";
- var STUDENT_FROMSTUDENTCOMMENTS = "fromstudentcomments";
- var STUDENT_FROMSTUDENTNAME = "fromname";
- var STUDENT_ID = "id";
- var STUDENT_INFORMATION = "information";
- var STUDENT_JUSTIFICATION = "justification";
- var STUDENT_NAME = "name";
- var STUDENT_NAMEEDITED = "nameedited";
- var STUDENT_NUMBEROFSUBMISSIONS = "numberofsubmissions";
- var STUDENT_POINTS = "points";
- var STUDENT_POINTSBUMPRATIO = "pointsbumpratio";
- var STUDENT_REGKEY = "regkey";
- var STUDENT_STATUS = "status";
- var STUDENT_TEAMNAME = "teamname";
- var STUDENT_TEAMNAMEEDITED = "teamnameedited";
- var STUDENT_TOSTUDENT = "toemail";
- var STUDENT_TOSTUDENTCOMMENTS = "tostudentcomments";
- var STUDENT_TOSTUDENTNAME = "toname";
-
- // MESSAGES
- var MSG_COURSE_EXISTS = "course exists";
- var MSG_COURSE_NOTEAMS = "course has no teams";
-
- var MSG_EVALUATION_ADDED = "evaluation added";
- var MSG_EVALUATION_DEADLINEPASSED = "evaluation deadline passed";
- var MSG_EVALUATION_EDITED = "evaluation edited";
- var MSG_EVALUATION_EXISTS = "evaluation exists";
- var MSG_EVALUATION_UNABLETOCHANGETEAMS = "evaluation ongoing unable to change teams";
-
- var MSG_STUDENT_COURSEJOINED = "course joined";
- var MSG_STUDENT_GOOGLEIDEXISTSINCOURSE = "googleid exists in course";
- var MSG_STUDENT_REGISTRATIONKEYINVALID = "registration key invalid";
- var MSG_STUDENT_REGISTRATIONKEYTAKEN = "registration key taken";
-
- // GLOBAL VARIABLE
- var courseID = "ATD-TESTING.1.2.3";
- var courseName = "ATD TESTING IN PROGRESS";
- var evaluationName = "ATD TEST";
-
- /*
- * Returns
- *
- * 0: successful
- * 1: server error
- * 2: field(s) empty
- * 3: courseID invalid
- * 4: name invalid
- * 5: course exists
- *
- */
- function addCourse(courseID, courseName)
- {
- if(xmlhttp)
- {
- courseID = trim(courseID);
- courseName = trim(courseName);
-
- if(courseID == "" || courseName == "")
- {
- return 2;
- }
-
- else if(!isCourseIDValid(courseID))
- {
- return 3;
- }
-
- else if(!isCourseNameValid(courseName))
- {
- return 4;
- }
-
- else
- {
- xmlhttp.open("POST","teammates",false);
- xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;");
- xmlhttp.send("operation=" + OPERATION_COORDINATOR_ADDCOURSE + "&" + COURSE_ID + "=" + encodeURIComponent(courseID) +
- "&" + COURSE_NAME + "=" + encodeURIComponent(courseName));
-
-
- var results = handleAddCourse();
-
- return results;
-
- }
- }
- }
-
- /*
- * Returns
- *
- * 0: successful
- * 1: server error
- * 2: fields empty
- * 3: evaluation name invalid
- * 4: evaluation schedule invalid
- * 5: evaluation exists
- * 6: course has no teams
- *
- */
- function addEvaluation(courseID, name, instructions, commentsEnabled, start, startTime, deadline, deadlineTime, timeZone, gracePeriod)
- {
- if(courseID == "" || name == "" || start == "" || startTime == "" || deadline == "" || deadlineTime == "" ||
- timeZone == "" || gracePeriod == "" || instructions == "")
- {
- return 2;
- }
-
- else if(!isEvaluationNameValid(name))
- {
- return 3;
- }
-
- else if(!isAddEvaluationScheduleValid(start, startTime, deadline, deadlineTime))
- {
- return 4;
- }
-
- else
- {
- xmlhttp.open("POST","teammates",false);
- xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;");
- xmlhttp.send("operation=" + OPERATION_COORDINATOR_ADDEVALUATION + "&" + COURSE_ID + "=" + encodeURIComponent(courseID) +
- "&" + EVALUATION_NAME + "=" + encodeURIComponent(name) + "&" + EVALUATION_DEADLINE + "=" + encodeURIComponent(deadline) +
- "&" + EVALUATION_DEADLINETIME + "=" + encodeURIComponent(deadlineTime) +
- "&" + EVALUATION_INSTRUCTIONS + "=" + encodeURIComponent(instructions) + "&" +
- EVALUATION_START + "=" + encodeURIComponent(start) + "&" + EVALUATION_STARTTIME + "=" +
- encodeURIComponent(startTime) + "&" + EVALUATION_GRACEPERIOD + "=" + encodeURIComponent(gracePeriod) +
- "&" + EVALUATION_TIMEZONE + "=" + encodeURIComponent(timeZone) +
- "&" + EVALUATION_COMMENTSENABLED + "=" + encodeURIComponent(commentsEnabled));
-
- return handleAddEvaluation();
- }
-
- }
-
- function cleanUp()
- {
- if(xmlhttp)
- {
- xmlhttp.open("POST","teammates",false);
- xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;");
- xmlhttp.send("operation=" + OPERATION_ADMINISTRATOR_CLEANUP + "&" + COURSE_ID + "=" + encodeURIComponent(courseID));
- }
-
- }
- function clearATD()
- {
- deleteCourse(courseID);
- }
-
- function convertDateFromDDMMYYYYToMMDDYYYY(dateString)
- {
- var newDateString = dateString.substring(3,5) + "/" + dateString.substring(0,2) + "/" +
- dateString.substring(6,10);
-
- return newDateString;
- }
-
- function convertDateToDDMMYYYY(date)
- {
- var string;
-
- if(date.getDate() < 10)
- {
- string = "0" + date.getDate();
- }
-
- else
- {
- string = date.getDate();
- }
-
- string = string + "/";
-
- if(date.getMonth()+1 < 10)
- {
- string = string + "0" + (date.getMonth()+1);
- }
-
- else
- {
- string = string + (date.getMonth()+1);
- }
-
- string = string + "/" + date.getFullYear();
-
- return string;
- }
-
- function convertDateToHHMM(date)
- {
- var string;
-
- if(date.getHours() < 10)
- {
- string = "0" + date.getHours();
- }
-
- else
- {
- string = "" + date.getHours();
- }
-
- if(date.getMinutes() < 10)
- {
- string = string + "0" + date.getMinutes();
- }
-
- else
- {
- string = string + date.getMinutes();
- }
-
- return string;
- }
-
- function createEnrollmentInput(studentList)
- {
- var input = "";
-
- for(var x = 0; x < studentList.length; x++)
- {
- if(x % 2 == 0)
- {
- if(comments == "")
- {
- input = input + studentList[x].name + "\t" + studentList[x].email + "\t"
- + studentList[x].teamName + "\n";
- }
-
- else
- {
- input = input + studentList[x].name + "\t" + studentList[x].email + "\t"
- + studentList[x].teamName + "\t" + studentList[x].comments + "\n";
- }
- }
-
- else
- {
- if(comments == "")
- {
- input = input + studentList[x].name + "|" + studentList[x].email + "|"
- + studentList[x].teamName + "\n";
- }
-
- else
- {
- input = input + studentList[x].name + "|" + studentList[x].email + "|"
- + studentList[x].teamName + "|" + studentList[x].comments + "\n";
- }
- }
- }
-
- return input;
- }
-
- function createInvalidCourseList()
- {
- var courseList = new Array();
-
- var ID;
- var name;
-
- ID = "Invalid>";
- name = "Valid name";
-
- courseList[0] = {ID:ID, name:name};
-
- ID = "InvalidIDthisistoolongtobeacourseidomgveryveryveryverylong";
- name = "Valid";
-
- courseList[1] = {ID:ID, name:name};
-
- ID = "ValidID";
- name = "Invalid name this might be a tad too long to be a valid course name";
-
- courseList[2] = {ID:ID, name:name};
-
- ID = "Invalid%";
- name = "Valid Name";
-
- courseList[3] = {ID:ID, name:name};
-
- ID = "Invalid\"\"";
- name = "Valid Name";
-
- courseList[4] = {ID:ID, name:name};
-
- ID = "Invalid'";
- name = "Valid Name :;";
-
- courseList[5] = {ID:ID, name:name};
-
- ID = "Invalid@";
- name = "Valid Name :;";
-
- courseList[6] = {ID:ID, name:name};
-
- ID = "";
- name = "Valid Name :;";
-
- courseList[7] = {ID:ID, name:name};
-
- ID = "Invalid space";
- name = "Valid Name :;";
-
- courseList[8] = {ID:ID, name:name};
-
- ID = "<b>Invalid";
- name = "Valid Name :;";
-
- courseList[9] = {ID:ID, name:name};
-
- ID = "<b>Invalid";
- name = "";
-
- courseList[10] = {ID:ID, name:name};
-
- return courseList;
- }
-
- function createInvalidEvaluationList()
- {
- var name;
- var instructions;
- var commentsEnabled;
- var start;
- var startTime;
- var deadline;
- var deadlineTime;
- var gracePeriod;
-
- var evaluationList = new Array();
-
- name = "Invalid Name This is Way too Long to be an Evaluation Name";
- instructions = "Valid instructions ' &s <hi>";
- commentsEnabled = "true";
- start = "01/01/2018";
- startTime = "0100";
- deadline = "01/01/2018";
- deadlineTime = "2359";
- gracePeriod = "10";
-
- evaluationList[0] = { name:name, instructions:instructions, commentsEnabled:commentsEnabled, start:start,
- startTime:startTime, deadline:deadline, deadlineTime:deadlineTime, gracePeriod:gracePeriod};
-
- name = "<hi> '";
- instructions = "Valid instructions ' &s <hi> dwdwadw wadwadawdwaaaaaawaaaaaaaaaaa";
- commentsEnabled = "false";
- start = "01/01/2018";
- startTime = "0100";
- deadline = "01/01/2018";
- deadlineTime = "2359";
- gracePeriod = "10";
-
- evaluationList[1] = { name:name, instructions:instructions, commentsEnabled:commentsEnabled, start:start,
- startTime:startTime, deadline:deadline, deadlineTime:deadlineTime, gracePeriod:gracePeriod};
-
- name = "%s invalid";
- instructions = "Valid instructions ' &s <hi>";
- commentsEnabled = "false";
- start = "01/01/2018";
- startTime = "0100";
- deadline = "01/01/2018";
- deadlineTime = "2359";
- gracePeriod = "10";
-
- evaluationList[2] = { name:name, instructions:instructions, commentsEnabled:commentsEnabled, start:start,
- startTime:startTime, deadline:deadline, deadlineTime:deadlineTime, gracePeriod:gracePeriod};
-
- name = "Valid Name11";
- instructions = "Valid instructions ' &s <hi>";
- commentsEnabled = "false";
- start = "01/12/2018";
- startTime = "0100";
- deadline = "01/01/2018";
- deadlineTime = "2359";
- gracePeriod = "5";
-
- evaluationList[3] = { name:name, instructions:instructions, commentsEnabled:commentsEnabled, start:start,
- startTime:startTime, deadline:deadline, deadlineTime:deadlineTime, gracePeriod:gracePeriod};
-
- name = "Valid Name22";
- instructions = "Valid instructions ' &s <hi>";
- commentsEnabled = "true";
- start = "21/11/2018";
- startTime = "0100";
- deadline = "10/01/2018";
- deadlineTime = "2359";
- gracePeriod = "30";
-
- evaluationList[4] = { name:name, instructions:instructions, commentsEnabled:commentsEnabled, start:start,
- startTime:startTime, deadline:deadline, deadlineTime:deadlineTime, gracePeriod:gracePeriod};
-
- name = "Valid Name33";
- instructions = "Valid instructions ' &s <hi>";
- commentsEnabled = "false";
- start = "21/11/2019";
- startTime = "1100";
- deadline = "21/11/2019";
- deadlineTime = "1000";
- gracePeriod = "25";
-
- evaluationList[5] = { name:name, instructions:instructions, commentsEnabled:commentsEnabled, start:start,
- startTime:startTime, deadline:deadline, deadlineTime:deadlineTime, gracePeriod:gracePeriod};
-
- name = "Valid Name44";
- instructions = "Valid instructions ' &s <hi>";
- commentsEnabled = "false";
- start = "21/11/2019";
- startTime = "1100";
- deadline = "21/11/2019";
- deadlineTime = "1100";
- gracePeriod = "20";
-
- evaluationList[6] = { name:name, instructions:instructions, commentsEnabled:commentsEnabled, start:start,
- startTime:startTime, deadline:deadline, deadlineTime:deadlineTime, gracePeriod:gracePeriod};
-
- /* PHANTOM
- name = "Valid Name";
- instructions = "Valid instructionsk k' &s <hi>";
- commentsEnabled = "false";
- start = "22/01/2017";
- startTime = "0100";
- deadline = "21/01/2017";
- deadlineTime = "2359";
- gracePeriod = "10";
-
- evaluationList[7] = { name:name, instructions:instructions, commentsEnabled:commentsEnabled, start:start,
- startTime:startTime, deadline:deadline, deadlineTime:deadlineTime, gracePeriod:gracePeriod};
- */
-
- return evaluationList;
- }
-
- function createInvalidStudentList()
- {
- var studentList = new Array();
-
- name = "Name is longer than forty two forty two forty two characters";
- email = "validemail@gmail.com";
- teamName = "Good Team";
- comments = "";
-
- studentList[0] = {name:name, teamName:teamName, email:email, comments:comments};
-
- name = "Name has % chars";
- email = "validemail@gmail.com";
- teamName = "Good Team";
- comments = "";
-
- studentList[1] = {name:name, teamName:teamName, email:email, comments:comments};
-
- name = "Name has <b> chars";
- email = "validemail@gmail.com";
- teamName = "Good Team";
- comments = "Good comments";
-
- studentList[2] = {name:name, teamName:teamName, email:email, comments:comments};
-
- name = "Name has &d chars";
- email = "validemail@gmail.com";
- teamName = "Good Team";
- comments = "Good comments";
-
- studentList[3] = {name:name, teamName:teamName, email:email, comments:comments};
-
- name = "Name has &d chars";
- email = "validemail@gmail.com";
- teamName = "Good Team";
- comments = "Good comments";
-
- studentList[4] = {name:name, teamName:teamName, email:email, comments:comments};
-
- name = "Name has ^%@ chars";
- email = "validemail@gmail.com";
- teamName = "Good Team";
- comments = "";
-
- studentList[5] = {name:name, teamName:teamName, email:email, comments:comments};
-
- name = "Good Name";
- email = "emailhasnoatgmail.com";
- teamName = "Good Team";
- comments = "";
-
- studentList[6] = {name:name, teamName:teamName, email:email, comments:comments};
-
- name = "Good Name";
- email = "emailiswaytoolongmorethanfortycharacters@gmailveryveryverylong.com";
- teamName = "Good Team";
- comments = "Good Comments";
-
- studentList[7] = {name:name, teamName:teamName, email:email, comments:comments};
-
- name = "Good Name";
- email = "emailhas;@gmail.com";
- teamName = "Good Team";
- comments = "Good Comments";
-
- studentList[8] = {name:name, teamName:teamName, email:email, comments:comments};
-
- name = "Good Name";
- email = "emailhasa space@gmail.com";
- teamName = "Good Team";
- comments = "";
-
- studentList[9] = {name:name, teamName:teamName, email:email, comments:comments};
-
- name = "Good Name";
- email = "emailhasadollarsign@gmail$.com";
- teamName = "Good Team";
- comments = "";
-
- studentList[10] = {name:name, teamName:teamName, email:email, comments:comments};
-
- name = "Good Name";
- email = "validemail@gmail.com";
- teamName = "Team Name has more than twenty five characters which is a lot";
- comments = "Good comments";
-
- studentList[11] = {name:name, teamName:teamName, email:email, comments:comments};
-
- name = "Bad ' Name";
- email = "emailiswaytoolongmorethanfortycharacters@gmailveryveryverylong.com";
- teamName = "Good Team";
- comments = "Good Comments";
-
- studentList[12] = {name:name, teamName:teamName, email:email, comments:comments};
-
- name = "Good Name";
- email = "emailiswaytoolongmorethanfortycharacters@gmailveryveryverylong.com";
- teamName = "Team Name has more than twenty five characters which is a lot";
- comments = "Good Comments";
-
- studentList[13] = {name:name, teamName:teamName, email:email, comments:comments};
-
- name = "Bad \" Name";
- email = "validemail@gmail.com";
- teamName = "Team Name has more than twenty five characters which is a lot";
- comments = "";
-
- studentList[14] = {name:name, email:email, teamName:teamName, comments:comments};
-
- return studentList;
- }
-
- function createValidCourseList()
- {
- var courseList = new Array();
-
- var ID;
- var name;
-
- ID = "Valid-ID";
- name = "<b>Valid name</b>";
-
- courseList[0] = {ID:ID, name:name};
-
- ID = "ValidID-12345678901";
- name = "Valid name 1234567890123456789";
-
- courseList[1] = {ID:ID, name:name};
-
- ID = "ValidID.11-";
- name = "Valid name 1234567890123456789";
-
- courseList[2] = {ID:ID, name:name};
-
- return courseList;
- }
-
- function createValidEvaluationList()
- {
- var name;
- var instructions;
- var commentsEnabled;
- var start;
- var startTime;
- var deadline;
- var deadlineTime;
- var gracePeriod;
-
- // Make sure evaluation names differ
- var evaluationList = new Array();
-
- name = "Valid Name1";
- instructions = "Valid instructions ' &s <hi>";
- commentsEnabled = "true";
- start = "01/01/2019";
- startTime = "0100";
- deadline = "01/03/2019";
- deadlineTime = "2359";
- gracePeriod = "10";
-
- evaluationList[0] = { name:name, instructions:instructions, commentsEnabled:commentsEnabled, start:start,
- startTime:startTime, deadline:deadline, deadlineTime:deadlineTime, gracePeriod:gracePeriod};
-
- name = "Valid Name2";
- instructions = "Valid instructions ' &s <hi>";
- commentsEnabled = "false";
- start = "01/01/2019";
- startTime = "0100";
- deadline = "02/01/2019";
- deadlineTime = "2359";
- gracePeriod = "10";
-
- evaluationList[1] = { name:name, instructions:instructions, commentsEnabled:commentsEnabled, start:start,
- startTime:startTime, deadline:deadline, deadlineTime:deadlineTime, gracePeriod:gracePeriod};
-
- name = "Valid Name3";
- instructions = "Valid instructions ' &s <hi>";
- commentsEnabled = "true";
- start = "20/01/2019";
- startTime = "0100";
- deadline = "02/02/2019";
- deadlineTime = "2359";
- gracePeriod = "10";
-
- evaluationList[2] = { name:name, instructions:instructions, commentsEnabled:commentsEnabled, start:start,
- startTime:startTime, deadline:deadline, deadlineTime:deadlineTime, gracePeriod:gracePeriod};
-
- name = "Valid Name4";
- instructions = "Valid instructions ' &s <hi>";
- commentsEnabled = "true";
- start = "20/03/2018";
- startTime = "0100";
- deadline = "02/02/2019";
- deadlineTime = "2359";
- gracePeriod = "30";
-
- evaluationList[3] = { name:name, instructions:instructions, commentsEnabled:commentsEnabled, start:start,
- startTime:startTime, deadline:deadline, deadlineTime:deadlineTime, gracePeriod:gracePeriod};
-
- name = "Valid Name5";
- instructions = "Valid instructions ' &s <hi>";
- commentsEnabled = "false";
- start = "20/03/2018";
- startTime = "0100";
- deadline = "20/03/2019";
- deadlineTime = "2359";
- gracePeriod = "15";
-
- evaluationList[4] = { name:name, instructions:instructions, commentsEnabled:commentsEnabled, start:start,
- startTime:startTime, deadline:deadline, deadlineTime:deadlineTime, gracePeriod:gracePeriod};
-
- name = "Valid Name6";
- instructions = "Valid instructions ' &s <hi>";
- commentsEnabled = "true";
- start = "20/01/2018";
- startTime = "2300";
- deadline = "20/01/2018";
- deadlineTime = "2359";
- gracePeriod = "20";
-
- evaluationList[5] = { name:name, instructions:instructions, commentsEnabled:commentsEnabled, start:start,
- startTime:startTime, deadline:deadline, deadlineTime:deadlineTime, gracePeriod:gracePeriod};
-
- return evaluationList;
- }
-
- function createValidStudentList(numberOfStudents)
- {
- var studentList = new Array();
-
- for(var x = 0; x < numberOfStudents; x++)
- {
- name = "Good Name-.," + x;
- email = "validemail" + x + "@gmail.com";
- teamName = "Good Team" + (x%40);
-
- if(x%2 == 0)
- {
- comments = "Good Comments" + x;
- }
-
- else
- {
- comments = "";
- }
-
- googleID = "";
-
- studentList[x] = {name:name, email:email, teamName:teamName, googleID:googleID, comments:comments};
-
- }
-
- return studentList;
- }
-
- /*
- * Returns
- *
- * 0: successful
- * 1: server error
- */
- function deleteAllStudents(courseID)
- {
- if(xmlhttp)
- {
- xmlhttp.open("POST","teammates",false);
- xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;");
- xmlhttp.send("operation=" + OPERATION_COORDINATOR_DELETEALLSTUDENTS + "&" + COURSE_ID + "=" + encodeURIComponent(courseID));
-
- return handleDeleteAllStudents(courseID);
- }
- }
-
- /*
- * Returns
- *
- * 0: successful
- * 1: server error
- *
- */
- function deleteCourse(courseID)
- {
- if(xmlhttp)
- {
- xmlhttp.open("POST","teammates",false);
- xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;");
- xmlhttp.send("operation=" + OPERATION_COORDINATOR_DELETECOURSE + "&" + COURSE_ID + "=" + encodeURIComponent(courseID));
-
- return handleDeleteCourse();
- }
- }
-
- /*
- * Returns
- *
- * 0: successful
- * 1: server error
- *
- */
- function deleteEvaluation(courseID, name)
- {
- if(xmlhttp)
- {
-
- xmlhttp.open("POST","teammates",false);
- xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;");
- xmlhttp.send("operation=" + OPERATION_COORDINATOR_DELETEEVALUATION + "&" + COURSE_ID + "="
- + encodeURIComponent(courseID) + "&" + EVALUATION_NAME + "=" + encodeURIComponent(name));
-
- return handleDeleteEvaluation();
- }
- }
-
- /*
- * Returns
- *
- * 0: successful
- * 1: server error
- */
- function deleteStudent(courseID, studentEmail)
- {
- if(xmlhttp)
- {
- xmlhttp.open("POST","teammates",false);
- xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;");
- xmlhttp.send("operation=" + OPERATION_COORDINATOR_DELETESTUDENT + "&" + COURSE_ID + "=" +
- encodeURIComponent(courseID) + "&" + STUDENT_EMAIL + "=" + encodeURIComponent(studentEmail));
-
- return handleDeleteStudent();
- }
- }
-
- /*
- * Returns
- *
- * 0: successful
- * 1: server error
- * 2: deadline passed
- * 3: fields missing
- *
- */
- function editEvaluationResults(submissionList, commentsEnabled)
- {
- for(loop = 0; loop < submissionList.length; loop++)
- {
- if(submissionList[loop].commentsToStudent == "" && commentsEnabled == true)
- {
- return 2;
- }
-
- if(submissionList[loop].justification == "")
- {
- return 2;
- }
-
- if( submissionList[loop].points == -999)
- {
- return 2;
- }
-
- if(!commentsEnabled)
- {
- submissionList[loop].commentsToStudent = "";
- }
- }
-
- var request = "operation=" + OPERATION_COORDINATOR_EDITEVALUATIONRESULTS + "&" + STUDENT_NUMBEROFSUBMISSIONS +
- "=" + submissionList.length + "&" + COURSE_ID + "=" + submissionList[0].courseID +
- "&" + EVALUATION_NAME + "=" + submissionList[0].evaluationName +
- "&" + STUDENT_TEAMNAME + "=" + submissionList[0].teamName;
-
- for(loop = 0; loop < submissionList.length; loop++)
- {
- request = request + "&" + STUDENT_FROMSTUDENT + loop + "=" +
- encodeURIComponent(submissionList[loop].fromStudent) + "&" +
- STUDENT_TOSTUDENT + loop + "=" +
- encodeURIComponent(submissionList[loop].toStudent) + "&" +
- STUDENT_POINTS + loop + "=" +
- encodeURIComponent(submissionList[loop].points) + "&" +
- STUDENT_JUSTIFICATION + loop + "=" +
- encodeURIComponent(submissionList[loop].justification) + "&" +
- STUDENT_COMMENTSTOSTUDENT + loop + "=" +
- encodeURIComponent(submissionList[loop].commentsToStudent);
- }
-
- if(xmlhttp)
- {
- xmlhttp.open("POST","teammates",false);
- xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;");
- xmlhttp.send(request);
-
- return handleEditEvaluationResults();
- }
- }
-
-
- /*
- * Returns
- *
- * 0: successful
- * 1: server error
- * 2: unable to change teams
- *
- */
- function editStudent(courseID, email, editName, editTeamName, editEmail, editGoogleID, editComments)
- {
- editName = trim(editName);
- editTeamName = trim(editTeamName);
- editEmail = trim(editEmail);
- editGoogleID = trim(editGoogleID);
-
-
- if(isEditStudentInputValid(editName, editTeamName, editEmail, editGoogleID))
- {
- if(xmlhttp)
- {
- xmlhttp.open("POST","teammates",false);
- xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;");
- xmlhttp.send("operation=" + OPERATION_COORDINATOR_EDITSTUDENT + "&" + COURSE_ID + "=" +
- encodeURIComponent(courseID) + "&" + STUDENT_EMAIL + "=" + encodeURIComponent(email) +
- "&" + STUDENT_EDITNAME + "=" + encodeURIComponent(editName) + "&" + STUDENT_EDITTEAMNAME + "=" + encodeURIComponent(editTeamName) +
- "&" + STUDENT_EDITEMAIL + "=" + encodeURIComponent(editEmail) + "&" + STUDENT_EDITGOOGLEID + "=" + encodeURIComponent(editGoogleID) +
- "&" + STUDENT_EDITCOMMENTS + "=" + encodeURIComponent(editComments));
-
- return handleEditStudent();
- }
- }
- }
-
- function editStudentListNameTeamComments(studentList)
- {
- for(var x = 0; x < studentList.length; x++)
- {
- if(x % 2 == 0)
- {
- studentList[x].name = studentList[x].name + x;
- }
-
- if(x % 3 == 0)
- {
- studentList[x].teamName = studentList[x].teamName + x;
- }
-
- if(x % 4 == 0)
- {
- studentList[x].comments = studentList[x].comments + x;
- }
- }
-
- return studentList;
- }
-
- function editStudentListNameTeamCommentsGoogleIDEmail(studentList)
- {
- for(var x = 0; x < studentList.length; x++)
- {
- if(x % 2 == 0)
- {
- studentList[x].name = studentList[x].name + x;
- }
-
- if(x % 3 == 0)
- {
- studentList[x].teamName = studentList[x].teamName + x;
- }
-
- if(x % 4 == 0)
- {
- studentList[x].comments = studentList[x].comments + x;
- }
-
- if(x % 5 == 0)
- {
- studentList[x].googleID = studentList[x].googleID + x;
- }
-
- if(x % 6 == 0)
- {
- studentList[x].email = x + studentList[x].email;
- }
- }
-
- return studentList;
- }
-
- /*
- * Returns
- *
- * reports: successful
- * 1: server error
- * 2: input empty
- * 3: input invalid
- *
- */
- function enrolStudents(input, courseID)
- {
- input = replaceAll(input,"|","\t");
-
- if(xmlhttp)
- {
- // Remove trailing "\n"
- if(input.lastIndexOf("\n") == input.length-1)
- {
- input = input.substring(0, input.length-1);
- }
-
- if(input == "")
- {
- return 2;
- }
-
- else if(isEnrollmentInputValid(input))
- {
- xmlhttp.open("POST","teammates",false);
- xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;");
- xmlhttp.send("operation=" + OPERATION_COORDINATOR_ENROLSTUDENTS + "&" + STUDENT_INFORMATION
- + "=" + encodeURIComponent(input) + "&" + COURSE_ID + "=" + encodeURIComponent(courseID));
-
- return handleEnrolStudents();
- }
-
- else
- {
- return 3;
- }
- }
- }
-
- /*
- * Returns
- *
- * courseList: successful
- * 1: server error
- *
- */
- function getCourseList()
- {
- if(xmlhttp)
- {
- xmlhttp.open("POST","teammates",false);
- xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;");
- xmlhttp.send("operation=" + OPERATION_COORDINATOR_GETCOURSELIST);
-
- return handleGetCourseList();
- }
- }
-
- /*
- * Returns
- *
- * evaluationList: successful
- * 1: server error
- *
- */
- function getEvaluationList()
- {
- if(xmlhttp)
- {
- OPERATION_CURRENT = OPERATION_COORDINATOR_GETEVALUATIONLIST;
-
- xmlhttp.open("POST","teammates",false);
- xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;");
- xmlhttp.send("operation=" + OPERATION_COORDINATOR_GETEVALUATIONLIST);
-
- return handleGetEvaluationList();
- }
- }
-
- /*
- * Returns
- *
- * studentList: successful
- * 1: server error
- *
- */
- function getStudentList(courseID)
- {
- if(xmlhttp)
- {
-
- xmlhttp.open("POST","teammates",false);
- xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;");
- xmlhttp.send("operation=" + OPERATION_COORDINATOR_GETSTUDENTLIST + "&" + COURSE_ID + "=" + encodeURIComponent(courseID));
-
- return handleGetStudentList();
- }
- }
-
- /*
- * Returns
- *
- * submissionList: successful
- * 1: server error
- *
- */
- function getSubmissionList(courseID, evaluationName)
- {
- if(xmlhttp)
- {
- xmlhttp.open("POST","teammates",false);
- xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;");
- xmlhttp.send("operation=" + OPERATION_COORDINATOR_GETSUBMISSIONLIST + "&" + COURSE_ID + "=" +
- encodeURIComponent(courseID) + "&" + EVALUATION_NAME + "=" + encodeURIComponent(evaluationName));
-
- return handleGetSubmissionList();
- }
- }
-
- // IMPORTANT: DUE TO SAME FUNCTION NAME IN BOTH COORDINATOR AND STUDENT JS FILES, THE GETSUBMISSIONLIST
- // AND HANDLEGETSUBMISSIONLIST FUNCTIONS FOR STUDENTS HAVE BEEN RENAMED WITH A POSTFIX OF "Student".
- // MOREOVER, PLEASE EDIT THE METHOD TO CALL THE CORRECT HANDLER FUNCTION
-
- /*
- * Returns
- *
- * submissionList: successful
- * 1: server error
- *
- */
- function getSubmissionListStudent(courseID, evaluationName)
- {
- if(xmlhttp)
- {
- xmlhttp.open("POST","teammates",false);
- xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;");
- xmlhttp.send("operation=" + OPERATION_STUDENT_GETSUBMISSIONLIST + "&" + COURSE_ID + "=" +
- encodeURIComponent(courseID) + "&" + EVALUATION_NAME + "=" + encodeURIComponent(evaluationName));
-
- return handleGetSubmissionListStudent();
- }
- }
-
- /*
- * Returns
- *
- * submissionList: successful
- * 1: server error
- *
- */
- function getSubmissionResultsList(courseID, evaluationName)
- {
- if(xmlhttp)
- {
- xmlhttp.open("POST","teammates",false);
- xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;");
- xmlhttp.send("operation=" + OPERATION_STUDENT_GETSUBMISSIONRESULTSLIST + "&" + COURSE_ID + "=" +
- encodeURIComponent(courseID) + "&" + EVALUATION_NAME + "=" + encodeURIComponent(evaluationName));
-
- return handleGetSubmissionResultsList();
- }
- }
-
- function getXMLObject()
- {
- var xmlHttp = false;
- try {
- xmlHttp = new ActiveXObject("Msxml2.XMLHTTP")
- }
- catch (e) {
- try {
- xmlHttp = new ActiveXObject("Microsoft.XMLHTTP")
- }
- catch (e2) {
- xmlHttp = false
- }
- }
- if (!xmlHttp && typeof XMLHttpRequest != 'undefined') {
- xmlHttp = new XMLHttpRequest();
- }
- return xmlHttp;
- }
-
- /*
- * Returns
- *
- * 0: successful
- * 1: server error
- * 5: course exists
- *
- */
- function handleAddCourse()
- {
- if (xmlhttp.status == 200)
- {
- var status = xmlhttp.responseXML.getElementsByTagName("status")[0];
- var message;
-
- if(status != null)
- {
- var message = status.firstChild.nodeValue;
-
- if(message == MSG_COURSE_EXISTS)
- {
- return 5;
- }
-
- else
- {
- return 0;
- }
- }
- }
-
- else
- {
- return 1;
- }
- }
-
- /*
- * Returns
- *
- * 0: successful
- * 1: server error
- * 5: evaluation exists
- * 6: course has no teams
- *
- */
- function handleAddEvaluation()
- {
- if (xmlhttp.status == 200)
- {
- var status = xmlhttp.responseXML.getElementsByTagName("status")[0];
- var message;
-
- if(status != null)
- {
- var message = status.firstChild.nodeValue;
-
- if(message == MSG_EVALUATION_EXISTS)
- {
- return 5;
- }
-
- else if(message == MSG_COURSE_NOTEAMS)
- {
- return 6;
- }
-
- else
- {
- return 0;
- }
- }
- }
-
- else
- {
- return 1;
- }
- }
-
- /*
- * Returns
- *
- * 0: successful
- * 1: server error
- *
- */
- function handleDeleteAllStudents(courseID)
- {
- if(xmlhttp)
- {
- return 0;
- }
-
- else
- {
- return 1;
- }
- }
-
- /*
- * Returns
- *
- * 0: successful
- * 1: server error
- *
- */
- function handleDeleteCourse()
- {
- if(xmlhttp)
- {
- return 0;
- }
-
- else
- {
- return 1;
- }
- }
-
- /*
- * Returns
- *
- * 0: successful
- * 1: server error
- *
- */
- function handleDeleteEvaluation()
- {
- if(xmlhttp)
- {
- return 0;
- }
-
- else
- {
- return 1;
- }
- }
-
- /*
- * Returns
- *
- * 0: successful
- * 1: server error
- *
- */
- function handleDeleteStudent()
- {
- if(xmlhttp.status == 200)
- {
- return 0;
- }
-
- else
- {
- return 1;
- }
- }
-
- /*
- * Returns
- *
- * 0: successful
- * 1: server error
- *
- */
- function handleEditEvaluationResults()
- {
- if(xmlhttp.status == 200)
- {
- return 0;
- }
-
- else
- {
- return 1;
- }
- }
-
- /*
- * Returns
- *
- * 0: successful
- * 1: server error
- * 2: unable to change teams
- *
- */
- function handleEditStudent()
- {
- if (xmlhttp.status == 200)
- {
- var status = xmlhttp.responseXML.getElementsByTagName("status")[0];
-
- if(status != null)
- {
- var message = status.firstChild.nodeValue;
-
- if(message == MSG_EVALUATION_UNABLETOCHANGETEAMS)
- {
- return 2;
- }
-
- else
- {
- return 0;
- }
- }
- }
-
- else
- {
- return 1;
- }
- }
-
- /*
- * Returns
- *
- * reports: successful
- * 1: server error
- *
- */
- function handleEnrolStudents()
- {
- if (xmlhttp.status == 200)
- {
- var enrollmentReports = xmlhttp.responseXML.getElementsByTagName("enrollmentreports")[0];
-
- if(enrollmentReports != null)
- {
- var enrollmentReport;
- var studentName;
- var studentEmail;
- var status;
- var nameEdited;
- var teamNameEdited;
- var commentsEdited;
-
- var reports = [];
-
- for(loop = 0; loop < enrollmentReports.childNodes.length; loop++)
- {
- enrollmentReport = enrollmentReports.childNodes[loop];
-
- studentName = enrollmentReport.getElementsByTagName(STUDENT_NAME)[0].firstChild.nodeValue;
- studentEmail = enrollmentReport.getElementsByTagName(STUDENT_EMAIL)[0].firstChild.nodeValue;
- status = enrollmentReport.getElementsByTagName(STUDENT_STATUS)[0].firstChild.nodeValue;
- nameEdited = enrollmentReport.getElementsByTagName(STUDENT_NAMEEDITED)[0].firstChild.nodeValue;
- teamNameEdited = enrollmentReport.getElementsByTagName(STUDENT_TEAMNAMEEDITED)[0].firstChild.nodeValue;
- commentsEdited = enrollmentReport.getElementsByTagName(STUDENT_COMMENTSEDITED)[0].firstChild.nodeValue;
-
- enrollmentReport = {studentName:studentName, studentEmail:studentEmail,
- nameEdited:nameEdited, teamNameEdited:teamNameEdited, commentsEdited:commentsEdited, status:status};
-
-
- reports.push(enrollmentReport);
-
- }
- }
-
- return reports;
- }
-
- else
- {
- return 1;
- }
-
- }
-
- /*
- * Returns
- *
- * courseList: successful
- * 1: server error
- *
- */
- function handleGetCourseList()
- {
- if (xmlhttp.status == 200)
- {
- var courses = xmlhttp.responseXML.getElementsByTagName("courses")[0];
- var courseList = new Array();
-
-
- if(courses != null)
- {
- var course;
- var ID;
- var name;
- var numberOfTeams;
- var status;
-
- for(loop = 0; loop < courses.childNodes.length; loop++)
- {
- course = courses.childNodes[loop];
- ID = course.getElementsByTagName(COURSE_ID)[0].firstChild.nodeValue;
- name = course.getElementsByTagName(COURSE_NAME)[0].firstChild.nodeValue;
- numberOfTeams = course.getElementsByTagName(COURSE_NUMBEROFTEAMS)[0].firstChild.nodeValue;
- status = course.getElementsByTagName(COURSE_STATUS)[0].firstChild.nodeValue;
- courseList[loop] = {ID:ID, name:name, numberOfTeams:numberOfTeams, status:status};
- }
- }
-
- return courseList;
- }
-
- else
- {
- return 1;
- }
-
- }
-
- /*
- * Returns
- *
- * evaluationList: successful
- * 1: server error
- *
- */
- function handleGetEvaluationList()
- {
- if (xmlhttp.status == 200)
- {
- var evaluations = xmlhttp.responseXML.getElementsByTagName("evaluations")[0];
- var evaluationList = new Array();
- var now = new Date();
-
- var evaluation;
- var courseID;
- var name;
- var commentsEnabled;
- var instructions;
- var start;
- var deadline;
- var gracePeriod;
- var numberOfCompletedEvaluations;
- var numberOfEvaluations;
- var published;
- var status;
- var activated;
-
- if(evaluations != null)
- {
- for(loop = 0; loop < evaluations.childNodes.length; loop++)
- {
- evaluation = evaluations.childNodes[loop];
-
- courseID = evaluation.getElementsByTagName(COURSE_ID)[0].firstChild.nodeValue;
- name = evaluation.getElementsByTagName(EVALUATION_NAME)[0].firstChild.nodeValue;
- commentsEnabled = (evaluation.getElementsByTagName(EVALUATION_COMMENTSENABLED)[0].firstChild.nodeValue.toLowerCase() == "true");
- instructions = evaluation.getElementsByTagName(EVALUATION_INSTRUCTIONS)[0].firstChild.nodeValue;
- start = new Date(evaluation.getElementsByTagName(EVALUATION_START)[0].firstChild.nodeValue);
- deadline = new Date(evaluation.getElementsByTagName(EVALUATION_DEADLINE)[0].firstChild.nodeValue);
- timeZone = parseFloat(evaluation.getElementsByTagName(EVALUATION_TIMEZONE)[0].firstChild.nodeValue);
- gracePeriod = parseInt(evaluation.getElementsByTagName(EVALUATION_GRACEPERIOD)[0].firstChild.nodeValue);
- published = (evaluation.getElementsByTagName(EVALUATION_PUBLISHED)[0].firstChild.nodeValue.toLowerCase() == "true");
- activated = (evaluation.getElementsByTagName(EVALUATION_ACTIVATED)[0].firstChild.nodeValue.toLowerCase() == "true");
- numberOfCompletedEvaluations = parseInt(evaluation.getElementsByTagName(EVALUATION_NUMBEROFCOMPLETEDEVALUATIONS)[0].firstChild.nodeValue);
- numberOfEvaluations = parseInt(evaluation.getElementsByTagName(EVALUATION_NUMBEROFEVALUATIONS)[0].firstChild.nodeValue);
-
- // Convert local time zone to ms
- var nowTime = now.getTime();
-
- // Obtain local time zone offset
- var localOffset = now.getTimezoneOffset() * 60000;
-
- // Obtain UTC time
- var UTC = nowTime + localOffset;
-
- // Add the time zone of evaluation
- var nowMilliS = UTC + (timeZone * 60 * 60 * 1000);
-
- now.setTime(nowMilliS);
-
- // Check if evaluation should be open or closed
- if(now > start && deadline > now)
- {
- status = "OPEN";
- }
-
- else if(now > deadline || activated)
- {
- status = "CLOSED";
- }
-
- else if (now < start && !activated)
- {
- status = "AWAITING";
- }
-
- if(published == true)
- {
- status = "PUBLISHED";
- }
-
- evaluationList[loop] = { courseID:courseID, name:name, commentsEnabled:commentsEnabled, instructions:instructions,
- start:start, deadline:deadline, timeZone:timeZone, gracePeriod:gracePeriod, published:published,
- published:published, activated:activated, numberOfCompletedEvaluations:numberOfCompletedEvaluations,
- numberOfEvaluations:numberOfEvaluations, status:status};
- }
- }
-
- return evaluationList;
- }
- else
- {
- 1;
- }
- }
-
- /*
- * Returns
- *
- * studentList: successful
- * 1: server error
- *
- */
- function handleGetStudentList()
- {
- if (xmlhttp.status == 200)
- {
- var students = xmlhttp.responseXML.getElementsByTagName("students")[0];
- var studentList = new Array();
-
- var student;
- var name;
- var teamName;
- var email;
- var registrationKey;
- var comments;
- var courseID;
- var googleID;
-
- for(var loop = 0; loop < students.childNodes.length; loop++)
- {
- student = students.childNodes[loop];
-
- name = student.getElementsByTagName(STUDENT_NAME)[0].firstChild.nodeValue;
- teamName = student.getElementsByTagName(STUDENT_TEAMNAME)[0].firstChild.nodeValue;
- email = student.getElementsByTagName(STUDENT_EMAIL)[0].firstChild.nodeValue;
- registrationKey = student.getElementsByTagName(STUDENT_REGKEY)[0].firstChild.nodeValue;
- googleID = student.getElementsByTagName(STUDENT_ID)[0].firstChild.nodeValue;
- comments = student.getElementsByTagName(STUDENT_COMMENTS)[0].firstChild.nodeValue;
- courseID = student.getElementsByTagName(STUDENT_COURSEID)[0].firstChild.nodeValue;
- studentList[loop] = {name:name, teamName:teamName, email:email, registrationKey:registrationKey, googleID:googleID,
- comments:comments, courseID:courseID};
- }
-
- return studentList;
- }
-
- else
- {
- return 1;
- }
- }
-
- /*
- * Returns
- *
- * submissionList: successful
- * 1: server error
- *
- */
- function handleGetSubmissionList()
- {
- if(xmlhttp.status == 200)
- {
- var submissions = xmlhttp.responseXML.getElementsByTagName("submissions")[0];
- var submissionList = new Array();
- var submission;
-
- var fromStudentName;
- var toStudentName;
- var fromStudent;
- var toStudent;
- var fromStudentComments;
- var toStudentComments;
- var courseID;
- var evaluationName;
- var teamName;
- var points;
- var pointsBumpRatio;
- var justification;
- var commentsToStudent;
-
- if(submissions != null)
- {
- for(loop = 0; loop < submissions.childNodes.length; loop++)
- {
- submission = submissions.childNodes[loop];
- fromStudentName = submission.getElementsByTagName(STUDENT_FROMSTUDENTNAME)[0].firstChild.nodeValue;
- fromStudent = submission.getElementsByTagName(STUDENT_FROMSTUDENT)[0].firstChild.nodeValue;
- toStudentName = submission.getElementsByTagName(STUDENT_TOSTUDENTNAME)[0].firstChild.nodeValue;
- toStudent = submission.getElementsByTagName(STUDENT_TOSTUDENT)[0].firstChild.nodeValue;
- fromStudentComments = submission.getElementsByTagName(STUDENT_FROMSTUDENTCOMMENTS)[0].firstChild.nodeValue;
- toStudentComments = submission.getElementsByTagName(STUDENT_TOSTUDENTCOMMENTS)[0].firstChild.nodeValue;
- courseID = submission.getElementsByTagName(COURSE_ID)[0].firstChild.nodeValue;
- evaluationName = submission.getElementsByTagName(EVALUATION_NAME)[0].firstChild.nodeValue;
- teamName = submission.getElementsByTagName(STUDENT_TEAMNAME)[0].firstChild.nodeValue;
- points = parseInt(submission.getElementsByTagName(STUDENT_POINTS)[0].firstChild.nodeValue);
- pointsBumpRatio = parseFloat(submission.getElementsByTagName(STUDENT_POINTSBUMPRATIO)[0].firstChild.nodeValue);
- justification = submission.getElementsByTagName(STUDENT_JUSTIFICATION)[0].firstChild.nodeValue;
- commentsToStudent = submission.getElementsByTagName(STUDENT_COMMENTSTOSTUDENT)[0].firstChild.nodeValue;
-
-
- submissionList[loop] = {fromStudentName:fromStudentName, toStudentName:toStudentName,
- fromStudent:fromStudent, toStudent:toStudent, courseID:courseID,
- evaluationName:evaluationName, teamName:teamName, justification:justification,
- commentsToStudent:commentsToStudent, points:points, pointsBumpRatio:pointsBumpRatio,
- fromStudentComments:fromStudentComments, toStudentComments:toStudentComments};
- }
- }
-
- return submissionList;
- }
-
- else
- {
- return 1;
- }
- }
-
- /*
- * Returns
- *
- * submissionList: successful
- * 1: server error
- *
- */
- function handleGetSubmissionListStudent()
- {
- if(xmlhttp.status == 200)
- {
- var submissions = xmlhttp.responseXML.getElementsByTagName("submissions")[0];
- var submissionList = new Array();
- var submission;
-
- var fromStudentName;
- var toStudentName;
- var fromStudent;
- var toStudent;
- var courseID;
- var evaluationName;
- var teamName;
- var points;
- var justification;
- var commentsToStudent;
-
- if(submissions != null)
- {
- for(loop = 0; loop < submissions.childNodes.length; loop++)
- {
- submission = submissions.childNodes[loop];
- fromStudentName = submission.getElementsByTagName(STUDENT_FROMSTUDENTNAME)[0].firstChild.nodeValue;
- fromStudent = submission.getElementsByTagName(STUDENT_FROMSTUDENT)[0].firstChild.nodeValue;
- toStudentName = submission.getElementsByTagName(STUDENT_TOSTUDENTNAME)[0].firstChild.nodeValue;
- toStudent = submission.getElementsByTagName(STUDENT_TOSTUDENT)[0].firstChild.nodeValue;
- courseID = submission.getElementsByTagName(COURSE_ID)[0].firstChild.nodeValue;
- evaluationName = submission.getElementsByTagName(EVALUATION_NAME)[0].firstChild.nodeValue;
- teamName = submission.getElementsByTagName(STUDENT_TEAMNAME)[0].firstChild.nodeValue;
- points = parseInt(submission.getElementsByTagName(STUDENT_POINTS)[0].firstChild.nodeValue);
- justification = submission.getElementsByTagName(STUDENT_JUSTIFICATION)[0].firstChild.nodeValue;
- commentsToStudent = submission.getElementsByTagName(STUDENT_COMMENTSTOSTUDENT)[0].firstChild.nodeValue;
-
-
- submissionList[loop] = {fromStudentName:fromStudentName, toStudentName:toStudentName,
- fromStudent:fromStudent, toStudent:toStudent, courseID:courseID,
- evaluationName:evaluationName, teamName:teamName, justification:justification,
- commentsToStudent:commentsToStudent, points:points};
- }
- }
-
- return submissionList;
- }
-
- else
- {
- return 1;
- }
- }
-
- /*
- * Returns
- *
- * submissionList: successful
- * 1: server error
- *
- */
- function handleGetSubmissionResultsList()
- {
- if(xmlhttp.status == 200)
- {
- var submissions = xmlhttp.responseXML.getElementsByTagName("submissions")[0];
- var submissionList = new Array();
- var submission;
-
- var fromStudentName;
- var toStudentName;
- var fromStudent;
- var toStudent;
- var fromStudentComments;
- var toStudentComments;
- var courseID;
- var evaluationName;
- var teamName;
- var points;
- var pointsBumpRatio;
- var justification;
- var commentsToStudent;
-
- if(submissions != null)
- {
- for(loop = 0; loop < submissions.childNodes.length; loop++)
- {
- submission = submissions.childNodes[loop];
- fromStudentName = submission.getElementsByTagName(STUDENT_FROMSTUDENTNAME)[0].firstChild.nodeValue;
- fromStudent = submission.getElementsByTagName(STUDENT_FROMSTUDENT)[0].firstChild.nodeValue;
- toStudentName = submission.getElementsByTagName(STUDENT_TOSTUDENTNAME)[0].firstChild.nodeValue;
- toStudent = submission.getElementsByTagName(STUDENT_TOSTUDENT)[0].firstChild.nodeValue;
- fromStudentComments = submission.getElementsByTagName(STUDENT_FROMSTUDENTCOMMENTS)[0].firstChild.nodeValue;
- toStudentComments = submission.getElementsByTagName(STUDENT_TOSTUDENTCOMMENTS)[0].firstChild.nodeValue;
- courseID = submission.getElementsByTagName(COURSE_ID)[0].firstChild.nodeValue;
- evaluationName = submission.getElementsByTagName(EVALUATION_NAME)[0].firstChild.nodeValue;
- teamName = submission.getElementsByTagName(STUDENT_TEAMNAME)[0].firstChild.nodeValue;
- points = parseInt(submission.getElementsByTagName(STUDENT_POINTS)[0].firstChild.nodeValue);
- pointsBumpRatio = parseFloat(submission.getElementsByTagName(STUDENT_POINTSBUMPRATIO)[0].firstChild.nodeValue);
- justification = submission.getElementsByTagName(STUDENT_JUSTIFICATION)[0].firstChild.nodeValue;
- commentsToStudent = submission.getElementsByTagName(STUDENT_COMMENTSTOSTUDENT)[0].firstChild.nodeValue;
-
- submissionList[loop] = {fromStudentName:fromStudentName, toStudentName:toStudentName,
- fromStudent:fromStudent, toStudent:toStudent, courseID:courseID,
- evaluationName:evaluationName, teamName:teamName, justification:justification,
- commentsToStudent:commentsToStudent, points:points, pointsBumpRatio:pointsBumpRatio,
- fromStudentComments:fromStudentComments, toStudentComments:toStudentComments};
- }
- }
-
- return submissionList;
- }
-
- else
- {
- return 1;
- }
- }
-
- /*
- * Returns
- *
- * 0: successful
- * 1: server error
- * 2: google ID already exists in course
- * 3: registration key invalid
- * 4: registration key taken
- *
- */
- function handleJoi…
Large files files are truncated, but you can click here to view the full file