Skip to content

Commit

Permalink
Bring back the previous text message for a text fallback.
Browse files Browse the repository at this point in the history
The text message is generated by the `templates/ContentGenerator/Feedback/feedback_email.txt.ep` template.
The text message is essentially the same as the prior text email. If
your email client is set to show text, then you will see this message.
If your client is set to show HTML, then you will see the new HTML
message. If your client does not support HTML, then you will see the
text message.
  • Loading branch information
drgrice1 committed Feb 18, 2025
1 parent ad0ae6e commit bf557ac
Show file tree
Hide file tree
Showing 3 changed files with 111 additions and 7 deletions.
17 changes: 11 additions & 6 deletions lib/WeBWorK/ContentGenerator/Feedback.pm
Original file line number Diff line number Diff line change
Expand Up @@ -136,24 +136,29 @@ sub initialize ($c) {
my $subject = $ce->{mail}{feedbackSubjectFormat} || 'WeBWorK question from %c: %u set %s/prob %p';
$subject =~ s/%([$chars])/defined $subject_map{$1} ? $subject_map{$1} : ''/eg;

my $remote_host = $c->tx->remote_address || 'UNKNOWN';

my $email = Email::Stuffer->to(join(',', @recipients))->subject($subject)->html_body($c->render_to_string(
'ContentGenerator/Feedback/feedback_email',
my %data = (
user => $user,
emailableURL => $emailableURL,
feedback => $feedback,
problem => $problem,
set => $set,
verbosity => $verbosity,
remote_host => $remote_host,
))->header('X-Remote-Host' => $remote_host);
remote_host => $c->tx->remote_address || 'UNKNOWN',
remote_port => $c->tx->remote_port || 'UNKNOWN'
);

my $email =
Email::Stuffer->to(join(',', @recipients))->subject($subject)
->text_body($c->render_to_string('ContentGenerator/Feedback/feedback_email', format => 'txt', %data))
->html_body($c->render_to_string('ContentGenerator/Feedback/feedback_email', %data))
->header('X-Remote-Host' => $data{remote_host});
if ($ce->{feedback_sender_email}) {
my $from_name = $user ? $user->full_name : $ce->{generic_sender_name};
$email->from("$from_name <$ce->{feedback_sender_email}>")->reply_to($sender);
} else {
$email->from($sender);
}

# Extra headers
$email->header('X-WeBWorK-Route', $route) if defined $route;
$email->header('X-WeBWorK-Course', $courseID) if defined $courseID;
Expand Down
2 changes: 1 addition & 1 deletion templates/ContentGenerator/Feedback/feedback_email.html.ep
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@
<tr><th>Section:</th><td><%= $user->section %></td></tr>
<tr><th>Recitation:</th><td><%= $user->recitation %></td></tr>
<tr><th>Comment:</th><td><%= $user->comment %></td></tr>
<tr><th>IP Address:</th><td><%= $remote_host %>:<%= $c->tx->remote_port || 'UNKNOWN' %></td></tr>
<tr><th>IP Address:</th><td><%= $remote_host %>:<%= $remote_port %></td></tr>
</tbody>
</table>
% }
Expand Down
99 changes: 99 additions & 0 deletions templates/ContentGenerator/Feedback/feedback_email.txt.ep
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
% use WeBWorK::Utils qw(decodeAnswers);
%
Message from <%== $user->full_name %> (<%== $user->user_id %>) via WeBWorK at
<%== url_for('root')->to_abs %>

To visit the page from which <%== $user->first_name %> sent feedback, go to:
<%== $emailableURL %>

% if ($feedback) {
<%== $user->full_name %> (<%== $user->user_id %>) wrote:


<%== $feedback %>

% }
% if ($problem && $verbosity >= 1) {

***** Data about the problem processor: *****

Display Mode: <%== param('displayMode') %>
Show Old Answers: <%== param('showOldAnswers') ? 'yes' : 'no' %>
Show Correct Answers: <%== param('showCorrectAnswers') ? 'yes' : 'no' %>
Show Hints: <%== param('showHints') ? 'yes' : 'no' %>
Show Solutions: <%== param('showSolutions') ? 'yes' : 'no' %>
% }
% if ($user && $verbosity >= 1) {

***** Data about the user: *****

User ID: <%== $user->user_id %>
Name: <%== $user->full_name %>
Email: <%== $user->email_address %>
% unless ($ce->{blockStudentIDinFeedback}) {
Student ID: <%== $user->student_id %>
% }
% my $status_name = $ce->status_abbrev_to_name($user->status);
%my $status_string =
% defined $status_name
% ? "$status_name ('" . $user->status . q{')}
% : $user->status . ' (unknown status abbreviation)';
Status: <%== $status_string %>
Section: <%== $user->section %>
Recitation: <%== $user->recitation %>
Comment: <%== $user->comment %>
IP Address: <%== $remote_host %>:<%== $c->tx->remote_port || 'UNKNOWN' %>
% }
% if ($problem && $verbosity >= 1) {

***** Data about the problem: *****

Problem ID: <%== $problem->problem_id %>
Source file: <%== $problem->source_file %>
Value: <%== $problem->value %>
Max attempts <%== $problem->max_attempts == -1 ? 'unlimited' : $problem->max_attempts %>
Random seed: <%== $problem->problem_seed %>
Status: <%== $problem->status %>
Attempted: <%== $problem->attempted ? 'yes' : 'no' %>
% my %last_answer = decodeAnswers($problem->last_answer);
% if (%last_answer) {
Last answer:
% for my $key (sort keys %last_answer) {
% if ($last_answer{$key}) {
<%== $key %>: <%== $last_answer{$key} %>
% }
% }
% } else {
Last answer: none
% }
Number of correct attempts: <%== $problem->num_correct %>
Number of incorrect attempts: <%== $problem->num_incorrect %>
% }
% if ($set && $verbosity >= 1) {

***** Data about the homework set: *****

Set ID: <%== $set->set_id %>
Set header file: <%== $set->set_header %>
Hardcopy header file: <%== $set->hardcopy_header %>
Open date: <%== $c->formatDateTime($set->open_date) %>
Due date: <%== $c->formatDateTime($set->due_date) %>
Answer date: <%== $c->formatDateTime($set->answer_date) %>
Visible: <%== $set->visible ? 'yes' : 'no' %>
Assignment type: <%== $set->assignment_type %>
% if ($set->assignment_type =~ /gateway/) {
Attempts per version: <%== $set->assignment_type %>
Time interval: <%== $set->time_interval %>
Versions per interval: <%== $set->versions_per_interval %>
Version time limit: <%== $set->version_time_limit %>
Version creation time: <%== $c->formatDateTime($set->version_creation_time) %>
Problem randorder: <%== $set->problem_randorder %>
Version last attempt time: <%== $set->version_last_attempt_time %>
% }
% }
% if ($verbosity >= 2) {

Data about the environment

<%== dumper($ce) %>
% }

0 comments on commit bf557ac

Please sign in to comment.