| 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.pm,v 1.83 2004/03/10 02:51:57 sh002i Exp $ |
4 | # $CVSHeader: webwork-modperl/lib/WeBWorK/ContentGenerator.pm,v 1.84 2004/03/11 03:07:46 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. |
| … | |
… | |
| 42 | =cut |
42 | =cut |
| 43 | |
43 | |
| 44 | use strict; |
44 | use strict; |
| 45 | use warnings; |
45 | use warnings; |
| 46 | use Apache::Constants qw(:common); |
46 | use Apache::Constants qw(:common); |
| 47 | use CGI qw(*ul *li); |
47 | use CGI::Pretty qw(*ul *li); |
| 48 | use URI::Escape; |
48 | use URI::Escape; |
| 49 | use WeBWorK::Template qw(template); |
49 | use WeBWorK::Template qw(template); |
| 50 | |
50 | |
| 51 | ################################################################################ |
51 | ################################################################################ |
| 52 | |
52 | |
| … | |
… | |
| 370 | |
370 | |
| 371 | # to make things more concise |
371 | # to make things more concise |
| 372 | my %args = ( courseID => $courseID ); |
372 | my %args = ( courseID => $courseID ); |
| 373 | my $pfx = "WeBWorK::ContentGenerator::"; |
373 | my $pfx = "WeBWorK::ContentGenerator::"; |
| 374 | |
374 | |
|
|
375 | my $sets = $urlpath->newFromModule("${pfx}ProblemSets", %args); |
|
|
376 | my $options = $urlpath->newFromModule("${pfx}Options", %args); |
|
|
377 | my $grades = $urlpath->newFromModule("${pfx}Grades", %args); |
|
|
378 | my $logout = $urlpath->newFromModule("${pfx}Logout", %args); |
|
|
379 | |
|
|
380 | print "\n<!-- BEGIN " . __PACKAGE__ . "::links -->\n"; |
|
|
381 | print CGI::start_ul({class=>"LinksMenu"}); |
|
|
382 | print CGI::li(CGI::span({style=>"font-size:larger"}, |
|
|
383 | CGI::a({href=>$self->systemLink($sets)}, "Problem Sets"))); |
|
|
384 | print CGI::li(CGI::a({href=>$self->systemLink($options)}, $options->name)); |
|
|
385 | print CGI::li(CGI::a({href=>$self->systemLink($grades)}, $grades->name)); |
|
|
386 | print CGI::li(CGI::a({href=>$self->systemLink($logout)}, $logout->name)); |
|
|
387 | |
| 375 | my $PermissionLevel = $db->getPermissionLevel($r->param("user")); # checked |
388 | my $PermissionLevel = $db->getPermissionLevel($r->param("user")); # checked |
| 376 | my $permLevel = $PermissionLevel ? $PermissionLevel->permission : 0; |
389 | my $permLevel = $PermissionLevel ? $PermissionLevel->permission : 0; |
| 377 | |
|
|
| 378 | my $iResult = ""; |
|
|
| 379 | |
390 | |
| 380 | if ($permLevel > 0) { |
391 | if ($permLevel > 0) { |
| 381 | my $ipfx = "${pfx}Instructor::"; |
392 | my $ipfx = "${pfx}Instructor::"; |
| 382 | |
393 | |
| 383 | my $userID = $r->param("effectiveUser"); |
394 | my $userID = $r->param("effectiveUser"); |
| … | |
… | |
| 400 | my $userStats = $urlpath->newFromModule("${ipfx}Stats", %args, statType => "student", userID => $userID); |
411 | my $userStats = $urlpath->newFromModule("${ipfx}Stats", %args, statType => "student", userID => $userID); |
| 401 | my $setStats = $urlpath->newFromModule("${ipfx}Stats", %args, statType => "set", setID => $setID); |
412 | my $setStats = $urlpath->newFromModule("${ipfx}Stats", %args, statType => "set", setID => $setID); |
| 402 | |
413 | |
| 403 | my $files = $urlpath->newFromModule("${ipfx}FileXfer", %args); |
414 | my $files = $urlpath->newFromModule("${ipfx}FileXfer", %args); |
| 404 | |
415 | |
| 405 | $iResult .= CGI::start_li(); |
416 | print CGI::start_li(); |
| 406 | $iResult .= CGI::span({style=>"font-size:larger"}, CGI::a({href=>$self->systemLink($instr)}, $instr->name)); |
417 | print CGI::span({style=>"font-size:larger"}, CGI::a({href=>$self->systemLink($instr)}, $instr->name)); |
| 407 | $iResult .= CGI::start_ul(); |
418 | print CGI::start_ul(); |
| 408 | $iResult .= CGI::li(CGI::a({href=>$self->systemLink($userList)}, $userList->name)); |
419 | print CGI::li(CGI::a({href=>$self->systemLink($userList)}, $userList->name)); |
| 409 | $iResult .= CGI::start_li(); |
420 | print CGI::start_li(); |
| 410 | $iResult .= CGI::a({href=>$self->systemLink($setList)}, $setList->name); |
421 | print CGI::a({href=>$self->systemLink($setList)}, $setList->name); |
| 411 | if (defined $setID and $setID ne "") { |
422 | if (defined $setID and $setID ne "") { |
| 412 | $iResult .= CGI::start_ul(); |
423 | print CGI::start_ul(); |
| 413 | $iResult .= CGI::start_li(); |
424 | print CGI::start_li(); |
| 414 | $iResult .= CGI::a({href=>$self->systemLink($setDetail)}, $setID); |
425 | print CGI::a({href=>$self->systemLink($setDetail)}, $setID); |
| 415 | if (defined $problemID and $problemID ne "") { |
426 | if (defined $problemID and $problemID ne "") { |
| 416 | $iResult .= CGI::ul( |
427 | print CGI::ul( |
| 417 | CGI::li(CGI::a({href=>$self->systemLink($problemEditor)}, $problemID)) |
428 | CGI::li(CGI::a({href=>$self->systemLink($problemEditor)}, $problemID)) |
| 418 | ); |
429 | ); |
| 419 | } |
430 | } |
| 420 | $iResult .= CGI::end_li(); |
431 | print CGI::end_li(); |
| 421 | $iResult .= CGI::end_ul(); |
432 | print CGI::end_ul(); |
| 422 | } |
433 | } |
| 423 | $iResult .= CGI::end_li(); |
434 | print CGI::end_li(); |
| 424 | $iResult .= CGI::li(CGI::a({href=>$self->systemLink($mail)}, $mail->name)); |
435 | print CGI::li(CGI::a({href=>$self->systemLink($mail)}, $mail->name)); |
| 425 | $iResult .= CGI::li(CGI::a({href=>$self->systemLink($scoring)}, $scoring->name)); |
436 | print CGI::li(CGI::a({href=>$self->systemLink($scoring)}, $scoring->name)); |
| 426 | $iResult .= CGI::start_li(); |
437 | print CGI::start_li(); |
| 427 | $iResult .= CGI::a({href=>$self->systemLink($stats)}, $stats->name); |
438 | print CGI::a({href=>$self->systemLink($stats)}, $stats->name); |
| 428 | if (defined $userID and $userID ne "") { |
439 | if (defined $userID and $userID ne "") { |
| 429 | $iResult .= CGI::ul( |
440 | print CGI::ul( |
| 430 | CGI::li(CGI::a({href=>$self->systemLink($userStats)}, $userID)) |
441 | CGI::li(CGI::a({href=>$self->systemLink($userStats)}, $userID)) |
| 431 | ); |
442 | ); |
| 432 | } |
443 | } |
| 433 | if (defined $setID and $setID ne "") { |
444 | if (defined $setID and $setID ne "") { |
| 434 | $iResult .= CGI::ul( |
445 | print CGI::ul( |
| 435 | CGI::li(CGI::a({href=>$self->systemLink($setStats)}, $setID)) |
446 | CGI::li(CGI::a({href=>$self->systemLink($setStats)}, $setID)) |
| 436 | ); |
447 | ); |
| 437 | } |
448 | } |
| 438 | $iResult .= CGI::end_li(); |
449 | print CGI::end_li(); |
| 439 | $iResult .= CGI::li(CGI::a({href=>$self->systemLink($files)}, $files->name)); |
450 | print CGI::li(CGI::a({href=>$self->systemLink($files)}, $files->name)); |
| 440 | $iResult .= CGI::end_ul(); |
451 | print CGI::end_ul(); |
| 441 | $iResult .= CGI::end_li(); |
452 | print CGI::end_li(); |
| 442 | } |
453 | } |
| 443 | |
454 | |
| 444 | my $sets = $urlpath->newFromModule("${pfx}ProblemSets", %args); |
455 | print CGI::end_ul(); |
| 445 | my $options = $urlpath->newFromModule("${pfx}Options", %args); |
456 | print "<!-- end " . __PACKAGE__ . "::links -->\n"; |
| 446 | my $grades = $urlpath->newFromModule("${pfx}Grades", %args); |
|
|
| 447 | my $logout = $urlpath->newFromModule("${pfx}Logout", %args); |
|
|
| 448 | |
457 | |
| 449 | return CGI::ul({class=>"LinksMenu"}, |
458 | return ""; |
| 450 | CGI::li(CGI::span({style=>"font-size:larger"}, |
|
|
| 451 | CGI::a({href=>$self->systemLink($sets)}, "Problem Sets"))), |
|
|
| 452 | CGI::li(CGI::a({href=>$self->systemLink($options)}, $options->name)), |
|
|
| 453 | CGI::li(CGI::a({href=>$self->systemLink($grades)}, $grades->name)), |
|
|
| 454 | CGI::li(CGI::a({href=>$self->systemLink($logout)}, $logout->name)), |
|
|
| 455 | $iResult, |
|
|
| 456 | ); |
|
|
| 457 | } |
459 | } |
| 458 | |
460 | |
| 459 | =item loginstatus() |
461 | =item loginstatus() |
| 460 | |
462 | |
| 461 | Defined in this package. |
463 | Defined in this package. |
| … | |
… | |
| 478 | my $eUserID = $r->param("effectiveUser"); |
480 | my $eUserID = $r->param("effectiveUser"); |
| 479 | |
481 | |
| 480 | my $stopActingURL = $self->systemLink($urlpath, effectiveUserID => $userID); |
482 | my $stopActingURL = $self->systemLink($urlpath, effectiveUserID => $userID); |
| 481 | my $logoutURL = $self->systemLink($urlpath->newFromModule(__PACKAGE__ . "::Logout", courseID => $courseID)); |
483 | my $logoutURL = $self->systemLink($urlpath->newFromModule(__PACKAGE__ . "::Logout", courseID => $courseID)); |
| 482 | |
484 | |
|
|
485 | print "\n<!-- BEGIN " . __PACKAGE__ . "::loginstatus -->\n"; |
|
|
486 | |
| 483 | print "Logged in as $userID. "; |
487 | print "Logged in as $userID. "; |
| 484 | print CGI::a({href=>$logoutURL}, "Log Out"); |
488 | print CGI::a({href=>$logoutURL}, "Log Out"); |
| 485 | |
489 | |
| 486 | if ($eUserID ne $userID) { |
490 | if ($eUserID ne $userID) { |
| 487 | print " | Acting as $eUserID. "; |
491 | print " | Acting as $eUserID. "; |
| 488 | print CGI::a({href=>$stopActingURL}, "Stop Acting"); |
492 | print CGI::a({href=>$stopActingURL}, "Stop Acting"); |
| 489 | } |
493 | } |
|
|
494 | |
|
|
495 | print "<!-- END " . __PACKAGE__ . "::loginstatus -->\n"; |
| 490 | } |
496 | } |
| 491 | |
497 | |
| 492 | return ""; |
498 | return ""; |
| 493 | } |
499 | } |
| 494 | |
500 | |
| … | |
… | |
| 554 | unshift @path, $urlpath->name, $r->location . $urlpath->path; |
560 | unshift @path, $urlpath->name, $r->location . $urlpath->path; |
| 555 | } while ($urlpath = $urlpath->parent); |
561 | } while ($urlpath = $urlpath->parent); |
| 556 | |
562 | |
| 557 | $path[$#path] = ""; # we don't want the last path element to be a link |
563 | $path[$#path] = ""; # we don't want the last path element to be a link |
| 558 | |
564 | |
|
|
565 | print "\n<!-- BEGIN " . __PACKAGE__ . "::path -->\n"; |
| 559 | return $self->pathMacro($args, @path); |
566 | print $self->pathMacro($args, @path); |
|
|
567 | print "<!-- END " . __PACKAGE__ . "::path -->\n"; |
|
|
568 | |
|
|
569 | return ""; |
| 560 | } |
570 | } |
| 561 | |
571 | |
| 562 | =item siblings() |
572 | =item siblings() |
| 563 | |
573 | |
| 564 | Not defined in this package. |
574 | Not defined in this package. |
| … | |
… | |
| 580 | |
590 | |
| 581 | =cut |
591 | =cut |
| 582 | |
592 | |
| 583 | sub submiterror { |
593 | sub submiterror { |
| 584 | my ($self) = @_; |
594 | my ($self) = @_; |
| 585 | if (exists $self->{submitError}) { |
595 | |
| 586 | return $self->{submitError}; |
596 | print "\n<!-- BEGIN " . __PACKAGE__ . "::submiterror -->\n"; |
| 587 | } else { |
597 | print $self->{submitError} if exists $self->{submitError}; |
|
|
598 | print "<!-- END " . __PACKAGE__ . "::submiterror -->\n"; |
|
|
599 | |
| 588 | return ""; |
600 | return ""; |
| 589 | } |
|
|
| 590 | } |
601 | } |
| 591 | |
602 | |
| 592 | =item title() |
603 | =item title() |
| 593 | |
604 | |
| 594 | Defined in this package. |
605 | Defined in this package. |
| … | |
… | |
| 602 | |
613 | |
| 603 | sub title { |
614 | sub title { |
| 604 | my ($self, $args) = @_; |
615 | my ($self, $args) = @_; |
| 605 | my $r = $self->r; |
616 | my $r = $self->r; |
| 606 | |
617 | |
|
|
618 | |
|
|
619 | print "\n<!-- BEGIN " . __PACKAGE__ . "::title -->\n"; |
| 607 | return $r->urlpath->name; |
620 | print $r->urlpath->name; |
|
|
621 | print "<!-- END " . __PACKAGE__ . "::title -->\n"; |
|
|
622 | |
|
|
623 | return ""; |
| 608 | } |
624 | } |
| 609 | |
625 | |
| 610 | =item warnings() |
626 | =item warnings() |
| 611 | |
627 | |
| 612 | Defined in this package. |
628 | Defined in this package. |
| … | |
… | |
| 619 | =cut |
635 | =cut |
| 620 | |
636 | |
| 621 | sub warnings { |
637 | sub warnings { |
| 622 | my ($self) = @_; |
638 | my ($self) = @_; |
| 623 | my $r = $self->r; |
639 | my $r = $self->r; |
| 624 | if ($r->notes("warnings")) { |
640 | |
| 625 | return $self->warningOutput($r->notes("warnings")); |
641 | print "\n<!-- BEGIN " . __PACKAGE__ . "::warnings -->\n"; |
| 626 | } else { |
642 | print $self->warningOutput($r->notes("warnings")) if $r->notes("warnings"); |
|
|
643 | print "<!-- END " . __PACKAGE__ . "::warnings -->\n"; |
|
|
644 | |
| 627 | return ""; |
645 | return ""; |
| 628 | } |
|
|
| 629 | } |
646 | } |
| 630 | |
647 | |
| 631 | =back |
648 | =back |
| 632 | |
649 | |
| 633 | =cut |
650 | =cut |