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 +4 -4
- data/Gemfile.lock +1 -1
- data/lib/one_roster.rb +8 -5
- data/lib/one_roster/client.rb +19 -1
- data/lib/one_roster/response.rb +2 -0
- data/lib/one_roster/version.rb +1 -1
- data/lib/types/class.rb +14 -2
- data/lib/types/classroom.rb +15 -7
- data/lib/types/enrollment.rb +2 -1
- data/lib/types/term.rb +19 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ac81a3a6a046beb01b2ae6d34e6ff2f373921d41
|
4
|
+
data.tar.gz: 35e4d0240dc30cfe9aa5bf38af83de2ab19dcb31
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dcd9b28d5b6d2607fff300142b0978a97b01d0227fa0ed1f89f828bdcad656b1955b9951864afd3a7ef75277cf4312d6b121ce12e61a882376adce66d9f46f7e
|
7
|
+
data.tar.gz: b8bc51ac42ea3b4aa4609f6b8d999368b2b181c35006d951133c1169151a02a85a41ba1c24fc035a00263185a26d776801203a3aa27094a05d08710d23919375
|
data/Gemfile.lock
CHANGED
data/lib/one_roster.rb
CHANGED
@@ -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
|
30
|
-
TEACHERS_ENDPOINT
|
31
|
-
COURSES_ENDPOINT
|
32
|
-
CLASSES_ENDPOINT
|
33
|
-
ENROLLMENTS_ENDPOINT
|
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',
|
data/lib/one_roster/client.rb
CHANGED
@@ -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
|
|
data/lib/one_roster/response.rb
CHANGED
data/lib/one_roster/version.rb
CHANGED
data/lib/types/class.rb
CHANGED
@@ -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
|
data/lib/types/classroom.rb
CHANGED
@@ -8,15 +8,23 @@ module OneRoster
|
|
8
8
|
:course_number,
|
9
9
|
:period,
|
10
10
|
:grades,
|
11
|
-
:
|
11
|
+
:subjects,
|
12
|
+
:provider,
|
13
|
+
:term_name,
|
14
|
+
:term_start_date,
|
15
|
+
:term_end_date
|
12
16
|
|
13
17
|
def initialize(attributes = {})
|
14
|
-
@uid
|
15
|
-
@name
|
16
|
-
@course_number
|
17
|
-
@period
|
18
|
-
@grades
|
19
|
-
@
|
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
|
data/lib/types/enrollment.rb
CHANGED
@@ -25,7 +25,7 @@ module OneRoster
|
|
25
25
|
teacher?
|
26
26
|
end
|
27
27
|
|
28
|
-
def
|
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
|
data/lib/types/term.rb
ADDED
@@ -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.
|
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-
|
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:
|