Cool Solution - Install Moodle

From Univention Wiki

Revision as of 08:12, 24 June 2015 by Rehberg (talk | contribs)
Jump to: navigation, search
Produktlogo UCS Version 4.0
Produktlogo UCS@School Version 4.0

Note: Cool Solutions are articles documenting additional functionality based on Univention products. Not all of the shown steps in the article are covered by Univention Support. For questions about your support coverage contact your contact person at Univention before you want to implement one of the shown steps.

Also regard the legal notes at Terms of Service.


Introduction

This article introduces you to the usage of Moodle. It covers the installation on a dedicated school server, as well as the users authentication with the LDAP. If further integration packages are needed, like loading classes from the LDAP or using the Microsoft Windows authentication for already logged in users, feel free to contact Univention for assistance.

Installation

This section will cover the preparation and installation of Moodle on the system. Please make sure that every command is executed as root user.

To install necessary packages, execute the following command to install apache2, php5 and mysql

 apt-get install apache2 php5 mysql-server php5-mysql libapache2-mod-php5 php5-gd php5-curl php5-xmlrpc php5-intl php5-ldap

The MySQL database modules must be included in PHP. Add the following two lines into the /etc/php5/apache2/php.ini file:

extension=mysql.so
extension=gd.so

To use Moodle effectively, it is recommended to raise the maximum size for uploads, e. g. 20 MB, to provide small programs to students. The changes must be done in the /etc/php5/apache2/php.ini file:

post_max_size = 20M
upload_max_filesize = 20M

For the changes to take effect, the Apache webserver must be restarted:

/etc/init.d/apache2 restart


Configuration

This section handles the basic configuration and LDAP connection for Moodle and how to delete users in Moodle that are not in the LDAP anymore.

Basic configuration

Hint: It is recommended to create a Moodle user with appropriate privileges on the Moodle database.

To setup the MySQL Database, execute the following command:

mysql -u root -p

Enter your password

Create the Moodle database

mysql> CREATE DATABASE moodle;

Then ensure that the database is set to UTF8 which is required by later distributions of Moodle

mysql> ALTER DATABASE moodle charset=utf8;

Then exit the database

mysql> exit;


The next step is, to download Moodle from the following site [1] (latest Version: 2.9):

Unpack the file with the following command:

tar -zxvf <your-file>

The file will probably be located in your current folder. Move the 'Moodle' file to /var/www:

mv moodle /var/www

Switch to the correct directory

cd /var/www

Set ownership and permissions so that Apache can access the files

chown -R www-data:www-data moodle \
chmod -R 755 moodle

Switch the directory again

cd /var/

Create a directory for user and course files

mkdir moodledata

Set ownership and permissions so that Apache can access the files

chown -R www-data:www-data moodledata

Now the Moodle service can be reached and configured by opening the web page in a webbrowser:

http://<server>/moodle


LDAP authentification

After the basic configuration is done, https should be activated in Site Administration -> Security -> HTTP security. Next, in Site Administration -> Plugin -> Authentication -> Manage authentication the option Email-based self-registration should be deactivated and LDAP server should be activated.

Next, a simple authentication account should be created using the UDM. This account can then be used for an authenticated bind. To find the DN of the account issue the following command on the command line:

udm users/user list --filter username=<NAME of the account> | grep DN

Now the LDAP connection can be configured under Site Administration -> Plugin -> Authentication -> Manage authentication -> LDAP Server -> Settings. The table gives information which default settings must be changed:

Key Value
LDAP server settings
Host URL ldap://<school server's FQDN>:7389
Version 3
Bind settings
Distinguished Name <DN of the authentication account>
Password <Password of the authentication account>
User lookup settings
Contexts cn=users,dc=<school>,dc=<domain>
Search subcontexts Yes
User Attribute uid
Course creator
Creators cn=lehrer,cn=users,dc=<school>,dc=<domain>
Cron synchronization script
Removed ext user Full delete internal
Data mapping
Update local On Every Login
Update external Never
Lock value Locked

Hint: To obtain the LDAP basis, execute the following command on the school server:

ucr get ldap/base

Hint: To obtain the system's FQDN, execute the following command on the relevant system:

hostname -f


LDAP mapping

Furthermore, the following mapping applies for LDAP entries:

Key Value
First name givenName
Surname sn
Email address mail
Phone 1 telephoneNumber
Phone 2 homePhone
City/town l
Country c


Note: Some fields like Email address are mandatory for moodle, so you should make sure all moodle users have a valid email in UCS.

Hint: Before logging in to Moodle , make sure that a mail domain has been created. (Use the UMC)

Cronjob for deleting users

In order for Moodle to remove users from its database that are deleted in the LDAP, a cronjob must be defined in the UDM.

ucr set cron/moodle/command='wget -q -O /dev/null http://localhost/moodle/admin/cron.php'\
cron/moodle/time='*/10 * * * *'

Restrictions

  1. OU: At this time it is not possible for Moodle to search for all users using the LDAP base DN.
  2. Class mapping: This article does not handle mappings between UCS@School classes and Moodle groups. If you need assistance to create the respective mapping or would like to have the setup packaged, feel free to contact Univention for an offer to create either.

References

Further links

Personal tools