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

Form sent via js show_confirm_dialog not marked as submitted

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 3.0, 3.1.2, 3.2
    • Fix Version/s: 3.0.7, 3.1.3
    • Component/s: JavaScript, Libraries
    • Labels:
      None
    • Testing Instructions:
      Hide

      • Add lines creating "submit all and finish" button to the quiz renderer as described in issue description (step 1)
      • Create a new course
      • Add a quiz activity with "Extra restrictions on attempts"->"Browser security" as javascript popup window
      • Set any value of "Attempts allowed" (not unlimited).
      • Go to the created quiz and choose "Edit quiz".
      • Add any questions and separate pages arbitrarily. It is good to use shortanswer or numerical questions where you actually enter text or numbers.
      • Attempt created quiz by clicking "Attempt quiz now" button.
      • Make sure that confirming start pop-up window doesn`t cause any browser`s warnings.
      Test 1.
      Enter answers to some questions during quiz attempt and
      1) try to close current browser`s tab and make sure you see a browser`s warning popup that you are going to lose you data. Press cancel in the popup.
      2) Click any link on the page (for example "Quiz Administration -> Edit settings") and make sure you see a browser`s warning popup that you are going to lose you data. Press cancel in the popup.
      3) Try to change address line and press "Enter". Make sure you see a browser`s warning popup that you are going to lose you data. Press cancel in the popup.
      4) Try to change question in the "Quiz navigation" and make sure that question changes without browser`s warning popup.
      5) Click "Next" button and make sure that page changed without browser`s warning popup.
      6) Click "Submit all and finish". Confirm pop-up window and make sure that attempt was finished without browsers warning popup.
      7) Start the attempt again and click next until summary page. Click "Submit all and finish". Confirm pop-up window and make sure that attempt was finished without browser`s warning popup.
      8) Click "Submit all and finish". Click "Cancel" in the confirmation pop-up window. Try to close current browser`s tab and make sure you see a browser`s warning popup that you are going to lose you data. Press cancel in the popup.

      Regression testing:

      • Verify that the form change checker continues working normally in other places/forms (activity edition, user profile...).
      Show
      • Add lines creating "submit all and finish" button to the quiz renderer as described in issue description (step 1) • Create a new course • Add a quiz activity with "Extra restrictions on attempts"->"Browser security" as javascript popup window • Set any value of "Attempts allowed" (not unlimited). • Go to the created quiz and choose "Edit quiz". • Add any questions and separate pages arbitrarily. It is good to use shortanswer or numerical questions where you actually enter text or numbers. • Attempt created quiz by clicking "Attempt quiz now" button. • Make sure that confirming start pop-up window doesn`t cause any browser`s warnings. Test 1. Enter answers to some questions during quiz attempt and 1) try to close current browser`s tab and make sure you see a browser`s warning popup that you are going to lose you data. Press cancel in the popup. 2) Click any link on the page (for example "Quiz Administration -> Edit settings") and make sure you see a browser`s warning popup that you are going to lose you data. Press cancel in the popup. 3) Try to change address line and press "Enter". Make sure you see a browser`s warning popup that you are going to lose you data. Press cancel in the popup. 4) Try to change question in the "Quiz navigation" and make sure that question changes without browser`s warning popup. 5) Click "Next" button and make sure that page changed without browser`s warning popup. 6) Click "Submit all and finish". Confirm pop-up window and make sure that attempt was finished without browsers warning popup. 7) Start the attempt again and click next until summary page. Click "Submit all and finish". Confirm pop-up window and make sure that attempt was finished without browser`s warning popup. 8) Click "Submit all and finish". Click "Cancel" in the confirmation pop-up window. Try to close current browser`s tab and make sure you see a browser`s warning popup that you are going to lose you data. Press cancel in the popup. Regression testing: Verify that the form change checker continues working normally in other places/forms (activity edition, user profile...).
    • Affected Branches:
      MOODLE_30_STABLE, MOODLE_31_STABLE, MOODLE_32_STABLE
    • Fixed Branches:
      MOODLE_30_STABLE, MOODLE_31_STABLE
    • Pull from Repository:
    • Pull 3.1 Branch:
      MOODLE_31_STABLE
    • Pull Master Branch:
      master

      Description

      This results in user getting wrong warning that entered data will be lost in some popups.

      Steps to reproduce:
      1. In mod/quiz/renderer.php in attempt_form() function after lines (approximately 480)
      $output .= html_writer::empty_tag('input', array('type' => 'submit', 'name' => 'next', 'value' => get_string('next')));
      $output .= html_writer::end_tag('div');
      insert lines
      $output .= html_writer::empty_tag('input', array('type' => 'submit', 'name' => 'finishattempt',
      'value' => get_string('submitallandfinish', 'quiz'), 'id' => 'submit-and-finish-button'));
      $this->page->requires->event_handler('#submit-and-finish-button', 'click', 'M.util.show_confirm_dialog',
      array('message' => get_string('confirmclose', 'quiz')));

      Alternatively you could write a theme with renderer, replacing basic quiz renderer and containing this code.
      2. Create a quiz with secure popup window and add a shortanswer questions to it.
      3. Attempt this quiz and enter some answers to the questions.
      4. Press "Submit all and finish" button and "Ok" in confirm dialog - you will see a message from the browser (onbeforeunload event) telling you that you are going to lose entered data, thought if you proceed the data would not be lost. You should not see this message.

        Attachments

          Issue Links

            Activity

              People

              • Votes:
                0 Vote for this issue
                Watchers:
                6 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Fix Release Date:
                  14/Nov/16