gaku_core 0.2.4 → 0.3.0.pre.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (108) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +17 -0
  3. data/app/assets/images/elements/toolbar1.png +0 -0
  4. data/app/assets/images/icon-chair.png +0 -0
  5. data/app/models/application_record.rb +3 -0
  6. data/app/models/concerns/{enrollmentable.rb → enrollable.rb} +2 -2
  7. data/app/models/concerns/gradable.rb +2 -0
  8. data/app/models/gaku/address.rb +3 -3
  9. data/app/models/gaku/attachment.rb +4 -2
  10. data/app/models/gaku/attendance.rb +3 -3
  11. data/app/models/gaku/class_group.rb +1 -1
  12. data/app/models/gaku/contact.rb +2 -2
  13. data/app/models/gaku/course.rb +3 -3
  14. data/app/models/gaku/enrollment.rb +23 -19
  15. data/app/models/gaku/exam.rb +2 -2
  16. data/app/models/gaku/exam_portion.rb +1 -1
  17. data/app/models/gaku/exam_portion_score.rb +6 -2
  18. data/app/models/gaku/exam_session.rb +3 -3
  19. data/app/models/gaku/extracurricular_activity.rb +1 -1
  20. data/app/models/gaku/grading_method_connector.rb +3 -3
  21. data/app/models/gaku/guardian.rb +1 -1
  22. data/app/models/gaku/lesson_plan.rb +1 -1
  23. data/app/models/gaku/note.rb +1 -1
  24. data/app/models/gaku/program_specialty.rb +2 -2
  25. data/app/models/gaku/school_role.rb +1 -1
  26. data/app/models/gaku/semester.rb +1 -1
  27. data/app/models/gaku/semester_connector.rb +2 -2
  28. data/app/models/gaku/specialty.rb +1 -1
  29. data/app/models/gaku/student.rb +10 -12
  30. data/app/models/gaku/student_review.rb +3 -3
  31. data/app/models/gaku/student_specialty.rb +2 -2
  32. data/app/models/gaku/syllabus.rb +1 -1
  33. data/app/models/gaku/teacher.rb +1 -1
  34. data/config/initializers/redis.rb +6 -2
  35. data/db/default/gaku/attendance_types.rb +1 -1
  36. data/db/migrate/20120202111850_presets.rb +3 -4
  37. data/db/migrate/20131014065028_translations.rb +1 -1
  38. data/db/migrate/20131025073352_gaku_core.rb +1 -1
  39. data/db/migrate/20140128141752_change_grading_methods_arguments_field.rb +1 -1
  40. data/db/migrate/20140130182100_change_fields_external_school_record.rb +1 -1
  41. data/db/migrate/20140131113337_create_student_configs.rb +1 -1
  42. data/db/migrate/20140207093618_drop_student_configs.rb +1 -1
  43. data/db/migrate/20140213113405_create_grading_method_connectors_table.rb +1 -1
  44. data/db/migrate/20140304094422_create_gaku_exam_sessions_table.rb +1 -1
  45. data/db/migrate/20140325073941_add_time_format_24_to_presets_table.rb +1 -1
  46. data/db/migrate/20140408111314_remove_semester_join_tables.rb +1 -1
  47. data/db/migrate/20140408111358_create_semester_connectors_table.rb +1 -1
  48. data/db/migrate/20140423093155_create_enrollments_table.rb +1 -1
  49. data/db/migrate/20140423100114_clean_enrollments_join_models.rb +1 -1
  50. data/db/migrate/20140429112725_add_counters_to_enrollmentable.rb +3 -1
  51. data/db/migrate/20140604104210_rename_method_to_grading_method.rb +1 -1
  52. data/db/migrate/20140604113045_add_default_value_to_curved.rb +1 -1
  53. data/db/migrate/20140610091053_add_seat_number_to_enrollments.rb +1 -1
  54. data/db/migrate/20140701104700_change_hstore_to_string_criteria.rb +1 -1
  55. data/db/migrate/20140715135152_create_semester_attendance_table.rb +1 -1
  56. data/db/migrate/20140718105226_create_student_review_categories_table.rb +1 -1
  57. data/db/migrate/20140728121353_create_student_review_table.rb +1 -1
  58. data/db/migrate/20150213095508_improve_countries_and_states.rb +1 -1
  59. data/db/migrate/20160125194100_add_gradable_to_exam_portion_score.rb +5 -0
  60. data/db/migrate/20170509132020_change_enrollmentable_to_enrollable.rb +6 -0
  61. data/gaku_core.gemspec +37 -0
  62. data/lib/gaku/core.rb +1 -1
  63. data/lib/gaku/core/engine.rb +1 -1
  64. data/lib/gaku/grading/collection/base_method.rb +3 -2
  65. data/lib/gaku/grading/collection/calculations.rb +5 -3
  66. data/lib/gaku/grading/collection/interval.rb +2 -2
  67. data/lib/gaku/grading/collection/ordinal.rb +1 -1
  68. data/lib/gaku/grading/collection/percentage.rb +1 -1
  69. data/lib/gaku/grading/collection/score.rb +1 -1
  70. data/lib/gaku/grading/single/base_method.rb +3 -2
  71. data/lib/gaku/grading/single/calculations.rb +5 -4
  72. data/lib/gaku/grading/single/ordinal.rb +2 -3
  73. data/lib/gaku/grading/single/percentage.rb +2 -3
  74. data/lib/gaku/grading/single/score.rb +2 -3
  75. data/lib/gaku/testing/common_rake.rb +47 -6
  76. data/lib/gaku/testing/controller_helpers.rb +6 -4
  77. data/lib/gaku/testing/factories/address_factory.rb +3 -3
  78. data/lib/gaku/testing/factories/campus_factory.rb +1 -1
  79. data/lib/gaku/testing/factories/enrollment_factory.rb +1 -1
  80. data/lib/gaku/testing/factories/guardian_factory.rb +2 -2
  81. data/lib/gaku/testing/factories/program_factory.rb +1 -1
  82. data/lib/gaku/testing/factories/school_factory.rb +1 -1
  83. data/lib/gaku/testing/factories/student_factory.rb +7 -5
  84. data/lib/gaku/testing/factories/syllabus_factory.rb +1 -1
  85. data/lib/gaku/testing/factories/teacher_factory.rb +4 -4
  86. data/lib/gaku/testing/factories/user_factory.rb +2 -2
  87. data/lib/generators/gaku/docker/docker_generator.rb +58 -0
  88. data/lib/generators/gaku/docker/templates/app/assets/javascripts/gaku/admin/all.js +10 -0
  89. data/lib/generators/gaku/docker/templates/app/assets/javascripts/gaku/archive/all.js +10 -0
  90. data/lib/generators/gaku/docker/templates/app/assets/javascripts/gaku/frontend/all.js +10 -0
  91. data/lib/generators/gaku/docker/templates/app/assets/stylesheets/gaku/admin/all.css +9 -0
  92. data/lib/generators/gaku/docker/templates/app/assets/stylesheets/gaku/archive/all.css +9 -0
  93. data/lib/generators/gaku/docker/templates/app/assets/stylesheets/gaku/frontend/all.css +9 -0
  94. data/lib/generators/gaku/docker/templates/bin/check_postgres.sh +16 -0
  95. data/lib/generators/gaku/docker/templates/config/database.yml +2 -0
  96. data/lib/generators/gaku/dummy/dummy_generator.rb +0 -1
  97. data/lib/generators/gaku/dummy/templates/rails/application.rb +0 -1
  98. data/lib/generators/gaku/dummy/templates/rails/database.yml +11 -10
  99. data/lib/generators/gaku/install/install_generator.rb +17 -0
  100. data/lib/generators/gaku/install/templates/Procfile +3 -0
  101. data/lib/generators/gaku/install/templates/lib/grading/README.md +2 -0
  102. data/lib/generators/gaku/install/templates/lib/grading/bin/gaku_grading.coffee +13 -0
  103. data/lib/generators/gaku/install/templates/lib/grading/package.json +19 -0
  104. data/lib/tasks/core.rake +1 -1
  105. data/lib/tasks/grading.rake +10 -0
  106. metadata +69 -53
  107. data/db/migrate/20140304101025_create_gaku_student_exam_session_table.rb +0 -8
  108. data/lib/gaku/testing/factories/student_exam_session_factory.rb +0 -8
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c177190fb90baf6702fe0ad328ff1bdf99fd69a8
4
- data.tar.gz: 060ed55eea189889c7efcc7a4aa1777f6ba96961
3
+ metadata.gz: a76c61f9769e8432f306125839305e169d1cb7ea
4
+ data.tar.gz: 6d7eff5c17d2c61af2a28989be672ad19b25d9e7
5
5
  SHA512:
