Forum for discussing general topics related to Couch.
5 posts Page 1 of 1
I am trying to build a "quizzing" application using couch.

Each quiz question will have multiple answers, each of which will be displayed via a radio input on the quiz page. I do not know what the questions or possible answers will be ahead of time.

I need to record the selected answer for each question. Is this possible with DataBound forms?

Each user answering questions will be authenticated using the 'members' module, if that helps. I'm wondering if I can create a 'repeatable' section there named 'question answers' and then populate that with the answers given.

Any help would be appreciated.
Hi,

I think one way of doing it could be this -

1. Use a clonable template, say named 'questions.php'.

2. Each question in the quiz will be represented by a cloned page of this template so define the regions required for holding the question and the four answers -
a. The title field may be used to hold the question text (or you can define a separate textarea for this purpose).

b. For the answers - use a repeatable region (http://www.couchcms.com/docs/concepts/r ... gions.html) where each row would be an answer. Each row could consist of a 'text' region to hold the content and also a dropdown or radio with two values 'correct' and 'incorrect'. The default would be 'incorrect' so manually assign any one of the row the 'correct' status.

3. Finally on the frontend - we'll show each page as a question and (this could be a little tricky) loop through the repeatable regions to create a form with radio buttons (the 'Poll' module uses a similar technique that could serve as a guide - viewtopic.php?f=5&t=8133).

4. Upon submission of form, we loop through the repeatable region to find the row with 'correct' value and check if the answer matches that row.

5. The result of quiz as the user progresses through the questions can be keep in "session variables" (discussed at viewtopic.php?f=5&t=7377).

One piece that remains would be randomize the question set. We can use a bit of PHP when the quiz begin to randomize the ids of questions and store them in session. This then is used to decide which question to show at each step.

So, yes, it can be done but it'll require a little bit of effort.

Hope this helps.
Thanks for the advice KK, and I'd like to compliment you on creating such a great piece of software!

One thing I did not mention (because I forgot) was the need to store the result of the quiz(s) long term and run reports (outside of couch if needed) on a per user basis. This is where I was going with the idea of storing the answers as a repeatable region inside the 'members' module. Do you think this will work or can you think of a better way to do it?

Also, each quiz is on one page, so I was going to just loop through all of them and use the 'random' orderby tag. Do you think that will work?
Thank you for the compliment :)

Replying to your query -
each quiz is on one page, so I was going to just loop through all of them and use the 'random' orderby tag. Do you think that will work?
Shouldn't be a problem. cms:pages tag can be made to loop and show multiple pages on a single front-end page.

need to store the result of the quiz(s) long term ..
Will a member ever take only a single quiz? If so, we can store the results with the member page itself. Else, I suggest you use a separate template to store the results and use 'relationships' (http://www.couchcms.com/docs/concepts/r ... ships.html) to relate members with all quizzes they have taken.

..and run reports (outside of couch if needed) on a per user basis.
Now this one is tricky. It can be done but will likely require resorting to PHP. Not sure how complex your reporting needs are but since Couch does not store data in the form of 'one table per template' and instead uses EAV (Entity Attribute Values) data model, formulating queries for reports will be complex.

Hope this answers your queries.
While members will take multiple quizzes, we will only ever need to record the answers for the "final" quiz, so I think this will work. Any tips on how to store the data in this repeatable field?

The reporting can be done using PHP (I am actually very well versed in PHP). Could I at least use custom admin screens to display the reports?
5 posts Page 1 of 1