diff --git a/includes/mlw_alerts.php b/includes/mlw_alerts.php new file mode 100644 index 000000000..e2b5f3ece --- /dev/null +++ b/includes/mlw_alerts.php @@ -0,0 +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(); +?> 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 +?> diff --git a/includes/mlw_quiz_admin.php b/includes/mlw_quiz_admin.php index 46417c78c..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'); } } } @@ -386,30 +377,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,59 +459,26 @@ function duplicateQuiz(id, quizName){ cursor:hand; } -
-
-

Quizzes(?)

- + .linkOptions { - ?> -
-

- 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.

-
- - + +
+
+

QuizzesAdd New

showAlerts(); + $quotes_list = ""; $display = ""; $alternate = ""; @@ -551,7 +487,8 @@ function duplicateQuiz(id, quizName){ else $alternate = " class=\"alternate\""; $quotes_list .= ""; $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)"; + $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 +544,6 @@ function duplicateQuiz(id, quizName){ $display .= ""; echo $display; ?> - - - @@ -685,17 +619,6 @@ function duplicateQuiz(id, quizName){ ?>
- -
prefix . "mlw_questions"; - $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'; - + 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"])); + } + ?> + + + + + + +
+
+

Quiz Settings For quiz_name; ?>

+ +
+
    + +
+ + +
+ +
+

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

+ showAlerts(); + echo $mlw_output; + ?> + + +
+
+Questions"; +} +function mlw_options_text_tab() +{ + echo "
  • Text
  • "; +} +function mlw_options_option_tab() +{ + echo "
  • Options
  • "; +} +function mlw_options_leaderboard_tab() +{ + echo "
  • Leaderboard
  • "; +} +function mlw_options_certificate_tab() +{ + echo "
  • Certificate (Beta)
  • "; +} +function mlw_options_emails_tab() +{ + echo "
  • Emails
  • "; +} +function mlw_options_results_tab() +{ + echo "
  • Results Page
  • "; +} +function mlw_options_styling_tab() +{ + echo "
  • Styling
  • "; +} +function mlw_options_tools_tab() +{ + echo "
  • Tools/Add-Ons
  • "; +} +function mlw_options_preview_tab() +{ + echo "
  • Preview (Beta)
  • "; +} +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'); +add_action('mlw_qmn_options_tab_content', 'mlw_options_preview_tab_content'); + +function mlw_options_questions_tab_content() +{ + global $wpdb; + global $mlwQmnAlertManager; + $quiz_id = $_GET["quiz_id"]; + //Edit question if ( isset($_POST["edit_question"]) && $_POST["edit_question"] == "confirmation") { @@ -83,7 +202,7 @@ function mlw_generate_quiz_options() $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; @@ -96,8 +215,7 @@ function mlw_generate_quiz_options() } 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'); } } @@ -112,7 +230,7 @@ function mlw_generate_quiz_options() $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; @@ -125,8 +243,7 @@ function mlw_generate_quiz_options() } 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'); } } @@ -195,7 +312,7 @@ function mlw_generate_quiz_options() if ($results != false) { - $hasDuplicatedQuestion = true; + $mlwQmnAlertManager->newAlert('The question has been duplicated successfully.', 'success'); //Insert Action Into Audit Trail global $current_user; @@ -208,8 +325,7 @@ function mlw_generate_quiz_options() } 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'); } } @@ -252,7 +368,7 @@ function mlw_generate_quiz_options() $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; @@ -265,1192 +381,238 @@ function mlw_generate_quiz_options() } 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'); } } - - //Get table of questions for this quiz - if ($quiz_id != "") + + if (isset($_GET["quiz_id"])) { - 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 ) ); - - 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 - { - $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 ) ); - $is_new_quiz = $wpdb->num_rows; + $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"])); } - /* - 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'; - } - } + $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 ) ); - - /* - Code for Quiz Options tab - */ - - //Submit saved options into database - if ( isset($_POST["save_options"]) && $_POST["save_options"] == "confirmation") + if( isset($_GET{'mlw_question_page'} ) ) { - //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'; - } + $mlw_qmn_question_page = $_GET{'mlw_question_page'} + 1; + $mlw_qmn_question_begin = $mlw_qmn_table_limit * $mlw_qmn_question_page ; } - - /* - Code For Leaderboard Options tab - */ - - ///Submit saved leaderboard template into database - if ( isset($_POST["save_leaderboard_options"]) && $_POST["save_leaderboard_options"] == "confirmation") + else { - ///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'; - } + $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); - /* - 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 ) ); - + $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 ($mlw_certificate_sql_results != false) + //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_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 ); + $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_isQueryError = true; - $mlw_qmn_error_code = '0012'; + $mlw_qmn_answer_arrays[$mlw_question_info->question_id] = $mlw_qmn_answer_array_each; } } - - /* - 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 .= "" . $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]; - ?> - - - + + + +
    + 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; + global $mlwQmnAlertManager; + $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) + { + $mlwQmnAlertManager->newAlert('The templates has been updated 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 . "' , 'Templates Have Been Edited For Quiz Number ".$quiz_id."' , '" . 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: 0007.', 'error'); + } + } + + 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 +1147,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) + { + $mlwQmnAlertManager->newAlert('The options has been updated 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 . "' , 'Options Have Been Edited For Quiz Number ".$quiz_id."' , '" . 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: 0008.', 'error'); + } + } + + 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,7 +1348,48 @@ 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) + { + $mlwQmnAlertManager->newAlert('The leaderboards has been updated 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 . "' , '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 + { + $mlwQmnAlertManager->newAlert('There has been an error in this action. Please share this with the developer. Error Code: 0009.', 'error'); + } + } + + 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 +1421,7 @@ function mlw_qmn_theme(theme)
    %QUIZ_NAME% - The name of the quiz
    - + "; echo ""; @@ -1941,7 +1452,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) + { + $mlwQmnAlertManager->newAlert('The certificate has been updated 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 . "' , 'Certificate Options Have Been Edited For Quiz Number ".$mlw_certificate_id."' , '" . 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: 0012.', 'error'); + } + } + 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,7 +1574,129 @@ 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) + { + $mlwQmnAlertManager->newAlert('The email has been added 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 . "' , '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 + { + $mlwQmnAlertManager->newAlert('There has been an error in this action. Please share this with the developer. Error Code: 0016.', 'error'); + } + } + + //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) + { + $mlwQmnAlertManager->newAlert('The email has been updated 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 . "' , '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 + { + $mlwQmnAlertManager->newAlert('There has been an error in this action. Please share this with the developer. Error Code: 0017.', 'error'); + } + } + + 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 +1738,6 @@ function mlw_qmn_theme(theme) -

    Email Sent To User

    @@ -2166,7 +1857,119 @@ 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) + { + $mlwQmnAlertManager->newAlert('The results page has been added 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 . "' , '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 + { + $mlwQmnAlertManager->newAlert('There has been an error in this action. Please share this with the developer. Error Code: 0013.', 'error'); + } + } + + //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) + { + $mlwQmnAlertManager->newAlert('The results page has been saved 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 . "' , '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 + { + $mlwQmnAlertManager->newAlert('There has been an error in this action. Please share this with the developer. Error Code: 0014.', 'error'); + } + } + + 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 +2012,6 @@ function mlw_qmn_theme(theme)
    -
    @@ -2287,7 +2089,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) + { + $mlwQmnAlertManager->newAlert('The style has been saved 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 . "' , 'Styles Have Been Saved For Quiz Number ".$mlw_qmn_style_id."' , '" . 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: 0015.', 'error'); + } + } + + 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,7 +2244,67 @@ 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) + { + $mlwQmnAlertManager->newAlert('The stats has been reset 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 . "' , '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 + { + $mlwQmnAlertManager->newAlert('There has been an error in this action. Please share this with the developer. Error Code: 0010.', 'error'); + } + } + + 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 +2319,17 @@ 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 diff --git a/includes/mlw_results.php b/includes/mlw_results.php index 625334fe4..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,23 +138,28 @@ function deleteResults(id,quizName){

    Quiz Results(?)

    - -
    -

    - Success! Your results have been deleted.

    -
    - showAlerts(); + $quotes_list = ""; $display = ""; $alternate = ""; 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 +175,7 @@ function deleteResults(id,quizName){ { $quotes_list .= ""; } + $quotes_list .= ""; $quotes_list .= ""; $quotes_list .= ""; $quotes_list .= ""; @@ -198,6 +211,7 @@ function deleteResults(id,quizName){ + diff --git a/includes/mlw_results_details.php b/includes/mlw_results_details.php index 9238aded1..c29091380 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; ?>

    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
    + + + + @@ -181,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):

    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 +?> diff --git a/mlw_quizmaster2.php b/mlw_quizmaster2.php index 3087bbc0f..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/ @@ -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"); @@ -190,4 +191,4 @@ function mlw_qmn_show_adverts() */ -?> \ No newline at end of file +?> 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
    Time Taken: time_taken; ?>
    Name Provided: name; ?>