A self-paced practice quiz

This Qube Script example asks three questions, calculates a score and shows feedback. It runs locally in QUBE Survey Workbench without an AI service.

Save the source as objective-quiz.qube, open it in VS Code and run QUBE: Run Interview. See Getting started with Qube Script for setup and uploading an immutable version.

@survey objective_quiz @language en @mode cawi
 
value MAX_SCORE = 3
value PASS_SCORE = 2
 
function quiz_score() returns integer
let total integer = 0
if answers.cards == 2 then total += 1 end
if answers.next_number == 8 then total += 1 end
if answers.finish_time == 2 then total += 1 end
return total
end
 
@question introduction display
# A short practice quiz
 
Answer three questions. Each correct answer earns one point. The practice
target is {PASS_SCORE} out of {MAX_SCORE}.
 
Read the feedback and use Back to revise answers before finishing.
 
@question cards single
A fictional club puts four cards in each pack. How many cards are in three packs?
@options
  1: 8 cards
  2: 12 cards
  3: 16 cards
 
@question next_number integer
The sequence increases by two each time: 2, 4, 6. What number comes next?
 
@question finish_time single
A fictional club meeting starts at 10:00 and lasts 20 minutes. When does it finish?
@options
  1: 10:10
  2: 10:20
  3: 10:30
 
@question result display
## Your result
 
Score: {quiz_score()}/{MAX_SCORE}
 
Practice target: {PASS_SCORE}/{MAX_SCORE}
 
@question passed_feedback display @if quiz_score() >= PASS_SCORE
You met the practice target.
 
Review the answers: three packs contain 3 × 4 = 12 cards; the next number is 8;
the meeting finishes at 10:20.
 
Use Back to revise an answer, or Continue to finish this attempt.
 
@question retry_feedback display @if quiz_score() < PASS_SCORE
You have not met the practice target yet.
 
Review the answers: three packs contain 3 × 4 = 12 cards; add two to 6 to get 8;
add 20 minutes to 10:00 to get 10:20.
 
Use Back to revise answers before finishing. A later try needs a new attempt
if the Run permits one.
 
@outcome complete
This practice attempt is finished.

Change the questions and scoring

Each correct answer earns one point. The maximum is 3; the practice target is 2. Change the question text, options, correct-answer comparisons, MAX_SCORE, PASS_SCORE and feedback together. quiz_score() recalculates a fresh total from the current answers. Going Back to change an answer recalculates the score and feedback without awarding extra points.

Both feedback paths finish through complete. Finishing an attempt and meeting its practice target are separate facts. For hosted collection, configure the Run’s completion mapping to retain finished attempts, including attempts below the target, and test with invented participant data before opening access. Started attempts retain their script version when you upload a new one.

A later try requires a new attempt permitted by the Run’s access and attempt policy. The script does not reset a finished attempt or grant retries.

Answers and results

Participants can inspect the source, correct answers and results. Use this recipe for practice with visible feedback. It does not provide confidential exam marking.

Standard answer exports contain the three participant answers. The calculated score, maximum and pass status appear on screen; they are not stored grade fields or additional export columns. To analyse results, recompute the score from the retained answers using their original script version and scoring rules.