A.4 Library of Source Scripts - Maple T.A. 10 Help

## A.4 Library of Source Scripts

This section provides examples of source script files for:

Algorithmically generated math fomulas—Algorithmic Mathematical Formula Question Source Script

Algorithmically generated multiple selection questions—Algorithmic Multiple Selection Question Source Script

Questions with embedded applets—Applet Questions

Clickable Image questions—Clickable Image Question Source Script

Essay questions—Essay Question Source Script

Key word or phrase questions—Key Word or Phrase Question Source Script

List questions—List Question Source Script

Maple Formula questions—Maple-graded Formula Question Source Script

Maple Syntax questions—Maple Syntax Question, Source Script

Multipart questions—Multipart Question, Source Script

Multiple Choice questions—Multiple Choice Question, Source Script

Multiple Selection questions—Multiple Selection Question Source Script

Numeric questions—Numeric Mathematical Questions Source Script

Question Designer questions—Question Designer Question Example using Various Embedded Questions

True or False questions—True or False Question Source Script

To use the example of a source script:

1. Save the question definition as a text file with the extension .qu.
1. Import the text file.

### Algorithmic Mathematical Formula Question Source Script

The following example source script creates a mathematical Formula question that has algorithmically generated variable data.

```qu.1.topic=Formula Question Example Script@
qu.1.1.mode=Formula@
qu.1.1.editing=useHTML@
qu.1.1.algorithm=
\$n=int(rint(20) + 2);
@
qu.1.1.question=
Let [itex]<mi>y</mi><mo>=</mo><msup><mi>x</mi><mn>\$n</mn></msup>[/itex]. What is the derivative of [itex]<mi>y</mi>[/itex]  with respect to [itex]<mi>x</mi>[/itex]?
@
@
```

Overview of Algorithmic Question Capabilities

Question Modes (Question Types)

### Algorithmic Multiple Selection Question Source Script

The following example source script creates a Multiple Selection question with algorithmically generated data.

```qu.1.topic=Multiple Selection Question Example Script@
qu.1.1.mode=Multiple Selection@
qu.1.1.name=<b>Multiple selection</b>
@
qu.1.1.editing=useHTML@
qu.1.1.algorithm=
\$a=int(2 * rint(10) + 2);
\$b=int(2 * rint(10) + 2);
\$c=int(2 * rint(10) + 2);
\$d=int(2 * rint(10) + 2);
\$e=int(2 * rint(10) + 1);
\$f=int(2 * rint(10) + 1);
condition: ne(\$a,\$b,\$c,\$d)  ne(\$e,\$f);
@
qu.1.1.question=
Which of these numbers are even?@
qu.1.1.choice.1=\$a@
qu.1.1.choice.2=\$b@
qu.1.1.choice.3=\$c@
qu.1.1.choice.4=\$d@
qu.1.1.choice.5=\$e@
qu.1.1.choice.6=\$f@
```

Overview of Algorithmic Question Capabilities

Question Modes (Question Types)

The following questions define mathematical questions that accept student responses to a specified precision or margin of error. For more information on precision and margins of error, see Controlling Answer Tolerance.

#### Formula Mathematical Questions

For formula question types (including subtypes), you must use the "?" operator to define a margin of error. The "?" operator functions as a "+/-" operator.

##### Example 1.1

You can specify an absolute margin of error using the form x ? y, which accepts x +/- y. This question grades as correct any student response between 0 and 4 (inclusive).

```qu.1.topic=Non-numeric Math Questions@

qu.1.1.mode=Formula@
qu.1.1.name=Absolute margin of error@
qu.1.1.editing=useHTML@
qu.1.1.question=Enter a number within 2 units of  2.@
qu.1.1.tolerance=1.0E-9@```

Note:

• For formula questions, there is a tolerance of 1.0E-9, which represents the floating-point limit in the system.

##### Example 1.2

You can specify a percentage margin of error using the form x (1 ? y), where 100y is the percentage tolerance, which accepts x +/- x*y. This question grades correct any response within 5% of the correct answer.

```qu.1.2.question=What is the length of the shadow cast by a 10 foot wall when the sun is 30 degrees above the horizon?@
qu.1.2.answer=10 / tan(pi/6) foot (1 ? 0.05)@
qu.1.2.tolerance=1.0E-9@
qu.1.2.mode=Dimensioned Formula@
qu.1.2.name=Percentage tolerance with units@
qu.1.2.comment=Using the formula 10 / tan(pi/6)  foot, the correct answer is 17.3 feet.@
qu.1.2.editing=useHTML@```

Note:

• By using the comment field, you return custom feedback to a student if the response is incorrect.

##### Example 1.3

You can use a margin of error in questions that use algorithmic variables.

```qu.1.3.mode=Formula@
qu.1.3.name=Algorithmic Variables@
qu.1.3.editing=useHTML@
qu.1.3.algorithm=\$InitialSize=int(rint(2,10)*1000);
\$DoublingTime=rint(5,10);
\$NumDays=rint(2,4);
\$DeltaTime=int(\$NumDays*24);
\$Exponent=ln(2)/\$DoublingTime;
\$Size=int(\$InitialSize*e^(\$Exponent*\$DeltaTime));
@
qu.1.3.question=A bacterial culture is initially of size \$InitialSize. If the doubling time is \$DoublingTime hours,
what is the size of the culture after \$NumDays days?@
qu.1.3.tolerance=1.0E-9@```

For general information on algorithmic variables, see Overview of Algorithmic Question Capabilities.

##### Example 1.4

You can use margins of errors with complicated answers. Enclose the answer in parentheses when there is a percentage margin of error. Otherwise, the percentage error multiplies only the last term in your answer.

