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

LTI embedded timed quizzes throws javascript error and breaks MathJax

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Open
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: 3.4.7, 3.7.2
    • Fix Version/s: None
    • Component/s: LTI provider, Quiz
    • Labels:
    • Environment:
      Windows 10. Chrome (v77.0) and Firefox (v60.2.2)
    • Database:
      Any
    • Testing Instructions:
      Hide
      1. Use a moodle server configured to act as an LTI provider and that "Allow frame embedding" of moodle is permitted in the security setting.
      2. Create a quiz and configure it to be timed.
      3. Create a question (any type) and include some MathJax notation in the question text.
      4. Deploy the quiz on the moodle server.
      5. Publish the quiz as an LTI tool within the course on moodle.
      6. In a consumer VLE platform, create an LTI link to the moodle quiz using the details from the published LTI quiz.
      7. Using a student test account on the consumer VLE, select the LTI link and begin the quiz.
      8. Note that all side-blocks are removed and therefore the quiz navigation is missing.   Note also that when viewing the question which features MathJax content, the Mathematics does not display and instead displays raw LaTeX.

       

      Alternatively, set a "Close the quiz" date and time just short of one hour after the current time.  Begin the test in the consumer server with the quiz embedded via LTI.  As soon as you reach 1 hour before the close time for the quiz, a 1 hour remaining timer will automatically appear and the MathJax again breaks.  See full description for why this issue occurs.

      Show
      Use a moodle server configured to act as an LTI provider and that "Allow frame embedding" of moodle is permitted in the security setting. Create a quiz and configure it to be timed . Create a question (any type) and include some MathJax notation in the question text. Deploy the quiz on the moodle server. Publish the quiz as an LTI tool within the course on moodle. In a consumer VLE platform, create an LTI link to the moodle quiz using the details from the published LTI quiz. Using a student test account on the consumer VLE, select the LTI link and begin the quiz. Note that all side-blocks are removed and therefore the quiz navigation is missing.   Note also that when viewing the question which features MathJax content, the Mathematics does not display and instead displays raw LaTeX.   Alternatively, set a " Close the quiz " date and time just short of one hour after the current time.  Begin the test in the consumer server with the quiz embedded via LTI.  As soon as you reach 1 hour before the close time for the quiz, a 1 hour remaining timer will automatically appear and the MathJax again breaks.  See full description for why this issue occurs.
    • Workaround:
      Hide

      Don't use timed quizzes.

      Show
      Don't use timed quizzes.
    • Difficulty:
      Moderate
    • Affected Branches:
      MOODLE_34_STABLE, MOODLE_37_STABLE

      Description

      When embedding a moodle quiz (provider) into an LTI consumer (in my case Blackboard) if the quiz timer is enabled, a javascript error is thrown and this can break the presentation of some types of question content.  In my case, this java script error is breaking the processing of MathJax markup in the custom STACK question type, however, I have also tested the use of MathJax in a simple True/False question type and the problem still occurs i.e. it is not specific to any one question type.  MathJax is presented in raw LaTeX marking with broken image place holders.  The attached image illustrates this for a STACK question which relies heavily on MathJax.  It is also worth noting that if the time isn't enabled, but "Close the quiz" date and time is set, a 1 hour countdown time will appear 1 hour before the quiz close time and the same error will be thrown.

       

      The javascript error message is:

      Uncaught TypeError: Cannot read property 'setContent' of null
      at Object.update (module.js:5)
      at Object.init (module.js:2)
      at attempt.php?attempt=1096:204
      at YUI._notify (VM4647 yui-moodlesimple-min.js:9)
      at T (VM4647 yui-moodlesimple-min.js:9)
      at YUI._use (VM4647 yui-moodlesimple-min.js:9)
      at YUI.T (VM4647 yui-moodlesimple-min.js:9)
      at e.Loader._finish (VM4647 yui-moodlesimple-min.js:16)
      at e.Loader._onSuccess (VM4647 yui-moodlesimple-min.js:16)
      at e.Loader.p (VM4647 yui-moodlesimple-min.js:17)

      The javascript line of code is:

      var hours=Math.floor(secondsleft/3600);secondsleft-=hours*3600;var minutes=Math.floor(secondsleft/60);secondsleft-=minutes*60;var seconds=secondsleft;Y.one('#quiz-time-left').setContent(hours+':'M.mod_quiz.timer.two_digit(minutes)':'+M.mod_quiz.timer.two_digit(seconds));M.mod_quiz.timer.timeoutid=setTimeout(M.mod_quiz.timer.update,100)}};M.mod_quiz.nav=M.mod_quiz.nav||{};M.mod_quiz.nav.update_flag_state=function(attemptid,questionid,newstate){var Y=M.mod_quiz.nav.Y;var navlink=Y.one('#quiznavbutton'+questionid);navlink.removeClass('flagged');if(newstate==1)

      {navlink.addClass('flagged');navlink.one('.accesshide .flagstate').setContent(M.util.get_string('flagged','question'))}

      else{navlink.one('.accesshide .flagstate').setContent('')}};M.mod_quiz.nav.init=function(Y){M.mod_quiz.nav.Y=Y;Y.all('#quiznojswarning').remove();var form=Y.one('#responseform');if(form){function nav_to_page(pageno)

      {Y.one('#followingpage').set('value',pageno);var submit=form.one('input[name="next"]');submit.set('name','');submit.getDOMNode().click()}

      ;Y.delegate('click',function(e){if(this.hasClass('thispage'))

      {return}

      My best guess is that this error is caused because when a quiz is embedded via LTI, the side-blocks are hidden and this includes the side block where the QUIZ NAVIGATION and Time left are displayed.  If these blocks don't get included, there is nothing to update and a javascript error is thrown.  A solution could be to stop the QUIZ NAVIGATION block from being stripped out when a quiz is presented as embedded inside a consumer service.

        Attachments

          Activity

            People

            Assignee:
            Unassigned
            Reporter:
            stuartmanderson Stuart Anderson
            Participants:
            Component watchers:
            Adrian Greeve, Jake Dallimore, Mathew May, Mihail Geshoski, Peter Dias, Tim Hunt, Andrew Nicols, Jun Pataleta, Michael Hawkins, Shamim Rezaie, Simey Lameze
            Votes:
            3 Vote for this issue
            Watchers:
            7 Start watching this issue

              Dates

              Created:
              Updated: