tag:blogger.com,1999:blog-37607363751197194082024-03-05T19:10:47.875-08:00Moodle 2.0moodlehttp://www.blogger.com/profile/09407417208895136273noreply@blogger.comBlogger32125tag:blogger.com,1999:blog-3760736375119719408.post-79242171791360829882011-04-03T18:52:00.000-07:002011-04-03T18:52:03.641-07:00Add a style (CSS)<ol><li style="font-family: "Courier New",Courier,monospace;">Open \theme\standard\config.php (assume you are using "standard" theme)</li>
<li style="font-family: "Courier New",Courier,monospace;">Find the last element of $THEME->sheets (should be css3 if you have not done anything yet)</li>
<li style="font-family: "Courier New",Courier,monospace;">Open \theme\standard\style\css3.css and add your css code</li>
<li style="font-family: "Courier New",Courier,monospace;">Goto \moodledata\cache\theme\standard\css and delete all files (anyone have a better way?)</li>
<li><span style="font-family: "Courier New",Courier,monospace;">Done</span></li>
</ol>moodlehttp://www.blogger.com/profile/09407417208895136273noreply@blogger.com0tag:blogger.com,1999:blog-3760736375119719408.post-50252657122531888942011-03-14T01:29:00.000-07:002011-03-21T02:40:09.791-07:00Set up role permissionFirst, add this to \mod\your_module\db\access.php (after line <span style="font-family: "Courier New",Courier,monospace;">$capabilities = array(</span> )<br />
<div style="font-family: "Courier New",Courier,monospace;"> 'mod/your_module:view' => array(<br />
'captype' => 'read',<br />
'contextlevel' => CONTEXT_MODULE,<br />
'legacy' => array(<br />
'teacher' => CAP_ALLOW<br />
)<br />
)</div><br />
Open \mod\your_module\lang\en\your_module.php, add this line:<br />
<span style="font-family: "Courier New",Courier,monospace;">$string['your_module:view'] = 'View your module';</span><br />
<br />
Change version.php to new version, and then goto Notification.<br />
<br />
Use this to test the permission: <br />
<div style="font-family: "Courier New",Courier,monospace;">$context = get_context_instance(CONTEXT_MODULE, $cm->id); <br />
has_capability('mod/your_module:view', $context) </div>moodlehttp://www.blogger.com/profile/09407417208895136273noreply@blogger.com0tag:blogger.com,1999:blog-3760736375119719408.post-36779980246251586922011-03-12T17:43:00.001-08:002011-03-12T17:43:38.804-08:00Construct a url stringnew moodle_url( 'url_path', array( 'paramenter1'=>$value1 ) );moodlehttp://www.blogger.com/profile/09407417208895136273noreply@blogger.com0tag:blogger.com,1999:blog-3760736375119719408.post-6588135436377796582011-03-10T16:42:00.000-08:002011-03-10T16:42:39.420-08:00Make new module with groupINGIn mod_form.php, add this line:<br />
$this->_features->groupings = true;<br />
<br />
Note: But i still wonder why others module don't add this line but they are still available for groupING, any idea?moodlehttp://www.blogger.com/profile/09407417208895136273noreply@blogger.com0tag:blogger.com,1999:blog-3760736375119719408.post-79736109716555475382011-03-08T01:17:00.000-08:002011-03-08T17:25:12.462-08:00Add a table to Module Database<ol><li>Site administration -> Development -> XMLDB editor</li>
<li>Find your module and click [Load]</li>
<li>Click [Edit]</li>
<li>Click [New table] and fill in the detail</li>
<li>Click [Back]</li>
<li>Click [View PHP code]</li>
<li>Select action: create table</li>
<li>Select table: select your table name</li>
<li>Click "View"</li>
<li><span>Copy the code to mod/your_mod/db/upgrade.php</span></li>
<li><span>Change XXXXXXXXXX to new version number (e.g. 2011022301)</span></li>
<li><span>Open mod/your_mod/version.php, change $module->version to the new version number</span></li>
<li>Notification<span> </span></li>
<li><span>Done </span></li>
</ol>moodlehttp://www.blogger.com/profile/09407417208895136273noreply@blogger.com0tag:blogger.com,1999:blog-3760736375119719408.post-217649313637290502011-02-27T16:34:00.000-08:002011-02-27T17:38:38.312-08:00Create a new format<ol><li>Goto course/format/ (read the README.txt there) </li>
<li>Copy topics folder to a new folder (e.g. yourformat)</li>
<li>Goto yourformat/lang/en/</li>
<li>Rename "format_topics.php" to "format_yourformat.php"</li>
<li>Open format_yourformat.php</li>
<li>Change the $string</li>
<li>Done.</li>
</ol>Note: course/format/yourformat/format.php is the file for output view <br />
<ol></ol>moodlehttp://www.blogger.com/profile/09407417208895136273noreply@blogger.com0tag:blogger.com,1999:blog-3760736375119719408.post-84746716380842845272011-02-22T18:45:00.001-08:002011-02-22T18:45:46.759-08:00Add new field to user profile<span>Site administration -> </span><span>Users -> </span><span>Accounts -> User profile fields</span>moodlehttp://www.blogger.com/profile/09407417208895136273noreply@blogger.com0tag:blogger.com,1999:blog-3760736375119719408.post-237775884661565132011-02-22T18:32:00.000-08:002011-02-22T18:40:54.235-08:00Add a field to Module Update pageBy Module Update page, i mean the page shown when you add a new activity or update it.<br />
<br />
Note: You should <a href="http://moodlever.blogspot.com/2011/02/add-field-to-module-database.html">add a field to the database</a> first if you want to save the entered field information.<br />
<br />
<ol><li>Open mod\your_mod\mod_form.php</li>
<li>Add this line: $mform->addElement('text', 'your_field', 'label_shown', array('size'=>'64'));</li>
<li>Done</li>
</ol><br />
Note2: your_field is the field name in the database of table mdl_your_mod, the field information will save to the table<br />
<br />
Note3: To show the field, just use $your_mod->your_fieldmoodlehttp://www.blogger.com/profile/09407417208895136273noreply@blogger.com1tag:blogger.com,1999:blog-3760736375119719408.post-69761813063022232112011-02-22T18:14:00.000-08:002011-02-22T18:14:01.653-08:00Add a field to Module Database<ol><li><span>Site administration -> </span><span>Development -></span><span> XMLDB editor</span></li>
<li><span>Find your module and click [Load]</span></li>
<li><span>Click [Edit]</span></li>
<li><span>At the Tables section, click the table you want to add field</span></li>
<li><span>Click [New field] and fill in the detail</span></li>
<li><span>[View PHP code]</span></li>
<li><span>Select action: add field</span></li>
<li><span>Select field/key/index: your_new_field_name</span></li>
<li><span>Click "View"</span></li>
<li><span>Copy the code to mod/your_mod/db/upgrade.php</span></li>
<li><span>Change XXXXXXXXXX to new version number (e.g. 2011022301)</span></li>
<li><span>Open mod/your_mod/version.php, change $module->version to the new version number</span></li>
<li>Notification<span> </span></li>
<li><span>Done </span></li>
</ol><span><br />
</span>moodlehttp://www.blogger.com/profile/09407417208895136273noreply@blogger.com2tag:blogger.com,1999:blog-3760736375119719408.post-16070800382443437432011-02-22T17:56:00.000-08:002011-02-22T17:56:45.428-08:00A good way to print messageUse: print_string<span style="color: #009900;">( </span><span style="color: blue;">'the_message'</span><span style="color: #339933;">, </span><span style="color: blue;">'your_module_name'</span><span style="color: #009900;"> )</span><span style="color: #339933;"><span style="color: black;">;</span></span><br />
<br />
<span style="color: #339933;"><span style="color: black;">Then, at mod\your_mod\lang\en\your_mod.php, add:</span></span><br />
<span style="color: #339933;"><span style="color: black;">$string[ 'the_message' ] = 'Welcome!!!'; </span></span>moodlehttp://www.blogger.com/profile/09407417208895136273noreply@blogger.com0tag:blogger.com,1999:blog-3760736375119719408.post-91731633322428964732011-02-22T16:50:00.000-08:002011-02-22T16:53:06.352-08:00Remove a Module<ol><li><span>Goto: Site administration -> </span><span>Plugins -> </span><span>Activity modules -> Manage activities</span></li>
<li><span>Find your module and click Delete</span></li>
<li><span>Remove the module from mod/ folder</span></li>
<li><span>Done</span></li>
</ol>moodlehttp://www.blogger.com/profile/09407417208895136273noreply@blogger.com0tag:blogger.com,1999:blog-3760736375119719408.post-17158709099385606302011-02-17T23:32:00.000-08:002011-02-17T23:32:19.196-08:00Show Block on My Moodle pageBy 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)<br />
<br />
<ol style="font-family: "Courier New",Courier,monospace;"><li>Go to blocks/your_block/ folder</li>
<li>Edit block_your_block.php</li>
<li>Go to function applicable_formats()</li>
<li>Change "'my' => false" to "'my' => true"</li>
<li>Done.</li>
</ol>moodlehttp://www.blogger.com/profile/09407417208895136273noreply@blogger.com0tag:blogger.com,1999:blog-3760736375119719408.post-48826733264173623792011-02-17T22:42:00.001-08:002011-02-17T22:42:59.181-08:00Redirect to My Moodle page after loginSite administrator -> Appearance -> Navigation -> Default home page for users -> My Moodlemoodlehttp://www.blogger.com/profile/09407417208895136273noreply@blogger.com0tag:blogger.com,1999:blog-3760736375119719408.post-73526320566751229102011-01-27T01:35:00.000-08:002011-01-27T01:35:15.184-08:00GD problemIf you cannot find the upload picture area in moodle, there is a chance that the GD module does not installed to the PHP.<br />
<br />
You can check by: <span>Site administration -> </span><span>Server -> PHP info (if it is installed, you will find the word "gd" somewhere on the page)</span><br />
<span><br />
</span><br />
<span>If GD is not installed:</span><br />
<span>1) If you are in Windows platform, go to php.ini, uncomment the line "extension=php_gd2.dll"</span><br />
<span>2) If you are unix platform, you need to reinstall php with "--with-gd" option</span><br />
<span><br />
</span><br />
<span>After installation, go to </span><span>Site administration -> </span><span>Server -> System paths, change </span>GD version to "GD 2.x installed".<br />
<br />
Good Luck! (It can be a big task!)moodlehttp://www.blogger.com/profile/09407417208895136273noreply@blogger.com0tag:blogger.com,1999:blog-3760736375119719408.post-9368982167027584112011-01-26T23:38:00.000-08:002011-01-26T23:39:50.527-08:00Create a new blockAssume the new block name is <b>your_new_block</b>: <br />
<ol><li>Got to moodle/blocks/</li>
<li>Create a folder: <b>your_new_block</b></li>
<li>Copy blog_menu/*.* to <b>your_new_block</b>/ (as blog_menu is a simple block)</li>
<li>Go to <b>your_new_block</b> folder</li>
<li>Rename block_blog_menu.php to block_<b>your_new_block</b>.php</li>
<li>Open block_<b>your_new_block</b>.php</li>
<li>Remove the "require_once" line at the top</li>
<li>Change "class block_blog_menu extends block_base {" to "class block_<b>your_new_block</b> extends block_base {"</li>
<li>In init(), change "$this->title = get_string('pluginname', 'block_blog_menu');" to "$this->title = get_string('pluginname', 'block_<b>your_new_block</b>');"</li>
<li>In get_content(), you can delete from "* Prepare the content for this block" to "// Return the content object", just keep the last return line.</li>
<li>All you have to do is fill in $this->content->text = "Your block content html";</li>
<li>Go to lang\en\ folder</li>
<li>Rename block_blog_menu.php to block_<b>your_new_block</b>.php</li>
<li>Open the file, change "$string['pluginname'] = 'Blog menu';" to your block displace name</li>
<li>Notifications</li>
<li>Done</li>
</ol>moodlehttp://www.blogger.com/profile/09407417208895136273noreply@blogger.com0tag:blogger.com,1999:blog-3760736375119719408.post-42725370100439113092011-01-26T00:46:00.000-08:002011-01-26T00:47:00.448-08:00Batch add new users<span id="yui_3_2_0_1_1296031392807759">Goto: Site administration -> </span><span id="yui_3_2_0_1_1296031392807704">Users -> </span><span id="yui_3_2_0_1_1296031392807774">Accounts -> Upload users</span><br />
<br />
<span id="yui_3_2_0_1_1296031392807774">Using the following file format:</span><br />
<span id="yui_3_2_0_1_1296031392807774">==========</span><span id="yui_3_2_0_1_1296031392807774">==========</span><span id="yui_3_2_0_1_1296031392807774">==========</span><span id="yui_3_2_0_1_1296031392807774">==========</span><span id="yui_3_2_0_1_1296031392807774">==========</span><span id="yui_3_2_0_1_1296031392807774"></span><br />
<span id="yui_3_2_0_1_1296031392807774">username, password, firstname, lastname, email<br />
is1, shtm1234, Susan, Ng, susan@localhost.com<br />
is2, shtm1234, Ann, Chan, ann@localhost.com</span><br />
<span id="yui_3_2_0_1_1296031392807774"></span><span id="yui_3_2_0_1_1296031392807774">==========</span><span id="yui_3_2_0_1_1296031392807774">==========</span><span id="yui_3_2_0_1_1296031392807774">==========</span><span id="yui_3_2_0_1_1296031392807774">==========</span><span id="yui_3_2_0_1_1296031392807774">==========</span><span id="yui_3_2_0_1_1296031392807774"></span>moodlehttp://www.blogger.com/profile/09407417208895136273noreply@blogger.com0tag:blogger.com,1999:blog-3760736375119719408.post-70136463778608975082011-01-26T00:39:00.000-08:002011-01-26T00:39:18.300-08:00How to change the Password Policy<span id="yui_3_2_0_1_1296031074758446">Site administration -> </span><span id="yui_3_2_0_1_1296031074758504">Security -> Site policies</span><a href="http://158.132.188.199/moodle/admin/settings.php?section=sitepolicies" id="yui_3_2_0_1_1296031074758522" title="Site policies"></a>moodlehttp://www.blogger.com/profile/09407417208895136273noreply@blogger.com0tag:blogger.com,1999:blog-3760736375119719408.post-59307844991888665492011-01-25T01:15:00.000-08:002011-01-26T00:28:55.702-08:00How to get the student list of a course<span style="font-family: "Courier New",Courier,monospace;">global $COURSE, $DB, $OUTPUT;</span><br />
<span style="font-family: "Courier New",Courier,monospace;">$context = get_context_instance( CONTEXT_COURSE, $COURSE->id );</span><br />
<br />
<span style="font-family: "Courier New",Courier,monospace;">$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;';</span><br />
<br />
<span style="font-family: "Courier New",Courier,monospace;">$rs = $DB->get_recordset_sql( $query ); </span><br />
<span style="font-family: "Courier New",Courier,monospace;">foreach( $rs as $r ) { </span><br />
<span style="font-family: "Courier New",Courier,monospace;"> echo $OUTPUT->user_picture($r, array('size' => 50, 'courseid'=>$COURSE->id));</span><br />
<span style="font-family: "Courier New",Courier,monospace;"> echo $r->firstname . ' ' . $r->lastname . '<br>'; </span><br />
<span style="font-family: "Courier New",Courier,monospace;">}</span>moodlehttp://www.blogger.com/profile/09407417208895136273noreply@blogger.com0tag:blogger.com,1999:blog-3760736375119719408.post-82661875198940377912011-01-25T00:49:00.001-08:002011-01-26T01:30:08.756-08:00Access phpMyAdminBrowse to: <a href="http://localhost/admin/mysql/">http://localhost/admin/mysql/</a><br />
<br />
(Not all installation package get this)moodlehttp://www.blogger.com/profile/09407417208895136273noreply@blogger.com0tag:blogger.com,1999:blog-3760736375119719408.post-321305659450352572011-01-24T01:18:00.000-08:002011-01-24T01:19:39.696-08:00No more Topic Section for Topics formatWhat i am trying to do is to hide all the topics when we are using the "Topics format".<br />
<ol><li>Open moodle\course\format\topics\format.php</li>
<li>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)</li>
<li>Done</li>
</ol>moodlehttp://www.blogger.com/profile/09407417208895136273noreply@blogger.com0tag:blogger.com,1999:blog-3760736375119719408.post-59478320458411169282011-01-24T00:53:00.000-08:002011-02-22T17:35:13.024-08:00Build a Hello World new module<ol><li>Download the NEWMODULE.zip (HEAD) from <a href="http://docs.moodle.org/en/Development:NEWMODULE_Documentation">http://docs.moodle.org/en/Development:NEWMODULE_Documentation</a> (or download <a href="http://download.moodle.org/plugins/mod/NEWMODULE.zip">here</a>) (Follow the README.txt from the zip file! (not the <a href="http://docs.moodle.org/en/Development:NEWMODULE_Tutorial">tutorial</a> at <a href="http://moodle.org/">moodle.org</a>, it is not for 2.0))</li>
<li>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)</li>
<li>Rename "NEWMODULE" folder to "widget"</li>
<li>Rename lang\en\NEWMODULE.php to widget.php</li>
<li>In version.php, modify $module->version to current date (you need to change the XX for each update). Comment this line: $module->version = 0</li>
<li>Optional: In view.php, just before the footer(), add -> echo 'Hello World';</li>
<li>Copy the widget folder to moodle\mod\</li>
<li>Site Administration -> Notifications, when you see the new module, -> Update</li>
<li>Done.</li>
</ol>Note: It seems there will be some problem if the last character of the module name is digital <br />
<ol></ol>moodlehttp://www.blogger.com/profile/09407417208895136273noreply@blogger.com0tag:blogger.com,1999:blog-3760736375119719408.post-88156046124210861432011-01-18T23:28:00.000-08:002011-01-18T23:28:31.688-08:00Word censorshipTo enable: Site Administration -> Plugins -> Filters -> Manage filters -> Word Censorship -> On -> Content and headings<br />
<br />
You can add words in the "Settings" link.<br />
<br />
The file contains the censor words: moodle\filter\censor\lang\en\filter_censor.phpmoodlehttp://www.blogger.com/profile/09407417208895136273noreply@blogger.com0tag:blogger.com,1999:blog-3760736375119719408.post-90991890272963657382011-01-13T01:51:00.000-08:002011-01-18T23:44:59.077-08:00Run cron.phpMoodle use cron.php to handle some routine tasks, i think we need to setup something to make this script run regularly.<br />
<br />
Simple enough, download and run <a href="http://download.moodle.org/download.php/windows/MoodleCron-Setup.exe">MoodleCron-Setup.exe</a>, it will install a windows service for you to handle the everything.<br />
<br />
You can also configure cron.php to be executed via command line (ie. cannot run by browser), and set up password: <span>Site administration -> </span><span>Security -> Site policies</span><br />
<br />
For more details, come here:<br />
<a href="http://docs.moodle.org/en/Cron#Managing_Cron_on_Windows_systems">http://docs.moodle.org/en/Cron#Managing_Cron_on_Windows_systems</a>moodlehttp://www.blogger.com/profile/09407417208895136273noreply@blogger.com0tag:blogger.com,1999:blog-3760736375119719408.post-49398030953080015262011-01-13T01:44:00.000-08:002011-01-13T01:52:35.467-08:00Why 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.<br />
<br />
You can run the cron.php manual by this url: (oops, it can be run by everyone)<br />
http://yoursite/admin/cron.php<br />
<br />
I think we should make the cron.php run regularly, <a href="http://moodlever.blogspot.com/2011/01/run-cronphp.html">this is what i have done</a>. Anyway, here is more detail about the cron.php:<br />
<a href="http://docs.moodle.org/en/Cron">http://docs.moodle.org/en/Cron</a>moodlehttp://www.blogger.com/profile/09407417208895136273noreply@blogger.com0tag:blogger.com,1999:blog-3760736375119719408.post-67175683829937147172011-01-13T01:07:00.000-08:002011-01-13T01:08:30.492-08:00User cannot update their email addressI don't understand the reason behide, but it does not work!<br />
<br />
Here is the discussion of this issue, it seems there is a solution but i have not tried yet:<br />
<a href="http://moodle.org/mod/forum/discuss.php?d=161993&parent=711518">http://moodle.org/mod/forum/discuss.php?d=161993&parent=711518</a>moodlehttp://www.blogger.com/profile/09407417208895136273noreply@blogger.com0