WeBWorK Problems

Scrambling the problem order with unionInclude.pl

Scrambling the problem order with unionInclude.pl

by Robin Cruz -
Number of replies: 6
I am using unionInclude.pl to scramble the order of problems in a problem set. There are 3 files with problem names in this set. The first grouping works fine. On the second group I get a warning (and a pink screen) after the 3rd problem and all of the problems presented use the first file in the list. On the third set, I get the same warning message and all of the problems are using the first file in the list. I checked several other user's problem sets and the same pattern holds. Here is the warning message:

Warning messages

  • Use of uninitialized value in array element at line 54 of [TMPL]/macros/unionInclude.pl
-------------------------------------------------------------------------------------------------------------
Here is the def file:

######################################################
###This def file scrambles the order of the problems
###via a utility: unionInclude.pl
######################################################
setNumber=Algebra_03_01_SystemOfLinearEq
openDate = 01/01/03, 0600
dueDate = 12/15/07 at 5:00pm
answerDate = 02/15/15 at 5:00pm
paperHeaderFile = paperHeader.pg
screenHeaderFile = Problems/setAlgebra_03_01_SystemOfLinearEq/screenHeader.pg
problemList =
Problems/setAlgebra_03_01_SystemOfLinearEq/aRandomizer_Problems_01_to_03.pg, 1
Problems/setAlgebra_03_01_SystemOfLinearEq/aRandomizer_Problems_01_to_03.pg, 1
Problems/setAlgebra_03_01_SystemOfLinearEq/aRandomizer_Problems_01_to_03.pg, 1
Problems/setAlgebra_03_01_SystemOfLinearEq/IntAlg_04_LinearSystem.pg, 2
Problems/setAlgebra_03_01_SystemOfLinearEq/IntAlg_05_LinearSystem.pg, 2
Problems/setAlgebra_03_01_SystemOfLinearEq/aRandomizer_Problems_06_to_13.pg, 1
Problems/setAlgebra_03_01_SystemOfLinearEq/aRandomizer_Problems_06_to_13.pg, 1
Problems/setAlgebra_03_01_SystemOfLinearEq/aRandomizer_Problems_06_to_13.pg, 1
Problems/setAlgebra_03_01_SystemOfLinearEq/aRandomizer_Problems_06_to_13.pg, 1
Problems/setAlgebra_03_01_SystemOfLinearEq/aRandomizer_Problems_06_to_13.pg, 1
Problems/setAlgebra_03_01_SystemOfLinearEq/aRandomizer_Problems_06_to_13.pg, 1
Problems/setAlgebra_03_01_SystemOfLinearEq/aRandomizer_Problems_06_to_13.pg, 1
Problems/setAlgebra_03_01_SystemOfLinearEq/aRandomizer_Problems_06_to_13.pg, 1
Problems/setAlgebra_03_01_SystemOfLinearEq/aRandomizer_Problems_14_to_17.pg, 1
Problems/setAlgebra_03_01_SystemOfLinearEq/aRandomizer_Problems_14_to_17.pg, 1
Problems/setAlgebra_03_01_SystemOfLinearEq/aRandomizer_Problems_14_to_17.pg, 1
Problems/setAlgebra_03_01_SystemOfLinearEq/aRandomizer_Problems_14_to_17.pg, 1
Problems/setAlgebra_03_01_SystemOfLinearEq/IntAlg_18_LinearSystem.pg, 3
Problems/setAlgebra_03_01_SystemOfLinearEq/IntAlg_19_SolveLinearEquation_Review.pg, 1
Problems/setAlgebra_03_01_SystemOfLinearEq/IntAlg_20_IntroFunctions_Review.pg, 1
Problems/setAlgebra_03_01_SystemOfLinearEq/IntAlg_21_Exponents_Review.pg, 1
------------------------------End def file---------------------------------------------------------------

Here is the second "selection" file, aRandomizer_Problems_06_to_13.pg: (The others are the similar.):

##DESCRIPTION
## Creates a random order for the first three problems
## in this folder.
##ENDDESCRIPTION

DOCUMENT(); # This should be the first executable line in the problem.

loadMacros(
"unionInclude.pl"
);

includeRandomProblem(
"IntAlg_06_LinearSystem.pg",
"IntAlg_07_LinearSystem.pg",
"IntAlg_08_LinearSystem.pg",
"IntAlg_09_LinearSystem.pg",
"IntAlg_10_LinearSystem.pg",
"IntAlg_11_LinearSystem.pg",
"IntAlg_12_LinearSystem.pg",
"IntAlg_13_LinearSystem.pg"
);
ENDDOCUMENT();
------------------------End selection file--------------------------------------------------------------

I also made a problem set using a straightforward def file and got no errors; so,
I think the problem files are OK.
--rac
In reply to Robin Cruz

Re: Scrambling the problem order with unionInclude.pl

by Davide Cervone -
I haven't had a chance to look into this yet, but make sure you have the most current version of unionInclude.pl. There was an update last month; perhaps that will fix it for you?

Davide
In reply to Davide Cervone

Re: Scrambling the problem order with unionInclude.pl

by Robin Cruz -

I updated the the union macro files today, just to make sure I had the latest version, but I still cannot get it to work. 

--rac

In reply to Robin Cruz

Re: Scrambling the problem order with unionInclude.pl

by Davide Cervone -
OK, I see what the difficulty is. The includeRandomProblem() macro was designed to be used for the ENTIRE homework set, not just a part of it, and so it assumes that the first problem it is used for is problem 1, and so on. That turns out to be false in your case, and so the macro ends up trying to use the current problem number to pick the right file out of the list you provided, but it's off by however many problems appeared in the set before the random problems. That means it will "fall off" the end of the array of files at some point, and that generated the error you see.

I have modified unionInclude.pl to compensate, but the solution requires you to tell includeRandomProblem() what the first problem number is that it is being used for (I could not think of a reliable way for it to figure that out on its own). To do so, add a line before the includeRandomProblem() call setting $initialProblemNumber to the number (in the problem set) of the first problem handled by that is handled by that file.

For example, aRandomizer_Problems_06_to_13.pg is first used as problem 6, so you should add

    $initialProblemNumber = 6;
to aRandomizer_Problems_06_to_13.pg before the includeRandomProblem() call. If the value of $initialProblemNUmber is not set, it will default to 1, so you don't need to modify aRandomizer_Problems_01_to_03.pg, but will need to fix the others. Note that includeRandomProblem only can handle contiguous ranges of problem numbers, but that is how yours are arranged, so it should not be a problem for you.

This does mean that the randomizer files are now homework-set specific, but it should not be hard to make a local copy and edit the number once the homework set is determined. Not an optimal solution, surely, but one that works.

You will need to update unionInclude.pl again to get this feature to work.

Davide

In reply to Davide Cervone

Re: Scrambling the problem order with unionInclude.pl

by Robin Cruz -

OK, I finally got around to working with this again.  I added the line to initialize the first problem number for the randomizer files and I no longer get an error/warning message.  All of the problems seem to be randomized.

A question:  Are all of the problems listed in a randomizer file supposed to be used?  I have 3 sections of "scrambled" problems in the set and the first two use a problem template twice and leave out a problem listed in the randomizer file.  The third set uses all of the problems in the list and scrambles them as desired.  I noticed that in the first two cases, it's the second problem in the list that is missing.

Thanks for your help on this -- rac

In reply to Robin Cruz

Re: Scrambling the problem order with unionInclude.pl

by Davide Cervone -
I have modified unionInclude.pl so that I think it will fix this problem. Try updating it and see if the results are more what you expected.

Davide