Forum archive 2000-2006

Monica VanDieren - shutting off the random generator

Monica VanDieren - shutting off the random generator

by Arnold Pizer -
Number of replies: 0
inactiveTopicshutting off the random generator topic started 9/7/2006; 11:53:24 AM
last post 9/7/2006; 3:33:42 PM
userMonica VanDieren - shutting off the random generator  blueArrow
9/7/2006; 11:53:24 AM (reads: 253, responses: 2)
Hello, Is there any easy fix (aside from going in and editing each individual problem) to create a problem set from the library and assure that every student receives the exact same problem?

Thanks, Monica

<| Post or View Comments |>


userJohn Jones - Re: shutting off the random generator  blueArrow
9/7/2006; 1:15:24 PM (reads: 333, responses: 0)
If you wanted this to happen on every problem used in your webwork installation, then you could modify webwork to always use the same seed when assigning problem sets.

If you only wanted to do it sometimes, then I think the best approach would be to write a perl script which will modify all of the problem seeds for all students on a particular assignment. I don't think anyone has written such a script.

John

<| Post or View Comments |>


userDavide P. Cervone - Re: shutting off the random generator  blueArrow
9/7/2006; 3:33:42 PM (reads: 324, responses: 0)
There is an alternative to John's suggestion. It is a real hack, but it would work without modification to the system, and without having to write scripts that need to be executed at the command line.

The idea is that you want to be able to run a small bit of code at the beginning of each problem, and that code would set the random seed to a common value across all the students in the class. The trick is to get that code executed without having to edit all the problems.

The solution (which I admit to be a horrible hack) is to realize that you already have code that is run at the beginning of each problem, namely the macro files that are loaded via loadMacros(). We will hook into one of these as a sneaky means of getting our own code to run in addition to its usual contents. We can do that by making a copy of th emacro file in our course's templates/macros directory, and modify that.

Almost all problems include PG.pl, PGbasicmacros.pl and PGanswermacros.pl, but these are actually preloaded by WeBWorK, and are not actually read for each problem, so we can't use those as our vehicle for our Trogan horse. Luckily, however, most problems also include PGauxiliaryFunctions.pl and PGchoicemacros.pl. Either of these would do.

Here's the process:

 

  1. Copy pg/macros/PGauxiliaryFunctions.pl to your course templates/macros directory.

     

  2. Rename the copy as PGauxiliaryFunctions_old.pl

     

  3. Edit the PGauxiliaryFunction_old.pl file and change the line
        sub _PGauxiliaryFunctions_init {
    to
        sub _PGauxiliaryFunctions_old_init {
    (this is not strictly necessary, but is safest that way).

     

  4. Create a new file called PGauxiliaryFunctions.pl in your templates/macros directory and include the lines
        loadMacros("PGauxiliaryFunctions_old.pl");


    SRAND($probNum) if $setNumber ne 'Undefined_Set';


    1;

This will case the random number generator to be seeded with the same value for all students (the seed value will be the problem number, so that different problems will be seeded with different values, at least.) That means all students will get the same version of the problem, regardless of the seed assigned originally by WeBWorK.

Note, however, that this will be the case for ALL problem sets (in this one course). If you want this to be true for only ONE problem set, you could use

    SRAND($probNum) if $setNumber eq 'set-name';
where set-name is the name of the set that you want to be the same for every student. You could include additional lines for additional sets if you needed it for more than one.

As I said, it's a terrible hack, but it should work.

Davide

PS, Mike, here's another example of where having a blank macro file loaded by all programs would come in helpfull. If all problems included PGcourse.pl, which is by default a blank perl file, then this file could be used to customize the environment on a course-by-course or set-by-set basis like this. All Union College problems include this, but most others don't.

<| Post or View Comments |>