@@ -8,48 +8,48 @@ discard block |
||
| 8 | 8 | */ |
| 9 | 9 | class AttendanceLink extends AbstractLink |
| 10 | 10 | { |
| 11 | - private $attendance_table = null; |
|
| 12 | - private $itemprop_table = null; |
|
| 11 | + private $attendance_table = null; |
|
| 12 | + private $itemprop_table = null; |
|
| 13 | 13 | |
| 14 | - /** |
|
| 15 | - * Constructor |
|
| 16 | - */ |
|
| 17 | - public function __construct() |
|
| 18 | - { |
|
| 19 | - parent::__construct(); |
|
| 20 | - $this->set_type(LINK_ATTENDANCE); |
|
| 21 | - } |
|
| 14 | + /** |
|
| 15 | + * Constructor |
|
| 16 | + */ |
|
| 17 | + public function __construct() |
|
| 18 | + { |
|
| 19 | + parent::__construct(); |
|
| 20 | + $this->set_type(LINK_ATTENDANCE); |
|
| 21 | + } |
|
| 22 | 22 | |
| 23 | - /** |
|
| 24 | - * @return string |
|
| 25 | - */ |
|
| 26 | - public function get_type_name() |
|
| 27 | - { |
|
| 28 | - return get_lang('Attendance'); |
|
| 29 | - } |
|
| 23 | + /** |
|
| 24 | + * @return string |
|
| 25 | + */ |
|
| 26 | + public function get_type_name() |
|
| 27 | + { |
|
| 28 | + return get_lang('Attendance'); |
|
| 29 | + } |
|
| 30 | 30 | |
| 31 | - /** |
|
| 32 | - * @return bool |
|
| 33 | - */ |
|
| 34 | - public function is_allowed_to_change_name() |
|
| 35 | - { |
|
| 36 | - return false; |
|
| 37 | - } |
|
| 31 | + /** |
|
| 32 | + * @return bool |
|
| 33 | + */ |
|
| 34 | + public function is_allowed_to_change_name() |
|
| 35 | + { |
|
| 36 | + return false; |
|
| 37 | + } |
|
| 38 | 38 | |
| 39 | - /** |
|
| 40 | - * Generate an array of attendances that a teacher hasn't created a link for. |
|
| 41 | - * @return array 2-dimensional array - every element contains 2 subelements (id, name) |
|
| 42 | - * @todo seems to be depracated |
|
| 43 | - */ |
|
| 44 | - public function get_not_created_links() |
|
| 45 | - { |
|
| 46 | - return false; |
|
| 47 | - if (empty($this->course_code)) { |
|
| 48 | - die('Error in get_not_created_links() : course code not set'); |
|
| 49 | - } |
|
| 50 | - $tbl_grade_links = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_LINK); |
|
| 39 | + /** |
|
| 40 | + * Generate an array of attendances that a teacher hasn't created a link for. |
|
| 41 | + * @return array 2-dimensional array - every element contains 2 subelements (id, name) |
|
| 42 | + * @todo seems to be depracated |
|
| 43 | + */ |
|
| 44 | + public function get_not_created_links() |
|
| 45 | + { |
|
| 46 | + return false; |
|
| 47 | + if (empty($this->course_code)) { |
|
| 48 | + die('Error in get_not_created_links() : course code not set'); |
|
| 49 | + } |
|
| 50 | + $tbl_grade_links = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_LINK); |
|
| 51 | 51 | |
| 52 | - $sql = 'SELECT att.id, att.name, att.attendance_qualify_title |
|
| 52 | + $sql = 'SELECT att.id, att.name, att.attendance_qualify_title |
|
| 53 | 53 | FROM '.$this->get_attendance_table().' att |
| 54 | 54 | WHERE |
| 55 | 55 | att.c_id = '.$this->course_id.' AND |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | course_code = "'.Database::escape_string($this->get_course_code()).'" |
| 61 | 61 | ) |
| 62 | 62 | AND att.session_id='.api_get_session_id().''; |
| 63 | - $result = Database::query($sql); |
|
| 63 | + $result = Database::query($sql); |
|
| 64 | 64 | |
| 65 | 65 | $cats = array(); |
| 66 | 66 | while ($data = Database::fetch_array($result)) { |
@@ -71,13 +71,13 @@ discard block |
||
| 71 | 71 | } |
| 72 | 72 | } |
| 73 | 73 | |
| 74 | - return $cats; |
|
| 75 | - } |
|
| 74 | + return $cats; |
|
| 75 | + } |
|
| 76 | 76 | |
| 77 | - /** |
|
| 78 | - * Generate an array of all attendances available. |
|
| 79 | - * @return array 2-dimensional array - every element contains 2 subelements (id, name) |
|
| 80 | - */ |
|
| 77 | + /** |
|
| 78 | + * Generate an array of all attendances available. |
|
| 79 | + * @return array 2-dimensional array - every element contains 2 subelements (id, name) |
|
| 80 | + */ |
|
| 81 | 81 | public function get_all_links() |
| 82 | 82 | { |
| 83 | 83 | if (empty($this->course_code)) { |
@@ -104,55 +104,55 @@ discard block |
||
| 104 | 104 | $my_cats = isset($cats) ? $cats : null; |
| 105 | 105 | |
| 106 | 106 | return $my_cats; |
| 107 | - } |
|
| 107 | + } |
|
| 108 | 108 | |
| 109 | - /** |
|
| 110 | - * Has anyone done this exercise yet ? |
|
| 111 | - */ |
|
| 112 | - public function has_results() |
|
| 113 | - { |
|
| 114 | - $tbl_attendance_result = Database :: get_course_table(TABLE_ATTENDANCE_RESULT); |
|
| 115 | - $session_id = api_get_session_id(); |
|
| 116 | - $sql = 'SELECT count(*) AS number FROM '.$tbl_attendance_result." |
|
| 109 | + /** |
|
| 110 | + * Has anyone done this exercise yet ? |
|
| 111 | + */ |
|
| 112 | + public function has_results() |
|
| 113 | + { |
|
| 114 | + $tbl_attendance_result = Database :: get_course_table(TABLE_ATTENDANCE_RESULT); |
|
| 115 | + $session_id = api_get_session_id(); |
|
| 116 | + $sql = 'SELECT count(*) AS number FROM '.$tbl_attendance_result." |
|
| 117 | 117 | WHERE |
| 118 | 118 | session_id = $session_id AND |
| 119 | 119 | c_id = '.$this->course_id.' AND |
| 120 | 120 | attendance_id = '".intval($this->get_ref_id())."'"; |
| 121 | - $result = Database::query($sql); |
|
| 122 | - $number = Database::fetch_row($result); |
|
| 121 | + $result = Database::query($sql); |
|
| 122 | + $number = Database::fetch_row($result); |
|
| 123 | 123 | |
| 124 | - return $number[0] != 0; |
|
| 125 | - } |
|
| 124 | + return $number[0] != 0; |
|
| 125 | + } |
|
| 126 | 126 | |
| 127 | - /** |
|
| 128 | - * @param int $stud_id |
|
| 129 | - * @return array|null |
|
| 130 | - */ |
|
| 131 | - public function calc_score($stud_id = null, $type = null) |
|
| 132 | - { |
|
| 133 | - $tbl_attendance_result = Database::get_course_table(TABLE_ATTENDANCE_RESULT); |
|
| 134 | - $session_id = api_get_session_id(); |
|
| 127 | + /** |
|
| 128 | + * @param int $stud_id |
|
| 129 | + * @return array|null |
|
| 130 | + */ |
|
| 131 | + public function calc_score($stud_id = null, $type = null) |
|
| 132 | + { |
|
| 133 | + $tbl_attendance_result = Database::get_course_table(TABLE_ATTENDANCE_RESULT); |
|
| 134 | + $session_id = api_get_session_id(); |
|
| 135 | 135 | |
| 136 | - // get attendance qualify max |
|
| 137 | - $sql = 'SELECT att.attendance_qualify_max |
|
| 136 | + // get attendance qualify max |
|
| 137 | + $sql = 'SELECT att.attendance_qualify_max |
|
| 138 | 138 | FROM '.$this->get_attendance_table().' att |
| 139 | 139 | WHERE |
| 140 | 140 | att.c_id = '.$this->course_id.' AND |
| 141 | 141 | att.id = '.intval($this->get_ref_id()).' AND |
| 142 | 142 | att.session_id='.intval($session_id).''; |
| 143 | - $query = Database::query($sql); |
|
| 144 | - $attendance = Database::fetch_array($query, 'ASSOC'); |
|
| 143 | + $query = Database::query($sql); |
|
| 144 | + $attendance = Database::fetch_array($query, 'ASSOC'); |
|
| 145 | 145 | |
| 146 | - // Get results |
|
| 147 | - $sql = 'SELECT * |
|
| 146 | + // Get results |
|
| 147 | + $sql = 'SELECT * |
|
| 148 | 148 | FROM '.$tbl_attendance_result.' |
| 149 | 149 | WHERE c_id = '.$this->course_id.' AND attendance_id = '.intval($this->get_ref_id()); |
| 150 | - if (isset($stud_id)) { |
|
| 151 | - $sql .= ' AND user_id = '.intval($stud_id); |
|
| 152 | - } |
|
| 153 | - $scores = Database::query($sql); |
|
| 154 | - // for 1 student |
|
| 155 | - if (isset($stud_id)) { |
|
| 150 | + if (isset($stud_id)) { |
|
| 151 | + $sql .= ' AND user_id = '.intval($stud_id); |
|
| 152 | + } |
|
| 153 | + $scores = Database::query($sql); |
|
| 154 | + // for 1 student |
|
| 155 | + if (isset($stud_id)) { |
|
| 156 | 156 | if ($data = Database::fetch_array($scores, 'ASSOC')) { |
| 157 | 157 | return array( |
| 158 | 158 | $data['score'], |
@@ -162,7 +162,7 @@ discard block |
||
| 162 | 162 | //We sent the 0/attendance_qualify_max instead of null for correct calculations |
| 163 | 163 | return array(0, $attendance['attendance_qualify_max']); |
| 164 | 164 | } |
| 165 | - } else { |
|
| 165 | + } else { |
|
| 166 | 166 | // all students -> get average |
| 167 | 167 | $students = array(); // user list, needed to make sure we only |
| 168 | 168 | // take first attempts into account |
@@ -171,144 +171,144 @@ discard block |
||
| 171 | 171 | $sumResult = 0; |
| 172 | 172 | $bestResult = 0; |
| 173 | 173 | |
| 174 | - while ($data = Database::fetch_array($scores)) { |
|
| 175 | - if (!(array_key_exists($data['user_id'], $students))) { |
|
| 176 | - if ($attendance['attendance_qualify_max'] != 0) { |
|
| 177 | - $students[$data['user_id']] = $data['score']; |
|
| 178 | - $rescount++; |
|
| 179 | - $sum += $data['score'] / $attendance['attendance_qualify_max']; |
|
| 180 | - $sumResult += $data['score']; |
|
| 181 | - if ($data['score'] > $bestResult) { |
|
| 182 | - $bestResult = $data['score']; |
|
| 183 | - } |
|
| 184 | - $weight = $attendance['attendance_qualify_max']; |
|
| 185 | - } |
|
| 186 | - } |
|
| 187 | - } |
|
| 174 | + while ($data = Database::fetch_array($scores)) { |
|
| 175 | + if (!(array_key_exists($data['user_id'], $students))) { |
|
| 176 | + if ($attendance['attendance_qualify_max'] != 0) { |
|
| 177 | + $students[$data['user_id']] = $data['score']; |
|
| 178 | + $rescount++; |
|
| 179 | + $sum += $data['score'] / $attendance['attendance_qualify_max']; |
|
| 180 | + $sumResult += $data['score']; |
|
| 181 | + if ($data['score'] > $bestResult) { |
|
| 182 | + $bestResult = $data['score']; |
|
| 183 | + } |
|
| 184 | + $weight = $attendance['attendance_qualify_max']; |
|
| 185 | + } |
|
| 186 | + } |
|
| 187 | + } |
|
| 188 | 188 | |
| 189 | - if ($rescount == 0) { |
|
| 190 | - return null; |
|
| 191 | - } else { |
|
| 192 | - switch ($type) { |
|
| 193 | - case 'best': |
|
| 194 | - return array($bestResult, $weight); |
|
| 195 | - break; |
|
| 196 | - case 'average': |
|
| 197 | - return array($sumResult / $rescount, $weight); |
|
| 198 | - break; |
|
| 199 | - case 'ranking': |
|
| 200 | - return AbstractLink::getCurrentUserRanking($stud_id, $students); |
|
| 201 | - break; |
|
| 202 | - default: |
|
| 203 | - return array($sum, $rescount); |
|
| 204 | - break; |
|
| 205 | - } |
|
| 206 | - } |
|
| 207 | - } |
|
| 208 | - } |
|
| 189 | + if ($rescount == 0) { |
|
| 190 | + return null; |
|
| 191 | + } else { |
|
| 192 | + switch ($type) { |
|
| 193 | + case 'best': |
|
| 194 | + return array($bestResult, $weight); |
|
| 195 | + break; |
|
| 196 | + case 'average': |
|
| 197 | + return array($sumResult / $rescount, $weight); |
|
| 198 | + break; |
|
| 199 | + case 'ranking': |
|
| 200 | + return AbstractLink::getCurrentUserRanking($stud_id, $students); |
|
| 201 | + break; |
|
| 202 | + default: |
|
| 203 | + return array($sum, $rescount); |
|
| 204 | + break; |
|
| 205 | + } |
|
| 206 | + } |
|
| 207 | + } |
|
| 208 | + } |
|
| 209 | 209 | |
| 210 | - /** |
|
| 211 | - * Lazy load function to get the database table of the student publications |
|
| 212 | - */ |
|
| 213 | - private function get_attendance_table() |
|
| 214 | - { |
|
| 215 | - $this->attendance_table = Database::get_course_table(TABLE_ATTENDANCE); |
|
| 216 | - return $this->attendance_table; |
|
| 217 | - } |
|
| 210 | + /** |
|
| 211 | + * Lazy load function to get the database table of the student publications |
|
| 212 | + */ |
|
| 213 | + private function get_attendance_table() |
|
| 214 | + { |
|
| 215 | + $this->attendance_table = Database::get_course_table(TABLE_ATTENDANCE); |
|
| 216 | + return $this->attendance_table; |
|
| 217 | + } |
|
| 218 | 218 | |
| 219 | - public function needs_name_and_description() |
|
| 220 | - { |
|
| 221 | - return false; |
|
| 222 | - } |
|
| 219 | + public function needs_name_and_description() |
|
| 220 | + { |
|
| 221 | + return false; |
|
| 222 | + } |
|
| 223 | 223 | |
| 224 | - public function needs_max() |
|
| 225 | - { |
|
| 226 | - return false; |
|
| 227 | - } |
|
| 224 | + public function needs_max() |
|
| 225 | + { |
|
| 226 | + return false; |
|
| 227 | + } |
|
| 228 | 228 | |
| 229 | - public function needs_results() |
|
| 230 | - { |
|
| 231 | - return false; |
|
| 232 | - } |
|
| 229 | + public function needs_results() |
|
| 230 | + { |
|
| 231 | + return false; |
|
| 232 | + } |
|
| 233 | 233 | |
| 234 | - /** |
|
| 235 | - * @return string |
|
| 236 | - */ |
|
| 237 | - public function get_name() |
|
| 238 | - { |
|
| 239 | - $this->get_attendance_data(); |
|
| 240 | - $attendance_title = isset($this->attendance_data['name']) ? $this->attendance_data['name'] : ''; |
|
| 241 | - $attendance_qualify_title = isset($this->attendance_data['attendance_qualify_title']) ? $this->attendance_data['attendance_qualify_title'] : ''; |
|
| 242 | - if ( isset($attendance_qualify_title) && $attendance_qualify_title != '') { |
|
| 243 | - return $this->attendance_data['attendance_qualify_title']; |
|
| 244 | - } else { |
|
| 245 | - return $attendance_title; |
|
| 246 | - } |
|
| 247 | - } |
|
| 234 | + /** |
|
| 235 | + * @return string |
|
| 236 | + */ |
|
| 237 | + public function get_name() |
|
| 238 | + { |
|
| 239 | + $this->get_attendance_data(); |
|
| 240 | + $attendance_title = isset($this->attendance_data['name']) ? $this->attendance_data['name'] : ''; |
|
| 241 | + $attendance_qualify_title = isset($this->attendance_data['attendance_qualify_title']) ? $this->attendance_data['attendance_qualify_title'] : ''; |
|
| 242 | + if ( isset($attendance_qualify_title) && $attendance_qualify_title != '') { |
|
| 243 | + return $this->attendance_data['attendance_qualify_title']; |
|
| 244 | + } else { |
|
| 245 | + return $attendance_title; |
|
| 246 | + } |
|
| 247 | + } |
|
| 248 | 248 | |
| 249 | - /** |
|
| 250 | - * @return string |
|
| 251 | - */ |
|
| 252 | - public function get_description() |
|
| 253 | - { |
|
| 254 | - return ''; |
|
| 255 | - } |
|
| 249 | + /** |
|
| 250 | + * @return string |
|
| 251 | + */ |
|
| 252 | + public function get_description() |
|
| 253 | + { |
|
| 254 | + return ''; |
|
| 255 | + } |
|
| 256 | 256 | |
| 257 | - /** |
|
| 258 | - * Check if this still links to an exercise |
|
| 259 | - */ |
|
| 260 | - public function is_valid_link() |
|
| 261 | - { |
|
| 262 | - $session_id = api_get_session_id(); |
|
| 263 | - $sql = 'SELECT count(att.id) FROM '.$this->get_attendance_table().' att |
|
| 257 | + /** |
|
| 258 | + * Check if this still links to an exercise |
|
| 259 | + */ |
|
| 260 | + public function is_valid_link() |
|
| 261 | + { |
|
| 262 | + $session_id = api_get_session_id(); |
|
| 263 | + $sql = 'SELECT count(att.id) FROM '.$this->get_attendance_table().' att |
|
| 264 | 264 | WHERE att.c_id = '.$this->course_id.' AND att.id = '.intval($this->get_ref_id()).' '; |
| 265 | - $result = Database::query($sql); |
|
| 266 | - $number = Database::fetch_row($result); |
|
| 267 | - return ($number[0] != 0); |
|
| 268 | - } |
|
| 265 | + $result = Database::query($sql); |
|
| 266 | + $number = Database::fetch_row($result); |
|
| 267 | + return ($number[0] != 0); |
|
| 268 | + } |
|
| 269 | 269 | |
| 270 | - public function get_test_id() |
|
| 271 | - { |
|
| 272 | - return 'DEBUG:ID'; |
|
| 273 | - } |
|
| 270 | + public function get_test_id() |
|
| 271 | + { |
|
| 272 | + return 'DEBUG:ID'; |
|
| 273 | + } |
|
| 274 | 274 | |
| 275 | - public function get_link() |
|
| 276 | - { |
|
| 277 | - //it was extracts the attendance id |
|
| 278 | - $session_id = api_get_session_id(); |
|
| 279 | - $sql = 'SELECT * FROM '.$this->get_attendance_table().' att |
|
| 275 | + public function get_link() |
|
| 276 | + { |
|
| 277 | + //it was extracts the attendance id |
|
| 278 | + $session_id = api_get_session_id(); |
|
| 279 | + $sql = 'SELECT * FROM '.$this->get_attendance_table().' att |
|
| 280 | 280 | WHERE att.c_id = '.$this->course_id.' AND att.id = '.intval($this->get_ref_id()).' '; |
| 281 | - $result = Database::query($sql); |
|
| 282 | - $row = Database::fetch_array($result,'ASSOC'); |
|
| 283 | - $attendance_id = $row['id']; |
|
| 284 | - $url = api_get_path(WEB_PATH).'main/attendance/index.php?action=attendance_sheet_list&gradebook=view&attendance_id='.$attendance_id.'&'.api_get_cidreq_params($this->get_course_code(), $session_id); |
|
| 281 | + $result = Database::query($sql); |
|
| 282 | + $row = Database::fetch_array($result,'ASSOC'); |
|
| 283 | + $attendance_id = $row['id']; |
|
| 284 | + $url = api_get_path(WEB_PATH).'main/attendance/index.php?action=attendance_sheet_list&gradebook=view&attendance_id='.$attendance_id.'&'.api_get_cidreq_params($this->get_course_code(), $session_id); |
|
| 285 | 285 | |
| 286 | - return $url; |
|
| 287 | - } |
|
| 286 | + return $url; |
|
| 287 | + } |
|
| 288 | 288 | |
| 289 | - /** |
|
| 290 | - * @return array|bool |
|
| 291 | - */ |
|
| 292 | - private function get_attendance_data() |
|
| 293 | - { |
|
| 294 | - $tbl_name = $this->get_attendance_table(); |
|
| 295 | - $session_id = api_get_session_id(); |
|
| 296 | - if ($tbl_name == '') { |
|
| 297 | - return false; |
|
| 298 | - } elseif (!isset($this->attendance_data)) { |
|
| 299 | - $sql = 'SELECT * FROM '.$this->get_attendance_table().' att |
|
| 289 | + /** |
|
| 290 | + * @return array|bool |
|
| 291 | + */ |
|
| 292 | + private function get_attendance_data() |
|
| 293 | + { |
|
| 294 | + $tbl_name = $this->get_attendance_table(); |
|
| 295 | + $session_id = api_get_session_id(); |
|
| 296 | + if ($tbl_name == '') { |
|
| 297 | + return false; |
|
| 298 | + } elseif (!isset($this->attendance_data)) { |
|
| 299 | + $sql = 'SELECT * FROM '.$this->get_attendance_table().' att |
|
| 300 | 300 | WHERE att.c_id = '.$this->course_id.' AND att.id = '.intval($this->get_ref_id()).' '; |
| 301 | - $query = Database::query($sql); |
|
| 302 | - $this->attendance_data = Database::fetch_array($query); |
|
| 303 | - } |
|
| 304 | - return $this->attendance_data; |
|
| 305 | - } |
|
| 301 | + $query = Database::query($sql); |
|
| 302 | + $this->attendance_data = Database::fetch_array($query); |
|
| 303 | + } |
|
| 304 | + return $this->attendance_data; |
|
| 305 | + } |
|
| 306 | 306 | |
| 307 | - /** |
|
| 308 | - * @return string |
|
| 309 | - */ |
|
| 310 | - public function get_icon_name() |
|
| 311 | - { |
|
| 312 | - return 'attendance'; |
|
| 313 | - } |
|
| 307 | + /** |
|
| 308 | + * @return string |
|
| 309 | + */ |
|
| 310 | + public function get_icon_name() |
|
| 311 | + { |
|
| 312 | + return 'attendance'; |
|
| 313 | + } |
|
| 314 | 314 | } |
@@ -3054,7 +3054,7 @@ |
||
| 3054 | 3054 | * @param integer $thread_qualify |
| 3055 | 3055 | * @param integer $qualify_time |
| 3056 | 3056 | * @param integer $session_id |
| 3057 | - * @return array optional |
|
| 3057 | + * @return string|null optional |
|
| 3058 | 3058 | * @author Isaac Flores <[email protected]>, U.N.A.S University |
| 3059 | 3059 | * @version October 2008, dokeos 1.8.6 |
| 3060 | 3060 | */ |
@@ -64,10 +64,10 @@ discard block |
||
| 64 | 64 | var l = $(this); |
| 65 | 65 | var id = l.closest("tr").attr("id"); |
| 66 | 66 | var filename = l.closest("tr").find(".attachFilename").html(); |
| 67 | - if (confirm("' . get_lang('AreYouSureToDeleteJS') . '", filename)) { |
|
| 67 | + if (confirm("' . get_lang('AreYouSureToDeleteJS').'", filename)) { |
|
| 68 | 68 | $.ajax({ |
| 69 | 69 | type: "POST", |
| 70 | - url: "'.api_get_path(WEB_AJAX_PATH) . 'forum.ajax.php?'.api_get_cidreq().'&a=delete_file&attachId=" + id +"&thread='.$threadId .'&forum='.$forumId .'", |
|
| 70 | + url: "'.api_get_path(WEB_AJAX_PATH).'forum.ajax.php?'.api_get_cidreq().'&a=delete_file&attachId=" + id +"&thread='.$threadId.'&forum='.$forumId.'", |
|
| 71 | 71 | dataType: "json", |
| 72 | 72 | success: function(data) { |
| 73 | 73 | if (data.error == false) { |
@@ -180,7 +180,7 @@ discard block |
||
| 180 | 180 | function show_add_forumcategory_form($inputvalues = array(), $lp_id) |
| 181 | 181 | { |
| 182 | 182 | // Initialize the object. |
| 183 | - $form = new FormValidator('forumcategory', 'post', 'index.php?' . api_get_cidreq()); |
|
| 183 | + $form = new FormValidator('forumcategory', 'post', 'index.php?'.api_get_cidreq()); |
|
| 184 | 184 | // hidden field if from learning path |
| 185 | 185 | |
| 186 | 186 | $form->addElement('hidden', 'lp_id', $lp_id); |
@@ -230,7 +230,7 @@ discard block |
||
| 230 | 230 | function show_add_forum_form($inputvalues = array(), $lp_id) |
| 231 | 231 | { |
| 232 | 232 | $_course = api_get_course_info(); |
| 233 | - $form = new FormValidator('forumcategory', 'post', 'index.php?' . api_get_cidreq()); |
|
| 233 | + $form = new FormValidator('forumcategory', 'post', 'index.php?'.api_get_cidreq()); |
|
| 234 | 234 | |
| 235 | 235 | // The header for the form |
| 236 | 236 | if (!empty($inputvalues)) { |
@@ -345,9 +345,9 @@ discard block |
||
| 345 | 345 | // Forum image |
| 346 | 346 | $form->addProgress(); |
| 347 | 347 | if (!empty($inputvalues['forum_image'])) { |
| 348 | - $baseImagePath = api_get_course_path() . '/upload/forum/images/' . $inputvalues['forum_image']; |
|
| 349 | - $image_path = api_get_path(WEB_COURSE_PATH) . $baseImagePath; |
|
| 350 | - $sysImagePath = api_get_path(SYS_COURSE_PATH) . $baseImagePath; |
|
| 348 | + $baseImagePath = api_get_course_path().'/upload/forum/images/'.$inputvalues['forum_image']; |
|
| 349 | + $image_path = api_get_path(WEB_COURSE_PATH).$baseImagePath; |
|
| 350 | + $sysImagePath = api_get_path(SYS_COURSE_PATH).$baseImagePath; |
|
| 351 | 351 | |
| 352 | 352 | if (file_exists($sysImagePath)) { |
| 353 | 353 | $show_preview_image = Display::img($image_path, null, ['class' => 'img-responsive']); |
@@ -1014,24 +1014,24 @@ discard block |
||
| 1014 | 1014 | $html = ''; |
| 1015 | 1015 | $id = Security::remove_XSS($id); |
| 1016 | 1016 | if ($current_visibility_status == '1') { |
| 1017 | - $html .= '<a href="' . api_get_self() . '?' . api_get_cidreq() . '&'; |
|
| 1017 | + $html .= '<a href="'.api_get_self().'?'.api_get_cidreq().'&'; |
|
| 1018 | 1018 | if (is_array($additional_url_parameters)) { |
| 1019 | 1019 | foreach ($additional_url_parameters as $key => $value) { |
| 1020 | - $html .= $key . '=' . $value . '&'; |
|
| 1020 | + $html .= $key.'='.$value.'&'; |
|
| 1021 | 1021 | } |
| 1022 | 1022 | } |
| 1023 | - $html.='action=invisible&content='.$content.'&id='.$id.'">'. |
|
| 1023 | + $html .= 'action=invisible&content='.$content.'&id='.$id.'">'. |
|
| 1024 | 1024 | Display::return_icon('visible.png', get_lang('MakeInvisible'), array(), ICON_SIZE_SMALL).'</a>'; |
| 1025 | 1025 | } |
| 1026 | 1026 | if ($current_visibility_status == '0') { |
| 1027 | - $html .= '<a href="' . api_get_self() . '?' . api_get_cidreq() . '&'; |
|
| 1027 | + $html .= '<a href="'.api_get_self().'?'.api_get_cidreq().'&'; |
|
| 1028 | 1028 | if (is_array($additional_url_parameters)) { |
| 1029 | 1029 | foreach ($additional_url_parameters as $key => $value) { |
| 1030 | - $html .= $key . '=' . $value . '&'; |
|
| 1030 | + $html .= $key.'='.$value.'&'; |
|
| 1031 | 1031 | } |
| 1032 | 1032 | } |
| 1033 | - $html .= 'action=visible&content=' . $content . '&id=' . $id . '">' . |
|
| 1034 | - Display::return_icon('invisible.png', get_lang('MakeVisible'), array(), ICON_SIZE_SMALL) . '</a>'; |
|
| 1033 | + $html .= 'action=visible&content='.$content.'&id='.$id.'">'. |
|
| 1034 | + Display::return_icon('invisible.png', get_lang('MakeVisible'), array(), ICON_SIZE_SMALL).'</a>'; |
|
| 1035 | 1035 | } |
| 1036 | 1036 | return $html; |
| 1037 | 1037 | } |
@@ -1059,21 +1059,21 @@ discard block |
||
| 1059 | 1059 | $html .= '<a href="'.api_get_self().'?'.api_get_cidreq().'&'; |
| 1060 | 1060 | if (is_array($additional_url_parameters)) { |
| 1061 | 1061 | foreach ($additional_url_parameters as $key => $value) { |
| 1062 | - $html .= $key . '=' . $value . '&'; |
|
| 1062 | + $html .= $key.'='.$value.'&'; |
|
| 1063 | 1063 | } |
| 1064 | 1064 | } |
| 1065 | - $html.= 'action=unlock&content='.$content.'&id='.$id.'">'. |
|
| 1065 | + $html .= 'action=unlock&content='.$content.'&id='.$id.'">'. |
|
| 1066 | 1066 | Display::return_icon('lock.png', get_lang('Unlock'), array(), ICON_SIZE_SMALL).'</a>'; |
| 1067 | 1067 | } |
| 1068 | 1068 | if ($current_lock_status == '0') { |
| 1069 | 1069 | $html .= '<a href="'.api_get_self().'?'.api_get_cidreq().'&'; |
| 1070 | 1070 | if (is_array($additional_url_parameters)) { |
| 1071 | 1071 | foreach ($additional_url_parameters as $key => $value) { |
| 1072 | - $html .= $key . '=' . $value . '&'; |
|
| 1072 | + $html .= $key.'='.$value.'&'; |
|
| 1073 | 1073 | } |
| 1074 | 1074 | } |
| 1075 | - $html .= 'action=lock&content=' . $content . '&id=' . $id . '">' . |
|
| 1076 | - Display::return_icon('unlock.png', get_lang('Lock'), array(), ICON_SIZE_SMALL) . '</a>'; |
|
| 1075 | + $html .= 'action=lock&content='.$content.'&id='.$id.'">'. |
|
| 1076 | + Display::return_icon('unlock.png', get_lang('Lock'), array(), ICON_SIZE_SMALL).'</a>'; |
|
| 1077 | 1077 | } |
| 1078 | 1078 | return $html; |
| 1079 | 1079 | } |
@@ -1251,7 +1251,7 @@ discard block |
||
| 1251 | 1251 | $sort_column = 'forum_order'; |
| 1252 | 1252 | // We also need the forum_category of this forum. |
| 1253 | 1253 | $sql = "SELECT forum_category FROM $table_forums |
| 1254 | - WHERE c_id = $course_id AND forum_id = " . intval($id); |
|
| 1254 | + WHERE c_id = $course_id AND forum_id = ".intval($id); |
|
| 1255 | 1255 | $result = Database::query($sql); |
| 1256 | 1256 | $row = Database::fetch_array($result); |
| 1257 | 1257 | $forum_category = $row['forum_category']; |
@@ -1276,7 +1276,7 @@ discard block |
||
| 1276 | 1276 | forum_categories.c_id = $course_id AND |
| 1277 | 1277 | item_properties.c_id = $course_id AND |
| 1278 | 1278 | forum_categories.cat_id=item_properties.ref AND |
| 1279 | - item_properties.tool='" . TOOL_FORUM_CATEGORY . "' |
|
| 1279 | + item_properties.tool='".TOOL_FORUM_CATEGORY."' |
|
| 1280 | 1280 | ORDER BY forum_categories.cat_order $sort_direction"; |
| 1281 | 1281 | } |
| 1282 | 1282 | if ($content == 'forum') { |
@@ -1284,7 +1284,7 @@ discard block |
||
| 1284 | 1284 | FROM $table |
| 1285 | 1285 | WHERE |
| 1286 | 1286 | c_id = $course_id AND |
| 1287 | - forum_category='" . Database::escape_string($forum_category) . "' |
|
| 1287 | + forum_category='".Database::escape_string($forum_category)."' |
|
| 1288 | 1288 | ORDER BY forum_order $sort_direction"; |
| 1289 | 1289 | } |
| 1290 | 1290 | // Finding the items that need to be switched. |
@@ -1308,16 +1308,16 @@ discard block |
||
| 1308 | 1308 | // We do an extra check if we do not have illegal values. If your remove this if statment you will |
| 1309 | 1309 | // be able to mess with the sorting by refreshing the page over and over again. |
| 1310 | 1310 | if ($this_sort != '' && $next_sort != '' && $next_id != '' && $this_id != '') { |
| 1311 | - $sql = "UPDATE $table SET $sort_column='" . Database::escape_string($this_sort) . "' |
|
| 1312 | - WHERE c_id = $course_id AND $id_column='" . Database::escape_string($next_id) . "'"; |
|
| 1311 | + $sql = "UPDATE $table SET $sort_column='".Database::escape_string($this_sort)."' |
|
| 1312 | + WHERE c_id = $course_id AND $id_column='".Database::escape_string($next_id)."'"; |
|
| 1313 | 1313 | Database::query($sql); |
| 1314 | 1314 | |
| 1315 | - $sql = "UPDATE $table SET $sort_column='" . Database::escape_string($next_sort) . "' |
|
| 1316 | - WHERE c_id = $course_id AND $id_column='" . Database::escape_string($this_id) . "'"; |
|
| 1315 | + $sql = "UPDATE $table SET $sort_column='".Database::escape_string($next_sort)."' |
|
| 1316 | + WHERE c_id = $course_id AND $id_column='".Database::escape_string($this_id)."'"; |
|
| 1317 | 1317 | Database::query($sql); |
| 1318 | 1318 | } |
| 1319 | 1319 | |
| 1320 | - return get_lang(ucfirst($content) . 'Moved'); |
|
| 1320 | + return get_lang(ucfirst($content).'Moved'); |
|
| 1321 | 1321 | } |
| 1322 | 1322 | |
| 1323 | 1323 | /** |
@@ -1579,7 +1579,7 @@ discard block |
||
| 1579 | 1579 | INNER JOIN $table_forums forum |
| 1580 | 1580 | ON (forum.forum_id = item_properties.ref AND forum.c_id = item_properties.c_id) |
| 1581 | 1581 | WHERE |
| 1582 | - forum.forum_id = " . intval($id) . " AND |
|
| 1582 | + forum.forum_id = ".intval($id)." AND |
|
| 1583 | 1583 | forum.c_id = $course_id AND |
| 1584 | 1584 | item_properties.visibility != 2 AND |
| 1585 | 1585 | item_properties.tool = '".TOOL_FORUM."' |
@@ -1819,7 +1819,7 @@ discard block |
||
| 1819 | 1819 | $groupCondition = ''; |
| 1820 | 1820 | if (!empty($groupInfo)) { |
| 1821 | 1821 | $groupIid = $groupInfo['iid']; |
| 1822 | - $groupCondition = " AND item_properties.to_group_id = '$groupIid' "; |
|
| 1822 | + $groupCondition = " AND item_properties.to_group_id = '$groupIid' "; |
|
| 1823 | 1823 | } |
| 1824 | 1824 | // important note: it might seem a little bit awkward that we have 'thread.locked as locked' in the sql statement |
| 1825 | 1825 | $sessionCondition = api_get_session_condition($sessionId, true, false, 'item_properties.session_id'); |
@@ -2308,7 +2308,7 @@ discard block |
||
| 2308 | 2308 | { |
| 2309 | 2309 | $table_forums = Database :: get_course_table(TABLE_FORUM); |
| 2310 | 2310 | $table_item_property = Database :: get_course_table(TABLE_ITEM_PROPERTY); |
| 2311 | - $courseId = empty($courseId) ? api_get_course_int_id(): intval($courseId); |
|
| 2311 | + $courseId = empty($courseId) ? api_get_course_int_id() : intval($courseId); |
|
| 2312 | 2312 | $forum_id = intval($forum_id); |
| 2313 | 2313 | |
| 2314 | 2314 | $sql = "SELECT * |
@@ -2747,11 +2747,11 @@ discard block |
||
| 2747 | 2747 | $form = new FormValidator( |
| 2748 | 2748 | 'thread', |
| 2749 | 2749 | 'post', |
| 2750 | - api_get_self() . '?' . http_build_query([ |
|
| 2750 | + api_get_self().'?'.http_build_query([ |
|
| 2751 | 2751 | 'forum' => $myForum, |
| 2752 | 2752 | 'gradebook' => $myGradebook, |
| 2753 | 2753 | 'thread' => $myThread, |
| 2754 | - ]) . '&' . api_get_cidreq() |
|
| 2754 | + ]).'&'.api_get_cidreq() |
|
| 2755 | 2755 | ); |
| 2756 | 2756 | |
| 2757 | 2757 | $form->addElement('header', get_lang('EditThread')); |
@@ -2814,7 +2814,7 @@ discard block |
||
| 2814 | 2814 | $form->addElement('html', '</div>'); |
| 2815 | 2815 | |
| 2816 | 2816 | if (!empty($formValues)) { |
| 2817 | - $defaults['thread_qualify_gradebook'] = ($formValues['threadQualifyMax'] > 0 && empty($_POST)) ? 1 : 0 ; |
|
| 2817 | + $defaults['thread_qualify_gradebook'] = ($formValues['threadQualifyMax'] > 0 && empty($_POST)) ? 1 : 0; |
|
| 2818 | 2818 | $defaults['thread_title'] = prepare4display($formValues['threadTitle']); |
| 2819 | 2819 | $defaults['thread_sticky'] = strval(intval($formValues['threadSticky'])); |
| 2820 | 2820 | $defaults['thread_peer_qualify'] = intval($formValues['threadPeerQualify']); |
@@ -2881,13 +2881,13 @@ discard block |
||
| 2881 | 2881 | $forumId = isset($_GET['forum']) ? (int) $_GET['forum'] : ''; |
| 2882 | 2882 | $my_post = isset($_GET['post']) ? (int) $_GET['post'] : ''; |
| 2883 | 2883 | $my_gradebook = isset($_GET['gradebook']) ? Security::remove_XSS($_GET['gradebook']) : ''; |
| 2884 | - $url = api_get_self() . '?' . http_build_query([ |
|
| 2884 | + $url = api_get_self().'?'.http_build_query([ |
|
| 2885 | 2885 | 'action' => $action, |
| 2886 | 2886 | 'forum' => $forumId, |
| 2887 | 2887 | 'gradebook' => $my_gradebook, |
| 2888 | 2888 | 'thread' => $myThread, |
| 2889 | 2889 | 'post' => $my_post |
| 2890 | - ]) . '&' . api_get_cidreq(); |
|
| 2890 | + ]).'&'.api_get_cidreq(); |
|
| 2891 | 2891 | $form = new FormValidator( |
| 2892 | 2892 | 'thread', |
| 2893 | 2893 | 'post', |
@@ -3185,7 +3185,7 @@ discard block |
||
| 3185 | 3185 | |
| 3186 | 3186 | if ($row[0] == 0) { |
| 3187 | 3187 | $sql = "INSERT INTO $table_threads_qualify (c_id, user_id, thread_id,qualify,qualify_user_id,qualify_time,session_id) |
| 3188 | - VALUES (".$course_id.", '".$user_id."','".$thread_id."',".(float)$thread_qualify.", '".$currentUserId."','".$qualify_time."','".$session_id."')"; |
|
| 3188 | + VALUES (".$course_id.", '".$user_id."','".$thread_id."',".(float) $thread_qualify.", '".$currentUserId."','".$qualify_time."','".$session_id."')"; |
|
| 3189 | 3189 | Database::query($sql); |
| 3190 | 3190 | |
| 3191 | 3191 | $insertId = Database::insert_id(); |
@@ -4808,9 +4808,9 @@ discard block |
||
| 4808 | 4808 | continue; |
| 4809 | 4809 | } |
| 4810 | 4810 | |
| 4811 | - $course_dir = $_course['path'] . '/upload/forum'; |
|
| 4811 | + $course_dir = $_course['path'].'/upload/forum'; |
|
| 4812 | 4812 | $sys_course_path = api_get_path(SYS_COURSE_PATH); |
| 4813 | - $updir = $sys_course_path . $course_dir; |
|
| 4813 | + $updir = $sys_course_path.$course_dir; |
|
| 4814 | 4814 | |
| 4815 | 4815 | // Try to add an extension to the file if it hasn't one. |
| 4816 | 4816 | $new_file_name = add_ext_on_mime( |
@@ -4827,7 +4827,7 @@ discard block |
||
| 4827 | 4827 | } |
| 4828 | 4828 | |
| 4829 | 4829 | $new_file_name = uniqid(''); |
| 4830 | - $new_path = $updir . '/' . $new_file_name; |
|
| 4830 | + $new_path = $updir.'/'.$new_file_name; |
|
| 4831 | 4831 | $result = @move_uploaded_file($attachment['tmp_name'], $new_path); |
| 4832 | 4832 | $safe_file_comment = Database::escape_string($file_comment); |
| 4833 | 4833 | $safe_file_name = Database::escape_string($file_name); |
@@ -4998,16 +4998,16 @@ discard block |
||
| 4998 | 4998 | $forum_table_attachment = Database::get_course_table(TABLE_FORUM_ATTACHMENT); |
| 4999 | 4999 | $course_id = api_get_course_int_id(); |
| 5000 | 5000 | |
| 5001 | - $cond = (!empty($id_attach)) ? " iid = " . (int) $id_attach . "" : " post_id = " . (int) $post_id . ""; |
|
| 5001 | + $cond = (!empty($id_attach)) ? " iid = ".(int) $id_attach."" : " post_id = ".(int) $post_id.""; |
|
| 5002 | 5002 | $sql = "SELECT path FROM $forum_table_attachment WHERE c_id = $course_id AND $cond"; |
| 5003 | 5003 | $res = Database::query($sql); |
| 5004 | 5004 | $row = Database::fetch_array($res); |
| 5005 | 5005 | |
| 5006 | - $course_dir = $_course['path'] . '/upload/forum'; |
|
| 5006 | + $course_dir = $_course['path'].'/upload/forum'; |
|
| 5007 | 5007 | $sys_course_path = api_get_path(SYS_COURSE_PATH); |
| 5008 | - $updir = $sys_course_path . $course_dir; |
|
| 5008 | + $updir = $sys_course_path.$course_dir; |
|
| 5009 | 5009 | $my_path = isset($row['path']) ? $row['path'] : null; |
| 5010 | - $file = $updir . '/' . $my_path; |
|
| 5010 | + $file = $updir.'/'.$my_path; |
|
| 5011 | 5011 | if (Security::check_abs_path($file, $updir)) { |
| 5012 | 5012 | @unlink($file); |
| 5013 | 5013 | } |
@@ -5560,37 +5560,37 @@ discard block |
||
| 5560 | 5560 | $post_list = get_thread_user_post_limit($course_code, $thread['thread_id'], $user_id, 1); |
| 5561 | 5561 | $post_counter = count($post_list); |
| 5562 | 5562 | if (is_array($post_list) && count($post_list) > 0) { |
| 5563 | - $hand_forums.= '<div id="social-thread">'; |
|
| 5564 | - $hand_forums.= Display::return_icon('thread.png', get_lang('Thread'), '', ICON_SIZE_MEDIUM); |
|
| 5565 | - $hand_forums.= ' '.Security::remove_XSS($thread['thread_title'], STUDENT); |
|
| 5566 | - $hand_forums.= '</div>'; |
|
| 5563 | + $hand_forums .= '<div id="social-thread">'; |
|
| 5564 | + $hand_forums .= Display::return_icon('thread.png', get_lang('Thread'), '', ICON_SIZE_MEDIUM); |
|
| 5565 | + $hand_forums .= ' '.Security::remove_XSS($thread['thread_title'], STUDENT); |
|
| 5566 | + $hand_forums .= '</div>'; |
|
| 5567 | 5567 | |
| 5568 | 5568 | foreach ($post_list as $posts) { |
| 5569 | - $hand_forums.= '<div id="social-post">'; |
|
| 5570 | - $hand_forums.= '<strong>'.Security::remove_XSS($posts['post_title'], STUDENT).'</strong>'; |
|
| 5571 | - $hand_forums.= '<br / >'; |
|
| 5572 | - $hand_forums.= Security::remove_XSS($posts['post_text'], STUDENT); |
|
| 5573 | - $hand_forums.= '</div>'; |
|
| 5574 | - $hand_forums.= '<br / >'; |
|
| 5569 | + $hand_forums .= '<div id="social-post">'; |
|
| 5570 | + $hand_forums .= '<strong>'.Security::remove_XSS($posts['post_title'], STUDENT).'</strong>'; |
|
| 5571 | + $hand_forums .= '<br / >'; |
|
| 5572 | + $hand_forums .= Security::remove_XSS($posts['post_text'], STUDENT); |
|
| 5573 | + $hand_forums .= '</div>'; |
|
| 5574 | + $hand_forums .= '<br / >'; |
|
| 5575 | 5575 | } |
| 5576 | 5576 | } |
| 5577 | 5577 | } |
| 5578 | 5578 | $i++; |
| 5579 | 5579 | } |
| 5580 | - $forum_results .='<div id="social-forum">'; |
|
| 5581 | - $forum_results .='<div class="clear"></div><br />'; |
|
| 5582 | - $forum_results .='<div id="social-forum-title">'. |
|
| 5580 | + $forum_results .= '<div id="social-forum">'; |
|
| 5581 | + $forum_results .= '<div class="clear"></div><br />'; |
|
| 5582 | + $forum_results .= '<div id="social-forum-title">'. |
|
| 5583 | 5583 | Display::return_icon('forum.gif', get_lang('Forum')).' '.Security::remove_XSS($forum['forum_title'], STUDENT). |
| 5584 | 5584 | '<div style="float:right;margin-top:-35px"> |
| 5585 | 5585 | <a href="../forum/viewforum.php?'.api_get_cidreq_params($course_code).'&forum='.$forum['forum_id'].' " >'. |
| 5586 | 5586 | get_lang('SeeForum').' |
| 5587 | 5587 | </a> |
| 5588 | 5588 | </div></div>'; |
| 5589 | - $forum_results .='<br / >'; |
|
| 5589 | + $forum_results .= '<br / >'; |
|
| 5590 | 5590 | if ($post_counter > 0) { |
| 5591 | - $forum_results .=$hand_forums; |
|
| 5591 | + $forum_results .= $hand_forums; |
|
| 5592 | 5592 | } |
| 5593 | - $forum_results .='</div>'; |
|
| 5593 | + $forum_results .= '</div>'; |
|
| 5594 | 5594 | }$j++; |
| 5595 | 5595 | } |
| 5596 | 5596 | } |
@@ -5731,16 +5731,16 @@ discard block |
||
| 5731 | 5731 | $courseId = intval($courseId); |
| 5732 | 5732 | if (empty($courseId)) { |
| 5733 | 5733 | // $courseId can be null, use api method |
| 5734 | - $courseId= api_get_course_int_id(); |
|
| 5734 | + $courseId = api_get_course_int_id(); |
|
| 5735 | 5735 | } |
| 5736 | 5736 | /* |
| 5737 | 5737 | * Check if Attachment ID and Course ID are greater than zero |
| 5738 | 5738 | * and array of field values is not empty |
| 5739 | 5739 | */ |
| 5740 | 5740 | if ($id > 0 && $courseId > 0 && !empty($array) && is_array($array)) { |
| 5741 | - foreach($array as $key => &$item) { |
|
| 5741 | + foreach ($array as $key => &$item) { |
|
| 5742 | 5742 | $item = Database::escape_string($item); |
| 5743 | - $setString .= $key . ' = "' .$item . '", '; |
|
| 5743 | + $setString .= $key.' = "'.$item.'", '; |
|
| 5744 | 5744 | } |
| 5745 | 5745 | // Delete last comma |
| 5746 | 5746 | $setString = substr($setString, 0, strlen($setString) - 2); |
@@ -5786,7 +5786,7 @@ discard block |
||
| 5786 | 5786 | return ''; |
| 5787 | 5787 | } |
| 5788 | 5788 | |
| 5789 | - $url = api_get_path(WEB_AJAX_PATH).'forum.ajax.php?'.api_get_cidreq().'&forum=' . $forumId . '&thread=' . $threadId . '&postId=' . $postId . '&a=upload_file'; |
|
| 5789 | + $url = api_get_path(WEB_AJAX_PATH).'forum.ajax.php?'.api_get_cidreq().'&forum='.$forumId.'&thread='.$threadId.'&postId='.$postId.'&a=upload_file'; |
|
| 5790 | 5790 | |
| 5791 | 5791 | $multipleForm = new FormValidator('post'); |
| 5792 | 5792 | $multipleForm->addMultipleUpload($url); |
@@ -5827,10 +5827,10 @@ discard block |
||
| 5827 | 5827 | foreach ($uploadedFiles as $k => $uploadedFile) { |
| 5828 | 5828 | if (!empty($uploadedFile) && in_array($uploadedFile['id'], $attachIds)) { |
| 5829 | 5829 | // Buil html table including an input with attachmentID |
| 5830 | - $fileDataContent .= '<tr id="' . $uploadedFile['id'] . '" ><td>' . $uploadedFile['name'] . '</td><td>' . $uploadedFile['size'] . '</td><td> ' . $uploadedFile['result'] . |
|
| 5831 | - ' </td><td> <input style="width:90%;" type="text" value="' . $uploadedFile['comment'] . '" name="file_comments[]"> </td><td>' . |
|
| 5832 | - $uploadedFile['delete'] . '</td>' . |
|
| 5833 | - '<input type="hidden" value="' . $uploadedFile['id'] .'" name="file_ids[]">' . '</tr>'; |
|
| 5830 | + $fileDataContent .= '<tr id="'.$uploadedFile['id'].'" ><td>'.$uploadedFile['name'].'</td><td>'.$uploadedFile['size'].'</td><td> '.$uploadedFile['result']. |
|
| 5831 | + ' </td><td> <input style="width:90%;" type="text" value="'.$uploadedFile['comment'].'" name="file_comments[]"> </td><td>'. |
|
| 5832 | + $uploadedFile['delete'].'</td>'. |
|
| 5833 | + '<input type="hidden" value="'.$uploadedFile['id'].'" name="file_ids[]">'.'</tr>'; |
|
| 5834 | 5834 | } else { |
| 5835 | 5835 | /* |
| 5836 | 5836 | * If attachment data is empty, then delete it from $_SESSION |
@@ -5843,7 +5843,7 @@ discard block |
||
| 5843 | 5843 | $style = empty($fileDataContent) ? 'display: none;' : ''; |
| 5844 | 5844 | // Forum attachment Ajax table |
| 5845 | 5845 | $fileData = ' |
| 5846 | - <div class="control-group " style="'. $style . '"> |
|
| 5846 | + <div class="control-group " style="'. $style.'"> |
|
| 5847 | 5847 | <label class="control-label">'.get_lang('AttachmentList').'</label> |
| 5848 | 5848 | <div class="controls"> |
| 5849 | 5849 | <table id="attachmentFileList" class="files data_table span10"> |
@@ -5915,7 +5915,7 @@ discard block |
||
| 5915 | 5915 | // name contains an URL to download attachment file and its filename |
| 5916 | 5916 | $json['name'] = Display::url( |
| 5917 | 5917 | api_htmlentities($row['filename']), |
| 5918 | - api_get_path(WEB_CODE_PATH) . 'forum/download.php?file='.$row['path'].'&'.api_get_cidreq(), |
|
| 5918 | + api_get_path(WEB_CODE_PATH).'forum/download.php?file='.$row['path'].'&'.api_get_cidreq(), |
|
| 5919 | 5919 | array('target'=>'_blank', 'class' => 'attachFilename') |
| 5920 | 5920 | ); |
| 5921 | 5921 | $json['id'] = $row['iid']; |
@@ -5926,9 +5926,9 @@ discard block |
||
| 5926 | 5926 | if (!empty($row) && is_array($row)) { |
| 5927 | 5927 | // Set result as success and bring delete URL |
| 5928 | 5928 | $json['result'] = Display::return_icon('accept.png', get_lang('Uploaded')); |
| 5929 | - $url = api_get_path(WEB_CODE_PATH) . 'forum/viewthread.php?' . api_get_cidreq() . '&action=delete_attach&forum=' . $forumId . '&thread=' . $threadId.'&id_attach=' . $row['iid']; |
|
| 5929 | + $url = api_get_path(WEB_CODE_PATH).'forum/viewthread.php?'.api_get_cidreq().'&action=delete_attach&forum='.$forumId.'&thread='.$threadId.'&id_attach='.$row['iid']; |
|
| 5930 | 5930 | $json['delete'] = Display::url( |
| 5931 | - Display::return_icon('delete.png',get_lang('Delete'), array(), ICON_SIZE_SMALL), |
|
| 5931 | + Display::return_icon('delete.png', get_lang('Delete'), array(), ICON_SIZE_SMALL), |
|
| 5932 | 5932 | $url, |
| 5933 | 5933 | array('class' => 'deleteLink') |
| 5934 | 5934 | ); |
@@ -6017,7 +6017,7 @@ discard block |
||
| 6017 | 6017 | WHERE c_id = $courseId AND post_id = $postId"; |
| 6018 | 6018 | $result = Database::query($sql); |
| 6019 | 6019 | if ($result !== false && Database::num_rows($result) > 0) { |
| 6020 | - while ($row = Database::fetch_array($result,'ASSOC')) { |
|
| 6020 | + while ($row = Database::fetch_array($result, 'ASSOC')) { |
|
| 6021 | 6021 | $array[] = $row['id']; |
| 6022 | 6022 | } |
| 6023 | 6023 | } |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | $UserIsSubscribedToSession = SessionManager::isUserSubscribedAsStudent($lastSessionId, $user->getId()); |
| 43 | 43 | |
| 44 | 44 | if (!empty($lastSessionId) && $UserIsSubscribedToSession) { |
| 45 | - $urlWithSession = api_get_self() . '?' . http_build_query([ |
|
| 45 | + $urlWithSession = api_get_self().'?'.http_build_query([ |
|
| 46 | 46 | 'session_id' => $lastCourseAccess->getSessionId() |
| 47 | 47 | ]); |
| 48 | 48 | |
@@ -116,13 +116,13 @@ discard block |
||
| 116 | 116 | foreach ($learningPathList->list as $learningPathId => $learningPath) { |
| 117 | 117 | $courseData['stats'][] = [ |
| 118 | 118 | $learningPath['lp_name'], |
| 119 | - 'lp/lp_controller.php?' . http_build_query([ |
|
| 119 | + 'lp/lp_controller.php?'.http_build_query([ |
|
| 120 | 120 | 'action' => 'stats', |
| 121 | 121 | 'cidReq' => $course->getCode(), |
| 122 | 122 | 'id_session' => $currentSession->getId(), |
| 123 | 123 | 'gidReq' => 0, |
| 124 | 124 | 'lp_id' => $learningPathId |
| 125 | - ]) . api_get_cidreq() |
|
| 125 | + ]).api_get_cidreq() |
|
| 126 | 126 | ]; |
| 127 | 127 | } |
| 128 | 128 | |
@@ -16,12 +16,12 @@ discard block |
||
| 16 | 16 | |
| 17 | 17 | if (isset($_GET['extra_field'])) { |
| 18 | 18 | $extraField = $em->find('ChamiloCoreBundle:ExtraField', intval($_GET['extra_field'])); |
| 19 | - $variableLanguage = '$' . api_underscore_to_camel_case($extraField->getVariable()); |
|
| 19 | + $variableLanguage = '$'.api_underscore_to_camel_case($extraField->getVariable()); |
|
| 20 | 20 | $originalName = $extraField->getDisplayText(false); |
| 21 | 21 | } elseif (isset($_GET['extra_field_option'])) { |
| 22 | 22 | $extraFieldOption = $em->find('ChamiloCoreBundle:ExtraFieldOptions', intval($_GET['extra_field_option'])); |
| 23 | 23 | $extraField = $extraFieldOption->getField(); |
| 24 | - $variableLanguage = '$' . ExtraFieldOption::getLanguageVariable($extraFieldOption->getDisplayText()); |
|
| 24 | + $variableLanguage = '$'.ExtraFieldOption::getLanguageVariable($extraFieldOption->getDisplayText()); |
|
| 25 | 25 | $originalName = $extraFieldOption->getDisplayText(false); |
| 26 | 26 | } |
| 27 | 27 | |
@@ -41,7 +41,7 @@ discard block |
||
| 41 | 41 | $languagesOptions[$language->getId()] = $language->getOriginalName(); |
| 42 | 42 | } |
| 43 | 43 | |
| 44 | -$translateUrl = api_get_path(WEB_CODE_PATH) . 'admin/sub_language_ajax.inc.php'; |
|
| 44 | +$translateUrl = api_get_path(WEB_CODE_PATH).'admin/sub_language_ajax.inc.php'; |
|
| 45 | 45 | |
| 46 | 46 | $form = new FormValidator('new_lang_variable', 'POST', $translateUrl); |
| 47 | 47 | $form->addHeader(get_lang('AddWordForTheSubLanguage')); |
@@ -70,24 +70,24 @@ discard block |
||
| 70 | 70 | $form->addRule('sub_language', get_lang('Required'), 'required'); |
| 71 | 71 | $form->freeze(['variable_language', 'original_name']); |
| 72 | 72 | |
| 73 | -$interbreadcrumb[] = ['url' => api_get_path(WEB_CODE_PATH) . 'admin', 'name' => get_lang('Administration')]; |
|
| 73 | +$interbreadcrumb[] = ['url' => api_get_path(WEB_CODE_PATH).'admin', 'name' => get_lang('Administration')]; |
|
| 74 | 74 | |
| 75 | 75 | switch ($extraField->getExtraFieldType()) { |
| 76 | 76 | case \Chamilo\CoreBundle\Entity\ExtraField::USER_FIELD_TYPE: |
| 77 | 77 | $interbreadcrumb[] = [ |
| 78 | - 'url' => api_get_path(WEB_CODE_PATH) . 'admin/extra_fields.php?type=user', |
|
| 78 | + 'url' => api_get_path(WEB_CODE_PATH).'admin/extra_fields.php?type=user', |
|
| 79 | 79 | 'name' => get_lang('UserFields') |
| 80 | 80 | ]; |
| 81 | 81 | break; |
| 82 | 82 | case \Chamilo\CoreBundle\Entity\ExtraField::COURSE_FIELD_TYPE: |
| 83 | 83 | $interbreadcrumb[] = [ |
| 84 | - 'url' => api_get_path(WEB_CODE_PATH) . 'admin/extra_fields.php?type=course', |
|
| 84 | + 'url' => api_get_path(WEB_CODE_PATH).'admin/extra_fields.php?type=course', |
|
| 85 | 85 | 'name' => get_lang('CourseFields') |
| 86 | 86 | ]; |
| 87 | 87 | break; |
| 88 | 88 | case \Chamilo\CoreBundle\Entity\ExtraField::SESSION_FIELD_TYPE: |
| 89 | 89 | $interbreadcrumb[] = [ |
| 90 | - 'url' => api_get_path(WEB_CODE_PATH) . 'admin/extra_fields.php?type=session', |
|
| 90 | + 'url' => api_get_path(WEB_CODE_PATH).'admin/extra_fields.php?type=session', |
|
| 91 | 91 | 'name' => get_lang('SessionFields') |
| 92 | 92 | ]; |
| 93 | 93 | break; |
@@ -139,7 +139,7 @@ |
||
| 139 | 139 | api_get_local_time($glossary_data['update_date']) |
| 140 | 140 | ); |
| 141 | 141 | } else { |
| 142 | - $glossary_data['update_date'] = ''; |
|
| 142 | + $glossary_data['update_date'] = ''; |
|
| 143 | 143 | } |
| 144 | 144 | |
| 145 | 145 | $form->addLabel(get_lang('CreationDate'), $glossary_data['insert_date']); |
@@ -53,7 +53,7 @@ discard block |
||
| 53 | 53 | if (!api_is_allowed_to_edit(null, true)) { |
| 54 | 54 | api_not_allowed(true); |
| 55 | 55 | } |
| 56 | - $tool_name = get_lang('Add'); |
|
| 56 | + $tool_name = get_lang('Add'); |
|
| 57 | 57 | $form = new FormValidator( |
| 58 | 58 | 'glossary', |
| 59 | 59 | 'post', |
@@ -190,7 +190,7 @@ discard block |
||
| 190 | 190 | if (!api_is_allowed_to_edit(null, true)) { |
| 191 | 191 | api_not_allowed(true); |
| 192 | 192 | } |
| 193 | - $tool_name = get_lang('ImportGlossary'); |
|
| 193 | + $tool_name = get_lang('ImportGlossary'); |
|
| 194 | 194 | $form = new FormValidator( |
| 195 | 195 | 'glossary', |
| 196 | 196 | 'post', |
@@ -218,7 +218,7 @@ discard block |
||
| 218 | 218 | foreach (GlossaryManager::get_glossary_terms() as $term) { |
| 219 | 219 | if (!GlossaryManager::delete_glossary($term['id'], false)) { |
| 220 | 220 | Display::addFlash( |
| 221 | - Display::return_message(get_lang("CannotDeleteGlossary") . ':' . $term['id'], 'error') |
|
| 221 | + Display::return_message(get_lang("CannotDeleteGlossary").':'.$term['id'], 'error') |
|
| 222 | 222 | ); |
| 223 | 223 | } else { |
| 224 | 224 | $termsDeleted[] = $term['name']; |
@@ -315,7 +315,7 @@ discard block |
||
| 315 | 315 | if (count($badList) > 0) { |
| 316 | 316 | Display::addFlash( |
| 317 | 317 | Display::return_message( |
| 318 | - get_lang("GlossaryTermAlreadyExists").': ' . implode(', ', $badList), |
|
| 318 | + get_lang("GlossaryTermAlreadyExists").': '.implode(', ', $badList), |
|
| 319 | 319 | 'error' |
| 320 | 320 | ) |
| 321 | 321 | ); |
@@ -358,7 +358,7 @@ discard block |
||
| 358 | 358 | GlossaryManager::export_to_pdf(); |
| 359 | 359 | break; |
| 360 | 360 | case 'changeview': |
| 361 | - if (in_array($_GET['view'], array('list','table'))) { |
|
| 361 | + if (in_array($_GET['view'], array('list', 'table'))) { |
|
| 362 | 362 | Session::write('glossary_view', $_GET['view']); |
| 363 | 363 | } else { |
| 364 | 364 | $view = Session::read('glossary_view'); |
@@ -87,8 +87,8 @@ discard block |
||
| 87 | 87 | die('Error in get_not_created_links() : course code not set'); |
| 88 | 88 | } |
| 89 | 89 | |
| 90 | - $tbl_grade_links = Database :: get_course_table(TABLE_FORUM_THREAD); |
|
| 91 | - $tbl_item_property = Database :: get_course_table(TABLE_ITEM_PROPERTY); |
|
| 90 | + $tbl_grade_links = Database :: get_course_table(TABLE_FORUM_THREAD); |
|
| 91 | + $tbl_item_property = Database :: get_course_table(TABLE_ITEM_PROPERTY); |
|
| 92 | 92 | $session_id = api_get_session_id(); |
| 93 | 93 | |
| 94 | 94 | if ($session_id) { |
@@ -110,7 +110,7 @@ discard block |
||
| 110 | 110 | |
| 111 | 111 | $result = Database::query($sql); |
| 112 | 112 | while ($data = Database::fetch_array($result)) { |
| 113 | - if ( isset($data['thread_title_qualify']) && $data['thread_title_qualify'] != "") { |
|
| 113 | + if (isset($data['thread_title_qualify']) && $data['thread_title_qualify'] != "") { |
|
| 114 | 114 | $cats[] = array($data['thread_id'], $data['thread_title_qualify']); |
| 115 | 115 | } else { |
| 116 | 116 | $cats[] = array($data['thread_id'], $data['thread_title']); |
@@ -207,11 +207,11 @@ discard block |
||
| 207 | 207 | if (empty($counter) || $counter <= 2) { |
| 208 | 208 | return array(0, $assignment['thread_qualify_max']); |
| 209 | 209 | } |
| 210 | - return [$score/$counter, $assignment['thread_qualify_max']]; |
|
| 210 | + return [$score / $counter, $assignment['thread_qualify_max']]; |
|
| 211 | 211 | } |
| 212 | 212 | } else { |
| 213 | 213 | // All students -> get average |
| 214 | - $students = array(); // user list, needed to make sure we only |
|
| 214 | + $students = array(); // user list, needed to make sure we only |
|
| 215 | 215 | // take first attempts into account |
| 216 | 216 | $counter = 0; |
| 217 | 217 | $sum = 0; |
@@ -242,7 +242,7 @@ discard block |
||
| 242 | 242 | return array($bestResult, $weight); |
| 243 | 243 | break; |
| 244 | 244 | case 'average': |
| 245 | - return array($sumResult/$counter, $weight); |
|
| 245 | + return array($sumResult / $counter, $weight); |
|
| 246 | 246 | break; |
| 247 | 247 | case 'ranking': |
| 248 | 248 | return AbstractLink::getCurrentUserRanking($stud_id, $students); |
@@ -284,9 +284,9 @@ discard block |
||
| 284 | 284 | public function get_name() |
| 285 | 285 | { |
| 286 | 286 | $this->get_exercise_data(); |
| 287 | - $thread_title=isset($this->exercise_data['thread_title']) ? $this->exercise_data['thread_title'] : ''; |
|
| 288 | - $thread_title_qualify=isset($this->exercise_data['thread_title_qualify']) ? $this->exercise_data['thread_title_qualify'] : ''; |
|
| 289 | - if ( isset($thread_title_qualify) && $thread_title_qualify!="") { |
|
| 287 | + $thread_title = isset($this->exercise_data['thread_title']) ? $this->exercise_data['thread_title'] : ''; |
|
| 288 | + $thread_title_qualify = isset($this->exercise_data['thread_title_qualify']) ? $this->exercise_data['thread_title_qualify'] : ''; |
|
| 289 | + if (isset($thread_title_qualify) && $thread_title_qualify != "") { |
|
| 290 | 290 | return $this->exercise_data['thread_title_qualify']; |
| 291 | 291 | } else { |
| 292 | 292 | return $thread_title; |
@@ -298,7 +298,7 @@ discard block |
||
| 298 | 298 | */ |
| 299 | 299 | public function get_description() |
| 300 | 300 | { |
| 301 | - return '';//$this->exercise_data['description']; |
|
| 301 | + return ''; //$this->exercise_data['description']; |
|
| 302 | 302 | } |
| 303 | 303 | |
| 304 | 304 | /** |
@@ -325,8 +325,8 @@ discard block |
||
| 325 | 325 | $sql = 'SELECT * FROM '.$this->get_forum_thread_table()." |
| 326 | 326 | WHERE c_id = '.$this->course_id.' AND thread_id = '".$this->get_ref_id()."' AND session_id = ".$sessionId.""; |
| 327 | 327 | $result = Database::query($sql); |
| 328 | - $row = Database::fetch_array($result,'ASSOC'); |
|
| 329 | - $forum_id=$row['forum_id']; |
|
| 328 | + $row = Database::fetch_array($result, 'ASSOC'); |
|
| 329 | + $forum_id = $row['forum_id']; |
|
| 330 | 330 | |
| 331 | 331 | $url = api_get_path(WEB_PATH).'main/forum/viewthread.php?'.api_get_cidreq_params($this->get_course_code(), $sessionId).'&thread='.$this->get_ref_id().'&gradebook=view&forum='.$forum_id; |
| 332 | 332 | return $url; |
@@ -357,7 +357,7 @@ discard block |
||
| 357 | 357 | |
| 358 | 358 | function save_linked_data() |
| 359 | 359 | { |
| 360 | - $weight = (float)$this->get_weight(); |
|
| 360 | + $weight = (float) $this->get_weight(); |
|
| 361 | 361 | $ref_id = $this->get_ref_id(); |
| 362 | 362 | |
| 363 | 363 | if (!empty($ref_id)) { |
@@ -10,47 +10,47 @@ discard block |
||
| 10 | 10 | */ |
| 11 | 11 | class ForumThreadLink extends AbstractLink |
| 12 | 12 | { |
| 13 | - private $forum_thread_table = null; |
|
| 14 | - private $itemprop_table = null; |
|
| 15 | - |
|
| 16 | - /** |
|
| 17 | - * Constructor |
|
| 18 | - */ |
|
| 19 | - public function __construct() |
|
| 20 | - { |
|
| 21 | - parent::__construct(); |
|
| 22 | - $this->set_type(LINK_FORUM_THREAD); |
|
| 23 | - } |
|
| 24 | - |
|
| 25 | - /** |
|
| 26 | - * @return string |
|
| 27 | - */ |
|
| 28 | - public function get_type_name() |
|
| 29 | - { |
|
| 30 | - return get_lang('ForumThreads'); |
|
| 31 | - } |
|
| 32 | - |
|
| 33 | - /** |
|
| 34 | - * @return bool |
|
| 35 | - */ |
|
| 36 | - public function is_allowed_to_change_name() |
|
| 37 | - { |
|
| 38 | - return false; |
|
| 39 | - } |
|
| 40 | - |
|
| 41 | - /** |
|
| 42 | - * Generate an array of exercises that a teacher hasn't created a link for. |
|
| 43 | - * @return array 2-dimensional array - every element contains 2 subelements (id, name) |
|
| 44 | - */ |
|
| 45 | - public function get_not_created_links() |
|
| 46 | - { |
|
| 47 | - if (empty($this->course_code)) { |
|
| 48 | - die('Error in get_not_created_links() : course code not set'); |
|
| 49 | - } |
|
| 50 | - |
|
| 51 | - $tbl_grade_links = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_LINK); |
|
| 52 | - |
|
| 53 | - $sql = 'SELECT thread_id,thread_title,thread_title_qualify |
|
| 13 | + private $forum_thread_table = null; |
|
| 14 | + private $itemprop_table = null; |
|
| 15 | + |
|
| 16 | + /** |
|
| 17 | + * Constructor |
|
| 18 | + */ |
|
| 19 | + public function __construct() |
|
| 20 | + { |
|
| 21 | + parent::__construct(); |
|
| 22 | + $this->set_type(LINK_FORUM_THREAD); |
|
| 23 | + } |
|
| 24 | + |
|
| 25 | + /** |
|
| 26 | + * @return string |
|
| 27 | + */ |
|
| 28 | + public function get_type_name() |
|
| 29 | + { |
|
| 30 | + return get_lang('ForumThreads'); |
|
| 31 | + } |
|
| 32 | + |
|
| 33 | + /** |
|
| 34 | + * @return bool |
|
| 35 | + */ |
|
| 36 | + public function is_allowed_to_change_name() |
|
| 37 | + { |
|
| 38 | + return false; |
|
| 39 | + } |
|
| 40 | + |
|
| 41 | + /** |
|
| 42 | + * Generate an array of exercises that a teacher hasn't created a link for. |
|
| 43 | + * @return array 2-dimensional array - every element contains 2 subelements (id, name) |
|
| 44 | + */ |
|
| 45 | + public function get_not_created_links() |
|
| 46 | + { |
|
| 47 | + if (empty($this->course_code)) { |
|
| 48 | + die('Error in get_not_created_links() : course code not set'); |
|
| 49 | + } |
|
| 50 | + |
|
| 51 | + $tbl_grade_links = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_LINK); |
|
| 52 | + |
|
| 53 | + $sql = 'SELECT thread_id,thread_title,thread_title_qualify |
|
| 54 | 54 | FROM '.$this->get_forum_thread_table().' |
| 55 | 55 | forum_thread WHERE thread_id NOT IN |
| 56 | 56 | ( |
@@ -61,7 +61,7 @@ discard block |
||
| 61 | 61 | ) |
| 62 | 62 | AND forum_thread.session_id='.api_get_session_id(); |
| 63 | 63 | |
| 64 | - $result = Database::query($sql); |
|
| 64 | + $result = Database::query($sql); |
|
| 65 | 65 | |
| 66 | 66 | $cats = array(); |
| 67 | 67 | while ($data = Database::fetch_array($result)) { |
@@ -76,29 +76,29 @@ discard block |
||
| 76 | 76 | } |
| 77 | 77 | |
| 78 | 78 | return $cats; |
| 79 | - } |
|
| 80 | - |
|
| 81 | - /** |
|
| 82 | - * Generate an array of all exercises available. |
|
| 83 | - * @return array 2-dimensional array - every element contains 2 subelements (id, name) |
|
| 84 | - */ |
|
| 85 | - public function get_all_links() |
|
| 86 | - { |
|
| 87 | - if (empty($this->course_code)) { |
|
| 88 | - die('Error in get_not_created_links() : course code not set'); |
|
| 89 | - } |
|
| 90 | - |
|
| 91 | - $tbl_grade_links = Database :: get_course_table(TABLE_FORUM_THREAD); |
|
| 92 | - $tbl_item_property = Database :: get_course_table(TABLE_ITEM_PROPERTY); |
|
| 93 | - $session_id = api_get_session_id(); |
|
| 94 | - |
|
| 95 | - if ($session_id) { |
|
| 96 | - $session_condition = 'tl.session_id='.api_get_session_id(); |
|
| 97 | - } else { |
|
| 98 | - $session_condition = '(tl.session_id = 0 OR tl.session_id IS NULL)'; |
|
| 99 | - } |
|
| 100 | - |
|
| 101 | - $sql = 'SELECT tl.thread_id, tl.thread_title, tl.thread_title_qualify |
|
| 79 | + } |
|
| 80 | + |
|
| 81 | + /** |
|
| 82 | + * Generate an array of all exercises available. |
|
| 83 | + * @return array 2-dimensional array - every element contains 2 subelements (id, name) |
|
| 84 | + */ |
|
| 85 | + public function get_all_links() |
|
| 86 | + { |
|
| 87 | + if (empty($this->course_code)) { |
|
| 88 | + die('Error in get_not_created_links() : course code not set'); |
|
| 89 | + } |
|
| 90 | + |
|
| 91 | + $tbl_grade_links = Database :: get_course_table(TABLE_FORUM_THREAD); |
|
| 92 | + $tbl_item_property = Database :: get_course_table(TABLE_ITEM_PROPERTY); |
|
| 93 | + $session_id = api_get_session_id(); |
|
| 94 | + |
|
| 95 | + if ($session_id) { |
|
| 96 | + $session_condition = 'tl.session_id='.api_get_session_id(); |
|
| 97 | + } else { |
|
| 98 | + $session_condition = '(tl.session_id = 0 OR tl.session_id IS NULL)'; |
|
| 99 | + } |
|
| 100 | + |
|
| 101 | + $sql = 'SELECT tl.thread_id, tl.thread_title, tl.thread_title_qualify |
|
| 102 | 102 | FROM '.$tbl_grade_links.' tl INNER JOIN '.$tbl_item_property.' ip |
| 103 | 103 | ON (tl.thread_id = ip.ref AND tl.c_id = ip.c_id) |
| 104 | 104 | WHERE |
@@ -109,24 +109,24 @@ discard block |
||
| 109 | 109 | '.$session_condition.' |
| 110 | 110 | '; |
| 111 | 111 | |
| 112 | - $result = Database::query($sql); |
|
| 112 | + $result = Database::query($sql); |
|
| 113 | 113 | |
| 114 | - while ($data = Database::fetch_array($result)) { |
|
| 115 | - if ( isset($data['thread_title_qualify']) && $data['thread_title_qualify'] != "") { |
|
| 116 | - $cats[] = array($data['thread_id'], $data['thread_title_qualify']); |
|
| 117 | - } else { |
|
| 118 | - $cats[] = array($data['thread_id'], $data['thread_title']); |
|
| 119 | - } |
|
| 120 | - } |
|
| 121 | - $my_cats = isset($cats) ? $cats : null; |
|
| 114 | + while ($data = Database::fetch_array($result)) { |
|
| 115 | + if ( isset($data['thread_title_qualify']) && $data['thread_title_qualify'] != "") { |
|
| 116 | + $cats[] = array($data['thread_id'], $data['thread_title_qualify']); |
|
| 117 | + } else { |
|
| 118 | + $cats[] = array($data['thread_id'], $data['thread_title']); |
|
| 119 | + } |
|
| 120 | + } |
|
| 121 | + $my_cats = isset($cats) ? $cats : null; |
|
| 122 | 122 | |
| 123 | - return $my_cats; |
|
| 124 | - } |
|
| 123 | + return $my_cats; |
|
| 124 | + } |
|
| 125 | 125 | |
| 126 | 126 | /** |
| 127 | - * Has anyone done this exercise yet ? |
|
| 128 | - * @return boolean |
|
| 129 | - */ |
|
| 127 | + * Has anyone done this exercise yet ? |
|
| 128 | + * @return boolean |
|
| 129 | + */ |
|
| 130 | 130 | public function has_results() |
| 131 | 131 | { |
| 132 | 132 | $table = Database :: get_course_table(TABLE_FORUM_POST); |
@@ -139,51 +139,51 @@ discard block |
||
| 139 | 139 | $number = Database::fetch_row($result); |
| 140 | 140 | |
| 141 | 141 | return $number[0] != 0; |
| 142 | - } |
|
| 142 | + } |
|
| 143 | 143 | |
| 144 | - /** |
|
| 145 | - * @param int $stud_id |
|
| 144 | + /** |
|
| 145 | + * @param int $stud_id |
|
| 146 | 146 | * @param string $type |
| 147 | 147 | * |
| 148 | - * @return array|null |
|
| 149 | - */ |
|
| 150 | - public function calc_score($stud_id = null, $type = null) |
|
| 151 | - { |
|
| 148 | + * @return array|null |
|
| 149 | + */ |
|
| 150 | + public function calc_score($stud_id = null, $type = null) |
|
| 151 | + { |
|
| 152 | 152 | require_once api_get_path(SYS_CODE_PATH).'forum/forumfunction.inc.php'; |
| 153 | 153 | $threadInfo = get_thread_information('', $this->get_ref_id()); |
| 154 | 154 | |
| 155 | - $thread_qualify = Database::get_course_table(TABLE_FORUM_THREAD_QUALIFY); |
|
| 155 | + $thread_qualify = Database::get_course_table(TABLE_FORUM_THREAD_QUALIFY); |
|
| 156 | 156 | |
| 157 | 157 | $sessionId = $this->get_session_id(); |
| 158 | 158 | $sessionCondition = api_get_session_condition($sessionId, true, false, 'session_id'); |
| 159 | 159 | |
| 160 | - $sql = 'SELECT thread_qualify_max |
|
| 160 | + $sql = 'SELECT thread_qualify_max |
|
| 161 | 161 | FROM '.Database :: get_course_table(TABLE_FORUM_THREAD)." |
| 162 | 162 | WHERE |
| 163 | 163 | c_id = ".$this->course_id." AND |
| 164 | 164 | thread_id = '".$this->get_ref_id()."' |
| 165 | 165 | $sessionCondition |
| 166 | 166 | "; |
| 167 | - $query = Database::query($sql); |
|
| 168 | - $assignment = Database::fetch_array($query); |
|
| 167 | + $query = Database::query($sql); |
|
| 168 | + $assignment = Database::fetch_array($query); |
|
| 169 | 169 | |
| 170 | - $sql = "SELECT * FROM $thread_qualify |
|
| 170 | + $sql = "SELECT * FROM $thread_qualify |
|
| 171 | 171 | WHERE |
| 172 | 172 | c_id = ".$this->course_id." AND |
| 173 | 173 | thread_id = ".$this->get_ref_id()." |
| 174 | 174 | $sessionCondition |
| 175 | 175 | "; |
| 176 | - if (isset($stud_id)) { |
|
| 177 | - $sql .= ' AND user_id = '.intval($stud_id); |
|
| 178 | - } |
|
| 176 | + if (isset($stud_id)) { |
|
| 177 | + $sql .= ' AND user_id = '.intval($stud_id); |
|
| 178 | + } |
|
| 179 | 179 | |
| 180 | - // order by id, that way the student's first attempt is accessed first |
|
| 181 | - $sql .= ' ORDER BY qualify_time DESC'; |
|
| 180 | + // order by id, that way the student's first attempt is accessed first |
|
| 181 | + $sql .= ' ORDER BY qualify_time DESC'; |
|
| 182 | 182 | |
| 183 | - $scores = Database::query($sql); |
|
| 183 | + $scores = Database::query($sql); |
|
| 184 | 184 | |
| 185 | - // for 1 student |
|
| 186 | - if (isset($stud_id)) { |
|
| 185 | + // for 1 student |
|
| 186 | + if (isset($stud_id)) { |
|
| 187 | 187 | if ($threadInfo['thread_peer_qualify'] == 0) { |
| 188 | 188 | // Classic way of calculate score |
| 189 | 189 | if ($data = Database::fetch_array($scores)) { |
@@ -211,175 +211,175 @@ discard block |
||
| 211 | 211 | } |
| 212 | 212 | return [$score/$counter, $assignment['thread_qualify_max']]; |
| 213 | 213 | } |
| 214 | - } else { |
|
| 215 | - // All students -> get average |
|
| 216 | - $students = array(); // user list, needed to make sure we only |
|
| 217 | - // take first attempts into account |
|
| 218 | - $counter = 0; |
|
| 219 | - $sum = 0; |
|
| 220 | - $bestResult = 0; |
|
| 221 | - $weight = 0; |
|
| 222 | - $sumResult = 0; |
|
| 223 | - |
|
| 224 | - while ($data = Database::fetch_array($scores)) { |
|
| 225 | - if (!(array_key_exists($data['user_id'], $students))) { |
|
| 226 | - if ($assignment['thread_qualify_max'] != 0) { |
|
| 227 | - $students[$data['user_id']] = $data['qualify']; |
|
| 228 | - $counter++; |
|
| 229 | - $sum += $data['qualify'] / $assignment['thread_qualify_max']; |
|
| 230 | - $sumResult += $data['qualify']; |
|
| 231 | - if ($data['qualify'] > $bestResult) { |
|
| 232 | - $bestResult = $data['qualify']; |
|
| 233 | - } |
|
| 234 | - $weight = $assignment['thread_qualify_max']; |
|
| 235 | - } |
|
| 236 | - } |
|
| 237 | - } |
|
| 238 | - |
|
| 239 | - if ($counter == 0) { |
|
| 240 | - return null; |
|
| 241 | - } else { |
|
| 242 | - switch ($type) { |
|
| 243 | - case 'best': |
|
| 244 | - return array($bestResult, $weight); |
|
| 245 | - break; |
|
| 246 | - case 'average': |
|
| 247 | - return array($sumResult/$counter, $weight); |
|
| 248 | - break; |
|
| 249 | - case 'ranking': |
|
| 250 | - return AbstractLink::getCurrentUserRanking($stud_id, $students); |
|
| 251 | - break; |
|
| 252 | - default: |
|
| 253 | - return array($sum, $counter); |
|
| 254 | - break; |
|
| 255 | - } |
|
| 256 | - } |
|
| 257 | - } |
|
| 258 | - } |
|
| 259 | - |
|
| 260 | - /** |
|
| 261 | - * Lazy load function to get the database table of the student publications |
|
| 262 | - */ |
|
| 263 | - private function get_forum_thread_table() |
|
| 264 | - { |
|
| 265 | - return $this->forum_thread_table = Database :: get_course_table(TABLE_FORUM_THREAD); |
|
| 266 | - } |
|
| 267 | - |
|
| 268 | - public function needs_name_and_description() |
|
| 269 | - { |
|
| 270 | - return false; |
|
| 271 | - } |
|
| 272 | - |
|
| 273 | - public function needs_max() |
|
| 274 | - { |
|
| 275 | - return false; |
|
| 276 | - } |
|
| 277 | - |
|
| 278 | - public function needs_results() |
|
| 279 | - { |
|
| 280 | - return false; |
|
| 281 | - } |
|
| 214 | + } else { |
|
| 215 | + // All students -> get average |
|
| 216 | + $students = array(); // user list, needed to make sure we only |
|
| 217 | + // take first attempts into account |
|
| 218 | + $counter = 0; |
|
| 219 | + $sum = 0; |
|
| 220 | + $bestResult = 0; |
|
| 221 | + $weight = 0; |
|
| 222 | + $sumResult = 0; |
|
| 223 | + |
|
| 224 | + while ($data = Database::fetch_array($scores)) { |
|
| 225 | + if (!(array_key_exists($data['user_id'], $students))) { |
|
| 226 | + if ($assignment['thread_qualify_max'] != 0) { |
|
| 227 | + $students[$data['user_id']] = $data['qualify']; |
|
| 228 | + $counter++; |
|
| 229 | + $sum += $data['qualify'] / $assignment['thread_qualify_max']; |
|
| 230 | + $sumResult += $data['qualify']; |
|
| 231 | + if ($data['qualify'] > $bestResult) { |
|
| 232 | + $bestResult = $data['qualify']; |
|
| 233 | + } |
|
| 234 | + $weight = $assignment['thread_qualify_max']; |
|
| 235 | + } |
|
| 236 | + } |
|
| 237 | + } |
|
| 238 | + |
|
| 239 | + if ($counter == 0) { |
|
| 240 | + return null; |
|
| 241 | + } else { |
|
| 242 | + switch ($type) { |
|
| 243 | + case 'best': |
|
| 244 | + return array($bestResult, $weight); |
|
| 245 | + break; |
|
| 246 | + case 'average': |
|
| 247 | + return array($sumResult/$counter, $weight); |
|
| 248 | + break; |
|
| 249 | + case 'ranking': |
|
| 250 | + return AbstractLink::getCurrentUserRanking($stud_id, $students); |
|
| 251 | + break; |
|
| 252 | + default: |
|
| 253 | + return array($sum, $counter); |
|
| 254 | + break; |
|
| 255 | + } |
|
| 256 | + } |
|
| 257 | + } |
|
| 258 | + } |
|
| 259 | + |
|
| 260 | + /** |
|
| 261 | + * Lazy load function to get the database table of the student publications |
|
| 262 | + */ |
|
| 263 | + private function get_forum_thread_table() |
|
| 264 | + { |
|
| 265 | + return $this->forum_thread_table = Database :: get_course_table(TABLE_FORUM_THREAD); |
|
| 266 | + } |
|
| 267 | + |
|
| 268 | + public function needs_name_and_description() |
|
| 269 | + { |
|
| 270 | + return false; |
|
| 271 | + } |
|
| 272 | + |
|
| 273 | + public function needs_max() |
|
| 274 | + { |
|
| 275 | + return false; |
|
| 276 | + } |
|
| 277 | + |
|
| 278 | + public function needs_results() |
|
| 279 | + { |
|
| 280 | + return false; |
|
| 281 | + } |
|
| 282 | 282 | |
| 283 | 283 | /** |
| 284 | 284 | * @return string |
| 285 | 285 | */ |
| 286 | - public function get_name() |
|
| 287 | - { |
|
| 288 | - $this->get_exercise_data(); |
|
| 289 | - $thread_title=isset($this->exercise_data['thread_title']) ? $this->exercise_data['thread_title'] : ''; |
|
| 290 | - $thread_title_qualify=isset($this->exercise_data['thread_title_qualify']) ? $this->exercise_data['thread_title_qualify'] : ''; |
|
| 291 | - if ( isset($thread_title_qualify) && $thread_title_qualify!="") { |
|
| 292 | - return $this->exercise_data['thread_title_qualify']; |
|
| 293 | - } else { |
|
| 294 | - return $thread_title; |
|
| 295 | - } |
|
| 296 | - } |
|
| 286 | + public function get_name() |
|
| 287 | + { |
|
| 288 | + $this->get_exercise_data(); |
|
| 289 | + $thread_title=isset($this->exercise_data['thread_title']) ? $this->exercise_data['thread_title'] : ''; |
|
| 290 | + $thread_title_qualify=isset($this->exercise_data['thread_title_qualify']) ? $this->exercise_data['thread_title_qualify'] : ''; |
|
| 291 | + if ( isset($thread_title_qualify) && $thread_title_qualify!="") { |
|
| 292 | + return $this->exercise_data['thread_title_qualify']; |
|
| 293 | + } else { |
|
| 294 | + return $thread_title; |
|
| 295 | + } |
|
| 296 | + } |
|
| 297 | 297 | |
| 298 | 298 | /** |
| 299 | 299 | * @return string |
| 300 | 300 | */ |
| 301 | - public function get_description() |
|
| 302 | - { |
|
| 303 | - return '';//$this->exercise_data['description']; |
|
| 304 | - } |
|
| 305 | - |
|
| 306 | - /** |
|
| 307 | - * Check if this still links to an exercise |
|
| 308 | - */ |
|
| 309 | - public function is_valid_link() |
|
| 310 | - { |
|
| 311 | - $sql = 'SELECT count(id) from '.$this->get_forum_thread_table().' |
|
| 301 | + public function get_description() |
|
| 302 | + { |
|
| 303 | + return '';//$this->exercise_data['description']; |
|
| 304 | + } |
|
| 305 | + |
|
| 306 | + /** |
|
| 307 | + * Check if this still links to an exercise |
|
| 308 | + */ |
|
| 309 | + public function is_valid_link() |
|
| 310 | + { |
|
| 311 | + $sql = 'SELECT count(id) from '.$this->get_forum_thread_table().' |
|
| 312 | 312 | WHERE c_id = '.$this->course_id.' AND thread_id = '.$this->get_ref_id().' AND session_id='.api_get_session_id().''; |
| 313 | - $result = Database::query($sql); |
|
| 314 | - $number = Database::fetch_row($result); |
|
| 315 | - return ($number[0] != 0); |
|
| 316 | - } |
|
| 317 | - |
|
| 318 | - public function get_test_id() |
|
| 319 | - { |
|
| 320 | - return 'DEBUG:ID'; |
|
| 321 | - } |
|
| 322 | - |
|
| 323 | - public function get_link() |
|
| 324 | - { |
|
| 325 | - $sessionId = api_get_session_id(); |
|
| 326 | - //it was extracts the forum id |
|
| 327 | - $sql = 'SELECT * FROM '.$this->get_forum_thread_table()." |
|
| 313 | + $result = Database::query($sql); |
|
| 314 | + $number = Database::fetch_row($result); |
|
| 315 | + return ($number[0] != 0); |
|
| 316 | + } |
|
| 317 | + |
|
| 318 | + public function get_test_id() |
|
| 319 | + { |
|
| 320 | + return 'DEBUG:ID'; |
|
| 321 | + } |
|
| 322 | + |
|
| 323 | + public function get_link() |
|
| 324 | + { |
|
| 325 | + $sessionId = api_get_session_id(); |
|
| 326 | + //it was extracts the forum id |
|
| 327 | + $sql = 'SELECT * FROM '.$this->get_forum_thread_table()." |
|
| 328 | 328 | WHERE c_id = '.$this->course_id.' AND thread_id = '".$this->get_ref_id()."' AND session_id = ".$sessionId.""; |
| 329 | - $result = Database::query($sql); |
|
| 330 | - $row = Database::fetch_array($result,'ASSOC'); |
|
| 331 | - $forum_id=$row['forum_id']; |
|
| 332 | - |
|
| 333 | - $url = api_get_path(WEB_PATH).'main/forum/viewthread.php?'.api_get_cidreq_params($this->get_course_code(), $sessionId).'&thread='.$this->get_ref_id().'&gradebook=view&forum='.$forum_id; |
|
| 334 | - return $url; |
|
| 335 | - } |
|
| 336 | - |
|
| 337 | - private function get_exercise_data() |
|
| 338 | - { |
|
| 339 | - $session_id = api_get_session_id(); |
|
| 340 | - if ($session_id) { |
|
| 341 | - $session_condition = 'session_id='.api_get_session_id(); |
|
| 342 | - } else { |
|
| 343 | - $session_condition = '(session_id = 0 OR session_id IS NULL)'; |
|
| 344 | - } |
|
| 345 | - |
|
| 346 | - if (!isset($this->exercise_data)) { |
|
| 347 | - $sql = 'SELECT * FROM '.$this->get_forum_thread_table().' |
|
| 329 | + $result = Database::query($sql); |
|
| 330 | + $row = Database::fetch_array($result,'ASSOC'); |
|
| 331 | + $forum_id=$row['forum_id']; |
|
| 332 | + |
|
| 333 | + $url = api_get_path(WEB_PATH).'main/forum/viewthread.php?'.api_get_cidreq_params($this->get_course_code(), $sessionId).'&thread='.$this->get_ref_id().'&gradebook=view&forum='.$forum_id; |
|
| 334 | + return $url; |
|
| 335 | + } |
|
| 336 | + |
|
| 337 | + private function get_exercise_data() |
|
| 338 | + { |
|
| 339 | + $session_id = api_get_session_id(); |
|
| 340 | + if ($session_id) { |
|
| 341 | + $session_condition = 'session_id='.api_get_session_id(); |
|
| 342 | + } else { |
|
| 343 | + $session_condition = '(session_id = 0 OR session_id IS NULL)'; |
|
| 344 | + } |
|
| 345 | + |
|
| 346 | + if (!isset($this->exercise_data)) { |
|
| 347 | + $sql = 'SELECT * FROM '.$this->get_forum_thread_table().' |
|
| 348 | 348 | WHERE c_id = '.$this->course_id.' AND thread_id = '.$this->get_ref_id().' AND '.$session_condition; |
| 349 | - $query = Database::query($sql); |
|
| 350 | - $this->exercise_data = Database::fetch_array($query); |
|
| 351 | - } |
|
| 352 | - return $this->exercise_data; |
|
| 353 | - } |
|
| 354 | - |
|
| 355 | - public function get_icon_name() |
|
| 356 | - { |
|
| 357 | - return 'forum'; |
|
| 358 | - } |
|
| 359 | - |
|
| 360 | - function save_linked_data() |
|
| 361 | - { |
|
| 362 | - $weight = (float)$this->get_weight(); |
|
| 363 | - $ref_id = $this->get_ref_id(); |
|
| 364 | - |
|
| 365 | - if (!empty($ref_id)) { |
|
| 366 | - $sql = 'UPDATE '.$this->get_forum_thread_table().' SET thread_weight='.$weight.' |
|
| 349 | + $query = Database::query($sql); |
|
| 350 | + $this->exercise_data = Database::fetch_array($query); |
|
| 351 | + } |
|
| 352 | + return $this->exercise_data; |
|
| 353 | + } |
|
| 354 | + |
|
| 355 | + public function get_icon_name() |
|
| 356 | + { |
|
| 357 | + return 'forum'; |
|
| 358 | + } |
|
| 359 | + |
|
| 360 | + function save_linked_data() |
|
| 361 | + { |
|
| 362 | + $weight = (float)$this->get_weight(); |
|
| 363 | + $ref_id = $this->get_ref_id(); |
|
| 364 | + |
|
| 365 | + if (!empty($ref_id)) { |
|
| 366 | + $sql = 'UPDATE '.$this->get_forum_thread_table().' SET thread_weight='.$weight.' |
|
| 367 | 367 | WHERE c_id = '.$this->course_id.' AND thread_id= '.$ref_id; |
| 368 | - Database::query($sql); |
|
| 369 | - } |
|
| 370 | - } |
|
| 371 | - |
|
| 372 | - function delete_linked_data() |
|
| 373 | - { |
|
| 374 | - $ref_id = $this->get_ref_id(); |
|
| 375 | - if (!empty($ref_id)) { |
|
| 376 | - //Cleans forum |
|
| 377 | - $sql = 'UPDATE '.$this->get_forum_thread_table().' SET |
|
| 368 | + Database::query($sql); |
|
| 369 | + } |
|
| 370 | + } |
|
| 371 | + |
|
| 372 | + function delete_linked_data() |
|
| 373 | + { |
|
| 374 | + $ref_id = $this->get_ref_id(); |
|
| 375 | + if (!empty($ref_id)) { |
|
| 376 | + //Cleans forum |
|
| 377 | + $sql = 'UPDATE '.$this->get_forum_thread_table().' SET |
|
| 378 | 378 | thread_qualify_max = 0, |
| 379 | 379 | thread_weight = 0, |
| 380 | 380 | thread_title_qualify = "" |
| 381 | 381 | WHERE c_id = '.$this->course_id.' AND thread_id= '.$ref_id; |
| 382 | - Database::query($sql); |
|
| 383 | - } |
|
| 384 | - } |
|
| 382 | + Database::query($sql); |
|
| 383 | + } |
|
| 384 | + } |
|
| 385 | 385 | } |
@@ -334,6 +334,9 @@ |
||
| 334 | 334 | return $this; |
| 335 | 335 | } |
| 336 | 336 | |
| 337 | + /** |
|
| 338 | + * @return integer |
|
| 339 | + */ |
|
| 337 | 340 | public function getTypeToInt($value) |
| 338 | 341 | { |
| 339 | 342 | switch ($value) { |
@@ -79,7 +79,7 @@ discard block |
||
| 79 | 79 | } |
| 80 | 80 | |
| 81 | 81 | /** |
| 82 | - * @return float |
|
| 82 | + * @return integer|null |
|
| 83 | 83 | */ |
| 84 | 84 | public function get_certificate_min_score() |
| 85 | 85 | { |
@@ -932,7 +932,8 @@ discard block |
||
| 932 | 932 | |
| 933 | 933 | /** |
| 934 | 934 | * Calculate the score of this category |
| 935 | - * @param $stud_id student id (default: all students - then the average is returned) |
|
| 935 | + * @param integer $stud_id student id (default: all students - then the average is returned) |
|
| 936 | + * @param integer $session_id |
|
| 936 | 937 | * @return array (score sum, weight sum) |
| 937 | 938 | * or null if no scores available |
| 938 | 939 | */ |
@@ -1193,6 +1194,9 @@ discard block |
||
| 1193 | 1194 | * @param int student id |
| 1194 | 1195 | * @param string Course code |
| 1195 | 1196 | * @param int Session id |
| 1197 | + * @param integer $stud_id |
|
| 1198 | + * @param string $course_code |
|
| 1199 | + * @param integer $session_id |
|
| 1196 | 1200 | */ |
| 1197 | 1201 | public function get_root_categories_for_student($stud_id, $course_code = null, $session_id = null) |
| 1198 | 1202 | { |
@@ -1287,6 +1291,9 @@ discard block |
||
| 1287 | 1291 | * @param int user id (to return everything, use 'null' here) |
| 1288 | 1292 | * @param string course code (optional) |
| 1289 | 1293 | * @param int session id (optional) |
| 1294 | + * @param integer $user_id |
|
| 1295 | + * @param string $course_code |
|
| 1296 | + * @param integer $session_id |
|
| 1290 | 1297 | */ |
| 1291 | 1298 | public function get_root_categories_for_teacher($user_id, $course_code = null, $session_id = null) |
| 1292 | 1299 | { |
@@ -1393,6 +1400,7 @@ discard block |
||
| 1393 | 1400 | |
| 1394 | 1401 | /** |
| 1395 | 1402 | * Internal function used by get_target_categories() |
| 1403 | + * @param integer $level |
|
| 1396 | 1404 | */ |
| 1397 | 1405 | private function add_target_subcategories($targets, $level, $catid) |
| 1398 | 1406 | { |
@@ -1492,6 +1500,8 @@ discard block |
||
| 1492 | 1500 | |
| 1493 | 1501 | /** |
| 1494 | 1502 | * Internal function used by get_tree() |
| 1503 | + * @param integer $level |
|
| 1504 | + * @param null|integer $visible |
|
| 1495 | 1505 | */ |
| 1496 | 1506 | private function add_subtree ($targets, $level, $catid, $visible) |
| 1497 | 1507 | { |
@@ -1509,6 +1519,7 @@ discard block |
||
| 1509 | 1519 | |
| 1510 | 1520 | /** |
| 1511 | 1521 | * Generate an array of courses that a teacher hasn't created a category for. |
| 1522 | + * @param integer $user_id |
|
| 1512 | 1523 | * @return array 2-dimensional array - every element contains 2 subelements (code, title) |
| 1513 | 1524 | */ |
| 1514 | 1525 | public function get_not_created_course_categories ($user_id) |
@@ -1548,6 +1559,7 @@ discard block |
||
| 1548 | 1559 | |
| 1549 | 1560 | /** |
| 1550 | 1561 | * Generate an array of all courses that a teacher is admin of. |
| 1562 | + * @param integer $user_id |
|
| 1551 | 1563 | * @return array 2-dimensional array - every element contains 2 subelements (code, title) |
| 1552 | 1564 | */ |
| 1553 | 1565 | public function get_all_courses ($user_id) |
@@ -1628,7 +1640,7 @@ discard block |
||
| 1628 | 1640 | /** |
| 1629 | 1641 | * Retrieve all categories inside a course independent category |
| 1630 | 1642 | * that should be visible to a student. |
| 1631 | - * @param $cat_id parent category |
|
| 1643 | + * @param integer $cat_id parent category |
|
| 1632 | 1644 | * @param $stud_id student id |
| 1633 | 1645 | * @param $cats optional: if defined, the categories will be added to this array |
| 1634 | 1646 | */ |
@@ -1953,7 +1965,7 @@ discard block |
||
| 1953 | 1965 | * the platform administrator. |
| 1954 | 1966 | * @param int locked 1 or unlocked 0 |
| 1955 | 1967 | |
| 1956 | - * @return bool |
|
| 1968 | + * @return boolean|null |
|
| 1957 | 1969 | * */ |
| 1958 | 1970 | public function lock($locked) |
| 1959 | 1971 | { |
@@ -2374,7 +2386,7 @@ discard block |
||
| 2374 | 2386 | * @param float $score The achieved score |
| 2375 | 2387 | * @param int $userId The user id |
| 2376 | 2388 | * @param int $categoryId The gradebook category |
| 2377 | - * @return int The insert id |
|
| 2389 | + * @return false|string The insert id |
|
| 2378 | 2390 | */ |
| 2379 | 2391 | public static function registerCurrentScore($score, $userId, $categoryId) |
| 2380 | 2392 | { |
@@ -89,6 +89,9 @@ discard block |
||
| 89 | 89 | return $this->description; |
| 90 | 90 | } |
| 91 | 91 | |
| 92 | + /** |
|
| 93 | + * @return integer |
|
| 94 | + */ |
|
| 92 | 95 | public function get_user_id() |
| 93 | 96 | { |
| 94 | 97 | return $this->user_id; |
@@ -120,21 +123,33 @@ discard block |
||
| 120 | 123 | return $this->created_at; |
| 121 | 124 | } |
| 122 | 125 | |
| 126 | + /** |
|
| 127 | + * @return double |
|
| 128 | + */ |
|
| 123 | 129 | public function get_weight() |
| 124 | 130 | { |
| 125 | 131 | return $this->weight; |
| 126 | 132 | } |
| 127 | 133 | |
| 134 | + /** |
|
| 135 | + * @return double |
|
| 136 | + */ |
|
| 128 | 137 | public function get_max() |
| 129 | 138 | { |
| 130 | 139 | return $this->eval_max; |
| 131 | 140 | } |
| 132 | 141 | |
| 142 | + /** |
|
| 143 | + * @return string |
|
| 144 | + */ |
|
| 133 | 145 | public function get_type() |
| 134 | 146 | { |
| 135 | 147 | return $this->type; |
| 136 | 148 | } |
| 137 | 149 | |
| 150 | + /** |
|
| 151 | + * @return integer |
|
| 152 | + */ |
|
| 138 | 153 | public function is_visible() |
| 139 | 154 | { |
| 140 | 155 | return $this->visible; |
@@ -9,270 +9,270 @@ discard block |
||
| 9 | 9 | */ |
| 10 | 10 | class Evaluation implements GradebookItem |
| 11 | 11 | { |
| 12 | - private $id; |
|
| 13 | - private $name; |
|
| 14 | - private $description; |
|
| 15 | - private $user_id; |
|
| 16 | - private $course_code; |
|
| 17 | - /** @var Category */ |
|
| 18 | - private $category; |
|
| 19 | - private $created_at; |
|
| 20 | - private $weight; |
|
| 21 | - private $eval_max; |
|
| 22 | - private $visible; |
|
| 23 | - private $sessionId; |
|
| 24 | - public $studentList; |
|
| 25 | - |
|
| 26 | - /** |
|
| 27 | - * Construct |
|
| 28 | - */ |
|
| 29 | - public function __construct() |
|
| 30 | - { |
|
| 31 | - } |
|
| 32 | - |
|
| 33 | - /** |
|
| 34 | - * @return Category |
|
| 35 | - */ |
|
| 36 | - public function getCategory() |
|
| 37 | - { |
|
| 38 | - return $this->category; |
|
| 39 | - } |
|
| 40 | - |
|
| 41 | - /** |
|
| 42 | - * @param Category $category |
|
| 43 | - */ |
|
| 44 | - public function setCategory($category) |
|
| 45 | - { |
|
| 46 | - $this->category = $category; |
|
| 47 | - } |
|
| 48 | - |
|
| 49 | - /** |
|
| 50 | - * @return int |
|
| 51 | - */ |
|
| 52 | - public function get_category_id() |
|
| 53 | - { |
|
| 54 | - return $this->category->get_id(); |
|
| 55 | - } |
|
| 56 | - |
|
| 57 | - /** |
|
| 58 | - * @param int $category_id |
|
| 59 | - */ |
|
| 60 | - public function set_category_id($category_id) |
|
| 61 | - { |
|
| 62 | - $categories = Category::load($category_id); |
|
| 63 | - if (isset($categories[0])) { |
|
| 64 | - $this->setCategory($categories[0]); |
|
| 65 | - } |
|
| 66 | - } |
|
| 67 | - |
|
| 68 | - /** |
|
| 69 | - * @return int |
|
| 70 | - */ |
|
| 71 | - public function get_id() |
|
| 72 | - { |
|
| 73 | - return $this->id; |
|
| 74 | - } |
|
| 75 | - |
|
| 76 | - /** |
|
| 77 | - * @return string |
|
| 78 | - */ |
|
| 79 | - public function get_name() |
|
| 80 | - { |
|
| 81 | - return $this->name; |
|
| 82 | - } |
|
| 83 | - |
|
| 84 | - /** |
|
| 85 | - * @return string |
|
| 86 | - */ |
|
| 87 | - public function get_description() |
|
| 88 | - { |
|
| 89 | - return $this->description; |
|
| 90 | - } |
|
| 91 | - |
|
| 92 | - public function get_user_id() |
|
| 93 | - { |
|
| 94 | - return $this->user_id; |
|
| 95 | - } |
|
| 96 | - |
|
| 97 | - public function get_course_code() |
|
| 98 | - { |
|
| 99 | - return $this->course_code; |
|
| 100 | - } |
|
| 101 | - |
|
| 102 | - /** |
|
| 103 | - * @return int |
|
| 104 | - */ |
|
| 105 | - public function getSessionId() |
|
| 106 | - { |
|
| 107 | - return $this->sessionId; |
|
| 108 | - } |
|
| 109 | - |
|
| 110 | - /** |
|
| 111 | - * @param int $sessionId |
|
| 112 | - */ |
|
| 113 | - public function setSessionId($sessionId) |
|
| 114 | - { |
|
| 115 | - $this->sessionId = intval($sessionId); |
|
| 116 | - } |
|
| 117 | - |
|
| 118 | - public function get_date() |
|
| 119 | - { |
|
| 120 | - return $this->created_at; |
|
| 121 | - } |
|
| 122 | - |
|
| 123 | - public function get_weight() |
|
| 124 | - { |
|
| 125 | - return $this->weight; |
|
| 126 | - } |
|
| 127 | - |
|
| 128 | - public function get_max() |
|
| 129 | - { |
|
| 130 | - return $this->eval_max; |
|
| 131 | - } |
|
| 132 | - |
|
| 133 | - public function get_type() |
|
| 134 | - { |
|
| 135 | - return $this->type; |
|
| 136 | - } |
|
| 137 | - |
|
| 138 | - public function is_visible() |
|
| 139 | - { |
|
| 140 | - return $this->visible; |
|
| 141 | - } |
|
| 142 | - |
|
| 143 | - public function get_locked() |
|
| 144 | - { |
|
| 145 | - return $this->locked; |
|
| 146 | - } |
|
| 147 | - |
|
| 148 | - public function is_locked() |
|
| 149 | - { |
|
| 150 | - return isset($this->locked) && $this->locked == 1 ? true : false; |
|
| 151 | - } |
|
| 152 | - |
|
| 153 | - public function set_id($id) |
|
| 154 | - { |
|
| 155 | - $this->id = $id; |
|
| 156 | - } |
|
| 157 | - |
|
| 158 | - public function set_name($name) |
|
| 159 | - { |
|
| 160 | - $this->name = $name; |
|
| 161 | - } |
|
| 162 | - |
|
| 163 | - public function set_description($description) |
|
| 164 | - { |
|
| 165 | - $this->description = $description; |
|
| 166 | - } |
|
| 167 | - |
|
| 168 | - public function set_user_id($user_id) |
|
| 169 | - { |
|
| 170 | - $this->user_id = $user_id; |
|
| 171 | - } |
|
| 172 | - |
|
| 173 | - public function set_course_code($course_code) |
|
| 174 | - { |
|
| 175 | - $this->course_code = $course_code; |
|
| 176 | - } |
|
| 177 | - |
|
| 178 | - public function set_date($date) |
|
| 179 | - { |
|
| 180 | - $this->created_at = $date; |
|
| 181 | - } |
|
| 182 | - |
|
| 183 | - public function set_weight($weight) |
|
| 184 | - { |
|
| 185 | - $this->weight = $weight; |
|
| 186 | - } |
|
| 187 | - |
|
| 188 | - public function set_max($max) |
|
| 189 | - { |
|
| 190 | - $this->eval_max = $max; |
|
| 191 | - } |
|
| 192 | - |
|
| 193 | - public function set_visible($visible) |
|
| 194 | - { |
|
| 195 | - $this->visible = $visible; |
|
| 196 | - } |
|
| 197 | - |
|
| 198 | - public function set_type($type) |
|
| 199 | - { |
|
| 200 | - $this->type = $type; |
|
| 201 | - } |
|
| 202 | - |
|
| 203 | - public function set_locked($locked) |
|
| 204 | - { |
|
| 205 | - $this->locked = $locked; |
|
| 206 | - } |
|
| 207 | - |
|
| 208 | - /** |
|
| 209 | - * Retrieve evaluations and return them as an array of Evaluation objects |
|
| 210 | - * @param int $id evaluation id |
|
| 211 | - * @param int $user_id user id (evaluation owner) |
|
| 212 | - * @param string $course_code course code |
|
| 213 | - * @param int $category_id parent category |
|
| 214 | - * @param integer $visible visible |
|
| 215 | - */ |
|
| 216 | - public static function load( |
|
| 217 | - $id = null, |
|
| 218 | - $user_id = null, |
|
| 219 | - $course_code = null, |
|
| 220 | - $category_id = null, |
|
| 221 | - $visible = null, |
|
| 222 | - $locked = null |
|
| 223 | - ) { |
|
| 12 | + private $id; |
|
| 13 | + private $name; |
|
| 14 | + private $description; |
|
| 15 | + private $user_id; |
|
| 16 | + private $course_code; |
|
| 17 | + /** @var Category */ |
|
| 18 | + private $category; |
|
| 19 | + private $created_at; |
|
| 20 | + private $weight; |
|
| 21 | + private $eval_max; |
|
| 22 | + private $visible; |
|
| 23 | + private $sessionId; |
|
| 24 | + public $studentList; |
|
| 25 | + |
|
| 26 | + /** |
|
| 27 | + * Construct |
|
| 28 | + */ |
|
| 29 | + public function __construct() |
|
| 30 | + { |
|
| 31 | + } |
|
| 32 | + |
|
| 33 | + /** |
|
| 34 | + * @return Category |
|
| 35 | + */ |
|
| 36 | + public function getCategory() |
|
| 37 | + { |
|
| 38 | + return $this->category; |
|
| 39 | + } |
|
| 40 | + |
|
| 41 | + /** |
|
| 42 | + * @param Category $category |
|
| 43 | + */ |
|
| 44 | + public function setCategory($category) |
|
| 45 | + { |
|
| 46 | + $this->category = $category; |
|
| 47 | + } |
|
| 48 | + |
|
| 49 | + /** |
|
| 50 | + * @return int |
|
| 51 | + */ |
|
| 52 | + public function get_category_id() |
|
| 53 | + { |
|
| 54 | + return $this->category->get_id(); |
|
| 55 | + } |
|
| 56 | + |
|
| 57 | + /** |
|
| 58 | + * @param int $category_id |
|
| 59 | + */ |
|
| 60 | + public function set_category_id($category_id) |
|
| 61 | + { |
|
| 62 | + $categories = Category::load($category_id); |
|
| 63 | + if (isset($categories[0])) { |
|
| 64 | + $this->setCategory($categories[0]); |
|
| 65 | + } |
|
| 66 | + } |
|
| 67 | + |
|
| 68 | + /** |
|
| 69 | + * @return int |
|
| 70 | + */ |
|
| 71 | + public function get_id() |
|
| 72 | + { |
|
| 73 | + return $this->id; |
|
| 74 | + } |
|
| 75 | + |
|
| 76 | + /** |
|
| 77 | + * @return string |
|
| 78 | + */ |
|
| 79 | + public function get_name() |
|
| 80 | + { |
|
| 81 | + return $this->name; |
|
| 82 | + } |
|
| 83 | + |
|
| 84 | + /** |
|
| 85 | + * @return string |
|
| 86 | + */ |
|
| 87 | + public function get_description() |
|
| 88 | + { |
|
| 89 | + return $this->description; |
|
| 90 | + } |
|
| 91 | + |
|
| 92 | + public function get_user_id() |
|
| 93 | + { |
|
| 94 | + return $this->user_id; |
|
| 95 | + } |
|
| 96 | + |
|
| 97 | + public function get_course_code() |
|
| 98 | + { |
|
| 99 | + return $this->course_code; |
|
| 100 | + } |
|
| 101 | + |
|
| 102 | + /** |
|
| 103 | + * @return int |
|
| 104 | + */ |
|
| 105 | + public function getSessionId() |
|
| 106 | + { |
|
| 107 | + return $this->sessionId; |
|
| 108 | + } |
|
| 109 | + |
|
| 110 | + /** |
|
| 111 | + * @param int $sessionId |
|
| 112 | + */ |
|
| 113 | + public function setSessionId($sessionId) |
|
| 114 | + { |
|
| 115 | + $this->sessionId = intval($sessionId); |
|
| 116 | + } |
|
| 117 | + |
|
| 118 | + public function get_date() |
|
| 119 | + { |
|
| 120 | + return $this->created_at; |
|
| 121 | + } |
|
| 122 | + |
|
| 123 | + public function get_weight() |
|
| 124 | + { |
|
| 125 | + return $this->weight; |
|
| 126 | + } |
|
| 127 | + |
|
| 128 | + public function get_max() |
|
| 129 | + { |
|
| 130 | + return $this->eval_max; |
|
| 131 | + } |
|
| 132 | + |
|
| 133 | + public function get_type() |
|
| 134 | + { |
|
| 135 | + return $this->type; |
|
| 136 | + } |
|
| 137 | + |
|
| 138 | + public function is_visible() |
|
| 139 | + { |
|
| 140 | + return $this->visible; |
|
| 141 | + } |
|
| 142 | + |
|
| 143 | + public function get_locked() |
|
| 144 | + { |
|
| 145 | + return $this->locked; |
|
| 146 | + } |
|
| 147 | + |
|
| 148 | + public function is_locked() |
|
| 149 | + { |
|
| 150 | + return isset($this->locked) && $this->locked == 1 ? true : false; |
|
| 151 | + } |
|
| 152 | + |
|
| 153 | + public function set_id($id) |
|
| 154 | + { |
|
| 155 | + $this->id = $id; |
|
| 156 | + } |
|
| 157 | + |
|
| 158 | + public function set_name($name) |
|
| 159 | + { |
|
| 160 | + $this->name = $name; |
|
| 161 | + } |
|
| 162 | + |
|
| 163 | + public function set_description($description) |
|
| 164 | + { |
|
| 165 | + $this->description = $description; |
|
| 166 | + } |
|
| 167 | + |
|
| 168 | + public function set_user_id($user_id) |
|
| 169 | + { |
|
| 170 | + $this->user_id = $user_id; |
|
| 171 | + } |
|
| 172 | + |
|
| 173 | + public function set_course_code($course_code) |
|
| 174 | + { |
|
| 175 | + $this->course_code = $course_code; |
|
| 176 | + } |
|
| 177 | + |
|
| 178 | + public function set_date($date) |
|
| 179 | + { |
|
| 180 | + $this->created_at = $date; |
|
| 181 | + } |
|
| 182 | + |
|
| 183 | + public function set_weight($weight) |
|
| 184 | + { |
|
| 185 | + $this->weight = $weight; |
|
| 186 | + } |
|
| 187 | + |
|
| 188 | + public function set_max($max) |
|
| 189 | + { |
|
| 190 | + $this->eval_max = $max; |
|
| 191 | + } |
|
| 192 | + |
|
| 193 | + public function set_visible($visible) |
|
| 194 | + { |
|
| 195 | + $this->visible = $visible; |
|
| 196 | + } |
|
| 197 | + |
|
| 198 | + public function set_type($type) |
|
| 199 | + { |
|
| 200 | + $this->type = $type; |
|
| 201 | + } |
|
| 202 | + |
|
| 203 | + public function set_locked($locked) |
|
| 204 | + { |
|
| 205 | + $this->locked = $locked; |
|
| 206 | + } |
|
| 207 | + |
|
| 208 | + /** |
|
| 209 | + * Retrieve evaluations and return them as an array of Evaluation objects |
|
| 210 | + * @param int $id evaluation id |
|
| 211 | + * @param int $user_id user id (evaluation owner) |
|
| 212 | + * @param string $course_code course code |
|
| 213 | + * @param int $category_id parent category |
|
| 214 | + * @param integer $visible visible |
|
| 215 | + */ |
|
| 216 | + public static function load( |
|
| 217 | + $id = null, |
|
| 218 | + $user_id = null, |
|
| 219 | + $course_code = null, |
|
| 220 | + $category_id = null, |
|
| 221 | + $visible = null, |
|
| 222 | + $locked = null |
|
| 223 | + ) { |
|
| 224 | 224 | $em = Database::getManager(); |
| 225 | 225 | $qb = $em->createQueryBuilder(); |
| 226 | 226 | $qb |
| 227 | 227 | ->select('ge') |
| 228 | 228 | ->from('ChamiloCoreBundle:GradebookEvaluation', 'ge'); |
| 229 | 229 | |
| 230 | - if (isset ($id)) { |
|
| 230 | + if (isset ($id)) { |
|
| 231 | 231 | $qb->andWhere( |
| 232 | 232 | $qb->expr()->eq('ge.id', $id) |
| 233 | 233 | ); |
| 234 | - } |
|
| 234 | + } |
|
| 235 | 235 | |
| 236 | - if (isset ($user_id)) { |
|
| 236 | + if (isset ($user_id)) { |
|
| 237 | 237 | $user_id = intval($user_id); |
| 238 | 238 | $qb->andWhere( |
| 239 | 239 | $qb->expr()->eq('ge.userId', $user_id) |
| 240 | 240 | ); |
| 241 | - } |
|
| 241 | + } |
|
| 242 | 242 | |
| 243 | - if (isset ($course_code) && $course_code <> '-1') { |
|
| 243 | + if (isset ($course_code) && $course_code <> '-1') { |
|
| 244 | 244 | $courseId = api_get_course_int_id($course_code); |
| 245 | 245 | $qb->andWhere( |
| 246 | 246 | $qb->expr()->eq('ge.course', $courseId) |
| 247 | 247 | ); |
| 248 | - } |
|
| 248 | + } |
|
| 249 | 249 | |
| 250 | - if (isset ($category_id)) { |
|
| 250 | + if (isset ($category_id)) { |
|
| 251 | 251 | $category_id = intval($category_id); |
| 252 | 252 | $qb->andWhere( |
| 253 | 253 | $qb->expr()->eq('ge.categoryId', $category_id) |
| 254 | 254 | ); |
| 255 | - } |
|
| 255 | + } |
|
| 256 | 256 | |
| 257 | - if (isset ($visible)) { |
|
| 257 | + if (isset ($visible)) { |
|
| 258 | 258 | $visible = intval($visible); |
| 259 | 259 | $qb->andWhere( |
| 260 | 260 | $qb->expr()->eq('ge.visible', $visible) |
| 261 | 261 | ); |
| 262 | - } |
|
| 262 | + } |
|
| 263 | 263 | |
| 264 | - if (isset ($locked)) { |
|
| 264 | + if (isset ($locked)) { |
|
| 265 | 265 | $locked = intval($locked); |
| 266 | 266 | $qb->andWhere( |
| 267 | 267 | $qb->expr()->eq('ge.locked', $locked) |
| 268 | 268 | ); |
| 269 | - } |
|
| 269 | + } |
|
| 270 | 270 | |
| 271 | - $result = $qb->getQuery()->getResult(); |
|
| 271 | + $result = $qb->getQuery()->getResult(); |
|
| 272 | 272 | $alleval = Evaluation::createEvaluationObjectsFromEntities($result); |
| 273 | 273 | |
| 274 | - return $alleval; |
|
| 275 | - } |
|
| 274 | + return $alleval; |
|
| 275 | + } |
|
| 276 | 276 | |
| 277 | 277 | /** |
| 278 | 278 | * Get an Evaluation array from an \Chamilo\CoreBundle\Entity\GradebookEvaluation collection |
@@ -305,48 +305,48 @@ discard block |
||
| 305 | 305 | return $alleval; |
| 306 | 306 | } |
| 307 | 307 | |
| 308 | - /** |
|
| 309 | - * @param array $result |
|
| 310 | - * @return array |
|
| 311 | - */ |
|
| 312 | - private static function create_evaluation_objects_from_sql_result($result) |
|
| 313 | - { |
|
| 314 | - $alleval = array(); |
|
| 315 | - if (Database::num_rows($result)) { |
|
| 316 | - while ($data = Database::fetch_array($result)) { |
|
| 317 | - $eval= new Evaluation(); |
|
| 318 | - $eval->set_id($data['id']); |
|
| 319 | - $eval->set_name($data['name']); |
|
| 320 | - $eval->set_description($data['description']); |
|
| 321 | - $eval->set_user_id($data['user_id']); |
|
| 322 | - $eval->set_course_code($data['course_code']); |
|
| 323 | - $eval->set_category_id($data['category_id']); |
|
| 324 | - $eval->set_date(api_get_local_time($data['created_at'])); |
|
| 325 | - $eval->set_weight($data['weight']); |
|
| 326 | - $eval->set_max($data['max']); |
|
| 327 | - $eval->set_visible($data['visible']); |
|
| 328 | - $eval->set_type($data['type']); |
|
| 329 | - $eval->set_locked($data['locked']); |
|
| 330 | - $eval->setSessionId(api_get_session_id()); |
|
| 331 | - |
|
| 332 | - $alleval[] = $eval; |
|
| 333 | - } |
|
| 334 | - } |
|
| 335 | - |
|
| 336 | - return $alleval; |
|
| 337 | - } |
|
| 338 | - |
|
| 339 | - /** |
|
| 340 | - * Insert this evaluation into the database |
|
| 341 | - */ |
|
| 342 | - public function add() |
|
| 343 | - { |
|
| 344 | - if (isset($this->name) && |
|
| 345 | - isset($this->user_id) && |
|
| 346 | - isset($this->weight) && |
|
| 347 | - isset ($this->eval_max) && |
|
| 348 | - isset($this->visible) |
|
| 349 | - ) { |
|
| 308 | + /** |
|
| 309 | + * @param array $result |
|
| 310 | + * @return array |
|
| 311 | + */ |
|
| 312 | + private static function create_evaluation_objects_from_sql_result($result) |
|
| 313 | + { |
|
| 314 | + $alleval = array(); |
|
| 315 | + if (Database::num_rows($result)) { |
|
| 316 | + while ($data = Database::fetch_array($result)) { |
|
| 317 | + $eval= new Evaluation(); |
|
| 318 | + $eval->set_id($data['id']); |
|
| 319 | + $eval->set_name($data['name']); |
|
| 320 | + $eval->set_description($data['description']); |
|
| 321 | + $eval->set_user_id($data['user_id']); |
|
| 322 | + $eval->set_course_code($data['course_code']); |
|
| 323 | + $eval->set_category_id($data['category_id']); |
|
| 324 | + $eval->set_date(api_get_local_time($data['created_at'])); |
|
| 325 | + $eval->set_weight($data['weight']); |
|
| 326 | + $eval->set_max($data['max']); |
|
| 327 | + $eval->set_visible($data['visible']); |
|
| 328 | + $eval->set_type($data['type']); |
|
| 329 | + $eval->set_locked($data['locked']); |
|
| 330 | + $eval->setSessionId(api_get_session_id()); |
|
| 331 | + |
|
| 332 | + $alleval[] = $eval; |
|
| 333 | + } |
|
| 334 | + } |
|
| 335 | + |
|
| 336 | + return $alleval; |
|
| 337 | + } |
|
| 338 | + |
|
| 339 | + /** |
|
| 340 | + * Insert this evaluation into the database |
|
| 341 | + */ |
|
| 342 | + public function add() |
|
| 343 | + { |
|
| 344 | + if (isset($this->name) && |
|
| 345 | + isset($this->user_id) && |
|
| 346 | + isset($this->weight) && |
|
| 347 | + isset ($this->eval_max) && |
|
| 348 | + isset($this->visible) |
|
| 349 | + ) { |
|
| 350 | 350 | $em = Database::getManager(); |
| 351 | 351 | |
| 352 | 352 | $createdAt = new DateTime(api_get_utc_datetime(), new DateTimeZone('UTC')); |
@@ -361,45 +361,45 @@ discard block |
||
| 361 | 361 | ->setCreatedAt($createdAt) |
| 362 | 362 | ->setLocked(false); |
| 363 | 363 | |
| 364 | - if (isset($this->description)) { |
|
| 364 | + if (isset($this->description)) { |
|
| 365 | 365 | $gradebookEvaluation->setDescription($this->get_description()); |
| 366 | - } |
|
| 367 | - if (isset($this->course_code)) { |
|
| 366 | + } |
|
| 367 | + if (isset($this->course_code)) { |
|
| 368 | 368 | $course = $em->getRepository('ChamiloCoreBundle:Course')->findOneBy([ |
| 369 | 369 | 'code' => $this->get_course_code() |
| 370 | 370 | ]); |
| 371 | 371 | $gradebookEvaluation->setCourse($course); |
| 372 | - } |
|
| 373 | - if (isset($this->category)) { |
|
| 372 | + } |
|
| 373 | + if (isset($this->category)) { |
|
| 374 | 374 | $gradebookEvaluation->setCategoryId($this->get_category_id()); |
| 375 | - } |
|
| 376 | - if (empty($this->type)) { |
|
| 377 | - $this->type = 'evaluation'; |
|
| 375 | + } |
|
| 376 | + if (empty($this->type)) { |
|
| 377 | + $this->type = 'evaluation'; |
|
| 378 | 378 | $gradebookEvaluation->setType($this->get_type()); |
| 379 | - } |
|
| 379 | + } |
|
| 380 | 380 | |
| 381 | 381 | $em->persist($gradebookEvaluation); |
| 382 | 382 | $em->flush(); |
| 383 | 383 | |
| 384 | - $this->set_id($gradebookEvaluation->getId()); |
|
| 385 | - } else { |
|
| 386 | - die('Error in Evaluation add: required field empty'); |
|
| 387 | - } |
|
| 388 | - } |
|
| 389 | - |
|
| 390 | - /** |
|
| 391 | - * @param int $idevaluation |
|
| 392 | - */ |
|
| 393 | - public function add_evaluation_log($idevaluation) |
|
| 394 | - { |
|
| 395 | - if (!empty($idevaluation)) { |
|
| 384 | + $this->set_id($gradebookEvaluation->getId()); |
|
| 385 | + } else { |
|
| 386 | + die('Error in Evaluation add: required field empty'); |
|
| 387 | + } |
|
| 388 | + } |
|
| 389 | + |
|
| 390 | + /** |
|
| 391 | + * @param int $idevaluation |
|
| 392 | + */ |
|
| 393 | + public function add_evaluation_log($idevaluation) |
|
| 394 | + { |
|
| 395 | + if (!empty($idevaluation)) { |
|
| 396 | 396 | $em = Database::getManager(); |
| 397 | 397 | |
| 398 | - $tbl_grade_linkeval_log = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_LINKEVAL_LOG); |
|
| 399 | - $eval = new Evaluation(); |
|
| 400 | - $dateobject = $eval->load($idevaluation,null,null,null,null); |
|
| 401 | - $arreval = get_object_vars($dateobject[0]); |
|
| 402 | - if (!empty($arreval['id'])) { |
|
| 398 | + $tbl_grade_linkeval_log = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_LINKEVAL_LOG); |
|
| 399 | + $eval = new Evaluation(); |
|
| 400 | + $dateobject = $eval->load($idevaluation,null,null,null,null); |
|
| 401 | + $arreval = get_object_vars($dateobject[0]); |
|
| 402 | + if (!empty($arreval['id'])) { |
|
| 403 | 403 | $row_old_weight = $em->find('ChamiloCoreBundle:GradebookEvaluation', $arreval['id']); |
| 404 | 404 | $current_date = api_get_utc_datetime(); |
| 405 | 405 | $params = [ |
@@ -413,15 +413,15 @@ discard block |
||
| 413 | 413 | 'user_id_log' => api_get_user_id() |
| 414 | 414 | ]; |
| 415 | 415 | Database::insert($tbl_grade_linkeval_log, $params); |
| 416 | - } |
|
| 417 | - } |
|
| 418 | - } |
|
| 419 | - |
|
| 420 | - /** |
|
| 421 | - * Update the properties of this evaluation in the database |
|
| 422 | - */ |
|
| 423 | - public function save() |
|
| 424 | - { |
|
| 416 | + } |
|
| 417 | + } |
|
| 418 | + } |
|
| 419 | + |
|
| 420 | + /** |
|
| 421 | + * Update the properties of this evaluation in the database |
|
| 422 | + */ |
|
| 423 | + public function save() |
|
| 424 | + { |
|
| 425 | 425 | $em = Database::getManager(); |
| 426 | 426 | $gradebookEvaluation = $em->find('ChamiloCoreBundle:GradebookEvaluation', $this->id); |
| 427 | 427 | |
@@ -430,7 +430,7 @@ discard block |
||
| 430 | 430 | } |
| 431 | 431 | |
| 432 | 432 | $eval_log = new Evaluation(); |
| 433 | - $eval_log->add_evaluation_log($this->id); |
|
| 433 | + $eval_log->add_evaluation_log($this->id); |
|
| 434 | 434 | |
| 435 | 435 | $gradebookEvaluation |
| 436 | 436 | ->setName($this->get_name()) |
@@ -439,296 +439,296 @@ discard block |
||
| 439 | 439 | ->setMax($this->get_max()) |
| 440 | 440 | ->setVisible($this->is_visible()); |
| 441 | 441 | |
| 442 | - if (isset($this->description)) { |
|
| 442 | + if (isset($this->description)) { |
|
| 443 | 443 | $gradebookEvaluation->setDescription($this->get_description()); |
| 444 | - } |
|
| 444 | + } |
|
| 445 | 445 | |
| 446 | - if (isset($this->course_code)) { |
|
| 446 | + if (isset($this->course_code)) { |
|
| 447 | 447 | $course = $em->getRepository('ChamiloCoreBundle:Course')->findOneBy([ |
| 448 | 448 | 'code' => $this->get_course_code() |
| 449 | 449 | ]); |
| 450 | 450 | $gradebookEvaluation->setCourse($course); |
| 451 | - } |
|
| 451 | + } |
|
| 452 | 452 | |
| 453 | - if (isset($this->category)) { |
|
| 453 | + if (isset($this->category)) { |
|
| 454 | 454 | $gradebookEvaluation->setCategoryId($this->get_category_id()); |
| 455 | - } |
|
| 456 | - //recorded history |
|
| 455 | + } |
|
| 456 | + //recorded history |
|
| 457 | 457 | |
| 458 | 458 | $em->persist($gradebookEvaluation); |
| 459 | 459 | $em->flush(); |
| 460 | - } |
|
| 460 | + } |
|
| 461 | 461 | |
| 462 | - /** |
|
| 463 | - * Delete this evaluation from the database |
|
| 464 | - */ |
|
| 465 | - public function delete() |
|
| 466 | - { |
|
| 462 | + /** |
|
| 463 | + * Delete this evaluation from the database |
|
| 464 | + */ |
|
| 465 | + public function delete() |
|
| 466 | + { |
|
| 467 | 467 | $em = Database::getManager(); |
| 468 | 468 | $gradebookEvaluation = $em->find('ChamiloCoreBundle:GradebookEvaluation', $this->id); |
| 469 | 469 | |
| 470 | 470 | $em->remove($gradebookEvaluation); |
| 471 | 471 | $em->flush(); |
| 472 | - } |
|
| 473 | - |
|
| 474 | - /** |
|
| 475 | - * Check if an evaluation name (with the same parent category) already exists |
|
| 476 | - * @param $name name to check (if not given, the name property of this object will be checked) |
|
| 477 | - * @param $parent parent category |
|
| 478 | - */ |
|
| 479 | - public function does_name_exist($name, $parent) |
|
| 480 | - { |
|
| 481 | - if (!isset ($name)) { |
|
| 482 | - $name = $this->name; |
|
| 483 | - $parent = $this->category; |
|
| 484 | - } |
|
| 485 | - $tbl_grade_evaluations = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_EVALUATION); |
|
| 486 | - $sql = 'SELECT count(id) AS number' |
|
| 487 | - .' FROM '.$tbl_grade_evaluations |
|
| 488 | - ." WHERE name = '".Database::escape_string($name)."'"; |
|
| 489 | - |
|
| 490 | - if (api_is_allowed_to_edit()) { |
|
| 491 | - $parent = Category::load($parent); |
|
| 492 | - $code = $parent[0]->get_course_code(); |
|
| 493 | - $courseInfo = api_get_course_info($code); |
|
| 494 | - $courseId = $courseInfo['real_id']; |
|
| 495 | - |
|
| 496 | - if (isset($code) && $code != '0') { |
|
| 497 | - $main_course_user_table = Database :: get_main_table(TABLE_MAIN_COURSE_USER); |
|
| 498 | - $sql .= ' AND user_id IN ( |
|
| 472 | + } |
|
| 473 | + |
|
| 474 | + /** |
|
| 475 | + * Check if an evaluation name (with the same parent category) already exists |
|
| 476 | + * @param $name name to check (if not given, the name property of this object will be checked) |
|
| 477 | + * @param $parent parent category |
|
| 478 | + */ |
|
| 479 | + public function does_name_exist($name, $parent) |
|
| 480 | + { |
|
| 481 | + if (!isset ($name)) { |
|
| 482 | + $name = $this->name; |
|
| 483 | + $parent = $this->category; |
|
| 484 | + } |
|
| 485 | + $tbl_grade_evaluations = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_EVALUATION); |
|
| 486 | + $sql = 'SELECT count(id) AS number' |
|
| 487 | + .' FROM '.$tbl_grade_evaluations |
|
| 488 | + ." WHERE name = '".Database::escape_string($name)."'"; |
|
| 489 | + |
|
| 490 | + if (api_is_allowed_to_edit()) { |
|
| 491 | + $parent = Category::load($parent); |
|
| 492 | + $code = $parent[0]->get_course_code(); |
|
| 493 | + $courseInfo = api_get_course_info($code); |
|
| 494 | + $courseId = $courseInfo['real_id']; |
|
| 495 | + |
|
| 496 | + if (isset($code) && $code != '0') { |
|
| 497 | + $main_course_user_table = Database :: get_main_table(TABLE_MAIN_COURSE_USER); |
|
| 498 | + $sql .= ' AND user_id IN ( |
|
| 499 | 499 | SELECT user_id FROM '.$main_course_user_table.' |
| 500 | 500 | WHERE |
| 501 | 501 | c_id = '.$courseId.' AND |
| 502 | 502 | status = '.COURSEMANAGER.' |
| 503 | 503 | )'; |
| 504 | - } else { |
|
| 505 | - $sql .= ' AND user_id = '.api_get_user_id(); |
|
| 506 | - } |
|
| 507 | - |
|
| 508 | - }else { |
|
| 509 | - $sql .= ' AND user_id = '.api_get_user_id(); |
|
| 510 | - } |
|
| 511 | - |
|
| 512 | - if (!isset ($parent)) { |
|
| 513 | - $sql.= ' AND category_id is null'; |
|
| 514 | - } else { |
|
| 515 | - $sql.= ' AND category_id = '.intval($parent); |
|
| 516 | - } |
|
| 517 | - $result = Database::query($sql); |
|
| 518 | - $number=Database::fetch_row($result); |
|
| 519 | - |
|
| 520 | - return $number[0] != 0; |
|
| 521 | - } |
|
| 522 | - |
|
| 523 | - /** |
|
| 524 | - * Are there any results for this evaluation yet ? |
|
| 525 | - * The 'max' property should not be changed then. |
|
| 526 | - */ |
|
| 527 | - public function has_results() |
|
| 528 | - { |
|
| 529 | - $tbl_grade_results = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_RESULT); |
|
| 530 | - $sql = 'SELECT count(id) AS number |
|
| 504 | + } else { |
|
| 505 | + $sql .= ' AND user_id = '.api_get_user_id(); |
|
| 506 | + } |
|
| 507 | + |
|
| 508 | + }else { |
|
| 509 | + $sql .= ' AND user_id = '.api_get_user_id(); |
|
| 510 | + } |
|
| 511 | + |
|
| 512 | + if (!isset ($parent)) { |
|
| 513 | + $sql.= ' AND category_id is null'; |
|
| 514 | + } else { |
|
| 515 | + $sql.= ' AND category_id = '.intval($parent); |
|
| 516 | + } |
|
| 517 | + $result = Database::query($sql); |
|
| 518 | + $number=Database::fetch_row($result); |
|
| 519 | + |
|
| 520 | + return $number[0] != 0; |
|
| 521 | + } |
|
| 522 | + |
|
| 523 | + /** |
|
| 524 | + * Are there any results for this evaluation yet ? |
|
| 525 | + * The 'max' property should not be changed then. |
|
| 526 | + */ |
|
| 527 | + public function has_results() |
|
| 528 | + { |
|
| 529 | + $tbl_grade_results = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_RESULT); |
|
| 530 | + $sql = 'SELECT count(id) AS number |
|
| 531 | 531 | FROM '.$tbl_grade_results.' |
| 532 | 532 | WHERE evaluation_id = '.intval($this->id); |
| 533 | - $result = Database::query($sql); |
|
| 534 | - $number=Database::fetch_row($result); |
|
| 535 | - |
|
| 536 | - return ($number[0] != 0); |
|
| 537 | - } |
|
| 538 | - |
|
| 539 | - /** |
|
| 540 | - * Delete all results for this evaluation |
|
| 541 | - */ |
|
| 542 | - public function delete_results() |
|
| 543 | - { |
|
| 544 | - $tbl_grade_results = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_RESULT); |
|
| 545 | - $sql = 'DELETE FROM '.$tbl_grade_results.' |
|
| 533 | + $result = Database::query($sql); |
|
| 534 | + $number=Database::fetch_row($result); |
|
| 535 | + |
|
| 536 | + return ($number[0] != 0); |
|
| 537 | + } |
|
| 538 | + |
|
| 539 | + /** |
|
| 540 | + * Delete all results for this evaluation |
|
| 541 | + */ |
|
| 542 | + public function delete_results() |
|
| 543 | + { |
|
| 544 | + $tbl_grade_results = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_RESULT); |
|
| 545 | + $sql = 'DELETE FROM '.$tbl_grade_results.' |
|
| 546 | 546 | WHERE evaluation_id = '.intval($this->id); |
| 547 | - Database::query($sql); |
|
| 548 | - } |
|
| 549 | - |
|
| 550 | - /** |
|
| 551 | - * Delete this evaluation and all underlying results. |
|
| 552 | - */ |
|
| 553 | - public function delete_with_results() |
|
| 554 | - { |
|
| 555 | - $this->delete_results(); |
|
| 556 | - $this->delete(); |
|
| 557 | - } |
|
| 558 | - |
|
| 559 | - /** |
|
| 560 | - * Check if the given score is possible for this evaluation |
|
| 561 | - */ |
|
| 562 | - public function is_valid_score($score) |
|
| 563 | - { |
|
| 564 | - return is_numeric($score) && $score >= 0 && $score <= $this->eval_max; |
|
| 565 | - } |
|
| 566 | - |
|
| 567 | - /** |
|
| 568 | - * Calculate the score of this evaluation |
|
| 569 | - * @param int $stud_id (default: all students who have results for this eval - then the average is returned) |
|
| 570 | - * @param string $type (best, average, ranking) |
|
| 571 | - * @return array (score, max) if student is given |
|
| 572 | - * array (sum of scores, number of scores) otherwise |
|
| 573 | - * or null if no scores available |
|
| 574 | - */ |
|
| 575 | - public function calc_score($stud_id = null, $type = null) |
|
| 576 | - { |
|
| 547 | + Database::query($sql); |
|
| 548 | + } |
|
| 549 | + |
|
| 550 | + /** |
|
| 551 | + * Delete this evaluation and all underlying results. |
|
| 552 | + */ |
|
| 553 | + public function delete_with_results() |
|
| 554 | + { |
|
| 555 | + $this->delete_results(); |
|
| 556 | + $this->delete(); |
|
| 557 | + } |
|
| 558 | + |
|
| 559 | + /** |
|
| 560 | + * Check if the given score is possible for this evaluation |
|
| 561 | + */ |
|
| 562 | + public function is_valid_score($score) |
|
| 563 | + { |
|
| 564 | + return is_numeric($score) && $score >= 0 && $score <= $this->eval_max; |
|
| 565 | + } |
|
| 566 | + |
|
| 567 | + /** |
|
| 568 | + * Calculate the score of this evaluation |
|
| 569 | + * @param int $stud_id (default: all students who have results for this eval - then the average is returned) |
|
| 570 | + * @param string $type (best, average, ranking) |
|
| 571 | + * @return array (score, max) if student is given |
|
| 572 | + * array (sum of scores, number of scores) otherwise |
|
| 573 | + * or null if no scores available |
|
| 574 | + */ |
|
| 575 | + public function calc_score($stud_id = null, $type = null) |
|
| 576 | + { |
|
| 577 | 577 | $useSession = true; |
| 578 | - if (isset($stud_id) && empty($type)) { |
|
| 579 | - $key = 'result_score_student_list_'.api_get_course_int_id().'_'.api_get_session_id().'_'.$this->id.'_'.$stud_id; |
|
| 580 | - $data = Session::read('calc_score'); |
|
| 578 | + if (isset($stud_id) && empty($type)) { |
|
| 579 | + $key = 'result_score_student_list_'.api_get_course_int_id().'_'.api_get_session_id().'_'.$this->id.'_'.$stud_id; |
|
| 580 | + $data = Session::read('calc_score'); |
|
| 581 | 581 | $results = isset($data[$key]) ? $data[$key] : null; |
| 582 | 582 | |
| 583 | 583 | if ($useSession == false) { |
| 584 | 584 | $results = null; |
| 585 | 585 | } |
| 586 | - if (empty($results)) { |
|
| 587 | - $results = Result::load(null, $stud_id, $this->id); |
|
| 588 | - Session::write('calc_score', array($key => $results)); |
|
| 589 | - } |
|
| 590 | - |
|
| 591 | - $score = 0; |
|
| 592 | - /** @var Result $res */ |
|
| 593 | - foreach ($results as $res) { |
|
| 594 | - $score = $res->get_score(); |
|
| 595 | - } |
|
| 596 | - |
|
| 597 | - return array($score, $this->get_max()); |
|
| 598 | - } else { |
|
| 599 | - |
|
| 600 | - $count = 0; |
|
| 601 | - $sum = 0; |
|
| 602 | - $bestResult = 0; |
|
| 603 | - $weight = 0; |
|
| 604 | - $sumResult = 0; |
|
| 605 | - |
|
| 606 | - $key = 'result_score_student_list_'.api_get_course_int_id().'_'.api_get_session_id().'_'.$this->id; |
|
| 586 | + if (empty($results)) { |
|
| 587 | + $results = Result::load(null, $stud_id, $this->id); |
|
| 588 | + Session::write('calc_score', array($key => $results)); |
|
| 589 | + } |
|
| 590 | + |
|
| 591 | + $score = 0; |
|
| 592 | + /** @var Result $res */ |
|
| 593 | + foreach ($results as $res) { |
|
| 594 | + $score = $res->get_score(); |
|
| 595 | + } |
|
| 596 | + |
|
| 597 | + return array($score, $this->get_max()); |
|
| 598 | + } else { |
|
| 599 | + |
|
| 600 | + $count = 0; |
|
| 601 | + $sum = 0; |
|
| 602 | + $bestResult = 0; |
|
| 603 | + $weight = 0; |
|
| 604 | + $sumResult = 0; |
|
| 605 | + |
|
| 606 | + $key = 'result_score_student_list_'.api_get_course_int_id().'_'.api_get_session_id().'_'.$this->id; |
|
| 607 | 607 | $data = Session::read('calc_score'); |
| 608 | 608 | $allResults = isset($data[$key]) ? $data[$key] : null; |
| 609 | 609 | if ($useSession == false) { |
| 610 | 610 | $allResults = null; |
| 611 | 611 | } |
| 612 | - if (empty($allResults)) { |
|
| 613 | - $allResults = Result::load(null, null, $this->id); |
|
| 614 | - Session::write($key, $allResults); |
|
| 615 | - } |
|
| 616 | - |
|
| 617 | - $students = array(); |
|
| 618 | - /** @var Result $res */ |
|
| 619 | - foreach ($allResults as $res) { |
|
| 620 | - $score = $res->get_score(); |
|
| 621 | - if (!empty($score) || $score == '0') { |
|
| 622 | - $count++; |
|
| 623 | - $sum += $score / $this->get_max(); |
|
| 624 | - $sumResult += $score; |
|
| 625 | - if ($score > $bestResult) { |
|
| 626 | - $bestResult = $score; |
|
| 627 | - } |
|
| 628 | - $weight = $this->get_max(); |
|
| 629 | - } |
|
| 630 | - $students[$res->get_user_id()] = $score; |
|
| 631 | - } |
|
| 632 | - |
|
| 633 | - if (empty($count)) { |
|
| 634 | - return null; |
|
| 635 | - } |
|
| 636 | - |
|
| 637 | - switch ($type) { |
|
| 638 | - case 'best': |
|
| 639 | - return array($bestResult, $weight); |
|
| 640 | - break; |
|
| 641 | - case 'average': |
|
| 642 | - return array($sumResult/$count, $weight); |
|
| 643 | - break; |
|
| 644 | - case 'ranking': |
|
| 612 | + if (empty($allResults)) { |
|
| 613 | + $allResults = Result::load(null, null, $this->id); |
|
| 614 | + Session::write($key, $allResults); |
|
| 615 | + } |
|
| 616 | + |
|
| 617 | + $students = array(); |
|
| 618 | + /** @var Result $res */ |
|
| 619 | + foreach ($allResults as $res) { |
|
| 620 | + $score = $res->get_score(); |
|
| 621 | + if (!empty($score) || $score == '0') { |
|
| 622 | + $count++; |
|
| 623 | + $sum += $score / $this->get_max(); |
|
| 624 | + $sumResult += $score; |
|
| 625 | + if ($score > $bestResult) { |
|
| 626 | + $bestResult = $score; |
|
| 627 | + } |
|
| 628 | + $weight = $this->get_max(); |
|
| 629 | + } |
|
| 630 | + $students[$res->get_user_id()] = $score; |
|
| 631 | + } |
|
| 632 | + |
|
| 633 | + if (empty($count)) { |
|
| 634 | + return null; |
|
| 635 | + } |
|
| 636 | + |
|
| 637 | + switch ($type) { |
|
| 638 | + case 'best': |
|
| 639 | + return array($bestResult, $weight); |
|
| 640 | + break; |
|
| 641 | + case 'average': |
|
| 642 | + return array($sumResult/$count, $weight); |
|
| 643 | + break; |
|
| 644 | + case 'ranking': |
|
| 645 | 645 | $students = array(); |
| 646 | 646 | /** @var Result $res */ |
| 647 | 647 | foreach ($allResults as $res) { |
| 648 | 648 | $score = $res->get_score(); |
| 649 | 649 | $students[$res->get_user_id()] = $score; |
| 650 | 650 | } |
| 651 | - return AbstractLink::getCurrentUserRanking($stud_id, $students); |
|
| 652 | - break; |
|
| 653 | - default: |
|
| 654 | - return array($sum, $count); |
|
| 655 | - break; |
|
| 656 | - } |
|
| 657 | - } |
|
| 658 | - } |
|
| 659 | - |
|
| 660 | - /** |
|
| 661 | - * Generate an array of possible categories where this evaluation can be moved to. |
|
| 662 | - * Notice: its own parent will be included in the list: it's up to the frontend |
|
| 663 | - * to disable this element. |
|
| 664 | - * @return array 2-dimensional array - every element contains 3 subelements (id, name, level) |
|
| 665 | - */ |
|
| 666 | - public function get_target_categories() |
|
| 667 | - { |
|
| 668 | - // - course independent evaluation |
|
| 669 | - // -> movable to root or other course independent categories |
|
| 670 | - // - evaluation inside a course |
|
| 671 | - // -> movable to root, independent categories or categories inside the course |
|
| 672 | - $user = (api_is_platform_admin() ? null : api_get_user_id()); |
|
| 673 | - $targets = array(); |
|
| 674 | - $level = 0; |
|
| 675 | - |
|
| 676 | - $root = array(0, get_lang('RootCat'), $level); |
|
| 677 | - $targets[] = $root; |
|
| 678 | - |
|
| 679 | - if (isset($this->course_code) && !empty($this->course_code)) { |
|
| 680 | - $crscats = Category::load(null,null,$this->course_code,0); |
|
| 681 | - foreach ($crscats as $cat) { |
|
| 682 | - $targets[] = array ($cat->get_id(), $cat->get_name(), $level+1); |
|
| 683 | - $targets = $this->add_target_subcategories($targets, $level+1, $cat->get_id()); |
|
| 684 | - } |
|
| 685 | - } |
|
| 686 | - |
|
| 687 | - $indcats = Category::load(null,$user,0,0); |
|
| 688 | - foreach ($indcats as $cat) { |
|
| 689 | - $targets[] = array ($cat->get_id(), $cat->get_name(), $level+1); |
|
| 690 | - $targets = $this->add_target_subcategories($targets, $level+1, $cat->get_id()); |
|
| 691 | - } |
|
| 692 | - |
|
| 693 | - return $targets; |
|
| 694 | - } |
|
| 695 | - |
|
| 696 | - /** |
|
| 697 | - * Internal function used by get_target_categories() |
|
| 698 | - * @param integer $level |
|
| 699 | - */ |
|
| 700 | - private function add_target_subcategories($targets, $level, $catid) |
|
| 701 | - { |
|
| 702 | - $subcats = Category::load(null,null,null,$catid); |
|
| 703 | - foreach ($subcats as $cat) { |
|
| 704 | - $targets[] = array ($cat->get_id(), $cat->get_name(), $level+1); |
|
| 705 | - $targets = $this->add_target_subcategories($targets, $level+1, $cat->get_id()); |
|
| 706 | - } |
|
| 707 | - return $targets; |
|
| 708 | - } |
|
| 709 | - |
|
| 710 | - /** |
|
| 711 | - * Move this evaluation to the given category. |
|
| 712 | - * If this evaluation moves from inside a course to outside, |
|
| 713 | - * its course code is also changed. |
|
| 714 | - */ |
|
| 715 | - public function move_to_cat($cat) |
|
| 716 | - { |
|
| 717 | - $this->set_category_id($cat->get_id()); |
|
| 718 | - if ($this->get_course_code() != $cat->get_course_code()) { |
|
| 719 | - $this->set_course_code($cat->get_course_code()); |
|
| 720 | - } |
|
| 721 | - $this->save(); |
|
| 722 | - } |
|
| 723 | - |
|
| 724 | - /** |
|
| 725 | - * Retrieve evaluations where a student has results for |
|
| 726 | - * and return them as an array of Evaluation objects |
|
| 727 | - * @param int $cat_id parent category (use 'null' to retrieve them in all categories) |
|
| 728 | - * @param int $stud_id student id |
|
| 729 | - */ |
|
| 730 | - public static function get_evaluations_with_result_for_student($cat_id = null, $stud_id) |
|
| 731 | - { |
|
| 651 | + return AbstractLink::getCurrentUserRanking($stud_id, $students); |
|
| 652 | + break; |
|
| 653 | + default: |
|
| 654 | + return array($sum, $count); |
|
| 655 | + break; |
|
| 656 | + } |
|
| 657 | + } |
|
| 658 | + } |
|
| 659 | + |
|
| 660 | + /** |
|
| 661 | + * Generate an array of possible categories where this evaluation can be moved to. |
|
| 662 | + * Notice: its own parent will be included in the list: it's up to the frontend |
|
| 663 | + * to disable this element. |
|
| 664 | + * @return array 2-dimensional array - every element contains 3 subelements (id, name, level) |
|
| 665 | + */ |
|
| 666 | + public function get_target_categories() |
|
| 667 | + { |
|
| 668 | + // - course independent evaluation |
|
| 669 | + // -> movable to root or other course independent categories |
|
| 670 | + // - evaluation inside a course |
|
| 671 | + // -> movable to root, independent categories or categories inside the course |
|
| 672 | + $user = (api_is_platform_admin() ? null : api_get_user_id()); |
|
| 673 | + $targets = array(); |
|
| 674 | + $level = 0; |
|
| 675 | + |
|
| 676 | + $root = array(0, get_lang('RootCat'), $level); |
|
| 677 | + $targets[] = $root; |
|
| 678 | + |
|
| 679 | + if (isset($this->course_code) && !empty($this->course_code)) { |
|
| 680 | + $crscats = Category::load(null,null,$this->course_code,0); |
|
| 681 | + foreach ($crscats as $cat) { |
|
| 682 | + $targets[] = array ($cat->get_id(), $cat->get_name(), $level+1); |
|
| 683 | + $targets = $this->add_target_subcategories($targets, $level+1, $cat->get_id()); |
|
| 684 | + } |
|
| 685 | + } |
|
| 686 | + |
|
| 687 | + $indcats = Category::load(null,$user,0,0); |
|
| 688 | + foreach ($indcats as $cat) { |
|
| 689 | + $targets[] = array ($cat->get_id(), $cat->get_name(), $level+1); |
|
| 690 | + $targets = $this->add_target_subcategories($targets, $level+1, $cat->get_id()); |
|
| 691 | + } |
|
| 692 | + |
|
| 693 | + return $targets; |
|
| 694 | + } |
|
| 695 | + |
|
| 696 | + /** |
|
| 697 | + * Internal function used by get_target_categories() |
|
| 698 | + * @param integer $level |
|
| 699 | + */ |
|
| 700 | + private function add_target_subcategories($targets, $level, $catid) |
|
| 701 | + { |
|
| 702 | + $subcats = Category::load(null,null,null,$catid); |
|
| 703 | + foreach ($subcats as $cat) { |
|
| 704 | + $targets[] = array ($cat->get_id(), $cat->get_name(), $level+1); |
|
| 705 | + $targets = $this->add_target_subcategories($targets, $level+1, $cat->get_id()); |
|
| 706 | + } |
|
| 707 | + return $targets; |
|
| 708 | + } |
|
| 709 | + |
|
| 710 | + /** |
|
| 711 | + * Move this evaluation to the given category. |
|
| 712 | + * If this evaluation moves from inside a course to outside, |
|
| 713 | + * its course code is also changed. |
|
| 714 | + */ |
|
| 715 | + public function move_to_cat($cat) |
|
| 716 | + { |
|
| 717 | + $this->set_category_id($cat->get_id()); |
|
| 718 | + if ($this->get_course_code() != $cat->get_course_code()) { |
|
| 719 | + $this->set_course_code($cat->get_course_code()); |
|
| 720 | + } |
|
| 721 | + $this->save(); |
|
| 722 | + } |
|
| 723 | + |
|
| 724 | + /** |
|
| 725 | + * Retrieve evaluations where a student has results for |
|
| 726 | + * and return them as an array of Evaluation objects |
|
| 727 | + * @param int $cat_id parent category (use 'null' to retrieve them in all categories) |
|
| 728 | + * @param int $stud_id student id |
|
| 729 | + */ |
|
| 730 | + public static function get_evaluations_with_result_for_student($cat_id = null, $stud_id) |
|
| 731 | + { |
|
| 732 | 732 | $em = Database::getManager(); |
| 733 | 733 | $query = $em->createQuery(); |
| 734 | 734 | |
@@ -740,81 +740,81 @@ discard block |
||
| 740 | 740 | ) |
| 741 | 741 | '; |
| 742 | 742 | $queryParams = ['user' => intval($stud_id)]; |
| 743 | - if (!api_is_allowed_to_edit()) { |
|
| 743 | + if (!api_is_allowed_to_edit()) { |
|
| 744 | 744 | $dql .= 'AND ge.visible = 1 '; |
| 745 | - } |
|
| 746 | - if (isset($cat_id)) { |
|
| 745 | + } |
|
| 746 | + if (isset($cat_id)) { |
|
| 747 | 747 | $dql .= 'AND ge.categoryId = :category '; |
| 748 | 748 | $queryParams['category'] = intval($cat_id); |
| 749 | - } else { |
|
| 749 | + } else { |
|
| 750 | 750 | $dql .= 'AND ge.categoryId >= 0 '; |
| 751 | - } |
|
| 751 | + } |
|
| 752 | 752 | |
| 753 | 753 | $result = $query->setParameters($queryParams)->getResult(); |
| 754 | 754 | $alleval = Evaluation::createEvaluationObjectsFromEntities($result); |
| 755 | 755 | |
| 756 | - return $alleval; |
|
| 757 | - } |
|
| 758 | - |
|
| 759 | - /** |
|
| 760 | - * Get a list of students that do not have a result record for this evaluation |
|
| 761 | - */ |
|
| 762 | - public function get_not_subscribed_students($first_letter_user = '') |
|
| 763 | - { |
|
| 764 | - $tbl_user = Database :: get_main_table(TABLE_MAIN_USER); |
|
| 765 | - $tbl_grade_results = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_RESULT); |
|
| 766 | - |
|
| 767 | - $sql = 'SELECT user_id,lastname,firstname,username FROM '.$tbl_user |
|
| 768 | - ." WHERE lastname LIKE '".Database::escape_string($first_letter_user)."%'" |
|
| 769 | - .' AND status = '.STUDENT |
|
| 770 | - .' AND user_id NOT IN' |
|
| 771 | - .' (SELECT user_id FROM '.$tbl_grade_results |
|
| 772 | - .' WHERE evaluation_id = '.intval($this->id) |
|
| 773 | - .' )' |
|
| 774 | - .' ORDER BY lastname'; |
|
| 775 | - |
|
| 776 | - $result = Database::query($sql); |
|
| 777 | - $users = Database::store_result($result); |
|
| 778 | - |
|
| 779 | - return $users; |
|
| 780 | - } |
|
| 781 | - |
|
| 782 | - /** |
|
| 783 | - * Find evaluations by name |
|
| 784 | - * @param string $name_mask search string |
|
| 785 | - * @return array evaluation objects matching the search criterium |
|
| 786 | - * @todo can be written more efficiently using a new (but very complex) sql query |
|
| 787 | - */ |
|
| 788 | - public function find_evaluations($name_mask,$selectcat) |
|
| 789 | - { |
|
| 790 | - $rootcat = Category::load($selectcat); |
|
| 791 | - $evals = $rootcat[0]->get_evaluations((api_is_allowed_to_create_course() ? null : api_get_user_id()), true); |
|
| 792 | - $foundevals = array(); |
|
| 793 | - foreach ($evals as $eval) { |
|
| 794 | - if (!(api_strpos(api_strtolower($eval->get_name()), api_strtolower($name_mask)) === false)) { |
|
| 795 | - $foundevals[] = $eval; |
|
| 796 | - } |
|
| 797 | - } |
|
| 798 | - return $foundevals; |
|
| 799 | - } |
|
| 800 | - |
|
| 801 | - public function get_item_type() |
|
| 802 | - { |
|
| 803 | - return 'E'; |
|
| 804 | - } |
|
| 805 | - |
|
| 806 | - public function get_icon_name() |
|
| 807 | - { |
|
| 808 | - return $this->has_results() ? 'evalnotempty' : 'evalempty'; |
|
| 809 | - } |
|
| 810 | - |
|
| 811 | - /** |
|
| 812 | - * Locks an evaluation, only one who can unlock it is the platform administrator. |
|
| 813 | - * @param int locked 1 or unlocked 0 |
|
| 814 | - * |
|
| 815 | - **/ |
|
| 816 | - function lock($locked) |
|
| 817 | - { |
|
| 756 | + return $alleval; |
|
| 757 | + } |
|
| 758 | + |
|
| 759 | + /** |
|
| 760 | + * Get a list of students that do not have a result record for this evaluation |
|
| 761 | + */ |
|
| 762 | + public function get_not_subscribed_students($first_letter_user = '') |
|
| 763 | + { |
|
| 764 | + $tbl_user = Database :: get_main_table(TABLE_MAIN_USER); |
|
| 765 | + $tbl_grade_results = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_RESULT); |
|
| 766 | + |
|
| 767 | + $sql = 'SELECT user_id,lastname,firstname,username FROM '.$tbl_user |
|
| 768 | + ." WHERE lastname LIKE '".Database::escape_string($first_letter_user)."%'" |
|
| 769 | + .' AND status = '.STUDENT |
|
| 770 | + .' AND user_id NOT IN' |
|
| 771 | + .' (SELECT user_id FROM '.$tbl_grade_results |
|
| 772 | + .' WHERE evaluation_id = '.intval($this->id) |
|
| 773 | + .' )' |
|
| 774 | + .' ORDER BY lastname'; |
|
| 775 | + |
|
| 776 | + $result = Database::query($sql); |
|
| 777 | + $users = Database::store_result($result); |
|
| 778 | + |
|
| 779 | + return $users; |
|
| 780 | + } |
|
| 781 | + |
|
| 782 | + /** |
|
| 783 | + * Find evaluations by name |
|
| 784 | + * @param string $name_mask search string |
|
| 785 | + * @return array evaluation objects matching the search criterium |
|
| 786 | + * @todo can be written more efficiently using a new (but very complex) sql query |
|
| 787 | + */ |
|
| 788 | + public function find_evaluations($name_mask,$selectcat) |
|
| 789 | + { |
|
| 790 | + $rootcat = Category::load($selectcat); |
|
| 791 | + $evals = $rootcat[0]->get_evaluations((api_is_allowed_to_create_course() ? null : api_get_user_id()), true); |
|
| 792 | + $foundevals = array(); |
|
| 793 | + foreach ($evals as $eval) { |
|
| 794 | + if (!(api_strpos(api_strtolower($eval->get_name()), api_strtolower($name_mask)) === false)) { |
|
| 795 | + $foundevals[] = $eval; |
|
| 796 | + } |
|
| 797 | + } |
|
| 798 | + return $foundevals; |
|
| 799 | + } |
|
| 800 | + |
|
| 801 | + public function get_item_type() |
|
| 802 | + { |
|
| 803 | + return 'E'; |
|
| 804 | + } |
|
| 805 | + |
|
| 806 | + public function get_icon_name() |
|
| 807 | + { |
|
| 808 | + return $this->has_results() ? 'evalnotempty' : 'evalempty'; |
|
| 809 | + } |
|
| 810 | + |
|
| 811 | + /** |
|
| 812 | + * Locks an evaluation, only one who can unlock it is the platform administrator. |
|
| 813 | + * @param int locked 1 or unlocked 0 |
|
| 814 | + * |
|
| 815 | + **/ |
|
| 816 | + function lock($locked) |
|
| 817 | + { |
|
| 818 | 818 | $em = Database::getManager(); |
| 819 | 819 | |
| 820 | 820 | $gradebookEvaluation = $em->find('ChamiloCoreBundle:GradebookEvaluation', $this->id); |
@@ -825,31 +825,31 @@ discard block |
||
| 825 | 825 | $em->persist($gradebookEvaluation); |
| 826 | 826 | $em->flush(); |
| 827 | 827 | } |
| 828 | - } |
|
| 828 | + } |
|
| 829 | 829 | |
| 830 | - function check_lock_permissions() |
|
| 831 | - { |
|
| 832 | - if (api_is_platform_admin()) { |
|
| 833 | - return true; |
|
| 834 | - } else { |
|
| 835 | - if ($this->is_locked()) { |
|
| 836 | - api_not_allowed(); |
|
| 837 | - } |
|
| 838 | - } |
|
| 839 | - } |
|
| 830 | + function check_lock_permissions() |
|
| 831 | + { |
|
| 832 | + if (api_is_platform_admin()) { |
|
| 833 | + return true; |
|
| 834 | + } else { |
|
| 835 | + if ($this->is_locked()) { |
|
| 836 | + api_not_allowed(); |
|
| 837 | + } |
|
| 838 | + } |
|
| 839 | + } |
|
| 840 | 840 | |
| 841 | - function delete_linked_data() |
|
| 842 | - { |
|
| 841 | + function delete_linked_data() |
|
| 842 | + { |
|
| 843 | 843 | |
| 844 | - } |
|
| 844 | + } |
|
| 845 | 845 | |
| 846 | 846 | public function getStudentList() |
| 847 | 847 | { |
| 848 | 848 | return $this->studentList; |
| 849 | 849 | } |
| 850 | 850 | |
| 851 | - public function setStudentList($list) |
|
| 852 | - { |
|
| 853 | - $this->studentList = $list; |
|
| 854 | - } |
|
| 851 | + public function setStudentList($list) |
|
| 852 | + { |
|
| 853 | + $this->studentList = $list; |
|
| 854 | + } |
|
| 855 | 855 | } |