Sanchez/fix duplicate assessments

Adds in the initial client side JS fix to avoid duplicate calls to get peer submissions, but also secures the client side code to avoid retrieving duplicate peer workflow items when an assessment has been made against the associated submission.

This does mean that, if a duplicate does get created, a soft lock will be created on the associated submission until the duplicate has expired. With client side changes this should be much less frequent. 

@wedaly @gradyward 
It's possible to do a nested SQL query, but I'm hoping to avoid raw SQL for
this. I'll see if I can find a suitable Django Models equivalent; I had the
same thought about the additional queries, though to be fair this should
very rarely be more than, say, two open items.


On Wed, Aug 6, 2014 at 12:43 PM, Will Daly <notifications@github.com> wrote:

> In openassessment/assessment/models/peer.py:
>
> > @@ -341,8 +365,10 @@ def get_latest_open_workflow_item(self):
> >
> >          """
> >          workflow_query = self.graded.filter(assessment__isnull=True).order_by("-started_at", "-id")  # pylint:disable=E1101
> > -        items = list(workflow_query[:1])
> > -        return items[0] if items else None
> > +        for item in workflow_query:
> > +            if not self._is_duplicate_of_completed_item(item):
> > +                return item
>
> I'm concerned that this is going to introduce more database calls in some
> of our slowest AJAX requests. Would it be possible to retrieve all the
> workflow items in one database request (both completed and incomplete),
> then programmatically filter out the duplicates?
>
> —
> Reply to this email directly or view it on GitHub
> <https://github.com/edx/edx-ora2/pull/592/files#r15886345>.
>