@ -100,25 +100,23 @@ class GradebookTable extends SortableTable
$this->set_header($column++, get_lang('Type'), '', 'width="20px"');
$this->set_header($column++, get_lang('Type'), '', 'width="20px"');
$this->set_header($column++, get_lang('Name'), false);
$this->set_header($column++, get_lang('Name'), false);
if (false == $this->exportToPdf) {
if (false == $this->exportToPdf) {
$this->set_header($column++, get_lang('Description'), false);
$this->set_header($column++, get_lang('Description'), false);
}
}
$model = ExerciseLib::getCourseScoreModel();
$model = ExerciseLib::getCourseScoreModel();
$settings = api_get_configuration_value('gradebook_pdf_export_settings');
$settings = api_get_configuration_value('gradebook_pdf_export_settings');
$showWeight = true;
$showWeight = true;
if ($this->exportToPdf & & isset($settings['hide_score_weight']) & & $settings['hide_score_weight']) {
if ($this->exportToPdf & & isset($settings['hide_score_weight']) & & $settings['hide_score_weight']) {
$showWeight = false;
$showWeight = false;
}
}
if ($showWeight) {
if ($showWeight) {
$this->set_header(
$this->set_header(
$column++,
$column++,
get_lang('Weight'),
get_lang('Weight'),
'',
'',
'width="100px"'
'width="100px"'
);
);
}
}
if (!$this->teacherView) {
if (!$this->teacherView) {
@ -228,7 +226,6 @@ class GradebookTable extends SortableTable
// Average
// Average
$average = $this->datagen->buildAverageResultColumn($item);
$average = $this->datagen->buildAverageResultColumn($item);
$defaultData[$item->get_id()]['average'] = $average;
$defaultData[$item->get_id()]['average'] = $average;
// Ranking
// Ranking
/*if (!empty($this->studentList)) {
/*if (!empty($this->studentList)) {
$invalidateRanking = true;
$invalidateRanking = true;
@ -382,7 +379,6 @@ class GradebookTable extends SortableTable
$total_categories_weight = 0;
$total_categories_weight = 0;
$scoredisplay = ScoreDisplay::instance();
$scoredisplay = ScoreDisplay::instance();
$totalBest = [0, 0];
$totalBest = [0, 0];
$totalAverage = [0, 0];
$totalAverage = [0, 0];
@ -395,7 +391,6 @@ class GradebookTable extends SortableTable
$userExerciseScoreInCategory = api_get_configuration_value(
$userExerciseScoreInCategory = api_get_configuration_value(
'gradebook_use_exercise_score_settings_in_categories'
'gradebook_use_exercise_score_settings_in_categories'
);
);
$useExerciseScoreInTotal = api_get_configuration_value('gradebook_use_exercise_score_settings_in_total');
$useExerciseScoreInTotal = api_get_configuration_value('gradebook_use_exercise_score_settings_in_total');
$course_code = api_get_course_id();
$course_code = api_get_course_id();
$session_id = api_get_session_id();
$session_id = api_get_session_id();
@ -405,7 +400,7 @@ class GradebookTable extends SortableTable
if ($this->exportToPdf & & isset($settings['hide_score_weight']) & & $settings['hide_score_weight']) {
if ($this->exportToPdf & & isset($settings['hide_score_weight']) & & $settings['hide_score_weight']) {
$showWeight = false;
$showWeight = false;
}
}
$totalAverageList = [];
// Categories.
// Categories.
if (!empty($data_array)) {
if (!empty($data_array)) {
foreach ($data_array as $data) {
foreach ($data_array as $data) {
@ -413,12 +408,10 @@ class GradebookTable extends SortableTable
$row = [];
$row = [];
/** @var AbstractLink $item */
/** @var AbstractLink $item */
$item = $data[0];
$item = $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 & & '0' == $item->is_visible() ? '< span class = "text-muted" > ' : '';
$invisibility_span_open = $isAllowedToEdit & & '0' == $item->is_visible() ? '< span class = "text-muted" > ' : '';
$invisibility_span_close = $isAllowedToEdit & & '0' == $item->is_visible() ? '< / span > ' : '';
$invisibility_span_close = $isAllowedToEdit & & '0' == $item->is_visible() ? '< / span > ' : '';
// Id
if ($this->teacherView) {
if ($this->teacherView) {
if (false == $this->exportToPdf) {
if (false == $this->exportToPdf) {
$row[] = $this->build_id_column($item);
$row[] = $this->build_id_column($item);
@ -469,7 +462,6 @@ class GradebookTable extends SortableTable
}
}
$category_weight = $item->get_weight();
$category_weight = $item->get_weight();
if ($this->teacherView) {
if ($this->teacherView) {
$weight_total_links += $data[3];
$weight_total_links += $data[3];
}
}
@ -482,21 +474,12 @@ class GradebookTable extends SortableTable
$row[] = $this->build_edit_column($item);
$row[] = $this->build_edit_column($item);
}
}
} else {
} else {
/*$score = $item->calc_score($this->userId);
if (!empty($score[1])) {
$score = $score[0] / $score[1] * $item->get_weight();
$score = $scoredisplay->display_score([$score, null], SCORE_SIMPLE);
} else {
$categoryScore = null;
}*/
// Students get the results and certificates columns
// Students get the results and certificates columns
$value_data = isset($data[4]) ? $data[4] : null;
$value_data = isset($data[4]) ? $data[4] : null;
$best = isset($data['best']) ? $data['best'] : null;
$best = isset($data['best']) ? $data['best'] : null;
$average = isset($data['average']) ? $data['average'] : null;
$average = isset($data['average']) ? $data['average'] : null;
$ranking = isset($data['ranking']) ? $data['ranking'] : null;
$ranking = isset($data['ranking']) ? $data['ranking'] : null;
$totalResult = [];
$totalResult = [];
if (isset($data['result_score'])) {
if (isset($data['result_score'])) {
$totalResult = [
$totalResult = [
$data['result_score'][0],
$data['result_score'][0],
@ -509,17 +492,16 @@ class GradebookTable extends SortableTable
$scoredisplay->format_score($totalBest[0] + $data['best_score'][0]),
$scoredisplay->format_score($totalBest[0] + $data['best_score'][0]),
$scoredisplay->format_score($totalBest[1] + $data['best_score'][1]),
$scoredisplay->format_score($totalBest[1] + $data['best_score'][1]),
];
];
$totalAverage = [0, 0];
$totalAverage = [0, 0];
if (isset($data['average_score']) & & !empty($data['average_score'])) {
if (isset($data['average_score']) & & !empty($data['average_score'])) {
$totalAverage = [
$totalAverage = [
$data['average_score'][0],
$data['average_score'][0],
$data['average_score'][1],
$data['average_score'][1],
];
];
}
}
}
}
// Student result
// Score
if (empty($model)) {
if (empty($model)) {
$row[] = $value_data;
$row[] = $value_data;
} else {
} else {
@ -529,6 +511,7 @@ class GradebookTable extends SortableTable
);
);
}
}
$totalAverageList[$item->get_id()] = $totalAverage;
$mode = SCORE_AVERAGE;
$mode = SCORE_AVERAGE;
if ($userExerciseScoreInCategory) {
if ($userExerciseScoreInCategory) {
$mode = SCORE_SIMPLE;
$mode = SCORE_SIMPLE;
@ -608,6 +591,7 @@ class GradebookTable extends SortableTable
$sub_cat_info->exportToPdf = $this->exportToPdf;
$sub_cat_info->exportToPdf = $this->exportToPdf;
$sub_cat_info->preLoadDataKey = $this->getPreloadDataKey();
$sub_cat_info->preLoadDataKey = $this->getPreloadDataKey();
$sub_cat_info->userId = $user_id;
$sub_cat_info->userId = $user_id;
$data_array2 = $sub_cat_info->get_data(
$data_array2 = $sub_cat_info->get_data(
$sorting,
$sorting,
$from,
$from,
@ -621,7 +605,6 @@ class GradebookTable extends SortableTable
foreach ($data_array2 as $data) {
foreach ($data_array2 as $data) {
$row = [];
$row = [];
$item = $data[0];
$item = $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 & & '0' == $item->is_visible() ? '< span class = "text-muted" > ' : '';
$invisibility_span_open = $isAllowedToEdit & & '0' == $item->is_visible() ? '< span class = "text-muted" > ' : '';
$invisibility_span_close = $isAllowedToEdit & & '0' == $item->is_visible() ? '< / span > ' : '';
$invisibility_span_close = $isAllowedToEdit & & '0' == $item->is_visible() ? '< / span > ' : '';
@ -639,7 +622,6 @@ class GradebookTable extends SortableTable
// Type
// Type
$row[] = $this->build_type_column($item, ['style' => 'padding-left:5px']);
$row[] = $this->build_type_column($item, ['style' => 'padding-left:5px']);
// Name.
// Name.
$row[] = $invisibility_span_open.' '.
$row[] = $invisibility_span_open.' '.
$this->build_name_link($item, $type, 4).$invisibility_span_close;
$this->build_name_link($item, $type, 4).$invisibility_span_close;
@ -654,7 +636,7 @@ class GradebookTable extends SortableTable
// Weight
// Weight
if ($showWeight) {
if ($showWeight) {
$row[] = $invisibility_span_open.$weight.$invisibility_span_close;
$row[] = $invisibility_span_open.$weight.$invisibility_span_close;
}
}
// Admins get an edit column.
// Admins get an edit column.
@ -672,25 +654,22 @@ class GradebookTable extends SortableTable
} else {
} else {
// Students get the results and certificates columns
// Students get the results and certificates columns
$eval_n_links = array_merge($alleval, $alllink);
$eval_n_links = array_merge($alleval, $alllink);
if (count($eval_n_links) > 0) {
if (count($eval_n_links) > 0) {
$value_data = isset($data[4]) ? $data[4] : null;
$value_data = isset($data[4]) ? $data[4] : null;
if (!is_null($value_data)) {
if (!is_null($value_data)) {
// Result
// Result
$row[] = $value_data;
$row[] = $value_data;
$best = isset($data['best']) ? $data['best'] : null;
$best = isset($data['best']) ? $data['best'] : null;
$average = isset($data['average']) ? $data['average'] : null;
$average = isset($data['average']) ? $data['average'] : null;
$ranking = isset($data['ranking']) ? $data['ranking'] : null;
$ranking = isset($data['ranking']) ? $data['ranking'] : null;
if (empty($model)) {
if (empty($model)) {
// Ranking
if (in_array(1, $this->loadStats)) {
if (in_array(1, $this->loadStats)) {
// Ranking
$row[] = $ranking;
$row[] = $ranking;
}
}
// Best
if (in_array(2, $this->loadStats)) {
if (in_array(2, $this->loadStats)) {
// Best
$row[] = $best;
$row[] = $best;
}
}
@ -784,6 +763,7 @@ class GradebookTable extends SortableTable
$sortable_data[] = $row;
$sortable_data[] = $row;
}
}
} else {
} else {
$showPercentage = false === $this->datagen->hidePercentage;
// Total for student.
// Total for student.
if (count($main_cat) > 1) {
if (count($main_cat) > 1) {
$main_weight = (int) $main_cat[0]->get_weight();
$main_weight = (int) $main_cat[0]->get_weight();
@ -812,6 +792,7 @@ class GradebookTable extends SortableTable
false,
false,
true
true
);
);
if ($useExerciseScoreInTotal) {
if ($useExerciseScoreInTotal) {
$totalResult = ExerciseLib::show_score($myTotal, $main_weight, false);
$totalResult = ExerciseLib::show_score($myTotal, $main_weight, false);
}
}
@ -827,8 +808,9 @@ class GradebookTable extends SortableTable
}
}
if ($showWeight) {
if ($showWeight) {
$row[] = $main_weight;
$row[] = $main_weight;
}
}
$row[] = $totalResult;
$row[] = $totalResult;
$categoryId = $main_cat[0]->get_id();
$categoryId = $main_cat[0]->get_id();
@ -865,18 +847,14 @@ class GradebookTable extends SortableTable
}
}
$totalRanking = AbstractLink::getCurrentUserRanking($user_id, $totalRanking);
$totalRanking = AbstractLink::getCurrentUserRanking($user_id, $totalRanking);
if ($useExerciseScoreInTotal) {
$totalRanking = ExerciseLib::show_score($totalRanking[0], $totalRanking[1], false);
} else {
$totalRanking = $scoredisplay->display_score(
$totalRanking = $scoredisplay->display_score(
$totalRanking,
$totalRanking,
SCORE_DIV,
SCORE_DIV,
SCORE_BOTH,
SCORE_BOTH,
true,
true,
true,
true,
true
true
);
);
}
if ($invalidateRanking) {
if ($invalidateRanking) {
$totalRanking = null;
$totalRanking = null;
@ -892,6 +870,7 @@ class GradebookTable extends SortableTable
$totalBest[1] = $main_weight;
$totalBest[1] = $main_weight;
$defaultData[$categoryId]['best'] = $totalBest;
$defaultData[$categoryId]['best'] = $totalBest;
}
}
if ($useExerciseScoreInTotal) {
if ($useExerciseScoreInTotal) {
if (isset($totalBest['score'])) {
if (isset($totalBest['score'])) {
$totalBestScore = $totalBest['score'];
$totalBestScore = $totalBest['score'];
@ -899,16 +878,16 @@ class GradebookTable extends SortableTable
$totalBestScore = $totalBest;
$totalBestScore = $totalBest;
}
}
$totalBest = ExerciseLib::show_score($totalBestScore[0], $totalBestScore[1], tru e);
$totalBest = ExerciseLib::show_score($totalBestScore[0], $totalBestScore[1], $showPercentag e);
} else {
} else {
$totalBest = $scoredisplay->display_score(
$totalBest = $scoredisplay->display_score(
$totalBest,
$totalBest,
SCORE_DIV,
SCORE_DIV,
SCORE_BOTH,
SCORE_BOTH,
true,
true,
false,
false,
true
true
);
);
}
}
$row[] = $totalBest;
$row[] = $totalBest;
}
}
@ -917,10 +896,21 @@ class GradebookTable extends SortableTable
if (isset($defaultData[$categoryId]) & & isset($defaultData[$categoryId]['average'])) {
if (isset($defaultData[$categoryId]) & & isset($defaultData[$categoryId]['average'])) {
$totalAverage = $defaultData[$categoryId]['average'];
$totalAverage = $defaultData[$categoryId]['average'];
} else {
} else {
$averageWeight = 0;
$categoryAverage = 0;
foreach ($totalAverageList as $averageScore) {
$categoryAverage += $averageScore[0];
$averageWeight += $averageScore[1];
}
$categoryAverage = $categoryAverage / count($totalAverageList);
//$averageWeight = $averageWeight ($totalAverageList);
// Overwrite main weight
// Overwrite main weight
$totalAverage[0] = $average / count($this->studentList);
//$totalAverage[0] = $average / count($this->studentList);
$totalAverage[1] = $main_weight;
//$totalAverage[1] = $main_weight;
$defaultData[$categoryId]['average'] = $totalBest;
$totalAverage[0] = $categoryAverage;
$totalAverage[1] = $averageWeight;
//$defaultData[$categoryId]['average'] = $totalBest;
}
}
if ($useExerciseScoreInTotal) {
if ($useExerciseScoreInTotal) {
@ -930,16 +920,16 @@ class GradebookTable extends SortableTable
$totalAverageScore = $totalAverage;
$totalAverageScore = $totalAverage;
}
}
$totalAverage = ExerciseLib::show_score($totalAverageScore[0], $totalAverageScore[1], tru e);
$totalAverage = ExerciseLib::show_score($totalAverageScore[0], $totalAverageScore[1], $showPercentag e);
} else {
} else {
$totalAverage = $scoredisplay->display_score(
$totalAverage = $scoredisplay->display_score(
$totalAverage,
$totalAverage,
SCORE_DIV,
SCORE_DIV,
SCORE_BOTH,
SCORE_BOTH,
true,
true,
false,
false,
true
true
);
);
}
}
$row[] = $totalAverage;
$row[] = $totalAverage;
@ -1062,8 +1052,8 @@ class GradebookTable extends SortableTable
$dataSet->addPoints($data['average'], get_lang('Average'));
$dataSet->addPoints($data['average'], get_lang('Average'));
$dataSet->addPoints($data['categories'], 'categories');
$dataSet->addPoints($data['categories'], 'categories');
$dataSet->setAbscissa('categories');
$dataSet->setAbscissa('categories');
$xSize = 6 00;
$xSize = 7 00;
$ySize = 4 00;
$ySize = 5 00;
$pChart = new pImage($xSize, $ySize, $dataSet);
$pChart = new pImage($xSize, $ySize, $dataSet);
/* Turn of Antialiasing */
/* Turn of Antialiasing */
$pChart->Antialias = false;
$pChart->Antialias = false;
@ -1085,8 +1075,9 @@ class GradebookTable extends SortableTable
$pChart->setGraphArea(50, 30, $xSize - 50, $ySize - 70);
$pChart->setGraphArea(50, 30, $xSize - 50, $ySize - 70);
$pChart->setFontProperties(
$pChart->setFontProperties(
[
[
'FontName' => api_get_path(SYS_FONTS_PATH).'opensans/OpenSans-Regular.ttf',
'FontName' => api_get_path(SYS_FONTS_PATH).'Harmattan/Harmattan-Regular.ttf',
'FontSize' => 12,
/*'FontName' => api_get_path(SYS_FONTS_PATH).'opensans/OpenSans-Regular.ttf',*/
'FontSize' => 10,
]
]
);
);
@ -1233,6 +1224,7 @@ class GradebookTable extends SortableTable
$categoryId = $item->getCategory()->get_id();
$categoryId = $item->getCategory()->get_id();
$is_student = api_is_student();
$is_student = api_is_student();
$cat = new Category();
$cat = new Category();
switch ($item->get_item_type()) {
switch ($item->get_item_type()) {
case 'C':
case 'C':
// Category
// Category
@ -1286,7 +1278,7 @@ class GradebookTable extends SortableTable
}
}
// no break because of return
// no break because of return
case 'L':
case 'L':
// l ink
// L ink
$course_id = CourseManager::get_course_by_category($categoryId);
$course_id = CourseManager::get_course_by_category($categoryId);
$show_message = $cat->show_message_resource_delete($course_id);
$show_message = $cat->show_message_resource_delete($course_id);
@ -1328,13 +1320,13 @@ class GradebookTable extends SortableTable
{
{
switch ($item->get_item_type()) {
switch ($item->get_item_type()) {
case 'C':
case 'C':
// c ategory
// C ategory
return GradebookUtils::build_edit_icons_cat($item, $this->currentcat);
return GradebookUtils::build_edit_icons_cat($item, $this->currentcat);
case 'E':
case 'E':
// e valuation
// E valuation
return GradebookUtils::build_edit_icons_eval($item, $this->currentcat->get_id());
return GradebookUtils::build_edit_icons_eval($item, $this->currentcat->get_id());
case 'L':
case 'L':
// l ink
// L ink
return GradebookUtils::build_edit_icons_link($item, $this->currentcat->get_id());
return GradebookUtils::build_edit_icons_link($item, $this->currentcat->get_id());
}
}
}
}