Skip to content

Commit d6856b6

Browse files
committed
part feedback summary shows when the feedback has changed
To try to get the student's attention, the "Show feedback" text is bold when the feedback messages have changed.
1 parent 83141ec commit d6856b6

4 files changed

Lines changed: 49 additions & 14 deletions

File tree

locales/en-GB.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,7 @@
292292
"part.unknown type": "{{part}}: Unrecognised part type {{type}}",
293293
"part.setting not present": "Property '{{property}}' not set",
294294
"part.feedback out of date": "This feedback is based on your last submitted answer. Save your changed answer to get updated feedback.",
295+
"part.there is new feedback": "The feedback has changed.",
295296
"part.input title": "Answer for part {{name}}",
296297
"part.show feedback": "Show feedback",
297298
"part.hide feedback": "Hide feedback",
@@ -490,4 +491,4 @@
490491
"worksheet.reconfigure": "Generate different sheets",
491492
"worksheet.show sheet": "Preview the sheet with ID:",
492493
"worksheet.answersheet show question content": "Show question content in answer sheets?"
493-
}
494+
}

themes/default/files/resources/exam.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1179,6 +1179,10 @@ select.multiplechoice {
11791179
cursor: pointer;
11801180
}
11811181

1182+
.part .feedbackMessages.changed > summary {
1183+
font-weight: bold;
1184+
}
1185+
11821186
.part.dirty > .submit-and-feedback > .feedbackMessages .out-of-date-message {
11831187
font-size: 0.9em;
11841188
font-style: italic;

themes/default/files/scripts/part-display.js

Lines changed: 38 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -265,12 +265,32 @@ Numbas.queueScript('part-display',['display-util', 'display-base','util','jme'],
265265
*/
266266
this.feedbackMessages = Knockout.observableArray([]);
267267

268+
/** Are there other parts in line with this one? (Used to decide whether to show the submit button and feedback text)
269+
* True if there's more than one part in the question, or this is a step.
270+
*
271+
* @member {observable|boolean} isNotOnlyPart
272+
* @memberof Numbas.display.PartDisplay
273+
*/
274+
this.isNotOnlyPart = Knockout.computed(function() {
275+
return this.question.display.numParts()>1 || this.part.isStep;
276+
},this);
277+
278+
var _feedbackShown = ko.observable(false);
279+
268280
/** Is the box containing the feedback messages open?
269281
*
270282
* @member {observable.<boolean>} feedbackShown
271283
* @memberof Numbas.display.PartDisplay
272284
*/
273-
this.feedbackShown = ko.observable(false);
285+
this.feedbackShown = Knockout.computed({
286+
read: function() {
287+
return _feedbackShown() || !this.isNotOnlyPart()
288+
},
289+
290+
write: function(v) {
291+
_feedbackShown(v);
292+
}
293+
}, this);
274294

275295
/** Text for the button to toggle the display of the feedback messages.
276296
*
@@ -284,15 +304,6 @@ Numbas.queueScript('part-display',['display-util', 'display-base','util','jme'],
284304
return this.feedbackShown() ? R('part.hide feedback') : R('part.show feedback');
285305
}, this);
286306

287-
/** Are there other parts in line with this one? (Used to decide whether to show the submit button and feedback text)
288-
* True if there's more than one part in the question, or this is a step.
289-
*
290-
* @member {observable|boolean} isNotOnlyPart
291-
* @memberof Numbas.display.PartDisplay
292-
*/
293-
this.isNotOnlyPart = Knockout.computed(function() {
294-
return this.question.display.numParts()>1 || this.part.isStep;
295-
},this);
296307
/** Have the steps ever been shown?
297308
*
298309
* @see Numbas.parts.Part#stepsShown
@@ -416,6 +427,18 @@ Numbas.queueScript('part-display',['display-util', 'display-base','util','jme'],
416427
*/
417428
this.showFeedbackMessages = Numbas.display_util.resolve_feedback_setting(this, p.question.exam.settings.showPartFeedbackMessages);
418429

430+
/** Has the feedback changed since it was last looked at?
431+
* @member {observable|boolean} showFeedbackMessages
432+
* @memberof Numbas.display.PartDisplay
433+
*/
434+
this.changedFeedback = Knockout.observable(false);
435+
436+
this.feedbackShown.subscribe(function(shown) {
437+
if(shown) {
438+
pd.changedFeedback(false);
439+
}
440+
});
441+
419442
/**
420443
* Feedback messages that are shown to the student.
421444
* If all feedback should be shown, then returns the entire list. If not, then only messages relating to invalid input are shown.
@@ -439,7 +462,7 @@ Numbas.queueScript('part-display',['display-util', 'display-base','util','jme'],
439462
}
440463

441464
// If showing the current score and this part is marked, add a message giving the total score.
442-
if(feedback_settings.showFeedbackIcon && this.marks()!=0 && this.scoreFeedback.showActualMark()) {
465+
if(feedback_settings.showFeedbackIcon && this.marks()!=0 && this.scoreFeedback.showActualMark() && this.answered()) {
443466
messages.push({
444467
credit_change: '',
445468
message: '',
@@ -451,6 +474,10 @@ Numbas.queueScript('part-display',['display-util', 'display-base','util','jme'],
451474
return messages;
452475
},this);
453476

477+
this.shownFeedbackMessages.subscribe(function() {
478+
pd.changedFeedback(!pd.feedbackShown());
479+
})
480+
454481
/**
455482
* Does this part have any shown feedback messages?
456483
*

themes/default/templates/xslt/part.xslt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,11 @@
5858
</div>
5959
<small class="answered-state" data-bind="html: scoreFeedback.answeredString"></small>
6060
</div>
61-
<details class="feedbackMessages" role="log" aria-live="polite" aria-atomic="true" data-bind="pulse: scoreFeedback.update, open: feedbackShown() || !isNotOnlyPart()" localise-data-jme-context-description="part.feedback">
62-
<summary data-bind="text: feedbackToggleText, visible: isNotOnlyPart"></summary>
61+
<details class="feedbackMessages" role="log" aria-live="polite" aria-atomic="true" data-bind="pulse: scoreFeedback.update, open: feedbackShown, css: {{changed: changedFeedback()}}" localise-data-jme-context-description="part.feedback">
62+
<summary data-bind="visible: isNotOnlyPart">
63+
<span data-bind="text: feedbackToggleText"></span>
64+
<span class="sr-only" data-bind="visible: changedFeedback"><localise>part.there is new feedback</localise></span>
65+
</summary>
6366
<p class="out-of-date-message" data-bind="visible: isDirty"><localise>part.feedback out of date</localise></p>
6467
<p class="sr-only" data-bind="visible: isNotOnlyPart, text: feedback_title"></p>
6568
<ol data-bind="visible: shownFeedbackMessages().length, foreach: shownFeedbackMessages">

0 commit comments

Comments
 (0)