WeBWorKdocs

sq_webwork:


Home
Current UR
courses
Visitor
page
Intro to
WeBWorK
WeBWorK 2
Twiki
WW
Community
Grant Support
& awards
Discussion
group
Problem
library
Write/modify
problems
Create &
manage course
Tutorial on
running a course
HowTos
FAQ
WeBWorK2
FAQ
Software
Download
How to
Install WW server
Feedback
Site Map
Change
preferences
Change
password





Prev | Next | tutorial

This page is no longer being maintained. The new URL for this content is http://webwork.maa.org/wiki/MatchingProblems

'Matching list' basic example

(for more advanced information on matching lists, see Match.pm) To obtain the problem:


(1 pt) rochesterLibrary/setMAAtutorial/matchinglistexample.pg

Matching list example

Place the letter of the derivative next to each function listed below:

 1. 2x^5
 2. \tan(x)
 3. \sin(2x)
 4. \sin(3x)


A. 4x^{1}
B. \sec^2(x)
C. 3\cos(3x)
D. 2\cos(2x)

Let's print the questions again, but insist that the first two questions (about sin and cos) always be included. Here is a second way to format this question, using tables:

 1. \cos(x)
 2. \sin(x)
 3. \tan(x)


A. -\sin(x)
B. \cos(x)
C. \sec^2(x)

And below is yet another way to enter a table of questions and answers:

 1. \cos(x)
 2. \sin(x)
 3. \tan(x)


A. -\sin(x)
B. \cos(x)
C. \sec^2(x)
D. The derivative is
not provided


WARNINGS
µ¦å{h­
{viewSource(setMAAtutorial/matchinglistexample.pg)}


  1. Since this is a matching questions, we do not usually wish to tell students which parts of the matching question have been answered correctly and which are incorrect. That is too easy. To accomplish this we set the following flag $showPartialCorrectAnswers to 0 (line 11).

  2. Saying that $ml$ml is a scalar variable which contains a pointer to the match list object, but you can think of the match list object as being shoe horned into the variable $ml. You need to remember that $ml Some people use the convention $o_ml to remind them that the variable contains an object, but for short problems that is probably not necessary.

    An object contains both data (in this case the list of questions and answers) and subroutines (called methods) for manipulating that data.

  3. The construction $ml ->qa(..list of alternating questions and matching answers ...). Asks the object $ml to store the matching questions and answers given in the argument in its private data (lines 35 and 45). Note that that you can call qa() more than once with a match list and it will add new questions. This is not true with all objects. Some objects will overwrite previous questions if qa() is used more than once.

  4. The construction $ml->choose(3) asks the object to choose three question/answer pairs from its private data and

  5. $out = $ml->print_q() asks the object to store a string of the formatted questions in the variable $out. Calling \{ $ml->print_q() \} within BEGIN_TEXT / END_TEXT statements will just append the formatted questions to the ouput text that the student sees (line 60).

  6. $out = $ml->print_a() asks the object to store a string of the formatted answers in the variable $out. \{ $ml->print_a() \} can be used just like above to append a string of the formatted answers to the output text seen by the student (line 62).

  7. ANS is needed to compare the students answers to the correct answers (line 66).

  8. The answer evaluator str_cmp is just one of many possible answer evaluators from which to choose, each of which specifies a different method for comparing the correct answers to the students answers. str_cmp is almost always used with matching lists since the correct answers will always be a letter indicating one of the possible answers (line 66).


Prev | Next | tutorial

Last update: Monday, March 3, 2008 at 6:37:01 PM.
This site maintained using Manila and Frontier software.