WeBWorK Main Forum

bin/addcourse --templates fails

bin/addcourse --templates fails

by Gavin LaRose -
Number of replies: 5
Hi all,

It looks as if the addcourse script in the bin directory has an error retaining a seed course environment when an existing course's templates are being copied. The error is reproducible by running addcourse with the --templates option, e.g.,
export WEBWORK_ROOT=/.../webwork2
sudo -u www-data /.../webwork2/bin/addcourse --templates-from=testCourse testAddCourse
The error message(s) is (are)
Use of uninitialized value in concatenation (.) or string at /var/www/webwork/webwork2/lib/WeBWorK/CourseEnvironment.pm line 125.
Use of uninitialized value in concatenation (.) or string at /var/www/webwork/webwork2/lib/WeBWorK/CourseEnvironment.pm line 152.
failed to read file /conf/global.conf: No such file or directory at /var/www/webwork/webwork2/lib/WeBWorK/Utils.pm line 157.

It appears this stems from about line 258 in lib/WeBWorK/Utils/CourseManagement.pm, in the addCourse routine. The lines are
##### step 5: copy templates #####

if (exists $options{templatesFrom}) {
my $sourceCourse = $options{templatesFrom};
my $sourceCE = new WeBWorK::CourseEnvironment({
%WeBWorK::SeedCE,
courseName => $sourceCourse,
});

and I believe the problem is that %WeBWorK::SeedCE isn't defined. That is, ref(%WeBWorK::SeedCE) is empty. Thus the source course environment is coming up with no root directory and therefore fails.

Run on-line, through the GUI, this works fine, so it would appear to be something to do with the hash not being defined in the addcourse script or its environment.

Is there an obvious fix to this?

Thanks,
Gavin
In reply to Gavin LaRose

Re: bin/addcourse --templates fails

by Michael Gage -
I'm a bit puzzled as to why the command line script has worked at all for the last two or three years. %WeBWorK::SeedCE is only initialized by the webserver whenever a server page is dispatched. Perhaps once it is initialized from serving a web page one can later access that preserved variable from the command line (especially if you are using the webserver's login when you run the command).

In any case I've uploaded a modified version of Utils/CourseManagement to HEAD which gets a seed course environment from the current course environment and then builds the course environment for the source Course from that. Perhaps that will be more reliable.

Use

cvs update -A Utils/CourseManagement.pm

(in the lib/WeBWorK directory) to update.

Let me know how this works.

-- Mike

In reply to Michael Gage

Re: bin/addcourse --templates fails

by John Spitler -
Mike - our ww server is running ubuntu 8.04 LTS and WW 2.4-patches. After updating CourseManagement.pm as above, the apache2 webserver fails to restart with the following error:

