Forum archive 2000-2006

Michael Gage - qa

Michael Gage - qa

by Arnold Pizer -
Number of replies: 0
inactiveTopicqa topic started 8/28/2001; 12:10:13 AM
last post 8/28/2001; 12:10:13 AM
userMichael Gage - qa  blueArrow
8/28/2001; 12:10:13 AM (reads: 2018, responses: 0)

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 |>