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.
91 lines
2.9 KiB
91 lines
2.9 KiB
class User < ApplicationRecord
|
|
# Include default devise modules. Others available are:
|
|
# :confirmable, :lockable, :timeoutable, :trackable and :omniauthable
|
|
devise :database_authenticatable, :registerable,
|
|
:recoverable, :rememberable, :validatable, :confirmable
|
|
|
|
has_many :entries, dependent: :destroy
|
|
|
|
PRAKTIKUMSTYPEN = %w[propädeutikum fachspezifikum]
|
|
ENTRY_ARTEN = [
|
|
"Praktikum",
|
|
"Selbsterfahrung",
|
|
"Supervision",
|
|
# Neue differenzierte Einträge (nur sichtbar im fachspezifikum-Kontext)
|
|
"Gruppenselbsterfahrung", # 64h
|
|
"Theorie/Methodikseminare", # 216h
|
|
"Peergruppensupervision", # 168h
|
|
"Einzel-/Kleingruppensupervision", # 40h
|
|
"Eigenständige Tätigkeit"
|
|
]
|
|
|
|
after_initialize :set_default, if: :new_record?
|
|
|
|
def praepedeutikum_abgeschlossen?
|
|
praepedeutikum_done
|
|
end
|
|
def is_admin?
|
|
self.email =="christoph@marzell.net"
|
|
end
|
|
|
|
def update_required_matrices!
|
|
PRAKTIKUMSTYPEN.each do |typ|
|
|
required_hours_matrix[typ] ||= {}
|
|
weekly_target_matrix[typ] ||= {}
|
|
|
|
ENTRY_ARTEN.each do |art|
|
|
required_hours_matrix[typ][art] ||= default_hours_for(typ, art)
|
|
weekly_target_matrix[typ][art] ||= default_weekly_target_for(typ, art)
|
|
end
|
|
end
|
|
|
|
save!
|
|
end
|
|
|
|
|
|
def default_weekly_target_for(typ, art)
|
|
case [typ, art]
|
|
when ["propädeutikum", "Praktikum"] then 12
|
|
when ["fachspezifikum", "Praktikum"] then 10
|
|
when ["propädeutikum", "Selbsterfahrung"],
|
|
["fachspezifikum", "Selbsterfahrung"],
|
|
["fachspezifikum", "Gruppenselbsterfahrung"] then 0.25
|
|
when ["propädeutikum", "Supervision"],
|
|
["fachspezifikum", "Supervision"],
|
|
["fachspezifikum", "Peergruppensupervision"],
|
|
["fachspezifikum", "Einzel-/Kleingruppensupervision"] then 0.25
|
|
when ["fachspezifikum", "Eigenständige Tätigkeit"] then 10
|
|
else 0
|
|
end
|
|
end
|
|
|
|
|
|
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
|
|
when ["fachspezifikum", "Eigenständige Tätigkeit"] then 600
|
|
else 0
|
|
end
|
|
end
|
|
|
|
def required_hours_for(typ, art)
|
|
required_hours_matrix.dig(typ, art) || 0
|
|
end
|
|
|
|
end
|