diff --git a/main/inc/lib/webservices/Rest.php b/main/inc/lib/webservices/Rest.php index 7a986e0a80..6eea34b5dd 100644 --- a/main/inc/lib/webservices/Rest.php +++ b/main/inc/lib/webservices/Rest.php @@ -60,6 +60,7 @@ class Rest extends WebService public const GET_COURSE_LP_PROGRESS = 'course_lp_progress'; public const GET_COURSE_LINKS = 'course_links'; public const GET_COURSE_WORKS = 'course_works'; + public const GET_COURSE_EXERCISES = 'course_exercises'; public const GET_COURSES_DETAILS_BY_EXTRA_FIELD = 'courses_details_by_extra_field'; public const SAVE_COURSE_NOTEBOOK = 'save_course_notebook'; @@ -3053,6 +3054,15 @@ class Rest extends WebService ); } + public function getCourseExercises(): array + { + Event::event_access_tool(TOOL_QUIZ); + + $sessionId = $this->session ? $this->session->getId() : 0; + $courseInfo = api_get_course_info_by_id($this->course->getId()); + return ExerciseLib::get_all_exercises($courseInfo, $sessionId); + } + /** * @throws Exception */ diff --git a/main/webservices/api/v2.php b/main/webservices/api/v2.php index fd8f14b6cb..b816da1a4d 100644 --- a/main/webservices/api/v2.php +++ b/main/webservices/api/v2.php @@ -302,6 +302,12 @@ try { $restApi->getCourseWorks() ); break; + case Rest::GET_COURSE_EXERCISES: + Event::addEvent(LOG_WS.$action, 'course_id', (int) $_POST['course']); + $restResponse->setData( + $restApi->getCourseExercises() + ); + break; case Rest::SAVE_COURSE_NOTEBOOK: $title = !empty($_POST['title']) ? $_POST['title'] : null; $text = !empty($_POST['text']) ? $_POST['text'] : null;