Time alerts during quiz

Time alerts during quiz

av Otoniel Ysea -
Antal svar: 16

Hello,

I've been looking to set a time alert at the remaining 5-minute mark in a quiz. Is this possible on moodle? Thanks in advance!

Genomsnitt av betyg: -
Som svar till Otoniel Ysea

Re: Time alerts during quiz

av Rick Jerz -
Bild på Particularly helpful Moodlers Bild på Testers
As far as I know, there is not this feature. However, the clock always shows. Isn't this enough?

Yes, some folks have wanted all kinds of "clock" display. For example: Don't show the clock at all. Show the clock temporarily every x minutes. Show warnings at 30 minutes, 15 minutes, 10 minutes, and 5 minutes. Change the color of the clock at 1 minute. You see, the list goes on and on. You can see that the problem might be that there could be a whole page of settings to control this clock. And if there was, then some people would complain that this feature is too complex.

I am just trying to point out that your question is good, but might lead to complexity. You might explore the Tracker feature requests to see if someone has suggested this, and to vote for it.
Som svar till Otoniel Ysea

Re: Time alerts during quiz

av Dominique Bauer -
Bild på Documentation writers Bild på Particularly helpful Moodlers Bild på Plugin developers

Hello Otoniel,

Just paste the following code in Site administration / Appearance / Additional HTML / When BODY is opened. Don't forget to Save changes.

<script>
var myVar = setInterval(myAlert, 500);
function myAlert() {
    var x = document.getElementById("quiz-time-left").innerHTML;
    if (x=="0:05:00") {
        alert("5 minutes left!");
    }
}
</script>
Som svar till Dominique Bauer

Re: Time alerts during quiz

av Tim Hunt -
Bild på Core developers Bild på Documentation writers Bild på Particularly helpful Moodlers Bild på Peer reviewers Bild på Plugin developers

Just to say that the quiz countdown timer is one of those things on my list of thing that need to be improved when I get a round tuit.

Doing what Otoniel asks for well is a tricky balance. On the one hand you want the student to notice that time is getting short. On the other hand, you don't want to completely interrupt their thoughts. (So, I think a plan JavaScript alert is on the side of being too invasive.)

