allow decimal point values on quiz index page

fixes QO-77
flag = none

test plan:
 - create Classic/New Quizzes worth 1 point, 2+ points,
   and a decimal point value, such as 1.23
 - on the quizzes index page, all point values should
   display correctly (i.e. 1 pt, 2 pts, 1.23 pts)

Change-Id: I52221bda7c27d92b9ed2f7bc61ff6f83ee7fa9c0
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/237896
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Syed Hussain <shussain@instructure.com>
QA-Review: Jacob Burroughs <jburroughs@instructure.com>
Product-Review: Kevin Dougherty <jdougherty@instructure.com>
This commit is contained in:
Jared Crystal 2020-05-19 12:30:11 -06:00
parent 8d12ab179b
commit ada67d5743
2 changed files with 8 additions and 1 deletions

View File

@ -115,7 +115,9 @@ export default class Quiz extends Backbone.Model {
const pts = this.get('points_possible')
let text = ''
if (pts && pts > 0 && !this.isUngradedSurvey()) {
text = I18n.t('assignment_points_possible', 'pt', {count: pts})
text = Number.isInteger(pts)
? I18n.t('assignment_points_possible', 'pt', {count: pts})
: I18n.t('%{points} pts', {points: I18n.n(pts)})
}
return this.set('possible_points_label', text)
}

View File

@ -135,6 +135,11 @@ test('#initialize sets possible points count with 2 points', function() {
equal(this.quiz.get('possible_points_label'), '2 pts')
})
test('#initialize sets possible points count with 1.23 points', function() {
this.quiz = new Quiz({points_possible: 1.23})
equal(this.quiz.get('possible_points_label'), '1.23 pts')
})
test('#initialize points possible to null if ungraded survey', function() {
this.quiz = new Quiz({
points_possible: 5,