PluginProbe
Tutor LMS – eLearning and online course solution / 2.7.1
Tutor LMS – eLearning and online course solution v2.7.1
4.0.7 4.0.6 4.0.5 4.0.4 4.0.3 4.0.2 4.0.1 4.0.0 3.9.15 3.9.14 3.9.13 3.9.12 3.9.11 trunk 1.0.0 1.0.0-alpha 1.0.1 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9 All 191 releases
← All changes | classes/RestAPI.php +27 -47 2.7.02.7.1 View file →
@@ -165,53 +165,12 @@
165 165 'permission_callback' => array( RestAuth::class, 'process_api_request' ),
166 166 )
167 167 );
168 168
169 - // Courses by terms cat and tag.
170 - register_rest_route(
171 - $this->namespace,
172 - '/course-by-terms',
173 - array(
174 - 'methods' => 'POST',
175 - 'callback' => array(
176 - $this->course_obj,
177 - 'course_by_terms',
178 - ),
179 - 'permission_callback' => array( RestAuth::class, 'process_api_request' ),
180 - )
181 - );
182 -
183 - // Courses by terms cat and tag.
184 - register_rest_route(
185 - $this->namespace,
186 - '/course-sorting-by-price',
187 - array(
188 - 'methods' => 'GET',
189 - 'callback' => array(
190 - $this->course_obj,
191 - 'course_sort_by_price',
192 - ),
193 - 'args' => array(
194 - 'order' => array(
195 - 'required' => true,
196 - 'type' => 'string',
197 - 'validate_callback' => function ( $order ) {
198 - return $this->validate_order( $order );
199 - },
200 - ),
201 - 'page' => array(
202 - 'required' => false,
203 - 'type' => 'number',
204 - ),
205 - ),
206 - 'permission_callback' => array( RestAuth::class, 'process_api_request' ),
207 - )
208 - );
209 -
210 169 // Course details.
211 170 register_rest_route(
212 171 $this->namespace,
213 - '/course-detail/(?P<id>\d+)',
172 + '/courses/(?P<id>\d+)',
214 173 array(
215 174 'methods' => 'GET',
216 175 'callback' => array(
217 176 $this->course_obj,
@@ -230,9 +189,9 @@
230 189
231 190 // Course topic.
232 191 register_rest_route(
233 192 $this->namespace,
234 - '/course-topic/(?P<id>\d+)',
193 + '/topics',
235 194 array(
236 195 'methods' => 'GET',
237 196 'callback' => array(
238 197 $this->topic_obj,
@@ -238,9 +197,9 @@
238 197 $this->topic_obj,
239 198 'course_topic',
240 199 ),
241 200 'args' => array(
242 - 'id' => array(
201 + 'course_id' => array(
243 202 'validate_callback' => function ( $param ) {
244 203 return is_numeric( $param );
245 204 },
246 205 ),
@@ -251,9 +210,9 @@
251 210
252 211 // Lesson by topic.
253 212 register_rest_route(
254 213 $this->namespace,
255 - '/lesson/(?P<id>\d+)',
214 + '/lessons',
256 215 array(
257 216 'methods' => 'GET',
258 217 'callback' => array(
259 218 $this->lesson_obj,
@@ -259,9 +218,9 @@
259 218 $this->lesson_obj,
260 219 'topic_lesson',
261 220 ),
262 221 'args' => array(
263 - 'id' => array(
222 + 'topic_id' => array(
264 223 'validate_callback' => function ( $param ) {
265 224 return is_numeric( $param );
266 225 },
267 226 ),
@@ -293,14 +252,35 @@
293 252
294 253 // Quiz by topic id.
295 254 register_rest_route(
296 255 $this->namespace,
297 - '/quiz/(?P<id>\d+)',
256 + '/quizzes',
298 257 array(
299 258 'methods' => 'GET',
300 259 'callback' => array(
301 260 $this->quiz_obj,
302 261 'quiz_with_settings',
262 + ),
263 + 'args' => array(
264 + 'topic_id' => array(
265 + 'validate_callback' => function ( $param ) {
266 + return is_numeric( $param );
267 + },
268 + ),
269 + ),
270 + 'permission_callback' => array( RestAuth::class, 'process_api_request' ),
271 + )
272 + );
273 +
274 + // Quiz by quiz id.
275 + register_rest_route(
276 + $this->namespace,
277 + '/quizzes/(?P<id>\d+)',
278 + array(
279 + 'methods' => 'GET',
280 + 'callback' => array(
281 + $this->quiz_obj,
282 + 'get_quiz',
303 283 ),
304 284 'args' => array(
305 285 'id' => array(
306 286 'validate_callback' => function ( $param ) {