Skip to content

Commit

Permalink
Merge branch 'dev' into fix/date-range-widget
Browse files Browse the repository at this point in the history
  • Loading branch information
brianhogg authored Feb 5, 2025
2 parents 27d3459 + 0de75d2 commit 2987b13
Show file tree
Hide file tree
Showing 12 changed files with 98 additions and 69 deletions.
5 changes: 5 additions & 0 deletions .changelogs/fix_my-grades-single-layout.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
significance: patch
type: fixed
links:
- "#2869"
entry: Avoid grades table wrapping in the My Grades section of the student dashboard.
5 changes: 5 additions & 0 deletions .changelogs/fix_new-lesson-selected-course-builder.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
significance: patch
type: fixed
links:
- "#2855"
entry: Open the lesson panel after adding a new lesson in the Course Builder.
3 changes: 3 additions & 0 deletions .changelogs/fix_quiz-attempt-with-deleted-question.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
significance: patch
type: deprecated
entry: Fixed issues with viewing quiz attempts when questions were deleted.
3 changes: 3 additions & 0 deletions .changelogs/save-trackd-events-more-often.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
significance: patch
type: added
entry: Setting to increase the frequency user tracked events are saved.
2 changes: 1 addition & 1 deletion assets/js/app/llms-tracking.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ LLMS.Tracking = function( settings ) {
store.set( 'events', all );

// If couldn't store the latest event because of size limits.
if ( all.length > store.get( 'events', [] ).length ) {
if ( settings.saving_frequency === 'always' || all.length > store.get( 'events', [] ).length ) {

// Copy the cookie in a temporary variable.
var _temp = store.getAll();
Expand Down
17 changes: 13 additions & 4 deletions assets/js/builder/Views/Lesson.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ define( [
* @version 3.16.12
*/
events: _.defaults( {
'click .edit-lesson': 'open_lesson_editor',
'click .llms-headline': 'open_lesson_editor',
'click .edit-lesson': 'edit_lesson',
'click .llms-headline': 'edit_lesson',
'click .edit-quiz': 'open_quiz_editor',
'click .edit-assignment': 'open_assignment_editor',
'click .section-prev': 'section_prev',
Expand Down Expand Up @@ -88,7 +88,7 @@ define( [
this.listenTo( this.model, 'change', this.render );

Backbone.pubSub.on( 'lesson-selected', this.on_select, this );
Backbone.pubSub.on( 'new-lesson-added', this.on_select, this );
Backbone.pubSub.on( 'new-lesson-added', this.maybe_open_editor, this );

},

Expand Down Expand Up @@ -139,16 +139,25 @@ define( [
* @since 3.16.0
* @version 3.27.0
*/
open_lesson_editor: function( event ) {
edit_lesson: function( event ) {

if ( event ) {
event.preventDefault();
}

this.open_lesson_editor();
},

open_lesson_editor: function() {
Backbone.pubSub.trigger( 'lesson-selected', this.model, 'lesson' );
this.model.set( '_selected', true );
this.set_hash( false );
},

maybe_open_editor: function( model ) {
if ( this.model.id === model.id ) {
this.open_lesson_editor();
}
},

/**
Expand Down
2 changes: 2 additions & 0 deletions assets/js/builder/Views/LessonEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,8 @@ define( [

this.render_points_percentage();

this.$('.llms-editable-title').focus();

return this;

},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@ public function manage_post_row_actions( $actions, $post ) {

$link = get_permalink( $post );
if ( $link ) {
$label = sprintf( esc_attr__( 'View "%s"', 'lifterlms' ), $post->post_title );
$actions['view'] = sprintf( '<a href="%1$s" rel="bookmark" aria-label="%2$s">%3$s</a>', esc_url( $link ), $label, __( 'View', 'lifterlms' ) );
$label = sprintf( __( 'View "%s"', 'lifterlms' ), $post->post_title );
$actions['view'] = sprintf( '<a href="%1$s" rel="bookmark" aria-label="%2$s">%3$s</a>', esc_url( $link ), esc_attr( $label ), esc_html__( 'View', 'lifterlms' ) );
}

return $actions;
Expand Down
16 changes: 12 additions & 4 deletions includes/admin/settings/class.llms.settings.general.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ public function __construct() {
add_filter( 'lifterlms_settings_tabs_array', array( $this, 'add_settings_page' ), 20 );
add_action( 'lifterlms_settings_' . $this->id, array( $this, 'output' ) );
add_action( 'lifterlms_settings_save_' . $this->id, array( $this, 'save' ) );

}

/**
Expand Down Expand Up @@ -115,13 +114,24 @@ function ( $role ) {
'type' => 'checkbox',
);

$settings[] = array(
'title' => __( 'Frequency of Saving Tracked Events', 'lifterlms' ),
'default' => 'minimum',
'desc' => __( 'Specifies how often tracked events are sent to the server. "Minimum" sends only when local storage is almost full (fewer network calls). "Always" sends each event immediately (higher accuracy, more server load).', 'lifterlms' ),
'id' => 'lifterlms_tracked_event_saving_frequency',
'type' => 'select',
'options' => array(
'minimum' => __( 'Minimum', 'lifterlms' ),
'always' => __( 'Always', 'lifterlms' ),
),
);

$settings[] = array(
'id' => 'general_settings',
'type' => 'sectionend',
);

return apply_filters( 'lifterlms_general_settings', $settings );

}

/**
Expand All @@ -133,9 +143,7 @@ public function save() {

$settings = $this->get_settings();
LLMS_Admin_Settings::save_fields( $settings );

}

}

return new LLMS_Settings_General();
16 changes: 3 additions & 13 deletions includes/class-llms-events.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ private function __construct() {

add_action( 'init', array( $this, 'register_events' ), 9 );
add_action( 'init', array( $this, 'store_cookie' ) );

}

/**
Expand Down Expand Up @@ -74,11 +73,11 @@ public function get_client_settings() {
return apply_filters(
'llms_events_get_client_settings',
array(
'nonce' => wp_create_nonce( 'llms-tracking' ),
'events' => $events,
'nonce' => wp_create_nonce( 'llms-tracking' ),
'events' => $events,
'saving_frequency' => get_option( 'lifterlms_tracked_event_saving_frequency', 'minimum' ),
)
);

}

/**
Expand All @@ -104,7 +103,6 @@ public function get_registered_events() {
protected function is_event_valid( $event ) {

return array_key_exists( $event, $this->get_registered_events() );

}

/**
Expand Down Expand Up @@ -149,7 +147,6 @@ public function prepare_event( $raw_event = array() ) {
}

return $prepared;

}

/**
Expand Down Expand Up @@ -221,7 +218,6 @@ public function record( $args = array() ) {
}

return $llms_event;

}

/**
Expand Down Expand Up @@ -260,7 +256,6 @@ public function record_many( $events = array() ) {
$wpdb->query( 'COMMIT' );

return $recorded;

}

/**
Expand Down Expand Up @@ -297,7 +292,6 @@ public function register_events() {
* @param array $events Array of events. Array key is the event name and array value is used to determine if the key is a client-side event.
*/
$this->registered_events = apply_filters( 'llms_get_registered_events', $events );

}

/**
Expand Down Expand Up @@ -333,7 +327,6 @@ protected function sanitize_raw_event( $raw ) {
}

return $clean;

}

/**
Expand Down Expand Up @@ -391,7 +384,6 @@ protected function should_track_client_events() {
* @param string[] $post_types Array of post types that should be tracked.
*/
return apply_filters( 'llms_tracking_should_track_client_events', $ret, $post_types );

}

/**
Expand Down Expand Up @@ -419,7 +411,6 @@ public function store_cookie() {

// Cookie reset.
llms_setcookie( 'llms-tracking', '', time() - 60, COOKIEPATH ? COOKIEPATH : '/', COOKIE_DOMAIN, llms_is_site_https() && is_ssl() );

}

/**
Expand Down Expand Up @@ -453,5 +444,4 @@ public function store_tracking_events( $tracking ) {

return true;
}

}
88 changes: 46 additions & 42 deletions templates/myaccount/my-grades-single.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,54 +11,58 @@

<?php if ( $course ) : ?>

<?php do_action( 'llms_before_my_grades_content', $course, $student ); ?>
<div class="llms-sd-section llms-sd-grades">

<section class="llms-sd-widgets">
<?php do_action( 'llms_before_my_grades_content', $course, $student ); ?>

<?php
do_action( 'llms_before_my_grades_widgets', $course, $student );
<section class="llms-sd-widgets">

llms_sd_dashboard_donut_widget(
__( 'Progress', 'lifterlms' ),
$student->get_progress( $course->get( 'id' ) ),
__( 'Complete', 'lifterlms' )
);
llms_sd_dashboard_donut_widget(
__( 'Grade', 'lifterlms' ),
$student->get_grade( $course->get( 'id' ) ),
__( 'Overall Grade', 'lifterlms' )
);
llms_sd_dashboard_date_widget(
__( 'Enrollment Date', 'lifterlms' ),
$student->get_enrollment_date( $course->get( 'id' ), 'enrolled', 'U' )
);
llms_sd_dashboard_widget(
__( 'Latest Achievement', 'lifterlms' ),
$latest_achievement ? llms_get_achievement( $latest_achievement ) : '',
__( 'No achievements', 'lifterlms' )
);
llms_sd_dashboard_date_widget(
__( 'Last Activity', 'lifterlms' ),
$last_activity,
__( 'No activity', 'lifterlms' )
);
<?php
do_action( 'llms_before_my_grades_widgets', $course, $student );

do_action( 'llms_after_my_grades_widgets', $course, $student );
?>
llms_sd_dashboard_donut_widget(
__( 'Progress', 'lifterlms' ),
$student->get_progress( $course->get( 'id' ) ),
__( 'Complete', 'lifterlms' )
);
llms_sd_dashboard_donut_widget(
__( 'Grade', 'lifterlms' ),
$student->get_grade( $course->get( 'id' ) ),
__( 'Overall Grade', 'lifterlms' )
);
llms_sd_dashboard_date_widget(
__( 'Enrollment Date', 'lifterlms' ),
$student->get_enrollment_date( $course->get( 'id' ), 'enrolled', 'U' )
);
llms_sd_dashboard_widget(
__( 'Latest Achievement', 'lifterlms' ),
$latest_achievement ? llms_get_achievement( $latest_achievement ) : '',
__( 'No achievements', 'lifterlms' )
);
llms_sd_dashboard_date_widget(
__( 'Last Activity', 'lifterlms' ),
$last_activity,
__( 'No activity', 'lifterlms' )
);

</section>
do_action( 'llms_after_my_grades_widgets', $course, $student );
?>

<?php
/**
* Hook: llms_my_grades_course_table.
*
* @hooked lifterlms_template_student_dashboard_my_grades_table - 10
*/
do_action( 'llms_my_grades_course_table', $course, $student );
?>
</section>

<?php else : ?>
<div class="llms-sd-section">
<?php
/**
* Hook: llms_my_grades_course_table.
*
* @hooked lifterlms_template_student_dashboard_my_grades_table - 10
*/
do_action( 'llms_my_grades_course_table', $course, $student );
?>
</div>
</div>
<?php else : ?>

<p><?php esc_html_e( 'Invalid course.', 'lifterlms' ); ?>
<p><?php esc_html_e( 'Invalid course.', 'lifterlms' ); ?></p>

<?php endif; ?>
<?php endif; ?>
6 changes: 3 additions & 3 deletions templates/quiz/results-attempt-questions-list.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,16 @@
$quiz_question = $attempt_question->get_question();
if ( ! $quiz_question ) { // Question missing/deleted.
?>
<li class="llms-quiz-attempt-question type--<?php echo esc_attr( $quiz_question->get( 'question_type' ) ); ?> status--<?php echo esc_attr( $attempt_question->get_status() ); ?> <?php echo $attempt_question->is_correct() ? 'correct' : 'incorrect'; ?>"
data-question-id="<?php echo esc_attr( $quiz_question->get( 'id' ) ); ?>"
<li class="llms-quiz-attempt-question type--deleted status--<?php echo esc_attr( $attempt_question->get_status() ); ?> <?php echo $attempt_question->is_correct() ? 'correct' : 'incorrect'; ?>"
data-question-id="<?php echo esc_attr( $attempt_question->get( 'id' ) ); ?>"
data-grading-manual="<?php echo $attempt_question->can_be_manually_graded() ? 'yes' : 'no'; ?>"
data-points="<?php echo esc_attr( $attempt_question->get( 'points' ) ); ?>"
data-points-curr="<?php echo esc_attr( $attempt_question->get( 'earned' ) ); ?>">
<header class="llms-quiz-attempt-question-header">
<span class="toggle-answer">
<h3 class="llms-question-title"><?php esc_html_e( 'This question has been deleted', 'lifterlms' ); ?></h3>
<span class="llms-points">
<?php if ( $quiz_question->get( 'points' ) ) : ?>
<?php if ( $attempt_question->get( 'points' ) ) : ?>
<?php echo esc_html( sprintf( __( '%1$d / %2$d points', 'lifterlms' ), $attempt_question->get( 'earned' ), $attempt_question->get( 'points' ) ) ); ?>
<?php endif; ?>
</span>
Expand Down

0 comments on commit 2987b13

Please sign in to comment.