6
- metadata.gz: 8beeab28594d5c8a463fd791876a81d8650384dd9e9442faf8b9e243d98fcc6ab286417caebf7ca7a38a479cfae7eac71a10804dd7763cb9deceec57bb069a8b
7
- data.tar.gz: f8ffaee0ca72868603d51b32d707043fbc7272007b0891a291b6d8ffc97c8ebbd4ab4d91ecac41154b4ce8f4d90de160ad171a4fe5a93f63dd3b646a3bdb3d29
6
+ metadata.gz: 4ef8d0892328e5bbce88f4e783d6173031a26a8bbfd7ad52df2fecb4524b3c666fbe10dfdef967915604f270a9bd6c08179a5c2178353e723267317825e3be9d
7
+ data.tar.gz: e68189a7119431bfc68de5a5b3f7508cf8263858de6cf7ed9e0f5425f2fa2b6a7bb15084c02d4d5e889385d11f0e5b2cf4c6cf08c91ee1642f17ad5a59819ed6
data/Rakefile ADDED
@@ -0,0 +1,17 @@
1
+ require 'rubygems'
2
+ require 'bundler'
3
+ require 'rake'
4
+ require 'rake/testtask'
5
+ require 'rake/packagetask'
6
+ require 'rubygems/package_task'
7
+ require 'gaku/testing/common_rake'
8
+
9
+ Bundler::GemHelper.install_tasks
10
+
11
+ task default: :spec
12
+
13
+ desc 'Generates a dummy app for testing'
14
+ task :test_app do
15
+ ENV['LIB_NAME'] = 'gaku/core'
16
+ Rake::Task['common:test_app'].invoke
17
+ end
File without changes
File without changes
@@ -0,0 +1,3 @@
1
+ class ApplicationRecord < ActiveRecord::Base
2
+ self.abstract_class = true
3
+ end
@@ -1,8 +1,8 @@
1
- module Enrollmentable
1
+ module Enrollable
2
2
  extend ActiveSupport::Concern
