[system] / branches / rel-2-4-patches / webwork-modperl / lib / WeBWorK / ContentGenerator / CourseAdmin.pm Repository:
ViewVC logotype

Diff of /branches/rel-2-4-patches/webwork-modperl/lib/WeBWorK/ContentGenerator/CourseAdmin.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 2253 Revision 2254
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.13 2004/05/23 23:59:41 sh002i Exp $ 4# $CVSHeader: webwork-modperl/lib/WeBWorK/ContentGenerator/CourseAdmin.pm,v 1.14 2004/06/02 18:21:38 gage 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.
194 my $ce = $r->ce; 194 my $ce = $r->ce;
195 #my $db = $r->db; 195 #my $db = $r->db;
196 #my $authz = $r->authz; 196 #my $authz = $r->authz;
197 #my $urlpath = $r->urlpath; 197 #my $urlpath = $r->urlpath;
198 198
199 my $add_courseID = $r->param("add_courseID") || ""; 199 my $add_courseID = $r->param("add_courseID") || "";
200 my $add_dbLayout = $r->param("add_dbLayout") || ""; 200 my $add_dbLayout = $r->param("add_dbLayout") || "";
201 my $add_sql_host = $r->param("add_sql_host") || ""; 201 my $add_sql_host = $r->param("add_sql_host") || "";
202 my $add_sql_port = $r->param("add_sql_port") || ""; 202 my $add_sql_port = $r->param("add_sql_port") || "";
203 my $add_sql_username = $r->param("add_sql_username") || ""; 203 my $add_sql_username = $r->param("add_sql_username") || "";
204 my $add_sql_password = $r->param("add_sql_password") || ""; 204 my $add_sql_password = $r->param("add_sql_password") || "";
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_initial_password_confirm = $r->param("add_initial_password_confirm") || "";
210 my $add_feedback_email = $r->param("add_feedback_email") || ""; 211 my $add_feedback_email = $r->param("add_feedback_email") || "";
211 my $add_templates_course = $r->param("add_templates_course") || ""; 212 my $add_templates_course = $r->param("add_templates_course") || "";
212 my $add_contact_person = $r->param("add_contact_person") || ""; 213 my $add_contact_person = $r->param("add_contact_person") || "";
213 my $add_contact_institution = $r->param("add_contact_institution") || ""; 214 my $add_contact_institution = $r->param("add_contact_institution") || "";
214 my $add_course_title = $r->param("add_course_title") || ""; 215 my $add_course_title = $r->param("add_course_title") || "";
215 my $add_contact_email = $r->param("add_contact_email") || ""; 216 my $add_contact_email = $r->param("add_contact_email") || "";
216 my $add_admin_userID = $r->param("add_admin_userID") || $r->param("user") || ""; 217 my $add_admin_userID = $r->param("add_admin_userID") || $r->param("user") || "";
217 my $add_admin_password = $r->param("add_admin_password") || ""; 218 my $add_admin_password = $r->param("add_admin_password") || "";
218 219
219 my @dbLayouts = sort keys %{ $ce->{dbLayouts} }; 220 my @dbLayouts = sort keys %{ $ce->{dbLayouts} };
220 221
221 my $ce2 = WeBWorK::CourseEnvironment->new( 222 my $ce2 = WeBWorK::CourseEnvironment->new(
222 $ce->{webworkDirs}->{root}, 223 $ce->{webworkDirs}->{root},
264 265
265 print CGI::p("To add an initial user to the new course, enter a user ID and password below. If you do not do so, you will not be able to log into the course."); 266 print CGI::p("To add an initial user to the new course, enter a user ID and password below. If you do not do so, you will not be able to log into the course.");
266 267
267 print CGI::table({class=>"FormLayout"}, 268 print CGI::table({class=>"FormLayout"},
268 CGI::Tr( 269 CGI::Tr(
269 CGI::th({class=>"CenterHeader"}, "Professor User ID"), 270 CGI::th({class=>"CenterHeader"}, "Instructor ID"),
270 CGI::th({class=>"CenterHeader"}, "Professor Password"), 271 CGI::th({class=>"CenterHeader"}, "Instructor Password"),
271 CGI::th({class=>"CenterHeader"}, "Feedback email"), 272 CGI::th({class=>"CenterHeader"}, "Confirm Instructor Password"),
273
272 274
273 ), 275 ),
274 CGI::Tr( 276 CGI::Tr(
275 CGI::td(CGI::textfield("add_initial_userID", $add_initial_userID || "professor", 25)), 277 CGI::td(CGI::textfield("add_initial_userID", $add_initial_userID || "professor", 25)),
276 CGI::td(CGI::password_field("add_initial_password", $add_initial_password, 25)), 278 CGI::td(CGI::password_field("add_initial_password", $add_initial_password, 25)),
277 CGI::td(CGI::textfield("add_feedback_email", $add_feedback_email, 25)), 279 CGI::td(CGI::password_field("add_initial_password_confirm", $add_initial_password_confirm, 25)),
280
278 ), 281 ),
279 282
280 CGI::Tr( 283 CGI::Tr(
281 CGI::th({class=>"CenterHeader"}, "Contact name"), 284 CGI::th({class=>"CenterHeader"}, "Contact name"),
282 CGI::th({class=>"CenterHeader"}, "Contact institution"), 285 CGI::th({class=>"CenterHeader"}, "Contact institution"),
286 CGI::td(CGI::textfield("add_contact_person", $add_contact_person, 35)), 289 CGI::td(CGI::textfield("add_contact_person", $add_contact_person, 35)),
287 CGI::td(CGI::textfield("add_contact_institution", $add_contact_institution, 35)), 290 CGI::td(CGI::textfield("add_contact_institution", $add_contact_institution, 35)),
288 CGI::td(CGI::textfield("add_contact_email", $add_contact_email, 35)), 291 CGI::td(CGI::textfield("add_contact_email", $add_contact_email, 35)),
289 ), 292 ),
290 CGI::Tr( 293 CGI::Tr(
291 CGI::th({class=>"CenterHeader"}, "Administrator User ID"), 294 CGI::th({class=>"CenterHeader"}, "Administrator ID"),
292 CGI::th({class=>"CenterHeader"}, "Administrator Password"), 295 CGI::th({class=>"CenterHeader"}, "Administrator Password"),
293 CGI::th({class=>"CenterHeader"}, " "), 296 CGI::th({class=>"CenterHeader"}, "Feedback e-mail"),
294 297
295 ), 298 ),
296 CGI::Tr( 299 CGI::Tr(
297 CGI::td(CGI::textfield("add_admin_userID", $add_admin_userID, 25)), 300 CGI::td(CGI::textfield("add_admin_userID", $add_admin_userID, 25)),
298 CGI::td(CGI::password_field("add_admin_password", $add_admin_password, 25)), 301 CGI::td(CGI::password_field("add_admin_password", $add_admin_password, 25)),
299 CGI::td(' '), 302 CGI::td(CGI::textfield("add_feedback_email", $add_feedback_email, 25)),
303 ),
304 );
305
306 print CGI::p("Select an existing course from which to copy templates:");
307
308 print CGI::table({class=>"FormLayout"},
309 CGI::Tr(
310 CGI::th({class=>"LeftHeader"}, "Copy templates from:"),
311 CGI::td(
312 CGI::popup_menu(
313 -name => "add_templates_course",
314 -values => [ "", @existingCourses ],
315 -default => $add_templates_course,
316 #-size => 10,
317 #-multiple => 0,
318 #-labels => \%courseLabels,
319 ),
320
300 ), 321 ),
322 ),
301 ); 323 );
324
302 print CGI::p("Select a database layout below. Some database layouts require additional information."); 325 print CGI::p("Select a database layout below. Some database layouts require additional information.");
303 326
304 #print CGI::start_Tr(); 327 #print CGI::start_Tr();
305 #print CGI::th({class=>"LeftHeader"}, "Database Layout:"); 328 #print CGI::th({class=>"LeftHeader"}, "Database Layout:");
306 #print CGI::start_td(); 329 #print CGI::start_td();
320 print CGI::start_Tr(); 343 print CGI::start_Tr();
321 print CGI::td(); # for indentation :( 344 print CGI::td(); # for indentation :(
322 print CGI::start_td(); 345 print CGI::start_td();
323 346
324 if ($dbLayout eq "sql") { 347 if ($dbLayout eq "sql") {
325 print CGI::p( 348
326 "The SQL settings you enter below must match the settings in the DBI source", 349 print CGI::start_table({class=>"FormLayout"});
327 " specification ", CGI::tt($dbi_source), ". Replace ", CGI::tt("COURSENAME"), 350 print CGI::Tr(CGI::td({colspan=>2},
328 " with the course name you entered above." 351 "The SQL Admin is a user in the SQL database with sufficient permissions to create a new database."
352 )
329 ); 353 );
330 print CGI::start_table({class=>"FormLayout"}); 354 print CGI::Tr(
355 CGI::th({class=>"LeftHeader"}, "SQL Admin Username:"),
356 CGI::td(CGI::textfield("add_sql_username", $add_sql_username, 25)),
357 );
358 print CGI::Tr(
359 CGI::th({class=>"LeftHeader"}, "SQL Admin Password:"),
360 CGI::td(CGI::password_field("add_sql_password", $add_sql_password, 25)),
361 );
362
363 print CGI::Tr(CGI::td({colspan=>2}, CGI::hr(),
364 "The optionial SQL settings you enter below must match the settings in the DBI source",
365 " specification ", CGI::tt($dbi_source), ". Replace ", CGI::tt("COURSENAME"),
366 " with the course name you entered above."
367 )
368 );
331 print CGI::Tr( 369 print CGI::Tr(
332 CGI::th({class=>"LeftHeader"}, "SQL Server Host:"), 370 CGI::th({class=>"LeftHeader"}, "SQL Server Host:"),
333 CGI::td( 371 CGI::td(
334 CGI::textfield("add_sql_host", $add_sql_host, 25), 372 CGI::textfield("add_sql_host", $add_sql_host, 25),
335 CGI::br(), 373 CGI::br(),
342 CGI::textfield("add_sql_port", $add_sql_port, 25), 380 CGI::textfield("add_sql_port", $add_sql_port, 25),
343 CGI::br(), 381 CGI::br(),
344 CGI::small("Leave blank to use the default port."), 382 CGI::small("Leave blank to use the default port."),
345 ), 383 ),
346 ); 384 );
347 print CGI::Tr( 385
348 CGI::th({class=>"LeftHeader"}, "SQL Admin Username:"),
349 CGI::td(CGI::textfield("add_sql_username", $add_sql_username, 25)),
350 );
351 print CGI::Tr(
352 CGI::th({class=>"LeftHeader"}, "SQL Admin Password:"),
353 CGI::td(CGI::password_field("add_sql_password", $add_sql_password, 25)),
354 );
355 print CGI::Tr( 386 print CGI::Tr(
356 CGI::th({class=>"LeftHeader"}, "SQL Database Name:"), 387 CGI::th({class=>"LeftHeader"}, "SQL Database Name:"),
357 CGI::td( 388 CGI::td(
358 CGI::textfield("add_sql_database", $add_sql_database, 25), 389 CGI::textfield("add_sql_database", $add_sql_database, 25),
359 CGI::br(), 390 CGI::br(),
385 416
386 417
387 418
388 419
389 420
390 print CGI::p("Select an existing course from which to copy templates:");
391
392 print CGI::table({class=>"FormLayout"},
393 CGI::Tr(
394 CGI::th({class=>"LeftHeader"}, "Copy templates from:"),
395 CGI::td(
396 CGI::popup_menu(
397 -name => "add_templates_course",
398 -values => [ "", @existingCourses ],
399 -default => $add_templates_course,
400 #-size => 10,
401 #-multiple => 0,
402 #-labels => \%courseLabels,
403 ),
404 421
405 ),
406 ),
407 );
408 422
409 print CGI::p({style=>"text-align: center"}, CGI::submit("add_course", "Add Course")); 423 print CGI::p({style=>"text-align: center"}, CGI::submit("add_course", "Add Course"));
410 424
411 print CGI::end_form(); 425 print CGI::end_form();
412} 426}
417 my $ce = $r->ce; 431 my $ce = $r->ce;
418 #my $db = $r->db; 432 #my $db = $r->db;
419 #my $authz = $r->authz; 433 #my $authz = $r->authz;
420 #my $urlpath = $r->urlpath; 434 #my $urlpath = $r->urlpath;
421 435
422 my $add_courseID = $r->param("add_courseID") || ""; 436 my $add_courseID = $r->param("add_courseID") || "";
423 my $add_dbLayout = $r->param("add_dbLayout") || ""; 437 my $add_dbLayout = $r->param("add_dbLayout") || "";
424 my $add_sql_host = $r->param("add_sql_host") || ""; 438 my $add_sql_host = $r->param("add_sql_host") || "";
425 my $add_sql_port = $r->param("add_sql_port") || ""; 439 my $add_sql_port = $r->param("add_sql_port") || "";
426 my $add_sql_username = $r->param("add_sql_username") || ""; 440 my $add_sql_username = $r->param("add_sql_username") || "";
427 my $add_sql_password = $r->param("add_sql_password") || ""; 441 my $add_sql_password = $r->param("add_sql_password") || "";
428 my $add_sql_database = $r->param("add_sql_database") || ""; 442 my $add_sql_database = $r->param("add_sql_database") || "";
429 my $add_sql_wwhost = $r->param("add_sql_wwhost") || ""; 443 my $add_sql_wwhost = $r->param("add_sql_wwhost") || "";
430 my $add_gdbm_globalUserID = $r->param("add_gdbm_globalUserID") || ""; 444 my $add_gdbm_globalUserID = $r->param("add_gdbm_globalUserID") || "";
431 my $add_initial_userID = $r->param("add_initial_userID") || ""; 445 my $add_initial_userID = $r->param("add_initial_userID") || "";
432 my $add_initial_password = $r->param("add_initial_password") || ""; 446 my $add_initial_password = $r->param("add_initial_password") || "";
447 my $add_initial_password_confirm = $r->param("add_initial_password_confirm") || "";
433 my $add_templates_course = $r->param("add_templates_course") || ""; 448 my $add_templates_course = $r->param("add_templates_course") || "";
434 my $add_contact_person = $r->param("add_contact_person") || ""; 449 my $add_contact_person = $r->param("add_contact_person") || "";
435 my $add_contact_institution = $r->param("add_contact_institution") || ""; 450 my $add_contact_institution = $r->param("add_contact_institution") || "";
436 my $add_contact_email = $r->param("add_contact_email") || ""; 451 my $add_contact_email = $r->param("add_contact_email") || "";
437 my $add_course_title = $r->param("add_course_title") || ""; 452 my $add_course_title = $r->param("add_course_title") || "";
438 my $add_admin_userID = $r->param("add_admin_userID") || ""; 453 my $add_admin_userID = $r->param("add_admin_userID") || "";
439 my $add_admin_password = $r->param("add_admin_password") || ""; 454 my $add_admin_password = $r->param("add_admin_password") || "";
440 455
441 my @errors; 456 my @errors;
442 457
443 if ($add_courseID eq "") { 458 if ($add_courseID eq "") {
444 push @errors, "You must specify a course name."; 459 push @errors, "You must specify a course name.";
450 push @errors, "You must specify a contact person."; 465 push @errors, "You must specify a contact person.";
451 } 466 }
452 if ($add_contact_email eq "") { 467 if ($add_contact_email eq "") {
453 push @errors, "You must specify an email address for the contact person." ; 468 push @errors, "You must specify an email address for the contact person." ;
454 } 469 }
470 if ($add_initial_password ne $add_initial_password_confirm) {
471 push @errors, "The instructor's passwords don't match";
472 }
455 if ($add_course_title eq "") { 473 if ($add_course_title eq "") {
456 push @errors, "You must specify a title for the course."; 474 push @errors, "You must specify a title for the course.";
457 } 475 }
458
459 476
460 if ($add_dbLayout eq "") { 477 if ($add_dbLayout eq "") {
461 push @errors, "You must select a database layout."; 478 push @errors, "You must select a database layout.";
462 } else { 479 } else {
463 if (exists $ce->{dbLayouts}->{$add_dbLayout}) { 480 if (exists $ce->{dbLayouts}->{$add_dbLayout}) {
585 my $error = $@; 602 my $error = $@;
586 print CGI::div({class=>"ResultsWithError"}, 603 print CGI::div({class=>"ResultsWithError"},
587 CGI::p("An error occured while creating the course $add_courseID:"), 604 CGI::p("An error occured while creating the course $add_courseID:"),
588 CGI::tt(CGI::escapeHTML($error)), 605 CGI::tt(CGI::escapeHTML($error)),
589 ); 606 );
607 # get rid of any partially built courses
608 # FIXME -- this is too fragile
609 unless ($error =~ /course exists/) {
610 eval {
611 deleteCourse(
612 courseID => $add_courseID,
613 ce => $ce2,
614 dbOptions => \%dbOptions,
615 );
616 }
617 }
590 } else { 618 } else {
591 writeLog($ce, "hosted_courses", join("\t", 619 writeLog($ce, "hosted_courses", join("\t",
592 "\tAdded", 620 "\tAdded",
593 $add_contact_institution, 621 $add_contact_institution,
594 $add_course_title, 622 $add_course_title,

Legend:
Removed from v.2253  
changed lines
  Added in v.2254

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9