[system] / branches / rel-2-4-patches / webwork2 / lib / WebworkSOAP.pm Repository:
ViewVC logotype

Annotation of /branches/rel-2-4-patches/webwork2/lib/WebworkSOAP.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 5714 - (view) (download) (as text)
Original Path: trunk/webwork2/lib/WebworkSOAP.pm

1 : mleventi 5009 package WebworkSOAP;
2 :    
3 :     use strict;
4 :    
5 :     use WeBWorK::Utils qw(pretty_print_rh);
6 :     use WeBWorK::Utils::CourseManagement qw(addCourse renameCourse deleteCourse listCourses archiveCourse listArchivedCourses unarchiveCourse);
7 :     use WeBWorK::DB;
8 : mleventi 5064 use WeBWorK::DB::Utils qw(initializeUserProblem);
9 : mleventi 5009 use WeBWorK::CourseEnvironment;
10 :     use WeBWorK::ContentGenerator::Instructor;
11 :    
12 :     use WebworkSOAP::Classes::GlobalSet;
13 :     use WebworkSOAP::Classes::UserSet;
14 :     use WebworkSOAP::Classes::GlobalProblem;
15 :     use WebworkSOAP::Classes::UserProblem;
16 :     use WebworkSOAP::Classes::User;
17 :     use WebworkSOAP::Classes::Key;
18 :     use WebworkSOAP::Classes::Password;
19 :     use WebworkSOAP::Classes::Permission;
20 :    
21 :     #init
22 :    
23 :     use constant {
24 :     SOAPERROR_MAJOR => 1,
25 :     SOAPERROR_MINOR => 2,
26 :     SOAPERROR_CLASS_NOT_FOUND => 3,
27 :     SOAPERROR_USER_NOT_FOUND => 4,
28 :     SOAPERROR_SET_NOT_FOUND => 5,
29 :     SOAPERROR_PROBLEM_NOT_FOUND => 6,
30 :     SOAPERROR_KEY_NOT_FOUND => 7,
31 :     SOAPERROR_AUTHEN_FAILED => 8
32 :     };
33 :    
34 :     our %SeedCE;
35 : gage 5223 %WebworkSOAP::SeedCE = %WeBWorK::SeedCE;
36 :    
37 : mleventi 5057 $WebworkSOAP::SeedCE{soap_authen_key} = "123456789123456789";
38 : gage 5226 #$WebworkSOAP::SeedCE{webwork_dir} = $ENV{WEBWORK_ROOT}|| warn "\$ENV{WEBWORK_ROOT} is undefined -- check your httpd configuration. Error caught ";
39 : mleventi 5009
40 : gage 5223
41 : mleventi 5009 sub new {
42 :     my($self,$authenKey,$courseName) = @_;
43 :     $self = {};
44 :     #Construct Course
45 : mleventi 5057 my $ce = eval { new WeBWorK::CourseEnvironment({%SeedCE, courseName => $courseName }) };
46 : gage 5225 $@ and soap_fault_major("Course Environment cannot be constructed.<br>$@");
47 : mleventi 5009 #Authentication Check
48 :     if($ce->{soap_authen_key} != $authenKey) {
49 :     soap_fault_authen();
50 :     }
51 :     #Construct DB handle
52 :     my $db = eval { new WeBWorK::DB($ce->{dbLayout}); };
53 : gage 5714 $@ and soap_fault_major("Failed to initialize database handle.<br>$@");
54 : mleventi 5009 $self->{db} = $db;
55 :     $self->{ce} = $ce;
56 :     bless $self;
57 :     return $self;
58 :     }
59 :    
60 :     sub soap_fault_authen {
61 :     die SOAP::Fault->faultcode(SOAPERROR_AUTHEN_FAILED)
62 :     ->faultstring("SOAP Webservice Authentication Failed!");
63 :     }
64 :    
65 :     sub soap_fault {
66 :     my ($errorCode,$errorMsg) = @_;
67 :     die SOAP::Fault->faultcode($errorCode)
68 :     ->faultstring($errorMsg);
69 :     }
70 :    
71 :     sub soap_fault_major {
72 :     my ($errorMsg) = @_;
73 :     soap_fault(SOAPERROR_MAJOR,$errorMsg);
74 :     }
75 :     ####################################################################################
76 :     #SOAP CALLABLE FUNCTIONS
77 :     ####################################################################################
78 :    
79 :     =pod
80 :     =begin WSDL
81 :     _RETURN $string Hello World!
82 :     =cut
83 :     sub hello {
84 :     return "Hello world!";
85 :     }
86 :    
87 :     #################################################
88 :     #Course
89 :     #################################################
90 :    
91 :     =pod
92 :     =begin WSDL
93 :     _IN authenKey $string
94 :     _RETURN @string
95 :     =end WSDL
96 :     =cut
97 :     sub list_courses {
98 :     my ($self,$authenKey) = @_;
99 : mleventi 5057 my $ce = eval { new WeBWorK::CourseEnvironment({%WeBWorK::SeedCE })};
100 :     $@ and soap_fault_major("Internal Course Environment cannot be constructed.");
101 :     if($authenKey != $WebworkSOAP::SeedCE{soap_authen_key}) {
102 : mleventi 5009 soap_fault_authen;
103 :     }
104 :     $@ and soap_fault_major("Course Environment cannot be constructed.");
105 :     my @test = listCourses($ce);
106 :     return \@test;
107 :     }
108 :    
109 :     =pod
110 :     =begin WSDL
111 :     _IN authenKey $string
112 :     _IN courseName $string
113 :     _IN userID $string
114 :     _RETURN $string
115 :     =end WSDL
116 :     =cut
117 :     sub login_user {
118 :     my ($self,$authenKey,$courseName,$userID) = @_;
119 :     my $soapEnv = new WebworkSOAP($authenKey,$courseName);
120 :     my $newKey;
121 :     my $timestamp = time;
122 :     my @chars = @{ $soapEnv->{ce}->{sessionKeyChars} };
123 :     my $length = $soapEnv->{ce}->{sessionKeyLength};
124 :     srand;
125 :     $newKey = join ("", @chars[map rand(@chars), 1 .. $length]);
126 :     my $Key = $soapEnv->{db}->newKey(user_id=>$userID, key=>$newKey, timestamp=>$timestamp);
127 :     eval { $soapEnv->{db}->deleteKey($userID) };
128 :     eval { $soapEnv->{db}->addKey($Key) };
129 :     $@ and soap_fault(SOAPERROR_USER_NOT_FOUND,"User not found.");
130 :     return $newKey;
131 :     }
132 :    
133 :     =pod
134 :     =begin WSDL
135 :     _IN authenKey $string
136 :     _IN courseName $string
137 :     _IN userID $string
138 :     _IN setID $string
139 :     _RETURN $string
140 :     =end WSDL
141 :     =cut
142 :     sub assign_set_to_user {
143 :     my ($self,$authenKey,$courseName,$userID,$setID) = @_;
144 :     my $soapEnv = new WebworkSOAP($authenKey,$courseName);
145 :     my $GlobalSet = eval {$soapEnv->{db}->getGlobalSet($setID)};
146 :     $@ and soap_fault(SOAPERROR_SET_NOT_FOUND,"Set not found.");
147 :     my $setID = $GlobalSet->set_id;
148 :     my $db = $soapEnv->{db};
149 :     my $UserSet = $db->newUserSet;
150 :     $UserSet->user_id($userID);
151 :     $UserSet->set_id($setID);
152 :     my @results;
153 :     my $set_assigned = 0;
154 :     eval { $db->addUserSet($UserSet) };
155 :     if ($@) {
156 :     if ($@ =~ m/user set exists/) {
157 :     push @results, "set $setID is already assigned to user $userID.";
158 :     $set_assigned = 1;
159 :     } else {
160 :     die $@;
161 :     }
162 :     }
163 : mleventi 5035
164 : mleventi 5009 my @GlobalProblems = grep { defined $_ } $db->getAllGlobalProblems($setID);
165 :     foreach my $GlobalProblem (@GlobalProblems) {
166 : mleventi 5057 my $seed = int( rand( 2423) ) + 36;
167 :     my $UserProblem = $db->newUserProblem;
168 :     $UserProblem->user_id($userID);
169 :     $UserProblem->set_id($GlobalProblem->set_id);
170 :     $UserProblem->problem_id($GlobalProblem->problem_id);
171 :     initializeUserProblem($UserProblem, $seed);
172 :     eval { $db->addUserProblem($UserProblem) };
173 : mleventi 5035 }
174 : mleventi 5009 return @results;
175 :     }
176 :    
177 : mleventi 5153 =pod
178 :     =begin WSDL
179 :     _IN authenKey $string
180 :     _IN courseName $string
181 :     _IN userIDs @string
182 :     _IN setID $string
183 : mleventi 5229 _RETURN @string
184 : mleventi 5153 =end WSDL
185 :     =cut
186 :     sub grade_users_sets {
187 :     my ($self,$authenKey,$courseName,$userIDs,$setID) = @_;
188 :     my $soapEnv = new WebworkSOAP($authenKey,$courseName);
189 :     my @grades;
190 :     foreach my $userID (@{$userIDs}) {
191 :     my @problemData = $soapEnv->{db}->getAllUserProblems($userID,$setID);
192 : mleventi 5035
193 : mleventi 5153 my $grade = 0;
194 :     for(my $i=0;$i<@problemData;$i++) {
195 :     $grade += @problemData[$i]->status;
196 :     }
197 :     push(@grades,$grade);
198 :     }
199 :     return \@grades;
200 :     }
201 :    
202 : mleventi 5229 =pod
203 :     =begin WSDL
204 :     _IN authenKey $string
205 :     _IN courseName $string
206 :     _IN setID $string
207 :     _RETURN @string
208 :     =end WSDL
209 :     =cut
210 :     sub get_set_data {
211 :     my ($self,$authenKey,$courseName,$setID) = @_;
212 :     my $soapEnv = new WebworkSOAP($authenKey,$courseName);
213 :     my $setData = $soapEnv->{db}->getGlobalSet($setID);
214 :     if(not defined $setData) {
215 :     return -1;
216 :     }
217 :     my $set = new WebworkSOAP::Classes::GlobalSet($setData);
218 :     return $set;
219 : mleventi 5153
220 : mleventi 5229
221 :     }
222 :    
223 : mleventi 5009 ####################################################################
224 :     ##FUNCTIONS DIRECTLY MAPPED TO FUNCTIONS IN DB.pm
225 :     ####################################################################
226 : mleventi 5057 ###############################################
227 : mleventi 5009 ##Password
228 : mleventi 5057 ###############################################
229 : mleventi 5009
230 :     =pod
231 :     =begin WSDL
232 :     _IN authenKey $string
233 :     _IN courseName $string
234 :     _IN record $WebworkSOAP::Classes::Password
235 : mleventi 5229 _RETURN $string
236 : mleventi 5009 =end WSDL
237 :     =cut
238 :     sub add_password {
239 :     my ($self,$authenKey,$courseName,$record) = @_;
240 :     my $soapEnv = new WebworkSOAP($authenKey,$courseName);
241 : mleventi 5035 my $newPassword = $soapEnv->{db}->newPassword;
242 :     %$newPassword = %$record;
243 :     return $soapEnv->{db}->addPassword($newPassword);
244 : mleventi 5009 }
245 :    
246 :     =pod
247 :     =begin WSDL
248 :     _IN authenKey $string
249 :     _IN courseName $string
250 :     _IN record $WebworkSOAP::Classes::Password
251 : mleventi 5229 _RETURN $string
252 : mleventi 5009 =end WSDL
253 :     =cut
254 :     sub put_password {
255 :     my ($self,$authenKey,$courseName,$record) = @_;
256 :     my $soapEnv = new WebworkSOAP($authenKey,$courseName);
257 :     return $soapEnv->{db}->putPassword($record);
258 :     }
259 :    
260 :     =pod
261 :     =begin WSDL
262 :     _IN authenKey $string
263 :     _IN courseName $string
264 :     _RETURN @string
265 :     =end WSDL
266 :     =cut
267 :     sub list_password {
268 :     my ($self,$authenKey,$courseName) = @_;
269 :     my $soapEnv = new WebworkSOAP($authenKey,$courseName);
270 :     my @tempArray = $soapEnv->{db}->listPasswords;
271 :     return \@tempArray;
272 :     }
273 :    
274 :     =pod
275 :     =begin WSDL
276 :     _IN authenKey $string
277 :     _IN courseName $string
278 :     _IN userIDs @string
279 : mleventi 5035 _RETURN @WebworkSOAP::Classes::Password Array of user objects
280 : mleventi 5009 =end WSDL
281 :     =cut
282 :     sub get_passwords {
283 :     my ($self,$authenKey,$courseName,$userIDs) = @_;
284 :     my $soapEnv = new WebworkSOAP($authenKey,$courseName);
285 : mleventi 5035 my @passwordData = $soapEnv->{db}->getPasswords(@$userIDs);
286 :     my @passwords;
287 :     for(my $i=0;$i<@passwordData;$i++) {
288 :     push(@passwords,new WebworkSOAP::Classes::Password(@passwordData[$i]));
289 : mleventi 5009 }
290 : mleventi 5035 return \@passwords;
291 : mleventi 5009 }
292 :    
293 :     =pod
294 :     =begin WSDL
295 :     _IN authenKey $string
296 :     _IN courseName $string
297 :     _IN userID $string
298 :     _RETURN $WebworkSOAP::Classes::Password of names objects.
299 :     =end WSDL
300 :     =cut
301 :     sub get_password {
302 :     my ($self,$authenKey,$courseName,$userID) = @_;
303 :     my $soapEnv = new WebworkSOAP($authenKey,$courseName);
304 : mleventi 5035 my $passwordData = $soapEnv->{db}->getPassword($userID);
305 :     if(not defined $passwordData) {
306 :     return -1;
307 :     }
308 :     my $password = new WebworkSOAP::Classes::Password($passwordData);
309 :     return ($password);
310 : mleventi 5009 }
311 :    
312 :     ##################################################
313 :     ##Permission
314 :     ##################################################
315 :    
316 :     =pod
317 :     =begin WSDL
318 :     _IN authenKey $string
319 :     _IN courseName $string
320 :     _IN record $WebworkSOAP::Classes::Permission
321 : mleventi 5229 _RETURN $string
322 : mleventi 5009 =end WSDL
323 :     =cut
324 :     sub add_permission {
325 :     my ($self,$authenKey,$courseName,$record) = @_;
326 :     my $soapEnv = new WebworkSOAP($authenKey,$courseName);
327 : mleventi 5035 my $newPermissionLevel = $soapEnv->{db}->newPermissionLevel;
328 :     %$newPermissionLevel = %$record;
329 :     return $soapEnv->{db}->addPermissionLevel($newPermissionLevel);
330 : mleventi 5009 }
331 :    
332 :     =pod
333 :     =begin WSDL
334 :     _IN authenKey $string
335 :     _IN courseName $string
336 :     _IN record $WebworkSOAP::Classes::Permission
337 : mleventi 5229 _RETURN $string
338 : mleventi 5009 =end WSDL
339 :     =cut
340 :     sub put_permission {
341 :     my ($self,$authenKey,$courseName,$record) = @_;
342 :     my $soapEnv = new WebworkSOAP($authenKey,$courseName);
343 :     return $soapEnv->{db}->putPermissionLevel($record);
344 :     }
345 :    
346 :     =pod
347 :     =begin WSDL
348 :     _IN authenKey $string
349 :     _IN courseName $string
350 :     _RETURN @string
351 :     =end WSDL
352 :     =cut
353 :     sub list_permissions {
354 :     my ($self,$authenKey,$courseName) = @_;
355 :     my $soapEnv = new WebworkSOAP($authenKey,$courseName);
356 :     my @tempArray = $soapEnv->{db}->listPermissionLevels;
357 :     return \@tempArray;
358 :     }
359 :    
360 :     =pod
361 :     =begin WSDL
362 :     _IN authenKey $string
363 :     _IN courseName $string
364 :     _IN userIDs @string
365 : mleventi 5035 _RETURN @WebworkSOAP::Classes::Permission Array of user objects
366 : mleventi 5009 =end WSDL
367 :     =cut
368 :     sub get_permissions {
369 :     my ($self,$authenKey,$courseName,$userIDs) = @_;
370 :     my $soapEnv = new WebworkSOAP($authenKey,$courseName);
371 : mleventi 5035 my @permissionData = $soapEnv->{db}->getPermissionLevels(@$userIDs);
372 :     my @permissions;
373 :     for(my $i=0;$i<@permissionData;$i++) {
374 :     push(@permissions,new WebworkSOAP::Classes::Permission(@permissionData[$i]));
375 : mleventi 5009 }
376 : mleventi 5035 return \@permissions;
377 : mleventi 5009 }
378 :    
379 :     =pod
380 :     =begin WSDL
381 :     _IN authenKey $string
382 :     _IN courseName $string
383 :     _IN userID $string
384 :     _RETURN $WebworkSOAP::Classes::Permission of names objects.
385 :     =end WSDL
386 :     =cut
387 :     sub get_permission {
388 :     my ($self,$authenKey,$courseName,$userID) = @_;
389 :     my $soapEnv = new WebworkSOAP($authenKey,$courseName);
390 : mleventi 5035 my $permissionData = $soapEnv->{db}->getPermissionLevel($userID);
391 :     if(not defined $permissionData) {
392 :     return -1;
393 :     }
394 :     my $permission = new WebworkSOAP::Classes::Permission($permissionData);
395 :     return ($permission);
396 : mleventi 5009 }
397 :    
398 :     ##################################################
399 :     ##Key
400 :     ##################################################
401 :    
402 :     =pod
403 :     =begin WSDL
404 :     _IN authenKey $string
405 :     _IN courseName $string
406 :     _IN record $WebworkSOAP::Classes::Key
407 : mleventi 5229 _RETURN $string
408 : mleventi 5009 =end WSDL
409 :     =cut
410 :     sub add_key {
411 :     my ($self,$authenKey,$courseName,$record) = @_;
412 :     my $soapEnv = new WebworkSOAP($authenKey,$courseName);
413 : mleventi 5035 my $newKey = $soapEnv->{db}->newKey;
414 :     %$newKey = %$record;
415 :     return $soapEnv->{db}->addKey($newKey);
416 : mleventi 5009 }
417 :    
418 :     =pod
419 :     =begin WSDL
420 :     _IN authenKey $string
421 :     _IN courseName $string
422 :     _IN record $WebworkSOAP::Classes::Key
423 : mleventi 5229 _RETURN $string
424 : mleventi 5009 =end WSDL
425 :     =cut
426 :     sub put_key {
427 :     my ($self,$authenKey,$courseName,$record) = @_;
428 :     my $soapEnv = new WebworkSOAP($authenKey,$courseName);
429 :     return $soapEnv->{db}->putKey($record);
430 :     }
431 :    
432 :     =pod
433 :     =begin WSDL
434 :     _IN authenKey $string
435 :     _IN courseName $string
436 :     _RETURN @string
437 :     =end WSDL
438 :     =cut
439 :     sub list_keys {
440 :     my ($self,$authenKey,$courseName) = @_;
441 :     my $soapEnv = new WebworkSOAP($authenKey,$courseName);
442 :     my @tempArray = $soapEnv->{db}->listKeys;
443 :     return \@tempArray;
444 :     }
445 :    
446 :     =pod
447 :     =begin WSDL
448 :     _IN authenKey $string
449 :     _IN courseName $string
450 :     _IN userIDs @string
451 : mleventi 5035 _RETURN @WebworkSOAP::Classes::Key Array of user objects
452 : mleventi 5009 =end WSDL
453 :     =cut
454 :     sub get_keys {
455 :     my ($self,$authenKey,$courseName,$userIDs) = @_;
456 :     my $soapEnv = new WebworkSOAP($authenKey,$courseName);
457 :     my @keyData = $soapEnv->{db}->getKeys(@$userIDs);
458 :     my @keys;
459 :     for(my $i=0;$i<@keyData;$i++) {
460 :     push(@keys,new WebworkSOAP::Classes::Key(@keyData[$i]));
461 :     }
462 :     return \@keys;
463 :     }
464 :    
465 :     =pod
466 :     =begin WSDL
467 :     _IN authenKey $string
468 :     _IN courseName $string
469 :     _IN userID $string
470 :     _RETURN $WebworkSOAP::Classes::Key of names objects.
471 :     =end WSDL
472 :     =cut
473 :     sub get_key {
474 :     my ($self,$authenKey,$courseName,$userID) = @_;
475 :     my $soapEnv = new WebworkSOAP($authenKey,$courseName);
476 :     my $keyData = $soapEnv->{db}->getKey($userID);
477 : mleventi 5035 if(not defined $keyData) {
478 :     return -1;
479 :     }
480 : mleventi 5009 my $key = new WebworkSOAP::Classes::Key($keyData);
481 :     return ($key);
482 :     }
483 :    
484 :     ##################################################
485 :     ##User
486 :     ##################################################
487 :    
488 :     =pod
489 :     =begin WSDL
490 :     _IN authenKey $string
491 :     _IN courseName $string
492 :     _IN record $WebworkSOAP::Classes::User
493 : mleventi 5229 _RETURN $string
494 : mleventi 5009 =end WSDL
495 :     =cut
496 :     sub add_user {
497 :     my ($self,$authenKey,$courseName,$record) = @_;
498 :     my $soapEnv = new WebworkSOAP($authenKey,$courseName);
499 : mleventi 5035 my $newUser = $soapEnv->{db}->newUser;
500 :     %$newUser = %$record;
501 :     return $soapEnv->{db}->addUser($newUser);
502 : mleventi 5009 }
503 :    
504 :     =pod
505 :     =begin WSDL
506 :     _IN authenKey $string
507 :     _IN courseName $string
508 :     _IN record $WebworkSOAP::Classes::User
509 : mleventi 5229 _RETURN $string
510 : mleventi 5009 =end WSDL
511 :     =cut
512 :     sub put_user {
513 :     my ($self,$authenKey,$courseName,$record) = @_;
514 :     my $soapEnv = new WebworkSOAP($authenKey,$courseName);
515 :     return $soapEnv->{db}->putUser($record);
516 :     }
517 :    
518 :     =pod
519 :     =begin WSDL
520 :     _IN authenKey $string
521 :     _IN courseName $string
522 :     _RETURN @string of names objects.
523 :     =end WSDL
524 :     =cut
525 :     sub list_users {
526 : mleventi 5035 my ($self,$authenKey,$courseName) = @_;
527 : mleventi 5009 my $soapEnv = new WebworkSOAP($authenKey,$courseName);
528 :     my @tempArray = $soapEnv->{db}->listUsers;
529 :     return \@tempArray;
530 :     }
531 :    
532 :     =pod
533 :     =begin WSDL
534 :     _IN authenKey $string
535 :     _IN courseName $string
536 :     _IN userID $string
537 :     _RETURN $WebworkSOAP::Classes::User of names objects.
538 :     =end WSDL
539 :     =cut
540 :     sub get_user {
541 :     my ($self,$authenKey,$courseName,$userID) = @_;
542 :     my $soapEnv = new WebworkSOAP($authenKey,$courseName);
543 :     my $userData = $soapEnv->{db}->getUser($userID);
544 : mleventi 5035 if(not defined $userData) {
545 :     return -1;
546 :     }
547 :     my $user = new WebworkSOAP::Classes::User($userData);
548 :     return ($user);
549 : mleventi 5009 }
550 :    
551 :     =pod
552 :     =begin WSDL
553 :     _IN authenKey $string
554 :     _IN courseName $string
555 :     _IN userIDs @string
556 : mleventi 5035 _RETURN @WebworkSOAP::Classes::User Array of user objects
557 : mleventi 5009 =end WSDL
558 :     =cut
559 :     sub get_users {
560 :     my ($self,$authenKey,$courseName,$userIDs) = @_;
561 :     my $soapEnv = new WebworkSOAP($authenKey,$courseName);
562 :     my @userData = $soapEnv->{db}->getUsers(@$userIDs);
563 :     my @users;
564 :     for(my $i=0;$i<@userData;$i++) {
565 :     push(@users,new WebworkSOAP::Classes::User(@userData[$i]));
566 :     }
567 :     return \@users;
568 :     }
569 :    
570 :     =pod
571 :     =begin WSDL
572 :     _IN authenKey $string
573 :     _IN courseName $string
574 :     _IN userID $string
575 : mleventi 5229 _RETURN $string
576 : mleventi 5009 =end WSDL
577 :     =cut
578 :     sub delete_user {
579 :     my ($self,$authenKey,$courseName,$userID) = @_;
580 :     my $soapEnv = new WebworkSOAP($authenKey,$courseName);
581 :     return $soapEnv->{db}->deleteUser($userID);
582 :     }
583 :    
584 :     ##################################################
585 :     ##Global Sets
586 :     ##################################################
587 :    
588 :     =pod
589 :     =begin WSDL
590 :     _IN authenKey $string
591 :     _IN courseName $string
592 :     _IN record $WebworkSOAP::Classes::GlobalSet
593 : mleventi 5229 _RETURN $string
594 : mleventi 5009 =end WSDL
595 :     =cut
596 :     sub add_global_set {
597 :     my ($self,$authenKey,$courseName,$record) = @_;
598 :     my $soapEnv = new WebworkSOAP($authenKey,$courseName);
599 : mleventi 5035 my $newGlobalSet = $soapEnv->{db}->newGlobalSet;
600 :     %$newGlobalSet = %$record;
601 :     return $soapEnv->{db}->addGlobalSet($newGlobalSet);
602 : mleventi 5009 }
603 :    
604 :     =pod
605 :     =begin WSDL
606 :     _IN authenKey $string
607 :     _IN courseName $string
608 :     _IN record $WebworkSOAP::Classes::GlobalSet
609 : mleventi 5229 _RETURN $string
610 : mleventi 5009 =end WSDL
611 :     =cut
612 :     sub put_global_set {
613 :     my ($self,$authenKey,$courseName,$record) = @_;
614 :     my $soapEnv = new WebworkSOAP($authenKey,$courseName);
615 :     return $soapEnv->{db}->putGlobalSet($record);
616 :     }
617 :    
618 :     =pod
619 :     =begin WSDL
620 :     _IN authenKey $string
621 :     _IN courseName $string
622 :     _RETURN @string of names objects.
623 :     =end WSDL
624 :     =cut
625 :     sub list_global_sets {
626 :     my ($self,$authenKey,$courseName) = @_;
627 :     my $soapEnv = new WebworkSOAP($authenKey,$courseName);
628 :     my @tempArray = $soapEnv->{db}->listGlobalSets;
629 :     return \@tempArray;
630 :     }
631 :    
632 :    
633 :     =pod
634 :     =begin WSDL
635 :     _IN authenKey $string
636 :     _IN courseName $string
637 : mleventi 5035 _RETURN @WebworkSOAP::Classes::GlobalSet Array of user objects
638 : mleventi 5009 =end WSDL
639 :     =cut
640 :     sub get_all_global_sets {
641 :     my ($self,$authenKey,$courseName) = @_;
642 :     my $soapEnv = new WebworkSOAP($authenKey,$courseName);
643 :     my @tempArray = $soapEnv->{db}->listGlobalSets;
644 :     my @setData = $soapEnv->{db}->getGlobalSets(@tempArray);
645 :     my @sets;
646 :     for(my $i=0;$i<@setData;$i++) {
647 :     push(@sets,new WebworkSOAP::Classes::GlobalSet(@setData[$i]));
648 :     }
649 :     return \@sets;
650 :     }
651 :    
652 :     =pod
653 :     =begin WSDL
654 :     _IN authenKey $string
655 :     _IN courseName $string
656 :     _IN setIDs @string
657 : mleventi 5035 _RETURN @WebworkSOAP::Classes::GlobalSet Array of user objects
658 : mleventi 5009 =end WSDL
659 :     =cut
660 :     sub get_global_sets {
661 :     my ($self,$authenKey,$courseName,$setIDs) = @_;
662 :     my $soapEnv = new WebworkSOAP($authenKey,$courseName);
663 :     my @setData = $soapEnv->{db}->getGlobalSets(@$setIDs);
664 :     my @sets;
665 :     for(my $i=0;$i<@setData;$i++) {
666 :     push(@sets,new WebworkSOAP::Classes::GlobalSet(@setData[$i]));
667 :     }
668 :     return \@sets;
669 :     }
670 :    
671 :     =pod
672 :     =begin WSDL
673 :     _IN authenKey $string
674 :     _IN courseName $string
675 :     _IN setID $string
676 : mleventi 5057 _RETURN $WebworkSOAP::Classes::GlobalSet
677 : mleventi 5009 =end WSDL
678 :     =cut
679 :     sub get_global_set {
680 :     my ($self,$authenKey,$courseName,$setID) = @_;
681 :     my $soapEnv = new WebworkSOAP($authenKey,$courseName);
682 :     my $setData = $soapEnv->{db}->getGlobalSet($setID);
683 : mleventi 5035 if(not defined $setData) {
684 :     return -1;
685 :     }
686 : mleventi 5009 my $set = new WebworkSOAP::Classes::GlobalSet($setData);
687 :     return ($set);
688 :     }
689 :    
690 :     =pod
691 :     =begin WSDL
692 :     _IN authenKey $string
693 :     _IN courseName $string
694 :     _IN setID $string
695 : mleventi 5229 _RETURN $string
696 : mleventi 5009 =end WSDL
697 :     =cut
698 : mleventi 5057 sub delete_global_set {
699 : mleventi 5009 my ($self,$authenKey,$courseName,$setID) = @_;
700 :     my $soapEnv = new WebworkSOAP($authenKey,$courseName);
701 :     return $soapEnv->{db}->deleteGlobalSet($setID);
702 :     }
703 :    
704 :     ##################################################
705 :     ##Global Problems
706 :     ##################################################
707 :    
708 :     =pod
709 :     =begin WSDL
710 :     _IN authenKey $string
711 :     _IN courseName $string
712 :     _IN record $WebworkSOAP::Classes::GlobalProblem
713 : mleventi 5229 _RETURN $string
714 : mleventi 5009 =end WSDL
715 :     =cut
716 :     sub add_global_problem {
717 :     my ($self,$authenKey,$courseName,$record) = @_;
718 :     my $soapEnv = new WebworkSOAP($authenKey,$courseName);
719 : mleventi 5035 my $newGlobalProblem = $soapEnv->{db}->newGlobalProblem;
720 :     %$newGlobalProblem = %$record;
721 :     return $soapEnv->{db}->addGlobalProblem($newGlobalProblem);
722 : mleventi 5009 }
723 :    
724 :     =pod
725 :     =begin WSDL
726 :     _IN authenKey $string
727 :     _IN courseName $string
728 :     _IN record $WebworkSOAP::Classes::GlobalProblem
729 : mleventi 5229 _RETURN $string
730 : mleventi 5009 =end WSDL
731 :     =cut
732 :     sub put_global_problem {
733 :     my ($self,$authenKey,$courseName,$record) = @_;
734 :     my $soapEnv = new WebworkSOAP($authenKey,$courseName);
735 :     return $soapEnv->{db}->putGlobalProblem($record);
736 :     }
737 :    
738 :     =pod
739 :     =begin WSDL
740 :     _IN authenKey $string
741 :     _IN courseName $string
742 : mleventi 5064 _IN setID $string
743 : mleventi 5009 _RETURN @string of names objects.
744 :     =end WSDL
745 :     =cut
746 :     sub list_global_problems {
747 : mleventi 5064 my ($self,$authenKey,$courseName,$setID) = @_;
748 : mleventi 5009 my $soapEnv = new WebworkSOAP($authenKey,$courseName);
749 : mleventi 5064 my @tempArray = $soapEnv->{db}->listGlobalProblems($setID);
750 : mleventi 5009 return \@tempArray;
751 :     }
752 :    
753 :     =pod
754 :     =begin WSDL
755 :     _IN authenKey $string
756 :     _IN courseName $string
757 :     _IN setID $string
758 : mleventi 5035 _RETURN @WebworkSOAP::Classes::GlobalProblem Array of user objects
759 : mleventi 5009 =end WSDL
760 :     =cut
761 :     sub get_all_global_problems {
762 :     my ($self,$authenKey,$courseName,$setID) = @_;
763 :     my $soapEnv = new WebworkSOAP($authenKey,$courseName);
764 :     my @problemData = $soapEnv->{db}->getAllGlobalProblems($setID);
765 :     my @problems;
766 :     for(my $i=0;$i<@problemData;$i++) {
767 :     push(@problems,new WebworkSOAP::Classes::GlobalProblem(@problemData[$i]));
768 :     }
769 :     return \@problems;
770 :     }
771 :    
772 :     =pod
773 :     =begin
774 :     _IN authenKey $string
775 :     _IN courseName $string
776 :     _IN problemIDs @string
777 : mleventi 5035 _RETURN @WebworkSOAP::Classes::GlobalProblem Array of user objects
778 : mleventi 5009 =end WSDL
779 :     =cut
780 :     sub get_global_problems {
781 :     my ($self,$authenKey,$courseName,$problemIDs) = @_;
782 :     my $soapEnv = new WebworkSOAP($authenKey,$courseName);
783 :     my @problemData = $soapEnv->{db}->getGlobalProblems(@$problemIDs);
784 :     my @problems;
785 :     for(my $i=0;$i<@problemData;$i++) {
786 :     push(@problems,new WebworkSOAP::Classes::GlobalProblem(@problemData[$i]));
787 :     }
788 :     return \@problems;
789 :     }
790 :    
791 :     =pod
792 :     =begin WSDL
793 :     _IN authenKey $string
794 :     _IN courseName $string
795 :     _IN setID $string
796 :     _IN problemID $string
797 :     _RETURN $WebworkSOAP::Classes::GlobalProblem of names objects.
798 :     =end WSDL
799 :     =cut
800 :     sub get_global_problem {
801 :     my ($self,$authenKey,$courseName,$setID,$problemID) = @_;
802 :     my $soapEnv = new WebworkSOAP($authenKey,$courseName);
803 :     my $problemData = $soapEnv->{db}->getGlobalProblem($setID,$problemID);
804 :     if(not defined $problemData) {
805 :     return -1;
806 :     }
807 :     my $problem = new WebworkSOAP::Classes::GlobalProblem($problemData);
808 :     return ($problem);
809 :     }
810 :    
811 :     =pod
812 :     =begin WSDL
813 :     _IN authenKey $string
814 :     _IN courseName $string
815 :     _IN setID $string
816 :     _IN problemID $string
817 : mleventi 5229 _RETURN $string
818 : mleventi 5009 =end WSDL
819 :     =cut
820 :     sub delete_global_problem {
821 :     my ($self,$authenKey,$courseName,$setID,$problemID) = @_;
822 :     my $soapEnv = new WebworkSOAP($authenKey,$courseName);
823 :     return $soapEnv->{db}->deleteGlobalProblem($setID,$problemID);
824 :     }
825 :    
826 :     ##################################################
827 :     ##USER PROBLEM
828 :     ##################################################
829 :    
830 :     =pod
831 :     =begin WSDL
832 :     _IN authenKey $string
833 :     _IN courseName $string
834 :     _IN record $WebworkSOAP::Classes::UserProblem
835 : mleventi 5229 _RETURN $string
836 : mleventi 5009 =end WSDL
837 :     =cut
838 :     sub add_user_problem {
839 :     my ($self,$authenKey,$courseName,$record) = @_;
840 :     my $soapEnv = new WebworkSOAP($authenKey,$courseName);
841 : mleventi 5035 my $newUserProblem = $soapEnv->{db}->newUserProblem;
842 :     %$newUserProblem = %$record;
843 :     return $soapEnv->{db}->addUserProblem($newUserProblem);
844 : mleventi 5009 }
845 :    
846 :     =pod
847 :     =begin WSDL
848 :     _IN authenKey $string
849 :     _IN courseName $string
850 :     _IN record $WebworkSOAP::Classes::UserProblem
851 : mleventi 5229 _RETURN $string
852 : mleventi 5009 =end WSDL
853 :     =cut
854 :     sub put_user_problem {
855 :     my ($self,$authenKey,$courseName,$record) = @_;
856 :     my $soapEnv = new WebworkSOAP($authenKey,$courseName);
857 :     return $soapEnv->{db}->putUserProblem($record);
858 :     }
859 :    
860 :     =pod
861 :     =begin WSDL
862 :     _IN authenKey $string
863 :     _IN courseName $string
864 :     _IN userID $string
865 :     _RETURN @string of names objects.
866 :     =end WSDL
867 :     =cut
868 :     sub list_user_problems {
869 :     my ($self,$authenKey,$courseName,$userID) = @_;
870 :     my $soapEnv = new WebworkSOAP($authenKey,$courseName);
871 :     my @tempArray = $soapEnv->{db}->listUserProblems($userID);
872 :     return \@tempArray;
873 :     }
874 :    
875 :     =pod
876 :     =begin WSDL
877 :     _IN authenKey $string
878 :     _IN courseName $string
879 :     _IN userID $string
880 :     _IN setID $string
881 :     _RETURN @WebworkSOAP::Classes::UserProblem of names objects.
882 :     =end WSDL
883 :     =cut
884 :     sub get_all_user_problems {
885 :     my ($self,$authenKey,$courseName,$userID,$setID) = @_;
886 :     my $soapEnv = new WebworkSOAP($authenKey,$courseName);
887 :     my @problemData = $soapEnv->{db}->getAllUserProblems($userID,$setID);
888 :     my @problems;
889 :     for(my $i=0;$i<@problemData;$i++) {
890 :     push(@problems,new WebworkSOAP::Classes::UserProblem(@problemData[$i]));
891 :     }
892 : mleventi 5035 return \@problems;
893 : mleventi 5009 }
894 :    
895 :     =pod
896 :     =begin WSDL
897 :     _IN authenKey $string
898 :     _IN courseName $string
899 :     _IN userProblemIDs @string
900 :     _RETURN @WebworkSOAP::Classes::UserProblem of names objects.
901 :     =end WSDL
902 :     =cut
903 :     sub get_user_problems {
904 :     my ($self,$authenKey,$courseName,$userProblemIDs) = @_;
905 :     my $soapEnv = new WebworkSOAP($authenKey,$courseName);
906 :     my @problemData = $soapEnv->{db}->getUserProblems(@$userProblemIDs);
907 :     my @problems;
908 :     for(my $i=0;$i<@problemData;$i++) {
909 :     push(@problems,new WebworkSOAP::Classes::UserProblem(@problemData[$i]));
910 :     }
911 : mleventi 5035 return \@problems;
912 : mleventi 5009 }
913 :    
914 :     =pod
915 :     =begin WSDL
916 :     _IN authenKey $string
917 :     _IN courseName $string
918 :     _IN userID $string
919 :     _IN setID $string
920 :     _IN problemID $string
921 :     _RETURN $WebworkSOAP::Classes::UserProblem of names objects.
922 :     =end WSDL
923 :     =cut
924 :     sub get_user_problem {
925 :     my ($self,$authenKey,$courseName,$userID,$setID,$problemID) = @_;
926 :     my $soapEnv = new WebworkSOAP($authenKey,$courseName);
927 :     my $problemData = $soapEnv->{db}->getUserProblem($userID,$setID,$problemID);
928 :     if(not defined $problemData) {
929 :     return -1;
930 :     }
931 :     my $problem = new WebworkSOAP::Classes::UserProblem($problemData);
932 : mleventi 5035 return ($problem);
933 : mleventi 5009 }
934 :    
935 :     =pod
936 :     =begin WSDL
937 :     _IN authenKey $string
938 :     _IN courseName $string
939 :     _IN userID $string
940 :     _IN setID $string
941 :     _IN problemID $string
942 : mleventi 5229 _RETURN $string
943 : mleventi 5009 =end WSDL
944 :     =cut
945 :     sub delete_user_problem {
946 :     my ($self,$authenKey,$courseName,$userID,$setID,$problemID) = @_;
947 :     my $soapEnv = new WebworkSOAP($authenKey,$courseName);
948 :     return $soapEnv->{db}->deleteUserProblem($userID,$setID,$problemID);
949 :     }
950 :    
951 :     ##################################################
952 :     ##USER SET
953 :     ##################################################
954 :    
955 :     =pod
956 :     =begin WSDL
957 :     _IN authenKey $string
958 :     _IN courseName $string
959 :     _IN record $WebworkSOAP::Classes::UserSet
960 : mleventi 5229 _RETURN $string
961 : mleventi 5009 =end WSDL
962 :     =cut
963 :     sub add_user_set {
964 :     my ($self,$authenKey,$courseName,$record) = @_;
965 :     my $soapEnv = new WebworkSOAP($authenKey,$courseName);
966 : mleventi 5035 my $newUserSet = $soapEnv->{db}->newUserSet;
967 :     %$newUserSet = %$record;
968 :     return $soapEnv->{db}->addUserSet($newUserSet);
969 : mleventi 5009 }
970 :    
971 :     =pod
972 :     =begin WSDL
973 :     _IN authenKey $string
974 :     _IN courseName $string
975 :     _IN record $WebworkSOAP::Classes::UserSet
976 : mleventi 5229 _RETURN $string
977 : mleventi 5009 =end WSDL
978 :     =cut
979 :     sub put_user_set {
980 :     my ($self,$authenKey,$courseName,$record) = @_;
981 :     my $soapEnv = new WebworkSOAP($authenKey,$courseName);
982 :     return $soapEnv->{db}->addUserSet($record);
983 :     }
984 :    
985 :     =pod
986 :     =begin WSDL
987 :     _IN authenKey $string
988 :     _IN courseName $string
989 :     _IN userID $string
990 :     _RETURN @string of names objects.
991 :     =end WSDL
992 :     =cut
993 :     sub list_user_sets {
994 :     my ($self,$authenKey,$courseName,$userID) = @_;
995 :     my $soapEnv = new WebworkSOAP($authenKey,$courseName);
996 :     my @tempArray = $soapEnv->{db}->listUserSets($userID);
997 :     return \@tempArray;
998 :     }
999 :    
1000 :     =pod
1001 :     =begin WSDL
1002 :     _IN authenKey $string
1003 :     _IN courseName $string
1004 :     _RETURN @WebworkSOAP::Classes::UserSet of names objects.
1005 :     =end WSDL
1006 :     =cut
1007 :     sub get_all_user_sets {
1008 :     my ($self,$authenKey,$courseName) = @_;
1009 :     my $soapEnv = new WebworkSOAP($authenKey,$courseName);
1010 :     my @setData = $soapEnv->{db}->getAllUserSets();
1011 :     my @sets;
1012 :     for(my $i=0;$i<@setData;$i++) {
1013 :     push(@sets,new WebworkSOAP::Classes::UserSet(@setData[$i]));
1014 :     }
1015 : mleventi 5035 return \@sets;
1016 : mleventi 5009 }
1017 :    
1018 :     =pod
1019 :     =begin WSDL
1020 :     _IN authenKey $string
1021 :     _IN courseName $string
1022 :     _IN userSetIDs $string
1023 :     _RETURN @WebworkSOAP::Classes::UserSet of names objects.
1024 :     =end WSDL
1025 :     =cut
1026 :     sub get_user_sets {
1027 :     my ($self,$authenKey,$courseName,$userSetIDs) = @_;
1028 :     my $soapEnv = new WebworkSOAP($authenKey,$courseName);
1029 :     my @setData = $soapEnv->{db}->getUserSets(@$userSetIDs);
1030 :     my @sets;
1031 :     for(my $i=0;$i<@setData;$i++) {
1032 :     push(@sets,new WebworkSOAP::Classes::UserSet(@setData[$i]));
1033 :     }
1034 : mleventi 5035 return \@sets;
1035 : mleventi 5009 }
1036 :    
1037 :     =pod
1038 :     =begin WSDL
1039 :     _IN authenKey $string
1040 :     _IN courseName $string
1041 :     _IN userID $string
1042 :     _IN setID $string
1043 :     _RETURN $WebworkSOAP::Classes::UserSet of names objects.
1044 :     =end WSDL
1045 :     =cut
1046 :     sub get_user_set {
1047 :     my ($self,$authenKey,$courseName,$userID,$setID) = @_;
1048 :     my $soapEnv = new WebworkSOAP($authenKey,$courseName);
1049 :     my $setData = $soapEnv->{db}->getUserSet($userID,$setID);
1050 :     if(not defined $setData) {
1051 :     return -1;
1052 :     }
1053 :     my $set = new WebworkSOAP::Classes::UserSet($setData);
1054 :     return $set;
1055 :     }
1056 :    
1057 :     =pod
1058 :     =begin WSDL
1059 :     _IN authenKey $string
1060 :     _IN courseName $string
1061 :     _IN userID $string
1062 :     _IN setID $string
1063 : mleventi 5229 _RETURN $string
1064 : mleventi 5009 =end WSDL
1065 :     =cut
1066 :     sub delete_user_set {
1067 :     my ($self,$authenKey,$courseName,$userID,$setID) = @_;
1068 :     my $soapEnv = new WebworkSOAP($authenKey,$courseName);
1069 :     return $soapEnv->{db}->deleteUserSet($userID,$setID);
1070 :     }
1071 :    
1072 :    
1073 :     1;

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9