```qu.1.4.mode=Formula@
qu.1.4.name=Absolute margin of error in sum@
qu.1.4.comment=The total area is \$AreaSquare +  \$AreaCircle.@
qu.1.4.editing=useHTML@
qu.1.4.algorithm=\$length=rand(2,15,2);
\$diameter=rand(3,10,2);
\$AreaSquare=\$length*\$length;
\$AreaCircle=decimal(2,pi*(\$diameter/2)^2);
@
qu.1.4.question=What is the total area of a square with sides of length \$length and a circle with diameter \$diameter?@
qu.1.4.tolerance=1.0E-9@```

Important:

• The exact answer is enclosed in parentheses so that the margin of error applies to both terms in the sum. If the answer were \$length^2+pi*(\$diameter/2)^2 (1 ? 0.01), the margin of error would be based on only the second term, pi*(\$diameter/2)^2, because the assumed multiplication is of higher precedence than the addition.

#### Numeric Mathematical Questions

For Numeric question types, you cannot use the "?" operator to define a margin of error. It is recommended that you use the Question Editor on-screen dialog boxes for setting the margin of error in numeric and numeric-with-unit questions. However, once familiar with the syntax, you may prefer to use a text or HTML editor.

For more information on setting the precision and margin of error in the Question Editor, see Setting the Answer Tolerance in Numeric Questions.

##### Example 2.1

```qu.2.topic=Numeric Math Questions@

qu.2.1.question=Round 2.76789m to three significant digits.@
qu.2.1.showUnits=true@
qu.2.1.mode=Numeric@
qu.2.1.name=2.77m (exact)@
qu.2.1.editing=useHTML@```

Notes:

• This question grades correct the response 2.77m and equal-valued responses with trailing zeros, for example, 2.770m and 2.7700m.
• If you set showUnits=false, the system does not display the Units text field in the question.

##### Example 2.2

To specify that the student response must exactly match the value of your answer and contain specified number of significant digits, use grading=exact_sigd and digit=<n>, where <n> is a positive integer that defines the required number of significant digits.

```qu.2.2.question=A person counts 162 cars driving up a street in 1.00 hour.
How many cars drive up the street per minute? Use the correct number of significant digits in your answer.@
qu.2.2.showUnits=true@
qu.2.2.digit=3@
qu.2.2.mode=Numeric@
qu.2.2.name=2.70 (exactly 3 significant digits)@
qu.2.2.editing=useHTML@```

Notes:

• This question grades correct the response 2.70, but grades incorrect equal-values responses with a different number of trailing zeros, for example, 2.7 and 2.700.
• Ensure that <n> is greater than or equal to the number of digits in the correct answer (the value in the answer.num field). Otherwise, all student responses are graded incorrect.
• If the correct answer is dimensionless and you set showUnits=true, the system displays the question with a Units text field.

##### Example 2.3

To specify an absolute margin of error, use grading=toler_abs and err=<tolerance>, where <tolerance> is a floating-point number. This question grades correct any answer within 0.001 of 3.14159.

```qu.2.3.question=Estimate pi to at least 3 decimal places.@
qu.2.3.showUnits=false@
qu.2.3.err=0.001@
qu.2.3.mode=Numeric@
qu.2.3.name=Pi (+/- 0.001)@
qu.2.3.editing=useHTML@```

##### Example 2.4

To specify a precision and an absolute margin of error as a value in a significant digit, use grading=toler_sigd, digit=<n>, and err=<tolerance>, where <n> is a positive integer specifying the number of significant digits required and <tolerance> is a floating-point number specifying the tolerance value in the <n>th digit. This question grades correct 3.141 and 3.142 because they contain 4 significant digits and are within 0.001 of 3.14159. All other responses are graded incorrect.

```qu.2.4.question=Estimate pi to four significant digits (to within a unit in the fourth significant digit).@
qu.2.4.showUnits=false@
qu.2.4.digit=4@
qu.2.4.err=1.0@
qu.2.4.mode=Numeric@
qu.2.4.name=Pi (+/- 1 in the 4th significant digit)  using four significant digits@
qu.2.4.editing=useHTML@```

Notes:

• The behavior of this question is different from that of Example 2.3, which has only a margin of error, but no required precision.
• The margin of error is applied with respect to the value in the answer.num field, not the result of rounding the value in the answer.num field to <n> significant digits. For example, 3.14159 rounded to 4 significant digits is 3.142. However, 3.143 is graded incorrect because it is not within 0.001 of 3.14159.

##### Example 2.5

To specify a percentage margin of error, use grading=toler_perc and perc=<percentage>, where <percentage> is the percentage margin of error. This question grades correct any answer within 0.1% of 3.14159.

```qu.2.5.question=Estimate pi to within 1%.@
qu.2.5.showUnits=false@
qu.2.5.perc=0.1@
qu.2.5.mode=Numeric@
qu.2.5.name=Pi (+/- 0.1%)@
qu.2.5.editing=useHTML@
```

### Applet Questions

Your question banks can integrate interactive learning objects in the form of JavaTM applets.

#### Question Mode: Applet

Question file (.qu) syntax:

`qu.x.y.mode=Applet@`

The Applet question presents a Java applet. Students are required to interact with the applet using the mouse and/or keyboard to alter the applet or identify hot spots in the movie to produce the correct answer.

```qu.1.1.mode=Applet@
qu.1.1.question=The left-hand ball has mass of \$m1 kg and the right-hand ball has mass \$m2 kg.  The center mass of the left ball is \$h1 meters above the ground.  Move the right-hand ball to the height that gives it the same potential energy as the ball on the left.@
qu.1.1.applet=applets.sliderBall.SliderBall@
qu.1.1.width=100@
qu.1.1.height=200@
qu.1.1.param.right=2@
qu.1.1.param.left=\$h1@
qu.1.1.algorithm=\$h1=int(rint(35)+5);
\$h2=int(rint(35)+5);
\$m1=rand(10,70,3);
\$m2=sig(3,\$m1*\$h1/\$h2);@
qu.1.1.name=Physics Applet Question@
qu.1.1.editing=useHTML@```

