@@ -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 *
0 commit comments