From 900ecb74f66003038b5fbeb710367fa1daa3df5c Mon Sep 17 00:00:00 2001 From: Vibina Date: Thu, 14 Sep 2023 12:34:16 +0530 Subject: [PATCH 01/13] unattempted template variable is created --- php/admin/functions.php | 1 + php/template-variables.php | 17 ++++++++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/php/admin/functions.php b/php/admin/functions.php index 18d95720a..097b444f0 100644 --- a/php/admin/functions.php +++ b/php/admin/functions.php @@ -854,6 +854,7 @@ function qsm_text_template_variable_list() { '%AMOUNT_CORRECT%' => __( 'The number of correct answers the user had', 'quiz-master-next' ), '%AMOUNT_INCORRECT%' => __( 'The number of incorrect answers the user had', 'quiz-master-next' ), '%AMOUNT_ATTEMPTED%' => __( 'The number of questions are attempted', 'quiz-master-next' ), + '%AMOUNT_UNATTEMPTED%' => __( 'The number of questions are not attempted', 'quiz-master-next' ), '%TOTAL_QUESTIONS%' => __( 'The total number of questions in the quiz', 'quiz-master-next' ), '%CORRECT_SCORE%' => __( 'Score for the quiz when using correct answers', 'quiz-master-next' ), '%USER_NAME%' => __( 'The name the user entered before the quiz', 'quiz-master-next' ), diff --git a/php/template-variables.php b/php/template-variables.php index 429eb6981..2ae334423 100644 --- a/php/template-variables.php +++ b/php/template-variables.php @@ -187,7 +187,22 @@ function qsm_variable_total_attempted_questions( $content, $mlw_quiz_array ) { $content = str_replace( '%AMOUNT_ATTEMPTED%', $total_attempted_questions, $content ); return $content; } - +/** + * Function to get the count of not answered questions or not attempted questions + * + * @since 8.1.16 + * + * @param string $content + * @param array $mlw_quiz_array + * @return string $content + */ +function qsm_variable_total_unattempted_questions( $content, $mlw_quiz_array ) { + $total_attempted_questions = isset( $mlw_quiz_array['total_attempted_questions'] ) ? $mlw_quiz_array['total_attempted_questions'] : 0; + $total_questions = isset( $mlw_quiz_array['total_questions'] ) ? $mlw_quiz_array['total_questions'] : 0; + $total_unattempted_questions = $total_questions - $total_attempted_questions; + $content = str_replace( '%AMOUNT_UNATTEMPTED%', $total_unattempted_questions, $content ); + return $content; +} /** * Show poll result * From e4673ad9d8472532574b22468f4027fd84b0f886 Mon Sep 17 00:00:00 2001 From: Vibina Date: Thu, 14 Sep 2023 12:49:49 +0530 Subject: [PATCH 02/13] added the hook --- php/template-variables.php | 1 + 1 file changed, 1 insertion(+) diff --git a/php/template-variables.php b/php/template-variables.php index 2ae334423..38cb6ccde 100644 --- a/php/template-variables.php +++ b/php/template-variables.php @@ -49,6 +49,7 @@ add_filter( 'mlw_qmn_template_variable_results_page', 'qsm_variable_single_answer', 20, 2 ); add_filter( 'mlw_qmn_template_variable_results_page', 'qsm_variable_total_possible_points', 10, 2 ); add_filter( 'mlw_qmn_template_variable_results_page', 'qsm_variable_total_attempted_questions', 10, 2 ); +add_filter( 'mlw_qmn_template_variable_results_page', 'qsm_variable_total_unattempted_questions', 10, 2 ); add_filter( 'mlw_qmn_template_variable_results_page', 'mlw_qmn_variable_user_full_name', 10, 2 ); add_filter( 'mlw_qmn_template_variable_results_page', 'qsm_variable_poll_result', 10, 3 ); add_filter( 'qmn_end_results', 'qsm_variable_poll_result', 10, 3 ); From b865be2c1a6a1f0092bf2868f363babcc9bdefc3 Mon Sep 17 00:00:00 2001 From: zubairraeen Date: Thu, 14 Sep 2023 17:16:09 +0530 Subject: [PATCH 03/13] added classes for image type questions --- js/qsm-admin.js | 6 ++++-- .../qsm-question-type-multiple-choice-horizontal.php | 2 +- php/question-types/qsm-question-type-multiple-choice.php | 2 +- .../qsm-question-type-multiple-response-horizontal.php | 2 +- php/question-types/qsm-question-type-multiple-response.php | 2 +- php/question-types/qsm-question-type-polar.php | 2 +- 6 files changed, 9 insertions(+), 7 deletions(-) diff --git a/js/qsm-admin.js b/js/qsm-admin.js index 8a46d48e8..57dc5209c 100644 --- a/js/qsm-admin.js +++ b/js/qsm-admin.js @@ -2246,7 +2246,8 @@ var import_button; question_id: answer['question_id'], answerType: answer['answerType'], form_type: qsmQuestionSettings.form_type, - quiz_system: qsmQuestionSettings.quiz_system + quiz_system: qsmQuestionSettings.quiz_system, + question_type: questionType, }; if (answer['answerType'] == 'image') { ansTemp = { @@ -2258,7 +2259,8 @@ var import_button; question_id: answer['question_id'], answerType: answer['answerType'], form_type: qsmQuestionSettings.form_type, - quiz_system: qsmQuestionSettings.quiz_system + quiz_system: qsmQuestionSettings.quiz_system, + question_type: questionType }; } jQuery(document).trigger('qsm_new_answer_template', [ansTemp, answer, questionType]); diff --git a/php/question-types/qsm-question-type-multiple-choice-horizontal.php b/php/question-types/qsm-question-type-multiple-choice-horizontal.php index 5b625aefd..af6f9769a 100644 --- a/php/question-types/qsm-question-type-multiple-choice-horizontal.php +++ b/php/question-types/qsm-question-type-multiple-choice-horizontal.php @@ -61,7 +61,7 @@ function qmn_horizontal_multiple_choice_display( $id, $question, $answers ) { $size_style .= ' height:'.$image_height.'px !important;'; } ?> - <?php echo esc_attr( $new_question_title ); ?> + <?php echo esc_attr( $new_question_title ); ?> - <?php echo esc_attr( $new_question_title ); ?> + <?php echo esc_attr( $new_question_title ); ?> - <?php echo esc_attr( $new_question_title ); ?> + <?php echo esc_attr( $new_question_title ); ?> - <?php echo esc_attr( $new_question_title ); ?> + <?php echo esc_attr( $new_question_title ); ?> - <?php echo esc_attr( $new_question_title ); ?> + <?php echo esc_attr( $new_question_title ); ?> Date: Fri, 15 Sep 2023 17:16:01 +0530 Subject: [PATCH 04/13] file upload code missing --- css/common.css | 15 +++++++--- js/qsm-quiz.js | 1 + php/classes/class-qmn-quiz-manager.php | 30 +++++++++++++++++-- .../qsm-question-type-file-upload.php | 4 +-- 4 files changed, 41 insertions(+), 9 deletions(-) diff --git a/css/common.css b/css/common.css index 22b6680c7..0cbe075d3 100644 --- a/css/common.css +++ b/css/common.css @@ -294,12 +294,19 @@ footer.qsm-popup__footer button.qsm-popup-secondary-button:hover { color: red; display: block; } - +.quiz_section .mlw-file-upload-error-msg.mlw-file-upload-success-msg { + color: green; + display: block; +} .quiz_section .remove-uploaded-file { color: red; - border: 1px solid red; - width: 31px; - padding: 5px 5px 0px 5px; + display: inline-block; + cursor: pointer; + margin-top: 5px; +} +.quiz_section .loading-uploaded-file { + width: 20px; + margin-bottom: -5px; } /** diff --git a/js/qsm-quiz.js b/js/qsm-quiz.js index 2781a93c7..c916ee201 100644 --- a/js/qsm-quiz.js +++ b/js/qsm-quiz.js @@ -1693,6 +1693,7 @@ jQuery(function () { $this.parent('.quiz_section').find('.mlw_file_upload_hidden_path').val(obj.file_path); $this.parent('.quiz_section').find('.mlw_file_upload_media_id').val(obj.media_id); $this.parent('.quiz_section').find('.mlw-file-upload-error-msg').hide(); + $this.parent('.quiz_section').find('.mlw-file-upload-error-msg').addClass('mlw-file-upload-success-msg').text(obj.message); $this.parent('.quiz_section').find('.mlw-file-upload-error-msg').show(); } else { $this.parent('.quiz_section').find('.mlw-file-upload-error-msg').removeClass('mlw-file-upload-success-msg'); diff --git a/php/classes/class-qmn-quiz-manager.php b/php/classes/class-qmn-quiz-manager.php index 0a5aa6c11..354ffaef7 100644 --- a/php/classes/class-qmn-quiz-manager.php +++ b/php/classes/class-qmn-quiz-manager.php @@ -180,9 +180,33 @@ public function qsm_upload_image_fd_question() { echo wp_json_encode( $json ); } } else { - $json['type'] = 'error'; - $json['message'] = __( 'Incorrect File Type uploaded. Please upload the allowed file type!', 'quiz-master-next' ); - echo wp_json_encode( $json ); + if ( ! empty ($file_upload_type) ) { + $filestype = explode(',', $file_upload_type); + foreach ( $filestype as $file ) { + if ( strpos($file, '/') !== false ) { + $filetypes = explode('/', $file); + if ( ! empty($filetypes[0]) && 'application' == $filetypes[0] ) { + $filetypes_allowed[] = 'pdf'; + } else { + $filetypes_allowed[] = $filetypes[0]; + } + }else { + $filetypes_allowed[] = $file; + } + } + if ( count($filetypes_allowed) > 1 ) { + $files_allowed = implode(',', $filetypes_allowed); + } else { + $files_allowed = $filetypes_allowed[0]; // Just take the single element + } + $json['type'] = 'error'; + $json['message'] = __('File Upload Unsuccessful! (Please upload ', 'quiz-master-next') . $files_allowed . __(' file type)', 'quiz-master-next'); + echo wp_json_encode( $json ); + } else { + $json['type'] = 'error'; + $json['message'] = __( 'File Upload Unsuccessful! (Please select file type)', 'quiz-master-next' ); + echo wp_json_encode( $json ); + } } exit; } diff --git a/php/question-types/qsm-question-type-file-upload.php b/php/question-types/qsm-question-type-file-upload.php index 3c7fc98ba..6dcd9be0c 100644 --- a/php/question-types/qsm-question-type-file-upload.php +++ b/php/question-types/qsm-question-type-file-upload.php @@ -22,8 +22,8 @@ function qmn_file_upload_display( $id, $question, $answers ) { $new_question_title = $mlwQuizMasterNext->pluginHelper->get_question_setting( $id, 'question_title' ); qsm_question_title_func( $question, '', $new_question_title, $id ); ?>
- - + + From 7b77db8e2d1846a438117830dad12b1ecaba6854 Mon Sep 17 00:00:00 2001 From: zubairraeen Date: Fri, 15 Sep 2023 17:56:50 +0530 Subject: [PATCH 05/13] added random page support with manual pagination --- php/classes/class-qmn-quiz-manager.php | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/php/classes/class-qmn-quiz-manager.php b/php/classes/class-qmn-quiz-manager.php index 0a5aa6c11..538b95da0 100644 --- a/php/classes/class-qmn-quiz-manager.php +++ b/php/classes/class-qmn-quiz-manager.php @@ -914,7 +914,7 @@ public function display_quiz( $options, $quiz_data, $question_amount, $shortcode // If deprecated pagination setting is not used, use new system... $pages = $mlwQuizMasterNext->pluginHelper->get_quiz_setting( 'pages', array() ); - if ( 0 == $options->randomness_order && 0 == $options->question_from_total && 0 == $options->pagination && is_countable($pages) && 0 !== count( $pages ) ) { + if ( 0 == $options->question_from_total && 0 == $options->pagination && is_countable($pages) && 0 !== count( $pages ) ) { $this->display_pages( $options, $quiz_data ); } else { // ... else, use older system. @@ -971,6 +971,23 @@ public function display_pages( $options, $quiz_data ) { $contact_fields = QSM_Contact_Manager::load_fields(); $animation_effect = isset( $options->quiz_animation ) && '' !== $options->quiz_animation ? ' animated ' . $options->quiz_animation : ''; $enable_pagination_quiz = isset( $options->enable_pagination_quiz ) && 1 == $options->enable_pagination_quiz ? true : false; + if ( ( 1 == $options->randomness_order || 2 == $options->randomness_order ) && is_array( $pages ) ) { + shuffle( $pages ); + $question_list_array = array(); + foreach( $pages as &$question_ids ){ + shuffle( $question_ids ); + $question_list_array = array_merge($question_list_array, $question_ids); + } + $question_list_str = implode( ',', $question_list_array ); + ?> + + disable_first_page ) && ( ! empty( $options->message_before ) || ( 0 == $options->contact_info_location && $contact_fields ) ) ) { $qmn_json_data['first_page'] = true; $message_before = $mlwQuizMasterNext->pluginHelper->qsm_language_support( htmlspecialchars_decode( $options->message_before, ENT_QUOTES ), "quiz_message_before-{$options->quiz_id}" ); From 0bc4cdfd32e0b7c1403d9151dd91dd559c1b75a5 Mon Sep 17 00:00:00 2001 From: etchirag Date: Mon, 18 Sep 2023 10:50:16 +0530 Subject: [PATCH 06/13] per page timer with auto pagination --- php/classes/class-qmn-quiz-manager.php | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/php/classes/class-qmn-quiz-manager.php b/php/classes/class-qmn-quiz-manager.php index 354ffaef7..ac6995eca 100644 --- a/php/classes/class-qmn-quiz-manager.php +++ b/php/classes/class-qmn-quiz-manager.php @@ -1292,19 +1292,13 @@ public function display_questions( $qmn_quiz_options, $qmn_quiz_questions, $qmn_ $current_page_number = 1; foreach ( $qmn_quiz_questions as $mlw_question ) { if ( 0 != $pagination_option ) { - if ( 1 == $pagination_option ) { + if ( 1 == $pagination_option || 1 == $pages_count % $pagination_option || 1 == $pages_count) { ?> -