Theoretically, we want to write it once even if the test_result is zero.
Then we can tell the difference between a "not tried" level and one in
which you failed with a result of zero.  But that could be accomplished
with your fetch() suggestion by passing "-1" instead of "0"


On Wed, Oct 30, 2013 at 12:36 PM, tobyk100 <notifications@github.com> wrote:

> In app/controllers/activities_controller.rb:
>
> >
> >        begin
> >          trophy_updates = trophy_check(current_user)
> >        rescue Exception => e
> >          Rails.logger.error "Error updating trophy exception: #{e.inspect}"
> >        end
> > +    else
> > +    session_progress = session[:progress] || {}
> > +
> > +      if !session_progress[level.id] || (test_result > session_progress[level.id])
>
> what about if test_result > session_progress.fetch(level.id, 0)
>
> —
> Reply to this email directly or view it on GitHub<https://github.com/code-dot-org/dashboard/pull/90/files#r7323412>
> .
>