3
3
 
4
4
  included do
5
- has_many :enrollments, as: :enrollmentable, dependent: :destroy
5
+ has_many :enrollments, as: :enrollable, dependent: :destroy
6
6
  has_many :students, through: :enrollments
7
7
  end
8
8
 
@@ -4,6 +4,8 @@ module Gradable
4
4
  included do
5
5
  has_many :grading_method_connectors, as: :gradable
6
6
  has_many :grading_methods, through: :grading_method_connectors
7
+
8
+ has_many :exam_portion_scores, as: :gradable
7
9
  end
8
10
 
9
11
  def use_primary_grading_method_set
@@ -1,8 +1,8 @@
1
1
  module Gaku
2
2
  class Address < ActiveRecord::Base
3
- belongs_to :country
4
- belongs_to :state
5
- belongs_to :addressable, polymorphic: true, counter_cache: true
3
+ belongs_to :country, required: false
4
+ belongs_to :state, required: false
5
+ belongs_to :addressable, polymorphic: true, counter_cache: true, required: false
6
6
 
7
7
  scope :students, -> { where(addressable_type: 'Gaku::Student') }
8
8
  scope :teachers, -> { where(addressable_type: 'Gaku::Teacher') }
@@ -1,6 +1,6 @@
1
1
  module Gaku
