- 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
訂閱:
文章 (Atom)