Annotation of loncom/interface/lonfeedback.pm, revision 1.36

1.1       www         1: # The LearningOnline Network
                      2: # Feedback
                      3: #
1.36    ! www         4: # $Id: lonfeedback.pm,v 1.35 2002/10/25 13:57:28 www Exp $
1.19      albertel    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: #
1.1       www        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: #
1.5       www        36: # 3/1,2/3,2/5,2/6,2/8 Gerd Kortemeyer
1.7       albertel   37: # 2/9 Guy Albertelli
1.8       www        38: # 2/10 Gerd Kortemeyer
1.9       albertel   39: # 2/13 Guy Albertelli
1.10      www        40: # 7/25 Gerd Kortemeyer
1.13      www        41: # 7/26 Guy Albertelli
1.21      www        42: # 7/26,8/10,10/1,11/5,11/6,12/27,12/29 Gerd Kortemeyer
1.22      www        43: # YEAR=2002
1.23      www        44: # 1/1,1/16 Gerd Kortemeyer
1.22      www        45: #
1.7       albertel   46: 
1.1       www        47: package Apache::lonfeedback;
                     48: 
                     49: use strict;
                     50: use Apache::Constants qw(:common);
1.3       www        51: use Apache::lonmsg();
1.9       albertel   52: use Apache::loncommon();
1.33      www        53: use Apache::lontexconvert();
1.1       www        54: 
1.6       albertel   55: sub mail_screen {
                     56:   my ($r,$feedurl,$options) = @_;
1.29      www        57:   my $bodytag=&Apache::loncommon::bodytag('Resource Feedback and Discussion',
                     58:                                           '','onLoad="window.focus();"');
1.6       albertel   59:   $r->print(<<ENDDOCUMENT);
1.1       www        60: <html>
                     61: <head>
                     62: <title>The LearningOnline Network with CAPA</title>
1.7       albertel   63: <meta http-equiv="pragma" content="no-cache"></meta>
1.5       www        64: <script>
                     65:     function gosubmit() {
                     66:         var rec=0;
1.12      albertel   67:         if (typeof(document.mailform.elements.author)!="undefined") {
1.5       www        68:           if (document.mailform.elements.author.checked) {
                     69:              rec=1;
                     70:           } 
                     71:         }
1.12      albertel   72:         if (typeof(document.mailform.elements.question)!="undefined") {
1.5       www        73:           if (document.mailform.elements.question.checked) {
                     74:              rec=1;
                     75:           } 
                     76:         }
1.12      albertel   77:         if (typeof(document.mailform.elements.course)!="undefined") {
1.5       www        78:           if (document.mailform.elements.course.checked) {
                     79:              rec=1;
                     80:           } 
                     81:         }
1.12      albertel   82:         if (typeof(document.mailform.elements.policy)!="undefined") {
1.5       www        83:           if (document.mailform.elements.policy.checked) {
                     84:              rec=1;
                     85:           } 
                     86:         }
1.12      albertel   87:         if (typeof(document.mailform.elements.discuss)!="undefined") {
1.10      www        88:           if (document.mailform.elements.discuss.checked) {
                     89:              rec=1;
                     90:           } 
                     91:         }
1.14      www        92:         if (typeof(document.mailform.elements.anondiscuss)!="undefined") {
                     93:           if (document.mailform.elements.anondiscuss.checked) {
                     94:              rec=1;
                     95:           } 
                     96:         }
1.5       www        97: 
                     98:         if (rec) {
                     99: 	    document.mailform.submit();
                    100:         } else {
                    101:             alert('Please check a feedback type.');
                    102: 	}
                    103:     }
                    104: </script>
1.1       www       105: </head>
1.29      www       106: $bodytag
1.2       www       107: <h2><tt>$feedurl</tt></h2>
1.5       www       108: <form action="/adm/feedback" method=post name=mailform>
1.2       www       109: <input type=hidden name=postdata value="$feedurl">
1.5       www       110: Please check at least one of the following feedback types:
1.2       www       111: $options<hr>
                    112: My question/comment/feedback:<p>
1.16      www       113: <textarea name=comment cols=60 rows=10 wrap=hard>
1.2       www       114: </textarea><p>
1.5       www       115: <input type=hidden name=sendit value=1>
                    116: <input type=button value="Send Feedback" onClick='gosubmit();'></input>
1.2       www       117: </form>
1.1       www       118: ENDDOCUMENT
1.33      www       119: $r->print(&generate_preview_button().'</body></html>');
1.6       albertel  120: }
                    121: 
                    122: sub fail_redirect {
                    123:   my ($r,$feedurl) = @_;
                    124:   $r->print (<<ENDFAILREDIR);
1.5       www       125: <head><title>Feedback not sent</title>
1.7       albertel  126: <meta http-equiv="pragma" content="no-cache"></meta>
1.5       www       127: <meta HTTP-EQUIV="Refresh" CONTENT="2; url=$feedurl">
                    128: </head>
                    129: <html>
                    130: <body bgcolor="#FFFFFF">
1.8       www       131: <img align=right src=/adm/lonIcons/lonlogos.gif>
                    132: <b>Sorry, no recipients  ...</b>
1.5       www       133: </body>
                    134: </html>
                    135: ENDFAILREDIR
                    136: }
