Difference between revisions of "Moodle Integration"

From WeBWorK_wiki
Jump to navigation Jump to search
(New page: The Moodle integration project has a separate web presence: http://question.webwork.rochester.edu/ It also has its own separate version control system and bug tracker. This is undesirable.)
 
Line 1: Line 1:
The Moodle integration project has a separate web presence: http://question.webwork.rochester.edu/ It also has its own separate version control system and bug tracker. This is undesirable.
 
  +
{|class="messagebox"
  +
| The page below describes an old method of integration between WeBWorK and Moodle. For the newer approaches go to http://question.webwork.rochester.edu.
  +
|}
  +
  +
WeBWorK 2.3 and later contain support for authenticating against a Moodle database. We are also developing a <code>wwassignment</code> module for Moodle which defines a new assignment type that links to a WeBWorK problem set. This is ready for use now, although installation is a little rough and there are several limitations.
  +
  +
== Requirements ==
  +
  +
WeBWorK 2.3.x. or later.
  +
  +
Moodle 1.5.x, 1.6.x, or 1.7.x. We tested with version 2005060231 a.k.a. 1.5.3+, and later with some varieties of 1.7.
  +
  +
MySQL 4.1 or later.
  +
  +
The <code>PHP::Serialization</code> Perl module. Available from CPAN.
  +
  +
WeBWorK and Moodle must use the same MySQL server. The account that Moodle uses to log into its database must have <code>SELECT</code> access on the WeBWorK database and the account the WeBWorK uses to log into its database must have <code>SELECT</code> access on the Moodle database.
  +
  +
Moodle must also be able to read the WeBWorK <code>courses</code> directory. This can be a local directory, or it could be some kind of network mount, i.e. NFS. Moodle does not need to write to this directory.
  +
  +
Moodle and WeBWorK need have the same hostname. This is because the client's browser will only send the Moodle cookie to WeBWorK if the hostname matches. (The two applications can be set up on different ports though, so if you absolutely need them on different servers you could set up some kind of router-based port-forwarding. This is also useful if you need to run Moodle on Apache1 and WeBWorK on Apache2.)
  +
  +
(We plan to eliminate the same-server requirements in a future version.)
  +
  +
== Installation ==
  +
  +
First, make sure that Moodle is set up to store session data in the database. Log in to Moodle as an administrator and select the "Configuration" option. Scroll down to the "Operating System" section and set the "dbsession" option to "Yes".
  +
  +
Check out the wwmoodle module from the WeBWorKCVS repository:
  +
  +
<code>cvs -d :pserver:anoncvs@cvs.webwork.rochester.edu:/webwork/cvs/system co wwmoodle</code>
  +
  +
This will create a <code>wwmoodle</code> directory in the current directory. Move the <code>wwassignment</code> subdirectory to your Moodle <code>mod</code> directory.
  +
  +
<code>cd wwmoodle<br>
  +
mv wwassignment /path/to/moodle/mod<br>
  +
cd /path/to/moodle</code>
  +
  +
Create symlinks to the language files in the proper locations.
  +
  +
<code>cd /path/to/moodle/lang/en<br>
  +
ln -s ../../mod/wwassignment/lang.php wwassignment.php<br>
  +
cd help<br>
  +
ln -s ../../../mod/wwassignment/help wwassignment</code>
  +
  +
If you're using the <code>utf8</code> encoding, move the files into the <code>en_utf8</code> directory instead of the <code>en</code> directory. (Or do both.)
  +
  +
The advantage of symlinking is that a <code>cvs up</code> from the <code>wwassignment</code> directory will be able to update the language files. Some people have reported problems when symlinking. If this is your experience, just move the files instead:
  +
  +
<code>cd /path/to/moodle/lang/en<br>
  +
mv ../../mod/wwassignment/lang.php wwassignment.php<br>
  +
cd help<br>
  +
mv ../../../mod/wwassignment/help wwassignment</code>
  +
  +
Log in to Moodle as an administrator and select the "Admin..." option. At this point, Moodle will set up the <code>wwassignment</code> module.
  +
  +
Then, select the "Configuration" option and then the "Modules" option. Click the "Settings" link next to "WeBWorK Problem Set" to configure the module.
  +
  +
{| border="1"
  +
|-
  +
| '''Option''' || '''Description'''
  +
|-
  +
| wwassignment_webworkcourses || This is the path to the WeBWorK courses directory. It should be set to the same value as the <code>$webwork_courses_dir</code> variable in <code>global.conf</code>, except that in this case it needs to end with a slash.
  +
|-
  +
| wwassignment_webworkurl || The URL where WeBWorK is accessible. By default, this is <code>/webwork2</code>. If WeBWorK is on a different port, you'll need the full URL. This should be the same value as <code>$webwork_url</code> in <code>global.conf</code>. It does not need a trailing slash.
  +
|-
  +
| wwassignment_iframewidth || Width of frame in which WeBWorK problem sets are embedded.
  +
|-
  +
| wwassignment_iframeheight || Height of frame in which WeBWorK problem sets are embedded.
  +
  +
|}
  +
  +
There are a few settings that need to be made in <code>global.conf</code> as well:
  +
  +
{| border="1"
  +
|-
  +
| '''Option''' || '''Description'''
  +
|-
  +
| $moodle_dsn || The DSN for the moodle database. Default: "dbi:mysql:moodle". Corresponds to <code>dbtype</code>, <code>dbhost</code>, and <code>dbname</code> in Moodle's <code>config.php</code>.
  +
|-
  +
| $moodle_table_prefix || The prefix to prepend to Moodle table names. Default: "mdl". Corresponds to <code>prefix</code> in Moodle's <code>config.php</code>.
  +
|-
  +
| $moodle_username || The username to use when connecting to the Moodle database. Default: same as WeBWorK database username. Corresponds to <code>dbuser</code> in Moodle's <code>config.php</code>.
  +
|-
  +
| $moodle_password || The password to use when connecting to the Moodle database. Default: same as WeBWorK database password. Corresponds to <code>dbpass</code> in Moodle's <code>config.php</code>.
  +
  +
|}
  +
  +
== Usage ==
  +
  +
Once you've set this up, you should notice a new ''WeBWorK Problem Set'' activity in the list of activities you can add to your course. The form for creating WeBWorK problem sets includes two interesting links.
  +
  +
The first is ''Create the WeBWorK course''. This links you to the WeBWorK Course Administration page, with the name of the course pre-filled and the <code>sql_moodle</code> database layout preselected. This link shows up whether or not the course has already been created, so you may get an error is the course already exists.
  +
  +
The second is ''Administer the WeBWorK portion of this course''. This links you to the WeBWorK Instructor Tools page, where you can configure problem sets. You can also view, but not edit, the User List.
  +
  +
=== WeBWorK theme for Moodle ===
  +
  +
The <code>moodle</code> WeBWorK theme is a modified version of the default <code>math</code> theme. It detects when WeBWorK is called from within a Moodle frame, and removes superfluous interface elements. It also expands the Moodle frame so that it doesn't have to scroll.
  +
  +
Set the theme by changing the value of <code>$defaultTheme</code> in <code>global.conf</code> (for all courses) or a specific course's <code>course.conf</code> (for just that course). This value can also be set for a particular course using the '''Course Configuration''' page.
  +
  +
=== Moodle authentication rules ===
  +
  +
Moodle administrators are allowed to log into any WeBWorK sql_moodle course. They are assigned permission level <code>10</code>.
  +
  +
Moodle teachers are allowed to log into only their corresponding WeBWorK sql_moodle course. They also get permission level <code>10</code>.
  +
  +
Moodle students are allowed to log into only their corresponding WeBWorK sql_moodle course. They get permission level =0=.
  +
  +
Moodle groups are mapped to WeBWorK recitations, unless the group begins with <code>SEC_</code>, in which case, it is mapped to a WeBWorK section (with the <code>SEC_</code> prefix is removed).
  +
  +
== sql_moodle admin course ==
  +
  +
The WeBWorK course administration system can be configured to authenticate against a Moodle course.
  +
  +
First, create a Moodle course with the short name <code>admin</code>. This course doesn't need to have any participants or any content.
  +
  +
If you haven't created your WeBWorK admin course yet, select the <code>sql_moodle</code> database layout when you do.
  +
  +
If you've already created your WeBWorK admin course, edit its <code>course.conf</code> file to change the <code>$dbLayoutName</code> to <code>sql_moodle</code>.
  +
  +
You will be able to log into the admin course using the credentials of any Moodle administrator. If you would like to grant access to non-administrators, make them teachers in the Moodle <code>admin</code> course.
  +
  +
== Limitations ==
  +
  +
=== Course naming ===
  +
  +
The name of the WeBWorK course that is associated with a given Moodle course is fixed. The system takes the short name of the Moodle course and removes any non-alphanumeric characters. This value is then stored. If you have two Moodle courses with identical short names (modulo non-alphanumeric characters), they will be associated with the same WeBWorK course. The behavior in this case is not defined.
  +
  +
We intend to make the name of the linked WeBWorK course configurable, and prevent two Moodle courses from being associated with the same WeBWorK course.
  +
  +
=== Set assignment ===
  +
  +
In Moodle, activities are always assigned to all participants in a course. However, you still have to assign WeBWorK homework sets to students using the WeBWorK instructor tools -- this is not done automatically.
  +
  +
== Credits ==
  +
  +
The original <code>wwmoodle</code> package was developed by Peter Snoblin at the University of Missouri. http://www2.truman.edu/~pas577/wwmoodle/
  +
  +
The WeBWorK parts were integrated into the official source by Main.SamHathaway. The Moodle parts (<code>wwmoodle</code> and <code>wwmoodleset</code>) were refactored into the <code>wwassignment</code> module by Main.MichaelGage.

Revision as of 19:28, 21 February 2008

The page below describes an old method of integration between WeBWorK and Moodle. For the newer approaches go to http://question.webwork.rochester.edu.

WeBWorK 2.3 and later contain support for authenticating against a Moodle database. We are also developing a wwassignment module for Moodle which defines a new assignment type that links to a WeBWorK problem set. This is ready for use now, although installation is a little rough and there are several limitations.

Requirements

WeBWorK 2.3.x. or later.

Moodle 1.5.x, 1.6.x, or 1.7.x. We tested with version 2005060231 a.k.a. 1.5.3+, and later with some varieties of 1.7.

MySQL 4.1 or later.

The PHP::Serialization Perl module. Available from CPAN.

WeBWorK and Moodle must use the same MySQL server. The account that Moodle uses to log into its database must have SELECT access on the WeBWorK database and the account the WeBWorK uses to log into its database must have SELECT access on the Moodle database.

Moodle must also be able to read the WeBWorK courses directory. This can be a local directory, or it could be some kind of network mount, i.e. NFS. Moodle does not need to write to this directory.

Moodle and WeBWorK need have the same hostname. This is because the client's browser will only send the Moodle cookie to WeBWorK if the hostname matches. (The two applications can be set up on different ports though, so if you absolutely need them on different servers you could set up some kind of router-based port-forwarding. This is also useful if you need to run Moodle on Apache1 and WeBWorK on Apache2.)

(We plan to eliminate the same-server requirements in a future version.)

Installation

First, make sure that Moodle is set up to store session data in the database. Log in to Moodle as an administrator and select the "Configuration" option. Scroll down to the "Operating System" section and set the "dbsession" option to "Yes".

Check out the wwmoodle module from the WeBWorKCVS repository:

cvs -d :pserver:anoncvs@cvs.webwork.rochester.edu:/webwork/cvs/system co wwmoodle

This will create a wwmoodle directory in the current directory. Move the wwassignment subdirectory to your Moodle mod directory.

cd wwmoodle
mv wwassignment /path/to/moodle/mod
cd /path/to/moodle

Create symlinks to the language files in the proper locations.

cd /path/to/moodle/lang/en
ln -s ../../mod/wwassignment/lang.php wwassignment.php
cd help
ln -s ../../../mod/wwassignment/help wwassignment

If you're using the utf8 encoding, move the files into the en_utf8 directory instead of the en directory. (Or do both.)

The advantage of symlinking is that a cvs up from the wwassignment directory will be able to update the language files. Some people have reported problems when symlinking. If this is your experience, just move the files instead:

cd /path/to/moodle/lang/en
mv ../../mod/wwassignment/lang.php wwassignment.php
cd help
mv ../../../mod/wwassignment/help wwassignment

Log in to Moodle as an administrator and select the "Admin..." option. At this point, Moodle will set up the wwassignment module.

Then, select the "Configuration" option and then the "Modules" option. Click the "Settings" link next to "WeBWorK Problem Set" to configure the module.

Option Description
wwassignment_webworkcourses This is the path to the WeBWorK courses directory. It should be set to the same value as the $webwork_courses_dir variable in global.conf, except that in this case it needs to end with a slash.
wwassignment_webworkurl The URL where WeBWorK is accessible. By default, this is /webwork2. If WeBWorK is on a different port, you'll need the full URL. This should be the same value as $webwork_url in global.conf. It does not need a trailing slash.
wwassignment_iframewidth Width of frame in which WeBWorK problem sets are embedded.
wwassignment_iframeheight Height of frame in which WeBWorK problem sets are embedded.

There are a few settings that need to be made in global.conf as well:

Option Description
$moodle_dsn The DSN for the moodle database. Default: "dbi:mysql:moodle". Corresponds to dbtype, dbhost, and dbname in Moodle's config.php.
$moodle_table_prefix The prefix to prepend to Moodle table names. Default: "mdl". Corresponds to prefix in Moodle's config.php.
$moodle_username The username to use when connecting to the Moodle database. Default: same as WeBWorK database username. Corresponds to dbuser in Moodle's config.php.
$moodle_password The password to use when connecting to the Moodle database. Default: same as WeBWorK database password. Corresponds to dbpass in Moodle's config.php.

Usage

Once you've set this up, you should notice a new WeBWorK Problem Set activity in the list of activities you can add to your course. The form for creating WeBWorK problem sets includes two interesting links.

The first is Create the WeBWorK course. This links you to the WeBWorK Course Administration page, with the name of the course pre-filled and the sql_moodle database layout preselected. This link shows up whether or not the course has already been created, so you may get an error is the course already exists.

The second is Administer the WeBWorK portion of this course. This links you to the WeBWorK Instructor Tools page, where you can configure problem sets. You can also view, but not edit, the User List.

WeBWorK theme for Moodle

The moodle WeBWorK theme is a modified version of the default math theme. It detects when WeBWorK is called from within a Moodle frame, and removes superfluous interface elements. It also expands the Moodle frame so that it doesn't have to scroll.

Set the theme by changing the value of $defaultTheme in global.conf (for all courses) or a specific course's course.conf (for just that course). This value can also be set for a particular course using the Course Configuration page.

Moodle authentication rules

Moodle administrators are allowed to log into any WeBWorK sql_moodle course. They are assigned permission level 10.

Moodle teachers are allowed to log into only their corresponding WeBWorK sql_moodle course. They also get permission level 10.

Moodle students are allowed to log into only their corresponding WeBWorK sql_moodle course. They get permission level =0=.

Moodle groups are mapped to WeBWorK recitations, unless the group begins with SEC_, in which case, it is mapped to a WeBWorK section (with the SEC_ prefix is removed).

sql_moodle admin course

The WeBWorK course administration system can be configured to authenticate against a Moodle course.

First, create a Moodle course with the short name admin. This course doesn't need to have any participants or any content.

If you haven't created your WeBWorK admin course yet, select the sql_moodle database layout when you do.

If you've already created your WeBWorK admin course, edit its course.conf file to change the $dbLayoutName to sql_moodle.

You will be able to log into the admin course using the credentials of any Moodle administrator. If you would like to grant access to non-administrators, make them teachers in the Moodle admin course.

Limitations

Course naming

The name of the WeBWorK course that is associated with a given Moodle course is fixed. The system takes the short name of the Moodle course and removes any non-alphanumeric characters. This value is then stored. If you have two Moodle courses with identical short names (modulo non-alphanumeric characters), they will be associated with the same WeBWorK course. The behavior in this case is not defined.

We intend to make the name of the linked WeBWorK course configurable, and prevent two Moodle courses from being associated with the same WeBWorK course.

Set assignment

In Moodle, activities are always assigned to all participants in a course. However, you still have to assign WeBWorK homework sets to students using the WeBWorK instructor tools -- this is not done automatically.

Credits

The original wwmoodle package was developed by Peter Snoblin at the University of Missouri. http://www2.truman.edu/~pas577/wwmoodle/

The WeBWorK parts were integrated into the official source by Main.SamHathaway. The Moodle parts (wwmoodle and wwmoodleset) were refactored into the wwassignment module by Main.MichaelGage.