Automattic / sensei

Sensei LMS - Online Courses, Quizzes, & Learning
https://senseilms.com
GNU General Public License v2.0
545 stars 198 forks source link

Restart Quiz redirects to the course completed page if the course was completed #7212

Closed renatho closed 11 months ago

renatho commented 1 year ago

Steps to Reproduce

  1. Create a course with lessons.
  2. Create a quiz with the "Allow Retakes" setting enabled.
  3. Complete the course as a student.
  4. Return to the quiz and click on "Restart Quiz"

What I Expected

Continue on the quiz page to answer the questions again.

What Happened Instead

I was redirected to the course completed page.

PHP / WordPress / Sensei LMS version

PHP 7.4 / WP 6.3 / Sensei 4.17.0

Browser / OS version

Chrome / Mac OS

Screenshot / Video

https://github.com/Automattic/sensei/assets/876340/c0ffcd23-0f00-4f18-b9ef-e1aff38953a2

StefMattana commented 11 months ago

A user in 7375078-zen reported the same bug, and tried to fix it with this hook:

add_action('sensei_user_lesson_reset', function($user_id, $lesson_id) {
$current_page = get_permalink();
wp_redirect($current_page);
exit;
}, 9, 2);

However, they stumbled upon with more issues:

Their solution would be to extend theSensei_Course_Theme_Quiz class and add a provision to only show the retake quiz button on failed grades, but they're looking for a better hook to manage that. Would that be possible?

github-actions[bot] commented 11 months ago

Support References

This comment is automatically generated. Please do not edit it.

m1r0 commented 11 months ago

passing the course allows students to retake the quiz anyway

I've created a separate issue for this: https://github.com/Automattic/sensei/issues/7379