Created
November 21, 2018 10:47
-
-
Save ecmelkytz/53485ce57661d8db7e7fdbe6cf78792c to your computer and use it in GitHub Desktop.
Akademik takvim tarih aralıkları
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class CalendarEvent < ApplicationRecord | |
def proper_range? | |
Time.zone.now >= start_date && Time.zone.now <= end_date | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class CalendarTitle < ApplicationRecord | |
EVENTS = YAML.safe_load(File.read("#{Rails.root}/db/static_data/calendar_titles.yml")).freeze | |
class << self | |
EVENTS.keys.each do |event| | |
EVENTS[event].keys.each do |key| | |
define_method "#{event}_#{key}" do | |
find_by(name: EVENTS[event][key]['name']) | |
end | |
end | |
end | |
end | |
end | |
# Usage | |
# CalendarTitle.course_registration | |
# => CalendarTitle Load (0.5ms) SELECT "calendar_titles".* FROM "calendar_titles" WHERE "calendar_titles"."name" = $1 LIMIT $2 [["name", "Ders Kayıtları"], ["LIMIT", 1]] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
course: | |
registration: | |
name: Ders Kayıtları | |
code: 10000 | |
add_and_drop: | |
name: Ders Ekleme ve Bırakma | |
code: 10001 | |
start_date: | |
name: Derslerin Başlaması | |
code: 10010 | |
end_date: | |
name: Derslerin Bitimi | |
code: 10011 | |
exam: | |
midterm_date: | |
name: Ara Sınav Haftası | |
code: 20000 | |
final_date: | |
name: Yarıyıl Sonu Sınav Haftası | |
code: 20010 | |
submission_final_date: | |
name: Yarıyıl Sonu Sınav Sonuçlarının İnternetten Girilmesinin Son Günü ve Sonuçların İlanı | |
code: 20011 | |
makeup_date: | |
name: Bütünleme Sınav Haftası | |
code: 20020 | |
submission_makeup_date: | |
name: Bütünleme Sınav Sonuçlarının İnternetten Girilmesinin Son Günü ve Sonuçların İlanı | |
code: 20021 | |
single_course: | |
name: Tek Ders Sınavları | |
code: 20030 | |
submission_single_course: | |
name: Tek Ders Sınav Sonuçlarının ÖİDB'ye Gönderilmesi | |
code: 20031 | |
foreign_language_proficiency: | |
name: Zorunlu Hazırlık Sınıfları Yabancı Dil Yeterlik Sınavı | |
code: 20040 | |
submission_proficiency: | |
name: Yeterlik Sınav Sonuçlarının İlanı | |
code: 20041 | |
foreign_language_exemption: | |
name: Yabancı Dil Muafiyet Sınavları (5/i Dersleri İçin) | |
code: 20050 | |
grading: | |
name: Hazırlık Sınıfları İçin Düzey Belirleme Sınavı | |
code: 20060 | |
application: | |
major_and_minor: | |
name: Çift Anadal ve Yandal Başvuruları | |
code: 30010 | |
submission_major_and_minor: | |
name: Çift Anadal ve Yandal Başvurularının Birimlerce Değerlendirilmesi ve İlanı | |
code: 30011 | |
exclusivly_course: | |
name: Mazeretli Ders Kaydı Başvuruları Son Günü | |
code: 30020 | |
single_course: | |
name: Tek Ders Sınav Müracaatları | |
code: 30030 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Student < ApplicationRecord | |
def proper_event_range?(title) | |
academic_calendars.last.calendar_events.find_by(calendar_title_id: CalendarTitle.send(title)).proper_range? | |
end | |
end | |
# Öğrencinin ders kaydını yapıp yapamayacağını sorgulamak için: | |
# @student.proper_event_range?(:course_registration) | |
# Öğrencinin çift anadal ve yandal başvurusunu yapıp yapamayacağını sorgulamak için: | |
# @student.proper_event_range?(:application_major_and_minor) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment