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!)

2011年1月26日 星期三

Create a new block

Assume the new block name is your_new_block:
  1. Got to moodle/blocks/
  2. Create a folder: your_new_block
  3. Copy blog_menu/*.* to your_new_block/ (as blog_menu is a simple block)
  4. Go to your_new_block folder
  5. Rename block_blog_menu.php to block_your_new_block.php
  6. Open block_your_new_block.php
  7. Remove the "require_once" line at the top
  8. Change "class block_blog_menu extends block_base {" to "class block_your_new_block extends block_base {"
  9. In init(), change "$this->title = get_string('pluginname', 'block_blog_menu');" to "$this->title = get_string('pluginname', 'block_your_new_block');"
  10. In get_content(), you can delete from "* Prepare the content for this block" to "// Return the content object", just keep the last return line.
  11. All you have to do is fill in $this->content->text = "Your block content html";
  12. Go to lang\en\ folder
  13. Rename block_blog_menu.php to block_your_new_block.php
  14. Open the file, change "$string['pluginname'] = 'Blog menu';" to your block displace name
  15. Notifications
  16. 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

==================================================

How to change the Password Policy

Site administration -> Security -> Site policies

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>';
}

Access phpMyAdmin

Browse to: http://localhost/admin/mysql/

(Not all installation package get this)

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".
  1. Open moodle\course\format\topics\format.php
  2. 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)
  3. Done

Build a Hello World new module

  1. 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))
  2. 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)
  3. Rename "NEWMODULE" folder to "widget"
  4. Rename lang\en\NEWMODULE.php to widget.php
  5. In version.php, modify $module->version to current date (you need to change the XX for each update). Comment this line: $module->version = 0
  6. Optional: In view.php, just before the footer(), add -> echo 'Hello World';
  7. Copy the widget folder to moodle\mod\
  8. Site Administration -> Notifications, when you see the new module, -> Update
  9. Done.
Note: It seems there will be some problem if the last character of the module name is digital

    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

    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

    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

    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

    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 Login form on the Front Page

    Simple!
    1. Turn editing on
    2. Add a block -> Login
    3. Done!
    I have tried adding the Login form at the middle of the page (as a label), but it is no good. It is difficult to remove the Login form after login! The role/permission settings is not good.

    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:
    1. Site administration -> Front page -> Front page settings
    2. Clear all "Front page" combo box
    3. Clear all "Front page items when logged in" combo box
    4. Check "Include a topic section"
    5. Click "Save changes"
    6. Back to "Home"
    7. Front page Settings -> Turn editing on
    8. For Navigation block, click "Configuration", select "No" for On this page: Visible
    9. Click "Save changes"
    10. Hide or Delete all other blocks that are visible by other users
    11. Back to "Home"
    12. Add a resource: Label, just type some contents and save
    13. Done!
    Reference: Moodle site

    2011年1月9日 星期日

    Resource: Page

    "Page" resource is good to create a page for information

    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/

    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.

    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.