Skip to content

Commit

Permalink
Merge pull request #2414 from QuizandSurveyMaster/CU-85ztj975f-advanc…
Browse files Browse the repository at this point in the history
…ed-drop-down-function

Cu 85ztj975f advanced drop down function
  • Loading branch information
zubairraeen authored Dec 13, 2023
2 parents d7f8294 + 9e78b04 commit 8a3f76d
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 4 deletions.
5 changes: 4 additions & 1 deletion js/qsm-admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -2157,7 +2157,7 @@ var import_button;
});
model.set('answers', answers);
model.set('required', required);

jQuery(document).trigger('qsm_save_question_before', [questionID, CurrentElement, model, advanced_option]);
$('.questionElements .advanced-content > .qsm-row:not(.core-option)').each(function () {
if ($(this).find('input[type="text"]').length > 0) {
$($(this).find('input[type="text"]')).each(function () {
Expand Down Expand Up @@ -2488,6 +2488,7 @@ var import_button;
$('#match-answer').val(value);
}
});
jQuery(document).trigger('qsm_all_question_setting_after', [all_setting]);
}
CurrentElement.parents('.question').next('.questionElements').slideDown('slow');
$('#modal-1-content').html(questionElements);
Expand Down Expand Up @@ -2818,6 +2819,7 @@ var import_button;
QSMQuestion.saveQuestion($(this).parents('.questionElements').children('#edit_question_id').val(), $(this));
$('.save-page-button').trigger('click');
$('#modal-1-content').html(model_html);
jQuery(document).trigger('qsm_save_popup_button_after', [questionElements]);
});
$(document).on('click', '#new-answer-button', function (event) {
event.preventDefault();
Expand Down Expand Up @@ -3056,6 +3058,7 @@ var import_button;
if ('image' === answerType) {
$('#image_size_area').show();
}
jQuery(document).trigger('qsm_question_type_change_after', [question_val]);
});


Expand Down
1 change: 1 addition & 0 deletions mlw_quizmaster2.php
Original file line number Diff line number Diff line change
Expand Up @@ -450,6 +450,7 @@ public function qsm_admin_scripts_style( $hook ) {
'add_more' => __("Add", 'quiz-master-next'),
'_X_validation_fails' => __("Please enter an appropriate value for 'X'", 'quiz-master-next'),
);
$qsm_admin_messages = apply_filters( 'qsm_admin_messages_after', $qsm_admin_messages );
wp_localize_script( 'qsm_admin_js', 'qsm_admin_messages', $qsm_admin_messages );

}
Expand Down
2 changes: 1 addition & 1 deletion php/admin/options-page-questions-tab.php
Original file line number Diff line number Diff line change
Expand Up @@ -599,7 +599,7 @@ class="save-page-button button button-primary"><?php esc_html_e( 'Save Questions
'required' => array(
'label' => __( 'Required?', 'quiz-master-next' ),
'type' => 'single_checkbox',
'priority' => '2',
'priority' => '3',
'options' => array(
'0' => __( 'Yes', 'quiz-master-next' ),
),
Expand Down
4 changes: 3 additions & 1 deletion php/question-types/qsm-question-title.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ function qsm_question_title_func( $question, $question_type = '', $new_question_
}
?>
<div class='mlw_qmn_question <?php echo esc_attr( $title_extra_classes ); ?>' >
<?php do_action('qsm_before_question_title',$question, $question_type, $new_question_title, $question_id );
<?php
$question_title = apply_filters( 'qsm_question_title_func_before', $question, $question_type, $new_question_title, $question_id );
do_action('qsm_before_question_title',$question, $question_type, $new_question_title, $question_id );
$allow_html = wp_kses_allowed_html('post');
$allow_html['input']['autocomplete'] = 1;
$allow_html['input']['name'] = 1;
Expand Down
5 changes: 5 additions & 0 deletions php/question-types/qsm-question-type-dropdown.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ function qmn_drop_down_display( $id, $question, $answers ) {
}
$new_question_title = $mlwQuizMasterNext->pluginHelper->get_question_setting( $id, 'question_title' );
qsm_question_title_func( $question, '', $new_question_title, $id );
$show = true;
$show = apply_filters( 'qsm_check_show_answer_drop_down', $id, $question, $answers );
if ( $show ) {
?>
<select class="qsm_select qsm_dropdown <?php echo esc_attr( $require_class ); ?>" name="question<?php echo esc_attr( $id ); ?>">
<option disabled selected value><?php echo esc_html__( 'Please select your answer', 'quiz-master-next' ); ?></option>
Expand All @@ -42,6 +45,7 @@ function qmn_drop_down_display( $id, $question, $answers ) {
?>
</select>
<?php
}
echo apply_filters( 'qmn_drop_down_display_front', '', $id, $question, $answers );
}

Expand All @@ -56,6 +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 );
$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
4 changes: 3 additions & 1 deletion php/template-variables/qsm-tempvar-question-answers.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@ function qsm_tempvar_qa_text_qt_choice( $total_answers, $answers_from_response,
$user_answer_keys = ! empty( $user_answer_array ) ? array_keys( $user_answer_array ) : array();
$is_answer_correct = false;
$is_user_answer = false;
if ( 1 === intval( $single_answer[2] ) ) {
if ( 1 === intval($single_answer[2]) ) {
$is_answer_correct = true;
}
$is_answer_correct = apply_filters( 'qsm_is_answer_correct_choice_before', $single_answer, $user_answer_array, $single_answer_key, $answers_from_response, $grading_system, $question_settings, $form_type );
if ( in_array( $single_answer_key, $user_answer_keys, true ) ) {
$is_user_answer = true;
}
Expand All @@ -34,6 +35,7 @@ function qsm_tempvar_qa_text_qt_choice( $total_answers, $answers_from_response,
$image_class = 'qmn_image_option';
} else {
$show_user_answer = $mlwQuizMasterNext->pluginHelper->qsm_language_support( htmlspecialchars_decode( $single_answer[0], ENT_QUOTES ), 'answer-' . $single_answer[0], 'QSM Answers' );
$show_user_answer = apply_filters( 'qsm_show_user_answer_before', $single_answer, $user_answer_array, $single_answer_key, $answers_from_response, $grading_system, $question_settings, $form_type, $show_user_answer );
$image_class = '';
}
$close_span = '</span>';
Expand Down

0 comments on commit 8a3f76d

Please sign in to comment.