Hi and thanks for all of your help.
I followed your Custom Quiz video on youtube. Awesome - thanks.
I want users to be able to come back to the quiz and start where they left off. Since we are storing their answers in CMS, shouldn't we be able to populate with their previous answers when they return?
Or something? I just want answers to persist for the user until they return and resubmit...
Thanks!
Mark
Hi Mark,
Great question! In order to load the quiz where they left off you will have to take several steps: 1. Decide how you are going to determine which quiz to load. Is it by _owner (memberId) or some other identifier. If it's member Id you can get that using the Wix members frontend or backend API.
import {currentMember} from 'wix-members-frontend'; //later const member = await currentMember.getMember(); const memberId = member._id;
2. Next you will need to query the Quiz collection to get the users quiz data. Something like:
import wixData from 'wix-data'; //later const quizQueryResult = await wixData.query("QuizCollection").eq("_owner", memberId).find(); const quizData = quizQueryResult.items[0];
3. Finally you will need to populate the quiz UI with the data. For example:
$w("#quizElement1").value = quizData.question1; $w("#quizElement2").value = quizData.question2;
Hope that helps!
Best,
Eitan