Moodle 3.x Developer's Guide - Ian Wild - E-Book

Moodle 3.x Developer's Guide E-Book

Ian Wild

0,0
41,99 €

-100%
Sammeln Sie Punkte in unserem Gutscheinprogramm und kaufen Sie E-Books und Hörbücher mit bis zu 100% Rabatt.

Mehr erfahren.
Beschreibung

Effortlessly ensure your application's code quality from day 1

About This Book

  • 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.

Who This Book Is 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

In Detail

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.

Style and approach

This book takes a step-by-step practical approach with every step explained in great detail using practical examples. You will create custom plugins from scratch with the examples shown and create new modules as well as extensions with the examples presented.

Sie lesen das E-Book in den Legimi-Apps auf:

Android
iOS
von Legimi
zertifizierten E-Readern

Seitenzahl: 281

Veröffentlichungsjahr: 2017

Bewertungen
0,0
0
0
0
0
0
Mehr Informationen
Mehr Informationen
Legimi prüft nicht, ob Rezensionen von Nutzern stammen, die den betreffenden Titel tatsächlich gekauft oder gelesen/gehört haben. Wir entfernen aber gefälschte Rezensionen.



To Susannah
Moodle 3.x Developer's Guide

 

 

 

 

 

 

 

 

 

Customize your Moodle apps by creating custom plugins, extensions, and modules

 

 

 

 

 

 

 

 

Ian Wild

 

BIRMINGHAM - MUMBAI

< html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">

Moodle 3.x Developer's Guide

 

Copyright © 2017 Packt Publishing

 

All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.

Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, nor Packt Publishing, and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book.

Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.

 

First published: June 2017

 

Production reference: 1270617

 

Published by Packt Publishing Ltd.
Livery Place
35 Livery Street
Birmingham
B3 2PB, UK.

ISBN 978-1-78646-711-9

 

www.packtpub.com

Credits

Author

Ian Wild

Copy Editor

Safis Editing

Reviewer

Susan Smith Nash

Project Coordinator

Ritika Manoj

Commissioning Editor

Amarabha Banerjee

Proofreader

Safis Editing

Acquisition Editor

Reshma Raman

Indexer

Tejal Daruwale Soni

Content Development Editor

Aditi Gour

Graphics

Jason Monteiro

Technical Editor

Shweta Jadhav

Production Coordinator

Melwyn Dsa

 

About the Author

Ian Wild is an experienced software developer, solutions architect, author, and educator with over 20 years' experience in the field of software design and implementation.

Fifteen years working in private industry saw Ian specializing in the design and development of access and learning aids for blind, visually impaired, dyslexic, and dyscalculic computer users, while also working part-time as a tutor and lecturer. Teaching only part-time meant not spending as much time with his students as he would have wished and this, coupled with his background in the development of communication technologies, and seeded his long-time interest in e-learning.

Ian is also, author of Moodle Course Conversion: Beginner's Guide and Moodle Math. He was also technical reviewer ofScience Teachingwith Moodle, Moodle Multimedia and Practical XMPP.

Many more names should go on the cover of this book than just mine. Firstly, many thanks must go again to the team at Packt Publishing for your guidance and support as this book was being produced. Next, thank you to the reviewers - including colleagues, friends and family - who kept me, my ideas and my writing focused and meaningful. As ever, a very big thank you must go to you the reader for taking the time to read this book. My aim is to show not tell. The purpose of this book isn't just to show you how to do things: it is to attempt to give you a grounding in Moodle development, perhaps reveal some interesting ideas, point the way to you, and, hopefully, give you some inspiration. Remember, if you do encounter any issues or you have any more questions do come and join the community. We are there to help you with your Moodle-related issues.

My final thank you must always go to Martin Dougiamas and his team. Thank you, all of you.

About the Reviewer

Susan Smith Nash is involved in the design, development, and administration of e-learning and m-learning programs for learners pursuing degrees, certification, credentialing, and professional development. Her current research interests include the effective design of competency-based education, knowledge management, knowledge transfer, and leadership. Her articles and columns have appeared in magazines and refereed journals. She received her PhD from the University of Oklahoma, and in addition to e-learning, Nash has also been involved in international economic development training, interdisciplinary studies, interdisciplinary petroleum geosciences programs, and sustainable business and career training. Her book, Leadership and the E-Learning Organization, was co-authored with George Henderson, and published by Charles Thomas and Sons. Her most recent books include E-Learning Success: From Courses to Careers, and E-Learner Survival Guide, Texture Press. Her edublog, E-Learning Queen has received numerous awards and recognition's.

www.PacktPub.com

 

For support files and downloads related to your book, please visit www.PacktPub.com.

Did you know that Packt offers eBook versions of every book published, with PDF and ePub files available? You can upgrade to the eBook version at www.PacktPub.com and as a print book customer, you are entitled to a discount on the eBook copy. Get in touch with us at [email protected] for more details.

At www.PacktPub.com, you can also read a collection of free technical articles, sign up for a range of free newsletters and receive exclusive discounts and offers on Packt books and eBooks.

 

 

https://www.packtpub.com/mapt

 

Get the most in-demand software skills with Mapt. Mapt gives you full access to all Packt books and video courses, as well as industry-leading tools to help you plan your personal development and advance your career.

Why subscribe?

Fully searchable across every book published by Packt

Copy and paste, print, and bookmark content

On demand and accessible via a web browser

 

Thanks for purchasing this Packt book. At Packt, quality is at the heart of our editorial process. To help us improve, please leave us an honest review on this book's Amazon page at https://www.amazon.com/Moodle-Developers-Guide-Ian-Wilds/dp/1786467119.

If you'd like to join our team of regular reviewers, you can e-mail us at [email protected]. We award our regular reviewers with free eBooks and videos in exchange for their valuable feedback. Help us be relentless in improving our products!

Table of Contents

Preface

What this book covers

What you need for this book

Who this book is for

Conventions

Reader feedback

Customer support

Downloading the example code

Downloading the color images of this book

Errata

Piracy

Questions

Getting to Grips with the Moodle 3 Architecture

Understanding Moodle

More on Moodle plugins

Running a local Moodle

Moodle architecture - the LAMP/WAMP stack

Installing WampServer

WampServer and Skype

Setting up an Integrated Development Environment (IDE)

Configuring the Eclipse IDE

Configuring remote debugging

Installing and configuring Moodle

Introducing the project

Planning is everything

Agile software development

Version control

Moodle Internals - Application Programming Interfaces (APIs)

An object-oriented philosophy

Types of APIs

Our first plugin - a custom string manager

The user story

The development process

Step 1: Understanding the problem

Step 2: Researching potential solutions

Moodle plugin directory

Moodle community forums

Moodle Tracker

String API

Step 3: Implementing the solution

Standard plugin features

Summary

Moodle Plugins - What Can I Plug In?

Managing users

Authentication

Enrolment

Learner competencies

Managing courses

Course layout

Course content

Resources

Activities

Quiz plugins

Assignment plugins

Where to find course interaction plugins

Other important course plugin types

Blocks

Editor plugins

Text filters

Reporting and analytics

Look and feel

Other major plugin types

What cannot be done with plugins?

Summary

Internal Interfaces

Adding configuration settings

Wireframing

Moodle application layers

Storing configuration data

Creating an admin settings page

Updating the get_string() function

Plugin language strings

System APIs

Events API

Plugin data and services

Form API

File Storage API

Cache API

Output renderers

Summary

Course Management

Course formats

GPS location - background to the project

Obtaining device location

Device location - security issues

Configuring SSL on WampServer

Understanding renderers

Finding a user's location with the Geolocation API

Including JavaScript

Specifying location settings

Displaying sections based on location

Try it yourself

Course blocks

Configuring the QR Code block

Including the QR Code library

Manipulating files with the File API

Serving files from the file store

Try it yourself

Text filters

Subscribing to a text changed event

Try it yourself

Summary

Creative Teaching - Developing Custom Resources and Activities

Teaching interactions

Developing a Resource plugin

Rendering a three-dimensional model

Module configuration

More on file handling

Plugin library callbacks

Rendering the Model

More on JavaScript

Asynchronous Module Definition (AMD) API

Reporting events

Other files

Installation scripts

XMLDB editor

Allowing user comments

More on file handling

Styling

Backup and Restore API

Backup API

Restore API

Roles and permissions

Preparing for release

Minimising JavaScript

Taking things further

Activities

Enhanced choice

Editing choices

Summary

Managing Users - Letting in the Crowds

Authentication

Authentication - general principles

Getting logged in

Single sign on

WordPress to Moodle - SSO options

Calling WordPress code directly

Cookie authentication

Links from WordPress to Moodle

External Web Services APIs

OAuth overview

Installing the WordPress OAuth 1.0a server

Creating a new Moodle auth plugin

Configuration

Handling OAuth calls

Handling the Moodle login event

Taking things further

Course Enrolment

A WordPress course enrolment plugin

Taking things further

Management of Competencies

Creating a new admin tool plugin

Synchronisation settings

Connecting to external databases

Taking things further - Moodle CLI scripts

Summary

Creating a Dashboard - Developing a Learner Homepage

The client's requirement

Addicted to learning

Course progress block

Including graphics libraries

JavaScript Object Notation (JSON)

Converting progress data to JSON

Constructing a progress chart

Creating a chart

Making the chart clickable

Taking things further

Dashboard progress overview

Taking things further

Encouraging learners to start a course

Implementing a new course availability block

Determining progress

Creating the Description page

Taking things further

Summary

Creating a New Skin

Theme plugin structure

Page layout

Theme library functions

Taking things further - updating the theme screen grab

Renderers

Creating a plugin renderer

Overriding a component renderer

Custom styling

Including images in CSS

Taking things further - styling button icons

Page layouts

Taking things further - doing more with page layouts

Templates

Mustache

Overriding templates in a theme

Theme responsiveness

Summary

Moodle Analytics

Reporting

Report plugin structure

Grabbing data

Reporting learner success

Determining certificates issued

EXPLAIN a query

Saving data

Creating spreadsheets

Taking things further

Displaying activity data - a bubble chart example

Accessing the report

Building the block

Extracting the data

Including D3.js libraries

Rendering a bubble chart

Further improvements

Web Services

Developing a new external API

A hello world API

Building a new API

Encrypting data

Decrypting data in PHP

Decrypting data in C#

Summary

Appendix

Testing

PHPUnit

Behat

Describing a scenario

Step definitions

Moodle guidelines

General guidelines

Describing functions and methods

Whitespaces and indentation

Configuring Eclipse indentation

SQL query coding style

The code checking tool

C# client

Installing Visual Studio

Creating a new project

Creating a test harness

Connecting to an XML-RPC API

Decrypting data

Decompressing data

Final testing

Source control with GitHub

Installing Git

Configuring SSH

Committing changes

Atomised commits

Preface

For any organization that's considering implementing an online learning environment, Moodle is often the number one choice. Key to its success is the free, open source ethos that underpins it. Not only is the Moodle source code fully available to developers, but Moodle itself has been developed to allow the inclusion of third-party plugins. Everything from how users access the platform and the kinds of teaching interactions that are available through to how attendance and success can be reported--in fact, all the key Moodle functionalities--can be adapted and enhanced through plugins.

Using real-world examples, this book will show you how to enhance a default Moodle installation with novel plugins to authenticate and enroll users on to courses, new and interesting teaching interactions, new custom skins, and enhanced course layouts.

Obviously, a book of this length won't be able to cover every single plugin type, but by the end of Chapter 9, Moodle Analytics, you will have a thorough grounding in Moodle plugin structure, a detailed understanding of how plugins should interact with Moodle's internal Application Programming Interfaces (APIs), and plenty of great ideas to help you enhance your Moodle installation with new, custom plugins. If you have developed a plugin you feel would be useful to the Moodle community, you should certainly consider submitting it to the Moodle Plugins Directory at https://moodle.org/plugins/.

What this book covers

Chapter 1, Getting to Grips with the Moodle 3 Architecture, introduces the ethos of the Moodle project and how it has influenced the internal architecture. We prepare ourselves for plugin development by installing the tools we need.

Chapter 2, Moodle plugins - What Can I Plug In?, investigates the main plugin types, such as those dealing with users and how they access the platform. Also, it covers plugins that provide the learning interactions that users experience when they take a course. We also looks at the less obvious plugins, such as filters.

Chapter 3, Internal Interfaces, shows the different types of application programming interfaces (APIs) Moodle provides to support plugin development.

Chapter 4, Course Management, demonstrates how courses can be enhanced through the development of novel course formats. We see how plugins can be used to modify course structure and, by so doing, enhance teaching.

Chapter 5, Creative TeachingDeveloping Custom Resources and Activities, shows that there are two types of teaching interaction: resources and activities. Both of these are types of course module plugin. In this chapter, you will learn how Moodle course plugins work, which scripts need to be present in order for your plugin to behave correctly, and how to modify course plugins to fit your needs.

Chapter 6, Managing Users - Letting in the Crowds, explores how plugins can manage users in a variety of different contexts. We develop two novel plugins, one to authenticate users against an external WordPress site using OAuth, and another to automatically enroll users onto courses when they connect to Moodle via WordPress.

Chapter 7, Creating a Dashboard - Developing a Learner Homepage, teaches us how plugins can be used to create an enhanced learner homepage. Gamification is all about using the same tricks and techniques employed by game developers to entice learners into progressing with courses. In this chapter, we learn how plugins can be developed to promote similar techniques.

Chapter 8, Creating a New Skin, focuses on aesthetics after we have concerned ourselves with functionality. We investigate how Moodle can be rebranded through theme plugins, with a particular focus on support for mobile and tablet devices.

Chapter 9, Moodle Analytics, showcases how to develop plugins to monitor and analyze learner behavior. We learn how to extract data efficiently, how to judge the effectiveness of that extraction, and the various means by which data can be reported, including via a secure external interface.

What you need for this book

You will need a computer suitable for software development, one that can run a web server and a separate development environment (Chapter 1, Getting to Grips with the Moodle 3 Architecture, guides the reader through the necessary configuration steps). This book is aimed at developers, so it is assumed that you will be able to install Moodle with minimum fuss. If you need more information on Moodle administration, check out Moodle Administration, also available from Packt (visit https://www.packtpub.com/hardware-and-creative/moodle-3-administration-third-edition for details).

Who this book is for

This book is for Moodle developers who are familiar with the basic Moodle functionalities 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 and should be familiar with the HTML and XML protocols. You do not need to have prior knowledge of Moodle-specific terminology.

Reader feedback

Feedback from our readers is always welcome. Let us know what you think about this book--what you liked or disliked. Reader feedback is important for us as it helps us develop titles that you will really get the most out of.

To send us general feedback, simply e-mail [email protected], and mention the book's title in the subject of your message.

If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide at www.packtpub.com/authors.

Customer support

Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.

Downloading the example code

You can download the example code files for this book from your account at http://www.packtpub.com. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.

You can download the code files by following these steps:

Log in or register to our website using your e-mail address and password.

Hover the mouse pointer on the

SUPPORT

tab at the top.

Click on

Code Downloads & Errata

.

Enter the name of the book in the

Search

box.

Select the book for which you're looking to download the code files.

Choose from the drop-down menu where you purchased this book from.

Click on

Code Download

.

Once the file is downloaded, please make sure that you unzip or extract the folder using the latest version of:

WinRAR / 7-Zip for Windows

Zipeg / iZip / UnRarX for Mac

7-Zip / PeaZip for Linux

The code bundle for the book is also hosted on GitHub at https://github.com/PacktPublishing/Moodle-3-Developer's-Guide. We also have other code bundles from our rich catalog of books and videos available at https://github.com/PacktPublishing/. Check them out!

Downloading the color images of this book

We also provide you with a PDF file that has color images of the screenshots/diagrams used in this book. The color images will help you better understand the changes in the output. You can download this file from https://www.packtpub.com/sites/default/files/downloads/Moodle3.xDevelopersGuide_ColorImages.pdf.

Errata

Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books-maybe a mistake in the text or the code-we would be grateful if you could report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/submit-errata, selecting your book, clicking on the Errata Submission Form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded to our website or added to any list of existing errata under the Errata section of that title.

To view the previously submitted errata, go to https://www.packtpub.com/books/content/support and enter the name of the book in the search field. The required information will appear under the Errata section.

Piracy

Piracy of copyrighted material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works in any form on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.

Please contact us at [email protected] with a link to the suspected pirated material.

We appreciate your help in protecting our authors and our ability to bring you valuable content.

Questions

If you have a problem with any aspect of this book, you can contact us at [email protected], and we will do our best to address the problem.

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:

Open Skype and click on the

Tools

menu option and slide down to

Options...

.

Select

Advanced

and then click on

Connection

.

Uncheck the

Use port 80 and 443 as alternatives for incoming connections

option and press

S

ave

.

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

Once installed, there are a number of recommended configuration preferences to change, and these are outlined in the Moodle developer documentation at https://docs.moodle.org/dev/Setting_up_Eclipse#Setting_the_preferences_for_Moodle_development.

Once the development environment is configured, we need to consider how we will debug any code we write. For that, we need to set up and configure remote debugging, which we discuss next.

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 usingXdebug helper. Check outhttps://github.com/mac-cain13/xdebug-helper-for-chromefor 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