Moodle
  1. Moodle
  2. MDL-36806

Incorrect require_login test in questionlib

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 2.3.3
    • Fix Version/s: 2.2.7, 2.3.4, 2.4
    • Component/s: Questions, Quiz
    • Labels:
      None
    • Testing Instructions:
      Hide

      1. As admin, Create some questions with images in various places like the questiontext, generalfeedback, etc.

      2. Create them in different areas of the question bank. That is in the question categories for system, course category, course CF100, and a Quiz1 in course CF100. (So, that is 4 questions.)

      3. Preview all 4 questions, and make sure you can see the images.

      4. Add those questions to Quiz1.

      5. Now log in as teacher t1, who is enrolled as a teacher in course CF100. You will only be able to preview two of the questions. Do that, and make sure you can see all the images.

      6. Preview the quiz. You should be able to see all four questions, including the images. (Of course, you will have to submit to see them all.)

      7. Now log in as student s1, who is enrolled in course CF100. Attempt the quiz. You should be able to see all four questions, including the images.

      8. Open each image on the review page in a separate tab. (In Firefox, right click on the image, then hold down CTRL and click View image.)

      9. Disable s1's enrolment in CF100. Re-load each image. You should get a permission denied error.

      10. Logged in as teacher t1 again, go to Quiz1 -> results -> Statistics in the navigation block. Click on the name of each question, and make sure you can see the images in the question text.

      11. Look in the PHP logs, and make sure there are no errors like the one in this issue's description.

      Show
      1. As admin, Create some questions with images in various places like the questiontext, generalfeedback, etc. 2. Create them in different areas of the question bank. That is in the question categories for system, course category, course CF100, and a Quiz1 in course CF100. (So, that is 4 questions.) 3. Preview all 4 questions, and make sure you can see the images. 4. Add those questions to Quiz1. 5. Now log in as teacher t1, who is enrolled as a teacher in course CF100. You will only be able to preview two of the questions. Do that, and make sure you can see all the images. 6. Preview the quiz. You should be able to see all four questions, including the images. (Of course, you will have to submit to see them all.) 7. Now log in as student s1, who is enrolled in course CF100. Attempt the quiz. You should be able to see all four questions, including the images. 8. Open each image on the review page in a separate tab. (In Firefox, right click on the image, then hold down CTRL and click View image.) 9. Disable s1's enrolment in CF100. Re-load each image. You should get a permission denied error. 10. Logged in as teacher t1 again, go to Quiz1 -> results -> Statistics in the navigation block. Click on the name of each question, and make sure you can see the images in the question text. 11. Look in the PHP logs, and make sure there are no errors like the one in this issue's description.
    • Affected Branches:
      MOODLE_23_STABLE
    • Fixed Branches:
      MOODLE_22_STABLE, MOODLE_23_STABLE, MOODLE_24_STABLE
    • Pull from Repository:
    • Pull Master Branch:
    • Rank:
      46322

      Description

      question_preview_question_pluginfile contains a require_login test using a cmid guessed from a contextid in the URL. However, this is not always correct. Functions like quiz_question_pluginfile later do the correct require_login call, and that leads to errors like

      .../php-logs/php.log.5:[18-Nov-2012 20:32:48 Europe/London] PHP Notice: Coding problem: unsupported modification of PAGE->context from 70 to 70

      • line 788 of /lib/pagelib.php: call to debugging()
      • line 830 of /lib/pagelib.php: call to moodle_page->set_context()
      • line 2653 of /lib/moodlelib.php: call to moodle_page->set_cm()
      • line 1729 of /mod/quiz/lib.php: call to require_login()
      • line 1855 of /lib/questionlib.php: call to mod_quiz_question_pluginfile()
      • line 3833 of /lib/filelib.php: call to question_pluginfile()
      • line 37 of /pluginfile.php: call to file_pluginfile()
        in /vle/www_root/lib/weblib.php on line 2751

        Activity

        Hide
        Tim Hunt added a comment -

        Submitting for integration.

        Show
        Tim Hunt added a comment - Submitting for integration.
        Hide
        Dan Poltawski added a comment -

        Integrated, thanks Tim.

        Show
        Dan Poltawski added a comment - Integrated, thanks Tim.
        Hide
        Rossiani Wijaya added a comment -

        This works as expected.

        Test passed.

        Show
        Rossiani Wijaya added a comment - This works as expected. Test passed.
        Hide
        Eloy Lafuente (stronk7) added a comment -

        Y E S !

        Closing as fixed, many thanks!

        Show
        Eloy Lafuente (stronk7) added a comment - Y E S ! Closing as fixed, many thanks!

          People

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

            Dates

            • Created:
              Updated:
              Resolved: