@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | <?php |
143 | 143 | $who = addslashes(api_get_person_name($_user['firstName'], $_user['lastName'])); |
144 | 144 | echo "result='$who';"; |
145 | - ?> |
|
145 | + ?> |
|
146 | 146 | }else if(param == 'cmi.core.lesson_location'){ |
147 | 147 | result=lesson_location; |
148 | 148 | }else if(param == 'cmi.core.total_time'){ |
@@ -198,7 +198,7 @@ discard block |
||
198 | 198 | <?php |
199 | 199 | $who = addslashes(api_get_person_name($_user['firstName'], $_user['lastName'])); |
200 | 200 | echo "result='$who';"; |
201 | - ?> break; |
|
201 | + ?> break; |
|
202 | 202 | case 'cmi.core.lesson_location' : |
203 | 203 | result=''; |
204 | 204 | break; |
@@ -322,12 +322,12 @@ discard block |
||
322 | 322 | } |
323 | 323 | <?php |
324 | 324 | /** |
325 | - * Chamilo-specific code that deals with event handling and inter-frames |
|
326 | - * messaging/refreshing. |
|
327 | - * Note that from now on, the Chamilo JS code in this library will act as |
|
328 | - * a controller, of the MVC pattern, and receive all requests for frame |
|
329 | - * updates, then redispatch to any frame concerned. |
|
330 | - */ |
|
325 | + * Chamilo-specific code that deals with event handling and inter-frames |
|
326 | + * messaging/refreshing. |
|
327 | + * Note that from now on, the Chamilo JS code in this library will act as |
|
328 | + * a controller, of the MVC pattern, and receive all requests for frame |
|
329 | + * updates, then redispatch to any frame concerned. |
|
330 | + */ |
|
331 | 331 | ?> |
332 | 332 | /** |
333 | 333 | * Defining the AJAX-object class to be made available from other frames. |
@@ -39,60 +39,60 @@ |
||
39 | 39 | case 'manifest': // Do the same as the default. |
40 | 40 | $children = $element->childNodes; |
41 | 41 | foreach ($children as $child) { |
42 | - switch ($child->nodeType) { |
|
43 | - case XML_ELEMENT_NODE: |
|
42 | + switch ($child->nodeType) { |
|
43 | + case XML_ELEMENT_NODE: |
|
44 | 44 | // Could be 'lom', 'schema', 'schemaversion' or 'location'. |
45 | 45 | switch ($child->tagName) { |
46 | - case 'lom': |
|
46 | + case 'lom': |
|
47 | 47 | $childchildren = $child->childNodes; |
48 | - foreach ($childchildren as $childchild) { |
|
49 | - $this->lom = $childchild->nodeValue; |
|
50 | - } |
|
51 | - break; |
|
52 | - case 'schema': |
|
48 | + foreach ($childchildren as $childchild) { |
|
49 | + $this->lom = $childchild->nodeValue; |
|
50 | + } |
|
51 | + break; |
|
52 | + case 'schema': |
|
53 | 53 | $childchildren = $child->childNodes; |
54 | - foreach ($childchildren as $childchild) { |
|
55 | - // There is generally only one child here. |
|
56 | - $this->schema = $childchild->nodeValue; |
|
57 | - } |
|
58 | - break; |
|
59 | - case 'schemaversion': |
|
54 | + foreach ($childchildren as $childchild) { |
|
55 | + // There is generally only one child here. |
|
56 | + $this->schema = $childchild->nodeValue; |
|
57 | + } |
|
58 | + break; |
|
59 | + case 'schemaversion': |
|
60 | 60 | $childchildren = $child->childNodes; |
61 | - foreach ($childchildren as $childchild) { |
|
62 | - // There is generally only one child here. |
|
63 | - $this->schemaversion = $childchild->nodeValue; |
|
64 | - } |
|
65 | - break; |
|
66 | - case 'location': |
|
61 | + foreach ($childchildren as $childchild) { |
|
62 | + // There is generally only one child here. |
|
63 | + $this->schemaversion = $childchild->nodeValue; |
|
64 | + } |
|
65 | + break; |
|
66 | + case 'location': |
|
67 | 67 | $childchildren = $child->childNodes; |
68 | - foreach ($childchildren as $childchild) { |
|
69 | - // There is generally only one child here. |
|
70 | - $this->location = $childchild->nodeValue; |
|
71 | - } |
|
72 | - break; |
|
73 | - } |
|
74 | - break; |
|
75 | - case XML_TEXT_NODE: |
|
68 | + foreach ($childchildren as $childchild) { |
|
69 | + // There is generally only one child here. |
|
70 | + $this->location = $childchild->nodeValue; |
|
71 | + } |
|
72 | + break; |
|
73 | + } |
|
74 | + break; |
|
75 | + case XML_TEXT_NODE: |
|
76 | 76 | if (trim($child->textContent) != '') { |
77 | - if (count($children == 1)) { |
|
78 | - // If this is the only child at this level and it is a content... save differently. |
|
79 | - $this->text = $child->textContent; |
|
80 | - } else { |
|
81 | - $this->text[$element->tagName] = $child->textContent; |
|
82 | - } |
|
83 | - } |
|
84 | - break; |
|
85 | - } |
|
86 | - } |
|
87 | - $attributes = $element->attributes; |
|
88 | - //$keep_href = ''; |
|
89 | - if (is_array($attributes)) { |
|
90 | - foreach ($attributes as $attrib) { |
|
91 | - if (trim($attrib->value) != ''){ |
|
92 | - $this->attribs[$attrib->name] = $attrib->value; |
|
93 | - } |
|
94 | - } |
|
95 | - } |
|
77 | + if (count($children == 1)) { |
|
78 | + // If this is the only child at this level and it is a content... save differently. |
|
79 | + $this->text = $child->textContent; |
|
80 | + } else { |
|
81 | + $this->text[$element->tagName] = $child->textContent; |
|
82 | + } |
|
83 | + } |
|
84 | + break; |
|
85 | + } |
|
86 | + } |
|
87 | + $attributes = $element->attributes; |
|
88 | + //$keep_href = ''; |
|
89 | + if (is_array($attributes)) { |
|
90 | + foreach ($attributes as $attrib) { |
|
91 | + if (trim($attrib->value) != ''){ |
|
92 | + $this->attribs[$attrib->name] = $attrib->value; |
|
93 | + } |
|
94 | + } |
|
95 | + } |
|
96 | 96 | return true; |
97 | 97 | //break; |
98 | 98 | } |
@@ -36,7 +36,7 @@ |
||
36 | 36 | api_get_group_id() |
37 | 37 | ); |
38 | 38 | if (!api_is_allowed_to_edit(null, true) && intval($visibility) == 0 ) { |
39 | - api_not_allowed(); |
|
39 | + api_not_allowed(); |
|
40 | 40 | } |
41 | 41 | |
42 | 42 | if (empty($_SESSION['oLP'])) { |
@@ -9,261 +9,261 @@ |
||
9 | 9 | */ |
10 | 10 | class LearnpathLink extends AbstractLink |
11 | 11 | { |
12 | - private $course_info = null; |
|
13 | - private $learnpath_table = null; |
|
14 | - private $learnpath_data = null; |
|
15 | - |
|
16 | - /** |
|
17 | - * Constructor |
|
18 | - */ |
|
19 | - public function __construct() |
|
20 | - { |
|
21 | - parent::__construct(); |
|
22 | - $this->set_type(LINK_LEARNPATH); |
|
23 | - } |
|
24 | - |
|
25 | - /** |
|
26 | - * Generate an array of learnpaths that a teacher hasn't created a link for. |
|
27 | - * @return array 2-dimensional array - every element contains 2 subelements (id, name) |
|
28 | - */ |
|
29 | - public function get_not_created_links() |
|
30 | - { |
|
31 | - return false; |
|
32 | - if (empty($this->course_code)) |
|
33 | - die('Error in get_not_created_links() : course code not set'); |
|
34 | - |
|
35 | - $tbl_grade_links = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_LINK); |
|
36 | - |
|
37 | - $sql = 'SELECT id, name from '.$this->get_learnpath_table().' lp |
|
12 | + private $course_info = null; |
|
13 | + private $learnpath_table = null; |
|
14 | + private $learnpath_data = null; |
|
15 | + |
|
16 | + /** |
|
17 | + * Constructor |
|
18 | + */ |
|
19 | + public function __construct() |
|
20 | + { |
|
21 | + parent::__construct(); |
|
22 | + $this->set_type(LINK_LEARNPATH); |
|
23 | + } |
|
24 | + |
|
25 | + /** |
|
26 | + * Generate an array of learnpaths that a teacher hasn't created a link for. |
|
27 | + * @return array 2-dimensional array - every element contains 2 subelements (id, name) |
|
28 | + */ |
|
29 | + public function get_not_created_links() |
|
30 | + { |
|
31 | + return false; |
|
32 | + if (empty($this->course_code)) |
|
33 | + die('Error in get_not_created_links() : course code not set'); |
|
34 | + |
|
35 | + $tbl_grade_links = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_LINK); |
|
36 | + |
|
37 | + $sql = 'SELECT id, name from '.$this->get_learnpath_table().' lp |
|
38 | 38 | WHERE c_id = '.$this->course_id.' AND id NOT IN ' |
39 | - .' (SELECT ref_id FROM '.$tbl_grade_links |
|
40 | - .' WHERE type = '.LINK_LEARNPATH |
|
41 | - ." AND course_code = '".$this->get_course_code()."'" |
|
42 | - .') AND lp.session_id='.api_get_session_id().''; |
|
43 | - |
|
44 | - $result = Database::query($sql); |
|
45 | - |
|
46 | - $cats=array(); |
|
47 | - while ($data=Database::fetch_array($result)) { |
|
48 | - $cats[] = array ($data['id'], $data['name']); |
|
49 | - } |
|
50 | - |
|
51 | - return $cats; |
|
52 | - } |
|
53 | - |
|
54 | - /** |
|
55 | - * Generate an array of all learnpaths available. |
|
56 | - * @return array 2-dimensional array - every element contains 2 subelements (id, name) |
|
57 | - */ |
|
58 | - public function get_all_links() |
|
59 | - { |
|
60 | - if (empty($this->course_code)) |
|
61 | - die('Error in get_not_created_links() : course code not set'); |
|
62 | - |
|
63 | - $session_id = api_get_session_id(); |
|
64 | - if (empty($session_id)) { |
|
65 | - $session_condition = api_get_session_condition(0, true); |
|
66 | - } else { |
|
67 | - $session_condition = api_get_session_condition($session_id, true, true); |
|
68 | - } |
|
69 | - |
|
70 | - $sql = 'SELECT id, name FROM '.$this->get_learnpath_table().' |
|
39 | + .' (SELECT ref_id FROM '.$tbl_grade_links |
|
40 | + .' WHERE type = '.LINK_LEARNPATH |
|
41 | + ." AND course_code = '".$this->get_course_code()."'" |
|
42 | + .') AND lp.session_id='.api_get_session_id().''; |
|
43 | + |
|
44 | + $result = Database::query($sql); |
|
45 | + |
|
46 | + $cats=array(); |
|
47 | + while ($data=Database::fetch_array($result)) { |
|
48 | + $cats[] = array ($data['id'], $data['name']); |
|
49 | + } |
|
50 | + |
|
51 | + return $cats; |
|
52 | + } |
|
53 | + |
|
54 | + /** |
|
55 | + * Generate an array of all learnpaths available. |
|
56 | + * @return array 2-dimensional array - every element contains 2 subelements (id, name) |
|
57 | + */ |
|
58 | + public function get_all_links() |
|
59 | + { |
|
60 | + if (empty($this->course_code)) |
|
61 | + die('Error in get_not_created_links() : course code not set'); |
|
62 | + |
|
63 | + $session_id = api_get_session_id(); |
|
64 | + if (empty($session_id)) { |
|
65 | + $session_condition = api_get_session_condition(0, true); |
|
66 | + } else { |
|
67 | + $session_condition = api_get_session_condition($session_id, true, true); |
|
68 | + } |
|
69 | + |
|
70 | + $sql = 'SELECT id, name FROM '.$this->get_learnpath_table().' |
|
71 | 71 | WHERE c_id = '.$this->course_id.' '.$session_condition.' '; |
72 | - $result = Database::query($sql); |
|
72 | + $result = Database::query($sql); |
|
73 | 73 | |
74 | - $cats = array(); |
|
75 | - while ($data=Database::fetch_array($result)) { |
|
76 | - $cats[] = array ($data['id'], $data['name']); |
|
77 | - } |
|
74 | + $cats = array(); |
|
75 | + while ($data=Database::fetch_array($result)) { |
|
76 | + $cats[] = array ($data['id'], $data['name']); |
|
77 | + } |
|
78 | 78 | |
79 | - return $cats; |
|
80 | - } |
|
79 | + return $cats; |
|
80 | + } |
|
81 | 81 | |
82 | 82 | |
83 | - /** |
|
84 | - * Has anyone used this learnpath yet ? |
|
85 | - */ |
|
86 | - public function has_results() |
|
87 | - { |
|
88 | - $tbl_stats = Database::get_course_table(TABLE_LP_VIEW); |
|
89 | - $sql = "SELECT count(id) AS number FROM $tbl_stats |
|
83 | + /** |
|
84 | + * Has anyone used this learnpath yet ? |
|
85 | + */ |
|
86 | + public function has_results() |
|
87 | + { |
|
88 | + $tbl_stats = Database::get_course_table(TABLE_LP_VIEW); |
|
89 | + $sql = "SELECT count(id) AS number FROM $tbl_stats |
|
90 | 90 | WHERE c_id = ".$this->course_id." AND lp_id = ".$this->get_ref_id(); |
91 | - $result = Database::query($sql); |
|
92 | - $number = Database::fetch_array($result,'NUM'); |
|
93 | - return ($number[0] != 0); |
|
94 | - } |
|
95 | - |
|
96 | - /** |
|
97 | - * Get the progress of this learnpath. Only the last attempt are taken into account. |
|
98 | - * @param $stud_id student id (default: all students who have results - then the average is returned) |
|
99 | - * @return array (score, max) if student is given |
|
100 | - * array (sum of scores, number of scores) otherwise |
|
101 | - * or null if no scores available |
|
102 | - */ |
|
103 | - public function calc_score($stud_id = null, $type = null) |
|
104 | - { |
|
105 | - $tbl_stats = Database::get_course_table(TABLE_LP_VIEW); |
|
106 | - $session_id = api_get_session_id(); |
|
107 | - |
|
108 | - $sql = "SELECT * FROM $tbl_stats |
|
91 | + $result = Database::query($sql); |
|
92 | + $number = Database::fetch_array($result,'NUM'); |
|
93 | + return ($number[0] != 0); |
|
94 | + } |
|
95 | + |
|
96 | + /** |
|
97 | + * Get the progress of this learnpath. Only the last attempt are taken into account. |
|
98 | + * @param $stud_id student id (default: all students who have results - then the average is returned) |
|
99 | + * @return array (score, max) if student is given |
|
100 | + * array (sum of scores, number of scores) otherwise |
|
101 | + * or null if no scores available |
|
102 | + */ |
|
103 | + public function calc_score($stud_id = null, $type = null) |
|
104 | + { |
|
105 | + $tbl_stats = Database::get_course_table(TABLE_LP_VIEW); |
|
106 | + $session_id = api_get_session_id(); |
|
107 | + |
|
108 | + $sql = "SELECT * FROM $tbl_stats |
|
109 | 109 | WHERE |
110 | 110 | c_id = ".$this->course_id." AND |
111 | 111 | lp_id = ".$this->get_ref_id()." AND |
112 | 112 | session_id = $session_id "; |
113 | 113 | |
114 | - if (isset($stud_id)) |
|
115 | - $sql .= ' AND user_id = '.intval($stud_id); |
|
116 | - |
|
117 | - // order by id, that way the student's first attempt is accessed first |
|
118 | - $sql .= ' ORDER BY view_count DESC'; |
|
119 | - |
|
120 | - $scores = Database::query($sql); |
|
121 | - // for 1 student |
|
122 | - if (isset($stud_id)) { |
|
123 | - if ($data = Database::fetch_assoc($scores)) { |
|
124 | - return array ($data['progress'], 100); |
|
125 | - } else |
|
126 | - return null; |
|
127 | - } else { |
|
128 | - // all students -> get average |
|
129 | - $students = array(); // user list, needed to make sure we only |
|
130 | - // take first attempts into account |
|
131 | - $rescount = 0; |
|
132 | - $sum = 0; |
|
133 | - $bestResult = 0; |
|
134 | - $sumResult = 0; |
|
135 | - while ($data = Database::fetch_array($scores)) { |
|
136 | - if (!(array_key_exists($data['user_id'], $students))) { |
|
137 | - $students[$data['user_id']] = $data['progress']; |
|
138 | - $rescount++; |
|
139 | - $sum += $data['progress'] / 100; |
|
140 | - $sumResult += $data['progress']; |
|
141 | - |
|
142 | - if ($data['progress'] > $bestResult) { |
|
143 | - $bestResult = $data['progress']; |
|
144 | - } |
|
145 | - } |
|
146 | - } |
|
147 | - |
|
148 | - if ($rescount == 0) { |
|
149 | - return null; |
|
150 | - } else { |
|
151 | - |
|
152 | - switch ($type) { |
|
153 | - case 'best': |
|
154 | - return array($bestResult, 100); |
|
155 | - break; |
|
156 | - case 'average': |
|
157 | - return array($sumResult/$rescount, 100); |
|
158 | - break; |
|
159 | - case 'ranking': |
|
160 | - return AbstractLink::getCurrentUserRanking($stud_id, $students); |
|
161 | - break; |
|
162 | - default: |
|
163 | - return array($sum, $rescount); |
|
164 | - break; |
|
165 | - } |
|
166 | - } |
|
167 | - } |
|
168 | - } |
|
169 | - |
|
170 | - /** |
|
171 | - * Get URL where to go to if the user clicks on the link. |
|
172 | - */ |
|
173 | - public function get_link() |
|
174 | - { |
|
175 | - $session_id = api_get_session_id(); |
|
176 | - $url = api_get_path(WEB_CODE_PATH) . 'lp/lp_controller.php?'.api_get_cidreq_params($this->get_course_code(), $session_id).'&gradebook=view'; |
|
177 | - |
|
178 | - if (!api_is_allowed_to_edit() || $this->calc_score(api_get_user_id()) == null) { |
|
179 | - $url .= '&action=view&lp_id='.$this->get_ref_id(); |
|
180 | - } else { |
|
181 | - $url .= '&action=build&lp_id='.$this->get_ref_id(); |
|
182 | - } |
|
183 | - return $url; |
|
184 | - } |
|
185 | - |
|
186 | - /** |
|
187 | - * Get name to display: same as learnpath title |
|
188 | - */ |
|
189 | - public function get_name() |
|
190 | - { |
|
191 | - $data = $this->get_learnpath_data(); |
|
192 | - return $data['name']; |
|
193 | - } |
|
194 | - |
|
195 | - /** |
|
196 | - * Get description to display: same as learnpath description |
|
197 | - */ |
|
198 | - public function get_description() |
|
199 | - { |
|
200 | - $data = $this->get_learnpath_data(); |
|
201 | - return $data['description']; |
|
202 | - } |
|
203 | - |
|
204 | - /** |
|
205 | - * Check if this still links to a learnpath |
|
206 | - */ |
|
207 | - public function is_valid_link() { |
|
208 | - $sql = 'SELECT count(id) FROM '.$this->get_learnpath_table().' |
|
114 | + if (isset($stud_id)) |
|
115 | + $sql .= ' AND user_id = '.intval($stud_id); |
|
116 | + |
|
117 | + // order by id, that way the student's first attempt is accessed first |
|
118 | + $sql .= ' ORDER BY view_count DESC'; |
|
119 | + |
|
120 | + $scores = Database::query($sql); |
|
121 | + // for 1 student |
|
122 | + if (isset($stud_id)) { |
|
123 | + if ($data = Database::fetch_assoc($scores)) { |
|
124 | + return array ($data['progress'], 100); |
|
125 | + } else |
|
126 | + return null; |
|
127 | + } else { |
|
128 | + // all students -> get average |
|
129 | + $students = array(); // user list, needed to make sure we only |
|
130 | + // take first attempts into account |
|
131 | + $rescount = 0; |
|
132 | + $sum = 0; |
|
133 | + $bestResult = 0; |
|
134 | + $sumResult = 0; |
|
135 | + while ($data = Database::fetch_array($scores)) { |
|
136 | + if (!(array_key_exists($data['user_id'], $students))) { |
|
137 | + $students[$data['user_id']] = $data['progress']; |
|
138 | + $rescount++; |
|
139 | + $sum += $data['progress'] / 100; |
|
140 | + $sumResult += $data['progress']; |
|
141 | + |
|
142 | + if ($data['progress'] > $bestResult) { |
|
143 | + $bestResult = $data['progress']; |
|
144 | + } |
|
145 | + } |
|
146 | + } |
|
147 | + |
|
148 | + if ($rescount == 0) { |
|
149 | + return null; |
|
150 | + } else { |
|
151 | + |
|
152 | + switch ($type) { |
|
153 | + case 'best': |
|
154 | + return array($bestResult, 100); |
|
155 | + break; |
|
156 | + case 'average': |
|
157 | + return array($sumResult/$rescount, 100); |
|
158 | + break; |
|
159 | + case 'ranking': |
|
160 | + return AbstractLink::getCurrentUserRanking($stud_id, $students); |
|
161 | + break; |
|
162 | + default: |
|
163 | + return array($sum, $rescount); |
|
164 | + break; |
|
165 | + } |
|
166 | + } |
|
167 | + } |
|
168 | + } |
|
169 | + |
|
170 | + /** |
|
171 | + * Get URL where to go to if the user clicks on the link. |
|
172 | + */ |
|
173 | + public function get_link() |
|
174 | + { |
|
175 | + $session_id = api_get_session_id(); |
|
176 | + $url = api_get_path(WEB_CODE_PATH) . 'lp/lp_controller.php?'.api_get_cidreq_params($this->get_course_code(), $session_id).'&gradebook=view'; |
|
177 | + |
|
178 | + if (!api_is_allowed_to_edit() || $this->calc_score(api_get_user_id()) == null) { |
|
179 | + $url .= '&action=view&lp_id='.$this->get_ref_id(); |
|
180 | + } else { |
|
181 | + $url .= '&action=build&lp_id='.$this->get_ref_id(); |
|
182 | + } |
|
183 | + return $url; |
|
184 | + } |
|
185 | + |
|
186 | + /** |
|
187 | + * Get name to display: same as learnpath title |
|
188 | + */ |
|
189 | + public function get_name() |
|
190 | + { |
|
191 | + $data = $this->get_learnpath_data(); |
|
192 | + return $data['name']; |
|
193 | + } |
|
194 | + |
|
195 | + /** |
|
196 | + * Get description to display: same as learnpath description |
|
197 | + */ |
|
198 | + public function get_description() |
|
199 | + { |
|
200 | + $data = $this->get_learnpath_data(); |
|
201 | + return $data['description']; |
|
202 | + } |
|
203 | + |
|
204 | + /** |
|
205 | + * Check if this still links to a learnpath |
|
206 | + */ |
|
207 | + public function is_valid_link() { |
|
208 | + $sql = 'SELECT count(id) FROM '.$this->get_learnpath_table().' |
|
209 | 209 | WHERE c_id = '.$this->course_id.' AND id = '.$this->get_ref_id().' '; |
210 | - $result = Database::query($sql); |
|
211 | - $number = Database::fetch_row($result,'NUM'); |
|
212 | - return ($number[0] != 0); |
|
213 | - } |
|
214 | - |
|
215 | - public function get_type_name() |
|
216 | - { |
|
217 | - return get_lang('LearningPaths'); |
|
218 | - } |
|
219 | - |
|
220 | - public function needs_name_and_description() |
|
221 | - { |
|
222 | - return false; |
|
223 | - } |
|
224 | - |
|
225 | - public function needs_max() |
|
226 | - { |
|
227 | - return false; |
|
228 | - } |
|
229 | - |
|
230 | - public function needs_results() |
|
231 | - { |
|
232 | - return false; |
|
233 | - } |
|
234 | - |
|
235 | - public function is_allowed_to_change_name() |
|
236 | - { |
|
237 | - return false; |
|
238 | - } |
|
239 | - |
|
240 | - // INTERNAL FUNCTIONS |
|
241 | - |
|
242 | - /** |
|
243 | - * Lazy load function to get the database table of the learnpath |
|
244 | - */ |
|
245 | - private function get_learnpath_table() |
|
246 | - { |
|
247 | - $this->learnpath_table = Database :: get_course_table(TABLE_LP_MAIN); |
|
248 | - return $this->learnpath_table; |
|
249 | - } |
|
250 | - |
|
251 | - /** |
|
252 | - * Lazy load function to get the database contents of this learnpath |
|
253 | - */ |
|
254 | - private function get_learnpath_data() |
|
255 | - { |
|
256 | - if (!isset($this->learnpath_data)) { |
|
257 | - $sql = 'SELECT * FROM '.$this->get_learnpath_table().' |
|
210 | + $result = Database::query($sql); |
|
211 | + $number = Database::fetch_row($result,'NUM'); |
|
212 | + return ($number[0] != 0); |
|
213 | + } |
|
214 | + |
|
215 | + public function get_type_name() |
|
216 | + { |
|
217 | + return get_lang('LearningPaths'); |
|
218 | + } |
|
219 | + |
|
220 | + public function needs_name_and_description() |
|
221 | + { |
|
222 | + return false; |
|
223 | + } |
|
224 | + |
|
225 | + public function needs_max() |
|
226 | + { |
|
227 | + return false; |
|
228 | + } |
|
229 | + |
|
230 | + public function needs_results() |
|
231 | + { |
|
232 | + return false; |
|
233 | + } |
|
234 | + |
|
235 | + public function is_allowed_to_change_name() |
|
236 | + { |
|
237 | + return false; |
|
238 | + } |
|
239 | + |
|
240 | + // INTERNAL FUNCTIONS |
|
241 | + |
|
242 | + /** |
|
243 | + * Lazy load function to get the database table of the learnpath |
|
244 | + */ |
|
245 | + private function get_learnpath_table() |
|
246 | + { |
|
247 | + $this->learnpath_table = Database :: get_course_table(TABLE_LP_MAIN); |
|
248 | + return $this->learnpath_table; |
|
249 | + } |
|
250 | + |
|
251 | + /** |
|
252 | + * Lazy load function to get the database contents of this learnpath |
|
253 | + */ |
|
254 | + private function get_learnpath_data() |
|
255 | + { |
|
256 | + if (!isset($this->learnpath_data)) { |
|
257 | + $sql = 'SELECT * FROM '.$this->get_learnpath_table().' |
|
258 | 258 | WHERE c_id = '.$this->course_id.' AND id = '.$this->get_ref_id().' '; |
259 | - $result = Database::query($sql); |
|
260 | - $this->learnpath_data = Database::fetch_array($result); |
|
261 | - } |
|
262 | - return $this->learnpath_data; |
|
263 | - } |
|
264 | - |
|
265 | - public function get_icon_name() |
|
266 | - { |
|
267 | - return 'learnpath'; |
|
268 | - } |
|
259 | + $result = Database::query($sql); |
|
260 | + $this->learnpath_data = Database::fetch_array($result); |
|
261 | + } |
|
262 | + return $this->learnpath_data; |
|
263 | + } |
|
264 | + |
|
265 | + public function get_icon_name() |
|
266 | + { |
|
267 | + return 'learnpath'; |
|
268 | + } |
|
269 | 269 | } |
@@ -10,7 +10,7 @@ |
||
10 | 10 | $this_section = SECTION_COURSES; |
11 | 11 | |
12 | 12 | if (extension_loaded('xapian')) { |
13 | - require '../lp/lp_list_search.php'; |
|
13 | + require '../lp/lp_list_search.php'; |
|
14 | 14 | } else { |
15 | 15 | Display::display_header(get_lang('Search')); |
16 | 16 | Display::display_error_message(get_lang('SearchXapianModuleNotInstalled')); |
@@ -18,8 +18,8 @@ discard block |
||
18 | 18 | $newstudents = $evaluation[0]->get_not_subscribed_students(); |
19 | 19 | |
20 | 20 | if (count($newstudents) == '0') { |
21 | - header('Location: gradebook_view_result.php?nouser=&selecteval=' . Security::remove_XSS($_GET['selecteval']).'&'.api_get_cidreq()); |
|
22 | - exit; |
|
21 | + header('Location: gradebook_view_result.php?nouser=&selecteval=' . Security::remove_XSS($_GET['selecteval']).'&'.api_get_cidreq()); |
|
22 | + exit; |
|
23 | 23 | } |
24 | 24 | $add_user_form = new EvalForm( |
25 | 25 | EvalForm :: TYPE_ADD_USERS_TO_EVAL, |
@@ -67,12 +67,12 @@ discard block |
||
67 | 67 | |
68 | 68 | $interbreadcrumb[]= array ('url' => Security::remove_XSS($_SESSION['gradebook_dest']),'name' => get_lang('Gradebook')); |
69 | 69 | $interbreadcrumb[]= array( |
70 | - 'url' => 'gradebook_view_result.php?selecteval=' .Security::remove_XSS($_GET['selecteval']).'&'.api_get_cidreq(), |
|
71 | - 'name' => get_lang('ViewResult') |
|
70 | + 'url' => 'gradebook_view_result.php?selecteval=' .Security::remove_XSS($_GET['selecteval']).'&'.api_get_cidreq(), |
|
71 | + 'name' => get_lang('ViewResult') |
|
72 | 72 | ); |
73 | 73 | Display :: display_header(get_lang('AddUserToEval')); |
74 | 74 | if (isset ($_GET['erroroneuser'])){ |
75 | - Display :: display_warning_message(get_lang('AtLeastOneUser'),false); |
|
75 | + Display :: display_warning_message(get_lang('AtLeastOneUser'),false); |
|
76 | 76 | } |
77 | 77 | DisplayGradebook :: display_header_result($evaluation[0], null, 0,0); |
78 | 78 | echo '<div class="main">'; |
@@ -115,13 +115,13 @@ discard block |
||
115 | 115 | } |
116 | 116 | |
117 | 117 | /** |
118 | - * Export tabular data to XML-file |
|
119 | - * @param array Simple array of data to put in XML |
|
120 | - * @param string Name of file to be given to the user |
|
121 | - * @param string Name of common tag to place each line in |
|
122 | - * @param string Name of the root element. A root element should always be given. |
|
123 | - * @param string Encoding in which the data is provided |
|
124 | - */ |
|
118 | + * Export tabular data to XML-file |
|
119 | + * @param array Simple array of data to put in XML |
|
120 | + * @param string Name of file to be given to the user |
|
121 | + * @param string Name of common tag to place each line in |
|
122 | + * @param string Name of the root element. A root element should always be given. |
|
123 | + * @param string Encoding in which the data is provided |
|
124 | + */ |
|
125 | 125 | public static function arrayToXml( |
126 | 126 | $data, |
127 | 127 | $filename = 'export', |
@@ -200,7 +200,7 @@ discard block |
||
200 | 200 | foreach ($data as $row) { |
201 | 201 | $string .= "\n".str_repeat("\t",$level).'<'.$row['name'].'>'; |
202 | 202 | if (is_array($row['value'])) { |
203 | - $string .= self::_export_complex_table_xml_helper($row['value'],$level+1)."\n"; |
|
203 | + $string .= self::_export_complex_table_xml_helper($row['value'],$level+1)."\n"; |
|
204 | 204 | $string .= str_repeat("\t",$level).'</'.$row['name'].'>'; |
205 | 205 | } else { |
206 | 206 | $string .= $row['value']; |
@@ -25,29 +25,29 @@ |
||
25 | 25 | function search_courses($needle,$type) |
26 | 26 | { |
27 | 27 | $tbl_session = Database :: get_main_table(TABLE_MAIN_SESSION); |
28 | - $xajax_response = new xajaxResponse(); |
|
29 | - $return = ''; |
|
30 | - if(!empty($needle) && !empty($type)) { |
|
31 | - // xajax send utf8 datas... datas in db can be non-utf8 datas |
|
32 | - $charset = api_get_system_encoding(); |
|
33 | - $needle = api_convert_encoding($needle, $charset, 'utf-8'); |
|
34 | - $needle = Database::escape_string($needle); |
|
28 | + $xajax_response = new xajaxResponse(); |
|
29 | + $return = ''; |
|
30 | + if(!empty($needle) && !empty($type)) { |
|
31 | + // xajax send utf8 datas... datas in db can be non-utf8 datas |
|
32 | + $charset = api_get_system_encoding(); |
|
33 | + $needle = api_convert_encoding($needle, $charset, 'utf-8'); |
|
34 | + $needle = Database::escape_string($needle); |
|
35 | 35 | |
36 | - $sql = 'SELECT * FROM '.$tbl_session.' WHERE name LIKE "'.$needle.'%" ORDER BY id'; |
|
36 | + $sql = 'SELECT * FROM '.$tbl_session.' WHERE name LIKE "'.$needle.'%" ORDER BY id'; |
|
37 | 37 | |
38 | - $rs = Database::query($sql); |
|
39 | - $course_list = array(); |
|
38 | + $rs = Database::query($sql); |
|
39 | + $course_list = array(); |
|
40 | 40 | |
41 | - $return .= '<select id="origin" name="NoSessionCategoryList[]" multiple="multiple" size="20" style="width:340px;">'; |
|
42 | - while($course = Database :: fetch_array($rs)) { |
|
43 | - $course_list[] = $course['id']; |
|
44 | - $return .= '<option value="'.$course['id'].'" title="'.htmlspecialchars($course['name'],ENT_QUOTES).'">'.$course['name'].'</option>'; |
|
45 | - } |
|
46 | - $return .= '</select>'; |
|
47 | - $xajax_response -> addAssign('ajax_list_courses_multiple','innerHTML',api_utf8_encode($return)); |
|
48 | - } |
|
49 | - $_SESSION['course_list'] = $course_list; |
|
41 | + $return .= '<select id="origin" name="NoSessionCategoryList[]" multiple="multiple" size="20" style="width:340px;">'; |
|
42 | + while($course = Database :: fetch_array($rs)) { |
|
43 | + $course_list[] = $course['id']; |
|
44 | + $return .= '<option value="'.$course['id'].'" title="'.htmlspecialchars($course['name'],ENT_QUOTES).'">'.$course['name'].'</option>'; |
|
45 | + } |
|
46 | + $return .= '</select>'; |
|
47 | + $xajax_response -> addAssign('ajax_list_courses_multiple','innerHTML',api_utf8_encode($return)); |
|
48 | + } |
|
49 | + $_SESSION['course_list'] = $course_list; |
|
50 | 50 | |
51 | - return $xajax_response; |
|
52 | - } |
|
51 | + return $xajax_response; |
|
52 | + } |
|
53 | 53 | } |
@@ -137,7 +137,7 @@ |
||
137 | 137 | array('\r', '\n', '\x3c', '\x3e', '\x26'), |
138 | 138 | addslashes($var) |
139 | 139 | ).'"'; |
140 | - case 'array': |
|
140 | + case 'array': |
|
141 | 141 | // Arrays in JSON can't be associative. If the array is empty or if it |
142 | 142 | // has sequential whole number keys starting with 0, it's not associative |
143 | 143 | // so we can go ahead and convert it as an array. |