app/models/mark.rb
# When a mark is saved, we need to make sure that that
# Result has not been released to students
When a mark is saved, we need to make sure that that
Result has not been released to students
When a mark is saved we need to make sure that that Result has not been released to students
def scale_mark(curr_max_mark, prev_max_mark, update: true)
    return if mark.nil?
    return 0 if prev_max_mark == 0 || mark == 0 
    if criterion.is_a? CheckboxCriterion
      new_mark = curr_max_mark
    else
      new_mark = (mark * (curr_max_mark.to_f / prev_max_mark)).round(2)
    end
    if update
      update_columns(mark: new_mark)
    end
    new_mark
  end
def scale_mark ( curr_max_mark , prev_max_mark , update : true ) return if mark . nil? return 0 if prev_max_mark == 0 || mark == 0 if criterion . is_a? CheckboxCriterion new_mark = curr_max_mark else new_mark = ( mark * ( curr_max_mark . to_f / prev_max_mark ) ) . round ( 2 ) end if update update_columns ( mark : new_mark ) end new_mark end
When a mark is saved, we need to make sure that that
Result has not been released to students
When a mark is saved we need to make sure that that Result has not been released to students
# no scaling occurs if prev_max_mark is 0 or mark is 0 # Use update_columns to skip validations.
curr_max_mark
<not_specific>
prev_max_mark
<not_specific>
update
<not_specific>