Merge lp:~c11emian/lenasys/1182127 into lp:lenasys

Proposed by Emil Andersson
Status: Merged
Merged at revision: 114
Proposed branch: lp:~c11emian/lenasys/1182127
Merge into: lp:lenasys
Diff against target: 83 lines (+44/-3)
3 files modified
codeigniter/application/controllers/cms.php (+14/-0)
codeigniter/application/models/admin/admin_model.php (+28/-1)
databas.sql (+2/-2)
To merge this branch: bzr merge lp:~c11emian/lenasys/1182127
Reviewer Review Type Date Requested Status
lenasysmaint Pending
Review via email: mp+166027@code.launchpad.net
To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'codeigniter/application/controllers/cms.php'
2--- codeigniter/application/controllers/cms.php 2013-05-28 08:51:26 +0000
3+++ codeigniter/application/controllers/cms.php 2013-05-28 11:53:29 +0000
4@@ -46,6 +46,20 @@
5 }
6 }
7
8+ public function test(){
9+
10+ $result = $this->admin_model->getStudentCourses("student");
11+ foreach($result as $res) {
12+ echo $res->courseID. ' - ';
13+ echo $res->name;
14+ echo "<br>";
15+
16+ }
17+
18+ //var_dump($result);
19+ }
20+
21+
22 /*
23 * This function draws the cms page.
24 */
25
26=== modified file 'codeigniter/application/models/admin/admin_model.php'
27--- codeigniter/application/models/admin/admin_model.php 2013-05-24 11:34:09 +0000
28+++ codeigniter/application/models/admin/admin_model.php 2013-05-28 11:53:29 +0000
29@@ -12,12 +12,39 @@
30 $this->load->database();
31 }
32
33-
34+ /* Get all of the courses */
35 function getCourses() {
36 $this->db->order_by("name", "asc");
37 $query = $this->db->get('Courses');
38 return $query->result();
39 }
40+
41+ /* Get all the public courses */
42+ function getPublicCourses() {
43+ $this->db->from("Courses");
44+ $this->db->where("isHidden","0");
45+ $this->db->where("isPublic","1");
46+ $query = $this->db->get();
47+ return $query->result();
48+ }
49+
50+ /* Get all the private courses for a student - If they are published and private*/
51+ function getPrivateCourses($studentID) {
52+ $this->db->from("Courses");
53+ $this->db->join("StudentCourseRegistrations", "Courses.courseID = StudentCourseRegistrations.courseID");
54+ $this->db->where("userName", $studentID);
55+ $this->db->where("isPublic", "0");
56+ $this->db->where("isHidden","0");
57+ $query = $this->db->get();
58+ return $query->result();
59+ }
60+
61+ /* Get all the courses for a student, both private from getPrivateCourses(), and public from getPublicCourses() */
62+ function getStudentCourses($studentID) {
63+ $private = $this->getPrivateCourses($studentID);
64+ $public = $this->getPublicCourses();
65+ return array_merge($private, $public);
66+ }
67
68 function setCourseHidden($courseID) {
69 $this->db->where("courseID", $courseID);
70
71=== modified file 'databas.sql'
72--- databas.sql 2013-05-21 14:40:12 +0000
73+++ databas.sql 2013-05-28 11:53:29 +0000
74@@ -10,8 +10,8 @@
75 `courseID` VARCHAR(10) NOT NULL ,
76 `name` VARCHAR(50) NULL ,
77 `courseData` VARCHAR(128) NULL , -- explanation about course, example: G1N 7,5hp + additional text
78- `isHidden` BIT(1) NOT NULL DEFAULT 0 ,
79- `isPublic` BIT(1) NOT NULL DEFAULT 1 ,
80+ `isHidden` BIT(1) NOT NULL DEFAULT 0 , -- Published or not
81+ `isPublic` BIT(1) NOT NULL DEFAULT 1 , -- Public or not
82 PRIMARY KEY (`courseID`))
83 ENGINE = InnoDB;
84

Subscribers

People subscribed via source and target branches

to all changes: