From 3e388a79c91b51563a632f1e2d8af584aa17f8c3 Mon Sep 17 00:00:00 2001 From: ihor-romaniuk Date: Mon, 27 May 2024 15:31:47 +0200 Subject: [PATCH] fix: visual and progress score display enhancement --- xmodule/js/src/capa/display.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/xmodule/js/src/capa/display.js b/xmodule/js/src/capa/display.js index f4254b43f8ff..9bc5591acd4f 100644 --- a/xmodule/js/src/capa/display.js +++ b/xmodule/js/src/capa/display.js @@ -290,14 +290,21 @@ Problem.prototype.updateProgress = function(response) { if (response.progress_changed) { - this.el.data('problem-score', response.current_score); - this.el.data('problem-total-possible', response.total_possible); + this.el.data('problem-score', this.convertToFloat(response.current_score)); + this.el.data('problem-total-possible', this.convertToFloat(response.total_possible)); this.el.data('attempts-used', response.attempts_used); this.el.trigger('progressChanged'); } return this.renderProgressState(); }; + Problem.prototype.convertToFloat = function(num) { + if (typeof num !== 'number' || !Number.isInteger(num)) { + return num; + } + return num.toFixed(1); + }; + Problem.prototype.forceUpdate = function(response) { this.el.data('problem-score', response.current_score); this.el.data('problem-total-possible', response.total_possible);