gaku_core 0.1.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/gaku/core_controller.rb +3 -8
- data/app/decorators/gaku/course_decorator.rb +1 -2
- data/app/decorators/gaku/guardian_decorator.rb +1 -1
- data/app/decorators/gaku/person_decorator.rb +8 -12
- data/app/decorators/gaku/student_decorator.rb +0 -2
- data/app/decorators/gaku/teacher_decorator.rb +1 -1
- data/app/models/concerns/addresses.rb +6 -6
- data/app/models/concerns/contacts.rb +6 -6
- data/app/models/concerns/enrollmentable.rb +9 -0
- data/app/models/concerns/gradable.rb +14 -0
- data/app/models/concerns/notes.rb +1 -2
- data/app/models/concerns/pagination.rb +1 -2
- data/app/models/concerns/person.rb +0 -2
- data/app/models/concerns/picture.rb +1 -3
- data/app/models/concerns/semesterable.rb +12 -0
- data/app/models/concerns/student_reviewable.rb +7 -0
- data/app/models/gaku/ability.rb +2 -4
- data/app/models/gaku/address.rb +11 -10
- data/app/models/gaku/admin_ability.rb +0 -1
- data/app/models/gaku/assignment.rb +0 -2
- data/app/models/gaku/assignment_score.rb +0 -1
- data/app/models/gaku/attachment.rb +1 -4
- data/app/models/gaku/attendance.rb +0 -2
- data/app/models/gaku/attendance_type.rb +0 -2
- data/app/models/gaku/badge.rb +0 -2
- data/app/models/gaku/badge_type.rb +0 -1
- data/app/models/gaku/class_group.rb +13 -13
- data/app/models/gaku/commute_method_type.rb +0 -2
- data/app/models/gaku/contact.rb +6 -36
- data/app/models/gaku/contact_type.rb +0 -2
- data/app/models/gaku/country.rb +0 -3
- data/app/models/gaku/course.rb +11 -25
- data/app/models/gaku/course_group.rb +0 -2
- data/app/models/gaku/course_group_enrollment.rb +3 -4
- data/app/models/gaku/department.rb +0 -2
- data/app/models/gaku/enrollment.rb +85 -0
- data/app/models/gaku/enrollment_status.rb +0 -2
- data/app/models/gaku/exam.rb +17 -22
- data/app/models/gaku/exam_portion.rb +2 -6
- data/app/models/gaku/exam_portion_score.rb +0 -2
- data/app/models/gaku/exam_schedule.rb +0 -1
- data/app/models/gaku/exam_session.rb +14 -0
- data/app/models/gaku/exam_syllabus.rb +2 -6
- data/app/models/gaku/external_school_record.rb +1 -9
- data/app/models/gaku/extracurricular_activity.rb +1 -2
- data/app/models/gaku/faculty.rb +0 -2
- data/app/models/gaku/grading_method.rb +14 -2
- data/app/models/gaku/grading_method_connector.rb +35 -0
- data/app/models/gaku/grading_method_set.rb +6 -4
- data/app/models/gaku/grading_method_set_item.rb +4 -5
- data/app/models/gaku/guardian.rb +1 -3
- data/app/models/gaku/install.rb +0 -2
- data/app/models/gaku/lesson.rb +0 -1
- data/app/models/gaku/lesson_plan.rb +0 -2
- data/app/models/gaku/level.rb +0 -2
- data/app/models/gaku/preset.rb +18 -18
- data/app/models/gaku/program.rb +0 -2
- data/app/models/gaku/program_level.rb +0 -2
- data/app/models/gaku/program_specialty.rb +0 -2
- data/app/models/gaku/program_syllabus.rb +0 -2
- data/app/models/gaku/role.rb +0 -2
- data/app/models/gaku/schedule.rb +0 -1
- data/app/models/gaku/scholarship_status.rb +0 -2
- data/app/models/gaku/school.rb +0 -2
- data/app/models/gaku/school_role.rb +0 -2
- data/app/models/gaku/school_year.rb +4 -2
- data/app/models/gaku/semester.rb +21 -6
- data/app/models/gaku/semester_attendance.rb +14 -0
- data/app/models/gaku/semester_connector.rb +27 -0
- data/app/models/gaku/simple_grade.rb +0 -2
- data/app/models/gaku/simple_grade_type.rb +0 -1
- data/app/models/gaku/specialty.rb +0 -2
- data/app/models/gaku/state.rb +0 -3
- data/app/models/gaku/student.rb +47 -45
- data/app/models/gaku/student_exam_session.rb +11 -0
- data/app/models/gaku/student_guardian.rb +0 -2
- data/app/models/gaku/student_review.rb +11 -0
- data/app/models/gaku/student_review_category.rb +13 -0
- data/app/models/gaku/student_specialty.rb +2 -5
- data/app/models/gaku/syllabus.rb +0 -4
- data/app/models/gaku/teacher.rb +0 -2
- data/app/models/gaku/template.rb +7 -9
- data/app/models/gaku/user.rb +10 -22
- data/app/models/gaku/user_role.rb +0 -2
- data/app/services/gaku/contact_creation.rb +49 -0
- data/app/services/gaku/contact_updation.rb +41 -0
- data/app/services/gaku/student_selection.rb +57 -0
- data/app/services/gaku/user_creator.rb +31 -0
- data/config/initializers/devise.rb +1 -1
- data/config/initializers/redis.rb +5 -0
- data/config/locales/en.yml +79 -15
- data/config/routes.rb +5 -10
- data/db/default/gaku/attendance_types.rb +14 -16
- data/db/default/gaku/commute_method_types.rb +2 -4
- data/db/default/gaku/enrollment_status.rb +3 -3
- data/db/default/gaku/master_school.rb +7 -6
- data/db/default/gaku/presets.rb +6 -9
- data/db/default/gaku/scholarship_statuses.rb +1 -1
- data/db/migrate/20140128141752_change_grading_methods_arguments_field.rb +5 -0
- data/db/migrate/20140213113405_create_grading_method_connectors_table.rb +9 -0
- data/db/migrate/20140304094422_create_gaku_exam_sessions_table.rb +10 -0
- data/db/migrate/20140304101025_create_gaku_student_exam_session_table.rb +8 -0
- data/db/migrate/20140325073941_add_time_format_24_to_presets_table.rb +5 -0
- data/db/migrate/20140408111314_remove_semester_join_tables.rb +6 -0
- data/db/migrate/20140408111358_create_semester_connectors_table.rb +8 -0
- data/db/migrate/20140423093155_create_enrollments_table.rb +11 -0
- data/db/migrate/20140423100114_clean_enrollments_join_models.rb +8 -0
- data/db/migrate/20140429112725_add_counters_to_enrollmentable.rb +11 -0
- data/db/migrate/20140604104210_rename_method_to_grading_method.rb +5 -0
- data/db/migrate/20140604113045_add_default_value_to_curved.rb +5 -0
- data/db/migrate/20140610091053_add_seat_number_to_enrollments.rb +5 -0
- data/db/migrate/20140701104700_change_hstore_to_string_criteria.rb +5 -0
- data/db/migrate/20140715135152_create_semester_attendance_table.rb +16 -0
- data/db/migrate/20140718105226_create_student_review_categories_table.rb +13 -0
- data/db/migrate/20140728121353_create_student_review_table.rb +12 -0
- data/db/seeds.rb +1 -1
- data/lib/gaku/core.rb +2 -1
- data/lib/gaku/core/engine.rb +7 -5
- data/lib/gaku/core/url_helpers.rb +1 -1
- data/lib/gaku/grading/collection/base_method.rb +30 -0
- data/lib/gaku/grading/collection/calculations.rb +36 -0
- data/lib/gaku/grading/collection/interval.rb +55 -0
- data/lib/gaku/grading/collection/ordinal.rb +10 -0
- data/lib/gaku/grading/collection/percentage.rb +10 -0
- data/lib/gaku/grading/collection/result.rb +18 -0
- data/lib/gaku/grading/collection/score.rb +10 -0
- data/lib/gaku/grading/single/base_method.rb +30 -0
- data/lib/gaku/grading/single/calculations.rb +42 -0
- data/lib/gaku/grading/single/interval.rb +7 -0
- data/lib/gaku/grading/single/ordinal.rb +30 -0
- data/lib/gaku/grading/single/pass_fail.rb +2 -0
- data/lib/gaku/grading/single/percentage.rb +26 -0
- data/lib/gaku/grading/single/ratio.rb +2 -0
- data/lib/gaku/grading/single/result.rb +18 -0
- data/lib/gaku/grading/single/score.rb +15 -0
- data/lib/gaku/migrations.rb +1 -1
- data/lib/gaku/streamer/sse.rb +5 -5
- data/lib/gaku/testing/auth_helpers.rb +6 -2
- data/lib/gaku/testing/common_rake.rb +9 -3
- data/lib/gaku/testing/controller_helpers.rb +17 -12
- data/lib/gaku/testing/coverage.rb +1 -1
- data/lib/gaku/testing/deferred_garbage_collection.rb +3 -3
- data/lib/gaku/testing/factories/attachment_factory.rb +0 -1
- data/lib/gaku/testing/factories/attendance_type_factory.rb +1 -1
- data/lib/gaku/testing/factories/class_group_factory.rb +12 -1
- data/lib/gaku/testing/factories/contact_creation_factory.rb +18 -0
- data/lib/gaku/testing/factories/course_enrollment_factory.rb +9 -9
- data/lib/gaku/testing/factories/course_factory.rb +2 -4
- data/lib/gaku/testing/factories/course_group_factory.rb +2 -4
- data/lib/gaku/testing/factories/enrollment_factory.rb +10 -0
- data/lib/gaku/testing/factories/exam_factory.rb +1 -1
- data/lib/gaku/testing/factories/exam_portion_factory.rb +2 -4
- data/lib/gaku/testing/factories/exam_score_factory.rb +1 -1
- data/lib/gaku/testing/factories/exam_session_factory.rb +14 -0
- data/lib/gaku/testing/factories/extracurricular_activity_factory.rb +1 -1
- data/lib/gaku/testing/factories/grading_method_connector_factory.rb +11 -0
- data/lib/gaku/testing/factories/grading_method_factory.rb +3 -2
- data/lib/gaku/testing/factories/guardian_factory.rb +2 -4
- data/lib/gaku/testing/factories/lesson_plan_factory.rb +2 -2
- data/lib/gaku/testing/factories/preset_factory.rb +7 -7
- data/lib/gaku/testing/factories/program_factory.rb +0 -1
- data/lib/gaku/testing/factories/school_factory.rb +3 -3
- data/lib/gaku/testing/factories/semester_attendance_factory.rb +8 -0
- data/lib/gaku/testing/factories/semester_connectors_factory.rb +11 -0
- data/lib/gaku/testing/factories/semester_factory.rb +16 -0
- data/lib/gaku/testing/factories/simple_grade_type_factory.rb +1 -1
- data/lib/gaku/testing/factories/state_factory.rb +2 -1
- data/lib/gaku/testing/factories/student_exam_session_factory.rb +8 -0
- data/lib/gaku/testing/factories/student_factory.rb +15 -5
- data/lib/gaku/testing/factories/student_review_category_factory.rb +7 -0
- data/lib/gaku/testing/factories/student_review_factory.rb +13 -0
- data/lib/gaku/testing/factories/teacher_factory.rb +1 -1
- data/lib/gaku/testing/factories/template_factory.rb +5 -7
- data/lib/gaku/testing/factories/traits.rb +32 -4
- data/lib/gaku/testing/factories/user_factory.rb +0 -1
- data/lib/gaku_core.rb +1 -1
- data/lib/generators/gaku/dummy/dummy_generator.rb +5 -4
- data/lib/generators/gaku/install/install_generator.rb +16 -14
- data/lib/tasks/admin_user.rake +2 -1
- metadata +310 -264
- data/app/models/gaku/class_group_course_enrollment.rb +0 -17
- data/app/models/gaku/class_group_enrollment.rb +0 -31
- data/app/models/gaku/course_enrollment.rb +0 -23
- data/app/models/gaku/disposal.rb +0 -45
- data/app/models/gaku/extracurricular_activity_enrollment.rb +0 -15
- data/app/models/gaku/semester_class_group.rb +0 -21
- data/app/models/gaku/semester_course.rb +0 -21
- data/lib/gaku/grading/calculations.rb +0 -279
- data/lib/gaku/grading/grade.rb +0 -17
- data/lib/gaku/grading/japanese_hs_standard.rb +0 -8
- data/lib/gaku/testing/factories/class_group_course_enrollment_factory.rb +0 -8
- data/lib/gaku/testing/factories/class_group_enrollment_factory.rb +0 -9
- data/lib/gaku/testing/factories/semester_class_group_factory.rb +0 -8
- data/lib/gaku/testing/factories/semester_course.rb +0 -8
@@ -1,17 +0,0 @@
|
|
1
|
-
module Gaku
|
2
|
-
class ClassGroupCourseEnrollment < ActiveRecord::Base
|
3
|
-
|
4
|
-
belongs_to :class_group
|
5
|
-
belongs_to :course
|
6
|
-
|
7
|
-
validates :class_group_id, presence: true
|
8
|
-
|
9
|
-
validates :course_id,
|
10
|
-
presence: true,
|
11
|
-
uniqueness: {
|
12
|
-
scope: :class_group_id,
|
13
|
-
message: I18n.t(:'class_group.already_enrolled')
|
14
|
-
}
|
15
|
-
|
16
|
-
end
|
17
|
-
end
|
@@ -1,31 +0,0 @@
|
|
1
|
-
module Gaku
|
2
|
-
class ClassGroupEnrollment < ActiveRecord::Base
|
3
|
-
|
4
|
-
belongs_to :class_group
|
5
|
-
belongs_to :student
|
6
|
-
has_many :school_roles, as: :school_rolable
|
7
|
-
|
8
|
-
validates :class_group, presence: true
|
9
|
-
|
10
|
-
validates :student,
|
11
|
-
presence: true,
|
12
|
-
uniqueness: {
|
13
|
-
scope: :class_group_id,
|
14
|
-
message: I18n.t(:'class_group.already_enrolled')
|
15
|
-
}
|
16
|
-
|
17
|
-
after_save :save_student_class_and_number
|
18
|
-
|
19
|
-
def class_and_number
|
20
|
-
"#{class_group} - ##{seat_number}"
|
21
|
-
end
|
22
|
-
|
23
|
-
private
|
24
|
-
|
25
|
-
def save_student_class_and_number
|
26
|
-
student.update_attribute(:class_and_number, class_and_number) if student
|
27
|
-
end
|
28
|
-
|
29
|
-
|
30
|
-
end
|
31
|
-
end
|
@@ -1,23 +0,0 @@
|
|
1
|
-
module Gaku
|
2
|
-
class CourseEnrollment < ActiveRecord::Base
|
3
|
-
|
4
|
-
belongs_to :student, counter_cache: :courses_count
|
5
|
-
belongs_to :course, counter_cache: :students_count
|
6
|
-
|
7
|
-
validates :course_id, presence: true
|
8
|
-
|
9
|
-
validates :student_id,
|
10
|
-
presence: true,
|
11
|
-
uniqueness: {
|
12
|
-
scope: :course_id,
|
13
|
-
message: I18n.t(:'course.already_enrolled')
|
14
|
-
}
|
15
|
-
def code_with_syllabus_name
|
16
|
-
course.decorate.code_with_syllabus_name if course
|
17
|
-
end
|
18
|
-
|
19
|
-
def course_id
|
20
|
-
course.id if course
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
data/app/models/gaku/disposal.rb
DELETED
@@ -1,45 +0,0 @@
|
|
1
|
-
module Gaku
|
2
|
-
class Disposal
|
3
|
-
|
4
|
-
def self.students
|
5
|
-
Student.deleted
|
6
|
-
end
|
7
|
-
|
8
|
-
def self.teachers
|
9
|
-
Teacher.deleted
|
10
|
-
end
|
11
|
-
|
12
|
-
def self.guardians
|
13
|
-
Guardian.deleted
|
14
|
-
end
|
15
|
-
|
16
|
-
def self.exams
|
17
|
-
Exam.deleted
|
18
|
-
end
|
19
|
-
|
20
|
-
def self.course_groups
|
21
|
-
CourseGroup.deleted
|
22
|
-
end
|
23
|
-
|
24
|
-
def self.attachments
|
25
|
-
Attachment.includes(:attachable).deleted
|
26
|
-
end
|
27
|
-
|
28
|
-
def self.student_addresses
|
29
|
-
Address.includes(:addressable, :country).deleted.students
|
30
|
-
end
|
31
|
-
|
32
|
-
def self.teacher_addresses
|
33
|
-
Address.includes(:addressable, :country).deleted.teachers
|
34
|
-
end
|
35
|
-
|
36
|
-
def self.student_contacts
|
37
|
-
Contact.includes(:contactable, :contact_type).deleted.students
|
38
|
-
end
|
39
|
-
|
40
|
-
def self.teacher_contacts
|
41
|
-
Contact.includes(:contactable, :contact_type).deleted.teachers
|
42
|
-
end
|
43
|
-
|
44
|
-
end
|
45
|
-
end
|
@@ -1,15 +0,0 @@
|
|
1
|
-
module Gaku
|
2
|
-
class ExtracurricularActivityEnrollment < ActiveRecord::Base
|
3
|
-
belongs_to :extracurricular_activity
|
4
|
-
belongs_to :student
|
5
|
-
has_many :school_roles, as: :school_rolable
|
6
|
-
|
7
|
-
validates :student_id,
|
8
|
-
presence: true,
|
9
|
-
uniqueness: {
|
10
|
-
scope: :extracurricular_activity_id,
|
11
|
-
message: I18n.t(:'extracurricular_activity.already_enrolled')
|
12
|
-
}
|
13
|
-
validates :extracurricular_activity_id, presence: true
|
14
|
-
end
|
15
|
-
end
|
@@ -1,21 +0,0 @@
|
|
1
|
-
module Gaku
|
2
|
-
class SemesterClassGroup < ActiveRecord::Base
|
3
|
-
|
4
|
-
belongs_to :semester
|
5
|
-
belongs_to :class_group
|
6
|
-
|
7
|
-
validates :class_group_id, presence: true
|
8
|
-
|
9
|
-
validates :semester_id,
|
10
|
-
presence: true,
|
11
|
-
uniqueness: {
|
12
|
-
scope: :class_group_id,
|
13
|
-
message: I18n.t(:'semester_class_group.uniqueness')
|
14
|
-
}
|
15
|
-
|
16
|
-
def self.group_by_semester
|
17
|
-
all.includes([:semester, :class_group]).group_by(&:semester_id)
|
18
|
-
end
|
19
|
-
|
20
|
-
end
|
21
|
-
end
|
@@ -1,21 +0,0 @@
|
|
1
|
-
module Gaku
|
2
|
-
class SemesterCourse < ActiveRecord::Base
|
3
|
-
|
4
|
-
belongs_to :semester
|
5
|
-
belongs_to :course
|
6
|
-
|
7
|
-
validates :course_id, presence: true
|
8
|
-
|
9
|
-
validates :semester_id,
|
10
|
-
presence: true,
|
11
|
-
uniqueness: {
|
12
|
-
scope: :course_id,
|
13
|
-
message: I18n.t(:'semester_course.uniqueness')
|
14
|
-
}
|
15
|
-
|
16
|
-
def self.group_by_semester
|
17
|
-
all.includes([:semester, :course]).group_by(&:semester_id)
|
18
|
-
end
|
19
|
-
|
20
|
-
end
|
21
|
-
end
|
@@ -1,279 +0,0 @@
|
|
1
|
-
module Gaku::Grading::Calculations
|
2
|
-
|
3
|
-
def self.included(base)
|
4
|
-
base.send(:include, InstanceMethods)
|
5
|
-
end
|
6
|
-
|
7
|
-
module InstanceMethods
|
8
|
-
def calculate_totals
|
9
|
-
@student_total_scores = Hash.new { |hash,key| hash[key] = {} }
|
10
|
-
@student_total_weights = Hash.new { |hash,key| hash[key] = {} }
|
11
|
-
@completion = Hash.new { |hash,key| hash[key] = {} }
|
12
|
-
@exam_averages = Hash.new []
|
13
|
-
@exam_weight_averages = Hash.new []
|
14
|
-
@weighting_score = true
|
15
|
-
@student_portion_attendance = Hash.new { |hash,key| hash[key] = {} }
|
16
|
-
@students.each do |student|
|
17
|
-
@exams.each do |exam|
|
18
|
-
caluculate_completion(exam)
|
19
|
-
@student_total_scores[student.id][exam.id] = 0.0
|
20
|
-
@student_total_weights[student.id][exam.id] = 0.0
|
21
|
-
exam.exam_portions.each do |portion|
|
22
|
-
if have_portion_score?(student, portion)
|
23
|
-
add_to_student_total_score(student, exam, portion)
|
24
|
-
add_to_student_total_weight(student,exam, portion) if exam.use_weighting
|
25
|
-
add_to_portion_attendance(student, exam, portion)
|
26
|
-
else
|
27
|
-
score = create_new_portion_score(student,portion)
|
28
|
-
add_to_portion_attendance(student, exam, portion, score)
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
def add_to_portion_attendance(student, exam, portion, score = nil)
|
36
|
-
score ||= portion.student_score(student)
|
37
|
-
@student_portion_attendance[student.id][score.id] = [score.attendances.last.try(:id), score.attendances.last.try(:attendance_type).try(:color_code)]
|
38
|
-
end
|
39
|
-
|
40
|
-
def calculate_exam_averages
|
41
|
-
@students.each do |student|
|
42
|
-
@exams.each do |exam|
|
43
|
-
add_to_exam_averages(exam, student)
|
44
|
-
add_to_weight_averages(exam, student) if exam.use_weighting
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
def calculate_deviation
|
50
|
-
@deviation = Hash.new { |hash,key| hash[key] = {} }
|
51
|
-
@standard_deviation = 0.0
|
52
|
-
@deviation_member = 0.0
|
53
|
-
@exams.each do |exam|
|
54
|
-
@students.each do |student|
|
55
|
-
if exam.use_weighting
|
56
|
-
add_to_weighted_standard_deviation(exam, student)
|
57
|
-
else
|
58
|
-
add_to_standard_deviation(exam, student)
|
59
|
-
end
|
60
|
-
end
|
61
|
-
standard_deviation(@standard_deviation)
|
62
|
-
|
63
|
-
@students.each do |student|
|
64
|
-
@deviation[student.id][exam.id] = 0.0
|
65
|
-
add_to_deviation_member(exam, student)
|
66
|
-
add_to_deviation(exam, student)
|
67
|
-
end
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
|
-
def calculate_rank_and_grade
|
72
|
-
@grades = Hash.new { |hash,key| hash[key] = {} }
|
73
|
-
@scores = []
|
74
|
-
|
75
|
-
populate_student_scores
|
76
|
-
|
77
|
-
|
78
|
-
# WIP Grade Calculation -----↓
|
79
|
-
|
80
|
-
# @grading_method = GradingMethod.find(exam.grading_method_id)
|
81
|
-
# puts "@grading_method-------------"
|
82
|
-
# puts @grading_method.name
|
83
|
-
# eval @grading_method.method
|
84
|
-
grading_method = 1
|
85
|
-
|
86
|
-
grade_calculate(grading_method)
|
87
|
-
|
88
|
-
# Rank Calculation -----↓
|
89
|
-
rank_calculate
|
90
|
-
end
|
91
|
-
|
92
|
-
private
|
93
|
-
|
94
|
-
def caluculate_completion(exam)
|
95
|
-
total ||= exam.total_records(@students)
|
96
|
-
ungraded ||= exam.ungraded(@students)
|
97
|
-
|
98
|
-
@completion[exam.id][:completion_percentage] = exam.completion(@students)
|
99
|
-
@completion[exam.id][:total] = total
|
100
|
-
@completion[exam.id][:graded] = total - ungraded
|
101
|
-
@completion[exam.id][:ungraded] = ungraded
|
102
|
-
end
|
103
|
-
|
104
|
-
|
105
|
-
def fix_digit(num, digit_num)
|
106
|
-
fix_num = 10 ** digit_num
|
107
|
-
fixed_num = num * fix_num
|
108
|
-
fixed_num.nan? ? 0 : fixed_num.truncate.to_f / fix_num.to_f
|
109
|
-
end
|
110
|
-
|
111
|
-
def create_new_portion_score(student, portion)
|
112
|
-
Gaku::ExamPortionScore.create(student: student, exam_portion: portion)
|
113
|
-
end
|
114
|
-
|
115
|
-
def add_to_student_total_score(student,exam, portion)
|
116
|
-
@student_total_scores[student.id][exam.id] += student.exam_portion_scores.where(exam_portion_id: portion.id).first.score.to_f
|
117
|
-
end
|
118
|
-
|
119
|
-
def have_portion_score?(student, portion)
|
120
|
-
student.exam_portion_scores.where(exam_portion_id: portion.id).first.present?
|
121
|
-
end
|
122
|
-
|
123
|
-
def add_to_student_total_weight(student,exam, portion)
|
124
|
-
@student_total_weights[student.id][exam.id] += (portion.weight.to_f / 100) * student.exam_portion_scores.where(exam_portion_id: portion.id).first.score.to_f
|
125
|
-
end
|
126
|
-
|
127
|
-
def calculate_array_total(array_data)
|
128
|
-
total = 0
|
129
|
-
array_data.each do |num|
|
130
|
-
total += num
|
131
|
-
end
|
132
|
-
total
|
133
|
-
end
|
134
|
-
|
135
|
-
def add_to_exam_averages(exam, student)
|
136
|
-
@exam_averages[exam.id].push @student_total_scores[student.id][exam.id]
|
137
|
-
if @exam_averages[exam.id].length == @students.length
|
138
|
-
total = calculate_array_total @exam_averages[exam.id]
|
139
|
-
@exam_averages[exam.id] = fix_digit(total / @students.length, 1)
|
140
|
-
end
|
141
|
-
end
|
142
|
-
|
143
|
-
def add_to_weight_averages(exam, student)
|
144
|
-
@exam_weight_averages[exam.id] += [@student_total_weights[student.id][exam.id]]
|
145
|
-
if @exam_weight_averages[exam.id].length == @students.length
|
146
|
-
total = calculate_array_total @exam_weight_averages[exam.id]
|
147
|
-
@exam_weight_averages[exam.id] = fix_digit(total / @students.length, 1)
|
148
|
-
end
|
149
|
-
end
|
150
|
-
|
151
|
-
def add_to_weighted_standard_deviation(exam, student)
|
152
|
-
@standard_deviation += (@student_total_weights[student.id][exam.id] - @exam_weight_averages[exam.id]) ** 2
|
153
|
-
end
|
154
|
-
|
155
|
-
def add_to_standard_deviation(exam, student)
|
156
|
-
@standard_deviation += fix_digit((@student_total_scores[student.id][exam.id] - @exam_averages[exam.id]) ** 2, 2)
|
157
|
-
end
|
158
|
-
|
159
|
-
def standard_deviation(standard_deviation)
|
160
|
-
@standard_deviation = fix_digit(Math.sqrt(standard_deviation / @students.length), 4)
|
161
|
-
end
|
162
|
-
|
163
|
-
def add_to_deviation_member(exam, student)
|
164
|
-
if exam.use_weighting
|
165
|
-
@deviation_member = (@student_total_weights[student.id][exam.id] - @exam_weight_averages[exam.id]) / @standard_deviation
|
166
|
-
else
|
167
|
-
@deviation_member = (@student_total_scores[student.id][exam.id] - @exam_averages[exam.id]) / @standard_deviation
|
168
|
-
end
|
169
|
-
end
|
170
|
-
|
171
|
-
def add_to_deviation(exam, student)
|
172
|
-
@deviation[student.id][exam.id] = @deviation_member.nan? ? 50 : fix_digit(@deviation_member * 10 + 50, 4)
|
173
|
-
end
|
174
|
-
|
175
|
-
def populate_student_scores
|
176
|
-
@exams.each do |exam|
|
177
|
-
if exam.use_weighting
|
178
|
-
@students.each do |student|
|
179
|
-
@scores.push [@student_total_weights[student.id][exam.id], student.id]
|
180
|
-
end
|
181
|
-
else
|
182
|
-
@students.each do |student|
|
183
|
-
@scores.push [@student_total_scores[student.id][exam.id], student.id]
|
184
|
-
end
|
185
|
-
end
|
186
|
-
@scores.sort!.reverse!
|
187
|
-
end
|
188
|
-
|
189
|
-
def grade_calculate(grading_method)
|
190
|
-
@gradePoint = 10
|
191
|
-
@grade_levels_deviation = [10000000000, 66, 62, 58, 55, 59, 45, 37, 0]
|
192
|
-
@grade_levels_percent = [5, 5, 10, 10, 30, 10, 100]
|
193
|
-
|
194
|
-
@exams.each do |exam|
|
195
|
-
case grading_method
|
196
|
-
when 1
|
197
|
-
grading_method_one(exam)
|
198
|
-
when 2
|
199
|
-
grading_method_two(exam)
|
200
|
-
end
|
201
|
-
end
|
202
|
-
end
|
203
|
-
|
204
|
-
def grading_method_one(exam)
|
205
|
-
@grade_levels_deviation.each_with_index do |glevel, i|
|
206
|
-
@students.each do |student|
|
207
|
-
if @grade_levels_deviation[i] > @deviation[student.id][exam.id] && @grade_levels_deviation[i+1] <= @deviation[student.id][exam.id]
|
208
|
-
@grades[exam.id][student.id] = @gradePoint
|
209
|
-
end
|
210
|
-
end
|
211
|
-
@gradePoint -= 1
|
212
|
-
end
|
213
|
-
end
|
214
|
-
|
215
|
-
def grading_method_two(exam)
|
216
|
-
scoresMem = @scores.clone
|
217
|
-
gradeNums = []
|
218
|
-
@grade_levels_percent.each do |glevel|
|
219
|
-
gradeNums.push((@students.length * (glevel.to_f / 100)).ceil)
|
220
|
-
end
|
221
|
-
gradeNums.each do |gnum|
|
222
|
-
i = 0
|
223
|
-
while i < gnum && scoresMem.length != 0
|
224
|
-
@grades[exam.id][scoresMem.shift[1]] = gradePoint
|
225
|
-
i += 1
|
226
|
-
end
|
227
|
-
@gradePoint -= 1
|
228
|
-
end
|
229
|
-
end
|
230
|
-
|
231
|
-
def rank_calculate
|
232
|
-
@rank_point = 5
|
233
|
-
@ranks = Hash.new { |hash,key| hash[key] = {} }
|
234
|
-
rank_levels = [15, 20]
|
235
|
-
@exams.each do |exam|
|
236
|
-
initial_student_rank(exam)
|
237
|
-
rank_nums = rank_nums(rank_levels)
|
238
|
-
rank_score(exam,rank_nums)
|
239
|
-
rank(exam)
|
240
|
-
end
|
241
|
-
end
|
242
|
-
|
243
|
-
def rank_nums(rank_levels)
|
244
|
-
rank_nums = []
|
245
|
-
rank_levels.each {|rlevel| rank_nums.push((@students.length * (rlevel.to_f / 100)).ceil)}
|
246
|
-
rank_nums
|
247
|
-
end
|
248
|
-
|
249
|
-
def initial_student_rank(exam)
|
250
|
-
@students.each {|student| @ranks[exam.id][student.id] = 3 }
|
251
|
-
end
|
252
|
-
|
253
|
-
def rank_score(exam,rank_nums)
|
254
|
-
rank_nums.each do |rnum|
|
255
|
-
i = 0
|
256
|
-
while i < rnum && @scores.length != 0
|
257
|
-
scoreMem = @scores.shift
|
258
|
-
@ranks[exam.id][scoreMem[1]] = @rank_point
|
259
|
-
rnum += 1 if @scores.length != 0 && scoreMem[0] == @scores[0][0]
|
260
|
-
i += 1
|
261
|
-
end
|
262
|
-
@rank_point -= 1
|
263
|
-
end
|
264
|
-
end
|
265
|
-
|
266
|
-
def rank(exam)
|
267
|
-
@scores.each do |score|
|
268
|
-
if @grades[exam.id][score[1]] == 3
|
269
|
-
@ranks[exam.id][score[1]] = 2
|
270
|
-
elsif @grades[exam.id][score[1]] < 3
|
271
|
-
@ranks[exam.id][score[1]] = 1
|
272
|
-
end
|
273
|
-
end
|
274
|
-
end
|
275
|
-
end
|
276
|
-
|
277
|
-
end
|
278
|
-
|
279
|
-
end
|