display a helpful message instead of a NaN time for Classic Quizzes

refs QO-679
flag=none

test plan:
 - if the timer would have displayed "NaN Minutes, NaN Seconds"
   now it should display a helpful message instead
 - the message should be in red (meeting 4.5:1 contrast)
 - when the message is displayed, the timer label "Time Running"
   should be hidden, as should the "hide" button
 - when there are no issues with the timer, it should display
   as before

Change-Id: I33938b0b5208d9d37aab57379459f076086983d3
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/250884
Reviewed-by: Stephen Kacsmark <skacsmark@instructure.com>
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
QA-Review: Mark McDermott <mmcdermott@instructure.com>
Product-Review: Matthew Goodwin <mattg@instructure.com>
This commit is contained in:
Jared Crystal 2020-10-22 14:25:01 -06:00
parent 199eadc544
commit 0a4e493c58
1 changed files with 14 additions and 0 deletions

View File

@ -444,6 +444,20 @@ var quizSubmission = (function() {
const hr = date.getUTCHours()
const min = date.getUTCMinutes()
const sec = date.getUTCSeconds()
// Only checking min and sec since those are the only two forced to always display.
// Plus, it's most likely either none of these will be NaN, or they all will be.
if (Number.isNaN(Number(min)) || Number.isNaN(Number(sec))) {
// display a helpful message instead of a NaN time
$('.time_header').hide()
$('.hide_time_link').hide()
$('.time_running').css('color', '#EA0611')
$timeRunningFunc().text(
I18n.t(
'Your browser connectivity might be unstable. Please refresh the page to continue with this quiz. If the problem persists please reach out to your instructor.'
)
)
return
}
const times = []
if (yr) {
times.push(I18n.t('years_count', 'Year', {count: yr}))