diff --git a/main/inc/lib/tracking.lib.php b/main/inc/lib/tracking.lib.php
index 0db0b25ba1..7a70febb16 100755
--- a/main/inc/lib/tracking.lib.php
+++ b/main/inc/lib/tracking.lib.php
@@ -37,19 +37,21 @@ class Tracking
$extendId = null,
$extendAttemptId = null,
$extendedAttempt = null,
- $extendedAll = null
+ $extendedAll = null,
+ $type = 'classic'
) {
- if (empty($courseInfo)) {
+ if (empty($courseInfo) || empty($lp_id)) {
return null;
}
- $list = learnpath :: get_flat_ordered_items_list($lp_id, 0, $courseInfo['real_id']);
-
$lp_id = intval($lp_id);
$lp_item_id = intval($lp_item_id);
$user_id = intval($user_id);
+ $session_id = intval($session_id);
$origin = Security::remove_XSS($origin);
+ $list = learnpath :: get_flat_ordered_items_list($lp_id, 0, $courseInfo['real_id']);
+
$is_allowed_to_edit = api_is_allowed_to_edit(null, true);
$course_id = $courseInfo['real_id'];
$courseCode = $courseInfo['code'];
@@ -66,12 +68,17 @@ class Tracking
}
if (!empty($extendedAll)) {
- $extend_all_link = '
-
';
+ $extend_all_link = Display::url(
+ Display::return_icon('view_less_stats.gif', get_lang('HideAllAttempts')),
+ api_get_self() . '?action=stats' . $url_suffix
+ );
+
$extend_all = 1;
} else {
- $extend_all_link = '
-
';
+ $extend_all_link = Display::url(
+ Display::return_icon('view_more_stats.gif', get_lang('ShowAllAttempts')),
+ api_get_self() . '?action=stats&extend_all=1' . $url_suffix
+ );
}
if ($origin != 'tracking') {
@@ -110,11 +117,13 @@ class Tracking
$tbl_stats_exercices = Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
$tbl_stats_attempts = Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_ATTEMPT);
- $sql = "SELECT max(view_count) FROM $TBL_LP_VIEW
+ $sql = "SELECT max(view_count)
+ FROM $TBL_LP_VIEW
WHERE
c_id = $course_id AND
lp_id = $lp_id AND
- user_id = '" . $user_id . "' $session_condition";
+ user_id = $user_id
+ $session_condition";
$res = Database::query($sql);
$view = '';
if (Database :: num_rows($res) > 0) {
@@ -148,69 +157,44 @@ class Tracking
}
// Prepare statement to go through each attempt.
+ $viewCondition = null;
if (!empty($view)) {
- $sql = "SELECT
- iv.status as mystatus,
- v.view_count as mycount,
- iv.score as myscore,
- iv.total_time as mytime,
- i.id as myid,
- i.lp_id as mylpid,
- iv.lp_view_id as mylpviewid,
- i.title as mytitle,
- i.max_score as mymaxscore,
- iv.max_score as myviewmaxscore,
- i.item_type as item_type,
- iv.view_count as iv_view_count,
- iv.id as iv_id,
- path
- FROM $TBL_LP_ITEM as i
- INNER JOIN $TBL_LP_ITEM_VIEW as iv
- ON (i.id = iv.lp_item_id AND i.c_id = $course_id AND iv.c_id = $course_id)
- INNER JOIN $TBL_LP_VIEW as v
- ON (iv.lp_view_id = v.id AND v.c_id = $course_id)
- WHERE
- i.id = $my_item_id AND
- i.lp_id = $lp_id AND
- v.user_id = $user_id AND
- v.view_count = $view AND
- v.session_id = $session_id
- ORDER BY iv.view_count $qry_order ";
-
- } else {
- $sql = "SELECT
- iv.status as mystatus,
- v.view_count as mycount,
- iv.score as myscore,
- iv.total_time as mytime,
- i.id as myid,
- i.lp_id as mylpid,
- iv.lp_view_id as mylpviewid,
- i.title as mytitle,
- i.max_score as mymaxscore,
- iv.max_score as myviewmaxscore,
- i.item_type as item_type,
- iv.view_count as iv_view_count,
- iv.id as iv_id,
- path
- FROM $TBL_LP_ITEM as i
- INNER JOIN $TBL_LP_ITEM_VIEW as iv
- ON (i.id = iv.lp_item_id AND i.c_id = $course_id AND iv.c_id = $course_id)
- INNER JOIN $TBL_LP_VIEW as v
- ON (iv.lp_view_id = v.id AND v.c_id = $course_id)
- WHERE
- i.id = $my_item_id AND
- i.lp_id = $lp_id AND
- v.user_id = $user_id AND
- v.session_id = $session_id
- ORDER BY iv.view_count $qry_order ";
+ $viewCondition = " AND v.view_count = $view ";
}
+ $sql = "SELECT
+ iv.status as mystatus,
+ v.view_count as mycount,
+ iv.score as myscore,
+ iv.total_time as mytime,
+ i.id as myid,
+ i.lp_id as mylpid,
+ iv.lp_view_id as mylpviewid,
+ i.title as mytitle,
+ i.max_score as mymaxscore,
+ iv.max_score as myviewmaxscore,
+ i.item_type as item_type,
+ iv.view_count as iv_view_count,
+ iv.id as iv_id,
+ path
+ FROM $TBL_LP_ITEM as i
+ INNER JOIN $TBL_LP_ITEM_VIEW as iv
+ ON (i.id = iv.lp_item_id AND i.c_id = $course_id AND iv.c_id = $course_id)
+ INNER JOIN $TBL_LP_VIEW as v
+ ON (iv.lp_view_id = v.id AND v.c_id = $course_id)
+ WHERE
+ i.id = $my_item_id AND
+ i.lp_id = $lp_id AND
+ v.user_id = $user_id AND
+ v.session_id = $session_id
+ $viewCondition
+ ORDER BY iv.view_count $qry_order ";
+
$result = Database::query($sql);
$num = Database :: num_rows($result);
$time_for_total = 'NaN';
- //Extend all + extend scorm?
+ // Extend all + extend scorm?
if (($extend_this || $extend_all) && $num > 0) {
$row = Database :: fetch_array($result);
$result_disabled_ext_all = false;
@@ -220,7 +204,9 @@ class Tracking
$sql = "SELECT results_disabled
FROM $TBL_QUIZ
- WHERE c_id = $course_id AND id ='" . $my_path . "'";
+ WHERE
+ c_id = $course_id AND
+ id ='" . $my_path . "'";
$res_result_disabled = Database::query($sql);
$row_result_disabled = Database::fetch_row($res_result_disabled);
@@ -239,9 +225,10 @@ class Tracking
}
$extend_link = '';
if (!empty($inter_num)) {
- $extend_link = '
-
- ';
+ $extend_link = Display::url(
+ Display::return_icon('visible.gif', get_lang('HideAttemptView')),
+ api_get_self() . '?action=stats&fold_id=' . $my_item_id . $url_suffix
+ );
}
$title = $row['mytitle'];
@@ -264,7 +251,6 @@ class Tracking
';
}
$counter++;
-
$attemptCount = 1;
do {
@@ -273,18 +259,22 @@ class Tracking
$extend_this_attempt = 0;
if ((learnpath :: get_interactions_count_from_db($row['iv_id'], $course_id) > 0 ||
- learnpath :: get_objectives_count_from_db($row['iv_id'], $course_id) > 0) &&
+ learnpath :: get_objectives_count_from_db($row['iv_id'], $course_id) > 0) &&
!$extend_all
) {
if ($extendAttemptId == $row['iv_id']) {
// The extend button for this attempt has been clicked.
$extend_this_attempt = 1;
- $extend_attempt_link = '
-
';
+ $extend_attempt_link = Display::url(
+ Display::return_icon('visible.gif', get_lang('HideAttemptView')),
+ api_get_self() . '?action=stats&extend_id=' . $my_item_id . '&fold_attempt_id=' . $row['iv_id'] . $url_suffix
+ );
} else { // Same case if fold_attempt_id is set, so not implemented explicitly.
// The extend button for this attempt has not been clicked.
- $extend_attempt_link = '
-
';
+ $extend_attempt_link = Display::url(
+ Display::return_icon('invisible.gif', get_lang('ExtendAttemptView')),
+ api_get_self() . '?action=stats&extend_id=' . $my_item_id . '&extend_attempt_id=' . $row['iv_id'] . $url_suffix
+ );
}
}
@@ -343,7 +333,7 @@ class Tracking
- ';
- } else { // Same case if fold_attempt_id is set, so not implemented explicitly.
+ $extend_attempt_link = Display::url(
+ Display::return_icon('visible.gif', get_lang('HideAttemptView')),
+ api_get_self() . '?action=stats&extend_id=' . $my_item_id . '&fold_attempt_id=' . $row['iv_id'] . $url_suffix
+ );
+ } else {
+ // Same case if fold_attempt_id is set, so not implemented explicitly.
// The extend button for this attempt has not been clicked.
- $extend_attempt_link = '
-
- ';
+ $extend_attempt_link = Display::url(
+ Display::return_icon('invisible.gif', get_lang('ExtendAttemptView')),
+ api_get_self() . '?action=stats&extend_id=' . $my_item_id . '&extend_attempt_id=' . $row['iv_id'] . $url_suffix
+ );
}
}
@@ -484,9 +477,10 @@ class Tracking
$extend_link = '';
if ($inter_num > 1) {
- $extend_link = '
-
- ';
+ $extend_link = Display::url(
+ Display::return_icon('invisible.gif', get_lang('ExtendAttemptView')),
+ api_get_self() . '?action=stats&extend_id=' . $my_item_id . '&extend_attempt_id=' . $row['iv_id'] . $url_suffix
+ );
}
$lesson_status = $row['mystatus'];
@@ -535,24 +529,28 @@ class Tracking
} else {
if ($row['item_type'] == 'quiz') {
// Get score and total time from last attempt of a exercise en lp.
- $sql = "SELECT score FROM $TBL_LP_ITEM_VIEW
- WHERE
- c_id = $course_id AND
- lp_item_id = '" . (int) $my_id . "' AND
- lp_view_id = '" . (int) $my_lp_view_id . "'
- ORDER BY view_count DESC limit 1";
+ $sql = "SELECT score
+ FROM $TBL_LP_ITEM_VIEW
+ WHERE
+ c_id = $course_id AND
+ lp_item_id = '" . (int) $my_id . "' AND
+ lp_view_id = '" . (int) $my_lp_view_id . "'
+ ORDER BY view_count DESC limit 1";
$res_score = Database::query($sql);
$row_score = Database::fetch_array($res_score);
- $sql = "SELECT SUM(total_time) as total_time FROM $TBL_LP_ITEM_VIEW
- WHERE
- c_id = $course_id AND
- lp_item_id = '" . (int) $my_id . "' AND
- lp_view_id = '" . (int) $my_lp_view_id . "'";
+ $sql = "SELECT SUM(total_time) as total_time
+ FROM $TBL_LP_ITEM_VIEW
+ WHERE
+ c_id = $course_id AND
+ lp_item_id = '" . (int) $my_id . "' AND
+ lp_view_id = '" . (int) $my_lp_view_id . "'";
$res_time = Database::query($sql);
$row_time = Database::fetch_array($res_time);
- if (Database::num_rows($res_score) > 0 && Database::num_rows($res_time) > 0) {
+ if (Database::num_rows($res_score) > 0 &&
+ Database::num_rows($res_time) > 0
+ ) {
$score = (float) $row_score['score'];
$subtotal_time = (int) $row_time['total_time'];
} else {
@@ -561,11 +559,11 @@ class Tracking
}
// Selecting the max score from an attempt.
$sql = "SELECT SUM(t.ponderation) as maxscore
- FROM (
- SELECT distinct question_id, marks, ponderation
- FROM $tbl_stats_attempts as at INNER JOIN $tbl_quiz_questions as q
- ON (q.id = at.question_id AND q.c_id = $course_id
- )
+ FROM (
+ SELECT distinct question_id, marks, ponderation
+ FROM $tbl_stats_attempts as at INNER JOIN $tbl_quiz_questions as q
+ ON (q.id = at.question_id AND q.c_id = $course_id
+ )
WHERE exe_id ='$id_last_attempt' ) as t";
$result = Database::query($sql);
@@ -582,15 +580,13 @@ class Tracking
if (empty($title)) {
$title = rl_get_resource_name(api_get_course_id(), $lp_id, $row['myid']);
}
- // Remove "NaN" if any (@todo: locate the source of these NaN)
- //$time = str_replace('NaN', '00'.$h.'00\'00"', $time);
if ($row['item_type'] != 'dokeos_chapter') {
if ($row['item_type'] == 'quiz') {
$correct_test_link = '';
$my_url_suffix = '';
- $my_url_suffix = '&course=' . $courseCode . '&student_id=' . $user_id . '&lp_id=' . intval($row['mylpid']) . '&origin=' . Security::remove_XSS($origin);
+ $my_url_suffix = '&course=' . $courseCode . '&student_id=' . $user_id . '&lp_id=' . intval($row['mylpid']) . '&origin=' . $origin;
$sql = 'SELECT * FROM ' . $tbl_stats_exercices . '
WHERE
exe_exo_id="' . $row['path'] . '" AND
@@ -606,11 +602,15 @@ class Tracking
$num = Database :: num_rows($resultLastAttempt);
if ($num > 0) {
if ($extendedAttempt == 1 && ($lp_id == $my_lp_id) && $lp_item_id == $my_id) {
- $correct_test_link = '
-
';
+ $correct_test_link = Display::url(
+ Display::return_icon('view_less_stats.gif', get_lang('HideAllAttempts')),
+ api_get_self() . '?action=stats' . $my_url_suffix . '&session_id=' . api_get_session_id() . '&lp_item_id=' . $my_id
+ );
} else {
- $correct_test_link = '
-
';
+ $correct_test_link = Display::url(
+ Display::return_icon('view_more_stats.gif', get_lang('ShowAllAttemptsByExercise')),
+ api_get_self() . '?action=stats&extend_attempt=1' . $my_url_suffix . '&session_id=' . api_get_session_id() . '&lp_item_id=' . $my_id
+ );
}
} else {
$correct_test_link = '-';
@@ -688,7 +688,6 @@ class Tracking
$counter++;
if ($extend_this_attempt OR $extend_all) {
$list1 = learnpath :: get_iv_interactions_array($row['iv_id']);
-
foreach ($list1 as $id => $interaction) {
if (($counter % 2) == 0) {
$oddclass = 'row_odd';
@@ -735,9 +734,7 @@ class Tracking
// Attempts listing by exercise.
if ($lp_id == $my_lp_id && $lp_item_id== $my_id && $extendedAttempt) {
-
// Get attempts of a exercise.
- $num_attempts = 0;
if (!empty($lp_id) && !empty($lp_item_id) && $row['item_type'] === 'quiz') {
$sql = "SELECT path FROM $TBL_LP_ITEM
WHERE
@@ -845,7 +842,7 @@ class Tracking
if (!empty($a_my_id)) {
if ($extendedAttempt) {
// "Right green cross" extended
- $total_score = Tracking::get_avg_student_score(
+ $total_score = self::get_avg_student_score(
$user_id,
$course_id,
$a_my_id,
@@ -855,7 +852,7 @@ class Tracking
);
} else {
// "Left green cross" extended
- $total_score = Tracking::get_avg_student_score(
+ $total_score = self::get_avg_student_score(
$user_id,
$course_id,
$a_my_id,
@@ -866,7 +863,7 @@ class Tracking
}
} else {
// Extend all "left green cross"
- $total_score = Tracking::get_avg_student_score(
+ $total_score = self::get_avg_student_score(
$user_id,
$course_id,
array($lp_id),
@@ -876,7 +873,7 @@ class Tracking
);
}
- $total_time = learnpathItem :: getScormTimeFromParameter('js', $total_time);
+ $total_time = learnpathItem::getScormTimeFromParameter('js', $total_time);
$total_time = str_replace('NaN', '00' . $h . '00\'00"', $total_time);
if (!$is_allowed_to_edit && $result_disabled_ext_all) {
@@ -889,6 +886,8 @@ class Tracking
}
}
+ //$progress = self::get_avg_student_progress()
+ $progress = null;
if (($counter % 2) == 0) {
$oddclass = 'row_odd';
} else {
@@ -900,7 +899,7 @@ class Tracking