PluginProbe
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses / 4.1.6.9.1
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses v4.1.6.9.1
4.4.8 4.4.7 4.4.6 4.4.5 4.4.4 4.4.3 4.4.2 4.4.1 4.4.0 4.3.9.1 4.3.9 4.3.8 4.3.7 4.1.6.9 4.1.6.9.1 4.1.6.9.2 4.1.6.9.3 4.1.6.9.4 4.1.7 4.1.7.1 4.1.7.2 4.1.7.3 4.1.7.3.1 4.1.7.3.2 4.2.0 All 139 releases
learnpress / inc / admin / views / tools / course / html-user.php

html-user.php in LearnPress – WordPress LMS Plugin for Create and Sell Online Courses 4.1.6.9.1, at inc/admin/views/tools/course/html-user.php

186 lines 5.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * @author ThimPress
4 * @package LearnPress/Admin/Views
5 * @version 3.0.0
6 */
7
8 defined( 'ABSPATH' ) or die();
9
10 ?>
11 <div id="learn-press-reset-user-courses" class="card">
12 <h2><?php _e( 'Reset user progress', 'learnpress' ); ?></h2>
13 <div class="description">
14 <p><?php _e( 'This action will reset progress of all courses that an user has enrolled.', 'learnpress' ); ?></p>
15 <p><?php _e( 'Search results only show users have course data.', 'learnpress' ); ?></p>
16 </div>
17 <p>
18 <input class="wide-fat" type="text" name="s" @keyup="updateSearch($event)"
19 placeholder="<?php esc_attr_e( 'Search user by login name or email', 'learnpress' ); ?>">
20 <button class="button" @click="search($event)"
21 :disabled="s.length < 3"><?php _e( 'Search', 'learnpress' ); ?></button>
22 </p>
23
24 <template v-if="users.length > 0">
25 <table class="wp-list-table widefat fixed striped">
26 <thead>
27 <tr>
28 <th width="50"><?php _e( 'ID', 'learnpress' ); ?></th>
29 <th width="200"><?php _e( 'Name', 'learnpress' ); ?></th>
30 <th><?php _e( 'Courses', 'learnpress' ); ?></th>
31 <th width="80"><?php _e( 'Actions', 'learnpress' ); ?></th>
32 </tr>
33 </thead>
34 <tbody>
35 <tr v-for="user in users">
36 <td>#{{user.id}}</td>
37 <td>{{user.username}} ({{user.email}})</td>
38 <td>
39 <ul class="courses-list">
40 <li v-for="course in user.courses">
41 <a :href="course.url" target="_blank">{{course.title}} (#{{course.id}})</a>
42 <a href=""
43 class="action-reset dashicons"
44 data-reset="single"
45 @click="reset($event, user, course.id);"
46 :class="resetActionClass(user, course)"></a>
47 </li>
48 </ul>
49 </td>
50 <td>
51 <a href=""
52 class="action-reset dashicons"
53 data-reset="all"
54 :class="resetActionClass(user)"
55 @click="reset($event, user);"></a>
56 <span style="font-size: 12px"><?php echo esc_html__( 'Delete All', 'learnpress' ); ?></span>
57 </td>
58 </tr>
59 </tbody>
60 </table>
61 </template>
62 <template v-else>
63 <p v-if="s.length < 3"><?php _e( 'Please enter at least 3 characters to searching users.', 'learnpress' ); ?></p>
64 <p v-else-if="status=='result'"><?php _e( 'No user found.', 'learnpress' ); ?></p>
65 <p v-else-if="status=='searching'"><?php _e( 'Searching user...', 'learnpress' ); ?></p>
66 </template>
67 </div>
68
69 <?php
70
71 // Translation
72 $localize = array(
73 'reset_course_users' => __( 'Are you sure to reset course progress of all users enrolled this course?', 'learnpress' ),
74 );
75 ?>
76 <script>
77 window.$Vue = window.$Vue || Vue;
78
79 jQuery(function ($) {
80 var js_localize = <?php echo wp_json_encode( $localize ); ?>
81
82 new $Vue({
83 el: '#learn-press-reset-user-courses',
84 data: {
85 s: '',
86 status: false,
87 users: []
88 },
89 methods: {
90 resetActionClass: function (user, course) {
91 var status = course ? course.status : user.status;
92 return {
93 'dashicons-trash': !status,
94 'dashicons-yes': status === 'done',
95 'dashicons-update': status === 'resetting'
96 }
97 },
98 updateSearch: function (e) {
99 this.s = e.target.value;
100 this.status = false;
101 e.preventDefault();
102 },
103 search: function (e) {
104 e.preventDefault();
105
106 var that = this;
107 this.s = $(this.$el).find('input[name="s"]').val();
108
109 if (this.s.length < 3) {
110 return;
111 }
112
113 this.status = 'searching';
114 this.courses = [];
115
116 $.ajax({
117 url: '',
118 data: {
119 'lp-ajax': 'rs-search-users',
120 s: this.s
121 },
122 success: function (response) {
123 var users = LP.parseJSON(response);
124 for(var i = 0; i < users.length; i++) {
125 for (var j in users[i].courses) {
126 users[i].courses[j].status = ''
127 }
128 }
129 that.users = users;
130 that.status = 'result';
131 }
132 })
133 },
134
135 reset: function (e, user, course_id) {
136 e.preventDefault();
137
138 if (!confirm(js_localize.reset_course_users)) {
139 return;
140 }
141 var that = this;
142 if(course_id){
143 user.courses[course_id].status = 'resetting'
144 }else{
145 for(var j in user.courses ){
146 user.courses[j].status = 'resetting'
147 }
148 user.status = 'resetting';
149 }
150
151 var object_reset = $(e.target).data('reset');
152
153 $.ajax({
154 url: '',
155 data: {
156 'lp-ajax': 'rs-reset-user-courses',
157 user_id: user.id,
158 course_id: course_id,
159 object_reset: object_reset
160 },
161 success: function (response) {
162 response = LP.parseJSON(response);
163 //if (response.id == user.id) {
164 for (var i = 0, n = that.users.length; i < n; i++) {
165 if (that.users[i].id === user.id) {
166 if(course_id){
167 that.users[i].courses[course_id].status = 'done'
168 }else{
169 for(var j in that.users[i].courses ){
170 that.users[i].courses[j].status = 'done'
171 }
172 user.status = 'done';
173 }
174 break;
175 }
176 }
177 // }
178 }
179 })
180 }
181 }
182 });
183 });
184
185 </script>
186