A discussion of open source eLearning tools covering Moodle, Alfresco, Mahara, and Kaltura amongst other technologies. Posts range from interesting anecdotes and adventures, to practical tips, to big picture discussions of trends and learning theory.
Configurable Reports is a popular plugin for Moodle that allows administrators to create custom reports for Moodle and make them available to their end users. In working with this plugin I have noticed that it can be difficult to track down all the variables and filters you can use in creating reports. Below are a list of all of the options.
Variables
%%CATEGORYID%%
%%COURSEID%%
%%CURRENTUSER%%
%%DEBUG%%
%%FILTER_VAR%%
%%STARTTIME%%','%%ENDTIME%%
%%USERID%%
%%WWWROOT%%
Filters
%%FILTER_CATEGORIES:
%%FILTER_COURSEMODULEID:
%%FILTER_COURSEMODULEFIELDS:
%%FILTER_COURSEMODULE:
%%FILTER_COURSES:
%%FILTER_COURSEENROLLEDSTUDENTS:
%%FILTER_USERS:
%%FILTER_ROLE:
%%FILTER_SEARCHTEXT:
%%FILTER_SEMESTER:
%%FILTER_STARTTIME:
%%FILTER_ENDTIME:
%%FILTER_SUBCATEGORIES:
%%FILTER_COURSEUSER:
%%FILTER_SYSTEMUSER:
%%FILTER_YEARHEBREW:
%%FILTER_YEARNUMERIC:
Using Variables
Variables can be used anywhere inside of your SQL query.
Using Filters
When using a filter you need at least one static WHERE condition then you list one or more filters. For example
You can technically add multiple filters, but once a user applies one filter to a report all filters for report are applied. So it can be a little tricky to have multiple filters on the same report. For example if you add a course and date filter to a report, then if you just want to filter by course you have to make sure your date filters are set to date range that covers all courses.
Many of the filters are hard code to be drop down menus which are sorted by database id number instead of alphabetically. This can be problematic if you have a large number of users, courses, or categories. However, you can use one search text filter per report, which can be used to work around the issue in some cases.
Many filters require a logical operator to specify how the filter works. For example
Moodle, as of the version 2 release, includes a built-in Web Services (WS) API that supports a variety of WS protocols including SOAP, REST, and XML-RPC. Since the API is built-in it's generally available whether the site is self-hosted or commercially hosted. The API is easily extensible to add greater functionality. The API provides a single standard method for WS for Moodle simplifying what was a more complex patchwork of third-party solutions.
The Bad
In my experience with LMS development, WS libraries are typically used to provide realtime integrations between specialized third-party software such as a student management system or a content repository. The core Moodle WS library is poorly suited to this use case because it doesn't provide functions to find specific objects in the Moodle database using an arbitrary matching field. This is an unfortunate oversight given Moodle's otherwise excellent support for this methodology with its consistent use of the ID Number field throughout its system. Without being able to do these targeted matches against a value known by the third-party software, one has to rely on function calls to get the entire list of objects (example full user list). This is simply impractical from a performance perspective for any realtime system of scale.
We ran across this problem during a recent project creating an integration between a membership portal and a Moodle 2.7 site.
Using the extensible nature of the WS API, we created a local plugin to allow clean and easy installation of our additions. We based the new calls on the conceptual solution posted by Craig. Many thanks to Craig for his contribution.
You can download a copy of the eLC WS library from git at
Be aware this was an emergency solution that to date has only been used on one Moodle site. As always with contributed code you should test for your particular use case. Please share your experiences with the code if you decide to try it and whether there are any improvements you would like to see.
This solution only really deals with allowing enrollment of a user into a course without knowing the users internal database ID number. Additional functions are needed to fully address the issue across all aspects of the API. As we do more WS related projects we plan to add additional functions.
Mod_deflate is an Apache web server module that uses compression to reduce the bandwidth needed to send web pages between the server and the end user's computer.
See http://httpd.apache.org/docs/2.4/mod/mod_deflate.html
Modern web applications such as Moodle send a lot of text from HTML code, to CSS styles, to javascript, all of which can achieve high compression rates.
So how does reducing bandwidth usage make your website faster? It's actually a bit of a trick. The website itself probably isn't really faster in terms of the number of users or pages it has the capacity to generate. Each page probably will take about the same build time as before on the server. In fact if your server's undersized in terms of CPU resources it might even reduce the server's overall capacity. But for the end user the perceived responsiveness of the website is significantly increased. This is because it takes a lot less time for the page to be transported from the server to the user's computer. This can have a significant impact on user satisfaction and is relatively easy to setup for knowledgable administrators. On a recent engagement, I actually saw a 2-3 second improvement in page load times for the end user, even while accessing from the local campus network. Needless to say the Moodle administrator for this site was very happy with the improvement and you will be too!
This week I am going to talk about a method to enable course completions en-masse across a library of existing Moodle courses.
Stupid Moodle Tricks!
This is my pet name for these little tips, #stupidmoodletrick anyone? Think Letterman's stupid human tricks (video below). These are generally one-off tips, tricks, hacks to manipulate Moodle, generally as a time saver or to accomplish something Moodle isn't generally known to do.
So last week, a client asked me if I could help save them some time in converting some old Moodle 1.9 courses. Actually the more honest version is my lovely and dear wife, Michelle, volunteered that I could totally save the client hours of work by "changing a few database settings." And it turned out she was right!
The following assumes you a have already enabled course completion tracking in your site administration settings. Be aware all of these changes are accomplished by running the below queries directly on your Moodle database. As always when making these sort of changes, be sure you have a good backup and that you know how to recover it to make a working site. Things can and do go wrong and in unexpected ways. I also recommend you use a test site first to become familiar with the technique.
This method was tested on Moodle version 2.7.1+, and 2.7.2+. As with any method that directly interacts with the Moodle database, things almost certainly will change with new versions. It probably will also work with older Moodle 2 versions, but again test first.
Enable course completions on all courses
First we need to enable completion tracking for all courses.
update mdl_course set enablecompletion = 1 where 1;
Turn on activity completion for all course modules (ie activities and resources)
This query enables the setting for all course modules across the site. It sets 'Completion Tracking' to 'Show activity as completed when conditions are met.' It also sets 'Require view' as the criteria, as illustrated in the screenshot below.
update mdl_course_modules set completion = 2, completionview = 1 where 1;
In contrast, if you wanted to set the activity completion to be marked manually by the student, you would run the following query instead.
update mdl_course_modules set completion = 1 where 1;
Which results in the following settings
Limiting which type of modules are set
Let's say we only want to enable completion tracking for all quiz modules. We would first need to have a look at the mdl_modules table and find the id assigned to the quiz module. We can use the following query.
SELECT * from mdl_modules;
Results from my test site are shown below.
We can see that the quiz module id is set to 25. Be aware this will be different for different sites. For example, I tried this on another test site and the quiz id was set to 16.
So now we can create a query to only modify quiz modules.
update mdl_course_modules set completion = 2, completionview = 1 where module=25;
Turn on grade required completion element for all quiz modules
The completion grade requirement is stored by setting a value of 0 in the completiongradeitemnumber field. Knowing this we can set the value and combined with the where clause above to limit to only quizzes. This can be a very useful technique since many compliance courses will use a quiz grade as their completion criteria.
update mdl_course_modules set completiongradeitemnumber=0 where module=25;
Note that this method only changes the setting to require a grade. It doesn't require a specific grade which need additional manual setup in the Moodle grade book. I think setting a specific grade is considerably less trivial. Let me know in the comments if you have a query / method to do this.
The overall result of applying this technique for the requesting client was to save 800 course setting edits, and about 2,500 activity setting edits which probably would have taken several days to a week to do manually.
A note about method
When developing a #stupidmoodletrick, I use a throw away test site. I usually just use the Moodle all-in-one installer to create the site. I then setup the test site with whatever test users / courses, and settings which are needed for the scenario. I then have a look at the database. The all-in-one installer includes phpMyAdmin which is an easy way to have a look at the database structure in a graphical environment. Moodle is good about using descriptive names for its tables and fields. I try to identify which table I think will be used to save the information and which are likely fields. Then, I go into Moodle and manually change the setting manually. After this, I go back to the database and look at the changes made and attempt to determine what is getting set.
Next, I attempt to manually edit the database using the information I have learned. I make the edit and then I purge all caches in Moodle. Finally, I access Moodle again to confirm that I have achieved the desired result. I also look to see if anything appears to be broken. I repeat the process until I have a working method that doesn't break anything.
Note a more thorough method is to trace the actual Moodle queries in the source code, but I find I normally don't have to do this. In particular think of settings that may impact more than one table (related tables and fields), we want to avoid introducing later hard to find problems.
I recently completed a project to provide a customized certificate including course completion elements for a course to be delivered in 14 languages. It was a great learning experience. This post shares a few tips and tricks learned along the way.
Some Context
This post is targeted toward any developers (or soon to be developers) that need to produce multi-language certificates of completion for Moodle. The Moodle certificate module delivers certificates by generating PDF files. I had assumed that PDFs benefited from the same gains that web applications have with the advent of unicode character sets. The reality is more nuanced when it comes to multi-language documents.
Moodle's PDF font support is broken, but soon to be fixed
During the Moodle 2 development process, Moodle HQ made a sensible decision to remove some of the less commonly used PDF fonts to reduce the size of the Moodle source code installation. This especially made sense given that there was little or no core functionality that used the TCPDF library that contained the fonts and the fonts used a lot of disk space. More recently the TCPDF library version was updated for the Moodle 2.6 release. Changes in the underlying library broke Moodle's support for installing additional fonts. See https://tracker.moodle.org/browse/MDL-47333 for details (fix slated for release around November 14th M2.6.6 and M2.7.3 releases).
The idea is that you can install the full set of PDF fonts from the TCPDF project by
Downloading fonts file from project http://sourceforge.net/projects/tcpdf/files/
Unzip and place the fonts folder into your Moodle dataroot folder
Reference additional fonts by creating a custom certificate type. See https://docs.moodle.org/19/en/Certificate_module#Customize_format for creating custom certificate type. Although Moodle 1.9 specific documentation, the Moodle 2.x version of the document doesn't have the details for making a custom type and the basic instructions are still the same.
This combination of changes makes it difficult to support some languages with certificates. Because of the bug, you will need to either replace the moodle/lib/tcpdf/fonts folder with the complete font folder download, or apply the patch / work around from the above Moodle tracker. This is especially important if you need to produce a certificate using any of the Asian languages such as Chinese, Japanese, or Korean (also referred to as CJK, or CID-0 fonts).
No universal free unicode font for all languages
For our project, we were hoping to make one custom certificate type that would work with any of the 14 language versions of the course. This would allow us to use Moodle's built-in language pack and editing capabilities to provide the correct unicode text for each language. What we found in practice is there was no single free font that had all 40k+ characters needed for universal coverage.
We also found that some fonts would have the characters for a language in one style but not another. For example we used the freeserif and freesans fonts (included in Moodle) for the prototype. We found that with a bold font style we couldn't output Hindi characters.
With some research, we did find a commercial font ($165 license fee) that has all the characters needed to make universal certificate types, but the client was not sure if the licensing terms made it legal to use in a web application such as this and opted for creating multiple certificate types.
CID-0 fonts are "non-embeddable" fonts. The idea is that they are supposed to be provided by the PDF reader. They are a bit like core fonts in this regard, but unlike core fonts which are generally included with your PDF reader download, these fonts need to be downloaded separately. The TCPF configuration for each of these fonts seems to reference the same basic font with an additional code to specify the specific language and character set. In practice, this meant we had to generate 5 custom certificate types to get complete coverage for the 14 language course.
Latin, cyrillic, arabic cert type (fonts freesans, freeserif without use of bold style)
Traditional Chinese cert type (font cid0ct)
Simplified Chinese cert type (font cid0cs)
Korean cert type (font cid0kr)
Japanese cert type (font cid0jp)
If you are an Adobe Acrobat user, you will automatically be prompted to download the CID-0 fonts if you open a PDF that uses them. This brings us to our final tip.
Mac preview gotchas
My development workstation is a Mac and by default it uses the Preview application to open PDF files. We spent a lot of time trying to figure out why our CID-0 based certificates were blank. After trying the same PDF files on a Windows workstation and finding that they worked correctly, we finally determined that Preview will not prompt for the missing fonts. We also found that installing Adobe Acrobat, opening the files, and downloading the CID-0 fonts package did not fix the issue for Preview which apparently uses a different font path. I have yet to determine a procedure to fix the issue for Preview, but it's pretty easy to work around once the root cause is discovered (right click on PDF and choose open with Acrobat, or change the default PDF viewing application).
Earlier this week, I was working with a client whose Moodle server was full. They asked me to help figure out why it was full. This can be a challenging question when using Moodle 2.x due to the fact that files are saved in a single hashed space. In this client's case, 6 SCORM files were using 3/5 of all their storage. Here is the simple query I developed to create the list showing the original filename and path, the storage used in megabytes, the content hash (ie filename used in moodle data folder), and which component of Moodle owns the file. The output is sorted by largest files first with a limit of the 50 largest files.
SELECT DISTINCT filename, filepath, FORMAT( (filesize /1024 /1024), 1 ) AS filesize_MB, contenthash, component FROM `mdl_files` ORDER BY filesize DESC LIMIT 0 , 50
If you are a Remote-Learner hosting client you can run this query via your phpMyAdmin link contained in your customer kit, or request via our support portal.
During this research I also found that its is possible for a file to become orphaned. In this situation the file is still stored in the moodle data folder, but is no longer referenced in the mdl_files table of the database. Look for a future post on how to track down orphaned files.
Here are some simple settings that any Moodle administrator can change from the Site Administration menu that will help to improve his/her Moodle site's performance. Some of these changes come at the cost of functionality, so sometimes you have to pick between a particular feature and performance (or a faster server), but often these settings are just enabled out of curiosity with no discernible reward other than a slower site.
Automated backup setup
Disable Automated backup setup for courses by setting Active to disabled in the pull down menu. The Moodle course backup and restore feature, while a convenient mechanism for moving courses between Moodle sites, is not very efficient. As the number of courses and the size of the courses on your site increase, the scheduled course backup process takes longer and longer to complete. This can cause extreme site slowdowns while it's running. Additionally, it makes it harder for your server's backup system to complete its own nightly backups.
Many users mistakenly view this as a way to restore their Moodle site in the event of a disaster. While it's possible to use these course backups to restore most of a site, it's not ideal or guaranteed to work when you need it. Disaster recovery backups should be performed outside of the scheduled course backup feature.
Statistics
Make sure Enable statistics is unchecked. Many administrators discover this setting and turn it on simply to see what it does. A common scenario is that a site will be performing well for a year or more and then suddenly experience problems when this setting is enabled. This setting includes options for how long to allow the statistics gathering to run in one session and how far back to process. If you must run statistics make sure to limit how long you allow the process to run. I recommend letting it run no more than 2 hours per session.
Site administration / ▶ Advanced features
Upcoming versions of Moodle may have an improved version of statistics that should reduce the load on the server's database by several orders of magnitude. So if you really need this feature, keep your eyes on MDL-30643.
Theme designer mode
Disable Theme designer mode on production Moodle sites. Theme designer mode is a great Moodle version 2 feature, if you are updating your theme and want to quickly see the impact of changes. It does this by having the Moodle server tell web browsers to not cache any of the images, css, and javascript that make up your theme. When this feature is enabled, every page view for every user must download every media object directly from the Moodle server. This makes viewing pages very very slow and greatly increases the load on the server. Administrators often enabled this to update their theme and then forget to turn it off. The best practice is to develop your theme on a testing site and then move it over to production only after it has been completed.
Set Keep logs for and Grade history lifetime to 365 days or less. By default Moodle will keep both your logs and grade history forever. For long established sites, these logs start to become the majority of the database. I have seen cases where log tables consumed 90% or more of the database. As a general rule the more of your database that fits into your server RAM the faster your database will perform. By limiting the size of these logs, you can make your site much faster.
Site administration / ▶ Server / ▶ Cleanup
Note: If you have a really large log, it may make your site even slower while the cleanup runs. Consider changing this setting during a low-use time or during a maintenance window. In extreme cases, it can take several hours for the cleanup query to complete the first time.
Session Handling
Disable Use database for session information by unchecking the box. Starting with Moodle version 2 and above the default setting is to have database sessions enabled. In our infrastructure, we have seen much better performance using file based sessions rather than having the database handle them. This is dependent on the server setup, but it's worth disabling to see if your performance improves.
Site administration / ▶ Server / ▶ Session handling
Pro-tips
Below are some additional tips that take a bit more effort, but provide additional benefits related to ensuring great performance for your Moodle site.
Running multiple simultaneous manual course backups can sometimes cause problems. Avoid creating situations where many course backup / restores need to run at the same time. This is a common problem for the start of a new school term. Often instructors will be asked to duplicate their prior courses for the new term. Moodle doesn't provide any internal mechanism to queue backup requests so that they don't overwhelm your server. If enough instructors are doing this at the same time, it can make a Moodle site nearly unusable.
While all of these settings can be accessed from the Moodle interface, if you want to really make sure none of your site administrators accidentally sets one of these incorrectly, enter the desired value in your config.php file so that it cannot be enabled accidentally.
Consider starting with a clean install of Moodle once a year to have the smallest database footprint and ensure the best performance for your site.
Part 3: The Last Half of Writing
This is the third of a four part series on my experiences writing my first book, Moodle 1.9 Extension Development. The book was co-authored by Mike Churchward. The four parts are detailed below:
Part 1: Getting a book deal
Part 2: Writing the first half
Part 3: Writing the last half
Part 4: Post writing production
Chapter 8 Reports -- Writing in Belize
Our CEO, Bryan Williams, is an avid SCUBA diver. For many years, we had talked about going on a dive together with my wife Michelle. Last September, we decided to finally make this happen and to get some much needed sun. So after looking at the options, we decided on a trip to Belize. I worked out that with Mike's efforts on Chapters 5-7, that I could get back on schedule, if I could complete a full chapter while on vacation. I must say that writing on the beach is really the way to go. While it can be a bit tricky getting your computer screen at just the right angle to be visible, its well worth the effort. I didn't quite manage to get the entire chapter done on vacation, but I got most of the source code finished and completed all but one section on the plane ride back to the US.
Feeling good about the progress and rejuvenated by our trip, I quickly wrapped up Chapter 8, on my return to the states.
Chapter 9 Integrating with 3rd Party Systems -- Drive Crash!
I was really feeling good again at this point. System integrations are a particular specialty of mine and I had an existing library of material that I was pretty quickly able to work into half of a completed chapter. I put in some extra time during the evenings and had most of the coding samples quickly completed. Then ene night, as I was packing up, I notice that my laptop which should have been fully charged was showing a low battery. When I get home, the computer wouldn't boot. The battery had died and somehow this caused a nearly complete wipe of my SSD drive. While I had backups, I had done so much work in a short period of time that I didn't really have a good backup of the materials for Chapter 9. Even more disruptive was taking the time to rebuild and reload the computer and restore my files. I went from finally being caught up with the schedule to being 2-3 weeks behind. My take away from this was, you can always improve your backup system, even after 15 years working in IT.
I managed to rewrite everything and get it out the door. I think I rushed it a bit trying to get back on schedule; this chapter ended up being one of the ones I spent the most time editing later.
Chapter 12 Pagelib -- Back on Track
Thankfully, our CEO has been very supportive of the book effort. He agreed to give me half a day per week during work hours to work on the book. This got me back on track to deliver the book on schedule. Chapter 13 was remarkable in that it was probably the only chapter in the book that we didn't end up tight on space. While pagelib is a core library, it is pretty simple. Mike and I actually recommended this as most easily cut from the book, when we thought we were going to have to delete a chapter. Luckily, we were eventually able to get the entire book into the print edition.
Chapter 14 Web Services-- Writing on Christmas Break
It was getting down to the wire. I was confident that there was enough time to get all the writing finished. Especially, since we had a block of time off for Christmas and later for New Years Eve. We had a major snow storm hit during this break and I recall not leaving the house for about 4 days and a final marathon coding/writing session finishing at 2 AM. I managed to submit the last chapter 2 days before our final deadline for the book. I can't tell you how much of a relief it was to finally hit send on that last chapter, especially considering how far behind I was just a few chapters into he book.
In the next and final part, I talk about the production process.
I recently did an interview with the staff at Packt Publishing, the publisher of Moodle 1.9 Extension Development.
Packt: Your book is published now. How is the feeling of being a published author? Jonathan: I don't think it has totally sunk in yet. I feel a tremendous sense of accomplishment. I have wanted to be a writer since I was twelve years old. Mike and I worked tremendously hard over the past year to put the book together. It was especially difficult putting together all the coding examples. Once the coding was finished for a chapter the writing was relatively easy. I feel really good that while it was a difficult process, that I was able to accomplish our goal of writing a great book on how to customize Moodle via its extensible plug-in model. Packt: What benefits did writing a book bring to your specialist area? Jonathan: The most direct thing that comes to mind is how much I learned over the course of researching and example creation for the book. Its very much like the saying that you have to teach it to truly learn a subject. I think writing a book on a subject, brings that idea to an even higher level. Longer term this is one more indication of the level of both my personal expertise as well as that of our company Remote-Learner provides in the Moodle space.
Part 2: The First Half of Writing
This is the second of a four part series on my experiences writing my first book, Moodle 1.9 Extension Development. The book was co-authored by Mike Churchward. The four parts are detailed below:
Part 1: Getting a book deal
Part 2: Writing the first half
Part 3: Writing the last half
Part 4: Post writing production
Chapter 1 Architecture of Moodle -- Writing Fitness
This is when the true realization of how much work this was going to be started to set in. Intellectually, theoretically, I knew it was going to be a lot of work, but this was when reality started to set in. With researching, coding, writing, and work, it was going to be hard to keep with the schedule. This first chapter felt a bit like that first two weeks on a new fitness program after being a couch potato all winter. I had to develop some writing fitness and fast.
Packt provided a really nice chapter template that let us focus on writing. There was a learning curve during the first few chapters on how to properly mark the styles of sections and format the document, but the template generally made everything look really nice and professional without a lot of effort. I remember my wife commenting on the first chapter printout, "Hey this looks like a real book!"
Mike and I worked on the first chapter together and still managed to miss our scheduled delivery date by about half a week. It was hard work but enjoyable. We ended up double writing a few sections and decided to write individual chapters going forward.
Chapter 2 Blocks -- Smooth Sailing
I started to feel some writing fitness at this point and developed some good habits. The writing started to be a nice stress reliever at the end of the day. I was able to split the writing up into chunks of 30-45 minutes. There was pretty good documentation on how to write blocks and I had lots of good examples. The coding took a lot more time than I expected, but because of working on it a little bit every day, I was able to turn it in ahead of schedule. In hindsight, this was the first sign of just how hard the code samples were going to be. We really wanted a hands on book that would cover original coding projects as a learning tool. We did not just want to copy lines of code from Moodle and give a dry explanation of what they did. This meant a lot of coding and testing on top of writing.
Table of Contents -- A Marketing Tool
This is about the time we received our first editorial feedback. I was pleasantly surprised that the requested changes were pretty easy to accomplish and we had mostly been applying the styles and formatting correctly with the template document. There were also some very specific instructions for taking screenshots and creating figures that we seemed to be doing correctly.
My major take away, which is obvious in hindsight, is the importance of the table of contents in selling a book. A lot of the feedback came on the proper way to name section titles so that they made the table of contents interesting and engaging. As soon as I read this, I immediately thought of how I decide whether to purchase a book. After reading the description, I immediately go through the table of contents. It's common sense, but Packt had down the mechanics of how to make the TOC engaging and they were able to distill it down to 3-4 recommendations.
Chapter 4 Activity Modules -- The Schedule Goes off the Rails
At this point I was feeling really good. I was enjoying the writing and managed to work diligently during Chapter 3 and got ahead of schedule. I even managed to get an early start on Chapter 4. Everything went downhill from there. I ended up with a perfect storm of issues:
1) Creating activity modules is considerably harder than other plugin types and many of the areas I wanted to cover such as course backup and restore did not have a lot of source material.
2) Renovating house for sale. Remote-Learner had opened a Kansas City office about 9 months earlier. I had rented an apartment so we could move to KC to oversee the launch. My lease was coming up for renewal and I had major renovations to complete on my old house before it could be sold. We wanted to buy a new house in KC rather than staying in an apartment for another year, but did not want to have two mortgages.
3) 150 page RFP for work. I was put in charge of putting together a major RFP that ended up being 150 pages in length (a book in its own right).
What followed was 4 months of the most intense work on all three of these fronts. Needless to say, I was very behind schedule by the end of this process. Luckily, Mike was able to keep moving forward with his chapters.
It took about 3 months of development in my spare time to complete activity Foo!, my example activity module for the chapter. Coding and testing truly took a phenomenal number of man hours.
Now, I faced a new challenge. Just printing the source code alone would have been 65 pages and we only had 24 pages allotted for this chapter. Up until this point, I had been able to cover every line of code in the samples as part of the chapter text. It took another painful effort to review the code base and boil it down to a 30 page chapter. I think all in all that this chapter is better and more readable for the effort.
In part 3, I cover writing the second half of the book, including what it's like to write on the beach in Belize.
by Jonathan Moore Michael Churchward |May 2010| Moodle
In this article byJonathan MooreandMichael Churchward, authors ofMoodle 1.9 Extension Development, we will discuss the basic concepts of creating a Moodle filter, which includes:
How a filter works
Using the API to create filter code
How to use language files
How to create configuration settings
Moodle filters modify content from the database as it is output to the screen, thus adding function to the display. An example of this is the multimedia filter, which can detect references to video and audio files, and can replace them with a "mini-player" embedded in the content.
How a filter works
Before trying to build a filter, it would help to understand how it works. To begin with, any text written to the screen in Moodle should be processed through theformat_textfunction. The purpose of this function is to process the text, such that it is always safe to be displayed. This means making sure there are no security issues and that any HTML used contains only allowed tags.
Additionally, the output is run through thefilter_textfunction, and this is the function we are interested in. This function takes the text destined for the screen, and applies all enabled filters to it. The resulting text will be the result of all of these filters.
filter_textapplies each enabled filter to the text in the order defined in the filter configuration screen (shown in the following screenshot). The order is important; each filter will be fed the output of the previous filter's text. So it is always possible that one filter may change the text in a way that impacts the next filter.
Part 1: Getting a Book Deal
This is the first of a four part series on my experiences writing my first book, Moodle 1.9 Extension Development. The book was co-authored by Mike Churchward. The four parts are detailed below:
Part 1: Getting a book deal
Part 2: Writing the first half
Part 3: Writing the last half
Part 4: Post writing production
I can remember wanting to write a book since I was twelve years old, just shortly after discovering Tolkien. So when the opportunity came to write a book in an area where I had some expertise, I felt I had to take it, regardless of whether it made sense with my schedule. I first worked with Packt Publishing (http://packtpub.com) on the second edition of William Rice's Moodle book. I served as a reviewer for some of the more technical sections. Early in 2009, Packt contacted us to see if we might be interested in writing a book on Moodle development.
Is this the Right Book?
I think I could have written a book on Moodle Administration in my sleep, but that wasn't the book we were offered (in fact that book had already been written). You often have to stretch outside your comfort zone in this life to get what you want. I had a lot of development experience and I had a lot of Moodle experience. But I really didn't have a lot of Moodle coding experience. I had primarily worked at Remote-Learner (http://remote-learner.net) to create our hosting and support groups and later as a project manager for development projects. I had a very good grasp of what Moodle could do out of the box, the overall methods for customizing, and what did and did not require changing core Moodle to accomplish. However, I did not have a lot of on the ground coding experience inside of Moodle. Thankfully, my writing partner, Mike Churchward had this in spades. Long story short, Mike Churchward and I had both wanted to write a book since we were kids and we agreed to enter discussions with Packt.
Writing a Book Outline and Schedule
It ended up being a very long 3 month process working out the details of what would go into the book, how long the book would be, and what schedule it would be written under. Packt provided a very detailed guide to writing a book outline along with samples. We had a pretty good idea of what topics we wanted to include from many years of doing custom development for Moodle. Our biggest challenge was figuring out how many pages each chapter should take and a realistic schedule for completing the writing. Mike and I were both juggling very tight time commitments with a growing Remote-Learner. These may seem like minor details to be stuck on for months on end, but writing a technical book is ultimately a business and the economics of the book are tightly tied to its size and delivery date.
We were really stuck for a while. Packt helped us out with a few guidelines. They had in mind a book no larger than 250 pages of content and that most writers can complete 8 pages per week. I went to a few other books on Moodle from my bookshelf and reviewed chapter sizes for some common topics. As a result we came up with two chapter sizes: 16 page chapters for simpler topics and 24 page chapters for more complex topics. From here the outline came together pretty quickly. We padded the schedule just a bit for some extra cushion just in case work got too crazy -- and it did. If you ever find yourself in this situation here is my advice. Try to get your outline done quickly so you have more time to actually write!
In the next article in this series, I will cover writing the first chapters of the book.