learnsprout 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +7 -4
- data/features/sections.feature +35 -0
- data/features/step_definitions/client_steps.rb +28 -0
- data/features/teachers.feature +7 -0
- data/features/term.feature +7 -0
- data/lib/learnsprout/course.rb +0 -1
- data/lib/learnsprout/org.rb +0 -1
- data/lib/learnsprout/phone.rb +14 -12
- data/lib/learnsprout/school.rb +70 -69
- data/lib/learnsprout/section.rb +44 -4
- data/lib/learnsprout/student.rb +26 -4
- data/lib/learnsprout/teacher.rb +10 -4
- data/lib/learnsprout/term.rb +23 -7
- data/lib/learnsprout/version.rb +1 -1
- metadata +2 -2
data/README.md
CHANGED
data/features/sections.feature
CHANGED
@@ -42,3 +42,38 @@ Feature: Get Sections
|
|
42
42
|
* I request an org with id 4fdaeaa92eea44952ab9e520
|
43
43
|
* When I request a section with id 4fdb1f6691e4e649b7000000 for that org
|
44
44
|
* I should get a section with id 4fdb1f6691e4e649b7000000
|
45
|
+
|
46
|
+
Scenario: Term for section
|
47
|
+
* I have entered my api key as fcb8534c-e4ee-4e02-8b22-9328db1dac18
|
48
|
+
* I request an org with id 4fdaeaa92eea44952ab9e520
|
49
|
+
* I request a section with id 4fdb1f6691e4e649b7000000 for that org
|
50
|
+
* When I request the term for that section
|
51
|
+
* I should get a term with id 4fdb21cb91e4e64a0600000b
|
52
|
+
|
53
|
+
Scenario: Teacher for section
|
54
|
+
* I have entered my api key as fcb8534c-e4ee-4e02-8b22-9328db1dac18
|
55
|
+
* I request an org with id 4fdaeaa92eea44952ab9e520
|
56
|
+
* I request a section with id 4fdb1f6691e4e649b7000000 for that org
|
57
|
+
* When I request the teacher for that section
|
58
|
+
* I should get a teacher with id 4fdb1ffaaa411b22c9a49e10
|
59
|
+
|
60
|
+
Scenario: School for section
|
61
|
+
* I have entered my api key as fcb8534c-e4ee-4e02-8b22-9328db1dac18
|
62
|
+
* I request an org with id 4fdaeaa92eea44952ab9e520
|
63
|
+
* I request a section with id 4fdb1f6691e4e649b7000000 for that org
|
64
|
+
* When I request the school for that section
|
65
|
+
* I should get a school with id 4fdac86faa411b22c9a3fd2f
|
66
|
+
|
67
|
+
Scenario: Course for section
|
68
|
+
* I have entered my api key as fcb8534c-e4ee-4e02-8b22-9328db1dac18
|
69
|
+
* I request an org with id 4fdaeaa92eea44952ab9e520
|
70
|
+
* I request a section with id 4fdb1f6691e4e649b7000000 for that org
|
71
|
+
* When I request the course for that section
|
72
|
+
* I should get a course with id 4fdac84faa411b22c9a3fd1b
|
73
|
+
|
74
|
+
Scenario: Students for section
|
75
|
+
* I have entered my api key as fcb8534c-e4ee-4e02-8b22-9328db1dac18
|
76
|
+
* I request an org with id 4fdaeaa92eea44952ab9e520
|
77
|
+
* I request a section with id 4fdb1f6691e4e649b7000000 for that org
|
78
|
+
* When I request the students for that section
|
79
|
+
* I should get a list of 21 students
|
@@ -135,6 +135,26 @@ Given /^(?:When )?I request a section with id ([a-f0-9]{24}) for that org$/ do |
|
|
135
135
|
@section = @org.section(section_id)
|
136
136
|
end
|
137
137
|
|
138
|
+
Given /^(?:When )?I request the term for that section$/ do
|
139
|
+
@term = @section.term
|
140
|
+
end
|
141
|
+
|
142
|
+
Given /^(?:When )?I request the students for that section$/ do
|
143
|
+
@students = @section.students
|
144
|
+
end
|
145
|
+
|
146
|
+
Given /^(?:When )?I request the teacher for that section$/ do
|
147
|
+
@teacher = @section.teacher
|
148
|
+
end
|
149
|
+
|
150
|
+
Given /^(?:When )?I request the school for that section$/ do
|
151
|
+
@school = @section.school
|
152
|
+
end
|
153
|
+
|
154
|
+
Given /^(?:When )?I request the course for that section$/ do
|
155
|
+
@course = @section.course
|
156
|
+
end
|
157
|
+
|
138
158
|
# Teachers
|
139
159
|
|
140
160
|
Given /^When I request teachers for an organization with id ([a-f0-9]{24})$/ do |org_id|
|
@@ -173,6 +193,10 @@ Given /^(?:When )?I request a teacher with id ([a-f0-9]{24}) for that org$/ do |
|
|
173
193
|
@teacher = @org.teacher(teacher_id)
|
174
194
|
end
|
175
195
|
|
196
|
+
Given /^(?:When )?I request the school for that teacher$/ do
|
197
|
+
@school = @teacher.school
|
198
|
+
end
|
199
|
+
|
176
200
|
# Terms
|
177
201
|
|
178
202
|
Given /^When I request terms for an organization with id ([a-f0-9]{24})$/ do |org_id|
|
@@ -224,6 +248,10 @@ Given /^(?:When )?I request the current term for an org with id ([a-f0-9]{24}) a
|
|
224
248
|
@term = @client.current_term(org_id, school_id)
|
225
249
|
end
|
226
250
|
|
251
|
+
Given /^(?:When )?I request the sections for that term$/ do
|
252
|
+
@sections = @term.sections
|
253
|
+
end
|
254
|
+
|
227
255
|
# Courses
|
228
256
|
|
229
257
|
Given /^When I request courses for an organization with id ([a-f0-9]{24})$/ do |org_id|
|
data/features/teachers.feature
CHANGED
@@ -42,3 +42,10 @@ Feature: Get Teachers
|
|
42
42
|
* I request an org with id 4fdaeaa92eea44952ab9e520
|
43
43
|
* When I request a teacher with id 4fdb1fceaa411b22c9a49d54 for that org
|
44
44
|
* I should get a teacher with id 4fdb1fceaa411b22c9a49d54
|
45
|
+
|
46
|
+
Scenario: School for teacher
|
47
|
+
* I have entered my api key as fcb8534c-e4ee-4e02-8b22-9328db1dac18
|
48
|
+
* I request an org with id 4fdaeaa92eea44952ab9e520
|
49
|
+
* I request a teacher with id 4fdb1fceaa411b22c9a49d54 for that org
|
50
|
+
* When I request the school for that teacher
|
51
|
+
* I should get a school with id 4fdac86faa411b22c9a3fd2f
|
data/features/term.feature
CHANGED
@@ -54,3 +54,10 @@ Feature: Get Terms
|
|
54
54
|
* I have entered my api key as fcb8534c-e4ee-4e02-8b22-9328db1dac18
|
55
55
|
* When I request the current term for an org with id 4fdaeaa92eea44952ab9e520 and a school with id 4fdac86eaa411b22c9a3fd2e
|
56
56
|
* I should get the current term
|
57
|
+
|
58
|
+
Scenario: Sections for term
|
59
|
+
* I have entered my api key as fcb8534c-e4ee-4e02-8b22-9328db1dac18
|
60
|
+
* I request an org with id 4fdaeaa92eea44952ab9e520
|
61
|
+
* I request a term with id 4fdb21cb91e4e64a06000008 for that org
|
62
|
+
* When I request the sections for that term
|
63
|
+
* I should get a list of 80 sections
|
data/lib/learnsprout/course.rb
CHANGED
data/lib/learnsprout/org.rb
CHANGED
data/lib/learnsprout/phone.rb
CHANGED
@@ -1,12 +1,14 @@
|
|
1
|
-
module LearnSprout
|
2
|
-
class Phone
|
3
|
-
|
4
|
-
attr_accessor :fax,
|
5
|
-
:main
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
@
|
10
|
-
|
11
|
-
|
12
|
-
end
|
1
|
+
module LearnSprout
|
2
|
+
class Phone
|
3
|
+
|
4
|
+
attr_accessor :fax,
|
5
|
+
:main,
|
6
|
+
:home
|
7
|
+
|
8
|
+
def initialize(attrs={})
|
9
|
+
@fax = attrs["fax"]
|
10
|
+
@main = attrs["main"]
|
11
|
+
@home = attrs["home"]
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
data/lib/learnsprout/school.rb
CHANGED
@@ -1,69 +1,70 @@
|
|
1
|
-
module LearnSprout
|
2
|
-
class School
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
:
|
7
|
-
:
|
8
|
-
:
|
9
|
-
:
|
10
|
-
:
|
11
|
-
|
12
|
-
def initialize(attrs={})
|
13
|
-
@client = attrs["client"]
|
14
|
-
@org_id = attrs["org_id"]
|
15
|
-
@school_id = attrs["id"]
|
16
|
-
@name = attrs["name"]
|
17
|
-
@number = attrs["number"]
|
18
|
-
@nces = Nces.new(attrs["nces"])
|
19
|
-
@phone = Phone.new(attrs["phone"])
|
20
|
-
@address = Address.new(attrs["address"])
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
end
|
1
|
+
module LearnSprout
|
2
|
+
class School
|
3
|
+
|
4
|
+
attr_accessor :school_id,
|
5
|
+
:name,
|
6
|
+
:number,
|
7
|
+
:nces,
|
8
|
+
:phone,
|
9
|
+
:address,
|
10
|
+
:time_updated
|
11
|
+
|
12
|
+
def initialize(attrs={})
|
13
|
+
@client = attrs["client"]
|
14
|
+
@org_id = attrs["org_id"]
|
15
|
+
@school_id = attrs["id"]
|
16
|
+
@name = attrs["name"]
|
17
|
+
@number = attrs["number"]
|
18
|
+
@nces = Nces.new(attrs["nces"])
|
19
|
+
@phone = Phone.new(attrs["phone"])
|
20
|
+
@address = Address.new(attrs["address"])
|
21
|
+
@time_updated = attrs["time_updated"]
|
22
|
+
end
|
23
|
+
|
24
|
+
#TODO Add org method?
|
25
|
+
|
26
|
+
def student(student_id)
|
27
|
+
@client.student(@org_id, student_id)
|
28
|
+
end
|
29
|
+
|
30
|
+
def students
|
31
|
+
@client.students(@org_id, :school_id => @school_id)
|
32
|
+
end
|
33
|
+
|
34
|
+
def section(section_id)
|
35
|
+
@client.section(@org_id, section_id)
|
36
|
+
end
|
37
|
+
|
38
|
+
def sections
|
39
|
+
@client.sections(@org_id, :school_id => @school_id)
|
40
|
+
end
|
41
|
+
|
42
|
+
def teacher(teacher_id)
|
43
|
+
@client.teacher(@org_id, teacher_id)
|
44
|
+
end
|
45
|
+
|
46
|
+
def teachers
|
47
|
+
@client.teachers(@org_id, :school_id => @school_id)
|
48
|
+
end
|
49
|
+
|
50
|
+
def term(term_id)
|
51
|
+
@client.term(@org_id, term_id)
|
52
|
+
end
|
53
|
+
|
54
|
+
def terms
|
55
|
+
@client.terms(@org_id, :school_id => @school_id)
|
56
|
+
end
|
57
|
+
|
58
|
+
def current_term
|
59
|
+
@client.current_term(@org_id, @school_id)
|
60
|
+
end
|
61
|
+
|
62
|
+
def course(course_id)
|
63
|
+
@client.course(@org_id, course_id)
|
64
|
+
end
|
65
|
+
|
66
|
+
def courses
|
67
|
+
@client.courses(@org_id, :school_id => @school_id)
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
data/lib/learnsprout/section.rb
CHANGED
@@ -1,10 +1,14 @@
|
|
1
1
|
module LearnSprout
|
2
2
|
class Section
|
3
|
-
include LearnSprout::Connection
|
4
3
|
|
5
|
-
attr_accessor :
|
4
|
+
attr_accessor :term_id,
|
5
|
+
:section_id,
|
6
6
|
:number,
|
7
|
-
:room
|
7
|
+
:room,
|
8
|
+
:time_updated,
|
9
|
+
:teacher_id,
|
10
|
+
:school_id,
|
11
|
+
:course_id
|
8
12
|
|
9
13
|
def initialize(attrs={})
|
10
14
|
@client = attrs["client"]
|
@@ -12,7 +16,43 @@ module LearnSprout
|
|
12
16
|
@section_id = attrs["id"]
|
13
17
|
@number = attrs["number"]
|
14
18
|
@room = attrs["room"]
|
15
|
-
|
19
|
+
@term_id = attrs["term"] && attrs["term"]["id"]
|
20
|
+
@teacher_id = attrs["teacher"] && attrs["teacher"]["id"]
|
21
|
+
@school_id = attrs["school"] && attrs["school"]["id"]
|
22
|
+
@course_id = attrs["course"] && attrs["course"]["id"]
|
23
|
+
@time_updated = attrs["time_updated"]
|
24
|
+
@student_ids = []
|
25
|
+
if attrs["students"]
|
26
|
+
attrs["students"].each do |student|
|
27
|
+
@student_ids.push student["id"]
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def term
|
33
|
+
@term_id && @client.term(@org_id, @term_id)
|
34
|
+
end
|
35
|
+
|
36
|
+
def teacher
|
37
|
+
@teacher_id && @client.teacher(@org_id, @teacher_id)
|
38
|
+
end
|
39
|
+
|
40
|
+
def school
|
41
|
+
@school_id && @client.school(@org_id, @school_id)
|
42
|
+
end
|
43
|
+
|
44
|
+
def course
|
45
|
+
@course_id && @client.course(@org_id, @course_id)
|
46
|
+
end
|
47
|
+
|
48
|
+
def students
|
49
|
+
temp_students = []
|
50
|
+
if @student_ids.count > 0
|
51
|
+
@student_ids.each do |student_id|
|
52
|
+
temp_students.push @client.student(@org_id, student_id)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
return temp_students
|
16
56
|
end
|
17
57
|
end
|
18
58
|
end
|
data/lib/learnsprout/student.rb
CHANGED
@@ -1,16 +1,38 @@
|
|
1
1
|
module LearnSprout
|
2
2
|
class Student
|
3
|
-
include LearnSprout::Connection
|
4
3
|
|
5
4
|
attr_accessor :student_id,
|
6
|
-
:
|
5
|
+
:last_name,
|
6
|
+
:grade,
|
7
|
+
:address,
|
8
|
+
:school_id,
|
9
|
+
:number,
|
10
|
+
:phone,
|
11
|
+
:birthday,
|
12
|
+
:first_name,
|
13
|
+
:time_updated,
|
14
|
+
:middle_name,
|
15
|
+
:gender,
|
16
|
+
:exit_date,
|
17
|
+
:entry_date
|
7
18
|
|
8
19
|
def initialize(attrs={})
|
9
20
|
@client = attrs["client"]
|
10
21
|
@org_id = attrs["org_id"]
|
11
22
|
@student_id = attrs["id"]
|
12
|
-
@
|
13
|
-
|
23
|
+
@last_name = attrs["last_name"]
|
24
|
+
@grade = attrs["grade"]
|
25
|
+
@address = Address.new(attrs["address"])
|
26
|
+
@school_id = attrs["school"]["id"]
|
27
|
+
@number = attrs["number"]
|
28
|
+
@phone = Phone.new(attrs["phone"])
|
29
|
+
@birthday = attrs["birthday"] && Date.parse(attrs["birthday"])
|
30
|
+
@first_name = attrs["first_name"]
|
31
|
+
@time_updated = attrs["time_updated"]
|
32
|
+
@middle_name = attrs["middle_name"]
|
33
|
+
@gender = attrs["gender"]
|
34
|
+
@exit_date = attrs["exit_date"] && Date.parse(attrs["exit_date"])
|
35
|
+
@entry_date = attrs["entry_date"] && Date.parse(attrs["entry_date"])
|
14
36
|
end
|
15
37
|
end
|
16
38
|
end
|
data/lib/learnsprout/teacher.rb
CHANGED
@@ -1,18 +1,18 @@
|
|
1
1
|
module LearnSprout
|
2
2
|
class Teacher
|
3
|
-
include LearnSprout::Connection
|
4
3
|
|
5
4
|
attr_accessor :teacher_id,
|
6
5
|
:first_name,
|
7
6
|
:middle_name,
|
8
7
|
:last_name,
|
9
8
|
:title,
|
9
|
+
:address,
|
10
|
+
:school_id,
|
10
11
|
:number,
|
12
|
+
:phone,
|
11
13
|
:time_updated,
|
12
14
|
:email
|
13
15
|
|
14
|
-
#TODO Other fields
|
15
|
-
|
16
16
|
def initialize(attrs={})
|
17
17
|
@client = attrs["client"]
|
18
18
|
@org_id = attrs["org_id"]
|
@@ -21,10 +21,16 @@ module LearnSprout
|
|
21
21
|
@middle_name = attrs["middle_name"]
|
22
22
|
@last_name = attrs["last_name"]
|
23
23
|
@title = attrs["title"]
|
24
|
+
@address = attrs["address"] && Address.new(attrs["address"])
|
25
|
+
@school_id = attrs["school"] && attrs["school"]["id"]
|
24
26
|
@number = attrs["number"]
|
27
|
+
@phone = attrs["phone"] && Phone.new(attrs["phone"])
|
25
28
|
@time_updated = attrs["time_updated"]
|
26
29
|
@email = attrs["email"]
|
27
|
-
|
30
|
+
end
|
31
|
+
|
32
|
+
def school
|
33
|
+
@school_id && @client.school(@org_id, @school_id)
|
28
34
|
end
|
29
35
|
end
|
30
36
|
end
|
data/lib/learnsprout/term.rb
CHANGED
@@ -1,22 +1,38 @@
|
|
1
1
|
module LearnSprout
|
2
2
|
class Term
|
3
|
-
include LearnSprout::Connection
|
4
3
|
|
5
4
|
attr_accessor :term_id,
|
6
5
|
:name,
|
7
6
|
:end_date,
|
8
|
-
:start_date
|
9
|
-
|
10
|
-
|
7
|
+
:start_date,
|
8
|
+
:school_id,
|
9
|
+
:time_updated
|
11
10
|
|
12
11
|
def initialize(attrs={})
|
13
12
|
@client = attrs["client"]
|
14
13
|
@org_id = attrs["org_id"]
|
15
14
|
@term_id = attrs["id"]
|
16
15
|
@name = attrs["name"]
|
17
|
-
@end_date = Date.parse(attrs["end_date"])
|
18
|
-
@start_date = Date.parse(attrs["start_date"])
|
19
|
-
|
16
|
+
@end_date = attrs["end_date"] && Date.parse(attrs["end_date"])
|
17
|
+
@start_date = attrs["start_date"] && Date.parse(attrs["start_date"])
|
18
|
+
@school_id = attrs["school_id"]
|
19
|
+
@time_updated = attrs["time_updated"]
|
20
|
+
@section_ids = []
|
21
|
+
if attrs["sections"]
|
22
|
+
attrs["sections"].each do |section|
|
23
|
+
@section_ids.push section["id"]
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def sections
|
29
|
+
temp_sections = []
|
30
|
+
if @section_ids.count > 0
|
31
|
+
@section_ids.each do |section_id|
|
32
|
+
temp_sections.push @client.section(@org_id, section_id)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
return temp_sections
|
20
36
|
end
|
21
37
|
end
|
22
38
|
end
|
data/lib/learnsprout/version.rb
CHANGED