Saltar al contenido principal

Interface: Moodle

Defined in: client.ts:233

One Moodle site worked through one browser: the driver's operations as methods, without the browser context and the site the functions take first (moodle.listCourses() is listCourses(context, site)), plus the session and the browser. The pieces the operations are built from stay functions only.

Extends​

Properties​

PropertyModifierTypeDescriptionDefined in
browserreadonlyBrowserManagerThe browser manager underneath, for what the methods don't cover.client.ts:237
defaultsreadonlyReadonly<MoodleDefaults>The defaults the object was made with.client.ts:239
sitereadonlystringThe site's base URL, normalized (a trailing slash).client.ts:235

Methods​

[asyncDispose]()​

asyncDispose: Promise<void>;

Defined in: client.ts:276

close(), so await using moodle = createMoodle(…) closes the browser when the block ends.

Returns​

Promise<void>


activitiesOverview()​

activitiesOverview(courseId, type?): Promise<object[]>;

Defined in: moodle-methods.generated.ts:15

Moodle 5's activities overview of a course for one type ("resource" for every resource type): per activity, the columns its overview page shows the person (due dates, submissions, what needs grading, their own grade…). Without a type, every type in the course's state: "resource" first, which brings pages, books, files, folders and links at once, then each type still missing.

Parameters​

ParameterType
courseIdnumber
type?string

Returns​

Promise<object[]>

Inherited from​

MoodleMethods.activitiesOverview


activityContent()​

Call Signature​

activityContent(activity, options?): Promise<ActivityContent>;

Defined in: client.ts:253

activityContent, at the object's trail unless given.

Parameters​
ParameterType
activity{ id: number; type: string; }
activity.idnumber
activity.type?string
options?PaceOptions<(secondsRead) => void>
Returns​

Promise<ActivityContent>

Call Signature​

activityContent(
activityId,
type,
options?
): Promise<ActivityContent>;

Defined in: client.ts:254

Parameters​
ParameterType
activityIdnumber
type"page" | "book" | "label" | "url" | "resource" | "folder"
options?PaceOptions<(secondsRead) => void>
Returns​

Promise<ActivityContent>


activityReport()​

activityReport(courseId, options?): Promise<ActivityViews[]>;

Defined in: moodle-methods.generated.ts:21

A course's activity report: per activity, how many times it was viewed, by how many people, and when last, from the logs (between from and until when given). Activities nobody viewed come with zero views.

Parameters​

ParameterType
courseIdnumber
options?{ from?: Date; until?: Date; }
options.from?Date
options.until?Date

Returns​

Promise<ActivityViews[]>

Inherited from​

MoodleMethods.activityReport


activitySettings()​

activitySettings(activityId): Promise<{
completion: Completion | undefined;
courseId: number;
description: string;
fields: FormField[];
files: DraftFile[] | undefined;
id: number;
module: string;
name: string;
restrictions: Restrictions | undefined;
}>;

Defined in: moodle-methods.generated.ts:27

An activity's settings as its form holds them, without submitting it: its module, name and description, every field by the name updateActivity takes in settings, the files of a resource, folder or SCORM, and its restrictions and completion in plain terms. Teachers only.

Parameters​

ParameterType
activityIdnumber

Returns​

Promise<{ completion: Completion | undefined; courseId: number; description: string; fields: FormField[]; files: DraftFile[] | undefined; id: number; module: string; name: string; restrictions: Restrictions | undefined; }>

Inherited from​

MoodleMethods.activitySettings


addGradeCategory()​

addGradeCategory(courseId, options): Promise<{
category?: GradebookCategory;
changed: string;
}>;

Defined in: moodle-methods.generated.ts:29

Adds a grade category (at the course's top level, or inside parentId); returns it as the setup shows it.

Parameters​

ParameterType
courseIdnumber
options{ aggregation?: | "mode" | "mean" | "median" | "lowest" | "highest" | "weighted-mean" | "simple-weighted-mean" | "mean-with-extra-credits" | "natural"; name: string; parentId?: number; }
options.aggregation?| "mode" | "mean" | "median" | "lowest" | "highest" | "weighted-mean" | "simple-weighted-mean" | "mean-with-extra-credits" | "natural"
options.namestring
options.parentId?number

Returns​

Promise<{ category?: GradebookCategory; changed: string; }>

Inherited from​

MoodleMethods.addGradeCategory


addGradeItem()​

addGradeItem(courseId, options): Promise<{
changed: string;
item?: GradebookItem;
}>;

Defined in: moodle-methods.generated.ts:35

Adds a manual grade item (one graded in the gradebook, not by an activity): out of maxGrade (Moodle's default, 100, when left out) or on a scale (scaleId), at the course's top level or in categoryId, hidden from students when asked. Returns it as the setup shows it.

Parameters​

ParameterType
courseIdnumber
options{ categoryId?: number; hidden?: boolean; maxGrade?: number; name: string; scaleId?: number; }
options.categoryId?number
options.hidden?boolean
options.maxGrade?number
options.namestring
options.scaleId?number

Returns​

Promise<{ changed: string; item?: GradebookItem; }>

Inherited from​

MoodleMethods.addGradeItem


addQuestionsToQuiz()​

addQuestionsToQuiz(activityId, options): Promise<QuizChange>;

Defined in: moodle-methods.generated.ts:41

Adds bank questions to a quiz by id, and random questions from a bank category, at the end or on a page, as the edit page's bank actions post them. Returns the quiz's structure afterwards. A quiz already attempted can't change its questions: Moodle refuses, and so does this.

Parameters​

ParameterType
activityIdnumber
options{ page?: number; questionIds?: number[]; random?: { categoryId: number; count: number; includeSubcategories?: boolean; }; }
options.page?number
options.questionIds?number[]
options.random?{ categoryId: number; count: number; includeSubcategories?: boolean; }
options.random.categoryIdnumber
options.random.countnumber
options.random.includeSubcategories?boolean

Returns​

Promise<QuizChange>

Inherited from​

MoodleMethods.addQuestionsToQuiz


addQuizSection()​

addQuizSection(activityId, options): Promise<QuizChange & object>;

Defined in: moodle-methods.generated.ts:47

Adds a section to a quiz starting at a slot, with its heading and whether its questions are shuffled, as the edit page's "Add a new section heading" and its heading and shuffle controls do. A section starts at a page: the slot must be the first of its page (see setQuizPages).

Parameters​

ParameterType
activityIdnumber
options{ firstSlot: number; heading: string; shuffle?: boolean; }
options.firstSlotnumber
options.headingstring
options.shuffle?boolean

Returns​

Promise<QuizChange & object>

Inherited from​

MoodleMethods.addQuizSection


addSection()​

addSection(courseId, options?): Promise<CourseChange>;

Defined in: moodle-methods.generated.ts:52

Adds a section after another one (at the end without it), named when a name is given, with a description (HTML) when summary is, and embed's local files in it (<img src="shot.png">).

Parameters​

ParameterType
courseIdnumber
options?{ afterSectionId?: number; embed?: string[]; name?: string; summary?: string; }
options.afterSectionId?number
options.embed?string[]
options.name?string
options.summary?string

Returns​

Promise<CourseChange>

Inherited from​

MoodleMethods.addSection


allocateMarker()​

allocateMarker(
activityId,
userIds,
markerId
): Promise<{
changed: string;
}>;

Defined in: moodle-methods.generated.ts:59

Allocates a marker (the user id of someone who can grade; several where the assignment uses several markers per submission) to participants' submissions, as the grading table's "Allocate marker" does. Moodle leaves alone submissions past marking (marking completed, in review, ready for release, released).

Parameters​

ParameterType
activityIdnumber
userIdsnumber[]
markerIdnumber | number[]

Returns​

Promise<{ changed: string; }>

Inherited from​

MoodleMethods.allocateMarker


anonymizeBackup()​

anonymizeBackup(file, destFile): Promise<{
changed: string;
cleared: BackupIdentifier[];
file: {
name: string;
path: string;
size: number;
};
}>;

Defined in: client.ts:249

A copy of a backup file that names no one and no site, written on this computer without the browser or a session (anonymizeBackup).

Parameters​

ParameterType
filestring
destFilestring

Returns​

Promise<{ changed: string; cleared: BackupIdentifier[]; file: { name: string; path: string; size: number; }; }>


answerChoice()​

answerChoice(activityId, optionIds): Promise<{
changed: string;
choice: Choice;
}>;

Defined in: moodle-methods.generated.ts:61

Answers a choice with one option (several where it allows them) by id, as "Save my choice" does; returns the choice afterwards.

Parameters​

ParameterType
activityIdnumber
optionIdsnumber[]

Returns​

Promise<{ changed: string; choice: Choice; }>

Inherited from​

MoodleMethods.answerChoice


answerLessonPage()​

answerLessonPage(
activityId,
answer,
options?
): Promise<{
changed: string;
feedback?: LessonPage;
page: LessonPage;
}>;

Defined in: client.ts:258

answerLessonPage, at the object's trail unless given.

Parameters​

ParameterType
activityIdnumber
answer{ button?: string | number; responses?: Record<string, string>; }
answer.button?string | number
answer.responses?Record<string, string>
options?PaceOptions<(elapsed, total) => void>

Returns​

Promise<{ changed: string; feedback?: LessonPage; page: LessonPage; }>


answerQuizQuestions()​

answerQuizQuestions(
attemptId,
answers,
options?
): Promise<{
attemptId: number;
changed: string;
questions: Question[];
}>;

Defined in: client.ts:256

answerQuizQuestions, at the object's trail unless given.

Parameters​

ParameterType
attemptIdnumber
answersobject[]
options?PaceOptions<(elapsed, total) => void>

Returns​

Promise<{ attemptId: number; changed: string; questions: Question[]; }>


assessWorkshopSubmission()​

assessWorkshopSubmission(
activityId,
submissionId,
options
): Promise<{
assessmentId: number;
changed: string;
grade?: number;
maxGrade?: number;
}>;

Defined in: moodle-methods.generated.ts:73

Assesses a submission as the person, through the workshop's assessment form (its grading strategy's: accumulative, comments, number of errors or rubric), as "Assess" on the submission's page and the form do: a teacher who hasn't assessed it yet gets an assessment of their own, and one already made is changed. criteria go in the form's order; feedback is the overall feedback for the author (HTML), where the workshop has it on; fields sets any other field of the form by name (weight…). Returns a sentence of what changed, the assessment's id, and the grade it gives the submission out of the workshop's grade. Throws WorkshopError outside the assessment phase, when a criterion's grade isn't one it takes, or when the workshop has no overall feedback; FormError when Moodle refuses the form (a criterion left without a grade).

Parameters​

ParameterType
activityIdnumber
submissionIdnumber
options{ criteria?: WorkshopCriterion[]; feedback?: string; fields?: Record<string, FieldValue>; }
options.criteria?WorkshopCriterion[]
options.feedback?string
options.fields?Record<string, FieldValue>

Returns​

Promise<{ assessmentId: number; changed: string; grade?: number; maxGrade?: number; }>

Inherited from​

MoodleMethods.assessWorkshopSubmission


assignmentSubmissions()​

Call Signature​

assignmentSubmissions(activityId, options): Promise<ListPage<Submission>>;

Defined in: moodle-methods.generated.ts:86

Every participant's submission to an assignment, with the group they submit for (group submissions), and, unless includeContent is false, its content, the feedback files they have, its marking workflow state and markers (all from each participant's grading panel). Those come only for participants with a submission: Moodle's grading panel creates an empty one for a participant who has none, so reading leaves them at "none", without the panel's details (confirmed empirically on the sandbox, 5.2). For a participant with a submission and no grade yet, the panel still leaves an empty grade (-1, not graded) and a "Grading form viewed" event, as Moodle's grader does. Only some participants when given their userIds; with limit, a page of them in the grader's order (see "Long lists" in the docs' concepts): Moodle's service lists every participant at once, cut to the page, and only the page's participants are read further (their dates, their panels).

Parameters​
ParameterType
activityIdnumber
optionsWithLimit<SubmissionOptions>
Returns​

Promise<ListPage<Submission>>

Inherited from​

MoodleMethods.assignmentSubmissions

Call Signature​

assignmentSubmissions(activityId, options?): Promise<Submission[]>;

Defined in: moodle-methods.generated.ts:99

Every participant's submission to an assignment, with the group they submit for (group submissions), and, unless includeContent is false, its content, the feedback files they have, its marking workflow state and markers (all from each participant's grading panel). Those come only for participants with a submission: Moodle's grading panel creates an empty one for a participant who has none, so reading leaves them at "none", without the panel's details (confirmed empirically on the sandbox, 5.2). For a participant with a submission and no grade yet, the panel still leaves an empty grade (-1, not graded) and a "Grading form viewed" event, as Moodle's grader does. Only some participants when given their userIds; with limit, a page of them in the grader's order (see "Long lists" in the docs' concepts): Moodle's service lists every participant at once, cut to the page, and only the page's participants are read further (their dates, their panels).

Parameters​
ParameterType
activityIdnumber
options?WithoutLimit<SubmissionOptions>
Returns​

Promise<Submission[]>

Inherited from​

MoodleMethods.assignmentSubmissions

Call Signature​

assignmentSubmissions(activityId, options?): Promise<
| ListPage<Submission>
| Submission[]>;

Defined in: moodle-methods.generated.ts:112

Every participant's submission to an assignment, with the group they submit for (group submissions), and, unless includeContent is false, its content, the feedback files they have, its marking workflow state and markers (all from each participant's grading panel). Those come only for participants with a submission: Moodle's grading panel creates an empty one for a participant who has none, so reading leaves them at "none", without the panel's details (confirmed empirically on the sandbox, 5.2). For a participant with a submission and no grade yet, the panel still leaves an empty grade (-1, not graded) and a "Grading form viewed" event, as Moodle's grader does. Only some participants when given their userIds; with limit, a page of them in the grader's order (see "Long lists" in the docs' concepts): Moodle's service lists every participant at once, cut to the page, and only the page's participants are read further (their dates, their panels).

Parameters​
ParameterType
activityIdnumber
options?SubmissionOptions
Returns​

Promise< | ListPage<Submission> | Submission[]>

Inherited from​

MoodleMethods.assignmentSubmissions


backupContents()​

backupContents(file): Promise<BackupContents>;

Defined in: client.ts:247

What a backup file (.mbz) holds and what its activities refer to outside it, read on this computer without the browser or a session (backupContents).

Parameters​

ParameterType
filestring

Returns​

Promise<BackupContents>


backupCourse()​

backupCourse(
courseId,
destDir,
options?
): Promise<{
changed: string;
file: DownloadedFile;
}>;

Defined in: moodle-methods.generated.ts:132

Backs a course up to a .mbz file, through Moodle's backup wizard (initial settings, schema, confirmation), and downloads it into destDir. Without users' data unless withUsers, which needs moodle/backup:userinfo (anonymize makes their names anonymous). An asynchronous backup is waited for up to timeoutMs (ten minutes). Moodle keeps the file in the course's or the person's backup area too.

With sections (section ids) or activities (course module ids: activities and resources), only those go in: a section with everything in it, an activity alone (with its section's name, which Moodle needs for it). A selection never carries people's data, nor what belongs to the course rather than to its content (blocks, filters, badges, course events, groups, competencies, custom fields, content bank, legacy files); the file is read afterwards to check that it holds what was asked and no people's data.

anonymous (the default for a selection, not for a whole course) makes the file name no one and no site, through anonymizeBackup: no user ids or authors, a neutral site, course and file name. It's then saved as backup-moodle2-anonymous-<date>.mbz; the copy Moodle keeps in its backup area stays as Moodle made it. anonymous: false keeps what Moodle wrote.

Parameters​

ParameterType
courseIdnumber
destDirstring
options?{ activities?: number[]; anonymize?: boolean; anonymous?: boolean; sections?: number[]; timeoutMs?: number; withUsers?: boolean; }
options.activities?number[]
options.anonymize?boolean
options.anonymous?boolean
options.sections?number[]
options.timeoutMs?number
options.withUsers?boolean

Returns​

Promise<{ changed: string; file: DownloadedFile; }>

Inherited from​

MoodleMethods.backupCourse


calendarEvent()​

calendarEvent(eventId): Promise<CalendarEvent>;

Defined in: moodle-methods.generated.ts:134

One calendar event by its id, as upcomingEvents gives them.

Parameters​

ParameterType
eventIdnumber

Returns​

Promise<CalendarEvent>

Inherited from​

MoodleMethods.calendarEvent


callService()​

callService<T>(methodname, args): Promise<T>;

Defined in: client.ts:251

Calls one of Moodle's AJAX services as the logged-in person.

Type Parameters​

Type Parameter
T

Parameters​

ParameterType
methodnamestring
argsRecord<string, unknown>

Returns​

Promise<T>


close()​

close(): Promise<void>;

Defined in: client.ts:274

Saves the session and closes the browser; the next call opens it again.

Returns​

Promise<void>


completionReport()​

completionReport(courseId, options?): Promise<CompletionReport>;

Defined in: moodle-methods.generated.ts:141

A course's progress report: every participant's completion of every activity that tracks it, page by page, in one group when given, only some people's when given their userIds (the report has no filter by user: its pages are read until all of them are found). People come as user id and full name only.

Parameters​

ParameterType
courseIdnumber
options?{ group?: number; userIds?: number[]; }
options.group?number
options.userIds?number[]

Returns​

Promise<CompletionReport>

Inherited from​

MoodleMethods.completionReport


context()​

context(): Promise<BrowserContext>;

Defined in: client.ts:241

The browser's context, launching it if needed: what the functions take.

Returns​

Promise<BrowserContext>


conversation()​

Call Signature​

conversation(conversationId, options): Promise<Conversation<ListPage<ConversationMessage>>>;

Defined in: moodle-methods.generated.ts:149

A conversation's messages, oldest first, as text, and its members as conversations() gives them: everyone but the person, whether they wrote in it or not (the person alone in their own conversation). With limit, messages is a page of them (see "Long lists" in the docs' concepts) counted from the newest: the first page is the latest messages, more says there are older ones, and each page's messages still come oldest first. Moodle's service returns only the page.

Parameters​
ParameterType
conversationIdnumber
optionsWithLimit<PageOptions>
Returns​

Promise<Conversation<ListPage<ConversationMessage>>>

Inherited from​

MoodleMethods.conversation

Call Signature​

conversation(conversationId, options?): Promise<Conversation<ConversationMessage[]>>;

Defined in: moodle-methods.generated.ts:157

A conversation's messages, oldest first, as text, and its members as conversations() gives them: everyone but the person, whether they wrote in it or not (the person alone in their own conversation). With limit, messages is a page of them (see "Long lists" in the docs' concepts) counted from the newest: the first page is the latest messages, more says there are older ones, and each page's messages still come oldest first. Moodle's service returns only the page.

