diff --git a/js/qsm-quiz.js b/js/qsm-quiz.js index 4c1115472..d9d96d6c3 100644 --- a/js/qsm-quiz.js +++ b/js/qsm-quiz.js @@ -166,6 +166,12 @@ var qsmTimerInterval = []; } var secondsRemaining = qmn_quiz_data[quizID].timerRemaning; var secondsConsumed = qmn_quiz_data[quizID].timerConsumed; + if (localStorage.getItem('mlw_time_quiz' + quizID) != null ) { + secondsRemaining = (parseFloat(qmn_quiz_data[quizID].timer_limit) * 60) - secondsConsumed + 1; + if(secondsRemaining < 0) { + secondsRemaining = 0; + } + } var display = QSM.secondsToTimer(secondsRemaining); var systemTime = new Date().getTime() / 1000; systemTime = Math.round(systemTime); @@ -1484,13 +1490,75 @@ jQuery(function () { }); }); + const videoAttributePatterns = [ + /\ssrc="([^"]+)"/, + /\smp4="([^"]+)"/, + /\sm4v="([^"]+)"/, + /\swebm="([^"]+)"/, + /\sogv="([^"]+)"/, + /\swmv="([^"]+)"/, + /\sflv="([^"]+)"/, + /\swidth="(\d+)"/, + /\sheight="(\d+)"/ + ]; + + function parseAttributes(match, src, width, height) { + let videoAttrs = { src: '', width: '', height: '' }; + + videoAttributePatterns.forEach(pattern => { + const attrMatch = match.match(pattern); + if (attrMatch) { + const value = attrMatch[1] || ''; + if (pattern.toString().includes('width')) { + videoAttrs.width = value; + } else if (pattern.toString().includes('height')) { + videoAttrs.height = value; + } else { + videoAttrs.src = value; + } + } + }); + + return videoAttrs; + } + + function generateVideoTag(src, width, height, content) { + return ``; + } + + function qsm_check_shortcode(message = null) { + const videoContentRegex = /\[video(?:\s(?:src|mp4|m4v|webm|ogv|wmv|flv|width|height)="[^"]*")*\](.*?)\[\/video\]/g; + let videoMatch = message.match(videoContentRegex); + + if (videoMatch) { + let videoHTML = message.replace(videoContentRegex, function(match, content) { + const { src, width, height } = parseAttributes(match); + const videoTag = generateVideoTag(src, width, height, content); + return `
${videoTag}
`; + }); + return videoHTML; + } + + // Check if message contains an image shortcode + let imageRegex = /\[img(?:(?:\ssrc="([^"]+)")|(?:\salt="([^"]+)")|(?:\swidth="(\d+)")|(?:\sheight="(\d+)")){0,4}\s*\]/g; + let imageMatch = message.match(imageRegex); + + if (imageMatch) { + let imageHTML = message.replace(imageRegex, function(match, src, alt, width, height) { + return '' + (alt || '') + ''; + }); + return '
' + imageHTML + '
'; + } + + return message; + } + //inline result status function function qsm_show_inline_result(quizID, question_id, value, $this, answer_type, $i_this, index = null) { jQuery('.qsm-spinner-loader').remove(); addSpinnerLoader($this,$i_this); let data = qsm_question_quick_result_js(question_id, value, answer_type, qmn_quiz_data[quizID].enable_quick_correct_answer_info,quizID); - $this.find('.quick-question-res-p').remove(); - $this.find('.qsm-inline-correct-info').remove(); + $this.find('.quick-question-res-p, .qsm-inline-correct-info').remove(); $this.find('.qmn_radio_answers').children().removeClass('data-correct-answer'); if ( 0 < value.length && data.success == 'correct') { $this.append('
' + qmn_quiz_data[quizID].quick_result_correct_answer_text + '
') diff --git a/php/admin/options-page-questions-tab.php b/php/admin/options-page-questions-tab.php index d1954fa7b..5c7de6350 100644 --- a/php/admin/options-page-questions-tab.php +++ b/php/admin/options-page-questions-tab.php @@ -158,12 +158,13 @@ function qsm_options_questions_tab_content() { $read_only = ""; $disable_class = ""; $background = "#FFFFFF"; + $display_advance = "yes"; if ( ! class_exists ( 'QSM_AdvancedTimer' ) ) { $read_only = 'readonly'; $disable_class = 'qsm-disabled-td'; $background = "#F0F0F0"; } else { - $date_now = date("d-m-Y"); + $date_now = gmdate("d-m-Y"); $settings_data = get_option('qsm_addon_advanced_timer_settings', ''); $license = isset( $settings_data['license_key'] ) ? trim( $settings_data['license_key'] ) : ''; if ( version_compare( $mlwQuizMasterNext->version, '8.1.6', '<' ) && (isset($settings_data['expiry_date']) && "" != $settings_data['expiry_date']) && (isset($settings_data['last_validate']) && "" != $settings_data['last_validate']) && strtotime($date_now) > strtotime($settings_data['expiry_date']) && strtotime($date_now) >= strtotime($settings_data['last_validate']) ) { @@ -180,6 +181,12 @@ function qsm_options_questions_tab_content() { $target_link = sprintf( '
'.__('Error! ', 'quiz-master-next').''.$target_text.'
' ); echo wp_kses_post($target_link); } + $advancetimer = 'qsm-advanced-timer/qsm-advanced-timer.php'; + $plugin_data = get_plugin_data(WP_PLUGIN_DIR . '/'. $advancetimer); + $version_number = $plugin_data['Version']; + if ( version_compare($version_number, '2.0.0', '<') ) { + $display_advance = "no"; + } } ?>
@@ -697,22 +704,23 @@ class="save-page-button button button-primary"> - +
+
- +
- - type="number" step="1" class="small-text" min="0" id="pagetimer" name="pagetimer" value="0" placeholder=""> : step="1" class="small-text" min="0" id="pagetimer_second" name="pagetimer_second" value="0" placeholder=""> + + type="number" step="1" class="small-text" min="0" id="pagetimer" name="pagetimer" value="0" placeholder=""> : step="1" class="small-text" min="0" id="pagetimer_second" name="pagetimer_second" value="0" placeholder="">
name="warning_checkbox" type="checkbox" value="" /> - type="number" step="1" class="small-text" min="0" placeholder="" id="pagetimer_warning" name="pagetimer_warning" value="0"> : - type="number" step="1" class="small-text" min="0" placeholder="" id="pagetimer_warning_second" name="pagetimer_warning_second" value="0"> + type="number" step="1" class="small-text" min="0" placeholder="" id="pagetimer_warning" name="pagetimer_warning" value="0"> : + type="number" step="1" class="small-text" min="0" placeholder="" id="pagetimer_warning_second" name="pagetimer_warning_second" value="0">
@@ -720,11 +728,12 @@ class="save-page-button button button-primary">
information - %s', esc_url( qsm_get_plugin_link( 'downloads/wordpress-quiz-timer-advanced', 'advanced-timer-popup', 'quiz_editor', 'get_addon', 'qsm_plugin_upsell' ) ), __( 'Get this add-on ', 'quiz-master-next' ) ); _e( 'and extend your quiz features.', 'quiz-master-next' ); ?> + %s', esc_url( qsm_get_plugin_link( 'downloads/wordpress-quiz-timer-advanced', 'advanced-timer-popup', 'quiz_editor', 'get_addon', 'qsm_plugin_upsell' ) ), __( 'Get this add-on ', 'quiz-master-next' ) ); esc_html_e( 'and extend your quiz features.', 'quiz-master-next' ); ?>
+ diff --git a/php/admin/settings-page.php b/php/admin/settings-page.php index 884b32cb0..3cd1e4058 100644 --- a/php/admin/settings-page.php +++ b/php/admin/settings-page.php @@ -76,6 +76,7 @@ public function init() { add_settings_field( 'ip-collection', __( 'Disable collecting and storing IP addresses?', 'quiz-master-next' ), array( $this, 'ip_collection_field' ), 'qmn_global_settings', 'qmn-global-section' ); add_settings_field( 'cpt-search', __( 'Disable Quiz Posts From Being Searched?', 'quiz-master-next' ), array( $this, 'cpt_search_field' ), 'qmn_global_settings', 'qmn-global-section' ); add_settings_field( 'cpt-archive', __( 'Quiz Archive Settings', 'quiz-master-next' ), array( $this, 'cpt_archive_field' ), 'qmn_global_settings', 'qmn-global-section' ); + add_settings_field( 'duplicate-quiz-with-theme', __( 'Duplicate Quiz Controls', 'quiz-master-next' ), array( $this, 'qsm_duplicate_quiz_with_theme' ), 'qmn_global_settings', 'qmn-global-section' ); add_settings_field( 'detele-qsm-data', __( 'Delete all the data related to QSM on deletion?', 'quiz-master-next' ), array( $this, 'qsm_delete_data' ), 'qmn_global_settings', 'qmn-global-section' ); add_settings_field( 'background-quiz-email-process', __( 'Process emails in background?', 'quiz-master-next' ), array( $this, 'qsm_background_quiz_email_process' ), 'qmn_global_settings', 'qmn-global-section' ); add_settings_field( 'cpt-slug', __( 'Quiz Url Slug', 'quiz-master-next' ), array( $this, 'cpt_slug_field' ), 'qmn_global_settings', 'qmn-global-section' ); @@ -368,6 +369,25 @@ public function cpt_search_field() { echo ''; } + /** + * Generates Setting Field To Duplicate Quiz with Theme Settings + * + * @since 8.1.19 + * @return void + */ + public function qsm_duplicate_quiz_with_theme() { + $settings = (array) get_option( 'qmn-settings' ); + $duplicate_quiz_with_theme = ! empty( $settings['duplicate_quiz_with_theme'] ) ? esc_attr( $settings['duplicate_quiz_with_theme'] ) : 0; + ?> +
+ +
+ get_var( $wpdb->prepare( "SELECT * FROM $quizzes_table WHERE quiz_id=%d", $quiz_id ) ); - + if ( $qsm_delete_from_db ) { $qsm_delete = $wpdb->delete( $wpdb->prefix . 'mlw_quizzes', @@ -273,7 +273,7 @@ public function delete_quiz( $quiz_id, $quiz_name ) { ); } } - + if ( empty( $is_row_exists ) ) { $qsm_delete = 1; } @@ -493,6 +493,34 @@ public function duplicate_quiz( $quiz_id, $quiz_name, $is_duplicating_questions ); $mlw_new_id = $wpdb->insert_id; + $settings = (array) get_option('qmn-settings'); + $duplicate_quiz_with_theme = ! empty($settings['duplicate_quiz_with_theme']) ? esc_attr($settings['duplicate_quiz_with_theme']) : 0; + + if ( '1' === $duplicate_quiz_with_theme ) { + $theme_table = $wpdb->prefix . 'mlw_quiz_theme_settings'; + $old_quiz_theme_data = $wpdb->get_row($wpdb->prepare("SELECT * FROM $theme_table WHERE quiz_id = %d AND active_theme = 1", $quiz_id)); + + if ( $old_quiz_theme_data ) { + $new_quiz_theme_data = array( + 'theme_id' => $old_quiz_theme_data->theme_id, + 'quiz_id' => $mlw_new_id, + 'quiz_theme_settings' => $old_quiz_theme_data->quiz_theme_settings, + 'active_theme' => 1, + ); + + $format = array( + '%d', + '%d', + '%s', + '%d', + ); + + $wpdb->insert($theme_table, $new_quiz_theme_data, $format); + $mlwQuizMasterNext->alertManager->newAlert(__('There has been an error in this action. Please share this with the developer. Error Code: 0051', 'quiz-master-next'), 'error'); + $mlwQuizMasterNext->log_manager->add('Error 0051', $wpdb->last_error . ' from ' . $wpdb->last_query, 0, 'error'); + } + } + // Update quiz settings $update_quiz_settings = maybe_unserialize( $mlw_qmn_duplicate_data->quiz_settings ); $update_pages = maybe_unserialize( $update_quiz_settings['pages'] ); diff --git a/php/question-types/qsm-question-title.php b/php/question-types/qsm-question-title.php index 81e449002..1210b7af6 100644 --- a/php/question-types/qsm-question-title.php +++ b/php/question-types/qsm-question-title.php @@ -48,6 +48,7 @@ function qsm_question_title_func( $question, $question_type = '', $new_question_ $allow_html['input']['class'] = 1; $allow_html['input']['id'] = 1; $allow_html['input']['maxlength'] = 1; + $allow_html = apply_filters( 'qsm_allow_html_question_title_after', $question_id, $allow_html ); ?>

diff --git a/php/question-types/qsm-question-type-fill-in-the-blanks.php b/php/question-types/qsm-question-type-fill-in-the-blanks.php index 0bb6b0dd8..b246a3e24 100644 --- a/php/question-types/qsm-question-type-fill-in-the-blanks.php +++ b/php/question-types/qsm-question-type-fill-in-the-blanks.php @@ -44,6 +44,7 @@ function qmn_fill_blank_display( $id, $question, $answers ) { $mlw_require_class = ''; } $input_text = '"; + $input_text = apply_filters( 'qsm_fill_in_blanks_input_after', $input_text, $id, $question, $answers, $mlw_require_class ); if ( strpos( $question, '%BLANK%' ) !== false ) { $question = str_replace( '%BLANK%', $input_text, do_shortcode( htmlspecialchars_decode( $question, ENT_QUOTES ) ) ); }