#### Applet Question Authoring

There are three steps to creating an Applet Question. Steps 1 and 2 require some familiarity with Java programming.

1. Create and deploy the Java applet.
1. Create and deploy a Java class grading.
1. Author the question.

##### Step 1: Create and Deploy a Java Applet

The applet is required to do three things:

1. Provide a getResponse() method which can be queried to find the current student response.
1. Call method getParameter("response") to read the response parameter for a string containing any previous attempt at a response to this question, and initialize the applet to display that state.
1. Call method getParameter("locked") to read the locked parameter, and disable user modifications if the flag is set.

You can also make additional getParameter(paramName) values to read any additional parameters for initialization. These are passed to the param fields in the question (see Step 3).

After creating the applet, place it in the applets directory or an appropriate subdirectory if packages are used) on the Maple T.A. server.

##### Step 2: Create and Deploy a Java Class for Grading

This is a server-side grader module that accepts the student response as prepared by the applet and compares it against the correct answer you will set in Step 3.

1. An init(String paramName, String paramValue) method with void return type. This method receives a set of name/value pairs which it can use for initialization. These are passed from the grader.param fields in the question (see Step 3).
1. A grade(String correctAnswerText, String studentResponseText) method with a double return type value between 0.0 and 1.0, where 1.0 is full credit. The method should compare the text of the student response with text representing the correct answer. Note: The student response text is delivered from the applet's getResponse() method. In many cases, grading will be performed by judging whether the response is "the same" as the correct answer text. However, in some cases the correct answer text may only provide general guidelines for grading. For example, the correct answer might be "up and to the left" and the student response might be a point "(76,145)" that the student clicked on.

After your grader class is created, create a JAR file and place it in the /WEB-INF/lib directory so it is accessible to the class loader. Then restart the Maple T.A. server.

##### Step 3: Author the Maple T.A. Question

The last step is to host your Java applet in a Maple T.A. question, using the Applet question type. Applet questions must be authored in a plain text script file.

For example, you can enter the sample code above for a question with slider balls in a plain text file, then save the file as filename.qu.

Question Modes (Question Types)

### Clickable Image Question Source Script

Question Mode: Clickable Image

Question Editor question type: Clickable Image

Question file (.qu) syntax:

`qu.x.y.mode=clickable image@`

The following example source script creates a Clickable Image question.

`qu.1.topic=Clickable Image Question Example Script@`
`qu.1.1.mode=Clickable Image@`
`qu.1.1.name=Click a region on the graph@`
`qu.1.1.editing=useHTML@`
`qu.1.1.algorithm=\$gp=rint(2);`
`  \$sign=switch(\$gp,"positive", "negative");`
`  \$region=\$gp + 3;@`
`qu.1.1.question=Click a <b>\$sign</b> region on the graph.</font></p>@`
`qu.1.1.imageURL=/questionbanks/physio/ClickableImage.gif@`
`qu.1.1.answer=\$region@`
`qu.1.1.width=373@`
`qu.1.1.height=568@`
`qu.1.1.region.1=0,284,187,284,187,0,0,0@`
`qu.1.1.region.2=372,285,372,567,187,567,188,285@`
`qu.1.1.region.3=187,283,220,133,242,63,260,27,267,18,278,14,287,18,296,25,308,47,323,89,337,134,372,285@`
`qu.1.1.region.4=1,286,14,348,39,454,60,519,68,535,79,549,93,555,102,552,107,548,118,533,132,499,151,434,186,286@`
`qu.1.1.region.5=0,286,25,398,42,465,63,525,77,546,89,554,104,551,121,526,148,447,187,282,185,567,0,567@`
`qu.1.1.region.6=372,0,301,0,187,0,187,15,187,119,187,154,186,283,212,165,225,117,236,81,252,38,264,19,272,14,280,13,287,15,298,26,313,56,345,164,372,283@`

`Note: The above question has the image defined by this line:`

`qu.1.1.imageURL=/questionbanks/physio/ClickableImage.gif@`

```You will have to replace the image path with the correct one for your server. Please upload the image below to your server and use that path instead.
```

Clickable Image Questions

Question Modes (Question Types)

### Essay Question Source Script

The following example source script creates an Essay question.

```qu.1.topic=Essay Question Example Script@
qu.1.1.mode=Essay@
qu.1.1.name=Friction@
qu.1.1.editing=useHTML@
qu.1.1.question=Contrast <i>kinetic</i>  and <i>static</i> friction.@```

Essay Questions

Question Modes (Question Types)

### Fill in the Blanks Question Source Script

The blanks question type has been deprecated. Use the Question Designer question type instead. For a sample Question Designer question, see Question Designer Question Example using Various Embedded Questions.

### Flash Questions

#### Question Mode: Flash

Question file (.qu) syntax:

`qu.x.y.mode=Flash@`

The Flash question presents a Flash movie of the question. Students are required to interact with the movie using the mouse and/or keyboard to alter the movie or identify hot spots in the movie to produce the correct answer.

```qu.1.1.mode=Flash@
qu.1.1.question=Move the red disk to the point (\$x, \$y).@
qu.1.1.width=400@
qu.1.1.height=400@
qu.1.1.algorithm=
\$x = range(1,8);
\$y = range(1,8);@
qu.1.1.name=Graph Coordinates@
qu.1.1.editing=useHTML@```

#### Flash Question Authoring

To create a Flash movie, you will need Flash development software (for example, Adobe® Flash® CS3) and some familiarity with Flash programming. Your flash movie must implement the following features.

