Skip to content
Snippets Groups Projects
Unverified Commit ea1bc143 authored by David Pesce's avatar David Pesce Committed by GitHub
Browse files

Fix: Fixes instance where scoremax or scoremin are not set in scorm_scoreraw_submitted

issue 161 : check if scoremax and scoremin are not 0
parents c774a6cd 7990adc5
No related branches found
No related tags found
No related merge requests found
...@@ -26,12 +26,24 @@ class ScormScoreRawSubmitted extends ScormEvent { ...@@ -26,12 +26,24 @@ class ScormScoreRawSubmitted extends ScormEvent {
* @override ModuleViewed * @override ModuleViewed
*/ */
public function read(array $opts) { public function read(array $opts) {
$scoremax = $opts['scorm_scoes_track']['scoremax']; $scoremax = null;
$scoreraw = $opts['cmi_data']['cmivalue']; $scoreraw = null;
$scoremin = $opts['scorm_scoes_track']['scoremin']; $scoremin = null;
$scorescaled = null; $scorescaled = null;
$scorescaled = $scoreraw >= 0 ? ($scoreraw / $scoremax) : ($scoreraw / $scoremin); if (isset($opts['scorm_scoes_track']['scoremax'])) {
$scoremax = $opts['scorm_scoes_track']['scoremax'];
}
if (isset($opts['cmi_data']['cmivalue'])) {
$scoremax = $opts['cmi_data']['cmivalue'];
}
if (isset($opts['scorm_scoes_track']['scoremin'])) {
$scoremin = $opts['scorm_scoes_track']['scoremin'];
}
if ($scoremax != 0 && $scoremin != 0) {
$scorescaled = $scoreraw >= 0 ? ($scoreraw / $scoremax) : ($scoreraw / $scoremin);
}
return [array_merge(parent::read($opts)[0], [ return [array_merge(parent::read($opts)[0], [
'recipe' => 'scorm_scoreraw_submitted', 'recipe' => 'scorm_scoreraw_submitted',
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment