Skip Navigation

[Resolved] Create multiple choice quiz and save user answers

This thread is resolved. Here is a description of the problem and solution.

Problem:

I'm trying to display a set of multiple-choice tests, each one with its own submit button. For each test, on submit, I must save the user's answer and give them feedback on whether or not it is correct.

Solution:

It is possible with little custom JS codes, see detail here:

https://toolset.com/forums/topic/create-multiple-choice-quiz-and-save-user-answers/#post-2131307

Relevant Documentation:

This support ticket is created 3 years, 10 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Hong_Kong (GMT+08:00)

This topic contains 2 replies, has 2 voices.

Last updated by larissaG 3 years, 10 months ago.

Assisted by: Luo Yang.

Author
Posts
#2130985

Tell us what you are trying to do?

I'm trying to display a set of multiple-choice tests, eacho one with its own submit button. For each test, on submit, I must save the user's answer and give them feedback on whether or not it is correct. The available answers for each test are currently represented as fields of the "question" post type (as opposed to a separate "answer" type), and should be displayed as radio buttons so the user can select only one. There's also a field that stores which answer is correct. The tests must be displayed in sets based on a filter on a many-to-many relationship with another post type.

1. How can I show the answers as group of radio buttons? I tried to import them as radio buttons using tha All Import plugin, but they all just show as "Option title 1", instead of the actual text for each answer.

2. How can I save the answer for each question submitted by each user?

3. How can I give the user feedback whenever they submit their answer?

Is there any documentation that you are following?
https://toolset.com/documentation/programmer-reference/cred-api/

Is there a similar example that we can see?
hidden link
In Portuguese. Not powered by wordpress, but that's the general idea.

What is the link to your site?
hidden link

#2131307

Hello,

I assume we are talking about custom radio field created with Toolset Types plugin.
Q1) You can display a post form for editing the "answer" post:
https://toolset.com/course-lesson/front-end-forms-for-editing-content/
So it will display as radio field in front-end, then use JS codes to disable them to users, for example:

jQuery(document).on('cred_form_ready', function(){
	jQuery("input:radio").attr('disabled',true);
});

In your case, do not display the "Submit" button in the post form, so users can not submit and edit the "Answer" post

Q2) You can setup a post form for creating new "answer" post, after user submit this form, the new post author is the user who submitted the form.

And you can create a page "My answers", in this page, setup a post view:
- Query "Answer" post
- Filter by post's author is same as logged-in users
https://toolset.com/documentation/user-guides/views/filtering-views-query-by-author/
- In views loop, display the "answer" post information

Q3) In the editing post form of Q1), you can use [wpv-conditional] shortcode to display different feedback on the field values, see our document:
https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-conditional

#2137057

My issue is resolved now. Thank you!