From dbe224a39b029fe8e4f0d56174cf2302bfe0a307 Mon Sep 17 00:00:00 2001 From: Frank Corso Date: Wed, 19 Nov 2014 11:28:38 -0500 Subject: [PATCH 01/17] Design Changes To Quizzes Fixes #9 Removed new quiz buttons to place wordpress button. Changed link options to wordpress class. Removed help dialog as we now have plugin documentation. --- includes/mlw_quiz_admin.php | 56 +++++++++++-------------------------- 1 file changed, 17 insertions(+), 39 deletions(-) diff --git a/includes/mlw_quiz_admin.php b/includes/mlw_quiz_admin.php index 46417c78c..14a9be87a 100644 --- a/includes/mlw_quiz_admin.php +++ b/includes/mlw_quiz_admin.php @@ -386,30 +386,8 @@ function mlw_generate_quiz_admin() var $j = jQuery.noConflict(); // increase the default animation speed to exaggerate the effect $j.fx.speeds._default = 1000; - $j(function() { - $j('#dialog').dialog({ - autoOpen: false, - show: 'blind', - hide: 'explode', - buttons: { - Ok: function() { - $j(this).dialog('close'); - } - } - }); - - $j('#opener').click(function() { - $j('#dialog').dialog('open'); - return false; - } ); - }); $j(function() { $j("#prev_page, #next_page").button(); - $j("#new_quiz_button, #new_quiz_button_two").button({ - icons: { - primary: "ui-icon-circle-plus" - } - }); }); $j(function() { $j('#new_quiz_dialog').dialog({ @@ -490,9 +468,23 @@ function duplicateQuiz(id, quizName){ cursor:hand; } +
-

Quizzes(?)

+

QuizzesAdd New

