devilsbibble / django-survey

Automatically exported from code.google.com/p/django-survey
0 stars 0 forks source link

A survey having been taken is tied only to the session.. and is easy to work around (and can be confusing.) #30

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
The issue is that we need surveys that can only be taken once by any one 
authenticated user.
However, the session key is used to determine if a user has taken the survey or 
not.

If a user logs out and then logs back in, they will no longer be considered to 
have taken the 
survey. I can see where using the session id works somewhat for anonymous users 
and this way 
you only have to worry about one mechanism for seeing if a survey has been 
taken.

However, this method seems exceptionally fragile. In our case, we want our 
users to take some 
surveys only once. Once they have taken them, we do not want them to be able to 
see the survey 
again. The curious thing is this is not because we can not trust them to try to 
jack the survey 
results, but they are trained to take a survey when they see it.

As it is now, they log out.. they come back later, or on a different machine, 
they see the survey 
again. They are a little bit confused, but since they can see the survey they 
figure that they must 
take it again, and do so.

I wager this is likely to be met with resistance, but I think for authenticated 
users you should use 
the user as the determining factor of whether they have taken a survey already.

The way I worked around it for our case was to add a 'has_answers_from_user' 
method to the 
survey model, and if the user is authenticated then check 
'has_answers_from_user' after checking 
'has_answers_from()' in 'survey_detail' in views.py at line 85.

This is based on subversion revision 92.

Original issue reported on code.google.com by scan...@gmail.com on 28 Oct 2008 at 3:52

GoogleCodeExporter commented 9 years ago
Here is the modification I am using to get the behaviour I mentioned above

Original comment by scan...@gmail.com on 28 Oct 2008 at 4:00

Attachments:

GoogleCodeExporter commented 9 years ago
The modification that you propose there sounds very reasonable to me. It would 
be
nice if next time that you submit a patch that bring new capability you could 
add
some tests.

Thank you for your recent contributions.
--yml

Original comment by yann.ma...@gmail.com on 30 Oct 2008 at 2:01

GoogleCodeExporter commented 9 years ago
Hi,

This issue insn't fixed for last revision in trunk (rev115)

Here is patch with tests. Hope it can be usefull.

Original comment by charpent...@gmail.com on 28 Oct 2009 at 6:32

Attachments: