Skip to content

Commit

Permalink
when showing part feedback messages but not answer state, don't show …
Browse files Browse the repository at this point in the history
…positive or negative messages
  • Loading branch information
christianp committed Sep 27, 2024
1 parent 8687bb3 commit 1ec6d12
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
2 changes: 1 addition & 1 deletion runtime/scripts/part.js
Original file line number Diff line number Diff line change
Expand Up @@ -1778,7 +1778,7 @@ if(res) { \
}
}
}
change_desc = credit_change>0 ? 'positive' : credit_change<0 ? 'negative' : 'neutral';
change_desc = credit_change > 0 ? 'positive' : credit_change < 0 ? 'negative' : 'neutral';
switch(action.reason) {
case 'correct':
change_desc = 'positive';
Expand Down
1 change: 1 addition & 0 deletions themes/default/files/scripts/display-util.js
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,7 @@ Numbas.queueScript('display-util', ['math'], function() {
state: state,
showActualMark: showActualMark,
showTotalMark: showTotalMark,
showAnswerState: showAnswerState,
answered: answered,
answeredString: Knockout.computed(function() {
if(obj.marks()==0 && !obj.doesMarking()) {
Expand Down
13 changes: 12 additions & 1 deletion themes/default/files/scripts/part-display.js
Original file line number Diff line number Diff line change
Expand Up @@ -425,12 +425,23 @@ Numbas.queueScript('part-display',['display-util', 'display-base','util','jme'],
*/
this.shownFeedbackMessages = Knockout.computed(function() {
var messages = this.feedbackMessages();

// If not showing part feedback messages, only show messages about invalid input.
if(!this.showFeedbackMessages()) {
messages = messages.filter(function(m) { return m.credit_change == 'invalid'; });
}

// If not showing the answer correctness, don't show messages that give positive or negative feedback.
if(!this.scoreFeedback.showAnswerState()) {
messages = messages.filter(function(m) {
return !(m.credit_change == 'positive' || m.credit_change == 'negative');
});
}

// If showing the current score and this part is marked, add a message giving the total score.
if(feedback_settings.showFeedbackIcon && this.marks()!=0 && this.scoreFeedback.showActualMark()) {
messages.push({
credit_change: 0,
credit_change: '',
message: '',
icon: undefined,
credit_message: R('part.marking.total score',{count:p.score}),
Expand Down

0 comments on commit 1ec6d12

Please sign in to comment.