Skip to content

v0.3.0

Choose a tag to compare

@fvarrui fvarrui released this 11 Oct 10:58
· 261 commits to main since this release

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 library

New

  • The moodle command. Every method of the Moodle object from a terminal: moodle login --site … once, then moodle 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, --allow to limit the data categories, --show to watch the browser. See the command line and the commands.
  • Sites and accounts. The command keeps everything in ~/.moodle-driver on every system: a folder per site, a named profile per account (moodle login --as student), the site's default in its site.json; a first login names its profile after the Moodle username. moodle sites lists them, moodle forget deletes one. siteProfileDir(site) lets a program share the command's sessions.
  • Moodle's services over HTTP. callService posts to lib/ajax/service.php with 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, readMoodleConfig and htmlSessionFacts in /internals read a page over HTTP.
  • Friendlier calls: activityContent(activity) takes an activity as the course structure gives it; deadlines() and logIn() need no options object; gradeSubmission takes a numeric grade; the Moodle object works with await 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 answerQuizQuestions is typed with changed, 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.mts measures reads on any site; scripts/generate-cli-commands.mjs keeps the command table in step with the types.

Documentation: https://falkenslab.github.io/moodle-driver/