 Grading[Quiz] - Maple Help

 Quiz
 generate an interactive quiz Calling Sequence Quiz( question_statement, grader, init, options ) Quiz( MapleTAImport ) Parameters

 question_statement - string or module grader - procedure or value init - procedure or value MapleTAImport - Record imported by MapleTA:-Import Options

 • style = math, truefalse, multiplechoice, multipleselect, or multiline
 The style option specifies the kind of question to display.  A multiline question expects a fully-worked multi-line solution as a response where the grade procedure should return a list of strings as feedback for each line of the response.
 • scramble = true or false
 The scramble option applies only to multiple choice and multiple select style questions.  The order of the entries are displayed in a random order.  The default is true.
 • solution = procedure
 The solution option is used to specify a procedure that will generate the steps explaining the solution steps for the given problem.  The procedure takes no arguments and must return output suitable for passing to Student:-Basics:-OutputStepsRecord for formatting.  This can be as simple as a list of text and math, each entry appearing on a single line.
 • hint = procedure
 The hint option is used to specify a procedure that will display a hint. The procedure takes no arguments and must return output suitable for passing to Student:-Basics:-OutputStepsRecord for formatting.  This can be as simple as a list of text and math, each entry appearing on a single line.
 • mathsize = [width,height]
 This size is used to format the answer input box.
 • plotsize = [width,height]
 This size is used to format the size of any plot that appears in the question.
 • gradebyindex = true or false
 For multiple choice and multiple select questions the default for this option is true.  This indicates that the correct answer should be tested against the index or set of indices of the pre-scrambled choices.  When gradebyindex=false, the result should be compared against the correct elements themselves.
 • numchoices = integer
 This can be used to specify the maximum number of choices in a multiple-choice question if there could be more than five choices and it is not obviously determined by the initialization data.
 • inertform = true or false
 When set to true, values returned from an answer area and sent to the grading routine will use the InertForm format to prevent automatic simplification.  This option only applies to the implicitly presented output area and response math container.  It does not affect Get or Set values.
 • name = string
 This option is used to give the question a name when used in conjunction with output = mapleta.
 • output = quiz, module, canvas, showcanvas, or mapleta
 The output option determines the return behavior of the Quiz command.  The default is to generate an interactive quiz.  Choosing output = module returns a Record structure encapsulating the data used to drive the interactive quiz. To generate a canvas that can be deployed to Maple Learn, and suitable for use with DocumentTools:-Canvas, use the output=canvas option. The final option, output=mapleta, causes a Record structure to be returned in such format that is suitable for giving to the MapleTA:-Export command so the quiz can be used in Maple T.A.
 • decodeentities = true or false
 By default, entities in the question text, like "<" are decoded to the character they represent.  To turn this off, use the option, decodeentities=false.
 • title = string
 If this option is used, a title is displayed above the question text.
 • The following options pertain to generating multiple questions by passing in an array of modules generated by calling the Quiz command with the 'output'=module option:
 – numberformat = identical(roman,lowercaseroman,none,decimal,alpha,lowercasealpha) := decimal
 When displaying an array of questions each question is numbered using decimal numbers by default.  Optionally roman numerals, alphabetic characters, or no numbering can be chosen.
 When displaying an array of questions, the text style used to display the introductory numbered heading can be one of these styles.
 – numberprefix = string := "Question "
 The prefix in front of a numbered question can be specified with the numberprefix option.
 – border = truefalse := false
 A border can be optionally turned on around each question when displaying an array of questions. Description

 • The Quiz command generates a simple interactive tool that displays a question, accepts a response, and grades the response. If the question generation is algorithmic, then it also offers the ability to try another version of the question with new random variables.
 • The question_statement should be a string containing the text of the question.  Blanks can be implicitly assigned by including "$" variables within the question text. The first argument can also be a previously generated question module or array of question modules built using the Quiz command with the option 'output'=module.  • The grader argument is either the correct answer, or a procedure that returns true or 1 for a correct answer and false or 0 for an incorrect response.  The grader procedure will be passed two arguments -- the response and init-value. These can be used or ignored as needed. The user's response can also be fetched by calling Quiz:-Get to get the "$RESPONSE" variable.
 • The init argument is either an initial value or a procedure that generates initial values.  For multiple choice questions init can be a list of choices.
 As a procedure, init takes no arguments. It can either set "\$" variables using Quiz:-Set, or return a value that will be implicitly filled into the question.
 • The related QuizBuilder provides an interface that helps you make custom Quiz questions and comes loaded with sample questions. Examples

The Quiz Example Worksheet provides a number of examples with detailed explanations.  A few simple questions are reproduced here.

