Lp: Fix update progress inside lp view - refs BT#19283

pull/4033/head
Christian 4 years ago
parent e7be21c9e0
commit 4bc6fc4cda
  1. 45
      main/lp/learnpath.class.php
  2. 3
      main/lp/learnpathItem.class.php

@ -4981,6 +4981,51 @@ class learnpath
return false;
}
/**
* Update the last progress only in case
*
*/
public function updateLpProgress()
{
$debug = $this->debug;
if ($debug) {
error_log('In learnpath::updateLpProgress()', 0);
}
$sessionCondition = api_get_session_condition(
api_get_session_id(),
true,
false
);
$courseId = api_get_course_int_id();
$userId = $this->get_user_id();
$table = Database::get_course_table(TABLE_LP_VIEW);
[$progress] = $this->get_progress_bar_text('%');
if ($progress >= 0 && $progress <= 100) {
// Check database.
$progress = (int) $progress;
$sql = "UPDATE $table SET
progress = $progress
WHERE
c_id = $courseId AND
lp_id = ".$this->get_id()." AND
user_id = ".$userId." ".$sessionCondition;
// Ignore errors as some tables might not have the progress field just yet.
Database::query($sql);
if ($debug) {
error_log($sql);
}
$this->progress_db = $progress;
if (100 == $progress) {
HookLearningPathEnd::create()
->setEventData(['lp_view_id' => $this->lp_view_id])
->hookLearningPathEnd();
}
}
}
/**
* Saves the last item seen's ID only in case.
*/

@ -4070,6 +4070,9 @@ class learnpathItem
}
}
// It updates the last progress only in case.
$_SESSION['oLP']->updateLpProgress();
if ($debug) {
error_log('End of learnpathItem::write_to_db()', 0);
}

Loading…
Cancel
Save