Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.


TeX & (C or JS) is the most commonly used question type to introduce randomization in variables. It can take the form of Numeric Free Response (NFR, also called TeX Open, template #179792) or TeX multiple choice (template #179793). These TeX problems are useful to introduce variation of numbers within questions so students in a large class each see the same question, but with different numbers.

...

TeX formatting is a powerful tool for creating content in Quest.  The upper TeX box serves as a display of the question. Write this code in TeX (and sometimes LaTeX). A standard TeX reference card can be found here, commonly used functions available here, and more tools for finding the appropriate commands for various symbols can be found here: Detexify (external site)

...

The lower code box (written in JS or C) performs calculations and initialize variables that are used in the top TeX portion. Each question part in the question body must define and initialize an answer in the code portion--it is in this code box where variable, any randomization, and the answer (ans1) are set. (Follow these steps to add more than one part.)

As the name indicates, this question type requires either Javascript (JS) or C in the code portion of questions.  No TeX is allowed in the code portion of a TeX question, especially in the definition of answer units. To avoid errors, spell out units that require more complicated symbols, like degrees, percents, etc. 

...

When writing the coding portion of the question in C, begin with "void answer(void) { }" and insert all code between the curly braces. Any variables you want to reference in the TeX portion of the problem must be defined as follows: /* global (insert type) (insert name) */ (without the parentheses). You can also specify units you want to be displayed after the variable by typing "u={type}" where type can be m, kg, etc. The rest of the problem can then be coded like a normal C program.

What about that 'execute' button (at the top of the code box)?

Pushing this button will run the code in the code block, and print the stuff in printjs(<stuff>)​; the purpose would be to generate a display of what the code box is telling it to do, for debugging purposes. 

...

Using variables (@)

Variables that have been declared and given a value in the code portion (see below) can be referenced in the question body with a preceding "@" symbol. For instance, if you calculated the variable k in the code portion and wanted to display the square root of k in an equation in the question body, you would simply type $\sqrt{@k}$. If k has been given a value, the editor will grab this value from the code portion and display it in the question body. Make sure you have initialized the variable in the code portion or you will receive an error message, and the question will not work.

...

Please follow these links for more information to create specific numeric free response (aka TeX open) or multiple choice questions.


For help beyond this brief intro, StackExchange is a very useful site for finding advice on a wide variety of subjects, most relevant here, is the communities about TeX/LaTeX, JavaScript and C. A quick internet search should yield a variety of forums to help.

...