Skip to content

Commit 91220e3

Browse files
committed
fix: visual and progress score display enhancement
1 parent 5071f28 commit 91220e3

File tree

2 files changed

+20
-9
lines changed

2 files changed

+20
-9
lines changed

xmodule/assets/capa/_display.scss

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,7 @@ div.problem {
209209
// Choice Group - silent class
210210
%choicegroup-base {
211211
@include clearfix();
212+
@include margin($baseline, 0 0 0);
212213

213214
min-width: 100px;
214215
width: auto !important;
@@ -307,7 +308,7 @@ div.problem {
307308
@include left(em(9));
308309

309310
position: absolute;
310-
top: 0.35em;
311+
top: .43em;
311312
width: $baseline*1.1;
312313
height: $baseline*1.1;
313314
z-index: 1;
@@ -572,10 +573,10 @@ div.problem {
572573
}
573574

574575
.grading {
575-
margin: 0px 7px 0 0;
576+
margin: 0 7px 0 0;
576577
padding-left: 25px;
577578
background: url('#{$static-path}/images/info-icon.png') left center no-repeat;
578-
text-indent: 0px;
579+
text-indent: 0;
579580
}
580581

581582
p {
@@ -646,7 +647,7 @@ div.problem {
646647
}
647648

648649
.submit-message-container {
649-
margin: $baseline 0px ;
650+
margin: $baseline 0;
650651
}
651652
}
652653

@@ -780,7 +781,10 @@ div.problem {
780781
// +Problem - Text Input, Numerical Input
781782
// ====================
782783
.problem {
783-
.capa_inputtype.textline, .inputtype.formulaequationinput {
784+
.capa_inputtype.textline,
785+
.inputtype.formulaequationinput {
786+
@include margin($baseline, 0 0 0);
787+
784788
input {
785789
box-sizing: border-box;
786790

@@ -879,7 +883,7 @@ div.problem {
879883
// ====================
880884
.problem {
881885
.inputtype.option-input {
882-
margin: 0 0 0 0 !important;
886+
margin: $baseline 0 0 0 !important;
883887

884888
.indicator-container {
885889
display: inline-block;
@@ -946,7 +950,7 @@ div.problem {
946950
}
947951

948952
.CodeMirror-scroll {
949-
margin-right: 0px;
953+
margin-right: 0;
950954
}
951955
}
952956

xmodule/js/src/capa/display.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -290,14 +290,21 @@
290290

291291
Problem.prototype.updateProgress = function(response) {
292292
if (response.progress_changed) {
293-
this.el.data('problem-score', response.current_score);
294-
this.el.data('problem-total-possible', response.total_possible);
293+
this.el.data('problem-score', this.convertToFloat(response.current_score));
294+
this.el.data('problem-total-possible', this.convertToFloat(response.total_possible));
295295
this.el.data('attempts-used', response.attempts_used);
296296
this.el.trigger('progressChanged');
297297
}
298298
return this.renderProgressState();
299299
};
300300

301+
Problem.prototype.convertToFloat = function(num) {
302+
if (typeof num !== 'number' || !Number.isInteger(num)) {
303+
return num;
304+
}
305+
return num.toFixed(1);
306+
};
307+
301308
Problem.prototype.forceUpdate = function(response) {
302309
this.el.data('problem-score', response.current_score);
303310
this.el.data('problem-total-possible', response.total_possible);

0 commit comments

Comments
 (0)