protected function showCourses() { if (!($listNode = $this->template->getElementByID("existing_course_list")) instanceof DOMNode) { return; } if ($this->getUser()->role == "registrar" || $this->getUser()->role == "lecturer" || $this->getUser()->role == "hod" || $this->getUser()->role == "principal" || $this->getUser()->role == "deputy_principal") { ######getting id of the currently logged in lecturer###### $username = $this->getUser()->username; $where = array("operator" => "FIELD_LIMIT", "field" => "identification_number", "style" => "equals", "data" => array("value" => $username)); $lecturer = I2CE_FormStorage::search("lecturer", false, $where); foreach ($lecturer as $id) { $lecturer_id = "lecturer|" . $id; } ######Getting the current academic year###### $academic_year = iHRIS_AcademicYear::currentAcademicYear(); $where = array("operator" => "FIELD_LIMIT", "field" => "name", "style" => "equals", "data" => array("value" => $academic_year)); $academic_year_id = I2CE_FormStorage::Search("academic_year", false, $where); $academic_year_id = "academic_year|" . $academic_year_id[0]; ######Getting a list of courses assigned to this lecturer###### $where_assign_course = array("operator" => "AND", "operand" => array(0 => array("operator" => "FIELD_LIMIT", "field" => "lecturer", "style" => "equals", "data" => array("value" => $lecturer_id)), 1 => array("operator" => "FIELD_LIMIT", "field" => "academic_year", "style" => "equals", "data" => array("value" => $academic_year_id)))); $assigned_courses = I2CE_FormStorage::listFields("assign_course_trainer", array("training"), false, $where_assign_course); } else { $this->userMessage("Login as a training provider to add results"); $this->redirect("manage?action=provider"); return false; } ######Displaying courses assigned to this lecturer###### if (count($assigned_courses) == 0) { $this->userMessage("No courses assigned to you,contact the Registrar for further assistance"); $this->redirect("manage?action=provider"); return false; } foreach ($assigned_courses as $id => $course) { $course_id = explode("|", $course["training"]); $course_id = $course_id[1]; $where = array("operator" => "FIELD_LIMIT", "field" => "id", "style" => "equals", "data" => array("value" => $course_id)); $training_courses = I2CE_FormStorage::ListFields("training", array("name", "code"), false, $where); foreach ($training_courses as $id => $training_course) { $course_name = $training_course["name"]; $course_code = $training_course["code"]; $course = $course_code . "-" . $course_name; $id = "training|" . $id; $aNode = $this->template->createElement("a", array(href => "add_results?id=" . $id), $course); $liNode = $this->template->createElement("li"); $this->template->appendNode($aNode, $liNode); $this->template->appendNode($liNode, $listNode); } } }
static function ensureAcademicYear() { $academic_year = self::currentAcademicYear(); $academic_years = I2CE_FormStorage::ListFields("academic_year", array("name")); $latest = false; //check to see if the academic_year in the DB is latest foreach ($academic_years as $db_academic_year) { if ($db_academic_year["name"] == $academic_year) { $latest = true; } } //if not latest,add latest if ($latest == false) { $accObj = I2CE_FormFactory::instance()->createContainer("academic_year"); $accObj->getField("name")->setFromPost($academic_year); $user = new I2CE_User(); $accObj->save($user); } }
protected function getElectiveCourses($curr_semester) { $current_academic_year = iHRIS_AcademicYear::currentAcademicYear(); $academic_year_id = iHRIS_AcademicYear::academicYearId($current_academic_year); $current_academic_year_id = "academic_year|" . $academic_year_id; $semester = self::getSemesterName($curr_semester); $trng_prgrms = self::get_institution_programs(); unset($trng_prgrms[$this->program]); for ($semester = $semester; $semester > 0; $semester = $semester - 2) { $semester_id = "semester|" . self::getSemesterId($semester); $where = array("operator" => "AND", "operand" => array(0 => array("operator" => "FIELD_LIMIT", "field" => "semester", "style" => "equals", "data" => array("value" => $semester_id)), 1 => array(0 => array("operator" => "FIELD_LIMIT", "field" => "training_program", "style" => "in", "data" => array("value" => $trng_prgrms))))); $courses = I2CE_FormStorage::listFields("training", array("id"), false, $where); foreach ($courses as $id => $course_array) { $training_course = "training|" . $id; if ($this->is_rescheduled($training_course, $current_academic_year_id, $curr_semester)) { continue; } //check if a student took and passed this course then skip displaying it $where = array("operator" => "AND", "operand" => array(0 => array("operator" => "FIELD_LIMIT", "field" => "training", "style" => "equals", "data" => array("value" => $training_course)), 1 => array("operator" => "FIELD_LIMIT", "field" => "parent", "style" => "equals", "data" => array("value" => $this->person_id)), 2 => array("operator" => "FIELD_LIMIT", "field" => "registration", "style" => "equals", "data" => array("value" => $this->student_registration["id"])))); $results = I2CE_FormStorage::ListFields("students_results_grade", array("total_marks", "status"), false, $where); $status = "display"; foreach ($results as $result) { if ($result["status"] == "status|pass") { $status = "pass"; break; } } if ($status == "display") { $this->elective_courses[$id] = $training_course; } } //get elective courses that have been rescheduled to this semester $where = array("operator" => "AND", "operand" => array(0 => array("operator" => "FIELD_LIMIT", "field" => "academic_year", "style" => "equals", "data" => array("value" => $current_academic_year_id)), 1 => array("operator" => "FIELD_LIMIT", "field" => "semester", "style" => "equals", "data" => array("value" => $semester)), 2 => array("operator" => "NOT", "operand" => array(0 => array("operator" => "FIELD_LIMIT", "field" => "training_program", "style" => "equals", "data" => array("value" => $this->program)))), 3 => array("operator" => "FIELD_LIMIT", "field" => "training_institution", "style" => "equals", "data" => array("value" => $this->training_institution)))); $courses = I2CE_FormStorage::listFields("reschedule_course", array("training"), false, $where); foreach ($courses as $course) { $trn_id = explode("|", $course["training"]); $id = $trn_id[1]; $this->elective_courses[$id] = $course["training"]; } } }
protected function getCourseHighestMark($course_id) { $where = array("operator" => "AND", "operand" => array(0 => array("operator" => "FIELD_LIMIT", "field" => "registration_number", "style" => "equals", "data" => array("value" => $this->reg_num)), 1 => array("operator" => "FIELD_LIMIT", "field" => "training", "style" => "equals", "data" => array("value" => $course_id)), 2 => array("operator" => "FIELD_LIMIT", "field" => "registration", "style" => "equals", "data" => array("value" => $this->student_registration["id"])))); $results = I2CE_FormStorage::ListFields("students_results_grade", array("total_marks"), false, $where); $mark = null; foreach ($results as $result) { //if total marks is missing then this course has no all results,return false if ($mark < $result["total_marks"]) { $mark = $result["total_marks"]; } } return $mark; }