You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

42 lines
1.4 KiB

class User < ApplicationRecord
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable, :trackable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :validatable
has_many :entries, dependent: :destroy
PRAKTIKUMSTYPEN = %w[propädeutikum fachspezifikum]
ENTRY_ARTEN = %w[Praktikum Selbsterfahrung Supervision]
after_initialize :set_default, if: :new_record?
def set_default
self.required_hours_matrix = PRAKTIKUMSTYPEN.to_h do |typ|
[typ, ENTRY_ARTEN.to_h { |art| [art, default_hours_for(typ, art)] }]
end
self.weekly_target_matrix = {
"propädeutikum" => { "Praktikum" => 12, "Selbsterfahrung" => 0.25, "Supervision" => 0.25 },
"fachspezifikum" => { "Praktikum" => 10, "Selbsterfahrung" => 0.25, "Supervision" => 0.25 }
}
end
def default_hours_for(typ, art)
case [typ, art]
when ["propädeutikum", "Praktikum"] then 480
when ["propädeutikum", "Selbsterfahrung"] then 50
when ["propädeutikum", "Supervision"] then 20
when ["fachspezifikum", "Praktikum"] then 600
when ["fachspezifikum", "Selbsterfahrung"] then 80
when ["fachspezifikum", "Supervision"] then 40
else 0
end
end
def required_hours_for(typ, art)
required_hours_matrix.dig(typ, art) || 0
end
end