Motivation

There is currently no way (that I could find) to hook into to the deletion of a quiz result.

Proposed resolution

I have attached a patch in the first comment below that adds a hook_quiz_results_deleted that is called whenever quiz results are deleted.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

ben.denham’s picture

Sivaji_Ganesh_Jojodae’s picture

Issue summary: View changes
Status: Needs review » Postponed (maintainer needs more info)
  • I would like to know some use cases for adding this hook
  • Not sure if we need to pass all the attributes of result id being deleted. Perhaps passing only $rids should be sufficient and hook implementing module shall query as needed
  • Maybe we can invoke hook after call to quiz_question_delete_result() per result id being deleted
berenddeboer’s picture

Use case is for example if a trophy is awarded to a user when he does the quiz.

For debugging/error cases sometimes you want to delete the quiz, and then the trophy should disappear as well.

As every other Drupal entity has a hook on delete, quiz should have one too.

berenddeboer’s picture

Status: Postponed (maintainer needs more info) » Reviewed & tested by the community

Status: Reviewed & tested by the community » Needs work
berenddeboer’s picture

Status: Needs work » Reviewed & tested by the community
berenddeboer’s picture

Have added a reroll of this patch.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 7: quiz-hook_quiz_results_deleted-2039375-5.patch, failed testing.

djdevin’s picture

We can put this in 4.x, but the hook in Quiz 7.x-5.x is hook_quiz_result_delete($quiz_result) so let's mirror that behavior.

berenddeboer’s picture

Status: Needs work » Needs review
FileSize
769 bytes

Reroll, and hook renamed as per #9.

berenddeboer’s picture

Version: 7.x-4.0-beta1 » 7.x-4.0-beta4

Status: Needs review » Needs work

The last submitted patch, 10: quiz-hook_quiz_results_deleted-2039375-10.patch, failed testing.

berenddeboer’s picture

Status: Needs work » Needs review
djdevin’s picture

Status: Needs review » Needs work

Can you have it mirror the hook in the newer 5.x?

We use the Entity API in 5.x so it follows this format

https://api.drupal.org/api/drupal/modules!system!system.api.php/function...

Function would be hook_quiz_result_delete($quiz_result) (takes in a single result)

djdevin’s picture

Status: Needs work » Closed (outdated)