--- loncom/interface/lonfeedback.pm 2001/01/03 16:20:59 1.1 +++ loncom/interface/lonfeedback.pm 2001/02/06 14:22:30 1.3 @@ -9,12 +9,13 @@ # # 3/1/1 Gerd Kortemeyer) # -# 3/1 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; @@ -22,20 +23,202 @@ sub handler { $r->send_http_header; return OK if $r->header_only; + my $feedurl=$ENV{'form.postdata'}; + $feedurl=~s/^http\:\/\///; + $feedurl=~s/^$ENV{'SERVER_NAME'}//; + $feedurl=~s/^$ENV{'HTTP_HOST'}//; + + if (($feedurl=~/^\/res/) || ($ENV{'request.course.id'})) { # --------------------------------------------------- Print login screen header - $r->print(< Feedback to resource author'; + } + if ($ENV{'course.'.$ENV{'request.course.id'}.'.question.email'}) { + $options.= + '
Question about resource content'; + } + 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(< The LearningOnline Network with CAPA +

Feedback

- +

$feedurl

+
+ +Please check at least one of the following: +$options
+My question/comment/feedback:

+

+ +

ENDDOCUMENT +} else { +# +# Get previous user input +# + my $symb=&Apache::lonnet::symbread($feedurl); + my $prevattempts=''; + if ($symb) { + my $answer=&Apache::lonnet::reply( + "restore:".$ENV{'user.domain'}.':'.$ENV{'user.name'}.':'. + $ENV{'request.course.id'}.':'. + &Apache::lonnet::escape($symb), + $ENV{'user.home'}); + my %returnhash=(); + map { + my ($name,$value)=split(/\=/,$_); + $returnhash{&Apache::lonnet::unescape($name)}= + &Apache::lonnet::unescape($value); + } split(/\&/,$answer); + my %lasthash=(); + my $version; + for ($version=1;$version<=$returnhash{'version'};$version++) { + map { + $lasthash{$_}=$returnhash{$version.':'.$_}; + } split(/\:/,$returnhash{$version.':keys'}); + } + $prevattempts=''; + map { + $prevattempts.=''; + } keys %lasthash; + for ($version=1;$version<=$returnhash{'version'};$version++) { + $prevattempts.=''; + map { + $prevattempts.=''; + } keys %lasthash; + } + $prevattempts.=''; + map { + $prevattempts.=''; + } keys %lasthash; + $prevattempts.='
History'.$_.'
Attempt '.$version.''.$returnhash{$version.':'.$_}.'
Current'.$lasthash{$_}.'
'; + } +# +# Get output from resource +# + my $usersaw=&Apache::lonnet::ssi($feedurl); + $usersaw=~s/\]*\>//gi; + $usersaw=~s/\<\/body\>//gi; + $usersaw=~s/\//gi; + $usersaw=~s/\<\/html\>//gi; + $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 ... +$status + + +ENDREDIR +} +} else { + print (<Feedback not sent + + + + +Sorry, no feedback possible on this resource ... + + +ENDNOREDIR +} return OK; } 1; __END__ + + +