|
23 | 23 | use Tutor\Helpers\HttpHelper; |
24 | 24 | use Tutor\Models\CourseModel; |
25 | 25 | use Tutor\Ecommerce\Ecommerce; |
| 26 | +use Tutor\Helpers\DateTimeHelper; |
26 | 27 | use Tutor\Traits\JsonResponse; |
27 | 28 | use Tutor\Helpers\ValidationHelper; |
28 | 29 | use Tutor\Models\EnrollmentModel; |
@@ -3079,15 +3080,22 @@ public function delete_associated_enrollment( $post_id ) { |
3079 | 3080 | */ |
3080 | 3081 | public function tutor_reset_course_progress() { |
3081 | 3082 | tutor_utils()->checking_nonce(); |
3082 | | - $course_id = Input::post( 'course_id', 0, Input::TYPE_INT ); |
| 3083 | + $course_id = Input::post( 'course_id', 0, Input::TYPE_INT ); |
| 3084 | + $course_reset_progress = tutor_utils()->get_option( 'course_reset_progress', false ); |
| 3085 | + $course_retake_feature = tutor_utils()->get_option( 'course_retake_feature', false ); |
| 3086 | + |
| 3087 | + if ( ! $course_reset_progress || ! $course_retake_feature ) { |
| 3088 | + $this->response_bad_request( __( 'You are not allowed to reset course progress.', 'tutor' ) ); |
| 3089 | + return; |
| 3090 | + } |
3083 | 3091 |
|
3084 | 3092 | if ( ! $course_id || ! is_numeric( $course_id ) || ! EnrollmentModel::is_enrolled( $course_id ) ) { |
3085 | | - wp_send_json_error( array( 'message' => __( 'Invalid Course ID or Access Denied.', 'tutor' ) ) ); |
| 3093 | + $this->response_bad_request( __( 'Invalid Course ID or Access Denied.', 'tutor' ) ); |
3086 | 3094 | return; |
3087 | 3095 | } |
3088 | 3096 |
|
3089 | 3097 | tutor_utils()->delete_course_progress( $course_id ); |
3090 | | - wp_send_json_success( array( 'redirect_to' => tutor_utils()->get_course_first_lesson( $course_id ) ) ); |
| 3098 | + $this->json_response( '', array( 'redirect_to' => tutor_utils()->get_course_first_lesson( $course_id ) ) ); |
3091 | 3099 | } |
3092 | 3100 |
|
3093 | 3101 | /** |
|
0 commit comments