moodle_rb 0.0.5
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/.gitignore +35 -0
- data/Gemfile +2 -0
- data/LICENSE +22 -0
- data/README.md +108 -0
- data/Rakefile +1 -0
- data/lib/moodle_rb/categories.rb +94 -0
- data/lib/moodle_rb/client.rb +44 -0
- data/lib/moodle_rb/courses.rb +101 -0
- data/lib/moodle_rb/enrolments.rb +39 -0
- data/lib/moodle_rb/error.rb +18 -0
- data/lib/moodle_rb/grades.rb +42 -0
- data/lib/moodle_rb/users.rb +83 -0
- data/lib/moodle_rb/utility.rb +25 -0
- data/lib/moodle_rb/version.rb +7 -0
- data/lib/moodle_rb.rb +16 -0
- data/moodle_rb.gemspec +27 -0
- data/spec/cassettes/MoodleRb_Categories/_create/.yml +39 -0
- data/spec/cassettes/MoodleRb_Categories/_create/when_validation_fails/.yml +39 -0
- data/spec/cassettes/MoodleRb_Categories/_destroy/.yml +75 -0
- data/spec/cassettes/MoodleRb_Categories/_index/.yml +39 -0
- data/spec/cassettes/MoodleRb_Categories/_show/.yml +39 -0
- data/spec/cassettes/MoodleRb_Client/_site_info/when_invalid_token/.yml +39 -0
- data/spec/cassettes/MoodleRb_Client/_site_info/when_valid_token/.yml +39 -0
- data/spec/cassettes/MoodleRb_Courses/_create/.yml +39 -0
- data/spec/cassettes/MoodleRb_Courses/_create/when_validation_fails/.yml +75 -0
- data/spec/cassettes/MoodleRb_Courses/_destroy/.yml +75 -0
- data/spec/cassettes/MoodleRb_Courses/_enrolled_users/.yml +75 -0
- data/spec/cassettes/MoodleRb_Courses/_index/.yml +39 -0
- data/spec/cassettes/MoodleRb_Courses/_show/.yml +39 -0
- data/spec/cassettes/MoodleRb_Enrolments/_create/.yml +39 -0
- data/spec/cassettes/MoodleRb_Enrolments/_create/when_user_or_course_id_is_invalid/.yml +39 -0
- data/spec/cassettes/MoodleRb_Grades/_by_assignment/.yml +39 -0
- data/spec/cassettes/MoodleRb_Grades/_by_course/.yml +39 -0
- data/spec/cassettes/MoodleRb_Users/_create/.yml +39 -0
- data/spec/cassettes/MoodleRb_Users/_create/when_missing_required_parameters/.yml +39 -0
- data/spec/cassettes/MoodleRb_Users/_destroy/.yml +39 -0
- data/spec/cassettes/MoodleRb_Users/_destroy/when_id_does_not_exist/.yml +39 -0
- data/spec/cassettes/MoodleRb_Users/_enrolled_courses/.yml +39 -0
- data/spec/cassettes/MoodleRb_Users/_show/.yml +39 -0
- data/spec/lib/moodle_rb/categories_spec.rb +74 -0
- data/spec/lib/moodle_rb/client_spec.rb +45 -0
- data/spec/lib/moodle_rb/courses_spec.rb +92 -0
- data/spec/lib/moodle_rb/enrolments_spec.rb +39 -0
- data/spec/lib/moodle_rb/error_spec.rb +20 -0
- data/spec/lib/moodle_rb/grades_spec.rb +32 -0
- data/spec/lib/moodle_rb/users_spec.rb +87 -0
- data/spec/lib/moodle_rb/utility_spec.rb +23 -0
- data/spec/lib/moodle_rb_spec.rb +11 -0
- data/spec/spec_helper.rb +25 -0
- metadata +251 -0
@@ -0,0 +1,39 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: post
|
5
|
+
uri: http://localhost:8888/moodle28/webservice/rest/server.php?moodlewsrestformat=json&wsfunction=core_course_get_courses&wstoken=60fc9c9415259404795094957e4ab32f
|
6
|
+
body:
|
7
|
+
string: options[ids][0]=1
|
8
|
+
headers: {}
|
9
|
+
|
10
|
+
response:
|
11
|
+
status:
|
12
|
+
code: 200
|
13
|
+
message: OK
|
14
|
+
headers:
|
15
|
+
Access-Control-Allow-Origin:
|
16
|
+
- "*"
|
17
|
+
X-Powered-By:
|
18
|
+
- PHP/5.6.2
|
19
|
+
Expires:
|
20
|
+
- Thu, 01 Jan 1970 00:00:00 GMT
|
21
|
+
Server:
|
22
|
+
- Apache/2.2.29 (Unix) mod_fastcgi/2.4.6 mod_wsgi/3.4 Python/2.7.8 PHP/5.6.2 mod_ssl/2.2.29 OpenSSL/0.9.8zd DAV/2 mod_perl/2.0.8 Perl/v5.20.0
|
23
|
+
Pragma:
|
24
|
+
- no-cache
|
25
|
+
Accept-Ranges:
|
26
|
+
- none
|
27
|
+
Content-Type:
|
28
|
+
- application/json
|
29
|
+
Date:
|
30
|
+
- Sun, 12 Apr 2015 00:51:46 GMT
|
31
|
+
Content-Length:
|
32
|
+
- "707"
|
33
|
+
Cache-Control:
|
34
|
+
- private, must-revalidate, pre-check=0, post-check=0, max-age=0
|
35
|
+
body:
|
36
|
+
string: "[{\"id\":1,\"shortname\":\"Moodle 2.8\",\"categoryid\":0,\"categorysortorder\":1,\"fullname\":\"Moodle 2.8\",\"idnumber\":\"\",\"summary\":\"<h2 style=\\\"font-size: large;\\\">Moodle<span style=\\\"font-size: 1.8em; color: red;\\\">4<\\/span>Mac<\\/h2>\\r\\n<p>This package for OS X comes with Moodle 2.8.5+ and MAMP 3.0.7.3. We hope you will like it!<\\/p>\",\"summaryformat\":1,\"format\":\"site\",\"showgrades\":1,\"newsitems\":3,\"startdate\":0,\"numsections\":1,\"maxbytes\":0,\"showreports\":0,\"visible\":1,\"groupmode\":0,\"groupmodeforce\":0,\"defaultgroupingid\":0,\"timecreated\":1405375287,\"timemodified\":1426316351,\"enablecompletion\":0,\"completionnotify\":0,\"lang\":\"\",\"forcetheme\":\"\",\"courseformatoptions\":[{\"name\":\"numsections\",\"value\":1}]}]"
|
37
|
+
http_version:
|
38
|
+
recorded_at: Sun, 12 Apr 2015 00:51:46 GMT
|
39
|
+
recorded_with: VCR 2.9.3
|
@@ -0,0 +1,39 @@
|
|
1
|
+
---
|
2
|
+
recorded_with: VCR 2.9.3
|
3
|
+
http_interactions:
|
4
|
+
- request:
|
5
|
+
method: post
|
6
|
+
uri: http://localhost:8888/moodle28/webservice/rest/server.php?moodlewsrestformat=json&wsfunction=enrol_manual_enrol_users&wstoken=60fc9c9415259404795094957e4ab32f
|
7
|
+
body:
|
8
|
+
string: enrolments[0][userid]=3&enrolments[0][courseid]=8&enrolments[0][roleid]=5
|
9
|
+
headers: {}
|
10
|
+
|
11
|
+
response:
|
12
|
+
status:
|
13
|
+
code: 200
|
14
|
+
message: OK
|
15
|
+
headers:
|
16
|
+
Access-Control-Allow-Origin:
|
17
|
+
- "*"
|
18
|
+
X-Powered-By:
|
19
|
+
- PHP/5.6.2
|
20
|
+
Content-Type:
|
21
|
+
- application/json
|
22
|
+
Date:
|
23
|
+
- Sun, 12 Apr 2015 01:06:20 GMT
|
24
|
+
Content-Length:
|
25
|
+
- "4"
|
26
|
+
Pragma:
|
27
|
+
- no-cache
|
28
|
+
Cache-Control:
|
29
|
+
- private, must-revalidate, pre-check=0, post-check=0, max-age=0
|
30
|
+
Server:
|
31
|
+
- Apache/2.2.29 (Unix) mod_fastcgi/2.4.6 mod_wsgi/3.4 Python/2.7.8 PHP/5.6.2 mod_ssl/2.2.29 OpenSSL/0.9.8zd DAV/2 mod_perl/2.0.8 Perl/v5.20.0
|
32
|
+
Expires:
|
33
|
+
- Thu, 01 Jan 1970 00:00:00 GMT
|
34
|
+
Accept-Ranges:
|
35
|
+
- none
|
36
|
+
body:
|
37
|
+
string: "null"
|
38
|
+
http_version:
|
39
|
+
recorded_at: Sun, 12 Apr 2015 01:06:20 GMT
|
@@ -0,0 +1,39 @@
|
|
1
|
+
---
|
2
|
+
recorded_with: VCR 2.9.3
|
3
|
+
http_interactions:
|
4
|
+
- request:
|
5
|
+
method: post
|
6
|
+
uri: http://localhost:8888/moodle28/webservice/rest/server.php?moodlewsrestformat=json&wsfunction=enrol_manual_enrol_users&wstoken=60fc9c9415259404795094957e4ab32f
|
7
|
+
body:
|
8
|
+
string: enrolments[0][userid]=9999&enrolments[0][courseid]=9999&enrolments[0][roleid]=5
|
9
|
+
headers: {}
|
10
|
+
|
11
|
+
response:
|
12
|
+
status:
|
13
|
+
code: 200
|
14
|
+
message: OK
|
15
|
+
headers:
|
16
|
+
Cache-Control:
|
17
|
+
- private, must-revalidate, pre-check=0, post-check=0, max-age=0
|
18
|
+
Content-Type:
|
19
|
+
- application/json
|
20
|
+
Accept-Ranges:
|
21
|
+
- none
|
22
|
+
Content-Length:
|
23
|
+
- "119"
|
24
|
+
Date:
|
25
|
+
- Sat, 11 Apr 2015 12:50:42 GMT
|
26
|
+
Expires:
|
27
|
+
- Thu, 01 Jan 1970 00:00:00 GMT
|
28
|
+
Access-Control-Allow-Origin:
|
29
|
+
- "*"
|
30
|
+
Server:
|
31
|
+
- Apache/2.2.29 (Unix) mod_fastcgi/2.4.6 mod_wsgi/3.4 Python/2.7.8 PHP/5.6.2 mod_ssl/2.2.29 OpenSSL/0.9.8zd DAV/2 mod_perl/2.0.8 Perl/v5.20.0
|
32
|
+
Pragma:
|
33
|
+
- no-cache
|
34
|
+
X-Powered-By:
|
35
|
+
- PHP/5.6.2
|
36
|
+
body:
|
37
|
+
string: "{\"exception\":\"invalid_parameter_exception\",\"errorcode\":\"invalidparameter\",\"message\":\"Invalid parameter value detected\"}"
|
38
|
+
http_version:
|
39
|
+
recorded_at: Sat, 11 Apr 2015 12:50:42 GMT
|
@@ -0,0 +1,39 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: post
|
5
|
+
uri: http://localhost:8888/moodle28/webservice/rest/server.php?moodlewsrestformat=json&wsfunction=mod_assign_get_grades&wstoken=60fc9c9415259404795094957e4ab32f
|
6
|
+
body:
|
7
|
+
string: assignmentids[0]=1
|
8
|
+
headers: {}
|
9
|
+
|
10
|
+
response:
|
11
|
+
status:
|
12
|
+
code: 200
|
13
|
+
message: OK
|
14
|
+
headers:
|
15
|
+
Content-Length:
|
16
|
+
- "180"
|
17
|
+
Server:
|
18
|
+
- Apache/2.2.29 (Unix) mod_fastcgi/2.4.6 mod_wsgi/3.4 Python/2.7.8 PHP/5.6.2 mod_ssl/2.2.29 OpenSSL/0.9.8zd DAV/2 mod_perl/2.0.8 Perl/v5.20.0
|
19
|
+
Expires:
|
20
|
+
- Thu, 01 Jan 1970 00:00:00 GMT
|
21
|
+
Cache-Control:
|
22
|
+
- private, must-revalidate, pre-check=0, post-check=0, max-age=0
|
23
|
+
Pragma:
|
24
|
+
- no-cache
|
25
|
+
Content-Type:
|
26
|
+
- application/json
|
27
|
+
Accept-Ranges:
|
28
|
+
- none
|
29
|
+
Date:
|
30
|
+
- Wed, 22 Apr 2015 23:29:46 GMT
|
31
|
+
X-Powered-By:
|
32
|
+
- PHP/5.6.2
|
33
|
+
Access-Control-Allow-Origin:
|
34
|
+
- "*"
|
35
|
+
body:
|
36
|
+
string: "{\"assignments\":[{\"assignmentid\":1,\"grades\":[{\"id\":1,\"userid\":5,\"attemptnumber\":0,\"timecreated\":1428801844,\"timemodified\":1428801869,\"grader\":2,\"grade\":\"90.00000\"}]}],\"warnings\":[]}"
|
37
|
+
http_version:
|
38
|
+
recorded_at: Wed, 22 Apr 2015 23:29:46 GMT
|
39
|
+
recorded_with: VCR 2.9.3
|
@@ -0,0 +1,39 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: post
|
5
|
+
uri: http://localhost:8888/moodle28/webservice/rest/server.php?moodlewsrestformat=json&wsfunction=core_grades_get_grades&wstoken=60fc9c9415259404795094957e4ab32f
|
6
|
+
body:
|
7
|
+
string: courseid=8&userids[0]=5
|
8
|
+
headers: {}
|
9
|
+
|
10
|
+
response:
|
11
|
+
status:
|
12
|
+
code: 200
|
13
|
+
message: OK
|
14
|
+
headers:
|
15
|
+
Content-Length:
|
16
|
+
- "1192"
|
17
|
+
Server:
|
18
|
+
- Apache/2.2.29 (Unix) mod_fastcgi/2.4.6 mod_wsgi/3.4 Python/2.7.8 PHP/5.6.2 mod_ssl/2.2.29 OpenSSL/0.9.8zd DAV/2 mod_perl/2.0.8 Perl/v5.20.0
|
19
|
+
Expires:
|
20
|
+
- Thu, 01 Jan 1970 00:00:00 GMT
|
21
|
+
Cache-Control:
|
22
|
+
- private, must-revalidate, pre-check=0, post-check=0, max-age=0
|
23
|
+
Pragma:
|
24
|
+
- no-cache
|
25
|
+
Content-Type:
|
26
|
+
- application/json
|
27
|
+
Accept-Ranges:
|
28
|
+
- none
|
29
|
+
Date:
|
30
|
+
- Wed, 22 Apr 2015 23:29:46 GMT
|
31
|
+
X-Powered-By:
|
32
|
+
- PHP/5.6.2
|
33
|
+
Access-Control-Allow-Origin:
|
34
|
+
- "*"
|
35
|
+
body:
|
36
|
+
string: "{\"items\":[{\"activityid\":\"course\",\"itemnumber\":0,\"scaleid\":0,\"name\":\"Course total\",\"grademin\":0,\"grademax\":100,\"gradepass\":0,\"locked\":0,\"hidden\":0,\"grades\":[{\"userid\":5,\"grade\":85,\"locked\":0,\"hidden\":0,\"overridden\":0,\"feedback\":null,\"feedbackformat\":0,\"usermodified\":null,\"datesubmitted\":null,\"dategraded\":1428807511,\"str_grade\":\"85.00\",\"str_long_grade\":\"85.00 \\/ 100.00\",\"str_feedback\":\"\"}]},{\"activityid\":\"13\",\"itemnumber\":0,\"scaleid\":0,\"name\":\"TestAssignment\",\"grademin\":0,\"grademax\":100,\"gradepass\":0,\"locked\":0,\"hidden\":0,\"grades\":[{\"userid\":5,\"grade\":90,\"locked\":0,\"hidden\":0,\"overridden\":0,\"feedback\":\"<p>Good<\\/p>\",\"feedbackformat\":1,\"usermodified\":2,\"datesubmitted\":null,\"dategraded\":1428801869,\"str_grade\":\"90.00\",\"str_long_grade\":\"90.00 \\/ 100.00\",\"str_feedback\":\"<p>Good<\\/p>\"}]},{\"activityid\":\"14\",\"itemnumber\":0,\"scaleid\":0,\"name\":\"Topic 1 Assignment Test\",\"grademin\":0,\"grademax\":100,\"gradepass\":0,\"locked\":0,\"hidden\":0,\"grades\":[{\"userid\":5,\"grade\":80,\"locked\":0,\"hidden\":0,\"overridden\":0,\"feedback\":null,\"feedbackformat\":1,\"usermodified\":2,\"datesubmitted\":null,\"dategraded\":1428807511,\"str_grade\":\"80.00\",\"str_long_grade\":\"80.00 \\/ 100.00\",\"str_feedback\":\"\"}]}],\"outcomes\":[]}"
|
37
|
+
http_version:
|
38
|
+
recorded_at: Wed, 22 Apr 2015 23:29:46 GMT
|
39
|
+
recorded_with: VCR 2.9.3
|
@@ -0,0 +1,39 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: post
|
5
|
+
uri: http://localhost:8888/moodle28/webservice/rest/server.php?moodlewsrestformat=json&wsfunction=core_user_create_users&wstoken=60fc9c9415259404795094957e4ab32f
|
6
|
+
body:
|
7
|
+
string: users[0][firstname]=Austin&users[0][password]=Password123!&users[0][lastname]=Powers&users[0][idnumber]=PAUST002&users[0][email]=austinp1%40jobready.com.au&users[0][username]=testuser1
|
8
|
+
headers: {}
|
9
|
+
|
10
|
+
response:
|
11
|
+
status:
|
12
|
+
code: 200
|
13
|
+
message: OK
|
14
|
+
headers:
|
15
|
+
Cache-Control:
|
16
|
+
- private, must-revalidate, pre-check=0, post-check=0, max-age=0
|
17
|
+
X-Powered-By:
|
18
|
+
- PHP/5.6.2
|
19
|
+
Pragma:
|
20
|
+
- no-cache
|
21
|
+
Content-Length:
|
22
|
+
- "33"
|
23
|
+
Server:
|
24
|
+
- Apache/2.2.29 (Unix) mod_fastcgi/2.4.6 mod_wsgi/3.4 Python/2.7.8 PHP/5.6.2 mod_ssl/2.2.29 OpenSSL/0.9.8zd DAV/2 mod_perl/2.0.8 Perl/v5.20.0
|
25
|
+
Access-Control-Allow-Origin:
|
26
|
+
- "*"
|
27
|
+
Accept-Ranges:
|
28
|
+
- none
|
29
|
+
Content-Type:
|
30
|
+
- application/json
|
31
|
+
Expires:
|
32
|
+
- Thu, 01 Jan 1970 00:00:00 GMT
|
33
|
+
Date:
|
34
|
+
- Sun, 12 Apr 2015 01:01:16 GMT
|
35
|
+
body:
|
36
|
+
string: "[{\"id\":5,\"username\":\"testuser1\"}]"
|
37
|
+
http_version:
|
38
|
+
recorded_at: Sun, 12 Apr 2015 01:01:16 GMT
|
39
|
+
recorded_with: VCR 2.9.3
|
@@ -0,0 +1,39 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: post
|
5
|
+
uri: http://localhost:8888/moodle28/webservice/rest/server.php?moodlewsrestformat=json&wsfunction=core_user_create_users&wstoken=60fc9c9415259404795094957e4ab32f
|
6
|
+
body:
|
7
|
+
string: users[0][username]=testuser1
|
8
|
+
headers: {}
|
9
|
+
|
10
|
+
response:
|
11
|
+
status:
|
12
|
+
code: 200
|
13
|
+
message: OK
|
14
|
+
headers:
|
15
|
+
Cache-Control:
|
16
|
+
- private, must-revalidate, pre-check=0, post-check=0, max-age=0
|
17
|
+
X-Powered-By:
|
18
|
+
- PHP/5.6.2
|
19
|
+
Pragma:
|
20
|
+
- no-cache
|
21
|
+
Content-Length:
|
22
|
+
- "119"
|
23
|
+
Server:
|
24
|
+
- Apache/2.2.29 (Unix) mod_fastcgi/2.4.6 mod_wsgi/3.4 Python/2.7.8 PHP/5.6.2 mod_ssl/2.2.29 OpenSSL/0.9.8zd DAV/2 mod_perl/2.0.8 Perl/v5.20.0
|
25
|
+
Access-Control-Allow-Origin:
|
26
|
+
- "*"
|
27
|
+
Accept-Ranges:
|
28
|
+
- none
|
29
|
+
Content-Type:
|
30
|
+
- application/json
|
31
|
+
Expires:
|
32
|
+
- Thu, 01 Jan 1970 00:00:00 GMT
|
33
|
+
Date:
|
34
|
+
- Sun, 12 Apr 2015 01:01:16 GMT
|
35
|
+
body:
|
36
|
+
string: "{\"exception\":\"invalid_parameter_exception\",\"errorcode\":\"invalidparameter\",\"message\":\"Invalid parameter value detected\"}"
|
37
|
+
http_version:
|
38
|
+
recorded_at: Sun, 12 Apr 2015 01:01:16 GMT
|
39
|
+
recorded_with: VCR 2.9.3
|
@@ -0,0 +1,39 @@
|
|
1
|
+
---
|
2
|
+
recorded_with: VCR 2.9.3
|
3
|
+
http_interactions:
|
4
|
+
- request:
|
5
|
+
method: post
|
6
|
+
uri: http://localhost:8888/moodle28/webservice/rest/server.php?moodlewsrestformat=json&wsfunction=core_user_delete_users&wstoken=60fc9c9415259404795094957e4ab32f
|
7
|
+
body:
|
8
|
+
string: userids[0]=5
|
9
|
+
headers: {}
|
10
|
+
|
11
|
+
response:
|
12
|
+
status:
|
13
|
+
code: 200
|
14
|
+
message: OK
|
15
|
+
headers:
|
16
|
+
Access-Control-Allow-Origin:
|
17
|
+
- "*"
|
18
|
+
Content-Type:
|
19
|
+
- application/json
|
20
|
+
Date:
|
21
|
+
- Sun, 12 Apr 2015 01:04:36 GMT
|
22
|
+
Content-Length:
|
23
|
+
- "4"
|
24
|
+
X-Powered-By:
|
25
|
+
- PHP/5.6.2
|
26
|
+
Accept-Ranges:
|
27
|
+
- none
|
28
|
+
Expires:
|
29
|
+
- Thu, 01 Jan 1970 00:00:00 GMT
|
30
|
+
Server:
|
31
|
+
- Apache/2.2.29 (Unix) mod_fastcgi/2.4.6 mod_wsgi/3.4 Python/2.7.8 PHP/5.6.2 mod_ssl/2.2.29 OpenSSL/0.9.8zd DAV/2 mod_perl/2.0.8 Perl/v5.20.0
|
32
|
+
Pragma:
|
33
|
+
- no-cache
|
34
|
+
Cache-Control:
|
35
|
+
- private, must-revalidate, pre-check=0, post-check=0, max-age=0
|
36
|
+
body:
|
37
|
+
string: "null"
|
38
|
+
http_version:
|
39
|
+
recorded_at: Sun, 12 Apr 2015 01:04:36 GMT
|
@@ -0,0 +1,39 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: post
|
5
|
+
uri: http://localhost:8888/moodle28/webservice/rest/server.php?moodlewsrestformat=json&wsfunction=core_user_delete_users&wstoken=60fc9c9415259404795094957e4ab32f
|
6
|
+
body:
|
7
|
+
string: userids[0]=999
|
8
|
+
headers: {}
|
9
|
+
|
10
|
+
response:
|
11
|
+
status:
|
12
|
+
code: 200
|
13
|
+
message: OK
|
14
|
+
headers:
|
15
|
+
Cache-Control:
|
16
|
+
- private, must-revalidate, pre-check=0, post-check=0, max-age=0
|
17
|
+
Content-Type:
|
18
|
+
- application/json
|
19
|
+
Access-Control-Allow-Origin:
|
20
|
+
- "*"
|
21
|
+
Pragma:
|
22
|
+
- no-cache
|
23
|
+
Expires:
|
24
|
+
- Thu, 01 Jan 1970 00:00:00 GMT
|
25
|
+
Accept-Ranges:
|
26
|
+
- none
|
27
|
+
Server:
|
28
|
+
- Apache/2.2.29 (Unix) mod_fastcgi/2.4.6 mod_wsgi/3.4 Python/2.7.8 PHP/5.6.2 mod_ssl/2.2.29 OpenSSL/0.9.8zd DAV/2 mod_perl/2.0.8 Perl/v5.20.0
|
29
|
+
X-Powered-By:
|
30
|
+
- PHP/5.6.2
|
31
|
+
Date:
|
32
|
+
- Sun, 12 Apr 2015 01:03:59 GMT
|
33
|
+
Content-Length:
|
34
|
+
- "95"
|
35
|
+
body:
|
36
|
+
string: "{\"exception\":\"dml_missing_record_exception\",\"errorcode\":\"invaliduser\",\"message\":\"Invalid user\"}"
|
37
|
+
http_version:
|
38
|
+
recorded_at: Sun, 12 Apr 2015 01:03:59 GMT
|
39
|
+
recorded_with: VCR 2.9.3
|
@@ -0,0 +1,39 @@
|
|
1
|
+
---
|
2
|
+
recorded_with: VCR 2.9.3
|
3
|
+
http_interactions:
|
4
|
+
- request:
|
5
|
+
method: post
|
6
|
+
uri: http://localhost:8888/moodle28/webservice/rest/server.php?moodlewsrestformat=json&wsfunction=core_enrol_get_users_courses&wstoken=60fc9c9415259404795094957e4ab32f
|
7
|
+
body:
|
8
|
+
string: userid=3
|
9
|
+
headers: {}
|
10
|
+
|
11
|
+
response:
|
12
|
+
status:
|
13
|
+
code: 200
|
14
|
+
message: OK
|
15
|
+
headers:
|
16
|
+
Accept-Ranges:
|
17
|
+
- none
|
18
|
+
Date:
|
19
|
+
- Sun, 12 Apr 2015 01:05:25 GMT
|
20
|
+
Cache-Control:
|
21
|
+
- private, must-revalidate, pre-check=0, post-check=0, max-age=0
|
22
|
+
Expires:
|
23
|
+
- Thu, 01 Jan 1970 00:00:00 GMT
|
24
|
+
Pragma:
|
25
|
+
- no-cache
|
26
|
+
X-Powered-By:
|
27
|
+
- PHP/5.6.2
|
28
|
+
Content-Type:
|
29
|
+
- application/json
|
30
|
+
Server:
|
31
|
+
- Apache/2.2.29 (Unix) mod_fastcgi/2.4.6 mod_wsgi/3.4 Python/2.7.8 PHP/5.6.2 mod_ssl/2.2.29 OpenSSL/0.9.8zd DAV/2 mod_perl/2.0.8 Perl/v5.20.0
|
32
|
+
Content-Length:
|
33
|
+
- "110"
|
34
|
+
Access-Control-Allow-Origin:
|
35
|
+
- "*"
|
36
|
+
body:
|
37
|
+
string: "[{\"id\":8,\"shortname\":\"TestC1\",\"fullname\":\"Test Course\",\"enrolledusercount\":1,\"idnumber\":\"ExtRef\",\"visible\":1}]"
|
38
|
+
http_version:
|
39
|
+
recorded_at: Sun, 12 Apr 2015 01:05:25 GMT
|
@@ -0,0 +1,39 @@
|
|
1
|
+
---
|
2
|
+
recorded_with: VCR 2.9.3
|
3
|
+
http_interactions:
|
4
|
+
- request:
|
5
|
+
method: post
|
6
|
+
uri: http://localhost:8888/moodle28/webservice/rest/server.php?moodlewsrestformat=json&wsfunction=core_user_get_users&wstoken=60fc9c9415259404795094957e4ab32f
|
7
|
+
body:
|
8
|
+
string: criteria[0][key]=id&criteria[0][value]=5
|
9
|
+
headers: {}
|
10
|
+
|
11
|
+
response:
|
12
|
+
status:
|
13
|
+
code: 200
|
14
|
+
message: OK
|
15
|
+
headers:
|
16
|
+
Server:
|
17
|
+
- Apache/2.2.29 (Unix) mod_fastcgi/2.4.6 mod_wsgi/3.4 Python/2.7.8 PHP/5.6.2 mod_ssl/2.2.29 OpenSSL/0.9.8zd DAV/2 mod_perl/2.0.8 Perl/v5.20.0
|
18
|
+
Pragma:
|
19
|
+
- no-cache
|
20
|
+
Date:
|
21
|
+
- Sun, 12 Apr 2015 01:01:44 GMT
|
22
|
+
Access-Control-Allow-Origin:
|
23
|
+
- "*"
|
24
|
+
Content-Length:
|
25
|
+
- "353"
|
26
|
+
X-Powered-By:
|
27
|
+
- PHP/5.6.2
|
28
|
+
Expires:
|
29
|
+
- Thu, 01 Jan 1970 00:00:00 GMT
|
30
|
+
Cache-Control:
|
31
|
+
- private, must-revalidate, pre-check=0, post-check=0, max-age=0
|
32
|
+
Content-Type:
|
33
|
+
- application/json
|
34
|
+
Accept-Ranges:
|
35
|
+
- none
|
36
|
+
body:
|
37
|
+
string: "{\"users\":[{\"id\":5,\"firstname\":\"Austin\",\"lastname\":\"Powers\",\"fullname\":\"Austin Powers\",\"email\":\"austinp1@jobready.com.au\",\"firstaccess\":0,\"lastaccess\":0,\"profileimageurlsmall\":\"http:\\/\\/localhost:8888\\/moodle28\\/pluginfile.php\\/69\\/user\\/icon\\/f2\",\"profileimageurl\":\"http:\\/\\/localhost:8888\\/moodle28\\/pluginfile.php\\/69\\/user\\/icon\\/f1\"}],\"warnings\":[]}"
|
38
|
+
http_version:
|
39
|
+
recorded_at: Sun, 12 Apr 2015 01:01:44 GMT
|
@@ -0,0 +1,74 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe MoodleRb::Categories do
|
4
|
+
let(:url) { ENV['MOODLE_URL'] || 'localhost' }
|
5
|
+
let(:token) { ENV['MOODLE_TOKEN'] || '' }
|
6
|
+
let(:category_moodle_rb) { MoodleRb.new(token, url).categories }
|
7
|
+
|
8
|
+
describe '#index', :vcr => {
|
9
|
+
:match_requests_on => [:body, :headers], :record => :once
|
10
|
+
} do
|
11
|
+
let(:result) { category_moodle_rb.index }
|
12
|
+
|
13
|
+
specify do
|
14
|
+
expect(result).to be_a Array
|
15
|
+
expect(result.first).to have_key 'id'
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
describe '#create', :vcr => {
|
20
|
+
:match_requests_on => [:headers], :record => :once
|
21
|
+
} do
|
22
|
+
let(:params) do
|
23
|
+
{
|
24
|
+
:name => 'Test category'
|
25
|
+
}
|
26
|
+
end
|
27
|
+
let(:result) { category_moodle_rb.create(params) }
|
28
|
+
|
29
|
+
specify do
|
30
|
+
expect(result).to be_a Hash
|
31
|
+
expect(result).to have_key 'id'
|
32
|
+
expect(result).to have_key 'name'
|
33
|
+
end
|
34
|
+
|
35
|
+
context 'when validation fails' do
|
36
|
+
let(:params) do
|
37
|
+
{
|
38
|
+
:name => 'Test category',
|
39
|
+
:idnumber => 'CAT101'
|
40
|
+
}
|
41
|
+
end
|
42
|
+
|
43
|
+
specify do
|
44
|
+
expect{ result }.to raise_error(
|
45
|
+
MoodleRb::MoodleError,
|
46
|
+
'ID number is already used for another category'
|
47
|
+
)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
describe '#show', :vcr => {
|
53
|
+
:match_requests_on => [:headers], :record => :once
|
54
|
+
} do
|
55
|
+
let(:id) { 1 }
|
56
|
+
let(:result) { category_moodle_rb.show(id) }
|
57
|
+
|
58
|
+
specify do
|
59
|
+
expect(result).to be_a Hash
|
60
|
+
expect(result['id']).to eq 1
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
describe '#destroy', :vcr => {
|
65
|
+
:match_requests_on => [:headers], :record => :once
|
66
|
+
} do
|
67
|
+
let!(:id) { category_moodle_rb.create(:name => '_')['id'] }
|
68
|
+
let(:result) { category_moodle_rb.destroy(id) }
|
69
|
+
|
70
|
+
specify do
|
71
|
+
expect(result).to eq true
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe MoodleRb::Client do
|
4
|
+
let(:url) { ENV['MOODLE_URL'] || 'localhost' }
|
5
|
+
let(:token) { ENV['MOODLE_TOKEN'] || '' }
|
6
|
+
let(:moodle_rb) { MoodleRb.new(token, url) }
|
7
|
+
|
8
|
+
describe '#site_info', :vcr => {
|
9
|
+
:match_requests_on => [:body, :headers], :record => :once
|
10
|
+
} do
|
11
|
+
let(:result) { moodle_rb.site_info }
|
12
|
+
|
13
|
+
context 'when invalid token' do
|
14
|
+
let(:token) { 'invalid_moodle_rb_token' }
|
15
|
+
|
16
|
+
specify do
|
17
|
+
expect(result).to be_a Hash
|
18
|
+
expect(result['errorcode']).to eq 'invalidtoken'
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
context 'when valid token' do
|
23
|
+
specify do
|
24
|
+
expect(result).to be_a Hash
|
25
|
+
expect(result['release']).to eq '2.8.5+ (Build: 20150313)'
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
describe '#courses' do
|
31
|
+
specify { expect(moodle_rb.courses).to be_a MoodleRb::Courses }
|
32
|
+
end
|
33
|
+
|
34
|
+
describe '#categories' do
|
35
|
+
specify { expect(moodle_rb.categories).to be_a MoodleRb::Categories }
|
36
|
+
end
|
37
|
+
|
38
|
+
describe '#users' do
|
39
|
+
specify { expect(moodle_rb.users).to be_a MoodleRb::Users }
|
40
|
+
end
|
41
|
+
|
42
|
+
describe '#enrolments' do
|
43
|
+
specify { expect(moodle_rb.enrolments).to be_a MoodleRb::Enrolments }
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,92 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe MoodleRb::Courses do
|
4
|
+
let(:url) { ENV['MOODLE_URL'] || 'localhost' }
|
5
|
+
let(:token) { ENV['MOODLE_TOKEN'] || '' }
|
6
|
+
let(:course_moodle_rb) { MoodleRb.new(token, url).courses }
|
7
|
+
let(:params) do
|
8
|
+
{
|
9
|
+
:full_name => 'Test Course',
|
10
|
+
:short_name => 'TestC1',
|
11
|
+
:parent_category => 1,
|
12
|
+
:idnumber => 'ExtRef'
|
13
|
+
}
|
14
|
+
end
|
15
|
+
|
16
|
+
describe '#index', :vcr => {
|
17
|
+
:match_requests_on => [:body, :headers], :record => :once
|
18
|
+
} do
|
19
|
+
let(:result) { course_moodle_rb.index }
|
20
|
+
|
21
|
+
specify do
|
22
|
+
expect(result).to be_a Array
|
23
|
+
expect(result.first).to have_key 'id'
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
describe '#create', :vcr => {
|
28
|
+
:match_requests_on => [:headers], :record => :once
|
29
|
+
} do
|
30
|
+
let(:result) { course_moodle_rb.create(params) }
|
31
|
+
|
32
|
+
specify do
|
33
|
+
expect(result).to be_a Hash
|
34
|
+
expect(result).to have_key 'id'
|
35
|
+
expect(result).to have_key 'shortname'
|
36
|
+
end
|
37
|
+
|
38
|
+
context 'when validation fails' do
|
39
|
+
before do
|
40
|
+
course_moodle_rb.create(params)
|
41
|
+
end
|
42
|
+
|
43
|
+
specify do
|
44
|
+
expect{ result }.to raise_error(
|
45
|
+
MoodleRb::MoodleError,
|
46
|
+
'Short name is already used for another course (TestC1)'
|
47
|
+
)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
describe '#show', :vcr => {
|
53
|
+
:match_requests_on => [:headers], :record => :once
|
54
|
+
} do
|
55
|
+
let(:id) { 1 }
|
56
|
+
let(:result) { course_moodle_rb.show(id) }
|
57
|
+
|
58
|
+
specify do
|
59
|
+
expect(result).to be_a Hash
|
60
|
+
expect(result['id']).to eq 1
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
describe '#destroy', :vcr => {
|
65
|
+
:match_requests_on => [:headers], :record => :once
|
66
|
+
} do
|
67
|
+
let(:id) { course_moodle_rb.create(params)['id'] }
|
68
|
+
let(:result) { course_moodle_rb.destroy(id) }
|
69
|
+
|
70
|
+
specify do
|
71
|
+
expect(result).to eq true
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
describe '#enrolled_users', :vcr => {
|
76
|
+
:match_requests_on => [:headers], :record => :once
|
77
|
+
} do
|
78
|
+
let(:course_id) { 8 }
|
79
|
+
let!(:enrolled_user) do
|
80
|
+
MoodleRb.new(token, url).enrolments.create(
|
81
|
+
:user_id => 3, :course_id => course_id)
|
82
|
+
end
|
83
|
+
let(:result) { course_moodle_rb.enrolled_users(course_id) }
|
84
|
+
let(:enrolment) { result.first }
|
85
|
+
|
86
|
+
specify do
|
87
|
+
expect(result).to be_a Array
|
88
|
+
expect(enrolment).to have_key 'id'
|
89
|
+
expect(enrolment).to have_key 'enrolledcourses'
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|