|
|
|
@ -1,6 +1,7 @@ |
|
|
|
|
<?php |
|
|
|
|
/* For licensing terms, see license.txt */ |
|
|
|
|
|
|
|
|
|
use ChamiloSession as Session; |
|
|
|
|
use CpChart\Cache as pCache; |
|
|
|
|
use CpChart\Data as pData; |
|
|
|
|
use CpChart\Image as pImage; |
|
|
|
@ -63,6 +64,7 @@ class GradebookTable extends SortableTable |
|
|
|
|
$this->teacherView = is_null($showTeacherView) ? api_is_allowed_to_edit(null, true) : $showTeacherView; |
|
|
|
|
$this->userId = is_null($userId) ? api_get_user_id() : $userId; |
|
|
|
|
$this->exportToPdf = $exportToPdf; |
|
|
|
|
$this->studentList = $studentList; |
|
|
|
|
|
|
|
|
|
parent::__construct( |
|
|
|
|
'gradebooklist', |
|
|
|
@ -79,6 +81,8 @@ class GradebookTable extends SortableTable |
|
|
|
|
$this->cats = $cats; |
|
|
|
|
$this->loadStats = $loadStats; |
|
|
|
|
$this->datagen = new GradebookDataGenerator($cats, $evals, $links); |
|
|
|
|
$this->datagen->preLoadDataKey = $this->getPreloadDataKey(); |
|
|
|
|
|
|
|
|
|
$this->datagen->hidePercentage = api_get_configuration_value('hide_gradebook_percentage_user_result'); |
|
|
|
|
|
|
|
|
|
if (!empty($userId)) { |
|
|
|
@ -182,6 +186,105 @@ class GradebookTable extends SortableTable |
|
|
|
|
return $this->datagen->get_total_items_count(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* @return string |
|
|
|
|
*/ |
|
|
|
|
public function getPreloadDataKey() |
|
|
|
|
{ |
|
|
|
|
return 'default_data_'.api_get_course_id().'_'.api_get_session_id(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function preloadData() |
|
|
|
|
{ |
|
|
|
|
$allitems = $this->datagen->items; |
|
|
|
|
usort($allitems, ['GradebookDataGenerator', 'sort_by_name']); |
|
|
|
|
//$visibleItems = $this->datagen->items; |
|
|
|
|
$visibleItems = array_merge($this->datagen->items, $this->evals_links); |
|
|
|
|
|
|
|
|
|
//Session::erase($this->getPreloadDataKey()); |
|
|
|
|
$defaultDataFromSession = Session::read($this->getPreloadDataKey()); |
|
|
|
|
if (empty($defaultDataFromSession)) { |
|
|
|
|
$defaultData = []; |
|
|
|
|
/** @var GradebookItem $item */ |
|
|
|
|
foreach ($visibleItems as $item) { |
|
|
|
|
$item->setStudentList($this->studentList); |
|
|
|
|
$itemType = get_class($item); |
|
|
|
|
switch ($itemType) { |
|
|
|
|
case 'Evaluation': |
|
|
|
|
// Best |
|
|
|
|
$best = $this->datagen->buildBestResultColumn($item); |
|
|
|
|
$defaultData[$item->get_id()]['best'] = $best; |
|
|
|
|
// Average |
|
|
|
|
$average = $this->datagen->buildAverageResultColumn($item); |
|
|
|
|
$defaultData[$item->get_id()]['average'] = $average; |
|
|
|
|
break; |
|
|
|
|
case 'ExerciseLink': |
|
|
|
|
/** @var ExerciseLink $item */ |
|
|
|
|
// Best |
|
|
|
|
$best = $this->datagen->buildBestResultColumn($item); |
|
|
|
|
$defaultData[$item->get_id()]['best'] = $best; |
|
|
|
|
// Average |
|
|
|
|
$average = $this->datagen->buildAverageResultColumn($item); |
|
|
|
|
$defaultData[$item->get_id()]['average'] = $average; |
|
|
|
|
|
|
|
|
|
// Ranking |
|
|
|
|
/*if (!empty($this->studentList)) { |
|
|
|
|
$invalidateRanking = true; |
|
|
|
|
foreach ($this->studentList as $user) { |
|
|
|
|
$score = $this->datagen->build_result_column( |
|
|
|
|
$user['user_id'], |
|
|
|
|
$item, |
|
|
|
|
false, |
|
|
|
|
true |
|
|
|
|
); |
|
|
|
|
if (!empty($score['score'])) { |
|
|
|
|
$invalidateRanking = false; |
|
|
|
|
} |
|
|
|
|
$rankingStudentList[$user['user_id']] = $score['score'][0]; |
|
|
|
|
$defaultData[$item->get_id()]['ranking'] = $rankingStudentList; |
|
|
|
|
$defaultData[$item->get_id()]['ranking_invalidate'] = $invalidateRanking; |
|
|
|
|
} |
|
|
|
|
}*/ |
|
|
|
|
break; |
|
|
|
|
default: |
|
|
|
|
// Best |
|
|
|
|
$best = $this->datagen->buildBestResultColumn($item); |
|
|
|
|
$defaultData[$item->get_id()]['best'] = $best; |
|
|
|
|
|
|
|
|
|
// Average |
|
|
|
|
$average = $this->datagen->buildAverageResultColumn($item); |
|
|
|
|
$defaultData[$item->get_id()]['average'] = $average; |
|
|
|
|
|
|
|
|
|
// Ranking |
|
|
|
|
if (!empty($this->studentList)) { |
|
|
|
|
$invalidateRanking = true; |
|
|
|
|
foreach ($this->studentList as $user) { |
|
|
|
|
$score = $this->datagen->build_result_column( |
|
|
|
|
$user['user_id'], |
|
|
|
|
$item, |
|
|
|
|
false, |
|
|
|
|
true |
|
|
|
|
); |
|
|
|
|
if (!empty($score['score'])) { |
|
|
|
|
$invalidateRanking = false; |
|
|
|
|
} |
|
|
|
|
$rankingStudentList[$user['user_id']] = $score['score'][0]; |
|
|
|
|
$defaultData[$item->get_id()]['ranking'] = $rankingStudentList; |
|
|
|
|
$defaultData[$item->get_id()]['ranking_invalidate'] = $invalidateRanking; |
|
|
|
|
} |
|
|
|
|
//exit; |
|
|
|
|
} |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
Session::write($this->getPreloadDataKey(), $defaultData); |
|
|
|
|
} else { |
|
|
|
|
$defaultData = $defaultDataFromSession; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return $defaultData; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Function used by SortableTable to generate the data to display. |
|
|
|
|
* |
|
|
|
@ -292,16 +395,20 @@ class GradebookTable extends SortableTable |
|
|
|
|
$userExerciseScoreInCategory = api_get_configuration_value( |
|
|
|
|
'gradebook_use_exercise_score_settings_in_categories' |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
$course_code = api_get_course_id(); |
|
|
|
|
$session_id = api_get_session_id(); |
|
|
|
|
$defaultData = Session::read($this->getPreloadDataKey()); |
|
|
|
|
|
|
|
|
|
// Categories. |
|
|
|
|
if (!empty($data_array)) { |
|
|
|
|
foreach ($data_array as $data) { |
|
|
|
|
// list of items inside the gradebook (exercises, lps, forums, etc) |
|
|
|
|
$row = []; |
|
|
|
|
|
|
|
|
|
/** @var AbstractLink $item */ |
|
|
|
|
$item = $mainCategory = $data[0]; |
|
|
|
|
|
|
|
|
|
//if the item is invisible, wrap it in a span with class invisible |
|
|
|
|
// If the item is invisible, wrap it in a span with class invisible |
|
|
|
|
$invisibility_span_open = $isAllowedToEdit && $item->is_visible() == '0' ? '<span class="text-muted">' : ''; |
|
|
|
|
$invisibility_span_close = $isAllowedToEdit && $item->is_visible() == '0' ? '</span>' : ''; |
|
|
|
|
|
|
|
|
@ -316,7 +423,7 @@ class GradebookTable extends SortableTable |
|
|
|
|
$row[] = $this->build_type_column($item); |
|
|
|
|
|
|
|
|
|
// Name. |
|
|
|
|
if (get_class($item) == 'Category') { |
|
|
|
|
if (get_class($item) === 'Category') { |
|
|
|
|
$row[] = $invisibility_span_open.'<strong>'.$item->get_name().'</strong>'.$invisibility_span_close; |
|
|
|
|
$main_categories[$item->get_id()]['name'] = $item->get_name(); |
|
|
|
|
} else { |
|
|
|
@ -383,94 +490,86 @@ class GradebookTable extends SortableTable |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Students get the results and certificates columns |
|
|
|
|
if (1) { |
|
|
|
|
$value_data = isset($data[4]) ? $data[4] : null; |
|
|
|
|
$best = isset($data['best']) ? $data['best'] : null; |
|
|
|
|
$average = isset($data['average']) ? $data['average'] : null; |
|
|
|
|
$ranking = isset($data['ranking']) ? $data['ranking'] : null; |
|
|
|
|
|
|
|
|
|
$totalResult = [ |
|
|
|
|
$data['result_score'][0], |
|
|
|
|
$data['result_score'][1], |
|
|
|
|
]; |
|
|
|
|
|
|
|
|
|
$totalUserResult[0] += $totalResult[0] / ($totalResult[1] ?: 1) * $data[3]; |
|
|
|
|
$totalUserResult[1] += $data[3]; |
|
|
|
|
|
|
|
|
|
$totalBest = [ |
|
|
|
|
$scoredisplay->format_score($totalBest[0] + $data['best_score'][0]), |
|
|
|
|
$scoredisplay->format_score($totalBest[1] + $data['best_score'][1]), |
|
|
|
|
]; |
|
|
|
|
|
|
|
|
|
$totalAverage = [ |
|
|
|
|
$data['average_score'][0], |
|
|
|
|
$data['average_score'][1], |
|
|
|
|
]; |
|
|
|
|
|
|
|
|
|
// Student result |
|
|
|
|
if (empty($model)) { |
|
|
|
|
$row[] = $value_data; |
|
|
|
|
} else { |
|
|
|
|
$row[] = ExerciseLib::show_score( |
|
|
|
|
$data['result_score'][0], |
|
|
|
|
$data['result_score'][1] |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
$value_data = isset($data[4]) ? $data[4] : null; |
|
|
|
|
$best = isset($data['best']) ? $data['best'] : null; |
|
|
|
|
$average = isset($data['average']) ? $data['average'] : null; |
|
|
|
|
$ranking = isset($data['ranking']) ? $data['ranking'] : null; |
|
|
|
|
|
|
|
|
|
$mode = SCORE_AVERAGE; |
|
|
|
|
if ($userExerciseScoreInCategory) { |
|
|
|
|
$mode = SCORE_SIMPLE; |
|
|
|
|
$totalResult = [ |
|
|
|
|
$data['result_score'][0], |
|
|
|
|
$data['result_score'][1], |
|
|
|
|
]; |
|
|
|
|
|
|
|
|
|
$result = ExerciseLib::convertScoreToPlatformSetting($totalAverage[0], $totalAverage[1]); |
|
|
|
|
$totalAverage[0] = $result['score']; |
|
|
|
|
$totalAverage[1] = $result['weight']; |
|
|
|
|
$totalUserResult[0] += $totalResult[0] / ($totalResult[1] ?: 1) * $data[3]; |
|
|
|
|
$totalUserResult[1] += $data[3]; |
|
|
|
|
|
|
|
|
|
$result = ExerciseLib::convertScoreToPlatformSetting($totalResult[0], $totalResult[1]); |
|
|
|
|
$totalResult[0] = $result['score']; |
|
|
|
|
$totalResult[1] = $result['weight']; |
|
|
|
|
$totalBest = [ |
|
|
|
|
$scoredisplay->format_score($totalBest[0] + $data['best_score'][0]), |
|
|
|
|
$scoredisplay->format_score($totalBest[1] + $data['best_score'][1]), |
|
|
|
|
]; |
|
|
|
|
|
|
|
|
|
$totalAverage = [ |
|
|
|
|
$data['average_score'][0], |
|
|
|
|
$data['average_score'][1], |
|
|
|
|
]; |
|
|
|
|
|
|
|
|
|
$result = ExerciseLib::convertScoreToPlatformSetting( |
|
|
|
|
$data['result_score'][0], |
|
|
|
|
$data['result_score'][1] |
|
|
|
|
// Student result |
|
|
|
|
if (empty($model)) { |
|
|
|
|
$row[] = $value_data; |
|
|
|
|
} else { |
|
|
|
|
$row[] = ExerciseLib::show_score( |
|
|
|
|
$data['result_score'][0], |
|
|
|
|
$data['result_score'][1] |
|
|
|
|
); |
|
|
|
|
$data['my_result_no_float'][0] = $result['score']; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$totalResultAverageValue = strip_tags($scoredisplay->display_score($totalResult, $mode)); |
|
|
|
|
$totalAverageValue = strip_tags($scoredisplay->display_score($totalAverage, $mode)); |
|
|
|
|
$mode = SCORE_AVERAGE; |
|
|
|
|
if ($userExerciseScoreInCategory) { |
|
|
|
|
$mode = SCORE_SIMPLE; |
|
|
|
|
|
|
|
|
|
$this->dataForGraph['my_result'][] = floatval($totalResultAverageValue); |
|
|
|
|
$this->dataForGraph['average'][] = floatval($totalAverageValue); |
|
|
|
|
$this->dataForGraph['my_result_no_float'][] = $data['result_score'][0]; |
|
|
|
|
$result = ExerciseLib::convertScoreToPlatformSetting($totalAverage[0], $totalAverage[1]); |
|
|
|
|
$totalAverage[0] = $result['score']; |
|
|
|
|
$totalAverage[1] = $result['weight']; |
|
|
|
|
|
|
|
|
|
if (empty($model)) { |
|
|
|
|
// Ranking |
|
|
|
|
if (in_array(1, $this->loadStats)) { |
|
|
|
|
$row[] = $ranking; |
|
|
|
|
} |
|
|
|
|
$result = ExerciseLib::convertScoreToPlatformSetting($totalResult[0], $totalResult[1]); |
|
|
|
|
$totalResult[0] = $result['score']; |
|
|
|
|
$totalResult[1] = $result['weight']; |
|
|
|
|
|
|
|
|
|
// Best |
|
|
|
|
if (in_array(2, $this->loadStats)) { |
|
|
|
|
$row[] = $best; |
|
|
|
|
} |
|
|
|
|
$result = ExerciseLib::convertScoreToPlatformSetting( |
|
|
|
|
$data['result_score'][0], |
|
|
|
|
$data['result_score'][1] |
|
|
|
|
); |
|
|
|
|
$data['my_result_no_float'][0] = $result['score']; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Average |
|
|
|
|
if (in_array(3, $this->loadStats)) { |
|
|
|
|
$row[] = $average; |
|
|
|
|
} |
|
|
|
|
$totalResultAverageValue = strip_tags($scoredisplay->display_score($totalResult, $mode)); |
|
|
|
|
$totalAverageValue = strip_tags($scoredisplay->display_score($totalAverage, $mode)); |
|
|
|
|
|
|
|
|
|
$this->dataForGraph['my_result'][] = floatval($totalResultAverageValue); |
|
|
|
|
$this->dataForGraph['average'][] = floatval($totalAverageValue); |
|
|
|
|
$this->dataForGraph['my_result_no_float'][] = $data['result_score'][0]; |
|
|
|
|
|
|
|
|
|
if (empty($model)) { |
|
|
|
|
// Ranking |
|
|
|
|
if (in_array(1, $this->loadStats)) { |
|
|
|
|
$row[] = $ranking; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (get_class($item) == 'Category') { |
|
|
|
|
if ($this->exportToPdf == false) { |
|
|
|
|
$row[] = $this->build_edit_column($item); |
|
|
|
|
} |
|
|
|
|
// Best |
|
|
|
|
if (in_array(2, $this->loadStats)) { |
|
|
|
|
$row[] = $best; |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
$row[] = $scoreToDisplay; |
|
|
|
|
if (!empty($this->cats)) { |
|
|
|
|
if ($this->exportToPdf == false) { |
|
|
|
|
$row[] = $this->build_edit_column($item); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Average |
|
|
|
|
if (in_array(3, $this->loadStats)) { |
|
|
|
|
$row[] = $average; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (get_class($item) === 'Category') { |
|
|
|
|
if ($this->exportToPdf == false) { |
|
|
|
|
$row[] = $this->build_edit_column($item); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -479,10 +578,9 @@ class GradebookTable extends SortableTable |
|
|
|
|
$sortable_data[] = $row; |
|
|
|
|
|
|
|
|
|
// Loading children |
|
|
|
|
if (get_class($item) == 'Category') { |
|
|
|
|
$course_code = api_get_course_id(); |
|
|
|
|
$session_id = api_get_session_id(); |
|
|
|
|
if (get_class($item) === 'Category') { |
|
|
|
|
$parent_id = $item->get_id(); |
|
|
|
|
|
|
|
|
|
$cats = Category::load( |
|
|
|
|
$parent_id, |
|
|
|
|
null, |
|
|
|
@ -500,6 +598,7 @@ class GradebookTable extends SortableTable |
|
|
|
|
$alllink = $subCategory->get_links($this->userId); |
|
|
|
|
|
|
|
|
|
$sub_cat_info = new GradebookDataGenerator($allcat, $alleval, $alllink); |
|
|
|
|
$sub_cat_info->preLoadDataKey = $this->getPreloadDataKey(); |
|
|
|
|
$sub_cat_info->userId = $user_id; |
|
|
|
|
$data_array2 = $sub_cat_info->get_data( |
|
|
|
|
$sorting, |
|
|
|
@ -534,7 +633,7 @@ class GradebookTable extends SortableTable |
|
|
|
|
$row[] = $this->build_type_column($item, ['style' => 'padding-left:5px']); |
|
|
|
|
|
|
|
|
|
// Name. |
|
|
|
|
$row[] = $invisibility_span_open." ". |
|
|
|
|
$row[] = $invisibility_span_open.' '. |
|
|
|
|
$this->build_name_link($item, $type).$invisibility_span_close; |
|
|
|
|
|
|
|
|
|
// Description. |
|
|
|
@ -652,7 +751,7 @@ class GradebookTable extends SortableTable |
|
|
|
|
foreach ($main_cat as $myCat) { |
|
|
|
|
$myParentId = $myCat->get_parent_id(); |
|
|
|
|
if ($myParentId == 0) { |
|
|
|
|
$main_weight = intval($myCat->get_weight()); |
|
|
|
|
$main_weight = (int) $myCat->get_weight(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -682,31 +781,27 @@ class GradebookTable extends SortableTable |
|
|
|
|
} else { |
|
|
|
|
// Total for student. |
|
|
|
|
if (count($main_cat) > 1) { |
|
|
|
|
$weights = []; |
|
|
|
|
foreach ($main_categories as $cat) { |
|
|
|
|
$weights[] = $cat['weight']; |
|
|
|
|
} |
|
|
|
|
$main_weight = intval($main_cat[0]->get_weight()); |
|
|
|
|
$main_weight = (int) $main_cat[0]->get_weight(); |
|
|
|
|
$global = null; |
|
|
|
|
$average = null; |
|
|
|
|
$myTotal = 0; |
|
|
|
|
|
|
|
|
|
foreach ($this->dataForGraph['my_result_no_float'] as $result) { |
|
|
|
|
$myTotal += $scoredisplay->format_score($result); |
|
|
|
|
$myTotal += $result; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$totalResult[0] = $myTotal; |
|
|
|
|
// Overwrite main weight |
|
|
|
|
$totalResult[1] = $main_weight; |
|
|
|
|
|
|
|
|
|
$totalResult = $scoredisplay->display_score( |
|
|
|
|
$totalResult, |
|
|
|
|
SCORE_DIV |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
$row = [ |
|
|
|
|
null, |
|
|
|
|
'<strong>'.get_lang('Total').'</strong>', |
|
|
|
|
]; |
|
|
|
|
null, |
|
|
|
|
'<strong>'.get_lang('Total').'</strong>', |
|
|
|
|
]; |
|
|
|
|
|
|
|
|
|
if (!$this->exportToPdf) { |
|
|
|
|
$row[] = null; |
|
|
|
@ -714,34 +809,43 @@ class GradebookTable extends SortableTable |
|
|
|
|
|
|
|
|
|
$row[] = $main_weight; |
|
|
|
|
$row[] = $totalResult; |
|
|
|
|
$categoryId = $main_cat[0]->get_id(); |
|
|
|
|
|
|
|
|
|
if (in_array(1, $this->loadStats)) { |
|
|
|
|
$totalRanking = []; |
|
|
|
|
$invalidateRanking = true; |
|
|
|
|
$average = 0; |
|
|
|
|
$main_cat[0]->setStudentList($this->studentList); |
|
|
|
|
foreach ($this->studentList as $student) { |
|
|
|
|
$score = $main_cat[0]->calc_score( |
|
|
|
|
$student['user_id'], |
|
|
|
|
null, |
|
|
|
|
api_get_course_id(), |
|
|
|
|
api_get_session_id() |
|
|
|
|
); |
|
|
|
|
if (!empty($score[0])) { |
|
|
|
|
$invalidateRanking = false; |
|
|
|
|
if (isset($defaultData[$categoryId]) && isset($defaultData[$categoryId]['ranking'])) { |
|
|
|
|
$totalRanking = $defaultData[$categoryId]['ranking']; |
|
|
|
|
$invalidateRanking = $defaultData[$categoryId]['ranking_invalidate']; |
|
|
|
|
} else { |
|
|
|
|
$totalRanking = []; |
|
|
|
|
$invalidateRanking = true; |
|
|
|
|
$average = 0; |
|
|
|
|
$main_cat[0]->setStudentList($this->studentList); |
|
|
|
|
foreach ($this->studentList as $student) { |
|
|
|
|
$score = $main_cat[0]->calc_score( |
|
|
|
|
$student['user_id'], |
|
|
|
|
null, |
|
|
|
|
api_get_course_id(), |
|
|
|
|
api_get_session_id() |
|
|
|
|
); |
|
|
|
|
if (!empty($score[0])) { |
|
|
|
|
$invalidateRanking = false; |
|
|
|
|
} |
|
|
|
|
$totalRanking[$student['user_id']] = $score[0]; |
|
|
|
|
$average += $score[0]; |
|
|
|
|
} |
|
|
|
|
$totalRanking[$student['user_id']] = $score[0]; |
|
|
|
|
$average += $score[0]; |
|
|
|
|
$defaultData[$categoryId]['ranking'] = $totalRanking; |
|
|
|
|
$defaultData[$categoryId]['ranking_invalidate'] = $invalidateRanking; |
|
|
|
|
Session::write($this->getPreloadDataKey(), $defaultData); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$totalRanking = AbstractLink::getCurrentUserRanking($user_id, $totalRanking); |
|
|
|
|
$totalRanking = $scoredisplay->display_score( |
|
|
|
|
$totalRanking, |
|
|
|
|
SCORE_DIV, |
|
|
|
|
SCORE_BOTH, |
|
|
|
|
true, |
|
|
|
|
true |
|
|
|
|
); |
|
|
|
|
$totalRanking, |
|
|
|
|
SCORE_DIV, |
|
|
|
|
SCORE_BOTH, |
|
|
|
|
true, |
|
|
|
|
true |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
if ($invalidateRanking) { |
|
|
|
|
$totalRanking = null; |
|
|
|
@ -750,46 +854,60 @@ class GradebookTable extends SortableTable |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (in_array(2, $this->loadStats)) { |
|
|
|
|
// Overwrite main weight |
|
|
|
|
$totalBest[1] = $main_weight; |
|
|
|
|
if (isset($defaultData[$categoryId]) && isset($defaultData[$categoryId]['best'])) { |
|
|
|
|
$totalBest = $defaultData[$categoryId]['best']; |
|
|
|
|
} else { |
|
|
|
|
// Overwrite main weight |
|
|
|
|
$totalBest[1] = $main_weight; |
|
|
|
|
$defaultData[$categoryId]['best'] = $totalBest; |
|
|
|
|
} |
|
|
|
|
$totalBest = $scoredisplay->display_score( |
|
|
|
|
$totalBest, |
|
|
|
|
SCORE_DIV, |
|
|
|
|
SCORE_BOTH, |
|
|
|
|
true |
|
|
|
|
); |
|
|
|
|
$totalBest, |
|
|
|
|
SCORE_DIV, |
|
|
|
|
SCORE_BOTH, |
|
|
|
|
true |
|
|
|
|
); |
|
|
|
|
$row[] = $totalBest; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (in_array(3, $this->loadStats)) { |
|
|
|
|
// Overwrite main weight |
|
|
|
|
$totalAverage[0] = $average / count($this->studentList); |
|
|
|
|
$totalAverage[1] = $main_weight; |
|
|
|
|
if (isset($defaultData[$categoryId]) && isset($defaultData[$categoryId]['average'])) { |
|
|
|
|
$totalAverage = $defaultData[$categoryId]['average']; |
|
|
|
|
} else { |
|
|
|
|
// Overwrite main weight |
|
|
|
|
$totalAverage[0] = $average / count($this->studentList); |
|
|
|
|
$totalAverage[1] = $main_weight; |
|
|
|
|
$defaultData[$categoryId]['average'] = $totalBest; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$totalAverage = $scoredisplay->display_score( |
|
|
|
|
$totalAverage, |
|
|
|
|
SCORE_DIV, |
|
|
|
|
SCORE_BOTH, |
|
|
|
|
true |
|
|
|
|
); |
|
|
|
|
$totalAverage, |
|
|
|
|
SCORE_DIV, |
|
|
|
|
SCORE_BOTH, |
|
|
|
|
true |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
$row[] = $totalAverage; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (!empty($row)) { |
|
|
|
|
$sortable_data[] = $row; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Session::write('default_data', $defaultData); |
|
|
|
|
|
|
|
|
|
// Warning messages |
|
|
|
|
$view = isset($_GET['view']) ? $_GET['view'] : null; |
|
|
|
|
|
|
|
|
|
if ($this->teacherView) { |
|
|
|
|
if (isset($_GET['selectcat']) && |
|
|
|
|
$_GET['selectcat'] > 0 && |
|
|
|
|
$view != 'presence' |
|
|
|
|
) { |
|
|
|
|
$id_cat = intval($_GET['selectcat']); |
|
|
|
|
$id_cat = (int) $_GET['selectcat']; |
|
|
|
|
$category = Category::load($id_cat); |
|
|
|
|
$weight_category = intval($this->build_weight($category[0])); |
|
|
|
|
$weight_category = (int) $this->build_weight($category[0]); |
|
|
|
|
$course_code = $this->build_course_code($category[0]); |
|
|
|
|
$weight_total_links = round($weight_total_links); |
|
|
|
|
|
|
|
|
@ -798,7 +916,8 @@ class GradebookTable extends SortableTable |
|
|
|
|
$weight_total_links > $weight_category |
|
|
|
|
) { |
|
|
|
|
$warning_message = sprintf(get_lang('TotalWeightMustBeX'), $weight_category); |
|
|
|
|
$modify_icons = '<a href="gradebook_edit_cat.php?editcat='.$id_cat.'&cidReq='.$course_code.'&id_session='.api_get_session_id().'">'. |
|
|
|
|
$modify_icons = |
|
|
|
|
'<a href="gradebook_edit_cat.php?editcat='.$id_cat.'&cidReq='.$course_code.'&id_session='.api_get_session_id().'">'. |
|
|
|
|
Display::return_icon('edit.png', $warning_message, [], ICON_SIZE_SMALL).'</a>'; |
|
|
|
|
$warning_message .= $modify_icons; |
|
|
|
|
echo Display::return_message($warning_message, 'warning', false); |
|
|
|
@ -853,7 +972,9 @@ class GradebookTable extends SortableTable |
|
|
|
|
if (empty($certificate_min_score) || |
|
|
|
|
($certificate_min_score > $weight_category) |
|
|
|
|
) { |
|
|
|
|
$warning_message .= $course_code.' - '.get_lang('CertificateMinimunScoreIsRequiredAndMustNotBeMoreThan').' '.$weight_category.'<br />'; |
|
|
|
|
$warning_message .= $course_code. |
|
|
|
|
' - '.get_lang('CertificateMinimunScoreIsRequiredAndMustNotBeMoreThan'). |
|
|
|
|
' '.$weight_category.'<br />'; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -864,27 +985,6 @@ class GradebookTable extends SortableTable |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (!$this->teacherView) { |
|
|
|
|
/*$rowTotal = []; |
|
|
|
|
$rowTotal[] = ' '; |
|
|
|
|
$rowTotal[] = '<strong>'.get_lang('FinalScore').'</strong>'; |
|
|
|
|
|
|
|
|
|
if (!$this->exportToPdf) { |
|
|
|
|
$rowTotal[] = ' '; |
|
|
|
|
} |
|
|
|
|
$rowTotal[] = ' '; |
|
|
|
|
$rowTotal[] = $scoredisplay->display_score( |
|
|
|
|
$totalUserResult, |
|
|
|
|
SCORE_DIV_PERCENT_WITH_CUSTOM |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
foreach ($this->loadStats as $col) { |
|
|
|
|
$rowTotal[] = ' '; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$sortable_data[] = $rowTotal;*/ |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return $sortable_data; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|