@@ -80,7 +80,7 @@ |
||
80 | 80 | |
81 | 81 | /** |
82 | 82 | * Validates the received active connection data with the database |
83 | - * @return bool Return the loginFailed variable value to local.inc.php |
|
83 | + * @return null|false Return the loginFailed variable value to local.inc.php |
|
84 | 84 | */ |
85 | 85 | public function check_user() |
86 | 86 | { |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | */ |
35 | 35 | public function __construct() |
36 | 36 | { |
37 | - $this->protocol = api_get_setting('sso_authentication_protocol'); |
|
37 | + $this->protocol = api_get_setting('sso_authentication_protocol'); |
|
38 | 38 | // There can be multiple domains, so make sure to take only the first |
39 | 39 | // This might be later extended with a decision process |
40 | 40 | $domains = explode(',', api_get_setting('sso_authentication_domain')); |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | $this->auth_uri = api_get_setting('sso_authentication_auth_uri'); |
43 | 43 | $this->deauth_uri = api_get_setting('sso_authentication_unauth_uri'); |
44 | 44 | //cut the string to avoid recursive URL construction in case of failure |
45 | - $this->referer = $this->protocol.$_SERVER['HTTP_HOST'].substr($_SERVER['REQUEST_URI'],0,strpos($_SERVER['REQUEST_URI'],'sso')); |
|
45 | + $this->referer = $this->protocol.$_SERVER['HTTP_HOST'].substr($_SERVER['REQUEST_URI'], 0, strpos($_SERVER['REQUEST_URI'], 'sso')); |
|
46 | 46 | $this->deauth_url = $this->protocol.$this->domain.$this->deauth_uri; |
47 | 47 | $this->master_url = $this->protocol.$this->domain.$this->auth_uri; |
48 | 48 | $this->referrer_uri = base64_encode($_SERVER['REQUEST_URI']); |
@@ -130,11 +130,11 @@ discard block |
||
130 | 130 | ) { |
131 | 131 | //error_log('user n password are ok'); |
132 | 132 | //Check if the account is active (not locked) |
133 | - if ($uData['active']=='1') { |
|
133 | + if ($uData['active'] == '1') { |
|
134 | 134 | // check if the expiration date has not been reached |
135 | 135 | if (empty($uData['expiration_date']) |
136 | 136 | or $uData['expiration_date'] > date('Y-m-d H:i:s') |
137 | - or $uData['expiration_date']=='0000-00-00 00:00:00') { |
|
137 | + or $uData['expiration_date'] == '0000-00-00 00:00:00') { |
|
138 | 138 | |
139 | 139 | //If Multiple URL is enabled |
140 | 140 | if (api_get_multiple_access_url()) { |
@@ -168,11 +168,11 @@ discard block |
||
168 | 168 | // the user credentials are OK, which |
169 | 169 | // should be protection enough |
170 | 170 | // against evil URL spoofing... |
171 | - $sso_target = api_get_path(WEB_PATH) . base64_decode($sso['ruri']); |
|
171 | + $sso_target = api_get_path(WEB_PATH).base64_decode($sso['ruri']); |
|
172 | 172 | } else { |
173 | - $sso_target = isset($sso['target']) ? $sso['target'] : api_get_path(WEB_PATH) . 'index.php'; |
|
173 | + $sso_target = isset($sso['target']) ? $sso['target'] : api_get_path(WEB_PATH).'index.php'; |
|
174 | 174 | } |
175 | - header('Location: '. $sso_target); |
|
175 | + header('Location: '.$sso_target); |
|
176 | 176 | exit; |
177 | 177 | } else { |
178 | 178 | // user does not have permission for this site |
@@ -286,9 +286,9 @@ discard block |
||
286 | 286 | $userId = intval($userId); |
287 | 287 | |
288 | 288 | if ($asAdmin && api_is_platform_admin(true)) { |
289 | - return api_get_path(WEB_CODE_PATH) . "admin/user_edit.php?user_id=$userId"; |
|
289 | + return api_get_path(WEB_CODE_PATH)."admin/user_edit.php?user_id=$userId"; |
|
290 | 290 | } |
291 | 291 | |
292 | - return api_get_path(WEB_CODE_PATH) . 'auth/profile.php'; |
|
292 | + return api_get_path(WEB_CODE_PATH).'auth/profile.php'; |
|
293 | 293 | } |
294 | 294 | } |
@@ -47,6 +47,9 @@ |
||
47 | 47 | |
48 | 48 | /* FUNCTIONS */ |
49 | 49 | |
50 | +/** |
|
51 | + * @param string $name |
|
52 | + */ |
|
50 | 53 | function make_select_session_list($name, $sessions, $attr = array()) |
51 | 54 | { |
52 | 55 | $attributes = ''; |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | |
86 | 86 | function display_form() |
87 | 87 | { |
88 | - $html = ''; |
|
88 | + $html = ''; |
|
89 | 89 | $sessions = SessionManager::get_sessions_list(array(), array('name', 'ASC')); |
90 | 90 | |
91 | 91 | // Link back to the documents overview |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | |
110 | 110 | //destination |
111 | 111 | $html .= '<div class="form-group">'; |
112 | - $html .= '<label class="col-sm-2 control-label">' . get_lang('DestinationCoursesFromSession') . ': </label>'; |
|
112 | + $html .= '<label class="col-sm-2 control-label">'.get_lang('DestinationCoursesFromSession').': </label>'; |
|
113 | 113 | $html .= '<div class="col-sm-5" id="ajax_sessions_list_destination">'; |
114 | 114 | $html .= '<select class="form-control" name="sessions_list_destination" onchange="javascript: xajax_search_courses(this.value,\'destination\');">'; |
115 | 115 | $html .= '<option value = "0">'.get_lang('ThereIsNotStillASession').'</option></select ></div>'; |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | $html .= '<button class="btn btn-success" type="submit" onclick="javascript:if(!confirm('."'".addslashes(api_htmlentities(get_lang('ConfirmYourChoice'), ENT_QUOTES))."'".')) return false;"><em class="fa fa-files-o"></em> '.get_lang('CopyCourse').'</button>'; |
132 | 132 | |
133 | 133 | // Add Security token |
134 | - $html .= '<input type="hidden" value="' . Security::get_token() . '" name="sec_token">'; |
|
134 | + $html .= '<input type="hidden" value="'.Security::get_token().'" name="sec_token">'; |
|
135 | 135 | $html .= '</div></div>'; |
136 | 136 | $html .= '</form>'; |
137 | 137 | |
@@ -227,7 +227,7 @@ discard block |
||
227 | 227 | |
228 | 228 | /* HTML head extra */ |
229 | 229 | |
230 | -$htmlHeadXtra[] = $xajax->getJavascript( api_get_path(WEB_LIBRARY_PATH).'xajax/'); |
|
230 | +$htmlHeadXtra[] = $xajax->getJavascript(api_get_path(WEB_LIBRARY_PATH).'xajax/'); |
|
231 | 231 | $htmlHeadXtra[] = '<script> |
232 | 232 | function checkSelected(id_select,id_radio,id_title,id_destination) { |
233 | 233 | var num=0; |
@@ -327,7 +327,7 @@ |
||
327 | 327 | * @param array $arr1 first array |
328 | 328 | * @param array $arr2 second array |
329 | 329 | * |
330 | - * @return array difference between the two arrays |
|
330 | + * @return string difference between the two arrays |
|
331 | 331 | */ |
332 | 332 | function diff($arr1, $arr2) |
333 | 333 | { |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | |
52 | 52 | // A student should not be able to download a root shared directory |
53 | 53 | if (($path == '/shared_folder' || |
54 | - $path == '/shared_folder_session_' . api_get_session_id()) && |
|
54 | + $path == '/shared_folder_session_'.api_get_session_id()) && |
|
55 | 55 | (!api_is_allowed_to_edit() || !api_is_platform_admin()) |
56 | 56 | ) { |
57 | 57 | api_not_allowed(true); |
@@ -149,7 +149,7 @@ discard block |
||
149 | 149 | (props.session_id IN ('0', '$sessionId') OR props.session_id IS NULL) AND |
150 | 150 | docs.c_id = ".$courseId." "; |
151 | 151 | |
152 | - $sql.= DocumentManager::getSessionFolderFilters($querypath, $sessionId); |
|
152 | + $sql .= DocumentManager::getSessionFolderFilters($querypath, $sessionId); |
|
153 | 153 | |
154 | 154 | $result = Database::query($sql); |
155 | 155 | |
@@ -214,7 +214,7 @@ discard block |
||
214 | 214 | $groupCondition |
215 | 215 | "; |
216 | 216 | |
217 | - $sql.= DocumentManager::getSessionFolderFilters($querypath, $sessionId); |
|
217 | + $sql .= DocumentManager::getSessionFolderFilters($querypath, $sessionId); |
|
218 | 218 | $result = Database::query($sql); |
219 | 219 | |
220 | 220 | $files = array(); |
@@ -294,9 +294,9 @@ discard block |
||
294 | 294 | // Add all files in our final array to the zipfile |
295 | 295 | for ($i = 0; $i < count($files_for_zipfile); $i++) { |
296 | 296 | $zip->add( |
297 | - $sysCoursePath . $courseInfo['path'] . '/document' . $files_for_zipfile[$i], |
|
297 | + $sysCoursePath.$courseInfo['path'].'/document'.$files_for_zipfile[$i], |
|
298 | 298 | PCLZIP_OPT_REMOVE_PATH, |
299 | - $sysCoursePath . $courseInfo['path'] . '/document' . $remove_dir, |
|
299 | + $sysCoursePath.$courseInfo['path'].'/document'.$remove_dir, |
|
300 | 300 | PCLZIP_CB_PRE_ADD, |
301 | 301 | 'fixDocumentNameCallback' |
302 | 302 | ); |
@@ -95,7 +95,7 @@ |
||
95 | 95 | |
96 | 96 | /** |
97 | 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) |
|
98 | + * @param integer $stud_id student id (default: all students who have results - then the average is returned) |
|
99 | 99 | * @return array (score, max) if student is given |
100 | 100 | * array (sum of scores, number of scores) otherwise |
101 | 101 | * or null if no scores available |
@@ -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 | } |
@@ -43,9 +43,9 @@ discard block |
||
43 | 43 | |
44 | 44 | $result = Database::query($sql); |
45 | 45 | |
46 | - $cats=array(); |
|
47 | - while ($data=Database::fetch_array($result)) { |
|
48 | - $cats[] = array ($data['id'], $data['name']); |
|
46 | + $cats = array(); |
|
47 | + while ($data = Database::fetch_array($result)) { |
|
48 | + $cats[] = array($data['id'], $data['name']); |
|
49 | 49 | } |
50 | 50 | |
51 | 51 | return $cats; |
@@ -72,8 +72,8 @@ discard block |
||
72 | 72 | $result = Database::query($sql); |
73 | 73 | |
74 | 74 | $cats = array(); |
75 | - while ($data=Database::fetch_array($result)) { |
|
76 | - $cats[] = array ($data['id'], $data['name']); |
|
75 | + while ($data = Database::fetch_array($result)) { |
|
76 | + $cats[] = array($data['id'], $data['name']); |
|
77 | 77 | } |
78 | 78 | |
79 | 79 | return $cats; |
@@ -89,7 +89,7 @@ discard block |
||
89 | 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 | 91 | $result = Database::query($sql); |
92 | - $number = Database::fetch_array($result,'NUM'); |
|
92 | + $number = Database::fetch_array($result, 'NUM'); |
|
93 | 93 | return ($number[0] != 0); |
94 | 94 | } |
95 | 95 | |
@@ -121,12 +121,12 @@ discard block |
||
121 | 121 | // for 1 student |
122 | 122 | if (isset($stud_id)) { |
123 | 123 | if ($data = Database::fetch_assoc($scores)) { |
124 | - return array ($data['progress'], 100); |
|
124 | + return array($data['progress'], 100); |
|
125 | 125 | } else |
126 | 126 | return null; |
127 | 127 | } else { |
128 | 128 | // all students -> get average |
129 | - $students = array(); // user list, needed to make sure we only |
|
129 | + $students = array(); // user list, needed to make sure we only |
|
130 | 130 | // take first attempts into account |
131 | 131 | $rescount = 0; |
132 | 132 | $sum = 0; |
@@ -154,7 +154,7 @@ discard block |
||
154 | 154 | return array($bestResult, 100); |
155 | 155 | break; |
156 | 156 | case 'average': |
157 | - return array($sumResult/$rescount, 100); |
|
157 | + return array($sumResult / $rescount, 100); |
|
158 | 158 | break; |
159 | 159 | case 'ranking': |
160 | 160 | return AbstractLink::getCurrentUserRanking($stud_id, $students); |
@@ -173,7 +173,7 @@ discard block |
||
173 | 173 | public function get_link() |
174 | 174 | { |
175 | 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'; |
|
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 | 177 | |
178 | 178 | if (!api_is_allowed_to_edit() || $this->calc_score(api_get_user_id()) == null) { |
179 | 179 | $url .= '&action=view&lp_id='.$this->get_ref_id(); |
@@ -208,7 +208,7 @@ discard block |
||
208 | 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 | 210 | $result = Database::query($sql); |
211 | - $number = Database::fetch_row($result,'NUM'); |
|
211 | + $number = Database::fetch_row($result, 'NUM'); |
|
212 | 212 | return ($number[0] != 0); |
213 | 213 | } |
214 | 214 |
@@ -29,8 +29,9 @@ discard block |
||
29 | 29 | public function get_not_created_links() |
30 | 30 | { |
31 | 31 | return false; |
32 | - if (empty($this->course_code)) |
|
33 | - die('Error in get_not_created_links() : course code not set'); |
|
32 | + if (empty($this->course_code)) { |
|
33 | + die('Error in get_not_created_links() : course code not set'); |
|
34 | + } |
|
34 | 35 | |
35 | 36 | $tbl_grade_links = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_LINK); |
36 | 37 | |
@@ -57,8 +58,9 @@ discard block |
||
57 | 58 | */ |
58 | 59 | public function get_all_links() |
59 | 60 | { |
60 | - if (empty($this->course_code)) |
|
61 | - die('Error in get_not_created_links() : course code not set'); |
|
61 | + if (empty($this->course_code)) { |
|
62 | + die('Error in get_not_created_links() : course code not set'); |
|
63 | + } |
|
62 | 64 | |
63 | 65 | $session_id = api_get_session_id(); |
64 | 66 | if (empty($session_id)) { |
@@ -111,8 +113,9 @@ discard block |
||
111 | 113 | lp_id = ".$this->get_ref_id()." AND |
112 | 114 | session_id = $session_id "; |
113 | 115 | |
114 | - if (isset($stud_id)) |
|
115 | - $sql .= ' AND user_id = '.intval($stud_id); |
|
116 | + if (isset($stud_id)) { |
|
117 | + $sql .= ' AND user_id = '.intval($stud_id); |
|
118 | + } |
|
116 | 119 | |
117 | 120 | // order by id, that way the student's first attempt is accessed first |
118 | 121 | $sql .= ' ORDER BY view_count DESC'; |
@@ -122,8 +125,9 @@ discard block |
||
122 | 125 | if (isset($stud_id)) { |
123 | 126 | if ($data = Database::fetch_assoc($scores)) { |
124 | 127 | return array ($data['progress'], 100); |
125 | - } else |
|
126 | - return null; |
|
128 | + } else { |
|
129 | + return null; |
|
130 | + } |
|
127 | 131 | } else { |
128 | 132 | // all students -> get average |
129 | 133 | $students = array(); // user list, needed to make sure we only |
@@ -32,6 +32,8 @@ discard block |
||
32 | 32 | * @param array $evals |
33 | 33 | * @param array $links |
34 | 34 | * @param null $addparams |
35 | + * @param boolean $showTeacherView |
|
36 | + * @param integer $userId |
|
35 | 37 | */ |
36 | 38 | public function __construct( |
37 | 39 | $currentcat, |
@@ -895,7 +897,7 @@ discard block |
||
895 | 897 | |
896 | 898 | /** |
897 | 899 | * @param $item |
898 | - * @return mixed |
|
900 | + * @return string|null |
|
899 | 901 | */ |
900 | 902 | private function build_course_code($item) |
901 | 903 | { |
@@ -256,10 +256,11 @@ |
||
256 | 256 | } |
257 | 257 | |
258 | 258 | // Categories. |
259 | - if (!empty($data_array)) |
|
260 | - foreach ($data_array as $data) { |
|
259 | + if (!empty($data_array)) { |
|
260 | + foreach ($data_array as $data) { |
|
261 | 261 | // list of items inside the gradebook (exercises, lps, forums, etc) |
262 | 262 | $row = array(); |
263 | + } |
|
263 | 264 | /** @var AbstractLink $item */ |
264 | 265 | $item = $mainCategory = $data[0]; |
265 | 266 |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | $this->set_additional_parameters($addparams); |
72 | 72 | } |
73 | 73 | |
74 | - $column= 0; |
|
74 | + $column = 0; |
|
75 | 75 | if ($this->teacherView) { |
76 | 76 | if ($this->exportToPdf == false) { |
77 | 77 | $this->set_header($column++, '', '', 'width="25px"'); |
@@ -281,13 +281,13 @@ discard block |
||
281 | 281 | $main_categories[$item->get_id()]['name'] = $item->get_name(); |
282 | 282 | } else { |
283 | 283 | $name = $this->build_name_link($item, $type); |
284 | - $row[] = $invisibility_span_open.$name. $invisibility_span_close; |
|
284 | + $row[] = $invisibility_span_open.$name.$invisibility_span_close; |
|
285 | 285 | $main_categories[$item->get_id()]['name'] = $name; |
286 | 286 | } |
287 | 287 | |
288 | 288 | $this->dataForGraph['categories'][] = $item->get_name(); |
289 | 289 | |
290 | - $main_categories[$item->get_id()]['weight']= $item->get_weight(); |
|
290 | + $main_categories[$item->get_id()]['weight'] = $item->get_weight(); |
|
291 | 291 | $total_categories_weight += $item->get_weight(); |
292 | 292 | |
293 | 293 | // Description. |
@@ -307,9 +307,9 @@ discard block |
||
307 | 307 | ); |
308 | 308 | |
309 | 309 | if ($this->teacherView) { |
310 | - $row[] = $invisibility_span_open .Display::tag('p', $weight, array('class' => 'score')).$invisibility_span_close; |
|
310 | + $row[] = $invisibility_span_open.Display::tag('p', $weight, array('class' => 'score')).$invisibility_span_close; |
|
311 | 311 | } else { |
312 | - $row[] = $invisibility_span_open .$weight.$invisibility_span_close; |
|
312 | + $row[] = $invisibility_span_open.$weight.$invisibility_span_close; |
|
313 | 313 | } |
314 | 314 | |
315 | 315 | $category_weight = $item->get_weight(); |
@@ -335,7 +335,7 @@ discard block |
||
335 | 335 | |
336 | 336 | if (!empty($score[1])) { |
337 | 337 | $completeScore = $scoredisplay->display_score($score, SCORE_DIV_PERCENT); |
338 | - $score = $score[0]/$score[1]*$item->get_weight(); |
|
338 | + $score = $score[0] / $score[1] * $item->get_weight(); |
|
339 | 339 | $score = $scoredisplay->display_score(array($score, null), SCORE_SIMPLE); |
340 | 340 | $scoreToDisplay = Display::tip($score, $completeScore); |
341 | 341 | } else { |
@@ -453,7 +453,7 @@ discard block |
||
453 | 453 | $row[] = $this->build_type_column($item, array('style' => 'padding-left:5px')); |
454 | 454 | |
455 | 455 | // Name. |
456 | - $row[] = $invisibility_span_open." ".$this->build_name_link($item, $type) . $invisibility_span_close; |
|
456 | + $row[] = $invisibility_span_open." ".$this->build_name_link($item, $type).$invisibility_span_close; |
|
457 | 457 | |
458 | 458 | // Description. |
459 | 459 | if ($this->exportToPdf == false) { |
@@ -491,7 +491,7 @@ discard block |
||
491 | 491 | // Students get the results and certificates columns |
492 | 492 | $eval_n_links = array_merge($alleval, $alllink); |
493 | 493 | |
494 | - if (count($eval_n_links)> 0) { |
|
494 | + if (count($eval_n_links) > 0) { |
|
495 | 495 | $value_data = isset($data[4]) ? $data[4] : null; |
496 | 496 | if (!is_null($value_data)) { |
497 | 497 | //$score = $item->calc_score(api_get_user_id()); |
@@ -587,7 +587,7 @@ discard block |
||
587 | 587 | $row = array( |
588 | 588 | null, |
589 | 589 | null, |
590 | - '<strong>' . get_lang('Total') . '</strong>', |
|
590 | + '<strong>'.get_lang('Total').'</strong>', |
|
591 | 591 | null, |
592 | 592 | $total |
593 | 593 | ); |
@@ -657,7 +657,7 @@ discard block |
||
657 | 657 | if ($this->exportToPdf) { |
658 | 658 | $row = array( |
659 | 659 | null, |
660 | - '<h3>' . get_lang('Total') . '</h3>', |
|
660 | + '<h3>'.get_lang('Total').'</h3>', |
|
661 | 661 | $main_weight, |
662 | 662 | $totalResult, |
663 | 663 | $totalRanking, |
@@ -667,7 +667,7 @@ discard block |
||
667 | 667 | } else { |
668 | 668 | $row = array( |
669 | 669 | null, |
670 | - '<h3>' . get_lang('Total') . '</h3>', |
|
670 | + '<h3>'.get_lang('Total').'</h3>', |
|
671 | 671 | null, |
672 | 672 | $main_weight, |
673 | 673 | $totalResult, |
@@ -682,7 +682,7 @@ discard block |
||
682 | 682 | } |
683 | 683 | |
684 | 684 | // Warning messages |
685 | - $view = isset($_GET['view']) ? $_GET['view']: null; |
|
685 | + $view = isset($_GET['view']) ? $_GET['view'] : null; |
|
686 | 686 | |
687 | 687 | if ($this->teacherView) { |
688 | 688 | if (isset($_GET['selectcat']) && |
@@ -693,14 +693,14 @@ discard block |
||
693 | 693 | $category = Category::load($id_cat); |
694 | 694 | $weight_category = intval($this->build_weight($category[0])); |
695 | 695 | $course_code = $this->build_course_code($category[0]); |
696 | - $weight_total_links = round($weight_total_links); |
|
696 | + $weight_total_links = round($weight_total_links); |
|
697 | 697 | |
698 | 698 | if ($weight_total_links > $weight_category || |
699 | 699 | $weight_total_links < $weight_category || |
700 | 700 | $weight_total_links > $weight_category |
701 | 701 | ) { |
702 | 702 | $warning_message = sprintf(get_lang('TotalWeightMustBeX'), $weight_category); |
703 | - $modify_icons = '<a href="gradebook_edit_cat.php?editcat='.$id_cat.'&cidReq='.$course_code.'&id_session='.api_get_session_id().'">'. |
|
703 | + $modify_icons = '<a href="gradebook_edit_cat.php?editcat='.$id_cat.'&cidReq='.$course_code.'&id_session='.api_get_session_id().'">'. |
|
704 | 704 | Display::return_icon('edit.png', $warning_message, array(), ICON_SIZE_SMALL).'</a>'; |
705 | 705 | $warning_message .= $modify_icons; |
706 | 706 | Display::display_warning_message($warning_message, false); |
@@ -755,7 +755,7 @@ discard block |
||
755 | 755 | if (empty($certificate_min_score) || |
756 | 756 | ($certificate_min_score > $weight_category) |
757 | 757 | ) { |
758 | - $warning_message .= $course_code .' - '.get_lang('CertificateMinimunScoreIsRequiredAndMustNotBeMoreThan').' '.$weight_category.'<br />'; |
|
758 | + $warning_message .= $course_code.' - '.get_lang('CertificateMinimunScoreIsRequiredAndMustNotBeMoreThan').' '.$weight_category.'<br />'; |
|
759 | 759 | } |
760 | 760 | } |
761 | 761 | |
@@ -820,7 +820,7 @@ discard block |
||
820 | 820 | $pChart->setGraphArea(50, 30, $xSize - 50, $ySize - 70); |
821 | 821 | $pChart->setFontProperties( |
822 | 822 | array( |
823 | - 'FontName' => api_get_path(SYS_FONTS_PATH) . 'opensans/OpenSans-Regular.ttf', |
|
823 | + 'FontName' => api_get_path(SYS_FONTS_PATH).'opensans/OpenSans-Regular.ttf', |
|
824 | 824 | 'FontSize' => 10, |
825 | 825 | ) |
826 | 826 | ); |
@@ -869,13 +869,13 @@ discard block |
||
869 | 869 | $chartHash = $myCache->getHash($dataSet); |
870 | 870 | |
871 | 871 | $myCache->writeToCache($chartHash, $pChart); |
872 | - $imgSysPath = api_get_path(SYS_ARCHIVE_PATH) . $chartHash; |
|
872 | + $imgSysPath = api_get_path(SYS_ARCHIVE_PATH).$chartHash; |
|
873 | 873 | $myCache->saveFromCache($chartHash, $imgSysPath); |
874 | - $imgWebPath = api_get_path(WEB_ARCHIVE_PATH) . $chartHash; |
|
874 | + $imgWebPath = api_get_path(WEB_ARCHIVE_PATH).$chartHash; |
|
875 | 875 | |
876 | 876 | if (file_exists($imgSysPath)) { |
877 | 877 | $result = '<div id="contentArea" style="text-align: center;" >'; |
878 | - $result .= '<img src="' . $imgWebPath.'" >'; |
|
878 | + $result .= '<img src="'.$imgWebPath.'" >'; |
|
879 | 879 | $result .= '</div>'; |
880 | 880 | return $result; |
881 | 881 | } |
@@ -920,13 +920,13 @@ discard block |
||
920 | 920 | switch ($item->get_item_type()) { |
921 | 921 | // category |
922 | 922 | case 'C': |
923 | - return 'CATE' . $item->get_id(); |
|
923 | + return 'CATE'.$item->get_id(); |
|
924 | 924 | // evaluation |
925 | 925 | case 'E': |
926 | - return 'EVAL' . $item->get_id(); |
|
926 | + return 'EVAL'.$item->get_id(); |
|
927 | 927 | // link |
928 | 928 | case 'L': |
929 | - return 'LINK' . $item->get_id(); |
|
929 | + return 'LINK'.$item->get_id(); |
|
930 | 930 | } |
931 | 931 | } |
932 | 932 | |
@@ -954,10 +954,10 @@ discard block |
||
954 | 954 | switch ($item->get_item_type()) { |
955 | 955 | // category |
956 | 956 | case 'C': |
957 | - $prms_uri='?selectcat=' . $item->get_id() . '&view='.$view; |
|
957 | + $prms_uri = '?selectcat='.$item->get_id().'&view='.$view; |
|
958 | 958 | if (isset($_GET['isStudentView'])) { |
959 | - if ( isset($is_student) || (isset($_SESSION['studentview']) && $_SESSION['studentview']=='studentview') ) { |
|
960 | - $prms_uri=$prms_uri.'&isStudentView='.Security::remove_XSS($_GET['isStudentView']); |
|
959 | + if (isset($is_student) || (isset($_SESSION['studentview']) && $_SESSION['studentview'] == 'studentview')) { |
|
960 | + $prms_uri = $prms_uri.'&isStudentView='.Security::remove_XSS($_GET['isStudentView']); |
|
961 | 961 | } |
962 | 962 | } |
963 | 963 | |
@@ -966,7 +966,7 @@ discard block |
||
966 | 966 | return ' <a href="'.Security::remove_XSS($_SESSION['gradebook_dest']).$prms_uri.'">' |
967 | 967 | . $item->get_name() |
968 | 968 | . '</a>' |
969 | - . ($item->is_course() ? ' [' . $item->get_course_code() . ']'.$show_message : ''); |
|
969 | + . ($item->is_course() ? ' ['.$item->get_course_code().']'.$show_message : ''); |
|
970 | 970 | // evaluation |
971 | 971 | case 'E': |
972 | 972 | $cat = new Category(); |
@@ -974,10 +974,10 @@ discard block |
||
974 | 974 | $show_message = $cat->show_message_resource_delete($course_id); |
975 | 975 | |
976 | 976 | // course/platform admin can go to the view_results page |
977 | - if (api_is_allowed_to_edit() && $show_message===false) { |
|
977 | + if (api_is_allowed_to_edit() && $show_message === false) { |
|
978 | 978 | if ($item->get_type() == 'presence') { |
979 | 979 | return ' ' |
980 | - . '<a href="gradebook_view_result.php?cidReq='.$course_id.'&selecteval=' . $item->get_id() . '">' |
|
980 | + . '<a href="gradebook_view_result.php?cidReq='.$course_id.'&selecteval='.$item->get_id().'">' |
|
981 | 981 | . $item->get_name() |
982 | 982 | . '</a>'; |
983 | 983 | } else { |
@@ -986,20 +986,20 @@ discard block |
||
986 | 986 | $extra = ''; |
987 | 987 | } |
988 | 988 | return ' ' |
989 | - . '<a href="gradebook_view_result.php?' . api_get_cidreq() . '&selecteval=' . $item->get_id() . '">' |
|
989 | + . '<a href="gradebook_view_result.php?'.api_get_cidreq().'&selecteval='.$item->get_id().'">' |
|
990 | 990 | . $item->get_name() |
991 | 991 | . '</a> '.$extra; |
992 | 992 | } |
993 | - } elseif (ScoreDisplay :: instance()->is_custom() && $show_message===false) { |
|
993 | + } elseif (ScoreDisplay :: instance()->is_custom() && $show_message === false) { |
|
994 | 994 | // students can go to the statistics page (if custom display enabled) |
995 | 995 | return ' ' |
996 | - . '<a href="gradebook_statistics.php?' . api_get_cidreq() . '&selecteval=' . $item->get_id() . '">' |
|
996 | + . '<a href="gradebook_statistics.php?'.api_get_cidreq().'&selecteval='.$item->get_id().'">' |
|
997 | 997 | . $item->get_name() |
998 | 998 | . '</a>'; |
999 | 999 | |
1000 | 1000 | } elseif ($show_message === false && !api_is_allowed_to_edit() && !ScoreDisplay :: instance()->is_custom()) { |
1001 | 1001 | return ' ' |
1002 | - . '<a href="gradebook_statistics.php?' . api_get_cidreq() . '&selecteval=' . $item->get_id() . '">' |
|
1002 | + . '<a href="gradebook_statistics.php?'.api_get_cidreq().'&selecteval='.$item->get_id().'">' |
|
1003 | 1003 | . $item->get_name() |
1004 | 1004 | . '</a>'; |
1005 | 1005 | } else { |
@@ -1014,7 +1014,7 @@ discard block |
||
1014 | 1014 | $url = $item->get_link(); |
1015 | 1015 | |
1016 | 1016 | if (isset($url) && $show_message === false) { |
1017 | - $text = ' <a href="' . $item->get_link() . '">' |
|
1017 | + $text = ' <a href="'.$item->get_link().'">' |
|
1018 | 1018 | . $item->get_name() |
1019 | 1019 | . '</a>'; |
1020 | 1020 | } else { |
@@ -9,7 +9,6 @@ |
||
9 | 9 | { |
10 | 10 | /** |
11 | 11 | * @param $value array Uploaded file info (from $_FILES) |
12 | - * @param null $options |
|
13 | 12 | * @return bool |
14 | 13 | */ |
15 | 14 | public function validate($elementValue, $maxSize) |
@@ -7,22 +7,22 @@ |
||
7 | 7 | */ |
8 | 8 | class HTML_QuickForm_Rule_MaxFileSize extends HTML_QuickForm_Rule |
9 | 9 | { |
10 | - /** |
|
11 | - * @param $value array Uploaded file info (from $_FILES) |
|
12 | - * @param null $options |
|
13 | - * @return bool |
|
14 | - */ |
|
15 | - public function validate($elementValue, $maxSize) |
|
16 | - { |
|
17 | - if (!empty($elementValue['error']) && |
|
18 | - (UPLOAD_ERR_FORM_SIZE == $elementValue['error'] || UPLOAD_ERR_INI_SIZE == $elementValue['error']) |
|
19 | - ) { |
|
20 | - return false; |
|
21 | - } |
|
22 | - if (!HTML_QuickForm_file::_ruleIsUploadedFile($elementValue)) { |
|
23 | - return true; |
|
24 | - } |
|
10 | + /** |
|
11 | + * @param $value array Uploaded file info (from $_FILES) |
|
12 | + * @param null $options |
|
13 | + * @return bool |
|
14 | + */ |
|
15 | + public function validate($elementValue, $maxSize) |
|
16 | + { |
|
17 | + if (!empty($elementValue['error']) && |
|
18 | + (UPLOAD_ERR_FORM_SIZE == $elementValue['error'] || UPLOAD_ERR_INI_SIZE == $elementValue['error']) |
|
19 | + ) { |
|
20 | + return false; |
|
21 | + } |
|
22 | + if (!HTML_QuickForm_file::_ruleIsUploadedFile($elementValue)) { |
|
23 | + return true; |
|
24 | + } |
|
25 | 25 | |
26 | - return ($maxSize >= @filesize($elementValue['tmp_name'])); |
|
27 | - } |
|
26 | + return ($maxSize >= @filesize($elementValue['tmp_name'])); |
|
27 | + } |
|
28 | 28 | } |
@@ -16,7 +16,7 @@ |
||
16 | 16 | * |
17 | 17 | * @param string Mobile phone number to be validated |
18 | 18 | * @param string Not using it. Just to respect the declaration |
19 | - * @return boolean Returns true if valid, false otherwise. |
|
19 | + * @return integer Returns true if valid, false otherwise. |
|
20 | 20 | */ |
21 | 21 | function validate($mobilePhoneNumber, $options = null) |
22 | 22 | { |
@@ -138,7 +138,7 @@ |
||
138 | 138 | |
139 | 139 | /** |
140 | 140 | * Return a list an associative array where keys are the active hook observer class name |
141 | - * @param $eventName |
|
141 | + * @param string $eventName |
|
142 | 142 | * |
143 | 143 | * @return array |
144 | 144 | */ |
@@ -145,10 +145,10 @@ discard block |
||
145 | 145 | public function listHookObservers($eventName) |
146 | 146 | { |
147 | 147 | $array = array(); |
148 | - $joinTable = $this->tables[TABLE_HOOK_CALL] . ' hc' . |
|
149 | - ' INNER JOIN ' . $this->tables[TABLE_HOOK_EVENT] . ' he' . |
|
150 | - ' ON hc.hook_event_id = he.id ' . |
|
151 | - ' INNER JOIN ' . $this->tables[TABLE_HOOK_OBSERVER] . ' ho ' . |
|
148 | + $joinTable = $this->tables[TABLE_HOOK_CALL].' hc'. |
|
149 | + ' INNER JOIN '.$this->tables[TABLE_HOOK_EVENT].' he'. |
|
150 | + ' ON hc.hook_event_id = he.id '. |
|
151 | + ' INNER JOIN '.$this->tables[TABLE_HOOK_OBSERVER].' ho '. |
|
152 | 152 | ' ON hc.hook_observer_id = ho.id '; |
153 | 153 | $columns = 'ho.class_name, ho.path, ho.plugin_name, hc.enabled'; |
154 | 154 | $where = array('where' => array('he.class_name = ? ' => $eventName, 'AND hc.enabled = ? ' => 1)); |
@@ -202,10 +202,10 @@ discard block |
||
202 | 202 | public function listAllHookCalls() |
203 | 203 | { |
204 | 204 | $array = array(); |
205 | - $joinTable = $this->tables[TABLE_HOOK_CALL] . ' hc' . |
|
206 | - ' INNER JOIN ' . $this->tables[TABLE_HOOK_EVENT] . ' he' . |
|
207 | - ' ON hc.hook_event_id = he.id ' . |
|
208 | - ' INNER JOIN ' . $this->tables[TABLE_HOOK_OBSERVER] . ' ho ' . |
|
205 | + $joinTable = $this->tables[TABLE_HOOK_CALL].' hc'. |
|
206 | + ' INNER JOIN '.$this->tables[TABLE_HOOK_EVENT].' he'. |
|
207 | + ' ON hc.hook_event_id = he.id '. |
|
208 | + ' INNER JOIN '.$this->tables[TABLE_HOOK_OBSERVER].' ho '. |
|
209 | 209 | ' ON hc.hook_observer_id = ho.id '; |
210 | 210 | $columns = 'he.class_name AS event_class_name, ho.class_name AS observer_class_name, hc.id AS id, hc.type AS type'; |
211 | 211 | $rows = Database::select($columns, $joinTable); |
@@ -231,7 +231,7 @@ discard block |
||
231 | 231 | if (isset($eventName) && !isset($this->hookEvents[$eventName])) { |
232 | 232 | $attributes = array( |
233 | 233 | 'class_name' => $eventName, |
234 | - 'description' => get_lang('HookDescription' . $eventName), |
|
234 | + 'description' => get_lang('HookDescription'.$eventName), |
|
235 | 235 | ); |
236 | 236 | $id = Database::insert($this->tables[TABLE_HOOK_EVENT], $attributes); |
237 | 237 | $this->hookEvents[$eventName] = $id; |
@@ -240,7 +240,7 @@ discard block |
||
240 | 240 | // Check if exists hook observer |
241 | 241 | if (isset($observerClassName) && |
242 | 242 | !isset($this->hookObservers[$observerClassName]) |
243 | - ){ |
|
243 | + ) { |
|
244 | 244 | $object = $observerClassName::create(); |
245 | 245 | $attributes = array( |
246 | 246 | 'class_name' => $observerClassName, |
@@ -338,10 +338,10 @@ discard block |
||
338 | 338 | $eventName = Database::escape_string($eventName); |
339 | 339 | $observerClassName($observerClassName); |
340 | 340 | $type = Database::escape_string($type); |
341 | - $joinTable = $this->tables[TABLE_HOOK_CALL] . ' hc' . |
|
342 | - ' INNER JOIN ' . $this->tables[TABLE_HOOK_EVENT] . ' he' . |
|
343 | - ' ON hc.hook_event_id = he.id ' . |
|
344 | - ' INNER JOIN ' . $this->tables[TABLE_HOOK_OBSERVER] . ' ho ' . |
|
341 | + $joinTable = $this->tables[TABLE_HOOK_CALL].' hc'. |
|
342 | + ' INNER JOIN '.$this->tables[TABLE_HOOK_EVENT].' he'. |
|
343 | + ' ON hc.hook_event_id = he.id '. |
|
344 | + ' INNER JOIN '.$this->tables[TABLE_HOOK_OBSERVER].' ho '. |
|
345 | 345 | ' ON hc.hook_observer_id = ho.id '; |
346 | 346 | $row = Database::select( |
347 | 347 | 'id', |
@@ -266,6 +266,7 @@ discard block |
||
266 | 266 | * @global bool $is_platformAdmin |
267 | 267 | * @global bool $is_allowedCreateCourse |
268 | 268 | * @global object $_user |
269 | + * @param boolean $reset |
|
269 | 270 | */ |
270 | 271 | public static function init_user($user_id, $reset) |
271 | 272 | { |
@@ -355,7 +356,7 @@ discard block |
||
355 | 356 | * @global type $is_allowed_in_course |
356 | 357 | * |
357 | 358 | * @param type $course_id |
358 | - * @param type $reset |
|
359 | + * @param boolean $reset |
|
359 | 360 | */ |
360 | 361 | static function init_course($course_id, $reset) |
361 | 362 | { |
@@ -852,14 +852,14 @@ discard block |
||
852 | 852 | $email = false; |
853 | 853 | } |
854 | 854 | |
855 | - if ($email) { |
|
856 | - $condition = "LOWER(email) = '".Database::escape_string($username)."' "; |
|
857 | - } else { |
|
855 | + if ($email) { |
|
856 | + $condition = "LOWER(email) = '".Database::escape_string($username)."' "; |
|
857 | + } else { |
|
858 | 858 | $condition = "LOWER(username) = '".Database::escape_string($username)."'"; |
859 | 859 | } |
860 | 860 | |
861 | - $tbl_user = Database :: get_main_table(TABLE_MAIN_USER); |
|
862 | - $query = "SELECT |
|
861 | + $tbl_user = Database :: get_main_table(TABLE_MAIN_USER); |
|
862 | + $query = "SELECT |
|
863 | 863 | user_id AS uid, |
864 | 864 | lastname AS lastName, |
865 | 865 | firstname AS firstName, |
@@ -874,7 +874,7 @@ discard block |
||
874 | 874 | auth_source |
875 | 875 | FROM $tbl_user |
876 | 876 | WHERE ( $condition AND active = 1) "; |
877 | - $result = Database::query($query); |
|
877 | + $result = Database::query($query); |
|
878 | 878 | $num_rows = Database::num_rows($result); |
879 | 879 | if ($result && $num_rows > 0) { |
880 | 880 | return Database::fetch_assoc($result); |
@@ -36,24 +36,24 @@ discard block |
||
36 | 36 | if ($by_username) { |
37 | 37 | $secret_word = self::get_secret_word($user['email']); |
38 | 38 | if ($reset) { |
39 | - $reset_link = $portal_url . "main/auth/lostPassword.php?reset=" . $secret_word . "&id=" . $user['uid']; |
|
39 | + $reset_link = $portal_url."main/auth/lostPassword.php?reset=".$secret_word."&id=".$user['uid']; |
|
40 | 40 | } else { |
41 | - $reset_link = get_lang('Pass') . " : $user[password]"; |
|
41 | + $reset_link = get_lang('Pass')." : $user[password]"; |
|
42 | 42 | } |
43 | - $user_account_list = get_lang('YourRegistrationData') . " : \n" . get_lang('UserName') . ' : ' . $user['loginName'] . "\n" . get_lang('ResetLink') . ' : ' . $reset_link . ''; |
|
43 | + $user_account_list = get_lang('YourRegistrationData')." : \n".get_lang('UserName').' : '.$user['loginName']."\n".get_lang('ResetLink').' : '.$reset_link.''; |
|
44 | 44 | |
45 | 45 | if ($user_account_list) { |
46 | - $user_account_list = "\n-----------------------------------------------\n" . $user_account_list; |
|
46 | + $user_account_list = "\n-----------------------------------------------\n".$user_account_list; |
|
47 | 47 | } |
48 | 48 | } else { |
49 | 49 | foreach ($user as $this_user) { |
50 | 50 | $secret_word = self::get_secret_word($this_user['email']); |
51 | 51 | if ($reset) { |
52 | - $reset_link = $portal_url . "main/auth/lostPassword.php?reset=" . $secret_word . "&id=" . $this_user['uid']; |
|
52 | + $reset_link = $portal_url."main/auth/lostPassword.php?reset=".$secret_word."&id=".$this_user['uid']; |
|
53 | 53 | } else { |
54 | - $reset_link = get_lang('Pass') . " : $this_user[password]"; |
|
54 | + $reset_link = get_lang('Pass')." : $this_user[password]"; |
|
55 | 55 | } |
56 | - $user_account_list[] = get_lang('YourRegistrationData') . " : \n" . get_lang('UserName') . ' : ' . $this_user['loginName'] . "\n" . get_lang('ResetLink') . ' : ' . $reset_link . ''; |
|
56 | + $user_account_list[] = get_lang('YourRegistrationData')." : \n".get_lang('UserName').' : '.$this_user['loginName']."\n".get_lang('ResetLink').' : '.$reset_link.''; |
|
57 | 57 | } |
58 | 58 | if ($user_account_list) { |
59 | 59 | $user_account_list = implode("\n-----------------------------------------------\n", $user_account_list); |
@@ -63,8 +63,8 @@ discard block |
||
63 | 63 | if (!$by_username) { |
64 | 64 | $user = $user[0]; |
65 | 65 | } |
66 | - $reset_link = get_lang('Pass') . " : $user[password]"; |
|
67 | - $user_account_list = get_lang('YourRegistrationData') . " : \n" . get_lang('UserName') . ' : ' . $user['loginName'] . "\n" . $reset_link . ''; |
|
66 | + $reset_link = get_lang('Pass')." : $user[password]"; |
|
67 | + $user_account_list = get_lang('YourRegistrationData')." : \n".get_lang('UserName').' : '.$user['loginName']."\n".$reset_link.''; |
|
68 | 68 | } |
69 | 69 | return $user_account_list; |
70 | 70 | } |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | */ |
78 | 78 | public static function send_password_to_user($user, $by_username = false) |
79 | 79 | { |
80 | - $email_subject = "[" . api_get_setting('siteName') . "] " . get_lang('LoginRequest'); // SUBJECT |
|
80 | + $email_subject = "[".api_get_setting('siteName')."] ".get_lang('LoginRequest'); // SUBJECT |
|
81 | 81 | |
82 | 82 | if ($by_username) { // Show only for lost password |
83 | 83 | $user_account_list = self::get_user_account_list($user, false, $by_username); // BODY |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | } |
97 | 97 | } |
98 | 98 | |
99 | - $email_body = get_lang('YourAccountParam') . " " . $portal_url . "\n\n$user_account_list"; |
|
99 | + $email_body = get_lang('YourAccountParam')." ".$portal_url."\n\n$user_account_list"; |
|
100 | 100 | // SEND MESSAGE |
101 | 101 | $sender_name = api_get_person_name( |
102 | 102 | api_get_setting('administratorName'), |
@@ -135,7 +135,7 @@ discard block |
||
135 | 135 | */ |
136 | 136 | public static function handle_encrypted_password($user, $by_username = false) |
137 | 137 | { |
138 | - $email_subject = "[" . api_get_setting('siteName') . "] " . get_lang('LoginRequest'); // SUBJECT |
|
138 | + $email_subject = "[".api_get_setting('siteName')."] ".get_lang('LoginRequest'); // SUBJECT |
|
139 | 139 | |
140 | 140 | if ($by_username) { |
141 | 141 | // Show only for lost password |
@@ -145,11 +145,11 @@ discard block |
||
145 | 145 | $user_account_list = self::get_user_account_list($user, true); // BODY |
146 | 146 | $email_to = $user[0]['email']; |
147 | 147 | } |
148 | - $email_body = get_lang('DearUser') . " :\n" . get_lang('password_request') . "\n"; |
|
149 | - $email_body .= $user_account_list . "\n-----------------------------------------------\n\n"; |
|
148 | + $email_body = get_lang('DearUser')." :\n".get_lang('password_request')."\n"; |
|
149 | + $email_body .= $user_account_list."\n-----------------------------------------------\n\n"; |
|
150 | 150 | $email_body .= get_lang('PasswordEncryptedForSecurity'); |
151 | 151 | |
152 | - $email_body .= "\n\n" . get_lang('SignatureFormula') . ",\n" . api_get_setting('administratorName') . " " . api_get_setting('administratorSurname') . "\n" . get_lang('PlataformAdmin') . " - " . api_get_setting('siteName'); |
|
152 | + $email_body .= "\n\n".get_lang('SignatureFormula').",\n".api_get_setting('administratorName')." ".api_get_setting('administratorSurname')."\n".get_lang('PlataformAdmin')." - ".api_get_setting('siteName'); |
|
153 | 153 | |
154 | 154 | $sender_name = api_get_person_name( |
155 | 155 | api_get_setting('administratorName'), |
@@ -243,7 +243,7 @@ discard block |
||
243 | 243 | password, |
244 | 244 | email, |
245 | 245 | auth_source |
246 | - FROM " . $tbl_user . " |
|
246 | + FROM " . $tbl_user." |
|
247 | 247 | WHERE user_id = $id"; |
248 | 248 | $result = Database::query($sql); |
249 | 249 | $num_rows = Database::num_rows($result); |
@@ -301,7 +301,7 @@ discard block |
||
301 | 301 | ON user.user_id = a.user_id |
302 | 302 | LEFT JOIN $track_e_login login |
303 | 303 | ON user.user_id = login.login_user_id |
304 | - WHERE user.user_id = '" . $_user['user_id'] . "' |
|
304 | + WHERE user.user_id = '".$_user['user_id']."' |
|
305 | 305 | ORDER BY login.login_date DESC LIMIT 1"; |
306 | 306 | |
307 | 307 | $result = Database::query($sql); |
@@ -331,7 +331,7 @@ discard block |
||
331 | 331 | Session::write('is_platformAdmin', $is_platformAdmin); |
332 | 332 | Session::write('is_allowedCreateCourse', $is_allowedCreateCourse); |
333 | 333 | } else { |
334 | - header('location:' . api_get_path(WEB_PATH)); |
|
334 | + header('location:'.api_get_path(WEB_PATH)); |
|
335 | 335 | //exit("WARNING UNDEFINED UID !! "); |
336 | 336 | } |
337 | 337 | } else { // no uid => logout or Anonymous |
@@ -377,9 +377,9 @@ discard block |
||
377 | 377 | global $_course; |
378 | 378 | global $_real_cid; |
379 | 379 | |
380 | - global $is_courseAdmin; //course teacher |
|
381 | - global $is_courseTutor; //course teacher - some rights |
|
382 | - global $is_courseCoach; //course coach |
|
380 | + global $is_courseAdmin; //course teacher |
|
381 | + global $is_courseTutor; //course teacher - some rights |
|
382 | + global $is_courseCoach; //course coach |
|
383 | 383 | global $is_courseMember; //course student |
384 | 384 | global $is_sessionAdmin; |
385 | 385 | global $is_allowed_in_course; |
@@ -436,7 +436,7 @@ discard block |
||
436 | 436 | |
437 | 437 | if (!empty($_GET['id_session'])) { |
438 | 438 | $_SESSION['id_session'] = intval($_GET['id_session']); |
439 | - $sql = 'SELECT name FROM ' . $tbl_session . ' WHERE id="' . intval($_SESSION['id_session']) . '"'; |
|
439 | + $sql = 'SELECT name FROM '.$tbl_session.' WHERE id="'.intval($_SESSION['id_session']).'"'; |
|
440 | 440 | $rs = Database::query($sql); |
441 | 441 | list($_SESSION['session_name']) = Database::fetch_array($rs); |
442 | 442 | } else { |
@@ -452,7 +452,7 @@ discard block |
||
452 | 452 | } |
453 | 453 | } else { |
454 | 454 | //exit("WARNING UNDEFINED CID !! "); |
455 | - header('location:' . api_get_path(WEB_PATH)); |
|
455 | + header('location:'.api_get_path(WEB_PATH)); |
|
456 | 456 | } |
457 | 457 | } else { |
458 | 458 | Session::erase('_cid'); |
@@ -479,7 +479,7 @@ discard block |
||
479 | 479 | } else { |
480 | 480 | // Continue with the previous values |
481 | 481 | if (empty($_SESSION['_course']) OR empty($_SESSION['_cid'])) { //no previous values... |
482 | - $_cid = -1; //set default values that will be caracteristic of being unset |
|
482 | + $_cid = -1; //set default values that will be caracteristic of being unset |
|
483 | 483 | $_course = -1; |
484 | 484 | } else { |
485 | 485 | $_cid = $_SESSION['_cid']; |
@@ -489,7 +489,7 @@ discard block |
||
489 | 489 | // Moreover, if we want to track a course with another session it can be usefull |
490 | 490 | if (!empty($_GET['id_session'])) { |
491 | 491 | $tbl_session = Database::get_main_table(TABLE_MAIN_SESSION); |
492 | - $sql = 'SELECT name FROM ' . $tbl_session . ' WHERE id="' . intval($_SESSION['id_session']) . '"'; |
|
492 | + $sql = 'SELECT name FROM '.$tbl_session.' WHERE id="'.intval($_SESSION['id_session']).'"'; |
|
493 | 493 | $rs = Database::query($sql); |
494 | 494 | list($_SESSION['session_name']) = Database::fetch_array($rs); |
495 | 495 | $_SESSION['id_session'] = intval($_GET['id_session']); |
@@ -528,9 +528,9 @@ discard block |
||
528 | 528 | //But only if the login date is < than now + max_life_time |
529 | 529 | $sql = "SELECT course_access_id FROM $course_tracking_table |
530 | 530 | WHERE |
531 | - user_id = " . intval($_user ['user_id']) . " AND |
|
531 | + user_id = ".intval($_user ['user_id'])." AND |
|
532 | 532 | c_id = '".api_get_course_int_id()."' AND |
533 | - session_id = " . api_get_session_id() . " AND |
|
533 | + session_id = " . api_get_session_id()." AND |
|
534 | 534 | login_course_date > now() - INTERVAL $session_lifetime SECOND |
535 | 535 | ORDER BY login_course_date DESC LIMIT 0,1"; |
536 | 536 | $result = Database::query($sql); |
@@ -540,11 +540,11 @@ discard block |
||
540 | 540 | //We update the course tracking table |
541 | 541 | $sql = "UPDATE $course_tracking_table |
542 | 542 | SET logout_course_date = '$time', counter = counter+1 |
543 | - WHERE course_access_id = " . intval($i_course_access_id) . " AND session_id = " . api_get_session_id(); |
|
543 | + WHERE course_access_id = ".intval($i_course_access_id)." AND session_id = ".api_get_session_id(); |
|
544 | 544 | Database::query($sql); |
545 | 545 | } else { |
546 | - $sql = "INSERT INTO $course_tracking_table (c_id, user_id, login_course_date, logout_course_date, counter, session_id)" . |
|
547 | - "VALUES('" . api_get_course_int_id() . "', '" . $_user['user_id'] . "', '$time', '$time', '1','" . api_get_session_id() . "')"; |
|
546 | + $sql = "INSERT INTO $course_tracking_table (c_id, user_id, login_course_date, logout_course_date, counter, session_id)". |
|
547 | + "VALUES('".api_get_course_int_id()."', '".$_user['user_id']."', '$time', '$time', '1','".api_get_session_id()."')"; |
|
548 | 548 | Database::query($sql); |
549 | 549 | } |
550 | 550 | } |
@@ -571,8 +571,8 @@ discard block |
||
571 | 571 | $course_user_table = Database::get_main_table(TABLE_MAIN_COURSE_USER); |
572 | 572 | $sql = "SELECT * FROM $course_user_table |
573 | 573 | WHERE |
574 | - user_id = '" . $user_id . "' AND |
|
575 | - relation_type <> " . COURSE_RELATION_TYPE_RRHH . " AND |
|
574 | + user_id = '".$user_id."' AND |
|
575 | + relation_type <> " . COURSE_RELATION_TYPE_RRHH." AND |
|
576 | 576 | c_id = '".$_real_cid."'"; |
577 | 577 | $result = Database::query($sql); |
578 | 578 | |
@@ -593,8 +593,8 @@ discard block |
||
593 | 593 | ); |
594 | 594 | |
595 | 595 | if (!$user_is_subscribed) { |
596 | - $url = api_get_path(WEB_CODE_PATH) . 'course_info/legal.php?course_code=' . $_course['code'] . '&session_id=' . $session_id; |
|
597 | - header('Location: ' . $url); |
|
596 | + $url = api_get_path(WEB_CODE_PATH).'course_info/legal.php?course_code='.$_course['code'].'&session_id='.$session_id; |
|
597 | + header('Location: '.$url); |
|
598 | 598 | exit; |
599 | 599 | } |
600 | 600 | } |
@@ -635,11 +635,11 @@ discard block |
||
635 | 635 | } else { |
636 | 636 | //Im a coach or a student? |
637 | 637 | $sql = "SELECT user_id, status |
638 | - FROM " . $tbl_session_course_user . " |
|
638 | + FROM " . $tbl_session_course_user." |
|
639 | 639 | WHERE |
640 | 640 | c_id = '$_cid' AND |
641 | - user_id = '" . $user_id . "' AND |
|
642 | - session_id = '" . $session_id . "' |
|
641 | + user_id = '".$user_id."' AND |
|
642 | + session_id = '" . $session_id."' |
|
643 | 643 | LIMIT 1"; |
644 | 644 | $result = Database::query($sql); |
645 | 645 | |
@@ -784,7 +784,7 @@ discard block |
||
784 | 784 | if ($reset) { // session data refresh requested |
785 | 785 | if ($group_id && $_cid && !empty($_course['real_id'])) { // have keys to search data |
786 | 786 | $group_table = Database::get_course_table(TABLE_GROUP); |
787 | - $sql = "SELECT * FROM $group_table WHERE c_id = " . $_course['real_id'] . " AND id = '$group_id'"; |
|
787 | + $sql = "SELECT * FROM $group_table WHERE c_id = ".$_course['real_id']." AND id = '$group_id'"; |
|
788 | 788 | $result = Database::query($sql); |
789 | 789 | if (Database::num_rows($result) > 0) { // This group has recorded status related to this course |
790 | 790 | $gpData = Database::fetch_array($result); |
@@ -837,7 +837,7 @@ discard block |
||
837 | 837 | */ |
838 | 838 | public static function get_user_accounts_by_username($username) |
839 | 839 | { |
840 | - if (strpos($username,'@')){ |
|
840 | + if (strpos($username, '@')) { |
|
841 | 841 | $username = api_strtolower($username); |
842 | 842 | $email = true; |
843 | 843 | } else { |