@@ -76,7 +76,7 @@ |
||
| 76 | 76 | |
| 77 | 77 | /** |
| 78 | 78 | * Exports the complete report as an XLS file |
| 79 | - * @return boolean False on error |
|
| 79 | + * @return boolean|null False on error |
|
| 80 | 80 | */ |
| 81 | 81 | public function exportCompleteReportXLS($data) |
| 82 | 82 | { |
@@ -14,7 +14,7 @@ discard block |
||
| 14 | 14 | /** |
| 15 | 15 | * constructor of the class |
| 16 | 16 | */ |
| 17 | - public function __construct($get_questions=false,$get_answers=false) |
|
| 17 | + public function __construct($get_questions = false, $get_answers = false) |
|
| 18 | 18 | { |
| 19 | 19 | } |
| 20 | 20 | |
@@ -36,21 +36,21 @@ discard block |
||
| 36 | 36 | //titles |
| 37 | 37 | |
| 38 | 38 | foreach ($dato[0] as $header_col) { |
| 39 | - if(!empty($header_col)) { |
|
| 40 | - $data .= str_replace("\r\n",' ',api_html_entity_decode(strip_tags($header_col))).';'; |
|
| 39 | + if (!empty($header_col)) { |
|
| 40 | + $data .= str_replace("\r\n", ' ', api_html_entity_decode(strip_tags($header_col))).';'; |
|
| 41 | 41 | } |
| 42 | 42 | } |
| 43 | 43 | |
| 44 | - $data .="\r\n"; |
|
| 44 | + $data .= "\r\n"; |
|
| 45 | 45 | $cant_students = count($dato[1]); |
| 46 | 46 | //print_r($data); exit(); |
| 47 | 47 | |
| 48 | - for($i=0;$i<$cant_students;$i++) { |
|
| 48 | + for ($i = 0; $i < $cant_students; $i++) { |
|
| 49 | 49 | $column = 0; |
| 50 | - foreach($dato[1][$i] as $col_name) { |
|
| 51 | - $data .= str_replace("\r\n",' ',api_html_entity_decode(strip_tags($col_name))).';'; |
|
| 50 | + foreach ($dato[1][$i] as $col_name) { |
|
| 51 | + $data .= str_replace("\r\n", ' ', api_html_entity_decode(strip_tags($col_name))).';'; |
|
| 52 | 52 | } |
| 53 | - $data .="\r\n"; |
|
| 53 | + $data .= "\r\n"; |
|
| 54 | 54 | } |
| 55 | 55 | |
| 56 | 56 | //output the results |
@@ -101,7 +101,7 @@ discard block |
||
| 101 | 101 | for ($i = 0; $i < $cant_students; $i++) { |
| 102 | 102 | $column = 0; |
| 103 | 103 | foreach ($data[1][$i] as $col_name) { |
| 104 | - $worksheet->SetCellValueByColumnAndRow($line,$column, html_entity_decode(strip_tags($col_name))); |
|
| 104 | + $worksheet->SetCellValueByColumnAndRow($line, $column, html_entity_decode(strip_tags($col_name))); |
|
| 105 | 105 | $column++; |
| 106 | 106 | } |
| 107 | 107 | $line++; |
@@ -137,9 +137,9 @@ discard block |
||
| 137 | 137 | 'border_sz' => 20 |
| 138 | 138 | ); |
| 139 | 139 | $lines = 0; |
| 140 | - $values[] = implode("\t",$data[0]); |
|
| 140 | + $values[] = implode("\t", $data[0]); |
|
| 141 | 141 | foreach ($data[1] as $line) { |
| 142 | - $values[] = implode("\t",$line); |
|
| 142 | + $values[] = implode("\t", $line); |
|
| 143 | 143 | $lines++; |
| 144 | 144 | } |
| 145 | 145 | //$data = array(); |
@@ -154,7 +154,7 @@ discard block |
||
| 154 | 154 | // 'right' => 4000, |
| 155 | 155 | // 'left' => 4000 |
| 156 | 156 | ); |
| 157 | - $docx->createDocx($filepath,$paramsPage); |
|
| 157 | + $docx->createDocx($filepath, $paramsPage); |
|
| 158 | 158 | //output the results |
| 159 | 159 | $data = file_get_contents($filepath.'.docx'); |
| 160 | 160 | $len = strlen($data); |
@@ -19,6 +19,7 @@ discard block |
||
| 19 | 19 | * @param int Visibility (0 hidden, 1 shown) |
| 20 | 20 | * @param int Session ID (optional or 0 if not defined) |
| 21 | 21 | * @param int |
| 22 | + * @param integer $resource_type |
|
| 22 | 23 | * @return boolean True on success, false on failure |
| 23 | 24 | */ |
| 24 | 25 | public static function add_resource_to_course_gradebook( |
@@ -117,7 +118,6 @@ discard block |
||
| 117 | 118 | |
| 118 | 119 | /** |
| 119 | 120 | * Builds an img tag for a gradebook item |
| 120 | - * @param string $type value returned by a gradebookitem's get_icon_name() |
|
| 121 | 121 | */ |
| 122 | 122 | public static function build_type_icon_tag($kind, $attributes = array()) |
| 123 | 123 | { |
@@ -382,6 +382,7 @@ discard block |
||
| 382 | 382 | * @param int Resource type (use constants defined in linkfactory.class.php) |
| 383 | 383 | * @param int Resource ID in the corresponding tool |
| 384 | 384 | * @param int Session ID (optional - 0 if not defined) |
| 385 | + * @param integer $resource_type |
|
| 385 | 386 | * @return int false on error or array of resource |
| 386 | 387 | */ |
| 387 | 388 | public static function is_resource_in_course_gradebook($course_code, $resource_type, $resource_id, $session_id = 0) |
@@ -579,6 +580,9 @@ discard block |
||
| 579 | 580 | * @param int The user id |
| 580 | 581 | * @param float The score obtained for certified |
| 581 | 582 | * @param Datetime The date when you obtained the certificate |
| 583 | + * @param integer $cat_id |
|
| 584 | + * @param integer $user_id |
|
| 585 | + * @param string $date_certificate |
|
| 582 | 586 | * @return void() |
| 583 | 587 | */ |
| 584 | 588 | public static function register_user_info_about_certificate($cat_id, $user_id, $score_certificate, $date_certificate) |
@@ -955,7 +959,7 @@ discard block |
||
| 955 | 959 | } |
| 956 | 960 | |
| 957 | 961 | /** |
| 958 | - * @param array $list_values |
|
| 962 | + * @param string[] $list_values |
|
| 959 | 963 | * @return string |
| 960 | 964 | */ |
| 961 | 965 | public static function score_badges($list_values) |
@@ -1015,7 +1019,7 @@ discard block |
||
| 1015 | 1019 | } |
| 1016 | 1020 | |
| 1017 | 1021 | /** |
| 1018 | - * @param $result |
|
| 1022 | + * @param Doctrine\DBAL\Driver\Statement|null $result |
|
| 1019 | 1023 | * @return array |
| 1020 | 1024 | */ |
| 1021 | 1025 | public static function get_user_array_from_sql_result($result) |
@@ -249,7 +249,7 @@ |
||
| 249 | 249 | } |
| 250 | 250 | } |
| 251 | 251 | |
| 252 | - $modify_icons .= '<a href="gradebook_edit_all.php?selectcat=' .$cat->get_id() . '&cidReq=' . $cat->get_course_code() . '&id_session='.$cat->get_session_id().'">' . |
|
| 252 | + $modify_icons .= '<a href="gradebook_edit_all.php?selectcat=' .$cat->get_id() . '&cidReq=' . $cat->get_course_code() . '&id_session='.$cat->get_session_id().'">' . |
|
| 253 | 253 | Display::return_icon( |
| 254 | 254 | 'percentage.png', |
| 255 | 255 | get_lang('EditAllWeights'), |
@@ -77,9 +77,9 @@ discard block |
||
| 77 | 77 | $course_code = Database::escape_string($course_code); |
| 78 | 78 | if (!empty($link_id)) { |
| 79 | 79 | $link_id = intval($link_id); |
| 80 | - $sql = 'UPDATE ' . Database :: get_main_table(TABLE_MAIN_GRADEBOOK_LINK) . ' |
|
| 81 | - SET weight = ' . "'" . Database::escape_string((float) $weight) . "'" . ' |
|
| 82 | - WHERE course_code = "' . $course_code . '" AND id = ' . $link_id; |
|
| 80 | + $sql = 'UPDATE '.Database :: get_main_table(TABLE_MAIN_GRADEBOOK_LINK).' |
|
| 81 | + SET weight = ' . "'".Database::escape_string((float) $weight)."'".' |
|
| 82 | + WHERE course_code = "' . $course_code.'" AND id = '.$link_id; |
|
| 83 | 83 | Database::query($sql); |
| 84 | 84 | } |
| 85 | 85 | |
@@ -99,7 +99,7 @@ discard block |
||
| 99 | 99 | |
| 100 | 100 | // TODO find the corresponding category (the first one for this course, ordered by ID) |
| 101 | 101 | $l = Database::get_main_table(TABLE_MAIN_GRADEBOOK_LINK); |
| 102 | - $sql = "DELETE FROM $l WHERE id = ".(int)$link_id; |
|
| 102 | + $sql = "DELETE FROM $l WHERE id = ".(int) $link_id; |
|
| 103 | 103 | Database::query($sql); |
| 104 | 104 | |
| 105 | 105 | return true; |
@@ -195,8 +195,8 @@ discard block |
||
| 195 | 195 | $visibility_icon = ($cat->is_visible() == 0) ? 'invisible' : 'visible'; |
| 196 | 196 | $visibility_command = ($cat->is_visible() == 0) ? 'set_visible' : 'set_invisible'; |
| 197 | 197 | |
| 198 | - $modify_icons .= '<a class="view_children" data-cat-id="' . $cat->get_id() . '" href="javascript:void(0);">' . |
|
| 199 | - Display::return_icon('view_more_stats.gif', get_lang('Show'), '', ICON_SIZE_SMALL) . '</a>'; |
|
| 198 | + $modify_icons .= '<a class="view_children" data-cat-id="'.$cat->get_id().'" href="javascript:void(0);">'. |
|
| 199 | + Display::return_icon('view_more_stats.gif', get_lang('Show'), '', ICON_SIZE_SMALL).'</a>'; |
|
| 200 | 200 | |
| 201 | 201 | if (!api_is_allowed_to_edit(null, true)) { |
| 202 | 202 | $modify_icons .= Display::url( |
@@ -206,9 +206,9 @@ discard block |
||
| 206 | 206 | '', |
| 207 | 207 | ICON_SIZE_SMALL |
| 208 | 208 | ), |
| 209 | - 'personal_stats.php?' . http_build_query([ |
|
| 209 | + 'personal_stats.php?'.http_build_query([ |
|
| 210 | 210 | 'selectcat' => $cat->get_id() |
| 211 | - ]) . '&' . api_get_cidreq(), |
|
| 211 | + ]).'&'.api_get_cidreq(), |
|
| 212 | 212 | [ |
| 213 | 213 | 'class' => 'ajax', |
| 214 | 214 | 'data-title' => get_lang('FlatView') |
@@ -222,16 +222,16 @@ discard block |
||
| 222 | 222 | if (api_get_setting('gradebook_locking_enabled') == 'true') { |
| 223 | 223 | if ($cat->is_locked()) { |
| 224 | 224 | if (api_is_platform_admin()) { |
| 225 | - $modify_icons .= ' <a onclick="javascript:if (!confirm(\'' . addslashes(get_lang('ConfirmToUnlockElement')) . '\')) return false;" href="' . api_get_self() . '?' . api_get_cidreq() . '&category_id=' . $cat->get_id() . '&action=unlock">' . |
|
| 226 | - Display::return_icon('lock.png', get_lang('UnLockEvaluation'), '', ICON_SIZE_SMALL) . '</a>'; |
|
| 225 | + $modify_icons .= ' <a onclick="javascript:if (!confirm(\''.addslashes(get_lang('ConfirmToUnlockElement')).'\')) return false;" href="'.api_get_self().'?'.api_get_cidreq().'&category_id='.$cat->get_id().'&action=unlock">'. |
|
| 226 | + Display::return_icon('lock.png', get_lang('UnLockEvaluation'), '', ICON_SIZE_SMALL).'</a>'; |
|
| 227 | 227 | } else { |
| 228 | - $modify_icons .= ' <a href="#">' . Display::return_icon('lock_na.png', get_lang('GradebookLockedAlert'), '', ICON_SIZE_SMALL) . '</a>'; |
|
| 228 | + $modify_icons .= ' <a href="#">'.Display::return_icon('lock_na.png', get_lang('GradebookLockedAlert'), '', ICON_SIZE_SMALL).'</a>'; |
|
| 229 | 229 | } |
| 230 | - $modify_icons .= ' <a href="gradebook_flatview.php?export_pdf=category&selectcat=' . $cat->get_id() . '" >' . Display::return_icon('pdf.png', get_lang('ExportToPDF'), '', ICON_SIZE_SMALL) . '</a>'; |
|
| 230 | + $modify_icons .= ' <a href="gradebook_flatview.php?export_pdf=category&selectcat='.$cat->get_id().'" >'.Display::return_icon('pdf.png', get_lang('ExportToPDF'), '', ICON_SIZE_SMALL).'</a>'; |
|
| 231 | 231 | } else { |
| 232 | - $modify_icons .= ' <a onclick="javascript:if (!confirm(\'' . addslashes(get_lang('ConfirmToLockElement')) . '\')) return false;" href="' . api_get_self() . '?' . api_get_cidreq() . '&category_id=' . $cat->get_id() . '&action=lock">' . |
|
| 233 | - Display::return_icon('unlock.png', get_lang('LockEvaluation'), '', ICON_SIZE_SMALL) . '</a>'; |
|
| 234 | - $modify_icons .= ' <a href="#" >' . Display::return_icon('pdf_na.png', get_lang('ExportToPDF'), '', ICON_SIZE_SMALL) . '</a>'; |
|
| 232 | + $modify_icons .= ' <a onclick="javascript:if (!confirm(\''.addslashes(get_lang('ConfirmToLockElement')).'\')) return false;" href="'.api_get_self().'?'.api_get_cidreq().'&category_id='.$cat->get_id().'&action=lock">'. |
|
| 233 | + Display::return_icon('unlock.png', get_lang('LockEvaluation'), '', ICON_SIZE_SMALL).'</a>'; |
|
| 234 | + $modify_icons .= ' <a href="#" >'.Display::return_icon('pdf_na.png', get_lang('ExportToPDF'), '', ICON_SIZE_SMALL).'</a>'; |
|
| 235 | 235 | } |
| 236 | 236 | } |
| 237 | 237 | |
@@ -239,38 +239,38 @@ discard block |
||
| 239 | 239 | if ($cat->is_locked() && !api_is_platform_admin()) { |
| 240 | 240 | $modify_icons .= Display::return_icon('edit_na.png', get_lang('Modify'), '', ICON_SIZE_SMALL); |
| 241 | 241 | } else { |
| 242 | - $modify_icons .= '<a href="gradebook_edit_cat.php?' .'editcat=' . $cat->get_id() . '&cidReq=' .$cat->get_course_code() . '&id_session='.$cat->get_session_id().'">' . |
|
| 242 | + $modify_icons .= '<a href="gradebook_edit_cat.php?'.'editcat='.$cat->get_id().'&cidReq='.$cat->get_course_code().'&id_session='.$cat->get_session_id().'">'. |
|
| 243 | 243 | Display::return_icon( |
| 244 | 244 | 'edit.png', |
| 245 | 245 | get_lang('Modify'), |
| 246 | 246 | '', |
| 247 | 247 | ICON_SIZE_SMALL |
| 248 | - ) . '</a>'; |
|
| 248 | + ).'</a>'; |
|
| 249 | 249 | } |
| 250 | 250 | } |
| 251 | 251 | |
| 252 | - $modify_icons .= '<a href="gradebook_edit_all.php?selectcat=' .$cat->get_id() . '&cidReq=' . $cat->get_course_code() . '&id_session='.$cat->get_session_id().'">' . |
|
| 252 | + $modify_icons .= '<a href="gradebook_edit_all.php?selectcat='.$cat->get_id().'&cidReq='.$cat->get_course_code().'&id_session='.$cat->get_session_id().'">'. |
|
| 253 | 253 | Display::return_icon( |
| 254 | 254 | 'percentage.png', |
| 255 | 255 | get_lang('EditAllWeights'), |
| 256 | 256 | '', |
| 257 | 257 | ICON_SIZE_SMALL |
| 258 | - ) . '</a>'; |
|
| 258 | + ).'</a>'; |
|
| 259 | 259 | |
| 260 | - $modify_icons .= '<a href="gradebook_flatview.php?selectcat=' .$cat->get_id() . '&cidReq=' . $cat->get_course_code() . '&id_session='.$cat->get_session_id(). '">' . |
|
| 260 | + $modify_icons .= '<a href="gradebook_flatview.php?selectcat='.$cat->get_id().'&cidReq='.$cat->get_course_code().'&id_session='.$cat->get_session_id().'">'. |
|
| 261 | 261 | Display::return_icon( |
| 262 | 262 | 'stats.png', |
| 263 | 263 | get_lang('FlatView'), |
| 264 | 264 | '', |
| 265 | 265 | ICON_SIZE_SMALL |
| 266 | - ) . '</a>'; |
|
| 267 | - $modify_icons .= ' <a href="' . api_get_self() .'?visiblecat=' . $cat->get_id() . '&' .$visibility_command . '=&selectcat=' . $selectcat .'&cidReq=' . $cat->get_course_code() . '&id_session='.$cat->get_session_id(). '">' . |
|
| 266 | + ).'</a>'; |
|
| 267 | + $modify_icons .= ' <a href="'.api_get_self().'?visiblecat='.$cat->get_id().'&'.$visibility_command.'=&selectcat='.$selectcat.'&cidReq='.$cat->get_course_code().'&id_session='.$cat->get_session_id().'">'. |
|
| 268 | 268 | Display::return_icon( |
| 269 | - $visibility_icon . '.png', |
|
| 269 | + $visibility_icon.'.png', |
|
| 270 | 270 | get_lang('Visible'), |
| 271 | 271 | '', |
| 272 | 272 | ICON_SIZE_SMALL |
| 273 | - ) . '</a>'; |
|
| 273 | + ).'</a>'; |
|
| 274 | 274 | //no move ability for root categories |
| 275 | 275 | if ($cat->is_movable()) { |
| 276 | 276 | /* $modify_icons .= ' <a href="' . api_get_self() . '?movecat=' . $cat->get_id() . '&selectcat=' . $selectcat . ' &cidReq='.$cat->get_course_code().'"> |
@@ -282,8 +282,8 @@ discard block |
||
| 282 | 282 | if ($cat->is_locked() && !api_is_platform_admin()) { |
| 283 | 283 | $modify_icons .= Display::return_icon('delete_na.png', get_lang('DeleteAll'), '', ICON_SIZE_SMALL); |
| 284 | 284 | } else { |
| 285 | - $modify_icons .= ' <a href="' . api_get_self() . '?deletecat=' . $cat->get_id() . '&selectcat=' . $selectcat . '&cidReq=' . $cat->get_course_code() . '&id_session='.$cat->get_session_id(). '" onclick="return confirmation();">' . |
|
| 286 | - Display::return_icon('delete.png', get_lang('DeleteAll'), '', ICON_SIZE_SMALL) . '</a>'; |
|
| 285 | + $modify_icons .= ' <a href="'.api_get_self().'?deletecat='.$cat->get_id().'&selectcat='.$selectcat.'&cidReq='.$cat->get_course_code().'&id_session='.$cat->get_session_id().'" onclick="return confirmation();">'. |
|
| 286 | + Display::return_icon('delete.png', get_lang('DeleteAll'), '', ICON_SIZE_SMALL).'</a>'; |
|
| 287 | 287 | } |
| 288 | 288 | } |
| 289 | 289 | |
@@ -310,21 +310,21 @@ discard block |
||
| 310 | 310 | if ($is_locked && !api_is_platform_admin()) { |
| 311 | 311 | $modify_icons = Display::return_icon('edit_na.png', get_lang('Modify'), '', ICON_SIZE_SMALL); |
| 312 | 312 | } else { |
| 313 | - $modify_icons = '<a href="gradebook_edit_eval.php?editeval=' . $eval->get_id() . '&cidReq=' . $eval->get_course_code() . '&id_session='.$eval->getSessionId(). '">' . |
|
| 314 | - Display::return_icon('edit.png', get_lang('Modify'), '', ICON_SIZE_SMALL) . '</a>'; |
|
| 313 | + $modify_icons = '<a href="gradebook_edit_eval.php?editeval='.$eval->get_id().'&cidReq='.$eval->get_course_code().'&id_session='.$eval->getSessionId().'">'. |
|
| 314 | + Display::return_icon('edit.png', get_lang('Modify'), '', ICON_SIZE_SMALL).'</a>'; |
|
| 315 | 315 | } |
| 316 | 316 | |
| 317 | - $modify_icons .= ' <a href="' . api_get_self() . '?visibleeval=' . $eval->get_id() . '&' . $visibility_command . '=&selectcat=' . $selectcat . '&id_session='.$eval->getSessionId(). ' ">' . |
|
| 318 | - Display::return_icon($visibility_icon . '.png', get_lang('Visible'), '', ICON_SIZE_SMALL) . '</a>'; |
|
| 317 | + $modify_icons .= ' <a href="'.api_get_self().'?visibleeval='.$eval->get_id().'&'.$visibility_command.'=&selectcat='.$selectcat.'&id_session='.$eval->getSessionId().' ">'. |
|
| 318 | + Display::return_icon($visibility_icon.'.png', get_lang('Visible'), '', ICON_SIZE_SMALL).'</a>'; |
|
| 319 | 319 | if (api_is_allowed_to_edit(null, true)) { |
| 320 | - $modify_icons .= ' <a href="gradebook_showlog_eval.php?visiblelog=' . $eval->get_id() . '&selectcat=' . $selectcat . ' &cidReq=' . $eval->get_course_code() . '&id_session='.$eval->getSessionId(). '">' . |
|
| 321 | - Display::return_icon('history.png', get_lang('GradebookQualifyLog'), '', ICON_SIZE_SMALL) . '</a>'; |
|
| 320 | + $modify_icons .= ' <a href="gradebook_showlog_eval.php?visiblelog='.$eval->get_id().'&selectcat='.$selectcat.' &cidReq='.$eval->get_course_code().'&id_session='.$eval->getSessionId().'">'. |
|
| 321 | + Display::return_icon('history.png', get_lang('GradebookQualifyLog'), '', ICON_SIZE_SMALL).'</a>'; |
|
| 322 | 322 | } |
| 323 | 323 | |
| 324 | 324 | if ($is_locked && !api_is_platform_admin()) { |
| 325 | - $modify_icons .= ' ' . Display::return_icon('delete_na.png', get_lang('Delete'), '', ICON_SIZE_SMALL); |
|
| 325 | + $modify_icons .= ' '.Display::return_icon('delete_na.png', get_lang('Delete'), '', ICON_SIZE_SMALL); |
|
| 326 | 326 | } else { |
| 327 | - $modify_icons .= ' <a href="' . api_get_self() . '?deleteeval=' . $eval->get_id() . '&selectcat=' . $selectcat . ' &cidReq=' . $eval->get_course_code() . '&id_session='.$eval->getSessionId(). '" onclick="return confirmation();">' . Display::return_icon('delete.png', get_lang('Delete'), '', ICON_SIZE_SMALL) . '</a>'; |
|
| 327 | + $modify_icons .= ' <a href="'.api_get_self().'?deleteeval='.$eval->get_id().'&selectcat='.$selectcat.' &cidReq='.$eval->get_course_code().'&id_session='.$eval->getSessionId().'" onclick="return confirmation();">'.Display::return_icon('delete.png', get_lang('Delete'), '', ICON_SIZE_SMALL).'</a>'; |
|
| 328 | 328 | } |
| 329 | 329 | return $modify_icons; |
| 330 | 330 | } |
@@ -354,23 +354,23 @@ discard block |
||
| 354 | 354 | if ($is_locked && !api_is_platform_admin()) { |
| 355 | 355 | $modify_icons = Display::return_icon('edit_na.png', get_lang('Modify'), '', ICON_SIZE_SMALL); |
| 356 | 356 | } else { |
| 357 | - $modify_icons = '<a href="gradebook_edit_link.php?editlink=' . $link->get_id() . '&cidReq=' . $link->get_course_code() . '&id_session='.$link->get_session_id().'">' . |
|
| 358 | - Display::return_icon('edit.png', get_lang('Modify'), '', ICON_SIZE_SMALL) . '</a>'; |
|
| 357 | + $modify_icons = '<a href="gradebook_edit_link.php?editlink='.$link->get_id().'&cidReq='.$link->get_course_code().'&id_session='.$link->get_session_id().'">'. |
|
| 358 | + Display::return_icon('edit.png', get_lang('Modify'), '', ICON_SIZE_SMALL).'</a>'; |
|
| 359 | 359 | } |
| 360 | 360 | |
| 361 | 361 | //$modify_icons .= ' <a href="' . api_get_self() . '?movelink=' . $link->get_id() . '&selectcat=' . $selectcat . '"><img src="../img/deplacer_fichier.gif" border="0" title="' . get_lang('Move') . '" alt="" /></a>'; |
| 362 | - $modify_icons .= ' <a href="' . api_get_self() . '?visiblelink=' . $link->get_id() . '&' . $visibility_command . '=&selectcat=' . $selectcat . '&id_session='.$link->get_session_id(). ' ">' . |
|
| 363 | - Display::return_icon($visibility_icon . '.png', get_lang('Visible'), '', ICON_SIZE_SMALL) . '</a>'; |
|
| 364 | - $modify_icons .= ' <a href="gradebook_showlog_link.php?visiblelink=' . $link->get_id() . '&selectcat=' . $selectcat . '&cidReq=' . $link->get_course_code() . '&id_session='.$link->get_session_id(). '">' . |
|
| 365 | - Display::return_icon('history.png', get_lang('GradebookQualifyLog'), '', ICON_SIZE_SMALL) . '</a>'; |
|
| 362 | + $modify_icons .= ' <a href="'.api_get_self().'?visiblelink='.$link->get_id().'&'.$visibility_command.'=&selectcat='.$selectcat.'&id_session='.$link->get_session_id().' ">'. |
|
| 363 | + Display::return_icon($visibility_icon.'.png', get_lang('Visible'), '', ICON_SIZE_SMALL).'</a>'; |
|
| 364 | + $modify_icons .= ' <a href="gradebook_showlog_link.php?visiblelink='.$link->get_id().'&selectcat='.$selectcat.'&cidReq='.$link->get_course_code().'&id_session='.$link->get_session_id().'">'. |
|
| 365 | + Display::return_icon('history.png', get_lang('GradebookQualifyLog'), '', ICON_SIZE_SMALL).'</a>'; |
|
| 366 | 366 | |
| 367 | 367 | //If a work is added in a gradebook you can only delete the link in the work tool |
| 368 | 368 | |
| 369 | 369 | if ($is_locked && !api_is_platform_admin()) { |
| 370 | - $modify_icons .= ' ' . Display::return_icon('delete_na.png', get_lang('Delete'), '', ICON_SIZE_SMALL); |
|
| 370 | + $modify_icons .= ' '.Display::return_icon('delete_na.png', get_lang('Delete'), '', ICON_SIZE_SMALL); |
|
| 371 | 371 | } else { |
| 372 | - $modify_icons .= ' <a href="' . api_get_self() . '?deletelink=' . $link->get_id() . '&selectcat=' . $selectcat . ' &cidReq=' . $link->get_course_code() . '&id_session='.$link->get_session_id(). '" onclick="return confirmation();">' . |
|
| 373 | - Display::return_icon('delete.png', get_lang('Delete'), '', ICON_SIZE_SMALL) . '</a>'; |
|
| 372 | + $modify_icons .= ' <a href="'.api_get_self().'?deletelink='.$link->get_id().'&selectcat='.$selectcat.' &cidReq='.$link->get_course_code().'&id_session='.$link->get_session_id().'" onclick="return confirmation();">'. |
|
| 373 | + Display::return_icon('delete.png', get_lang('Delete'), '', ICON_SIZE_SMALL).'</a>'; |
|
| 374 | 374 | } |
| 375 | 375 | return $modify_icons; |
| 376 | 376 | } |
@@ -391,8 +391,8 @@ discard block |
||
| 391 | 391 | $sql = "SELECT * FROM $table l |
| 392 | 392 | WHERE |
| 393 | 393 | course_code = '$course_code' AND |
| 394 | - type = ".(int)$resource_type . " AND |
|
| 395 | - ref_id = " . (int)$resource_id; |
|
| 394 | + type = ".(int) $resource_type." AND |
|
| 395 | + ref_id = " . (int) $resource_id; |
|
| 396 | 396 | $res = Database::query($sql); |
| 397 | 397 | |
| 398 | 398 | if (Database::num_rows($res) < 1) { |
@@ -414,7 +414,7 @@ discard block |
||
| 414 | 414 | } |
| 415 | 415 | // TODO find the corresponding category (the first one for this course, ordered by ID) |
| 416 | 416 | $l = Database::get_main_table(TABLE_MAIN_GRADEBOOK_LINK); |
| 417 | - $sql = "SELECT * FROM $l WHERE id = " . (int) $link_id; |
|
| 417 | + $sql = "SELECT * FROM $l WHERE id = ".(int) $link_id; |
|
| 418 | 418 | $res = Database::query($sql); |
| 419 | 419 | $row = array(); |
| 420 | 420 | if (Database::num_rows($res) > 0) { |
@@ -432,10 +432,10 @@ discard block |
||
| 432 | 432 | { |
| 433 | 433 | $course_table = Database::get_main_table(TABLE_MAIN_COURSE); |
| 434 | 434 | $tbl_grade_links = Database::get_main_table(TABLE_MAIN_GRADEBOOK_LINK); |
| 435 | - $sql = 'SELECT c.id FROM ' . $course_table . ' c |
|
| 436 | - INNER JOIN ' . $tbl_grade_links . ' l |
|
| 435 | + $sql = 'SELECT c.id FROM '.$course_table.' c |
|
| 436 | + INNER JOIN ' . $tbl_grade_links.' l |
|
| 437 | 437 | ON c.code = l.course_code |
| 438 | - WHERE l.id=' . intval($id_link) . ' OR l.category_id=' . intval($id_link); |
|
| 438 | + WHERE l.id=' . intval($id_link).' OR l.category_id='.intval($id_link); |
|
| 439 | 439 | $res = Database::query($sql); |
| 440 | 440 | $array = Database::fetch_array($res, 'ASSOC'); |
| 441 | 441 | return $array['id']; |
@@ -544,7 +544,7 @@ discard block |
||
| 544 | 544 | { |
| 545 | 545 | $result = Result :: load($resid); |
| 546 | 546 | if ($importscore > $eval_max) { |
| 547 | - header('Location: gradebook_view_result.php?selecteval=' . Security::remove_XSS($_GET['selecteval']) . '&overwritemax='); |
|
| 547 | + header('Location: gradebook_view_result.php?selecteval='.Security::remove_XSS($_GET['selecteval']).'&overwritemax='); |
|
| 548 | 548 | exit; |
| 549 | 549 | } |
| 550 | 550 | $result[0]->set_score($importscore); |
@@ -585,8 +585,8 @@ discard block |
||
| 585 | 585 | { |
| 586 | 586 | $table = Database::get_main_table(TABLE_MAIN_GRADEBOOK_CERTIFICATE); |
| 587 | 587 | $sql = 'SELECT COUNT(*) as count |
| 588 | - FROM ' . $table . ' gc |
|
| 589 | - WHERE gc.cat_id="' . intval($cat_id) . '" AND user_id="' . intval($user_id) . '" '; |
|
| 588 | + FROM ' . $table.' gc |
|
| 589 | + WHERE gc.cat_id="' . intval($cat_id).'" AND user_id="'.intval($user_id).'" '; |
|
| 590 | 590 | $rs_exist = Database::query($sql); |
| 591 | 591 | $row = Database::fetch_array($rs_exist); |
| 592 | 592 | if ($row['count'] == 0) { |
@@ -609,8 +609,8 @@ discard block |
||
| 609 | 609 | public static function get_certificate_by_user_id($cat_id, $user_id) |
| 610 | 610 | { |
| 611 | 611 | $table_certificate = Database::get_main_table(TABLE_MAIN_GRADEBOOK_CERTIFICATE); |
| 612 | - $sql = 'SELECT * FROM ' . $table_certificate . ' |
|
| 613 | - WHERE cat_id="' . intval($cat_id) . '" AND user_id="' . intval($user_id) . '"'; |
|
| 612 | + $sql = 'SELECT * FROM '.$table_certificate.' |
|
| 613 | + WHERE cat_id="' . intval($cat_id).'" AND user_id="'.intval($user_id).'"'; |
|
| 614 | 614 | |
| 615 | 615 | $result = Database::query($sql); |
| 616 | 616 | $row = Database::fetch_array($result, 'ASSOC'); |
@@ -629,18 +629,18 @@ discard block |
||
| 629 | 629 | $table_certificate = Database::get_main_table(TABLE_MAIN_GRADEBOOK_CERTIFICATE); |
| 630 | 630 | $table_user = Database::get_main_table(TABLE_MAIN_USER); |
| 631 | 631 | $sql = 'SELECT DISTINCT u.user_id, u.lastname, u.firstname, u.username |
| 632 | - FROM ' . $table_user . ' u |
|
| 633 | - INNER JOIN ' . $table_certificate . ' gc |
|
| 632 | + FROM ' . $table_user.' u |
|
| 633 | + INNER JOIN ' . $table_certificate.' gc |
|
| 634 | 634 | ON u.user_id=gc.user_id '; |
| 635 | 635 | if (!is_null($cat_id) && $cat_id > 0) { |
| 636 | - $sql.=' WHERE cat_id=' . intval($cat_id); |
|
| 636 | + $sql .= ' WHERE cat_id='.intval($cat_id); |
|
| 637 | 637 | } |
| 638 | 638 | if (!empty($userList)) { |
| 639 | 639 | $userList = array_map('intval', $userList); |
| 640 | 640 | $userListCondition = implode("','", $userList); |
| 641 | 641 | $sql .= " AND u.user_id IN ('$userListCondition')"; |
| 642 | 642 | } |
| 643 | - $sql.=' ORDER BY u.firstname'; |
|
| 643 | + $sql .= ' ORDER BY u.firstname'; |
|
| 644 | 644 | $rs = Database::query($sql); |
| 645 | 645 | |
| 646 | 646 | $list_users = array(); |
@@ -661,10 +661,10 @@ discard block |
||
| 661 | 661 | { |
| 662 | 662 | $table_certificate = Database::get_main_table(TABLE_MAIN_GRADEBOOK_CERTIFICATE); |
| 663 | 663 | $sql = 'SELECT gc.score_certificate, gc.created_at, gc.path_certificate, gc.cat_id, gc.user_id, gc.id |
| 664 | - FROM ' . $table_certificate . ' gc |
|
| 665 | - WHERE gc.user_id="' . intval($user_id) . '" '; |
|
| 664 | + FROM ' . $table_certificate.' gc |
|
| 665 | + WHERE gc.user_id="' . intval($user_id).'" '; |
|
| 666 | 666 | if (!is_null($cat_id) && $cat_id > 0) { |
| 667 | - $sql.=' AND cat_id=' . intval($cat_id); |
|
| 667 | + $sql .= ' AND cat_id='.intval($cat_id); |
|
| 668 | 668 | } |
| 669 | 669 | |
| 670 | 670 | $rs = Database::query($sql); |
@@ -702,21 +702,21 @@ discard block |
||
| 702 | 702 | $variables = $content_html['variables']; |
| 703 | 703 | } |
| 704 | 704 | |
| 705 | - $path_image = api_get_path(WEB_COURSE_PATH) . api_get_course_path($course_code) . '/document/images/gallery'; |
|
| 705 | + $path_image = api_get_path(WEB_COURSE_PATH).api_get_course_path($course_code).'/document/images/gallery'; |
|
| 706 | 706 | $new_content_html = str_replace('../images/gallery', $path_image, $new_content_html); |
| 707 | 707 | |
| 708 | - $path_image_in_default_course = api_get_path(WEB_CODE_PATH) . 'default_course_document'; |
|
| 708 | + $path_image_in_default_course = api_get_path(WEB_CODE_PATH).'default_course_document'; |
|
| 709 | 709 | $new_content_html = str_replace('/main/default_course_document', $path_image_in_default_course, $new_content_html); |
| 710 | - $new_content_html = str_replace(SYS_CODE_PATH . 'img/', api_get_path(WEB_IMG_PATH), $new_content_html); |
|
| 710 | + $new_content_html = str_replace(SYS_CODE_PATH.'img/', api_get_path(WEB_IMG_PATH), $new_content_html); |
|
| 711 | 711 | |
| 712 | 712 | //add print header |
| 713 | 713 | if ($hide_print_button == false) { |
| 714 | 714 | $print = '<style media="print" type="text/css">#print_div {visibility:hidden;}</style>'; |
| 715 | - $print .= '<a href="javascript:window.print();" style="float:right; padding:4px;" id="print_div"><img src="' . api_get_path(WEB_CODE_PATH) . 'img/printmgr.gif" alt="' . get_lang('Print') . '" /> ' . get_lang('Print') . '</a>'; |
|
| 715 | + $print .= '<a href="javascript:window.print();" style="float:right; padding:4px;" id="print_div"><img src="'.api_get_path(WEB_CODE_PATH).'img/printmgr.gif" alt="'.get_lang('Print').'" /> '.get_lang('Print').'</a>'; |
|
| 716 | 716 | } |
| 717 | 717 | |
| 718 | 718 | // Add header |
| 719 | - $new_content_html = $contentHead. $print . '</head>' . $new_content_html; |
|
| 719 | + $new_content_html = $contentHead.$print.'</head>'.$new_content_html; |
|
| 720 | 720 | |
| 721 | 721 | return array( |
| 722 | 722 | 'content' => $new_content_html, |
@@ -738,9 +738,9 @@ discard block |
||
| 738 | 738 | $session_id = api_get_session_id(); |
| 739 | 739 | |
| 740 | 740 | $t = Database::get_main_table(TABLE_MAIN_GRADEBOOK_CATEGORY); |
| 741 | - $sql = "SELECT * FROM $t WHERE course_code = '" . Database::escape_string($course_code) . "' "; |
|
| 741 | + $sql = "SELECT * FROM $t WHERE course_code = '".Database::escape_string($course_code)."' "; |
|
| 742 | 742 | if (!empty($session_id)) { |
| 743 | - $sql .= " AND session_id = " . (int) $session_id; |
|
| 743 | + $sql .= " AND session_id = ".(int) $session_id; |
|
| 744 | 744 | } else { |
| 745 | 745 | $sql .= " AND (session_id IS NULL OR session_id = 0) "; |
| 746 | 746 | } |
@@ -752,7 +752,7 @@ discard block |
||
| 752 | 752 | if (!empty($session_id)) { |
| 753 | 753 | $my_session_id = api_get_session_id(); |
| 754 | 754 | $s_name = api_get_session_name($my_session_id); |
| 755 | - $cat->set_name($course_code . ' - ' . get_lang('Session') . ' ' . $s_name); |
|
| 755 | + $cat->set_name($course_code.' - '.get_lang('Session').' '.$s_name); |
|
| 756 | 756 | $cat->set_session_id($session_id); |
| 757 | 757 | } else { |
| 758 | 758 | $cat->set_name($course_code); |
@@ -874,13 +874,13 @@ discard block |
||
| 874 | 874 | |
| 875 | 875 | if ($use_grade_model) { |
| 876 | 876 | if ($parent_id == 0) { |
| 877 | - $title = api_strtoupper(get_lang('Average')) . '<br />' . get_lang('Detailed'); |
|
| 877 | + $title = api_strtoupper(get_lang('Average')).'<br />'.get_lang('Detailed'); |
|
| 878 | 878 | } else { |
| 879 | - $title = api_strtoupper(get_lang('Average')) . '<br />' . $cat[0]->get_description() . ' - (' . $cat[0]->get_name() . ')'; |
|
| 879 | + $title = api_strtoupper(get_lang('Average')).'<br />'.$cat[0]->get_description().' - ('.$cat[0]->get_name().')'; |
|
| 880 | 880 | } |
| 881 | 881 | } else { |
| 882 | 882 | if ($parent_id == 0) { |
| 883 | - $title = api_strtoupper(get_lang('Average')) . '<br />' . get_lang('Detailed'); |
|
| 883 | + $title = api_strtoupper(get_lang('Average')).'<br />'.get_lang('Detailed'); |
|
| 884 | 884 | } else { |
| 885 | 885 | $title = api_strtoupper(get_lang('Average')); |
| 886 | 886 | } |
@@ -934,11 +934,11 @@ discard block |
||
| 934 | 934 | } else { |
| 935 | 935 | $column = 0; |
| 936 | 936 | $table->setCellContents($row, $column, get_lang('NoResults')); |
| 937 | - $table->updateCellAttributes($row, $column, 'colspan="' . $columns . '" align="center" class="row_odd"'); |
|
| 937 | + $table->updateCellAttributes($row, $column, 'colspan="'.$columns.'" align="center" class="row_odd"'); |
|
| 938 | 938 | } |
| 939 | 939 | |
| 940 | 940 | $pdfParams = array( |
| 941 | - 'filename' => get_lang('FlatView') . '_' . api_get_utc_datetime(), |
|
| 941 | + 'filename' => get_lang('FlatView').'_'.api_get_utc_datetime(), |
|
| 942 | 942 | 'pdf_title' => $title, |
| 943 | 943 | 'course_code' => $course_code, |
| 944 | 944 | 'add_signatures' => true |
@@ -1023,7 +1023,7 @@ discard block |
||
| 1023 | 1023 | $a_students = array(); |
| 1024 | 1024 | while ($user = Database::fetch_array($result)) { |
| 1025 | 1025 | if (!array_key_exists($user['user_id'], $a_students)) { |
| 1026 | - $a_current_student = array (); |
|
| 1026 | + $a_current_student = array(); |
|
| 1027 | 1027 | $a_current_student[] = $user['user_id']; |
| 1028 | 1028 | $a_current_student[] = $user['username']; |
| 1029 | 1029 | $a_current_student[] = $user['lastname']; |
@@ -1081,7 +1081,7 @@ discard block |
||
| 1081 | 1081 | foreach ($links as $link) { |
| 1082 | 1082 | // links are always in a course |
| 1083 | 1083 | $coursecode = $link->get_course_code(); |
| 1084 | - if (!array_key_exists($coursecode,$coursecodes)) { |
|
| 1084 | + if (!array_key_exists($coursecode, $coursecodes)) { |
|
| 1085 | 1085 | $coursecodes[$coursecode] = '1'; |
| 1086 | 1086 | $users = array_merge($users, GradebookUtils::get_users_in_course($coursecode)); |
| 1087 | 1087 | } |
@@ -1094,7 +1094,7 @@ discard block |
||
| 1094 | 1094 | * Search students matching a given last name and/or first name |
| 1095 | 1095 | * @author Bert Steppé |
| 1096 | 1096 | */ |
| 1097 | - public static function find_students($mask= '') |
|
| 1097 | + public static function find_students($mask = '') |
|
| 1098 | 1098 | { |
| 1099 | 1099 | // students shouldn't be here // don't search if mask empty |
| 1100 | 1100 | if (!api_is_allowed_to_edit() || empty ($mask)) { |
@@ -1105,23 +1105,23 @@ discard block |
||
| 1105 | 1105 | $tbl_user = Database :: get_main_table(TABLE_MAIN_USER); |
| 1106 | 1106 | $tbl_cru = Database :: get_main_table(TABLE_MAIN_COURSE_USER); |
| 1107 | 1107 | $sql = 'SELECT DISTINCT user.user_id, user.lastname, user.firstname, user.email, user.official_code |
| 1108 | - FROM ' . $tbl_user . ' user'; |
|
| 1108 | + FROM ' . $tbl_user.' user'; |
|
| 1109 | 1109 | if (!api_is_platform_admin()) { |
| 1110 | - $sql .= ', ' . $tbl_cru . ' cru'; |
|
| 1110 | + $sql .= ', '.$tbl_cru.' cru'; |
|
| 1111 | 1111 | } |
| 1112 | 1112 | |
| 1113 | - $sql .= ' WHERE user.status = ' . STUDENT; |
|
| 1114 | - $sql .= ' AND (user.lastname LIKE '."'%" . $mask . "%'"; |
|
| 1115 | - $sql .= ' OR user.firstname LIKE '."'%" . $mask . "%')"; |
|
| 1113 | + $sql .= ' WHERE user.status = '.STUDENT; |
|
| 1114 | + $sql .= ' AND (user.lastname LIKE '."'%".$mask."%'"; |
|
| 1115 | + $sql .= ' OR user.firstname LIKE '."'%".$mask."%')"; |
|
| 1116 | 1116 | |
| 1117 | 1117 | if (!api_is_platform_admin()) { |
| 1118 | 1118 | $sql .= ' AND user.user_id = cru.user_id AND |
| 1119 | 1119 | cru.relation_type <> '.COURSE_RELATION_TYPE_RRHH.' AND |
| 1120 | 1120 | cru.c_id in ( |
| 1121 | - SELECT c_id FROM '.$tbl_cru . ' |
|
| 1121 | + SELECT c_id FROM '.$tbl_cru.' |
|
| 1122 | 1122 | WHERE |
| 1123 | - user_id = ' . api_get_user_id() . ' AND |
|
| 1124 | - status = ' . COURSEMANAGER . ' |
|
| 1123 | + user_id = ' . api_get_user_id().' AND |
|
| 1124 | + status = ' . COURSEMANAGER.' |
|
| 1125 | 1125 | ) |
| 1126 | 1126 | '; |
| 1127 | 1127 | } |
@@ -1164,7 +1164,7 @@ discard block |
||
| 1164 | 1164 | $sql = 'SELECT ref_id FROM '.$table_link.' |
| 1165 | 1165 | WHERE id = '.$linkId.' AND type='.LINK_ATTENDANCE; |
| 1166 | 1166 | |
| 1167 | - $rs_attendance = Database::query($sql); |
|
| 1167 | + $rs_attendance = Database::query($sql); |
|
| 1168 | 1168 | if (Database::num_rows($rs_attendance) > 0) { |
| 1169 | 1169 | $row_attendance = Database::fetch_array($rs_attendance); |
| 1170 | 1170 | $sql = 'UPDATE '.$tbl_attendance.' SET attendance_weight ='.$weight.' |
@@ -1250,7 +1250,7 @@ discard block |
||
| 1250 | 1250 | 'course' => $courseInfo['title'], |
| 1251 | 1251 | 'score' => $certificateInfo['score_certificate'], |
| 1252 | 1252 | 'date' => api_format_date($certificateInfo['created_at'], DATE_FORMAT_SHORT), |
| 1253 | - 'link' => api_get_path(WEB_PATH) . "certificates/index.php?id={$certificateInfo['id']}" |
|
| 1253 | + 'link' => api_get_path(WEB_PATH)."certificates/index.php?id={$certificateInfo['id']}" |
|
| 1254 | 1254 | ]; |
| 1255 | 1255 | } |
| 1256 | 1256 | |
@@ -1314,7 +1314,7 @@ discard block |
||
| 1314 | 1314 | 'course' => $course['title'], |
| 1315 | 1315 | 'score' => $certificateInfo['score_certificate'], |
| 1316 | 1316 | 'date' => api_format_date($certificateInfo['created_at'], DATE_FORMAT_SHORT), |
| 1317 | - 'link' => api_get_path(WEB_PATH) . "certificates/index.php?id={$certificateInfo['id']}" |
|
| 1317 | + 'link' => api_get_path(WEB_PATH)."certificates/index.php?id={$certificateInfo['id']}" |
|
| 1318 | 1318 | ]; |
| 1319 | 1319 | } |
| 1320 | 1320 | } |
@@ -45,6 +45,7 @@ discard block |
||
| 45 | 45 | |
| 46 | 46 | /** |
| 47 | 47 | * Get actual array data |
| 48 | + * @param integer $count |
|
| 48 | 49 | * @return array 2-dimensional array - each array contains the elements: |
| 49 | 50 | * 0 ['id'] : user id |
| 50 | 51 | * 1 ['result_id'] : result id |
@@ -130,6 +131,7 @@ discard block |
||
| 130 | 131 | * @param float Current absolute score (max score is taken from $this->evaluation->get_max() |
| 131 | 132 | * @param bool Whether we want the real score (2/4 (50 %)) or the transformation (A, B, C, etc) |
| 132 | 133 | * @param bool Whether we want to ignore the score color |
| 134 | + * @param boolean $realscore |
|
| 133 | 135 | * @result string The score as we want to show it |
| 134 | 136 | */ |
| 135 | 137 | private function get_score_display ($score, $realscore, $ignore_score_color = false) |
@@ -38,7 +38,7 @@ discard block |
||
| 38 | 38 | /** |
| 39 | 39 | * Get total number of results (rows) |
| 40 | 40 | */ |
| 41 | - public function get_total_results_count () |
|
| 41 | + public function get_total_results_count() |
|
| 42 | 42 | { |
| 43 | 43 | return count($this->results); |
| 44 | 44 | } |
@@ -53,12 +53,12 @@ discard block |
||
| 53 | 53 | * 4 ['score'] : student's score |
| 54 | 54 | * 5 ['display'] : custom score display (only if custom scoring enabled) |
| 55 | 55 | */ |
| 56 | - public function get_data ($sorting = 0, $start = 0, $count = null, $ignore_score_color = false, $pdf=false) |
|
| 56 | + public function get_data($sorting = 0, $start = 0, $count = null, $ignore_score_color = false, $pdf = false) |
|
| 57 | 57 | { |
| 58 | 58 | // do some checks on count, redefine if invalid value |
| 59 | 59 | $number_decimals = api_get_setting('gradebook_number_decimals'); |
| 60 | 60 | if (!isset($count)) { |
| 61 | - $count = count ($this->results) - $start; |
|
| 61 | + $count = count($this->results) - $start; |
|
| 62 | 62 | } |
| 63 | 63 | if ($count < 0) { |
| 64 | 64 | $count = 0; |
@@ -66,11 +66,11 @@ discard block |
||
| 66 | 66 | $scoredisplay = ScoreDisplay :: instance(); |
| 67 | 67 | // generate actual data array |
| 68 | 68 | $table = array(); |
| 69 | - foreach($this->results as $result) { |
|
| 69 | + foreach ($this->results as $result) { |
|
| 70 | 70 | $user = array(); |
| 71 | 71 | $info = api_get_user_info($result->get_user_id()); |
| 72 | 72 | $user['id'] = $result->get_user_id(); |
| 73 | - if ($pdf){ |
|
| 73 | + if ($pdf) { |
|
| 74 | 74 | $user['username'] = $info['username']; |
| 75 | 75 | } |
| 76 | 76 | $user['result_id'] = $result->get_id(); |
@@ -92,7 +92,7 @@ discard block |
||
| 92 | 92 | true |
| 93 | 93 | ) |
| 94 | 94 | ); |
| 95 | - if ($pdf && $number_decimals == null){ |
|
| 95 | + if ($pdf && $number_decimals == null) { |
|
| 96 | 96 | $user['scoreletter'] = $result->get_score(); |
| 97 | 97 | } |
| 98 | 98 | if ($scoredisplay->is_custom()) { |
@@ -132,13 +132,13 @@ discard block |
||
| 132 | 132 | * @param bool Whether we want to ignore the score color |
| 133 | 133 | * @result string The score as we want to show it |
| 134 | 134 | */ |
| 135 | - private function get_score_display ($score, $realscore, $ignore_score_color = false) |
|
| 135 | + private function get_score_display($score, $realscore, $ignore_score_color = false) |
|
| 136 | 136 | { |
| 137 | 137 | if ($score != null) { |
| 138 | 138 | $scoredisplay = ScoreDisplay :: instance(); |
| 139 | 139 | $type = SCORE_CUSTOM; |
| 140 | 140 | if ($realscore === true) { |
| 141 | - $type = SCORE_DIV_PERCENT ; |
|
| 141 | + $type = SCORE_DIV_PERCENT; |
|
| 142 | 142 | } |
| 143 | 143 | |
| 144 | 144 | return $scoredisplay->display_score( |
@@ -172,10 +172,10 @@ discard block |
||
| 172 | 172 | } |
| 173 | 173 | } |
| 174 | 174 | |
| 175 | - function sort_by_mask ($item1, $item2) |
|
| 175 | + function sort_by_mask($item1, $item2) |
|
| 176 | 176 | { |
| 177 | - $score1 = (isset($item1['score']) ? array($item1['score'],$this->evaluation->get_max()) : null); |
|
| 178 | - $score2 = (isset($item2['score']) ? array($item2['score'],$this->evaluation->get_max()) : null); |
|
| 177 | + $score1 = (isset($item1['score']) ? array($item1['score'], $this->evaluation->get_max()) : null); |
|
| 178 | + $score2 = (isset($item2['score']) ? array($item2['score'], $this->evaluation->get_max()) : null); |
|
| 179 | 179 | return ScoreDisplay :: compare_scores_by_custom_display($score1, $score2); |
| 180 | 180 | } |
| 181 | 181 | } |
@@ -232,7 +232,7 @@ discard block |
||
| 232 | 232 | |
| 233 | 233 | /** |
| 234 | 234 | * @param int $category_id |
| 235 | - * @return bool |
|
| 235 | + * @return false|null |
|
| 236 | 236 | */ |
| 237 | 237 | public function insert_defaults($category_id) |
| 238 | 238 | { |
@@ -263,7 +263,7 @@ discard block |
||
| 263 | 263 | } |
| 264 | 264 | |
| 265 | 265 | /** |
| 266 | - * @return int|null|string |
|
| 266 | + * @return integer |
|
| 267 | 267 | */ |
| 268 | 268 | public function get_number_decimals() |
| 269 | 269 | { |
@@ -337,8 +337,8 @@ discard block |
||
| 337 | 337 | |
| 338 | 338 | /** |
| 339 | 339 | * @param $score |
| 340 | - * @param $type |
|
| 341 | - * @return float|string |
|
| 340 | + * @param integer $type |
|
| 341 | + * @return string |
|
| 342 | 342 | */ |
| 343 | 343 | private function display_default($score, $type) |
| 344 | 344 | { |
@@ -34,7 +34,7 @@ discard block |
||
| 34 | 34 | /** |
| 35 | 35 | * Compare the custom display of 2 scores, can be useful in sorting |
| 36 | 36 | */ |
| 37 | - public static function compare_scores_by_custom_display ($score1, $score2) |
|
| 37 | + public static function compare_scores_by_custom_display($score1, $score2) |
|
| 38 | 38 | { |
| 39 | 39 | if (!isset($score1)) { |
| 40 | 40 | return (isset($score2) ? 1 : 0); |
@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | if ($custom1 == $custom2) { |
| 48 | 48 | return 0; |
| 49 | 49 | } else { |
| 50 | - return (($score1[0]/$score1[1]) < ($score2[0]/$score2[1]) ? -1 : 1); |
|
| 50 | + return (($score1[0] / $score1[1]) < ($score2[0] / $score2[1]) ? -1 : 1); |
|
| 51 | 51 | } |
| 52 | 52 | } |
| 53 | 53 | } |
@@ -79,7 +79,7 @@ discard block |
||
| 79 | 79 | //Setting custom enabled |
| 80 | 80 | $value = api_get_setting('gradebook_score_display_custom'); |
| 81 | 81 | $value = $value['my_display_custom']; |
| 82 | - $this->custom_enabled = $value == 'true' ? true : false; |
|
| 82 | + $this->custom_enabled = $value == 'true' ? true : false; |
|
| 83 | 83 | |
| 84 | 84 | if ($this->custom_enabled) { |
| 85 | 85 | $params = array('category = ?' => array('Gradebook')); |
@@ -96,10 +96,10 @@ discard block |
||
| 96 | 96 | sort($portal_displays); |
| 97 | 97 | } |
| 98 | 98 | $this->custom_display = $portal_displays; |
| 99 | - if (count($this->custom_display)>0) { |
|
| 99 | + if (count($this->custom_display) > 0) { |
|
| 100 | 100 | $value = api_get_setting('gradebook_score_display_upperlimit'); |
| 101 | 101 | $value = $value['my_display_upperlimit']; |
| 102 | - $this->upperlimit_included = $value == 'true' ? true : false; |
|
| 102 | + $this->upperlimit_included = $value == 'true' ? true : false; |
|
| 103 | 103 | $this->custom_display_conv = $this->convert_displays($this->custom_display); |
| 104 | 104 | } |
| 105 | 105 | } |
@@ -110,7 +110,7 @@ discard block |
||
| 110 | 110 | //Load course settings |
| 111 | 111 | if ($this->custom_enabled) { |
| 112 | 112 | $this->custom_display = $this->get_custom_displays(); |
| 113 | - if (count($this->custom_display)> 0) { |
|
| 113 | + if (count($this->custom_display) > 0) { |
|
| 114 | 114 | $this->custom_display_conv = $this->convert_displays($this->custom_display); |
| 115 | 115 | } |
| 116 | 116 | } |
@@ -182,7 +182,7 @@ discard block |
||
| 182 | 182 | } |
| 183 | 183 | |
| 184 | 184 | $sql = 'SELECT id FROM '.$tbl_gradebook_category.' |
| 185 | - WHERE course_code = "'.$curr_course_code.'" '. $session_condition; |
|
| 185 | + WHERE course_code = "'.$curr_course_code.'" '.$session_condition; |
|
| 186 | 186 | $rs = Database::query($sql); |
| 187 | 187 | $category_id = 0; |
| 188 | 188 | if (Database::num_rows($rs) > 0) { |
@@ -251,7 +251,7 @@ discard block |
||
| 251 | 251 | ); |
| 252 | 252 | |
| 253 | 253 | $tbl_display = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_SCORE_DISPLAY); |
| 254 | - foreach($display as $value => $text) { |
|
| 254 | + foreach ($display as $value => $text) { |
|
| 255 | 255 | $params = array( |
| 256 | 256 | 'score' => $value, |
| 257 | 257 | 'display' => $text, |
@@ -307,7 +307,7 @@ discard block |
||
| 307 | 307 | $my_score = $score == 0 ? 1 : $score; |
| 308 | 308 | |
| 309 | 309 | if ($type == SCORE_BAR) { |
| 310 | - $percentage = $my_score[0]/$my_score[1]*100; |
|
| 310 | + $percentage = $my_score[0] / $my_score[1] * 100; |
|
| 311 | 311 | |
| 312 | 312 | return Display::bar_progress($percentage); |
| 313 | 313 | } |
@@ -348,7 +348,7 @@ discard block |
||
| 348 | 348 | case SCORE_PERCENT : // XX % |
| 349 | 349 | return $this->display_as_percent($score); |
| 350 | 350 | case SCORE_DIV_PERCENT : // X / Y (XX %) |
| 351 | - return $this->display_as_div($score).' (' . $this->display_as_percent($score) . ')'; |
|
| 351 | + return $this->display_as_div($score).' ('.$this->display_as_percent($score).')'; |
|
| 352 | 352 | case SCORE_AVERAGE : // XX % |
| 353 | 353 | return $this->display_as_percent($score); |
| 354 | 354 | case SCORE_DECIMAL : // 0.50 (X/Y) |
@@ -358,7 +358,7 @@ discard block |
||
| 358 | 358 | if (!empty($custom)) { |
| 359 | 359 | $custom = ' - '.$custom; |
| 360 | 360 | } |
| 361 | - return $this->display_as_div($score).' (' . $this->display_as_percent($score) . ')'.$custom; |
|
| 361 | + return $this->display_as_div($score).' ('.$this->display_as_percent($score).')'.$custom; |
|
| 362 | 362 | case SCORE_DIV_SIMPLE_WITH_CUSTOM : // X - Good! |
| 363 | 363 | $custom = $this->display_custom($score); |
| 364 | 364 | |
@@ -410,9 +410,9 @@ discard block |
||
| 410 | 410 | */ |
| 411 | 411 | private function display_as_decimal($score) |
| 412 | 412 | { |
| 413 | - $score_denom = ($score[1]==0) ? 1 : $score[1]; |
|
| 413 | + $score_denom = ($score[1] == 0) ? 1 : $score[1]; |
|
| 414 | 414 | |
| 415 | - return $this->format_score($score[0]/$score_denom); |
|
| 415 | + return $this->format_score($score[0] / $score_denom); |
|
| 416 | 416 | } |
| 417 | 417 | |
| 418 | 418 | /** |
@@ -420,9 +420,9 @@ discard block |
||
| 420 | 420 | */ |
| 421 | 421 | private function display_as_percent($score) |
| 422 | 422 | { |
| 423 | - $score_denom = ($score[1]==0) ? 1 : $score[1]; |
|
| 423 | + $score_denom = ($score[1] == 0) ? 1 : $score[1]; |
|
| 424 | 424 | |
| 425 | - return $this->format_score($score[0]/$score_denom*100) . ' %'; |
|
| 425 | + return $this->format_score($score[0] / $score_denom * 100).' %'; |
|
| 426 | 426 | } |
| 427 | 427 | |
| 428 | 428 | /** |
@@ -438,7 +438,7 @@ discard block |
||
| 438 | 438 | } else { |
| 439 | 439 | $score[0] = isset($score[0]) ? $this->format_score($score[0]) : 0; |
| 440 | 440 | $score[1] = isset($score[1]) ? $this->format_score($score[1]) : 0; |
| 441 | - return $score[0] . ' / ' . $score[1]; |
|
| 441 | + return $score[0].' / '.$score[1]; |
|
| 442 | 442 | } |
| 443 | 443 | } |
| 444 | 444 | |
@@ -448,7 +448,7 @@ discard block |
||
| 448 | 448 | */ |
| 449 | 449 | private function display_custom($score) |
| 450 | 450 | { |
| 451 | - $my_score_denom= ($score[1]==0) ? 1 : $score[1]; |
|
| 451 | + $my_score_denom = ($score[1] == 0) ? 1 : $score[1]; |
|
| 452 | 452 | $scaledscore = $score[0] / $my_score_denom; |
| 453 | 453 | if ($this->upperlimit_included) { |
| 454 | 454 | foreach ($this->custom_display_conv as $displayitem) { |
@@ -512,7 +512,7 @@ discard block |
||
| 512 | 512 | ORDER BY score'; |
| 513 | 513 | $result = Database::query($sql); |
| 514 | 514 | |
| 515 | - return Database::store_result($result,'ASSOC'); |
|
| 515 | + return Database::store_result($result, 'ASSOC'); |
|
| 516 | 516 | } |
| 517 | 517 | |
| 518 | 518 | /** |
@@ -72,6 +72,7 @@ discard block |
||
| 72 | 72 | |
| 73 | 73 | /** |
| 74 | 74 | * Get actual array data |
| 75 | + * @param integer $count |
|
| 75 | 76 | * @return array 2-dimensional array - each array contains the elements: |
| 76 | 77 | * 0: eval/link object |
| 77 | 78 | * 1: item name |
@@ -285,7 +286,7 @@ discard block |
||
| 285 | 286 | |
| 286 | 287 | /** |
| 287 | 288 | * @param $item |
| 288 | - * @param $ignore_score_color |
|
| 289 | + * @param boolean $ignore_score_color |
|
| 289 | 290 | * @return string |
| 290 | 291 | */ |
| 291 | 292 | private function build_average_column($item, $ignore_score_color) |
@@ -306,7 +307,7 @@ discard block |
||
| 306 | 307 | |
| 307 | 308 | /** |
| 308 | 309 | * @param $item |
| 309 | - * @param $ignore_score_color |
|
| 310 | + * @param boolean $ignore_score_color |
|
| 310 | 311 | * @return string |
| 311 | 312 | */ |
| 312 | 313 | private function build_result_column($item, $ignore_score_color) |
@@ -323,7 +324,7 @@ discard block |
||
| 323 | 324 | |
| 324 | 325 | /** |
| 325 | 326 | * @param $item |
| 326 | - * @param $ignore_score_color |
|
| 327 | + * @param boolean $ignore_score_color |
|
| 327 | 328 | * @return string |
| 328 | 329 | */ |
| 329 | 330 | private function build_mask_column($item, $ignore_score_color) |
@@ -339,7 +340,7 @@ discard block |
||
| 339 | 340 | |
| 340 | 341 | /** |
| 341 | 342 | * @param $coursecode |
| 342 | - * @return mixed |
|
| 343 | + * @return string |
|
| 343 | 344 | */ |
| 344 | 345 | private function get_course_name_from_code_cached($coursecode) |
| 345 | 346 | { |
@@ -10,28 +10,28 @@ discard block |
||
| 10 | 10 | */ |
| 11 | 11 | class UserDataGenerator |
| 12 | 12 | { |
| 13 | - // Sorting types constants |
|
| 14 | - const UDG_SORT_TYPE = 1; |
|
| 15 | - const UDG_SORT_NAME = 2; |
|
| 16 | - const UDG_SORT_COURSE = 4; |
|
| 17 | - const UDG_SORT_CATEGORY = 8; |
|
| 18 | - const UDG_SORT_AVERAGE = 16; |
|
| 19 | - const UDG_SORT_SCORE = 32; |
|
| 20 | - const UDG_SORT_MASK = 64; |
|
| 21 | - |
|
| 22 | - const UDG_SORT_ASC = 128; |
|
| 23 | - const UDG_SORT_DESC = 256; |
|
| 24 | - |
|
| 25 | - private $items; |
|
| 26 | - private $userid; |
|
| 27 | - |
|
| 28 | - private $coursecodecache; |
|
| 29 | - private $categorycache; |
|
| 30 | - private $scorecache; |
|
| 31 | - private $avgcache; |
|
| 32 | - |
|
| 33 | - public function UserDataGenerator($userid, $evals = array(), $links = array()) |
|
| 34 | - { |
|
| 13 | + // Sorting types constants |
|
| 14 | + const UDG_SORT_TYPE = 1; |
|
| 15 | + const UDG_SORT_NAME = 2; |
|
| 16 | + const UDG_SORT_COURSE = 4; |
|
| 17 | + const UDG_SORT_CATEGORY = 8; |
|
| 18 | + const UDG_SORT_AVERAGE = 16; |
|
| 19 | + const UDG_SORT_SCORE = 32; |
|
| 20 | + const UDG_SORT_MASK = 64; |
|
| 21 | + |
|
| 22 | + const UDG_SORT_ASC = 128; |
|
| 23 | + const UDG_SORT_DESC = 256; |
|
| 24 | + |
|
| 25 | + private $items; |
|
| 26 | + private $userid; |
|
| 27 | + |
|
| 28 | + private $coursecodecache; |
|
| 29 | + private $categorycache; |
|
| 30 | + private $scorecache; |
|
| 31 | + private $avgcache; |
|
| 32 | + |
|
| 33 | + public function UserDataGenerator($userid, $evals = array(), $links = array()) |
|
| 34 | + { |
|
| 35 | 35 | $this->userid = $userid; |
| 36 | 36 | $evals_filtered = array(); |
| 37 | 37 | $result = array(); |
@@ -62,330 +62,330 @@ discard block |
||
| 62 | 62 | $this->avgcache = null; |
| 63 | 63 | } |
| 64 | 64 | |
| 65 | - /** |
|
| 66 | - * Get total number of items (rows) |
|
| 67 | - */ |
|
| 68 | - public function get_total_items_count() |
|
| 69 | - { |
|
| 70 | - return count($this->items); |
|
| 71 | - } |
|
| 72 | - |
|
| 73 | - /** |
|
| 74 | - * Get actual array data |
|
| 75 | - * @return array 2-dimensional array - each array contains the elements: |
|
| 76 | - * 0: eval/link object |
|
| 77 | - * 1: item name |
|
| 78 | - * 2: course name |
|
| 79 | - * 3: category name |
|
| 80 | - * 4: average score |
|
| 81 | - * 5: student's score |
|
| 82 | - * 6: student's score as custom display (only if custom scoring enabled) |
|
| 83 | - */ |
|
| 84 | - public function get_data($sorting = 0, $start = 0, $count = null, $ignore_score_color = false) |
|
| 85 | - { |
|
| 86 | - // do some checks on count, redefine if invalid value |
|
| 87 | - if (!isset($count)) { |
|
| 88 | - $count = count ($this->items) - $start; |
|
| 89 | - } |
|
| 90 | - if ($count < 0) { |
|
| 91 | - $count = 0; |
|
| 92 | - } |
|
| 93 | - $allitems = $this->items; |
|
| 94 | - |
|
| 95 | - // sort users array |
|
| 96 | - if ($sorting & self :: UDG_SORT_TYPE) { |
|
| 97 | - usort($allitems, array('UserDataGenerator', 'sort_by_type')); |
|
| 98 | - }elseif ($sorting & self :: UDG_SORT_NAME) { |
|
| 99 | - usort($allitems, array('UserDataGenerator', 'sort_by_name')); |
|
| 100 | - } elseif ($sorting & self :: UDG_SORT_COURSE) { |
|
| 101 | - usort($allitems, array('UserDataGenerator', 'sort_by_course')); |
|
| 102 | - } elseif ($sorting & self :: UDG_SORT_CATEGORY) { |
|
| 103 | - usort($allitems, array('UserDataGenerator', 'sort_by_category')); |
|
| 104 | - } elseif ($sorting & self :: UDG_SORT_AVERAGE) { |
|
| 105 | - // if user sorts on average scores, first calculate them and cache them |
|
| 106 | - foreach ($allitems as $item) { |
|
| 107 | - $this->avgcache[$item->get_item_type() . $item->get_id()]= $item->calc_score(); |
|
| 108 | - } |
|
| 109 | - usort($allitems, array('UserDataGenerator', 'sort_by_average')); |
|
| 110 | - } elseif ($sorting & self :: UDG_SORT_SCORE) { |
|
| 111 | - // if user sorts on student's scores, first calculate them and cache them |
|
| 112 | - foreach ($allitems as $item) { |
|
| 113 | - $this->scorecache[$item->get_item_type() . $item->get_id()] |
|
| 114 | - = $item->calc_score($this->userid); |
|
| 115 | - } |
|
| 116 | - usort($allitems, array('UserDataGenerator', 'sort_by_score')); |
|
| 117 | - } elseif ($sorting & self :: UDG_SORT_MASK) { |
|
| 118 | - // if user sorts on student's masks, first calculate scores and cache them |
|
| 119 | - foreach ($allitems as $item) { |
|
| 120 | - $this->scorecache[$item->get_item_type() . $item->get_id()] |
|
| 121 | - = $item->calc_score($this->userid); |
|
| 122 | - } |
|
| 123 | - usort($allitems, array('UserDataGenerator', 'sort_by_mask')); |
|
| 124 | - } |
|
| 125 | - |
|
| 126 | - if ($sorting & self :: UDG_SORT_DESC) { |
|
| 127 | - $allitems = array_reverse($allitems); |
|
| 128 | - } |
|
| 129 | - // select the items we have to display |
|
| 130 | - $visibleitems = array_slice($allitems, $start, $count); |
|
| 131 | - |
|
| 132 | - // fill score cache if not done yet |
|
| 133 | - if (!isset ($this->scorecache)) { |
|
| 134 | - foreach ($visibleitems as $item) { |
|
| 135 | - $this->scorecache[$item->get_item_type() . $item->get_id()] |
|
| 136 | - = $item->calc_score($this->userid); |
|
| 137 | - } |
|
| 138 | - |
|
| 139 | - } |
|
| 140 | - // generate the data to display |
|
| 141 | - $scoredisplay = ScoreDisplay :: instance(); |
|
| 142 | - $data = array(); |
|
| 143 | - foreach ($visibleitems as $item) { |
|
| 144 | - $row = array (); |
|
| 145 | - $row[] = $item; |
|
| 146 | - $row[] = $item->get_name(); |
|
| 147 | - $row[] = $this->build_course_name($item); |
|
| 148 | - $row[] = $this->build_category_name($item); |
|
| 149 | - $row[] = $this->build_average_column($item, $ignore_score_color); |
|
| 150 | - $row[] = $this->build_result_column($item, $ignore_score_color); |
|
| 151 | - if ($scoredisplay->is_custom()) |
|
| 152 | - $row[] = $this->build_mask_column($item, $ignore_score_color); |
|
| 153 | - $data[] = $row; |
|
| 154 | - } |
|
| 155 | - return $data; |
|
| 156 | - } |
|
| 157 | - |
|
| 158 | - /** |
|
| 159 | - * @param $item1 |
|
| 160 | - * @param $item2 |
|
| 161 | - * @return int |
|
| 162 | - */ |
|
| 163 | - function sort_by_type($item1, $item2) |
|
| 164 | - { |
|
| 165 | - if ($item1->get_item_type() == $item2->get_item_type()) { |
|
| 166 | - return $this->sort_by_name($item1,$item2); |
|
| 167 | - } else { |
|
| 168 | - return ($item1->get_item_type() < $item2->get_item_type() ? -1 : 1); |
|
| 169 | - } |
|
| 170 | - } |
|
| 171 | - |
|
| 172 | - /** |
|
| 173 | - * @param $item1 |
|
| 174 | - * @param $item2 |
|
| 175 | - * @return int |
|
| 176 | - */ |
|
| 177 | - function sort_by_course($item1, $item2) |
|
| 178 | - { |
|
| 179 | - $name1 = api_strtolower($this->get_course_name_from_code_cached($item1->get_course_code())); |
|
| 180 | - $name2 = api_strtolower($this->get_course_name_from_code_cached($item2->get_course_code())); |
|
| 181 | - return api_strnatcmp($name1, $name2); |
|
| 182 | - } |
|
| 183 | - |
|
| 184 | - /** |
|
| 185 | - * @param $item1 |
|
| 186 | - * @param $item2 |
|
| 187 | - * @return int |
|
| 188 | - */ |
|
| 189 | - function sort_by_category($item1, $item2) |
|
| 190 | - { |
|
| 191 | - $cat1 = $this->get_category_cached($item1->get_category_id()); |
|
| 192 | - $cat2 = $this->get_category_cached($item2->get_category_id()); |
|
| 193 | - $name1 = api_strtolower($this->get_category_name_to_display($cat1)); |
|
| 194 | - $name2 = api_strtolower($this->get_category_name_to_display($cat2)); |
|
| 195 | - |
|
| 196 | - return api_strnatcmp($name1, $name2); |
|
| 197 | - } |
|
| 198 | - |
|
| 199 | - /** |
|
| 200 | - * @param $item1 |
|
| 201 | - * @param $item2 |
|
| 202 | - * @return int |
|
| 203 | - */ |
|
| 204 | - function sort_by_name($item1, $item2) |
|
| 205 | - { |
|
| 206 | - return api_strnatcmp($item1->get_name(),$item2->get_name()); |
|
| 207 | - } |
|
| 208 | - |
|
| 209 | - /** |
|
| 210 | - * @param $item1 |
|
| 211 | - * @param $item2 |
|
| 212 | - * @return int |
|
| 213 | - */ |
|
| 214 | - function sort_by_average($item1, $item2) |
|
| 215 | - { |
|
| 216 | - $score1 = $this->avgcache[$item1->get_item_type() . $item1->get_id()]; |
|
| 217 | - $score2 = $this->avgcache[$item2->get_item_type() . $item2->get_id()]; |
|
| 218 | - |
|
| 219 | - return $this->compare_scores($score1, $score2); |
|
| 220 | - } |
|
| 221 | - |
|
| 222 | - /** |
|
| 223 | - * @param $item1 |
|
| 224 | - * @param $item2 |
|
| 225 | - * @return int |
|
| 226 | - */ |
|
| 227 | - function sort_by_score($item1, $item2) |
|
| 228 | - { |
|
| 229 | - $score1 = $this->scorecache[$item1->get_item_type() . $item1->get_id()]; |
|
| 230 | - $score2 = $this->scorecache[$item2->get_item_type() . $item2->get_id()]; |
|
| 231 | - |
|
| 232 | - return $this->compare_scores($score1, $score2); |
|
| 233 | - } |
|
| 234 | - |
|
| 235 | - /** |
|
| 236 | - * @param $item1 |
|
| 237 | - * @param $item2 |
|
| 238 | - * @return int |
|
| 239 | - */ |
|
| 240 | - function sort_by_mask($item1, $item2) |
|
| 241 | - { |
|
| 242 | - $score1 = $this->scorecache[$item1->get_item_type() . $item1->get_id()]; |
|
| 243 | - $score2 = $this->scorecache[$item2->get_item_type() . $item2->get_id()]; |
|
| 244 | - |
|
| 245 | - return ScoreDisplay :: compare_scores_by_custom_display($score1, $score2); |
|
| 246 | - } |
|
| 247 | - |
|
| 248 | - /** |
|
| 249 | - * @param $score1 |
|
| 250 | - * @param $score2 |
|
| 251 | - * @return int |
|
| 252 | - */ |
|
| 253 | - function compare_scores($score1, $score2) |
|
| 254 | - { |
|
| 255 | - if (!isset($score1)) { |
|
| 256 | - return (isset($score2) ? 1 : 0); |
|
| 257 | - } elseif (!isset($score2)) { |
|
| 258 | - return -1; |
|
| 259 | - } elseif (($score1[0]/$score1[1]) == ($score2[0]/$score2[1])) { |
|
| 260 | - return 0; |
|
| 261 | - } else { |
|
| 262 | - return (($score1[0]/$score1[1]) < ($score2[0]/$score2[1]) ? -1 : 1); |
|
| 263 | - } |
|
| 264 | - } |
|
| 265 | - |
|
| 266 | - /** |
|
| 267 | - * @param $item |
|
| 268 | - * @return mixed |
|
| 269 | - */ |
|
| 270 | - private function build_course_name($item) |
|
| 271 | - { |
|
| 272 | - return $this->get_course_name_from_code_cached($item->get_course_code()); |
|
| 273 | - } |
|
| 274 | - |
|
| 275 | - /** |
|
| 276 | - * @param $item |
|
| 277 | - * @return string |
|
| 278 | - */ |
|
| 279 | - private function build_category_name($item) |
|
| 280 | - { |
|
| 281 | - $cat = $this->get_category_cached($item->get_category_id()); |
|
| 282 | - |
|
| 283 | - return $this->get_category_name_to_display($cat); |
|
| 284 | - } |
|
| 285 | - |
|
| 286 | - /** |
|
| 287 | - * @param $item |
|
| 288 | - * @param $ignore_score_color |
|
| 289 | - * @return string |
|
| 290 | - */ |
|
| 291 | - private function build_average_column($item, $ignore_score_color) |
|
| 292 | - { |
|
| 293 | - if (isset($this->avgcache)) { |
|
| 294 | - $avgscore = $this->avgcache[$item->get_item_type() . $item->get_id()]; |
|
| 295 | - } else { |
|
| 296 | - $avgscore = $item->calc_score(); |
|
| 297 | - } |
|
| 298 | - |
|
| 299 | - $scoredisplay = ScoreDisplay :: instance(); |
|
| 300 | - $displaytype = SCORE_AVERAGE; |
|
| 301 | - /*if ($ignore_score_color) |
|
| 65 | + /** |
|
| 66 | + * Get total number of items (rows) |
|
| 67 | + */ |
|
| 68 | + public function get_total_items_count() |
|
| 69 | + { |
|
| 70 | + return count($this->items); |
|
| 71 | + } |
|
| 72 | + |
|
| 73 | + /** |
|
| 74 | + * Get actual array data |
|
| 75 | + * @return array 2-dimensional array - each array contains the elements: |
|
| 76 | + * 0: eval/link object |
|
| 77 | + * 1: item name |
|
| 78 | + * 2: course name |
|
| 79 | + * 3: category name |
|
| 80 | + * 4: average score |
|
| 81 | + * 5: student's score |
|
| 82 | + * 6: student's score as custom display (only if custom scoring enabled) |
|
| 83 | + */ |
|
| 84 | + public function get_data($sorting = 0, $start = 0, $count = null, $ignore_score_color = false) |
|
| 85 | + { |
|
| 86 | + // do some checks on count, redefine if invalid value |
|
| 87 | + if (!isset($count)) { |
|
| 88 | + $count = count ($this->items) - $start; |
|
| 89 | + } |
|
| 90 | + if ($count < 0) { |
|
| 91 | + $count = 0; |
|
| 92 | + } |
|
| 93 | + $allitems = $this->items; |
|
| 94 | + |
|
| 95 | + // sort users array |
|
| 96 | + if ($sorting & self :: UDG_SORT_TYPE) { |
|
| 97 | + usort($allitems, array('UserDataGenerator', 'sort_by_type')); |
|
| 98 | + }elseif ($sorting & self :: UDG_SORT_NAME) { |
|
| 99 | + usort($allitems, array('UserDataGenerator', 'sort_by_name')); |
|
| 100 | + } elseif ($sorting & self :: UDG_SORT_COURSE) { |
|
| 101 | + usort($allitems, array('UserDataGenerator', 'sort_by_course')); |
|
| 102 | + } elseif ($sorting & self :: UDG_SORT_CATEGORY) { |
|
| 103 | + usort($allitems, array('UserDataGenerator', 'sort_by_category')); |
|
| 104 | + } elseif ($sorting & self :: UDG_SORT_AVERAGE) { |
|
| 105 | + // if user sorts on average scores, first calculate them and cache them |
|
| 106 | + foreach ($allitems as $item) { |
|
| 107 | + $this->avgcache[$item->get_item_type() . $item->get_id()]= $item->calc_score(); |
|
| 108 | + } |
|
| 109 | + usort($allitems, array('UserDataGenerator', 'sort_by_average')); |
|
| 110 | + } elseif ($sorting & self :: UDG_SORT_SCORE) { |
|
| 111 | + // if user sorts on student's scores, first calculate them and cache them |
|
| 112 | + foreach ($allitems as $item) { |
|
| 113 | + $this->scorecache[$item->get_item_type() . $item->get_id()] |
|
| 114 | + = $item->calc_score($this->userid); |
|
| 115 | + } |
|
| 116 | + usort($allitems, array('UserDataGenerator', 'sort_by_score')); |
|
| 117 | + } elseif ($sorting & self :: UDG_SORT_MASK) { |
|
| 118 | + // if user sorts on student's masks, first calculate scores and cache them |
|
| 119 | + foreach ($allitems as $item) { |
|
| 120 | + $this->scorecache[$item->get_item_type() . $item->get_id()] |
|
| 121 | + = $item->calc_score($this->userid); |
|
| 122 | + } |
|
| 123 | + usort($allitems, array('UserDataGenerator', 'sort_by_mask')); |
|
| 124 | + } |
|
| 125 | + |
|
| 126 | + if ($sorting & self :: UDG_SORT_DESC) { |
|
| 127 | + $allitems = array_reverse($allitems); |
|
| 128 | + } |
|
| 129 | + // select the items we have to display |
|
| 130 | + $visibleitems = array_slice($allitems, $start, $count); |
|
| 131 | + |
|
| 132 | + // fill score cache if not done yet |
|
| 133 | + if (!isset ($this->scorecache)) { |
|
| 134 | + foreach ($visibleitems as $item) { |
|
| 135 | + $this->scorecache[$item->get_item_type() . $item->get_id()] |
|
| 136 | + = $item->calc_score($this->userid); |
|
| 137 | + } |
|
| 138 | + |
|
| 139 | + } |
|
| 140 | + // generate the data to display |
|
| 141 | + $scoredisplay = ScoreDisplay :: instance(); |
|
| 142 | + $data = array(); |
|
| 143 | + foreach ($visibleitems as $item) { |
|
| 144 | + $row = array (); |
|
| 145 | + $row[] = $item; |
|
| 146 | + $row[] = $item->get_name(); |
|
| 147 | + $row[] = $this->build_course_name($item); |
|
| 148 | + $row[] = $this->build_category_name($item); |
|
| 149 | + $row[] = $this->build_average_column($item, $ignore_score_color); |
|
| 150 | + $row[] = $this->build_result_column($item, $ignore_score_color); |
|
| 151 | + if ($scoredisplay->is_custom()) |
|
| 152 | + $row[] = $this->build_mask_column($item, $ignore_score_color); |
|
| 153 | + $data[] = $row; |
|
| 154 | + } |
|
| 155 | + return $data; |
|
| 156 | + } |
|
| 157 | + |
|
| 158 | + /** |
|
| 159 | + * @param $item1 |
|
| 160 | + * @param $item2 |
|
| 161 | + * @return int |
|
| 162 | + */ |
|
| 163 | + function sort_by_type($item1, $item2) |
|
| 164 | + { |
|
| 165 | + if ($item1->get_item_type() == $item2->get_item_type()) { |
|
| 166 | + return $this->sort_by_name($item1,$item2); |
|
| 167 | + } else { |
|
| 168 | + return ($item1->get_item_type() < $item2->get_item_type() ? -1 : 1); |
|
| 169 | + } |
|
| 170 | + } |
|
| 171 | + |
|
| 172 | + /** |
|
| 173 | + * @param $item1 |
|
| 174 | + * @param $item2 |
|
| 175 | + * @return int |
|
| 176 | + */ |
|
| 177 | + function sort_by_course($item1, $item2) |
|
| 178 | + { |
|
| 179 | + $name1 = api_strtolower($this->get_course_name_from_code_cached($item1->get_course_code())); |
|
| 180 | + $name2 = api_strtolower($this->get_course_name_from_code_cached($item2->get_course_code())); |
|
| 181 | + return api_strnatcmp($name1, $name2); |
|
| 182 | + } |
|
| 183 | + |
|
| 184 | + /** |
|
| 185 | + * @param $item1 |
|
| 186 | + * @param $item2 |
|
| 187 | + * @return int |
|
| 188 | + */ |
|
| 189 | + function sort_by_category($item1, $item2) |
|
| 190 | + { |
|
| 191 | + $cat1 = $this->get_category_cached($item1->get_category_id()); |
|
| 192 | + $cat2 = $this->get_category_cached($item2->get_category_id()); |
|
| 193 | + $name1 = api_strtolower($this->get_category_name_to_display($cat1)); |
|
| 194 | + $name2 = api_strtolower($this->get_category_name_to_display($cat2)); |
|
| 195 | + |
|
| 196 | + return api_strnatcmp($name1, $name2); |
|
| 197 | + } |
|
| 198 | + |
|
| 199 | + /** |
|
| 200 | + * @param $item1 |
|
| 201 | + * @param $item2 |
|
| 202 | + * @return int |
|
| 203 | + */ |
|
| 204 | + function sort_by_name($item1, $item2) |
|
| 205 | + { |
|
| 206 | + return api_strnatcmp($item1->get_name(),$item2->get_name()); |
|
| 207 | + } |
|
| 208 | + |
|
| 209 | + /** |
|
| 210 | + * @param $item1 |
|
| 211 | + * @param $item2 |
|
| 212 | + * @return int |
|
| 213 | + */ |
|
| 214 | + function sort_by_average($item1, $item2) |
|
| 215 | + { |
|
| 216 | + $score1 = $this->avgcache[$item1->get_item_type() . $item1->get_id()]; |
|
| 217 | + $score2 = $this->avgcache[$item2->get_item_type() . $item2->get_id()]; |
|
| 218 | + |
|
| 219 | + return $this->compare_scores($score1, $score2); |
|
| 220 | + } |
|
| 221 | + |
|
| 222 | + /** |
|
| 223 | + * @param $item1 |
|
| 224 | + * @param $item2 |
|
| 225 | + * @return int |
|
| 226 | + */ |
|
| 227 | + function sort_by_score($item1, $item2) |
|
| 228 | + { |
|
| 229 | + $score1 = $this->scorecache[$item1->get_item_type() . $item1->get_id()]; |
|
| 230 | + $score2 = $this->scorecache[$item2->get_item_type() . $item2->get_id()]; |
|
| 231 | + |
|
| 232 | + return $this->compare_scores($score1, $score2); |
|
| 233 | + } |
|
| 234 | + |
|
| 235 | + /** |
|
| 236 | + * @param $item1 |
|
| 237 | + * @param $item2 |
|
| 238 | + * @return int |
|
| 239 | + */ |
|
| 240 | + function sort_by_mask($item1, $item2) |
|
| 241 | + { |
|
| 242 | + $score1 = $this->scorecache[$item1->get_item_type() . $item1->get_id()]; |
|
| 243 | + $score2 = $this->scorecache[$item2->get_item_type() . $item2->get_id()]; |
|
| 244 | + |
|
| 245 | + return ScoreDisplay :: compare_scores_by_custom_display($score1, $score2); |
|
| 246 | + } |
|
| 247 | + |
|
| 248 | + /** |
|
| 249 | + * @param $score1 |
|
| 250 | + * @param $score2 |
|
| 251 | + * @return int |
|
| 252 | + */ |
|
| 253 | + function compare_scores($score1, $score2) |
|
| 254 | + { |
|
| 255 | + if (!isset($score1)) { |
|
| 256 | + return (isset($score2) ? 1 : 0); |
|
| 257 | + } elseif (!isset($score2)) { |
|
| 258 | + return -1; |
|
| 259 | + } elseif (($score1[0]/$score1[1]) == ($score2[0]/$score2[1])) { |
|
| 260 | + return 0; |
|
| 261 | + } else { |
|
| 262 | + return (($score1[0]/$score1[1]) < ($score2[0]/$score2[1]) ? -1 : 1); |
|
| 263 | + } |
|
| 264 | + } |
|
| 265 | + |
|
| 266 | + /** |
|
| 267 | + * @param $item |
|
| 268 | + * @return mixed |
|
| 269 | + */ |
|
| 270 | + private function build_course_name($item) |
|
| 271 | + { |
|
| 272 | + return $this->get_course_name_from_code_cached($item->get_course_code()); |
|
| 273 | + } |
|
| 274 | + |
|
| 275 | + /** |
|
| 276 | + * @param $item |
|
| 277 | + * @return string |
|
| 278 | + */ |
|
| 279 | + private function build_category_name($item) |
|
| 280 | + { |
|
| 281 | + $cat = $this->get_category_cached($item->get_category_id()); |
|
| 282 | + |
|
| 283 | + return $this->get_category_name_to_display($cat); |
|
| 284 | + } |
|
| 285 | + |
|
| 286 | + /** |
|
| 287 | + * @param $item |
|
| 288 | + * @param $ignore_score_color |
|
| 289 | + * @return string |
|
| 290 | + */ |
|
| 291 | + private function build_average_column($item, $ignore_score_color) |
|
| 292 | + { |
|
| 293 | + if (isset($this->avgcache)) { |
|
| 294 | + $avgscore = $this->avgcache[$item->get_item_type() . $item->get_id()]; |
|
| 295 | + } else { |
|
| 296 | + $avgscore = $item->calc_score(); |
|
| 297 | + } |
|
| 298 | + |
|
| 299 | + $scoredisplay = ScoreDisplay :: instance(); |
|
| 300 | + $displaytype = SCORE_AVERAGE; |
|
| 301 | + /*if ($ignore_score_color) |
|
| 302 | 302 | $displaytype |= SCORE_IGNORE_SPLIT; |
| 303 | 303 | */ |
| 304 | - return $scoredisplay->display_score($avgscore, $displaytype); |
|
| 305 | - } |
|
| 306 | - |
|
| 307 | - /** |
|
| 308 | - * @param $item |
|
| 309 | - * @param $ignore_score_color |
|
| 310 | - * @return string |
|
| 311 | - */ |
|
| 312 | - private function build_result_column($item, $ignore_score_color) |
|
| 313 | - { |
|
| 314 | - $studscore = $this->scorecache[$item->get_item_type() . $item->get_id()]; |
|
| 315 | - $scoredisplay = ScoreDisplay :: instance(); |
|
| 316 | - $displaytype = SCORE_DIV_PERCENT; |
|
| 317 | - if ($ignore_score_color) { |
|
| 318 | - $displaytype |= SCORE_IGNORE_SPLIT; |
|
| 319 | - } |
|
| 320 | - |
|
| 321 | - return $scoredisplay->display_score($studscore, $displaytype, SCORE_ONLY_DEFAULT); |
|
| 322 | - } |
|
| 323 | - |
|
| 324 | - /** |
|
| 325 | - * @param $item |
|
| 326 | - * @param $ignore_score_color |
|
| 327 | - * @return string |
|
| 328 | - */ |
|
| 329 | - private function build_mask_column($item, $ignore_score_color) |
|
| 330 | - { |
|
| 331 | - $studscore = $this->scorecache[$item->get_item_type() . $item->get_id()]; |
|
| 332 | - $scoredisplay = ScoreDisplay :: instance(); |
|
| 333 | - $displaytype = SCORE_DIV_PERCENT; |
|
| 334 | - if ($ignore_score_color) { |
|
| 335 | - $displaytype |= SCORE_IGNORE_SPLIT; |
|
| 336 | - } |
|
| 337 | - return $scoredisplay->display_score($studscore, $displaytype, SCORE_ONLY_CUSTOM); |
|
| 338 | - } |
|
| 339 | - |
|
| 340 | - /** |
|
| 341 | - * @param $coursecode |
|
| 342 | - * @return mixed |
|
| 343 | - */ |
|
| 344 | - private function get_course_name_from_code_cached($coursecode) |
|
| 345 | - { |
|
| 346 | - if (isset ($this->coursecodecache) |
|
| 347 | - && isset ($this->coursecodecache[$coursecode])) { |
|
| 348 | - return $this->coursecodecache[$coursecode]; |
|
| 349 | - } else { |
|
| 350 | - $name = CourseManager::getCourseNameFromCode($coursecode); |
|
| 351 | - $this->coursecodecache[$coursecode] = $name; |
|
| 352 | - return $name; |
|
| 353 | - } |
|
| 354 | - } |
|
| 355 | - |
|
| 356 | - /** |
|
| 357 | - * @param $category_id |
|
| 358 | - * @return null |
|
| 359 | - */ |
|
| 360 | - private function get_category_cached($category_id) |
|
| 361 | - { |
|
| 362 | - if (isset ($this->categorycache) |
|
| 363 | - && isset ($this->categorycache[$category_id])) { |
|
| 364 | - return $this->categorycache[$category_id]; |
|
| 365 | - }else { |
|
| 366 | - $cat = Category::load($category_id); |
|
| 367 | - if (isset($cat)){ |
|
| 368 | - $this->categorycache[$category_id] = $cat[0]; |
|
| 369 | - return $cat[0]; |
|
| 370 | - }else |
|
| 371 | - return null; |
|
| 372 | - } |
|
| 373 | - } |
|
| 374 | - |
|
| 375 | - /** |
|
| 376 | - * @param $cat |
|
| 377 | - * @return string |
|
| 378 | - */ |
|
| 379 | - private function get_category_name_to_display($cat) |
|
| 380 | - { |
|
| 381 | - if (isset($cat)) { |
|
| 382 | - if ($cat->get_parent_id() == '0' || $cat->get_parent_id() == null){ |
|
| 383 | - return ''; |
|
| 384 | - } else { |
|
| 385 | - return $cat->get_name(); |
|
| 386 | - } |
|
| 387 | - } else { |
|
| 388 | - return ''; |
|
| 389 | - } |
|
| 390 | - } |
|
| 304 | + return $scoredisplay->display_score($avgscore, $displaytype); |
|
| 305 | + } |
|
| 306 | + |
|
| 307 | + /** |
|
| 308 | + * @param $item |
|
| 309 | + * @param $ignore_score_color |
|
| 310 | + * @return string |
|
| 311 | + */ |
|
| 312 | + private function build_result_column($item, $ignore_score_color) |
|
| 313 | + { |
|
| 314 | + $studscore = $this->scorecache[$item->get_item_type() . $item->get_id()]; |
|
| 315 | + $scoredisplay = ScoreDisplay :: instance(); |
|
| 316 | + $displaytype = SCORE_DIV_PERCENT; |
|
| 317 | + if ($ignore_score_color) { |
|
| 318 | + $displaytype |= SCORE_IGNORE_SPLIT; |
|
| 319 | + } |
|
| 320 | + |
|
| 321 | + return $scoredisplay->display_score($studscore, $displaytype, SCORE_ONLY_DEFAULT); |
|
| 322 | + } |
|
| 323 | + |
|
| 324 | + /** |
|
| 325 | + * @param $item |
|
| 326 | + * @param $ignore_score_color |
|
| 327 | + * @return string |
|
| 328 | + */ |
|
| 329 | + private function build_mask_column($item, $ignore_score_color) |
|
| 330 | + { |
|
| 331 | + $studscore = $this->scorecache[$item->get_item_type() . $item->get_id()]; |
|
| 332 | + $scoredisplay = ScoreDisplay :: instance(); |
|
| 333 | + $displaytype = SCORE_DIV_PERCENT; |
|
| 334 | + if ($ignore_score_color) { |
|
| 335 | + $displaytype |= SCORE_IGNORE_SPLIT; |
|
| 336 | + } |
|
| 337 | + return $scoredisplay->display_score($studscore, $displaytype, SCORE_ONLY_CUSTOM); |
|
| 338 | + } |
|
| 339 | + |
|
| 340 | + /** |
|
| 341 | + * @param $coursecode |
|
| 342 | + * @return mixed |
|
| 343 | + */ |
|
| 344 | + private function get_course_name_from_code_cached($coursecode) |
|
| 345 | + { |
|
| 346 | + if (isset ($this->coursecodecache) |
|
| 347 | + && isset ($this->coursecodecache[$coursecode])) { |
|
| 348 | + return $this->coursecodecache[$coursecode]; |
|
| 349 | + } else { |
|
| 350 | + $name = CourseManager::getCourseNameFromCode($coursecode); |
|
| 351 | + $this->coursecodecache[$coursecode] = $name; |
|
| 352 | + return $name; |
|
| 353 | + } |
|
| 354 | + } |
|
| 355 | + |
|
| 356 | + /** |
|
| 357 | + * @param $category_id |
|
| 358 | + * @return null |
|
| 359 | + */ |
|
| 360 | + private function get_category_cached($category_id) |
|
| 361 | + { |
|
| 362 | + if (isset ($this->categorycache) |
|
| 363 | + && isset ($this->categorycache[$category_id])) { |
|
| 364 | + return $this->categorycache[$category_id]; |
|
| 365 | + }else { |
|
| 366 | + $cat = Category::load($category_id); |
|
| 367 | + if (isset($cat)){ |
|
| 368 | + $this->categorycache[$category_id] = $cat[0]; |
|
| 369 | + return $cat[0]; |
|
| 370 | + }else |
|
| 371 | + return null; |
|
| 372 | + } |
|
| 373 | + } |
|
| 374 | + |
|
| 375 | + /** |
|
| 376 | + * @param $cat |
|
| 377 | + * @return string |
|
| 378 | + */ |
|
| 379 | + private function get_category_name_to_display($cat) |
|
| 380 | + { |
|
| 381 | + if (isset($cat)) { |
|
| 382 | + if ($cat->get_parent_id() == '0' || $cat->get_parent_id() == null){ |
|
| 383 | + return ''; |
|
| 384 | + } else { |
|
| 385 | + return $cat->get_name(); |
|
| 386 | + } |
|
| 387 | + } else { |
|
| 388 | + return ''; |
|
| 389 | + } |
|
| 390 | + } |
|
| 391 | 391 | } |
@@ -50,9 +50,9 @@ discard block |
||
| 50 | 50 | |
| 51 | 51 | } |
| 52 | 52 | if (count($result) == 0) { |
| 53 | - $evals_filtered=$evals; |
|
| 53 | + $evals_filtered = $evals; |
|
| 54 | 54 | } else { |
| 55 | - $evals_filtered=$evals_filtered_copy; |
|
| 55 | + $evals_filtered = $evals_filtered_copy; |
|
| 56 | 56 | } |
| 57 | 57 | $this->items = array_merge($evals_filtered, $links); |
| 58 | 58 | |
@@ -85,7 +85,7 @@ discard block |
||
| 85 | 85 | { |
| 86 | 86 | // do some checks on count, redefine if invalid value |
| 87 | 87 | if (!isset($count)) { |
| 88 | - $count = count ($this->items) - $start; |
|
| 88 | + $count = count($this->items) - $start; |
|
| 89 | 89 | } |
| 90 | 90 | if ($count < 0) { |
| 91 | 91 | $count = 0; |
@@ -104,20 +104,20 @@ discard block |
||
| 104 | 104 | } elseif ($sorting & self :: UDG_SORT_AVERAGE) { |
| 105 | 105 | // if user sorts on average scores, first calculate them and cache them |
| 106 | 106 | foreach ($allitems as $item) { |
| 107 | - $this->avgcache[$item->get_item_type() . $item->get_id()]= $item->calc_score(); |
|
| 107 | + $this->avgcache[$item->get_item_type().$item->get_id()] = $item->calc_score(); |
|
| 108 | 108 | } |
| 109 | 109 | usort($allitems, array('UserDataGenerator', 'sort_by_average')); |
| 110 | 110 | } elseif ($sorting & self :: UDG_SORT_SCORE) { |
| 111 | 111 | // if user sorts on student's scores, first calculate them and cache them |
| 112 | 112 | foreach ($allitems as $item) { |
| 113 | - $this->scorecache[$item->get_item_type() . $item->get_id()] |
|
| 113 | + $this->scorecache[$item->get_item_type().$item->get_id()] |
|
| 114 | 114 | = $item->calc_score($this->userid); |
| 115 | 115 | } |
| 116 | 116 | usort($allitems, array('UserDataGenerator', 'sort_by_score')); |
| 117 | 117 | } elseif ($sorting & self :: UDG_SORT_MASK) { |
| 118 | 118 | // if user sorts on student's masks, first calculate scores and cache them |
| 119 | 119 | foreach ($allitems as $item) { |
| 120 | - $this->scorecache[$item->get_item_type() . $item->get_id()] |
|
| 120 | + $this->scorecache[$item->get_item_type().$item->get_id()] |
|
| 121 | 121 | = $item->calc_score($this->userid); |
| 122 | 122 | } |
| 123 | 123 | usort($allitems, array('UserDataGenerator', 'sort_by_mask')); |
@@ -132,7 +132,7 @@ discard block |
||
| 132 | 132 | // fill score cache if not done yet |
| 133 | 133 | if (!isset ($this->scorecache)) { |
| 134 | 134 | foreach ($visibleitems as $item) { |
| 135 | - $this->scorecache[$item->get_item_type() . $item->get_id()] |
|
| 135 | + $this->scorecache[$item->get_item_type().$item->get_id()] |
|
| 136 | 136 | = $item->calc_score($this->userid); |
| 137 | 137 | } |
| 138 | 138 | |
@@ -141,7 +141,7 @@ discard block |
||
| 141 | 141 | $scoredisplay = ScoreDisplay :: instance(); |
| 142 | 142 | $data = array(); |
| 143 | 143 | foreach ($visibleitems as $item) { |
| 144 | - $row = array (); |
|
| 144 | + $row = array(); |
|
| 145 | 145 | $row[] = $item; |
| 146 | 146 | $row[] = $item->get_name(); |
| 147 | 147 | $row[] = $this->build_course_name($item); |
@@ -163,7 +163,7 @@ discard block |
||
| 163 | 163 | function sort_by_type($item1, $item2) |
| 164 | 164 | { |
| 165 | 165 | if ($item1->get_item_type() == $item2->get_item_type()) { |
| 166 | - return $this->sort_by_name($item1,$item2); |
|
| 166 | + return $this->sort_by_name($item1, $item2); |
|
| 167 | 167 | } else { |
| 168 | 168 | return ($item1->get_item_type() < $item2->get_item_type() ? -1 : 1); |
| 169 | 169 | } |
@@ -203,7 +203,7 @@ discard block |
||
| 203 | 203 | */ |
| 204 | 204 | function sort_by_name($item1, $item2) |
| 205 | 205 | { |
| 206 | - return api_strnatcmp($item1->get_name(),$item2->get_name()); |
|
| 206 | + return api_strnatcmp($item1->get_name(), $item2->get_name()); |
|
| 207 | 207 | } |
| 208 | 208 | |
| 209 | 209 | /** |
@@ -213,8 +213,8 @@ discard block |
||
| 213 | 213 | */ |
| 214 | 214 | function sort_by_average($item1, $item2) |
| 215 | 215 | { |
| 216 | - $score1 = $this->avgcache[$item1->get_item_type() . $item1->get_id()]; |
|
| 217 | - $score2 = $this->avgcache[$item2->get_item_type() . $item2->get_id()]; |
|
| 216 | + $score1 = $this->avgcache[$item1->get_item_type().$item1->get_id()]; |
|
| 217 | + $score2 = $this->avgcache[$item2->get_item_type().$item2->get_id()]; |
|
| 218 | 218 | |
| 219 | 219 | return $this->compare_scores($score1, $score2); |
| 220 | 220 | } |
@@ -226,8 +226,8 @@ discard block |
||
| 226 | 226 | */ |
| 227 | 227 | function sort_by_score($item1, $item2) |
| 228 | 228 | { |
| 229 | - $score1 = $this->scorecache[$item1->get_item_type() . $item1->get_id()]; |
|
| 230 | - $score2 = $this->scorecache[$item2->get_item_type() . $item2->get_id()]; |
|
| 229 | + $score1 = $this->scorecache[$item1->get_item_type().$item1->get_id()]; |
|
| 230 | + $score2 = $this->scorecache[$item2->get_item_type().$item2->get_id()]; |
|
| 231 | 231 | |
| 232 | 232 | return $this->compare_scores($score1, $score2); |
| 233 | 233 | } |
@@ -239,8 +239,8 @@ discard block |
||
| 239 | 239 | */ |
| 240 | 240 | function sort_by_mask($item1, $item2) |
| 241 | 241 | { |
| 242 | - $score1 = $this->scorecache[$item1->get_item_type() . $item1->get_id()]; |
|
| 243 | - $score2 = $this->scorecache[$item2->get_item_type() . $item2->get_id()]; |
|
| 242 | + $score1 = $this->scorecache[$item1->get_item_type().$item1->get_id()]; |
|
| 243 | + $score2 = $this->scorecache[$item2->get_item_type().$item2->get_id()]; |
|
| 244 | 244 | |
| 245 | 245 | return ScoreDisplay :: compare_scores_by_custom_display($score1, $score2); |
| 246 | 246 | } |
@@ -256,10 +256,10 @@ discard block |
||
| 256 | 256 | return (isset($score2) ? 1 : 0); |
| 257 | 257 | } elseif (!isset($score2)) { |
| 258 | 258 | return -1; |
| 259 | - } elseif (($score1[0]/$score1[1]) == ($score2[0]/$score2[1])) { |
|
| 259 | + } elseif (($score1[0] / $score1[1]) == ($score2[0] / $score2[1])) { |
|
| 260 | 260 | return 0; |
| 261 | 261 | } else { |
| 262 | - return (($score1[0]/$score1[1]) < ($score2[0]/$score2[1]) ? -1 : 1); |
|
| 262 | + return (($score1[0] / $score1[1]) < ($score2[0] / $score2[1]) ? -1 : 1); |
|
| 263 | 263 | } |
| 264 | 264 | } |
| 265 | 265 | |
@@ -291,7 +291,7 @@ discard block |
||
| 291 | 291 | private function build_average_column($item, $ignore_score_color) |
| 292 | 292 | { |
| 293 | 293 | if (isset($this->avgcache)) { |
| 294 | - $avgscore = $this->avgcache[$item->get_item_type() . $item->get_id()]; |
|
| 294 | + $avgscore = $this->avgcache[$item->get_item_type().$item->get_id()]; |
|
| 295 | 295 | } else { |
| 296 | 296 | $avgscore = $item->calc_score(); |
| 297 | 297 | } |
@@ -311,7 +311,7 @@ discard block |
||
| 311 | 311 | */ |
| 312 | 312 | private function build_result_column($item, $ignore_score_color) |
| 313 | 313 | { |
| 314 | - $studscore = $this->scorecache[$item->get_item_type() . $item->get_id()]; |
|
| 314 | + $studscore = $this->scorecache[$item->get_item_type().$item->get_id()]; |
|
| 315 | 315 | $scoredisplay = ScoreDisplay :: instance(); |
| 316 | 316 | $displaytype = SCORE_DIV_PERCENT; |
| 317 | 317 | if ($ignore_score_color) { |
@@ -328,7 +328,7 @@ discard block |
||
| 328 | 328 | */ |
| 329 | 329 | private function build_mask_column($item, $ignore_score_color) |
| 330 | 330 | { |
| 331 | - $studscore = $this->scorecache[$item->get_item_type() . $item->get_id()]; |
|
| 331 | + $studscore = $this->scorecache[$item->get_item_type().$item->get_id()]; |
|
| 332 | 332 | $scoredisplay = ScoreDisplay :: instance(); |
| 333 | 333 | $displaytype = SCORE_DIV_PERCENT; |
| 334 | 334 | if ($ignore_score_color) { |
@@ -362,12 +362,12 @@ discard block |
||
| 362 | 362 | if (isset ($this->categorycache) |
| 363 | 363 | && isset ($this->categorycache[$category_id])) { |
| 364 | 364 | return $this->categorycache[$category_id]; |
| 365 | - }else { |
|
| 365 | + } else { |
|
| 366 | 366 | $cat = Category::load($category_id); |
| 367 | - if (isset($cat)){ |
|
| 367 | + if (isset($cat)) { |
|
| 368 | 368 | $this->categorycache[$category_id] = $cat[0]; |
| 369 | 369 | return $cat[0]; |
| 370 | - }else |
|
| 370 | + } else |
|
| 371 | 371 | return null; |
| 372 | 372 | } |
| 373 | 373 | } |
@@ -379,7 +379,7 @@ discard block |
||
| 379 | 379 | private function get_category_name_to_display($cat) |
| 380 | 380 | { |
| 381 | 381 | if (isset($cat)) { |
| 382 | - if ($cat->get_parent_id() == '0' || $cat->get_parent_id() == null){ |
|
| 382 | + if ($cat->get_parent_id() == '0' || $cat->get_parent_id() == null) { |
|
| 383 | 383 | return ''; |
| 384 | 384 | } else { |
| 385 | 385 | return $cat->get_name(); |
@@ -95,7 +95,7 @@ discard block |
||
| 95 | 95 | // sort users array |
| 96 | 96 | if ($sorting & self :: UDG_SORT_TYPE) { |
| 97 | 97 | usort($allitems, array('UserDataGenerator', 'sort_by_type')); |
| 98 | - }elseif ($sorting & self :: UDG_SORT_NAME) { |
|
| 98 | + } elseif ($sorting & self :: UDG_SORT_NAME) { |
|
| 99 | 99 | usort($allitems, array('UserDataGenerator', 'sort_by_name')); |
| 100 | 100 | } elseif ($sorting & self :: UDG_SORT_COURSE) { |
| 101 | 101 | usort($allitems, array('UserDataGenerator', 'sort_by_course')); |
@@ -148,8 +148,9 @@ discard block |
||
| 148 | 148 | $row[] = $this->build_category_name($item); |
| 149 | 149 | $row[] = $this->build_average_column($item, $ignore_score_color); |
| 150 | 150 | $row[] = $this->build_result_column($item, $ignore_score_color); |
| 151 | - if ($scoredisplay->is_custom()) |
|
| 152 | - $row[] = $this->build_mask_column($item, $ignore_score_color); |
|
| 151 | + if ($scoredisplay->is_custom()) { |
|
| 152 | + $row[] = $this->build_mask_column($item, $ignore_score_color); |
|
| 153 | + } |
|
| 153 | 154 | $data[] = $row; |
| 154 | 155 | } |
| 155 | 156 | return $data; |
@@ -362,13 +363,14 @@ discard block |
||
| 362 | 363 | if (isset ($this->categorycache) |
| 363 | 364 | && isset ($this->categorycache[$category_id])) { |
| 364 | 365 | return $this->categorycache[$category_id]; |
| 365 | - }else { |
|
| 366 | + } else { |
|
| 366 | 367 | $cat = Category::load($category_id); |
| 367 | 368 | if (isset($cat)){ |
| 368 | 369 | $this->categorycache[$category_id] = $cat[0]; |
| 369 | 370 | return $cat[0]; |
| 370 | - }else |
|
| 371 | - return null; |
|
| 371 | + } else { |
|
| 372 | + return null; |
|
| 373 | + } |
|
| 372 | 374 | } |
| 373 | 375 | } |
| 374 | 376 | |
@@ -471,7 +471,7 @@ |
||
| 471 | 471 | * Display a user icon that links to the user page |
| 472 | 472 | * |
| 473 | 473 | * @param integer $user_id the id of the user |
| 474 | - * @return html code |
|
| 474 | + * @return string code |
|
| 475 | 475 | * |
| 476 | 476 | * @author Patrick Cool <[email protected]>, Ghent University, Belgium |
| 477 | 477 | * @version April 2008 |
@@ -10,7 +10,7 @@ discard block |
||
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | 12 | require_once '../inc/global.inc.php'; |
| 13 | -$current_course_tool = TOOL_GROUP; |
|
| 13 | +$current_course_tool = TOOL_GROUP; |
|
| 14 | 14 | |
| 15 | 15 | // Notice for unauthorized people. |
| 16 | 16 | api_protect_course_script(true); |
@@ -69,7 +69,7 @@ discard block |
||
| 69 | 69 | |
| 70 | 70 | echo '<div class="actions">'; |
| 71 | 71 | echo '<a href="group.php">'. |
| 72 | - Display::return_icon('back.png',get_lang('BackToGroupList'),'',ICON_SIZE_MEDIUM). |
|
| 72 | + Display::return_icon('back.png', get_lang('BackToGroupList'), '', ICON_SIZE_MEDIUM). |
|
| 73 | 73 | '</a>'; |
| 74 | 74 | |
| 75 | 75 | /* |
@@ -86,7 +86,7 @@ discard block |
||
| 86 | 86 | */ |
| 87 | 87 | $unsubscribe_group = ''; |
| 88 | 88 | if (GroupManager :: is_self_unregistration_allowed($user_id, $current_group['id'])) { |
| 89 | - $unsubscribe_group = '<a class="btn btn-default" href="'.api_get_self().'?selfUnReg=1" onclick="javascript: if(!confirm('."'".addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES))."'".')) return false;">'. |
|
| 89 | + $unsubscribe_group = '<a class="btn btn-default" href="'.api_get_self().'?selfUnReg=1" onclick="javascript: if(!confirm('."'".addslashes(api_htmlentities(get_lang("ConfirmYourChoice"), ENT_QUOTES))."'".')) return false;">'. |
|
| 90 | 90 | get_lang("StudentUnsubscribe").'</a>'; |
| 91 | 91 | } |
| 92 | 92 | echo ' </div>'; |
@@ -98,8 +98,8 @@ discard block |
||
| 98 | 98 | GroupManager::is_tutor_of_group(api_get_user_id(), api_get_group_id()) |
| 99 | 99 | ) { |
| 100 | 100 | $my_origin = isset($origin) ? $origin : ''; |
| 101 | - $edit_url = '<a href="'.api_get_path(WEB_CODE_PATH).'group/settings.php?'.api_get_cidreq().'&origin='.$my_origin.'">'. |
|
| 102 | - Display::return_icon('edit.png', get_lang('EditGroup'),'',ICON_SIZE_SMALL).'</a>'; |
|
| 101 | + $edit_url = '<a href="'.api_get_path(WEB_CODE_PATH).'group/settings.php?'.api_get_cidreq().'&origin='.$my_origin.'">'. |
|
| 102 | + Display::return_icon('edit.png', get_lang('EditGroup'), '', ICON_SIZE_SMALL).'</a>'; |
|
| 103 | 103 | } |
| 104 | 104 | |
| 105 | 105 | echo Display::page_header( |
@@ -122,7 +122,7 @@ discard block |
||
| 122 | 122 | $forums_of_groups = get_forums_of_group($current_group['id']); |
| 123 | 123 | |
| 124 | 124 | if (is_array($forums_of_groups)) { |
| 125 | - if ($current_group['forum_state'] != GroupManager::TOOL_NOT_AVAILABLE ) { |
|
| 125 | + if ($current_group['forum_state'] != GroupManager::TOOL_NOT_AVAILABLE) { |
|
| 126 | 126 | foreach ($forums_of_groups as $key => $value) { |
| 127 | 127 | |
| 128 | 128 | //*!empty($user_subscribe_to_current_group) && */ |
@@ -134,7 +134,7 @@ discard block |
||
| 134 | 134 | |
| 135 | 135 | $actions_array[] = array( |
| 136 | 136 | 'url' => '../forum/viewforum.php?forum='.$value['forum_id'].'&'.api_get_cidreq().'&origin=group', |
| 137 | - 'content' => Display::return_icon('forum.png', get_lang('Forum').': '.$value['forum_title'] , array(), 32) |
|
| 137 | + 'content' => Display::return_icon('forum.png', get_lang('Forum').': '.$value['forum_title'], array(), 32) |
|
| 138 | 138 | ); |
| 139 | 139 | } |
| 140 | 140 | } |
@@ -212,9 +212,9 @@ discard block |
||
| 212 | 212 | $forums_of_groups = get_forums_of_group($current_group['id']); |
| 213 | 213 | |
| 214 | 214 | if (is_array($forums_of_groups)) { |
| 215 | - if ( $current_group['forum_state'] == GroupManager::TOOL_PUBLIC ) { |
|
| 215 | + if ($current_group['forum_state'] == GroupManager::TOOL_PUBLIC) { |
|
| 216 | 216 | foreach ($forums_of_groups as $key => $value) { |
| 217 | - if ($value['forum_group_public_private'] == 'public' ) { |
|
| 217 | + if ($value['forum_group_public_private'] == 'public') { |
|
| 218 | 218 | $actions_array[] = array( |
| 219 | 219 | 'url' => '../forum/viewforum.php?cidReq='.api_get_course_id().'&forum='.$value['forum_id'].'&gidReq='.Security::remove_XSS($current_group['id']).'&origin=group', |
| 220 | 220 | 'content' => Display::return_icon('forum.png', get_lang('GroupForum'), array(), ICON_SIZE_MEDIUM) |
@@ -265,7 +265,7 @@ discard block |
||
| 265 | 265 | ); |
| 266 | 266 | } |
| 267 | 267 | |
| 268 | - if ($current_group['chat_state'] == GroupManager::TOOL_PUBLIC ) { |
|
| 268 | + if ($current_group['chat_state'] == GroupManager::TOOL_PUBLIC) { |
|
| 269 | 269 | // Link to the chat area of this group |
| 270 | 270 | if (api_get_course_setting('allow_open_chat_window')) { |
| 271 | 271 | $actions_array[] = array( |
@@ -294,7 +294,7 @@ discard block |
||
| 294 | 294 | if (count($tutors) == 0) { |
| 295 | 295 | $tutor_info = get_lang('GroupNoneMasc'); |
| 296 | 296 | } else { |
| 297 | - isset($origin) ? $my_origin = $origin:$my_origin=''; |
|
| 297 | + isset($origin) ? $my_origin = $origin : $my_origin = ''; |
|
| 298 | 298 | $tutor_info .= '<ul class="thumbnails">'; |
| 299 | 299 | foreach ($tutors as $index => $tutor) { |
| 300 | 300 | $userInfo = api_get_user_info($tutor['user_id']); |
@@ -373,7 +373,7 @@ discard block |
||
| 373 | 373 | FROM ".$table_group_user." |
| 374 | 374 | WHERE c_id = $course_id AND group_id='".Database::escape_string($current_group['id'])."'"; |
| 375 | 375 | $result = Database::query($sql); |
| 376 | - $return = Database::fetch_array($result,'ASSOC'); |
|
| 376 | + $return = Database::fetch_array($result, 'ASSOC'); |
|
| 377 | 377 | return $return['number_of_users']; |
| 378 | 378 | } |
| 379 | 379 | |
@@ -394,8 +394,8 @@ discard block |
||
| 394 | 394 | global $current_group; |
| 395 | 395 | |
| 396 | 396 | // Database table definition |
| 397 | - $table_group_user = Database :: get_course_table(TABLE_GROUP_USER); |
|
| 398 | - $table_user = Database :: get_main_table(TABLE_MAIN_USER); |
|
| 397 | + $table_group_user = Database :: get_course_table(TABLE_GROUP_USER); |
|
| 398 | + $table_user = Database :: get_main_table(TABLE_MAIN_USER); |
|
| 399 | 399 | |
| 400 | 400 | $course_id = api_get_course_int_id(); |
| 401 | 401 | |
@@ -189,6 +189,8 @@ |
||
| 189 | 189 | * @param float Timeout |
| 190 | 190 | * @param bool Include HTTP Request headers? |
| 191 | 191 | * @param bool Include HTTP Response headers? |
| 192 | + * @param string $ip |
|
| 193 | + * @return string |
|
| 192 | 194 | */ |
| 193 | 195 | function _http_request($ip, $port = 80, $uri = '/', $getdata = array(), $timeout = 5, $req_hdr = false, $res_hdr = false) |
| 194 | 196 | { |
@@ -50,9 +50,9 @@ discard block |
||
| 50 | 50 | $url = api_remove_trailing_slash(preg_replace('/https?:\/\//i', '', $urlInfo['url'])); |
| 51 | 51 | $cleanUrl = str_replace('/', '-', $url); |
| 52 | 52 | |
| 53 | - $newUrlDir = api_get_path(SYS_APP_PATH) . "home/$cleanUrl/admin/"; |
|
| 53 | + $newUrlDir = api_get_path(SYS_APP_PATH)."home/$cleanUrl/admin/"; |
|
| 54 | 54 | } else { |
| 55 | - $newUrlDir = api_get_path(SYS_APP_PATH) . "home/admin/"; |
|
| 55 | + $newUrlDir = api_get_path(SYS_APP_PATH)."home/admin/"; |
|
| 56 | 56 | } |
| 57 | 57 | |
| 58 | 58 | if (!file_exists($newUrlDir)) { |
@@ -166,15 +166,15 @@ discard block |
||
| 166 | 166 | } |
| 167 | 167 | |
| 168 | 168 | if ($system_version != $version_info) { |
| 169 | - $output = '<br /><span style="color:red">' . get_lang('YourVersionNotUpToDate') . '. '.get_lang('LatestVersionIs').' <b>Chamilo '.$version_info.'</b>. '.get_lang('YourVersionIs').' <b>Chamilo '.$system_version. '</b>. '.str_replace('http://www.chamilo.org', '<a href="http://www.chamilo.org">http://www.chamilo.org</a>', get_lang('PleaseVisitOurWebsite')).'</span>'; |
|
| 169 | + $output = '<br /><span style="color:red">'.get_lang('YourVersionNotUpToDate').'. '.get_lang('LatestVersionIs').' <b>Chamilo '.$version_info.'</b>. '.get_lang('YourVersionIs').' <b>Chamilo '.$system_version.'</b>. '.str_replace('http://www.chamilo.org', '<a href="http://www.chamilo.org">http://www.chamilo.org</a>', get_lang('PleaseVisitOurWebsite')).'</span>'; |
|
| 170 | 170 | } else { |
| 171 | 171 | $output = '<br /><span style="color:green">'.get_lang('VersionUpToDate').': Chamilo '.$version_info.'</span>'; |
| 172 | 172 | } |
| 173 | 173 | } else { |
| 174 | - $output = '<span style="color:red">' . get_lang('ImpossibleToContactVersionServerPleaseTryAgain') . '</span>'; |
|
| 174 | + $output = '<span style="color:red">'.get_lang('ImpossibleToContactVersionServerPleaseTryAgain').'</span>'; |
|
| 175 | 175 | } |
| 176 | 176 | } else { |
| 177 | - $output = '<span style="color:red">' . get_lang('AllowurlfopenIsSetToOff') . '</span>'; |
|
| 177 | + $output = '<span style="color:red">'.get_lang('AllowurlfopenIsSetToOff').'</span>'; |
|
| 178 | 178 | } |
| 179 | 179 | return $output; |
| 180 | 180 | } |
@@ -197,17 +197,17 @@ discard block |
||
| 197 | 197 | $getdata_str = count($getdata) ? '?' : ''; |
| 198 | 198 | |
| 199 | 199 | foreach ($getdata as $k => $v) { |
| 200 | - $getdata_str .= urlencode($k) .'='. urlencode($v) . '&'; |
|
| 200 | + $getdata_str .= urlencode($k).'='.urlencode($v).'&'; |
|
| 201 | 201 | } |
| 202 | 202 | |
| 203 | 203 | $crlf = "\r\n"; |
| 204 | - $req = $verb .' '. $uri . $getdata_str .' HTTP/1.1' . $crlf; |
|
| 205 | - $req .= 'Host: '. $ip . $crlf; |
|
| 206 | - $req .= 'User-Agent: Mozilla/5.0 Firefox/3.6.12' . $crlf; |
|
| 207 | - $req .= 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8' . $crlf; |
|
| 208 | - $req .= 'Accept-Language: en-us,en;q=0.5' . $crlf; |
|
| 209 | - $req .= 'Accept-Encoding: deflate' . $crlf; |
|
| 210 | - $req .= 'Accept-Charset: utf-8;q=0.7,*;q=0.7' . $crlf; |
|
| 204 | + $req = $verb.' '.$uri.$getdata_str.' HTTP/1.1'.$crlf; |
|
| 205 | + $req .= 'Host: '.$ip.$crlf; |
|
| 206 | + $req .= 'User-Agent: Mozilla/5.0 Firefox/3.6.12'.$crlf; |
|
| 207 | + $req .= 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8'.$crlf; |
|
| 208 | + $req .= 'Accept-Language: en-us,en;q=0.5'.$crlf; |
|
| 209 | + $req .= 'Accept-Encoding: deflate'.$crlf; |
|
| 210 | + $req .= 'Accept-Charset: utf-8;q=0.7,*;q=0.7'.$crlf; |
|
| 211 | 211 | |
| 212 | 212 | $req .= $crlf; |
| 213 | 213 | |
@@ -1,8 +1,8 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | /* For licensing terms, see /license.txt */ |
| 3 | 3 | /** |
| 4 | - * Responses to AJAX calls |
|
| 5 | - */ |
|
| 4 | + * Responses to AJAX calls |
|
| 5 | + */ |
|
| 6 | 6 | |
| 7 | 7 | require_once '../global.inc.php'; |
| 8 | 8 | |
@@ -22,7 +22,7 @@ |
||
| 22 | 22 | * a given string |
| 23 | 23 | * @param string String to search for |
| 24 | 24 | * @param int Deprecated param |
| 25 | - * @return string A formatted, xajax answer block |
|
| 25 | + * @return xajaxResponse A formatted, xajax answer block |
|
| 26 | 26 | * @assert () === false |
| 27 | 27 | */ |
| 28 | 28 | function search_courses($needle, $id) |
@@ -1,9 +1,9 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | /* For licensing terms, see /license.txt */ |
| 3 | 3 | /** |
| 4 | - * Definition of the Accessurleditcoursestourl class |
|
| 5 | - * @package chamilo.library |
|
| 6 | - */ |
|
| 4 | + * Definition of the Accessurleditcoursestourl class |
|
| 5 | + * @package chamilo.library |
|
| 6 | + */ |
|
| 7 | 7 | |
| 8 | 8 | /** |
| 9 | 9 | * Access_url_edit_courses_to_url class |
@@ -38,17 +38,17 @@ discard block |
||
| 38 | 38 | $needle = Database::escape_string($needle); |
| 39 | 39 | // search courses where username or firstname or lastname begins likes $needle |
| 40 | 40 | $sql = 'SELECT code, title FROM '.$tbl_course.' u '. |
| 41 | - ' WHERE (title LIKE "'.$needle.'%" '. |
|
| 42 | - ' OR code LIKE "'.$needle.'%" '. |
|
| 43 | - ' ) '. |
|
| 44 | - ' ORDER BY title, code '. |
|
| 45 | - ' LIMIT 11'; |
|
| 41 | + ' WHERE (title LIKE "'.$needle.'%" '. |
|
| 42 | + ' OR code LIKE "'.$needle.'%" '. |
|
| 43 | + ' ) '. |
|
| 44 | + ' ORDER BY title, code '. |
|
| 45 | + ' LIMIT 11'; |
|
| 46 | 46 | $rs = Database::query($sql); |
| 47 | 47 | $i=0; |
| 48 | 48 | while ($course = Database :: fetch_array($rs)) { |
| 49 | 49 | $i++; |
| 50 | 50 | if ($i<=10) { |
| 51 | - $return .= '<a href="javascript: void(0);" onclick="javascript: add_user_to_url(\''.addslashes($course['code']).'\',\''.addslashes($course['title']).' ('.addslashes($course['code']).')'.'\')">'.$course['title'].' ('.$course['code'].')</a><br />'; |
|
| 51 | + $return .= '<a href="javascript: void(0);" onclick="javascript: add_user_to_url(\''.addslashes($course['code']).'\',\''.addslashes($course['title']).' ('.addslashes($course['code']).')'.'\')">'.$course['title'].' ('.$course['code'].')</a><br />'; |
|
| 52 | 52 | } else { |
| 53 | 53 | $return .= '...<br />'; |
| 54 | 54 | } |
@@ -44,17 +44,17 @@ |
||
| 44 | 44 | ORDER BY name, id |
| 45 | 45 | LIMIT 11'; |
| 46 | 46 | $rs = Database::query($sql); |
| 47 | - $i=0; |
|
| 47 | + $i = 0; |
|
| 48 | 48 | while ($session = Database :: fetch_array($rs)) { |
| 49 | 49 | $i++; |
| 50 | - if ($i<=10) { |
|
| 50 | + if ($i <= 10) { |
|
| 51 | 51 | $return .= '<a href="#" onclick="add_user_to_url(\''.addslashes($session['id']).'\',\''.addslashes($session['name']).' ('.addslashes($session['id']).')'.'\')">'.$session['name'].' </a><br />'; |
| 52 | 52 | } else { |
| 53 | 53 | $return .= '...<br />'; |
| 54 | 54 | } |
| 55 | 55 | } |
| 56 | 56 | } |
| 57 | - $xajax_response -> addAssign('ajax_list_courses','innerHTML',api_utf8_encode($return)); |
|
| 57 | + $xajax_response -> addAssign('ajax_list_courses', 'innerHTML', api_utf8_encode($return)); |
|
| 58 | 58 | return $xajax_response; |
| 59 | 59 | } |
| 60 | 60 | } |
@@ -23,7 +23,7 @@ |
||
| 23 | 23 | * search string |
| 24 | 24 | * @param string Search string |
| 25 | 25 | * @param int Deprecated param |
| 26 | - * @return string Xajax response block |
|
| 26 | + * @return xajaxResponse Xajax response block |
|
| 27 | 27 | * @assert () === false |
| 28 | 28 | */ |
| 29 | 29 | function search_users($needle, $id) |
@@ -1,9 +1,9 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | /* For licensing terms, see /license.txt */ |
| 3 | 3 | /** |
| 4 | - * Accessurledituserstourl class definition |
|
| 5 | - * @package chamilo.library |
|
| 6 | - */ |
|
| 4 | + * Accessurledituserstourl class definition |
|
| 5 | + * @package chamilo.library |
|
| 6 | + */ |
|
| 7 | 7 | |
| 8 | 8 | /** |
| 9 | 9 | * Accessurledituserstourl class definition |
@@ -40,11 +40,11 @@ discard block |
||
| 40 | 40 | // search users where username or firstname or lastname begins likes $needle |
| 41 | 41 | $order_clause = api_sort_by_first_name() ? ' ORDER BY firstname, lastname, username' : ' ORDER BY lastname, firstname, username'; |
| 42 | 42 | $sql = 'SELECT u.user_id, username, lastname, firstname FROM '.$tbl_user.' u '. |
| 43 | - ' WHERE (username LIKE "'.$needle.'%" '. |
|
| 44 | - ' OR firstname LIKE "'.$needle.'%" '. |
|
| 45 | - ' OR lastname LIKE "'.$needle.'%") '. |
|
| 43 | + ' WHERE (username LIKE "'.$needle.'%" '. |
|
| 44 | + ' OR firstname LIKE "'.$needle.'%" '. |
|
| 45 | + ' OR lastname LIKE "'.$needle.'%") '. |
|
| 46 | 46 | $order_clause . |
| 47 | - ' LIMIT 11'; |
|
| 47 | + ' LIMIT 11'; |
|
| 48 | 48 | |
| 49 | 49 | $rs = Database::query($sql); |
| 50 | 50 | $i=0; |
@@ -43,22 +43,22 @@ |
||
| 43 | 43 | ' WHERE (username LIKE "'.$needle.'%" '. |
| 44 | 44 | ' OR firstname LIKE "'.$needle.'%" '. |
| 45 | 45 | ' OR lastname LIKE "'.$needle.'%") '. |
| 46 | - $order_clause . |
|
| 46 | + $order_clause. |
|
| 47 | 47 | ' LIMIT 11'; |
| 48 | 48 | |
| 49 | 49 | $rs = Database::query($sql); |
| 50 | - $i=0; |
|
| 50 | + $i = 0; |
|
| 51 | 51 | |
| 52 | 52 | while ($user = Database :: fetch_array($rs)) { |
| 53 | 53 | $i++; |
| 54 | - if ($i<=10) { |
|
| 54 | + if ($i <= 10) { |
|
| 55 | 55 | $return .= '<a href="javascript: void(0);" onclick="javascript: add_user_to_url(\''.addslashes($user['user_id']).'\',\''.api_get_person_name(addslashes($user['firstname']), addslashes($user['lastname'])).' ('.addslashes($user['username']).')'.'\')">'.api_get_person_name($user['firstname'], $user['lastname']).' ('.$user['username'].')</a><br />'; |
| 56 | 56 | } else { |
| 57 | 57 | $return .= '...<br />'; |
| 58 | 58 | } |
| 59 | 59 | } |
| 60 | 60 | } |
| 61 | - $xajax_response -> addAssign('ajax_list_users','innerHTML',api_utf8_encode($return)); |
|
| 61 | + $xajax_response -> addAssign('ajax_list_users', 'innerHTML', api_utf8_encode($return)); |
|
| 62 | 62 | return $xajax_response; |
| 63 | 63 | } |
| 64 | 64 | } |