## WeBWorK Main Forum

### Hardcopy Error

by Blake Thornton -
Number of replies: 1
I am getting errors when generating a hardcopy. This seems to happen in two cases:

1. When the student has been assigned the set but it is before the open date. The student can still see "download a hardcopy" but when this is clicked there is an error.

2. When the student tries to generate a hardcopy when they don't select a set.

Both of these are understandable but it would certainly be better for the student to just be warned that they need to do something else.

Here is the error message for case number 2:

### Error messages

argument 2 must contain a set_id at /opt/webwork/webwork2/lib/WeBWorK/ContentGenerator/Hardcopy.pm line 207

### Call stack

The information below can help locate the source of the problem.

• in Carp::croak called at line 2025 of /opt/webwork/webwork2/lib/WeBWorK/DB.pm
• in WeBWorK::DB::checkArgs called at line 1231 of /opt/webwork/webwork2/lib/WeBWorK/DB.pm
• in WeBWorK::DB::getMergedSet called at line 207 of /opt/webwork/webwork2/lib/WeBWorK/ContentGenerator/Hardcopy.pm
• in WeBWorK::ContentGenerator::Hardcopy::pre_header_initialize called at line 176 of /opt/webwork/webwork2/lib/WeBWorK/ContentGenerator.pm
• in WeBWorK::ContentGenerator::go called at line 353 of /opt/webwork/webwork2/lib/WeBWorK.pm

### Re: Hardcopy Error

by Arnold Pizer -
Thanks for reporting this Blake. I think both are the same error since in case 1 the students can not select the set which is not open.

The bug is in Hardcopy.pm and is subtle since it happens for students but not professors (they select sets differently). Here's what is there now:

# when students don't select any sets the size of @setIDs is 1 with a null character in $setIDs[0]. # when professors don't select any sets the size of @setIDs is 0. # the following test "unless ((@setIDs) and ($setIDs[0] =~ /\S+/))" catches both cases and prevents
# warning messages in the case of a professor's empty array.

Previously the test was "unless (@setIDs)"

I don't think it is worthwhile to put this in patches. If you want to use it cd to
.../webwork/webwork2/lib/WeBWorK/ContentGenerator
and run
cvs update -A Hardcopy.pm

Arnie