Creating Quizzes with Grading[Quiz] - Maple Help

Online Help

All Products    Maple    MapleSim

Home : Support : Online Help : Education : Grading : examples/Quiz

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.


Note:  All examples assume the Grading package is loaded by executing the following command:






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' ;

What is 1 + 1?


Other question types can also be given an initial value, which can simplify the formatting of math expressions.  


QuizCalculate:, cosx, Intsinx,x ;




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 ;

Is the following number prime?


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 ;

Is the following number prime?


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 rx  rx+r  rx+r ; end ;

Factor the expression completely:




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`$P` = nextprimerand2..20 ; end,     'style' = truefalse ;

Is  prime?


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`$FUNC`=A;          plotA,plotA,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`$A`, Get`$B`;      end,     proc        uses MapleTA:-Builtin, Grading:-Quiz;       Set`$A`=range5,10;       Set`$B`=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 respspecfunc`%/`             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 &semi;

    Factor the following algebraic expression x2 + x + . Your answer should be in the form (x+a)(x+b).  


A course module usually contains multiple questions.


cmfile  catkerneloptsmapledir&comma;/data/help/MapleTA/;

cmquestions   MapleTA:-Import cmfile  &colon;




Quiz cmquestions1 &semi;

  Convert  feet to meters. Answers require 4 significant digits.Do not include units in your response.  

Quizcmquestions3 &semi;

  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 &semi;       Grading:-Quiz:-Set`$P` &equals; p &semi;        p&ast;rand1..2 &plus; 1&comma;         p&ast;rand3..4 &plus; 1&comma;         p&ast;rand1..2 &plus; 0&comma;         p&ast;rand1..2 &plus; 2&comma;         p&ast;rand1..2  1 &semi;    end&colon;

Grading:-QuizFor which values of X does ( X mod $P) = 1&comma;1&comma;2&comma;qinit&comma;style&equals;multipleselect &semi;

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&comma;1&comma;2&comma;qinit&comma;   style&equals;multipleselect&comma;output&equals;mapleta&comma;name&equals; Imported MS 15 (mod)

Recordmode&equals;Multiple Selection&comma;name&equals; Imported MS 15 (mod) &comma;algorithm&equals; $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)(): MapleTA:-ToString(op(r), Grading:-Quiz:-Get(`\x24P`),'print','sequence'): 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); &comma;text&equals; For which values of X does ( X mod $P) = 1 &comma;type&equals;formula&comma;answer&equals; 1, 2 &comma;_attributes&equals;Record...&comma;choices&equals;Record...



This can be exported as a course module:


if then; end if&semi;

MapleTA:-Export Q&comma; &semi;


See Also

Grading[Quiz], MapleTA[Export], MapleTA[Import], Maple T.A. Integration


Return to Index for Example Worksheets

Download Help Document

Was this information helpful?

Please add your Comment (Optional)
E-mail Address (Optional)
What is ? This question helps us to combat spam