sis_core 1.0.15 → 1.0.16

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a693cc89dd56d1a0b03c6a33e3e4254a0c31ba9fed62d736fcd5abd08ade3abe
4
- data.tar.gz: ef4448b178025f62b5c0538f1fd19d504c082a8bd11d382e11f2320122745728
3
+ metadata.gz: 765cf9bd0e11c73f120a46ef27e7c452f96881e0c360c54ecb697af5a129abb2
4
+ data.tar.gz: 0fc3147cba5580ede372afac7041a727aff0dc09431cd3af9856623ed652b28d
5
5
  SHA512:
6
- metadata.gz: eca6082acb41b9058dec21c40f7b9d2819bf70a15f434e6428c45af7d62f657c65dbc37daaad388147fed8101d237d4226c7ee90a96342a3c992691f2957b37c
7
- data.tar.gz: 6599a39511fdf9b93732bd61c7c0cc535b15d4eaa089190812e79e8385c4371566d58e3fd327195c5530b76d5ff439d6ea9fb640b73b475a1ab34b6a2a3c4b86
6
+ metadata.gz: f626f605104d910d210424efb3ab331dd567517577b786999ab3035317059d421ba0a694e0a00a00bc945d228663e908a44c51678eef3c5160de1bcbdf2eea69
7
+ data.tar.gz: 6ffe0155717f44b3c4fb5819e3fa206503cc9a32e6afe273f395667f53de7fd8cb2894c230cbcd07a308cab5382940a8dae0032ec6ba602e57a97c827ce3f025
@@ -0,0 +1,19 @@
1
+ module Sis
2
+ module Core
3
+ class UtilsController < ApplicationController
4
+ skip_before_action :authenticate_request, only: %i[filter]
5
+ before_action :set_util_service, only: %i[filter]
6
+
7
+ def filter
8
+ result = ApplicationRecord.serialize(@service.filter_record(params))
9
+ render json: { success: true, data: result }
10
+ end
11
+
12
+ private
13
+
14
+ def set_util_service
15
+ @service = UtilService.new
16
+ end
17
+ end
18
+ end
19
+ end
@@ -2,6 +2,10 @@ module Sis
2
2
  module Core
3
3
  class ApplicationRecord < ActiveRecord::Base
4
4
  self.abstract_class = true
5
+
6
+ def self.serialize(data)
7
+ ActiveModelSerializers::SerializableResource.new(data)
8
+ end
5
9
  end
6
10
  end
7
11
  end
@@ -1,10 +1,8 @@
1
1
  module Sis
2
2
  module Core
3
3
  class Course < ApplicationRecord
4
- belongs_to :program
5
-
6
- validates :code, :title, :description, :credit_hours, :ects, :lecture_hours, :lab_hours, presence: true
7
- validates :code, uniqueness: true
4
+ validates :code, :title, :credit_hours, :ects, :lecture_hours, presence: true
5
+ validates :code, uniqueness: { case_sensitive: false }
8
6
  end
9
7
  end
10
8
  end
