Exemplo n.º 1
0
 function get_all_courses()
 {
     $CI =& get_instance();
     $CI->load->model("Course_Model");
     $courses = false;
     $courseinfo = new Course_Model();
     $query = $CI->db->select("*")->from($courseinfo->table_name)->get();
     if ($query && $query->num_rows() > 0) {
         $courses = array();
         foreach ($query->result() as $rwi => $rw) {
             $courseinfo = new Course_Model();
             $courseinfo->setCourseid($rw->course_id);
             $courseinfo->setCoursecode($rw->course_code);
             $courseinfo->setCoursedescription($rw->course_description);
             $courseinfo->setCreatedon($rw->created_on);
             $courseinfo->setLastupdate($rw->last_update);
             $courses[] = $courseinfo;
         }
     }
     return $courses;
 }
Exemplo n.º 2
0
 public function curriculum_settings_add_course()
 {
     if ($this->input->post(sha1("addcourse"))) {
         $this->form_validation->set_rules("courseCode", "Course Code", "trim|required|xss_xlean");
         $this->form_validation->set_rules("courseDescription", "Course Description", "trim|required|xss_xlean");
         if ($this->form_validation->run() == false) {
             if (form_error("courseCode")) {
                 set_has_error("courseCode", true);
                 set_message("courseCode", form_error("courseCode", " ", " "));
             }
             if (form_error("courseDescription")) {
                 set_has_error("courseDescription", true);
                 set_message("courseDescription", form_error("courseDescription", " ", " "));
             }
         } else {
             $newcourse_code = $this->input->post("courseCode");
             $newcourse_description = $this->input->post("courseDescription");
             if (is_course_exist(false, $newcourse_code)) {
                 set_has_error("courseCode", true);
                 set_message("courseCode", "Course code already exists.");
             } else {
                 $newcourseinfo = new Course_Model();
                 $newcourseinfo->setCoursecode($newcourse_code);
                 $newcourseinfo->setCoursedescription($newcourse_description);
                 if ($newcourseinfo->saveAsnew()) {
                     redirect("dashboard/curriculums/settings/courses");
                 }
             }
         }
     }
     $this->load->view("management/dashboard/curriculums/settings/courses/add/view", $this->data);
 }