moodle 2.1: How can I skip the summary after quiz, and go directly to processattempt?

moodle 2.1: How can I skip the summary after quiz, and go directly to processattempt?

by Max Elander -
Number of replies: 26

Well the title kinda says it, really. I want the last question page to be the last page in the quiz, and when the student clicks "next" he should be taken directly to the result. Any ideas on how to do that?

 

I'm running version 2.1 by the way (edited the title to show it there too).

Average of ratings: -
In reply to Max Elander

Re: moodle 2.1: How can I skip the summary after quiz, and go directly to processattempt?

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

You can't.

This has been requested before, but not very often, and I am not convinced it is a very good idea.

So, I am not going to do anything about it any time soon, but I will go on listening to arguments for or against.

In reply to Tim Hunt

Re: moodle 2.1: How can I skip the summary after quiz, and go directly to processattempt?

by Max Elander -

Well, to me it's not a question wether it's a good idea or not, it's a requirement from my client, so I really don't have much choice.

 

I'll just have to hack away at it I guess.

In reply to Max Elander

Re: moodle 2.1: How can I skip the summary after quiz, and go directly to processattempt?

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

Try this. Near the top of mod/quiz/processattempt.php change 

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

to

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

As a nicety, also change the 'End test...' langauge string to say 'Submit now' or something like that.

No idea if that acutally works, but it might.

In reply to Tim Hunt

Re: moodle 2.1: How can I skip the summary after quiz, and go directly to processattempt?

by Max Elander -

Brilliant! Works like a charm and I'm happy. Thanks a million!

In reply to Tim Hunt

Re: moodle 2.1: How can I skip the summary after quiz, and go directly to processattempt?

by Nikita M -

with this change, how is it possible to add a popup message?

thanks in advance for answer.

In reply to Nikita M

Re: moodle 2.1: How can I skip the summary after quiz, and go directly to processattempt?

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

Well, you need to find the JS that is normally added on the summary page, and add it to the next button if you are on the last page of the quiz, and add it to the end test link.

However, if you want a confirmation step, why do you want to get rid of the summary page?!

In reply to Tim Hunt

Re: moodle 2.1: How can I skip the summary after quiz, and go directly to processattempt?

by Nikita M -

I prefer to put all question in one page and at the end of the page the submit button (with popup), because to pass to one page to another require to much time, and I have to create a quiz in wich student have only 30 minutes to answer 30 question!
(to go to summary page and then come back to review a question, require to much time).
They can easly and faster move to one question to another inside the page using "Quiz navigation" .

In reply to Nikita M

Re: moodle 2.1: How can I skip the summary after quiz, and go directly to processattempt?

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

They can do that even if the summary page exists.

The danger with a one-page quiz, and no summary page, is that there is no way to save your answers as you go, until you submit. Very dangerous if your browser crashes.

In reply to Tim Hunt

Re: moodle 2.1: How can I skip the summary after quiz, and go directly to processattempt?

by Nikita M -

Thanks for your attention Tim.

I know this problem, that's why I would like to find another way to save questions (es. to submit question without change page with deferred feedback).
I notice that flag is saved without change and save page and it is very fast.
Many student need to be tested their ICT knowledge in as short time as possible (from many different university courses).
I must avoid any waste of time during quiz (such as to pass to one page to another).
I don't know if I have clear explained my reason.

In reply to Tim Hunt

Re: moodle 2.1: How can I skip the summary after quiz, and go directly to processattempt?

by Albert Leatherman -

Thanks Tim. Changing 

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

to

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

worked like a charm.

In reply to Max Elander

Re: moodle 2.1: How can I skip the summary after quiz, and go directly to processattempt?

by Jan Aagaard Meier -

For anyone  stumbling over this, I solved the issue by redirecting to the processattempt page in a custom renderer:


class theme_XXX_mod_quiz_renderer extends mod_quiz_renderer {
    public function summary_page($attemptobj, $displayoptions) {
        // Skip the summary page, redirect directly to process
        redirect(new moodle_url('/mod/quiz/processattempt.php', array(
            'attempt' => $attemptobj->get_attemptid(),
            'finishattempt' => 1,
            'sesskey' => sesskey()
        )));
    }
}
In reply to Jan Aagaard Meier

Re: moodle 2.1: How can I skip the summary after quiz, and go directly to processattempt?

by Peter Onyx -

I tried to implement your method but I am not sure if it worked. I wanted to remove the page which appears when we click on a specific quiz , i.e., "summary of your previous attempts". I want to go directly to the quiz, but this is not doing so. I also followed the other solutions but could not find any solution. Please comment.

In reply to Peter Onyx

Re: moodle 2.1: How can I skip the summary after quiz, and go directly to processattempt?

by Jan Aagaard Meier -

This thread concerns the summary page shown after the quiz, which shows what you answered to each question, and asks you to confirm that you want to submit it. You could probably do something similar to what I described by overriding view_page and redirecting to startattempt.php

In reply to Jan Aagaard Meier

Re: moodle 2.1: How can I skip the summary after quiz, and go directly to processattempt?

by Peter Onyx -

 you mean this code:

It did bypass the summary of previous attempts though but it did not land on the quiz question. Just a blank box. Can you help? 



public function view_page($attemptobj, $displayoptions) {

        // Skip the summary page, redirect directly to process

        redirect(new moodle_url('/mod/quiz/startattempt.php', array(

            'attempt' => $attemptobj->get_attemptid(),

            'finishattempt' => 1,

            'sesskey' => sesskey()

        )));

    }


In reply to Peter Onyx

Re: moodle 2.1: How can I skip the summary after quiz, and go directly to processattempt?

by Peter Onyx -

