-
Notifications
You must be signed in to change notification settings - Fork 86
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1717 from QuizandSurveyMaster/dev
Release 7.3.9
- Loading branch information
Showing
14 changed files
with
311 additions
and
173 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
121 changes: 121 additions & 0 deletions
121
php/backward-compatibility/qsm-backward-compatibility-template-variables.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
<?php | ||
|
||
function qsm_bckcmp_tempvar_qa_text_qt_multi_choice_correct( $answers_from_db, $answers_from_response, $question_settings ) { | ||
$question_with_answer_text = ''; | ||
$new_array_user_answer = isset($answers_from_response['user_compare_text']) ? explode('=====', $answers_from_response['user_compare_text']) : array(); | ||
foreach ( $answers_from_db as $single_answer ) { | ||
$current_answer_text = trim(stripslashes(htmlspecialchars_decode($single_answer[0], ENT_QUOTES))); | ||
$is_answer_correct = false; | ||
if ( $new_array_user_answer ) { | ||
foreach ( $new_array_user_answer as $new_array_value ) { | ||
$new_array_value = trim(stripslashes(htmlspecialchars_decode($new_array_value, ENT_QUOTES))); | ||
if ( $current_answer_text == $new_array_value ) { | ||
$is_answer_correct = true; | ||
break; | ||
} | ||
} | ||
} | ||
$image_class = ''; | ||
if ( isset($question_settings['answerEditor']) && 'image' == $question_settings['answerEditor'] ) { | ||
$show_user_answer = '<img src="' . htmlspecialchars_decode($single_answer[0], ENT_QUOTES) . '"/>'; | ||
$image_class = 'qmn_image_option'; | ||
} else { | ||
$show_user_answer = htmlspecialchars_decode($single_answer[0], ENT_QUOTES); | ||
$image_class = ''; | ||
} | ||
if ( isset($single_answer[2]) && 1 == $single_answer[2] && $is_answer_correct ) { | ||
$question_with_answer_text .= '<span class="qsm-text-correct-option qsm-text-user-correct-answers_from_response ' . $image_class . '">' . $show_user_answer . '</span>'; | ||
} elseif ( isset($single_answer[2]) && 1 === $single_answer[2] ) { | ||
$question_with_answer_text .= '<span class="qsm-text-correct-option ' . $image_class . '">' . $show_user_answer . '</span>'; | ||
} elseif ( $is_answer_correct && 1 !== $single_answer[2] ) { | ||
$question_with_answer_text .= '<span class="qsm-text-wrong-option ' . $image_class . '">' . $show_user_answer . '</span>'; | ||
} else { | ||
$question_with_answer_text .= '<span class="qsm-text-simple-option ' . $image_class . '">' . $show_user_answer . '</span>'; | ||
} | ||
} | ||
|
||
return $question_with_answer_text; | ||
} | ||
|
||
function qsm_bckcmp_tempvar_qa_text_qt_single_choice_correct( $answers_from_db, $answers_from_response, $question_settings ) { | ||
$question_with_answer_text = ''; | ||
foreach ( $answers_from_db as $single_answer ) { | ||
$single_answer_option = $single_answer[0]; | ||
if ( isset($question_settings['answerEditor']) && 'rich' == $question_settings['answerEditor'] ) { | ||
$single_answer_option = htmlspecialchars_decode($single_answer[0], ENT_QUOTES); | ||
$single_answer_option = htmlentities($single_answer_option); | ||
if ( strpos($single_answer_option, '<') !== false || strpos($single_answer_option, '"') !== false ) { | ||
$single_answer_option = htmlspecialchars($single_answer_option); | ||
} | ||
if ( strpos($answers_from_response[1], '<') !== false || strpos($answers_from_response[1], '"') !== false ) { | ||
$answer_value = htmlentities($answers_from_response[1]); | ||
} else { | ||
$answer_value = htmlspecialchars_decode($answers_from_response[1], ENT_QUOTES); | ||
$answer_value = htmlspecialchars_decode($answer_value, ENT_QUOTES); | ||
$answer_value = htmlentities($answer_value); | ||
$answer_value = htmlspecialchars($answer_value); | ||
} | ||
} else { | ||
$answer_value = htmlspecialchars_decode($answers_from_response[1], ENT_QUOTES); | ||
} | ||
$image_class = ''; | ||
if ( isset($question_settings['answerEditor']) && 'image' == $question_settings['answerEditor'] ) { | ||
$show_user_answer = '<img src="' . htmlspecialchars_decode($single_answer[0], ENT_QUOTES) . '"/>'; | ||
$image_class = 'qmn_image_option'; | ||
} else { | ||
$show_user_answer = htmlspecialchars_decode($single_answer[0], ENT_QUOTES); | ||
$image_class = ''; | ||
} | ||
if ( isset($single_answer[2]) && 1 == $single_answer[2] && $answer_value == $single_answer_option ) { | ||
$question_with_answer_text .= '<span class="qsm-text-correct-option qsm-text-user-correct-answer ' . $image_class . '">' . $show_user_answer . '</span>'; | ||
} elseif ( isset($single_answer[2]) && 1 == $single_answer[2] ) { | ||
$question_with_answer_text .= '<span class="qsm-text-correct-option ' . $image_class . '">' . $show_user_answer . '</span>'; | ||
} elseif ( $answer_value == $single_answer_option && 1 !== $single_answer[2] ) { | ||
$question_with_answer_text .= '<span class="qsm-text-wrong-option ' . $image_class . '">' . $show_user_answer . '</span>'; | ||
} else { | ||
$question_with_answer_text .= '<span class="qsm-text-simple-option ' . $image_class . '">' . $show_user_answer . '</span>'; | ||
} | ||
} | ||
return $question_with_answer_text; | ||
} | ||
|
||
function qsm_bckcmp_tempvar_qa_text_qt_multi_choice_points( $answers_from_db, $answers_from_response, $question_settings ) { | ||
$question_with_answer_text = ''; | ||
$user_selected_answer = htmlspecialchars_decode($answers_from_response[1], ENT_QUOTES); | ||
foreach ( $answers_from_db as $single_answer ) { | ||
$image_class = ''; | ||
if ( isset($question_settings['answerEditor']) && 'image' == $question_settings['answerEditor'] ) { | ||
$show_user_answer = '<img src="' . htmlspecialchars_decode($single_answer[0], ENT_QUOTES) . '"/>'; | ||
$image_class = 'qmn_image_option'; | ||
} else { | ||
$show_user_answer = htmlspecialchars_decode($single_answer[0], ENT_QUOTES); | ||
$image_class = ''; | ||
} | ||
if ( strpos($user_selected_answer, $single_answer[0]) !== false ) { | ||
$question_with_answer_text .= '<span class="qsm-text-correct-option ' . $image_class . '">' . $show_user_answer . '</span>'; | ||
} else { | ||
$question_with_answer_text .= '<span class="qsm-text-simple-option ' . $image_class . '">' . $show_user_answer . '</span>'; | ||
} | ||
} | ||
return $question_with_answer_text; | ||
} | ||
|
||
function qsm_bckcmp_tempvar_qa_text_qt_single_choice_points( $answers_from_db, $answers_from_response, $question_settings ) { | ||
$question_with_answer_text = ''; | ||
foreach ( $answers_from_db as $single_answer ) { | ||
$image_class = ''; | ||
if ( isset($question_settings['answerEditor']) && 'image' == $question_settings['answerEditor'] ) { | ||
$show_user_answer = '<img src="' . htmlspecialchars_decode($single_answer[0], ENT_QUOTES) . '"/>'; | ||
$image_class = 'qmn_image_option'; | ||
} else { | ||
$show_user_answer = htmlspecialchars_decode($single_answer[0], ENT_QUOTES); | ||
$image_class = ''; | ||
} | ||
if ( htmlspecialchars_decode($answers_from_response[1], ENT_QUOTES) == $single_answer[0] ) { | ||
$question_with_answer_text .= '<span class="qsm-text-correct-option ' . $image_class . '">' . $show_user_answer . '</span>'; | ||
} else { | ||
$question_with_answer_text .= '<span class="qsm-text-simple-option ' . $image_class . '">' . $show_user_answer . '</span>'; | ||
} | ||
} | ||
return $question_with_answer_text; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.