/** * Create and load data for the objects used for this form. */ protected function loadObjects() { //check to ensure that the current academic year is available iHRIS_AcademicYear::ensureAcademicYear(); if (!$this->hasPermission("task(can_approve_results)") or $this->getUser()->role == "admin") { $this->setRedirect("noaccess"); } if ($this->isPost()) { $apprObj = $this->factory->createContainer("results_approval"); $this->applyLimits($apprObj); $apprObj->load($this->post); } else { $username = $this->getUser()->username; $user_info = iHRIS_PageFormLecturer::fetch_user_info($username); $inst_id = $user_info["training_institution"]; $academic_year = iHRIS_AcademicYear::currentAcademicYear(); $academic_year_id = iHRIS_AcademicYear::academicYearId($academic_year); $academic_year_id = "academic_year|" . $academic_year_id; //check if the object exists $where = array("operator" => "AND", "operand" => array(0 => array("operator" => "FIELD_LIMIT", "field" => "academic_year", "style" => "equals", "data" => array("value" => $academic_year_id)), 1 => array("operator" => "FIELD_LIMIT", "field" => "training_institution", "style" => "equals", "data" => array("value" => $inst_id)))); $approval = I2CE_FormStorage::search("results_approval", false, $where); $appr_id = 0; foreach ($approval as $appr) { $appr_id = $appr; } $apprObj = $this->factory->createContainer("results_approval|" . $appr_id); $apprObj->populate(); $this->applyLimits($apprObj); } $this->setObject($apprObj, I2CE_PageForm::EDIT_PRIMARY, null, true); }
/** * Create and load data for the objects used for this form. */ protected function loadObjects() { $this->ff = I2CE_FormFactory::instance(); //check to ensure that the current academic year is available iHRIS_AcademicYear::ensureAcademicYear(); $selected_courses = $this->post("course"); $person_id = $this->post("person_id"); $curr_semester = $this->post("curr_semester"); $student_registration = STS_PageFormPerson::load_current_registration($person_id); if (count($selected_courses) == 0) { $this->userMessage("No courses Selected!!!"); $this->setRedirect("view?id=" . $this->person_id); } foreach ($selected_courses as $course) { $courseObj = $this->factory->createContainer($course); $courseObj->populate(); $total_credits = $total_credits + $courseObj->getField("course_credits")->getDBValue(); } $selected_courses = implode(",", $selected_courses); $where = array("operator" => "AND", "operand" => array(0 => array("operator" => "FIELD_LIMIT", "field" => "parent", "style" => "equals", "data" => array("value" => $person_id)), 1 => array("operator" => "FIELD_LIMIT", "field" => "semester", "style" => "equals", "data" => array("value" => $curr_semester)), 2 => array("operator" => "FIELD_LIMIT", "field" => "registration", "style" => "equals", "data" => array("value" => $student_registration["id"])))); $enrolled_courses = I2CE_FormStorage::search("enroll_course", false, $where); if (count($enrolled_courses) > 0) { foreach ($enrolled_courses as $enrollment) { $course_enrollment_form = "enroll_course|" . $enrollment; } } else { $course_enrollment_form = "enroll_course"; } if (!($enrollcourseObj = $this->ff->createContainer($course_enrollment_form)) instanceof I2CE_Form) { I2CE::raiseError("Invalid Object"); return false; } $trainingCourseField = $enrollcourseObj->getField("training"); $trainingCourseField->setFromPost($selected_courses); $date_enrolled = date("Y-m-d"); $enrollcourseObj->getField("date_enrolled")->setFromDB($date_enrolled); $semesterField = $enrollcourseObj->getField("semester"); $semesterField->setFromPost($curr_semester); $enrollcourseObj->getField("total_credits")->setValue($total_credits); $enrollcourseObj->getField("registration")->setFromDB($student_registration["id"]); $current_academic_year = iHRIS_AcademicYear::currentAcademicYear(); $academic_year_id = iHRIS_AcademicYear::academicYearId($current_academic_year); $academic_year_id = "academic_year|" . $academic_year_id; if (!($academicYearField = $enrollcourseObj->getField("academic_year")) instanceof I2CE_FormField_MAP) { return; } $academicYearField->setFromDB($academic_year_id); $parentObj = $this->ff->createContainer($person_id); if ($parentObj instanceof I2CE_Form) { $parentObj->populate(); } $this->setObject($enrollcourseObj, I2CE_PageForm::EDIT_PRIMARY); $this->setObject($parentObj, I2CE_PageForm::EDIT_PARENT); parent::save(); $this->userMessage("Courses Enrolled Successfully"); $this->setRedirect("view?id=" . $person_id); return true; }
/** * Create and load data for the objects used for this form. * * Create the list object and if this is a form submission load * the data from the form data. */ protected function loadObjects() { $role = $this->getUser()->role; if ($role != "registrar") { $this->userMessage("Only Registrar Can Add Students"); $this->setRedirect("home"); } //check to ensure that the current academic year is available iHRIS_AcademicYear::ensureAcademicYear(); $username = $this->getUser()->username; $inst_id = iHRIS_PageFormLecturer::fetch_institution($username); $factory = I2CE_FormFactory::instance(); if ($this->isPost()) { $person = $factory->createContainer("person"); $person->load($this->post); $regObj = $factory->createContainer("registration"); $regObj->load($this->post); $regObj->getField("training_institution")->setFromDB($inst_id); $regObj->getField("registration_status")->setFromDB("registration_status|ongoing"); $program = $regObj->getField("training_program")->getDBValue(); $st_reg_num = self::generateRegistrationNumber($program, $inst_id); $regObj->getField("registration_number")->setFromPost($st_reg_num); } else { if ($this->get_exists('id')) { $id = $this->get('id'); if (strpos($id, '|') === false) { I2CE::raiseError("Depcreated use of id variable"); $id = 'person|' . $id; } } else { $id = 'person|0'; } $person = $factory->createContainer($id); if ($this->get_exists('id')) { $person->populateChildren("registration"); foreach ($person->getChildren("registration") as $regObj) { } } else { $regObj = $this->factory->createContainer("registration|0"); } if (!$person instanceof iHRIS_Person) { I2CE::raiseError("Could not create valid person form from id:{$id}"); return; } $person->populate(); $person->load($this->request()); } $this->applyLimits($inst_id, $person, $regObj); $this->template->setForm($regObj); $this->template->setForm($person); }
protected function action() { if (!$this->hasPermission("task(can_add_students_results)" or $this->getUser()->role == "admin")) { $this->setRedirect("noaccess"); } $this->ff = I2CE_FormFactory::instance(); $this->user = new I2CE_User(); //check to ensure that the current academic year is available iHRIS_AcademicYear::ensureAcademicYear(); $this->current_academic_year = iHRIS_AcademicYear::currentAcademicYear(); $academic_year_id = iHRIS_AcademicYear::academicYearId($this->current_academic_year); $this->academic_year_id = "academic_year|" . $academic_year_id; $this->course_id = $this->request("course_id"); if (!($courseObj = $this->ff->createContainer($this->course_id)) instanceof iHRIS_Training || !($examTypesField = $courseObj->getField('training_course_exam_type')) instanceof I2CE_FormField_MAP_MULT) { I2CE::raiseError("Invalid training course: " . $this->course_id); return false; } $courseObj->populate(); $reg_numbers = $this->post("reg_num"); ######start processing results of each student###### foreach ($reg_numbers as $this->reg_num) { $this->getParentId($this->reg_num); $all_results = false; $this->update = false; ######process each course assessment for this student###### $exam_types = explode(",", $examTypesField->getDBValue()); foreach ($exam_types as $exam_type) { if ($this->post_exists($this->reg_num . "_results")) { $this->students_results_grade_form = "students_results_grade|" . $this->post($this->reg_num . "_results"); break; } else { $this->students_results_grade_form = "students_results_grade"; } } foreach ($exam_types as $exam_type) { ######Skip processing existing assessment results###### $mark = $this->check_assessment_mark($exam_type); if ($this->post($exam_type . "/" . $this->reg_num) != "" and $mark < 0) { $this->results[$exam_type] = $this->post($exam_type . "/" . $this->reg_num); } } if (count($this->results) > 0) { $this->saveResults($exam_types); } unset($this->results); ######End of processing each course assessment for this student###### } ######End of processing results of each student###### }
/** * Create and load data for the objects used for this form. */ protected function loadObjects() { if (!$this->hasPermission("task(can_assign_course_trainer)") or $this->getUser()->role == "admin") { $this->setRedirect("noaccess"); } $factory = I2CE_FormFactory::instance(); //check to ensure that the current academic year is available iHRIS_AcademicYear::ensureAcademicYear(); if ($this->isPost()) { $assign_course_trainer = $factory->createContainer("assign_course_trainer"); $assign_course_trainer->load($this->post); $this->applyLimits($assign_course_trainer); $this->setObject($assign_course_trainer); } else { if ($this->get_exist("id")) { $id = "assign_course_trainer|" . $this->get('id'); } $id = "assign_course_trainer|0"; $assign_course_trainer = $factory->createContainer($id); $this->applyLimits($assign_course_trainer); $assign_course_trainer->populate(); $this->setObject($assign_course_trainer); } }
protected function action() { $role = $this->getUser()->role; if ($role != "student") { $this->userMessage("Only A Student Can Enroll Into Courses"); $this->setRedirect("view?id=" . $this->Get("parent")); return false; } iHRIS_AcademicYear::ensureAcademicYear(); $this->person_id = $this->Get("parent"); $this->getProgramAndSemester(); ############Deny Course Registration For A Student Dropped Out Of Semester################### $persObj = I2CE_FormFactory::instance()->createContainer($this->person_id); $persObj->populateChildren("drop_semester"); foreach ($persObj->getChildren("drop_semester") as $dropSemObj) { //check to insure that this drop semester is the one that belongs to the current registration if ($dropSemObj->getField("registration")->getDBValue() != $this->student_registration["id"]) { continue; } $dropSemObj->populateChildren("resume_semester"); $resSemObj = $dropSemObj->getChildren("resume_semester"); if (count($resSemObj) == 0) { $this->userMessage("You Are Currently Dropped From A Semester,Course Enrollment Not Allowed"); $this->setRedirect("view?id=" . $this->person_id); return; } } ############End Of Denying Course Registration For A Student Dropped Out Of Semester################### ############checking if course enrollment closed################# $username = $this->getUser()->username; $this->training_institution = iHRIS_PageFormLecturer::fetch_institution($username); $where = array("operator" => "FIELD_LIMIT", "field" => "training_institution", "style" => "equals", "data" => array("value" => $this->training_institution)); $fields = I2CE_FormStorage::listFields("schedule_course_enrollment", array("start_date", "end_date"), false, $where); foreach ($fields as $id => $field) { $start_date = $field["start_date"]; $end_date = $field["end_date"]; } if (count($fields) == 0) { $this->userMessage("Course Registration Closed"); $this->setRedirect("view?id=" . self::$person_id); return false; } else { $start_date = strtotime($start_date); $end_date = strtotime($end_date); $today = strtotime(date("Y-m-d")); if ($today > $end_date) { $this->userMessage("Course Registration Closed"); $this->setRedirect("view?id=" . self::$person_id); return false; } } ########### End checking of course enrollment deadline ##################### ########### Check if this student is not discontinued ##################### if ($this->check_discontinue($this->person_id)) { $this->userMessage("You have discontinued from this program!!!"); $this->setRedirect("view?id=" . $this->person_id); return false; } ########### End of checking if a student has discontinued ################# ########### If its a new semester then increment the semester and level ################ ######get total number of semesters###### list($prog_form, $prog_id) = array_pad(explode("|", $this->program, 2), 2, ""); $total_sems = I2CE_FormStorage::lookupField("training_program", $prog_id, array("total_semesters"), false); $total_semesters = $total_sems["total_semesters"]; ######end of getting total number of semesters###### ######get passing score###### list($inst_form, $inst_id) = array_pad(explode("|", $this->training_institution, 2), 2, ""); $pass_score = I2CE_FormStorage::lookupField("training_institution", $inst_id, array("passing_score"), false); $this->passing_score = $pass_score["passing_score"]; ######end of getting passing score###### $semester_name = self::getSemesterName($this->curr_semester); $where_GPA = array("operator" => "AND", "operand" => array(0 => array("operator" => "FIELD_LIMIT", "field" => "parent", "style" => "equals", "data" => array("value" => $this->person_id)), 1 => array("operator" => "FIELD_LIMIT", "field" => "semester", "style" => "equals", "data" => array("value" => $this->curr_semester))), 2 => array("operator" => "FIELD_LIMIT", "field" => "registration", "style" => "equals", "data" => array("value" => $this->student_registration["id"]))); ######if GPA for current semester available then increment the semester###### $sem_GPA = I2CE_FormStorage::Search("semester_GPA", false, $where_GPA); if (count($sem_GPA) > 0 and $semester_name < $total_semesters) { $regObj = $this->factory->createContainer($this->student_registration["id"]); list($form, $level) = array_pad(explode("|", $this->curr_level, 2), 2, ""); $semester_name = ++$semester_name; if ($semester_name % 2 != 0) { $new_level = ++$level; } $new_semester = "semester|" . $semester_name; $user = new I2CE_User(); $regObj->populate(); $regObj->getField("semester")->setFromDB($new_semester); if ($semester_name % 2 != 0) { $regObj->getField("academic_level")->setFromDB("academic_level|" . $new_level); } $regObj->save($user); } ########### End of incrementing the semester and level ############ $this->getProgramCourses($this->curr_semester); $this->getElectiveCourses($this->curr_semester); $this->getPreviousSemesterCourses($this->curr_semester); if (count($this->subject_courses) == 0 and count($this->elective_courses) == 0) { $this->userMessage("No courses defined into the system,try later on!!!"); $this->setRedirect("view?id=" . $this->person_id); } $this->displayCourses($this->subject_courses, "subject", "Subject Courses"); if (count($this->elective_courses) > 0) { $this->displayCourses($this->elective_courses, "elective", "Elective Courses"); } //append hidden values to be used on the onload if (!($hidden = $this->template->getElementByID("hidden_values")) instanceof DOMNode) { return; } $input = $this->template->createElement("input", array("type" => "hidden", "name" => "person_id", "value" => $this->person_id)); $this->template->appendNode($input, $hidden); $input = $this->template->createElement("input", array("type" => "hidden", "name" => "curr_semester", "value" => $this->curr_semester)); $this->template->appendNode($input, $hidden); if (!($div = $this->template->getElementByID("button")) instanceof DOMNode) { return; } $input = $this->template->createElement("input", array("type" => "submit", "value" => "Save")); $this->template->appendNode($input, $div); }
protected function action() { if (!$this->hasPermission("task(can_add_students_results)" or $this->getUser()->role == "admin")) { $this->setRedirect("noaccess"); return; } $this->ff = I2CE_FormFactory::instance(); //update academic year iHRIS_AcademicYear::ensureAcademicYear(); //retrive the academic year $current_academic_year = iHRIS_AcademicYear::currentAcademicYear(); $academic_year_id = iHRIS_AcademicYear::academicYearId($current_academic_year); $academic_year_id = "academic_year|" . $academic_year_id; $this->course_id = $this->request("id"); $where_course_id = array("operator" => "AND", "operand" => array(0 => array('operator' => 'FIELD_LIMIT', 'field' => 'training', 'style' => 'like', 'data' => array('value' => "%" . $this->course_id . "%")), 1 => array('operator' => 'FIELD_LIMIT', 'field' => 'academic_year', 'style' => 'equals', 'data' => array('value' => $academic_year_id)))); $parents = I2CE_FormStorage::listFields("enroll_course", array("parent", "training", "academic_year"), false, $where_course_id); if (!($listNode = $this->template->getElementByID("students_list")) instanceof DOMNode) { return; } if (!($hidden_data = $this->template->getElementByID("hidden_data")) instanceof DOMNode) { return; } if (count($parents) == 0) { $this->userMessage("No students enrolled for this course!!!"); $this->setRedirect("add_results_select_course"); } $input = $this->template->createElement("input", array("type" => "hidden", "name" => "course_id", "value" => $this->course_id)); $this->template->appendNode($input, $listNode); $table = $this->template->createElement("table", array("class" => "multiFormTable", "width" => "100%", "border" => "0", "cellpadding" => "0", "cellspacing" => "0")); $tr = $this->template->createElement("tr"); $th = $this->template->createElement("th", array("width" => "60%"), "Student Name"); $this->template->appendNode($th, $tr); $th = $this->template->createElement("th", "", "Registration Number"); $this->template->appendNode($th, $tr); $this->appendExamTypesHeaders($tr); $this->template->appendNode($tr, $table); //retrieving the max mark for each assessment foreach ($this->exam_types as $exam_type) { list($form, $id) = array_pad(explode("|", $exam_type, 2), 2, ''); list($form, $course_id) = array_pad(explode("|", $this->course_id, 2), 2, ''); $max_mark = I2CE_FormStorage::lookupField("training", $course_id, array($id), false); $max_mark = $max_mark[$id]; $input = $this->template->createElement("input", array("type" => "hidden", "name" => $id, "id" => $id, "value" => $max_mark)); $this->template->appendNode($input, $listNode); } //fecth lecturer institution to make sure can see students for his/her institution $username = $this->getUser()->username; $inst_id = iHRIS_PageFormLecturer::fetch_institution($username); foreach ($parents as $enroll_id => $parent) { $reg_details = STS_PageFormPerson::load_current_registration($person_id); ###drop students which are on different institution### if ($inst_id != $reg_details["training_institution"]) { continue; } $trainings = explode(",", $parent["training"]); $tr = $this->template->createElement("tr"); $person_id = $parent["parent"]; $reg_num = $this->getRegistrationNumber($person_id); $input = $this->template->createElement("input", array("type" => "hidden", "name" => "reg_num[" . $reg_num . "]", "value" => $reg_num)); $this->template->appendNode($input, $tr); list($form, $id) = array_pad(explode("|", $person_id, 2), 2, ''); $field_data = I2CE_FormStorage::lookupField("person", $id, array('firstname', 'surname'), false); if (is_array($field_data) && array_key_exists('surname', $field_data) && array_key_exists('firstname', $field_data)) { $fullname = $field_data['firstname'] . ' ' . $field_data['surname']; $aNode = $this->template->createElement("a", array("href" => "view?id=" . $person_id), $fullname); $td = $this->template->createElement("td"); $this->template->appendNode($aNode, $td); $this->template->appendNode($td, $tr); $td = $this->template->createElement("td", array("id" => $reg_num, "align" => "center")); $this->template->addTextNode($reg_num, $reg_num, $td); $this->template->appendNode($td, $tr); $this->appendExamTypesInput($tr, $reg_num, $person_id, $this->course_id, $parent["academic_year"], $enroll_id); } $this->template->appendNode($tr, $table); } $tr = $this->template->createElement("tr"); $td = $this->template->createElement("td", array("colspan" => "10", "align" => "right")); $input = $this->template->createElement("input", array("type" => "submit", "value" => "Save", "onclick" => "return verify()")); $this->template->appendNode($input, $td); $this->template->appendNode($td, $tr); $this->template->appendNode($tr, $table); $this->template->appendNode($table, $listNode); }
protected function action() { //check to ensure that the current academic year is available iHRIS_AcademicYear::ensureAcademicYear(); $this->showCourses(); }
protected function applyLimits($primary, $inst_id, $role) { $all_trng_prgrms = iHRIS_PageFormEnrollcourse::get_institution_programs(); $dep_training_prgrms = iHRIS_PageFormEnrollcourse::get_department_programs(); $semesters = array("semester|1", "semester|3", "semester|5"); if ($role == "registrar") { $where = array("operator" => "AND", "operand" => array(0 => array("operator" => "FIELD_LIMIT", "field" => "semester", "style" => "in", "data" => array("value" => $semesters)), 1 => array("operator" => "FIELD_LIMIT", "field" => "training_program", "style" => "in", "data" => array("value" => $all_trng_prgrms)))); } else { if ($role == "hod") { $where = array("operator" => "AND", "operand" => array(0 => array("operator" => "FIELD_LIMIT", "field" => "semester", "style" => "in", "data" => array("value" => $semesters)), 1 => array("operator" => "FIELD_LIMIT", "field" => "training_program", "style" => "in", "data" => array("value" => $dep_training_prgrms)))); } } $training = $primary->getField("training"); $training->setOption(array("meta", "limits", "default", "training"), $where); iHRIS_AcademicYear::ensureAcademicYear(); $current_academic_year = iHRIS_AcademicYear::currentAcademicYear(); $academic_year_id = iHRIS_AcademicYear::academicYearId($current_academic_year); $where = array("operator" => "FIELD_LIMIT", "field" => "id", "style" => "equals", "data" => array("value" => $academic_year_id)); $ac_yr = $primary->getField("academic_year"); $ac_yr->setOption(array("meta", "limits", "default", "academic_year"), $where); }
public static function getMethods() { return array('iHRIS_PageView->action_overall_GPA' => 'action_overall_GPA'); iHRIS_AcademicYear::ensureAcademicYear(); }