Okay the following code did the trick and now clicking on a quiz would directly take you to the beginning of the quiz and the summary of previous attempts page does not show up. I did it by redirecting the page. However, the problem now is that there is this intermediate page which says that the page should redirect now and if it doesn't, click here to redirect. This page stays for like 3 seconds and then it redirects to the quiz questions. How can I get rid of this page. I did not see any parameter related to time which I can make 0. Please help. The renderer code I used is as follows:-


public function view_page($course, $quiz, $cm, $context, $viewobj) {

redirect(new moodle_url('/mod/quiz/startattempt.php',

            array('cmid' => $cm->id, 'sesskey' => sesskey())));

    }

In reply to Peter Onyx

Re: moodle 2.1: How can I skip the summary after quiz, and go directly to processattempt?

by Peter Onyx -

This is the intermediate annoying page that I want to get rid of. Thanks.


Attachment 1.PNG
In reply to Peter Onyx

Re: moodle 2.1: How can I skip the summary after quiz, and go directly to processattempt?

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

redirect has optional arguments to control this. Set that to 0 then the redirect is instant.

redirect(new moodle_url(...), '', 0);

In reply to Tim Hunt

Re: moodle 2.1: How can I skip the summary after quiz, and go directly to processattempt?

by Peter Onyx -

I used this but does not seem to work.



redirect(new moodle_url('/mod/quiz/startattempt.php',
            array('cmid' => $cm->id, 'sesskey' => sesskey())),0);

In reply to Peter Onyx

Re: moodle 2.1: How can I skip the summary after quiz, and go directly to processattempt?

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

You are passing 0 as the second argument, the text message to display.

The delay is the third argument, which you are not passing, so you are getting the default 3 seconds.

In reply to Tim Hunt

Re: moodle 2.1: How can I skip the summary after quiz, and go directly to processattempt?

by Albert Leatherman -

Hi folks, sort of a related question. I'd like to delete all the stuff in the box in the attached pic, to simplify the summary of attempts page. Does anyone know how to do that? Thanks.

Attachment delete.jpg
In reply to Albert Leatherman

Re: moodle 2.1: How can I skip the summary after quiz, and go directly to processattempt?

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

You can do this with a custom Moodle theme, using this technique: https://docs.moodle.org/dev/Overriding_a_renderer

In reply to Tim Hunt

Re: moodle 2.1: How can I skip the summary after quiz, and go directly to processattempt?

by Albert Leatherman -
Thanks, Tim. That link looks like a super helpful resource and will help me learn a little php. I'll dive into it. Before I get too far in, though, will it work with Evolve-D, the theme I'm using? Thanks.
In reply to Albert Leatherman

Re: moodle 2.1: How can I skip the summary after quiz, and go directly to processattempt?

by Albert Leatherman -

Hi Tim, I made some good progress through lots of trial and error hacking away at renderer.php in mod/quiz. Thanks a lot for the tip to help me get started. I've now got the page looking as in the attached pic, which is great.

Now I'd just like to delete "No more attempts are allowed" and change the text on the "Back to the course" button to just say "Back". To do the former, I deleted the following:

$output .= $this->box($this->view_page_buttons($viewobj), 'quizattempt');

That removed both "No more attempts are allowed" (good) and the "Back to the course" button (bad). It also removed the start button at the beginning of the quiz (bad). Is there a better way to get rid of "No more attempts are allowed"?

In order to change the text on the button, I changed the following in quiz.php in mod/quiz/lang/en:

$string['backtocourse'] = 'Back to the course'; (OLD)

$string['backtocourse'] = 'Back'; (NEW)

However, the button still read "Back to the course", even after I turned on theme developer mode and cleared my browser's cache. Any thoughts on why that didn't work?

Thanks again.

Attachment Screen Shot 2016-08-15 at 11.32.38 PM.png
Average of ratings: Useful (1)
In reply to Albert Leatherman

Re: moodle 2.1: How can I skip the summary after quiz, and go directly to processattempt?

by Albert Leatherman -

Also, for any given quiz (but not for all quizzes), is there a way to skip review.php and go directly to the summary of attempts page that I have modified? Thx

In reply to Albert Leatherman

Re: moodle 2.1: How can I skip the summary after quiz, and go directly to processattempt?

by Nicholas Yang -
A bit late for replying, but in case anybody else is still reading:

  1. Instead of hacking core code in mod/quiz, I'd follow the instructions as Tim had linked in "Overriding a renderer". It looks like you will need to copy over (from mod/quiz/renderer.php) to your own renderer:

    public function view_page_buttons(mod_quiz_view_object $viewobj) {
    ...
    }
    And then edit that to your liking. Specifically, it looks like $viewobj->preventmessages and get_string('backtocourse', 'quiz') are what you need to change.

  2. Strings in the lang/en folder won't be updated unless you bump the version number in version.php and then go to Notifications to update plugins. I'd just override (as mentioned above) and change the get_string('backtocourse', 'quiz') to "My Custom String", or whatever you like. Manually bumping the version number in core code to force an update is not really a good idea, as updating Moodle in the future gets a bit more convoluted (i.e. if your version number is not less than the new version of Moodle you're trying to update to, the code won't get updated). Also note, if the code does get updated, it will overwrite all of your changes -- well, because it's core code.
In reply to Jan Aagaard Meier

Re: moodle 2.1: How can I skip the summary after quiz, and go directly to processattempt?

by Struan McCallum -

"... I solved the issue by redirecting to the processattempt page in a custom renderer:"

Can you point my in the right direction to apply this fix? 

I've currently found the original answer (using $finishattempt  = 1;) doesn't work in the latest version of Moodle.


Thanks