| … | |
… | |
| 3 | use strict; |
3 | use strict; |
| 4 | |
4 | |
| 5 | use WeBWorK::Utils qw(pretty_print_rh); |
5 | use WeBWorK::Utils qw(pretty_print_rh); |
| 6 | use WeBWorK::Utils::CourseManagement qw(addCourse renameCourse deleteCourse listCourses archiveCourse listArchivedCourses unarchiveCourse); |
6 | use WeBWorK::Utils::CourseManagement qw(addCourse renameCourse deleteCourse listCourses archiveCourse listArchivedCourses unarchiveCourse); |
| 7 | use WeBWorK::DB; |
7 | use WeBWorK::DB; |
|
|
8 | use WeBWorK::DB::Utils qw(initializeUserProblem); |
| 8 | use WeBWorK::CourseEnvironment; |
9 | use WeBWorK::CourseEnvironment; |
| 9 | use WeBWorK::ContentGenerator::Instructor; |
10 | use WeBWorK::ContentGenerator::Instructor; |
| 10 | |
11 | |
| 11 | use WebworkSOAP::Classes::GlobalSet; |
12 | use WebworkSOAP::Classes::GlobalSet; |
| 12 | use WebworkSOAP::Classes::UserSet; |
13 | use WebworkSOAP::Classes::UserSet; |
| … | |
… | |
| 29 | SOAPERROR_KEY_NOT_FOUND => 7, |
30 | SOAPERROR_KEY_NOT_FOUND => 7, |
| 30 | SOAPERROR_AUTHEN_FAILED => 8 |
31 | SOAPERROR_AUTHEN_FAILED => 8 |
| 31 | }; |
32 | }; |
| 32 | |
33 | |
| 33 | our %SeedCE; |
34 | our %SeedCE; |
|
|
35 | %WebworkSOAP::SeedCE = %WeBWorK::SeedCE; |
|
|
36 | |
|
|
37 | $WebworkSOAP::SeedCE{soap_authen_key} = "123456789123456789"; |
|
|
38 | #$WebworkSOAP::SeedCE{webwork_dir} = $ENV{WEBWORK_ROOT}|| warn "\$ENV{WEBWORK_ROOT} is undefined -- check your httpd configuration. Error caught "; |
|
|
39 | |
| 34 | |
40 | |
| 35 | sub new { |
41 | sub new { |
| 36 | my($self,$authenKey,$courseName) = @_; |
42 | my($self,$authenKey,$courseName) = @_; |
| 37 | $self = {}; |
43 | $self = {}; |
| 38 | #Construct Course |
44 | #Construct Course |
| 39 | my $ce = eval { new WeBWorK::CourseEnvironment({%WebworkSOAP::SeedCE, courseName => $courseName }) }; |
45 | my $ce = eval { new WeBWorK::CourseEnvironment({%SeedCE, courseName => $courseName }) }; |
| 40 | $@ and soap_fault_major("Course Environment cannot be constructed."); |
46 | $@ and soap_fault_major("Course Environment cannot be constructed.<br>$@"); |
| 41 | #Authentication Check |
47 | #Authentication Check |
| 42 | if($ce->{soap_authen_key} != $authenKey) { |
48 | if($ce->{soap_authen_key} != $authenKey) { |
| 43 | soap_fault_authen(); |
49 | soap_fault_authen(); |
| 44 | } |
50 | } |
| 45 | #Construct DB handle |
51 | #Construct DB handle |
| 46 | my $db = eval { new WeBWorK::DB($ce->{dbLayout}); }; |
52 | my $db = eval { new WeBWorK::DB($ce->{dbLayout}); }; |
| 47 | $@ and soap_fault_major("Failed to initialize database handle."); |
53 | $@ and soap_fault_major("Failed to initialize database handle.<br>$@"); |
| 48 | $self->{db} = $db; |
54 | $self->{db} = $db; |
| 49 | $self->{ce} = $ce; |
55 | $self->{ce} = $ce; |
| 50 | bless $self; |
56 | bless $self; |
| 51 | return $self; |
57 | return $self; |
| 52 | } |
58 | } |
| 53 | |
59 | |
|
|
60 | sub array_to_soap_string { |
|
|
61 | my @array = @_; |
|
|
62 | @array = map { SOAP::Data->type( 'string', $_ ) } @array; |
|
|
63 | return \@array; |
|
|
64 | } |
|
|
65 | |
| 54 | sub soap_fault_authen { |
66 | sub soap_fault_authen { |
| 55 | die SOAP::Fault->faultcode(SOAPERROR_AUTHEN_FAILED) |
67 | die SOAP::Fault->faultcode(SOAPERROR_AUTHEN_FAILED) |
| 56 | ->faultstring("SOAP Webservice Authentication Failed!"); |
68 | ->faultstring("SOAP Webservice Authentication Failed!"); |
| 57 | } |
69 | } |
| 58 | |
70 | |
| … | |
… | |
| 88 | _RETURN @string |
100 | _RETURN @string |
| 89 | =end WSDL |
101 | =end WSDL |
| 90 | =cut |
102 | =cut |
| 91 | sub list_courses { |
103 | sub list_courses { |
| 92 | my ($self,$authenKey) = @_; |
104 | my ($self,$authenKey) = @_; |
| 93 | |
|
|
| 94 | my $ce = eval { new WeBWorK::CourseEnvironment({%WebworkSOAP::SeedCE })}; |
105 | my $ce = eval { new WeBWorK::CourseEnvironment({%WeBWorK::SeedCE })}; |
| 95 | $@ and soap_fault_major("Course Environment cannot be constructed."); |
106 | $@ and soap_fault_major("Internal Course Environment cannot be constructed."); |
| 96 | if($authenKey != $ce->{soap_authen_key}) { |
107 | if($authenKey != $WebworkSOAP::SeedCE{soap_authen_key}) { |
| 97 | soap_fault_authen; |
108 | soap_fault_authen; |
| 98 | } |
109 | } |
| 99 | $@ and soap_fault_major("Course Environment cannot be constructed."); |
110 | $@ and soap_fault_major("Course Environment cannot be constructed."); |
| 100 | my @test = listCourses($ce); |
111 | my @test = listCourses($ce); |
| 101 | return \@test; |
112 | return array_to_soap_string( @test ); |
| 102 | } |
113 | } |
| 103 | |
114 | |
| 104 | =pod |
115 | =pod |
| 105 | =begin WSDL |
116 | =begin WSDL |
| 106 | _IN authenKey $string |
117 | _IN authenKey $string |
| … | |
… | |
| 120 | $newKey = join ("", @chars[map rand(@chars), 1 .. $length]); |
131 | $newKey = join ("", @chars[map rand(@chars), 1 .. $length]); |
| 121 | my $Key = $soapEnv->{db}->newKey(user_id=>$userID, key=>$newKey, timestamp=>$timestamp); |
132 | my $Key = $soapEnv->{db}->newKey(user_id=>$userID, key=>$newKey, timestamp=>$timestamp); |
| 122 | eval { $soapEnv->{db}->deleteKey($userID) }; |
133 | eval { $soapEnv->{db}->deleteKey($userID) }; |
| 123 | eval { $soapEnv->{db}->addKey($Key) }; |
134 | eval { $soapEnv->{db}->addKey($Key) }; |
| 124 | $@ and soap_fault(SOAPERROR_USER_NOT_FOUND,"User not found."); |
135 | $@ and soap_fault(SOAPERROR_USER_NOT_FOUND,"User not found."); |
| 125 | return $newKey; |
136 | return SOAP::Data->type( 'string', $newKey ); |
| 126 | } |
137 | } |
| 127 | |
138 | |
| 128 | =pod |
139 | =pod |
| 129 | =begin WSDL |
140 | =begin WSDL |
| 130 | _IN authenKey $string |
141 | _IN authenKey $string |
| … | |
… | |
| 156 | } |
167 | } |
| 157 | } |
168 | } |
| 158 | |
169 | |
| 159 | my @GlobalProblems = grep { defined $_ } $db->getAllGlobalProblems($setID); |
170 | my @GlobalProblems = grep { defined $_ } $db->getAllGlobalProblems($setID); |
| 160 | foreach my $GlobalProblem (@GlobalProblems) { |
171 | foreach my $GlobalProblem (@GlobalProblems) { |
| 161 | my @result = $db->assignProblemToUser($userID, $GlobalProblem); |
172 | my $seed = int( rand( 2423) ) + 36; |
| 162 | push @results, @result if @result and not $set_assigned; |
173 | my $UserProblem = $db->newUserProblem; |
|
|
174 | $UserProblem->user_id($userID); |
|
|
175 | $UserProblem->set_id($GlobalProblem->set_id); |
|
|
176 | $UserProblem->problem_id($GlobalProblem->problem_id); |
|
|
177 | initializeUserProblem($UserProblem, $seed); |
|
|
178 | eval { $db->addUserProblem($UserProblem) }; |
| 163 | } |
179 | } |
|
|
180 | return array_to_soap_string( @results ); #FIXME WSDL says $string, not @string? |
|
|
181 | } |
|
|
182 | |
|
|
183 | =pod |
|
|
184 | =begin WSDL |
|
|
185 | _IN authenKey $string |
|
|
186 | _IN courseName $string |
|
|
187 | _IN userIDs @string |
|
|
188 | _IN setID $string |
|
|
189 | _RETURN @string |
|
|
190 | =end WSDL |
|
|
191 | =cut |
|
|
192 | sub grade_users_sets { |
|
|
193 | my ($self,$authenKey,$courseName,$userIDs,$setID) = @_; |
|
|
194 | my $soapEnv = new WebworkSOAP($authenKey,$courseName); |
|
|
195 | my @grades; |
|
|
196 | #open (LOG, ">>/opt/webwork/tmp_log") or die "Can't open log file"; |
|
|
197 | #print LOG "\n\nhi there\n\n"; |
|
|
198 | |
|
|
199 | my $db = $soapEnv->{db}; |
|
|
200 | foreach my $userID (@{$userIDs}) { |
|
|
201 | # my @problemData = $soapEnv->{db}->getAllMergedUserProblems($userID,$setID); |
|
|
202 | # |
|
|
203 | # my $grade = 0; |
|
|
204 | # for(my $i=0;$i<@problemData;$i++) { |
|
|
205 | # #print LOG "$userID problem Data",join(" ", %{$problemData[$i]}),"\n\n"; |
|
|
206 | # $grade += ($problemData[$i]->status)*($problemData[$i]->value); |
|
|
207 | # #print LOG "grade is $grade\n"; |
|
|
208 | # } |
|
|
209 | #print LOG "grade_users_sets: get user $userID set $setID\n"; |
|
|
210 | my $grade = get_wwassignment_grade_for_one_user($db, $userID,$setID ); |
|
|
211 | #print LOG " grade is $grade \n\n"; |
|
|
212 | push(@grades,$grade); |
|
|
213 | } |
|
|
214 | #close(LOG); |
|
|
215 | return array_to_soap_string( @grades ); |
|
|
216 | } |
|
|
217 | |
|
|
218 | =pod |
|
|
219 | =begin WSDL |
|
|
220 | _IN authenKey $string |
|
|
221 | _IN courseName $string |
|
|
222 | _IN setID $string |
|
|
223 | _RETURN $WebworkSOAP::Classes::GlobalSet |
|
|
224 | =end WSDL |
|
|
225 | =cut |
|
|
226 | sub get_set_data { |
|
|
227 | my ($self,$authenKey,$courseName,$setID) = @_; |
|
|
228 | my $soapEnv = new WebworkSOAP($authenKey,$courseName); |
|
|
229 | my $setData = $soapEnv->{db}->getGlobalSet($setID); |
|
|
230 | if(not defined $setData) { |
|
|
231 | return -1; |
|
|
232 | } |
|
|
233 | my $set = new WebworkSOAP::Classes::GlobalSet($setData); |
| 164 | return @results; |
234 | return $set; |
| 165 | } |
235 | } |
| 166 | |
|
|
| 167 | |
236 | |
| 168 | #################################################################### |
237 | #################################################################### |
| 169 | ##FUNCTIONS DIRECTLY MAPPED TO FUNCTIONS IN DB.pm |
238 | ##FUNCTIONS DIRECTLY MAPPED TO FUNCTIONS IN DB.pm |
| 170 | #################################################################### |
239 | #################################################################### |
| 171 | ################################################## |
240 | ############################################### |
| 172 | ##Password |
241 | ##Password |
| 173 | ################################################## |
242 | ############################################### |
| 174 | |
243 | |
| 175 | =pod |
244 | =pod |
| 176 | =begin WSDL |
245 | =begin WSDL |
| 177 | _IN authenKey $string |
246 | _IN authenKey $string |
| 178 | _IN courseName $string |
247 | _IN courseName $string |
| 179 | _IN record $WebworkSOAP::Classes::Password |
248 | _IN record $WebworkSOAP::Classes::Password |
| 180 | _RETURN $integer |
249 | _RETURN $string |
| 181 | =end WSDL |
250 | =end WSDL |
| 182 | =cut |
251 | =cut |
| 183 | sub add_password { |
252 | sub add_password { |
| 184 | my ($self,$authenKey,$courseName,$record) = @_; |
253 | my ($self,$authenKey,$courseName,$record) = @_; |
| 185 | my $soapEnv = new WebworkSOAP($authenKey,$courseName); |
254 | my $soapEnv = new WebworkSOAP($authenKey,$courseName); |
| 186 | my $newPassword = $soapEnv->{db}->newPassword; |
255 | my $newPassword = $soapEnv->{db}->newPassword; |
| 187 | %$newPassword = %$record; |
256 | %$newPassword = %$record; |
| 188 | return $soapEnv->{db}->addPassword($newPassword); |
257 | return SOAP::Data->type( 'string', $soapEnv->{db}->addPassword($newPassword) ); |
| 189 | } |
258 | } |
| 190 | |
259 | |
| 191 | =pod |
260 | =pod |
| 192 | =begin WSDL |
261 | =begin WSDL |
| 193 | _IN authenKey $string |
262 | _IN authenKey $string |
| 194 | _IN courseName $string |
263 | _IN courseName $string |
| 195 | _IN record $WebworkSOAP::Classes::Password |
264 | _IN record $WebworkSOAP::Classes::Password |
| 196 | _RETURN $integer |
265 | _RETURN $string |
| 197 | =end WSDL |
266 | =end WSDL |
| 198 | =cut |
267 | =cut |
| 199 | sub put_password { |
268 | sub put_password { |
| 200 | my ($self,$authenKey,$courseName,$record) = @_; |
269 | my ($self,$authenKey,$courseName,$record) = @_; |
| 201 | my $soapEnv = new WebworkSOAP($authenKey,$courseName); |
270 | my $soapEnv = new WebworkSOAP($authenKey,$courseName); |
| 202 | return $soapEnv->{db}->putPassword($record); |
271 | return SOAP::Data->type( 'string', $soapEnv->{db}->putPassword($record) ); |
| 203 | } |
272 | } |
| 204 | |
273 | |
| 205 | =pod |
274 | =pod |
| 206 | =begin WSDL |
275 | =begin WSDL |
| 207 | _IN authenKey $string |
276 | _IN authenKey $string |
| … | |
… | |
| 211 | =cut |
280 | =cut |
| 212 | sub list_password { |
281 | sub list_password { |
| 213 | my ($self,$authenKey,$courseName) = @_; |
282 | my ($self,$authenKey,$courseName) = @_; |
| 214 | my $soapEnv = new WebworkSOAP($authenKey,$courseName); |
283 | my $soapEnv = new WebworkSOAP($authenKey,$courseName); |
| 215 | my @tempArray = $soapEnv->{db}->listPasswords; |
284 | my @tempArray = $soapEnv->{db}->listPasswords; |
| 216 | return \@tempArray; |
285 | return array_to_soap_string( @tempArray ); |
| 217 | } |
286 | } |
| 218 | |
287 | |
| 219 | =pod |
288 | =pod |
| 220 | =begin WSDL |
289 | =begin WSDL |
| 221 | _IN authenKey $string |
290 | _IN authenKey $string |
| … | |
… | |
| 261 | =pod |
330 | =pod |
| 262 | =begin WSDL |
331 | =begin WSDL |
| 263 | _IN authenKey $string |
332 | _IN authenKey $string |
| 264 | _IN courseName $string |
333 | _IN courseName $string |
| 265 | _IN record $WebworkSOAP::Classes::Permission |
334 | _IN record $WebworkSOAP::Classes::Permission |
| 266 | _RETURN $integer |
335 | _RETURN $string |
| 267 | =end WSDL |
336 | =end WSDL |
| 268 | =cut |
337 | =cut |
| 269 | sub add_permission { |
338 | sub add_permission { |
| 270 | my ($self,$authenKey,$courseName,$record) = @_; |
339 | my ($self,$authenKey,$courseName,$record) = @_; |
| 271 | my $soapEnv = new WebworkSOAP($authenKey,$courseName); |
340 | my $soapEnv = new WebworkSOAP($authenKey,$courseName); |
| 272 | my $newPermissionLevel = $soapEnv->{db}->newPermissionLevel; |
341 | my $newPermissionLevel = $soapEnv->{db}->newPermissionLevel; |
| 273 | %$newPermissionLevel = %$record; |
342 | %$newPermissionLevel = %$record; |
| 274 | return $soapEnv->{db}->addPermissionLevel($newPermissionLevel); |
343 | return SOAP::Data->type( 'string', $soapEnv->{db}->addPermissionLevel($newPermissionLevel) ); |
| 275 | } |
344 | } |
| 276 | |
345 | |
| 277 | =pod |
346 | =pod |
| 278 | =begin WSDL |
347 | =begin WSDL |
| 279 | _IN authenKey $string |
348 | _IN authenKey $string |
| 280 | _IN courseName $string |
349 | _IN courseName $string |
| 281 | _IN record $WebworkSOAP::Classes::Permission |
350 | _IN record $WebworkSOAP::Classes::Permission |
| 282 | _RETURN $integer |
351 | _RETURN $string |
| 283 | =end WSDL |
352 | =end WSDL |
| 284 | =cut |
353 | =cut |
| 285 | sub put_permission { |
354 | sub put_permission { |
| 286 | my ($self,$authenKey,$courseName,$record) = @_; |
355 | my ($self,$authenKey,$courseName,$record) = @_; |
| 287 | my $soapEnv = new WebworkSOAP($authenKey,$courseName); |
356 | my $soapEnv = new WebworkSOAP($authenKey,$courseName); |
| 288 | return $soapEnv->{db}->putPermissionLevel($record); |
357 | my $newPermissionLevel = $soapEnv->{db}->newPermissionLevel; |
|
|
358 | %$newPermissionLevel = %$record; |
|
|
359 | return SOAP::Data->type( 'string', |
|
|
360 | $soapEnv->{db}->putPermissionLevel($newPermissionLevel) ); |
| 289 | } |
361 | } |
| 290 | |
362 | |
| 291 | =pod |
363 | =pod |
| 292 | =begin WSDL |
364 | =begin WSDL |
| 293 | _IN authenKey $string |
365 | _IN authenKey $string |
| … | |
… | |
| 297 | =cut |
369 | =cut |
| 298 | sub list_permissions { |
370 | sub list_permissions { |
| 299 | my ($self,$authenKey,$courseName) = @_; |
371 | my ($self,$authenKey,$courseName) = @_; |
| 300 | my $soapEnv = new WebworkSOAP($authenKey,$courseName); |
372 | my $soapEnv = new WebworkSOAP($authenKey,$courseName); |
| 301 | my @tempArray = $soapEnv->{db}->listPermissionLevels; |
373 | my @tempArray = $soapEnv->{db}->listPermissionLevels; |
| 302 | return \@tempArray; |
374 | return array_to_soap_string( @tempArray ); |
| 303 | } |
375 | } |
| 304 | |
376 | |
| 305 | =pod |
377 | =pod |
| 306 | =begin WSDL |
378 | =begin WSDL |
| 307 | _IN authenKey $string |
379 | _IN authenKey $string |
| … | |
… | |
| 347 | =pod |
419 | =pod |
| 348 | =begin WSDL |
420 | =begin WSDL |
| 349 | _IN authenKey $string |
421 | _IN authenKey $string |
| 350 | _IN courseName $string |
422 | _IN courseName $string |
| 351 | _IN record $WebworkSOAP::Classes::Key |
423 | _IN record $WebworkSOAP::Classes::Key |
| 352 | _RETURN $integer |
424 | _RETURN $string |
| 353 | =end WSDL |
425 | =end WSDL |
| 354 | =cut |
426 | =cut |
| 355 | sub add_key { |
427 | sub add_key { |
| 356 | my ($self,$authenKey,$courseName,$record) = @_; |
428 | my ($self,$authenKey,$courseName,$record) = @_; |
| 357 | my $soapEnv = new WebworkSOAP($authenKey,$courseName); |
429 | my $soapEnv = new WebworkSOAP($authenKey,$courseName); |
| 358 | my $newKey = $soapEnv->{db}->newKey; |
430 | my $newKey = $soapEnv->{db}->newKey; |
| 359 | %$newKey = %$record; |
431 | %$newKey = %$record; |
| 360 | return $soapEnv->{db}->addKey($newKey); |
432 | return SOAP::Data->type( 'string', $soapEnv->{db}->addKey($newKey) ); |
| 361 | } |
433 | } |
| 362 | |
434 | |
| 363 | =pod |
435 | =pod |
| 364 | =begin WSDL |
436 | =begin WSDL |
| 365 | _IN authenKey $string |
437 | _IN authenKey $string |
| 366 | _IN courseName $string |
438 | _IN courseName $string |
| 367 | _IN record $WebworkSOAP::Classes::Key |
439 | _IN record $WebworkSOAP::Classes::Key |
| 368 | _RETURN $integer |
440 | _RETURN $string |
| 369 | =end WSDL |
441 | =end WSDL |
| 370 | =cut |
442 | =cut |
| 371 | sub put_key { |
443 | sub put_key { |
| 372 | my ($self,$authenKey,$courseName,$record) = @_; |
444 | my ($self,$authenKey,$courseName,$record) = @_; |
| 373 | my $soapEnv = new WebworkSOAP($authenKey,$courseName); |
445 | my $soapEnv = new WebworkSOAP($authenKey,$courseName); |
| 374 | return $soapEnv->{db}->putKey($record); |
446 | return SOAP::Data->type( 'string', $soapEnv->{db}->putKey($record) ); |
| 375 | } |
447 | } |
| 376 | |
448 | |
| 377 | =pod |
449 | =pod |
| 378 | =begin WSDL |
450 | =begin WSDL |
| 379 | _IN authenKey $string |
451 | _IN authenKey $string |
| … | |
… | |
| 383 | =cut |
455 | =cut |
| 384 | sub list_keys { |
456 | sub list_keys { |
| 385 | my ($self,$authenKey,$courseName) = @_; |
457 | my ($self,$authenKey,$courseName) = @_; |
| 386 | my $soapEnv = new WebworkSOAP($authenKey,$courseName); |
458 | my $soapEnv = new WebworkSOAP($authenKey,$courseName); |
| 387 | my @tempArray = $soapEnv->{db}->listKeys; |
459 | my @tempArray = $soapEnv->{db}->listKeys; |
| 388 | return \@tempArray; |
460 | return array_to_soap_string( @tempArray ); |
| 389 | } |
461 | } |
| 390 | |
462 | |
| 391 | =pod |
463 | =pod |
| 392 | =begin WSDL |
464 | =begin WSDL |
| 393 | _IN authenKey $string |
465 | _IN authenKey $string |
| … | |
… | |
| 433 | =pod |
505 | =pod |
| 434 | =begin WSDL |
506 | =begin WSDL |
| 435 | _IN authenKey $string |
507 | _IN authenKey $string |
| 436 | _IN courseName $string |
508 | _IN courseName $string |
| 437 | _IN record $WebworkSOAP::Classes::User |
509 | _IN record $WebworkSOAP::Classes::User |
| 438 | _RETURN $integer |
510 | _RETURN $string |
| 439 | =end WSDL |
511 | =end WSDL |
| 440 | =cut |
512 | =cut |
| 441 | sub add_user { |
513 | sub add_user { |
| 442 | my ($self,$authenKey,$courseName,$record) = @_; |
514 | my ($self,$authenKey,$courseName,$record) = @_; |
| 443 | my $soapEnv = new WebworkSOAP($authenKey,$courseName); |
515 | my $soapEnv = new WebworkSOAP($authenKey,$courseName); |
| 444 | my $newUser = $soapEnv->{db}->newUser; |
516 | my $newUser = $soapEnv->{db}->newUser; |
| 445 | %$newUser = %$record; |
517 | %$newUser = %$record; |
| 446 | return $soapEnv->{db}->addUser($newUser); |
518 | return SOAP::Data->type( 'string', $soapEnv->{db}->addUser($newUser) ); |
| 447 | } |
519 | } |
| 448 | |
520 | |
| 449 | =pod |
521 | =pod |
| 450 | =begin WSDL |
522 | =begin WSDL |
| 451 | _IN authenKey $string |
523 | _IN authenKey $string |
| 452 | _IN courseName $string |
524 | _IN courseName $string |
| 453 | _IN record $WebworkSOAP::Classes::User |
525 | _IN record $WebworkSOAP::Classes::User |
| 454 | _RETURN $integer |
526 | _RETURN $string |
| 455 | =end WSDL |
527 | =end WSDL |
| 456 | =cut |
528 | =cut |
| 457 | sub put_user { |
529 | sub put_user { |
| 458 | my ($self,$authenKey,$courseName,$record) = @_; |
530 | my ($self,$authenKey,$courseName,$record) = @_; |
| 459 | my $soapEnv = new WebworkSOAP($authenKey,$courseName); |
531 | my $soapEnv = new WebworkSOAP($authenKey,$courseName); |
| 460 | return $soapEnv->{db}->putUser($record); |
532 | return SOAP::Data->type( 'string', $soapEnv->{db}->putUser($record) ); |
| 461 | } |
533 | } |
| 462 | |
534 | |
| 463 | =pod |
535 | =pod |
| 464 | =begin WSDL |
536 | =begin WSDL |
| 465 | _IN authenKey $string |
537 | _IN authenKey $string |
| … | |
… | |
| 469 | =cut |
541 | =cut |
| 470 | sub list_users { |
542 | sub list_users { |
| 471 | my ($self,$authenKey,$courseName) = @_; |
543 | my ($self,$authenKey,$courseName) = @_; |
| 472 | my $soapEnv = new WebworkSOAP($authenKey,$courseName); |
544 | my $soapEnv = new WebworkSOAP($authenKey,$courseName); |
| 473 | my @tempArray = $soapEnv->{db}->listUsers; |
545 | my @tempArray = $soapEnv->{db}->listUsers; |
| 474 | return \@tempArray; |
546 | return array_to_soap_string( @tempArray ); |
| 475 | } |
547 | } |
| 476 | |
548 | |
| 477 | =pod |
549 | =pod |
| 478 | =begin WSDL |
550 | =begin WSDL |
| 479 | _IN authenKey $string |
551 | _IN authenKey $string |
| … | |
… | |
| 515 | =pod |
587 | =pod |
| 516 | =begin WSDL |
588 | =begin WSDL |
| 517 | _IN authenKey $string |
589 | _IN authenKey $string |
| 518 | _IN courseName $string |
590 | _IN courseName $string |
| 519 | _IN userID $string |
591 | _IN userID $string |
| 520 | _RETURN $integer |
592 | _RETURN $string |
| 521 | =end WSDL |
593 | =end WSDL |
| 522 | =cut |
594 | =cut |
| 523 | sub delete_user { |
595 | sub delete_user { |
| 524 | my ($self,$authenKey,$courseName,$userID) = @_; |
596 | my ($self,$authenKey,$courseName,$userID) = @_; |
| 525 | my $soapEnv = new WebworkSOAP($authenKey,$courseName); |
597 | my $soapEnv = new WebworkSOAP($authenKey,$courseName); |
| 526 | return $soapEnv->{db}->deleteUser($userID); |
598 | return SOAP::Data->type( 'string', $soapEnv->{db}->deleteUser($userID) ); |
| 527 | } |
599 | } |
| 528 | |
600 | |
| 529 | ################################################## |
601 | ################################################## |
| 530 | ##Global Sets |
602 | ##Global Sets |
| 531 | ################################################## |
603 | ################################################## |
| … | |
… | |
| 533 | =pod |
605 | =pod |
| 534 | =begin WSDL |
606 | =begin WSDL |
| 535 | _IN authenKey $string |
607 | _IN authenKey $string |
| 536 | _IN courseName $string |
608 | _IN courseName $string |
| 537 | _IN record $WebworkSOAP::Classes::GlobalSet |
609 | _IN record $WebworkSOAP::Classes::GlobalSet |
| 538 | _RETURN $integer |
610 | _RETURN $string |
| 539 | =end WSDL |
611 | =end WSDL |
| 540 | =cut |
612 | =cut |
| 541 | sub add_global_set { |
613 | sub add_global_set { |
| 542 | my ($self,$authenKey,$courseName,$record) = @_; |
614 | my ($self,$authenKey,$courseName,$record) = @_; |
| 543 | my $soapEnv = new WebworkSOAP($authenKey,$courseName); |
615 | my $soapEnv = new WebworkSOAP($authenKey,$courseName); |
| 544 | my $newGlobalSet = $soapEnv->{db}->newGlobalSet; |
616 | my $newGlobalSet = $soapEnv->{db}->newGlobalSet; |
| 545 | %$newGlobalSet = %$record; |
617 | %$newGlobalSet = %$record; |
| 546 | return $soapEnv->{db}->addGlobalSet($newGlobalSet); |
618 | return SOAP::Data->type( 'string', $soapEnv->{db}->addGlobalSet($newGlobalSet) ); |
| 547 | } |
619 | } |
| 548 | |
620 | |
| 549 | =pod |
621 | =pod |
| 550 | =begin WSDL |
622 | =begin WSDL |
| 551 | _IN authenKey $string |
623 | _IN authenKey $string |
| 552 | _IN courseName $string |
624 | _IN courseName $string |
| 553 | _IN record $WebworkSOAP::Classes::GlobalSet |
625 | _IN record $WebworkSOAP::Classes::GlobalSet |
| 554 | _RETURN $integer |
626 | _RETURN $string |
| 555 | =end WSDL |
627 | =end WSDL |
| 556 | =cut |
628 | =cut |
| 557 | sub put_global_set { |
629 | sub put_global_set { |
| 558 | my ($self,$authenKey,$courseName,$record) = @_; |
630 | my ($self,$authenKey,$courseName,$record) = @_; |
| 559 | my $soapEnv = new WebworkSOAP($authenKey,$courseName); |
631 | my $soapEnv = new WebworkSOAP($authenKey,$courseName); |
| 560 | return $soapEnv->{db}->putGlobalSet($record); |
632 | return SOAP::Data->type( 'string', $soapEnv->{db}->putGlobalSet($record) ); |
| 561 | } |
633 | } |
| 562 | |
634 | |
| 563 | =pod |
635 | =pod |
| 564 | =begin WSDL |
636 | =begin WSDL |
| 565 | _IN authenKey $string |
637 | _IN authenKey $string |
| … | |
… | |
| 569 | =cut |
641 | =cut |
| 570 | sub list_global_sets { |
642 | sub list_global_sets { |
| 571 | my ($self,$authenKey,$courseName) = @_; |
643 | my ($self,$authenKey,$courseName) = @_; |
| 572 | my $soapEnv = new WebworkSOAP($authenKey,$courseName); |
644 | my $soapEnv = new WebworkSOAP($authenKey,$courseName); |
| 573 | my @tempArray = $soapEnv->{db}->listGlobalSets; |
645 | my @tempArray = $soapEnv->{db}->listGlobalSets; |
| 574 | return \@tempArray; |
646 | return array_to_soap_string( @tempArray ); |
| 575 | } |
647 | } |
| 576 | |
|
|
| 577 | |
648 | |
| 578 | =pod |
649 | =pod |
| 579 | =begin WSDL |
650 | =begin WSDL |
| 580 | _IN authenKey $string |
651 | _IN authenKey $string |
| 581 | _IN courseName $string |
652 | _IN courseName $string |
| … | |
… | |
| 616 | =pod |
687 | =pod |
| 617 | =begin WSDL |
688 | =begin WSDL |
| 618 | _IN authenKey $string |
689 | _IN authenKey $string |
| 619 | _IN courseName $string |
690 | _IN courseName $string |
| 620 | _IN setID $string |
691 | _IN setID $string |
| 621 | _RETURN $WebworkSOAP::Classes::GlobalSet of names objects. |
692 | _RETURN $WebworkSOAP::Classes::GlobalSet |
| 622 | =end WSDL |
693 | =end WSDL |
| 623 | =cut |
694 | =cut |
| 624 | sub get_global_set { |
695 | sub get_global_set { |
| 625 | my ($self,$authenKey,$courseName,$setID) = @_; |
696 | my ($self,$authenKey,$courseName,$setID) = @_; |
| 626 | my $soapEnv = new WebworkSOAP($authenKey,$courseName); |
697 | my $soapEnv = new WebworkSOAP($authenKey,$courseName); |
| … | |
… | |
| 635 | =pod |
706 | =pod |
| 636 | =begin WSDL |
707 | =begin WSDL |
| 637 | _IN authenKey $string |
708 | _IN authenKey $string |
| 638 | _IN courseName $string |
709 | _IN courseName $string |
| 639 | _IN setID $string |
710 | _IN setID $string |
| 640 | _RETURN $integer |
711 | _RETURN $string |
| 641 | =end WSDL |
712 | =end WSDL |
| 642 | =cut |
713 | =cut |
| 643 | sub delete_global_user { |
714 | sub delete_global_set { |
| 644 | my ($self,$authenKey,$courseName,$setID) = @_; |
715 | my ($self,$authenKey,$courseName,$setID) = @_; |
| 645 | my $soapEnv = new WebworkSOAP($authenKey,$courseName); |
716 | my $soapEnv = new WebworkSOAP($authenKey,$courseName); |
| 646 | return $soapEnv->{db}->deleteGlobalSet($setID); |
717 | return SOAP::Data->type( 'string', $soapEnv->{db}->deleteGlobalSet($setID) ); |
| 647 | } |
718 | } |
| 648 | |
719 | |
| 649 | ################################################## |
720 | ################################################## |
| 650 | ##Global Problems |
721 | ##Global Problems |
| 651 | ################################################## |
722 | ################################################## |
| … | |
… | |
| 653 | =pod |
724 | =pod |
| 654 | =begin WSDL |
725 | =begin WSDL |
| 655 | _IN authenKey $string |
726 | _IN authenKey $string |
| 656 | _IN courseName $string |
727 | _IN courseName $string |
| 657 | _IN record $WebworkSOAP::Classes::GlobalProblem |
728 | _IN record $WebworkSOAP::Classes::GlobalProblem |
| 658 | _RETURN $integer |
729 | _RETURN $string |
| 659 | =end WSDL |
730 | =end WSDL |
| 660 | =cut |
731 | =cut |
| 661 | sub add_global_problem { |
732 | sub add_global_problem { |
| 662 | my ($self,$authenKey,$courseName,$record) = @_; |
733 | my ($self,$authenKey,$courseName,$record) = @_; |
| 663 | my $soapEnv = new WebworkSOAP($authenKey,$courseName); |
734 | my $soapEnv = new WebworkSOAP($authenKey,$courseName); |
| 664 | my $newGlobalProblem = $soapEnv->{db}->newGlobalProblem; |
735 | my $newGlobalProblem = $soapEnv->{db}->newGlobalProblem; |
| 665 | %$newGlobalProblem = %$record; |
736 | %$newGlobalProblem = %$record; |
| 666 | return $soapEnv->{db}->addGlobalProblem($newGlobalProblem); |
737 | return SOAP::Data->type( 'string', $soapEnv->{db}->addGlobalProblem($newGlobalProblem) ); |
| 667 | } |
738 | } |
| 668 | |
739 | |
| 669 | =pod |
740 | =pod |
| 670 | =begin WSDL |
741 | =begin WSDL |
| 671 | _IN authenKey $string |
742 | _IN authenKey $string |
| 672 | _IN courseName $string |
743 | _IN courseName $string |
| 673 | _IN record $WebworkSOAP::Classes::GlobalProblem |
744 | _IN record $WebworkSOAP::Classes::GlobalProblem |
| 674 | _RETURN $integer |
745 | _RETURN $string |
| 675 | =end WSDL |
746 | =end WSDL |
| 676 | =cut |
747 | =cut |
| 677 | sub put_global_problem { |
748 | sub put_global_problem { |
| 678 | my ($self,$authenKey,$courseName,$record) = @_; |
749 | my ($self,$authenKey,$courseName,$record) = @_; |
| 679 | my $soapEnv = new WebworkSOAP($authenKey,$courseName); |
750 | my $soapEnv = new WebworkSOAP($authenKey,$courseName); |
| 680 | return $soapEnv->{db}->putGlobalProblem($record); |
751 | return SOAP::Data->type( 'string', $soapEnv->{db}->putGlobalProblem($record) ); |
| 681 | } |
752 | } |
| 682 | |
753 | |
| 683 | =pod |
754 | =pod |
| 684 | =begin WSDL |
755 | =begin WSDL |
| 685 | _IN authenKey $string |
756 | _IN authenKey $string |
| 686 | _IN courseName $string |
757 | _IN courseName $string |
| 687 | _IN problemID $string |
758 | _IN setID $string |
| 688 | _RETURN @string of names objects. |
759 | _RETURN @string of names objects. |
| 689 | =end WSDL |
760 | =end WSDL |
| 690 | =cut |
761 | =cut |
| 691 | sub list_global_problems { |
762 | sub list_global_problems { |
| 692 | my ($self,$authenKey,$courseName,$problemID) = @_; |
763 | my ($self,$authenKey,$courseName,$setID) = @_; |
| 693 | my $soapEnv = new WebworkSOAP($authenKey,$courseName); |
764 | my $soapEnv = new WebworkSOAP($authenKey,$courseName); |
| 694 | my @tempArray = $soapEnv->{db}->listGlobalProblems($problemID); |
765 | my @tempArray = $soapEnv->{db}->listGlobalProblems($setID); |
| 695 | return \@tempArray; |
766 | return array_to_soap_string( @tempArray ); |
| 696 | } |
767 | } |
| 697 | |
768 | |
| 698 | =pod |
769 | =pod |
| 699 | =begin WSDL |
770 | =begin WSDL |
| 700 | _IN authenKey $string |
771 | _IN authenKey $string |
| … | |
… | |
| 716 | |
787 | |
| 717 | =pod |
788 | =pod |
| 718 | =begin |
789 | =begin |
| 719 | _IN authenKey $string |
790 | _IN authenKey $string |
| 720 | _IN courseName $string |
791 | _IN courseName $string |
| 721 | _IN problemIDs @string |
792 | _IN problemIDs @string An array reference: [userID setID problemID] |
| 722 | _RETURN @WebworkSOAP::Classes::GlobalProblem Array of user objects |
793 | _RETURN @WebworkSOAP::Classes::GlobalProblem Array of user objects |
| 723 | =end WSDL |
794 | =end WSDL |
| 724 | =cut |
795 | =cut |
| 725 | sub get_global_problems { |
796 | sub get_global_problems { |
| 726 | my ($self,$authenKey,$courseName,$problemIDs) = @_; |
797 | my ($self,$authenKey,$courseName,$problemIDs) = @_; |
| 727 | my $soapEnv = new WebworkSOAP($authenKey,$courseName); |
798 | my $soapEnv = new WebworkSOAP($authenKey,$courseName); |
| 728 | my @problemData = $soapEnv->{db}->getGlobalProblems(@$problemIDs); |
799 | my @problemData = $soapEnv->{db}->getGlobalProblems(@$problemIDs); |
| 729 | my @problems; |
800 | my @problems; |
| 730 | for(my $i=0;$i<@problemData;$i++) { |
801 | for(my $i=0;$i<@problemData;$i++) { |
| 731 | push(@problems,new WebworkSOAP::Classes::GlobalProblem(@problemData[$i])); |
802 | push(@problems,new WebworkSOAP::Classes::GlobalProblem(@problemData[$i])); #FIXME $problemData[$i]? |
| 732 | } |
803 | } |
| 733 | return \@problems; |
804 | return \@problems; |
| 734 | } |
805 | } |
| 735 | |
806 | |
| 736 | =pod |
807 | =pod |
| … | |
… | |
| 757 | =begin WSDL |
828 | =begin WSDL |
| 758 | _IN authenKey $string |
829 | _IN authenKey $string |
| 759 | _IN courseName $string |
830 | _IN courseName $string |
| 760 | _IN setID $string |
831 | _IN setID $string |
| 761 | _IN problemID $string |
832 | _IN problemID $string |
| 762 | _RETURN $integer |
833 | _RETURN $string |
| 763 | =end WSDL |
834 | =end WSDL |
| 764 | =cut |
835 | =cut |
| 765 | sub delete_global_problem { |
836 | sub delete_global_problem { |
| 766 | my ($self,$authenKey,$courseName,$setID,$problemID) = @_; |
837 | my ($self,$authenKey,$courseName,$setID,$problemID) = @_; |
| 767 | my $soapEnv = new WebworkSOAP($authenKey,$courseName); |
838 | my $soapEnv = new WebworkSOAP($authenKey,$courseName); |
| 768 | return $soapEnv->{db}->deleteGlobalProblem($setID,$problemID); |
839 | return SOAP::Data->type( 'string', $soapEnv->{db}->deleteGlobalProblem($setID,$problemID) ); |
| 769 | } |
840 | } |
| 770 | |
841 | |
| 771 | ################################################## |
842 | ################################################## |
| 772 | ##USER PROBLEM |
843 | ##USER PROBLEM |
| 773 | ################################################## |
844 | ################################################## |
| … | |
… | |
| 775 | =pod |
846 | =pod |
| 776 | =begin WSDL |
847 | =begin WSDL |
| 777 | _IN authenKey $string |
848 | _IN authenKey $string |
| 778 | _IN courseName $string |
849 | _IN courseName $string |
| 779 | _IN record $WebworkSOAP::Classes::UserProblem |
850 | _IN record $WebworkSOAP::Classes::UserProblem |
| 780 | _RETURN $integer |
851 | _RETURN $string |
| 781 | =end WSDL |
852 | =end WSDL |
| 782 | =cut |
853 | =cut |
| 783 | sub add_user_problem { |
854 | sub add_user_problem { |
| 784 | my ($self,$authenKey,$courseName,$record) = @_; |
855 | my ($self,$authenKey,$courseName,$record) = @_; |
| 785 | my $soapEnv = new WebworkSOAP($authenKey,$courseName); |
856 | my $soapEnv = new WebworkSOAP($authenKey,$courseName); |
| 786 | my $newUserProblem = $soapEnv->{db}->newUserProblem; |
857 | my $newUserProblem = $soapEnv->{db}->newUserProblem; |
| 787 | %$newUserProblem = %$record; |
858 | %$newUserProblem = %$record; |
| 788 | return $soapEnv->{db}->addUserProblem($newUserProblem); |
859 | return SOAP::Data->type( 'string', $soapEnv->{db}->addUserProblem($newUserProblem) ); |
| 789 | } |
860 | } |
| 790 | |
861 | |
| 791 | =pod |
862 | =pod |
| 792 | =begin WSDL |
863 | =begin WSDL |
| 793 | _IN authenKey $string |
864 | _IN authenKey $string |
| 794 | _IN courseName $string |
865 | _IN courseName $string |
| 795 | _IN record $WebworkSOAP::Classes::UserProblem |
866 | _IN record $WebworkSOAP::Classes::UserProblem |
| 796 | _RETURN $integer |
867 | _RETURN $string |
| 797 | =end WSDL |
868 | =end WSDL |
| 798 | =cut |
869 | =cut |
| 799 | sub put_user_problem { |
870 | sub put_user_problem { |
| 800 | my ($self,$authenKey,$courseName,$record) = @_; |
871 | my ($self,$authenKey,$courseName,$record) = @_; |
| 801 | my $soapEnv = new WebworkSOAP($authenKey,$courseName); |
872 | my $soapEnv = new WebworkSOAP($authenKey,$courseName); |
| 802 | return $soapEnv->{db}->putUserProblem($record); |
873 | return SOAP::Data->type( 'string', $soapEnv->{db}->putUserProblem($record) ); |
| 803 | } |
874 | } |
| 804 | |
875 | |
| 805 | =pod |
876 | =pod |
| 806 | =begin WSDL |
877 | =begin WSDL |
| 807 | _IN authenKey $string |
878 | _IN authenKey $string |
|
|
879 | _IN courseName $string |
| 808 | _IN courseName $string |
880 | _IN userID $string |
| 809 | _IN userID $string |
881 | _IN setID $string |
| 810 | _RETURN @string of names objects. |
882 | _RETURN @string of names objects. |
| 811 | =end WSDL |
883 | =end WSDL |
| 812 | =cut |
884 | =cut |
| 813 | sub list_user_problems { |
885 | sub list_user_problems { |
| 814 | my ($self,$authenKey,$courseName,$userID) = @_; |
886 | my ($self,$authenKey,$courseName,$userID,$setID) = @_; |
| 815 | my $soapEnv = new WebworkSOAP($authenKey,$courseName); |
887 | my $soapEnv = new WebworkSOAP($authenKey,$courseName); |
| 816 | my @tempArray = $soapEnv->{db}->listUserProblems($userID); |
888 | my @tempArray = $soapEnv->{db}->listUserProblems($userID,$setID); |
| 817 | return \@tempArray; |
889 | return array_to_soap_string( @tempArray ); |
| 818 | } |
890 | } |
| 819 | |
891 | |
| 820 | =pod |
892 | =pod |
| 821 | =begin WSDL |
893 | =begin WSDL |
| 822 | _IN authenKey $string |
894 | _IN authenKey $string |
| … | |
… | |
| 839 | |
911 | |
| 840 | =pod |
912 | =pod |
| 841 | =begin WSDL |
913 | =begin WSDL |
| 842 | _IN authenKey $string |
914 | _IN authenKey $string |
| 843 | _IN courseName $string |
915 | _IN courseName $string |
| 844 | _IN userProblemIDs @string |
916 | _IN userProblemIDs @string A 3 element array: { user_ID, setID, problemID } |
| 845 | _RETURN @WebworkSOAP::Classes::UserProblem of names objects. |
917 | _RETURN @WebworkSOAP::Classes::UserProblem of names objects. |
| 846 | =end WSDL |
918 | =end WSDL |
| 847 | =cut |
919 | =cut |
| 848 | sub get_user_problems { |
920 | sub get_user_problems { |
| 849 | my ($self,$authenKey,$courseName,$userProblemIDs) = @_; |
921 | my ($self,$authenKey,$courseName,$userProblemIDs) = @_; |
| … | |
… | |
| 882 | _IN authenKey $string |
954 | _IN authenKey $string |
| 883 | _IN courseName $string |
955 | _IN courseName $string |
| 884 | _IN userID $string |
956 | _IN userID $string |
| 885 | _IN setID $string |
957 | _IN setID $string |
| 886 | _IN problemID $string |
958 | _IN problemID $string |
| 887 | _RETURN $integer |
959 | _RETURN $string |
| 888 | =end WSDL |
960 | =end WSDL |
| 889 | =cut |
961 | =cut |
| 890 | sub delete_user_problem { |
962 | sub delete_user_problem { |
| 891 | my ($self,$authenKey,$courseName,$userID,$setID,$problemID) = @_; |
963 | my ($self,$authenKey,$courseName,$userID,$setID,$problemID) = @_; |
| 892 | my $soapEnv = new WebworkSOAP($authenKey,$courseName); |
964 | my $soapEnv = new WebworkSOAP($authenKey,$courseName); |
| 893 | return $soapEnv->{db}->deleteUserProblem($userID,$setID,$problemID); |
965 | return SOAP::Data->type( 'string', $soapEnv->{db}->deleteUserProblem($userID,$setID,$problemID) ); |
| 894 | } |
966 | } |
| 895 | |
967 | |
| 896 | ################################################## |
968 | ################################################## |
| 897 | ##USER SET |
969 | ##USER SET |
| 898 | ################################################## |
970 | ################################################## |
| … | |
… | |
| 900 | =pod |
972 | =pod |
| 901 | =begin WSDL |
973 | =begin WSDL |
| 902 | _IN authenKey $string |
974 | _IN authenKey $string |
| 903 | _IN courseName $string |
975 | _IN courseName $string |
| 904 | _IN record $WebworkSOAP::Classes::UserSet |
976 | _IN record $WebworkSOAP::Classes::UserSet |
| 905 | _RETURN $integer |
977 | _RETURN $string |
| 906 | =end WSDL |
978 | =end WSDL |
| 907 | =cut |
979 | =cut |
| 908 | sub add_user_set { |
980 | sub add_user_set { |
| 909 | my ($self,$authenKey,$courseName,$record) = @_; |
981 | my ($self,$authenKey,$courseName,$record) = @_; |
| 910 | my $soapEnv = new WebworkSOAP($authenKey,$courseName); |
982 | my $soapEnv = new WebworkSOAP($authenKey,$courseName); |
| 911 | my $newUserSet = $soapEnv->{db}->newUserSet; |
983 | my $newUserSet = $soapEnv->{db}->newUserSet; |
| 912 | %$newUserSet = %$record; |
984 | %$newUserSet = %$record; |
| 913 | return $soapEnv->{db}->addUserSet($newUserSet); |
985 | return SOAP::Data->type( 'string', $soapEnv->{db}->addUserSet($newUserSet) ); |
| 914 | } |
986 | } |
| 915 | |
987 | |
| 916 | =pod |
988 | =pod |
| 917 | =begin WSDL |
989 | =begin WSDL |
| 918 | _IN authenKey $string |
990 | _IN authenKey $string |
| 919 | _IN courseName $string |
991 | _IN courseName $string |
| 920 | _IN record $WebworkSOAP::Classes::UserSet |
992 | _IN record $WebworkSOAP::Classes::UserSet |
| 921 | _RETURN $integer |
993 | _RETURN $string |
| 922 | =end WSDL |
994 | =end WSDL |
| 923 | =cut |
995 | =cut |
| 924 | sub put_user_set { |
996 | sub put_user_set { |
| 925 | my ($self,$authenKey,$courseName,$record) = @_; |
997 | my ($self,$authenKey,$courseName,$record) = @_; |
| 926 | my $soapEnv = new WebworkSOAP($authenKey,$courseName); |
998 | my $soapEnv = new WebworkSOAP($authenKey,$courseName); |
| 927 | return $soapEnv->{db}->addUserSet($record); |
999 | return SOAP::Data->type( 'string', $soapEnv->{db}->addUserSet($record) ); |
| 928 | } |
1000 | } |
| 929 | |
1001 | |
| 930 | =pod |
1002 | =pod |
| 931 | =begin WSDL |
1003 | =begin WSDL |
| 932 | _IN authenKey $string |
1004 | _IN authenKey $string |
| … | |
… | |
| 937 | =cut |
1009 | =cut |
| 938 | sub list_user_sets { |
1010 | sub list_user_sets { |
| 939 | my ($self,$authenKey,$courseName,$userID) = @_; |
1011 | my ($self,$authenKey,$courseName,$userID) = @_; |
| 940 | my $soapEnv = new WebworkSOAP($authenKey,$courseName); |
1012 | my $soapEnv = new WebworkSOAP($authenKey,$courseName); |
| 941 | my @tempArray = $soapEnv->{db}->listUserSets($userID); |
1013 | my @tempArray = $soapEnv->{db}->listUserSets($userID); |
| 942 | return \@tempArray; |
1014 | return array_to_soap_string( @tempArray ); |
| 943 | } |
1015 | } |
| 944 | |
1016 | |
| 945 | =pod |
1017 | =pod |
| 946 | =begin WSDL |
1018 | =begin WSDL |
| 947 | _IN authenKey $string |
1019 | _IN authenKey $string |
| … | |
… | |
| 1003 | =begin WSDL |
1075 | =begin WSDL |
| 1004 | _IN authenKey $string |
1076 | _IN authenKey $string |
| 1005 | _IN courseName $string |
1077 | _IN courseName $string |
| 1006 | _IN userID $string |
1078 | _IN userID $string |
| 1007 | _IN setID $string |
1079 | _IN setID $string |
| 1008 | _RETURN $integer |
1080 | _RETURN $string |
| 1009 | =end WSDL |
1081 | =end WSDL |
| 1010 | =cut |
1082 | =cut |
| 1011 | sub delete_user_set { |
1083 | sub delete_user_set { |
| 1012 | my ($self,$authenKey,$courseName,$userID,$setID) = @_; |
1084 | my ($self,$authenKey,$courseName,$userID,$setID) = @_; |
| 1013 | my $soapEnv = new WebworkSOAP($authenKey,$courseName); |
1085 | my $soapEnv = new WebworkSOAP($authenKey,$courseName); |
| 1014 | return $soapEnv->{db}->deleteUserSet($userID,$setID); |
1086 | return SOAP::Data->type( 'string', $soapEnv->{db}->deleteUserSet($userID,$setID) ); |
| 1015 | } |
1087 | } |
| 1016 | |
1088 | |
| 1017 | |
1089 | |
|
|
1090 | ########################################### |
|
|
1091 | # grading utilties -- to be moved to Utils::Grades |
|
|
1092 | ############################################ |
|
|
1093 | |
|
|
1094 | ############################################ |
|
|
1095 | # get_wwassignment_grade_for_one ($db $userID $setID); |
|
|
1096 | #input $userID, $setID (or a UserSet record)? |
|
|
1097 | #output set grade for a homework problem or maximum grade for a gateway problem with several set versions |
|
|
1098 | ############################################ |
|
|
1099 | sub get_wwassignment_grade_for_one_user{ |
|
|
1100 | my($db, $userID, $setID) = @_; |
|
|
1101 | my $user_set = $db->getMergedSet($userID,$setID); |
|
|
1102 | print LOG "user $userID set $setID user_set ".ref($user_set)."\n"; |
|
|
1103 | return " " unless ref($user_set); # return a blank grade if there is no user_set |
|
|
1104 | warn " user $userID $setID ".ref($user_set)."\n"; |
|
|
1105 | my $setIsVersioned = ( defined($user_set->assignment_type) && $user_set->assignment_type =~ /gateway/)?1:0; |
|
|
1106 | my @setVersions=(); |
|
|
1107 | if ( $setIsVersioned ) { |
|
|
1108 | my @vList = $db->listSetVersions($userID,$setID); |
|
|
1109 | # we have to have the merged set versions to |
|
|
1110 | # know what each of their assignment types |
|
|
1111 | # are (because proctoring can change) |
|
|
1112 | @setVersions = $db->getMergedSetVersions( map {[$userID, $setID, $_]} @vList ); |
|
|
1113 | |
|
|
1114 | # add the set versions to our list of sets |
|
|
1115 | # foreach ( @setVersions ) { |
|
|
1116 | # $setsByID{$_->set_id . ",v" . $_->version_id} = $_; |
|
|
1117 | # } |
|
|
1118 | # # flag the existence of set versions for this set |
|
|
1119 | # $setVersionsByID{$setName} = [ @vList ]; |
|
|
1120 | # # and save the set names for display |
|
|
1121 | # push( @allSetIDs, $setName ); |
|
|
1122 | # push( @allSetIDs, map { "$setName,v$_" } @vList ); |
|
|
1123 | |
|
|
1124 | } else { |
|
|
1125 | # push( @allSetIDs, $setName ); |
|
|
1126 | # $setVersionsByID{$setName} = "None"; |
|
|
1127 | } |
|
|
1128 | my $grade; |
|
|
1129 | if ($setIsVersioned) { |
|
|
1130 | if (@setVersions) { |
|
|
1131 | $grade =0; |
|
|
1132 | foreach my $setVersion (@setVersions) { # get highest grade among versions |
|
|
1133 | #print LOG "getting set $userID $setID version:".ref($setVersion)."\n"; |
|
|
1134 | my $current_grade = get_set_grade_for_UserSet($db, $setVersion); |
|
|
1135 | $grade = $current_grade if $current_grade > $grade; |
|
|
1136 | |
|
|
1137 | } |
|
|
1138 | |
|
|
1139 | } else { |
|
|
1140 | $grade = " "; |
|
|
1141 | } |
|
|
1142 | } else { # not versioned |
|
|
1143 | $grade = get_set_grade_for_UserSet($db, $user_set); |
|
|
1144 | } |
|
|
1145 | $grade; # return grade |
|
|
1146 | } |
|
|
1147 | |
|
|
1148 | ############################################ |
|
|
1149 | # get_set_grade_for_UserSet ($db, $user_set); |
|
|
1150 | #input $userID, $setID (UserSet record); |
|
|
1151 | #output set grade for a homework problem or a single set version of a gateway quiz |
|
|
1152 | ############################################ |
|
|
1153 | |
|
|
1154 | sub get_set_grade_for_UserSet{ |
|
|
1155 | my $db = shift; |
|
|
1156 | my $user_set = shift; |
|
|
1157 | warn "get_set_grade_for_UserSet(db, user_set); an argument is missing db: $db user_set $user_set" |
|
|
1158 | unless ref($db) =~ /DB/ and ref($user_set) =~/Set/; |
|
|
1159 | my $setIsVersioned = ( defined( $user_set->assignment_type() ) |
|
|
1160 | && $user_set->assignment_type() =~ /gateway/ )? 1:0; |
|
|
1161 | my @problemData=(); |
|
|
1162 | print LOG "get_set_grade_for_UserSet: getting set ".$user_set->set_id." "." for ".$user_set->user_id."\n"; |
|
|
1163 | if ($setIsVersioned) { |
|
|
1164 | @problemData = $db->getAllMergedProblemVersions( $user_set->user_id, $user_set->set_id, $user_set->version_id ) if $user_set->can('version_id'); |
|
|
1165 | } else { |
|
|
1166 | @problemData = $db->getAllMergedUserProblems($user_set->user_id, $user_set->set_id); |
|
|
1167 | } |
|
|
1168 | |
|
|
1169 | my $grade = 0; |
|
|
1170 | for(my $i=0;$i<@problemData;$i++) { |
|
|
1171 | #print LOG "$userID problem Data",join(" ", %{$problemData[$i]}),"\n\n"; |
|
|
1172 | $grade += ($problemData[$i]->status)*($problemData[$i]->value); |
|
|
1173 | #print LOG "grade is $grade\n"; |
|
|
1174 | } |
|
|
1175 | return $grade; |
|
|
1176 | } |
| 1018 | 1; |
1177 | 1; |