Update from 1.11.x

pull/3432/head
Julio Montoya 5 years ago
parent c340760360
commit 6cb4af9195
  1. 10
      public/main/forum/forumfunction.inc.php
  2. 2
      public/main/forum/index.php
  3. 3
      public/main/gradebook/get_badges.php
  4. 4
      public/main/gradebook/gradebook.php
  5. 3
      public/main/gradebook/gradebook_add_cat.php
  6. 3
      public/main/gradebook/gradebook_add_eval.php
  7. 3
      public/main/gradebook/gradebook_add_link.php
  8. 3
      public/main/gradebook/gradebook_add_link_select_course.php
  9. 3
      public/main/gradebook/gradebook_add_result.php
  10. 38
      public/main/gradebook/gradebook_flatview.php
  11. 1
      public/main/gradebook/index.php
  12. 23
      public/main/gradebook/lib/be/category.class.php
  13. 3
      public/main/gradebook/lib/be/exerciselink.class.php
  14. 2
      public/main/gradebook/lib/be/learnpathlink.class.php
  15. 20
      public/main/gradebook/lib/fe/catform.class.php
  16. 6
      public/main/gradebook/lib/fe/flatviewtable.class.php
  17. 3
      public/main/gradebook/lib/fe/gradebooktable.class.php
  18. 6
      public/main/gradebook/lib/fe/linkaddeditform.class.php
  19. 21
      public/main/gradebook/lib/gradebook_data_generator.class.php
  20. 22
      public/main/gradebook/lib/scoredisplay.class.php
  21. 15
      public/main/gradebook/my_certificates.php
  22. 3
      public/main/gradebook/user_stats.php
  23. 8
      public/main/inc/lib/document.lib.php
  24. 15
      public/main/template/default/forum/list.html.twig
  25. 457
      public/main/tracking/lp_report.php
  26. 1
      public/main/tracking/messages.php