2
- class Attachment < ActiveRecord::Base
3
- belongs_to :attachable, polymorphic: true
2
+ class Attachment < ApplicationRecord
3
+ belongs_to :attachable, polymorphic: true, required: false
4
4
 
5
5
  has_attached_file :asset
6
6
 
@@ -8,6 +8,8 @@ module Gaku
8
8
 
9
9
  validates :name, presence: true
10
10
  validates :asset, presence: true, on: :create
11
+ do_not_validate_attachment_file_type :asset
12
+ validates_attachment_presence :asset
11
13
 
12
14
  def to_s
13
15
  name
@@ -1,8 +1,8 @@
1
1
  module Gaku
2
2
  class Attendance < ActiveRecord::Base
3
- belongs_to :attendancable, polymorphic: true
4
- belongs_to :student
5
- belongs_to :attendance_type
3
+ belongs_to :attendancable, polymorphic: true, required: false
4
+ belongs_to :student, required: false
5
+ belongs_to :attendance_type, required: false
6
6
 
7
7
  validates :student, :attendance_type, presence: true
8
8
  validates_associated :attendancable, :student, :attendance_type
@@ -1,7 +1,7 @@
1
1
  module Gaku
2
2
  class ClassGroup < ActiveRecord::Base
3
3
 
4
- include Notes, Pagination, Enrollmentable, Semesterable, StudentReviewable
4
+ include Notes, Pagination, Enrollable, Semesterable, StudentReviewable
5
5
 
6
6
  validates :name, presence: true
7
7
 
@@ -1,7 +1,7 @@
1
1
  module Gaku
2
2
  class Contact < ActiveRecord::Base
3
- belongs_to :contact_type
4
- belongs_to :contactable, polymorphic: true, counter_cache: true
3
+ belongs_to :contact_type, required: false
4
+ belongs_to :contactable, polymorphic: true, counter_cache: true, required: false
5
5
 
6
6
  validates :data, :contact_type, presence: true
7
7
 
@@ -1,15 +1,15 @@
1
1
  module Gaku
2
2
  class Course < ActiveRecord::Base
3
3
 
4
- include Notes, Gradable, Enrollmentable, Semesterable
4
+ include Notes, Gradable, Enrollable, Semesterable
5
5
 
6
6
  has_many :course_group_enrollments
7
7
  has_many :course_groups, through: :course_group_enrollments
8
8
 
9
9
  has_many :exam_schedules
10
10
 
11
- belongs_to :syllabus
12
- belongs_to :class_group
11
+ belongs_to :syllabus, required: false
12
+ belongs_to :class_group, required: false
13
13
 
14
14
  delegate :name, :code, to: :syllabus, prefix: true, allow_nil: true
15
15
 
@@ -1,27 +1,27 @@
1
1
  module Gaku
2
2
  class Enrollment < ActiveRecord::Base
3
3
 
4
- belongs_to :student
5
- belongs_to :enrollmentable, polymorphic: true, counter_cache: true
4
+ belongs_to :student, required: false
5
+ belongs_to :enrollable, polymorphic: true, counter_cache: true, required: false
6
6
 
7
- validates :enrollmentable_type, :enrollmentable_id, :student_id, presence: true
7
+ validates :enrollable_type, :enrollable_id, :student_id, presence: true
8
8
 
9
9
  validates :student_id,
10
10
  uniqueness: {
11
- scope: %w( enrollmentable_type enrollmentable_id ),
11
+ scope: %w( enrollable_type enrollable_id ),
12
12
  message: I18n.t(:'student.already_enrolled')
13
13
  }
14
14
 
15
- validates :enrollmentable_type,
15
+ validates :enrollable_type,
16
16
  inclusion: {
17
- in: %w( Gaku::Course Gaku::ClassGroup Gaku::ExtracurricularActivity ),
17
+ in: %w( Gaku::Course Gaku::ClassGroup Gaku::ExtracurricularActivity Gaku::ExamSession ),
18
18
  message: '%{value} is not a valid'
19
19
  }
20
20
 
21
21
  validate :class_group_semesters_overlap, if: ->(record) { record.class_group_type? }
22
22
 
23
- before_create :increment_enrollmentable_counter
24
- before_destroy :decrement_enrollmentable_counter
23
+ before_create :increment_enrollable_counter
24
+ before_destroy :decrement_enrollable_counter
25
25
 
26
26
  before_create :proper_position, if: ->(record) { record.class_group_type? }
27
27
  after_destroy :refresh_positions, if: ->(record) { record.class_group_type? }
@@ -29,7 +29,11 @@ module Gaku
29
29
  scope :seat_numbered, -> { order('seat_number ASC') }
30
30
 
31
31
  def class_group_type?
32
- enrollmentable_type == 'Gaku::ClassGroup'
32
+ enrollable_type == 'Gaku::ClassGroup'
33
+ end
34
+
35
+ def course_type?
36
+ enrollable_type == 'Gaku::Course'
33
37
  end
34
38
 
35
39
  private
@@ -41,44 +45,44 @@ module Gaku
41
45
  end
42
46
 
43
47
  def overlap_semester?
44
- if student && student.semesters && enrollmentable
45
- student.semesters.where(id: enrollmentable.semester_ids).any?
48
+ if student && student.semesters && enrollable
49
+ student.semesters.where(id: enrollable.semester_ids).any?
46
50
  end
47
51
  end
48
52
 
49
53
  def not_in_student_class_groups?
50
- student.class_groups.exclude?(enrollmentable)
54
+ student.class_groups.exclude?(enrollable)
51
55
  end
52
56
 
53
- def increment_enrollmentable_counter
57
+ def increment_enrollable_counter
54
58
  Student.increment_counter(resource_name_counter, student.id) if student
55
59
  end
56
60
 
57
- def decrement_enrollmentable_counter
61
+ def decrement_enrollable_counter
58
62
  Student.decrement_counter(resource_name_counter, student.id) if student
59
63
  end
60
64
 
61
65
  def resource_name_counter
62
- enrollmentable_type.demodulize.underscore.pluralize.concat('_count') if enrollmentable_type
66
+ enrollable_type.demodulize.underscore.pluralize.concat('_count') if enrollable_type
63
67
  end
64
68
 
65
69
  def proper_position
66
- self.seat_number = enrollmentable.enrollments_count.next
70
+ self.seat_number = enrollable.enrollments_count.next
67
71
  end
68
72
 
69
73
  def refresh_positions
70
- enrollments = enrollmentable.enrollments
74
+ enrollments = enrollable.enrollments
71
75
  enrollments.pluck(:id).each_with_index do |id, index|
72
76
  enrollments.where(id: id).update_all(seat_number: index.next)
73
77
  end
74
78
  end
75
79
 
76
80
  def class_group_is_active?
77
- Gaku::ClassGroup.active.include?(enrollmentable)
81
+ Gaku::ClassGroup.active.include?(enrollable)
78
82
  end
79
83
 
80
84
  def not_in_student_class_groups?
81
- student.class_groups.exclude?(enrollmentable)
85
+ student.class_groups.exclude?(enrollable)
82
86
  end
83
87
 
84
88
  end
@@ -13,8 +13,8 @@ module Gaku
13
13
 
14
14
  has_many :exam_sessions
15
15
 
16
- belongs_to :grading_method
17
- belongs_to :department
16
+ belongs_to :grading_method, required: false
17
+ belongs_to :department, required: false
18
18
 
19
19
  validates :name, presence: true
20
20
 
@@ -5,7 +5,7 @@ module Gaku
5
5
  attr_accessor :custom_errors
6
6
 
7
7
  belongs_to :exam, counter_cache: true
