| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package WebService::ScormCloud::Service::Course; |
|
2
|
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
2164
|
use Moose::Role; |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
with 'WebService::ScormCloud::Service'; |
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 NAME |
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
WebService::ScormCloud::Service::Course - ScormCloud API "course" namespace |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=head1 VERSION |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
Version 0.03 |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=cut |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
our $VERSION = '0.03'; |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
use WebService::ScormCloud; |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
my $ScormCloud = WebService::ScormCloud->new( |
|
24
|
|
|
|
|
|
|
app_id => '12345678', |
|
25
|
|
|
|
|
|
|
secret_key => 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', |
|
26
|
|
|
|
|
|
|
); |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
print "Found a course\n" if $ScormCloud->courseExists('123'); |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
my $course_list = $ScormCloud->getCourseList; |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
This module defines L<WebService::ScormCloud> API methods in the "course" |
|
35
|
|
|
|
|
|
|
namespace. See L<WebService::ScormCloud> for more info. |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=cut |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
use Carp; |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
requires 'process_request'; |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=head1 METHODS |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=head2 courseExists ( I<course_id> ) |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
Given a course ID, returns true if that course exists. |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=cut |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub courseExists ## no critic (NamingConventions::Capitalization) |
|
52
|
|
|
|
|
|
|
{ |
|
53
|
|
|
|
|
|
|
my ($self, $course_id) = @_; |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
croak 'Missing course_id' unless $course_id; |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
return $self->process_request( |
|
58
|
|
|
|
|
|
|
{method => 'course.exists', courseid => $course_id}, |
|
59
|
|
|
|
|
|
|
sub { |
|
60
|
|
|
|
|
|
|
my ($response) = @_; |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
return $response->{result} eq 'true' ? 1 : 0; |
|
63
|
|
|
|
|
|
|
} |
|
64
|
|
|
|
|
|
|
); |
|
65
|
|
|
|
|
|
|
} |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=head2 getMetadata ( I<course_id> ) |
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
Given a course ID, returns course metadata. |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=cut |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
sub getMetadata ## no critic (NamingConventions::Capitalization) |
|
74
|
|
|
|
|
|
|
{ |
|
75
|
|
|
|
|
|
|
my ($self, $course_id) = @_; |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
croak 'Missing course_id' unless $course_id; |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
return $self->process_request( |
|
80
|
|
|
|
|
|
|
{method => 'course.getMetadata', courseid => $course_id}, |
|
81
|
|
|
|
|
|
|
sub { |
|
82
|
|
|
|
|
|
|
my ($response) = @_; |
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
return ref($response->{package}) eq 'HASH' |
|
85
|
|
|
|
|
|
|
? $response->{package} |
|
86
|
|
|
|
|
|
|
: undef; |
|
87
|
|
|
|
|
|
|
} |
|
88
|
|
|
|
|
|
|
); |
|
89
|
|
|
|
|
|
|
} |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=head2 getCourseList ( [ I<filters> ] ) |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
Returns an arrayref containing a list of courses. |
|
94
|
|
|
|
|
|
|
The returned list might be empty. |
|
95
|
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
The optional I<filters> hashref can contain any of these entries |
|
97
|
|
|
|
|
|
|
to filter the returned list of registrations: |
|
98
|
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=over 4 |
|
100
|
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=item B<filter> |
|
102
|
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
A regular expression for matching the course ID |
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=back |
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
Note that any filter regular expressions must match the B<entire> |
|
108
|
|
|
|
|
|
|
string. (There seems to be an implied C<^...$> around the supplied |
|
109
|
|
|
|
|
|
|
pattern.) So to match e.g. any courses that begin with "ABC": |
|
110
|
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
{filter => '^ABC'} # THIS WILL NOT WORK |
|
112
|
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
{filter => 'ABC.*'} # This will work |
|
114
|
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=cut |
|
116
|
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
sub getCourseList ## no critic (NamingConventions::Capitalization) |
|
118
|
|
|
|
|
|
|
{ |
|
119
|
|
|
|
|
|
|
my ($self, $filters) = @_; |
|
120
|
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
$filters ||= {}; |
|
122
|
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
my %params = (method => 'course.getCourseList'); |
|
124
|
|
|
|
|
|
|
$params{filter} = $filters->{filter} if $filters->{filter}; |
|
125
|
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
return $self->process_request( |
|
127
|
|
|
|
|
|
|
\%params, |
|
128
|
|
|
|
|
|
|
sub { |
|
129
|
|
|
|
|
|
|
my ($response) = @_; |
|
130
|
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
die "bad\n" unless exists $response->{courselist}; |
|
132
|
|
|
|
|
|
|
if ($response->{courselist}) |
|
133
|
|
|
|
|
|
|
{ |
|
134
|
|
|
|
|
|
|
return $response->{courselist}; |
|
135
|
|
|
|
|
|
|
} |
|
136
|
|
|
|
|
|
|
else |
|
137
|
|
|
|
|
|
|
{ |
|
138
|
|
|
|
|
|
|
return []; # empty list |
|
139
|
|
|
|
|
|
|
} |
|
140
|
|
|
|
|
|
|
}, |
|
141
|
|
|
|
|
|
|
{ |
|
142
|
|
|
|
|
|
|
xml_parser => { |
|
143
|
|
|
|
|
|
|
ForceArray => ['course'], |
|
144
|
|
|
|
|
|
|
GroupTags => {'courselist' => 'course'}, |
|
145
|
|
|
|
|
|
|
} |
|
146
|
|
|
|
|
|
|
} |
|
147
|
|
|
|
|
|
|
); |
|
148
|
|
|
|
|
|
|
} |
|
149
|
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
1; |
|
151
|
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
__END__ |
|
153
|
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
155
|
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
L<WebService::ScormCloud> |
|
157
|
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
=head1 AUTHOR |
|
159
|
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
Larry Leszczynski, C<< <larryl at cpan.org> >> |
|
161
|
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
=head1 BUGS |
|
163
|
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
Please report any bugs or feature requests to C<bug-scormcloud at rt.cpan.org>, or through |
|
165
|
|
|
|
|
|
|
the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=WebService-ScormCloud>. I will be notified, and then you'll |
|
166
|
|
|
|
|
|
|
automatically be notified of progress on your bug as I make changes. |
|
167
|
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
Patches more than welcome, especially via GitHub: |
|
169
|
|
|
|
|
|
|
L<https://github.com/larryl/ScormCloud> |
|
170
|
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
=head1 SUPPORT |
|
172
|
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
|
174
|
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
perldoc WebService::ScormCloud::Service::Course |
|
176
|
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
You can also look for information at: |
|
178
|
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
=over 4 |
|
180
|
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
=item * GitHub |
|
182
|
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
L<https://github.com/larryl/ScormCloud> |
|
184
|
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
=item * RT: CPAN's request tracker |
|
186
|
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=WebService-ScormCloud> |
|
188
|
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
=item * AnnoCPAN: Annotated CPAN documentation |
|
190
|
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
L<http://annocpan.org/dist/WebService-ScormCloud> |
|
192
|
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
=item * CPAN Ratings |
|
194
|
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
L<http://cpanratings.perl.org/d/WebService-ScormCloud> |
|
196
|
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
=item * Search CPAN |
|
198
|
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
L<http://search.cpan.org/dist/WebService-ScormCloud/> |
|
200
|
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
=back |
|
202
|
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
=head1 ACKNOWLEDGEMENTS |
|
204
|
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |
|
207
|
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
Copyright 2010 Larry Leszczynski. |
|
209
|
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
|
211
|
|
|
|
|
|
|
under the terms of either: the GNU General Public License as published |
|
212
|
|
|
|
|
|
|
by the Free Software Foundation; or the Artistic License. |
|
213
|
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
See http://dev.perl.org/licenses/ for more information. |
|
215
|
|
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
=cut |
|
217
|
|
|
|
|
|
|
|