Webservice: Add course_exercises to get a list of tests from a course - refs BT#20478

pull/4552/head
Yannick Warnier 3 years ago
parent d3e5d875ec
commit a7cd2e10e4
  1. 10
      main/inc/lib/webservices/Rest.php
  2. 6
      main/webservices/api/v2.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
*/

@ -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;

Loading…
Cancel
Save