12
12
$this->load->database();
15
/* Get all of the courses */
16
16
function getCourses() {
17
17
$this->db->order_by("name", "asc");
18
18
$query = $this->db->get('Courses');
19
19
return $query->result();
22
/* Get all the public courses */
23
function getPublicCourses() {
24
$this->db->from("Courses");
25
$this->db->order_by("name", "asc");
26
$this->db->where("isHidden","0");
27
$this->db->where("isPublic","1");
28
$query = $this->db->get();
29
return $query->result();
32
/* Get all the private courses for a student - If they are published and private*/
33
function getPrivateCourses($username) {
34
$this->db->from("Courses");
35
$this->db->join("StudentCourseRegistrations", "Courses.courseID = StudentCourseRegistrations.courseID");
36
$this->db->order_by("name", "asc");
37
$this->db->where("userName", $username);
38
$this->db->where("isPublic", "0");
39
$this->db->where("isHidden","0");
40
$query = $this->db->get();
41
return $query->result();
44
/* Get all the courses for a student, both private from getPrivateCourses(), and public from getPublicCourses() */
45
function getStudentCourses($username) {
46
$private = $this->getPrivateCourses($username);
47
$public = $this->getPublicCourses();
48
return array_merge($private, $public);
51
function setCourseHidden($courseID) {
52
$this->db->where("courseID", $courseID);
53
$this->db->update("Courses", array("isHidden" => 1));
56
function unsetCourseHidden($courseID){
57
$this->db->where("courseID", $courseID);
58
$this->db->update("Courses", array("isHidden" => 0));
22
61
function addCourse($cid, $name, $courseData){
73
function editCourse($cid, $name, $courseData) {
76
'courseData' => $courseData
79
$this->db->where('courseID', $cid);
80
$this->db->update('Courses', $data);
34
83
function getMenu(){
36
85
$courses = $this->db->get("Courses");