├── .gitignore ├── .hound.yml ├── .rspec ├── .rubocop.yml ├── Dockerfile ├── Gemfile ├── LICENSE.md ├── README.md ├── Rakefile ├── VERSION ├── api ├── .gitignore ├── .rspec ├── Gemfile ├── Rakefile ├── app │ ├── channels │ │ └── application_cable │ │ │ ├── connection.rb │ │ │ ├── exam_channel.rb │ │ │ └── grading_channel.rb │ ├── controllers │ │ ├── .keep │ │ └── gaku │ │ │ └── api │ │ │ ├── application_controller.rb │ │ │ └── v1 │ │ │ ├── addresses_controller.rb │ │ │ ├── authentication_controller.rb │ │ │ ├── base_controller.rb │ │ │ ├── class_groups │ │ │ ├── enrollments_controller.rb │ │ │ └── students_controller.rb │ │ │ ├── contact_types_controller.rb │ │ │ ├── contacts_controller.rb │ │ │ ├── courses │ │ │ ├── enrollments_controller.rb │ │ │ ├── exams │ │ │ │ └── exam_portion_scores_controller.rb │ │ │ └── students_controller.rb │ │ │ ├── courses_controller.rb │ │ │ ├── enrollment_statuses_controller.rb │ │ │ ├── enrollments_controller.rb │ │ │ ├── exam_portion_scores_controller.rb │ │ │ ├── exams │ │ │ ├── exam_portions │ │ │ │ └── exam_portion_scores_controller.rb │ │ │ └── exam_portions_controller.rb │ │ │ ├── exams_controller.rb │ │ │ ├── guardians_controller.rb │ │ │ ├── roles_controller.rb │ │ │ ├── statuses_controller.rb │ │ │ ├── students │ │ │ ├── addresses_controller.rb │ │ │ ├── class_groups_controller.rb │ │ │ ├── courses_controller.rb │ │ │ ├── exam_sessions_controller.rb │ │ │ ├── extracurricular_activities_controller.rb │ │ │ ├── guardians_controller.rb │ │ │ └── student_guardians_controller.rb │ │ │ ├── students_controller.rb │ │ │ ├── syllabuses │ │ │ ├── courses_controlle.rb │ │ │ └── exams_controller.rb │ │ │ ├── syllabuses_controller.rb │ │ │ ├── users │ │ │ └── user_roles_controller.rb │ │ │ └── users_controller.rb │ ├── mailers │ │ └── .keep │ ├── models │ │ └── .keep │ ├── serializers │ │ └── gaku │ │ │ ├── address_serializer.rb │ │ │ ├── class_group_serializer.rb │ │ │ ├── contact_serializer.rb │ │ │ ├── contact_type_serializer.rb │ │ │ ├── course_serializer.rb │ │ │ ├── enrollment_serializer.rb │ │ │ ├── enrollment_status_serializer.rb │ │ │ ├── exam_portion_score_serializer.rb │ │ │ ├── exam_portion_serializer.rb │ │ │ ├── exam_serializer.rb │ │ │ ├── exam_session_serializer.rb │ │ │ ├── extracurricular_activity_serializer.rb │ │ │ ├── guardian_serializer.rb │ │ │ ├── role_serializer.rb │ │ │ ├── student_serializer.rb │ │ │ ├── syllabus_serializer.rb │ │ │ └── user_serializer.rb │ └── services │ │ └── gaku │ │ └── api │ │ ├── address_create_service.rb │ │ ├── authenticate_user.rb │ │ ├── authorize_api_request.rb │ │ ├── create_syllabus_service.rb │ │ ├── guardian_create_service.rb │ │ ├── refresh_authenticate_user.rb │ │ └── student_create_service.rb ├── bin │ └── rails ├── config │ ├── initializers │ │ ├── kaminari.rb │ │ └── mime_types.rb │ └── routes.rb ├── gaku_api.gemspec ├── lib │ ├── gaku │ │ ├── api.rb │ │ └── api │ │ │ ├── engine.rb │ │ │ └── version.rb │ ├── gaku_api.rb │ ├── json_web_token.rb │ └── tasks │ │ └── api_tasks.rake └── spec │ ├── requests │ ├── course_enrollments_spec.rb │ ├── course_students_spec.rb │ ├── courses_spec.rb │ ├── guardians │ │ └── addresses_spec.rb │ ├── guardians_spec.rb │ ├── students │ │ └── addresses_spec.rb │ ├── students_spec.rb │ └── syllabus_spec.rb │ ├── spec_helper.rb │ ├── spec_helper_requests.rb │ └── support │ ├── fixtures │ └── student_index.msgpack │ └── request_helpers.rb ├── bin └── gaku ├── common_gaku_dependencies.rb ├── common_gaku_gemspec_mixin.rb ├── core ├── .rspec ├── Gemfile ├── Guardfile ├── Rakefile ├── app │ ├── assets │ │ ├── images │ │ │ ├── background.jpg │ │ │ ├── check.png │ │ │ ├── cross.png │ │ │ ├── down_arrow.gif │ │ │ ├── elements │ │ │ │ ├── highlight.png │ │ │ │ └── toolbar1.png │ │ │ ├── gaku-logo-gear.png │ │ │ ├── gaku-logo-gear.svg │ │ │ ├── gaku-logo.png │ │ │ ├── gaku-logo.svg │ │ │ ├── gakuengine.png │ │ │ ├── gakuengine20.png │ │ │ ├── icon-chair.png │ │ │ ├── images │ │ │ │ ├── ui-bg_flat_30_cccccc_40x100.png │ │ │ │ ├── ui-bg_flat_50_5c5c5c_40x100.png │ │ │ │ ├── ui-bg_glass_20_555555_1x400.png │ │ │ │ ├── ui-bg_glass_40_0078a3_1x400.png │ │ │ │ ├── ui-bg_glass_40_ffc73d_1x400.png │ │ │ │ ├── ui-bg_gloss-wave_25_333333_500x100.png │ │ │ │ ├── ui-bg_highlight-soft_80_eeeeee_1x100.png │ │ │ │ ├── ui-bg_inset-soft_25_000000_1x100.png │ │ │ │ ├── ui-bg_inset-soft_30_f58400_1x100.png │ │ │ │ ├── ui-icons_222222_256x240.png │ │ │ │ ├── ui-icons_4b8e0b_256x240.png │ │ │ │ ├── ui-icons_a83300_256x240.png │ │ │ │ ├── ui-icons_cccccc_256x240.png │ │ │ │ └── ui-icons_ffffff_256x240.png │ │ │ ├── missing_original.png │ │ │ ├── missing_thumb.png │ │ │ ├── rails.png │ │ │ ├── raw │ │ │ │ ├── GAKU Colors.png │ │ │ │ ├── GAKU Engine G Logo + Text Logo [#87CAF3](900x816px).svg │ │ │ │ ├── GAKU Engine Gear + Text Logo.svg │ │ │ │ └── top-logo.svg │ │ │ ├── themes │ │ │ │ └── gakuengine │ │ │ │ │ └── images │ │ │ │ │ ├── ui-bg_flat_65_ffffff_40x100.png │ │ │ │ │ ├── ui-bg_highlight-hard_100_f9f9f9_1x100.png │ │ │ │ │ ├── ui-bg_highlight-hard_40_aaaaaa_1x100.png │ │ │ │ │ ├── ui-bg_highlight-soft_50_aaaaaa_1x100.png │ │ │ │ │ ├── ui-bg_inset-hard_40_111111_1x100.png │ │ │ │ │ ├── ui-bg_inset-hard_45_cd0a0a_1x100.png │ │ │ │ │ ├── ui-bg_inset-hard_55_165e83_1x100.png │ │ │ │ │ ├── ui-bg_inset-soft_55_00a3af_1x100.png │ │ │ │ │ ├── ui-bg_inset-soft_99_00a3af_1x100.png │ │ │ │ │ ├── ui-icons_222222_256x240.png │ │ │ │ │ ├── ui-icons_70f000_256x240.png │ │ │ │ │ ├── ui-icons_bbbbbb_256x240.png │ │ │ │ │ ├── ui-icons_ededed_256x240.png │ │ │ │ │ ├── ui-icons_ffcf29_256x240.png │ │ │ │ │ └── ui-icons_ffffff_256x240.png │ │ │ ├── tick.png │ │ │ ├── ui-bg_flat_75_ffffff_40x100.png │ │ │ └── up_arrow.gif │ │ ├── javascripts │ │ │ └── gaku │ │ │ │ ├── courses.js.coffee │ │ │ │ └── exams.js.coffee │ │ └── stylesheets │ │ │ └── gaku │ │ │ └── bootstrap_and_theme.css.scss │ ├── controllers │ │ └── gaku │ │ │ ├── core_controller.rb │ │ │ ├── courses │ │ │ ├── exams │ │ │ │ └── exam_portion_scores_controller.rb │ │ │ └── exams_controller.rb │ │ │ └── exams_controller.rb │ ├── decorators │ │ └── gaku │ │ │ ├── course_decorator.rb │ │ │ ├── guardian_decorator.rb │ │ │ ├── person_decorator.rb │ │ │ ├── student_decorator.rb │ │ │ └── teacher_decorator.rb │ ├── helpers │ │ └── gaku │ │ │ └── gaku_helper.rb │ ├── models │ │ ├── application_record.rb │ │ ├── concerns │ │ │ ├── addresses.rb │ │ │ ├── contacts.rb │ │ │ ├── enrollable.rb │ │ │ ├── gradable.rb │ │ │ ├── notes.rb │ │ │ ├── pagination.rb │ │ │ ├── person.rb │ │ │ ├── picture.rb │ │ │ ├── semesterable.rb │ │ │ └── student_reviewable.rb │ │ └── gaku │ │ │ ├── ability.rb │ │ │ ├── address.rb │ │ │ ├── admin_ability.rb │ │ │ ├── assignment.rb │ │ │ ├── assignment_score.rb │ │ │ ├── attachment.rb │ │ │ ├── attendance.rb │ │ │ ├── attendance_type.rb │ │ │ ├── badge.rb │ │ │ ├── badge_type.rb │ │ │ ├── campus.rb │ │ │ ├── class_group.rb │ │ │ ├── commute_method_type.rb │ │ │ ├── contact.rb │ │ │ ├── contact_type.rb │ │ │ ├── country.rb │ │ │ ├── course.rb │ │ │ ├── course_group.rb │ │ │ ├── course_group_enrollment.rb │ │ │ ├── course_teacher.rb │ │ │ ├── department.rb │ │ │ ├── enrollment.rb │ │ │ ├── enrollment_status.rb │ │ │ ├── exam.rb │ │ │ ├── exam_portion.rb │ │ │ ├── exam_portion_score.rb │ │ │ ├── exam_schedule.rb │ │ │ ├── exam_score.rb │ │ │ ├── exam_session.rb │ │ │ ├── exam_syllabus.rb │ │ │ ├── external_school_record.rb │ │ │ ├── extracurricular_activity.rb │ │ │ ├── faculty.rb │ │ │ ├── grading_method.rb │ │ │ ├── grading_method_connector.rb │ │ │ ├── grading_method_set.rb │ │ │ ├── grading_method_set_item.rb │ │ │ ├── guardian.rb │ │ │ ├── install.rb │ │ │ ├── lesson.rb │ │ │ ├── lesson_plan.rb │ │ │ ├── level.rb │ │ │ ├── note.rb │ │ │ ├── preset.rb │ │ │ ├── program.rb │ │ │ ├── program_level.rb │ │ │ ├── program_specialty.rb │ │ │ ├── program_syllabus.rb │ │ │ ├── role.rb │ │ │ ├── schedule.rb │ │ │ ├── scholarship_status.rb │ │ │ ├── school.rb │ │ │ ├── school_role.rb │ │ │ ├── school_year.rb │ │ │ ├── semester.rb │ │ │ ├── semester_attendance.rb │ │ │ ├── semester_connector.rb │ │ │ ├── simple_grade.rb │ │ │ ├── simple_grade_type.rb │ │ │ ├── specialty.rb │ │ │ ├── state.rb │ │ │ ├── student.rb │ │ │ ├── student_exam_session.rb │ │ │ ├── student_guardian.rb │ │ │ ├── student_review.rb │ │ │ ├── student_review_category.rb │ │ │ ├── student_specialty.rb │ │ │ ├── syllabus.rb │ │ │ ├── syllabus_teacher.rb │ │ │ ├── teacher.rb │ │ │ ├── template.rb │ │ │ ├── user.rb │ │ │ └── user_role.rb │ ├── services │ │ └── gaku │ │ │ ├── contact_creation.rb │ │ │ ├── contact_updation.rb │ │ │ ├── student_selection.rb │ │ │ └── user_creator.rb │ └── views │ │ └── gaku │ │ ├── admin │ │ └── grading_methods │ │ │ ├── _arguments_form_fields.html.slim │ │ │ ├── _arguments_template.html.slim │ │ │ └── _form_fields.html.slim │ │ ├── courses │ │ ├── _form_fields.html.slim │ │ └── exams │ │ │ ├── exam_portion_scores │ │ │ └── update.js.erb │ │ │ ├── grading.html.slim │ │ │ └── grading │ │ │ ├── _calculations.html.slim │ │ │ ├── _exam_portion_score_form.htmls.lim │ │ │ ├── _exam_scores.html.slim │ │ │ └── _students.html.slim │ │ ├── layouts │ │ └── gaku.html.slim │ │ └── shared │ │ └── menu │ │ └── _global.html.erb ├── config │ ├── initializers │ │ ├── active_record.rb │ │ ├── devise.rb │ │ ├── i18n.rb │ │ ├── inflections.rb │ │ ├── kaminari.rb │ │ ├── locale.rb │ │ ├── redis.rb │ │ └── translation_missing.rb │ ├── locales │ │ ├── bg.yml │ │ ├── en.yml │ │ ├── ja.yml │ │ ├── pt-BR.yml │ │ └── zh-CN.yml │ └── routes.rb ├── core_dependencies.rb ├── db │ ├── default │ │ └── gaku │ │ │ ├── attendance_types.rb │ │ │ ├── commute_method_types.rb │ │ │ ├── contact_types.yml │ │ │ ├── countries.rb │ │ │ ├── departments.rb │ │ │ ├── enrollment_status.rb │ │ │ ├── master_school.rb │ │ │ ├── presets.rb │ │ │ ├── roles.yml │ │ │ ├── scholarship_statuses.rb │ │ │ └── states.rb │ ├── migrate │ │ ├── 20120202111850_presets.rb │ │ ├── 20131014065028_translations.rb │ │ ├── 20131025073352_gaku_core.rb │ │ ├── 20140128141752_change_grading_methods_arguments_field.rb │ │ ├── 20140130182100_change_fields_external_school_record.rb │ │ ├── 20140131113337_create_student_configs.rb │ │ ├── 20140207093618_drop_student_configs.rb │ │ ├── 20140213113405_create_grading_method_connectors_table.rb │ │ ├── 20140304094422_create_gaku_exam_sessions_table.rb │ │ ├── 20140325073941_add_time_format_24_to_presets_table.rb │ │ ├── 20140408111314_remove_semester_join_tables.rb │ │ ├── 20140408111358_create_semester_connectors_table.rb │ │ ├── 20140423093155_create_enrollments_table.rb │ │ ├── 20140423100114_clean_enrollments_join_models.rb │ │ ├── 20140429112725_add_counters_to_enrollmentable.rb │ │ ├── 20140604104210_rename_method_to_grading_method.rb │ │ ├── 20140604113045_add_default_value_to_curved.rb │ │ ├── 20140610091053_add_seat_number_to_enrollments.rb │ │ ├── 20140701104700_change_hstore_to_string_criteria.rb │ │ ├── 20140715135152_create_semester_attendance_table.rb │ │ ├── 20140718105226_create_student_review_categories_table.rb │ │ ├── 20140728121353_create_student_review_table.rb │ │ ├── 20150213095508_improve_countries_and_states.rb │ │ ├── 20160125194100_add_gradable_to_exam_portion_score.rb │ │ ├── 20160209100945_add_score_types_to_exam_portions.rb │ │ ├── 20160209104713_add_fields_to_exam_portion_score.rb │ │ ├── 20170509132020_change_enrollmentable_to_enrollable.rb │ │ ├── 20180326143207_join_models_for_syllabus_and_course_to_teacher.rb │ │ └── 20180403134527_add_disabled_attributes_to_user.rb │ ├── schema.rb │ └── seeds.rb ├── faye.ru ├── gaku_core.gemspec ├── lib │ ├── gaku │ │ ├── class_name_detector.rb │ │ ├── core.rb │ │ ├── core │ │ │ ├── console_colors.rb │ │ │ ├── engine.rb │ │ │ └── url_helpers.rb │ │ ├── grading │ │ │ ├── collection │ │ │ │ ├── base_method.rb │ │ │ │ ├── calculations.rb │ │ │ │ ├── interval.rb │ │ │ │ ├── ordinal.rb │ │ │ │ ├── percentage.rb │ │ │ │ ├── result.rb │ │ │ │ └── score.rb │ │ │ └── single │ │ │ │ ├── base_method.rb │ │ │ │ ├── calculations.rb │ │ │ │ ├── interval.rb │ │ │ │ ├── ordinal.rb │ │ │ │ ├── pass_fail.rb │ │ │ │ ├── percentage.rb │ │ │ │ ├── ratio.rb │ │ │ │ ├── result.rb │ │ │ │ └── score.rb │ │ ├── migrations.rb │ │ ├── streamer │ │ │ └── sse.rb │ │ └── testing │ │ │ ├── auth_helpers.rb │ │ │ ├── common_rake.rb │ │ │ ├── controller_helpers.rb │ │ │ ├── coverage.rb │ │ │ ├── deferred_garbage_collection.rb │ │ │ ├── factories.rb │ │ │ └── factories │ │ │ ├── address_factory.rb │ │ │ ├── assignment_factory.rb │ │ │ ├── assignment_score_factory.rb │ │ │ ├── attachment_factory.rb │ │ │ ├── attendance_factory.rb │ │ │ ├── attendance_type_factory.rb │ │ │ ├── badge_factory.rb │ │ │ ├── badge_type_factory.rb │ │ │ ├── campus_factory.rb │ │ │ ├── class_group_factory.rb │ │ │ ├── commute_method_type_factory.rb │ │ │ ├── contact_creation_factory.rb │ │ │ ├── contact_factory.rb │ │ │ ├── contact_type_factory.rb │ │ │ ├── country_factory.rb │ │ │ ├── course_enrollment_factory.rb │ │ │ ├── course_factory.rb │ │ │ ├── course_group_enrollment_factory.rb │ │ │ ├── course_group_factory.rb │ │ │ ├── department_factory.rb │ │ │ ├── enrollment_factory.rb │ │ │ ├── enrollment_status_factory.rb │ │ │ ├── exam_factory.rb │ │ │ ├── exam_portion_factory.rb │ │ │ ├── exam_portion_score_factory.rb │ │ │ ├── exam_schedule_factory.rb │ │ │ ├── exam_score_factory.rb │ │ │ ├── exam_session_factory.rb │ │ │ ├── external_school_record_factory.rb │ │ │ ├── extracurricular_activity_factory.rb │ │ │ ├── faculty_factory.rb │ │ │ ├── grading_method_connector_factory.rb │ │ │ ├── grading_method_factory.rb │ │ │ ├── grading_method_set_factory.rb │ │ │ ├── grading_method_set_item_factory.rb │ │ │ ├── guardian_factory.rb │ │ │ ├── lesson_factory.rb │ │ │ ├── lesson_plan_factory.rb │ │ │ ├── level_factory.rb │ │ │ ├── note_factory.rb │ │ │ ├── preset_factory.rb │ │ │ ├── program_factory.rb │ │ │ ├── program_level_factory.rb │ │ │ ├── program_specialty.rb │ │ │ ├── program_syllabus_factory.rb │ │ │ ├── role_factory.rb │ │ │ ├── schedule_factory.rb │ │ │ ├── scholarship_status_factory.rb │ │ │ ├── school_factory.rb │ │ │ ├── school_role_factory.rb │ │ │ ├── school_year_factory.rb │ │ │ ├── semester_attendance_factory.rb │ │ │ ├── semester_connectors_factory.rb │ │ │ ├── semester_factory.rb │ │ │ ├── simple_grade_factory.rb │ │ │ ├── simple_grade_type_factory.rb │ │ │ ├── specialty_factory.rb │ │ │ ├── state_factory.rb │ │ │ ├── student_factory.rb │ │ │ ├── student_review_category_factory.rb │ │ │ ├── student_review_factory.rb │ │ │ ├── student_specialty_factory.rb │ │ │ ├── syllabus_factory.rb │ │ │ ├── teacher_factory.rb │ │ │ ├── template_factory.rb │ │ │ ├── traits.rb │ │ │ ├── user_factory.rb │ │ │ └── user_role_factory.rb │ ├── gaku_core.rb │ ├── generators │ │ └── gaku │ │ │ ├── docker │ │ │ ├── docker_generator.rb │ │ │ └── templates │ │ │ │ ├── app │ │ │ │ └── assets │ │ │ │ │ ├── javascripts │ │ │ │ │ └── gaku │ │ │ │ │ │ ├── admin │ │ │ │ │ │ └── all.js │ │ │ │ │ │ ├── archive │ │ │ │ │ │ └── all.js │ │ │ │ │ │ └── frontend │ │ │ │ │ │ └── all.js │ │ │ │ │ └── stylesheets │ │ │ │ │ └── gaku │ │ │ │ │ ├── admin │ │ │ │ │ └── all.css │ │ │ │ │ ├── archive │ │ │ │ │ └── all.css │ │ │ │ │ └── frontend │ │ │ │ │ └── all.css │ │ │ │ ├── bin │ │ │ │ └── check_postgres.sh │ │ │ │ └── config │ │ │ │ └── database.yml │ │ │ ├── dummy │ │ │ ├── dummy_generator.rb │ │ │ └── templates │ │ │ │ └── rails │ │ │ │ ├── application.rb │ │ │ │ ├── boot.rb │ │ │ │ ├── database.yml │ │ │ │ ├── routes.rb │ │ │ │ └── script │ │ │ │ └── rails │ │ │ └── install │ │ │ ├── install_generator.rb │ │ │ └── templates │ │ │ ├── Procfile │ │ │ ├── app │ │ │ └── assets │ │ │ │ ├── javascripts │ │ │ │ └── gaku │ │ │ │ │ ├── admin │ │ │ │ │ └── all.js │ │ │ │ │ ├── archive │ │ │ │ │ └── all.js │ │ │ │ │ └── frontend │ │ │ │ │ └── all.js │ │ │ │ └── stylesheets │ │ │ │ └── gaku │ │ │ │ ├── admin │ │ │ │ └── all.css │ │ │ │ ├── archive │ │ │ │ └── all.css │ │ │ │ └── frontend │ │ │ │ └── all.css │ │ │ └── lib │ │ │ └── grading │ │ │ ├── README.md │ │ │ ├── bin │ │ │ └── gaku_grading.coffee │ │ │ └── package.json │ └── tasks │ │ ├── admin_user.rake │ │ ├── core.rake │ │ ├── grading.rake │ │ ├── reset.rake │ │ └── testing.rake └── spec │ ├── lib │ └── gaku │ │ └── grading │ │ ├── collection │ │ ├── calculations_spec.rb │ │ ├── interval_spec.rb │ │ ├── ordinal_spec.rb │ │ ├── percentage_spec.rb │ │ ├── result_spec.rb │ │ └── score_spec.rb │ │ └── single │ │ ├── calculations_spec.rb │ │ ├── ordinal_spec.rb │ │ ├── percentage_spec.rb │ │ ├── result_spec.rb │ │ └── score_spec.rb │ ├── models │ ├── address_spec.rb │ ├── assignment_score_spec.rb │ ├── assignment_spec.rb │ ├── attachment_spec.rb │ ├── attendance_spec.rb │ ├── attendance_type_spec.rb │ ├── badge_spec.rb │ ├── badge_type_spec.rb │ ├── campus_spec.rb │ ├── class_group_spec.rb │ ├── commute_method_type_spec.rb │ ├── contact_spec.rb │ ├── contact_type_spec.rb │ ├── country_spec.rb │ ├── course_group_enrollment_spec.rb │ ├── course_group_spec.rb │ ├── course_spec.rb │ ├── department_spec.rb │ ├── enrollment_spec.rb │ ├── enrollment_status_spec.rb │ ├── exam_portion_score_spec.rb │ ├── exam_portion_spec.rb │ ├── exam_schedule_spec.rb │ ├── exam_score_spec.rb │ ├── exam_session_spec.rb │ ├── exam_spec.rb │ ├── exam_syllabus_spec.rb │ ├── external_school_record_spec.rb │ ├── extracurricular_activity_spec.rb │ ├── factories_spec.rb │ ├── faculty_spec.rb │ ├── grading_method_connector_spec.rb │ ├── grading_method_set_item_spec.rb │ ├── grading_method_set_spec.rb │ ├── grading_method_spec.rb │ ├── guardian_spec.rb │ ├── lesson_plan_spec.rb │ ├── lesson_spec.rb │ ├── level_spec.rb │ ├── note_spec.rb │ ├── preset_spec.rb │ ├── program_level_spec.rb │ ├── program_spec.rb │ ├── program_specialty_spec.rb │ ├── program_syllabus_spec.rb │ ├── role_spec.rb │ ├── scholarship_status_spec.rb │ ├── school_role_spec.rb │ ├── school_spec.rb │ ├── school_year_spec.rb │ ├── semester_attendance_spec.rb │ ├── semester_connector_spec.rb │ ├── semester_spec.rb │ ├── simple_grade_spec.rb │ ├── simple_grade_type_spec.rb │ ├── specialty_spec.rb │ ├── state_spec.rb │ ├── student_guardian_spec.rb │ ├── student_review_category_spec.rb │ ├── student_review_spec.rb │ ├── student_spec.rb │ ├── student_speciality_spec.rb │ ├── syllabus_spec.rb │ ├── teacher_spec.rb │ ├── template_spec.rb │ ├── user_role_spec.rb │ └── user_spec.rb │ ├── services │ ├── contact_creation_spec.rb │ ├── contact_updation_spec.rb │ ├── student_selection_spec.rb │ └── user_creator_spec.rb │ ├── spec_helper_base.rb │ ├── spec_helper_models.rb │ └── support │ ├── 120x120.jpg │ ├── models │ ├── matchers │ │ └── accept_nested_attributes_for_matcher.rb │ └── shared_examples │ │ ├── addressable.rb │ │ ├── avatarable.rb │ │ ├── contactable.rb │ │ ├── enrollmentable.rb │ │ ├── gradable.rb │ │ ├── notable.rb │ │ ├── person.rb │ │ ├── semesterable.rb │ │ └── student_reviewable.rb │ └── sample_roster.ods ├── docker-compose.yml ├── frontend ├── app │ └── controllers │ │ └── gaku │ │ └── grading_method_connectors_controller.rb └── lib │ └── gaku │ └── frontend │ └── engine.rb ├── gaku.gemspec ├── lib ├── gaku.rb └── gaku │ ├── command │ └── installer.rb │ └── container.rb ├── sample ├── Rakefile ├── db │ └── sample │ │ └── gaku │ │ ├── 01_syllabuses.rb │ │ ├── 02_courses.rb │ │ ├── 20-grading_methods.rb │ │ ├── badge_types.rb │ │ ├── changes │ │ └── student_changes.rb │ │ ├── class_groups.rb │ │ ├── course_groups.rb │ │ ├── disposals │ │ ├── address_and_contact_disposals.rb │ │ ├── attachment_disposals.rb │ │ ├── course_group_disposals.rb │ │ ├── exam_disposals.rb │ │ ├── student_disposals.rb │ │ └── teacher_disposals.rb │ │ ├── exams.rb │ │ ├── extracurricular_activities.rb │ │ ├── grading_widget.rb │ │ ├── images │ │ └── 120x120.jpg │ │ ├── roles.rb │ │ ├── schools.rb │ │ ├── specialties.rb │ │ ├── students.rb │ │ ├── teachers.rb │ │ └── users.rb ├── gaku_sample.gemspec └── lib │ ├── gaku_sample.rb │ ├── sample_counters.rb │ ├── shared_sample_data.rb │ └── tasks │ └── sample.rake ├── support └── docker.md ├── test.yml ├── testing ├── Rakefile ├── docker │ └── docker-compose.yml ├── gaku_testing.gemspec └── lib │ ├── gaku │ ├── testing.rb │ └── testing │ │ ├── engine.rb │ │ ├── env.rb │ │ ├── feature_helpers.rb │ │ ├── flash_helpers.rb │ │ └── spec_helpers │ │ ├── spec_helper.rb │ │ ├── spec_helper_base.rb │ │ ├── spec_helper_controllers.rb │ │ ├── spec_helper_models.rb │ │ └── spec_helper_routing.rb │ └── gaku_testing.rb └── wait-for-it.sh /.hound.yml: -------------------------------------------------------------------------------- 1 | AsciiIdentifiers: 2 | Enabled: false 3 | 4 | AsciiComments: 5 | Enabled: false 6 | 7 | AccessorMethodName: 8 | Enabled: false 9 | 10 | LineLength: 11 | Max: 119 12 | 13 | Documentation: 14 | Enabled: false 15 | 16 | ClassAndModuleChildren: 17 | Enabled: false 18 | 19 | EmptyLinesAroundBody: 20 | Enabled: false 21 | 22 | SingleLineBlockParams: 23 | Enabled: false 24 | 25 | AllCops: 26 | Exclude: 27 | - '**/spec/dummy/**/*' 28 | - 'bin/**/*' 29 | - '**/bin/**/*' 30 | - '**/db/schema.rb' 31 | - '**/pkg/**/*' 32 | - 'pkg/**/*' 33 | - '**/config/initializers/**/*' 34 | - '**/db/migrate/**/*' 35 | - '**/lib/generators/**/*' 36 | RunRailsCops: false -------------------------------------------------------------------------------- /.rspec: -------------------------------------------------------------------------------- 1 | --colour 2 | --format documentation -------------------------------------------------------------------------------- /.rubocop.yml: -------------------------------------------------------------------------------- 1 | AsciiIdentifiers: 2 | Enabled: false 3 | 4 | AsciiComments: 5 | Enabled: false 6 | 7 | AccessorMethodName: 8 | Enabled: false 9 | 10 | LineLength: 11 | Max: 119 12 | 13 | Documentation: 14 | Enabled: false 15 | 16 | ClassAndModuleChildren: 17 | Enabled: false 18 | 19 | SingleLineBlockParams: 20 | Enabled: false 21 | 22 | AllCops: 23 | Exclude: 24 | - '**/spec/dummy/**/*' 25 | - 'bin/**/*' 26 | - '**/bin/**/*' 27 | - '**/db/schema.rb' 28 | - '**/pkg/**/*' 29 | - 'pkg/**/*' 30 | - '**/config/initializers/**/*' 31 | - '**/db/migrate/**/*' 32 | - '**/lib/generators/**/*' 33 | 34 | Rails: 35 | Enabled: true 36 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:bionic 2 | MAINTAINER Georgi Tapalilov & Rei Kagetsuki 3 | 4 | EXPOSE 3000 5 | 6 | RUN echo "nameserver 1.1.1.1" >> /etc/resolv.conf 7 | 8 | RUN apt update 9 | RUN apt upgrade -y 10 | RUN apt install -y ruby ruby-dev build-essential imagemagick libmagickcore-dev git libpq-dev postgresql-client nodejs 11 | 12 | RUN gem install rails -v 5.2.2 --no-ri --no-rdoc 13 | RUN gem install bundler --no-ri --no-rdoc 14 | 15 | ADD . /gaku 16 | WORKDIR /gaku 17 | 18 | ENV app /app 19 | ENV gaku /gaku 20 | 21 | RUN rails new $app --database=postgresql --skip-bundle 22 | 23 | WORKDIR $app 24 | 25 | RUN echo "gem 'gaku', path: '../gaku'" >> Gemfile 26 | #RUN echo "gem 'therubyracer'" >> Gemfile 27 | RUN echo "gem 'tzinfo-data'" >> Gemfile 28 | 29 | RUN bundle install 30 | 31 | RUN bundle exec rails g gaku:docker 32 | -------------------------------------------------------------------------------- /Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | 3 | eval(File.read(File.dirname(__FILE__) + '/common_gaku_dependencies.rb')) 4 | 5 | gemspec 6 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | GAKU Engine Copyright 2012 K.K. GenSouSha of Aichi, Japan 2 | All rights reserved. 3 | 4 | This software is dual licensed under the GNU GPL version 3 and the AGPL version 3. 5 | The full text of these licenses can be found here: 6 | https://gnu.org/licenses/gpl.html 7 | https://gnu.org/licenses/agpl.html 8 | 9 | When submitting code, patches, or pull requests to GAKU Engine you agree to either transfer 10 | copyright to your code to the GAKU Engine project or to abandon your copyright claims and 11 | release your code as public domain. This is to prevent an external party from controlling 12 | code incorporated into GAKU Engine in such a way as to influence the development or sub-licensing 13 | of GAKU Engine. 14 | 15 | Alternative licenses can be granted upon consultation. 16 | Please contact info@gakuengine.com for details. 17 | -------------------------------------------------------------------------------- /VERSION: -------------------------------------------------------------------------------- 1 | 0.3.0 2 | -------------------------------------------------------------------------------- /api/.gitignore: -------------------------------------------------------------------------------- 1 | .bundle/ 2 | log/*.log 3 | pkg/ 4 | coverage 5 | -------------------------------------------------------------------------------- /api/.rspec: -------------------------------------------------------------------------------- 1 | --colour 2 | --format documentation -------------------------------------------------------------------------------- /api/Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | 3 | # Declare your gem's dependencies in api.gemspec. 4 | # Bundler will treat runtime dependencies like base dependencies, and 5 | # development dependencies will be added by default to the :development group. 6 | eval(File.read(File.dirname(__FILE__) + '/../common_gaku_dependencies.rb')) 7 | eval(File.read(File.dirname(__FILE__) + '/../core/core_dependencies.rb')) 8 | 9 | gem 'gaku_core', path: '../core' 10 | gem 'gaku_testing', path: '../testing' 11 | 12 | gemspec 13 | # Declare any dependencies that are still in development here instead of in 14 | # your gemspec. These might include edge Rails or gems from your path or 15 | # Git. Remember to move these dependencies to your gemspec before releasing 16 | # your gem to rubygems.org. 17 | 18 | # To use a debugger 19 | # gem 'byebug', group: [:development, :test] 20 | -------------------------------------------------------------------------------- /api/Rakefile: -------------------------------------------------------------------------------- 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/api' 16 | Rake::Task['common:test_app'].invoke 17 | end 18 | 19 | desc 'start testing' 20 | task :start_testing do 21 | ENV['LIB_NAME'] = 'gaku/core' 22 | Rake::Task['common:start_testing'].invoke 23 | end 24 | 25 | desc 'stop testing' 26 | task :stop_testing do 27 | ENV['LIB_NAME'] = 'gaku/core' 28 | Rake::Task['common:stop_testing'].invoke 29 | end 30 | -------------------------------------------------------------------------------- /api/app/channels/application_cable/connection.rb: -------------------------------------------------------------------------------- 1 | module ApplicationCable 2 | class Connection < ActionCable::Connection::Base 3 | identified_by :user 4 | 5 | def connect 6 | self.user = find_user 7 | unless user 8 | reject_unauthorized_connection 9 | end 10 | end 11 | 12 | private 13 | 14 | def find_user 15 | Gaku::User.first 16 | # headers = { "Authorization" => request.params[:auth_token] } 17 | # Gaku::Api::AuthorizeApiRequest.call(headers).result 18 | end 19 | end 20 | end 21 | -------------------------------------------------------------------------------- /api/app/channels/application_cable/exam_channel.rb: -------------------------------------------------------------------------------- 1 | module ApplicationCable 2 | 3 | class ExamChannel < ActionCable::Channel::Base 4 | def subscribed 5 | stream_from "exam_#{params['exam_id']}" 6 | end 7 | 8 | def unsubscribed 9 | # Any cleanup needed when channel is unsubscribed 10 | end 11 | end 12 | end 13 | -------------------------------------------------------------------------------- /api/app/channels/application_cable/grading_channel.rb: -------------------------------------------------------------------------------- 1 | module ApplicationCable 2 | 3 | class GradingChannel < ActionCable::Channel::Base 4 | def subscribed 5 | stream_from "grading_exam_#{params['exam_id']}" 6 | end 7 | 8 | def unsubscribed 9 | # Any cleanup needed when channel is unsubscribed 10 | end 11 | end 12 | end 13 | -------------------------------------------------------------------------------- /api/app/controllers/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GAKUEngine/gaku/5e2f1580520c09b4f871893075a0c9b5e9f50037/api/app/controllers/.keep -------------------------------------------------------------------------------- /api/app/controllers/gaku/api/application_controller.rb: -------------------------------------------------------------------------------- 1 | class Gaku::Api::ApplicationController < ActionController::API 2 | 3 | end 4 | -------------------------------------------------------------------------------- /api/app/controllers/gaku/api/v1/class_groups/students_controller.rb: -------------------------------------------------------------------------------- 1 | module Gaku 2 | module Api 3 | module V1 4 | module ClassGroups 5 | class StudentsController < BaseController 6 | before_action :set_class_group 7 | 8 | def index 9 | @students = @class_group.students.page(params[:page ]) 10 | collection_respond_to @students, root: :students 11 | end 12 | 13 | private 14 | 15 | def set_class_group 16 | @class_group = ClassGroup.find(params[:class_group_id]) 17 | end 18 | end 19 | end 20 | end 21 | end 22 | end 23 | -------------------------------------------------------------------------------- /api/app/controllers/gaku/api/v1/contact_types_controller.rb: -------------------------------------------------------------------------------- 1 | module Gaku 2 | module Api 3 | module V1 4 | class ContactTypesController < BaseController 5 | skip_before_action :authenticate_request 6 | 7 | def index 8 | @contact_types = ContactType.all 9 | collection_respond_to @contact_types, root: :contact_types 10 | end 11 | 12 | def create 13 | @contact_types = ContactType.create!(contact_type_params) 14 | member_respond_to @contact_types 15 | end 16 | 17 | private 18 | 19 | def contact_type_params 20 | params.require(:name) 21 | params.permit(:name) 22 | end 23 | 24 | end 25 | end 26 | end 27 | end 28 | -------------------------------------------------------------------------------- /api/app/controllers/gaku/api/v1/courses/students_controller.rb: -------------------------------------------------------------------------------- 1 | module Gaku 2 | module Api 3 | module V1 4 | module Courses 5 | class StudentsController < BaseController 6 | before_action :set_course 7 | 8 | def index 9 | @students = @course.students.page(params[:page ]) 10 | collection_respond_to @students, root: :students 11 | end 12 | 13 | private 14 | 15 | def set_course 16 | @course = Course.find(params[:course_id]) 17 | end 18 | end 19 | end 20 | end 21 | end 22 | end 23 | -------------------------------------------------------------------------------- /api/app/controllers/gaku/api/v1/enrollment_statuses_controller.rb: -------------------------------------------------------------------------------- 1 | module Gaku 2 | module Api 3 | module V1 4 | class EnrollmentStatusesController < BaseController 5 | 6 | skip_before_action :authenticate_request 7 | 8 | def index 9 | @enrollment_statuses = EnrollmentStatus.all 10 | collection_respond_to @enrollment_statuses, root: :enrollment_statuses 11 | end 12 | 13 | def create 14 | @enrollment_statuses = EnrollmentStatus.create!(enrollment_status_params) 15 | member_respond_to @enrollment_statuses 16 | end 17 | 18 | private 19 | 20 | def enrollment_status_params 21 | params.require(:name) 22 | params.permit(:name) 23 | end 24 | 25 | end 26 | end 27 | end 28 | end 29 | -------------------------------------------------------------------------------- /api/app/controllers/gaku/api/v1/enrollments_controller.rb: -------------------------------------------------------------------------------- 1 | module Gaku 2 | module Api 3 | module V1 4 | class EnrollmentsController < BaseController 5 | before_action :set_enrollable 6 | 7 | def index 8 | @enrollments = @enrollable.enrollments.page(params[:page]) 9 | collection_respond_to @enrollments, root: :enrollments 10 | end 11 | 12 | private 13 | 14 | def set_enrollable 15 | resource, id = request.path.split('/').values_at(3,4) 16 | @enrollable = "gaku/#{resource}".pluralize.classify.constantize.find(id) 17 | end 18 | end 19 | end 20 | end 21 | end 22 | -------------------------------------------------------------------------------- /api/app/controllers/gaku/api/v1/exams_controller.rb: -------------------------------------------------------------------------------- 1 | module Gaku 2 | module Api 3 | module V1 4 | class ExamsController < BaseController 5 | skip_before_action :authenticate_request 6 | 7 | def index 8 | @exams = Exam.all.page(params[:page]) 9 | collection_respond_to @exams, root: :exams 10 | end 11 | 12 | end 13 | end 14 | end 15 | end 16 | -------------------------------------------------------------------------------- /api/app/controllers/gaku/api/v1/roles_controller.rb: -------------------------------------------------------------------------------- 1 | module Gaku 2 | module Api 3 | module V1 4 | class RolesController < BaseController 5 | skip_before_action :authenticate_request 6 | 7 | def index 8 | @roles = Gaku::Role.all 9 | collection_respond_to @roles, root: :roles 10 | end 11 | 12 | end 13 | end 14 | end 15 | end 16 | -------------------------------------------------------------------------------- /api/app/controllers/gaku/api/v1/statuses_controller.rb: -------------------------------------------------------------------------------- 1 | module Gaku 2 | module Api 3 | module V1 4 | class StatusesController < ActionController::API 5 | 6 | def show 7 | if msgpack_request? 8 | render msgpack: { status: :running } 9 | 10 | else 11 | render json: { status: :running } 12 | end 13 | end 14 | 15 | private 16 | 17 | def msgpack_request? 18 | request.format.to_sym == :msgpack 19 | end 20 | 21 | end 22 | end 23 | end 24 | end 25 | -------------------------------------------------------------------------------- /api/app/controllers/gaku/api/v1/students/addresses_controller.rb: -------------------------------------------------------------------------------- 1 | module Gaku 2 | module Api 3 | module V1 4 | module Students 5 | class AddressesController < BaseController 6 | 7 | before_action :set_student 8 | 9 | def index 10 | @addresses = @student.addresses 11 | collection_respond_to @addresses, root: :addresses 12 | end 13 | 14 | private 15 | 16 | def set_student 17 | @student = Gaku::Student.find(params[:student_id]) 18 | end 19 | 20 | end 21 | end 22 | end 23 | end 24 | end 25 | -------------------------------------------------------------------------------- /api/app/controllers/gaku/api/v1/students/class_groups_controller.rb: -------------------------------------------------------------------------------- 1 | module Gaku 2 | module Api 3 | module V1 4 | module Students 5 | class ClassGroupsController < BaseController 6 | 7 | before_action :set_student 8 | 9 | def index 10 | @class_groups = @student.class_groups 11 | respond_to do |format| 12 | format.json { render json: @class_groups, root: :class_groups, adapter: :json } 13 | format.msgpack { render msgpack: @class_groups, root: :class_groups, adapter: :json } 14 | end 15 | end 16 | 17 | private 18 | 19 | def set_student 20 | @student = Gaku::Student.find(params[:student_id]) 21 | end 22 | 23 | end 24 | end 25 | end 26 | end 27 | end 28 | -------------------------------------------------------------------------------- /api/app/controllers/gaku/api/v1/students/courses_controller.rb: -------------------------------------------------------------------------------- 1 | module Gaku 2 | module Api 3 | module V1 4 | module Students 5 | class CoursesController < BaseController 6 | 7 | before_action :set_student 8 | 9 | def index 10 | @courses = @student.courses 11 | respond_to do |format| 12 | format.json { render json: @courses, root: :courses, adapter: :json } 13 | format.msgpack { render msgpack: @courses, root: :courses, adapter: :json } 14 | end 15 | end 16 | 17 | private 18 | 19 | def set_student 20 | @student = Gaku::Student.find(params[:student_id]) 21 | end 22 | 23 | end 24 | end 25 | end 26 | end 27 | end 28 | -------------------------------------------------------------------------------- /api/app/controllers/gaku/api/v1/students/exam_sessions_controller.rb: -------------------------------------------------------------------------------- 1 | module Gaku 2 | module Api 3 | module V1 4 | module Students 5 | class ExamSessionsController < BaseController 6 | 7 | before_action :set_student 8 | 9 | def index 10 | @exam_sessions = @student.exam_sessions 11 | respond_to do |format| 12 | format.json { render json: @exam_sessions, root: :exam_sessions, adapter: :json } 13 | format.msgpack { render msgpack: @exam_sessions, root: :exam_sessions, adapter: :json } 14 | end 15 | end 16 | 17 | private 18 | 19 | def set_student 20 | @student = Gaku::Student.find(params[:student_id]) 21 | end 22 | 23 | end 24 | end 25 | end 26 | end 27 | end 28 | -------------------------------------------------------------------------------- /api/app/controllers/gaku/api/v1/students/guardians_controller.rb: -------------------------------------------------------------------------------- 1 | module Gaku 2 | module Api 3 | module V1 4 | module Students 5 | class GuardiansController < BaseController 6 | 7 | before_action :set_student 8 | 9 | def index 10 | @guardians = @student.guardians 11 | respond_to do |format| 12 | format.json { render json: @guardians, root: :guardians, adapter: :json } 13 | format.msgpack { render msgpack: @guardians, root: :guardians, adapter: :json } 14 | end 15 | end 16 | 17 | private 18 | 19 | def set_student 20 | @student = Gaku::Student.find(params[:student_id]) 21 | end 22 | 23 | end 24 | end 25 | end 26 | end 27 | end 28 | -------------------------------------------------------------------------------- /api/app/controllers/gaku/api/v1/students/student_guardians_controller.rb: -------------------------------------------------------------------------------- 1 | module Gaku 2 | module Api 3 | module V1 4 | module Students 5 | class StudentGuardiansController < BaseController 6 | 7 | before_action :set_guardian 8 | before_action :set_student 9 | 10 | def create 11 | @student.guardians << @guardian 12 | member_respond_to @guardian 13 | end 14 | 15 | private 16 | 17 | def set_guardian 18 | @guardian = Guardian.find(params[:guardian_id]) 19 | end 20 | 21 | def set_student 22 | @student = Student.find(params[:student_id]) 23 | end 24 | 25 | end 26 | end 27 | end 28 | end 29 | end 30 | -------------------------------------------------------------------------------- /api/app/controllers/gaku/api/v1/syllabuses/courses_controlle.rb: -------------------------------------------------------------------------------- 1 | module Gaku 2 | module Api 3 | module V1 4 | module Sylabuses 5 | class CoursesController < BaseController 6 | 7 | before_action :set_syllabus 8 | 9 | def index 10 | @courses = @syllabus.courses 11 | respond_to do |format| 12 | format.json { render json: @courses, root: :courses, adapter: :json } 13 | format.msgpack { render msgpack: @courses, root: :courses, adapter: :json } 14 | end 15 | end 16 | 17 | private 18 | 19 | def set_syllabus 20 | @syllabus = Gaku::Syllabus.find(params[:syllabus_id]) 21 | end 22 | 23 | end 24 | end 25 | end 26 | end 27 | end 28 | -------------------------------------------------------------------------------- /api/app/controllers/gaku/api/v1/syllabuses/exams_controller.rb: -------------------------------------------------------------------------------- 1 | module Gaku 2 | module Api 3 | module V1 4 | module Syllabuses 5 | class ExamsController < BaseController 6 | 7 | before_action :set_syllabus 8 | 9 | def index 10 | @exams = @syllabus.exams 11 | respond_to do |format| 12 | format.json { render json: @exams, root: :exams, adapter: :json } 13 | format.msgpack { render msgpack: @exams, root: :exams, adapter: :json } 14 | end 15 | end 16 | 17 | private 18 | 19 | def set_syllabus 20 | @syllabus = Gaku::Syllabus.find(params[:syllabus_id]) 21 | end 22 | 23 | end 24 | end 25 | end 26 | end 27 | end 28 | -------------------------------------------------------------------------------- /api/app/controllers/gaku/api/v1/users/user_roles_controller.rb: -------------------------------------------------------------------------------- 1 | module Gaku 2 | module Api 3 | module V1 4 | module Users 5 | class UserRolesController < BaseController 6 | before_action :set_role 7 | before_action :set_user 8 | 9 | def create 10 | @user.roles << @role 11 | member_respond_to @role 12 | end 13 | 14 | private 15 | 16 | def set_role 17 | @role = Role.find(params[:role_id]) 18 | end 19 | 20 | def set_user 21 | @user = User.find(params[:user_id]) 22 | end 23 | 24 | end 25 | end 26 | end 27 | end 28 | end 29 | -------------------------------------------------------------------------------- /api/app/mailers/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GAKUEngine/gaku/5e2f1580520c09b4f871893075a0c9b5e9f50037/api/app/mailers/.keep -------------------------------------------------------------------------------- /api/app/models/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GAKUEngine/gaku/5e2f1580520c09b4f871893075a0c9b5e9f50037/api/app/models/.keep -------------------------------------------------------------------------------- /api/app/serializers/gaku/address_serializer.rb: -------------------------------------------------------------------------------- 1 | module Gaku 2 | class AddressSerializer < ActiveModel::Serializer 3 | attributes :id, :address1, :address2, :city, :zipcode, :title, :country_id, :state_id 4 | end 5 | end 6 | -------------------------------------------------------------------------------- /api/app/serializers/gaku/class_group_serializer.rb: -------------------------------------------------------------------------------- 1 | 2 | module Gaku 3 | class ClassGroupSerializer < ActiveModel::Serializer 4 | attributes %i( id name grade homeroom notes_count faculty_id created_at updated_at enrollments_count ) 5 | end 6 | end 7 | -------------------------------------------------------------------------------- /api/app/serializers/gaku/contact_serializer.rb: -------------------------------------------------------------------------------- 1 | module Gaku 2 | class ContactSerializer < ActiveModel::Serializer 3 | attributes %i( id data ) 4 | attribute :student_id, if: :student_contact? 5 | 6 | belongs_to :contact_type 7 | 8 | def student_id 9 | object.contactable_id 10 | end 11 | 12 | def student_contact? 13 | object.contactable_type == 'Gaku::Student' 14 | end 15 | end 16 | end 17 | -------------------------------------------------------------------------------- /api/app/serializers/gaku/contact_type_serializer.rb: -------------------------------------------------------------------------------- 1 | module Gaku 2 | class ContactTypeSerializer < ActiveModel::Serializer 3 | attributes %i( id name ) 4 | end 5 | end 6 | -------------------------------------------------------------------------------- /api/app/serializers/gaku/course_serializer.rb: -------------------------------------------------------------------------------- 1 | module Gaku 2 | class CourseSerializer < ActiveModel::Serializer 3 | attributes %i( id name code notes_count students_count faculty_id 4 | syllabus_id class_group_id enrollments_count 5 | ) 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /api/app/serializers/gaku/enrollment_serializer.rb: -------------------------------------------------------------------------------- 1 | module Gaku 2 | class EnrollmentSerializer < ActiveModel::Serializer 3 | attributes %i( id student_id seat_number ) 4 | attribute :course_id, if: :course_enrollment? 5 | 6 | def course_id 7 | object.enrollable_id 8 | end 9 | 10 | def course_enrollment? 11 | object.course_type? 12 | end 13 | end 14 | end 15 | -------------------------------------------------------------------------------- /api/app/serializers/gaku/enrollment_status_serializer.rb: -------------------------------------------------------------------------------- 1 | module Gaku 2 | class EnrollmentStatusSerializer < ActiveModel::Serializer 3 | attributes :id, :code, :active, :immutable 4 | end 5 | end 6 | -------------------------------------------------------------------------------- /api/app/serializers/gaku/exam_portion_score_serializer.rb: -------------------------------------------------------------------------------- 1 | module Gaku 2 | class ExamPortionScoreSerializer < ActiveModel::Serializer 3 | attributes %i( id score exam_portion_id student_id) 4 | end 5 | end 6 | -------------------------------------------------------------------------------- /api/app/serializers/gaku/exam_portion_serializer.rb: -------------------------------------------------------------------------------- 1 | module Gaku 2 | class ExamPortionSerializer < ActiveModel::Serializer 3 | attributes %i( id name max_score exam_id ) 4 | end 5 | end 6 | -------------------------------------------------------------------------------- /api/app/serializers/gaku/exam_serializer.rb: -------------------------------------------------------------------------------- 1 | module Gaku 2 | class ExamSerializer < ActiveModel::Serializer 3 | attributes %i( id name ) 4 | end 5 | end 6 | -------------------------------------------------------------------------------- /api/app/serializers/gaku/exam_session_serializer.rb: -------------------------------------------------------------------------------- 1 | module Gaku 2 | class ExamSessionSerializer < ActiveModel::Serializer 3 | attributes %i( id session_time name exam_id session_start enrollments_count ) 4 | end 5 | end 6 | -------------------------------------------------------------------------------- /api/app/serializers/gaku/extracurricular_activity_serializer.rb: -------------------------------------------------------------------------------- 1 | module Gaku 2 | class ExtracurricularActivitySerializer < ActiveModel::Serializer 3 | attributes %i( id name created_at updated_at enrollments_count ) 4 | end 5 | end 6 | -------------------------------------------------------------------------------- /api/app/serializers/gaku/guardian_serializer.rb: -------------------------------------------------------------------------------- 1 | module Gaku 2 | class GuardianSerializer < ActiveModel::Serializer 3 | attributes %i( id name surname middle_name name_reading middle_name_reading surname_reading 4 | gender birth_date relationship picture_file_name picture_content_type picture_file_size 5 | picture_updated_at primary_address primary_contact addresses_count contacts_count user_id 6 | created_at updated_at 7 | ) 8 | end 9 | end 10 | -------------------------------------------------------------------------------- /api/app/serializers/gaku/role_serializer.rb: -------------------------------------------------------------------------------- 1 | module Gaku 2 | class RoleSerializer < ActiveModel::Serializer 3 | attributes :id, :name 4 | end 5 | end 6 | -------------------------------------------------------------------------------- /api/app/serializers/gaku/syllabus_serializer.rb: -------------------------------------------------------------------------------- 1 | module Gaku 2 | class SyllabusSerializer < ActiveModel::Serializer 3 | attributes %i( id name code description credits hours created_at updated_at ) 4 | end 5 | end 6 | -------------------------------------------------------------------------------- /api/app/serializers/gaku/user_serializer.rb: -------------------------------------------------------------------------------- 1 | module Gaku 2 | class UserSerializer < ActiveModel::Serializer 3 | attributes :id, :username, :email, :disabled, :disabled_until 4 | has_many :roles 5 | end 6 | end 7 | -------------------------------------------------------------------------------- /api/app/services/gaku/api/create_syllabus_service.rb: -------------------------------------------------------------------------------- 1 | class Gaku::Api::CreateSyllabusService 2 | prepend SimpleCommand 3 | 4 | attr_accessor :params, :user 5 | 6 | def initialize(user, params = {}) 7 | @user = user 8 | @params = params 9 | end 10 | 11 | def call 12 | @syllabus = Gaku::Syllabus.new(params) 13 | if @syllabus.save 14 | if user.role?('teacher') 15 | @syllabus.teachers << user.teacher 16 | end 17 | return @syllabus 18 | else 19 | errors.add(:base, @syllabus.errors.full_messages) 20 | end 21 | nil 22 | end 23 | 24 | 25 | 26 | end 27 | -------------------------------------------------------------------------------- /api/app/services/gaku/api/student_create_service.rb: -------------------------------------------------------------------------------- 1 | class Gaku::Api::StudentCreateService 2 | prepend SimpleCommand 3 | attr_accessor :student_params 4 | 5 | def initialize(student_params) 6 | @student_params = student_params 7 | end 8 | 9 | def call 10 | student = Gaku::Student.where(required_attributes).first_or_create(student_params) 11 | 12 | if student.persisted? 13 | return student 14 | else 15 | errors.add(:base, student.errors.full_messages) 16 | end 17 | 18 | end 19 | 20 | def required_attributes 21 | { 22 | name: student_params[:name], 23 | surname: student_params[:surname], 24 | birth_date: student_params[:birth_date] 25 | } 26 | end 27 | end 28 | -------------------------------------------------------------------------------- /api/bin/rails: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | # This command will automatically be run when you run "rails" with Rails gems 3 | # installed from the root of your application. 4 | 5 | ENGINE_ROOT = File.expand_path('../..', __FILE__) 6 | ENGINE_PATH = File.expand_path('../../lib/api/engine', __FILE__) 7 | 8 | # Set up gems listed in the Gemfile. 9 | ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) 10 | require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE']) 11 | 12 | require 'rails/all' 13 | require 'rails/engine/commands' 14 | -------------------------------------------------------------------------------- /api/config/initializers/kaminari.rb: -------------------------------------------------------------------------------- 1 | Kaminari.configure do |config| 2 | config.default_per_page = 100 3 | end 4 | -------------------------------------------------------------------------------- /api/config/initializers/mime_types.rb: -------------------------------------------------------------------------------- 1 | Mime::Type.register "application/msgpack", :msgpack 2 | -------------------------------------------------------------------------------- /api/gaku_api.gemspec: -------------------------------------------------------------------------------- 1 | require_relative '../common_gaku_gemspec_mixin' 2 | 3 | Gem::Specification.new do |s| 4 | set_gaku_gemspec_shared s 5 | 6 | s.name = 'gaku_api' 7 | s.summary = 'GAKU Engine API module' 8 | s.description = 'API functionality for GAKU Engine. See https://github.com/GAKUEngine/gaku' 9 | 10 | s.files = Dir.glob("{app,config,db,lib}/**/*") + 11 | [ 12 | 'Rakefile', 13 | 'gaku_api.gemspec' 14 | ] 15 | 16 | s.add_dependency 'simple_command' 17 | s.add_dependency 'jwt' 18 | s.add_dependency 'active_model_serializers' 19 | s.add_dependency 'msgpack_rails' 20 | s.add_dependency 'kaminari' 21 | 22 | s.add_dependency 'gaku_core', s.version 23 | 24 | s.add_development_dependency 'gaku_testing', s.version 25 | end 26 | -------------------------------------------------------------------------------- /api/lib/gaku/api.rb: -------------------------------------------------------------------------------- 1 | require 'gaku_core' 2 | require 'simple_command' 3 | require 'jwt' 4 | require 'active_model_serializers' 5 | require 'msgpack_rails' 6 | require 'kaminari' 7 | 8 | module Gaku 9 | 10 | module Api 11 | end 12 | 13 | end 14 | 15 | require 'gaku/api/engine' 16 | -------------------------------------------------------------------------------- /api/lib/gaku/api/version.rb: -------------------------------------------------------------------------------- 1 | module Gaku 2 | module Api 3 | VERSION = '0.2.4' 4 | end 5 | end 6 | -------------------------------------------------------------------------------- /api/lib/gaku_api.rb: -------------------------------------------------------------------------------- 1 | require 'gaku/api' 2 | -------------------------------------------------------------------------------- /api/lib/json_web_token.rb: -------------------------------------------------------------------------------- 1 | class JsonWebToken 2 | class << self 3 | def encode(payload, exp:, jti:, secret:) 4 | payload[:exp] = exp.to_i 5 | payload[:jti] = jti 6 | JWT.encode(payload, secret) 7 | end 8 | 9 | def decode(token, refresh: false) 10 | secret = extract_secret(token, refresh: refresh) 11 | body = JWT.decode(token, secret)[0] 12 | HashWithIndifferentAccess.new body 13 | rescue 14 | nil 15 | end 16 | 17 | def extract_secret(token, refresh: false) 18 | key = JSON.parse(Base64.decode64 token.split('.')[1])['jti'] 19 | $redis.get("token:#{key}").tap do 20 | $redis.del("token:#{key}") if refresh 21 | end 22 | end 23 | end 24 | end 25 | -------------------------------------------------------------------------------- /api/lib/tasks/api_tasks.rake: -------------------------------------------------------------------------------- 1 | # desc "Explaining what the task does" 2 | # task :api do 3 | # # Task goes here 4 | # end 5 | -------------------------------------------------------------------------------- /api/spec/spec_helper.rb: -------------------------------------------------------------------------------- 1 | ENV['RAILS_ENV'] ||= 'test' 2 | require File.expand_path('../dummy/config/environment', __FILE__) 3 | 4 | require 'gaku/testing/spec_helpers/spec_helper' 5 | Dir["#{File.dirname(__FILE__)}/support/features/**/*.rb"].each { |f| require f } 6 | 7 | require 'simplecov' 8 | SimpleCov.start do 9 | add_filter '/spec/' 10 | add_group 'Controllers', 'app/controllers' 11 | end 12 | 13 | RSpec.configure do |config| 14 | config.include Rails.application.routes.url_helpers, type: :request 15 | end 16 | -------------------------------------------------------------------------------- /api/spec/spec_helper_requests.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | require 'support/request_helpers' 3 | RSpec.configure do |config| 4 | 5 | config.include RequestHelpers, type: :request 6 | config.include Rails.application.routes.url_helpers 7 | 8 | end 9 | -------------------------------------------------------------------------------- /api/spec/support/fixtures/student_index.msgpack: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GAKUEngine/gaku/5e2f1580520c09b4f871893075a0c9b5e9f50037/api/spec/support/fixtures/student_index.msgpack -------------------------------------------------------------------------------- /common_gaku_dependencies.rb: -------------------------------------------------------------------------------- 1 | group :test do 2 | gem 'capybara', '3.13.2' 3 | gem 'poltergeist', '1.18.1' 4 | gem 'handy_controller_helpers', '0.0.3' 5 | gem 'simplecov', require: false 6 | end 7 | -------------------------------------------------------------------------------- /common_gaku_gemspec_mixin.rb: -------------------------------------------------------------------------------- 1 | def set_gaku_gemspec_shared(s) 2 | 3 | s.version = File.read(File.expand_path('../VERSION', __FILE__)).strip 4 | 5 | s.authors = ['Rei Kagetsuki', 'Georgi Tapalilov', 'Nakaya Yukiharu'] 6 | s.email = 'info@gakuengine.com' 7 | s.homepage = 'http://www.gakuengine.com' 8 | s.licenses = ['GPL-3.0', 'AGPL-3.0'] 9 | end 10 | -------------------------------------------------------------------------------- /core/.rspec: -------------------------------------------------------------------------------- 1 | --colour 2 | --format documentation -------------------------------------------------------------------------------- /core/Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | 3 | eval(File.read(File.dirname(__FILE__) + '/core_dependencies.rb')) 4 | 5 | gem 'activemodel-serializers-xml' 6 | 7 | gemspec 8 | -------------------------------------------------------------------------------- /core/Rakefile: -------------------------------------------------------------------------------- 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 18 | 19 | desc 'start testing' 20 | task :start_testing do 21 | ENV['LIB_NAME'] = 'gaku/core' 22 | Rake::Task['common:start_testing'].invoke 23 | end 24 | 25 | desc 'stop testing' 26 | task :stop_testing do 27 | ENV['LIB_NAME'] = 'gaku/core' 28 | Rake::Task['common:stop_testing'].invoke 29 | end 30 | -------------------------------------------------------------------------------- /core/app/assets/images/background.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GAKUEngine/gaku/5e2f1580520c09b4f871893075a0c9b5e9f50037/core/app/assets/images/background.jpg -------------------------------------------------------------------------------- /core/app/assets/images/check.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GAKUEngine/gaku/5e2f1580520c09b4f871893075a0c9b5e9f50037/core/app/assets/images/check.png -------------------------------------------------------------------------------- /core/app/assets/images/cross.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GAKUEngine/gaku/5e2f1580520c09b4f871893075a0c9b5e9f50037/core/app/assets/images/cross.png -------------------------------------------------------------------------------- /core/app/assets/images/down_arrow.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GAKUEngine/gaku/5e2f1580520c09b4f871893075a0c9b5e9f50037/core/app/assets/images/down_arrow.gif -------------------------------------------------------------------------------- /core/app/assets/images/elements/highlight.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GAKUEngine/gaku/5e2f1580520c09b4f871893075a0c9b5e9f50037/core/app/assets/images/elements/highlight.png -------------------------------------------------------------------------------- /core/app/assets/images/elements/toolbar1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GAKUEngine/gaku/5e2f1580520c09b4f871893075a0c9b5e9f50037/core/app/assets/images/elements/toolbar1.png -------------------------------------------------------------------------------- /core/app/assets/images/gaku-logo-gear.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GAKUEngine/gaku/5e2f1580520c09b4f871893075a0c9b5e9f50037/core/app/assets/images/gaku-logo-gear.png -------------------------------------------------------------------------------- /core/app/assets/images/gaku-logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GAKUEngine/gaku/5e2f1580520c09b4f871893075a0c9b5e9f50037/core/app/assets/images/gaku-logo.png -------------------------------------------------------------------------------- /core/app/assets/images/gakuengine.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GAKUEngine/gaku/5e2f1580520c09b4f871893075a0c9b5e9f50037/core/app/assets/images/gakuengine.png -------------------------------------------------------------------------------- /core/app/assets/images/gakuengine20.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GAKUEngine/gaku/5e2f1580520c09b4f871893075a0c9b5e9f50037/core/app/assets/images/gakuengine20.png -------------------------------------------------------------------------------- /core/app/assets/images/icon-chair.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GAKUEngine/gaku/5e2f1580520c09b4f871893075a0c9b5e9f50037/core/app/assets/images/icon-chair.png -------------------------------------------------------------------------------- /core/app/assets/images/images/ui-bg_flat_30_cccccc_40x100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GAKUEngine/gaku/5e2f1580520c09b4f871893075a0c9b5e9f50037/core/app/assets/images/images/ui-bg_flat_30_cccccc_40x100.png -------------------------------------------------------------------------------- /core/app/assets/images/images/ui-bg_flat_50_5c5c5c_40x100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GAKUEngine/gaku/5e2f1580520c09b4f871893075a0c9b5e9f50037/core/app/assets/images/images/ui-bg_flat_50_5c5c5c_40x100.png -------------------------------------------------------------------------------- /core/app/assets/images/images/ui-bg_glass_20_555555_1x400.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GAKUEngine/gaku/5e2f1580520c09b4f871893075a0c9b5e9f50037/core/app/assets/images/images/ui-bg_glass_20_555555_1x400.png -------------------------------------------------------------------------------- /core/app/assets/images/images/ui-bg_glass_40_0078a3_1x400.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GAKUEngine/gaku/5e2f1580520c09b4f871893075a0c9b5e9f50037/core/app/assets/images/images/ui-bg_glass_40_0078a3_1x400.png -------------------------------------------------------------------------------- /core/app/assets/images/images/ui-bg_glass_40_ffc73d_1x400.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GAKUEngine/gaku/5e2f1580520c09b4f871893075a0c9b5e9f50037/core/app/assets/images/images/ui-bg_glass_40_ffc73d_1x400.png -------------------------------------------------------------------------------- /core/app/assets/images/images/ui-bg_gloss-wave_25_333333_500x100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GAKUEngine/gaku/5e2f1580520c09b4f871893075a0c9b5e9f50037/core/app/assets/images/images/ui-bg_gloss-wave_25_333333_500x100.png -------------------------------------------------------------------------------- /core/app/assets/images/images/ui-bg_highlight-soft_80_eeeeee_1x100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GAKUEngine/gaku/5e2f1580520c09b4f871893075a0c9b5e9f50037/core/app/assets/images/images/ui-bg_highlight-soft_80_eeeeee_1x100.png -------------------------------------------------------------------------------- /core/app/assets/images/images/ui-bg_inset-soft_25_000000_1x100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GAKUEngine/gaku/5e2f1580520c09b4f871893075a0c9b5e9f50037/core/app/assets/images/images/ui-bg_inset-soft_25_000000_1x100.png -------------------------------------------------------------------------------- /core/app/assets/images/images/ui-bg_inset-soft_30_f58400_1x100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GAKUEngine/gaku/5e2f1580520c09b4f871893075a0c9b5e9f50037/core/app/assets/images/images/ui-bg_inset-soft_30_f58400_1x100.png -------------------------------------------------------------------------------- /core/app/assets/images/images/ui-icons_222222_256x240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GAKUEngine/gaku/5e2f1580520c09b4f871893075a0c9b5e9f50037/core/app/assets/images/images/ui-icons_222222_256x240.png -------------------------------------------------------------------------------- /core/app/assets/images/images/ui-icons_4b8e0b_256x240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GAKUEngine/gaku/5e2f1580520c09b4f871893075a0c9b5e9f50037/core/app/assets/images/images/ui-icons_4b8e0b_256x240.png -------------------------------------------------------------------------------- /core/app/assets/images/images/ui-icons_a83300_256x240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GAKUEngine/gaku/5e2f1580520c09b4f871893075a0c9b5e9f50037/core/app/assets/images/images/ui-icons_a83300_256x240.png -------------------------------------------------------------------------------- /core/app/assets/images/images/ui-icons_cccccc_256x240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GAKUEngine/gaku/5e2f1580520c09b4f871893075a0c9b5e9f50037/core/app/assets/images/images/ui-icons_cccccc_256x240.png -------------------------------------------------------------------------------- /core/app/assets/images/images/ui-icons_ffffff_256x240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GAKUEngine/gaku/5e2f1580520c09b4f871893075a0c9b5e9f50037/core/app/assets/images/images/ui-icons_ffffff_256x240.png -------------------------------------------------------------------------------- /core/app/assets/images/missing_original.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GAKUEngine/gaku/5e2f1580520c09b4f871893075a0c9b5e9f50037/core/app/assets/images/missing_original.png -------------------------------------------------------------------------------- /core/app/assets/images/missing_thumb.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GAKUEngine/gaku/5e2f1580520c09b4f871893075a0c9b5e9f50037/core/app/assets/images/missing_thumb.png -------------------------------------------------------------------------------- /core/app/assets/images/rails.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GAKUEngine/gaku/5e2f1580520c09b4f871893075a0c9b5e9f50037/core/app/assets/images/rails.png -------------------------------------------------------------------------------- /core/app/assets/images/raw/GAKU Colors.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GAKUEngine/gaku/5e2f1580520c09b4f871893075a0c9b5e9f50037/core/app/assets/images/raw/GAKU Colors.png -------------------------------------------------------------------------------- /core/app/assets/images/themes/gakuengine/images/ui-bg_flat_65_ffffff_40x100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GAKUEngine/gaku/5e2f1580520c09b4f871893075a0c9b5e9f50037/core/app/assets/images/themes/gakuengine/images/ui-bg_flat_65_ffffff_40x100.png -------------------------------------------------------------------------------- /core/app/assets/images/themes/gakuengine/images/ui-bg_highlight-hard_100_f9f9f9_1x100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GAKUEngine/gaku/5e2f1580520c09b4f871893075a0c9b5e9f50037/core/app/assets/images/themes/gakuengine/images/ui-bg_highlight-hard_100_f9f9f9_1x100.png -------------------------------------------------------------------------------- /core/app/assets/images/themes/gakuengine/images/ui-bg_highlight-hard_40_aaaaaa_1x100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GAKUEngine/gaku/5e2f1580520c09b4f871893075a0c9b5e9f50037/core/app/assets/images/themes/gakuengine/images/ui-bg_highlight-hard_40_aaaaaa_1x100.png -------------------------------------------------------------------------------- /core/app/assets/images/themes/gakuengine/images/ui-bg_highlight-soft_50_aaaaaa_1x100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GAKUEngine/gaku/5e2f1580520c09b4f871893075a0c9b5e9f50037/core/app/assets/images/themes/gakuengine/images/ui-bg_highlight-soft_50_aaaaaa_1x100.png -------------------------------------------------------------------------------- /core/app/assets/images/themes/gakuengine/images/ui-bg_inset-hard_40_111111_1x100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GAKUEngine/gaku/5e2f1580520c09b4f871893075a0c9b5e9f50037/core/app/assets/images/themes/gakuengine/images/ui-bg_inset-hard_40_111111_1x100.png -------------------------------------------------------------------------------- /core/app/assets/images/themes/gakuengine/images/ui-bg_inset-hard_45_cd0a0a_1x100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GAKUEngine/gaku/5e2f1580520c09b4f871893075a0c9b5e9f50037/core/app/assets/images/themes/gakuengine/images/ui-bg_inset-hard_45_cd0a0a_1x100.png -------------------------------------------------------------------------------- /core/app/assets/images/themes/gakuengine/images/ui-bg_inset-hard_55_165e83_1x100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GAKUEngine/gaku/5e2f1580520c09b4f871893075a0c9b5e9f50037/core/app/assets/images/themes/gakuengine/images/ui-bg_inset-hard_55_165e83_1x100.png -------------------------------------------------------------------------------- /core/app/assets/images/themes/gakuengine/images/ui-bg_inset-soft_55_00a3af_1x100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GAKUEngine/gaku/5e2f1580520c09b4f871893075a0c9b5e9f50037/core/app/assets/images/themes/gakuengine/images/ui-bg_inset-soft_55_00a3af_1x100.png -------------------------------------------------------------------------------- /core/app/assets/images/themes/gakuengine/images/ui-bg_inset-soft_99_00a3af_1x100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GAKUEngine/gaku/5e2f1580520c09b4f871893075a0c9b5e9f50037/core/app/assets/images/themes/gakuengine/images/ui-bg_inset-soft_99_00a3af_1x100.png -------------------------------------------------------------------------------- /core/app/assets/images/themes/gakuengine/images/ui-icons_222222_256x240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GAKUEngine/gaku/5e2f1580520c09b4f871893075a0c9b5e9f50037/core/app/assets/images/themes/gakuengine/images/ui-icons_222222_256x240.png -------------------------------------------------------------------------------- /core/app/assets/images/themes/gakuengine/images/ui-icons_70f000_256x240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GAKUEngine/gaku/5e2f1580520c09b4f871893075a0c9b5e9f50037/core/app/assets/images/themes/gakuengine/images/ui-icons_70f000_256x240.png -------------------------------------------------------------------------------- /core/app/assets/images/themes/gakuengine/images/ui-icons_bbbbbb_256x240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GAKUEngine/gaku/5e2f1580520c09b4f871893075a0c9b5e9f50037/core/app/assets/images/themes/gakuengine/images/ui-icons_bbbbbb_256x240.png -------------------------------------------------------------------------------- /core/app/assets/images/themes/gakuengine/images/ui-icons_ededed_256x240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GAKUEngine/gaku/5e2f1580520c09b4f871893075a0c9b5e9f50037/core/app/assets/images/themes/gakuengine/images/ui-icons_ededed_256x240.png -------------------------------------------------------------------------------- /core/app/assets/images/themes/gakuengine/images/ui-icons_ffcf29_256x240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GAKUEngine/gaku/5e2f1580520c09b4f871893075a0c9b5e9f50037/core/app/assets/images/themes/gakuengine/images/ui-icons_ffcf29_256x240.png -------------------------------------------------------------------------------- /core/app/assets/images/themes/gakuengine/images/ui-icons_ffffff_256x240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GAKUEngine/gaku/5e2f1580520c09b4f871893075a0c9b5e9f50037/core/app/assets/images/themes/gakuengine/images/ui-icons_ffffff_256x240.png -------------------------------------------------------------------------------- /core/app/assets/images/tick.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GAKUEngine/gaku/5e2f1580520c09b4f871893075a0c9b5e9f50037/core/app/assets/images/tick.png -------------------------------------------------------------------------------- /core/app/assets/images/ui-bg_flat_75_ffffff_40x100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GAKUEngine/gaku/5e2f1580520c09b4f871893075a0c9b5e9f50037/core/app/assets/images/ui-bg_flat_75_ffffff_40x100.png -------------------------------------------------------------------------------- /core/app/assets/images/up_arrow.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GAKUEngine/gaku/5e2f1580520c09b4f871893075a0c9b5e9f50037/core/app/assets/images/up_arrow.gif -------------------------------------------------------------------------------- /core/app/assets/javascripts/gaku/courses.js.coffee: -------------------------------------------------------------------------------- 1 | ready = -> 2 | 3 | self = this 4 | 5 | class CoursesController 6 | edit: -> 7 | self.app.student_chooser() 8 | 9 | grading: -> 10 | $('.edit_exam_portion_score').find('input').on 'blur', -> 11 | $(@).parent().submit() 12 | 13 | faye = new Faye.Client 'http://localhost:9292/faye' 14 | faye.subscribe '/messages/new', (data) -> 15 | eval(data) 16 | 17 | @app.courses = new CoursesController 18 | 19 | $(document).ready(ready) 20 | $(document).on('page:load', ready) 21 | -------------------------------------------------------------------------------- /core/app/assets/javascripts/gaku/exams.js.coffee: -------------------------------------------------------------------------------- 1 | ready = -> 2 | 3 | class ExamsController 4 | init: -> 5 | $('.exam-portion-weight').on 'change', -> 6 | $(@).parent('form').submit() 7 | 8 | $('#new-exam-portion-attachment-link').on 'click', (e)-> 9 | e.preventDefault() 10 | $('#new-exam-portion-attachment-form').slide() 11 | 12 | # $(document).ready -> 13 | # $(document).on 'click','#exam_use_weighting', -> 14 | # if $(@).is ':checked' 15 | # $('#exam_weight').attr 'class','validate[required, custom[integer]min[0]] span12' 16 | # else 17 | # $('#exam_weight').attr 'class','span12' 18 | # $('.exam_weightformError').remove() 19 | 20 | @app.exams = new ExamsController 21 | 22 | $(document).ready(ready) 23 | $(document).on('page:load', ready) 24 | -------------------------------------------------------------------------------- /core/app/controllers/gaku/courses/exams/exam_portion_scores_controller.rb: -------------------------------------------------------------------------------- 1 | module Gaku 2 | class Courses::Exams::ExamPortionScoresController < GakuController 3 | respond_to :js 4 | 5 | def update 6 | @exam_portion_score = ExamPortionScore.find(params[:id]) 7 | @exam_portion_score.update_attributes(exam_portion_score_params) 8 | 9 | respond_with @exam_portion_score 10 | end 11 | 12 | private 13 | 14 | def exam_portion_score_params 15 | params.require(:exam_portion_score).permit(attributes) 16 | end 17 | 18 | def attributes 19 | %i[score] 20 | end 21 | end 22 | end 23 | -------------------------------------------------------------------------------- /core/app/decorators/gaku/course_decorator.rb: -------------------------------------------------------------------------------- 1 | module Gaku 2 | class CourseDecorator < Draper::Decorator 3 | decorates 'Gaku::Course' 4 | delegate_all 5 | 6 | def code_with_syllabus_name 7 | if object.syllabus_name 8 | "#{object.syllabus_name}-#{object.code}" 9 | else 10 | object.code 11 | end 12 | end 13 | end 14 | end 15 | -------------------------------------------------------------------------------- /core/app/decorators/gaku/guardian_decorator.rb: -------------------------------------------------------------------------------- 1 | module Gaku 2 | class GuardianDecorator < PersonDecorator 3 | decorates 'Gaku::Guardian' 4 | delegate_all 5 | end 6 | end 7 | -------------------------------------------------------------------------------- /core/app/decorators/gaku/teacher_decorator.rb: -------------------------------------------------------------------------------- 1 | module Gaku 2 | class TeacherDecorator < PersonDecorator 3 | decorates 'Gaku::Teacher' 4 | delegate_all 5 | end 6 | end 7 | -------------------------------------------------------------------------------- /core/app/models/application_record.rb: -------------------------------------------------------------------------------- 1 | class ApplicationRecord < ActiveRecord::Base 2 | self.abstract_class = true 3 | end 4 | -------------------------------------------------------------------------------- /core/app/models/concerns/addresses.rb: -------------------------------------------------------------------------------- 1 | module Addresses 2 | extend ActiveSupport::Concern 3 | 4 | included do 5 | has_many :addresses, as: :addressable 6 | has_one :primary_address, -> { where(primary: true) }, class_name: 'Gaku::Address', as: :addressable 7 | 8 | # def primary_address 9 | # addresses.where(primary: true).first 10 | # end 11 | 12 | def address_widget 13 | if primary_address 14 | "#{primary_address.city}, " \ 15 | "#{primary_address.address1}" 16 | end 17 | end 18 | end 19 | end 20 | -------------------------------------------------------------------------------- /core/app/models/concerns/contacts.rb: -------------------------------------------------------------------------------- 1 | module Contacts 2 | extend ActiveSupport::Concern 3 | 4 | included do 5 | has_many :contacts, as: :contactable 6 | has_one :primary_contact, -> { where(primary: true) }, class_name: 'Gaku::Contact', as: :contactable 7 | 8 | # def primary_contact 9 | # contacts.where(primary: true).first 10 | # end 11 | 12 | def contact_widget 13 | "#{primary_contact.contact_type}: #{primary_contact.data}" if primary_contact 14 | end 15 | end 16 | end 17 | -------------------------------------------------------------------------------- /core/app/models/concerns/enrollable.rb: -------------------------------------------------------------------------------- 1 | module Enrollable 2 | extend ActiveSupport::Concern 3 | 4 | included do 5 | has_many :enrollments, as: :enrollable, dependent: :destroy 6 | has_many :students, through: :enrollments 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /core/app/models/concerns/gradable.rb: -------------------------------------------------------------------------------- 1 | module Gradable 2 | extend ActiveSupport::Concern 3 | 4 | included do 5 | has_many :grading_method_connectors, as: :gradable 6 | has_many :grading_methods, through: :grading_method_connectors 7 | 8 | has_many :exam_portion_scores, as: :gradable 9 | end 10 | 11 | def use_primary_grading_method_set 12 | grading_methods << Gaku::GradingMethodSet.primary.grading_methods if Gaku::GradingMethodSet.primary 13 | end 14 | end 15 | -------------------------------------------------------------------------------- /core/app/models/concerns/notes.rb: -------------------------------------------------------------------------------- 1 | module Notes 2 | extend ActiveSupport::Concern 3 | 4 | included do 5 | has_many :notes, as: :notable 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /core/app/models/concerns/pagination.rb: -------------------------------------------------------------------------------- 1 | module Pagination 2 | extend ActiveSupport::Concern 3 | 4 | included do 5 | paginates_per 20 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /core/app/models/concerns/person.rb: -------------------------------------------------------------------------------- 1 | module Person 2 | extend ActiveSupport::Concern 3 | 4 | included do 5 | validates :name, :surname, presence: true 6 | 7 | def to_s 8 | "#{surname} #{name}" 9 | end 10 | 11 | def phonetic_reading 12 | "#{surname_reading} #{name_reading}" 13 | end 14 | 15 | def age 16 | Date.today.year - birth_date.year 17 | end 18 | 19 | ransacker :age do 20 | Arel::Nodes::SqlLiteral.new( 21 | "DATE_PART('year', AGE(NOW(), birth_date))" 22 | ) 23 | end 24 | end 25 | end 26 | -------------------------------------------------------------------------------- /core/app/models/concerns/picture.rb: -------------------------------------------------------------------------------- 1 | module Picture 2 | extend ActiveSupport::Concern 3 | 4 | included do 5 | has_attached_file :picture, styles: { thumb: '256x256>' }, default_url: ':placeholder' 6 | do_not_validate_attachment_file_type :picture 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /core/app/models/concerns/semesterable.rb: -------------------------------------------------------------------------------- 1 | module Semesterable 2 | extend ActiveSupport::Concern 3 | 4 | included do 5 | has_many :semester_connectors, as: :semesterable, dependent: :destroy 6 | has_many :semesters, through: :semester_connectors, source: :semester 7 | 8 | scope :without_semester, 9 | -> { includes(:semester_connectors).where(gaku_semester_connectors: { semesterable_id: nil }) } 10 | end 11 | end 12 | -------------------------------------------------------------------------------- /core/app/models/concerns/student_reviewable.rb: -------------------------------------------------------------------------------- 1 | module StudentReviewable 2 | extend ActiveSupport::Concern 3 | 4 | included do 5 | has_many :student_reviews, as: :student_reviewable 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /core/app/models/gaku/ability.rb: -------------------------------------------------------------------------------- 1 | # See http://github.com/ryanb/cancan for more details on cancan. 2 | require 'cancancan' 3 | 4 | module Gaku 5 | class Ability 6 | include CanCan::Ability 7 | 8 | def initialize(user) 9 | if user.role?('admin') 10 | can :manage, :all 11 | elsif user.role?('teacher') 12 | can :manage, Gaku::Syllabus, syllabus_teachers: { teacher_id: user.teacher.id } 13 | can :create, Gaku::Syllabus 14 | else 15 | # NOTE: to be added 16 | end 17 | end 18 | end 19 | end 20 | -------------------------------------------------------------------------------- /core/app/models/gaku/admin_ability.rb: -------------------------------------------------------------------------------- 1 | require 'cancan' 2 | 3 | module Gaku 4 | class AdminAbility 5 | include CanCan::Ability 6 | 7 | def initialize(user) 8 | clear_aliased_actions 9 | 10 | alias_action :edit, to: :update 11 | alias_action :new, to: :create 12 | alias_action :new_action, to: :create 13 | alias_action :show, to: :read 14 | 15 | user ||= User.new 16 | 17 | can :manage, :all if user.role? :admin 18 | end 19 | end 20 | end 21 | -------------------------------------------------------------------------------- /core/app/models/gaku/assignment.rb: -------------------------------------------------------------------------------- 1 | module Gaku 2 | class Assignment < ActiveRecord::Base 3 | belongs_to :syllabus 4 | belongs_to :grading_method 5 | 6 | validates :name, presence: true 7 | validates_associated :syllabus, :grading_method 8 | 9 | def to_s 10 | name 11 | end 12 | end 13 | end 14 | -------------------------------------------------------------------------------- /core/app/models/gaku/assignment_score.rb: -------------------------------------------------------------------------------- 1 | module Gaku 2 | class AssignmentScore < ActiveRecord::Base 3 | belongs_to :student 4 | 5 | validates :score, :student, presence: true 6 | validates_associated :student 7 | 8 | def to_s 9 | score 10 | end 11 | end 12 | end 13 | -------------------------------------------------------------------------------- /core/app/models/gaku/attachment.rb: -------------------------------------------------------------------------------- 1 | module Gaku 2 | class Attachment < ApplicationRecord 3 | belongs_to :attachable, polymorphic: true, required: false 4 | 5 | has_attached_file :asset 6 | 7 | validates_associated :attachable, message: I18n.t(:'attachment.associated') 8 | 9 | validates :name, presence: true 10 | validates :asset, presence: true, on: :create 11 | do_not_validate_attachment_file_type :asset 12 | validates_attachment_presence :asset 13 | 14 | def to_s 15 | name 16 | end 17 | end 18 | end 19 | -------------------------------------------------------------------------------- /core/app/models/gaku/attendance.rb: -------------------------------------------------------------------------------- 1 | module Gaku 2 | class Attendance < ActiveRecord::Base 3 | belongs_to :attendancable, polymorphic: true, required: false 4 | belongs_to :student, required: false 5 | belongs_to :attendance_type, required: false 6 | 7 | validates :student, :attendance_type, presence: true 8 | validates_associated :attendancable, :student, :attendance_type 9 | 10 | def to_s 11 | reason 12 | end 13 | end 14 | end 15 | -------------------------------------------------------------------------------- /core/app/models/gaku/attendance_type.rb: -------------------------------------------------------------------------------- 1 | module Gaku 2 | class AttendanceType < ActiveRecord::Base 3 | has_many :attendances 4 | 5 | translates :name 6 | 7 | validates :name, presence: true, uniqueness: true 8 | 9 | def to_s 10 | name 11 | end 12 | end 13 | end 14 | -------------------------------------------------------------------------------- /core/app/models/gaku/badge.rb: -------------------------------------------------------------------------------- 1 | module Gaku 2 | class Badge < ActiveRecord::Base 3 | belongs_to :student, counter_cache: :badges_count 4 | belongs_to :badge_type 5 | 6 | validates :badge_type_id, :student_id, presence: true 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /core/app/models/gaku/badge_type.rb: -------------------------------------------------------------------------------- 1 | module Gaku 2 | class BadgeType < ActiveRecord::Base 3 | has_many :badges 4 | has_many :students, through: :badges 5 | 6 | has_attached_file :badge_image, default_url: ':placeholder' 7 | 8 | validates :name, presence: true 9 | 10 | def to_s 11 | name 12 | end 13 | end 14 | end 15 | -------------------------------------------------------------------------------- /core/app/models/gaku/campus.rb: -------------------------------------------------------------------------------- 1 | module Gaku 2 | class Campus < ActiveRecord::Base 3 | include Picture 4 | include Contacts 5 | 6 | belongs_to :school 7 | has_one :address, as: :addressable 8 | 9 | validates :name, :school, presence: true 10 | 11 | scope :master, -> { where(master: true) } 12 | 13 | def to_s 14 | name 15 | end 16 | end 17 | end 18 | -------------------------------------------------------------------------------- /core/app/models/gaku/class_group.rb: -------------------------------------------------------------------------------- 1 | module Gaku 2 | class ClassGroup < ActiveRecord::Base 3 | include StudentReviewable 4 | include Semesterable 5 | include Enrollable 6 | include Pagination 7 | include Notes 8 | 9 | validates :name, presence: true 10 | 11 | def self.for_select 12 | %w[active upcomming].map do |state| 13 | [state.humanize, send(state).map { |cg| [cg.to_s, cg.id] }] 14 | end 15 | end 16 | 17 | def self.active 18 | @active = joins(:semesters).merge(Gaku::Semester.active).uniq 19 | end 20 | 21 | def self.upcomming 22 | @upcomming = joins(:semesters).merge(Gaku::Semester.upcomming).uniq - active 23 | end 24 | 25 | def to_s 26 | "#{grade} - #{name}" 27 | end 28 | end 29 | end 30 | -------------------------------------------------------------------------------- /core/app/models/gaku/commute_method_type.rb: -------------------------------------------------------------------------------- 1 | module Gaku 2 | class CommuteMethodType < ActiveRecord::Base 3 | has_many :students 4 | 5 | validates :name, presence: true, uniqueness: true 6 | 7 | translates :name 8 | 9 | def to_s 10 | name 11 | end 12 | end 13 | end 14 | -------------------------------------------------------------------------------- /core/app/models/gaku/contact_type.rb: -------------------------------------------------------------------------------- 1 | module Gaku 2 | class ContactType < ActiveRecord::Base 3 | has_many :contacts 4 | 5 | validates :name, presence: true, uniqueness: { case_sensitive: false } 6 | 7 | def to_s 8 | name 9 | end 10 | end 11 | end 12 | -------------------------------------------------------------------------------- /core/app/models/gaku/country.rb: -------------------------------------------------------------------------------- 1 | module Gaku 2 | class Country < ActiveRecord::Base 3 | has_many :states, -> { order name: :asc }, 4 | foreign_key: :country_iso, 5 | primary_key: :iso 6 | 7 | default_scope -> { order('name ASC') } 8 | 9 | validates :name, :iso_name, :iso, presence: true 10 | validates :iso, uniqueness: true 11 | 12 | def <=>(other) 13 | name <=> other.name 14 | end 15 | 16 | def to_s 17 | i18n_name 18 | end 19 | 20 | def i18n_name 21 | carmen_country = Carmen::Country.coded(iso) 22 | if carmen_country 23 | carmen_country.name 24 | else 25 | name 26 | end 27 | end 28 | end 29 | end 30 | -------------------------------------------------------------------------------- /core/app/models/gaku/course_group.rb: -------------------------------------------------------------------------------- 1 | module Gaku 2 | class CourseGroup < ActiveRecord::Base 3 | has_many :course_group_enrollments 4 | has_many :courses, through: :course_group_enrollments 5 | 6 | validates :name, presence: true 7 | 8 | def to_s 9 | name 10 | end 11 | end 12 | end 13 | -------------------------------------------------------------------------------- /core/app/models/gaku/course_group_enrollment.rb: -------------------------------------------------------------------------------- 1 | module Gaku 2 | class CourseGroupEnrollment < ActiveRecord::Base 3 | belongs_to :course 4 | belongs_to :course_group 5 | 6 | validates :course_group_id, presence: true 7 | 8 | validates :course_id, 9 | presence: true, 10 | uniqueness: { 11 | scope: :course_group_id, 12 | message: I18n.t(:'course_group.already_enrolled') 13 | } 14 | end 15 | end 16 | -------------------------------------------------------------------------------- /core/app/models/gaku/course_teacher.rb: -------------------------------------------------------------------------------- 1 | class CourseTeacher 2 | belongs_to :teacher 3 | belongs_to :course 4 | end 5 | -------------------------------------------------------------------------------- /core/app/models/gaku/department.rb: -------------------------------------------------------------------------------- 1 | module Gaku 2 | class Department < ActiveRecord::Base 3 | has_many :specialties 4 | has_many :syllabuses 5 | has_many :exams 6 | 7 | translates :name 8 | 9 | validates :name, presence: true, uniqueness: true 10 | 11 | def to_s 12 | name 13 | end 14 | end 15 | end 16 | -------------------------------------------------------------------------------- /core/app/models/gaku/enrollment_status.rb: -------------------------------------------------------------------------------- 1 | module Gaku 2 | class EnrollmentStatus < ActiveRecord::Base 3 | has_many :students, foreign_key: :enrollment_status_code, primary_key: :code 4 | 5 | translates :name 6 | 7 | validates :code, presence: true, uniqueness: true 8 | 9 | before_create :set_name 10 | 11 | scope :active, -> { where(active: true) } 12 | 13 | def to_s 14 | name 15 | end 16 | 17 | private 18 | 19 | def set_name 20 | self.name = code if name.nil? 21 | end 22 | end 23 | end 24 | -------------------------------------------------------------------------------- /core/app/models/gaku/exam_portion_score.rb: -------------------------------------------------------------------------------- 1 | module Gaku 2 | class ExamPortionScore < ActiveRecord::Base 3 | belongs_to :student, required: false 4 | belongs_to :exam_portion, required: false 5 | 6 | belongs_to :gradable, polymorphic: true, required: false 7 | 8 | has_many :attendances, as: :attendancable 9 | 10 | validates :student, :exam_portion, presence: true 11 | 12 | scope :gradable_scope, ->(gradable) { where(gradable: gradable) } 13 | end 14 | end 15 | -------------------------------------------------------------------------------- /core/app/models/gaku/exam_schedule.rb: -------------------------------------------------------------------------------- 1 | module Gaku 2 | class ExamSchedule < ActiveRecord::Base 3 | belongs_to :exam_portion 4 | belongs_to :schedule 5 | belongs_to :course 6 | 7 | validates :exam_portion, :schedule, :course, presence: true 8 | end 9 | end 10 | -------------------------------------------------------------------------------- /core/app/models/gaku/exam_score.rb: -------------------------------------------------------------------------------- 1 | module Gaku 2 | class ExamScore < ActiveRecord::Base 3 | belongs_to :exam 4 | 5 | validates :exam, presence: true 6 | validates :score, numericality: { greater_than_or_equal_to: 0 }, 7 | presence: true 8 | end 9 | end 10 | -------------------------------------------------------------------------------- /core/app/models/gaku/exam_session.rb: -------------------------------------------------------------------------------- 1 | module Gaku 2 | class ExamSession < ActiveRecord::Base 3 | include Gradable 4 | include Enrollable 5 | 6 | belongs_to :exam 7 | 8 | validates :exam_id, presence: true 9 | 10 | def to_s 11 | name 12 | end 13 | end 14 | end 15 | -------------------------------------------------------------------------------- /core/app/models/gaku/exam_syllabus.rb: -------------------------------------------------------------------------------- 1 | module Gaku 2 | class ExamSyllabus < ActiveRecord::Base 3 | belongs_to :syllabus, counter_cache: :exams_count 4 | belongs_to :exam 5 | 6 | validates :exam_id, presence: true 7 | 8 | validates :syllabus_id, 9 | presence: true, 10 | uniqueness: { scope: :exam_id, 11 | message: I18n.t(:'exam.already_added') } 12 | end 13 | end 14 | -------------------------------------------------------------------------------- /core/app/models/gaku/external_school_record.rb: -------------------------------------------------------------------------------- 1 | module Gaku 2 | class ExternalSchoolRecord < ActiveRecord::Base 3 | belongs_to :school 4 | belongs_to :student, counter_cache: :external_school_records_count 5 | 6 | validates :school, :student, presence: true 7 | 8 | def attendance_rate 9 | (presence_days.to_f / total_units) * 100 if units_values_present? 10 | end 11 | 12 | def presence_days 13 | total_units - units_absent if units_values_present? 14 | end 15 | 16 | private 17 | 18 | def units_values_present? 19 | units_absent.present? && total_units.present? 20 | end 21 | end 22 | end 23 | -------------------------------------------------------------------------------- /core/app/models/gaku/extracurricular_activity.rb: -------------------------------------------------------------------------------- 1 | module Gaku 2 | class ExtracurricularActivity < ActiveRecord::Base 3 | include Enrollable 4 | 5 | validates :name, presence: true, uniqueness: true 6 | 7 | def to_s 8 | name 9 | end 10 | end 11 | end 12 | -------------------------------------------------------------------------------- /core/app/models/gaku/faculty.rb: -------------------------------------------------------------------------------- 1 | module Gaku 2 | class Faculty < ActiveRecord::Base 3 | include Contacts 4 | include Addresses 5 | 6 | has_many :school_roles, as: :school_rolable 7 | has_many :students 8 | has_many :class_groups 9 | has_many :courses 10 | end 11 | end 12 | -------------------------------------------------------------------------------- /core/app/models/gaku/grading_method.rb: -------------------------------------------------------------------------------- 1 | module Gaku 2 | class GradingMethod < ActiveRecord::Base 3 | has_one :exam 4 | has_one :exam_portion 5 | has_one :assignment 6 | has_many :simple_grade_types 7 | 8 | has_many :grading_method_connectors 9 | 10 | has_many :grading_method_set_items 11 | has_many :grading_method_sets, through: :grading_method_set_items 12 | 13 | validates :name, presence: true, uniqueness: true 14 | 15 | Types = %w[score percentage ordinal interval].freeze 16 | 17 | validates :grading_type, presence: true, inclusion: { in: Types } 18 | 19 | serialize :criteria, Hash 20 | 21 | Types.each do |type| 22 | define_method "#{type}?" do 23 | grading_type == type 24 | end 25 | end 26 | 27 | def to_s 28 | name 29 | end 30 | end 31 | end 32 | -------------------------------------------------------------------------------- /core/app/models/gaku/guardian.rb: -------------------------------------------------------------------------------- 1 | module Gaku 2 | class Guardian < ActiveRecord::Base 3 | include Picture 4 | include Contacts 5 | include Addresses 6 | include Person 7 | 8 | belongs_to :user, required: false 9 | has_many :student_guardians, dependent: :destroy 10 | has_many :students, through: :student_guardians 11 | 12 | after_create :reset_student_count 13 | after_destroy :reset_student_count 14 | 15 | private 16 | 17 | def reset_student_count 18 | students.each do |s| 19 | Student.reset_counters(s.id, :guardians) 20 | end 21 | end 22 | end 23 | end 24 | -------------------------------------------------------------------------------- /core/app/models/gaku/install.rb: -------------------------------------------------------------------------------- 1 | module Gaku 2 | class Install < ActiveRecord::Base 3 | devise :database_authenticatable, :registerable, 4 | :recoverable, :rememberable, :trackable, :validatable 5 | end 6 | end 7 | -------------------------------------------------------------------------------- /core/app/models/gaku/lesson.rb: -------------------------------------------------------------------------------- 1 | module Gaku 2 | class Lesson < ActiveRecord::Base 3 | belongs_to :lesson_plan 4 | has_many :attendances, as: :attendancable 5 | 6 | validates :lesson_plan, presence: true 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /core/app/models/gaku/lesson_plan.rb: -------------------------------------------------------------------------------- 1 | module Gaku 2 | class LessonPlan < ActiveRecord::Base 3 | include Notes 4 | 5 | has_many :lessons 6 | has_many :attachments, as: :attachable 7 | belongs_to :syllabus, required: false 8 | 9 | validates :syllabus, presence: true 10 | end 11 | end 12 | -------------------------------------------------------------------------------- /core/app/models/gaku/level.rb: -------------------------------------------------------------------------------- 1 | module Gaku 2 | class Level < ActiveRecord::Base 3 | belongs_to :school 4 | 5 | has_many :program_levels 6 | has_many :programs, through: :program_levels 7 | 8 | validates :name, :school, presence: true 9 | validates :name, uniqueness: true 10 | 11 | def to_s 12 | name 13 | end 14 | end 15 | end 16 | -------------------------------------------------------------------------------- /core/app/models/gaku/note.rb: -------------------------------------------------------------------------------- 1 | module Gaku 2 | class Note < ActiveRecord::Base 3 | belongs_to :notable, polymorphic: true, counter_cache: true, required: false 4 | 5 | validates :title, :content, presence: true 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /core/app/models/gaku/program.rb: -------------------------------------------------------------------------------- 1 | module Gaku 2 | class Program < ActiveRecord::Base 3 | has_many :program_specialties 4 | has_many :specialties, through: :program_specialties 5 | 6 | has_many :program_levels 7 | has_many :levels, through: :program_levels 8 | 9 | has_many :program_syllabuses 10 | has_many :syllabuses, through: :program_syllabuses 11 | 12 | belongs_to :school 13 | 14 | validates :name, :school, presence: true 15 | validates :name, uniqueness: true 16 | 17 | accepts_nested_attributes_for :program_levels, 18 | :program_specialties, 19 | :program_syllabuses, 20 | allow_destroy: true 21 | 22 | def to_s 23 | name 24 | end 25 | end 26 | end 27 | -------------------------------------------------------------------------------- /core/app/models/gaku/program_level.rb: -------------------------------------------------------------------------------- 1 | module Gaku 2 | class ProgramLevel < ActiveRecord::Base 3 | belongs_to :program 4 | belongs_to :level 5 | 6 | validates :level, presence: true 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /core/app/models/gaku/program_specialty.rb: -------------------------------------------------------------------------------- 1 | module Gaku 2 | class ProgramSpecialty < ActiveRecord::Base 3 | belongs_to :program, required: false 4 | belongs_to :specialty, required: false 5 | 6 | validates :specialty, presence: true 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /core/app/models/gaku/program_syllabus.rb: -------------------------------------------------------------------------------- 1 | module Gaku 2 | class ProgramSyllabus < ActiveRecord::Base 3 | belongs_to :program 4 | belongs_to :syllabus 5 | belongs_to :level 6 | 7 | validates :syllabus, presence: true 8 | end 9 | end 10 | -------------------------------------------------------------------------------- /core/app/models/gaku/role.rb: -------------------------------------------------------------------------------- 1 | module Gaku 2 | class Role < ActiveRecord::Base 3 | has_many :user_roles 4 | has_many :users, through: :user_roles 5 | 6 | validates :name, presence: true, uniqueness: { case_sensitive: false } 7 | 8 | before_save :ensure_name_downcase 9 | 10 | def to_s 11 | name 12 | end 13 | 14 | private 15 | 16 | def ensure_name_downcase 17 | self.name = self.name.downcase 18 | end 19 | end 20 | end 21 | -------------------------------------------------------------------------------- /core/app/models/gaku/schedule.rb: -------------------------------------------------------------------------------- 1 | module Gaku 2 | class Schedule < ActiveRecord::Base 3 | end 4 | end 5 | -------------------------------------------------------------------------------- /core/app/models/gaku/scholarship_status.rb: -------------------------------------------------------------------------------- 1 | module Gaku 2 | class ScholarshipStatus < ActiveRecord::Base 3 | has_many :students 4 | 5 | translates :name 6 | 7 | validates :name, presence: true, uniqueness: true 8 | 9 | def to_s 10 | name 11 | end 12 | end 13 | end 14 | -------------------------------------------------------------------------------- /core/app/models/gaku/school_role.rb: -------------------------------------------------------------------------------- 1 | module Gaku 2 | class SchoolRole < ActiveRecord::Base 3 | belongs_to :school_rolable, polymorphic: true, required: false 4 | 5 | validates :name, presence: true, uniqueness: true 6 | 7 | def to_s 8 | name 9 | end 10 | end 11 | end 12 | -------------------------------------------------------------------------------- /core/app/models/gaku/school_year.rb: -------------------------------------------------------------------------------- 1 | module Gaku 2 | class SchoolYear < ActiveRecord::Base 3 | has_many :semesters 4 | 5 | validates :starting, :ending, presence: true 6 | 7 | validate :ending_after_starting 8 | 9 | def to_s 10 | "#{starting} - #{ending}" 11 | end 12 | 13 | private 14 | 15 | def ending_after_starting 16 | return if starting.blank? && ending.blank? 17 | 18 | errors.add(:base, I18n.t(:'school_year.ending_after_starting')) if starting >= ending 19 | end 20 | end 21 | end 22 | -------------------------------------------------------------------------------- /core/app/models/gaku/semester_attendance.rb: -------------------------------------------------------------------------------- 1 | module Gaku 2 | class SemesterAttendance < ActiveRecord::Base 3 | belongs_to :student 4 | belongs_to :semester 5 | 6 | def self.grouped_for_table 7 | all.group_by(&:student_id).map do |k, v| 8 | [k, v.group_by(&:semester_id).map { |x, y| [x, y.first] }.to_h] 9 | end.to_h 10 | end 11 | end 12 | end 13 | -------------------------------------------------------------------------------- /core/app/models/gaku/simple_grade.rb: -------------------------------------------------------------------------------- 1 | module Gaku 2 | class SimpleGrade < ActiveRecord::Base 3 | belongs_to :student 4 | belongs_to :simple_grade_type 5 | 6 | %i[name school grading_method max_score passing_score].each do |attribute| 7 | delegate attribute, to: :simple_grade_type, allow_nil: true, prefix: true 8 | end 9 | 10 | validates :student_id, :simple_grade_type_id, :score, presence: true 11 | 12 | def to_s 13 | simple_grade_type_name 14 | end 15 | end 16 | end 17 | -------------------------------------------------------------------------------- /core/app/models/gaku/simple_grade_type.rb: -------------------------------------------------------------------------------- 1 | module Gaku 2 | class SimpleGradeType < ActiveRecord::Base 3 | has_many :simple_grades 4 | belongs_to :school 5 | belongs_to :grading_method 6 | 7 | validates :name, presence: true 8 | 9 | def to_s 10 | name 11 | end 12 | end 13 | end 14 | -------------------------------------------------------------------------------- /core/app/models/gaku/specialty.rb: -------------------------------------------------------------------------------- 1 | module Gaku 2 | class Specialty < ActiveRecord::Base 3 | has_many :student_specialties 4 | has_many :students, through: :student_specialties 5 | 6 | has_many :program_specialties 7 | has_many :programs, through: :program_specialties 8 | 9 | belongs_to :department, required: false 10 | 11 | validates :name, presence: true, uniqueness: true 12 | 13 | def to_s 14 | name 15 | end 16 | end 17 | end 18 | -------------------------------------------------------------------------------- /core/app/models/gaku/student_exam_session.rb: -------------------------------------------------------------------------------- 1 | module Gaku 2 | class StudentExamSession < ActiveRecord::Base 3 | belongs_to :exam_session 4 | belongs_to :student 5 | 6 | validates :exam_session_id, presence: true 7 | validates :student_id, 8 | presence: true, 9 | uniqueness: { scope: :exam_session_id } 10 | end 11 | end 12 | -------------------------------------------------------------------------------- /core/app/models/gaku/student_guardian.rb: -------------------------------------------------------------------------------- 1 | module Gaku 2 | class StudentGuardian < ActiveRecord::Base 3 | belongs_to :student, counter_cache: :guardians_count 4 | belongs_to :guardian 5 | 6 | validates :student_id, uniqueness: { scope: :guardian_id } 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /core/app/models/gaku/student_review.rb: -------------------------------------------------------------------------------- 1 | module Gaku 2 | class StudentReview < ActiveRecord::Base 3 | belongs_to :student, required: false 4 | belongs_to :student_review_category, required: false 5 | belongs_to :student_reviewable, polymorphic: true, required: false 6 | 7 | validates :content, :student_id, :student_review_category_id, :student_reviewable_id, :student_reviewable_type, presence: true 8 | validates :student_id, uniqueness: { scope: %i[student_reviewable_type student_reviewable_id] } 9 | end 10 | end 11 | -------------------------------------------------------------------------------- /core/app/models/gaku/student_review_category.rb: -------------------------------------------------------------------------------- 1 | module Gaku 2 | class StudentReviewCategory < ActiveRecord::Base 3 | validates :name, presence: true, uniqueness: true 4 | 5 | translates :name 6 | 7 | def to_s 8 | name 9 | end 10 | end 11 | end 12 | -------------------------------------------------------------------------------- /core/app/models/gaku/student_specialty.rb: -------------------------------------------------------------------------------- 1 | module Gaku 2 | class StudentSpecialty < ActiveRecord::Base 3 | belongs_to :specialty, required: false 4 | belongs_to :student, required: false 5 | 6 | validates :specialty_id, presence: true 7 | 8 | validates :student_id, 9 | presence: true, 10 | uniqueness: { scope: :specialty_id, 11 | message: I18n.t(:'specialty.already_added') } 12 | 13 | scope :ordered, -> { order('major desc') } 14 | end 15 | end 16 | -------------------------------------------------------------------------------- /core/app/models/gaku/syllabus.rb: -------------------------------------------------------------------------------- 1 | module Gaku 2 | class Syllabus < ActiveRecord::Base 3 | include Notes 4 | 5 | has_many :courses 6 | has_many :assignments 7 | has_many :lesson_plans 8 | 9 | has_many :syllabus_teachers 10 | has_many :teachers, through: :syllabus_teachers 11 | 12 | has_many :programs, class_name: 'Gaku::ProgramSyllabus' 13 | 14 | has_many :exam_syllabuses, dependent: :destroy 15 | has_many :exams, through: :exam_syllabuses 16 | 17 | belongs_to :department, required: false 18 | 19 | accepts_nested_attributes_for :exams, :assignments 20 | 21 | validates :name, :code, presence: true 22 | end 23 | end 24 | -------------------------------------------------------------------------------- /core/app/models/gaku/syllabus_teacher.rb: -------------------------------------------------------------------------------- 1 | class Gaku::SyllabusTeacher < ActiveRecord::Base 2 | belongs_to :teacher 3 | belongs_to :syllabus 4 | end 5 | -------------------------------------------------------------------------------- /core/app/models/gaku/teacher.rb: -------------------------------------------------------------------------------- 1 | module Gaku 2 | class Teacher < ActiveRecord::Base 3 | include Pagination 4 | include Picture 5 | include Notes 6 | include Contacts 7 | include Addresses 8 | include Person 9 | 10 | belongs_to :user, required: false 11 | end 12 | end 13 | -------------------------------------------------------------------------------- /core/app/models/gaku/template.rb: -------------------------------------------------------------------------------- 1 | module Gaku 2 | class Template < ActiveRecord::Base 3 | has_attached_file :file 4 | 5 | validates_with AttachmentContentTypeValidator, 6 | attributes: :file, 7 | content_type: ['text/plain', 8 | 'application/vnd.ms-excel', 9 | 'application/vnd.oasis.opendocument.spreadsheet', 10 | 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'], 11 | message: I18n.t(:'template.file_type_error') 12 | 13 | validates :name, :context, presence: true 14 | validates :file, presence: true, on: :create 15 | end 16 | end 17 | -------------------------------------------------------------------------------- /core/app/models/gaku/user_role.rb: -------------------------------------------------------------------------------- 1 | module Gaku 2 | class UserRole < ActiveRecord::Base 3 | belongs_to :user 4 | belongs_to :role 5 | 6 | validates :user, uniqueness: { scope: :role, message: 'role already exists' } 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /core/app/services/gaku/user_creator.rb: -------------------------------------------------------------------------------- 1 | module Gaku 2 | class UserCreator 3 | def initialize(params = {}) 4 | @user = User.new(params) 5 | set_default_language 6 | end 7 | 8 | def save 9 | @user.save 10 | end 11 | 12 | def save! 13 | @user.save! 14 | end 15 | 16 | def get_user 17 | @user 18 | end 19 | 20 | private 21 | 22 | def set_default_language 23 | @user.settings[:locale] = if Preset.active.nil? 24 | 'en' 25 | else 26 | Preset.active.locale['language'] 27 | end 28 | end 29 | end 30 | end 31 | -------------------------------------------------------------------------------- /core/app/views/gaku/admin/grading_methods/_arguments_template.html.slim: -------------------------------------------------------------------------------- 1 | .row.attribute-template class="#{'hide' if f.object.arguments.present?}" 2 | .col-md-3 3 | .form-group 4 | .controls 5 | = text_field_tag nil, nil, class: 'dynamicAttributeName form-control', name: nil 6 | .col-md-3 7 | .form-group 8 | .controls 9 | = text_field_tag nil, nil, class: 'dynamicAttributeValue form-control', name: nil 10 | .col-md-3 11 | = link_to t('grading_method.remove_argument'), '#', class: 'remove-argument-row btn btn-danger' 12 | -------------------------------------------------------------------------------- /core/app/views/gaku/admin/grading_methods/_form_fields.html.slim: -------------------------------------------------------------------------------- 1 | = f.text_field :name, label: t(:'grading_method.name') 2 | = f.text_field :description, label: t(:'grading_method.description') 3 | 4 | /= f.text_field :method, label: t(:'grading_method.method') 5 | = f.select :method, {"Score" => "score", "Percentage" => "percentage", "Ordinal" => "ordinal", "Interval" => "interval", "Ratio" => "ratio", "Pass/Fail" => "pass_fail"}, {prompt: "メソッドを選択してください"} , class: "form-control" 6 | 7 | = render 'arguments_form_fields', f: f 8 | -------------------------------------------------------------------------------- /core/app/views/gaku/courses/_form_fields.html.slim: -------------------------------------------------------------------------------- 1 | .row 2 | .col-md-6 3 | = f.select :syllabus_id, options_from_collection_for_select(@syllabuses, :id, :name), {}, label: t(:'syllabus.singular'), class: 'form-control' 4 | .col-md-6 5 | = f.text_field :code, placeholder: t(:'course.code_sample'), label: t(:'course.code') 6 | -------------------------------------------------------------------------------- /core/app/views/gaku/courses/exams/exam_portion_scores/update.js.erb: -------------------------------------------------------------------------------- 1 | var jsonObject = '<%= @exam_portion_score.to_json.html_safe.to_s %>' 2 | <% broadcast "/messages/new" do %> 3 | $('#edit_exam_portion_score_<%= @exam_portion_score.id %>').children('input').val('<%= @exam_portion_score.score %>') 4 | <% end %> 5 | 6 | -------------------------------------------------------------------------------- /core/app/views/gaku/courses/exams/grading/_calculations.html.slim: -------------------------------------------------------------------------------- 1 | table.grading.grading-calculations.table.table-bordered.table-condensed 2 | thead 3 | tr 4 | th.btn-inverse Total & Grade 5 | tbody 6 | - @students.each do |student| 7 | = tr_for student do 8 | td 9 | - p "student dayo-" 10 | - p student 11 | - p "exam dayo-" 12 | - p @exam 13 | - p "student_total_scores dayo-" 14 | - p @student_total_scores 15 | 16 | = @student_exams_total_score[:raw][@exam.id][student.id] 17 | -------------------------------------------------------------------------------- /core/app/views/gaku/courses/exams/grading/_exam_portion_score_form.htmls.lim: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GAKUEngine/gaku/5e2f1580520c09b4f871893075a0c9b5e9f50037/core/app/views/gaku/courses/exams/grading/_exam_portion_score_form.htmls.lim -------------------------------------------------------------------------------- /core/app/views/gaku/courses/exams/grading/_students.html.slim: -------------------------------------------------------------------------------- 1 | table.grading.grading-students.table.table-bordered.table-condensed 2 | thead 3 | tr 4 | th.btn-info style="width:60px" Class 5 | th.btn-info style="width:60px" Seat_Number 6 | th.btn-info style="width:150px" Name 7 | tbody 8 | - students.each do |student| 9 | = tr_for student do 10 | td.vm-tc 11 | td.vm-tc 12 | td.vm = student.full_name 13 | -------------------------------------------------------------------------------- /core/app/views/gaku/shared/menu/_global.html.erb: -------------------------------------------------------------------------------- 1 |
-------------------------------------------------------------------------------- /core/config/initializers/inflections.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Add new inflection rules using the following format 4 | # (all these examples are active by default): 5 | # ActiveSupport::Inflector.inflections do |inflect| 6 | # inflect.plural /^(ox)$/i, '\1en' 7 | # inflect.singular /^(ox)en/i, '\1' 8 | # inflect.irregular 'person', 'people' 9 | # inflect.uncountable %w( fish sheep ) 10 | # end 11 | # 12 | # These inflection rules are supported but not enabled by default: 13 | # ActiveSupport::Inflector.inflections do |inflect| 14 | # inflect.acronym 'RESTful' 15 | # end 16 | 17 | ActiveSupport::Inflector.inflections do |inflect| 18 | inflect.irregular 'campus', 'campuses' 19 | end -------------------------------------------------------------------------------- /core/config/initializers/kaminari.rb: -------------------------------------------------------------------------------- 1 | Kaminari.configure do |config| 2 | config.default_per_page = 10 3 | # config.max_per_page = nil 4 | # config.window = 4 5 | # config.outer_window = 0 6 | # config.left = 0 7 | # config.right = 0 8 | # config.page_method_name = :page 9 | # config.param_name = :page 10 | end 11 | -------------------------------------------------------------------------------- /core/config/initializers/locale.rb: -------------------------------------------------------------------------------- 1 | I18n.load_path += Dir[Rails.root.join('lib', 'locale', '*.{rb,yml}')] 2 | I18n.default_locale = :en 3 | -------------------------------------------------------------------------------- /core/config/initializers/redis.rb: -------------------------------------------------------------------------------- 1 | if Rails.env.test? 2 | $redis = Redis.new(db: 15) 3 | else 4 | if ENV['REDIS_HOST'] 5 | $redis = Redis.new(host: ENV['REDIS_HOST']) 6 | else 7 | $redis = Redis.new 8 | end 9 | end 10 | -------------------------------------------------------------------------------- /core/config/initializers/translation_missing.rb: -------------------------------------------------------------------------------- 1 | if %w(development test).include? Rails.env 2 | unless ENV['I18N'] == 0 3 | module I18n 4 | def self.just_raise_that_exception(exception, key, locale, options) 5 | raise [exception, key].inspect if locale == 'en' 6 | end 7 | end 8 | 9 | I18n.exception_handler = :just_raise_that_exception 10 | end 11 | end 12 | -------------------------------------------------------------------------------- /core/core_dependencies.rb: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | 3 | group :development, :test do 4 | gem 'pry' 5 | gem 'listen' 6 | end 7 | 8 | group :test do 9 | gem 'rspec-rails', '~> 3.8.2' 10 | gem 'factory_bot_rails', '~> 4.11.1' 11 | gem 'database_cleaner', '~> 1.7.0' 12 | gem 'shoulda-matchers', '~> 3.1.2' 13 | gem 'rails-controller-testing' 14 | gem 'simplecov' 15 | end 16 | -------------------------------------------------------------------------------- /core/db/default/gaku/commute_method_types.rb: -------------------------------------------------------------------------------- 1 | commute_method_types = [ 2 | { name: 'Unknown', name_ja: '不明' }, 3 | { name: 'Walking', name_ja: '歩行' }, 4 | { name: 'Bicycle', name_ja: '自転車' }, 5 | { name: 'Train', name_ja: '列車' }, 6 | { name: 'Bus', name_ja: 'バス' }, 7 | { name: 'Car', name_ja: '車' }, 8 | { name: 'Metro', name_ja: '地下鉄' } 9 | ] 10 | 11 | commute_method_types.each do |type| 12 | I18n.locale = :en 13 | commute_method_type = Gaku::CommuteMethodType.where(name: type[:name]).first_or_create! 14 | 15 | I18n.locale = :ja 16 | commute_method_type.update_attributes(name: type[:name_ja]) 17 | end 18 | -------------------------------------------------------------------------------- /core/db/default/gaku/contact_types.yml: -------------------------------------------------------------------------------- 1 | home_phone: 2 | name: "Home Phone" 3 | work_phone: 4 | name: "Work Phone" 5 | mobile_phone: 6 | name: "Mobile Phone" 7 | phone: 8 | name: "Phone" 9 | email: 10 | name: "Email" 11 | mobile_mail: 12 | name: "Mobile Mail" 13 | skype: 14 | name: "Skype" 15 | google_plus: 16 | name: "Google Plus" 17 | facebook: 18 | name: "Facebook" 19 | twitter: 20 | name: "Twitter" -------------------------------------------------------------------------------- /core/db/default/gaku/countries.rb: -------------------------------------------------------------------------------- 1 | require 'carmen' 2 | 3 | Carmen::Country.all.each do |country| 4 | next if Gaku::Country.exists?(iso: country.alpha_2_code) 5 | 6 | Gaku::Country.create!(name: country.name, 7 | iso3: country.alpha_3_code, 8 | iso: country.alpha_2_code, 9 | iso_name: country.official_name || country.name.upcase, 10 | numcode: country.numeric_code, 11 | states_required: country.subregions?) 12 | end 13 | -------------------------------------------------------------------------------- /core/db/default/gaku/departments.rb: -------------------------------------------------------------------------------- 1 | departments = [ 2 | { 3 | name: 'Mathematics', 4 | name_ja: 'Japanese Mathematics' 5 | } 6 | ] 7 | 8 | departments.each do |d| 9 | I18n.locale = :en 10 | department = Gaku::Department.where(name: d[:name]).first_or_create! 11 | 12 | I18n.locale = :ja 13 | department.update_attributes(name: d[:name_ja]) 14 | end 15 | -------------------------------------------------------------------------------- /core/db/default/gaku/master_school.rb: -------------------------------------------------------------------------------- 1 | Gaku::School.where(name: 'Our School', 2 | primary: true, 3 | slogan: 'Our Slogan', 4 | founded: Time.now, 5 | principal: 'Our Principal', 6 | vice_principal: 'Our Vice Principal').first_or_create! 7 | -------------------------------------------------------------------------------- /core/db/default/gaku/roles.yml: -------------------------------------------------------------------------------- 1 | admin_role: 2 | name: Admin 3 | -------------------------------------------------------------------------------- /core/db/default/gaku/scholarship_statuses.rb: -------------------------------------------------------------------------------- 1 | scholarship_statuses = [ 2 | { name: 'Self Paid', name_ja: '自己支払い', default: true }, 3 | { name: 'Government Scholarship', name_ja: '政府奨学金', default: false }, 4 | { name: 'School Scholarship', name_ja: '学校の奨学金', default: false }, 5 | { name: 'Organizational Scholarship', name_ja: '組織の奨学金', default: false }, 6 | { name: 'Charity Scholarship', name_ja: 'チャリティー奨学金', default: false } 7 | ] 8 | 9 | scholarship_statuses.each do |status| 10 | I18n.locale = :en 11 | scholarship_status = Gaku::ScholarshipStatus.where( 12 | name: status[:name], 13 | default: status[:default] 14 | ).first_or_create! 15 | 16 | I18n.locale = :ja 17 | scholarship_status.update_attribute(:name, status[:name_ja]) 18 | end 19 | 20 | I18n.locale = :en 21 | -------------------------------------------------------------------------------- /core/db/default/gaku/states.rb: -------------------------------------------------------------------------------- 1 | Gaku::Country.where(states_required: true).each do |country| 2 | carmen_country = Carmen::Country.named(country.name) 3 | 4 | carmen_country.subregions.each do |subregion| 5 | unless Gaku::State.exists?(name: subregion.name, country_iso: country.iso) 6 | Gaku::State.create!(name: subregion.name, abbr: subregion.code, country_iso: country.iso) 7 | end 8 | end 9 | end 10 | -------------------------------------------------------------------------------- /core/db/migrate/20140128141752_change_grading_methods_arguments_field.rb: -------------------------------------------------------------------------------- 1 | class ChangeGradingMethodsArgumentsField < ActiveRecord::Migration[4.2] 2 | def change 3 | rename_column :gaku_grading_methods, :arguments, :criteria 4 | end 5 | end 6 | -------------------------------------------------------------------------------- /core/db/migrate/20140130182100_change_fields_external_school_record.rb: -------------------------------------------------------------------------------- 1 | class ChangeFieldsExternalSchoolRecord < ActiveRecord::Migration[4.2] 2 | def change 3 | add_column :gaku_external_school_records, :units_absent, :integer 4 | add_column :gaku_external_school_records, :total_units, :integer 5 | remove_column :gaku_external_school_records, :attendance_rate 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /core/db/migrate/20140207093618_drop_student_configs.rb: -------------------------------------------------------------------------------- 1 | class DropStudentConfigs < ActiveRecord::Migration[4.2] 2 | def change 3 | drop_table :gaku_student_configs 4 | end 5 | end 6 | -------------------------------------------------------------------------------- /core/db/migrate/20140213113405_create_grading_method_connectors_table.rb: -------------------------------------------------------------------------------- 1 | class CreateGradingMethodConnectorsTable < ActiveRecord::Migration[4.2] 2 | def change 3 | create_table :gaku_grading_method_connectors do |t| 4 | t.references :grading_method 5 | t.references :gradable, polymorphic: true 6 | t.integer :position 7 | end 8 | end 9 | end 10 | -------------------------------------------------------------------------------- /core/db/migrate/20140304094422_create_gaku_exam_sessions_table.rb: -------------------------------------------------------------------------------- 1 | class CreateGakuExamSessionsTable < ActiveRecord::Migration[4.2] 2 | def change 3 | create_table :gaku_exam_sessions do |t| 4 | t.integer :session_time 5 | t.string :name 6 | t.references :exam 7 | t.datetime :session_start 8 | end 9 | end 10 | end 11 | -------------------------------------------------------------------------------- /core/db/migrate/20140325073941_add_time_format_24_to_presets_table.rb: -------------------------------------------------------------------------------- 1 | class AddTimeFormat24ToPresetsTable < ActiveRecord::Migration[4.2] 2 | def change 3 | add_column :gaku_presets, :time_format_24, :boolean, default: true 4 | end 5 | end 6 | -------------------------------------------------------------------------------- /core/db/migrate/20140408111314_remove_semester_join_tables.rb: -------------------------------------------------------------------------------- 1 | class RemoveSemesterJoinTables < ActiveRecord::Migration[4.2] 2 | def change 3 | drop_table :gaku_semester_class_groups 4 | drop_table :gaku_semester_courses 5 | end 6 | end 7 | -------------------------------------------------------------------------------- /core/db/migrate/20140408111358_create_semester_connectors_table.rb: -------------------------------------------------------------------------------- 1 | class CreateSemesterConnectorsTable < ActiveRecord::Migration[4.2] 2 | def change 3 | create_table :gaku_semester_connectors do |t| 4 | t.references :semester 5 | t.references :semesterable, polymorphic: true 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /core/db/migrate/20140423093155_create_enrollments_table.rb: -------------------------------------------------------------------------------- 1 | class CreateEnrollmentsTable < ActiveRecord::Migration[4.2] 2 | def change 3 | create_table :gaku_enrollments do |t| 4 | t.references :student 5 | t.references :enrollmentable, polymorphic: true 6 | end 7 | 8 | add_index :gaku_enrollments, :student_id 9 | add_index :gaku_enrollments, [:enrollmentable_id, :enrollmentable_type], name: :gaku_enrollments_enrollmentable 10 | end 11 | end 12 | -------------------------------------------------------------------------------- /core/db/migrate/20140423100114_clean_enrollments_join_models.rb: -------------------------------------------------------------------------------- 1 | class CleanEnrollmentsJoinModels < ActiveRecord::Migration[4.2] 2 | def change 3 | drop_table :gaku_class_group_enrollments 4 | drop_table :gaku_class_group_course_enrollments 5 | drop_table :gaku_course_enrollments 6 | drop_table :gaku_extracurricular_activity_enrollments 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /core/db/migrate/20140604104210_rename_method_to_grading_method.rb: -------------------------------------------------------------------------------- 1 | class RenameMethodToGradingMethod < ActiveRecord::Migration[4.2] 2 | def change 3 | rename_column :gaku_grading_methods, :method, :grading_type 4 | end 5 | end 6 | -------------------------------------------------------------------------------- /core/db/migrate/20140604113045_add_default_value_to_curved.rb: -------------------------------------------------------------------------------- 1 | class AddDefaultValueToCurved < ActiveRecord::Migration[4.2] 2 | def change 3 | change_column :gaku_grading_methods, :curved, :boolean, default: false 4 | end 5 | end 6 | -------------------------------------------------------------------------------- /core/db/migrate/20140610091053_add_seat_number_to_enrollments.rb: -------------------------------------------------------------------------------- 1 | class AddSeatNumberToEnrollments < ActiveRecord::Migration[4.2] 2 | def change 3 | add_column :gaku_enrollments, :seat_number, :integer 4 | end 5 | end 6 | -------------------------------------------------------------------------------- /core/db/migrate/20140701104700_change_hstore_to_string_criteria.rb: -------------------------------------------------------------------------------- 1 | class ChangeHstoreToStringCriteria < ActiveRecord::Migration[4.2] 2 | def change 3 | change_column :gaku_grading_methods, :criteria, :string 4 | end 5 | end 6 | -------------------------------------------------------------------------------- /core/db/migrate/20140715135152_create_semester_attendance_table.rb: -------------------------------------------------------------------------------- 1 | class CreateSemesterAttendanceTable < ActiveRecord::Migration[4.2] 2 | 3 | def change 4 | create_table :gaku_semester_attendances do |t| 5 | t.references :semester 6 | t.references :student 7 | 8 | t.integer :days_present, default: 0 9 | t.integer :days_absent, default: 0 10 | 11 | 12 | t.timestamps 13 | end 14 | end 15 | 16 | end 17 | -------------------------------------------------------------------------------- /core/db/migrate/20140718105226_create_student_review_categories_table.rb: -------------------------------------------------------------------------------- 1 | class CreateStudentReviewCategoriesTable < ActiveRecord::Migration[4.2] 2 | def up 3 | create_table :gaku_student_review_categories do |t| 4 | t.string :name 5 | t.timestamps 6 | end 7 | Gaku::StudentReviewCategory.create_translation_table! name: :string 8 | end 9 | def down 10 | drop_table :gaku_student_review_categories 11 | Gaku::StudentReviewCategory.drop_translation_table! 12 | end 13 | end 14 | -------------------------------------------------------------------------------- /core/db/migrate/20140728121353_create_student_review_table.rb: -------------------------------------------------------------------------------- 1 | class CreateStudentReviewTable < ActiveRecord::Migration[4.2] 2 | def change 3 | create_table :gaku_student_reviews do |t| 4 | t.references :student 5 | t.references :student_review_category 6 | t.references :student_reviewable, polymorphic: true 7 | t.text :content 8 | 9 | t.timestamps 10 | end 11 | end 12 | end 13 | -------------------------------------------------------------------------------- /core/db/migrate/20150213095508_improve_countries_and_states.rb: -------------------------------------------------------------------------------- 1 | class ImproveCountriesAndStates < ActiveRecord::Migration[4.2] 2 | def change 3 | add_column :gaku_countries, :states_required, :boolean 4 | end 5 | end 6 | -------------------------------------------------------------------------------- /core/db/migrate/20160125194100_add_gradable_to_exam_portion_score.rb: -------------------------------------------------------------------------------- 1 | class AddGradableToExamPortionScore < ActiveRecord::Migration[4.2] 2 | def change 3 | add_reference :gaku_exam_portion_scores, :gradable, polymorphic: true, index: true 4 | end 5 | end 6 | -------------------------------------------------------------------------------- /core/db/migrate/20160209100945_add_score_types_to_exam_portions.rb: -------------------------------------------------------------------------------- 1 | class AddScoreTypesToExamPortions < ActiveRecord::Migration[4.2] 2 | def change 3 | add_column :gaku_exam_portions, :score_type, :integer, default: 0 4 | add_column :gaku_exam_portions, :score_selection_options, :text, array:true, default: [] 5 | end 6 | end 7 | -------------------------------------------------------------------------------- /core/db/migrate/20160209104713_add_fields_to_exam_portion_score.rb: -------------------------------------------------------------------------------- 1 | class AddFieldsToExamPortionScore < ActiveRecord::Migration[4.2] 2 | def change 3 | add_column :gaku_exam_portion_scores, :score_text, :string 4 | add_column :gaku_exam_portion_scores, :score_selection, :string 5 | end 6 | end 7 | -------------------------------------------------------------------------------- /core/db/migrate/20170509132020_change_enrollmentable_to_enrollable.rb: -------------------------------------------------------------------------------- 1 | class ChangeEnrollmentableToEnrollable < ActiveRecord::Migration[5.0] 2 | def change 3 | rename_column :gaku_enrollments, :enrollmentable_id, :enrollable_id 4 | rename_column :gaku_enrollments, :enrollmentable_type, :enrollable_type 5 | end 6 | end 7 | -------------------------------------------------------------------------------- /core/db/migrate/20180326143207_join_models_for_syllabus_and_course_to_teacher.rb: -------------------------------------------------------------------------------- 1 | class JoinModelsForSyllabusAndCourseToTeacher < ActiveRecord::Migration[5.1] 2 | def change 3 | create_table(:gaku_syllabus_teachers) do |t| 4 | t.references :syllabus 5 | t.references :teacher 6 | end 7 | 8 | create_table(:gaku_course_teachers) do |t| 9 | t.references :course 10 | t.references :teacher 11 | end 12 | end 13 | end 14 | -------------------------------------------------------------------------------- /core/db/migrate/20180403134527_add_disabled_attributes_to_user.rb: -------------------------------------------------------------------------------- 1 | class AddDisabledAttributesToUser < ActiveRecord::Migration[5.1] 2 | def change 3 | add_column :gaku_users, :disabled_until, :date 4 | add_column :gaku_users, :disabled, :boolean, default: false 5 | end 6 | end 7 | -------------------------------------------------------------------------------- /core/db/seeds.rb: -------------------------------------------------------------------------------- 1 | # Loads seed data out of default dir 2 | default_path = File.join(File.dirname(__FILE__), 'default') 3 | 4 | Rake::Task['db:load_dir'].reenable 5 | Rake::Task['db:load_dir'].invoke(default_path) 6 | -------------------------------------------------------------------------------- /core/faye.ru: -------------------------------------------------------------------------------- 1 | require 'faye' 2 | Faye::WebSocket.load_adapter('thin') 3 | 4 | Faye.logger = ->(m) { puts m } 5 | 6 | faye_server = Faye::RackAdapter.new(mount: '/faye', timeout: 45) 7 | run faye_server 8 | -------------------------------------------------------------------------------- /core/lib/gaku/class_name_detector.rb: -------------------------------------------------------------------------------- 1 | module Gaku::ClassNameDetector 2 | def class_name 3 | "Gaku::#{controller_name.classify}" 4 | end 5 | 6 | def class_name_minus_enrollment 7 | "Gaku::#{controller_name.classify.split('Enrollment').first}" 8 | end 9 | 10 | def class_name_underscored 11 | controller_name.classify.split('Enrollment').first.underscore 12 | end 13 | 14 | def class_name_underscored_plural 15 | class_name_underscored.pluralize 16 | end 17 | 18 | def enrollment_param 19 | "#{controller_name.classify.split('Enrollment').first.underscore}_id" 20 | end 21 | end 22 | -------------------------------------------------------------------------------- /core/lib/gaku/core.rb: -------------------------------------------------------------------------------- 1 | require 'rails/all' 2 | require 'rails/generators' 3 | require 'rails-i18n' 4 | require 'paperclip' 5 | require 'ransack' 6 | # require 'deface' 7 | require 'redis' 8 | 9 | require 'devise' 10 | require 'cancancan' 11 | require 'kaminari' 12 | require 'globalize' 13 | require 'draper' 14 | require 'carmen' 15 | 16 | module Gaku 17 | module Core 18 | end 19 | 20 | def self.config(&_block) 21 | yield(Gaku::Config) 22 | end 23 | end 24 | 25 | require 'gaku/core/engine' 26 | require 'gaku/core/console_colors' 27 | require 'generators/gaku/dummy/dummy_generator' 28 | -------------------------------------------------------------------------------- /core/lib/gaku/core/console_colors.rb: -------------------------------------------------------------------------------- 1 | class String 2 | # colorization 3 | def colorize(color_code) 4 | "\e[#{color_code}m#{self}\e[0m" 5 | end 6 | 7 | def red 8 | colorize(31) 9 | end 10 | 11 | def green 12 | colorize(32) 13 | end 14 | 15 | def yellow 16 | colorize(33) 17 | end 18 | 19 | def pink 20 | colorize(35) 21 | end 22 | end 23 | -------------------------------------------------------------------------------- /core/lib/gaku/core/url_helpers.rb: -------------------------------------------------------------------------------- 1 | module Gaku::Core::UrlHelpers 2 | def gaku 3 | Gaku::Core::Engine.routes.url_helpers 4 | end 5 | end 6 | -------------------------------------------------------------------------------- /core/lib/gaku/grading/collection/ordinal.rb: -------------------------------------------------------------------------------- 1 | class Gaku::Grading::Collection::Ordinal < Gaku::Grading::Collection::BaseMethod 2 | def grade_exam 3 | @students.each do |student| 4 | @result << Gaku::Grading::Single::Ordinal.new(@gradable, student, gradable_scope, criteria).grade_exam 5 | end 6 | @result 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /core/lib/gaku/grading/collection/percentage.rb: -------------------------------------------------------------------------------- 1 | class Gaku::Grading::Collection::Percentage < Gaku::Grading::Collection::BaseMethod 2 | def grade_exam 3 | @students.each do |student| 4 | @result << Gaku::Grading::Single::Percentage.new(@gradable, student, gradable_scope).grade_exam 5 | end 6 | @result 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /core/lib/gaku/grading/collection/result.rb: -------------------------------------------------------------------------------- 1 | module Gaku 2 | module Grading 3 | module Collection 4 | class Result 5 | def initialize(exam_id, result) 6 | @exam_id = exam_id 7 | @result = result 8 | end 9 | 10 | def as_json 11 | { exam_id: @exam_id, student_results: @result }.as_json 12 | end 13 | end 14 | end 15 | end 16 | end 17 | -------------------------------------------------------------------------------- /core/lib/gaku/grading/collection/score.rb: -------------------------------------------------------------------------------- 1 | class Gaku::Grading::Collection::Score < Gaku::Grading::Collection::BaseMethod 2 | def grade_exam 3 | @students.each do |student| 4 | @result << Gaku::Grading::Single::Score.new(@gradable, student, gradable_scope).grade_exam 5 | end 6 | @result 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /core/lib/gaku/grading/single/interval.rb: -------------------------------------------------------------------------------- 1 | class Gaku::Grading::Single::Interval < Gaku::Grading::Single::BaseMethod 2 | def grade_exam 3 | @result = { id: student.first, score: student.last } 4 | end 5 | end 6 | -------------------------------------------------------------------------------- /core/lib/gaku/grading/single/ordinal.rb: -------------------------------------------------------------------------------- 1 | class Gaku::Grading::Single::Ordinal < Gaku::Grading::Single::BaseMethod 2 | # attr_accessor :criteria 3 | 4 | def grade_exam 5 | exam = @gradable 6 | percentage = Gaku::Grading::Single::Percentage.new(exam, @student, gradable_scope).grade 7 | @result = { id: @student.id, score: ordinal(percentage['score']) } 8 | end 9 | 10 | private 11 | 12 | def ordinal(percentage) 13 | if percentage 14 | criteria.sort_by(&:last).reverse.find do |_grade, min_points| 15 | percentage >= min_points.to_i 16 | end.first 17 | end 18 | end 19 | 20 | def criteria 21 | if @criteria.value?('0') 22 | @criteria 23 | else 24 | @criteria.merge('' => '0') 25 | end 26 | end 27 | end 28 | -------------------------------------------------------------------------------- /core/lib/gaku/grading/single/pass_fail.rb: -------------------------------------------------------------------------------- 1 | class Gaku::Grading::Single::PassFail < Gaku::Grading::Single::BaseMethod 2 | end 3 | -------------------------------------------------------------------------------- /core/lib/gaku/grading/single/percentage.rb: -------------------------------------------------------------------------------- 1 | class Gaku::Grading::Single::Percentage < Gaku::Grading::Single::BaseMethod 2 | attr_reader :scores 3 | 4 | def grade_exam 5 | exam = @gradable 6 | 7 | @scores = [] 8 | @max_score = exam.max_score 9 | exam.exam_portions.select(&:score?).each_with_index do |exam_portion, _index| 10 | ep_score = @student.exam_portion_scores.find_by(gradable: gradable_scope, exam_portion_id: exam_portion.id) 11 | @scores << ep_score.score if ep_score.score 12 | end 13 | 14 | @result = { id: @student.id, score: formated_score } 15 | end 16 | 17 | def score 18 | @scores.inject(:+) / @max_score unless @scores.blank? 19 | end 20 | 21 | def formated_score 22 | score.try(:*, 100).try(:round, 3) 23 | end 24 | end 25 | -------------------------------------------------------------------------------- /core/lib/gaku/grading/single/ratio.rb: -------------------------------------------------------------------------------- 1 | class Gaku::Grading::Single::Ratio < Gaku::Grading::Single::BaseMethod 2 | end 3 | -------------------------------------------------------------------------------- /core/lib/gaku/grading/single/result.rb: -------------------------------------------------------------------------------- 1 | module Gaku 2 | module Grading 3 | module Single 4 | class Result 5 | def initialize(exam_id, result) 6 | @exam_id = exam_id 7 | @result = result 8 | end 9 | 10 | def as_json 11 | @result.merge(exam_id: @exam_id).as_json 12 | end 13 | end 14 | end 15 | end 16 | end 17 | -------------------------------------------------------------------------------- /core/lib/gaku/grading/single/score.rb: -------------------------------------------------------------------------------- 1 | class Gaku::Grading::Single::Score < Gaku::Grading::Single::BaseMethod 2 | def grade_exam 3 | @score = nil 4 | exam = @gradable 5 | exam.exam_portions.select(&:score?).each_with_index do |exam_portion, index| 6 | ep_score = @student.exam_portion_scores.find_by( 7 | gradable: gradable_scope, 8 | exam_portion_id: exam_portion.id 9 | ) 10 | @score = @score.to_f + ep_score.score if ep_score.score 11 | end 12 | 13 | @result = { id: @student.id, score: @score } 14 | end 15 | end 16 | -------------------------------------------------------------------------------- /core/lib/gaku/streamer/sse.rb: -------------------------------------------------------------------------------- 1 | # change SSE.new with rails SSE object when is released 2 | # https://github.com/rails/rails/blob/master/actionpack/lib/action_controller/metal/live.rb 3 | require 'json' 4 | 5 | module Streamer 6 | class SSE 7 | def initialize(io) 8 | @io = io 9 | end 10 | 11 | def write(object, options = {}) 12 | options.each do |k, v| 13 | @io.write "#{k}: #{v}\n" 14 | end 15 | @io.write "data: #{object}\n\n" 16 | end 17 | 18 | def close 19 | @io.close 20 | end 21 | end 22 | end 23 | -------------------------------------------------------------------------------- /core/lib/gaku/testing/auth_helpers.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | include Warden::Test::Helpers 3 | 4 | module Gaku::Testing::AuthHelpers 5 | module Controller 6 | def as(user) 7 | @request.env['devise.mapping'] = ::Devise.mappings[:admin] if user == 'admin' 8 | sign_in create("#{user.to_sym}_user") 9 | end 10 | end 11 | 12 | module Feature 13 | def as(user) 14 | if user.is_a?(Symbol) 15 | login_as create("#{user.to_sym}_user"), scope: :user 16 | else 17 | login_as user, scope: :user 18 | end 19 | end 20 | end 21 | end 22 | 23 | RSpec.configure do |config| 24 | config.include Gaku::Testing::AuthHelpers::Controller, type: :controller 25 | config.include Gaku::Testing::AuthHelpers::Feature, type: :request 26 | config.include Gaku::Testing::AuthHelpers::Feature, type: :feature 27 | end 28 | -------------------------------------------------------------------------------- /core/lib/gaku/testing/coverage.rb: -------------------------------------------------------------------------------- 1 | if ENV['COVERAGE'] 2 | # Run Coverage report 3 | require 'rubygems' 4 | require 'coveralls' 5 | Coveralls.wear! 6 | 7 | require 'simplecov' 8 | puts 'Starting SimpleCov' 9 | SimpleCov.start do 10 | add_filter '/support/' 11 | add_filter '/support/requests/' 12 | add_filter '/spec/requests/**' 13 | add_filter '/config/**' 14 | add_group 'Controllers', 'app/controllers' 15 | add_group 'Helpers', 'app/helpers' 16 | add_group 'Mailers', 'app/mailers' 17 | add_group 'Models', 'app/models' 18 | add_group 'Libraries', 'lib' 19 | end 20 | end 21 | -------------------------------------------------------------------------------- /core/lib/gaku/testing/deferred_garbage_collection.rb: -------------------------------------------------------------------------------- 1 | class DeferredGarbageCollection 2 | DEFERRED_GC_THRESHOLD = (ENV['DEFER_GC'] || 10.0).to_f 3 | 4 | @last_gc_run = Time.now 5 | 6 | def self.start 7 | GC.disable if DEFERRED_GC_THRESHOLD > 0 8 | end 9 | 10 | def self.reconsider 11 | if DEFERRED_GC_THRESHOLD > 0 && Time.now - @last_gc_run >= DEFERRED_GC_THRESHOLD 12 | GC.enable 13 | GC.start 14 | GC.disable 15 | @last_gc_run = Time.now 16 | end 17 | end 18 | end 19 | -------------------------------------------------------------------------------- /core/lib/gaku/testing/factories.rb: -------------------------------------------------------------------------------- 1 | require 'factory_bot' 2 | 3 | Dir["#{File.dirname(__FILE__)}/factories/**"].each do |f| 4 | require File.expand_path(f) 5 | end 6 | -------------------------------------------------------------------------------- /core/lib/gaku/testing/factories/address_factory.rb: -------------------------------------------------------------------------------- 1 | FactoryBot.define do 2 | factory :address, class: Gaku::Address do 3 | address1 { FFaker::Address.street_address } 4 | address2 { FFaker::Address.street_address } 5 | city { FFaker::Address.city } 6 | 7 | state 8 | country 9 | 10 | after(:build) do |address| 11 | address.addressable.addresses.reload if address.addressable.respond_to?(:addresses) 12 | end 13 | 14 | factory :invalid_address do 15 | address1 { nil } 16 | end 17 | end 18 | end 19 | -------------------------------------------------------------------------------- /core/lib/gaku/testing/factories/assignment_factory.rb: -------------------------------------------------------------------------------- 1 | FactoryBot.define do 2 | factory :assignment, class: Gaku::Assignment do 3 | name { 'Assignment #1' } 4 | description { 'Assignment #1 description' } 5 | max_score { 6 } 6 | syllabus 7 | grading_method 8 | end 9 | end 10 | -------------------------------------------------------------------------------- /core/lib/gaku/testing/factories/assignment_score_factory.rb: -------------------------------------------------------------------------------- 1 | FactoryBot.define do 2 | factory :assignment_score, class: Gaku::AssignmentScore do 3 | score { 6 } 4 | student 5 | end 6 | end 7 | -------------------------------------------------------------------------------- /core/lib/gaku/testing/factories/attachment_factory.rb: -------------------------------------------------------------------------------- 1 | include ActionDispatch::TestProcess 2 | 3 | FactoryBot.define do 4 | factory :attachment, class: Gaku::Attachment do 5 | name { 'pic1' } 6 | asset_file_name { 'avatar.jpg' } 7 | asset_content_type { 'image/jpg' } 8 | end 9 | 10 | trait :for_exam_portion do 11 | association :attachable, factory: :exam_portion 12 | end 13 | end 14 | -------------------------------------------------------------------------------- /core/lib/gaku/testing/factories/attendance_factory.rb: -------------------------------------------------------------------------------- 1 | FactoryBot.define do 2 | factory :attendance, class: Gaku::Attendance do 3 | reason { 'headache' } 4 | after(:build) do |attendance| 5 | attendance.attendance_type = build(:attendance_type) 6 | attendance.student = build(:student) 7 | end 8 | end 9 | end 10 | -------------------------------------------------------------------------------- /core/lib/gaku/testing/factories/attendance_type_factory.rb: -------------------------------------------------------------------------------- 1 | FactoryBot.define do 2 | factory :attendance_type, class: Gaku::AttendanceType do 3 | name { 'Illness' } 4 | color_code { 'f0f0f0' } 5 | counted_absent { 1 } 6 | disable_credit { 1 } 7 | 8 | factory :invalid_attendance_type do 9 | name { nil } 10 | end 11 | end 12 | end 13 | -------------------------------------------------------------------------------- /core/lib/gaku/testing/factories/badge_factory.rb: -------------------------------------------------------------------------------- 1 | FactoryBot.define do 2 | factory :badge, class: Gaku::Badge do 3 | student 4 | badge_type 5 | 6 | factory :invalid_badge do 7 | student { nil } 8 | end 9 | end 10 | end 11 | -------------------------------------------------------------------------------- /core/lib/gaku/testing/factories/badge_type_factory.rb: -------------------------------------------------------------------------------- 1 | FactoryBot.define do 2 | factory :badge_type, class: Gaku::BadgeType do 3 | name { 'credits' } 4 | description { 'some helpful achievement' } 5 | 6 | factory :invalid_badge_type do 7 | name { nil } 8 | end 9 | end 10 | end 11 | -------------------------------------------------------------------------------- /core/lib/gaku/testing/factories/campus_factory.rb: -------------------------------------------------------------------------------- 1 | FactoryBot.define do 2 | factory :campus, class: Gaku::Campus do 3 | name { FFaker::Education.school_generic_name } 4 | school 5 | 6 | factory :invalid_campus do 7 | name { nil } 8 | end 9 | end 10 | 11 | trait :with_one_address do 12 | after(:create) do |campus| 13 | campus.address = create(:address, addressable: campus) 14 | campus.save 15 | end 16 | end 17 | end 18 | -------------------------------------------------------------------------------- /core/lib/gaku/testing/factories/class_group_factory.rb: -------------------------------------------------------------------------------- 1 | FactoryBot.define do 2 | factory :class_group, class: Gaku::ClassGroup do 3 | sequence(:name) { |n| "A#{n}" } 4 | 5 | grade { 8 } 6 | homeroom { '123' } 7 | 8 | factory :invalid_class_group do 9 | name { nil } 10 | end 11 | 12 | factory :class_group_with_active_semester do 13 | transient do 14 | semester { create(:active_semester) } 15 | end 16 | 17 | after(:create) do |class_group, evaluator| 18 | class_group.semesters << evaluator.semester 19 | end 20 | end 21 | end 22 | end 23 | -------------------------------------------------------------------------------- /core/lib/gaku/testing/factories/commute_method_type_factory.rb: -------------------------------------------------------------------------------- 1 | FactoryBot.define do 2 | factory :commute_method_type, class: Gaku::CommuteMethodType do 3 | name { 'Car' } 4 | 5 | factory :invalid_commute_method_type do 6 | name { nil } 7 | end 8 | end 9 | end 10 | -------------------------------------------------------------------------------- /core/lib/gaku/testing/factories/contact_creation_factory.rb: -------------------------------------------------------------------------------- 1 | FactoryBot.define do 2 | factory :contact_creation, class: Gaku::ContactCreation do 3 | data { 'gaku@example.com' } 4 | details { 'My email' } 5 | contact_type 6 | 7 | initialize_with { new(attributes) } 8 | 9 | after(:build) do |contact_creation| 10 | if contact_creation.contact.contactable.respond_to?(:contacts) 11 | contact_creation.contact.contactable.contacts.reload 12 | end 13 | end 14 | end 15 | end 16 | -------------------------------------------------------------------------------- /core/lib/gaku/testing/factories/contact_factory.rb: -------------------------------------------------------------------------------- 1 | FactoryBot.define do 2 | factory :contact, class: Gaku::Contact do 3 | data { 'gaku@example.com' } 4 | details { 'My email' } 5 | contact_type 6 | 7 | after(:build) do |contact| 8 | contact.contactable.contacts.reload if contact.contactable.respond_to?(:contacts) 9 | end 10 | 11 | factory :invalid_contact do 12 | data { nil } 13 | end 14 | end 15 | end 16 | -------------------------------------------------------------------------------- /core/lib/gaku/testing/factories/contact_type_factory.rb: -------------------------------------------------------------------------------- 1 | FactoryBot.define do 2 | factory :contact_type, class: Gaku::ContactType do 3 | sequence(:name) { |n| "Email_#{n}" } 4 | 5 | factory :invalid_contact_type do 6 | name { nil } 7 | end 8 | end 9 | end 10 | -------------------------------------------------------------------------------- /core/lib/gaku/testing/factories/country_factory.rb: -------------------------------------------------------------------------------- 1 | FactoryBot.define do 2 | factory :country, class: Gaku::Country do 3 | iso_name { 'UNITED STATES' } 4 | name { 'United States of Foo' } 5 | sequence(:iso) { |n| "US_#{n}" } 6 | sequence(:iso3) { |n| "USA_#{n}" } 7 | numcode { 840 } 8 | end 9 | end 10 | -------------------------------------------------------------------------------- /core/lib/gaku/testing/factories/course_enrollment_factory.rb: -------------------------------------------------------------------------------- 1 | # FactoryBot.define do 2 | 3 | # factory :course_enrollment, class: Gaku::CourseEnrollment do 4 | # course 5 | # student 6 | 7 | # factory :invalid_course_enrollment do 8 | # course nil 9 | # end 10 | # end 11 | 12 | # end 13 | -------------------------------------------------------------------------------- /core/lib/gaku/testing/factories/course_factory.rb: -------------------------------------------------------------------------------- 1 | FactoryBot.define do 2 | factory :course, class: Gaku::Course do 3 | code { 'A1' } 4 | 5 | factory(:invalid_course) { code { nil } } 6 | 7 | trait :with_student do 8 | after(:create) do |course| 9 | course.students << create(:student) 10 | course.save 11 | end 12 | end 13 | 14 | trait :with_enrollement do 15 | after(:create) do |course| 16 | course.enrollments << create(:course_enrollment) 17 | course.save 18 | end 19 | end 20 | end 21 | end 22 | -------------------------------------------------------------------------------- /core/lib/gaku/testing/factories/course_group_enrollment_factory.rb: -------------------------------------------------------------------------------- 1 | FactoryBot.define do 2 | factory :course_group_enrollment, class: Gaku::CourseGroupEnrollment do 3 | course_group 4 | course 5 | end 6 | end 7 | -------------------------------------------------------------------------------- /core/lib/gaku/testing/factories/course_group_factory.rb: -------------------------------------------------------------------------------- 1 | FactoryBot.define do 2 | factory :course_group, class: Gaku::CourseGroup do 3 | name { 'Math Course Group' } 4 | 5 | factory(:invalid_course_group) { name { nil } } 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /core/lib/gaku/testing/factories/department_factory.rb: -------------------------------------------------------------------------------- 1 | FactoryBot.define do 2 | factory :department, class: Gaku::Department do 3 | name { 'Mathematics' } 4 | 5 | factory :invalid_department do 6 | name { nil } 7 | end 8 | end 9 | end 10 | -------------------------------------------------------------------------------- /core/lib/gaku/testing/factories/enrollment_factory.rb: -------------------------------------------------------------------------------- 1 | %w[class_group course extracurricular_activity].each do |resource| 2 | FactoryBot.define do 3 | factory "#{resource}_enrollment", class: Gaku::Enrollment do 4 | student 5 | association :enrollable, factory: resource 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /core/lib/gaku/testing/factories/enrollment_status_factory.rb: -------------------------------------------------------------------------------- 1 | FactoryBot.define do 2 | factory :enrollment_status, class: Gaku::EnrollmentStatus do 3 | code { 'enrolled' } 4 | name { 'Enrolled' } 5 | active { false } 6 | immutable { true } 7 | end 8 | 9 | factory :enrollment_status_applicant, class: Gaku::EnrollmentStatus do 10 | code { 'applicant' } 11 | name { 'Applicant' } 12 | active { false } 13 | immutable { true } 14 | end 15 | 16 | factory :enrollment_status_admitted, class: Gaku::EnrollmentStatus do 17 | code { 'admitted' } 18 | name { 'Admitted' } 19 | active { true } 20 | immutable { true } 21 | end 22 | 23 | factory :invalid_enrollment_status, class: Gaku::EnrollmentStatus do 24 | code { nil } 25 | end 26 | end 27 | -------------------------------------------------------------------------------- /core/lib/gaku/testing/factories/exam_factory.rb: -------------------------------------------------------------------------------- 1 | FactoryBot.define do 2 | factory :exam, class: Gaku::Exam do 3 | name { 'Math exam' } 4 | weight { 4 } 5 | use_weighting { true } 6 | 7 | factory :invalid_exam do 8 | name { nil } 9 | end 10 | end 11 | 12 | trait :with_portion do 13 | after(:create) do |exam| 14 | exam.exam_portions << create(:exam_portion, exam: exam) 15 | exam.save 16 | end 17 | end 18 | 19 | trait :with_portions do 20 | after(:create) do |exam| 21 | exam.exam_portions << create(:exam_portion, exam: exam) 22 | exam.exam_portions << create(:exam_portion, exam: exam) 23 | exam.save 24 | end 25 | end 26 | end 27 | -------------------------------------------------------------------------------- /core/lib/gaku/testing/factories/exam_portion_factory.rb: -------------------------------------------------------------------------------- 1 | FactoryBot.define do 2 | factory :exam_portion, class: Gaku::ExamPortion do 3 | name { 'wow' } 4 | max_score { 100 } 5 | weight { 100 } 6 | problem_count { 1 } 7 | exam 8 | score_type { 'score' } 9 | factory(:invalid_exam_portion) { name { nil } } 10 | end 11 | end 12 | -------------------------------------------------------------------------------- /core/lib/gaku/testing/factories/exam_portion_score_factory.rb: -------------------------------------------------------------------------------- 1 | FactoryBot.define do 2 | factory :exam_portion_score, class: Gaku::ExamPortionScore do 3 | score { 5.90 } 4 | student 5 | exam_portion 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /core/lib/gaku/testing/factories/exam_schedule_factory.rb: -------------------------------------------------------------------------------- 1 | FactoryBot.define do 2 | factory :exam_schedule, class: Gaku::ExamSchedule do 3 | exam_portion 4 | schedule 5 | course 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /core/lib/gaku/testing/factories/exam_score_factory.rb: -------------------------------------------------------------------------------- 1 | FactoryBot.define do 2 | factory :exam_score, class: Gaku::ExamScore do 3 | exam 4 | score { 6 } 5 | comment { 'Excellent score' } 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /core/lib/gaku/testing/factories/exam_session_factory.rb: -------------------------------------------------------------------------------- 1 | FactoryBot.define do 2 | factory :exam_session, class: Gaku::ExamSession do 3 | name { 'Ruby Session' } 4 | session_time { 45 } 5 | session_start { Time.now } 6 | exam 7 | 8 | factory :invalid_exam_session do 9 | exam_id { '' } 10 | end 11 | end 12 | end 13 | -------------------------------------------------------------------------------- /core/lib/gaku/testing/factories/external_school_record_factory.rb: -------------------------------------------------------------------------------- 1 | FactoryBot.define do 2 | factory :external_school_record, class: Gaku::ExternalSchoolRecord do 3 | beginning { Time.now - 1.year } 4 | ending { Time.now } 5 | school 6 | student 7 | 8 | factory :invalid_external_school_record do 9 | school { nil } 10 | end 11 | end 12 | end 13 | -------------------------------------------------------------------------------- /core/lib/gaku/testing/factories/extracurricular_activity_factory.rb: -------------------------------------------------------------------------------- 1 | FactoryBot.define do 2 | factory :extracurricular_activity, class: Gaku::ExtracurricularActivity do 3 | sequence(:name) { |n| "tennis#{n}" } 4 | 5 | factory :invalid_extracurricular_activity do 6 | name { nil } 7 | end 8 | end 9 | end 10 | -------------------------------------------------------------------------------- /core/lib/gaku/testing/factories/faculty_factory.rb: -------------------------------------------------------------------------------- 1 | FactoryBot.define do 2 | factory :faculty, class: Gaku::Faculty do 3 | end 4 | end 5 | -------------------------------------------------------------------------------- /core/lib/gaku/testing/factories/grading_method_connector_factory.rb: -------------------------------------------------------------------------------- 1 | # add assigments when integrate with GradingMethodConnector 2 | %w[exam course].each do |resource| 3 | FactoryBot.define do 4 | factory "grading_method_connector_#{resource}", class: Gaku::GradingMethodConnector do 5 | grading_method 6 | association :gradable, factory: resource 7 | end 8 | end 9 | end 10 | -------------------------------------------------------------------------------- /core/lib/gaku/testing/factories/grading_method_factory.rb: -------------------------------------------------------------------------------- 1 | FactoryBot.define do 2 | factory :grading_method, class: Gaku::GradingMethod do 3 | sequence(:name) { |n| "Method #{n}" } 4 | description { 'Grading method description' } 5 | 6 | grading_type { 'score' } 7 | 8 | factory :invalid_grading_method do 9 | name { nil } 10 | end 11 | end 12 | end 13 | -------------------------------------------------------------------------------- /core/lib/gaku/testing/factories/grading_method_set_factory.rb: -------------------------------------------------------------------------------- 1 | FactoryBot.define do 2 | factory :grading_method_set, class: Gaku::GradingMethodSet do 3 | sequence(:name) { |n| "Set #{n}" } 4 | 5 | factory :invalid_grading_method_set do 6 | name { nil } 7 | end 8 | end 9 | end 10 | -------------------------------------------------------------------------------- /core/lib/gaku/testing/factories/grading_method_set_item_factory.rb: -------------------------------------------------------------------------------- 1 | FactoryBot.define do 2 | factory :grading_method_set_item, class: Gaku::GradingMethodSetItem do 3 | grading_method_set 4 | grading_method 5 | 6 | factory :invalid_grading_method_set_item do 7 | grading_method { nil } 8 | end 9 | end 10 | end 11 | -------------------------------------------------------------------------------- /core/lib/gaku/testing/factories/guardian_factory.rb: -------------------------------------------------------------------------------- 1 | FactoryBot.define do 2 | factory :guardian, class: Gaku::Guardian do 3 | name { FFaker::Name.first_name } 4 | surname { FFaker::Name.last_name } 5 | relationship { 'Relationship' } 6 | 7 | factory(:invalid_guardian) { name { nil } } 8 | end 9 | end 10 | -------------------------------------------------------------------------------- /core/lib/gaku/testing/factories/lesson_factory.rb: -------------------------------------------------------------------------------- 1 | FactoryBot.define do 2 | factory :lesson, class: Gaku::Lesson do 3 | lesson_plan 4 | end 5 | end 6 | -------------------------------------------------------------------------------- /core/lib/gaku/testing/factories/lesson_plan_factory.rb: -------------------------------------------------------------------------------- 1 | FactoryBot.define do 2 | factory :lesson_plan, class: Gaku::LessonPlan do 3 | title { 'Biology Lesson Plan' } 4 | description { 'Lesson Plan Description' } 5 | syllabus 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /core/lib/gaku/testing/factories/level_factory.rb: -------------------------------------------------------------------------------- 1 | FactoryBot.define do 2 | factory :level, class: Gaku::Level do 3 | sequence(:name) { |n| "High #{n}" } 4 | school 5 | end 6 | end 7 | -------------------------------------------------------------------------------- /core/lib/gaku/testing/factories/note_factory.rb: -------------------------------------------------------------------------------- 1 | FactoryBot.define do 2 | factory :note, class: Gaku::Note do 3 | title { 'Excellent' } 4 | content { 'Excellent student' } 5 | 6 | factory :invalid_note do 7 | title { nil } 8 | end 9 | end 10 | end 11 | -------------------------------------------------------------------------------- /core/lib/gaku/testing/factories/preset_factory.rb: -------------------------------------------------------------------------------- 1 | FactoryBot.define do 2 | factory :preset, class: Gaku::Preset do 3 | name { 'Default' } 4 | names_order { '%first %middle %last' } 5 | active { true } 6 | default { true } 7 | pagination { {} } 8 | person { {} } 9 | student { { increment_foreign_id_code: 0 } } 10 | address { {} } 11 | export_formats { {} } 12 | chooser_fields { {} } 13 | grading { {} } 14 | end 15 | end 16 | -------------------------------------------------------------------------------- /core/lib/gaku/testing/factories/program_level_factory.rb: -------------------------------------------------------------------------------- 1 | FactoryBot.define do 2 | factory :program_level, class: Gaku::ProgramLevel do 3 | program 4 | level 5 | end 6 | end 7 | -------------------------------------------------------------------------------- /core/lib/gaku/testing/factories/program_specialty.rb: -------------------------------------------------------------------------------- 1 | FactoryBot.define do 2 | factory :program_specialty, class: Gaku::ProgramSpecialty do 3 | program 4 | specialty 5 | end 6 | end 7 | -------------------------------------------------------------------------------- /core/lib/gaku/testing/factories/program_syllabus_factory.rb: -------------------------------------------------------------------------------- 1 | FactoryBot.define do 2 | factory :program_syllabus, class: Gaku::ProgramSyllabus do 3 | program 4 | syllabus 5 | level 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /core/lib/gaku/testing/factories/schedule_factory.rb: -------------------------------------------------------------------------------- 1 | FactoryBot.define do 2 | factory :schedule, class: Gaku::Schedule do 3 | starting { Time.now } 4 | ending { starting + 40.minutes } 5 | repeat { 3 } 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /core/lib/gaku/testing/factories/scholarship_status_factory.rb: -------------------------------------------------------------------------------- 1 | FactoryBot.define do 2 | factory :scholarship_status, class: Gaku::ScholarshipStatus do 3 | name { 'Self Paid' } 4 | default { true } 5 | end 6 | end 7 | -------------------------------------------------------------------------------- /core/lib/gaku/testing/factories/school_role_factory.rb: -------------------------------------------------------------------------------- 1 | FactoryBot.define do 2 | factory :school_role, class: Gaku::SchoolRole do 3 | sequence(:name) { |n| "school_role#{n}" } 4 | end 5 | end 6 | -------------------------------------------------------------------------------- /core/lib/gaku/testing/factories/school_year_factory.rb: -------------------------------------------------------------------------------- 1 | FactoryBot.define do 2 | factory :school_year, class: Gaku::SchoolYear do 3 | starting { Time.now } 4 | ending { Time.now + 1.year } 5 | 6 | factory :invalid_school_year do 7 | starting { Time.now + 1.year } 8 | ending { Time.now } 9 | end 10 | end 11 | end 12 | -------------------------------------------------------------------------------- /core/lib/gaku/testing/factories/semester_attendance_factory.rb: -------------------------------------------------------------------------------- 1 | FactoryBot.define do 2 | factory :semester_attendance, class: Gaku::SemesterAttendance do 3 | student 4 | semester 5 | end 6 | end 7 | -------------------------------------------------------------------------------- /core/lib/gaku/testing/factories/semester_connectors_factory.rb: -------------------------------------------------------------------------------- 1 | # add assigments when integrate with GradingMethodConnector 2 | %w[class_group course].each do |resource| 3 | FactoryBot.define do 4 | factory "semester_connector_#{resource}", class: Gaku::SemesterConnector do 5 | semester 6 | association :semesterable, factory: resource 7 | end 8 | end 9 | end 10 | -------------------------------------------------------------------------------- /core/lib/gaku/testing/factories/semester_factory.rb: -------------------------------------------------------------------------------- 1 | FactoryBot.define do 2 | factory :semester, class: Gaku::Semester do 3 | starting { Date.parse('2013-04-08') } 4 | ending { Date.parse('2014-04-08') } 5 | 6 | factory :invalid_semester do 7 | starting { Date.parse('2014-04-08') } 8 | ending { Date.parse('2013-04-08') } 9 | end 10 | 11 | factory :active_semester do 12 | starting { Date.today - 1.day } 13 | ending { Date.today + 1.day } 14 | end 15 | 16 | factory :upcomming_semester do 17 | starting { Date.today + 1.day } 18 | ending { Date.today + 2.day } 19 | end 20 | 21 | factory :ended_semester do 22 | starting { Date.today - 2.day } 23 | ending { Date.today - 1.day } 24 | end 25 | end 26 | end 27 | -------------------------------------------------------------------------------- /core/lib/gaku/testing/factories/simple_grade_factory.rb: -------------------------------------------------------------------------------- 1 | FactoryBot.define do 2 | factory :simple_grade, class: Gaku::SimpleGrade do 3 | score { 2.5 } 4 | award_date { Date.today } 5 | simple_grade_type 6 | student 7 | 8 | factory :invalid_simple_grade do 9 | score { nil } 10 | end 11 | end 12 | end 13 | -------------------------------------------------------------------------------- /core/lib/gaku/testing/factories/simple_grade_type_factory.rb: -------------------------------------------------------------------------------- 1 | FactoryBot.define do 2 | factory :simple_grade_type, class: Gaku::SimpleGradeType do 3 | sequence(:name) { |n| "ruby_#{n}" } 4 | grading_method 5 | school 6 | 7 | factory :invalid_simple_grade_type do 8 | name { nil } 9 | end 10 | end 11 | end 12 | -------------------------------------------------------------------------------- /core/lib/gaku/testing/factories/specialty_factory.rb: -------------------------------------------------------------------------------- 1 | FactoryBot.define do 2 | factory :specialty, class: Gaku::Specialty do 3 | name { 'Biology Specialty' } 4 | description { 'Biology Specialty Description' } 5 | major_only { 0 } 6 | 7 | factory :invalid_specialty do 8 | name { nil } 9 | end 10 | end 11 | end 12 | -------------------------------------------------------------------------------- /core/lib/gaku/testing/factories/state_factory.rb: -------------------------------------------------------------------------------- 1 | FactoryBot.define do 2 | factory :state, class: Gaku::State do 3 | name { 'Alabama' } 4 | abbr { 'AL' } 5 | country do |country| 6 | usa = Gaku::Country.find_by_numcode(840) 7 | if usa 8 | country = usa 9 | else 10 | country.association(:country) 11 | end 12 | end 13 | end 14 | end 15 | -------------------------------------------------------------------------------- /core/lib/gaku/testing/factories/student_review_category_factory.rb: -------------------------------------------------------------------------------- 1 | FactoryBot.define do 2 | factory :student_review_category, class: Gaku::StudentReviewCategory do 3 | name { 'Performance' } 4 | end 5 | end 6 | -------------------------------------------------------------------------------- /core/lib/gaku/testing/factories/student_review_factory.rb: -------------------------------------------------------------------------------- 1 | # add assigments when integrate with GradingMethodConnector 2 | %w[class_group].each do |resource| 3 | FactoryBot.define do 4 | factory "#{resource}_student_review", class: Gaku::StudentReview do 5 | content { 'Excellent student' } 6 | student 7 | student_review_category 8 | association :student_reviewable, factory: resource 9 | end 10 | end 11 | end 12 | -------------------------------------------------------------------------------- /core/lib/gaku/testing/factories/student_specialty_factory.rb: -------------------------------------------------------------------------------- 1 | FactoryBot.define do 2 | factory :student_specialty, class: Gaku::StudentSpecialty do 3 | student 4 | specialty 5 | major { true } 6 | 7 | factory :invalid_student_specialty do 8 | specialty { nil } 9 | end 10 | end 11 | end 12 | -------------------------------------------------------------------------------- /core/lib/gaku/testing/factories/syllabus_factory.rb: -------------------------------------------------------------------------------- 1 | FactoryBot.define do 2 | factory :syllabus, class: Gaku::Syllabus do 3 | name { FFaker::Name.name } 4 | code { '12345' } 5 | description { 'Short description' } 6 | credits { 'Huge Credits' } 7 | 8 | factory :invalid_syllabus do 9 | code { nil } 10 | end 11 | end 12 | 13 | trait :with_exam do 14 | after(:create) do |syllabus| 15 | syllabus.exams << create(:exam) 16 | end 17 | end 18 | end 19 | -------------------------------------------------------------------------------- /core/lib/gaku/testing/factories/teacher_factory.rb: -------------------------------------------------------------------------------- 1 | FactoryBot.define do 2 | factory :teacher, class: Gaku::Teacher do 3 | name { FFaker::Name.first_name } 4 | surname { FFaker::Name.last_name } 5 | name_reading { FFaker::Name.first_name } 6 | surname_reading { FFaker::Name.last_name } 7 | gender { true } 8 | 9 | factory :invalid_teacher do 10 | name { nil } 11 | end 12 | end 13 | end 14 | -------------------------------------------------------------------------------- /core/lib/gaku/testing/factories/template_factory.rb: -------------------------------------------------------------------------------- 1 | include ActionDispatch::TestProcess 2 | 3 | FactoryBot.define do 4 | factory :template, class: Gaku::Template do 5 | name { 'Roster Template' } 6 | context { 'spreadsheet' } 7 | file do 8 | fixture_file_upload(Rails.root + '../support/sample_roster.ods', 9 | 'application/vnd.oasis.opendocument.spreadsheet') 10 | end 11 | locked { false } 12 | 13 | factory(:invalid_template) { name { nil } } 14 | end 15 | end 16 | -------------------------------------------------------------------------------- /core/lib/gaku/testing/factories/user_role_factory.rb: -------------------------------------------------------------------------------- 1 | FactoryBot.define do 2 | factory :user_role, class: Gaku::UserRole do 3 | user 4 | role 5 | end 6 | end 7 | -------------------------------------------------------------------------------- /core/lib/gaku_core.rb: -------------------------------------------------------------------------------- 1 | require 'gaku/core' 2 | -------------------------------------------------------------------------------- /core/lib/generators/gaku/docker/templates/app/assets/javascripts/gaku/admin/all.js: -------------------------------------------------------------------------------- 1 | // This is a manifest file that'll be compiled into including all the files listed below. 2 | // Add new JavaScript/Coffee code in separate files in this directory and they'll automatically 3 | // be included in the compiled file accessible from http://example.com/assets/application.js 4 | // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the 5 | // the compiled file. 6 | // 7 | //= require jquery 8 | //= require jquery_ujs 9 | //= require gaku/admin 10 | //= require_tree . -------------------------------------------------------------------------------- /core/lib/generators/gaku/docker/templates/app/assets/javascripts/gaku/archive/all.js: -------------------------------------------------------------------------------- 1 | // This is a manifest file that'll be compiled into including all the files listed below. 2 | // Add new JavaScript/Coffee code in separate files in this directory and they'll automatically 3 | // be included in the compiled file accessible from http://example.com/assets/application.js 4 | // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the 5 | // the compiled file. 6 | // 7 | //= require jquery 8 | //= require jquery_ujs 9 | //= require gaku/archive 10 | //= require_tree . -------------------------------------------------------------------------------- /core/lib/generators/gaku/docker/templates/app/assets/javascripts/gaku/frontend/all.js: -------------------------------------------------------------------------------- 1 | // This is a manifest file that'll be compiled into including all the files listed below. 2 | // Add new JavaScript/Coffee code in separate files in this directory and they'll automatically 3 | // be included in the compiled file accessible from http://example.com/assets/application.js 4 | // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the 5 | // the compiled file. 6 | // 7 | //= require jquery 8 | //= require jquery_ujs 9 | //= require gaku/frontend 10 | //= require_tree . -------------------------------------------------------------------------------- /core/lib/generators/gaku/docker/templates/app/assets/stylesheets/gaku/admin/all.css: -------------------------------------------------------------------------------- 1 | /* 2 | * This is a manifest file that'll automatically include all the stylesheets available in this directory 3 | * and any sub-directories. You're free to add application-wide styles to this file and they'll appear at 4 | * the top of the compiled file, but it's generally better to create a new file per style scope. 5 | * 6 | *= require gaku/admin 7 | *= require_self 8 | *= require_tree . 9 | */ -------------------------------------------------------------------------------- /core/lib/generators/gaku/docker/templates/app/assets/stylesheets/gaku/archive/all.css: -------------------------------------------------------------------------------- 1 | /* 2 | * This is a manifest file that'll automatically include all the stylesheets available in this directory 3 | * and any sub-directories. You're free to add application-wide styles to this file and they'll appear at 4 | * the top of the compiled file, but it's generally better to create a new file per style scope. 5 | * 6 | *= require gaku/archive 7 | *= require_self 8 | *= require_tree . 9 | */ -------------------------------------------------------------------------------- /core/lib/generators/gaku/docker/templates/app/assets/stylesheets/gaku/frontend/all.css: -------------------------------------------------------------------------------- 1 | /* 2 | * This is a manifest file that'll automatically include all the stylesheets available in this directory 3 | * and any sub-directories. You're free to add application-wide styles to this file and they'll appear at 4 | * the top of the compiled file, but it's generally better to create a new file per style scope. 5 | * 6 | *= require gaku/frontend 7 | *= require_self 8 | *= require_tree . 9 | */ -------------------------------------------------------------------------------- /core/lib/generators/gaku/docker/templates/bin/check_postgres.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | while ! pg_isready -h postgres -p 5432 > /dev/null 2> /dev/null; do 4 | echo "Connecting to postgresql failed" 5 | sleep 1 6 | done 7 | rm /app/tmp/pids/server.pid 8 | bundle check || bundle install 9 | 10 | psql --host=postgres --port=5432 -U postgres -c "CREATE USER manabu WITH PASSWORD 'manabu';" 11 | psql --host=postgres --port=5432 -U postgres -c "ALTER USER manabu WITH SUPERUSER;" 12 | psql --host=postgres --port=5432 -U postgres -c "CREATE EXTENSION IF NOT EXISTS hstore;" 13 | 14 | bundle exec rake db:create 15 | bundle exec rake db:migrate 16 | exec "$@" 17 | -------------------------------------------------------------------------------- /core/lib/generators/gaku/docker/templates/config/database.yml: -------------------------------------------------------------------------------- 1 | development: 2 | url: postgres://manabu:manabu@postgres:5432/gaku_development 3 | -------------------------------------------------------------------------------- /core/lib/generators/gaku/dummy/templates/rails/application.rb: -------------------------------------------------------------------------------- 1 | require File.expand_path('../boot', __FILE__) 2 | 3 | require 'rails/all' 4 | 5 | Bundler.require(:default, Rails.env) 6 | 7 | require '<%= lib_name %>' 8 | 9 | <%= application_definition %> 10 | -------------------------------------------------------------------------------- /core/lib/generators/gaku/dummy/templates/rails/boot.rb: -------------------------------------------------------------------------------- 1 | require 'rubygems' 2 | gemfile = File.expand_path('<%= gemfile_path %>', __FILE__) 3 | 4 | ENV['BUNDLE_GEMFILE'] = gemfile 5 | require 'bundler' 6 | Bundler.setup 7 | -------------------------------------------------------------------------------- /core/lib/generators/gaku/dummy/templates/rails/database.yml: -------------------------------------------------------------------------------- 1 | default: &default 2 | host: localhost 3 | adapter: postgresql 4 | username: manabu 5 | password: manabu 6 | min_messages: warning 7 | 8 | development: 9 | <<: *default 10 | database: gaku_development 11 | 12 | 13 | test: 14 | <<: *default 15 | database: gaku_test 16 | port: 5434 17 | 18 | production: 19 | <<: *default 20 | database: gaku_production 21 | -------------------------------------------------------------------------------- /core/lib/generators/gaku/dummy/templates/rails/routes.rb: -------------------------------------------------------------------------------- 1 | Rails.application.routes.draw do 2 | <%= 'mount Gaku::Core::Engine => "/"' if defined?(Gaku::Core) %> 3 | end 4 | -------------------------------------------------------------------------------- /core/lib/generators/gaku/dummy/templates/rails/script/rails: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | # This command will automatically be run when you run "rails" with Rails 3 3 | # gems installed from the root of your application. 4 | 5 | APP_PATH = File.expand_path('../../config/application', __FILE__) 6 | require File.expand_path('../../config/boot', __FILE__) 7 | require 'rails/commands' 8 | -------------------------------------------------------------------------------- /core/lib/generators/gaku/install/templates/Procfile: -------------------------------------------------------------------------------- 1 | #web: bundle exec puma 2 | websocket: coffee lib/grading/bin/gaku_grading.coffee 3 | #worker: sidekiq 4 | -------------------------------------------------------------------------------- /core/lib/generators/gaku/install/templates/app/assets/javascripts/gaku/admin/all.js: -------------------------------------------------------------------------------- 1 | // This is a manifest file that'll be compiled into including all the files listed below. 2 | // Add new JavaScript/Coffee code in separate files in this directory and they'll automatically 3 | // be included in the compiled file accessible from http://example.com/assets/application.js 4 | // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the 5 | // the compiled file. 6 | // 7 | //= require jquery 8 | //= require jquery_ujs 9 | //= require gaku/admin 10 | //= require_tree . -------------------------------------------------------------------------------- /core/lib/generators/gaku/install/templates/app/assets/javascripts/gaku/archive/all.js: -------------------------------------------------------------------------------- 1 | // This is a manifest file that'll be compiled into including all the files listed below. 2 | // Add new JavaScript/Coffee code in separate files in this directory and they'll automatically 3 | // be included in the compiled file accessible from http://example.com/assets/application.js 4 | // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the 5 | // the compiled file. 6 | // 7 | //= require jquery 8 | //= require jquery_ujs 9 | //= require gaku/archive 10 | //= require_tree . -------------------------------------------------------------------------------- /core/lib/generators/gaku/install/templates/app/assets/javascripts/gaku/frontend/all.js: -------------------------------------------------------------------------------- 1 | // This is a manifest file that'll be compiled into including all the files listed below. 2 | // Add new JavaScript/Coffee code in separate files in this directory and they'll automatically 3 | // be included in the compiled file accessible from http://example.com/assets/application.js 4 | // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the 5 | // the compiled file. 6 | // 7 | //= require jquery 8 | //= require jquery_ujs 9 | //= require gaku/frontend 10 | //= require_tree . -------------------------------------------------------------------------------- /core/lib/generators/gaku/install/templates/app/assets/stylesheets/gaku/admin/all.css: -------------------------------------------------------------------------------- 1 | /* 2 | * This is a manifest file that'll automatically include all the stylesheets available in this directory 3 | * and any sub-directories. You're free to add application-wide styles to this file and they'll appear at 4 | * the top of the compiled file, but it's generally better to create a new file per style scope. 5 | * 6 | *= require gaku/admin 7 | *= require_self 8 | *= require_tree . 9 | */ -------------------------------------------------------------------------------- /core/lib/generators/gaku/install/templates/app/assets/stylesheets/gaku/archive/all.css: -------------------------------------------------------------------------------- 1 | /* 2 | * This is a manifest file that'll automatically include all the stylesheets available in this directory 3 | * and any sub-directories. You're free to add application-wide styles to this file and they'll appear at 4 | * the top of the compiled file, but it's generally better to create a new file per style scope. 5 | * 6 | *= require gaku/archive 7 | *= require_self 8 | *= require_tree . 9 | */ -------------------------------------------------------------------------------- /core/lib/generators/gaku/install/templates/app/assets/stylesheets/gaku/frontend/all.css: -------------------------------------------------------------------------------- 1 | /* 2 | * This is a manifest file that'll automatically include all the stylesheets available in this directory 3 | * and any sub-directories. You're free to add application-wide styles to this file and they'll appear at 4 | * the top of the compiled file, but it's generally better to create a new file per style scope. 5 | * 6 | *= require gaku/frontend 7 | *= require_self 8 | *= require_tree . 9 | */ -------------------------------------------------------------------------------- /core/lib/generators/gaku/install/templates/lib/grading/README.md: -------------------------------------------------------------------------------- 1 | Gaku grading 2 | ============ -------------------------------------------------------------------------------- /core/lib/generators/gaku/install/templates/lib/grading/bin/gaku_grading.coffee: -------------------------------------------------------------------------------- 1 | #!/usr/bin/coffee 2 | 3 | io = require("socket.io").listen(5001) 4 | redis = require("redis").createClient() 5 | 6 | redis.subscribe "grading-change" 7 | 8 | io.on "connection", (socket) -> 9 | console.log 'Connected to GAKU' 10 | 11 | redis.on "message", (channel, message) -> 12 | console.log(channel, message) 13 | socket.emit "grading-change", JSON.parse(message) 14 | -------------------------------------------------------------------------------- /core/lib/generators/gaku/install/templates/lib/grading/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "gaku_grading", 3 | "version": "0.0.1", 4 | "description": "Gaku grading connects to gaku via socket.io", 5 | "main": "./bin/gaku_grading", 6 | 7 | "bin": { 8 | "gaku_grading": "./bin/gaku_grading" 9 | }, 10 | "repository": "", 11 | "author": "Vassil Kalkov", 12 | "license": "BSD", 13 | 14 | "dependencies": { 15 | "socket.io": "latest" 16 | , "redis": "latest" 17 | , "coffee-script": "latest" 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /core/lib/tasks/grading.rake: -------------------------------------------------------------------------------- 1 | namespace :gaku do 2 | namespace :grading do 3 | desc '!!! Reset DB and delete migrations !!!' 4 | task setup: :environment do 5 | system('cd lib/grading; npm install') 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /core/lib/tasks/testing.rake: -------------------------------------------------------------------------------- 1 | namespace :testing do 2 | desc 'Setup test enviroment' 3 | task env_setup: :environment do 4 | admin_role = Gaku::Role.where(name: 'admin').first_or_create 5 | 6 | user = Gaku::User.where(username: 'admin').first_or_create(email: 'admin@gakuengine.com', password: '123456') 7 | user.roles << admin_role 8 | 9 | Gaku::ContactType.where(name: 'email').first_or_create 10 | Gaku::EnrollmentStatus.where(name: 'enrolled', code: 'enrolled', active: true).first_or_create 11 | end 12 | end 13 | -------------------------------------------------------------------------------- /core/spec/lib/gaku/grading/collection/result_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper_models' 2 | 3 | describe Gaku::Grading::Collection::Result do 4 | subject { described_class.new(1, id: 2, score: 33) } 5 | 6 | describe '.initialize' do 7 | it 'initializes result hash' do 8 | expect(subject.as_json).to eq({ exam_id: 1, student_results: { id: 2, score: 33 } }.as_json) 9 | end 10 | end 11 | end 12 | -------------------------------------------------------------------------------- /core/spec/lib/gaku/grading/single/result_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper_models' 2 | 3 | describe Gaku::Grading::Single::Result do 4 | subject { described_class.new(1, id: 2, score: 33) } 5 | 6 | describe '.initialize' do 7 | it 'initializes result hash' do 8 | expect(subject.as_json).to eq({ exam_id: 1, id: 2, score: 33 }.as_json) 9 | end 10 | end 11 | end 12 | -------------------------------------------------------------------------------- /core/spec/models/assignment_score_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper_models' 2 | 3 | describe Gaku::AssignmentScore, type: :model do 4 | describe 'relations' do 5 | it { is_expected.to belong_to :student } 6 | end 7 | 8 | describe 'validations' do 9 | it { is_expected.to validate_presence_of :score } 10 | it { is_expected.to validate_presence_of :student } 11 | end 12 | 13 | describe '#to_s' do 14 | let(:assignment_score) { build(:assignment_score) } 15 | 16 | specify { assignment_score.to_s.should eq assignment_score.score } 17 | end 18 | end 19 | -------------------------------------------------------------------------------- /core/spec/models/assignment_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper_models' 2 | 3 | describe Gaku::Assignment, type: :model do 4 | describe 'relations' do 5 | it { is_expected.to belong_to :syllabus } 6 | it { is_expected.to belong_to :grading_method } 7 | end 8 | 9 | describe 'validations' do 10 | it { is_expected.to validate_presence_of :name } 11 | end 12 | 13 | describe '#to_s' do 14 | let(:assignment) { build(:assignment) } 15 | 16 | specify { assignment.to_s.should eq assignment.name } 17 | end 18 | end 19 | -------------------------------------------------------------------------------- /core/spec/models/attachment_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper_models' 2 | 3 | describe Gaku::Attachment, type: :model do 4 | describe 'associations' do 5 | it { is_expected.to belong_to :attachable } 6 | end 7 | 8 | describe 'validations' do 9 | it { is_expected.to validate_presence_of :name } 10 | it { is_expected.to validate_attachment_presence(:asset) } 11 | it { is_expected.to have_attached_file :asset } 12 | end 13 | 14 | describe '#to_s' do 15 | let(:attachment) { build(:attachment) } 16 | 17 | specify { attachment.to_s.should eq attachment.name } 18 | end 19 | end 20 | -------------------------------------------------------------------------------- /core/spec/models/attendance_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper_models' 2 | 3 | describe Gaku::Attendance, type: :model do 4 | describe 'relations' do 5 | it { is_expected.to belong_to :attendance_type } 6 | it { is_expected.to belong_to :attendancable } 7 | it { is_expected.to belong_to :student } 8 | end 9 | 10 | describe 'validations' do 11 | it { is_expected.to validate_presence_of :student } 12 | it { is_expected.to validate_presence_of :attendance_type } 13 | end 14 | 15 | describe '#to_s' do 16 | let(:attendance) { build(:attendance) } 17 | 18 | specify { attendance.to_s.should eq attendance.reason } 19 | end 20 | end 21 | -------------------------------------------------------------------------------- /core/spec/models/attendance_type_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper_models' 2 | 3 | describe Gaku::AttendanceType, type: :model do 4 | describe 'relations' do 5 | it { is_expected.to have_many :attendances } 6 | end 7 | 8 | describe 'validations' do 9 | it { is_expected.to validate_presence_of :name } 10 | it { is_expected.to validate_uniqueness_of :name } 11 | end 12 | 13 | describe '#to_s' do 14 | let(:attendance_type) { build(:attendance_type) } 15 | 16 | specify { attendance_type.to_s.should eq attendance_type.name } 17 | end 18 | end 19 | -------------------------------------------------------------------------------- /core/spec/models/badge_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper_models' 2 | 3 | describe Gaku::Badge, type: :model do 4 | describe 'associations' do 5 | it { is_expected.to belong_to :badge_type } 6 | it { is_expected.to belong_to :student } 7 | end 8 | 9 | describe 'validations' do 10 | it { is_expected.to validate_presence_of :student_id } 11 | it { is_expected.to validate_presence_of :badge_type_id } 12 | end 13 | end 14 | -------------------------------------------------------------------------------- /core/spec/models/badge_type_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper_models' 2 | 3 | describe Gaku::BadgeType, type: :model do 4 | describe 'relations' do 5 | it { is_expected.to have_many :badges } 6 | it { is_expected.to have_many(:students).through(:badges) } 7 | end 8 | 9 | describe 'validations' do 10 | it { is_expected.to have_attached_file :badge_image } 11 | it { is_expected.to validate_presence_of :name } 12 | end 13 | 14 | describe '#to_s' do 15 | let(:badge_type) { build(:badge_type) } 16 | 17 | specify { badge_type.to_s.should eq badge_type.name } 18 | end 19 | end 20 | -------------------------------------------------------------------------------- /core/spec/models/commute_method_type_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper_models' 2 | 3 | describe Gaku::CommuteMethodType, type: :model do 4 | describe 'associations' do 5 | it { is_expected.to have_many :students } 6 | end 7 | 8 | describe 'validations' do 9 | it { is_expected.to validate_presence_of :name } 10 | it { is_expected.to validate_uniqueness_of :name } 11 | end 12 | 13 | describe '#to_s' do 14 | let(:commute_method_type) { build(:commute_method_type) } 15 | 16 | specify { commute_method_type.to_s.should eq commute_method_type.name } 17 | end 18 | end 19 | -------------------------------------------------------------------------------- /core/spec/models/contact_type_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper_models' 2 | 3 | describe Gaku::ContactType, type: :model do 4 | describe 'relations' do 5 | it { is_expected.to have_many :contacts } 6 | end 7 | 8 | describe 'validations' do 9 | it { is_expected.to validate_presence_of :name } 10 | it { is_expected.to validate_uniqueness_of(:name).case_insensitive } 11 | end 12 | 13 | describe '#to_s' do 14 | let(:contact_type) { build(:contact_type) } 15 | 16 | specify { contact_type.to_s.should eq contact_type.name } 17 | end 18 | end 19 | -------------------------------------------------------------------------------- /core/spec/models/country_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper_models' 2 | 3 | describe Gaku::Country, type: :model do 4 | describe 'associations' do 5 | it { is_expected.to have_many :states } 6 | end 7 | 8 | describe 'validations' do 9 | it { is_expected.to validate_presence_of :name } 10 | it { is_expected.to validate_presence_of :iso_name } 11 | it { is_expected.to validate_presence_of :iso } 12 | it { is_expected.to validate_uniqueness_of :iso } 13 | end 14 | 15 | describe '#to_s' do 16 | let(:country) { build(:country) } 17 | 18 | specify { country.to_s.should eq country.name } 19 | end 20 | end 21 | -------------------------------------------------------------------------------- /core/spec/models/course_group_enrollment_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper_models' 2 | 3 | describe Gaku::CourseGroupEnrollment, type: :model do 4 | describe 'associations' do 5 | it { is_expected.to belong_to :course_group } 6 | it { is_expected.to belong_to :course } 7 | end 8 | 9 | describe 'validations' do 10 | it { is_expected.to validate_presence_of :course_group_id } 11 | it { is_expected.to validate_presence_of :course_id } 12 | it do 13 | expect(subject).to validate_uniqueness_of(:course_id).scoped_to(:course_group_id) 14 | .with_message(/Already enrolled to this course group!/) 15 | end 16 | end 17 | end 18 | -------------------------------------------------------------------------------- /core/spec/models/course_group_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper_models' 2 | 3 | describe Gaku::CourseGroup, type: :model do 4 | describe 'associations' do 5 | it { is_expected.to have_many :course_group_enrollments } 6 | it { is_expected.to have_many(:courses).through(:course_group_enrollments) } 7 | end 8 | 9 | describe 'validations' do 10 | it { is_expected.to validate_presence_of :name } 11 | end 12 | 13 | describe '#to_s' do 14 | let(:course_group) { build(:course_group) } 15 | 16 | specify { course_group.to_s.should eq course_group.name } 17 | end 18 | end 19 | -------------------------------------------------------------------------------- /core/spec/models/department_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper_models' 2 | 3 | describe Gaku::Department, type: :model do 4 | describe 'associations' do 5 | it { is_expected.to have_many :specialties } 6 | it { is_expected.to have_many :syllabuses } 7 | it { is_expected.to have_many :exams } 8 | end 9 | 10 | describe 'validations' do 11 | it { is_expected.to validate_presence_of :name } 12 | it { is_expected.to validate_uniqueness_of :name } 13 | end 14 | 15 | describe '#to_s' do 16 | let(:department) { build(:department) } 17 | 18 | specify { department.to_s.should eq department.name } 19 | end 20 | end 21 | -------------------------------------------------------------------------------- /core/spec/models/enrollment_status_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper_models' 2 | 3 | describe Gaku::EnrollmentStatus, type: :model do 4 | describe 'associations' do 5 | it { is_expected.to have_many :students } 6 | end 7 | 8 | describe 'validations' do 9 | it { is_expected.to validate_presence_of :code } 10 | it { is_expected.to validate_uniqueness_of :code } 11 | end 12 | 13 | describe '#to_s' do 14 | let(:enrollment_status) { build(:enrollment_status) } 15 | 16 | specify { enrollment_status.to_s.should eq enrollment_status.name } 17 | end 18 | 19 | describe 'it sets name if missing' do 20 | let(:enrollment_status) { create(:enrollment_status, name: nil) } 21 | 22 | specify { enrollment_status.name.should eq enrollment_status.code } 23 | end 24 | end 25 | -------------------------------------------------------------------------------- /core/spec/models/exam_portion_score_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper_models' 2 | 3 | describe Gaku::ExamPortionScore, type: :model do 4 | describe 'relations' do 5 | it { is_expected.to belong_to :exam_portion } 6 | it { is_expected.to belong_to :student } 7 | it { is_expected.to have_many :attendances } 8 | end 9 | 10 | describe 'validations' do 11 | it { is_expected.to validate_presence_of :student } 12 | it { is_expected.to validate_presence_of :exam_portion } 13 | end 14 | end 15 | -------------------------------------------------------------------------------- /core/spec/models/exam_schedule_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper_models' 2 | 3 | describe Gaku::ExamSchedule, type: :model do 4 | describe 'relations' do 5 | it { is_expected.to belong_to :exam_portion } 6 | it { is_expected.to belong_to :schedule } 7 | it { is_expected.to belong_to :course } 8 | end 9 | 10 | describe 'validations' do 11 | it { is_expected.to validate_presence_of :schedule } 12 | it { is_expected.to validate_presence_of :exam_portion } 13 | it { is_expected.to validate_presence_of :course } 14 | end 15 | end 16 | -------------------------------------------------------------------------------- /core/spec/models/exam_score_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper_models' 2 | 3 | describe Gaku::ExamScore, type: :model do 4 | describe 'relations' do 5 | it { is_expected.to belong_to :exam } 6 | end 7 | 8 | describe 'validations' do 9 | it { is_expected.to validate_presence_of :exam } 10 | it { is_expected.to validate_presence_of :score } 11 | it { is_expected.to validate_numericality_of :score } 12 | end 13 | end 14 | -------------------------------------------------------------------------------- /core/spec/models/exam_session_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper_models' 2 | 3 | describe Gaku::ExamSession, type: :model do 4 | it_behaves_like 'enrollable' 5 | 6 | describe 'relations' do 7 | it { is_expected.to belong_to :exam } 8 | end 9 | 10 | describe '#to_s' do 11 | let(:exam_session) { build(:exam_session) } 12 | 13 | specify { exam_session.to_s.should eq exam_session.name } 14 | end 15 | end 16 | -------------------------------------------------------------------------------- /core/spec/models/exam_syllabus_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper_models' 2 | 3 | describe Gaku::ExamSyllabus, type: :model do 4 | describe 'relations' do 5 | it { is_expected.to belong_to :exam } 6 | it { is_expected.to belong_to :syllabus } 7 | end 8 | 9 | describe 'validations' do 10 | it { is_expected.to validate_presence_of :exam_id } 11 | it { is_expected.to validate_presence_of :syllabus_id } 12 | it { is_expected.to validate_uniqueness_of(:syllabus_id).scoped_to(:exam_id).with_message(/Exam already added!/) } 13 | end 14 | end 15 | -------------------------------------------------------------------------------- /core/spec/models/factories_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper_models' 2 | 3 | FactoryBot.factories.each do |factory| 4 | describe "Factory for :#{factory.name}" do 5 | if factory.name.to_s.include? 'invalid' 6 | it('is invalid') { build(factory.name).should be_invalid } 7 | elsif factory.name.to_s.include?('creation') 8 | else 9 | it('is valid') { build(factory.name).should be_valid } 10 | end 11 | end 12 | end 13 | -------------------------------------------------------------------------------- /core/spec/models/faculty_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper_models' 2 | 3 | describe Gaku::Faculty, type: :model do 4 | describe 'concerns' do 5 | it_behaves_like 'contactable' 6 | it_behaves_like 'addressable' 7 | end 8 | 9 | describe 'associations' do 10 | it { is_expected.to have_many :school_roles } 11 | it { is_expected.to have_many :students } 12 | it { is_expected.to have_many :class_groups } 13 | it { is_expected.to have_many :courses } 14 | end 15 | end 16 | -------------------------------------------------------------------------------- /core/spec/models/grading_method_connector_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper_models' 2 | 3 | describe Gaku::GradingMethodConnector, type: :model do 4 | describe 'associations' do 5 | it { is_expected.to belong_to :gradable } 6 | it { is_expected.to belong_to :grading_method } 7 | end 8 | 9 | describe 'validations' do 10 | it { is_expected.to validate_presence_of :grading_method_id } 11 | it { is_expected.to validate_presence_of :gradable_id } 12 | it { is_expected.to validate_presence_of :gradable_type } 13 | it { is_expected.to validate_inclusion_of(:gradable_type).in_array(%w[Gaku::Exam Gaku::Course]) } 14 | it { is_expected.to validate_uniqueness_of(:grading_method_id).scoped_to(%i[gradable_type gradable_id]) } 15 | end 16 | end 17 | -------------------------------------------------------------------------------- /core/spec/models/grading_method_set_item_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper_models' 2 | 3 | describe Gaku::GradingMethodSetItem, type: :model do 4 | describe 'associations' do 5 | it { is_expected.to belong_to :grading_method } 6 | it { is_expected.to belong_to :grading_method_set } 7 | end 8 | 9 | describe 'validations' do 10 | it do 11 | expect(subject).to validate_uniqueness_of(:grading_method_id) 12 | .scoped_to(:grading_method_set_id) 13 | .with_message('Grading Method already added to Grading Method Set') 14 | end 15 | 16 | it { is_expected.to validate_presence_of :grading_method_id } 17 | it { is_expected.to validate_presence_of :grading_method_set_id } 18 | end 19 | end 20 | -------------------------------------------------------------------------------- /core/spec/models/lesson_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper_models' 2 | 3 | describe Gaku::Lesson, type: :model do 4 | describe 'relations' do 5 | it { is_expected.to belong_to :lesson_plan } 6 | it { is_expected.to have_many :attendances } 7 | end 8 | 9 | describe 'validations' do 10 | it { is_expected.to validate_presence_of :lesson_plan } 11 | end 12 | end 13 | -------------------------------------------------------------------------------- /core/spec/models/level_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper_models' 2 | 3 | describe Gaku::Level, type: :model do 4 | describe 'validations' do 5 | it { is_expected.to validate_presence_of :name } 6 | it { is_expected.to validate_uniqueness_of :name } 7 | it { is_expected.to validate_presence_of :school } 8 | end 9 | 10 | describe 'relations' do 11 | it { is_expected.to have_many :program_levels } 12 | it { is_expected.to have_many(:programs).through(:program_levels) } 13 | it { is_expected.to belong_to :school } 14 | end 15 | 16 | describe '#to_s' do 17 | let(:level) { build(:level) } 18 | 19 | specify { level.to_s.should eq level.name } 20 | end 21 | end 22 | -------------------------------------------------------------------------------- /core/spec/models/note_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper_models' 2 | 3 | describe Gaku::Note, type: :model do 4 | describe 'associations' do 5 | it { is_expected.to belong_to :notable } 6 | end 7 | 8 | describe 'validations' do 9 | it { is_expected.to validate_presence_of :title } 10 | it { is_expected.to validate_presence_of :content } 11 | end 12 | end 13 | -------------------------------------------------------------------------------- /core/spec/models/preset_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper_models' 2 | 3 | describe Gaku::Preset, type: :model do 4 | it 'responds to .default' do 5 | expect(Gaku::Preset).to respond_to(:default) 6 | end 7 | 8 | it 'responds to .active' do 9 | expect(Gaku::Preset).to respond_to(:active) 10 | end 11 | 12 | it 'responds to .per_page' do 13 | expect(Gaku::Preset).to respond_to(:per_page) 14 | end 15 | 16 | it 'responds to .address' do 17 | expect(Gaku::Preset).to respond_to(:address) 18 | end 19 | end 20 | -------------------------------------------------------------------------------- /core/spec/models/program_level_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper_models' 2 | 3 | describe Gaku::ProgramLevel, type: :model do 4 | describe 'associations' do 5 | it { is_expected.to belong_to :program } 6 | it { is_expected.to belong_to :level } 7 | end 8 | 9 | describe 'validations' do 10 | it { is_expected.to validate_presence_of :level } 11 | # it { should validate_presence_of :program } 12 | end 13 | end 14 | -------------------------------------------------------------------------------- /core/spec/models/program_specialty_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper_models' 2 | 3 | describe Gaku::ProgramSpecialty, type: :model do 4 | describe 'associations' do 5 | it { is_expected.to belong_to :program } 6 | it { is_expected.to belong_to :specialty } 7 | end 8 | 9 | describe 'validations' do 10 | it { is_expected.to validate_presence_of :specialty } 11 | # it { should validate_presence_of :program } 12 | end 13 | end 14 | -------------------------------------------------------------------------------- /core/spec/models/program_syllabus_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper_models' 2 | describe Gaku::ProgramSyllabus, type: :model do 3 | describe 'associations' do 4 | it { is_expected.to belong_to :program } 5 | it { is_expected.to belong_to :syllabus } 6 | it { is_expected.to belong_to :level } 7 | end 8 | 9 | describe 'validations' do 10 | # it { should validate_presence_of :level } 11 | it { is_expected.to validate_presence_of :syllabus } 12 | # it { should validate_presence_of :program } 13 | end 14 | end 15 | -------------------------------------------------------------------------------- /core/spec/models/role_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper_models' 2 | 3 | describe Gaku::Role, type: :model do 4 | describe 'associations' do 5 | it { is_expected.to have_many :user_roles } 6 | it { is_expected.to have_many(:users).through(:user_roles) } 7 | end 8 | 9 | describe 'validations' do 10 | it { is_expected.to validate_presence_of :name } 11 | end 12 | 13 | describe '#to_s' do 14 | let(:role) { build(:role) } 15 | 16 | specify { role.to_s.should eq role.name } 17 | end 18 | end 19 | -------------------------------------------------------------------------------- /core/spec/models/scholarship_status_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper_models' 2 | 3 | describe Gaku::ScholarshipStatus, type: :model do 4 | describe 'associations' do 5 | it { is_expected.to have_many :students } 6 | end 7 | 8 | describe 'validations' do 9 | it { is_expected.to validate_presence_of :name } 10 | it { is_expected.to validate_uniqueness_of :name } 11 | end 12 | 13 | describe '#to_s' do 14 | let(:scholarship_status) { build(:scholarship_status) } 15 | 16 | specify { scholarship_status.to_s.should eq scholarship_status.name } 17 | end 18 | end 19 | -------------------------------------------------------------------------------- /core/spec/models/school_role_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper_models' 2 | 3 | describe Gaku::SchoolRole, type: :model do 4 | describe 'relations' do 5 | it { is_expected.to belong_to :school_rolable } 6 | end 7 | 8 | describe 'validations' do 9 | it { is_expected.to validate_presence_of :name } 10 | it { is_expected.to validate_uniqueness_of :name } 11 | end 12 | 13 | describe '#to_s' do 14 | let(:school_role) { build(:school_role) } 15 | 16 | specify { school_role.to_s.should eq school_role.name } 17 | end 18 | end 19 | -------------------------------------------------------------------------------- /core/spec/models/school_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper_models' 2 | 3 | describe Gaku::School, type: :model do 4 | describe 'concerns' do 5 | it_behaves_like 'avatarable' 6 | end 7 | 8 | describe 'associations' do 9 | it { is_expected.to have_many :levels } 10 | it { is_expected.to have_many :campuses } 11 | it { is_expected.to have_many :simple_grade_types } 12 | it { is_expected.to have_many :programs } 13 | it { is_expected.to have_one :master_campus } 14 | end 15 | 16 | describe 'validations' do 17 | it { is_expected.to validate_presence_of :name } 18 | xit { is_expected.to validate_uniqueness_of :name } 19 | end 20 | end 21 | -------------------------------------------------------------------------------- /core/spec/models/school_year_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper_models' 2 | describe Gaku::SchoolYear, type: :model do 3 | describe 'associations' do 4 | it { is_expected.to have_many :semesters } 5 | end 6 | 7 | describe 'validations' do 8 | it { is_expected.to validate_presence_of :starting } 9 | it { is_expected.to validate_presence_of :ending } 10 | 11 | it 'validation error for ending before after' do 12 | school_year = Gaku::SchoolYear.create starting: Date.parse('2013-4-8'), ending: Date.parse('2013-4-7') 13 | expect(school_year).not_to be_valid 14 | expect(school_year.errors[:base].count).to eq(1) 15 | end 16 | end 17 | end 18 | -------------------------------------------------------------------------------- /core/spec/models/semester_attendance_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper_models' 2 | 3 | describe Gaku::SemesterAttendance, type: :model do 4 | describe 'relations' do 5 | it { is_expected.to belong_to :semester } 6 | it { is_expected.to belong_to :student } 7 | end 8 | 9 | # describe 'validations' do 10 | # it { should validate_presence_of :student } 11 | # it { should validate_presence_of :attendance_type } 12 | # end 13 | end 14 | -------------------------------------------------------------------------------- /core/spec/models/semester_connector_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper_models' 2 | 3 | describe Gaku::SemesterConnector, type: :model do 4 | describe 'associations' do 5 | it { is_expected.to belong_to :semester } 6 | it { is_expected.to belong_to :semesterable } 7 | end 8 | 9 | describe 'validations' do 10 | it { is_expected.to validate_presence_of :semester_id } 11 | it { is_expected.to validate_presence_of :semesterable_id } 12 | it { is_expected.to validate_presence_of :semesterable_type } 13 | 14 | it do 15 | expect(subject).to validate_uniqueness_of(:semester_id).scoped_to(%i[semesterable_id semesterable_type]) 16 | # .with_message(/Semester already added/) 17 | end 18 | 19 | it { is_expected.to validate_inclusion_of(:semesterable_type).in_array(%w[Gaku::ClassGroup Gaku::Course]) } 20 | end 21 | end 22 | -------------------------------------------------------------------------------- /core/spec/models/simple_grade_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper_models' 2 | 3 | describe Gaku::SimpleGrade, type: :model do 4 | describe 'associations' do 5 | it { is_expected.to belong_to :simple_grade_type } 6 | it { is_expected.to belong_to :student } 7 | end 8 | 9 | describe 'validations' do 10 | it { is_expected.to validate_presence_of :simple_grade_type_id } 11 | it { is_expected.to validate_presence_of :student_id } 12 | it { is_expected.to validate_presence_of :score } 13 | end 14 | end 15 | -------------------------------------------------------------------------------- /core/spec/models/simple_grade_type_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper_models' 2 | 3 | describe Gaku::SimpleGradeType, type: :model do 4 | describe 'associations' do 5 | it { is_expected.to belong_to :school } 6 | it { is_expected.to belong_to :grading_method } 7 | end 8 | 9 | describe 'validations' do 10 | it { is_expected.to validate_presence_of :name } 11 | end 12 | 13 | describe '#to_s' do 14 | let(:simple_grade_type) { build(:simple_grade_type) } 15 | 16 | specify { simple_grade_type.to_s.should eq simple_grade_type.name } 17 | end 18 | end 19 | -------------------------------------------------------------------------------- /core/spec/models/specialty_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper_models' 2 | 3 | describe Gaku::Specialty, type: :model do 4 | describe 'associations' do 5 | it { is_expected.to have_many :student_specialties } 6 | it { is_expected.to have_many(:students).through(:student_specialties) } 7 | 8 | it { is_expected.to have_many(:program_specialties) } 9 | it { is_expected.to have_many(:programs).through(:program_specialties) } 10 | 11 | it { is_expected.to belong_to :department } 12 | end 13 | 14 | describe 'validations' do 15 | it { is_expected.to validate_presence_of :name } 16 | it { is_expected.to validate_uniqueness_of :name } 17 | end 18 | 19 | describe '#to_s' do 20 | let(:specialty) { build(:specialty) } 21 | 22 | specify { specialty.to_s.should eq specialty.name } 23 | end 24 | end 25 | -------------------------------------------------------------------------------- /core/spec/models/student_guardian_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper_models' 2 | 3 | describe Gaku::StudentGuardian, type: :model do 4 | describe 'associations' do 5 | it { is_expected.to belong_to :student } 6 | it { is_expected.to belong_to :guardian } 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /core/spec/models/student_review_category_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper_models' 2 | 3 | describe Gaku::Program, type: :model do 4 | describe 'associations' do 5 | end 6 | 7 | describe 'validations' do 8 | it { is_expected.to validate_presence_of :name } 9 | it { is_expected.to validate_uniqueness_of :name } 10 | end 11 | 12 | describe '#to_s' do 13 | let(:student_review_category) { build(:student_review_category) } 14 | 15 | specify { student_review_category.to_s.should eq student_review_category.name } 16 | end 17 | end 18 | -------------------------------------------------------------------------------- /core/spec/models/student_speciality_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper_models' 2 | 3 | describe Gaku::StudentSpecialty, type: :model do 4 | describe 'associations' do 5 | it { is_expected.to belong_to :specialty } 6 | it { is_expected.to belong_to :student } 7 | end 8 | 9 | describe 'validations' do 10 | it { is_expected.to validate_presence_of :student_id } 11 | it { is_expected.to validate_presence_of :specialty_id } 12 | it { is_expected.to validate_uniqueness_of(:student_id).scoped_to(:specialty_id).with_message(/Specialty already added!/) } 13 | end 14 | end 15 | -------------------------------------------------------------------------------- /core/spec/models/template_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper_models' 2 | 3 | describe Gaku::Template, type: :model do 4 | describe 'validations' do 5 | it { is_expected.to validate_presence_of :name } 6 | it { is_expected.to validate_presence_of :context } 7 | it { is_expected.to validate_presence_of :file } 8 | it { is_expected.to have_attached_file :file } 9 | it do 10 | expect(subject).to validate_attachment_content_type(:file) 11 | .allowing('text/plain', 12 | 'application/vnd.ms-excel', 13 | 'application/vnd.oasis.opendocument.spreadsheet', 14 | 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet') 15 | end 16 | end 17 | end 18 | -------------------------------------------------------------------------------- /core/spec/models/user_role_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper_models' 2 | 3 | describe Gaku::UserRole, type: :model do 4 | describe 'associations' do 5 | it { is_expected.to belong_to :user } 6 | it { is_expected.to belong_to :role } 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /core/spec/spec_helper_base.rb: -------------------------------------------------------------------------------- 1 | ENV['RAILS_ENV'] ||= 'test' 2 | require File.expand_path('dummy/config/environment', __dir__) 3 | 4 | require 'gaku/testing/deferred_garbage_collection' 5 | require 'gaku/testing/coverage' 6 | 7 | Rails.logger.level = 3 8 | 9 | RSpec.configure do |config| 10 | config.mock_with :rspec 11 | config.order = 'random' 12 | 13 | config.before do 14 | $redis.flushdb 15 | end 16 | 17 | config.before(:all) do 18 | DeferredGarbageCollection.start 19 | end 20 | 21 | config.after(:all) do 22 | DeferredGarbageCollection.reconsider 23 | end 24 | end 25 | -------------------------------------------------------------------------------- /core/spec/support/120x120.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GAKUEngine/gaku/5e2f1580520c09b4f871893075a0c9b5e9f50037/core/spec/support/120x120.jpg -------------------------------------------------------------------------------- /core/spec/support/models/shared_examples/addressable.rb: -------------------------------------------------------------------------------- 1 | shared_examples_for 'addressable' do 2 | it { is_expected.to have_many :addresses } 3 | end 4 | -------------------------------------------------------------------------------- /core/spec/support/models/shared_examples/avatarable.rb: -------------------------------------------------------------------------------- 1 | shared_examples_for 'avatarable' do 2 | it { is_expected.to have_attached_file :picture } 3 | end 4 | -------------------------------------------------------------------------------- /core/spec/support/models/shared_examples/contactable.rb: -------------------------------------------------------------------------------- 1 | shared_examples_for 'contactable' do 2 | it { is_expected.to have_many :contacts } 3 | end 4 | -------------------------------------------------------------------------------- /core/spec/support/models/shared_examples/enrollmentable.rb: -------------------------------------------------------------------------------- 1 | shared_examples_for 'enrollable' do 2 | it { is_expected.to have_many(:enrollments).dependent(:destroy) } 3 | it { is_expected.to have_many(:students).through(:enrollments) } 4 | end 5 | -------------------------------------------------------------------------------- /core/spec/support/models/shared_examples/gradable.rb: -------------------------------------------------------------------------------- 1 | shared_examples_for 'gradable' do 2 | it { is_expected.to have_many :grading_method_connectors } 3 | it { is_expected.to have_many(:grading_methods).through(:grading_method_connectors) } 4 | end 5 | -------------------------------------------------------------------------------- /core/spec/support/models/shared_examples/notable.rb: -------------------------------------------------------------------------------- 1 | shared_examples_for 'notable' do 2 | it { is_expected.to have_many :notes } 3 | end 4 | -------------------------------------------------------------------------------- /core/spec/support/models/shared_examples/person.rb: -------------------------------------------------------------------------------- 1 | shared_examples_for 'person' do 2 | it { is_expected.to validate_presence_of :name } 3 | it { is_expected.to validate_presence_of :surname } 4 | end 5 | -------------------------------------------------------------------------------- /core/spec/support/models/shared_examples/semesterable.rb: -------------------------------------------------------------------------------- 1 | shared_examples_for 'semesterable' do 2 | it { is_expected.to have_many :semester_connectors } 3 | it { is_expected.to have_many(:semesters).through(:semester_connectors) } 4 | end 5 | -------------------------------------------------------------------------------- /core/spec/support/models/shared_examples/student_reviewable.rb: -------------------------------------------------------------------------------- 1 | shared_examples_for 'student_reviewable' do 2 | it { is_expected.to have_many :student_reviews } 3 | end 4 | -------------------------------------------------------------------------------- /core/spec/support/sample_roster.ods: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GAKUEngine/gaku/5e2f1580520c09b4f871893075a0c9b5e9f50037/core/spec/support/sample_roster.ods -------------------------------------------------------------------------------- /docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '3.0' 2 | services: 3 | web: 4 | environment: 5 | - RAILS_ENV=development 6 | - REDIS_HOST=redis 7 | build: . 8 | command: "bin/check_postgres.sh bundle exec rails server -b 0.0.0.0 -p 9000" 9 | ports: 10 | - "9000:9000" 11 | volumes: 12 | - .:/gaku 13 | - uploads:/app/uploads 14 | depends_on: 15 | - postgres 16 | - redis 17 | postgres: 18 | image: postgres:11 19 | ports: 20 | - "9001:5432" 21 | volumes: 22 | - postgres-data:/var/lib/postgresql/data 23 | 24 | redis: 25 | image: redis:5 26 | ports: 27 | - "9002:6379" 28 | 29 | volumes: 30 | postgres-data: 31 | driver: local 32 | uploads: 33 | driver: local 34 | -------------------------------------------------------------------------------- /lib/gaku.rb: -------------------------------------------------------------------------------- 1 | require 'gaku_core' 2 | require 'gaku_api' 3 | # require 'gaku_admin' 4 | require 'gaku_sample' 5 | require 'gaku_api' 6 | -------------------------------------------------------------------------------- /lib/gaku/command/installer.rb: -------------------------------------------------------------------------------- 1 | module Gaku 2 | module Command 3 | class Installer 4 | def install(path ='./') 5 | end 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /sample/Rakefile: -------------------------------------------------------------------------------- 1 | require 'rake' 2 | require 'rake/testtask' 3 | require 'rake/packagetask' 4 | require 'rubygems/package_task' 5 | -------------------------------------------------------------------------------- /sample/db/sample/gaku/02_courses.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | 3 | courses = [ 4 | { syllabus: Gaku::Syllabus.where(code: 'B01').first, code: 'Spring 2013' }, 5 | { syllabus: Gaku::Syllabus.where(code: 'MT').first, code: '2013年(秋)' }, 6 | { syllabus: Gaku::Syllabus.where(code: 'RB1').first, code: 'Prof. Why' } 7 | ] 8 | 9 | say "Creating #{courses.size} courses ...".yellow 10 | courses.each do |course| 11 | Gaku::Course.where(code: course[:code], syllabus_id: course[:syllabus]).first_or_create! 12 | end 13 | -------------------------------------------------------------------------------- /sample/db/sample/gaku/20-grading_methods.rb: -------------------------------------------------------------------------------- 1 | grading_methods = [ 2 | { 3 | name: 'Score', 4 | grading_type: 'score', 5 | description: 'Straight Score', 6 | curved: false 7 | }, 8 | { 9 | name: 'Curved Score', 10 | grading_type: 'score', 11 | description: 'Curved Score', 12 | curved: true 13 | }, 14 | { 15 | name: 'Percentage', 16 | grading_type: 'percentage', 17 | description: 'Straight Percentage', 18 | curved: false 19 | }, 20 | { 21 | name: 'Curved Percentage', 22 | grading_type: 'percentage', 23 | description: 'Curved Percentage', 24 | curved: true 25 | } 26 | ] 27 | 28 | say "Creating #{grading_methods.size} grading methods ...".yellow 29 | 30 | grading_methods.each do |grading_method| 31 | Gaku::GradingMethod.where(grading_method).first_or_create! 32 | end 33 | -------------------------------------------------------------------------------- /sample/db/sample/gaku/badge_types.rb: -------------------------------------------------------------------------------- 1 | els = %w( JuniorRuby SeniorRuby RubyGuru 2 | JuniorJavascript SeniorJavascript JavascriptGuru 3 | JuniorClojure SeniorClojure ClojureGuru 4 | JuniorScala SeniorScala ScalaGuru ) 5 | 6 | say "Creating #{els.size} badges ...".yellow 7 | 8 | els.each { |el| Gaku::BadgeType.where(name: el).first_or_create! } 9 | -------------------------------------------------------------------------------- /sample/db/sample/gaku/course_groups.rb: -------------------------------------------------------------------------------- 1 | els = %w( Ruby Node.js Clojure ) 2 | 3 | say "Creating #{els.size} course groups ...".yellow 4 | 5 | els.each do |el| 6 | Gaku::CourseGroup.where(name: el).first_or_create! 7 | end 8 | -------------------------------------------------------------------------------- /sample/db/sample/gaku/disposals/course_group_disposals.rb: -------------------------------------------------------------------------------- 1 | # # encoding: utf-8 2 | # require 'shared_sample_data' 3 | 4 | # say "Creating #{@count[:disposals]} course groups ...".yellow 5 | 6 | # batch_create(@count[:disposals]) do 7 | # Gaku::CourseGroup.where(name: "#{Faker::Education.major} CourseGroup", deleted: true).first_or_create! 8 | # end 9 | -------------------------------------------------------------------------------- /sample/db/sample/gaku/disposals/exam_disposals.rb: -------------------------------------------------------------------------------- 1 | # # encoding: utf-8 2 | # require 'shared_sample_data' 3 | 4 | # say "Creating #{@count[:disposals]} exams ...".yellow 5 | 6 | # batch_create(@count[:disposals]) do 7 | # Gaku::Exam.where(name: FFaker::Education.major, deleted: true).first_or_create! 8 | # end 9 | -------------------------------------------------------------------------------- /sample/db/sample/gaku/disposals/student_disposals.rb: -------------------------------------------------------------------------------- 1 | # # encoding: utf-8 2 | # require 'shared_sample_data' 3 | 4 | # say "Creating #{@count[:disposals]} students and guardians ...".yellow 5 | 6 | # batch_create(@count[:disposals]) do 7 | # student = Gaku::Student.where(random_person.merge(deleted: true)).first_or_create! 8 | # guardian = Gaku::Guardian.where(random_person.merge(deleted: true)).first_or_create! 9 | # student.guardians << guardian 10 | # end 11 | -------------------------------------------------------------------------------- /sample/db/sample/gaku/disposals/teacher_disposals.rb: -------------------------------------------------------------------------------- 1 | # # encoding: utf-8 2 | # require 'shared_sample_data' 3 | 4 | # say "Creating #{@count[:disposals]} teachers ...".yellow 5 | 6 | # batch_create(@count[:disposals]) do 7 | # Gaku::Teacher.where(random_person.merge(deleted: true)).first_or_create! 8 | # end 9 | -------------------------------------------------------------------------------- /sample/db/sample/gaku/exams.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | 3 | names = [ 4 | 'Summer Program Entry', 5 | 'Regular Program Entry', 6 | 'International Program Exams', 7 | 'National Information Engineer Certification' 8 | ] 9 | 10 | say "Creating #{names.size} exams ...".yellow 11 | names.each { |name| Gaku::Exam.where(name: name).first_or_create! } 12 | -------------------------------------------------------------------------------- /sample/db/sample/gaku/extracurricular_activities.rb: -------------------------------------------------------------------------------- 1 | els = %w( Tennis Football Basketball Handball Climbing Running Swimming Rugby PingPong Chess Fitness ) 2 | 3 | say "Creating #{els.size} extracurricular activities ...".yellow 4 | els.each { |el| Gaku::ExtracurricularActivity.where(name: el).first_or_create! } 5 | -------------------------------------------------------------------------------- /sample/db/sample/gaku/images/120x120.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GAKUEngine/gaku/5e2f1580520c09b4f871893075a0c9b5e9f50037/sample/db/sample/gaku/images/120x120.jpg -------------------------------------------------------------------------------- /sample/db/sample/gaku/roles.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | 3 | roles = %w( Admin ProgramManager Instructor Counselor Staff Principal VicePrincipal Student Guardian ) 4 | 5 | say "Creating #{roles.size} roles ...".yellow 6 | roles.each { |role| Gaku::Role.where(name: role.downcase).first_or_create! } 7 | -------------------------------------------------------------------------------- /sample/db/sample/gaku/specialties.rb: -------------------------------------------------------------------------------- 1 | els = %w( RubyDeveloper JavascriptDeveloper ClojureDeveloper ScalaDeveloper PythonDeveloper GoDeveloper ) 2 | 3 | say "Creating #{els.size} specialties ...".yellow 4 | els.each { |el| Gaku::Specialty.where(name: el).first_or_create! } 5 | -------------------------------------------------------------------------------- /sample/db/sample/gaku/teachers.rb: -------------------------------------------------------------------------------- 1 | require 'rake-progressbar' 2 | require 'shared_sample_data' 3 | 4 | teachers = [ 5 | { name: 'Vassil', surname: 'Kalkov' }, 6 | { name: 'Marta', surname: 'Kostova' }, 7 | { name: 'Georgi', surname: 'Tapalilov' }, 8 | { name: 'Radoslav', surname: 'Georgiev' }, 9 | { name: 'Rei', surname: 'Kagetsuki' } 10 | ] 11 | 12 | say 'Creating predefined teachers...'.yellow 13 | teachers.each { |teacher| create_teacher_with_full_info(teacher) } 14 | 15 | say "Creating #{@count[:teachers]} teachers...".yellow 16 | batch_create(@count[:teachers]) { create_teacher_with_full_info } 17 | -------------------------------------------------------------------------------- /sample/gaku_sample.gemspec: -------------------------------------------------------------------------------- 1 | # encoding: UTF-8 2 | 3 | require_relative '../common_gaku_gemspec_mixin' 4 | 5 | Gem::Specification.new do |s| 6 | set_gaku_gemspec_shared s 7 | 8 | s.name = 'gaku_sample' 9 | s.summary = 'Sample data for use with GAKU Engine' 10 | s.description = 'Just some sample data' 11 | 12 | 13 | s.files = Dir['LICENSE', 'README.md', 'lib/**/*', 'db/**/*'] 14 | s.require_path = 'lib' 15 | 16 | s.requirements << 'postgresql' 17 | s.requirements << 'postgresql-contrib' 18 | 19 | s.add_dependency 'gaku_core', s.version 20 | end 21 | -------------------------------------------------------------------------------- /sample/lib/gaku_sample.rb: -------------------------------------------------------------------------------- 1 | require 'gaku_core' 2 | require 'ffaker' 3 | require 'rake-progressbar' 4 | require 'highline' 5 | 6 | module GakuSample 7 | class Engine < Rails::Engine 8 | engine_name 'gaku_sample' 9 | end 10 | end 11 | -------------------------------------------------------------------------------- /sample/lib/sample_counters.rb: -------------------------------------------------------------------------------- 1 | @full_sample_counts = { 2 | disposals: 100, 3 | changes: 100, 4 | students: 500, 5 | teachers: 80, 6 | users: 100 7 | } 8 | 9 | @normal_sample_counts = { 10 | disposals: 30, 11 | changes: 30, 12 | students: 50, 13 | teachers: 50, 14 | users: 50 15 | } 16 | 17 | @simple_sample_counts = { 18 | disposals: 10, 19 | changes: 10, 20 | students: 10, 21 | teachers: 10, 22 | users: 10 23 | } 24 | -------------------------------------------------------------------------------- /support/docker.md: -------------------------------------------------------------------------------- 1 | # First Run 2 | - Run `docker-compose up`. All ubuntu and gem packages will be installed and app with services will be up 3 | 4 | # Add new migration 5 | - add new migration to gaku gem 6 | - run `docker-compose exec web bundle exec rake railties:install:migrations` to copy migrations in app db/migrations 7 | - run `docker-compose exec web bundle exec rake db:migrate` to install migrations 8 | 9 | # Add new gem 10 | - add gem in gemspec files and then stop and run docker-compose 11 | 12 | # Add sample data 13 | - run `docker-compose exec web bundle exec rake db:sample` 14 | 15 | # NOTE!!! 16 | - do not run `docker-compose up --build` because will install initialize app, will download all gems and will copy migrations again and will not start becase of duplicated tables 17 | -------------------------------------------------------------------------------- /test.yml: -------------------------------------------------------------------------------- 1 | gem 'gaku', git: 'https://github.com/GAKUEngine/gaku.git', branch: 'docker' 2 | gem 'gaku', git: 'https://github.com/GAKUEngine/gaku.git', branch: 'docker' 3 | -------------------------------------------------------------------------------- /testing/Rakefile: -------------------------------------------------------------------------------- 1 | require 'rake' 2 | require 'rake/testtask' 3 | require 'rake/packagetask' 4 | require 'rubygems/package_task' 5 | 6 | desc 'Release to gemcutter' 7 | task :release do 8 | version = File.read(File.expand_path('../../VERSION', __FILE__)).strip 9 | cmd = "cd pkg && gem push gaku_testing-#{version}.gem" 10 | puts cmd 11 | system cmd 12 | end 13 | -------------------------------------------------------------------------------- /testing/docker/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '3' 2 | services: 3 | db: 4 | image: postgres:10 5 | ports: 6 | - "5434:5432" 7 | environment: 8 | POSTGRES_USER: manabu 9 | POSTGRES_PASSWORD: manabu 10 | POSTGRES_DB: gaku_test 11 | -------------------------------------------------------------------------------- /testing/gaku_testing.gemspec: -------------------------------------------------------------------------------- 1 | require_relative '../common_gaku_gemspec_mixin' 2 | 3 | Gem::Specification.new do |s| 4 | set_gaku_gemspec_shared s 5 | 6 | s.name = 'gaku_testing' 7 | s.summary = 'Shared testing helpers for GAKU Engine' 8 | s.description = 'Testing helpers used in other engines/modules for GAKU Engine.' 9 | 10 | s.files = Dir['lib/**/*'] 11 | s.test_files = `git ls-files -- {spec}/*`.split("\n") 12 | s.require_path = 'lib' 13 | 14 | s.add_dependency 'gaku_core', s.version 15 | end 16 | -------------------------------------------------------------------------------- /testing/lib/gaku/testing.rb: -------------------------------------------------------------------------------- 1 | require 'gaku/core' 2 | 3 | module Gaku 4 | 5 | module Testing 6 | end 7 | 8 | end 9 | 10 | require 'gaku/testing/engine' 11 | -------------------------------------------------------------------------------- /testing/lib/gaku/testing/engine.rb: -------------------------------------------------------------------------------- 1 | module Gaku 2 | module Testing 3 | class Engine < ::Rails::Engine 4 | engine_name 'gaku_testing' 5 | 6 | config.autoload_paths += %W(#{config.root}/lib) 7 | 8 | end 9 | end 10 | end 11 | -------------------------------------------------------------------------------- /testing/lib/gaku/testing/env.rb: -------------------------------------------------------------------------------- 1 | require 'capybara' 2 | require 'capybara/dsl' 3 | require 'capybara/poltergeist' 4 | 5 | Capybara.default_selector = :css 6 | Capybara.default_driver = :rack_test 7 | 8 | Capybara.register_driver :poltergeist_debug do |app| 9 | Capybara::Poltergeist::Driver.new(app, inspector: true, js_errors: false) 10 | end 11 | 12 | if ENV['SELENIUM'] 13 | Capybara.javascript_driver = :selenium 14 | elsif ENV['PHANTOM'] 15 | Capybara.javascript_driver = :poltergeist_debug 16 | else 17 | Capybara.javascript_driver = :poltergeist_debug 18 | end 19 | -------------------------------------------------------------------------------- /testing/lib/gaku/testing/flash_helpers.rb: -------------------------------------------------------------------------------- 1 | module Gaku::Testing::FlashHelpers 2 | 3 | def flash?(text) 4 | page.should have_selector('#notice', text: text) 5 | end 6 | 7 | def flash_created? 8 | flash? 'successfully created' 9 | end 10 | 11 | def flash_updated? 12 | flash? 'successfully updated' 13 | end 14 | 15 | def flash_destroyed? 16 | flash? 'successfully destroyed' 17 | end 18 | 19 | def flash_recovered? 20 | flash? 'successfully recovered' 21 | end 22 | 23 | def flash_uploaded? 24 | flash? 'successfully uploaded' 25 | end 26 | 27 | def flash_error_for(field) 28 | page.should have_selector("div.#{field}formError") 29 | end 30 | 31 | end 32 | 33 | RSpec.configure do |config| 34 | config.include Gaku::Testing::FlashHelpers, type: :feature 35 | end 36 | -------------------------------------------------------------------------------- /testing/lib/gaku/testing/spec_helpers/spec_helper_base.rb: -------------------------------------------------------------------------------- 1 | require 'gaku/testing/deferred_garbage_collection' 2 | require 'gaku/testing/coverage' 3 | 4 | Rails.logger.level = 3 5 | 6 | RSpec.configure do |config| 7 | config.mock_with :rspec 8 | config.order = 'random' 9 | 10 | config.before(:each) do 11 | $redis.flushdb 12 | end 13 | 14 | config.before(:all) do 15 | DeferredGarbageCollection.start 16 | end 17 | 18 | config.after(:all) do 19 | DeferredGarbageCollection.reconsider 20 | end 21 | end 22 | -------------------------------------------------------------------------------- /testing/lib/gaku/testing/spec_helpers/spec_helper_routing.rb: -------------------------------------------------------------------------------- 1 | require_relative 'spec_helper_base' 2 | 3 | require 'rspec/core' 4 | require 'rspec/rails/matchers' 5 | require 'rspec/rails/fixture_support' 6 | 7 | require 'rspec/rails/view_rendering' 8 | require 'rspec/rails/adapters' 9 | require 'rspec/rails/example' 10 | -------------------------------------------------------------------------------- /testing/lib/gaku_testing.rb: -------------------------------------------------------------------------------- 1 | require 'gaku/testing' 2 | --------------------------------------------------------------------------------