Wiris

Documentation / WirisQuizzes

  • Demos
  • Visit our website
  • Contact us
  • MathType

    • WirisQuizzes

      • Nubric

        • CalcMe

          • MathPlayer

            • Store FAQ

              • MathFlow

                • BF FAQ

                  • Miscellaneous

                    • Wiris Integrations

                      • Home
                      • WirisQuizzes
                      • Getting Started
                      • WirisQuizzes User Interface

                      Random variables section

                      Reading time: 4min

                      The Random variables section is at the core of many of WirisQuizzes capabilities. You can make questions dynamic by adding random variables to the question's statement and to the Correct answer field accordingly. If your question only involves integer independent variables, you can use the Basic mode to define these values easily.

                      basic_mode.png

                      On the other hand, if you want to generate a more complex algorithm, you need to use the computer algebra system (CAS) by clicking on the Advanced mode button.

                      advanced_mode_button.png

                      If you're familiar with CalcMe, then you have a head start. If not, it's easy to get started. You can think of it as an extensive scientific calculator, but it can also manipulate symbolic equations. You can always check CalcMe basic guide.

                      Define random variables and function section with CalcMe as the default calculator

                      Below is a detailed description of both procedures and more information regarding when and how to use each.

                      Basic mode

                      The basic mode allows you to add up to five random variable groups to your question by clicking on the Add variable button.              

                      add_variable.png

                      For the moment, these variables need to be integers, and they can't be dependent on the previously defined ones.

                      Declaring variables

                      Variables are defined by writing a name for a variable next to the pound symbol # and the minimum and maximum value between which it's comprised.

                      one_variable.png

                      There are two details to note:

                      • The variable's name can be any letter or word without spaces, excluding reserved words (e.g. sin, cos).
                      • The minimum and maximum values can be any integer value such that the first one is less or equal than the second one.

                      Inserting variables

                      Those are the basics of how variables function inside of WirisQuizzes Studio works. What's very important, though, is to know how to use these variables outside of Studio.

                      To include a variable anywhere within a question type, write a pound symbol # followed by the name of the variable (e.g. #a). So we could include the above values in a question just like this:

                      statement_2.png

                      Even though you can include mathematical expressions in LaTeX, variables defined inside CalcMe need to be referred to in MathType or in plain text.

                       

                      This would appear to the student as:

                      question_preview.png

                      It's also possible to insert these variables in the question's feedback. Furthermore, you can use the student's answer there. Learn how to do it here.

                       

                      Variables evaluation

                      When defining the question's correct answer, we can expect the corresponding expression to be displayed as we have written it, or we want to evaluate it before showing the result to the students. To do so, we need to use the evaluate() command and insert the variables to be simplified as its argument.

                      evaluate_command.png

                      If we don't use the command mentioned above and just type √#a2+#b2, the correct answer will be displayed, as you can see below.

                      preview_not_evaluated.png

                      It won't suppose any validation problem, as the student's answer will be compared following the corresponding assertions as usual. We only recommend using the evaluate() command to display the correct answer in a more compact way.

                      Transferring variables to CalcMe

                      You can automatically convert these basic random variables to the advanced mode if you wish. Thus, you will be able to add more variables and restrictions using all CalcMe resources.

                      automatic_conversion.gif

                      The same happens if you delete a random variable from the quick edition mode; it will disappear from the advanced mode automatically.

                       

                      Below you will find a detailed description of how CalcMe works within WirisQuizzes Studio.

                      Advanced mode (CalcMe)

                      If you want to generate a more complex algorithm where variables may be correlated or not integers, you need to use the computer algebra system (CAS). You can open it by clicking on the Advanced mode button.

                      advanced_mode_button.png

                      What you see is CalcMe. You can think of it as an extensive scientific calculator, but it can also manipulate symbolic equations. You can always check CalcMe basic guide for further details.

                      Declaring variables

                      Variables are defined by writing a name for a variable, an equal sign, and an expression on the right-hand side. For example:

                      calc.declaring_variables.1.calc.png

                      If you used CalcMe before, you might have noticed some differences with previous versions. You can see further details about the new procedure to declare variables here.

                       

                      Within this field, variables can be manipulated and acted on, and new variables can be defined from old ones, just as on paper. For instance:

                      calc.declaring_variables.2.calc.png

                      There are two details to note:

                      • The left-hand side can be any letter or word without spaces, excluding reserved words (e.g. sin, cos).
                      • The right-hand side can be any reasonable mathematical expression, numerical (as in the first variable above) or algebraic (as in the second).

                      Algorithm language

                      The algorithm field is available in multiple languages. By default, the language of the CAS will be the same as Moodle or English as the fallback. But you can choose another one of the available languages.

                      If you change the CalcMe language, then any existing algorithm will be automatically translated. This is very useful if you have algorithms in other languages, like the ones in the STEM collection.

                      Animation showing how to change the CalcMe language

                      Inserting variables

                      Those are the basics of how variables function inside of WirisQuizzes Studio works. What's very important, though, is to know how to use these variables outside of Studio.

                      To include a variable anywhere within a question type, write a pound symbol # followed by the name of the variable (e.g. #a). So we could include the above polynomial in a question just like this:

                      Statement of a WirisQuizzes question involving variables

                      Even though you can include mathematical expressions in LaTeX, variables defined inside CalcMe need to be referred to in MathType or in plain text.

                       

                      This would appear to the student as:

                      Preview of the corresponding WirisQuizzes question involving variables

                      It's also possible to insert these variables in the question's feedback. Furthermore, you can use the student's answer there. Learn how to do it here.

                       

                      Random variables

                      Perhaps the most important use of variables is to introduce randomness into a question. There is a simple instruction in CalcMe that generates random numbers, random(). For example:

                      calc_random_calc.png

                      Generates a random number between -10 and 10. This could then be used in the question text, as we have seen. The result is that each time the question is opened, a random value for a is used. So, students viewing the same question will see potentially different values.

                      There are many ways to use the random() command, and we list a few of them in the basic guide. Similarly, you can see take a look to the dedicated page if you want to see examples of questions that use randomness at different levels.

                       

                      Output options

                      Different countries, education levels, or textbooks use different notations. You can configure some output options in the Application settings section inside CalcMe to better match the notation you use.

                      These options apply only to the values generated in the Algorithm field, i.e. the variables. All generated values will be in the same notation; you can not create values in different notations.

                      CalcMe application settings panel

                      Imaginary unit

                      Choose between i and j (often used in electrical engineering).

                      application_settings_imaginary.png

                      Times operator

                      Choose between middle dot · and cross x. Set Implicit to hide all non-necessary products, that is, implicit products.

                      application_settings_operator.png

                      Precision

                      Precision must be an integer between 1 and 15 included, and it can be set as Significant figures or Decimal places. By default, it is Precision = 4 significant figures. All notations usually imply a rounding. When rounding, the rule used for tie-breaking is half-up. 

                      precision.png

                      Visit our dedicated page for complete detailed information about tolerance, precision, and notation.

                       

                      Decimal

                      Choose the symbol for the decimal mark. Available options depend on the Validation options section symbols in Options... > Separators marked as Decimal digits. Trailing decimal points of integer numbers are never shown.

                      application_settings_decimal.png

                      Thousands

                      Choose the symbol for the digit groups separator, that is, thousands separator. Available options depend on the Validation options section symbols in Options... > Separators marked as Digit groups.

                      application_settings_thousands.png

                      List items

                      Choose the symbol for the list items separator. Available options depend on the Validation options section symbols in Options... > Separators marked as List items.

                      application_settings_list.png

                      Was this article helpful?

                      Give feedback about this article

                      Related Articles

                      • WirisQuizzes User Interface
                      • WirisQuizzes Studio main section
                      • Answer type section
                      • Settings section
                      • Test this question

                      Random variables section

                      Basic mode Declaring variables Inserting variables Variables evaluation Transferring variables to CalcMe Advanced mode (CalcMe) Declaring variables Algorithm language Inserting variables Random variables Output options Imaginary unit Times operator Precision Decimal Thousands List items

                      Empowering STEM education

                      MathType

                      • Office Tools
                      • LMS
                      • XML
                      • HTML

                      WirisQuizzes

                      Nubric

                      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