@ -1144,8 +1144,9 @@ function return_visible_invisible_icon(
) {
$html = '';
$id = (int) $id;
$current_visibility_status = (int) $current_visibility_status;
if ($current_visibility_status) {
if ($current_visibility_status == 1) {
$html .= '<a href="'.api_get_self().'?'.api_get_cidreq().'&';
if (is_array($additional_url_parameters)) {
foreach ($additional_url_parameters as $key => $value) {
@ -1153,8 +1154,9 @@ function return_visible_invisible_icon(
}
}
$html .= 'action=invisible&content='.$content.'&id='.$id.'">'.
Display::return_icon('visible.png', get_lang('Make invisible'), [], ICON_SIZE_SMALL).'</a>';
} else {
Display::return_icon('visible.png', get_lang('MakeInvisible'), [], ICON_SIZE_SMALL).'</a>';
}
if ($current_visibility_status == 0) {
$html .= '<a href="'.api_get_self().'?'.api_get_cidreq().'&';
if (is_array($additional_url_parameters)) {
foreach ($additional_url_parameters as $key => $value) {
@ -1297,7 +1299,7 @@ function move_up_down($content, $direction, $id)
$sort_column = 'forum_order';
// We also need the forum_category of this forum.
$sql = "SELECT forum_category FROM $table_forums
WHERE c_id = $course_id AND forum_id = ".(int) $id;
WHERE c_id = $course_id AND forum_id = ".$id;
$result = Database::query($sql);
$row = Database::fetch_array($result);
$forum_category = $row['forum_category'];

@ -235,7 +235,6 @@ if ($translate) {
// Fixes error if there forums with no category.
$forumsInNoCategory = get_forums_in_category(0);
if (!empty($forumsInNoCategory)) {
$forumCategories = array_merge(
$forumCategories,
@ -254,7 +253,6 @@ if (!empty($forumsInNoCategory)) {
// Step 3: We display the forum_categories first.
$listForumCategory = [];
$forumCategoryInfo = [];
if (is_array($forumCategories)) {
foreach ($forumCategories as $forumCategory) {
$categoryId = $forumCategory->getIid();

@ -45,6 +45,9 @@ $backpack = 'https://backpack.openbadges.org/';
$configBackpack = api_get_setting('openbadges_backpack');
if (0 !== strcmp($backpack, $configBackpack)) {
$backpack = $configBackpack;
if (substr($backpack, -1) !== '/') {
$backpack .= '/';
}
}
$htmlHeadXtra[] = '<script src="'.$backpack.'issuer.js"></script>';

@ -1,10 +1,6 @@
<?php
/* For licensing terms, see /license.txt */
/**
* Script.
*/
// $cidReset : This is the main difference with gradebook.php, here we say,
// basically, that we are inside a course, and many things depend from that
$cidReset = true;

@ -1,9 +1,6 @@
<?php
/* For licensing terms, see /license.txt */
/**
* Script.
*/
require_once __DIR__.'/../inc/global.inc.php';
$_in_course = true;
$course_code = api_get_course_id();

@ -1,9 +1,6 @@
<?php
/* For licensing terms, see /license.txt */
/**
* Script.
*/
require_once __DIR__.'/../inc/global.inc.php';
$current_course_tool = TOOL_GRADEBOOK;

@ -1,9 +1,6 @@
<?php
/* For licensing terms, see /license.txt */
/**
* Script.
*/
require_once __DIR__.'/../inc/global.inc.php';
require_once '../forum/forumfunction.inc.php';
$current_course_tool = TOOL_GRADEBOOK;

@ -1,9 +1,6 @@
<?php
/* For licensing terms, see /license.txt */
/**
* Script.
*/
require_once __DIR__.'/../inc/global.inc.php';
$current_course_tool = TOOL_GRADEBOOK;

@ -1,9 +1,6 @@
<?php
/* For licensing terms, see /license.txt */
/**
* Script.
*/
//$cidReset = true;
require_once __DIR__.'/../inc/global.inc.php';
$current_course_tool = TOOL_GRADEBOOK;

@ -1,9 +1,7 @@
<?php
/* For licensing terms, see /license.txt */
/**
* Script.
*/
require_once __DIR__.'/../inc/global.inc.php';
require_once api_get_path(SYS_CODE_PATH).'gradebook/lib/fe/exportgradebook.php';
@ -272,28 +270,18 @@ if (isset($_GET['exportpdf'])) {
Display::display_header(get_lang('List View'));
}
if (isset($_GET['isStudentView']) && 'false' == $_GET['isStudentView']) {
DisplayGradebook::display_header_reduce_flatview(
$cat[0],
$showeval,
$showlink,
$simple_search_form
);
$flatViewTable->display();
} elseif (isset($_GET['selectcat']) && isset($_GET['isStudentView']) && ('teacherview' == $_SESSION['studentview'])) {
DisplayGradebook::display_header_reduce_flatview(
$cat[0],
$showeval,
$showlink,
$simple_search_form
);
DisplayGradebook::display_header_reduce_flatview(
$cat[0],
$showeval,
$showlink,
$simple_search_form
);
// Table
$flatViewTable->display();
//@todo load images with jquery
echo '<div id="contentArea" style="text-align: center;" >';
$flatViewTable->display_graph_by_resource();
echo '</div>';
}
// Table
$flatViewTable->display();
//@todo load images with jquery
echo '<div id="contentArea" style="text-align: center;" >';
$flatViewTable->display_graph_by_resource();
echo '</div>';
Display::display_footer();

@ -762,6 +762,7 @@ if (isset($_GET['studentoverview'])) {
$cat->set_session_id($session_id);
} else {
$cat->set_name($course_code);
$cat->setIsRequirement(1);
}
$cat->set_course_code($course_code);
$cat->set_description(null);

@ -2365,9 +2365,8 @@ class Category implements GradebookItem
);
$minCertificateScore = $category->getCertificateMinScore();
$passedCourse = $currentScore >= $minCertificateScore;
return $passedCourse;
return $currentScore >= $minCertificateScore;
}
/**
@ -2583,6 +2582,26 @@ class Category implements GradebookItem
return $this->documentId;
}
/**
* Get the remaining weight in root category.
*
* @return int
*/
public function getRemainingWeight()
{
$subCategories = $this->get_subcategories();
$subWeight = 0;
/** @var Category $subCategory */
foreach ($subCategories as $subCategory) {
$subWeight += $subCategory->get_weight();
}
return $this->weight - $subWeight;
}
/**
* @return int
*/

@ -223,8 +223,7 @@ class ExerciseLink extends AbstractLink
} else {
$lpId = null;
if (!empty($exercise->lpList)) {
// Taking only the first LP
$lpId = current($exercise->lpList);
$lpId = $exercise->getLpBySession($sessionId);
$lpId = $lpId['lp_id'];
}

@ -161,7 +161,7 @@ class LearnpathLink extends AbstractLink
if (!api_is_allowed_to_edit() || null == $this->calc_score(api_get_user_id())) {
$url .= '&action=view&lp_id='.$this->get_ref_id();
} else {
$url .= '&action=add_item&lp_id='.$this->get_ref_id();
$url .= '&action=build&lp_id='.$this->get_ref_id();
}
return $url;

@ -390,16 +390,16 @@ class CatForm extends FormValidator
);
}
if (!empty($session_id)) {
$isRequirementCheckbox = $this->addCheckBox(
'is_requirement',
[
null,
get_lang('Consider this gradebook as a requirement to complete the course (influences the sessions sequences)'),
],
get_lang('Is requirement')
);
}
$isRequirementCheckbox = $this->addCheckBox(
'is_requirement',
[
null,
get_lang('Consider this gradebook as a requirement to complete the course (influences the sessions sequences)'),
],
get_lang('Is requirement')
);
if ($this->category_object->getIsRequirement()) {
$isRequirementCheckbox->setChecked(true);

@ -189,7 +189,8 @@ class FlatViewTable extends SortableTable
if (is_array($header) && isset($header['header'])) {
$header = $header['header'];
}
$dataSet->setSerieDescription('Labels', strip_tags($header));
$header = strip_tags(api_html_entity_decode($header));
$dataSet->setSerieDescription('Labels', $header);
$dataSet->setAbscissa('Labels');
$dataSet->setAbscissaName(get_lang('Skills ranking'));
$dataSet->setAxisName(0, get_lang('Learners'));
@ -242,12 +243,11 @@ class FlatViewTable extends SortableTable
'FontSize' => 10,
]
);
/* Write the chart title */
$myPicture->drawText(
250,
30,
strip_tags($header),
$header,
[
'FontSize' => 12,
'Align' => TEXT_ALIGN_BOTTOMMIDDLE,

@ -68,7 +68,7 @@ class GradebookTable extends SortableTable
null,
null,
api_is_allowed_to_edit() ? 1 : 0,
20,
1000,
'ASC',
'gradebook_list'
);
@ -265,7 +265,6 @@ class GradebookTable extends SortableTable
$defaultData[$item->get_id()]['ranking'] = $rankingStudentList;
$defaultData[$item->get_id()]['ranking_invalidate'] = $invalidateRanking;
}
//exit;
}
break;
}

@ -33,6 +33,7 @@ class LinkAddEditForm extends FormValidator
} elseif (isset($link_type) && isset($category_object)) {
$link = LinkFactory:: create($link_type);
$link->set_course_code(api_get_course_id());
$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');
@ -48,9 +49,10 @@ class LinkAddEditForm extends FormValidator
if ($link->needs_name_and_description()) {
$this->addText('name', get_lang('Name'), true, ['size' => '40', 'maxlength' => '40']);
} else {
$select = $this->addElement('select', 'select_link', get_lang('Choose activity to assess'));
$select = $this->addElement('select', 'select_link', get_lang('ChooseItem'));
foreach ($link->get_all_links() as $newlink) {
$select->addoption($newlink[1], $newlink[0]);
$name = strip_tags(Exercise::get_formated_title_variable($newlink[1]));
$select->addoption($name, $newlink[0]);
}
}
} else {

@ -241,9 +241,12 @@ class GradebookDataGenerator
} else {
if (!empty($studentList)) {
$session_id = api_get_session_id();
//$cats = $item->get_subcategories(null);
$evals = $item->get_evaluations(null);
$links = $item->get_links(null);
$evals = [];
$links = [];
if ('C' === $item->get_item_type()) {
$evals = $item->get_evaluations(null);
$links = $item->get_links(null);
}
foreach ($studentList as $user) {
$ressum = 0;
$weightsum = 0;
@ -301,16 +304,6 @@ class GradebookDataGenerator
}
}
/*$score = $this->build_result_column(
$user['user_id'],
$item,
$ignore_score_color,
true
);
if (!empty($score['score'][0])) {
$invalidateResults = false;
}*/
if (!empty($ressum)) {
$invalidateResults = false;
}
@ -318,9 +311,7 @@ class GradebookDataGenerator
$rankingStudentList[$user['user_id']] = $ressum;
}
}
//error_log($item->get_id());
$score = AbstractLink::getCurrentUserRanking($userId, $rankingStudentList);
//error_log(print_r($score, 1));
}
$row['ranking'] = $scoreDisplay->display_score(

@ -1,4 +1,5 @@
<?php
/* For licensing terms, see /license.txt */
/**
@ -300,6 +301,10 @@ class ScoreDisplay
$disableColor = false,
$ignoreDecimals = false
) {
if (null === $score) {
return '';
}
$my_score = 0 == $score ? 1 : $score;
if (SCORE_BAR == $type) {
@ -314,9 +319,7 @@ class ScoreDisplay
}
if (SCORE_SIMPLE == $type) {
$simpleScore = $this->format_score($my_score[0], $ignoreDecimals);
return $simpleScore;
return $this->format_score($my_score[0], $ignoreDecimals);
}
if ($this->custom_enabled && isset($this->custom_display_conv)) {
@ -412,14 +415,11 @@ class ScoreDisplay
}
$score = $this->display_simple_score($score);
//needs sudo apt-get install php5-intl
if (class_exists('NumberFormatter')) {
$iso = api_get_language_isocode();
$f = new NumberFormatter($iso, NumberFormatter::SPELLOUT);
$letters = $f->format($score);
$letters = api_strtoupper($letters);
$letters = " ($letters) ";
}
$iso = api_get_language_isocode();
$f = new NumberFormatter($iso, NumberFormatter::SPELLOUT);
$letters = $f->format($score);
$letters = api_strtoupper($letters);
$letters = " ($letters) ";
return $score.$letters.$custom;
break;

@ -1,4 +1,5 @@
<?php
/* For licensing terms, see /license.txt */
/**
@ -12,10 +13,6 @@ require_once __DIR__.'/../inc/global.inc.php';
$logInfo = [
'tool' => 'MyCertificates',
'tool_id' => 0,
'tool_id_detail' => 0,
'action' => '',
'action_details' => '',
];
Event::registerLog($logInfo);
@ -34,10 +31,18 @@ if (empty($courseList) && empty($sessionList)) {
);
}
$template = new Template(get_lang('My certificates'));
$hideExportLink = api_get_setting('hide_certificate_export_link');
$hideExportLinkStudent = api_get_setting('hide_certificate_export_link_students');
$allowExport = true;
if ($hideExportLink === 'true' ||
(api_is_student() && $hideExportLinkStudent === 'true')
) {
$allowExport = false;
}
$template->assign('course_list', $courseList);
$template->assign('session_list', $sessionList);
$template->assign('allow_export', $allowExport);
$templateName = $template->get_template('gradebook/my_certificates.tpl');
$content = $template->fetch($templateName);

@ -1,9 +1,6 @@
<?php
/* For licensing terms, see /license.txt */
/**
* Script.
*/
require_once __DIR__.'/../inc/global.inc.php';
api_block_anonymous_users();

@ -2634,7 +2634,7 @@ class DocumentManager
if ($document) {
if ($index_document) {
self::index_document(
$document->getId(),
$document->getIid(),
$course_info['code'],
null,
$_POST['language'] ?? '',
@ -4181,7 +4181,7 @@ class DocumentManager
if (!isset($defaultCertificateId)) {
self::attach_gradebook_certificate(
$courseData['real_id'],
$document->getId(),
$document->getIid(),
$sessionId
);
}
@ -5857,7 +5857,7 @@ This folder contains all sessions that have been opened in the chat. Although th
if (!self::cloudLinkExists($_course, $path, $url)) {
$doc = self::addDocument($_course, $file_path, 'link', 0, $name, $url);
return $doc->getId();
return $doc->getIid();
} else {
return 0;
}
@ -6231,7 +6231,7 @@ This folder contains all sessions that have been opened in the chat. Although th
}
$url = api_get_path(WEB_CODE_PATH).
'document/showinframes.php?cidReq='.$courseInfo['code'].'&id_session='.$sessionId.'&id='.$document->getId();
'document/showinframes.php?cidReq='.$courseInfo['code'].'&id_session='.$sessionId.'&id='.$document->getIid();
$link = Display::url(basename($title), $url, ['target' => '_blank']);
$userInfo = api_get_user_info($userId);

@ -39,12 +39,15 @@
{% for item in data %}
{% set category_language_array = [] %}
{% set category_language = '' %}
{% for extra_field in item.extra_fields %}
{% if extra_field.variable == 'language' %}
{% set category_language_array = extra_field.value | split(';') %}
{% set category_language = extra_field.value | replace({';': ' ' }) %}
{% endif %}
{% endfor %}
{% if item.extra_fields is defined %}
{% for extra_field in item.extra_fields %}
{% if extra_field.variable == 'language' %}
{% set category_language_array = extra_field.value | split(';') %}
{% set category_language = extra_field.value | replace({';': ' ' }) %}
{% endif %}
{% endfor %}
{% endif %}
{% if fold_forum_categories %}
{% set panel_icon %}

@ -0,0 +1,457 @@
<?php
/* For licensing terms, see /license.txt */
use ChamiloSession as Session;
require_once __DIR__.'/../inc/global.inc.php';
api_protect_course_script();
$sessionId = api_get_session_id();
$courseId = api_get_course_int_id();
// Access restrictions.
$is_allowedToTrack = Tracking::isAllowToTrack($sessionId);
if (!$is_allowedToTrack) {
api_not_allowed(true);
exit;
}
$action = isset($_GET['action']) ? $_GET['action'] : null;
$lps = learnpath::getLpList($courseId);
Session::write('lps', $lps);
/**
* Prepares the shared SQL query for the user table.
* See get_user_data() and get_number_of_users().
*
* @param bool $getCount Whether to count, or get data
*
* @return string SQL query
*/
function prepare_user_sql_query($getCount)
{
$sql = '';
$user_table = Database::get_main_table(TABLE_MAIN_USER);
$admin_table = Database::get_main_table(TABLE_MAIN_ADMIN);
if ($getCount) {
$sql .= "SELECT COUNT(u.id) AS total_number_of_items FROM $user_table u";
} else {
$sql .= 'SELECT u.id AS col0, u.official_code AS col2, ';
if (api_is_western_name_order()) {
$sql .= 'u.firstname AS col3, u.lastname AS col4, ';
} else {
$sql .= 'u.lastname AS col3, u.firstname AS col4, ';
}
$sql .= " u.username AS col5,
u.email AS col6,
u.status AS col7,
u.active AS col8,
u.registration_date AS col9,
u.last_login as col10,
u.id AS col11,
u.expiration_date AS exp,
u.password
FROM $user_table u";
}
// adding the filter to see the user's only of the current access_url
if ((api_is_platform_admin() || api_is_session_admin()) && api_get_multiple_access_url()) {
$access_url_rel_user_table = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
$sql .= " INNER JOIN $access_url_rel_user_table url_rel_user
ON (u.id=url_rel_user.user_id)";
}
$keywordList = [
'keyword_firstname',
'keyword_lastname',
'keyword_username',
'keyword_email',
'keyword_officialcode',
'keyword_status',
'keyword_active',
'keyword_inactive',
'check_easy_passwords',
];
$keywordListValues = [];
$atLeastOne = false;
foreach ($keywordList as $keyword) {
$keywordListValues[$keyword] = null;
if (isset($_GET[$keyword]) && !empty($_GET[$keyword])) {
$keywordListValues[$keyword] = $_GET[$keyword];
$atLeastOne = true;
}
}
if ($atLeastOne == false) {
$keywordListValues = [];
}
if (isset($_GET['keyword']) && !empty($_GET['keyword'])) {
$keywordFiltered = Database::escape_string("%".$_GET['keyword']."%");
$sql .= " WHERE (
u.firstname LIKE '$keywordFiltered' OR
u.lastname LIKE '$keywordFiltered' OR
concat(u.firstname, ' ', u.lastname) LIKE '$keywordFiltered' OR
concat(u.lastname,' ',u.firstname) LIKE '$keywordFiltered' OR
u.username LIKE '$keywordFiltered' OR
u.official_code LIKE '$keywordFiltered' OR
u.email LIKE '$keywordFiltered'
)
";
} elseif (isset($keywordListValues) && !empty($keywordListValues)) {
$query_admin_table = '';
$keyword_admin = '';
if (isset($keywordListValues['keyword_status']) &&
$keywordListValues['keyword_status'] == PLATFORM_ADMIN
) {
$query_admin_table = " , $admin_table a ";
$keyword_admin = ' AND a.user_id = u.id ';
$keywordListValues['keyword_status'] = '%';
}
$keyword_extra_value = '';
$sql .= " $query_admin_table
WHERE (
u.firstname LIKE '".Database::escape_string("%".$keywordListValues['keyword_firstname']."%")."' AND
u.lastname LIKE '".Database::escape_string("%".$keywordListValues['keyword_lastname']."%")."' AND
u.username LIKE '".Database::escape_string("%".$keywordListValues['keyword_username']."%")."' AND
u.email LIKE '".Database::escape_string("%".$keywordListValues['keyword_email']."%")."' AND
u.status LIKE '".Database::escape_string($keywordListValues['keyword_status'])."' ";
if (!empty($keywordListValues['keyword_officialcode'])) {
$sql .= " AND u.official_code LIKE '".Database::escape_string("%".$keywordListValues['keyword_officialcode']."%")."' ";
}
$sql .= "
$keyword_admin
$keyword_extra_value
";
if (isset($keywordListValues['keyword_active']) &&
!isset($keywordListValues['keyword_inactive'])
) {
$sql .= ' AND u.active = 1';
} elseif (isset($keywordListValues['keyword_inactive']) &&
!isset($keywordListValues['keyword_active'])
) {
$sql .= ' AND u.active = 0';
}
$sql .= ' ) ';
}
$preventSessionAdminsToManageAllUsers = api_get_setting('prevent_session_admins_to_manage_all_users');
if (api_is_session_admin() && $preventSessionAdminsToManageAllUsers === 'true') {
$sql .= ' AND u.creator_id = '.api_get_user_id();
}
$variables = Session::read('variables_to_show', []);
if (!empty($variables)) {
$extraField = new ExtraField('user');
$extraFieldResult = [];
$extraFieldHasData = [];
foreach ($variables as $variable) {
if (isset($_GET['extra_'.$variable])) {
if (is_array($_GET['extra_'.$variable])) {
$values = $_GET['extra_'.$variable];
} else {
$values = [$_GET['extra_'.$variable]];
}
if (empty($values)) {
continue;
}
$info = $extraField->get_handler_field_info_by_field_variable(
$variable
);
if (empty($info)) {
continue;
}
foreach ($values as $value) {
if (empty($value)) {
continue;
}
if ($info['field_type'] == ExtraField::FIELD_TYPE_TAG) {
$result = $extraField->getAllUserPerTag(
$info['id'],
$value
);
$result = empty($result) ? [] : array_column(
$result,
'user_id'
);
} else {
$result = UserManager::get_extra_user_data_by_value(
$variable,
$value
);
}
$extraFieldHasData[] = true;
if (!empty($result)) {
$extraFieldResult = array_merge(
$extraFieldResult,
$result
);
}
}
}
}
if (!empty($extraFieldHasData)) {
$sql .= " AND (u.id IN ('".implode("','", $extraFieldResult)."')) ";
}
}
// adding the filter to see the user's only of the current access_url
if ((api_is_platform_admin() || api_is_session_admin()) &&
api_get_multiple_access_url()
) {
$sql .= ' AND url_rel_user.access_url_id = '.api_get_current_access_url_id();
}
return $sql;
}
function getCount()
{
$sessionId = api_get_session_id();
$courseCode = api_get_course_id();
if (empty($sessionId)) {
// Registered students in a course outside session.
$count = CourseManager::get_student_list_from_course_code(
$courseCode,
false,
null,
null,
null,
null,
null,
true
);
} else {
// Registered students in session.
$count = CourseManager::get_student_list_from_course_code(
$courseCode,
true,
$sessionId,
null,
null,
null,
null,
true
);
}
return $count;
}
/**
* Get the users to display on the current page (fill the sortable-table).
*
* @param int offset of first user to recover
* @param int Number of users to get
* @param int Column to sort on
* @param string Order (ASC,DESC)
*
* @return array Users list
*
* @see SortableTable#get_table_data($from)
*/
function getData($from, $numberOfItems, $column, $direction)
{
$sessionId = api_get_session_id();
$courseCode = api_get_course_id();
$courseId = api_get_course_int_id();
$lps = Session::read('lps');
if (empty($sessionId)) {
// Registered students in a course outside session.
$students = CourseManager::get_student_list_from_course_code(
$courseCode,
false,
null,
null,
null,
null,
null,
false,
$from,
$numberOfItems
);
} else {
// Registered students in session.
$students = CourseManager::get_student_list_from_course_code(
$courseCode,
true,
$sessionId,
null,
null,
null,
null,
false,
$from,
$numberOfItems
);
}
$useNewTable = Tracking::minimumTimeAvailable($sessionId, $courseId);
$users = [];
foreach ($students as $student) {
$user = [];
$userId = $student['id'];
$user[] = $student['firstname'];
$user[] = $student['lastname'];
$user[] = $student['username'];
$lpTimeList = [];
if ($useNewTable) {
$lpTimeList = Tracking::getCalculateTime($userId, $courseId, $sessionId);
}
foreach ($lps as $lp) {
$lpId = $lp['id'];
$progress = Tracking::get_avg_student_progress(
$userId,
$courseCode,
[$lpId],
$sessionId
);
if ($useNewTable) {
$time = isset($lpTimeList[TOOL_LEARNPATH][$lpId]) ? $lpTimeList[TOOL_LEARNPATH][$lpId] : 0;
} else {
$time = Tracking::get_time_spent_in_lp(
$userId,
$courseCode,
[$lpId],
$sessionId
);
}
$time = api_time_to_hms($time);
$first = Tracking::getFirstConnectionTimeInLp(
$userId,
$courseCode,
$lpId,
$sessionId
);
$first = api_convert_and_format_date(
$first,
DATE_TIME_FORMAT_LONG
);
$last = Tracking::get_last_connection_time_in_lp(
$userId,
$courseCode,
$lpId,
$sessionId
);
$last = api_convert_and_format_date(
$last,
DATE_TIME_FORMAT_LONG
);
$score = Tracking::getAverageStudentScore(
$userId,
$courseCode,
[$lpId],
$sessionId
);
if (is_numeric($score)) {
$score = $score.'%';
}
$user[] = $progress;
$user[] = $first;
$user[] = $last;
$user[] = $time;
$user[] = $score;
}
$users[] = $user;
}
return $users;
}
$interbreadcrumb[] = [
'url' => api_get_path(WEB_CODE_PATH).'tracking/courseLog.php?'.api_get_cidreq(),
'name' => get_lang('Tracking'),
];
$tool_name = get_lang('CourseLPsGenericStats');
$headers = [];
$headers[] = get_lang('FirstName');
$headers[] = get_lang('LastName');
$headers[] = get_lang('Username');
foreach ($lps as $lp) {
$lpName = $lp['name'];
$headers[] = get_lang('Progress').': '.$lpName;
$headers[] = get_lang('FirstAccess').': '.$lpName;
$headers[] = get_lang('LastAccess').': '.$lpName;
$headers[] = get_lang('Time').': '.$lpName;
$headers[] = get_lang('Score').': '.$lpName;
}
if (!empty($action)) {
switch ($action) {
case 'export':
$data = getData(0, 100000, null, null);
$data = array_merge([$headers], $data);
$name = api_get_course_id().'_'.get_lang('Learnpath').'_'.get_lang('Export');
Export::arrayToXls($data, $name);
exit;
break;
}
}
$actionsLeft = TrackingCourseLog::actionsLeft('lp');
$actionsCenter = '';
$actionsRight = Display::url(
Display::return_icon('export_excel.png', get_lang('ExportAsXLS'), null, ICON_SIZE_MEDIUM),
api_get_self().'?action=export&'.api_get_cidreq()
);
// Create a sortable table with user-data
$parameters = [];
$parameters['sec_token'] = Security::get_token();
$parameters['cidReq'] = api_get_course_id();
$parameters['id_session'] = api_get_session_id();
$table = new SortableTable(
'lps',
'getCount',
'getData'
);
$table->set_additional_parameters($parameters);
$column = 0;
foreach ($headers as $header) {
$lpName = $lp['name'];
$table->set_header($column++, $header, false);
}
$tableToString = $table->return_table();
$toolbarActions = Display::toolbarAction(
'toolbarUser',
[$actionsLeft, $actionsCenter, $actionsRight],
[4, 4, 4]
);
$tpl = new Template($tool_name);
$tpl->assign('actions', $toolbarActions);
$tpl->assign('content', $tableToString);
$tpl->display_one_col_template();

@ -17,6 +17,7 @@ if (!$allowUser) {
$fromUserId = isset($_GET['from_user']) ? (int) $_GET['from_user'] : 0;
$toUserId = isset($_GET['to_user']) ? (int) $_GET['to_user'] : 0;
if (empty($fromUserId) || empty($toUserId)) {
api_not_allowed(true);
}

Loading…
Cancel
Save