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...…
Sent from the XWiki- Users mailing list archive at
Nabble.com.