Adding my_students_lp/my_progress_lp tracking column settings

See BT#12474
pull/2487/head
jmontoyaa 8 years ago
parent b2141e6b0c
commit 04047d2932
  1. 98
      main/inc/lib/tracking.lib.php
  2. 16
      main/install/configuration.dist.php
  3. 193
      main/mySpace/myStudents.php

@ -5279,16 +5279,40 @@ class Tracking
}
$html .= '</tbody></table></div>';
$columnHeaders = [
'lp' => get_lang('LearningPath'),
'time' => get_lang('LatencyTimeSpent'),
'progress' => get_lang('Progress'),
'score' => get_lang('Score'),
'best_score' => get_lang('BestScore'),
'last_connection' => get_lang('LastConnexion'),
];
$headers = '';
$trackingColumns = api_get_configuration_value('tracking_columns');
if (isset($trackingColumns['my_progress_lp'])) {
foreach ($columnHeaders as $key => $value) {
if (!isset($trackingColumns['my_progress_lp'][$key]) ||
$trackingColumns['my_progress_lp'][$key] == false
) {
unset($columnHeaders[$key]);
}
}
}
$columnHeadersKeys = array_keys($columnHeaders);
foreach ($columnHeaders as $key => $columnName) {
$headers .= Display::tag(
'th',
$columnName
);
}
// LP table results
$html .= '<div class="table-responsive">';
$html .= '<table class="table table-striped table-hover">';
$html .= '<thead><tr>';
$html .= Display::tag('th', get_lang('LearningPath'));
$html .= Display::tag('th', get_lang('LatencyTimeSpent'));
$html .= Display::tag('th', get_lang('Progress'));
$html .= Display::tag('th', get_lang('Score'));
$html .= Display::tag('th', get_lang('BestScore'));
$html .= Display::tag('th', get_lang('LastConnexion'));
$html .= $headers;
$html .= '</tr></thead><tbody>';
$list = new LearnpathList(
@ -5340,6 +5364,9 @@ class Tracking
true
);
if (is_numeric($progress)) {
$progress = $progress.'%';
}
if (is_numeric($percentage_score)) {
$percentage_score = $percentage_score.'%';
} else {
@ -5353,30 +5380,57 @@ class Tracking
}
$time_spent_in_lp = api_time_to_hms($time_spent_in_lp);
$last_connection = '-';
if (!empty($last_connection_in_lp)) {
$last_connection = api_convert_and_format_date($last_connection_in_lp, DATE_TIME_FORMAT_LONG);
}
$html .= '<tr class="row_even">';
$url = api_get_path(WEB_CODE_PATH)."lp/lp_controller.php?cidReq={$course_code}&id_session=$session_id&lp_id=$lp_id&action=view";
$html .= '<tr class="row_even">';
if ($learnpath['lp_visibility'] == 0) {
$html .= Display::tag('td', $learnpath['lp_name']);
} else {
$html .= Display::tag('td', Display::url($learnpath['lp_name'], $url, array('target'=>SESSION_LINK_TARGET)));
if (in_array('lp', $columnHeadersKeys)) {
if ($learnpath['lp_visibility'] == 0) {
$html .= Display::tag('td', $learnpath['lp_name']);
} else {
$html .= Display::tag(
'td',
Display::url(
$learnpath['lp_name'],
$url,
array('target' => SESSION_LINK_TARGET)
)
);
}
}
$html .= Display::tag('td', $time_spent_in_lp, array('align'=>'center'));
if (is_numeric($progress)) {
$progress = $progress.'%';
if (in_array('time', $columnHeadersKeys)) {
$html .= Display::tag(
'td',
$time_spent_in_lp,
array('align' => 'center')
);
}
$html .= Display::tag('td', $progress, array('align'=>'center'));
$html .= Display::tag('td', $percentage_score);
$html .= Display::tag('td', $bestScore);
$last_connection = '-';
if (!empty($last_connection_in_lp)) {
$last_connection = api_convert_and_format_date($last_connection_in_lp, DATE_TIME_FORMAT_LONG);
if (in_array('progress', $columnHeadersKeys)) {
$html .= Display::tag(
'td',
$progress,
array('align' => 'center')
);
}
if (in_array('score', $columnHeadersKeys)) {
$html .= Display::tag('td', $percentage_score);
}
if (in_array('best_score', $columnHeadersKeys)) {
$html .= Display::tag('td', $bestScore);
}
$html .= Display::tag('td', $last_connection, array('align'=>'center', 'width'=>'180px'));
$html .= "</tr>";
if (in_array('last_connection', $columnHeadersKeys)) {
$html .= Display::tag('td', $last_connection, array('align'=>'center', 'width'=>'180px'));
}
$html .= '</tr>';
}
} else {
$html .= '<tr>

@ -335,6 +335,22 @@ $_configuration['tracking_columns'] = [
'last_connection' => true,
'details' => true,
],
'my_students_lp' => [
'lp' => true,
'time' => true,
'best_score' => true,
'latest_attempt_avg_score' => true,
'progress' => true,
'last_connection' => true,
],
'my_progress_lp' => [
'lp' => true,
'time' => true,
'progress' => true,
'score' => true,
'best_score' => true,
'last_connection' => true,
]
];
*/
// Hide session link of course_block on index/userportal

@ -858,22 +858,64 @@ if (!empty($student_id)) {
echo '</div>';
}
} else {
$trackingColumns = api_get_configuration_value('tracking_columns');
$columnHeaders = [
'lp' => get_lang('LearningPath'),
'time' => get_lang('Time').
Display::return_icon(
'info3.gif',
get_lang('TotalTimeByCourse'),
array('align' => 'absmiddle', 'hspace' => '3px')
),
'best_score' => get_lang('BestScore'),
'latest_attempt_avg_score' => get_lang('LatestAttemptAverageScore').
Display::return_icon(
'info3.gif',
get_lang('AverageIsCalculatedBasedInTheLatestAttempts'),
array('align' => 'absmiddle', 'hspace' => '3px')
),
'progress'=> get_lang('Progress').
Display::return_icon(
'info3.gif',
get_lang('LPProgressScore'),
array('align' => 'absmiddle', 'hspace' => '3px')
),
'last_connection' => get_lang('LastConnexion').
Display::return_icon(
'info3.gif',
get_lang('LastTimeTheCourseWasUsed'),
array('align' => 'absmiddle', 'hspace' => '3px')
)
];
if ($user_info['status'] != INVITEE) {
$csv_content[] = array();
$csv_content[] = array(str_replace('&nbsp;', '', $table_title));
$t_lp = Database::get_course_table(TABLE_LP_MAIN);
$trackingColumns = api_get_configuration_value('tracking_columns');
if (isset($trackingColumns['my_students_lp'])) {
foreach ($columnHeaders as $key => $value) {
if (!isset($trackingColumns['my_progress_lp'][$key]) ||
$trackingColumns['my_students_lp'][$key] == false
) {
unset($columnHeaders[$key]);
}
}
}
$headers = '';
$columnHeadersToExport = [];
// csv export headers
$csv_content[] = array();
$csv_content[] = array(
get_lang('Learnpath'),
get_lang('Time'),
get_lang('BestScore'),
get_lang('AverageScore'),
get_lang('LatestAttemptAverageScore'),
get_lang('Progress'),
get_lang('LastConnexion')
);
foreach ($columnHeaders as $key => $columnName) {
$columnHeadersToExport[] = strip_tags($columnName);
$headers .= Display::tag(
'th',
$columnName
);
}
$csv_content[] = $columnHeadersToExport;
$columnHeadersKeys = array_keys($columnHeaders);
// @todo use LearnpathList class
if (empty($sessionId)) {
@ -905,66 +947,14 @@ if (!empty($student_id)) {
$lps = $query->getResult();
if (count($lps) > 0) {
?>
<!-- LPs-->
<div class="table-responsive">
<table class="table table-striped table-hover">
<thead>
<tr>
<th><?php echo get_lang('LearningPath');?></th>
<th>
<?php
echo get_lang('Time').' ';
Display:: display_icon(
'info3.gif',
get_lang('TotalTimeByCourse'),
array('align' => 'absmiddle', 'hspace' => '3px')
);
?>
</th>
<th>
<?php
echo get_lang('BestScore').' ';
?>
</th>
<th>
<?php
echo get_lang('LatestAttemptAverageScore').' ';
Display::display_icon(
'info3.gif',
get_lang('AverageIsCalculatedBasedInTheLatestAttempts'),
array('align' => 'absmiddle', 'hspace' => '3px')
);
?>
</th>
<th><?php
echo get_lang('Progress').' ';
Display:: display_icon(
'info3.gif',
get_lang('LPProgressScore'),
array('align' => 'absmiddle', 'hspace' => '3px')
);
?>
</th>
<th><?php
echo get_lang('LastConnexion').' ';
Display:: display_icon(
'info3.gif',
get_lang('LastTimeTheCourseWasUsed'),
array('align' => 'absmiddle', 'hspace' => '3px')
);
?>
</th>
<?php
echo '<th>'.get_lang('Details').'</th>';
if (api_is_allowed_to_edit()) {
echo '<th>'.get_lang('ResetLP').'</th>';
}
?>
</tr>
</thead>
<tbody>
<?php
echo '<div class="table-responsive">';
echo '<table class="table table-striped table-hover"><thead><tr>';
echo $headers;
echo '<th>'.get_lang('Details').'</th>';
if (api_is_allowed_to_edit()) {
echo '<th>'.get_lang('ResetLP').'</th>';
}
echo '</tr></thead><tbody>';
$i = 0;
/** @var CLp $learnpath */
@ -1059,33 +1049,11 @@ if (!empty($student_id)) {
$i++;
// csv export content
$csv_content[] = array(
api_html_entity_decode(stripslashes($lp_name), ENT_QUOTES, $charset),
api_time_to_hms($total_time),
$bestScore,
$score_latest,
$progress.'%',
$start_time
);
echo '<tr class="'.$css_class.'">';
echo Display::tag('td', stripslashes($lp_name));
echo Display::tag('td', api_time_to_hms($total_time));
if (isset($score) && !is_null($score)) {
if (is_numeric($score)) {
$score = $score.'%';
}
}
echo Display::tag('td', $bestScore);
if (isset($score_latest) && !is_null($score_latest)) {
if (is_numeric($score_latest)) {
$score_latest = $score_latest.'%';
}
}
echo Display::tag('td', $score_latest);
if (is_numeric($progress)) {
$progress = $progress.'%';
@ -1093,10 +1061,39 @@ if (!empty($student_id)) {
$progress = '-';
}
echo Display::tag('td', $progress);
//Do not change with api_convert_and_format_date, because this value came from the lp_item_view table
//which implies several other changes not a priority right now
echo Display::tag('td', $start_time);
echo '<tr class="'.$css_class.'">';
$contentToExport = [];
if (in_array('lp', $columnHeadersKeys)) {
$contentToExport[] = api_html_entity_decode(stripslashes($lp_name), ENT_QUOTES, $charset);
echo Display::tag('td', stripslashes($lp_name));
}
if (in_array('time', $columnHeadersKeys)) {
$contentToExport[] = api_time_to_hms($total_time);
echo Display::tag('td', api_time_to_hms($total_time));
}
if (in_array('best_score', $columnHeadersKeys)) {
$contentToExport[] = $bestScore;
echo Display::tag('td', $bestScore);
}
if (in_array('latest_attempt_avg_score', $columnHeadersKeys)) {
$contentToExport[] = $score_latest;
echo Display::tag('td', $score_latest);
}
if (in_array('progress', $columnHeadersKeys)) {
$contentToExport[] = $progress;
echo Display::tag('td', $progress);
}
if (in_array('last_connection', $columnHeadersKeys)) {
//Do not change with api_convert_and_format_date, because this value came from the lp_item_view table
//which implies several other changes not a priority right now
$contentToExport[] = $start_time;
echo Display::tag('td', $start_time);
}
$csv_content[] = $contentToExport;
if ($any_result === true) {
$from = '';
@ -1125,8 +1122,6 @@ if (!empty($student_id)) {
echo '</td>';
echo '</tr>';
}
$data_learnpath[$i][] = $lp_name;
$data_learnpath[$i][] = $progress . '%';
}
?>
</tbody>

Loading…
Cancel
Save