app/models/project.rb
# Given numeric level 1+, set the value of
# achieve_{previous_level_name}_status to either Met or Unmet, based on
# the achievement of the *previous* level. This is a simple way to ensure
# that to pass level X when X > 0, you must meet the criteria of level X-1.
# We *only* set the field if it currently has a different value.
# When filling in the prerequisites, we do not fill in the justification
# for them. The justification is only there as it makes implementing this
# portion of the code simpler.
Given numeric level 1+, set the value of
achieve_{previous_level_name}_status to either Met or Unmet, based on
the achievement of the *previous* level. This is a simple way to ensure
that to pass level X when X > 0, you must meet the criteria of level X-1.
We *only* set the field if it currently has a different value.
When filling in the prerequisites, we do not fill in the justification
for them. The justification is only there as it makes implementing this
portion of the code simpler.
Given numeric level 1 + set the value of achieve_ { previous_level_name } _status to either Met or Unmet based on the achievement of the * previous * level . This is a simple way to ensure that to pass level X when X > 0 you must meet the criteria of level X - 1 . We * only * set the field if it currently has a different value . When filling in the prerequisites we do not fill in the justification for them . The justification is only there as it makes implementing this portion of the code simpler .
def update_prereqs(level)
    level = level.to_i
    return if level <= 0
    achieved_previous_level = "achieve_#{BADGE_LEVELS[level]}_status".to_sym
    if self["badge_percentage_#{level - 1}".to_sym] >= 100
      return if self[achieved_previous_level] == 'Met'
      self[achieved_previous_level] = 'Met'
    else
      return if self[achieved_previous_level] == 'Unmet'
      self[achieved_previous_level] = 'Unmet'
    end
  end
def update_prereqs ( level ) level = level . to_i return if level <= 0 achieved_previous_level = "achieve_#{BADGE_LEVELS[level]}_status" . to_sym if self [ "badge_percentage_#{level - 1}" . to_sym ] >= 100 return if self [ achieved_previous_level ] == 'Met' self [ achieved_previous_level ] = 'Met' else return if self [ achieved_previous_level ] == 'Unmet' self [ achieved_previous_level ] = 'Unmet' end end
Given numeric level 1+, set the value of
achieve_{previous_level_name}_status to either Met or Unmet, based on
the achievement of the *previous* level.
Given numeric level 1 + set the value of achieve_ { previous_level_name } _status to either Met or Unmet based on the achievement of the * previous * level .
# The following works because BADGE_LEVELS[1] is 'passing', etc:
level
<not_specific>