Archive for November, 2008
Thursday, November 6th, 2008
Created custom script in <moodleroot>/local/cron.php which enrolls users in a course and puts users in groups in depending on custom user profile fields set in Moodle.
To enrol participants in a course, I use the role_assign function from accesslib.php:
role_assign($roleid, $userid, $groupid, $contextid, $timestart=0, $timeend=0, $hidden=0, $enrol='manual',$timemodified='')
In this case ideal function because ...
Posted in BrnDmp | No Comments »
Thursday, November 6th, 2008
Developing Moodle usage statistics report for client.
Created some SQL queries and dummy report.
Structure will be as follows:
stats_collect.php -> script which collects stats from the Moodle database and updates the moodlestats database. This script should be run by a cron job like every week.
stats_display.php -> script to display the stats from ...
Posted in BrnDmp | No Comments »
Tuesday, November 4th, 2008
copy/paste from the Moodle forums:
There are some good papers around on tuning PostgreSQL, and Moodle's case does not seem to be different to the general case.
The first thing to recognise is that if you really need to worry about tuning you should be using a separate machine for the database ...
Posted in BrnDmp | No Comments »
Tuesday, November 4th, 2008
Based on earlier attempts, I did a migration of a Moodle database from mysql2postgresql:
1. install 'clean' postgresql database exactly like mysql database (copy codebase and do upgrade)
2. dump mysql, data only with full insert:
[bash]
mysqldump --skip-opt --single-transaction -u moodleuser -p -c -t db &amp;amp;gt; db.20081104.sql
[/bash]
3. converting pg_dump to mysqldump by removing ...
Posted in BrnDmp | No Comments »
Tuesday, November 4th, 2008
If you want to search and replace with sed and immediately save to the file, use the -i option like this:
sed -i s/pattern1/pattern2/g filename
then pattern1 is replaced by pattern2 and replaced in the filename. If you're not sure first run the command without -i to check the output.
Posted in BrnDmp | No Comments »
Monday, November 3rd, 2008
Got request from client to check if we can see who did the 100th quiz. Looked into the Moodle database and came up with the following queries:
select distinct(userid),timemodified from prefix_quiz_grades where quiz = quizid order by timemodified limit 100;
(you should first find the appropriate quizid of course)
then use the userid ...
Posted in BrnDmp | No Comments »
Monday, November 3rd, 2008
Rolled out first version of Moodlestats:
1. dumped database from dev machine and restored in production machine
2. copy / past codebase
3. edited config.php
4. edited httpd.conf
5. added stats_collect.php to crontab (first did inital run)
(6. included authentication hack: included moodle isloggedin() call)
Posted in BrnDmp | No Comments »