Wiris

Documentation / LearningLemur

  • Demos
  • Visit our website
  • Contact us
  • MathType

    • WirisQuizzes

      • Nubric

        • CalcMe

          • MathPlayer

            • Store FAQ

              • MathFlow

                • BF FAQ

                  • Miscellaneous

                    • Wiris Integrations

                      • Home
                      • Nubric
                      • Using Nubric
                      • Advanced Logic in Nubric
                      • Advanced Logic in Nubric

                      Understanding Advanced Logic in Nubric

                      Reading time: 2min

                      Advanced Logic in Nubric allows you to generate dynamic mathematical questions using controlled randomization, conditional rules, loops, and custom functions. It enables teachers to create robust, reusable question templates that automatically produce multiple valid variations while preserving pedagogical intent.

                      What It Is

                      Advanced Logic is the rule-based engine that powers dynamic question generation in Nubric. Instead of manually writing each question variation, you define:

                      • Variables.
                      • Mathematical relationships.
                      • Conditions.
                      • Constraints.

                      The system then automatically generates consistent, mathematically valid problem instances. Advanced Logic is conceptually similar to using a lightweight programming language inside your question. It supports:

                      • Random value generation.
                      • Conditional statements.
                      • Loops.
                      • Mathematical functions.
                      • Vector and matrix operations.
                      • Custom function definitions.

                      It is designed specifically for educational use, not general-purpose programming.

                      Why It Matters

                      Without Advanced Logic, teachers would need to:

                      • Manually create multiple versions of the same exercise.
                      • Risk inconsistent difficulty between variations.
                      • Lose control over edge cases (e.g., irrational roots, invalid fractions, non-unique systems).

                      Advanced Logic solves these problems by allowing you to:

                      • Control mathematical properties (e.g., "solutions must be integers").
                      • Avoid undesired outcomes (e.g., zero denominators, non-square discriminants).
                      • Guarantee pedagogical constraints.
                      • Scale a single question into unlimited variants.

                      This increases question quality, reduces repetition, and improves assessment fairness.

                      How It Works

                      Advanced Logic executes in stages when a question is generated.

                      Stage 1: Variable Initialization

                      The system evaluates all variable definitions in the algorithm section. Example conceptual actions:

                      • Generate random numbers
                      • Define sets
                      • Initialize matrices or vectors

                      All variables are computed before the question is rendered.

                      Stage 2: Constraint Enforcement

                      If your logic includes loops or conditions, the system ensures that mathematical constraints are satisfied. Common mechanisms include:

                      • while loops
                      • repeat … until loops
                      • Logical conditions (&&, ||)

                      If a condition is not met, the system regenerates values until the constraint is satisfied. This is how you guarantee properties such as:

                      • Coprime numbers
                      • Perfect square discriminants
                      • Non-zero determinants

                      Stage 3: Derived Calculations

                      Once valid variables are established, dependent values are computed. Examples:

                      • Computing solutions
                      • Building matrices
                      • Calculating right-hand side vectors

                      These derived variables are typically used for grading or answer validation.

                      Stage 4: Rendering and Grading

                      After all logic is evaluated:

                      • The question statement is rendered using computed variables
                      • Student responses are compared against the defined solution logic
                      • Grading rules are applied

                      The logic is executed on the server and is not visible to students.

                      Key Rules or Behaviours

                      • Logic is executed before the question is displayed.
                      • All constraints must terminate — infinite loops will prevent question generation.
                      • Variables defined later in the algorithm can depend on earlier ones.
                      • Zero exclusion syntax (e.g., /[0]) prevents invalid mathematical cases.
                      • Deterministic logic produces reproducible results per attempt.

                      Examples

                      Example 1: Controlled Random Fractions.
                      You generate two fractions but enforce coprime numerator/denominator pairs. Result: Fractions are always irreducible.

                      Example 2: Guaranteed Integer Solutions.
                      You first define a solution vector and then compute the coefficients backward. Result: The generated system always has the intended solution.

                      Common Misunderstandings

                      Misconception: Advanced Logic is programming.
                      Clarification: It uses programming-like syntax, but its purpose is mathematical control, not software development.

                      Misconception: Random automatically means unpredictable.
                      Clarification: Random values can be fully controlled through constraints and validation loops.

                      Misconception: Loops are risky.
                      Clarification: Loops are safe when intervals are properly designed, and termination conditions are guaranteed.

                      Related Concepts

                      • Common Patterns and Best Practices
                      • Advanced Logic Examples in Nubric
                      • Glossary of Commands

                      Was this article helpful?

                      Give feedback about this article

                      Related Articles

                      • Programming
                      • Improvements

                      Understanding Advanced Logic in Nubric

                      What It Is Why It Matters How It Works Stage 1: Variable Initialization Stage 2: Constraint Enforcement Stage 3: Derived Calculations Stage 4: Rendering and Grading Key Rules or Behaviours Examples Common Misunderstandings Related Concepts

                      Empowering STEM education

                      MathType

                      • Office Tools
                      • LMS
                      • XML
                      • HTML

                      WirisQuizzes

                      Learning Lemur

                      Integrations

                      Solutions

                      • Education
                      • Publishing houses – platforms and interactive
                      • Publishing houses – Print and digital
                      • Technical writers

                      Pricing

                      Downloads

                      Blog

                      • Success stories

                      About us

                      • Careers
                      • Partnership

                      Contact Us

                      Contact Sales

                      European union (European Regional Development Fund) and 1EdTech (TrustEd Apps Certified)
                      • Cookie Policy
                      • Terms of Use
                      • Privacy Policy / GDPR
                      • Student Data Privacy
                      • Compliance
                      • Cookie Settings

                      © Wiris 2026

                      Expand