[LON-CAPA-cvs] cvs: loncom /interface lonfeedback.pm lonparmset.pm /xml lonxml.pm

www lon-capa-cvs@mail.lon-capa.org
Mon, 28 Oct 2002 14:00:19 -0000


www		Mon Oct 28 09:00:19 2002 EDT

  Modified files:              
    /loncom/interface	lonfeedback.pm lonparmset.pm 
    /loncom/xml	lonxml.pm 
  Log:
  Bug #728.
  
  
Index: loncom/interface/lonfeedback.pm
diff -u loncom/interface/lonfeedback.pm:1.35 loncom/interface/lonfeedback.pm:1.36
--- loncom/interface/lonfeedback.pm:1.35	Fri Oct 25 09:57:28 2002
+++ loncom/interface/lonfeedback.pm	Mon Oct 28 09:00:18 2002
@@ -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 @@
     $options= 
       '<p><input type=checkbox name=author> Feedback to resource author';
   }
-  if ($ENV{'course.'.$ENV{'request.course.id'}.'.question.email'}) {
+  if (&feedback_available(1)) {
     $options.=
     '<br><input type=checkbox name=question> Question about resource content';
   }
-  if ($ENV{'course.'.$ENV{'request.course.id'}.'.comment.email'}) {
+  if (&feedback_available(0,1)) {
     $options.=
       '<br><input type=checkbox name=course> '.
 	'Question/Comment/Feedback about course content';
   }
-  if ($ENV{'course.'.$ENV{'request.course.id'}.'.policy.email'}) {
+  if (&feedback_available(0,0,1)) {
     $options.=
       '<br><input type=checkbox name=policy> '.
 	'Question/Comment/Feedback about course policy';
@@ -252,43 +252,70 @@
 
 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<br>';
     $feedurl=~/^\/res\/(\w+)\/(\w+)\//;
     $to{$2.':'.$1}=1;
   }
-  if ($ENV{'form.question'}) {
+  if ($ENV{'form.question'}||$question) {
     $typestyle.='Submitting as Question<br>';
     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<br>';
     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<br>';
     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 {
Index: loncom/interface/lonparmset.pm
diff -u loncom/interface/lonparmset.pm:1.73 loncom/interface/lonparmset.pm:1.74
--- loncom/interface/lonparmset.pm:1.73	Fri Oct  4 01:51:28 2002
+++ loncom/interface/lonparmset.pm	Mon Oct 28 09:00:18 2002
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Handler to set parameters for assessments
 #
-# $Id: lonparmset.pm,v 1.73 2002/10/04 05:51:28 albertel Exp $
+# $Id: lonparmset.pm,v 1.74 2002/10/28 14:00:18 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1403,13 +1403,13 @@
                     '<a href="javascript:openbrowser'.
                     "('envform','default_xml_style'".
                     ",'sty')\">Browse</a><br>",
-             'question.email' => '<b>Feedback Addresses for Content '.
+             'question.email' => '<b>Feedback Addresses for Resource Content '.
                                  'Questions</b><br>(<tt>user:domain,'.
-                                 'user:domain,...</tt>)',
-             'comment.email'  => '<b>Feedback Addresses for Comments</b><br>'.
-                                 '(<tt>user:domain,user:domain,...</tt>)',
+                                 'user:domain(section;section;...;*;...),...</tt>)',
+             'comment.email'  => '<b>Feedback Addresses for Course Content Comments</b><br>'.
+                                 '(<tt>user:domain,user:domain(section;section;...;*;...),...</tt>)',
              'policy.email'   => '<b>Feedback Addresses for Course Policy</b>'.
-                                 '<br>(<tt>user:domain,user:domain,...</tt>)',
+                                 '<br>(<tt>user:domain,user:domain(section;section;...;*;...),...</tt>)',
              'hideemptyrows'  => '<b>Hide Empty Rows in Spreadsheets</b><br>'.
                                  '("<tt>yes</tt>" for default hiding)',
              'pageseparators'  => '<b>Visibly Separate Items on Pages</b><br>'.
Index: loncom/xml/lonxml.pm
diff -u loncom/xml/lonxml.pm:1.208 loncom/xml/lonxml.pm:1.209
--- loncom/xml/lonxml.pm:1.208	Fri Oct 25 14:58:19 2002
+++ loncom/xml/lonxml.pm	Mon Oct 28 09:00:18 2002
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # XML Parser Module 
 #
-# $Id: lonxml.pm,v 1.208 2002/10/25 18:58:19 albertel Exp $
+# $Id: lonxml.pm,v 1.209 2002/10/28 14:00:18 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1381,10 +1381,10 @@
     &Apache::lonmsg::author_res_msg($ENV{'request.filename'},join('<br />',@_));
     #notify course
     if ( $ENV{'request.course.id'} ) {
-      my $users=$ENV{'course.'.$ENV{'request.course.id'}.'.comment.email'};
+      my (undef,%users)=&Apache::lonfeedback::decide_receiver(undef,0,1,1,1);
       my $declutter=&Apache::lonnet::declutter($ENV{'request.filename'});
-      foreach my $user (split /\,/, $users) {
-	($user,my $domain) = split /:/, $user;
+      foreach (keys %users) {
+	my ($user,$domain) = split(/:/, $_);
 	&Apache::lonmsg::user_normal_msg($user,$domain,
         "Error [$declutter]",join('<br />',@_));
       }