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.

3.PNG

Pushing next user finishes his attempt and goes to review page.

4.jpg

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 yes/no trigger to Layout menu of quiz.

5.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


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

Change table structure

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

Add row

If we don`t want to add a new column we may add a new row to a table quiz_slots. This table contains the information about quiz pages configuration. May be it`s a reason to add a new additional slot for summary page. Some columns fill by negative numbers to mark it as not a question. This way allow not to change structure but confuses different objects in one table. It can cause more additional conditions in php code to filter what is question and what is not and which page to show in quiz and which not.

8.PNG

Edit quiz name'

This way is a temporary solution and it doesn`t need any addings to database. If we need to add flag we can add to a quiz name or intro any invisible symbol and then check it as a flag.

9.png

The problem that user can delete it by name/intro edition.


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.