sudo apache2ctl restart
[sudo] password for spitler:
Syntax error on line 33 of /etc/apache2/conf.d/webwork.conf:
"listCourses" is not exported by the WeBWorK::Utils::CourseManagement module\nCan't continue after import errors at /opt/webwork/webwork2/lib/WeBWorK/Utils/DBUpgrade.pm line 28\nBEGIN failed--compilation aborted at /opt/webwork/webwork2/lib/WeBWorK/Utils/DBUpgrade.pm line 28.\nCompilation failed in require at /opt/webwork/webwork2/lib/WeBWorK/Utils/CourseManagement.pm line 36.\nBEGIN failed--compilation aborted at /opt/webwork/webwork2/lib/WeBWorK/Utils/CourseManagement.pm line 36.\nCompilation failed in require at /opt/webwork/webwork2/lib/WeBWorK/ContentGenerator/Home.pm line 31.\nBEGIN failed--compilation aborted at /opt/webwork/webwork2/lib/WeBWorK/ContentGenerator/Home.pm line 31.\nCompilation failed in require at (eval 827) line 3.\nBEGIN failed--compilation aborted at /opt/webwork/webwork2/lib/WeBWorK.pm line 85.\nCompilation failed in require at /opt/webwork/webwork2/lib/Apache/WeBWorK.pm line 35.\nBEGIN failed--compilation aborted at /opt/webwork/webwork2/lib/Apache/WeBWorK.pm line 35.\n\t(in cleanup) "listCourses" is not exported by the WeBWorK::Utils::CourseManagement module\nCan't continue after import errors at /opt/webwork/webwork2/lib/WeBWorK/Utils/DBUpgrade.pm line 28\nBEGIN failed--compilation aborted at /opt/webwork/webwork2/lib/WeBWorK/Utils/DBUpgrade.pm line 28.\nCompilation failed in require at /opt/webwork/webwork2/lib/WeBWorK/Utils/CourseManagement.pm line 36.\nBEGIN failed--compilation aborted at /opt/webwork/webwork2/lib/WeBWorK/Utils/CourseManagement.pm line 36.\nCompilation failed in require at /opt/webwork/webwork2/lib/WeBWorK/ContentGenerator/Home.pm line 31.\nBEGIN failed--compilation aborted at /opt/webwork/webwork2/lib/WeBWorK/ContentGenerator/Home.pm line 31.\nCompilation failed in require at (eval 827) line 3.\nBEGIN failed--compilation aborted at /opt/webwork/webwork2/lib/WeBWorK.pm line 85.\nCompilation failed in require at /opt/webwork/webwork2/lib/Apache/WeBWorK.pm line 35.\nBEGIN failed--compilation aborted at /opt/webwork/webwork2/lib/Apache/WeBWorK.pm line 35.\nCompilation failed in require at /etc/apache2/conf.d/webwork.conf line 50.\n


any ideas?
In reply to John Spitler

Re: bin/addcourse --templates fails

by Michael Gage -
My suggestion is to make sure that DBupgrade.pm is up-to-date to the

rel-2-patches release. The version of DBupgrade.pm included in the original tar ball had some difficulties.

I'm not sure this will help, but it might. Report back how it works.
In reply to Michael Gage

Re: bin/addcourse --templates fails

by John Spitler -
(1) cvs status showed DBUpgrade.pm was up-to-date with Working revision: 1.4.2.3, Repository revision: 1.4.2.3, and sticky tag rel-2-4-patches

(2) ran sudo cvs update -A Utils/DBUpgrade.pm from /opt/webwork/webwork2/lib

(3) now cvs status shows DBUpgrade.pm was up-to-date with Working revision: 1.5, Repository revision: 1.5, and no sticky tag

(4) Apache2 now functions properly

(5) addcourse command-line command functions properly with templates flag

Summary:

Fix for addcourse command-line command for WW2.4 under Ubuntu 8.04 LTS from live DVD download, run in /opt/webwork/webwork2/lib directory:

sudo cvs update -A Utils/CourseManagement.pm

sudo cvs update -A Utils/DBUpgrade.pm


In reply to John Spitler

Re: bin/addcourse --templates fails

by Arnold Pizer -
Thanks John,

I just want to clarify the situation so that others do not get confused. The bottom line is that people should now use the rel-2-4-patches version.

There are 3 interrelated files:
.../webwork2/bin/wwdb_upgrade
.../webwork2/lib/WeBWorK/Utils/DBUpgrade.pm
.../webwork2/lib/WeBWorK/Utils/CourseManagement.pm

Mike edited CourseManagement.pm and put the changes into head. You downloaded that version and had problems because you had a patched version of DBUpgrade.pm. As long as you don't run wwdb_upgrade you will be fine with the head versions. I have now put Mike's changes into the rel-2-4-patches version of CourseManagement.pm so you will also be fine with the patches version of the files.

Just for the record the current problem with the head versions is as follows. Sam was in the process of moving some of the code out of wwdb_upgrade so that it could be used by other processes. However this was not completed (or at least not debugged) and the iterative nature of wwdb_upgrade was broken. wwdb_upgrade is supposed to iterate through all updates (currently 23) to bring the database up to date. The head version of wwdb_upgrade seems to perform one update at a time so it has to be run 23 times on a new install of WeBWorK (I assume it works after being run 23 times but I didn't have the patience to test that). So we backed off the changes to wwdb_upgrade and this necessitated small changes to DBUpgrade.pm
and CourseManagement.pm. All the changes were put in the rel-2-4-patches version of the files.

Arnie