Version Description
- Fixed issue with slug of course page is the same with slug of course tab in profile
- Fixed issue with metabox show/hide field
Download this release
Release Info
Developer | leehld |
Plugin | LearnPress – WordPress LMS Plugin |
Version | 2.1.5.5 |
Comparing to | |
See all releases |
Code changes from version 2.1.6.1 to 2.1.5.5
- assets/css/admin/admin.css +6 -6
- assets/css/admin/admin.less +9 -8
- assets/css/admin/meta-box-course.css +0 -7
- assets/css/admin/meta-box-course.less +1 -4
- assets/css/learnpress.css +23 -88
- assets/css/learnpress.less +37 -98
- assets/js/admin/admin.js +1 -1
- assets/js/admin/meta-box-course.js +1 -25
- assets/js/admin/meta-box-quiz.js +1 -13
- assets/js/frontend/learnpress.js +2 -1
- assets/js/frontend/lesson.js +6 -3
- assets/js/frontend/single-course.js +12 -43
- assets/js/global.js +3 -2
- assets/js/global.min.js +2 -2
- inc/admin/includes/class-markdown-parse.php +5 -7
- inc/class-lp-assets.php +1 -1
- inc/class-lp-cache.php +2 -34
- inc/class-lp-page-controller.php +3 -6
- inc/class-lp-request-handler.php +10 -20
- inc/class-lp-shortcodes.php +21 -2
- inc/course/abstract-lp-course.php +25 -154
- inc/course/lp-course-functions.php +0 -31
- inc/custom-post-types/course.php +12 -26
- inc/custom-post-types/order.php +2 -32
- inc/custom-post-types/quiz.php +41 -50
- inc/lesson/lp-lesson-functions.php +7 -19
- inc/libraries/meta-box/inc/fields/datetime.php +1 -1
- inc/libraries/meta-box/inc/fields/time.php +2 -2
- inc/lp-constants.php +1 -1
- inc/lp-core-functions.php +9 -52
- inc/lp-init.php +20 -40
- inc/lp-template-functions.php +17 -10
- inc/new-functions.php +119 -0
- inc/order/class-lp-order.php +3 -2
- inc/question/class-lp-question-factory.php +2 -17
- inc/quiz/class-lp-quiz-factory.php +1 -10
- inc/updates/09/script.js +2 -1
- inc/user/abstract-lp-user.php +17 -58
- inc/user/class-lp-user-factory.php +5 -10
- inc/user/lp-user-functions.php +4 -14
- learnpress.php +1 -1
- readme.txt +2 -16
- templates/content-quiz/buttons.php +2 -6
- templates/global/become-teacher-form.php +2 -5
- templates/profile/tabs/edit.php +3 -11
- templates/single-course/buttons.php +116 -91
- templates/single-course/content-item-only.php +1 -0
- templates/single-course/nav-items.php +0 -1
- templates/single-course/progress.php +17 -12
- templates/single-course/section/item-meta.php +24 -57
- templates/single-course/section/item-quiz.php +9 -33
- templates/single-course/section/title.php +1 -1
assets/css/admin/admin.css
CHANGED
@@ -19,14 +19,11 @@ input:focus:-moz-placeholder {
|
|
19 |
.rwmb-field .rwmb-input .rwmb-label {
|
20 |
margin-top: 0;
|
21 |
}
|
22 |
-
.rwmb-field .rwmb-input .
|
23 |
-
margin-top: 5px;
|
24 |
-
}
|
25 |
-
.rwmb-field .rwmb-input .description.option-desc {
|
26 |
font-weight: normal;
|
27 |
-
|
28 |
-
font-size: smaller;
|
29 |
font-style: italic;
|
|
|
30 |
}
|
31 |
.lp-nav-tab-wrapper {
|
32 |
border-bottom: 1px solid #ccc;
|
@@ -272,6 +269,9 @@ input:focus:-moz-placeholder {
|
|
272 |
.meta_box_course_lesson_quiz li select {
|
273 |
min-width: 250px;
|
274 |
}
|
|
|
|
|
|
|
275 |
.dashed-placeholder {
|
276 |
border: 2px dashed #999;
|
277 |
padding: 10px;
|
19 |
.rwmb-field .rwmb-input .rwmb-label {
|
20 |
margin-top: 0;
|
21 |
}
|
22 |
+
.rwmb-field .rwmb-input .option-desc {
|
|
|
|
|
|
|
23 |
font-weight: normal;
|
24 |
+
padding-left: 24px;
|
|
|
25 |
font-style: italic;
|
26 |
+
margin-top: 3px;
|
27 |
}
|
28 |
.lp-nav-tab-wrapper {
|
29 |
border-bottom: 1px solid #ccc;
|
269 |
.meta_box_course_lesson_quiz li select {
|
270 |
min-width: 250px;
|
271 |
}
|
272 |
+
.description {
|
273 |
+
margin-top: 5px;
|
274 |
+
}
|
275 |
.dashed-placeholder {
|
276 |
border: 2px dashed #999;
|
277 |
padding: 10px;
|
assets/css/admin/admin.less
CHANGED
@@ -26,14 +26,11 @@ input:focus:-moz-placeholder {
|
|
26 |
.rwmb-label {
|
27 |
margin-top: 0;
|
28 |
}
|
29 |
-
.
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
font-size: smaller;
|
35 |
-
font-style: italic;
|
36 |
-
}
|
37 |
}
|
38 |
}
|
39 |
}
|
@@ -318,6 +315,10 @@ input:focus:-moz-placeholder {
|
|
318 |
min-width: 250px;
|
319 |
}
|
320 |
|
|
|
|
|
|
|
|
|
321 |
.dashed-placeholder {
|
322 |
border: 2px dashed #999;
|
323 |
padding: 10px;
|
26 |
.rwmb-label {
|
27 |
margin-top: 0;
|
28 |
}
|
29 |
+
.option-desc {
|
30 |
+
font-weight: normal;
|
31 |
+
padding-left: 24px;
|
32 |
+
font-style: italic;
|
33 |
+
margin-top: 3px;
|
|
|
|
|
|
|
34 |
}
|
35 |
}
|
36 |
}
|
315 |
min-width: 250px;
|
316 |
}
|
317 |
|
318 |
+
.description {
|
319 |
+
margin-top: 5px;
|
320 |
+
}
|
321 |
+
|
322 |
.dashed-placeholder {
|
323 |
border: 2px dashed #999;
|
324 |
padding: 10px;
|
assets/css/admin/meta-box-course.css
CHANGED
@@ -3,13 +3,6 @@
|
|
3 |
.rwmb-duration-wrapper select {
|
4 |
vertical-align: baseline;
|
5 |
}
|
6 |
-
#learn-press-toggle-course-results {
|
7 |
-
display: block;
|
8 |
-
margin-bottom: 10px;
|
9 |
-
}
|
10 |
-
#learn-press-toggle-course-results a {
|
11 |
-
box-shadow: none;
|
12 |
-
}
|
13 |
.post-type-lp_course #postdivric,
|
14 |
.post-type-lp_course #submitpost {
|
15 |
visibility: hidden;
|
3 |
.rwmb-duration-wrapper select {
|
4 |
vertical-align: baseline;
|
5 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
.post-type-lp_course #postdivric,
|
7 |
.post-type-lp_course #submitpost {
|
8 |
visibility: hidden;
|
assets/css/admin/meta-box-course.less
CHANGED
@@ -3,10 +3,7 @@
|
|
3 |
.rwmb-duration-wrapper select {
|
4 |
vertical-align: baseline;
|
5 |
}
|
6 |
-
|
7 |
-
display: block;margin-bottom:10px;
|
8 |
-
a{box-shadow: none;}
|
9 |
-
}
|
10 |
.post-type-lp_course {
|
11 |
#postdivric,
|
12 |
#submitpost {
|
3 |
.rwmb-duration-wrapper select {
|
4 |
vertical-align: baseline;
|
5 |
}
|
6 |
+
|
|
|
|
|
|
|
7 |
.post-type-lp_course {
|
8 |
#postdivric,
|
9 |
#submitpost {
|
assets/css/learnpress.css
CHANGED
@@ -277,55 +277,6 @@
|
|
277 |
#learn-press-course-curriculum .course-item .lp-icon {
|
278 |
display: none;
|
279 |
}
|
280 |
-
#learn-press-course-curriculum .course-item .item-status {
|
281 |
-
display: none;
|
282 |
-
font-family: dashicons;
|
283 |
-
-webkit-border-radius: 4px;
|
284 |
-
-khtml-border-radius: 4px;
|
285 |
-
-moz-border-radius: 4px;
|
286 |
-
-ms-border-radius: 4px;
|
287 |
-
-o-border-radius: 4px;
|
288 |
-
border-radius: 4px;
|
289 |
-
background: #DDD;
|
290 |
-
color: #22b4ff;
|
291 |
-
font-size: 18px;
|
292 |
-
}
|
293 |
-
#learn-press-course-curriculum .course-item .item-status:before {
|
294 |
-
content: "\f177";
|
295 |
-
}
|
296 |
-
#learn-press-course-curriculum .course-item .item-status.item-status-started:before {
|
297 |
-
content: "\f469";
|
298 |
-
}
|
299 |
-
#learn-press-course-curriculum .course-item .item-status.item-status-completed {
|
300 |
-
background: #22b4ff;
|
301 |
-
color: #FFF;
|
302 |
-
}
|
303 |
-
#learn-press-course-curriculum .course-item .item-status.item-status-completed:before {
|
304 |
-
content: "\f147";
|
305 |
-
}
|
306 |
-
#learn-press-course-curriculum .course-item .item-status.item-status-passed {
|
307 |
-
background: #22b4ff;
|
308 |
-
color: #FFF;
|
309 |
-
}
|
310 |
-
#learn-press-course-curriculum .course-item .item-status.item-status-passed:before {
|
311 |
-
content: "\f147";
|
312 |
-
}
|
313 |
-
#learn-press-course-curriculum .course-item .item-status.item-status-failed {
|
314 |
-
background: #cc540d;
|
315 |
-
color: #FFF;
|
316 |
-
}
|
317 |
-
#learn-press-course-curriculum .course-item .item-status.item-status-failed:before {
|
318 |
-
content: "\f335";
|
319 |
-
}
|
320 |
-
#learn-press-course-curriculum .course-item .item-result {
|
321 |
-
display: none;
|
322 |
-
}
|
323 |
-
#learn-press-course-curriculum .course-item.item-has-status .item-status {
|
324 |
-
display: inline-block;
|
325 |
-
}
|
326 |
-
#learn-press-course-curriculum .course-item.item-has-result .item-result {
|
327 |
-
display: inline-block;
|
328 |
-
}
|
329 |
#learn-press-course-curriculum .course-item.viewable {
|
330 |
cursor: pointer;
|
331 |
}
|
@@ -357,6 +308,27 @@
|
|
357 |
height: 100%;
|
358 |
content: '';
|
359 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
360 |
#learn-press-course-curriculum .course-item.focus {
|
361 |
background: #ffb710;
|
362 |
}
|
@@ -381,20 +353,6 @@
|
|
381 |
float: right;
|
382 |
margin-top: 5px;
|
383 |
}
|
384 |
-
#learn-press-course-curriculum .course-item-meta .item-loop-meta-text {
|
385 |
-
font-size: small;
|
386 |
-
}
|
387 |
-
#learn-press-course-curriculum .course-item-meta .item-loop-meta-text.item-final {
|
388 |
-
color: #ffffff;
|
389 |
-
background: #cc540d;
|
390 |
-
padding: 3px 8px;
|
391 |
-
-webkit-border-radius: 3px;
|
392 |
-
-khtml-border-radius: 3px;
|
393 |
-
-moz-border-radius: 3px;
|
394 |
-
-ms-border-radius: 3px;
|
395 |
-
-o-border-radius: 3px;
|
396 |
-
border-radius: 3px;
|
397 |
-
}
|
398 |
.lp-icon {
|
399 |
display: inline-block;
|
400 |
font-family: 'lp-icons';
|
@@ -516,26 +474,6 @@
|
|
516 |
.single-lp_course .learn-press-course-results-progress .percentage-sign {
|
517 |
margin-left: 5px;
|
518 |
}
|
519 |
-
.single-lp_course .learn-press-course-results-progress .grade {
|
520 |
-
font-size: 12px;
|
521 |
-
font-weight: bold;
|
522 |
-
background: #F5F5F5;
|
523 |
-
padding: 2px 7px;
|
524 |
-
-webkit-border-radius: 3px;
|
525 |
-
-khtml-border-radius: 3px;
|
526 |
-
-moz-border-radius: 3px;
|
527 |
-
-ms-border-radius: 3px;
|
528 |
-
-o-border-radius: 3px;
|
529 |
-
border-radius: 3px;
|
530 |
-
}
|
531 |
-
.single-lp_course .learn-press-course-results-progress .grade.passed {
|
532 |
-
color: #ffffff;
|
533 |
-
background: #95e6f9;
|
534 |
-
}
|
535 |
-
.single-lp_course .learn-press-course-results-progress .grade.failed {
|
536 |
-
color: #ffffff;
|
537 |
-
background: #ff5425;
|
538 |
-
}
|
539 |
.single-lp_course .learn-press-course-results-progress:after {
|
540 |
display: block;
|
541 |
content: '';
|
@@ -901,7 +839,7 @@ body.course-has-popup {
|
|
901 |
height: 43px;
|
902 |
line-height: 43px;
|
903 |
background: #F5F5F5;
|
904 |
-
margin
|
905 |
border: 1px solid #DDD;
|
906 |
outline: none;
|
907 |
}
|
@@ -1024,9 +962,6 @@ body.block-content #learn-press-block-content {
|
|
1024 |
padding: 0;
|
1025 |
margin-left: 0;
|
1026 |
}
|
1027 |
-
.quiz-intro li label {
|
1028 |
-
display: inline-block;
|
1029 |
-
}
|
1030 |
.quiz-questions-list {
|
1031 |
margin: 0 0 20px 0;
|
1032 |
padding: 0;
|
@@ -2619,7 +2554,7 @@ body.content-item-only #learn-press-content-item.expand {
|
|
2619 |
.course-item-navigation {
|
2620 |
border-top: 4px solid #333;
|
2621 |
padding-top: 10px;
|
2622 |
-
margin-
|
2623 |
}
|
2624 |
.course-item-navigation .nav-links .nav-link {
|
2625 |
opacity: 1;
|
277 |
#learn-press-course-curriculum .course-item .lp-icon {
|
278 |
display: none;
|
279 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
280 |
#learn-press-course-curriculum .course-item.viewable {
|
281 |
cursor: pointer;
|
282 |
}
|
308 |
height: 100%;
|
309 |
content: '';
|
310 |
}
|
311 |
+
#learn-press-course-curriculum .course-item.item-has-status .item-status {
|
312 |
+
display: inline-block;
|
313 |
+
background: #d6d6d6;
|
314 |
+
margin-left: 5px;
|
315 |
+
}
|
316 |
+
#learn-press-course-curriculum .course-item.item-has-status .item-status:before {
|
317 |
+
content: '\ea10';
|
318 |
+
color: #FFF;
|
319 |
+
}
|
320 |
+
#learn-press-course-curriculum .course-item.item-has-status.item-completed .item-status-completed,
|
321 |
+
#learn-press-course-curriculum .course-item.item-has-status.item-completed .item-status-passed {
|
322 |
+
background: #95e6f9;
|
323 |
+
}
|
324 |
+
#learn-press-course-curriculum .course-item.item-has-status.item-completed .item-status-failed {
|
325 |
+
background: #ff5425;
|
326 |
+
}
|
327 |
+
#learn-press-course-curriculum .course-item.item-has-status.item-completed .item-status-failed:before {
|
328 |
+
content: '\f335';
|
329 |
+
font-family: Dashicons;
|
330 |
+
font-size: 24px;
|
331 |
+
}
|
332 |
#learn-press-course-curriculum .course-item.focus {
|
333 |
background: #ffb710;
|
334 |
}
|
353 |
float: right;
|
354 |
margin-top: 5px;
|
355 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
356 |
.lp-icon {
|
357 |
display: inline-block;
|
358 |
font-family: 'lp-icons';
|
474 |
.single-lp_course .learn-press-course-results-progress .percentage-sign {
|
475 |
margin-left: 5px;
|
476 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
477 |
.single-lp_course .learn-press-course-results-progress:after {
|
478 |
display: block;
|
479 |
content: '';
|
839 |
height: 43px;
|
840 |
line-height: 43px;
|
841 |
background: #F5F5F5;
|
842 |
+
margin: 0 10px;
|
843 |
border: 1px solid #DDD;
|
844 |
outline: none;
|
845 |
}
|
962 |
padding: 0;
|
963 |
margin-left: 0;
|
964 |
}
|
|
|
|
|
|
|
965 |
.quiz-questions-list {
|
966 |
margin: 0 0 20px 0;
|
967 |
padding: 0;
|
2554 |
.course-item-navigation {
|
2555 |
border-top: 4px solid #333;
|
2556 |
padding-top: 10px;
|
2557 |
+
margin-bottom: 20px;
|
2558 |
}
|
2559 |
.course-item-navigation .nav-links .nav-link {
|
2560 |
opacity: 1;
|
assets/css/learnpress.less
CHANGED
@@ -430,59 +430,6 @@
|
|
430 |
.lp-icon {
|
431 |
display: none;
|
432 |
}
|
433 |
-
.item-status {
|
434 |
-
display: none;
|
435 |
-
font-family: dashicons;
|
436 |
-
.border-radius(4px);
|
437 |
-
background: #DDD;
|
438 |
-
color: #22b4ff;
|
439 |
-
font-size: 18px;
|
440 |
-
&:before {
|
441 |
-
content: "\f177";
|
442 |
-
}
|
443 |
-
&.item-status-viewed {
|
444 |
-
|
445 |
-
}
|
446 |
-
&.item-status-started {
|
447 |
-
&:before {
|
448 |
-
content: "\f469";
|
449 |
-
}
|
450 |
-
}
|
451 |
-
&.item-status-completed {
|
452 |
-
background: #22b4ff;
|
453 |
-
color: #FFF;
|
454 |
-
&:before {
|
455 |
-
content: "\f147";
|
456 |
-
}
|
457 |
-
}
|
458 |
-
&.item-status-passed {
|
459 |
-
background: #22b4ff;
|
460 |
-
color: #FFF;
|
461 |
-
&:before {
|
462 |
-
content: "\f147";
|
463 |
-
}
|
464 |
-
}
|
465 |
-
&.item-status-failed {
|
466 |
-
background: #cc540d;
|
467 |
-
color: #FFF;
|
468 |
-
&:before {
|
469 |
-
content: "\f335";
|
470 |
-
}
|
471 |
-
}
|
472 |
-
}
|
473 |
-
.item-result {
|
474 |
-
display: none;
|
475 |
-
}
|
476 |
-
&.item-has-status {
|
477 |
-
.item-status {
|
478 |
-
display: inline-block;
|
479 |
-
}
|
480 |
-
}
|
481 |
-
&.item-has-result {
|
482 |
-
.item-result {
|
483 |
-
display: inline-block;
|
484 |
-
}
|
485 |
-
}
|
486 |
&.viewable {
|
487 |
cursor: pointer;
|
488 |
&:hover {
|
@@ -517,7 +464,29 @@
|
|
517 |
content: '';
|
518 |
}
|
519 |
}
|
520 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
521 |
&.focus {
|
522 |
background: #ffb710;
|
523 |
&.off {
|
@@ -538,15 +507,6 @@
|
|
538 |
right: 15px;
|
539 |
float: right;
|
540 |
margin-top: 5px;
|
541 |
-
.item-loop-meta-text {
|
542 |
-
font-size: small;
|
543 |
-
&.item-final {
|
544 |
-
color: #ffffff;
|
545 |
-
background: #cc540d;
|
546 |
-
padding: 3px 8px;
|
547 |
-
.border-radius(3px);
|
548 |
-
}
|
549 |
-
}
|
550 |
}
|
551 |
}
|
552 |
|
@@ -644,24 +604,6 @@
|
|
644 |
.percentage-sign {
|
645 |
margin-left: 5px;
|
646 |
}
|
647 |
-
.grade {
|
648 |
-
font-size: 12px;
|
649 |
-
font-weight: bold;
|
650 |
-
background: #F5F5F5;
|
651 |
-
padding: 2px 7px;
|
652 |
-
.border-radius(3px);
|
653 |
-
&.in-progress {
|
654 |
-
|
655 |
-
}
|
656 |
-
&.passed {
|
657 |
-
color: #ffffff;
|
658 |
-
background: #95e6f9;
|
659 |
-
}
|
660 |
-
&.failed {
|
661 |
-
color: #ffffff;
|
662 |
-
background: #ff5425;
|
663 |
-
}
|
664 |
-
}
|
665 |
&:after {
|
666 |
display: block;
|
667 |
content: '';
|
@@ -1059,7 +1001,7 @@ body.course-has-popup {
|
|
1059 |
height: 43px;
|
1060 |
line-height: 43px;
|
1061 |
background: #F5F5F5;
|
1062 |
-
margin
|
1063 |
border: 1px solid #DDD;
|
1064 |
outline: none;
|
1065 |
}
|
@@ -1154,9 +1096,6 @@ body.block-content {
|
|
1154 |
list-style: none;
|
1155 |
padding: 0;
|
1156 |
margin-left: 0;
|
1157 |
-
li label {
|
1158 |
-
display: inline-block;
|
1159 |
-
}
|
1160 |
}
|
1161 |
|
1162 |
.quiz-questions-list {
|
@@ -2212,12 +2151,12 @@ body.content-item-only {
|
|
2212 |
}
|
2213 |
}
|
2214 |
|
2215 |
-
.edit-course-item-link
|
2216 |
-
a
|
2217 |
font-size: 14px;
|
2218 |
position: relative;
|
2219 |
padding-left: 25px;
|
2220 |
-
&:after
|
2221 |
content: "\f464";
|
2222 |
font-family: Dashicons;
|
2223 |
font-size: 26px;
|
@@ -2229,34 +2168,34 @@ body.content-item-only {
|
|
2229 |
}
|
2230 |
}
|
2231 |
|
2232 |
-
.course-item-navigation
|
2233 |
border-top: 4px solid #333;
|
2234 |
padding-top: 10px;
|
2235 |
-
margin-
|
2236 |
-
.nav-links
|
2237 |
-
.nav-link
|
2238 |
opacity: 1;
|
2239 |
-
a
|
2240 |
opacity: 1;
|
2241 |
-
.meta-nav
|
2242 |
display: block;
|
2243 |
text-transform: uppercase;
|
2244 |
font-size: small;
|
2245 |
color: #b9b9b9;
|
2246 |
}
|
2247 |
-
.post-title
|
2248 |
opacity: 1;
|
2249 |
}
|
2250 |
}
|
2251 |
-
&.nav-previous
|
2252 |
float: left;
|
2253 |
}
|
2254 |
-
&.nav-next
|
2255 |
float: right;
|
2256 |
text-align: right;
|
2257 |
}
|
2258 |
}
|
2259 |
-
&:after
|
2260 |
clear: both;
|
2261 |
display: block;
|
2262 |
content: '';
|
430 |
.lp-icon {
|
431 |
display: none;
|
432 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
433 |
&.viewable {
|
434 |
cursor: pointer;
|
435 |
&:hover {
|
464 |
content: '';
|
465 |
}
|
466 |
}
|
467 |
+
&.item-has-status .item-status {
|
468 |
+
display: inline-block;
|
469 |
+
background: #d6d6d6;
|
470 |
+
margin-left: 5px;
|
471 |
+
&:before {
|
472 |
+
content: '\ea10';
|
473 |
+
color: #FFF;
|
474 |
+
}
|
475 |
+
}
|
476 |
+
&.item-has-status.item-completed {
|
477 |
+
.item-status-completed,
|
478 |
+
.item-status-passed {
|
479 |
+
background: #95e6f9;
|
480 |
+
}
|
481 |
+
.item-status-failed {
|
482 |
+
background: #ff5425;
|
483 |
+
&:before {
|
484 |
+
content: '\f335';
|
485 |
+
font-family: Dashicons;
|
486 |
+
font-size: 24px;
|
487 |
+
}
|
488 |
+
}
|
489 |
+
}
|
490 |
&.focus {
|
491 |
background: #ffb710;
|
492 |
&.off {
|
507 |
right: 15px;
|
508 |
float: right;
|
509 |
margin-top: 5px;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
510 |
}
|
511 |
}
|
512 |
|
604 |
.percentage-sign {
|
605 |
margin-left: 5px;
|
606 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
607 |
&:after {
|
608 |
display: block;
|
609 |
content: '';
|
1001 |
height: 43px;
|
1002 |
line-height: 43px;
|
1003 |
background: #F5F5F5;
|
1004 |
+
margin: 0 10px;
|
1005 |
border: 1px solid #DDD;
|
1006 |
outline: none;
|
1007 |
}
|
1096 |
list-style: none;
|
1097 |
padding: 0;
|
1098 |
margin-left: 0;
|
|
|
|
|
|
|
1099 |
}
|
1100 |
|
1101 |
.quiz-questions-list {
|
2151 |
}
|
2152 |
}
|
2153 |
|
2154 |
+
.edit-course-item-link{
|
2155 |
+
a{
|
2156 |
font-size: 14px;
|
2157 |
position: relative;
|
2158 |
padding-left: 25px;
|
2159 |
+
&:after{
|
2160 |
content: "\f464";
|
2161 |
font-family: Dashicons;
|
2162 |
font-size: 26px;
|
2168 |
}
|
2169 |
}
|
2170 |
|
2171 |
+
.course-item-navigation{
|
2172 |
border-top: 4px solid #333;
|
2173 |
padding-top: 10px;
|
2174 |
+
margin-bottom: 20px;
|
2175 |
+
.nav-links{
|
2176 |
+
.nav-link{
|
2177 |
opacity: 1;
|
2178 |
+
a{
|
2179 |
opacity: 1;
|
2180 |
+
.meta-nav{
|
2181 |
display: block;
|
2182 |
text-transform: uppercase;
|
2183 |
font-size: small;
|
2184 |
color: #b9b9b9;
|
2185 |
}
|
2186 |
+
.post-title{
|
2187 |
opacity: 1;
|
2188 |
}
|
2189 |
}
|
2190 |
+
&.nav-previous{
|
2191 |
float: left;
|
2192 |
}
|
2193 |
+
&.nav-next{
|
2194 |
float: right;
|
2195 |
text-align: right;
|
2196 |
}
|
2197 |
}
|
2198 |
+
&:after{
|
2199 |
clear: both;
|
2200 |
display: block;
|
2201 |
content: '';
|
assets/js/admin/admin.js
CHANGED
@@ -655,7 +655,7 @@ lprHook.addAction('lpr_admin_quiz_question_html', _lprAdminQuestionHTML);
|
|
655 |
parse_json : function (response) {
|
656 |
if (typeof reposnse == 'object') return response;
|
657 |
try {
|
658 |
-
var m = response.match(
|
659 |
|
660 |
if (m && m[1]) {
|
661 |
response = JSON.parse(m[1])
|
655 |
parse_json : function (response) {
|
656 |
if (typeof reposnse == 'object') return response;
|
657 |
try {
|
658 |
+
var m = response.match(/<!-- LP_AJAX_START -->(.*)<!-- LP_AJAX_END -->/)
|
659 |
|
660 |
if (m && m[1]) {
|
661 |
response = JSON.parse(m[1])
|
assets/js/admin/meta-box-course.js
CHANGED
@@ -45,8 +45,7 @@
|
|
45 |
'click .learn-press-dropdown-item-types > li a' : '_changeItemType',
|
46 |
'change .lp-item-name ' : '_updateItem',
|
47 |
'focus .lp-item-name' : '_focusItem',
|
48 |
-
'blur .lp-item-name' : '_blurItem'
|
49 |
-
'click #learn-press-toggle-course-results' : '_toggleCourseResults'
|
50 |
},
|
51 |
removeSectionIds : [],
|
52 |
removeItemIds : [],
|
@@ -67,13 +66,6 @@
|
|
67 |
$('#course_curriculum.postbox').removeClass('closed');
|
68 |
|
69 |
},
|
70 |
-
_toggleCourseResults : function (e) {
|
71 |
-
e.preventDefault();
|
72 |
-
var $a = $(e.target),
|
73 |
-
click = $a.data('click');
|
74 |
-
$a.html($a.data(click));
|
75 |
-
$a.attr('data-click', click == 'advanced' ? 'basic' : 'advanced');
|
76 |
-
},
|
77 |
_focusItem : function (e) {
|
78 |
$(e.target).closest('tr').removeClass('focus');
|
79 |
},
|
@@ -1442,22 +1434,6 @@
|
|
1442 |
});
|
1443 |
});
|
1444 |
|
1445 |
-
function _toggleCourseResults(click) {
|
1446 |
-
|
1447 |
-
}
|
1448 |
-
|
1449 |
-
$(document).on('click.learn-press-toggle-course-results', '#learn-press-toggle-course-results a', function (e) {
|
1450 |
-
e.preventDefault();
|
1451 |
-
var $a = $(this),
|
1452 |
-
click = $a.data('click');
|
1453 |
-
$a.html($a.data(click));
|
1454 |
-
$a.data('click', click == 'advanced' ? 'basic' : 'advanced');
|
1455 |
-
$a.closest('.rwmb-input').children('label:gt(1)').toggle(click != 'advanced');
|
1456 |
-
$a.parent().remove();
|
1457 |
-
});
|
1458 |
-
if ($.inArray($('input[name="_lp_course_result"]:checked').val(), ['', 'evaluate_lesson', 'evaluate_final_quiz']) != -1) {
|
1459 |
-
$('#learn-press-toggle-course-results').closest('.rwmb-input').children('label:gt(1)').hide();
|
1460 |
-
}
|
1461 |
|
1462 |
function canSubmit() {
|
1463 |
if ((opts.current_user_type == 'admin') || !opts.required_review || (opts.course_status == 'publish' && opts.enable_edit_published)) {
|
45 |
'click .learn-press-dropdown-item-types > li a' : '_changeItemType',
|
46 |
'change .lp-item-name ' : '_updateItem',
|
47 |
'focus .lp-item-name' : '_focusItem',
|
48 |
+
'blur .lp-item-name' : '_blurItem'
|
|
|
49 |
},
|
50 |
removeSectionIds : [],
|
51 |
removeItemIds : [],
|
66 |
$('#course_curriculum.postbox').removeClass('closed');
|
67 |
|
68 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
69 |
_focusItem : function (e) {
|
70 |
$(e.target).closest('tr').removeClass('focus');
|
71 |
},
|
1434 |
});
|
1435 |
});
|
1436 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1437 |
|
1438 |
function canSubmit() {
|
1439 |
if ((opts.current_user_type == 'admin') || !opts.required_review || (opts.course_status == 'publish' && opts.enable_edit_published)) {
|
assets/js/admin/meta-box-quiz.js
CHANGED
@@ -283,18 +283,6 @@
|
|
283 |
}
|
284 |
$el.find('span').html(t);
|
285 |
}).filter(':checked').trigger('change');
|
286 |
-
|
287 |
-
$('input[name="_lp_show_hide_question"]').change(function () {
|
288 |
-
var t = $('input[name="_lp_show_hide_question"]:checked').val(),
|
289 |
-
$el = $('label[for="_lp_show_result"]'),
|
290 |
-
passing_grade = $('input[name="_lp_show_result"]');
|
291 |
-
if( t === 'show' ){
|
292 |
-
$el.closest('.rwmb-field').show();
|
293 |
-
} else {
|
294 |
-
$el.closest('.rwmb-field').hide();
|
295 |
-
}
|
296 |
-
$el.find('span').html(t);
|
297 |
-
}).filter(':checked').trigger('change');
|
298 |
});
|
299 |
|
300 |
return;
|
@@ -327,4 +315,4 @@
|
|
327 |
|
328 |
$doc.ready(_ready);
|
329 |
|
330 |
-
})(jQuery)
|
283 |
}
|
284 |
$el.find('span').html(t);
|
285 |
}).filter(':checked').trigger('change');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
286 |
});
|
287 |
|
288 |
return;
|
315 |
|
316 |
$doc.ready(_ready);
|
317 |
|
318 |
+
})(jQuery)
|
assets/js/frontend/learnpress.js
CHANGED
@@ -22,7 +22,7 @@
|
|
22 |
window.location.href = url;
|
23 |
},
|
24 |
parseJSON : function (data) {
|
25 |
-
var m = data.match(
|
26 |
try {
|
27 |
if (m) {
|
28 |
data = $.parseJSON(m[1]);
|
@@ -30,6 +30,7 @@
|
|
30 |
data = $.parseJSON(data);
|
31 |
}
|
32 |
} catch (e) {
|
|
|
33 |
data = {};
|
34 |
}
|
35 |
return data;
|
22 |
window.location.href = url;
|
23 |
},
|
24 |
parseJSON : function (data) {
|
25 |
+
var m = data.match(/<!-- LP_AJAX_START -->(.*)<!-- LP_AJAX_END -->/);
|
26 |
try {
|
27 |
if (m) {
|
28 |
data = $.parseJSON(m[1]);
|
30 |
data = $.parseJSON(data);
|
31 |
}
|
32 |
} catch (e) {
|
33 |
+
LP.log(e);
|
34 |
data = {};
|
35 |
}
|
36 |
return data;
|
assets/js/frontend/lesson.js
CHANGED
@@ -42,7 +42,7 @@
|
|
42 |
security = $button.data('security'),
|
43 |
$item = $button.closest('.course-item');
|
44 |
windowTarget.LP.blockContent();
|
45 |
-
|
46 |
this.complete({
|
47 |
security : security,
|
48 |
course_id : this.model.get('courseId'),
|
@@ -55,7 +55,10 @@
|
|
55 |
item.$el.removeClass('focus off');
|
56 |
}, 3000, item);
|
57 |
|
58 |
-
|
|
|
|
|
|
|
59 |
windowTarget.LP.setUrl(that.model.get('permalink'));
|
60 |
var data = response.course_result;
|
61 |
data.messageType = 'update-course';
|
@@ -63,7 +66,7 @@
|
|
63 |
}
|
64 |
windowTarget.LP.unblockContent();
|
65 |
}
|
66 |
-
})
|
67 |
},
|
68 |
complete : function (args) {
|
69 |
var that = this;
|
42 |
security = $button.data('security'),
|
43 |
$item = $button.closest('.course-item');
|
44 |
windowTarget.LP.blockContent();
|
45 |
+
return;
|
46 |
this.complete({
|
47 |
security : security,
|
48 |
course_id : this.model.get('courseId'),
|
55 |
item.$el.removeClass('focus off');
|
56 |
}, 3000, item);
|
57 |
|
58 |
+
/*that.$('.learn-press-course-results-progress').replaceWith($(response.html.progress));
|
59 |
+
$section.find('.section-header').replaceWith($(response.html.section_header));
|
60 |
+
that.$('.learn-press-course-buttons').replaceWith($(response.html.buttons));
|
61 |
+
that.currentItem.set('content', $(response.html.content))*/
|
62 |
windowTarget.LP.setUrl(that.model.get('permalink'));
|
63 |
var data = response.course_result;
|
64 |
data.messageType = 'update-course';
|
66 |
}
|
67 |
windowTarget.LP.unblockContent();
|
68 |
}
|
69 |
+
});
|
70 |
},
|
71 |
complete : function (args) {
|
72 |
var that = this;
|
assets/js/frontend/single-course.js
CHANGED
@@ -44,13 +44,6 @@ if (typeof LearnPress === 'undefined') {
|
|
44 |
},
|
45 |
_changeCurrent : function (m) {
|
46 |
|
47 |
-
},
|
48 |
-
get : function () {
|
49 |
-
var val = Course_Item.__super__.get.apply(this, arguments);
|
50 |
-
if (arguments[0] == 'url') {
|
51 |
-
val = LP_Course_Params.root_url + val;
|
52 |
-
}
|
53 |
-
return val;
|
54 |
},
|
55 |
request : function (args) {
|
56 |
var that = this;
|
@@ -301,43 +294,24 @@ if (typeof LearnPress === 'undefined') {
|
|
301 |
sections = {},
|
302 |
$progress = this.$('.course-progress').find('.number, .percentage-sign'),
|
303 |
$itemProgress = this.$('.items-progress').find('.number, .percentage-sign');
|
304 |
-
|
305 |
-
if ($progress.length == 0) {
|
306 |
-
return;
|
307 |
-
}
|
308 |
-
|
309 |
-
$progress[0].childNodes[0].nodeValue = parseInt(data.results);
|
310 |
-
|
311 |
this.$('.course-progress .lp-progress-value').width(parseInt(data.results) + '%');
|
312 |
data.items && data.items.forEach(function (item) {
|
313 |
-
var $item = this.$('.course-item.course-item-' + item.id)
|
314 |
-
$status = $item.find('.item-status'),
|
315 |
-
statusClass = ($status[0].className + '').replace(/(item-status-[^\s]*)/g, '').trim();
|
316 |
if (!sections[item.section_id]) {
|
317 |
sections[item.section_id] = [0, 0];
|
318 |
}
|
319 |
-
if (item.status) {
|
320 |
-
statusClass += ' item-status-' + item.status;
|
321 |
-
}
|
322 |
if (item.status === 'completed') {
|
|
|
323 |
$item.addClass('item-has-status item-completed');
|
|
|
324 |
} else if (item.status) {
|
325 |
$item.addClass('item-has-status').removeClass('item-completed');
|
326 |
} else {
|
327 |
$item.removeClass('item-has-status').removeClass('item-completed');
|
328 |
}
|
329 |
-
|
330 |
if (item.type === 'lp_quiz') {
|
331 |
-
$item.find('.item-result').html(LP.Hook.applyFilters('item_result_text', item.results));
|
332 |
-
}
|
333 |
-
$status[0].className = statusClass;
|
334 |
-
if ($.inArray(item.status, ['completed', 'failed', 'passed']) != -1) {
|
335 |
-
sections[item.section_id][1]++;
|
336 |
-
}
|
337 |
-
if (item.status && item.status != 'viewed') {
|
338 |
-
$item.addClass('item-has-result');
|
339 |
-
} else {
|
340 |
-
$item.removeClass('item-has-result');
|
341 |
}
|
342 |
sections[item.section_id][0]++;
|
343 |
}, this);
|
@@ -348,16 +322,10 @@ if (typeof LearnPress === 'undefined') {
|
|
348 |
if (!data) {
|
349 |
return;
|
350 |
}
|
351 |
-
itemsCompleted += data[1];
|
352 |
$section.find('.section-header span.step').html(LP.Hook.applyFilters('section_header_span_text', data[1] + '/' + data[0]));
|
353 |
});
|
354 |
$itemProgress.eq(0).html(data.completed_items_text.replace('%d', itemsCompleted).replace('%d', itemsCount));
|
355 |
var passingCondition = parseInt(this.$('.course-progress .lp-course-progress').data('passing-condition'));
|
356 |
-
if (data.grade) {
|
357 |
-
var $grade = this.$('.grade').html(data.grade_html),
|
358 |
-
gradeClass = $grade[0].className.replace(/passed|failed|in-progress/, '') + ' ' + data.grade;
|
359 |
-
$grade[0].className = gradeClass;
|
360 |
-
}
|
361 |
this.$('.button-finish-course').toggleClass('hide-if-js', !(data.results >= passingCondition));
|
362 |
|
363 |
if (data.setUrl) {
|
@@ -421,6 +389,7 @@ if (typeof LearnPress === 'undefined') {
|
|
421 |
var that = this,
|
422 |
$target = $(e.target),
|
423 |
id = this._getItemId($target);
|
|
|
424 |
f = f || {force: false};
|
425 |
if (!id || this.itemLoading) {
|
426 |
return;
|
@@ -752,12 +721,12 @@ if (typeof LearnPress === 'undefined') {
|
|
752 |
_loadItem : function (e) {
|
753 |
var $iframe = $('<iframe webkitallowfullscreen mozallowfullscreen allowfullscreen />').src($(e.target).attr('href') + '?content-item-only=yes');
|
754 |
this.$('#popup-content-inner').html($iframe);
|
755 |
-
|
756 |
-
|
757 |
-
|
758 |
-
|
759 |
-
|
760 |
-
|
761 |
},
|
762 |
_ajaxLoadItemSuccess: function (response) {
|
763 |
this.$('#popup-content-inner').html($(response).contents().find('.lp_course'));
|
44 |
},
|
45 |
_changeCurrent : function (m) {
|
46 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
47 |
},
|
48 |
request : function (args) {
|
49 |
var that = this;
|
294 |
sections = {},
|
295 |
$progress = this.$('.course-progress').find('.number, .percentage-sign'),
|
296 |
$itemProgress = this.$('.items-progress').find('.number, .percentage-sign');
|
297 |
+
$progress.eq(0).html(parseInt(data.results));
|
|
|
|
|
|
|
|
|
|
|
|
|
298 |
this.$('.course-progress .lp-progress-value').width(parseInt(data.results) + '%');
|
299 |
data.items && data.items.forEach(function (item) {
|
300 |
+
var $item = this.$('.course-item.course-item-' + item.id);
|
|
|
|
|
301 |
if (!sections[item.section_id]) {
|
302 |
sections[item.section_id] = [0, 0];
|
303 |
}
|
|
|
|
|
|
|
304 |
if (item.status === 'completed') {
|
305 |
+
itemsCompleted++;
|
306 |
$item.addClass('item-has-status item-completed');
|
307 |
+
sections[item.section_id][1]++;
|
308 |
} else if (item.status) {
|
309 |
$item.addClass('item-has-status').removeClass('item-completed');
|
310 |
} else {
|
311 |
$item.removeClass('item-has-status').removeClass('item-completed');
|
312 |
}
|
|
|
313 |
if (item.type === 'lp_quiz') {
|
314 |
+
$item.find('.item-result').html(LP.Hook.applyFilters('item_result_text', item.results + '%'));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
315 |
}
|
316 |
sections[item.section_id][0]++;
|
317 |
}, this);
|
322 |
if (!data) {
|
323 |
return;
|
324 |
}
|
|
|
325 |
$section.find('.section-header span.step').html(LP.Hook.applyFilters('section_header_span_text', data[1] + '/' + data[0]));
|
326 |
});
|
327 |
$itemProgress.eq(0).html(data.completed_items_text.replace('%d', itemsCompleted).replace('%d', itemsCount));
|
328 |
var passingCondition = parseInt(this.$('.course-progress .lp-course-progress').data('passing-condition'));
|
|
|
|
|
|
|
|
|
|
|
329 |
this.$('.button-finish-course').toggleClass('hide-if-js', !(data.results >= passingCondition));
|
330 |
|
331 |
if (data.setUrl) {
|
389 |
var that = this,
|
390 |
$target = $(e.target),
|
391 |
id = this._getItemId($target);
|
392 |
+
console.log(id)
|
393 |
f = f || {force: false};
|
394 |
if (!id || this.itemLoading) {
|
395 |
return;
|
721 |
_loadItem : function (e) {
|
722 |
var $iframe = $('<iframe webkitallowfullscreen mozallowfullscreen allowfullscreen />').src($(e.target).attr('href') + '?content-item-only=yes');
|
723 |
this.$('#popup-content-inner').html($iframe);
|
724 |
+
return '';
|
725 |
+
e.preventDefault();
|
726 |
+
$.ajax({
|
727 |
+
url : $(e.target).attr('href'),
|
728 |
+
success: this._ajaxLoadItemSuccess
|
729 |
+
});
|
730 |
},
|
731 |
_ajaxLoadItemSuccess: function (response) {
|
732 |
this.$('#popup-content-inner').html($(response).contents().find('.lp_course'));
|
assets/js/global.js
CHANGED
@@ -557,14 +557,14 @@ if (typeof window.LP == 'undefined') {
|
|
557 |
},
|
558 |
|
559 |
parseResponse: function (response, type) {
|
560 |
-
var m = response.match(
|
561 |
if (m) {
|
562 |
response = m[1];
|
563 |
}
|
564 |
return (type || "json") == "json" ? this.parseJSON(response) : response;
|
565 |
},
|
566 |
parseJSON : function (data) {
|
567 |
-
var m = data.match(
|
568 |
try {
|
569 |
if (m) {
|
570 |
data = $.parseJSON(m[1]);
|
@@ -572,6 +572,7 @@ if (typeof window.LP == 'undefined') {
|
|
572 |
data = $.parseJSON(data);
|
573 |
}
|
574 |
} catch (e) {
|
|
|
575 |
data = {};
|
576 |
}
|
577 |
return data;
|
557 |
},
|
558 |
|
559 |
parseResponse: function (response, type) {
|
560 |
+
var m = response.match(/<!-- LP_AJAX_START -->(.*)<!-- LP_AJAX_END -->/);
|
561 |
if (m) {
|
562 |
response = m[1];
|
563 |
}
|
564 |
return (type || "json") == "json" ? this.parseJSON(response) : response;
|
565 |
},
|
566 |
parseJSON : function (data) {
|
567 |
+
var m = data.match(/<!-- LP_AJAX_START -->(.*)<!-- LP_AJAX_END -->/);
|
568 |
try {
|
569 |
if (m) {
|
570 |
data = $.parseJSON(m[1]);
|
572 |
data = $.parseJSON(data);
|
573 |
}
|
574 |
} catch (e) {
|
575 |
+
LP.log(e);
|
576 |
data = {};
|
577 |
}
|
578 |
return data;
|
assets/js/global.min.js
CHANGED
@@ -395,7 +395,7 @@ if (typeof window.LP == "undefined") {
|
|
395 |
}
|
396 |
window.location.href = url
|
397 |
}, parseJSON : function (data) {
|
398 |
-
var m = data.match(
|
399 |
try {
|
400 |
if (m) {
|
401 |
data = $.parseJSON(m[1])
|
@@ -408,7 +408,7 @@ if (typeof window.LP == "undefined") {
|
|
408 |
}
|
409 |
return data
|
410 |
}, parseResponse : function (response, type) {
|
411 |
-
var m = response.match(
|
412 |
if (m) {
|
413 |
response = m[1]
|
414 |
}
|
395 |
}
|
396 |
window.location.href = url
|
397 |
}, parseJSON : function (data) {
|
398 |
+
var m = data.match(/<!-- LP_AJAX_START -->(.*)<!-- LP_AJAX_END -->/);
|
399 |
try {
|
400 |
if (m) {
|
401 |
data = $.parseJSON(m[1])
|
408 |
}
|
409 |
return data
|
410 |
}, parseResponse : function (response, type) {
|
411 |
+
var m = response.match(/<!-- LP_AJAX_START -->(.*)<!-- LP_AJAX_END -->/);
|
412 |
if (m) {
|
413 |
response = m[1]
|
414 |
}
|
inc/admin/includes/class-markdown-parse.php
CHANGED
@@ -239,7 +239,7 @@ class Markdown_Parser {
|
|
239 |
var $predef_titles = array();
|
240 |
|
241 |
|
242 |
-
function
|
243 |
#
|
244 |
# Constructor function. Initialize appropriate member variables.
|
245 |
#
|
@@ -1691,7 +1691,7 @@ class MarkdownExtra_Parser extends Markdown_Parser {
|
|
1691 |
var $predef_abbr = array();
|
1692 |
|
1693 |
|
1694 |
-
function
|
1695 |
#
|
1696 |
# Constructor function. Initialize the parser object.
|
1697 |
#
|
@@ -1717,7 +1717,7 @@ class MarkdownExtra_Parser extends Markdown_Parser {
|
|
1717 |
"doAbbreviations" => 70,
|
1718 |
);
|
1719 |
|
1720 |
-
parent::
|
1721 |
}
|
1722 |
|
1723 |
|
@@ -2268,15 +2268,13 @@ class MarkdownExtra_Parser extends Markdown_Parser {
|
|
2268 |
if ($matches[3] == '-' && preg_match('{^- }', $matches[1]))
|
2269 |
return $matches[0];
|
2270 |
$level = $matches[3]{0} == '=' ? 1 : 2;
|
2271 |
-
$id =& $matches[2];
|
2272 |
-
$attr = $this->_doHeaders_attr($id);
|
2273 |
$block = "<h$level$attr>".$this->runSpanGamut($matches[1])."</h$level>";
|
2274 |
return "\n" . $this->hashBlock($block) . "\n\n";
|
2275 |
}
|
2276 |
function _doHeaders_callback_atx($matches) {
|
2277 |
$level = strlen($matches[1]);
|
2278 |
-
$id =& $matches[3];
|
2279 |
-
$attr = $this->_doHeaders_attr($id);
|
2280 |
$block = "<h$level$attr>".$this->runSpanGamut($matches[2])."</h$level>";
|
2281 |
return "\n" . $this->hashBlock($block) . "\n\n";
|
2282 |
}
|
239 |
var $predef_titles = array();
|
240 |
|
241 |
|
242 |
+
function Markdown_Parser() {
|
243 |
#
|
244 |
# Constructor function. Initialize appropriate member variables.
|
245 |
#
|
1691 |
var $predef_abbr = array();
|
1692 |
|
1693 |
|
1694 |
+
function MarkdownExtra_Parser() {
|
1695 |
#
|
1696 |
# Constructor function. Initialize the parser object.
|
1697 |
#
|
1717 |
"doAbbreviations" => 70,
|
1718 |
);
|
1719 |
|
1720 |
+
parent::Markdown_Parser();
|
1721 |
}
|
1722 |
|
1723 |
|
2268 |
if ($matches[3] == '-' && preg_match('{^- }', $matches[1]))
|
2269 |
return $matches[0];
|
2270 |
$level = $matches[3]{0} == '=' ? 1 : 2;
|
2271 |
+
$attr = $this->_doHeaders_attr($id =& $matches[2]);
|
|
|
2272 |
$block = "<h$level$attr>".$this->runSpanGamut($matches[1])."</h$level>";
|
2273 |
return "\n" . $this->hashBlock($block) . "\n\n";
|
2274 |
}
|
2275 |
function _doHeaders_callback_atx($matches) {
|
2276 |
$level = strlen($matches[1]);
|
2277 |
+
$attr = $this->_doHeaders_attr($id =& $matches[3]);
|
|
|
2278 |
$block = "<h$level$attr>".$this->runSpanGamut($matches[2])."</h$level>";
|
2279 |
return "\n" . $this->hashBlock($block) . "\n\n";
|
2280 |
}
|
inc/class-lp-assets.php
CHANGED
@@ -285,7 +285,7 @@ class LP_Assets {
|
|
285 |
$styles->add( 'learn-press-jquery.ui.core', $default_path . 'css/admin/jquery.ui.core' . $suffix . '.css', null, $ver );
|
286 |
$styles->add( 'learn-press-jquery.ui.slider', $default_path . 'css/admin/jquery.ui.slider' . $suffix . '.css', null, $ver );
|
287 |
$styles->add( 'learn-press-mb-course', $default_path . 'css/admin/meta-box-course' . $suffix . '.css', null, $ver );
|
288 |
-
|
289 |
$styles->add( 'learn-press-mb-order', $default_path . 'css/admin/meta-box-order' . $suffix . '.css', null, $ver );
|
290 |
$styles->add( 'learn-press-jalerts', $default_path . 'css/jalert' . $suffix . '.css', null, $ver );
|
291 |
//$styles->add( 'learn-press-statistics-select2', '/' . LP_WP_CONTENT . '/plugins/learnpress/inc/libraries/meta-box/css/select2/select2.css' );
|
285 |
$styles->add( 'learn-press-jquery.ui.core', $default_path . 'css/admin/jquery.ui.core' . $suffix . '.css', null, $ver );
|
286 |
$styles->add( 'learn-press-jquery.ui.slider', $default_path . 'css/admin/jquery.ui.slider' . $suffix . '.css', null, $ver );
|
287 |
$styles->add( 'learn-press-mb-course', $default_path . 'css/admin/meta-box-course' . $suffix . '.css', null, $ver );
|
288 |
+
$styles->add( 'learn-press-mb-question', $default_path . 'css/admin/meta-box-question' . $suffix . '.css', null, $ver );
|
289 |
$styles->add( 'learn-press-mb-order', $default_path . 'css/admin/meta-box-order' . $suffix . '.css', null, $ver );
|
290 |
$styles->add( 'learn-press-jalerts', $default_path . 'css/jalert' . $suffix . '.css', null, $ver );
|
291 |
//$styles->add( 'learn-press-statistics-select2', '/' . LP_WP_CONTENT . '/plugins/learnpress/inc/libraries/meta-box/css/select2/select2.css' );
|
inc/class-lp-cache.php
CHANGED
@@ -118,11 +118,6 @@ class LP_Cache {
|
|
118 |
*/
|
119 |
protected static $_quiz_history = 'user-quiz-history';
|
120 |
|
121 |
-
/**
|
122 |
-
* @var string
|
123 |
-
*/
|
124 |
-
protected static $_quiz_grade = 'quiz-grade';
|
125 |
-
|
126 |
/**
|
127 |
* Set data to cache
|
128 |
*
|
@@ -624,30 +619,6 @@ class LP_Cache {
|
|
624 |
return self::_get_cache( self::$_user_item_id, $key, $def );
|
625 |
}
|
626 |
|
627 |
-
/**
|
628 |
-
* @param bool $key
|
629 |
-
* @param bool $def
|
630 |
-
*
|
631 |
-
* @return array|bool|mixed
|
632 |
-
*/
|
633 |
-
public static function get_quiz_grade( $key = false, $def = false ) {
|
634 |
-
return self::_get_cache( self::$_quiz_grade, $key, $def );
|
635 |
-
}
|
636 |
-
|
637 |
-
/**
|
638 |
-
* @param $key_or_value
|
639 |
-
* @param bool $value
|
640 |
-
*
|
641 |
-
* @return array|bool|mixed
|
642 |
-
*/
|
643 |
-
public static function set_quiz_grade( $key_or_value, $value = false ) {
|
644 |
-
if ( func_num_args() == 1 ) {
|
645 |
-
wp_cache_set( self::$_quiz_grade, $key_or_value, self::$_group );
|
646 |
-
return $key_or_value;
|
647 |
-
}
|
648 |
-
return self::_set_cache( self::$_quiz_grade, $key_or_value, $value );
|
649 |
-
}
|
650 |
-
|
651 |
/**
|
652 |
* Flush cache by sections or LP group
|
653 |
*
|
@@ -679,6 +650,7 @@ class LP_Cache {
|
|
679 |
}
|
680 |
wp_cache_delete( $value, self::$_group );
|
681 |
}
|
|
|
682 |
} catch ( Exception $ex ) {
|
683 |
}
|
684 |
}
|
@@ -723,12 +695,8 @@ class LP_Cache {
|
|
723 |
}
|
724 |
|
725 |
public static function init() {
|
726 |
-
|
727 |
-
self::flush();
|
728 |
-
} catch ( Exception $ex ) {
|
729 |
|
730 |
-
}
|
731 |
-
add_action( 'init', array( __CLASS__, 'redirect' ) );*/
|
732 |
}
|
733 |
|
734 |
public static function redirect() {
|
118 |
*/
|
119 |
protected static $_quiz_history = 'user-quiz-history';
|
120 |
|
|
|
|
|
|
|
|
|
|
|
121 |
/**
|
122 |
* Set data to cache
|
123 |
*
|
619 |
return self::_get_cache( self::$_user_item_id, $key, $def );
|
620 |
}
|
621 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
622 |
/**
|
623 |
* Flush cache by sections or LP group
|
624 |
*
|
650 |
}
|
651 |
wp_cache_delete( $value, self::$_group );
|
652 |
}
|
653 |
+
add_filter( 'wp_redirect', array( __CLASS__, 'cache_flush' ) );
|
654 |
} catch ( Exception $ex ) {
|
655 |
}
|
656 |
}
|
695 |
}
|
696 |
|
697 |
public static function init() {
|
698 |
+
add_action( 'init', array( __CLASS__, 'redirect' ) );
|
|
|
|
|
699 |
|
|
|
|
|
700 |
}
|
701 |
|
702 |
public static function redirect() {
|
inc/class-lp-page-controller.php
CHANGED
@@ -205,12 +205,9 @@ class LP_Page_Controller {
|
|
205 |
if ( LEARNPRESS_IS_COURSES || LEARNPRESS_IS_TAG || LEARNPRESS_IS_CATEGORY || LEARNPRESS_IS_SEARCH || LEARNPRESS_IS_TAX ) {
|
206 |
|
207 |
global $wp_query, $post, $wp;
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
// PHP 7
|
212 |
-
LP()->wp_query = clone $wp_query;
|
213 |
-
}
|
214 |
|
215 |
$template = get_page_template();
|
216 |
/**
|
205 |
if ( LEARNPRESS_IS_COURSES || LEARNPRESS_IS_TAG || LEARNPRESS_IS_CATEGORY || LEARNPRESS_IS_SEARCH || LEARNPRESS_IS_TAX ) {
|
206 |
|
207 |
global $wp_query, $post, $wp;
|
208 |
+
|
209 |
+
LP()->wp_query = clone( $wp_query );
|
210 |
+
|
|
|
|
|
|
|
211 |
|
212 |
$template = get_page_template();
|
213 |
/**
|
inc/class-lp-request-handler.php
CHANGED
@@ -28,31 +28,25 @@ class LP_Request_Handler {
|
|
28 |
* Constructor
|
29 |
*/
|
30 |
public static function init() {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
31 |
if ( is_admin() ) {
|
32 |
add_action( 'init', array( __CLASS__, 'process_request' ), 50 );
|
33 |
} else {
|
34 |
add_action( 'wp', array( __CLASS__, 'process_request' ), 50 );
|
35 |
}
|
36 |
|
37 |
-
add_action( 'get_header', array( __CLASS__, 'clean_cache' ), 1000000 );
|
38 |
-
add_action( 'save_post', array( __CLASS__, 'clean_cache' ), 1000000 );
|
39 |
-
|
40 |
LP_Request_Handler::register( 'purchase-course', 'learn_press_purchase_course_handler', 20 );
|
41 |
LP_Request_Handler::register( 'enroll-course', 'learn_press_purchase_course_handler', 20 );
|
42 |
}
|
43 |
|
44 |
-
public static function clean_cache() {
|
45 |
-
if ( strtolower( $_SERVER['REQUEST_METHOD'] ) == 'post' ) {
|
46 |
-
add_filter( 'wp_redirect', array( __CLASS__, 'redirect' ) );
|
47 |
-
LP_Cache::flush();
|
48 |
-
}
|
49 |
-
}
|
50 |
-
|
51 |
-
public static function redirect( $url ) {
|
52 |
-
remove_filter( 'wp_redirect', array( __CLASS__, 'redirect' ) );
|
53 |
-
return add_query_arg( 'lp-reload', 'yes', $url );
|
54 |
-
}
|
55 |
-
|
56 |
public static function get_header() {
|
57 |
ob_start();
|
58 |
}
|
@@ -61,10 +55,6 @@ class LP_Request_Handler {
|
|
61 |
* Process actions
|
62 |
*/
|
63 |
public static function process_request() {
|
64 |
-
if ( !empty( $_REQUEST['lp-reload'] ) ) {
|
65 |
-
wp_redirect( remove_query_arg( 'lp-reload' ) );
|
66 |
-
exit();
|
67 |
-
}
|
68 |
if ( !empty( $_REQUEST ) ) foreach ( $_REQUEST as $key => $value ) {
|
69 |
do_action( 'learn_press_request_handler_' . $key, $value, $_REQUEST );
|
70 |
}
|
@@ -84,7 +74,7 @@ class LP_Request_Handler {
|
|
84 |
if ( !$item['action'] || !$item['callback'] ) {
|
85 |
continue;
|
86 |
}
|
87 |
-
list( $action, $callback, $priority ) = array_values(
|
88 |
add_action( 'learn_press_request_handler_' . $action, $callback, $priority );
|
89 |
}
|
90 |
} else {
|
28 |
* Constructor
|
29 |
*/
|
30 |
public static function init() {
|
31 |
+
if(strtolower($_SERVER['REQUEST_METHOD']) == 'post'){
|
32 |
+
LP_Cache::flush();
|
33 |
+
//wp_cache_delete( 'course-curriculum', 'learnpress');
|
34 |
+
}
|
35 |
+
//add_action( 'wp_loaded', array( __CLASS__, 'get_header' ), - 1000 );
|
36 |
+
//add_action( 'wp_head', array( __CLASS__, 'process_request' ), 1000 );
|
37 |
+
|
38 |
+
//add_action( 'wp_loaded', array( __CLASS__, 'get_header' ), - 1000 );
|
39 |
+
//add_action( 'admin_head', array( __CLASS__, 'process_request' ), 1000 );
|
40 |
if ( is_admin() ) {
|
41 |
add_action( 'init', array( __CLASS__, 'process_request' ), 50 );
|
42 |
} else {
|
43 |
add_action( 'wp', array( __CLASS__, 'process_request' ), 50 );
|
44 |
}
|
45 |
|
|
|
|
|
|
|
46 |
LP_Request_Handler::register( 'purchase-course', 'learn_press_purchase_course_handler', 20 );
|
47 |
LP_Request_Handler::register( 'enroll-course', 'learn_press_purchase_course_handler', 20 );
|
48 |
}
|
49 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
50 |
public static function get_header() {
|
51 |
ob_start();
|
52 |
}
|
55 |
* Process actions
|
56 |
*/
|
57 |
public static function process_request() {
|
|
|
|
|
|
|
|
|
58 |
if ( !empty( $_REQUEST ) ) foreach ( $_REQUEST as $key => $value ) {
|
59 |
do_action( 'learn_press_request_handler_' . $key, $value, $_REQUEST );
|
60 |
}
|
74 |
if ( !$item['action'] || !$item['callback'] ) {
|
75 |
continue;
|
76 |
}
|
77 |
+
list( $action, $callback, $priority ) = array_values($item);
|
78 |
add_action( 'learn_press_request_handler_' . $action, $callback, $priority );
|
79 |
}
|
80 |
} else {
|
inc/class-lp-shortcodes.php
CHANGED
@@ -70,6 +70,7 @@ class LP_Shortcodes {
|
|
70 |
parse_str( $wp->matched_query, $query );
|
71 |
if ( empty( $query['view'] ) ) {
|
72 |
$redirect = learn_press_user_profile_link( $wp->query_vars['user'] );
|
|
|
73 |
if ( ! empty( $redirect ) ) {
|
74 |
wp_redirect( $redirect );
|
75 |
die();
|
@@ -439,7 +440,26 @@ class LP_Shortcodes {
|
|
439 |
),
|
440 |
$atts
|
441 |
);
|
442 |
-
$fields =
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
443 |
ob_start();
|
444 |
$args = array_merge(
|
445 |
array(
|
@@ -449,7 +469,6 @@ class LP_Shortcodes {
|
|
449 |
),
|
450 |
$atts
|
451 |
);
|
452 |
-
|
453 |
learn_press_get_template( 'global/become-teacher-form.php', $args );
|
454 |
|
455 |
$html = ob_get_clean();
|
70 |
parse_str( $wp->matched_query, $query );
|
71 |
if ( empty( $query['view'] ) ) {
|
72 |
$redirect = learn_press_user_profile_link( $wp->query_vars['user'] );
|
73 |
+
|
74 |
if ( ! empty( $redirect ) ) {
|
75 |
wp_redirect( $redirect );
|
76 |
die();
|
440 |
),
|
441 |
$atts
|
442 |
);
|
443 |
+
$fields = array(
|
444 |
+
'bat_name' => array(
|
445 |
+
'title' => __( 'Name', 'learnpress' ),
|
446 |
+
'type' => 'text',
|
447 |
+
'placeholder' => __( 'Your name', 'learnpress' ),
|
448 |
+
'def' => $user->display_name
|
449 |
+
),
|
450 |
+
'bat_email' => array(
|
451 |
+
'title' => __( 'Email', 'learnpress' ),
|
452 |
+
'type' => 'email',
|
453 |
+
'placeholder' => __( 'Your email address', 'learnpress' ),
|
454 |
+
'def' => $user->user_email
|
455 |
+
),
|
456 |
+
'bat_phone' => array(
|
457 |
+
'title' => __( 'Phone', 'learnpress' ),
|
458 |
+
'type' => 'text',
|
459 |
+
'placeholder' => __( 'Your phone number', 'learnpress' )
|
460 |
+
)
|
461 |
+
);
|
462 |
+
$fields = apply_filters( 'learn_press_become_teacher_form_fields', $fields );
|
463 |
ob_start();
|
464 |
$args = array_merge(
|
465 |
array(
|
469 |
),
|
470 |
$atts
|
471 |
);
|
|
|
472 |
learn_press_get_template( 'global/become-teacher-form.php', $args );
|
473 |
|
474 |
$html = ob_get_clean();
|
inc/course/abstract-lp-course.php
CHANGED
@@ -821,7 +821,7 @@ abstract class LP_Abstract_Course {
|
|
821 |
}
|
822 |
sort( $statuses );
|
823 |
$key = md5( serialize( $statuses ) );
|
824 |
-
if ( !array_key_exists(
|
825 |
$in_clause = join( ',', array_fill( 0, sizeof( $statuses ), '%s' ) );
|
826 |
$query = $wpdb->prepare( "
|
827 |
SELECT count(oim.meta_id)
|
@@ -1093,113 +1093,17 @@ abstract class LP_Abstract_Course {
|
|
1093 |
|
1094 |
$quizzes = $this->get_quizzes();
|
1095 |
|
1096 |
-
if ( (
|
1097 |
//$results = $this->_evaluate_course_by_items( $user_id, $force );
|
1098 |
$results = $this->_evaluate_course_by_lesson( $user_id, $force );
|
1099 |
-
}
|
1100 |
-
|
1101 |
-
|
1102 |
-
$results = $this->_evaluate_course_by_quizzes( $user_id, $force );
|
1103 |
-
} elseif ( 'evaluate_quizzes' === $this->course_result ) {
|
1104 |
-
$results = $this->_evaluate_course_by_quizzes_results( $user_id, $force );
|
1105 |
-
} elseif ( 'evaluate_passed_quizzes' === $this->course_result ) {
|
1106 |
-
$results = $this->_evaluate_course_by_passed_quizzes_results( $user_id, $force );
|
1107 |
-
}
|
1108 |
-
|
1109 |
-
return apply_filters( 'learn_press_evaluation_course_results', $results );
|
1110 |
-
}
|
1111 |
-
|
1112 |
-
/**
|
1113 |
-
* Get achieved point of all quizzes per total points of all quizzes
|
1114 |
-
*
|
1115 |
-
* @param $user_id
|
1116 |
-
* @param bool $force
|
1117 |
-
*
|
1118 |
-
* @return mixed|void
|
1119 |
-
*/
|
1120 |
-
public function _evaluate_course_by_quizzes_results( $user_id, $force = false ) {
|
1121 |
-
$quizzes = $this->get_quizzes();
|
1122 |
-
$user = learn_press_get_user( $user_id );
|
1123 |
-
$results = array();
|
1124 |
-
$achieved_point = 0;
|
1125 |
-
$total_point = 0;
|
1126 |
-
$quizzes_ids = array();
|
1127 |
-
foreach ( $quizzes as $quiz ) {
|
1128 |
-
if ( !$this->enable_evaluate_item( $quiz->ID, $user_id ) ) {
|
1129 |
-
continue;
|
1130 |
-
}
|
1131 |
-
$quizzes_ids[] = $quiz->ID;
|
1132 |
-
$results[$quiz->ID] = $user->get_quiz_results( $quiz->ID, $this->id, true );
|
1133 |
-
if ( $quiz = wp_cache_get( $quiz->ID, 'posts' ) ) {
|
1134 |
-
$total_point += isset( $quiz->mark ) ? absint( $quiz->mark ) : 0;
|
1135 |
-
}
|
1136 |
-
$achieved_point += is_object( $results[$quiz->ID] ) ? $results[$quiz->ID]->mark : 0;
|
1137 |
-
}
|
1138 |
-
$result = ( $achieved_point / $total_point ) * 100;
|
1139 |
-
return apply_filters( 'learn_press_evaluate_course_by_quizzes_results', $result, $this->id, $user_id );
|
1140 |
-
}
|
1141 |
-
|
1142 |
-
public function enable_evaluate_item( $item_id, $user_id = 0 ) {
|
1143 |
-
if ( !$user_id ) {
|
1144 |
-
$user_id = get_current_user_id();
|
1145 |
-
}
|
1146 |
-
return apply_filters( 'learn_press_enable_evaluate_course_item', true, $item_id, $user_id, $this->id );
|
1147 |
-
}
|
1148 |
-
|
1149 |
-
public function _evaluate_course_by_passed_quizzes_results( $user_id, $force = false ) {
|
1150 |
-
$quizzes = $this->get_quizzes();
|
1151 |
-
$user = learn_press_get_user( $user_id );
|
1152 |
-
$results = array();
|
1153 |
-
$achieved_point = 0;
|
1154 |
-
$total_point = 0;
|
1155 |
-
foreach ( $quizzes as $_quiz ) {
|
1156 |
-
if ( !$this->enable_evaluate_item( $_quiz->ID, $user_id ) ) {
|
1157 |
-
continue;
|
1158 |
-
}
|
1159 |
-
$quiz = LP_Quiz::get_quiz( $_quiz->ID );
|
1160 |
-
if ( $_quiz = wp_cache_get( $quiz->id, 'posts' ) ) {
|
1161 |
-
$total_point += isset( $_quiz->mark ) ? absint( $_quiz->mark ) : 0;
|
1162 |
-
}
|
1163 |
-
$grade = $user->get_quiz_graduation( $quiz->id, $this->id );
|
1164 |
-
/*$passing_grade = get_post_meta( $quiz->ID, '_lp_passing_grade', true );
|
1165 |
-
$results[$quiz->ID] = $user->get_quiz_results( $quiz->ID, $this->id, true );
|
1166 |
-
$quiz_passed = false;
|
1167 |
-
$passing_grade_type = get_post_meta( $quiz->ID, '_lp_passing_grade_type', true );
|
1168 |
-
$passing_grade = get_post_meta( $quiz->ID, '_lp_passing_grade', true );
|
1169 |
-
if ( $passing_grade_type = 'percentage' ) {
|
1170 |
-
$quiz_passed = ( $results[$quiz->ID]->correct_percent >= intval( $passing_grade ) );
|
1171 |
-
} elseif ( $passing_grade_type = 'point' ) {
|
1172 |
-
$quiz_passed = ( $results[$quiz->ID]->mark >= intval( $passing_grade ) );
|
1173 |
} else {
|
1174 |
-
$
|
1175 |
-
}*/
|
1176 |
-
if ( $grade == 'passed' ) {
|
1177 |
-
$quiz_results = $user->get_quiz_results( $quiz->ID, $this->id, true );
|
1178 |
-
$achieved_point += is_object( $quiz_results ) ? $quiz_results->mark : 0;
|
1179 |
}
|
1180 |
}
|
1181 |
-
|
1182 |
-
return apply_filters( 'learn_press_evaluate_course_by_passed_quizzes_results', $result, $this->id, $user_id );
|
1183 |
-
}
|
1184 |
-
|
1185 |
-
public function _get_total_question( $quizzes_ids = array() ) {
|
1186 |
-
global $wpdb;
|
1187 |
-
if ( !empty( $quizzes_ids ) ) {
|
1188 |
-
$format = array_fill( 0, sizeof( $quizzes_ids ), '%d' );
|
1189 |
-
$args = array_merge( $quizzes_ids, array( 'publish', LP_QUESTION_CPT ) );
|
1190 |
-
echo $sql = $wpdb->prepare( "
|
1191 |
-
SELECT COUNT(*)
|
1192 |
-
FROM {$wpdb->prefix}learnpress_quiz_questions lqq
|
1193 |
-
INNER JOIN {$wpdb->posts} p ON lqq.question_id = p.ID
|
1194 |
-
WHERE
|
1195 |
-
quiz_id IN (" . join( ',', $format ) . ")
|
1196 |
-
AND p.post_status = %s
|
1197 |
-
AND p.post_type = %s",
|
1198 |
-
$args
|
1199 |
-
);
|
1200 |
-
return $wpdb->get_var( $sql );
|
1201 |
-
}
|
1202 |
-
return 0;
|
1203 |
}
|
1204 |
|
1205 |
public function is_evaluation( $thing ) {
|
@@ -1268,13 +1172,14 @@ abstract class LP_Abstract_Course {
|
|
1268 |
/**
|
1269 |
* Get number of lessons user has completed
|
1270 |
*
|
1271 |
-
* @param
|
1272 |
-
* @param
|
1273 |
-
* @param
|
1274 |
*
|
1275 |
* @return int|mixed|null|void
|
1276 |
*/
|
1277 |
public function get_completed_items( $user_id = 0, $force = false, $type = '' ) {
|
|
|
1278 |
if ( !$user_id ) {
|
1279 |
$user_id = get_current_user_id();
|
1280 |
}
|
@@ -1290,9 +1195,7 @@ abstract class LP_Abstract_Course {
|
|
1290 |
}
|
1291 |
$k = sprintf( '%d-%d-%d', $user_id, $this->id, $item_id );
|
1292 |
if ( !empty( $item_statuses[$k] ) && $item_statuses[$k] == 'completed' ) {
|
1293 |
-
|
1294 |
-
$completed_items[] = $item_id;
|
1295 |
-
}
|
1296 |
}
|
1297 |
}
|
1298 |
}
|
@@ -1315,17 +1218,6 @@ abstract class LP_Abstract_Course {
|
|
1315 |
return apply_filters( 'learn_press_count_user_completed_items', $count, $this->id, $user_id );
|
1316 |
}
|
1317 |
|
1318 |
-
/**
|
1319 |
-
* Check a quiz is a final quiz in this course
|
1320 |
-
*
|
1321 |
-
* @param $quiz_id
|
1322 |
-
*
|
1323 |
-
* @return mixed|void
|
1324 |
-
*/
|
1325 |
-
public function is_final_quiz( $quiz_id ) {
|
1326 |
-
return apply_filters( 'learn_press_is_final_quiz', $this->final_quiz == $quiz_id, $quiz_id, $this->id );
|
1327 |
-
}
|
1328 |
-
|
1329 |
/**
|
1330 |
* Calculate results of course by final quiz
|
1331 |
*
|
@@ -1342,6 +1234,7 @@ abstract class LP_Abstract_Course {
|
|
1342 |
|
1343 |
public function evaluate_quiz( $quiz_id, $user_id, $force = false ) {
|
1344 |
$user = learn_press_get_user( $user_id );
|
|
|
1345 |
$results = $user->get_quiz_results( $quiz_id, $this->id );
|
1346 |
if ( !$results ) {
|
1347 |
$result = 0;
|
@@ -1368,17 +1261,10 @@ abstract class LP_Abstract_Course {
|
|
1368 |
$quizzes = $this->get_quizzes();
|
1369 |
$result = 0;
|
1370 |
if ( $quizzes ) {
|
1371 |
-
$count = 0;
|
1372 |
foreach ( $quizzes as $quiz ) {
|
1373 |
-
if ( !$this->enable_evaluate_item( $quiz->ID, $user_id ) ) {
|
1374 |
-
continue;
|
1375 |
-
}
|
1376 |
$result += $this->evaluate_quiz( $quiz->ID, $user_id, $force );
|
1377 |
-
$count ++;
|
1378 |
-
}
|
1379 |
-
if ( $count ) {
|
1380 |
-
$result = round( $result / $count );
|
1381 |
}
|
|
|
1382 |
}
|
1383 |
return apply_filters( 'learn_press_evaluation_course_quizzes', $result, $this->id, $user_id );
|
1384 |
}
|
@@ -1494,20 +1380,15 @@ abstract class LP_Abstract_Course {
|
|
1494 |
* @return mixed
|
1495 |
*/
|
1496 |
public function output_args( $args = null ) {
|
1497 |
-
|
1498 |
-
$
|
1499 |
-
|
1500 |
-
$
|
1501 |
-
|
1502 |
-
unset( $course_info['items'] );
|
1503 |
-
}
|
1504 |
$output = array(
|
1505 |
-
'root_url' => trailingslashit( get_site_url() ),
|
1506 |
'id' => $this->id,
|
1507 |
'url' => $this->get_permalink(),
|
1508 |
-
'results' => $
|
1509 |
-
'grade' => $course_grade,
|
1510 |
-
'grade_html' => learn_press_course_grade_html( $course_grade, false ),
|
1511 |
'current_item' => $this->is_viewing_item(),
|
1512 |
'items' => $this->get_items_params()
|
1513 |
);
|
@@ -1523,20 +1404,18 @@ abstract class LP_Abstract_Course {
|
|
1523 |
*/
|
1524 |
public function get_items_params( $user_id = null ) {
|
1525 |
global $wpdb;
|
1526 |
-
$user
|
1527 |
-
$items
|
1528 |
array(
|
1529 |
'field' => array( 'item_id', 'item_type', 'post_title', 'section_id' ),
|
1530 |
'field_map' => array( 'id', 'type', 'title' ),
|
1531 |
'field_format' => array( '%d', '%s', '%s', '%d' )
|
1532 |
)
|
1533 |
);
|
1534 |
-
$root_url = trailingslashit( get_site_url() );
|
1535 |
if ( $items ) foreach ( $items as $k => $item ) {
|
1536 |
if ( ( $view = $user->can( 'view-item', $item['id'], $this->id ) ) !== false ) {
|
1537 |
-
$
|
1538 |
-
$items[$k]['
|
1539 |
-
$items[$k]['status'] = ( $status == 'completed' && $item['type'] == LP_QUIZ_CPT ) ? $user->get_quiz_graduation( $item['id'], $this->id ) : $status;
|
1540 |
if ( $view == 'preview' ) {
|
1541 |
|
1542 |
}
|
@@ -1549,14 +1428,6 @@ abstract class LP_Abstract_Course {
|
|
1549 |
return $items;
|
1550 |
}
|
1551 |
|
1552 |
-
/**
|
1553 |
-
* Get external link of "Buy this course" button
|
1554 |
-
*
|
1555 |
-
* @return mixed|void
|
1556 |
-
*/
|
1557 |
-
public function get_external_link() {
|
1558 |
-
return apply_filters( 'learn_press_external_link_buy_course', $this->external_link_buy_course, $this->id );
|
1559 |
-
}
|
1560 |
|
1561 |
public function get_video_embed() {
|
1562 |
$video_id = $this->video_id;
|
@@ -1584,4 +1455,4 @@ abstract class LP_Abstract_Course {
|
|
1584 |
return $embed;
|
1585 |
}
|
1586 |
|
1587 |
-
}
|
821 |
}
|
822 |
sort( $statuses );
|
823 |
$key = md5( serialize( $statuses ) );
|
824 |
+
if ( !array_key_exists($key, $data ) ) {
|
825 |
$in_clause = join( ',', array_fill( 0, sizeof( $statuses ), '%s' ) );
|
826 |
$query = $wpdb->prepare( "
|
827 |
SELECT count(oim.meta_id)
|
1093 |
|
1094 |
$quizzes = $this->get_quizzes();
|
1095 |
|
1096 |
+
if ( ( $this->course_result == 'evaluate_lesson' ) || !$quizzes ) {
|
1097 |
//$results = $this->_evaluate_course_by_items( $user_id, $force );
|
1098 |
$results = $this->_evaluate_course_by_lesson( $user_id, $force );
|
1099 |
+
} else {
|
1100 |
+
if ( $this->course_result == 'evaluate_final_quiz' ) {
|
1101 |
+
$results = $this->_evaluate_course_by_quiz( $user_id, $force );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1102 |
} else {
|
1103 |
+
$results = $this->_evaluate_course_by_quizzes( $user_id, $force );
|
|
|
|
|
|
|
|
|
1104 |
}
|
1105 |
}
|
1106 |
+
return apply_filters( 'learn_press_evaluation_course_results', $results );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1107 |
}
|
1108 |
|
1109 |
public function is_evaluation( $thing ) {
|
1172 |
/**
|
1173 |
* Get number of lessons user has completed
|
1174 |
*
|
1175 |
+
* @param $user_id
|
1176 |
+
* @param array $items
|
1177 |
+
* @param bool $force
|
1178 |
*
|
1179 |
* @return int|mixed|null|void
|
1180 |
*/
|
1181 |
public function get_completed_items( $user_id = 0, $force = false, $type = '' ) {
|
1182 |
+
// public function get_completed_items( $user_id = 0, $items = array(), $force = false, $type='' ) {
|
1183 |
if ( !$user_id ) {
|
1184 |
$user_id = get_current_user_id();
|
1185 |
}
|
1195 |
}
|
1196 |
$k = sprintf( '%d-%d-%d', $user_id, $this->id, $item_id );
|
1197 |
if ( !empty( $item_statuses[$k] ) && $item_statuses[$k] == 'completed' ) {
|
1198 |
+
$completed_items[] = $item_id;
|
|
|
|
|
1199 |
}
|
1200 |
}
|
1201 |
}
|
1218 |
return apply_filters( 'learn_press_count_user_completed_items', $count, $this->id, $user_id );
|
1219 |
}
|
1220 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1221 |
/**
|
1222 |
* Calculate results of course by final quiz
|
1223 |
*
|
1234 |
|
1235 |
public function evaluate_quiz( $quiz_id, $user_id, $force = false ) {
|
1236 |
$user = learn_press_get_user( $user_id );
|
1237 |
+
$quiz = LP_Quiz::get_quiz( $quiz_id );
|
1238 |
$results = $user->get_quiz_results( $quiz_id, $this->id );
|
1239 |
if ( !$results ) {
|
1240 |
$result = 0;
|
1261 |
$quizzes = $this->get_quizzes();
|
1262 |
$result = 0;
|
1263 |
if ( $quizzes ) {
|
|
|
1264 |
foreach ( $quizzes as $quiz ) {
|
|
|
|
|
|
|
1265 |
$result += $this->evaluate_quiz( $quiz->ID, $user_id, $force );
|
|
|
|
|
|
|
|
|
1266 |
}
|
1267 |
+
$result = round( $result / sizeof( $quizzes ) );
|
1268 |
}
|
1269 |
return apply_filters( 'learn_press_evaluation_course_quizzes', $result, $this->id, $user_id );
|
1270 |
}
|
1380 |
* @return mixed
|
1381 |
*/
|
1382 |
public function output_args( $args = null ) {
|
1383 |
+
|
1384 |
+
$args = wp_parse_args( $args, array( 'echo' => true, 'user_id' => get_current_user_id() ) );
|
1385 |
+
|
1386 |
+
$user = learn_press_get_user( $args['user_id'] );
|
1387 |
+
|
|
|
|
|
1388 |
$output = array(
|
|
|
1389 |
'id' => $this->id,
|
1390 |
'url' => $this->get_permalink(),
|
1391 |
+
'results' => $user->get_course_info( $this->id ),// $this->get_course_info( $args['user_id'] ),
|
|
|
|
|
1392 |
'current_item' => $this->is_viewing_item(),
|
1393 |
'items' => $this->get_items_params()
|
1394 |
);
|
1404 |
*/
|
1405 |
public function get_items_params( $user_id = null ) {
|
1406 |
global $wpdb;
|
1407 |
+
$user = learn_press_get_current_user( $user_id );
|
1408 |
+
$items = $this->get_curriculum_items(
|
1409 |
array(
|
1410 |
'field' => array( 'item_id', 'item_type', 'post_title', 'section_id' ),
|
1411 |
'field_map' => array( 'id', 'type', 'title' ),
|
1412 |
'field_format' => array( '%d', '%s', '%s', '%d' )
|
1413 |
)
|
1414 |
);
|
|
|
1415 |
if ( $items ) foreach ( $items as $k => $item ) {
|
1416 |
if ( ( $view = $user->can( 'view-item', $item['id'], $this->id ) ) !== false ) {
|
1417 |
+
$items[$k]['url'] = $this->get_item_link( $item['id'] );
|
1418 |
+
$items[$k]['status'] = $user->get_item_status( $item['id'], $this->id );
|
|
|
1419 |
if ( $view == 'preview' ) {
|
1420 |
|
1421 |
}
|
1428 |
return $items;
|
1429 |
}
|
1430 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1431 |
|
1432 |
public function get_video_embed() {
|
1433 |
$video_id = $this->video_id;
|
1455 |
return $embed;
|
1456 |
}
|
1457 |
|
1458 |
+
}
|
inc/course/lp-course-functions.php
CHANGED
@@ -773,34 +773,3 @@ function learn_press_prepare_archive_courses( $template ) {
|
|
773 |
}
|
774 |
return $template;
|
775 |
}
|
776 |
-
|
777 |
-
function learn_press_course_grade_html( $grade, $echo = true ) {
|
778 |
-
$html = '';
|
779 |
-
switch ( $grade ) {
|
780 |
-
case 'passed':
|
781 |
-
$html = __( 'Passed', 'learnpress' );
|
782 |
-
break;
|
783 |
-
case 'failed':
|
784 |
-
$html = __( 'Failed', 'learnpress' );
|
785 |
-
break;
|
786 |
-
case 'in-progress':
|
787 |
-
$html = __( 'In Progress', 'learnpress' );
|
788 |
-
break;
|
789 |
-
}
|
790 |
-
$html = apply_filters( 'learn_press_course_grade_html', $html, $grade );
|
791 |
-
if ( $echo ) echo $html;
|
792 |
-
return $html;
|
793 |
-
}
|
794 |
-
|
795 |
-
function learn_press_get_course_results_tooltip( $course_id ) {
|
796 |
-
$metabox = LP_Course_Post_Type::assessment_meta_box();
|
797 |
-
$options = $metabox['fields'][0]['options'];
|
798 |
-
$cr = get_post_meta( $course_id, '_lp_course_result', true );
|
799 |
-
$tooltip = !empty( $options[$cr] ) ? $options[$cr] : false;
|
800 |
-
if ( $tooltip ) {
|
801 |
-
if ( preg_match_all( '~<p.*>(.*)<\/p>~im', $tooltip, $matches ) ) {
|
802 |
-
$tooltip = $matches[1][0];
|
803 |
-
}
|
804 |
-
}
|
805 |
-
return $tooltip;
|
806 |
-
}
|
773 |
}
|
774 |
return $template;
|
775 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
inc/custom-post-types/course.php
CHANGED
@@ -571,17 +571,12 @@ if ( !class_exists( 'LP_Course_Post_Type' ) ) {
|
|
571 |
*
|
572 |
* @return mixed|null|void
|
573 |
*/
|
574 |
-
public
|
|
|
575 |
$post_id = learn_press_get_request( 'post' );
|
576 |
$prefix = '_lp_';
|
577 |
-
$
|
578 |
-
$
|
579 |
-
if ( in_array( $course_results, array( '', 'evaluate_lesson', 'evaluate_final_quiz' ) ) ) {
|
580 |
-
$course_result_desc .= sprintf( '<a href="" data-advanced="%2$s" data-basic="%1$s" data-click="basic">%2$s</a>', __( 'Basic Options', 'learnpress' ), __( 'Advanced Options', 'learnpress' ) );
|
581 |
-
}
|
582 |
-
$course_result_desc = "<span id=\"learn-press-toggle-course-results\">{$course_result_desc}</span>";
|
583 |
-
$course_result_desc .= __( 'The method to assess the result of a student for a course.', 'learnpress' );
|
584 |
-
if ( $course_results == 'evaluate_final_quiz' && !get_post_meta( $post_id, '_lp_final_quiz', true ) ) {
|
585 |
$course_result_desc .= __( '<br /><strong>Note! </strong>No final quiz in course, please add a final quiz', 'learnpress' );
|
586 |
}
|
587 |
$meta_box = array(
|
@@ -596,15 +591,11 @@ if ( !class_exists( 'LP_Course_Post_Type' ) ) {
|
|
596 |
'type' => 'radio',
|
597 |
'desc' => $course_result_desc,
|
598 |
'options' => array(
|
599 |
-
'evaluate_lesson'
|
600 |
-
'
|
601 |
-
|
602 |
-
'evaluate_quizzes' => __( 'Evaluate results of quizzes', 'learnpress' ) . sprintf( '<p class="description option-desc">%s</p>', __( 'Evaluate by achieved points per total point of all quizzes.', 'learnpress' ) ),
|
603 |
-
'evaluate_passed_quizzes' => __( 'Evaluate results of quizzes passed', 'learnpress' ) . sprintf( '<p class="description option-desc">%s</p>', __( 'Evaluate by achieved points of passed course per total point of all quizzes.', 'learnpress' ) ),
|
604 |
-
'evaluate_quiz' => __( 'Evaluate quizzes', 'learnpress' ) . sprintf( '<p class="description option-desc">%s</p>', __( 'Evaluate by quizzes user has completed per total quizzes.', 'learnpress' ) ),
|
605 |
),
|
606 |
'std' => 'evaluate_lesson',
|
607 |
-
'inline' => false
|
608 |
),
|
609 |
array(
|
610 |
'name' => __( 'Passing condition value', 'learnpress' ),
|
@@ -763,8 +754,8 @@ if ( !class_exists( 'LP_Course_Post_Type' ) ) {
|
|
763 |
public static function author_meta_box() {
|
764 |
|
765 |
$course_id = !empty( $_GET['post'] ) ? $_GET['post'] : 0;
|
766 |
-
|
767 |
-
$author
|
768 |
|
769 |
$prefix = '_lp_';
|
770 |
|
@@ -965,9 +956,6 @@ if ( !class_exists( 'LP_Course_Post_Type' ) ) {
|
|
965 |
if ( 'dopreview' == $preview && 'draft' == $post->post_status ) {
|
966 |
learn_press_add_message( __( 'Course Curriculum only appear if course is saved', 'learnpress' ), 'error' );
|
967 |
}
|
968 |
-
|
969 |
-
$this->_reset_sections();
|
970 |
-
|
971 |
if ( !empty( $_REQUEST['_lp_curriculum'] ) && 'dopreview' !== $preview ) {
|
972 |
$section_order = 0;
|
973 |
$query_update = array();
|
@@ -1114,10 +1102,8 @@ if ( !class_exists( 'LP_Course_Post_Type' ) ) {
|
|
1114 |
$submit_for_review = false;
|
1115 |
}
|
1116 |
if ( ( $submit_for_review || ( $old_status != $new_status ) ) && $post->post_status != 'auto-draft' ) {
|
1117 |
-
|
1118 |
-
|
1119 |
-
update_post_meta( $post->ID, '_lp_submit_for_reviewer', 'yes' );
|
1120 |
-
}
|
1121 |
}
|
1122 |
}
|
1123 |
$message = learn_press_get_request( 'review-message' );
|
@@ -1228,7 +1214,7 @@ if ( !class_exists( 'LP_Course_Post_Type' ) ) {
|
|
1228 |
private function _update_price() {
|
1229 |
global $wpdb, $post;
|
1230 |
$request = $_POST;
|
1231 |
-
$payment = learn_press_get_request(
|
1232 |
$price = floatval( $request['_lp_price'] );
|
1233 |
$sale_price = $request['_lp_sale_price'];
|
1234 |
$sale_price_start = $request['_lp_sale_start'];
|
571 |
*
|
572 |
* @return mixed|null|void
|
573 |
*/
|
574 |
+
public
|
575 |
+
static function assessment_meta_box() {
|
576 |
$post_id = learn_press_get_request( 'post' );
|
577 |
$prefix = '_lp_';
|
578 |
+
$course_result_desc = __( 'The method to assess the result of a student for a course.', 'learnpress' );
|
579 |
+
if ( $post_id && get_post_meta( $post_id, '_lp_course_result', true ) == 'evaluate_final_quiz' && !get_post_meta( $post_id, '_lp_final_quiz', true ) ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
580 |
$course_result_desc .= __( '<br /><strong>Note! </strong>No final quiz in course, please add a final quiz', 'learnpress' );
|
581 |
}
|
582 |
$meta_box = array(
|
591 |
'type' => 'radio',
|
592 |
'desc' => $course_result_desc,
|
593 |
'options' => array(
|
594 |
+
'evaluate_lesson' => __( 'Evaluate lessons', 'learnpress' ),
|
595 |
+
'evaluate_quizzes' => __( 'Evaluate result of quizzes', 'learnpress' ),
|
596 |
+
'evaluate_final_quiz' => __( 'Evaluate the result of the final quiz', 'learnpress' )
|
|
|
|
|
|
|
597 |
),
|
598 |
'std' => 'evaluate_lesson',
|
|
|
599 |
),
|
600 |
array(
|
601 |
'name' => __( 'Passing condition value', 'learnpress' ),
|
754 |
public static function author_meta_box() {
|
755 |
|
756 |
$course_id = !empty( $_GET['post'] ) ? $_GET['post'] : 0;
|
757 |
+
|
758 |
+
$author = get_post( $course_id ) ? get_post( $course_id )->post_author : '';
|
759 |
|
760 |
$prefix = '_lp_';
|
761 |
|
956 |
if ( 'dopreview' == $preview && 'draft' == $post->post_status ) {
|
957 |
learn_press_add_message( __( 'Course Curriculum only appear if course is saved', 'learnpress' ), 'error' );
|
958 |
}
|
|
|
|
|
|
|
959 |
if ( !empty( $_REQUEST['_lp_curriculum'] ) && 'dopreview' !== $preview ) {
|
960 |
$section_order = 0;
|
961 |
$query_update = array();
|
1102 |
$submit_for_review = false;
|
1103 |
}
|
1104 |
if ( ( $submit_for_review || ( $old_status != $new_status ) ) && $post->post_status != 'auto-draft' ) {
|
1105 |
+
$action = 'for_reviewer';
|
1106 |
+
update_post_meta( $post->ID, '_lp_submit_for_reviewer', 'yes' );
|
|
|
|
|
1107 |
}
|
1108 |
}
|
1109 |
$message = learn_press_get_request( 'review-message' );
|
1214 |
private function _update_price() {
|
1215 |
global $wpdb, $post;
|
1216 |
$request = $_POST;
|
1217 |
+
$payment = learn_press_get_request('_lp_payment') == 1;
|
1218 |
$price = floatval( $request['_lp_price'] );
|
1219 |
$sale_price = $request['_lp_sale_price'];
|
1220 |
$sale_price_start = $request['_lp_sale_start'];
|
inc/custom-post-types/order.php
CHANGED
@@ -29,7 +29,7 @@ if ( !class_exists( 'LP_Order_Post_Type' ) ) {
|
|
29 |
add_action( 'add_meta_boxes', array( $this, 'post_new' ) );
|
30 |
|
31 |
$this
|
32 |
-
->add_map_method( 'before_delete', '
|
33 |
->add_map_method( 'save', 'save_order' );
|
34 |
|
35 |
parent::__construct( $post_type );
|
@@ -54,7 +54,7 @@ if ( !class_exists( 'LP_Order_Post_Type' ) ) {
|
|
54 |
*
|
55 |
* @param $post_id
|
56 |
*/
|
57 |
-
public function
|
58 |
global $wpdb, $post;
|
59 |
if ( get_post_type( $post_id ) != 'lp_order' ) {
|
60 |
return;
|
@@ -83,36 +83,6 @@ if ( !class_exists( 'LP_Order_Post_Type' ) ) {
|
|
83 |
", $post_id );
|
84 |
$wpdb->query( $query );
|
85 |
|
86 |
-
$query = $wpdb->prepare( "
|
87 |
-
SELECT item_id
|
88 |
-
FROM {$wpdb->prefix}learnpress_user_items
|
89 |
-
WHERE ref_id = %d AND user_id = %d AND ref_type = %s
|
90 |
-
", $post_id, $user_id, LP_ORDER_CPT );
|
91 |
-
if ( $course_ids = $wpdb->get_col( $query ) ) {
|
92 |
-
// Delete user course items
|
93 |
-
$query = $wpdb->prepare( "
|
94 |
-
DELETE
|
95 |
-
FROM ui, uim
|
96 |
-
USING {$wpdb->prefix}learnpress_user_items AS ui
|
97 |
-
LEFT JOIN {$wpdb->prefix}learnpress_user_itemmeta AS uim ON ui.user_item_id = uim.learnpress_user_item_id
|
98 |
-
WHERE ref_id = %d AND user_id = %d AND ref_type = %s
|
99 |
-
", $post_id, $user_id, LP_ORDER_CPT );
|
100 |
-
$wpdb->query( $query );
|
101 |
-
|
102 |
-
// Delete other items
|
103 |
-
$format = array_fill( 0, sizeof( $course_ids ), '%d' );
|
104 |
-
$args = array_merge( $course_ids, array( $user_id ) );
|
105 |
-
$query = $wpdb->prepare( "
|
106 |
-
DELETE
|
107 |
-
FROM ui, uim
|
108 |
-
USING {$wpdb->prefix}learnpress_user_items AS ui
|
109 |
-
LEFT JOIN {$wpdb->prefix}learnpress_user_itemmeta AS uim ON ui.user_item_id = uim.learnpress_user_item_id
|
110 |
-
WHERE ref_id IN(" . join( ',', $format ) . ") AND user_id = %d
|
111 |
-
", $args );
|
112 |
-
$wpdb->query( $query );
|
113 |
-
|
114 |
-
}
|
115 |
-
|
116 |
// delete all data related user order
|
117 |
if ( $user_id ) {
|
118 |
learn_press_delete_user_data( $user_id );
|
29 |
add_action( 'add_meta_boxes', array( $this, 'post_new' ) );
|
30 |
|
31 |
$this
|
32 |
+
->add_map_method( 'before_delete', 'delete_order_items' )
|
33 |
->add_map_method( 'save', 'save_order' );
|
34 |
|
35 |
parent::__construct( $post_type );
|
54 |
*
|
55 |
* @param $post_id
|
56 |
*/
|
57 |
+
public function delete_order_items( $post_id ) {
|
58 |
global $wpdb, $post;
|
59 |
if ( get_post_type( $post_id ) != 'lp_order' ) {
|
60 |
return;
|
83 |
", $post_id );
|
84 |
$wpdb->query( $query );
|
85 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
86 |
// delete all data related user order
|
87 |
if ( $user_id ) {
|
88 |
learn_press_delete_user_data( $user_id );
|
inc/custom-post-types/quiz.php
CHANGED
@@ -27,10 +27,6 @@ if ( !class_exists( 'LP_Quiz_Post_Type' ) ) {
|
|
27 |
public function __construct( $post_type, $args = '' ) {
|
28 |
add_action( 'admin_head', array( $this, 'enqueue_script' ) );
|
29 |
$this->add_map_method( 'before_delete', 'delete_quiz_questions' );
|
30 |
-
|
31 |
-
$this
|
32 |
-
->add_map_method( 'save', 'update_quiz', false );
|
33 |
-
|
34 |
add_action( 'init', array( $this, 'init_quiz' ) );
|
35 |
|
36 |
/**
|
@@ -46,9 +42,6 @@ if ( !class_exists( 'LP_Quiz_Post_Type' ) ) {
|
|
46 |
parent::__construct( $post_type, $args );
|
47 |
}
|
48 |
|
49 |
-
public function update_quiz( $post_id ) {
|
50 |
-
}
|
51 |
-
|
52 |
public function init_quiz() {
|
53 |
if ( !empty( $_REQUEST['post'] ) && get_post_type( $_REQUEST['post'] ) == LP_QUIZ_CPT ) {
|
54 |
$q = _learn_press_get_quiz_questions( array( $_REQUEST['post'] ) );
|
@@ -162,18 +155,11 @@ if ( !class_exists( 'LP_Quiz_Post_Type' ) ) {
|
|
162 |
'options' => array(
|
163 |
// Removed from 2.1.4
|
164 |
//'global' => __( wp_kses( 'Global Setting <a target="_blank" href="' . admin_url( 'admin.php?page=learn-press-settings&tab=courses' ) . '">Go to the setting</a>', array( 'a' => array( 'href' => array(), 'target' => array() ) ) ), 'learnpress' ),
|
165 |
-
'show'
|
166 |
-
'hide'
|
167 |
),
|
168 |
'std' => 'hide'
|
169 |
),
|
170 |
-
array(
|
171 |
-
'name' => __( 'Show correct answer', 'learnpress' ),
|
172 |
-
'id' => "{$prefix}show_result",
|
173 |
-
'type' => 'yes_no',
|
174 |
-
'desc' => __( 'Show the correct answer in result of the quiz.', 'learnpress' ),
|
175 |
-
'std' => 'no'
|
176 |
-
),
|
177 |
array(
|
178 |
'name' => __( 'Duration', 'learnpress' ),
|
179 |
'desc' => __( 'Duration of the quiz. Set 0 to disable.', 'learnpress' ),
|
@@ -212,6 +198,13 @@ if ( !class_exists( 'LP_Quiz_Post_Type' ) ) {
|
|
212 |
'min' => 0,
|
213 |
'std' => 0
|
214 |
),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
215 |
array(
|
216 |
'name' => __( 'Show check answer', 'learnpress' ),
|
217 |
'id' => "{$prefix}show_check_answer",
|
@@ -254,7 +247,7 @@ if ( !class_exists( 'LP_Quiz_Post_Type' ) ) {
|
|
254 |
if ( LP_QUIZ_CPT != get_post_type() ) return;
|
255 |
ob_start();
|
256 |
?>
|
257 |
-
|
258 |
var form = $('#post');
|
259 |
|
260 |
form.submit(function (evt) {
|
@@ -267,7 +260,7 @@ if ( !class_exists( 'LP_Quiz_Post_Type' ) ) {
|
|
267 |
is_error = true;
|
268 |
}
|
269 |
|
270 |
-
|
271 |
is_error = form.triggerHandler('learn_press_question_before_update') === false;
|
272 |
|
273 |
if (window.learn_press_before_update_quiz_message.length /*true == is_error*/) {
|
@@ -278,7 +271,7 @@ if ( !class_exists( 'LP_Quiz_Post_Type' ) ) {
|
|
278 |
return false;
|
279 |
}
|
280 |
});
|
281 |
-
|
282 |
<?php
|
283 |
$script = ob_get_clean();
|
284 |
$script = preg_replace( '!</?script>!', '', $script );
|
@@ -286,21 +279,21 @@ if ( !class_exists( 'LP_Quiz_Post_Type' ) ) {
|
|
286 |
|
287 |
ob_start();
|
288 |
?>
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
<?php if ( $questions = learn_press_question_types() ): ?>
|
294 |
<?php foreach ( $questions as $type => $name ): ?>
|
295 |
-
|
296 |
<?php endforeach; ?>
|
297 |
<?php endif; ?>
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
<?php
|
305 |
$js_template = ob_get_clean();
|
306 |
learn_press_enqueue_script( $js_template, true );
|
@@ -541,31 +534,29 @@ if ( !class_exists( 'LP_Quiz_Post_Type' ) ) {
|
|
541 |
}
|
542 |
if ( $current_screen->id === LP_QUIZ_CPT && !learn_press_get_item_course_id( $post->ID, $post->post_type ) ) {
|
543 |
?>
|
544 |
-
|
545 |
-
|
546 |
-
|
547 |
-
|
548 |
-
|
549 |
-
|
550 |
-
|
551 |
-
|
552 |
-
|
553 |
-
|
554 |
-
|
555 |
-
|
556 |
-
|
557 |
-
|
558 |
-
}
|
559 |
-
</style>
|
560 |
<?php
|
561 |
}
|
562 |
}
|
563 |
|
564 |
-
public
|
565 |
|
566 |
-
|
567 |
|
568 |
-
|
569 |
|
570 |
public static function instance() {
|
571 |
if ( !self::$_instance ) {
|
@@ -578,4 +569,4 @@ if ( !class_exists( 'LP_Quiz_Post_Type' ) ) {
|
|
578 |
|
579 |
// end LP_Quiz_Post_Type
|
580 |
$quiz_post_type = LP_Quiz_Post_Type::instance();
|
581 |
-
}
|
27 |
public function __construct( $post_type, $args = '' ) {
|
28 |
add_action( 'admin_head', array( $this, 'enqueue_script' ) );
|
29 |
$this->add_map_method( 'before_delete', 'delete_quiz_questions' );
|
|
|
|
|
|
|
|
|
30 |
add_action( 'init', array( $this, 'init_quiz' ) );
|
31 |
|
32 |
/**
|
42 |
parent::__construct( $post_type, $args );
|
43 |
}
|
44 |
|
|
|
|
|
|
|
45 |
public function init_quiz() {
|
46 |
if ( !empty( $_REQUEST['post'] ) && get_post_type( $_REQUEST['post'] ) == LP_QUIZ_CPT ) {
|
47 |
$q = _learn_press_get_quiz_questions( array( $_REQUEST['post'] ) );
|
155 |
'options' => array(
|
156 |
// Removed from 2.1.4
|
157 |
//'global' => __( wp_kses( 'Global Setting <a target="_blank" href="' . admin_url( 'admin.php?page=learn-press-settings&tab=courses' ) . '">Go to the setting</a>', array( 'a' => array( 'href' => array(), 'target' => array() ) ) ), 'learnpress' ),
|
158 |
+
'show' => __( 'Show', 'learnpress' ),
|
159 |
+
'hide' => __( 'Hide', 'learnpress' )
|
160 |
),
|
161 |
'std' => 'hide'
|
162 |
),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
163 |
array(
|
164 |
'name' => __( 'Duration', 'learnpress' ),
|
165 |
'desc' => __( 'Duration of the quiz. Set 0 to disable.', 'learnpress' ),
|
198 |
'min' => 0,
|
199 |
'std' => 0
|
200 |
),
|
201 |
+
array(
|
202 |
+
'name' => __( 'Show correct answer', 'learnpress' ),
|
203 |
+
'id' => "{$prefix}show_result",
|
204 |
+
'type' => 'yes_no',
|
205 |
+
'desc' => __( 'Show the correct answer in result of the quiz.', 'learnpress' ),
|
206 |
+
'std' => 'no'
|
207 |
+
),
|
208 |
array(
|
209 |
'name' => __( 'Show check answer', 'learnpress' ),
|
210 |
'id' => "{$prefix}show_check_answer",
|
247 |
if ( LP_QUIZ_CPT != get_post_type() ) return;
|
248 |
ob_start();
|
249 |
?>
|
250 |
+
<script>
|
251 |
var form = $('#post');
|
252 |
|
253 |
form.submit(function (evt) {
|
260 |
is_error = true;
|
261 |
}
|
262 |
|
263 |
+
/* hook */
|
264 |
is_error = form.triggerHandler('learn_press_question_before_update') === false;
|
265 |
|
266 |
if (window.learn_press_before_update_quiz_message.length /*true == is_error*/) {
|
271 |
return false;
|
272 |
}
|
273 |
});
|
274 |
+
</script>
|
275 |
<?php
|
276 |
$script = ob_get_clean();
|
277 |
$script = preg_replace( '!</?script>!', '', $script );
|
279 |
|
280 |
ob_start();
|
281 |
?>
|
282 |
+
<script type="text/html" id="tmpl-form-quick-add-question">
|
283 |
+
<div id="lpr-form-quick-add-question" class="lpr-quick-add-form">
|
284 |
+
<input type="text">
|
285 |
+
<select class="lpr-question-types lpr-select2" name="lpr_question[type]" id="lpr-quiz-question-type">
|
286 |
<?php if ( $questions = learn_press_question_types() ): ?>
|
287 |
<?php foreach ( $questions as $type => $name ): ?>
|
288 |
+
<option value="<?php echo $type; ?>"><?php echo $name; ?></option>
|
289 |
<?php endforeach; ?>
|
290 |
<?php endif; ?>
|
291 |
+
</select>
|
292 |
+
<button class="button" data-action="add" type="button"><?php _e( 'Add [Enter]', 'learnpress' ); ?></button>
|
293 |
+
<button data-action="cancel" class="button" type="button"><?php _e( 'Cancel [ESC]', 'learnpress' ); ?></button>
|
294 |
+
<span class="lpr-ajaxload">...</span>
|
295 |
+
</div>
|
296 |
+
</script>
|
297 |
<?php
|
298 |
$js_template = ob_get_clean();
|
299 |
learn_press_enqueue_script( $js_template, true );
|
534 |
}
|
535 |
if ( $current_screen->id === LP_QUIZ_CPT && !learn_press_get_item_course_id( $post->ID, $post->post_type ) ) {
|
536 |
?>
|
537 |
+
<style type="text/css">
|
538 |
+
#wp-admin-bar-view {
|
539 |
+
display: none;
|
540 |
+
}
|
541 |
+
#sample-permalink a {
|
542 |
+
pointer-events: none;
|
543 |
+
cursor: default;
|
544 |
+
text-decoration: none;
|
545 |
+
color: #666;
|
546 |
+
}
|
547 |
+
#preview-action {
|
548 |
+
display: none;
|
549 |
+
}
|
550 |
+
</style>
|
|
|
|
|
551 |
<?php
|
552 |
}
|
553 |
}
|
554 |
|
555 |
+
public function get_sample_permalink_html( $return, $post_id , $new_title, $new_slug, $post ) {
|
556 |
|
557 |
+
return $return;
|
558 |
|
559 |
+
}
|
560 |
|
561 |
public static function instance() {
|
562 |
if ( !self::$_instance ) {
|
569 |
|
570 |
// end LP_Quiz_Post_Type
|
571 |
$quiz_post_type = LP_Quiz_Post_Type::instance();
|
572 |
+
}
|
inc/lesson/lp-lesson-functions.php
CHANGED
@@ -51,15 +51,15 @@ function learn_press_lesson_comment_form( $lesson_id, $course_id, $content_only
|
|
51 |
/**
|
52 |
* Add class css js-action to element comment reply
|
53 |
*/
|
54 |
-
add_filter('comment_reply_link', 'lesson_comment_reply_link', 10, 4);
|
55 |
|
56 |
-
if (!function_exists('lesson_comment_reply_link')) {
|
57 |
|
58 |
-
|
59 |
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
}
|
64 |
|
65 |
/**
|
@@ -73,16 +73,4 @@ if ( !function_exists( 'lesson_cancel_comment_reply_link' ) ) {
|
|
73 |
$formatted_link = str_replace( 'cancel-comment-reply-link"', 'cancel-comment-reply-link" class="js-action"', $formatted_link );
|
74 |
return $formatted_link;
|
75 |
}
|
76 |
-
}
|
77 |
-
|
78 |
-
/**
|
79 |
-
* Remove data section after remove lesson
|
80 |
-
*/
|
81 |
-
add_action( 'delete_post', 'learn_press_lesson_before_delete_post', 10, 2 );
|
82 |
-
function learn_press_lesson_before_delete_post( $post_id, $force=false ) {
|
83 |
-
global $wpdb;
|
84 |
-
if( 'lp_lesson' === get_post_type( $post_id ) ) {
|
85 |
-
$sql = 'DELETE FROM `'.$wpdb->prefix.'learnpress_section_items` WHERE `item_id` = '.$post_id.' AND `item_type` = "lp_lesson"';
|
86 |
-
$wpdb->query($sql);
|
87 |
-
}
|
88 |
-
}
|
51 |
/**
|
52 |
* Add class css js-action to element comment reply
|
53 |
*/
|
54 |
+
add_filter( 'comment_reply_link', 'lesson_comment_reply_link', 10, 4 );
|
55 |
|
56 |
+
if ( !function_exists( 'lesson_comment_reply_link' ) ) {
|
57 |
|
58 |
+
function lesson_comment_reply_link( $link, $args, $comment, $post ) {
|
59 |
|
60 |
+
$link = str_replace( 'comment-reply-link', 'comment-reply-link js-action', $link );
|
61 |
+
return $link;
|
62 |
+
}
|
63 |
}
|
64 |
|
65 |
/**
|
73 |
$formatted_link = str_replace( 'cancel-comment-reply-link"', 'cancel-comment-reply-link" class="js-action"', $formatted_link );
|
74 |
return $formatted_link;
|
75 |
}
|
76 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
inc/libraries/meta-box/inc/fields/datetime.php
CHANGED
@@ -11,7 +11,7 @@ if ( ! class_exists( 'RWMB_Datetime_Field' ) ) {
|
|
11 |
*/
|
12 |
static function admin_enqueue_scripts() {
|
13 |
$url = RWMB_CSS_URL . 'jqueryui';
|
14 |
-
wp_enqueue_style( 'jquery-ui-timepicker', "{$url}/jquery-ui-timepicker-addon.css", array(
|
15 |
|
16 |
wp_register_script( 'jquery-ui-timepicker', RWMB_JS_URL . 'jqueryui/jquery-ui-timepicker-addon.js', array( 'jquery-ui-datepicker', 'jquery-ui-slider' ), '0.9.7', true );
|
17 |
|
11 |
*/
|
12 |
static function admin_enqueue_scripts() {
|
13 |
$url = RWMB_CSS_URL . 'jqueryui';
|
14 |
+
wp_enqueue_style( 'jquery-ui-timepicker', "{$url}/jquery-ui-timepicker-addon.css", array( 'jquery-ui-datepicker', 'jquery-ui-slider' ), '0.9.7' );
|
15 |
|
16 |
wp_register_script( 'jquery-ui-timepicker', RWMB_JS_URL . 'jqueryui/jquery-ui-timepicker-addon.js', array( 'jquery-ui-datepicker', 'jquery-ui-slider' ), '0.9.7', true );
|
17 |
|
inc/libraries/meta-box/inc/fields/time.php
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
// Prevent loading this file directly
|
3 |
defined( 'ABSPATH' ) || exit;
|
4 |
|
5 |
-
if ( !class_exists( 'RWMB_Time_Field' ) ) {
|
6 |
class RWMB_Time_Field extends RWMB_Field {
|
7 |
/**
|
8 |
* Enqueue scripts and styles
|
@@ -11,7 +11,7 @@ if ( !class_exists( 'RWMB_Time_Field' ) ) {
|
|
11 |
*/
|
12 |
static function admin_enqueue_scripts() {
|
13 |
$url = RWMB_CSS_URL . 'jqueryui';
|
14 |
-
wp_enqueue_style( 'jquery-ui-timepicker', "{$url}/jquery-ui-timepicker-addon.css", array(
|
15 |
|
16 |
$url = RWMB_JS_URL . 'jqueryui';
|
17 |
wp_register_script( 'jquery-ui-timepicker', "{$url}/jquery-ui-timepicker-addon.js", array( 'jquery-ui-datepicker', 'jquery-ui-slider' ), '0.9.7', true );
|
2 |
// Prevent loading this file directly
|
3 |
defined( 'ABSPATH' ) || exit;
|
4 |
|
5 |
+
if ( ! class_exists( 'RWMB_Time_Field' ) ) {
|
6 |
class RWMB_Time_Field extends RWMB_Field {
|
7 |
/**
|
8 |
* Enqueue scripts and styles
|
11 |
*/
|
12 |
static function admin_enqueue_scripts() {
|
13 |
$url = RWMB_CSS_URL . 'jqueryui';
|
14 |
+
wp_enqueue_style( 'jquery-ui-timepicker', "{$url}/jquery-ui-timepicker-addon.css", array( 'jquery-ui-datepicker', 'jquery-ui-slider' ), '0.9.7' );
|
15 |
|
16 |
$url = RWMB_JS_URL . 'jqueryui';
|
17 |
wp_register_script( 'jquery-ui-timepicker', "{$url}/jquery-ui-timepicker-addon.js", array( 'jquery-ui-datepicker', 'jquery-ui-slider' ), '0.9.7', true );
|
inc/lp-constants.php
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
*/
|
5 |
$upload_dir = wp_upload_dir();
|
6 |
// version
|
7 |
-
define( 'LEARNPRESS_VERSION', '2.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', '2.1.5.5' );
|
8 |
|
9 |
define( 'LP_WP_CONTENT', basename( WP_CONTENT_DIR ) );
|
10 |
|
inc/lp-core-functions.php
CHANGED
@@ -1361,31 +1361,6 @@ function learn_press_user_maybe_is_a_teacher( $user = null ) {
|
|
1361 |
return apply_filters( 'learn_press_user_maybe_is_a_teacher', $role, $user->id );
|
1362 |
}
|
1363 |
|
1364 |
-
function learn_press_get_become_a_teacher_form_fields(){
|
1365 |
-
$user = learn_press_get_current_user();
|
1366 |
-
$fields = array(
|
1367 |
-
'bat_name' => array(
|
1368 |
-
'title' => __( 'Name', 'learnpress' ),
|
1369 |
-
'type' => 'text',
|
1370 |
-
'placeholder' => __( 'Your name', 'learnpress' ),
|
1371 |
-
'def' => $user->display_name
|
1372 |
-
),
|
1373 |
-
'bat_email' => array(
|
1374 |
-
'title' => __( 'Email', 'learnpress' ),
|
1375 |
-
'type' => 'email',
|
1376 |
-
'placeholder' => __( 'Your email address', 'learnpress' ),
|
1377 |
-
'def' => $user->user_email
|
1378 |
-
),
|
1379 |
-
'bat_phone' => array(
|
1380 |
-
'title' => __( 'Phone', 'learnpress' ),
|
1381 |
-
'type' => 'text',
|
1382 |
-
'placeholder' => __( 'Your phone number', 'learnpress' )
|
1383 |
-
)
|
1384 |
-
);
|
1385 |
-
$fields = apply_filters( 'learn_press_become_teacher_form_fields', $fields );
|
1386 |
-
return $fields;
|
1387 |
-
}
|
1388 |
-
|
1389 |
function learn_press_process_become_a_teacher_form( $args = null ) {
|
1390 |
$user = learn_press_get_current_user();
|
1391 |
$error = false;
|
@@ -1416,33 +1391,16 @@ function learn_press_process_become_a_teacher_form( $args = null ) {
|
|
1416 |
$error = true;
|
1417 |
}
|
1418 |
}
|
1419 |
-
|
1420 |
if ( !$error ) {
|
1421 |
$to_email = array( get_option( 'admin_email' ) );
|
1422 |
$message_headers = '';
|
1423 |
$subject = __( 'Please moderate', 'learnpress' );
|
1424 |
-
|
1425 |
-
$fields = learn_press_get_become_a_teacher_form_fields();
|
1426 |
-
$default_fields = array('bat_name' , 'bat_email', 'bat_phone' );
|
1427 |
-
foreach( $fields as $key => $field ){
|
1428 |
-
if( isset($_POST[$key]) ) {
|
1429 |
-
$fields[$key]['value'] = $_POST[$key];
|
1430 |
-
}
|
1431 |
-
}
|
1432 |
-
$notify_message = apply_filters('learn_press_filter_become_a_teacher_notify_message','', $args, $fields, $user);
|
1433 |
-
if( !$notify_message ) {
|
1434 |
-
$notify_message = sprintf( __( 'The user <a href="%s">%s</a> wants to be a teacher.', 'learnpress' ) . "\r\n", admin_url( 'user-edit.php?user_id=' . $user->id ), $user->user_login ) . "\r\n";
|
1435 |
-
$notify_message .= sprintf( __( 'Name: %s', 'learnpress' ), $args['name'] ) . "\r\n";
|
1436 |
-
$notify_message .= sprintf( __( 'Email: %s', 'learnpress' ), $args['email'] ) . "\r\n";
|
1437 |
-
$notify_message .= sprintf( __( 'Phone: %s', 'learnpress' ), $args['phone'] ) . "\r\n";
|
1438 |
-
foreach( $fields as $key => $field ) {
|
1439 |
-
if( !in_array( $key, $default_fields ) ) {
|
1440 |
-
$notify_message .= $field['title'].': ' . ( isset($field['value']) ? $field['value'] : '' ) . "\r\n";
|
1441 |
-
}
|
1442 |
-
}
|
1443 |
-
$notify_message .= wp_specialchars_decode( sprintf( __( 'Accept: %s', 'learnpress' ), wp_nonce_url( admin_url( 'user-edit.php?user_id=' . $user->id ) . '&action=accept-to-be-teacher', 'accept-to-be-teacher' ) ) ) . "\r\n";
|
1444 |
-
}
|
1445 |
|
|
|
|
|
|
|
|
|
1446 |
$args = array(
|
1447 |
$to_email,
|
1448 |
( $subject ),
|
@@ -1455,7 +1413,6 @@ function learn_press_process_become_a_teacher_form( $args = null ) {
|
|
1455 |
|
1456 |
set_transient( 'learn_press_become_teacher_sent_' . $user->id, 'yes', HOUR_IN_SECONDS * 2 );
|
1457 |
}
|
1458 |
-
|
1459 |
$return['result'] = $error ? 'error' : 'success';
|
1460 |
return $return;
|
1461 |
}
|
@@ -1558,10 +1515,10 @@ add_filter( 'pre_get_posts', 'learn_press_filter_search', 99 );
|
|
1558 |
* @param $data
|
1559 |
*/
|
1560 |
function learn_press_send_json( $data ) {
|
1561 |
-
echo '
|
1562 |
@header( 'Content-Type: application/json; charset=' . get_option( 'blog_charset' ) );
|
1563 |
echo wp_json_encode( $data );
|
1564 |
-
echo '
|
1565 |
die;
|
1566 |
}
|
1567 |
|
@@ -2246,7 +2203,7 @@ function learn_press_user_profile_link( $user_id = 0, $tab = null ) {
|
|
2246 |
if ( is_numeric( $user_id ) ) {
|
2247 |
$user = get_user_by( 'id', $user_id );
|
2248 |
} else {
|
2249 |
-
$user = get_user_by( 'login',
|
2250 |
}
|
2251 |
} else {
|
2252 |
return '';
|
@@ -2859,4 +2816,4 @@ function learn_press_validation_data_before_save( $value = '', $name = '' ) {
|
|
2859 |
}
|
2860 |
|
2861 |
return $value;
|
2862 |
-
}
|
1361 |
return apply_filters( 'learn_press_user_maybe_is_a_teacher', $role, $user->id );
|
1362 |
}
|
1363 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1364 |
function learn_press_process_become_a_teacher_form( $args = null ) {
|
1365 |
$user = learn_press_get_current_user();
|
1366 |
$error = false;
|
1391 |
$error = true;
|
1392 |
}
|
1393 |
}
|
|
|
1394 |
if ( !$error ) {
|
1395 |
$to_email = array( get_option( 'admin_email' ) );
|
1396 |
$message_headers = '';
|
1397 |
$subject = __( 'Please moderate', 'learnpress' );
|
1398 |
+
$notify_message = sprintf( __( 'The user <a href="%s">%s</a> wants to be a teacher.', 'learnpress' ) . "\r\n", admin_url( 'user-edit.php?user_id=' . $user->id ), $user->user_login ) . "\r\n";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1399 |
|
1400 |
+
$notify_message .= sprintf( __( 'Name: %s', 'learnpress' ), $args['name'] ) . "\r\n";
|
1401 |
+
$notify_message .= sprintf( __( 'Email: %s', 'learnpress' ), $args['email'] ) . "\r\n";
|
1402 |
+
$notify_message .= sprintf( __( 'Phone: %s', 'learnpress' ), $args['phone'] ) . "\r\n";
|
1403 |
+
$notify_message .= wp_specialchars_decode( sprintf( __( 'Accept: %s', 'learnpress' ), wp_nonce_url( admin_url( 'user-edit.php?user_id=' . $user->id ) . '&action=accept-to-be-teacher', 'accept-to-be-teacher' ) ) ) . "\r\n";
|
1404 |
$args = array(
|
1405 |
$to_email,
|
1406 |
( $subject ),
|
1413 |
|
1414 |
set_transient( 'learn_press_become_teacher_sent_' . $user->id, 'yes', HOUR_IN_SECONDS * 2 );
|
1415 |
}
|
|
|
1416 |
$return['result'] = $error ? 'error' : 'success';
|
1417 |
return $return;
|
1418 |
}
|
1515 |
* @param $data
|
1516 |
*/
|
1517 |
function learn_press_send_json( $data ) {
|
1518 |
+
echo '<!-- LP_AJAX_START -->';
|
1519 |
@header( 'Content-Type: application/json; charset=' . get_option( 'blog_charset' ) );
|
1520 |
echo wp_json_encode( $data );
|
1521 |
+
echo '<!-- LP_AJAX_END -->';
|
1522 |
die;
|
1523 |
}
|
1524 |
|
2203 |
if ( is_numeric( $user_id ) ) {
|
2204 |
$user = get_user_by( 'id', $user_id );
|
2205 |
} else {
|
2206 |
+
$user = get_user_by( 'login', $user_id );
|
2207 |
}
|
2208 |
} else {
|
2209 |
return '';
|
2816 |
}
|
2817 |
|
2818 |
return $value;
|
2819 |
+
}
|
inc/lp-init.php
CHANGED
@@ -240,7 +240,8 @@ function _learn_press_get_courses_curriculum( $course_ids, $force = false, $pars
|
|
240 |
$item->{$prop} = $row->{$prop};
|
241 |
}
|
242 |
}
|
243 |
-
$
|
|
|
244 |
if ( $item->post_type == LP_QUIZ_CPT ) {
|
245 |
if ( false == wp_cache_get( $item->ID, 'posts' ) ) {
|
246 |
$quiz_ids[] = $item->ID;
|
@@ -262,7 +263,6 @@ function _learn_press_get_courses_curriculum( $course_ids, $force = false, $pars
|
|
262 |
}
|
263 |
}
|
264 |
}
|
265 |
-
$_curriculum[$section_id]->items[] = $item;
|
266 |
wp_cache_delete( $item->ID, 'posts' );
|
267 |
wp_cache_add( $item->ID, $item, 'posts' );
|
268 |
}
|
@@ -322,6 +322,8 @@ function _learn_press_get_course_curriculum( $course_id, $force = false ) {
|
|
322 |
return $curriculum;
|
323 |
}
|
324 |
|
|
|
|
|
325 |
/**
|
326 |
* @param $quiz_ids
|
327 |
*
|
@@ -480,59 +482,43 @@ function _learn_press_parse_user_item_statuses( $user_id, $course_id, $force = f
|
|
480 |
if ( $item_ids ) {
|
481 |
$in = implode( ', ', $item_ids );
|
482 |
$query = $wpdb->prepare( "
|
483 |
-
SELECT
|
484 |
-
|
485 |
-
|
486 |
-
|
487 |
-
|
488 |
-
|
489 |
-
|
490 |
-
|
491 |
-
|
492 |
-
|
493 |
-
|
494 |
-
WHERE user_id = %d and ref_id = %d
|
495 |
-
AND item_id = t2.item_id
|
496 |
-
)
|
497 |
-
AND item_id IN({$in})
|
498 |
)
|
499 |
-
|
500 |
-
|
501 |
ORDER BY user_item_id ASC
|
502 |
-
", $user_id, $course_id, $user_id, $course_id, $user_id, $course_id
|
503 |
} else {
|
504 |
$query = $wpdb->prepare( "
|
505 |
-
SELECT
|
506 |
-
LEFT JOIN {$wpdb->prefix}learnpress_user_itemmeta uim ON uim.learnpress_user_item_id = ui.user_item_id AND uim.meta_key = %s
|
507 |
WHERE user_id = %d
|
508 |
AND item_id = %d
|
509 |
-
",
|
510 |
}
|
511 |
$items = $wpdb->get_results( $query );
|
512 |
|
513 |
$item_statuses = LP_Cache::get_item_statuses( false, array() );
|
514 |
-
$quiz_grades = LP_Cache::get_quiz_grade( false, array() );
|
515 |
foreach ( $item_ids as $id ) {
|
516 |
if ( !array_key_exists( $id, $item_statuses ) || $force ) {
|
517 |
$item_statuses[$user_id . '-' . $course_id . '-' . $id] = '';
|
518 |
}
|
519 |
-
|
520 |
-
if ( !array_key_exists( $id, $item_statuses ) || $force ) {
|
521 |
-
$quiz_grades[$user_id . '-' . $course_id . '-' . $id] = '';
|
522 |
-
}
|
523 |
}
|
524 |
if ( $items ) {
|
525 |
foreach ( $items as $item ) {
|
526 |
$item_statuses[$user_id . '-' . $course_id . '-' . $item->item_id] = learn_press_validate_item_status( $item );
|
527 |
-
if ( !empty($item->grade) ) {
|
528 |
-
$quiz_grades[$user_id . '-' . $course_id . '-' . $item->item_id] = $item->grade;
|
529 |
-
}else{
|
530 |
-
$quiz_grades[$user_id . '-' . $course_id . '-' . $item->item_id] = '';
|
531 |
-
}
|
532 |
}
|
533 |
}
|
534 |
LP_Cache::set_item_statuses( $item_statuses );
|
535 |
-
LP_Cache::set_quiz_grade( $quiz_grades );
|
536 |
|
537 |
do_action( "learn_press_parse_user_item_statuses", $user_id, $course_id );
|
538 |
do_action( "learn_press_parse_user_item_statuses_{$user_id}_{$course_id}" );
|
@@ -541,12 +527,6 @@ function _learn_press_parse_user_item_statuses( $user_id, $course_id, $force = f
|
|
541 |
function learn_press_validate_item_status( $item ) {
|
542 |
$end_time = $item->end_time !== '0000-00-00 00:00:00';
|
543 |
$status = $end_time > 0 ? ( $item->item_type != LP_COURSE_CPT ? 'completed' : 'finished' ) : $item->status;
|
544 |
-
if ( $item->item_type == LP_QUIZ_CPT && $item->status == 'completed' && is_null( $item->grade ) ) {
|
545 |
-
$user = learn_press_get_user( $item->user_id );
|
546 |
-
$grade = $user->get_quiz_graduation( $item->item_id, $item->ref_id );
|
547 |
-
LP_Cache::set_quiz_grade( sprintf( '%d-%d-%d', $item->user_id, $item->ref_id, $item->item_id ), $grade );
|
548 |
-
learn_press_update_user_item_meta( $item->user_item_id, '_quiz_grade', $grade );
|
549 |
-
}
|
550 |
if ( $end_time && !in_array( $item->status, array( 'completed', 'finished' ) ) ) {
|
551 |
global $wpdb;
|
552 |
$data = (array) $item;
|
240 |
$item->{$prop} = $row->{$prop};
|
241 |
}
|
242 |
}
|
243 |
+
$_curriculum[$section_id]->items[] = $item;
|
244 |
+
$item_ids[] = $item->ID;
|
245 |
if ( $item->post_type == LP_QUIZ_CPT ) {
|
246 |
if ( false == wp_cache_get( $item->ID, 'posts' ) ) {
|
247 |
$quiz_ids[] = $item->ID;
|
263 |
}
|
264 |
}
|
265 |
}
|
|
|
266 |
wp_cache_delete( $item->ID, 'posts' );
|
267 |
wp_cache_add( $item->ID, $item, 'posts' );
|
268 |
}
|
322 |
return $curriculum;
|
323 |
}
|
324 |
|
325 |
+
include_once "new-functions.php";
|
326 |
+
|
327 |
/**
|
328 |
* @param $quiz_ids
|
329 |
*
|
482 |
if ( $item_ids ) {
|
483 |
$in = implode( ', ', $item_ids );
|
484 |
$query = $wpdb->prepare( "
|
485 |
+
SELECT * FROM {$wpdb->prefix}learnpress_user_items t1
|
486 |
+
WHERE user_id = %d
|
487 |
+
AND item_id = %d
|
488 |
+
UNION
|
489 |
+
(
|
490 |
+
SELECT * FROM {$wpdb->prefix}learnpress_user_items t2
|
491 |
+
WHERE user_id = %d AND ref_id = %d
|
492 |
+
AND user_item_id = (
|
493 |
+
SELECT MAX(user_item_id) FROM {$wpdb->prefix}learnpress_user_items
|
494 |
+
WHERE user_id = %d and ref_id = %d
|
495 |
+
AND item_id = t2.item_id
|
|
|
|
|
|
|
|
|
496 |
)
|
497 |
+
AND item_id IN({$in})
|
498 |
+
)
|
499 |
ORDER BY user_item_id ASC
|
500 |
+
", $user_id, $course_id, $user_id, $course_id, $user_id, $course_id );
|
501 |
} else {
|
502 |
$query = $wpdb->prepare( "
|
503 |
+
SELECT * FROM {$wpdb->prefix}learnpress_user_items t1
|
|
|
504 |
WHERE user_id = %d
|
505 |
AND item_id = %d
|
506 |
+
", $user_id, $course_id );
|
507 |
}
|
508 |
$items = $wpdb->get_results( $query );
|
509 |
|
510 |
$item_statuses = LP_Cache::get_item_statuses( false, array() );
|
|
|
511 |
foreach ( $item_ids as $id ) {
|
512 |
if ( !array_key_exists( $id, $item_statuses ) || $force ) {
|
513 |
$item_statuses[$user_id . '-' . $course_id . '-' . $id] = '';
|
514 |
}
|
|
|
|
|
|
|
|
|
515 |
}
|
516 |
if ( $items ) {
|
517 |
foreach ( $items as $item ) {
|
518 |
$item_statuses[$user_id . '-' . $course_id . '-' . $item->item_id] = learn_press_validate_item_status( $item );
|
|
|
|
|
|
|
|
|
|
|
519 |
}
|
520 |
}
|
521 |
LP_Cache::set_item_statuses( $item_statuses );
|
|
|
522 |
|
523 |
do_action( "learn_press_parse_user_item_statuses", $user_id, $course_id );
|
524 |
do_action( "learn_press_parse_user_item_statuses_{$user_id}_{$course_id}" );
|
527 |
function learn_press_validate_item_status( $item ) {
|
528 |
$end_time = $item->end_time !== '0000-00-00 00:00:00';
|
529 |
$status = $end_time > 0 ? ( $item->item_type != LP_COURSE_CPT ? 'completed' : 'finished' ) : $item->status;
|
|
|
|
|
|
|
|
|
|
|
|
|
530 |
if ( $end_time && !in_array( $item->status, array( 'completed', 'finished' ) ) ) {
|
531 |
global $wpdb;
|
532 |
$data = (array) $item;
|
inc/lp-template-functions.php
CHANGED
@@ -672,7 +672,7 @@ if ( !function_exists( 'learn_press_user_profile_tabs' ) ) {
|
|
672 |
if ( !$user ) {
|
673 |
$user = learn_press_get_current_user();
|
674 |
}
|
675 |
-
return LP_Profile::instance(
|
676 |
}
|
677 |
}
|
678 |
|
@@ -682,7 +682,7 @@ if ( !function_exists( 'learn_press_output_user_profile_info' ) ) {
|
|
682 |
*
|
683 |
* @param $user
|
684 |
*/
|
685 |
-
function learn_press_output_user_profile_info( $user, $current, $tabs ) {
|
686 |
learn_press_get_template( 'profile/info.php', array(
|
687 |
'user' => $user,
|
688 |
'tabs' => $tabs,
|
@@ -702,8 +702,8 @@ if ( !function_exists( 'learn_press_single_quiz_title' ) ) {
|
|
702 |
}
|
703 |
|
704 |
|
705 |
-
if ( !function_exists( 'learn_press_after_quiz_question_title' ) ) {
|
706 |
-
function learn_press_single_quiz_question_answer( $question_id = null, $quiz_id = null ) {
|
707 |
learn_press_get_template( 'content-quiz/question-answer.php', array(
|
708 |
'question_id' => $question_id,
|
709 |
'quiz_id' => $quiz_id
|
@@ -827,10 +827,6 @@ if ( !function_exists( 'learn_press_course_quiz_class' ) ) {
|
|
827 |
$classes[] = 'viewable';
|
828 |
}
|
829 |
|
830 |
-
if ( $course->is_final_quiz( $quiz_id ) ) {
|
831 |
-
$classes[] = 'final-quiz';
|
832 |
-
}
|
833 |
-
|
834 |
$classes = array_unique( array_merge( $classes, $class ) );
|
835 |
|
836 |
if ( $echo ) {
|
@@ -1291,7 +1287,7 @@ if ( !function_exists( 'learn_press_404_page' ) ) {
|
|
1291 |
|
1292 |
if ( !function_exists( 'learn_press_course_curriculum_popup' ) ) {
|
1293 |
function learn_press_course_curriculum_popup() {
|
1294 |
-
learn_press_get_template( '
|
1295 |
}
|
1296 |
}
|
1297 |
|
@@ -1510,7 +1506,7 @@ if ( !function_exists( 'learn_press_get_profile_display_name' ) ) {
|
|
1510 |
*
|
1511 |
* @return string
|
1512 |
*/
|
1513 |
-
function learn_press_get_profile_display_name( $user ) {
|
1514 |
if ( empty( $user ) ) {
|
1515 |
return '';
|
1516 |
}
|
@@ -1589,3 +1585,14 @@ function learn_press_fontend_js_template() {
|
|
1589 |
}
|
1590 |
|
1591 |
add_action( 'wp_footer', 'learn_press_fontend_js_template' );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
672 |
if ( !$user ) {
|
673 |
$user = learn_press_get_current_user();
|
674 |
}
|
675 |
+
return LP_Profile::instance($user->id)->get_tabs();
|
676 |
}
|
677 |
}
|
678 |
|
682 |
*
|
683 |
* @param $user
|
684 |
*/
|
685 |
+
function learn_press_output_user_profile_info ( $user, $current, $tabs ) {
|
686 |
learn_press_get_template( 'profile/info.php', array(
|
687 |
'user' => $user,
|
688 |
'tabs' => $tabs,
|
702 |
}
|
703 |
|
704 |
|
705 |
+
if ( ! function_exists( 'learn_press_after_quiz_question_title' ) ) {
|
706 |
+
function learn_press_single_quiz_question_answer ( $question_id = null, $quiz_id = null ) {
|
707 |
learn_press_get_template( 'content-quiz/question-answer.php', array(
|
708 |
'question_id' => $question_id,
|
709 |
'quiz_id' => $quiz_id
|
827 |
$classes[] = 'viewable';
|
828 |
}
|
829 |
|
|
|
|
|
|
|
|
|
830 |
$classes = array_unique( array_merge( $classes, $class ) );
|
831 |
|
832 |
if ( $echo ) {
|
1287 |
|
1288 |
if ( !function_exists( 'learn_press_course_curriculum_popup' ) ) {
|
1289 |
function learn_press_course_curriculum_popup() {
|
1290 |
+
learn_press_get_template( 'single-course/popup.php' );
|
1291 |
}
|
1292 |
}
|
1293 |
|
1506 |
*
|
1507 |
* @return string
|
1508 |
*/
|
1509 |
+
function learn_press_get_profile_display_name ( $user ) {
|
1510 |
if ( empty( $user ) ) {
|
1511 |
return '';
|
1512 |
}
|
1585 |
}
|
1586 |
|
1587 |
add_action( 'wp_footer', 'learn_press_fontend_js_template' );
|
1588 |
+
|
1589 |
+
add_action( 'wp_head', 'learn_press_js_template' );
|
1590 |
+
function learn_press_js_template() {
|
1591 |
+
?>
|
1592 |
+
<script type="text/template" id="learn-press-template-block-content">
|
1593 |
+
<div id="learn-press-block-content" class="popup-block-content">
|
1594 |
+
<span></span>
|
1595 |
+
</div>
|
1596 |
+
</script>
|
1597 |
+
<?php
|
1598 |
+
}
|
inc/new-functions.php
ADDED
@@ -0,0 +1,119 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
|
4 |
+
add_action( 'get_header', function () {
|
5 |
+
return;
|
6 |
+
echo "XXXXXXXXXXXXXXXXXXXXXXXXXXX\n\n";
|
7 |
+
learn_press_execute_time();
|
8 |
+
print_r( learn_press_get_course_curriculumx( 2424 ) );
|
9 |
+
learn_press_execute_time();
|
10 |
+
|
11 |
+
learn_press_execute_time();
|
12 |
+
print_r( _learn_press_get_courses_curriculum( array( 2424 ), true ) );
|
13 |
+
learn_press_execute_time();
|
14 |
+
echo "yyyyyyyyyyyyyyyyyyyyy";
|
15 |
+
} );
|
16 |
+
|
17 |
+
/**
|
18 |
+
* Create an object with WP_Post format.
|
19 |
+
*
|
20 |
+
* @param array $data
|
21 |
+
*
|
22 |
+
* @return object
|
23 |
+
*/
|
24 |
+
function learn_press_create_default_post( $data = array() ) {
|
25 |
+
if ( !function_exists( 'get_default_post_to_edit' ) ) {
|
26 |
+
include_once ABSPATH . '/wp-admin/includes/post.php';
|
27 |
+
}
|
28 |
+
|
29 |
+
$post = get_default_post_to_edit();
|
30 |
+
if ( $data ) {
|
31 |
+
$data = (array) $data;
|
32 |
+
foreach ( $data as $prop => $value ) {
|
33 |
+
$post->{$prop} = $value;
|
34 |
+
}
|
35 |
+
}
|
36 |
+
return $post;
|
37 |
+
}
|
38 |
+
|
39 |
+
function learn_press_get_course_curriculumx( $course_id, $force = false ) {
|
40 |
+
static $cached = false;
|
41 |
+
$force = !$cached || $force;
|
42 |
+
$curriculum = LP_Cache::get_course_curriculum( $course_id );
|
43 |
+
if ( $force || $curriculum === false ) {
|
44 |
+
global $wpdb;
|
45 |
+
/*echo $query = $wpdb->prepare( "
|
46 |
+
SELECT si.*, s.section_name, s.section_order, s.section_description
|
47 |
+
FROM {$wpdb->prefix}learnpress_sections s
|
48 |
+
INNER JOIN {$wpdb->prefix}learnpress_section_items si ON si.section_id = s.section_id
|
49 |
+
WHERE s.section_id IN(
|
50 |
+
SELECT cc.section_id
|
51 |
+
FROM {$wpdb->posts} p
|
52 |
+
INNER JOIN {$wpdb->prefix}learnpress_sections cc ON p.ID = cc.section_course_id
|
53 |
+
WHERE p.ID IN(%d)
|
54 |
+
)
|
55 |
+
ORDER BY s.section_order, si.item_order ASC
|
56 |
+
", $course_id );*/
|
57 |
+
$query = $wpdb->prepare( "
|
58 |
+
SELECT s.*, si.*, p.*
|
59 |
+
FROM {$wpdb->prefix}posts p
|
60 |
+
INNER JOIN {$wpdb->prefix}learnpress_section_items si ON si.item_id = p.ID
|
61 |
+
INNER JOIN {$wpdb->prefix}learnpress_sections s ON s.section_id = si.section_id
|
62 |
+
WHERE s.section_id IN(
|
63 |
+
SELECT cc.section_id
|
64 |
+
FROM {$wpdb->prefix}posts p
|
65 |
+
INNER JOIN {$wpdb->prefix}learnpress_sections cc ON p.ID = cc.section_course_id
|
66 |
+
WHERE p.ID IN(%d)
|
67 |
+
ORDER BY `section_order` ASC
|
68 |
+
)
|
69 |
+
ORDER BY s.section_course_id, s.section_order, si.item_order ASC
|
70 |
+
", $course_id );
|
71 |
+
$curriculum = array();
|
72 |
+
$meta_ids = array( $course_id );
|
73 |
+
$item_ids = array();
|
74 |
+
if ( $results = $wpdb->get_results( $query ) ) {
|
75 |
+
foreach ( $results as $result ) {
|
76 |
+
$section_id = $result->section_id;
|
77 |
+
if ( empty( $curriculum[$section_id] ) ) {
|
78 |
+
$curriculum[$result->section_id] = (object) array(
|
79 |
+
'section_id' => $result->section_id,
|
80 |
+
'section_name' => $result->section_name,
|
81 |
+
'section_course_id' => $result->section_course_id,
|
82 |
+
'section_order' => $result->section_order,
|
83 |
+
'section_description' => $result->section_description,
|
84 |
+
'items' => array()
|
85 |
+
);
|
86 |
+
}
|
87 |
+
$item = learn_press_create_default_post( $result );
|
88 |
+
$item->section_item_id = $result->section_item_id;
|
89 |
+
$item->section_id = $result->section_id;
|
90 |
+
$item->item_id = $result->ID;
|
91 |
+
|
92 |
+
$curriculum[$section_id]->items[$item->item_id] = $item;
|
93 |
+
// Update post to cache
|
94 |
+
wp_cache_delete( $item->ID, 'posts' );
|
95 |
+
wp_cache_add( $item->ID, $item, 'posts' );
|
96 |
+
|
97 |
+
if ( $item->post_type == LP_QUIZ_CPT ) {
|
98 |
+
// Todo: Parse quiz questions
|
99 |
+
}
|
100 |
+
$item_ids = $item->ID;
|
101 |
+
$meta_ids[] = $item->ID;
|
102 |
+
}
|
103 |
+
|
104 |
+
// Update post to cache
|
105 |
+
$course = get_post( $course_id );
|
106 |
+
$course->curriculum_items = is_admin() ? maybe_serialize( $item_ids ) : $item_ids;
|
107 |
+
|
108 |
+
wp_cache_replace( $course_id, $course, 'posts' );
|
109 |
+
|
110 |
+
// Update meta cache for posts
|
111 |
+
update_meta_cache( 'post', $meta_ids );
|
112 |
+
|
113 |
+
}
|
114 |
+
|
115 |
+
LP_Cache::set_course_curriculum( $course_id, $curriculum );
|
116 |
+
}
|
117 |
+
$cached = true;
|
118 |
+
return $curriculum;
|
119 |
+
}
|
inc/order/class-lp-order.php
CHANGED
@@ -266,7 +266,8 @@ class LP_Order {
|
|
266 |
|
267 |
public function customer_exists() {
|
268 |
$user_id = $this->user_id;
|
269 |
-
|
|
|
270 |
}
|
271 |
|
272 |
/**
|
@@ -387,7 +388,7 @@ class LP_Order {
|
|
387 |
|
388 |
public function __get( $key ) {
|
389 |
$value = null;
|
390 |
-
if ( !
|
391 |
$value = get_post_meta( $this->id, '_' . $key, true );
|
392 |
}
|
393 |
return $value;
|
266 |
|
267 |
public function customer_exists() {
|
268 |
$user_id = $this->user_id;
|
269 |
+
$user = learn_press_get_user( $user_id );
|
270 |
+
return $user->is_exists();
|
271 |
}
|
272 |
|
273 |
/**
|
388 |
|
389 |
public function __get( $key ) {
|
390 |
$value = null;
|
391 |
+
if ( !isset( $this->{$key} ) ) {
|
392 |
$value = get_post_meta( $this->id, '_' . $key, true );
|
393 |
}
|
394 |
return $value;
|
inc/question/class-lp-question-factory.php
CHANGED
@@ -60,7 +60,6 @@ class LP_Question_Factory {
|
|
60 |
return self::$_instances[$the_id];
|
61 |
}
|
62 |
|
63 |
-
|
64 |
/**
|
65 |
* @param string
|
66 |
*
|
@@ -161,7 +160,6 @@ class LP_Question_Factory {
|
|
161 |
add_action( 'learn_press_after_quiz_question_title', array( __CLASS__, 'show_answer' ), 100, 2 );
|
162 |
add_action( 'learn_press_after_question_wrap', array( __CLASS__, 'show_hint' ), 100, 2 );
|
163 |
add_action( 'learn_press_after_question_wrap', array( __CLASS__, 'show_explanation' ), 110, 2 );
|
164 |
-
add_action( 'delete_post', array( __CLASS__, 'delete_question' ), 10, 2 );
|
165 |
|
166 |
LP_Question_Factory::add_template( 'multi-choice-option', LP_Question_Multi_Choice::admin_js_template() );
|
167 |
LP_Question_Factory::add_template( 'single-choice-option', LP_Question_Single_Choice::admin_js_template() );
|
@@ -169,19 +167,6 @@ class LP_Question_Factory {
|
|
169 |
do_action( 'learn_press_question_factory_init', __CLASS__ );
|
170 |
}
|
171 |
|
172 |
-
|
173 |
-
public static function delete_question( $post_id, $force=false ) {
|
174 |
-
global $wpdb;
|
175 |
-
if( 'lp_question' === get_post_type($post_id) ) {
|
176 |
-
// remove question answears
|
177 |
-
$sql = 'DELETE FROM `'.$wpdb->prefix.'learnpress_question_answers` WHERE `question_id` = '.$post_id;
|
178 |
-
$wpdb->query($sql);
|
179 |
-
// remove question in quiz
|
180 |
-
$sql = 'DELETE FROM `'.$wpdb->prefix.'learnpress_quiz_questions` WHERE `question_id` = '.$post_id;
|
181 |
-
$wpdb->query($sql);
|
182 |
-
}
|
183 |
-
}
|
184 |
-
|
185 |
public static function show_answer( $id, $quiz_id ) {
|
186 |
|
187 |
$quiz = LP_Quiz::get_quiz( $quiz_id );
|
@@ -314,7 +299,7 @@ class LP_Question_Factory {
|
|
314 |
}
|
315 |
|
316 |
public static function admin_assets() {
|
317 |
-
|
318 |
//LP_Assets::enqueue_script( 'learn-press-meta-box-question', false, array( 'learn-press-admin' ) );
|
319 |
}
|
320 |
|
@@ -392,4 +377,4 @@ class LP_Question_Factory {
|
|
392 |
}
|
393 |
}
|
394 |
|
395 |
-
LP_Question_Factory::init();
|
60 |
return self::$_instances[$the_id];
|
61 |
}
|
62 |
|
|
|
63 |
/**
|
64 |
* @param string
|
65 |
*
|
160 |
add_action( 'learn_press_after_quiz_question_title', array( __CLASS__, 'show_answer' ), 100, 2 );
|
161 |
add_action( 'learn_press_after_question_wrap', array( __CLASS__, 'show_hint' ), 100, 2 );
|
162 |
add_action( 'learn_press_after_question_wrap', array( __CLASS__, 'show_explanation' ), 110, 2 );
|
|
|
163 |
|
164 |
LP_Question_Factory::add_template( 'multi-choice-option', LP_Question_Multi_Choice::admin_js_template() );
|
165 |
LP_Question_Factory::add_template( 'single-choice-option', LP_Question_Single_Choice::admin_js_template() );
|
167 |
do_action( 'learn_press_question_factory_init', __CLASS__ );
|
168 |
}
|
169 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
170 |
public static function show_answer( $id, $quiz_id ) {
|
171 |
|
172 |
$quiz = LP_Quiz::get_quiz( $quiz_id );
|
299 |
}
|
300 |
|
301 |
public static function admin_assets() {
|
302 |
+
LP_Assets::enqueue_style( 'learn-press-meta-box-question' );
|
303 |
//LP_Assets::enqueue_script( 'learn-press-meta-box-question', false, array( 'learn-press-admin' ) );
|
304 |
}
|
305 |
|
377 |
}
|
378 |
}
|
379 |
|
380 |
+
LP_Question_Factory::init();
|
inc/quiz/class-lp-quiz-factory.php
CHANGED
@@ -30,15 +30,6 @@ class LP_Quiz_Factory {
|
|
30 |
LP_Request_Handler::register_ajax( $k, array( __CLASS__, $v ) );
|
31 |
}
|
32 |
add_action( 'learn_press_after_single_quiz_summary', array( __CLASS__, 'output_quiz_params' ) );
|
33 |
-
add_action( 'delete_post', array( __CLASS__, 'delete_quiz' ), 10, 2 );
|
34 |
-
}
|
35 |
-
|
36 |
-
public static function delete_quiz( $post_id, $force=false ) {
|
37 |
-
global $wpdb;
|
38 |
-
if('lp_quiz' === get_post_type($post_id) ){
|
39 |
-
$sql = 'DELETE FROM `'.$wpdb->prefix.'learnpress_quiz_questions` WHERE `quiz_id` = '.$post_id;
|
40 |
-
$wpdb->query($sql);
|
41 |
-
}
|
42 |
}
|
43 |
|
44 |
public static function output_quiz_params( $quiz ) {
|
@@ -217,7 +208,7 @@ class LP_Quiz_Factory {
|
|
217 |
$result = $user->finish_quiz( $quiz_id, $course_id, $args );
|
218 |
if ( $result ) {
|
219 |
if ( !empty( $args['auto_finish'] ) ) {
|
220 |
-
learn_press_add_message( __( '
|
221 |
} else {
|
222 |
learn_press_add_message( __( 'You have finished quiz', 'learnpress' ) );
|
223 |
}
|
30 |
LP_Request_Handler::register_ajax( $k, array( __CLASS__, $v ) );
|
31 |
}
|
32 |
add_action( 'learn_press_after_single_quiz_summary', array( __CLASS__, 'output_quiz_params' ) );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
33 |
}
|
34 |
|
35 |
public static function output_quiz_params( $quiz ) {
|
208 |
$result = $user->finish_quiz( $quiz_id, $course_id, $args );
|
209 |
if ( $result ) {
|
210 |
if ( !empty( $args['auto_finish'] ) ) {
|
211 |
+
learn_press_add_message( __( 'You quiz has finished automatically', 'learnpress' ) );
|
212 |
} else {
|
213 |
learn_press_add_message( __( 'You have finished quiz', 'learnpress' ) );
|
214 |
}
|
inc/updates/09/script.js
CHANGED
@@ -58,13 +58,14 @@
|
|
58 |
var $doc = $(document);
|
59 |
|
60 |
function parseJSON(response) {
|
61 |
-
var matches = response.match(
|
62 |
json = {};
|
63 |
|
64 |
if (matches && matches[1]) {
|
65 |
try {
|
66 |
json = JSON.parse(matches[1]);
|
67 |
} catch (e) {
|
|
|
68 |
}
|
69 |
}
|
70 |
return json;
|
58 |
var $doc = $(document);
|
59 |
|
60 |
function parseJSON(response) {
|
61 |
+
var matches = response.match(/<!-- LP_AJAX_START -->(.*)<!-- LP_AJAX_END -->/),
|
62 |
json = {};
|
63 |
|
64 |
if (matches && matches[1]) {
|
65 |
try {
|
66 |
json = JSON.parse(matches[1]);
|
67 |
} catch (e) {
|
68 |
+
LP.log(e);
|
69 |
}
|
70 |
}
|
71 |
return json;
|
inc/user/abstract-lp-user.php
CHANGED
@@ -2486,12 +2486,10 @@ class LP_Abstract_User {
|
|
2486 |
foreach ( $course_info['items'] as $k => $item ) {
|
2487 |
if ( $item['type'] == 'lp_quiz' ) {
|
2488 |
$result = $this->get_quiz_results( $item['id'], $course_id );
|
2489 |
-
$passing_grade_type = get_post_meta( $item['id'], '_lp_passing_grade_type', true );
|
2490 |
$course_info['items'][$k] = array_merge(
|
2491 |
$course_info['items'][$k],
|
2492 |
array(
|
2493 |
-
'results'
|
2494 |
-
'passing_grade_type' => $passing_grade_type
|
2495 |
)
|
2496 |
);
|
2497 |
}
|
@@ -2685,9 +2683,7 @@ class LP_Abstract_User {
|
|
2685 |
if ( $curriculum && $curriculum->items ) {
|
2686 |
foreach ( $curriculum->items as $item ) {
|
2687 |
if ( $this->has_completed_item( $item->ID, $course_id, $force ) ) {
|
2688 |
-
|
2689 |
-
$completed ++;
|
2690 |
-
}
|
2691 |
}
|
2692 |
}
|
2693 |
}
|
@@ -2730,27 +2726,23 @@ class LP_Abstract_User {
|
|
2730 |
* @return mixed|void
|
2731 |
*/
|
2732 |
public function get_quiz_graduation( $quiz_id, $course_id = 0, $check_completed = true ) {
|
|
|
2733 |
|
2734 |
-
|
2735 |
-
|
2736 |
-
|
2737 |
-
$
|
2738 |
-
|
2739 |
-
|
2740 |
-
|
2741 |
-
$
|
2742 |
-
|
2743 |
-
|
2744 |
-
|
2745 |
-
|
2746 |
-
$grade = $passing_grade <= $result->mark_percent;
|
2747 |
-
} else {
|
2748 |
-
$grade = true;
|
2749 |
-
}
|
2750 |
-
$grade = $grade ? 'passed' : 'failed';
|
2751 |
}
|
|
|
2752 |
}
|
2753 |
-
//echo $quiz_id, ',',LP_Cache::get_quiz_grade( sprintf( '%d-%d-%d', $this->id, $course_id, $quiz_id ));
|
2754 |
return apply_filters( 'learn_press_user_quiz_graduation', $grade, $quiz_id, $course_id );
|
2755 |
}
|
2756 |
|
@@ -2764,7 +2756,7 @@ class LP_Abstract_User {
|
|
2764 |
* @return bool
|
2765 |
*/
|
2766 |
public function is_exists() {
|
2767 |
-
return
|
2768 |
}
|
2769 |
|
2770 |
/**
|
@@ -2879,39 +2871,6 @@ class LP_Abstract_User {
|
|
2879 |
return apply_filters( 'learn_press_user_can_do_quiz', $can, $quiz_id, $this->id, $course_id );
|
2880 |
}
|
2881 |
|
2882 |
-
/**
|
2883 |
-
* Get user course's grade.
|
2884 |
-
* Possible values:
|
2885 |
-
* + passed User has finished and passed course
|
2886 |
-
* + failed User has finished but failed
|
2887 |
-
* + in-progress User still is learning course
|
2888 |
-
* + false All other cases, e.g: not enrolled
|
2889 |
-
*
|
2890 |
-
* @param $course_id
|
2891 |
-
*
|
2892 |
-
* @return mixed|void
|
2893 |
-
* @throws Exception
|
2894 |
-
*/
|
2895 |
-
public function get_course_grade( $course_id ) {
|
2896 |
-
$course = LP_Course::get_course( $course_id );
|
2897 |
-
$status = $this->get( 'course-status', $course_id );
|
2898 |
-
$grade = false;
|
2899 |
-
if ( $status == 'finished' ) {
|
2900 |
-
$result = $course->evaluate_course_results( $this->id );
|
2901 |
-
$current = absint( $result );
|
2902 |
-
$passing_condition = absint( $course->passing_condition );
|
2903 |
-
$passed = $current >= $passing_condition;
|
2904 |
-
if ( $passed ) {
|
2905 |
-
$grade = 'passed';
|
2906 |
-
} else {
|
2907 |
-
$grade = 'failed';
|
2908 |
-
}
|
2909 |
-
} else if ( $status && $status != 'finished' ) {
|
2910 |
-
$grade = 'in-progress';
|
2911 |
-
}
|
2912 |
-
return apply_filters( 'learn_press_user_course_grade', $grade, $this->id, $course_id );
|
2913 |
-
}
|
2914 |
-
|
2915 |
public static function get_user() {
|
2916 |
_deprecated_function( __CLASS__ . '::' . __FUNCTION__, '2.0.7', 'LP_User_Factory::get_user' );
|
2917 |
$func_args = func_get_args();
|
2486 |
foreach ( $course_info['items'] as $k => $item ) {
|
2487 |
if ( $item['type'] == 'lp_quiz' ) {
|
2488 |
$result = $this->get_quiz_results( $item['id'], $course_id );
|
|
|
2489 |
$course_info['items'][$k] = array_merge(
|
2490 |
$course_info['items'][$k],
|
2491 |
array(
|
2492 |
+
'results' => $result ? $result->mark_percent : 0
|
|
|
2493 |
)
|
2494 |
);
|
2495 |
}
|
2683 |
if ( $curriculum && $curriculum->items ) {
|
2684 |
foreach ( $curriculum->items as $item ) {
|
2685 |
if ( $this->has_completed_item( $item->ID, $course_id, $force ) ) {
|
2686 |
+
$completed ++;
|
|
|
|
|
2687 |
}
|
2688 |
}
|
2689 |
}
|
2726 |
* @return mixed|void
|
2727 |
*/
|
2728 |
public function get_quiz_graduation( $quiz_id, $course_id = 0, $check_completed = true ) {
|
2729 |
+
$course_id = $this->_get_course_id( $course_id );
|
2730 |
|
2731 |
+
$result = $this->get_quiz_results( $quiz_id, $course_id );
|
2732 |
+
$grade = '';
|
2733 |
+
if ( $result && ( ( $check_completed == false ) || $check_completed && $result->status == 'completed' ) ) {
|
2734 |
+
$quiz = LP_Quiz::get_quiz( $quiz_id );
|
2735 |
+
$grade_type = $quiz->passing_grade_type;
|
2736 |
+
$passing_grade = $quiz->passing_grade;
|
2737 |
+
if ( $grade_type == 'point' ) {
|
2738 |
+
$grade = $passing_grade <= $result->mark;
|
2739 |
+
} elseif ( $grade_type == 'percentage' ) {
|
2740 |
+
$grade = $passing_grade <= $result->mark_percent;
|
2741 |
+
} else {
|
2742 |
+
$grade = true;
|
|
|
|
|
|
|
|
|
|
|
2743 |
}
|
2744 |
+
$grade = $grade ? 'passed' : 'failed';
|
2745 |
}
|
|
|
2746 |
return apply_filters( 'learn_press_user_quiz_graduation', $grade, $quiz_id, $course_id );
|
2747 |
}
|
2748 |
|
2756 |
* @return bool
|
2757 |
*/
|
2758 |
public function is_exists() {
|
2759 |
+
return $this->user->ID > 0;
|
2760 |
}
|
2761 |
|
2762 |
/**
|
2871 |
return apply_filters( 'learn_press_user_can_do_quiz', $can, $quiz_id, $this->id, $course_id );
|
2872 |
}
|
2873 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2874 |
public static function get_user() {
|
2875 |
_deprecated_function( __CLASS__ . '::' . __FUNCTION__, '2.0.7', 'LP_User_Factory::get_user' );
|
2876 |
$func_args = func_get_args();
|
inc/user/class-lp-user-factory.php
CHANGED
@@ -113,17 +113,16 @@ class LP_User_Factory {
|
|
113 |
* @return LP_Abstract_User
|
114 |
*/
|
115 |
public static function get_user( $the_user, $force = false ) {
|
116 |
-
$the_id = 0;
|
117 |
if ( is_numeric( $the_user ) ) {
|
118 |
$the_id = $the_user;
|
119 |
} elseif ( $the_user instanceof LP_Abstract_User ) {
|
120 |
$the_id = $the_user->id;
|
121 |
} elseif ( isset( $the_user->ID ) ) {
|
122 |
$the_id = $the_user->ID;
|
123 |
-
}
|
|
|
124 |
$the_id = get_current_user_id();
|
125 |
}
|
126 |
-
|
127 |
$user_class = self::get_user_class( $the_id );
|
128 |
if ( empty( self::$_users[$the_id] ) || $force ) {
|
129 |
self::$_users[$the_id] = new $user_class( $the_id );
|
@@ -150,7 +149,7 @@ class LP_User_Factory {
|
|
150 |
/**
|
151 |
* Prevent loading user does not exists in database
|
152 |
*/
|
153 |
-
$user
|
154 |
wp_cache_add( $the_id, $user, 'users' );
|
155 |
wp_cache_add( '', $the_id, 'userlogins' );
|
156 |
wp_cache_add( '', $the_id, 'useremail' );
|
@@ -224,12 +223,8 @@ class LP_User_Factory {
|
|
224 |
if ( get_user_by( 'id', $user_id ) ) {
|
225 |
return;
|
226 |
}
|
227 |
-
|
228 |
-
|
229 |
-
}
|
230 |
-
$item_id = !empty( $item->user_item_id ) ? $item->user_item_id : $item->history_id;
|
231 |
-
learn_press_add_user_item_meta( $item_id, 'temp_user_id', 'yes' );
|
232 |
-
learn_press_add_user_item_meta( $item_id, 'temp_user_time', date( 'Y-m-d H:i:s', time() ) );
|
233 |
}
|
234 |
}
|
235 |
|
113 |
* @return LP_Abstract_User
|
114 |
*/
|
115 |
public static function get_user( $the_user, $force = false ) {
|
|
|
116 |
if ( is_numeric( $the_user ) ) {
|
117 |
$the_id = $the_user;
|
118 |
} elseif ( $the_user instanceof LP_Abstract_User ) {
|
119 |
$the_id = $the_user->id;
|
120 |
} elseif ( isset( $the_user->ID ) ) {
|
121 |
$the_id = $the_user->ID;
|
122 |
+
}
|
123 |
+
if ( empty( $the_id ) ) {
|
124 |
$the_id = get_current_user_id();
|
125 |
}
|
|
|
126 |
$user_class = self::get_user_class( $the_id );
|
127 |
if ( empty( self::$_users[$the_id] ) || $force ) {
|
128 |
self::$_users[$the_id] = new $user_class( $the_id );
|
149 |
/**
|
150 |
* Prevent loading user does not exists in database
|
151 |
*/
|
152 |
+
$user = new LP_User_Guest( $the_id );
|
153 |
wp_cache_add( $the_id, $user, 'users' );
|
154 |
wp_cache_add( '', $the_id, 'userlogins' );
|
155 |
wp_cache_add( '', $the_id, 'useremail' );
|
223 |
if ( get_user_by( 'id', $user_id ) ) {
|
224 |
return;
|
225 |
}
|
226 |
+
learn_press_add_user_item_meta( $item->user_item_id, 'temp_user_id', 'yes' );
|
227 |
+
learn_press_add_user_item_meta( $item->user_item_id, 'temp_user_time', date( 'Y-m-d H:i:s', time() ) );
|
|
|
|
|
|
|
|
|
228 |
}
|
229 |
}
|
230 |
|
inc/user/lp-user-functions.php
CHANGED
@@ -59,7 +59,7 @@ function learn_press_get_current_user_id() {
|
|
59 |
* @return LP_User
|
60 |
*/
|
61 |
function learn_press_get_current_user( $user_id = 0 ) {
|
62 |
-
return LP_User_Factory::get_user( $user_id
|
63 |
}
|
64 |
|
65 |
/**
|
@@ -903,19 +903,9 @@ function learn_press_user_profile_picture_upload_dir( $width_user = true ) {
|
|
903 |
if ( $width_user ) {
|
904 |
$subdir .= '/' . get_current_user_id();
|
905 |
}
|
906 |
-
$subdir
|
907 |
-
|
908 |
-
|
909 |
-
$u_subdir = str_replace( '\\', '/', $upload_dir['subdir'] );
|
910 |
-
$u_path = str_replace( '\\', '/', $upload_dir['path'] );
|
911 |
-
|
912 |
-
$upload_dir['path'] = str_replace( $u_subdir, $subdir, $u_path );
|
913 |
-
$upload_dir['url'] = str_replace( $u_subdir, $subdir, $upload_dir['url'] );
|
914 |
-
} else {
|
915 |
-
$upload_dir['path'] = $upload_dir['path'] . $subdir;
|
916 |
-
$upload_dir['url'] = $upload_dir['url'] . $subdir;
|
917 |
-
}
|
918 |
-
|
919 |
$upload_dir['subdir'] = $subdir;
|
920 |
|
921 |
// Point path/url to main site if we are in multisite
|
59 |
* @return LP_User
|
60 |
*/
|
61 |
function learn_press_get_current_user( $user_id = 0 ) {
|
62 |
+
return LP_User_Factory::get_user( $user_id );
|
63 |
}
|
64 |
|
65 |
/**
|
903 |
if ( $width_user ) {
|
904 |
$subdir .= '/' . get_current_user_id();
|
905 |
}
|
906 |
+
$subdir = '/' . $subdir;
|
907 |
+
$upload_dir['path'] = str_replace( $upload_dir['subdir'], $subdir, $upload_dir['path'] );
|
908 |
+
$upload_dir['url'] = str_replace( $upload_dir['subdir'], $subdir, $upload_dir['url'] );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
909 |
$upload_dir['subdir'] = $subdir;
|
910 |
|
911 |
// Point path/url to main site if we are in multisite
|
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: 2.1.
|
8 |
Author URI: http://thimpress.com
|
9 |
Requires at least: 3.8
|
10 |
Tested up to: 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: 2.1.5.5
|
8 |
Author URI: http://thimpress.com
|
9 |
Requires at least: 3.8
|
10 |
Tested up to: 4.7
|
readme.txt
CHANGED
@@ -1,10 +1,10 @@
|
|
1 |
=== LearnPress - WordPress LMS Plugin ===
|
2 |
-
Contributors: thimpress, tunnhn, phonglq.foobla,
|
3 |
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.7
|
7 |
-
Stable tag: 2.1.
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
@@ -193,20 +193,6 @@ https://www.transifex.com/projects/p/learnpress/
|
|
193 |
8. Add-ons of LearnPress.
|
194 |
|
195 |
== Changelog ==
|
196 |
-
= 2.1.6.1 =
|
197 |
-
+ Removed cache-flush param
|
198 |
-
+ Added some filters for evaluating course results
|
199 |
-
+ Fixed js unreachable code
|
200 |
-
+ Fixed warning message on update post
|
201 |
-
|
202 |
-
= 2.1.6 =
|
203 |
-
+ Add more options for course results
|
204 |
-
+ Made 'Show correct answer' option depending on 'Show/Hide questions'
|
205 |
-
+ Fixed process fields are added by filter for become a teacher form
|
206 |
-
+ Fixed wrong user profile url
|
207 |
-
+ Fixed user avatar can not save in profile
|
208 |
-
+ Remove related data after removing posts
|
209 |
-
|
210 |
= 2.1.5.5 =
|
211 |
+ Fixed issue with slug of course page is the same with slug of course tab in profile
|
212 |
+ Fixed issue with metabox show/hide field
|
1 |
=== LearnPress - WordPress LMS Plugin ===
|
2 |
+
Contributors: thimpress, tunnhn, phonglq.foobla, thongta, kendy73, leehld
|
3 |
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.7
|
7 |
+
Stable tag: 2.1.5.5
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
193 |
8. Add-ons of LearnPress.
|
194 |
|
195 |
== Changelog ==
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
196 |
= 2.1.5.5 =
|
197 |
+ Fixed issue with slug of course page is the same with slug of course tab in profile
|
198 |
+ Fixed issue with metabox show/hide field
|
templates/content-quiz/buttons.php
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
*
|
5 |
* @author ThimPress
|
6 |
* @package LearnPress/Templates
|
7 |
-
* @version 2.
|
8 |
*/
|
9 |
|
10 |
if ( !defined( 'ABSPATH' ) ) {
|
@@ -18,11 +18,7 @@ if ( !$quiz ) {
|
|
18 |
}
|
19 |
|
20 |
if ( $user->has( 'finished-course', $course->id ) ) {
|
21 |
-
|
22 |
-
return;
|
23 |
-
}
|
24 |
-
|
25 |
-
if ( !$quiz->has( 'questions' ) ) {
|
26 |
return;
|
27 |
}
|
28 |
|
4 |
*
|
5 |
* @author ThimPress
|
6 |
* @package LearnPress/Templates
|
7 |
+
* @version 2.0.7
|
8 |
*/
|
9 |
|
10 |
if ( !defined( 'ABSPATH' ) ) {
|
18 |
}
|
19 |
|
20 |
if ( $user->has( 'finished-course', $course->id ) ) {
|
21 |
+
learn_press_display_message( __( 'You have already finished course but have not started this quiz.', 'learnpress' ) );
|
|
|
|
|
|
|
|
|
22 |
return;
|
23 |
}
|
24 |
|
templates/global/become-teacher-form.php
CHANGED
@@ -13,10 +13,7 @@ $submit_button_process_text = __( 'Submitting...', 'learnpress' );
|
|
13 |
$submit_button_text = __( 'Submit', 'learnpress' );
|
14 |
?>
|
15 |
<div id="learn-press-become-teacher-form" class="learn-press-become-teacher-form">
|
16 |
-
<?php
|
17 |
-
learn_press_display_message( $message );
|
18 |
-
}
|
19 |
-
?>
|
20 |
<?php if ( !learn_press_become_teacher_sent() ): ?>
|
21 |
<form id="<?php echo $form_id; ?>" name="become-teacher-form" method="<?php echo $method; ?>" enctype="multipart/form-data" action="<?php echo $action; ?>">
|
22 |
<?php if ( $fields ): ?>
|
@@ -63,4 +60,4 @@ $submit_button_text = __( 'Submit', 'learnpress' );
|
|
63 |
<?php endif; ?>
|
64 |
</form>
|
65 |
<?php endif; ?>
|
66 |
-
</div>
|
13 |
$submit_button_text = __( 'Submit', 'learnpress' );
|
14 |
?>
|
15 |
<div id="learn-press-become-teacher-form" class="learn-press-become-teacher-form">
|
16 |
+
<?php learn_press_display_message( $message ); ?>
|
|
|
|
|
|
|
17 |
<?php if ( !learn_press_become_teacher_sent() ): ?>
|
18 |
<form id="<?php echo $form_id; ?>" name="become-teacher-form" method="<?php echo $method; ?>" enctype="multipart/form-data" action="<?php echo $action; ?>">
|
19 |
<?php if ( $fields ): ?>
|
60 |
<?php endif; ?>
|
61 |
</form>
|
62 |
<?php endif; ?>
|
63 |
+
</div>
|
templates/profile/tabs/edit.php
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
*
|
5 |
* @author ThimPress
|
6 |
* @package LearnPress/Templates
|
7 |
-
* @version 2.1.
|
8 |
*/
|
9 |
if ( !defined( 'ABSPATH' ) ) {
|
10 |
exit;
|
@@ -49,16 +49,8 @@ $first_tab = 'basic-information';
|
|
49 |
<?php endforeach; ?>
|
50 |
</ul>
|
51 |
<div class="learn-press-subtab-content user-profile-section-content">
|
52 |
-
<?php
|
53 |
-
|
54 |
-
if ( $section && file_exists( $section_template ) ) {
|
55 |
-
?>
|
56 |
-
<?php include $section_template; ?>
|
57 |
-
<input type="hidden" name="lp-profile-section" value="<?php echo $section; ?>" />
|
58 |
-
<?php } else {
|
59 |
-
?>
|
60 |
-
<?php learn_press_display_message( __( 'The section you are trying to access does not exists.', 'learnpress' ) ); ?>
|
61 |
-
<?php } ?>
|
62 |
</div>
|
63 |
|
64 |
<input type="hidden" name="user_id" id="user_id" value="<?php echo esc_attr( $user->id ); ?>" />
|
4 |
*
|
5 |
* @author ThimPress
|
6 |
* @package LearnPress/Templates
|
7 |
+
* @version 2.1.1
|
8 |
*/
|
9 |
if ( !defined( 'ABSPATH' ) ) {
|
10 |
exit;
|
49 |
<?php endforeach; ?>
|
50 |
</ul>
|
51 |
<div class="learn-press-subtab-content user-profile-section-content">
|
52 |
+
<?php include learn_press_locate_template( 'profile/tabs/edit/' . $section . '.php' ); ?>
|
53 |
+
<input type="hidden" name="lp-profile-section" value="<?php echo $section; ?>" />
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
54 |
</div>
|
55 |
|
56 |
<input type="hidden" name="user_id" id="user_id" value="<?php echo esc_attr( $user->id ); ?>" />
|
templates/single-course/buttons.php
CHANGED
@@ -4,87 +4,118 @@
|
|
4 |
*
|
5 |
* @author ThimPress
|
6 |
* @package LearnPress/Templates
|
7 |
-
* @version 2.
|
8 |
*/
|
9 |
|
10 |
-
if ( !defined( 'ABSPATH' ) ) {
|
11 |
exit; // Exit if accessed directly
|
12 |
}
|
13 |
|
14 |
$course = LP()->global['course'];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
?>
|
16 |
<div class="learn-press-course-buttons">
|
|
|
17 |
<?php do_action( 'learn_press_before_course_buttons', $course->id ); ?>
|
|
|
18 |
<?php
|
19 |
-
|
20 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
?>
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
<?php
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
# -------------------------------
|
58 |
-
# Enrolled Course
|
59 |
-
# -------------------------------
|
60 |
-
elseif ( $user->has( 'enrolled-course', $course->id ) ): ?>
|
61 |
-
<?php
|
62 |
-
$can_finish = $user->can_finish_course( $course->id );
|
63 |
-
//if ( $can_finish ) {
|
64 |
-
$finish_course_security = wp_create_nonce( sprintf( 'learn-press-finish-course-' . $course->id . '-' . $user->id ) );
|
65 |
-
//} else {
|
66 |
-
//$finish_course_security = '';
|
67 |
-
//}
|
68 |
-
?>
|
69 |
-
<button
|
70 |
-
id="learn-press-finish-course"
|
71 |
-
class="button-finish-course<?php echo !$can_finish ? ' hide-if-js' : ''; ?>"
|
72 |
-
data-id="<?php echo esc_attr( $course->id ); ?>"
|
73 |
-
data-security="<?php echo esc_attr( $finish_course_security ); ?>">
|
74 |
-
<?php esc_html_e( 'Finish course', 'learnpress' ); ?>
|
75 |
</button>
|
76 |
-
|
77 |
-
<
|
78 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
79 |
|
80 |
-
|
81 |
-
|
82 |
-
<button class="button enroll-button" data-block-content="yes"><?php echo $enroll_button_text; ?></button>
|
83 |
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
|
|
|
88 |
<form name="purchase-course" class="purchase-course" method="post" enctype="multipart/form-data">
|
89 |
<?php do_action( 'learn_press_before_purchase_button' ); ?>
|
90 |
<button class="button purchase-button" data-block-content="yes">
|
@@ -92,32 +123,26 @@ $course = LP()->global['course'];
|
|
92 |
</button>
|
93 |
<?php do_action( 'learn_press_after_purchase_button' ); ?>
|
94 |
<input type="hidden" name="purchase-course" value="<?php echo $course->id; ?>" />
|
95 |
-
<input type="hidden" value="user
|
|
|
96 |
</form>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
97 |
|
98 |
-
<?php elseif ( $user->can( 'enroll-course', $course->id ) === 'enough' ) : ?>
|
99 |
-
<p class="learn-press-message"><?php echo $notice_enough_student; ?></p>
|
100 |
-
<?php else: ?>
|
101 |
-
<?php $order_status = $user->get_order_status( $course->id ); ?>
|
102 |
-
<?php if ( in_array( $order_status, array( 'lp-pending', 'lp-refunded', 'lp-cancelled', 'lp-failed' ) ) ) { ?>
|
103 |
-
<form name="purchase-course" class="purchase-course" method="post" enctype="multipart/form-data">
|
104 |
-
<?php do_action( 'learn_press_before_purchase_button' ); ?>
|
105 |
-
<button class="button purchase-button" data-block-content="yes">
|
106 |
-
<?php echo $course->is_free() ? $enroll_button_text : $purchase_button_text; ?>
|
107 |
-
</button>
|
108 |
-
<?php do_action( 'learn_press_after_purchase_button' ); ?>
|
109 |
-
<input type="hidden" name="purchase-course" value="<?php echo $course->id; ?>" />
|
110 |
-
<input type="hidden" value="user order cancelled" />
|
111 |
-
|
112 |
-
</form>
|
113 |
-
<?php } elseif ( in_array( $order_status, array( 'lp-processing', 'lp-on-hold' ) ) ) { ?>
|
114 |
-
<?php learn_press_display_message( '<p>' . apply_filters( 'learn_press_user_course_pending_message', __( 'You have purchased this course. Please wait for approval.', 'learnpress' ), $course, $user ) . '</p>' ); ?>
|
115 |
-
<?php } elseif ( $order_status && $order_status != 'lp-completed' ) { ?>
|
116 |
-
<?php learn_press_display_message( '<p>' . apply_filters( 'learn_press_user_can_not_purchase_course_message', __( 'Sorry, you can not purchase this course', 'learnpress' ), $course, $user ) . '</p>' ); ?>
|
117 |
-
<?php } ?>
|
118 |
-
<?php endif;
|
119 |
-
}
|
120 |
-
endif;
|
121 |
-
?>
|
122 |
<?php do_action( 'learn_press_after_course_buttons', $course->id ); ?>
|
|
|
123 |
</div>
|
4 |
*
|
5 |
* @author ThimPress
|
6 |
* @package LearnPress/Templates
|
7 |
+
* @version 2.0.6
|
8 |
*/
|
9 |
|
10 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
11 |
exit; // Exit if accessed directly
|
12 |
}
|
13 |
|
14 |
$course = LP()->global['course'];
|
15 |
+
|
16 |
+
if ( ! $course->is_required_enroll() ) {
|
17 |
+
return;
|
18 |
+
}
|
19 |
+
|
20 |
+
$course_status = learn_press_get_user_course_status();
|
21 |
+
$user = learn_press_get_current_user();
|
22 |
+
$in_cart = learn_press_is_added_to_cart( $course->id );
|
23 |
+
// only show enroll button if user had not enrolled
|
24 |
+
$purchase_button_text = apply_filters( 'learn_press_purchase_button_text', __( 'Buy this course', 'learnpress' ) );
|
25 |
+
$enroll_button_text = apply_filters( 'learn_press_enroll_button_text', __( 'Enroll', 'learnpress' ) );
|
26 |
+
$retake_button_text = apply_filters( 'learn_press_retake_button_text', __( 'Retake', 'learnpress' ) );
|
27 |
+
$notice_enough_student = apply_filters( 'learn_press_course enough students_notice', __( 'The class is full so the enrollment is close. Please contact the site admin.', 'learnpress' ) );
|
28 |
+
$external_link_buy_course = apply_filters( 'learn_press_external_link_buy_course', $course->external_link_buy_course, $course, $user );
|
29 |
?>
|
30 |
<div class="learn-press-course-buttons">
|
31 |
+
|
32 |
<?php do_action( 'learn_press_before_course_buttons', $course->id ); ?>
|
33 |
+
|
34 |
<?php
|
35 |
+
|
36 |
+
# -------------------------------
|
37 |
+
# Finished Course
|
38 |
+
# -------------------------------
|
39 |
+
if ( $user->has( 'finished-course', $course->id ) ): ?>
|
40 |
+
<?php if ( $count = $user->can( 'retake-course', $course->id ) ): ?>
|
41 |
+
<button
|
42 |
+
class="button button-retake-course"
|
43 |
+
data-course_id="<?php echo esc_attr( $course->id ); ?>"
|
44 |
+
data-security="<?php echo esc_attr( wp_create_nonce( sprintf( 'learn-press-retake-course-%d-%d', $course->id, $user->id ) ) ); ?>">
|
45 |
+
<?php echo esc_html( sprintf( __( 'Retake course (+%d)', 'learnpress' ), $count ) ); ?>
|
46 |
+
</button>
|
47 |
+
<?php endif; ?>
|
48 |
+
<?php
|
49 |
+
|
50 |
+
# -------------------------------
|
51 |
+
# Enrolled Course
|
52 |
+
# -------------------------------
|
53 |
+
elseif ( $user->has( 'enrolled-course', $course->id ) ): ?>
|
54 |
+
<?php
|
55 |
+
$can_finish = $user->can_finish_course( $course->id );
|
56 |
+
//if ( $can_finish ) {
|
57 |
+
$finish_course_security = wp_create_nonce( sprintf( 'learn-press-finish-course-' . $course->id . '-' . $user->id ) );
|
58 |
+
//} else {
|
59 |
+
//$finish_course_security = '';
|
60 |
+
//}
|
61 |
?>
|
62 |
+
<button
|
63 |
+
id="learn-press-finish-course"
|
64 |
+
class="button-finish-course<?php echo ! $can_finish ? ' hide-if-js' : ''; ?>"
|
65 |
+
data-id="<?php echo esc_attr( $course->id ); ?>"
|
66 |
+
data-security="<?php echo esc_attr( $finish_course_security ); ?>">
|
67 |
+
<?php esc_html_e( 'Finish course', 'learnpress' ); ?>
|
68 |
+
</button>
|
69 |
+
<?php elseif ( $user->can( 'enroll-course', $course->id ) === true ) : ?>
|
70 |
+
<?php if ( !empty( $external_link_buy_course ) && $user->can( 'purchase-course', $course->id ) ) : ?>
|
71 |
+
<?php do_action( 'learn_press_before_external_link_buy_course' ); ?>
|
72 |
+
<div class="purchase-course">
|
73 |
+
<a href="<?php echo esc_url($external_link_buy_course); ?>" class="button purchase-button">
|
74 |
+
<?php echo $purchase_button_text; ?>
|
75 |
+
</a>
|
76 |
+
</div>
|
77 |
+
<?php do_action( 'learn_press_after_external_link_buy_course' ); ?>
|
78 |
+
<?php else : ?>
|
79 |
+
<form name="enroll-course" class="enroll-course" method="post" enctype="multipart/form-data">
|
80 |
+
<?php do_action( 'learn_press_before_enroll_button' ); ?>
|
81 |
+
|
82 |
+
<input type="hidden" name="lp-ajax" value="enroll-course" />
|
83 |
+
<input type="hidden" name="enroll-course" value="<?php echo $course->id; ?>" />
|
84 |
+
<button class="button enroll-button" data-block-content="yes"><?php echo $enroll_button_text; ?></button>
|
85 |
+
|
86 |
+
<?php do_action( 'learn_press_after_enroll_button' ); ?>
|
87 |
+
</form>
|
88 |
+
<?php endif; ?>
|
89 |
+
<?php elseif ( $user->can( 'purchase-course', $course->id ) ) : ?>
|
90 |
+
|
91 |
+
<?php if ( empty( $external_link_buy_course ) ) : ?>
|
92 |
+
<form name="purchase-course" class="purchase-course" method="post" enctype="multipart/form-data">
|
93 |
+
<?php do_action( 'learn_press_before_purchase_button' ); ?>
|
94 |
+
<button class="button purchase-button" data-block-content="yes">
|
95 |
+
<?php echo $course->is_free() ? $enroll_button_text : $purchase_button_text; ?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
96 |
</button>
|
97 |
+
<?php do_action( 'learn_press_after_purchase_button' ); ?>
|
98 |
+
<input type="hidden" name="purchase-course" value="<?php echo $course->id; ?>" />
|
99 |
+
<input type="hidden" value="user can purchase course" />
|
100 |
+
</form>
|
101 |
+
<?php else : ?>
|
102 |
+
<?php do_action( 'learn_press_before_external_link_buy_course' ); ?>
|
103 |
+
<div class="purchase-course">
|
104 |
+
<a href="<?php echo esc_url($external_link_buy_course); ?>" class="button purchase-button">
|
105 |
+
<?php echo $purchase_button_text; ?>
|
106 |
+
</a>
|
107 |
+
</div>
|
108 |
+
<?php do_action( 'learn_press_after_external_link_buy_course' ); ?>
|
109 |
+
<?php endif; ?>
|
110 |
|
111 |
+
<?php elseif ( $user->can( 'enroll-course', $course->id ) === 'enough' ) : ?>
|
112 |
+
<p class="learn-press-message"><?php echo $notice_enough_student; ?></p>
|
|
|
113 |
|
114 |
+
<?php else: ?>
|
115 |
+
<?php $order_status = $user->get_order_status( $course->id ); ?>
|
116 |
+
<?php if ( in_array( $order_status, array( 'lp-pending', 'lp-refunded', 'lp-cancelled', 'lp-failed' ) ) ) { ?>
|
117 |
|
118 |
+
<?php if ( empty( $external_link_buy_course ) ) : ?>
|
119 |
<form name="purchase-course" class="purchase-course" method="post" enctype="multipart/form-data">
|
120 |
<?php do_action( 'learn_press_before_purchase_button' ); ?>
|
121 |
<button class="button purchase-button" data-block-content="yes">
|
123 |
</button>
|
124 |
<?php do_action( 'learn_press_after_purchase_button' ); ?>
|
125 |
<input type="hidden" name="purchase-course" value="<?php echo $course->id; ?>" />
|
126 |
+
<input type="hidden" value="user order cancelled" />
|
127 |
+
|
128 |
</form>
|
129 |
+
<?php else : ?>
|
130 |
+
<?php do_action( 'learn_press_before_external_link_buy_course' ); ?>
|
131 |
+
<div class="purchase-course">
|
132 |
+
<a href="<?php echo esc_url($external_link_buy_course); ?>" class="button purchase-button">
|
133 |
+
<?php echo $purchase_button_text; ?>
|
134 |
+
</a>
|
135 |
+
</div>
|
136 |
+
<?php do_action( 'learn_press_after_external_link_buy_course' ); ?>
|
137 |
+
<?php endif; ?>
|
138 |
+
|
139 |
+
<?php } elseif ( in_array( $order_status, array( 'lp-processing', 'lp-on-hold' ) ) ) { ?>
|
140 |
+
<?php learn_press_display_message( '<p>' . apply_filters( 'learn_press_user_course_pending_message', __( 'You have purchased this course. Please wait for approval.', 'learnpress' ), $course, $user ) . '</p>' ); ?>
|
141 |
+
<?php } elseif ( $order_status && $order_status != 'lp-completed' ) { ?>
|
142 |
+
<?php learn_press_display_message( '<p>' . apply_filters( 'learn_press_user_can_not_purchase_course_message', __( 'Sorry, you can not purchase this course', 'learnpress' ), $course, $user ) . '</p>' ); ?>
|
143 |
+
<?php } ?>
|
144 |
+
<?php endif; ?>
|
145 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
146 |
<?php do_action( 'learn_press_after_course_buttons', $course->id ); ?>
|
147 |
+
|
148 |
</div>
|
templates/single-course/content-item-only.php
CHANGED
@@ -28,6 +28,7 @@ if ( !empty( $_REQUEST['done-action'] ) ) {
|
|
28 |
}
|
29 |
}
|
30 |
$data = array_merge( $user->get_course_info2( get_the_ID() ), $data );
|
|
|
31 |
?>
|
32 |
<style type="text/css">
|
33 |
html{
|
28 |
}
|
29 |
}
|
30 |
$data = array_merge( $user->get_course_info2( get_the_ID() ), $data );
|
31 |
+
|
32 |
?>
|
33 |
<style type="text/css">
|
34 |
html{
|
templates/single-course/nav-items.php
CHANGED
@@ -10,7 +10,6 @@
|
|
10 |
defined( 'ABSPATH' ) || exit;
|
11 |
|
12 |
$nav = learn_press_get_nav_course_item_url( $course_id, $item_id, $content_only );
|
13 |
-
|
14 |
?>
|
15 |
<nav id="lp-navigation" class="navigation course-item-navigation" role="navigation">
|
16 |
<div class="nav-links">
|
10 |
defined( 'ABSPATH' ) || exit;
|
11 |
|
12 |
$nav = learn_press_get_nav_course_item_url( $course_id, $item_id, $content_only );
|
|
|
13 |
?>
|
14 |
<nav id="lp-navigation" class="navigation course-item-navigation" role="navigation">
|
15 |
<div class="nav-links">
|
templates/single-course/progress.php
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
/**
|
3 |
* @author ThimPress
|
4 |
* @package LearnPress/Templates
|
5 |
-
* @version 2.
|
6 |
*/
|
7 |
|
8 |
defined( 'ABSPATH' ) || exit();
|
@@ -45,19 +45,21 @@ $course_results = $course->evaluate_course_results();
|
|
45 |
<div class="course-progress">
|
46 |
<h4 class="lp-course-progress-heading">
|
47 |
<?php esc_html_e( 'Course results', 'learnpress' ); ?>
|
48 |
-
<?php
|
49 |
-
|
50 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
51 |
</h4>
|
52 |
-
<div
|
53 |
-
<span class="number"><?php echo $current
|
54 |
-
<?php if ( $grade = $user->get_course_grade( $course->id ) ) { ?>
|
55 |
-
<span class="grade <?php echo esc_attr( $grade ); ?>">
|
56 |
-
<?php learn_press_course_grade_html( $grade ); ?>
|
57 |
-
</span>
|
58 |
-
<?php } ?>
|
59 |
</div>
|
60 |
-
<div class="lp-course-progress
|
61 |
data-passing-condition="<?php echo $passing_condition; ?>">
|
62 |
<div class="lp-progress-bar">
|
63 |
<div class="lp-progress-value" style="width: <?php echo $current; ?>%;">
|
@@ -69,4 +71,7 @@ $course_results = $course->evaluate_course_results();
|
|
69 |
</div>
|
70 |
</div>
|
71 |
</div>
|
|
|
|
|
|
|
72 |
</div>
|
2 |
/**
|
3 |
* @author ThimPress
|
4 |
* @package LearnPress/Templates
|
5 |
+
* @version 2.0.4
|
6 |
*/
|
7 |
|
8 |
defined( 'ABSPATH' ) || exit();
|
45 |
<div class="course-progress">
|
46 |
<h4 class="lp-course-progress-heading">
|
47 |
<?php esc_html_e( 'Course results', 'learnpress' ); ?>
|
48 |
+
<?php
|
49 |
+
if ( $course->is_evaluation( 'evaluate_final_quiz' ) ) {
|
50 |
+
$tooltip = __( "Evaluated by results of final quiz", 'learnpress' );
|
51 |
+
} elseif ( $course->is_evaluation( 'evaluate_quizzes' ) ) {
|
52 |
+
$tooltip = __( "Evaluated by average results of quizzes", 'learnpress' );
|
53 |
+
} else {
|
54 |
+
$tooltip = __( "Evaluated by items completed", 'learnpress' );
|
55 |
+
}
|
56 |
+
?>
|
57 |
+
<span class="learn-press-tooltip" data-content="<?php echo esc_html( $tooltip ); ?>"></span>
|
58 |
</h4>
|
59 |
+
<div>
|
60 |
+
<span class="number"><?php echo $current ?></span><span class="percentage-sign">%</span>
|
|
|
|
|
|
|
|
|
|
|
61 |
</div>
|
62 |
+
<div class="lp-course-progress<?php echo $passed ? ' passed' : ''; ?>" data-value="<?php echo $current; ?>"
|
63 |
data-passing-condition="<?php echo $passing_condition; ?>">
|
64 |
<div class="lp-progress-bar">
|
65 |
<div class="lp-progress-value" style="width: <?php echo $current; ?>%;">
|
71 |
</div>
|
72 |
</div>
|
73 |
</div>
|
74 |
+
<?php /*if ($user->has_enrolled_course($course->id)): ?>
|
75 |
+
<?php learn_press_get_template('single-course/buttons.php'); ?>
|
76 |
+
<?php endif;*/ ?>
|
77 |
</div>
|
templates/single-course/section/item-meta.php
CHANGED
@@ -2,80 +2,47 @@
|
|
2 |
/**
|
3 |
* @author ThimPress
|
4 |
* @package LearnPress/Templates
|
5 |
-
* @version 2.1.
|
6 |
*/
|
7 |
|
8 |
defined( 'ABSPATH' ) || exit();
|
9 |
|
10 |
$user = learn_press_get_current_user();
|
11 |
$course = LP()->global['course'];
|
|
|
|
|
12 |
$course_item = $course->get_item( $item->ID );
|
13 |
-
|
14 |
$status = $user->get_course_status( $course->id );
|
15 |
-
$item_status = $user->get_item_status( $item->ID );
|
16 |
-
|
17 |
-
$security = wp_create_nonce( sprintf( 'complete-item-%d-%d-%d', $user->id, $course->id, $item->ID ) );
|
18 |
-
|
19 |
-
$result = $user->get_quiz_results( $item->ID );
|
20 |
-
$has_result = false;
|
21 |
-
if ( in_array( $item_status, array( 'completed', 'started' ) ) ) {
|
22 |
-
$has_result = true;
|
23 |
-
}
|
24 |
?>
|
25 |
<div class="course-item-meta">
|
26 |
<?php do_action( 'learn_press_before_item_meta', $item ); ?>
|
27 |
<?php if ( $status != 'enrolled' && $course_item->is_preview() && $course->is_required_enroll() ): ?>
|
28 |
<span class="lp-label lp-label-preview"><?php _e( 'Preview', 'learnpress' ); ?></span>
|
29 |
<?php endif; ?>
|
30 |
-
<?php
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
}
|
40 |
-
?>
|
41 |
-
<span class="item-loop-meta-text item-result"><?php echo $result_text; ?></span>
|
42 |
-
|
43 |
<?php
|
44 |
-
|
45 |
-
|
46 |
-
}
|
47 |
-
if ( $item_status == 'completed' ) {
|
48 |
-
$grade = $user->get_quiz_graduation( $course_item->id, $course->id );
|
49 |
-
if ( $grade === 'passed' ) {
|
50 |
-
?>
|
51 |
-
<span class="lp-icon item-status item-status-passed" title="<?php esc_attr_e( 'Passed', 'learnpress' ); ?>"></span><?php
|
52 |
-
} else {
|
53 |
-
?>
|
54 |
-
<span class="lp-icon item-status item-status-failed" title="<?php esc_attr_e( 'Failed', 'learnpress' ); ?>"></span><?php
|
55 |
-
}
|
56 |
-
} elseif ( $item_status == 'viewed' ) {
|
57 |
-
?>
|
58 |
-
<span class="lp-icon item-status item-status-viewed" title="<?php esc_attr_e( 'Viewed', 'learnpress' ); ?>"></span><?php
|
59 |
-
} elseif ( $item_status == 'started' ) {
|
60 |
-
?>
|
61 |
-
<span class="lp-icon item-status item-status-started" title="<?php esc_attr_e( 'In Progress', 'learnpress' ); ?>"></span><?php
|
62 |
-
}
|
63 |
-
} else {
|
64 |
-
if ( $item_status == 'completed' ) {
|
65 |
?>
|
66 |
<span class="lp-icon item-status item-status-passed" title="<?php esc_attr_e( 'Completed', 'learnpress' ); ?>"></span>
|
67 |
<?php
|
68 |
-
}
|
69 |
-
|
70 |
-
<?php
|
71 |
-
}
|
72 |
-
}
|
73 |
-
|
74 |
-
|
75 |
-
<span class="lp-icon item-status"></span>
|
76 |
-
|
77 |
-
|
78 |
-
}
|
79 |
-
?>
|
80 |
<?php do_action( 'learn_press_after_item_meta', $item ); ?>
|
81 |
</div>
|
2 |
/**
|
3 |
* @author ThimPress
|
4 |
* @package LearnPress/Templates
|
5 |
+
* @version 2.1.4
|
6 |
*/
|
7 |
|
8 |
defined( 'ABSPATH' ) || exit();
|
9 |
|
10 |
$user = learn_press_get_current_user();
|
11 |
$course = LP()->global['course'];
|
12 |
+
$item_status = $user->get_item_status( $item->ID );
|
13 |
+
$security = wp_create_nonce( sprintf( 'complete-item-%d-%d-%d', $user->id, $course->id, $item->ID ) );
|
14 |
$course_item = $course->get_item( $item->ID );
|
|
|
15 |
$status = $user->get_course_status( $course->id );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
16 |
?>
|
17 |
<div class="course-item-meta">
|
18 |
<?php do_action( 'learn_press_before_item_meta', $item ); ?>
|
19 |
<?php if ( $status != 'enrolled' && $course_item->is_preview() && $course->is_required_enroll() ): ?>
|
20 |
<span class="lp-label lp-label-preview"><?php _e( 'Preview', 'learnpress' ); ?></span>
|
21 |
<?php endif; ?>
|
22 |
+
<?php if ( $user->can_view_item( $item->ID, $course->id ) !== false ) { ?>
|
23 |
+
<?php if ( $item->post_type == 'lp_quiz' ) { ?>
|
24 |
+
<span class="item-loop-meta-text item-result">
|
25 |
+
<?php if ( $result = $user->get_quiz_results( $item->ID ) ): ?>
|
26 |
+
<?php echo sprintf( '%d%%', round( $result->mark_percent ) ); ?>
|
27 |
+
<?php endif; ?>
|
28 |
+
</span>
|
29 |
+
<?php } ?>
|
30 |
+
<?php if ( $item_status == 'completed' ) { ?>
|
|
|
|
|
|
|
|
|
31 |
<?php
|
32 |
+
$grade = $user->get_quiz_graduation( $course_item->id, $course->id );
|
33 |
+
if ( $grade === 'passed' ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
34 |
?>
|
35 |
<span class="lp-icon item-status item-status-passed" title="<?php esc_attr_e( 'Completed', 'learnpress' ); ?>"></span>
|
36 |
<?php
|
37 |
+
} else {
|
38 |
+
?>
|
39 |
+
<span class="lp-icon item-status item-status-failed" title="<?php esc_attr_e( 'Failed', 'learnpress' ); ?>"></span>
|
40 |
+
<?php } ?>
|
41 |
+
<?php } elseif ( $item_status == 'started' ) { ?>
|
42 |
+
<span class="lp-icon item-status button-complete-item button-complete-lesson" data-security="<?php echo esc_attr( $security ); ?>" title="<?php esc_attr_e( 'Not Completed', 'learnpress' ); ?>"></span>
|
43 |
+
<?php } else { ?>
|
44 |
+
<span class="lp-icon item-status button-complete-item button-complete-lesson" data-security="<?php echo esc_attr( $security ); ?>" title="<?php esc_attr_e( 'Not Started', 'learnpress' ); ?>"></span>
|
45 |
+
<?php } ?>
|
46 |
+
<?php } ?>
|
|
|
|
|
47 |
<?php do_action( 'learn_press_after_item_meta', $item ); ?>
|
48 |
</div>
|
templates/single-course/section/item-quiz.php
CHANGED
@@ -2,46 +2,22 @@
|
|
2 |
/**
|
3 |
* @author ThimPress
|
4 |
* @package LearnPress/Templates
|
5 |
-
* @version
|
6 |
*/
|
7 |
|
8 |
if ( !defined( 'ABSPATH' ) ) {
|
9 |
exit; // Exit if accessed directly
|
10 |
}
|
11 |
-
$
|
12 |
-
$
|
13 |
-
$
|
14 |
-
$
|
15 |
-
$
|
16 |
-
$
|
17 |
-
$item_link = $viewable ? 'href="' . $course->get_item_link( $item->ID ) . '"' : '';
|
18 |
-
$item_status = $user->get_item_status( $item->ID );
|
19 |
-
$result = $user->get_quiz_results( $item->ID );
|
20 |
-
$has_result = false;
|
21 |
-
if ( in_array( $item_status, array( 'completed', 'started' ) ) ) {
|
22 |
-
$has_result = true;
|
23 |
-
}
|
24 |
-
$class = '';
|
25 |
-
if ( $has_result ) {
|
26 |
-
$class = 'item-has-result';
|
27 |
-
}
|
28 |
?>
|
29 |
|
30 |
-
<li <?php learn_press_course_item_class( $item->ID
|
31 |
<?php do_action( 'learn_press_before_section_item_title', $item, $section, $course ); ?>
|
32 |
-
|
33 |
-
<?php
|
34 |
-
printf(
|
35 |
-
'<%s class="%s" target="%s" data-id="%d" %s>%s</%s>',
|
36 |
-
$tag,
|
37 |
-
'course-item-title button-load-item',
|
38 |
-
$target,
|
39 |
-
$item->ID,
|
40 |
-
$item_link,
|
41 |
-
$item_title,
|
42 |
-
$tag
|
43 |
-
);
|
44 |
-
?>
|
45 |
-
<!--<<?php echo $tag; ?> class="course-item-title button-load-item" target="<?php echo $target; ?>" <?php echo $item_link; ?> data-id="<?php echo $item->ID; ?>"><?php echo $item_title ?></<?php echo $tag; ?>>-->
|
46 |
<?php do_action( 'learn_press_after_section_item_title', $item, $section, $course ); ?>
|
47 |
</li>
|
2 |
/**
|
3 |
* @author ThimPress
|
4 |
* @package LearnPress/Templates
|
5 |
+
* @version 1.0
|
6 |
*/
|
7 |
|
8 |
if ( !defined( 'ABSPATH' ) ) {
|
9 |
exit; // Exit if accessed directly
|
10 |
}
|
11 |
+
$course = LP()->global['course'];
|
12 |
+
$viewable = learn_press_user_can_view_quiz( $item->ID, $course->id );//learn_press_is_enrolled_course();
|
13 |
+
$tag = $viewable ? 'a' : 'span';
|
14 |
+
$target = apply_filters( 'learn_press_section_item_link_target', '_blank', $item );
|
15 |
+
$item_title = apply_filters( 'learn_press_section_item_title', get_the_title( $item->ID ), $item );
|
16 |
+
$item_link = $viewable ? 'href="' . $course->get_item_link( $item->ID ) . '"' : '';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
17 |
?>
|
18 |
|
19 |
+
<li <?php learn_press_course_item_class( $item->ID ); ?> data-type="<?php echo $item->post_type; ?>">
|
20 |
<?php do_action( 'learn_press_before_section_item_title', $item, $section, $course ); ?>
|
21 |
+
<<?php echo $tag; ?> class="course-item-title button-load-item" target="<?php echo $target; ?>" <?php echo $item_link; ?> data-id="<?php echo $item->ID; ?>"><?php echo $item_title ?></<?php echo $tag; ?>>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
22 |
<?php do_action( 'learn_press_after_section_item_title', $item, $section, $course ); ?>
|
23 |
</li>
|
templates/single-course/section/title.php
CHANGED
@@ -22,7 +22,7 @@ if ( $section_name === false ) {
|
|
22 |
<?php if ( $section_description = apply_filters( 'learn_press_curriculum_section_description', $section->section_description, $section ) ) { ?>
|
23 |
<p><?php echo $section_description; ?></p>
|
24 |
<?php } ?>
|
25 |
-
|
26 |
<span class="step"><?php printf( __( '%d/%d', 'learnpress' ), $user->get_completed_items_in_section( $course->id, $section->section_id, $force ), sizeof( $section->items ) ); ?></span>
|
27 |
<span class="collapse"></span>
|
28 |
</span>
|
22 |
<?php if ( $section_description = apply_filters( 'learn_press_curriculum_section_description', $section->section_description, $section ) ) { ?>
|
23 |
<p><?php echo $section_description; ?></p>
|
24 |
<?php } ?>
|
25 |
+
<span class="meta">
|
26 |
<span class="step"><?php printf( __( '%d/%d', 'learnpress' ), $user->get_completed_items_in_section( $course->id, $section->section_id, $force ), sizeof( $section->items ) ); ?></span>
|
27 |
<span class="collapse"></span>
|
28 |
</span>
|