0

We create Moodle courses with PHP and the Moodle libraries.

The content comes from our users.

Some users create spoilers (DIVs to be clicked and then they reveal the content).

How could such a spoiler be created in Moodle?

Can Javascript and CSS be implemented directly into the HTML of a course? – It seems so!

Avatar
  • 14,622
  • 9
  • 119
  • 198

1 Answers1

0

You can basically add javascript and CSS to an HTML element:

$output = '<div style="cursor: pointer; background-color: yellow; color: transparent; opacity: 1;" onclick="javascript:this.style.color = \'#000\';this.style.backgroundColor = \'white\';">This is the spoiler content.</div>';

Then it works as a spoiler.

Avatar
  • 14,622
  • 9
  • 119
  • 198