There is no way to enable the timer, because the module https://www.drupal.org/project/jquery_countdown referenced by this option is not ported to Drupal 8.

Issue fork quiz-3157376

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

nikkrop created an issue. See original summary.

djdevin’s picture

djdevin’s picture

Category: Support request » Task
Status: Active » Needs review
StatusFileSize
new27.69 KB

I 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.

hypertext200’s picture

StatusFileSize
new5.35 KB

This patch works with this D8 port from jQuery timer, https://www.drupal.org/project/jquery_countdown/issues/2261877#comment-1...

hypertext200’s picture

StatusFileSize
new6.47 KB

The last submitted patch, 4: 3157376-04.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

Status: Needs review » Needs work

The last submitted patch, 5: 3157376-05.diff, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

djdevin’s picture

Thank 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.

hypertext200’s picture

Yes, @djdevin. I tested your patch and it worked perfect, my code was also written based on that :).

nikkrop’s picture

Maybe 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.

djdevin’s picture

Yes, 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).

nikkrop’s picture

Also, 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.

djdevin’s picture

Yes...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().

Nazmul Apu’s picture

Hello, any update on this issue?

attisan made their first commit to this issue’s fork.

attisan’s picture

Assigned: Unassigned » attisan
Status: Needs work » Needs review

Ported 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).

golddragon007’s picture

I would like actually to see how you would use it with composer this. Could you provide an example?

golddragon007’s picture

i.e. I tried with this: but this will fetch a package which only contains the js files only and not within a dist directory:

        {
            "type": "package",
            "package": {
                "name": "hilios/jquery.countdown",
                "version": "2.2.0",
                "type": "drupal-library",
                "dist": {
                    "url": "https://github.com/hilios/jQuery.countdown/releases/download/2.2.0/jquery.countdown-2.2.0.zip",
                    "type": "zip"
                }
            }
        },

(placed under "repositories" key in composer.json)

golddragon007’s picture

Status: Needs review » Needs work

Ok, I managed to make it work with composer with this:

        {
            "type": "package",
            "package": {
                "name": "hilios/jquery-countdown",
                "version": "2.2.0",
                "type": "drupal-library",
                "dist": {
                    "url": "https://github.com/hilios/jQuery.countdown/archive/refs/tags/2.2.0.zip",
                    "type": "zip"
                }
            }
        },

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.

smustgrave’s picture

Version: 6.x-dev » 7.0.x-dev

With there being an effort to get off jquery where possible now, is there a non jquery solution.

smustgrave’s picture

smustgrave’s picture

Rebased 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.

aaron.ferris’s picture

Updated the MR with a post update hook to set timer_format

smustgrave’s picture

Assigned: attisan » Unassigned

Thanks! Now just need to figure out what's going on with that infinite refresh

aaron.ferris’s picture

Can 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.

aaron.ferris’s picture

Status: Needs work » Needs review
aaron.ferris’s picture

Status: Needs review » Needs work
aaron.ferris’s picture

Noticed some php notices, pushed a change.

aaron.ferris’s picture

Status: Needs work » Needs review

smustgrave’s picture

Status: Needs review » Fixed

Nice 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!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

anaconda777’s picture

Hi,
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?