From WeBWorK
Jump to: navigation, search

Matching Question

Click to enlarge

This PG code shows how to set up a matching question.

Templates by Subject Area

PG problem file Explanation

Problem tagging data

Problem tagging:




Initialization: We use to construct the list of matching object, and the custom problem grader fluid from for incremental grading.

#  Create a matching list and use popups
$ml = new_match_list();
"No answer" => "?",
"A" => "A", "B" => "B", "C" => "C", 
"D" => "D", "E" => "E", "F" => "F",
"G" => "G", "H" => "H", "I" => "I",

#  Add correct questions and answers
"Question a?", "Answer a",
"Question b?", "Answer b",
"Question c?", "Answer c",
"Question d?", "Answer d",
"Question e?", "Answer e",
"Question f?", "Answer f",

#  Add extra incorrect answers
"Extra answer 1", 
"Extra answer 2",
$ml->makeLast("None of the above");

Setup: Since we are choosing 6 questions and 2 extra answers and have 1 entry in makeLast, we must create a popup list with 9 entries A through I.

For more details, see MatchingProblems from the Problem Techniques documentation.

Match each question with its answer.
\{ ColumnMatchTable($ml, valign=>'TOP') \}

Main Text: The ColumnMatchTable() is provided by the macro file

$showPartialCorrectAnswers = 0;

#  Incremental grader
$ENV{'grader_numright'} = [2,4,6];
$ENV{'grader_scores'} = [0.3,0.6,1];
$ENV{'grader_message'} = "You can earn " .
"30% partial credit for 2 - 3 correct answers, and ".
"60% partial credit for 4 - 5 correct answers.";

#  All or nothing grader
# install_problem_grader(~~&std_problem_grader);

ANS( str_cmp( $ml->ra_correct_ans ) );

Answer Evaluation: We must withhold feedback from students by setting $showPartialCorrectAnswers = 0; We use an incremental grader called custom_problem_grader_fluid. With this problem grader, you must specify the number of correct answers [2,4,6] and their corresponding scores [0.3,0.6,1] and update the grader message accordingly. The last entry in the array for grader_numright must be the total number of questions asked, and the last entry in the array for grader_scores must be 1 (otherwise nobody can earn full credit!).

If you want a grader that awards full credit when all questions are correct and no credit otherwise, uncomment the standard problem grader.

@correct = @{$ml->ra_correct_ans()};
$answerstring = join(", ", @correct);
The correct answers are $answerstring

COMMENT('MathObject version.');


Solution: It is also possible to provide explanations for these answers. For details, see MatchingProblems from the Problem Techniques documentation.

Templates by Subject Area

follow us