General help

Want to reveal answers in web page

Kate & fiddle
Want to reveal answers in web page

My university is using Moodle 1.9.9.

I would like to reveal extra text - the answer to a question -- in a web page. The point is to give the students an opportunity to observe something before I go ahead and tell them. I would prefer to do this in a web page because I use a combination of web pages + quiz, and lessons, and the subject matter is in a section for which I am using a web page.

I don't know javascript, but I was able to find some on the internet and apply it in a web page outside of Moodle. It doesn't work inside Moodle though. If there's a way to do it without javascript, that's fine with me, but I would just like to be able to do it. Here's how I tried:

<script type="text/javascript">
function toggle(id) {
var e = document.getElementById(id);
if( == 'none') = 'block';
else = 'none';

<div id="question1">
Which hand are O'Neill and Hempson using to play the bass (long and low) strings and which for the treble (short and high) strings?<br>
<a href="#"
onclick="toggle('answer1');">Click here</a> to see the answer.
<div style="display:none" id="answer1">
Bass: right hand, Treble: left hand.
<div id="question2">
Which hand is associated with the bass side of of instruments today?<br>
<a href="#"
onclick="toggle('answer2');">Click here</a> to see the answer.
<div style="display:none" id="answer2">
By modern convention, on keyboard and stringed instruments the left hand or left side is associated with the bass. The old Irish harpers used their hands opposite from how harpists play today.

- Kate D.

Average of ratings: -
Picture of Patrick Pollet
Re: Want to reveal answers in web page
Plugin developers

You cannot include javascript in Moodle text editor. It will be stripped out for security reasons when you save it.

But there is a text filter named Hidden text that does what you want. see

basically , after you get it installed by your admin, you surround in Moodle editor the text to be revealed/hidden on a click by [hiddentext] [/hiddentext]  like the following example ( a french joke) and Moodle will render it with a nice 'eye icon' on which you can toogle the hidden state :

tu connais la différence entre une mère juive et un terroriste ?
[hiddentext]avec un terroriste on peut négocier [/hiddentext]

see some doc here


edit : the hidden content can be very rich, including formating, images, links ... and if you swap to HTML mode, you will get more using span and div tags.

Average of ratings: -
Picture of Richard Jones
Re: Want to reveal answers in web page
Particularly helpful MoodlersPlugin developersTesters

Hi Patrick

Have you tried this in version 2.0 and above?  Hasn't the plugin API changed quite a bit since 1.8?



Average of ratings: -