Skip to content
This repository was archived by the owner on Mar 12, 2021. It is now read-only.

Commit 4c68031

Browse files
authored
Merge pull request #28 from ExtensionEngine/vkaracic/NDPD-1243
NDPD-1243: Show max score in grading modal.
2 parents b6c536a + d777a0d commit 4c68031

File tree

4 files changed

+19
-7
lines changed

4 files changed

+19
-7
lines changed

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def package_data(pkg, roots):
2323

2424
setup(
2525
name='short_answer-xblock',
26-
version='0.2.23',
26+
version='0.2.24',
2727
description='Short Answer XBlock',
2828
license='MIT',
2929
packages=[

short_answer/static/css/short_answer.css

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,12 +123,12 @@
123123
}
124124

125125
.short-answer-block .modal table .score-column {
126-
width: 55px;
126+
width: 65px;
127127
}
128128

129129
.short-answer-block .modal table .answer {
130130
display: block;
131-
width: 195px;
131+
width: 185px;
132132
}
133133

134134
.short-answer-block .modal table .answer-column {

short_answer/static/html/short_answer.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
</td>
3939
<td><%= answered_at %></td>
4040
<td>
41-
<span class="score"><%= score %></span>
41+
<span class="score"><% if (score) { %><%= score %></span> / <span="max_score"><%= max_score %><% } %></span>
4242
<input type="number" step="0.1" min="0.1" name="score-input" class="hidden" value="<%= score %>"
4343
placeholder="<%= max_score %>" max="<%= max_score %>">
4444
</td>

short_answer/static/js/src/short_answer.js

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,14 @@ function ShortAnswerXBlock(runtime, element, options) {
5454
return score !== '' && !isNaN(score) && 0 <= score && score <= maxScore;
5555
}
5656

57+
/**
58+
* Returns a float with two decimal positions for the passed in grade.
59+
* @param {int} grade
60+
*/
61+
function gradeWithDecimals(grade) {
62+
return parseFloat(grade).toFixed(2);
63+
}
64+
5765
/**
5866
* Populate the submissions table in the modal window and
5967
* bind all the buttons for each row.
@@ -67,12 +75,14 @@ function ShortAnswerXBlock(runtime, element, options) {
6775

6876
submissions.forEach(function(submission) {
6977
submission.answer = submission.answer || '';
70-
if (submission.answered_at !== 'None') {
78+
if (submission.answered_at && submission.answered_at !== 'None') {
7179
submission.answered_at = moment.utc(submission.answered_at).local().format('MM/DD/YYYY hh:mma');
7280
} else {
7381
submission.answered_at = ''
7482
}
75-
submission.score = submission.score || '';
83+
84+
submission.score = submission.score ? gradeWithDecimals(submission.score) : '';
85+
submission.max_score = gradeWithDecimals(submission.max_score);
7686

7787
$(template(submission)).appendTo($tableBody);
7888
});
@@ -102,6 +112,7 @@ function ShortAnswerXBlock(runtime, element, options) {
102112

103113
closeEditing();
104114
$('.score', $row).addClass('hidden');
115+
$('.max_score', $row).addClass('hidden');
105116
$('input[name=score-input]', $row).removeClass('hidden');
106117
$('.submit-grade-form', $row).removeClass('hidden');
107118
$('.action-buttons', $row).addClass('hidden');
@@ -149,7 +160,8 @@ function ShortAnswerXBlock(runtime, element, options) {
149160
score: score
150161
}),
151162
success: function(data) {
152-
$('.score', $row).text(data.new_score)
163+
$('.score', $row).text(gradeWithDecimals(data.new_score));
164+
$('.max_score', $row).removeClass('hidden');
153165
},
154166
error: function(err) {
155167
displayError('.modal-error', err);

0 commit comments

Comments
 (0)