Update LP view using lp min time BT#15020

pull/2757/head
Julio Montoya 7 years ago
parent cebc8e01e6
commit 85e1093d6c
  1. 157
      main/lp/learnpath.class.php
  2. 92
      main/lp/lp_ajax_switch_item.php
  3. 22
      main/lp/lp_controller.php
  4. 17
      main/lp/lp_edit.php
  5. 134
      main/lp/lp_list.php
  6. 108
      main/lp/lp_view.php
  7. 93
      main/lp/scorm_api.php
  8. 19
      main/template/default/learnpath/list.tpl
  9. 89
      main/template/default/learnpath/view.tpl

@ -2407,54 +2407,54 @@ class learnpath
$isBlocked = true;
}
// ## NSR - bloquear si no supera tiempo minimo
// TL --- Tiempo minimo para superar la lección ( en minutos )
$accumulateWorkTime = self::getAccumulateWorkTimePrerequisite($prerequisite, $courseInfo['real_id']);
if ($accumulateWorkTime > 0) {
// TT --- Tiempo total del curso
$accumulateWorkTimeTotal = self::getAccumulateWorkTimeTotal($courseInfo['real_id']);
// P y TC --- Conectamos con la tabla plugin_licences_course_session en la que se indica que porcentaje del tiempo se aplica
$perc = 100;
$tc = $accumulateWorkTimeTotal;
if (!empty($sessionId) && $sessionId != 0) {
$sql = "SELECT hours, perc FROM plugin_licences_course_session WHERE session_id = $sessionId";
$res = Database::query($sql);
if (Database::num_rows($res) > 0) {
$aux = Database::fetch_assoc($res);
$perc = $aux['perc'];
$tc = $aux['hours'] * 60;
if (api_get_configuration_value('lp_minimum_time')) {
// ## NSR - bloquear si no supera tiempo minimo
// TL --- Tiempo minimo para superar la lección ( en minutos )
$accumulateWorkTime = self::getAccumulateWorkTimePrerequisite($prerequisite, $courseInfo['real_id']);
if ($accumulateWorkTime > 0) {
// TT --- Tiempo total del curso
$accumulateWorkTimeTotal = self::getAccumulateWorkTimeTotal($courseInfo['real_id']);
// P y TC --- Conectamos con la tabla plugin_licences_course_session en la que se indica que porcentaje del tiempo se aplica
$perc = 100;
$tc = $accumulateWorkTimeTotal;
if (!empty($sessionId) && $sessionId != 0) {
/*$sql = "SELECT hours, perc FROM plugin_licences_course_session WHERE session_id = $sessionId";
$res = Database::query($sql);
if (Database::num_rows($res) > 0) {
$aux = Database::fetch_assoc($res);
$perc = $aux['perc'];
$tc = $aux['hours'] * 60;
}*/
}
}
// PL --- Porcentaje lección (tiempo leccion / tiempo total curso)
$pl = $accumulateWorkTime / $accumulateWorkTimeTotal;
/*
* TL: Tiempo que pone en una lección
* TT : tiempo total que pone Teresa (suma tiempos lecciones curso)
* PL: Fracción que supone una lección sobre el tiempo total = TL/TT
* TC: Tiempo que dice el cliente que tiene el curso
* P: porcentaje mínimo conexión que indica el cliente
*
* el tiempo mínimo de cada lección sería: PL x TC x P /100
*/
$accumulateWorkTime = ($pl * $tc * $perc / 100);
// Tiempo empleado hasta el momento en la leccion ( en segundos )
$lpTime = Tracking::get_time_spent_in_lp(
$studentId,
$courseInfo['code'],
array($prerequisite),
$sessionId
);
// PL --- Porcentaje lección (tiempo leccion / tiempo total curso)
$pl = $accumulateWorkTime / $accumulateWorkTimeTotal;
/*
* TL: Tiempo que pone en una lección
* TT : tiempo total que pone Teresa (suma tiempos lecciones curso)
* PL: Fracción que supone una lección sobre el tiempo total = TL/TT
* TC: Tiempo que dice el cliente que tiene el curso
* P: porcentaje mínimo conexión que indica el cliente
*
* el tiempo mínimo de cada lección sería: PL x TC x P /100
*/
$accumulateWorkTime = ($pl * $tc * $perc / 100);
// Tiempo empleado hasta el momento en la leccion ( en segundos )
$lpTime = Tracking::get_time_spent_in_lp(
$studentId,
$courseInfo['code'],
array($prerequisite),
$sessionId
);
if ($lpTime < ($accumulateWorkTime * 60)) {
$isBlocked = true;
if ($lpTime < ($accumulateWorkTime * 60)) {
$isBlocked = true;
}
}
}
}
return $isBlocked;
@ -14006,56 +14006,75 @@ EOD;
*/
public function getAccumulateWorkTimeTotalCourse()
{
$lp_table = Database::get_course_table(TABLE_LP_MAIN);
$lp_id = $this->get_id();
$sql = "SELECT SUM(accumulate_work_time) AS tt FROM $lp_table WHERE c_id = ".$this->course_int_id;
$table = Database::get_course_table(TABLE_LP_MAIN);
$sql = "SELECT SUM(accumulate_work_time) AS total
FROM $table
WHERE c_id = ".$this->course_int_id;
$result = Database::query($sql);
$myrow = Database::fetch_array($result);
return $myrow['tt'];
$row = Database::fetch_array($result);
return (int) $row['total'];
}
/**
* Set whether this is a learning path with the accumulated work time or not
*
* @param int $value (0 = false, 1 = true)
* @return bool Always returns true
*
* @return bool
*/
public function setAccumulateWorkTime($value)
{
if ($this->debug > 0) {
error_log('New LP - In learnpath::setAccumulateScormTime()', 0);
if (!api_get_configuration_value('lp_minimum_time')) {
return false;
}
$this->accumulateWorkTime = intval($value);
$lp_table = Database::get_course_table(TABLE_LP_MAIN);
$this->accumulateWorkTime = (int) $value;
$table = Database::get_course_table(TABLE_LP_MAIN);
$lp_id = $this->get_id();
$sql = "UPDATE $lp_table SET accumulate_work_time = ".$this->accumulateWorkTime."
$sql = "UPDATE $table SET accumulate_work_time = ".$this->accumulateWorkTime."
WHERE c_id = ".$this->course_int_id." AND id = $lp_id";
Database::query($sql);
return true;
}
public function getAccumulateWorkTimePrerequisite($lp_id, $c_id)
/**
* @param int $lpId
* @param int $courseId
*
* @return mixed
*/
public static function getAccumulateWorkTimePrerequisite($lpId, $courseId)
{
$lp_id = intval($lp_id);
$lp_table = Database::get_course_table(TABLE_LP_MAIN);
$sql = "SELECT accumulate_work_time
FROM $lp_table
WHERE c_id = ".$c_id." AND id = $lp_id";
$lpId = (int) $lpId;
$courseId = (int) $courseId;
$table = Database::get_course_table(TABLE_LP_MAIN);
$sql = "SELECT accumulate_work_time
FROM $table
WHERE c_id = $courseId AND id = $lpId";
$result = Database::query($sql);
$myrow = Database::fetch_array($result);
$row = Database::fetch_array($result);
return $myrow['accumulate_work_time'];
return $row['accumulate_work_time'];
}
public function getAccumulateWorkTimeTotal($c_id)
/**
* @param int $courseId
*
* @return int
*/
public static function getAccumulateWorkTimeTotal($courseId)
{
$lp_table = Database::get_course_table(TABLE_LP_MAIN);
$sql = "SELECT SUM(accumulate_work_time) AS tt
FROM $lp_table
WHERE c_id = ".$c_id;
$table = Database::get_course_table(TABLE_LP_MAIN);
$courseId = (int) $courseId;
$sql = "SELECT SUM(accumulate_work_time) AS total
FROM $table
WHERE c_id = $courseId";
$result = Database::query($sql);
$myrow = Database::fetch_array($result);
$row = Database::fetch_array($result);
return $myrow['tt'];
return (int) $row['total'];
}
}

@ -220,58 +220,64 @@ function switch_item_details($lp_id, $user_id, $view_id, $current_item, $next_it
$timeLp = $mylp->getAccumulateWorkTime();
$timeTotalCourse = $mylp->getAccumulateWorkTimeTotalCourse();
$perc = 100;
$tc = $timeTotalCourse;
$sessionId = api_get_session_id();
if (!empty($sessionId) && $sessionId != 0) {
/*$sql = "SELECT hours, perc FROM plugin_licences_course_session WHERE session_id = $sessionId";
$res = Database::query($sql);
if (Database::num_rows($res) > 0) {
$aux = Database::fetch_assoc($res);
$perc = $aux['perc'];
$tc = $aux['hours'] * 60;
}*/
}
$updateMinTime = '';
if (api_get_configuration_value('lp_minimum_time')) {
$perc = 100;
$tc = $timeTotalCourse;
$sessionId = api_get_session_id();
if (!empty($sessionId) && $sessionId != 0) {
/*$sql = "SELECT hours, perc FROM plugin_licences_course_session WHERE session_id = $sessionId";
$res = Database::query($sql);
if (Database::num_rows($res) > 0) {
$aux = Database::fetch_assoc($res);
$perc = $aux['perc'];
$tc = $aux['hours'] * 60;
}*/
}
// PL --- Porcentaje lección (tiempo leccion / tiempo total curso)
$pl = $timeLp / $timeTotalCourse;
// PL --- Porcentaje lección (tiempo leccion / tiempo total curso)
$pl = $timeLp / $timeTotalCourse;
/*
* TL: Tiempo que pone en una lección
* TT : tiempo total que pone Teresa (suma tiempos lecciones curso)
* PL: Fracción que supone una lección sobre el tiempo total = TL/TT
* TC: Tiempo que dice el cliente que tiene el curso
* P: porcentaje mínimo conexión que indica el cliente
*
* el tiempo mínimo de cada lección sería: PL x TC x P /100
*/
// Aplicamos el porcentaje si no hubiese definido un porcentaje por defecto es 100%
$time_total = intval($pl * $tc * $perc / 100) * 60;
/*
* TL: Tiempo que pone en una lección
* TT : tiempo total que pone Teresa (suma tiempos lecciones curso)
* PL: Fracción que supone una lección sobre el tiempo total = TL/TT
* TC: Tiempo que dice el cliente que tiene el curso
* P: porcentaje mínimo conexión que indica el cliente
*
* el tiempo mínimo de cada lección sería: PL x TC x P /100
*/
// Aplicamos el porcentaje si no hubiese definido un porcentaje por defecto es 100%
$time_total = intval($pl * $tc * $perc / 100) * 60;
//$time_total = $mylp->getAccumulateWorkTime() * 60;
$lpTime = Tracking::get_time_spent_in_lp(
$user_id,
api_get_course_id(),
array($lp_id),
api_get_session_id()
);
//$time_total = $mylp->getAccumulateWorkTime() * 60;
$lpTime = Tracking::get_time_spent_in_lp(
$user_id,
api_get_course_id(),
array($lp_id),
api_get_session_id()
);
if ($lpTime >= $time_total) {
$time_spent = $time_total;
} else {
$time_spent = $lpTime;
}
if ($lpTime >= $time_total) {
$time_spent = $time_total;
} else {
$time_spent = $lpTime;
$hour = (intval($lpTime / 3600)) < 10 ? '0'.intval($lpTime / 3600) : intval($lpTime / 3600);
$minute = date('i', $lpTime);
$second = date('s', $lpTime);
$updateMinTime = "update_time_bar('$time_spent','$time_total','%');".
"update_cronometro('$hour','$minute','$second');";
}
$hour = (intval($lpTime/3600)) < 10 ? '0'.intval($lpTime/3600) : intval($lpTime/3600);
$minute = date("i", $lpTime);
$second = date("s", $lpTime);
$return .= "update_toc('unhighlight','".$current_item."');".
$return .=
"update_toc('unhighlight','".$current_item."');".
"update_toc('highlight','".$new_item_id."');".
"update_toc('$mylesson_status','".$new_item_id."');".
"update_progress_bar('$mycomplete','$mytotal','$myprogress_mode');".
"update_time_bar('$time_spent','$time_total','%');".
"update_cronometro('$hour','$minute','$second');";
$updateMinTime
;
$return .= 'updateGamificationValues(); ';

@ -369,6 +369,26 @@ if ($debug) {
error_log('Entered lp_controller.php -+- (action: '.$action.')');
}
// ## NSR - log
$lp_id = (!empty($_REQUEST['lp_id']) ? (int) $_REQUEST['lp_id'] : 0);
switch ($action) {
case 'view':
case 'content':
$lp_detail_id = $_SESSION['oLP']->get_current_item_id();
break;
default:
$lp_detail_id = (!empty($_REQUEST['id']) ? (int) $_REQUEST['id'] : 0);
}
$logInfo = [
'tool' => TOOL_LEARNPATH,
'tool_id' => $lp_id,
'tool_id_detail' => $lp_detail_id,
'action' => !empty($action) ? $action : 'list',
'info' => '',
];
Event::registerLog($logInfo);
// format title to be displayed correctly if QUIZ
$post_title = '';
if (isset($_POST['title'])) {
@ -1030,7 +1050,7 @@ switch ($action) {
}
$_SESSION['oLP']->set_hide_toc_frame($hide_toc_frame);
$_SESSION['oLP']->set_prerequisite(isset($_POST['prerequisites']) ? (int) $_POST['prerequisites'] : 0);
$_SESSION['oLP']->setAccumulateWorkTime($_REQUEST['accumulate_work_time']);
$_SESSION['oLP']->setAccumulateWorkTime(isset($_REQUEST['accumulate_work_time']) ? $_REQUEST['accumulate_work_time'] : 0);
$_SESSION['oLP']->set_use_max_score(isset($_POST['use_max_score']) ? 1 : 0);
$subscribeUsers = isset($_REQUEST['subscribe_users']) ? 1 : 0;

@ -156,18 +156,17 @@ $form->addElement('html', '<div class="col-md-8">');
$form->addElement('html', $items);
$form->addElement('html', '<div class="help-block">'.get_lang('LpPrerequisiteDescription').'</div>');
$form->addElement('html', '</div>');
$form->addElement('html', '<div class="col-md-2"></div>');
$form->addElement('html', '</div>');
// Time Control
$accumulateTime = $_SESSION['oLP']->getAccumulateWorkTime();
$items = '<input size="10" class="form-control" name="accumulate_work_time" type="text" value="'.$accumulateTime.'">';
$form->addElement('html', '<div class="form-group">');
$form->addElement('html', '<label class="col-md-2 control-label" style="margin-top:-10px">'.get_lang('LearnpathTimeIn').'</label>');
$form->addElement('html', '<div class="col-md-2">');
$form->addElement('html', $items);
$form->addElement('html', '</div><div class="col-md-8">');
$form->addElement('html', '<div class="help-block">'.get_lang('LpAccumulateTimeDescription').'</div></div></div>');
if (api_get_configuration_value('lp_minimum_time')) {
$accumulateTime = $_SESSION['oLP']->getAccumulateWorkTime();
$form->addText('accumulate_work_time', [get_lang('LearnpathTimeIn'), get_lang('LpAccumulateTimeDescription')]);
$defaults['accumulate_work_time'] = $accumulateTime;
}
//Start date
// Start date
$form->addElement(
'checkbox',
'activate_start_date_check',

@ -397,75 +397,78 @@ foreach ($categories as $item) {
$ending = false;
}
$dsp_time = '';
$linkMinTime = '';
if (api_get_configuration_value('lp_minimum_time')) {
// ## NSR
// Time info
// TL --- Tiempo minimo para superar la lección ( en minutos )
$accumulateWorkTime = learnpath::getAccumulateWorkTimePrerequisite($id, api_get_course_int_id());
if ($accumulateWorkTime > 0) {
// TT --- Tiempo total del curso
$accumulateWorkTimeTotal = learnpath::getAccumulateWorkTimeTotal(api_get_course_int_id());
// Tiempo empleado hasta el momento en la leccion ( en segundos )
$lpTime = Tracking::get_time_spent_in_lp(
$userId,
api_get_course_id(),
array($id),
api_get_session_id()
);
// ## NSR
// Time info
// TL --- Tiempo minimo para superar la lección ( en minutos )
$accumulateWorkTime = learnpath::getAccumulateWorkTimePrerequisite($id, api_get_course_int_id());
if ($accumulateWorkTime > 0) {
// TT --- Tiempo total del curso
$accumulateWorkTimeTotal = learnpath::getAccumulateWorkTimeTotal(api_get_course_int_id());
// Tiempo empleado hasta el momento en la leccion ( en segundos )
$lpTime = Tracking::get_time_spent_in_lp(
$userId,
api_get_course_id(),
array($id),
api_get_session_id()
);
// Conectamos con la tabla plugin_licences_course_session en la que se indica que porcentaje del tiempo se aplica
$perc = 100;
$tc = $accumulateWorkTimeTotal;
/*if (!empty($current_session) && $current_session != 0) {
$sql = "SELECT hours, perc FROM plugin_licences_course_session WHERE session_id = $current_session";
$res = Database::query($sql);
if (Database::num_rows($res) > 0) {
$aux = Database::fetch_assoc($res);
$perc = $aux['perc'];
$tc = ($aux['hours'] * 60);
// Conectamos con la tabla plugin_licences_course_session en la que se indica que porcentaje del tiempo se aplica
$perc = 100;
$tc = $accumulateWorkTimeTotal;
/*if (!empty($current_session) && $current_session != 0) {
$sql = "SELECT hours, perc FROM plugin_licences_course_session WHERE session_id = $current_session";
$res = Database::query($sql);
if (Database::num_rows($res) > 0) {
$aux = Database::fetch_assoc($res);
$perc = $aux['perc'];
$tc = ($aux['hours'] * 60);
}
}*/
// PL --- Porcentaje lección (tiempo leccion / tiempo total curso)
$pl = $accumulateWorkTime / $accumulateWorkTimeTotal;
/*
* TL: Tiempo que pone en una lección
* TT : tiempo total que pone Teresa (suma tiempos lecciones curso)
* PL: Fracción que supone una lección sobre el tiempo total = TL/TT
* TC: Tiempo que dice el cliente que tiene el curso
* P: porcentaje mínimo conexión que indica el cliente
*
* el tiempo mínimo de cada lección sería: PL x TC x P /100
*/
// Aplicamos el porcentaje si no hubiese definido un porcentaje por defecto es 100%
$accumulateWorkTime = ($pl * $tc * $perc / 100);
// Si el tiempo empleado es menor que lo necesario mostramos un icono en la columna de acción indicando la advertencia
if ($lpTime < ($accumulateWorkTime * 60)) {
$linkMinTime = Display::return_icon(
'warning.png',
get_lang('LpMessageTimeMin').' - '.api_time_to_hms($lpTime).' / '.api_time_to_hms(
$accumulateWorkTime * 60
)
).'<b>'.api_time_to_hms($lpTime).' / '.api_time_to_hms($accumulateWorkTime * 60).'</b>';
}
}*/
// PL --- Porcentaje lección (tiempo leccion / tiempo total curso)
$pl = $accumulateWorkTime / $accumulateWorkTimeTotal;
/*
* TL: Tiempo que pone en una lección
* TT : tiempo total que pone Teresa (suma tiempos lecciones curso)
* PL: Fracción que supone una lección sobre el tiempo total = TL/TT
* TC: Tiempo que dice el cliente que tiene el curso
* P: porcentaje mínimo conexión que indica el cliente
*
* el tiempo mínimo de cada lección sería: PL x TC x P /100
*/
// Aplicamos el porcentaje si no hubiese definido un porcentaje por defecto es 100%
$accumulateWorkTime = ($pl * $tc * $perc / 100);
// Si el tiempo empleado es menor que lo necesario mostramos un icono en la columna de acción indicando la advertencia
$dsp_accumulateWorkTime = '';
if ($lpTime < ($accumulateWorkTime*60)) {
$dsp_accumulateWorkTime = Display::return_icon('warning.png', get_lang('LpMessageTimeMin').' - '.api_time_to_hms($lpTime).' / '.api_time_to_hms($accumulateWorkTime*60)).'<b>'.api_time_to_hms($lpTime).' / '.api_time_to_hms($accumulateWorkTime*60).'</b>';
}
// Calculamos el porcentaje superado del tiempo para la barra de "superacion de tiempo mínimo"
if ($lpTime >= ($accumulateWorkTime*60)) {
$time_progress_perc = '100%';
$time_progress_value = 100;
} else {
$time_progress_value = intval(($lpTime * 100) / ($accumulateWorkTime*60));
}
// Calculamos el porcentaje superado del tiempo para la barra de "superacion de tiempo mínimo"
if ($lpTime >= ($accumulateWorkTime * 60)) {
$time_progress_perc = '100%';
$time_progress_value = 100;
} else {
$time_progress_value = intval(($lpTime * 100) / ($accumulateWorkTime * 60));
}
// ## NSR
if ($time_progress_value < 100) {
$ending = false;
// ## NSR
if ($time_progress_value < 100) {
$ending = false;
}
$dsp_time = learnpath::get_progress_bar($time_progress_value, '%');
}
$dsp_time = learnpath::get_progress_bar($time_progress_value, '%');
} else {
$dsp_time = '';
$dsp_accumulateWorkTime = '';
}
$token_parameter = "&sec_token=$token";
@ -969,7 +972,7 @@ foreach ($categories as $item) {
'action_subscribe_users' => $subscribeUsers,
'action_update_scorm' => $actionUpdateScormFile,
'action_export_to_course_build' => $actionExportToCourseBuild,
'info_time_prerequisite' => $dsp_accumulateWorkTime,
'info_time_prerequisite' => $linkMinTime,
];
$lpIsShown = true;
@ -1010,6 +1013,7 @@ $template = new Template($nameTools);
$template->assign('subscription_settings', $subscriptionSettings);
$template->assign('is_allowed_to_edit', $is_allowed_to_edit);
$template->assign('is_invitee', api_is_invitee());
$template->assign('is_ending', $ending);
$template->assign('actions', $actions);
$template->assign('categories', $categories);
$template->assign('message', $message);

@ -560,65 +560,69 @@ if ($gamificationMode == 1) {
}
$template->assign('lp_author', $lp->get_author());
/* ## NSR - calculo de tiempo minimo y acumulado */
$timeLp = $_SESSION['oLP']->getAccumulateWorkTime();
$timeTotalCourse = $_SESSION['oLP']->getAccumulateWorkTimeTotalCourse();
$perc = 100;
$tc = $timeTotalCourse;
if (!empty($sessionId) && $sessionId != 0) {
/*$sql = "SELECT hours, perc FROM plugin_licences_course_session WHERE session_id = $sessionId";
$res = Database::query($sql);
if (Database::num_rows($res) > 0) {
$aux = Database::fetch_assoc($res);
$perc = $aux['perc'];
$tc = $aux['hours'] * 60;
}*/
}
// PL --- Porcentaje lección (tiempo leccion / tiempo total curso)
$pl = $timeLp / $timeTotalCourse;
$lpMinTime = '';
if (api_get_configuration_value('lp_minimum_time')) {
/* ## NSR - calculo de tiempo minimo y acumulado */
$timeLp = $_SESSION['oLP']->getAccumulateWorkTime();
$timeTotalCourse = $_SESSION['oLP']->getAccumulateWorkTimeTotalCourse();
$perc = 100;
$tc = $timeTotalCourse;
if (!empty($sessionId) && $sessionId != 0) {
/*$sql = "SELECT hours, perc FROM plugin_licences_course_session WHERE session_id = $sessionId";
$res = Database::query($sql);
if (Database::num_rows($res) > 0) {
$aux = Database::fetch_assoc($res);
$perc = $aux['perc'];
$tc = $aux['hours'] * 60;
}*/
}
/*
* TL: Tiempo que pone en una lección
* TT : tiempo total que pone Teresa (suma tiempos lecciones curso)
* PL: Fracción que supone una lección sobre el tiempo total = TL/TT
* TC: Tiempo que dice el cliente que tiene el curso
* P: porcentaje mínimo conexión que indica el cliente
*
* el tiempo mínimo de cada lección sería: PL x TC x P /100
*/
// Aplicamos el porcentaje si no hubiese definido un porcentaje por defecto es 100%
$time_min = intval($pl * $tc * $perc / 100);
// PL --- Porcentaje lección (tiempo leccion / tiempo total curso)
$pl = $timeLp / $timeTotalCourse;
/*
* TL: Tiempo que pone en una lección
* TT : tiempo total que pone Teresa (suma tiempos lecciones curso)
* PL: Fracción que supone una lección sobre el tiempo total = TL/TT
* TC: Tiempo que dice el cliente que tiene el curso
* P: porcentaje mínimo conexión que indica el cliente
*
* el tiempo mínimo de cada lección sería: PL x TC x P /100
*/
// Aplicamos el porcentaje si no hubiese definido un porcentaje por defecto es 100%
$time_min = intval($pl * $tc * $perc / 100);
if ($_SESSION['oLP']->getAccumulateWorkTime() > 0) {
$lpMinTime = '('.$time_min.' min)';
}
if ($_SESSION['oLP']->getAccumulateWorkTime() > 0){
$template->assign('lp_accumulate_work_time', '('.$time_min.' min)');
}
$lpTime = Tracking::get_time_spent_in_lp(
$user_id,
$course_code,
array($_SESSION['oLP']->lp_id),
$sessionId
);
$lpTime = Tracking::get_time_spent_in_lp(
$user_id,
$course_code,
array($_SESSION['oLP']->lp_id),
$sessionId
);
if ($lpTime >= ($time_min * 60)) {
$time_progress_perc = '100%';
$time_progress_value = 100;
} else {
$time_progress_value = intval(($lpTime * 100) / ($time_min * 60));
$time_progress_perc = $time_progress_value.'%';
}
if ($lpTime >= ($time_min*60)) {
$time_progress_perc = '100%';
$time_progress_value = 100;
} else {
$time_progress_value = intval(($lpTime * 100) / ($time_min*60));
$time_progress_perc = $time_progress_value.'%';
$template->assign('time_progress_perc', $time_progress_perc);
$template->assign('time_progress_value', $time_progress_value);
// Cronometro
$hour = (intval($lpTime / 3600)) < 10 ? '0'.intval($lpTime / 3600) : intval($lpTime / 3600);
$template->assign('hour', $hour);
$template->assign('minute', date('i', $lpTime));
$template->assign('second', date('s', $lpTime));
/* ## NSR fin modificacion */
}
$template->assign('time_progress_perc', $time_progress_perc);
$template->assign('time_progress_value', $time_progress_value);
// Cronometro
$hour = (intval($lpTime/3600)) < 10 ? '0'.intval($lpTime/3600) : intval($lpTime/3600);
$template->assign('hour', $hour);
$template->assign('minute', date("i", $lpTime));
$template->assign('second', date("s", $lpTime));
/* ## NSR fin modificacion */
$template->assign('lp_accumulate_work_time', $lpMinTime);
$template->assign('lp_mode', $lp->mode);
$template->assign('lp_title_scorm', $lp->name);
if (api_get_configuration_value('lp_view_accordion') === true && $lpType == 1) {

@ -2382,3 +2382,96 @@ function attach_glossary_into_scorm(type) {
}
}
}
// ## NSR ##
/**
* Updates the time bar with the new status. Prevents the need of a page refresh and flickering
* @param integer Number of completed items
* @param integer Number of items in total
* @param string Display mode (absolute 'abs' or percentage '%').Defaults to %
*/
function update_time_bar(nbr_complete, nbr_total, mode)
{
logit_lms('update_progress_bar('+nbr_complete+', '+nbr_total+', '+mode+')',3);
logit_lms(
'update_progress_bar with params: lms_lp_id= ' + olms.lms_lp_id +
', lms_view_id= '+ olms.lms_view_id + ' lms_user_id= '+ olms.lms_user_id,
3
);
if (mode == '') {
mode='%';
}
if (nbr_total == 0) {
nbr_total=1;
}
var percentage = (nbr_complete/nbr_total)*100;
percentage = Math.round(percentage);
var progress_bar = $("#progress_bar_value2");
progress_bar.css('width', percentage + "%");
var mytext = '';
switch(mode){
case 'abs':
mytext = nbr_complete + '/' + nbr_total;
break;
case '%':
default:
mytext = percentage + '%';
break;
}
progress_bar.html(mytext);
return true;
}
/**
* Update cronometro
*/
function update_cronometro(text_hour, text_minute, text_second)
{
$("#hour").text(text_hour);
$("#minute").text(text_minute);
$("#second").text(text_second);
var tiempo = {
hora: parseInt($("#hour").text()),
minuto: parseInt($("#minute").text()),
segundo: parseInt($("#second").text())
};
/*
var tiempo = {
hora: text_hour,
minuto: text_minute,
segundo: text_second
};
*/
//window.tiempo_corriendo = null;
clearInterval(window.tiempo_corriendo);
window.tiempo_corriendo = setInterval(function(){
// Segundos
tiempo.segundo++;
if(tiempo.segundo >= 60) {
tiempo.segundo = 0;
tiempo.minuto++;
}
// Minutos
if(tiempo.minuto >= 60) {
tiempo.minuto = 0;
tiempo.hora++;
}
$("#hour").text(tiempo.hora < 10 ? '0' + tiempo.hora : tiempo.hora);
//$("#hour").text(tiempo.hora);
$("#minute").text(tiempo.minuto < 10 ? '0' + tiempo.minuto : tiempo.minuto);
//$("#minute").text(tiempo.minuto);
$("#second").text(tiempo.segundo < 10 ? '0' + tiempo.segundo : tiempo.segundo);
//$("#second").text(tiempo.segundo);
}, 1000);
return true;
}

@ -148,6 +148,10 @@
{% endif %}
{% endif %}
<td>
{% if not is_allowed_to_edit and row.info_time_prerequisite %}
{{ row.info_time_prerequisite }}
{% endif %}
{{ row.action_build }}
{{ row.action_edit }}
{{ row.action_visible }}
@ -485,6 +489,21 @@
{% endif %}
{% endfor %}
</div>
{% if not is_invitee %}
<div class="controls text-center">
{% if not is_ending %}
<a href="{{ web_self ~ "?" ~ _p.web_cid_query ~ "&action=send_notify_teacher" }}" class="btn btn-primary disabled">
He finalizado las lecciones, notificar al profesor
</a>
{% else %}
<a href="{{ web_self ~ "?" ~ _p.web_cid_query ~ "&action=send_notify_teacher" }}" class="btn btn-primary">
He finalizado las lecciones, notificar al profesor
</a>
{% endif %}
</div>
{% endif %}
{% if is_allowed_to_edit and not lp_is_shown %}
<div id="no-data-view">
<h2>{{ "LearningPaths"|get_lang }}</h2>

@ -26,6 +26,86 @@
{{ media_player }}
</div>
{% endif %}
{% if lp_accumulate_work_time != '' %}
{% set lp_progress %}
<style>
#timer .container{display:table;background:#777;color:#eee;font-weight:bold;width:100%;text-align:center;text-shadow:1px 1px 4px #999;}
#timer .container div{display:table-cell;font-size:24px;padding:0px;width:20px;}
#timer .container .divider{width:10px;color:#ddd;}
#btn-comenzar{box-sizing:border-box;background:#eee;border:none;margin:0 auto;padding:20px;width:100%;font-size:30px;color:#777;}
#btn-comenzar:hover{background:#fff;}
</style>
<script>
$(document).ready(function() {
var tiempo = {
hora: parseInt($("#hour").text()),
minuto: parseInt($("#minute").text()),
segundo: parseInt($("#second").text())
};
//window.tiempo_corriendo = null;
clearInterval(window.tiempo_corriendo);
window.tiempo_corriendo = setInterval(function(){
// Segundos
tiempo.segundo++;
if(tiempo.segundo >= 60) {
tiempo.segundo = 0;
tiempo.minuto++;
}
if (tiempo.segundo%10 == 0) {
//console.log({{lp_current_item_id}});
/*time_save({{lp_current_item_id}});*/
}
// Minutos
if(tiempo.minuto >= 60)
{
tiempo.minuto = 0;
tiempo.hora++;
}
$("#hour").text(tiempo.hora < 10 ? '0' + tiempo.hora : tiempo.hora);
//$("#hour").text(tiempo.hora);
$("#minute").text(tiempo.minuto < 10 ? '0' + tiempo.minuto : tiempo.minuto);
//$("#minute").text(tiempo.minuto);
$("#second").text(tiempo.segundo < 10 ? '0' + tiempo.segundo : tiempo.segundo);
//$("#second").text(tiempo.segundo);
}, 1000);
})
</script>
<b>Superación del tiempo mínimo {{ lp_accumulate_work_time }}</b>
<div id="progress_bar">
<div class="progress">
<div id="progress_bar_value2"
class="progress-bar progress-bar-success"
role="progressbar" aria-valuenow="50"
aria-valuemin="0"
aria-valuemax="{{ time_progress_value }}"
style="width: {{ time_progress_perc }};"
>
{{ time_progress_perc }}
</div>
</div>
</div>
<div id="timer">
<div class="container">
<div id="hour">{{ hour }}</div>
<div class="divider">:</div>
<div id="minute">{{ minute }}</div>
<div class="divider">:</div>
<div id="second">{{ second }}</div>
</div>
</div>
{% endset %}
{% else %}
{% set lp_progress %}
<div id="progress_bar">
{{ progress_bar }}
</div>
{% endset %}
{% endif %}
{% if gamification_mode == 1 %}
<!--- gamification -->
<div id="scorm-gamification">
@ -49,18 +129,15 @@
</div>
<div class="row">
<div class="col-xs-12 navegation-bar">
<div id="progress_bar">
{{ progress_bar }}
</div>
{{ lp_progress }}
</div>
</div>
</div>
<!--- end gamification -->
{% else %}
<div id="progress_bar">
{{ progress_bar }}
</div>
{{ lp_progress }}
{% endif %}
{{ teacher_toc_buttons }}
</div>
</div>

Loading…
Cancel
Save