Parameters​
ParameterType
conversationIdnumber
options?WithoutLimit<PageOptions>
Returns​

Promise<Conversation<ConversationMessage[]>>

Inherited from​

MoodleMethods.conversation

Call Signature​

conversation(conversationId, options?): Promise<Conversation<
| ConversationMessage[]
| ListPage<ConversationMessage>>>;

Defined in: moodle-methods.generated.ts:165

A conversation's messages, oldest first, as text, and its members as conversations() gives them: everyone but the person, whether they wrote in it or not (the person alone in their own conversation). With limit, messages is a page of them (see "Long lists" in the docs' concepts) counted from the newest: the first page is the latest messages, more says there are older ones, and each page's messages still come oldest first. Moodle's service returns only the page.

Parameters​
ParameterType
conversationIdnumber
options?PageOptions
Returns​

Promise<Conversation< | ConversationMessage[] | ListPage<ConversationMessage>>>

Inherited from​

MoodleMethods.conversation


conversations()​

Call Signature​

conversations(options): Promise<ListPage<ConversationSummary>>;

Defined in: moodle-methods.generated.ts:170

The person's conversations, latest first, with their last message as text. With limit, a page of them (see "Long lists" in the docs' concepts), the only ones Moodle's service returns.

Parameters​
ParameterType
optionsWithLimit<PageOptions>
Returns​

Promise<ListPage<ConversationSummary>>

Inherited from​

MoodleMethods.conversations

Call Signature​

conversations(options?): Promise<ConversationSummary[]>;

Defined in: moodle-methods.generated.ts:175

The person's conversations, latest first, with their last message as text. With limit, a page of them (see "Long lists" in the docs' concepts), the only ones Moodle's service returns.

Parameters​
ParameterType
options?WithoutLimit<PageOptions>
Returns​

Promise<ConversationSummary[]>

Inherited from​

MoodleMethods.conversations

Call Signature​

conversations(options?): Promise<
| ListPage<ConversationSummary>
| ConversationSummary[]>;

Defined in: moodle-methods.generated.ts:180

The person's conversations, latest first, with their last message as text. With limit, a page of them (see "Long lists" in the docs' concepts), the only ones Moodle's service returns.

Parameters​
ParameterType
options?PageOptions
Returns​

Promise< | ListPage<ConversationSummary> | ConversationSummary[]>

Inherited from​

MoodleMethods.conversations


copyCourse()​

copyCourse(courseId, options): Promise<{
changed: string;
course: CourseRef;
}>;

Defined in: moodle-methods.generated.ts:189

Copies a course into a new one, as Moodle's "Copy course" does: its content (and its people's data and enrolments, withUsers), under a new full and short name, in a category (the course's unless given), with new dates. Goes through Moodle's copy service, then waits for the copy, which Moodle makes in its scheduled tasks, up to timeoutMs (ten minutes). Needs the rights to back up, restore and create courses (moodle/backup:backupcourse, moodle/restore:restorecourse, moodle/course:create); without them, BackupError says so.

Parameters​

ParameterType
courseIdnumber
options{ categoryId?: number; end?: Date; fullName: string; shortName: string; start?: Date; timeoutMs?: number; visible?: boolean; withUsers?: boolean; }
options.categoryId?number
options.end?Date
options.fullNamestring
options.shortNamestring
options.start?Date
options.timeoutMs?number
options.visible?boolean
options.withUsers?boolean

Returns​

Promise<{ changed: string; course: CourseRef; }>

Inherited from​

MoodleMethods.copyCourse


courseAbilities()​

courseAbilities(courseId, sectionId): Promise<{
canEdit: boolean;
canGrade: boolean;
}>;

Defined in: moodle-methods.generated.ts:195

What the person can do in a course, asked of read-only services that need the capability: the activity types they can add (none without moodle/course:manageactivities) and the grader report's users (nopermissions without gradereport/grader:view). Nothing is changed.

Parameters​

ParameterType
courseIdnumber
sectionIdnumber

Returns​

Promise<{ canEdit: boolean; canGrade: boolean; }>

Inherited from​

MoodleMethods.courseAbilities


courseActivityTypes()​

courseActivityTypes(courseId): Promise<object[]>;

Defined in: moodle-methods.generated.ts:197

The activity and resource types the person can add to a course: none when they can't edit it.

Parameters​

ParameterType
courseIdnumber

Returns​

Promise<object[]>

Inherited from​

MoodleMethods.courseActivityTypes


courseLogs()​

Call Signature​

courseLogs(courseId, options): Promise<ListPage<LogEntry>>;

Defined in: moodle-methods.generated.ts:207

A course's logs, newest first, as its logs report lists them: by a user, an activity, a kind of action, and a time span, up to limit entries (100 unless given). Moodle filters by user, activity and action; the span is read page by page, stopping at the first entry older than from. Every entry's time comes as an ISO date, read back with the site language's own format. Without limit, the first 100 entries (from offset) as a list; with it, a page of them (see "Long lists" in the docs' concepts), from the report's page that holds offset on (without until; with it, from the first page, since only the driver filters by it).

Parameters​
ParameterType
courseIdnumber
optionsWithLimit<CourseLogOptions>
Returns​

Promise<ListPage<LogEntry>>

Inherited from​

MoodleMethods.courseLogs

Call Signature​

courseLogs(courseId, options?): Promise<LogEntry[]>;

Defined in: moodle-methods.generated.ts:217

