version 1.2, 2001/02/05 17:38:17
|
version 1.5, 2001/02/08 21:35:24
|
Line 9
|
Line 9
|
# |
# |
# 3/1/1 Gerd Kortemeyer) |
# 3/1/1 Gerd Kortemeyer) |
# |
# |
# 3/1,2/3,2/5 Gerd Kortemeyer |
# 3/1,2/3,2/5,2/6,2/8 Gerd Kortemeyer |
# |
# |
package Apache::lonfeedback; |
package Apache::lonfeedback; |
|
|
use strict; |
use strict; |
use Apache::Constants qw(:common); |
use Apache::Constants qw(:common); |
|
use Apache::lonmsg(); |
|
|
sub handler { |
sub handler { |
my $r = shift; |
my $r = shift; |
Line 27 sub handler {
|
Line 28 sub handler {
|
$feedurl=~s/^$ENV{'SERVER_NAME'}//; |
$feedurl=~s/^$ENV{'SERVER_NAME'}//; |
$feedurl=~s/^$ENV{'HTTP_HOST'}//; |
$feedurl=~s/^$ENV{'HTTP_HOST'}//; |
|
|
if (($feedurl=~/^\/res/) || ($ENV{'request.course.id'})) { |
if ((($feedurl=~/^\/res/) && ($feedurl!~/^\/res\/adm/)) |
|
|| ($ENV{'request.course.id'})) { |
# --------------------------------------------------- Print login screen header |
# --------------------------------------------------- Print login screen header |
unless ($ENV{'form.sendit'}) { |
unless ($ENV{'form.sendit'}) { |
my $options=''; |
my $options=''; |
if ($feedurl=~/^\/res/) { |
if (($feedurl=~/^\/res/) && ($feedurl!~/^\/res\/adm/)) { |
$options= |
$options= |
'<p><input type=checkbox name=author> Feedback to resource author'; |
'<p><input type=checkbox name=author> Feedback to resource author'; |
} |
} |
Line 41 sub handler {
|
Line 43 sub handler {
|
} |
} |
if ($ENV{'course.'.$ENV{'request.course.id'}.'.comment.email'}) { |
if ($ENV{'course.'.$ENV{'request.course.id'}.'.comment.email'}) { |
$options.= |
$options.= |
'<br><input type=checkbox name=question> '. |
'<br><input type=checkbox name=course> '. |
'Question/Comment/Feedback about course content'; |
'Question/Comment/Feedback about course content'; |
} |
} |
if ($ENV{'course.'.$ENV{'request.course.id'}.'.policy.email'}) { |
if ($ENV{'course.'.$ENV{'request.course.id'}.'.policy.email'}) { |
$options.= |
$options.= |
'<br><input type=checkbox name=question> '. |
'<br><input type=checkbox name=policy> '. |
'Question/Comment/Feedback about course policy'; |
'Question/Comment/Feedback about course policy'; |
} |
} |
|
if ($options) { |
$r->print(<<ENDDOCUMENT); |
$r->print(<<ENDDOCUMENT); |
<html> |
<html> |
<head> |
<head> |
<title>The LearningOnline Network with CAPA</title> |
<title>The LearningOnline Network with CAPA</title> |
|
<script> |
|
function gosubmit() { |
|
var rec=0; |
|
if (document.mailform.elements.author!=undefined) { |
|
if (document.mailform.elements.author.checked) { |
|
rec=1; |
|
} |
|
} |
|
if (document.mailform.elements.question!=undefined) { |
|
if (document.mailform.elements.question.checked) { |
|
rec=1; |
|
} |
|
} |
|
if (document.mailform.elements.course!=undefined) { |
|
if (document.mailform.elements.course.checked) { |
|
rec=1; |
|
} |
|
} |
|
if (document.mailform.elements.policy!=undefined) { |
|
if (document.mailform.elements.policy.checked) { |
|
rec=1; |
|
} |
|
} |
|
|
|
if (rec) { |
|
document.mailform.submit(); |
|
} else { |
|
alert('Please check a feedback type.'); |
|
} |
|
} |
|
</script> |
</head> |
</head> |
<body bgcolor="#FFFFFF"> |
<body bgcolor="#FFFFFF" onLoad="window.focus();"> |
<img align=right src=/adm/lonIcons/lonlogos.gif> |
<img align=right src=/adm/lonIcons/lonlogos.gif> |
<h1>Feedback</h1> |
<h1>Feedback</h1> |
<h2><tt>$feedurl</tt></h2> |
<h2><tt>$feedurl</tt></h2> |
<form action="/adm/feedback" method=post> |
<form action="/adm/feedback" method=post name=mailform> |
<input type=hidden name=postdata value="$feedurl"> |
<input type=hidden name=postdata value="$feedurl"> |
Please check at least one of the following: |
Please check at least one of the following feedback types: |
$options<hr> |
$options<hr> |
My question/comment/feedback:<p> |
My question/comment/feedback:<p> |
<textarea name=comment cols=60 rows=10> |
<textarea name=comment cols=60 rows=10> |
</textarea><p> |
</textarea><p> |
<input type=submit name=sendit value="Send Feedback"></input> |
<input type=hidden name=sendit value=1> |
|
<input type=button value="Send Feedback" onClick='gosubmit();'></input> |
</form> |
</form> |
</body> |
</body> |
</html> |
</html> |
ENDDOCUMENT |
ENDDOCUMENT |
} else { |
} else { |
|
print (<<ENDFAILREDIR); |
|
<head><title>Feedback not sent</title> |
|
<meta HTTP-EQUIV="Refresh" CONTENT="2; url=$feedurl"> |
|
</head> |
|
<html> |
|
<body bgcolor="#FFFFFF"> |
|
Sorry, no recipients ... |
|
</body> |
|
</html> |
|
ENDFAILREDIR |
|
|
|
} |
|
} else { |
|
# |
|
# Get previous user input |
|
# |
my $symb=&Apache::lonnet::symbread($feedurl); |
my $symb=&Apache::lonnet::symbread($feedurl); |
my $prevattempts=''; |
my $prevattempts=''; |
if ($symb) { |
if ($symb) { |
Line 108 ENDDOCUMENT
|
Line 159 ENDDOCUMENT
|
} keys %lasthash; |
} keys %lasthash; |
$prevattempts.='</tr></table>'; |
$prevattempts.='</tr></table>'; |
} |
} |
|
# |
|
# Get output from resource |
|
# |
my $usersaw=&Apache::lonnet::ssi($feedurl); |
my $usersaw=&Apache::lonnet::ssi($feedurl); |
$usersaw=~s/\<body[^\>]*\>//gi; |
$usersaw=~s/\<body[^\>]*\>//gi; |
$usersaw=~s/\<\/body\>//gi; |
$usersaw=~s/\<\/body\>//gi; |
Line 116 ENDDOCUMENT
|
Line 170 ENDDOCUMENT
|
$usersaw=~s/\<head\>//gi; |
$usersaw=~s/\<head\>//gi; |
$usersaw=~s/\<\/head\>//gi; |
$usersaw=~s/\<\/head\>//gi; |
$usersaw=~s/action\s*\=/would_be_action\=/gi; |
$usersaw=~s/action\s*\=/would_be_action\=/gi; |
# <meta HTTP-EQUIV="Refresh" CONTENT="1; url=$feedurl"> |
# |
|
# Filter HTML out of message (could be nasty) |
|
# |
|
my $message=$ENV{'form.comment'}; |
|
$message=~s/\</\<\;/g; |
|
$message=~s/\>/\>\;/g; |
|
|
|
# |
|
# Assemble email |
|
# |
|
my $email=<<"ENDEMAIL"; |
|
Refers to <a href="$feedurl">$feedurl</a> |
|
|
|
$message |
|
ENDEMAIL |
|
my $citations=<<"ENDCITE"; |
|
<h2>Previous attempts of student (if applicable)</h2> |
|
$prevattempts |
|
<p><hr> |
|
<h2>Original screen output (if applicable)</h2> |
|
$usersaw |
|
ENDCITE |
|
# |
|
# Who gets this? |
|
# |
|
my $typestyle=''; |
|
my %to=(); |
|
if ($ENV{'form.author'}) { |
|
$typestyle.='Author Feedback<br>'; |
|
$feedurl=~/^\/res\/(\w+)\/(\w+)\//; |
|
$to{$2.':'.$1}=1; |
|
} |
|
if ($ENV{'form.question'}) { |
|
$typestyle.='Question<br>'; |
|
map { |
|
$to{$_}=1; |
|
} split(/\,/, |
|
$ENV{'course.'.$ENV{'request.course.id'}.'.question.email'}); |
|
} |
|
if ($ENV{'form.course'}) { |
|
$typestyle.='Comment<br>'; |
|
map { |
|
$to{$_}=1; |
|
} split(/\,/, |
|
$ENV{'course.'.$ENV{'request.course.id'}.'.comment.email'}); |
|
} |
|
if ($ENV{'form.policy'}) { |
|
$typestyle.='Policy<br>'; |
|
map { |
|
$to{$_}=1; |
|
} split(/\,/, |
|
$ENV{'course.'.$ENV{'request.course.id'}.'.policy.email'}); |
|
} |
|
# |
|
# Actually send mail |
|
# |
|
my $status=''; |
|
my $sendsomething=0; |
|
map { |
|
if ($_) { |
|
unless ( |
|
&Apache::lonmsg::user_normal_msg(split(/\:/,$_),'Feedback '.$feedurl, |
|
$email,$citations) eq 'ok') { |
|
$status.='<br>Error sending message to '.$_.'<br>'; |
|
} else { |
|
$sendsomething++; |
|
} |
|
} |
|
} keys %to; |
|
# |
|
# Receipt screen and redirect back to where came from |
|
# |
print (<<ENDREDIR); |
print (<<ENDREDIR); |
<head><title>Feedback sent</title> |
<head> |
|
<title>Feedback sent</title> |
|
<meta HTTP-EQUIV="Refresh" CONTENT="2; url=$feedurl"> |
</head> |
</head> |
<html> |
<html> |
<body bgcolor="#FFFFFF"> |
<body bgcolor="#FFFFFF"> |
<b>Feedback sent ...</b> |
$typestyle |
$prevattempts |
<b>Sent $sendsomething message(s).</b> |
<hr> |
<font color=red>$status</font> |
$usersaw |
|
</body> |
</body> |
</html> |
</html> |
ENDREDIR |
ENDREDIR |
Line 134 ENDREDIR
|
Line 259 ENDREDIR
|
} else { |
} else { |
print (<<ENDNOREDIR); |
print (<<ENDNOREDIR); |
<head><title>Feedback not sent</title> |
<head><title>Feedback not sent</title> |
<meta HTTP-EQUIV="Refresh" CONTENT="1; url=$feedurl"> |
<meta HTTP-EQUIV="Refresh" CONTENT="2; url=$feedurl"> |
</head> |
</head> |
<html> |
<html> |
<body bgcolor="#FFFFFF"> |
<body bgcolor="#FFFFFF"> |