Repository navigation
v0.3.0
A command for the whole API, Moodle's services over plain HTTP, and a friendlier API. Several changes break 0.2 programs: see Breaking changes.
Install
Not on npm yet: the package is attached to this release, built.
npm i -g https://github.com/falkenslab/moodle-driver/releases/download/v0.3.0/falkenslab-moodle-driver-0.3.0.tgz # the moodle command
npm install https://github.com/falkenslab/moodle-driver/releases/download/v0.3.0/falkenslab-moodle-driver-0.3.0.tgz playwright-core # the libraryNew
- The
moodlecommand. Every method of the Moodle object from a terminal:moodle login --site …once, thenmoodle list-courses,moodle my-grades 3 --json,moodle grade-submission 35 7 --grade 8.5 --notify… 81 commands generated from the API's types, so none is missing; tables at a terminal, JSON for scripts, errors with their code and exit status,--allowto limit the data categories,--showto watch the browser. See the command line and the commands. - Sites and accounts. The command keeps everything in
~/.moodle-driveron every system: a folder per site, a named profile per account (moodle login --as student), the site's default in itssite.json; a first login names its profile after the Moodle username.moodle siteslists them,moodle forgetdeletes one.siteProfileDir(site)lets a program share the command's sessions. - Moodle's services over HTTP.
callServiceposts tolib/ajax/service.phpwith the profile's session and its sesskey, without a tab; the kept service tab is gone. Pages and forms stay in tabs: measured, Moodle's server takes most of their time (ADR-011).fetchSitePage,readMoodleConfigandhtmlSessionFactsin/internalsread a page over HTTP. - Friendlier calls:
activityContent(activity)takes an activity as the course structure gives it;deadlines()andlogIn()need no options object;gradeSubmissiontakes a numeric grade; the Moodle object works withawait using. - Documentation: 17 complete, commented use-case examples (student, teacher, programs), a glossary of Moodle's terms, diagrams, a new logo, and every example compiled against the code (
npm run docs:check, also in CI). The site now lives at https://falkenslab.github.io/moodle-driver/ (no/docs).
Breaking changes
| Was (0.2) | Now |
|---|---|
MoodleDriverError |
MoodleError (same codes and subclasses) |
moodle-driver-session.json in the profile |
moodle-session.json: profiles from 0.2 log in once more |
courseStructure(id) → { course, sections } |
the sections, CourseSection[] |
assignmentSubmissions(id) → { assignment, submissions } |
the submissions, Submission[] |
callService from a kept tab |
over HTTP; nothing to change in calls |
Fixes
- The Moodle object's
answerQuizQuestionsis typed withchanged, which the function returned already. pause()no longer reports the same second twice when a timer fires a millisecond early.
Internal
- ADR-011 (services over HTTP, pages in tabs, with the timings), ADR-012 (the command in the package), ADR-013 (one home for sites and sessions).
scripts/benchmark-reads.mtsmeasures reads on any site;scripts/generate-cli-commands.mjskeeps the command table in step with the types.
Documentation: https://falkenslab.github.io/moodle-driver/