function getByID($ID) { // print "ID:$ID<br />"; $hashUserID = hashUserID($ID); $query = "SELECT id FROM users WHERE hash_user_id LIKE '{$hashUserID}'"; #$query = "SELECT id FROM users WHERE first_name LIKE 'shane'"; // print "query:$query<br />"; $result = mysql_query($query, $this->link); // echo mysql_errno($dbConn) . ": " . mysql_error($dbConn) . "<br />"; if (false == $result) { die("query failed"); } if (1 == mysql_num_rows($result)) { $userID = mysql_result($result, 0); } else { $userID = null; } return $userID; }
function updateClassEnrollment($classID, $dbConn, $command, $commandState, $csvStudentListArray = null) { global $session, $department, $courseNo, $sectionNo, $season, $yteststudent_hashed_id; $isCourseNo4Character = strlen($courseNo) == 4; $oldEnrolled = getStudentsInClass_FROM_OVAL_DB($classID, $dbConn); $oldEnrolled = empty($oldEnrolled) ? array() : $oldEnrolled; $oldEnrolledTotal = count($oldEnrolled); if ($command == Commands::ImportFromSIS) { if (is_null($department) || strlen($department) < 4 || (is_null($courseNo) || strlen($courseNo) < 3 || strlen($courseNo) > 4 || !is_numeric(substr($courseNo, 0, strlen($courseNo - 1)))) || (is_null($sectionNo) || strlen($sectionNo) < 3 || strlen($sectionNo) > 4)) { print "<br/><span style=\"color:red;font-weight:bold\">\r\n\t\t\t\t\tSTOP! This OVAL course does not appear to be a standard UBC course!\r\n\t\t\t\t\t<br/>\r\n\t\t\t\t\tThe enrollment list cannot be queried automatically from SIS.\r\n\t\t\t\t\t<br/>\r\n\t\t\t\t\tPlease return to the main menu and import a CSV student list instead.\r\n\t\t\t\t\t</span>\r\n\t\t\t\t\t<br/>"; return; } } if (empty($csvStudentListArray)) { $studentNos = getStudentNumbers_FROM_SIS($session, $department, $courseNo, $sectionNo, $season); } else { $studentNos = $csvStudentListArray; $totalEnrolled = $studentNos == null ? 0 : count($studentNos); print "<br/>New enrollment list (excluding the test account): {$totalEnrolled} students<br/>"; if ($commandState != CommandStates::Execute) { DEBUG_printSimpleArray($studentNos); print "<br/>"; } print "<br/>"; } // Courses with letters at the end sometimes have problems, let's try again! if ($isCourseNo4Character && $command == Commands::ImportFromSIS) { $courseNoWoutLetter = substr($courseNo, 0, 3); if (empty($studentNos)) { print "<span style=\"color:blue;font-weight:bold\">\r\n\t\t\t\t\tWarning: Has zero students. Let's try again once.</span>\r\n\t\t\t\t\t<br/><br/>"; $studentNos = getStudentNumbers_FROM_SIS($session, $department, $courseNoWoutLetter, $sectionNo, $season); } } if (!empty($studentNos)) { $EntriesToSkip = array(); foreach ($studentNos as $key => $studentNo) { if (!is_null($studentNo) && strlen($studentNo) >= 2) { $newEnrolled[] = hashUserID($studentNo); } else { $EntriesToSkip[] = $key + 1; } } if (!empty($EntriesToSkip)) { print "<span style=\"color:blue;font-weight:bold\">\r\n\t\t\t\t\tWarning: Several input ID's were found to be corrupted (blank, too short, etc.) and skipped, at positions:<br/>\r\n\t\t\t\t\t</span>"; DEBUG_printSimpleArray($EntriesToSkip, 1, 70); print "<br/><br/>"; } // yteststudent account $newEnrolled[] = $yteststudent_hashed_id; print "Also include the test student account, hashed student ID: {$yteststudent_hashed_id}<br/>"; $newEnrolledTotal = count($newEnrolled); $compareViewWidth = $commandState == CommandStates::Preview ? "1000px" : "800px"; $compareViewMinWidth = $compareViewWidth - 10; print "<div style=\"min-width:{$compareViewMinWidth}" . "px;text-align:center;\">"; print "<br/><fieldset style=\"border:0px;margin:0px;padding:0px;margin-left:auto;margin-right:auto;width:{$compareViewWidth}\">"; print "<div style=\"float:left;\">Existing enrollment list in OVAL (hashed): <b>{$oldEnrolledTotal} students</b><br />"; if ($commandState == CommandStates::Preview) { DEBUG_printSimpleArray($oldEnrolled); } print "</div>"; print "<div style=\"float:right\">New enrollment list (hashed): <b>{$newEnrolledTotal} students</b><br />"; if ($commandState == CommandStates::Preview) { DEBUG_printSimpleArray($newEnrolled); } print "</div>"; print "</fieldset>"; print "</div>"; // get the difference $usersToAdd = array_diff($newEnrolled, $oldEnrolled); $usersToDrop = array_diff($oldEnrolled, $newEnrolled); $usersToAddTotal = count($usersToAdd); $usersToDropTotal = count($usersToDrop); print "<div style=\"min-width:{$compareViewMinWidth}" . "px;text-align:center;\">"; print "<br/><fieldset style=\"border:0px;margin:0px;padding:0px;margin-left:auto;margin-right:auto;width:{$compareViewWidth}\">"; print "<div style=\"float:left\">Users to add to {$session}{$season} {$department} {$courseNo} {$sectionNo}: <b>{$usersToAddTotal} students</b><br />"; if ($commandState == CommandStates::Preview) { DEBUG_printSimpleArray($usersToAdd); } print "</div>"; print "<div style=\"float:right\">Users to drop from {$session}{$season} {$department} {$courseNo} {$sectionNo}: <b>{$usersToDropTotal} students</b><br />"; if ($commandState == CommandStates::Preview) { DEBUG_printSimpleArray($usersToDrop); } print "</div>"; print "</fieldset>"; print "</div>"; print "<br/>"; $nothingToDo = $usersToAddTotal == 0 && $usersToDropTotal == 0; if ($nothingToDo) { print "<span style=\"color:blue;font-weight:bold\">\r\n\t\t\t\t\tWarning: apparently both the \"to add\" and \"to drop\" lists are empty.<br/>\r\n\t\t\t\t\tThere is probably nothing to do for this command, or you should import another data source.\r\n\t\t\t\t\t</span>\r\n\t\t\t\t\t<br/><br/>"; } if ($isCourseNo4Character && $command == Commands::ImportFromSIS) { print "<span style=\"color:blue;font-weight:bold\">\r\n\t\t\t\t\tWarning: SIS often doesn't return correct enrollment lists for courses ending with a letter.<br/>\r\n\t\t\t\t\tIf the number of students is different from students.ubc.ca, please import an enrollment list (csv) manually.</span>\r\n\t\t\t\t\t<br/><br/>"; } if ($nothingToDo) { return; } if ($commandState == CommandStates::Preview) { print "<span style=\"color:red;font-weight:bold\">\r\n\t\t\t\tSTOP! Check the student numbers, or at least the total number enrolled, against students.ubc.ca to make sure!\r\n\t\t\t\t<br>\r\n\t\t\t\tPlease also double check the year, season, etc. to ensure that you are updating the course that you intended!\r\n\t\t\t\t</span>\r\n\t\t\t\t<br/><br/>"; printExecuteImportCSVForm($classID, $session, $department, $courseNo, $sectionNo, $season, "Go Ahead and Execute the Update(s)", $studentNos); } else { print "<span style=\"font-weight:bold\">\r\n\t\t\t\tSTOP! Please check the results of the database updates to OVAL \r\n\t\t\t\t<br>\r\n\t\t\t\tto make sure that all the results are <span style=\"color:green\">green</span>\r\n\t\t\t\t</span>\r\n\t\t\t\t<br/><br/>"; // The rest of the debug messages (SQL output) goes into a text area, for neatness print "<div style=\"min-width:1024px;text-align:center;font-size:75%\">"; print "<div style=\"margin-left:auto;margin-right:auto;border:1px solid gray;height:200px;width:1030px;white-space:pre-wrap;overflow:scroll;\">"; // add new users to the course, creating new users if necessary. $userIDs = createUsers($usersToAdd, STUDENT, $dbConn, true); addStudents($classID, $userIDs, $dbConn); UTIL_setDefaultUISettings($userIDs); UTIL_addToEveryoneGroup($userIDs, $classID, $dbConn); // dropping old students from the course and the everyone_group UTIL_dropHashedStudentsFromCourse($usersToDrop, $classID, $dbConn); print "</div></div>"; } } else { print "<span style=\"color:red;font-weight:bold\">\r\n\t\t\t\tSTOP! SIS returns 0 students in the course for this term. Perhaps try again later or import a spreadsheet.\r\n\t\t\t\t<br>\r\n\t\t\t\tAlso double check the year, season, etc. to ensure that you are updating the course that you intended!\r\n\t\t\t\t</span>\r\n\t\t\t\t<br/>"; } }
/** * OVAL (Online Video Annotation for Learning) is a video annotation tool * that allows users to make annotations on videos. * * Copyright (C) 2014 Shane Dawson, University of South Australia, Australia * Copyright (C) 2014 An Zhao, University of South Australia, Australia * Copyright (C) 2014 Dragan Gasevic, University of Edinburgh, United Kingdom * Copyright (C) 2014 Negin Mirriahi, University of New South Wales, Australia * Copyright (C) 2014 Abelardo Pardo, University of Sydney, Australia * Copyright (C) 2014 Alan Kingstone, University of British Columbia, Canada * Copyright (C) 2014 Thomas Dang, , University of British Columbia, Canada * Copyright (C) 2014 John Bratlien, University of British Columbia, Canada * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/> */ require_once dirname(__FILE__) . "/includes/auth.inc.php"; $ID = ''; print hashUserID($ID);