Annotation of loncom/interface/lonfeedback.pm, revision 1.44
1.1 www 1: # The LearningOnline Network
2: # Feedback
3: #
1.44 ! www 4: # $Id: lonfeedback.pm,v 1.43 2003/03/30 21:58:17 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.44 ! www 57: my $bodytag=&Apache::loncommon::bodytag('Resource Feedback and Discussion');
1.6 albertel 58: $r->print(<<ENDDOCUMENT);
1.1 www 59: <html>
60: <head>
61: <title>The LearningOnline Network with CAPA</title>
1.7 albertel 62: <meta http-equiv="pragma" content="no-cache"></meta>
1.5 www 63: <script>
64: function gosubmit() {
65: var rec=0;
1.12 albertel 66: if (typeof(document.mailform.elements.author)!="undefined") {
1.5 www 67: if (document.mailform.elements.author.checked) {
68: rec=1;
69: }
70: }
1.12 albertel 71: if (typeof(document.mailform.elements.question)!="undefined") {
1.5 www 72: if (document.mailform.elements.question.checked) {
73: rec=1;
74: }
75: }
1.12 albertel 76: if (typeof(document.mailform.elements.course)!="undefined") {
1.5 www 77: if (document.mailform.elements.course.checked) {
78: rec=1;
79: }
80: }
1.12 albertel 81: if (typeof(document.mailform.elements.policy)!="undefined") {
1.5 www 82: if (document.mailform.elements.policy.checked) {
83: rec=1;
84: }
85: }
1.12 albertel 86: if (typeof(document.mailform.elements.discuss)!="undefined") {
1.10 www 87: if (document.mailform.elements.discuss.checked) {
88: rec=1;
89: }
90: }
1.14 www 91: if (typeof(document.mailform.elements.anondiscuss)!="undefined") {
92: if (document.mailform.elements.anondiscuss.checked) {
93: rec=1;
94: }
95: }
1.5 www 96:
97: if (rec) {
98: document.mailform.submit();
99: } else {
100: alert('Please check a feedback type.');
101: }
102: }
103: </script>
1.1 www 104: </head>
1.29 www 105: $bodytag
1.2 www 106: <h2><tt>$feedurl</tt></h2>
1.43 www 107: <form action="/adm/feedback" method="post" name="mailform"
108: enctype="multipart/form-data">
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.42 www 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>
1.2 www 121: </form>
1.1 www 122: ENDDOCUMENT
1.33 www 123: $r->print(&generate_preview_button().'</body></html>');
1.6 albertel 124: }
125:
126: sub fail_redirect {
127: my ($r,$feedurl) = @_;
128: $r->print (<<ENDFAILREDIR);
1.5 www 129: <head><title>Feedback not sent</title>
1.7 albertel 130: <meta http-equiv="pragma" content="no-cache"></meta>
1.5 www 131: <meta HTTP-EQUIV="Refresh" CONTENT="2; url=$feedurl">
132: </head>
133: <html>
134: <body bgcolor="#FFFFFF">
1.8 www 135: <img align=right src=/adm/lonIcons/lonlogos.gif>
136: <b>Sorry, no recipients ...</b>
1.5 www 137: </body>
138: </html>
139: ENDFAILREDIR
140: }
1.4 www 141:
1.6 albertel 142: sub redirect_back {
1.32 albertel 143: my ($r,$feedurl,$typestyle,$sendsomething,$sendposts,$status) = @_;
1.6 albertel 144: $r->print (<<ENDREDIR);
1.3 www 145: <head>
146: <title>Feedback sent</title>
1.7 albertel 147: <meta http-equiv="pragma" content="no-cache"></meta>
1.5 www 148: <meta HTTP-EQUIV="Refresh" CONTENT="2; url=$feedurl">
1.2 www 149: </head>
150: <html>
151: <body bgcolor="#FFFFFF">
1.8 www 152: <img align=right src=/adm/lonIcons/lonlogos.gif>
1.5 www 153: $typestyle
1.32 albertel 154: <b>Sent $sendsomething message(s), and $sendposts post(s).</b>
1.3 www 155: <font color=red>$status</font>
1.2 www 156: </body>
157: </html>
158: ENDREDIR
159: }
1.6 albertel 160:
161: sub no_redirect_back {
162: my ($r,$feedurl) = @_;
163: $r->print (<<ENDNOREDIR);
1.2 www 164: <head><title>Feedback not sent</title>
1.7 albertel 165: <meta http-equiv="pragma" content="no-cache"></meta>
166: ENDNOREDIR
167:
1.8 www 168: if ($feedurl!~/^\/adm\/feedback/) {
1.7 albertel 169: $r->print('<meta HTTP-EQUIV="Refresh" CONTENT="2; url='.$feedurl.'">');
170: }
171:
1.8 www 172: $r->print (<<ENDNOREDIRTWO);
1.2 www 173: </head>
174: <html>
175: <body bgcolor="#FFFFFF">
1.8 www 176: <img align=right src=/adm/lonIcons/lonlogos.gif>
177: <b>Sorry, no feedback possible on this resource ...</b>
1.2 www 178: </body>
179: </html>
1.8 www 180: ENDNOREDIRTWO
1.2 www 181: }
1.6 albertel 182:
183: sub screen_header {
184: my ($feedurl) = @_;
185: my $options='';
1.35 www 186: if (($feedurl=~/^\/res\//) && ($feedurl!~/^\/res\/adm/)) {
1.6 albertel 187: $options=
188: '<p><input type=checkbox name=author> Feedback to resource author';
189: }
1.36 www 190: if (&feedback_available(1)) {
1.6 albertel 191: $options.=
1.8 www 192: '<br><input type=checkbox name=question> Question about resource content';
1.6 albertel 193: }
1.36 www 194: if (&feedback_available(0,1)) {
1.6 albertel 195: $options.=
196: '<br><input type=checkbox name=course> '.
197: 'Question/Comment/Feedback about course content';
198: }
1.36 www 199: if (&feedback_available(0,0,1)) {
1.6 albertel 200: $options.=
201: '<br><input type=checkbox name=policy> '.
202: 'Question/Comment/Feedback about course policy';
1.10 www 203: }
1.20 www 204:
1.10 www 205: if ($ENV{'request.course.id'}) {
1.23 www 206: if (&Apache::lonnet::allowed('pch',
207: $ENV{'request.course.id'}.
208: ($ENV{'request.course.sec'}?'/'.$ENV{'request.course.sec'}:''))) {
1.10 www 209: $options.='<br><input type=checkbox name=discuss> '.
210: '<b>Contribution to course discussion of resource</b>';
1.14 www 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)';
1.20 www 214: }
1.14 www 215: }
1.6 albertel 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 {
1.39 www 233: my ($message,$override)=@_;
1.37 albertel 234: my $cid=$ENV{'request.course.id'};
1.39 www 235: if (($ENV{"course.$cid.allow_limited_html_in_feedback"} =~ m/yes/i) ||
236: ($override)) {
1.37 albertel 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":"\<$1"}/ge;
244: $message =~ s/(\<?\s*(\w+)[^\<\>]*)\>/
245: {($html{uc($2)}&(length($1)<1000))?"$1\>":"$1\>"}/ge;
246: } else {
247: $message=~s/\<\/*m\s*\>//g;
248: $message=~s/\</\<\;/g;
249: $message=~s/\>/\>\;/g;
250: }
1.6 albertel 251: return $message;
252: }
253:
254: sub assemble_email {
1.40 albertel 255: my ($feedurl,$message,$prevattempts,$usersaw,$useranswer)=@_;
1.6 albertel 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
1.40 albertel 267: <h2>Correct Answer(s) (if applicable)</h2>
268: $useranswer
1.6 albertel 269: ENDCITE
270: return ($email,$citations);
271: }
272:
1.35 www 273: sub secapply {
274: my $rec=shift;
1.36 www 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 '';
1.35 www 290: }
291:
1.6 albertel 292: sub decide_receiver {
1.36 www 293: my ($feedurl,$author,$question,$course,$policy,$defaultflag) = @_;
1.6 albertel 294: my $typestyle='';
295: my %to=();
1.36 www 296: if ($ENV{'form.author'}||$author) {
1.8 www 297: $typestyle.='Submitting as Author Feedback<br>';
1.6 albertel 298: $feedurl=~/^\/res\/(\w+)\/(\w+)\//;
299: $to{$2.':'.$1}=1;
300: }
1.36 www 301: if ($ENV{'form.question'}||$question) {
1.8 www 302: $typestyle.='Submitting as Question<br>';
1.24 harris41 303: foreach (split(/\,/,
304: $ENV{'course.'.$ENV{'request.course.id'}.'.question.email'})
305: ) {
1.36 www 306: my $rec=&secapply($_,$defaultflag);
307: if ($rec) { $to{$rec}=1; }
1.24 harris41 308: }
1.6 albertel 309: }
1.36 www 310: if ($ENV{'form.course'}||$course) {
1.8 www 311: $typestyle.='Submitting as Comment<br>';
1.24 harris41 312: foreach (split(/\,/,
313: $ENV{'course.'.$ENV{'request.course.id'}.'.comment.email'})
314: ) {
1.36 www 315: my $rec=&secapply($_,$defaultflag);
316: if ($rec) { $to{$rec}=1; }
1.24 harris41 317: }
1.6 albertel 318: }
1.36 www 319: if ($ENV{'form.policy'}||$policy) {
1.8 www 320: $typestyle.='Submitting as Policy Feedback<br>';
1.24 harris41 321: foreach (split(/\,/,
322: $ENV{'course.'.$ENV{'request.course.id'}.'.policy.email'})
323: ) {
1.36 www 324: my $rec=&secapply($_,$defaultflag);
325: if ($rec) { $to{$rec}=1; }
1.24 harris41 326: }
1.6 albertel 327: }
1.36 www 328: if ((scalar(%to) eq '0') && (!$defaultflag)) {
329: ($typestyle,%to)=
330: &decide_receiver($feedurl,$author,$question,$course,$policy,1);
331: }
1.6 albertel 332: return ($typestyle,%to);
1.36 www 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);
1.6 albertel 339: }
340:
341: sub send_msg {
1.43 www 342: my ($feedurl,$email,$citations,$attachmenturl,%to)=@_;
1.6 albertel 343: my $status='';
344: my $sendsomething=0;
1.24 harris41 345: foreach (keys %to) {
1.6 albertel 346: if ($_) {
1.22 www 347: my $declutter=&Apache::lonnet::declutter($feedurl);
1.8 www 348: unless (&Apache::lonmsg::user_normal_msg(split(/\:/,$_),
1.43 www 349: 'Feedback ['.$declutter.']',$email,$citations,$feedurl,
350: $attachmenturl)=~/ok/) {
1.6 albertel 351: $status.='<br>Error sending message to '.$_.'<br>';
352: } else {
353: $sendsomething++;
354: }
355: }
1.24 harris41 356: }
1.18 www 357:
358: my %record=&Apache::lonnet::restore('_feedback');
359: my ($temp)=keys %record;
360: unless ($temp=~/^error\:/) {
361: my %newrecord=();
362: $newrecord{'resource'}=$feedurl;
363: $newrecord{'subnumber'}=$record{'subnumber'}+1;
364: unless (&Apache::lonnet::cstore(\%newrecord,'_feedback') eq 'ok') {
365: $status.='<br>Not registered<br>';
366: }
367: }
368:
1.6 albertel 369: return ($status,$sendsomething);
370: }
371:
1.13 www 372: sub adddiscuss {
1.42 www 373: my ($symb,$email,$anon,$attachmenturl)=@_;
1.13 www 374: my $status='';
1.23 www 375: if (&Apache::lonnet::allowed('pch',$ENV{'request.course.id'}.
376: ($ENV{'request.course.sec'}?'/'.$ENV{'request.course.sec'}:''))) {
1.20 www 377:
1.13 www 378: my %contrib=('message' => $email,
379: 'sendername' => $ENV{'user.name'},
1.26 www 380: 'senderdomain' => $ENV{'user.domain'},
381: 'screenname' => $ENV{'environment.screenname'},
382: 'plainname' => $ENV{'environment.firstname'}.' '.
383: $ENV{'environment.middlename'}.' '.
384: $ENV{'environment.lastname'}.' '.
1.42 www 385: $ENV{'enrironment.generation'},
1.43 www 386: 'attachmenturl'=> $attachmenturl);
1.14 www 387: if ($anon) {
388: $contrib{'anonymous'}='true';
389: }
1.13 www 390: if (($symb) && ($email)) {
1.14 www 391: $status='Adding to class discussion'.($anon?' (anonymous)':'').': '.
1.13 www 392: &Apache::lonnet::store(\%contrib,$symb,$ENV{'request.course.id'},
393: $ENV{'course.'.$ENV{'request.course.id'}.'.domain'},
1.17 www 394: $ENV{'course.'.$ENV{'request.course.id'}.'.num'});
1.21 www 395: my %storenewentry=($symb => time);
396: $status.='<br>Updating discussion time: '.
397: &Apache::lonnet::put('discussiontimes',\%storenewentry,
398: $ENV{'course.'.$ENV{'request.course.id'}.'.domain'},
399: $ENV{'course.'.$ENV{'request.course.id'}.'.num'});
1.13 www 400: }
1.17 www 401: my %record=&Apache::lonnet::restore('_discussion');
402: my ($temp)=keys %record;
403: unless ($temp=~/^error\:/) {
404: my %newrecord=();
405: $newrecord{'resource'}=$symb;
406: $newrecord{'subnumber'}=$record{'subnumber'}+1;
1.21 www 407: $status.='<br>Registering: '.
408: &Apache::lonnet::cstore(\%newrecord,'_discussion');
1.20 www 409: }
410: } else {
411: $status.='Failed.';
1.17 www 412: }
413: return $status.'<br>';
1.13 www 414: }
415:
1.33 www 416: # ----------------------------------------------------------- Preview function
417:
418: sub show_preview {
419: my $r=shift;
420: my $message=&clear_out_html($ENV{'form.comment'});
421: $message=~s/\n/\<br \/\>/g;
422: $message=&Apache::lontexconvert::msgtexconverted($message);
423: $r->print('<table border="2"><tr><td>'.
424: $message.'</td></tr></table>');
425: }
426:
427: sub generate_preview_button {
428: return(<<ENDPREVIEW);
429: <form name="preview" action="/adm/feedback?preview=1" method="post" target="preview">
430: <input type="hidden" name="comment" />
431: <input type="button" value="Show Preview"
432: onClick="this.form.comment.value=document.mailform.comment.value;this.form.submit();" />
433: </form>
434: ENDPREVIEW
435: }
1.6 albertel 436: sub handler {
437: my $r = shift;
1.8 www 438: if ($r->header_only) {
439: $r->content_type('text/html');
440: $r->send_http_header;
441: return OK;
442: }
1.15 www 443:
444: # --------------------------- Get query string for limited number of parameters
445:
1.27 stredwic 446: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
1.38 www 447: ['hide','unhide','deldisc','postdata','preview']);
1.15 www 448:
449: if (($ENV{'form.hide'}) || ($ENV{'form.unhide'})) {
450: # ----------------------------------------------------------------- Hide/unhide
451: $r->content_type('text/html');
452: $r->send_http_header;
453:
454: my $entry=$ENV{'form.hide'}?$ENV{'form.hide'}:$ENV{'form.unhide'};
455:
456: my ($symb,$idx)=split(/\:\:\:/,$entry);
457: my ($map,$ind,$url)=split(/\_\_\_/,$symb);
458:
459: my %contrib=&Apache::lonnet::restore($symb,$ENV{'request.course.id'},
460: $ENV{'course.'.$ENV{'request.course.id'}.'.domain'},
461: $ENV{'course.'.$ENV{'request.course.id'}.'.num'});
462:
463:
464: my $currenthidden=$contrib{'hidden'};
465:
466: if ($ENV{'form.hide'}) {
467: $currenthidden.='.'.$idx.'.';
468: } else {
469: $currenthidden=~s/\.$idx\.//g;
470: }
471: my %newhash=('hidden' => $currenthidden);
1.38 www 472:
473: &Apache::lonnet::store(\%newhash,$symb,$ENV{'request.course.id'},
474: $ENV{'course.'.$ENV{'request.course.id'}.'.domain'},
475: $ENV{'course.'.$ENV{'request.course.id'}.'.num'});
476:
477: &redirect_back($r,&Apache::lonnet::clutter($url),
478: 'Changed discussion status<p>','0','0');
479: } elsif ($ENV{'form.deldisc'}) {
480: # --------------------------------------------------------------- Hide for good
481: $r->content_type('text/html');
482: $r->send_http_header;
483:
484: my $entry=$ENV{'form.deldisc'};
485:
486: my ($symb,$idx)=split(/\:\:\:/,$entry);
487: my ($map,$ind,$url)=split(/\_\_\_/,$symb);
488:
489: my %contrib=&Apache::lonnet::restore($symb,$ENV{'request.course.id'},
490: $ENV{'course.'.$ENV{'request.course.id'}.'.domain'},
491: $ENV{'course.'.$ENV{'request.course.id'}.'.num'});
492:
493:
494: my $currentdeleted=$contrib{'deleted'};
495:
496: $currentdeleted.='.'.$idx.'.';
497:
498: my %newhash=('deleted' => $currentdeleted);
1.15 www 499:
500: &Apache::lonnet::store(\%newhash,$symb,$ENV{'request.course.id'},
501: $ENV{'course.'.$ENV{'request.course.id'}.'.domain'},
502: $ENV{'course.'.$ENV{'request.course.id'}.'.num'});
503:
1.30 www 504: &redirect_back($r,&Apache::lonnet::clutter($url),
1.32 albertel 505: 'Changed discussion status<p>','0','0');
1.33 www 506: } elsif ($ENV{'form.preview'}) {
507: # -------------------------------------------------------- User wants a preview
508: &show_preview($r);
1.15 www 509: } else {
510: # ------------------------------------------------------------- Normal feedback
1.6 albertel 511: my $feedurl=$ENV{'form.postdata'};
512: $feedurl=~s/^http\:\/\///;
513: $feedurl=~s/^$ENV{'SERVER_NAME'}//;
514: $feedurl=~s/^$ENV{'HTTP_HOST'}//;
1.8 www 515:
516: my $symb=&Apache::lonnet::symbread($feedurl);
1.31 www 517: unless ($symb) {
518: $symb=$ENV{'form.symb'};
519: if ($symb) {
520: my ($map,$id,$url)=split(/\_\_\_/,$symb);
521: $feedurl=&Apache::lonnet::clutter($url);
522: }
523: }
1.8 www 524: my $goahead=1;
525: if ($feedurl=~/\.(problem|exam|quiz|assess|survey|form)$/) {
526: unless ($symb) { $goahead=0; }
527: }
528:
529: if ($goahead) {
530: # Go ahead with feedback, no ambiguous reference
531: $r->content_type('text/html');
532: $r->send_http_header;
1.6 albertel 533:
1.8 www 534: if (
1.7 albertel 535: (
536: ($feedurl=~m:^/res:) && ($feedurl!~m:^/res/adm:)
537: )
538: ||
539: ($ENV{'request.course.id'} && ($feedurl!~m:^/adm:))
1.31 www 540: ||
541: ($ENV{'request.course.id'} && ($symb=~/^bulletin\_\_\_/))
1.7 albertel 542: ) {
1.6 albertel 543: # --------------------------------------------------- Print login screen header
544: unless ($ENV{'form.sendit'}) {
545: my $options=&screen_header($feedurl);
546: if ($options) {
547: &mail_screen($r,$feedurl,$options);
548: } else {
549: &fail_redirect($r,$feedurl);
550: }
551: } else {
552:
553: # Get previous user input
1.9 albertel 554: my $prevattempts=&Apache::loncommon::get_previous_attempt(
1.11 albertel 555: $symb,$ENV{'user.name'},$ENV{'user.domain'},
1.9 albertel 556: $ENV{'request.course.id'});
1.6 albertel 557:
558: # Get output from resource
559: my $usersaw=&resource_output($feedurl);
560:
1.40 albertel 561: # Get resource answer
562: my $useranswer=&Apache::loncommon::get_student_answers(
563: $symb,$ENV{'user.name'},$ENV{'user.domain'},
564: $ENV{'request.course.id'});
1.42 www 565: # Get attachments, if any, and not too large
566: my $attachmenturl='';
567: if ($ENV{'form.attachment.filename'}) {
568: unless (length($ENV{'form.attachment'})>131072) {
1.43 www 569: $attachmenturl=&Apache::lonnet::userfileupload('attachment');
1.42 www 570: }
571: }
1.6 albertel 572: # Filter HTML out of message (could be nasty)
1.39 www 573: my $message=&clear_out_html($ENV{'form.comment'});
1.6 albertel 574:
575: # Assemble email
1.8 www 576: my ($email,$citations)=&assemble_email($feedurl,$message,$prevattempts,
1.40 albertel 577: $usersaw,$useranswer);
578:
1.6 albertel 579: # Who gets this?
580: my ($typestyle,%to) = &decide_receiver($feedurl);
581:
582: # Actually send mail
1.43 www 583: my ($status,$numsent)=&send_msg($feedurl,$email,$citations,
584: $attachmenturl,%to);
1.13 www 585:
586: # Discussion? Store that.
587:
1.32 albertel 588: my $numpost=0;
1.13 www 589: if ($ENV{'form.discuss'}) {
1.42 www 590: $typestyle.=&adddiscuss($symb,$message,0,$attachmenturl);
1.32 albertel 591: $numpost++;
1.13 www 592: }
1.6 albertel 593:
1.14 www 594: if ($ENV{'form.anondiscuss'}) {
1.42 www 595: $typestyle.=&adddiscuss($symb,$message,1,$attachmenturl);
1.32 albertel 596: $numpost++;
1.14 www 597: }
598:
599:
1.6 albertel 600: # Receipt screen and redirect back to where came from
1.32 albertel 601: &redirect_back($r,$feedurl,$typestyle,$numsent,$numpost,$status);
1.6 albertel 602:
603: }
1.8 www 604: } else {
1.7 albertel 605: # Unable to give feedback
1.6 albertel 606: &no_redirect_back($r,$feedurl);
1.8 www 607: }
608: } else {
609: # Ambiguous Problem Resource
610: $r->internal_redirect('/adm/ambiguous');
1.6 albertel 611: }
1.15 www 612: }
1.6 albertel 613: return OK;
1.1 www 614: }
615:
616: 1;
617: __END__
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>