File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -25,6 +25,7 @@ window.jQuery(document).ready(($) => {
2525 data : {
2626 action : 'tutor_reset_course_progress' ,
2727 course_id : course_id ,
28+ context : 'course-landing' ,
2829 } ,
2930 beforeSend : ( ) => {
3031 button . prop ( 'disabled' , true ) . addClass ( 'is-loading' ) ;
Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ interface CourseCompletePayload {
1010}
1111interface CourseRetakePayload {
1212 course_id : number ;
13+ context : string ;
1314}
1415
1516/**
@@ -70,7 +71,7 @@ export const courseCompleteHandler = () => {
7071 } ,
7172
7273 async handleCourseRetake ( courseId : number ) {
73- await this . courseRetakeMutation ?. mutate ( { course_id : courseId } ) ;
74+ await this . courseRetakeMutation ?. mutate ( { course_id : courseId , context : 'learning-area' } ) ;
7475 } ,
7576 } ;
7677} ;
Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ import { type AxiosError } from 'axios';
1212
1313interface ResetProgressPayload {
1414 course_id : number ;
15+ context : string ;
1516}
1617
1718interface ResetProgressResponse {
@@ -104,7 +105,7 @@ export const sidebarComponent = ({
104105 } ,
105106
106107 resetProgress ( ) {
107- this . resetProgressMutation ?. mutate ( { course_id : this . courseId } ) ;
108+ this . resetProgressMutation ?. mutate ( { course_id : this . courseId , context : 'learning-area-sidebar' } ) ;
108109 } ,
109110 } ;
110111} ;
Original file line number Diff line number Diff line change @@ -3084,10 +3084,16 @@ public function delete_associated_enrollment( $post_id ) {
30843084 public function tutor_reset_course_progress () {
30853085 tutor_utils ()->checking_nonce ();
30863086 $ course_id = Input::post ( 'course_id ' , 0 , Input::TYPE_INT );
3087+ $ context = Input::post ( 'context ' , '' );
30873088 $ course_reset_progress = tutor_utils ()->get_option ( 'course_reset_progress ' , false );
30883089 $ course_retake_feature = tutor_utils ()->get_option ( 'course_retake_feature ' , false );
30893090
3090- if ( ! $ course_reset_progress || ! $ course_retake_feature ) {
3091+ if ( ! $ course_reset_progress && 'learning-area-sidebar ' === $ context ) {
3092+ $ this ->response_bad_request ( __ ( 'You are not allowed to reset course progress. ' , 'tutor ' ) );
3093+ return ;
3094+ }
3095+
3096+ if ( ! $ course_retake_feature && ( 'course-landing ' === $ context || 'learning-area ' === $ context ) ) {
30913097 $ this ->response_bad_request ( __ ( 'You are not allowed to reset course progress. ' , 'tutor ' ) );
30923098 return ;
30933099 }
You can’t perform that action at this time.
0 commit comments