Skip to content

Commit

Permalink
Fixed correct answer not showing with random match type in Fill in th…
Browse files Browse the repository at this point in the history
…e blank question
  • Loading branch information
iam-pranav committed Oct 15, 2024
1 parent 19f9c47 commit 382e135
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions php/template-variables.php
Original file line number Diff line number Diff line change
Expand Up @@ -1200,8 +1200,9 @@ function qsm_questions_answers_shortcode_to_text( $mlw_quiz_array, $qmn_question
} else {
$options[] = mb_strtoupper( htmlspecialchars_decode( $mlwQuizMasterNext->pluginHelper->qsm_language_support( $single_answer[0], 'answer-' . $answer['id'] . '-' . $key, 'QSM Answers' ), ENT_QUOTES ) );
}
$question_correct_fill_answer_text .= '<span class="qsm-text-correct-option">(' . $key + 1 . ') ' . strval( $mlwQuizMasterNext->pluginHelper->qsm_language_support( $single_answer[0], 'answer-' . $answer['id'] . '-' . $key, 'QSM Answers' ) ) . '</span>';
}

$is_any_incorrect = false;
if ( sizeof( $new_array_user_answer ) < sizeof( $total_answers ) ) {
foreach ( $new_array_user_answer as $show_user_answer ) {
if ( isset($answer['case_sensitive']) && 1 === intval( $answer['case_sensitive'] ) ) {
Expand All @@ -1212,6 +1213,7 @@ function qsm_questions_answers_shortcode_to_text( $mlw_quiz_array, $qmn_question
if ( false !== $key ) {
$question_with_answer_text .= '<span class="qsm-text-correct-option qsm-text-user-correct-answer">' . htmlspecialchars_decode( $show_user_answer, ENT_QUOTES ) . '</span>';
} else {
$is_any_incorrect = true;
if ( '' === $show_user_answer ) {
$show_user_answer = $quiz_options->no_answer_text;
}
Expand All @@ -1229,14 +1231,15 @@ function qsm_questions_answers_shortcode_to_text( $mlw_quiz_array, $qmn_question
if ( false !== $key ) {
$question_with_answer_text .= '<span class="qsm-text-correct-option qsm-text-user-correct-answer">' . $show_user_answer . '</span>';
} else {

$is_any_incorrect = true;
if ( '' === $show_user_answer ) {
$show_user_answer = $quiz_options->no_answer_text;
}
$question_with_answer_text .= '<span class="qsm-text-wrong-option">' . $show_user_answer . '</span>';
}
}
}
$question_with_answer_text = $is_any_incorrect ? $question_with_answer_text . $question_correct_fill_answer_text : $question_with_answer_text;
}
} else {
if ( 0 == $form_type && ( 0 == $quiz_system || 3 == $quiz_system ) ) {
Expand Down

0 comments on commit 382e135

Please sign in to comment.