LearnPress – WordPress LMS Plugin - Version 3.0.12.1

Version Description

= 0.9.19 = In this version, we have changed a little bit about LearnPress Plugin directory structure and moved all add-ons to become independence plugins. If you face any problems relate to add-ons, please completely remove old version and re-install LearnPress. It does not affect your current data. Thank you.

Download this release

Release Info

Developer leehld
Plugin Icon 128x128 LearnPress – WordPress LMS Plugin
Version 3.0.12.1
Comparing to
See all releases

Code changes from version 3.0.11.1 to 3.0.12.1

assets/js/admin/quiz-editor.js CHANGED
@@ -933,7 +933,7 @@ var LP_List_Quiz_Questions_Store = (function (Vue, helpers, data, $) {
933
payload['nonce'] = $store.getters.nonce;
934
payload['lp-ajax'] = $store.getters.action;
935
936
- payload['code'] = $store.getters.code;
937
$( '#publishing-action #publish' ).addClass( 'disabled' );
938
$( '#publishing-action .spinner' ).addClass( 'is-active' );
939
$( '#publishing-action' ).addClass( 'code-'+payload['code'] );
933
payload['nonce'] = $store.getters.nonce;
934
payload['lp-ajax'] = $store.getters.action;
935
936
+ payload['code'] = Date.now();
937
$( '#publishing-action #publish' ).addClass( 'disabled' );
938
$( '#publishing-action .spinner' ).addClass( 'is-active' );
939
$( '#publishing-action' ).addClass( 'code-'+payload['code'] );
assets/js/frontend/course.js CHANGED
@@ -451,7 +451,9 @@
451
fitVideo();
452
453
fullScreen = window.localStorage && 'yes' === window.localStorage.getItem('lp-full-screen');
454
-
455
if (fullScreen) {
456
var curriculumWidth = getCurriculumWidth();
457
$body.addClass('full-screen-content-item');
451
fitVideo();
452
453
fullScreen = window.localStorage && 'yes' === window.localStorage.getItem('lp-full-screen');
454
+ if($(window).width()<=768){
455
+ fullScreen = true;
456
+ }
457
if (fullScreen) {
458
var curriculumWidth = getCurriculumWidth();
459
$body.addClass('full-screen-content-item');
assets/js/frontend/quiz.js CHANGED
@@ -63,9 +63,8 @@
63
}
64
65
if (overtime) {
66
- // console.log('Overtime')
67
- // return;
68
- //
69
return;
70
}
71
thisSettings.remainingTime--;
@@ -143,6 +142,12 @@
143
return remainingTime;
144
}
145
146
init();
147
}
148
63
}
64
65
if (overtime) {
66
+ $('form.complete-quiz').off('submit.learn-press-confirm');
67
+ callbackEvents.callEvent('finish');
68
return;
69
}
70
thisSettings.remainingTime--;
142
return remainingTime;
143
}
144
145
+ if(thisSettings.remainingTime <= 0){
146
+ // Disable confirm message
147
+ $('form.complete-quiz').off('submit.learn-press-confirm');
148
+ callbackEvents.callEvent('finish');
149
+ }
150
+
151
init();
152
}
153
inc/class-lp-forms-handler.php CHANGED
@@ -152,10 +152,13 @@ class LP_Forms_Handler {
152
153
learn_press_add_message( $message, 'success' );
154
}
155
156
learn_press_maybe_send_json( $result, 'learn_press_print_messages' );
157
158
- if ( ( $result['result'] === 'success' ) && $redirect = LP_Request::get( 'redirect_to' ) ) {
159
wp_redirect( $redirect );
160
exit();
161
}
152
153
learn_press_add_message( $message, 'success' );
154
}
155
+ if ( ! $redirect = LP_Request::get( 'redirect_to' ) ) {
156
+ $redirect = LP_Request::get_redirect( learn_press_get_current_url() );
157
+ }
158
159
learn_press_maybe_send_json( $result, 'learn_press_print_messages' );
160
161
+ if ( ( $result['result'] === 'success' ) && $redirect ) {
162
wp_redirect( $redirect );
163
exit();
164
}
inc/class-lp-preview-course.php CHANGED
@@ -150,8 +150,7 @@ class LP_Preview_Course {
150
151
//learn_press_debug($_SERVER);die();
152
153
- }
154
- catch ( Exception $ex ) {
155
learn_press_add_message( $ex->getMessage(), 'error' );
156
wp_redirect( get_home_url() );
157
exit();
@@ -229,7 +228,16 @@ class LP_Preview_Course {
229
230
public static function reduce_counts( $counts, $type, $perm ) {
231
if ( ( LP_COURSE_CPT === $type ) && ( $ids = self::get_preview_courses() ) ) {
232
- $counts->publish -= sizeof( $ids );
233
}
234
235
return $counts;
150
151
//learn_press_debug($_SERVER);die();
152
153
+ } catch ( Exception $ex ) {
154
learn_press_add_message( $ex->getMessage(), 'error' );
155
wp_redirect( get_home_url() );
156
exit();
228
229
public static function reduce_counts( $counts, $type, $perm ) {
230
if ( ( LP_COURSE_CPT === $type ) && ( $ids = self::get_preview_courses() ) ) {
231
+ foreach ( $ids as $id ) {
232
+ switch ( get_post_status( $id ) ) {
233
+ case 'draft':
234
+ $counts->draft -= 1;
235
+ break;
236
+ default:
237
+ $counts->publish -= 1;
238
+ break;
239
+ }
240
+ }
241
}
242
243
return $counts;
inc/class-lp-query-list-table.php CHANGED
@@ -92,8 +92,10 @@ class LP_Query_List_Table implements ArrayAccess {
92
*
93
* @return string
94
*/
95
- public function get_nav_numbers( $echo = true ) {
96
-
97
if ( ! empty( $this->_data['nav_base'] ) ) {
98
if ( is_callable( $this->_data['nav_base'] ) ) {
99
$base = call_user_func_array( $this->_data['nav_base'], array( $this->_data['nav_format'] ) );
@@ -101,7 +103,7 @@ class LP_Query_List_Table implements ArrayAccess {
101
$base = $this->_data['nav_base'];
102
}
103
} else {
104
- $base = trailingslashit( preg_replace( '~\/[0-9]+\/?$~', '', learn_press_get_current_url() ) );
105
}
106
107
return learn_press_paging_nav(
@@ -161,10 +163,10 @@ class LP_Query_List_Table implements ArrayAccess {
161
return $output;
162
}
163
164
- public function get_nav( $format = '', $echo = false ) {
165
$output = '';
166
$offset = $this->get_offset_text( empty( $format ) ? $this->_data['format'] : $format, false );
167
- $numbers = $this->get_nav_numbers( false );
168
169
if ( $offset && $numbers ) {
170
$output = sprintf( '<div class="learn-press-nav-items">%s%s</div>', $offset, $numbers );
92
*
93
* @return string
94
*/
95
+ public function get_nav_numbers( $echo = true, $base_url='' ) {
96
+ if( !$base_url ) {
97
+ $base_url = learn_press_get_current_url();
98
+ }
99
if ( ! empty( $this->_data['nav_base'] ) ) {
100
if ( is_callable( $this->_data['nav_base'] ) ) {
101
$base = call_user_func_array( $this->_data['nav_base'], array( $this->_data['nav_format'] ) );
103
$base = $this->_data['nav_base'];
104
}
105
} else {
106
+ $base = trailingslashit( preg_replace( '~\/[0-9]+\/?$~', '', $base_url ) );
107
}
108
109
return learn_press_paging_nav(
163
return $output;
164
}
165
166
+ public function get_nav( $format = '', $echo = false, $base_url = '' ) {
167
$output = '';
168
$offset = $this->get_offset_text( empty( $format ) ? $this->_data['format'] : $format, false );
169
+ $numbers = $this->get_nav_numbers( false, $base_url );
170
171
if ( $offset && $numbers ) {
172
$output = sprintf( '<div class="learn-press-nav-items">%s%s</div>', $offset, $numbers );
inc/custom-post-types/lesson.php CHANGED
@@ -185,7 +185,7 @@ if ( ! class_exists( 'LP_Lesson_Post_Type' ) ) {
185
$query = $wpdb->prepare( "
186
SELECT COUNT(ID)
187
FROM {$wpdb->posts} p
188
- WHERE p.post_type = %s
189
", LP_LESSON_CPT );
190
191
return $wpdb->get_var( $query ) - $this->get_preview_items();
185
$query = $wpdb->prepare( "
186
SELECT COUNT(ID)
187
FROM {$wpdb->posts} p
188
+ WHERE p.post_type = %s AND p.post_status NOT LIKE 'auto-draft'
189
", LP_LESSON_CPT );
190
191
return $wpdb->get_var( $query ) - $this->get_preview_items();
inc/lesson/class-lp-lesson.php CHANGED
@@ -170,11 +170,11 @@ if ( ! function_exists( 'LP_Lesson' ) ) {
170
*/
171
public static function get_default_meta() {
172
$meta = array(
173
- 'duration' => '30 minute',
174
'preview' => 'no'
175
);
176
177
- return apply_filters( 'learn-press/course/default-meta', $meta );
178
}
179
180
/**
170
*/
171
public static function get_default_meta() {
172
$meta = array(
173
+ 'duration' => '0 minute',
174
'preview' => 'no'
175
);
176
177
+ return apply_filters( 'learn-press/course/lesson/default-meta', $meta );
178
}
179
180
/**
inc/lesson/lp-lesson-functions.php CHANGED
@@ -43,9 +43,9 @@ function learn_press_lesson_comment_form() {
43
44
$user = learn_press_get_current_user();
45
46
- if ( ! $user->is_admin() && ! $user->has_course_status( $course->get_id(), array( 'enrolled', 'finished' ) ) ) {
47
- return;
48
- }
49
50
if ( $lesson->setup_postdata() ) {
51
43
44
$user = learn_press_get_current_user();
45
46
+ // if ( ! $user->is_admin() && ! $user->has_course_status( $course->get_id(), array( 'enrolled', 'finished' ) ) ) {
47
+ // return;
48
+ // }
49
50
if ( $lesson->setup_postdata() ) {
51
inc/lp-constants.php CHANGED
@@ -4,7 +4,7 @@
4
*/
5
$upload_dir = wp_upload_dir();
6
// version
7
- define( 'LEARNPRESS_VERSION', '3.0.11.1' );
8
9
define( 'LP_WP_CONTENT', basename( WP_CONTENT_DIR ) );
10
4
*/
5
$upload_dir = wp_upload_dir();
6
// version
7
+ define( 'LEARNPRESS_VERSION', '3.0.12.1' );
8
9
define( 'LP_WP_CONTENT', basename( WP_CONTENT_DIR ) );
10
inc/lp-core-functions.php CHANGED
@@ -2407,6 +2407,9 @@ function learn_press_auto_enroll_user_to_courses( $order_id ) {
2407
if ( $user->has_enrolled_course( $course->get_id() ) ) {
2408
continue;
2409
}
2410
// error. this scripts will create new order each course item
2411
$return = learn_press_update_user_item_field( array(
2412
'user_id' => $user->get_id(),
2407
if ( $user->has_enrolled_course( $course->get_id() ) ) {
2408
continue;
2409
}
2410
+ if( !$user->can_enroll_course($course->get_id()) ) {
2411
+ continue;
2412
+ }
2413
// error. this scripts will create new order each course item
2414
$return = learn_press_update_user_item_field( array(
2415
'user_id' => $user->get_id(),
inc/lp-template-functions.php CHANGED
@@ -579,6 +579,8 @@ if ( ! function_exists( 'learn_press_get_course_tabs' ) ) {
579
if ( $request_tab === $v['id'] ) {
580
$v['active'] = true;
581
$has_active = $k;
582
}
583
$tabs[ $k ] = $v;
584
}
@@ -2884,7 +2886,7 @@ if ( ! function_exists( 'learn_press_content_item_lesson_content' ) ) {
2884
2885
return;
2886
}
2887
-
2888
learn_press_get_template( 'content-lesson/content.php' );
2889
}
2890
}
@@ -3054,6 +3056,7 @@ function learn_press_course_comments_open( $open, $post_id ) {
3054
if ( LP_COURSE_CPT == $post->post_type ) {
3055
$open = false;
3056
}
3057
return $open;
3058
}
3059
@@ -3772,7 +3775,7 @@ function learn_press_get_link_current_question_instead_of_continue_button( $link
3772
$user = LP_Global::user();
3773
$course = $item->get_course();
3774
$quiz_data = $user->get_item_data( $item->get_id(), $course->get_id() );
3775
- if ( $quiz_data->get_status() === 'started' ) {
3776
$link = $item->get_question_link( $quiz_data->get_current_question() );
3777
}
3778
}
579
if ( $request_tab === $v['id'] ) {
580
$v['active'] = true;
581
$has_active = $k;
582
+ } elseif(isset($v['active']) && $v['active'] ){
583
+ $has_active = true;
584
}
585
$tabs[ $k ] = $v;
586
}
2886
2887
return;
2888
}
2889
+ do_action( 'learn-press/lesson-start', $item );
2890
learn_press_get_template( 'content-lesson/content.php' );
2891
}
2892
}
3056
if ( LP_COURSE_CPT == $post->post_type ) {
3057
$open = false;
3058
}
3059
+
3060
return $open;
3061
}
3062
3775
$user = LP_Global::user();
3776
$course = $item->get_course();
3777
$quiz_data = $user->get_item_data( $item->get_id(), $course->get_id() );
3778
+ if ( $quiz_data && $quiz_data->get_status() === 'started' ) {
3779
$link = $item->get_question_link( $quiz_data->get_current_question() );
3780
}
3781
}
inc/quiz/class-lp-quiz-factory.php CHANGED
@@ -359,6 +359,7 @@ if ( ! class_exists( 'LP_Quiz_Factory' ) ) {
359
360
// Redirecting...
361
if ( ! empty( $result['redirect'] ) ) {
362
wp_redirect( $result['redirect'] );
363
exit();
364
}
359
360
// Redirecting...
361
if ( ! empty( $result['redirect'] ) ) {
362
+ wp_cache_flush();
363
wp_redirect( $result['redirect'] );
364
exit();
365
}
inc/user-item/class-lp-user-item-course-bk.php DELETED
@@ -1,898 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * Class LP_User_Item_Course
5
- */
6
- class LP_User_Item_CourseY extends LP_User_Item implements ArrayAccess {
7
- /**
8
- * Course's items
9
- *
10
- * @var array
11
- */
12
- protected $_items = false;
13
-
14
- /**
15
- * Course
16
- *
17
- * @var LP_Course
18
- */
19
- protected $_course = 0;
20
-
21
- /**
22
- * @var LP_User
23
- */
24
- protected $_user = 0;
25
-
26
- /**
27
- * @var array
28
- */
29
- protected $_items_by_item_ids = array();
30
-
31
- /**
32
- * @var bool
33
- */
34
- protected $_loaded = false;
35
-
36
- /**
37
- * @var LP_User_CURD
38
- */
39
- protected $_curd = null;
40
-
41
- /**
42
- * LP_User_Item_Course constructor.
43
- *
44
- * @param null $item
45
- */
46
- public function __construct( $item ) {
47
-
48
- parent::__construct( $item );
49
-
50
- $this->_curd = new LP_User_CURD();
51
- $this->_changes = array();
52
- $this->load();
53
- }
54
-
55
- public function load() {
56
- if ( ! $this->_loaded ) {
57
- $this->read_items();
58
- //$this->read_items_meta();
59
- $this->_loaded = true;
60
- }
61
- }
62
-
63
- /**
64
- * Read items's data of course for the user.
65
- */
66
- public function read_items() {
67
- $this->_items = array();
68
- $this->_course = learn_press_get_course( $this->get_id() );
69
-
70
- if ( ! $this->_course || ( ! $user_course_item_id = $this->get_user_item_id() ) ) {
71
- return false;
72
- }
73
- $course_items = $this->_course->get_item_ids();
74
-
75
- if ( ! $course_items ) {
76
- return false;
77
- }
78
-
79
- if ( $user_course_items = $this->_curd->read_course_items_by_user_item_id( $user_course_item_id ) ) {
80
-
81
- // Convert keys of array from numeric to keys is item id
82
- foreach ( array_keys( $user_course_items ) as $key ) {
83
- $user_course_item = $user_course_items[ $key ];
84
- $user_course_items[ $user_course_item->item_id ] = $user_course_item;
85
- unset( $user_course_items[ $key ] );
86
- }
87
- } else {
88
- $user_course_items = array();
89
- }
90
-
91
- foreach ( $course_items as $item_id ) {
92
-
93
- if ( ! empty( $user_course_items[ $item_id ] ) ) {
94
- $user_course_item = (array) $user_course_items[ $item_id ];
95
- } else {
96
- $user_course_item = array(
97
- 'item_id' => $item_id,
98
- 'ref_id' => $this->get_id(),
99
- 'parent_id' => $user_course_item_id
100
- );
101
- }
102
-
103
- if ( $course_item = apply_filters( 'learn-press/user-course-item', LP_User_Item::get_item_object( $user_course_item ), $user_course_item, $this ) ) {
104
- $this->_items[ $item_id ] = $course_item;
105
- $this->_items_by_item_ids[ $course_item->get_user_item_id() ] = $item_id;
106
- }
107
- }
108
-
109
- return true;
110
- }
111
-
112
- public function is_exceeded() {
113
- $exceeded = DAY_IN_SECONDS * 360 * 100;
114
-
115
- if ( ! $course = $this->get_course() ) {
116
- return $exceeded;
117
- }
118
-
119
- if ( ! $course->get_duration() ) {
120
- return $exceeded;
121
- }
122
-
123
- return parent::is_exceeded();
124
- }
125
-
126
- public function get_finishing_type() {
127
- if ( ! $type = $this->get_meta( 'finishing_type' ) ) {
128
- $type = $this->is_exceeded() <= 0 ? 'exceeded' : 'click';
129
- learn_press_update_user_item_meta( $this->get_user_item_id(), 'finishing_type', $type );
130
- $this->set_meta( 'finishing_type', $type );
131
- }
132
-
133
- return $type;
134
- }
135
-
136
- /**
137
- * Read item meta.
138
- *
139
- * @return mixed|bool
140
- */
141
- public function read_items_meta() {
142
-
143
- $item_ids = array();
144
- if ( $this->_items ) {
145
- foreach ( $this->_items as $item ) {
146
- if ( $item->get_user_item_id() ) {
147
- $item_ids[ $item->get_user_item_id() ] = $item->get_item_id();
148
- }
149
- }
150
- }
151
-
152
- if ( ! $item_ids ) {
153
- return false;
154
- }
155
-
156
- global $wpdb;
157
- $meta_ids = array_keys( $item_ids );
158
- $format = array_fill( 0, sizeof( $meta_ids ), '%d' );
159
- $sql = $wpdb->prepare( "
160
- SELECT *
161
- FROM {$wpdb->learnpress_user_itemmeta}
162
- WHERE learnpress_user_item_id IN(" . join( ',', $format ) . ")
163
- ", $meta_ids );
164
-
165
- if ( $results = $wpdb->get_results( $sql ) ) {
166
- foreach ( $results as $result ) {
167
- $item_id = $item_ids[ $result->learnpress_user_item_id ];
168
-
169
- if ( $item_id === $this->get_item_id() ) {
170
- $this->add_meta( $result );
171
- } else {
172
- $item = $this->get_item( $item_id );
173
- $result->meta_value = LP_Helper::maybe_unserialize( $result->meta_value );
174
-
175
- $item->add_meta( $result );
176
- }
177
- }
178
- }
179
-
180
- return $this->_meta_data;
181
- }
182
-
183
- public function offsetSet( $offset, $value ) {
184
- //$this->set_data( $offset, $value );
185
- // Do not allow to set value directly!
186
- }
187
-
188
- public function offsetUnset( $offset ) {
189
- // Do not allow to unset value directly!
190
- }
191
-
192
- public function offsetGet( $offset ) {
193
- $this->load();
194
-
195
- return $this->offsetExists( $offset ) ? $this->_items[ $offset ] : false;
196
- }
197
-
198
- public function offsetExists( $offset ) {
199
- $this->load();
200
-
201
- return array_key_exists( $offset, $this->_items );
202
- }
203
-
204
- public function evaluate() {
205
-
206
- }
207
-
208
- /**
209
- * @return LP_User_Item|bool
210
- */
211
- public function get_viewing_item() {
212
- $item = LP_Global::course_item();
213
- if ( $item ) {
214
- return $this[ $item->get_id() ];
215
- }
216
-
217
- return false;
218
- }
219
-
220
- public function get_course( $return = '' ) {
221
- $cid = $this->get_data( 'item_id' );
222
- if ( $return == '' ) {
223
- return $cid ? learn_press_get_course( $cid ) : false;
224
- }
225
-
226
- return $cid;
227
- }
228
-
229
- /**
230
- * Get result of course.
231
- *
232
- * @param string $prop
233
- *
234
- * @return float|int
235
- */
236
- public function get_results( $prop = 'result' ) {
237
-
238
- if ( ! $course = $this->get_course() ) {
239
- return false;
240
- }
241
-
242
- $this->load();
243
- $course_result = $course->get_data( 'course_result' );
244
- $results = false;
245
- switch ( $course_result ) {
246
- // Completed lessons per total
247
- case 'evaluate_lesson':
248
- $results = $this->_evaluate_course_by_lesson();
249
- break;
250
- // Results of final quiz
251
- case 'evaluate_final_quiz':
252
- $results = $this->_evaluate_course_by_final_quiz();
253
- break;
254
- // Points of quizzes per points of all quizzes
255
- case 'evaluate_quizzes':
256
- $results = $this->_evaluate_course_by_quizzes();
257
- break;
258
- // Points of passed quizzes per points of all quizzes
259
- case 'evaluate_passed_quizzes':
260
- $results = $this->_evaluate_course_by_passed_quizzes();
261
- break;
262
- // Points of completed (may not passed) quizzes per points of all quizzes
263
- case 'evaluate_quiz':
264
- $results = $this->_evaluate_course_by_completed_quizzes();
265
- break;
266
- default:
267
- $results = apply_filters( 'learn-press/evaluate_passed_conditions', $course_result, $this );
268
- break;
269
- }
270
-
271
- if ( is_array( $results ) ) {
272
- $count_items = $course->count_items( '', true );
273
- $completed_items = $this->get_completed_items();
274
- $results = array_merge(
275
- $results,
276
- array(
277
- 'count_items' => $count_items,
278
- 'completed_items' => $completed_items,
279
- 'skipped_items' => $count_items - $completed_items,
280
- 'status' => $this->get_status(),
281
- 'grade' => ''
282
- )
283
- );
284
-
285
- if ( ! in_array( $this->get_status(), array( 'purchased', 'viewed' ) ) ) {
286
- $results['grade'] = $this->is_finished() ? $this->_is_passed( $results['result'] ) : 'in-progress';
287
- } else {
288
- }
289
- }
290
-
291
- if ( $prop === 'status' ) {
292
- if ( isset( $results['grade'] ) ) {
293
- $prop = 'grade';
294
- }
295
- }
296
-
297
- ///$result = wp_cache_get( 'user-course-' . $this->get_user_id() . '-' . $this->get_id(), 'learn-press/user-course-results' );
298
-
299
- return $prop && $results && array_key_exists( $prop, $results ) ? $results[ $prop ] : $results;
300
- }
301
-
302
- /**
303
- * @param string $context
304
- *
305
- * @return string
306
- */
307
- public function get_grade( $context = '' ) {
308
- $grade = $this->get_results( 'grade' );
309
-
310
- return $context == 'display' ? learn_press_course_grade_html( $grade, false ) : $grade;
311
- }
312
-
313
- /**
314
- * @return bool
315
- */
316
- public function is_passed() {
317
- return $this->get_grade() == 'passed';
318
- }
319
-
320
- /**
321
- * @param int $decimal
322
- *
323
- * @return int|string
324
- */
325
- public function get_percent_result( $decimal = 1 ) {
326
- return apply_filters( 'learn-press/user/course-percent-result', sprintf( '%s%%', round( $this->get_results( 'result' ), $decimal ), $this->get_user_id(), $this->get_item_id() ) );
327
- }
328
-
329
- /**
330
- * Evaluate course result by lessons.
331
- *
332
- * @return array
333
- */
334
- protected function _evaluate_course_by_lesson() {
335
-
336
- $cache_key = 'user-course-' . $this->get_user_id() . '-' . $this->get_id();
337
-
338
- if ( false === ( $cached_data = wp_cache_get( $cache_key, 'learn-press/course-results' ) ) || ! array_key_exists( 'lessons', $cached_data ) ) {
339
- $completing = $this->get_completed_items( LP_LESSON_CPT, true );
340
- if ( $completing[1] ) {
341
- $result = $completing[0] / $completing[1];
342
- } else {
343
- $result = 0;
344
- }
345
- $result *= 100;
346
- $data = array(
347
- 'result' => $result,
348
- 'grade' => $this->is_finished() ? $this->_is_passed( $result ) : '',
349
- 'status' => $this->get_status()
350
- );
351
-
352
- settype( $cached_data, 'array' );
353
- $cached_data['lessons'] = $data;
354
-
355
- wp_cache_set( $cache_key, $cached_data, 'learn-press/course-results' );
356
- }
357
-
358
- return isset( $cached_data['lessons'] ) ? $cached_data['lessons'] : array();
359
- }
360
-
361
- /**
362
- * Finish course for user
363
- *
364
- * @return int
365
- */
366
- public function finish() {
367
-
368
- $return = parent::complete( 'finished' );
369
-
370
- return $return;
371
- }
372
-
373
- /**
374
- * Evaluate course result by final quiz.
375
- *
376
- * @return array
377
- */
378
- protected function _evaluate_course_by_final_quiz() {
379
-
380
- $cache_key = 'user-course-' . $this->get_user_id() . '-' . $this->get_id();
381
-
382
- if ( false === ( $cached_data = wp_cache_get( $cache_key, 'learn-press/course-results' ) ) || ! array_key_exists( 'final-quiz', $cached_data ) ) {
383
- $course = $this->get_course();
384
- $final_quiz = $course->get_final_quiz();
385
- $result = false;
386
- if ( $user_quiz = $this->get_item( $final_quiz ) ) {
387
- $result = $user_quiz->get_results( false );
388
- }
389
-
390
- $percent = $result ? $result['result'] : 0;
391
- $data = array(
392
- 'result' => $percent,
393
- 'grade' => $this->is_finished() ? $this->_is_passed( $percent ) : '',
394
- 'status' => $this->get_status()
395
- );
396
- settype( $cached_data, 'array' );
397
- $cached_data['final-quiz'] = $data;
398
-
399
- wp_cache_set( $cache_key, $cached_data, 'learn-press/course-results' );
400
- }
401
-
402
- return isset( $cached_data['final-quiz'] ) ? $cached_data['final-quiz'] : array();
403
- }
404
-
405
- /**
406
- * Evaluate course result by point of quizzes doing/done per total quizzes.
407
- *
408
- * @return array
409
- */
410
- protected function _evaluate_course_by_quizzes() {
411
-
412
- $cache_key = 'user-course-' . $this->get_user_id() . '-' . $this->get_id();
413
-
414
- if ( ( false === ( $cached_data = wp_cache_get( $cache_key, 'learn-press/course-results' ) ) ) || ! array_key_exists( 'quizzes', $cached_data ) ) {
415
-
416
- $data = array( 'result' => 0, 'grade' => '', 'status' => $this->get_status() );
417
- $result = 0;
418
- $result_of_items = 0;
419
-
420
- if ( $items = $this->get_items() ) {
421
- foreach ( $items as $item ) {
422
- if ( $item->get_type() !== LP_QUIZ_CPT ) {
423
- continue;
424
- }
425
- if ( $item->get_quiz()->get_data( 'passing_grade' ) ) {
426
- $result += $item->get_results( 'result' );
427
- $result_of_items ++;
428
- }
429
- }
430
- $result = $result_of_items ? $result / $result_of_items : 0;
431
- $data['result'] = $result;
432
- if ( $this->is_finished() ) {
433
- $data['grade'] = $this->_is_passed( $result );
434
- }
435
- }
436
-
437
- settype( $cached_data, 'array' );
438
- $cached_data['quizzes'] = $data;
439
-
440
- wp_cache_set( $cache_key, $cached_data, 'learn-press/course-results' );
441
- }
442
-
443
- return isset( $cached_data['quizzes'] ) ? $cached_data['quizzes'] : array();
444
- }
445
-
446
- /**
447
- * Evaluate course result by point of quizzes doing/done per total quizzes.
448
- *
449
- * @return array
450
- */
451
- protected function _evaluate_course_by_passed_quizzes() {
452
-
453
- $cache_key = 'user-course-' . $this->get_user_id() . '-' . $this->get_id();
454
-
455
- if ( false === ( $cached_data = wp_cache_get( $cache_key, 'learn-press/course-results' ) ) || ! array_key_exists( 'passed-quizzes', $cached_data ) ) {
456
-
457
- $data = array( 'result' => 0, 'grade' => '', 'status' => $this->get_status() );
458
- $result = 0;
459
- $result_of_items = 0;
460
- if ( $items = $this->get_items() ) {
461
- foreach ( $items as $item ) {
462
- if ( $item->get_type() !== LP_QUIZ_CPT ) {
463
- continue;
464
- }
465
- if ( $item->get_quiz()->get_data( 'passing_grade' ) ) {
466
- $result += $item->is_passed() ? $item->get_results( 'result' ) : 0;
467
- $result_of_items ++;
468
- }
469
- }
470
- $result = $result_of_items ? $result / $result_of_items : 0;
471
- $data['result'] = $result;
472
-
473
- if ( $this->is_finished() ) {
474
- $data['grade'] = $this->_is_passed( $result );
475
- }
476
- }
477
-
478
- settype( $cached_data, 'array' );
479
- $cached_data['passed-quizzes'] = $data;
480
-
481
- wp_cache_set( $cache_key, $cached_data, 'learn-press/course-results' );
482
- }
483
-
484
- return isset( $cached_data['passed-quizzes'] ) ? $cached_data['passed-quizzes'] : array();
485
- }
486
-
487
- /**
488
- * Evaluate course result by number of passed quizzes per total quizzes.
489
- *
490
- * @return array
491
- */
492
- protected function _evaluate_course_by_completed_quizzes() {
493
- $cache_key = 'user-course-' . $this->get_user_id() . '-' . $this->get_id();
494
-
495
- if ( false === ( $cached_data = wp_cache_get( $cache_key, 'learn-press/course-results' ) ) || ! array_key_exists( 'completed-quizzes', $cached_data ) ) {
496
- $course = $this->get_course();
497
-
498
- $data = array( 'result' => 0, 'grade' => '', 'status' => $this->get_status() );
499
- $result = 0;
500
-
501
- if ( $items = $this->get_items() ) {
502
- $result_of_items = 0;
503
- foreach ( $items as $item ) {
504
- if ( $item->get_type() !== LP_QUIZ_CPT ) {
505
- continue;
506
- }
507
- if ( $item->get_quiz()->get_data( 'passing_grade' ) ) {
508
- $result += $item->is_passed() ? 1 : 0;
509
- $result_of_items ++;
510
- }
511
- }
512
- $result = $result_of_items ? $result * 100 / $result_of_items : 0;
513
- $data['result'] = $result;
514
- if ( $this->is_finished() ) {
515
- $data['grade'] = $this->_is_passed( $result );
516
- }
517
- }
518
-
519
- settype( $cached_data, 'array' );
520
- $cached_data['completed-quizzes'] = $data;
521
-
522
- wp_cache_set( $cache_key, $cached_data, 'learn-press/course-results' );
523
- }
524
-
525
- return isset( $cached_data['completed-quizzes'] ) ? $cached_data['completed-quizzes'] : array();
526
- }
527
-
528
- protected function _is_passed( $result ) {
529
- $result = round( $result, 2 );
530
-
531
- return $result >= $this->get_passing_condition() ? 'passed' : 'failed';
532
- }
533
-
534
- /**
535
- * Get completed items.
536
- *
537
- * @param string $type - Optional. Filter by type (such lp_quiz, lp_lesson) if passed
538
- * @param bool $with_total - Optional. Include total if TRUE
539
- * @param int $section_id - Optional. Get in specific section
540
- *
541
- * @return array|bool|mixed
542
- */
543
- public function get_completed_items( $type = '', $with_total = false, $section_id = 0 ) {
544
- $this->load();
545
-
546
- $key = sprintf( '%d-%d-%s', $this->get_user_id(), $this->_course->get_id(), md5( build_query( func_get_args() ) ) );
547
-
548
- if ( false === ( $completed_items = wp_cache_get( $key, 'learn-press/user-completed-items' ) ) ) {
549
- $completed = 0;
550
- $total = 0;
551
- $section_items = array();
552
-
553
- if ( $section_id && $section = $this->_course->get_sections( 'object', $section_id ) ) {
554
- $section_items = $section->get_items();
555
-
556
- if ( $section_items ) {
557
- $section_items = array_keys( $section_items );
558
- }
559
- }
560
-
561
- if ( $items = $this->_items ) {
562
- foreach ( $items as $item ) {
563
-
564
- if ( $section_id && ! in_array( $item->get_id(), $section_items ) ) {
565
- continue;
566
- }
567
-
568
- if ( $type ) {
569
- $item_type = $item->get_data( 'item_type' );
570
- } else {
571
- $item_type = '';
572
- }
573
-
574
- if ( $type === $item_type ) {
575
- if ( $item->get_status() == 'completed' ) {
576
- $completed ++;
577
- }
578
- $completed = apply_filters( 'learn-press/course-item/completed', $completed, $item, $item->get_status() );
579
- //if ( ! $item->is_preview() ) {
580
- $total ++;
581
- //}
582
- }
583
- }
584
- }
585
- $completed_items = array( $completed, $total );
586
- wp_cache_set( $key, $completed_items, 'learn-press/user-completed-items' );
587
- }
588
-
589
- return $with_total ? $completed_items : $completed_items[0];
590
- }
591
-
592
- /**
593
- * Get items completed by percentage.
594
- *
595
- * @param string $type - Optional. Filter by type or not
596
- * @param int $section_id - Optional. Get in specific section
597
- *
598
- * @return float|int
599
- */
600
- public function get_percent_completed_items( $type = '', $section_id = 0 ) {
601
- $values = $this->get_completed_items( $type, true, $section_id );
602
- if ( $values[1] ) {
603
- return $values[0] / $values[1] * 100;
604
- }
605
-
606
- return 0;
607
- }
608
-
609
- /**
610
- * Get passing condition criteria.
611
- *
612
- * @return string
613
- */
614
- public function get_passing_condition() {
615
- return $this->_course->get_passing_condition();
616
- }
617
-
618
- /**
619
- * Get all items in course.
620
- *
621
- * @return LP_User_Item[]
622
- */
623
- public function get_items() {
624
- $this->load();
625
-
626
- return $this->_items;
627
- }
628
-
629
- /**
630
- * Check course is completed or not.
631
- *
632
- * @return bool
633
- */
634
- public function is_finished() {
635
- return $this->get_status() === 'finished';
636
- }
637
-
638
- /**
639
- * Check course graduation is passed or not.
640
- *
641
- * @return bool
642
- */
643
- public function is_graduated() {
644
- return $this->get_results( 'grade' ) == 'passed';
645
- }
646
-
647
- /**
648
- * @return bool
649
- */
650
- public function can_graduated() {
651
- return $this->get_results( 'result' ) >= $this->get_passing_condition();
652
- }
653
-
654
- function __destruct() {
655
- // TODO: Implement __unset() method.
656
- }
657
-
658
- /**
659
- * @param int $item_id
660
- *
661
- * @return LP_User_Item|LP_User_Item_Quiz|bool
662
- */
663
- public function get_item( $item_id ) {
664
- $this->load();
665
-
666
- return ! empty( $this->_items[ $item_id ] ) ? $this->_items[ $item_id ] : false;
667
- }
668
-
669
- /**
670
- * @param int $user_item_id
671
- *
672
- * @return LP_User_Item|LP_User_Item_Quiz|bool
673
- */
674
- public function get_item_by_user_item_id( $user_item_id ) {
675
- $this->load();
676
-
677
- if ( ! empty( $this->_items_by_item_ids[ $user_item_id ] ) ) {
678
- $item_id = $this->_items_by_item_ids[ $user_item_id ];
679
-
680
- return $this->get_item( $item_id );
681
- }
682
-
683
- return false;
684
- }
685
-
686
- public function set_item( $item ) {
687
-
688
-
689
- $this->load();
690
-
691
- if ( $item = LP_User_Item::get_item_object( $item ) ) {
692
- $this->_items[ $item->get_item_id() ] = $item;
693
- }
694
- }
695
-
696
- /**
697
- * @param $item_id
698
- * @param string $prop
699
- *
700
- * @return bool|float|int
701
- */
702
- public function get_item_result( $item_id, $prop = 'result' ) {
703
- if ( $item = $this->get_item( $item_id ) ) {
704
- return $item->get_result( $prop );
705
- }
706
-
707
- return false;
708
- }
709
-
710
- public function get_result( $prop = '' ) {
711
- return $this->get_results( $prop );
712
- }
713
-
714
- /**
715
- * @param int $at
716
- *
717
- * @return LP_User_Item_Course
718
- */
719
- public function get_item_at( $at = 0 ) {
720
- $this->load();
721
- $values = array_values( $this->_items );
722
- $item = ! empty( $values[ $at ] ) ? $values[ $at ] : false;
723
-
724
- return $item;
725
- }
726
-
727
- /**
728
- * @param $id
729
- *
730
- * @return LP_User_Item_Quiz|bool
731
- */
732
- public function get_item_quiz( $id ) {
733
-
734
- $this->load();
735
- $item = ! empty( $this->_items[ $id ] ) ? $this->_items[ $id ] : new LP_User_Item_Quiz( array() );
736
-
737
- return $item;
738
- }
739
-
740
- /**
741
- * Get js settings of course.
742
- *
743
- * @return array
744
- */
745
- public function get_js_args() {
746
- $js_args = false;
747
- if ( $course = $this->get_course() ) {
748
- $item = false;
749
- $js_args = array(
750
- 'root_url' => trailingslashit( get_home_url() ),
751
- 'id' => $course->get_id(),
752
- 'url' => $course->get_permalink(),
753
- 'result' => $this->get_results(),
754
- 'current_item' => $item ? $item->get_id() : false,
755
- 'items' => $this->get_items_for_js()
756
- );
757
- }
758
-
759
- return apply_filters( 'learn-press/course/single-params', $js_args, $this->get_id() );
760
- }
761
-
762
- public function update_item_retaken_count( $item_id, $count = 0 ) {
763
- $items = $this->get_meta( '_retaken_items' );
764
- if ( is_string( $count ) && preg_match( '#^(\+|\-)([0-9]+)#', $count, $m ) ) {
765
- $last_count = ! empty( $items[ $item_id ] ) ? $items[ $item_id ] : 0;
766
- $count = $m[1] == '+' ? ( $last_count + $m[2] ) : ( $last_count - $m[2] );
767
- }
768
-
769
- $items[ $item_id ] = $count;
770
-
771
- learn_press_update_user_item_meta( $this->get_user_item_id(), '_retaken_items', $items );
772
-
773
- return $count;
774
- }
775
-
776
- public function get_item_retaken_count( $item_id ) {
777
- $items = $this->get_meta( '_retaken_items' );
778
- $count = false;
779
-
780
- if ( is_array( $items ) && array_key_exists( $item_id, $items ) ) {
781
- $count = absint( $items[ $item_id ] );
782
- }
783
-
784
- return $count;
785
- }
786
-
787
- /**
788
- * Get number of retaken times for user course.
789
- *
790
- * @return int
791
- */
792
- public function get_retaken_count() {
793
- return absint( learn_press_get_user_item_meta( $this->get_user_item_id(), '_lp_retaken_count', true ) );
794
- }
795
-
796
- /**
797
- * Increase retaken count.
798
- *
799
- * @return bool|int
800
- */
801
- public function increase_retake_count() {
802
- $count = $this->get_retaken_count();
803
- $count ++;
804
-
805
- return learn_press_update_user_item_meta( $this->get_user_item_id(), '_lp_retaken_count', $count );
806
- }
807
-
808
- /**
809
- * Get js settings of course items.
810
- *
811
- * @return array
812
- */
813
- public function get_items_for_js() {
814
-
815
- /*** TEST CACHE ***/
816
- return false;
817
- $args = array();
818
- if ( $items = $this->get_items() ) {
819
- $user = $this->get_user();
820
- $course = $this->get_course();
821
- foreach ( $items as $item ) {
822
-
823
- $args[ $item->get_id() ] = $item->get_js_args();// $item_js;
824
- }
825
- }
826
-
827
- return apply_filters( 'learn-press/course/items-for-js', $args, $this->get_id(), $this->get_user_id() );
828
- }
829
-
830
- /**
831
- * Add new item
832
- *
833
- * @param int|array $item_id
834
- * @param int $user_id
835
- *
836
- * @return bool
837
- */
838
- public function add_item( $item_id, $user_id = 0 ) {
839
- $this->load();
840
-
841
- if ( empty( $this->_items[ $item_id ] ) ) {
842
- return false;
843
- }
844
-
845
- $item_data = is_numeric( $item_id ) ? array( 'item_id' => $item_id ) : (array) $item_id;
846
-
847
- if ( func_num_args() == 2 ) {
848
- $item_data['user_id'] = $user_id ? $user_id : get_current_user_id();
849
- }
850
-
851
- $current_time = new LP_Datetime();
852
- $defaults = array(
853
- 'start_time' => $current_time,
854
- 'start_time_gtm' => $current_time->toSql( false ),
855
- 'end_time' => $current_time,
856
- 'end_time_gmt' => $current_time->toSql( false ),
857
- 'item_type' => learn_press_get_post_type( $item_id ),
858
- 'status' => '',
859
- 'ref_id' => $this->get_id(),
860
- 'ref_type' => learn_press_get_post_type( $this->get_id() ),
861
- 'parent_id' => $this->get_user_item_id()
862
- );
863
- $item_data = wp_parse_args(
864
- $item_data,
865
- $defaults
866
- );
867
-
868
- $this->_items[ $item_id ] = LP_User_Item::get_item_object( $item_data );
869
-
870
- return $this->_items[ $item_id ];
871
- }
872
-
873
- /**
874
- * Update user item
875
- */
876
- public function save() {
877
- $this->update();
878
-
879
- if ( ! $items = $this->get_items() ) {
880
- return false;
881
- }
882
-
883
- foreach ( $items as $item_id => $item ) {
884
-
885
- if ( ! $item->get_status() ) {
886
- continue;
887
- }
888
-
889
- $item->update();
890
- }
891
-
892
- //global $wp_object_cache;
893
- //
894
- // learn_press_debug($wp_object_cache);
895
-
896
- return true;
897
- }
898
- }
inc/user-item/class-lp-user-item-quiz.php CHANGED
@@ -158,7 +158,7 @@ class LP_User_Item_Quiz extends LP_User_Item {
158
$result['question_empty'] ++;
159
} else {
160
// minus for each wrong, empty question
161
- $result['user_mark'] -= $quiz->get_minus_points();
162
$result['question_wrong'] ++;
163
}
164
}
158
$result['question_empty'] ++;
159
} else {
160
// minus for each wrong, empty question
161
+ $result['user_mark'] -= intval($quiz->get_minus_points());
162
$result['question_wrong'] ++;
163
}
164
}
inc/user/abstract-lp-user.php CHANGED
@@ -160,7 +160,10 @@ if ( ! class_exists( 'LP_Abstract_User' ) ) {
160
if ( ! $course_id ) {
161
$course_id = get_the_ID();
162
}
163
-
164
if ( false === ( $object_course_data = wp_cache_get( 'course-' . $this->get_id() . '-' . $course_id, 'lp-user-course-data' ) ) ) {
165
$this->_curd->read_course( $this->get_id(), $course_id );
166
if ( false !== ( $course_item = wp_cache_get( 'course-' . $this->get_id() . '-' . $course_id, 'lp-user-courses' ) ) ) {
160
if ( ! $course_id ) {
161
$course_id = get_the_ID();
162
}
163
+ /**
164
+ * @BUG: Cache enable => Not store all user answer of quiz, only store the last use answer for question
165
+ * @TODO: need improve this proccess
166
+ */
167
if ( false === ( $object_course_data = wp_cache_get( 'course-' . $this->get_id() . '-' . $course_id, 'lp-user-course-data' ) ) ) {
168
$this->_curd->read_course( $this->get_id(), $course_id );
169
if ( false !== ( $course_item = wp_cache_get( 'course-' . $this->get_id() . '-' . $course_id, 'lp-user-courses' ) ) ) {
inc/user/class-lp-profile.php CHANGED
@@ -228,12 +228,12 @@ if ( ! class_exists( 'LP_Profile' ) ) {
228
}
229
230
$settings = LP()->settings;
231
- $this->_publicity = array(
232
'view-tab-dashboard' => $this->get_publicity( 'my-dashboard' ) == 'yes',
233
'view-tab-basic-information' => $this->get_publicity( 'dashboard' ) == 'yes',
234
'view-tab-courses' => $this->get_publicity( 'courses' ) == 'yes',
235
'view-tab-quizzes' => $this->get_publicity( 'quizzes' ) == 'yes'
236
- );
237
}
238
239
return $this->_user;
@@ -397,7 +397,7 @@ if ( ! class_exists( 'LP_Profile' ) ) {
397
* Get current tab slug in query string.
398
*
399
* @param string $default Optional.
400
- * @param bool $key Optional. True if return the key instead of value.
401
*
402
* @return string
403
*/
@@ -409,7 +409,7 @@ if ( ! class_exists( 'LP_Profile' ) ) {
409
* Get current section in query string.
410
*
411
* @param string $default
412
- * @param bool $key
413
* @param string $tab
414
*
415
* @return bool|int|mixed|string
@@ -457,8 +457,8 @@ if ( ! class_exists( 'LP_Profile' ) ) {
457
/**
458
* Get current link of profile
459
*
460
- * @param string $args - Optional. Add more query args to url.
461
- * @param bool $with_permalink - Optional. TRUE to build url as friendly url.
462
*
463
* @return mixed|string
464
*/
@@ -748,8 +748,8 @@ if ( ! class_exists( 'LP_Profile' ) ) {
748
);
749
}
750
751
- }else{
752
- $query = new LP_Query_List_Table($query);
753
}
754
755
return $query;
@@ -759,7 +759,7 @@ if ( ! class_exists( 'LP_Profile' ) ) {
759
* Query user's courses
760
*
761
* @param string $type - Optional. [own, purchased, enrolled, etc]
762
- * @param mixed $args - Optional.
763
*
764
* @return array|LP_Query_List_Table
765
*/
@@ -925,7 +925,7 @@ if ( ! class_exists( 'LP_Profile' ) ) {
925
/**
926
* Echo class for main div.
927
*
928
- * @param bool $echo
929
* @param string $more
930
*
931
* @return string
@@ -958,7 +958,7 @@ if ( ! class_exists( 'LP_Profile' ) ) {
958
* Return true if the tab is visible for current user.
959
*
960
* @param string $tab_key
961
- * @param array $tab_data
962
*
963
* @return bool
964
*/
@@ -970,7 +970,7 @@ if ( ! class_exists( 'LP_Profile' ) ) {
970
* Return true if the section is visible for current user.
971
*
972
* @param string $section_key
973
- * @param array $section_data
974
*
975
* @return bool
976
*/
228
}
229
230
$settings = LP()->settings;
231
+ $this->_publicity = apply_filters( 'learn-press/check-publicity-setting', array(
232
'view-tab-dashboard' => $this->get_publicity( 'my-dashboard' ) == 'yes',
233
'view-tab-basic-information' => $this->get_publicity( 'dashboard' ) == 'yes',
234
'view-tab-courses' => $this->get_publicity( 'courses' ) == 'yes',
235
'view-tab-quizzes' => $this->get_publicity( 'quizzes' ) == 'yes'
236
+ ), $this );
237
}
238
239
return $this->_user;
397
* Get current tab slug in query string.
398
*
399
* @param string $default Optional.
400
+ * @param bool $key Optional. True if return the key instead of value.
401
*
402
* @return string
403
*/
409
* Get current section in query string.
410
*
411
* @param string $default
412
+ * @param bool $key
413
* @param string $tab
414
*
415
* @return bool|int|mixed|string
457
/**
458
* Get current link of profile
459
*
460
+ * @param string $args - Optional. Add more query args to url.
461
+ * @param bool $with_permalink - Optional. TRUE to build url as friendly url.
462
*
463
* @return mixed|string
464
*/
748
);
749
}
750
751
+ } else {
752
+ $query = new LP_Query_List_Table( $query );
753
}
754
755
return $query;
759
* Query user's courses
760
*
761
* @param string $type - Optional. [own, purchased, enrolled, etc]
762
+ * @param mixed $args - Optional.
763
*
764
* @return array|LP_Query_List_Table
765
*/
925
/**
926
* Echo class for main div.
927
*
928
+ * @param bool $echo
929
* @param string $more
930
*
931
* @return string
958
* Return true if the tab is visible for current user.
959
*
960
* @param string $tab_key
961
+ * @param array $tab_data
962
*
963
* @return bool
964
*/
970
* Return true if the section is visible for current user.
971
*
972
* @param string $section_key
973
+ * @param array $section_data
974
*
975
* @return bool
976
*/
inc/user/class-lp-user-factory.php CHANGED
@@ -191,11 +191,16 @@ class LP_User_Factory {
191
$item = $curd->get_user_item_by_id( $user_item_id );
192
$last_status = $curd->get_user_item_meta( $user_item_id, '_last_status' );
193
$args = array( 'status' => $last_status );
194
- if ( $new_status == 'completed' ) {
195
$args['status'] = 'enrolled';
196
}
197
if ( ! $last_status ) {
198
- if ( 'enrolled' == ( $args['status'] = LP()->settings->get( 'auto_enroll' ) == 'no' ? 'purchased' : 'enrolled' ) ) {
199
$time = new LP_Datetime();
200
$args['start_time'] = $time->toSql();
201
$args['start_time_gmt'] = $time->toSql( false );
191
$item = $curd->get_user_item_by_id( $user_item_id );
192
$last_status = $curd->get_user_item_meta( $user_item_id, '_last_status' );
193
$args = array( 'status' => $last_status );
194
+ $user = learn_press_get_user($user_id);
195
+ $course_id = $item['item_id'];
196
+ $can_enroll = $user->can_enroll_course($course_id);
197
+ $auto_enroll = LP()->settings->get( 'auto_enroll' ) == 'yes';
198
+ if ( $new_status == 'completed' && $can_enroll && $auto_enroll) {
199
$args['status'] = 'enrolled';
200
}
201
if ( ! $last_status ) {
202
+ $args['status'] = $auto_enroll && $can_enroll ? 'enrolled' : 'purchased';
203
+ if ( 'enrolled' == $args['status'] ) {
204
$time = new LP_Datetime();
205
$args['start_time'] = $time->toSql();
206
$args['start_time_gmt'] = $time->toSql( false );
learnpress.php CHANGED
@@ -4,7 +4,7 @@ Plugin Name: LearnPress
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: 3.0.11.1
8
Author URI: http://thimpress.com
9
Requires at least: 3.8
10
Tested up to: 4.9.6
@@ -137,7 +137,7 @@ if ( ! class_exists( 'LearnPress' ) ) {
137
}
138
139
if ( file_exists( $file ) ) {
140
- $this->backgrounds[ $name ] = include $file;
141
}
142
}
143
}
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: 3.0.12.1
8
Author URI: http://thimpress.com
9
Requires at least: 3.8
10
Tested up to: 4.9.6
137
}
138
139
if ( file_exists( $file ) ) {
140
+ $this->backgrounds[ $name ] = include_once $file;
141
}
142
}
143
}
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link:
4
Tags: WordPress LMS, LMS, eLearning, e-Learning, Learning Management System, LMS WordPress, Course, Courses, Quiz, Quizzes, Training, Guru, Sell Courses
5
Requires at least: 3.8
6
Tested up to: 4.9.5
7
- Stable tag: 3.0.11.1
8
License: GPLv2 or later
9
License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
@@ -36,8 +36,8 @@ Take a look at Premium **[Education WordPress Theme](http://themeforest.net/item
36
37
- **[How to create a Udemy or Coursera clone easily with LearnPress](https://thimpress.com/create-udemy-coursera-clone-easily-learnpress/?utm_source=wporg&utm_medium=learnpress&ref=thimpress&utm_campaign=learnpress)**
38
39
- - Step-by-step Youtube guide on setting up your own Online Course site. **[Click here >>](https://www.youtube.com/watch?v=zTtZ_CpWDOY)**
40
- [youtube https://www.youtube.com/watch?v=zTtZ_CpWDOY&hd=1&&cc_load_policy=1]
41
42
Are you looking for *best LMS WordPress plugin*?
43
@@ -199,6 +199,25 @@ https://www.transifex.com/projects/p/learnpress/
199
8. Add-ons of LearnPress.
200
201
== Changelog ==
202
203
= 3.0.10 =
204
+ Added quiz option to minus a number of point for each wrong question in quiz
4
Tags: WordPress LMS, LMS, eLearning, e-Learning, Learning Management System, LMS WordPress, Course, Courses, Quiz, Quizzes, Training, Guru, Sell Courses
5
Requires at least: 3.8
6
Tested up to: 4.9.5
7
+ Stable tag: 3.0.12.1
8
License: GPLv2 or later
9
License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
36
37
- **[How to create a Udemy or Coursera clone easily with LearnPress](https://thimpress.com/create-udemy-coursera-clone-easily-learnpress/?utm_source=wporg&utm_medium=learnpress&ref=thimpress&utm_campaign=learnpress)**
38
39
+ - Step-by-step Youtube guide on setting up your own Online Course site. **[Click here >>](https://www.youtube.com/watch?v=3LDa8vtDIAk)**
40
+ [youtube https://www.youtube.com/watch?v=3LDa8vtDIAk&hd=1&&cc_load_policy=1]
41
42
Are you looking for *best LMS WordPress plugin*?
43
199
8. Add-ons of LearnPress.
200
201
== Changelog ==
202
+ = 3.0.12 =
203
+ ~ Fixed minor bug in gradebook list in admin
204
+ ~ Made hook learn-press/course-tabs work
205
+ ~ Fixed bug: not auto complete quiz. Add 1 more filter hook for checking publicity in profile page
206
+ ~ Fixed bug: auto enroll course without permission to enroll course
207
+ ~ Changed filter tag for get_default_meta of lesson
208
+ ~ Auto full-screen in mobile view
209
+ ~ Fixed bug: wrong count number in No Preview at Lessons List back end page
210
+ ~ Fixed bug: Instructor user cannot see comments of lesson
211
+ ~ Changed version for template files
212
+ ~ Added base url for construct nav in user profile
213
+ ~ Added param for get_nav method
214
+ ~ Fixed bug: answer correct all question but quiz result is failse with 0%
215
+ ~ Fixed small bug in quiz editor
216
+ ~ Fixed bug: wrong count number of the courses in back end because of the status of preview course
217
+ ~ Fixed bug: not redirect to correct page after logged in in Profile page
218
+ ~ Fixed bug fatal error include file
219
+ ~ Added icon for chat-type-format of content item
220
+ ~ Fixed header-sent when log file
221
222
= 3.0.10 =
223
+ Added quiz option to minus a number of point for each wrong question in quiz
templates/profile/tabs/courses/owned.php CHANGED
@@ -6,7 +6,7 @@
6
*
7
* @author ThimPress
8
* @package Learnpress/Templates
9
- * @version 3.0.0
10
*/
11
12
/**
@@ -49,8 +49,7 @@ $query = $profile->query_courses( 'own', array( 'status' => $filter_stat
49
wp_reset_postdata();
50
?>
51
</ul>
52
-
53
- <?php $query->get_nav( '', true ); ?>
54
55
<?php } ?>
56
</div>
6
*
7
* @author ThimPress
8
* @package Learnpress/Templates
9
+ * @version 3.0.11.2
10
*/
11
12
/**
49
wp_reset_postdata();
50
?>
51
</ul>
52
+ <?php $query->get_nav( '', true, $profile->get_current_url() ); ?>
53
54
<?php } ?>
55
</div>
templates/profile/tabs/courses/purchased.php CHANGED
@@ -6,7 +6,7 @@
6
*
7
* @author ThimPress
8
* @package Learnpress/Templates
9
- * @version 3.0.0
10
*/
11
12
/**
@@ -73,7 +73,7 @@ $query = $profile->query_courses( 'purchased', array( 'status' => $filte
73
<?php echo $query->get_offset_text(); ?>
74
</td>
75
<td colspan="2" class="nav-pages">
76
- <?php $query->get_nav_numbers( true ); ?>
77
</td>
78
</tr>
79
</tfoot>
6
*
7
* @author ThimPress
8
* @package Learnpress/Templates
9
+ * @version 3.0.11.2
10
*/
11
12
/**
73
<?php echo $query->get_offset_text(); ?>
74
</td>
75
<td colspan="2" class="nav-pages">
76
+ <?php $query->get_nav_numbers( true, $profile->get_current_url() ); ?>
77
</td>
78
</tr>
79
</tfoot>