I am seeking assistance in determining a user's overall score and the maximum achievable score in a course. My goal is to calculate the percentage of total points the user has achieved throughout the entire course. Additionally, I am interested in the ability to set and retrieve a predefined threshold, representing a specific percentage of points, through an API.
I initially attempted to use the core_completion_get_course_completion_status function. However, I encountered an error for some courses, indicating that completion criteria were not set. Subsequently, I considered downloading all activities in the course and retrieving user results from each. However, the volume of data obtained led me to reconsider this approach as it seems overly complex.
I am in search of a simpler method to achieve these goals. If you have any suggestions or insights, I would greatly appreciate your assistance.
Thank you.
I've solved the problem by using method
gradereport_user_get_grade_items. From the response provided I managed to get a list of objects and iterate over it until I find an item with property:itemtypeset tocourseandgradeisoverriddenset tofalse. From this item I can get:graderaw- raw value of the gradegradeformatted- string representing formatted gradegrademin- minimal grade that can be obtainedgrademax- maximum grade that can be obtainedTo the request I must add such headers:
wstoken- access token (with needed permissions)wsfunction- moodle method (gradereport_user_get_grade_items)moodlewsrestformat- optional (json, xml - default)courseid- ID of the courseuserid- ID of the user for whom the grade is being searchedCurl example: