Creating Quizzes with Grading:-Quiz
The Quiz command in the Grading package offers an easy way to generate interactive tests in Maple. This document describes the usage of the Quiz command and demonstrates the various kinds of quiz questions that can be created.
The QuizBuilder command, also part of the Grading package, provides an assistant that helps you make custom quiz questions, and comes loaded with sample questions. The samples provided give structured examples using hint, try another, and other features of Quizzes.
Note: All examples assume the Grading package is loaded by executing the following command:
withGrading:
Introduction
The simplest form of a quiz takes two arguments—the question and the answer.
QuizWhat is 1 + 1?, 2 ;
What is 1 + 1?
Because the above question is not algorithmic—given the input, there is no way to regenerate this and arrive at a different question—there is no way to practice variations of the same question. The Algorithmic Questions section below demonstrates questions designed random variables that include a Try Another button.
The following example shows a different way of capturing the answer, rather than a generic input area, the response is to select a check box.
QuizIs 1 + 1 = 2? , true, 'style'=truefalse ;
Is 1 + 1 = 2?
Another style of question, multiplechoice requires an initial value to define the choices. Note that the default is for those choices to appear in a scrambled order. The grade value '3' refers to the third item in the list, denoting the index of the correct answer in the choice list.
QuizWhat is 1 + 1?, 3, 0,1,2,3,4, 'style'='multiplechoice' ;
Other question types can also be given an initial value, which can simplify the formatting of math expressions.
QuizCalculate:, −cosx, Intsinx,x ;
Calculate: =
Plots can be used as initial values.
QuizWhich of the following could be portions of the plot of sin(x)?, 1,2, plotsinx,x=0..rand2..3, plotsinx,x=rand2..3..5, plot2⋅ sinx,x=rand2..3..rand4..7, style=multipleselect, gradebyindex=true, size=250,150;
Which of the following could be portions of the plot of sin(x)?
Algorithmic Questions
Algorithmic questions incorporate randomization so that a single source can generate an unlimited number of tests on the same topic.
To generate an algorithmic quiz, you need to supply an initialization procedure.
QuizIs the following number prime?, true, proc nextprimerand2..20 end, 'style'=truefalse ;
Is the following number prime?
Note that when generating an algorithmic quiz, a Try Another button appears. Clicking this button causes the question to be reinitialized, thus presenting a new variation of the question.
The initialization procedure will be passed all extra arguments given to the Quiz command. Below we will add the parameter, r, to the initialization routine. Calling Quiz with the extra argument, 100, will pass this along to the initializer, resulting in a different random number sequence.
QuizIs the following number prime?, true, procr nextprimerandr..r+20 end, 'style'=truefalse, 100 ;
This repeats the same command above, only changing the extra argument.
QuizIs the following number prime?, true, procr nextprimerandr..r+20 end, 'style'=truefalse, 1000 ;
So far, the second parameter has been a fixed result. For math-response questions, a procedure can be passed to grade the result. The procedure accepts the following parameters:
The user response
The "answer" — as returned by the initialization procedure, which can be the correct answer, or could be data used to derive the correct answer
Quiz Factor the expression completely:, procResp, Ans evalbfactorAns = Resp end, proc local r ≔ rand1..3; expand r⋅x ⋅ r⋅x+r ⋅ r⋅x+r ; end ;
Factor the expression completely: =
When using a grading procedure to check the solution to a multiple-choice question, note that the default is to test against the index of the pre-scrambled choice. Here the grading code compares against indices {1,4} as the correct solution.
QuizPick 0 and 3:, r→evalb r = 1,4, C0,C1, C2, C3, C4, 'style' = 'multipleselect'
Pick 0 and 3:
When the 'gradebyindex' option is set to false, the values of the choices will be given as the response variable.
QuizPick 0 and 3:, r→evalb r = C0,C3, C0,C1, C2, C3, C4, 'style' = 'multipleselect', gradebyindex=false
Using $ Variables To Randomize the Question Text
Random values can be inserted in the question text by naming variables with a $ prefix and placing them in the question text.
QuizIs $P prime?, true, proc Quiz:-Set = nextprimerand2..20 ; end, 'style' = truefalse ;
Is prime?
A better version of this isprime question would give both prime and non-prime values. In this case we need an algorithm to check the result. Here are two ways to implement such a question:
1. This variation uses a procedure to generate and return the initial value. That initial value is passed as the second argument to the grading procedure, which does the comparison and returns true for a correct result and false for an incorrect result.
QuizIs the following number prime?, response,initval→evalb response = isprimeinitval , → rand2..20, 'style' = truefalse;
2. In this variation, we replace $P with the generated number. Because the initial-value generator returns NULL, our grading procedure will receive NULL as the second argument, so we have to fetch it using Quiz:-Get in order to do the comparison.
QuizIs $P prime?, response→response = isprimeQuiz:-Get, proc Quiz:-Set = rand2 .. 20; end proc, 'style' = truefalse;
The Quiz:-Get command can be used to query the variable, and Quiz:-Set will set the value. The variable named in calls to Set should be prefixed with a $ to match the question text. The question text may reference $A or ${A}, but the Set and Get commands should always reference the form without curly brackets, as $A. Also, since $ is a special character in Maple, references to $ names in SetVar and GetVar must be enclosed in left single quotes (see "name").
QuizWhich is a plot of ${FUNC}?, 1, proc local A ≔ sinx,cosx,tanxrand1..3; Quiz:-Set=A; plotA,plot−A,plotπ*A,x=−2*π..2*π: end, style=multiplechoice, plotsize=250,150;
Which is a plot of ?
The special variable, `$RESPONSE`, is automatically set to the value entered by the user. By using `$RESPONSE` in conjunction with other pre-defined variables, the grading procedure can be written to take no arguments, as is the situation for writing a grading procedure within Maple T.A.
Quiz There are ${A} balls of different colors in a sack. How many distinct combinations of ${B} balls can you remove from the sack?, proc uses Grading:-Quiz; evalbGet`$RESPONSE`=binomialGet, Get; end, proc uses MapleTA:-Builtin, Grading:-Quiz; Set=range5,10; Set=range1,4; 1; end;
There are balls of different colors in a sack. How many distinct combinations of balls can you remove from the sack?
Preventing Simplification
For certain fundamental concepts it is necessary to "dumb down" Maple. Sometimes Maple is too smart, and it will automatically do favors for you, such as collecting terms in a polynomial or adding constants. The "InertForm" package gives you a way to represent expressions that won't be automatically simplified. The Quiz command can make use of this inert-form notation for displaying expressions and grading responses.
Inert-form represents the core operators and functions in the following form:
Standard Notation
Inert Form
A + B
`%+`( A, B )
A - B
`%+`( A, -B )
A * B
`%*`( A, B )
A / B
`%/`( A, B )
A ^ B
`%^`( A, B )
f( A, B )
`%f`( A, B )
( A + B ) * C
`%*`( `%+`(A,B), C )
In the following question, we use this notation to prevent reduction of fractions. We specify the 'inertform' option so that the Quiz command can apply appropriate formatting when displaying the question.
Grading:-QuizWhich fractions are reduced to lowest terms?,1, 1/3, `%/`4,6, `%/`9,3 , style='multipleselect', 'inertform'=true ;
Which fractions are reduced to lowest terms?
This is also relevant to the response being graded in a free-form math question.
Grading:-QuizReduce this fraction to lowest terms: , proc resp, ans evalb resp∷specfunc`%/` and opresp = opInertForm:-Valueans ; end proc, proc local i ≔ rand2..5; `%/`i*rand2..4,i*rand5..7; end proc, 'inertform' = true ;
Reduce this fraction to lowest terms: =
Because the answer is being delivered to the grading procedure in inert form, there is no chance for automatic simplification to happen along the way. You can't cheat by typing in the given expression and have it auto-simplify behind the scenes.
The grading code checks to see that the response was a divide form,`%/`, and that the operands of the response match the simplified operands of a reduced fraction equivalent.
Importing and Exporting Questions From Maple T.A
Maple T.A. is an easy-to-use web-based system for creating tests and assignments, and automatically assessing student responses and performance. The "maple-graded" style of question can be imported into Maple and run via the Quiz command.
The MapleTA:-Import command will read a course module zip file and import all of its questions into a Record-based data structure that closely mirrors the XML in the course-module manifest. A sample structure might look like the following (omitting optional fields):
TAQuestion := Record("name" = " Quadratic Factor Question ", "mode" = "Maple", "text" = " Factor the following algebraic expression x<sup>2</sup> + ${A}x + ${B}. Your answer should be in the form (x+a)(x+b). ", "algorithm" = " $a=rint(1,10);$b=rint(2,10);$A=int($a+$b);$B=int($a*$b);$factor=maple(\"factor(x^2+${A}*x+${B})\"); ", "mapleAnswer" = " $factor; ", "maple" = " evalb(($ANSWER)-($RESPONSE)=0); " ):
This imported structure is recognized by the Quiz command and it builds the appropriate question in Maple.
Quiz TAQuestion ;
Factor the following algebraic expression x2 + x + . Your answer should be in the form (x+a)(x+b).
Record⁡name= Quadratic Factor Question ,mode=Maple,text= Factor the following algebraic expression x<sup>2</sup> + ${A}x + ${B}. Your answer should be in the form (x+a)(x+b). ,algorithm= $a=rint(1,10);$b=rint(2,10);$A=int($a+$b);$B=int($a*$b);$factor=maple("factor(x^2+${A}*x+${B})"); ,mapleAnswer= $factor; ,maple= evalb(($ANSWER)-($RESPONSE)=0);
A course module usually contains multiple questions.
cmfile ≔ catkerneloptsmapledir,/data/help/MapleTA/coursemodule.zip:
cmquestions ≔ MapleTA:-Import cmfile :
numelemscmquestions;
18
Quiz cmquestions1 ;
Convert feet to meters. Answers require 4 significant digits.Do not include units in your response.
Quizcmquestions3 ;
Solve the expression x3 - x = 0. Enter only the expression for x, omitting "x =".
Similarly, all Quiz-based questions can be exported back to Maple T.A. The Quiz command takes an 'output' = 'mapleta' option that will generate a Record structure as described above. This Record can then be passed to the MapleTA:-Export command to generate a course module suitable for importing into Maple T.A.
As an example, let's define a question and see how it looks.
qinit ≔ proc local p ≔ nextprime rand2..7 ; Grading:-Quiz:-Set = p ; p*rand1..2 + 1, p*rand3..4 + 1, p*rand1..2 + 0, p*rand1..2 + 2, p*rand1..2 − 1 ; end:
Grading:-QuizFor which values of X does ( X mod $P) = 1,1,2,qinit,style=multipleselect ;
For which values of X does ( X mod ) = 1
Now, let's use the same question parameters, but specify the 'output' option. We will also give the question a name so it can be easily identified inside Maple T.A.
Q ≔ Grading:-QuizFor which values of X does ( X mod $P) = 1,1,2,qinit, style=multipleselect,output=mapleta,name= Imported MS 15 (mod)
Q≔Record⁡mode=Multiple Selection,name= Imported MS 15 (mod) ,algorithm= $MAPLE_INIT = maple("randomize(): proc() local r := (proc () local p: p := nextprime(rand(2 .. 7)()): Grading:-Quiz:-Set(`\x24P` = p): [p*rand(1 .. 2)()+1, p*rand(3 .. 4)()+1, p*rand(1 .. 2)(), p*rand(1 .. 2)()+2, p*rand(1 .. 2)()-1]: end proc)(NULL): op(map(InertForm:-ToMathML,r)); end(); "); $MCCHOICE1 = switch(0,$MAPLE_INIT); $MCCHOICE2 = switch(1,$MAPLE_INIT); $MCCHOICE3 = switch(2,$MAPLE_INIT); $MCCHOICE4 = switch(3,$MAPLE_INIT); $MCCHOICE5 = switch(4,$MAPLE_INIT); $P = switch(5,$MAPLE_INIT); ,text= For which values of X does ( X mod $P) = 1 ,type=formula,answer= 1, 2 ,_attributes=Record⁡...,choices=Record⁡...
This can be exported as a course module:
if FileTools:-Existssample.zip then FileTools:-Removesample.zip; end if;
MapleTA:-Export Q, sample.zip ;
Record⁡mode=Multiple Selection,name= Imported MS 15 (mod) ,algorithm= $MAPLE_INIT = maple("randomize(): proc() local r := (proc () local p: p := nextprime(rand(2 .. 7)()): Grading:-Quiz:-Set(`\x24P` = p): [p*rand(1 .. 2)()+1, p*rand(3 .. 4)()+1, p*rand(1 .. 2)(), p*rand(1 .. 2)()+2, p*rand(1 .. 2)()-1]: end proc)(NULL): op(map(InertForm:-ToMathML,r)); end(); "); $MCCHOICE1 = switch(0,$MAPLE_INIT); $MCCHOICE2 = switch(1,$MAPLE_INIT); $MCCHOICE3 = switch(2,$MAPLE_INIT); $MCCHOICE4 = switch(3,$MAPLE_INIT); $MCCHOICE5 = switch(4,$MAPLE_INIT); $P = switch(5,$MAPLE_INIT); ,text= For which values of X does ( X mod $P) = 1 ,type=formula,answer= 1, 2 ,_attributes=Record⁡...,choices=Record⁡...
See Also
Grading:-Quiz, Grading:-QuizBuilder, MapleTA:-Export, MapleTA:-Import, Maple T.A. Integration
Return to Index for Example Worksheets
Download Help Document