International Developer Logo Last Updated 19.11.08 at 11.48
 
TUTORIALS

Online Course Management with Moodle


  05.10.06

Building a module

There are many modules included in the default Moodle installation, and you can extend these or build new custom modules quite easily. To create a completely new module, the first step is to download the NEWMODULE template from the Moodle site. This zip archive contains all the generic files and functions required to complete a basic module. To customise this template, it is first necessary to unzip it into the /mod directory of the Moodle installation folder and rename it. For our interactive puzzle module, we’ll rename the NEWMODULE folder to “draganddrop”. Next, we need to create a language file to store the dictionary of terms used by the module. This file must have a name identical to the module folder, followed by the .php file extension. This file has to be included for each supported language in the /lang directory. For now, we’ll just create a draganddrop.php file in the en_utf8 folder inside /lang. The contents of this file are shown here.

 

<?php // $Id: draganddrop.php

$string[‘modulename’] = ‘Drag and Drop’;

$string[‘modulenameplural’] = ‘Drag and Drop Modules’;

$string[‘image’] = ‘Image’;

$string[‘title’] = ‘Title’;

$string[‘answer’] = ‘Correct Answer’;?>

 

Our module requires two database tables to store the relevant data for each instance of the module. One table will store the core module information, and the minimum requirements for this table are specified by the Moodle API. For instance, each module needs a name, a course identifier and a ‘timemodified’ field. We will also use a separate table to store image information used by our module. Using a many-to-one relationship, this second table will store the location of each image for each instance of the module.  The schema for the two tables is as follows:

 

CREATE TABLE `mdl_draganddrop` (

  `id` int(10) unsigned NOT NULL auto_increment,

  `course` int(10) unsigned NOT NULL default ‘0’,

  `name` varchar(255) NOT NULL,

  `title` varchar(255) NOT NULL,

  `answer` varchar(255) NOT NULL,

  `timemodified` int(10) unsigned NOT NULL default ‘0’,

  PRIMARY KEY  (`id`)

) ENGINE=InnoDB DEFAULT CHARSET=utf8;

 

-- --------------------------------------------------------

 

CREATE TABLE `mdl_draganddrop_images` (

  `id` int(11) NOT NULL auto_increment,

  `url` varchar(255) NOT NULL,

  `ddid` int(11) NOT NULL,

  PRIMARY KEY  (`id`)

) ENGINE=InnoDB DEFAULT CHARSET=utf8;




   Previous Page  1 2 3 4 5 6 7 8 9 10 ... Next Page   

HAVE YOUR SAY
This article is rated  Rate this article