Skip to content

Commit

Permalink
show expected answers when the question is revealed
Browse files Browse the repository at this point in the history
After the recent changes to feedback, expected answers were only shown
when the exam is in the `revealed` state.

When you do "Reveal answers" on a single question, the exam is not
`revealed`, only the question.

This changes the logic for displaying expected answers to use the
question's `revealed` state instead of the exam's.

This still leaves a weird behaviour where if "Allow revealing answers to
a single question" is turned on, but all feedback is set to "only in
review mode" and "enter review mode immediately on ending the exam" is
turned off, then you can see your scores for a question by revealing
answers, but any questions you haven't revealed when the exam ends don't
show feedback.

Should "allow revealing answers to a single question" only be available
if "enter review mode immediately on ending the exam" is turned off, and
"show expected answers" isn't "never"?

fixes #1115
  • Loading branch information
christianp committed Sep 24, 2024
1 parent 823c703 commit adb8bd4
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
2 changes: 1 addition & 1 deletion themes/default/files/scripts/part-display.js
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ Numbas.queueScript('part-display',['display-util', 'display-base','util','jme'],
if(!pd.revealed()) {
return false;
}
return Numbas.is_instructor || (p.settings.showCorrectAnswer && p.question.exam.display.expectedAnswersRevealed());
return Numbas.is_instructor || (p.settings.showCorrectAnswer && p.question.display.expectedAnswersRevealed());
});

var feedback_settings = Numbas.util.copyobj(p.question.exam.settings);
Expand Down
19 changes: 14 additions & 5 deletions themes/default/files/scripts/question-display.js
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,16 @@ Numbas.queueScript('question-display',['display-util', 'display-base','jme-varia
* @memberof Numbas.display.QuestionDisplay
*/
this.revealed = Knockout.observable(q.revealed);

/** Should expected answers to parts be shown?
*/
this.expectedAnswersRevealed = Knockout.pureComputed(function() {
if(!this.revealed()) {
return false;
}
return exam.settings.revealExpectedAnswers == 'inreview';
},this);

/** Have any of this question's parts been answered?
*
* @member {observable|boolean} anyAnswered
Expand Down Expand Up @@ -501,19 +511,18 @@ Numbas.queueScript('question-display',['display-util', 'display-base','jme-varia
*
* @memberof Numbas.display.QuestionDisplay
*/
showAdvice: function()
{
showAdvice: function() {
this.adviceDisplayed(this.question.adviceDisplayed);
},
/** Reveal the answers to this question.
*
* @memberof Numbas.display.QuestionDisplay
*/
revealAnswer: function()
{
revealAnswer: function() {
this.revealed(this.question.revealed);
if(!this.question.revealed)
if(!this.question.revealed) {
return;
}
scroll(0,0);
},
/**
Expand Down

0 comments on commit adb8bd4

Please sign in to comment.