Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds
Moodle 3.x Developer's Guide
Moodle 3.x Developer's Guide

Moodle 3.x Developer's Guide: Build custom plugins, extensions, modules and more

Arrow left icon
Profile Icon Wild Profile Icon Jaswant Tak
Arrow right icon
€18.99 per month
Full star icon Full star icon Full star icon Full star icon Half star icon 4.5 (2 Ratings)
Paperback Jun 2017 368 pages 1st Edition
eBook
€26.98 €29.99
Paperback
€36.99
Subscription
Free Trial
Renews at €18.99p/m
Arrow left icon
Profile Icon Wild Profile Icon Jaswant Tak
Arrow right icon
€18.99 per month
Full star icon Full star icon Full star icon Full star icon Half star icon 4.5 (2 Ratings)
Paperback Jun 2017 368 pages 1st Edition
eBook
€26.98 €29.99
Paperback
€36.99
Subscription
Free Trial
Renews at €18.99p/m
eBook
€26.98 €29.99
Paperback
€36.99
Subscription
Free Trial
Renews at €18.99p/m

What do you get with a Packt Subscription?

Free for first 7 days. $19.99 p/m after that. Cancel any time!
Product feature icon Unlimited ad-free access to the largest independent learning library in tech. Access this title and thousands more!
Product feature icon 50+ new titles added per month, including many first-to-market concepts and exclusive early access to books as they are being written.
Product feature icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Product feature icon Thousands of reference materials covering every tech concept you need to stay up to date.
Subscribe now
View plans & pricing
Table of content icon View table of contents Preview book icon Preview Book

Moodle 3.x Developer's Guide

Getting to Grips with the Moodle 3 Architecture

Have you ever experienced the frustration of being held back by technology? Perhaps you or your colleagues have wanted to teach something in a particular way and have found that your Virtual Learning Environment (VLE) doesn't support the feature you really needed. Maybe you are a learning manager, and you need to report on the numbers of learners from a particular postcode who have completed specific courses because this data is critical to ensuring continued funding. How many times have you held conversations about your VLE that began with "Wouldn't it be great if our learning platform could allow a learner/a manager to... ?".

The purpose of this book is to show you, through real-world examples, the details of plugin design and development. However, the key to plugin wisdom is understanding the Moodle architecture and, for that, you will need to understand Moodle itself. This chapter forms a general introduction to the Moodle philosophy, Moodle history, and the Moodle community.

In this chapter, we will also learn what a Moodle plugin is, what can be achieved with plugins, and cover not only how your plugins will actually plug in to Moodle but also what functionality Moodle can provide to your plugin (through dedicated application programming interfaces that your plugin can call upon).

This chapter will also help you set up your development environment ready to start developing. We will show you how to install and configure a local web server, the Eclipse IDE, and the Chrome Xdebug plugin for remote script debugging.

By the end of this chapter, you will be able to do the following:

  • Understand the importance of Application Programming Interfaces (APIs), both generally and in the context of Moodle plugin development
  • Be able to configure Moodle on a local development computer (for example, your personal laptop)
  • Be able to configure an integrated development environment, ready to start creating your first Moodle plugin

The final part of this chapter sees us walking through the process of creating our very first Moodle plugin--a language-switching plugin to support a UK/China joint venture. We won't go into the details of how plugins operate at this stage (that will be covered in the rest of the book), but you will get an appreciation of just a few of the decisions that must be made before and during the development process.

Let's begin our journey by exploring the background of the Moodle project a little.

Understanding Moodle

