-
MathType
-
WirisQuizzes
-
Nubric
-
CalcMe
-
MathPlayer
-
Store FAQ
-
MathFlow
-
BF FAQ
-
Miscellaneous
-
Wiris Integrations
Understanding Algorithm Mode in Nubric
Reading time: 3minAlgorithm Mode in Nubric allows you to apply advanced logic to mathematical questions using controlled randomization, conditional rules, loops, and custom functions. You can create reusable question templates that generate multiple valid variations while preserving your teaching objectives.
What It Is
Algorithm Mode is the tool where you write algorithms to control how Nubric questions are generated. The term advanced logic describes the mathematical relationships, conditions, and constraints you define through those algorithms.
Instead of manually writing each question variation, you define:
- Variables.
- Mathematical relationships.
- Conditions.
- Constraints.
Nubric evaluates the algorithm to generate question variations according to those definitions. Writing advanced logic in Algorithm Mode is similar to using a lightweight programming language within your question. Algorithm Mode supports:
- Random value generation.
- Conditional statements.
- Loops.
- Mathematical functions.
- Vector and matrix operations.
- Custom function definitions.
Algorithm Mode is designed specifically for creating mathematical questions rather than general-purpose software development.
Why It Matters
Creating question variations manually can require teachers to:
- Write multiple versions of the same exercise.
- Check that the difficulty remains consistent between variations.
- Handle unwanted cases, such as irrational roots, invalid fractions, or systems without a unique solution.
Applying advanced logic through Algorithm Mode allows you to:
- Control mathematical properties, such as requiring integer solutions.
- Avoid undesired outcomes, such as zero denominators or non-square discriminants.
- Enforce constraints that support your teaching objectives.
- Generate multiple variations from a single question template.
These controls help maintain question quality, reduce repetitive work, and support consistent assessment across variations.
How It Works
Nubric evaluates the algorithm you define in Algorithm Mode when generating a question. A typical algorithm follows the structure described below, although the execution order depends on how you write it.
Stage 1: Variable Initialization
Define the initial variables in Algorithm Mode. For example, your algorithm can:
- Generate random numbers.
- Define sets.
- Initialize matrices or vectors.
Variables needed to display the question are computed before it is rendered.
Stage 2: Constraint Enforcement
Use conditions and loops in your algorithm to enforce the required mathematical constraints. Common mechanisms include:
-
whileloops. -
repeat … untilloops. - Logical conditions using operators such as
&&and||.
For example, you can write a loop that regenerates values until a condition is satisfied. This allows you to require properties such as:
- Coprime numbers.
- Perfect square discriminants.
- Non-zero determinants.
These constraints must be explicitly defined in your algorithm; Algorithm Mode does not infer them automatically.
Stage 3: Derived Calculations
Once valid initial values are established, calculate the values that depend on them. Examples include:
- Computing solutions.
- Building matrices.
- Calculating right-hand side vectors.
These derived variables can be used to define the expected answers and support answer validation.
Stage 4: Rendering and Grading
After the algorithm has been evaluated:
- The question statement is rendered using the computed variables.
- When students submit their responses, Nubric evaluates them against the configured answers.
- The configured grading rules are applied.
Students see the resulting question rather than the algorithm defined in Algorithm Mode.
Key Rules or Behaviours
- The algorithm used to generate the question is evaluated before the question is displayed.
- Loops must terminate. An infinite loop prevents the algorithm from completing and the question from being generated.
- Variables defined later in the algorithm can depend on earlier definitions.
- Excluding unwanted values, for example with
/[0], helps avoid invalid mathematical cases. - Deterministic calculations produce the same results when given the same input values.
Examples
Controlled Random Fractions
In Algorithm Mode, generate two fractions and use advanced logic to require each numerator and denominator pair to be coprime. The resulting fractions are always irreducible.
Guaranteed Integer Solutions
Define an integer solution vector and an invertible coefficient matrix, then calculate the corresponding right-hand side vector. This constructs a system with the intended unique integer solution.
Common Misunderstandings
Algorithm Mode and advanced logic are separate tools
Algorithm Mode is the tool you use in Nubric. Advanced logic describes the rules, calculations, and constraints you write within it to control question generation.
Using Algorithm Mode requires general-purpose software development
Algorithm Mode uses programming concepts, such as variables, conditions, and loops. Its purpose is to define the mathematical behavior of questions rather than develop standalone software.
Random values cannot be controlled
The values can vary while still satisfying the mathematical properties you define. Use constraints and validation loops to control which variations are allowed.
Loops are inherently unreliable
Loops can enforce mathematical constraints reliably when the conditions are achievable and the algorithm is designed to terminate.