class Grade

Public Instance Methods

get_url_label() click to toggle source
# File Entities/Grade.rb, line 152
def get_url_label
  # dputs_func
  init_random
  dputs(4) { "Course is #{course.inspect}" }
  center_id = course.center ? course.center.login_name : 'pit'
  dputs(4) { "Course is #{course.inspect}" }
  "#{ConfigBase.get_url(:label_url)}/#{center_id}/#{random}"
end
init_random() click to toggle source
# File Entities/Grade.rb, line 145
def init_random
  while not self.random
    r = rand(1_000_000_000).to_s.rjust(9, '0')
    Grades.match_by_random(r) or self.random = r
  end
end
means=(m) click to toggle source
# File Entities/Grade.rb, line 166
def means=(m)
  if m != self._means
    if ConfigBase.has_function? :course_client
      self.random = nil
    end
  end
  if m
    self._means = m.collect { |v| [20.0, [0.0, v.to_f].max].min }
    self._mean = means.reduce(:+).to_f / m.count.to_f
  end
end
mention() click to toggle source
# File Entities/Grade.rb, line 128
def mention
  case to_s
    when 'P' then
      'Passable'
    when 'AB' then
      'Assez bien'
    when 'B' then
      'Bien'
    when 'TB' then
      'Très bien'
    when 'E' then
      'Excellent'
    else
      'PAS PASSÉ'
  end
end
person() click to toggle source
# File Entities/Grade.rb, line 161
def person
  dputs(0) { "Error: Deprecated - use student in #{caller.inspect}" }
  student
end
remark=(r) click to toggle source
# File Entities/Grade.rb, line 178
def remark=(r)
  if r != self._remark
    if ConfigBase.has_function? :course_client
      self.random = nil
    end
  end
  self._remark = r
end
setup_instance() click to toggle source
# File Entities/Grade.rb, line 99
def setup_instance
  if ConfigBase.has_function? :course_server
    init_random
  end
end
to_s() click to toggle source
# File Entities/Grade.rb, line 105
def to_s
  begin
    value = (data_get(:mean).to_f * 2).round / 2
  rescue FloatDomainError => _e
    return 'NP'
  end

  case value
    when 10..11.5 then
      'P'
    when 12..13 then
      'AB'
    when 14..15.5 then
      'B'
    when 16..17.5 then
      'TB'
    when 18..20 then
      'E'
    else
      'NP'
  end
end