Diff for /loncom/interface/lonfeedback.pm between versions 1.370.2.5.2.5 and 1.388

version 1.370.2.5.2.5, 2023/10/06 23:03:46 version 1.388, 2022/01/18 16:55:30
Line 1003  sub postingform_display { Line 1003  sub postingform_display {
             }              }
         }          }
     }      }
       my $postanon;
       if (&Apache::lonnet::allowed('pac',$env{'request.course.id'}.
          ($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:''))) {
           $postanon = '<input type="submit" name="anondiscuss" value="'.$lt{'poan'}.'" />';
       }
     $postingform .= (<<ENDDISCUSS);      $postingform .= (<<ENDDISCUSS);
 <form action="/adm/feedback" method="post" name="mailform" enctype="multipart/form-data"> <input type="submit" name="discuss" value="$lt{'podi'}" />  <form action="/adm/feedback" method="post" name="mailform" enctype="multipart/form-data"> <input type="submit" name="discuss" value="$lt{'podi'}" />
 <input type="submit" name="anondiscuss" value="$lt{'poan'}" /> <input type="hidden" name="symb" value="$ressymb" />  $postanon<input type="hidden" name="symb" value="$ressymb" />
 <input type="hidden" name="sendit" value="true" />  <input type="hidden" name="sendit" value="true" />
 <input type="hidden" name="timestamp" value="$now" />  <input type="hidden" name="timestamp" value="$now" />
 <a name="newpost"></a>  <a name="newpost"></a>