@@ -541,7 +533,6 @@ function duplicateQuiz(id, quizName){ - "; $quotes_list .= "" . $mlw_quiz_info->quiz_id . ""; - $quotes_list .= "" . esc_html($mlw_quiz_info->quiz_name) ." quiz_id."','".esc_js($mlw_quiz_info->quiz_name)."')\" href='#'>(Edit Name)
Edit | quiz_id."','".esc_js($mlw_quiz_info->quiz_name)."')\" href='#'>Delete | Results | quiz_id."','".esc_js($mlw_quiz_info->quiz_name)."')\">Duplicate
"; + $quotes_list .= "" . esc_html($mlw_quiz_info->quiz_name) ." quiz_id."','".esc_js($mlw_quiz_info->quiz_name)."')\" href='javascript:();'>(Edit Name)"; + $quotes_list .= ""; $quotes_list .= "[mlw_quizmaster quiz=".$mlw_quiz_info->quiz_id."]"; $quotes_list .= "[mlw_quizmaster_leaderboard mlw_quiz=".$mlw_quiz_info->quiz_id."]"; $quotes_list .= "" . $mlw_quiz_info->quiz_views . ""; @@ -607,9 +599,6 @@ function duplicateQuiz(id, quizName){ $display .= ""; echo $display; ?> - - - @@ -685,17 +674,6 @@ function duplicateQuiz(id, quizName){ ?>
- -
Date: Wed, 19 Nov 2014 11:41:04 -0500 Subject: [PATCH 02/17] Added Time Taken To Result Details Page Added a row on the result details page that shows the time the quiz was taken. --- includes/mlw_results_details.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/includes/mlw_results_details.php b/includes/mlw_results_details.php index 9238aded1..e8ad9e2e6 100644 --- a/includes/mlw_results_details.php +++ b/includes/mlw_results_details.php @@ -133,6 +133,10 @@ function mlw_generate_result_details()

Quiz Results From quiz_name; ?>

+ + + + From 71a1f9197622ecf1f6d75a501c7c5e5b27740ba6 Mon Sep 17 00:00:00 2001 From: Frank Corso Date: Wed, 19 Nov 2014 11:58:37 -0500 Subject: [PATCH 03/17] Added Completion Time Column Added the amount of time user took to finish quiz to table. --- includes/mlw_results.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/includes/mlw_results.php b/includes/mlw_results.php index 625334fe4..20c154022 100644 --- a/includes/mlw_results.php +++ b/includes/mlw_results.php @@ -148,6 +148,19 @@ function deleteResults(id,quizName){ foreach($mlw_quiz_data as $mlw_quiz_info) { if($alternate) $alternate = ""; else $alternate = " class=\"alternate\""; + $mlw_complete_time = ''; + $mlw_qmn_results_array = @unserialize($mlw_quiz_info->quiz_results); + if (is_array($mlw_qmn_results_array)) + { + $mlw_complete_minutes = floor($mlw_qmn_results_array[0] / 60); + if ($mlw_complete_minutes > 0) + { + $mlw_complete_time .= "$mlw_complete_minutes minutes "; + } + $mlw_complete_seconds = $mlw_qmn_results_array[0] % 60; + $mlw_complete_time .= "$mlw_complete_seconds seconds"; + } + $quotes_list .= ""; $quotes_list .= ""; $quotes_list .= ""; @@ -163,6 +176,7 @@ function deleteResults(id,quizName){ { $quotes_list .= ""; } + $quotes_list .= ""; $quotes_list .= ""; $quotes_list .= ""; $quotes_list .= ""; @@ -198,6 +212,7 @@ function deleteResults(id,quizName){ + From 67398cfbb4eb5d3ef53da3d0f1fb3eaae45a6777 Mon Sep 17 00:00:00 2001 From: Frank Corso Date: Wed, 19 Nov 2014 11:59:33 -0500 Subject: [PATCH 04/17] Changed Completion Time Output To Minutes & Seconds Changed the output of completion time to be shown in minutes and seconds instead of just seconds. --- includes/mlw_results_details.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/includes/mlw_results_details.php b/includes/mlw_results_details.php index e8ad9e2e6..c29091380 100644 --- a/includes/mlw_results_details.php +++ b/includes/mlw_results_details.php @@ -185,8 +185,16 @@ function mlw_generate_result_details() } else { + $mlw_complete_time = ''; + $mlw_complete_minutes = floor($mlw_qmn_results_array[0] / 60); + if ($mlw_complete_minutes > 0) + { + $mlw_complete_time .= "$mlw_complete_minutes minutes "; + } + $mlw_complete_seconds = $mlw_qmn_results_array[0] % 60; + $mlw_complete_time .= "$mlw_complete_seconds seconds"; ?> - This quiz was completed in seconds.
+ This quiz was completed in .

The comments entered into the comment box (if enabled):

From f8f19531d5c2eea9abdcf1d926acfe184d3257b0 Mon Sep 17 00:00:00 2001 From: Frank Corso Date: Wed, 19 Nov 2014 14:28:38 -0500 Subject: [PATCH 05/17] Broke Apart Quiz Settings Into Smaller Functions Added hook to allow functions to be hooked into quiz settings. Broke tabs into separate functions and hooked into new hook. Minor design changes such as questions table has row-actions class now. --- includes/mlw_quiz_options.php | 2575 ++++++++++++++++----------------- 1 file changed, 1270 insertions(+), 1305 deletions(-) diff --git a/includes/mlw_quiz_options.php b/includes/mlw_quiz_options.php index af6a036e7..0ad3dfb8f 100644 --- a/includes/mlw_quiz_options.php +++ b/includes/mlw_quiz_options.php @@ -8,9 +8,13 @@ function mlw_generate_quiz_options() { - $quiz_id = $_GET["quiz_id"]; global $wpdb; - $table_name = $wpdb->prefix . "mlw_questions"; + $quiz_id = $_GET["quiz_id"]; + if (isset($_GET["quiz_id"])) + { + $table_name = $wpdb->prefix . "mlw_quizzes"; + $mlw_quiz_options = $wpdb->get_row($wpdb->prepare("SELECT * FROM $table_name WHERE quiz_id=%d LIMIT 1", $_GET["quiz_id"])); + } $is_new_quiz = 0; $hasUpdatedLeaderboardOptions = false; $hasCreatedQuestion = false; @@ -28,13 +32,259 @@ function mlw_generate_quiz_options() $mlw_hasSavedStyle = false; $mlw_qmn_isQueryError = false; $mlw_qmn_error_code = '0000'; - + ?> + + + + + +
+
+

Quiz Settings For quiz_name; ?>

+ +
+

+ Success! Your leaderboard options for this quiz have been saved.

+
+ +
+

+ Uh-Oh! There has been an error in this action! Please share this with the developer: Error Code

+
+ +
+

+ Success! Your new question has been created successfully.

+
+ +
+

+ Success! Your templates for this quiz have been saved.

+
+ +
+

+ Success! Your options for this quiz have been saved.

+
+ +
+

+ Success! The question has been deleted from this quiz.

+
+ +
+

+ Success! The question has been duplicated.

+
+ +
+

+ Success! The question has been updated.

+
+ +
+

+ Success! The stats for this quiz has been reset!

+
+ +
+

+ Success! A new results page has been added successfully!

+
+ +
+

+ Success! The results pages have been saved successfully!

+
+ +
+

+ Success! A new email has been added successfully!

+
+ +
+

+ Success! The email templates have been saved successfully!

+
+ +
+

+ Success! The certificate options have been saved successfully!

+
+ +
+

+ Success! The styles have been saved successfully!

+
+ +
+
    + +
+ + +
+ +
+

+ Hey! Please go to the quizzes page and click on the Edit link from the quiz you wish to edit.

+ + + +
+
+Quiz Questions"; +} +function mlw_options_text_tab() +{ + echo "
  • Quiz Text
  • "; +} +function mlw_options_option_tab() +{ + echo "
  • Quiz Options
  • "; +} +function mlw_options_leaderboard_tab() +{ + echo "
  • Quiz Leaderboard
  • "; +} +function mlw_options_certificate_tab() +{ + echo "
  • Quiz Certificate (Beta)
  • "; +} +function mlw_options_emails_tab() +{ + echo "
  • Quiz Emails
  • "; +} +function mlw_options_results_tab() +{ + echo "
  • Quiz Results Page
  • "; +} +function mlw_options_styling_tab() +{ + echo "
  • Quiz Styling
  • "; +} +function mlw_options_tools_tab() +{ + echo "
  • Quiz Tools/Add-Ons
  • "; +} + +add_action('mlw_qmn_options_tab_content', 'mlw_options_questions_tab_content'); +add_action('mlw_qmn_options_tab_content', 'mlw_options_text_tab_content'); +add_action('mlw_qmn_options_tab_content', 'mlw_options_option_tab_content'); +add_action('mlw_qmn_options_tab_content', 'mlw_options_leaderboard_tab_content'); +add_action('mlw_qmn_options_tab_content', 'mlw_options_certificate_tab_content'); +add_action('mlw_qmn_options_tab_content', 'mlw_options_emails_tab_content'); +add_action('mlw_qmn_options_tab_content', 'mlw_options_results_tab_content'); +add_action('mlw_qmn_options_tab_content', 'mlw_options_styling_tab_content'); +add_action('mlw_qmn_options_tab_content', 'mlw_options_tools_tab_content'); +function mlw_options_questions_tab_content() +{ + global $wpdb; + $quiz_id = $_GET["quiz_id"]; + //Edit question if ( isset($_POST["edit_question"]) && $_POST["edit_question"] == "confirmation") { @@ -269,1188 +519,235 @@ function mlw_generate_quiz_options() $mlw_qmn_error_code = '0006'; } } + + if (isset($_GET["quiz_id"])) + { + $table_name = $wpdb->prefix . "mlw_quizzes"; + $mlw_quiz_options = $wpdb->get_row($wpdb->prepare("SELECT * FROM $table_name WHERE quiz_id=%d LIMIT 1", $_GET["quiz_id"])); + } - //Get table of questions for this quiz - if ($quiz_id != "") + $mlw_qmn_table_limit = 10; + $mlw_qmn_question_count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(question_id) FROM " . $wpdb->prefix . "mlw_questions WHERE quiz_id=%d AND deleted='0'", $quiz_id ) ); + + if( isset($_GET{'mlw_question_page'} ) ) + { + $mlw_qmn_question_page = $_GET{'mlw_question_page'} + 1; + $mlw_qmn_question_begin = $mlw_qmn_table_limit * $mlw_qmn_question_page ; + } + else { - global $wpdb; - $mlw_qmn_table_limit = 10; - $mlw_qmn_question_count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(question_id) FROM " . $wpdb->prefix . "mlw_questions WHERE quiz_id=%d AND deleted='0'", $quiz_id ) ); + $mlw_qmn_question_page = 0; + $mlw_qmn_question_begin = 0; + } + $mlw_qmn_question_left = $mlw_qmn_question_count - ($mlw_qmn_question_page * $mlw_qmn_table_limit); + + $mlw_question_data = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM " . $wpdb->prefix . "mlw_questions WHERE quiz_id=%d AND deleted='0' + ORDER BY question_order ASC LIMIT %d, %d", $quiz_id, $mlw_qmn_question_begin, $mlw_qmn_table_limit ) ); - if( isset($_GET{'mlw_question_page'} ) ) + //Load and prepare answer arrays + $mlw_qmn_answer_arrays = array(); + foreach($mlw_question_data as $mlw_question_info) { + $mlw_qmn_answer_array_each = @unserialize($mlw_question_info->answer_array); + if ( !is_array($mlw_qmn_answer_array_each) ) { - $mlw_qmn_question_page = $_GET{'mlw_question_page'} + 1; - $mlw_qmn_question_begin = $mlw_qmn_table_limit * $mlw_qmn_question_page ; + $mlw_answer_array_correct = array(0, 0, 0, 0, 0, 0); + $mlw_answer_array_correct[$mlw_question_info->correct_answer-1] = 1; + $mlw_qmn_answer_arrays[$mlw_question_info->question_id] = array( + array($mlw_question_info->answer_one, $mlw_question_info->answer_one_points, $mlw_answer_array_correct[0]), + array($mlw_question_info->answer_two, $mlw_question_info->answer_two_points, $mlw_answer_array_correct[1]), + array($mlw_question_info->answer_three, $mlw_question_info->answer_three_points, $mlw_answer_array_correct[2]), + array($mlw_question_info->answer_four, $mlw_question_info->answer_four_points, $mlw_answer_array_correct[3]), + array($mlw_question_info->answer_five, $mlw_question_info->answer_five_points, $mlw_answer_array_correct[4]), + array($mlw_question_info->answer_six, $mlw_question_info->answer_six_points, $mlw_answer_array_correct[5])); } else { - $mlw_qmn_question_page = 0; - $mlw_qmn_question_begin = 0; + $mlw_qmn_answer_arrays[$mlw_question_info->question_id] = $mlw_qmn_answer_array_each; } - $mlw_qmn_question_left = $mlw_qmn_question_count - ($mlw_qmn_question_page * $mlw_qmn_table_limit); - - $mlw_question_data = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM " . $wpdb->prefix . "mlw_questions WHERE quiz_id=%d AND deleted='0' - ORDER BY question_order ASC LIMIT %d, %d", $quiz_id, $mlw_qmn_question_begin, $mlw_qmn_table_limit ) ); - $is_new_quiz = $wpdb->num_rows; } - - /* - Code for Quiz Text tab - */ - - //Submit saved templates into database - if ( isset($_POST["save_templates"]) && $_POST["save_templates"] == "confirmation") - { - //Variables for save templates form - $mlw_before_message = htmlspecialchars($_POST["mlw_quiz_before_message"], ENT_QUOTES); - $mlw_qmn_message_end = htmlspecialchars($_POST["message_end_template"], ENT_QUOTES); - $mlw_qmn_social_medi_text = htmlspecialchars($_POST["mlw_quiz_social_media_text_template"], ENT_QUOTES); - $mlw_user_tries_text = htmlspecialchars($_POST["mlw_quiz_total_user_tries_text"], ENT_QUOTES); - $mlw_submit_button_text = htmlspecialchars($_POST["mlw_submitText"], ENT_QUOTES); - $mlw_name_field_text = htmlspecialchars($_POST["mlw_nameText"], ENT_QUOTES); - $mlw_business_field_text = htmlspecialchars($_POST["mlw_businessText"], ENT_QUOTES); - $mlw_email_field_text = htmlspecialchars($_POST["mlw_emailText"], ENT_QUOTES); - $mlw_phone_field_text = htmlspecialchars($_POST["mlw_phoneText"], ENT_QUOTES); - $mlw_before_comments = htmlspecialchars($_POST["mlw_quiz_before_comments"], ENT_QUOTES); - $mlw_comment_field_text = htmlspecialchars($_POST["mlw_commentText"], ENT_QUOTES); - $mlw_qmn_pagination_field = serialize(array( $_POST["pagination_prev_text"], $_POST["pagination_next_text"] )); - $mlw_email_from_text = $_POST["emailFromText"]; - $mlw_question_answer_template = htmlspecialchars($_POST["mlw_quiz_question_answer_template"], ENT_QUOTES); - $quiz_id = $_POST["quiz_id"]; - - $update = "UPDATE " . $wpdb->prefix . "mlw_quizzes" . " SET message_before='".$mlw_before_message."', message_comment='".$mlw_before_comments."', message_end_template='".$mlw_qmn_message_end."', comment_field_text='".$mlw_comment_field_text."', email_from_text='".$mlw_email_from_text."', question_answer_template='".$mlw_question_answer_template."', submit_button_text='".$mlw_submit_button_text."', name_field_text='".$mlw_name_field_text."', business_field_text='".$mlw_business_field_text."', email_field_text='".$mlw_email_field_text."', phone_field_text='".$mlw_phone_field_text."', total_user_tries_text='".$mlw_user_tries_text."', social_media_text='".$mlw_qmn_social_medi_text."', pagination_text='".$mlw_qmn_pagination_field."', last_activity='".date("Y-m-d H:i:s")."' WHERE quiz_id=".$quiz_id; - $results = $wpdb->query( $update ); - if ($results != false) - { - $hasUpdatedTemplates = true; - - //Insert Action Into Audit Trail - global $current_user; - get_currentuserinfo(); - $table_name = $wpdb->prefix . "mlw_qm_audit_trail"; - $insert = "INSERT INTO " . $table_name . - "(trail_id, action_user, action, time) " . - "VALUES (NULL , '" . $current_user->display_name . "' , 'Templates Have Been Edited For Quiz Number ".$quiz_id."' , '" . date("h:i:s A m/d/Y") . "')"; - $results = $wpdb->query( $insert ); - } - else - { - $mlw_qmn_isQueryError = true; - $mlw_qmn_error_code = '0007'; - } - } - - - /* - Code for Quiz Options tab - */ - - //Submit saved options into database - if ( isset($_POST["save_options"]) && $_POST["save_options"] == "confirmation") - { - //Variables for save options form - $mlw_system = $_POST["system"]; - $mlw_qmn_pagination = intval($_POST["pagination"]); - $mlw_qmn_social_media = intval($_POST["social_media"]); - $mlw_qmn_question_numbering = intval($_POST["question_numbering"]); - $mlw_qmn_timer = intval($_POST["timer_limit"]); - $mlw_qmn_questions_from_total = $_POST["question_from_total"]; - $mlw_randomness_order = $_POST["randomness_order"]; - $mlw_total_user_tries = intval($_POST["total_user_tries"]); - $mlw_send_user_email = $_POST["sendUserEmail"]; - $mlw_send_admin_email = $_POST["sendAdminEmail"]; - $mlw_contact_location = $_POST["contact_info_location"]; - $mlw_user_name = $_POST["userName"]; - $mlw_user_comp = $_POST["userComp"]; - $mlw_user_email = $_POST["userEmail"]; - $mlw_user_phone = $_POST["userPhone"]; - $mlw_admin_email = $_POST["adminEmail"]; - $mlw_comment_section = $_POST["commentSection"]; - $mlw_qmn_loggedin_contact = $_POST["loggedin_user_contact"]; - $quiz_id = $_POST["quiz_id"]; - - $update = "UPDATE " . $wpdb->prefix . "mlw_quizzes" . " SET system='".$mlw_system."', send_user_email='".$mlw_send_user_email."', send_admin_email='".$mlw_send_admin_email."', loggedin_user_contact='".$mlw_qmn_loggedin_contact."', contact_info_location=".$mlw_contact_location.", user_name='".$mlw_user_name."', user_comp='".$mlw_user_comp."', user_email='".$mlw_user_email."', user_phone='".$mlw_user_phone."', admin_email='".$mlw_admin_email."', comment_section='".$mlw_comment_section."', randomness_order='".$mlw_randomness_order."', question_from_total=".$mlw_qmn_questions_from_total.", total_user_tries=".$mlw_total_user_tries.", social_media=".$mlw_qmn_social_media.", pagination=".$mlw_qmn_pagination.", timer_limit=".$mlw_qmn_timer.", question_numbering=".$mlw_qmn_question_numbering.", last_activity='".date("Y-m-d H:i:s")."' WHERE quiz_id=".$quiz_id; - $results = $wpdb->query( $update ); - if ($results != false) - { - $hasUpdatedOptions = true; - - //Insert Action Into Audit Trail - global $current_user; - get_currentuserinfo(); - $table_name = $wpdb->prefix . "mlw_qm_audit_trail"; - $insert = "INSERT INTO " . $table_name . - "(trail_id, action_user, action, time) " . - "VALUES (NULL , '" . $current_user->display_name . "' , 'Options Have Been Edited For Quiz Number ".$quiz_id."' , '" . date("h:i:s A m/d/Y") . "')"; - $results = $wpdb->query( $insert ); - } - else - { - $mlw_qmn_isQueryError = true; - $mlw_qmn_error_code = '0008'; - } - } - - /* - Code For Leaderboard Options tab - */ - - ///Submit saved leaderboard template into database - if ( isset($_POST["save_leaderboard_options"]) && $_POST["save_leaderboard_options"] == "confirmation") - { - ///Variables for save leaderboard options form - $mlw_leaderboard_template = $_POST["mlw_quiz_leaderboard_template"]; - $mlw_leaderboard_quiz_id = $_POST["leaderboard_quiz_id"]; - $update = "UPDATE " . $wpdb->prefix . "mlw_quizzes" . " SET leaderboard_template='".$mlw_leaderboard_template."', last_activity='".date("Y-m-d H:i:s")."' WHERE quiz_id=".$mlw_leaderboard_quiz_id; - $results = $wpdb->query( $update ); - if ($results != false) - { - $hasUpdatedLeaderboardOptions = true; - - //Insert Action Into Audit Trail - global $current_user; - get_currentuserinfo(); - $table_name = $wpdb->prefix . "mlw_qm_audit_trail"; - $insert = "INSERT INTO " . $table_name . - "(trail_id, action_user, action, time) " . - "VALUES (NULL , '" . $current_user->display_name . "' , 'Leaderboard Options Have Been Edited For Quiz Number ".$mlw_leaderboard_quiz_id."' , '" . date("h:i:s A m/d/Y") . "')"; - $results = $wpdb->query( $insert ); - } - else - { - $mlw_qmn_isQueryError = true; - $mlw_qmn_error_code = '0009'; - } - } - - /* - Code For Certificate Tab - */ - - //Saved Certificate Options - if (isset($_POST["save_certificate_options"]) && $_POST["save_certificate_options"] == "confirmation") - { - $mlw_certificate_id = intval($_POST["certificate_quiz_id"]); - $mlw_certificate_title = $_POST["certificate_title"]; - $mlw_certificate_text = $_POST["certificate_template"]; - $mlw_certificate_logo = $_POST["certificate_logo"]; - $mlw_certificate_background = $_POST["certificate_background"]; - $mlw_enable_certificates = intval($_POST["enableCertificates"]); - $mlw_certificate = array($mlw_certificate_title, $mlw_certificate_text, $mlw_certificate_logo, $mlw_certificate_background, $mlw_enable_certificates); - $mlw_certificate_serialized = serialize($mlw_certificate); - - $mlw_certificate_sql_results = $wpdb->query( $wpdb->prepare( "UPDATE " . $wpdb->prefix . "mlw_quizzes SET certificate_template=%s, last_activity='".date("Y-m-d H:i:s")."' WHERE quiz_id=%d", $mlw_certificate_serialized, $mlw_certificate_id ) ); - - - if ($mlw_certificate_sql_results != false) - { - $mlw_UpdatedCertificate = true; - - //Insert Action Into Audit Trail - global $current_user; - get_currentuserinfo(); - $table_name = $wpdb->prefix . "mlw_qm_audit_trail"; - $insert = "INSERT INTO " . $table_name . - "(trail_id, action_user, action, time) " . - "VALUES (NULL , '" . $current_user->display_name . "' , 'Certificate Options Have Been Edited For Quiz Number ".$mlw_certificate_id."' , '" . date("h:i:s A m/d/Y") . "')"; - $results = $wpdb->query( $insert ); - } - else - { - $mlw_qmn_isQueryError = true; - $mlw_qmn_error_code = '0012'; - } - } - - /* - Code For Quiz Emails Tab - */ - - //Check to add new user email template - if (isset($_POST["mlw_add_email_page"]) && $_POST["mlw_add_email_page"] == "confirmation") - { - //Function variables - $mlw_qmn_add_email_id = intval($_POST["mlw_add_email_quiz_id"]); - $mlw_qmn_user_email = $wpdb->get_var( $wpdb->prepare( "SELECT user_email_template FROM ".$wpdb->prefix."mlw_quizzes WHERE quiz_id=%d", $mlw_qmn_add_email_id ) ); - - //Load user email and check if it is array already. If not, turn it into one - $mlw_qmn_email_array = @unserialize($mlw_qmn_user_email); - if (is_array($mlw_qmn_email_array)) - { - $mlw_new_landing_array = array(0, 100, 'Enter Your Text Here', 'Quiz Results For %QUIZ_NAME%'); - array_unshift($mlw_qmn_email_array , $mlw_new_landing_array); - $mlw_qmn_email_array = serialize($mlw_qmn_email_array); - - } - else - { - $mlw_qmn_email_array = array(array(0, 0, $mlw_qmn_user_email, 'Quiz Results For %QUIZ_NAME%')); - $mlw_new_landing_array = array(0, 100, 'Enter Your Text Here', 'Quiz Results For %QUIZ_NAME%'); - array_unshift($mlw_qmn_email_array , $mlw_new_landing_array); - $mlw_qmn_email_array = serialize($mlw_qmn_email_array); - } - //Update message_after with new array then check to see if worked - $mlw_new_email_results = $wpdb->query( $wpdb->prepare( "UPDATE ".$wpdb->prefix."mlw_quizzes SET user_email_template='%s', last_activity='".date("Y-m-d H:i:s")."' WHERE quiz_id=%d", $mlw_qmn_email_array, $mlw_qmn_add_email_id ) ); - if ($mlw_new_email_results != false) - { - $mlw_hasAddedEmail = true; - - //Insert Action Into Audit Trail - global $current_user; - get_currentuserinfo(); - $table_name = $wpdb->prefix . "mlw_qm_audit_trail"; - $insert = "INSERT INTO " . $table_name . - "(trail_id, action_user, action, time) " . - "VALUES (NULL , '" . $current_user->display_name . "' , 'New User Email Has Been Created For Quiz Number ".$mlw_qmn_add_email_id."' , '" . date("h:i:s A m/d/Y") . "')"; - $results = $wpdb->query( $insert ); - } - else - { - $mlw_qmn_isQueryError = true; - $mlw_qmn_error_code = '0016'; - } - } - - //Check to save email templates - if (isset($_POST["mlw_save_email_template"]) && $_POST["mlw_save_email_template"] == "confirmation") - { - //Function Variables - $mlw_qmn_email_id = intval($_POST["mlw_email_quiz_id"]); - $mlw_qmn_email_template_total = intval($_POST["mlw_email_template_total"]); - $mlw_qmn_admin_email = htmlspecialchars(stripslashes($_POST["mlw_quiz_admin_email_template"]), ENT_QUOTES); - - //Create new array - $i = 1; - $mlw_qmn_new_email_array = array(); - while ($i <= $mlw_qmn_email_template_total) - { - if ($_POST["user_email_".$i] != "Delete") - { - $mlw_qmn_email_each = array(intval($_POST["user_email_begin_".$i]), intval($_POST["user_email_end_".$i]), htmlspecialchars(stripslashes($_POST["user_email_".$i]), ENT_QUOTES), htmlspecialchars(stripslashes($_POST["user_email_subject_".$i]), ENT_QUOTES)); - $mlw_qmn_new_email_array[] = $mlw_qmn_email_each; - } - $i++; - } - $mlw_qmn_new_email_array = serialize($mlw_qmn_new_email_array); - $mlw_new_email_results = $wpdb->query( $wpdb->prepare( "UPDATE ".$wpdb->prefix."mlw_quizzes SET user_email_template='%s', admin_email_template='%s', last_activity='".date("Y-m-d H:i:s")."' WHERE quiz_id=%d", $mlw_qmn_new_email_array, $mlw_qmn_admin_email, $mlw_qmn_email_id ) ); - if ($mlw_new_email_results != false) - { - $mlw_hasSavedEmail = true; - - //Insert Action Into Audit Trail - global $current_user; - get_currentuserinfo(); - $table_name = $wpdb->prefix . "mlw_qm_audit_trail"; - $insert = "INSERT INTO " . $table_name . - "(trail_id, action_user, action, time) " . - "VALUES (NULL , '" . $current_user->display_name . "' , 'Email Templates Have Been Saved For Quiz Number ".$mlw_qmn_email_id."' , '" . date("h:i:s A m/d/Y") . "')"; - $results = $wpdb->query( $insert ); - } - else - { - $mlw_qmn_isQueryError = true; - $mlw_qmn_error_code = '0017'; - } - } - - /* - Code For Quiz Results Page Tab - */ - - //Check to add new results page - if (isset($_POST["mlw_add_landing_page"]) && $_POST["mlw_add_landing_page"] == "confirmation") - { - //Function variables - $mlw_qmn_landing_id = intval($_POST["mlw_add_landing_quiz_id"]); - $mlw_qmn_message_after = $wpdb->get_var( $wpdb->prepare( "SELECT message_after FROM ".$wpdb->prefix."mlw_quizzes WHERE quiz_id=%d", $mlw_qmn_landing_id ) ); - //Load message_after and check if it is array already. If not, turn it into one - $mlw_qmn_landing_array = @unserialize($mlw_qmn_message_after); - if (is_array($mlw_qmn_landing_array)) - { - $mlw_new_landing_array = array(0, 100, 'Enter Your Text Here'); - array_unshift($mlw_qmn_landing_array , $mlw_new_landing_array); - $mlw_qmn_landing_array = serialize($mlw_qmn_landing_array); - - } - else - { - $mlw_qmn_landing_array = array(array(0, 0, $mlw_qmn_message_after)); - $mlw_new_landing_array = array(0, 100, 'Enter Your Text Here'); - array_unshift($mlw_qmn_landing_array , $mlw_new_landing_array); - $mlw_qmn_landing_array = serialize($mlw_qmn_landing_array); - } - - //Update message_after with new array then check to see if worked - $mlw_new_landing_results = $wpdb->query( $wpdb->prepare( "UPDATE ".$wpdb->prefix."mlw_quizzes SET message_after=%s, last_activity='".date("Y-m-d H:i:s")."' WHERE quiz_id=%d", $mlw_qmn_landing_array, $mlw_qmn_landing_id ) ); - if ($mlw_new_landing_results != false) - { - $mlw_hasAddedLanding = true; - - //Insert Action Into Audit Trail - global $current_user; - get_currentuserinfo(); - $table_name = $wpdb->prefix . "mlw_qm_audit_trail"; - $insert = "INSERT INTO " . $table_name . - "(trail_id, action_user, action, time) " . - "VALUES (NULL , '" . $current_user->display_name . "' , 'New Landing Page Has Been Created For Quiz Number ".$mlw_qmn_landing_id."' , '" . date("h:i:s A m/d/Y") . "')"; - $results = $wpdb->query( $insert ); - } - else - { - $mlw_qmn_isQueryError = true; - $mlw_qmn_error_code = '0013'; - } - } - - //Check to save landing pages - if (isset($_POST["mlw_save_landing_pages"]) && $_POST["mlw_save_landing_pages"] == "confirmation") - { - //Function Variables - $mlw_qmn_landing_id = intval($_POST["mlw_landing_quiz_id"]); - $mlw_qmn_landing_total = intval($_POST["mlw_landing_page_total"]); - - //Create new array - $i = 1; - $mlw_qmn_new_landing_array = array(); - while ($i <= $mlw_qmn_landing_total) - { - if ($_POST["message_after_".$i] != "Delete") - { - $mlw_qmn_landing_each = array(intval($_POST["message_after_begin_".$i]), intval($_POST["message_after_end_".$i]), htmlspecialchars(stripslashes($_POST["message_after_".$i]), ENT_QUOTES)); - $mlw_qmn_new_landing_array[] = $mlw_qmn_landing_each; - } - $i++; - } - $mlw_qmn_new_landing_array = serialize($mlw_qmn_new_landing_array); - $mlw_new_landing_results = $wpdb->query( $wpdb->prepare( "UPDATE ".$wpdb->prefix."mlw_quizzes SET message_after='%s', last_activity='".date("Y-m-d H:i:s")."' WHERE quiz_id=%d", $mlw_qmn_new_landing_array, $mlw_qmn_landing_id ) ); - if ($mlw_new_landing_results != false) - { - $mlw_hasSavedLanding = true; - - //Insert Action Into Audit Trail - global $current_user; - get_currentuserinfo(); - $table_name = $wpdb->prefix . "mlw_qm_audit_trail"; - $insert = "INSERT INTO " . $table_name . - "(trail_id, action_user, action, time) " . - "VALUES (NULL , '" . $current_user->display_name . "' , 'Landing Pages Have Been Saved For Quiz Number ".$mlw_qmn_landing_id."' , '" . date("h:i:s A m/d/Y") . "')"; - $results = $wpdb->query( $insert ); - } - else - { - $mlw_qmn_isQueryError = true; - $mlw_qmn_error_code = '0014'; - } - } - - /* - Code For Quiz Style Tab - */ - - if (isset($_POST["save_style_options"]) && $_POST["save_style_options"] == "confirmation") - { - //Function Variables - $mlw_qmn_style_id = intval($_POST["style_quiz_id"]); - $mlw_qmn_theme = $_POST["save_quiz_theme"]; - $mlw_qmn_style = htmlspecialchars(stripslashes($_POST["quiz_css"]), ENT_QUOTES); - - //Save the new css - $mlw_save_stle_results = $wpdb->query( $wpdb->prepare( "UPDATE ".$wpdb->prefix."mlw_quizzes SET quiz_stye='%s', theme_selected='%s', last_activity='".date("Y-m-d H:i:s")."' WHERE quiz_id=%d", $mlw_qmn_style, $mlw_qmn_theme, $mlw_qmn_style_id ) ); - if ($mlw_save_stle_results != false) - { - $mlw_hasSavedStyle = true; - - //Insert Action Into Audit Trail - global $current_user; - get_currentuserinfo(); - $table_name = $wpdb->prefix . "mlw_qm_audit_trail"; - $insert = "INSERT INTO " . $table_name . - "(trail_id, action_user, action, time) " . - "VALUES (NULL , '" . $current_user->display_name . "' , 'Styles Have Been Saved For Quiz Number ".$mlw_qmn_style_id."' , '" . date("h:i:s A m/d/Y") . "')"; - $results = $wpdb->query( $insert ); - } - else - { - $mlw_qmn_isQueryError = true; - $mlw_qmn_error_code = '0015'; - } - } - - - /* - Code For Quiz Tools Tab - */ - - //Update Quiz Table - if (isset($_POST["mlw_reset_quiz_stats"]) && $_POST["mlw_reset_quiz_stats"] == "confirmation") - { - //Variables from reset stats form - $mlw_reset_stats_quiz_id = $_POST["mlw_reset_quiz_id"]; - $mlw_reset_update_sql = "UPDATE " . $wpdb->prefix . "mlw_quizzes" . " SET quiz_views=0, quiz_taken=0, last_activity='".date("Y-m-d H:i:s")."' WHERE quiz_id=".$mlw_reset_stats_quiz_id; - $mlw_reset_sql_results = $wpdb->query( $mlw_reset_update_sql ); - if ($mlw_reset_sql_results != false) - { - $mlw_hasResetQuizStats = true; - - //Insert Action Into Audit Trail - global $current_user; - get_currentuserinfo(); - $table_name = $wpdb->prefix . "mlw_qm_audit_trail"; - $insert = "INSERT INTO " . $table_name . - "(trail_id, action_user, action, time) " . - "VALUES (NULL , '" . $current_user->display_name . "' , 'Quiz Stats Have Been Reset For Quiz Number ".$mlw_leaderboard_quiz_id."' , '" . date("h:i:s A m/d/Y") . "')"; - $results = $wpdb->query( $insert ); - } - else - { - $mlw_qmn_isQueryError = true; - $mlw_qmn_error_code = '0010'; - } - } - - - /* - Code to load entire page - */ - - //Load all quiz data - if ($quiz_id != "") - { - $sql = "SELECT * FROM " . $wpdb->prefix . "mlw_quizzes" . " WHERE quiz_id=".$quiz_id; - $mlw_quiz_options = $wpdb->get_results($sql); - - foreach($mlw_quiz_options as $testing) { - $mlw_quiz_options = $testing; - break; - } - } - - //Load and prepare answer arrays - $mlw_qmn_answer_arrays = array(); - foreach($mlw_question_data as $mlw_question_info) { - $mlw_qmn_answer_array_each = @unserialize($mlw_question_info->answer_array); - if ( !is_array($mlw_qmn_answer_array_each) ) - { - $mlw_answer_array_correct = array(0, 0, 0, 0, 0, 0); - $mlw_answer_array_correct[$mlw_question_info->correct_answer-1] = 1; - $mlw_qmn_answer_arrays[$mlw_question_info->question_id] = array( - array($mlw_question_info->answer_one, $mlw_question_info->answer_one_points, $mlw_answer_array_correct[0]), - array($mlw_question_info->answer_two, $mlw_question_info->answer_two_points, $mlw_answer_array_correct[1]), - array($mlw_question_info->answer_three, $mlw_question_info->answer_three_points, $mlw_answer_array_correct[2]), - array($mlw_question_info->answer_four, $mlw_question_info->answer_four_points, $mlw_answer_array_correct[3]), - array($mlw_question_info->answer_five, $mlw_question_info->answer_five_points, $mlw_answer_array_correct[4]), - array($mlw_question_info->answer_six, $mlw_question_info->answer_six_points, $mlw_answer_array_correct[5])); - } - else - { - $mlw_qmn_answer_arrays[$mlw_question_info->question_id] = $mlw_qmn_answer_array_each; - } - } - - - //Load Certificate Options Variables - $mlw_certificate_options = @unserialize($mlw_quiz_options->certificate_template); - if (!is_array($mlw_certificate_options)) { - // something went wrong, initialize to empty array - $mlw_certificate_options = array('Enter title here', 'Enter text here', '', '', 1); - } - - - //Load Email Templates - $mlw_qmn_user_email_array = @unserialize($mlw_quiz_options->user_email_template); - if (!is_array($mlw_qmn_user_email_array)) { - // something went wrong, initialize to empty array - $mlw_qmn_user_email_array = array(array(0, 0, $mlw_quiz_options->user_email_template, 'Quiz Results For %QUIZ_NAME%')); - } - - //Load Landing Pages - $mlw_message_after_array = @unserialize($mlw_quiz_options->message_after); - if (!is_array($mlw_message_after_array)) { - // something went wrong, initialize to empty array - $mlw_message_after_array = array(array(0, 0, $mlw_quiz_options->message_after)); - } - - //Load Pagination Text - $mlw_qmn_pagination_text = ""; - $mlw_qmn_pagination_text = @unserialize($mlw_quiz_options->pagination_text); - if (!is_array($mlw_qmn_pagination_text)) { - $mlw_qmn_pagination_text = array('Previous', $mlw_quiz_options->pagination_text); - } - ?> - - - - - - -
    -
    -

    Quiz Settings For quiz_name; ?>(?)

    - -
    -

    - Success! Your leaderboard options for this quiz have been saved.

    -
    - -
    -

    - Uh-Oh! There has been an error in this action! Please share this with the developer: Error Code

    -
    - -
    -

    - Success! Your new question has been created successfully.

    -
    - -
    -

    - Success! Your templates for this quiz have been saved.

    -
    - -
    -

    - Success! Your options for this quiz have been saved.

    -
    - -
    -

    - Success! The question has been deleted from this quiz.

    -
    - -
    -

    - Success! The question has been duplicated.

    -
    - -
    -

    - Success! The question has been updated.

    -
    - -
    -

    - Success! The stats for this quiz has been reset!

    -
    - -
    -

    - Success! A new results page has been added successfully!

    -
    - -
    -

    - Success! The results pages have been saved successfully!

    -
    - -
    -

    - Success! A new email has been added successfully!

    -
    - -
    -

    - Success! The email templates have been saved successfully!

    -
    - -
    -

    - Success! The certificate options have been saved successfully!

    -
    - -
    -

    - Success! The styles have been saved successfully!

    -
    - num_rows; ?> -
    - -
    - -
    - question_settings); - if (!is_array($mlw_question_settings)) { - $mlw_question_settings = array(); - $mlw_question_settings['required'] = 1; - } - $mlw_question_type_text = ""; - switch ($mlw_question_info->question_type) { - case 0: - $mlw_question_type_text = "Multiple Choice"; - break; - case 1: - $mlw_question_type_text = "Horizontal Multiple Choice"; - break; - case 2: - $mlw_question_type_text = "Drop Down"; - break; - case 3: - $mlw_question_type_text = "Small Open Answer"; - break; - case 4: - $mlw_question_type_text = "Multiple Response"; - break; - case 5: - $mlw_question_type_text = "Large Open Answer"; - break; - case 6: - $mlw_question_type_text = "Text Block"; - break; - case 7: - $mlw_question_type_text = "Number"; - break; - case 8: - $mlw_question_type_text = "Accept"; - break; - case 9: - $mlw_question_type_text = "Captcha"; - break; - case 10: - $mlw_question_type_text = "Horizontal Multiple Response"; - break; - default: - $mlw_question_type_text = "Error Code "; - } - if($alternate) $alternate = ""; - else $alternate = " class=\"alternate\""; - $question_list .= ""; - $question_list .= "
    "; - $question_list .= ""; - $question_list .= ""; - $question_list .= ""; - - - $mlw_question_answer_array = $mlw_qmn_answer_arrays[$mlw_question_info->question_id]; - ?> -
    Time Taken: time_taken; ?>
    Name Provided: name; ?>View|result_id."','".esc_js($mlw_quiz_info->quiz_name)."')\" href='#'>Delete" . $mlw_quiz_info->quiz_name . "Not Graded" . $mlw_complete_time ."" . $mlw_quiz_info->name ."" . $mlw_quiz_info->business ."" . $mlw_quiz_info->email ."Actions Quiz Name ScoreTime To Complete Name Business Email" . $mlw_question_info->question_order . "" . $mlw_question_type_text . "" . $mlw_question_info->question_name ."
    - - - - - - - - - - - - - - - - - - - - - - -
    Question - -
      
     AnswersPoints WorthCorrect Answer
    Answer - - - - value=1 />
    - Add New Answer! -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    Correct Answer Info:
    Hint - -
     
     
    Question Type - -
    Comment Field - comments == 0) { echo 'checked="checked"'; } ?>/> - comments == 2) { echo 'checked="checked"'; } ?>/> - comments == 1) { echo 'checked="checked"'; } ?>/> -
    Question Order - -
    Required? - -
    -

    *Required currently only works on open answer, number, and captcha question types

    - -

    - -
    - - + + + +
    + question_settings); + if (!is_array($mlw_question_settings)) { + $mlw_question_settings = array(); + $mlw_question_settings['required'] = 1; + } + $mlw_question_type_text = ""; + switch ($mlw_question_info->question_type) { + case 0: + $mlw_question_type_text = "Multiple Choice"; + break; + case 1: + $mlw_question_type_text = "Horizontal Multiple Choice"; + break; + case 2: + $mlw_question_type_text = "Drop Down"; + break; + case 3: + $mlw_question_type_text = "Small Open Answer"; + break; + case 4: + $mlw_question_type_text = "Multiple Response"; + break; + case 5: + $mlw_question_type_text = "Large Open Answer"; + break; + case 6: + $mlw_question_type_text = "Text Block"; + break; + case 7: + $mlw_question_type_text = "Number"; + break; + case 8: + $mlw_question_type_text = "Accept"; + break; + case 9: + $mlw_question_type_text = "Captcha"; + break; + case 10: + $mlw_question_type_text = "Horizontal Multiple Response"; + break; + default: + $mlw_question_type_text = "Error Code "; + } + if($alternate) $alternate = ""; + else $alternate = " class=\"alternate\""; + $question_list .= ""; + $question_list .= "" . $mlw_question_info->question_order . ""; + $question_list .= "" . $mlw_question_type_text . ""; + $question_list .= "" . $mlw_question_info->question_name .""; + $question_list .= ""; + + $mlw_question_answer_array = $mlw_qmn_answer_arrays[$mlw_question_info->question_id]; + ?> + - + +

    + + + 0 ) + { + $mlw_qmn_previous_page = $mlw_qmn_question_page - 2; + $display .= "Previous 10 Questions"; + if( $mlw_qmn_question_left > $mlw_qmn_table_limit ) + { + $display .= "Next 10 Questions"; + } + } + else if( $mlw_qmn_question_page == 0 ) + { + if( $mlw_qmn_question_left > $mlw_qmn_table_limit ) + { + $display .= "Next 10 Questions"; + } + } + else if( $mlw_qmn_question_left < $mlw_qmn_table_limit ) + { + $mlw_qmn_previous_page = $mlw_qmn_question_page - 2; + $display .= "Previous 10 Questions"; + } + $display .= ""; + $display .= " + + + + "; + $display .= "{$question_list}"; + $display .= " + + + + "; + $display .= "
    Question OrderQuestion TypeQuestion
    Question OrderQuestion TypeQuestion
    "; + echo $display; + ?> + + + + + + + + -
    +function mlw_options_text_tab_content() +{ + global $wpdb; + $quiz_id = $_GET["quiz_id"]; + //Submit saved templates into database + if ( isset($_POST["save_templates"]) && $_POST["save_templates"] == "confirmation") + { + //Variables for save templates form + $mlw_before_message = htmlspecialchars($_POST["mlw_quiz_before_message"], ENT_QUOTES); + $mlw_qmn_message_end = htmlspecialchars($_POST["message_end_template"], ENT_QUOTES); + $mlw_qmn_social_medi_text = htmlspecialchars($_POST["mlw_quiz_social_media_text_template"], ENT_QUOTES); + $mlw_user_tries_text = htmlspecialchars($_POST["mlw_quiz_total_user_tries_text"], ENT_QUOTES); + $mlw_submit_button_text = htmlspecialchars($_POST["mlw_submitText"], ENT_QUOTES); + $mlw_name_field_text = htmlspecialchars($_POST["mlw_nameText"], ENT_QUOTES); + $mlw_business_field_text = htmlspecialchars($_POST["mlw_businessText"], ENT_QUOTES); + $mlw_email_field_text = htmlspecialchars($_POST["mlw_emailText"], ENT_QUOTES); + $mlw_phone_field_text = htmlspecialchars($_POST["mlw_phoneText"], ENT_QUOTES); + $mlw_before_comments = htmlspecialchars($_POST["mlw_quiz_before_comments"], ENT_QUOTES); + $mlw_comment_field_text = htmlspecialchars($_POST["mlw_commentText"], ENT_QUOTES); + $mlw_qmn_pagination_field = serialize(array( $_POST["pagination_prev_text"], $_POST["pagination_next_text"] )); + $mlw_email_from_text = $_POST["emailFromText"]; + $mlw_question_answer_template = htmlspecialchars($_POST["mlw_quiz_question_answer_template"], ENT_QUOTES); + $quiz_id = $_POST["quiz_id"]; + + $update = "UPDATE " . $wpdb->prefix . "mlw_quizzes" . " SET message_before='".$mlw_before_message."', message_comment='".$mlw_before_comments."', message_end_template='".$mlw_qmn_message_end."', comment_field_text='".$mlw_comment_field_text."', email_from_text='".$mlw_email_from_text."', question_answer_template='".$mlw_question_answer_template."', submit_button_text='".$mlw_submit_button_text."', name_field_text='".$mlw_name_field_text."', business_field_text='".$mlw_business_field_text."', email_field_text='".$mlw_email_field_text."', phone_field_text='".$mlw_phone_field_text."', total_user_tries_text='".$mlw_user_tries_text."', social_media_text='".$mlw_qmn_social_medi_text."', pagination_text='".$mlw_qmn_pagination_field."', last_activity='".date("Y-m-d H:i:s")."' WHERE quiz_id=".$quiz_id; + $results = $wpdb->query( $update ); + if ($results != false) + { + $hasUpdatedTemplates = true; + + //Insert Action Into Audit Trail + global $current_user; + get_currentuserinfo(); + $table_name = $wpdb->prefix . "mlw_qm_audit_trail"; + $insert = "INSERT INTO " . $table_name . + "(trail_id, action_user, action, time) " . + "VALUES (NULL , '" . $current_user->display_name . "' , 'Templates Have Been Edited For Quiz Number ".$quiz_id."' , '" . date("h:i:s A m/d/Y") . "')"; + $results = $wpdb->query( $insert ); + } + else + { + $mlw_qmn_isQueryError = true; + $mlw_qmn_error_code = '0007'; + } + } + + if (isset($_GET["quiz_id"])) + { + $table_name = $wpdb->prefix . "mlw_quizzes"; + $mlw_quiz_options = $wpdb->get_row($wpdb->prepare("SELECT * FROM $table_name WHERE quiz_id=%d LIMIT 1", $_GET["quiz_id"])); + } + + //Load Pagination Text + $mlw_qmn_pagination_text = ""; + $mlw_qmn_pagination_text = @unserialize($mlw_quiz_options->pagination_text); + if (!is_array($mlw_qmn_pagination_text)) { + $mlw_qmn_pagination_text = array('Previous', $mlw_quiz_options->pagination_text); + } + ?> +

    Template Variables

    @@ -1741,7 +1282,71 @@ function mlw_qmn_theme(theme) "; ?> -
    + prefix . "mlw_quizzes" . " SET system='".$mlw_system."', send_user_email='".$mlw_send_user_email."', send_admin_email='".$mlw_send_admin_email."', loggedin_user_contact='".$mlw_qmn_loggedin_contact."', contact_info_location=".$mlw_contact_location.", user_name='".$mlw_user_name."', user_comp='".$mlw_user_comp."', user_email='".$mlw_user_email."', user_phone='".$mlw_user_phone."', admin_email='".$mlw_admin_email."', comment_section='".$mlw_comment_section."', randomness_order='".$mlw_randomness_order."', question_from_total=".$mlw_qmn_questions_from_total.", total_user_tries=".$mlw_total_user_tries.", social_media=".$mlw_qmn_social_media.", pagination=".$mlw_qmn_pagination.", timer_limit=".$mlw_qmn_timer.", question_numbering=".$mlw_qmn_question_numbering.", last_activity='".date("Y-m-d H:i:s")."' WHERE quiz_id=".$quiz_id; + $results = $wpdb->query( $update ); + if ($results != false) + { + $hasUpdatedOptions = true; + + //Insert Action Into Audit Trail + global $current_user; + get_currentuserinfo(); + $table_name = $wpdb->prefix . "mlw_qm_audit_trail"; + $insert = "INSERT INTO " . $table_name . + "(trail_id, action_user, action, time) " . + "VALUES (NULL , '" . $current_user->display_name . "' , 'Options Have Been Edited For Quiz Number ".$quiz_id."' , '" . date("h:i:s A m/d/Y") . "')"; + $results = $wpdb->query( $insert ); + } + else + { + $mlw_qmn_isQueryError = true; + $mlw_qmn_error_code = '0008'; + } + } + + if (isset($_GET["quiz_id"])) + { + $table_name = $wpdb->prefix . "mlw_quizzes"; + $mlw_quiz_options = $wpdb->get_row($wpdb->prepare("SELECT * FROM $table_name WHERE quiz_id=%d LIMIT 1", $_GET["quiz_id"])); + } + ?> +
    + "; @@ -1878,6 +1483,47 @@ function mlw_qmn_theme(theme) "; ?>
    + prefix . "mlw_quizzes" . " SET leaderboard_template='".$mlw_leaderboard_template."', last_activity='".date("Y-m-d H:i:s")."' WHERE quiz_id=".$mlw_leaderboard_quiz_id; + $results = $wpdb->query( $update ); + if ($results != false) + { + $hasUpdatedLeaderboardOptions = true; + + //Insert Action Into Audit Trail + global $current_user; + get_currentuserinfo(); + $table_name = $wpdb->prefix . "mlw_qm_audit_trail"; + $insert = "INSERT INTO " . $table_name . + "(trail_id, action_user, action, time) " . + "VALUES (NULL , '" . $current_user->display_name . "' , 'Leaderboard Options Have Been Edited For Quiz Number ".$mlw_leaderboard_quiz_id."' , '" . date("h:i:s A m/d/Y") . "')"; + $results = $wpdb->query( $insert ); + } + else + { + $mlw_qmn_isQueryError = true; + $mlw_qmn_error_code = '0009'; + } + } + + if (isset($_GET["quiz_id"])) + { + $table_name = $wpdb->prefix . "mlw_quizzes"; + $mlw_quiz_options = $wpdb->get_row($wpdb->prepare("SELECT * FROM $table_name WHERE quiz_id=%d LIMIT 1", $_GET["quiz_id"])); + } + ?>

    Template Variables

    @@ -1910,7 +1556,7 @@ function mlw_qmn_theme(theme)
    %QUIZ_NAME% - The name of the quiz
    - + "; echo ""; @@ -1941,7 +1587,66 @@ function mlw_qmn_theme(theme)
    + query( $wpdb->prepare( "UPDATE " . $wpdb->prefix . "mlw_quizzes SET certificate_template=%s, last_activity='".date("Y-m-d H:i:s")."' WHERE quiz_id=%d", $mlw_certificate_serialized, $mlw_certificate_id ) ); + + + if ($mlw_certificate_sql_results != false) + { + $mlw_UpdatedCertificate = true; + + //Insert Action Into Audit Trail + global $current_user; + get_currentuserinfo(); + $table_name = $wpdb->prefix . "mlw_qm_audit_trail"; + $insert = "INSERT INTO " . $table_name . + "(trail_id, action_user, action, time) " . + "VALUES (NULL , '" . $current_user->display_name . "' , 'Certificate Options Have Been Edited For Quiz Number ".$mlw_certificate_id."' , '" . date("h:i:s A m/d/Y") . "')"; + $results = $wpdb->query( $insert ); + } + else + { + $mlw_qmn_isQueryError = true; + $mlw_qmn_error_code = '0012'; + } + } + if (isset($_GET["quiz_id"])) + { + $table_name = $wpdb->prefix . "mlw_quizzes"; + $mlw_quiz_options = $wpdb->get_row($wpdb->prepare("SELECT * FROM $table_name WHERE quiz_id=%d LIMIT 1", $_GET["quiz_id"])); + } + + //Load Certificate Options Variables + $mlw_certificate_options = @unserialize($mlw_quiz_options->certificate_template); + if (!is_array($mlw_certificate_options)) { + // something went wrong, initialize to empty array + $mlw_certificate_options = array('Enter title here', 'Enter text here', '', '', 1); + } + ?>
    +

    Quiz Certificate (Beta)

    Enter in your text here to fill in the certificate for this quiz. Be sure to enter in the link variable into the templates on the Quiz Text tab so the user can access the certificate.

    These fields cannot contain HTML.

    @@ -2004,6 +1709,128 @@ function mlw_qmn_theme(theme)
    + get_var( $wpdb->prepare( "SELECT user_email_template FROM ".$wpdb->prefix."mlw_quizzes WHERE quiz_id=%d", $mlw_qmn_add_email_id ) ); + + //Load user email and check if it is array already. If not, turn it into one + $mlw_qmn_email_array = @unserialize($mlw_qmn_user_email); + if (is_array($mlw_qmn_email_array)) + { + $mlw_new_landing_array = array(0, 100, 'Enter Your Text Here', 'Quiz Results For %QUIZ_NAME%'); + array_unshift($mlw_qmn_email_array , $mlw_new_landing_array); + $mlw_qmn_email_array = serialize($mlw_qmn_email_array); + + } + else + { + $mlw_qmn_email_array = array(array(0, 0, $mlw_qmn_user_email, 'Quiz Results For %QUIZ_NAME%')); + $mlw_new_landing_array = array(0, 100, 'Enter Your Text Here', 'Quiz Results For %QUIZ_NAME%'); + array_unshift($mlw_qmn_email_array , $mlw_new_landing_array); + $mlw_qmn_email_array = serialize($mlw_qmn_email_array); + } + //Update message_after with new array then check to see if worked + $mlw_new_email_results = $wpdb->query( $wpdb->prepare( "UPDATE ".$wpdb->prefix."mlw_quizzes SET user_email_template='%s', last_activity='".date("Y-m-d H:i:s")."' WHERE quiz_id=%d", $mlw_qmn_email_array, $mlw_qmn_add_email_id ) ); + if ($mlw_new_email_results != false) + { + $mlw_hasAddedEmail = true; + + //Insert Action Into Audit Trail + global $current_user; + get_currentuserinfo(); + $table_name = $wpdb->prefix . "mlw_qm_audit_trail"; + $insert = "INSERT INTO " . $table_name . + "(trail_id, action_user, action, time) " . + "VALUES (NULL , '" . $current_user->display_name . "' , 'New User Email Has Been Created For Quiz Number ".$mlw_qmn_add_email_id."' , '" . date("h:i:s A m/d/Y") . "')"; + $results = $wpdb->query( $insert ); + } + else + { + $mlw_qmn_isQueryError = true; + $mlw_qmn_error_code = '0016'; + } + } + + //Check to save email templates + if (isset($_POST["mlw_save_email_template"]) && $_POST["mlw_save_email_template"] == "confirmation") + { + //Function Variables + $mlw_qmn_email_id = intval($_POST["mlw_email_quiz_id"]); + $mlw_qmn_email_template_total = intval($_POST["mlw_email_template_total"]); + $mlw_qmn_admin_email = htmlspecialchars(stripslashes($_POST["mlw_quiz_admin_email_template"]), ENT_QUOTES); + + //Create new array + $i = 1; + $mlw_qmn_new_email_array = array(); + while ($i <= $mlw_qmn_email_template_total) + { + if ($_POST["user_email_".$i] != "Delete") + { + $mlw_qmn_email_each = array(intval($_POST["user_email_begin_".$i]), intval($_POST["user_email_end_".$i]), htmlspecialchars(stripslashes($_POST["user_email_".$i]), ENT_QUOTES), htmlspecialchars(stripslashes($_POST["user_email_subject_".$i]), ENT_QUOTES)); + $mlw_qmn_new_email_array[] = $mlw_qmn_email_each; + } + $i++; + } + $mlw_qmn_new_email_array = serialize($mlw_qmn_new_email_array); + $mlw_new_email_results = $wpdb->query( $wpdb->prepare( "UPDATE ".$wpdb->prefix."mlw_quizzes SET user_email_template='%s', admin_email_template='%s', last_activity='".date("Y-m-d H:i:s")."' WHERE quiz_id=%d", $mlw_qmn_new_email_array, $mlw_qmn_admin_email, $mlw_qmn_email_id ) ); + if ($mlw_new_email_results != false) + { + $mlw_hasSavedEmail = true; + + //Insert Action Into Audit Trail + global $current_user; + get_currentuserinfo(); + $table_name = $wpdb->prefix . "mlw_qm_audit_trail"; + $insert = "INSERT INTO " . $table_name . + "(trail_id, action_user, action, time) " . + "VALUES (NULL , '" . $current_user->display_name . "' , 'Email Templates Have Been Saved For Quiz Number ".$mlw_qmn_email_id."' , '" . date("h:i:s A m/d/Y") . "')"; + $results = $wpdb->query( $insert ); + } + else + { + $mlw_qmn_isQueryError = true; + $mlw_qmn_error_code = '0017'; + } + } + + if (isset($_GET["quiz_id"])) + { + $table_name = $wpdb->prefix . "mlw_quizzes"; + $mlw_quiz_options = $wpdb->get_row($wpdb->prepare("SELECT * FROM $table_name WHERE quiz_id=%d LIMIT 1", $_GET["quiz_id"])); + } + + //Load Email Templates + $mlw_qmn_user_email_array = @unserialize($mlw_quiz_options->user_email_template); + if (!is_array($mlw_qmn_user_email_array)) { + // something went wrong, initialize to empty array + $mlw_qmn_user_email_array = array(array(0, 0, $mlw_quiz_options->user_email_template, 'Quiz Results For %QUIZ_NAME%')); + } + ?> +

    Template Variables

    @@ -2046,7 +1873,6 @@ function mlw_qmn_theme(theme) -

    Email Sent To User

    @@ -2166,7 +1992,120 @@ function mlw_qmn_theme(theme)
    + get_var( $wpdb->prepare( "SELECT message_after FROM ".$wpdb->prefix."mlw_quizzes WHERE quiz_id=%d", $mlw_qmn_landing_id ) ); + //Load message_after and check if it is array already. If not, turn it into one + $mlw_qmn_landing_array = @unserialize($mlw_qmn_message_after); + if (is_array($mlw_qmn_landing_array)) + { + $mlw_new_landing_array = array(0, 100, 'Enter Your Text Here'); + array_unshift($mlw_qmn_landing_array , $mlw_new_landing_array); + $mlw_qmn_landing_array = serialize($mlw_qmn_landing_array); + + } + else + { + $mlw_qmn_landing_array = array(array(0, 0, $mlw_qmn_message_after)); + $mlw_new_landing_array = array(0, 100, 'Enter Your Text Here'); + array_unshift($mlw_qmn_landing_array , $mlw_new_landing_array); + $mlw_qmn_landing_array = serialize($mlw_qmn_landing_array); + } + + //Update message_after with new array then check to see if worked + $mlw_new_landing_results = $wpdb->query( $wpdb->prepare( "UPDATE ".$wpdb->prefix."mlw_quizzes SET message_after=%s, last_activity='".date("Y-m-d H:i:s")."' WHERE quiz_id=%d", $mlw_qmn_landing_array, $mlw_qmn_landing_id ) ); + if ($mlw_new_landing_results != false) + { + $mlw_hasAddedLanding = true; + + //Insert Action Into Audit Trail + global $current_user; + get_currentuserinfo(); + $table_name = $wpdb->prefix . "mlw_qm_audit_trail"; + $insert = "INSERT INTO " . $table_name . + "(trail_id, action_user, action, time) " . + "VALUES (NULL , '" . $current_user->display_name . "' , 'New Landing Page Has Been Created For Quiz Number ".$mlw_qmn_landing_id."' , '" . date("h:i:s A m/d/Y") . "')"; + $results = $wpdb->query( $insert ); + } + else + { + $mlw_qmn_isQueryError = true; + $mlw_qmn_error_code = '0013'; + } + } + + //Check to save landing pages + if (isset($_POST["mlw_save_landing_pages"]) && $_POST["mlw_save_landing_pages"] == "confirmation") + { + //Function Variables + $mlw_qmn_landing_id = intval($_POST["mlw_landing_quiz_id"]); + $mlw_qmn_landing_total = intval($_POST["mlw_landing_page_total"]); + + //Create new array + $i = 1; + $mlw_qmn_new_landing_array = array(); + while ($i <= $mlw_qmn_landing_total) + { + if ($_POST["message_after_".$i] != "Delete") + { + $mlw_qmn_landing_each = array(intval($_POST["message_after_begin_".$i]), intval($_POST["message_after_end_".$i]), htmlspecialchars(stripslashes($_POST["message_after_".$i]), ENT_QUOTES)); + $mlw_qmn_new_landing_array[] = $mlw_qmn_landing_each; + } + $i++; + } + $mlw_qmn_new_landing_array = serialize($mlw_qmn_new_landing_array); + $mlw_new_landing_results = $wpdb->query( $wpdb->prepare( "UPDATE ".$wpdb->prefix."mlw_quizzes SET message_after='%s', last_activity='".date("Y-m-d H:i:s")."' WHERE quiz_id=%d", $mlw_qmn_new_landing_array, $mlw_qmn_landing_id ) ); + if ($mlw_new_landing_results != false) + { + $mlw_hasSavedLanding = true; + + //Insert Action Into Audit Trail + global $current_user; + get_currentuserinfo(); + $table_name = $wpdb->prefix . "mlw_qm_audit_trail"; + $insert = "INSERT INTO " . $table_name . + "(trail_id, action_user, action, time) " . + "VALUES (NULL , '" . $current_user->display_name . "' , 'Landing Pages Have Been Saved For Quiz Number ".$mlw_qmn_landing_id."' , '" . date("h:i:s A m/d/Y") . "')"; + $results = $wpdb->query( $insert ); + } + else + { + $mlw_qmn_isQueryError = true; + $mlw_qmn_error_code = '0014'; + } + } + + if (isset($_GET["quiz_id"])) + { + $table_name = $wpdb->prefix . "mlw_quizzes"; + $mlw_quiz_options = $wpdb->get_row($wpdb->prepare("SELECT * FROM $table_name WHERE quiz_id=%d LIMIT 1", $_GET["quiz_id"])); + } + + //Load Landing Pages + $mlw_message_after_array = @unserialize($mlw_quiz_options->message_after); + if (!is_array($mlw_message_after_array)) { + // something went wrong, initialize to empty array + $mlw_message_after_array = array(array(0, 0, $mlw_quiz_options->message_after)); + } + ?>
    +

    Template Variables

    @@ -2209,7 +2148,6 @@ function mlw_qmn_theme(theme)
    -
    @@ -2287,7 +2225,58 @@ function mlw_qmn_theme(theme) + query( $wpdb->prepare( "UPDATE ".$wpdb->prefix."mlw_quizzes SET quiz_stye='%s', theme_selected='%s', last_activity='".date("Y-m-d H:i:s")."' WHERE quiz_id=%d", $mlw_qmn_style, $mlw_qmn_theme, $mlw_qmn_style_id ) ); + if ($mlw_save_stle_results != false) + { + $mlw_hasSavedStyle = true; + + //Insert Action Into Audit Trail + global $current_user; + get_currentuserinfo(); + $table_name = $wpdb->prefix . "mlw_qm_audit_trail"; + $insert = "INSERT INTO " . $table_name . + "(trail_id, action_user, action, time) " . + "VALUES (NULL , '" . $current_user->display_name . "' , 'Styles Have Been Saved For Quiz Number ".$mlw_qmn_style_id."' , '" . date("h:i:s A m/d/Y") . "')"; + $results = $wpdb->query( $insert ); + } + else + { + $mlw_qmn_isQueryError = true; + $mlw_qmn_error_code = '0015'; + } + } + + if (isset($_GET["quiz_id"])) + { + $table_name = $wpdb->prefix . "mlw_quizzes"; + $mlw_quiz_options = $wpdb->get_row($wpdb->prepare("SELECT * FROM $table_name WHERE quiz_id=%d LIMIT 1", $_GET["quiz_id"])); + } + ?>
    + "; echo ""; @@ -2391,6 +2380,66 @@ function mlw_qmn_theme(theme)
    + prefix . "mlw_quizzes" . " SET quiz_views=0, quiz_taken=0, last_activity='".date("Y-m-d H:i:s")."' WHERE quiz_id=".$mlw_reset_stats_quiz_id; + $mlw_reset_sql_results = $wpdb->query( $mlw_reset_update_sql ); + if ($mlw_reset_sql_results != false) + { + $mlw_hasResetQuizStats = true; + + //Insert Action Into Audit Trail + global $current_user; + get_currentuserinfo(); + $table_name = $wpdb->prefix . "mlw_qm_audit_trail"; + $insert = "INSERT INTO " . $table_name . + "(trail_id, action_user, action, time) " . + "VALUES (NULL , '" . $current_user->display_name . "' , 'Quiz Stats Have Been Reset For Quiz Number ".$mlw_leaderboard_quiz_id."' , '" . date("h:i:s A m/d/Y") . "')"; + $results = $wpdb->query( $insert ); + } + else + { + $mlw_qmn_isQueryError = true; + $mlw_qmn_error_code = '0010'; + } + } + + if (isset($_GET["quiz_id"])) + { + $table_name = $wpdb->prefix . "mlw_quizzes"; + $mlw_quiz_options = $wpdb->get_row($wpdb->prepare("SELECT * FROM $table_name WHERE quiz_id=%d LIMIT 1", $_GET["quiz_id"])); + } + ?> +

    Use this button to reset all the stats collected for this quiz (Quiz Views and Times Quiz Has Been Taken).

    @@ -2406,91 +2455,7 @@ function mlw_qmn_theme(theme) ?>
    - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    -
    -

    - Hey! Please go to the quizzes page and click on the Edit link from the quiz you wish to edit.

    -
    - - \ No newline at end of file From 2802d114e34681bfe60404828795ceb5e955cf2d Mon Sep 17 00:00:00 2001 From: Frank Corso Date: Wed, 19 Nov 2014 14:55:42 -0500 Subject: [PATCH 06/17] Added Preview (Beta) Mode Resolves #12 Added a tab on the quiz settings page to show a preview of the quiz. --- includes/mlw_quiz_options.php | 60 ++++++++++++++++++++++++----------- 1 file changed, 42 insertions(+), 18 deletions(-) diff --git a/includes/mlw_quiz_options.php b/includes/mlw_quiz_options.php index 0ad3dfb8f..7b08b2a50 100644 --- a/includes/mlw_quiz_options.php +++ b/includes/mlw_quiz_options.php @@ -56,6 +56,13 @@ function mlw_generate_quiz_options() $j( "#tabs" ).tabs(); }); +

    Quiz Settings For quiz_name; ?>

    @@ -232,42 +239,47 @@ function mlw_generate_quiz_options() add_action('mlw_qmn_options_tab', 'mlw_options_results_tab'); add_action('mlw_qmn_options_tab', 'mlw_options_styling_tab'); add_action('mlw_qmn_options_tab', 'mlw_options_tools_tab'); +add_action('mlw_qmn_options_tab', 'mlw_options_preview_tab'); function mlw_options_questions_tab() { - echo "
  • Quiz Questions
  • "; + echo "
  • Questions
  • "; } function mlw_options_text_tab() { - echo "
  • Quiz Text
  • "; + echo "
  • Text
  • "; } function mlw_options_option_tab() { - echo "
  • Quiz Options
  • "; + echo "
  • Options
  • "; } function mlw_options_leaderboard_tab() { - echo "
  • Quiz Leaderboard
  • "; + echo "
  • Leaderboard
  • "; } function mlw_options_certificate_tab() { - echo "
  • Quiz Certificate (Beta)
  • "; + echo "
  • Certificate (Beta)
  • "; } function mlw_options_emails_tab() { - echo "
  • Quiz Emails
  • "; + echo "
  • Emails
  • "; } function mlw_options_results_tab() { - echo "
  • Quiz Results Page
  • "; + echo "
  • Results Page
  • "; } function mlw_options_styling_tab() { - echo "
  • Quiz Styling
  • "; + echo "
  • Styling
  • "; } function mlw_options_tools_tab() { - echo "
  • Quiz Tools/Add-Ons
  • "; + echo "
  • Tools/Add-Ons
  • "; +} +function mlw_options_preview_tab() +{ + echo "
  • Preview (Beta)
  • "; } add_action('mlw_qmn_options_tab_content', 'mlw_options_questions_tab_content'); @@ -279,6 +291,7 @@ function mlw_options_tools_tab() add_action('mlw_qmn_options_tab_content', 'mlw_options_results_tab_content'); add_action('mlw_qmn_options_tab_content', 'mlw_options_styling_tab_content'); add_action('mlw_qmn_options_tab_content', 'mlw_options_tools_tab_content'); +add_action('mlw_qmn_options_tab_content', 'mlw_options_preview_tab_content'); function mlw_options_questions_tab_content() { @@ -567,7 +580,7 @@ function mlw_options_questions_tab_content() } $is_new_quiz = $wpdb->num_rows; ?> -
    +
    -

    Template Variables

    @@ -2098,7 +2112,7 @@ function mlw_options_results_tab_content() $mlw_message_after_array = array(array(0, 0, $mlw_quiz_options->message_after)); } ?> -
    +
    -

    Use this button to reset all the stats collected for this quiz (Quiz Views and Times Quiz Has Been Taken).

    @@ -2458,4 +2472,14 @@ function mlw_options_tools_tab_content() +
    + +
    + \ No newline at end of file From 6f620bdd892b5cfbfd77bebad095d5a0ff498d54 Mon Sep 17 00:00:00 2001 From: Frank Corso Date: Wed, 19 Nov 2014 15:02:59 -0500 Subject: [PATCH 07/17] Creating new file for alerts class This class will be used for success/error messages in admin pages. --- includes/mlw_alerts.php | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 includes/mlw_alerts.php diff --git a/includes/mlw_alerts.php b/includes/mlw_alerts.php new file mode 100644 index 000000000..6eff33c4e --- /dev/null +++ b/includes/mlw_alerts.php @@ -0,0 +1,4 @@ + From 4154f54005da142af7c227d4e30ed371a0701596 Mon Sep 17 00:00:00 2001 From: Frank Corso Date: Wed, 19 Nov 2014 15:33:45 -0500 Subject: [PATCH 08/17] Created Alert Class Created the MlwQmnAlertManager class. This class stores alerts in array and then displays the alerts. --- includes/mlw_alerts.php | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/includes/mlw_alerts.php b/includes/mlw_alerts.php index 6eff33c4e..e2b5f3ece 100644 --- a/includes/mlw_alerts.php +++ b/includes/mlw_alerts.php @@ -1,4 +1,30 @@ alerts[] = array( 'message' => $message, 'type' => $type ); + } + + public function showAlerts() + { + $alert_list = ""; + foreach ($this->alerts as $alert) + { + if ($alert['type'] == "success") + { + $alert_list .= "

    Success! ".$alert["message"]."

    "; + } + if ($alert['type'] == "error") + { + $alert_list .= "

    Error! ".$alert["message"]."

    "; + } + } + echo $alert_list; + } + +} +$mlwQmnAlertManager = new MlwQmnAlertManager(); ?> From 1286f0faba7b2ff095c5a0b102d034508f87609d Mon Sep 17 00:00:00 2001 From: Frank Corso Date: Wed, 19 Nov 2014 15:34:47 -0500 Subject: [PATCH 09/17] Replaced Old Error System With Alert Class Replaced old error system with the new alert class. --- includes/mlw_quiz_options.php | 236 ++++++---------------------------- 1 file changed, 41 insertions(+), 195 deletions(-) diff --git a/includes/mlw_quiz_options.php b/includes/mlw_quiz_options.php index 7b08b2a50..5092fea7f 100644 --- a/includes/mlw_quiz_options.php +++ b/includes/mlw_quiz_options.php @@ -9,29 +9,13 @@ function mlw_generate_quiz_options() { global $wpdb; + global $mlwQmnAlertManager; $quiz_id = $_GET["quiz_id"]; if (isset($_GET["quiz_id"])) { $table_name = $wpdb->prefix . "mlw_quizzes"; $mlw_quiz_options = $wpdb->get_row($wpdb->prepare("SELECT * FROM $table_name WHERE quiz_id=%d LIMIT 1", $_GET["quiz_id"])); - } - $is_new_quiz = 0; - $hasUpdatedLeaderboardOptions = false; - $hasCreatedQuestion = false; - $hasUpdatedOptions = false; - $hasUpdatedTemplates = false; - $hasDeletedQuestion = false; - $hasDuplicatedQuestion = false; - $hasUpdatedQuestion = false; - $mlw_UpdatedCertificate = false; - $mlw_hasResetQuizStats = false; - $mlw_hasAddedLanding = false; - $mlw_hasSavedLanding = false; - $mlw_hasAddedEmail = false; - $mlw_hasSavedEmail = false; - $mlw_hasSavedStyle = false; - $mlw_qmn_isQueryError = false; - $mlw_qmn_error_code = '0000'; + } ?> @@ -66,141 +50,8 @@ function mlw_generate_quiz_options()

    Quiz Settings For quiz_name; ?>

    - -
    -

    - Success! Your leaderboard options for this quiz have been saved.

    -
    - -
    -

    - Uh-Oh! There has been an error in this action! Please share this with the developer: Error Code

    -
    - -
    -

    - Success! Your new question has been created successfully.

    -
    - -
    -

    - Success! Your templates for this quiz have been saved.

    -
    - -
    -

    - Success! Your options for this quiz have been saved.

    -
    - -
    -

    - Success! The question has been deleted from this quiz.

    -
    - -
    -

    - Success! The question has been duplicated.

    -
    - -
    -

    - Success! The question has been updated.

    -
    - -
    -

    - Success! The stats for this quiz has been reset!

    -
    - -
    -

    - Success! A new results page has been added successfully!

    -
    - -
    -

    - Success! The results pages have been saved successfully!

    -
    - -
    -

    - Success! A new email has been added successfully!

    -
    - -
    -

    - Success! The email templates have been saved successfully!

    -
    - -
    -

    - Success! The certificate options have been saved successfully!

    -
    - -
    -

    - Success! The styles have been saved successfully!

    -
    - showAlerts(); if ($quiz_id != "") { ?> @@ -296,6 +147,7 @@ function mlw_options_preview_tab() function mlw_options_questions_tab_content() { global $wpdb; + global $mlwQmnAlertManager; $quiz_id = $_GET["quiz_id"]; //Edit question @@ -346,7 +198,7 @@ function mlw_options_questions_tab_content() $results = $wpdb->query( $update ); if ($results != false) { - $hasUpdatedQuestion = true; + $mlwQmnAlertManager->newAlert('The question has been updated successfully.', 'success'); //Insert Action Into Audit Trail global $current_user; @@ -359,8 +211,7 @@ function mlw_options_questions_tab_content() } else { - $mlw_qmn_isQueryError = true; - $mlw_qmn_error_code = '0004'; + $mlwQmnAlertManager->newAlert('There has been an error in this action. Please share this with the developer. Error Code: 0004.', 'error'); } } @@ -375,7 +226,7 @@ function mlw_options_questions_tab_content() $results = $wpdb->query( $update ); if ($results != false) { - $hasDeletedQuestion = true; + $mlwQmnAlertManager->newAlert('The question has been deleted successfully.', 'success'); //Insert Action Into Audit Trail global $current_user; @@ -388,8 +239,7 @@ function mlw_options_questions_tab_content() } else { - $mlw_qmn_isQueryError = true; - $mlw_qmn_error_code = '0002'; + $mlwQmnAlertManager->newAlert('There has been an error in this action. Please share this with the developer. Error Code: 0005.', 'error'); } } @@ -458,7 +308,7 @@ function mlw_options_questions_tab_content() if ($results != false) { - $hasDuplicatedQuestion = true; + $mlwQmnAlertManager->newAlert('The question has been duplicated successfully.', 'success'); //Insert Action Into Audit Trail global $current_user; @@ -471,8 +321,7 @@ function mlw_options_questions_tab_content() } else { - $mlw_qmn_isQueryError = true; - $mlw_qmn_error_code = '0019'; + $mlwQmnAlertManager->newAlert('There has been an error in this action. Please share this with the developer. Error Code: 0019.', 'error'); } } @@ -515,7 +364,7 @@ function mlw_options_questions_tab_content() $results = $wpdb->query( $insert ); if ($results != false) { - $hasCreatedQuestion = true; + $mlwQmnAlertManager->newAlert('The question has been created successfully.', 'success'); //Insert Action Into Audit Trail global $current_user; @@ -528,8 +377,7 @@ function mlw_options_questions_tab_content() } else { - $mlw_qmn_isQueryError = true; - $mlw_qmn_error_code = '0006'; + $mlwQmnAlertManager->newAlert('There has been an error in this action. Please share this with the developer. Error Code: 0006.', 'error'); } } @@ -1059,6 +907,7 @@ function mlw_add_answer_to_new_question() function mlw_options_text_tab_content() { global $wpdb; + global $mlwQmnAlertManager; $quiz_id = $_GET["quiz_id"]; //Submit saved templates into database if ( isset($_POST["save_templates"]) && $_POST["save_templates"] == "confirmation") @@ -1084,7 +933,7 @@ function mlw_options_text_tab_content() $results = $wpdb->query( $update ); if ($results != false) { - $hasUpdatedTemplates = true; + $mlwQmnAlertManager->newAlert('The templates has been updated successfully.', 'success'); //Insert Action Into Audit Trail global $current_user; @@ -1097,8 +946,7 @@ function mlw_options_text_tab_content() } else { - $mlw_qmn_isQueryError = true; - $mlw_qmn_error_code = '0007'; + $mlwQmnAlertManager->newAlert('There has been an error in this action. Please share this with the developer. Error Code: 0007.', 'error'); } } @@ -1301,6 +1149,7 @@ function mlw_options_text_tab_content() function mlw_options_option_tab_content() { global $wpdb; + global $mlwQmnAlertManager; $quiz_id = $_GET["quiz_id"]; //Submit saved options into database if ( isset($_POST["save_options"]) && $_POST["save_options"] == "confirmation") @@ -1330,7 +1179,7 @@ function mlw_options_option_tab_content() $results = $wpdb->query( $update ); if ($results != false) { - $hasUpdatedOptions = true; + $mlwQmnAlertManager->newAlert('The options has been updated successfully.', 'success'); //Insert Action Into Audit Trail global $current_user; @@ -1343,8 +1192,7 @@ function mlw_options_option_tab_content() } else { - $mlw_qmn_isQueryError = true; - $mlw_qmn_error_code = '0008'; + $mlwQmnAlertManager->newAlert('There has been an error in this action. Please share this with the developer. Error Code: 0008.', 'error'); } } @@ -1502,6 +1350,7 @@ function mlw_options_option_tab_content() function mlw_options_leaderboard_tab_content() { global $wpdb; + global $mlwQmnAlertManager; $quiz_id = $_GET["quiz_id"]; ///Submit saved leaderboard template into database if ( isset($_POST["save_leaderboard_options"]) && $_POST["save_leaderboard_options"] == "confirmation") @@ -1513,7 +1362,7 @@ function mlw_options_leaderboard_tab_content() $results = $wpdb->query( $update ); if ($results != false) { - $hasUpdatedLeaderboardOptions = true; + $mlwQmnAlertManager->newAlert('The leaderboards has been updated successfully.', 'success'); //Insert Action Into Audit Trail global $current_user; @@ -1526,8 +1375,7 @@ function mlw_options_leaderboard_tab_content() } else { - $mlw_qmn_isQueryError = true; - $mlw_qmn_error_code = '0009'; + $mlwQmnAlertManager->newAlert('There has been an error in this action. Please share this with the developer. Error Code: 0009.', 'error'); } } @@ -1606,6 +1454,7 @@ function mlw_options_leaderboard_tab_content() function mlw_options_certificate_tab_content() { global $wpdb; + global $mlwQmnAlertManager; $quiz_id = $_GET["quiz_id"]; //Saved Certificate Options if (isset($_POST["save_certificate_options"]) && $_POST["save_certificate_options"] == "confirmation") @@ -1624,7 +1473,7 @@ function mlw_options_certificate_tab_content() if ($mlw_certificate_sql_results != false) { - $mlw_UpdatedCertificate = true; + $mlwQmnAlertManager->newAlert('The certificate has been updated successfully.', 'success'); //Insert Action Into Audit Trail global $current_user; @@ -1637,8 +1486,7 @@ function mlw_options_certificate_tab_content() } else { - $mlw_qmn_isQueryError = true; - $mlw_qmn_error_code = '0012'; + $mlwQmnAlertManager->newAlert('There has been an error in this action. Please share this with the developer. Error Code: 0012.', 'error'); } } if (isset($_GET["quiz_id"])) @@ -1728,6 +1576,7 @@ function mlw_options_certificate_tab_content() function mlw_options_emails_tab_content() { global $wpdb; + global $mlwQmnAlertManager; $quiz_id = $_GET["quiz_id"]; //Check to add new user email template if (isset($_POST["mlw_add_email_page"]) && $_POST["mlw_add_email_page"] == "confirmation") @@ -1756,7 +1605,7 @@ function mlw_options_emails_tab_content() $mlw_new_email_results = $wpdb->query( $wpdb->prepare( "UPDATE ".$wpdb->prefix."mlw_quizzes SET user_email_template='%s', last_activity='".date("Y-m-d H:i:s")."' WHERE quiz_id=%d", $mlw_qmn_email_array, $mlw_qmn_add_email_id ) ); if ($mlw_new_email_results != false) { - $mlw_hasAddedEmail = true; + $mlwQmnAlertManager->newAlert('The email has been added successfully.', 'success'); //Insert Action Into Audit Trail global $current_user; @@ -1769,8 +1618,7 @@ function mlw_options_emails_tab_content() } else { - $mlw_qmn_isQueryError = true; - $mlw_qmn_error_code = '0016'; + $mlwQmnAlertManager->newAlert('There has been an error in this action. Please share this with the developer. Error Code: 0016.', 'error'); } } @@ -1798,7 +1646,7 @@ function mlw_options_emails_tab_content() $mlw_new_email_results = $wpdb->query( $wpdb->prepare( "UPDATE ".$wpdb->prefix."mlw_quizzes SET user_email_template='%s', admin_email_template='%s', last_activity='".date("Y-m-d H:i:s")."' WHERE quiz_id=%d", $mlw_qmn_new_email_array, $mlw_qmn_admin_email, $mlw_qmn_email_id ) ); if ($mlw_new_email_results != false) { - $mlw_hasSavedEmail = true; + $mlwQmnAlertManager->newAlert('The email has been updated successfully.', 'success'); //Insert Action Into Audit Trail global $current_user; @@ -1811,8 +1659,7 @@ function mlw_options_emails_tab_content() } else { - $mlw_qmn_isQueryError = true; - $mlw_qmn_error_code = '0017'; + $mlwQmnAlertManager->newAlert('There has been an error in this action. Please share this with the developer. Error Code: 0017.', 'error'); } } @@ -2012,6 +1859,7 @@ function delete_email(id) function mlw_options_results_tab_content() { global $wpdb; + global $mlwQmnAlertManager; $quiz_id = $_GET["quiz_id"]; //Check to add new results page if (isset($_POST["mlw_add_landing_page"]) && $_POST["mlw_add_landing_page"] == "confirmation") @@ -2040,7 +1888,7 @@ function mlw_options_results_tab_content() $mlw_new_landing_results = $wpdb->query( $wpdb->prepare( "UPDATE ".$wpdb->prefix."mlw_quizzes SET message_after=%s, last_activity='".date("Y-m-d H:i:s")."' WHERE quiz_id=%d", $mlw_qmn_landing_array, $mlw_qmn_landing_id ) ); if ($mlw_new_landing_results != false) { - $mlw_hasAddedLanding = true; + $mlwQmnAlertManager->newAlert('The results page has been added successfully.', 'success'); //Insert Action Into Audit Trail global $current_user; @@ -2053,8 +1901,7 @@ function mlw_options_results_tab_content() } else { - $mlw_qmn_isQueryError = true; - $mlw_qmn_error_code = '0013'; + $mlwQmnAlertManager->newAlert('There has been an error in this action. Please share this with the developer. Error Code: 0013.', 'error'); } } @@ -2081,7 +1928,7 @@ function mlw_options_results_tab_content() $mlw_new_landing_results = $wpdb->query( $wpdb->prepare( "UPDATE ".$wpdb->prefix."mlw_quizzes SET message_after='%s', last_activity='".date("Y-m-d H:i:s")."' WHERE quiz_id=%d", $mlw_qmn_new_landing_array, $mlw_qmn_landing_id ) ); if ($mlw_new_landing_results != false) { - $mlw_hasSavedLanding = true; + $mlwQmnAlertManager->newAlert('The results page has been saved successfully.', 'success'); //Insert Action Into Audit Trail global $current_user; @@ -2094,8 +1941,7 @@ function mlw_options_results_tab_content() } else { - $mlw_qmn_isQueryError = true; - $mlw_qmn_error_code = '0014'; + $mlwQmnAlertManager->newAlert('There has been an error in this action. Please share this with the developer. Error Code: 0014.', 'error'); } } @@ -2245,6 +2091,7 @@ function delete_landing(id) function mlw_options_styling_tab_content() { global $wpdb; + global $mlwQmnAlertManager; $quiz_id = $_GET["quiz_id"]; if (isset($_POST["save_style_options"]) && $_POST["save_style_options"] == "confirmation") { @@ -2257,7 +2104,7 @@ function mlw_options_styling_tab_content() $mlw_save_stle_results = $wpdb->query( $wpdb->prepare( "UPDATE ".$wpdb->prefix."mlw_quizzes SET quiz_stye='%s', theme_selected='%s', last_activity='".date("Y-m-d H:i:s")."' WHERE quiz_id=%d", $mlw_qmn_style, $mlw_qmn_theme, $mlw_qmn_style_id ) ); if ($mlw_save_stle_results != false) { - $mlw_hasSavedStyle = true; + $mlwQmnAlertManager->newAlert('The style has been saved successfully.', 'success'); //Insert Action Into Audit Trail global $current_user; @@ -2270,8 +2117,7 @@ function mlw_options_styling_tab_content() } else { - $mlw_qmn_isQueryError = true; - $mlw_qmn_error_code = '0015'; + $mlwQmnAlertManager->newAlert('There has been an error in this action. Please share this with the developer. Error Code: 0015.', 'error'); } } @@ -2400,6 +2246,7 @@ function mlw_qmn_theme(theme) function mlw_options_tools_tab_content() { global $wpdb; + global $mlwQmnAlertManager; $quiz_id = $_GET["quiz_id"]; //Update Quiz Table if (isset($_POST["mlw_reset_quiz_stats"]) && $_POST["mlw_reset_quiz_stats"] == "confirmation") @@ -2410,7 +2257,7 @@ function mlw_options_tools_tab_content() $mlw_reset_sql_results = $wpdb->query( $mlw_reset_update_sql ); if ($mlw_reset_sql_results != false) { - $mlw_hasResetQuizStats = true; + $mlwQmnAlertManager->newAlert('The stats has been reset successfully.', 'success'); //Insert Action Into Audit Trail global $current_user; @@ -2423,8 +2270,7 @@ function mlw_options_tools_tab_content() } else { - $mlw_qmn_isQueryError = true; - $mlw_qmn_error_code = '0010'; + $mlwQmnAlertManager->newAlert('There has been an error in this action. Please share this with the developer. Error Code: 0010.', 'error'); } } From f69a2bef9b5195cba3d997c579799cc65a6b9f24 Mon Sep 17 00:00:00 2001 From: Frank Corso Date: Wed, 19 Nov 2014 15:35:47 -0500 Subject: [PATCH 10/17] Added Include Code For Alert Class --- mlw_quizmaster2.php | 1 + 1 file changed, 1 insertion(+) diff --git a/mlw_quizmaster2.php b/mlw_quizmaster2.php index 3087bbc0f..f91ab35c8 100644 --- a/mlw_quizmaster2.php +++ b/mlw_quizmaster2.php @@ -22,6 +22,7 @@ ///Files to Include +include("includes/mlw_alerts.php"); include("includes/mlw_quiz.php"); include("includes/mlw_dashboard.php"); include("includes/mlw_quiz_admin.php"); From c8aae2c392716877bc48b157bc94fe0b0803c419 Mon Sep 17 00:00:00 2001 From: Frank Corso Date: Wed, 19 Nov 2014 15:50:44 -0500 Subject: [PATCH 11/17] Use Of ob_start To Use Alerts Had to put the tab contents inside ob_start to capture the newAlerts() to display them above the tabs. --- includes/mlw_quiz_options.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/includes/mlw_quiz_options.php b/includes/mlw_quiz_options.php index 5092fea7f..dcbde2584 100644 --- a/includes/mlw_quiz_options.php +++ b/includes/mlw_quiz_options.php @@ -50,8 +50,8 @@ function mlw_generate_quiz_options()

    Quiz Settings For quiz_name; ?>

    - showAlerts(); + @@ -73,6 +73,10 @@ function mlw_generate_quiz_options()
    showAlerts(); + echo $mlw_output; ?> From e5c79e437870e75f32d8228793699d7684938b5b Mon Sep 17 00:00:00 2001 From: Frank Corso Date: Wed, 19 Nov 2014 15:56:10 -0500 Subject: [PATCH 12/17] Replaced Error System With New Alert Class Replaced the old error system we have been using since the beginning with the new alert class. --- includes/mlw_quiz_admin.php | 79 ++++++------------------------------- 1 file changed, 12 insertions(+), 67 deletions(-) diff --git a/includes/mlw_quiz_admin.php b/includes/mlw_quiz_admin.php index 14a9be87a..5eeb27388 100644 --- a/includes/mlw_quiz_admin.php +++ b/includes/mlw_quiz_admin.php @@ -9,13 +9,8 @@ function mlw_generate_quiz_admin() { global $wpdb; + global $mlwQmnAlertManager; $table_name = $wpdb->prefix . "mlw_quizzes"; - $hasCreatedQuiz = false; - $hasDeletedQuiz = false; - $hasUpdatedQuizName = false; - $hasDuplicatedQuiz = false; - $mlw_qmn_isQueryError = false; - $mlw_qmn_error_code = '0'; //Create new quiz if ( isset( $_POST["create_quiz"] ) && $_POST["create_quiz"] == "confirmation" ) @@ -77,7 +72,7 @@ function mlw_generate_quiz_admin() $results = $wpdb->query( $insert ); if ($results != false) { - $hasCreatedQuiz = true; + $mlwQmnAlertManager->newAlert('Your new quiz has been created successfully. To begin editing your quiz, click the Edit link on the new quiz.', 'success'); //Insert Action Into Audit Trail global $current_user; get_currentuserinfo(); @@ -89,8 +84,7 @@ function mlw_generate_quiz_admin() } else { - $mlw_qmn_error_code = '0001'; - $mlw_qmn_isQueryError = true; + $mlwQmnAlertManager->newAlert('There has been an error in this action. Please share this with the developer. Error Code: 0001.', 'error'); } } @@ -109,7 +103,7 @@ function mlw_generate_quiz_admin() $delete_question_results = $wpdb->query( $update ); if ($results != false) { - $hasDeletedQuiz = true; + $mlwQmnAlertManager->newAlert('Your quiz has been deleted successfully.', 'success'); //Insert Action Into Audit Trail global $current_user; @@ -122,8 +116,7 @@ function mlw_generate_quiz_admin() } else { - $mlw_qmn_error_code = '0002'; - $mlw_qmn_isQueryError = true; + $mlwQmnAlertManager->newAlert('There has been an error in this action. Please share this with the developer. Error Code: 0002.', 'error'); } } @@ -137,7 +130,7 @@ function mlw_generate_quiz_admin() $results = $wpdb->query( $mlw_update_quiz_table ); if ($results != false) { - $hasUpdatedQuizName = true; + $mlwQmnAlertManager->newAlert('Your quiz name has been updated successfully.', 'success'); //Insert Action Into Audit Trail global $current_user; @@ -150,8 +143,7 @@ function mlw_generate_quiz_admin() } else { - $mlw_qmn_error_code = '0003'; - $mlw_qmn_isQueryError = true; + $mlwQmnAlertManager->newAlert('There has been an error in this action. Please share this with the developer. Error Code: 0003.', 'error'); } } @@ -265,6 +257,7 @@ function mlw_generate_quiz_admin() //$results = $wpdb->query( "INSERT INTO ".$table_name." (quiz_id, quiz_name, message_before, message_after, message_comment, message_end_template, user_email_template, admin_email_template, submit_button_text, name_field_text, business_field_text, email_field_text, phone_field_text, comment_field_text, email_from_text, question_answer_template, leaderboard_template, system, randomness_order, loggedin_user_contact, show_score, send_user_email, send_admin_email, contact_info_location, user_name, user_comp, user_email, user_phone, admin_email, comment_section, question_from_total, total_user_tries, total_user_tries_text, certificate_template, social_media, social_media_text, pagination, pagination_text, timer_limit, quiz_stye, question_numbering, quiz_views, quiz_taken, deleted) VALUES (NULL , '".$mlw_duplicate_quiz_name."' , '".$mlw_qmn_duplicate_data->message_before."', '".$mlw_qmn_duplicate_data->message_after."', '".$mlw_qmn_duplicate_data->message_comment."', '".$mlw_qmn_duplicate_data->message_end_template."', '".$mlw_qmn_duplicate_data->user_email_template."', '".$mlw_qmn_duplicate_data->admin_email_template."', '".$mlw_qmn_duplicate_data->submit_button_text."', '".$mlw_qmn_duplicate_data->name_field_text."', '".$mlw_qmn_duplicate_data->business_field_text."', '".$mlw_qmn_duplicate_data->email_field_text."', '".$mlw_qmn_duplicate_data->phone_field_text."', '".$mlw_qmn_duplicate_data->comment_field_text."', '".$mlw_qmn_duplicate_data->email_from_text."', '".$mlw_qmn_duplicate_data->question_answer_template."', '".$mlw_qmn_duplicate_data->leaderboard_template."', ".$mlw_qmn_duplicate_data->system.", ".$mlw_qmn_duplicate_data->randomness_order.", ".$mlw_qmn_duplicate_data->loggedin_user_contact.", ".$mlw_qmn_duplicate_data->show_score.", ".$mlw_qmn_duplicate_data->send_user_email.", ".$mlw_qmn_duplicate_data->send_admin_email.", ".$mlw_qmn_duplicate_data->contact_info_location.", ".$mlw_qmn_duplicate_data->user_name.", ".$mlw_qmn_duplicate_data->user_comp.", ".$mlw_qmn_duplicate_data->user_email.", ".$mlw_qmn_duplicate_data->user_phone.", '".get_option( 'admin_email', 'Enter email' )."', ".$mlw_qmn_duplicate_data->comment_section.", ".$mlw_qmn_duplicate_data->question_from_total.", ".$mlw_qmn_duplicate_data->total_user_tries.", '".$mlw_qmn_duplicate_data->total_user_tries_text."', '".$mlw_qmn_duplicate_data->certificate_template."', ".$mlw_qmn_duplicate_data->social_media.", '".$mlw_qmn_duplicate_data->social_media_text."', ".$mlw_qmn_duplicate_data->pagination.", '".$mlw_qmn_duplicate_data->pagination_text."', ".$mlw_qmn_duplicate_data->timer_limit.", '".$mlw_qmn_duplicate_data->quiz_stye."', ".$mlw_qmn_duplicate_data->question_numbering.", 0, 0, 0)" ); if ($results != false) { + $mlwQmnAlertManager->newAlert('Your quiz has been duplicated successfully.', 'success'); $hasDuplicatedQuiz = true; //Insert Action Into Audit Trail @@ -278,8 +271,7 @@ function mlw_generate_quiz_admin() } else { - $mlw_qmn_error_code = '0011'; - $mlw_qmn_isQueryError = true; + $mlwQmnAlertManager->newAlert('There has been an error in this action. Please share this with the developer. Error Code: 0011.', 'error'); } if (isset($_POST["duplicate_questions"])) { @@ -342,8 +334,7 @@ function mlw_generate_quiz_admin() ); if ($question_results == false) { - $mlw_qmn_error_code = '0011'; - $mlw_qmn_isQueryError = true; + $mlwQmnAlertManager->newAlert('There has been an error in this action. Please share this with the developer. Error Code: 0020.', 'error'); } } } @@ -485,55 +476,9 @@ function duplicateQuiz(id, quizName){

    QuizzesAdd New

    - -
    -

    - Hey! Your new quiz has been created successfully. To begin editing options and adding questions to your quiz, click on the edit link for that quiz.

    -
    - -
    -

    - Hey! The quiz has been duplicated successfully.

    -
    - - -
    -

    - Uh-Oh! There has been an error in this action! Please share this with the developer: Error Code

    -
    - -
    -

    - Hey! The quiz has been deleted.

    -
    - - -
    -

    - Hey! The quiz name has been updated.

    -
    - showAlerts(); + $quotes_list = ""; $display = ""; $alternate = ""; From 5a6d94d9461d19d5e1a209e24db07a83029de8f0 Mon Sep 17 00:00:00 2001 From: Frank Corso Date: Wed, 19 Nov 2014 16:04:45 -0500 Subject: [PATCH 13/17] Replaced Error System With Alert Class Replaced the error system on this page with the new alert class. --- includes/mlw_results.php | 39 +++++++++++++++++++-------------------- 1 file changed, 19 insertions(+), 20 deletions(-) diff --git a/includes/mlw_results.php b/includes/mlw_results.php index 20c154022..d49248351 100644 --- a/includes/mlw_results.php +++ b/includes/mlw_results.php @@ -9,7 +9,7 @@ function mlw_generate_quiz_results() { global $wpdb; - $mlw_hasDeletedResults = false; + global $mlwQmnAlertManager; ///Delete Results Function if (isset($_POST["delete_results"]) && $_POST["delete_results"] == "confirmation") @@ -20,16 +20,23 @@ function mlw_generate_quiz_results() $mlw_delete_results_name = $_POST["delete_quiz_name"]; $mlw_delete_results_update_sql = "UPDATE " . $wpdb->prefix . "mlw_results" . " SET deleted=1 WHERE result_id=".$mlw_delete_results_id; $mlw_delete_results_results = $wpdb->query( $mlw_delete_results_update_sql ); - $mlw_hasDeletedResults = true; + if ($mlw_delete_results_results != false) + { + $mlwQmnAlertManager->newAlert('Your results has been deleted successfully.', 'success'); - //Insert Action Into Audit Trail - global $current_user; - get_currentuserinfo(); - $table_name = $wpdb->prefix . "mlw_qm_audit_trail"; - $insert = "INSERT INTO " . $table_name . - "(trail_id, action_user, action, time) " . - "VALUES (NULL , '" . $current_user->display_name . "' , 'Results Has Been Deleted From: ".$mlw_delete_results_name."' , '" . date("h:i:s A m/d/Y") . "')"; - $results = $wpdb->query( $insert ); + //Insert Action Into Audit Trail + global $current_user; + get_currentuserinfo(); + $table_name = $wpdb->prefix . "mlw_qm_audit_trail"; + $insert = "INSERT INTO " . $table_name . + "(trail_id, action_user, action, time) " . + "VALUES (NULL , '" . $current_user->display_name . "' , 'Results Has Been Deleted From: ".$mlw_delete_results_name."' , '" . date("h:i:s A m/d/Y") . "')"; + $results = $wpdb->query( $insert ); + } + else + { + $mlwQmnAlertManager->newAlert('There has been an error in this action. Please share this with the developer. Error Code: 0021.', 'error'); + } } global $wpdb; @@ -131,17 +138,9 @@ function deleteResults(id,quizName){

    Quiz Results(?)

    - -
    -

    - Success! Your results have been deleted.

    -
    - showAlerts(); + $quotes_list = ""; $display = ""; $alternate = ""; From 805a0ca4c7813ef9050cbbc9eb07280bd00e23cc Mon Sep 17 00:00:00 2001 From: Frank Corso Date: Wed, 19 Nov 2014 16:25:25 -0500 Subject: [PATCH 14/17] Updated Readme To Prepare For Release --- readme.txt | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/readme.txt b/readme.txt index d8360b244..dddaaa9ce 100644 --- a/readme.txt +++ b/readme.txt @@ -4,7 +4,7 @@ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_i Tags: quiz, test, score, exam, survey, contact, form, email, answer, question Requires at least: 3.8.1 Tested up to: 4.0 -Stable tag: 3.3.3 +Stable tag: 3.4.1 License URI: http://www.gnu.org/licenses/gpl-2.0.html The easiest and most flexible way to add multiple quizzes, tests, and surveys to your website. @@ -52,6 +52,9 @@ The plugin will **save** the results, the user's answers, the user's comments, a * Able to set up time limits on the quiz * And **Much** More... += Make Suggestions Or Contribute = +Quiz Master Next is now on [GitHub](https://github.com/fpcorso/quiz_master_next/)! + = Quiz Master Next Add-ons = While Quiz Master Next is fully functional and is packed full of features that will meet the needs of most, we do offer vaious extra features and support available in our [Wordpress Store](http://mylocalwebstop.com/shop/) @@ -76,9 +79,6 @@ We now offer an installation service to assist you in this process. We will inst == Frequently Asked Questions == -= What does the option do on that page? = -On each page, there is a "?" next to the page title. Clicking on it will bring up a small help window that will assist you on that page. - = How do you use that feature? = We have begun creating documentation for the plugin. You can view the documentation here: [Documentation](http://mylocalwebstop.com/plugin-documentation/) If you still have any trouble, feel free to use the widget on the quiz dashboard within the plugin to contact me and I will help you. @@ -104,6 +104,16 @@ Feel free to use the widget on the quiz dashboard within the plugin or from the == Changelog == += 3.4.1 (November 20, 2014) = + * Added Preview Mode (Beta) + * Several Design Changes To Quizzes Page + * Minor Design Changes To Quiz Settings Page + * Added Completion Time To Quiz Results Page + * Added Time Taken To Quiz Result Details Page + * Created New Hook On Quiz Settings Page + * Broke Apart Quiz Settings Backend Into Smaller Functions That Hook Into New Hook + * Created New Backend Alert Manager Class To Replace Archaic Old Error System + = 3.3.3 (November 14, 2014) = * Minor Backend Change To Quiz Validation * Disabled Enter Key On Quiz @@ -524,6 +534,9 @@ Feel free to use the widget on the quiz dashboard within the plugin or from the == Upgrade Notice == += 3.4.1 = +Upgrade for new preview mode, many design changes, and more! + = 3.3.3 = Upgrade for minor bug fixes. @@ -714,4 +727,4 @@ Upgrade to enjoy the new Not Graded scoring system and some error fixes! Upgrade to enjoy three new features and some minor fixes! = 0.1 = -Initial Version \ No newline at end of file +Initial Version From cef5f52a2e9c0010791d8f29b69551b6c729fb37 Mon Sep 17 00:00:00 2001 From: Frank Corso Date: Wed, 19 Nov 2014 16:26:02 -0500 Subject: [PATCH 15/17] Updated mlw_update.php To Prepare For Release --- includes/mlw_update.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/includes/mlw_update.php b/includes/mlw_update.php index a05179d9b..3805312c1 100644 --- a/includes/mlw_update.php +++ b/includes/mlw_update.php @@ -6,7 +6,7 @@ function mlw_quiz_update() { //Update this variable each update. This is what is checked when the plugin is deciding to run the upgrade script or not. - $data = "3.3.2"; + $data = "3.4.1"; if ( ! get_option('mlw_quiz_master_version')) { add_option('mlw_quiz_master_version' , $data); @@ -340,4 +340,4 @@ function mlw_quiz_update() add_option('mlw_advert_shows' , 'true'); } } -?> \ No newline at end of file +?> From dbc68aa305bcb03822c76a1c5784fb1f641d192a Mon Sep 17 00:00:00 2001 From: Frank Corso Date: Wed, 19 Nov 2014 16:33:43 -0500 Subject: [PATCH 16/17] Updated mlw_qmn_credits.php To Prepare For Release --- includes/mlw_qmn_credits.php | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/includes/mlw_qmn_credits.php b/includes/mlw_qmn_credits.php index 01d716873..5a0343087 100644 --- a/includes/mlw_qmn_credits.php +++ b/includes/mlw_qmn_credits.php @@ -89,28 +89,36 @@ function mlw_qmn_setTab(tab) {
    Version
    -

    Duplicate Questions With Quizzes

    -

    You can now duplicate your questions with your quizzes when duplicating!

    +

    Preview Mode

    +

    You can now preview your quiz while in the admin side by going to the new Preview tab on the Quiz Settings page!


    -

    New Question Type

    -

    You can now use the new Horizontal Multiple Response type to have your multiple reponse check boxes go horizontally instead of vertically.

    +

    Design Changes

    +

    This version made several design changes to various pages as we continue to redesign our plugin. We also made many design changes in our code!

    +
    +

    We Are On GitHub Now

    +

    We have had several users ask for this so we thought we would try it out. We now love github! Be sure to make suggestions or contribute.


    Our Premium Add-Ons!

    We have several new premium add-ons in our WordPress Store: MailPoet Integration (subscribes users to your MailPoet list), MailChimp Integration (subscribes users to your Mailchimp list), Export Results (exports your quiz results), Extra Shortcodes (gives you extra shortcodes to use), User Dashboard (allow users to see the results from all the quizzes they have taken), and Advertisement Be Gone (gets rid of blue-border ads). Visit our WordPress Store for details!

    \ No newline at end of file +?> From a8254696249e01feba34992d3ec12a7c41305ddd Mon Sep 17 00:00:00 2001 From: Frank Corso Date: Wed, 19 Nov 2014 16:34:46 -0500 Subject: [PATCH 17/17] Updated Main File To Prepare For Release --- mlw_quizmaster2.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mlw_quizmaster2.php b/mlw_quizmaster2.php index f91ab35c8..143bb2454 100644 --- a/mlw_quizmaster2.php +++ b/mlw_quizmaster2.php @@ -3,7 +3,7 @@ /* Plugin Name: Quiz Master Next Description: Use this plugin to add multiple quizzes, tests, or surveys to your website. -Version: 3.3.3 +Version: 3.4.1 Author: Frank Corso Author URI: http://www.mylocalwebstop.com/ Plugin URI: http://www.mylocalwebstop.com/ @@ -191,4 +191,4 @@ function mlw_qmn_show_adverts() */ -?> \ No newline at end of file +?>