In addition to extra JS, the other thing you can hook into is that inside the last 100 seconds, Moodle puts a CSS class on the timer like class="timeleft99" (https://github.com/moodle/moodle/blob/master/mod/quiz/module.js#L114). Moodle itself only hooks into this for the last 15 seconds: https://github.com/moodle/moodle/blob/master/mod/quiz/styles.css#L209, but you could do more. (I have not idea why it is just 15 seconds. It has just been like that for many years.)

Som svar till Dominique Bauer

Re: Time alerts during quiz

av Mawuli Gatro -

Please i am a new bee here. How can my quiz time left be displayed like the one in the attachment bellow?


Bilaga 678.png
Som svar till Mawuli Gatro

Re: Time alerts during quiz

av Dominique Bauer -
Bild på Documentation writers Bild på Particularly helpful Moodlers Bild på Plugin developers

Hello Mawuli,

Paste the following code in Site administration / Appearance / Additional HTML / When BODY is opened. Don't forget to Save changes. If you don't have access to the Site administration, put the code in an HTML block and set the block to appear on every page of the quiz.

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script>
    $(document).ready(function() {
        /* FORMAT TIMER */
        $("#quiz-timer-wrapper, #quiz-timer").css("background-color", "red");
        $("#quiz-timer-wrapper").css("position", "fixed");
        $("#quiz-timer-wrapper").css("top", "50px");
        $("#quiz-timer-wrapper").css("left", "0px");
        $("#quiz-timer-wrapper").css("width", "100%");
        $("#quiz-timer").css("margin", "0 auto 0");
        $("#quiz-timer").css("color", "white");
        $("#quiz-timer").css("font-weight", "bold");
        $("#quiz-timer").css("font-size", "150%");
        $("#quiz-timer").css("border", "none");
    });
</script>

Som svar till Dominique Bauer

Re: Time alerts during quiz

av Mawuli Gatro -

Hi Dominique,
Thanks very much for your timely response. I am very much grateful.
Please I did exactly what you asked me to but i realized  the quiz timer had not moved to the top position like the attachment in your message . It is still where it is only that the background color has changed to red.
Please find attached the changes in the image below.

Thanks.

Bilaga TIMER.png
Som svar till Mawuli Gatro

Re: Time alerts during quiz

av Dominique Bauer -
Bild på Documentation writers Bild på Particularly helpful Moodlers Bild på Plugin developers
Hello Mawuli,

You're using the Boost theme, aren't you? If so, that's fine. Tags identified by "quiz-timer" are recognized. Those identified by "quiz-timer-wrapper" seem not to have been recognized.

I see the following three possibilities:
  • You made a mistake in transcribing the code.
  • The "quiz-timer-wrapper" identification is incorrect. Inspect the document to verify the name of the id.
  • For some reason the code is not suitable.

Som svar till Dominique Bauer

Re: Time alerts during quiz

av Mawuli Gatro -
Hi Dominique,
I am using the Boost theme and Moodle version 3.7
Please attached is the code transcribed. Kindly go through and check what might be wrong or the reason the code is not suitable.
Also how can I verify the name of the id of ''quiz-timer-wrapper'' ?

Thanks!
Bilaga code transcribed1.png
Som svar till Dominique Bauer

Re: Time alerts during quiz

av Mawuli Gatro -
Please I still don't have my quiz timer display like in the attachment bellow. Any help from any person? 🤔
Bilaga Quiz timer over the quiz name.png
Som svar till Mawuli Gatro

Re: Time alerts during quiz

av Dominique Bauer -
Bild på Documentation writers Bild på Particularly helpful Moodlers Bild på Plugin developers
Hello Mawuli,

I can try to help you online. Can you use say Google Meet?
Som svar till Dominique Bauer

Re: Time alerts during quiz

av Mawuli Gatro -
Hi Dominique,
Thanks in advance for your help. I have not use Google Meet before but i think i can give it a try.
Please when do you think will be appropriate to meet online? I am ever ready for your help at any time.
Som svar till Mawuli Gatro

Re: Time alerts during quiz

av Dominique Bauer -
Bild på Documentation writers Bild på Particularly helpful Moodlers Bild på Plugin developers
Check your email, I will send you a link for our meeting.
Som svar till Dominique Bauer

Re: Time alerts during quiz

av Mawuli Gatro -
I will be waiting for your mail sir! Thank so much.
Som svar till Mawuli Gatro

Re: Time alerts during quiz

av Dominique Bauer -
Bild på Documentation writers Bild på Particularly helpful Moodlers Bild på Plugin developers
Mawuli,

Let's meet, say today (Thursday) at 3:00 p.m. local time in Ghana. To use Google Meet, you must have a Google account. If you don't have one, you can create one in a matter of minutes. To join the meeting, simply go to this address:
https://meet.google.com/rnx-wbyk-ptm ↗

It should work fine with Google Meet, but if there is a problem we could use Zoom.
Som svar till Mawuli Gatro

Re: Time alerts during quiz

av Thorsten Leich -
Hi Mawuli and Dominique,

I found your conversation and it is what I am looking for. I inserted your css code with same result. The quiz timer is located in the quiz navigation and sadly not as shown at top of the screen. That's why I am wondering if you guys figured out what was the problem in Mawuli's environment?

Thanks for your help!
Thorsten
Som svar till Thorsten Leich

Re: Time alerts during quiz

av Dominique Bauer -
Bild på Documentation writers Bild på Particularly helpful Moodlers Bild på Plugin developers

Hello Thorsten,

To change the timer display to a red line at the top of the page, just style a div element as follows in the file "..\mod\quiz\templates\timer.mustache":

<div id="quiz-timer" class="quiz-timer-inner py-1 px-2 ml-auto" role="timer" aria-atomic="true" aria-relevant="text" style="background-color:#F00;color:#FFF;width:100%;text-align:center;">

It is certainly the fastest way, but not necessarily the most convenient. First of all, you need to have access to the Moodle files, which you don't have if you are not the site administrator. Second, the change will be overwritten with the next update to Moodle.

Regarding the little script I had suggested to Mawuli, I found the problem when looking at the code on his installation. I don't remember but it was a small bug, maybe related to the language used for the name of the selectors or something else.

What do you see if you inspect the timer? (In Chrome, place the cursor on the timer, click the right mouse button and select "Inspect".)