More theme - Collapsing the course descriptions

More theme - Collapsing the course descriptions

by James B. Byrne -
Number of replies: 2

We are developing an in-house Moodle based training program.  The courses offered have fairly extensive technical descriptions.  Currently the course name and the entire description is displayed on the front page.  Is there a plugin or a configuration option such that the front page course descriptions can be collapsed to their first sentence or so and expanded if desired?

Average of ratings: -
In reply to James B. Byrne

Re: More theme - Collapsing the course descriptions

by Mary Evans -
Picture of Core developers Picture of Documentation writers Picture of Peer reviewers Picture of Plugin developers Picture of Testers

This is not theme related, but could be the type of Course format you are using or the settings for course listings For the frontpage.

Either way I have moved this to courses as there are lots of helpers here who know more about this than I do.

Mary

In reply to Mary Evans

Re: More theme - Collapsing the course descriptions

by James B. Byrne -

Thanks.  I sorted this out (with the help of google of course).

For anyone interested this is what you can do:


Step 1. Add the following javascript to:

Before BODY is closed additionalhtmlfooter

<script type="text/javascript">
<!--
    function toggle_visibility(id) {
       var e = document.getElementById(id);
       if(e.style.display == 'block')
          e.style.display = 'none';
       else
          e.style.display = 'block';
    }
//-->
</script>
This could probably go into the:  Within HEAD additionalhtmlhead section instead.

Step 2.  Enclose the variable portion of your course description like this:
<p>A course to prepare for whatever</p>
<a href="#" onclick="toggle_visibility('foo');">See more. . .</a>
<div id="foo"  style='display:none;>
<p>More text than we can comfortably display. . .</p>
<p>Several paragraphs in fact</p>
<p>Mind the div closing tag goes at the end.</p>
</div>

Gives this:
Guest access requires password

A course to prepare for whatever

See more. . .

And that is all there is to it.  Click on 'See more. . .' to display the hidden text and again to hide it. 

Of course, this might be the brute force way of doing things.  If there is some sort of setting or other builtin way to accomplish this then I would like to know.  We are presently using Moodle-2.8.