@@ -0,0 +1,19 @@
1
+ module Sis
2
+ module Core
3
+ class CourseOffering < ApplicationRecord
4
+ belongs_to :course_offering_sequence
5
+ belongs_to :academic_year
6
+ belongs_to :semester
7
+ belongs_to :level
8
+
9
+ delegate(:course_code, to: :course_offering_sequence, prefix: false)
10
+ delegate(:course_title, to: :course_offering_sequence, prefix: false)
11
+ delegate(:course_ects, to: :course_offering_sequence, prefix: false)
12
+ delegate(:course_credit_hours, to: :course_offering_sequence, prefix: false)
13
+ delegate(:course_id, to: :course_offering_sequence, prefix: false)
14
+ delegate(:course_lecture_hours, to: :course_offering_sequence, prefix: false)
15
+ delegate(:course_lab_hours, to: :course_offering_sequence, prefix: false)
16
+ delegate(:course_tutorial_hours, to: :course_offering_sequence, prefix: false)
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,42 @@
1
+ module Sis
2
+ module Core
3
+ class CourseOfferingSequence < ApplicationRecord
4
+ belongs_to :curriculum_course
5
+ belongs_to :programme_type
6
+ belongs_to :level
7
+ belongs_to :semester
8
+
9
+ def course_id
10
+ curriculum_course.course.id.to_s
11
+ end
12
+
13
+ def course_code
14
+ curriculum_course.course.code.to_s
15
+ end
16
+
17
+ def course_title
18
+ curriculum_course.course.title.to_s
19
+ end
20
+
21
+ def course_ects
22
+ curriculum_course.course.ects.to_s
23
+ end
24
+
25
+ def course_credit_hours
26
+ curriculum_course.course.credit_hours.to_s
27
+ end
28
+
29
+ def course_lecture_hours
30
+ curriculum_course.course.lecture_hours.to_s
31
+ end
32
+
33
+ def course_lab_hours
34
+ curriculum_course.course.lab_hours.to_s
35
+ end
36
+
37
+ def course_tutorial_hours
38
+ curriculum_course.course.tutorial_hours.to_s
39
+ end
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,17 @@
1
+ module Sis
2
+ module Core
3
+ class Curriculum < ApplicationRecord
4
+ belongs_to :programme
5
+ belongs_to :programme_level
6
+
7
+ validates :compulsory_course_credit_hours, :elective_course_credit_hours, :thesis_hour, :project_hour,
8
+ presence: true
9
+ delegate(:name, to: :programme, prefix: true)
10
+ delegate(:name, to: :programme_level, prefix: true)
11
+
12
+ def name
13
+ "#{programme.name} #{programme_level.name}"
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,19 @@
1
+ module Sis
2
+ module Core
3
+ class CurriculumCourse < ApplicationRecord
4
+ belongs_to :curriculum
5
+ belongs_to :course
6
+ validates :course_type, presence: true
7
+ has_many :predecessor_prerequisites, foreign_key: :successor_id, class_name: 'Prerequisite'
8
+ has_many :predecessors, through: :predecessor_prerequisites, source: :predecessor
9
+ has_many :successor_prerequisites, foreign_key: :predecessor_id, class_name: 'Prerequisite'
10
+ has_many :successors, through: :successor_prerequisites, source: :successor
11
+
12
+ delegate(:title, to: :course, prefix: true)
13
+ delegate(:code, to: :course, prefix: true)
14
+ delegate(:ects, to: :course, prefix: true)
15
+ delegate(:credit_hours, to: :course, prefix: true)
16
+ delegate(:name, to: :curriculum, prefix: true)
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,7 @@
1
+ module Sis
2
+ module Core
3
+ class Level < Lookup
4
+ validates :code, :name, presence: true
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,16 @@
1
+ module Sis
2
+ module Core
3
+ class Prerequisite < ApplicationRecord
4
+ belongs_to :predecessor, foreign_key: 'predecessor_id', class_name: 'CurriculumCourse'
5
+ belongs_to :successor, foreign_key: 'successor_id', class_name: 'CurriculumCourse'
6
+
7
+ def predecessor_name
8
+ predecessor.course.title.to_s
9
+ end
10
+
11
+ def successor_name
12
+ successor.course.name.to_s
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,16 @@
1
+ module Sis
2
+ module Core
3
+ class UtilService
4
+ def filter_record(params)
5
+ pos = {}
6
+ neg = {}
7
+
8
+ filter = params[:filter] || []
9
+ filter.each do |f|
10
+ f[:cond] == 'P' ? pos[f[:key]] = f[:value] : neg[f[:key]] = f[:value]
11
+ end
12
+ params[:entity].constantize.where(pos).where.not(neg)
13
+ end
14
+ end
15
+ end
16
+ end
data/config/routes.rb CHANGED
@@ -5,4 +5,6 @@ Sis::Core::Engine.routes.draw do
5
5
  post '/sign_in', controller: :users, action: :sign_in
6
6
  post '/generate_recovery_token', controller: :users, action: :generate_recovery_token
7
7
  post '/reset_password', controller: :users, action: :reset_password
