Forum archive 2000-2006

Andy Wildenberg - choosing from multiple choice questions

Andy Wildenberg - choosing from multiple choice questions

by Arnold Pizer -
Number of replies: 0
inactiveTopicchoosing from multiple choice questions topic started 1/23/2001; 5:02:50 PM
last post 1/23/2001; 10:04:48 PM
userAndy Wildenberg - choosing from multiple choice questions  blueArrow
1/23/2001; 5:02:50 PM (reads: 1726, responses: 7)
I have a program that generates lots of equivalent multiple choice questions. What is the best way to have WebWork choose one out of the list of questions. I think I could generate an array of multiple choice questions, and then generate a random index into it. At least I think I could do that in theory: my Perl still leaves a lot to be desired.

Any ideas?

Andy

<| Post or View Comments |>


userMichael Gage - Re: choosing from multiple choice questions  blueArrow
1/23/2001; 5:27:01 PM (reads: 1966, responses: 0)
Hi Andy,

You can certainly do this, and we already have several macros that do this kind of thing. I don't know if they are exactly what you have in mind.

http://webhost.math.rochester.edu/webworkdocs/docs/pglanguage/pod/PGchoicemacros describes the "front end" macros for multiple choice questions, matching questions, etc. and some examples of their use are at:

http://webhost.math.rochester.edu/webworkdocs/docs/pglanguage/tutorial/ (examples 3 through 7 )

Problem 3 of the MAAtutorial set at http://webwork.math.rochester.edu/maa100 (use practice1 as login, and password) is also similar.

There is also @slice = NchooseK(10,3) which gives a random ordered list of 3 integers between 0 and 9

@permutation=NchooseK(3,3) gives a permutation of the numbers 0,1,2

inverse(@permutation) gives the inverse of that permutation.

More detailed descriptions of the existing macros are in: http://webhost.math.rochester.edu/webworkdocs/docs/pglanguage/pod/List

http://webhost.math.rochester.edu/webworkdocs/docs/pglanguage/pod/Multiple

http://webhost.math.rochester.edu/webworkdocs/docs/pglanguage/pod/Select

http://webhost.math.rochester.edu/webworkdocs/docs/pglanguage/pod/Match

I hope this helps. Feel free to write back with a more detailed description of what is needed, if these references don't seem appropriate.

Take care,

Mike

<| Post or View Comments |>


