Skip to content

Fix setScore() ignoring item scores when _hasItemScoring is enabled #848

@joe-replin

Description

@joe-replin

Subject of the issue/enhancement/features

When _hasItemScoring: true is set on an MCQ, setScore() always stores 0 or _questionWeight based on correctness, ignoring the selected item's _score value. A get score() getter exists that sums active item scores correctly, but setScore() was never updated to use it. Plugins that read model.get('_score') directly — including SCORM tracking and custom scoring extensions — receive the wrong value.

Your environment

  • adapt-contrib-core v6.73.0
  • All modern browsers
  • All operating systems

Steps to reproduce

  1. Create an MCQ with _hasItemScoring: true and _selectable: 1
  2. Give items fractional _score values, e.g. 0, 0.25, 0.75, 1.0
  3. Mark one item _shouldBeSelected: true
  4. Submit the question by selecting a different item — one with _shouldBeSelected: false and _score: 0.25
  5. After submission, run in the browser console:
    Adapt.components.findWhere({ _id: 'your-component-id' }).get('_score')

Expected behaviour

model.get('_score') returns 0.25 — the selected item's _score value.

Actual behaviour

model.get('_score') returns 0. setScore() treats the question as incorrect and stores 0, regardless of the selected item's _score.

Suggested Fix (if known)

Replace setScore() in ItemsQuestionModel with:

setScore() {
  this.set('_score', this.score);
}

The existing get score() getter already handles _hasItemScoring correctly. setScore() should sync the stored attribute to it rather than recalculate independently.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    Status

    New

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions