Moodle 3.x Developer's Guide
By Ian Wild
()
About this ebook
- 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.
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
Ian Wild
A physicist by profession, Ian's career has always focused primarily on communication and learning. Fifteen years spent in private industry designing communication systems software eventually saw Ian concentrate on the development of accessibility and learning aids for blind, partially sighted, dyslexic, and dyscalculic computer users - whilst also working part-time as a math and science tutor. Teaching only part-time meant not spending as much time with his students as he would have wanted. This and his background in learning and communication technology seeded his interest in virtual learning environments.
Related to Moodle 3.x Developer's Guide
Related ebooks
Moodle Administration Essentials Rating: 5 out of 5 stars5/5Moodle Theme Development Rating: 0 out of 5 stars0 ratingsMoodle Security Rating: 0 out of 5 stars0 ratingsMoodle Gradebook Rating: 0 out of 5 stars0 ratingsMoodle 3.x Teaching Techniques - Third Edition Rating: 0 out of 5 stars0 ratingsLearning Material Design Rating: 4 out of 5 stars4/5Learning Articulate Storyline Rating: 0 out of 5 stars0 ratingsInvestigating Performance: Design and Outcomes With Xapi Rating: 0 out of 5 stars0 ratingsE-learning with Camtasia Studio Rating: 0 out of 5 stars0 ratingsInstant Hands-on Testing with PHPUnit How-to Rating: 0 out of 5 stars0 ratingsMoodle for Mobile Learning Rating: 0 out of 5 stars0 ratingsInstant Moodle Quiz Module How-to Rating: 0 out of 5 stars0 ratingsMastering Articulate Storyline Rating: 0 out of 5 stars0 ratingsMoodle 3 Administration - Third Edition Rating: 0 out of 5 stars0 ratingsMoodle E-Learning Course Development - Third Edition Rating: 0 out of 5 stars0 ratingsResponsive Web Design A Complete Guide - 2020 Edition Rating: 0 out of 5 stars0 ratingsMoodle 1.9 Multimedia Rating: 0 out of 5 stars0 ratingsCreating ELearning Games with Unity Rating: 0 out of 5 stars0 ratingsDigital Growth A Complete Guide - 2019 Edition Rating: 0 out of 5 stars0 ratingsMoodle JavaScript Cookbook Rating: 0 out of 5 stars0 ratingsE-didactics and practices for e-learning Rating: 0 out of 5 stars0 ratingsMastering Adobe Captivate 8 Rating: 5 out of 5 stars5/5STEAM Jobs in Social Media Rating: 0 out of 5 stars0 ratingsiOS Game Programming Cookbook Rating: 0 out of 5 stars0 ratingsGamification Of Learning A Complete Guide - 2020 Edition Rating: 0 out of 5 stars0 ratingsWireframing A Complete Guide - 2021 Edition Rating: 0 out of 5 stars0 ratingsKnowledge Base Complete Self-Assessment Guide Rating: 0 out of 5 stars0 ratingsConstruct Game Development: Beginner’s Guide Rating: 0 out of 5 stars0 ratingsMoodle A Clear and Concise Reference Rating: 0 out of 5 stars0 ratings
Applications & Software For You
Sound Design for Filmmakers: Film School Sound Rating: 5 out of 5 stars5/5Adobe Illustrator: A Complete Course and Compendium of Features Rating: 0 out of 5 stars0 ratingsLearn to Code. Get a Job. The Ultimate Guide to Learning and Getting Hired as a Developer. Rating: 5 out of 5 stars5/5Logic Pro X For Dummies Rating: 0 out of 5 stars0 ratingsSix Figure Blogging In 3 Months Rating: 4 out of 5 stars4/5GarageBand Basics: The Complete Guide to GarageBand: Music Rating: 0 out of 5 stars0 ratingsHow to Create Cpn Numbers the Right way: A Step by Step Guide to Creating cpn Numbers Legally Rating: 4 out of 5 stars4/5GarageBand For Dummies Rating: 5 out of 5 stars5/5ScreenFlow Concepts: Easy Video Editing for Professional Screencasts Rating: 5 out of 5 stars5/5Adobe Photoshop: A Complete Course and Compendium of Features Rating: 5 out of 5 stars5/5Excel : The Ultimate Comprehensive Step-By-Step Guide to the Basics of Excel Programming: 1 Rating: 5 out of 5 stars5/5Mastering ChatGPT Rating: 0 out of 5 stars0 ratingsData Science and Big Data Analytics: Discovering, Analyzing, Visualizing and Presenting Data Rating: 0 out of 5 stars0 ratingsAdobe Premiere Pro: A Complete Course and Compendium of Features Rating: 0 out of 5 stars0 ratingsVocal Rescue: Rediscover the Beauty, Power and Freedom in Your Singing Rating: 4 out of 5 stars4/5Synthesizer Cookbook: How to Use Filters: Sound Design for Beginners, #2 Rating: 3 out of 5 stars3/5Blender 3D Basics Beginner's Guide Second Edition Rating: 5 out of 5 stars5/5iPhone Photography For Dummies Rating: 0 out of 5 stars0 ratingsAdobe Premiere Pro CC: A Tutorial Approach Rating: 5 out of 5 stars5/5The Best Hacking Tricks for Beginners Rating: 4 out of 5 stars4/5The Little SAS Book: A Primer, Sixth Edition Rating: 5 out of 5 stars5/5OneNote Recipes: Elegant Techniques for Problem Solving and Visual Thinking Rating: 5 out of 5 stars5/5Start Your Own Podcast Business: Your Step-By-Step Guide to Success Rating: 5 out of 5 stars5/5Audio Engineering: Know It All Rating: 5 out of 5 stars5/5Mastering QuickBooks 2020: The ultimate guide to bookkeeping and QuickBooks Online Rating: 0 out of 5 stars0 ratingsFL Studio Cookbook Rating: 4 out of 5 stars4/5
Reviews for Moodle 3.x Developer's Guide
0 ratings0 reviews
Book preview
Moodle 3.x Developer's Guide - Ian Wild
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
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 of Science Teaching with 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 service@packtpub.com 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 customerreviews@packtpub.com. 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.
Conventions
In this book, you will find a number of text styles that distinguish between different kinds of information. Here are some examples of these styles and an explanation of their meaning.
Code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles are shown as follows: For example, an administration setting named local_duallang/primarylanguage is accessed by calling get_config('local_duallang', 'primarylanguage').
A block of code is set as follows:
Any command-line input or output is written as follows:
New terms and important words are shown in bold. Words that you see on the screen, for example, in menus or dialog boxes, appear in the text like this: When the learner clicks on the Description button, the client wants a Course information page to be displayed.
Warnings or important notes appear in a box like this.
Tips and tricks appear like this.
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 feedback@packtpub.com, 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