Random for LiaScript: Dynamic Quiz Banks and Randomized Practice Sets
- André Dietrich
- Template , Tutorial
- May 28, 2026
A central challenge in self-paced learning is keeping practice fresh.
If students see the same 20 questions every time, they memorize positions rather than content.
The Random template adds controlled randomization to LiaScript: wrap exercises in <div class="random"> containers, and let the template pick a subset on each page visit.
Quick Start
<!--
import: https://raw.githubusercontent.com/liaTemplates/Random/main/README.md
-->
Macro 1: @Random.random(n, filterFlag) — Re-randomize Each Visit
Selects n items from the pool on every page visit.
Changing slides and coming back will pick a different selection.
@Random.random(2, false)
Macro 2: @Random.static(n, filterFlag) — Stable Within Session
Selects n items and keeps that selection stable as long as the browser session is open.
Refreshing the page may change the selection, but navigating away and back will not.
@Random.static(3, true)
The second parameter (filterFlag) controls filtering:
false— always shownitems, regardless of quiz statetrue— only include items that have not yet been solved (already-solved quizzes are hidden from the pool)
Defining the Pool: <div class="random">
Wrap each exercise or content block in a <div> with class="random".
Use data-propability (note: original spelling) to weight items:
<div class="random" data-propability="1">
<!-- normal weight item -->
What is 2 + 2? [[4]]
</div>
<div class="random" data-propability="3">
<!-- 3x more likely to be selected -->
What is the derivative of x²? [[2x]]
</div>
<div class="random" data-propability="0">
<!-- fallback: only shown when all other items are solved (with filterFlag=true) -->
You have solved all exercises! Well done.
</div>
The data-propability value is relative weight:
- Default (
1): equal probability 3: three times more likely to appear than a1-weighted item0: special fallback, shown only when the remaining pool is empty (all solved)
Full Example
<!--
import: https://github.com/liaTemplates/Random/README.md
-->
# Practice Quiz
Pick 2 questions from the pool (never the same two in a row):
@Random.random(2, false)
<div class="random" data-propability="1">
**Q1:** What is the speed of light in vacuum?
[[ 3 × 10⁸ m/s | 3 × 10⁶ m/s | 3 × 10¹⁰ m/s ]]
[[ (3 × 10⁸ m/s) | 3 × 10⁶ m/s | 3 × 10¹⁰ m/s ]]
</div>
<div class="random" data-propability="1">
**Q2:** What unit measures electrical resistance?
[[Ohm]]
</div>
<div class="random" data-propability="1">
**Q3:** What is Avogadro's number?
[[6.022 × 10²³]]
</div>
<div class="random" data-propability="0">
All questions solved! Review your notes and try again.
</div>
Try it live — each visit picks 2 different questions from the pool (reload to get a new pair):
Full Template Demo
Use Cases
Self-assessment modules — Let students practice from a large bank, seeing a fresh subset each session.
With filterFlag=true, already-mastered items disappear from the selection.
Exam preparation — Build a 50-question bank, show 10 per visit, with harder questions weighted higher.
Flashcard-style slides — Wrap vocabulary items as class="random" divs and show 5 per slide per visit.
Homework generation — Create a shared course with a large exercise pool; each student sees a different sample.
Technical Facts
| Runs in browser | Yes — fully client-side |
| Server required | No |
| Weighting | Yes — data-propability attribute |
| Filter solved | Yes — filterFlag=true |
| Session stable | Yes — via @Random.static |
| Per-visit fresh | Yes — via @Random.random |
| License | MIT |
| Maintained | Version 0.0.2 |
Try It
Try in LiaScript Open in LiveEditor View on GitHubRelated Templates
- SpreadSheet — interactive spreadsheets with student-editable data tables
- TextAnalysis — readability checks for teaching material quality
- Survey — gather anonymous student feedback inside a course slide