Matching1

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Matching Question

Click to enlarge

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

• Download file: File:Matching1.txt (change the file extension from txt to pg when you save it)
• File location in NPL: `FortLewis/Authoring/Templates/Misc/Matching1.pg`

PG problem file Explanation

Problem tagging:

```DOCUMENT();

"PGstandard.pl",
"MathObjects.pl",
"PGchoicemacros.pl",
"unionTables.pl",
);

TEXT(beginproblem());
```

Initialization:

```#
#  Create a matching list and use popups
#
\$ml = new_match_list();
\$ml->rf_print_q(~~&pop_up_list_print_q);
\$ml->ra_pop_up_list([
"No answer" => "?",
"A" => "A", "B" => "B", "C" => "C",
"D" => "D", "E" => "E", "F" => "F",
"G" => "G", "H" => "H", "I" => "I",
]);

#
#
\$ml->qa(
"Question a?", "Answer a",
"Question b?", "Answer b",
"Question c?", "Answer c",
"Question d?", "Answer d",
"Question e?", "Answer e",
"Question f?", "Answer f",
);
\$ml->choose(6);

#
#
\$ml->extra(
);
\$ml->choose_extra(2);

\$ml->makeLast("None of the above");
```

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

```Context()->texStrings;
BEGIN_TEXT
Match each question with its answer.
\{ ColumnMatchTable(\$ml) \}
END_TEXT
Context()->normalStrings;
```

Main Text:

```\$showPartialCorrectAnswers = 0;

#
#
\$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
#

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

```@correct = @{\$ml->ra_correct_ans()};
\$answerstring = join(", ", @correct);
Context()->texStrings;
BEGIN_SOLUTION
\${PAR}SOLUTION:\$PAR