From cc77b4d78200b7e6bec64bf62b8d782037b91426 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/assets/capa/_display.scss | 18 +++++++++++------- xmodule/js/src/capa/display.js | 11 +++++++++-- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/xmodule/assets/capa/_display.scss b/xmodule/assets/capa/_display.scss index 15571b65dc30..ddf53eae6f64 100644 --- a/xmodule/assets/capa/_display.scss +++ b/xmodule/assets/capa/_display.scss @@ -209,6 +209,7 @@ div.problem { // Choice Group - silent class %choicegroup-base { @include clearfix(); + @include margin($baseline, 0 0 0); min-width: 100px; width: auto !important; @@ -307,7 +308,7 @@ div.problem { @include left(em(9)); position: absolute; - top: 0.35em; + top: .43em; width: $baseline*1.1; height: $baseline*1.1; z-index: 1; @@ -572,10 +573,10 @@ div.problem { } .grading { - margin: 0px 7px 0 0; + margin: 0 7px 0 0; padding-left: 25px; background: url('#{$static-path}/images/info-icon.png') left center no-repeat; - text-indent: 0px; + text-indent: 0; } p { @@ -646,7 +647,7 @@ div.problem { } .submit-message-container { - margin: $baseline 0px ; + margin: $baseline 0; } } @@ -780,7 +781,10 @@ div.problem { // +Problem - Text Input, Numerical Input // ==================== .problem { - .capa_inputtype.textline, .inputtype.formulaequationinput { + .capa_inputtype.textline, + .inputtype.formulaequationinput { + @include margin($baseline, 0 0 0); + input { box-sizing: border-box; @@ -879,7 +883,7 @@ div.problem { // ==================== .problem { .inputtype.option-input { - margin: 0 0 0 0 !important; + margin: $baseline 0 0 0 !important; .indicator-container { display: inline-block; @@ -946,7 +950,7 @@ div.problem { } .CodeMirror-scroll { - margin-right: 0px; + margin-right: 0; } } 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);