Skip to content

Commit

Permalink
Merge pull request #712 from fpcorso/dev
Browse files Browse the repository at this point in the history
6.0.2 Release
  • Loading branch information
Frank Corso authored Jul 18, 2018
2 parents 780e4b3 + 1b951a9 commit 075a8ed
Show file tree
Hide file tree
Showing 11 changed files with 209 additions and 294 deletions.
16 changes: 16 additions & 0 deletions css/qsm-admin.css
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,22 @@ Options Page
font-weight: bold;
}

/********************
Quiz Styles Tab
*********************/

.qsm-styles {
display: flex;
flex-direction: column;
}

@media screen and (min-width:700px) {
.qsm-styles {
flex-direction: row;
flex-wrap: wrap;
}
}



/********************
Expand Down
24 changes: 20 additions & 4 deletions js/qmn_quiz.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,19 @@
*************************/

/**************************
* This object is the newer functions. All global functions under are slowing
* This object contains the newer functions. All global functions under are slowly
* being deprecated and replaced with rewritten newer functions
**************************/
var QSM;
(function ($) {
QSM = {
/**
* Initializes all quizzes or surveys on the page
*/
init: function() {
// Makes sure we have quizzes on this page
if ( typeof qmn_quiz_data != 'undefined' && qmn_quiz_data) {
// Cycle through all quizzes
_.each( qmn_quiz_data, function( quiz ) {
quizID = parseInt( quiz.quiz_id );
QSM.initPagination( quizID );
Expand All @@ -27,18 +32,26 @@ var QSM;
* @param int quizID The ID of the quiz
*/
initTimer: function( quizID ) {

// Gets our form
$quizForm = QSM.getQuizForm( quizID );

// If we are using the newer pagination system...
if ( 0 < $quizForm.children( '.qsm-page' ).length ) {
// If there is a first page...
if ( qmn_quiz_data[quizID].hasOwnProperty('first_page') && qmn_quiz_data[quizID].first_page ) {
// ... attach an event handler to the click event to activate the timer.
jQuery( '#quizForm' + quizID ).closest( '.qmn_quiz_container' ).find( '.mlw_next' ).on( 'click', function(event) {
event.preventDefault();
if ( !qmn_timer_activated && qmnValidatePage( 'quizForm' + quizID ) ) {
qmnActivateTimer( quizID );
}
});
// ...else, activate the timer on page load.
} else {
qmnActivateTimer( quizID );
}
// ...else, we must be using the questions per page option.
} else {
if ( qmn_quiz_data[quizID].hasOwnProperty('pagination') && qmn_quiz_data[quizID].first_page ) {
jQuery( '#quizForm' + quizID ).closest( '.qmn_quiz_container' ).find( '.mlw_next' ).on( 'click', function(event) {
Expand Down Expand Up @@ -182,6 +195,11 @@ var QSM;

// On load code
$(function() {

// Legacy init.
qmnInit();

// Call main initialization.
QSM.init();
});
}(jQuery));
Expand Down Expand Up @@ -643,9 +661,7 @@ function qmnSocialShare( network, mlw_qmn_social_text, mlw_qmn_title, facebook_i
return false;
}

jQuery(function() {
qmnInit();

jQuery(function() {
jQuery( '.qmn_quiz_container' ).tooltip();

jQuery( '.qmn_quiz_container input' ).on( 'keypress', function ( e ) {
Expand Down
6 changes: 3 additions & 3 deletions mlw_quizmaster2.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
/**
* Plugin Name: Quiz And Survey Master
* Description: Easily and quickly add quizzes and surveys to your website.
* Version: 6.0.1
* Version: 6.0.2
* Author: Frank Corso
* Author URI: https://www.quizandsurveymaster.com/
* Plugin URI: https://www.quizandsurveymaster.com/
* Text Domain: quiz-master-next
*
* @author Frank Corso
* @version 6.0.1
* @version 6.0.2
* @package QSM
*/

Expand All @@ -33,7 +33,7 @@ class MLWQuizMasterNext {
* @var string
* @since 4.0.0
*/
public $version = '6.0.1';
public $version = '6.0.2';

/**
* QSM Alert Manager Object
Expand Down
1 change: 1 addition & 0 deletions php/admin/about-page.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ function mlw_generate_about_page() {
</div>
<div class="qsm-tab-content tab-2" style="display: none;">
<h2>Changelog</h2>
<?php QSM_Changelog_Generator::get_changelog_list( 'fpcorso/quiz_master_next', 54 ); ?>
<?php QSM_Changelog_Generator::get_changelog_list( 'fpcorso/quiz_master_next', 53 ); ?>
<?php QSM_Changelog_Generator::get_changelog_list( 'fpcorso/quiz_master_next', 36 ); ?>
</div>
Expand Down
13 changes: 1 addition & 12 deletions php/admin/admin-results-page.php
Original file line number Diff line number Diff line change
Expand Up @@ -188,25 +188,14 @@ function qsm_results_overview_tab_content() {
wp_enqueue_script( 'jquery-ui-core' );
wp_enqueue_script( 'jquery-ui-dialog' );
wp_enqueue_script( 'jquery-ui-button' );
wp_enqueue_script( 'jquery-effects-blind' );
wp_enqueue_script( 'jquery-effects-explode' );
wp_enqueue_script('qmn_admin_js', plugins_url( '../../js/admin.js' , __FILE__ ));
wp_enqueue_script( 'qmn_admin_js', plugins_url( '../../js/admin.js', __FILE__ ) );
wp_enqueue_style( 'qmn_jquery_redmond_theme', '//ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/themes/redmond/jquery-ui.css' );
?>
<script type="text/javascript">
var $j = jQuery.noConflict();
// increase the default animation speed to exaggerate the effect
$j.fx.speeds._default = 1000;

$j(function() {
$j("button, #prev_page, #next_page").button();

});
function deleteResults(id,quizName){
$j("#delete_dialog").dialog({
autoOpen: false,
show: 'blind',
hide: 'explode',
buttons: {
Cancel: function() {
$j(this).dialog('close');
Expand Down
14 changes: 7 additions & 7 deletions php/admin/help-page.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,13 +105,13 @@ function qsm_get_system_info() {

$sys_info .= "<h3>Plugins Information</h3><br />";
$plugin_mu = get_mu_plugins();
if( count( $plugin_mu > 0 ) ) {
$sys_info .= "<h4>Must Use</h4><br />";
foreach( $plugin_mu as $plugin => $plugin_data ) {
$sys_info .= $plugin_data['Name'] . ': ' . $plugin_data['Version'] . "<br />";
}
}
$sys_info .= "<h4>Active</h4><br />";
if ( count( $plugin_mu ) > 0 ) {
$sys_info .= "<h4>Must Use</h4><br />";
foreach ( $plugin_mu as $plugin => $plugin_data ) {
$sys_info .= $plugin_data['Name'] . ': ' . $plugin_data['Version'] . "<br />";
}
}
$sys_info .= "<h4>Active</h4><br />";
$plugins = get_plugins();
$active_plugins = get_option( 'active_plugins', array() );
foreach( $plugins as $plugin_path => $plugin ) {
Expand Down
164 changes: 75 additions & 89 deletions php/admin/options-page-style-tab.php
Original file line number Diff line number Diff line change
@@ -1,52 +1,57 @@
<?php
if ( ! defined( 'ABSPATH' ) ) exit;
/**
* Handles the functions/views for the "Style" tab when editing a quiz or survey
*/

if ( ! defined( 'ABSPATH' ) ) {
exit;
}

/**
* Adds the Style tab to the Quiz Settings page.
*
* @return void
* @since 4.4.0
*/
function qmn_settings_style_tab()
{
* Adds the Style tab to the Quiz Settings page.
*
* @return void
* @since 6.0.2
*/
function qsm_settings_style_tab() {
global $mlwQuizMasterNext;
$mlwQuizMasterNext->pluginHelper->register_quiz_settings_tabs(__("Style", 'quiz-master-next'), 'mlw_options_styling_tab_content');
$mlwQuizMasterNext->pluginHelper->register_quiz_settings_tabs( __( 'Style', 'quiz-master-next' ), 'qsm_options_styling_tab_content' );
}
add_action("plugins_loaded", 'qmn_settings_style_tab', 5);
add_action( 'plugins_loaded', 'qsm_settings_style_tab', 5 );

/**
* Adds the Style tab content to the tab.
*
* @return void
* @since 4.4.0
*/
function mlw_options_styling_tab_content()
{
* Adds the Style tab content to the tab.
*
* @return void
* @since 6.0.2
*/
function qsm_options_styling_tab_content() {
global $wpdb;
global $mlwQuizMasterNext;
$quiz_id = $_GET["quiz_id"];
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 = sanitize_text_field( $_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 ( false != $mlw_save_stle_results ) {
$mlwQuizMasterNext->alertManager->newAlert(__('The style has been saved successfully.', 'quiz-master-next'), 'success');
$mlwQuizMasterNext->audit_manager->new_audit( "Styles Have Been Saved For Quiz Number $mlw_qmn_style_id" );
wp_enqueue_style( 'qsm_admin_style', plugins_url( '../../css/qsm-admin.css', __FILE__ ), array(), $mlwQuizMasterNext->version );

$quiz_id = intval( $_GET['quiz_id'] );
if ( isset( $_POST['save_style_options'] ) && 'confirmation' == $_POST['save_style_options'] ) {

$style_quiz_id = intval( $_POST['style_quiz_id'] );
$quiz_theme = sanitize_text_field( $_POST['save_quiz_theme'] );
$quiz_style = htmlspecialchars( stripslashes( $_POST['quiz_css'] ), ENT_QUOTES );

// Saves the new css.
$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", $quiz_style, $quiz_theme, $style_quiz_id ) );
if ( false !== $results ) {
$mlwQuizMasterNext->alertManager->newAlert( __( 'The style has been saved successfully.', 'quiz-master-next' ), 'success' );
$mlwQuizMasterNext->audit_manager->new_audit( "Styles Have Been Saved For Quiz Number $style_quiz_id" );
} else {
$mlwQuizMasterNext->alertManager->newAlert(sprintf(__('There has been an error in this action. Please share this with the developer. Error Code: %s', 'quiz-master-next'), '0015'), 'error');
$mlwQuizMasterNext->log_manager->add("Error 0015", $wpdb->last_error.' from '.$wpdb->last_query, 0, 'error');
$mlwQuizMasterNext->alertManager->newAlert( __( 'Error occured when trying to save the styles. Please try again.', 'quiz-master-next' ), 'error' );
$mlwQuizMasterNext->log_manager->add( 'Error saving styles', $wpdb->last_error . ' from ' . $wpdb->last_query, 0, '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"]));
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", $quiz_id ) );
}
$registered_templates = $mlwQuizMasterNext->pluginHelper->get_quiz_templates();
?>
Expand All @@ -60,60 +65,41 @@ function mlw_qmn_theme(theme)

}
</script>
<?php
echo "<form action='' method='post' name='quiz_style_form'>";
echo "<input type='hidden' name='save_style_options' value='confirmation' />";
echo "<input type='hidden' name='style_quiz_id' value='".$quiz_id."' />";
echo "<input type='hidden' name='save_quiz_theme' id='save_quiz_theme' value='".$mlw_quiz_options->theme_selected."' />";
?>
<h3><?php _e('Quiz Styles', 'quiz-master-next'); ?></h3>
<p><?php _e('Choose your style:', 'quiz-master-next'); ?></p>
<style>
div.mlw_qmn_themeBlock
{
cursor: pointer;
position: relative;
height: 100px;
width: 100px;
background-color: #eee;
color: blue;
border: #ccc solid 1px;
border-radius: 4px;
padding: 5px 5px 5px 5px;
display: inline-block;
box-sizing: border-box;
margin: auto;
}
div.mlw_qmn_themeBlockActive
{
background-color: yellow;
}
</style>
<?php
foreach($registered_templates as $slug => $template) {
?>
<div onclick="mlw_qmn_theme('<?php echo $slug; ?>');" id="mlw_qmn_theme_block_<?php echo $slug; ?>" class="mlw_qmn_themeBlock <?php if ($mlw_quiz_options->theme_selected == $slug) {echo 'mlw_qmn_themeBlockActive';} ?>"><?php echo $template["name"]; ?></div>
<?php
}
?>
<div onclick="mlw_qmn_theme('default');" id="mlw_qmn_theme_block_default" class="mlw_qmn_themeBlock <?php if ($mlw_quiz_options->theme_selected == 'default') {echo 'mlw_qmn_themeBlockActive';} ?>"><?php _e('Custom', 'quiz-master-next'); ?></div>
<script>
mlw_qmn_theme('<?php echo $mlw_quiz_options->theme_selected; ?>');
</script>
<br /><br />
<button id="save_styles_button" class="button-primary" onclick="javascript: document.quiz_style_form.submit();"><?php _e('Save Quiz Style', 'quiz-master-next'); ?></button>
<hr />
<h3><?php _e('Custom Style CSS', 'quiz-master-next'); ?></h3>
<p><?php _e('For detailed help and guidance along with a list of different classes used in this plugin, please visit the following link:', 'quiz-master-next'); ?>
<a target="_blank" href="http://quizmasternext.com/quiz-master-next-editing-quizs-style/">Style Guide</a></p>
<button id="save_styles_button" class="button-primary" onclick="javascript: document.quiz_style_form.submit();">Save Quiz Style</button>

<table class="form-table">
<tr>
<td><textarea style="width: 100%; height: 700px;" id="quiz_css" name="quiz_css"><?php echo $mlw_quiz_options->quiz_stye; ?></textarea></td>
</tr>
</table>
<button id="save_styles_button" class="button-primary" onclick="javascript: document.quiz_style_form.submit();"><?php _e('Save Quiz Style', 'quiz-master-next'); ?></button>
<form action='' method='post' name='quiz_style_form'>
<input type='hidden' name='save_style_options' value='confirmation' />
<input type='hidden' name='style_quiz_id' value='<?php echo esc_attr( $quiz_id ); ?>' />
<input type='hidden' name='save_quiz_theme' id='save_quiz_theme' value='<?php echo esc_attr( $mlw_quiz_options->theme_selected ); ?>' />
<h3><?php _e( 'Quiz Styles', 'quiz-master-next' ); ?></h3>
<p><?php _e( 'Choose your style:', 'quiz-master-next' ); ?></p>
<style>
div.mlw_qmn_themeBlockActive {
background-color: yellow;
}
</style>
<div class="qsm-styles">
<?php
foreach ( $registered_templates as $slug => $template ) {
?>
<div onclick="mlw_qmn_theme('<?php echo $slug; ?>');" id="mlw_qmn_theme_block_<?php echo $slug; ?>" class="qsm-info-widget <?php if ($mlw_quiz_options->theme_selected == $slug) {echo 'mlw_qmn_themeBlockActive';} ?>"><?php echo $template["name"]; ?></div>
<?php
}
?>
<div onclick="mlw_qmn_theme('default');" id="mlw_qmn_theme_block_default" class="qsm-info-widget <?php if ($mlw_quiz_options->theme_selected == 'default') {echo 'mlw_qmn_themeBlockActive';} ?>"><?php _e('Custom', 'quiz-master-next'); ?></div>
<script>
mlw_qmn_theme('<?php echo $mlw_quiz_options->theme_selected; ?>');
</script>
</div>
<button id="save_styles_button" class="button-primary"><?php _e('Save Quiz Style', 'quiz-master-next'); ?></button>
<hr />
<h3><?php _e('Custom Style CSS', 'quiz-master-next'); ?></h3>
<p><?php _e('For detailed help and guidance along with a list of different classes used in this plugin, please visit the following link:', 'quiz-master-next'); ?>
<a target="_blank" href="http://bit.ly/2JDHwA6">Style Guide</a></p>
<table class="form-table">
<tr>
<td><textarea style="width: 100%; height: 700px;" id="quiz_css" name="quiz_css"><?php echo $mlw_quiz_options->quiz_stye; ?></textarea></td>
</tr>
</table>
<button id="save_styles_button" class="button-primary"><?php _e('Save Quiz Style', 'quiz-master-next'); ?></button>
</form>
</div>
<?php
Expand Down
Loading

0 comments on commit 075a8ed

Please sign in to comment.