Quantcast
Viewing latest article 2
Browse Latest Browse All 6

Course contents block

I published a simple Moodle block called Course contens. It generates a list of all visible topics/weeks in the course. Clicking at one of these links displays that particular week or topic. What I needed to solve was how to automatically obtain a title for every course section.

The block extracts a suitable title for every week or topic from the section summary. If you start summary with a heading (H1, H2, H3, etc), it will use such heading text. If your summary starts with a bold text, it will be used as a section title. If the summary consists of several paragraphs, the first one will be used. If the summary is empty, a customizable text “Unit X” (where X is the number) is displayed.

Technically spoken, the plain text content of the first non-empty HTML DOM node of the section summary is used as the summary title. I realized that Moodle 1.9 does not contain any HTML parser so the block source code is shipped with a its own Simple HTML DOM parser library (credit goes to S. C. Chen and other contributors).


Viewing latest article 2
Browse Latest Browse All 6

Trending Articles