Skip to content

Commit

Permalink
Merge pull request #2416 from QuizandSurveyMaster/dev-zubair
Browse files Browse the repository at this point in the history
added option to change deselect answer text
  • Loading branch information
zubairraeen authored Dec 13, 2023
2 parents 7ee1fdb + 0a7e3ba commit 774a2b1
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 4 deletions.
1 change: 1 addition & 0 deletions php/classes/class-qmn-plugin-helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -554,6 +554,7 @@ public static function get_default_texts() {
'retake_quiz_button_text' => __('Retake Quiz', 'quiz-master-next'),
'previous_button_text' => __('Previous', 'quiz-master-next'),
'next_button_text' => __('Next', 'quiz-master-next'),
'deselect_answer_text' => __('Deselect Answer', 'quiz-master-next'),
'empty_error_text' => __('Please complete all required fields!', 'quiz-master-next'),
'email_error_text' => __('Not a valid e-mail address!', 'quiz-master-next'),
'number_error_text' => __('This field must be a number!', 'quiz-master-next'),
Expand Down
12 changes: 11 additions & 1 deletion php/classes/class-qsm-install.php
Original file line number Diff line number Diff line change
Expand Up @@ -1146,7 +1146,7 @@ public function register_default_settings() {
);
$mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_text' );

// Registers start_quiz_survey_text setting
// Registers No answer provided setting
$field_array = array(
'id' => 'no_answer_text',
'label' => __( 'No Answer Text', 'quiz-master-next' ),
Expand All @@ -1156,6 +1156,16 @@ public function register_default_settings() {
);
$mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_text' );

// Registers Deselect Answer setting
$field_array = array(
'id' => 'deselect_answer_text',
'label' => __( 'Deselect Answer Text', 'quiz-master-next' ),
'type' => 'text',
'default' => __( 'Deselect Answer', 'quiz-master-next' ),
'option_tab' => 'text-button',
);
$mlwQuizMasterNext->pluginHelper->register_quiz_setting( $field_array, 'quiz_text' );

// Registers empty_error_text setting
$field_array = array(
'id' => 'empty_error_text',
Expand Down
6 changes: 4 additions & 2 deletions php/question-types/qsm-question-title.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ function qsm_question_title_func( $question, $question_type = '', $new_question_
$qmn_quiz_options = $mlwQuizMasterNext->quiz_settings->get_quiz_options();
$deselect_answer = '';
if ( isset( $qmn_quiz_options->enable_deselect_option ) && 1 == $qmn_quiz_options->enable_deselect_option && ( 'multiple_choice' === $question_type || 'horizontal_multiple_choice' === $question_type ) ) {
$deselect_answer = '<a href="javascript:void(0)" class="qsm-deselect-answer">'.__( 'Deselect Answer', 'quiz-master-next' ).'</a>';
$default_texts = QMNPluginHelper::get_default_texts();
$deselect_answer_text = ! empty( $qmn_quiz_options->deselect_answer_text ) ? $qmn_quiz_options->deselect_answer_text : $default_texts['deselect_answer_text'];
$deselect_answer = '<a href="javascript:void(0)" class="qsm-deselect-answer">'. $mlwQuizMasterNext->pluginHelper->qsm_language_support( $deselect_answer_text, "deselect_answer_text-{$qmn_quiz_options->quiz_id}" ) .'</a>';
}
do_action('qsm_question_title_func_before',$question, $question_type, $new_question_title, $question_id );
if ( '' !== $new_question_title ) {
Expand Down Expand Up @@ -50,7 +52,7 @@ function qsm_question_title_func( $question, $question_type = '', $new_question_
$allow_html['input']['class'] = 1;
$allow_html['input']['id'] = 1;
$allow_html['input']['maxlength'] = 1;
$allow_html = apply_filters( 'qsm_allow_html_question_title_after', $question_id, $allow_html );
$allow_html = apply_filters( 'qsm_allow_html_question_title_after', $allow_html, $question_id );
?>
<p><?php echo do_shortcode( wp_kses( $question_title . $deselect_answer, $allow_html ) ); ?></p>
</div>
Expand Down
2 changes: 1 addition & 1 deletion php/question-types/qsm-question-type-dropdown.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ function qmn_drop_down_display( $id, $question, $answers ) {
*/
function qmn_drop_down_review( $id, $question, $answers ) {
$current_question = new QSM_Question_Review_Choice( $id, $question, $answers );
$current_question = apply_filters( 'qmn_drop_down_review_before', $id, $question, $answers, $current_question );
$current_question = apply_filters( 'qmn_drop_down_review_before', $id, $question, $answers, $current_question );
$user_text_array = $current_question->get_user_answer();
$correct_text_array = $current_question->get_correct_answer();
$return_array['user_text'] = ! empty( $user_text_array ) ? implode( ', ', $user_text_array ) : '' ;
Expand Down

0 comments on commit 774a2b1

Please sign in to comment.