Note: You are currently viewing documentation for Moodle 2.0. Up-to-date documentation for the latest stable version is available here: Administration hacks.

Administration hacks: Difference between revisions

From MoodleDocs
(Intro to page)
(Added section: "Accessing courses with a permanent user friendly URL")
Line 1: Line 1:
Here are some hacks or tweaks to Moodle code that administrators have found useful on their sites to fill specific needs.   
Here are some hacks or tweaks to Moodle code that administrators have found useful on their sites to fill specific needs.   
== Accessing courses with a permanent user friendly URL ==
The idea is to access a course with a user friendly URL instead of the usual cryptic way.
In this example we will propose URLs for courses based on their short names, in the form:
http://moodle.some.where.org/pages/SHORTNAME
where SHORTNAME is the exact name defined on the course settings (case sensitive).
There are, however, some limitations on the characters that can be used to achieve this due to URL special characters.
In this example the allowed set of characters are [ A-Z a-z 0-9 - _  . @ ].
So you have to change apache configuration in the global or VirtualHost section:
  RewriteEngine on
  #uncomment the following two lines if you want to debug
  #RewriteLog "/var/log/httpd/rewrite.log"
  #RewriteLogLevel 9
 
  #pages@moodle
  RewriteRule ^/pages/([A-Za-z0-9\-\_\.\@]+)/?$ /course/view.php?name=$1 [R,L]
  RewriteRule ^/pages/ / [R,L]


== Preventing Welcome to the course emails ==
== Preventing Welcome to the course emails ==

Revision as of 19:24, 21 August 2008

Here are some hacks or tweaks to Moodle code that administrators have found useful on their sites to fill specific needs.

Accessing courses with a permanent user friendly URL

The idea is to access a course with a user friendly URL instead of the usual cryptic way. In this example we will propose URLs for courses based on their short names, in the form:

http://moodle.some.where.org/pages/SHORTNAME

where SHORTNAME is the exact name defined on the course settings (case sensitive).

There are, however, some limitations on the characters that can be used to achieve this due to URL special characters. In this example the allowed set of characters are [ A-Z a-z 0-9 - _ . @ ].

So you have to change apache configuration in the global or VirtualHost section:


  RewriteEngine on
  #uncomment the following two lines if you want to debug
  #RewriteLog "/var/log/httpd/rewrite.log"
  #RewriteLogLevel 9
  
  #pages@moodle
  RewriteRule ^/pages/([A-Za-z0-9\-\_\.\@]+)/?$ /course/view.php?name=$1 [R,L]
  RewriteRule ^/pages/ / [R,L]


Preventing Welcome to the course emails

You can stop moodle sending enrolment emails by changing two lines in the file /enrol/enrol.class.php

The line (occuring twice in the file!) reads:

      email_to_user($USER, $teacher, $subject, $message);

It must be changed to:

      //     email_to_user($USER, $teacher, $subject, $message);

That way, moodle ignores the e-mail-command until you change back to the original line. The setting works for all courses at the same time. It does not affect other e-mails being sent (e.g. the login confirmation).

Reference