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

sensei_user_quiz_grade happens before Sensei()->quiz->set_user_grades() #2385

Open
jondcampbell opened this Issue Jan 24, 2019 · 1 comment

Comments

Projects
None yet
1 participant
@jondcampbell
Copy link

jondcampbell commented Jan 24, 2019

Steps to Reproduce

  1. Submit a quiz with learner graded quiz notification turned on.
  2. Customize the learner-graded-quiz.php email template to show some data based on specific questions in the quiz.
  3. The email template doesn't yet have access to the users quiz answers grading because that doesn't get saved until after the sensei_user_quiz_grade hooks are all complete. Then it sets the users grades.

What I Expected

It would be great to access the users question grades in the email templates.
I use this to retrieve the grades for the questions:
Sensei()->quiz->get_user_question_grade( $lesson_id, $question->ID, $user_id )

What Happened Instead

The question grades are all unset because emails are sent before the users question grade data is stored.

@jondcampbell

This comment has been minimized.

Copy link
Author

jondcampbell commented Jan 29, 2019

My current use case only has one course/lesson/quiz so I can get away with moving the emails from 'sensei_user_quiz_grade' and 'sensei_course_status_updated' hooks to be on 'sensei_user_quiz_submitted' with some messy tweaking. By the time 'sensei_user_quiz_submitted' fires I have access to the quiz answers.

But to me, it would make more sense to have the users answered saved to the database before we trigger the email for `learner_graded_quiz.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment