LLMS_REST_Lessons_Controller::get_item_schema()

Get the Lesson’s schema, conforming to JSON Schema.


Return Return

(array) Item schema data.


Top ↑

Source Source

File: libraries/lifterlms-rest/includes/server/class-llms-rest-lessons-controller.php

308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
    return ! empty( $to_set );
 
}
 
/**
 * Get the Lesson's schema, conforming to JSON Schema.
 *
 * @since 1.0.0-beta.27
 *
 * @return array Item schema data.
 */
protected function get_item_schema_base() {
 
    $schema = (array) parent::get_item_schema_base();
 
    $lesson_properties = array(
        'parent_id'    => array(
            'description' => __( 'WordPress post ID of the parent item. Must be a Section ID. 0 indicates an "orphaned" lesson which can be edited and viewed by instructors and admins but cannot be read by students.', 'lifterlms' ),
            'type'        => 'integer',
            'context'     => array( 'view', 'edit' ),
            'arg_options' => array(
                'sanitize_callback' => 'absint',
            ),
        ),
        'course_id'    => array(
            'description' => __( 'WordPress post ID of the lesson\'s parent course.', 'lifterlms' ),
            'type'        => 'integer',
            'context'     => array( 'view', 'edit' ),
            'arg_options' => array(
                'sanitize_callback' => 'absint',
            ),
            'readonly'    => true,
        ),
        'order'        => array(
            'description' => __( 'Order of the lesson within its immediate parent.', 'lifterlms' ),
            'type'        => 'integer',
            'default'     => 1,
            'context'     => array( 'view', 'edit' ),
            'arg_options' => array(
                'sanitize_callback' => 'absint',
            ),
            'required'    => true,
        ),
        'prerequisite' => array(
            'description' => __( 'Lesson ID of the prerequisite lesson.', 'lifterlms' ),
            'type'        => 'integer',
            'context'     => array( 'view', 'edit' ),
            'arg_options' => array(
                'sanitize_callback' => 'absint',
            ),
        ),
        'points'       => array(
            'description' => __( 'Determines the weight of the lesson when grading the course.', 'lifterlms' ),
            'type'        => 'integer',
            'default'     => 1,
            'context'     => array( 'view', 'edit' ),
            'arg_options' => array(
                'sanitize_callback' => 'absint',
            ),
        ),
        'audio_embed'  => array(
            'description' => __( 'URL to an oEmbed enable audio URL.', 'lifterlms' ),
            'type'        => 'string',
            'context'     => array( 'view', 'edit' ),
            'format'      => 'uri',
            'arg_options' => array(
                'sanitize_callback' => 'esc_url_raw',
            ),
        ),
        'video_embed'  => array(
            'description' => __( 'URL to an oEmbed enable video URL.', 'lifterlms' ),
            'type'        => 'string',
            'context'     => array( 'view', 'edit' ),
            'format'      => 'uri',
            'arg_options' => array(
                'sanitize_callback' => 'esc_url_raw',
            ),
        ),
        'drip_date'    => array(
            'description' => __(
                'The date and time when the lesson becomes available. Applicable only when drip_method is date. Format: Y-m-d H:i:s.',
                'lifterlms'
            ),
            'type'        => 'string',
            'context'     => array( 'view', 'edit' ),
        ),
        'drip_days'    => array(
            'description' => __( 'Number of days to wait before allowing access to the lesson. Applicable only when drip_method is enrollment, start, or prerequisite.', 'lifterlms' ),
            'type'        => 'integer',
            'default'     => 1,
            'context'     => array( 'view', 'edit' ),
            'arg_options' => array(
                'sanitize_callback' => 'absint',
            ),
        ),
        'drip_method'  => array(
            'description' => __(
                'Determine the method with which to make the lesson content available.
                <ul>
                    <li>none: Drip is disabled; the lesson is immediately available.</li>
                    <li>date: Lesson is made available at a specific date and time.</li>
                    <li>enrollment: Lesson is made available a specific number of days after enrollment into the course.</li>
                    <li>start: Lesson is made available a specific number of days after the course\'s start date. Only available on courses with a access_opens_date.</li>
                    <li>prerequisite: Lesson is made available a specific number of days after the prerequisite lesson is completed.</li>
                </ul>',
                'lifterlms'
            ),
            'type'        => 'string',
            'default'     => 'none',
            'enum'        => array( 'none', 'date', 'enrollment', 'start', 'prerequisite' ),
            'context'     => array( 'view', 'edit' ),
        ),
        'public'       => array(
            'description' => __( 'Denotes a lesson that\'s publicly accessible regardless of course enrollment.', 'lifterlms' ),
            'type'        => 'boolean',
            'default'     => false,
            'context'     => array( 'view', 'edit' ),
        ),
        'quiz'         => array(
            'description' => __( 'Associate a quiz with this lesson.', 'lifterlms' ),
            'type'        => 'object',
            'context'     => array( 'view', 'edit' ),
            'arg_options' => array(
                'sanitize_callback' => null, // Note: sanitization implemented in self::prepare_item_for_database().
                'validate_callback' => null, // Note: validation implemented in self::prepare_item_for_database().
            ),
            'properties'  => array(
                'enabled'     => array(
                    'description' => __( 'Determines if a quiz is enabled for the lesson.', 'lifterlms' ),
                    'type'        => 'boolean',
                    'default'     => false,
                    'context'     => array( 'view', 'edit' ),
                ),
                'id'          => array(
                    'description' => __( 'The post ID of the associated quiz.', 'lifterlms' ),
                    'type'        => 'integer',
                    'default'     => 0,
                    'context'     => array( 'view', 'edit' ),
                    'arg_options' => array(
                        'sanitize_callback' => 'absint',
                    ),
                ),
                'progression' => array(
                    'description' => __(
                        'Determines lesson progression requirements related to the quiz.
                        <ul>
                            <li>complete: The quiz must be completed (with any grade) to progress the lesson.</li>
                            <li>pass: A passing grade must be earned to progress the lesson.</li>
                        </ul>',
                        'lifterlms'
                    ),
                    'type'        => 'string',
                    'default'     => 'complete',
                    'enum'        => array( 'complete', 'pass' ),
                    'context'     => array( 'view', 'edit' ),
                ),
            ),
        ),
    );


Top ↑

Changelog Changelog

Changelog
Version Description
1.0.0-beta.7 Added the following properties: drip_date, drip_days, drip_method, public, quiz. Added llms_rest_lesson_item_schema filter hook.
1.0.0-beta.15 Fixed course_id property access: it must be read-only.
1.0.0-beta.1 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.