Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Similar to this issue:
https://www.drupal.org/node/2581979
I am getting an SQL error on `result_id` for short_answers. To me at least the original SQL appears similar to the un-altered long_answer sql by amending the SQL in a similar fashion to the above resolved issue the query works and my result(s) are loaded.
See attached patch.
Comment | File | Size | Author |
---|---|---|---|
fix-short-answer-get-answer-query.patch | 1.79 KB | tenken | |
Comments
Comment #2
djdevinHi,
This function is no longer called in beta3, are you sure you are on that version?
Comment #3
tenken CreditAttribution: tenken as a volunteer commentedI'm sorry, I never told you how I was using this function. It appears this function is in the module and non-depercated at this time, nor is it labeled as private with a convention such as _short_answer_get_answer() Here it is in git:
http://cgit.drupalcode.org/quiz/tree/question_types/short_answer/short_a...
I want to send an email after quiz submission that contains within the email body some answers submitted by students. I found the default email options in the quiz admin form lacking to send summitted answers in quizes, whereas say the Webform module can more easily do this but doesn't contain a scoring feature. When I send an email I need to use this function to get the answers. Please correct me if there is a better approach :).
I used hook_quiz_finished simply because it was the simplest means to send a custom email on submission from this SO advice: http://stackoverflow.com/a/24161050/1491507
The below code works for beta3 within my project.
I understand, and my client understands, hook_quiz_finished is deprecated, when Quiz6 comes out we'll deal with making this all work again:
Thank you for your time and this module has shown to be very helpful! In this case we're using it basically to score small "work safety" training materials that have a simple score for student jobs such as cashier, food handing safety, etc and we require new student hires to complete.
So in short I use this function, and it appears broken, possibly relevant xkcd https://xkcd.com/1172/ :D
Comment #4
djdevinSorry :)
If you check out quiz.api.php all the deprecated hooks are listed there (as deprecated). Slowly we have been moving away from those "helper" functions and putting them into the Question API.
Moving forward Quiz 5+ is Entity-aware, so you can use Rules for doing things like sending email on Quiz completion. Or, you can use any of the Entity-defined hooks. There are 5 entity types defined, in quiz.api.php, that you can use instead of the deprecated custom hooks.
i.e. instead of
hook_quiz_finished
, usehook_quiz_result_update($quiz_result)
Then you can check if
$quiz_result->is_evaluated
.To replace
short_answer_get_answer()
I would do this instead:Let me know if that helps.
Comment #5
tenken CreditAttribution: tenken as a volunteer commentedok thank you! yes this is helpful should I re-engineer it in the future. :)
I'm not sure you want to use the supplied patch, my understanding is that the SQL in the current helper function is broken as-is.
Comment #6
djdevin