update achievement gain date to submission date(not grading date)

1. It makes the leaderboard more fair.
2. Tested properly, it works.
OK, 2nd point is a good idea. will update

On Wed, Sep 10, 2014 at 8:19 PM, Raymoond Tang <notifications@github.com>
wrote:

> In app/models/user_achievement.rb:
>
> > +        INNER JOIN (SELECT requirements.req_id FROM requirements
> > +            WHERE requirements.obj_id = #{ achievement.id }
> > +            AND requirements.obj_type = 'Achievement'
> > +            AND requirements.req_type = 'AsmReq') req
> > +            ON req.req_id = asm_reqs.id")
> > +
> > +    lastest_submission_date = nil
> > +    submissions.each do |submission|
> > +      if submission.submitted_at &&
> > +          (!lastest_submission_date ||
> > +              submission.submitted_at > lastest_submission_date)
> > +        lastest_submission_date = submission.submitted_at
> > +      end
> > +    end
> > +    self.updated_at = lastest_submission_date if lastest_submission_date
> > +  end
>
> Two steps:
> 1, get all req assessments of the achievement
> 2, get all submission of these assessments by this student order by
> submitted_at desc, and take the first one.
>
> —
> Reply to this email directly or view it on GitHub
> <https://github.com/Coursemology/coursemology.org/pull/204/files#r17357195>
> .
>