| 1 | ################################################################################ |
1 | ################################################################################ |
| 2 | # WeBWorK Online Homework Delivery System |
2 | # WeBWorK Online Homework Delivery System |
| 3 | # Copyright © 2000-2003 The WeBWorK Project, http://openwebwork.sf.net/ |
3 | # Copyright © 2000-2003 The WeBWorK Project, http://openwebwork.sf.net/ |
| 4 | # $CVSHeader: webwork-modperl/lib/WeBWorK/ContentGenerator/CourseAdmin.pm,v 1.10 2004/05/13 20:49:18 sh002i Exp $ |
4 | # $CVSHeader: webwork-modperl/lib/WeBWorK/ContentGenerator/CourseAdmin.pm,v 1.11 2004/05/21 20:55:38 sh002i Exp $ |
| 5 | # |
5 | # |
| 6 | # This program is free software; you can redistribute it and/or modify it under |
6 | # This program is free software; you can redistribute it and/or modify it under |
| 7 | # the terms of either: (a) the GNU General Public License as published by the |
7 | # the terms of either: (a) the GNU General Public License as published by the |
| 8 | # Free Software Foundation; either version 2, or (at your option) any later |
8 | # Free Software Foundation; either version 2, or (at your option) any later |
| 9 | # version, or (b) the "Artistic License" which comes with this package. |
9 | # version, or (b) the "Artistic License" which comes with this package. |
| … | |
… | |
| 205 | my $add_sql_database = $r->param("add_sql_database") || ""; |
205 | my $add_sql_database = $r->param("add_sql_database") || ""; |
| 206 | my $add_sql_wwhost = $r->param("add_sql_wwhost") || ""; |
206 | my $add_sql_wwhost = $r->param("add_sql_wwhost") || ""; |
| 207 | my $add_gdbm_globalUserID = $r->param("add_gdbm_globalUserID") || ""; |
207 | my $add_gdbm_globalUserID = $r->param("add_gdbm_globalUserID") || ""; |
| 208 | my $add_initial_userID = $r->param("add_initial_userID") || ""; |
208 | my $add_initial_userID = $r->param("add_initial_userID") || ""; |
| 209 | my $add_initial_password = $r->param("add_initial_password") || ""; |
209 | my $add_initial_password = $r->param("add_initial_password") || ""; |
|
|
210 | my $add_templates_course = $r->param("add_templates_course") || ""; |
| 210 | |
211 | |
| 211 | my @dbLayouts = sort keys %{ $ce->{dbLayouts} }; |
212 | my @dbLayouts = sort keys %{ $ce->{dbLayouts} }; |
| 212 | |
213 | |
| 213 | my $ce2 = WeBWorK::CourseEnvironment->new( |
214 | my $ce2 = WeBWorK::CourseEnvironment->new( |
| 214 | $ce->{webworkDirs}->{root}, |
215 | $ce->{webworkDirs}->{root}, |
| … | |
… | |
| 232 | } else { |
233 | } else { |
| 233 | ($source) = keys %sources; |
234 | ($source) = keys %sources; |
| 234 | } |
235 | } |
| 235 | $source; |
236 | $source; |
| 236 | }; |
237 | }; |
|
|
238 | |
|
|
239 | my @existingCourses = listCourses($ce); |
| 237 | |
240 | |
| 238 | print CGI::h2("Add Course"); |
241 | print CGI::h2("Add Course"); |
| 239 | |
242 | |
| 240 | print CGI::start_form("POST", $r->uri); |
243 | print CGI::start_form("POST", $r->uri); |
| 241 | print $self->hidden_authen_fields; |
244 | print $self->hidden_authen_fields; |
| … | |
… | |
| 346 | CGI::th({class=>"LeftHeader"}, "Professor Password:"), |
349 | CGI::th({class=>"LeftHeader"}, "Professor Password:"), |
| 347 | CGI::td(CGI::password_field("add_initial_password", $add_initial_password, 25)), |
350 | CGI::td(CGI::password_field("add_initial_password", $add_initial_password, 25)), |
| 348 | ), |
351 | ), |
| 349 | ); |
352 | ); |
| 350 | |
353 | |
|
|
354 | print CGI::p("Select an existing course from which to copy templates:"); |
|
|
355 | |
|
|
356 | print CGI::table({class=>"FormLayout"}, |
|
|
357 | CGI::Tr( |
|
|
358 | CGI::th({class=>"LeftHeader"}, "Copy templates from:"), |
|
|
359 | CGI::td( |
|
|
360 | CGI::popup_menu( |
|
|
361 | -name => "add_templates_course", |
|
|
362 | -values => [ "", @existingCourses ], |
|
|
363 | -default => $add_templates_course, |
|
|
364 | #-size => 10, |
|
|
365 | #-multiple => 0, |
|
|
366 | #-labels => \%courseLabels, |
|
|
367 | ), |
|
|
368 | |
|
|
369 | ), |
|
|
370 | ), |
|
|
371 | ); |
|
|
372 | |
| 351 | print CGI::p({style=>"text-align: center"}, CGI::submit("add_course", "Add Course")); |
373 | print CGI::p({style=>"text-align: center"}, CGI::submit("add_course", "Add Course")); |
| 352 | |
374 | |
| 353 | print CGI::end_form(); |
375 | print CGI::end_form(); |
| 354 | } |
376 | } |
| 355 | |
377 | |
| … | |
… | |
| 370 | my $add_sql_database = $r->param("add_sql_database") || ""; |
392 | my $add_sql_database = $r->param("add_sql_database") || ""; |
| 371 | my $add_sql_wwhost = $r->param("add_sql_wwhost") || ""; |
393 | my $add_sql_wwhost = $r->param("add_sql_wwhost") || ""; |
| 372 | my $add_gdbm_globalUserID = $r->param("add_gdbm_globalUserID") || ""; |
394 | my $add_gdbm_globalUserID = $r->param("add_gdbm_globalUserID") || ""; |
| 373 | my $add_initial_userID = $r->param("add_initial_userID") || ""; |
395 | my $add_initial_userID = $r->param("add_initial_userID") || ""; |
| 374 | my $add_initial_password = $r->param("add_initial_password") || ""; |
396 | my $add_initial_password = $r->param("add_initial_password") || ""; |
|
|
397 | my $add_templates_course = $r->param("add_templates_course") || ""; |
| 375 | |
398 | |
| 376 | my @errors; |
399 | my @errors; |
| 377 | |
400 | |
| 378 | if ($add_courseID eq "") { |
401 | if ($add_courseID eq "") { |
| 379 | push @errors, "You must specify a course name."; |
402 | push @errors, "You must specify a course name."; |
| … | |
… | |
| 420 | my $add_sql_database = $r->param("add_sql_database") || ""; |
443 | my $add_sql_database = $r->param("add_sql_database") || ""; |
| 421 | my $add_sql_wwhost = $r->param("add_sql_wwhost") || ""; |
444 | my $add_sql_wwhost = $r->param("add_sql_wwhost") || ""; |
| 422 | my $add_gdbm_globalUserID = $r->param("add_gdbm_globalUserID") || ""; |
445 | my $add_gdbm_globalUserID = $r->param("add_gdbm_globalUserID") || ""; |
| 423 | my $add_initial_userID = $r->param("add_initial_userID") || ""; |
446 | my $add_initial_userID = $r->param("add_initial_userID") || ""; |
| 424 | my $add_initial_password = $r->param("add_initial_password") || ""; |
447 | my $add_initial_password = $r->param("add_initial_password") || ""; |
|
|
448 | my $add_templates_course = $r->param("add_templates_course") || ""; |
| 425 | |
449 | |
| 426 | my $ce2 = WeBWorK::CourseEnvironment->new( |
450 | my $ce2 = WeBWorK::CourseEnvironment->new( |
| 427 | $ce->{webworkDirs}->{root}, |
451 | $ce->{webworkDirs}->{root}, |
| 428 | $ce->{webworkURLs}->{root}, |
452 | $ce->{webworkURLs}->{root}, |
| 429 | $ce->{pg}->{directories}->{root}, |
453 | $ce->{pg}->{directories}->{root}, |
| … | |
… | |
| 460 | permission => "10", |
484 | permission => "10", |
| 461 | ); |
485 | ); |
| 462 | push @users, [ $User, $Password, $PermissionLevel ]; |
486 | push @users, [ $User, $Password, $PermissionLevel ]; |
| 463 | } |
487 | } |
| 464 | |
488 | |
|
|
489 | my %optional_arguments; |
|
|
490 | if ($add_templates_course ne "") { |
|
|
491 | $optional_arguments{templatesFrom} = $add_templates_course; |
|
|
492 | } |
|
|
493 | |
| 465 | eval { |
494 | eval { |
| 466 | addCourse( |
495 | addCourse( |
| 467 | courseID => $add_courseID, |
496 | courseID => $add_courseID, |
| 468 | ce => $ce2, |
497 | ce => $ce2, |
| 469 | courseOptions => \%courseOptions, |
498 | courseOptions => \%courseOptions, |
| 470 | dbOptions => \%dbOptions, |
499 | dbOptions => \%dbOptions, |
| 471 | users => \@users, |
500 | users => \@users, |
|
|
501 | %optional_arguments, |
| 472 | ); |
502 | ); |
| 473 | }; |
503 | }; |
| 474 | |
504 | |
| 475 | if ($@) { |
505 | if ($@) { |
| 476 | my $error = $@; |
506 | my $error = $@; |