Internal: Merge from 1.11.x

pull/3733/head
Julio Montoya 5 years ago
parent 3b84630c11
commit a4752e802e
  1. 11
      public/main/gradebook/gradebook_display_summary.php
  2. 12
      public/main/gradebook/gradebook_flatview.php
  3. 2
      public/main/gradebook/gradebook_statistics.php
  4. 17
      public/main/gradebook/index.php
  5. 19
      public/main/gradebook/lib/GradebookUtils.php
  6. 7
      public/main/gradebook/lib/be/attendancelink.class.php
  7. 25
      public/main/gradebook/lib/be/category.class.php
  8. 10
      public/main/gradebook/lib/be/evaluation.class.php
  9. 43
      public/main/gradebook/lib/be/exerciselink.class.php
  10. 4
      public/main/gradebook/lib/be/result.class.php
  11. 2
      public/main/gradebook/lib/be/surveylink.class.php
  12. 7
      public/main/gradebook/lib/fe/displaygradebook.php
  13. 2
      public/main/gradebook/lib/fe/evalform.class.php
  14. 101
      public/main/gradebook/lib/fe/gradebooktable.class.php
  15. 2
      public/main/gradebook/lib/fe/linkaddeditform.class.php
  16. 4
      public/main/gradebook/lib/fe/linkform.class.php
  17. 2
      public/main/gradebook/lib/fe/resulttable.class.php
  18. 4
      public/main/gradebook/lib/fe/userform.class.php
  19. 17
      public/main/gradebook/lib/flatview_data_generator.class.php
  20. 105
      public/main/gradebook/lib/gradebook_data_generator.class.php
  21. 165
      public/main/gradebook/lib/scoredisplay.class.php
  22. 5
      public/main/gradebook/lib/user_data_generator.class.php
  23. 1
      public/main/gradebook/my_certificates.php
  24. 4
      public/main/mySpace/course.php
  25. 2
      public/main/mySpace/lp_tracking.php
  26. 279
      public/main/mySpace/myStudents.php
  27. 10
      public/main/tracking/courseLog.php
  28. 6
      public/main/tracking/course_log_tools.php
  29. 2
      public/main/tracking/lp_report.php
  30. 2
      public/main/user/resume_session.php

