Saturday, January 28, 2012

Giving students a feel good factor with a Stamp Collection pseudo-block (Moodle 1.9.x)

The Stamp Collection module by David Mudrak is one of my all-time favourite modules on my Moodle 1.9.15 site. It's a great tool to provide feedback to students and to reward them whenever work has been done. I like to think of it as a motivational tool.

I had always wished that there could be a block that shows the student how many stamps he or she has earned. Why? This is because at the moment, the student has to click on the Stamp Collection module to view the stamps earned. So this evening, I sat down to craft such a block. And I failed miserably because of my lack of experience in PHP coding!

Undeterred, I had a brainwave of how I could achieve the same effect as a real block. Within 4 hours, I crafted something that made use of David's existing code, HTML, PHP and some tricks. Here's what it looks like:

So the advantage of this 'block' is that the student can see his Stamp collection. Is it growing? Is it stagnant?
Oh, and I'm also glad to mention that if the student does a mouseover on any of the stamps (gold stars?), the description of the stamp is displayed. See the image below:

So what do you think? Do you like this 'block'? Are you already using the Stamp Collection module by David Mudrak on your Moodle 1.9.x? Would you like to know how you can set up this pseudo-block on your Moodle 1.9.x site as well? You do? GREAT! Let's dive in!

Instructions to setup the Stamp Collection Pseudo-block 
Step 1: Make sure that you already have the Stamp Collection module installed on you Moodle 1.9.x site.

Step 2: Login as a student account.

Step 3: Click on the Stamp Collection module icon.

 Step 4: Copy the link to the "Own Stamps" tab.

Step 5: Take special attention to the id value of the URL. In the example above, that value is 2012. The value on your Moodle site will differ. Just copy and paste that value to Notepad. Or write it down. You'll be needing it in a couple of minutes.

Step 6: Log out from Moodle. Login again, this time as Administrator. Turn Editing on.

Step 7: Create a HTML block, then click on the Edit icon (the writing hand)

Step 8: Configure the HTML block with the title "My Stamps".

Step 9: In the Editor, go to HTML (<>) mode and copy and paste this code:

<iframe width="98%" height="60" frameborder="0" 

Remember that value 2021? That was from Step 3. And where in the world, did the viewblock.php file come from? It doesn't exist - yet. Don't worry, it will soon!

Step 10: Backup your Moodlesite/mod/stampcoll/lib.php file. Or rename it as lib.original. Do this before proceeding to Step 9.

Step 11: Download this modified lib.php and copy or FTP it to your Moodlesite/mod/stampcoll/ folder. Actually, the only difference between the original lib.php and the new lib.php is that the new lib.php file contains one extra function named stampcoll_stamp_block().

Step 12: Now download the file named viewblock.php and copy or FTP it to your Moodlesite/mod/syampcoll/ folder.

That's it. It should work now. Give it a go. Fire it up. Hope this little block will do wonders for your moodle site and for your students.

But wait! There's more. I've also managed to get the stamps to do the wiggle!
You can use this wiggle version of lib.php that has the wiggle code in it.

In my humble opinion, the Stamp Collection should include THREE features to become almost perfect:

(1) Automatically and simultaneously assign a stamp to a class of N students
(currently, doing this action one-by-one is very tedious. Works for small classes, but once the class reaches 50 and above, it gets very tiring and tedious to do)

(2) Allow the teacher to assign mult-stamp icons. This will allow clear distinctions among stamp awards. E.g., a gold star for excellent effort, a silver star for good effort and a bronze star for average effort.
Important update 9th February 2012!
I have managed to implement the multi-stamp feature. Smurf, I mean surf here.

(3) Work for both Moodle 1.9.x and Moodle 2.x.

I know, I'm asking for the sky here. But it is possible, no? Hopefully, this Stamp Collection pseudo-block will be a prototype and the basis for an actual and proper Stamp Collection block. In the meantime, this works for me, and I hope it works for you as well!

Frankie Kam
Melaka, Malaysia

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!


  1. Thank you for sharing this.
    But I have a litte problem: the text "Number of your stamps:" in the block is black and the background of my site is also black, so you can`t see the text.
    I don`t know, where to change this.
    Thanks again.

  2. Hi Ralf. Thanks for asking. Here's how you can do it: Edit line 105 of viewblock.php to become:

    echo '<span style ="color:white ;">'.get_string('numberofyourstamps', 'stampcoll', count($mystamps)).'</span>';

    This will give you white text on your black background. If white text doesn't match your theme's colors, you can always change white color to any other colour using a color hexadecimal code.
    Okay, to make it easy for you, you can download the modified viewblock.php (with the white text) from here!
    Hope this helps, yeah?

  3. Thanks so much.

    I expand it a little bit:
    "color:white ; font-size: 12px; font-family: Arial; line-height: 4;"



  4. Hi Ralf. There you go! You're well on your way to making it work on your site. Who knows? Maybe you can even improve on it.

  5. Thanks for this!
    And I agree with you about next steps for the Stamp Collection, particularly the multi-stamp option.

  6. I got the Multi-stamp option to work now! Surf here:


Ratings and Recommendations by outbrain