In order to test the following examples, make sure you open the help page as a worksheet.  The components are not interactive when viewed within the help system.

 > $\mathrm{with}\left(\mathrm{Grading}\right):$
 > $\mathrm{Quiz}\left("Is 1+1=2?",\mathrm{true},'\mathrm{style}'=\mathrm{truefalse}\right)$

 Is 1+1=2?    > $\mathrm{Quiz}\left("Is the following number prime?",\mathrm{true},\mathbf{proc}\left(r\right)\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}\mathrm{nextprime}\left(\mathrm{rand}\left(r..r+20\right)\left(\right)\right)\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}\mathbf{end proc},'\mathrm{style}'=\mathrm{truefalse},1000\right)$

 Is the following number prime?     > $\mathrm{init}≔\mathbf{proc}\left(\right)\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}\mathrm{_local}\left(\mathrm{fn},n,\mathrm{choices}\right);\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}\mathrm{choices}≔\left[\mathrm{sin}\left(x\right),\mathrm{cos}\left(x\right),\mathrm{tan}\left(x\right)\right];\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}n≔\mathrm{rand}\left(1..\mathrm{numelems}\left(\mathrm{choices}\right)\right)\left(\right);\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}\mathrm{fn}≔\mathrm{choices}[n];\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}\mathrm{Quiz}:-\mathrm{Set}\left(=\mathrm{fn}\right);\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}\left[\mathrm{plot}\left(\mathrm{fn}\right),\mathrm{plot}\left(−\mathrm{fn}\right),\mathrm{plot}\left(\mathrm{Pi}*\mathrm{fn},x=−2*\mathrm{Pi}..2*\mathrm{Pi}\right)\right]\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}\mathbf{end proc}:$
 > $\mathrm{Quiz}\left("Which is a plot of \left\{FUNC\right\}?",1,\mathrm{init},\mathrm{style}=\mathrm{multiplechoice},\mathrm{plotsize}=\left[250,150\right]\right)$

Which is a plot of ?         The following example shows how to generate and display multiple questions from the same procedure, using the 'output'=module option.  Note that since module is a keyword, it needs left single quotes around it in order to parse as a name.

 > $A≔\mathrm{Array}\left(\right):$
 > $A\left(1\right)≔\mathrm{Grading}:-\mathrm{Quiz}\left("Is 1 + 1 = 2?",\mathrm{true},'\mathrm{style}'=\mathrm{truefalse},'\mathrm{output}'=\mathrm{module}\right):$
 > $A\left(2\right)≔\mathrm{Grading}:-\mathrm{Quiz}\left("What is 1 + 1?",2,'\mathrm{style}'=\mathrm{math},'\mathrm{output}'=\mathrm{module}\right):$
 > $A\left(3\right)≔\mathrm{Grading}:-\mathrm{Quiz}\left("Pick C.",3,\left["A","B","C"\right],'\mathrm{style}'=\mathrm{multiplechoice},'\mathrm{output}'=\mathrm{module}\right):$
 > $A\left(4\right)≔\mathrm{Grading}:-\mathrm{Quiz}\left("Which of the following could be portions of the plot of sin\left(x\right)?",\left\{1,2\right\},\left[\mathrm{plot}\left(\mathrm{sin}\left(x\right),x=0..\mathrm{rand}\left(2..3\right)\left(\right)\right),\mathrm{plot}\left(\mathrm{sin}\left(x\right),x=\mathrm{rand}\left(2..3\right)\left(\right)..5\right),\mathrm{plot}\left(2\mathrm{sin}\left(x\right),x=\mathrm{rand}\left(2..3\right)\left(\right)..\mathrm{rand}\left(4..7\right)\left(\right)\right)\right],\mathrm{style}=\mathrm{multipleselect},\mathrm{gradebyindex}=\mathrm{true},\mathrm{size}=\left[250,150\right],'\mathrm{output}'=\mathrm{module}\right):$
 > $\mathrm{Grading}:-\mathrm{Quiz}\left(A,\mathrm{numberformat}=\mathrm{lowercaseroman},\mathrm{numberprefix}="Question 1.",\mathrm{border}=\mathrm{true}\right)$

Question 1.i

 Is 1 + 1 = 2?    Question 1.ii

 What is 1 + 1?  Question 1.iii

Pick C.     Question 1.iv

Which of the following could be portions of the plot of sin(x)?        The following example includes a "Show Solution" button:

 > $\mathrm{with}\left(\mathrm{Grading}\right):$
 > $\mathrm{Quiz}\left("There are A balls in B sacks",\mathbf{proc}\left(\right)\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}\mathrm{evalb}\left(\mathrm{Quiz}:-\mathrm{Get}\left(\mathrm{RESPONSE}\right)=\mathrm{binomial}\left(\mathrm{Quiz}:-\mathrm{Get}\left(\right),\mathrm{Quiz}:-\mathrm{Get}\left(\right)\right)\right)\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}\mathbf{end proc},\mathbf{proc}\left(\right)\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}\mathrm{Quiz}:-\mathrm{Set}\left(=\mathrm{rand}\left(5..10\right)\left(\right)\right);\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}\mathrm{Quiz}:-\mathrm{Set}\left(=\mathrm{rand}\left(1..4\right)\left(\right)\right);\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}1\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}\mathbf{end proc},'\mathrm{solution}'=\mathbf{proc}\left(\right)\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}\mathrm{_local}\left(a≔\mathrm{Quiz}:-\mathrm{Get}\left(\right)\right);\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}\mathrm{_local}\left(b≔\mathrm{Quiz}:-\mathrm{Get}\left(\right)\right);\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}\left[\left["Compute the Binomial Coefficient",\mathrm{%binomial}\left(a,b\right)=\mathrm{%/}\left(\mathrm{%factorial}\left(a\right),\mathrm{%*}\left(\mathrm{%factorial}\left(b\right),\mathrm{factorial}\left(\mathrm{%+}\left(a,−b\right)\right)\right)\right)\right],\left["Result:",\mathrm{binomial}\left(a,b\right)\right]\right]\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}\mathbf{end proc}\right)$

 There are  balls in  sacks     Compatibility

 • The Grading[Quiz] command was introduced in Maple 18.
 • The Grading[Quiz] command was updated in Maple 2022.
 • The solution, gradebyindex and decodeentities options were introduced in Maple 2022.
 • The output option was updated in Maple 2022.