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