• A pair of variables called response and locked should be declared.
• Whenever a student interacts with the movie and brings it to a new state, that state should be translated into a text string and assigned to the variable response. You are free to decide for yourself how this translation is done.
• When the Flash movie starts, it reads the variable response and finds a string that was returned by a previous call to GetVariable("response"). You must program the movie to initialize its appearance to the state consistent with that response.
• The Flash movie also reads the variable locked. This variable determines when a student is allowed to modify his/her response. When the value of locked is equal to true, this signals to the Flash movie that the question is in 'feedback' mode; in this case, the movie should present in a form suitable for feedback.

After creating the Flash movie, upload it to a folder on the class web site, as described in Flash Movies and Java Applets in Questions

Finally, you need to host the Flash movie in a Maple T.A. question, using the Flash question type. Flash questions must be authored in a plain text script file.

For example, the demonstrated code above is for a Flash question which asks students to move the disk to a specific point on the Cartesian plane.

Question Modes (Question Types)

### Formula - Form Variant

#### Question Mode: Formula (with "form" grading)

Question file (.qu) syntax:

```qu.x.y.mode=Formula@

The Formula - Form Variant question type is a restricted-grading variant of the Formula question type. In this mode, the student response is required not only to be mathematically equal to the correct answer, but also to be expressed in the same form.

Thus,

```(x-1)(x+1),
(x+1)(x-1),```

and

```(x^2-1)
```

would be graded the same by a standard formula question. However, with the form submode set, only the first two would be graded as equivalent.

Authoring of this question variant is not directly available using the Question Editor. To invoke this grading variant, you must create a formula question, and then edit the source by adding a line: "grading=form@".

You can also specify it in the source for a question. When editing the source, include a line of the form "qu.1.1.grading=form@"

Question Modes (Question Types)

### Graph Sketching Question Source Script

The following example source scripts create Sketch questions.

```qu.1.1.mode=sketch@
qu.1.1.question=<p class="noindent">Sketch the graph of the function <math xmlns="http://www.w3.org/1998/Math/MathML"  display="inline">
<mi>y</mi>
<mo>=</mo>
<mi>x</mi>
<mo>+</mo>
<mn>1</mn>
[/itex].</p>@
qu.1.1.gridlines=4@
qu.1.1.axes=-2,2,-2,2@
qu.1.1.axes.labeled=true@
qu.1.1.axes.background=\@ImageBase @
qu.1.1.example=-2,-1 1,2@
qu.1.1.answer=check(( linear(\$1) ) &&  ( goes_through(\$1,0,1) ))@
qu.1.1.info=@

