Conditions | 99 |
Paths | > 20000 |
Total Lines | 618 |
Code Lines | 388 |
Lines | 29 |
Ratio | 4.69 % |
Changes | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | <?php |
||
161 | public function get_table_data($from = 1, $per_page = null, $column = null, $direction = null, $sort = null) |
||
162 | { |
||
163 | //variables load in index.php |
||
164 | global $certificate_min_score; |
||
165 | // determine sorting type |
||
166 | $col_adjust = api_is_allowed_to_edit() ? 1 : 0; |
||
167 | // By id |
||
168 | $this->column = 5; |
||
169 | |||
170 | switch ($this->column) { |
||
171 | // Type |
||
172 | case (0 + $col_adjust) : |
||
173 | $sorting = GradebookDataGenerator :: GDG_SORT_TYPE; |
||
174 | break; |
||
175 | case (1 + $col_adjust) : |
||
176 | $sorting = GradebookDataGenerator :: GDG_SORT_NAME; |
||
177 | break; |
||
178 | case (2 + $col_adjust) : |
||
179 | $sorting = GradebookDataGenerator :: GDG_SORT_DESCRIPTION; |
||
180 | break; |
||
181 | case (3 + $col_adjust) : |
||
182 | $sorting = GradebookDataGenerator :: GDG_SORT_WEIGHT; |
||
183 | break; |
||
184 | case (4 + $col_adjust) : |
||
|
|||
185 | $sorting = GradebookDataGenerator :: GDG_SORT_DATE; |
||
186 | case (5 + $col_adjust) : |
||
187 | $sorting = GradebookDataGenerator :: GDG_SORT_ID; |
||
188 | break; |
||
189 | } |
||
190 | |||
191 | if ($this->direction == 'DESC') { |
||
192 | $sorting |= GradebookDataGenerator :: GDG_SORT_DESC; |
||
193 | } else { |
||
194 | $sorting |= GradebookDataGenerator :: GDG_SORT_ASC; |
||
195 | } |
||
196 | |||
197 | // Status of user in course. |
||
198 | $user_id = $this->userId; |
||
199 | $course_code = api_get_course_id(); |
||
200 | $session_id = api_get_session_id(); |
||
201 | $status_user = api_get_status_of_user_in_course( |
||
202 | api_get_user_id(), |
||
203 | api_get_course_int_id() |
||
204 | ); |
||
205 | |||
206 | if (empty($session_id)) { |
||
207 | $statusToFilter = STUDENT; |
||
208 | } else { |
||
209 | $statusToFilter = 0; |
||
210 | } |
||
211 | |||
212 | if (empty($this->studentList)) { |
||
213 | $studentList = CourseManager::get_user_list_from_course_code( |
||
214 | $course_code, |
||
215 | $session_id, |
||
216 | null, |
||
217 | null, |
||
218 | $statusToFilter |
||
219 | ); |
||
220 | $this->studentList = $studentList; |
||
221 | } |
||
222 | |||
223 | $this->datagen->userId = $this->userId; |
||
224 | |||
225 | $data_array = $this->datagen->get_data( |
||
226 | $sorting, |
||
227 | $from, |
||
228 | $this->per_page, |
||
229 | false, |
||
230 | $this->studentList |
||
231 | ); |
||
232 | |||
233 | // generate the data to display |
||
234 | $sortable_data = array(); |
||
235 | $weight_total_links = 0; |
||
236 | $main_categories = array(); |
||
237 | $main_cat = Category::load( |
||
238 | null, |
||
239 | null, |
||
240 | $course_code, |
||
241 | null, |
||
242 | null, |
||
243 | $session_id, |
||
244 | 'ORDER BY id' |
||
245 | ); |
||
246 | $total_categories_weight = 0; |
||
247 | $scoredisplay = ScoreDisplay :: instance(); |
||
248 | |||
249 | $totalResult = [0, 0]; |
||
250 | $totalBest = [0, 0]; |
||
251 | $totalAverage = [0, 0]; |
||
252 | |||
253 | $type = 'detail'; |
||
254 | if ($this->exportToPdf) { |
||
255 | $type = 'simple'; |
||
256 | } |
||
257 | |||
258 | // Categories. |
||
259 | if (!empty($data_array)) |
||
260 | foreach ($data_array as $data) { |
||
261 | // list of items inside the gradebook (exercises, lps, forums, etc) |
||
262 | $row = array(); |
||
263 | /** @var AbstractLink $item */ |
||
264 | $item = $mainCategory = $data[0]; |
||
265 | |||
266 | //if the item is invisible, wrap it in a span with class invisible |
||
267 | $invisibility_span_open = api_is_allowed_to_edit() && $item->is_visible() == '0' ? '<span class="invisible">' : ''; |
||
268 | $invisibility_span_close = api_is_allowed_to_edit() && $item->is_visible() == '0' ? '</span>' : ''; |
||
269 | |||
270 | // Id |
||
271 | if ($this->teacherView) { |
||
272 | if ($this->exportToPdf == false) { |
||
273 | $row[] = $this->build_id_column($item); |
||
274 | } |
||
275 | } |
||
276 | |||
277 | // Type. |
||
278 | $row[] = $this->build_type_column($item); |
||
279 | |||
280 | // Name. |
||
281 | if (get_class($item) == 'Category') { |
||
282 | $row[] = $invisibility_span_open.'<strong>'.$item->get_name().'</strong>'.$invisibility_span_close; |
||
283 | $main_categories[$item->get_id()]['name'] = $item->get_name(); |
||
284 | } else { |
||
285 | $name = $this->build_name_link($item, $type); |
||
286 | $row[] = $invisibility_span_open.$name. $invisibility_span_close; |
||
287 | $main_categories[$item->get_id()]['name'] = $name; |
||
288 | } |
||
289 | |||
290 | $this->dataForGraph['categories'][] = $item->get_name(); |
||
291 | |||
292 | $main_categories[$item->get_id()]['weight']= $item->get_weight(); |
||
293 | $total_categories_weight += $item->get_weight(); |
||
294 | |||
295 | // Description. |
||
296 | View Code Duplication | if ($this->exportToPdf == false) { |
|
297 | $row[] = $invisibility_span_open.$data[2].$invisibility_span_close; |
||
298 | } |
||
299 | |||
300 | // Weight. |
||
301 | $weight = $scoredisplay->display_score( |
||
302 | array( |
||
303 | $data['3'], |
||
304 | $this->currentcat->get_weight(), |
||
305 | ), |
||
306 | SCORE_SIMPLE, |
||
307 | SCORE_BOTH, |
||
308 | true |
||
309 | ); |
||
310 | |||
311 | if ($this->teacherView) { |
||
312 | $row[] = $invisibility_span_open .Display::tag('p', $weight, array('class' => 'score')).$invisibility_span_close; |
||
313 | } else { |
||
314 | $row[] = $invisibility_span_open .$weight.$invisibility_span_close; |
||
315 | } |
||
316 | |||
317 | $category_weight = $item->get_weight(); |
||
318 | $mainCategoryWeight = $main_cat[0]->get_weight(); |
||
319 | |||
320 | if ($this->teacherView) { |
||
321 | $weight_total_links += $data[3]; |
||
322 | View Code Duplication | } else { |
|
323 | $cattotal = Category::load($_GET['selectcat']); |
||
324 | $scoretotal = $cattotal[0]->calc_score($this->userId); |
||
325 | $item_value = $scoredisplay->display_score($scoretotal, SCORE_SIMPLE); |
||
326 | } |
||
327 | |||
328 | // Edit (for admins). |
||
329 | if ($this->teacherView) { |
||
330 | $cat = new Category(); |
||
331 | $show_message = $cat->show_message_resource_delete($item->get_course_code()); |
||
332 | if ($show_message === false) { |
||
333 | $row[] = $this->build_edit_column($item); |
||
334 | } |
||
335 | } else { |
||
336 | $score = $item->calc_score($this->userId); |
||
337 | |||
338 | if (!empty($score[1])) { |
||
339 | $completeScore = $scoredisplay->display_score($score, SCORE_DIV_PERCENT); |
||
340 | $score = $score[0]/$score[1]*$item->get_weight(); |
||
341 | $score = $scoredisplay->display_score(array($score, null), SCORE_SIMPLE); |
||
342 | $scoreToDisplay = Display::tip($score, $completeScore); |
||
343 | } else { |
||
344 | $scoreToDisplay = '-'; |
||
345 | $categoryScore = null; |
||
346 | } |
||
347 | |||
348 | // Students get the results and certificates columns |
||
349 | //if (count($this->evals_links) > 0 && $status_user != 1) { |
||
350 | if (1) { |
||
351 | $value_data = isset($data[4]) ? $data[4] : null; |
||
352 | $best = isset($data['best']) ? $data['best'] : null; |
||
353 | $average = isset($data['average']) ? $data['average'] : null; |
||
354 | $ranking = isset($data['ranking']) ? $data['ranking'] : null; |
||
355 | |||
356 | $totalResult = [ |
||
357 | $totalResult[0] + $data['result_score_weight'][0], |
||
358 | $totalResult[1] + $data['result_score_weight'][1], |
||
359 | ]; |
||
360 | |||
361 | $totalBest = [ |
||
362 | $totalBest[0] + $data['best_score'][0], |
||
363 | $totalBest[1] + $data['best_score'][1], |
||
364 | ]; |
||
365 | |||
366 | $totalAverage = [ |
||
367 | $totalAverage[0] + $data['average_score'][0], |
||
368 | $totalAverage[1] + $data['average_score'][1], |
||
369 | ]; |
||
370 | |||
371 | // Student result |
||
372 | $row[] = $value_data; |
||
373 | $totalResultAverageValue = strip_tags($scoredisplay->display_score($totalResult, SCORE_AVERAGE)); |
||
374 | $this->dataForGraph['my_result'][] = (float) str_replace('%', '', $totalResultAverageValue); |
||
375 | $totalAverageValue = strip_tags($scoredisplay->display_score($totalAverage, SCORE_AVERAGE)); |
||
376 | $this->dataForGraph['average'][] = (float) str_replace('%', '', $totalAverageValue); |
||
377 | // Ranking |
||
378 | $row[] = $ranking; |
||
379 | // Best |
||
380 | $row[] = $best; |
||
381 | // Average |
||
382 | $row[] = $average; |
||
383 | |||
384 | if (get_class($item) == 'Category') { |
||
385 | if ($this->exportToPdf == false) { |
||
386 | $row[] = $this->build_edit_column($item); |
||
387 | } |
||
388 | } |
||
389 | } else { |
||
390 | $row[] = $scoreToDisplay; |
||
391 | |||
392 | if (!empty($this->cats)) { |
||
393 | if ($this->exportToPdf == false) { |
||
394 | $row[] = $this->build_edit_column($item); |
||
395 | } |
||
396 | } |
||
397 | } |
||
398 | } |
||
399 | |||
400 | // Category added. |
||
401 | $sortable_data[] = $row; |
||
402 | |||
403 | // Loading children |
||
404 | if (get_class($item) == 'Category') { |
||
405 | $course_code = api_get_course_id(); |
||
406 | $session_id = api_get_session_id(); |
||
407 | $parent_id = $item->get_id(); |
||
408 | $cats = Category::load( |
||
409 | $parent_id, |
||
410 | null, |
||
411 | null, |
||
412 | null, |
||
413 | null, |
||
414 | null |
||
415 | ); |
||
416 | |||
417 | if (isset($cats[0])) { |
||
418 | $allcat = $cats[0]->get_subcategories($this->userId, $course_code, $session_id); |
||
419 | $alleval = $cats[0]->get_evaluations($this->userId); |
||
420 | $alllink = $cats[0]->get_links($this->userId); |
||
421 | |||
422 | $sub_cat_info = new GradebookDataGenerator($allcat, $alleval, $alllink); |
||
423 | $sub_cat_info->userId = $user_id; |
||
424 | |||
425 | $data_array2 = $sub_cat_info->get_data( |
||
426 | $sorting, |
||
427 | $from, |
||
428 | $this->per_page, |
||
429 | false, |
||
430 | $this->studentList |
||
431 | ); |
||
432 | $total_weight = 0; |
||
433 | |||
434 | // Links. |
||
435 | foreach ($data_array2 as $data) { |
||
436 | |||
437 | $row = array(); |
||
438 | $item = $data[0]; |
||
439 | |||
440 | //if the item is invisible, wrap it in a span with class invisible |
||
441 | $invisibility_span_open = api_is_allowed_to_edit() && $item->is_visible() == '0' ? '<span class="invisible">' : ''; |
||
442 | $invisibility_span_close = api_is_allowed_to_edit() && $item->is_visible() == '0' ? '</span>' : ''; |
||
443 | |||
444 | if (isset($item)) { |
||
445 | $main_categories[$parent_id]['children'][$item->get_id()]['name'] = $item->get_name(); |
||
446 | $main_categories[$parent_id]['children'][$item->get_id()]['weight'] = $item->get_weight(); |
||
447 | } |
||
448 | |||
449 | if ($this->teacherView) { |
||
450 | if ($this->exportToPdf == false) { |
||
451 | $row[] = $this->build_id_column($item); |
||
452 | } |
||
453 | } |
||
454 | |||
455 | // Type |
||
456 | $row[] = $this->build_type_column($item, array('style' => 'padding-left:5px')); |
||
457 | |||
458 | // Name. |
||
459 | $row[] = $invisibility_span_open." ".$this->build_name_link($item, $type) . $invisibility_span_close; |
||
460 | |||
461 | // Description. |
||
462 | View Code Duplication | if ($this->exportToPdf == false) { |
|
463 | $row[] = $invisibility_span_open.$data[2].$invisibility_span_close; |
||
464 | } |
||
465 | |||
466 | $weight = $data[3]; |
||
467 | $total_weight += $weight; |
||
468 | |||
469 | // Weight |
||
470 | $row[] = $invisibility_span_open.$weight.$invisibility_span_close; |
||
471 | |||
472 | View Code Duplication | if ($this->teacherView) { |
|
473 | //$weight_total_links += intval($data[3]); |
||
474 | } else { |
||
475 | $cattotal = Category::load($_GET['selectcat']); |
||
476 | $scoretotal = $cattotal[0]->calc_score($this->userId); |
||
477 | $item_value = $scoretotal[0]; |
||
478 | } |
||
479 | |||
480 | // Admins get an edit column. |
||
481 | if (api_is_allowed_to_edit(null, true) && |
||
482 | isset($_GET['user_id']) == false && |
||
483 | (isset($_GET['action']) && $_GET['action'] != 'export_all' || !isset($_GET['action']) |
||
484 | ) |
||
485 | ) { |
||
486 | $cat = new Category(); |
||
487 | $show_message = $cat->show_message_resource_delete($item->get_course_code()); |
||
488 | if ($show_message === false) { |
||
489 | if ($this->exportToPdf == false) { |
||
490 | $row[] = $this->build_edit_column($item); |
||
491 | } |
||
492 | } |
||
493 | } else { |
||
494 | // Students get the results and certificates columns |
||
495 | $eval_n_links = array_merge($alleval, $alllink); |
||
496 | |||
497 | if (count($eval_n_links)> 0) { |
||
498 | $value_data = isset($data[4]) ? $data[4] : null; |
||
499 | |||
500 | if (!is_null($value_data)) { |
||
501 | //$score = $item->calc_score(api_get_user_id()); |
||
502 | //$new_score = $data[3] * $score[0] / $score[1]; |
||
503 | //$new_score = floatval(number_format($new_score, api_get_setting('gradebook_number_decimals'))); |
||
504 | |||
505 | // Result |
||
506 | $row[] = $value_data; |
||
507 | |||
508 | $best = isset($data['best']) ? $data['best'] : null; |
||
509 | $average = isset($data['average']) ? $data['average'] : null; |
||
510 | $ranking = isset($data['ranking']) ? $data['ranking'] : null; |
||
511 | |||
512 | // Ranking |
||
513 | $row[] = $ranking; |
||
514 | // Best |
||
515 | $row[] = $best; |
||
516 | // Average |
||
517 | $row[] = $average; |
||
518 | } |
||
519 | } |
||
520 | |||
521 | if (!empty($cats)) { |
||
522 | if ($this->exportToPdf == false) { |
||
523 | $row[] = null; |
||
524 | } |
||
525 | } |
||
526 | } |
||
527 | |||
528 | if ($this->exportToPdf == false) { |
||
529 | $row['child_of'] = $parent_id; |
||
530 | } |
||
531 | $sortable_data[] = $row; |
||
532 | } |
||
533 | |||
534 | // "Warning row" |
||
535 | if (!empty($data_array)) { |
||
536 | if ($this->teacherView) { |
||
537 | // Compare the category weight to the sum of all weights inside the category |
||
538 | if (intval($total_weight) == $category_weight) { |
||
539 | $label = null; |
||
540 | $total = GradebookUtils::score_badges( |
||
541 | array( |
||
542 | $total_weight.' / '.$category_weight, |
||
543 | '100' |
||
544 | ) |
||
545 | ); |
||
546 | } else { |
||
547 | $label = Display::return_icon( |
||
548 | 'warning.png', |
||
549 | sprintf(get_lang('TotalWeightMustBeX'), $category_weight) |
||
550 | ); |
||
551 | $total = Display::badge($total_weight.' / '.$category_weight, 'warning'); |
||
552 | } |
||
553 | $row = array( |
||
554 | null, |
||
555 | null, |
||
556 | " <h5>".get_lang('SubTotal').'</h5>', |
||
557 | null, |
||
558 | $total.' '.$label, |
||
559 | 'child_of' => $parent_id |
||
560 | ); |
||
561 | $sortable_data[] = $row; |
||
562 | } |
||
563 | } |
||
564 | } |
||
565 | } |
||
566 | } //end looping categories |
||
567 | |||
568 | $main_weight = 0; |
||
569 | if (count($main_cat) > 1) { |
||
570 | /** @var Category $myCat */ |
||
571 | foreach ($main_cat as $myCat) { |
||
572 | $myParentId = $myCat->get_parent_id(); |
||
573 | if ($myParentId == 0) { |
||
574 | $main_weight = intval($myCat->get_weight()); |
||
575 | } |
||
576 | } |
||
577 | } |
||
578 | |||
579 | if ($this->teacherView) { |
||
580 | // Total for teacher. |
||
581 | if (count($main_cat) > 1) { |
||
582 | |||
583 | if (intval($total_categories_weight) == $main_weight) { |
||
584 | $total = GradebookUtils::score_badges( |
||
585 | array( |
||
586 | $total_categories_weight.' / '.$main_weight, |
||
587 | '100' |
||
588 | ) |
||
589 | ); |
||
590 | } else { |
||
591 | $total = Display::badge($total_categories_weight.' / '.$main_weight, 'warning'); |
||
592 | } |
||
593 | $row = array( |
||
594 | null, |
||
595 | null, |
||
596 | '<strong>' . get_lang('Total') . '</strong>', |
||
597 | null, |
||
598 | $total |
||
599 | ); |
||
600 | $sortable_data[] = $row; |
||
601 | } |
||
602 | } else { |
||
603 | // Total for student. |
||
604 | if (count($main_cat) > 1) { |
||
605 | $main_weight = intval($main_cat[0]->get_weight()); |
||
606 | |||
607 | $global = null; |
||
608 | $average = null; |
||
609 | // Overwrite main weight |
||
610 | $totalResult[1] = $main_weight; |
||
611 | |||
612 | $totalResult = $scoredisplay->display_score( |
||
613 | $totalResult, |
||
614 | SCORE_DIV |
||
615 | ); |
||
616 | |||
617 | $totalRanking = array(); |
||
618 | $invalidateRanking = true; |
||
619 | $average = 0; |
||
620 | foreach ($this->studentList as $student) { |
||
621 | $score = $main_cat[0]->calc_score($student['user_id']); |
||
622 | if (!empty($score[0])) { |
||
623 | $invalidateRanking = false; |
||
624 | } |
||
625 | $totalRanking[$student['user_id']] = $score[0]; |
||
626 | $average += $score[0]; |
||
627 | } |
||
628 | |||
629 | $totalRanking = AbstractLink::getCurrentUserRanking($user_id, $totalRanking); |
||
630 | |||
631 | $totalRanking = $scoredisplay->display_score( |
||
632 | $totalRanking, |
||
633 | SCORE_DIV, |
||
634 | SCORE_BOTH, |
||
635 | true |
||
636 | ); |
||
637 | |||
638 | if ($invalidateRanking) { |
||
639 | $totalRanking = null; |
||
640 | } |
||
641 | |||
642 | // Overwrite main weight |
||
643 | $totalBest[1] = $main_weight; |
||
644 | |||
645 | $totalBest = $scoredisplay->display_score( |
||
646 | $totalBest, |
||
647 | SCORE_DIV, |
||
648 | SCORE_BOTH, |
||
649 | true |
||
650 | ); |
||
651 | |||
652 | // Overwrite main weight |
||
653 | $totalAverage[0] = $average / count($this->studentList); |
||
654 | $totalAverage[1] = $main_weight; |
||
655 | |||
656 | $totalAverage = $scoredisplay->display_score( |
||
657 | $totalAverage, |
||
658 | SCORE_DIV, |
||
659 | SCORE_BOTH, |
||
660 | true |
||
661 | ); |
||
662 | |||
663 | if ($this->exportToPdf) { |
||
664 | $row = array( |
||
665 | null, |
||
666 | '<h3>' . get_lang('Total') . '</h3>', |
||
667 | $main_weight, |
||
668 | $totalResult, |
||
669 | $totalRanking, |
||
670 | $totalBest, |
||
671 | $totalAverage, |
||
672 | ); |
||
673 | } else { |
||
674 | $row = array( |
||
675 | null, |
||
676 | '<h3>' . get_lang('Total') . '</h3>', |
||
677 | null, |
||
678 | $main_weight, |
||
679 | $totalResult, |
||
680 | $totalRanking, |
||
681 | $totalBest, |
||
682 | $totalAverage, |
||
683 | ); |
||
684 | } |
||
685 | |||
686 | $sortable_data[] = $row; |
||
687 | } |
||
688 | } |
||
689 | |||
690 | // Warning messages |
||
691 | $view = isset($_GET['view']) ? $_GET['view']: null; |
||
692 | |||
693 | if ($this->teacherView) { |
||
694 | if (isset($_GET['selectcat']) && |
||
695 | $_GET['selectcat'] > 0 && |
||
696 | $view <> 'presence' |
||
697 | ) { |
||
698 | $id_cat = intval($_GET['selectcat']); |
||
699 | $category = Category::load($id_cat); |
||
700 | |||
701 | $weight_category = intval($this->build_weight($category[0])); |
||
702 | |||
703 | $course_code = $this->build_course_code($category[0]); |
||
704 | $weight_total_links = round($weight_total_links); |
||
705 | |||
706 | if ($weight_total_links > $weight_category || |
||
707 | $weight_total_links < $weight_category || |
||
708 | $weight_total_links > $weight_category |
||
709 | ) { |
||
710 | $warning_message = sprintf(get_lang('TotalWeightMustBeX'), $weight_category); |
||
711 | $modify_icons = '<a href="gradebook_edit_cat.php?editcat='.$id_cat.'&cidReq='.$course_code.'&id_session='.api_get_session_id().'">'. |
||
712 | Display::return_icon('edit.png', $warning_message, array(), ICON_SIZE_SMALL).'</a>'; |
||
713 | $warning_message .= $modify_icons; |
||
714 | Display::display_warning_message($warning_message, false); |
||
715 | } |
||
716 | |||
717 | $content_html = DocumentManager::replace_user_info_into_html( |
||
718 | api_get_user_id(), |
||
719 | $course_code, |
||
720 | api_get_session_id() |
||
721 | ); |
||
722 | |||
723 | if (!empty($content_html)) { |
||
724 | $new_content = explode('</head>',$content_html['content']); |
||
725 | } |
||
726 | |||
727 | if (empty($new_content[0])) { |
||
728 | // Set default certificate |
||
729 | $courseData = api_get_course_info($course_code); |
||
730 | DocumentManager::generateDefaultCertificate($courseData); |
||
731 | } |
||
732 | } |
||
733 | |||
734 | if (empty($_GET['selectcat'])) { |
||
735 | $categories = Category :: load(); |
||
736 | $weight_categories = $certificate_min_scores = $course_codes = array(); |
||
737 | foreach ($categories as $category) { |
||
738 | $course_code_category = $this->build_course_code($category); |
||
739 | if (!empty($course_code)) { |
||
740 | View Code Duplication | if ($course_code_category == $course_code) { |
|
741 | $weight_categories[] = intval($this->build_weight($category)); |
||
742 | $certificate_min_scores[] = intval($this->build_certificate_min_score($category)); |
||
743 | $course_codes[] = $course_code; |
||
744 | break; |
||
745 | } |
||
746 | View Code Duplication | } else { |
|
747 | $weight_categories[] = intval($this->build_weight($category)); |
||
748 | $certificate_min_scores[] = intval($this->build_certificate_min_score($category)); |
||
749 | $course_codes[] = $course_code_category; |
||
750 | } |
||
751 | } |
||
752 | |||
753 | if (is_array($weight_categories) && |
||
754 | is_array($certificate_min_scores) && |
||
755 | is_array($course_codes) |
||
756 | ) { |
||
757 | $warning_message = ''; |
||
758 | for ($x = 0; $x<count($weight_categories);$x++) { |
||
759 | $weight_category = intval($weight_categories[$x]); |
||
760 | $certificate_min_score = intval($certificate_min_scores[$x]); |
||
761 | $course_code = $course_codes[$x]; |
||
762 | |||
763 | if (empty($certificate_min_score) || |
||
764 | ($certificate_min_score > $weight_category) |
||
765 | ) { |
||
766 | $warning_message .= $course_code .' - '.get_lang('CertificateMinimunScoreIsRequiredAndMustNotBeMoreThan').' '.$weight_category.'<br />'; |
||
767 | } |
||
768 | } |
||
769 | |||
770 | if (!empty($warning_message)) { |
||
771 | Display::display_warning_message($warning_message,false); |
||
772 | } |
||
773 | } |
||
774 | } |
||
775 | } |
||
776 | |||
777 | return $sortable_data; |
||
778 | } |
||
779 | |||
1049 |