Complete programs for real tasks, each explained step by step, with its code commented where Moodle or the driver does something you wouldn't guess. Copy one, change the site, the profile and the ids, and run it.
Every program starts the same way: a Moodle object for the site, created with await using so the browser closes when the program ends, and logIn(), which opens a window only the first time (see Logging in). The ids come from the site: a course's from listCourses(), an activity's from courseStructure() (see Ids).
π As a studentβ
| Example | What it does |
|---|
| A weekly agenda | Courses in progress, deadlines of the week, what's pending, unread notifications |
| Download a course's files | Every file and folder of a course, saved in a folder per section |
| Read a course's content | Pages and books at a person's pace, marked done where the course asks |
| Submit an assignment | Online text and a file, submitted for grading, the statement accepted by the person |
| Answer a quiz | An attempt page by page, finished, its review printed |
| Surveys and choices | A feedback or questionnaire survey, and a choice |
π§βπ« As a teacherβ
π οΈ For your programβ
| Example | What it does |
|---|
| Errors and sessions | A program that logs in again when the session ends and reports errors by code |
| Several sites | One object per site and person, and showing the browser while someone watches |
| Moodle services | What the driver doesn't wrap: Moodle's AJAX services, pages and forms, and limiting what may be called |
| Testing your program | Tests against the fake Moodle, without a real site |