diff --git a/js/qsm-admin.js b/js/qsm-admin.js index ce913e10..2cd08aab 100644 --- a/js/qsm-admin.js +++ b/js/qsm-admin.js @@ -2246,9 +2246,11 @@ var qsm_link_button; $('.import-button, .link-question').removeClass('disable_import'); QSMQuestion.countTotal(); - import_button ? import_button.html('').html(qsm_admin_messages.add_question) : ""; + if(import_button){ + import_button.html(qsm_admin_messages.add_question); + } if(qsm_link_button) { - qsm_link_button.html('').html(qsm_admin_messages.link_question); + qsm_link_button.html(qsm_admin_messages.link_question); } if(import_button){ import_button.attr("onclick", "return confirm('" + qsm_admin_messages.confirm_message + " " + qsm_admin_messages.import_question_again + "');"); diff --git a/php/admin/options-page-questions-tab.php b/php/admin/options-page-questions-tab.php index b13b42b0..5139748c 100644 --- a/php/admin/options-page-questions-tab.php +++ b/php/admin/options-page-questions-tab.php @@ -940,7 +940,7 @@ function qsm_process_unlink_question_from_list_by_question_id( $question_id ) { $updated_linked_list = implode(',', array_filter($current_links)); $linked_ids = explode(',', $updated_linked_list); foreach ( $linked_ids as $linked_id ) { - $result = $wpdb->update( + $wpdb->update( $wpdb->prefix . 'mlw_questions', array( 'linked_question' => $updated_linked_list ), array( 'question_id' => intval($linked_id) ), @@ -1248,7 +1248,7 @@ function qsm_bulk_delete_question_from_database() { $update_qpages_after_delete = array(); $dependent_question_ids = qsm_get_unique_linked_question_ids_to_remove($question_id); if ( ! empty($dependent_question_ids) ) { - $dependent_question_ids = array_diff($dependent_question_ids, [ $base_question_id ] ); + $dependent_question_ids = array_diff($dependent_question_ids, [ $base_question_ids ] ); $update_qpages_after_delete = qsm_process_to_update_qpages_after_unlink($dependent_question_ids); } $question_id = array_merge($dependent_question_ids, $question_id); @@ -1299,18 +1299,16 @@ function qsm_process_to_update_qpages_after_unlink( $dependent_question_ids ) { global $wpdb, $mlwQuizMasterNext; $quiz_results = $wpdb->get_results( "SELECT `quiz_id`, `question_id` FROM `{$wpdb->prefix}mlw_questions` WHERE `question_id` IN (" .$comma_seprated_ids. ")" ); if ( ! empty($quiz_results) ) { - foreach ( $quiz_results as $key => $single_quiz ) { + foreach ( $quiz_results as $single_quiz ) { $quiz_id = $single_quiz->quiz_id; $mlwQuizMasterNext->pluginHelper->prepare_quiz( $quiz_id ); $pages = $mlwQuizMasterNext->pluginHelper->get_quiz_setting( 'pages', array() ); $clone_qpages = $qpages = $mlwQuizMasterNext->pluginHelper->get_quiz_setting( 'qpages', array() ); if ( ! empty($clone_qpages) ) { foreach ( $clone_qpages as $clonekey => $clonevalue ) { - if ( ! empty($clonevalue['questions']) ) { - if ( in_array($single_quiz->question_id, $clonevalue['questions']) ) { - $clone_qpages[ $clonekey ]['questions'] = array_diff($clonevalue['questions'], [ $single_quiz->question_id ]); - $pages[ $clonekey ] = array_diff($pages[ $clonekey ], [ $single_quiz->question_id ]); - } + if ( ! empty($clonevalue['questions']) && in_array($single_quiz->question_id, $clonevalue['questions']) ) { + $clone_qpages[ $clonekey ]['questions'] = array_diff($clonevalue['questions'], [ $single_quiz->question_id ]); + $pages[ $clonekey ] = array_diff($pages[ $clonekey ], [ $single_quiz->question_id ]); } } $qpages = $clone_qpages; diff --git a/php/classes/class-qsm-questions.php b/php/classes/class-qsm-questions.php index 18313ee1..a0cabf38 100644 --- a/php/classes/class-qsm-questions.php +++ b/php/classes/class-qsm-questions.php @@ -366,7 +366,6 @@ private static function create_save_question( $data, $answers, $settings, $is_cr $quiz_questions_array = array(); $quiz_questions_array[ intval( $data['quiz_id'] ) ] = $question_id; $linked_questions_array[] = $question_id; - $imploded_question_ids = $question_id; if ( isset($linked_question) && "" != $linked_question ) { $expolded_question_array = explode(',', $linked_question); $linked_questions_array = array_merge($expolded_question_array, $linked_questions_array); @@ -383,7 +382,7 @@ private static function create_save_question( $data, $answers, $settings, $is_cr $question_terms_table = $wpdb->prefix . 'mlw_question_terms'; foreach ( $quiz_questions_array as $quiz_id => $question_id_loop ) { $values['quiz_id'] = intval( $quiz_id ); - $results = $wpdb->update( + $wpdb->update( $wpdb->prefix . 'mlw_questions', $values, array( 'question_id' => intval($question_id_loop) ), diff --git a/php/rest-api.php b/php/rest-api.php index 5591619c..d59d4d80 100644 --- a/php/rest-api.php +++ b/php/rest-api.php @@ -509,7 +509,7 @@ function qsm_rest_get_question( WP_REST_Request $request ) { $quiz_name_by_question = array(); if ( ! empty($comma_seprated_ids) ) { $quiz_results = $wpdb->get_results( "SELECT `quiz_id`, `question_id` FROM `{$wpdb->prefix}mlw_questions` WHERE `question_id` IN (" .$comma_seprated_ids. ")" ); - foreach ( $quiz_results as $key => $value ) { + foreach ( $quiz_results as $value ) { $quiz_name_in_loop = $wpdb->get_row( $wpdb->prepare( "SELECT quiz_name FROM {$wpdb->prefix}mlw_quizzes WHERE quiz_id = %d", $value->quiz_id ), ARRAY_A ); $quiz_name_in_loop = isset( $quiz_name_in_loop['quiz_name'] ) ? $quiz_name_in_loop['quiz_name'] : ''; $quiz_name_by_question[] = $quiz_name_in_loop;