Skip to content

Commit 311ec9e

Browse files
authored
Merge pull request openwebwork#2708 from Alex-Jordan/email
changes to email template for feedback
2 parents 43a71e2 + 8c8621d commit 311ec9e

File tree

2 files changed

+174
-171
lines changed

2 files changed

+174
-171
lines changed

templates/ContentGenerator/Feedback/feedback_email.html.ep

+128-130
Original file line numberDiff line numberDiff line change
@@ -1,183 +1,181 @@
11
% use WeBWorK::Utils qw(decodeAnswers);
2+
% use WeBWorK::Utils::Sets qw(format_set_name_display);
23
%
34
<html>
4-
<head>
5-
<%= stylesheet begin =%>
6-
.data-table td, .data-table th {
7-
text-align: left;
8-
padding: 0.25rem;
9-
}
10-
.data-table.bordered {
11-
border-collapse: collapse;
12-
}
13-
.data-table.bordered > * > tr > td, .data-table.bordered > * > tr > th {
14-
border: 1px solid black;
15-
}
16-
.data-table.bordered thead tr:first-child th {
17-
border-bottom-width: 2px;
18-
}
19-
.mb-1 {
20-
margin-bottom: 1rem
21-
}
22-
.user-message {
23-
border: 1px solid black;
24-
border-radius: 0.375rem;
25-
padding: 1rem;
26-
}
27-
.user-message-line {
28-
margin: 0;
29-
white-space: pre-wrap;
30-
}
31-
<% end =%>
32-
</head>
335
<body>
346
<p>
35-
Message from <%= $user->full_name %> (<%= $user->user_id %>) via WeBWorK at <%= url_for('root')->to_abs %>
36-
</p>
37-
<p>
38-
<%= $user->first_name %> sent feedback from <%= link_to 'this page' => $emailableURL %>.
7+
% if ($problem) {
8+
Message from <%= $user->full_name %> (<%= $user->user_id %>) via WeBWorK at
9+
<%= $ce->{institutionName} %> (sent from
10+
<%= link_to format_set_name_display($set->set_id) . ', #' . $problem->problem_id => $emailableURL %>).
11+
% } elsif ($set) {
12+
Message from <%= $user->full_name %> (<%= $user->user_id %>) via WeBWorK at
13+
<%= $ce->{institutionName} %>
14+
(sent from <%= link_to format_set_name_display($set->set_id) => $emailableURL %>)
15+
% } else {
16+
Message from <%= $user->full_name %> (<%= $user->user_id %>) via WeBWorK at
17+
<%= $ce->{institutionName} %> (sent from <%= link_to 'this page' => $emailableURL %>).
18+
% }
3919
</p>
4020
% if ($feedback) {
41-
<p><%= $user->full_name %> (<%= $user->user_id %>) wrote:</p>
42-
<div class="user-message mb-1">
21+
<div style="border: 1px solid lightgray; padding: 1rem; margin-bottom: 1rem; border-radius: 0.375rem">
4322
% for (split /\n\r?/, $feedback) {
4423
% if ($_) {
45-
<p class="user-message-line"><%= $_ %></p>
24+
<p style="margin: 0; white-space: pre-wrap"><%= $_ %></p>
4625
% } else {
4726
<div style="margin-top: 1em"></div>
4827
% }
4928
% }
5029
</div>
5130
% }
5231
% if ($problem && $verbosity >= 1) {
53-
<table class="data-table bordered mb-1">
32+
<table style="border-collapse: collapse; margin-bottom: 1rem">
5433
<thead>
55-
<tr><th colspan="2">Data about the problem processor</th></tr>
34+
<tr><th style="text-align: left; padding: 0.25rem; border: 1px solid black;
35+
background-color: lightgray" colspan="2">Data about the problem</th></tr>
5636
</thead>
5737
<tbody>
58-
<tr>
59-
<th>Display Mode:</th>
60-
<td><%= param('displayMode') %></td>
61-
</tr>
62-
<tr>
63-
<th>Show Old Answers:</th>
64-
<td><%= param('showOldAnswers') ? 'yes' : 'no' %></td>
65-
</tr>
66-
<tr>
67-
<th>Show Correct Answers:</th>
68-
<td><%= param('showCorrectAnswers') ? 'yes' : 'no' %></td>
69-
</tr>
70-
<tr>
71-
<th>Show Hints:</th>
72-
<td><%= param('showHints') ? 'yes' : 'no' %></td>
73-
</tr>
74-
<tr>
75-
<th>Show Solutions:</th>
76-
<td><%= param('showSolutions') ? 'yes' : 'no' %></td>
38+
% my @rows = (
39+
% [ 'Problem ID', $problem->problem_id ],
40+
% [ 'Source file', $problem->source_file ],
41+
% [ 'Value', $problem->value ],
42+
% [ 'Max attempts', $problem->max_attempts == -1 ? 'unlimited' : $problem->max_attempts ],
43+
% [ 'Random seed', $problem->problem_seed ],
44+
% [ 'Status', $problem->status ],
45+
% [ 'Attempted', $problem->attempted ? 'yes' : 'no' ],
46+
% [ 'Correct attempts', $problem->num_correct ],
47+
% [ 'Incorrect attempts', $problem->num_incorrect ]
48+
% );
49+
% for (@rows) {
50+
<tr>
51+
<th style="text-align: left; padding: 0.25rem"><%= $_->[0] %>:</th>
52+
<td style="text-align: left; padding: 0.25rem"><%= $_->[1] %></td>
53+
</tr>
54+
% }
55+
% my %last_answer = decodeAnswers($problem->last_answer);
56+
<tr style="border-top: solid 1pt">
57+
<th style="text-align: left; padding: 0.25rem; vertical-align: baseline">Last submission:</th>
58+
% if (%last_answer) {
59+
<td style="text-align: left; padding: 0.25rem; padding-top: 0"><table style="border-collapse: collapse">
60+
% for my $key (sort keys %last_answer) {
61+
% if ($last_answer{$key}) {
62+
<tr>
63+
<td style="text-align: left; padding: 0.25rem"><%= $key %>:</td>
64+
<td style="text-align: left; padding: 0.25rem"><%= $last_answer{$key} %></td>
65+
</tr>
66+
% }
67+
% }
68+
</table></td>
69+
% } else {
70+
<td style="text-align: left; padding: 0.25rem">none</td>
71+
% }
7772
</tr>
7873
</tbody>
7974
</table>
8075
% }
81-
%
82-
% if ($user && $verbosity >= 1) {
83-
<table class="data-table bordered mb-1">
76+
% if ($set && $verbosity >= 1) {
77+
<table style="border-collapse: collapse; margin-bottom: 1rem">
8478
<thead>
85-
<tr><th colspan="2">Data about the user</th></tr>
79+
<tr><th style="text-align: left; padding: 0.25rem; border: 1px solid black;
80+
background-color: lightgray" colspan="2">Data about the assignment</th></tr>
8681
</thead>
8782
<tbody>
88-
<tr><th>User ID:</th><td><%= $user->user_id %></td></tr>
89-
<tr><th>Name:</th><td><%= $user->full_name %></td></tr>
90-
<tr><th>Email:</th><td><%= $user->email_address %></td></tr>
91-
% unless ($ce->{blockStudentIDinFeedback}) {
92-
<tr><th>Student ID:</th><td><%= $user->student_id %></td></tr>
83+
% my @rows = (
84+
% [ 'Set ID', $set->set_id ],
85+
% [ 'Set header file', $set->set_header ],
86+
% [ 'Hardcopy header file', $set->hardcopy_header ],
87+
% [ 'Open date', $c->formatDateTime($set->open_date) ],
88+
% [ 'Close date', $c->formatDateTime($set->due_date) ],
89+
% [ 'Answer date', $c->formatDateTime($set->answer_date) ],
90+
% [ 'Visible', $set->visible ? 'yes' : 'no' ],
91+
% [ 'Assignment type', $set->assignment_type ]
92+
% );
93+
% if ($set->assignment_type =~ /gateway/) {
94+
% push @rows, (
95+
% [ 'Attempts per version', $set->attempts_per_version ],
96+
% [ 'Time interval', $set->time_interval ],
97+
% [ 'Versions per interval', $set->versions_per_interval ],
98+
% [ 'Version time limit', $set->version_time_limit ],
99+
% [ 'Version creation time', $c->formatDateTime($set->version_creation_time) ],
100+
% [ 'Problem randorder', $set->problem_randorder ],
101+
% [ 'Version last attempt time', $set->version_last_attempt_time ]
102+
% );
103+
% }
104+
% for (@rows) {
105+
<tr>
106+
<th style="text-align: left; padding: 0.25rem"><%= $_->[0] %>:</th>
107+
<td style="text-align: left; padding: 0.25rem"><%= $_->[1] %></td>
108+
</tr>
93109
% }
94-
% my $status_name = $ce->status_abbrev_to_name($user->status);
95-
%my $status_string =
96-
% defined $status_name
97-
% ? "$status_name ('" . $user->status . q{')}
98-
% : $user->status . ' (unknown status abbreviation)';
99-
<tr><th>Status:</th><td><%= $status_string %></td></tr>
100-
<tr><th>Section:</th><td><%= $user->section %></td></tr>
101-
<tr><th>Recitation:</th><td><%= $user->recitation %></td></tr>
102-
<tr><th>Comment:</th><td><%= $user->comment %></td></tr>
103-
<tr><th>IP Address:</th><td><%= $remote_host %>:<%= $remote_port %></td></tr>
104110
</tbody>
105111
</table>
106112
% }
107113
% if ($problem && $verbosity >= 1) {
108-
<table class="data-table bordered mb-1">
114+
<table style="border-collapse: collapse; margin-bottom: 1rem">
109115
<thead>
110-
<tr><th colspan="2">Data about the problem</th></tr>
116+
<tr><th style="text-align: left; padding: 0.25rem; border: 1px solid black;
117+
background-color: lightgray" colspan="2">Data about the problem processor</th></tr>
111118
</thead>
112119
<tbody>
113-
<tr><th>Problem ID:</th><td><%= $problem->problem_id %></td></tr>
114-
<tr><th>Source file:</th><td><%= $problem->source_file %></td></tr>
115-
<tr><th>Value:</th><td><%= $problem->value %></td></tr>
116-
<tr>
117-
<th>Max attempts</th>
118-
<td><%= $problem->max_attempts == -1 ? 'unlimited' : $problem->max_attempts %></td>
119-
</tr>
120-
<tr><th>Random seed:</th><td><%= $problem->problem_seed %></td></tr>
121-
<tr><th>Status:</th><td><%= $problem->status %></td></tr>
122-
<tr><th>Attempted:</th><td><%= $problem->attempted ? 'yes' : 'no' %></td></tr>
123-
% my %last_answer = decodeAnswers($problem->last_answer);
124-
<tr>
125-
<th>Last answer:</th>
126-
% if (%last_answer) {
127-
<td>
128-
<table class="data-table">
129-
% for my $key (sort keys %last_answer) {
130-
% if ($last_answer{$key}) {
131-
<tr><td><%= $key %>:</td><td><%= $last_answer{$key} %></td></tr>
132-
% }
133-
% }
134-
</table>
135-
</td>
136-
% } else {
137-
<td>none</td>
138-
% }
139-
</tr>
140-
<tr><th>Number of correct attempts:</th><td><%= $problem->num_correct %></td></tr>
141-
<tr><th>Number of incorrect attempts:</th><td><%= $problem->num_incorrect %></td></tr>
120+
% my @rows = (
121+
% [ 'Display Mode', param('displayMode') ],
122+
% [ 'Show Old Answers', param('showOldAnswers') ? 'yes' : 'no' ],
123+
% [ 'Show Correct Answers', param('showCorrectAnswers') ? 'yes' : 'no' ],
124+
% [ 'Show Hints', param('showHints') ? 'yes' : 'no' ],
125+
% [ 'Show Solutions', param('showSolutions') ? 'yes' : 'no' ]
126+
% );
127+
% for (@rows) {
128+
<tr>
129+
<th style="text-align: left; padding: 0.25rem"><%= $_->[0] %>:</th>
130+
<td style="text-align: left; padding: 0.25rem"><%= $_->[1] %></td>
131+
</tr>
132+
% }
142133
</tbody>
143134
</table>
144135
% }
145-
% if ($set && $verbosity >= 1) {
146-
<table class="data-table bordered mb-1">
136+
%
137+
% if ($user && $verbosity >= 1) {
138+
<table style="border-collapse: collapse; margin-bottom: 1rem">
147139
<thead>
148-
<tr><th colspan="2">Data about the homework set</th></tr>
140+
<tr><th style="text-align: left; padding: 0.25rem; border: 1px solid black;
141+
background-color: lightgray" colspan="2">Data about the user</th></tr>
149142
</thead>
150143
<tbody>
151-
<tr><th>Set ID:</th><td><%= $set->set_id %></td></tr>
152-
<tr><th>Set header file:</th><td><%= $set->set_header %></td></tr>
153-
<tr><th>Hardcopy header file:</th><td><%= $set->hardcopy_header %></td></tr>
154-
<tr><th>Open date:</th><td><%= $c->formatDateTime($set->open_date) %></td></tr>
155-
<tr><th>Due date:</th><td><%= $c->formatDateTime($set->due_date) %></td></tr>
156-
<tr><th>Answer date:</th><td><%= $c->formatDateTime($set->answer_date) %></td></tr>
157-
<tr><th>Visible:</th><td><%= $set->visible ? 'yes' : 'no' %></td></tr>
158-
<tr><th>Assignment type:</th><td><%= $set->assignment_type %></td></tr>
159-
% if ($set->assignment_type =~ /gateway/) {
160-
<tr><th>Attempts per version:</th><td><%= $set->assignment_type %></td></tr>
161-
<tr><th>Time interval:</th><td><%= $set->time_interval %></td></tr>
162-
<tr><th>Versions per interval:</th><td><%= $set->versions_per_interval %></td></tr>
163-
<tr><th>Version time limit:</th><td><%= $set->version_time_limit %></td></tr>
144+
% my @rows = (
145+
% [ 'User ID', $user->user_id ],
146+
% [ 'Name', $user->full_name ],
147+
% [ 'Email', $user->email_address ]
148+
% );
149+
% unless ($ce->{blockStudentIDinFeedback}) { push @rows, ['Student ID', $user->student_id]; }
150+
% my $status_name = $ce->status_abbrev_to_name($user->status);
151+
% my $status_string =
152+
% defined $status_name
153+
% ? "$status_name ('" . $user->status . q{')}
154+
% : $user->status . ' (unknown status abbreviation)';
155+
% push @rows, (
156+
% [ 'Status', $status_string ],
157+
% [ 'Section', $user->section ],
158+
% [ 'Recitation', $user->recitation ],
159+
% [ 'Comment', $user->comment ],
160+
% [ 'IP Address', $remote_host ]
161+
%);
162+
% for (@rows) {
164163
<tr>
165-
<th>Version creation time:</th>
166-
<td><%= $c->formatDateTime($set->version_creation_time) %></td>
164+
<th style="text-align: left; padding: 0.25rem"><%= $_->[0] %>:</th>
165+
<td style="text-align: left; padding: 0.25rem"><%= $_->[1] %></td>
167166
</tr>
168-
<tr><th>Problem randorder:</th><td><%= $set->problem_randorder %></td></tr>
169-
<tr><th>Version last attempt time:</th><td><%= $set->version_last_attempt_time %></td></tr>
170167
% }
171168
</tbody>
172169
</table>
173170
% }
174171
% if ($verbosity >= 2) {
175-
<table class="data-table bordered">
172+
<table style="border-collapse: collapse">
176173
<thead>
177-
<tr><th colspan="2">Data about the environment</th></tr>
174+
<tr><th style="text-align: left; padding: 0.25rem; border: 1px solid black;
175+
background-color: lightgray" colspan="2">Data about the environment</th></tr>
178176
</thead>
179177
<tbody>
180-
<tr><td><pre><%= dumper($ce) %></pre></td></tr>
178+
<tr><td style="text-align: left; padding: 0.25rem"><pre><%= dumper($ce) %></pre></td></tr>
181179
</tbody>
182180
</table>
183181
% }

0 commit comments

Comments
 (0)