From e0a596f5d12bb3e6a0a3a51cfb9e17d39eaba67c Mon Sep 17 00:00:00 2001 From: PranavAwasthi Date: Mon, 5 Feb 2024 18:40:15 +0530 Subject: [PATCH 1/3] Fixed wpml issue with fill in the blank on result page --- .../class-question-review-fill-in-blanks.php | 2 +- .../qsm-question-type-fill-in-the-blanks.php | 3 +++ php/template-variables.php | 16 +++++++++------- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/php/classes/question-types/class-question-review-fill-in-blanks.php b/php/classes/question-types/class-question-review-fill-in-blanks.php index 46fca8a61..f4e2ed640 100644 --- a/php/classes/question-types/class-question-review-fill-in-blanks.php +++ b/php/classes/question-types/class-question-review-fill-in-blanks.php @@ -29,7 +29,7 @@ public function set_user_answer() { public function set_correct_answer() { foreach ( $this->answer_array as $answer_key => $answer_value ) { - $this->correct_answer[ $answer_key ] = $this->sanitize_answer_from_db( $answer_value[0] ); + $this->correct_answer[ $answer_key ] = $mlwQuizMasterNext->pluginHelper->qsm_language_support( $this->sanitize_answer_from_db( $answer_value[0] ), "answer-{$this->question_id}-{$answer_key}", "QSM Answers" ); } } 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 2dc8b68a2..7a4fd1f1b 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 @@ -70,6 +70,9 @@ function qmn_fill_blank_display( $id, $question, $answers ) { */ function qmn_fill_blank_review( $id, $question, $answers ) { global $mlwQuizMasterNext; + if ( ! empty( $question ) ) { + $question = $mlwQuizMasterNext->pluginHelper->qsm_language_support( htmlspecialchars_decode( html_entity_decode( $question, ENT_HTML5 ), ENT_QUOTES ), "question-description-{$id}", "QSM Questions" ); + } $case_sensitive = $mlwQuizMasterNext->pluginHelper->get_question_setting( $id, 'case_sensitive' ); $current_question = new QSM_Question_Review_Fill_In_Blanks( $id, $question, $answers ); $user_text_array = $current_question->get_user_answer(); diff --git a/php/template-variables.php b/php/template-variables.php index b8a4ad320..a6b398ce9 100644 --- a/php/template-variables.php +++ b/php/template-variables.php @@ -1011,7 +1011,9 @@ function qsm_questions_answers_shortcode_to_text( $mlw_quiz_array, $qmn_question $question_settings = isset( $questions[ $answer['id'] ]['settings'] ) ? $questions[ $answer['id'] ]['settings'] : array(); $question_title = $mlwQuizMasterNext->pluginHelper->qsm_language_support( $answer['question_title'], "Question-{$answer['id']}", 'QSM Questions' ); $question_description = ''; - if ( ! empty( $answer[0] ) ) { + if ( 14 == $answer['question_type'] ) { + $question_description = ! empty($answer[0]) ? $answer[0] : ''; + } elseif ( ! empty( $answer[0] ) ) { $question_description = $mlwQuizMasterNext->pluginHelper->qsm_language_support( $answer[0], "question-description-{$answer['id']}", 'QSM Questions' ); } $question_description = ! empty( $question_description ) ? '' . $question_description . '' : $question_description; @@ -1129,10 +1131,10 @@ function qsm_questions_answers_shortcode_to_text( $mlw_quiz_array, $qmn_question $is_answer_correct = 0; if ( isset($answer['case_sensitive']) && 1 === intval( $answer['case_sensitive'] ) ) { $decode_show_user_answer = htmlspecialchars_decode( $show_user_answer, ENT_QUOTES ); - $decode_single_user_answer = htmlspecialchars_decode( $mlwQuizMasterNext->pluginHelper->qsm_language_support( $single_answer[0], 'answer-' . $single_answer[0], 'QSM Answers' ), ENT_QUOTES ); + $decode_single_user_answer = htmlspecialchars_decode( $mlwQuizMasterNext->pluginHelper->qsm_language_support( $single_answer[0], 'answer-' . $answer['id'] . '-' . $key, 'QSM Answers' ), ENT_QUOTES ); } else { $decode_show_user_answer = htmlspecialchars_decode( mb_strtoupper( $show_user_answer ), ENT_QUOTES ); - $decode_single_user_answer = mb_strtoupper( htmlspecialchars_decode( $mlwQuizMasterNext->pluginHelper->qsm_language_support( $single_answer[0], 'answer-' . $single_answer[0], 'QSM Answers' ), ENT_QUOTES ) ); + $decode_single_user_answer = mb_strtoupper( htmlspecialchars_decode( $mlwQuizMasterNext->pluginHelper->qsm_language_support( $single_answer[0], 'answer-' . $answer['id'] . '-' . $key, 'QSM Answers' ), ENT_QUOTES ) ); } if ( $decode_show_user_answer == $decode_single_user_answer ) { @@ -1140,23 +1142,23 @@ function qsm_questions_answers_shortcode_to_text( $mlw_quiz_array, $qmn_question } $index = $key + 1; if ( $is_answer_correct ) { - $question_with_answer_text .= '(' . $index . ') ' . $show_user_answer . ''; + $question_with_answer_text .= '(' . $index . ') ' . $decode_single_user_answer . ''; } else { if ( '' === $show_user_answer ) { $show_user_answer = $quiz_options->no_answer_text; } $question_with_answer_text .= '(' . $index . ') ' . $show_user_answer . ''; - $question_with_answer_text .= '(' . $index . ') ' . strval( $mlwQuizMasterNext->pluginHelper->qsm_language_support( $single_answer[0], 'answer-' . $single_answer[0], 'QSM Answers' ) ) . ''; + $question_with_answer_text .= '(' . $index . ') ' . strval( $mlwQuizMasterNext->pluginHelper->qsm_language_support( $single_answer[0], 'answer-' . $answer['id'] . '-' . $key, 'QSM Answers' ) ) . ''; } } } else { $options = array(); foreach ( $total_answers as $key => $single_answer ) { if ( isset($answer['case_sensitive']) && 1 === intval( $answer['case_sensitive'] ) ) { - $options[] = htmlspecialchars_decode( $mlwQuizMasterNext->pluginHelper->qsm_language_support( $single_answer[0], 'answer-' . $single_answer[0], 'QSM Answers' ), ENT_QUOTES ); + $options[] = htmlspecialchars_decode( $mlwQuizMasterNext->pluginHelper->qsm_language_support( $single_answer[0], 'answer-' . $answer['id'] . '-' . $key, 'QSM Answers' ), ENT_QUOTES ); } else { - $options[] = mb_strtoupper( htmlspecialchars_decode( $mlwQuizMasterNext->pluginHelper->qsm_language_support( $single_answer[0], 'answer-' . $single_answer[0], 'QSM Answers' ), ENT_QUOTES ) ); + $options[] = mb_strtoupper( htmlspecialchars_decode( $mlwQuizMasterNext->pluginHelper->qsm_language_support( $single_answer[0], 'answer-' . $answer['id'] . '-' . $key, 'QSM Answers' ), ENT_QUOTES ) ); } } From bf14104e32ba3ac785ff7a5f3727fd31ea449f2c Mon Sep 17 00:00:00 2001 From: PranavAwasthi Date: Mon, 5 Feb 2024 18:45:56 +0530 Subject: [PATCH 2/3] Fixed wpml issue with fill in the blank on result page --- php/template-variables.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/php/template-variables.php b/php/template-variables.php index a6b398ce9..385a4eadf 100644 --- a/php/template-variables.php +++ b/php/template-variables.php @@ -1142,7 +1142,7 @@ function qsm_questions_answers_shortcode_to_text( $mlw_quiz_array, $qmn_question } $index = $key + 1; if ( $is_answer_correct ) { - $question_with_answer_text .= '(' . $index . ') ' . $decode_single_user_answer . ''; + $question_with_answer_text .= '(' . $index . ') ' . $show_user_answer . ''; } else { if ( '' === $show_user_answer ) { $show_user_answer = $quiz_options->no_answer_text; From 0ed4b88ea563315b7ec1911c56bfb413992a56db Mon Sep 17 00:00:00 2001 From: PranavAwasthi Date: Mon, 5 Feb 2024 18:56:50 +0530 Subject: [PATCH 3/3] Fixed wpml issue with fill in the blank on result page --- .../question-types/class-question-review-fill-in-blanks.php | 1 + 1 file changed, 1 insertion(+) diff --git a/php/classes/question-types/class-question-review-fill-in-blanks.php b/php/classes/question-types/class-question-review-fill-in-blanks.php index f4e2ed640..9fe37f119 100644 --- a/php/classes/question-types/class-question-review-fill-in-blanks.php +++ b/php/classes/question-types/class-question-review-fill-in-blanks.php @@ -28,6 +28,7 @@ public function set_user_answer() { } public function set_correct_answer() { + global $mlwQuizMasterNext; foreach ( $this->answer_array as $answer_key => $answer_value ) { $this->correct_answer[ $answer_key ] = $mlwQuizMasterNext->pluginHelper->qsm_language_support( $this->sanitize_answer_from_db( $answer_value[0] ), "answer-{$this->question_id}-{$answer_key}", "QSM Answers" ); }