8
+ resources :user_roles, only: %i[index]
9
+ post '/utils/filter', controller: :utils, action: :filter
8
10
  end
@@ -0,0 +1,20 @@
1
+ class CreateSisCoreCurriculums < ActiveRecord::Migration[6.0]
2
+ def change
3
+ create_table :sis_core_curriculums do |t|
4
+ t.references :programme,
5
+ null: false,
6
+ index: { name: 'pr_on_curriculum_indx' },
7
+ foreign_key: { to_table: :sis_core_programmes }
8
+ t.references :programme_level,
9
+ null: false,
10
+ index: { name: 'pr_level_on_curriculum_indx' },
11
+ foreign_key: { to_table: :sis_core_lookups }
12
+ t.float :compulsory_course_credit_hours, null: false
13
+ t.float :elective_course_credit_hours, null: false
14
+ t.float :thesis_hour, null: false
15
+ t.float :project_hour, null: false
16
+
17
+ t.timestamps
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,10 @@
1
+ class RemoveProgrammeAndAddMaximumClassSizeToCourse < ActiveRecord::Migration[6.0]
2
+ def change
3
+ remove_column :sis_core_courses, :academic_programme_id
4
+ add_column :sis_core_courses, :maximum_class_size, :integer
5
+ add_column :sis_core_courses, :has_lab, :boolean, default: false
6
+ add_column :sis_core_courses, :has_tutorial, :boolean, default: false
7
+ add_column :sis_core_courses, :tutorial_hours, :float
8
+ change_column :sis_core_courses, :description, :string, null: true
9
+ end
10
+ end
@@ -0,0 +1,17 @@
1
+ class CreateSisCoreCurriculumCourses < ActiveRecord::Migration[6.0]
2
+ def change
3
+ create_table :sis_core_curriculum_courses do |t|
4
+ t.references :curriculum,
5
+ null: false,
6
+ index: { name: 'cc_on_cc_course_indx' },
7
+ foreign_key: { to_table: :sis_core_curriculums }
8
+ t.references :course,
9
+ null: false,
10
+ index: { name: 'course_on_cc_course_indx' },
11
+ foreign_key: { to_table: :sis_core_courses }
12
+ t.string :course_type
13
+
14
+ t.timestamps
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,24 @@
1
+ class CreateSisCoreCourseOfferingSequences < ActiveRecord::Migration[6.0]
2
+ def change
3
+ create_table :sis_core_course_offering_sequences do |t|
4
+ t.references :curriculum_course,
5
+ null: false,
6
+ index: { name: 'cc_on_course_off_seq' },
7
+ foreign_key: { to_table: :sis_core_curriculum_courses }
8
+ t.references :programme_type,
9
+ null: false,
10
+ index: { name: 'pt_on_course_off_seq' },
11
+ foreign_key: { to_table: :sis_core_lookups }
12
+ t.references :level,
13
+ null: false,
14
+ index: { name: 'level_on_course_off_seq' },
15
+ foreign_key: { to_table: :sis_core_lookups }
16
+ t.references :semester,
17
+ null: false,
18
+ index: { name: 'sem_on_course_off_seq' },
19
+ foreign_key: { to_table: :sis_core_semesters }
20
+
21
+ t.timestamps
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,24 @@
1
+ class CreateSisCoreCourseOfferings < ActiveRecord::Migration[6.0]
2
+ def change
3
+ create_table :sis_core_course_offerings do |t|
4
+ t.references :course_offering_sequence,
5
+ null: false,
6
+ index: { name: 'crs_off_seq_on_crs_off' },
7
+ foreign_key: { to_table: :sis_core_course_offering_sequences }
8
+ t.references :academic_year,
9
+ null: false,
10
+ index: { name: 'ay_on_crs_off' },
11
+ foreign_key: { to_table: :sis_core_academic_years }
12
+ t.references :semester,
13
+ null: false,
14
+ index: { name: 'sem_on_crs_off' },
15
+ foreign_key: { to_table: :sis_core_semesters }
16
+ t.references :level,
17
+ null: false,
18
+ index: { name: 'level_on_crs_off' },
19
+ foreign_key: { to_table: :sis_core_lookups }
20
+
21
+ t.timestamps
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,15 @@
1
+ class CreateSisCorePrerequisites < ActiveRecord::Migration[6.0]
2
+ def change
3
+ create_table :sis_core_prerequisites do |t|
4
+ t.references :predecessor,
5
+ null: false,
6
+ index: { name: 'pred_on_prerequisite' },
7
+ foreign_key: { to_table: :sis_core_curriculum_courses }
8
+ t.references :successor,
9
+ null: false,
10
+ index: { name: 'succ_on_prerequisite' },
11
+ foreign_key: { to_table: :sis_core_curriculum_courses }
12
+ t.timestamps
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,6 @@
1
+ class AddMinimumClassSizeToCourse < ActiveRecord::Migration[6.0]
2
+ def change
3
+ add_column :sis_core_courses, :minimum_class_size, :integer
4
+ change_column :sis_core_courses, :lab_hours, :float, null: true
5
+ end
6
+ end
@@ -1,5 +1,5 @@
1
1
  module Sis
