1: # The LearningOnline Network
2: # Feedback
3: #
4: # $Id: lonfeedback.pm,v 1.87 2004/06/02 16:47:33 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: ###
29:
30: package Apache::lonfeedback;
31:
32: use strict;
33: use Apache::Constants qw(:common);
34: use Apache::lonmsg();
35: use Apache::loncommon();
36: use Apache::lontexconvert();
37: use Apache::lonlocal; # must not have ()
38: use Apache::lonhtmlcommon();
39:
40: sub list_discussion {
41: my ($mode,$status,$symb)=@_;
42: # &Apache::lonnet::logthis("status is $status");
43: if (!($status eq 'CAN_ANSWER' || $status eq 'CANNOT_ANSWER'
44: || $status eq 'OPEN')) {
45: return '';
46: }
47:
48: my @bgcols = ("#cccccc","#eeeeee");
49: my $discussiononly=0;
50: if ($mode eq 'board') { $discussiononly=1; }
51: unless ($ENV{'request.course.id'}) { return ''; }
52: my $crs='/'.$ENV{'request.course.id'};
53: if ($ENV{'request.course.sec'}) {
54: $crs.='_'.$ENV{'request.course.sec'};
55: }
56: $crs=~s/\_/\//g;
57: unless ($symb) {
58: $symb=&Apache::lonnet::symbread();
59: }
60: unless ($symb) { return ''; }
61:
62: # backward compatibility (bulletin boards used to be 'wrapped')
63: my $ressymb=$symb;
64: if ($mode eq 'board') {
65: unless ($ressymb =~ m|bulletin___\d+___adm/wrapper|) {
66: $ressymb=~s|(bulletin___\d+___)|$1adm/wrapper|;
67: }
68: }
69:
70: # Get discussion display settings for this discussion
71: my $lastkey = $ressymb.'_lastread';
72: my $showkey = $ressymb.'_showonlyunread';
73: my $visitkey = $ressymb.'_visit';
74: my $ondispkey = $ressymb.'_markondisp';
75: my %dischash = &Apache::lonnet::get('nohist_'.$ENV{'request.course.id'}.'_discuss',[$lastkey,$showkey,$visitkey,$ondispkey],$ENV{'user.domain'},$ENV{'user.name'});
76: my %discinfo = ();
77: my $showonlyunread = 0;
78: my $markondisp = 0;
79: my $prevread = 0;
80: my $previous = 0;
81: my $visit = 0;
82: my $newpostsflag = 0;
83:
84: # Retain identification of "NEW" posts identified in last display, if continuing 'previous' browsing of posts.
85: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['previous']);
86: $previous = $ENV{'form.previous'};
87: if ($previous > 0) {
88: $prevread = $previous;
89: } elsif (defined($dischash{$lastkey})) {
90: unless ($dischash{$lastkey} eq '') {
91: $prevread = $dischash{$lastkey};
92: }
93: }
94:
95: # Get discussion display default settings for user
96: my %userenv = &Apache::lonnet::get('environment',['discdisplay','discmarkread'],$ENV{'user.domain'},$ENV{'user.name'});
97: my $discdisplay=$userenv{'discdisplay'};
98: if ($discdisplay eq 'unread') {
99: $showonlyunread = 1;
100: }
101: my $discmarkread=$userenv{'discmarkread'};
102: if ($discmarkread eq 'ondisp') {
103: $markondisp = 1;
104: }
105:
106: # Override user's default if user specified display setting for this discussion
107: if (defined($dischash{$ondispkey})) {
108: $markondisp = $dischash{$ondispkey};
109: }
110: if ($markondisp) {
111: $discinfo{$lastkey} = time;
112: }
113:
114: if (defined($dischash{$showkey})) {
115: $showonlyunread = $dischash{$showkey};
116: }
117:
118: if (defined($dischash{$visitkey})) {
119: $visit = $dischash{$visitkey};
120: }
121: $visit ++;
122:
123: my $seeid=&Apache::lonnet::allowed('rin',$crs);
124: my $viewgrades=(&Apache::lonnet::allowed('vgr',$crs)
125: && ($symb=~/\.(problem|exam|quiz|assess|survey|form)$/));
126: my @discussionitems=();
127: my %contrib=&Apache::lonnet::restore($ressymb,$ENV{'request.course.id'},
128: $ENV{'course.'.$ENV{'request.course.id'}.'.domain'},
129: $ENV{'course.'.$ENV{'request.course.id'}.'.num'});
130: my $visible=0;
131: my @depth=();
132: my @original=();
133: my @index=();
134: my @replies=();
135: my %alldiscussion=();
136: my %notshown = ();
137: my %newitem = ();
138: my $maxdepth=0;
139:
140: my $target='';
141: unless ($ENV{'browser.interface'} eq 'textual' ||
142: $ENV{'environment.remote'} eq 'off' ) {
143: $target='target="LONcom"';
144: }
145:
146: my $now = time;
147: $discinfo{$visitkey} = $visit;
148:
149: &Apache::lonnet::put('nohist_'.$ENV{'request.course.id'}.'_discuss',\%discinfo,$ENV{'user.domain'},$ENV{'user.name'});
150:
151: if ($contrib{'version'}) {
152: my $oldest = $contrib{'1:timestamp'};
153: if ($prevread eq '0') {
154: $prevread = $oldest-1;
155: }
156: for (my $id=1;$id<=$contrib{'version'};$id++) {
157: my $idx=$id;
158: my $posttime = $contrib{$idx.':timestamp'};
159: if ($prevread <= $posttime) {
160: $newpostsflag = 1;
161: }
162: my $hidden=($contrib{'hidden'}=~/\.$idx\./);
163: my $deleted=($contrib{'deleted'}=~/\.$idx\./);
164: my $origindex='0.';
165: if (($contrib{$idx.':replyto'}) && ($ENV{'environment.threadeddiscussion'})) {
166: # this is a follow-up message
167: $original[$idx]=$original[$contrib{$idx.':replyto'}];
168: $depth[$idx]=$depth[$contrib{$idx.':replyto'}]+1;
169: $origindex=$index[$contrib{$idx.':replyto'}];
170: if ($depth[$idx]>$maxdepth) { $maxdepth=$depth[$idx]; }
171: } else {
172: # this is an original message
173: $original[$idx]=0;
174: $depth[$idx]=0;
175: }
176: if ($replies[$depth[$idx]]) {
177: $replies[$depth[$idx]]++;
178: } else {
179: $replies[$depth[$idx]]=1;
180: }
181: unless ((($hidden) && (!$seeid)) || ($deleted)) {
182: $visible++;
183: my $message=$contrib{$idx.':message'};
184: $message=~s/\n/\<br \/\>/g;
185: $message=&Apache::lontexconvert::msgtexconverted($message);
186: my $subject=$contrib{$idx.':subject'};
187: if (defined($subject)) {
188: $subject=~s/\n/\<br \/\>/g;
189: $subject=&Apache::lontexconvert::msgtexconverted($subject);
190: }
191: if ($contrib{$idx.':attachmenturl'}) {
192: my ($fname)
193: =($contrib{$idx.':attachmenturl'}=~m|/([^/]+)$|);
194: &Apache::lonnet::allowuploaded('/adm/feedback',
195: $contrib{$idx.':attachmenturl'});
196: $message.='<p>'.&mt('Attachment').
197: ': <a href="'.$contrib{$idx.':attachmenturl'}.'"><tt>'.
198: $fname.'</tt></a></p>';
199: }
200: if ($message) {
201: if ($hidden) {
202: $message='<font color="#888888">'.$message.'</font>';
203: }
204: my $screenname=&Apache::loncommon::screenname(
205: $contrib{$idx.':sendername'},
206: $contrib{$idx.':senderdomain'});
207: my $plainname=&Apache::loncommon::nickname(
208: $contrib{$idx.':sendername'},
209: $contrib{$idx.':senderdomain'});
210:
211: my $sender=&mt('Anonymous');
212: if ((!$contrib{$idx.':anonymous'}) || ($seeid)) {
213: $sender=&Apache::loncommon::aboutmewrapper(
214: $plainname,
215: $contrib{$idx.':sendername'},
216: $contrib{$idx.':senderdomain'}).' ('.
217: $contrib{$idx.':sendername'}.' at '.
218: $contrib{$idx.':senderdomain'}.')';
219: if ($contrib{$idx.':anonymous'}) {
220: $sender.=' ['.&mt('anonymous').'] '.
221: $screenname;
222: }
223: if ($seeid) {
224: if ($hidden) {
225: $sender.=' <a href="/adm/feedback?unhide='.
226: $ressymb.':::'.$idx;
227: if ($newpostsflag) {
228: $sender .= '&previous='.$prevread;
229: }
230: $sender .= '">'.&mt('Make Visible').'</a>';
231: } else {
232: $sender.=' <a href="/adm/feedback?hide='.
233: $ressymb.':::'.$idx;
234: if ($newpostsflag) {
235: $sender .= '&previous='.$prevread;
236: }
237: $sender .= '">'.&mt('Hide').'</a>';
238: }
239: $sender.=' <a href="/adm/feedback?deldisc='.
240: $ressymb.':::'.$idx;
241: if ($newpostsflag) {
242: $sender .= '&previous='.$prevread;
243: }
244: $sender .= '">'.&mt('Delete').'</a>';
245: }
246: } else {
247: if ($screenname) {
248: $sender='<i>'.$screenname.'</i>';
249: }
250: }
251: if (&Apache::lonnet::allowed('pch',
252: $ENV{'request.course.id'}.
253: ($ENV{'request.course.sec'}?'/'.$ENV{'request.course.sec'}:''))) {
254: $sender.=' <a href="/adm/feedback?replydisc='.
255: $ressymb.':::'.$idx;
256: if ($newpostsflag) {
257: $sender .= '&previous='.$prevread;
258: }
259: $sender .= '" '.$target.'>'.&mt('Reply').'</a>';
260: }
261: my $vgrlink;
262: if ($viewgrades) {
263: $vgrlink=&Apache::loncommon::submlink('Submissions',
264: $contrib{$idx.':sendername'},$contrib{$idx.':senderdomain'},$symb);
265: }
266: #figure out at what position this needs to print
267: my $thisindex=$idx;
268: if ($ENV{'environment.threadeddiscussion'}) {
269: $thisindex=$origindex.substr('00'.$replies[$depth[$idx]],-2,2);
270: }
271: $alldiscussion{$thisindex}=$idx;
272: $index[$idx]=$thisindex;
273: my $spansize = 2;
274: if ($showonlyunread && $prevread > $posttime) {
275: $notshown{$idx} = 1;
276: } else {
277: if ($prevread > 0 && $prevread <= $posttime) {
278: $newitem{$idx} = 1;
279: $discussionitems[$idx] .= '
280: <p><table border="0" width="100%">
281: <tr><td align="left"><font color="#FF0000"><b>NEW</b></font></td>';
282: } else {
283: $newitem{$idx} = 0;
284: $discussionitems[$idx] .= '
285: <p><table border="0" width="100%">
286: <tr><td align="left"> </td>';
287: }
288: $discussionitems[$idx] .= '<td align ="left"> '.
289: '<b>'.$subject.'</b> '.
290: $sender.'</b> '.$vgrlink.' ('.
291: localtime($posttime).')</td></tr>'.
292: '</table><blockquote>'.$message.'</blockquote></p>';
293: }
294: }
295: }
296: }
297: }
298:
299: my $discussion='';
300:
301: my $function = &Apache::loncommon::get_users_function();
302: my $color = &Apache::loncommon::designparm($function.'.tabbg',
303: $ENV{'user.domain'});
304: my %lt = &Apache::lonlocal::texthash(
305: 'cuse' => 'Current settings for this discussion',
306: 'allposts' => 'All posts',
307: 'unread' => 'New posts only',
308: 'ondisp' => 'Once displayed',
309: 'onmark' => 'Once marked read',
310: 'disa' => 'Posts to be displayed',
311: 'npce' => 'Posts cease to be marked "NEW"',
312: 'chgt' => 'Change to ',
313: );
314:
315: my $currdisp = $lt{'allposts'};
316: my $currmark = $lt{'onmark'};
317: my $dispchange = $lt{'unread'};
318: my $markchange = $lt{'ondisp'};
319: my $displink = '/adm/feedback?onlyunread='.$ressymb;
320: my $marklink = '/adm/feedback?markondisp='.$ressymb;
321:
322: if ($markondisp) {
323: $currmark = $lt{'ondisp'};
324: $markchange = $lt{'onmark'};
325: $marklink = '/adm/feedback?markonread='.$ressymb;
326: if ($newpostsflag) {
327: $marklink .= '&previous='.$prevread;
328: }
329: }
330:
331: if ($showonlyunread) {
332: $currdisp = $lt{'unread'};
333: $dispchange = $lt{'allposts'};
334: $displink = '/adm/feedback?allposts='.$ressymb;
335: }
336:
337: if ($newpostsflag) {
338: $displink .= '&previous='.$prevread;
339: }
340:
341: if ($visible) {
342: # Print the discusssion
343: $discussion.='<table bgcolor="#AAAAAA" cellpadding="2" cellspacing="2" border="0">';
344: my $colspan=$maxdepth+1;
345: $discussion .= '<tr bgcolor="#FFFFFF"><td colspan="'.$colspan.'" valign="top">'.
346: '<table border="0" bgcolor="#FFFFFF" width="100%" cellspacing="2" cellpadding="2">'.
347: '<tr><td align="left"><b>'.$lt{'cuse'}.'</b></td><td> </td><td align="right"><b>'.$lt{'chgt'}.'</b></td></tr>'.
348: '<tr><td>'.$lt{'disa'}.': <i>'.$currdisp.'</i></td><td> </td><td align="right"><a href="'.$displink.'">'.$dispchange.'</a></td></tr>'.
349: '<tr><td>'.$lt{'npce'}.': <i>'.$currmark.'</i></td><td> </td><td align="right"><a href="'.$marklink.'">'.$markchange.'</a></td></tr>'.
350: '</table></td></tr>'.
351: '<tr><td bgcolor="#DDDDBB" colspan="'.$colspan.'">'.
352: '<table border="0" width="100%" bgcolor="#DDDDBB"><tr>';
353: if ($visible>2) {
354: $discussion.='<td align="left">'.
355: '<a href="/adm/feedback?threadedon='.$ressymb;
356: if ($newpostsflag) {
357: $discussion .= '&previous='.$prevread;
358: }
359: $discussion .='">'.&mt('Threaded View').'</a> '.
360: '<a href="/adm/feedback?threadedoff='.$ressymb;
361: if ($newpostsflag) {
362: $discussion .= '&previous='.$prevread;
363: }
364: $discussion .='">'.&mt('Chronological View').'</a> </td>';
365: }
366: if ($newpostsflag) {
367: if (!$markondisp) {
368: $discussion .='<td align="right"><a href="/adm/feedback?markread='.$ressymb.'">'.&mt('Mark new posts as read').'</a> ';
369: } else {
370: $discussion .= '<td> </td>';
371: }
372: } else {
373: $discussion .= '<td> </td>';
374: }
375: $discussion .= '</tr></table></td></tr>';
376:
377: my $numhidden = keys %notshown;
378: if ($numhidden > 0) {
379: my $colspan = $maxdepth+1;
380: $discussion.="\n".'<tr><td bgcolor="#CCCCCC" colspan="'.$colspan.'">'.
381: '<a href="/adm/feedback?allposts='.$ressymb;
382: if ($newpostsflag) {
383: $discussion .= '&previous='.$prevread;
384: }
385: $discussion .= '">'.&mt('Show all posts').'</a> '.&mt('to display').' '.
386: $numhidden.' '.&mt('previously viewed posts').
387: '<br/></td></tr>';
388: }
389: foreach (sort { $a <=> $b } keys %alldiscussion) {
390: unless ($notshown{$alldiscussion{$_}} eq '1') {
391: $discussion.="\n<tr>";
392: my $thisdepth=$depth[$alldiscussion{$_}];
393: for (1..$thisdepth) {
394: $discussion.='<td> </td>';
395: }
396: my $colspan=$maxdepth-$thisdepth+1;
397: $discussion.='<td bgcolor="'.$bgcols[$newitem{$alldiscussion{$_}}].'" colspan="'.$colspan.'">'.
398: $discussionitems[$alldiscussion{$_}].
399: '</td></tr>';
400: }
401: }
402: $discussion.='</table><br /><br />';
403: }
404: if ($discussiononly) {
405: $discussion.=(<<ENDDISCUSS);
406: <form action="/adm/feedback" method="post" name="mailform" enctype="multipart/form-data">
407: <input type="submit" name="discuss" value="Post Discussion" />
408: <input type="submit" name="anondiscuss" value="Post Anonymous Discussion" />
409: <input type="hidden" name="symb" value="$ressymb" />
410: <input type="hidden" name="sendit" value="true" />
411: <br />
412: <font size="1">Note: in anonymous discussion, your name is visible only to
413: course faculty</font><br />
414: <b>Title:</b> <input type="text" name="subject" value="" size="30" /><br /><br />
415: <textarea name="comment" cols="60" rows="10" wrap="hard"></textarea>
416: <p>
417: Attachment (128 KB max size): <input type="file" name="attachment" />
418: </p>
419: </form>
420: ENDDISCUSS
421: $discussion.=&generate_preview_button();
422: } else {
423: if (&Apache::lonnet::allowed('pch',
424: $ENV{'request.course.id'}.
425: ($ENV{'request.course.sec'}?'/'.$ENV{'request.course.sec'}:''))) {
426: $discussion.='<table bgcolor="#BBBBBB"><tr><td><a href="/adm/feedback?replydisc='.
427: $symb.':::" '.$target.'>'.
428: '<img src="/adm/lonMisc/chat.gif" border="0" />'.
429: &mt('Post Discussion').'</a></td></tr></table>';
430: }
431: }
432: return $discussion;
433: }
434:
435: sub mail_screen {
436: my ($r,$feedurl,$options) = @_;
437: my $bodytag=&Apache::loncommon::bodytag('Resource Feedback and Discussion',
438: '','onLoad="window.focus();"');
439: my $title=&Apache::lonnet::gettitle($feedurl);
440: if (!$title) { $title = $feedurl; }
441: my $quote='';
442: my $subject = '';
443: my $prevtag = '';
444: if ($ENV{'form.replydisc'}) {
445: my ($symb,$idx)=split(/\:\:\:/,$ENV{'form.replydisc'});
446: my %contrib=&Apache::lonnet::restore($symb,$ENV{'request.course.id'},
447: $ENV{'course.'.$ENV{'request.course.id'}.'.domain'},
448: $ENV{'course.'.$ENV{'request.course.id'}.'.num'});
449: unless (($contrib{'hidden'}=~/\.$idx\./) || ($contrib{'deleted'}=~/\.$idx\./)) {
450: my $message=$contrib{$idx.':message'};
451: $message=~s/\n/\<br \/\>/g;
452: $quote='<blockquote>'.&Apache::lontexconvert::msgtexconverted($message).'</blockquote>';
453: if ($idx > 0) {
454: $subject = 'Re: '.$contrib{$idx.':subject'};
455: }
456: }
457: if ($ENV{'form.previous'}) {
458: $prevtag = '<input type="hidden" name="previous" value="'.$ENV{'form.previous'}.'" />';
459: }
460: }
461: my $latexHelp=&Apache::loncommon::helpLatexCheatsheet();
462: my $htmlheader=&Apache::lonhtmlcommon::htmlareaheaders();
463: my $send=&mt('Send');
464: $r->print(<<ENDDOCUMENT);
465: <html>
466: <head>
467: <title>The LearningOnline Network with CAPA</title>
468: <meta http-equiv="pragma" content="no-cache"></meta>
469: $htmlheader
470: <script type="text/javascript">
471: //<!--
472: function gosubmit() {
473: var rec=0;
474: if (typeof(document.mailform.elements.author)!="undefined") {
475: if (document.mailform.elements.author.checked) {
476: rec=1;
477: }
478: }
479: if (typeof(document.mailform.elements.question)!="undefined") {
480: if (document.mailform.elements.question.checked) {
481: rec=1;
482: }
483: }
484: if (typeof(document.mailform.elements.course)!="undefined") {
485: if (document.mailform.elements.course.checked) {
486: rec=1;
487: }
488: }
489: if (typeof(document.mailform.elements.policy)!="undefined") {
490: if (document.mailform.elements.policy.checked) {
491: rec=1;
492: }
493: }
494: if (typeof(document.mailform.elements.discuss)!="undefined") {
495: if (document.mailform.elements.discuss.checked) {
496: rec=1;
497: }
498: }
499: if (typeof(document.mailform.elements.anondiscuss)!="undefined") {
500: if (document.mailform.elements.anondiscuss.checked) {
501: rec=1;
502: }
503: }
504:
505: if (rec) {
506: document.mailform.onsubmit();
507: document.mailform.submit();
508: } else {
509: alert('Please check a feedback type.');
510: }
511: }
512: //-->
513: </script>
514: </head>
515: $bodytag
516: <h2><tt>$title</tt></h2>
517: <form action="/adm/feedback" method="post" name="mailform"
518: enctype="multipart/form-data">
519: $prevtag
520: <input type="hidden" name="postdata" value="$feedurl" />
521: <input type="hidden" name="replydisc" value="$ENV{'form.replydisc'}" />
522: Please check at least one of the following feedback types:
523: $options<hr />
524: $quote
525: <p>My question/comment/feedback:</p>
526: <p>
527: $latexHelp
528: Title: <input type="text" name="subject" size="30" value="$subject" /></p>
529: <p>
530: <textarea name="comment" cols="60" rows="10" wrap="hard">
531: </textarea></p>
532: <p>
533: Attachment (128 KB max size): <input type="file" name="attachment" />
534: </p>
535: <p>
536: <input type="hidden" name="sendit" value="1" />
537: <input type="button" value="$send" onClick='gosubmit();' />
538: </p>
539: </form>
540: ENDDOCUMENT
541: $r->print(&generate_preview_button().
542: &Apache::lonhtmlcommon::htmlareaactive().
543: '</body></html>');
544: }
545:
546: sub fail_redirect {
547: my ($r,$feedurl) = @_;
548: if ($feedurl=~/^\/adm\//) { $feedurl.='?register=1' };
549: $r->print (<<ENDFAILREDIR);
550: <html>
551: <head><title>Feedback not sent</title>
552: <meta http-equiv="pragma" content="no-cache" />
553: <meta HTTP-EQUIV="Refresh" CONTENT="2; url=$feedurl" />
554: </head>
555: <body bgcolor="#FFFFFF">
556: <img align="right" src="/adm/lonIcons/lonlogos.gif" />
557: <b>Sorry, no recipients ...</b>
558: </body>
559: </html>
560: ENDFAILREDIR
561: }
562:
563: sub redirect_back {
564: my ($r,$feedurl,$typestyle,$sendsomething,$sendposts,$status,$previous) = @_;
565: my $prevtag = '';
566: my $qrystr = '';
567: if ($feedurl=~/^\/adm\//) { $feedurl.='?register=1' };
568: if ($previous > 0) {
569: $qrystr = 'previous='.$previous;
570: if ($feedurl =~ /\?register=1/) {
571: $feedurl .= '&'.$qrystr;
572: } else {
573: $feedurl .= '?'.$qrystr;
574: }
575: $prevtag = '<input type="hidden" name="previous" value="'.$previous.'" />';
576: }
577: $r->print (<<ENDREDIR);
578: <html>
579: <head>
580: <title>Feedback sent</title>
581: <meta http-equiv="pragma" content="no-cache" />
582: <meta HTTP-EQUIV="Refresh" CONTENT="2; url=$feedurl" />
583: </head>
584: <body bgcolor="#FFFFFF" onLoad='if (window.name!="loncapaclient") { this.document.reldt.submit(); self.close(); }'>
585: <img align="right" src="/adm/lonIcons/lonlogos.gif" />
586: $typestyle
587: <b>Sent $sendsomething message(s), and $sendposts post(s).</b>
588: <font color="red">$status</font>
589: <form name="reldt" action="$feedurl" target="loncapaclient">
590: $prevtag
591: </form>
592: </body>
593: </html>
594: ENDREDIR
595: }
596:
597: sub no_redirect_back {
598: my ($r,$feedurl) = @_;
599: $r->print (<<ENDNOREDIR);
600: <html>
601: <head><title>Feedback not sent</title>
602: <meta http-equiv="pragma" content="no-cache" />
603: ENDNOREDIR
604:
605: if ($feedurl!~/^\/adm\/feedback/) {
606: $r->print('<meta HTTP-EQUIV="Refresh" CONTENT="2; url='.$feedurl.'">');
607: }
608:
609: $r->print (<<ENDNOREDIRTWO);
610: </head>
611: <body bgcolor="#FFFFFF" onLoad='if (window.name!="loncapaclient") { self.close(); }'>
612: <img align="right" src="/adm/lonIcons/lonlogos.gif" />
613: <b>Sorry, no feedback possible on this resource ...</b>
614: </body>
615: </html>
616: ENDNOREDIRTWO
617: }
618:
619: sub screen_header {
620: my ($feedurl) = @_;
621: my $msgoptions='';
622: my $discussoptions='';
623: unless ($ENV{'form.replydisc'}) {
624: if (($feedurl=~/^\/res\//) && ($feedurl!~/^\/res\/adm/)) {
625: $msgoptions=
626: '<p><input type="checkbox" name="author" /> '.
627: &mt('Feedback to resource author').'</p>';
628: }
629: if (&feedback_available(1)) {
630: $msgoptions.=
631: '<br /><input type="checkbox" name="question" /> '.
632: &mt('Question about resource content');
633: }
634: if (&feedback_available(0,1)) {
635: $msgoptions.=
636: '<br /><input type="checkbox" name="course" /> '.
637: &mt('Question/Comment/Feedback about course content');
638: }
639: if (&feedback_available(0,0,1)) {
640: $msgoptions.=
641: '<br /><input type="checkbox" name="policy" /> '.
642: &mt('Question/Comment/Feedback about course policy');
643: }
644: }
645: if ($ENV{'request.course.id'}) {
646: if (&Apache::lonnet::allowed('pch',
647: $ENV{'request.course.id'}.
648: ($ENV{'request.course.sec'}?'/'.$ENV{'request.course.sec'}:''))) {
649: $discussoptions='<input type="checkbox" name="discuss" onClick="this.form.anondiscuss.checked=false;" '.
650: ($ENV{'form.replydisc'}?' checked="1"':'').' /> '.
651: &mt('Contribution to course discussion of resource');
652: $discussoptions.='<br /><input type="checkbox" name="anondiscuss" onClick="this.form.discuss.checked=false;" /> '.
653: &mt('Anonymous contribution to course discussion of resource').
654: ' <i>('.&mt('name only visible to course faculty').')</i>';
655: }
656: }
657: if ($msgoptions) { $msgoptions='<h2><img src="/adm/lonMisc/feedback.gif" />'.&mt('Sending Messages').'</h2>'.$msgoptions; }
658: if ($discussoptions) {
659: $discussoptions='<h2><img src="/adm/lonMisc/chat.gif" />'.&mt('Discussion Contributions').'</h2>'.$discussoptions; }
660: return $msgoptions.$discussoptions;
661: }
662:
663: sub resource_output {
664: my ($feedurl) = @_;
665: my $usersaw=&Apache::lonnet::ssi_body($feedurl);
666: $usersaw=~s/\<body[^\>]*\>//gi;
667: $usersaw=~s/\<\/body\>//gi;
668: $usersaw=~s/\<html\>//gi;
669: $usersaw=~s/\<\/html\>//gi;
670: $usersaw=~s/\<head\>//gi;
671: $usersaw=~s/\<\/head\>//gi;
672: $usersaw=~s/action\s*\=/would_be_action\=/gi;
673: return $usersaw;
674: }
675:
676: sub clear_out_html {
677: my ($message,$override)=@_;
678: my $cid=$ENV{'request.course.id'};
679: if (($ENV{"course.$cid.allow_limited_html_in_feedback"} =~ m/yes/i) ||
680: ($override)) {
681: # allows <B> <I> <P> <A> <LI> <OL> <UL> <EM> <BR> <TT> <STRONG>
682: # <BLOCKQUOTE> <DIV .*> <DIV> <IMG>
683: my %html=(B=>1, I=>1, P=>1, A=>1, LI=>1, OL=>1, UL=>1, EM=>1,
684: BR=>1, TT=>1, STRONG=>1, BLOCKQUOTE=>1, DIV=>1, IMG=>1,
685: M=>1);
686:
687: $message =~ s/\<(\/?\s*(\w+)[^\>\<]*)/
688: {($html{uc($2)}&&(length($1)<1000))?"\<$1":"\<$1"}/ge;
689: $message =~ s/(\<?\s*(\w+)[^\<\>]*)\>/
690: {($html{uc($2)}&&(length($1)<1000))?"$1\>":"$1\>"}/ge;
691: } else {
692: $message=~s/\</\<\;/g;
693: $message=~s/\>/\>\;/g;
694: }
695: return $message;
696: }
697:
698: sub assemble_email {
699: my ($feedurl,$message,$prevattempts,$usersaw,$useranswer)=@_;
700: my $email=<<"ENDEMAIL";
701: Refers to <a href="$feedurl">$feedurl</a>
702:
703: $message
704: ENDEMAIL
705: my $citations=<<"ENDCITE";
706: <h2>Previous attempts of student (if applicable)</h2>
707: $prevattempts
708: <br /><hr />
709: <h2>Original screen output (if applicable)</h2>
710: $usersaw
711: <h2>Correct Answer(s) (if applicable)</h2>
712: $useranswer
713: ENDCITE
714: return ($email,$citations);
715: }
716:
717: sub secapply {
718: my $rec=shift;
719: my $defaultflag=shift;
720: $rec=~s/\s+//g;
721: $rec=~s/\@/\:/g;
722: my ($adr,$sections)=($rec=~/^([^\(]+)\(([^\)]+)\)/);
723: if ($sections) {
724: foreach (split(/\;/,$sections)) {
725: if (($_ eq $ENV{'request.course.sec'}) ||
726: ($defaultflag && ($_ eq '*'))) {
727: return $adr;
728: }
729: }
730: } else {
731: return $rec;
732: }
733: return '';
734: }
735:
736: sub decide_receiver {
737: my ($feedurl,$author,$question,$course,$policy,$defaultflag) = @_;
738: my $typestyle='';
739: my %to=();
740: if ($ENV{'form.author'}||$author) {
741: $typestyle.='Submitting as Author Feedback<br>';
742: $feedurl=~/^\/res\/(\w+)\/(\w+)\//;
743: $to{$2.':'.$1}=1;
744: }
745: if ($ENV{'form.question'}||$question) {
746: $typestyle.='Submitting as Question<br>';
747: foreach (split(/\,/,
748: $ENV{'course.'.$ENV{'request.course.id'}.'.question.email'})
749: ) {
750: my $rec=&secapply($_,$defaultflag);
751: if ($rec) { $to{$rec}=1; }
752: }
753: }
754: if ($ENV{'form.course'}||$course) {
755: $typestyle.='Submitting as Comment<br />';
756: foreach (split(/\,/,
757: $ENV{'course.'.$ENV{'request.course.id'}.'.comment.email'})
758: ) {
759: my $rec=&secapply($_,$defaultflag);
760: if ($rec) { $to{$rec}=1; }
761: }
762: }
763: if ($ENV{'form.policy'}||$policy) {
764: $typestyle.='Submitting as Policy Feedback<br />';
765: foreach (split(/\,/,
766: $ENV{'course.'.$ENV{'request.course.id'}.'.policy.email'})
767: ) {
768: my $rec=&secapply($_,$defaultflag);
769: if ($rec) { $to{$rec}=1; }
770: }
771: }
772: if ((scalar(%to) eq '0') && (!$defaultflag)) {
773: ($typestyle,%to)=
774: &decide_receiver($feedurl,$author,$question,$course,$policy,1);
775: }
776: return ($typestyle,%to);
777: }
778:
779: sub feedback_available {
780: my ($question,$course,$policy)=@_;
781: my ($typestyle,%to)=&decide_receiver('',0,$question,$course,$policy);
782: return scalar(%to);
783: }
784:
785: sub send_msg {
786: my ($feedurl,$email,$citations,$attachmenturl,%to)=@_;
787: my $status='';
788: my $sendsomething=0;
789: foreach (keys %to) {
790: if ($_) {
791: my $declutter=&Apache::lonnet::declutter($feedurl);
792: unless (&Apache::lonmsg::user_normal_msg(split(/\:/,$_),
793: 'Feedback ['.$declutter.']',$email,$citations,$feedurl,
794: $attachmenturl)=~/ok/) {
795: $status.='<br />'.&mt('Error sending message to').' '.$_.'<br />';
796: } else {
797: $sendsomething++;
798: }
799: }
800: }
801:
802: my %record=&Apache::lonnet::restore('_feedback');
803: my ($temp)=keys %record;
804: unless ($temp=~/^error\:/) {
805: my %newrecord=();
806: $newrecord{'resource'}=$feedurl;
807: $newrecord{'subnumber'}=$record{'subnumber'}+1;
808: unless (&Apache::lonnet::cstore(\%newrecord,'_feedback') eq 'ok') {
809: $status.='<br />'.&mt('Not registered').'<br />';
810: }
811: }
812:
813: return ($status,$sendsomething);
814: }
815:
816: sub adddiscuss {
817: my ($symb,$email,$anon,$attachmenturl,$subject)=@_;
818: my $status='';
819: if (&Apache::lonnet::allowed('pch',$ENV{'request.course.id'}.
820: ($ENV{'request.course.sec'}?'/'.$ENV{'request.course.sec'}:''))) {
821:
822: my %contrib=('message' => $email,
823: 'sendername' => $ENV{'user.name'},
824: 'senderdomain' => $ENV{'user.domain'},
825: 'screenname' => $ENV{'environment.screenname'},
826: 'plainname' => $ENV{'environment.firstname'}.' '.
827: $ENV{'environment.middlename'}.' '.
828: $ENV{'environment.lastname'}.' '.
829: $ENV{'enrironment.generation'},
830: 'attachmenturl'=> $attachmenturl,
831: 'subject' => $subject);
832: if ($ENV{'form.replydisc'}) {
833: $contrib{'replyto'}=(split(/\:\:\:/,$ENV{'form.replydisc'}))[1];
834: }
835: if ($anon) {
836: $contrib{'anonymous'}='true';
837: }
838: if (($symb) && ($email)) {
839: $status='Adding to class discussion'.($anon?' (anonymous)':'').': '.
840: &Apache::lonnet::store(\%contrib,$symb,$ENV{'request.course.id'},
841: $ENV{'course.'.$ENV{'request.course.id'}.'.domain'},
842: $ENV{'course.'.$ENV{'request.course.id'}.'.num'});
843: my %storenewentry=($symb => time);
844: $status.='<br />'.&mt('Updating discussion time').': '.
845: &Apache::lonnet::put('discussiontimes',\%storenewentry,
846: $ENV{'course.'.$ENV{'request.course.id'}.'.domain'},
847: $ENV{'course.'.$ENV{'request.course.id'}.'.num'});
848: }
849: my %record=&Apache::lonnet::restore('_discussion');
850: my ($temp)=keys %record;
851: unless ($temp=~/^error\:/) {
852: my %newrecord=();
853: $newrecord{'resource'}=$symb;
854: $newrecord{'subnumber'}=$record{'subnumber'}+1;
855: $status.='<br />'.&mt('Registering').': '.
856: &Apache::lonnet::cstore(\%newrecord,'_discussion');
857: }
858: } else {
859: $status.='Failed.';
860: }
861: return $status.'<br />';
862: }
863:
864: # ----------------------------------------------------------- Preview function
865:
866: sub show_preview {
867: my $r=shift;
868: my $message=&clear_out_html($ENV{'form.comment'});
869: $message=~s/\n/\<br \/\>/g;
870: $message=&Apache::lontexconvert::msgtexconverted($message);
871: my $subject=&clear_out_html($ENV{'form.subject'});
872: $subject=~s/\n/\<br \/\>/g;
873: $subject=&Apache::lontexconvert::msgtexconverted($subject);
874: $r->print('<table border="2"><tr><td>'.
875: '<b>Subject:</b> '.$subject.'<br /><br />'.
876: $message.'</td></tr></table>');
877: }
878:
879: sub generate_preview_button {
880: my $pre=&mt("Show Preview");
881: return(<<ENDPREVIEW);
882: <form name="preview" action="/adm/feedback?preview=1" method="post" target="preview">
883: <input type="hidden" name="subject">
884: <input type="hidden" name="comment" />
885: <input type="button" value="$pre"
886: onClick="document.mailform.onsubmit();this.form.comment.value=document.mailform.comment.value;this.form.subject.value=document.mailform.subject.value;this.form.submit();" />
887: </form>
888: ENDPREVIEW
889: }
890:
891: sub handler {
892: my $r = shift;
893: if ($r->header_only) {
894: &Apache::loncommon::content_type($r,'text/html');
895: $r->send_http_header;
896: return OK;
897: }
898:
899: # --------------------------- Get query string for limited number of parameters
900:
901: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
902: ['hide','unhide','deldisc','postdata','preview','replydisc','threadedon','threadedoff','onlyunread','allposts','previous','markread','markonread','markondisp']);
903:
904: if (($ENV{'form.markondisp'}) || ($ENV{'form.markonread'})) {
905: # ---------------------- Modify setting for identification of 'NEW' posts in this discussion
906:
907: &Apache::loncommon::content_type($r,'text/html');
908: $r->send_http_header;
909: my $symb=$ENV{'form.markondisp'}?$ENV{'form.markondisp'}:$ENV{'form.markonread'};
910: my $ressymb = $symb;
911: my ($map,$ind,$url)=&Apache::lonnet::decode_symb($symb);
912: unless ($ressymb =~ m|bulletin___\d+___adm/wrapper|) {
913: $ressymb=~s|(bulletin___\d+___)|$1adm/wrapper|;
914: }
915:
916: my %discinfo = ();
917: my $lastkey = $ressymb.'_lastread';
918: my $ondispkey = $ressymb.'_markondisp';
919: if ($ENV{'form.markondisp'}) {
920: $discinfo{$lastkey} = time;
921: $discinfo{$ondispkey} = 1;
922: } elsif ($ENV{'form.markonread'}) {
923: if ( defined($ENV{'previous'}) ) {
924: $discinfo{$lastkey} = $ENV{'previous'};
925: }
926: $discinfo{$ondispkey} = 0;
927: }
928: &Apache::lonnet::put('nohist_'.$ENV{'request.course.id'}.'_discuss',\%discinfo,$ENV{'user.domain'},$ENV{'user.name'});
929: if ($ENV{'form.markondisp'}) {
930: &redirect_back($r,&Apache::lonnet::clutter($url),&mt('Changed display status').'<br />','0','0');
931: } else {
932: &redirect_back($r,&Apache::lonnet::clutter($url),&mt('Changed display status').'<br />','0','0','',$ENV{'form.previous'});
933: }
934: return OK;
935: } elsif (($ENV{'form.allposts'}) || ($ENV{'form.onlyunread'})) {
936: # ----------------------------------------------------------------- Modify display setting for this discussion
937: &Apache::loncommon::content_type($r,'text/html');
938: $r->send_http_header;
939: my $symb=$ENV{'form.allposts'}?$ENV{'form.allposts'}:$ENV{'form.onlyunread'};
940: my $ressymb = $symb;
941: my ($map,$ind,$url)=&Apache::lonnet::decode_symb($symb);
942: unless ($ressymb =~ m|bulletin___\d+___adm/wrapper|) {
943: $ressymb=~s|(bulletin___\d+___)|$1adm/wrapper|;
944: }
945: my %discinfo = ();
946: if ($ENV{'form.allposts'}) {
947: $discinfo{$ressymb.'_showonlyunread'} = 0;
948: } elsif ($ENV{'form.onlyunread'}) {
949: $discinfo{$ressymb.'_showonlyunread'} = 1;
950: }
951: &Apache::lonnet::put('nohist_'.$ENV{'request.course.id'}.'_discuss',\%discinfo,$ENV{'user.domain'},$ENV{'user.name'});
952: &redirect_back($r,&Apache::lonnet::clutter($url),&mt('Changed display status').'<br />','0','0','',$ENV{'form.previous'});
953: return OK;
954: } elsif ($ENV{'form.markread'}) {
955: # ----------------------------------------------------------------- Mark new posts as read
956: &Apache::loncommon::content_type($r,'text/html');
957: $r->send_http_header;
958: my $symb=$ENV{'form.markread'};
959: my $ressymb = $symb;
960: my ($map,$ind,$url)=&Apache::lonnet::decode_symb($symb);
961: unless ($ressymb =~ m|bulletin___\d+___adm/wrapper|) {
962: $ressymb=~s|(bulletin___\d+___)|$1adm/wrapper|;
963: }
964: my %discinfo = ();
965: my $lastkey = $ressymb.'_lastread';
966: $discinfo{$lastkey} = time;
967: &Apache::lonnet::put('nohist_'.$ENV{'request.course.id'}.'_discuss',\%discinfo,$ENV{'user.domain'},$ENV{'user.name'});
968: &redirect_back($r,&Apache::lonnet::clutter($url),&mt('Changed reading status').'<br />','0','0');
969: return OK;
970: } elsif (($ENV{'form.hide'}) || ($ENV{'form.unhide'})) {
971: # ----------------------------------------------------------------- Hide/unhide
972: &Apache::loncommon::content_type($r,'text/html');
973: $r->send_http_header;
974:
975: my $entry=$ENV{'form.hide'}?$ENV{'form.hide'}:$ENV{'form.unhide'};
976:
977: my ($symb,$idx)=split(/\:\:\:/,$entry);
978: my ($map,$ind,$url)=&Apache::lonnet::decode_symb($symb);
979:
980: my %contrib=&Apache::lonnet::restore($symb,$ENV{'request.course.id'},
981: $ENV{'course.'.$ENV{'request.course.id'}.'.domain'},
982: $ENV{'course.'.$ENV{'request.course.id'}.'.num'});
983:
984:
985: my $currenthidden=$contrib{'hidden'};
986:
987: if ($ENV{'form.hide'}) {
988: $currenthidden.='.'.$idx.'.';
989: } else {
990: $currenthidden=~s/\.$idx\.//g;
991: }
992: my %newhash=('hidden' => $currenthidden);
993:
994: &Apache::lonnet::store(\%newhash,$symb,$ENV{'request.course.id'},
995: $ENV{'course.'.$ENV{'request.course.id'}.'.domain'},
996: $ENV{'course.'.$ENV{'request.course.id'}.'.num'});
997:
998: &redirect_back($r,&Apache::lonnet::clutter($url),
999: &mt('Changed discussion status').'<br />','0','0','',$ENV{'form.previous'});
1000: } elsif (($ENV{'form.threadedon'}) || ($ENV{'form.threadedoff'})) {
1001: &Apache::loncommon::content_type($r,'text/html');
1002: $r->send_http_header;
1003: if ($ENV{'form.threadedon'}) {
1004: &Apache::lonnet::put('environment',{'threadeddiscussion' => 'on'});
1005: &Apache::lonnet::appenv('environment.threadeddiscussion' => 'on');
1006: } else {
1007: &Apache::lonnet::del('environment',['threadeddiscussion']);
1008: &Apache::lonnet::delenv('environment\.threadeddiscussion');
1009: }
1010: my $symb=$ENV{'form.threadedon'}?$ENV{'form.threadedon'}:$ENV{'form.threadedoff'};
1011: my ($map,$ind,$url)=&Apache::lonnet::decode_symb($symb);
1012: &redirect_back($r,&Apache::lonnet::clutter($url),
1013: &mt('Changed discussion view mode').'<br />','0','0','',$ENV{'form.previous'});
1014: } elsif ($ENV{'form.deldisc'}) {
1015: # --------------------------------------------------------------- Hide for good
1016: &Apache::loncommon::content_type($r,'text/html');
1017: $r->send_http_header;
1018:
1019: my $entry=$ENV{'form.deldisc'};
1020:
1021: my ($symb,$idx)=split(/\:\:\:/,$entry);
1022: my ($map,$ind,$url)=&Apache::lonnet::decode_symb($symb);
1023:
1024: my %contrib=&Apache::lonnet::restore($symb,$ENV{'request.course.id'},
1025: $ENV{'course.'.$ENV{'request.course.id'}.'.domain'},
1026: $ENV{'course.'.$ENV{'request.course.id'}.'.num'});
1027:
1028:
1029: my $currentdeleted=$contrib{'deleted'};
1030:
1031: $currentdeleted.='.'.$idx.'.';
1032:
1033: my %newhash=('deleted' => $currentdeleted);
1034:
1035: &Apache::lonnet::store(\%newhash,$symb,$ENV{'request.course.id'},
1036: $ENV{'course.'.$ENV{'request.course.id'}.'.domain'},
1037: $ENV{'course.'.$ENV{'request.course.id'}.'.num'});
1038:
1039: &redirect_back($r,&Apache::lonnet::clutter($url),
1040: &mt('Changed discussion status').'<br />','0','0','',$ENV{'form.previous'});
1041: } elsif ($ENV{'form.preview'}) {
1042: # -------------------------------------------------------- User wants a preview
1043: $r->content_type('text/html');
1044: $r->send_http_header;
1045: &show_preview($r);
1046: } else {
1047: # ------------------------------------------------------------- Normal feedback
1048: my $feedurl=$ENV{'form.postdata'};
1049: $feedurl=~s/^http\:\/\///;
1050: $feedurl=~s/^$ENV{'SERVER_NAME'}//;
1051: $feedurl=~s/^$ENV{'HTTP_HOST'}//;
1052: $feedurl=~s/\?.+$//;
1053:
1054: my $symb;
1055: if ($ENV{'form.replydisc'}) {
1056: $symb=(split(/\:\:\:/,$ENV{'form.replydisc'}))[0];
1057: my ($map,$id,$url)=&Apache::lonnet::decode_symb($symb);
1058: $feedurl=&Apache::lonnet::clutter($url);
1059: } else {
1060: $symb=&Apache::lonnet::symbread($feedurl);
1061: }
1062: unless ($symb) {
1063: $symb=$ENV{'form.symb'};
1064: if ($symb) {
1065: my ($map,$id,$url)=&Apache::lonnet::decode_symb($symb);
1066: $feedurl=&Apache::lonnet::clutter($url);
1067: }
1068: }
1069: my $goahead=1;
1070: if ($feedurl=~/\.(problem|exam|quiz|assess|survey|form)$/) {
1071: unless ($symb) { $goahead=0; }
1072: }
1073: # backward compatibility (bulltin boards used to be 'wrapped')
1074: if ($feedurl=~m|^/adm/wrapper/adm/.*/bulletinboard$|) {
1075: $feedurl=~s|^/adm/wrapper||;
1076: }
1077: if ($goahead) {
1078: # Go ahead with feedback, no ambiguous reference
1079: &Apache::loncommon::content_type($r,'text/html');
1080: $r->send_http_header;
1081:
1082: if (
1083: (
1084: ($feedurl=~m:^/res:) && ($feedurl!~m:^/res/adm:)
1085: )
1086: ||
1087: ($ENV{'request.course.id'} && ($feedurl!~m:^/adm:))
1088: ||
1089: ($ENV{'request.course.id'} && ($symb=~/^bulletin\_\_\_/))
1090: ) {
1091: # --------------------------------------------------- Print login screen header
1092: unless ($ENV{'form.sendit'}) {
1093: my $options=&screen_header($feedurl);
1094: if ($options) {
1095: &mail_screen($r,$feedurl,$options);
1096: } else {
1097: &fail_redirect($r,$feedurl);
1098: }
1099: } else {
1100:
1101: # Get previous user input
1102: my $prevattempts=&Apache::loncommon::get_previous_attempt(
1103: $symb,$ENV{'user.name'},$ENV{'user.domain'},
1104: $ENV{'request.course.id'});
1105:
1106: # Get output from resource
1107: my $usersaw=&resource_output($feedurl);
1108:
1109: # Get resource answer (need to allow student to view grades for this to work)
1110: &Apache::lonnet::appenv(('allowed.vgr'=>'F'));
1111: my $useranswer=&Apache::loncommon::get_student_answers(
1112: $symb,$ENV{'user.name'},$ENV{'user.domain'},
1113: $ENV{'request.course.id'});
1114: &Apache::lonnet::delenv('allowed.vgr');
1115: # Get attachments, if any, and not too large
1116: my $attachmenturl='';
1117: if ($ENV{'form.attachment.filename'}) {
1118: unless (length($ENV{'form.attachment'})>131072) {
1119: $attachmenturl=&Apache::lonnet::userfileupload('attachment',undef,'feedback');
1120: }
1121: }
1122: # Filter HTML out of message (could be nasty)
1123: my $message=&clear_out_html($ENV{'form.comment'});
1124:
1125: # Assemble email
1126: my ($email,$citations)=&assemble_email($feedurl,$message,$prevattempts,
1127: $usersaw,$useranswer);
1128:
1129: # Who gets this?
1130: my ($typestyle,%to) = &decide_receiver($feedurl);
1131:
1132: # Actually send mail
1133: my ($status,$numsent)=&send_msg($feedurl,$email,$citations,
1134: $attachmenturl,%to);
1135:
1136: # Discussion? Store that.
1137:
1138: my $numpost=0;
1139: if ($ENV{'form.discuss'}) {
1140: my $subject = &clear_out_html($ENV{'form.subject'});
1141: $typestyle.=&adddiscuss($symb,$message,0,$attachmenturl,$subject);
1142: $numpost++;
1143: }
1144:
1145: if ($ENV{'form.anondiscuss'}) {
1146: my $subject = &clear_out_html($ENV{'form.subject'});
1147: $typestyle.=&adddiscuss($symb,$message,1,$attachmenturl,$subject);
1148: $numpost++;
1149: }
1150:
1151:
1152: # Receipt screen and redirect back to where came from
1153: &redirect_back($r,$feedurl,$typestyle,$numsent,$numpost,$status,$ENV{'form.previous'});
1154:
1155: }
1156: } else {
1157: # Unable to give feedback
1158: &no_redirect_back($r,$feedurl);
1159: }
1160: } else {
1161: # Ambiguous Problem Resource
1162: if ( &Apache::lonnet::mod_perl_version() == 2 ) {
1163: &Apache::lonnet::cleanenv();
1164: }
1165: $r->internal_redirect('/adm/ambiguous');
1166: }
1167: }
1168: return OK;
1169: }
1170:
1171: 1;
1172: __END__
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>