161 results in How-tos - search across all projects.
-
Question
When saving the data necessary to resume an attempt, Numbas only saves the values of variables which use the random number generator.
If you naively generate a large random sample in one variable, it'll be marked as a source of randomness so Numbas will save every value in the sample. Loading this value when you resume the attempt can be very slow.
Instead, you can generate a seed value in one variable and then use it with the seedrandom function in the variable that stores your random list. Only the value of the seed needs to be saved.
-
Question
The diagram contains a line and a hidden glider on that line.
The JavaScript preamble adds a callback which shows the glider when the question advice is displayed.
-
Question
Shows how to use the lpad function to format a time in HH:MM format so that leading zeros are used for numbers less than 10.
-
Question
The CSS preamble adds a vertical line down the input for part b, to separate the two parts of the matrix.
-
Question
Do not use this: adaptive marking is the best way to access the student's answer to another part.
Shows how to retrieve the student's answer to another part from a custom marking script.
-
Question
You can use LaTeX in marking comments, but remember to escape backslashes!
-
Question
This question asks the student to give a function with a particular root. It then asks them to divide by (x-{root}), and uses adaptive marking to mark against the previous answer.
This uses the "expression" data type, which is currently undocumented and experimental.
-
Question
The student is given a quadratic formula and asked to fill in a table of values of $f(x)$ for a given range of $x$.
The table uses the spreadsheet extension.
-
Question
Shows two different ways
-
Question
Shows how to mark a boolean expression, by checking all possible values of the free variables. There's an information step containing a reminder of the syntax for boolean operations.
-
Question
The student is asked to find the square root of an integer of the form $\pm n^2$. If the root is not real, they should enter "nan".
A custom marking algorithm extends the built-in one to deal with "nan".
There's some custom javascript to set the expected answer correctly. In the future this will be possible in the marking algorithm - see https://github.com/numbas/Numbas/issues/856
-
Question
Example showing how to mark a "choose one from a list" part where the student has to pick the range a given number lies in.
-
Question
The student is asked to enter a given matrix, but they're only required to fill in the upper triangle.
A custom marking algorithm fills in any empty cells in the lower triangle of the student's answer with the corresponding cell in the upper triangle.
The student is still warned if they leave any cells empty in the upper triangle.
-
Question
This demonstrates how to:
- Generate a fixed number of observations of data in two categories.
- Display the data in a table, with row and column totals.
- Ask the student to enter the data in a spreadsheet which is automatically marked.
-
Question
The student has to enter `diff(y,x,2)`, equivalent to $\frac{\mathrm{d}^2y}{\mathrm{d}x^2}$, as their answer. It's marked by pattern matching, using a custom marking algorithm.
-
Question
The student has to enter three different letters of the alphabet in the three gaps. Their answer is marked as a set: repeated answers only count as one answer.
Each gap has the same custom marking algorithm which marks that gap as correct if the student's answer is in the set of acceptable answers.
-
Question
This question models an experiment: the student must collect some data and enter it at the start of the question, and the expected answers to subsequent parts are marked based on that data.
The student's values of the variables width, depth and height are stored once they move on from the first part.
-
Question
This question models an experiment: the student must collect some data and enter it at the start of the question, and the expected answers to subsequent parts are marked based on that data.
A downside of working this way is that you have to set up the variable replacements on each part of the question. You could avoid this by using explore mode.
-
Question
In the first part, the student must write any linear equation in three unknowns. Each distinct variable can occur more than once, and on either side of the equals sign. It doesn't check that the equation has a unique solution.
In the second part, they must write three equations in two unknowns. It doesn't check that they're independent or that the system has a solution. The marking algorithm on each of the gaps just checks that they're valid linear equations, and the marking algorithm for the whole gap-fill checks the number of unknowns.
-
Question
The student must solve a pair of simultaneous equations in $x$ and $y$.
The variables are generated backwards: first $x$ and $y$ are picked, then values for the coefficients of the equations are chosen satisfying those values.
-
Question
Shows how to use JSXGraph to make a sine graph with amplitude, frequency and phase controlled by sliders.
-
Question
This shows how to define a list of LaTeX strings, and pick a couple of them at random to display.
The "JSON data" type is used to define the available strings, so they're automatically marked as "safe" and curly braces aren't interpreted as variable substitution.
-
Question
This question shows how to generate a random set of $(x,y)$ samples, where $y = mx + c + \mathrm{noise}$.
The JSXGraph extension is used to show a scatter plot of the data. This isn't necessary if you just want to generate the data.
-
Question
This shows how to use a variable name annotation to put a hat on a variable name inside the \simplify command.
-
Question
A mathematical expression part with a pattern restriction to ensure that the student has extracted the highest common factor of two terms.
The answer must be of the form $a(b+cx)$, where $b$ and $c$ are coprime.
-
Question
The student is asked to give the roots of a quadratic equation. They should be able to enter the numbers in any order, and each correct number should earn a mark.
When there's only one root, the student can only fill in one of the answer fields.
This is implemented with a gap-fill with two number entry gaps. The gaps have a custom marking algorithm to allow an empty answer. The gap-fill considers the student's two answers as a set, and compares with the set of correct answers.
The marking corresponds to this table:
There is one root There are two roots Student gives one correct root 100% 50%, "The root you gave is correct, but there is another one." Student gives two correct roots impossible 100% Student gives one incorrect root 0% 0% Student gives one incorrect, one correct root 50% "One of the numbers you gave is not a root". 50% "One of the numbers you gave is not a root". Student gives two incorrect roots 0% 0% -
Question
The expected answer involves the logarithm of a negative number, which doesn't have a unique solution.
The part's marking algorithm evaluates the exponential of the student's answer and the expected answer, and compares those.
-
Question
The expected answer involves the logarithm of a negative number, which doesn't have a unique solution.
The part's marking algorithm checks that the student's answer differs from the expected answer by a multiple of $2\pi$.
-
Question
This shows one way of laying out matrix cells in a table, so that some cells can be filled in by the student.
At the time this was written, there's an open issue for allowing some entries in the matrix entry part to be filled-in, which would make this technique redundant.
Some CSS in the preamble adds the brackets around the table - it has to have the attribute
class="matrix-gaps" -
Question
The student is given a quadratic formula and asked to fill in a table of values of $f(x)$ for a given range of $x$.
There is also a plot of the points, which updates when the table is filled in, or the student can move the points to fill in the table.
The table uses the spreadsheet and JSXgraph extensions.