qu.1.2.mode=sketch@
qu.1.2.algorithm=\$a = int(rand(2,6));
\$a2 = int(\$a*\$a);
\$xmax = int(2*\$a);
\$x = sqrt(2)*\$a;@
qu.1.2.question=<p class="noindent">Sketch the graph of the function <math xmlns="http://www.w3.org/1998/Math/MathML"  display="inline">
<mi>y</mi>
<mo>=</mo>
<msup>
<mrow>
<mi>x</mi>
</mrow>
<mrow>
<mn>2</mn>
</mrow>
</msup>
<mo>&#8725;</mo>
<mn>\${a2}</mn>
[/itex].</p>@
qu.1.2.gridlines=4@
qu.1.2.axes=-\${xmax},\${xmax},-4,4@
qu.1.2.axes.labeled=true@
qu.1.2.axes.background=\@ImageBase @
qu.1.2.example=-\${x},2 -\${a},1 0,0 \${a},1  \${x},2@
qu.1.2.answer=check(( goes_through(\$1,0,0)  && goes_through(\$1,-\${a},1) && goes_through(\$1,\${a},1)  ) && ( slope_at(\$1,0) == 0 ) && ( decreasing(restriction(\$1,-\${x},0))  ) && ( increasing(restriction(\$1,0,\${x})) ) && ( concave_up(\$1)  ))@
qu.1.2.info=@```

Question Modes (Question Types)

### Key Word or Phrase Question Source Script

There is no Question Editor interface for Key Words (or phrase) questions. To create a key word question, you must use a text or HTML editor to produce script files.

In Key Words questions, the text of the student response is checked for key words. The system ignores other text, extra white space, and capitalization in the student response.

In the correct answer, identify keywords by enclosing them in parentheses. The complete text of your correct answer (omitting parentheses) is used as feedback if the student response is incorrect.

The following example source script creates a Key Words question.

```qu.1.topic=Key Words Question Example Script@
qu.1.1.mode=Key Words@
qu.1.1.name=<b>Translation into French - four houses</b>@
qu.1.1.question=<b>Translate into French:</b>
<p>"four houses".</p>
@
The French phrase for "four houses"  is "(quatre)  (maisons)"
@```

Question Modes (Question Types)

### Labeling Graphics in Questions Source Script

The following example source script creates a Numeric question with a labeled graph.

Suppose you have uploaded an image file to your class and its URL is "web/MyClass/Public_Html/ball.gif".

```qu.1.1.mode=Numeric@
qu.1.1.question=<p class="noindent">A ball is thrown upward from the top of a 40
foot high tower at an initial velocity of 64 feet/second. The graph of the height
of the ball versus time is shown below. What is the maximum height of the ball in
feet? Express your answer to an accuracy of at least 3 significant figures.
</p>
<div class="labelledImage" style="height: 250px; width: 200px; float: none;">
<img src="web/MyClass/Public_Html/ball.gif">
<div style="left: 120px; top: 10px" class="centered">time (seconds)</div>
<div style="left: 10px; top: 100px" class="centered">height (meters)</div>
</div>
@
qu.1.1.showUnits=false@
qu.1.1.info=@
```

Questions with Labeled Images

Question Modes (Question Types)

### List Question Source Script

#### Example 1: List Question - Textbox Display - Exact Grader Options

Sets a question with a text response cell that uses the exact grader to enforce capitalization and punctuation in the answer. Specifies three expected responses with credit for each.

```qu.1.1.question=
Who first developed the General Theory of Relativity?
@
qu.1.1.display=text@
qu.1.1.credit.1=1.0@
qu.1.1.credit.2=1.0@
qu.1.1.credit.3=0.25@
qu.1.1.mode=List@
qu.1.1.editing=useHTML@```

#### Example 2: List Question - Textbox Display - Relaxed Grader Options

Sets a question with a text response cell that uses the relaxed grader to ignore case sensitivity and punctuation in student responses. Specifies three expected responses with credit for each and a comment for each.

```
qu.1.2.question=
Who first developed the General Theory of Relativity?
@
qu.1.2.display=text@
qu.1.2.credit.1=1.0@
qu.1.2.comment.1=Yes, but you should specify his first name too.@
qu.1.2.comment.2=Exactly correct.@
qu.1.2.credit.2=1.0@
qu.1.2.credit.3=0.25@
qu.1.2.comment.3=Your answer is partially correct. Hawking helped to extend Albert Einstein's General Theory of Relativity.@
qu.1.2.mode=List@
qu.1.2.editing=useHTML@
```

#### Example 3: List Question - Menu Display - Exact Grader Options

Sets a question with a menu list response object that uses the exact grader. Specifies credit for each option in the list, and a comment for each.

```
qu.1.3.question=
Who first developed the General Theory of Relativity?
@
qu.1.3.credit.1=0@
qu.1.3.comment.1=No, Sir Isaac Newton formed the theory of Newtonian gravitation that preceded Albert Einstein's General Theory of relativity.@
qu.1.3.comment.2=Correct.@
qu.1.3.credit.2=1.0@
qu.1.3.credit.3=0.25@
qu.1.3.comment.3=Your answer is partially correct. Hawking helped to extend Albert Einstein's General Theory of Relativity.@
qu.1.3.mode=List@
qu.1.3.editing=useHTML@
```

List Questions in the Question Designer

Question Modes (Question Types)

### Maple-graded Formula Question Source Script

#### Question Mode: Maple

Question file (.qu) syntax:

```qu.x.y.mode=Maple@
type=formula@```

In Maple-graded Formula question types, students can enter a math formula, that is, an expression constructed of numbers, variable names, and the standard arithmetic expressions and functions.

 Note: In the Question Editor, on the Maple-graded question screen, the Select the type of expression you want to accept field lists the Maple-graded Formula option as simply Formula.

#### Example

The following example source script creates a Maple-graded question using the Formula subtype.

qu.1.topic=Maple Formula Question Example Script@ qu.1.1.question=What is the derivative of x^2 with respect to x?@ qu.1.1.maple=evalb(\$RESPONSE = diff(x^2,x));@ qu.1.1.type=formula@ qu.1.1.mode=Maple@ qu.1.1.allow2d=1@ qu.1.1.comment=The correct answer is 2*x.@ qu.1.1.name=Derivative - Maple Formula@ qu.1.1.editing=useHTML@

qu.1.2.question=What is the integral of 2*x with respect to x?@ qu.1.2.maple=evalb(diff(\$RESPONSE,x)=2*x);@ qu.1.2.type=formula@ qu.1.2.mode=Maple@ qu.1.2.comment=The correct answer is x^2.@ qu.1.2.name=Integral - Maple Formula@ qu.1.2.editing=useHTML@

To return feedback to a student if the response is incorrect, you must use the comment field. For more information, see Using the comment Field in a Maple Question, below.

Plotting a Student Response

Tutorial: Maple-based Algorithmic Question Authoring

Question Modes (Question Types)

#### Using the Comment Field in a Maple Question

The following example source script returns feedback to the student including a comment in a Maple formula question.

 Note: When a student response is incorrect, Maple question subtypes can return feedback. You must enter Maple code that evaluates to the correct answer by using the \$ANSWER variable. See Maple-graded Questions.

```qu.1.topic=Maple Comment Example Script@
qu.1.1.question=What is the greatest common divisor of \$a and \$b?@
qu.1.1.type=formula@
qu.1.1.mode=Maple@
qu.1.1.allow2d=1@
qu.1.1.comment=Try again!@
qu.1.1.editing=useHTML@
qu.1.1.algorithm=\$a=int(rand(3, 100));
\$b=int(rand(3, 100));
\$gcd=maple("gcd(\$a, \$b)");@```

The Algorithm Designer

### Maple Syntax Question Source Script

#### Question Mode: Maple

Question file (.qu) syntax:

```qu.x.y.mode=Maple@
type=maple@```

##### Example Uses

The Maple Syntax subtype is particularly useful when the answer is to be expressed as a:

• Definite integral, int(f(x),x=a..b)
• Derivative, diff(f(x),x)
• Limit, limit(f(x), x=0)
• Differential equation, for example, diff(y(x,t),t,t)=c^2*diff(y(x,t),x,x)
• Set, for example, {1,4,9}
• Matrix, for example,

The following example source script creates a Maple-graded question using the Syntax subtype, and using the text-entry student response area.

```qu.1.topic=Maple Syntax Question Example Script@
qu.1.1.question=What is the Maple syntax for the derivative of x^2 with respect to x? Do not include the trailing semicolon.@
qu.1.1.maple=evalb("\$RESPONSE" = "diff(x^2,x)") or evalb("\$RESPONSE" = "Diff(x^2,x)");@
qu.1.1.type=maple@
qu.1.1.mode=Maple@
qu.1.1.allow2d=0@```
```qu.1.1.comment=The correct answer is diff(x^2,x).@
qu.1.1.name=Derivative - Maple Syntax@
qu.1.1.editing=useHTML@```

```qu.1.2.question=What is the Maple syntax for the integral of 2*x with respect to x? Do not include the trailing semicolon.@
qu.1.2.maple=evalb("\$RESPONSE"="int(2*x,x)") or evalb("\$RESPONSE"="Int(2*x,x)");@
qu.1.2.type=maple@
qu.1.2.mode=Maple@
qu.1.1.allow2d=0@```
```qu.1.2.comment=The correct answer is int(2*x,x).@
qu.1.2.name=Integral - Maple Syntax@
qu.1.2.editing=useHTML@```
` `

To return feedback to a student if the response is incorrect, you must use the comment field. For more information, see Using the Comment Field in a Maple Question.

Plotting a Student Response

### Matching Source Script

The following example source script creates a Matching question. This algorithmically generated Matching question uses images (not text) for matching pairs.

`qu.1.topic=Matching Example Script@`
```qu.1.1.mode=Matching@
qu.1.1.name=pKa sort by matching@
qu.1.1.editing=useHTML@
qu.1.1.algorithm=
\$a=switch(rint(4),
"<img src=../classes/myclass/pka/pka01a01.gif>",
"<img src=../classes/myclass/pka/pka01a02.gif>",
"<img src=../classes/myclass/pka/pka01a03.gif>",
"<img src=../classes/myclass/pka/pka01a04.gif>");
\$b=switch(rint(4),
"<img src=../classes/myclass/pka/pka02a01.gif>",
"<img src=../classes/myclass/pka/pka02a02.gif>",
"<img src=../classes/myclass/pka/pka02a03.gif>",
"<img src=../classes/myclass/pka/pka02a04.gif>");
\$c=switch(rint(5),
"<img src=../classes/myclass/pka/pka03a01.gif>",
"<img src=../classes/myclass/pka/pka03a02.gif>",
"<img src=../classes/myclass/pka/pka03a03.gif>",
"<img src=../classes/myclass/pka/pka03a04.gif>",
"<img src=../classes/myclass/pka/pka03a05.gif>");
\$d=switch(rint(6),
"<img src=../classes/myclass/pka/pka04a01.gif>",
"<img src=../classes/myclass/pka/pka04a02.gif>",
"<img src=../classes/myclass/pka/pka04a03.gif>",
"<img src=../classes/myclass/pka/pka04a04.gif>",
"<img src=../classes/myclass/pka/pka04a05.gif>",
"<img src=../classes/myclass/pka/pka04a06.gif>");
\$e=switch(rint(2),
"<img src=../classes/myclass/pka/pka05a01.gif>",
"<img src=../classes/myclass/pka/pka05a02.gif>");
@
qu.1.1.format.columns=5@
qu.1.1.question=Sort the molecules below from highest to lowest pKa:@
qu.1.1.term.1=1 (lowest pKa, Most acidic)@
qu.1.1.term.1.def.1=\$a@
qu.1.1.term.2=2@
qu.1.1.term.2.def.1=\$b@
qu.1.1.term.3=3@
qu.1.1.term.3.def.1=\$c@
qu.1.1.term.4=4@
qu.1.1.term.4.def.1=\$d@
qu.1.1.term.5=5 (highest pKa, Least acidic)@
qu.1.1.term.5.def.1=\$e@```

Matching Questions

Question Modes (Question Types)

### Matrix

The Matrix question type generates an n by m matrix of text fields, each of which accepts a number or formula.

Matrix questions must be created in a plain text .qu file. You must specify a unique matrix as the correct solution.

Note: It is recommended that you use the Maple Syntax question type for questions that will have a matrix response. Maple Syntax questions provide more flexibility than the Matrix questions in question authoring and grading. With the Maple Syntax question type:

• Rather than showing the student with a specific size of matrix with a blank for each entry, the student can select the appropriate size of the matrix in their answer (for instance, using a palette).
• By sending the entire matrix to Maple for grading, you can evaluate properties of the matrix (such as whether it is invertible or symmetric).

Question Modes (Question Types)

### Multipart Formula

#### Question Mode: multipart formula

Question file (.qu) syntax:

`qu.x.y.mode=multipart formula@`

The multipart formula question type behaves as a multipart question in which each part is a formula question. It displays multiple text fields for multiple student responses.

 Note: A multipart formula question displays multiple individual text fields, while a multi formula question requires a student to enter multiple formulas in one text field as its correct answer.

Multipart formula questions must be authored in script files.

To identify multiple correct answers, separate each with a semicolon in your answer field definition statement. (Include a trailing semicolon for the last answer in the list.)

In a test, the input field for the response appears as shown in Figure A.1.

Question Modes (Question Types)

### Multipart Question Source Script

Multipart questions can consist of any combination of questions as parts, including nested multipart questions.

The following example source script creates a Multipart question that contains a nested Multipart question.

`qu.1.topic=Multipart Question Example Script@`
```qu.1.1.mode=Multipart@
qu.1.1.name=<b>Full multipart question featuring nested multipart</b>@
qu.1.1.editing=useHTML@
qu.1.1.algorithm=
\$n=int(rand(5,15));
\$a=int(rand(1,10));
\$nminus = int(\$n - 1);
\$nplus = int(\$n + 1);
\$isEven=int(eq(\$n/2, int(\$n/2)));
\$k=if(\$isEven, 1, 3);
\$type=if(\$isEven, "even", "odd");
\$othertype=if(\$isEven, "odd", "even");
@
qu.1.1.question=
This question concerns the integral of the function
[itex]
<msup>
<mi>x</mi>
<mn>\$n</mn>
</msup>
[/itex].
@
qu.1.1.weighting=1,1,1@
qu.1.1.numbering=alpha@
qu.1.1.part.1.question=
In the first part, use a geometric argument to decide whether
[itex]
<msubsup>
<mo>&Integral;</mo>
<mn>-\$a</mn>
<mn>\$a</mn>
</msubsup>
<msup><mi>x</mi><mn>\$n</mn></msup>  <mi>dx</mi>
[/itex] is:
@
qu.1.1.part.1.editing=useHTML@
qu.1.1.part.1.mode=Multiple Choice@
qu.1.1.part.1.choice.3=zero@
qu.1.1.part.1.choice.2=negative@
qu.1.1.part.1.choice.1=positive@
qu.1.1.part.2.part.2.question=
Use the indefinite integral above to compute
[itex]
<msubsup>
<mo>&Integral;</mo>
<mn>-\$a</mn>
<mn>\$a</mn>
</msubsup>
<msup><mi>x</mi><mn>\$n</mn></msup>  <mi>dx</mi>
[/itex]
@
qu.1.1.part.2.weighting=1,1@
qu.1.1.part.2.question=
@
qu.1.1.part.2.editing=useHTML@
qu.1.1.part.2.numbering=roman@
qu.1.1.part.2.part.1.mode=Formula Mod C@
qu.1.1.part.2.part.2.mode=Formula@
qu.1.1.part.2.part.1.editing=useHTML@
qu.1.1.part.2.mode=Multipart@
qu.1.1.part.2.part.2.editing=useHTML@
qu.1.1.part.2.part.1.question=
Evaluate
[itex]
<mo>&Integral;</mo>  <msup><mi>x</mi><mn>\$n</mn></msup>  <mi>dx</mi>
[/itex].
@
qu.1.1.part.3.question=
The geometric argument in the first part was based on the fact that
[itex]
<msup>
<mi>x</mi>
<mn>\$n</mn>```
```  </msup>
[/itex] is an <1> function.
@
qu.1.1.part.3.extra=\$othertype@
qu.1.1.part.3.editing=useHTML@
qu.1.1.part.3.blank.1=\$type@
qu.1.1.part.3.mode=Complete Sentence@```

Multipart Questions

Question Modes (Question Types)

### Multiple Choice Question Source Script

The following example source script creates a Multiple Choice question.

```qu.1.topic=Multiple Choice Question Example Script@
qu.1.1.mode=Multiple Choice@
qu.1.1.name=Type of Point@
qu.1.1.editing=useHTML@
qu.1.1.question=For f(x)=(x-4)(x-1)(x+3), classify the point with x-coordinate 2/3+1/3*37^(1/2).@
qu.1.1.choice.1=global minimum@
qu.1.1.choice.2=local minimum@
qu.1.1.choice.3=inflection point@
qu.1.1.choice.4=local maximum@
qu.1.1.choice.5=global maximum@
qu.1.1.choice.6=none of the above@```

Multiple Choice Questions

Question Modes (Question Types)

### Multiple Selection Question Source Script

#### Question Mode: Multiple Selection; Non-permuting Multiple Selection

Question Editor question type: Multiple selection

Question file (.qu) syntax:

```qu.x.y.mode=multiple selection@
qu.x.y.mode=non permuting multiple selection@
```

Multiple selection questions are similar to multiple choice items. However, they can require the user to identify more than one correct answer. You can create as many choices as you want.

In multiple selection questions, the selections are permuted each time they appear. In non-permuting multiple selection questions, the selection order is static.

#### Example

The following example source script creates a Multiple Selection question.

qu.1.topic=Multiple Selection Question Example Script@ qu.1.1.mode=Multiple Selection@ qu.1.1.name=Characterization of function at a point@ qu.1.1.editing=useHTML@ qu.1.1.question=Classify f(x)=x^3-3x^2+4 at the point with x-coordinate 2. <p><i>(Choose all that apply)</i></p>@ qu.1.1.answer=2, 5@ qu.1.1.choice.1=negative@ qu.1.1.choice.2=zero@ qu.1.1.choice.3=positive@ qu.1.1.choice.4=increasing@ qu.1.1.choice.5=extremum@ qu.1.1.choice.6=decreasing@ qu.1.1.choice.7=concave down@ qu.1.1.choice.8=inflection point@ qu.1.1.choice.9=concave up@

Multiple Selection Questions

Question Modes (Question Types)

### Numeric Question Source Script

The following example source script creates a Numeric question.

qu.1.topic=Numeric Question Example Script@ qu.1.1.mode=numeric@ qu.1.1.question= <question_text> @ qu.1.1.answer.num=<numeric part of the answer, for example, 3>@ qu.1.1.answer.units=<units part of the answer, for example, m/s>@ qu.1.1.showUnits=<true or false; whether to display the question with a Units text field>@ qu.1.1.grading=<grading mode; see below>@ qu.1.1.units=<(optional) reference to external table of units; see below>@ qu.1.1.digit=<# sig digits (positive integer); required for exact_sigd and toler_sigd grading modes>@ qu.1.1.err=<error/tolerance; required for toler_sigd and toler_abs grading modes>@ qu.1.1.perc=<percentage error/tolerance; required for toler_perc grading mode>@

Numeric Questions

Question Modes (Question Types)

### Question Designer Question Example using Various Embedded Questions

This is an example of a question designer question containing response objects within the question statement. Note: The Question Designer question type supersedes the Inline question type.

#### Description

• Question Designer questions are multipart questions.
• You control question weighting.
• You control formatting of the entire question (including tables).
• Blanks can be inserted inside tables (to create fill in the blanks tables of data).
• Multiple Choice and Multiple Selection Questions are set with response choices displayed horizontally rather than following the question. This enables you to create survey-style questions.
• Individual response cells are indicated by angle brackets, in the form <#>, where # corresponds to the sequentially numbered part.
• This question includes individual response objects (embedded questions) as follows.
• Blank 1 - Formula question
• Blank 2 - Numeric question
• Blank 3 - Numeric question with required units
• Blank 4 - List question, text input, relaxed grading, multiple answers, partial credit
• Blank 5 - List question, text input, exact grading, multiple answers, partial credit
• Blank 6 - List question, menu input, exact grading, partial credit

```qu.1.topic=Question Designer Question Example@
qu.1.1.mode=Inline@
qu.1.1.editing=useHTML@
qu.1.1.weighting=1,1,1,1,1,1@
qu.1.1.numbering=alpha@
qu.1.1.part.1.editing=useHTML@
qu.1.1.part.1.tolerance=1.0E-9@
qu.1.1.part.1.question=xx@
qu.1.1.part.1.mode=Formula@
qu.1.1.part.2.editing=useHTML@
qu.1.1.part.2.question=xx@
qu.1.1.part.2.mode=Numeric@
qu.1.1.part.2.showUnits=false@
qu.1.1.part.3.showUnits=true@
qu.1.1.part.3.editing=useHTML@
qu.1.1.part.3.question=xx@
qu.1.1.part.3.mode=Numeric@
qu.1.1.part.4.editing=useHTML@
qu.1.1.part.4.question=xx@
qu.1.1.part.4.mode=List@
qu.1.1.part.4.display=text@
qu.1.1.part.4.credit.3=0.5@
qu.1.1.part.4.credit.2=1.0@
qu.1.1.part.4.credit.1=1.0@
qu.1.1.part.5.editing=useHTML@
qu.1.1.part.5.question=xx@
qu.1.1.part.5.mode=List@
qu.1.1.part.5.display=text@
qu.1.1.part.5.credit.3=0.5@
qu.1.1.part.5.credit.2=1.0@
qu.1.1.part.5.credit.1=1.0@
qu.1.1.part.6.editing=useHTML@
qu.1.1.part.6.question=xx@
qu.1.1.part.6.mode=List@
qu.1.1.part.6.credit.4=0.0@
qu.1.1.part.6.credit.3=0.0@
qu.1.1.part.6.credit.2=0.5@
qu.1.1.part.6.credit.1=1.0@
qu.1.1.algorithm=\$n=int(rint(20) + 2);
\$n2=\$n-1;
@
qu.1.1.question=
<p>This single question demonstrates the power and flexibility of the inline question type. There are 6 individual response cells included, each of which requires a different type of student response.</p>