1.4       www       137: 
1.6       albertel  138: sub redirect_back {
1.32      albertel  139:   my ($r,$feedurl,$typestyle,$sendsomething,$sendposts,$status) = @_;
1.6       albertel  140:   $r->print (<<ENDREDIR);
1.3       www       141: <head>
                    142: <title>Feedback sent</title>
1.7       albertel  143: <meta http-equiv="pragma" content="no-cache"></meta>
1.5       www       144: <meta HTTP-EQUIV="Refresh" CONTENT="2; url=$feedurl">
1.2       www       145: </head>
                    146: <html>
                    147: <body bgcolor="#FFFFFF">
1.8       www       148: <img align=right src=/adm/lonIcons/lonlogos.gif>
1.5       www       149: $typestyle
1.32      albertel  150: <b>Sent $sendsomething message(s), and $sendposts post(s).</b>
1.3       www       151: <font color=red>$status</font>
1.2       www       152: </body>
                    153: </html>
                    154: ENDREDIR
                    155: }
1.6       albertel  156: 
                    157: sub no_redirect_back {
                    158:   my ($r,$feedurl) = @_;
                    159:   $r->print (<<ENDNOREDIR);
1.2       www       160: <head><title>Feedback not sent</title>
1.7       albertel  161: <meta http-equiv="pragma" content="no-cache"></meta>
                    162: ENDNOREDIR
                    163: 
1.8       www       164:   if ($feedurl!~/^\/adm\/feedback/) { 
1.7       albertel  165:     $r->print('<meta HTTP-EQUIV="Refresh" CONTENT="2; url='.$feedurl.'">');
                    166:   }
                    167:   
1.8       www       168:   $r->print (<<ENDNOREDIRTWO);
1.2       www       169: </head>
                    170: <html>
                    171: <body bgcolor="#FFFFFF">
1.8       www       172: <img align=right src=/adm/lonIcons/lonlogos.gif>
                    173: <b>Sorry, no feedback possible on this resource  ...</b>
1.2       www       174: </body>
                    175: </html>
1.8       www       176: ENDNOREDIRTWO
1.2       www       177: }
1.6       albertel  178: 
                    179: sub screen_header {
                    180:   my ($feedurl) = @_;
                    181:   my $options='';
1.35      www       182:   if (($feedurl=~/^\/res\//) && ($feedurl!~/^\/res\/adm/)) {
1.6       albertel  183:     $options= 
                    184:       '<p><input type=checkbox name=author> Feedback to resource author';
                    185:   }
1.36    ! www       186:   if (&feedback_available(1)) {
1.6       albertel  187:     $options.=
1.8       www       188:     '<br><input type=checkbox name=question> Question about resource content';
1.6       albertel  189:   }
1.36    ! www       190:   if (&feedback_available(0,1)) {
1.6       albertel  191:     $options.=
                    192:       '<br><input type=checkbox name=course> '.
                    193: 	'Question/Comment/Feedback about course content';
                    194:   }
1.36    ! www       195:   if (&feedback_available(0,0,1)) {
1.6       albertel  196:     $options.=
                    197:       '<br><input type=checkbox name=policy> '.
                    198: 	'Question/Comment/Feedback about course policy';
1.10      www       199:   }
1.20      www       200: 
1.10      www       201:   if ($ENV{'request.course.id'}) {
1.23      www       202:       if (&Apache::lonnet::allowed('pch',
                    203:         $ENV{'request.course.id'}.
                    204:         ($ENV{'request.course.sec'}?'/'.$ENV{'request.course.sec'}:''))) {
1.10      www       205:     $options.='<br><input type=checkbox name=discuss> '.
                    206: 	'<b>Contribution to course discussion of resource</b>';
1.14      www       207:     $options.='<br><input type=checkbox name=anondiscuss> '.
                    208: 	'<b>Anonymous contribution to course discussion of resource</b>'.
                    209:         ' (name only visible to course faculty)';
1.20      www       210:       }
1.14      www       211:   }
1.6       albertel  212:   return $options;
                    213: }
                    214: 
                    215: sub resource_output {
                    216:   my ($feedurl) = @_;
                    217:   my $usersaw=&Apache::lonnet::ssi($feedurl);
                    218:   $usersaw=~s/\<body[^\>]*\>//gi;
                    219:   $usersaw=~s/\<\/body\>//gi;
                    220:   $usersaw=~s/\<html\>//gi;
                    221:   $usersaw=~s/\<\/html\>//gi;
                    222:   $usersaw=~s/\<head\>//gi;
                    223:   $usersaw=~s/\<\/head\>//gi;
                    224:   $usersaw=~s/action\s*\=/would_be_action\=/gi;
                    225:   return $usersaw;
                    226: }
                    227: 
                    228: sub clear_out_html {
                    229:   my $message=$ENV{'form.comment'};
1.33      www       230:   $message=~s/\<\/*m\s*\>//g;
1.6       albertel  231:   $message=~s/\</\&lt\;/g;
                    232:   $message=~s/\>/\&gt\;/g;
                    233:   return $message;
                    234: }
                    235: 
                    236: sub assemble_email {
                    237:   my ($feedurl,$message,$prevattempts,$usersaw)=@_;
                    238:   my $email=<<"ENDEMAIL";
                    239: Refers to <a href="$feedurl">$feedurl</a>
                    240: 
                    241: $message
                    242: ENDEMAIL
                    243:     my $citations=<<"ENDCITE";
                    244: <h2>Previous attempts of student (if applicable)</h2>
                    245: $prevattempts
                    246: <p><hr>
                    247: <h2>Original screen output (if applicable)</h2>
                    248: $usersaw
                    249: ENDCITE
                    250:   return ($email,$citations);
                    251: }
                    252: 
1.35      www       253: sub secapply {
                    254:     my $rec=shift;
1.36    ! www       255:     my $defaultflag=shift;
        !           256:     $rec=~s/\s+//g;
        !           257:     $rec=~s/\@/\:/g;
        !           258:     my ($adr,$sections)=($rec=~/^([^\(]+)\(([^\)]+)\)/);
        !           259:     if ($sections) {
        !           260: 	foreach (split(/\;/,$sections)) {
        !           261:             if (($_ eq $ENV{'request.course.sec'}) ||
        !           262:                 ($defaultflag && ($_ eq '*'))) {
        !           263:                 return $adr; 
        !           264:             }
        !           265:         }
        !           266:     } else {
        !           267:        return $rec;
        !           268:     }
        !           269:     return '';
1.35      www       270: }
                    271: 
1.6       albertel  272: sub decide_receiver {
1.36    ! www       273:   my ($feedurl,$author,$question,$course,$policy,$defaultflag) = @_;
1.6       albertel  274:   my $typestyle='';
                    275:   my %to=();
1.36    ! www       276:   if ($ENV{'form.author'}||$author) {
1.8       www       277:     $typestyle.='Submitting as Author Feedback<br>';
1.6       albertel  278:     $feedurl=~/^\/res\/(\w+)\/(\w+)\//;
                    279:     $to{$2.':'.$1}=1;
                    280:   }
1.36    ! www       281:   if ($ENV{'form.question'}||$question) {
1.8       www       282:     $typestyle.='Submitting as Question<br>';
1.24      harris41  283:     foreach (split(/\,/,
                    284: 		   $ENV{'course.'.$ENV{'request.course.id'}.'.question.email'})
                    285: 	     ) {
1.36    ! www       286: 	my $rec=&secapply($_,$defaultflag);
        !           287:         if ($rec) { $to{$rec}=1; }
1.24      harris41  288:     } 
1.6       albertel  289:   }
1.36    ! www       290:   if ($ENV{'form.course'}||$course) {
1.8       www       291:     $typestyle.='Submitting as Comment<br>';
1.24      harris41  292:     foreach (split(/\,/,
                    293: 		   $ENV{'course.'.$ENV{'request.course.id'}.'.comment.email'})
                    294: 	     ) {
1.36    ! www       295: 	my $rec=&secapply($_,$defaultflag);
        !           296:         if ($rec) { $to{$rec}=1; }
1.24      harris41  297:     } 
1.6       albertel  298:   }
1.36    ! www       299:   if ($ENV{'form.policy'}||$policy) {
1.8       www       300:     $typestyle.='Submitting as Policy Feedback<br>';
1.24      harris41  301:     foreach (split(/\,/,
                    302: 		   $ENV{'course.'.$ENV{'request.course.id'}.'.policy.email'})
                    303: 	     ) {
1.36    ! www       304: 	my $rec=&secapply($_,$defaultflag);
        !           305:         if ($rec) { $to{$rec}=1; }
1.24      harris41  306:     } 
1.6       albertel  307:   }
1.36    ! www       308:   if ((scalar(%to) eq '0') && (!$defaultflag)) {
        !           309:      ($typestyle,%to)=
        !           310: 	 &decide_receiver($feedurl,$author,$question,$course,$policy,1);
        !           311:   }
1.6       albertel  312:   return ($typestyle,%to);
1.36    ! www       313: }
        !           314: 
        !           315: sub feedback_available {
        !           316:     my ($question,$course,$policy)=@_;
        !           317:     my ($typestyle,%to)=&decide_receiver('',0,$question,$course,$policy);
        !           318:     return scalar(%to);
1.6       albertel  319: }
                    320: 
                    321: sub send_msg {
                    322:   my ($feedurl,$email,$citations,%to)=@_;
                    323:   my $status='';
                    324:   my $sendsomething=0;
1.24      harris41  325:   foreach (keys %to) {
1.6       albertel  326:     if ($_) {
1.22      www       327:       my $declutter=&Apache::lonnet::declutter($feedurl);
1.8       www       328:       unless (&Apache::lonmsg::user_normal_msg(split(/\:/,$_),
1.34      www       329:                'Feedback ['.$declutter.']',$email,$citations)=~/ok/) {
1.6       albertel  330: 	$status.='<br>Error sending message to '.$_.'<br>';
                    331:       } else {
                    332: 	$sendsomething++;
                    333:       }
                    334:     }
1.24      harris41  335:   }
1.18      www       336: 
                    337:     my %record=&Apache::lonnet::restore('_feedback');
                    338:     my ($temp)=keys %record;
                    339:     unless ($temp=~/^error\:/) {
                    340:        my %newrecord=();
                    341:        $newrecord{'resource'}=$feedurl;
                    342:        $newrecord{'subnumber'}=$record{'subnumber'}+1;
                    343:        unless (&Apache::lonnet::cstore(\%newrecord,'_feedback') eq 'ok') {
                    344: 	   $status.='<br>Not registered<br>';
                    345:        }
                    346:     }
                    347:        
1.6       albertel  348:   return ($status,$sendsomething);
                    349: }
                    350: 
1.13      www       351: sub adddiscuss {
1.14      www       352:     my ($symb,$email,$anon)=@_;
1.13      www       353:     my $status='';
1.23      www       354:     if (&Apache::lonnet::allowed('pch',$ENV{'request.course.id'}.
                    355:         ($ENV{'request.course.sec'}?'/'.$ENV{'request.course.sec'}:''))) {
1.20      www       356: 
1.13      www       357:     my %contrib=('message'      => $email,
                    358:                  'sendername'   => $ENV{'user.name'},
1.26      www       359:                  'senderdomain' => $ENV{'user.domain'},
                    360:                  'screenname'   => $ENV{'environment.screenname'},
                    361:                  'plainname'    => $ENV{'environment.firstname'}.' '.
                    362: 		                   $ENV{'environment.middlename'}.' '.
                    363:                                    $ENV{'environment.lastname'}.' '.
                    364:                                    $ENV{'enrironment.generation'});
1.14      www       365:     if ($anon) {
                    366: 	$contrib{'anonymous'}='true';
                    367:     }
1.13      www       368:     if (($symb) && ($email)) {
1.14      www       369:        $status='Adding to class discussion'.($anon?' (anonymous)':'').': '.
1.13      www       370:         &Apache::lonnet::store(\%contrib,$symb,$ENV{'request.course.id'},
                    371:                      $ENV{'course.'.$ENV{'request.course.id'}.'.domain'},
1.17      www       372: 		     $ENV{'course.'.$ENV{'request.course.id'}.'.num'});
1.21      www       373:         my %storenewentry=($symb => time);
                    374:         $status.='<br>Updating discussion time: '.
                    375:         &Apache::lonnet::put('discussiontimes',\%storenewentry,
                    376:                      $ENV{'course.'.$ENV{'request.course.id'}.'.domain'},
                    377: 		     $ENV{'course.'.$ENV{'request.course.id'}.'.num'});
1.13      www       378:     }
1.17      www       379:     my %record=&Apache::lonnet::restore('_discussion');
                    380:     my ($temp)=keys %record;
                    381:     unless ($temp=~/^error\:/) {
                    382:        my %newrecord=();
                    383:        $newrecord{'resource'}=$symb;
                    384:        $newrecord{'subnumber'}=$record{'subnumber'}+1;
1.21      www       385:        $status.='<br>Registering: '.
                    386:                &Apache::lonnet::cstore(\%newrecord,'_discussion');
1.20      www       387:     }
                    388:     } else {
                    389: 	$status.='Failed.';
1.17      www       390:     }
                    391:     return $status.'<br>';   
1.13      www       392: }
                    393: 
1.33      www       394: # ----------------------------------------------------------- Preview function
                    395: 
                    396: sub show_preview {
                    397:     my $r=shift;
                    398:     my $message=&clear_out_html($ENV{'form.comment'});
                    399:     $message=~s/\n/\<br \/\>/g;
                    400:     $message=&Apache::lontexconvert::msgtexconverted($message);
                    401:     $r->print('<table border="2"><tr><td>'.
                    402:        $message.'</td></tr></table>');
                    403: }
                    404: 
                    405: sub generate_preview_button {
                    406:     return(<<ENDPREVIEW);
                    407: <form name="preview" action="/adm/feedback?preview=1" method="post" target="preview">
                    408: <input type="hidden" name="comment" />
                    409: <input type="button" value="Show Preview"
                    410: onClick="this.form.comment.value=document.mailform.comment.value;this.form.submit();" />
                    411: </form>
                    412: ENDPREVIEW
                    413: }
1.6       albertel  414: sub handler {
                    415:   my $r = shift;
1.8       www       416:   if ($r->header_only) {
                    417:      $r->content_type('text/html');
                    418:      $r->send_http_header;
                    419:      return OK;
                    420:   }
1.15      www       421: 
                    422: # --------------------------- Get query string for limited number of parameters
                    423: 
1.27      stredwic  424:    &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
1.33      www       425:                                        ['hide','unhide','postdata','preview']);
1.15      www       426: 
                    427:   if (($ENV{'form.hide'}) || ($ENV{'form.unhide'})) {
                    428: # ----------------------------------------------------------------- Hide/unhide
                    429:     $r->content_type('text/html');
                    430:     $r->send_http_header;
                    431: 
                    432:     my $entry=$ENV{'form.hide'}?$ENV{'form.hide'}:$ENV{'form.unhide'};
                    433: 
                    434:     my ($symb,$idx)=split(/\:\:\:/,$entry);
                    435:     my ($map,$ind,$url)=split(/\_\_\_/,$symb);
                    436: 
                    437:     my %contrib=&Apache::lonnet::restore($symb,$ENV{'request.course.id'},
                    438:                      $ENV{'course.'.$ENV{'request.course.id'}.'.domain'},
                    439: 		     $ENV{'course.'.$ENV{'request.course.id'}.'.num'});
                    440: 
                    441:         
                    442:     my $currenthidden=$contrib{'hidden'};
                    443:     
                    444:     if ($ENV{'form.hide'}) {
                    445: 	$currenthidden.='.'.$idx.'.';
                    446:     } else {
                    447:         $currenthidden=~s/\.$idx\.//g;
                    448:     }
                    449:     my %newhash=('hidden' => $currenthidden);
                    450: 
                    451:     &Apache::lonnet::store(\%newhash,$symb,$ENV{'request.course.id'},
                    452:                      $ENV{'course.'.$ENV{'request.course.id'}.'.domain'},
                    453: 		     $ENV{'course.'.$ENV{'request.course.id'}.'.num'});
                    454: 
1.30      www       455:     &redirect_back($r,&Apache::lonnet::clutter($url),
1.32      albertel  456:        'Changed discussion status<p>','0','0');
1.33      www       457:   } elsif ($ENV{'form.preview'}) {
                    458: # -------------------------------------------------------- User wants a preview
                    459:       &show_preview($r);
1.15      www       460:   } else {
                    461: # ------------------------------------------------------------- Normal feedback
1.6       albertel  462:   my $feedurl=$ENV{'form.postdata'};
                    463:   $feedurl=~s/^http\:\/\///;
                    464:   $feedurl=~s/^$ENV{'SERVER_NAME'}//;
                    465:   $feedurl=~s/^$ENV{'HTTP_HOST'}//;
1.8       www       466: 
                    467:   my $symb=&Apache::lonnet::symbread($feedurl);
1.31      www       468:   unless ($symb) {
                    469:       $symb=$ENV{'form.symb'};
                    470:       if ($symb) {
                    471: 	  my ($map,$id,$url)=split(/\_\_\_/,$symb);
                    472:           $feedurl=&Apache::lonnet::clutter($url);
                    473:       }
                    474:   }
1.8       www       475:   my $goahead=1;
                    476:   if ($feedurl=~/\.(problem|exam|quiz|assess|survey|form)$/) {
                    477:       unless ($symb) { $goahead=0; }
                    478:   }
                    479: 
                    480:   if ($goahead) {
                    481: # Go ahead with feedback, no ambiguous reference
                    482:     $r->content_type('text/html');
                    483:     $r->send_http_header;
1.6       albertel  484:   
1.8       www       485:     if (
1.7       albertel  486:       (
                    487:        ($feedurl=~m:^/res:) && ($feedurl!~m:^/res/adm:)
                    488:       ) 
                    489:       || 
                    490:       ($ENV{'request.course.id'} && ($feedurl!~m:^/adm:))
1.31      www       491:       ||
                    492:       ($ENV{'request.course.id'} && ($symb=~/^bulletin\_\_\_/))
1.7       albertel  493:      ) {
1.6       albertel  494: # --------------------------------------------------- Print login screen header
                    495:     unless ($ENV{'form.sendit'}) {
                    496:       my $options=&screen_header($feedurl);
                    497:       if ($options) {
                    498: 	&mail_screen($r,$feedurl,$options);
                    499:       } else {
                    500: 	&fail_redirect($r,$feedurl);
                    501:       }
                    502:     } else {
                    503:       
                    504: # Get previous user input
1.9       albertel  505:       my $prevattempts=&Apache::loncommon::get_previous_attempt(
1.11      albertel  506:             $symb,$ENV{'user.name'},$ENV{'user.domain'},
1.9       albertel  507:             $ENV{'request.course.id'});
1.6       albertel  508: 
                    509: # Get output from resource
                    510:       my $usersaw=&resource_output($feedurl);
                    511: 
                    512: # Filter HTML out of message (could be nasty)
                    513:       my $message=&clear_out_html;
                    514: 
                    515: # Assemble email
1.8       www       516:       my ($email,$citations)=&assemble_email($feedurl,$message,$prevattempts,
                    517:           $usersaw);
1.6       albertel  518: 
                    519: # Who gets this?
                    520:       my ($typestyle,%to) = &decide_receiver($feedurl);
                    521: 
                    522: # Actually send mail
                    523:       my ($status,$numsent)=&send_msg($feedurl,$email,$citations,%to);
1.13      www       524: 
                    525: # Discussion? Store that.
                    526: 
1.32      albertel  527:       my $numpost=0;
1.13      www       528:       if ($ENV{'form.discuss'}) {
                    529: 	  $typestyle.=&adddiscuss($symb,$message);
1.32      albertel  530: 	  $numpost++;
1.13      www       531:       }
1.6       albertel  532: 
1.14      www       533:       if ($ENV{'form.anondiscuss'}) {
                    534: 	  $typestyle.=&adddiscuss($symb,$message,1);
1.32      albertel  535: 	  $numpost++;
1.14      www       536:       }
                    537: 
                    538: 
1.6       albertel  539: # Receipt screen and redirect back to where came from
1.32      albertel  540:       &redirect_back($r,$feedurl,$typestyle,$numsent,$numpost,$status);
1.6       albertel  541: 
                    542:     }
1.8       www       543:    } else {
1.7       albertel  544: # Unable to give feedback
1.6       albertel  545:     &no_redirect_back($r,$feedurl);
1.8       www       546:    }
                    547:   } else {
                    548: # Ambiguous Problem Resource
                    549:     $r->internal_redirect('/adm/ambiguous');
1.6       albertel  550:   }
1.15      www       551: }
1.6       albertel  552:   return OK;
1.1       www       553: } 
                    554: 
                    555: 1;
                    556: __END__

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