@ -142,7 +142,7 @@ switch ($action) {
case 'download': case 'download':
$userId = isset($_GET['user_id']) && $_GET['user_id'] ? $_GET['user_id'] : null; $userId = isset($_GET['user_id']) && $_GET['user_id'] ? $_GET['user_id'] : null;
$cats = Category::load($cat_id, null, null, null, null, null, false); $cats = Category::load($cat_id, null, null, null, null, null, false);
GradebookUtils::generateTable($courseInfo, $userId, $cats); GradebookUtils::generateTable($courseInfo, $userId, $cats, false, false, $userList);
break; break;
} }
@ -174,7 +174,8 @@ $allowSkillRelItem = api_get_configuration_value('allow_skill_rel_items');
if (0 == count($userList)) { if (0 == count($userList)) {
echo Display::return_message(get_lang('No results available'), 'warning'); echo Display::return_message(get_lang('No results available'), 'warning');
} else { } else {
echo '<br /><br /><table class="data_table">'; echo '<br /><br /><div class="table-responsive">
<table class="table table-hover table-striped table-bordered data_table">';
echo '<tr><th>'; echo '<tr><th>';
echo get_lang('Learner'); echo get_lang('Learner');
echo '</th>'; echo '</th>';
@ -182,9 +183,9 @@ if (0 == count($userList)) {
echo get_lang('Action'); echo get_lang('Action');
echo '</th></tr>'; echo '</th></tr>';
foreach ($userList as $index => $value) { foreach ($userList as $index => $value) {
$userData = api_get_person_name($value['firstname'], $value['lastname']).' ('.$value['username'].')';
echo '<tr> echo '<tr>
<td width="70%">' <td width="70%">'.$userData.'</td>';
.api_get_person_name($value['firstname'], $value['lastname']).' ('.$value['username'].') </td>';
echo '<td>'; echo '<td>';
$link = ''; $link = '';
if ($allowSkillRelItem) { if ($allowSkillRelItem) {
@ -206,7 +207,7 @@ if (0 == count($userList)) {
echo $link; echo $link;
echo '</td></tr>'; echo '</td></tr>';
} }
echo '</table>'; echo '</table></div>';
} }
Display::display_footer(); Display::display_footer();

@ -269,8 +269,11 @@ if (isset($_GET['exportpdf'])) {
} else { } else {
Display::display_header(get_lang('List View')); Display::display_header(get_lang('List View'));
} }
$studentView = api_is_student_view_active(); $studentView = api_is_student_view_active();
if (isset($_GET['isStudentView']) && 'false' === $_GET['isStudentView']) {
DisplayGradebook::display_header_reduce_flatview( DisplayGradebook::display_header_reduce_flatview(
$cat[0], $cat[0],
$showeval, $showeval,
@ -278,8 +281,15 @@ DisplayGradebook::display_header_reduce_flatview(
$simple_search_form $simple_search_form
); );
$flatViewTable->display(); $flatViewTable->display();
} elseif (isset($_GET['selectcat']) && ($studentView === 'teacherview')) {
DisplayGradebook::display_header_reduce_flatview(
$cat[0],
$showeval,
$showlink,
$simple_search_form
);
if (false === $studentView) { $flatViewTable->display();
//@todo load images with jquery //@todo load images with jquery
echo '<div id="contentArea" style="text-align: center;" >'; echo '<div id="contentArea" style="text-align: center;" >';
$flatViewTable->display_graph_by_resource(); $flatViewTable->display_graph_by_resource();

@ -82,7 +82,7 @@ if (!$displayScore->is_custom() || empty($displays)) {
} }
// Generate table // Generate table
$html = '<table class="data_table" cellspacing="0" cellpadding="3">'; $html = '<table class="table table-hover table-striped data_table" cellspacing="0" cellpadding="3">';
$html .= '<tr><th>'.get_lang('Skills ranking').'</th>'; $html .= '<tr><th>'.get_lang('Skills ranking').'</th>';
$html .= '<th>'.get_lang('Percentage').'</th>'; $html .= '<th>'.get_lang('Percentage').'</th>';
$html .= '<th>'.get_lang('Number of users').'</th></tr>'; $html .= '<th>'.get_lang('Number of users').'</th></tr>';

@ -937,6 +937,11 @@ if (isset($first_time) && 1 == $first_time && api_is_allowed_to_edit(null, true)
$allowGraph = false === api_get_configuration_value('gradebook_hide_graph'); $allowGraph = false === api_get_configuration_value('gradebook_hide_graph');
$isAllow = api_is_allowed_to_edit(null, true); $isAllow = api_is_allowed_to_edit(null, true);
$settings = api_get_configuration_value('gradebook_pdf_export_settings');
$showFeedBack = true;
if (isset($settings['hide_feedback_textarea']) && $settings['hide_feedback_textarea']) {
$showFeedBack = false;
}
/** @var Category $cat */ /** @var Category $cat */
foreach ($cats as $cat) { foreach ($cats as $cat) {
$allcat = $cat->get_subcategories($stud_id, $course_code, $session_id); $allcat = $cat->get_subcategories($stud_id, $course_code, $session_id);
@ -1026,13 +1031,13 @@ if (isset($first_time) && 1 == $first_time && api_is_allowed_to_edit(null, true)
'orientation' => 'P', 'orientation' => 'P',
]; ];
$feedback = '';
if ($showFeedBack) {
$feedback = '<br />'.get_lang('Feedback').'<br />
<textarea rows="5" cols="100" >&nbsp;</textarea>';
}
$pdf = new PDF('A4', $params['orientation'], $params); $pdf = new PDF('A4', $params['orientation'], $params);
$pdf->html_to_pdf_with_template( $pdf->html_to_pdf_with_template($table.$graph.$feedback);
$table.
$graph.
'<br />'.get_lang('Feedback').'<br />
<textarea rows="5" cols="100" >&nbsp;</textarea>'
);
} else { } else {
echo $table; echo $table;
echo $graph; echo $graph;

@ -974,7 +974,7 @@ class GradebookUtils
/** /**
* @param FlatViewTable $flatviewtable * @param FlatViewTable $flatviewtable
* @param array $cat * @param Category $cat
* @param $users * @param $users
* @param $alleval * @param $alleval
* @param $alllinks * @param $alllinks
@ -1051,7 +1051,7 @@ class GradebookUtils
$columns = count($printable_data[0]); $columns = count($printable_data[0]);
$has_data = is_array($printable_data[1]) && count($printable_data[1]) > 0; $has_data = is_array($printable_data[1]) && count($printable_data[1]) > 0;
$table = new HTML_Table(['class' => 'data_table']); $table = new HTML_Table(['class' => 'table table-hover table-striped data_table']);
$row = 0; $row = 0;
$column = 0; $column = 0;
$table->setHeaderContents($row, $column, get_lang('N°')); $table->setHeaderContents($row, $column, get_lang('N°'));
@ -1633,12 +1633,19 @@ class GradebookUtils
$pdf->params['student_info'] = $userInfo; $pdf->params['student_info'] = $userInfo;
$file = api_get_path(SYS_ARCHIVE_PATH).uniqid().'.html'; $file = api_get_path(SYS_ARCHIVE_PATH).uniqid().'.html';
$content = $settings = api_get_configuration_value('gradebook_pdf_export_settings');
$table. $showFeedBack = true;
$graph. if (isset($settings['hide_feedback_textarea']) && $settings['hide_feedback_textarea']) {
'<br />'.get_lang('Feedback').'<br /> $showFeedBack = false;
}
$feedback = '';
if ($showFeedBack) {
$feedback = '<br />'.get_lang('Feedback').'<br />
<textarea class="form-control" rows="5" cols="100">&nbsp;</textarea>'; <textarea class="form-control" rows="5" cols="100">&nbsp;</textarea>';
}
$content = $table.$graph.$feedback;
$result = $pdf->html_to_pdf_with_template( $result = $pdf->html_to_pdf_with_template(
$content, $content,
$saveToFile, $saveToFile,

@ -2,6 +2,9 @@
/* For licensing terms, see /license.txt */ /* For licensing terms, see /license.txt */
use Chamilo\CoreBundle\Framework\Container;
use Chamilo\CourseBundle\Entity\CAttendance;
/** /**
* Gradebook link to attendance item. * Gradebook link to attendance item.
* *
@ -48,7 +51,7 @@ class AttendanceLink extends AbstractLink
return []; return [];
} }
$sessionId = $this->get_session_id(); $sessionId = $this->get_session_id();
$repo = \Chamilo\CoreBundle\Framework\Container::getStudentPublicationRepository(); $repo = Container::getAttendanceRepository();
$qb = $repo->getResourcesByCourse(api_get_course_entity($this->course_id), api_get_session_entity($sessionId)); $qb = $repo->getResourcesByCourse(api_get_course_entity($this->course_id), api_get_session_entity($sessionId));
$qb->andWhere('resource.active = 1'); $qb->andWhere('resource.active = 1');
$links = $qb->getQuery()->getResult(); $links = $qb->getQuery()->getResult();
@ -62,7 +65,7 @@ class AttendanceLink extends AbstractLink
att.session_id = '.$sessionId; att.session_id = '.$sessionId;
$result = Database::query($sql);*/ $result = Database::query($sql);*/
/** @var \Chamilo\CourseBundle\Entity\CAttendance $link */ /** @var CAttendance $link */
foreach ($links as $link) { foreach ($links as $link) {
$title = $link->getAttendanceQualifyTitle(); $title = $link->getAttendanceQualifyTitle();
if (!empty($title)) { if (!empty($title)) {

@ -1085,8 +1085,10 @@ class Category implements GradebookItem
foreach ($links as $link) { foreach ($links as $link) {
$linkres = $link->calc_score($studentId, null); $linkres = $link->calc_score($studentId, null);
$linkweight = $link->get_weight(); $linkweight = $link->get_weight();
$link_res_denom = 0 == $linkres[1] ? 1 : $linkres[1]; if ($linkres) {
$ressum = $linkres[0] / $link_res_denom * $linkweight; $link_res_denom = 0 == $linkres[1] ? 1 : $linkres[1];
$ressum = $linkres[0] / $link_res_denom * $linkweight;
}
if (!isset($totalScorePerStudent[$studentId])) { if (!isset($totalScorePerStudent[$studentId])) {
$totalScorePerStudent[$studentId] = 0; $totalScorePerStudent[$studentId] = 0;
@ -2076,13 +2078,15 @@ class Category implements GradebookItem
* @param int $category_id gradebook id * @param int $category_id gradebook id
* @param int $user_id * @param int $user_id
* @param bool $sendNotification * @param bool $sendNotification
* @param bool $skipGenerationIfExists
* *
* @return array * @return array
*/ */
public static function generateUserCertificate( public static function generateUserCertificate(
$category_id, $category_id,
$user_id, $user_id,
$sendNotification = false $sendNotification = false,
$skipGenerationIfExists = false
) { ) {
$user_id = (int) $user_id; $user_id = (int) $user_id;
$category_id = (int) $category_id; $category_id = (int) $category_id;
@ -2174,6 +2178,9 @@ class Category implements GradebookItem
$user_id $user_id
); );
if ($skipGenerationIfExists && !empty($my_certificate)) {
return false;
}
if (empty($my_certificate)) { if (empty($my_certificate)) {
GradebookUtils::registerUserInfoAboutCertificate( GradebookUtils::registerUserInfoAboutCertificate(
$category_id, $category_id,
@ -2798,22 +2805,18 @@ class Category implements GradebookItem
* *
* @return float The score * @return float The score
*/ */
private static function calculateCurrentScore( private static function calculateCurrentScore($userId, $category)
$userId, {
$category
) {
if (empty($category)) { if (empty($category)) {
return 0; return 0;
} }
$courseEvaluations = $category->get_evaluations( $courseEvaluations = $category->get_evaluations($userId, true);
$userId,
true
);
$courseLinks = $category->get_links($userId, true); $courseLinks = $category->get_links($userId, true);
$evaluationsAndLinks = array_merge($courseEvaluations, $courseLinks); $evaluationsAndLinks = array_merge($courseEvaluations, $courseLinks);
$categoryScore = 0; $categoryScore = 0;
for ($i = 0; $i < count($evaluationsAndLinks); $i++) { for ($i = 0; $i < count($evaluationsAndLinks); $i++) {
$item = $evaluationsAndLinks[$i]; $item = $evaluationsAndLinks[$i];
$item->set_session_id($category->get_session_id());
$score = $item->calc_score($userId); $score = $item->calc_score($userId);
$itemValue = 0; $itemValue = 0;
if (!empty($score)) { if (!empty($score)) {

@ -588,10 +588,12 @@ class Evaluation implements GradebookItem
Session::write('calc_score', [$key => $results]); Session::write('calc_score', [$key => $results]);
} }
$score = 0; $score = null;
/** @var Result $res */ if (!empty($results)) {
foreach ($results as $res) { /** @var Result $res */
$score = $res->get_score(); foreach ($results as $res) {
$score = $res->get_score();
}
} }
return [$score, $this->get_max()]; return [$score, $this->get_max()];

@ -10,6 +10,7 @@
*/ */
class ExerciseLink extends AbstractLink class ExerciseLink extends AbstractLink
{ {
public $checkBaseExercises = false;
private $course_info; private $course_info;
private $exercise_table; private $exercise_table;
private $exercise_data = []; private $exercise_data = [];
@ -135,21 +136,17 @@ class ExerciseLink extends AbstractLink
switch ($type) { switch ($type) {
case 'best': case 'best':
$bestResult = $link->getBestScore(); $bestResult = $link->getBestScore();
$result = [$bestResult, $weight];
return $result; return [$bestResult, $weight];
break; break;
case 'average': case 'average':
$count = count($this->getStudentList()); $count = count($link->getUserScoreList());
if (empty($count)) { if (empty($count)) {
$result = [0, $weight]; return [0, $weight];
return $result;
} }
$sumResult = array_sum($link->getUserScoreList()); $sumResult = array_sum($link->getUserScoreList());
$result = [$sumResult / $count, $weight];
return $result; return [$sumResult / $count, $weight];
break; break;
case 'ranking': case 'ranking':
return [null, null]; return [null, null];
@ -184,7 +181,7 @@ class ExerciseLink extends AbstractLink
$sessionId = $this->get_session_id(); $sessionId = $this->get_session_id();
$courseId = $this->getCourseId(); $courseId = $this->getCourseId();
$exerciseData = $this->get_exercise_data(); $exerciseData = $this->get_exercise_data();
$exerciseId = isset($exerciseData['id']) ? (int) $exerciseData['id'] : 0; $exerciseId = isset($exerciseData['iid']) ? (int) $exerciseData['iid'] : 0;
$studentId = (int) $studentId; $studentId = (int) $studentId;
if (empty($exerciseId)) { if (empty($exerciseId)) {
@ -225,11 +222,27 @@ class ExerciseLink extends AbstractLink
//$lpId = $exercise->getLpBySession($sessionId); //$lpId = $exercise->getLpBySession($sessionId);
$lpList = []; $lpList = [];
foreach ($exercise->lpList as $lpData) { foreach ($exercise->lpList as $lpData) {
if ($this->checkBaseExercises) {
if ((int) $lpData['session_id'] == 0) {
$lpList[] = $lpData['lp_id'];
}
} else {
if ((int) $lpData['session_id'] == $sessionId) { if ((int) $lpData['session_id'] == $sessionId) {
$lpList[] = $lpData['lp_id']; $lpList[] = $lpData['lp_id'];
} }
} }
$lpCondition = ' orig_lp_id = 0 OR (orig_lp_id IN ("'.implode('", "', $lpList).'")) AND '; }
if (empty($lpList) && !empty($sessionId)) {
// Check also if an LP was added in the base course.
foreach ($exercise->lpList as $lpData) {
if ((int) $lpData['session_id'] == 0) {
$lpList[] = $lpData['lp_id'];
}
}
}
$lpCondition = ' (orig_lp_id = 0 OR (orig_lp_id IN ("'.implode('", "', $lpList).'"))) AND ';
} }
$sql = "SELECT * $sql = "SELECT *
@ -385,7 +398,7 @@ class ExerciseLink extends AbstractLink
{ {
$sessionId = $this->get_session_id(); $sessionId = $this->get_session_id();
$data = $this->get_exercise_data(); $data = $this->get_exercise_data();
$exerciseId = $data['id']; $exerciseId = $data['iid'];
$path = isset($data['path']) ? $data['path'] : ''; $path = isset($data['path']) ? $data['path'] : '';
return api_get_path(WEB_CODE_PATH).'gradebook/exercise_jump.php?' return api_get_path(WEB_CODE_PATH).'gradebook/exercise_jump.php?'
@ -414,7 +427,7 @@ class ExerciseLink extends AbstractLink
public function getLpListToString() public function getLpListToString()
{ {
$data = $this->get_exercise_data(); $data = $this->get_exercise_data();
$lpList = Exercise::getLpListFromExercise($data['id'], $this->getCourseId()); $lpList = Exercise::getLpListFromExercise($data['iid'], $this->getCourseId());
$lpListToString = ''; $lpListToString = '';
if (!empty($lpList)) { if (!empty($lpList)) {
foreach ($lpList as &$list) { foreach ($lpList as &$list) {
@ -523,7 +536,7 @@ class ExerciseLink extends AbstractLink
if (empty($this->exercise_data)) { if (empty($this->exercise_data)) {
if (1 == $this->is_hp) { if (1 == $this->is_hp) {
$sql = "SELECT * FROM $table ex /*$sql = "SELECT * FROM $table ex
INNER JOIN $tableItemProperty ip INNER JOIN $tableItemProperty ip
ON (ip.ref = ex.id AND ip.c_id = ex.c_id) ON (ip.ref = ex.id AND ip.c_id = ex.c_id)
WHERE WHERE
@ -535,7 +548,7 @@ class ExerciseLink extends AbstractLink
ex.path LIKE '%HotPotatoes_files%' AND ex.path LIKE '%HotPotatoes_files%' AND
ip.visibility = 1"; ip.visibility = 1";
$result = Database::query($sql); $result = Database::query($sql);
$this->exercise_data = Database::fetch_array($result); $this->exercise_data = Database::fetch_array($result);*/
} else { } else {
// Try with iid // Try with iid
$sql = 'SELECT * FROM '.$table.' $sql = 'SELECT * FROM '.$table.'
@ -552,7 +565,7 @@ class ExerciseLink extends AbstractLink
$sql = 'SELECT * FROM '.$table.' $sql = 'SELECT * FROM '.$table.'
WHERE WHERE
c_id = '.$this->course_id.' AND c_id = '.$this->course_id.' AND
id = '.$exerciseId; iid = '.$exerciseId;
$result = Database::query($sql); $result = Database::query($sql);
$this->exercise_data = Database::fetch_array($result); $this->exercise_data = Database::fetch_array($result);
} }

@ -217,7 +217,7 @@ class Result
$sql .= ")"; $sql .= ")";
Database::query($sql); Database::query($sql);
} else { } else {
die('Error in Result add: required field empty'); exit('Error in Result add: required field empty');
} }
} }
@ -247,7 +247,7 @@ class Result
Database::query($sql); Database::query($sql);
} else { } else {
die('Error in Result add: required field empty'); exit('Error in Result add: required field empty');
} }
} }

@ -77,7 +77,7 @@ class SurveyLink extends AbstractLink
public function get_all_links() public function get_all_links()
{ {
if (empty($this->course_code)) { if (empty($this->course_code)) {
die('Error in get_all_links() : course code not set'); exit('Error in get_all_links() : course code not set');
} }
$tbl_survey = $this->get_survey_table(); $tbl_survey = $this->get_survey_table();
$sessionId = $this->get_session_id(); $sessionId = $this->get_session_id();

@ -11,7 +11,8 @@ class DisplayGradebook
* Displays the header for the result page containing the navigation tree and links. * Displays the header for the result page containing the navigation tree and links.
* *
* @param Evaluation $evalobj * @param Evaluation $evalobj
* @param $selectcat * @param int $selectcat
* @param string $page
*/ */
public static function display_header_result($evalobj, $selectcat, $page) public static function display_header_result($evalobj, $selectcat, $page)
{ {
@ -151,8 +152,8 @@ class DisplayGradebook
$header .= '<a href="'.$url.'?'.api_get_cidreq().'&selectcat='.$select_cat.'">'. $header .= '<a href="'.$url.'?'.api_get_cidreq().'&selectcat='.$select_cat.'">'.
Display::return_icon('back.png', get_lang('Assessment home'), '', ICON_SIZE_MEDIUM).'</a>'; Display::return_icon('back.png', get_lang('Assessment home'), '', ICON_SIZE_MEDIUM).'</a>';
$pageNum = isset($_GET['flatviewlist_page_nr']) ? intval($_GET['flatviewlist_page_nr']) : null; $pageNum = isset($_GET['flatviewlist_page_nr']) ? (int) $_GET['flatviewlist_page_nr'] : null;
$perPage = isset($_GET['flatviewlist_per_page']) ? intval($_GET['flatviewlist_per_page']) : null; $perPage = isset($_GET['flatviewlist_per_page']) ? (int) $_GET['flatviewlist_per_page'] : null;
$offset = isset($_GET['offset']) ? $_GET['offset'] : '0'; $offset = isset($_GET['offset']) ? $_GET['offset'] : '0';
$exportCsvUrl = api_get_self().'?'.api_get_cidreq().'&'.http_build_query([ $exportCsvUrl = api_get_self().'?'.api_get_cidreq().'&'.http_build_query([

@ -309,7 +309,7 @@ class EvalForm extends FormValidator
$renderer->setFormTemplate( $renderer->setFormTemplate(
'<form{attributes}> '<form{attributes}>
<div class="table-responsive"> <div class="table-responsive">
<table class="data_table"> <table class="table table-hover table-striped data_table">
{content} {content}
</table> </table>
</div> </div>

@ -79,6 +79,7 @@ class GradebookTable extends SortableTable
$this->cats = $cats; $this->cats = $cats;
$this->loadStats = $loadStats; $this->loadStats = $loadStats;
$this->datagen = new GradebookDataGenerator($cats, $evals, $links); $this->datagen = new GradebookDataGenerator($cats, $evals, $links);
$this->datagen->exportToPdf = $this->exportToPdf;
$this->datagen->preLoadDataKey = $this->getPreloadDataKey(); $this->datagen->preLoadDataKey = $this->getPreloadDataKey();
$this->datagen->hidePercentage = api_get_configuration_value('hide_gradebook_percentage_user_result'); $this->datagen->hidePercentage = api_get_configuration_value('hide_gradebook_percentage_user_result');
@ -97,7 +98,7 @@ class GradebookTable extends SortableTable
} }
} }
$this->set_header($column++, get_lang('Type'), '', 'width="35px"'); $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) {
@ -106,12 +107,19 @@ class GradebookTable extends SortableTable
$model = ExerciseLib::getCourseScoreModel(); $model = ExerciseLib::getCourseScoreModel();
$settings = api_get_configuration_value('gradebook_pdf_export_settings');
$showWeight = true;
if ($this->exportToPdf && isset($settings['hide_score_weight']) && $settings['hide_score_weight']) {
$showWeight = false;
}
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) {
$this->set_header($column++, get_lang('Result'), false); $this->set_header($column++, get_lang('Result'), false);
@ -119,13 +127,13 @@ class GradebookTable extends SortableTable
if (empty($model)) { if (empty($model)) {
if (in_array(1, $this->loadStats)) { if (in_array(1, $this->loadStats)) {
$this->set_header($column++, get_lang('Ranking'), false); $this->set_header($column++, get_lang('Ranking'), false, 'width="50px"');
} }
if (in_array(2, $this->loadStats)) { if (in_array(2, $this->loadStats)) {
$this->set_header($column++, get_lang('Best score'), false); $this->set_header($column++, get_lang('BestScore'), false, 'width="140px"');
} }
if (in_array(3, $this->loadStats)) { if (in_array(3, $this->loadStats)) {
$this->set_header($column++, get_lang('Average'), false); $this->set_header($column++, get_lang('Average'), false, 'width="140px"');
} }
} }
@ -375,7 +383,6 @@ class GradebookTable extends SortableTable
$total_categories_weight = 0; $total_categories_weight = 0;
$scoredisplay = ScoreDisplay::instance(); $scoredisplay = ScoreDisplay::instance();
$totalUserResult = [0, 0];
$totalBest = [0, 0]; $totalBest = [0, 0];
$totalAverage = [0, 0]; $totalAverage = [0, 0];
@ -389,9 +396,15 @@ class GradebookTable extends SortableTable
'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');
$course_code = api_get_course_id(); $course_code = api_get_course_id();
$session_id = api_get_session_id(); $session_id = api_get_session_id();
$defaultData = Session::read($this->getPreloadDataKey()); $defaultData = Session::read($this->getPreloadDataKey());
$settings = api_get_configuration_value('gradebook_pdf_export_settings');
$showWeight = true;
if ($this->exportToPdf && isset($settings['hide_score_weight']) && $settings['hide_score_weight']) {
$showWeight = false;
}
// Categories. // Categories.
if (!empty($data_array)) { if (!empty($data_array)) {
@ -445,12 +458,14 @@ class GradebookTable extends SortableTable
true true
); );
if ($this->teacherView) { if ($showWeight) {
$row[] = $invisibility_span_open. if ($this->teacherView) {
Display::tag('p', $weight, ['class' => 'score']). $row[] = $invisibility_span_open.
$invisibility_span_close; Display::tag('p', $weight, ['class' => 'score']).
} else { $invisibility_span_close;
$row[] = $invisibility_span_open.$weight.$invisibility_span_close; } else {
$row[] = $invisibility_span_open.$weight.$invisibility_span_close;
}
} }
$category_weight = $item->get_weight(); $category_weight = $item->get_weight();
@ -467,14 +482,13 @@ class GradebookTable extends SortableTable
$row[] = $this->build_edit_column($item); $row[] = $this->build_edit_column($item);
} }
} else { } else {
$score = $item->calc_score($this->userId); /*$score = $item->calc_score($this->userId);
if (!empty($score[1])) { if (!empty($score[1])) {
$completeScore = $scoredisplay->display_score($score, SCORE_DIV_PERCENT);
$score = $score[0] / $score[1] * $item->get_weight(); $score = $score[0] / $score[1] * $item->get_weight();
$score = $scoredisplay->display_score([$score, null], SCORE_SIMPLE); $score = $scoredisplay->display_score([$score, null], SCORE_SIMPLE);
} else { } else {
$categoryScore = null; $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;
@ -493,10 +507,13 @@ class GradebookTable extends SortableTable
$scoredisplay->format_score($totalBest[1] + $data['best_score'][1]), $scoredisplay->format_score($totalBest[1] + $data['best_score'][1]),
]; ];
$totalAverage = [0, 0];
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 // Student result
@ -527,8 +544,12 @@ class GradebookTable extends SortableTable
$data['my_result_no_float'][0] = $result['score']; $data['my_result_no_float'][0] = $result['score'];
} }
$totalResultAverageValue = strip_tags($scoredisplay->display_score($totalResult, $mode)); $totalResultAverageValue = strip_tags(
$totalAverageValue = strip_tags($scoredisplay->display_score($totalAverage, $mode)); $scoredisplay->display_score($totalResult, $mode, null, false, false, true)
);
$totalAverageValue = strip_tags(
$scoredisplay->display_score($totalAverage, $mode, null, false, false, true)
);
$this->dataForGraph['my_result'][] = floatval($totalResultAverageValue); $this->dataForGraph['my_result'][] = floatval($totalResultAverageValue);
$this->dataForGraph['average'][] = floatval($totalAverageValue); $this->dataForGraph['average'][] = floatval($totalAverageValue);
@ -581,6 +602,7 @@ class GradebookTable extends SortableTable
$alllink = $subCategory->get_links($this->userId); $alllink = $subCategory->get_links($this->userId);
$sub_cat_info = new GradebookDataGenerator($allcat, $alleval, $alllink); $sub_cat_info = new GradebookDataGenerator($allcat, $alleval, $alllink);
$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(
@ -628,7 +650,9 @@ class GradebookTable extends SortableTable
$total_weight += $weight; $total_weight += $weight;
// Weight // Weight
$row[] = $invisibility_span_open.$weight.$invisibility_span_close; if ($showWeight) {
$row[] = $invisibility_span_open.$weight.$invisibility_span_close;
}
// Admins get an edit column. // Admins get an edit column.
if (api_is_allowed_to_edit(null, true) && if (api_is_allowed_to_edit(null, true) &&
@ -776,8 +800,15 @@ class GradebookTable extends SortableTable
} else { } else {
$totalResult = $scoredisplay->display_score( $totalResult = $scoredisplay->display_score(
$totalResult, $totalResult,
SCORE_DIV SCORE_DIV,
null,
false,
false,
true
); );
if ($useExerciseScoreInTotal) {
$totalResult = ExerciseLib::show_score($myTotal, $main_weight, false);
}
} }
$row = [ $row = [
@ -789,7 +820,9 @@ class GradebookTable extends SortableTable
$row[] = null; $row[] = null;
} }
$row[] = $main_weight; if ($showWeight) {
$row[] = $main_weight;
}
$row[] = $totalResult; $row[] = $totalResult;
$categoryId = $main_cat[0]->get_id(); $categoryId = $main_cat[0]->get_id();
@ -826,13 +859,18 @@ 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
); );
}
if ($invalidateRanking) { if ($invalidateRanking) {
$totalRanking = null; $totalRanking = null;
@ -848,12 +886,24 @@ class GradebookTable extends SortableTable
$totalBest[1] = $main_weight; $totalBest[1] = $main_weight;
$defaultData[$categoryId]['best'] = $totalBest; $defaultData[$categoryId]['best'] = $totalBest;
} }
if ($useExerciseScoreInTotal) {
if (isset($totalBest['score'])) {
$totalBestScore = $totalBest['score'];
} else {
$totalBestScore = $totalBest;
}
$totalBest = ExerciseLib::show_score($totalBestScore[0], $totalBestScore[1], true);
} else {
$totalBest = $scoredisplay->display_score( $totalBest = $scoredisplay->display_score(
$totalBest, $totalBest,
SCORE_DIV, SCORE_DIV,
SCORE_BOTH, SCORE_BOTH,
true,
false,
true true
); );
}
$row[] = $totalBest; $row[] = $totalBest;
} }
@ -867,12 +917,24 @@ class GradebookTable extends SortableTable
$defaultData[$categoryId]['average'] = $totalBest; $defaultData[$categoryId]['average'] = $totalBest;
} }
if ($useExerciseScoreInTotal) {
if (isset($totalAverage['score'])) {
$totalAverageScore = $totalAverage['score'];
} else {
$totalAverageScore = $totalAverage;
}
$totalAverage = ExerciseLib::show_score($totalAverageScore[0], $totalAverageScore[1], true);
} else {
$totalAverage = $scoredisplay->display_score( $totalAverage = $scoredisplay->display_score(
$totalAverage, $totalAverage,
SCORE_DIV, SCORE_DIV,
SCORE_BOTH, SCORE_BOTH,
true,
false,
true true
); );
}
$row[] = $totalAverage; $row[] = $totalAverage;
} }
@ -1165,7 +1227,6 @@ class GradebookTable extends SortableTable
$categoryId = $item->getCategory()->get_id(); $categoryId = $item->getCategory()->get_id();
$cat = new Category(); $cat = new Category();
$is_student = api_is_student();
switch ($item->get_item_type()) { switch ($item->get_item_type()) {
case 'C': case 'C':
// Category // Category

@ -37,7 +37,7 @@ class LinkAddEditForm extends FormValidator
$link->set_session_id(api_get_session_id()); $link->set_session_id(api_get_session_id());
$link->set_category_id($category_object[0]->get_id()); $link->set_category_id($category_object[0]->get_id());
} else { } else {
die('LinkAddEditForm error: define link_type/category_object or link_object'); exit('LinkAddEditForm error: define link_type/category_object or link_object');
} }
$defaults = []; $defaults = [];

@ -115,7 +115,7 @@ class LinkForm extends FormValidator
if (LINK_EXERCISE == $link->get_type()) { if (LINK_EXERCISE == $link->get_type()) {
// Adding hot potatoes // Adding hot potatoes
$linkHot = $this->createLink(LINK_HOTPOTATOES, $courseCode); /*$linkHot = $this->createLink(LINK_HOTPOTATOES, $courseCode);
$linkHot->setHp(true); $linkHot->setHp(true);
if ($linkHot->get_all_links(true)) { if ($linkHot->get_all_links(true)) {
$select->addOption( $select->addOption(
@ -128,7 +128,7 @@ class LinkForm extends FormValidator
LINK_HOTPOTATOES, LINK_HOTPOTATOES,
'disabled' 'disabled'
); );
} }*/
} }
} }

@ -189,7 +189,7 @@ class ResultTable extends SortableTable
$resultQuery = Database::query($sql); $resultQuery = Database::query($sql);
$list = Database::store_result($resultQuery); $list = Database::store_result($resultQuery);
$htmlTable = new HTML_Table(['class' => 'data_table']); $htmlTable = new HTML_Table(['class' => 'table table-hover table-striped data_table']);
$htmlTable->setHeaderContents(0, 0, get_lang('Score')); $htmlTable->setHeaderContents(0, 0, get_lang('Score'));
$htmlTable->setHeaderContents(0, 1, get_lang('Comment')); $htmlTable->setHeaderContents(0, 1, get_lang('Comment'));
$htmlTable->setHeaderContents(0, 2, get_lang('Created at')); $htmlTable->setHeaderContents(0, 2, get_lang('Created at'));

@ -28,9 +28,9 @@ class UserForm extends FormValidator
if (isset($user)) { if (isset($user)) {
$this->user_info = $user; $this->user_info = $user;
} }
/*if (isset($result_object)) { if (isset($result_object)) {
$this->result_object = $result_object; $this->result_object = $result_object;
}*/ }
if (self::TYPE_USER_INFO == $this->form_type) { if (self::TYPE_USER_INFO == $this->form_type) {
$this->build_user_info_form(); $this->build_user_info_form();
} elseif (self::TYPE_SIMPLE_SEARCH == $this->form_type) { } elseif (self::TYPE_SIMPLE_SEARCH == $this->form_type) {

@ -224,7 +224,13 @@ class FlatViewDataGenerator
} }
} }
$headers[] = '<span class="text-center">'.api_strtoupper(get_lang('Total')).'</span>'; $headers[] = '<span class="text-center">'.api_strtoupper(get_lang('GradebookQualificationTotal')).'</span>';
if (api_get_configuration_value('gradebook_score_display_custom_standalone')
&& ScoreDisplay::instance()->is_custom()
) {
$headers[] = get_lang('GradebookScoreDisplayCustomValues');
}
return $headers; return $headers;
} }
@ -570,6 +576,8 @@ class FlatViewDataGenerator
$item_value_total += $result['item_value_total']; $item_value_total += $result['item_value_total'];
$total_score = [$item_value_total, $item_total]; $total_score = [$item_value_total, $item_total];
$style = api_get_configuration_value('gradebook_report_score_style'); $style = api_get_configuration_value('gradebook_report_score_style');
$customDisplayIsStandalone = api_get_configuration_value('gradebook_score_display_custom_standalone')
&& $scoreDisplay->is_custom();
if (!$show_all) { if (!$show_all) {
$defaultStyle = empty($style) ? SCORE_DIV_PERCENT : (int) $style; $defaultStyle = empty($style) ? SCORE_DIV_PERCENT : (int) $style;
@ -594,6 +602,13 @@ class FlatViewDataGenerator
$row[] = $displayScore; $row[] = $displayScore;
} }
} }
if ($customDisplayIsStandalone) {
if ($export_to_pdf) {
$row['display_custom'] = $scoreDisplay->display_custom($total_score);
} else {
$row[] = $scoreDisplay->display_custom($total_score);
}
}
unset($score); unset($score);
$data[] = $row; $data[] = $row;
} }

@ -27,6 +27,7 @@ class GradebookDataGenerator
public $items; public $items;
public $preLoadDataKey; public $preLoadDataKey;
public $exportToPdf;
private $evals_links; private $evals_links;
/** /**
@ -39,6 +40,7 @@ class GradebookDataGenerator
$allcats = isset($cats) ? $cats : []; $allcats = isset($cats) ? $cats : [];
$allevals = isset($evals) ? $evals : []; $allevals = isset($evals) ? $evals : [];
$alllinks = isset($links) ? $links : []; $alllinks = isset($links) ? $links : [];
$this->exportToPdf = false;
// if we are in the root category and if there are sub categories // if we are in the root category and if there are sub categories
// display only links depending of the root category and not link that belongs // display only links depending of the root category and not link that belongs
@ -120,6 +122,7 @@ class GradebookDataGenerator
$defaultData = Session::read($this->preLoadDataKey); $defaultData = Session::read($this->preLoadDataKey);
$model = ExerciseLib::getCourseScoreModel(); $model = ExerciseLib::getCourseScoreModel();
$useExerciseScoreInTotal = api_get_configuration_value('gradebook_use_exercise_score_settings_in_total');
/** @var GradebookItem $item */ /** @var GradebookItem $item */
foreach ($visibleItems as $item) { foreach ($visibleItems as $item) {
@ -140,7 +143,8 @@ class GradebookDataGenerator
$resultColumn = $this->build_result_column( $resultColumn = $this->build_result_column(
$userId, $userId,
$item, $item,
$ignore_score_color $ignore_score_color,
false
); );
$row[] = $resultColumn['display']; $row[] = $resultColumn['display'];
@ -334,7 +338,8 @@ class GradebookDataGenerator
$userId, $userId,
$item, $item,
$ignore_score_color, $ignore_score_color,
true true,
$useExerciseScoreInTotal
); );
$row[] = $result['display']; $row[] = $result['display'];
$row['result_score'] = $result['score']; $row['result_score'] = $result['score'];
@ -344,8 +349,14 @@ class GradebookDataGenerator
// Best // Best
if (isset($defaultData[$item->get_id()]) && isset($defaultData[$item->get_id()]['best'])) { if (isset($defaultData[$item->get_id()]) && isset($defaultData[$item->get_id()]['best'])) {
$best = $defaultData[$item->get_id()]['best']; $best = $defaultData[$item->get_id()]['best'];
if ($useExerciseScoreInTotal) {
$bestScore = $best['score'];
$best['display'] = ExerciseLib::show_score($bestScore[0], $bestScore[1], true);
} else { } else {
$best = $this->buildBestResultColumn($item); $best = $defaultData[$item->get_id()]['best'];
}
} else {
$best = $this->buildBestResultColumn($item, $useExerciseScoreInTotal);
} }
$row['best'] = $best['display']; $row['best'] = $best['display'];
@ -357,8 +368,12 @@ class GradebookDataGenerator
// Average // Average
if (isset($defaultData[$item->get_id()]) && isset($defaultData[$item->get_id()]['average'])) { if (isset($defaultData[$item->get_id()]) && isset($defaultData[$item->get_id()]['average'])) {
$average = $defaultData[$item->get_id()]['average']; $average = $defaultData[$item->get_id()]['average'];
if ($useExerciseScoreInTotal) {
$averageScore = $average['score'];
$average['display'] = ExerciseLib::show_score($averageScore[0], $averageScore[1], true);
}
} else { } else {
$average = $this->buildAverageResultColumn($item); $average = $this->buildAverageResultColumn($item, $useExerciseScoreInTotal);
} }
$row['average'] = $average['display']; $row['average'] = $average['display'];
$row['average_score'] = $average['score']; $row['average_score'] = $average['score'];
@ -392,6 +407,7 @@ class GradebookDataGenerator
SCORE_DIV, SCORE_DIV,
SCORE_BOTH, SCORE_BOTH,
true, true,
true,
true true
); );
@ -419,7 +435,8 @@ class GradebookDataGenerator
{ {
if (is_a($item, 'Category')) { if (is_a($item, 'Category')) {
if ($item->is_certificate_available(api_get_user_id())) { if ($item->is_certificate_available(api_get_user_id())) {
$link = '<a href="'.Category::getUrl().'export_certificate=1&cat='.$item->get_id().'&user='.api_get_user_id().'">'. $link = '<a
href="'.Category::getUrl().'export_certificate=1&cat='.$item->get_id().'&user='.api_get_user_id().'">'.
get_lang('Certificate').'</a>'; get_lang('Certificate').'</a>';
return $link; return $link;
@ -461,9 +478,8 @@ class GradebookDataGenerator
{ {
if ($item1->get_item_type() == $item2->get_item_type()) { if ($item1->get_item_type() == $item2->get_item_type()) {
return $this->sort_by_name($item1, $item2); return $this->sort_by_name($item1, $item2);
} else {
return $item1->get_item_type() < $item2->get_item_type() ? -1 : 1;
} }
return $item1->get_item_type() < $item2->get_item_type() ? -1 : 1;
} }
/** /**
@ -492,9 +508,8 @@ class GradebookDataGenerator
{ {
if ($item1->get_weight() == $item2->get_weight()) { if ($item1->get_weight() == $item2->get_weight()) {
return $this->sort_by_name($item1, $item2); return $this->sort_by_name($item1, $item2);
} else {
return $item1->get_weight() < $item2->get_weight() ? -1 : 1;
} }
return $item1->get_weight() < $item2->get_weight() ? -1 : 1;
} }
/** /**
@ -524,9 +539,8 @@ class GradebookDataGenerator
if ($timestamp1 == $timestamp2) { if ($timestamp1 == $timestamp2) {
return $this->sort_by_name($item1, $item2); return $this->sort_by_name($item1, $item2);
} else {
return $timestamp1 < $timestamp2 ? -1 : 1;
} }
return $timestamp1 < $timestamp2 ? -1 : 1;
} }
/** /**
@ -534,7 +548,7 @@ class GradebookDataGenerator
* *
* @return array * @return array
*/ */
public function buildBestResultColumn(GradebookItem $item) public function buildBestResultColumn(GradebookItem $item, $userExerciseSettings = false)
{ {
$score = $item->calc_score( $score = $item->calc_score(
null, null,
@ -560,11 +574,25 @@ class GradebookDataGenerator
$score, $score,
$scoreMode, $scoreMode,
SCORE_BOTH, SCORE_BOTH,
true,
false,
true true
); );
$type = $item->get_item_type(); $type = $item->get_item_type();
if ('L' === $type && 'ExerciseLink' === get_class($item)) { if ('L' === $type && 'ExerciseLink' === get_class($item)) {
$display = ExerciseLib::show_score($score[0], $score[1], false); $display = ExerciseLib::show_score(
$score[0],
$score[1],
false
);
}
if ($userExerciseSettings) {
$display = ExerciseLib::show_score(
$score[0],
$score[1],
true
);
} }
return [ return [
@ -576,7 +604,7 @@ class GradebookDataGenerator
/** /**
* @return array * @return array
*/ */
public function buildAverageResultColumn(GradebookItem $item) public function buildAverageResultColumn(GradebookItem $item, $userExerciseSettings = false)
{ {
$score = $item->calc_score(null, 'average'); $score = $item->calc_score(null, 'average');
@ -598,6 +626,8 @@ class GradebookDataGenerator
$score, $score,
$scoreMode, $scoreMode,
SCORE_BOTH, SCORE_BOTH,
true,
false,
true true
); );
$type = $item->get_item_type(); $type = $item->get_item_type();
@ -607,6 +637,14 @@ class GradebookDataGenerator
$result = ExerciseLib::convertScoreToPlatformSetting($score[0], $score[1]); $result = ExerciseLib::convertScoreToPlatformSetting($score[0], $score[1]);
$score[0] = $result['score']; $score[0] = $result['score'];
$score[1] = $result['weight']; $score[1] = $result['weight'];
} else {
if ($userExerciseSettings) {
$display = ExerciseLib::show_score(
$score[0],
$score[1],
true
);
}
} }
return [ return [
@ -633,6 +671,7 @@ class GradebookDataGenerator
SCORE_DIV, SCORE_DIV,
SCORE_BOTH, SCORE_BOTH,
false, false,
true,
true true
); );
} }
@ -654,7 +693,8 @@ class GradebookDataGenerator
$userId, $userId,
$item, $item,
$ignore_score_color, $ignore_score_color,
$forceSimpleResult = false $forceSimpleResult = false,
$useExerciseScoreInTotal = false
) { ) {
$scoreDisplay = ScoreDisplay::instance(); $scoreDisplay = ScoreDisplay::instance();
$score = $item->calc_score($userId); $score = $item->calc_score($userId);
@ -666,11 +706,20 @@ class GradebookDataGenerator
case 'C': case 'C':
if (null != $score) { if (null != $score) {
if (empty($model)) { if (empty($model)) {
return [ if ($useExerciseScoreInTotal) {
'display' => $scoreDisplay->display_score( $display = ExerciseLib::show_score($score[0], $score[1], false);
} else {
$display = $scoreDisplay->display_score(
$score, $score,
SCORE_DIV SCORE_DIV,
), null,
false,
false,
true
);
}
return [
'display' => $display,
'score' => $score, 'score' => $score,
'score_weight' => $score, 'score_weight' => $score,
]; ];
@ -705,7 +754,11 @@ class GradebookDataGenerator
if (empty($model)) { if (empty($model)) {
$display = $scoreDisplay->display_score( $display = $scoreDisplay->display_score(
$score, $score,
SCORE_DIV_PERCENT_WITH_CUSTOM SCORE_DIV_PERCENT_WITH_CUSTOM,
null,
false,
false,
true
); );
$type = $item->get_item_type(); $type = $item->get_item_type();
@ -713,7 +766,14 @@ class GradebookDataGenerator
$display = ExerciseLib::show_score( $display = ExerciseLib::show_score(
$score[0], $score[0],
$score[1], $score[1],
false false,
true,
false,
false,
null,
null,
false,
true
); );
} }
} else { } else {
@ -752,9 +812,8 @@ class GradebookDataGenerator
} else { } else {
if (is_int($date)) { if (is_int($date)) {
return api_convert_and_format_date($date); return api_convert_and_format_date($date);
} else {
return api_format_date($date);
} }
return api_format_date($date);
} }
} }
} }

@ -263,19 +263,52 @@ class ScoreDisplay
* @param bool $ignoreDecimals * @param bool $ignoreDecimals
* @param string $decimalSeparator * @param string $decimalSeparator
* @param string $thousandSeparator * @param string $thousandSeparator
* @param bool $removeEmptyDecimals Converts 100.00 to 100, 53.00 to 53
* *
* @return float the score formatted * @return float the score formatted
*/ */
public function format_score($score, $ignoreDecimals = false, $decimalSeparator = '.', $thousandSeparator = ',') public function format_score(
{ $score,
$ignoreDecimals = false,
$decimalSeparator = '.',
$thousandSeparator = ',',
$removeEmptyDecimals = false
) {
$decimals = $this->get_number_decimals(); $decimals = $this->get_number_decimals();
if ($ignoreDecimals) { if ($ignoreDecimals) {
$decimals = 0; $decimals = 0;
} }
if ($removeEmptyDecimals) {
if ($score && self::hasEmptyDecimals($score)) {
$score = round($score);
$decimals = 0;
}
}
return api_number_format($score, $decimals, $decimalSeparator, $thousandSeparator); return api_number_format($score, $decimals, $decimalSeparator, $thousandSeparator);
} }
public static function hasEmptyDecimals($score)
{
$hasEmptyDecimals = false;
if (is_float($score)) {
$check = fmod($score, 1);
if (0 === bccomp(0, $check)) {
$score = round($score);
$hasEmptyDecimals = true;
}
}
if (is_int($score) || is_string($score)) {
$score = (float) $score;
$check = fmod($score, 1);
if (0 === bccomp(0, $check)) {
$hasEmptyDecimals = true;
}
}
return $hasEmptyDecimals;
}
/** /**
* Display a score according to the current settings. * Display a score according to the current settings.
* *
@ -288,6 +321,7 @@ class ScoreDisplay
* (only taken into account if custom score display is enabled and for course/platform admin) * (only taken into account if custom score display is enabled and for course/platform admin)
* @param bool $disableColor * @param bool $disableColor
* @param bool $ignoreDecimals * @param bool $ignoreDecimals
* @param bool $removeEmptyDecimals Replaces 100.00 to 100
* *
* @return string * @return string
*/ */
@ -296,9 +330,10 @@ class ScoreDisplay
$type = SCORE_DIV_PERCENT, $type = SCORE_DIV_PERCENT,
$what = SCORE_BOTH, $what = SCORE_BOTH,
$disableColor = false, $disableColor = false,
$ignoreDecimals = false $ignoreDecimals = false,
$removeEmptyDecimals = false
) { ) {
$my_score = 0 == $score ? [] : $score; $my_score = $score == 0 ? [] : $score;
switch ($type) { switch ($type) {
case SCORE_BAR: case SCORE_BAR:
@ -313,20 +348,23 @@ class ScoreDisplay
return round($percentage); return round($percentage);
break; break;
case SCORE_SIMPLE: case SCORE_SIMPLE:
if (!isset($my_score[0])) {
$my_score[0] = 0;
}
return $this->format_score($my_score[0], $ignoreDecimals); return $this->format_score($my_score[0], $ignoreDecimals);
break; break;
} }
if ($this->custom_enabled && isset($this->custom_display_conv)) { if ($this->custom_enabled && isset($this->custom_display_conv)) {
$display = $this->display_default($my_score, $type, $ignoreDecimals); $display = $this->displayDefault($my_score, $type, $ignoreDecimals, $removeEmptyDecimals);
} else { } else {
// if no custom display set, use default display // if no custom display set, use default display
$display = $this->display_default($my_score, $type, $ignoreDecimals); $display = $this->displayDefault($my_score, $type, $ignoreDecimals, $removeEmptyDecimals);
} }
if ($this->coloring_enabled && false == $disableColor) { if ($this->coloring_enabled && $disableColor == false) {
$my_score_denom = isset($score[1]) && !empty($score[1]) && $score[1] > 0 ? $score[1] : 1; $denom = isset($score[1]) && !empty($score[1]) && $score[1] > 0 ? $score[1] : 1;
$scoreCleaned = isset($score[0]) ? $score[0] : 0; $scoreCleaned = isset($score[0]) ? $score[0] : 0;
if (($scoreCleaned / $my_score_denom) < ($this->color_split_value / 100)) { if (($scoreCleaned / $denom) < ($this->color_split_value / 100)) {
$display = Display::tag( $display = Display::tag(
'font', 'font',
$display, $display,
@ -338,6 +376,39 @@ class ScoreDisplay
return $display; return $display;
} }
/**
* Depends on the teacher's configuration of thresholds. i.e. [0 50] "Bad", [50:100] "Good".
*
* @param array $score
*
* @return string
*/
public function display_custom($score)
{
if (empty($score)) {
return null;
}
$denom = $score[1] == 0 ? 1 : $score[1];
$scaledscore = $score[0] / $denom;
if ($this->upperlimit_included) {
foreach ($this->custom_display_conv as $displayitem) {
if ($scaledscore <= $displayitem['score']) {
return $displayitem['display'];
}
}
} else {
if (!empty($this->custom_display_conv)) {
foreach ($this->custom_display_conv as $displayitem) {
if ($scaledscore < $displayitem['score'] || $displayitem['score'] == 1) {
return $displayitem['display'];
}
}
}
}
}
/** /**
* Get current gradebook category id. * Get current gradebook category id.
* *
@ -363,21 +434,22 @@ class ScoreDisplay
} }
/** /**
* @param $score * @param array $score
* @param int $type * @param int $type
* @param bool $ignoreDecimals * @param bool $ignoreDecimals
* @param bool $removeEmptyDecimals
* *
* @return string * @return string
*/ */
private function display_default($score, $type, $ignoreDecimals = false) private function displayDefault($score, $type, $ignoreDecimals = false, $removeEmptyDecimals = false)
{ {
switch ($type) { switch ($type) {
case SCORE_DIV: // X / Y case SCORE_DIV: // X / Y
return $this->display_as_div($score, $ignoreDecimals); return $this->display_as_div($score, $ignoreDecimals, $removeEmptyDecimals);
case SCORE_PERCENT: // XX % case SCORE_PERCENT: // XX %
return $this->display_as_percent($score); return $this->display_as_percent($score);
case SCORE_DIV_PERCENT: // X / Y (XX %) case SCORE_DIV_PERCENT: // X / Y (XX %)
return $this->display_as_div($score).' ('.$this->display_as_percent($score).')'; return $this->display_as_percent($score).' ('.$this->display_as_div($score).')';
case SCORE_AVERAGE: // XX % case SCORE_AVERAGE: // XX %
return $this->display_as_percent($score); return $this->display_as_percent($score);
case SCORE_DECIMAL: // 0.50 (X/Y) case SCORE_DECIMAL: // 0.50 (X/Y)
@ -388,7 +460,13 @@ class ScoreDisplay
$custom = ' - '.$custom; $custom = ' - '.$custom;
} }
return $this->display_as_div($score).' ('.$this->display_as_percent($score).')'.$custom; $div = $this->display_as_div($score, false, $removeEmptyDecimals);
/*return
$div.
' ('.$this->display_as_percent($score).')'.$custom;*/
return
$this->display_as_percent($score).
' ('.$div.')'.$custom;
case SCORE_DIV_SIMPLE_WITH_CUSTOM: // X - Good! case SCORE_DIV_SIMPLE_WITH_CUSTOM: // X - Good!
$custom = $this->display_custom($score); $custom = $this->display_custom($score);
@ -433,7 +511,7 @@ class ScoreDisplay
} }
/** /**
* Returns "1" for array("100", "100");. * Returns "1" for array("100", "100").
* *
* @param array $score * @param array $score
* *
@ -447,29 +525,30 @@ class ScoreDisplay
} }
/** /**
* Returns "100 %" for array("100", "100");. * Returns "100 %" for array("100", "100").
*/ */
private function display_as_percent($score) private function display_as_percent($score)
{ {
if (empty($score)) { if (empty($score)) {
return null; return null;
} }
$score_denom = (0 == $score[1]) ? 1 : $score[1]; $scoreDenom = $score[1] == 0 ? 1 : $score[1];
return $this->format_score($score[0] / $score_denom * 100).' %'; return $this->format_score($score[0] / $scoreDenom * 100).' %';
} }
/** /**
* Returns 10.00 / 10.00 for array("100", "100");. * Returns 10.00 / 10.00 for array("100", "100").
* *
* @param array $score * @param array $score
* @param bool $ignoreDecimals * @param bool $ignoreDecimals
* @param bool $removeEmptyDecimals
* *
* @return string * @return string
*/ */
private function display_as_div($score, $ignoreDecimals = false) private function display_as_div($score, $ignoreDecimals = false, $removeEmptyDecimals = false)
{ {
if (1 == $score) { if ($score == 1) {
return '0 / 0'; return '0 / 0';
} }
@ -478,44 +557,17 @@ class ScoreDisplay
} }
$score[0] = isset($score[0]) ? $this->format_score($score[0], $ignoreDecimals) : 0; $score[0] = isset($score[0]) ? $this->format_score($score[0], $ignoreDecimals) : 0;
$score[1] = isset($score[1]) ? $this->format_score($score[1], $ignoreDecimals) : 0; $score[1] = isset($score[1]) ? $this->format_score(
$score[1],
$ignoreDecimals,
'.',
',',
$removeEmptyDecimals
) : 0;
return $score[0].' / '.$score[1]; return $score[0].' / '.$score[1];
} }
/**
* Depends on the teacher's configuration of thresholds. i.e. [0 50] "Bad", [50:100] "Good".
*
* @param array $score
*
* @return string
*/
private function display_custom($score)
{
if (empty($score)) {
return null;
}
$my_score_denom = 0 == $score[1] ? 1 : $score[1];
$scaledscore = $score[0] / $my_score_denom;
if ($this->upperlimit_included) {
foreach ($this->custom_display_conv as $displayitem) {
if ($scaledscore <= $displayitem['score']) {
return $displayitem['display'];
}
}
} else {
if (!empty($this->custom_display_conv)) {
foreach ($this->custom_display_conv as $displayitem) {
if ($scaledscore < $displayitem['score'] || 1 == $displayitem['score']) {
return $displayitem['display'];
}
}
}
}
}
/** /**
* Get score color percent by category. * Get score color percent by category.
* *
@ -602,9 +654,8 @@ class ScoreDisplay
} }
return $converted2; return $converted2;
} else {
return null;
} }
return null;
} }
/** /**

@ -335,14 +335,11 @@ class UserDataGenerator
if (isset($this->avgcache)) { if (isset($this->avgcache)) {
$avgscore = $this->avgcache[$item->get_item_type().$item->get_id()]; $avgscore = $this->avgcache[$item->get_item_type().$item->get_id()];
} else { } else {
$avgscore = $item->calc_score(); $avgscore = $item->calc_score('', 'average');
} }
$scoredisplay = ScoreDisplay::instance(); $scoredisplay = ScoreDisplay::instance();
$displaytype = SCORE_AVERAGE; $displaytype = SCORE_AVERAGE;
/*if ($ignore_score_color)
$displaytype |= SCORE_IGNORE_SPLIT;
*/
return $scoredisplay->display_score($avgscore, $displaytype); return $scoredisplay->display_score($avgscore, $displaytype);
} }

@ -10,6 +10,7 @@
$cidReset = true; $cidReset = true;
require_once __DIR__.'/../inc/global.inc.php'; require_once __DIR__.'/../inc/global.inc.php';
api_block_inactive_user();
$logInfo = [ $logInfo = [
'tool' => 'MyCertificates', 'tool' => 'MyCertificates',

@ -101,8 +101,8 @@ if (api_is_platform_admin(true, true)) {
'#' '#'
); );
$menu_items[] = Display::url( $menu_items[] = Display::url(
Display::return_icon('session.png', get_lang('Course sessions'), [], ICON_SIZE_MEDIUM), Display::return_icon('session.png', get_lang('Sessions'), [], ICON_SIZE_MEDIUM),
'session.php' api_get_path(WEB_CODE_PATH).'mySpace/session.php'
); );
$menu_items[] = Display::url( $menu_items[] = Display::url(
get_lang('QuestionStats'), get_lang('QuestionStats'),

@ -149,7 +149,7 @@ switch ($action) {
} }
$counter = 1; $counter = 1;
$table = new HTML_Table(['class' => 'table data_table']); $table = new HTML_Table(['class' => 'table table-hover table-striped data_table']);
$row = 0; $row = 0;
$scoreDisplay = new ScoreDisplay(); $scoreDisplay = new ScoreDisplay();
$globalTotal = 0; $globalTotal = 0;

@ -16,7 +16,7 @@ require_once '../work/work.lib.php';
api_block_anonymous_users(); api_block_anonymous_users();
$htmlHeadXtra[] = '<script type="text/javascript" src="'.api_get_path(WEB_PUBLIC_PATH).'assets/jquery.easy-pie-chart/dist/jquery.easypiechart.js"></script>'; //$htmlHeadXtra[] = '<script type="text/javascript" src="'.api_get_path(WEB_PUBLIC_PATH).'assets/jquery.easy-pie-chart/dist/jquery.easypiechart.js"></script>';
$export = isset($_GET['export']) ? $_GET['export'] : false; $export = isset($_GET['export']) ? $_GET['export'] : false;
$sessionId = isset($_GET['sid']) ? (int) $_GET['sid'] : 0; $sessionId = isset($_GET['sid']) ? (int) $_GET['sid'] : 0;
@ -28,11 +28,6 @@ if ($courseInfo) {
$courseCode = $courseInfo['code']; $courseCode = $courseInfo['code'];
} }
$studentId = isset($_GET['student']) ? (int) $_GET['student'] : 0; $studentId = isset($_GET['student']) ? (int) $_GET['student'] : 0;
if (empty($studentId)) {
api_not_allowed(true);
}
$coachId = isset($_GET['id_coach']) ? (int) $_GET['id_coach'] : 0; $coachId = isset($_GET['id_coach']) ? (int) $_GET['id_coach'] : 0;
$details = isset($_GET['details']) ? Security::remove_XSS($_GET['details']) : ''; $details = isset($_GET['details']) ? Security::remove_XSS($_GET['details']) : '';
$currentUrl = api_get_self().'?student='.$studentId.'&course='.$courseCode.'&id_session='.$sessionId $currentUrl = api_get_self().'?student='.$studentId.'&course='.$courseCode.'&id_session='.$sessionId
@ -41,53 +36,46 @@ $allowMessages = api_get_configuration_value('private_messages_about_user');
$workingTime = api_get_configuration_value('considered_working_time'); $workingTime = api_get_configuration_value('considered_working_time');
$workingTimeEdit = api_get_configuration_value('allow_working_time_edition'); $workingTimeEdit = api_get_configuration_value('allow_working_time_edition');
// user info
$userInfo = api_get_user_info($studentId);
if (empty($userInfo)) {
api_not_allowed(true);
}
$allowToQualify = api_is_allowed_to_edit(null, true) || $allowToQualify = api_is_allowed_to_edit(null, true) ||
api_is_course_tutor() || api_is_course_tutor() ||
api_is_session_admin() || api_is_session_admin() ||
api_is_drh() || api_is_drh() ||
api_is_student_boss(); api_is_student_boss();
$allowedToTrackUser = true; $allowedToTrackUser =
if (!api_is_session_admin() && api_is_platform_admin(true, true) ||
!api_is_drh() && api_is_allowed_to_edit(null, true) ||
!api_is_student_boss() && api_is_session_admin() ||
!api_is_platform_admin() api_is_drh() ||
) { api_is_student_boss() ||
api_is_course_admin() ||
api_is_teacher();
if (false === $allowedToTrackUser && !empty($courseInfo)) {
if (empty($sessionId)) { if (empty($sessionId)) {
$isTeacher = false; $isTeacher = CourseManager::isCourseTeacher(
// Check if is current teacher if set api_get_user_id(),
if (!empty($courseInfo)) { $courseInfo['code']
$isTeacher = CourseManager::isCourseTeacher( );
if ($isTeacher) {
$allowedToTrackUser = true;
} else {
// Check if the user is tutor of the course
$userCourseStatus = CourseManager::get_tutor_in_course_status(
api_get_user_id(), api_get_user_id(),
$courseInfo['real_id'] $courseInfo['real_id']
); );
}
if (!api_is_course_admin() && false == $isTeacher) { if ($userCourseStatus == 1) {
if (!empty($courseInfo)) { $allowedToTrackUser = true;
// Check if the user is tutor of the course
$userCourseStatus = CourseManager::get_tutor_in_course_status(
api_get_user_id(),
$courseInfo['real_id']
);
if (1 != $userCourseStatus) {
$allowedToTrackUser = false;
}
} }
} }
} else { } else {
$coach = api_is_coach($sessionId, $courseInfo['real_id']); $coach = api_is_coach($sessionId, $courseInfo['real_id']);
if (!$coach) { if ($coach) {
$allowedToTrackUser = false; $allowedToTrackUser = true;
} }
} }
} }
@ -95,8 +83,13 @@ if (!api_is_session_admin() &&
if (!$allowedToTrackUser) { if (!$allowedToTrackUser) {
api_not_allowed(true); api_not_allowed(true);
} }
if (empty($studentId)) {
api_not_allowed(true);
}
$user_info = api_get_user_info($studentId);
if (api_is_student()) { if (empty($user_info)) {
api_not_allowed(true); api_not_allowed(true);
} }
@ -364,7 +357,7 @@ switch ($action) {
$courseTable .= '<tr> $courseTable .= '<tr>
<td> <td>
<a href="'.$courseInfoItem['course_public_url'].'?id_session='.$sId.'">'. <a href="'.$courseInfoItem['course_public_url'].'?id_session='.$sId.'">'.
$courseInfoItem['title'].'</a> $courseInfoItem['title'].'</a>
</td> </td>
<td >'.$time_spent_on_course.'</td> <td >'.$time_spent_on_course.'</td>
<td >'.$progress.'</td> <td >'.$progress.'</td>
@ -396,10 +389,13 @@ switch ($action) {
$tpl->assign('session_title', $sessionInfo['name']); $tpl->assign('session_title', $sessionInfo['name']);
$tpl->assign('student', $userInfo['complete_name']); $tpl->assign('student', $userInfo['complete_name']);
$tpl->assign('table_progress', $table->toHtml()); $tpl->assign('table_progress', $table->toHtml());
$tpl->assign('subtitle', sprintf( $tpl->assign(
get_lang('In session %s, you had the following results'), 'subtitle',
$sessionInfo['name'] sprintf(
)); get_lang('In session %s, you had the following results'),
$sessionInfo['name']
)
);
$tpl->assign('table_course', $courseTable); $tpl->assign('table_course', $courseTable);
$content = $tpl->fetch($tpl->get_template('my_space/pdf_export_student.tpl')); $content = $tpl->fetch($tpl->get_template('my_space/pdf_export_student.tpl'));
@ -524,7 +520,9 @@ switch ($action) {
if ($isBoss || api_is_platform_admin()) { if ($isBoss || api_is_platform_admin()) {
$subject = get_lang('Legal conditions'); $subject = get_lang('Legal conditions');
$content = sprintf( $content = sprintf(
get_lang('Hello,<br />Your tutor sent you your terms and conditions. You can sign it following this URL: %s'), get_lang(
'Hello,<br />Your tutor sent you your terms and conditions. You can sign it following this URL: %s'
),
api_get_path(WEB_PATH) api_get_path(WEB_PATH)
); );
MessageManager::send_message_simple($studentId, $subject, $content); MessageManager::send_message_simple($studentId, $subject, $content);
@ -659,7 +657,7 @@ if (api_is_drh() && !api_is_platform_admin()) {
} else { } else {
if (!$isDrhOfCourse) { if (!$isDrhOfCourse) {
if (api_is_drh() && if (api_is_drh() &&
!UserManager::is_user_followed_by_drh($studentId, api_get_user_id()) !UserManager::is_user_followed_by_drh($studentId, api_get_user_id())
) { ) {
api_not_allowed(true); api_not_allowed(true);
} }
@ -909,18 +907,18 @@ $timezone_user = UserManager::get_extra_user_data_by_field(
'timezone' 'timezone'
); );
$use_users_timezone = api_get_setting('use_users_timezone', 'timezones'); $use_users_timezone = api_get_setting('use_users_timezone', 'timezones');
if (null != $timezone_user['timezone'] && 'true' === $use_users_timezone) { if (null != $timezone_user['timezone'] && 'true' === $use_users_timezone) {
$timezone = $timezone_user['timezone']; $timezone = $timezone_user['timezone'];
} }
if (null !== $timezone) { if (null !== $timezone) {
$userInfo['timezone'] = $timezone; $userInfo['timezone'] = $timezone;
} }
if (is_numeric($avg_student_score)) { if (is_numeric($avg_student_score)) {
$score = $avg_student_score.'%'; $score = $avg_student_score.'%';
} else { } else {
$score = $avg_student_score; $score = $avg_student_score;
} }
$userInfo['student_score'] = $score; $userInfo['student_score'] = $score;
$userInfo['student_progress'] = $avg_student_progress; $userInfo['student_progress'] = $avg_student_progress;
@ -1000,22 +998,36 @@ if (isset($_GET['action']) and 'all_attendance' == $_GET['action']) {
/** Start date and end date*/ /** Start date and end date*/
$defaults['startDate'] = $startDateText; $defaults['startDate'] = $startDateText;
$defaults['endDate'] = $endDateText; $defaults['endDate'] = $endDateText;
$form = new FormValidator('all_attendance_list', 'GET', $form = new FormValidator(
'myStudents.php?action=all_attendance&student='.$studentId.'&startDate='.$defaults['startDate'].'&endDate='.$defaults['endDate'].'&&'.api_get_cidreq(), 'all_attendance_list',
''); 'GET',
'myStudents.php?action=all_attendance&student='.$studentId.'&startDate='.$defaults['startDate'].'&endDate='.$defaults['endDate'].'&&'.api_get_cidreq(
),
''
);
$form->addElement('html', '<input type="hidden" name="student" value="'.$studentId.'" >'); $form->addElement('html', '<input type="hidden" name="student" value="'.$studentId.'" >');
$form->addElement('html', '<input type="hidden" name="action" value="all_attendance" >'); $form->addElement('html', '<input type="hidden" name="action" value="all_attendance" >');
$form->addDateTimePicker('startDate', [ $form->addDateTimePicker(
get_lang('ExeStartTime'), 'startDate',
], [ [
'form_name' => 'attendance_calendar_edit', get_lang('ExeStartTime'),
], 5); ],
$form->addDateTimePicker('endDate', [ [
get_lang('ExeEndTime'), 'form_name' => 'attendance_calendar_edit',
], [ ],
'form_name' => 'attendance_calendar_edit', 5
], 5); );
$form->addDateTimePicker(
'endDate',
[
get_lang('ExeEndTime'),
],
[
'form_name' => 'attendance_calendar_edit',
],
5
);
$form->addButtonSave(get_lang('Submit')); $form->addButtonSave(get_lang('Submit'));
$form->setDefaults($defaults); $form->setDefaults($defaults);
@ -1039,12 +1051,8 @@ if (isset($_GET['action']) and 'all_attendance' == $_GET['action']) {
</tr> </tr>
</thead> </thead>
<tbody>'; <tbody>';
// <th>'.get_lang('Professor').'</th>
foreach ($data as $attendanceData => $attendanceSheet) {
/*
* $attendanceData can be in_category or not_category for courses
* */
foreach ($data as $attendanceData => $attendanceSheet) {
$totalAttendance = count($attendanceSheet); $totalAttendance = count($attendanceSheet);
for ($i = 0; $i < $totalAttendance; $i++) { for ($i = 0; $i < $totalAttendance; $i++) {
$attendanceWork = $attendanceSheet[$i]; $attendanceWork = $attendanceSheet[$i];
@ -1106,7 +1114,11 @@ if (!empty($courseInfo)) {
'chat_connection' => $chat_last_connection, 'chat_connection' => $chat_last_connection,
'documents' => $documents, 'documents' => $documents,
'upload_documents' => $uploaded_documents, 'upload_documents' => $uploaded_documents,
'course_first_access' => Tracking::get_first_connection_date_on_the_course($studentId, $courseInfo['real_id'], $sessionId), 'course_first_access' => Tracking::get_first_connection_date_on_the_course(
$studentId,
$courseInfo['real_id'],
$sessionId
),
'course_last_access' => Tracking::get_last_connection_date_on_the_course($studentId, $courseInfo, $sessionId), 'course_last_access' => Tracking::get_last_connection_date_on_the_course($studentId, $courseInfo, $sessionId),
'count_access_dates' => Tracking::getNumberOfCourseAccessDates($studentId, $courseInfo['real_id'], $sessionId), 'count_access_dates' => Tracking::getNumberOfCourseAccessDates($studentId, $courseInfo['real_id'], $sessionId),
]; ];
@ -1276,11 +1288,14 @@ if (empty($details)) {
$attendances_faults_avg = '0/0 (0%)'; $attendances_faults_avg = '0/0 (0%)';
if (!empty($results_faults_avg['total'])) { if (!empty($results_faults_avg['total'])) {
if (api_is_drh()) { if (api_is_drh()) {
$attendances_faults_avg = '<a title="'.get_lang('Go to attendances').'" href="'.api_get_path(WEB_CODE_PATH) $attendances_faults_avg = Display::url(
$results_faults_avg['faults'].'/'.$results_faults_avg['total']
.' ('.$results_faults_avg['porcent'].'%)',
api_get_path(WEB_CODE_PATH)
.'attendance/index.php?cidReq='.$courseCodeItem.'&id_session='.$sId.'&student_id=' .'attendance/index.php?cidReq='.$courseCodeItem.'&id_session='.$sId.'&student_id='
.$studentId.'">' .$studentId,
.$results_faults_avg['faults'].'/'.$results_faults_avg['total'].' (' ['title' => get_lang('GoAttendance')]
.$results_faults_avg['percent'].'%)</a>'; );
} else { } else {
$attendances_faults_avg = $results_faults_avg['faults'].'/' $attendances_faults_avg = $results_faults_avg['faults'].'/'
.$results_faults_avg['total'] .$results_faults_avg['total']
@ -1357,8 +1372,11 @@ if (empty($details)) {
$exportCourseList[$sId][] = $csvRow; $exportCourseList[$sId][] = $csvRow;
echo '<tr> echo '<tr>
<td ><a href="'.$courseInfoItem['course_public_url'].'?id_session='.$sId.'">'. <td>
$courseInfoItem['title'].'</a></td> <a href="'.$courseInfoItem['course_public_url'].'?id_session='.$sId.'">'.
$courseInfoItem['title'].'
</a>
</td>
<td >'.$time_spent_on_course.'</td> <td >'.$time_spent_on_course.'</td>
<td >'.$progress.'</td> <td >'.$progress.'</td>
<td >'.$score.'</td> <td >'.$score.'</td>
@ -1411,29 +1429,51 @@ if (empty($details)) {
$csv_content[] = $csvRow; $csv_content[] = $csvRow;
$exportCourseList[$sId][] = $csvRow; $exportCourseList[$sId][] = $csvRow;
$sessionAction = Display::url( $sessionAction = Display::url(
Display::return_icon('export_csv.png', get_lang('CSV export'), [], ICON_SIZE_MEDIUM), Display::return_icon('export_csv.png', get_lang('ExportAsCSV'), [], ICON_SIZE_MEDIUM),
$currentUrl $currentUrl.'&'
.'&' .http_build_query(
.http_build_query( [
['action' => 'export_one_session_row', 'export' => 'csv', 'session_to_export' => $sId] 'action' => 'export_one_session_row',
) 'export' => 'csv',
'session_to_export' => $sId,
]
)
); );
$sessionAction .= Display::url( $sessionAction .= Display::url(
Display::return_icon('export_excel.png', get_lang('Excel export'), [], ICON_SIZE_MEDIUM), Display::return_icon('export_excel.png', get_lang('ExportAsXLS'), [], ICON_SIZE_MEDIUM),
$currentUrl $currentUrl.'&'
.'&' .http_build_query(
.http_build_query( [
['action' => 'export_one_session_row', 'export' => 'xls', 'session_to_export' => $sId] 'action' => 'export_one_session_row',
) 'export' => 'xls',
'session_to_export' => $sId,
]
)
); );
if (!empty($sId)) { if (!empty($sId)) {
$sessionAction .= Display::url( $sessionAction .= Display::url(
Display::return_icon('pdf.png', get_lang('Export to PDF'), [], ICON_SIZE_MEDIUM), Display::return_icon('pdf.png', get_lang('ExportToPDF'), [], ICON_SIZE_MEDIUM),
$currentUrl api_get_path(WEB_CODE_PATH).'mySpace/session.php?'
.'&' .http_build_query(
[
'student' => $studentId,
'action' => 'export_to_pdf',
'type' => 'attendance',
'session_to_export' => $sId,
]
)
);
$sessionAction .= Display::url(
Display::return_icon('pdf.png', get_lang('CertificateOfAchievement'), [], ICON_SIZE_MEDIUM),
api_get_path(WEB_CODE_PATH).'mySpace/session.php?'
.http_build_query( .http_build_query(
['action' => 'export_to_pdf', 'session_to_export' => $sId] [
'student' => $studentId,
'action' => 'export_to_pdf',
'type' => 'achievement',
'session_to_export' => $sId,
]
) )
); );
} }
@ -1507,10 +1547,12 @@ if (empty($details)) {
$hookHeaders = $hookLpTracking->notifyTrackingHeader(); $hookHeaders = $hookLpTracking->notifyTrackingHeader();
foreach ($hookHeaders as $hookHeader) { foreach ($hookHeaders as $hookHeader) {
if (isset($hookHeader['value'])) {
$columnHeadersToExport[] = $hookHeader['value']; $columnHeadersToExport[] = $hookHeader['value'];
$headers .= Display::tag('th', $hookHeader['value'], $hookHeader['attrs']); $headers .= Display::tag('th', $hookHeader['value'], $hookHeader['attrs']);
} }
}
}*/ }*/
$csv_content[] = $columnHeadersToExport; $csv_content[] = $columnHeadersToExport;
@ -1518,7 +1560,8 @@ if (empty($details)) {
$categoriesTempList = learnpath::getCategories($courseInfo['real_id']); $categoriesTempList = learnpath::getCategories($courseInfo['real_id']);
$categoryTest = new CLpCategory(); $categoryTest = new CLpCategory();
//$categoryTest->setId(0); //$categoryTest->setId(0);
$categoryTest->setName(get_lang('Without category')); $categoryTest->setId(0);
$categoryTest->setName(get_lang('WithOutCategory'));
$categoryTest->setPosition(0); $categoryTest->setPosition(0);
$categories = [ $categories = [
$categoryTest, $categoryTest,
@ -1712,9 +1755,11 @@ if (empty($details)) {
$hookContents = $hookLpTracking->notifyTrackingContent($lp_id, $studentId); $hookContents = $hookLpTracking->notifyTrackingContent($lp_id, $studentId);
foreach ($hookContents as $hookContent) { foreach ($hookContents as $hookContent) {
$contentToExport[] = strip_tags($hookContent['value']); if (isset($hookContent['value'])) {
$contentToExport[] = strip_tags($hookContent['value']);
echo Display::tag('td', $hookContent['value'], $hookContent['attrs']); echo Display::tag('td', $hookContent['value'], $hookContent['attrs']);
}
} }
} }
@ -1781,7 +1826,9 @@ if (empty($details)) {
if ($hookQuizTracking) { if ($hookQuizTracking) {
$hookHeaders = array_map( $hookHeaders = array_map(
function ($hookHeader) { function ($hookHeader) {
return Display::tag('th', $hookHeader['value'], $hookHeader['attrs']); if (isset($hookHeader['value'])) {
return Display::tag('th', $hookHeader['value'], $hookHeader['attrs']);
}
}, },
$hookQuizTracking->notifyTrackingHeader() $hookQuizTracking->notifyTrackingHeader()
); );
@ -1802,7 +1849,9 @@ if (empty($details)) {
/*if ($hookQuizTracking) { /*if ($hookQuizTracking) {
$hookHeaders = array_map( $hookHeaders = array_map(
function ($hookHeader) { function ($hookHeader) {
if (isset($hookHeader['value'])) {
return strip_tags($hookHeader['value']); return strip_tags($hookHeader['value']);
}
}, },
$hookQuizTracking->notifyTrackingHeader() $hookQuizTracking->notifyTrackingHeader()
); );
@ -1885,7 +1934,9 @@ if (empty($details)) {
$css_class = 'row_odd'; $css_class = 'row_odd';
} }
echo '<tr class="'.$css_class.'"><td>'.Exercise::get_formated_title_variable($exercices['title']).'</td>'; echo '<tr class="'.$css_class.'"><td>'.Exercise::get_formated_title_variable(
$exercices['title']
).'</td>';
echo '<td>'; echo '<td>';
if (!empty($lp_name)) { if (!empty($lp_name)) {
@ -1954,7 +2005,9 @@ if (empty($details)) {
if (!empty($hookContents)) { if (!empty($hookContents)) {
foreach ($hookContents as $hookContent) { foreach ($hookContents as $hookContent) {
echo Display::tag('td', $hookContent['value'], $hookContent['attrs']); if (isset($hookContent['value'])) {
echo Display::tag('td', $hookContent['value'], $hookContent['attrs']);
}
} }
} }
@ -1974,7 +2027,9 @@ if (empty($details)) {
$csvContentIndex = count($csv_content) - 1; $csvContentIndex = count($csv_content) - 1;
foreach ($hookContents as $hookContent) { foreach ($hookContents as $hookContent) {
$csv_content[$csvContentIndex][] = strip_tags($hookContent['value']); if (isset($hookContent['value'])) {
$csv_content[$csvContentIndex][] = strip_tags($hookContent['value']);
}
} }
} }
$i++; $i++;
@ -2070,7 +2125,9 @@ if (empty($details)) {
echo '<td class="text-center"><a href="'.$url.'">('.$documentNumber.')</a></td>'; echo '<td class="text-center"><a href="'.$url.'">('.$documentNumber.')</a></td>';
$qualification = !empty($results['qualification']) ? $results['qualification'] : '-'; $qualification = !empty($results['qualification']) ? $results['qualification'] : '-';
echo '<td class="text-center">'.$qualification.'</td>'; echo '<td class="text-center">'.$qualification.'</td>';
echo '<td class="text-center">'.api_convert_and_format_date($results['sent_date_from_db']).' '.$results['expiry_note'].'</td>'; echo '<td class="text-center">'.api_convert_and_format_date(
$results['sent_date_from_db']
).' '.$results['expiry_note'].'</td>';
$assignment = get_work_assignment_by_id($work->id, $courseInfo['real_id']); $assignment = get_work_assignment_by_id($work->id, $courseInfo['real_id']);
echo '<td class="text-center">'; echo '<td class="text-center">';
@ -2094,14 +2151,14 @@ if (empty($details)) {
if ($workingTimeEdit && $showOnce) { if ($workingTimeEdit && $showOnce) {
$showOnce = false; $showOnce = false;
echo '&nbsp;'.Display::url( echo '&nbsp;'.Display::url(
get_lang('AddTime'), get_lang('AddTime'),
$currentUrl.'&action=add_work_time&time='.$time.'&work_id='.$work->id $currentUrl.'&action=add_work_time&time='.$time.'&work_id='.$work->id
); );
echo '&nbsp;'.Display::url( echo '&nbsp;'.Display::url(
get_lang('RemoveTime'), get_lang('RemoveTime'),
$currentUrl.'&action=remove_work_time&time='.$time.'&work_id='.$work->id $currentUrl.'&action=remove_work_time&time='.$time.'&work_id='.$work->id
); );
} }
echo '</td>'; echo '</td>';
} }

@ -970,10 +970,12 @@ if (!empty($groupList)) {
$bestScoreAverageNotInLP += $best; $bestScoreAverageNotInLP += $best;
} }
} }
$bestScoreAverageNotInLP = round( if (!empty($nbStudents)) {
$bestScoreAverageNotInLP / count($exerciseList) * 100 / $nbStudents, $bestScoreAverageNotInLP = round(
2 $bestScoreAverageNotInLP / count($exerciseList) * 100 / $nbStudents,
).' %'; 2
).' %';
}
} }
$row = 1; $row = 1;

@ -321,7 +321,7 @@ if ($showTrackingReporting) {
get_lang('Tools most used') get_lang('Tools most used')
).' '.get_lang('Tools most used') ).' '.get_lang('Tools most used')
); );
echo '<table class="data_table">'; echo '<table class="table table-hover table-striped data_table">';
$tools_most_used = Tracking::get_tools_most_used_by_course( $tools_most_used = Tracking::get_tools_most_used_by_course(
$course_id, $course_id,
@ -371,7 +371,7 @@ if ($documentReporting) {
).'&nbsp;'.get_lang('Documents most downloaded').$link ).'&nbsp;'.get_lang('Documents most downloaded').$link
); );
echo '<table class="data_table">'; echo '<table class="table table-hover table-striped data_table">';
$documents_most_downloaded = Tracking::get_documents_most_downloaded_by_course( $documents_most_downloaded = Tracking::get_documents_most_downloaded_by_course(
$course_code, $course_code,
$session_id, $session_id,
@ -425,7 +425,7 @@ if ($linkReporting) {
get_lang('Links most visited') get_lang('Links most visited')
).'&nbsp;'.get_lang('Links most visited') ).'&nbsp;'.get_lang('Links most visited')
); );
echo '<table class="data_table">'; echo '<table class="table table-hover table-striped data_table">';
$links_most_visited = Tracking::get_links_most_visited_by_course( $links_most_visited = Tracking::get_links_most_visited_by_course(
$course_code, $course_code,
$session_id $session_id

@ -20,7 +20,7 @@ if (!$is_allowedToTrack) {
} }
$action = isset($_GET['action']) ? $_GET['action'] : null; $action = isset($_GET['action']) ? $_GET['action'] : null;
$lps = learnpath::getLpList($courseId); $lps = learnpath::getLpList($courseId, $sessionId);
Session::write('lps', $lps); Session::write('lps', $lps);
/** /**

@ -131,7 +131,7 @@ if ('true' === $allowTutors) {
); );
echo Display::page_subheader(get_lang('General properties').$url); ?> echo Display::page_subheader(get_lang('General properties').$url); ?>
<!-- General properties --> <!-- General properties -->
<table class="data_table"> <table class="table table-hover table-striped data_table">
<tr> <tr>
<td><?php echo get_lang('General coach'); ?> :</td> <td><?php echo get_lang('General coach'); ?> :</td>
<td><?php echo api_get_person_name($session['firstname'], $session['lastname']).' ('.$session['username'].')'; ?></td> <td><?php echo api_get_person_name($session['firstname'], $session['lastname']).' ('.$session['username'].')'; ?></td>

Loading…
Cancel
Save