File:  [LON-CAPA] / loncom / interface / lonfeedback.pm
Revision 1.42: download - view: text, annotated - select for diffs
Sat Mar 29 22:50:22 2003 UTC (21 years, 2 months ago) by www
Branches: MAIN
CVS tags: HEAD
Work on small attachments for discussion and feedback

    1: # The LearningOnline Network
    2: # Feedback
    3: #
    4: # $Id: lonfeedback.pm,v 1.42 2003/03/29 22:50:22 www Exp $
    5: #
    6: # Copyright Michigan State University Board of Trustees
    7: #
    8: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
    9: #
   10: # LON-CAPA is free software; you can redistribute it and/or modify
   11: # it under the terms of the GNU General Public License as published by
   12: # the Free Software Foundation; either version 2 of the License, or
   13: # (at your option) any later version.
   14: #
   15: # LON-CAPA is distributed in the hope that it will be useful,
   16: # but WITHOUT ANY WARRANTY; without even the implied warranty of
   17: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   18: # GNU General Public License for more details.
   19: #
   20: # You should have received a copy of the GNU General Public License
   21: # along with LON-CAPA; if not, write to the Free Software
   22: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   23: #
   24: # /home/httpd/html/adm/gpl.txt
   25: #
   26: # http://www.lon-capa.org/
   27: #
   28: # (Internal Server Error Handler
   29: #
   30: # (Login Screen
   31: # 5/21/99,5/22,5/25,5/26,5/31,6/2,6/10,7/12,7/14,
   32: # 1/14/00,5/29,5/30,6/1,6/29,7/1,11/9 Gerd Kortemeyer)
   33: #
   34: # 3/1/1 Gerd Kortemeyer)
   35: #
   36: # 3/1,2/3,2/5,2/6,2/8 Gerd Kortemeyer
   37: # 2/9 Guy Albertelli
   38: # 2/10 Gerd Kortemeyer
   39: # 2/13 Guy Albertelli
   40: # 7/25 Gerd Kortemeyer
   41: # 7/26 Guy Albertelli
   42: # 7/26,8/10,10/1,11/5,11/6,12/27,12/29 Gerd Kortemeyer
   43: # YEAR=2002
   44: # 1/1,1/16 Gerd Kortemeyer
   45: #
   46: 
   47: package Apache::lonfeedback;
   48: 
   49: use strict;
   50: use Apache::Constants qw(:common);
   51: use Apache::lonmsg();
   52: use Apache::loncommon();
   53: use Apache::lontexconvert();
   54: 
   55: sub mail_screen {
   56:   my ($r,$feedurl,$options) = @_;
   57:   my $bodytag=&Apache::loncommon::bodytag('Resource Feedback and Discussion',
   58:                                           '','onLoad="window.focus();"');
   59:   $r->print(<<ENDDOCUMENT);
   60: <html>
   61: <head>
   62: <title>The LearningOnline Network with CAPA</title>
   63: <meta http-equiv="pragma" content="no-cache"></meta>
   64: <script>
   65:     function gosubmit() {
   66:         var rec=0;
   67:         if (typeof(document.mailform.elements.author)!="undefined") {
   68:           if (document.mailform.elements.author.checked) {
   69:              rec=1;
   70:           } 
   71:         }
   72:         if (typeof(document.mailform.elements.question)!="undefined") {
   73:           if (document.mailform.elements.question.checked) {
   74:              rec=1;
   75:           } 
   76:         }
   77:         if (typeof(document.mailform.elements.course)!="undefined") {
   78:           if (document.mailform.elements.course.checked) {
   79:              rec=1;
   80:           } 
   81:         }
   82:         if (typeof(document.mailform.elements.policy)!="undefined") {
   83:           if (document.mailform.elements.policy.checked) {
   84:              rec=1;
   85:           } 
   86:         }
   87:         if (typeof(document.mailform.elements.discuss)!="undefined") {
   88:           if (document.mailform.elements.discuss.checked) {
   89:              rec=1;
   90:           } 
   91:         }
   92:         if (typeof(document.mailform.elements.anondiscuss)!="undefined") {
   93:           if (document.mailform.elements.anondiscuss.checked) {
   94:              rec=1;
   95:           } 
   96:         }
   97: 
   98:         if (rec) {
   99: 	    document.mailform.submit();
  100:         } else {
  101:             alert('Please check a feedback type.');
  102: 	}
  103:     }
  104: </script>
  105: </head>
  106: $bodytag
  107: <h2><tt>$feedurl</tt></h2>
  108: <form action="/adm/feedback" method=post name=mailform>
  109: <input type=hidden name=postdata value="$feedurl">
  110: Please check at least one of the following feedback types:
  111: $options<hr>
  112: My question/comment/feedback:<p>
  113: <textarea name=comment cols=60 rows=10 wrap=hard>
  114: </textarea><p>
  115: Attachment (128 KB max size): <input type="file" name="attachment" />
  116: </p>
  117: <p>
  118: <input type="hidden" name="sendit" value="1" />
  119: <input type=button value="Send Feedback" onClick='gosubmit();' />
  120: </p>
  121: </form>
  122: ENDDOCUMENT
  123: $r->print(&generate_preview_button().'</body></html>');
  124: }
  125: 
  126: sub fail_redirect {
  127:   my ($r,$feedurl) = @_;
  128:   $r->print (<<ENDFAILREDIR);
  129: <head><title>Feedback not sent</title>
  130: <meta http-equiv="pragma" content="no-cache"></meta>
  131: <meta HTTP-EQUIV="Refresh" CONTENT="2; url=$feedurl">
  132: </head>
  133: <html>
  134: <body bgcolor="#FFFFFF">
  135: <img align=right src=/adm/lonIcons/lonlogos.gif>
  136: <b>Sorry, no recipients  ...</b>
  137: </body>
  138: </html>
  139: ENDFAILREDIR
  140: }
  141: 
  142: sub redirect_back {
  143:   my ($r,$feedurl,$typestyle,$sendsomething,$sendposts,$status) = @_;
  144:   $r->print (<<ENDREDIR);
  145: <head>
  146: <title>Feedback sent</title>
  147: <meta http-equiv="pragma" content="no-cache"></meta>
  148: <meta HTTP-EQUIV="Refresh" CONTENT="2; url=$feedurl">
  149: </head>
  150: <html>
  151: <body bgcolor="#FFFFFF">
  152: <img align=right src=/adm/lonIcons/lonlogos.gif>
  153: $typestyle
  154: <b>Sent $sendsomething message(s), and $sendposts post(s).</b>
  155: <font color=red>$status</font>
  156: </body>
  157: </html>
  158: ENDREDIR
  159: }
  160: 
  161: sub no_redirect_back {
  162:   my ($r,$feedurl) = @_;
  163:   $r->print (<<ENDNOREDIR);
  164: <head><title>Feedback not sent</title>
  165: <meta http-equiv="pragma" content="no-cache"></meta>
  166: ENDNOREDIR
  167: 
  168:   if ($feedurl!~/^\/adm\/feedback/) { 
  169:     $r->print('<meta HTTP-EQUIV="Refresh" CONTENT="2; url='.$feedurl.'">');
  170:   }
  171:   
  172:   $r->print (<<ENDNOREDIRTWO);
  173: </head>
  174: <html>
  175: <body bgcolor="#FFFFFF">
  176: <img align=right src=/adm/lonIcons/lonlogos.gif>
  177: <b>Sorry, no feedback possible on this resource  ...</b>
  178: </body>
  179: </html>
  180: ENDNOREDIRTWO
  181: }
  182: 
  183: sub screen_header {
  184:   my ($feedurl) = @_;
  185:   my $options='';
  186:   if (($feedurl=~/^\/res\//) && ($feedurl!~/^\/res\/adm/)) {
  187:     $options= 
  188:       '<p><input type=checkbox name=author> Feedback to resource author';
  189:   }
  190:   if (&feedback_available(1)) {
  191:     $options.=
  192:     '<br><input type=checkbox name=question> Question about resource content';
  193:   }
  194:   if (&feedback_available(0,1)) {
  195:     $options.=
  196:       '<br><input type=checkbox name=course> '.
  197: 	'Question/Comment/Feedback about course content';
  198:   }
  199:   if (&feedback_available(0,0,1)) {
  200:     $options.=
  201:       '<br><input type=checkbox name=policy> '.
  202: 	'Question/Comment/Feedback about course policy';
  203:   }
  204: 
  205:   if ($ENV{'request.course.id'}) {
  206:       if (&Apache::lonnet::allowed('pch',
  207:         $ENV{'request.course.id'}.
  208:         ($ENV{'request.course.sec'}?'/'.$ENV{'request.course.sec'}:''))) {
  209:     $options.='<br><input type=checkbox name=discuss> '.
  210: 	'<b>Contribution to course discussion of resource</b>';
  211:     $options.='<br><input type=checkbox name=anondiscuss> '.
  212: 	'<b>Anonymous contribution to course discussion of resource</b>'.
  213:         ' (name only visible to course faculty)';
  214:       }
  215:   }
  216:   return $options;
  217: }
  218: 
  219: sub resource_output {
  220:   my ($feedurl) = @_;
  221:   my $usersaw=&Apache::lonnet::ssi($feedurl);
  222:   $usersaw=~s/\<body[^\>]*\>//gi;
  223:   $usersaw=~s/\<\/body\>//gi;
  224:   $usersaw=~s/\<html\>//gi;
  225:   $usersaw=~s/\<\/html\>//gi;
  226:   $usersaw=~s/\<head\>//gi;
  227:   $usersaw=~s/\<\/head\>//gi;
  228:   $usersaw=~s/action\s*\=/would_be_action\=/gi;
  229:   return $usersaw;
  230: }
  231: 
  232: sub clear_out_html {
  233:   my ($message,$override)=@_;
  234:   my $cid=$ENV{'request.course.id'};
  235:   if (($ENV{"course.$cid.allow_limited_html_in_feedback"} =~ m/yes/i) ||
  236:       ($override)) {
  237:       # allows <B> <I> <P> <A> <LI> <OL> <UL> <EM> <BR> <TT> <STRONG> 
  238:       # <BLOCKQUOTE> <DIV .*> <DIV> <IMG>
  239:       my %html=(B=>1, I=>1, P=>1, A=>1, LI=>1, OL=>1, UL=>1, EM=>1,
  240: 		BR=>1, TT=>1, STRONG=>1, BLOCKQUOTE=>1, DIV=>1, IMG=>1);
  241: 
  242:       $message =~ s/\<(\/?\s*(\w+)[^\>\<]*)/
  243: 	  {($html{uc($2)}&(length($1)<1000))?"\<$1":"\&lt;$1"}/ge;
  244:       $message =~ s/(\<?\s*(\w+)[^\<\>]*)\>/
  245: 	  {($html{uc($2)}&(length($1)<1000))?"$1\>":"$1\&gt;"}/ge;
  246:   } else {
  247:       $message=~s/\<\/*m\s*\>//g;
  248:       $message=~s/\</\&lt\;/g;
  249:       $message=~s/\>/\&gt\;/g;
  250:   }
  251:   return $message;
  252: }
  253: 
  254: sub assemble_email {
  255:   my ($feedurl,$message,$prevattempts,$usersaw,$useranswer)=@_;
  256:   my $email=<<"ENDEMAIL";
  257: Refers to <a href="$feedurl">$feedurl</a>
  258: 
  259: $message
  260: ENDEMAIL
  261:     my $citations=<<"ENDCITE";
  262: <h2>Previous attempts of student (if applicable)</h2>
  263: $prevattempts
  264: <p><hr>
  265: <h2>Original screen output (if applicable)</h2>
  266: $usersaw
  267: <h2>Correct Answer(s) (if applicable)</h2>
  268: $useranswer
  269: ENDCITE
  270:   return ($email,$citations);
  271: }
  272: 
  273: sub secapply {
  274:     my $rec=shift;
  275:     my $defaultflag=shift;
  276:     $rec=~s/\s+//g;
  277:     $rec=~s/\@/\:/g;
  278:     my ($adr,$sections)=($rec=~/^([^\(]+)\(([^\)]+)\)/);
  279:     if ($sections) {
  280: 	foreach (split(/\;/,$sections)) {
  281:             if (($_ eq $ENV{'request.course.sec'}) ||
  282:                 ($defaultflag && ($_ eq '*'))) {
  283:                 return $adr; 
  284:             }
  285:         }
  286:     } else {
  287:        return $rec;
  288:     }
  289:     return '';
  290: }
  291: 
  292: sub decide_receiver {
  293:   my ($feedurl,$author,$question,$course,$policy,$defaultflag) = @_;
  294:   my $typestyle='';
  295:   my %to=();
  296:   if ($ENV{'form.author'}||$author) {
  297:     $typestyle.='Submitting as Author Feedback<br>';
  298:     $feedurl=~/^\/res\/(\w+)\/(\w+)\//;
  299:     $to{$2.':'.$1}=1;
  300:   }
  301:   if ($ENV{'form.question'}||$question) {
  302:     $typestyle.='Submitting as Question<br>';
  303:     foreach (split(/\,/,
  304: 		   $ENV{'course.'.$ENV{'request.course.id'}.'.question.email'})
  305: 	     ) {
  306: 	my $rec=&secapply($_,$defaultflag);
  307:         if ($rec) { $to{$rec}=1; }
  308:     } 
  309:   }
  310:   if ($ENV{'form.course'}||$course) {
  311:     $typestyle.='Submitting as Comment<br>';
  312:     foreach (split(/\,/,
  313: 		   $ENV{'course.'.$ENV{'request.course.id'}.'.comment.email'})
  314: 	     ) {
  315: 	my $rec=&secapply($_,$defaultflag);
  316:         if ($rec) { $to{$rec}=1; }
  317:     } 
  318:   }
  319:   if ($ENV{'form.policy'}||$policy) {
  320:     $typestyle.='Submitting as Policy Feedback<br>';
  321:     foreach (split(/\,/,
  322: 		   $ENV{'course.'.$ENV{'request.course.id'}.'.policy.email'})
  323: 	     ) {
  324: 	my $rec=&secapply($_,$defaultflag);
  325:         if ($rec) { $to{$rec}=1; }
  326:     } 
  327:   }
  328:   if ((scalar(%to) eq '0') && (!$defaultflag)) {
  329:      ($typestyle,%to)=
  330: 	 &decide_receiver($feedurl,$author,$question,$course,$policy,1);
  331:   }
  332:   return ($typestyle,%to);
  333: }
  334: 
  335: sub feedback_available {
  336:     my ($question,$course,$policy)=@_;
  337:     my ($typestyle,%to)=&decide_receiver('',0,$question,$course,$policy);
  338:     return scalar(%to);
  339: }
  340: 
  341: sub send_msg {
  342:   my ($feedurl,$email,$citations,%to)=@_;
  343:   my $status='';
  344:   my $sendsomething=0;
  345:   foreach (keys %to) {
  346:     if ($_) {
  347:       my $declutter=&Apache::lonnet::declutter($feedurl);
  348:       unless (&Apache::lonmsg::user_normal_msg(split(/\:/,$_),
  349:                'Feedback ['.$declutter.']',$email,$citations,$feedurl)=~/ok/) {
  350: 	$status.='<br>Error sending message to '.$_.'<br>';
  351:       } else {
  352: 	$sendsomething++;
  353:       }
  354:     }
  355:   }
  356: 
  357:     my %record=&Apache::lonnet::restore('_feedback');
  358:     my ($temp)=keys %record;
  359:     unless ($temp=~/^error\:/) {
  360:        my %newrecord=();
  361:        $newrecord{'resource'}=$feedurl;
  362:        $newrecord{'subnumber'}=$record{'subnumber'}+1;
  363:        unless (&Apache::lonnet::cstore(\%newrecord,'_feedback') eq 'ok') {
  364: 	   $status.='<br>Not registered<br>';
  365:        }
  366:     }
  367:        
  368:   return ($status,$sendsomething);
  369: }
  370: 
  371: sub adddiscuss {
  372:     my ($symb,$email,$anon,$attachmenturl)=@_;
  373:     my $status='';
  374:     if (&Apache::lonnet::allowed('pch',$ENV{'request.course.id'}.
  375:         ($ENV{'request.course.sec'}?'/'.$ENV{'request.course.sec'}:''))) {
  376: 
  377:     my %contrib=('message'      => $email,
  378:                  'sendername'   => $ENV{'user.name'},
  379:                  'senderdomain' => $ENV{'user.domain'},
  380:                  'screenname'   => $ENV{'environment.screenname'},
  381:                  'plainname'    => $ENV{'environment.firstname'}.' '.
  382: 		                   $ENV{'environment.middlename'}.' '.
  383:                                    $ENV{'environment.lastname'}.' '.
  384:                                    $ENV{'enrironment.generation'},
  385:                  'attachment'   => $attachmenturl);
  386:     if ($anon) {
  387: 	$contrib{'anonymous'}='true';
  388:     }
  389:     if (($symb) && ($email)) {
  390:        $status='Adding to class discussion'.($anon?' (anonymous)':'').': '.
  391:         &Apache::lonnet::store(\%contrib,$symb,$ENV{'request.course.id'},
  392:                      $ENV{'course.'.$ENV{'request.course.id'}.'.domain'},
  393: 		     $ENV{'course.'.$ENV{'request.course.id'}.'.num'});
  394:         my %storenewentry=($symb => time);
  395:         $status.='<br>Updating discussion time: '.
  396:         &Apache::lonnet::put('discussiontimes',\%storenewentry,
  397:                      $ENV{'course.'.$ENV{'request.course.id'}.'.domain'},
  398: 		     $ENV{'course.'.$ENV{'request.course.id'}.'.num'});
  399:     }
  400:     my %record=&Apache::lonnet::restore('_discussion');
  401:     my ($temp)=keys %record;
  402:     unless ($temp=~/^error\:/) {
  403:        my %newrecord=();
  404:        $newrecord{'resource'}=$symb;
  405:        $newrecord{'subnumber'}=$record{'subnumber'}+1;
  406:        $status.='<br>Registering: '.
  407:                &Apache::lonnet::cstore(\%newrecord,'_discussion');
  408:     }
  409:     } else {
  410: 	$status.='Failed.';
  411:     }
  412:     return $status.'<br>';   
  413: }
  414: 
  415: # ----------------------------------------------------------- Preview function
  416: 
  417: sub show_preview {
  418:     my $r=shift;
  419:     my $message=&clear_out_html($ENV{'form.comment'});
  420:     $message=~s/\n/\<br \/\>/g;
  421:     $message=&Apache::lontexconvert::msgtexconverted($message);
  422:     $r->print('<table border="2"><tr><td>'.
  423:        $message.'</td></tr></table>');
  424: }
  425: 
  426: sub generate_preview_button {
  427:     return(<<ENDPREVIEW);
  428: <form name="preview" action="/adm/feedback?preview=1" method="post" target="preview">
  429: <input type="hidden" name="comment" />
  430: <input type="button" value="Show Preview"
  431: onClick="this.form.comment.value=document.mailform.comment.value;this.form.submit();" />
  432: </form>
  433: ENDPREVIEW
  434: }
  435: sub handler {
  436:   my $r = shift;
  437:   if ($r->header_only) {
  438:      $r->content_type('text/html');
  439:      $r->send_http_header;
  440:      return OK;
  441:   }
  442: 
  443: # --------------------------- Get query string for limited number of parameters
  444: 
  445:    &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
  446:                              ['hide','unhide','deldisc','postdata','preview']);
  447: 
  448:   if (($ENV{'form.hide'}) || ($ENV{'form.unhide'})) {
  449: # ----------------------------------------------------------------- Hide/unhide
  450:     $r->content_type('text/html');
  451:     $r->send_http_header;
  452: 
  453:     my $entry=$ENV{'form.hide'}?$ENV{'form.hide'}:$ENV{'form.unhide'};
  454: 
  455:     my ($symb,$idx)=split(/\:\:\:/,$entry);
  456:     my ($map,$ind,$url)=split(/\_\_\_/,$symb);
  457: 
  458:     my %contrib=&Apache::lonnet::restore($symb,$ENV{'request.course.id'},
  459:                      $ENV{'course.'.$ENV{'request.course.id'}.'.domain'},
  460: 		     $ENV{'course.'.$ENV{'request.course.id'}.'.num'});
  461: 
  462:         
  463:     my $currenthidden=$contrib{'hidden'};
  464:     
  465:     if ($ENV{'form.hide'}) {
  466: 	$currenthidden.='.'.$idx.'.';
  467:     } else {
  468:         $currenthidden=~s/\.$idx\.//g;
  469:     }
  470:     my %newhash=('hidden' => $currenthidden);
  471: 
  472:     &Apache::lonnet::store(\%newhash,$symb,$ENV{'request.course.id'},
  473:                      $ENV{'course.'.$ENV{'request.course.id'}.'.domain'},
  474: 		     $ENV{'course.'.$ENV{'request.course.id'}.'.num'});
  475: 
  476:     &redirect_back($r,&Apache::lonnet::clutter($url),
  477:        'Changed discussion status<p>','0','0');
  478:   } elsif ($ENV{'form.deldisc'}) {
  479: # --------------------------------------------------------------- Hide for good
  480:     $r->content_type('text/html');
  481:     $r->send_http_header;
  482: 
  483:     my $entry=$ENV{'form.deldisc'};
  484: 
  485:     my ($symb,$idx)=split(/\:\:\:/,$entry);
  486:     my ($map,$ind,$url)=split(/\_\_\_/,$symb);
  487: 
  488:     my %contrib=&Apache::lonnet::restore($symb,$ENV{'request.course.id'},
  489:                      $ENV{'course.'.$ENV{'request.course.id'}.'.domain'},
  490: 		     $ENV{'course.'.$ENV{'request.course.id'}.'.num'});
  491: 
  492:         
  493:     my $currentdeleted=$contrib{'deleted'};
  494:     
  495:     $currentdeleted.='.'.$idx.'.';
  496: 
  497:     my %newhash=('deleted' => $currentdeleted);
  498: 
  499:     &Apache::lonnet::store(\%newhash,$symb,$ENV{'request.course.id'},
  500:                      $ENV{'course.'.$ENV{'request.course.id'}.'.domain'},
  501: 		     $ENV{'course.'.$ENV{'request.course.id'}.'.num'});
  502: 
  503:     &redirect_back($r,&Apache::lonnet::clutter($url),
  504:        'Changed discussion status<p>','0','0');
  505:   } elsif ($ENV{'form.preview'}) {
  506: # -------------------------------------------------------- User wants a preview
  507:       &show_preview($r);
  508:   } else {
  509: # ------------------------------------------------------------- Normal feedback
  510:   my $feedurl=$ENV{'form.postdata'};
  511:   $feedurl=~s/^http\:\/\///;
  512:   $feedurl=~s/^$ENV{'SERVER_NAME'}//;
  513:   $feedurl=~s/^$ENV{'HTTP_HOST'}//;
  514: 
  515:   my $symb=&Apache::lonnet::symbread($feedurl);
  516:   unless ($symb) {
  517:       $symb=$ENV{'form.symb'};
  518:       if ($symb) {
  519: 	  my ($map,$id,$url)=split(/\_\_\_/,$symb);
  520:           $feedurl=&Apache::lonnet::clutter($url);
  521:       }
  522:   }
  523:   my $goahead=1;
  524:   if ($feedurl=~/\.(problem|exam|quiz|assess|survey|form)$/) {
  525:       unless ($symb) { $goahead=0; }
  526:   }
  527: 
  528:   if ($goahead) {
  529: # Go ahead with feedback, no ambiguous reference
  530:     $r->content_type('text/html');
  531:     $r->send_http_header;
  532:   
  533:     if (
  534:       (
  535:        ($feedurl=~m:^/res:) && ($feedurl!~m:^/res/adm:)
  536:       ) 
  537:       || 
  538:       ($ENV{'request.course.id'} && ($feedurl!~m:^/adm:))
  539:       ||
  540:       ($ENV{'request.course.id'} && ($symb=~/^bulletin\_\_\_/))
  541:      ) {
  542: # --------------------------------------------------- Print login screen header
  543:     unless ($ENV{'form.sendit'}) {
  544:       my $options=&screen_header($feedurl);
  545:       if ($options) {
  546: 	&mail_screen($r,$feedurl,$options);
  547:       } else {
  548: 	&fail_redirect($r,$feedurl);
  549:       }
  550:     } else {
  551:       
  552: # Get previous user input
  553:       my $prevattempts=&Apache::loncommon::get_previous_attempt(
  554:             $symb,$ENV{'user.name'},$ENV{'user.domain'},
  555:             $ENV{'request.course.id'});
  556: 
  557: # Get output from resource
  558:       my $usersaw=&resource_output($feedurl);
  559: 
  560: # Get resource answer
  561:       my $useranswer=&Apache::loncommon::get_student_answers(
  562:                        $symb,$ENV{'user.name'},$ENV{'user.domain'},
  563: 		       $ENV{'request.course.id'});
  564: # Get attachments, if any, and not too large
  565:       my $attachmenturl='';
  566:       if ($ENV{'form.attachment.filename'}) {
  567: 	  unless (length($ENV{'form.attachment'})>131072) {
  568: 	      $attachmenturl=&Apache::lonnet::userfileupload('attachment',1);
  569: 	  }
  570:       }
  571: # Filter HTML out of message (could be nasty)
  572:       my $message=&clear_out_html($ENV{'form.comment'});
  573: 
  574: # Assemble email
  575:       my ($email,$citations)=&assemble_email($feedurl,$message,$prevattempts,
  576:           $usersaw,$useranswer);
  577:  
  578: # Who gets this?
  579:       my ($typestyle,%to) = &decide_receiver($feedurl);
  580: 
  581: # Actually send mail
  582:       my ($status,$numsent)=&send_msg($feedurl,$email,$citations,%to);
  583: 
  584: # Discussion? Store that.
  585: 
  586:       my $numpost=0;
  587:       if ($ENV{'form.discuss'}) {
  588: 	  $typestyle.=&adddiscuss($symb,$message,0,$attachmenturl);
  589: 	  $numpost++;
  590:       }
  591: 
  592:       if ($ENV{'form.anondiscuss'}) {
  593: 	  $typestyle.=&adddiscuss($symb,$message,1,$attachmenturl);
  594: 	  $numpost++;
  595:       }
  596: 
  597: 
  598: # Receipt screen and redirect back to where came from
  599:       &redirect_back($r,$feedurl,$typestyle,$numsent,$numpost,$status);
  600: 
  601:     }
  602:    } else {
  603: # Unable to give feedback
  604:     &no_redirect_back($r,$feedurl);
  605:    }
  606:   } else {
  607: # Ambiguous Problem Resource
  608:     $r->internal_redirect('/adm/ambiguous');
  609:   }
  610: }
  611:   return OK;
  612: } 
  613: 
  614: 1;
  615: __END__

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