WeBWorK Main Forum

Limiting responses with a .def file in 2.4.1

Limiting responses with a .def file in 2.4.1

by Robin Cruz -
Number of replies: 4

I just upgraded to 2.4.1 and today I created a homework set with a .def file I've been using for a number of years.  However, after importing the problem set from this .def file, the problems are showing up with unlimited attempts.  I checked on the "Set definition file format" page and I think the format is the same as for previous versions of WeBWorK.  Here is a line from my .def file which, I think, should limit the number of attempts to 3:

setStatistics_Ch01PicturingDistributionsWithGraphs/dm1_1.pg , 2 ,3

--rac

In reply to Robin Cruz

Re: Limiting responses with a .def file in 2.4.1

by Gavin LaRose -
Hi Robin,

I think this is a bug in the distribution. I ran into a similar problem when trying to import sets. If there are any developers out there with time to work on it, I think it's in the new CSV handling routine at about line 1741 in ProblemSetList.pm. But I might be wrong.

In any case, my workaround right now is to change the database records directly: in mysql,
     mysql> update `coursename_problem` set max_attempts=3 where set_id='setname'; 

That's not a good long-term solution, however, and requires that one get into the database directly, which isn't generally advisable.

Gavin
In reply to Gavin LaRose

Re: Limiting responses with a .def file in 2.4.1

by Gavin LaRose -
Hi Robin,

I've finally had a chance to look at this. I've patched and tested it on my development box and think I've fixed the problem. I also copied the patch to our production server, so it will be tested with some greater energy in the next days to weeks.

I've also uploaded the patch to the HEAD branch of the CVS, so it should get wrapped into the next update to WeBWorK. In the mean time, if you want to get the patch you can (a) either grab (or have your sysadmin grab) the patched version of ProblemSetList.pm from the CVS, or (b) manually edit in the patch on your system (or have your sysadmin do that).

For (a), the patched version of the file is version 1.106 of webwork2/lib/WeBWorK/ContentGenerator/Instructor/ProblemSetList.pm, in the HEAD branch of the tree.

For (b), the patch follows around line 1723 of the file, depending on your current version. The existing code is:

my @line = ();
my $curr = '';
for (my $i = 0; $i < length $line; $i++) {
my $c = substr($line,$i,1);
if ($c eq '\\') {
$curr .= substr($line,++$i,1);
} elsif ($c eq ',') {
push @line, $curr;
$curr = '';
} else {
$curr .= $c;
}
}
($name, $value, $attemptLimit, $continueFlag) = @line;

The problem is that the last value that's read isn't being added to the list @line. So, at the end of the loop, I've added it back on:

...
} else {
$curr .= $c;
}
}
## anything left?
push(@line, $curr) if ( $curr );

($name, $value, $attemptLimit, $continueFlag) = @line;

And that appears to fix the problem.

I hope that helps,
Gavin
In reply to Gavin LaRose

Re: Limiting responses with a .def file in 2.4.1

by Robin Cruz -

OK,  I edited the file as you suggested and the point values for the problems are now showing up OK from the def file.  The number of attempts is still not being limited by the def file.

Thanks for looking into this for me, Gavin.

--rac

In reply to Robin Cruz

Re: Limiting responses with a .def file in 2.4.1

by Gavin LaRose -
An update for anyone who is following this thread. After doing some debugging on the side, it appears that the patch is working with the 2.4.1 codebase. We're not sure why it wasn't working before; the best guess is probably something to do with odd caching by the mod_perl side of the apache server.

Gavin