A course's logs, newest first, as its logs report lists them: by a user, an activity, a kind of action, and a time span, up to limit entries (100 unless given). Moodle filters by user, activity and action; the span is read page by page, stopping at the first entry older than from. Every entry's time comes as an ISO date, read back with the site language's own format. Without limit, the first 100 entries (from offset) as a list; with it, a page of them (see "Long lists" in the docs' concepts), from the report's page that holds offset on (without until; with it, from the first page, since only the driver filters by it).

Parameters​
ParameterType
courseIdnumber
options?WithoutLimit<CourseLogOptions>
Returns​

Promise<LogEntry[]>

Inherited from​

MoodleMethods.courseLogs

Call Signature​

courseLogs(courseId, options?): Promise<
| ListPage<LogEntry>
| LogEntry[]>;

Defined in: moodle-methods.generated.ts:227

A course's logs, newest first, as its logs report lists them: by a user, an activity, a kind of action, and a time span, up to limit entries (100 unless given). Moodle filters by user, activity and action; the span is read page by page, stopping at the first entry older than from. Every entry's time comes as an ISO date, read back with the site language's own format. Without limit, the first 100 entries (from offset) as a list; with it, a page of them (see "Long lists" in the docs' concepts), from the report's page that holds offset on (without until; with it, from the first page, since only the driver filters by it).

Parameters​
ParameterType
courseIdnumber
options?CourseLogOptions
Returns​

Promise< | ListPage<LogEntry> | LogEntry[]>

Inherited from​

MoodleMethods.courseLogs


courseRoles()​

courseRoles(userId, courseId): Promise<object[]>;

Defined in: moodle-methods.generated.ts:229

A user's roles in a course, from their profile there: role links carry the role id in any language.

Parameters​

ParameterType
userIdnumber
courseIdnumber

Returns​

Promise<object[]>

Inherited from​

MoodleMethods.courseRoles


courseStructure()​

courseStructure(courseId, options?): Promise<CourseSection[]>;

Defined in: moodle-methods.generated.ts:234

A course's sections and activities; with details, each activity's dates and restriction and each section's description, from the course page (slower).

Parameters​

ParameterType
courseIdnumber
options?{ details?: boolean; }
options.details?boolean

Returns​

Promise<CourseSection[]>

Inherited from​

MoodleMethods.courseStructure


courseUpdates()​

courseUpdates(courseId, since): Promise<object[]>;

Defined in: moodle-methods.generated.ts:236

What changed in a course's activities since a date, with their names from the course's state.

Parameters​

ParameterType
courseIdnumber
sinceDate

Returns​

Promise<object[]>

Inherited from​

MoodleMethods.courseUpdates


createActivity()​

createActivity(input): Promise<CourseChange>;

Defined in: moodle-methods.generated.ts:243

Creates an activity or resource of any type at the end of a section, through Moodle's own form, hidden from students unless visibility says otherwise. files are local paths uploaded to a file resource or folder (a DraftUpload puts one in a folder's subfolder); a SCORM (type: "scorm") or an H5P activity (type: "h5pactivity") takes the first as its package.

Parameters​

ParameterType
inputActivityFields & object

Returns​

Promise<CourseChange>

Inherited from​

MoodleMethods.createActivity


createEvent()​

createEvent(options): Promise<{
changed: string;
event: CalendarEvent;
}>;

Defined in: moodle-methods.generated.ts:248

Creates a course event, through the calendar's own form: its start, and its duration and description when given. Returns it as the calendar has it.

Parameters​

ParameterType
options{ courseId: number; description?: string; durationMinutes?: number; name: string; start: Date; }
options.courseIdnumber
options.description?string
options.durationMinutes?number
options.namestring
options.startDate

Returns​

Promise<{ changed: string; event: CalendarEvent; }>

Inherited from​

MoodleMethods.createEvent


createGroup()​

createGroup(courseId, settings): Promise<{
changed: string;
groupId: number;
}>;

Defined in: moodle-methods.generated.ts:253

Creates a group in a course with its group form (group/group.php). Throws FormError with Moodle's reason when it refuses (a name already used, an enrolment key another group has).

Parameters​

ParameterType
courseIdnumber
settingsGroupSettings & object

Returns​

Promise<{ changed: string; groupId: number; }>

Inherited from​

MoodleMethods.createGroup


createGrouping()​

createGrouping(courseId, settings): Promise<{
changed: string;
groupingId: number;
}>;

Defined in: moodle-methods.generated.ts:255

Creates a grouping in a course with its form (group/grouping.php); add its groups with setGroupingGroups.

Parameters​

ParameterType
courseIdnumber
settingsGroupingSettings & object

Returns​

Promise<{ changed: string; groupingId: number; }>

Inherited from​

MoodleMethods.createGrouping


createQuestion()​

createQuestion(activityId, input): Promise<{
changed: string;
questionId?: number;
}>;

Defined in: moodle-methods.generated.ts:260

Creates one question in a bank through its type's edit form; returns its id. Imports are the way for several; this is for one-offs.

Parameters​

ParameterType
activityIdnumber
inputQuestionInput

Returns​

Promise<{ changed: string; questionId?: number; }>

Inherited from​

MoodleMethods.createQuestion


deadlines()​

deadlines(options?): Promise<object[]>;

Defined in: moodle-methods.generated.ts:266

What the person has to do by a date (calendar action events: submit, attempt, grade…), from the last pastDays to days ahead, in one course or all. Teachers' grading counts come from the activities overview instead: Moodle gives them few action events.

Parameters​

ParameterType
options?{ courseId?: number; days?: number; pastDays?: number; }
options.courseId?number
options.days?number
options.pastDays?number

Returns​

Promise<object[]>

Inherited from​

MoodleMethods.deadlines


deleteActivity()​

deleteActivity(courseId, activityId): Promise<CourseChange>;

Defined in: moodle-methods.generated.ts:268

Deletes an activity, with its participants' data (submissions, posts, attempts); gives the course afterwards.

Parameters​

ParameterType
courseIdnumber
activityIdnumber

Returns​

Promise<CourseChange>

Inherited from​

MoodleMethods.deleteActivity


deleteEvent()​

deleteEvent(eventId): Promise<{
changed: string;
}>;

Defined in: moodle-methods.generated.ts:270

Deletes a calendar event the person can manage.

Parameters​

ParameterType
eventIdnumber

Returns​

Promise<{ changed: string; }>

Inherited from​

MoodleMethods.deleteEvent


deleteGradeCategory()​

deleteGradeCategory(courseId, categoryId): Promise<{
changed: string;
}>;

Defined in: moodle-methods.generated.ts:275

Deletes a grade category. Moodle moves what it held (items and categories) into its parent and deletes the grades of its total; the course's own category can't be deleted.

Parameters​

ParameterType
courseIdnumber
categoryIdnumber

Returns​

Promise<{ changed: string; }>

Inherited from​

MoodleMethods.deleteGradeCategory


deleteGradeItem()​

deleteGradeItem(courseId, itemId): Promise<{
changed: string;
}>;

Defined in: moodle-methods.generated.ts:280

Deletes a manual grade item and its grades. An activity's item goes with its activity (Moodle would make it again), so it's refused.

Parameters​

ParameterType
courseIdnumber
itemIdnumber

Returns​

Promise<{ changed: string; }>

Inherited from​

MoodleMethods.deleteGradeItem


deleteGroup()​

deleteGroup(groupId): Promise<{
changed: string;
}>;

Defined in: moodle-methods.generated.ts:282

Deletes a group, as the groups page's "Delete selected group" does once confirmed; its members stay in the course.

Parameters​

ParameterType
groupIdnumber

Returns​

Promise<{ changed: string; }>

Inherited from​

MoodleMethods.deleteGroup


deleteGrouping()​

deleteGrouping(groupingId): Promise<{
changed: string;
}>;

Defined in: moodle-methods.generated.ts:284

Deletes a grouping, as its delete icon does once confirmed; its groups stay.

Parameters​

ParameterType
groupingIdnumber

Returns​

Promise<{ changed: string; }>

Inherited from​

MoodleMethods.deleteGrouping


deletePost()​

deletePost(postId): Promise<{
changed: string;
discussionDeleted: boolean;
discussionId?: number;
replies: number;
}>;

Defined in: moodle-methods.generated.ts:291

Deletes a post and its replies through Moodle's own confirmation (post.php?delete=); a discussion's first post takes the whole discussion. Only a moderator deletes a post with replies, or someone else's. replies says how many replies went with it. Throws ForumError with Moodle's reason when it refuses.

Parameters​

ParameterType
postIdnumber

Returns​

Promise<{ changed: string; discussionDeleted: boolean; discussionId?: number; replies: number; }>

Inherited from​

MoodleMethods.deletePost


deleteQuestions()​

deleteQuestions(activityId, questionIds): Promise<{
changed: string;
deleted: number[];
hidden: number[];
}>;

Defined in: moodle-methods.generated.ts:296

Deletes questions from a bank, every version of each, as the bank's delete action does: asked, then confirmed. Moodle doesn't delete a question a quiz uses: it hides it, and hidden lists those.

Parameters​

ParameterType
activityIdnumber
questionIdsnumber[]

Returns​

Promise<{ changed: string; deleted: number[]; hidden: number[]; }>

Inherited from​

MoodleMethods.deleteQuestions


deleteSection()​

deleteSection(courseId, sectionId): Promise<CourseChange>;

Defined in: moodle-methods.generated.ts:298

Deletes a section and every activity in it, with their participants' data.

Parameters​

ParameterType
courseIdnumber
sectionIdnumber

Returns​

Promise<CourseChange>

Inherited from​

MoodleMethods.deleteSection


discussion()​

Call Signature​

discussion(discussionId, options): Promise<DiscussionPosts<ListPage<ForumPost>>>;

Defined in: moodle-methods.generated.ts:305

A discussion's posts, oldest first, with their messages as text, and whether the person is subscribed to it (subscribed, undefined where they can't subscribe or it's forced). With limit, posts is a page of them (see "Long lists" in the docs' concepts): Moodle's service has no paging, so every post is read and cut, but only the page's messages are turned into text.

Parameters​
ParameterType
discussionIdnumber
optionsWithLimit<PageOptions>
Returns​

Promise<DiscussionPosts<ListPage<ForumPost>>>

Inherited from​

MoodleMethods.discussion

Call Signature​

discussion(discussionId, options?): Promise<DiscussionPosts<ForumPost[]>>;

Defined in: moodle-methods.generated.ts:312

A discussion's posts, oldest first, with their messages as text, and whether the person is subscribed to it (subscribed, undefined where they can't subscribe or it's forced). With limit, posts is a page of them (see "Long lists" in the docs' concepts): Moodle's service has no paging, so every post is read and cut, but only the page's messages are turned into text.

Parameters​
ParameterType
discussionIdnumber
options?WithoutLimit<PageOptions>
Returns​

Promise<DiscussionPosts<ForumPost[]>>

Inherited from​

MoodleMethods.discussion

Call Signature​

discussion(discussionId, options?): Promise<DiscussionPosts<
| ForumPost[]
| ListPage<ForumPost>>>;

Defined in: moodle-methods.generated.ts:319

A discussion's posts, oldest first, with their messages as text, and whether the person is subscribed to it (subscribed, undefined where they can't subscribe or it's forced). With limit, posts is a page of them (see "Long lists" in the docs' concepts): Moodle's service has no paging, so every post is read and cut, but only the page's messages are turned into text.

Parameters​
ParameterType
discussionIdnumber
options?PageOptions
Returns​

Promise<DiscussionPosts< | ForumPost[] | ListPage<ForumPost>>>

Inherited from​

MoodleMethods.discussion


downloadFile()​

downloadFile(url, destDir?): Promise<DownloadedFile>;

Defined in: client.ts:260

downloadFile, into the object's downloadDir unless given a folder.

Parameters​

ParameterType
urlstring
destDir?string

Returns​

Promise<DownloadedFile>


duplicateActivity()​

duplicateActivity(courseId, activityId): Promise<CourseChange>;

Defined in: moodle-methods.generated.ts:321

Duplicates an activity as the course page's "Duplicate" does (right after it, named with "(copy)"); gives the copy's id and the course afterwards.

Parameters​

ParameterType
courseIdnumber
activityIdnumber

Returns​

Promise<CourseChange>

Inherited from​

MoodleMethods.duplicateActivity


