/lenasys/trunk

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/lenasys/trunk

« back to all changes in this revision

Viewing changes to codeigniter/application/models/admin/admin_model.php

  • Committer: Gustav Hatvigsson
  • Date: 2013-05-28 12:14:12 UTC
  • mfrom: (109.1.2 lenasys)
  • Revision ID: gustav.hartvigsson@gmail.com-20130528121412-m9lt45yzezb2vqxy
Merged Andersson:s changes:
Added the functions getPublicCourses(), getPrivateCourses() and getStudentCourses().
* getPublicCourses() returns all the public courses.
* getPrivateCourses() returns the private and published courses a student is registred to.
* getStudentCourses() returns both public and private courses for a student.

Show diffs side-by-side

added added

removed removed

Lines of Context:
12
12
                $this->load->database();
13
13
        }
14
14
 
15
 
 
 
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();
20
20
        }
 
21
        
 
22
        /* Get all the public courses */
 
23
        function getPublicCourses() {
 
24
                $this->db->from("Courses");
 
25
                $this->db->where("isHidden","0");
 
26
                $this->db->where("isPublic","1");
 
27
                $query = $this->db->get();
 
28
                return $query->result();
 
29
        }
 
30
        
 
31
        /* Get all the private courses for a student - If they are published and private*/
 
32
        function getPrivateCourses($studentID) {
 
33
                $this->db->from("Courses");
 
34
                $this->db->join("StudentCourseRegistrations", "Courses.courseID = StudentCourseRegistrations.courseID");
 
35
                $this->db->where("userName", $studentID);
 
36
                $this->db->where("isPublic", "0");
 
37
                $this->db->where("isHidden","0");
 
38
                $query = $this->db->get();
 
39
                return $query->result();
 
40
        }
 
41
        
 
42
        /* Get all the courses for a student, both private from getPrivateCourses(), and public from getPublicCourses() */
 
43
        function getStudentCourses($studentID) {
 
44
                $private = $this->getPrivateCourses($studentID);
 
45
                $public = $this->getPublicCourses();
 
46
                return array_merge($private, $public);
 
47
        }
21
48
 
22
49
        function setCourseHidden($courseID) {
23
50
                $this->db->where("courseID", $courseID);