| … | |
… | |
| 16 | use base qw(WeBWorK::ContentGenerator); |
16 | use base qw(WeBWorK::ContentGenerator); |
| 17 | use Apache::Constants qw(:common); |
17 | use Apache::Constants qw(:common); |
| 18 | use CGI qw(); |
18 | use CGI qw(); |
| 19 | use WeBWorK::ContentGenerator; |
19 | use WeBWorK::ContentGenerator; |
| 20 | use WeBWorK::DB::WW; |
20 | use WeBWorK::DB::WW; |
| 21 | use WeBWorK::Utils qw(formatDateTime); |
21 | use WeBWorK::Utils qw(readFile formatDateTime); |
| 22 | |
22 | |
| 23 | sub initialize { |
23 | sub initialize { |
| 24 | my $self = shift; |
24 | my $self = shift; |
| 25 | my $courseEnvironment = $self->{courseEnvironment}; |
25 | my $courseEnvironment = $self->{courseEnvironment}; |
| 26 | |
26 | |
| … | |
… | |
| 52 | |
52 | |
| 53 | sub body { |
53 | sub body { |
| 54 | my $self = shift; |
54 | my $self = shift; |
| 55 | my $r = $self->{r}; |
55 | my $r = $self->{r}; |
| 56 | my $courseEnvironment = $self->{courseEnvironment}; |
56 | my $courseEnvironment = $self->{courseEnvironment}; |
| 57 | my $user = $r->param('user'); |
57 | my $user = $r->param("user"); |
|
|
58 | my $effectiveUser = $r->param("effectiveUser"); |
|
|
59 | my $sort = $r->param("sort") || "status"; |
| 58 | my $wwdb = $self->{wwdb}; |
60 | my $wwdb = $self->{wwdb}; |
| 59 | |
61 | |
|
|
62 | if (defined $courseEnvironment->{courseFiles}->{motd} |
|
|
63 | and $courseEnvironment->{courseFiles}->{motd}) { |
|
|
64 | my $motd = eval { readFile($courseEnvironment->{courseFiles}->{motd}) }; |
|
|
65 | $@ or print $motd; |
|
|
66 | } |
|
|
67 | |
|
|
68 | $sort = "status" unless $sort eq "status" or $sort eq "name"; |
|
|
69 | my $baseURL = $r->uri . "?" . $self->url_authen_args(); |
|
|
70 | my $nameHeader = ($sort eq "name") ? "Name" : CGI::a({-href=>"$baseURL&sort=name"}, "Name"); |
|
|
71 | my $statusHeader = ($sort eq "status") ? "Status" : CGI::a({-href=>"$baseURL&sort=status"}, "Status"); |
|
|
72 | |
| 60 | print CGI::startform(-method=>"POST", -action=>$r->uri."/hardcopy"); |
73 | print CGI::startform(-method=>"POST", -action=>$r->uri."hardcopy/"); |
|
|
74 | print $self->hidden_authen_fields; |
| 61 | print CGI::start_table(); |
75 | print CGI::start_table(); |
| 62 | print CGI::Tr( |
76 | print CGI::Tr( |
| 63 | CGI::th("Sel."), |
77 | CGI::th("Sel."), |
| 64 | CGI::th("Name"), |
78 | CGI::th($nameHeader), |
| 65 | CGI::th("Status"), |
79 | CGI::th($statusHeader), |
| 66 | CGI::th("Hardcopy"), |
80 | CGI::th("Hardcopy"), |
| 67 | ); |
81 | ); |
| 68 | |
82 | |
| 69 | my @sets; |
83 | my @sets; |
| 70 | push @sets, $wwdb->getSet($user, $_) foreach ($wwdb->getSets($user)); |
84 | push @sets, $wwdb->getSet($effectiveUser, $_) foreach ($wwdb->getSets($effectiveUser)); |
| 71 | foreach my $set (sort { $a->open_date <=> $b->open_date } @sets) { |
85 | @sets = sort byname @sets if $sort eq "name"; |
|
|
86 | @sets = sort byduedate @sets if $sort eq "status"; |
|
|
87 | foreach my $set (@sets) { |
| 72 | print $self->setListRow($set); |
88 | print $self->setListRow($set); |
| 73 | } |
89 | } |
| 74 | |
90 | |
| 75 | print CGI::end_table(); |
91 | print CGI::end_table(); |
| 76 | print $self->hidden_authen_fields; |
|
|
| 77 | print CGI::p(CGI::submit("hardcopy", "Download Harcopy for Selected Sets")); |
92 | print CGI::p(CGI::submit("hardcopy", "Download Harcopy for Selected Sets")); |
| 78 | print CGI::endform(); |
93 | print CGI::endform(); |
|
|
94 | |
|
|
95 | # feedback form |
|
|
96 | my $ce = $self->{courseEnvironment}; |
|
|
97 | my $root = $ce->{webworkURLs}->{root}; |
|
|
98 | my $courseName = $ce->{courseName}; |
|
|
99 | my $feedbackURL = "$root/$courseName/feedback/"; |
|
|
100 | print |
|
|
101 | CGI::startform("POST", $feedbackURL), |
|
|
102 | $self->hidden_authen_fields, |
|
|
103 | CGI::hidden("module", __PACKAGE__), |
|
|
104 | CGI::p({-align=>"right"}, |
|
|
105 | CGI::submit(-name=>"feedbackForm", -label=>"Send Feedback") |
|
|
106 | ), |
|
|
107 | CGI::endform(); |
| 79 | |
108 | |
| 80 | return ""; |
109 | return ""; |
| 81 | } |
110 | } |
| 82 | |
111 | |
| 83 | sub setListRow($$) { |
112 | sub setListRow($$) { |
| 84 | my $self = shift; |
113 | my $self = shift; |
| 85 | my $set = shift; |
114 | my $set = shift; |
| 86 | |
115 | |
| 87 | my $name = $set->id; |
116 | my $name = $set->id; |
| 88 | |
117 | |
| 89 | my $interactiveURL = "set$name/?" . $self->url_authen_args; |
118 | my $interactiveURL = "$name/?" . $self->url_authen_args; |
| 90 | my $hardcopyURL = "hardcopy/set$name/?" . $self->url_authen_args; |
119 | my $hardcopyURL = "hardcopy/$name/?" . $self->url_authen_args; |
| 91 | |
120 | |
| 92 | my $openDate = formatDateTime($set->open_date); |
121 | my $openDate = formatDateTime($set->open_date); |
| 93 | my $dueDate = formatDateTime($set->due_date); |
122 | my $dueDate = formatDateTime($set->due_date); |
| 94 | my $answerDate = formatDateTime($set->answer_date); |
123 | my $answerDate = formatDateTime($set->answer_date); |
| 95 | |
124 | |
| 96 | my $checkbox = CGI::checkbox(-name=>"set", -value=>$set->id, -label=>""); |
125 | my $checkbox = CGI::checkbox(-name=>"set", -value=>$set->id, -label=>""); |
| 97 | my $interactive = CGI::a({-href=>$interactiveURL}, $name); |
126 | my $interactive = CGI::a({-href=>$interactiveURL}, $name); |
| 98 | my $hardcopy = CGI::a({-href=>$hardcopyURL}, "download hardcopy"); |
127 | my $hardcopy = CGI::a({-href=>$hardcopyURL}, "download"); |
| 99 | |
128 | |
| 100 | my $status; |
129 | my $status; |
| 101 | if (time < $set->open_date) { |
130 | if (time < $set->open_date) { |
| 102 | $status = "opens at $openDate"; |
131 | $status = "opens at $openDate"; |
| 103 | $checkbox = ""; |
132 | $checkbox = ""; |
| … | |
… | |
| 117 | $status, |
146 | $status, |
| 118 | $hardcopy, |
147 | $hardcopy, |
| 119 | ])); |
148 | ])); |
| 120 | } |
149 | } |
| 121 | |
150 | |
|
|
151 | sub byname { $a->id cmp $b->id; } |
|
|
152 | sub byduedate { $a->due_date <=> $b->due_date; } |
|
|
153 | |
| 122 | 1; |
154 | 1; |