Moodle API - get quizz attempt/data - permission problem

Moodle API - get quizz attempt/data - permission problem

Höfundur Maxime Paintendre -
Number of replies: 0

Hello everyone.

first of all sorry for my bad english....

I'm fairly new to Moodle and as part of a pro project, I need an external system to retrieve data from a quiz via the API. 

More than that, a lot of the user management, enrolment cohorts and other stuff will have to be handled by the external system.


So I followed the doc and I have : 

Enable the web services

Activate the rest protocol

Create a specific user

Manage the user capacities

Create a service

Add functions

 Select user

Create a token for a user


All these steps are done correctly and my user is able to create users, groups, cohorts...

But I have a problem when I get to the step of retrieving attempts and data related to a quiz.

Indeed, I try to retrieve the attempts of a quiz via: `mod_quiz_get_user_attempts` but I encounter an unknown error: 

{

  "exception": "required_capability_exception",

  "errorcode": "nopermissions",

  "message": "Sorry, you currently do not have the required permissions to perform this (View test reports)"

}

but when I check the capabilities of the user using the API, I see : 

View test reports: mod/quiz:viewreports => YES


I'm a bit stumped by this error, and I need your knowledge.

I imagine that the permission error is related to the quiz context but without being able to confirm or know how to modify that.


Thanks in advance!

Meðaltal dóma: -