Developing with surveys

2019-10-08 15:24:00.0

Surveys allow you to capture data from users in a form which can be reported on as survey results.

At the time of writing Kademi does not have a survey form builder, but you can use any html form. This guide shows you to create surveys (and polls)

First you need to create a "reward". A reward is a generic term which represents any competition, poll, survey, etc.

Select the Survey/Quiz check box on the Entry form tab

And be sure to make the survey "Active" in the status field. Then we're good to go!

So now lets have a form. Here's a very simple page to do that:



Survey form example





There are three things to remember when creating the form:

  • The form action should be /rewards/[reward name]
  • The form must contain an input named "entry" to trigger the submission
  • Fields you want to capture must have the prefix of "answer", for example name="answer-pet-name"

So now you're submitting happily away, the next question is how to retrieve results? You can:

  • get poll results by ajax, where you get a number of submissions for each answer
  • get the answers for the current user by ajax
  • get a list of all submissions in templating

To get the current user's answers you simply request the myAnswers property through the dav gateway with a URL like this:




Similarly you can get poll results by requesting the pollResults (for single question polls) and allPollResults properties


You can access the entire list of submissions from templating like this:

		#foreach( $sub in $page.submissions)
		$sub.profile.firstName - $sub.answers.get("answer-pet-name")