Kevin
The main thing I'm trying to determine at this
point is if
I can't require someone to have an account in order to vote,
how do I keep them from voting multiple times? I can't use cookies,
and I'm not sure using their IP address will prove of any use.
Even if users do have to register in order to vote, I'm not sure
there's an API method available that allows me to access their
unique user ID as opposed to their user name. If I have to track
usernames on each of these objects for all of the people who have
ever voted on a particular question it could get out of hand
really fast!
Any ideas?
Not sure if storing IDs instead of usernames makes much difference.
Also IP addresses will change but maybe not that often.
Just thinking but perhaps you could create a new property in your page
class and add username to it each time someone votes.
Then on load (view mode) you can get this list of usernames as an array
and loop to check if current user already in there. If so then do not
show the vote form.
Ajdin
-----Original Message-----
From: users-bounces(a)xwiki.org [mailto:users-bounces@xwiki.org] On Behalf
Of KevinC
Sent: 22 January 2009 12:54
To: users(a)xwiki.org
Subject: Re: [xwiki-users] Adding survey question and details to page
template...
Ajdin,
You are absolutely right, especially since there seem to be so few
people posting information from a users perspective. So here's what I
did.
The key to getting it working was an example I found in the snippets
section that talked about how to create new documents with Tags. It
showed an example of how to check if there was an instance of a certain
class already attached to a document and create one if not (I already
knew how to do this more or less). The important piece was how to set a
property on that object once you have a handle to it. I don't have the
code done completely yet but the basic shell is something like:
#set($surveyObj = $doc.getObject("CPA_FAQs.SurveyClass"))
#set($surveyChoice = $request.getParameter("surveyChoice"))
#if(!$surveyObj)
##Create a new survey object and attach it to this document.
#set($sObj = $doc.newObject("CPA_FAQs.SurveyClass"))
$sObj.set("votetotal", $voteCnt) ## these are just here as an example
$sObj.set("voters", $voters) ## as I haven't even created the
Survey
class yet
$doc.save()
#end
#if($surveyChoice)
## Need to update the objects values here #end ## If the current user
has voted don't allow them to vote again
Was this information useful to you?
<form action="${doc.getURL()}" method="POST"
style="display:
inline">
<input name="surveyChoice" type="radio" name="Yes"
value="Yes"/>Yes
<input name="surveyChoice" type="radio" name="No"
value="No"/>No
<input type="submit" value="Submit"/>
</form>
I still need to implement a few things but I know should work for what I
need.
The main thing I'm trying to determine at this point is if I can't
require someone to have an account in order to vote, how do I keep them
from voting multiple times? I can't use cookies, and I'm not sure using
their IP address will prove of any use. Even if users do have to
register in order to vote, I'm not sure there's an API method available
that allows me to access their unique user ID as opposed to their user
name. If I have to track usernames on each of these objects for all of
the people who have ever voted on a particular question it could get out
of hand really fast!
Any ideas?
Thanks!
.:. Kevin
--
View this message in context:
http://n2.nabble.com/Adding-survey-question-and-details-to-page-template
...-tp2192675p2197567.html
Sent from the XWiki- Users mailing list archive at
Nabble.com.
_______________________________________________
users mailing list
users(a)xwiki.org
http://lists.xwiki.org/mailman/listinfo/users
--------------------------------------------------------
NOTICE
This message and any files transmitted with it is intended for the addressee only and may
contain information that is confidential or privileged. Unauthorised use is strictly
prohibited. If you are not the addressee, you should not read, copy, disclose or otherwise
use this message, except for the purpose of delivery to the addressee.
Any views or opinions expressed within this e-mail are those of the author and do not
necessarily represent those of Coventry University.