Tuesday, May 7, 2013

Moodle - First attempt

After reading the Moodle community documents for several days, I finally decide to try it out and hope to fix several bugs before they give the final decision on my GSoC 2013 application.

Initially, I followed the steps provided in http://docs.moodle.org/dev/Git_for_developers on my current machine. First apply for those accounts and then fork a brunch on Github (https://github.com/troylee/moodle) and checking out a local copy with SHH-key setup. Then I'm totally lost where to start. That's a pretty big project with lots of source files. Need to find an IDE.

During the process of figuring out which is the popular IDE for Moodle development, I decided to use a completely clean system to do all the development. A Ubuntu 12.04 system is thus created in VirtualBox. 

1. Setup the LAMP system following instructions on https://help.ubuntu.com/community/ApacheMySQLPHP . It simply includes two steps:

First install tasksel...

    $ sudo apt-get install tasksel

... and then the LAMP stack:

    $ sudo tasksel install lamp-server


The only change to the steps is the one that inputs "Source Git repository". Use the previously forked Github repository and my own gihub account and password. Instead of using SSH, the HTTPS is used as there is always error when I tried SSH.

3. Till now, it is almost done. Put a symbolic link under the path /var/www to the git repository folder for Moodle (for mine, it is ~/git/moodle). And make sure the folder has been granted correct permission. I simply used chmod 777 to it as this is for development not for public testing. 

Then, open the browser and type in the http://localhost/moodle . A web-based installation will automatically start for the first time. It requires the creation of a proper permission data folder moodledata, which is better to be under the /var/www path with permission right 777. 

During the installation, it will check the system environments. For my case, I the php5-curl, php5-gd, php5-xmlrpc packages are missing. Using the Ubuntu's apt-get install to get them ready and restart the apache server by /etc/init.d/apache restart. Then click the button at the bottom of the page to redo the checking until all the items are OK. 

Next, the database configuration is required. For Ubuntu, MySql is the default one for LAMP setup, the Improved MySql (native/mysqli) is thus chosen. It at first gave me errors of PHP not configured for mysqli. This was solved by uncomment the line "mysqli.allow_local_infile = On" in the /etc/php5/aphace2/php.ini as all the other lines with mysqli configurations are by default enabled.

Meanwhile, create a MySql database and user for Moodle:

Create a mysql database

    $ mysql> CREATE DATABASE moodel;

Create a mysql user

For creating a new user with all privileges on the moodle database at mysql prompt type:

    $ mysql> GRANT ALL PRIVILEGES ON moodel.* TO 'yourusername'@'localhost' IDENTIFIED BY 'yourpassword' WITH GRANT OPTION;

Next fill out the corresponding information to Moodle.

After updating the admin account information for Moodle site, the final admin workspace will be presented to you.

4. Taking Tim's suggestions on http://dev.moodle.org/mod/forum/discuss.php?d=1803 . Following configuration is done at the admin workspace:

After installing a copy of Moodle for development, the first thing you should do is:

  1. Go to Site administration -> Development -> Debugging
  2. Set Debug messages to DEVELOPER, and Turn on Display debug messages. (Consider turning on some of the other options too.)
  3. In the administration block, search for "Cache" then
    1. Turn off Cache all language strings.
    2. Set Text cache lifetime to No
    3. Turn on Theme designer mode
    4. Turn off Cache Javascript
5. Next as the remote repository we used to setup the Eclipse is forked from Moodle and to keep it updated with changes in Moodle, the instructions in the section "Keeping your public repository update to date" on http://docs.moodle.org/dev/Git_for_developers was followed. 

Before addressing the problem, make sure the suggested git configuration is done:

Immediately after the installation, set your name and contact e-mail. The name and e-mail will become part of your commits and they can't be changed later once your commits are accepted into the Moodle code. Therefore we ask contributors to use their real names written in capital letters, eg "John Smith" and not "john smith" or even "john5677".

   git config --global user.name "Your Name"     git config --global user.email yourmail@domain.tld  

Unless you are the repository maintainer, it is wise to set your Git to not push changes in file permissions:

   git config --global core.filemode false

Then register the upstream remote:

   cd moodle     git remote add upstream git://git.moodle.org/moodle.git  

Then use following commands to keep the standard Moodle branches at your Github repository synced with the upstream repository. You may wish to store them in a script so that you can run it every week after the upstream repository is updated.

   #!/bin/sh     git fetch upstream     for BRANCH in MOODLE_19_STABLE MOODLE_20_STABLE MOODLE_21_STABLE MOODLE_22_STABLE MOODLE_23_STABLE MOODLE_24_STABLE master; do         git push origin refs/remotes/upstream/$BRANCH:$BRANCH     done

However, as in the Eclipse configuration, the git repository is using HTTPS instead of SSH, running the update shell script will require the input of both Github username and password for each push command, which is really annoying. To avoid the trouble of tying, first the SHH-Key configuration should be done (c.f. https://help.github.com/articles/generating-ssh-keys) and added to GitHub account's SHH Keys. 

Then change the repository url by:
git remote set-url origin git@github.com:[username]/moodle.git

With this successfully done, running the above update scripts will bypass the log in phase.

6. From my understanding the changes fetched from upstreams are directly pushed to the Gibhub origin. The local working copy is not affected. It may thus require to fetch/pull changes from my own Github repository and merge with my local copy. Not sure yet. To be confirmed later. 

It seems the setup is almost done to me. It's time to start fixing some bugs!






No comments:

Post a Comment

Google+