2
2
  module Core
3
- VERSION = '1.0.15'.freeze
3
+ VERSION = '1.0.16'.freeze
4
4
  end
5
5
  end
@@ -0,0 +1,8 @@
1
+ FactoryBot.define do
2
+ factory :course_offering_sequence, class: Sis::Core::CourseOfferingSequence do
3
+ association :curriculum_course
4
+ association :programme_type
5
+ association :level
6
+ association :semester
7
+ end
8
+ end
@@ -0,0 +1,8 @@
1
+ FactoryBot.define do
2
+ factory :course_offering, class: Sis::Core::CourseOffering do
3
+ association :course_offering_sequence
4
+ association :academic_year
5
+ association :semester
6
+ association :level
7
+ end
8
+ end
@@ -7,6 +7,8 @@ FactoryBot.define do
7
7
  ects { FFaker::Random.rand(1..10) }
8
8
  lecture_hours { FFaker::Random.rand(1..4) }
9
9
  lab_hours { FFaker::Random.rand(1..4) }
10
- association :program
10
+ has_lab { true }
11
+ has_tutorial { false }
12
+ maximum_class_size { 40 }
11
13
  end
12
14
  end
@@ -0,0 +1,7 @@
1
+ FactoryBot.define do
2
+ factory :curriculum_course, class: Sis::Core::CurriculumCourse do
3
+ association :curriculum
4
+ association :course
5
+ course_type { 'Compulsory' }
6
+ end
7
+ end
@@ -0,0 +1,5 @@
1
+ FactoryBot.define do
2
+ factory :level, class: Sis::Core::Level, parent: :lookup do
3
+ type { 'Sis::Core::Level' }
4
+ end
5
+ end
@@ -0,0 +1,6 @@
1
+ FactoryBot.define do
2
+ factory :prerequisite, class: Sis::Core::Prerequisite do
3
+ association :predecessor, factory: :curriculum_course
4
+ association :successor, factory: :curriculum_course
5
+ end
6
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sis_core
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.15
4
+ version: 1.0.16
5
5
  platform: ruby
6
6
  authors:
7
7
  - Henock L.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-11-15 00:00:00.000000000 Z
11
+ date: 2021-03-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aasm
@@ -226,6 +226,7 @@ files:
226
226
  - app/controllers/sis/core/application_controller.rb
227
227
  - app/controllers/sis/core/menus_controller.rb
228
228
  - app/controllers/sis/core/users_controller.rb
229
+ - app/controllers/sis/core/utils_controller.rb
229
230
  - app/models/sis/core/academic_programme.rb
230
231
  - app/models/sis/core/academic_programme_document.rb
231
232
  - app/models/sis/core/academic_year.rb
@@ -236,9 +237,13 @@ files:
236
237
  - app/models/sis/core/application_record.rb
237
238
  - app/models/sis/core/application_setup.rb
238
239
  - app/models/sis/core/course.rb
240
+ - app/models/sis/core/course_offering.rb
241
+ - app/models/sis/core/course_offering_sequence.rb
239
242
  - app/models/sis/core/course_registration.rb
