Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-39246

Better synchronise times on the server with times in the browser (e.g. quiz timer)

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Major Major
    • 2.4.4, 2.5
    • 2.3.6, 2.4.3
    • JavaScript, Quiz
    • MOODLE_23_STABLE, MOODLE_24_STABLE
    • MOODLE_24_STABLE, MOODLE_25_STABLE
    • Hide

      1. Create a quiz with a time-limit.
      2. Start an attempt at that quiz.
      3. Verify that the count-down timer starts with the right amount of time left.
      4. View page source, and verify that the code "M.pageloadstarttime = new Date();" appears near the start of <head>.

      Show
      1. Create a quiz with a time-limit. 2. Start an attempt at that quiz. 3. Verify that the count-down timer starts with the right amount of time left. 4. View page source, and verify that the code "M.pageloadstarttime = new Date();" appears near the start of <head>.

      If you try to initialise a timer in the browser by using yui_module or js_init_call, then there the timer will not acutally start running until those script files have loaded, which could be a delay of several seconds.

      It would be better to capture the current time ASAP in <head> using some inline JS like
      M.pageloadstarttime = Date();

      That lets client-side JS get a timestamp that is as close as possible to when Moodle served the page.

      We need this in the quiz module to set make the count-down timer as accurate as possible.

            timhunt Tim Hunt
            timhunt Tim Hunt
            Andrew Lyons Andrew Lyons
            Damyon Wiese Damyon Wiese
            Damyon Wiese Damyon Wiese
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved:

                Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.