| … | |
… | |
| 92 | my $wwdb = WeBWorK::DB::WW->new($ce); |
92 | my $wwdb = WeBWorK::DB::WW->new($ce); |
| 93 | |
93 | |
| 94 | my $permissionLevel = ($userName |
94 | my $permissionLevel = ($userName |
| 95 | ? $authdb->getPermissions($userName) |
95 | ? $authdb->getPermissions($userName) |
| 96 | : undef); |
96 | : undef); |
| 97 | my $user = ($userName |
97 | my $user = ($userName ne "" |
| 98 | ? $cldb->getUser($userName) |
98 | ? $cldb->getUser($userName) |
| 99 | : undef); |
99 | : undef); |
| 100 | my $set = ($setName |
100 | my $set = ($setName ne "" |
| 101 | ? $wwdb->getSet($userName, $setName) |
101 | ? $wwdb->getSet($userName, $setName) |
| 102 | : undef); |
102 | : undef); |
| 103 | my $problem = ($setName && $problemNumber |
103 | my $problem = ($setName ne "" && $problemNumber ne "" |
| 104 | ? $wwdb->getProblem($userName, $setName, $problemNumber) |
104 | ? $wwdb->getProblem($userName, $setName, $problemNumber) |
| 105 | : undef); |
105 | : undef); |
| 106 | |
106 | |
| 107 | if (defined $r->param("sendFeedback")) { |
107 | if (defined $r->param("sendFeedback")) { |
|
|
108 | # get verbosity level |
|
|
109 | my $verbosity = $ce->{mail}->{feedbackVerbosity}; |
|
|
110 | |
| 108 | # determine the sender of the email |
111 | # determine the sender of the email |
| 109 | my $sender = ($user && $user->email_address |
112 | my $sender = ($user && $user->email_address |
| 110 | ? $user->email_address |
113 | ? $user->email_address |
| 111 | : $from); |
114 | : $from); |
| 112 | |
115 | |
| … | |
… | |
| 124 | } |
127 | } |
| 125 | } |
128 | } |
| 126 | } |
129 | } |
| 127 | } |
130 | } |
| 128 | |
131 | |
| 129 | # sanity checks # *** make these prettier |
132 | # sanity checks |
| 130 | unless ($sender) { |
133 | unless ($sender) { |
| 131 | $self->feedbackForm($user, |
134 | $self->feedbackForm($user, |
| 132 | "No Sender specified."); |
135 | "No Sender specified."); |
| 133 | return ""; |
136 | return ""; |
| 134 | } |
137 | } |
| 135 | unless (@recipients) { |
138 | unless (@recipients) { |
| 136 | $self->feedbackForm($user, |
139 | $self->feedbackForm($user, |
| 137 | "No recipients specified."); |
140 | "No recipients specified."); |
| 138 | return ""; |
141 | return ""; |
|
|
142 | } |
|
|
143 | |
|
|
144 | # get some network settings |
|
|
145 | my $hostname = $r->hostname(); |
|
|
146 | my $port = $r->get_server_port(); |
|
|
147 | my $remoteIdent = $r->get_remote_logname() || "UNKNOWN"; |
|
|
148 | my $remoteHost = $r->get_remote_host(); |
|
|
149 | |
|
|
150 | # generate context URL |
|
|
151 | my $URL; |
|
|
152 | if ($user) { |
|
|
153 | if ($set) { |
|
|
154 | if ($problem) { |
|
|
155 | $URL = "http://$hostname:$port" |
|
|
156 | . $ce->{webworkURLs}->{root} |
|
|
157 | . "/" . $ce->{courseName} |
|
|
158 | . "/" . $problem->set_id |
|
|
159 | . "/" . $problem->id |
|
|
160 | . "/" . "?effectiveUser=$userName"; |
|
|
161 | } else { |
|
|
162 | $URL = "http://$hostname:$port" |
|
|
163 | . $ce->{webworkURLs}->{root} |
|
|
164 | . "/" . $ce->{courseName} |
|
|
165 | . "/" . $set->id |
|
|
166 | . "/" . "?effectiveUser=$userName"; |
|
|
167 | } |
|
|
168 | } else { |
|
|
169 | $URL = "http://$hostname:$port" |
|
|
170 | . $ce->{webworkURLs}->{root} |
|
|
171 | . "/" . $ce->{courseName} |
|
|
172 | . "/" . "?effectiveUser=$userName"; |
|
|
173 | } |
|
|
174 | } else { |
|
|
175 | $URL = "(not available)"; |
| 139 | } |
176 | } |
| 140 | |
177 | |
| 141 | # bring up a mailer |
178 | # bring up a mailer |
| 142 | my $mailer = Mail::Sender->new({ |
179 | my $mailer = Mail::Sender->new({ |
| 143 | from => $sender, |
180 | from => $sender, |
| … | |
… | |
| 158 | "Failed to open the mailer: $Mail::Sender::Error"); |
195 | "Failed to open the mailer: $Mail::Sender::Error"); |
| 159 | return ""; |
196 | return ""; |
| 160 | } |
197 | } |
| 161 | my $MAIL = $mailer->GetHandle(); |
198 | my $MAIL = $mailer->GetHandle(); |
| 162 | |
199 | |
| 163 | my $hostname = $r->hostname(); |
200 | # print message |
| 164 | my $port = $r->get_server_port(); |
|
|
| 165 | my $remoteIdent = $r->get_remote_logname() || "UNKNOWN"; |
|
|
| 166 | my $remoteHost = $r->get_remote_host(); |
|
|
| 167 | print $MAIL |
201 | print $MAIL |
| 168 | wrap("", "", "This feedback message was automatically", |
202 | wrap("", "", "This feedback message was automatically", |
| 169 | "generated by the WeBWorK system at", |
203 | "generated by the WeBWorK system at", |
| 170 | "$hostname:$port, in response to a request from", |
204 | "$hostname:$port, in response to a request from", |
| 171 | "$remoteIdent\@$remoteHost."), "\n\n"; |
205 | "$remoteIdent\@$remoteHost."), "\n\n"; |
| 172 | ; |
206 | print $MAIL "Context: $URL\n\n"; |
| 173 | |
207 | |
| 174 | if ($feedback) { |
208 | if ($feedback) { |
| 175 | print $MAIL |
209 | print $MAIL |
| 176 | "***** The feedback message: *****\n\n", |
210 | "***** The feedback message: *****\n\n", |
| 177 | wrap("", "", $feedback), "\n\n"; |
211 | wrap("", "", $feedback), "\n\n"; |
| 178 | } |
212 | } |
| 179 | if ($problem) { |
213 | if ($problem and $verbosity >= 1) { |
| 180 | my $problemURL = "http://$hostname:$port" |
|
|
| 181 | . $ce->{webworkURLs}->{root} |
|
|
| 182 | . "/" . $ce->{courseName} |
|
|
| 183 | . "/" . $problem->set_id |
|
|
| 184 | . "/" . $problem->id |
|
|
| 185 | . "/" . "?effectiveUser=$userName"; |
|
|
| 186 | |
|
|
| 187 | print $MAIL |
214 | print $MAIL |
| 188 | "***** Data about the problem processor: *****\n\n", |
215 | "***** Data about the problem processor: *****\n\n", |
| 189 | |
216 | |
| 190 | "Display Mode: $displayMode\n", |
217 | "Display Mode: $displayMode\n", |
| 191 | "Show Old Answers? $showOldAnswers\n", |
218 | "Show Old Answers? $showOldAnswers\n", |
| 192 | "Show Correct Answers? $showCorrectAnswers\n", |
219 | "Show Correct Answers? $showCorrectAnswers\n", |
| 193 | "Show Hints? $showHints\n", |
220 | "Show Hints? $showHints\n", |
| 194 | "Show Solutions? $showSolutions\n\n", |
221 | "Show Solutions? $showSolutions\n\n", |
| 195 | "Link to problem:\n\n", |
|
|
| 196 | "$problemURL\n\n"; |
|
|
| 197 | } |
222 | } |
| 198 | if ($user) { |
223 | if ($user and $verbosity >= 1) { |
| 199 | print $MAIL |
224 | print $MAIL |
| 200 | "***** Data about the user: *****\n\n", |
225 | "***** Data about the user: *****\n\n", |
| 201 | $user->toString(), "\n\n"; |
226 | $user->toString(), "\n\n"; |
| 202 | |
227 | |
| 203 | } |
228 | } |
| 204 | if ($problem) { |
229 | if ($problem and $verbosity >= 1) { |
| 205 | print $MAIL |
230 | print $MAIL |
| 206 | "***** Data about the problem: *****\n\n", |
231 | "***** Data about the problem: *****\n\n", |
| 207 | $problem->toString(), "\n\n"; |
232 | $problem->toString(), "\n\n"; |
| 208 | |
233 | |
| 209 | } |
234 | } |
| 210 | if ($set) { |
235 | if ($set and $verbosity >= 1) { |
| 211 | print $MAIL |
236 | print $MAIL |
| 212 | "***** Data about the problem set: *****\n\n", |
237 | "***** Data about the problem set: *****\n\n", |
| 213 | $set->toString(), "\n\n"; |
238 | $set->toString(), "\n\n"; |
| 214 | |
239 | |
| 215 | } |
240 | } |
| 216 | if ($ce) { |
241 | if ($ce and $verbosity >= 2) { |
| 217 | print $MAIL |
242 | print $MAIL |
| 218 | "***** Data about the environment: *****\n\n", |
243 | "***** Data about the environment: *****\n\n", |
| 219 | Dumper($ce), "\n\n"; |
244 | Dumper($ce), "\n\n"; |
| 220 | |
245 | |
| 221 | } |
246 | } |