Adding moodle database to webwork

Adding moodle database to webwork

by Fuzzy Rogers -
Number of replies: 3
We've finally got a campus wide course management system running moodle and now I'm working on getting a brand new server to hook into it. The installation seems straightforward however one question:

Do I make the sql_moodle db in the same fashion as the sql_single db as in:
$ mysql -u root -p mysql
Password: ***
ON webwork.* TO webworkWrite@localhost IDENTIFIED BY 'password';
> exit

but substitute

I'm getting a mysql error when attempting to set up a course - looks like it doesn't have a moodle db

"error instantiating DB driver WeBWorK::DB::Driver::SQL for table password: DBI connect('moodle','webworkWrite',...) failed: Access enied for user 'webworkWrite'@'localhost' to database 'moodle' at /o....."

We're running centos5, ww 2.4.7, apache2
In reply to Fuzzy Rogers

Re: Adding moodle database to webwork

by Michael Gage -

I don't recommend using the sql_moodle db approach to integrating moodle and webwork. It's the first approach we implemented where moodle and webwork communicate by accessing each others database because it was easy to program, but it's very fragile and broke as soon as either moodle or webwork was upgraded in any serious way. The next versions of the database.conf file won't even include the sql_moodle schema.

The current bridges (at the assignment level and at the question level) use webservices for communication between WW and moodle and are described and available at:

The question level integration uses the moodle bridge model and is still in early beta stage. The assignment level works pretty well and I use it regularly: see for example:

Setting up the assignment level connection involves adding the moodle module to moodle and possibly changing a couple of
hard coded addresses on your standard moodle site (in lib/WebworkSOAP/ and possibly in lib/

There is some discussion of using moodle/webwork here:

and here

there is a video conference on this subject also, but we are
having technical issues with the streaming video right at the moment -- we hope to have this fixed fairly soon:

I hope this information helps.

-- Mike
In reply to Michael Gage

Re: Adding moodle database to webwork

by Fuzzy Rogers -
Just to be clear, I create courses with sql_single db?

I've followed the instructions for Moodle Assignment, and now just need to create a democourse for our campus-wide moodle folks for testing purposes.

In reply to Fuzzy Rogers

Re: Adding moodle database to webwork

by Michael Gage -
That's correct. With this scheme the webwork course has no idea that it is connected to a moodle course. You can connect a moodle course to any existing webwork course.

As an instructor you should first enter yourself in the webwork course, giving yourself professor privileges, before connecting to that course from moodle. Use the same user name as you use for the moodle course.

Students will always log into the webwork course from moodle. When they click on a webwork assignment, then if they are not in the webwork course a user with the moodle login name will be created. The new user is given a random, hidden password -- which is never used. WeBWorK authenticates the user because it has been given a session key by the moodle installation (which it trusts). (If a user with that name already exists then no user record is created. This is why you want to establish yourself in the webwork course first as a professor -- so that you will know your webwork password.)

This means that students cannot login to the webwork site directly since they won't know their password. If their session expires they have to go back to moodle and re-enter from there with a fresh session key. For the most part this is a feature not a bug.

As an instructor you will create webwork homework assignment templates as usual and then link to them from the moodle side using the "WeBWorK assignment" activity.
If no webwork assignment has been created specifically for this user when the click on the moodle "WeBWorK assignment" button than a version of that homework assignment is automatically created and assigned to that user.

Homework grades are automatically transferred back to the moodle gradebook whenever the cron job is run or when the moodle link to the webwork assignment is edited and saved.

Essentially everything works with a pull or push from moodle -- webwork simply responds -- and much of the creation is done "just in time".

Hope this helps.

-- Mike