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

1. It makes the leaderboard more fair.
2. Tested properly, it works.
why ?  If save here then means every time it will automatic save after
create ?

On Thu, Sep 11, 2014 at 10:35 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
>
> this will not work: after_create :set_obtained_at
>
> —
> Reply to this email directly or view it on GitHub
> <https://github.com/Coursemology/coursemology.org/pull/204/files#r17423634>
> .
>