8
- belongs_to :grading_method
8
+ belongs_to :grading_method, required: false
9
9
 
10
10
  has_many :exam_schedules
11
11
  has_many :exam_portion_scores
@@ -1,10 +1,14 @@
1
1
  module Gaku
2
2
  class ExamPortionScore < ActiveRecord::Base
3
- belongs_to :student
4
- belongs_to :exam_portion
3
+ belongs_to :student, required: false
4
+ belongs_to :exam_portion, required: false
5
+
6
+ belongs_to :gradable, polymorphic: true, required: false
5
7
 
6
8
  has_many :attendances, as: :attendancable
7
9
 
8
10
  validates :student, :exam_portion, presence: true
11
+
12
+ scope :gradable_scope, ->(gradable) { where(gradable: gradable) }
9
13
  end
10
14
  end
@@ -1,9 +1,9 @@
1
1
  module Gaku
2
2
  class ExamSession < ActiveRecord::Base
3
- belongs_to :exam
4
3
 
5
- has_many :student_exam_sessions
6
- has_many :students, through: :student_exam_sessions
4
+ include Enrollable, Gradable
5
+
6
+ belongs_to :exam
7
7
 
8
8
  validates :exam_id, presence: true
9
9
 
@@ -1,7 +1,7 @@
1
1
  module Gaku
2
2
  class ExtracurricularActivity < ActiveRecord::Base
3
3
 
4
- include Enrollmentable
4
+ include Enrollable
5
5
 
6
6
  validates :name, presence: true, uniqueness: true
7
7
 
@@ -1,14 +1,14 @@
1
1
  module Gaku
2
2
  class GradingMethodConnector < ActiveRecord::Base
3
- belongs_to :grading_method
4
- belongs_to :gradable, polymorphic: true
3
+ belongs_to :grading_method, required: false
4
+ belongs_to :gradable, polymorphic: true, required: false
5
5
 
6
6
  validates :grading_method_id, :gradable_id, :gradable_type, presence: true
7
7
 
8
8
  validates(
9
9
  :gradable_type,
10
10
  inclusion: {
11
- in: %w(Gaku::Exam Gaku::Course),
11
+ in: %w(Gaku::Exam Gaku::Course Gaku::ExamSession),
12
12
  message: '%value is not a valid'
13
13
  }
14
14
  )
@@ -2,7 +2,7 @@ module Gaku
2
2
  class Guardian < ActiveRecord::Base
3
3
  include Person, Addresses, Contacts, Picture
4
4
 
5
- belongs_to :user
5
+ belongs_to :user, required: false
6
6
  has_many :student_guardians, dependent: :destroy
7
7
  has_many :students, through: :student_guardians
8
8
 
@@ -4,7 +4,7 @@ module Gaku
4
4
 
5
5
  has_many :lessons
6
6
  has_many :attachments, as: :attachable
7
- belongs_to :syllabus
7
+ belongs_to :syllabus, required: false
8
8
 
9
9
  validates :syllabus, presence: true
10
10
  end
@@ -1,6 +1,6 @@
1
1
  module Gaku
2
2
  class Note < ActiveRecord::Base
3
- belongs_to :notable, polymorphic: true, counter_cache: true
3
+ belongs_to :notable, polymorphic: true, counter_cache: true, required: false
4
4
 
5
5
  validates :title, :content, presence: true
6
6
  end
@@ -1,7 +1,7 @@
1
1
  module Gaku
2
2
  class ProgramSpecialty < ActiveRecord::Base
3
- belongs_to :program
4
- belongs_to :specialty
3
+ belongs_to :program, required: false
4
+ belongs_to :specialty, required: false
5
5
 
6
6
  validates :specialty, presence: true
7
7
  end
@@ -1,6 +1,6 @@
1
1
  module Gaku
2
2
  class SchoolRole < ActiveRecord::Base
3
- belongs_to :school_rolable, polymorphic: true
3
+ belongs_to :school_rolable, polymorphic: true, required: false
4
4
 
5
5
  validates :name, presence: true, uniqueness: true
