@@ -47,10 +47,10 @@ discard block |
||
47 | 47 | $eval = $this->get_evaluation(); |
48 | 48 | // course/platform admin can go to the view_results page |
49 | 49 | if (api_is_allowed_to_edit()) { |
50 | - return 'gradebook_view_result.php?' . api_get_cidreq() . '&selecteval=' . $eval->get_id(); |
|
50 | + return 'gradebook_view_result.php?'.api_get_cidreq().'&selecteval='.$eval->get_id(); |
|
51 | 51 | } // students can go to the statistics page (if custom display enabled) |
52 | 52 | elseif (ScoreDisplay :: instance()->is_custom()) { |
53 | - return 'gradebook_statistics.php?' . api_get_cidreq() . '&selecteval=' . $eval->get_id(); |
|
53 | + return 'gradebook_statistics.php?'.api_get_cidreq().'&selecteval='.$eval->get_id(); |
|
54 | 54 | } else { |
55 | 55 | return null; |
56 | 56 | } |
@@ -176,8 +176,8 @@ discard block |
||
176 | 176 | $eval = new Evaluation(); |
177 | 177 | $eval->set_category_id(-1); |
178 | 178 | $eval->set_date(api_get_utc_datetime()); // these values will be changed |
179 | - $eval->set_weight(0); // when the link setter |
|
180 | - $eval->set_visible(0); // is called |
|
179 | + $eval->set_weight(0); // when the link setter |
|
180 | + $eval->set_visible(0); // is called |
|
181 | 181 | $eval->set_id(-1); // a 'real' id will be set when eval is added to db |
182 | 182 | $eval->set_user_id($this->get_user_id()); |
183 | 183 | $eval->set_course_code($this->get_course_code()); |
@@ -117,6 +117,9 @@ discard block |
||
117 | 117 | } |
118 | 118 | } |
119 | 119 | |
120 | + /** |
|
121 | + * @param string $name |
|
122 | + */ |
|
120 | 123 | public function set_name($name) |
121 | 124 | { |
122 | 125 | if ($this->is_valid_link()) { |
@@ -124,6 +127,9 @@ discard block |
||
124 | 127 | } |
125 | 128 | } |
126 | 129 | |
130 | + /** |
|
131 | + * @param string $description |
|
132 | + */ |
|
127 | 133 | public function set_description($description) |
128 | 134 | { |
129 | 135 | if ($this->is_valid_link()) { |
@@ -131,6 +137,9 @@ discard block |
||
131 | 137 | } |
132 | 138 | } |
133 | 139 | |
140 | + /** |
|
141 | + * @param integer $max |
|
142 | + */ |
|
134 | 143 | public function set_max($max) |
135 | 144 | { |
136 | 145 | if ($this->is_valid_link()) { |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | $links[] = array( |
76 | 76 | $data['survey_id'], |
77 | 77 | api_trunc_str( |
78 | - $data['code'] . ': ' . self::html_to_text($data['title']), |
|
78 | + $data['code'].': '.self::html_to_text($data['title']), |
|
79 | 79 | 80 |
80 | 80 | ) |
81 | 81 | ); |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | /** |
122 | 122 | * Has anyone done this survey yet? |
123 | 123 | */ |
124 | - public function has_results($stud_id=null) |
|
124 | + public function has_results($stud_id = null) |
|
125 | 125 | { |
126 | 126 | $ref_id = intval($this->get_ref_id()); |
127 | 127 | $session_id = api_get_session_id(); |
@@ -8,98 +8,98 @@ discard block |
||
8 | 8 | */ |
9 | 9 | class SurveyLink extends AbstractLink |
10 | 10 | { |
11 | - private $survey_table = null; |
|
12 | - |
|
13 | - /** |
|
14 | - * Constructor |
|
15 | - */ |
|
16 | - public function __construct() |
|
17 | - { |
|
18 | - parent::__construct(); |
|
19 | - $this->set_type(LINK_SURVEY); |
|
20 | - } |
|
21 | - |
|
22 | - /** |
|
23 | - * @return string |
|
24 | - */ |
|
25 | - public function get_name() |
|
26 | - { |
|
27 | - $this->get_survey_data(); |
|
11 | + private $survey_table = null; |
|
12 | + |
|
13 | + /** |
|
14 | + * Constructor |
|
15 | + */ |
|
16 | + public function __construct() |
|
17 | + { |
|
18 | + parent::__construct(); |
|
19 | + $this->set_type(LINK_SURVEY); |
|
20 | + } |
|
21 | + |
|
22 | + /** |
|
23 | + * @return string |
|
24 | + */ |
|
25 | + public function get_name() |
|
26 | + { |
|
27 | + $this->get_survey_data(); |
|
28 | 28 | |
29 | - return $this->survey_data['code'].': '.self::html_to_text($this->survey_data['title']); |
|
30 | - } |
|
31 | - |
|
32 | - public function get_description() |
|
33 | - { |
|
34 | - $this->get_survey_data(); |
|
35 | - return $this->survey_data['subtitle']; |
|
36 | - } |
|
37 | - |
|
38 | - public function get_type_name() |
|
39 | - { |
|
40 | - return get_lang('Survey'); |
|
41 | - } |
|
42 | - |
|
43 | - public function is_allowed_to_change_name() |
|
44 | - { |
|
45 | - return false; |
|
46 | - } |
|
47 | - |
|
48 | - public function needs_name_and_description() |
|
49 | - { |
|
50 | - return false; |
|
51 | - } |
|
52 | - |
|
53 | - public function needs_max() |
|
54 | - { |
|
55 | - return false; |
|
56 | - } |
|
57 | - |
|
58 | - public function needs_results() |
|
59 | - { |
|
60 | - return false; |
|
61 | - } |
|
62 | - |
|
63 | - /** |
|
64 | - * Generates an array of all surveys available. |
|
65 | - * @return array 2-dimensional array - every element contains 2 subelements (id, name) |
|
66 | - */ |
|
67 | - public function get_all_links() |
|
68 | - { |
|
69 | - if (empty($this->course_code)) { |
|
70 | - die('Error in get_all_links() : course code not set'); |
|
71 | - } |
|
72 | - $tbl_survey = $this->get_survey_table(); |
|
73 | - $session_id = api_get_session_id(); |
|
74 | - $course_id = api_get_course_int_id(); |
|
75 | - $sql = 'SELECT survey_id, title, code FROM '.$tbl_survey.' |
|
29 | + return $this->survey_data['code'].': '.self::html_to_text($this->survey_data['title']); |
|
30 | + } |
|
31 | + |
|
32 | + public function get_description() |
|
33 | + { |
|
34 | + $this->get_survey_data(); |
|
35 | + return $this->survey_data['subtitle']; |
|
36 | + } |
|
37 | + |
|
38 | + public function get_type_name() |
|
39 | + { |
|
40 | + return get_lang('Survey'); |
|
41 | + } |
|
42 | + |
|
43 | + public function is_allowed_to_change_name() |
|
44 | + { |
|
45 | + return false; |
|
46 | + } |
|
47 | + |
|
48 | + public function needs_name_and_description() |
|
49 | + { |
|
50 | + return false; |
|
51 | + } |
|
52 | + |
|
53 | + public function needs_max() |
|
54 | + { |
|
55 | + return false; |
|
56 | + } |
|
57 | + |
|
58 | + public function needs_results() |
|
59 | + { |
|
60 | + return false; |
|
61 | + } |
|
62 | + |
|
63 | + /** |
|
64 | + * Generates an array of all surveys available. |
|
65 | + * @return array 2-dimensional array - every element contains 2 subelements (id, name) |
|
66 | + */ |
|
67 | + public function get_all_links() |
|
68 | + { |
|
69 | + if (empty($this->course_code)) { |
|
70 | + die('Error in get_all_links() : course code not set'); |
|
71 | + } |
|
72 | + $tbl_survey = $this->get_survey_table(); |
|
73 | + $session_id = api_get_session_id(); |
|
74 | + $course_id = api_get_course_int_id(); |
|
75 | + $sql = 'SELECT survey_id, title, code FROM '.$tbl_survey.' |
|
76 | 76 | WHERE c_id = '.$course_id.' AND session_id = '.intval($session_id).''; |
77 | - $result = Database::query($sql); |
|
78 | - while ($data = Database::fetch_array($result)) { |
|
79 | - $links[] = array( |
|
80 | - $data['survey_id'], |
|
81 | - api_trunc_str( |
|
82 | - $data['code'] . ': ' . self::html_to_text($data['title']), |
|
83 | - 80 |
|
84 | - ) |
|
85 | - ); |
|
86 | - } |
|
87 | - |
|
88 | - return isset($links) ? $links : null; |
|
89 | - } |
|
90 | - |
|
91 | - /** |
|
92 | - * Generates an array of surveys that a teacher hasn't created a link for. |
|
93 | - * @return array 2-dimensional array - every element contains 2 subelements (id, name) |
|
94 | - */ |
|
95 | - public function get_not_created_links() |
|
96 | - { |
|
97 | - if (empty($this->course_code)) { |
|
98 | - die('Error in get_not_created_links() : course code not set'); |
|
99 | - } |
|
100 | - $tbl_grade_links = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_LINK); |
|
101 | - |
|
102 | - $sql = 'SELECT survey_id, title, code |
|
77 | + $result = Database::query($sql); |
|
78 | + while ($data = Database::fetch_array($result)) { |
|
79 | + $links[] = array( |
|
80 | + $data['survey_id'], |
|
81 | + api_trunc_str( |
|
82 | + $data['code'] . ': ' . self::html_to_text($data['title']), |
|
83 | + 80 |
|
84 | + ) |
|
85 | + ); |
|
86 | + } |
|
87 | + |
|
88 | + return isset($links) ? $links : null; |
|
89 | + } |
|
90 | + |
|
91 | + /** |
|
92 | + * Generates an array of surveys that a teacher hasn't created a link for. |
|
93 | + * @return array 2-dimensional array - every element contains 2 subelements (id, name) |
|
94 | + */ |
|
95 | + public function get_not_created_links() |
|
96 | + { |
|
97 | + if (empty($this->course_code)) { |
|
98 | + die('Error in get_not_created_links() : course code not set'); |
|
99 | + } |
|
100 | + $tbl_grade_links = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_LINK); |
|
101 | + |
|
102 | + $sql = 'SELECT survey_id, title, code |
|
103 | 103 | FROM '.$this->get_survey_table().' AS srv |
104 | 104 | WHERE survey_id NOT IN |
105 | 105 | ( |
@@ -110,28 +110,28 @@ discard block |
||
110 | 110 | ) |
111 | 111 | AND srv.session_id = '.api_get_session_id(); |
112 | 112 | |
113 | - $result = Database::query($sql); |
|
114 | - |
|
115 | - $links = array(); |
|
116 | - while ($data = Database::fetch_array($result)) { |
|
117 | - $links[] = array( |
|
118 | - $data['survey_id'], |
|
119 | - api_trunc_str($data['code'].': '.self::html_to_text($data['title']), 80) |
|
120 | - ); |
|
121 | - } |
|
122 | - return $links; |
|
123 | - } |
|
124 | - |
|
125 | - /** |
|
126 | - * Has anyone done this survey yet? |
|
127 | - */ |
|
128 | - public function has_results($stud_id=null) |
|
129 | - { |
|
130 | - $ref_id = intval($this->get_ref_id()); |
|
131 | - $session_id = api_get_session_id(); |
|
132 | - $tbl_survey = Database::get_course_table(TABLE_SURVEY); |
|
133 | - $tbl_survey_invitation = Database::get_course_table(TABLE_SURVEY_INVITATION); |
|
134 | - $sql = "SELECT |
|
113 | + $result = Database::query($sql); |
|
114 | + |
|
115 | + $links = array(); |
|
116 | + while ($data = Database::fetch_array($result)) { |
|
117 | + $links[] = array( |
|
118 | + $data['survey_id'], |
|
119 | + api_trunc_str($data['code'].': '.self::html_to_text($data['title']), 80) |
|
120 | + ); |
|
121 | + } |
|
122 | + return $links; |
|
123 | + } |
|
124 | + |
|
125 | + /** |
|
126 | + * Has anyone done this survey yet? |
|
127 | + */ |
|
128 | + public function has_results($stud_id=null) |
|
129 | + { |
|
130 | + $ref_id = intval($this->get_ref_id()); |
|
131 | + $session_id = api_get_session_id(); |
|
132 | + $tbl_survey = Database::get_course_table(TABLE_SURVEY); |
|
133 | + $tbl_survey_invitation = Database::get_course_table(TABLE_SURVEY_INVITATION); |
|
134 | + $sql = "SELECT |
|
135 | 135 | COUNT(i.answered) |
136 | 136 | FROM $tbl_survey AS s |
137 | 137 | JOIN $tbl_survey_invitation AS i ON s.code = i.survey_code |
@@ -141,30 +141,30 @@ discard block |
||
141 | 141 | s.survey_id = $ref_id AND |
142 | 142 | i.session_id = $session_id"; |
143 | 143 | |
144 | - $sql_result = Database::query($sql); |
|
145 | - $data = Database::fetch_array($sql_result); |
|
144 | + $sql_result = Database::query($sql); |
|
145 | + $data = Database::fetch_array($sql_result); |
|
146 | 146 | |
147 | - return ($data[0] != 0); |
|
148 | - } |
|
147 | + return ($data[0] != 0); |
|
148 | + } |
|
149 | 149 | |
150 | - /** |
|
151 | - * @param int $stud_id |
|
152 | - * @return array|null |
|
153 | - */ |
|
154 | - public function calc_score($stud_id = null, $type = null) |
|
155 | - { |
|
156 | - // Note: Max score is assumed to be always 1 for surveys, |
|
157 | - // only student's participation is to be taken into account. |
|
158 | - $max_score = 1; |
|
150 | + /** |
|
151 | + * @param int $stud_id |
|
152 | + * @return array|null |
|
153 | + */ |
|
154 | + public function calc_score($stud_id = null, $type = null) |
|
155 | + { |
|
156 | + // Note: Max score is assumed to be always 1 for surveys, |
|
157 | + // only student's participation is to be taken into account. |
|
158 | + $max_score = 1; |
|
159 | 159 | |
160 | - $ref_id = intval($this->get_ref_id()); |
|
161 | - $session_id = api_get_session_id(); |
|
162 | - $tbl_survey = Database::get_course_table(TABLE_SURVEY); |
|
163 | - $tbl_survey_invitation = Database::get_course_table(TABLE_SURVEY_INVITATION); |
|
160 | + $ref_id = intval($this->get_ref_id()); |
|
161 | + $session_id = api_get_session_id(); |
|
162 | + $tbl_survey = Database::get_course_table(TABLE_SURVEY); |
|
163 | + $tbl_survey_invitation = Database::get_course_table(TABLE_SURVEY_INVITATION); |
|
164 | 164 | |
165 | - $get_individual_score = !is_null($stud_id); |
|
165 | + $get_individual_score = !is_null($stud_id); |
|
166 | 166 | |
167 | - $sql = "SELECT i.answered |
|
167 | + $sql = "SELECT i.answered |
|
168 | 168 | FROM $tbl_survey AS s |
169 | 169 | JOIN $tbl_survey_invitation AS i |
170 | 170 | ON s.code = i.survey_code |
@@ -175,131 +175,131 @@ discard block |
||
175 | 175 | i.session_id = $session_id |
176 | 176 | "; |
177 | 177 | |
178 | - if ($get_individual_score) { |
|
179 | - $sql .= ' AND i.user = '.intval($stud_id); |
|
180 | - } |
|
181 | - |
|
182 | - $sql_result = Database::query($sql); |
|
183 | - |
|
184 | - if ($get_individual_score) { |
|
185 | - // for 1 student |
|
186 | - if ($data = Database::fetch_array($sql_result)) { |
|
187 | - return array($data['answered'] ? $max_score : 0, $max_score); |
|
188 | - } |
|
189 | - return array(0, $max_score); |
|
190 | - } else { |
|
191 | - // for all the students -> get average |
|
192 | - $rescount = 0; |
|
193 | - $sum = 0; |
|
194 | - $bestResult = 0; |
|
195 | - $weight = 0; |
|
196 | - while ($data = Database::fetch_array($sql_result)) { |
|
197 | - $sum += $data['answered'] ? $max_score : 0; |
|
198 | - $rescount++; |
|
199 | - if ($data['answered'] > $bestResult) { |
|
200 | - $bestResult = $data['answered']; |
|
201 | - $weight = $assignment['qualification']; |
|
202 | - } |
|
203 | - } |
|
204 | - $sum = $sum / $max_score; |
|
205 | - |
|
206 | - if ($rescount == 0) { |
|
207 | - return null; |
|
208 | - } |
|
209 | - |
|
210 | - switch ($type) { |
|
211 | - case 'best': |
|
212 | - return array($bestResult, $rescount); |
|
213 | - break; |
|
214 | - case 'average': |
|
215 | - return array($sum, $rescount); |
|
216 | - break; |
|
217 | - case 'ranking': |
|
218 | - return null; |
|
219 | - break; |
|
220 | - default: |
|
221 | - return array($sum, $rescount); |
|
222 | - break; |
|
223 | - } |
|
224 | - } |
|
225 | - } |
|
226 | - |
|
227 | - /** |
|
228 | - * Lazy load function to get the database table of the surveys |
|
229 | - */ |
|
230 | - private function get_survey_table() |
|
231 | - { |
|
232 | - $this->survey_table = Database :: get_course_table(TABLE_SURVEY); |
|
233 | - return $this->survey_table; |
|
234 | - } |
|
235 | - |
|
236 | - /** |
|
237 | - * Check if this still links to a survey |
|
238 | - */ |
|
239 | - public function is_valid_link() |
|
240 | - { |
|
241 | - $session_id = api_get_session_id(); |
|
242 | - $sql = 'SELECT count(survey_id) FROM '.$this->get_survey_table().' |
|
178 | + if ($get_individual_score) { |
|
179 | + $sql .= ' AND i.user = '.intval($stud_id); |
|
180 | + } |
|
181 | + |
|
182 | + $sql_result = Database::query($sql); |
|
183 | + |
|
184 | + if ($get_individual_score) { |
|
185 | + // for 1 student |
|
186 | + if ($data = Database::fetch_array($sql_result)) { |
|
187 | + return array($data['answered'] ? $max_score : 0, $max_score); |
|
188 | + } |
|
189 | + return array(0, $max_score); |
|
190 | + } else { |
|
191 | + // for all the students -> get average |
|
192 | + $rescount = 0; |
|
193 | + $sum = 0; |
|
194 | + $bestResult = 0; |
|
195 | + $weight = 0; |
|
196 | + while ($data = Database::fetch_array($sql_result)) { |
|
197 | + $sum += $data['answered'] ? $max_score : 0; |
|
198 | + $rescount++; |
|
199 | + if ($data['answered'] > $bestResult) { |
|
200 | + $bestResult = $data['answered']; |
|
201 | + $weight = $assignment['qualification']; |
|
202 | + } |
|
203 | + } |
|
204 | + $sum = $sum / $max_score; |
|
205 | + |
|
206 | + if ($rescount == 0) { |
|
207 | + return null; |
|
208 | + } |
|
209 | + |
|
210 | + switch ($type) { |
|
211 | + case 'best': |
|
212 | + return array($bestResult, $rescount); |
|
213 | + break; |
|
214 | + case 'average': |
|
215 | + return array($sum, $rescount); |
|
216 | + break; |
|
217 | + case 'ranking': |
|
218 | + return null; |
|
219 | + break; |
|
220 | + default: |
|
221 | + return array($sum, $rescount); |
|
222 | + break; |
|
223 | + } |
|
224 | + } |
|
225 | + } |
|
226 | + |
|
227 | + /** |
|
228 | + * Lazy load function to get the database table of the surveys |
|
229 | + */ |
|
230 | + private function get_survey_table() |
|
231 | + { |
|
232 | + $this->survey_table = Database :: get_course_table(TABLE_SURVEY); |
|
233 | + return $this->survey_table; |
|
234 | + } |
|
235 | + |
|
236 | + /** |
|
237 | + * Check if this still links to a survey |
|
238 | + */ |
|
239 | + public function is_valid_link() |
|
240 | + { |
|
241 | + $session_id = api_get_session_id(); |
|
242 | + $sql = 'SELECT count(survey_id) FROM '.$this->get_survey_table().' |
|
243 | 243 | WHERE |
244 | 244 | c_id = '.$this->course_id.' AND |
245 | 245 | survey_id = '.intval($this->get_ref_id()).' AND |
246 | 246 | session_id='.intval($session_id).''; |
247 | - $result = Database::query($sql); |
|
248 | - $number = Database::fetch_row($result); |
|
249 | - return ($number[0] != 0); |
|
250 | - } |
|
251 | - |
|
252 | - public function get_test_id() |
|
253 | - { |
|
254 | - return 'DEBUG:ID'; |
|
255 | - } |
|
256 | - |
|
257 | - public function get_link() |
|
258 | - { |
|
259 | - if (api_is_allowed_to_edit()) { // Let students make access only through "Surveys" tool. |
|
260 | - $tbl_name = $this->get_survey_table(); |
|
261 | - $session_id = api_get_session_id(); |
|
262 | - if ($tbl_name != '') { |
|
263 | - $sql = 'SELECT survey_id FROM '.$this->get_survey_table().' |
|
247 | + $result = Database::query($sql); |
|
248 | + $number = Database::fetch_row($result); |
|
249 | + return ($number[0] != 0); |
|
250 | + } |
|
251 | + |
|
252 | + public function get_test_id() |
|
253 | + { |
|
254 | + return 'DEBUG:ID'; |
|
255 | + } |
|
256 | + |
|
257 | + public function get_link() |
|
258 | + { |
|
259 | + if (api_is_allowed_to_edit()) { // Let students make access only through "Surveys" tool. |
|
260 | + $tbl_name = $this->get_survey_table(); |
|
261 | + $session_id = api_get_session_id(); |
|
262 | + if ($tbl_name != '') { |
|
263 | + $sql = 'SELECT survey_id FROM '.$this->get_survey_table().' |
|
264 | 264 | WHERE |
265 | 265 | c_id = '.$this->course_id.' AND |
266 | 266 | survey_id = '.intval($this->get_ref_id()).' AND |
267 | 267 | session_id = '.intval($session_id).' '; |
268 | - $result = Database::query($sql); |
|
269 | - $row = Database::fetch_array($result, 'ASSOC'); |
|
270 | - $survey_id = $row['survey_id']; |
|
271 | - return api_get_path(WEB_PATH).'main/survey/reporting.php?'.api_get_cidreq_params($this->get_course_code(), $session_id).'&survey_id='.$survey_id; |
|
272 | - } |
|
273 | - } |
|
274 | - return null; |
|
275 | - } |
|
276 | - |
|
277 | - private function get_survey_data() |
|
278 | - { |
|
279 | - $tbl_name = $this->get_survey_table(); |
|
280 | - $session_id = api_get_session_id(); |
|
281 | - if ($tbl_name == '') { |
|
282 | - return false; |
|
283 | - } elseif (!isset($this->survey_data)) { |
|
284 | - $sql = 'SELECT * FROM '.$tbl_name.' |
|
268 | + $result = Database::query($sql); |
|
269 | + $row = Database::fetch_array($result, 'ASSOC'); |
|
270 | + $survey_id = $row['survey_id']; |
|
271 | + return api_get_path(WEB_PATH).'main/survey/reporting.php?'.api_get_cidreq_params($this->get_course_code(), $session_id).'&survey_id='.$survey_id; |
|
272 | + } |
|
273 | + } |
|
274 | + return null; |
|
275 | + } |
|
276 | + |
|
277 | + private function get_survey_data() |
|
278 | + { |
|
279 | + $tbl_name = $this->get_survey_table(); |
|
280 | + $session_id = api_get_session_id(); |
|
281 | + if ($tbl_name == '') { |
|
282 | + return false; |
|
283 | + } elseif (!isset($this->survey_data)) { |
|
284 | + $sql = 'SELECT * FROM '.$tbl_name.' |
|
285 | 285 | WHERE |
286 | 286 | c_id = '.$this->course_id.' AND |
287 | 287 | survey_id = '.intval($this->get_ref_id()).' AND |
288 | 288 | session_id='.intval($session_id).''; |
289 | - $query = Database::query($sql); |
|
290 | - $this->survey_data = Database::fetch_array($query); |
|
291 | - } |
|
292 | - return $this->survey_data; |
|
293 | - } |
|
294 | - |
|
295 | - public function get_icon_name() |
|
296 | - { |
|
297 | - return 'survey'; |
|
298 | - } |
|
299 | - |
|
300 | - private static function html_to_text($string) |
|
301 | - { |
|
302 | - return strip_tags($string); |
|
303 | - //return trim(api_html_entity_decode(strip_tags(str_ireplace(array('<p>', '</p>', '<br />', '<br/>', '<br>'), array('', ' ', ' ', ' ', ' '), $string)), ENT_QUOTES)); |
|
304 | - } |
|
289 | + $query = Database::query($sql); |
|
290 | + $this->survey_data = Database::fetch_array($query); |
|
291 | + } |
|
292 | + return $this->survey_data; |
|
293 | + } |
|
294 | + |
|
295 | + public function get_icon_name() |
|
296 | + { |
|
297 | + return 'survey'; |
|
298 | + } |
|
299 | + |
|
300 | + private static function html_to_text($string) |
|
301 | + { |
|
302 | + return strip_tags($string); |
|
303 | + //return trim(api_html_entity_decode(strip_tags(str_ireplace(array('<p>', '</p>', '<br />', '<br/>', '<br>'), array('', ' ', ' ', ' ', ' '), $string)), ENT_QUOTES)); |
|
304 | + } |
|
305 | 305 | } |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | * @param string $name_mask search string |
59 | 59 | * @return array link objects matching the search criterium |
60 | 60 | */ |
61 | - public function find_links($name_mask,$selectcat) |
|
61 | + public function find_links($name_mask, $selectcat) |
|
62 | 62 | { |
63 | 63 | return AbstractLink::find_links($name_mask, $selectcat); |
64 | 64 | } |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | public static function get_all_types() |
99 | 99 | { |
100 | 100 | //LINK_DROPBOX, |
101 | - return array ( |
|
101 | + return array( |
|
102 | 102 | LINK_EXERCISE, |
103 | 103 | //LINK_DROPBOX, |
104 | 104 | LINK_HOTPOTATOES, |
@@ -93,7 +93,7 @@ |
||
93 | 93 | |
94 | 94 | /** |
95 | 95 | * Return an array of all known link types |
96 | - * @return array |
|
96 | + * @return integer[] |
|
97 | 97 | */ |
98 | 98 | public static function get_all_types() |
99 | 99 | { |
@@ -90,23 +90,23 @@ discard block |
||
90 | 90 | if (is_null($id) && is_null($user_id) && !is_null($evaluation_id)) { |
91 | 91 | // Verified_if_exist_evaluation |
92 | 92 | $sql = 'SELECT COUNT(*) AS count |
93 | - FROM ' . $tbl_grade_results . ' |
|
94 | - WHERE evaluation_id="' . Database::escape_string($evaluation_id) . '";'; |
|
93 | + FROM ' . $tbl_grade_results.' |
|
94 | + WHERE evaluation_id="' . Database::escape_string($evaluation_id).'";'; |
|
95 | 95 | $result = Database::query($sql); |
96 | 96 | $existEvaluation = Database::result($result, 0, 0); |
97 | 97 | |
98 | 98 | if ($existEvaluation != 0) { |
99 | 99 | if ($sessionId) { |
100 | 100 | $sql = 'SELECT c_id, user_id as user_id, status |
101 | - FROM ' . $tbl_session_rel_course_user . ' |
|
101 | + FROM ' . $tbl_session_rel_course_user.' |
|
102 | 102 | WHERE |
103 | 103 | status= 0 AND |
104 | - c_id = "' . api_get_course_int_id() . '" AND |
|
104 | + c_id = "' . api_get_course_int_id().'" AND |
|
105 | 105 | session_id = ' . $sessionId; |
106 | 106 | } else { |
107 | 107 | $sql = 'SELECT c_id, user_id, status |
108 | - FROM ' . $tbl_course_rel_course . ' |
|
109 | - WHERE status ="' . STUDENT . '" AND c_id = "' . api_get_course_int_id() . '" '; |
|
108 | + FROM ' . $tbl_course_rel_course.' |
|
109 | + WHERE status ="' . STUDENT.'" AND c_id = "'.api_get_course_int_id().'" '; |
|
110 | 110 | } |
111 | 111 | |
112 | 112 | $res_course_rel_user = Database::query($sql); |
@@ -116,15 +116,15 @@ discard block |
||
116 | 116 | $current_date = api_get_utc_datetime(); |
117 | 117 | for ($i = 0; $i < count($list_user_course_list); $i++) { |
118 | 118 | $sql_verified = 'SELECT COUNT(*) AS count |
119 | - FROM ' . $tbl_grade_results . ' |
|
119 | + FROM ' . $tbl_grade_results.' |
|
120 | 120 | WHERE |
121 | - user_id="' . intval($list_user_course_list[$i]['user_id']) . '" AND |
|
122 | - evaluation_id="' . intval($evaluation_id) . '";'; |
|
121 | + user_id="' . intval($list_user_course_list[$i]['user_id']).'" AND |
|
122 | + evaluation_id="' . intval($evaluation_id).'";'; |
|
123 | 123 | $res_verified = Database::query($sql_verified); |
124 | 124 | $info_verified = Database::result($res_verified, 0, 0); |
125 | 125 | if ($info_verified == 0) { |
126 | - $sql_insert = 'INSERT INTO ' . $tbl_grade_results . '(user_id,evaluation_id,created_at,score) |
|
127 | - VALUES ("' . intval($list_user_course_list[$i]['user_id']) . '","' . intval($evaluation_id) . '","' . $current_date . '",0);'; |
|
126 | + $sql_insert = 'INSERT INTO '.$tbl_grade_results.'(user_id,evaluation_id,created_at,score) |
|
127 | + VALUES ("' . intval($list_user_course_list[$i]['user_id']).'","'.intval($evaluation_id).'","'.$current_date.'",0);'; |
|
128 | 128 | Database::query($sql_insert); |
129 | 129 | } |
130 | 130 | } |
@@ -148,16 +148,16 @@ discard block |
||
148 | 148 | |
149 | 149 | $paramcount = 0; |
150 | 150 | if (!empty($id)) { |
151 | - $sql.= ' WHERE gr.id = ' . intval($id); |
|
152 | - $paramcount ++; |
|
151 | + $sql .= ' WHERE gr.id = '.intval($id); |
|
152 | + $paramcount++; |
|
153 | 153 | } |
154 | 154 | if (!empty($user_id)) { |
155 | 155 | if ($paramcount != 0) |
156 | 156 | $sql .= ' AND'; |
157 | 157 | else |
158 | 158 | $sql .= ' WHERE'; |
159 | - $sql .= ' gr.user_id = ' . intval($user_id); |
|
160 | - $paramcount ++; |
|
159 | + $sql .= ' gr.user_id = '.intval($user_id); |
|
160 | + $paramcount++; |
|
161 | 161 | } |
162 | 162 | if (!empty($evaluation_id)) { |
163 | 163 | if ($paramcount != 0) { |
@@ -165,8 +165,8 @@ discard block |
||
165 | 165 | } else { |
166 | 166 | $sql .= ' WHERE'; |
167 | 167 | } |
168 | - $sql .= ' gr.evaluation_id = ' . intval($evaluation_id); |
|
169 | - $paramcount ++; |
|
168 | + $sql .= ' gr.evaluation_id = '.intval($evaluation_id); |
|
169 | + $paramcount++; |
|
170 | 170 | } |
171 | 171 | $sql .= ' ORDER BY u.lastname, u.firstname'; |
172 | 172 | $result = Database::query($sql); |
@@ -191,17 +191,17 @@ discard block |
||
191 | 191 | { |
192 | 192 | if (isset($this->user_id) && isset($this->evaluation)) { |
193 | 193 | $tbl_grade_results = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_RESULT); |
194 | - $sql = "INSERT INTO " . $tbl_grade_results |
|
194 | + $sql = "INSERT INTO ".$tbl_grade_results |
|
195 | 195 | . " (user_id, evaluation_id, |
196 | 196 | created_at"; |
197 | 197 | if (isset($this->score)) { |
198 | 198 | $sql .= ",score"; |
199 | 199 | } |
200 | 200 | $sql .= ") VALUES |
201 | - (" . (int) $this->get_user_id() . ", " . (int) $this->get_evaluation_id() |
|
202 | - . ", '" . $this->get_date() . "' "; |
|
201 | + (" . (int) $this->get_user_id().", ".(int) $this->get_evaluation_id() |
|
202 | + . ", '".$this->get_date()."' "; |
|
203 | 203 | if (isset($this->score)) { |
204 | - $sql .= ", " . $this->get_score(); |
|
204 | + $sql .= ", ".$this->get_score(); |
|
205 | 205 | } |
206 | 206 | $sql .= ")"; |
207 | 207 | Database::query($sql); |
@@ -222,16 +222,16 @@ discard block |
||
222 | 222 | $arr_result = $result->load(null, $userid, $evaluationid); |
223 | 223 | $arr = get_object_vars($arr_result[0]); |
224 | 224 | |
225 | - $sql = 'INSERT INTO ' . $tbl_grade_results_log |
|
225 | + $sql = 'INSERT INTO '.$tbl_grade_results_log |
|
226 | 226 | . ' (id_result,user_id, evaluation_id,created_at'; |
227 | 227 | if (isset($arr['score'])) { |
228 | 228 | $sql .= ',score'; |
229 | 229 | } |
230 | 230 | $sql .= ') VALUES |
231 | - (' . (int) $arr['id'] . ',' . (int) $arr['user_id'] . ', ' . (int) $arr['evaluation'] |
|
232 | - . ", '" . api_get_utc_datetime() . "'"; |
|
231 | + (' . (int) $arr['id'].','.(int) $arr['user_id'].', '.(int) $arr['evaluation'] |
|
232 | + . ", '".api_get_utc_datetime()."'"; |
|
233 | 233 | if (isset($arr['score'])) { |
234 | - $sql .= ', ' . $arr['score']; |
|
234 | + $sql .= ', '.$arr['score']; |
|
235 | 235 | } |
236 | 236 | $sql .= ')'; |
237 | 237 | |
@@ -247,16 +247,16 @@ discard block |
||
247 | 247 | public function save() |
248 | 248 | { |
249 | 249 | $tbl_grade_results = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_RESULT); |
250 | - $sql = 'UPDATE ' . $tbl_grade_results . ' |
|
250 | + $sql = 'UPDATE '.$tbl_grade_results.' |
|
251 | 251 | SET user_id = ' . $this->get_user_id() |
252 | - . ', evaluation_id = ' . $this->get_evaluation_id() |
|
252 | + . ', evaluation_id = '.$this->get_evaluation_id() |
|
253 | 253 | . ', score = '; |
254 | 254 | if (isset($this->score)) { |
255 | 255 | $sql .= $this->get_score(); |
256 | 256 | } else { |
257 | 257 | $sql .= 'null'; |
258 | 258 | } |
259 | - $sql .= ' WHERE id = ' . $this->id; |
|
259 | + $sql .= ' WHERE id = '.$this->id; |
|
260 | 260 | // no need to update creation date |
261 | 261 | Database::query($sql); |
262 | 262 | } |
@@ -267,7 +267,7 @@ discard block |
||
267 | 267 | public function delete() |
268 | 268 | { |
269 | 269 | $tbl_grade_results = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_RESULT); |
270 | - $sql = 'DELETE FROM ' . $tbl_grade_results . ' WHERE id = ' . $this->id; |
|
270 | + $sql = 'DELETE FROM '.$tbl_grade_results.' WHERE id = '.$this->id; |
|
271 | 271 | Database::query($sql); |
272 | 272 | } |
273 | 273 | } |
@@ -152,10 +152,11 @@ |
||
152 | 152 | $paramcount ++; |
153 | 153 | } |
154 | 154 | if (!empty($user_id)) { |
155 | - if ($paramcount != 0) |
|
156 | - $sql .= ' AND'; |
|
157 | - else |
|
158 | - $sql .= ' WHERE'; |
|
155 | + if ($paramcount != 0) { |
|
156 | + $sql .= ' AND'; |
|
157 | + } else { |
|
158 | + $sql .= ' WHERE'; |
|
159 | + } |
|
159 | 160 | $sql .= ' gr.user_id = ' . intval($user_id); |
160 | 161 | $paramcount ++; |
161 | 162 | } |
@@ -87,7 +87,7 @@ |
||
87 | 87 | $from = intval($from); |
88 | 88 | $number_of_items = intval($number_of_items); |
89 | 89 | $column = intval($column); |
90 | - $direction = !in_array(strtolower(trim($direction)), ['asc','desc']) ? 'asc' : $direction; |
|
90 | + $direction = !in_array(strtolower(trim($direction)), ['asc', 'desc']) ? 'asc' : $direction; |
|
91 | 91 | |
92 | 92 | $sql = "SELECT |
93 | 93 | id AS col0, |
@@ -269,8 +269,7 @@ |
||
269 | 269 | echo '<br /><br />'; |
270 | 270 | echo '</div>'; |
271 | 271 | |
272 | -} |
|
273 | -elseif (!empty($annee) && !empty($course) && ($_POST['confirmed']=='yes')) |
|
272 | +} elseif (!empty($annee) && !empty($course) && ($_POST['confirmed']=='yes')) |
|
274 | 273 | { |
275 | 274 | $id=$_POST['username_form']; |
276 | 275 | $UserList=array(); |
@@ -56,19 +56,19 @@ discard block |
||
56 | 56 | //if ($annee == "" && $composante == "" && $etape == "") { |
57 | 57 | if (empty($annee) && empty($course)) |
58 | 58 | { |
59 | - Display::display_header($tool_name); |
|
60 | - echo '<div style="align:center">'; |
|
61 | - Display::display_icon('group.gif', get_lang('LDAPSelectFilterOnUsersOU')); |
|
62 | - echo get_lang('LDAPSelectFilterOnUsersOU'); |
|
63 | - //echo '<em>'.get_lang('ToDoThisYouMustEnterYearComponentAndComponentStep').'</em><br />'; |
|
64 | - ///echo get_lang('FollowEachOfTheseStepsStepByStep').'<br />'; |
|
65 | - |
|
66 | - echo '<form method="get" action="'.api_get_self().'"><br />'; |
|
67 | - echo '<em>'.get_lang('LDAPOUAttributeFilter').' :</em> '; |
|
68 | - echo '<input type="text" name="annee" size="4" maxlength="30" value="'.$annee_base.'"><br />'; |
|
69 | - echo '<input type="submit" value="'.get_lang('Submit').'">'; |
|
70 | - echo '</form>'; |
|
71 | - echo '</div>'; |
|
59 | + Display::display_header($tool_name); |
|
60 | + echo '<div style="align:center">'; |
|
61 | + Display::display_icon('group.gif', get_lang('LDAPSelectFilterOnUsersOU')); |
|
62 | + echo get_lang('LDAPSelectFilterOnUsersOU'); |
|
63 | + //echo '<em>'.get_lang('ToDoThisYouMustEnterYearComponentAndComponentStep').'</em><br />'; |
|
64 | + ///echo get_lang('FollowEachOfTheseStepsStepByStep').'<br />'; |
|
65 | + |
|
66 | + echo '<form method="get" action="'.api_get_self().'"><br />'; |
|
67 | + echo '<em>'.get_lang('LDAPOUAttributeFilter').' :</em> '; |
|
68 | + echo '<input type="text" name="annee" size="4" maxlength="30" value="'.$annee_base.'"><br />'; |
|
69 | + echo '<input type="submit" value="'.get_lang('Submit').'">'; |
|
70 | + echo '</form>'; |
|
71 | + echo '</div>'; |
|
72 | 72 | |
73 | 73 | } |
74 | 74 | /* |
@@ -200,71 +200,71 @@ discard block |
||
200 | 200 | */ |
201 | 201 | elseif(!empty($annee) && empty($course)) |
202 | 202 | { |
203 | - Display::display_header($tool_name); |
|
204 | - echo '<div style="align:center">'; |
|
205 | - echo Display::return_icon('course.png', get_lang('SelectCourseToImportUsersTo')).' '.get_lang('SelectCourseToImportUsersTo').'<br />'; |
|
206 | - echo '<form method="post" action="'.api_get_self().'?annee='.Security::remove_XSS($annee).'"><br />'; |
|
207 | - echo '<select name="course">'; |
|
208 | - $courses = CourseManager::get_courses_list(); |
|
209 | - foreach($courses as $row) |
|
210 | - { |
|
211 | - echo '<option value="'.$row['code'].'">'.api_htmlentities($row['title']).'</option>'; |
|
212 | - } |
|
213 | - echo '</select>'; |
|
214 | - echo '<input type="submit" value="'.get_lang('Submit').'">'; |
|
215 | - echo '</form>'; |
|
216 | - echo '</div>'; |
|
203 | + Display::display_header($tool_name); |
|
204 | + echo '<div style="align:center">'; |
|
205 | + echo Display::return_icon('course.png', get_lang('SelectCourseToImportUsersTo')).' '.get_lang('SelectCourseToImportUsersTo').'<br />'; |
|
206 | + echo '<form method="post" action="'.api_get_self().'?annee='.Security::remove_XSS($annee).'"><br />'; |
|
207 | + echo '<select name="course">'; |
|
208 | + $courses = CourseManager::get_courses_list(); |
|
209 | + foreach($courses as $row) |
|
210 | + { |
|
211 | + echo '<option value="'.$row['code'].'">'.api_htmlentities($row['title']).'</option>'; |
|
212 | + } |
|
213 | + echo '</select>'; |
|
214 | + echo '<input type="submit" value="'.get_lang('Submit').'">'; |
|
215 | + echo '</form>'; |
|
216 | + echo '</div>'; |
|
217 | 217 | } |
218 | 218 | // form4 annee != 0; composante != 0 etape != 0 |
219 | 219 | //elseif ($annee <> "" && $composante <> "" && $etape <> "" && $listeok != 'yes') { |
220 | 220 | elseif (!empty($annee) && !empty($course) && empty($_POST['confirmed'])) |
221 | 221 | { |
222 | - Display::display_header($tool_name); |
|
223 | - echo '<div style="align: center;">'; |
|
224 | - echo '<br />'; |
|
225 | - echo '<br />'; |
|
226 | - echo '<h3>'.Display::return_icon('group.gif', get_lang('SelectStudents')).' '.get_lang('SelectStudents').'</h3>'; |
|
227 | - //echo "Connection ..."; |
|
228 | - $ds = ldap_connect($ldap_host, $ldap_port) or die(get_lang('LDAPConnectionError')); |
|
229 | - ldap_set_version($ds); |
|
230 | - |
|
231 | - if ($ds) { |
|
232 | - |
|
233 | - $r = false; |
|
234 | - $res = ldap_handle_bind($ds, $r); |
|
235 | - |
|
236 | - //$sr = @ ldap_search($ds, "ou=people,$LDAPbasedn", "(|(edupersonprimaryorgunitdn=ou=$etape,ou=$annee,ou=diploma,o=Paris1,$LDAPbasedn)(edupersonprimaryorgunitdn=ou=02PEL,ou=$annee,ou=diploma,o=Paris1,$LDAPbasedn))"); |
|
237 | - //echo "(ou=*$annee,ou=$composante)"; |
|
238 | - $sr = @ ldap_search($ds, $ldap_basedn, "(ou=*$annee)"); |
|
239 | - |
|
240 | - $info = ldap_get_entries($ds, $sr); |
|
241 | - |
|
242 | - for ($key = 0; $key < $info["count"]; $key ++) { |
|
243 | - $nom_form[] = $info[$key]["sn"][0]; |
|
244 | - $prenom_form[] = $info[$key]["givenname"][0]; |
|
245 | - $email_form[] = $info[$key]["mail"][0]; |
|
246 | - // Get uid from dn |
|
247 | - //$dn_array=ldap_explode_dn($info[$key]["dn"],1); |
|
248 | - //$username_form[] = $dn_array[0]; // uid is first key |
|
249 | - $username_form[] = $info[$key]['uid'][0]; |
|
250 | - $outab[] = $info[$key]["eduPersonPrimaryAffiliation"][0]; // Ici "student" |
|
251 | - //$val = ldap_get_values_len($ds, $entry, "userPassword"); |
|
252 | - //$password_form[] = $val[0]; |
|
253 | - $password_form[] = $info[$key]['userPassword'][0]; |
|
254 | - } |
|
255 | - ldap_unbind($ds); |
|
256 | - |
|
257 | - /*-----------------------------------------------*/ |
|
258 | - |
|
259 | - asort($nom_form); |
|
260 | - reset($nom_form); |
|
261 | - |
|
262 | - $statut=5; |
|
263 | - include ('ldap_form_add_users_group.php'); |
|
264 | - } else { |
|
265 | - echo '<h4>'.get_lang('UnableToConnectTo').' '.$host.'</h4>'; |
|
266 | - } |
|
267 | - echo '<br /><br />'; |
|
222 | + Display::display_header($tool_name); |
|
223 | + echo '<div style="align: center;">'; |
|
224 | + echo '<br />'; |
|
225 | + echo '<br />'; |
|
226 | + echo '<h3>'.Display::return_icon('group.gif', get_lang('SelectStudents')).' '.get_lang('SelectStudents').'</h3>'; |
|
227 | + //echo "Connection ..."; |
|
228 | + $ds = ldap_connect($ldap_host, $ldap_port) or die(get_lang('LDAPConnectionError')); |
|
229 | + ldap_set_version($ds); |
|
230 | + |
|
231 | + if ($ds) { |
|
232 | + |
|
233 | + $r = false; |
|
234 | + $res = ldap_handle_bind($ds, $r); |
|
235 | + |
|
236 | + //$sr = @ ldap_search($ds, "ou=people,$LDAPbasedn", "(|(edupersonprimaryorgunitdn=ou=$etape,ou=$annee,ou=diploma,o=Paris1,$LDAPbasedn)(edupersonprimaryorgunitdn=ou=02PEL,ou=$annee,ou=diploma,o=Paris1,$LDAPbasedn))"); |
|
237 | + //echo "(ou=*$annee,ou=$composante)"; |
|
238 | + $sr = @ ldap_search($ds, $ldap_basedn, "(ou=*$annee)"); |
|
239 | + |
|
240 | + $info = ldap_get_entries($ds, $sr); |
|
241 | + |
|
242 | + for ($key = 0; $key < $info["count"]; $key ++) { |
|
243 | + $nom_form[] = $info[$key]["sn"][0]; |
|
244 | + $prenom_form[] = $info[$key]["givenname"][0]; |
|
245 | + $email_form[] = $info[$key]["mail"][0]; |
|
246 | + // Get uid from dn |
|
247 | + //$dn_array=ldap_explode_dn($info[$key]["dn"],1); |
|
248 | + //$username_form[] = $dn_array[0]; // uid is first key |
|
249 | + $username_form[] = $info[$key]['uid'][0]; |
|
250 | + $outab[] = $info[$key]["eduPersonPrimaryAffiliation"][0]; // Ici "student" |
|
251 | + //$val = ldap_get_values_len($ds, $entry, "userPassword"); |
|
252 | + //$password_form[] = $val[0]; |
|
253 | + $password_form[] = $info[$key]['userPassword'][0]; |
|
254 | + } |
|
255 | + ldap_unbind($ds); |
|
256 | + |
|
257 | + /*-----------------------------------------------*/ |
|
258 | + |
|
259 | + asort($nom_form); |
|
260 | + reset($nom_form); |
|
261 | + |
|
262 | + $statut=5; |
|
263 | + include ('ldap_form_add_users_group.php'); |
|
264 | + } else { |
|
265 | + echo '<h4>'.get_lang('UnableToConnectTo').' '.$host.'</h4>'; |
|
266 | + } |
|
267 | + echo '<br /><br />'; |
|
268 | 268 | echo '<a href="ldap_import_students.php?annee=&composante=&etape=">'.get_lang('BackToNewSearch').'</a>'; |
269 | 269 | echo '<br /><br />'; |
270 | 270 | echo '</div>'; |
@@ -272,27 +272,27 @@ discard block |
||
272 | 272 | } |
273 | 273 | elseif (!empty($annee) && !empty($course) && ($_POST['confirmed']=='yes')) |
274 | 274 | { |
275 | - $id=$_POST['username_form']; |
|
276 | - $UserList=array(); |
|
277 | - $userid_match_login = array(); |
|
278 | - foreach ($id as $form_index=>$user_id) |
|
279 | - { |
|
280 | - if(is_array($_POST['checkboxes']) && in_array($form_index,array_values($_POST['checkboxes']))) |
|
281 | - { |
|
282 | - $tmp = ldap_add_user($user_id); |
|
283 | - $UserList[]= $tmp; |
|
284 | - $userid_match_login[$tmp] = $user_id; |
|
285 | - } |
|
286 | - } |
|
287 | - if (!empty($_POST['course'])) |
|
288 | - { |
|
289 | - foreach($UserList as $user_id) |
|
290 | - { |
|
291 | - CourseManager::add_user_to_course($user_id,$_POST['course']); |
|
292 | - } |
|
293 | - header('Location: course_information.php?code='.Security::remove_XSS($_POST['course'])); |
|
294 | - } |
|
295 | - /* |
|
275 | + $id=$_POST['username_form']; |
|
276 | + $UserList=array(); |
|
277 | + $userid_match_login = array(); |
|
278 | + foreach ($id as $form_index=>$user_id) |
|
279 | + { |
|
280 | + if(is_array($_POST['checkboxes']) && in_array($form_index,array_values($_POST['checkboxes']))) |
|
281 | + { |
|
282 | + $tmp = ldap_add_user($user_id); |
|
283 | + $UserList[]= $tmp; |
|
284 | + $userid_match_login[$tmp] = $user_id; |
|
285 | + } |
|
286 | + } |
|
287 | + if (!empty($_POST['course'])) |
|
288 | + { |
|
289 | + foreach($UserList as $user_id) |
|
290 | + { |
|
291 | + CourseManager::add_user_to_course($user_id,$_POST['course']); |
|
292 | + } |
|
293 | + header('Location: course_information.php?code='.Security::remove_XSS($_POST['course'])); |
|
294 | + } |
|
295 | + /* |
|
296 | 296 | else |
297 | 297 | { |
298 | 298 | Display :: display_header($tool_name); |
@@ -311,13 +311,13 @@ discard block |
||
311 | 311 | Display :: display_normal_message($message,false); |
312 | 312 | } |
313 | 313 | */ |
314 | - else |
|
315 | - { |
|
316 | - Display::display_header($tool_name); |
|
317 | - $message=get_lang('NoUserAdded'); |
|
318 | - Display :: display_normal_message($message,false); |
|
319 | - } |
|
320 | - echo '<br /><br />'; |
|
314 | + else |
|
315 | + { |
|
316 | + Display::display_header($tool_name); |
|
317 | + $message=get_lang('NoUserAdded'); |
|
318 | + Display :: display_normal_message($message,false); |
|
319 | + } |
|
320 | + echo '<br /><br />'; |
|
321 | 321 | echo '<a href="ldap_import_students.php?annee=&composante=&etape=">'.get_lang('BackToNewSearch').'</a>'; |
322 | 322 | echo '<br /><br />'; |
323 | 323 | } |
@@ -6,7 +6,7 @@ discard block |
||
6 | 6 | * Copyright (c) 2007 Mustapha Alouani (supervised by Michel Moreau-Belliard) |
7 | 7 | */ |
8 | 8 | // resetting the course id |
9 | -$cidReset=true; |
|
9 | +$cidReset = true; |
|
10 | 10 | require_once __DIR__.'/../inc/global.inc.php'; |
11 | 11 | // setting the section (for the tabs) |
12 | 12 | $this_section = SECTION_PLATFORM_ADMIN; |
@@ -15,11 +15,11 @@ discard block |
||
15 | 15 | api_protect_admin_script(); |
16 | 16 | require('../auth/ldap/authldap.php'); |
17 | 17 | |
18 | -$annee_base=date('Y'); |
|
18 | +$annee_base = date('Y'); |
|
19 | 19 | |
20 | 20 | $tool_name = get_lang('LDAPImport'); |
21 | 21 | // setting breadcrumbs |
22 | -$interbreadcrumb[]=array('url' => 'index.php','name' => get_lang('PlatformAdmin')); |
|
22 | +$interbreadcrumb[] = array('url' => 'index.php', 'name' => get_lang('PlatformAdmin')); |
|
23 | 23 | |
24 | 24 | $htmlHeadXtra[] = '<script language="JavaScript" type="text/javascript"> |
25 | 25 | var buttoncheck = 1; |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | |
46 | 46 | $annee = $_GET['annee']; |
47 | 47 | $composante = $_GET['composante']; |
48 | -$etape = $_GET['etape']; |
|
48 | +$etape = $_GET['etape']; |
|
49 | 49 | $course = $_POST['course']; |
50 | 50 | |
51 | 51 | |
@@ -195,7 +195,7 @@ discard block |
||
195 | 195 | echo '</div>'; |
196 | 196 | } |
197 | 197 | */ |
198 | -elseif(!empty($annee) && empty($course)) |
|
198 | +elseif (!empty($annee) && empty($course)) |
|
199 | 199 | { |
200 | 200 | Display::display_header($tool_name); |
201 | 201 | echo '<div style="align:center">'; |
@@ -203,7 +203,7 @@ discard block |
||
203 | 203 | echo '<form method="post" action="'.api_get_self().'?annee='.Security::remove_XSS($annee).'"><br />'; |
204 | 204 | echo '<select name="course">'; |
205 | 205 | $courses = CourseManager::get_courses_list(); |
206 | - foreach($courses as $row) |
|
206 | + foreach ($courses as $row) |
|
207 | 207 | { |
208 | 208 | echo '<option value="'.$row['code'].'">'.api_htmlentities($row['title']).'</option>'; |
209 | 209 | } |
@@ -236,7 +236,7 @@ discard block |
||
236 | 236 | |
237 | 237 | $info = ldap_get_entries($ds, $sr); |
238 | 238 | |
239 | - for ($key = 0; $key < $info["count"]; $key ++) { |
|
239 | + for ($key = 0; $key < $info["count"]; $key++) { |
|
240 | 240 | $nom_form[] = $info[$key]["sn"][0]; |
241 | 241 | $prenom_form[] = $info[$key]["givenname"][0]; |
242 | 242 | $email_form[] = $info[$key]["mail"][0]; |
@@ -256,7 +256,7 @@ discard block |
||
256 | 256 | asort($nom_form); |
257 | 257 | reset($nom_form); |
258 | 258 | |
259 | - $statut=5; |
|
259 | + $statut = 5; |
|
260 | 260 | include ('ldap_form_add_users_group.php'); |
261 | 261 | } else { |
262 | 262 | echo '<h4>'.get_lang('UnableToConnectTo').' '.$host.'</h4>'; |
@@ -267,25 +267,25 @@ discard block |
||
267 | 267 | echo '</div>'; |
268 | 268 | |
269 | 269 | } |
270 | -elseif (!empty($annee) && !empty($course) && ($_POST['confirmed']=='yes')) |
|
270 | +elseif (!empty($annee) && !empty($course) && ($_POST['confirmed'] == 'yes')) |
|
271 | 271 | { |
272 | - $id=$_POST['username_form']; |
|
273 | - $UserList=array(); |
|
272 | + $id = $_POST['username_form']; |
|
273 | + $UserList = array(); |
|
274 | 274 | $userid_match_login = array(); |
275 | 275 | foreach ($id as $form_index=>$user_id) |
276 | 276 | { |
277 | - if(is_array($_POST['checkboxes']) && in_array($form_index,array_values($_POST['checkboxes']))) |
|
277 | + if (is_array($_POST['checkboxes']) && in_array($form_index, array_values($_POST['checkboxes']))) |
|
278 | 278 | { |
279 | 279 | $tmp = ldap_add_user($user_id); |
280 | - $UserList[]= $tmp; |
|
280 | + $UserList[] = $tmp; |
|
281 | 281 | $userid_match_login[$tmp] = $user_id; |
282 | 282 | } |
283 | 283 | } |
284 | 284 | if (!empty($_POST['course'])) |
285 | 285 | { |
286 | - foreach($UserList as $user_id) |
|
286 | + foreach ($UserList as $user_id) |
|
287 | 287 | { |
288 | - CourseManager::add_user_to_course($user_id,$_POST['course']); |
|
288 | + CourseManager::add_user_to_course($user_id, $_POST['course']); |
|
289 | 289 | } |
290 | 290 | header('Location: course_information.php?code='.Security::remove_XSS($_POST['course'])); |
291 | 291 | } |
@@ -311,8 +311,8 @@ discard block |
||
311 | 311 | else |
312 | 312 | { |
313 | 313 | Display::display_header($tool_name); |
314 | - $message=get_lang('NoUserAdded'); |
|
315 | - Display :: display_normal_message($message,false); |
|
314 | + $message = get_lang('NoUserAdded'); |
|
315 | + Display :: display_normal_message($message, false); |
|
316 | 316 | } |
317 | 317 | echo '<br /><br />'; |
318 | 318 | echo '<a href="ldap_import_students.php?annee=&composante=&etape=">'.get_lang('BackToNewSearch').'</a>'; |
@@ -87,7 +87,7 @@ |
||
87 | 87 | <?php |
88 | 88 | echo Display::get_alphabet_options($firstLetterUserGroup); |
89 | 89 | echo Display::get_numeric_options(0, 9, $firstLetterUserGroup); |
90 | - ?> |
|
90 | + ?> |
|
91 | 91 | </select> |
92 | 92 | </td> |
93 | 93 | <td width="20%"> </td> |
@@ -30,8 +30,8 @@ discard block |
||
30 | 30 | $tbl_course = Database:: get_main_table(TABLE_MAIN_COURSE); |
31 | 31 | |
32 | 32 | $tool_name = get_lang('AddUserGroupToURL'); |
33 | -$interbreadcrumb[] = array ('url' => 'index.php', 'name' => get_lang('PlatformAdmin')); |
|
34 | -$interbreadcrumb[] = array ('url' => 'access_urls.php', 'name' => get_lang('MultipleAccessURLs')); |
|
33 | +$interbreadcrumb[] = array('url' => 'index.php', 'name' => get_lang('PlatformAdmin')); |
|
34 | +$interbreadcrumb[] = array('url' => 'access_urls.php', 'name' => get_lang('MultipleAccessURLs')); |
|
35 | 35 | |
36 | 36 | Display::display_header($tool_name); |
37 | 37 | |
@@ -46,8 +46,8 @@ discard block |
||
46 | 46 | |
47 | 47 | if (isset($_POST['form_sent']) && $_POST['form_sent']) { |
48 | 48 | $form_sent = $_POST['form_sent']; |
49 | - $userGroups = is_array($_POST['user_group_list']) ? $_POST['user_group_list'] : array() ; |
|
50 | - $urlList = is_array($_POST['url_list']) ? $_POST['url_list'] : array() ; |
|
49 | + $userGroups = is_array($_POST['user_group_list']) ? $_POST['user_group_list'] : array(); |
|
50 | + $urlList = is_array($_POST['url_list']) ? $_POST['url_list'] : array(); |
|
51 | 51 | $firstLetterUserGroup = $_POST['first_letter_user_group']; |
52 | 52 | |
53 | 53 | if ($form_sent == 1) { |
@@ -99,7 +99,10 @@ discard block |
||
99 | 99 | <td width="40%" align="center"> |
100 | 100 | <select name="user_group_list[]" multiple="multiple" size="20" style="width:400px;"> |
101 | 101 | <?php foreach ($dbUserGroups as $item) { ?> |
102 | - <option value="<?php echo $item['id']; ?>" <?php if (in_array($item['id'], $courses)) echo 'selected="selected"'; ?>><?php echo $item['name']; ?> |
|
102 | + <option value="<?php echo $item['id']; ?>" <?php if (in_array($item['id'], $courses)) { |
|
103 | + echo 'selected="selected"'; |
|
104 | +} |
|
105 | +?>><?php echo $item['name']; ?> |
|
103 | 106 | </option> |
104 | 107 | <?php } ?> |
105 | 108 | </select> |
@@ -110,7 +113,10 @@ discard block |
||
110 | 113 | <td width="40%" align="center"> |
111 | 114 | <select name="url_list[]" multiple="multiple" size="20" style="width:300px;"> |
112 | 115 | <?php foreach ($db_urls as $url_obj) { ?> |
113 | - <option value="<?php echo $url_obj['id']; ?>" <?php if (in_array($url_obj['id'], $url_list)) echo 'selected="selected"'; ?>><?php echo $url_obj['url']; ?> |
|
116 | + <option value="<?php echo $url_obj['id']; ?>" <?php if (in_array($url_obj['id'], $url_list)) { |
|
117 | + echo 'selected="selected"'; |
|
118 | +} |
|
119 | +?>><?php echo $url_obj['url']; ?> |
|
114 | 120 | </option> |
115 | 121 | <?php } ?> |
116 | 122 | </select> |
@@ -90,26 +90,26 @@ |
||
90 | 90 | { |
91 | 91 | $baseDir = api_get_path(SYS_ARCHIVE_PATH); |
92 | 92 | $uploadPath = 'pdfimport/'; |
93 | - $errors = array (); |
|
93 | + $errors = array(); |
|
94 | 94 | if (!is_dir($baseDir.$uploadPath)) { |
95 | 95 | @mkdir($baseDir.$uploadPath); |
96 | 96 | } |
97 | - if (!unzip_uploaded_file($_FILES['import_file'], $uploadPath, $baseDir, 1024*1024*1024)) { |
|
97 | + if (!unzip_uploaded_file($_FILES['import_file'], $uploadPath, $baseDir, 1024 * 1024 * 1024)) { |
|
98 | 98 | error_log('Could not unzip uploaded file in '.__FILE__.', line '.__LINE__); |
99 | 99 | return $errors; |
100 | 100 | } |
101 | 101 | $list = scandir($baseDir.$uploadPath); |
102 | 102 | $i = 0; |
103 | 103 | foreach ($list as $file) { |
104 | - if (substr($file,0,1) == '.' or !is_file($baseDir.$uploadPath.$file)) { |
|
104 | + if (substr($file, 0, 1) == '.' or !is_file($baseDir.$uploadPath.$file)) { |
|
105 | 105 | continue; |
106 | 106 | } |
107 | - $parts = preg_split('/_/',$file); |
|
107 | + $parts = preg_split('/_/', $file); |
|
108 | 108 | $course = api_get_course_info($parts[0]); |
109 | 109 | if (count($course) > 0) { |
110 | 110 | // Build file info because handle_uploaded_document() needs it (name, type, size, tmp_name) |
111 | 111 | $fileSize = filesize($baseDir.$uploadPath.$file); |
112 | - $docId = add_document($course, $subDir.'/'.$file, 'file', $fileSize, $parts[1].' '.substr($parts[2],0,-4)); |
|
112 | + $docId = add_document($course, $subDir.'/'.$file, 'file', $fileSize, $parts[1].' '.substr($parts[2], 0, -4)); |
|
113 | 113 | if ($docId > 0) { |
114 | 114 | if (!is_file($baseDir.$uploadPath.$file)) { |
115 | 115 | error_log($baseDir.$uploadPath.$file.' does not exists in '.__FILE__); |
@@ -229,31 +229,31 @@ discard block |
||
229 | 229 | <td align="center"> |
230 | 230 | <div id="content_source"> |
231 | 231 | <?php |
232 | - if (!($add_type=='multiple')) { |
|
232 | + if (!($add_type=='multiple')) { |
|
233 | 233 | ?> |
234 | 234 | <input type="text" id="user_to_add" onkeyup="xajax_search_users(this.value,'single')" /> |
235 | 235 | <div id="ajax_list_users_single"></div> |
236 | 236 | <?php |
237 | - } else { |
|
238 | - ?> |
|
237 | + } else { |
|
238 | + ?> |
|
239 | 239 | <div id="ajax_list_multiple"> |
240 | 240 | <?php echo Display::select('elements_not_in_name', $elements_not_in, '', array('style'=>'width:360px', 'multiple'=>'multiple','id'=>'elements_not_in','size'=>'15px'),false); ?> |
241 | 241 | </div> |
242 | 242 | <?php |
243 | - } |
|
244 | - ?> |
|
243 | + } |
|
244 | + ?> |
|
245 | 245 | </div> |
246 | 246 | </td> |
247 | 247 | <td width="10%" valign="middle" align="center"> |
248 | 248 | <?php |
249 | - if ($ajax_search) { |
|
250 | - ?> |
|
249 | + if ($ajax_search) { |
|
250 | + ?> |
|
251 | 251 | <button class="btn bt-default" type="button" onclick="remove_item(document.getElementById('elements_in'))" > |
252 | 252 | <em class="fa fa-arrow-left"></em> |
253 | 253 | </button> |
254 | 254 | <?php |
255 | - } else { |
|
256 | - ?> |
|
255 | + } else { |
|
256 | + ?> |
|
257 | 257 | <button class="btn btn-default" type="button" onclick="moveItem(document.getElementById('elements_not_in'), document.getElementById('elements_in'))" onclick="moveItem(document.getElementById('elements_not_in'), document.getElementById('elements_in'))"> |
258 | 258 | <em class="fa fa-arrow-right"></em> |
259 | 259 | </button> |
@@ -262,8 +262,8 @@ discard block |
||
262 | 262 | <em class="fa fa-arrow-left"></em> |
263 | 263 | </button> |
264 | 264 | <?php |
265 | - } |
|
266 | - ?> |
|
265 | + } |
|
266 | + ?> |
|
267 | 267 | <br /><br /><br /><br /><br /><br /> |
268 | 268 | </td> |
269 | 269 | <td align="center"> |
@@ -192,7 +192,10 @@ |
||
192 | 192 | |
193 | 193 | ?> |
194 | 194 | |
195 | -<form name="formulaire" method="post" action="<?php echo api_get_self(); ?>?id=<?php echo $id; if(!empty($_GET['add'])) echo '&add=true' ; ?>" style="margin:0px;" <?php if($ajax_search){echo ' onsubmit="valide();"';}?>> |
|
195 | +<form name="formulaire" method="post" action="<?php echo api_get_self(); ?>?id=<?php echo $id; if(!empty($_GET['add'])) { |
|
196 | + echo '&add=true' ; |
|
197 | +} |
|
198 | +?>" style="margin:0px;" <?php if($ajax_search){echo ' onsubmit="valide();"';}?>> |
|
196 | 199 | |
197 | 200 | <?php echo '<legend>'.$data['name'].': '.$tool_name.'</legend>'; |
198 | 201 | echo Display::input('hidden', 'id', $id); |
@@ -19,14 +19,14 @@ discard block |
||
19 | 19 | api_protect_admin_script(true); |
20 | 20 | |
21 | 21 | // Setting breadcrumbs. |
22 | -$interbreadcrumb[] = array('url' => 'index.php','name' => get_lang('PlatformAdmin')); |
|
23 | -$interbreadcrumb[] = array('url' => 'usergroups.php','name' => get_lang('Classes')); |
|
22 | +$interbreadcrumb[] = array('url' => 'index.php', 'name' => get_lang('PlatformAdmin')); |
|
23 | +$interbreadcrumb[] = array('url' => 'usergroups.php', 'name' => get_lang('Classes')); |
|
24 | 24 | |
25 | 25 | // Setting the name of the tool. |
26 | 26 | $tool_name = get_lang('SubscribeClassToCourses'); |
27 | 27 | |
28 | 28 | $add_type = 'multiple'; |
29 | -if (isset($_REQUEST['add_type']) && $_REQUEST['add_type']!=''){ |
|
29 | +if (isset($_REQUEST['add_type']) && $_REQUEST['add_type'] != '') { |
|
30 | 30 | $add_type = Security::remove_XSS($_REQUEST['add_type']); |
31 | 31 | } |
32 | 32 | |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | |
98 | 98 | $searchForm = new FormValidator('search', 'get', api_get_self().'?id='.$id); |
99 | 99 | $searchForm->addHeader(get_lang('AdvancedSearch')); |
100 | -$renderer =& $searchForm->defaultRenderer(); |
|
100 | +$renderer = & $searchForm->defaultRenderer(); |
|
101 | 101 | $searchForm->addElement('hidden', 'id', $id); |
102 | 102 | foreach ($filters as $param) { |
103 | 103 | $searchForm->addElement($param['type'], $param['name'], $param['label']); |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | |
142 | 142 | //checking for extra field with filter on |
143 | 143 | |
144 | -function search($needle,$type) |
|
144 | +function search($needle, $type) |
|
145 | 145 | { |
146 | 146 | global $elements_in; |
147 | 147 | $xajax_response = new xajaxResponse(); |
@@ -180,7 +180,7 @@ discard block |
||
180 | 180 | } |
181 | 181 | |
182 | 182 | echo '<div class="actions">'; |
183 | -echo '<a href="usergroups.php">'.Display::return_icon('back.png',get_lang('Back'), array(), ICON_SIZE_MEDIUM).'</a>'; |
|
183 | +echo '<a href="usergroups.php">'.Display::return_icon('back.png', get_lang('Back'), array(), ICON_SIZE_MEDIUM).'</a>'; |
|
184 | 184 | echo Display::url(get_lang('AdvancedSearch'), '#', array('class' => 'advanced_options', 'id' => 'advanced_search')); |
185 | 185 | echo '</div>'; |
186 | 186 | |
@@ -190,7 +190,7 @@ discard block |
||
190 | 190 | |
191 | 191 | ?> |
192 | 192 | |
193 | -<form name="formulaire" method="post" action="<?php echo api_get_self(); ?>?id=<?php echo $id; if(!empty($_GET['add'])) echo '&add=true' ; ?>" style="margin:0px;" <?php if($ajax_search){echo ' onsubmit="valide();"';}?>> |
|
193 | +<form name="formulaire" method="post" action="<?php echo api_get_self(); ?>?id=<?php echo $id; if (!empty($_GET['add'])) echo '&add=true'; ?>" style="margin:0px;" <?php if ($ajax_search) {echo ' onsubmit="valide();"'; }?>> |
|
194 | 194 | |
195 | 195 | <?php echo '<legend>'.$data['name'].': '.$tool_name.'</legend>'; |
196 | 196 | echo Display::input('hidden', 'id', $id); |
@@ -209,7 +209,7 @@ discard block |
||
209 | 209 | <td align="center"><b><?php echo get_lang('CoursesInGroup') ?> :</b></td> |
210 | 210 | </tr> |
211 | 211 | |
212 | -<?php if ($add_type=='multiple') { ?> |
|
212 | +<?php if ($add_type == 'multiple') { ?> |
|
213 | 213 | <tr> |
214 | 214 | <td align="center"> |
215 | 215 | <?php echo get_lang('FirstLetterCourseTitle'); ?> : |
@@ -227,7 +227,7 @@ discard block |
||
227 | 227 | <td align="center"> |
228 | 228 | <div id="content_source"> |
229 | 229 | <?php |
230 | - if (!($add_type=='multiple')) { |
|
230 | + if (!($add_type == 'multiple')) { |
|
231 | 231 | ?> |
232 | 232 | <input type="text" id="user_to_add" onkeyup="xajax_search_users(this.value,'single')" /> |
233 | 233 | <div id="ajax_list_users_single"></div> |
@@ -235,7 +235,7 @@ discard block |
||
235 | 235 | } else { |
236 | 236 | ?> |
237 | 237 | <div id="ajax_list_multiple"> |
238 | - <?php echo Display::select('elements_not_in_name', $elements_not_in, '', array('style'=>'width:360px', 'multiple'=>'multiple','id'=>'elements_not_in','size'=>'15px'),false); ?> |
|
238 | + <?php echo Display::select('elements_not_in_name', $elements_not_in, '', array('style'=>'width:360px', 'multiple'=>'multiple', 'id'=>'elements_not_in', 'size'=>'15px'), false); ?> |
|
239 | 239 | </div> |
240 | 240 | <?php |
241 | 241 | } |
@@ -266,7 +266,7 @@ discard block |
||
266 | 266 | </td> |
267 | 267 | <td align="center"> |
268 | 268 | <?php |
269 | - echo Display::select('elements_in_name[]', $elements_in, '', array('style'=>'width:360px', 'multiple'=>'multiple','id'=>'elements_in','size'=>'15px'),false ); |
|
269 | + echo Display::select('elements_in_name[]', $elements_in, '', array('style'=>'width:360px', 'multiple'=>'multiple', 'id'=>'elements_in', 'size'=>'15px'), false); |
|
270 | 270 | unset($sessionUsersList); |
271 | 271 | ?> |
272 | 272 | </td> |