--- loncom/interface/lonfeedback.pm 2001/02/05 17:38:17 1.2 +++ loncom/interface/lonfeedback.pm 2001/02/06 14:22:30 1.3 @@ -9,12 +9,13 @@ # # 3/1/1 Gerd Kortemeyer) # -# 3/1,2/3,2/5 Gerd Kortemeyer +# 3/1,2/3,2/5,2/6 Gerd Kortemeyer # package Apache::lonfeedback; use strict; use Apache::Constants qw(:common); +use Apache::lonmsg(); sub handler { my $r = shift; @@ -41,12 +42,12 @@ sub handler { } if ($ENV{'course.'.$ENV{'request.course.id'}.'.comment.email'}) { $options.= - '
'. + '
'. 'Question/Comment/Feedback about course content'; } if ($ENV{'course.'.$ENV{'request.course.id'}.'.policy.email'}) { $options.= - '
'. + '
'. 'Question/Comment/Feedback about course policy'; } $r->print(< ENDDOCUMENT } else { +# +# Get previous user input +# my $symb=&Apache::lonnet::symbread($feedurl); my $prevattempts=''; if ($symb) { @@ -108,6 +112,9 @@ ENDDOCUMENT } keys %lasthash; $prevattempts.=''; } +# +# Get output from resource +# my $usersaw=&Apache::lonnet::ssi($feedurl); $usersaw=~s/\]*\>//gi; $usersaw=~s/\<\/body\>//gi; @@ -116,17 +123,81 @@ ENDDOCUMENT $usersaw=~s/\//gi; $usersaw=~s/\<\/head\>//gi; $usersaw=~s/action\s*\=/would_be_action\=/gi; -# - +# +# Filter HTML out of message (could be nasty) +# + my $message=$ENV{'form.comment'}; + $message=~s/\/\>\;/g; + +# +# Assemble email +# + my $email=<<"ENDEMAIL"; +Refers to $feedurl +
+

Message

+
+$message
+
+
+

Previous attempts of student (if applicable)

+$prevattempts +


+

Original screen output (if applicable)

+$usersaw +ENDEMAIL +# +# Who gets this? +# + my %to=(); + if ($ENV{'form.author'}) { + $feedurl=~/^\/res\/(\w+)\/(\w+)\//; + $to{$2.':'.$1}=1; + } + if ($ENV{'form.question'}) { + map { + $to{$_}=1; + } split(/\,/, + $ENV{'course.'.$ENV{'request.course.id'}.'.question.email'}); + } + if ($ENV{'form.comment'}) { + map { + $to{$_}=1; + } split(/\,/, + $ENV{'course.'.$ENV{'request.course.id'}.'.comment.email'}); + } + if ($ENV{'form.policy'}) { + map { + $to{$_}=1; + } split(/\,/, + $ENV{'course.'.$ENV{'request.course.id'}.'.policy.email'}); + } +# +# Actually send mail +# + my $status=''; + map { + if ($_) { + unless ( + &Apache::lonmsg::user_normal_msg(split(/\:/,$_),'Feedback '.$feedurl, + $email) eq 'ok') { + $status.='
Error sending message to '.$_.'
'; + } + } + } keys %to; +# +# Receipt screen and redirect back to where came from +# print (<Feedback sent + +Feedback sent + Feedback sent ... -$prevattempts -
-$usersaw +$status ENDREDIR