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