Skip to content

Commit

Permalink
get_ and set_value handle cmi.score.scaled (#58)
Browse files Browse the repository at this point in the history
cmi.score.scaled in SCORM 2004 packages should be a
decimal between 0 and 1 reflecting a percentage score
(Actually cmi.score.scaled can have -1 to 1 but Open edX
shouldn't allow negative scores)

Fix Issue #55
  • Loading branch information
bryanlandia authored Jan 17, 2024
1 parent 15433c7 commit f28165d
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions openedxscorm/scormxblock.py
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,8 @@ def scorm_get_value(self, data, _suffix):
return {"value": self.success_status}
if name in ["cmi.core.score.raw", "cmi.score.raw"]:
return {"value": self.lesson_score * 100}
if name == "cmi.score.scaled":
return {"value": self.lesson_score}
if name in ["cmi.core.student_id", "cmi.learner_id"]:
return {"value": self.get_current_user_attr("edx-platform.user_id")}
if name in ["cmi.core.student_name", "cmi.learner_name"]:
Expand Down Expand Up @@ -457,6 +459,8 @@ def set_value(self, data):
completion_status = value
elif name in ["cmi.core.score.raw", "cmi.score.raw"] and self.has_score:
lesson_score = parse_validate_positive_float(value, name) / 100.0
elif name == "cmi.score.scaled" and self.has_score:
lesson_score = parse_validate_positive_float(value, name)
elif name == "cmi.progress_measure":
completion_percent = parse_validate_positive_float(value, name)

Expand Down

0 comments on commit f28165d

Please sign in to comment.