var retStatus = true;
var ccapiRet = "";
var dataStruct = StructNew();
dataStruct.ID = createUUID();
dataStruct.UserID = arguments.userid;
dataStruct.questionID = arguments.questionID;
dataStruct.vote = arguments.vote;
dataStruct.date = request.formattedtimestamp;
// Create the element record
ccapiRet = application.ptPoll.pollVoteDAO.set(dataStruct);
retStatus = ccapiRet.contentUpdated;
var retHTML = "result";
// Get the vote data
var voteData = buildVoteData(arguments.questionID);
// Get the question date
var qData = application.ptPoll.pollQuestionDAO.get(arguments.questionID);
var voteOptionsList = qData[1].values.voteOptions;
var voteQuestion = qData[1].values.question;
var keyList = StructKeyList(voteData);
var key = "";
#voteQuestion#
--->
#key#
#voteData[key].percent#%
Total Votes: #voteData.totalVotes#
var retVoteData = StructNew();
// Get the vote data
var voteData = application.ptPoll.pollVoteDAO.getByQuestionID(arguments.questionID);
var i = 1;
// Set the total votes
retVoteData.totalVotes = ArrayLen(voteData);
// Loop over the vote data
for ( i=1; i LTE ArrayLen(voteData); i++){
currVote = voteData[i].values.vote;
// Check if the key exists
if ( StructKeyExists(retVoteData, currVote) ){
// New key, so add it in
retVoteData["#currVote#"].count++;
}
else
{
// New key, so add it in
retVoteData["#currVote#"] = StructNew();
retVoteData["#currVote#"].count = 1;
}
retVoteData["#currVote#"].percent = application.ptPoll.data.decimalRound(retVoteData["#currVote#"].count/retVoteData.totalVotes, 2) * 100;
}
var retDocHTML = "";
// Get the poll vote data from the view table
var pollDataQry = application.ptPoll.pollVoteDAO.getPollDataCountView();
// Create the export object
var excelObj = CreateObject( "component", "ADF.apps.pt_poll.components.hooks.ObjectToExcel" ).init();
var params = StructNew();
params.localeDates = false;
params.autoFilter = true;
params.worksheetNames = "Poll Votes";
#excelObj.processObj( pollDataQry, params)#