<p><i><font face="arial"  size="-1">
<b>Notes:</b>
<br>- Response cells can appear anywhere within the formatted question statement, including within tables.
<br>- Response cells can consist of any individual question mode, including response cells that handle text (lenient or stringent string matching), numbers, formulas, or any other question variety.
<br>- Partial credit can be allowed for exact-graded text or menu-style entry cells.</font></i></p>

<p>Here is a question using a <b>symbolic formula</b> blank:
<br>Let [itex]<mi>y</mi><mo>=</mo><msup><mi>x</mi><mn>\$n</mn></msup>[/itex]. What is the derivative of [itex]<mi>y</mi>[/itex] with respect to [itex]<mi>x</mi>[/itex]?  <1><br>
<font face="arial" size="-1"><i>Enter only the expression for the derivative, omitting "y' =".<b>
Try it:</b>  The answer is \${mathml("\$n x^(\$n2)")}</i> </font>
</p>

<p>Here is a <b>numeric</b> blank style of question:<br>
3+8=<2><br>
<br><i><font face="arial"  size="-1">Numeric questions can specify margin of error and significant figure precision.</font></i>
</p>

<p>The following numeric blanks question requires a <b>number and a unit dimension</b> in its response:<br>
If a cat walks 20ft in 2min, how fast is the cat walking?  <3>
<br><i><font face="arial"  size="-1">Most standard equivalent unit dimensions are graded correctly by the system, or you can specify your own table of unit equivalents to apply to a question.</p></font></i>

