oneroster 1.3.6 → 2.3.0

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
  SHA1:
3
- metadata.gz: 0306c18daaa1cea3ae7e49f18700a4c230181441
4
- data.tar.gz: 9ac72dfc6ceee7d40da62b119b227a12316ff45c
3
+ metadata.gz: 1295abb50254210617e64c5e1da8e0af8210cdc6
4
+ data.tar.gz: 4f9b52e8420ac4d9013feea4dd6322c5de1a71e2
5
5
  SHA512:
6
- metadata.gz: ca0e3070091f7a024c5b18048b67ede35e211f76b2741f68673e5c7b416b2413ab37587648b2eac555066ca71eebe746fe9a8b8383aff6ef97bddedf8826f494
7
- data.tar.gz: 1635b08056de344c9b2107cc2ed7379d5d6b7661fafaa3ed000f2b1eb8f94568ffc12e12c9fa3358e01bcda7e8bc294aa006725d813f9bd5b10dd64796957482
6
+ metadata.gz: 1ea266064d17e410069e9fa1980f7020e207ddaec7a815024b66553f16e5e9560f8efb9e120286d4bef9c23de3acde39a20532f0500ffd588ef7f2fee17d0468
7
+ data.tar.gz: 3e4f32bf681d828b15d4d3412b460baf8e135edd53fd3f4fbbb6d3997153420cd80a620ee70a3e93fc7cef7c1b7fd2a702334a8cadfeda5e4bb5263aa9cb8e21
@@ -6,8 +6,8 @@ defaults: &defaults
6
6
  restore_ruby_cache: &restore_ruby_cache
7
7
  restore_cache:
8
8
  keys:
9
- - v1-dependencies-{{ checksum "Gemfile.lock" }}
10
- - v1-dependencies-
9
+ - v2-dependencies-{{ checksum "Gemfile.lock" }}
10
+ - v2-dependencies-
11
11
  setup_rubygems: &setup_rubygems
12
12
  run:
13
13
  name: Add RubyGems API key
@@ -20,6 +20,9 @@ install_dependencies: &install_dependencies
20
20
  run:
21
21
  name: Install Dependencies
22
22
  command: |
23
+ echo 'export BUNDLER_VERSION=$(cat Gemfile.lock | tail -1 | tr -d " ")' >> $BASH_ENV
24
+ source $BASH_ENV
25
+ gem install bundler
23
26
  bundle install --jobs=4 --retry=3 --path vendor/bundle
24
27
 
25
28
  save_ruby_cache: &save_ruby_cache
@@ -59,8 +62,6 @@ run_rspec_tests: &run_rspec_tests
59
62
  $TEST_FILES
60
63
  ./tmp/cc-test-reporter format-coverage -t simplecov -o "tmp/codeclimate.json"
61
64
 
62
-
63
-
64
65
  upload_coverage: &upload_coverage
65
66
  run:
66
67
  name: Upload Coverage
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- oneroster (1.3.6)
4
+ oneroster (2.3.0)
5
5
  dry-inflector
6
6
  faraday
7
7
  faraday_middleware
@@ -21,19 +21,22 @@ require 'types/classroom'
21
21
  require 'types/enrollment'
22
22
  require 'types/student'
23
23
  require 'types/teacher'
24
+ require 'types/term'
24
25
 
25
26
  module OneRoster
26
27
  class DistrictNotFound < StandardError; end
27
28
  class ConnectionError < StandardError; end
28
29
 
29
- STUDENTS_ENDPOINT = 'ims/oneroster/v1p1/students'
30
- TEACHERS_ENDPOINT = 'ims/oneroster/v1p1/teachers'
31
- COURSES_ENDPOINT = 'ims/oneroster/v1p1/courses'
32
- CLASSES_ENDPOINT = 'ims/oneroster/v1p1/classes'
33
- ENROLLMENTS_ENDPOINT = 'ims/oneroster/v1p1/enrollments'
30
+ STUDENTS_ENDPOINT = 'ims/oneroster/v1p1/students'
31
+ TEACHERS_ENDPOINT = 'ims/oneroster/v1p1/teachers'
32
+ COURSES_ENDPOINT = 'ims/oneroster/v1p1/courses'
33
+ CLASSES_ENDPOINT = 'ims/oneroster/v1p1/classes'
34
+ ENROLLMENTS_ENDPOINT = 'ims/oneroster/v1p1/enrollments'
35
+ ACADEMIC_SESSIONS_ENDPOINT = 'ims/oneroster/v1p1/academicSessions'
34
36
 
