Versions Compared

Key

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

The code portion of a question is used to define solutions to the different question parts, but it can also be used to perform calculations and initialize variables that can be used in the TeX portion. Each question part in the question body must define and initialize an answer in the code portion. Quest can parse code that is written in The Quest Editor requires either Javascript or C in the code portion of questions.

 

Warning
iconfalse

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.

...

A Javascript question will be defined like a Javascript function: function js_answer() { }. All code you write in this section must be contained in the function brackets. When using Javascript in the code portion of a TeX question, take special notice of semicolons and matching opening and closing braces {}. Like any Javascript code, each statement must end in a semicolon and all functions, loops, and conditional statement blocks must begin and end in curly braces. If you want to learn a little more about Javascript in general, try this link.

Info
iconfalse

For more details about using Javascript, use question ID 169286 as a template to create a reference question in your bank.

 

C

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.

...