Administration hacks: Difference between revisions
(added new hacks - ref 1, 2 and 3.) |
mNo edit summary |
||
Line 74: | Line 74: | ||
$mform->addElement(’text’, ’shortname’, get_string(’shortname’), ‘maxlength=”25″ size=”25″‘); | $mform->addElement(’text’, ’shortname’, get_string(’shortname’), ‘maxlength=”25″ size=”25″‘); | ||
== | == Access 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. | The idea is to access a course with a user friendly URL instead of the usual cryptic way. | ||
Line 96: | Line 96: | ||
RewriteRule ^/pages/ / [R,L] | RewriteRule ^/pages/ / [R,L] | ||
== | == Prevent "Welcome to course" emails == | ||
You can stop moodle sending enrolment emails by changing two lines in the file ''/enrol/enrol.class.php''(4). | You can stop moodle sending enrolment emails by changing two lines in the file ''/enrol/enrol.class.php''(4). |
Revision as of 14:49, 22 August 2008
Here are some hacks or tweaks to Moodle code that administrators have found useful on their sites to fill specific needs.
Approve account creation by self-registration before the new user gains access
In /lib/moodlelib.php, search for the function send_confirmation_email. Change this line of the function (around line 4339 in 1.9.1+):
return email_to_user($user, $supportuser, $subject, $message, $messagehtml);
to:
return email_to_user($supportuser, $supportuser, $subject, $message, $messagehtml);
The confirmation e-mail is sent to the administrator (and not to the new user). Checking the list of user accounts (as Admin on the site), there is link to confirm the account (edit/delete/confirm). Once this is done the administrator can forward the e-mail to the new user (but the account is already approved). (1)
Send a duplicate of the registration email to the administrator
In /lib/moodlelib.php, search for the function send_confirmation_email (around line 3629 in 1.8.4+). At the end of the function there is a line that reads (2):
return email_to_user($user, $from, $subject, $message, $messagehtml);
Just before that line, add a line like this:
email_to_user($from, $from, $subject, $message, $messagehtml);
Set default course blocks rather than using sticky blocks
In moodle/config.php, change lines 20-25:
Find the defaultblocks_topics line and replace with this. Also change the string for defaultblocks_weeks. Don’t change social though (3).
$CFG->defaultblocks_topics = ‘course_menu,myCourses:activity_modules,calendar_upcoming,quickmail’; $CFG->defaultblocks_weeks = ‘course_menu,myCourses:activity_modules,calendar_upcoming,quickmail’;
Turn quickgrade on as default, increase default number of assignments shown to 20, and remove instructor from the list
In moodle/mod/assignment/lib.php, change line 682 (3):
$perpage = get_user_preferences(’assignment_perpage’, 20);
In line 684:
$quickgrade = get_user_preferences(’assignment_quickgrade’, 1);
In line 982:
$teacherattempts = false; /// Temporary measure
Increase the number of course summaries displayed before going to collapsed mode in category view
The following change was made in course/lib.php. Line 13 should read (3):
define(’COURSE_MAX_SUMMARIES_PER_PAGE?‘, 25); // courses
Allow admins to edit posts after closing
In moodle/config.php file, add the following two lines (3):
// Setting this to true will enable admins to edit any post at any time // $CFG->admineditalways = true;
except uncomment the second line (remove the two slashes):
// Setting this to true will enable admins to edit any post at any time $CFG->admineditalways = true;
Change the default course settings to create topic courses instead of weekly courses
In course/edit.php, change line 98 (3):
$mform->setDefault(’format’, ‘weeks’);
to:
$mform->setDefault(’format’, ‘topics’);
If you wanted to, you could change the default number of topics/weeks in a course. Change line 104 in this same file according to your needs:
$mform->setDefault(’numsections’, 10);
Increase shortname field length in the course request form and the course creation form
In moodle/course/edit_form.php, change line 72 (3):
$mform->addElement(’text’,’shortname’, get_string(’shortname’),’maxlength=”25″ size=”25″‘);
In moodle/course/request_form.php, change line 13:
$mform->addElement(’text’, ’shortname’, get_string(’shortname’), ‘maxlength=”25″ size=”25″‘);
Access 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 is [ 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]
Prevent "Welcome to course" emails
You can stop moodle sending enrolment emails by changing two lines in the file /enrol/enrol.class.php(4).
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).