editActivity()​

editActivity(
courseId,
activityId,
options
): Promise<CourseChange>;

Defined in: moodle-methods.generated.ts:323

Renames, shows or hides, or moves an activity (to a section's end, or before another one).

Parameters​

ParameterType
courseIdnumber
activityIdnumber
options{ beforeActivityId?: number; name?: string; sectionId?: number; visibility?: "hidden" | "shown" | "stealth"; }
options.beforeActivityId?number
options.name?string
options.sectionId?number
options.visibility?"hidden" | "shown" | "stealth"

Returns​

Promise<CourseChange>

Inherited from​

MoodleMethods.editActivity


editPost()​

editPost(postId, changes): Promise<{
changed: string;
post?: ForumPost;
}>;

Defined in: moodle-methods.generated.ts:329

Changes a post through Moodle's own post form (post.php?edit=), as its author (within the site's editing time) or a moderator: only what's given changes. Returns the post afterwards. Throws ForumError with Moodle's reason when it refuses.

Parameters​

ParameterType
postIdnumber
changesPostChanges

Returns​

Promise<{ changed: string; post?: ForumPost; }>

Inherited from​

MoodleMethods.editPost


editQuizSlot()​

editQuizSlot(
activityId,
slot,
options
): Promise<QuizChange>;

Defined in: moodle-methods.generated.ts:335

Changes one slot of a quiz (by its place, from 1): its maximum mark, through the slots' service, and where it is, as dragging it on the edit page does: after another slot (moveAfter, 0 for first) and on a page. Moodle lets the mark change after attempts (it regrades them), not the rest.

Parameters​

ParameterType
activityIdnumber
slotnumber
options{ maxMark?: number; moveAfter?: number; page?: number; }
options.maxMark?number
options.moveAfter?number
options.page?number

Returns​

Promise<QuizChange>

Inherited from​

MoodleMethods.editQuizSlot


editSection()​

editSection(
courseId,
sectionId,
options
): Promise<CourseChange>;

Defined in: moodle-methods.generated.ts:340

Renames, shows or hides, describes (summary, HTML, with embed's local files in it), restricts (restrictions; { conditions: [] } removes them) or moves a section after another one.

Parameters​

ParameterType
courseIdnumber
sectionIdnumber
options{ afterSectionId?: number; embed?: string[]; name?: string; restrictions?: Restrictions; summary?: string; visible?: boolean; }
options.afterSectionId?number
options.embed?string[]
options.name?string
options.restrictions?Restrictions
options.summary?string
options.visible?boolean

Returns​

Promise<CourseChange>

Inherited from​

MoodleMethods.editSection


enrolmentMethods()​

enrolmentMethods(courseId): Promise<EnrolmentMethod[]>;

Defined in: moodle-methods.generated.ts:355

A course's enrolment methods, in the order Moodle tries them: each one's type, name, whether it's enabled and how many users it enrolled, and from its form the role it gives and, for self enrolment and guest access, whether it asks for a key (never the key), self enrolment's dates and limit. Throws EnrolmentError when the person can't manage the course's enrolment methods.

Parameters​

ParameterType
courseIdnumber

Returns​

Promise<EnrolmentMethod[]>

Inherited from​

MoodleMethods.enrolmentMethods


enrolUsers()​

enrolUsers(
courseId,
userIds,
options?
): Promise<{
changed: string;
count: number;
roleId?: number;
}>;

Defined in: moodle-methods.generated.ts:348

Enrols users in a course by manual enrolment, as the participants page's "Enrol users" dialog does: with roleId or the enrolment's default role, from start (now, unless given) until end (the enrolment's default duration, unless given). Users already enrolled keep their enrolment, with the new dates. Throws EnrolmentError with Moodle's reason when it refuses (a role the person can't assign, no manual enrolment).

Parameters​

ParameterType
courseIdnumber
userIdsnumber[]
options?{ end?: Date; roleId?: number; start?: Date; }
options.end?Date
options.roleId?number
options.start?Date

Returns​

Promise<{ changed: string; count: number; roleId?: number; }>

Inherited from​

MoodleMethods.enrolUsers


exportGrades()​

exportGrades(courseId, options): Promise<DownloadedFile>;

Defined in: client.ts:262

exportGrades, into the object's downloadDir unless given a folder.

Parameters​

ParameterType
courseIdnumber
optionsExportGradesOptions

Returns​

Promise<DownloadedFile>


finishQuizAttempt()​

finishQuizAttempt(attemptId): Promise<{
attemptId: number;
changed: string;
finished: true;
review: | {
questions: Question[];
summary: Detail[];
}
| undefined;
}>;

Defined in: moodle-methods.generated.ts:357

Submits an attempt for grading, and gives its review when the quiz shows it.

Parameters​

ParameterType
attemptIdnumber

Returns​

Promise<{ attemptId: number; changed: string; finished: true; review: | { questions: Question[]; summary: Detail[]; } | undefined; }>

Inherited from​

MoodleMethods.finishQuizAttempt


forumDiscussions()​

Call Signature​

forumDiscussions(activityId, options): Promise<ListPage<ForumDiscussion>>;

Defined in: moodle-methods.generated.ts:363

A forum's discussions, as its page lists them: who started each, replies, last post, the person's subscription. With limit, a page of them in the forum's order (see "Long lists" in the docs' concepts), read from the one page of the forum's own paging that holds it.

Parameters​
ParameterType
activityIdnumber
optionsWithLimit<PageOptions>
Returns​

Promise<ListPage<ForumDiscussion>>

Inherited from​

MoodleMethods.forumDiscussions

Call Signature​

forumDiscussions(activityId, options?): Promise<ForumDiscussion[]>;

Defined in: moodle-methods.generated.ts:369

A forum's discussions, as its page lists them: who started each, replies, last post, the person's subscription. With limit, a page of them in the forum's order (see "Long lists" in the docs' concepts), read from the one page of the forum's own paging that holds it.

Parameters​
ParameterType
activityIdnumber
options?WithoutLimit<PageOptions>
Returns​

Promise<ForumDiscussion[]>

Inherited from​

MoodleMethods.forumDiscussions

Call Signature​

forumDiscussions(activityId, options?): Promise<
| ListPage<ForumDiscussion>
| ForumDiscussion[]>;

Defined in: moodle-methods.generated.ts:375

A forum's discussions, as its page lists them: who started each, replies, last post, the person's subscription. With limit, a page of them in the forum's order (see "Long lists" in the docs' concepts), read from the one page of the forum's own paging that holds it.

Parameters​
ParameterType
activityIdnumber
options?PageOptions
Returns​

Promise< | ListPage<ForumDiscussion> | ForumDiscussion[]>

Inherited from​

MoodleMethods.forumDiscussions


forumGrades()​

forumGrades(activityId, options?): Promise<ForumGrades>;

Defined in: moodle-methods.generated.ts:382

Everyone's whole-forum grade in a forum graded as a whole, as its grader shows them: one per person it can grade (only the active ones when the forum says so), with how it's graded. One service call per person. Throws NotAForumError for another activity, and GradingError when the forum isn't graded as a whole or uses an advanced grading method.

Parameters​

ParameterType
activityIdnumber
options?{ groupId?: number; }
options.groupId?number

Returns​

Promise<ForumGrades>

Inherited from​

MoodleMethods.forumGrades


getChoice()​

getChoice(activityId): Promise<Choice>;

Defined in: moodle-methods.generated.ts:384

A choice: its options, whether it can be answered or changed, and the person's answer.

Parameters​

ParameterType
activityIdnumber

Returns​

Promise<Choice>

Inherited from​

MoodleMethods.getChoice


getSurvey()​

getSurvey(activityId, type?): Promise<{
canAnswer: boolean;
intro: string;
messages: string[];
questions: SurveyQuestion[];
}>;

Defined in: moodle-methods.generated.ts:386

A survey (questionnaire or feedback): whether it can be answered, its intro and messages, and its questions page by page. Its module is found when not given.

Parameters​

ParameterType
activityIdnumber
type?SurveyType

Returns​

Promise<{ canAnswer: boolean; intro: string; messages: string[]; questions: SurveyQuestion[]; }>

Inherited from​

MoodleMethods.getSurvey


gradebookSetup()​

gradebookSetup(courseId): Promise<{
categories: GradebookCategory[];
items: GradebookItem[];
}>;

Defined in: moodle-methods.generated.ts:413

A course's gradebook setup: its categories (aggregation, weights) and grade items (category, maximum, weight).

Parameters​

ParameterType
courseIdnumber

Returns​

Promise<{ categories: GradebookCategory[]; items: GradebookItem[]; }>

Inherited from​

MoodleMethods.gradebookSetup


gradeForumUser()​

gradeForumUser(
activityId,
userId,
options
): Promise<{
changed: string;
grade: Omit<ForumGrade, "fullName">;
}>;

Defined in: moodle-methods.generated.ts:394

Gives a person their whole-forum grade, as the forum's grader does: points (out of the forum's maximum), or a scale item by name or value; null takes the grade away. Moodle's forum grader has no feedback text. notify sends the person Moodle's notification, as the grader's checkbox does. Returns a sentence of what changed and the grade afterwards. Throws GradingError when the forum isn't graded as a whole, the grade is out of range or not on the scale, or Moodle refuses it.

Parameters​

ParameterType
activityIdnumber
userIdnumber
options{ grade: string | number | null; notify?: boolean; }
options.gradestring | number | null
options.notify?boolean

Returns​

Promise<{ changed: string; grade: Omit<ForumGrade, "fullName">; }>

Inherited from​

MoodleMethods.gradeForumUser


gradeQuizQuestion()​

gradeQuizQuestion(
attemptId,
slot,
options
): Promise<{
attemptId: number;
changed: string;
grade?: string;
mark: number;
maxMark?: number;
slot: number;
}>;

Defined in: moodle-methods.generated.ts:401

Grades one question of a finished attempt by hand, with a comment, through Moodle's comment form (the review's "Make comment or override mark"): an essay waiting for grading, or any question whose mark the teacher overrides. The mark is in the question's points (0 to its maximum in the quiz). Returns the attempt's grade afterwards when the results report shows it.

Parameters​

ParameterType
attemptIdnumber
slotnumber
options{ comment?: string; mark: number; }
options.comment?string
options.marknumber

Returns​

Promise<{ attemptId: number; changed: string; grade?: string; mark: number; maxMark?: number; slot: number; }>

Inherited from​

MoodleMethods.gradeQuizQuestion


graderReport()​

graderReport(courseId, options?): Promise<GraderReport>;

Defined in: moodle-methods.generated.ts:419

Everyone's grades in a course as the grader report shows them, page by page, in one group when given, only some people's rows when given their userIds (the report has no filter by user: its pages are read until all of them are found). People come as user id and full name only.

Parameters​

ParameterType
courseIdnumber
options?{ group?: number; userIds?: number[]; }
options.group?number
options.userIds?number[]

Returns​

Promise<GraderReport>

Inherited from​

MoodleMethods.graderReport


gradeSubmission()​

gradeSubmission(
activityId,
userId,
options
): Promise<{
changed: string;
feedback?: string;
feedbackFiles?: object[];
grade?: string;
gradebookGrade?: string;
workflowState?: | "notmarked"
| "inmarking"
| "readyforreview"
| "inreview"
| "readyforrelease"
| "released";
}>;

Defined in: moodle-methods.generated.ts:411

Grades a participant as the grader does: a grade (simple grading), a rubric's level per criterion or a marking guide's score per criterion (by their ids, from rubric()), remarks per criterion, feedback comments (HTML), feedback files (local paths that replace the ones the participant has; [] removes them), whether to notify, and any other grading field by name. Returns the grade saved and the gradebook's grade, the total Moodle computes for a rubric or a guide, and the feedback files after saving when they were given. Throws GradingError when Moodle refuses the grade, or when files are given to an assignment without feedback files.

Parameters​

