ruby-d2l 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/Gemfile +15 -0
- data/Gemfile.lock +41 -0
- data/LICENSE.txt +20 -0
- data/README.rdoc +44 -0
- data/Rakefile +53 -0
- data/VERSION +1 -0
- data/lib/ruby-d2l/auth.rb +52 -0
- data/lib/ruby-d2l/config.rb +17 -0
- data/lib/ruby-d2l/grades.rb +4 -0
- data/lib/ruby-d2l/org_unit.rb +241 -0
- data/lib/ruby-d2l/user.rb +86 -0
- data/lib/ruby-d2l.rb +17 -0
- data/ruby-d2l.gemspec +68 -0
- data/test/helper.rb +18 -0
- data/test/test_ruby-d2l.rb +7 -0
- metadata +149 -0
data/.document
ADDED
data/Gemfile
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
source "http://rubygems.org"
|
2
|
+
# Add dependencies required to use your gem here.
|
3
|
+
# Example:
|
4
|
+
# gem "activesupport", ">= 2.3.5"
|
5
|
+
|
6
|
+
gem "savon", ">= 0"
|
7
|
+
|
8
|
+
# Add dependencies to develop your gem here.
|
9
|
+
# Include everything needed to run rake, tests, features, etc.
|
10
|
+
group :development do
|
11
|
+
gem "shoulda", ">= 0"
|
12
|
+
gem "bundler", "~> 1.0.0"
|
13
|
+
gem "jeweler", "~> 1.6.4"
|
14
|
+
gem "rcov", ">= 0"
|
15
|
+
end
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
GEM
|
2
|
+
remote: http://rubygems.org/
|
3
|
+
specs:
|
4
|
+
akami (1.0.0)
|
5
|
+
gyoku (>= 0.4.0)
|
6
|
+
builder (3.0.0)
|
7
|
+
git (1.2.5)
|
8
|
+
gyoku (0.4.4)
|
9
|
+
builder (>= 2.1.2)
|
10
|
+
httpi (0.9.5)
|
11
|
+
rack
|
12
|
+
jeweler (1.6.4)
|
13
|
+
bundler (~> 1.0)
|
14
|
+
git (>= 1.2.5)
|
15
|
+
rake
|
16
|
+
nokogiri (1.5.0)
|
17
|
+
nori (1.0.2)
|
18
|
+
rack (1.3.0)
|
19
|
+
rake (0.9.2.2)
|
20
|
+
rcov (0.9.11)
|
21
|
+
savon (0.9.7)
|
22
|
+
akami (~> 1.0)
|
23
|
+
builder (>= 2.1.2)
|
24
|
+
gyoku (>= 0.4.0)
|
25
|
+
httpi (~> 0.9)
|
26
|
+
nokogiri (>= 1.4.0)
|
27
|
+
nori (~> 1.0)
|
28
|
+
wasabi (~> 2.0)
|
29
|
+
shoulda (2.11.3)
|
30
|
+
wasabi (2.0.0)
|
31
|
+
nokogiri (>= 1.4.0)
|
32
|
+
|
33
|
+
PLATFORMS
|
34
|
+
ruby
|
35
|
+
|
36
|
+
DEPENDENCIES
|
37
|
+
bundler (~> 1.0.0)
|
38
|
+
jeweler (~> 1.6.4)
|
39
|
+
rcov
|
40
|
+
savon
|
41
|
+
shoulda
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2011 Matt Mencel
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
= ruby-d2l
|
2
|
+
|
3
|
+
Description goes here.
|
4
|
+
|
5
|
+
== Installation
|
6
|
+
|
7
|
+
gem install ruby-d2l
|
8
|
+
|
9
|
+
|
10
|
+
== Configuration
|
11
|
+
|
12
|
+
Create a user in your Desire2Learn instance for web services. It should have administrator privileges.
|
13
|
+
|
14
|
+
Then in your Ruby application you can use the configure block to set these values...
|
15
|
+
|
16
|
+
RubyD2L.configure do |config|
|
17
|
+
config.username = "D2L_WEB_SERVICES_USERNAME"
|
18
|
+
config.password = "D2L_WEB_SERVICES_PASSWORD"
|
19
|
+
config.site_url = "D2L_INSTANCE_URL" (e.g. https://d2l.mysite.edu)
|
20
|
+
end
|
21
|
+
|
22
|
+
== Documentation
|
23
|
+
|
24
|
+
Code Example:
|
25
|
+
|
26
|
+
template = RubyD2L::OrgUnit.get_course_template_by_code("TEMPLATE_CODE").to_hash
|
27
|
+
ap template[:get_course_template_response][:course_template][:name].to_s
|
28
|
+
|
29
|
+
|
30
|
+
== Contributing to ruby-d2l
|
31
|
+
|
32
|
+
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
|
33
|
+
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
|
34
|
+
* Fork the project
|
35
|
+
* Start a feature/bugfix branch
|
36
|
+
* Commit and push until you are happy with your contribution
|
37
|
+
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
38
|
+
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
|
39
|
+
|
40
|
+
== Copyright
|
41
|
+
|
42
|
+
Copyright (c) 2011 Matt Mencel. See LICENSE.txt for
|
43
|
+
further details.
|
44
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'bundler'
|
5
|
+
begin
|
6
|
+
Bundler.setup(:default, :development)
|
7
|
+
rescue Bundler::BundlerError => e
|
8
|
+
$stderr.puts e.message
|
9
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
10
|
+
exit e.status_code
|
11
|
+
end
|
12
|
+
require 'rake'
|
13
|
+
|
14
|
+
require 'jeweler'
|
15
|
+
Jeweler::Tasks.new do |gem|
|
16
|
+
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
17
|
+
gem.name = "ruby-d2l"
|
18
|
+
gem.homepage = "http://github.com/chewie71/ruby-d2l"
|
19
|
+
gem.license = "MIT"
|
20
|
+
gem.summary = "Desire2Learn Ruby SOAP Client"
|
21
|
+
gem.description = "A Ruby SOAP client for accessing Desire2Learn Web Services (D2LWS)"
|
22
|
+
gem.email = "mr-mencel@wiu.edu"
|
23
|
+
gem.authors = ["Matt Mencel"]
|
24
|
+
# dependencies defined in Gemfile
|
25
|
+
end
|
26
|
+
Jeweler::RubygemsDotOrgTasks.new
|
27
|
+
|
28
|
+
require 'rake/testtask'
|
29
|
+
Rake::TestTask.new(:test) do |test|
|
30
|
+
test.libs << 'lib' << 'test'
|
31
|
+
test.pattern = 'test/**/test_*.rb'
|
32
|
+
test.verbose = true
|
33
|
+
end
|
34
|
+
|
35
|
+
require 'rcov/rcovtask'
|
36
|
+
Rcov::RcovTask.new do |test|
|
37
|
+
test.libs << 'test'
|
38
|
+
test.pattern = 'test/**/test_*.rb'
|
39
|
+
test.verbose = true
|
40
|
+
test.rcov_opts << '--exclude "gems/*"'
|
41
|
+
end
|
42
|
+
|
43
|
+
task :default => :test
|
44
|
+
|
45
|
+
require 'rake/rdoctask'
|
46
|
+
Rake::RDocTask.new do |rdoc|
|
47
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
48
|
+
|
49
|
+
rdoc.rdoc_dir = 'rdoc'
|
50
|
+
rdoc.title = "ruby-d2l #{version}"
|
51
|
+
rdoc.rdoc_files.include('README*')
|
52
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
53
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.2.0
|
@@ -0,0 +1,52 @@
|
|
1
|
+
require "savon"
|
2
|
+
|
3
|
+
module RubyD2L
|
4
|
+
class Auth
|
5
|
+
|
6
|
+
def self.connect(site_url)
|
7
|
+
Savon::Client.new do
|
8
|
+
ap site_url
|
9
|
+
wsdl.document = "#{site_url}/d2l/AuthenticationTokenService.asmx?WSDL"
|
10
|
+
wsdl.endpoint = "#{site_url}/d2l/AuthenticationTokenService.asmx"
|
11
|
+
#http.proxy = @@proxy_server if @@proxy_server != nil
|
12
|
+
http.auth.ssl.verify_mode = :none
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def list_soap_actions(params)
|
17
|
+
site_url = params[0]
|
18
|
+
# Get available SOAP actions
|
19
|
+
ap connect(site_url).wsdl.soap_actions
|
20
|
+
|
21
|
+
# [
|
22
|
+
# [0] :authenticate,
|
23
|
+
# [1] :authenticate2,
|
24
|
+
# [2] :authenticate_with_app_token
|
25
|
+
# ]
|
26
|
+
|
27
|
+
end
|
28
|
+
|
29
|
+
|
30
|
+
def self.get_token
|
31
|
+
username = RubyD2L.username
|
32
|
+
password = RubyD2L.password
|
33
|
+
# RETURNS THE AUTH TOKEN
|
34
|
+
response = self.connect(RubyD2L.site_url).request :authenticate do
|
35
|
+
soap.xml = '<?xml version="1.0" encoding="utf-8"?>
|
36
|
+
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
|
37
|
+
<soap:Body>
|
38
|
+
<AuthenticateRequest xmlns="http://desire2learn.com/security/token/2007/08">
|
39
|
+
<username>'+ username +'</username>
|
40
|
+
<password>'+ password +'</password>
|
41
|
+
<purpose>Web Service</purpose>
|
42
|
+
</AuthenticateRequest>
|
43
|
+
</soap:Body>
|
44
|
+
</soap:Envelope>'
|
45
|
+
end
|
46
|
+
token = response.to_hash[:authenticate_response][:token]
|
47
|
+
|
48
|
+
end
|
49
|
+
|
50
|
+
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,241 @@
|
|
1
|
+
module RubyD2L
|
2
|
+
|
3
|
+
class OrgUnit
|
4
|
+
def self.connect(site_url)
|
5
|
+
Savon::Client.new do
|
6
|
+
wsdl.document = "#{site_url}/D2LWS/OrgUnitManagementService-v1.asmx?WSDL"
|
7
|
+
wsdl.endpoint = "#{site_url}/D2LWS/OrgUnitManagementService-v1.asmx"
|
8
|
+
#http.proxy = @@proxy_server if @@proxy_server != nil
|
9
|
+
http.auth.ssl.verify_mode = :none
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.list_soap_actions(params)
|
14
|
+
# Get available SOAP actions
|
15
|
+
|
16
|
+
site_url = params[0]
|
17
|
+
ap connect(site_url).wsdl.soap_actions
|
18
|
+
|
19
|
+
# [
|
20
|
+
# [ 0] :link_course_offering_to_navbar,
|
21
|
+
# [ 1] :link_course_offering_to_homepage,
|
22
|
+
# [ 2] :set_course_offering_colors,
|
23
|
+
# [ 3] :configure_course_offering_appearance,
|
24
|
+
# [ 4] :get_child_org_units,
|
25
|
+
# [ 5] :get_organization,
|
26
|
+
# [ 6] :get_system_org_unit_types,
|
27
|
+
# [ 7] :get_custom_org_unit_types,
|
28
|
+
# [ 8] :create_custom_org_unit_type,
|
29
|
+
# [ 9] :get_custom_org_unit_type,
|
30
|
+
# [10] :update_custom_org_unit_type,
|
31
|
+
# [11] :delete_custom_org_unit_type,
|
32
|
+
# [12] :create_custom_org_unit,
|
33
|
+
# [13] :get_custom_org_unit,
|
34
|
+
# [14] :get_custom_org_unit_by_code,
|
35
|
+
# [15] :update_custom_org_unit,
|
36
|
+
# [16] :delete_custom_org_unit,
|
37
|
+
# [17] :get_department_org_unit_type,
|
38
|
+
# [18] :create_department,
|
39
|
+
# [19] :get_department,
|
40
|
+
# [20] :get_department_by_code,
|
41
|
+
# [21] :update_department,
|
42
|
+
# [22] :delete_department,
|
43
|
+
# [23] :get_semester_org_unit_type,
|
44
|
+
# [24] :create_semester,
|
45
|
+
# [25] :get_semester,
|
46
|
+
# [26] :get_semester_by_code,
|
47
|
+
# [27] :update_semester,
|
48
|
+
# [28] :delete_semester,
|
49
|
+
# [29] :create_course_template,
|
50
|
+
# [30] :get_course_template,
|
51
|
+
# [31] :get_course_template_by_code,
|
52
|
+
# [32] :update_course_template,
|
53
|
+
# [33] :delete_course_template,
|
54
|
+
# [34] :create_course_offering,
|
55
|
+
# [35] :get_course_offering,
|
56
|
+
# [36] :get_course_offering_by_code,
|
57
|
+
# [37] :update_course_offering,
|
58
|
+
# [38] :delete_course_offering,
|
59
|
+
# [39] :get_group_types,
|
60
|
+
# [40] :get_group_type,
|
61
|
+
# [41] :create_group_type,
|
62
|
+
# [42] :update_group_type,
|
63
|
+
# [43] :delete_group_type,
|
64
|
+
# [44] :create_group,
|
65
|
+
# [45] :get_group,
|
66
|
+
# [46] :get_group_by_code,
|
67
|
+
# [47] :update_group,
|
68
|
+
# [48] :delete_group,
|
69
|
+
# [49] :create_section,
|
70
|
+
# [50] :get_section,
|
71
|
+
# [51] :get_section_by_code,
|
72
|
+
# [52] :update_section,
|
73
|
+
# [53] :delete_section,
|
74
|
+
# [54] :add_child_org_unit,
|
75
|
+
# [55] :remove_child_org_unit,
|
76
|
+
# [56] :get_child_org_unit_type_ids,
|
77
|
+
# [57] :get_child_org_unit_ids,
|
78
|
+
# [58] :get_parent_org_unit_ids,
|
79
|
+
# [59] :get_child_groups,
|
80
|
+
# [60] :get_child_groups_by_type,
|
81
|
+
# [61] :get_child_sections,
|
82
|
+
# [62] :get_child_course_offerings,
|
83
|
+
# [63] :get_child_course_templates,
|
84
|
+
# [64] :get_child_departments,
|
85
|
+
# [65] :get_child_semesters,
|
86
|
+
# [66] :get_child_custom_org_units,
|
87
|
+
# [67] :get_child_custom_org_units_by_type
|
88
|
+
# ]
|
89
|
+
end
|
90
|
+
|
91
|
+
def self.create_course_offering(params)
|
92
|
+
|
93
|
+
# I don't use <Path>'+ @course_path +'</Path>. Add it if you need it.
|
94
|
+
|
95
|
+
@course_name = ""
|
96
|
+
@course_code = ""
|
97
|
+
@course_path = ""
|
98
|
+
@template_id = ""
|
99
|
+
@is_active = "false"
|
100
|
+
@start_date = DateTime.now.to_s
|
101
|
+
@end_date = DateTime.now.to_s
|
102
|
+
@can_register = "false"
|
103
|
+
@allow_sections = "false"
|
104
|
+
|
105
|
+
site_url = params[0]
|
106
|
+
token = params[1]
|
107
|
+
if params[2] == nil || params[2] == "list_params"
|
108
|
+
ap "REQUIRED: [course_name, course_code, template_id]"
|
109
|
+
ap "OPTIONAL: [is_active(T/F), start_date (2011-12-12T00:00:00), end_date, can_register(T/F), allow_sections(T/F)]"
|
110
|
+
ap "Must be comma separated with no spaces. (e.g. -p course_name=CS100,course_code=123,is_active=false)"
|
111
|
+
exit
|
112
|
+
else
|
113
|
+
params[2].split(',').each do |values|
|
114
|
+
vals = values.split('=')
|
115
|
+
instance_variable_set("@#{vals[0]}", vals[1])
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
the_xml = '<?xml version="1.0" encoding="utf-8"?>
|
120
|
+
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
|
121
|
+
<soap:Header>
|
122
|
+
<RequestHeader xmlns="http://www.desire2learn.com/services/common/xsd/common-v1_0">
|
123
|
+
<Version>1.0</Version>
|
124
|
+
<CorellationId>12345</CorellationId>
|
125
|
+
<AuthenticationToken>'+ token +'</AuthenticationToken>
|
126
|
+
</RequestHeader>
|
127
|
+
</soap:Header>
|
128
|
+
<soap:Body>
|
129
|
+
<CreateCourseOfferingRequest xmlns="http://www.desire2learn.com/services/oums/wsdl/OrgUnitManagementService-v1_0">
|
130
|
+
<Name>'+ @course_name +'</Name>
|
131
|
+
<Code>'+ @course_code +'</Code>
|
132
|
+
<TemplateId>
|
133
|
+
<Id xmlns="http://www.desire2learn.com/services/common/xsd/common-v1_0">'+ @template_id +'</Id>
|
134
|
+
<Source xmlns="http://www.desire2learn.com/services/common/xsd/common-v1_0">Desire2Learn</Source>
|
135
|
+
</TemplateId>
|
136
|
+
<IsActive>'+ @is_active +'</IsActive>
|
137
|
+
<StartDate>'+ @start_date +'</StartDate>
|
138
|
+
<EndDate>'+ @end_date +'</EndDate>
|
139
|
+
<CanRegister>'+ @can_register +'</CanRegister>
|
140
|
+
<AllowSections>'+ @allow_sections +'</AllowSections>
|
141
|
+
</CreateCourseOfferingRequest>
|
142
|
+
</soap:Body>
|
143
|
+
</soap:Envelope>'
|
144
|
+
|
145
|
+
orgunit = connect(site_url).request :create_course_offering do
|
146
|
+
soap.xml = the_xml
|
147
|
+
end
|
148
|
+
|
149
|
+
end
|
150
|
+
|
151
|
+
def self.create_course_template(params)
|
152
|
+
|
153
|
+
# I don't use <Path>'+ @template_path +'</Path>. Add it if you need it.
|
154
|
+
|
155
|
+
@template_name = ""
|
156
|
+
@template_code = ""
|
157
|
+
@is_active = "false"
|
158
|
+
@start_date = DateTime.now.to_s
|
159
|
+
@end_date = DateTime.now.to_s
|
160
|
+
|
161
|
+
site_url = params[0]
|
162
|
+
token = params[1]
|
163
|
+
if params[2] == nil || params[2] == "list_params"
|
164
|
+
ap "REQUIRED: [template_name, template_code]"
|
165
|
+
ap "OPTIONAL: [is_active(true/false), start_date(YYYY-MM-DDThh:mm:ss), end_date(YYYY-MM-DDThh:mm:ss)]"
|
166
|
+
ap "Must be comma separated with no spaces. (e.g. -p template_name=CS100,template_code=123,is_active=false)"
|
167
|
+
exit
|
168
|
+
else
|
169
|
+
params[2].split(',').each do |values|
|
170
|
+
vals = values.split('=')
|
171
|
+
instance_variable_set("@#{vals[0]}", vals[1])
|
172
|
+
end
|
173
|
+
end
|
174
|
+
|
175
|
+
the_xml = '<?xml version="1.0" encoding="utf-8"?>
|
176
|
+
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
|
177
|
+
<soap:Header>
|
178
|
+
<RequestHeader xmlns="http://www.desire2learn.com/services/common/xsd/common-v1_0">
|
179
|
+
<Version>1.0</Version>
|
180
|
+
<CorellationId>12345</CorellationId>
|
181
|
+
<AuthenticationToken>'+ token +'</AuthenticationToken>
|
182
|
+
</RequestHeader>
|
183
|
+
</soap:Header>
|
184
|
+
<soap:Body>
|
185
|
+
<CreateCourseTemplateRequest xmlns="http://www.desire2learn.com/services/oums/wsdl/OrgUnitManagementService-v1_0">
|
186
|
+
<Name>'+ @template_name +'</Name>
|
187
|
+
<Code>'+ @template_code +'</Code>
|
188
|
+
<IsActive>'+ @is_active +'</IsActive>
|
189
|
+
<StartDate>'+ @start_date +'</StartDate>
|
190
|
+
<EndDate>'+ @end_date +'</EndDate>
|
191
|
+
</CreateCourseTemplateRequest>
|
192
|
+
</soap:Body>
|
193
|
+
</soap:Envelope>'
|
194
|
+
|
195
|
+
template = connect(site_url).request :create_course_template do
|
196
|
+
soap.xml = the_xml
|
197
|
+
end
|
198
|
+
|
199
|
+
|
200
|
+
end
|
201
|
+
|
202
|
+
def self.get_course_template_by_code(template_code)
|
203
|
+
|
204
|
+
# @template_code = ""
|
205
|
+
token = RubyD2L::Auth.get_token
|
206
|
+
|
207
|
+
# site_url = params[0]
|
208
|
+
# token = params[1]
|
209
|
+
# if params[2] == nil || params[2] == "list_params"
|
210
|
+
# ap "REQUIRED: [template_code]"
|
211
|
+
# exit
|
212
|
+
# else
|
213
|
+
# params[2].split(',').each do |values|
|
214
|
+
# vals = values.split('=')
|
215
|
+
# instance_variable_set("@#{vals[0]}", vals[1])
|
216
|
+
# end
|
217
|
+
# end
|
218
|
+
|
219
|
+
the_xml = '<?xml version="1.0" encoding="utf-8"?>
|
220
|
+
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
|
221
|
+
<soap:Header>
|
222
|
+
<RequestHeader xmlns="http://www.desire2learn.com/services/common/xsd/common-v1_0">
|
223
|
+
<Version>1.0</Version>
|
224
|
+
<CorellationId>12345</CorellationId>
|
225
|
+
<AuthenticationToken>'+ token +'</AuthenticationToken>
|
226
|
+
</RequestHeader>
|
227
|
+
</soap:Header>
|
228
|
+
<soap:Body>
|
229
|
+
<GetCourseTemplateByCodeRequest xmlns="http://www.desire2learn.com/services/oums/wsdl/OrgUnitManagementService-v1_0">
|
230
|
+
<Code>'+ template_code +'</Code>
|
231
|
+
</GetCourseTemplateByCodeRequest>
|
232
|
+
</soap:Body>
|
233
|
+
</soap:Envelope>'
|
234
|
+
|
235
|
+
template = self.connect(RubyD2L.site_url).request :get_course_template_by_code do
|
236
|
+
soap.xml = the_xml
|
237
|
+
end
|
238
|
+
|
239
|
+
end
|
240
|
+
end
|
241
|
+
end
|
@@ -0,0 +1,86 @@
|
|
1
|
+
class User
|
2
|
+
|
3
|
+
def self.connect(site_url)
|
4
|
+
Savon::Client.new do
|
5
|
+
wsdl.document = "#{site_url}/D2LWS/UserManagementService-v1.asmx?WSDL"
|
6
|
+
wsdl.endpoint = "#{site_url}/D2LWS/UserManagementService-v1.asmx"
|
7
|
+
http.proxy = @@proxy_server if @@proxy_server != nil
|
8
|
+
http.auth.ssl.verify_mode = :none
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.list_soap_actions(params)
|
13
|
+
# Get available SOAP actions
|
14
|
+
|
15
|
+
site_url = params[0]
|
16
|
+
ap connect(site_url).wsdl.soap_actions
|
17
|
+
|
18
|
+
# [
|
19
|
+
# [ 0] :get_active_course_offerings_ex,
|
20
|
+
# [ 1] :get_active_course_offerings,
|
21
|
+
# [ 2] :activate_users,
|
22
|
+
# [ 3] :deactivate_users,
|
23
|
+
# [ 4] :get_user_activation_status,
|
24
|
+
# [ 5] :create_auditor_relationship,
|
25
|
+
# [ 6] :remove_auditor_relationship,
|
26
|
+
# [ 7] :get_auditors,
|
27
|
+
# [ 8] :get_auditees,
|
28
|
+
# [ 9] :get_users_by_org_unit_role,
|
29
|
+
# [10] :create_user,
|
30
|
+
# [11] :delete_user,
|
31
|
+
# [12] :get_user,
|
32
|
+
# [13] :update_user,
|
33
|
+
# [14] :delete_user_by_user_name,
|
34
|
+
# [15] :delete_user_by_org_defined_id,
|
35
|
+
# [16] :get_user_by_user_name,
|
36
|
+
# [17] :get_user_by_org_defined_id,
|
37
|
+
# [18] :get_roles,
|
38
|
+
# [19] :get_role,
|
39
|
+
# [20] :change_password,
|
40
|
+
# [21] :enroll_user,
|
41
|
+
# [22] :unenroll_user,
|
42
|
+
# [23] :get_org_unit_enrollment,
|
43
|
+
# [24] :get_enrollments_by_org_unit,
|
44
|
+
# [25] :get_profile_by_user,
|
45
|
+
# [26] :get_profile_picture,
|
46
|
+
# [27] :update_profile,
|
47
|
+
# [28] :get_users_by_group,
|
48
|
+
# [29] :get_users_by_section,
|
49
|
+
# [30] :get_users_by_course_offerings_index,
|
50
|
+
# [31] :get_permitted_tasks_by_user_org_unit
|
51
|
+
# ]
|
52
|
+
|
53
|
+
end
|
54
|
+
|
55
|
+
|
56
|
+
def self.get_user_by_user_name(params)
|
57
|
+
site_url = params[0]
|
58
|
+
token = params[1]
|
59
|
+
if params[2] == nil || params[2] == "list_params"
|
60
|
+
ap "[user_name] param required by get_user_by_user_name!"
|
61
|
+
exit
|
62
|
+
else
|
63
|
+
user_name = params[2]
|
64
|
+
end
|
65
|
+
|
66
|
+
user = connect(site_url).request :get_user_by_user_name do
|
67
|
+
soap.xml = '<?xml version="1.0" encoding="utf-8"?>
|
68
|
+
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
|
69
|
+
<soap:Header>
|
70
|
+
<RequestHeader xmlns="http://www.desire2learn.com/services/common/xsd/common-v1_0">
|
71
|
+
<Version>1.0</Version>
|
72
|
+
<CorellationId>12345</CorellationId>
|
73
|
+
<AuthenticationToken>'+ token +'</AuthenticationToken>
|
74
|
+
</RequestHeader>
|
75
|
+
</soap:Header>
|
76
|
+
<soap:Body>
|
77
|
+
<GetUserByUserNameRequest xmlns="http://www.desire2learn.com/services/ums/wsdl/UserManagementService-v1_0">
|
78
|
+
<UserName>'+ user_name +'</UserName>
|
79
|
+
</GetUserByUserNameRequest>
|
80
|
+
</soap:Body>
|
81
|
+
</soap:Envelope>'
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
|
86
|
+
end
|
data/lib/ruby-d2l.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
require "ruby-d2l/auth"
|
2
|
+
require "ruby-d2l/config"
|
3
|
+
require "ruby-d2l/grades"
|
4
|
+
require "ruby-d2l/org_unit"
|
5
|
+
require "ruby-d2l/user"
|
6
|
+
|
7
|
+
|
8
|
+
module RubyD2L
|
9
|
+
extend Config
|
10
|
+
|
11
|
+
# Yields this module to a given +block+. Please refer to the
|
12
|
+
# <tt>RubyD2L::Config</tt> module for configuration options.
|
13
|
+
def self.configure
|
14
|
+
yield self if block_given?
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
data/ruby-d2l.gemspec
ADDED
@@ -0,0 +1,68 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{ruby-d2l}
|
8
|
+
s.version = "0.2.0"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Matt Mencel"]
|
12
|
+
s.date = %q{2011-12-13}
|
13
|
+
s.description = %q{A Ruby SOAP client for accessing Desire2Learn Web Services (D2LWS)}
|
14
|
+
s.email = %q{mr-mencel@wiu.edu}
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"LICENSE.txt",
|
17
|
+
"README.rdoc"
|
18
|
+
]
|
19
|
+
s.files = [
|
20
|
+
".document",
|
21
|
+
"Gemfile",
|
22
|
+
"Gemfile.lock",
|
23
|
+
"LICENSE.txt",
|
24
|
+
"README.rdoc",
|
25
|
+
"Rakefile",
|
26
|
+
"VERSION",
|
27
|
+
"lib/ruby-d2l.rb",
|
28
|
+
"lib/ruby-d2l/auth.rb",
|
29
|
+
"lib/ruby-d2l/config.rb",
|
30
|
+
"lib/ruby-d2l/grades.rb",
|
31
|
+
"lib/ruby-d2l/org_unit.rb",
|
32
|
+
"lib/ruby-d2l/user.rb",
|
33
|
+
"ruby-d2l.gemspec",
|
34
|
+
"test/helper.rb",
|
35
|
+
"test/test_ruby-d2l.rb"
|
36
|
+
]
|
37
|
+
s.homepage = %q{http://github.com/chewie71/ruby-d2l}
|
38
|
+
s.licenses = ["MIT"]
|
39
|
+
s.require_paths = ["lib"]
|
40
|
+
s.rubygems_version = %q{1.3.7}
|
41
|
+
s.summary = %q{Desire2Learn Ruby SOAP Client}
|
42
|
+
|
43
|
+
if s.respond_to? :specification_version then
|
44
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
45
|
+
s.specification_version = 3
|
46
|
+
|
47
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
48
|
+
s.add_runtime_dependency(%q<savon>, [">= 0"])
|
49
|
+
s.add_development_dependency(%q<shoulda>, [">= 0"])
|
50
|
+
s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
|
51
|
+
s.add_development_dependency(%q<jeweler>, ["~> 1.6.4"])
|
52
|
+
s.add_development_dependency(%q<rcov>, [">= 0"])
|
53
|
+
else
|
54
|
+
s.add_dependency(%q<savon>, [">= 0"])
|
55
|
+
s.add_dependency(%q<shoulda>, [">= 0"])
|
56
|
+
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
57
|
+
s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
|
58
|
+
s.add_dependency(%q<rcov>, [">= 0"])
|
59
|
+
end
|
60
|
+
else
|
61
|
+
s.add_dependency(%q<savon>, [">= 0"])
|
62
|
+
s.add_dependency(%q<shoulda>, [">= 0"])
|
63
|
+
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
64
|
+
s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
|
65
|
+
s.add_dependency(%q<rcov>, [">= 0"])
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
data/test/helper.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler'
|
3
|
+
begin
|
4
|
+
Bundler.setup(:default, :development)
|
5
|
+
rescue Bundler::BundlerError => e
|
6
|
+
$stderr.puts e.message
|
7
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
8
|
+
exit e.status_code
|
9
|
+
end
|
10
|
+
require 'test/unit'
|
11
|
+
require 'shoulda'
|
12
|
+
|
13
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
14
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
15
|
+
require 'ruby-d2l'
|
16
|
+
|
17
|
+
class Test::Unit::TestCase
|
18
|
+
end
|
metadata
ADDED
@@ -0,0 +1,149 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ruby-d2l
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 2
|
8
|
+
- 0
|
9
|
+
version: 0.2.0
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- Matt Mencel
|
13
|
+
autorequire:
|
14
|
+
bindir: bin
|
15
|
+
cert_chain: []
|
16
|
+
|
17
|
+
date: 2011-12-13 00:00:00 -06:00
|
18
|
+
default_executable:
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
name: savon
|
22
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
23
|
+
none: false
|
24
|
+
requirements:
|
25
|
+
- - ">="
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
segments:
|
28
|
+
- 0
|
29
|
+
version: "0"
|
30
|
+
type: :runtime
|
31
|
+
prerelease: false
|
32
|
+
version_requirements: *id001
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: shoulda
|
35
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
36
|
+
none: false
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
segments:
|
41
|
+
- 0
|
42
|
+
version: "0"
|
43
|
+
type: :development
|
44
|
+
prerelease: false
|
45
|
+
version_requirements: *id002
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: bundler
|
48
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ~>
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
segments:
|
54
|
+
- 1
|
55
|
+
- 0
|
56
|
+
- 0
|
57
|
+
version: 1.0.0
|
58
|
+
type: :development
|
59
|
+
prerelease: false
|
60
|
+
version_requirements: *id003
|
61
|
+
- !ruby/object:Gem::Dependency
|
62
|
+
name: jeweler
|
63
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
64
|
+
none: false
|
65
|
+
requirements:
|
66
|
+
- - ~>
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
segments:
|
69
|
+
- 1
|
70
|
+
- 6
|
71
|
+
- 4
|
72
|
+
version: 1.6.4
|
73
|
+
type: :development
|
74
|
+
prerelease: false
|
75
|
+
version_requirements: *id004
|
76
|
+
- !ruby/object:Gem::Dependency
|
77
|
+
name: rcov
|
78
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
79
|
+
none: false
|
80
|
+
requirements:
|
81
|
+
- - ">="
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
segments:
|
84
|
+
- 0
|
85
|
+
version: "0"
|
86
|
+
type: :development
|
87
|
+
prerelease: false
|
88
|
+
version_requirements: *id005
|
89
|
+
description: A Ruby SOAP client for accessing Desire2Learn Web Services (D2LWS)
|
90
|
+
email: mr-mencel@wiu.edu
|
91
|
+
executables: []
|
92
|
+
|
93
|
+
extensions: []
|
94
|
+
|
95
|
+
extra_rdoc_files:
|
96
|
+
- LICENSE.txt
|
97
|
+
- README.rdoc
|
98
|
+
files:
|
99
|
+
- .document
|
100
|
+
- Gemfile
|
101
|
+
- Gemfile.lock
|
102
|
+
- LICENSE.txt
|
103
|
+
- README.rdoc
|
104
|
+
- Rakefile
|
105
|
+
- VERSION
|
106
|
+
- lib/ruby-d2l.rb
|
107
|
+
- lib/ruby-d2l/auth.rb
|
108
|
+
- lib/ruby-d2l/config.rb
|
109
|
+
- lib/ruby-d2l/grades.rb
|
110
|
+
- lib/ruby-d2l/org_unit.rb
|
111
|
+
- lib/ruby-d2l/user.rb
|
112
|
+
- ruby-d2l.gemspec
|
113
|
+
- test/helper.rb
|
114
|
+
- test/test_ruby-d2l.rb
|
115
|
+
has_rdoc: true
|
116
|
+
homepage: http://github.com/chewie71/ruby-d2l
|
117
|
+
licenses:
|
118
|
+
- MIT
|
119
|
+
post_install_message:
|
120
|
+
rdoc_options: []
|
121
|
+
|
122
|
+
require_paths:
|
123
|
+
- lib
|
124
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
125
|
+
none: false
|
126
|
+
requirements:
|
127
|
+
- - ">="
|
128
|
+
- !ruby/object:Gem::Version
|
129
|
+
hash: -2981189433034712797
|
130
|
+
segments:
|
131
|
+
- 0
|
132
|
+
version: "0"
|
133
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
134
|
+
none: false
|
135
|
+
requirements:
|
136
|
+
- - ">="
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
segments:
|
139
|
+
- 0
|
140
|
+
version: "0"
|
141
|
+
requirements: []
|
142
|
+
|
143
|
+
rubyforge_project:
|
144
|
+
rubygems_version: 1.3.7
|
145
|
+
signing_key:
|
146
|
+
specification_version: 3
|
147
|
+
summary: Desire2Learn Ruby SOAP Client
|
148
|
+
test_files: []
|
149
|
+
|