qa
Description
qa stands for "question and answer". This subroutine
splits an array of alternating questions and answers into two arrays.
It is frequently easier to enter the questions and answers in pairs
rather than to enter them separately in different arrays. The latter
procedure makes it easier to mismatch the question and its answer when
modifying a problem. This simple qa subroutine is seldom needed, but is kept for backword compatibility.
Syntax
qa(~~@questions, ~~@answers, $question1, $answer1, $question2, $answer2...)
Params
~~@questions and ~~@answers are references to
arrays which will contain the questions and answers respectively. The
remaining inputs in the list are questions and answers alternating.
Action
Places the questions in the @question array and the answers in the @answer array
Returns
Nothing
Examples
@questions=(); #initialize the question and answer arrays.
@answers=();
qa(~~@questions, ~~@answers,
"What color is the sky?"
"Blue"
"What is the square root of 4"
2
);
Notes
* Make sure that the arrays @questions and @answers have been initialized.
* In PG problems ~~@questions indicates a reference to an array.
In macro packages (and pure perl) use \\@questions instead.
* Perl allows the use of => to separate questions and answers:
"This is a question1" => "and aswer 1", "question 2" => " and answer 2"
which might be clearer. (In this context => is just an alias for the comma.)
* This subroutine is defined in PGchoicemacros.pl
See Also
PGchoicemacros.pl.
This simple qa subroutine is seldom needed, but provides backword compatibility with earlier problems. See Match.pm, Select.pm, and List.pm
whose objects all have a qa method for entering questions and answers.
The use of these objects can simplify the creation of matching
questions or multiple choice questions.
<| Post or View Comments |> |