ParameterType
activityIdnumber
userIdnumber
options{ applyToGroup?: boolean; feedback?: string; feedbackFiles?: string[]; fields?: Record<string, FieldValue>; grade?: string | number; guide?: Record<number, number>; notify?: boolean; remarks?: Record<number, string>; rubric?: Record<number, number>; workflowState?: | "notmarked" | "inmarking" | "readyforreview" | "inreview" | "readyforrelease" | "released"; }
options.applyToGroup?boolean
options.feedback?string
options.feedbackFiles?string[]
options.fields?Record<string, FieldValue>
options.grade?string | number
options.guide?Record<number, number>
options.notify?boolean
options.remarks?Record<number, string>
options.rubric?Record<number, number>
options.workflowState?| "notmarked" | "inmarking" | "readyforreview" | "inreview" | "readyforrelease" | "released"

Returns​

Promise<{ changed: string; feedback?: string; feedbackFiles?: object[]; grade?: string; gradebookGrade?: string; workflowState?: | "notmarked" | "inmarking" | "readyforreview" | "inreview" | "readyforrelease" | "released"; }>

Inherited from​

MoodleMethods.gradeSubmission


grantExtension()​

grantExtension(
activityId,
userIds,
until
): Promise<{
changed: string;
}>;

Defined in: moodle-methods.generated.ts:426

Grants participants an extension until a date, through the assignment's extension form (several at once as its bulk action does). Moodle refuses a date before the assignment's due date, and a person without its "grant extension" capability only on saving (the form opens for anyone, confirmed empirically on the sandbox, 5.2): both throw.

Parameters​

ParameterType
activityIdnumber
userIdsnumber[]
untilDate

Returns​

Promise<{ changed: string; }>

Inherited from​

MoodleMethods.grantExtension


groupings()​

groupings(courseId): Promise<Grouping[]>;

Defined in: moodle-methods.generated.ts:428

A course's groupings with their groups' ids, from its groupings page and each grouping's groups page. Throws MoodleError with Moodle's refusal for a person who can't manage groups.

Parameters​

ParameterType
courseIdnumber

Returns​

Promise<Grouping[]>

Inherited from​

MoodleMethods.groupings


groups()​

groups(courseId): Promise<CourseGroup[]>;

Defined in: moodle-methods.generated.ts:430

A course's groups the person can see, with their members' user ids.

Parameters​

ParameterType
courseIdnumber

Returns​

Promise<CourseGroup[]>

Inherited from​

MoodleMethods.groups


h5pActivity()​

h5pActivity(activityId): Promise<H5PActivity>;

Defined in: moodle-methods.generated.ts:432

An H5P activity: its content type, whether attempts are tracked, and the person's attempts with their scores.

Parameters​

ParameterType
activityIdnumber

Returns​

Promise<H5PActivity>

Inherited from​

MoodleMethods.h5pActivity


importActivities()​

importActivities(
fromCourseId,
toCourseId,
options?
): Promise<{
activityIds: number[];
changed: string;
}>;

Defined in: moodle-methods.generated.ts:440

Imports activities from another course into a course, as Moodle's "Import" does: every activity of fromCourseId, or only activityIds, added to toCourseId's content (with their sections), without users' data. Needs moodle/restore:restoretargetimport in the course imported into and moodle/backup:backuptargetimport in the other. Returns the activities the course has afterwards that it didn't have before, by id.

Parameters​

ParameterType
fromCourseIdnumber
toCourseIdnumber
options?{ activityIds?: number[]; }
options.activityIds?number[]

Returns​

Promise<{ activityIds: number[]; changed: string; }>

Inherited from​

MoodleMethods.importActivities


importQuestions()​

importQuestions(activityId, options): Promise<{
changed: string;
questions: BankQuestion[];
}>;

Defined in: moodle-methods.generated.ts:446

Imports questions into a bank from a GIFT or Moodle XML file (a local path) or text, through the bank's import form; returns the questions created. A file Moodle can't parse comes back as a QuestionBankError with its messages, and nothing is imported.

Parameters​

ParameterType
activityIdnumber
options{ categoryId?: number; file?: string; format: "gift" | "xml"; text?: string; }
options.categoryId?number
options.file?string
options.format"gift" | "xml"
options.text?string

Returns​

Promise<{ changed: string; questions: BankQuestion[]; }>

Inherited from​

MoodleMethods.importQuestions


lessonPage()​

lessonPage(activityId): Promise<LessonPage>;

Defined in: moodle-methods.generated.ts:448

The lesson page the person is on (starting the lesson the first time).

Parameters​

ParameterType
activityIdnumber

Returns​

Promise<LessonPage>

Inherited from​

MoodleMethods.lessonPage


listAssignments()​

listAssignments(courseId): Promise<CourseAssignment[]>;

Defined in: moodle-methods.generated.ts:450

The course's assignments, in the course's order, with the section each is in.

Parameters​

ParameterType
courseIdnumber

Returns​

Promise<CourseAssignment[]>

Inherited from​

MoodleMethods.listAssignments


listCourses()​

listCourses(classification?): Promise<Course[]>;

Defined in: moodle-methods.generated.ts:452

The courses the person is enrolled in, as teacher or student.

Parameters​

ParameterType
classification?"all" | "inprogress" | "future" | "past"

Returns​

Promise<Course[]>

Inherited from​

MoodleMethods.listCourses


logIn()​

logIn(options?): Promise<LoginResult>;

Defined in: client.ts:243

Makes sure there's a session: at once if there is one, else a window where the person logs in (loginTimeoutMs by default).

Parameters​

ParameterType
options?{ onWait?: (elapsedMs) => void; timeoutMs?: number; }
options.onWait?(elapsedMs) => void
options.timeoutMs?number

Returns​

Promise<LoginResult>


logOut()​

logOut(): Promise<boolean>;

Defined in: moodle-methods.generated.ts:458

Logs the person out of Moodle through the user menu's logout link (it carries the sesskey; without one Moodle asks to confirm, and the confirmation is accepted). Returns false when nobody was logged in. Only Moodle's session ends: a single sign-on provider may keep its own.

Returns​

Promise<boolean>

Inherited from​

MoodleMethods.logOut


markNotificationsRead()​

markNotificationsRead(): Promise<{
changed: string;
}>;

Defined in: moodle-methods.generated.ts:460

Marks all the person's notifications read, as the popover's "Mark all as read" does; doing it twice changes nothing.

Returns​

Promise<{ changed: string; }>

Inherited from​

MoodleMethods.markNotificationsRead


messageParticipants()​

messageParticipants(
courseId,
text,
selection?
): Promise<{
changed: string;
refused: object[];
sentTo: number[];
}>;

Defined in: moodle-methods.generated.ts:472

Sends one message to several participants of a course, as the participants page's "Send a message" does for the users selected: one private message each, in one call. They are userIds, or the participants participants() chooses with role, group and inactiveSince (all of them when none is given), the person left out. sentTo lists exactly who got it, refused who Moodle didn't write to and why (they blocked the person, their privacy settings); someone who may message any user (a teacher, moodle/site:messageanyuser) gets through a block, as in Moodle's own page (confirmed empirically, Moodle 5.2). Throws MessageError for an empty message or nobody to write to, NoParticipantsError when the person can't see the course's participants.

Parameters​

ParameterType
courseIdnumber
textstring
selection?ParticipantSelection

Returns​

Promise<{ changed: string; refused: object[]; sentTo: number[]; }>

Inherited from​

MoodleMethods.messageParticipants


myGrades()​

myGrades(courseId): Promise<GradeRow[]>;

Defined in: moodle-methods.generated.ts:474

The person's own grade report for a course.

Parameters​

ParameterType
courseIdnumber

Returns​

Promise<GradeRow[]>

Inherited from​

MoodleMethods.myGrades


notifications()​

Call Signature​

notifications(options): Promise<ListPage<Notification>>;

Defined in: moodle-methods.generated.ts:480

The person's notifications, newest first, only the unread ones when asked. With limit, a page of them (see "Long lists" in the docs' concepts): Moodle's service gives only the page, or, for the unread ones, batches until the page is full (it has no unread filter).

Parameters​
ParameterType
optionsWithLimit<NotificationOptions>
Returns​

Promise<ListPage<Notification>>

Inherited from​

MoodleMethods.notifications

Call Signature​

notifications(options?): Promise<Notification[]>;

Defined in: moodle-methods.generated.ts:486

The person's notifications, newest first, only the unread ones when asked. With limit, a page of them (see "Long lists" in the docs' concepts): Moodle's service gives only the page, or, for the unread ones, batches until the page is full (it has no unread filter).

Parameters​
ParameterType
options?WithoutLimit<NotificationOptions>
Returns​

Promise<Notification[]>

Inherited from​

MoodleMethods.notifications

Call Signature​

notifications(options?): Promise<
| ListPage<Notification>
| Notification[]>;

Defined in: moodle-methods.generated.ts:492

The person's notifications, newest first, only the unread ones when asked. With limit, a page of them (see "Long lists" in the docs' concepts): Moodle's service gives only the page, or, for the unread ones, batches until the page is full (it has no unread filter).

Parameters​
ParameterType
options?NotificationOptions
Returns​

Promise< | ListPage<Notification> | Notification[]>

Inherited from​

MoodleMethods.notifications


openForm()​

openForm(pathAndQuery): Promise<Page>;

Defined in: moodle-methods.generated.ts:494

Opens a Moodle form page and waits for its editors to be ready.

Parameters​

ParameterType
pathAndQuerystring

Returns​

Promise<Page>

Inherited from​

MoodleMethods.openForm


openScorm()​

openScorm(activityId, options?): Promise<OpenedScorm>;

Defined in: client.ts:266

openScorm: a SCORM's player, on the working tab.

Parameters​

ParameterType
activityIdnumber
options?{ newAttempt?: boolean; scoId?: number; }
options.newAttempt?boolean
options.scoId?number

Returns​

Promise<OpenedScorm>


openSitePage()​

openSitePage(path, options?): Promise<Page>;

Defined in: moodle-methods.generated.ts:499

Opens a page of the site (path relative to it) in a new tab and checks the session; throws NotLoggedInError, closing the tab, when Moodle answers with its login page.

Parameters​

ParameterType
pathstring
options?{ follow?: boolean; }
options.follow?boolean

Returns​

Promise<Page>

Inherited from​

MoodleMethods.openSitePage


overrideCompletion()​

overrideCompletion(
activityId,
userId,
state
): Promise<{
changed: string;
overridden: boolean;
state: "incomplete" | "complete" | "complete-pass" | "complete-fail";
}>;

Defined in: moodle-methods.generated.ts:501

Sets someone's completion of an activity as a teacher does from the progress report; returns the state saved.

Parameters​

ParameterType
activityIdnumber
userIdnumber
state"incomplete" | "complete" | "complete-pass" | "complete-fail"

Returns​

Promise<{ changed: string; overridden: boolean; state: "incomplete" | "complete" | "complete-pass" | "complete-fail"; }>

Inherited from​

MoodleMethods.overrideCompletion


participantFilters()​

participantFilters(courseId): Promise<{
groups: object[];
roles: object[];
}>;

Defined in: moodle-methods.generated.ts:507

The roles and groups the participants page filters by in a course (its filters' options), as the person may use them: every group, or only their own in a course with separate groups. "No roles" and "no group" left out.

Parameters​

ParameterType
courseIdnumber

Returns​

Promise<{ groups: object[]; roles: object[]; }>

Inherited from​

MoodleMethods.participantFilters


participants()​

Call Signature​

participants(courseId, options): Promise<ListPage<Participant>>;

Defined in: moodle-methods.generated.ts:516

A course's participants with their roles and groups, as the participants page lists them: only those with a role (its id), in a group, or (inactiveSince) who haven't accessed the course since that date, when asked. Each role and group is a filter of its own, so ids come in any language. With limit, a page of them in the page's order, by last name (see "Long lists" in the docs' concepts): the one page of the table's own paging that holds it; the roles' and groups' members are still read whole, to tell each one's.

Parameters​
ParameterType
courseIdnumber
optionsWithLimit<ParticipantOptions>
Returns​

Promise<ListPage<Participant>>

Inherited from​

MoodleMethods.participants

Call Signature​

participants(courseId, options?): Promise<Participant[]>;

Defined in: moodle-methods.generated.ts:525

A course's participants with their roles and groups, as the participants page lists them: only those with a role (its id), in a group, or (inactiveSince) who haven't accessed the course since that date, when asked. Each role and group is a filter of its own, so ids come in any language. With limit, a page of them in the page's order, by last name (see "Long lists" in the docs' concepts): the one page of the table's own paging that holds it; the roles' and groups' members are still read whole, to tell each one's.

