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. 229
      main/lp/learnpathItem.class.php

@ -2756,64 +2756,57 @@ class learnpathItem
// in case it's a SCORM, we should get: // in case it's a SCORM, we should get:
if ($this->type == 'sco' || $this->type == 'au') { if ($this->type == 'sco' || $this->type == 'au') {
$status = $this->get_status(true); $status = $this->get_status(true);
if ($this->prevent_reinit == 1 && if ($debug) {
$status != $this->possible_status[0] && // not attempted error_log(
$status != $this->possible_status[1] //incomplete 'learnpathItem::save() - SCORM save request received',
) { 0
if ($debug) { );
error_log( }
'learnpathItem::save() - save reinit blocked by setting', // Get all new settings from the URL
0 if ($from_outside) {
);
}
// 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) { if ($debug) {
error_log( error_log(
'learnpathItem::save() - SCORM save request received', 'learnpathItem::save() - Getting item data from outside',
0 0
); );
} }
// Get all new settings from the URL foreach ($_GET as $param => $value) {
if ($from_outside) { switch ($param) {
if ($debug) { case 'score':
error_log( $this->set_score($value);
'learnpathItem::save() - Getting item data from outside', if ($debug) {
0 error_log(
); 'learnpathItem::save() - setting score to '.$value,
} 0
foreach ($_GET as $param => $value) { );
switch ($param) { }
case 'score': break;
$this->set_score($value); case 'max':
if ($debug) { $this->set_max_score($value);
error_log( if ($debug) {
'learnpathItem::save() - setting score to '.$value, error_log(
0 'learnpathItem::save() - setting view_max_score to '.$value,
); 0
} );
break; }
case 'max': break;
$this->set_max_score($value); case 'min':
if ($debug) { $this->min_score = $value;
error_log( if ($debug) {
'learnpathItem::save() - setting view_max_score to '.$value, error_log(
0 'learnpathItem::save() - setting min_score to '.$value,
); 0
} );
break; }
case 'min': break;
$this->min_score = $value; case 'lesson_status':
if ($debug) { if (!empty($value)) {
error_log( if ($this->prevent_reinit == 1 &&
'learnpathItem::save() - setting min_score to '.$value, $status != $this->possible_status[0] && // not attempted
0 $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
break; } else {
case 'lesson_status':
if (!empty($value)) {
$this->set_status($value); $this->set_status($value);
if ($debug) { if ($debug) {
error_log( error_log(
@ -2822,61 +2815,60 @@ class learnpathItem
); );
} }
} }
break; }
case 'time': break;
$this->set_time($value); case 'time':
if ($debug) { $this->set_time($value);
error_log( if ($debug) {
'learnpathItem::save() - setting time to '.$value, error_log(
0 'learnpathItem::save() - setting time to '.$value,
); 0
} );
break; }
case 'suspend_data': break;
$this->current_data = $value; case 'suspend_data':
if ($debug) { $this->current_data = $value;
error_log( if ($debug) {
'learnpathItem::save() - setting suspend_data to '.$value, error_log(
0 'learnpathItem::save() - setting suspend_data to '.$value,
); 0
} );
break; }
case 'lesson_location': break;
$this->set_lesson_location($value); case 'lesson_location':
if ($debug) { $this->set_lesson_location($value);
error_log( if ($debug) {
'learnpathItem::save() - setting lesson_location to '.$value, error_log(
0 'learnpathItem::save() - setting lesson_location to '.$value,
); 0
} );
break; }
case 'core_exit': break;
$this->set_core_exit($value); case 'core_exit':
if ($debug) { $this->set_core_exit($value);
error_log( if ($debug) {
'learnpathItem::save() - setting core_exit to '.$value, error_log(
0 'learnpathItem::save() - setting core_exit to '.$value,
); 0
} );
break; }
case 'interactions': break;
break; case 'interactions':
case 'objectives': case 'objectives':
break; break;
default: default:
// Ignore. // Ignore.
break; break;
}
}
} else {
if ($debug) {
error_log(
'learnpathItem::save() - Using inside item status',
0
);
} }
// Do nothing, just let the local attributes be used.
} }
} else {
if ($debug) {
error_log(
'learnpathItem::save() - Using inside item status',
0
);
}
// Do nothing, just let the local attributes be used.
} }
} else { } else {
// If not SCO, such messages should not be expected. // If not SCO, such messages should not be expected.
@ -3702,26 +3694,14 @@ class learnpathItem
$rs_verified = Database::query($sql); $rs_verified = Database::query($sql);
$row_verified = Database::fetch_array($rs_verified); $row_verified = Database::fetch_array($rs_verified);
$my_case_completed = [
'completed',
'passed',
'browsed',
'failed',
];
$oldTotalTime = $row_verified['total_time']; $oldTotalTime = $row_verified['total_time'];
$this->oldTotalTime = $oldTotalTime; $this->oldTotalTime = $oldTotalTime;
$inserted = false;
$save = true; if (
if (isset($row_verified) && isset($row_verified['status'])) { $this->type === 'sco' &&
if (in_array($row_verified['status'], $my_case_completed)) { ($credit === 'no-credit' || $mode === 'review' || $mode === 'browse') &&
$save = false; $this->seriousgame_mode != 1
}
}
if ((($save === false && $this->type === 'sco') ||
($this->type === 'sco' && ($credit === 'no-credit' || $mode === 'review' || $mode === 'browse'))) &&
($this->seriousgame_mode != 1 && $this->type === 'sco')
) { ) {
if ($debug) { if ($debug) {
error_log( error_log(
@ -3735,7 +3715,6 @@ class learnpathItem
} }
} else { } else {
// Check the row exists. // Check the row exists.
$inserted = false;
// This a special case for multiple attempts and Chamilo exercises. // This a special case for multiple attempts and Chamilo exercises.
if ($this->type === 'quiz' && if ($this->type === 'quiz' &&
$this->get_prevent_reinit() == 0 && $this->get_prevent_reinit() == 0 &&
@ -3863,7 +3842,7 @@ class learnpathItem
error_log('get_type_static: '.$my_type_lp); 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 = [ $case_completed = [
'completed', 'completed',
'passed', 'passed',

Loading…
Cancel
Save