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. 21
      public/main/gradebook/lib/be/category.class.php
  8. 4
      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. 85
      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. 213
      public/main/mySpace/myStudents.php
  27. 2
      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':
$userId = isset($_GET['user_id']) && $_GET['user_id'] ? $_GET['user_id'] : null;
$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;
}
@ -174,7 +174,8 @@ $allowSkillRelItem = api_get_configuration_value('allow_skill_rel_items');
if (0 == count($userList)) {
echo Display::return_message(get_lang('No results available'), 'warning');
} 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 get_lang('Learner');
echo '</th>';
@ -182,9 +183,9 @@ if (0 == count($userList)) {
echo get_lang('Action');
echo '</th></tr>';
foreach ($userList as $index => $value) {
$userData = api_get_person_name($value['firstname'], $value['lastname']).' ('.$value['username'].')';
echo '<tr>
<td width="70%">'
.api_get_person_name($value['firstname'], $value['lastname']).' ('.$value['username'].') </td>';
<td width="70%">'.$userData.'</td>';
echo '<td>';
$link = '';
if ($allowSkillRelItem) {
@ -206,7 +207,7 @@ if (0 == count($userList)) {
echo $link;
echo '</td></tr>';
}
echo '</table>';
echo '</table></div>';
}
Display::display_footer();

@ -269,8 +269,11 @@ if (isset($_GET['exportpdf'])) {
} else {
Display::display_header(get_lang('List View'));
}
$studentView = api_is_student_view_active();
if (isset($_GET['isStudentView']) && 'false' === $_GET['isStudentView']) {
DisplayGradebook::display_header_reduce_flatview(
$cat[0],
$showeval,
@ -278,8 +281,15 @@ DisplayGradebook::display_header_reduce_flatview(
$simple_search_form
);
$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
echo '<div id="contentArea" style="text-align: center;" >';
$flatViewTable->display_graph_by_resource();

@ -82,7 +82,7 @@ if (!$displayScore->is_custom() || empty($displays)) {
}
// 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 .= '<th>'.get_lang('Percentage').'</th>';
$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');
$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 */
foreach ($cats as $cat) {
$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',
];
$feedback = '';
if ($showFeedBack) {
$feedback = '<br />'.get_lang('Feedback').'<br />
<textarea rows="5" cols="100" >&nbsp;</textarea>';
}
$pdf = new PDF('A4', $params['orientation'], $params);
$pdf->html_to_pdf_with_template(
$table.
$graph.
'<br />'.get_lang('Feedback').'<br />
<textarea rows="5" cols="100" >&nbsp;</textarea>'
);
$pdf->html_to_pdf_with_template($table.$graph.$feedback);
} else {
echo $table;
echo $graph;

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

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

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

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

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

@ -217,7 +217,7 @@ class Result
$sql .= ")";
Database::query($sql);
} 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);
} 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()
{
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();
$sessionId = $this->get_session_id();

@ -11,7 +11,8 @@ class DisplayGradebook
* Displays the header for the result page containing the navigation tree and links.
*
* @param Evaluation $evalobj
* @param $selectcat
* @param int $selectcat
* @param string $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.'">'.
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;
$perPage = isset($_GET['flatviewlist_per_page']) ? intval($_GET['flatviewlist_per_page']) : null;
$pageNum = isset($_GET['flatviewlist_page_nr']) ? (int) $_GET['flatviewlist_page_nr'] : null;
$perPage = isset($_GET['flatviewlist_per_page']) ? (int) $_GET['flatviewlist_per_page'] : null;
$offset = isset($_GET['offset']) ? $_GET['offset'] : '0';
$exportCsvUrl = api_get_self().'?'.api_get_cidreq().'&'.http_build_query([

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

@ -79,6 +79,7 @@ class GradebookTable extends SortableTable
$this->cats = $cats;
$this->loadStats = $loadStats;
$this->datagen = new GradebookDataGenerator($cats, $evals, $links);
$this->datagen->exportToPdf = $this->exportToPdf;
$this->datagen->preLoadDataKey = $this->getPreloadDataKey();
$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);
if (false == $this->exportToPdf) {
@ -106,12 +107,19 @@ class GradebookTable extends SortableTable
$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(
$column++,
get_lang('Weight'),
'',
'width="100px"'
);
}
if (!$this->teacherView) {
$this->set_header($column++, get_lang('Result'), false);
@ -119,13 +127,13 @@ class GradebookTable extends SortableTable
if (empty($model)) {
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)) {
$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)) {
$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;
$scoredisplay = ScoreDisplay::instance();
$totalUserResult = [0, 0];
$totalBest = [0, 0];
$totalAverage = [0, 0];
@ -389,9 +396,15 @@ class GradebookTable extends SortableTable
'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();
$session_id = api_get_session_id();
$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.
if (!empty($data_array)) {
@ -445,6 +458,7 @@ class GradebookTable extends SortableTable
true
);
if ($showWeight) {
if ($this->teacherView) {
$row[] = $invisibility_span_open.
Display::tag('p', $weight, ['class' => 'score']).
@ -452,6 +466,7 @@ class GradebookTable extends SortableTable
} else {
$row[] = $invisibility_span_open.$weight.$invisibility_span_close;
}
}
$category_weight = $item->get_weight();
@ -467,14 +482,13 @@ class GradebookTable extends SortableTable
$row[] = $this->build_edit_column($item);
}
} else {
$score = $item->calc_score($this->userId);
/*$score = $item->calc_score($this->userId);
if (!empty($score[1])) {
$completeScore = $scoredisplay->display_score($score, SCORE_DIV_PERCENT);
$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
$value_data = isset($data[4]) ? $data[4] : null;
@ -493,11 +507,14 @@ class GradebookTable extends SortableTable
$scoredisplay->format_score($totalBest[1] + $data['best_score'][1]),
];
$totalAverage = [0, 0];
if (isset($data['average_score']) && !empty($data['average_score'])) {
$totalAverage = [
$data['average_score'][0],
$data['average_score'][1],
];
}
}
// Student result
if (empty($model)) {
@ -527,8 +544,12 @@ class GradebookTable extends SortableTable
$data['my_result_no_float'][0] = $result['score'];
}
$totalResultAverageValue = strip_tags($scoredisplay->display_score($totalResult, $mode));
$totalAverageValue = strip_tags($scoredisplay->display_score($totalAverage, $mode));
$totalResultAverageValue = strip_tags(
$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['average'][] = floatval($totalAverageValue);
@ -581,6 +602,7 @@ class GradebookTable extends SortableTable
$alllink = $subCategory->get_links($this->userId);
$sub_cat_info = new GradebookDataGenerator($allcat, $alleval, $alllink);
$sub_cat_info->exportToPdf = $this->exportToPdf;
$sub_cat_info->preLoadDataKey = $this->getPreloadDataKey();
$sub_cat_info->userId = $user_id;
$data_array2 = $sub_cat_info->get_data(
@ -628,7 +650,9 @@ class GradebookTable extends SortableTable
$total_weight += $weight;
// Weight
if ($showWeight) {
$row[] = $invisibility_span_open.$weight.$invisibility_span_close;
}
// Admins get an edit column.
if (api_is_allowed_to_edit(null, true) &&
@ -776,8 +800,15 @@ class GradebookTable extends SortableTable
} else {
$totalResult = $scoredisplay->display_score(
$totalResult,
SCORE_DIV
SCORE_DIV,
null,
false,
false,
true
);
if ($useExerciseScoreInTotal) {
$totalResult = ExerciseLib::show_score($myTotal, $main_weight, false);
}
}
$row = [
@ -789,7 +820,9 @@ class GradebookTable extends SortableTable
$row[] = null;
}
if ($showWeight) {
$row[] = $main_weight;
}
$row[] = $totalResult;
$categoryId = $main_cat[0]->get_id();
@ -826,13 +859,18 @@ class GradebookTable extends SortableTable
}
$totalRanking = AbstractLink::getCurrentUserRanking($user_id, $totalRanking);
if ($useExerciseScoreInTotal) {
$totalRanking = ExerciseLib::show_score($totalRanking[0], $totalRanking[1], false);
} else {
$totalRanking = $scoredisplay->display_score(
$totalRanking,
SCORE_DIV,
SCORE_BOTH,
true,
true,
true
);
}
if ($invalidateRanking) {
$totalRanking = null;
@ -848,12 +886,24 @@ class GradebookTable extends SortableTable
$totalBest[1] = $main_weight;
$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,
SCORE_DIV,
SCORE_BOTH,
true,
false,
true
);
}
$row[] = $totalBest;
}
@ -867,12 +917,24 @@ class GradebookTable extends SortableTable
$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,
SCORE_DIV,
SCORE_BOTH,
true,
false,
true
);
}
$row[] = $totalAverage;
}
@ -1165,7 +1227,6 @@ class GradebookTable extends SortableTable
$categoryId = $item->getCategory()->get_id();
$cat = new Category();
$is_student = api_is_student();
switch ($item->get_item_type()) {
case 'C':
// Category

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

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

@ -189,7 +189,7 @@ class ResultTable extends SortableTable
$resultQuery = Database::query($sql);
$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, 1, get_lang('Comment'));
$htmlTable->setHeaderContents(0, 2, get_lang('Created at'));

@ -28,9 +28,9 @@ class UserForm extends FormValidator
if (isset($user)) {
$this->user_info = $user;
}
/*if (isset($result_object)) {
if (isset($result_object)) {
$this->result_object = $result_object;
}*/
}
if (self::TYPE_USER_INFO == $this->form_type) {
$this->build_user_info_form();
} 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;
}
@ -570,6 +576,8 @@ class FlatViewDataGenerator
$item_value_total += $result['item_value_total'];
$total_score = [$item_value_total, $item_total];
$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) {
$defaultStyle = empty($style) ? SCORE_DIV_PERCENT : (int) $style;
@ -594,6 +602,13 @@ class FlatViewDataGenerator
$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);
$data[] = $row;
}

