LearnPress – WordPress LMS Plugin - Version 4.1.6.9.1

Version Description

(2022-08-04) = ~ Fixed: error ESC content of course, items' course make iframe, embed not working. ~ Fixed: error complete lesson, do quiz on API for App mobile.

Download this release

Release Info

Developer ThimPress
Plugin Icon 128x128 LearnPress – WordPress LMS Plugin
Version 4.1.6.9.1
Comparing to
See all releases

Code changes from version 4.1.6.9 to 4.1.6.9.1

assets/src/apps/js/frontend/courses.js CHANGED
@@ -110,6 +110,7 @@ window.lpArchiveRequestCourse = ( args, callBackSuccess ) => {
110
  }
111
  } ).catch( ( error ) => {
112
  listCourse.innerHTML += `<div class="lp-ajax-message error" style="display:block">${ error.message || 'Error: Query lp/v1/courses/archive-course' }</div>`;
 
113
  } ).finally( () => {
114
  isLoading = false;
115
  // skeleton && skeleton.remove();
110
  }
111
  } ).catch( ( error ) => {
112
  listCourse.innerHTML += `<div class="lp-ajax-message error" style="display:block">${ error.message || 'Error: Query lp/v1/courses/archive-course' }</div>`;
113
+ console.log( error );
114
  } ).finally( () => {
115
  isLoading = false;
116
  // skeleton && skeleton.remove();
inc/admin/lp-admin-functions.php CHANGED
@@ -205,18 +205,6 @@ function learn_press_admin_view( $name, $args = array(), $include_once = false,
205
  return false;
206
  }
207
 
208
- /**
209
- * Vue write php has script, so when sanitize will error, so use code is mask pass check sanitize, esc
210
- *
211
- * @param $content
212
- *
213
- * @return void
214
- * @since 4.1.6.9
215
- */
216
- function learn_press_echo_vuejs_write_on_php( $content ) {
217
- echo ( $content );
218
- }
219
-
220
  /**
221
  * List all pages as a dropdown with "Add New Page" option
222
  *
205
  return false;
206
  }
207
 
 
 
 
 
 
 
 
 
 
 
 
 
208
  /**
209
  * List all pages as a dropdown with "Add New Page" option
210
  *
inc/admin/views/meta-boxes/order/child-order.php DELETED
@@ -1,49 +0,0 @@
1
- <?php
2
- /**
3
- * Child Order in multil site.
4
- */
5
-
6
- if ( ! isset( $order ) ) {
7
- $order = learn_press_get_order();
8
- }
9
-
10
- if ( ! $order->is_multi_users() ) {
11
- return;
12
- }
13
- ?>
14
-
15
- <h4><?php echo esc_html_e( 'Child orders', 'learnpress' ); ?></h4>
16
-
17
- <table class="wp-list-table widefat fixed striped posts">
18
- <thead>
19
- <tr>
20
- <th>#</th>
21
- <th><?php esc_html_e( 'Customer', 'learnpress' ); ?></th>
22
- <th><?php esc_html_e( 'Order key', 'learnpress' ); ?></th>
23
- <th><?php esc_html_e( 'Status', 'learnpress' ); ?></th>
24
- </tr>
25
- </thead>
26
-
27
- <tbody>
28
- <?php $child_orders = $order->get_child_orders(); ?>
29
-
30
- <?php foreach ( $child_orders as $child_order_id ) : ?>
31
- <?php
32
- $child_order = learn_press_get_order( $child_order_id );
33
-
34
- if ( ! $child_order ) {
35
- continue;
36
- }
37
- ?>
38
-
39
- <tr>
40
- <td>
41
- <strong><?php echo sprintf( '<a href="%s">%s</a>', admin_url( 'post.php?post=' . $child_order->get_id() . '&action=edit' ), $child_order->get_order_number() ); ?></strong>
42
- </td>
43
- <td><?php echo $child_order->get_customer_name(); ?></td>
44
- <td><?php echo $child_order->get_order_key(); ?></td>
45
- <td><?php echo $child_order->get_status(); ?></td>
46
- </tr>
47
- <?php endforeach; ?>
48
- </tbody>
49
- </table>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
inc/course/class-lp-course.php CHANGED
@@ -772,7 +772,7 @@ if ( ! class_exists( 'LP_Course' ) ) {
772
  }
773
 
774
  $item_arr = (array) $item;
775
- $item_arr['title'] = $itemObject->get_title();
776
  $item_arr['preview'] = $itemObject->is_preview();
777
  $section_items_arr['items'][] = $item_arr;
778
  }
772
  }
773
 
774
  $item_arr = (array) $item;
775
+ $item_arr['title'] = html_entity_decode( $itemObject->get_title() );
776
  $item_arr['preview'] = $itemObject->is_preview();
777
  $section_items_arr['items'][] = $item_arr;
778
  }
