Note:

If you want to create a new page for developers, you should create it on the Moodle Developer Resource site.

Quiz Summary Page Hiding

From MoodleDocs

Summary page in Moodle quiz


At the end of every quiz user sees a summary page asking to confirm quiz finishing.

SummaryPage1.png

Pushing the "Submit all and finish" user gets another submit request.

2.PNG

Only after this user can finish and go to review page.


Finishing quiz without summary page


As a way not see the summary page is to ask the confirmation on the last quiz page. It could be "Submit and finish" button instead of "Next" on the last page of the quiz

3н.PNG

Pushing this button user finishes his attempt and goes to review page.

4н.jpg

Another way to avoid the summary page is to add a submit and finish button to every page of the quiz. The student doesn`t need to click next button to the last page and can finish quiz anywhere.

13.PNG

Turning off the summary page


We should have an additional option to omit the summary page.

There are some variants to place this option:

Quiz administration -> Edit settings:

Add a new point to Layout menu of quiz. It can be an advanced option and seen only after clicking "Show more".

11a.PNG

New option will contain information block.


12.PNG

Quiz administration -> Edit quiz:

Add a new special summary page with a checkbox.

6.jpg

Add a new special summary page with a add-option on the page. And spedial close-button for disabling.

X.png

Storing the flag in the database


The main problem of this task we need save anywhere the flag about the summary page showing. I`ve got some idea how to save this information:

Change table structure by adding a new column to mdl_quiz table

The most obvious way to add a new column to the quiz information table mdl_quiz.This table was created for storing options and it`s common to add such things. But this table has already many columns and we need to take into account our new column in backup and restore procedures.

7.PNG

Implementation


The last page of the quiz redirects us to the summary page. Now it should be checked if summery page should be shawn.

We can create this fork next way:

next button sends a form with different properties of current and next page (look moodle\mod\quiz\renderer.php - attempt_form function). Inside this function we can check the hide-flag from database and send additional value by form. Another script (moodle\mod\quiz\process_attempt.php) catches this form and checks different given properties. The properties are:

   // Get submitted parameters.
   $attemptid     = required_param('attempt',  PARAM_INT);
   $thispage      = optional_param('thispage', 0, PARAM_INT);
   $nextpage      = optional_param('nextpage', 0, PARAM_INT);
   $next          = optional_param('next',          false, PARAM_BOOL);
   $finishattempt = optional_param('finishattempt', false, PARAM_BOOL);
   $timeup        = optional_param('timeup',        0,      PARAM_BOOL); // True if form was submitted by timer.
   $scrollpos     = optional_param('scrollpos',    null ,     PARAM_RAW);
   // Here we can catch our hide-flag

And then in the place:

   if ($page == -1) {    $nexturl = $attemptobj->summary_url(); }

we can add checking hide-flag and if we need hide the summary page set the $finishattempt variable as true.

If we need show the confirm window before redirecting to preview page we can use

$button->add_action(new confirm_action(get_string('confirmclose', 'quiz'), null, get_string('submitallandfinish', 'quiz')));

for the "next" button on the last attempt page.