240
243
  - app/models/sis/core/credit_hour_rate.rb
241
244
  - app/models/sis/core/currency.rb
245
+ - app/models/sis/core/curriculum.rb
246
+ - app/models/sis/core/curriculum_course.rb
242
247
  - app/models/sis/core/document_requirement.rb
243
248
  - app/models/sis/core/document_type.rb
244
249
  - app/models/sis/core/exam.rb
@@ -247,8 +252,10 @@ files:
247
252
  - app/models/sis/core/field_of_study.rb
248
253
  - app/models/sis/core/instructor.rb
249
254
  - app/models/sis/core/instructor_course.rb
255
+ - app/models/sis/core/level.rb
250
256
  - app/models/sis/core/lookup.rb
251
257
  - app/models/sis/core/menu.rb
258
+ - app/models/sis/core/prerequisite.rb
252
259
  - app/models/sis/core/programme.rb
253
260
  - app/models/sis/core/programme_level.rb
254
261
  - app/models/sis/core/programme_type.rb
@@ -257,6 +264,7 @@ files:
257
264
  - app/models/sis/core/user.rb
258
265
  - app/models/sis/core/user_role.rb
259
266
  - app/services/sis/core/user_service.rb
267
+ - app/services/sis/core/util_service.rb
260
268
  - app/uploaders/sis/core/application_document_uploader.rb
261
269
  - app/uploaders/sis/core/photo_uploader.rb
262
270
  - config/database.ci.yml
@@ -285,6 +293,13 @@ files:
285
293
  - db/migrate/20200511165450_create_sis_core_menus.rb
286
294
  - db/migrate/20200919235516_create_sis_core_credit_hour_rates.rb
287
295
  - db/migrate/20201019055620_create_sis_core_academic_programme_documents.rb
296
+ - db/migrate/20201102134749_create_sis_core_curriculums.rb
297
+ - db/migrate/20201102182012_remove_programme_and_add_maximum_class_size_to_course.rb
298
+ - db/migrate/20201102192055_create_sis_core_curriculum_courses.rb
299
+ - db/migrate/20201104085458_create_sis_core_course_offering_sequences.rb
300
+ - db/migrate/20201104111548_create_sis_core_course_offerings.rb
301
+ - db/migrate/20201106091250_create_sis_core_prerequisites.rb
302
+ - db/migrate/20210310071526_add_minimum_class_size_to_course.rb
288
303
  - lib/authorize_request.rb
289
304
  - lib/json_web_token.rb
290
305
  - lib/sis/core.rb
@@ -300,10 +315,13 @@ files:
300
315
  - spec/factories/sis/core/application_modules.rb
301
316
  - spec/factories/sis/core/application_setups.rb
302
317
  - spec/factories/sis/core/applications.rb
318
+ - spec/factories/sis/core/course_offering_sequences.rb
319
+ - spec/factories/sis/core/course_offerings.rb
303
320
  - spec/factories/sis/core/course_registrations.rb
304
321
  - spec/factories/sis/core/courses.rb
305
322
  - spec/factories/sis/core/credit_hour_rates.rb
306
323
  - spec/factories/sis/core/currencies.rb
324
+ - spec/factories/sis/core/curriculum_courses.rb
307
325
  - spec/factories/sis/core/curriculums.rb
308
326
  - spec/factories/sis/core/document_requirements.rb
309
327
  - spec/factories/sis/core/document_types.rb
@@ -312,8 +330,10 @@ files:
312
330
  - spec/factories/sis/core/exams.rb
313
331
  - spec/factories/sis/core/instructor_courses.rb
314
332
  - spec/factories/sis/core/instructors.rb
333
+ - spec/factories/sis/core/levels.rb
315
334
  - spec/factories/sis/core/lookups.rb
316
335
  - spec/factories/sis/core/menus.rb
336
+ - spec/factories/sis/core/prerequisites.rb
317
337
  - spec/factories/sis/core/programme_levels.rb
318
338
  - spec/factories/sis/core/programme_types.rb
319
339
  - spec/factories/sis/core/programmes.rb