From a93eaa22e9f757696b5f464751eb39df2374b86a Mon Sep 17 00:00:00 2001 From: Anthony Talarico Date: Tue, 31 Jul 2018 09:28:48 -0400 Subject: [PATCH] changing the course completion behavior to only show when the modal when a course is complete and not quizzes --- footer.php | 4 +--- functions.php | 25 ++++++++++++------------- header.php | 1 + js/custom.js | 6 ++++++ 4 files changed, 20 insertions(+), 16 deletions(-) diff --git a/footer.php b/footer.php index cdb9d15..1263155 100644 --- a/footer.php +++ b/footer.php @@ -94,7 +94,7 @@ this.addEventListener("readystatechange", function() { if( (this.response.includes('quiz_finished') ) && this.readyState === 4 ){ let data = JSON.parse(this.response); - if(data.pass === 1){ + if(data.quiz_finished === 1){ setTimeout(function(){ $(".glm-badge-alert#quiz-badge").fadeIn("fast"); $(".glm-badge-alert#quiz-badge").addClass("shake"); @@ -105,7 +105,6 @@ } } if( (this.response.includes('lesson_finished') ) && this.readyState === 4 ){ - let data = JSON.parse(this.response); setTimeout(function(){ $(".glm-badge-alert#lesson-badge").fadeIn("fast"); $(".glm-badge-alert#lesson-badge").addClass("shake"); @@ -115,7 +114,6 @@ }, 10000); } if( this.response.includes('course_finished') && this.readyState === 4 ){ - let data = JSON.parse(this.response); setTimeout(function(){ $("#glm-badge-overlay").fadeIn("fast"); }, 1500) diff --git a/functions.php b/functions.php index e429781..93ac8f6 100644 --- a/functions.php +++ b/functions.php @@ -289,18 +289,17 @@ function displaydate(){ } add_shortcode( 'date', 'displaydate' ); add_filter( 'show_admin_bar', '__return_false' ); -add_action("learndash_quiz_completed", function($data) { - $data["quiz_finished"] = "yes"; - echo json_encode($data); - wp_die(); -}, 5, 1); +// add_action("learndash_quiz_completed", function($data) { +// global $action_data; +// $action_data["quiz_finished"] = $data['pass']; +// echo json_encode( $action_data); +// }, 5, 1); add_action("learndash_course_completed", function($data) { - $finished["course_finished"] = "yes"; - echo json_encode($finished); - wp_die(); + $action_data = array("course_finished" => "yes"); + echo json_encode($action_data); }, 5, 1); -add_action("learndash_lesson_completed", function($data) { - $finished["lesson_finished"] = "yes"; - echo json_encode($finished); - wp_die(); -}, 5, 1); \ No newline at end of file +// add_action("learndash_lesson_completed", function($data) { +// $finished["lesson_finished"] = "yes"; +// echo json_encode($finished); +// wp_die(); +// }, 5, 1); \ No newline at end of file diff --git a/header.php b/header.php index fb0f04a..f4b1044 100644 --- a/header.php +++ b/header.php @@ -27,6 +27,7 @@ $type =strtolower(str_replace(" ","-",$post->post_type)); ?>