I need to make a different front-end I need good API interface for Question Bank/Question Engine? I didn't find much details on this.. Can someone help?
Asked
Active
Viewed 239 times
1 Answers
0
Doesn't look like there is a web service for the question bank
https://docs.moodle.org/dev/Web_service_API_functions
If you know PHP, then you could create your own web service in Moodle
https://moodledev.io/docs/apis/subsystems/external
First you will need to create a simple local plugin
https://moodledev.io/docs/apis/plugintypes/local
At the very least, have these 2 files
local/yourpluginname/version.php
local/yourpluginname/en/local_yourpluginname.php
Then add a web service to the plugin
https://moodledev.io/docs/apis/subsystems/external/writing-a-service
Declare your web service in this file
local/yourpluginname/db/services.php
And add the code for the web service to something like
local/yourpluginname/classes/external/get_questions.php
The class will need 3 functions, what parameters are required, what parameters are returned and code for the web service
namespace local_yourpluginname\external;
use external_function_parameters;
use external_multiple_structure;
use external_single_structure;
use external_value;
class get_questions extends \core_external\external_api {
public static function execute_parameters() {
...
}
public static function execute_returns() {
...
}
public static function execute($params) {
...
}
}

Russell England
- 9,436
- 1
- 27
- 41
-
Thanks for your response. I am using Moodle 4.1.2 (MOODLE_4012). I am creating the web application that's why I need API from Moodle and I have found this web services wsfunction=core_course_get_courses to get all courses from moodle that is fine and it worked. so I am also looking is there any web services to get all the question from moodle question bank. If yes then help for this. I tried but could not get success. I want a simple documentation for this from where I can see the endpoint for the question bank and simply call them to get those question from question bank. – suraj shukl Mar 28 '23 at 15:43