I wonder if someone has not thought of putting the "return to course" button always visible at the end of the quiz.
Making the "Back to the course" button always visible will surely not be unanimous among developers. At best, this might not
be seen as a priority.
Many of our users have serious difficulties understanding how to move, once the quiz is over.
Of course, the solution I am proposing should not make the situation even more difficult for users to understand. So I added a clear "OR" (although
I don't think it's really necessary) between the "Back to the course" button and the "Re-attempt quiz" or "Continue the last attempt" button. I also use the code in all cases as I think it's clearer for users to go back to the current section than
to the main page of the course.
Note that the script works well with the Boost theme in Chrome and Firefox on a Windows desktop computer. It might not work with other systems.
Stefano, if you use my code, I'd be curious if your users find the situation clearer or less clear than before.
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js">
</script>
<script>
$(document).ready(function(){
if (window.location.href.indexOf("https://moodleformulas.org/mod/quiz/view.php") > -1) {
if ($(".continuebutton").length) {
$(".continuebutton").css("display","none");
$("<div style='text-align:center;'><button class='btn btn-secondary' onclick='backtotheCourse()'>Back to the course</button></div>").insertBefore($("div.quizattempt"));
} else {
$("<div style='text-align:center;'><button class='btn btn-secondary' onclick='backtotheCourse()'>Back to the course</button></div><div style='text-align:center;position:relative;top:8px;'>OR</div>").insertBefore($("div.quizattempt"));
}
}
})
function backtotheCourse() {
var x = $("ol.breadcrumb li:eq(-2) > a").attr("href");
window.location.replace(x);
}
</script>
Don't forget to replace "https://moodleformulas.org" with the domain name of your Moodle site.