- Open \theme\standard\config.php (assume you are using "standard" theme)
- Find the last element of $THEME->sheets (should be css3 if you have not done anything yet)
- Open \theme\standard\style\css3.css and add your css code
- Goto \moodledata\cache\theme\standard\css and delete all files (anyone have a better way?)
- Done
2011年4月3日 星期日
Add a style (CSS)
2011年3月14日 星期一
Set up role permission
First, add this to \mod\your_module\db\access.php (after line $capabilities = array( )
Open \mod\your_module\lang\en\your_module.php, add this line:
$string['your_module:view'] = 'View your module';
Change version.php to new version, and then goto Notification.
Use this to test the permission:
'mod/your_module:view' => array(
'captype' => 'read',
'contextlevel' => CONTEXT_MODULE,
'legacy' => array(
'teacher' => CAP_ALLOW
)
)
'captype' => 'read',
'contextlevel' => CONTEXT_MODULE,
'legacy' => array(
'teacher' => CAP_ALLOW
)
)
Open \mod\your_module\lang\en\your_module.php, add this line:
$string['your_module:view'] = 'View your module';
Change version.php to new version, and then goto Notification.
Use this to test the permission:
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
has_capability('mod/your_module:view', $context)
has_capability('mod/your_module:view', $context)
2011年3月12日 星期六
2011年3月10日 星期四
Make new module with groupING
In mod_form.php, add this line:
$this->_features->groupings = true;
Note: But i still wonder why others module don't add this line but they are still available for groupING, any idea?
$this->_features->groupings = true;
Note: But i still wonder why others module don't add this line but they are still available for groupING, any idea?
2011年3月8日 星期二
Add a table to Module Database
- Site administration -> Development -> XMLDB editor
- Find your module and click [Load]
- Click [Edit]
- Click [New table] and fill in the detail
- Click [Back]
- Click [View PHP code]
- Select action: create table
- Select table: select your table name
- Click "View"
- Copy the code to mod/your_mod/db/upgrade.php
- Change XXXXXXXXXX to new version number (e.g. 2011022301)
- Open mod/your_mod/version.php, change $module->version to the new version number
- Notification
- Done
2011年2月27日 星期日
Create a new format
- Goto course/format/ (read the README.txt there)
- Copy topics folder to a new folder (e.g. yourformat)
- Goto yourformat/lang/en/
- Rename "format_topics.php" to "format_yourformat.php"
- Open format_yourformat.php
- Change the $string
- Done.
2011年2月22日 星期二
Add a field to Module Update page
By Module Update page, i mean the page shown when you add a new activity or update it.
Note: You should add a field to the database first if you want to save the entered field information.
Note2: your_field is the field name in the database of table mdl_your_mod, the field information will save to the table
Note3: To show the field, just use $your_mod->your_field
Note: You should add a field to the database first if you want to save the entered field information.
- Open mod\your_mod\mod_form.php
- Add this line: $mform->addElement('text', 'your_field', 'label_shown', array('size'=>'64'));
- Done
Note2: your_field is the field name in the database of table mdl_your_mod, the field information will save to the table
Note3: To show the field, just use $your_mod->your_field
Add a field to Module Database
- Site administration -> Development -> XMLDB editor
- Find your module and click [Load]
- Click [Edit]
- At the Tables section, click the table you want to add field
- Click [New field] and fill in the detail
- [View PHP code]
- Select action: add field
- Select field/key/index: your_new_field_name
- Click "View"
- Copy the code to mod/your_mod/db/upgrade.php
- Change XXXXXXXXXX to new version number (e.g. 2011022301)
- Open mod/your_mod/version.php, change $module->version to the new version number
- Notification
- Done
A good way to print message
Use: print_string( 'the_message', 'your_module_name' );
Then, at mod\your_mod\lang\en\your_mod.php, add:
$string[ 'the_message' ] = 'Welcome!!!';
Then, at mod\your_mod\lang\en\your_mod.php, add:
$string[ 'the_message' ] = 'Welcome!!!';
Remove a Module
- Goto: Site administration -> Plugins -> Activity modules -> Manage activities
- Find your module and click Delete
- Remove the module from mod/ folder
- Done
2011年2月17日 星期四
Show Block on My Moodle page
By default, some of the blocks cannot be shown on My Moodle page. However, we can force them, but you need to take the risk that the block may be work on My Moodle page. (e.g. some course level functions)
- Go to blocks/your_block/ folder
- Edit block_your_block.php
- Go to function applicable_formats()
- Change "'my' => false" to "'my' => true"
- Done.
Redirect to My Moodle page after login
Site administrator -> Appearance -> Navigation -> Default home page for users -> My Moodle
2011年1月27日 星期四
GD problem
If you cannot find the upload picture area in moodle, there is a chance that the GD module does not installed to the PHP.
You can check by: Site administration -> Server -> PHP info (if it is installed, you will find the word "gd" somewhere on the page)
If GD is not installed:
1) If you are in Windows platform, go to php.ini, uncomment the line "extension=php_gd2.dll"
2) If you are unix platform, you need to reinstall php with "--with-gd" option
After installation, go to Site administration -> Server -> System paths, change GD version to "GD 2.x installed".
Good Luck! (It can be a big task!)
You can check by: Site administration -> Server -> PHP info (if it is installed, you will find the word "gd" somewhere on the page)
If GD is not installed:
1) If you are in Windows platform, go to php.ini, uncomment the line "extension=php_gd2.dll"
2) If you are unix platform, you need to reinstall php with "--with-gd" option
After installation, go to Site administration -> Server -> System paths, change GD version to "GD 2.x installed".
Good Luck! (It can be a big task!)
2011年1月26日 星期三
Create a new block
Assume the new block name is your_new_block:
- Got to moodle/blocks/
- Create a folder: your_new_block
- Copy blog_menu/*.* to your_new_block/ (as blog_menu is a simple block)
- Go to your_new_block folder
- Rename block_blog_menu.php to block_your_new_block.php
- Open block_your_new_block.php
- Remove the "require_once" line at the top
- Change "class block_blog_menu extends block_base {" to "class block_your_new_block extends block_base {"
- In init(), change "$this->title = get_string('pluginname', 'block_blog_menu');" to "$this->title = get_string('pluginname', 'block_your_new_block');"
- In get_content(), you can delete from "* Prepare the content for this block" to "// Return the content object", just keep the last return line.
- All you have to do is fill in $this->content->text = "Your block content html";
- Go to lang\en\ folder
- Rename block_blog_menu.php to block_your_new_block.php
- Open the file, change "$string['pluginname'] = 'Blog menu';" to your block displace name
- Notifications
- Done
Batch add new users
Goto: Site administration -> Users -> Accounts -> Upload users
Using the following file format:
==================================================
username, password, firstname, lastname, email
is1, shtm1234, Susan, Ng, susan@localhost.com
is2, shtm1234, Ann, Chan, ann@localhost.com
==================================================
Using the following file format:
==================================================
username, password, firstname, lastname, email
is1, shtm1234, Susan, Ng, susan@localhost.com
is2, shtm1234, Ann, Chan, ann@localhost.com
==================================================
2011年1月25日 星期二
How to get the student list of a course
global $COURSE, $DB, $OUTPUT;
$context = get_context_instance( CONTEXT_COURSE, $COURSE->id );
$query = 'select u.id as id, firstname, lastname, picture, imagealt, email from mdl_role_assignments as a, mdl_user as u where contextid=' . $context->id . ' and roleid=5 and a.userid=u.id;';
$rs = $DB->get_recordset_sql( $query );
foreach( $rs as $r ) {
echo $OUTPUT->user_picture($r, array('size' => 50, 'courseid'=>$COURSE->id));
echo $r->firstname . ' ' . $r->lastname . '<br>';
}
$context = get_context_instance( CONTEXT_COURSE, $COURSE->id );
$query = 'select u.id as id, firstname, lastname, picture, imagealt, email from mdl_role_assignments as a, mdl_user as u where contextid=' . $context->id . ' and roleid=5 and a.userid=u.id;';
$rs = $DB->get_recordset_sql( $query );
foreach( $rs as $r ) {
echo $OUTPUT->user_picture($r, array('size' => 50, 'courseid'=>$COURSE->id));
echo $r->firstname . ' ' . $r->lastname . '<br>';
}
2011年1月24日 星期一
No more Topic Section for Topics format
What i am trying to do is to hide all the topics when we are using the "Topics format".
- Open moodle\course\format\topics\format.php
- uncomment started from "/// Now all the normal modules by topic" to the end of the while loop (Just before "if (!displaysection and...") (from line 135 to 260)
- Done
Build a Hello World new module
- Download the NEWMODULE.zip (HEAD) from http://docs.moodle.org/en/Development:NEWMODULE_Documentation (or download here) (Follow the README.txt from the zip file! (not the tutorial at moodle.org, it is not for 2.0))
- Rename all occurrences of "NEWMODULE" to "widget" (or your new module name) of the all files in the zip (161 replacements) (Also rename "newmodule" to "widget" for unix system)
- Rename "NEWMODULE" folder to "widget"
- Rename lang\en\NEWMODULE.php to widget.php
- In version.php, modify $module->version to current date (you need to change the XX for each update). Comment this line: $module->version = 0
- Optional: In view.php, just before the footer(), add -> echo 'Hello World';
- Copy the widget folder to moodle\mod\
- Site Administration -> Notifications, when you see the new module, -> Update
- Done.
2011年1月18日 星期二
Word censorship
To enable: Site Administration -> Plugins -> Filters -> Manage filters -> Word Censorship -> On -> Content and headings
You can add words in the "Settings" link.
The file contains the censor words: moodle\filter\censor\lang\en\filter_censor.php
You can add words in the "Settings" link.
The file contains the censor words: moodle\filter\censor\lang\en\filter_censor.php
2011年1月13日 星期四
Run cron.php
Moodle use cron.php to handle some routine tasks, i think we need to setup something to make this script run regularly.
Simple enough, download and run MoodleCron-Setup.exe, it will install a windows service for you to handle the everything.
You can also configure cron.php to be executed via command line (ie. cannot run by browser), and set up password: Site administration -> Security -> Site policies
For more details, come here:
http://docs.moodle.org/en/Cron#Managing_Cron_on_Windows_systems
Simple enough, download and run MoodleCron-Setup.exe, it will install a windows service for you to handle the everything.
You can also configure cron.php to be executed via command line (ie. cannot run by browser), and set up password: Site administration -> Security -> Site policies
For more details, come here:
http://docs.moodle.org/en/Cron#Managing_Cron_on_Windows_systems
Why no email is received from a subscribed forum?
It is all because the cron.php does not run. The cron.php is for the regular tasks need to be done, including sending these emails.
You can run the cron.php manual by this url: (oops, it can be run by everyone)
http://yoursite/admin/cron.php
I think we should make the cron.php run regularly, this is what i have done. Anyway, here is more detail about the cron.php:
http://docs.moodle.org/en/Cron
You can run the cron.php manual by this url: (oops, it can be run by everyone)
http://yoursite/admin/cron.php
I think we should make the cron.php run regularly, this is what i have done. Anyway, here is more detail about the cron.php:
http://docs.moodle.org/en/Cron
User cannot update their email address
I don't understand the reason behide, but it does not work!
Here is the discussion of this issue, it seems there is a solution but i have not tried yet:
http://moodle.org/mod/forum/discuss.php?d=161993&parent=711518
Here is the discussion of this issue, it seems there is a solution but i have not tried yet:
http://moodle.org/mod/forum/discuss.php?d=161993&parent=711518
2011年1月10日 星期一
Redirect to user course after login
Aim: When I login to Moodle, the system will redirect the user to his last accessed course.
Add the following code to \moodle\login\index.php (just before the "Go to my-moodle page instead of site homepage if defaulthomepage set to homepage_my" comment):
==================================================
//redirect user to his course (ignore if it is his first time login)
if ( !empty( $user->lastcourseaccess ) ) {
$mostRecent = 0;
$mostRecentCourse = 0;
foreach ( $user->lastcourseaccess as $k => $v ) {
if ( $v > $mostRecent ) {
$mostRecent = $v;
$mostRecentCourse = $k;
}
}
if ( $mostRecent != 0 ) {
$urltogo = $CFG->wwwroot.'/course/view.php?id='.$mostRecentCourse;
}
}
}
==================================================
Add the following code to \moodle\login\index.php (just before the "Go to my-moodle page instead of site homepage if defaulthomepage set to homepage_my" comment):
==================================================
//redirect user to his course (ignore if it is his first time login)
if ( !empty( $user->lastcourseaccess ) ) {
$mostRecent = 0;
$mostRecentCourse = 0;
foreach ( $user->lastcourseaccess as $k => $v ) {
if ( $v > $mostRecent ) {
$mostRecent = $v;
$mostRecentCourse = $k;
}
}
if ( $mostRecent != 0 ) {
$urltogo = $CFG->wwwroot.'/course/view.php?id='.$mostRecentCourse;
}
}
}
==================================================
Add Login form on the Front Page
Simple!
- Turn editing on
- Add a block -> Login
- Done!
How to create a clean, 1 column Front Page
I want to make a very clean first page.
By first page, i mean the front page that the users first landed without login.
By clean, i mean only the site title, the login link and some description text.
This is what i want:
Here are the steps:
By first page, i mean the front page that the users first landed without login.
By clean, i mean only the site title, the login link and some description text.
This is what i want:
Here are the steps:
- Site administration -> Front page -> Front page settings
- Clear all "Front page" combo box
- Clear all "Front page items when logged in" combo box
- Check "Include a topic section"
- Click "Save changes"
- Back to "Home"
- Front page Settings -> Turn editing on
- For Navigation block, click "Configuration", select "No" for On this page: Visible
- Click "Save changes"
- Hide or Delete all other blocks that are visible by other users
- Back to "Home"
- Add a resource: Label, just type some contents and save
- Done!
2011年1月9日 星期日
Moodle 2.0 window installation package
The installation packages of Moodle 2.0 for Windows is finally out! (It is already out for a few weeks)
We don't need to install the Apache+PHP+Mysql by ourself now.
Download page:
http://download.moodle.org/windows/
We don't need to install the Apache+PHP+Mysql by ourself now.
Download page:
http://download.moodle.org/windows/
What is Front page questions?
We can access "Question bank" from here. Question bank is used to create question template or standard questions.
Please noted that moodle treats Front page as a course.
Please noted that moodle treats Front page as a course.
What is this web log about?
I am a newbie for moodle. Just start working on moodle project.
This blog will record the problem that i have encountered during my development, and if possible, the solution.
I will also drop developing notes here, so that i can come back to see what i have already done. (No need to re-invent the FORGOTTEN wheel)
btw, I am working on Moodle 2.0.
This blog will record the problem that i have encountered during my development, and if possible, the solution.
I will also drop developing notes here, so that i can come back to see what i have already done. (No need to re-invent the FORGOTTEN wheel)
btw, I am working on Moodle 2.0.
訂閱:
文章 (Atom)