35
37
  RESPONSE_TYPE_MAP = {
36
38
  'teachers' => 'users',
39
+ 'academicSessions' => 'academicSessions',
37
40
  'students' => 'users',
38
41
  'courses' => 'courses',
39
42
  'classes' => 'classes',
@@ -40,22 +40,40 @@ module OneRoster
40
40
 
41
41
  oneroster_classes = classes
42
42
 
43
+ terms_hash = terms.each_with_object({}) { |term, terms| terms[term.uid] = term }
44
+
43
45
  courses = courses(course_codes, oneroster_classes)
44
46
 
45
47
  oneroster_classes.each_with_object([]) do |oneroster_class, oneroster_classes|
46
48
  course = courses.find { |course| course.uid == oneroster_class.course_uid }
47
49
  next unless course
48
50
 
51
+ term = terms_hash[oneroster_class.term_id]
52
+
49
53
  oneroster_classes << Types::Classroom.new(
50
54
  'id' => oneroster_class.uid,
51
55
  'name' => oneroster_class.title,
52
56
  'course_number' => course.course_code,
53
57
  'period' => oneroster_class.period,
54
- 'grades' => oneroster_class.grades
58
+ 'grades' => oneroster_class.grades,
59
+ 'subjects' => oneroster_class.subjects,
60
+ 'term_name' => term&.name,
61
+ 'term_start_date' => term&.start_date,
62
+ 'term_end_date' => term&.end_date
55
63
  )
56
64
  end
57
65
  end
58
66
 
67
+ def terms
68
+ authenticate
69
+
70
+ endpoint = OneRoster::ACADEMIC_SESSIONS_ENDPOINT
71
+
72
+ type = Types::Term
73
+
74
+ Paginator.fetch(connection, endpoint, :get, type, client: self).force
75
+ end
76
+
59
77
  def courses(course_codes = [], oneroster_classes = classes)
60
78
  authenticate
61
79
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module OneRoster
2
4
  class Response
3
5
  attr_reader :status, :raw_body, :headers
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module OneRoster
4
- VERSION = '1.3.6'
4
+ VERSION = '2.3.0'
5
5
  end
@@ -8,7 +8,9 @@ module OneRoster
8
8
  :course_uid,
9
9
  :provider,
10
10
  :period,
11
- :grades
11
+ :grades,
12
+ :subjects,
13
+ :term_id
12
14
 
13
15
  def initialize(attributes = {}, *)
14
16
  @uid = attributes['sourcedId']
@@ -16,7 +18,9 @@ module OneRoster
16
18
  @course_uid = attributes['course']['sourcedId']
17
19
  @status = attributes['status']
18
20
  @period = first_period(attributes) || period_from_code(attributes)
19
- @grades = attributes['grades']
21
+ @grades = presence(attributes['grades']) || []
22
+ @subjects = presence(attributes['subjects']) || []
23
+ @term_id = attributes['terms'][0]['sourcedId']
20
24
  @provider = 'oneroster'
21
25
  end
22
26
 
@@ -33,6 +37,14 @@ module OneRoster
33
37
  def period_from_code(attributes)
34
38
  attributes['classCode']&.match(/- Period (\d+) -/) { |m| m[1] }
35
39
  end
40
+
41
+ def presence(field)
42
+ field unless blank?(field)
43
+ end
44
+
45
+ def blank?(field)
46
+ field.nil? || field == ''
47
+ end
36
48
  end
37
49
  end
38
50
  end
@@ -8,15 +8,23 @@ module OneRoster
8
8
  :course_number,
9
9
  :period,
10
10
  :grades,
11
- :provider
11
+ :subjects,
12
+ :provider,
13
+ :term_name,
14
+ :term_start_date,
15
+ :term_end_date
12
16
 
13
17
  def initialize(attributes = {})
14
- @uid = attributes['id']
15
- @name = attributes['name']
16
- @course_number = attributes['course_number']
17
- @period = attributes['period']
18
- @grades = attributes['grades']
19
- @provider = 'oneroster'
18
+ @uid = attributes['id']
19
+ @name = attributes['name']
20
+ @course_number = attributes['course_number']
21
+ @period = attributes['period']
22
+ @grades = attributes['grades']
23
+ @subjects = attributes['subjects']
24
+ @term_name = attributes['term_name']
25
+ @term_start_date = attributes['term_start_date']
26
+ @term_end_date = attributes['term_end_date']
27
+ @provider = 'oneroster'
20
28
  end
21
29
  end
22
30
  end
@@ -25,7 +25,7 @@ module OneRoster
25
25
  teacher?
26
26
  end
27
27
 
28
- def primary_teacher?
28
+ def primary
29
29
  teacher? && @primary.to_s == 'true'
30
30
  end
31
31
 
@@ -41,6 +41,7 @@ module OneRoster
41
41
  {
42
42
  classroom_uid: @classroom_uid,
43
43
  user_uid: @user_uid,
44
+ primary: primary,
44
45
  provider: @provider
45
46
  }
46
47
  end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module OneRoster
4
+ module Types
5
+ class Term < Base
6
+ attr_reader :uid,
7
+ :name,
8
+ :start_date,
9
+ :end_date
10
+
11
+ def initialize(attributes = {}, *)
12
+ @uid = attributes['sourcedId']
13
+ @name = attributes['title']
14
+ @start_date = attributes['startDate']
15
+ @end_date = attributes['endDate']
16
+ end
17
+ end
18
+ end
19
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: oneroster
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.6
4
+ version: 2.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robert Julius
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-05-15 00:00:00.000000000 Z
11
+ date: 2020-08-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -243,6 +243,7 @@ files:
243
243
  - lib/types/enrollment.rb
244
244
  - lib/types/student.rb
245
245
  - lib/types/teacher.rb
246
+ - lib/types/term.rb
246
247
  - one_roster.gemspec
247
248
  homepage: https://github.com/TCI/oneroster
248
249
  licenses:
@@ -265,7 +266,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
265
266
  version: '0'
266
267
  requirements: []
267
268
  rubyforge_project:
268
- rubygems_version: 2.6.11
269
+ rubygems_version: 2.6.13
269
270
  signing_key:
270
271
  specification_version: 4
271
272
  summary: Wrapper for the OneRoster API.