LLMS_REST_Lessons_Controller::get_item_schema()
Get the Lesson’s schema, conforming to JSON Schema.
Return Return
(array) Item schema data.
Source Source
File: libraries/lifterlms-rest/includes/server/class-llms-rest-lessons-controller.php
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' ),
),
),
),
);
Expand full source code Collapse full source code View on GitHub
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. |