Parent Directory
|
Revision Log
Revision 640 -
(view)
(download)
(as text)
Original Path: trunk/webwork2/lib/WeBWorK/ContentGenerator/ProblemSets.pm
| 1 : | sh002i | 455 | ################################################################################ |
| 2 : | sh002i | 494 | # WeBWorK mod_perl (c) 2000-2002 WeBWorK Project |
| 3 : | sh002i | 455 | # $Id$ |
| 4 : | ################################################################################ | ||
| 5 : | |||
| 6 : | malsyned | 353 | package WeBWorK::ContentGenerator::ProblemSets; |
| 7 : | |||
| 8 : | sh002i | 455 | =head1 NAME |
| 9 : | |||
| 10 : | WeBWorK::ContentGenerator::ProblemSets - Display a list of built problem sets. | ||
| 11 : | |||
| 12 : | =cut | ||
| 13 : | |||
| 14 : | malsyned | 441 | use strict; |
| 15 : | use warnings; | ||
| 16 : | sh002i | 455 | use base qw(WeBWorK::ContentGenerator); |
| 17 : | sh002i | 449 | use Apache::Constants qw(:common); |
| 18 : | use CGI qw(); | ||
| 19 : | malsyned | 353 | use WeBWorK::ContentGenerator; |
| 20 : | malsyned | 441 | use WeBWorK::DB::WW; |
| 21 : | sh002i | 449 | use WeBWorK::Utils qw(formatDateTime); |
| 22 : | malsyned | 353 | |
| 23 : | malsyned | 441 | sub initialize { |
| 24 : | my $self = shift; | ||
| 25 : | my $courseEnvironment = $self->{courseEnvironment}; | ||
| 26 : | |||
| 27 : | # Open a database connection that we can use for the rest of | ||
| 28 : | # the content generation. | ||
| 29 : | |||
| 30 : | my $wwdb = new WeBWorK::DB::WW $courseEnvironment; | ||
| 31 : | $self->{wwdb} = $wwdb; | ||
| 32 : | } | ||
| 33 : | |||
| 34 : | sh002i | 469 | sub path { |
| 35 : | my ($self, $args) = @_; | ||
| 36 : | |||
| 37 : | my $ce = $self->{courseEnvironment}; | ||
| 38 : | my $root = $ce->{webworkURLs}->{root}; | ||
| 39 : | my $courseName = $ce->{courseName}; | ||
| 40 : | return $self->pathMacro($args, | ||
| 41 : | "Home" => "$root", | ||
| 42 : | $courseName => "", | ||
| 43 : | ); | ||
| 44 : | } | ||
| 45 : | |||
| 46 : | malsyned | 353 | sub title { |
| 47 : | my $self = shift; | ||
| 48 : | my $courseEnvironment = $self->{courseEnvironment}; | ||
| 49 : | sh002i | 469 | |
| 50 : | return $courseEnvironment->{courseName}; | ||
| 51 : | malsyned | 353 | } |
| 52 : | |||
| 53 : | sub body { | ||
| 54 : | my $self = shift; | ||
| 55 : | my $r = $self->{r}; | ||
| 56 : | my $courseEnvironment = $self->{courseEnvironment}; | ||
| 57 : | my $user = $r->param('user'); | ||
| 58 : | malsyned | 441 | my $wwdb = $self->{wwdb}; |
| 59 : | malsyned | 353 | |
| 60 : | sh002i | 640 | print CGI::startform(-method=>"POST", -action=>$r->uri."hardcopy/"); |
| 61 : | print $self->hidden_authen_fields; | ||
| 62 : | sh002i | 449 | print CGI::start_table(); |
| 63 : | print CGI::Tr( | ||
| 64 : | sh002i | 469 | CGI::th("Sel."), |
| 65 : | sh002i | 449 | CGI::th("Name"), |
| 66 : | CGI::th("Status"), | ||
| 67 : | sh002i | 469 | CGI::th("Hardcopy"), |
| 68 : | sh002i | 449 | ); |
| 69 : | |||
| 70 : | sh002i | 469 | my @sets; |
| 71 : | push @sets, $wwdb->getSet($user, $_) foreach ($wwdb->getSets($user)); | ||
| 72 : | foreach my $set (sort { $a->open_date <=> $b->open_date } @sets) { | ||
| 73 : | print $self->setListRow($set); | ||
| 74 : | sh002i | 449 | } |
| 75 : | malsyned | 441 | |
| 76 : | sh002i | 449 | print CGI::end_table(); |
| 77 : | sh002i | 469 | print CGI::p(CGI::submit("hardcopy", "Download Harcopy for Selected Sets")); |
| 78 : | sh002i | 449 | print CGI::endform(); |
| 79 : | malsyned | 441 | |
| 80 : | sh002i | 449 | return ""; |
| 81 : | malsyned | 353 | } |
| 82 : | |||
| 83 : | sh002i | 469 | sub setListRow($$) { |
| 84 : | my $self = shift; | ||
| 85 : | sh002i | 449 | my $set = shift; |
| 86 : | |||
| 87 : | my $name = $set->id; | ||
| 88 : | |||
| 89 : | sh002i | 555 | my $interactiveURL = "$name/?" . $self->url_authen_args; |
| 90 : | my $hardcopyURL = "hardcopy/$name/?" . $self->url_authen_args; | ||
| 91 : | sh002i | 469 | |
| 92 : | sh002i | 449 | my $openDate = formatDateTime($set->open_date); |
| 93 : | my $dueDate = formatDateTime($set->due_date); | ||
| 94 : | my $answerDate = formatDateTime($set->answer_date); | ||
| 95 : | |||
| 96 : | my $checkbox = CGI::checkbox(-name=>"set", -value=>$set->id, -label=>""); | ||
| 97 : | sh002i | 469 | my $interactive = CGI::a({-href=>$interactiveURL}, $name); |
| 98 : | sh002i | 555 | my $hardcopy = CGI::a({-href=>$hardcopyURL}, "download"); |
| 99 : | sh002i | 449 | |
| 100 : | my $status; | ||
| 101 : | if (time < $set->open_date) { | ||
| 102 : | $status = "opens at $openDate"; | ||
| 103 : | $checkbox = ""; | ||
| 104 : | sh002i | 469 | $interactive = $name; |
| 105 : | sh002i | 449 | $hardcopy = ""; |
| 106 : | } elsif (time < $set->due_date) { | ||
| 107 : | $status = "open, due at $dueDate"; | ||
| 108 : | } elsif (time < $set->answer_date) { | ||
| 109 : | $status = "closed, answers at $answerDate"; | ||
| 110 : | } else { | ||
| 111 : | $status = "closed, answers available"; | ||
| 112 : | } | ||
| 113 : | |||
| 114 : | return CGI::Tr(CGI::td([ | ||
| 115 : | $checkbox, | ||
| 116 : | sh002i | 469 | $interactive, |
| 117 : | sh002i | 449 | $status, |
| 118 : | $hardcopy, | ||
| 119 : | ])); | ||
| 120 : | } | ||
| 121 : | |||
| 122 : | malsyned | 353 | 1; |
| aubreyja at gmail dot com | ViewVC Help |
| Powered by ViewVC 1.0.9 |