6
6
 
@@ -9,7 +9,7 @@ module Gaku
9
9
 
10
10
  has_many :semester_attendances
11
11
 
12
- belongs_to :school_year
12
+ belongs_to :school_year, required: false
13
13
 
14
14
  validates :starting, :ending, presence: true
15
15
 
@@ -1,8 +1,8 @@
1
1
  module Gaku
2
2
  class SemesterConnector < ActiveRecord::Base
3
3
 
4
- belongs_to :semester
5
- belongs_to :semesterable, polymorphic: true
4
+ belongs_to :semester, required: false
5
+ belongs_to :semesterable, polymorphic: true, required: false
6
6
 
7
7
  validates :semester_id, :semesterable_type, :semesterable_id, presence: true
8
8
 
@@ -6,7 +6,7 @@ module Gaku
6
6
  has_many :program_specialties
7
7
  has_many :programs, through: :program_specialties
8
8
 
9
- belongs_to :department
9
+ belongs_to :department, required: false
10
10
 
11
11
  validates :name, presence: true, uniqueness: true
12
12
 
@@ -1,27 +1,25 @@
1
1
  module Gaku
2
- class Student < ActiveRecord::Base
2
+ class Student < ApplicationRecord
3
3
  include Person, Addresses, Contacts, Notes, Picture, Pagination
4
4
 
5
5
  has_many :enrollments, dependent: :destroy
6
6
 
7
7
  has_many :course_enrollments,
8
- -> { where(enrollmentable_type: 'Gaku::Course') }, class_name: 'Gaku::Enrollment'
8
+ -> { where(enrollable_type: 'Gaku::Course') }, class_name: 'Gaku::Enrollment'
9
9
  has_many :class_group_enrollments,
10
- -> { where(enrollmentable_type: 'Gaku::ClassGroup') }, class_name: 'Gaku::Enrollment'
10
+ -> { where(enrollable_type: 'Gaku::ClassGroup') }, class_name: 'Gaku::Enrollment'
11
11
  has_many :extracurricular_activity_enrollments,
12
- -> { where(enrollmentable_type: 'Gaku::ExtracurricularActivity') }, class_name: 'Gaku::Enrollment'
12
+ -> { where(enrollable_type: 'Gaku::ExtracurricularActivity') }, class_name: 'Gaku::Enrollment'
13
13
 
14
- with_options through: :enrollments, source: :enrollmentable do |assoc|
14
+ with_options through: :enrollments, source: :enrollable do |assoc|
15
15
  assoc.has_many :courses, source_type: 'Gaku::Course'
16
16
  assoc.has_many :class_groups, source_type: 'Gaku::ClassGroup'
17
17
  assoc.has_many :extracurricular_activities, source_type: 'Gaku::ExtracurricularActivity'
18
+ assoc.has_many :exam_sessions, source_type: 'Gaku::ExamSession'
18
19
  end
19
20
 
20
21
  has_many :semesters, through: :class_groups
21
22
 
22
- has_many :student_exam_sessions
23
- has_many :exam_sessions, through: :student_exam_sessions
24
-
25
23
  has_many :student_specialties
26
24
  has_many :specialties, through: :student_specialties
27
25
  has_one :major_specialty, -> { where('gaku_student_specialties.major = ?', true) }
@@ -41,10 +39,10 @@ module Gaku
41
39
 
42
40
  has_many :student_reviews
43
41
 
44
- belongs_to :user
45
- belongs_to :commute_method_type
46
- belongs_to :scholarship_status
47
- belongs_to :enrollment_status, foreign_key: :enrollment_status_code, primary_key: :code
42
+ belongs_to :user, required: false
43
+ belongs_to :commute_method_type, required: false
44
+ belongs_to :scholarship_status, required: false
45
+ belongs_to :enrollment_status, foreign_key: :enrollment_status_code, primary_key: :code, required: false
48
46
 
49
47
  accepts_nested_attributes_for :guardians, allow_destroy: true
50
48