moodle_save_grade
Saves a participant's assignment grade and feedback comments after teacher confirmation, making them visible to the student and triggering notifications if enabled.
Instructions
Saves a participant's grade for an assignment and writes feedback comments. THE STUDENT WILL SEE the grade and feedback (immediately, or after release if marking workflow is enabled) and may receive a notification. Call only after the teacher has explicitly confirmed the grade and the text. The grade is checked against the assignment maximum. If feedback is omitted, the existing feedback is kept unchanged.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| grade | Yes | Grade: points from 0 to the assignment maximum; for a scale, the item number from 1 | |
| userId | Yes | Participant id (userId from moodle_list_submissions) | |
| feedback | No | Feedback comments for the student; if omitted, the existing feedback is kept | |
| addAttempt | No | Open a new attempt for the student (if the assignment allows it) | |
| applyToAll | No | For group assignments, apply the grade to the whole group | |
| assignmentId | Yes | Assignment id from moodle_list_assignments (the id field, NOT the cmid from the mod/assign/view.php?id=… URL) | |
| attemptNumber | No | Attempt number; -1 means the latest | |
| workflowState | No | Marking workflow state (if enabled): notmarked, inmarking, readyforreview, inreview, readyforrelease, released | |
| feedbackFormat | No | feedback format: plain — plain text (paragraphs separated by a blank line), markdown, html | plain |