Skip to content

Commit

Permalink
Merge pull request #2493 from QuizandSurveyMaster/CU-86curpua7-issue-…
Browse files Browse the repository at this point in the history
…with-category-limit

fixed QSL error with limit category option
  • Loading branch information
zubairraeen authored Mar 13, 2024
2 parents 71e6901 + 895802a commit 2246e75
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions php/classes/class-qmn-quiz-manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -696,7 +696,7 @@ public function load_questions( $quiz_id, $quiz_options, $is_quiz_page, $questio
}
}
// check If we should load a specific number of question
if ( '' == $quiz_options->limit_category_checkbox && 0 != $quiz_options->question_per_category && $is_quiz_page ) {
if ( ( '' == $quiz_options->limit_category_checkbox || 0 == $quiz_options->limit_category_checkbox ) && 0 != $quiz_options->question_per_category && $is_quiz_page ) {
$categories = QSM_Questions::get_quiz_categories( $quiz_id );
$category_ids = ( isset( $categories['list'] ) ? array_keys( $categories['list'] ) : array() );
$categories_tree = ( isset( $categories['tree'] ) ? $categories['tree'] : array() );
Expand All @@ -706,13 +706,13 @@ public function load_questions( $quiz_id, $quiz_options, $is_quiz_page, $questio
$question_id = implode( ',', $question_ids );
$term_ids = ( '' !== $quiz_options->randon_category ) ? $quiz_options->randon_category : $term_ids;
$tq_ids = $wpdb->get_results(
"SELECT DISTINCT `term_id`, `question_id`
FROM `{$wpdb->prefix}mlw_question_terms`
JOIN `{$wpdb->prefix}mlw_questions` ON `{$wpdb->prefix}mlw_question_terms`.`question_id` = `{$wpdb->prefix}mlw_questions`.`question_id`
WHERE `{$wpdb->prefix}mlw_question_terms`.`question_id` IN ($question_id)
AND `{$wpdb->prefix}mlw_question_terms`.`term_id` IN ($term_ids)
AND `{$wpdb->prefix}mlw_question_terms`.`taxonomy` = 'qsm_category'
AND `{$wpdb->prefix}mlw_questions`.`deleted` = 0
"SELECT DISTINCT qt.term_id, qt.question_id
FROM {$wpdb->prefix}mlw_question_terms AS qt
JOIN {$wpdb->prefix}mlw_questions AS q ON qt.question_id = q.question_id
WHERE qt.question_id IN ($question_id)
AND qt.term_id IN ($term_ids)
AND qt.taxonomy = 'qsm_category'
AND q.deleted = 0
",
ARRAY_A
);
Expand Down

0 comments on commit 2246e75

Please sign in to comment.