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

1. It makes the leaderboard more fair.
2. Tested properly, it works.
There is an "if submission"


On Thu, Sep 11, 2014 at 10:07 PM, Raymoond Tang <notifications@github.com>
wrote:

> In app/models/user_achievement.rb:
>
> >    belongs_to :user_course
> >    belongs_to :achievement
> >
> > +  def assign_obtained_date
> > +    # update achievement obtained date to submission date(not grading date)
> > +    submission = Assessment.joins(:as_asm_reqs)
> > +        .where("asm_reqs.id IN (?)", achievement.requirements.asm_req.pluck(:req_id)).submissions
> > +        .where(std_course_id: user_course_id)
> > +        .order("submitted_at DESC").first
> > +    self.obtained_at = submission.submitted_at || obtained_at if submission
>
> submission could be nil
>
> —
> Reply to this email directly or view it on GitHub
> <https://github.com/Coursemology/coursemology.org/pull/204/files#r17422009>
> .
>