staywoke/catalyst

Give a User only one correct / incorrect point per Task

Closed this issue · 2 comments

I think it's possible right now that if you've submitted multiple answers for a Task, you could get multiple "credits" for those answers. It should max out to one positive and one negative point per question.

app/jobs/calculate_response_statistics.rb

The way I would do this is to keep a Hash for correct and a Hash for incorrect. When you find a correct or incorrect answer, add a key into the appropriate Hash that's indexed by the task_id. You can just set the value to true. If you find a second response for the same task, you'll just set true again for an existing key (task_id). At the end, just count the keys of each of the Hashes.