@falkenslab/moodle-driver 0.5.0 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. package/dist/areas/activities/build.d.ts +15 -5
  2. package/dist/areas/activities/build.js +33 -10
  3. package/dist/areas/activities/build.js.map +1 -1
  4. package/dist/areas/activities/content.d.ts +3 -1
  5. package/dist/areas/activities/content.js +9 -1
  6. package/dist/areas/activities/content.js.map +1 -1
  7. package/dist/areas/courses/list.d.ts +5 -3
  8. package/dist/areas/courses/list.js +9 -3
  9. package/dist/areas/courses/list.js.map +1 -1
  10. package/dist/areas/courses/structure.d.ts +5 -1
  11. package/dist/areas/courses/structure.js +3 -1
  12. package/dist/areas/courses/structure.js.map +1 -1
  13. package/dist/areas/forums/discussions.d.ts +16 -0
  14. package/dist/areas/forums/discussions.js +30 -3
  15. package/dist/areas/forums/discussions.js.map +1 -1
  16. package/dist/areas/forums/posts.d.ts +35 -4
  17. package/dist/areas/forums/posts.js +57 -9
  18. package/dist/areas/forums/posts.js.map +1 -1
  19. package/dist/areas/participants/methods.d.ts +9 -6
  20. package/dist/areas/participants/methods.js +91 -39
  21. package/dist/areas/participants/methods.js.map +1 -1
  22. package/dist/areas/quizzes/structure.d.ts +2 -2
  23. package/dist/areas/quizzes/structure.js.map +1 -1
  24. package/dist/categories.js +3 -0
  25. package/dist/categories.js.map +1 -1
  26. package/dist/cli/commands.generated.js +72 -9
  27. package/dist/cli/commands.generated.js.map +1 -1
  28. package/dist/client.d.ts +6 -179
  29. package/dist/client.js +4 -1
  30. package/dist/client.js.map +1 -1
  31. package/dist/core/embed.d.ts +19 -0
  32. package/dist/core/embed.js +88 -0
  33. package/dist/core/embed.js.map +1 -0
  34. package/dist/core/forms.d.ts +3 -1
  35. package/dist/core/forms.js +10 -3
  36. package/dist/core/forms.js.map +1 -1
  37. package/dist/core/text.d.ts +10 -0
  38. package/dist/core/text.js +19 -0
  39. package/dist/core/text.js.map +1 -1
  40. package/dist/index.d.ts +3 -3
  41. package/dist/index.js +1 -1
  42. package/dist/index.js.map +1 -1
  43. package/dist/internals.d.ts +1 -1
  44. package/dist/internals.js +1 -1
  45. package/dist/internals.js.map +1 -1
  46. package/dist/moodle-methods.generated.d.ts +1159 -0
  47. package/dist/moodle-methods.generated.js +4 -0
  48. package/dist/moodle-methods.generated.js.map +1 -0
  49. package/package.json +1 -1
