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

1. It makes the leaderboard more fair.
2. Tested properly, it works.
it saves outside, why need save here ?  also you said in convention update
means save, so I changed the function name.

On Thu, Sep 11, 2014 at 10:06 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
> > +  end
> > +
> > +  def set_obtained_at
> > +    self.obtained_at = created_at
>
> didn't save
>
> —
> Reply to this email directly or view it on GitHub
> <https://github.com/Coursemology/coursemology.org/pull/204/files#r17421965>
> .
>