PluginProbe
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses / 4.4.3
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses v4.4.3
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 4.2.1 All 138 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.4.3, at inc/admin/views/tools/course/html-user.php

188 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 all course progresses of users.', 'learnpress' ); ?></p>
15 <p><?php _e( 'Search results only show if 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.', '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 nonce: lpGlobalSettings.nonce
122 },
123 success: function (response) {
124 var users = LP.parseJSON(response);
125 for(var i = 0; i < users.length; i++) {
126 for (var j in users[i].courses) {
127 users[i].courses[j].status = ''
128 }
129 }
130 that.users = users;
131 that.status = 'result';
132 }
133 })
134 },
135
136 reset: function (e, user, course_id) {
137 e.preventDefault();
138
139 if (!confirm(js_localize.reset_course_users)) {
140 return;
141 }
142 var that = this;
143 if(course_id){
144 user.courses[course_id].status = 'resetting'
145 }else{
146 for(var j in user.courses ){
147 user.courses[j].status = 'resetting'
148 }
149 user.status = 'resetting';
150 }
151
152 var object_reset = $(e.target).data('reset');
153
154 $.ajax({
155 url: '',
156 data: {
157 'lp-ajax': 'rs-reset-user-courses',
158 user_id: user.id,
159 course_id: course_id,
160 object_reset: object_reset,
161 nonce: lpGlobalSettings.nonce
162 },
163 success: function (response) {
164 response = LP.parseJSON(response);
165 //if (response.id == user.id) {
166 for (var i = 0, n = that.users.length; i < n; i++) {
167 if (that.users[i].id === user.id) {
168 if(course_id){
169 that.users[i].courses[course_id].status = 'done'
170 }else{
171 for(var j in that.users[i].courses ){
172 that.users[i].courses[j].status = 'done'
173 }
174 user.status = 'done';
175 }
176 break;
177 }
178 }
179 // }
180 }
181 })
182 }
183 }
184 });
185 });
186
187 </script>
188