Disabling "Return to Attempt" in Quiz

Disabling "Return to Attempt" in Quiz

by niraj B -
Number of replies: 20

Moodle version 3.8.2+

Dear Moodle community, I am working on a quiz and would like to remove a functionality.

At the end of the quiz, there is the "Return to Attempt" button. I wish to get rid of it 

could anyone provide a solution to either removing or disabling it?


Average of ratings: -
In reply to niraj B

Re: Disabling "Return to Attempt" in Quiz

by Rick Jerz -
Picture of Particularly helpful Moodlers Picture of Testers
It appears that the student still has 1:46 minutes remaining. Do you not want them to be able to easily return to the quiz in their remaining time?
Average of ratings: Useful (1)
In reply to Rick Jerz

Re: Disabling "Return to Attempt" in Quiz

by Dominique Bauer -
Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Plugin developers

Hello niray,

As Rick mentioned, this may not be a good idea, for example if a student inadvertently clicks on the "Finish attempt..." link or button.

But if you really want to, you can probabably do it with a little javascript that will hide the "Return to attempt" button or go straight to the review page.

In reply to Dominique Bauer

Re: Disabling "Return to Attempt" in Quiz

by niraj B -

Any Suggestions what the javascript codes would be?

In reply to Dominique Bauer

Re: Disabling "Return to Attempt" in Quiz

by Ahmad Amer -

The JavaScript link does not have the code!

In reply to Dominique Bauer

Re: Disabling "Return to Attempt" in Quiz

by Ahmad Amer -
The JavaScript link does not have the code!
In reply to Ahmad Amer

Re: Disabling "Return to Attempt" in Quiz

by Dominique Bauer -
Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Plugin developers

Hello niraj and Ahmad,

It is not a real link, more like a "tiptool". Anyways, here's the script that you can add in Site administration / Appearance / Additional HTML / Within HEAD (also works in When BODY is opened and Before BODY is closed):

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
  $("button:contains(Return to attempt)").css("display", "none");
});
</script>
Average of ratings: Useful (3)
In reply to Dominique Bauer

Re: Disabling "Return to Attempt" in Quiz

by Ahmad Amer -
Thank you very much Dominique. This is very useful especially when Moodle is used with very young learners. One more question please: how to get rid of the second “submit all and finish”?
In reply to Ahmad Amer

Re: Disabling "Return to Attempt" in Quiz

by Dominique Bauer -
Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Plugin developers

Hello Ahmad,

With javascript, it is a little difficult to hide only the "Submit all and finish" confirmation. Here is  a temporary workaround. Add the following code in Site administration / Appearance / Additional HTML / Within HEAD (also works in When BODY is opened and Before BODY is closed):

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.0/jquery.min.js"></script>
<script>
$(document).ready(function(){
    $("a.endtestlink").css("display","none");
    $("input[value='Finish attempt ...']").on("focus", function(){
        var x = confirm("\n \n Submit all and finish?");
        if (x == true) {
            $("input[value='Finish attempt ...']").blur()
            $("input[value='Finish attempt ...']").click()
        } else {
            $("input[value='Finish attempt ...']").blur()
        };
    });
$("button:contains(Submit all and finish)").click();
});
</script>

This code replaces the "Summary of attempt" page with a window confirm message, then skips the "Submit all and finish" confirmation.

Also, $("a.endtestlink").css("display","none"); removes the "Finish attempt ..." link which is somewhat redundant and perhaps confusing.

Here's what you'll get:



Average of ratings: Useful (2)
In reply to Dominique Bauer

Re: Disabling "Return to Attempt" in Quiz

