qastands 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
qasubroutine is seldom needed, but is kept for backword compatibility.
qa(~~@questions, ~~@answers, $question1, $answer1, $question2, $answer2...)
~~@answersare references to arrays which will contain the questions and answers respectively. The remaining inputs in the list are questions and answers alternating.
Places the questions in the @question array and the answers in the @answer array
@questions=(); #initialize the question and answer arrays.
"What color is the sky?"
"What is the square root of 4"
* Make sure that the arrays @questions and @answers have been initialized.
* In PG problems
~~@questionsindicates a reference to an array.
In macro packages (and pure perl) use
* 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]