--- loncom/interface/lonfeedback.pm 2002/10/25 13:57:28 1.35 +++ loncom/interface/lonfeedback.pm 2002/10/28 14:00:18 1.36 @@ -1,7 +1,7 @@ # The LearningOnline Network # Feedback # -# $Id: lonfeedback.pm,v 1.35 2002/10/25 13:57:28 www Exp $ +# $Id: lonfeedback.pm,v 1.36 2002/10/28 14:00:18 www Exp $ # # Copyright Michigan State University Board of Trustees # @@ -183,16 +183,16 @@ sub screen_header { $options= '
Feedback to resource author';
}
- if ($ENV{'course.'.$ENV{'request.course.id'}.'.question.email'}) {
+ if (&feedback_available(1)) {
$options.=
'
Question about resource content';
}
- if ($ENV{'course.'.$ENV{'request.course.id'}.'.comment.email'}) {
+ if (&feedback_available(0,1)) {
$options.=
'
'.
'Question/Comment/Feedback about course content';
}
- if ($ENV{'course.'.$ENV{'request.course.id'}.'.policy.email'}) {
+ if (&feedback_available(0,0,1)) {
$options.=
'
'.
'Question/Comment/Feedback about course policy';
@@ -252,45 +252,72 @@ ENDCITE
sub secapply {
my $rec=shift;
- return $rec;
+ my $defaultflag=shift;
+ $rec=~s/\s+//g;
+ $rec=~s/\@/\:/g;
+ my ($adr,$sections)=($rec=~/^([^\(]+)\(([^\)]+)\)/);
+ if ($sections) {
+ foreach (split(/\;/,$sections)) {
+ if (($_ eq $ENV{'request.course.sec'}) ||
+ ($defaultflag && ($_ eq '*'))) {
+ return $adr;
+ }
+ }
+ } else {
+ return $rec;
+ }
+ return '';
}
sub decide_receiver {
- my ($feedurl) = @_;
+ my ($feedurl,$author,$question,$course,$policy,$defaultflag) = @_;
my $typestyle='';
my %to=();
- if ($ENV{'form.author'}) {
+ if ($ENV{'form.author'}||$author) {
$typestyle.='Submitting as Author Feedback
';
$feedurl=~/^\/res\/(\w+)\/(\w+)\//;
$to{$2.':'.$1}=1;
}
- if ($ENV{'form.question'}) {
+ if ($ENV{'form.question'}||$question) {
$typestyle.='Submitting as Question
';
foreach (split(/\,/,
$ENV{'course.'.$ENV{'request.course.id'}.'.question.email'})
) {
- if (my $rec=&secapply($_)) { $to{$rec}=1; }
+ my $rec=&secapply($_,$defaultflag);
+ if ($rec) { $to{$rec}=1; }
}
}
- if ($ENV{'form.course'}) {
+ if ($ENV{'form.course'}||$course) {
$typestyle.='Submitting as Comment
';
foreach (split(/\,/,
$ENV{'course.'.$ENV{'request.course.id'}.'.comment.email'})
) {
- if (my $rec=&secapply($_)) { $to{$rec}=1; }
+ my $rec=&secapply($_,$defaultflag);
+ if ($rec) { $to{$rec}=1; }
}
}
- if ($ENV{'form.policy'}) {
+ if ($ENV{'form.policy'}||$policy) {
$typestyle.='Submitting as Policy Feedback
';
foreach (split(/\,/,
$ENV{'course.'.$ENV{'request.course.id'}.'.policy.email'})
) {
- if (my $rec=&secapply($_)) { $to{$rec}=1; }
+ my $rec=&secapply($_,$defaultflag);
+ if ($rec) { $to{$rec}=1; }
}
}
+ if ((scalar(%to) eq '0') && (!$defaultflag)) {
+ ($typestyle,%to)=
+ &decide_receiver($feedurl,$author,$question,$course,$policy,1);
+ }
return ($typestyle,%to);
}
+sub feedback_available {
+ my ($question,$course,$policy)=@_;
+ my ($typestyle,%to)=&decide_receiver('',0,$question,$course,$policy);
+ return scalar(%to);
+}
+
sub send_msg {
my ($feedurl,$email,$citations,%to)=@_;
my $status='';