Friday, December 2, 2011

How to install the Accordion Resource on Moodle 1.9.14

Abrar Ullah's Accordion Resource Editor 2009 module allows you to hide and display labels and Moodle resources and activities at will. I absolutely love using it on my Moodle site. In this post, I will show you how to install it on the latest (as of December 2011!) Moodle 1.9.14.

Firstlly, here's what it looks like on my production site:

Here's what the course page looks like after I click on the Video Accordion tab:

A video pops up! After viewing the video, I can click on the video tab and the video tucks back into the Accordion! Nice, huh?

If you ever felt you could use the Accordion resource on your own Moodle site, then boy are you in for a treat! Here are the detailed steps to install the Accordion:

1. Download the Accordion zip file from here.
2. Extract the zip file. You will get the following folder structure:

3. First the EASY part. Select ..\mod folder and copy & paste the accordion folder into the mod folder of your Moodle site.

4. Now it gets a little bit tougher, but no problem, you can handle it. Edit ..\lang\en_utf8\resource.php and copy $string['resourcetypeaccordion'] = 'Insert and Accordian'; in the last line before closing "?>"

Here's what the tail-end of resource.php looks like:

5. The course folder contains just one file: lib.php. Do NOT copy this file to overwrite your lib.php file in your production site! That would be asking for trouble. Instead backup your Moodle site's lib.php file first. It is better to be safe than sorry.

6. Now it gets really tough and edgy. This one's the most delicate part of the operation. So go slow, and hang on to every text I type and to every image file I am showing to you!
Edit the file ..\course\lib.php
Goto the following code lines from line:1398 (approx).
Find the following code:

and replace it with:

To make it clearer, here is what the code looks like before the 'surgery':

Here is what the code looks like after the 'surgery':

Save your lib.php into the /course folder of your Moodle site.

5. Go to Administration | Notifications and your Moodle site should auto-install the Accordion resource.

6. Load up your Moodle site. If it loads normally, then PHEW YOU MADE IT THUS FAR!

7. To control the 'shutter' speed of the Accordion resource, all you need to do is to edit the file ../mod/accordion/accordion.js. Look for the line of code that reads as
                            this.duration = 500;
and change the code to:
                            this.duration = 300; //500 was the original value

8. If you don't like the default blue colour of the Accordion horizontal tabs, you can always edit the images files inside the ../mod/accordion/accordion_images folder.

9. Some advanced stuff - 'adding' Moodle resources inside an Accordion.

Intially I thought that the objects inside an accordion were limited to labels and HTML embed code like Youtube videos. However, I have since discovered how to add other stuff inside the Accordion. In this part of the post I will show you how you can add Moodle activites and resources inside an Accordion. Read on!
Here's a post I made in that talks about the Accordion Resource Editor.

I made a YouTube video of how to achieve this effect in your Moodle 1.9 course page. So here it is. Using Abrar Ullah's Accordion Resource Editor (2009) in an innovative way to reduce the scroll of death. It's a hack that's not too simple, but achievable by all. Take your time to watch this 19-minute tutorial. Sit back and ENJOY.


Useful reminders, links and resources

1. This code works on Moodle 1.8 & Moodle 1.9. It works on my Moodle 1.9.14 site.

2. Please, please, please backup your lib.php file (\course\lib\lib.php) before installing the module and definitely before doing the hack!!!

Read Abrar Ullah's August 2009(!) entry in's Modules and Plugins page:

This is the download link of Abrar Ullah's Accordian Resource:

Read the discussion forum for this module:
The page also informs you how to hack the code of the lib.php file found in \course\lib.php

This link contains the files modified by me (accordianBar.png, accoridanBarRollover.png, lib.php and resource.php), which I am using on my Moodle site:

To modify the png files to suit your course page's theme, I recommend using

For a live demo, head over to:
Username: student
Password: moodle

If anyone needs any help getting this Accordion resource running on his or her Moodle site, feel free to contact me at boonsengkam at gmail dot com.

Frankie Kam
Melaka, Malaysia
3rd December 2011

If you like this post or site
a small donation would be nice but would last only a day,
otherwise leaving a comment (or a compliment) below will last me a month!

Ratings and Recommendations by outbrain