Parent Directory
|
Revision Log
Revision 449 -
(view)
(download)
(as text)
Original Path: trunk/webwork2/lib/WeBWorK/ContentGenerator/ProblemSets.pm
| 1 : | malsyned | 353 | package WeBWorK::ContentGenerator::ProblemSets; |
| 2 : | our @ISA = qw(WeBWorK::ContentGenerator); | ||
| 3 : | |||
| 4 : | malsyned | 441 | use strict; |
| 5 : | use warnings; | ||
| 6 : | sh002i | 449 | use Apache::Constants qw(:common); |
| 7 : | use CGI qw(); | ||
| 8 : | malsyned | 353 | use WeBWorK::ContentGenerator; |
| 9 : | malsyned | 441 | use WeBWorK::DB::WW; |
| 10 : | sh002i | 449 | use WeBWorK::Utils qw(formatDateTime); |
| 11 : | malsyned | 353 | |
| 12 : | malsyned | 441 | sub initialize { |
| 13 : | my $self = shift; | ||
| 14 : | my $courseEnvironment = $self->{courseEnvironment}; | ||
| 15 : | |||
| 16 : | # Open a database connection that we can use for the rest of | ||
| 17 : | # the content generation. | ||
| 18 : | |||
| 19 : | my $wwdb = new WeBWorK::DB::WW $courseEnvironment; | ||
| 20 : | $self->{wwdb} = $wwdb; | ||
| 21 : | } | ||
| 22 : | |||
| 23 : | malsyned | 353 | sub title { |
| 24 : | my $self = shift; | ||
| 25 : | my $r = $self->{r}; | ||
| 26 : | my $courseEnvironment = $self->{courseEnvironment}; | ||
| 27 : | my $user = $r->param('user'); | ||
| 28 : | |||
| 29 : | return "Problem Sets for $user"; | ||
| 30 : | } | ||
| 31 : | |||
| 32 : | sub body { | ||
| 33 : | my $self = shift; | ||
| 34 : | my $r = $self->{r}; | ||
| 35 : | my $courseEnvironment = $self->{courseEnvironment}; | ||
| 36 : | my $user = $r->param('user'); | ||
| 37 : | malsyned | 441 | my $wwdb = $self->{wwdb}; |
| 38 : | malsyned | 353 | |
| 39 : | sh002i | 449 | # if (!defined $wwdb->getSets($user)) { |
| 40 : | # print "undefined".CGI::br(); | ||
| 41 : | # } | ||
| 42 : | malsyned | 441 | |
| 43 : | sh002i | 449 | print CGI::startform(-method=>"POST", -action=>$r->uri); |
| 44 : | print CGI::start_table(); | ||
| 45 : | print CGI::Tr( | ||
| 46 : | CGI::th(""), | ||
| 47 : | CGI::th("Name"), | ||
| 48 : | CGI::th("Status"), | ||
| 49 : | CGI::th({-colspan=>2}, "Actions"), | ||
| 50 : | ); | ||
| 51 : | |||
| 52 : | malsyned | 441 | my @setNames = $wwdb->getSets($user); |
| 53 : | sh002i | 449 | foreach my $setName (sort @setNames) { |
| 54 : | my $set = $wwdb->getSet($user, $setName); | ||
| 55 : | print setListRow($set); | ||
| 56 : | } | ||
| 57 : | malsyned | 441 | |
| 58 : | sh002i | 449 | print CGI::end_table(); |
| 59 : | print CGI::endform(); | ||
| 60 : | malsyned | 441 | |
| 61 : | sh002i | 449 | return ""; |
| 62 : | |||
| 63 : | # print "Set Names", CGI::br(), "\n"; | ||
| 64 : | # print join(CGI::br()."\n", sort @setNames); | ||
| 65 : | # print CGI::p(); | ||
| 66 : | # | ||
| 67 : | # print CGI::startform({-method=>"POST", -action=>$r->uri."set0/"}); | ||
| 68 : | # print $self->hidden_authen_fields; | ||
| 69 : | # print CGI::input({-type=>"submit", -value=>"Do Set 0"}); | ||
| 70 : | # print CGI::endform(); | ||
| 71 : | # ""; | ||
| 72 : | malsyned | 353 | } |
| 73 : | |||
| 74 : | sh002i | 449 | sub setListRow($) { |
| 75 : | my $set = shift; | ||
| 76 : | |||
| 77 : | my $name = $set->id; | ||
| 78 : | |||
| 79 : | my $openDate = formatDateTime($set->open_date); | ||
| 80 : | my $dueDate = formatDateTime($set->due_date); | ||
| 81 : | my $answerDate = formatDateTime($set->answer_date); | ||
| 82 : | |||
| 83 : | my $checkbox = CGI::checkbox(-name=>"set", -value=>$set->id, -label=>""); | ||
| 84 : | my $interactive = CGI::submit("", "do problem set"); | ||
| 85 : | my $hardcopy = CGI::submit("", "get hard copy"); | ||
| 86 : | |||
| 87 : | my $status; | ||
| 88 : | if (time < $set->open_date) { | ||
| 89 : | $status = "opens at $openDate"; | ||
| 90 : | $checkbox = ""; | ||
| 91 : | $interactive = ""; | ||
| 92 : | $hardcopy = ""; | ||
| 93 : | } elsif (time < $set->due_date) { | ||
| 94 : | $status = "open, due at $dueDate"; | ||
| 95 : | } elsif (time < $set->answer_date) { | ||
| 96 : | $status = "closed, answers at $answerDate"; | ||
| 97 : | } else { | ||
| 98 : | $status = "closed, answers available"; | ||
| 99 : | } | ||
| 100 : | |||
| 101 : | return CGI::Tr(CGI::td([ | ||
| 102 : | $checkbox, | ||
| 103 : | $name, | ||
| 104 : | $status, | ||
| 105 : | $interactive, | ||
| 106 : | $hardcopy, | ||
| 107 : | ])); | ||
| 108 : | } | ||
| 109 : | |||
| 110 : | malsyned | 353 | 1; |
| aubreyja at gmail dot com | ViewVC Help |
| Powered by ViewVC 1.0.9 |