After a user has replied a question, his answer and the feedback will be cached. If the user does not click the reset button, these values will re-appear even after the page refreshes.

Is it possible to clear these cached values either on clicking the reset button or on each page refreshing?

Thanks in advance for your help.

Comments

HylkeVDS’s picture

The answer of the user is not really "cached", it's stored in the database on purpose so the user does not lose his work/progress when navigating away from the site, or on a browser crash.

Clicking the reset button clears the stored answer.

danny1997’s picture

Status: Active » Closed (works as designed)

Thanks for your reply.

So it is by design to keep the answers stored. You've got reasons to do that. But still ... if we could change it in the settings, it would be perfect!

tranquillus’s picture

Just my .02. I too would prefer it if there were a way to have it clear and reset on leaving or refreshing the page. Is there something we could change ourselves in the files that would allow this?

HylkeVDS’s picture

You can comment out the 2 update and 1 insert call in CqUserAnswerDefault.class.php on lines 145, 151 and 154. Of course that will disable saving for all questions in your entire site.

If you also want to disable logging, you can comment out lines 158 till 167

Would you want a setting to not store answers to be set in the question, or for a whole site?

danny1997’s picture

At the moment, compared to the questions in your demo sites, the questions on my site are much simpler and it's not necessary to store answers for a user to continue later. The purpose of these questions are learning, not testing. So DB logging is not really necessary.

A setting for all site would be sufficient.

Thanks.

tranquillus’s picture

A whole-site setting would be fine for me as well. I'm also just using it for small learning-quiz questions. I tried commenting out those lines you mentioned, but the refresh behaviour is still the same. I could very well be doing it wrong though. :)

danny1997’s picture

For these questions that you had done before, you must click the reset button first to clear the stored values.

Then try again. Afterwards, you will get all answers and feedback cleared on each page refresh.

tranquillus’s picture

Okay, tried it again...this time after I reset and cleared the cache, it works great, but only when I'm logged in to drupal. As soon as I log out, it no longer resets on refresh, no matter how many times I clear the cache. Weird. I guess I'm halfway there. :)

HylkeVDS’s picture

Ah, yes, for users that are not logged in the data is stored in the session. To stop that, you need to comment out line 176:
$_SESSION['cq']['answers'][$this->nodeId] = $row;

tranquillus’s picture

Oh, thank you so much! It's working great now. :)

m_i_c_h_a_e_l’s picture

I have a question about this. I still need the session and database logging (for tracking purposes). But even after resetting the question, the field still offers "suggestions" as soon as the user starts typing, based on text previously entered into the field. As far as I know, this is a browser autocomplete function.

Like most of you, I'm using this wonderful module as a learning tool, and it kind of defeats the purpose to have the browser suggest answers.

I need it to:

1. Show an empty answer field at all times (even if you have previously answered the question), and

2. Disable the autocomplete function for this field, so it doesn't bring up a dropdown list of previous attempts as soon as you type the first letter.

Asking my users to disable their browser's autocomplete setting is not practical. I have a suggestion, but I'm not a programmer, so I don't know if it's feasible:

There is another great module called drupal.org/project/clear_password_field, which uses jquery to prevent the password field from being autopopulated. It doesn't affect the database at all. It just shows an empty field.

I wonder if you might be able to do something similar with Closed Question?

By the way, I'm still using drupal 6, and CQ version 6.x-1.9 (for now).

Thanks again for such a great module.

HylkeVDS’s picture

Assigned: Unassigned » HylkeVDS

Good idea, I had not thought of that problem yet. This is a separate issue though, so any further post should go into a new issue.

The clear_password_field method won't work, as the answer won't be pre-filled in. The hints will only show once the user starts typing. But apparently there is the html5 tag autocomplete="off" that can be added to forms. I'll look into this.