You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
TL;DR: Article-level assessment config overwrites question components' _canShowFeedback / _canShowMarking / _canShowModelAnswer even when those properties are omitted.
Summary
Issue #65 was closed as fixed in v2.0.5 (2015). The fix added a hasOwnProperty guard in the override path so that when an author omitted _canShowFeedback / _canShowModelAnswer from the article's _assessment._questions block, the question component's own value was preserved.
The same bug has since returned via two changes that together defeat the original fix:
The introduction of assessmentConfigDefaults._questions (with all three properties defaulting to false) at the top of adapt-assessmentArticleModel.js. getConfig() deep-merges these defaults with the article config, so "omitted" properties get filled in as false before any downstream code runs.
The combined effect: the original v2.0.5 fix in _overrideQuestionComponentSettings() (which still uses hasOwnProperty) is bypassed because setupCurrentQuestionComponents() runs first and overwrites component values from the merged-with-defaults config.
Reproduction
Place a question component (e.g. an mcq) with "_attempts": 1 inside an assessment article.
In the component's components.json entry, set "_canShowModelAnswer": true.
In the article's _assessment._questions block, either:
Omit _canShowModelAnswer entirely, or
Set "_canShowModelAnswer": false.
Run the course. Submit an incorrect answer to exhaust the attempt.
Expected (per #65): When the property is omitted from the article, the question's own _canShowModelAnswer: true is respected and the Show Correct Answer button appears.
Actual: The button never appears. The article-level (or defaulted) false overrides the component value regardless of whether the author specified it.
Remove _canShowFeedback, _canShowMarking, _canShowModelAnswer from assessmentConfigDefaults._questions so that omission in articles.json produces genuinely undefined values rather than defaulted false. The QuestionModel already defaults these to true at the component level, which is the appropriate fallback.
‼️ Backward compatibility risk
Existing courses that author _canShowMarking: false etc. at the article level are unaffected - the property is still defined, hasOwnProperty returns true, behavior is unchanged.
Existing courses that omitted the property and were relying on the implicit false default would see a behavior change: questions would start showing model answers / marking. This is technically a behavior change but matches both the documented behavior (#65) and the QuestionModel defaults. May warrant a minor version bump and release-note callout, or an opt-in property (e.g. _respectComponentOverrides) for safety.
Use case
In the project that surfaced this, one question in an assessment article needs to expose the Show Correct Answer button while the others do not. Currently impossible without a custom extension or fork.
TL;DR: Article-level assessment config overwrites question components'
_canShowFeedback/_canShowMarking/_canShowModelAnswereven when those properties are omitted.Summary
Issue #65 was closed as fixed in v2.0.5 (2015). The fix added a
hasOwnPropertyguard in the override path so that when an author omitted_canShowFeedback/_canShowModelAnswerfrom the article's_assessment._questionsblock, the question component's own value was preserved.The same bug has since returned via two changes that together defeat the original fix:
assessmentConfigDefaults._questions(with all three properties defaulting tofalse) at the top ofadapt-assessmentArticleModel.js.getConfig()deep-merges these defaults with the article config, so "omitted" properties get filled in asfalsebefore any downstream code runs.setupCurrentQuestionComponents()that blunt-sets_canShowFeedback,_canShowMarking, and_canShowModelAnsweron every question component duringinit()and after assessment reset, with nohasOwnPropertycheck.The combined effect: the original v2.0.5 fix in
_overrideQuestionComponentSettings()(which still useshasOwnProperty) is bypassed becausesetupCurrentQuestionComponents()runs first and overwrites component values from the merged-with-defaults config.Reproduction
mcq) with"_attempts": 1inside an assessment article.components.jsonentry, set"_canShowModelAnswer": true._assessment._questionsblock, either:_canShowModelAnswerentirely, or"_canShowModelAnswer": false.Expected (per #65): When the property is omitted from the article, the question's own
_canShowModelAnswer: trueis respected and the Show Correct Answer button appears.Actual: The button never appears. The article-level (or defaulted)
falseoverrides the component value regardless of whether the author specified it.Root cause - code references
js/adapt-assessmentArticleModel.js(v5.4.1):assessmentConfigDefaultsdefaults all three properties tofalse.getConfig()deep-merges via$.extend(true, {}, defaults, config).setupCurrentQuestionComponents()unconditionally sets all three. No guard._getMarkingSettings()keeps the assessment overrides_canShowFeedbackand_canShowModelAnswereven if not set #65 guard, but runs after components clobbered.Regression timeline
62789f28):_canShowModelAnsweroverride feature implemented (blunt set, no guard).6b9a16ec, released as v2.0.5): assessment overrides_canShowFeedbackand_canShowModelAnswereven if not set #65 fixed by addinghasOwnPropertyguards in_overrideQuestionComponentSettings().ab8f7a7a, PR assessment: _canShowMarking & _canShowModelAnswer settings not applied on restore #2693 #130, fixing framework issue #2693): New methodsetupCurrentQuestionComponents()added to push article settings down to components duringinit()and after reset, so settings would be applied on session restore. This method reintroduced the blunt-set pattern, reverting the spirit of the assessment overrides_canShowFeedbackand_canShowModelAnswereven if not set #65 fix.Suggested fix
Two changes needed; both are required because they reinforce each other:
In
setupCurrentQuestionComponents(), addhasOwnPropertyguards mirroring_getMarkingSettings():Remove
_canShowFeedback,_canShowMarking,_canShowModelAnswerfromassessmentConfigDefaults._questionsso that omission inarticles.jsonproduces genuinely undefined values rather than defaultedfalse. The QuestionModel already defaults these totrueat the component level, which is the appropriate fallback.Existing courses that author
_canShowMarking: falseetc. at the article level are unaffected - the property is still defined,hasOwnPropertyreturns true, behavior is unchanged.Existing courses that omitted the property and were relying on the implicit
falsedefault would see a behavior change: questions would start showing model answers / marking. This is technically a behavior change but matches both the documented behavior (#65) and the QuestionModel defaults. May warrant a minor version bump and release-note callout, or an opt-in property (e.g._respectComponentOverrides) for safety.Use case
In the project that surfaced this, one question in an assessment article needs to expose the Show Correct Answer button while the others do not. Currently impossible without a custom extension or fork.
Posted via collaboration with Claude Code.