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