GETTING STARTED



One of the challenges in Moodle development is finding a good starting point for creating a Moodle plug-in. I thought it would be cool to build a step-wise tutorial on the subject as I embark on a personal whim:

Building a Moodle Module that allows the Student to post their Moodle Forum posts to FaceBook, and elicits responses from their group of friends into a totally separate forum. Perhaps too ambitious for a first project, but it hits all of the major challenges.

I will start by coming up with a cool name for the plug-in. I am thinking of calling it InYourFace ?  This particular exercise will focus on building an activity module - a module that provides an activity that can be added to any Moodle course.

WHERE DO WE START?

NOTE: This tutorial assumes that you already have a working installation of Moodle 1.9.x available, and that you have at least one course installed in your Moodle instance.  It also assumes that you have some basic knowledge of PHP and MySQL.

Before we embark on writing our first Moodle module, let's download a template provided by the folks at Moodle.org. In our case, we will be writing our module for Moodle version 1.9.x:

Download Link for The Module Template for Moodle 1.9

We end up with a file called NEWMODULE.zip which we need to save to our local drive and unzip. In my case, I download to the Public folder, unzip the file and end up with .\Public\NEWMODULE.

NEXT ARTICLE IN SERIES

Thursday, May 13, 2010

05MOD: Moodle Module Development - The module's language file

TO START THE TUTORIAL FROM THE BEGINNING, CLICK HERE

When we first set our module up, we simply completed a series of search & replace for the the phrase "NEWMODULE" and replaced them with our Module's name. This is enough to get the Module registered, but it leaves a very ugly footprint in Moodle.

Our goal right now, is to start some cleanup of these references so the user interface of our Module starts to take shape.


1. UPDATE THE .\mod\inyourface\lang\en_utf8\inyourface.php FILE

Inside the Moodle interface, the text that is displayed during the addition of our activity is controlled by the language file. These string variables are contained in the module's language file. Any modifications we make will take effect immediately.

2. !!! IMPORTANT !!! MOVE THE .\mod\lang folder to the Moodle root directory (move it to .\lang). 
If you browse through your Moodle's .\lang directory, you will notice that each module has its own language file.

Here is the contents of the inyourface.php file after a little clean-up.


<?php
    $string['inyourface'] = 'Facebook Integration';
    $string['modulename'] = 'Facebook Integration';
    $string['modulenameplural'] = 'Facebook Integration';
    $string['inyourfacefieldset'] = 'Custom Fields';
    $string['inyourfaceintro'] = 'Post to Facebook Intro';
    $string['inyourfacename'] = 'Post to Facebook';
?>


After making these changes, when you navigate to a course and enter edit mode, you will notice the following changes:

Add Activity Drop Down When Editing a Course:

Click Image to Zoom

The Module's Add Activity Form:


Click Image to Zoom

The Activity Breadcrumb Trail:


Click Image to Zoom

SMALL CHANGES, BIG BANG!

Next Article in Series

2 comments:

  1. hi,
    I need a help.
    I am creating an activity module for moodle. But i am encountering a problem at this step.
    When I am navigating to a course and editing is on, after adding an activity the form is not appearing up. Please help me.

    ReplyDelete
  2. hi,
    I need a help.
    I am creating an activity module for moodle. But i am encountering a problem at this step.
    When I am navigating to a course and editing is on, after adding an activity the form is not appearing up. Please help me.

    ReplyDelete