Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
f3b6bae
Adds option to enable course-level drip settings for lessons, in numb…
brianhogg Feb 20, 2024
a4a23c1
Add "ignore first X lessons" setting. Setting minimum delay to be 1 day.
brianhogg Feb 20, 2024
9a4dac2
WIP: Apply course-level settings if no lesson-level settings set. Wil…
brianhogg Feb 20, 2024
d6ef634
If course-level drip settings set, ignore any saved lesson-level ones…
brianhogg Feb 20, 2024
b613c2c
Removing var dumps
brianhogg Feb 20, 2024
aabc958
Ensure we have an enrollment date or a course start date to determine…
brianhogg Feb 20, 2024
f7f1602
Hide the lesson drip settings in the course builder if the course has…
brianhogg Feb 20, 2024
f340530
WIP: Scaffolding additional unit tests
brianhogg Feb 20, 2024
7f94b5d
WIP: Adding a message if there are course-level drip settings
brianhogg Feb 20, 2024
6e4fa8b
Wording tweak
brianhogg Feb 21, 2024
4316fd7
Hide rest of inputs when lesson drip toggled off
brianhogg Feb 21, 2024
a25797a
WIP: There doesn't seem to be any way to grab the course dynamically …
brianhogg Feb 21, 2024
6ecfab2
Adding "link" to exit course builder to set the course-level drip set…
brianhogg Feb 22, 2024
8cd289a
Moving code to builder/Schemas (via npm run start:legacy)
brianhogg Feb 22, 2024
71af4de
Add message with link to course edit at the top of Edit Lesson, Restr…
brianhogg Feb 22, 2024
2deb54f
Hide lesson drip settings if course-level drip settings are enabled.
brianhogg Feb 22, 2024
1f354de
Merge branch 'dev' into feature/course-level-lesson-drip
brianhogg Feb 22, 2024
8428548
Test for get available date with course-level
brianhogg Feb 23, 2024
a7114e0
Formatting
brianhogg Feb 23, 2024
009c262
Formatting fixes.
brianhogg Feb 23, 2024
3b7b6b7
Fixing test.
brianhogg Feb 26, 2024
d259c2e
Merge branch 'dev' into feature/course-level-lesson-drip
brianhogg Feb 26, 2024
b416cf3
Formatting fixes.
brianhogg Feb 26, 2024
e24c505
Adding changelog.
brianhogg Feb 26, 2024
8e48939
Spacing. Removing TODOs.
brianhogg Feb 26, 2024
37e1881
Removing unneeded tests. Test for looking at the course start date if…
brianhogg Feb 26, 2024
e1f5525
Removing comments, spacing.
brianhogg Feb 26, 2024
3a22045
Merge branch 'dev' into feature/course-level-lesson-drip
ideadude Apr 16, 2024
6deeebb
Merge branch 'dev' into feature/course-level-lesson-drip
ideadude Apr 16, 2024
a4623c5
Update includes/admin/post-types/meta-boxes/class.llms.meta.box.cours…
brianhogg Apr 16, 2024
0d2a6b3
Update includes/admin/post-types/meta-boxes/class.llms.meta.box.lesso…
brianhogg Apr 16, 2024
f202413
Merge branch 'dev' into feature/course-level-lesson-drip
ideadude Apr 16, 2024
938fa38
Merge branch 'dev' into feature/course-level-lesson-drip
ideadude Apr 16, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .changelogs/feature_course-level-lesson-drip.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
significance: minor
type: added
entry: Adds course-level lesson drip settings.
35 changes: 35 additions & 0 deletions assets/js/builder/Schemas/Lesson.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,36 @@ define( [], function() {
return this.get_available_prereq_options();
},
},
], [
{
label: LLMS.l10n.translate( 'Course Drip Method' ),
id: 'course-drip',
type: 'heading',
condition: function() {
return ( this.get_course() && 'yes' === this.get_course().get( 'lesson_drip' ) && this.get_course().get( 'drip_method' ) );
},
detail: LLMS.l10n.translate( 'Drip settings are currently set at the course level, under the Restrictions settings tab. Disable to allow lesson level drip settings.' ) + ' <a href=\"javascript:document.getElementById(\'llms-exit-button\').click()\">' + LLMS.l10n.translate( 'Edit Course' ) + '</a>',
},
], [
{
label: LLMS.l10n.translate( 'Course Drip Method' ),
id: 'course-drip',
type: 'heading',
condition: function() {
return ( ! this.get_course() || 'yes' !== this.get_course().get( 'lesson_drip' ) || ! this.get_course().get( 'drip_method' ) );
},
detail: LLMS.l10n.translate( 'Drip settings can be set at the course level to release course content at a specified interval, in the Restrictions settings tab.' ) + ' <a href=\"javascript:document.getElementById(\'llms-exit-button\').click()\">' + LLMS.l10n.translate( 'Edit Course' ) + '</a>',
},
], [
{
attribute: 'drip_method',
id: 'drip-method',
label: LLMS.l10n.translate( 'Drip Method' ),
switch_attribute: 'drip_method',
type: 'select',
condition: function() {
return ( ! this.get_course() || 'yes' !== this.get_course().get( 'lesson_drip' ) || ! this.get_course().get( 'drip_method' ) );
},
options: function() {

var options = [
Expand Down Expand Up @@ -132,6 +155,10 @@ define( [], function() {
{
attribute: 'days_before_available',
condition: function() {
if ( this.get_course() && 'yes' === this.get_course().get( 'lesson_drip' ) && this.get_course().get( 'drip_method' ) ) {
return false;
}

return ( -1 !== [ 'enrollment', 'start', 'prerequisite' ].indexOf( this.get( 'drip_method' ) ) );
},
id: 'days-before-available',
Expand All @@ -143,6 +170,10 @@ define( [], function() {
attribute: 'date_available',
date_format: 'Y-m-d',
condition: function() {
if ( this.get_course() && 'yes' === this.get_course().get( 'lesson_drip' ) && this.get_course().get( 'drip_method' ) ) {
return false;
}

return ( 'date' === this.get( 'drip_method' ) );
},
id: 'date-available',
Expand All @@ -153,6 +184,10 @@ define( [], function() {
{
attribute: 'time_available',
condition: function() {
if ( this.get_course() && 'yes' === this.get_course().get( 'lesson_drip' ) && this.get_course().get( 'drip_method' ) ) {
return false;
}

return ( 'date' === this.get( 'drip_method' ) );
},
datepicker: 'false',
Expand Down
37 changes: 37 additions & 0 deletions assets/js/llms-builder.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,51 @@ public function get_fields() {
'label' => __( 'Choose Prerequisite Course Track', 'lifterlms' ),
'value' => $course_tracks,
),

array(
'type' => 'checkbox',
'label' => __( 'Enable Lesson Drip', 'lifterlms' ),
'desc' => __( 'Set global drip restrictions so lesson content becomes available at an interval you define for the course.', 'lifterlms' ),
'id' => $this->prefix . 'lesson_drip',
'is_controller' => true,
'value' => 'yes',
'class' => '',
'desc_class' => 'd-3of4 t-3of4 m-1of2',
),
array(
'class' => 'llms-select2',
'controller' => '#' . $this->prefix . 'lesson_drip',
'controller_value' => 'yes',
'is_controller' => true,
'type' => 'select',
'id' => $this->prefix . 'drip_method',
'label' => __( 'Drip Method', 'lifterlms' ),
'value' => array(
array(
'key' => 'start',
'title' => __( 'After course start or enrollment', 'lifterlms' ),
),
),
),
array(
'controller' => '#' . $this->prefix . 'lesson_drip',
'controller_value' => 'yes',
'class' => 'input-full',
'id' => $this->prefix . 'ignore_lessons',
'label' => __( 'Number of lessons to make immediately available on course start', 'lifterlms' ),
'type' => 'number',
'step' => 1,
'min' => 1,
),
array(
'controller' => '#' . $this->prefix . 'lesson_drip',
'controller_value' => 'yes',
'class' => 'input-full',
'id' => $this->prefix . 'days_before_available',
'label' => __( 'Delay (in days) ', 'lifterlms' ),
'type' => 'number',
'step' => 1,
'min' => 1,
),
array(
'is_controller' => true,
'type' => 'checkbox',
Expand Down
100 changes: 64 additions & 36 deletions includes/admin/post-types/meta-boxes/class.llms.meta.box.lesson.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public function get_fields() {
unset( $methods['start'] );
}

return array(
$fields = array(
array(
'title' => __( 'General', 'lifterlms' ),
'fields' => array(
Expand Down Expand Up @@ -134,44 +134,13 @@ public function get_fields() {
),
),
),
array(
'drip' => array(
'title' => __( 'Drip Settings', 'lifterlms' ),
'fields' => array(
array(
'class' => 'llms-select2',
'desc_class' => 'd-all',
'id' => $this->prefix . 'drip_method',
'is_controller' => true,
'label' => __( 'Method', 'lifterlms' ),
'type' => 'select',
'value' => $methods,
),
array(
'controller' => '#' . $this->prefix . 'drip_method',
'controller_value' => 'lesson,enrollment,start,prerequisite',
'class' => 'input-full',
'id' => $this->prefix . 'days_before_available',
'label' => __( 'Delay (in days) ', 'lifterlms' ),
'type' => 'number',
'step' => 1,
'min' => 0,
),
array(
'controller' => '#' . $this->prefix . 'drip_method',
'controller_value' => 'date',
'class' => 'llms-datepicker',
'id' => $this->prefix . 'date_available',
'label' => __( 'Date Available', 'lifterlms' ),
'type' => 'date',
),
array(
'controller' => '#' . $this->prefix . 'drip_method',
'controller_value' => 'date',
'class' => '',
'desc' => __( 'Optionally enter a time when the lesson should become available. If no time supplied, lesson will be available at 12:00 AM. Format must be HH:MM AM', 'lifterlms' ),
'id' => $this->prefix . 'time_available',
'label' => __( 'Time Available', 'lifterlms' ),
'type' => 'text',
'type' => 'custom-html',
'id' => $this->prefix . 'drip_course_settings_info',
'value' => $this->get_drip_course_settings_info_html( $course ),
),
),
),
Expand All @@ -191,8 +160,67 @@ public function get_fields() {
),
),
);

if ( 'yes' !== $course->get( 'lesson_drip' ) || ! $course->get( 'drip_method' ) ) {
$fields['drip']['fields'][] = array(
'class' => 'llms-select2',
'desc_class' => 'd-all',
'id' => $this->prefix . 'drip_method',
'is_controller' => true,
'label' => __( 'Method', 'lifterlms' ),
'type' => 'select',
'value' => $methods,
);
$fields['drip']['fields'][] = array(
'controller' => '#' . $this->prefix . 'drip_method',
'controller_value' => 'lesson,enrollment,start,prerequisite',
'class' => 'input-full',
'id' => $this->prefix . 'days_before_available',
'label' => __( 'Delay (in days) ', 'lifterlms' ),
'type' => 'number',
'step' => 1,
'min' => 0,
);
$fields['drip']['fields'][] = array(
'controller' => '#' . $this->prefix . 'drip_method',
'controller_value' => 'date',
'class' => 'llms-datepicker',
'id' => $this->prefix . 'date_available',
'label' => __( 'Date Available', 'lifterlms' ),
'type' => 'date',
);
$fields['drip']['fields'][] = array(
'controller' => '#' . $this->prefix . 'drip_method',
'controller_value' => 'date',
'class' => '',
'desc' => __( 'Optionally enter a time when the lesson should become available. If no time supplied, lesson will be available at 12:00 AM. Format must be HH:MM AM', 'lifterlms' ),
'id' => $this->prefix . 'time_available',
'label' => __( 'Time Available', 'lifterlms' ),
'type' => 'text',
);
}

return $fields;
}

/**
* Helpful messaging depending on whether the course for this lesson has drip settings enabled or not.
*
* @since [version]
*
* @param LLMS_Course $course Course object.
* @return string
*/
public function get_drip_course_settings_info_html( $course ) {
$output = 'yes' === $course->get( 'lesson_drip' ) && $course->get( 'drip_method' ) ?
__( 'Drip settings are currently set at the course level, under the Restrictions settings tab. If you would like to set individual drip settings for each lesson, you must disable the course level drip settings first.', 'lifterlms' )
:
__( 'Drip settings can be set at the course level to release course content at a specified interval, in the Restrictions settings tab.', 'lifterlms' );

$output .= ' <a href="' . admin_url( 'post.php?post=' . $course->get( 'id' ) . '&action=edit#lifterlms-course-options' ) . '">' . __( 'Edit Course', 'lifterlms' ) . '</a>';

return $output;
}
}

new LLMS_Meta_Box_Lesson();
3 changes: 3 additions & 0 deletions includes/admin/views/builder/settings-fields.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,9 @@ class="llms-input standard"
<span class="llms-label llms-label--after">{{{ field.label_after }}}</span>
<# } #>

<# if ( field.detail ) { #>
<div class="llms-detail">{{{ field.detail }}}</div>
<# } #>
</div>
<# } ); #>
</div>
Expand Down
4 changes: 4 additions & 0 deletions includes/models/model.llms.course.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,10 @@ class LLMS_Course extends LLMS_Post_Model implements LLMS_Interface_Post_Instruc
'tile_featured_video' => 'yesno',
'time_period' => 'yesno',
'start_date' => 'text',
'lesson_drip' => 'yesno',
'drip_method' => 'text',
'ignore_lessons' => 'absint',
'days_before_available' => 'absint',

// Private.
'temp_calc_data' => 'array',
Expand Down
Loading