<p>This next question grades input in the form of a <b>text string,</b> and can also be set to accept multiple correct answers, so "Einstein" <i>or</i>  "einstein" will be graded as correct, as will "Albert Einstein"  <i>or</i> "aLbeRt einSTEIN".
<br>
Who first developed the General Theory of Relativity? <4><br>
<br><i><i><font face="arial"  size="-1">This question <b>also</b> awards partial credit if you answer 'Stephen Hawking'. </font></i></i></p>

<p>This is the same question, with the grader set to accept only an <b>exact match</b> of the answer text string, however it too can be set to accept multiple correct answers, so "Einstein" <i>or</i> "Albert Einstein"  will be graded as correct, but "einstein"  or  "aLbeRt einSTEIN" will be graded wrong.
<br>
Who first developed the General Theory of Relativity? <5><br>
<br><i><font face="arial"  size="-1">This type of question also allows you to give some partial credit for certain responses, so if you enter "einstein"  or "albert einstein" you will get 1/2 credit for this question.</font></i></p>

<p>In the following question the student picks from a <b>drop-down menu</b> of choices. Partial credit can be set for some options, full credit for others.<br>
Who first developed the General Theory of Relativity? <6><br>
<font face="arial" size="-1"><i>In this case, you get full credit for 'Albert Einstein' and 1/2 credit for 'Stephen Hawking'.</font></i></p>
@
```

Mathematical Formula, Formula Subtype

Numeric Questions

List Questions in the Question Designer

Question Modes (Question Types)

### Short Phrase Question Source Script

The short phrase question type has been deprecated. Use the List question type instead. For an example List question, see List Question Source Script.

Question Modes (Question Types)

### True or False Question Source Script

The following example source script creates a True/False question.

```qu.1.topic=True-or-False Question Example Script@
qu.1.1.mode=True False@
qu.1.1.name=Quantum Tunneling@
qu.1.1.editing=useHTML@
qu.1.1.question=The phenomenon of quantum tunneling has a counterpart in classical physics.@
qu.1.1.choice.1=True@
qu.1.1.choice.2=False@```

True/False Questions

Question Modes (Question Types)