Line 1307  sub build_posting_display { Line 1312  sub build_posting_display {
                                 @{$$usernamesort{$contrib{$idx.':senderdomain'}}{$contrib{$idx.':sendername'}}} = ("$idx");                                  @{$$usernamesort{$contrib{$idx.':senderdomain'}}{$contrib{$idx.':sendername'}}} = ("$idx");
                             }                              }
 # Set up for sorting by last name, then first name  # Set up for sorting by last name, then first name
                             my %names = &Apache::loncommon::getnames($contrib{$idx.':sendername'},                              my %names = &Apache::lonnet::get('environment',
                                                                      $contrib{$idx.':senderdomain'});                                   ['firstname','lastname'],$contrib{$idx.':senderdomain'},
                                     ,$contrib{$idx.':sendername'});
                             my $lastname = $names{'lastname'};                              my $lastname = $names{'lastname'};
                             my $firstname = $names{'firstname'};                              my $firstname = $names{'firstname'};
                             if ($lastname eq '') {                              if ($lastname eq '') {
Line 1688  sub get_post_contents { Line 1694  sub get_post_contents {
                                         $$contrib{$idx.':sendername'},                                          $$contrib{$idx.':sendername'},
                                         $$contrib{$idx.':senderdomain'});                                          $$contrib{$idx.':senderdomain'});
     $$screenname=$$contrib{$idx.':screenname'};      $$screenname=$$contrib{$idx.':screenname'};
     $$showaboutme = &Apache::loncommon::aboutme_on($$contrib{$idx.':sendername'},      $$showaboutme = &Apache::lonnet::usertools_access($$contrib{$idx.':sendername'},
                                                    $$contrib{$idx.':senderdomain'});                                                        $$contrib{$idx.':senderdomain'},
                                                         'aboutme');
     my $sender = $$plainname;      my $sender = $$plainname;
     if ($$showaboutme) {      if ($$showaboutme) {
         $sender = &Apache::loncommon::aboutmewrapper(          $sender = &Apache::loncommon::aboutmewrapper(
Line 2108  END Line 2115  END
         $r->print('<input type="hidden" name="ref" value="'.$env{'form.ref'}.'" />');          $r->print('<input type="hidden" name="ref" value="'.$env{'form.ref'}.'" />');
     }      }
     $r->print(<<END);      $r->print(<<END);
 <input type="hidden" name="sendit" value="1" />  <input type="hidden" name="sendit" value="1" /><br /><br />
 <input type="button" value="$send" onclick='gosubmit();' />  <input type="button" value="$send" onclick='gosubmit();' />
 </form>  </form>
 END  END
Line 2756  sub fail_redirect { Line 2763  sub fail_redirect {
   my $logo=&Apache::loncommon::lonhttpdurl('/adm/lonIcons/lonlogos.gif');    my $logo=&Apache::loncommon::lonhttpdurl('/adm/lonIcons/lonlogos.gif');
   my %parms=('only_body'   => 1);    my %parms=('only_body'   => 1);
   if ($delay !~ /^\d+(|\.\d+)$/) {    if ($delay !~ /^\d+(|\.\d+)$/) {
       $delay = 2;        $delay = 0;
   }    }
   if ($env{'form.modal'}) {    if ($env{'form.modal'}) {
       my $onload = 'document.forms.reldt.submit()';        my $onload = 'document.forms.reldt.submit()';
Line 2772  sub fail_redirect { Line 2779  sub fail_redirect {
   }    }
   $r->print(&Apache::loncommon::start_page('Feedback not sent',undef,\%parms));    $r->print(&Apache::loncommon::start_page('Feedback not sent',undef,\%parms));
   my $windowname = 'loncapaclient';    my $windowname = 'loncapaclient';
     if ($env{'request.lti.login'}) {
        $windowname .= 'lti';
     }
   $r->print(<<ENDFAILREDIR);    $r->print(<<ENDFAILREDIR);
 <img align="right" src="$logo" />  <img align="right" src="$logo" />
 <p class="LC_warning">$lt{'sorr'}</p>  <p class="LC_warning">$lt{'sorr'}</p>
Line 2783  ENDFAILREDIR Line 2793  ENDFAILREDIR
   
 sub redirect_back {  sub redirect_back {
   my ($r,$feedurl,$typestyle,$sendsomething,$sendposts,$blog,$status,$previous,$sort,    my ($r,$feedurl,$typestyle,$sendsomething,$sendposts,$blog,$status,$previous,$sort,
       $rolefilter,$statusfilter,$sectionpick,$grouppick,$numpicks,$group,$toolarge,$delay) = @_;        $rolefilter,$statusfilter,$sectionpick,$grouppick,$numpicks,$group,$toolarge) = @_;
   my $sorttag = '';    my $sorttag = '';
   my $roletag = '';    my $roletag = '';
   my $statustag = '';    my $statustag = '';
Line 2882  sub redirect_back { Line 2892  sub redirect_back {
   &Apache::lonenc::check_encrypt(\$feedurl);    &Apache::lonenc::check_encrypt(\$feedurl);
   my $logo=&Apache::loncommon::lonhttpdurl('/adm/lonIcons/lonlogos.gif');    my $logo=&Apache::loncommon::lonhttpdurl('/adm/lonIcons/lonlogos.gif');
   my %parms=('only_body'   => 1);    my %parms=('only_body'   => 1);
   if ($delay !~ /^\d+(|\.\d+)$/) {  
       $delay = 0;  
   }  
   if ($env{'form.modal'}) {    if ($env{'form.modal'}) {
       my $onload = 'document.forms.reldt.submit()';        my $onload = 'document.forms.reldt.submit()';
       if ($delay) {  
           my $js_delay = int(1000 * $delay);  
           $onload = "setTimeout(function(){  
                         document.forms.reldt.submit();  
                      },$js_delay);";  
       }  
       $parms{'add_entries'}={'onload' => $onload};        $parms{'add_entries'}={'onload' => $onload};
   } else {    } else {
       $parms{'redirect'}=[$delay,$feedurl];        $parms{'redirect'}=[0,$feedurl];
   }    }
   my $start_page=    my $start_page=
       &Apache::loncommon::start_page('Feedback sent',undef,\%parms);        &Apache::loncommon::start_page('Feedback sent',undef,\%parms);
   my $end_page = &Apache::loncommon::end_page();    my $end_page = &Apache::loncommon::end_page();
     my $windowname = 'loncapaclient';
     if ($env{'request.lti.login'}) {
        $windowname .= 'lti';
     }
   $r->print(<<ENDREDIR);    $r->print(<<ENDREDIR);
 $start_page  $start_page
 <img align="right" src="$logo" />  <img align="right" src="$logo" />
Line 2908  $typestyle Line 2913  $typestyle
 $blog  $blog
 $toolarge  $toolarge
 <font color="red">$status</font>  <font color="red">$status</font>
 <form name="reldt" action="$feedurl" target="loncapaclient">  <form name="reldt" action="$feedurl" target="$windowname">
 $prevtag  $prevtag
 $sorttag  $sorttag
 $statustag  $statustag
Line 2941  sub no_redirect_back { Line 2946  sub no_redirect_back {
                          },$js_delay);";                           },$js_delay);";
           }            }
           $parms{'add_entries'}={'onload' => $onload};            $parms{'add_entries'}={'onload' => $onload};
           my $windowname = 'loncapaclient';             my $windowname = 'loncapaclient';
             if ($env{'request.lti.login'}) {
                 $windowname .= 'lti';
             }
           $form_for_modal = <<ENDFORM;            $form_for_modal = <<ENDFORM;
 <form name="reldt" action="$feedurl" target="$windowname">  <form name="reldt" action="$feedurl" target="$windowname">
 </form>  </form>
Line 2952  ENDFORM Line 2960  ENDFORM
           $parms{'redirect'}=[$delay,$feedurl];            $parms{'redirect'}=[$delay,$feedurl];
       }        }
   }    }
    
   my $start_page=    my $start_page=
       &Apache::loncommon::start_page('Feedback not sent',undef,        &Apache::loncommon::start_page('Feedback not sent',undef,
      \%parms);       \%parms);
Line 2975  sub screen_header { Line 2984  sub screen_header {
                     question => 'Question about resource content',                      question => 'Question about resource content',
                     comment => 'Question/Comment/Feedback about course content',                      comment => 'Question/Comment/Feedback about course content',
                     policy => 'Question/Comment/Feedback about course policy',                      policy => 'Question/Comment/Feedback about course policy',
                   );                    );  
     my $contribdisc = &mt('Contribution to course discussion of resource');      my $contribdisc = &mt('Contribution to course discussion of resource');
     my $anoncontrib = &mt('Anonymous contribution to course discussion of resource');      my $anoncontrib = &mt('Anonymous contribution to course discussion of resource');
     my $namevis = &mt('name only visible to course faculty');      my $namevis = &mt('name only visible to course faculty');
Line 2984  sub screen_header { Line 2993  sub screen_header {
         $crstype = &Apache::loncommon::course_type();          $crstype = &Apache::loncommon::course_type();
         if ($crstype eq 'Community') {          if ($crstype eq 'Community') {
             $default{'comment'} = &mt('Question/Comment/Feedback about community content');              $default{'comment'} = &mt('Question/Comment/Feedback about community content');
             $default{'policy'} = &mt('Question/Comment/Feedback about community policy');              $default{'policy'} = &mt('Question/Comment/Feedback about community policy'); 
             $contribdisc = &mt('Contribution to community discussion of resource');              $contribdisc = &mt('Contribution to community discussion of resource');
             $anoncontrib = &mt('Anonymous contribution to community discussion of resource');              $anoncontrib = &mt('Anonymous contribution to community discussion of resource');
             $namevis = &mt('name only visible to community facilitators');              $namevis = &mt('name only visible to community facilitators');
Line 3017  sub screen_header { Line 3026  sub screen_header {
         if (!$blocked && &discussion_open(undef,$realsymb) &&          if (!$blocked && &discussion_open(undef,$realsymb) &&
             (&Apache::lonnet::allowed('pch',              (&Apache::lonnet::allowed('pch',
                                       $env{'request.course.id'}.                                        $env{'request.course.id'}.
                                       ($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:'')) ||                                         ($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:'')) ||
             (($group ne '') && ($symb =~ m{^bulletin___\d+___adm/wrapper/adm/\Q$cdom\E/\Q$cnum\E/\d+/bulletinboard$}) && (&check_group_priv($group,'pgd') eq 'ok')))) {              (($group ne '') && ($symb =~ m{^bulletin___\d+___adm/wrapper/adm/\Q$cdom\E/\Q$cnum\E/\d+/bulletinboard$}) && (&check_group_priv($group,'pgd') eq 'ok')))) {
             $discoptions{'nonanon'} = 1;              $discoptions{'nonanon'} = 1;
             $discoptions{'anon'} = 1;              if (&Apache::lonnet::allowed('pac',$env{'request.course.id'}.
                  ($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:''))) {
                   $discoptions{'anon'} = 1;
               }
             $blockblog = &Apache::loncommon::blocking_status('blogs');              $blockblog = &Apache::loncommon::blocking_status('blogs');
         }          }
     }      }
Line 3031  sub screen_header { Line 3043  sub screen_header {
     }      }
     if (keys(%fdbkoptions)) {      if (keys(%fdbkoptions)) {
         if ($fdbkoptions{'author'}) {          if ($fdbkoptions{'author'}) {
             $msgoptions =      $msgoptions =
                 '<label><input type="radio" name="discuss" value="author"'.$checkradio.' /> '.   '<label><input type="radio" name="discuss" value="author"'.$checkradio.' /> '.
                 &mt('Feedback to resource author').'</label><br />';   &mt('Feedback to resource author').'</label><br />';
         }   }
         foreach my $item ('question','comment','policy') {          foreach my $item ('question','comment','policy') {
             my $type = $item;              my $type = $item;
             if ($item eq 'comment') {              if ($item eq 'comment') {
Line 3044  sub screen_header { Line 3056  sub screen_header {
             if ($fdbkoptions{$type}) {              if ($fdbkoptions{$type}) {
                 $msgoptions .=                  $msgoptions .=
                     '<label><input type="radio" name="discuss" value="'.$type.'"'.$checkradio.' />'.                      '<label><input type="radio" name="discuss" value="'.$type.'"'.$checkradio.' />'.
                     ($optionhash?$optionhash:$default{$item}).'</label><br />';                      ($optionhash?$optionhash:$default{$item}).'</label><br />'; 
             }      }
         }          }
     }      }
     if (keys(%discoptions)) {      if (keys(%discoptions)) {
Line 3149  sub feedback_available { Line 3161  sub feedback_available {
 }  }
   
 sub send_msg {  sub send_msg {
     my ($title,$feedurl,$email,$citations,$attachmenturl,$symb,$clientip,%to)=@_;      my ($title,$feedurl,$email,$citations,$attachmenturl,$symb,%to)=@_;
     my $status='';      my $status='';
     my $sendsomething=0;      my $sendsomething=0;
     my $delay;  
     my $senthide;  
     my %setters;  
     my ($startblock,$endblock,$triggerblock,$by_ip,$blockdom) =  
         &Apache::loncommon::blockcheck(\%setters,'com',$clientip);  
     if ($by_ip) {  
         $senthide = 1;  
     }  
     my $restitle = &get_resource_title($symb,$feedurl);      my $restitle = &get_resource_title($symb,$feedurl);
     if ($title=~/^Error/) { $title=&mt('Feedback').': '.$title; }      if ($title=~/^Error/) { $title=&mt('Feedback').': '.$title; }
     unless ($title=~/\w/) { $title=&mt('Feedback'); }      unless ($title=~/\w/) { $title=&mt('Feedback'); }
Line 3173  sub send_msg { Line 3177  sub send_msg {
     } else {      } else {
  unless (&Apache::lonmsg::user_normal_msg($user,$domain,   unless (&Apache::lonmsg::user_normal_msg($user,$domain,
  $title.' ['.$restitle.']',$email,$citations,$feedurl,   $title.' ['.$restitle.']',$email,$citations,$feedurl,
  $attachmenturl,undef,undef,$symb,$restitle,undef,   $attachmenturl,undef,undef,$symb,$restitle)=~/ok/) {
                                                          undef,undef,undef,$senthide)=~/ok/) {  
     $status.='<br />'.&mt('Error sending message to').' '.$key.'<br />';      $status.='<br />'.&mt('Error sending message to').' '.$key.'<br />';
  } else {   } else {
     $sendsomething++;      $sendsomething++;
Line 3182  sub send_msg { Line 3185  sub send_msg {
     }      }
  }   }
     }      }
     if ($sendsomething && $senthide) {  
         if ($by_ip) {  
             my $showdom = &Apache::lonnet::domain($blockdom);  
             if ($showdom eq '') {  
                 $showdom = $blockdom;  
             }  
             $delay = 4;  
             $status.='<br />'.&mt("Message content of feedback you send to instructor(s) from your current IP address: [_1] will be unavailable in your 'Sent' folder.",$clientip).  
                      '<ul><li>'.  
                      &mt('This does not affect delivery of feedback to your instructor(s).').  
                      '</li><li>'.  
                      &mt('Note: some types of communication functionality are blocked for certain IP address(es).').  
                      '</li><li>'.  
                      &mt('This restriction was set by an administrator in the [_1] LON-CAPA domain.',  
                          $showdom).  
                      '</li></ul><br />';  
         }  
     }  
   
 # Records of number of feedback messages are kept under the "symb" called "_feedback"  # Records of number of feedback messages are kept under the "symb" called "_feedback"
 # There are two entries within the framework of a course:  # There are two entries within the framework of a course:
Line 3217  sub send_msg { Line 3202  sub send_msg {
     }      }
         }          }
     }      }
     return ($status,$sendsomething,$delay);      return ($status,$sendsomething);
 }  }
   
 # Routine to get the complete feedback records  # Routine to get the complete feedback records
Line 3641  sub modify_attachments { Line 3626  sub modify_attachments {
    document.modattachments.action = document.modattachments.origpage.value;     document.modattachments.action = document.modattachments.origpage.value;
    document.modattachments.submit();     document.modattachments.submit();
  }   }
 </script>  </script> 
 <script type="text/javascript" src="/res/adm/includes/file_upload.js"></script>  <script type="text/javascript" src="/res/adm/includes/file_upload.js"></script>
 END  END
   
Line 4173  sub handler { Line 4158  sub handler {
   'only_body'   => 1,    'only_body'   => 1,
   'add_entries' => \%onload});    'add_entries' => \%onload});
       my $end_page = &Apache::loncommon::end_page();        my $end_page = &Apache::loncommon::end_page();
         my $windowname = 'loncapaclient';
         if ($env{'request.lti.login'}) {
             $windowname .= 'lti';
         }
       $r->print (<<ENDREDIR);        $r->print (<<ENDREDIR);
 $start_page  $start_page
 <img align="right" src="$logo" />  <img align="right" src="$logo" />
 $textline  $textline
 <form name="reldt" action="$feedurl" target="loncapaclient">  <form name="reldt" action="$feedurl" target="$windowname">
 </form>  </form>
 <br />  <br />
 $end_page  $end_page
Line 4711  ENDREDIR Line 4700  ENDREDIR
   if ($options) {    if ($options) {
       &mail_screen($r,$feedurl,$options,$symb,$attachmax{'text'});        &mail_screen($r,$feedurl,$options,$symb,$attachmax{'text'});
   } else {    } else {
       &fail_redirect($r,$feedurl,2);        &fail_redirect($r,$feedurl,1);
   }    }
   return OK;    return OK;
       }        }
Line 4730  ENDREDIR Line 4719  ENDREDIR
       my $usersymb = &Apache::lonenc::check_encrypt($symb);        my $usersymb = &Apache::lonenc::check_encrypt($symb);
       my $useranswer=        my $useranswer=
           &Apache::loncommon::get_student_answers(            &Apache::loncommon::get_student_answers(
               $symb,$env{'user.name'},$env{'user.domain'},                $usersymb,$env{'user.name'},$env{'user.domain'},
               $env{'request.course.id'});                $env{'request.course.id'});
       &Apache::lonnet::delenv('allowed.vgr');        &Apache::lonnet::delenv('allowed.vgr');
 # Get attachments, if any, and not too large  # Get attachments, if any, and not too large
Line 4777  ENDREDIR Line 4766  ENDREDIR
       my ($typestyle,%to) = &Apache::lonmsg::decide_receiver($feedurl);        my ($typestyle,%to) = &Apache::lonmsg::decide_receiver($feedurl);
   
 # Actually send mail  # Actually send mail
       my $clientip = &Apache::lonnet::get_requestor_ip($r);        my ($status,$numsent)=&send_msg(&clear_out_html($env{'form.subject'}),
       my ($status,$numsent,$delay)=&send_msg(&clear_out_html($env{'form.subject'}),        $feedurl,$email,$citations,
              $feedurl,$email,$citations,        $attachmenturl,$usersymb,%to);
              $attachmenturl,$usersymb,$clientip,%to);  
   
 # Discussion? Store that.  # Discussion? Store that.
       my $numpost=0;        my $numpost=0;
Line 4788  ENDREDIR Line 4776  ENDREDIR
      && $env{'form.discuss'} !~ /^(?:author|question|course|policy)/)       && $env{'form.discuss'} !~ /^(?:author|question|course|policy)/)
    || $env{'form.anondiscuss'} ne '') {     || $env{'form.anondiscuss'} ne '') {
   my $subject = &clear_out_html($env{'form.subject'});    my $subject = &clear_out_html($env{'form.subject'});
   my $anonmode=($env{'form.discuss'} eq 'anon' || $env{'form.anondiscuss'} );            my $anonmode;
             if (&Apache::lonnet::allowed('pac',$env{'request.course.id'}.
                ($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:''))) {
         $anonmode=($env{'form.discuss'} eq 'anon' || $env{'form.anondiscuss'} );
             }
   $typestyle.=&adddiscuss($symb,$message,$anonmode,$attachmenturl,    $typestyle.=&adddiscuss($symb,$message,$anonmode,$attachmenturl,
   $subject,$group);    $subject,$group);
   $numpost++;    $numpost++;
Line 4812  ENDREDIR Line 4804  ENDREDIR
       
 # Receipt screen and redirect back to where came from  # Receipt screen and redirect back to where came from
       &redirect_back($r,$feedurl,$typestyle,$numsent,$numpost,$blog,$status,$env{'form.previous'},        &redirect_back($r,$feedurl,$typestyle,$numsent,$numpost,$blog,$status,$env{'form.previous'},
                      undef,undef,undef,undef,undef,undef,$group,$toolarge,$delay);                       undef,undef,undef,undef,undef,undef,$group,$toolarge);
   }    }
   return OK;    return OK;
 }  }

Removed from v.1.370.2.5.2.5  
changed lines
  Added in v.1.388


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