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

1. It makes the leaderboard more fair.
2. Tested properly, it works.
no, the logic is not correct, if I just want to create a achievement for
test,  don't want to save how to do ?

On Thu, Sep 11, 2014 at 10:40 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
>
> how many times after_create will be triggered ?
>
> —
> Reply to this email directly or view it on GitHub
> <https://github.com/Coursemology/coursemology.org/pull/204/files#r17424123>
> .
>