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.
- checksums.yaml +4 -4
- data/Rakefile +17 -0
- data/app/assets/images/elements/toolbar1.png +0 -0
- data/app/assets/images/icon-chair.png +0 -0
- data/app/models/application_record.rb +3 -0
- data/app/models/concerns/{enrollmentable.rb → enrollable.rb} +2 -2
- data/app/models/concerns/gradable.rb +2 -0
- data/app/models/gaku/address.rb +3 -3
- data/app/models/gaku/attachment.rb +4 -2
- data/app/models/gaku/attendance.rb +3 -3
- data/app/models/gaku/class_group.rb +1 -1
- data/app/models/gaku/contact.rb +2 -2
- data/app/models/gaku/course.rb +3 -3
- data/app/models/gaku/enrollment.rb +23 -19
- data/app/models/gaku/exam.rb +2 -2
- data/app/models/gaku/exam_portion.rb +1 -1
- data/app/models/gaku/exam_portion_score.rb +6 -2
- data/app/models/gaku/exam_session.rb +3 -3
- data/app/models/gaku/extracurricular_activity.rb +1 -1
- data/app/models/gaku/grading_method_connector.rb +3 -3
- data/app/models/gaku/guardian.rb +1 -1
- data/app/models/gaku/lesson_plan.rb +1 -1
- data/app/models/gaku/note.rb +1 -1
- data/app/models/gaku/program_specialty.rb +2 -2
- data/app/models/gaku/school_role.rb +1 -1
- data/app/models/gaku/semester.rb +1 -1
- data/app/models/gaku/semester_connector.rb +2 -2
- data/app/models/gaku/specialty.rb +1 -1
- data/app/models/gaku/student.rb +10 -12
- data/app/models/gaku/student_review.rb +3 -3
- data/app/models/gaku/student_specialty.rb +2 -2
- data/app/models/gaku/syllabus.rb +1 -1
- data/app/models/gaku/teacher.rb +1 -1
- data/config/initializers/redis.rb +6 -2
- data/db/default/gaku/attendance_types.rb +1 -1
- data/db/migrate/20120202111850_presets.rb +3 -4
- data/db/migrate/20131014065028_translations.rb +1 -1
- data/db/migrate/20131025073352_gaku_core.rb +1 -1
- data/db/migrate/20140128141752_change_grading_methods_arguments_field.rb +1 -1
- data/db/migrate/20140130182100_change_fields_external_school_record.rb +1 -1
- data/db/migrate/20140131113337_create_student_configs.rb +1 -1
- data/db/migrate/20140207093618_drop_student_configs.rb +1 -1
- data/db/migrate/20140213113405_create_grading_method_connectors_table.rb +1 -1
- data/db/migrate/20140304094422_create_gaku_exam_sessions_table.rb +1 -1
- data/db/migrate/20140325073941_add_time_format_24_to_presets_table.rb +1 -1
- data/db/migrate/20140408111314_remove_semester_join_tables.rb +1 -1
- data/db/migrate/20140408111358_create_semester_connectors_table.rb +1 -1
- data/db/migrate/20140423093155_create_enrollments_table.rb +1 -1
- data/db/migrate/20140423100114_clean_enrollments_join_models.rb +1 -1
- data/db/migrate/20140429112725_add_counters_to_enrollmentable.rb +3 -1
- data/db/migrate/20140604104210_rename_method_to_grading_method.rb +1 -1
- data/db/migrate/20140604113045_add_default_value_to_curved.rb +1 -1
- data/db/migrate/20140610091053_add_seat_number_to_enrollments.rb +1 -1
- data/db/migrate/20140701104700_change_hstore_to_string_criteria.rb +1 -1
- data/db/migrate/20140715135152_create_semester_attendance_table.rb +1 -1
- data/db/migrate/20140718105226_create_student_review_categories_table.rb +1 -1
- data/db/migrate/20140728121353_create_student_review_table.rb +1 -1
- data/db/migrate/20150213095508_improve_countries_and_states.rb +1 -1
- data/db/migrate/20160125194100_add_gradable_to_exam_portion_score.rb +5 -0
- data/db/migrate/20170509132020_change_enrollmentable_to_enrollable.rb +6 -0
- data/gaku_core.gemspec +37 -0
- data/lib/gaku/core.rb +1 -1
- data/lib/gaku/core/engine.rb +1 -1
- data/lib/gaku/grading/collection/base_method.rb +3 -2
- data/lib/gaku/grading/collection/calculations.rb +5 -3
- data/lib/gaku/grading/collection/interval.rb +2 -2
- data/lib/gaku/grading/collection/ordinal.rb +1 -1
- data/lib/gaku/grading/collection/percentage.rb +1 -1
- data/lib/gaku/grading/collection/score.rb +1 -1
- data/lib/gaku/grading/single/base_method.rb +3 -2
- data/lib/gaku/grading/single/calculations.rb +5 -4
- data/lib/gaku/grading/single/ordinal.rb +2 -3
- data/lib/gaku/grading/single/percentage.rb +2 -3
- data/lib/gaku/grading/single/score.rb +2 -3
- data/lib/gaku/testing/common_rake.rb +47 -6
- data/lib/gaku/testing/controller_helpers.rb +6 -4
- data/lib/gaku/testing/factories/address_factory.rb +3 -3
- data/lib/gaku/testing/factories/campus_factory.rb +1 -1
- data/lib/gaku/testing/factories/enrollment_factory.rb +1 -1
- data/lib/gaku/testing/factories/guardian_factory.rb +2 -2
- data/lib/gaku/testing/factories/program_factory.rb +1 -1
- data/lib/gaku/testing/factories/school_factory.rb +1 -1
- data/lib/gaku/testing/factories/student_factory.rb +7 -5
- data/lib/gaku/testing/factories/syllabus_factory.rb +1 -1
- data/lib/gaku/testing/factories/teacher_factory.rb +4 -4
- data/lib/gaku/testing/factories/user_factory.rb +2 -2
- data/lib/generators/gaku/docker/docker_generator.rb +58 -0
- data/lib/generators/gaku/docker/templates/app/assets/javascripts/gaku/admin/all.js +10 -0
- data/lib/generators/gaku/docker/templates/app/assets/javascripts/gaku/archive/all.js +10 -0
- data/lib/generators/gaku/docker/templates/app/assets/javascripts/gaku/frontend/all.js +10 -0
- data/lib/generators/gaku/docker/templates/app/assets/stylesheets/gaku/admin/all.css +9 -0
- data/lib/generators/gaku/docker/templates/app/assets/stylesheets/gaku/archive/all.css +9 -0
- data/lib/generators/gaku/docker/templates/app/assets/stylesheets/gaku/frontend/all.css +9 -0
- data/lib/generators/gaku/docker/templates/bin/check_postgres.sh +16 -0
- data/lib/generators/gaku/docker/templates/config/database.yml +2 -0
- data/lib/generators/gaku/dummy/dummy_generator.rb +0 -1
- data/lib/generators/gaku/dummy/templates/rails/application.rb +0 -1
- data/lib/generators/gaku/dummy/templates/rails/database.yml +11 -10
- data/lib/generators/gaku/install/install_generator.rb +17 -0
- data/lib/generators/gaku/install/templates/Procfile +3 -0
- data/lib/generators/gaku/install/templates/lib/grading/README.md +2 -0
- data/lib/generators/gaku/install/templates/lib/grading/bin/gaku_grading.coffee +13 -0
- data/lib/generators/gaku/install/templates/lib/grading/package.json +19 -0
- data/lib/tasks/core.rake +1 -1
- data/lib/tasks/grading.rake +10 -0
- metadata +69 -53
- data/db/migrate/20140304101025_create_gaku_student_exam_session_table.rb +0 -8
- 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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a76c61f9769e8432f306125839305e169d1cb7ea
|
4
|
+
data.tar.gz: 6d7eff5c17d2c61af2a28989be672ad19b25d9e7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
@@ -1,8 +1,8 @@
|
|
1
|
-
module
|
1
|
+
module Enrollable
|
2
2
|
extend ActiveSupport::Concern
|
3
3
|
|
4
4
|
included do
|
5
|
-
has_many :enrollments, as: :
|
5
|
+
has_many :enrollments, as: :enrollable, dependent: :destroy
|
6
6
|
has_many :students, through: :enrollments
|
7
7
|
end
|
8
8
|
|
data/app/models/gaku/address.rb
CHANGED
@@ -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 <
|
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
|
data/app/models/gaku/contact.rb
CHANGED
@@ -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
|
|
data/app/models/gaku/course.rb
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
module Gaku
|
2
2
|
class Course < ActiveRecord::Base
|
3
3
|
|
4
|
-
include Notes, Gradable,
|
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 :
|
4
|
+
belongs_to :student, required: false
|
5
|
+
belongs_to :enrollable, polymorphic: true, counter_cache: true, required: false
|
6
6
|
|
7
|
-
validates :
|
7
|
+
validates :enrollable_type, :enrollable_id, :student_id, presence: true
|
8
8
|
|
9
9
|
validates :student_id,
|
10
10
|
uniqueness: {
|
11
|
-
scope: %w(
|
11
|
+
scope: %w( enrollable_type enrollable_id ),
|
12
12
|
message: I18n.t(:'student.already_enrolled')
|
13
13
|
}
|
14
14
|
|
15
|
-
validates :
|
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 :
|
24
|
-
before_destroy :
|
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
|
-
|
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 &&
|
45
|
-
student.semesters.where(id:
|
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?(
|
54
|
+
student.class_groups.exclude?(enrollable)
|
51
55
|
end
|
52
56
|
|
53
|
-
def
|
57
|
+
def increment_enrollable_counter
|
54
58
|
Student.increment_counter(resource_name_counter, student.id) if student
|
55
59
|
end
|
56
60
|
|
57
|
-
def
|
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
|
-
|
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 =
|
70
|
+
self.seat_number = enrollable.enrollments_count.next
|
67
71
|
end
|
68
72
|
|
69
73
|
def refresh_positions
|
70
|
-
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?(
|
81
|
+
Gaku::ClassGroup.active.include?(enrollable)
|
78
82
|
end
|
79
83
|
|
80
84
|
def not_in_student_class_groups?
|
81
|
-
student.class_groups.exclude?(
|
85
|
+
student.class_groups.exclude?(enrollable)
|
82
86
|
end
|
83
87
|
|
84
88
|
end
|
data/app/models/gaku/exam.rb
CHANGED
@@ -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,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
|
)
|
data/app/models/gaku/guardian.rb
CHANGED
data/app/models/gaku/note.rb
CHANGED
data/app/models/gaku/semester.rb
CHANGED
@@ -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
|
|
data/app/models/gaku/student.rb
CHANGED
@@ -1,27 +1,25 @@
|
|
1
1
|
module Gaku
|
2
|
-
class Student <
|
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(
|
8
|
+
-> { where(enrollable_type: 'Gaku::Course') }, class_name: 'Gaku::Enrollment'
|
9
9
|
has_many :class_group_enrollments,
|
10
|
-
-> { where(
|
10
|
+
-> { where(enrollable_type: 'Gaku::ClassGroup') }, class_name: 'Gaku::Enrollment'
|
11
11
|
has_many :extracurricular_activity_enrollments,
|
12
|
-
-> { where(
|
12
|
+
-> { where(enrollable_type: 'Gaku::ExtracurricularActivity') }, class_name: 'Gaku::Enrollment'
|
13
13
|
|
14
|
-
with_options through: :enrollments, source: :
|
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
|
|