Random for LiaScript: Dynamic Quiz Banks and Randomized Practice Sets

Random for LiaScript: Dynamic Quiz Banks and Randomized Practice Sets

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 show n items, regardless of quiz state
  • true — 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 a 1-weighted item
  • 0: 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 browserYes — fully client-side
Server requiredNo
WeightingYes — data-propability attribute
Filter solvedYes — filterFlag=true
Session stableYes — via @Random.static
Per-visit freshYes — via @Random.random
LicenseMIT
MaintainedVersion 0.0.2

Try It

Try in LiaScript Open in LiveEditor View on GitHub
  • SpreadSheet — interactive spreadsheets with student-editable data tables
  • TextAnalysis — readability checks for teaching material quality
  • Survey — gather anonymous student feedback inside a course slide

Related Posts

lia-orthography for LiaScript: Spelling and Dictation Exercises

Create interactive spelling correction and dictation exercises in LiaScript with lia-orthography — inline correction, full-text editing with diff feedback, and narrated dictation gaps.

Read More

Fullscreen for LiaScript: Clean Presentation Mode Without the Navigation Bar

Use the Fullscreen template to automatically hide the LiaScript navigation bar when entering fullscreen mode — one import, zero configuration, clean presentations.

Read More

Speech-Recognition-Quiz for LiaScript: Turn Spoken Words into Interactive Quizzes

Use the Speech-Recognition-Quiz template to create spoken-answer quizzes in LiaScript — ideal for language courses, pronunciation training, and accessible learning without any server.

Read More