You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
While testing #3052 I encountered the following Fatal error when viewing lessons
PHP Fatal error: Uncaught TypeError: Argument 1 passed to Sensei\Internal\Student_Progress\Quiz_Progress\Repositories\Comments_Based_Quiz_Progress_Repository::get() must be of the type int, null given, called in /var/www/html/wp-content/themes/pub/wporg-learn-2024/inc/block-hooks.php on line 183 and defined in /var/www/html/wp-content/plugins/sensei-lms/includes/internal/student-progress/quiz-progress/repositories/class-comments-based-quiz-progress-repository.php:73
Stack trace:
#0 /var/www/html/wp-content/themes/pub/wporg-learn-2024/inc/block-hooks.php(183): Sensei\Internal\Student_Progress\Quiz_Progress\Repositories\Comments_Based_Quiz_Progress_Repository->get(NULL, 1)
#1 /var/www/html/wp-content/themes/pub/wporg-learn-2024/inc/block-hooks.php(119): WordPressdotorg\Theme\Learn_2024\Block_Hooks\is_quiz_ungraded()
#2 /var/www/html/wp-includes/class-wp-hook.php(326): WordPressdotorg\Theme\Learn_2024\Block_Hooks\update_lesson_quiz_notice_text('<div class="wp-...')
#3 /var/www/html/wp-includes/plugin.php(205): WP_Hook->apply_fil in /var/www/html/wp-content/plugins/sensei-lms/includes/internal/student-progress/quiz-progress/repositories/class-comments-based-quiz-progress-repository.php on line 73
This is happening in the is_quiz_ungraded() function, when a lesson is rendered, but which does not have a quiz attached to it.
A quick fix could be to check if the quiz_id returned from Sensei()->lesson->lesson_quizzes() is null or not, and return false early
/**
* Check if the quiz is ungraded.
*
* @return bool
*/
function is_quiz_ungraded() {
$lesson_id = Sensei_Utils::get_current_lesson();
$quiz_id = Sensei()->lesson->lesson_quizzes( $lesson_id );
if ( ! $quiz_id ) {
return false;
}
$user_id = get_current_user_id();
$quiz_progress = Sensei()->quiz_progress_repository->get( $quiz_id, $user_id );
if ( $quiz_progress && 'ungraded' === $quiz_progress->get_status() ) {
return true;
}
return false;
}
The text was updated successfully, but these errors were encountered:
While testing #3052 I encountered the following Fatal error when viewing lessons
This is happening in the
is_quiz_ungraded()
function, when a lesson is rendered, but which does not have a quiz attached to it.A quick fix could be to check if the quiz_id returned from
Sensei()->lesson->lesson_quizzes()
is null or not, and return false earlyThe text was updated successfully, but these errors were encountered: