| … | |
… | |
| 29 | |
29 | |
| 30 | my $wwdb = new WeBWorK::DB::WW $courseEnvironment; |
30 | my $wwdb = new WeBWorK::DB::WW $courseEnvironment; |
| 31 | $self->{wwdb} = $wwdb; |
31 | $self->{wwdb} = $wwdb; |
| 32 | } |
32 | } |
| 33 | |
33 | |
|
|
34 | 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 | |
| 34 | sub title { |
46 | sub title { |
| 35 | my $self = shift; |
47 | my $self = shift; |
| 36 | my $r = $self->{r}; |
|
|
| 37 | my $courseEnvironment = $self->{courseEnvironment}; |
48 | my $courseEnvironment = $self->{courseEnvironment}; |
| 38 | my $user = $r->param('user'); |
49 | |
| 39 | |
50 | return $courseEnvironment->{courseName}; |
| 40 | return "Problem Sets for $user"; |
|
|
| 41 | } |
51 | } |
| 42 | |
52 | |
| 43 | sub body { |
53 | sub body { |
| 44 | my $self = shift; |
54 | my $self = shift; |
| 45 | my $r = $self->{r}; |
55 | my $r = $self->{r}; |
| 46 | my $courseEnvironment = $self->{courseEnvironment}; |
56 | my $courseEnvironment = $self->{courseEnvironment}; |
| 47 | my $user = $r->param('user'); |
57 | my $user = $r->param('user'); |
| 48 | my $wwdb = $self->{wwdb}; |
58 | my $wwdb = $self->{wwdb}; |
| 49 | |
59 | |
| 50 | # if (!defined $wwdb->getSets($user)) { |
|
|
| 51 | # print "undefined".CGI::br(); |
|
|
| 52 | # } |
|
|
| 53 | |
|
|
| 54 | print CGI::startform(-method=>"POST", -action=>$r->uri); |
60 | print CGI::startform(-method=>"POST", -action=>$r->uri."/hardcopy"); |
| 55 | print CGI::start_table(); |
61 | print CGI::start_table(); |
| 56 | print CGI::Tr( |
62 | print CGI::Tr( |
| 57 | CGI::th(""), |
63 | CGI::th("Sel."), |
| 58 | CGI::th("Name"), |
64 | CGI::th("Name"), |
| 59 | CGI::th("Status"), |
65 | CGI::th("Status"), |
| 60 | CGI::th({-colspan=>2}, "Actions"), |
66 | CGI::th("Hardcopy"), |
| 61 | ); |
67 | ); |
| 62 | |
68 | |
| 63 | my @setNames = $wwdb->getSets($user); |
69 | my @sets; |
| 64 | foreach my $setName (sort @setNames) { |
70 | push @sets, $wwdb->getSet($user, $_) foreach ($wwdb->getSets($user)); |
| 65 | my $set = $wwdb->getSet($user, $setName); |
71 | foreach my $set (sort { $a->open_date <=> $b->open_date } @sets) { |
| 66 | print setListRow($set); |
72 | print $self->setListRow($set); |
| 67 | } |
73 | } |
| 68 | |
74 | |
| 69 | print CGI::end_table(); |
75 | print CGI::end_table(); |
|
|
76 | print $self->hidden_authen_fields; |
|
|
77 | print CGI::p(CGI::submit("hardcopy", "Download Harcopy for Selected Sets")); |
| 70 | print CGI::endform(); |
78 | print CGI::endform(); |
| 71 | |
79 | |
| 72 | return ""; |
80 | return ""; |
| 73 | |
|
|
| 74 | # print "Set Names", CGI::br(), "\n"; |
|
|
| 75 | # print join(CGI::br()."\n", sort @setNames); |
|
|
| 76 | # print CGI::p(); |
|
|
| 77 | # |
|
|
| 78 | # print CGI::startform({-method=>"POST", -action=>$r->uri."set0/"}); |
|
|
| 79 | # print $self->hidden_authen_fields; |
|
|
| 80 | # print CGI::input({-type=>"submit", -value=>"Do Set 0"}); |
|
|
| 81 | # print CGI::endform(); |
|
|
| 82 | # ""; |
|
|
| 83 | } |
81 | } |
| 84 | |
82 | |
| 85 | sub setListRow($) { |
83 | sub setListRow($$) { |
|
|
84 | my $self = shift; |
| 86 | my $set = shift; |
85 | my $set = shift; |
| 87 | |
86 | |
| 88 | my $name = $set->id; |
87 | my $name = $set->id; |
|
|
88 | |
|
|
89 | my $interactiveURL = "set$name/?" . $self->url_authen_args; |
|
|
90 | my $hardcopyURL = "hardcopy/set$name/?" . $self->url_authen_args; |
| 89 | |
91 | |
| 90 | my $openDate = formatDateTime($set->open_date); |
92 | my $openDate = formatDateTime($set->open_date); |
| 91 | my $dueDate = formatDateTime($set->due_date); |
93 | my $dueDate = formatDateTime($set->due_date); |
| 92 | my $answerDate = formatDateTime($set->answer_date); |
94 | my $answerDate = formatDateTime($set->answer_date); |
| 93 | |
95 | |
| 94 | my $checkbox = CGI::checkbox(-name=>"set", -value=>$set->id, -label=>""); |
96 | my $checkbox = CGI::checkbox(-name=>"set", -value=>$set->id, -label=>""); |
| 95 | my $interactive = CGI::submit("", "do problem set"); |
97 | my $interactive = CGI::a({-href=>$interactiveURL}, $name); |
| 96 | my $hardcopy = CGI::submit("", "get hard copy"); |
98 | my $hardcopy = CGI::a({-href=>$hardcopyURL}, "download hardcopy"); |
| 97 | |
99 | |
| 98 | my $status; |
100 | my $status; |
| 99 | if (time < $set->open_date) { |
101 | if (time < $set->open_date) { |
| 100 | $status = "opens at $openDate"; |
102 | $status = "opens at $openDate"; |
| 101 | $checkbox = ""; |
103 | $checkbox = ""; |
| 102 | $interactive = ""; |
104 | $interactive = $name; |
| 103 | $hardcopy = ""; |
105 | $hardcopy = ""; |
| 104 | } elsif (time < $set->due_date) { |
106 | } elsif (time < $set->due_date) { |
| 105 | $status = "open, due at $dueDate"; |
107 | $status = "open, due at $dueDate"; |
| 106 | } elsif (time < $set->answer_date) { |
108 | } elsif (time < $set->answer_date) { |
| 107 | $status = "closed, answers at $answerDate"; |
109 | $status = "closed, answers at $answerDate"; |
| … | |
… | |
| 109 | $status = "closed, answers available"; |
111 | $status = "closed, answers available"; |
| 110 | } |
112 | } |
| 111 | |
113 | |
| 112 | return CGI::Tr(CGI::td([ |
114 | return CGI::Tr(CGI::td([ |
| 113 | $checkbox, |
115 | $checkbox, |
| 114 | $name, |
116 | $interactive, |
| 115 | $status, |
117 | $status, |
| 116 | $interactive, |
|
|
| 117 | $hardcopy, |
118 | $hardcopy, |
| 118 | ])); |
119 | ])); |
| 119 | } |
120 | } |
| 120 | |
121 | |
| 121 | 1; |
122 | 1; |