by aziz vefa -
Hi Mr. Bauer.
I have a quiz that has 4 questions.
I set the quiz time limit to 2 minutes. Also, I set the "open attempts are submitted automatically".
I answered 2 questions and logged out or left the quiz. I wait for the time is up, then back to the quiz again with the "continue to last attempt" button. The quiz is still in progress and I'm able to continue to answer. In the end, I finished the quiz with an overdue time. All my answers are saved and I passed the quiz. How can that happen?
The setting for "when the time expires" is working only if the student doesn't leave the quiz and time is up. Then the answers are saved and submitted automatically. That's ok. But as I see in that URL (https://docs.moodle.org/310/en/Quiz_settings) it should also be working "if the student starts a timed attempt, then leaves the attempt, and then later time expires."
Would you please help me?
Thank you.
In reply to aziz vefa

Re: Disabling "Return to Attempt" in Quiz

by Emma Richardson -
Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Plugin developers
DId you do this as a student (logged in with a student account - not just a change role to)?
In reply to Dominique Bauer

Re: Disabling "Return to Attempt" in Quiz

by Francisco Mancera -

Thank you very much, for me your solution was very useful, I had been looking for something to skip that part for a long time
In reply to Rick Jerz

Re: Disabling "Return to Attempt" in Quiz

by niraj B -

I dont want Students to return to the quiz even if time is remaining. once they reach the end it is the end.

In reply to niraj B

Re: Disabling "Return to Attempt" in Quiz

by Timothy Takemoto -
Me too. If they are allowed to return to the attempt then they can play a question video again.

Fortunately this "step" is recorded so I can see which students have used the "Return to Attempt" button.

Alas I don' t have the option of injecting Dominique Bauer's cool JavaScript into the whole site since it is not my site and many teachers may want to give their students the option of using the "Return to Attempt" button. I don't  seem to have  the option of using a custom theme into which I might inject the javascript  either.

It would be nice if this were a quiz option allong the lines of the take the test "in order" option.
In reply to Timothy Takemoto

Re: Disabling "Return to Attempt" in Quiz

by Timothy Takemoto -
I was about to ask the administrator for the inclusion of custom course themes so I could inject that wizard javascript of Dominique's but I see that I would also need to stop the mobile and tablet themes site wide which would not be possible.

I am wondering whether the fact that students return to the test is recorded on the test page attempt summary. If so I could just ask them not to use the "Return to Attempt" button and penalise those that do.
In reply to Timothy Takemoto

Re: Disabling "Return to Attempt" in Quiz

by Dominique Bauer -
Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Plugin developers
Hello Timothy,

JavaScript code can just as easily be placed, by a teacher without access to the site administration, in the text of a question or in an HTML block, which would be more appropriate in this case. This should work for the mobile app as well, but I'm not sure.
In reply to Dominique Bauer

Re: Disabling "Return to Attempt" in Quiz

by Dominique Bauer -
Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Plugin developers
Hello Timothy,

 ... I would also need to stop the mobile and tablet themes site wide which would not be possible.

Using JavaScript code has some limitations. First, computer savvy students might figure out how to undo the JavaScript code. Therefore, it is not 100% secure and should not be used if there are security concerns. Second, and more importantly here, JavaScript code works with the browser version of Moodle, on desktop computers and mobile devices, but not with the Moodle Mobile app.


It would be nice if this were a quiz option allong the lines of the take the test "in order" option.

You can use the "Sequential" navigation method (https://docs.moodle.org/310/en/Quiz_settings#Layout ↗). However, be aware that this method of navigation can be inconvenient for students as they cannot skip questions or return to previous ones.
In reply to Dominique Bauer

Re: Disabling "Return to Attempt" in Quiz

by Dominique Bauer -
Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Plugin developers
The JavaScript code is available at Skip Summary of attempt ↗.
In reply to Dominique Bauer

Re: Disabling "Return to Attempt" in Quiz

by Uwe Brauer -
Hi
thanks for this description. However I don't understand what you mean by
Add an HTML block to your quiz and paste the JavaScript code into the HTML of the block "Content". (See JavaScript.)
When I chose edit quiz, there is no option for adding a HTML block, do you mean a question type description
Or do you mean you have a topic that contains a quiz and I add a HTML block to that topic.
I am not even sure what you mean by HTML block:
a label?
a (HTML) page?
Sorry for this elementary question
regards
Uwe Brauer
In reply to Uwe Brauer

Re: Disabling "Return to Attempt" in Quiz

by Uwe Brauer -
I think I know now what ad HTML block means, however do I paste the js directly in that block or do I activate HTML to see the HTML code
I tried both ways, but my test did not work, that is the return attempt button still pops up.
In reply to Uwe Brauer

Re: Disabling "Return to Attempt" in Quiz

by Uwe Brauer -
The configuration  of that HTML block is either:

block or bloc3 attached below. Neither do work for me
Attachment block.png
Attachment block3.png