There are three reasons Moodle has become so important and much talked about in the world of online learning (refer to The Campus Computing Project at http://www.campuscomputing.net / new.html): one technical, one philosophical, and the third educational.

From a technical standpoint, Moodle--an acronym for Modular Object-Oriented Dynamic Learning Environment (Moodle)--is highly customizable. As a Moodle developer, always remember that the "M" in Moodle stands for modular. If you are faced with a client feature request that demands a feature Moodle doesn't support, don't panic. The answer is simple--we create a new custom plugin to implement it. Check out the Moodle plugins directory (https://moodle.org/plugins/) for a comprehensive library of supported third-party plugins that Moodle developers have created and given back to the community. This leads to the philosophical reason why Moodle dominates.

Moodle is, from a philosophical perspective, grounded firmly in a community-based, open source ethos (check out https://en.wikipedia.org/wiki/Open-source_model). However, what does this mean for us as developers? Fundamentally, it means that we have complete access to the source code, and within reason, unfettered access to the people who develop it. Access to the application itself is free--you don't need to pay to download it, and you don't need to pay to run it. However, be aware of what free means. Hosting and administration, for example, take time and resources are very unlikely to be free.

You will very often hear beer talked about in the context of free software (and I have purposefully stressed the word free): free software means free as in freedom, not free as in beer. Possibly, a better way of stating the case is to say that the Moodle developers in general--and Martin Dougiamas, the creator of Moodle, in particular--have given us freedom to do what we must. What we have not been granted is license to do what we want. Note that, again and like the beer example, this isn't quite the same as gratis (free of price) and libre (free of restriction--refer to https://en.wikipedia.org/wiki/Gratis_versus_libre). As Moodle developers, we are bound by the duties specified in the free Software Foundation's GPLv3 license (check out http://www.gnu.org/licenses/gpl-3.0.txt), and it is worth having an appreciation of these duties before you start developing.

Finally, as an educational tool, Moodle was developed to support social constructionism (refer to https://docs.moodle.org/31/en/Pedagogy); if you are not familiar with this concept, it is essentially suggesting that building an understanding of a concept or idea can be best achieved by interacting with a broad community. The impact on us as Moodle plugin developers is that there is a highly active group of users and developers. Before you begin developing any Moodle plugins, come and join us at https://moodle.org/mod/forum/?id=5.

More on Moodle plugins

As briefly described earlier, if we are faced with a need to enhance or alter the functionality of Moodle in some way, then the prescribed approach is to create a plugin. Refer to https://docs.moodle.org/dev/Moodle_architecture#Moodle_as_a_modular_system for a further description of Moodle's modular architecture. The https://docs.moodle.org/dev/Moodle_architecture page is also a good reference for learning about the basic plugin types and where these plugin types are to be found in the application folder structure.

In the following sections, we will set ourselves up ready to start developing our own plugins. First, we need to learn how to run a Moodle on our development computers.

Running a local Moodle

Moodle is a web application; so, you will need a web server in order to run it. In this section, we will be configuring a local development server that can run on your local machine.

Moodle architecture - the LAMP/WAMP stack

Moodle is a web application running typically (but not exclusively) in a web browser. A Moodle user interacts with a user interface on a client computer. The client requests resources from the application server (generally known as middleware) that provides the requested resources. It can do so by calling on another server, known as the data server. The data server provides the application server with the data it requires:

Check out https://en.wikipedia.org/wiki/LAMP_(software_bundle) for more information on the stack.

Generally, this architecture is referred to either as a WAMP stack or LAMP stack, the W or L referring to Windows or Linux, depending on the operating system you are running. A is for the web server Apache, M for the database server MySQL, and P for PHP, the scripting language Moodle is authored in. It should be noted that other web servers and databases are available and Moodle will run quite happily on them; refer to the online Moodle documentation.

Setting up an Internet ready Moodle server is beyond the scope of this book--see Moodle 3.0 Administration, also from Packt, for details. Instead, we will install a local web server running on Windows, using WampServer.

Installing WampServer

The WampServer development stack can be downloaded from http://www.wampserver.com/en/. Ensure that you download either the 32-bit or 64-bit version to suit your computer. Also, ensure that you run the install with Administrator privileges as both Apache and MySQL run as Windows services and the installer will require elevated privileges to install these. Once installed and running, the WampServer icon will be visible in the taskbar--green means everything is operating as it should and your local web server is up and running:

WampServer and Skype

Do you use Skype on your development machine? If so, you will likely experience a configuration conflict between the Apache instance in WampServer and Skype as Apache attempts to use ports 80 (for HTTP) and 443 (for HTTPS) to display web pages. By default, Skype is configured to use both these ports as alternatives for data transfer, so you will need to reconfigure Skype accordingly:

  1. Open Skype and click on the Tools menu option and slide down to Options....
  2. Select Advanced and then click on Connection.
  3. Uncheck the Use port 80 and 443 as alternatives for incoming connections option and press Save.
  4. Restart Skype.

Setting up an Integrated Development Environment (IDE)

As discussed earlier, the Moodle application consists of a great number of text scripts that can, in practice as well as theory, be edited with any simple text editor. However, you will be far better off using an integrated development environment for your development. An IDE will contain tools for code completion and code insight; for example, if you have forgotten the name of a class method, or if you need quick access to a function declaration, or the instances where a variable is used.

Perhaps more importantly, IDEs contain integrated debugging tools that allow you to step through the code as it runs (more on this later). The examples in this book use a special PHP version of the Eclipse IDE called Eclipse PDT, which can be downloaded from http://www.eclipse.org/pdt/.

Configuring the Eclipse IDE

Configuring remote debugging

We will use the Chrome browser for development using the integrated JavaScript, CSS, and HTML debugging tools. To debug PHP scripts, we will need to install and configure a PHP remote debugger. The debugger we will use is called Xdebug--https://xdebug.org/index.php. Xdebug needs to be installed and configured in three places:

  • The web server (Apache running our local development server)
  • The development environment (Eclipse)
  • The browser (Chrome)

The first step is to configure Xdebug in Apache. In order to determine which version of Xdebug is required, you will need to obtain a copy of the full output from phpinfo()--refer to http://php.net/manual/en/function.phpinfo.php--and paste that into https://xdebug.org/wizard.php, as follows:

Press the Analyse my phpinfo() output button at the bottom of the page for instructions on how to download and configure Xdebug.

Next, we need to configure Xdebug in the IDE. Instructions are available in the Eclipse documentation at https://wiki.eclipse.org/Debugging_using_XDebug.

Finally, we need to install an Xdebug plugin into the browser. For Chrome, we will be using Xdebug helper. Check out https://github.com/mac-cain13/xdebug-helper-for-chrome for details, but the helper itself is easily installed through the Chrome Web Store (you can find relevant links on the GitHub page).

Installing and configuring Moodle

Where should we install our development Moodle? It is always easier to debug an application that is running on the same (local) machine as your integrated development environment, although the PHP debugging tools described in this book also support remote debugging. If it's a separate development server (and not your local machine) you are working with, be sure to check out the guidance on how to configure remote debugging online as this can be tricky to set up. Each remote setup is different, so there is no definitive guide. The Eclipse forums are a great place to look for help, for example, http://www.eclipse.org/forums/index.php/mv/msg/365474/890896/#msg_890896.

The latest version of Moodle can be downloaded from https://download.moodle.org/. Download the latest version and unpack in the www directory created by WampServer. Before running the installation, you will need to follow the setting up instructions at https://docs.moodle.org/31/en/Windows_installation_using_XAMPP. Note that these instructions are for XAMPP, an alternative web server based on LAMP (https://www.apachefriends.org/download.html), but the principles of configuring Moodle running on WampServer are exactly the same. Before you install Moodle, ensure that the required PHP modules are installed and enabled (refer to https://docs.moodle.org/31/en/PHP for details) as failure to do so can result in you experiencing almost impossible to debug blank pages during the installation process.

Left arrow icon Right arrow icon
Download code icon Download Code

Key benefits

  • Customize your Moodle 3.x app.
  • Leverage the new features of Moodle 3.x by diving deep into the Moodle development eco-system.
  • Cater to heavy user traffic, customize learning requirements and create custom third party plugins.

Description

The new and revamped Moodle is the top choice for developers to create cutting edge e-learning apps that cater to different user’s segments and are visually appealing as well. This book explains how the Moodle 3.x platform provides a framework that allows developers to create a customized e-learning solution. It begins with an exploration of the different types of plugin.. We then continue with an investigation of creating new courses. You will create a custom plugin that pulls in resources from a third-party repository. Then you’ll learn how users can be assigned to courses and granted the necessary permissions. Furthermore, you will develop a custom user home. At the end of the book, we’ll discuss the Web Services API to fully automate Moodle 3.x in real time.

Who is this book for?

This book is for Moodle developers who are familiar with the basic Moodle functionality and have an understanding of the types of scenarios in which the Moodle platform can be usefully employed. You must have medium-level PHP programming knowledge. You should be familiar with HTML and XML protocols. You do not need to have prior knowledge of Moodle-specific terminology

What you will learn

  • • Work with the different types of custom modules that can be written for Moodle 3.x
  • • Understand how to author custom modules so they conform to the agreed Moodle 3.x development guidelines
  • • Get familiar with the Moodle 3.x architecture—its internal and external APIs
  • • Customize Moodle 3.x so it can integrate seamlessly with third-party applications of any kind
  • • Build a new course format to specify the layout of a course
  • • Implement third-party graphics libraries in your plugins
  • • Build plugins that can be themed easily
  • • Provide custom APIs that will provide the means to automate Moodle 3 in real time

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : Jun 29, 2017
Length: 368 pages
Edition : 1st
Language : English
ISBN-13 : 9781786467119
Languages :
Tools :

What do you get with a Packt Subscription?

Free for first 7 days. $19.99 p/m after that. Cancel any time!
Product feature icon Unlimited ad-free access to the largest independent learning library in tech. Access this title and thousands more!
Product feature icon 50+ new titles added per month, including many first-to-market concepts and exclusive early access to books as they are being written.
Product feature icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Product feature icon Thousands of reference materials covering every tech concept you need to stay up to date.
Subscribe now
View plans & pricing

Product Details

Publication date : Jun 29, 2017
Length: 368 pages
Edition : 1st
Language : English
ISBN-13 : 9781786467119
Languages :
Tools :

Packt Subscriptions

See our plans and pricing
Modal Close icon
€18.99 billed monthly
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Simple pricing, no contract
€189.99 billed annually
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just €5 each
Feature tick icon Exclusive print discounts
€264.99 billed in 18 months
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just €5 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total 115.97
Moodle 3.x Developer's Guide
€36.99
Moodle 3 Administration, Third Edition
€41.99
Moodle Theme Development
€36.99
Total 115.97 Stars icon

Table of Contents

9 Chapters
Getting to Grips with the Moodle 3 Architecture Chevron down icon Chevron up icon
Moodle Plugins - What Can I Plug In? Chevron down icon Chevron up icon
Internal Interfaces Chevron down icon Chevron up icon
Course Management Chevron down icon Chevron up icon
Creative Teaching - Developing Custom Resources and Activities Chevron down icon Chevron up icon
Managing Users - Letting in the Crowds Chevron down icon Chevron up icon
Creating a Dashboard - Developing a Learner Homepage Chevron down icon Chevron up icon
Creating a New Skin Chevron down icon Chevron up icon
Moodle Analytics Chevron down icon Chevron up icon

Customer reviews

Rating distribution
Full star icon Full star icon Full star icon Full star icon Half star icon 4.5
(2 Ratings)
5 star 50%
4 star 50%
3 star 0%
2 star 0%
1 star 0%
Michael Ford Aug 23, 2017
Full star icon Full star icon Full star icon Full star icon Full star icon 5
A guide to Moodle development is long overdue but the author has nailed it! I found the book well-written, thorough and very practical. The author's technical and educational expertise shine through and he's generous with insights not easily found on Moodle docs. In fact, the book has many parallels to Moodle as a learning platform, offering collaborative learning experiences while pulling together useful resources where required.The first chapter is about setting up. We're given a brief explanation of how to set up the development environment, an introduction to agile software methodology, to object orientated programming and to Moodle itself. Once prepared, we’re given our first client requirements and we’re then guided through the research, development and implementation of a working solution.Going through the book, the requirements get increasingly more complex and the explanations more detailed. In each case, we end up with a working solution as well as suggestions on how this might be further developed. I found the customised authentication plugin and the learning analytics particularly relevant. However, as the author also uses these projects to give us a thorough tour of Moodle functionality, there'll be something here for almost everybody.On the resources side, links to further reading are offered throughout the book, and the appendix is particularly worth checking - Behat, unit testing, coding standards, XML-RPC, encryption, compression, and GIT among other topics.Finally, the author's enthusiasm is infectious. I haven't coded for a while but I've been inspired. This is a book worth making space for.
Amazon Verified review Amazon
Client d'Amazon Apr 26, 2018
Full star icon Full star icon Full star icon Full star icon Empty star icon 4
Dès le premier chapitre, le livre est intéressant et vous permet de mieux comprendre l'outil et sa structure.Et d'être productif. Après une journée on est capable de réaliser des plug-ins... je dis chapeaux l'auteur.
Amazon Verified review Amazon
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

What is included in a Packt subscription? Chevron down icon Chevron up icon

A subscription provides you with full access to view all Packt and licnesed content online, this includes exclusive access to Early Access titles. Depending on the tier chosen you can also earn credits and discounts to use for owning content

How can I cancel my subscription? Chevron down icon Chevron up icon

To cancel your subscription with us simply go to the account page - found in the top right of the page or at https://subscription.packtpub.com/my-account/subscription - From here you will see the ‘cancel subscription’ button in the grey box with your subscription information in.

What are credits? Chevron down icon Chevron up icon

Credits can be earned from reading 40 section of any title within the payment cycle - a month starting from the day of subscription payment. You also earn a Credit every month if you subscribe to our annual or 18 month plans. Credits can be used to buy books DRM free, the same way that you would pay for a book. Your credits can be found in the subscription homepage - subscription.packtpub.com - clicking on ‘the my’ library dropdown and selecting ‘credits’.

What happens if an Early Access Course is cancelled? Chevron down icon Chevron up icon

Projects are rarely cancelled, but sometimes it's unavoidable. If an Early Access course is cancelled or excessively delayed, you can exchange your purchase for another course. For further details, please contact us here.

Where can I send feedback about an Early Access title? Chevron down icon Chevron up icon

If you have any feedback about the product you're reading, or Early Access in general, then please fill out a contact form here and we'll make sure the feedback gets to the right team. 

Can I download the code files for Early Access titles? Chevron down icon Chevron up icon

We try to ensure that all books in Early Access have code available to use, download, and fork on GitHub. This helps us be more agile in the development of the book, and helps keep the often changing code base of new versions and new technologies as up to date as possible. Unfortunately, however, there will be rare cases when it is not possible for us to have downloadable code samples available until publication.

When we publish the book, the code files will also be available to download from the Packt website.

How accurate is the publication date? Chevron down icon Chevron up icon

The publication date is as accurate as we can be at any point in the project. Unfortunately, delays can happen. Often those delays are out of our control, such as changes to the technology code base or delays in the tech release. We do our best to give you an accurate estimate of the publication date at any given time, and as more chapters are delivered, the more accurate the delivery date will become.

How will I know when new chapters are ready? Chevron down icon Chevron up icon

We'll let you know every time there has been an update to a course that you've bought in Early Access. You'll get an email to let you know there has been a new chapter, or a change to a previous chapter. The new chapters are automatically added to your account, so you can also check back there any time you're ready and download or read them online.

I am a Packt subscriber, do I get Early Access? Chevron down icon Chevron up icon

Yes, all Early Access content is fully available through your subscription. You will need to have a paid for or active trial subscription in order to access all titles.

How is Early Access delivered? Chevron down icon Chevron up icon

Early Access is currently only available as a PDF or through our online reader. As we make changes or add new chapters, the files in your Packt account will be updated so you can download them again or view them online immediately.

How do I buy Early Access content? Chevron down icon Chevron up icon

Early Access is a way of us getting our content to you quicker, but the method of buying the Early Access course is still the same. Just find the course you want to buy, go through the check-out steps, and you’ll get a confirmation email from us with information and a link to the relevant Early Access courses.

What is Early Access? Chevron down icon Chevron up icon

Keeping up to date with the latest technology is difficult; new versions, new frameworks, new techniques. This feature gives you a head-start to our content, as it's being created. With Early Access you'll receive each chapter as it's written, and get regular updates throughout the product's development, as well as the final course as soon as it's ready.We created Early Access as a means of giving you the information you need, as soon as it's available. As we go through the process of developing a course, 99% of it can be ready but we can't publish until that last 1% falls in to place. Early Access helps to unlock the potential of our content early, to help you start your learning when you need it most. You not only get access to every chapter as it's delivered, edited, and updated, but you'll also get the finalized, DRM-free product to download in any format you want when it's published. As a member of Packt, you'll also be eligible for our exclusive offers, including a free course every day, and discounts on new and popular titles.