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

Quiz unit tests create_instance doesn't handle review options correctly

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Duplicate
    • Affects Version/s: 2.5.3
    • Fix Version/s: None
    • Component/s: Quiz, Unit tests
    • Labels:

      Description

      Function quiz_process_options() expects input to be in the format of a form.

       // Combing the individual settings into the review columns.
          $quiz->reviewattempt = quiz_review_option_form_to_db($quiz, 'attempt');
          $quiz->reviewcorrectness = quiz_review_option_form_to_db($quiz, 'correctness');
          $quiz->reviewmarks = quiz_review_option_form_to_db($quiz, 'marks');
          $quiz->reviewspecificfeedback = quiz_review_option_form_to_db($quiz, 'specificfeedback');
          $quiz->reviewgeneralfeedback = quiz_review_option_form_to_db($quiz, 'generalfeedback');
          $quiz->reviewrightanswer = quiz_review_option_form_to_db($quiz, 'rightanswer');
          $quiz->reviewoverallfeedback = quiz_review_option_form_to_db($quiz, 'overallfeedback');
          $quiz->reviewattempt |= mod_quiz_display_options::DURING;
          $quiz->reviewoverallfeedback &= ~mod_quiz_display_options::DURING;
      

      This is called by;
      1. quiz_add_instance()
      2. mod_quiz_generator->create_instance()

      create_instance uses;

        $alwaysvisible = mod_quiz_display_options::DURING | mod_quiz_display_options::IMMEDIATELY_AFTER |
                      mod_quiz_display_options::LATER_WHILE_OPEN | mod_quiz_display_options::AFTER_CLOSE;
       
                  'reviewattempt'          => $alwaysvisible,
                  'reviewcorrectness'      => $alwaysvisible,
                  'reviewmarks'            => $alwaysvisible,
                  'reviewspecificfeedback' => $alwaysvisible,
                  'reviewgeneralfeedback'  => $alwaysvisible,
                  'reviewrightanswer'      => $alwaysvisible,
                  'reviewoverallfeedback'  => $alwaysvisible,
      

      to build the attempt information. That is directly overridden by quiz_process_options() and I'm therefore unable to input unit test data into a quiz to test if review options are set correctly.

      In the custom code I'm developing, I'm attempting to detect if the review options are set a specific way and produce an error report if a user has not administratively set the correct values.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              mr-russ Russell Smith
              Reporter:
              mr-russ Russell Smith
              Participants:
              Component watchers:
              Tim Hunt, Andrew Nicols, Jun Pataleta, Michael Hawkins, Shamim Rezaie, Simey Lameze, Andrew Nicols, Jun Pataleta, Michael Hawkins, Shamim Rezaie, Simey Lameze
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: