NAME

PeriodicRerandomization.pl - forced re-randomization of the problem every p submissions.

SYNOPSIS

Let p be a positive integer. This macro provides the ability to force a re-randomization of the question every p attempts. For example, this macro can be used to create a practice exercise that provides a new version of the question every 4 attempts and displays a solution every fourth attempt.

DESCRIPTION

Usage:

DOCUMENT();
loadMacros(
"PGstandard.pl",
"MathObjects.pl",
"PeriodicRerandomization.pl",
);
TEXT(beginproblem());

PeriodicRerandomization("4");

$a = random(2,9,1);
do { $b = random(2,9,1); } until ($b != $a);

BEGIN_TEXT
An equation for a line in the xy-plane with slope \( $a \)
and y-intercept \( $b \) is
$BR
$BR
\( y = \) \{ ans_rule(20) \} 
$BR
$BR
END_TEXT

PeriodicStatus(
"Generate a new version of this problem",
"You have ${attempts_modp_remaining} attempt(s) remaining 
before you will receive a new version of this problem."
); 

if ($attempts_modp == 0) {
BEGIN_TEXT
$BR
$BR
${BBOLD}Solution:${EBOLD}  Multiply \( x \) by \( $a \)
and add \( $b \).
$BR
$BR
END_TEXT
}

ANS( Compute("$a x + $b")->cmp() );

COMMENT('Periodically re-randomizes.');

ENDDOCUMENT();

The argument of PeriodicRerandomization() is a number p (the period) that is the number of attempts allowed before the problem is re-randomized. PeriodicRerandomization() must be called before any random parameters are defined.

The two arguments of PeriodicStatus() are (1) the text that will appear on the button for a new version of the problem when the number of attempts is 0 mod p, and (2) a message that will appear when the number of attempts is not 0 mod N. If PeriodicStatus() has no arguments, then it will use defaults.

There are several globally defined variables. $rerand_period is the period p. $attempts_modp is the total number of attempts modulo the period except for when the problem is first accessed, in which case its value is -p (the rationale behind this is that the case when the problem is first accessed often needs to be handled separately.) $attempts_modp_remaining is the number of attempts remaining before re-randomization. $problem_version_number is the floor function applied to the total number of attempts divided by the period p. $newProblemSeed is the problem seed for the current version of the problem, whereas $problemSeed is the original problem seed (which does not change with different versions of the problem). You can access the total number of attempts using $envir{numOfAttempts}, which is a sequence 0,0,1,2,3,... (not 0,1,2,3,...).

AUTHOR

Paul Pearson, Fort Lewis College, Department of Mathematics