Hi,

It would be great if Quiz can be loaded only once when user start the quiz, then all data (quiz questions, user answer) is saved temporary on user local storage. And then when user finished the quiz, user save the data from local storage to server. I think this idea will reduce the server load/user and server interaction because quizzes downloaded only once at the beginning.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

dadangnh created an issue. See original summary.

djdevin’s picture

Wouldn't the user be able to peek at the quiz answers, by looking at local storage?

dadangnh’s picture

No, I mean the server just send the questions and answer (for multi choice,etc) without knowing which answer is correct. After user upload the answer, processing the answer is still happened on the server side. It is like download and save some node content to local storage, then when user make a choice/answer, user answer is also saved on the lcoal storage until user finished the quiz. Then, when user click finish, user answer is uploaded from local storage to drupal and Quiz process the scoring. Can we do something like that?

djdevin’s picture

Really not sure if you could, and I don't know if it would work with all question types.

Patches welcome though!

4d2e’s picture

Here I'm trying make some patch for localstorage on multiple choice question. (I used 7.x-5.0-beta2). It's should work for site that have microcache.

4d2e’s picture

FileSize
3.16 KB
4d2e’s picture

djdevin’s picture

Thanks for the patch, however

1. It's bad practice to use PHP or put Javascript inside of a theme template
2. This needs to work for all questions if it is to be accepted into the Quiz project. You can create your own sandbox if you want to, or an extension module.

How are you handling the server-level validation? (For example, so that the user cannot advance to the next question until they answer the first one?)

4d2e’s picture

thanks for your advice.

right now, it's just a support to site that use microcache and that localstorage have no connection to server.

in my case, the site with microcache and have a quiz that allow backward navigation, when the user back to the previous question the answer is still blank, even if the user already answer it.

so the localstorage that i wrote is for tricking this case, so the answer is checked when the user back to that question.