-
Notifications
You must be signed in to change notification settings - Fork 197
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
Block quiz answers when the quiz is completed #4951
Block quiz answers when the quiz is completed #4951
Conversation
f0bf63f
to
c88940f
Compare
includes/class-sensei-question.php
Outdated
$data['quiz_grade_type'] = get_post_meta( $quiz_id, '_quiz_grade_type', true ); | ||
$data['reset_quiz_allowed'] = $reset_allowed; | ||
$data['lesson_complete'] = $user_lesson_complete; | ||
$data['quiz_is_completed'] = Sensei_Quiz::is_quiz_completed(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you think it makes sense to pass the $quiz_id
variable when calling the is_quiz_completed
method?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I'm not sure if I understand your question. I think you already have the $quiz_id
provided to the get_template_data( $question_id, $quiz_id )
method, so you could pass that along to Sensei_Quiz::is_quiz_completed( $quiz_id )
. If you don't, is_quiz_completed
will use by default the post that is currently in the loop (by calling get_the_ID()
).
Did that answer the question?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, my comment was in the wrong place, please ignore it.
I agree with quiz_id, I am going to update.
// Check again that the lesson is complete | ||
$user_lesson_end = Sensei_Utils::user_completed_lesson( Sensei()->quiz->get_lesson_id( $quiz_id ), get_current_user_id() ); | ||
$user_lesson_complete = false; | ||
if ( $user_lesson_end ) { | ||
$user_lesson_complete = true; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice refactoring! 👍
We were calling some methods multiple times, instead of reuse the returned value. E.g quiz_id, user_id
a9135a6
to
5501ecb
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Works well 👍
There are a few linter issues, though.
@merkushin I added back the $data['lesson_complete'] until we have a way to deprecate keys. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, Gabriel! 👍
Fixes #4889
Changes proposed in this Pull Request
This PR is blocking almost all question types to be updated after the student submits its answer.
Testing instructions