Closed (fixed)
Project:
Quiz
Version:
7.0.x-dev
Component:
Code - Quiz core
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Reporter:
Created:
7 Jul 2020 at 08:06 UTC
Updated:
15 Dec 2024 at 15:12 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
djdevinLooks like we may have to use https://www.drupal.org/project/countdown or https://www.drupal.org/project/jquery_countdown_timer
Comment #3
djdevinI couldn't find a jquery countdown timer that looked normal, supported custom formats/strings, and also had an onFinished event, so I bundled http://hilios.github.io/jQuery.countdown which allows for custom formats.
Comment #4
hypertext200This patch works with this D8 port from jQuery timer, https://www.drupal.org/project/jquery_countdown/issues/2261877#comment-1...
Comment #5
hypertext200Comment #8
djdevinThank you, when there is a release for that module we can merge this. Hopefully soon, though if not, the one I bundled is pretty lightweight.
Comment #9
hypertext200Yes, @djdevin. I tested your patch and it worked perfect, my code was also written based on that :).
Comment #10
nikkrop commentedMaybe I'm missing something, but the timer completion handler just clicks next/finish button on timer expire.
How is it supposed to work? After all, if I have not entered an answer and press the next button (or timer expire), I simply receive a message that it is necessary to enter an answer. I think this handler needs to be reworked.
Comment #11
djdevinYes, that's correct.
But the form handler is supposed to detect that the timer has expired and turn off validation, so that might need another look.
The same should happen if the JS timer wasn't present (the user should not receive "you must enter an answer" and the attempt should be finalized).
Comment #12
nikkrop commentedAlso, the module has a buffer time setting, which adds additional time to provide an answer, but this option does not count in visual time, and the form processor does (adds to the total time). It can also lead to incorrect handling of timer expiration.
Comment #13
djdevinYes...if a user selects an answer, we let them slide if it's close :)
I authored the current approach but I welcome any alternatives. Maybe we should add a dedicated timer handler instead of doing a JS click().
Comment #14
Nazmul Apu commentedHello, any update on this issue?
Comment #16
attisanPorted the last patch to the current dev and switched to requiring the npm-asset (using packagist) or manual library way as more and more modules are joining in on this approach (see branch).
Comment #18
golddragon007 commentedI would like actually to see how you would use it with composer this. Could you provide an example?
Comment #19
golddragon007 commentedi.e. I tried with this: but this will fetch a package which only contains the js files only and not within a dist directory:
(placed under "repositories" key in composer.json)
Comment #20
golddragon007 commentedOk, I managed to make it work with composer with this:
However, I think this can be part of the module's composer file and the require also.
While I tested, I noticed the fact that:
- when you are on the quiz view page, where you can see the summary of the quiz, the timer already counts backwards (it should start on the first question page)
- when the timer reaches 0 it tries to submit the quiz question in a fast way, but as the answers are required it only reloads rapidly the page endlessly
- after I take the quiz, and I want to retake I may not be able, as the counter does not reset
- for anonymous users, it wants from the beginning to submit before the time expires...
I also don't see how this timer will work on a quiz where the user can continue the quiz.
I guess drupal cache is not handled at all, but correctly I can't say where, but the default quiz module has cache issues I already noticed that.
Comment #21
smustgrave commentedWith there being an effort to get off jquery where possible now, is there a non jquery solution.
Comment #23
smustgrave commentedClosed #3444626: Implement countdown counter as duplicate
Comment #26
smustgrave commentedRebased for 7.0.x and fixed up some old and removed some crust.
Will still need a post update hook to add the new config setting
Also during testing noticed that when the time ends the page infinitely refreshes unable to submit as the question has no answer.
Comment #27
aaron.ferris commentedUpdated the MR with a post update hook to set
timer_formatComment #28
smustgrave commentedThanks! Now just need to figure out what's going on with that infinite refresh
Comment #29
aaron.ferris commentedCan confirm this behaviour, I can see the new JS fires the hidden 'finish' button, but each question type will fail validation.
Pushed a change that will resolve that although im not convinced it's the best way to do so, ive added a new triggering element the timer end JS can use that will limit validation.
Comment #30
aaron.ferris commentedComment #31
aaron.ferris commentedComment #32
aaron.ferris commentedNoticed some php notices, pushed a change.
Comment #33
aaron.ferris commentedComment #35
smustgrave commentedNice find @aaron.ferris.
I'm sure more issues will come out of this but initial testing appears to be working so going to merge.
Thanks everyone!
Comment #37
anaconda777 commentedHi,
Sorry but I am not able to patch current quiz 7.01 with any of these patches
Tried for example this:
"drupal/quiz": {
"quiz timer":"https://www.drupal.org/files/issues/2020-07-09/3157376-04.patch",
},
Wont apply, or is it still dev version which to use?