@ -27,6 +27,7 @@ class GradebookDataGenerator
public $items;
public $preLoadDataKey;
public $exportToPdf;
private $evals_links;
/**
@ -39,6 +40,7 @@ class GradebookDataGenerator
$allcats = isset($cats) ? $cats : [];
$allevals = isset($evals) ? $evals : [];
$alllinks = isset($links) ? $links : [];
$this->exportToPdf = false;
// 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
@ -120,6 +122,7 @@ class GradebookDataGenerator
$defaultData = Session::read($this->preLoadDataKey);
$model = ExerciseLib::getCourseScoreModel();
$useExerciseScoreInTotal = api_get_configuration_value('gradebook_use_exercise_score_settings_in_total');
/** @var GradebookItem $item */
foreach ($visibleItems as $item) {
@ -140,7 +143,8 @@ class GradebookDataGenerator
$resultColumn = $this->build_result_column(
$userId,
$item,
$ignore_score_color
$ignore_score_color,
false
);
$row[] = $resultColumn['display'];
@ -334,7 +338,8 @@ class GradebookDataGenerator
$userId,
$item,
$ignore_score_color,
true
true,
$useExerciseScoreInTotal
);
$row[] = $result['display'];
$row['result_score'] = $result['score'];
@ -344,8 +349,14 @@ class GradebookDataGenerator
// Best
if (isset($defaultData[$item->get_id()]) && isset($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 {
$best = $this->buildBestResultColumn($item);
$best = $defaultData[$item->get_id()]['best'];
}
} else {
$best = $this->buildBestResultColumn($item, $useExerciseScoreInTotal);
}
$row['best'] = $best['display'];
@ -357,8 +368,12 @@ class GradebookDataGenerator
// Average
if (isset($defaultData[$item->get_id()]) && isset($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 {
$average = $this->buildAverageResultColumn($item);
$average = $this->buildAverageResultColumn($item, $useExerciseScoreInTotal);
}
$row['average'] = $average['display'];
$row['average_score'] = $average['score'];
@ -392,6 +407,7 @@ class GradebookDataGenerator
SCORE_DIV,
SCORE_BOTH,
true,
true,
true
);
@ -419,7 +435,8 @@ class GradebookDataGenerator
{
if (is_a($item, 'Category')) {
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>';
return $link;
@ -461,9 +478,8 @@ class GradebookDataGenerator
{
if ($item1->get_item_type() == $item2->get_item_type()) {
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()) {
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) {
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
*/
public function buildBestResultColumn(GradebookItem $item)
public function buildBestResultColumn(GradebookItem $item, $userExerciseSettings = false)
{
$score = $item->calc_score(
null,
@ -560,11 +574,25 @@ class GradebookDataGenerator
$score,
$scoreMode,
SCORE_BOTH,
true,
false,
true
);
$type = $item->get_item_type();
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 [
@ -576,7 +604,7 @@ class GradebookDataGenerator
/**
* @return array
*/
public function buildAverageResultColumn(GradebookItem $item)
public function buildAverageResultColumn(GradebookItem $item, $userExerciseSettings = false)
{
$score = $item->calc_score(null, 'average');
@ -598,6 +626,8 @@ class GradebookDataGenerator
$score,
$scoreMode,
SCORE_BOTH,
true,
false,
true
);
$type = $item->get_item_type();
@ -607,6 +637,14 @@ class GradebookDataGenerator
$result = ExerciseLib::convertScoreToPlatformSetting($score[0], $score[1]);
$score[0] = $result['score'];
$score[1] = $result['weight'];
} else {
if ($userExerciseSettings) {
$display = ExerciseLib::show_score(
$score[0],
$score[1],
true
);
}
}
return [
@ -633,6 +671,7 @@ class GradebookDataGenerator
SCORE_DIV,
SCORE_BOTH,
false,
true,
true
);
}
@ -654,7 +693,8 @@ class GradebookDataGenerator
$userId,
$item,
$ignore_score_color,
$forceSimpleResult = false
$forceSimpleResult = false,
$useExerciseScoreInTotal = false
) {
$scoreDisplay = ScoreDisplay::instance();
$score = $item->calc_score($userId);
@ -666,11 +706,20 @@ class GradebookDataGenerator
case 'C':
if (null != $score) {
if (empty($model)) {
return [
'display' => $scoreDisplay->display_score(
if ($useExerciseScoreInTotal) {
$display = ExerciseLib::show_score($score[0], $score[1], false);
} else {
$display = $scoreDisplay->display_score(
$score,
SCORE_DIV
),
SCORE_DIV,
null,
false,
false,
true
);
}
return [
'display' => $display,
'score' => $score,
'score_weight' => $score,
];
@ -705,7 +754,11 @@ class GradebookDataGenerator
if (empty($model)) {
$display = $scoreDisplay->display_score(
$score,
SCORE_DIV_PERCENT_WITH_CUSTOM
SCORE_DIV_PERCENT_WITH_CUSTOM,
null,
false,
false,
true
);
$type = $item->get_item_type();
@ -713,7 +766,14 @@ class GradebookDataGenerator
$display = ExerciseLib::show_score(
$score[0],
$score[1],
false
false,
true,
false,
false,
null,
null,
false,
true
);
}
} else {
@ -752,9 +812,8 @@ class GradebookDataGenerator
} else {
if (is_int($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 string $decimalSeparator
* @param string $thousandSeparator
* @param bool $removeEmptyDecimals Converts 100.00 to 100, 53.00 to 53
*
* @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();
if ($ignoreDecimals) {
$decimals = 0;
}
if ($removeEmptyDecimals) {
if ($score && self::hasEmptyDecimals($score)) {
$score = round($score);
$decimals = 0;
}
}
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.
*
@ -288,6 +321,7 @@ class ScoreDisplay
* (only taken into account if custom score display is enabled and for course/platform admin)
* @param bool $disableColor
* @param bool $ignoreDecimals
* @param bool $removeEmptyDecimals Replaces 100.00 to 100
*
* @return string
*/
@ -296,9 +330,10 @@ class ScoreDisplay
$type = SCORE_DIV_PERCENT,
$what = SCORE_BOTH,
$disableColor = false,
$ignoreDecimals = false
$ignoreDecimals = false,
$removeEmptyDecimals = false
) {
$my_score = 0 == $score ? [] : $score;
$my_score = $score == 0 ? [] : $score;
switch ($type) {
case SCORE_BAR:
@ -313,20 +348,23 @@ class ScoreDisplay
return round($percentage);
break;
case SCORE_SIMPLE:
if (!isset($my_score[0])) {
$my_score[0] = 0;
}
return $this->format_score($my_score[0], $ignoreDecimals);
break;
}
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 {
// 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) {
$my_score_denom = isset($score[1]) && !empty($score[1]) && $score[1] > 0 ? $score[1] : 1;
if ($this->coloring_enabled && $disableColor == false) {
$denom = isset($score[1]) && !empty($score[1]) && $score[1] > 0 ? $score[1] : 1;
$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(
'font',
$display,
@ -338,6 +376,39 @@ class ScoreDisplay
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.
*
@ -363,21 +434,22 @@ class ScoreDisplay
}
/**
* @param $score
* @param array $score
* @param int $type
* @param bool $ignoreDecimals
* @param bool $removeEmptyDecimals
*
* @return string
*/
private function display_default($score, $type, $ignoreDecimals = false)
private function displayDefault($score, $type, $ignoreDecimals = false, $removeEmptyDecimals = false)
{
switch ($type) {
case SCORE_DIV: // X / Y
return $this->display_as_div($score, $ignoreDecimals);
return $this->display_as_div($score, $ignoreDecimals, $removeEmptyDecimals);
case SCORE_PERCENT: // XX %
return $this->display_as_percent($score);
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 %
return $this->display_as_percent($score);
case SCORE_DECIMAL: // 0.50 (X/Y)
@ -388,7 +460,13 @@ class ScoreDisplay
$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!
$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
*
@ -447,29 +525,30 @@ class ScoreDisplay
}
/**
* Returns "100 %" for array("100", "100");.
* Returns "100 %" for array("100", "100").
*/
private function display_as_percent($score)
{
if (empty($score)) {
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 bool $ignoreDecimals
* @param bool $removeEmptyDecimals
*
* @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';
}
@ -478,44 +557,17 @@ class ScoreDisplay
}
$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];
}
/**
* 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.
*
@ -602,9 +654,8 @@ class ScoreDisplay
}
return $converted2;
} else {
return null;
}
return null;
}
/**

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

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

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

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

@ -16,7 +16,7 @@ require_once '../work/work.lib.php';
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;
$sessionId = isset($_GET['sid']) ? (int) $_GET['sid'] : 0;
@ -28,11 +28,6 @@ if ($courseInfo) {
$courseCode = $courseInfo['code'];
}
$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;
$details = isset($_GET['details']) ? Security::remove_XSS($_GET['details']) : '';
$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');
$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) ||
api_is_course_tutor() ||
api_is_session_admin() ||
api_is_drh() ||
api_is_student_boss();
$allowedToTrackUser = true;
if (!api_is_session_admin() &&
!api_is_drh() &&
!api_is_student_boss() &&
!api_is_platform_admin()
) {
$allowedToTrackUser =
api_is_platform_admin(true, true) ||
api_is_allowed_to_edit(null, true) ||
api_is_session_admin() ||
api_is_drh() ||
api_is_student_boss() ||
api_is_course_admin() ||
api_is_teacher();
if (false === $allowedToTrackUser && !empty($courseInfo)) {
if (empty($sessionId)) {
$isTeacher = false;
// Check if is current teacher if set
if (!empty($courseInfo)) {
$isTeacher = CourseManager::isCourseTeacher(
api_get_user_id(),
$courseInfo['real_id']
$courseInfo['code']
);
}
if (!api_is_course_admin() && false == $isTeacher) {
if (!empty($courseInfo)) {
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(),
$courseInfo['real_id']
);
if (1 != $userCourseStatus) {
$allowedToTrackUser = false;
}
if ($userCourseStatus == 1) {
$allowedToTrackUser = true;
}
}
} else {
$coach = api_is_coach($sessionId, $courseInfo['real_id']);
if (!$coach) {
$allowedToTrackUser = false;
if ($coach) {
$allowedToTrackUser = true;
}
}
}
@ -95,8 +83,13 @@ if (!api_is_session_admin() &&
if (!$allowedToTrackUser) {
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);
}
@ -396,10 +389,13 @@ switch ($action) {
$tpl->assign('session_title', $sessionInfo['name']);
$tpl->assign('student', $userInfo['complete_name']);
$tpl->assign('table_progress', $table->toHtml());
$tpl->assign('subtitle', sprintf(
$tpl->assign(
'subtitle',
sprintf(
get_lang('In session %s, you had the following results'),
$sessionInfo['name']
));
)
);
$tpl->assign('table_course', $courseTable);
$content = $tpl->fetch($tpl->get_template('my_space/pdf_export_student.tpl'));
@ -524,7 +520,9 @@ switch ($action) {
if ($isBoss || api_is_platform_admin()) {
$subject = get_lang('Legal conditions');
$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)
);
MessageManager::send_message_simple($studentId, $subject, $content);
@ -909,18 +907,18 @@ $timezone_user = UserManager::get_extra_user_data_by_field(
'timezone'
);
$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'];
}
if (null !== $timezone) {
}
if (null !== $timezone) {
$userInfo['timezone'] = $timezone;
}
}
if (is_numeric($avg_student_score)) {
if (is_numeric($avg_student_score)) {
$score = $avg_student_score.'%';
} else {
} else {
$score = $avg_student_score;
}
}
$userInfo['student_score'] = $score;
$userInfo['student_progress'] = $avg_student_progress;
@ -1000,22 +998,36 @@ if (isset($_GET['action']) and 'all_attendance' == $_GET['action']) {
/** Start date and end date*/
$defaults['startDate'] = $startDateText;
$defaults['endDate'] = $endDateText;
$form = new FormValidator('all_attendance_list', 'GET',
'myStudents.php?action=all_attendance&student='.$studentId.'&startDate='.$defaults['startDate'].'&endDate='.$defaults['endDate'].'&&'.api_get_cidreq(),
'');
$form = new FormValidator(
'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="action" value="all_attendance" >');
$form->addDateTimePicker('startDate', [
$form->addDateTimePicker(
'startDate',
[
get_lang('ExeStartTime'),
], [
],
[
'form_name' => 'attendance_calendar_edit',
], 5);
$form->addDateTimePicker('endDate', [
],
5
);
$form->addDateTimePicker(
'endDate',
[
get_lang('ExeEndTime'),
], [
],
[
'form_name' => 'attendance_calendar_edit',
], 5);
],
5
);
$form->addButtonSave(get_lang('Submit'));
$form->setDefaults($defaults);
@ -1039,12 +1051,8 @@ if (isset($_GET['action']) and 'all_attendance' == $_GET['action']) {
</tr>
</thead>
<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);
for ($i = 0; $i < $totalAttendance; $i++) {
$attendanceWork = $attendanceSheet[$i];
@ -1106,7 +1114,11 @@ if (!empty($courseInfo)) {
'chat_connection' => $chat_last_connection,
'documents' => $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),
'count_access_dates' => Tracking::getNumberOfCourseAccessDates($studentId, $courseInfo['real_id'], $sessionId),
];
@ -1276,11 +1288,14 @@ if (empty($details)) {
$attendances_faults_avg = '0/0 (0%)';
if (!empty($results_faults_avg['total'])) {
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='
.$studentId.'">'
.$results_faults_avg['faults'].'/'.$results_faults_avg['total'].' ('
.$results_faults_avg['percent'].'%)</a>';
.$studentId,
['title' => get_lang('GoAttendance')]
);
} else {
$attendances_faults_avg = $results_faults_avg['faults'].'/'
.$results_faults_avg['total']
@ -1357,8 +1372,11 @@ if (empty($details)) {
$exportCourseList[$sId][] = $csvRow;
echo '<tr>
<td ><a href="'.$courseInfoItem['course_public_url'].'?id_session='.$sId.'">'.
$courseInfoItem['title'].'</a></td>
<td>
<a href="'.$courseInfoItem['course_public_url'].'?id_session='.$sId.'">'.
$courseInfoItem['title'].'
</a>
</td>
<td >'.$time_spent_on_course.'</td>
<td >'.$progress.'</td>
<td >'.$score.'</td>
@ -1411,29 +1429,51 @@ if (empty($details)) {
$csv_content[] = $csvRow;
$exportCourseList[$sId][] = $csvRow;
$sessionAction = Display::url(
Display::return_icon('export_csv.png', get_lang('CSV export'), [], ICON_SIZE_MEDIUM),
$currentUrl
.'&'
Display::return_icon('export_csv.png', get_lang('ExportAsCSV'), [], ICON_SIZE_MEDIUM),
$currentUrl.'&'
.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(
Display::return_icon('export_excel.png', get_lang('Excel export'), [], ICON_SIZE_MEDIUM),
$currentUrl
.'&'
Display::return_icon('export_excel.png', get_lang('ExportAsXLS'), [], ICON_SIZE_MEDIUM),
$currentUrl.'&'
.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)) {
$sessionAction .= Display::url(
Display::return_icon('pdf.png', get_lang('Export to PDF'), [], ICON_SIZE_MEDIUM),
$currentUrl
.'&'
Display::return_icon('pdf.png', get_lang('ExportToPDF'), [], ICON_SIZE_MEDIUM),
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(
['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();
foreach ($hookHeaders as $hookHeader) {
if (isset($hookHeader['value'])) {
$columnHeadersToExport[] = $hookHeader['value'];
$headers .= Display::tag('th', $hookHeader['value'], $hookHeader['attrs']);
}
}
}*/
$csv_content[] = $columnHeadersToExport;
@ -1518,7 +1560,8 @@ if (empty($details)) {
$categoriesTempList = learnpath::getCategories($courseInfo['real_id']);
$categoryTest = new CLpCategory();
//$categoryTest->setId(0);
$categoryTest->setName(get_lang('Without category'));
$categoryTest->setId(0);
$categoryTest->setName(get_lang('WithOutCategory'));
$categoryTest->setPosition(0);
$categories = [
$categoryTest,
@ -1712,11 +1755,13 @@ if (empty($details)) {
$hookContents = $hookLpTracking->notifyTrackingContent($lp_id, $studentId);
foreach ($hookContents as $hookContent) {
if (isset($hookContent['value'])) {
$contentToExport[] = strip_tags($hookContent['value']);
echo Display::tag('td', $hookContent['value'], $hookContent['attrs']);
}
}
}
$csv_content[] = $contentToExport;
@ -1781,7 +1826,9 @@ if (empty($details)) {
if ($hookQuizTracking) {
$hookHeaders = array_map(
function ($hookHeader) {
if (isset($hookHeader['value'])) {
return Display::tag('th', $hookHeader['value'], $hookHeader['attrs']);
}
},
$hookQuizTracking->notifyTrackingHeader()
);
@ -1802,7 +1849,9 @@ if (empty($details)) {
/*if ($hookQuizTracking) {
$hookHeaders = array_map(
function ($hookHeader) {
if (isset($hookHeader['value'])) {
return strip_tags($hookHeader['value']);
}
},
$hookQuizTracking->notifyTrackingHeader()
);
@ -1885,7 +1934,9 @@ if (empty($details)) {
$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>';
if (!empty($lp_name)) {
@ -1954,9 +2005,11 @@ if (empty($details)) {
if (!empty($hookContents)) {
foreach ($hookContents as $hookContent) {
if (isset($hookContent['value'])) {
echo Display::tag('td', $hookContent['value'], $hookContent['attrs']);
}
}
}
echo '</tr>';
$data_exercices[$i][] = $exercices['title'];
@ -1974,9 +2027,11 @@ if (empty($details)) {
$csvContentIndex = count($csv_content) - 1;
foreach ($hookContents as $hookContent) {
if (isset($hookContent['value'])) {
$csv_content[$csvContentIndex][] = strip_tags($hookContent['value']);
}
}
}
$i++;
}
} else {
@ -2070,7 +2125,9 @@ if (empty($details)) {
echo '<td class="text-center"><a href="'.$url.'">('.$documentNumber.')</a></td>';
$qualification = !empty($results['qualification']) ? $results['qualification'] : '-';
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']);
echo '<td class="text-center">';

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

@ -321,7 +321,7 @@ if ($showTrackingReporting) {
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(
$course_id,
@ -371,7 +371,7 @@ if ($documentReporting) {
).'&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(
$course_code,
$session_id,
@ -425,7 +425,7 @@ if ($linkReporting) {
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(
$course_code,
$session_id

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

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

Loading…
Cancel
Save