oneroster 2.0.0 → 2.3.1

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: d91a0bad177611a68ff1df87f169e8e13e28c099
4
- data.tar.gz: 0e9d6b9b88376cf28bacd10a4cad460917c6f0ca
3
+ metadata.gz: ac81a3a6a046beb01b2ae6d34e6ff2f373921d41
4
+ data.tar.gz: 35e4d0240dc30cfe9aa5bf38af83de2ab19dcb31
5
5
  SHA512:
6
- metadata.gz: 6346c597c1c3017ae5e423f8f1ff5f11a1df833ad0451ee533bfd6cb57842f25c3bc8e818cbdd4a6dfd38da1b16e8a47c0835de1c6b29fac10ae8a649e70311a
7
- data.tar.gz: 607d41b9292ad1533e6c7339feeae9a97b344c4dd04c77509141018e026d73797075b2d6438ddc075b3ffe76fd1b054d1ee032e93b961e2ad1b6b65322153f5d
6
+ metadata.gz: dcd9b28d5b6d2607fff300142b0978a97b01d0227fa0ed1f89f828bdcad656b1955b9951864afd3a7ef75277cf4312d6b121ce12e61a882376adce66d9f46f7e
7
+ data.tar.gz: b8bc51ac42ea3b4aa4609f6b8d999368b2b181c35006d951133c1169151a02a85a41ba1c24fc035a00263185a26d776801203a3aa27094a05d08710d23919375
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- oneroster (2.0.0)
4
+ oneroster (2.3.1)
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 = '2.0.0'
4
+ VERSION = '2.3.1'
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.dig('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: 2.0.0
4
+ version: 2.3.1
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-27 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: