static function fetch($id) { $q = new Query('CourseOffering'); $q->select_object('CourseOffering')->where_eq(CourseOffering::id, $id); return $q->executeFetchScalar(); }
$q = new Query('course_offerings'); $q->select_object('CourseOffering'); $q->where("term=? \n\t\t\t\t\t\tAND year=?\n\t\t\t\t\t\tAND course_code = ?\n\t\t\t\t\t\tAND section = ?", [$term, $year, $course_code, $section_id]); $result = $q->executeFetchAll(); if (count($result) < 1) { echo '<p style="color:red">Could not find section ' . $sectioncode . '</p>'; continue; } if ($result[0][0]->getcapacity() - $result[0][0]->getenrolled() > 0 or $result[0][0]->getcapacity() == 0) { $sql = "UPDATE course_offerings\n\t\t\t\t\t\tSET enrolled=enrolled+1\n\t\t\t\t\t\tWHERE \n\t\t\t\t\t\tterm=?\n\t\t\t\t\t\tAND year=?\n\t\t\t\t\t\tAND course_code=?\n\t\t\t\t\t\tAND section=?\n\t\t\t\t\t\tAND (enrolled < capacity OR capacity=0)"; $result = db_exec($sql, [$term, $year, $course_code, $section_id]); if ($result->rowCount() == 0) { echo '<p style="color:red">Section ' . $sectioncode . ' is now full. Continued registration in remaining courses</p>'; } else { $q = new Query('course_offerings'); $q->select_object('CourseOffering'); $q->where("term=? \n\t\t\t\t\t\tAND year=?\n\t\t\t\t\t\tAND course_code = ?\n\t\t\t\t\t\tAND section = ?", [$term, $year, $course_code, $section_id]); $result = $q->executeFetchAll(); if (isset($result[0])) { if ($result[0][0]->getcapacity() != 0) { echo '<p>Registered in ' . $sectioncode . ' Seats remaining:' . ($result[0][0]->getcapacity() - $result[0][0]->getenrolled()) . '</p>'; } else { echo '<p>Registered in ' . $sectioncode . '</p>'; } } } } else { echo '<p style="color:red">Section ' . $sectioncode . ' is now full. Continued registration in remaining courses</p>'; } } echo '<h2>Registration completed</h2>';
static function fetch($code) { $q = new Query('Course'); $q->select_object('Course')->where_eq(Course::code, $code); return $q->executeFetchScalar(); }
function getOfferingInfo($course_code) { $offerings = array(); //Get all the lecture sections for a particular course $q = new Query("course_offerings"); $q->select_object("CourseOffering"); $q->where('course_code=? AND term=? AND year=? AND (capacity - enrolled) > 0 AND type=0', [$course_code, $this->term, $this->year]); $rows = $q->executeFetchAll(); //For each lecture section get the available lab/tutorial sections foreach ($rows as $row) { $sub = new Query("course_offerings"); $sub->select_object('CourseOffering'); $sub->where("course_code=?\n\t\t\t\t\t\t\t\t AND (section LIKE CONCAT(?,'%')\n\t\t\t\t\t\t\t\t OR section LIKE ('L%'))\n\t\t\t\t\t\t\t\t AND (((capacity-enrolled) > 0) OR (capacity=0))\n\t\t\t\t\t\t\t\t AND term=?\n\t\t\t\t\t\t\t\t AND year=?\n\t\t\t\t\t\t\t\t AND type <> 0", [$course_code, $row[0]->getsection(), $term, $year]); array_push($offerings, ['labs' => $sub->executeFetchAll(), 'lecture' => $row[0]]); } return $offerings; }
* /api/courses.php?qualified&completed[]=SYSC1005&completed[]=ECOR1010&taking[]=SYSC2006 * - completed: An array of completed courses. Ignored if * `qualified` not set * - taking: An array of courses that are being taken in the same * term. Ignored if `qualified` not set. * * Returns: * <response e="0"> * <courses> * <!-- One course element per course in the result. --> * <course>...</course> * </courses> * </response> */ $q = new Query('Course'); $q->select_object('Course'); // Filter based on course code (or prefix thereof) if (isset($_GET['code'])) { $q->where_startswith(Course::code, strtoupper($_GET['code'])); } // Filter where dependancies are satisfied. if (isset($_GET['qualified'])) { $completed = isset($_GET['completed']) ? $_GET['completed'] : []; $taking = isset($_GET['taking']) ? $_GET['taking'] : []; foreach ($completed as &$c) { $c = strtoupper($c); } foreach ($taking as &$c) { $c = strtoupper($c); } $preqquery = Course::query_prerequisites(Course::code, $completed, $taking);
static function fetch($code) { $q = new Query('Program'); $q->select_object('Program')->where_eq(Program::id, $code); return $q->executeFetchScalar(); }