Time alerts during quiz

Time alerts during quiz

de către Otoniel Ysea-
Număr de răspunsuri: 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!

Media aprecierilor: -
Ca răspuns la Otoniel Ysea

Re: Time alerts during quiz

de către Rick Jerz-
Fotografia lui Particularly helpful Moodlers Fotografia lui 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.
Ca răspuns la Otoniel Ysea

Re: Time alerts during quiz

de către Dominique Bauer-
Fotografia lui Documentation writers Fotografia lui Particularly helpful Moodlers Fotografia lui 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>
Media aprecierilor:Useful (2)
Ca răspuns la Dominique Bauer

Re: Time alerts during quiz

de către Tim Hunt-
Fotografia lui Core developers Fotografia lui Documentation writers Fotografia lui Particularly helpful Moodlers Fotografia lui Peer reviewers Fotografia lui 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.)

Media aprecierilor:Useful (3)
Ca răspuns la Dominique Bauer

Re: Time alerts during quiz

de către Mawuli Gatro-

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


Ca răspuns la Mawuli Gatro

Re: Time alerts during quiz

de către Dominique Bauer-
Fotografia lui Documentation writers Fotografia lui Particularly helpful Moodlers Fotografia lui 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>

Media aprecierilor:Useful (1)
Ca răspuns la Dominique Bauer

Re: Time alerts during quiz

de către 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.

Atașament TIMER.png
Ca răspuns la Mawuli Gatro

Re: Time alerts during quiz

de către Dominique Bauer-
Fotografia lui Documentation writers Fotografia lui Particularly helpful Moodlers Fotografia lui 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.

Ca răspuns la Dominique Bauer

Re: Time alerts during quiz

de către 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!
Atașament code transcribed1.png
Ca răspuns la Dominique Bauer

Re: Time alerts during quiz

de către Mawuli Gatro-
Please I still don't have my quiz timer display like in the attachment bellow. Any help from any person? 🤔
Ca răspuns la Mawuli Gatro

Re: Time alerts during quiz

de către Dominique Bauer-
Fotografia lui Documentation writers Fotografia lui Particularly helpful Moodlers Fotografia lui Plugin developers
Hello Mawuli,

I can try to help you online. Can you use say Google Meet?
Ca răspuns la Dominique Bauer

Re: Time alerts during quiz

de către 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.
Ca răspuns la Mawuli Gatro

Re: Time alerts during quiz

de către Dominique Bauer-
Fotografia lui Documentation writers Fotografia lui Particularly helpful Moodlers Fotografia lui Plugin developers
Check your email, I will send you a link for our meeting.
Ca răspuns la Dominique Bauer

Re: Time alerts during quiz

de către Mawuli Gatro-
I will be waiting for your mail sir! Thank so much.
Ca răspuns la Mawuli Gatro

Re: Time alerts during quiz

de către Dominique Bauer-
Fotografia lui Documentation writers Fotografia lui Particularly helpful Moodlers Fotografia lui 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.
Ca răspuns la Mawuli Gatro

Re: Time alerts during quiz

de către 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
Ca răspuns la Thorsten Leich

Re: Time alerts during quiz

de către Dominique Bauer-
Fotografia lui Documentation writers Fotografia lui Particularly helpful Moodlers Fotografia lui 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".)