Update: Refactor and improve quiz attempt list queries#2563
Merged
harunollyo merged 11 commits into4.0.0-devfrom Apr 16, 2026
Merged
Update: Refactor and improve quiz attempt list queries#2563harunollyo merged 11 commits into4.0.0-devfrom
harunollyo merged 11 commits into4.0.0-devfrom
Conversation
harunollyo
requested changes
Apr 15, 2026
| $is_student = tutor_utils()->is_enrolled( $course_id, get_current_user_id(), false ) && $is_student_view; | ||
|
|
||
| return $is_student; | ||
| private function check_is_student(): bool { |
Collaborator
There was a problem hiding this comment.
Use existing method
User::is_student_view()| const RESULT_FAIL = 'fail'; | ||
| const RESULT_PENDING = 'pending'; | ||
|
|
||
| const TABLE_NAME = 'tutor_quiz_attempts'; |
Collaborator
There was a problem hiding this comment.
This is not base table of quiz model, rename it
ATTEMPTS_TABLE = 'tutor_quiz_attempts';| @@ -40,7 +42,7 @@ class QuizModel { | |||
| */ | |||
| public function get_table(): string { | |||
| global $wpdb; | |||
Collaborator
There was a problem hiding this comment.
Just return with
QueryHelper::prepare_table_name( self::ATTEMPTS_TABLE );| return $quiz_attempts_list; | ||
| } | ||
|
|
||
| foreach ( $quiz_ids as $quiz_info ) { |
harunollyo
requested changes
Apr 15, 2026
| * | ||
| * @return array | ||
| */ | ||
| public static function get_quiz_id_by_user_quiz_attempts( $user_id = 0, $course_id = 0, $start = 0, $limit = 0, $order_filter = 'DESC', $result_filter = '' ) { |
Collaborator
There was a problem hiding this comment.
`get_attempted_quizzes( $user_id, $course_id = 0, $start = 0, $limit = 0, $order_filter = 'DESC', $args = array() )
| $quiz_attempts_formatted = QuizModel::format_quiz_attempts( $quiz_attempts, $result_filter ); | ||
| $quiz_attempts_list = array_slice( $quiz_attempts_formatted, $offset, $item_per_page, true ); | ||
| $quiz_attempts_count = (int) count( $quiz_attempts_formatted ); | ||
| $quiz_ids_query = QuizModel::get_quiz_id_by_user_quiz_attempts( get_current_user_id(), $course_id, $offset, $item_per_page, $order_filter, $result_filter ); |
harunollyo
approved these changes
Apr 16, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.