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

Autosave in quiz does not always work with TinyMCE editor fields

XMLWordPrintable

    • MOODLE_401_STABLE, MOODLE_402_STABLE, MOODLE_403_STABLE
    • MOODLE_402_STABLE, MOODLE_403_STABLE
    • MDL-80003_401
    • MDL-80003_403
    • MDL-80003_master
    • Hide

      Have students do a manual save (by changing the question page or following "Finish attempt…" and "Return to attempt") from time to time.

      Show
      Have students do a manual save (by changing the question page or following "Finish attempt…" and "Return to attempt") from time to time.
    • Hide
      1. Log in as a teacher.
      2. Open a second (incognito) window and log in as a student.
      3. As the teacher, create a quiz with a single essay question.
      4. As the student, attempt the quiz.
      5. Using the developer tools of your browser, set a breakpoint in the function autosave.js:init_tinymce() in the line var startSaveTimer = this.start_save_timer_if_necessary.bind(this). (Not giving a line number, because it differs between versions and depends on your setting of developer mode. Also, it might be autosave-debug.js.)
      6. In the console. type tinymce.get() and verify that no TinyMCE editor has been added yet.
      7. With the element inspector from the developer tools, select the textarea and duplicate it.
      8. For the duplicated element, change its classid and name attribute to "MDL80003".
      9. In the console, type tinymce.init({selector: ".MDL80003"}).
      10. Now, the textarea should be invisible like in my "failing" video.
      11. Resume script execution.
      12. In the console, type monitor(M.mod_quiz.autosave.start_save_timer_if_necessary).
      13. Start typing in the upper (the original) editor and see how start_save_timer_if_necessary is called.
      14. Start typing in the lower (the duplicated and manually inserted) editor and see how start_save_timer_if_necessary is called.
      15. As the teacher, go to the results overview of the quiz and click "Review attempt" for the relevant student account.
      16. Verify the student's work has been autosaved.

       

      Show
      Log in as a teacher. Open a second (incognito) window and log in as a student. As the teacher , create a quiz with a single essay question. As the student , attempt the quiz. Using the developer tools of your browser, set a breakpoint in the function autosave.js:init_tinymce() in the line var startSaveTimer = this.start_save_timer_if_necessary.bind(this) . (Not giving a line number, because it differs between versions and depends on your setting of developer mode. Also, it might be autosave-debug.js .) In the console. type  tinymce.get()  and  verify  that no TinyMCE editor has been added yet. With the element inspector from the developer tools, select the textarea and duplicate it. For the duplicated element, change its  class ,  id  and  name  attribute to "MDL80003". In the console, type  tinymce.init({selector: ".MDL80003"}) . Now, the textarea should be invisible like in my "failing" video. Resume script execution. In the console, type  monitor(M.mod_quiz.autosave.start_save_timer_if_necessary) . Start typing in the upper (the  original ) editor and see how  start_save_timer_if_necessary  is called. Start typing in the lower (the  duplicated  and manually inserted) editor and see how  start_save_timer_if_necessary  is called. As the teacher , go to the results overview of the quiz and click "Review attempt" for the relevant student account. Verify the student's work has been autosaved.  

      Given a quiz with one essay question using (new) default TinyMCE.

      Attempt the quiz as student and start typing. The console shows that TinyMCE is autosaving the data in order to recover in case of problems. However, in some cases, the data is not autosaved on the quiz side, i. e. M.mod_quiz.autosave.save_changes is not called, checking the student's log shows no entries of autosave and reviewing the student's (in progress) attempt shows an empty field.

      This may seem related to MDL-74378, but it is not. It can happen for quizzes with a time limit or a closing time, even for short quizzes. 

      Update

      The error happens, because we attach the change (et al.) event handlers to TinyMCE's  AddEditor handler. However, in some cases (and for whatever reason), at least one editor might already exist and, thus, will not get the handlers attached, because it is not added anymore.

            philippimhof Philipp Imhof
            philippimhof Philipp Imhof
            Tim Hunt Tim Hunt
            Ilya Tregubov Ilya Tregubov
            Kim Jared Lucas Kim Jared Lucas
            Votes:
            0 Vote for this issue
            Watchers:
            9 Start watching this issue

              Created:
              Updated:
              Resolved:

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 3 hours, 25 minutes
                3h 25m

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