Skip to content
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

attempt_submitted\handler.php is using the wrong table to look up attempt #317

Closed
caperneoignis opened this issue Nov 20, 2018 · 3 comments
Labels

Comments

@caperneoignis
Copy link
Contributor

Description

  • $event->objectid is coming in with 417 for quiz_attempts. However, question_attempts does not have 417. The record is not found and hence no data is being pulled from the record. Some how this is still working unless you have a boat load of attempts. Not sure how it's still working, unless there is an additional lookup deeper for each question and that just so happens to still work with smaller attempt numbers. However, on bigger sites this breaks.
$questionattempts = $repo->read_records('question_attempts', [
       'questionusageid' => $event->objectid
   ]);

Version

  • my latest branch using the latest master.

Steps to reproduce the bug

  1. get more quiz attempts then question attempts. Should break the attempt submitted.

Expected behaviour

  • should pull up the questions for that attempt.

Actual behaviour

  • nothing is returned for question attempts which means nothing is being sent to the LRS.

Additional information

  • Since I have to fix this any way, I will try and submit the fix with my question submitted fix. Not sure how this broke, it was working before on the server with a bunch of attempts. I will check file history to see what has changed.
@caperneoignis
Copy link
Contributor Author

This looks like it may solve the issue.

SELECT qa.*, qat.questionid FROM moodle.mdl_quiz_attempts as qa 
join mdl_question_usages as qu on qu.id = qa.uniqueid 
join mdl_question_attempts as qat on qat.questionusageid = qu.id where qa.id = {attemptID};

This returns all 15 quiz questions. About to test now.

@caperneoignis
Copy link
Contributor Author

That pretty much was the fix, including these items. $attempt = $repo->read_record('quiz_attempts', array('uniqueid' => $questionattempt->questionusageid)); the quiz_attempts are being sent incorrect ids. I didn't notice this until I started to get super high in attempts for one quiz. Not sure how we haven't had a problem yet. I also had to put back $DB->get_records_sql() so I could pull the complex sql command.

@HT2Bot
Copy link
Member

HT2Bot commented Nov 27, 2018

🎉 This issue has been resolved in version 3.18.3 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants