Learnpath: Remove validation on "completed" (or equivalent) lesson_status to update the SCO view details in SCORM learning paths - refs #4595

pull/4621/head
Yannick Warnier 3 years ago
parent e19e39d665
commit a5c5c36e8c
  1. 47
      main/lp/learnpathItem.class.php

@ -2756,19 +2756,6 @@ class learnpathItem
// in case it's a SCORM, we should get:
if ($this->type == 'sco' || $this->type == 'au') {
$status = $this->get_status(true);
if ($this->prevent_reinit == 1 &&
$status != $this->possible_status[0] && // not attempted
$status != $this->possible_status[1] //incomplete
) {
if ($debug) {
error_log(
'learnpathItem::save() - save reinit blocked by setting',
0
);
}
// Do nothing because the status has already been set. Don't allow it to change.
// TODO: Check there isn't a special circumstance where this should be saved.
} else {
if ($debug) {
error_log(
'learnpathItem::save() - SCORM save request received',
@ -2814,6 +2801,12 @@ class learnpathItem
break;
case 'lesson_status':
if (!empty($value)) {
if ($this->prevent_reinit == 1 &&
$status != $this->possible_status[0] && // not attempted
$status != $this->possible_status[1] // incomplete
) {
// do nothing: status was already completed or similar and we don't want to allow the SCO to reinitialize
} else {
$this->set_status($value);
if ($debug) {
error_log(
@ -2822,6 +2815,7 @@ class learnpathItem
);
}
}
}
break;
case 'time':
$this->set_time($value);
@ -2860,7 +2854,6 @@ class learnpathItem
}
break;
case 'interactions':
break;
case 'objectives':
break;
default:
@ -2877,7 +2870,6 @@ class learnpathItem
}
// Do nothing, just let the local attributes be used.
}
}
} else {
// If not SCO, such messages should not be expected.
$type = strtolower($this->type);
@ -3702,26 +3694,14 @@ class learnpathItem
$rs_verified = Database::query($sql);
$row_verified = Database::fetch_array($rs_verified);
$my_case_completed = [
'completed',
'passed',
'browsed',
'failed',
];
$oldTotalTime = $row_verified['total_time'];
$this->oldTotalTime = $oldTotalTime;
$inserted = false;
$save = true;
if (isset($row_verified) && isset($row_verified['status'])) {
if (in_array($row_verified['status'], $my_case_completed)) {
$save = false;
}
}
if ((($save === false && $this->type === 'sco') ||
($this->type === 'sco' && ($credit === 'no-credit' || $mode === 'review' || $mode === 'browse'))) &&
($this->seriousgame_mode != 1 && $this->type === 'sco')
if (
$this->type === 'sco' &&
($credit === 'no-credit' || $mode === 'review' || $mode === 'browse') &&
$this->seriousgame_mode != 1
) {
if ($debug) {
error_log(
@ -3735,7 +3715,6 @@ class learnpathItem
}
} else {
// Check the row exists.
$inserted = false;
// This a special case for multiple attempts and Chamilo exercises.
if ($this->type === 'quiz' &&
$this->get_prevent_reinit() == 0 &&
@ -3863,7 +3842,7 @@ class learnpathItem
error_log('get_type_static: '.$my_type_lp);
}
// This is a array containing values finished
// This is an array containing values equivalent to a finished state
$case_completed = [
'completed',
'passed',

Loading…
Cancel
Save