inc/curds/class-lp-helper-curd.php DELETED
@@ -1,114 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * Class LP_Helper_CURD
5
- *
6
- * @since 3.0.0
7
- */
8
- class LP_Helper_CURD {
9
- /**
10
- * @var int
11
- */
12
- protected static $_time = 0;
13
-
14
- /**
15
- * Update meta into cache by ids.
16
- *
17
- * @since 3.0.0
18
- *
19
- * @param string $type - E.g: post, user, ...
20
- * @param array|int $ids
21
- * @param int $limit
22
- * @depecated 4.1.6.4
23
- */
24
- public static function update_meta_cache( $ids, $type = 'post', $limit = 500 ) {
25
- _deprecated_function( __CLASS__ . '::' . __FUNCTION__, '4.1.6.4' );
26
- if ( ! $ids ) {
27
- return;
28
- }
29
-
30
- //@since 3.3.0
31
- settype( $ids, 'array' );
32
-
33
- sort( $ids );
34
- $cache_key = md5( serialize( $ids ) );
35
-
36
- if ( false === ( $meta_data = LP_Object_Cache::get( $cache_key, "{$type}-meta" ) ) ) {
37
- $meta_data = array();
38
-
39
- if ( $limit > 0 ) {
40
- $chunks = array_chunk( $ids, $limit );
41
- foreach ( $chunks as $chunk ) {
42
- $cache = update_meta_cache( $type, $chunk );
43
- $meta_data = $meta_data + $cache;// array_merge( $meta_data, $cache );
44
- }
45
- } else {
46
- $meta_data = update_meta_cache( $type, $ids );
47
- }
48
-
49
- LP_Object_Cache::set( $cache_key, $meta_data, "{$type}-meta" );
50
- }
51
-
52
- foreach ( $ids as $id ) {
53
- if ( ! isset( $meta_data[ $id ] ) ) {
54
- $meta_data[ $id ] = array();
55
- }
56
-
57
- wp_cache_set( $id, $meta_data[ $id ], "{$type}_meta" );
58
- }
59
-
60
- }
61
-
62
- /**
63
- * Load posts from database into cache.
64
- *
65
- * @param int|array $post_ids
66
- *
67
- * @return mixed
68
- * @depecated 4.1.6.4
69
- */
70
- public static function cache_posts( $post_ids ) {
71
- _deprecated_function( __CLASS__ . '::' . __FUNCTION__, '4.1.6.4' );
72
- global $wpdb;
73
- settype( $post_ids, 'array' );
74
-
75
- // Remove the posts has already cached
76
- for ( $n = sizeof( $post_ids ), $i = $n - 1; $i >= 0; $i -- ) {
77
- if ( false !== wp_cache_get( $post_ids[ $i ], 'posts' ) ) {
78
- unset( $post_ids[ $i ] );
79
- }
80
- }
81
-
82
- if ( ! sizeof( $post_ids ) ) {
83
- return false;
84
- }
85
-
86
- $format = array_fill( 0, sizeof( $post_ids ), '%d' );
87
- $query = $wpdb->prepare(
88
- "
89
- SELECT *
90
- FROM {$wpdb->posts}
91
- WHERE ID IN(" . join( ',', $format ) . ')
92
- ',
93
- $post_ids
94
- );
95
-
96
- if ( false === ( $post_types = LP_Object_Cache::get( 'post-types', 'learn-press' ) ) ) {
97
- $post_types = array();
98
- }
99
-
100
- if ( $posts = $wpdb->get_results( $query ) ) {
101
- foreach ( $posts as $post ) {
102
- $post = sanitize_post( $post, 'raw' );
103
- $post_types[ $post->ID ] = $post->post_type;
104
-
105
- wp_cache_set( $post->ID, $post, 'posts' );
106
- }
107
- }
108
-
109
- // self::update_meta_cache( $post_ids );
110
- learn_press_cache_add_post_type( $post_types );
111
-
112
- return $posts;
113
- }
114
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
inc/curds/class-lp-user-curd.php CHANGED
@@ -883,8 +883,9 @@ class LP_User_CURD extends LP_Object_Data_CURD implements LP_Interface_CURD {
883
  * @param int $course_id
884
  *
885
  * @return mixed
 
886
  */
887
- public function get_user_items( $user_id, $course_id ) {
888
  if ( false === ( $course_data = LP_Object_Cache::get(
889
  'course-' . $user_id . '-' . $course_id,
890
  'learn-press/user-item-courses'
@@ -893,16 +894,19 @@ class LP_User_CURD extends LP_Object_Data_CURD implements LP_Interface_CURD {
893
  }
894
 
895
  return $course_data['items'];
896
- }
897
 
898
- public function get_user_completed_items( $user_id, $course_id ) {
 
 
 
899
  if ( ! $items = $this->get_user_items( $user_id, $course_id ) ) {
900
  return false;
901
  }
902
  foreach ( $items as $item ) {
903
 
904
  }
905
- }
906
 
907
  /**
908
  * Read meta data of an user item.
883
  * @param int $course_id
884
  *
885
  * @return mixed
886
+ * @depecated 4.1.6.9.1
887
  */
888
+ /*public function get_user_items( $user_id, $course_id ) {
889
  if ( false === ( $course_data = LP_Object_Cache::get(
890
  'course-' . $user_id . '-' . $course_id,
891
  'learn-press/user-item-courses'
894
  }
895
 
896
  return $course_data['items'];
897
+ }*/
898
 
899
+ /**
900
+ * @depecated 4.1.6.9.1
901
+ */
902
+ /*public function get_user_completed_items( $user_id, $course_id ) {
903
  if ( ! $items = $this->get_user_items( $user_id, $course_id ) ) {
904
  return false;
905
  }
906
  foreach ( $items as $item ) {
907
 
908
  }
909
+ }*/
910
 
911
  /**
912
  * Read meta data of an user item.
inc/custom-post-types/quiz.php CHANGED
@@ -295,22 +295,25 @@ if ( ! class_exists( 'LP_Quiz_Post_Type' ) ) {
295
  $duration_str .= 's';
296
  $duration_str_arr = explode( ' ', $duration_str );
297
  $type_time = '';
298
- switch ( $duration_str_arr[1] ) {
299
- case 'hours':
300
- $type_time = __( 'hours', 'learnpress' );
301
- break;
302
- case 'minutes':
303
- $type_time = __( 'minutes', 'learnpress' );
304
- break;
305
- case 'days':
306
- $type_time = __( 'days', 'learnpress' );
307
- break;
308
- case 'weeks':
309
- $type_time = __( 'weeks', 'learnpress' );
310
- break;
311
- }
312
 
313
- $duration_str = sprintf( '%1$s %2$s', $duration_str_arr[0], $type_time );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
314
  } else {
315
  $duration_str = '--';
316
  }
295
  $duration_str .= 's';
296
  $duration_str_arr = explode( ' ', $duration_str );
297
  $type_time = '';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
298
 
299
+ if ( is_array( $duration_str_arr ) && ! empty( $duration_str_arr ) && count( $duration_str_arr ) >= 2 ) {
300
+ switch ( $duration_str_arr[1] ) {
301
+ case 'hours':
302
+ $type_time = __( 'hours', 'learnpress' );
303
+ break;
304
+ case 'minutes':
305
+ $type_time = __( 'minutes', 'learnpress' );
306
+ break;
307
+ case 'days':
308
+ $type_time = __( 'days', 'learnpress' );
309
+ break;
310
+ case 'weeks':
311
+ $type_time = __( 'weeks', 'learnpress' );
312
+ break;
313
+ }
314
+
315
+ $duration_str = sprintf( '%1$s %2$s', $duration_str_arr[0], $type_time );
316
+ }
317
  } else {
318
  $duration_str = '--';
319
  }
inc/databases/class-lp-user-items-db.php CHANGED
@@ -708,7 +708,7 @@ class LP_User_Items_DB extends LP_Database {
708
  * @throws Exception
709
  */
710
  public function get_user_quizzes( LP_User_Items_Filter $filter ) {
711
- $this->wpdb->query( "SET GLOBAL sql_mode=(SELECT REPLACE(@@sql_mode,'ONLY_FULL_GROUP_BY',''))" );
712
  $offset = ( absint( $filter->page ) - 1 ) * $filter->limit;
713
 
714
  $WHERE = '';
708
  * @throws Exception
709
  */
710
  public function get_user_quizzes( LP_User_Items_Filter $filter ) {
711
+ @$this->wpdb->query( "SET GLOBAL sql_mode=(SELECT REPLACE(@@sql_mode,'ONLY_FULL_GROUP_BY',''))" );
712
  $offset = ( absint( $filter->page ) - 1 ) * $filter->limit;
713
 
714
  $WHERE = '';
inc/jwt/rest-api/version1/class-lp-rest-lessons-v1-controller.php CHANGED
@@ -555,4 +555,52 @@ class LP_Jwt_Lessons_V1_Controller extends LP_REST_Jwt_Posts_Controller {
555
 
556
  return $this->add_additional_fields_schema( $schema );
557
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
558
  }
555
 
556
  return $this->add_additional_fields_schema( $schema );
557
  }
558
+
559
+ /**
560
+ * API get item lesson
561
+ * @since 4.1.6.9.1
562
+ *
563
+ * @param $request
564
+ *
565
+ * @return WP_Error|WP_HTTP_Response|WP_REST_Response
566
+ * @throws Exception
567
+ */
568
+ public function get_item( $request ) {
569
+ $object = $this->get_object( (int) $request['id'] );
570
+
571
+ if ( ! $object || 0 === $object->get_id() ) {
572
+ return new WP_Error( "lp_rest_{$this->post_type}_invalid_id", esc_html__( 'Invalid ID.', 'learnpress' ), array( 'status' => 404 ) );
573
+ }
574
+
575
+ $item_id = (int) $request['id'];
576
+
577
+ $course_id = $this->get_course_by_item_id( $item_id );
578
+ $course = learn_press_get_course( $course_id );
579
+ if ( $course && is_user_logged_in() ) {
580
+ $user = learn_press_get_current_user();
581
+ $course_data = $user->get_course_data( $course_id );
582
+
583
+ if ( $course_data && $course_data->is_enrolled() ) {
584
+ $item = $course_data->get_item( $item_id );
585
+
586
+ if ( ! $item ) {
587
+ $item = LP_User_Item::get_item_object( $item_id );
588
+
589
+ $item->set_ref_id( $course_id );
590
+ $item->set_parent_id( $course_data->get_user_item_id() );
591
+ $item->update();
592
+ }
593
+ }
594
+ }
595
+
596
+ $data = $this->prepare_object_for_response( $object, $request );
597
+ $response = rest_ensure_response( $data );
598
+
599
+ if ( $this->public ) {
600
+ $response->link_header( 'alternate', $this->get_permalink( $object ), array( 'type' => 'text/html' ) );
601
+ }
602
+
603
+ return $response;
604
+ }
605
+
606
  }
inc/jwt/rest-api/version1/class-lp-rest-quiz-v1-controller.php CHANGED
@@ -417,7 +417,9 @@ class LP_Jwt_Quiz_V1_Controller extends LP_REST_Jwt_Posts_Controller {
417
  }
418
 
419
  public function get_quiz_results( $quiz, $get_question = false ) {
420
- $output = array();
 
 
421
 
422
  $user = learn_press_get_current_user();
423
 
@@ -440,7 +442,7 @@ class LP_Jwt_Quiz_V1_Controller extends LP_REST_Jwt_Posts_Controller {
440
  $answered = array();
441
  $status = '';
442
  $checked_questions = array();
443
- $question_ids = array();
444
 
445
  if ( $user_quiz ) {
446
  $status = $user_quiz->get_status();
@@ -462,8 +464,6 @@ class LP_Jwt_Quiz_V1_Controller extends LP_REST_Jwt_Posts_Controller {
462
  $output['results'] = $quiz_results->get();
463
  $answered = $quiz_results->getQuestions();
464
  $question_ids = $quiz_results->getQuestions( 'ids' );
465
- } else {
466
- $question_ids = $quiz->get_question_ids();
467
  }
468
 
469
  $output['answered'] = ! empty( $answered ) ? (object) $answered : new stdClass();
417
  }
418
 
419
  public function get_quiz_results( $quiz, $get_question = false ) {
420
+ $output = array(
421
+ 'status' => '',
422
+ );
423
 
424
  $user = learn_press_get_current_user();
425
 
442
  $answered = array();
443
  $status = '';
444
  $checked_questions = array();
445
+ $question_ids = $quiz->get_question_ids();
446
 
447
  if ( $user_quiz ) {
448
  $status = $user_quiz->get_status();
464
  $output['results'] = $quiz_results->get();
465
  $answered = $quiz_results->getQuestions();
466
  $question_ids = $quiz_results->getQuestions( 'ids' );
 
 
467
  }
468
 
469
  $output['answered'] = ! empty( $answered ) ? (object) $answered : new stdClass();
inc/lp-core-functions.php CHANGED
@@ -10,6 +10,18 @@
10
 
11
  defined( 'ABSPATH' ) || exit;
12
 
 
 
 
 
 
 
 
 
 
 
 
 
13
  function learnpress_gutenberg_disable_cpt( $can_edit, $post_type ) {
14
  $post_types = array(
15
  LP_COURSE_CPT => LP_Settings::get_option( 'enable_gutenberg_course', 'no' ),
10
 
11
  defined( 'ABSPATH' ) || exit;
12
 
13
+ /**
14
+ * Vue write php has script, so when sanitize will error, so use code is mask pass check sanitize, esc
15
+ *
16
+ * @param $content
17
+ *
18
+ * @return void
19
+ * @since 4.1.6.9
20
+ */
21
+ function learn_press_echo_vuejs_write_on_php( $content ) {
22
+ echo ( $content );
23
+ }
24
+
25
  function learnpress_gutenberg_disable_cpt( $can_edit, $post_type ) {
26
  $post_types = array(
27
  LP_COURSE_CPT => LP_Settings::get_option( 'enable_gutenberg_course', 'no' ),
inc/user-item/class-lp-user-item-course.php CHANGED
@@ -381,223 +381,6 @@ class LP_User_Item_Course extends LP_User_Item implements ArrayAccess {
381
  return $results;
382
  }
383
 
384
- /**
385
- * @editor tungnx
386
- * @modify 4.1.4.1 - comment - not use
387
- */
388
- /*
389
- public function count_items() {
390
- global $wpdb;
391
- $t = microtime( true );
392
- $course = $this->get_course();
393
- $item_ids = $course->get_items();
394
- $item_ids_format = LP_Helper::db_format_array( $item_ids, '%d' );
395
-
396
- $query = LP_Helper::prepare(
397
- "
398
- SELECT MAX(user_item_id) user_item_id
399
- FROM {$wpdb->learnpress_user_items}
400
- WHERE user_id = %d
401
- AND item_id IN (" . $item_ids_format . ')
402
- GROUP BY item_id
403
- ',
404
- $this->get_user_id(),
405
- $item_ids
406
- );
407
-
408
- if ( $user_item_ids = $wpdb->get_col( $query ) ) {
409
-
410
- $item_types = learn_press_get_course_item_types();
411
- $item_types_format = LP_Helper::db_format_array( $item_types, '%s' );
412
-
413
- $query = LP_Helper::prepare(
414
- "
415
- SELECT ui.*, p.post_type AS item_type, grade.meta_value as grade, data.meta_value as data, results.meta_value as results, version.meta_value as version
416
- FROM {$wpdb->learnpress_user_items} ui
417
- LEFT JOIN {$wpdb->learnpress_user_itemmeta} grade ON ui.user_item_id = grade.learnpress_user_item_id AND grade.meta_key = '%s'
418
- LEFT JOIN {$wpdb->learnpress_user_itemmeta} data ON ui.user_item_id = data.learnpress_user_item_id AND data.meta_key = '%s'
419
- LEFT JOIN {$wpdb->learnpress_user_itemmeta} results ON ui.user_item_id = results.learnpress_user_item_id AND results.meta_key = '%s'
420
- LEFT JOIN {$wpdb->learnpress_user_itemmeta} version ON ui.user_item_id = version.learnpress_user_item_id AND version.meta_key = '%s'
421
- INNER JOIN {$wpdb->posts} p ON p.ID = ui.item_id
422
- WHERE user_item_id IN(" . LP_Helper::db_format_array( $user_item_ids ) . ')
423
- AND p.post_type IN(' . $item_types_format . ')
424
- ',
425
- 'grade',
426
- 'data',
427
- 'results',
428
- 'version',
429
- $user_item_ids,
430
- $item_types
431
- );
432
-
433
- $user_items = $wpdb->get_results( $query );
434
- $user_items_by_types = array();
435
-
436
- if ( $user_items ) {
437
- foreach ( $user_items as $k => $user_item ) {
438
- $user_items[ $k ]->data = maybe_unserialize( $user_item->data );
439
- $user_items[ $k ]->results = maybe_unserialize( $user_item->results );
440
-
441
- if ( empty( $user_items_by_types[ $user_item->item_type ] ) ) {
442
- $user_items_by_types[ $user_item->item_type ] = array();
443
- }
444
- $user_items_by_types[ $user_item->item_type ][] = $user_item->item_id;
445
- }
446
- }
447
-
448
- learn_press_debug( $user_items, $user_items_by_types );
449
-
450
- }
451
-
452
- }*/
453
-
454
- /**
455
- * Evaluate course results by count quizzes passed/all quizzes.
456
- *
457
- * @param bool $hard - Optional. TRUE will re-calculate results instead of get from cache
458
- *
459
- * @return array|mixed
460
- * @since 4.0.0
461
- * @author Nhamdv <email@email.com>
462
- */
463
- protected function _evaluate_results_by_passed_per_all_quizzes( $hard = false ) {
464
- $cache_key = 'user-course-' . $this->get_user_id() . '-' . $this->get_id();
465
- $cache_sub_key = 'passed-per-all-quizzes';
466
- $cached_data = LP_Object_Cache::get( $cache_key, 'learn-press/course-results' );
467
-
468
- if ( $hard || false === $cached_data || ! array_key_exists( $cache_sub_key, $cached_data ) ) {
469
- $data = array(
470
- 'items_completed' => 0,
471
- 'items_count' => 0,
472
- 'result' => 0,
473
- 'status' => $this->get_status(),
474
- );
475
-
476
- $items = $this->get_items( true );
477
- if ( $items ) {
478
- foreach ( $items as $item ) {
479
- if ( $item->get_type() !== LP_QUIZ_CPT ) {
480
- continue;
481
- }
482
-
483
- $data['items_completed'] += $item->get_status( 'graduation' ) == 'passed' ? 1 : 0;
484
- $data['items_count'] ++;
485
- }
486
-
487
- $data['result'] = $data['items_count'] ? ( $data['items_completed'] / $data['items_count'] ) * 100 : 0;
488
- }
489
-
490
- if ( $cached_data ) {
491
- $cached_data[ $cache_sub_key ] = $data;
492
- } else {
493
- $cached_data = array( $cache_sub_key => $data );
494
- }
495
-
496
- LP_Object_Cache::set( $cache_key, $cached_data, 'learn-press/course-results' );
497
- }
498
-
499
- return isset( $cached_data[ $cache_sub_key ] ) ? $cached_data[ $cache_sub_key ] : array();
500
- }
501
-
502
- protected function _evaluate_course_by_question( $hard = false ) {
503
- $cache_key = 'user-course-' . $this->get_user_id() . '-' . $this->get_id();
504
- $cached_data = LP_Object_Cache::get( $cache_key, 'learn-press/course-results' );
505
-
506
- if ( $hard || false === $cached_data || ! array_key_exists( 'questions', $cached_data ) ) {
507
- $data = array(
508
- 'result' => 0,
509
- 'status' => $this->get_status(),
510
- );
511
-
512
- $result = 0;
513
- $result_of_items = 0;
514
-
515
- $items = $this->get_items();
516
-
517
- if ( $items ) {
518
- foreach ( $items as $item ) {
519
- if ( $item->get_type() !== LP_QUIZ_CPT ) {
520
- continue;
521
- }
522
-
523
- $quiz_result = $item->get_results( '' );
524
-
525
- if ( $quiz_result ) {
526
- if ( $quiz_result['question_correct'] ) {
527
- $result += absint( $quiz_result['question_correct'] );
528
- }
529
- }
530
-
531
- $result_of_items += ! empty( $item->get_questions() ) ? count( $item->get_questions() ) : 0;
532
- }
533
-
534
- $result = $result_of_items ? ( $result * 100 ) / $result_of_items : 0;
535
- $data['result'] = $result;
536
- }
537
-
538
- settype( $cached_data, 'array' );
539
- $cached_data['questions'] = $data;
540
-
541
- LP_Object_Cache::set( $cache_key, $cached_data, 'learn-press/course-results' );
542
- }
543
-
544
- return isset( $cached_data['questions'] ) ? $cached_data['questions'] : array();
545
- }
546
-
547
- protected function _evaluate_course_by_mark() {
548
- $cache_key = 'user-course-' . $this->get_user_id() . '-' . $this->get_id();
549
- $cached_data = LP_Object_Cache::get( $cache_key, 'learn-press/course-results' );
550
-
551
- if ( false === $cached_data || ! array_key_exists( 'marks', $cached_data ) ) {
552
- $data = array(
553
- 'result' => 0,
554
- 'status' => $this->get_status(),
555
- );
556
-
557
- $result = 0;
558
- $result_of_items = 0;
559
-
560
- $items = $this->get_items();
561
-
562
- if ( $items ) {
563
- foreach ( $items as $item ) {
564
- if ( $item->get_type() !== LP_QUIZ_CPT ) {
565
- continue;
566
- }
567
-
568
- $questions = $item->get_questions();
569
- $quiz_result = $item->get_results( '' );
570
-
571
- if ( $questions ) {
572
- foreach ( $questions as $question_id ) {
573
- $question = LP_Question::get_question( $question_id );
574
-
575
- if ( $question ) {
576
- $result_of_items += absint( $question->get_mark() );
577
- }
578
- }
579
- }
580
-
581
- if ( $quiz_result ) {
582
- if ( $quiz_result['user_mark'] ) {
583
- $result += $quiz_result['user_mark'];
584
- }
585
- }
586
- }
587
-
588
- $result = $result_of_items ? ( $result * 100 ) / $result_of_items : 0;
589
- $data['result'] = $result;
590
- }
591
-
592
- settype( $cached_data, 'array' );
593
- $cached_data['marks'] = $data;
594
-
595
- LP_Object_Cache::set( $cache_key, $cached_data, 'learn-press/course-results' );
596
- }
597
-
598
- return isset( $cached_data['marks'] ) ? $cached_data['marks'] : array();
599
- }
600
-
601
  /**
602
  * Get graduation
603
  *
@@ -624,53 +407,7 @@ class LP_User_Item_Course extends LP_User_Item implements ArrayAccess {
624
  * @return int|string
625
  */
626
  public function get_percent_result( $decimal = 1 ) {
627
- return apply_filters(
628
- 'learn-press/user/course-percent-result',
629
- sprintf(
630
- '%s%%',
631
- round( $this->get_results( 'result' ), $decimal ),
632
- $this->get_user_id(),
633
- $this->get_item_id()
634
- )
635
- );
636
- }
637
-
638
- /**
639
- * Evaluate course result by lessons.
640
- *
641
- * @param bool $hard
642
- *
643
- * @return array
644
- */
645
- protected function _evaluate_course_by_lesson( $hard = false ) {
646
- $cache_key = 'user-course-' . $this->get_user_id() . '-' . $this->get_id();
647
- $cached_data = LP_Object_Cache::get( $cache_key, 'learn-press/course-results' );
648
-
649
- if ( $hard || false === $cached_data || ! array_key_exists( 'lessons', $cached_data ) ) {
650
- $completing = $this->get_completed_items( LP_LESSON_CPT, true );
651
-
652
- if ( $completing[1] ) {
653
- $result = $completing[0] / $completing[1];
654
- } else {
655
- $result = 0;
656
- }
657
-
658
- $result *= 100;
659
- $data = array(
660
- 'result' => $result,
661
- 'status' => $this->get_status(),
662
- );
663
-
664
- if ( $cached_data ) {
665
- $cached_data['lessons'] = $data;
666
- } else {
667
- $cached_data = array( 'lessons' => $data );
668
- }
669
-
670
- LP_Object_Cache::set( $cache_key, $cached_data, 'learn-press/course-results' );
671
- }
672
-
673
- return isset( $cached_data['lessons'] ) ? $cached_data['lessons'] : array();
674
  }
675
 
676
  /**
@@ -928,26 +665,6 @@ class LP_User_Item_Course extends LP_User_Item implements ArrayAccess {
928
  return $evaluate;
929
  }
930
 
931
- /**
932
- * Finish course for user
933
- *
934
- * @return int
935
- * @depecated 4.1.6.9
936
- */
937
- /*public function finish() {
938
- $status = apply_filters(
939
- 'learn-press/finish-course-status',
940
- 'finished',
941
- $this->get_course_id(),
942
- $this->get_user(),
943
- $this
944
- );
945
-
946
- // $results = $this->calculate_course_results();
947
-
948
- return parent::complete( $status );
949
- }*/
950
-
951
  /**
952
  * Check course of use has enrolled
953
  *
@@ -1023,54 +740,6 @@ class LP_User_Item_Course extends LP_User_Item implements ArrayAccess {
1023
  return isset( $cached_data['final-quiz'] ) ? $cached_data['final-quiz'] : array();
1024
  }
1025
 
1026
- /**
1027
- * Evaluate course result by point of quizzes doing/done per total quizzes.
1028
- *
1029
- * @return array
1030
- * @editor tungnx
1031
- * @modify 4.1.3 - comment - not use
1032
- */
1033
- /*
1034
- protected function _evaluate_course_by_quizzes() {
1035
- $cache_key = 'user-course-' . $this->get_user_id() . '-' . $this->get_id();
1036
- $cached_data = LP_Object_Cache::get( $cache_key, 'learn-press/course-results' );
1037
-
1038
- if ( ( false === $cached_data ) || ! array_key_exists( 'quizzes', $cached_data ) ) {
1039
- $data = array(
1040
- 'result' => 0,
1041
- 'status' => $this->get_status(),
1042
- );
1043
-
1044
- $result = 0;
1045
- $result_of_items = 0;
1046
-
1047
- $items = $this->get_items();
1048
-
1049
- if ( $items ) {
1050
- foreach ( $items as $item ) {
1051
- if ( $item->get_type() !== LP_QUIZ_CPT ) {
1052
- continue;
1053
- }
1054
-
1055
- if ( $item->get_quiz()->get_data( 'passing_grade' ) ) {
1056
- $result += $item->get_results( 'result' );
1057
- $result_of_items ++;
1058
- }
1059
- }
1060
-
1061
- $result = $result_of_items ? $result / $result_of_items : 0;
1062
- $data['result'] = $result;
1063
- }
1064
-
1065
- settype( $cached_data, 'array' );
1066
- $cached_data['quizzes'] = $data;
1067
-
1068
- LP_Object_Cache::set( $cache_key, $cached_data, 'learn-press/course-results' );
1069
- }
1070
-
1071
- return isset( $cached_data['quizzes'] ) ? $cached_data['quizzes'] : array();
1072
- }*/
1073
-
1074
  protected function _is_passed( $result ) {
1075
  $is_passed = LP_COURSE_GRADUATION_FAILED;
1076
  $result = round( $result, 2 );
@@ -1100,7 +769,7 @@ class LP_User_Item_Course extends LP_User_Item implements ArrayAccess {
1100
  // return $with_total ? $completed_items : $completed_items[0];
1101
 
1102
  if ( ! $this->_course ) {
1103
- return;
1104
  }
1105
 
1106
  $key = sprintf(
@@ -1281,45 +950,6 @@ class LP_User_Item_Course extends LP_User_Item implements ArrayAccess {
1281
  // TODO: Implement __unset() method.
1282
  }
1283
 
1284
- /**
1285
- * @depecated 4.1.6.9
1286
- */
1287
- /*public function count_history_items( $item_id ) {
1288
-
1289
- if ( false === ( $history = LP_Object_Cache::get(
1290
- 'course-' . $this->get_item_id() . '-' . $this->get_user_id(),
1291
- 'learn-press/items-history'
1292
- ) ) ) {
1293
- global $wpdb;
1294
- $query = $wpdb->prepare(
1295
- "
1296
- SELECT item_id, COUNT(user_item_id) `count`
1297
- FROM {$wpdb->learnpress_user_items}
1298
- WHERE user_id = %d
1299
- AND parent_id = %d
1300
- GROUP BY item_id
1301
- ",
1302
- $this->get_user_id(),
1303
- $this->get_user_item_id()
1304
- );
1305
-
1306
- $history = array();
1307
- if ( $results = $wpdb->get_results( $query ) ) {
1308
- foreach ( $results as $result ) {
1309
- $history[ $result->item_id ] = $result->count;
1310
- }
1311
- }
1312
-
1313
- LP_Object_Cache::set(
1314
- 'course-' . $this->get_item_id() . '-' . $this->get_user_id(),
1315
- $history,
1316
- 'learn-press/items-history'
1317
- );
1318
- }
1319
-
1320
- return isset( $history[ $item_id ] ) ? $history[ $item_id ] : 0;
1321
- }*/
1322
-
1323
  /**
1324
  * @param int $item_id
1325
  *
@@ -1350,65 +980,6 @@ class LP_User_Item_Course extends LP_User_Item implements ArrayAccess {
1350
  return $item;
1351
  }
1352
 
1353
- /**
1354
- * @param int $user_item_id
1355
- *
1356
- * @return LP_User_Item|LP_User_Item_Quiz|bool
1357
- */
1358
- /*
1359
- public function get_item_by_user_item_id( $user_item_id ) {
1360
- $this->read_items();
1361
-
1362
- if ( ! empty( $this->_items_by_item_ids[ $user_item_id ] ) ) {
1363
- $item_id = $this->_items_by_item_ids[ $user_item_id ];
1364
-
1365
- return $this->get_item( $item_id );
1366
- }
1367
-
1368
- return false;
1369
- }*/
1370
-
1371
- /**
1372
- * @param $item
1373
- *
1374
- * @return bool|LP_User_Item
1375
- * @depecated 4.1.6.9
1376
- */
1377
- /*public function set_item( $item ) {
1378
- if ( $item = LP_User_Item::get_item_object( $item ) ) {
1379
- $this->cache_set_item( $item );
1380
- }
1381
-
1382
- return $item;
1383
- }*/
1384
-
1385
- /**
1386
- * @param LP_User_Item $item
1387
- * @depecated 4.1.6.9
1388
- */
1389
- /*public function cache_set_item( $item ) {
1390
- $items = $this->read_items();
1391
- if ( ! $items ) {
1392
- $items = array();
1393
- }
1394
- $items[ $item->get_item_id() ] = $item;
1395
- LP_Object_Cache::set(
1396
- $this->get_user_id() . '-' . $this->get_id(),
1397
- $items,
1398
- 'learn-press/user-course-item-objects'
1399
- );
1400
- }*/
1401
-
1402
- /**
1403
- * @depecated 4.1.6.9
1404
- */
1405
- /*public function cache_get_items() {
1406
- return LP_Object_Cache::get(
1407
- $this->get_user_id() . '-' . $this->get_id(),
1408
- 'learn-press/user-course-item-objects'
1409
- );
1410
- }*/
1411
-
1412
  /**
1413
  * @param $item_id
1414
  * @param string $prop
@@ -1431,25 +1002,6 @@ class LP_User_Item_Course extends LP_User_Item implements ArrayAccess {
1431
  return false;
1432
  }
1433
 
1434
- /**
1435
- * @param int $at
1436
- *
1437
- * @return LP_User_Item_Course
1438
- * @editor tungnx
1439
- * @modify 4.1.3 - comment - not use
1440
- */
1441
- /*
1442
- public function get_item_at( $at = 0 ) {
1443
- $items = $this->read_items();
1444
- $item_id = ! empty( $this->_items_by_order[ $at ] ) ? $this->_items_by_order[ $at ] : 0;
1445
- if ( ! $item_id && $items ) {
1446
- $items = array_values( $items );
1447
- $item_id = $items[ $at ]->get_id();
1448
- }
1449
-
1450
- return $this->offsetGet( $item_id );
1451
- }*/
1452
-
1453
  /**
1454
  * @param $id
1455
  *
@@ -1460,62 +1012,6 @@ class LP_User_Item_Course extends LP_User_Item implements ArrayAccess {
1460
  return $this->get_item( $id );
1461
  }
1462
 
1463
- /**
1464
- * Get js settings of course.
1465
- *
1466
- * @return array
1467
- * @depecated 4.1.6.9
1468
- */
1469
- /*public function get_js_args() {
1470
- $js_args = false;
1471
- $course = $this->get_course();
1472
-
1473
- if ( $course ) {
1474
- $item = false;
1475
- $js_args = array(
1476
- 'root_url' => trailingslashit( get_home_url() ),
1477
- 'id' => $course->get_id(),
1478
- 'url' => $course->get_permalink(),
1479
- 'result' => $this->get_results(),
1480
- 'current_item' => $item ? $item->get_id() : false,
1481
- //'items' => $this->get_items_for_js(),
1482
- );
1483
- }
1484
-
1485
- return apply_filters( 'learn-press/course/single-params', $js_args, $this->get_id() );
1486
- }*/
1487
-
1488
- /**
1489
- * @depecated 4.1.6.9
1490
- */
1491
- /*public function update_item_retaken_count( $item_id, $count = 0 ) {
1492
- $items = $this->get_meta( '_retaken_items' );
1493
- if ( is_string( $count ) && preg_match( '#^(\+|\-)([0-9]+)#', $count, $m ) ) {
1494
- $last_count = ! empty( $items[ $item_id ] ) ? $items[ $item_id ] : 0;
1495
- $count = $m[1] == '+' ? ( $last_count + $m[2] ) : ( $last_count - $m[2] );
1496
- }
1497
-
1498
- $items[ $item_id ] = $count;
1499
-
1500
- learn_press_update_user_item_meta( $this->get_user_item_id(), '_retaken_items', $items );
1501
-
1502
- return $count;
1503
- }*/
1504
-
1505
- /**
1506
- * @depecated 4.1.6.9
1507
- */
1508
- /*public function get_item_retaken_count( $item_id ) {
1509
- $items = $this->get_meta( '_retaken_items' );
1510
- $count = false;
1511
-
1512
- if ( is_array( $items ) && array_key_exists( $item_id, $items ) ) {
1513
- $count = absint( $items[ $item_id ] );
1514
- }
1515
-
1516
- return $count;
1517
- }*/
1518
-
1519
  /**
1520
  * Get number of retaken times for user course.
1521
  *
@@ -1537,30 +1033,6 @@ class LP_User_Item_Course extends LP_User_Item implements ArrayAccess {
1537
  return $this->update_meta( '_lp_retaken_count', $count );
1538
  }
1539
 
1540
- /**
1541
- * Get js settings of course items.
1542
- *
1543
- * @return array
1544
- * @editor tungnx
1545
- * @modify 4.1.4.1 - comment - not use
1546
- */
1547
- // public function get_items_for_js() {
1548
- //
1549
- // *** TEST CACHE */
1550
- // return false;
1551
- // $args = array();
1552
- // if ( $items = $this->get_items() ) {
1553
- // $user = $this->get_user();
1554
- // $course = $this->get_course();
1555
- // foreach ( $items as $item ) {
1556
- //
1557
- // $args[ $item->get_id() ] = $item->get_js_args();// $item_js;
1558
- // }
1559
- // }
1560
- //
1561
- // return apply_filters( 'learn-press/course/items-for-js', $args, $this->get_id(), $this->get_user_id() );
1562
- // }
1563
-
1564
  /**
1565
  * Update course item and it's child.
1566
  *
@@ -1750,8 +1222,4 @@ class LP_User_Item_Course extends LP_User_Item implements ArrayAccess {
1750
 
1751
  return $courses;
1752
  }
1753
-
1754
- public function get_total_users_learn_course( LP_User_Items_Filter $filter ) {
1755
-
1756
- }
1757
  }
381
  return $results;
382
  }
383
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
384
  /**
385
  * Get graduation
386
  *
407
  * @return int|string
408
  */
409
  public function get_percent_result( $decimal = 1 ) {
410
+ return round( $this->get_result( 'result' ), $decimal );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
411
  }
412
 
413
  /**
665
  return $evaluate;
666
  }
667
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
668
  /**
669
  * Check course of use has enrolled
670
  *
740
  return isset( $cached_data['final-quiz'] ) ? $cached_data['final-quiz'] : array();
741
  }
742
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
743
  protected function _is_passed( $result ) {
744
  $is_passed = LP_COURSE_GRADUATION_FAILED;
745
  $result = round( $result, 2 );
769
  // return $with_total ? $completed_items : $completed_items[0];
770
 
771
  if ( ! $this->_course ) {
772
+ return 0;
773
  }
774
 
775
  $key = sprintf(
950
  // TODO: Implement __unset() method.
951
  }
952
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
953
  /**
954
  * @param int $item_id
955
  *
980
  return $item;
981
  }
982
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
983
  /**
984
  * @param $item_id
985
  * @param string $prop
1002
  return false;
1003
  }
1004
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1005
  /**
1006
  * @param $id
1007
  *
1012
  return $this->get_item( $id );
1013
  }
1014
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1015
  /**
1016
  * Get number of retaken times for user course.
1017
  *
1033
  return $this->update_meta( '_lp_retaken_count', $count );
1034
  }
1035
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1036
  /**
1037
  * Update course item and it's child.
1038
  *
1222
 
1223
  return $courses;
1224
  }
 
 
 
 
1225
  }
inc/user-item/class-lp-user-item.php CHANGED
@@ -805,14 +805,11 @@ class LP_User_Item extends LP_Abstract_Object_Data implements ArrayAccess {
805
 
806
  public function get_status_label( $status = '' ) {
807
  $statuses = array(
808
- 'enrolled' => esc_html__( 'In Progress', 'learnpress' ),
809
- 'started' => esc_html__( 'In Progress', 'learnpress' ),
810
- 'in-progress' => esc_html__( 'In Progress', 'learnpress' ),
811
- 'purchased' => esc_html__( 'Not Enrolled', 'learnpress' ),
812
- 'completed' => esc_html__( 'Completed', 'learnpress' ),
813
- 'finished' => esc_html__( 'Finished', 'learnpress' ),
814
- 'passed' => esc_html__( 'Passed', 'learnpress' ),
815
- 'failed' => esc_html__( 'Failed', 'learnpress' ),
816
  );
817
 
818
  if ( ! $status ) {
805
 
806
  public function get_status_label( $status = '' ) {
807
  $statuses = array(
808
+ LP_COURSE_ENROLLED => esc_html__( 'Enrolled', 'learnpress' ),
809
+ LP_COURSE_PURCHASED => esc_html__( 'Purchased', 'learnpress' ),
810
+ LP_ITEM_COMPLETED => esc_html__( 'Completed', 'learnpress' ),
811
+ LP_ITEM_STARTED => esc_html__( 'Started', 'learnpress' ),
812
+ LP_COURSE_FINISHED => esc_html__( 'Finished', 'learnpress' ),
 
 
 
813
  );
814
 
815
  if ( ! $status ) {
inc/user/abstract-lp-user.php CHANGED
@@ -1088,11 +1088,14 @@ if ( ! class_exists( 'LP_Abstract_User' ) ) {
1088
  return false;
1089
  }
1090
 
1091
- public function get_completed_items( $course_id ) {
 
 
 
1092
  $this->_curd->get_user_items( $this->get_id(), $course_id );
1093
 
1094
  return $this->_curd->get_user_completed_items( $this->get_id(), $course_id );
1095
- }
1096
 
1097
  /**
1098
  * Finish course
@@ -1256,10 +1259,7 @@ if ( ! class_exists( 'LP_Abstract_User' ) ) {
1256
  * @return bool|WP_Error
1257
  */
1258
  public function complete_lesson( $lesson_id, $course_id = 0, $return_wp_error = true ) {
1259
- global $wpdb;
1260
-
1261
  try {
1262
- do_action( 'learn-press/before-complete-lesson', $lesson_id, $course_id, $this->get_id() );
1263
  $course_id = $this->_get_course( $course_id );
1264
 
1265
  $course_data = $this->get_course_data( $course_id );
@@ -1271,28 +1271,24 @@ if ( ! class_exists( 'LP_Abstract_User' ) ) {
1271
  */
1272
  $item = $course_data->get_item( $lesson_id );
1273
  if ( $item ) {
1274
-
1275
  if ( $item->is_completed() ) {
1276
  throw new Exception(
1277
  __( 'You have already completed this lesson.', 'learnpress' ),
1278
  LP_COMPLETE_ITEM_FAIL
1279
  );
1280
  }
1281
- // TODO: conflict???
1282
- //$time = new LP_Datetime();
1283
  $item->set_end_time( current_time( 'mysql', 1 ) );
1284
  $item->set_status( 'completed' );
1285
- $item->set_graduation( apply_filters( 'learn-press/complete-lesson-graduation', 'passed' ) );
1286
 
1287
- $updated = $item->update( true, true );
1288
 
1289
  if ( is_wp_error( $updated ) ) {
1290
  return $return_wp_error ? $updated : false;
1291
  } else {
1292
  $result = true;
1293
  }
1294
-
1295
- //$result = $this->evaluate_course_results( $this->get_id() );
1296
  }
1297
 
1298
  do_action( 'learn-press/user-completed-lesson', $lesson_id, $course_id, $this->get_id() );
1088
  return false;
1089
  }
1090
 
1091
+ /**
1092
+ * @depecated 4.1.6.9.1
1093
+ */
1094
+ /*public function get_completed_items( $course_id ) {
1095
  $this->_curd->get_user_items( $this->get_id(), $course_id );
1096
 
1097
  return $this->_curd->get_user_completed_items( $this->get_id(), $course_id );
1098
+ }*/
1099
 
1100
  /**
1101
  * Finish course
1259
  * @return bool|WP_Error
1260
  */
1261
  public function complete_lesson( $lesson_id, $course_id = 0, $return_wp_error = true ) {
 
 
1262
  try {
 
1263
  $course_id = $this->_get_course( $course_id );
1264
 
1265
  $course_data = $this->get_course_data( $course_id );
1271
  */
1272
  $item = $course_data->get_item( $lesson_id );
1273
  if ( $item ) {
 
1274
  if ( $item->is_completed() ) {
1275
  throw new Exception(
1276
  __( 'You have already completed this lesson.', 'learnpress' ),
1277
  LP_COMPLETE_ITEM_FAIL
1278
  );
1279
  }
1280
+
 
1281
  $item->set_end_time( current_time( 'mysql', 1 ) );
1282
  $item->set_status( 'completed' );
1283
+ $item->set_graduation( 'passed' );
1284
 
1285
+ $updated = $item->update();
1286
 
1287
  if ( is_wp_error( $updated ) ) {
1288
  return $return_wp_error ? $updated : false;
1289
  } else {
1290
  $result = true;
1291
  }
 
 
1292
  }
1293
 
1294
  do_action( 'learn-press/user-completed-lesson', $lesson_id, $course_id, $this->get_id() );
inc/user/class-lp-user.php CHANGED
@@ -765,7 +765,7 @@ class LP_User extends LP_Abstract_User {
765
  $item_id = $item->get_id();
766
  $course_data = $this->get_course_data( $course_id );
767
 
768
- if ( $course_data ) {
769
  $item = $course_data->get_item( $item_id );
770
 
771
  if ( ! $item ) {
765
  $item_id = $item->get_id();
766
  $course_data = $this->get_course_data( $course_id );
767
 
768
+ if ( $course_data && $course_data->is_enrolled() ) {
769
  $item = $course_data->get_item( $item_id );
770
 
771
  if ( ! $item ) {
inc/user/lp-user-functions.php CHANGED
@@ -109,7 +109,7 @@ if ( ! function_exists( 'learn_press_get_user' ) ) {
109
  * @param int $user_id
110
  * @param bool $current
111
  *
112
- * @return LP_User|mixed
113
  * Todo: check this function - tungnx
114
  */
115
  function learn_press_get_user( $user_id, $current = false, $force_new = false ) {
109
  * @param int $user_id
110
  * @param bool $current
111
  *
112
+ * @return LP_User|LP_User_Guest|mixed
113
  * Todo: check this function - tungnx
114
  */
115
  function learn_press_get_user( $user_id, $current = false, $force_new = false ) {
learnpress.php CHANGED
@@ -4,7 +4,7 @@
4
  * Plugin URI: http://thimpress.com/learnpress
5
  * Description: LearnPress is a WordPress complete solution for creating a Learning Management System (LMS). It can help you to create courses, lessons and quizzes.
6
  * Author: ThimPress
7
- * Version: 4.1.6.9
8
  * Author URI: http://thimpress.com
9
  * Requires at least: 5.6
10
  * Tested up to: 6.0
4
  * Plugin URI: http://thimpress.com/learnpress
5
  * Description: LearnPress is a WordPress complete solution for creating a Learning Management System (LMS). It can help you to create courses, lessons and quizzes.
6
  * Author: ThimPress
7
+ * Version: 4.1.6.9.1
8
  * Author URI: http://thimpress.com
9
  * Requires at least: 5.6
10
  * Tested up to: 6.0
readme.txt CHANGED
@@ -5,7 +5,7 @@ Tags: elearning, education, course, lms, learning management system
5
  Requires at least: 5.6
6
  Tested up to: 6.0
7
  Requires PHP: 7.0
8
- Stable tag: 4.1.6.9
9
  License: GPLv2 or later
10
  License URI: https://www.gnu.org/licenses/gpl-2.0.html
11
 
@@ -203,6 +203,10 @@ https://www.transifex.com/projects/p/learnpress/
203
 
204
  == Changelog ==
205
 
 
 
 
 
206
  = 4.1.6.9 (2022-08-03) =
207
  ~ Modified: read items, read sections of course. (optimize read speed).
208
  ~ Modified: 'set_viewing_item' method.
5
  Requires at least: 5.6
6
  Tested up to: 6.0
7
  Requires PHP: 7.0
8
+ Stable tag: 4.1.6.9.1
9
  License: GPLv2 or later
10
  License URI: https://www.gnu.org/licenses/gpl-2.0.html
11
 
203
 
204
  == Changelog ==
205
 
206
+ = 4.1.6.9.1 (2022-08-04) =
207
+ ~ Fixed: error ESC content of course, items' course make iframe, embed not working.
208
+ ~ Fixed: error complete lesson, do quiz on API for App mobile.
209
+
210
  = 4.1.6.9 (2022-08-03) =
211
  ~ Modified: read items, read sections of course. (optimize read speed).
212
  ~ Modified: 'set_viewing_item' method.
templates/checkout/payment-method.php CHANGED
@@ -32,7 +32,7 @@ $icon = $gateway->get_icon();
32
 
33
  <?php if ( $payment_form ) : ?>
34
  <div class="payment-method-form payment_method_<?php echo esc_attr( $gateway->id ); ?>">
35
- <?php echo wp_kses_post( $payment_form ); ?>
36
  </div>
37
  <?php endif; ?>
38
  </li>
32
 
33
  <?php if ( $payment_form ) : ?>
34
  <div class="payment-method-form payment_method_<?php echo esc_attr( $gateway->id ); ?>">
35
+ <?php learn_press_echo_vuejs_write_on_php( $payment_form ); ?>
36
  </div>
37
  <?php endif; ?>
38
  </li>
templates/content-lesson/content.php CHANGED
@@ -32,4 +32,9 @@ if ( ! $content ) {
32
  }
33
  ?>
34
 
35
- <div class="content-item-description lesson-description"><?php echo wp_kses_post( $content ); ?></div>
 
 
 
 
 
32
  }
33
  ?>
34
 
35
+ <div class="content-item-description lesson-description">
36
+ <?php
37
+ $content = apply_filters( 'the_content', $content );
38
+ echo str_replace( ']]>', ']]&gt;', $content );
39
+ ?>
40
+ </div>
templates/single-course/tabs/overview.php CHANGED
@@ -36,7 +36,8 @@ if ( ! $course ) {
36
  */
37
  do_action( 'learn-press/before-single-course-description' );
38
 
39
- echo wp_kses_post( $course->get_content() );
 
40
 
41
  /**
42
  * @since 3.0.0
36
  */
37
  do_action( 'learn-press/before-single-course-description' );
38
 
39
+ $content = apply_filters( 'the_content', $course->get_content() );
40
+ echo str_replace( ']]>', ']]&gt;', $content );
41
 
42
  /**
43
  * @since 3.0.0