@@ -0,0 +1,1159 @@
1
+ /**
2
+ * The methods a `Moodle` has from the driver's functions: each is the function of the same name
3
+ * without its first two parameters (the browser context and the site), and its doc comment.
4
+ */
5
+ export interface MoodleMethods {
6
+ /**
7
+ * Moodle 5's activities overview of a course for one type ("resource" for every resource type):
8
+ * per activity, the columns its overview page shows the person (due dates, submissions, what needs
9
+ * grading, their own grade…). Without a type, every type in the course's state: "resource" first,
10
+ * which brings pages, books, files, folders and links at once, then each type still missing.
11
+ */
12
+ activitiesOverview(courseId: number, type?: string): Promise<{
13
+ fields: import("./areas/courses/overview.js").OverviewField[];
14
+ available?: boolean | undefined;
15
+ visible: boolean;
16
+ url?: string | undefined;
17
+ id: number;
18
+ name: string;
19
+ type: string;
20
+ }[]>;
21
+ /**
22
+ * A course's activity report: per activity, how many times it was viewed, by how many people, and
23
+ * when last, from the logs (between `from` and `until` when given). Activities nobody viewed come with
24
+ * zero views.
25
+ */
26
+ activityReport(courseId: number, options?: {
27
+ from?: Date | undefined;
28
+ until?: Date | undefined;
29
+ }): Promise<import("./areas/reports/reports.js").ActivityViews[]>;
30
+ /**
31
+ * An activity's settings as its form holds them, without submitting it: its module, name and
32
+ * description, every field by the name `updateActivity` takes in `settings`, the files of a
33
+ * resource, folder or SCORM, and its restrictions and completion in plain terms. Teachers only.
34
+ */
35
+ activitySettings(activityId: number): Promise<{
36
+ id: number;
37
+ module: string;
38
+ courseId: number;
39
+ name: string;
40
+ description: string;
41
+ fields: import("./areas/activities/build.js").FormField[];
42
+ files: import("./core/forms.js").DraftFile[] | undefined;
43
+ restrictions: import("./areas/activities/conditions.js").Restrictions | undefined;
44
+ completion: import("./areas/activities/conditions.js").Completion | undefined;
45
+ }>;
46
+ /** Adds a grade category (at the course's top level, or inside `parentId`); returns it as the setup shows it. */
47
+ addGradeCategory(courseId: number, options: {
48
+ name: string;
49
+ aggregation?: "mean" | "median" | "lowest" | "highest" | "mode" | "weighted-mean" | "simple-weighted-mean" | "mean-with-extra-credits" | "natural" | undefined;
50
+ parentId?: number | undefined;
51
+ }): Promise<{
52
+ changed: string;
53
+ category?: import("./areas/grades/gradebook.js").GradebookCategory | undefined;
54
+ }>;
55
+ /**
56
+ * Adds a manual grade item (one graded in the gradebook, not by an activity): out of `maxGrade`
57
+ * (Moodle's default, 100, when left out) or on a scale (`scaleId`), at the course's top level or in
58
+ * `categoryId`, hidden from students when asked. Returns it as the setup shows it.
59
+ */
60
+ addGradeItem(courseId: number, options: {
61
+ name: string;
62
+ maxGrade?: number | undefined;
63
+ scaleId?: number | undefined;
64
+ categoryId?: number | undefined;
65
+ hidden?: boolean | undefined;
66
+ }): Promise<{
67
+ changed: string;
68
+ item?: import("./areas/grades/gradebook.js").GradebookItem | undefined;
69
+ }>;
70
+ /**
71
+ * Adds bank questions to a quiz by id, and random questions from a bank category, at the end or on a
72
+ * page, as the edit page's bank actions post them. Returns the quiz's structure afterwards. A quiz
73
+ * already attempted can't change its questions: Moodle refuses, and so does this.
74
+ */
75
+ addQuestionsToQuiz(activityId: number, options: {
76
+ questionIds?: number[] | undefined;
77
+ random?: {
78
+ categoryId: number;
79
+ count: number;
80
+ includeSubcategories?: boolean | undefined;
81
+ } | undefined;
82
+ page?: number | undefined;
83
+ }): Promise<import("./areas/quizzes/structure.js").QuizChange>;
84
+ /**
85
+ * Adds a section to a quiz starting at a slot, with its heading and whether its questions are
86
+ * shuffled, as the edit page's "Add a new section heading" and its heading and shuffle controls do.
87
+ * A section starts at a page: the slot must be the first of its page (see `setQuizPages`).
88
+ */
89
+ addQuizSection(activityId: number, options: {
90
+ firstSlot: number;
91
+ heading: string;
92
+ shuffle?: boolean | undefined;
93
+ }): Promise<import("./areas/quizzes/structure.js").QuizChange & {
94
+ sectionId: number;
95
+ }>;
96
+ /**
97
+ * Adds a section after another one (at the end without it), named when a name is given, with a
98
+ * description (HTML) when `summary` is, and `embed`'s local files in it (`<img src="shot.png">`).
99
+ */
100
+ addSection(courseId: number, options?: {
101
+ name?: string | undefined;
102
+ afterSectionId?: number | undefined;
103
+ summary?: string | undefined;
104
+ embed?: string[] | undefined;
105
+ }): Promise<import("./areas/activities/build.js").CourseChange>;
106
+ /**
107
+ * Allocates a marker (the user id of someone who can grade; several where the assignment uses
108
+ * several markers per submission) to participants' submissions, as the grading table's "Allocate
109
+ * marker" does. Moodle leaves alone submissions past marking (marking completed, in review, ready
110
+ * for release, released).
111
+ */
112
+ allocateMarker(activityId: number, userIds: number[], markerId: number | number[]): Promise<{
113
+ changed: string;
114
+ }>;
115
+ /** Answers a choice with one option (several where it allows them) by id, as "Save my choice" does; returns the choice afterwards. */
116
+ answerChoice(activityId: number, optionIds: number[]): Promise<{
117
+ changed: string;
118
+ choice: import("./areas/surveys/choice.js").Choice;
119
+ }>;
120
+ /**
121
+ * Assesses a submission as the person, through the workshop's assessment form (its grading
122
+ * strategy's: accumulative, comments, number of errors or rubric), as "Assess" on the submission's
123
+ * page and the form do: a teacher who hasn't assessed it yet gets an assessment of their own, and one
124
+ * already made is changed. `criteria` go in the form's order; `feedback` is the overall feedback for
125
+ * the author (HTML), where the workshop has it on; `fields` sets any other field of the form by name
126
+ * (`weight`…). Returns a sentence of what changed, the assessment's id, and the grade it gives the
127
+ * submission out of the workshop's grade. Throws `WorkshopError` outside the assessment phase, when a
128
+ * criterion's grade isn't one it takes, or when the workshop has no overall feedback; `FormError` when
129
+ * Moodle refuses the form (a criterion left without a grade).
130
+ */
131
+ assessWorkshopSubmission(activityId: number, submissionId: number, options: {
132
+ criteria?: import("./areas/workshops/workshops.js").WorkshopCriterion[] | undefined;
133
+ feedback?: string | undefined;
134
+ fields?: Record<string, import("./core/forms.js").FieldValue> | undefined;
135
+ }): Promise<{
136
+ changed: string;
137
+ assessmentId: number;
138
+ grade?: number | undefined;
139
+ maxGrade?: number | undefined;
140
+ }>;
141
+ /**
142
+ * Every participant's submission to an assignment, with the group they submit for (group
143
+ * submissions), and, unless `includeContent` is false, its content, the feedback files they have,
144
+ * its marking workflow state and markers (all from each participant's grading panel).
145
+ */
146
+ assignmentSubmissions(activityId: number, options?: {
147
+ includeContent?: boolean | undefined;
148
+ }): Promise<import("./areas/assignments/grading.js").Submission[]>;
149
+ /**
150
+ * Backs a course up to a `.mbz` file, through Moodle's backup wizard (initial settings, schema,
151
+ * confirmation), and downloads it into `destDir`. Without users' data unless `withUsers`, which
152
+ * needs `moodle/backup:userinfo` (`anonymize` makes their names anonymous). An asynchronous backup
153
+ * is waited for up to `timeoutMs` (ten minutes). Moodle keeps the file in the course's or the
154
+ * person's backup area too.
155
+ */
156
+ backupCourse(courseId: number, destDir: string, options?: {
157
+ withUsers?: boolean | undefined;
158
+ anonymize?: boolean | undefined;
159
+ timeoutMs?: number | undefined;
160
+ }): Promise<{
161
+ changed: string;
162
+ file: import("./core/files.js").DownloadedFile;
163
+ }>;
164
+ /** One calendar event by its id, as `upcomingEvents` gives them. */
165
+ calendarEvent(eventId: number): Promise<import("./areas/calendar/calendar.js").CalendarEvent>;
166
+ /**
167
+ * A course's progress report: every participant's completion of every activity that tracks it, page
168
+ * by page, in one group when given. People come as user id and full name only.
169
+ */
170
+ completionReport(courseId: number, options?: {
171
+ group?: number | undefined;
172
+ }): Promise<import("./areas/completion/completion.js").CompletionReport>;
173
+ /**
174
+ * A conversation's messages, oldest first, as text, and its members as `conversations()` gives them:
175
+ * everyone but the person, whether they wrote in it or not (the person alone in their own conversation).
176
+ */
177
+ conversation(conversationId: number): Promise<{
178
+ id: number;
179
+ members: {
180
+ userId: number;
181
+ fullName: string;
182
+ }[];
183
+ messages: {
184
+ id: number;
185
+ fromUserId: number;
186
+ text: string;
187
+ time: string | undefined;
188
+ }[];
189
+ }>;
190
+ /** The person's conversations, latest first, with their last message as text. */
191
+ conversations(): Promise<import("./areas/messages/messages.js").ConversationSummary[]>;
192
+ /**
193
+ * Copies a course into a new one, as Moodle's "Copy course" does: its content (and its people's
194
+ * data and enrolments, `withUsers`), under a new full and short name, in a category (the course's
195
+ * unless given), with new dates. Goes through Moodle's copy service, then waits for the copy, which
196
+ * Moodle makes in its scheduled tasks, up to `timeoutMs` (ten minutes). Needs the rights to back
197
+ * up, restore and create courses (`moodle/backup:backupcourse`, `moodle/restore:restorecourse`,
198
+ * `moodle/course:create`); without them, `BackupError` says so.
199
+ */
200
+ copyCourse(courseId: number, options: {
201
+ fullName: string;
202
+ shortName: string;
203
+ categoryId?: number | undefined;
204
+ start?: Date | undefined;
205
+ end?: Date | undefined;
206
+ withUsers?: boolean | undefined;
207
+ visible?: boolean | undefined;
208
+ timeoutMs?: number | undefined;
209
+ }): Promise<{
210
+ changed: string;
211
+ course: import("./areas/backup/backup.js").CourseRef;
212
+ }>;
213
+ /**
214
+ * What the person can do in a course, asked of read-only services that need the capability: the
215
+ * activity types they can add (none without `moodle/course:manageactivities`) and the grader
216
+ * report's users (`nopermissions` without `gradereport/grader:view`). Nothing is changed.
217
+ */
218
+ courseAbilities(courseId: number, sectionId: number): Promise<{
219
+ canEdit: boolean;
220
+ canGrade: boolean;
221
+ }>;
222
+ /** The activity and resource types the person can add to a course: none when they can't edit it. */
223
+ courseActivityTypes(courseId: number): Promise<{
224
+ purpose?: string | undefined;
225
+ type: string;
226
+ title: string;
227
+ }[]>;
228
+ /**
229
+ * A course's logs, newest first, as its logs report lists them: by a user, an activity, a kind of
230
+ * action, and a time span, up to `limit` entries (100 unless given). Moodle filters by user, activity
231
+ * and action; the span is read page by page, stopping at the first entry older than `from`. Every
232
+ * entry's time comes as an ISO date, read back with the site language's own format.
233
+ */
234
+ courseLogs(courseId: number, options?: {
235
+ userId?: number | undefined;
236
+ activityId?: number | undefined;
237
+ from?: Date | undefined;
238
+ until?: Date | undefined;
239
+ action?: "create" | "view" | "update" | "delete" | "change" | undefined;
240
+ limit?: number | undefined;
241
+ }): Promise<import("./areas/reports/reports.js").LogEntry[]>;
242
+ /** A user's roles in a course, from their profile there: role links carry the role id in any language. */
243
+ courseRoles(userId: number, courseId: number): Promise<{
244
+ id: number;
245
+ name: string;
246
+ }[]>;
247
+ /**
248
+ * A course's sections and activities; with `details`, each activity's dates and restriction and each
249
+ * section's description, from the course page (slower).
250
+ */
251
+ courseStructure(courseId: number, options?: {
252
+ details?: boolean | undefined;
253
+ }): Promise<import("./areas/courses/structure.js").CourseSection[]>;
254
+ /** What changed in a course's activities since a date, with their names from the course's state. */
255
+ courseUpdates(courseId: number, since: Date): Promise<{
256
+ changes: {
257
+ items?: number | undefined;
258
+ time?: string | undefined;
259
+ what: string;
260
+ }[];
261
+ name?: string | undefined;
262
+ type?: string | undefined;
263
+ id: number;
264
+ }[]>;
265
+ /**
266
+ * Creates an activity or resource of any type at the end of a section, through Moodle's own form,
267
+ * hidden from students unless `visibility` says otherwise. `files` are local paths uploaded to a file
268
+ * resource or folder (a `DraftUpload` puts one in a folder's subfolder); a SCORM (`type: "scorm"`) or
269
+ * an H5P activity (`type: "h5pactivity"`) takes the first as its package.
270
+ */
271
+ createActivity(input: import("./areas/activities/build.js").ActivityFields & {
272
+ courseId: number;
273
+ sectionId: number;
274
+ type: string;
275
+ files?: (string | import("./core/forms.js").DraftUpload)[] | undefined;
276
+ }): Promise<import("./areas/activities/build.js").CourseChange>;
277
+ /**
278
+ * Creates a course event, through the calendar's own form: its start, and its duration and
279
+ * description when given. Returns it as the calendar has it.
280
+ */
281
+ createEvent(options: {
282
+ courseId: number;
283
+ name: string;
284
+ start: Date;
285
+ durationMinutes?: number | undefined;
286
+ description?: string | undefined;
287
+ }): Promise<{
288
+ changed: string;
289
+ event: import("./areas/calendar/calendar.js").CalendarEvent;
290
+ }>;
291
+ /**
292
+ * Creates a group in a course with its group form (`group/group.php`). Throws `FormError` with
293
+ * Moodle's reason when it refuses (a name already used, an enrolment key another group has).
294
+ */
295
+ createGroup(courseId: number, settings: import("./areas/participants/groups.js").GroupSettings & {
296
+ name: string;
297
+ }): Promise<{
298
+ changed: string;
299
+ groupId: number;
300
+ }>;
301
+ /** Creates a grouping in a course with its form (`group/grouping.php`); add its groups with `setGroupingGroups`. */
302
+ createGrouping(courseId: number, settings: import("./areas/participants/groups.js").GroupingSettings & {
303
+ name: string;
304
+ }): Promise<{
305
+ changed: string;
306
+ groupingId: number;
307
+ }>;
308
+ /**
309
+ * Creates one question in a bank through its type's edit form; returns its id. Imports are the way
310
+ * for several; this is for one-offs.
311
+ */
312
+ createQuestion(activityId: number, input: import("./areas/questions/banks.js").QuestionInput): Promise<{
313
+ changed: string;
314
+ questionId?: number | undefined;
315
+ }>;
316
+ /**
317
+ * What the person has to do by a date (calendar action events: submit, attempt, grade…), from the
318
+ * last `pastDays` to `days` ahead, in one course or all. Teachers' grading counts come from the
319
+ * activities overview instead: Moodle gives them few action events.
320
+ */
321
+ deadlines(options?: {
322
+ courseId?: number | undefined;
323
+ days?: number | undefined;
324
+ pastDays?: number | undefined;
325
+ }): Promise<{
326
+ action?: {
327
+ url?: string | undefined;
328
+ count?: number | undefined;
329
+ name: string;
330
+ actionable: boolean;
331
+ } | undefined;
332
+ course?: {
333
+ shortname?: string | undefined;
334
+ id: number;
335
+ } | undefined;
336
+ event: string;
337
+ kind: string;
338
+ date: string;
339
+ overdue: boolean;
340
+ type?: string | undefined;
341
+ activity: string;
342
+ activityId?: number | undefined;
343
+ }[]>;
344
+ /** Deletes an activity, with its participants' data (submissions, posts, attempts); gives the course afterwards. */
345
+ deleteActivity(courseId: number, activityId: number): Promise<import("./areas/activities/build.js").CourseChange>;
346
+ /** Deletes a calendar event the person can manage. */
347
+ deleteEvent(eventId: number): Promise<{
348
+ changed: string;
349
+ }>;
350
+ /**
351
+ * Deletes a grade category. Moodle moves what it held (items and categories) into its parent and
352
+ * deletes the grades of its total; the course's own category can't be deleted.
353
+ */
354
+ deleteGradeCategory(courseId: number, categoryId: number): Promise<{
355
+ changed: string;
356
+ }>;
357
+ /**
358
+ * Deletes a manual grade item and its grades. An activity's item goes with its activity (Moodle
359
+ * would make it again), so it's refused.
360
+ */
361
+ deleteGradeItem(courseId: number, itemId: number): Promise<{
362
+ changed: string;
363
+ }>;
364
+ /** Deletes a group, as the groups page's "Delete selected group" does once confirmed; its members stay in the course. */
365
+ deleteGroup(groupId: number): Promise<{
366
+ changed: string;
367
+ }>;
368
+ /** Deletes a grouping, as its delete icon does once confirmed; its groups stay. */
369
+ deleteGrouping(groupingId: number): Promise<{
370
+ changed: string;
371
+ }>;
372
+ /**
373
+ * Deletes a post and its replies through Moodle's own confirmation (`post.php?delete=`); a
374
+ * discussion's first post takes the whole discussion. Only a moderator deletes a post with replies,
375
+ * or someone else's. `replies` says how many replies went with it. Throws `ForumError` with
376
+ * Moodle's reason when it refuses.
377
+ */
378
+ deletePost(postId: number): Promise<{
379
+ changed: string;
380
+ discussionId?: number | undefined;
381
+ replies: number;
382
+ discussionDeleted: boolean;
383
+ }>;
384
+ /**
385
+ * Deletes questions from a bank, every version of each, as the bank's delete action does: asked,
386
+ * then confirmed. Moodle doesn't delete a question a quiz uses: it hides it, and `hidden` lists those.
387
+ */
388
+ deleteQuestions(activityId: number, questionIds: number[]): Promise<{
389
+ changed: string;
390
+ deleted: number[];
391
+ hidden: number[];
392
+ }>;
393
+ /** Deletes a section and every activity in it, with their participants' data. */
394
+ deleteSection(courseId: number, sectionId: number): Promise<import("./areas/activities/build.js").CourseChange>;
395
+ /**
396
+ * A discussion's posts, oldest first, with their messages as text, and whether the person is
397
+ * subscribed to it (`subscribed`, undefined where they can't subscribe or it's forced).
398
+ */
399
+ discussion(discussionId: number): Promise<{
400
+ discussion: {
401
+ id: number;
402
+ forumInstanceId: number;
403
+ courseId: number;
404
+ subscribed: boolean | undefined;
405
+ };
406
+ posts: import("./areas/forums/posts.js").ForumPost[];
407
+ }>;
408
+ /** 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. */
409
+ duplicateActivity(courseId: number, activityId: number): Promise<import("./areas/activities/build.js").CourseChange>;
410
+ /** Renames, shows or hides, or moves an activity (to a section's end, or before another one). */
411
+ editActivity(courseId: number, activityId: number, options: {
412
+ name?: string | undefined;
413
+ visibility?: "shown" | "hidden" | "stealth" | undefined;
414
+ sectionId?: number | undefined;
415
+ beforeActivityId?: number | undefined;
416
+ }): Promise<import("./areas/activities/build.js").CourseChange>;
417
+ /**
418
+ * Changes a post through Moodle's own post form (`post.php?edit=`), as its author (within the site's
419
+ * editing time) or a moderator: only what's given changes. Returns the post afterwards. Throws
420
+ * `ForumError` with Moodle's reason when it refuses.
421
+ */
422
+ editPost(postId: number, changes: import("./areas/forums/posts.js").PostChanges): Promise<{
423
+ changed: string;
424
+ post?: import("./areas/forums/posts.js").ForumPost | undefined;
425
+ }>;
426
+ /**
427
+ * Changes one slot of a quiz (by its place, from 1): its maximum mark, through the slots' service,
428
+ * and where it is, as dragging it on the edit page does: after another slot (`moveAfter`, 0 for
429
+ * first) and on a page. Moodle lets the mark change after attempts (it regrades them), not the rest.
430
+ */
431
+ editQuizSlot(activityId: number, slot: number, options: {
432
+ maxMark?: number | undefined;
433
+ moveAfter?: number | undefined;
434
+ page?: number | undefined;
435
+ }): Promise<import("./areas/quizzes/structure.js").QuizChange>;
436
+ /**
437
+ * Renames, shows or hides, describes (`summary`, HTML, with `embed`'s local files in it), restricts
438
+ * (`restrictions`; `{ conditions: [] }` removes them) or moves a section after another one.
439
+ */
440
+ editSection(courseId: number, sectionId: number, options: {
441
+ name?: string | undefined;
442
+ visible?: boolean | undefined;
443
+ summary?: string | undefined;
444
+ restrictions?: import("./areas/activities/conditions.js").Restrictions | undefined;
445
+ afterSectionId?: number | undefined;
446
+ embed?: string[] | undefined;
447
+ }): Promise<import("./areas/activities/build.js").CourseChange>;
448
+ /**
449
+ * Enrols users in a course by manual enrolment, as the participants page's "Enrol users" dialog does:
450
+ * with `roleId` or the enrolment's default role, from `start` (now, unless given) until `end` (the
451
+ * enrolment's default duration, unless given). Users already enrolled keep their enrolment, with the
452
+ * new dates. Throws `EnrolmentError` with Moodle's reason when it refuses (a role the person can't
453
+ * assign, no manual enrolment).
454
+ */
455
+ enrolUsers(courseId: number, userIds: number[], options?: {
456
+ roleId?: number | undefined;
457
+ start?: Date | undefined;
458
+ end?: Date | undefined;
459
+ }): Promise<{
460
+ changed: string;
461
+ count: number;
462
+ roleId?: number | undefined;
463
+ }>;
464
+ /**
465
+ * A course's enrolment methods, in the order Moodle tries them: each one's type, name, whether it's
466
+ * enabled and how many users it enrolled, and from its form the role it gives and, for self enrolment
467
+ * and guest access, whether it asks for a key (never the key), self enrolment's dates and limit.
468
+ * Throws `EnrolmentError` when the person can't manage the course's enrolment methods.
469
+ */
470
+ enrolmentMethods(courseId: number): Promise<import("./areas/participants/methods.js").EnrolmentMethod[]>;
471
+ /** Submits an attempt for grading, and gives its review when the quiz shows it. */
472
+ finishQuizAttempt(attemptId: number): Promise<{
473
+ changed: string;
474
+ attemptId: number;
475
+ finished: true;
476
+ review: {
477
+ summary: import("./areas/quizzes/attempts.js").Detail[];
478
+ questions: import("./areas/quizzes/attempts.js").Question[];
479
+ } | undefined;
480
+ }>;
481
+ /** A forum's discussions, as its page lists them: who started each, replies, last post, the person's subscription. */
482
+ forumDiscussions(activityId: number): Promise<import("./areas/forums/posts.js").ForumDiscussion[]>;
483
+ /**
484
+ * Everyone's whole-forum grade in a forum graded as a whole, as its grader shows them: one per
485
+ * person it can grade (only the active ones when the forum says so), with how it's graded. One
486
+ * service call per person. Throws `NotAForumError` for another activity, and `GradingError` when
487
+ * the forum isn't graded as a whole or uses an advanced grading method.
488
+ */
489
+ forumGrades(activityId: number, options?: {
490
+ groupId?: number | undefined;
491
+ }): Promise<import("./areas/forums/grading.js").ForumGrades>;
492
+ /** A choice: its options, whether it can be answered or changed, and the person's answer. */
493
+ getChoice(activityId: number): Promise<import("./areas/surveys/choice.js").Choice>;
494
+ /** 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. */
495
+ getSurvey(activityId: number, type?: import("./areas/surveys/surveys.js").SurveyType): Promise<{
496
+ questions: import("./areas/surveys/surveys.js").SurveyQuestion[];
497
+ canAnswer: boolean;
498
+ intro: string;
499
+ messages: string[];
500
+ }>;
501
+ /**
502
+ * Gives a person their whole-forum grade, as the forum's grader does: points (out of the forum's
503
+ * maximum), or a scale item by name or value; `null` takes the grade away. Moodle's forum grader
504
+ * has no feedback text. `notify` sends the person Moodle's notification, as the grader's checkbox
505
+ * does. Returns a sentence of what changed and the grade afterwards. Throws `GradingError` when the
506
+ * forum isn't graded as a whole, the grade is out of range or not on the scale, or Moodle refuses it.
507
+ */
508
+ gradeForumUser(activityId: number, userId: number, options: {
509
+ grade: string | number | null;
510
+ notify?: boolean | undefined;
511
+ }): Promise<{
512
+ changed: string;
513
+ grade: Omit<import("./areas/forums/grading.js").ForumGrade, "fullName">;
514
+ }>;
515
+ /**
516
+ * Grades one question of a finished attempt by hand, with a comment, through Moodle's comment form
517
+ * (the review's "Make comment or override mark"): an essay waiting for grading, or any question whose
518
+ * mark the teacher overrides. The mark is in the question's points (0 to its maximum in the quiz).
519
+ * Returns the attempt's grade afterwards when the results report shows it.
520
+ */
521
+ gradeQuizQuestion(attemptId: number, slot: number, options: {
522
+ mark: number;
523
+ comment?: string | undefined;
524
+ }): Promise<{
525
+ changed: string;
526
+ attemptId: number;
527
+ slot: number;
528
+ mark: number;
529
+ maxMark?: number | undefined;
530
+ grade?: string | undefined;
531
+ }>;
532
+ /**
533
+ * Grades a participant as the grader does: a grade (simple grading), a rubric's level per criterion
534
+ * or a marking guide's score per criterion (by their ids, from `rubric()`), remarks per criterion,
535
+ * feedback comments (HTML), feedback files (local paths that replace the ones the participant has;
536
+ * `[]` removes them), whether to notify, and any other grading field by name. Returns the grade
537
+ * saved and the gradebook's grade, the total Moodle computes for a rubric or a guide, and the
538
+ * feedback files after saving when they were given. Throws `GradingError` when Moodle refuses the
539
+ * grade, or when files are given to an assignment without feedback files.
540
+ */
541
+ gradeSubmission(activityId: number, userId: number, options: {
542
+ grade?: string | number | undefined;
543
+ rubric?: Record<number, number> | undefined;
544
+ guide?: Record<number, number> | undefined;
545
+ remarks?: Record<number, string> | undefined;
546
+ feedback?: string | undefined;
547
+ feedbackFiles?: string[] | undefined;
548
+ workflowState?: "notmarked" | "inmarking" | "readyforreview" | "inreview" | "readyforrelease" | "released" | undefined;
549
+ applyToGroup?: boolean | undefined;
550
+ notify?: boolean | undefined;
551
+ fields?: Record<string, import("./core/forms.js").FieldValue> | undefined;
552
+ }): Promise<{
553
+ workflowState?: "notmarked" | "inmarking" | "readyforreview" | "inreview" | "readyforrelease" | "released" | undefined;
554
+ feedbackFiles?: {
555
+ name: string;
556
+ url: string;
557
+ }[] | undefined;
558
+ grade?: string | undefined;
559
+ gradebookGrade?: string | undefined;
560
+ feedback?: string | undefined;
561
+ changed: string;
562
+ }>;
563
+ /** A course's gradebook setup: its categories (aggregation, weights) and grade items (category, maximum, weight). */
564
+ gradebookSetup(courseId: number): Promise<{
565
+ categories: import("./areas/grades/gradebook.js").GradebookCategory[];
566
+ items: import("./areas/grades/gradebook.js").GradebookItem[];
567
+ }>;
568
+ /**
569
+ * Everyone's grades in a course as the grader report shows them, page by page, in one group when
570
+ * given. People come as user id and full name only.
571
+ */
572
+ graderReport(courseId: number, options?: {
573
+ group?: number | undefined;
574
+ }): Promise<import("./areas/grades/gradebook.js").GraderReport>;
575
+ /**
576
+ * Grants participants an extension until a date, through the assignment's extension form (several at
577
+ * once as its bulk action does). Moodle refuses a date before the assignment's due date, and a person
578
+ * without its "grant extension" capability only on saving (the form opens for anyone, confirmed
579
+ * empirically on the sandbox, 5.2): both throw.
580
+ */
581
+ grantExtension(activityId: number, userIds: number[], until: Date): Promise<{
582
+ changed: string;
583
+ }>;
584
+ /** 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. */
585
+ groupings(courseId: number): Promise<import("./areas/participants/groups.js").Grouping[]>;
586
+ /** A course's groups the person can see, with their members' user ids. */
587
+ groups(courseId: number): Promise<import("./areas/participants/participants.js").CourseGroup[]>;
588
+ /** An H5P activity: its content type, whether attempts are tracked, and the person's attempts with their scores. */
589
+ h5pActivity(activityId: number): Promise<import("./areas/h5p/h5p.js").H5PActivity>;
590
+ /**
591
+ * Imports activities from another course into a course, as Moodle's "Import" does: every activity
592
+ * of `fromCourseId`, or only `activityIds`, added to `toCourseId`'s content (with their sections),
593
+ * without users' data. Needs `moodle/restore:restoretargetimport` in the course imported into and
594
+ * `moodle/backup:backuptargetimport` in the other. Returns the activities the course has afterwards
595
+ * that it didn't have before, by id.
596
+ */
597
+ importActivities(fromCourseId: number, toCourseId: number, options?: {
598
+ activityIds?: number[] | undefined;
599
+ }): Promise<{
600
+ changed: string;
601
+ activityIds: number[];
602
+ }>;
603
+ /**
604
+ * Imports questions into a bank from a GIFT or Moodle XML file (a local path) or text, through the
605
+ * bank's import form; returns the questions created. A file Moodle can't parse comes back as a
606
+ * `QuestionBankError` with its messages, and nothing is imported.
607
+ */
608
+ importQuestions(activityId: number, options: {
609
+ format: "xml" | "gift";
610
+ file?: string | undefined;
611
+ text?: string | undefined;
612
+ categoryId?: number | undefined;
613
+ }): Promise<{
614
+ changed: string;
615
+ questions: import("./areas/questions/banks.js").BankQuestion[];
616
+ }>;
617
+ /** The lesson page the person is on (starting the lesson the first time). */
618
+ lessonPage(activityId: number): Promise<import("./areas/lessons/lessons.js").LessonPage>;
619
+ /** The course's assignments, in the course's order, with the section each is in. */
620
+ listAssignments(courseId: number): Promise<import("./areas/courses/structure.js").CourseAssignment[]>;
621
+ /** The courses the person is enrolled in, as teacher or student. */
622
+ listCourses(classification?: "all" | "inprogress" | "future" | "past"): Promise<import("./areas/courses/list.js").Course[]>;
623
+ /**
624
+ * Logs the person out of Moodle through the user menu's logout link (it carries the sesskey; without
625
+ * one Moodle asks to confirm, and the confirmation is accepted). Returns false when nobody was logged
626
+ * in. Only Moodle's session ends: a single sign-on provider may keep its own.
627
+ */
628
+ logOut(): Promise<boolean>;
629
+ /** Marks all the person's notifications read, as the popover's "Mark all as read" does; doing it twice changes nothing. */
630
+ markNotificationsRead(): Promise<{
631
+ changed: string;
632
+ }>;
633
+ /**
634
+ * Sends one message to several participants of a course, as the participants page's "Send a message"
635
+ * does for the users selected: one private message each, in one call. They are `userIds`, or the
636
+ * participants `participants()` chooses with `role`, `group` and `inactiveSince` (all of them when
637
+ * none is given), the person left out. `sentTo` lists exactly who got it, `refused` who Moodle
638
+ * didn't write to and why (they blocked the person, their privacy settings); someone who may message
639
+ * any user (a teacher, `moodle/site:messageanyuser`) gets through a block, as in Moodle's own page
640
+ * (confirmed empirically, Moodle 5.2). Throws `MessageError`
641
+ * for an empty message or nobody to write to, `NoParticipantsError` when the person can't see the
642
+ * course's participants.
643
+ */
644
+ messageParticipants(courseId: number, text: string, selection?: import("./areas/messages/messages.js").ParticipantSelection): Promise<{
645
+ changed: string;
646
+ sentTo: number[];
647
+ refused: {
648
+ userId: number;
649
+ reason: string;
650
+ }[];
651
+ }>;
652
+ /** The person's own grade report for a course. */
653
+ myGrades(courseId: number): Promise<import("./areas/grades/user-report.js").GradeRow[]>;
654
+ /** The person's notifications, newest first, only the unread ones when asked. */
655
+ notifications(options?: {
656
+ unreadOnly?: boolean | undefined;
657
+ }): Promise<import("./areas/messages/messages.js").Notification[]>;
658
+ /** Opens a Moodle form page and waits for its editors to be ready. */
659
+ openForm(pathAndQuery: string): Promise<import("playwright-core").Page>;
660
+ /**
661
+ * Opens a page of the site (`path` relative to it) in a new tab and checks the session; throws
662
+ * `NotLoggedInError`, closing the tab, when Moodle answers with its login page.
663
+ */
664
+ openSitePage(path: string, options?: {
665
+ follow?: boolean | undefined;
666
+ }): Promise<import("playwright-core").Page>;
667
+ /** Sets someone's completion of an activity as a teacher does from the progress report; returns the state saved. */
668
+ overrideCompletion(activityId: number, userId: number, state: "incomplete" | "complete" | "complete-pass" | "complete-fail"): Promise<{
669
+ changed: string;
670
+ state: "incomplete" | "complete" | "complete-pass" | "complete-fail";
671
+ overridden: boolean;
672
+ }>;
673
+ /**
674
+ * The roles and groups the participants page filters by in a course (its filters' options), as the
675
+ * person may use them: every group, or only their own in a course with separate groups. "No roles"
676
+ * and "no group" left out.
677
+ */
678
+ participantFilters(courseId: number): Promise<{
679
+ roles: {
680
+ id: number;
681
+ name: string;
682
+ }[];
683
+ groups: {
684
+ id: number;
685
+ name: string;
686
+ }[];
687
+ }>;
688
+ /**
689
+ * A course's participants with their roles and groups, as the participants page lists them: only
690
+ * those with a role (its id), in a group, or (`inactiveSince`) who haven't accessed the course since
691
+ * that date, when asked. Each role and group is a filter of its own, so ids come in any language.
692
+ */
693
+ participants(courseId: number, options?: {
694
+ role?: number | undefined;
695
+ group?: number | undefined;
696
+ inactiveSince?: Date | undefined;
697
+ }): Promise<import("./areas/participants/participants.js").Participant[]>;
698
+ /**
699
+ * Who took part in an activity of a course, as its participation report counts it: everyone with
700
+ * the role (every role the report offers, unless `roleId`), with how many actions they made there
701
+ * (views or posts only, when `action`; since `since`, when given); those who did nothing come with 0.
702
+ */
703
+ participationReport(courseId: number, activityId: number, options?: {
704
+ roleId?: number | undefined;
705
+ since?: Date | undefined;
706
+ action?: "view" | "post" | undefined;
707
+ }): Promise<import("./areas/reports/reports.js").ActivityParticipant[]>;
708
+ /**
709
+ * What the person still has to do in a course: activities whose completion is tracked and not
710
+ * complete or, where completion isn't tracked, graded activities without a grade yet.
711
+ */
712
+ pendingActivities(courseId: number): Promise<{
713
+ completionTracked: boolean;
714
+ pending: import("./areas/courses/structure.js").PendingActivity[];
715
+ }>;
716
+ /**
717
+ * Users the person may enrol in a course by manual enrolment, matching `search` anywhere in their
718
+ * name or the identity fields the site shows (all of them, a page of up to 100, when empty), as the
719
+ * "Enrol users" dialog finds them. Throws `EnrolmentError` when the course has no manual enrolment
720
+ * the person can use.
721
+ */
722
+ potentialUsers(courseId: number, search?: string): Promise<import("./areas/participants/enrolments.js").PotentialUser[]>;
723
+ /** A course's question banks: its shared ones and the activities' own, as the banks page lists them. */
724
+ questionBanks(courseId: number): Promise<import("./areas/questions/banks.js").QuestionBank[]>;
725
+ /** A bank's categories and every question in them, category by category. */
726
+ questions(activityId: number): Promise<{
727
+ categories: import("./areas/questions/banks.js").BankCategory[];
728
+ questions: import("./areas/questions/banks.js").BankQuestion[];
729
+ }>;
730
+ /**
731
+ * The questions of a quiz that wait for grading by hand (essays…), as its manual grading report lists
732
+ * them, each with the finished attempts whose answer requires grading (from the results report).
733
+ * People as user id and full name.
734
+ */
735
+ questionsToGrade(activityId: number): Promise<{
736
+ quiz: {
737
+ id: number;
738
+ };
739
+ questions: import("./areas/quizzes/grading.js").QuestionToGrade[];
740
+ }>;
741
+ /** 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. */
742
+ quizInfo(activityId: number): Promise<import("./areas/quizzes/attempts.js").QuizInfo>;
743
+ /**
744
+ * A quiz's attempts as its grades report shows them: per attempt the user, state, dates, grade and
745
+ * the mark per question; with `responses`, also the answer per question from the responses report.
746
+ * Every page of the report.
747
+ */
748
+ quizResults(activityId: number, options?: {
749
+ responses?: boolean | undefined;
750
+ }): Promise<{
751
+ quiz: {
752
+ id: number;
753
+ };
754
+ attempts: import("./areas/quizzes/results.js").QuizAttemptResult[];
755
+ }>;
756
+ /** A quiz's questions as its edit page lists them: slots with their page, question, type, name and mark, and its sections. */
757
+ quizStructure(activityId: number): Promise<{
758
+ quiz: {
759
+ id: number;
760
+ };
761
+ slots: import("./areas/quizzes/structure.js").QuizSlot[];
762
+ sections: import("./areas/quizzes/structure.js").QuizSection[];
763
+ }>;
764
+ /**
765
+ * Rates a forum post, a glossary entry or a database record as the person, as the rating menu under
766
+ * it does: by a scale item's name, or its number (the points of a point scale). `null` takes the
767
+ * person's rating away. Returns a sentence of what changed and the item's aggregate afterwards (as
768
+ * Moodle shows it, by the activity's aggregation) with the number of ratings. Throws `GradingError`
769
+ * when the item has no rating menu for the person (ratings off, their own item, outside the
770
+ * rating period, or no permission) or the rating isn't on its scale.
771
+ */
772
+ rate(item: import("./areas/ratings/ratings.js").RateableItem, rating: string | number | null): Promise<{
773
+ changed: string;
774
+ aggregate?: string | undefined;
775
+ count?: number | undefined;
776
+ }>;
777
+ /** Every question of an attempt, page by page, with the page each is on. */
778
+ readAttempt(attemptId: number): Promise<import("./areas/quizzes/attempts.js").Question[]>;
779
+ /** A finished attempt's review, as far as the quiz's review options let the person see it. */
780
+ readReview(attemptId: number): Promise<{
781
+ summary: import("./areas/quizzes/attempts.js").Detail[];
782
+ questions: import("./areas/quizzes/attempts.js").Question[];
783
+ }>;
784
+ /** 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. */
785
+ removeQuizSlot(activityId: number, slot: number): Promise<import("./areas/quizzes/structure.js").QuizChange>;
786
+ /**
787
+ * Replies to a post; returns the new post's id and its discussion's, and, when `subscribe` is given,
788
+ * the person's subscription to the discussion afterwards, read back (`subscribed`).
789
+ */
790
+ replyToPost(postId: number, input: import("./areas/forums/posts.js").PostInput & {
791
+ subject?: string | undefined;
792
+ }): Promise<{
793
+ subscribed?: boolean | undefined;
794
+ changed: string;
795
+ postId: number | undefined;
796
+ discussionId: number | undefined;
797
+ }>;
798
+ /**
799
+ * Resets a course for a new year, as Moodle's reset form does: deletes only what's named in `delete`
800
+ * (in every module of the course that has it), unenrols the people with `unenrolRoles` (role ids),
801
+ * moves the course's start date to `start` (and its activities' dates with it), and sets any other of
802
+ * the form's fields by name (`fields`). Nothing is deleted unless asked: the form's own defaults are
803
+ * unticked first. It can't be undone. Returns Moodle's report: per component, what it did and its
804
+ * errors. Needs `moodle/course:reset`.
805
+ */
806
+ resetCourse(courseId: number, options: {
807
+ delete?: import("./areas/courses/reset.js").ResetDeletions | undefined;
808
+ unenrolRoles?: number[] | undefined;
809
+ start?: Date | undefined;
810
+ fields?: Record<string, import("./core/forms.js").FieldValue> | undefined;
811
+ }): Promise<{
812
+ changed: string;
813
+ report: import("./areas/courses/reset.js").ResetStatus[];
814
+ }>;
815
+ /**
816
+ * Restores a backup file (`.mbz`) through Moodle's restore wizard: into a new course in a category
817
+ * (`into: "new"`, with `categoryId`, which needs `moodle/course:create` there), or into an existing
818
+ * course (`into: <course id>`), its content added to the course's (`mode: "merge"`, the default) or
819
+ * replacing it (`"replace"`: the course's content is deleted first). A new course takes the backup's
820
+ * names unless `fullName` and `shortName` are given. Users' data is restored when `withUsers` and the
821
+ * backup has it. An asynchronous restore is waited for up to `timeoutMs` (ten minutes). Needs
822
+ * `moodle/restore:restorecourse` where it restores.
823
+ */
824
+ restoreCourse(file: string, options: {
825
+ into: number | "new";
826
+ categoryId?: number | undefined;
827
+ mode?: "merge" | "replace" | undefined;
828
+ fullName?: string | undefined;
829
+ shortName?: string | undefined;
830
+ withUsers?: boolean | undefined;
831
+ timeoutMs?: number | undefined;
832
+ }): Promise<{
833
+ changed: string;
834
+ course: import("./areas/backup/backup.js").CourseRef;
835
+ }>;
836
+ /**
837
+ * An assignment's grading method and, for a rubric or a marking guide, its criteria with the ids
838
+ * `gradeSubmission` takes: read from the grader's panel for its first participant.
839
+ */
840
+ rubric(activityId: number): Promise<{
841
+ assignment: {
842
+ id: number;
843
+ };
844
+ } & import("./areas/assignments/grading.js").GradingDefinition>;
845
+ /** Saves the submission's online text and adds files, as "Save changes" on the edit page does; gives the assignment afterwards. */
846
+ saveSubmission(activityId: number, input: {
847
+ onlineText?: string | undefined;
848
+ files?: string[] | undefined;
849
+ }): Promise<{
850
+ changed: string;
851
+ assignment: import("./areas/assignments/student.js").StudentAssignment;
852
+ }>;
853
+ /**
854
+ * A SCORM activity as the person sees it: its attempts (allowed and made), the grading method, the
855
+ * grade reported and each attempt's, and its SCOs with the person's status and score in the last
856
+ * attempt. Moodle doesn't show a SCORM's version on its page: `openScorm` tells it.
857
+ */
858
+ scorm(activityId: number): Promise<import("./areas/scorm/scorm.js").ScormActivity>;
859
+ /** Sends a private message to a user, as the messaging drawer does; returns the message and its conversation. */
860
+ sendMessage(userId: number, text: string): Promise<{
861
+ changed: string;
862
+ messageId: number;
863
+ conversationId?: number | undefined;
864
+ }>;
865
+ /**
866
+ * Marks the person's own completion of an activity with manual completion, done or not, as its
867
+ * "Mark as done" button does; doing it twice changes nothing. An activity that completes on its own
868
+ * gives a `CompletionError`.
869
+ */
870
+ setCompletion(activityId: number, done: boolean): Promise<{
871
+ changed: string;
872
+ }>;
873
+ /**
874
+ * Pins or unpins, locks or unlocks a discussion, as the discussion list's menu does; what's already
875
+ * so is left alone. Returns the discussion as the forum lists it afterwards.
876
+ */
877
+ setDiscussionState(activityId: number, discussionId: number, options: {
878
+ pinned?: boolean | undefined;
879
+ locked?: boolean | undefined;
880
+ }): Promise<{
881
+ changed: string;
882
+ discussion?: import("./areas/forums/posts.js").ForumDiscussion | undefined;
883
+ }>;
884
+ /**
885
+ * Subscribes the person to a discussion or unsubscribes them, as the discussion list's toggle does
886
+ * (`mod_forum_set_subscription_state`); what's already so is left alone. Returns the discussion as
887
+ * the forum lists it afterwards.
888
+ */
889
+ setDiscussionSubscription(activityId: number, discussionId: number, subscribed: boolean): Promise<{
890
+ changed: string;
891
+ discussion?: import("./areas/forums/posts.js").ForumDiscussion | undefined;
892
+ }>;
893
+ /**
894
+ * Sets an enrolment method: by id, or the course's first method of a type (`{ type: "self" }`),
895
+ * added when the course has none and the "Add method" menu offers it. Only what's given changes.
896
+ * `enabled` goes through the methods page's enable and disable icons, the rest through the method's
897
+ * form: what Moodle lets the person change differs by method (an editing teacher can't configure
898
+ * manual enrolment, enrol/manual:config, so neither switch it nor set its role). Returns the method
899
+ * afterwards. Throws `EnrolmentError` for a method the course doesn't have or can't add, and for a
900
+ * setting Moodle doesn't let the person change (naming it); `FormError` with Moodle's reason when it
901
+ * refuses the form (a key required by the site, an end before the start).
902
+ */
903
+ setEnrolmentMethod(courseId: number, method: number | {
904
+ type: string;
905
+ }, settings: import("./areas/participants/methods.js").EnrolmentMethodSettings): Promise<{
906
+ changed: string;
907
+ method: import("./areas/participants/methods.js").EnrolmentMethod;
908
+ }>;
909
+ /**
910
+ * Sets a person's grade in a grade item through the gradebook's single view report, as a teacher
911
+ * does there: a manual item takes the grade; an activity's or a category's is overridden (Moodle
912
+ * keeps the override until it's taken off with `override: false`). Feedback and excluding from
913
+ * the totals go the same way. Returns a sentence of what changed and the grade afterwards.
914
+ * Throws `GradebookError` when the item or the person isn't in the course's gradebook, the grade
915
+ * is locked, or Moodle refuses the value (out of range, a scale item it doesn't have).
916
+ */
917
+ setGrade(courseId: number, itemId: number, userId: number, options: import("./areas/grades/singleview.js").SetGradeOptions): Promise<{
918
+ changed: string;
919
+ grade: import("./areas/grades/singleview.js").GradebookGrade;
920
+ }>;
921
+ /**
922
+ * Adds and removes a group's members (user ids), as its members page does. Only the course's
923
+ * participants can be added: ids the page doesn't offer (not enrolled, or already members) and
924
+ * members not in it are left as they were and named in `changed`. Returns the members afterwards.
925
+ */
926
+ setGroupMembers(groupId: number, options: {
927
+ add?: number[] | undefined;
928
+ remove?: number[] | undefined;
929
+ }): Promise<{
930
+ changed: string;
931
+ members: number[];
932
+ }>;
933
+ /**
934
+ * Makes a grouping's groups exactly `groupIds`, as its groups page adds and removes them. Groups of
935
+ * other courses aren't offered there and are left out, named in `changed`. Returns the groups afterwards.
936
+ */
937
+ setGroupingGroups(groupingId: number, groupIds: number[]): Promise<{
938
+ changed: string;
939
+ groupIds: number[];
940
+ }>;
941
+ /** Sets a question ready (quizzes can use it) or draft, as the bank's status menu does, through its service. */
942
+ setQuestionStatus(questionId: number, status: "ready" | "draft"): Promise<{
943
+ changed: string;
944
+ questionId: number;
945
+ status: "ready" | "draft";
946
+ }>;
947
+ /**
948
+ * Sets a user override on a quiz, through its override form: other opening and closing dates, a time
949
+ * limit in minutes, or a number of attempts (0 unlimited); what isn't given stays the quiz's.
950
+ */
951
+ setQuizOverride(activityId: number, userId: number, options: {
952
+ open?: Date | undefined;
953
+ close?: Date | undefined;
954
+ timeLimitMinutes?: number | undefined;
955
+ attempts?: number | undefined;
956
+ }): Promise<{
957
+ changed: string;
958
+ }>;
959
+ /**
960
+ * Sets a quiz's pages: `perPage` questions a page (0 for all on one), as the edit page's
961
+ * "Repaginate" does, or page breaks exactly after the given slots (and nowhere else), as its page
962
+ * break icons do one by one.
963
+ */
964
+ setQuizPages(activityId: number, pages: {
965
+ perPage: number;
966
+ } | {
967
+ breaksAfter: number[];
968
+ }): Promise<import("./areas/quizzes/structure.js").QuizChange>;
969
+ /**
970
+ * Sets a user's roles in a course, as the participants page's roles column does: gives the roles in
971
+ * `roleIds` the person may assign, and takes away the others the person may assign. Roles the person
972
+ * can't assign that the user already holds, and those from elsewhere (a category, an enrolment that
973
+ * protects them), stay. Returns the user's roles afterwards, as that column shows them. Throws
974
+ * `EnrolmentError` with Moodle's reason for a role the person can't assign or a user not enrolled.
975
+ */
976
+ setUserRoles(courseId: number, userId: number, roleIds: number[]): Promise<{
977
+ changed: string;
978
+ roleIds: number[];
979
+ }>;
980
+ /**
981
+ * Sets the marking workflow state of participants' submissions, as the grading table's "Set marking
982
+ * workflow state" does; "released" shows them their grades, notifying them when `notify` is true
983
+ * (the form's default is not to). With several markers, it sets the submission's overall state.
984
+ */
985
+ setWorkflowState(activityId: number, userIds: number[], state: "inmarking" | "readyforreview" | "inreview" | "readyforrelease" | "released", options?: {
986
+ notify?: boolean | undefined;
987
+ }): Promise<{
988
+ changed: string;
989
+ }>;
990
+ /**
991
+ * Switches a workshop to a phase, as its page's phase links do, confirming Moodle's question (any
992
+ * phase, forwards or back; Moodle allocates nothing and calculates no grades on its own when it
993
+ * switches). Returns a sentence of what changed and the phase afterwards. Throws `WorkshopError` when
994
+ * the person can't switch the workshop's phases (Moodle's `mod/workshop:switchphase`, a teacher's) or
995
+ * the id isn't a workshop's.
996
+ */
997
+ setWorkshopPhase(activityId: number, phase: import("./areas/workshops/workshops.js").WorkshopPhase): Promise<{
998
+ changed: string;
999
+ phase: import("./areas/workshops/workshops.js").WorkshopPhase;
1000
+ }>;
1001
+ /** The site's name, from its public settings; `undefined` where the mobile app support is off. */
1002
+ siteName(): Promise<string | undefined>;
1003
+ /**
1004
+ * Starts a discussion in a forum; returns its id, and whether it's pinned and the person subscribed
1005
+ * to it, as the forum lists it afterwards, so one call confirms what `subscribe` and `fields` set.
1006
+ */
1007
+ startDiscussion(activityId: number, input: import("./areas/forums/posts.js").PostInput & {
1008
+ subject: string;
1009
+ }): Promise<{
1010
+ changed: string;
1011
+ discussionId: number | undefined;
1012
+ pinned: boolean | undefined;
1013
+ subscribed: boolean | undefined;
1014
+ }>;
1015
+ /** Starts an attempt, or continues the one in progress, and gives its questions. */
1016
+ startQuizAttempt(activityId: number): Promise<{
1017
+ changed: string;
1018
+ attemptId: number;
1019
+ questions: import("./areas/quizzes/attempts.js").Question[];
1020
+ }>;
1021
+ /** 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. */
1022
+ studentAssignment(activityId: number): Promise<import("./areas/assignments/student.js").StudentAssignment>;
1023
+ /**
1024
+ * Submits the saved submission for grading, accepting the site's statement when it asks for one
1025
+ * (`acceptStatement`, once the person agrees; a bare boolean as before 0.2 too); gives the
1026
+ * assignment afterwards.
1027
+ */
1028
+ submitForGrading(activityId: number, options?: boolean | {
1029
+ acceptStatement?: boolean | undefined;
1030
+ }): Promise<{
1031
+ changed: string;
1032
+ assignment: import("./areas/assignments/student.js").StudentAssignment;
1033
+ }>;
1034
+ /**
1035
+ * Fills the survey page by page with `responses` (field name → value) and submits it on the last
1036
+ * page. Every name is checked against the form first, so nothing is sent with a wrong one.
1037
+ */
1038
+ submitSurvey(activityId: number, type: import("./areas/surveys/surveys.js").SurveyType, responses: Record<string, string>): Promise<{
1039
+ changed: string;
1040
+ messages: string[];
1041
+ }>;
1042
+ /**
1043
+ * Fills the survey page by page with `responses` (field name → value) and submits it on the last
1044
+ * page. Every name is checked against the form first, so nothing is sent with a wrong one.
1045
+ */
1046
+ submitSurvey(activityId: number, responses: Record<string, string>, options?: {
1047
+ type?: import("./areas/surveys/surveys.js").SurveyType | undefined;
1048
+ }): Promise<{
1049
+ changed: string;
1050
+ messages: string[];
1051
+ }>;
1052
+ /**
1053
+ * Unenrols a user from a course: removes every enrolment of theirs the person may remove (its
1054
+ * unenrol link on the participants page), with their roles and group memberships in the course, as
1055
+ * that link does. `changed` and `removed` say which ones (by enrolment method's name), `kept` those
1056
+ * the person may not remove (a cohort sync, another teacher's method). Throws `EnrolmentError` when
1057
+ * the user isn't enrolled.
1058
+ */
1059
+ unenrolUser(courseId: number, userId: number): Promise<{
1060
+ changed: string;
1061
+ removed: string[];
1062
+ kept: string[];
1063
+ }>;
1064
+ /** The person's upcoming events, as the calendar's "Upcoming events" view lists them, in one course or all. */
1065
+ upcomingEvents(options?: {
1066
+ courseId?: number | undefined;
1067
+ }): Promise<import("./areas/calendar/calendar.js").CalendarEvent[]>;
1068
+ /**
1069
+ * Changes an existing activity through its form: only what's given changes. A file resource's or
1070
+ * folder's files stay as they are unless `files` says what to add, remove or replace.
1071
+ */
1072
+ updateActivity(activityId: number, input: import("./areas/activities/build.js").ActivityFields & {
1073
+ files?: import("./areas/activities/build.js").FileChanges | undefined;
1074
+ }): Promise<import("./areas/activities/build.js").CourseChange>;
1075
+ /**
1076
+ * Changes a course's full name, short name, summary (HTML) or any other setting by its form field
1077
+ * name, through the course's settings form; returns the course as `listCourses` gives it. `embed`
1078
+ * takes local files the summary names (`<img src="shot.png">`), put in it as Moodle's editor does.
1079
+ * Moodle's refusals (a short name already taken) come back as `FormError` by field.
1080
+ */
1081
+ updateCourse(courseId: number, options: {
1082
+ fullName?: string | undefined;
1083
+ shortName?: string | undefined;
1084
+ summary?: string | undefined;
1085
+ settings?: Record<string, import("./core/forms.js").FieldValue> | undefined;
1086
+ embed?: string[] | undefined;
1087
+ }): Promise<{
1088
+ changed: string;
1089
+ course?: import("./areas/courses/list.js").Course | undefined;
1090
+ }>;
1091
+ /**
1092
+ * Changes a calendar event through the calendar's own form, opened on it: only what's given
1093
+ * changes. A new start keeps the event's length unless a new one is given. Returns the event as the
1094
+ * calendar has it afterwards.
1095
+ */
1096
+ updateEvent(eventId: number, changes: import("./areas/calendar/calendar.js").EventChanges): Promise<{
1097
+ changed: string;
1098
+ event: import("./areas/calendar/calendar.js").CalendarEvent;
1099
+ }>;
1100
+ /**
1101
+ * Changes a grade category: its name, its aggregation, its weight in its parent (percent, overriding
1102
+ * Natural's automatic one), or moves it into another category. Returns the category afterwards.
1103
+ */
1104
+ updateGradeCategory(courseId: number, categoryId: number, options: {
1105
+ name?: string | undefined;
1106
+ aggregation?: "mean" | "median" | "lowest" | "highest" | "mode" | "weighted-mean" | "simple-weighted-mean" | "mean-with-extra-credits" | "natural" | undefined;
1107
+ weight?: number | undefined;
1108
+ parentId?: number | undefined;
1109
+ }): Promise<{
1110
+ changed: string;
1111
+ category?: import("./areas/grades/gradebook.js").GradebookCategory | undefined;
1112
+ }>;
1113
+ /**
1114
+ * Changes a grade item: moves it into a category, sets its weight (percent, overriding Natural's
1115
+ * automatic one), or its maximum grade (a manual item's; an activity's is set in the activity).
1116
+ * Returns the item afterwards.
1117
+ */
1118
+ updateGradeItem(courseId: number, itemId: number, options: {
1119
+ category?: number | undefined;
1120
+ weight?: number | undefined;
1121
+ maxGrade?: number | undefined;
1122
+ }): Promise<{
1123
+ changed: string;
1124
+ item?: import("./areas/grades/gradebook.js").GradebookItem | undefined;
1125
+ }>;
1126
+ /** Changes a group's name, description, ID number or enrolment key with its form; what isn't given stays. */
1127
+ updateGroup(groupId: number, settings: import("./areas/participants/groups.js").GroupSettings): Promise<{
1128
+ changed: string;
1129
+ }>;
1130
+ /**
1131
+ * Changes a question of a bank through its type's edit form, with the same inputs as
1132
+ * `createQuestion` and only what's given (`answers` replaces them all). Saving makes a new version
1133
+ * of the question, with an id of its own: the one returned, which quizzes using the latest version
1134
+ * get from then on.
1135
+ */
1136
+ updateQuestion(activityId: number, questionId: number, input: Partial<Omit<import("./areas/questions/banks.js").QuestionInput, "type">>): Promise<{
1137
+ changed: string;
1138
+ questionId?: number | undefined;
1139
+ }>;
1140
+ /**
1141
+ * A user by id, or `undefined` when there's nobody: no such user, one the person may not see, or a
1142
+ * deleted account. Moodle keeps a deleted account's record and its user service still gives it to an
1143
+ * administrator, renamed, with the email replaced by an MD5 hash of the old username (`delete_user`,
1144
+ * confirmed empirically on the sandbox, 5.2); the driver treats it as gone.
1145
+ */
1146
+ userById(userId: number): Promise<import("./areas/site/users.js").User | undefined>;
1147
+ /** Who the logged-in person is; with `courseId`, also their roles and abilities in that course. */
1148
+ whoAmI(courseId?: number): Promise<import("./areas/site/users.js").Me>;
1149
+ /**
1150
+ * A workshop's phase, and its report as the workshop's page shows it to a teacher: every submission
1151
+ * (its author, title, and grade once calculated) and every assessment (reviewer, the submission's
1152
+ * author, the grade it gives, its weight, the grade for assessing once calculated), all of its pages.
1153
+ * The report is Moodle's own: it shows from the submission phase on to those who can see every
1154
+ * submission, in the course's current group; for anyone else the lists are empty. Grades are out of
1155
+ * the workshop's grade for submission, as Moodle shows them. Throws `WorkshopError` for an activity
1156
+ * that isn't a workshop the person can view.
1157
+ */
1158
+ workshopInfo(activityId: number): Promise<import("./areas/workshops/workshops.js").WorkshopInfo>;
1159
+ }