Moodle
  1. Moodle
  2. MDL-26178

Trying to preview an empty quiz displays PHP errors

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 2.0
    • Fix Version/s: 2.0.2
    • Component/s: Quiz
    • Labels:
    • Affected Branches:
      MOODLE_20_STABLE
    • Fixed Branches:
      MOODLE_20_STABLE
    • Rank:
      16210

      Description

      Trying to preview an empty quiz displays PHP errors when trying to preview quiz just after having deleted all of its questions.

      Notice: Trying to get property of non-object in \moodle\mod\quiz\attemptlib.php on line 412
      Fatal error: Cannot use string offset as an array in \moodle\mod\quiz\attemptlib.php on line 416

      A more user-friendly message would be welcome.

        Activity

        Hide
        Helen Foster added a comment -

        Joseph, thanks for your report.

        I tried to reproduce it on the QA Testing site by logging in as a teacher, deleting all questions from http://qa.moodle.net/mod/quiz/view.php?id=59 then previewing it, but rather than obtaining an error message, I was redirected to the editing quiz page.

        Have you any ideas why you obtained a fatal error but I didn't? Have I misunderstood your description perhaps?

        Show
        Helen Foster added a comment - Joseph, thanks for your report. I tried to reproduce it on the QA Testing site by logging in as a teacher, deleting all questions from http://qa.moodle.net/mod/quiz/view.php?id=59 then previewing it, but rather than obtaining an error message, I was redirected to the editing quiz page. Have you any ideas why you obtained a fatal error but I didn't? Have I misunderstood your description perhaps?
        Hide
        Joseph Rézeau added a comment -

        Helen, here are more details to reproduce this problem.
        Create new quiz.
        Edit quiz. One question per page.
        Add several questions (from the Question bank) to it.
        Preview: OK.
        Edit quiz.
        Click on the Remove icon to remove all the questions.
        You are left with a number of "empty pages".
        Now click on the Preview link in the Quiz navigation block.
        On the QA moodle site you get a blank page (because debug mode does not display PHP errors).
        Joseph

        Show
        Joseph Rézeau added a comment - Helen, here are more details to reproduce this problem. Create new quiz. Edit quiz. One question per page. Add several questions (from the Question bank) to it. Preview: OK. Edit quiz. Click on the Remove icon to remove all the questions. You are left with a number of "empty pages". Now click on the Preview link in the Quiz navigation block. On the QA moodle site you get a blank page (because debug mode does not display PHP errors). Joseph
        Hide
        Tim Hunt added a comment -

        Yes, the key think is to have more than one empty page.

        Show
        Tim Hunt added a comment - Yes, the key think is to have more than one empty page.
        Hide
        Tim Hunt added a comment -

        Pull request done.

        Show
        Tim Hunt added a comment - Pull request done.

          People

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

            Dates

            • Created:
              Updated:
              Resolved: