Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed QSL error with limit category option #2493

Merged
merged 1 commit into from
Mar 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading