Skip to content

Commit 1a48b65

Browse files
allanhaggettclaude
andcommitted
Add Lesson activity documentation to README
Document lesson directory structure, lesson.yaml metadata, and page types (content, true/false, multichoice) with front matter examples. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 960ebac commit 1a48b65

File tree

1 file changed

+110
-2
lines changed

1 file changed

+110
-2
lines changed

README.md

Lines changed: 110 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ A Moodle local plugin that syncs course content from a GitHub repository. Conten
66

77
- **One-click sync** from a GitHub repository into a Moodle course
88
- **Automatic section creation** based on directory structure
9-
- **Page, Label, URL, and Book activities** created from HTML files and directories
9+
- **Page, Label, URL, Book, and Lesson activities** created from HTML files and directories
1010
- **YAML front matter** support for controlling activity types
1111
- **Asset management** — CSS, images, and JS uploaded to Moodle file storage with automatic URL rewriting
1212
- **Incremental sync** — only changed files are updated (content hash tracking)
@@ -56,6 +56,11 @@ sections/
5656
section.yaml
5757
01-lesson.html
5858
02-external-link.html # -> URL activity (with front matter)
59+
03-safety-training/ # -> Lesson activity "Safety Training"
60+
lesson.yaml # Optional: title, intro, practice, retake
61+
01-introduction.html # -> Content page
62+
02-hazard-check.html # -> True/false question (with front matter)
63+
03-procedure-quiz.html # -> Multichoice question (with front matter)
5964
assets/
6065
css/
6166
custom.css # Shared stylesheets
@@ -123,7 +128,7 @@ url: "https://docs.moodle.org"
123128
**Supported front matter fields:**
124129
| Field | Description |
125130
|-------|-------------|
126-
| `type` | Activity type: `page` (default), `label`, or `url`. Books are created from directories, not front matter. Other Moodle activity types (quiz, forum, assign, etc.) are not yet implemented. Unrecognized types are treated as `page`. |
131+
| `type` | Activity type: `page` (default), `label`, or `url`. Books and Lessons are created from directories, not front matter. Other Moodle activity types (quiz, forum, assign, etc.) are not yet implemented. Unrecognized types are treated as `page`. |
127132
| `name` | Override the activity name (otherwise derived from filename) |
128133
| `url` | External URL (required for `type: url`) |
129134
| `visible` | `true` or `false` |
@@ -185,6 +190,109 @@ subchapter: true
185190
- **Modified book.yaml**: Updates book name, numbering, and intro without touching chapters
186191
- **Reordered chapters** (renamed with different numeric prefixes): Page numbers are updated even if content is unchanged
187192

193+
### Lesson Activities
194+
195+
A subdirectory inside a section directory that contains a `lesson.yaml` file (or has its name recognized as a lesson) becomes a **Lesson** activity. Each `.html` file in the subdirectory becomes a lesson page. Pages can be content pages, true/false questions, or multichoice questions, controlled by YAML front matter.
196+
197+
```
198+
sections/
199+
01-introduction/
200+
03-safety-training/ # -> Lesson "Safety Training"
201+
lesson.yaml # Optional metadata
202+
01-introduction.html # -> Content page
203+
02-hazard-check.html # -> True/false question
204+
03-procedure-quiz.html # -> Multichoice question
205+
```
206+
207+
#### lesson.yaml
208+
209+
Optional. Sets lesson-level metadata:
210+
211+
```yaml
212+
title: "Safety Training"
213+
intro: "<p>Complete this lesson to demonstrate your understanding.</p>"
214+
practice: false
215+
retake: true
216+
feedback: true
217+
review: false
218+
maxattempts: 3
219+
progressbar: true
220+
```
221+
222+
| Field | Description |
223+
|-------|-------------|
224+
| `title` | Override the lesson name (otherwise derived from directory name) |
225+
| `intro` | HTML description shown on the lesson's intro page |
226+
| `practice` | Practice lesson — no grades recorded (default: `false`) |
227+
| `retake` | Allow students to retake the lesson (default: `true`) |
228+
| `feedback` | Show feedback after answering (default: `true`) |
229+
| `review` | Allow students to review their answers (default: `false`) |
230+
| `maxattempts` | Maximum number of attempts (default: `1`) |
231+
| `progressbar` | Show progress bar (default: `true`) |
232+
233+
#### Lesson Page Types
234+
235+
Each HTML file in a lesson directory becomes a page. The page type is set via front matter:
236+
237+
**Content page** (default — no front matter needed):
238+
```html
239+
<h2>Introduction to Safety</h2>
240+
<p>This module covers workplace safety fundamentals.</p>
241+
```
242+
243+
A "Continue" button is automatically added. The last page links to End of Lesson.
244+
245+
**True/false question:**
246+
```html
247+
---
248+
pagetype: truefalse
249+
correct: true
250+
feedback_correct: "That's right! PPE is always required."
251+
feedback_incorrect: "Actually, PPE is required in all work areas."
252+
---
253+
<p>Personal protective equipment (PPE) must be worn in all work areas.</p>
254+
```
255+
256+
| Field | Description |
257+
|-------|-------------|
258+
| `pagetype` | `truefalse` |
259+
| `correct` | `true` or `false` — which answer is correct |
260+
| `feedback_correct` | Feedback shown when the student answers correctly |
261+
| `feedback_incorrect` | Feedback shown when the student answers incorrectly |
262+
263+
**Multichoice question:**
264+
```html
265+
---
266+
pagetype: multichoice
267+
answers:
268+
- text: "Stop work and report it"
269+
correct: true
270+
feedback: "Correct! Always stop and report hazards."
271+
- text: "Ignore it and continue"
272+
correct: false
273+
feedback: "Incorrect. Ignoring hazards puts everyone at risk."
274+
- text: "Fix it yourself without training"
275+
correct: false
276+
feedback: "Incorrect. Only trained personnel should address hazards."
277+
---
278+
<p>What should you do if you notice a safety hazard?</p>
279+
```
280+
281+
| Field | Description |
282+
|-------|-------------|
283+
| `pagetype` | `multichoice` |
284+
| `answers` | List of answer options, each with `text`, `correct`, and `feedback` |
285+
286+
Correct answers advance to the next page; incorrect answers stay on the current page.
287+
288+
#### Sync Behavior for Lessons
289+
290+
- **New lesson directory**: Creates the lesson activity and all pages in one operation
291+
- **Modified page**: Only the changed page is updated (content hash tracking via `itemid` in the mapping table)
292+
- **New page file**: Added at the correct position based on filename ordering
293+
- **Removed page file**: The page mapping is updated; pages are managed through the lesson's linked list
294+
- **Modified lesson.yaml**: Updates lesson name, intro, and settings without touching pages
295+
188296
### Assets
189297

190298
Files in the `assets/` directory are uploaded to Moodle's file storage. References in HTML are automatically rewritten:

0 commit comments

Comments
 (0)