userAndy Wildenberg - Re: choosing from multiple choice questions  blueArrow
1/23/2001; 5:49:14 PM (reads: 1967, responses: 0)
Consider the following file. It currently has two separate multiple choice questions that test exactly the same thing. How can I write code to randomly choose only one of them instead of printing them both out. (my apologies for typos -- I don't have a WebWork machine currently running, so this is a "paper only" exercise)

Andy

**

DOCUMENT();

loadMacros('PG.pl', 'PGbasicmacros.pl', 'PGchoicemacros.pl', 'PGanswermacros.pl', );

TEXT(beginproblem());

$showPartialCorrectAnswers = 0;

$mca = new_multiple_choice;

$mca->qa('what is the negation of the following: If I form a study group then I raise my grades.', 'I form a study group and I lower my grades.' );

$mca->extra( 'I form a study group and I raise my grades.', 'If I work alone then I lower my grades.', 'I work alone or I raise my grades.' );

BEGIN_TEXT $PAR { $mca->print_q() } $PAR { $mcb->print_a() } END_TEXT ANS(radio_cmp($mca->correct_ans));

$mcb = new_multiple_choice;

$mcb->qa('what is the negation of the following: If P is a square then P is a rectangle.', 'P is a square and P is not a rectangle.' );

$mcb->extra( 'P is a square and P is a rectangle.', 'P is a square or P is a rectangle.', 'P is a square.' );

BEGIN_TEXT $PAR { $mcb->print_q() } $PAR { $mcb->print_a() } END_TEXT ANS(radio_cmp($mcb->correct_ans));

ENDDOCUMENT();

<| Post or View Comments |>


userMichael Gage - Re: choosing from multiple choice questions  blueArrow
1/23/2001; 6:23:59 PM (reads: 1963, responses: 1)
Hi Andy, Try this: (I haven't checked this on webwork yet either, so it might not be exactly right, but the general idea should work.) There may also be cleverer ways to do this, but this is a start.

If you have a perl subroutine to generate these questions, you can store it in a file called "myMacros.pl" (or whatever name you like) which you place in the directory templates/macros. Add "myMacros.pl" to the list in loadMacros(). You will also need to uncomment the definition of $macroDirectory in webworkCourse.ph.

Hope this helps.

Take care,

Mike

 


DOCUMENT();
loadMacros('PG.pl',
'PGbasicmacros.pl',
'PGchoicemacros.pl',
'PGanswermacros.pl',
);
TEXT(beginproblem());
$showPartialCorrectAnswers = 0;
$ra_question_and_answer[0] =
['what is the negation of the following: If I form a study group then I raise my grades.',
'I form a study group and I lower my grades.'
];
$ra_extra_answers[0] =[
'I form a study group and I raise my grades.',
'If I work alone then I lower my grades.',
'I work alone or I raise my grades.'
];



$ra_question_and_answer[1] = ['what is the negation of the following: If P is a square then P is a rectangle.',
'P is a square and P is not a rectangle.'
];
$ra_extra_answers[1] =[
'P is a square and P is a rectangle.',
'P is a square or P is a rectangle.',
'P is a square.'
];
$mca = new_multiple_choice;
$i = random(0,1,1); # choose one of the two sets of questions
$mca->qa(@{ $ra_question_and_answer[$i] } ); # The @{ ...} takes the reference
$mca->extras(@{$ra_extra_answers[$i] } );
BEGIN_TEXT
$PAR
{ $mca->print_q() }
$PAR
{ $mcb->print_a() }
END_TEXT
ANS(radio_cmp($mca->correct_ans));
ENDDOCUMENT();

<| Post or View Comments |>


userRobert (Rochester ugrad) - Re: choosing from multiple choice questions  blueArrow
1/23/2001; 6:42:43 PM (reads: 2231, responses: 0)
I may be forgetting something important about perl objects that doesn't allow this but I'm pretty sure that you could make a two element array of the multiple choice questions and then use a random number to pick between them. So in pseudo-pg you would have

 

$mc[0] = new_multiple_choice;



# mc[0] stuff



$mc[1] = new_multiple_choice;



# mc[1] stuff



$i = RANDOM(0, 1, 1);



BEGIN_TEXT
$PAR
{ $mc[$i]->print_q() }
$PAR
( $mc[$i]->print_a() }
END_TEXT
ANS(radio_cmp($mc[$i]->correct_ans));

<| Post or View Comments |>


userMichael Gage - Re: choosing from multiple choice questions  blueArrow
1/23/2001; 6:50:56 PM (reads: 1931, responses: 0)
Yep. I'll bet that works too. "In perl there is more than one way to do things."

Take care,

Mike

<| Post or View Comments |>


userAndy Wildenberg - Re: choosing from multiple choice questions  blueArrow
1/23/2001; 9:56:13 PM (reads: 1938, responses: 0)
Sound like I should just consider porting the program that generated the questions to Perl...

That does raise a newbie question: this file is going to be executed once for every student, right? The original questions are more like 3000 lines total with 20 versions of 10 questions instead of 2 versions of the same question. So it would seem like this could seriously slow down the problem generation sequence, if nothing else from the lag in reading in the generated questions off of the disk.

Andy

<| Post or View Comments |>


userMichael Gage - Re: choosing from multiple choice questions  blueArrow
1/23/2001; 10:04:48 PM (reads: 1935, responses: 0)
Porting the program to perl might actually work pretty well, depending on how involved the program is. Perl should be pretty good at this type of text manipulation.

As to a slow down from reading a large file. I can't say for sure, but I don't think the slowdown would be outrageous, although it might be noticable (e.g. 2 sec instead of 1). We're already reading in several thousand lines of code to compile the scripts. Even things like drawing all those graphs on the fly doesn't affect the timing. The only thing that has ever been too slow is the creation of the .gif equations for latex2HTML -- that 's why we cache those and precreate those equation .gif files before giving the problem set to the students.

Your mileage may vary -- it may depend a lot on the speed of the machine, the number of students, other loads, etc. etc. etc.

Hope this helps.

Take care,

Mike

<| Post or View Comments |>