oneroster 2.0.0 → 2.0.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: 56b1e4481ec56f6041edd31f16457ace9bd84d88
4
+ data.tar.gz: 364a22aeaa63d58c65997563a239e549e1fbd70a
5
5
  SHA512:
6
- metadata.gz: 6346c597c1c3017ae5e423f8f1ff5f11a1df833ad0451ee533bfd6cb57842f25c3bc8e818cbdd4a6dfd38da1b16e8a47c0835de1c6b29fac10ae8a649e70311a
7
- data.tar.gz: 607d41b9292ad1533e6c7339feeae9a97b344c4dd04c77509141018e026d73797075b2d6438ddc075b3ffe76fd1b054d1ee032e93b961e2ad1b6b65322153f5d
6
+ metadata.gz: f0a4b44c8e3e518fc65bb7ca287b7ace69f5a036b82def7c33f2fbccc5aae60188efe7152e012a4bd4878dbd58512f28d15f1b4557ba95d59432d1226ec3e260
7
+ data.tar.gz: 7940dcec5c164d80229032579927374c9b2c9d539d15a30ed8423002ad35795de980152252a58b04b04371762a4c9c76a47e675fd22fabafdc91f0efafecb383
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- oneroster (2.0.0)
4
+ oneroster (2.0.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,39 @@ 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
+ 'term_name' => term&.name,
60
+ 'term_start_date' => term&.start_date,
61
+ 'term_end_date' => term&.end_date
55
62
  )
56
63
  end
57
64
  end
58
65
 
66
+ def terms
67
+ authenticate
68
+
69
+ endpoint = OneRoster::ACADEMIC_SESSIONS_ENDPOINT
70
+
71
+ type = Types::Term
72
+
73
+ Paginator.fetch(connection, endpoint, :get, type, client: self).force
74
+ end
75
+
59
76
  def courses(course_codes = [], oneroster_classes = classes)
60
77
  authenticate
61
78
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module OneRoster
4
- VERSION = '2.0.0'
4
+ VERSION = '2.0.1'
5
5
  end
@@ -8,7 +8,8 @@ module OneRoster
8
8
  :course_uid,
9
9
  :provider,
10
10
  :period,
11
- :grades
11
+ :grades,
12
+ :term_id
12
13
 
13
14
  def initialize(attributes = {}, *)
14
15
  @uid = attributes['sourcedId']
@@ -17,6 +18,7 @@ module OneRoster
17
18
  @status = attributes['status']
18
19
  @period = first_period(attributes) || period_from_code(attributes)
19
20
  @grades = attributes['grades']
21
+ @term_id = attributes['terms'][0]['sourcedId']
20
22
  @provider = 'oneroster'
21
23
  end
22
24
 
@@ -8,15 +8,21 @@ module OneRoster
8
8
  :course_number,
9
9
  :period,
10
10
  :grades,
11
- :provider
11
+ :provider,
12
+ :term_name,
13
+ :term_start_date,
14
+ :term_end_date
12
15
 
13
16
  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'
17
+ @uid = attributes['id']
18
+ @name = attributes['name']
19
+ @course_number = attributes['course_number']
20
+ @period = attributes['period']
21
+ @grades = attributes['grades']
22
+ @term_name = attributes['term_name']
23
+ @term_start_date = attributes['term_start_date']
24
+ @term_end_date = attributes['term_end_date']
25
+ @provider = 'oneroster'
20
26
  end
21
27
  end
22
28
  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.0.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-06-24 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: