I wanted to add the option for a timeout between attempts. It was very tricky to add this feature with hooks in a custom module. I added it directly to the quiz module and created a patch. You may consider bringing it into the next release?
You would need to add something to it, though, to add the 'timeout' column to the 'quiz_node_properties' table in the database. I just enabled the module, post patch, on a database that never had quiz installed before on it. I would also suggest adding a column for a 'next_attempt' timestamp, or something similar, to make the function _quiz_get_next_allowed_attempt() in quiz.module more performant.
Please let me know if you have any questions.
Peace
Comment | File | Size | Author |
---|---|---|---|
Screen Shot 2019-06-25 at 11.13.39 AM.png | 34.78 KB | genellann | |
Screen Shot 2019-06-25 at 11.04.06 AM.png | 52.48 KB | genellann | |
Screen Shot 2019-06-25 at 11.11.55 AM.png | 104.8 KB | genellann | |
quiz-timeout.patch | 6.12 KB | genellann | |
Comments
Comment #2
djdevinTake a look at quiz.api.php
In that file there is an example of implementing your own access handler using hook_quiz_access() - you can use this to add your own functionality to restrict quiz taking based on whatever criteria you need.
If you wanted to add this as feature it needs some work - there's no tests and you have a lot of redundant code for handling the time limit. Take a look at how Quiz does it by using timeperiod. Also, you should use the access system that Quiz already has instead of trying to do it in a nonstandard way.
Comment #3
djdevinFor reference
Use timeperiod:
https://git.drupalcode.org/project/quiz/blob/7.x-5.x/quiz.admin.inc#L83
Quiz access:
https://git.drupalcode.org/project/quiz/blob/7.x-5.x/quiz.api.php#L155
Comment #4
genellann CreditAttribution: genellann at On Fire Media commentedThank you so much. For the quick reply, wow. And for pointing me in a better direction.
Comment #5
djdevinYou're welcome!
I'll leave this open as a feature request to see if there's any interest.
Comment #6
genellann CreditAttribution: genellann at On Fire Media commentedCan you tell me, please, how to add to the settings array in _quiz_get_node_defaults()?
Comment #7
djdevinHere's an example, a module that adds a configuration: https://git.drupalcode.org/sandbox/devin-3008617/blob/master/quiz_answer...