Fix get_scorm_time() static not static calls see #7342

1.9.x
Julio Montoya 11 years ago
parent 048d7a3ee5
commit 03c75e8a3f
  1. 2
      main/newscorm/learnpath.class.php
  2. 49
      main/newscorm/learnpathItem.class.php
  3. 8
      main/newscorm/lp_stats.php
  4. 2
      main/tracking/courseLogCSV.php
  5. 2
      main/tracking/userLog.php

@ -1802,7 +1802,7 @@ class learnpath
$info .= "top.set_max(" . learnpathItem :: get_max() . ");\n";
$info .= "top.set_min(" . learnpathItem :: get_min() . ");\n";
$info .= "top.set_lesson_status('" . learnpathItem :: get_status() . "');";
$info .= "top.set_session_time('" . learnpathItem :: get_scorm_time('js') . "');";
$info .= "top.set_session_time('" . learnpathItem :: getScormTimeFromParameter('js') . "');";
$info .= "top.set_suspend_data('" . learnpathItem :: get_suspend_data() . "');";
$info .= "top.set_saved_lesson_status('" . learnpathItem :: get_status() . "');";
$info .= "top.set_flag_synchronized();";

@ -1770,6 +1770,24 @@ class learnpathItem
}
}
/**
* @param string $origin
* @return string
*/
public static function getScormTimeFromParameter($origin = 'php', $time = null)
{
$h = get_lang('h');
if (!isset($time)) {
if ($origin == 'js') {
return '00:00:00';
} else {
return '00' . $h . '00\'00"';
}
} else {
return self::calculateScormTime($origin, $time);
}
}
/**
* Gets the total time spent on this item view so far
* @param string $origin Origin of the request. If coming from PHP,
@ -1783,7 +1801,6 @@ class learnpathItem
$given_time = null,
$query_db = false
) {
$h = get_lang('h');
$time = null;
$course_id = api_get_course_int_id();
if (!isset($given_time)) {
@ -1793,7 +1810,6 @@ class learnpathItem
0
);
}
if (is_object($this)) {
if ($query_db === true) {
$table = Database::get_course_table(TABLE_LP_ITEM_VIEW);
$sql = "SELECT start_time, total_time FROM $table
@ -1816,13 +1832,6 @@ class learnpathItem
$time = time() - $start;
}
}
} else {
if ($origin == 'js') {
return '00:00:00';
} else {
return '00' . $h . '00\'00"';
}
}
} else {
$time = $given_time;
}
@ -1832,21 +1841,35 @@ class learnpathItem
0
);
}
$time = self::calculateScormTime($origin, $time);
return $time;
}
/**
* @param string $origin
* @param string $time
* @return string
*/
public static function calculateScormTime($origin, $time)
{
$h = get_lang('h');
$hours = $time / 3600;
$mins = ($time % 3600) / 60;
$secs = ($time % 60);
if ($origin == 'js') {
$scorm_time = trim(sprintf("%4d:%02d:%02d", $hours, $mins, $secs));
$scormTime = trim(sprintf("%4d:%02d:%02d", $hours, $mins, $secs));
} else {
$scorm_time = trim(
$scormTime = trim(
sprintf("%4d$h%02d'%02d\"", $hours, $mins, $secs)
);
}
if (self::debug > 2) {
error_log('learnpathItem::get_scorm_time(' . $scorm_time . ')', 0);
error_log('learnpathItem::get_scorm_time(' . $scormTime . ')', 0);
}
return $scorm_time;
return $scormTime;
}
/**

@ -335,7 +335,7 @@ if (is_array($list) && count($list) > 0) {
$lesson_status = $row['mystatus'];
$score = $row['myscore'];
$time_for_total = $row['mytime'];
$time = learnpathItem :: get_scorm_time('js', $row['mytime']);
$time = learnpathItem :: getScormTimeFromParameter('js', $row['mytime']);
$scoIdentifier = $row['myid'];
if ($score == 0) {
@ -627,7 +627,7 @@ if (is_array($list) && count($list) > 0) {
}
$time_for_total = $subtotal_time;
$time = learnpathItem :: get_scorm_time('js', $subtotal_time);
$time = learnpathItem :: getScormTimeFromParameter('js', $subtotal_time);
if (empty($title)) {
$title = rl_get_resource_name(api_get_course_id(), $lp_id, $row['myid']);
}
@ -818,7 +818,7 @@ if (is_array($list) && count($list) > 0) {
$mktime_exe_date = api_strtotime($row_attempts['exe_date'], 'UTC');
if ($mktime_start_date && $mktime_exe_date) {
$mytime = ((int) $mktime_exe_date - (int) $mktime_start_date);
$time_attemp = learnpathItem :: get_scorm_time('js', $mytime);
$time_attemp = learnpathItem :: getScormTimeFromParameter('js', $mytime);
$time_attemp = str_replace('NaN', '00' . $h . '00\'00"', $time_attemp);
} else {
$time_attemp = ' - ';
@ -945,7 +945,7 @@ if (!empty($a_my_id)) {
}
}
$total_time = learnpathItem :: get_scorm_time('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) {

@ -380,7 +380,7 @@ if ($is_allowedToTrack) {
$title_line .= get_lang('ScormTitleColumn') . ";" . get_lang('ScormStatusColumn') . ";" . get_lang('ScormScoreColumn') . ";" . get_lang('ScormTimeColumn');
while ($ar3['status'] != '') {
require_once '../newscorm/learnpathItem.class.php';
$time = learnpathItem::get_scorm_time('php', $ar3['total_time']);
$time = learnpathItem::getScormTimeFromParameter('php', $ar3['total_time']);
$line .= $title . ";" . $ar3['status'] . ";" . $ar3['score'] . ";" . $time;
$ar3 = Database::fetch_array($result3);
}

@ -332,7 +332,7 @@ if( ( $is_allowedToTrack || $is_allowedToTrackEverybodyInCourse )) {
</tr>";
while ($ar3['status'] != '') {
require_once '../newscorm/learnpathItem.class.php';
$time = learnpathItem::get_scorm_time('php',$ar3['total_time']);
$time = learnpathItem::getScormTimeFromParameter('php', $ar3['total_time']);
echo "<tr><td>&nbsp;&nbsp;&nbsp;</td><td>";
echo "$title</td><td align=right>{$ar3['status']}</td><td align=right>{$ar3['score']}</td><td align=right>$time</td>";
echo "</tr>";

Loading…
Cancel
Save