Parameters​
ParameterType
courseIdnumber
options?WithoutLimit<ParticipantOptions>
Returns​

Promise<Participant[]>

Inherited from​

MoodleMethods.participants

Call Signature​

participants(courseId, options?): Promise<
| ListPage<Participant>
| Participant[]>;

Defined in: moodle-methods.generated.ts:534

A course's participants with their roles and groups, as the participants page lists them: only those with a role (its id), in a group, or (inactiveSince) who haven't accessed the course since that date, when asked. Each role and group is a filter of its own, so ids come in any language. With limit, a page of them in the page's order, by last name (see "Long lists" in the docs' concepts): the one page of the table's own paging that holds it; the roles' and groups' members are still read whole, to tell each one's.

Parameters​
ParameterType
courseIdnumber
options?ParticipantOptions
Returns​

Promise< | ListPage<Participant> | Participant[]>

Inherited from​

MoodleMethods.participants


participationReport()​

participationReport(
courseId,
activityId,
options?
): Promise<ActivityParticipant[]>;

Defined in: moodle-methods.generated.ts:540

Who took part in an activity of a course, as its participation report counts it: everyone with the role (every role the report offers, unless roleId), with how many actions they made there (views or posts only, when action; since since, when given); those who did nothing come with 0.

Parameters​

ParameterType
courseIdnumber
activityIdnumber
options?{ action?: "view" | "post"; roleId?: number; since?: Date; }
options.action?"view" | "post"
options.roleId?number
options.since?Date

Returns​

Promise<ActivityParticipant[]>

Inherited from​

MoodleMethods.participationReport


pendingActivities()​

pendingActivities(courseId): Promise<{
completionTracked: boolean;
pending: PendingActivity[];
}>;

Defined in: moodle-methods.generated.ts:545

What the person still has to do in a course: activities whose completion is tracked and not complete or, where completion isn't tracked, graded activities without a grade yet.

Parameters​

ParameterType
courseIdnumber

Returns​

Promise<{ completionTracked: boolean; pending: PendingActivity[]; }>

Inherited from​

MoodleMethods.pendingActivities


potentialUsers()​

potentialUsers(courseId, search?): Promise<PotentialUser[]>;

Defined in: moodle-methods.generated.ts:552

Users the person may enrol in a course by manual enrolment, matching search anywhere in their name or the identity fields the site shows (all of them, a page of up to 100, when empty), as the "Enrol users" dialog finds them. Throws EnrolmentError when the course has no manual enrolment the person can use.

Parameters​

ParameterType
courseIdnumber
search?string

Returns​

Promise<PotentialUser[]>

Inherited from​

MoodleMethods.potentialUsers


publicSiteInfo()​

publicSiteInfo(): Promise<{
language: string | undefined;
languages?: string[];
login: {
appLogin?: "app" | "browser" | "embedded";
guestAccess: boolean;
identityProviders: string[];
};
maintenance?: string;
name: string;
supportPage?: string;
url: string;
}>;

Defined in: client.ts:245

What the site tells anyone before logging in, without the browser.

Returns​

Promise<{ language: string | undefined; languages?: string[]; login: { appLogin?: "app" | "browser" | "embedded"; guestAccess: boolean; identityProviders: string[]; }; maintenance?: string; name: string; supportPage?: string; url: string; }>


questionBanks()​

questionBanks(courseId): Promise<QuestionBank[]>;

Defined in: moodle-methods.generated.ts:554

A course's question banks: its shared ones and the activities' own, as the banks page lists them.

Parameters​

ParameterType
courseIdnumber

Returns​

Promise<QuestionBank[]>

Inherited from​

MoodleMethods.questionBanks


questions()​

Call Signature​

questions(activityId, options): Promise<BankQuestions<ListPage<BankQuestion>>>;

Defined in: moodle-methods.generated.ts:561

