From 40d357957f1923e380168fa8daface54a5a5c96b Mon Sep 17 00:00:00 2001 From: PranavAwasthi Date: Thu, 27 Jun 2024 12:28:18 +0530 Subject: [PATCH] added case sensitive option to text question types --- php/admin/options-page-questions-tab.php | 2 +- php/classes/question-types/class-question-review-text.php | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/php/admin/options-page-questions-tab.php b/php/admin/options-page-questions-tab.php index 9d318afb3..ff2789454 100644 --- a/php/admin/options-page-questions-tab.php +++ b/php/admin/options-page-questions-tab.php @@ -433,7 +433,7 @@ class="save-page-button button button-primary"> __( 'Yes', 'quiz-master-next' ), ), 'default' => '0', - 'show' => '14' . $show_case_sensitive, + 'show' => '3, 5, 14' . $show_case_sensitive, ), 'limit_text' => array( 'heading' => __( 'Limit Text', 'quiz-master-next' ), diff --git a/php/classes/question-types/class-question-review-text.php b/php/classes/question-types/class-question-review-text.php index 79e02cf0a..18a2c9380 100644 --- a/php/classes/question-types/class-question-review-text.php +++ b/php/classes/question-types/class-question-review-text.php @@ -18,8 +18,14 @@ public function set_user_answer() { } public function set_answer_status() { + global $mlwQuizMasterNext; + $case_sensitive = $mlwQuizMasterNext->pluginHelper->get_question_setting( $this->question_id, 'case_sensitive' ); $user_answer_value = $this->user_answer['input']; - $answer_key = array_search( $this->prepare_for_string_matching( $user_answer_value ), array_map( array( $this, 'prepare_for_string_matching' ), $this->correct_answer ), true ); + if ( 1 === intval($case_sensitive ) ) { + $answer_key = array_search( $user_answer_value, $this->correct_answer, true ); + }else { + $answer_key = array_search( $this->prepare_for_string_matching( $user_answer_value ), array_map( array( $this, 'prepare_for_string_matching' ), $this->correct_answer ), true ); + } if ( false !== $answer_key ) { $this->answer_status = 'correct'; $this->points += $this->answer_array[ $answer_key ][1];