Diff for /loncom/interface/lonfeedback.pm between versions 1.21 and 1.32

version 1.21, 2002/01/01 15:02:31 version 1.32, 2002/09/16 19:54:01
Line 40 Line 40
 # 7/25 Gerd Kortemeyer  # 7/25 Gerd Kortemeyer
 # 7/26 Guy Albertelli  # 7/26 Guy Albertelli
 # 7/26,8/10,10/1,11/5,11/6,12/27,12/29 Gerd Kortemeyer  # 7/26,8/10,10/1,11/5,11/6,12/27,12/29 Gerd Kortemeyer
   # YEAR=2002
   # 1/1,1/16 Gerd Kortemeyer
   #
   
 package Apache::lonfeedback;  package Apache::lonfeedback;
   
Line 51  use Apache::loncommon(); Line 53  use Apache::loncommon();
   
 sub mail_screen {  sub mail_screen {
   my ($r,$feedurl,$options) = @_;    my ($r,$feedurl,$options) = @_;
     my $bodytag=&Apache::loncommon::bodytag('Resource Feedback and Discussion',
                                             '','onLoad="window.focus();"');
   $r->print(<<ENDDOCUMENT);    $r->print(<<ENDDOCUMENT);
 <html>  <html>
 <head>  <head>
Line 98  sub mail_screen { Line 102  sub mail_screen {
     }      }
 </script>  </script>
 </head>  </head>
 <body bgcolor="#FFFFFF" onLoad="window.focus();">  $bodytag
 <img align=right src=/adm/lonIcons/lonlogos.gif>  
 <h1>Feedback</h1>  
 <h2><tt>$feedurl</tt></h2>  <h2><tt>$feedurl</tt></h2>
 <form action="/adm/feedback" method=post name=mailform>  <form action="/adm/feedback" method=post name=mailform>
 <input type=hidden name=postdata value="$feedurl">  <input type=hidden name=postdata value="$feedurl">
Line 134  ENDFAILREDIR Line 136  ENDFAILREDIR
 }  }
   
 sub redirect_back {  sub redirect_back {
   my ($r,$feedurl,$typestyle,$sendsomething,$status) = @_;    my ($r,$feedurl,$typestyle,$sendsomething,$sendposts,$status) = @_;
   $r->print (<<ENDREDIR);    $r->print (<<ENDREDIR);
 <head>  <head>
 <title>Feedback sent</title>  <title>Feedback sent</title>
Line 145  sub redirect_back { Line 147  sub redirect_back {
 <body bgcolor="#FFFFFF">  <body bgcolor="#FFFFFF">
 <img align=right src=/adm/lonIcons/lonlogos.gif>  <img align=right src=/adm/lonIcons/lonlogos.gif>
 $typestyle  $typestyle
 <b>Sent $sendsomething message(s).</b>  <b>Sent $sendsomething message(s), and $sendposts post(s).</b>
 <font color=red>$status</font>  <font color=red>$status</font>
 </body>  </body>
 </html>  </html>
Line 197  sub screen_header { Line 199  sub screen_header {
   }    }
   
   if ($ENV{'request.course.id'}) {    if ($ENV{'request.course.id'}) {
       if (&Apache::lonnet::allowed('pch',$ENV{'request.course.id'})) {        if (&Apache::lonnet::allowed('pch',
           $ENV{'request.course.id'}.
           ($ENV{'request.course.sec'}?'/'.$ENV{'request.course.sec'}:''))) {
     $options.='<br><input type=checkbox name=discuss> '.      $options.='<br><input type=checkbox name=discuss> '.
  '<b>Contribution to course discussion of resource</b>';   '<b>Contribution to course discussion of resource</b>';
     $options.='<br><input type=checkbox name=anondiscuss> '.      $options.='<br><input type=checkbox name=anondiscuss> '.
Line 256  sub decide_receiver { Line 260  sub decide_receiver {
   }    }
   if ($ENV{'form.question'}) {    if ($ENV{'form.question'}) {
     $typestyle.='Submitting as Question<br>';      $typestyle.='Submitting as Question<br>';
     map {      foreach (split(/\,/,
      $ENV{'course.'.$ENV{'request.course.id'}.'.question.email'})
        ) {
       $to{$_}=1;        $to{$_}=1;
     } split(/\,/,      } 
     $ENV{'course.'.$ENV{'request.course.id'}.'.question.email'});  
   }    }
   if ($ENV{'form.course'}) {    if ($ENV{'form.course'}) {
     $typestyle.='Submitting as Comment<br>';      $typestyle.='Submitting as Comment<br>';
     map {      foreach (split(/\,/,
      $ENV{'course.'.$ENV{'request.course.id'}.'.comment.email'})
        ) {
       $to{$_}=1;        $to{$_}=1;
     } split(/\,/,      } 
     $ENV{'course.'.$ENV{'request.course.id'}.'.comment.email'});  
   }    }
   if ($ENV{'form.policy'}) {    if ($ENV{'form.policy'}) {
     $typestyle.='Submitting as Policy Feedback<br>';      $typestyle.='Submitting as Policy Feedback<br>';
     map {      foreach (split(/\,/,
      $ENV{'course.'.$ENV{'request.course.id'}.'.policy.email'})
        ) {
       $to{$_}=1;        $to{$_}=1;
     } split(/\,/,      } 
     $ENV{'course.'.$ENV{'request.course.id'}.'.policy.email'});  
   }    }
   return ($typestyle,%to);    return ($typestyle,%to);
 }  }
Line 282  sub send_msg { Line 289  sub send_msg {
   my ($feedurl,$email,$citations,%to)=@_;    my ($feedurl,$email,$citations,%to)=@_;
   my $status='';    my $status='';
   my $sendsomething=0;    my $sendsomething=0;
   map {    foreach (keys %to) {
     if ($_) {      if ($_) {
         my $declutter=&Apache::lonnet::declutter($feedurl);
       unless (&Apache::lonmsg::user_normal_msg(split(/\:/,$_),        unless (&Apache::lonmsg::user_normal_msg(split(/\:/,$_),
                'Feedback '.$feedurl,$email,$citations) eq 'ok') {                 'Feedback ['.$declutter.']',$email,$citations) eq 'ok') {
  $status.='<br>Error sending message to '.$_.'<br>';   $status.='<br>Error sending message to '.$_.'<br>';
       } else {        } else {
  $sendsomething++;   $sendsomething++;
       }        }
     }      }
   } keys %to;    }
   
     my %record=&Apache::lonnet::restore('_feedback');      my %record=&Apache::lonnet::restore('_feedback');
     my ($temp)=keys %record;      my ($temp)=keys %record;
Line 310  sub send_msg { Line 318  sub send_msg {
 sub adddiscuss {  sub adddiscuss {
     my ($symb,$email,$anon)=@_;      my ($symb,$email,$anon)=@_;
     my $status='';      my $status='';
     if (&Apache::lonnet::allowed('pch',$ENV{'request.course.id'})) {      if (&Apache::lonnet::allowed('pch',$ENV{'request.course.id'}.
           ($ENV{'request.course.sec'}?'/'.$ENV{'request.course.sec'}:''))) {
   
     my %contrib=('message'      => $email,      my %contrib=('message'      => $email,
                  'sendername'   => $ENV{'user.name'},                   'sendername'   => $ENV{'user.name'},
                  'senderdomain' => $ENV{'user.domain'});                   'senderdomain' => $ENV{'user.domain'},
                    'screenname'   => $ENV{'environment.screenname'},
                    'plainname'    => $ENV{'environment.firstname'}.' '.
                      $ENV{'environment.middlename'}.' '.
                                      $ENV{'environment.lastname'}.' '.
                                      $ENV{'enrironment.generation'});
     if ($anon) {      if ($anon) {
  $contrib{'anonymous'}='true';   $contrib{'anonymous'}='true';
     }      }
Line 354  sub handler { Line 368  sub handler {
   
 # --------------------------- Get query string for limited number of parameters  # --------------------------- Get query string for limited number of parameters
   
     map {     &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
        my ($name, $value) = split(/=/,$_);                                             ['hide','unhide','postdata']);
        $value =~ tr/+/ /;  
        $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C",hex($1))/eg;  
        if (($name eq 'hide') || ($name eq 'unhide')) {  
            unless ($ENV{'form.'.$name}) {  
               $ENV{'form.'.$name}=$value;  
    }  
        }  
     } (split(/&/,$ENV{'QUERY_STRING'}));  
   
   if (($ENV{'form.hide'}) || ($ENV{'form.unhide'})) {    if (($ENV{'form.hide'}) || ($ENV{'form.unhide'})) {
 # ----------------------------------------------------------------- Hide/unhide  # ----------------------------------------------------------------- Hide/unhide
Line 393  sub handler { Line 399  sub handler {
                      $ENV{'course.'.$ENV{'request.course.id'}.'.domain'},                       $ENV{'course.'.$ENV{'request.course.id'}.'.domain'},
      $ENV{'course.'.$ENV{'request.course.id'}.'.num'});       $ENV{'course.'.$ENV{'request.course.id'}.'.num'});
   
     &redirect_back($r,'/res/'.$url,'Changed discussion status<p>','0');      &redirect_back($r,&Apache::lonnet::clutter($url),
          'Changed discussion status<p>','0','0');
         
   } else {    } else {
 # ------------------------------------------------------------- Normal feedback  # ------------------------------------------------------------- Normal feedback
   my $feedurl=$ENV{'form.postdata'};    my $feedurl=$ENV{'form.postdata'};
Line 404  sub handler { Line 409  sub handler {
   $feedurl=~s/^$ENV{'HTTP_HOST'}//;    $feedurl=~s/^$ENV{'HTTP_HOST'}//;
   
   my $symb=&Apache::lonnet::symbread($feedurl);    my $symb=&Apache::lonnet::symbread($feedurl);
     unless ($symb) {
         $symb=$ENV{'form.symb'};
         if ($symb) {
     my ($map,$id,$url)=split(/\_\_\_/,$symb);
             $feedurl=&Apache::lonnet::clutter($url);
         }
     }
   my $goahead=1;    my $goahead=1;
   if ($feedurl=~/\.(problem|exam|quiz|assess|survey|form)$/) {    if ($feedurl=~/\.(problem|exam|quiz|assess|survey|form)$/) {
       unless ($symb) { $goahead=0; }        unless ($symb) { $goahead=0; }
Line 420  sub handler { Line 432  sub handler {
       )         ) 
       ||         || 
       ($ENV{'request.course.id'} && ($feedurl!~m:^/adm:))        ($ENV{'request.course.id'} && ($feedurl!~m:^/adm:))
         ||
         ($ENV{'request.course.id'} && ($symb=~/^bulletin\_\_\_/))
      ) {       ) {
 # --------------------------------------------------- Print login screen header  # --------------------------------------------------- Print login screen header
     unless ($ENV{'form.sendit'}) {      unless ($ENV{'form.sendit'}) {
Line 454  sub handler { Line 468  sub handler {
   
 # Discussion? Store that.  # Discussion? Store that.
   
         my $numpost=0;
       if ($ENV{'form.discuss'}) {        if ($ENV{'form.discuss'}) {
   $typestyle.=&adddiscuss($symb,$message);    $typestyle.=&adddiscuss($symb,$message);
     $numpost++;
       }        }
   
       if ($ENV{'form.anondiscuss'}) {        if ($ENV{'form.anondiscuss'}) {
   $typestyle.=&adddiscuss($symb,$message,1);    $typestyle.=&adddiscuss($symb,$message,1);
     $numpost++;
       }        }
   
   
 # Receipt screen and redirect back to where came from  # Receipt screen and redirect back to where came from
       &redirect_back($r,$feedurl,$typestyle,$numsent,$status);        &redirect_back($r,$feedurl,$typestyle,$numsent,$numpost,$status);
   
     }      }
    } else {     } else {
Line 481  sub handler { Line 498  sub handler {
   
 1;  1;
 __END__  __END__
   
   
   
   

Removed from v.1.21  
changed lines
  Added in v.1.32


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>