A bank's categories and every question in them, category by category. With limit, questions is a page of them in that order (see "Long lists" in the docs' concepts), the categories all: the bank is read category by category until the page is full, each category whole and cut (its page counts aren't reliable enough to skip by).

Parameters​
ParameterType
activityIdnumber
optionsWithLimit<PageOptions>
Returns​

Promise<BankQuestions<ListPage<BankQuestion>>>

Inherited from​

MoodleMethods.questions

Call Signature​

questions(activityId, options?): Promise<BankQuestions<BankQuestion[]>>;

Defined in: moodle-methods.generated.ts:568

A bank's categories and every question in them, category by category. With limit, questions is a page of them in that order (see "Long lists" in the docs' concepts), the categories all: the bank is read category by category until the page is full, each category whole and cut (its page counts aren't reliable enough to skip by).

Parameters​
ParameterType
activityIdnumber
options?WithoutLimit<PageOptions>
Returns​

Promise<BankQuestions<BankQuestion[]>>

Inherited from​

MoodleMethods.questions

Call Signature​

questions(activityId, options?): Promise<BankQuestions<
| BankQuestion[]
| ListPage<BankQuestion>>>;

Defined in: moodle-methods.generated.ts:575

A bank's categories and every question in them, category by category. With limit, questions is a page of them in that order (see "Long lists" in the docs' concepts), the categories all: the bank is read category by category until the page is full, each category whole and cut (its page counts aren't reliable enough to skip by).

Parameters​
ParameterType
activityIdnumber
options?PageOptions
Returns​

Promise<BankQuestions< | BankQuestion[] | ListPage<BankQuestion>>>

Inherited from​

MoodleMethods.questions


questionsToGrade()​

questionsToGrade(activityId): Promise<{
questions: QuestionToGrade[];
quiz: {
id: number;
};
}>;

Defined in: moodle-methods.generated.ts:581

The questions of a quiz that wait for grading by hand (essays…), as its manual grading report lists them, each with the finished attempts whose answer requires grading (from the results report). People as user id and full name.

Parameters​

ParameterType
activityIdnumber

Returns​

Promise<{ questions: QuestionToGrade[]; quiz: { id: number; }; }>

Inherited from​

MoodleMethods.questionsToGrade


quizInfo()​

quizInfo(activityId): Promise<QuizInfo>;

Defined in: moodle-methods.generated.ts:583

A quiz's page as the person sees it: its description and dates, the person's attempts with their summary, and whether they can start one.

Parameters​

ParameterType
activityIdnumber

Returns​

Promise<QuizInfo>

Inherited from​

MoodleMethods.quizInfo


quizResults()​

Call Signature​

quizResults(activityId, options): Promise<QuizResults<ListPage<QuizAttemptResult>>>;

Defined in: moodle-methods.generated.ts:590

A quiz's attempts as its grades report shows them: per attempt the user, state, dates, grade and the mark per question; with responses, also the answer per question from the responses report. Every page of the report; with limit, attempts is a page of them in the report's order (see "Long lists" in the docs' concepts), read from the one page of the report's own paging that holds it.

Parameters​
ParameterType
activityIdnumber
optionsWithLimit<QuizResultsOptions>
Returns​

Promise<QuizResults<ListPage<QuizAttemptResult>>>

Inherited from​

MoodleMethods.quizResults

Call Signature​

quizResults(activityId, options?): Promise<QuizResults<QuizAttemptResult[]>>;

Defined in: moodle-methods.generated.ts:597

A quiz's attempts as its grades report shows them: per attempt the user, state, dates, grade and the mark per question; with responses, also the answer per question from the responses report. Every page of the report; with limit, attempts is a page of them in the report's order (see "Long lists" in the docs' concepts), read from the one page of the report's own paging that holds it.

Parameters​
ParameterType
activityIdnumber
options?WithoutLimit<QuizResultsOptions>
Returns​

Promise<QuizResults<QuizAttemptResult[]>>

Inherited from​

MoodleMethods.quizResults

Call Signature​

quizResults(activityId, options?): Promise<QuizResults<
| QuizAttemptResult[]
| ListPage<QuizAttemptResult>>>;

Defined in: moodle-methods.generated.ts:604

A quiz's attempts as its grades report shows them: per attempt the user, state, dates, grade and the mark per question; with responses, also the answer per question from the responses report. Every page of the report; with limit, attempts is a page of them in the report's order (see "Long lists" in the docs' concepts), read from the one page of the report's own paging that holds it.

Parameters​
ParameterType
activityIdnumber
options?QuizResultsOptions
Returns​

Promise<QuizResults< | QuizAttemptResult[] | ListPage<QuizAttemptResult>>>

Inherited from​

MoodleMethods.quizResults


quizStructure()​

quizStructure(activityId): Promise<{
quiz: {
id: number;
};
sections: QuizSection[];
slots: QuizSlot[];
}>;

Defined in: moodle-methods.generated.ts:606

A quiz's questions as its edit page lists them: slots with their page, question, type, name and mark, and its sections.

Parameters​

ParameterType
activityIdnumber

Returns​

Promise<{ quiz: { id: number; }; sections: QuizSection[]; slots: QuizSlot[]; }>

Inherited from​

MoodleMethods.quizStructure


rate()​

rate(item, rating): Promise<{
aggregate?: string;
changed: string;
count?: number;
}>;

Defined in: moodle-methods.generated.ts:615

Rates a forum post, a glossary entry or a database record as the person, as the rating menu under it does: by a scale item's name, or its number (the points of a point scale). null takes the person's rating away. Returns a sentence of what changed and the item's aggregate afterwards (as Moodle shows it, by the activity's aggregation) with the number of ratings. Throws GradingError when the item has no rating menu for the person (ratings off, their own item, outside the rating period, or no permission) or the rating isn't on its scale.

Parameters​

ParameterType
itemRateableItem
ratingstring | number | null

Returns​

Promise<{ aggregate?: string; changed: string; count?: number; }>

Inherited from​

MoodleMethods.rate


readAttempt()​

readAttempt(attemptId): Promise<Question[]>;

Defined in: moodle-methods.generated.ts:617

Every question of an attempt, page by page, with the page each is on.

Parameters​

ParameterType
attemptIdnumber

Returns​

Promise<Question[]>

Inherited from​

MoodleMethods.readAttempt


readReview()​

readReview(attemptId): Promise<{
questions: Question[];
summary: Detail[];
}>;

Defined in: moodle-methods.generated.ts:619

A finished attempt's review, as far as the quiz's review options let the person see it.

Parameters​

ParameterType
attemptIdnumber

Returns​

Promise<{ questions: Question[]; summary: Detail[]; }>

Inherited from​

MoodleMethods.readReview


removeQuizSlot()​

removeQuizSlot(activityId, slot): Promise<QuizChange>;

Defined in: moodle-methods.generated.ts:621

Removes a slot (by its place, from 1) from a quiz, as the edit page's delete icon does; the question stays in its bank.

Parameters​

ParameterType
activityIdnumber
slotnumber

Returns​

Promise<QuizChange>

Inherited from​

MoodleMethods.removeQuizSlot


replyToPost()​

replyToPost(postId, input): Promise<{
changed: string;
discussionId: number | undefined;
postId: number | undefined;
subscribed?: boolean;
}>;

Defined in: moodle-methods.generated.ts:626

Replies to a post; returns the new post's id and its discussion's, and, when subscribe is given, the person's subscription to the discussion afterwards, read back (subscribed).

Parameters​

ParameterType
postIdnumber
inputPostInput & object

Returns​

Promise<{ changed: string; discussionId: number | undefined; postId: number | undefined; subscribed?: boolean; }>

Inherited from​

MoodleMethods.replyToPost


resetCourse()​

resetCourse(courseId, options): Promise<{
changed: string;
report: ResetStatus[];
}>;

Defined in: moodle-methods.generated.ts:635

Resets a course for a new year, as Moodle's reset form does: deletes only what's named in delete (in every module of the course that has it), unenrols the people with unenrolRoles (role ids), moves the course's start date to start (and its activities' dates with it), and sets any other of the form's fields by name (fields). Nothing is deleted unless asked: the form's own defaults are unticked first. It can't be undone. Returns Moodle's report: per component, what it did and its errors. Needs moodle/course:reset.

Parameters​

ParameterType
courseIdnumber
options{ delete?: ResetDeletions; fields?: Record<string, FieldValue>; start?: Date; unenrolRoles?: number[]; }
options.delete?ResetDeletions
options.fields?Record<string, FieldValue>
options.start?Date
options.unenrolRoles?number[]

Returns​

Promise<{ changed: string; report: ResetStatus[]; }>

Inherited from​

MoodleMethods.resetCourse


restoreCourse()​

restoreCourse(file, options): Promise<{
activityIds?: number[];
changed: string;
course: CourseRef;
sectionIds?: number[];
warnings?: RestoreWarning[];
}>;

Defined in: moodle-methods.generated.ts:657

Restores a backup file (.mbz) through Moodle's restore wizard: into a new course in a category (into: "new", with categoryId, which needs moodle/course:create there), or into an existing course (into: <course id>), its content added to the course's (mode: "merge", the default) or replacing it ("replace": the course's content is deleted first). A new course takes the backup's names unless fullName and shortName are given. Users' data is restored when withUsers and the backup has it. An asynchronous restore is waited for up to timeoutMs (ten minutes). Needs moodle/restore:restorecourse where it restores.

Before the wizard, the backup is read: one made on a newer Moodle than the site's, or holding activities of a type the site doesn't offer the person in that course, is refused (Moodle would warn only, or skip those activities without a word).

Merged into an existing course, Moodle puts each of the backup's sections into the course's section of the same number (creating it when there's none) and each activity at the end of it; sectionId puts every restored activity at the end of that section instead, and afterSectionId makes each of the backup's sections a new section, in order, after that one (the driver restores, then moves what Moodle made: one move per section). With either, a section of the course that Moodle changed on the way (named, described, hidden or restricted as the backup's, when it had none) is put back. Returns the sections and activities the course has new, in the course's order.

Parameters​

ParameterType
filestring
options{ afterSectionId?: number; categoryId?: number; fullName?: string; into: number | "new"; mode?: "replace" | "merge"; sectionId?: number; shortName?: string; timeoutMs?: number; withUsers?: boolean; }
options.afterSectionId?number
options.categoryId?number
options.fullName?string
options.intonumber | "new"
options.mode?"replace" | "merge"
options.sectionId?number
options.shortName?string
options.timeoutMs?number
options.withUsers?boolean

Returns​

Promise<{ activityIds?: number[]; changed: string; course: CourseRef; sectionIds?: number[]; warnings?: RestoreWarning[]; }>

Inherited from​

MoodleMethods.restoreCourse


rubric()​

rubric(activityId): Promise<object & GradingDefinition>;

Defined in: moodle-methods.generated.ts:664

An assignment's grading method and, for a rubric or a marking guide, its criteria with the ids gradeSubmission takes: read from the grader's panel for the first participant with a submission. Where nobody has one yet, the panel is the first participant's, and Moodle creates an empty submission ("new") for them on opening it.

Parameters​

ParameterType
activityIdnumber

Returns​

Promise<object & GradingDefinition>

Inherited from​

MoodleMethods.rubric


saveSession()​

saveSession(): Promise<void>;

Defined in: client.ts:272

Saves the session cookies of the open browser now.

Returns​

Promise<void>


saveSubmission()​

saveSubmission(activityId, input): Promise<{
assignment: StudentAssignment;
changed: string;
}>;

Defined in: moodle-methods.generated.ts:666

Saves the submission's online text and adds files, as "Save changes" on the edit page does; gives the assignment afterwards.

Parameters​

ParameterType
activityIdnumber
input{ files?: string[]; onlineText?: string; }
input.files?string[]
input.onlineText?string

Returns​

Promise<{ assignment: StudentAssignment; changed: string; }>

Inherited from​

MoodleMethods.saveSubmission


scorm()​

scorm(activityId): Promise<ScormActivity>;

Defined in: moodle-methods.generated.ts:672

A SCORM activity as the person sees it: its attempts (allowed and made), the grading method, the grade reported and each attempt's, and its SCOs with the person's status and score in the last attempt. Moodle doesn't show a SCORM's version on its page: openScorm tells it.

Parameters​

ParameterType
activityIdnumber

Returns​

Promise<ScormActivity>

Inherited from​

MoodleMethods.scorm


sendMessage()​

sendMessage(userId, text): Promise<{
changed: string;
conversationId?: number;
messageId: number;
}>;

Defined in: moodle-methods.generated.ts:674

Sends a private message to a user, as the messaging drawer does; returns the message and its conversation.

Parameters​

ParameterType
userIdnumber
textstring

Returns​

Promise<{ changed: string; conversationId?: number; messageId: number; }>

Inherited from​

MoodleMethods.sendMessage


setCompletion()​

setCompletion(activityId, done): Promise<{
changed: string;
}>;

Defined in: moodle-methods.generated.ts:680

Marks the person's own completion of an activity with manual completion, done or not, as its "Mark as done" button does; doing it twice changes nothing. An activity that completes on its own gives a CompletionError.

Parameters​

ParameterType
activityIdnumber
doneboolean

Returns​

Promise<{ changed: string; }>

Inherited from​

MoodleMethods.setCompletion


setDiscussionState()​

setDiscussionState(
activityId,
discussionId,
options
): Promise<{
changed: string;
discussion?: ForumDiscussion;
}>;

Defined in: moodle-methods.generated.ts:685

Pins or unpins, locks or unlocks a discussion, as the discussion list's menu does; what's already so is left alone. Returns the discussion as the forum lists it afterwards.

Parameters​

ParameterType
activityIdnumber
discussionIdnumber
options{ locked?: boolean; pinned?: boolean; }
options.locked?boolean
options.pinned?boolean

Returns​

Promise<{ changed: string; discussion?: ForumDiscussion; }>

Inherited from​

MoodleMethods.setDiscussionState


setDiscussionSubscription()​

setDiscussionSubscription(
activityId,
discussionId,
subscribed
): Promise<{
changed: string;
discussion?: ForumDiscussion;
}>;

Defined in: moodle-methods.generated.ts:691

Subscribes the person to a discussion or unsubscribes them, as the discussion list's toggle does (mod_forum_set_subscription_state); what's already so is left alone. Returns the discussion as the forum lists it afterwards.

Parameters​

ParameterType
activityIdnumber
discussionIdnumber
subscribedboolean

Returns​

Promise<{ changed: string; discussion?: ForumDiscussion; }>

Inherited from​

MoodleMethods.setDiscussionSubscription


setEnrolmentMethod()​

setEnrolmentMethod(
courseId,
method,
settings
): Promise<{
changed: string;
method: EnrolmentMethod;
}>;

Defined in: moodle-methods.generated.ts:702

Sets an enrolment method: by id, or the course's first method of a type ({ type: "self" }), added when the course has none and the "Add method" menu offers it. Only what's given changes. enabled goes through the methods page's enable and disable icons, the rest through the method's form: what Moodle lets the person change differs by method (an editing teacher can't configure manual enrolment, enrol/manual:config, so neither switch it nor set its role). Returns the method afterwards. Throws EnrolmentError for a method the course doesn't have or can't add, and for a setting Moodle doesn't let the person change (naming it); FormError with Moodle's reason when it refuses the form (a key required by the site, an end before the start).

Parameters​

ParameterType
courseIdnumber
method| number | { type: string; }
settingsEnrolmentMethodSettings

Returns​

Promise<{ changed: string; method: EnrolmentMethod; }>

Inherited from​

MoodleMethods.setEnrolmentMethod


setGrade()​

setGrade(
courseId,
itemId,
userId,
options
): Promise<{
changed: string;
grade: GradebookGrade;
}>;

Defined in: moodle-methods.generated.ts:711

Sets a person's grade in a grade item through the gradebook's single view report, as a teacher does there: a manual item takes the grade; an activity's or a category's is overridden (Moodle keeps the override until it's taken off with override: false). Feedback and excluding from the totals go the same way. Returns a sentence of what changed and the grade afterwards. Throws GradebookError when the item or the person isn't in the course's gradebook, the grade is locked, or Moodle refuses the value (out of range, a scale item it doesn't have).

Parameters​

ParameterType
courseIdnumber
itemIdnumber
userIdnumber
optionsSetGradeOptions

Returns​

Promise<{ changed: string; grade: GradebookGrade; }>

Inherited from​

MoodleMethods.setGrade


setGroupingGroups()​

setGroupingGroups(groupingId, groupIds): Promise<{
changed: string;
groupIds: number[];
}>;

Defined in: moodle-methods.generated.ts:722

Makes a grouping's groups exactly groupIds, as its groups page adds and removes them. Groups of other courses aren't offered there and are left out, named in changed. Returns the groups afterwards.

Parameters​

ParameterType
groupingIdnumber
groupIdsnumber[]

Returns​

Promise<{ changed: string; groupIds: number[]; }>

Inherited from​

MoodleMethods.setGroupingGroups


setGroupMembers()​

setGroupMembers(groupId, options): Promise<{
changed: string;
members: number[];
}>;

Defined in: moodle-methods.generated.ts:717

Adds and removes a group's members (user ids), as its members page does. Only the course's participants can be added: ids the page doesn't offer (not enrolled, or already members) and members not in it are left as they were and named in changed. Returns the members afterwards.

Parameters​

ParameterType
groupIdnumber
options{ add?: number[]; remove?: number[]; }
options.add?number[]
options.remove?number[]

Returns​

Promise<{ changed: string; members: number[]; }>

Inherited from​

MoodleMethods.setGroupMembers


setQuestionStatus()​

setQuestionStatus(questionId, status): Promise<{
changed: string;
questionId: number;
status: "ready" | "draft";
}>;

Defined in: moodle-methods.generated.ts:724

Sets a question ready (quizzes can use it) or draft, as the bank's status menu does, through its service.

Parameters​

ParameterType
questionIdnumber
status"ready" | "draft"

Returns​

Promise<{ changed: string; questionId: number; status: "ready" | "draft"; }>

Inherited from​

MoodleMethods.setQuestionStatus


setQuizOverride()​

setQuizOverride(
activityId,
userId,
options
): Promise<{
changed: string;
}>;

Defined in: moodle-methods.generated.ts:729

Sets a user override on a quiz, through its override form: other opening and closing dates, a time limit in minutes, or a number of attempts (0 unlimited); what isn't given stays the quiz's.

Parameters​

ParameterType
activityIdnumber
userIdnumber
options{ attempts?: number; close?: Date; open?: Date; timeLimitMinutes?: number; }
options.attempts?number
options.close?Date
options.open?Date
options.timeLimitMinutes?number

Returns​

Promise<{ changed: string; }>

Inherited from​

MoodleMethods.setQuizOverride


setQuizPages()​

setQuizPages(activityId, pages): Promise<QuizChange>;

Defined in: moodle-methods.generated.ts:735

Sets a quiz's pages: perPage questions a page (0 for all on one), as the edit page's "Repaginate" does, or page breaks exactly after the given slots (and nowhere else), as its page break icons do one by one.

Parameters​

ParameterType
activityIdnumber
pages| { perPage: number; } | { breaksAfter: number[]; }

Returns​

Promise<QuizChange>

Inherited from​

MoodleMethods.setQuizPages


setUserRoles()​

setUserRoles(
courseId,
userId,
roleIds
): Promise<{
changed: string;
roleIds: number[];
}>;

Defined in: moodle-methods.generated.ts:743

Sets a user's roles in a course, as the participants page's roles column does: gives the roles in roleIds the person may assign, and takes away the others the person may assign. Roles the person can't assign that the user already holds, and those from elsewhere (a category, an enrolment that protects them), stay. Returns the user's roles afterwards, as that column shows them. Throws EnrolmentError with Moodle's reason for a role the person can't assign or a user not enrolled.

Parameters​

ParameterType
courseIdnumber
userIdnumber
roleIdsnumber[]

Returns​

Promise<{ changed: string; roleIds: number[]; }>

Inherited from​

MoodleMethods.setUserRoles


setVisible()​

setVisible(visible): Promise<void>;

Defined in: client.ts:270

Shows the browser and follows the pages methods open, or hides it.

Parameters​

ParameterType
visibleboolean

Returns​

Promise<void>


setWorkflowState()​

setWorkflowState(
activityId,
userIds,
state,
options?
): Promise<{
changed: string;
}>;

Defined in: moodle-methods.generated.ts:749

Sets the marking workflow state of participants' submissions, as the grading table's "Set marking workflow state" does; "released" shows them their grades, notifying them when notify is true (the form's default is not to). With several markers, it sets the submission's overall state.

Parameters​

ParameterType
activityIdnumber
userIdsnumber[]
state| "inmarking" | "readyforreview" | "inreview" | "readyforrelease" | "released"
options?{ notify?: boolean; }
options.notify?boolean

Returns​

Promise<{ changed: string; }>

Inherited from​

MoodleMethods.setWorkflowState


setWorkshopPhase()​

setWorkshopPhase(activityId, phase): Promise<{
changed: string;
phase: WorkshopPhase;
}>;

Defined in: moodle-methods.generated.ts:757

Switches a workshop to a phase, as its page's phase links do, confirming Moodle's question (any phase, forwards or back; Moodle allocates nothing and calculates no grades on its own when it switches). Returns a sentence of what changed and the phase afterwards. Throws WorkshopError when the person can't switch the workshop's phases (Moodle's mod/workshop:switchphase, a teacher's) or the id isn't a workshop's.

Parameters​

ParameterType
activityIdnumber
phaseWorkshopPhase

Returns​

Promise<{ changed: string; phase: WorkshopPhase; }>

Inherited from​

MoodleMethods.setWorkshopPhase


siteName()​

siteName(): Promise<string | undefined>;

Defined in: moodle-methods.generated.ts:759

The site's name, from its public settings; undefined where the mobile app support is off.

Returns​

Promise<string | undefined>

Inherited from​

MoodleMethods.siteName


startDiscussion()​

startDiscussion(activityId, input): Promise<{
changed: string;
discussionId: number | undefined;
pinned: boolean | undefined;
subscribed: boolean | undefined;
}>;

Defined in: moodle-methods.generated.ts:764

Starts a discussion in a forum; returns its id, and whether it's pinned and the person subscribed to it, as the forum lists it afterwards, so one call confirms what subscribe and fields set.

Parameters​

ParameterType
activityIdnumber
inputPostInput & object

Returns​

Promise<{ changed: string; discussionId: number | undefined; pinned: boolean | undefined; subscribed: boolean | undefined; }>

Inherited from​

MoodleMethods.startDiscussion


startQuizAttempt()​

startQuizAttempt(activityId): Promise<{
attemptId: number;
changed: string;
questions: Question[];
}>;

Defined in: moodle-methods.generated.ts:766

Starts an attempt, or continues the one in progress, and gives its questions.

Parameters​

ParameterType
activityIdnumber

Returns​

Promise<{ attemptId: number; changed: string; questions: Question[]; }>

Inherited from​

MoodleMethods.startQuizAttempt


studentAssignment()​

studentAssignment(activityId): Promise<StudentAssignment>;

Defined in: moodle-methods.generated.ts:768

An assignment as the student sees it: its description and files, dates, the submission's status and files, the feedback, and whether it can be edited or submitted now.

Parameters​

ParameterType
activityIdnumber

Returns​

Promise<StudentAssignment>

Inherited from​

MoodleMethods.studentAssignment


submitForGrading()​

submitForGrading(activityId, options?): Promise<{
assignment: StudentAssignment;
changed: string;
}>;

Defined in: moodle-methods.generated.ts:774

Submits the saved submission for grading, accepting the site's statement when it asks for one (acceptStatement, once the person agrees; a bare boolean as before 0.2 too); gives the assignment afterwards.

Parameters​

ParameterType
activityIdnumber
options?| boolean | { acceptStatement?: boolean; }

Returns​

Promise<{ assignment: StudentAssignment; changed: string; }>

Inherited from​

MoodleMethods.submitForGrading


submitSurvey()​

Call Signature​

submitSurvey(
activityId,
type,
responses
): Promise<{
changed: string;
messages: string[];
}>;

Defined in: moodle-methods.generated.ts:779

Fills the survey page by page with responses (field name → value) and submits it on the last page. Every name is checked against the form first, so nothing is sent with a wrong one.

Parameters​
ParameterType
activityIdnumber
typeSurveyType
responsesRecord<string, string>
Returns​

Promise<{ changed: string; messages: string[]; }>

Inherited from​

MoodleMethods.submitSurvey

Call Signature​

submitSurvey(
activityId,
responses,
options?
): Promise<{
changed: string;
messages: string[];
}>;

Defined in: moodle-methods.generated.ts:784

Fills the survey page by page with responses (field name → value) and submits it on the last page. Every name is checked against the form first, so nothing is sent with a wrong one.

Parameters​
ParameterType
activityIdnumber
responsesRecord<string, string>
options?{ type?: SurveyType; }
options.type?SurveyType
Returns​

Promise<{ changed: string; messages: string[]; }>

Inherited from​

MoodleMethods.submitSurvey


tab()​

tab(): Promise<Page>;

Defined in: client.ts:264

The working tab a program drives itself (ADR-007).

Returns​

Promise<Page>


unenrolUser()​

unenrolUser(courseId, userId): Promise<{
changed: string;
kept: string[];
removed: string[];
}>;

Defined in: moodle-methods.generated.ts:792

Unenrols a user from a course: removes every enrolment of theirs the person may remove (its unenrol link on the participants page), with their roles and group memberships in the course, as that link does. changed and removed say which ones (by enrolment method's name), kept those the person may not remove (a cohort sync, another teacher's method). Throws EnrolmentError when the user isn't enrolled.

Parameters​

ParameterType
courseIdnumber
userIdnumber

Returns​

Promise<{ changed: string; kept: string[]; removed: string[]; }>

Inherited from​

MoodleMethods.unenrolUser


upcomingEvents()​

upcomingEvents(options?): Promise<CalendarEvent[]>;

Defined in: moodle-methods.generated.ts:794

The person's upcoming events, as the calendar's "Upcoming events" view lists them, in one course or all.

Parameters​

ParameterType
options?{ courseId?: number; }
options.courseId?number

Returns​

Promise<CalendarEvent[]>

Inherited from​

MoodleMethods.upcomingEvents


updateActivity()​

updateActivity(activityId, input): Promise<CourseChange>;

Defined in: moodle-methods.generated.ts:799

Changes an existing activity through its form: only what's given changes. A file resource's or folder's files stay as they are unless files says what to add, remove or replace.

Parameters​

ParameterType
activityIdnumber
inputActivityFields & object

Returns​

Promise<CourseChange>

Inherited from​

MoodleMethods.updateActivity


updateCourse()​

updateCourse(courseId, options): Promise<{
changed: string;
course?: Course;
}>;

Defined in: moodle-methods.generated.ts:806

Changes a course's full name, short name, summary (HTML) or any other setting by its form field name, through the course's settings form; returns the course as listCourses gives it. embed takes local files the summary names (<img src="shot.png">), put in it as Moodle's editor does. Moodle's refusals (a short name already taken) come back as FormError by field.

Parameters​

ParameterType
courseIdnumber
options{ embed?: string[]; fullName?: string; settings?: Record<string, FieldValue>; shortName?: string; summary?: string; }
options.embed?string[]
options.fullName?string
options.settings?Record<string, FieldValue>
options.shortName?string
options.summary?string

Returns​

Promise<{ changed: string; course?: Course; }>

Inherited from​

MoodleMethods.updateCourse


updateEvent()​

updateEvent(eventId, changes): Promise<{
changed: string;
event: CalendarEvent;
}>;

Defined in: moodle-methods.generated.ts:812

Changes a calendar event through the calendar's own form, opened on it: only what's given changes. A new start keeps the event's length unless a new one is given. Returns the event as the calendar has it afterwards.

Parameters​

ParameterType
eventIdnumber
changesEventChanges

Returns​

Promise<{ changed: string; event: CalendarEvent; }>

Inherited from​

MoodleMethods.updateEvent


updateGradeCategory()​

updateGradeCategory(
courseId,
categoryId,
options
): Promise<{
category?: GradebookCategory;
changed: string;
}>;

Defined in: moodle-methods.generated.ts:817

Changes a grade category: its name, its aggregation, its weight in its parent (percent, overriding Natural's automatic one), or moves it into another category. Returns the category afterwards.

Parameters​

ParameterType
courseIdnumber
categoryIdnumber
options{ aggregation?: | "mode" | "mean" | "median" | "lowest" | "highest" | "weighted-mean" | "simple-weighted-mean" | "mean-with-extra-credits" | "natural"; name?: string; parentId?: number; weight?: number; }
options.aggregation?| "mode" | "mean" | "median" | "lowest" | "highest" | "weighted-mean" | "simple-weighted-mean" | "mean-with-extra-credits" | "natural"
options.name?string
options.parentId?number
options.weight?number

Returns​

Promise<{ category?: GradebookCategory; changed: string; }>

Inherited from​

MoodleMethods.updateGradeCategory


updateGradeItem()​

updateGradeItem(
courseId,
itemId,
options
): Promise<{
changed: string;
item?: GradebookItem;
}>;

Defined in: moodle-methods.generated.ts:823

Changes a grade item: moves it into a category, sets its weight (percent, overriding Natural's automatic one), or its maximum grade (a manual item's; an activity's is set in the activity). Returns the item afterwards.

Parameters​

ParameterType
courseIdnumber
itemIdnumber
options{ category?: number; maxGrade?: number; weight?: number; }
options.category?number
options.maxGrade?number
options.weight?number

Returns​

Promise<{ changed: string; item?: GradebookItem; }>

Inherited from​

MoodleMethods.updateGradeItem


updateGroup()​

updateGroup(groupId, settings): Promise<{
changed: string;
}>;

Defined in: moodle-methods.generated.ts:825

Changes a group's name, description, ID number or enrolment key with its form; what isn't given stays.

Parameters​

ParameterType
groupIdnumber
settingsGroupSettings

Returns​

Promise<{ changed: string; }>

Inherited from​

MoodleMethods.updateGroup


updateQuestion()​

updateQuestion(
activityId,
questionId,
input
): Promise<{
changed: string;
questionId?: number;
}>;

Defined in: moodle-methods.generated.ts:832

Changes a question of a bank through its type's edit form, with the same inputs as createQuestion and only what's given (answers replaces them all). Saving makes a new version of the question, with an id of its own: the one returned, which quizzes using the latest version get from then on.

Parameters​

ParameterType
activityIdnumber
questionIdnumber
inputPartial<Omit<QuestionInput, "type">>

Returns​

Promise<{ changed: string; questionId?: number; }>

Inherited from​

MoodleMethods.updateQuestion


userById()​

userById(userId): Promise<User | undefined>;

Defined in: moodle-methods.generated.ts:839

A user by id, or undefined when there's nobody: no such user, one the person may not see, or a deleted account. Moodle keeps a deleted account's record and its user service still gives it to an administrator, renamed, with the email replaced by an MD5 hash of the old username (delete_user, confirmed empirically on the sandbox, 5.2); the driver treats it as gone.

Parameters​

ParameterType
userIdnumber

Returns​

Promise<User | undefined>

Inherited from​

MoodleMethods.userById


visible()​

visible(): boolean;

Defined in: client.ts:268

Whether the browser shows a window now.

Returns​

boolean


whoAmI()​

whoAmI(courseId?): Promise<Me>;

Defined in: moodle-methods.generated.ts:841

Who the logged-in person is; with courseId, also their roles and abilities in that course.

Parameters​

ParameterType
courseId?number

Returns​

Promise<Me>

Inherited from​

MoodleMethods.whoAmI


workshopInfo()​

workshopInfo(activityId): Promise<WorkshopInfo>;

Defined in: moodle-methods.generated.ts:851

A workshop's phase, and its report as the workshop's page shows it to a teacher: every submission (its author, title, and grade once calculated) and every assessment (reviewer, the submission's author, the grade it gives, its weight, the grade for assessing once calculated), all of its pages. The report is Moodle's own: it shows from the submission phase on to those who can see every submission, in the course's current group; for anyone else the lists are empty. Grades are out of the workshop's grade for submission, as Moodle shows them. Throws WorkshopError for an activity that isn't a workshop the person can view.

Parameters​

ParameterType
activityIdnumber

Returns​

Promise<WorkshopInfo>

Inherited from​

MoodleMethods.workshopInfo