When a poll deletion action is performed now, it only delete a poll and leave the options and votes related to it.
Consider this situation:
Database:MySQL, and the primary key of POLL_POLL, POLL_OPTION and POLL_VOTE is auto_inc.
1. An instructor(say Alice) created a poll(id=1) with some options(id=1,2,3,4), and some students voted it(id=1,2,3)
2. The instructor delete the vote. This action only delete the poll(id=1) and leave the options and votes like orphans.
3. For some reason, an DB backup/restore action is executed.
4. Another instructor(say Bob) create a poll. This poll will assigned by the same ID(id=1). He will see the options(id=1,2,3,4) appear in his new poll without any more actions. Also, if the poll is created by Alice in the same course site, the poll vote will be assigned to some students even they haven't seen the poll.
Here is my solution:
1. Delete the relevant options and votes when delete a poll.
2. Delete the relevant votes when (hard) delete an option.
About the Attachment
1. Modify /polls/impl/src/java/org/sakaiproject/poll/service/impl/PollListManagerImpl.java to perform these actions. And inject a PollVoteManager to delete votes of a poll/option.
2. Modify /polls/pack/src/webapp/WEB-INF/components.xml to inject PollVoteManager.
3. Delete the mothod testDeletePoll of /polls/impl/src/test/org/sakaiproject/poll/logic/test/PollListManagerTest.java. Since this test method will generate an error.
4. SQL statments to delete the exist orphan optoins and votes.