Annotation of loncom/interface/lonfeedback.pm, revision 1.99.2.11
1.1 www 1: # The LearningOnline Network
2: # Feedback
3: #
1.99.2.11! albertel 4: # $Id: lonfeedback.pm,v 1.99.2.10 2004/10/07 19:55:52 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.86 www 37: use Apache::lonlocal; # must not have ()
38: use Apache::lonhtmlcommon();
1.99.2.10 albertel 39: use Apache::lonnavmaps();
1.54 www 40:
1.92 albertel 41: sub discussion_open {
1.90 albertel 42: my ($status)=@_;
1.92 albertel 43: if (defined($status) &&
44: !($status eq 'CAN_ANSWER' || $status eq 'CANNOT_ANSWER'
1.77 www 45: || $status eq 'OPEN')) {
1.92 albertel 46: return 0;
1.75 albertel 47: }
1.89 albertel 48: my $close=&Apache::lonnet::EXT('resource.0.discussend');
49: if (defined($close) && $close ne '' && $close < time) {
1.92 albertel 50: return 0;
1.89 albertel 51: }
1.92 albertel 52: return 1;
53: }
54:
55: sub discussion_visible {
56: my ($status)=@_;
57: if (not &discussion_open($status)) {
58: my $hidden=&Apache::lonnet::EXT('resource.0.discusshide');
59: if (lc($hidden) eq 'yes' or $hidden eq '' or !defined($hidden)) {
60: return 0;
61: }
62: }
63: return 1;
1.90 albertel 64: }
1.84 raeburn 65:
1.90 albertel 66: sub list_discussion {
67: my ($mode,$status,$symb)=@_;
68:
1.95 sakharuk 69: my $outputtarget=$ENV{'form.grade_target'};
1.92 albertel 70: if (not &discussion_visible($status)) { return ''; }
1.84 raeburn 71: my @bgcols = ("#cccccc","#eeeeee");
1.57 www 72: my $discussiononly=0;
73: if ($mode eq 'board') { $discussiononly=1; }
1.55 www 74: unless ($ENV{'request.course.id'}) { return ''; }
75: my $crs='/'.$ENV{'request.course.id'};
76: if ($ENV{'request.course.sec'}) {
77: $crs.='_'.$ENV{'request.course.sec'};
78: }
79: $crs=~s/\_/\//g;
1.54 www 80: unless ($symb) {
81: $symb=&Apache::lonnet::symbread();
82: }
83: unless ($symb) { return ''; }
1.78 raeburn 84:
1.80 raeburn 85: # backward compatibility (bulletin boards used to be 'wrapped')
86: my $ressymb=$symb;
87: if ($mode eq 'board') {
88: unless ($ressymb =~ m|bulletin___\d+___adm/wrapper|) {
89: $ressymb=~s|(bulletin___\d+___)|$1adm/wrapper|;
90: }
91: }
92:
93: # Get discussion display settings for this discussion
94: my $lastkey = $ressymb.'_lastread';
95: my $showkey = $ressymb.'_showonlyunread';
1.84 raeburn 96: my $ondispkey = $ressymb.'_markondisp';
1.99.2.8 albertel 97: my %dischash = &Apache::lonnet::get('nohist_'.$ENV{'request.course.id'}.'_discuss',[$lastkey,$showkey,$ondispkey],$ENV{'user.domain'},$ENV{'user.name'});
1.84 raeburn 98: my %discinfo = ();
1.80 raeburn 99: my $showonlyunread = 0;
1.84 raeburn 100: my $markondisp = 0;
1.79 raeburn 101: my $prevread = 0;
1.81 raeburn 102: my $previous = 0;
1.80 raeburn 103: my $newpostsflag = 0;
104:
1.81 raeburn 105: # Retain identification of "NEW" posts identified in last display, if continuing 'previous' browsing of posts.
106: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['previous']);
107: $previous = $ENV{'form.previous'};
1.80 raeburn 108: if ($previous > 0) {
109: $prevread = $previous;
110: } elsif (defined($dischash{$lastkey})) {
1.84 raeburn 111: unless ($dischash{$lastkey} eq '') {
112: $prevread = $dischash{$lastkey};
113: }
1.80 raeburn 114: }
1.79 raeburn 115:
1.84 raeburn 116: # Get discussion display default settings for user
1.99.2.7 albertel 117: if ($ENV{'environment.discdisplay'} eq 'unread') {
1.83 raeburn 118: $showonlyunread = 1;
119: }
1.99.2.7 albertel 120: if ($ENV{'environment.discmarkread'} eq 'ondisp') {
1.84 raeburn 121: $markondisp = 1;
122: }
123:
124: # Override user's default if user specified display setting for this discussion
125: if (defined($dischash{$ondispkey})) {
1.99.2.6 albertel 126: unless ($dischash{$showkey} eq '') {
127: $markondisp = $dischash{$ondispkey};
128: }
1.84 raeburn 129: }
130: if ($markondisp) {
131: $discinfo{$lastkey} = time;
132: }
1.83 raeburn 133:
1.80 raeburn 134: if (defined($dischash{$showkey})) {
1.99.2.6 albertel 135: unless ($dischash{$showkey} eq '') {
136: $showonlyunread = $dischash{$showkey};
137: }
1.80 raeburn 138: }
139:
1.54 www 140: my $seeid=&Apache::lonnet::allowed('rin',$crs);
1.77 www 141: my $viewgrades=(&Apache::lonnet::allowed('vgr',$crs)
142: && ($symb=~/\.(problem|exam|quiz|assess|survey|form)$/));
1.68 www 143: my @discussionitems=();
1.73 albertel 144: my %contrib=&Apache::lonnet::restore($ressymb,$ENV{'request.course.id'},
1.54 www 145: $ENV{'course.'.$ENV{'request.course.id'}.'.domain'},
146: $ENV{'course.'.$ENV{'request.course.id'}.'.num'});
1.67 www 147: my $visible=0;
1.68 www 148: my @depth=();
149: my @original=();
150: my @index=();
151: my @replies=();
152: my %alldiscussion=();
1.80 raeburn 153: my %notshown = ();
1.84 raeburn 154: my %newitem = ();
1.68 www 155: my $maxdepth=0;
156:
1.69 www 157: my $target='';
158: unless ($ENV{'browser.interface'} eq 'textual' ||
159: $ENV{'environment.remote'} eq 'off' ) {
160: $target='target="LONcom"';
161: }
1.79 raeburn 162:
163: my $now = time;
1.99.2.8 albertel 164: if (%discinfo) {
165: &Apache::lonnet::put('nohist_'.$ENV{'request.course.id'}.'_discuss',\%discinfo,$ENV{'user.domain'},$ENV{'user.name'});
166: }
1.79 raeburn 167:
1.54 www 168: if ($contrib{'version'}) {
1.84 raeburn 169: my $oldest = $contrib{'1:timestamp'};
170: if ($prevread eq '0') {
171: $prevread = $oldest-1;
172: }
1.64 www 173: for (my $id=1;$id<=$contrib{'version'};$id++) {
174: my $idx=$id;
1.80 raeburn 175: my $posttime = $contrib{$idx.':timestamp'};
1.84 raeburn 176: if ($prevread <= $posttime) {
1.80 raeburn 177: $newpostsflag = 1;
178: }
1.54 www 179: my $hidden=($contrib{'hidden'}=~/\.$idx\./);
180: my $deleted=($contrib{'deleted'}=~/\.$idx\./);
1.68 www 181: my $origindex='0.';
1.69 www 182: if (($contrib{$idx.':replyto'}) && ($ENV{'environment.threadeddiscussion'})) {
1.68 www 183: # this is a follow-up message
184: $original[$idx]=$original[$contrib{$idx.':replyto'}];
185: $depth[$idx]=$depth[$contrib{$idx.':replyto'}]+1;
186: $origindex=$index[$contrib{$idx.':replyto'}];
187: if ($depth[$idx]>$maxdepth) { $maxdepth=$depth[$idx]; }
188: } else {
189: # this is an original message
190: $original[$idx]=0;
191: $depth[$idx]=0;
192: }
193: if ($replies[$depth[$idx]]) {
194: $replies[$depth[$idx]]++;
195: } else {
196: $replies[$depth[$idx]]=1;
197: }
1.54 www 198: unless ((($hidden) && (!$seeid)) || ($deleted)) {
1.67 www 199: $visible++;
1.54 www 200: my $message=$contrib{$idx.':message'};
201: $message=~s/\n/\<br \/\>/g;
202: $message=&Apache::lontexconvert::msgtexconverted($message);
1.78 raeburn 203: my $subject=$contrib{$idx.':subject'};
204: if (defined($subject)) {
205: $subject=~s/\n/\<br \/\>/g;
206: $subject=&Apache::lontexconvert::msgtexconverted($subject);
207: }
1.54 www 208: if ($contrib{$idx.':attachmenturl'}) {
1.82 albertel 209: my ($fname)
210: =($contrib{$idx.':attachmenturl'}=~m|/([^/]+)$|);
211: &Apache::lonnet::allowuploaded('/adm/feedback',
212: $contrib{$idx.':attachmenturl'});
213: $message.='<p>'.&mt('Attachment').
214: ': <a href="'.$contrib{$idx.':attachmenturl'}.'"><tt>'.
215: $fname.'</tt></a></p>';
1.54 www 216: }
217: if ($message) {
218: if ($hidden) {
219: $message='<font color="#888888">'.$message.'</font>';
220: }
1.99.2.7 albertel 221: # my $screenname=&Apache::loncommon::screenname(
222: # $contrib{$idx.':sendername'},
223: # $contrib{$idx.':senderdomain'});
224: # my $plainname=&Apache::loncommon::nickname(
225: # $contrib{$idx.':sendername'},
226: # $contrib{$idx.':senderdomain'});
1.99.2.9 matthew 227: my ($screenname,$plainname)=($contrib{$idx.':screenname'},
228: $contrib{$idx.':plainname'});
1.62 www 229: my $sender=&mt('Anonymous');
1.54 www 230: if ((!$contrib{$idx.':anonymous'}) || ($seeid)) {
231: $sender=&Apache::loncommon::aboutmewrapper(
232: $plainname,
233: $contrib{$idx.':sendername'},
234: $contrib{$idx.':senderdomain'}).' ('.
235: $contrib{$idx.':sendername'}.' at '.
236: $contrib{$idx.':senderdomain'}.')';
237: if ($contrib{$idx.':anonymous'}) {
1.62 www 238: $sender.=' ['.&mt('anonymous').'] '.
1.54 www 239: $screenname;
240: }
241: if ($seeid) {
242: if ($hidden) {
243: $sender.=' <a href="/adm/feedback?unhide='.
1.80 raeburn 244: $ressymb.':::'.$idx;
245: if ($newpostsflag) {
246: $sender .= '&previous='.$prevread;
247: }
248: $sender .= '">'.&mt('Make Visible').'</a>';
1.54 www 249: } else {
250: $sender.=' <a href="/adm/feedback?hide='.
1.80 raeburn 251: $ressymb.':::'.$idx;
252: if ($newpostsflag) {
253: $sender .= '&previous='.$prevread;
254: }
255: $sender .= '">'.&mt('Hide').'</a>';
1.54 www 256: }
257: $sender.=' <a href="/adm/feedback?deldisc='.
1.80 raeburn 258: $ressymb.':::'.$idx;
259: if ($newpostsflag) {
260: $sender .= '&previous='.$prevread;
261: }
262: $sender .= '">'.&mt('Delete').'</a>';
1.64 www 263: }
1.54 www 264: } else {
265: if ($screenname) {
266: $sender='<i>'.$screenname.'</i>';
267: }
1.77 www 268: }
1.92 albertel 269: if (&discussion_open($status) &&
1.90 albertel 270: &Apache::lonnet::allowed('pch',
1.77 www 271: $ENV{'request.course.id'}.
272: ($ENV{'request.course.sec'}?'/'.$ENV{'request.course.sec'}:''))) {
273: $sender.=' <a href="/adm/feedback?replydisc='.
1.80 raeburn 274: $ressymb.':::'.$idx;
275: if ($newpostsflag) {
276: $sender .= '&previous='.$prevread;
277: }
278: $sender .= '" '.$target.'>'.&mt('Reply').'</a>';
1.54 www 279: }
280: my $vgrlink;
281: if ($viewgrades) {
282: $vgrlink=&Apache::loncommon::submlink('Submissions',
283: $contrib{$idx.':sendername'},$contrib{$idx.':senderdomain'},$symb);
284: }
1.68 www 285: #figure out at what position this needs to print
286: my $thisindex=$idx;
1.69 www 287: if ($ENV{'environment.threadeddiscussion'}) {
1.68 www 288: $thisindex=$origindex.substr('00'.$replies[$depth[$idx]],-2,2);
289: }
290: $alldiscussion{$thisindex}=$idx;
291: $index[$idx]=$thisindex;
1.79 raeburn 292: my $spansize = 2;
1.80 raeburn 293: if ($showonlyunread && $prevread > $posttime) {
294: $notshown{$idx} = 1;
1.78 raeburn 295: } else {
1.80 raeburn 296: if ($prevread > 0 && $prevread <= $posttime) {
1.84 raeburn 297: $newitem{$idx} = 1;
298: $discussionitems[$idx] .= '
299: <p><table border="0" width="100%">
300: <tr><td align="left"><font color="#FF0000"><b>NEW</b></font></td>';
301: } else {
302: $newitem{$idx} = 0;
303: $discussionitems[$idx] .= '
304: <p><table border="0" width="100%">
305: <tr><td align="left"> </td>';
1.80 raeburn 306: }
307: $discussionitems[$idx] .= '<td align ="left"> '.
308: '<b>'.$subject.'</b> '.
309: $sender.'</b> '.$vgrlink.' ('.
310: localtime($posttime).')</td></tr>'.
311: '</table><blockquote>'.$message.'</blockquote></p>';
1.78 raeburn 312: }
313: }
314: }
1.54 www 315: }
1.64 www 316: }
1.80 raeburn 317:
1.67 www 318: my $discussion='';
1.84 raeburn 319:
320: my $function = &Apache::loncommon::get_users_function();
321: my $color = &Apache::loncommon::designparm($function.'.tabbg',
322: $ENV{'user.domain'});
323: my %lt = &Apache::lonlocal::texthash(
1.97 raeburn 324: 'cuse' => 'Current discussion settings',
1.84 raeburn 325: 'allposts' => 'All posts',
326: 'unread' => 'New posts only',
327: 'ondisp' => 'Once displayed',
328: 'onmark' => 'Once marked read',
329: 'disa' => 'Posts to be displayed',
330: 'npce' => 'Posts cease to be marked "NEW"',
1.97 raeburn 331: 'chgt' => 'Change',
332: 'disp' => 'Display',
333: 'nolo' => 'Not new',
1.84 raeburn 334: );
335:
336: my $currdisp = $lt{'allposts'};
337: my $currmark = $lt{'onmark'};
338: my $dispchange = $lt{'unread'};
339: my $markchange = $lt{'ondisp'};
1.97 raeburn 340: my $chglink = '/adm/feedback?modifydisp='.$ressymb;
341: my $displink = 'onlyunread';
342: my $marklink = 'markondisp';
1.84 raeburn 343:
344: if ($markondisp) {
345: $currmark = $lt{'ondisp'};
346: $markchange = $lt{'onmark'};
1.97 raeburn 347: $marklink = 'markonread';
1.84 raeburn 348: }
349:
350: if ($showonlyunread) {
351: $currdisp = $lt{'unread'};
352: $dispchange = $lt{'allposts'};
1.97 raeburn 353: $displink = 'allposts';
1.84 raeburn 354: }
1.97 raeburn 355:
356: $chglink .= '&changes='.$displink.'_'.$marklink;
1.84 raeburn 357:
358: if ($newpostsflag) {
1.97 raeburn 359: $chglink .= '&previous='.$prevread;
1.84 raeburn 360: }
361:
1.67 www 362: if ($visible) {
1.80 raeburn 363: # Print the discusssion
1.95 sakharuk 364: if ($outputtarget ne 'tex') {
1.97 raeburn 365: my $colspan=$maxdepth+1;
1.95 sakharuk 366: $discussion.='<table bgcolor="#AAAAAA" cellpadding="2" cellspacing="2" border="0">';
1.97 raeburn 367: $discussion .='<tr><td bgcolor="#DDDDBB" colspan="'.$colspan.'">'.
1.95 sakharuk 368: '<table border="0" width="100%" bgcolor="#DDDDBB"><tr>';
369: if ($visible>2) {
370: $discussion.='<td align="left">'.
371: '<a href="/adm/feedback?threadedon='.$ressymb;
372: if ($newpostsflag) {
373: $discussion .= '&previous='.$prevread;
374: }
375: $discussion .='">'.&mt('Threaded View').'</a> '.
376: '<a href="/adm/feedback?threadedoff='.$ressymb;
377: if ($newpostsflag) {
378: $discussion .= '&previous='.$prevread;
379: }
380: $discussion .='">'.&mt('Chronological View').'</a> </td>';
1.99 raeburn 381: }
1.95 sakharuk 382: if ($newpostsflag) {
383: if (!$markondisp) {
384: $discussion .='<td align="right"><a href="/adm/feedback?markread='.$ressymb.'">'.&mt('Mark new posts as read').'</a> ';
385: } else {
386: $discussion .= '<td> </td>';
387: }
388: } else {
389: $discussion .= '<td> </td>';
390: }
391: $discussion .= '</tr></table></td></tr>';
392: } else {
393: $discussion.='\vskip 0 mm\noindent\makebox[2 cm][b]{\hrulefill}'.
394: '\textbf{DISCUSSIONS}\makebox[2 cm][b]{\hrulefill}'.
395: '\vskip 0 mm\noindent\textbf{'.$lt{'cuse'}.'}:\vskip 0 mm'.
396: '\noindent\textbf{'.$lt{'disa'}.'}: \textit{'.$currdisp.'}\vskip 0 mm'.
397: '\noindent\textbf{'.$lt{'npce'}.'}: \textit{'.$currmark.'}';
398: }
1.80 raeburn 399: my $numhidden = keys %notshown;
400: if ($numhidden > 0) {
401: my $colspan = $maxdepth+1;
402: $discussion.="\n".'<tr><td bgcolor="#CCCCCC" colspan="'.$colspan.'">'.
403: '<a href="/adm/feedback?allposts='.$ressymb;
404: if ($newpostsflag) {
405: $discussion .= '&previous='.$prevread;
406: }
407: $discussion .= '">'.&mt('Show all posts').'</a> '.&mt('to display').' '.
408: $numhidden.' '.&mt('previously viewed posts').
409: '<br/></td></tr>';
410: }
1.68 www 411: foreach (sort { $a <=> $b } keys %alldiscussion) {
1.80 raeburn 412: unless ($notshown{$alldiscussion{$_}} eq '1') {
1.95 sakharuk 413: if ($outputtarget ne 'tex') {
414: $discussion.="\n<tr>";
415: } else {
416: $discussion.='\vskip 0 mm\noindent\makebox[2 cm][b]{\hrulefill}';
417: }
1.80 raeburn 418: my $thisdepth=$depth[$alldiscussion{$_}];
1.95 sakharuk 419: if ($outputtarget ne 'tex') {
420: for (1..$thisdepth) {
421: $discussion.='<td> </td>';
422: }
423: }
1.80 raeburn 424: my $colspan=$maxdepth-$thisdepth+1;
1.95 sakharuk 425: if ($outputtarget ne 'tex') {
426: $discussion.='<td bgcolor="'.$bgcols[$newitem{$alldiscussion{$_}}].'" colspan="'.$colspan.'">'.
1.80 raeburn 427: $discussionitems[$alldiscussion{$_}].
428: '</td></tr>';
1.95 sakharuk 429: } else {
430: #cleanup block
431: $discussionitems[$alldiscussion{$_}]=~s/<table([^>]*)>/<table TeXwidth="90 mm">/;
432: $discussionitems[$alldiscussion{$_}]=~s/<tr([^>]*)><td([^>]*)>/<tr><td TeXwidth="20 mm" align="left">/;
433: my $threadinsert='';
434: if ($thisdepth > 0) {
435: $threadinsert='<br /><strong>Reply: '.$thisdepth.'</strong>';
436: }
437: $discussionitems[$alldiscussion{$_}]=~s/<\/td><td([^>]*)>/$threadinsert<\/td><td TeXwidth="65 mm" align="left">/;
438: $discussionitems[$alldiscussion{$_}]=~s/<a([^>]+)>(Hide|Delete|Reply|Submissions)<\/a>//g;
439: $discussionitems[$alldiscussion{$_}]=~s/(<b>|<\/b>|<\/a>|<a([^>]+)>)//g;
1.96 albertel 440:
441: #FIXME xmlparse can't be safely called from inside xmlparse
442: # due to the global variables that are use, the safe
443: # space etc. I expect this has unforseen issues that
444: # need resolving.
445:
446: $discussion.=&Apache::lonxml::xmlparse('','tex',$discussionitems[$alldiscussion{$_}]);
1.95 sakharuk 447: }
1.69 www 448: }
1.80 raeburn 449: }
1.95 sakharuk 450: if ($outputtarget ne 'tex') {
1.97 raeburn 451: my $colspan=$maxdepth+1;
452: $discussion .= <<END;
453: <tr bgcolor="#FFFFFF">
1.98 raeburn 454: <td colspan="$colspan" valign="top">
1.97 raeburn 455: <table border="0" bgcolor="#FFFFFF" width="100%" cellspacing="2" cellpadding="2">
456: <tr>
457: <td align="left">
458: <table border="0" cellpadding="0" cellspacing="4">
459: <tr>
460: <td>
461: <font size="-1"><b>$lt{'cuse'}</b>:</td>
462: <td> </td>
463: END
464: if ($newpostsflag) {
465: $discussion .=
466: '<td><font size="-1">1. '.$lt{'disp'}.' - <i>'.$currdisp.'</i> 2. '.$lt{'nolo'}.' - <i>'.$currmark.'</i></font></td>';
467: } else {
468: $discussion .=
469: '<td><font size="-1">'.$lt{'disp'}.' - <i>'.$currdisp.'</i></font></td>';
470: }
471: $discussion .= <<END;
472: <td> </td>
473: <td>
474: <font size="-1"><b><a href="$chglink">$lt{'chgt'}</a>?</font></b></td>
475: </tr>
476: </table>
477: </td>
478: </tr>
479: </table>
480: </td>
481: </tr>
482: </table>
483: <br /><br />
484: END
1.95 sakharuk 485: }
1.54 www 486: }
487: if ($discussiononly) {
488: $discussion.=(<<ENDDISCUSS);
489: <form action="/adm/feedback" method="post" name="mailform" enctype="multipart/form-data">
490: <input type="submit" name="discuss" value="Post Discussion" />
491: <input type="submit" name="anondiscuss" value="Post Anonymous Discussion" />
1.73 albertel 492: <input type="hidden" name="symb" value="$ressymb" />
1.54 www 493: <input type="hidden" name="sendit" value="true" />
494: <br />
495: <font size="1">Note: in anonymous discussion, your name is visible only to
496: course faculty</font><br />
1.78 raeburn 497: <b>Title:</b> <input type="text" name="subject" value="" size="30" /><br /><br />
1.94 www 498: <textarea name="comment" cols="80" rows="14" wrap="hard"></textarea>
1.54 www 499: <p>
500: Attachment (128 KB max size): <input type="file" name="attachment" />
501: </p>
502: </form>
503: ENDDISCUSS
1.95 sakharuk 504: if ($outputtarget ne 'tex') {
505: $discussion.=&generate_preview_button();
506: }
1.74 www 507: } else {
1.92 albertel 508: if (&discussion_open($status) &&
1.90 albertel 509: &Apache::lonnet::allowed('pch',
1.74 www 510: $ENV{'request.course.id'}.
511: ($ENV{'request.course.sec'}?'/'.$ENV{'request.course.sec'}:''))) {
1.95 sakharuk 512: if ($outputtarget ne 'tex') {
513: $discussion.='<table bgcolor="#BBBBBB"><tr><td><a href="/adm/feedback?replydisc='.
514: $symb.':::" '.$target.'>'.
515: '<img src="/adm/lonMisc/chat.gif" border="0" />'.
516: &mt('Post Discussion').'</a></td></tr></table>';
517: }
1.74 www 518: }
519: }
1.54 www 520: return $discussion;
521: }
1.1 www 522:
1.6 albertel 523: sub mail_screen {
524: my ($r,$feedurl,$options) = @_;
1.45 www 525: my $bodytag=&Apache::loncommon::bodytag('Resource Feedback and Discussion',
526: '','onLoad="window.focus();"');
1.51 albertel 527: my $title=&Apache::lonnet::gettitle($feedurl);
528: if (!$title) { $title = $feedurl; }
1.69 www 529: my $quote='';
1.78 raeburn 530: my $subject = '';
1.80 raeburn 531: my $prevtag = '';
1.69 www 532: if ($ENV{'form.replydisc'}) {
533: my ($symb,$idx)=split(/\:\:\:/,$ENV{'form.replydisc'});
534: my %contrib=&Apache::lonnet::restore($symb,$ENV{'request.course.id'},
535: $ENV{'course.'.$ENV{'request.course.id'}.'.domain'},
536: $ENV{'course.'.$ENV{'request.course.id'}.'.num'});
1.80 raeburn 537: unless (($contrib{'hidden'}=~/\.$idx\./) || ($contrib{'deleted'}=~/\.$idx\./)) {
1.69 www 538: my $message=$contrib{$idx.':message'};
539: $message=~s/\n/\<br \/\>/g;
540: $quote='<blockquote>'.&Apache::lontexconvert::msgtexconverted($message).'</blockquote>';
1.79 raeburn 541: if ($idx > 0) {
542: $subject = 'Re: '.$contrib{$idx.':subject'};
543: }
1.69 www 544: }
1.80 raeburn 545: if ($ENV{'form.previous'}) {
546: $prevtag = '<input type="hidden" name="previous" value="'.$ENV{'form.previous'}.'" />';
547: }
1.69 www 548: }
1.85 www 549: my $latexHelp=&Apache::loncommon::helpLatexCheatsheet();
1.86 www 550: my $htmlheader=&Apache::lonhtmlcommon::htmlareaheaders();
1.74 www 551: my $send=&mt('Send');
1.6 albertel 552: $r->print(<<ENDDOCUMENT);
1.1 www 553: <html>
554: <head>
555: <title>The LearningOnline Network with CAPA</title>
1.7 albertel 556: <meta http-equiv="pragma" content="no-cache"></meta>
1.85 www 557: $htmlheader
1.63 albertel 558: <script type="text/javascript">
559: //<!--
1.5 www 560: function gosubmit() {
561: var rec=0;
1.12 albertel 562: if (typeof(document.mailform.elements.author)!="undefined") {
1.5 www 563: if (document.mailform.elements.author.checked) {
564: rec=1;
565: }
566: }
1.12 albertel 567: if (typeof(document.mailform.elements.question)!="undefined") {
1.5 www 568: if (document.mailform.elements.question.checked) {
569: rec=1;
570: }
571: }
1.12 albertel 572: if (typeof(document.mailform.elements.course)!="undefined") {
1.5 www 573: if (document.mailform.elements.course.checked) {
574: rec=1;
575: }
576: }
1.12 albertel 577: if (typeof(document.mailform.elements.policy)!="undefined") {
1.5 www 578: if (document.mailform.elements.policy.checked) {
579: rec=1;
580: }
581: }
1.12 albertel 582: if (typeof(document.mailform.elements.discuss)!="undefined") {
1.10 www 583: if (document.mailform.elements.discuss.checked) {
584: rec=1;
585: }
586: }
1.14 www 587: if (typeof(document.mailform.elements.anondiscuss)!="undefined") {
588: if (document.mailform.elements.anondiscuss.checked) {
589: rec=1;
590: }
591: }
1.5 www 592:
593: if (rec) {
1.99.2.3 albertel 594: if (typeof(document.mailform.onsubmit)=='function') {
1.99.2.2 albertel 595: document.mailform.onsubmit();
596: }
1.5 www 597: document.mailform.submit();
598: } else {
599: alert('Please check a feedback type.');
600: }
601: }
1.63 albertel 602: //-->
1.5 www 603: </script>
1.1 www 604: </head>
1.29 www 605: $bodytag
1.51 albertel 606: <h2><tt>$title</tt></h2>
1.43 www 607: <form action="/adm/feedback" method="post" name="mailform"
608: enctype="multipart/form-data">
1.80 raeburn 609: $prevtag
1.63 albertel 610: <input type="hidden" name="postdata" value="$feedurl" />
1.68 www 611: <input type="hidden" name="replydisc" value="$ENV{'form.replydisc'}" />
1.5 www 612: Please check at least one of the following feedback types:
1.63 albertel 613: $options<hr />
1.69 www 614: $quote
1.63 albertel 615: <p>My question/comment/feedback:</p>
616: <p>
1.47 bowersj2 617: $latexHelp
1.78 raeburn 618: Title: <input type="text" name="subject" size="30" value="$subject" /></p>
619: <p>
1.94 www 620: <textarea name="comment" id="comment" cols="60" rows="10" wrap="hard">
1.63 albertel 621: </textarea></p>
622: <p>
1.42 www 623: Attachment (128 KB max size): <input type="file" name="attachment" />
624: </p>
625: <p>
626: <input type="hidden" name="sendit" value="1" />
1.74 www 627: <input type="button" value="$send" onClick='gosubmit();' />
1.42 www 628: </p>
1.2 www 629: </form>
1.1 www 630: ENDDOCUMENT
1.99.2.2 albertel 631: $r->print(&generate_preview_button().
1.94 www 632: &Apache::lonhtmlcommon::htmlareaselectactive('comment').
1.85 www 633: '</body></html>');
1.6 albertel 634: }
635:
1.97 raeburn 636: sub print_display_options {
637: my ($r,$symb,$previous,$dispchg,$markchg,$feedurl) = @_;
1.98 raeburn 638: # backward compatibility (bulletin boards used to be 'wrapped')
639: if ($feedurl=~m|^/adm/wrapper/adm/.*/bulletinboard$|) {
640: $feedurl=~s|^/adm/wrapper||;
641: }
642:
1.97 raeburn 643: my $function = &Apache::loncommon::get_users_function();
644: my $tabcolor = &Apache::loncommon::designparm($function.'.tabbg',
645: $ENV{'user.domain'});
646: my $bodytag=&Apache::loncommon::bodytag('Discussion options',
647: '','');
648:
649: my %lt = &Apache::lonlocal::texthash(
650: 'dido' => 'Discussion display options',
651: 'pref' => 'Display Preference',
652: 'curr' => 'Current setting ',
653: 'actn' => 'Action',
654: 'deff' => 'Default for all discussions',
655: 'prca' => 'Preferences can be set for this discussion that determine ....',
656: 'whpo' => 'Which posts are displayed when you display this bulletin board or resource, and',
657: 'unwh' => 'Under what circumstances posts are identfied as "New."',
658: 'allposts' => 'All posts',
659: 'unread' => 'New posts only',
660: 'ondisp' => 'Once displayed',
661: 'onmark' => 'Once marked as read',
662: 'disa' => 'Posts displayed?',
663: 'npmr' => 'New posts cease to be identified as "New"?',
664: 'chgt' => 'Change to ',
665: 'mkdf' => 'Set to ',
666: 'yhni' => 'You have not indicated that you wish to change either of the discussion settings',
667: 'ywbr' => 'You will be returned to the previous page if you click OK.'
668: );
669:
670: my $dispchange = $lt{'unread'};
671: my $markchange = $lt{'ondisp'};
672: my $currdisp = $lt{'allposts'};
673: my $currmark = $lt{'onmark'};
674: my $discdisp = 'allposts';
675: my $discmark = 'onmark';
676:
677: if ($dispchg eq 'allposts') {
678: $dispchange = $lt{'allposts'};
679: $currdisp = $lt{'unread'};
680: $discdisp = 'unread';
681: }
682:
683: if ($markchg eq 'markonread') {
684: $markchange = $lt{'onmark'};
685: $currmark = $lt{'ondisp'};
686: $discmark = 'ondisp';
687: }
688: $r->print(<<END);
689: <html>
690: <head>
691: <title>$lt{'dido'}</title>
692: <meta http-equiv="pragma" content="no-cache" />
693: <script>
694: function setDisp() {
695: var prev = "$previous"
696: var chktotal = 0
697: if (document.modifydisp.discdisp.checked == true) {
698: document.modifydisp.$dispchg.value = "$symb"
699: chktotal ++
700: }
701: if (document.modifydisp.discmark.checked == true) {
702: document.modifydisp.$markchg.value = "$symb"
703: chktotal ++
704: }
705: if (chktotal > 0) {
706: document.modifydisp.submit()
707: } else {
708: if(confirm("$lt{'yhni'}. \\n$lt{'ywbr'}")) {
709: if (prev > 0) {
710: location.href = "$feedurl?previous=$previous"
711: } else {
712: location.href = "$feedurl"
713: }
714: }
715: }
716: }
717: </script>
718: </head>
719: $bodytag
720: <form name="modifydisp" method="post" action="/adm/feedback">
721: $lt{'sdpf'}<br/> $lt{'prca'} <ol><li>$lt{'whpo'}</li><li>$lt{'unwh'}</li></ol>
722: <br />
723: <table border="0" cellpadding="0" cellspacing="0">
724: <tr>
725: <td width="100%" bgcolor="#000000">
726: <table width="100%" border="0" cellpadding="1" cellspacing="0">
727: <tr>
728: <td width="100%" bgcolor="#000000">
729: <table border="0" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF">
730: <tr bgcolor="$tabcolor">
731: <td><b>$lt{'pref'}</b></td>
732: <td><b>$lt{'curr'}</b></td>
733: <td><b>$lt{'actn'}?</b></td>
734: </tr>
735: <tr bgcolor="#dddddd">
736: <td>$lt{'disa'}</td>
737: <td>$lt{$discdisp}</td>
738: <td><input type="checkbox" name="discdisp" /> $lt{'chgt'} "$dispchange"</td>
739: </tr><tr bgcolor="#eeeeee">
740: <td>$lt{'npmr'}</td>
741: <td>$lt{$discmark}</td>
742: <td><input type="checkbox" name="discmark" />$lt{'chgt'} "$markchange"</td>
743: </tr>
744: </table>
745: </td>
746: </tr>
747: </table>
748: </td>
749: </tr>
750: </table>
751: <br />
752: <br />
753: <input type="hidden" name="previous" value="$previous" />
754: <input type="hidden" name="$dispchg" value=""/>
755: <input type="hidden" name="$markchg" value=""/>
756: <input type="button" name="sub" value="Store Changes" onClick="javascript:setDisp()" />
757: <br />
758: <br />
759: </form>
760: </body>
761: </html>
762: END
763: return;
764: }
765:
1.6 albertel 766: sub fail_redirect {
767: my ($r,$feedurl) = @_;
1.70 www 768: if ($feedurl=~/^\/adm\//) { $feedurl.='?register=1' };
1.6 albertel 769: $r->print (<<ENDFAILREDIR);
1.72 albertel 770: <html>
1.5 www 771: <head><title>Feedback not sent</title>
1.63 albertel 772: <meta http-equiv="pragma" content="no-cache" />
773: <meta HTTP-EQUIV="Refresh" CONTENT="2; url=$feedurl" />
1.5 www 774: </head>
775: <body bgcolor="#FFFFFF">
1.63 albertel 776: <img align="right" src="/adm/lonIcons/lonlogos.gif" />
1.8 www 777: <b>Sorry, no recipients ...</b>
1.99.2.5 albertel 778: <br /><a href="$feedurl">Continue</a>
1.5 www 779: </body>
780: </html>
781: ENDFAILREDIR
782: }
1.4 www 783:
1.6 albertel 784: sub redirect_back {
1.80 raeburn 785: my ($r,$feedurl,$typestyle,$sendsomething,$sendposts,$status,$previous) = @_;
786: my $prevtag = '';
787: my $qrystr = '';
1.98 raeburn 788: # backward compatibility (bulletin boards used to be 'wrapped')
789: if ($feedurl=~m|^/adm/wrapper/adm/.*/bulletinboard$|) {
790: $feedurl=~s|^/adm/wrapper||;
791: }
792:
1.70 www 793: if ($feedurl=~/^\/adm\//) { $feedurl.='?register=1' };
1.80 raeburn 794: if ($previous > 0) {
795: $qrystr = 'previous='.$previous;
796: if ($feedurl =~ /\?register=1/) {
797: $feedurl .= '&'.$qrystr;
798: } else {
799: $feedurl .= '?'.$qrystr;
800: }
801: $prevtag = '<input type="hidden" name="previous" value="'.$previous.'" />';
802: }
1.6 albertel 803: $r->print (<<ENDREDIR);
1.72 albertel 804: <html>
1.3 www 805: <head>
806: <title>Feedback sent</title>
1.63 albertel 807: <meta http-equiv="pragma" content="no-cache" />
1.80 raeburn 808: <meta HTTP-EQUIV="Refresh" CONTENT="2; url=$feedurl" />
1.2 www 809: </head>
1.49 www 810: <body bgcolor="#FFFFFF" onLoad='if (window.name!="loncapaclient") { this.document.reldt.submit(); self.close(); }'>
1.63 albertel 811: <img align="right" src="/adm/lonIcons/lonlogos.gif" />
1.5 www 812: $typestyle
1.32 albertel 813: <b>Sent $sendsomething message(s), and $sendposts post(s).</b>
1.63 albertel 814: <font color="red">$status</font>
1.49 www 815: <form name="reldt" action="$feedurl" target="loncapaclient">
1.80 raeburn 816: $prevtag
1.49 www 817: </form>
1.99.2.5 albertel 818: <br /><a href="$feedurl">Continue</a>
1.2 www 819: </body>
820: </html>
821: ENDREDIR
822: }
1.6 albertel 823:
824: sub no_redirect_back {
825: my ($r,$feedurl) = @_;
826: $r->print (<<ENDNOREDIR);
1.72 albertel 827: <html>
1.2 www 828: <head><title>Feedback not sent</title>
1.63 albertel 829: <meta http-equiv="pragma" content="no-cache" />
1.7 albertel 830: ENDNOREDIR
831:
1.8 www 832: if ($feedurl!~/^\/adm\/feedback/) {
1.7 albertel 833: $r->print('<meta HTTP-EQUIV="Refresh" CONTENT="2; url='.$feedurl.'">');
834: }
835:
1.8 www 836: $r->print (<<ENDNOREDIRTWO);
1.2 www 837: </head>
1.49 www 838: <body bgcolor="#FFFFFF" onLoad='if (window.name!="loncapaclient") { self.close(); }'>
1.63 albertel 839: <img align="right" src="/adm/lonIcons/lonlogos.gif" />
1.8 www 840: <b>Sorry, no feedback possible on this resource ...</b>
1.99.2.5 albertel 841: <br /><a href="$feedurl">Continue</a>
1.2 www 842: </body>
843: </html>
1.8 www 844: ENDNOREDIRTWO
1.2 www 845: }
1.6 albertel 846:
847: sub screen_header {
1.65 www 848: my ($feedurl) = @_;
849: my $msgoptions='';
850: my $discussoptions='';
851: unless ($ENV{'form.replydisc'}) {
852: if (($feedurl=~/^\/res\//) && ($feedurl!~/^\/res\/adm/)) {
853: $msgoptions=
854: '<p><input type="checkbox" name="author" /> '.
855: &mt('Feedback to resource author').'</p>';
856: }
857: if (&feedback_available(1)) {
858: $msgoptions.=
859: '<br /><input type="checkbox" name="question" /> '.
860: &mt('Question about resource content');
861: }
862: if (&feedback_available(0,1)) {
863: $msgoptions.=
864: '<br /><input type="checkbox" name="course" /> '.
865: &mt('Question/Comment/Feedback about course content');
866: }
867: if (&feedback_available(0,0,1)) {
868: $msgoptions.=
869: '<br /><input type="checkbox" name="policy" /> '.
870: &mt('Question/Comment/Feedback about course policy');
871: }
872: }
873: if ($ENV{'request.course.id'}) {
1.92 albertel 874: if (&discussion_open() &&
1.90 albertel 875: &Apache::lonnet::allowed('pch',
1.65 www 876: $ENV{'request.course.id'}.
877: ($ENV{'request.course.sec'}?'/'.$ENV{'request.course.sec'}:''))) {
1.74 www 878: $discussoptions='<input type="checkbox" name="discuss" onClick="this.form.anondiscuss.checked=false;" '.
879: ($ENV{'form.replydisc'}?' checked="1"':'').' /> '.
1.65 www 880: &mt('Contribution to course discussion of resource');
881: $discussoptions.='<br /><input type="checkbox" name="anondiscuss" onClick="this.form.discuss.checked=false;" /> '.
882: &mt('Anonymous contribution to course discussion of resource').
883: ' <i>('.&mt('name only visible to course faculty').')</i>';
1.20 www 884: }
1.65 www 885: }
1.74 www 886: if ($msgoptions) { $msgoptions='<h2><img src="/adm/lonMisc/feedback.gif" />'.&mt('Sending Messages').'</h2>'.$msgoptions; }
1.65 www 887: if ($discussoptions) {
1.74 www 888: $discussoptions='<h2><img src="/adm/lonMisc/chat.gif" />'.&mt('Discussion Contributions').'</h2>'.$discussoptions; }
1.65 www 889: return $msgoptions.$discussoptions;
1.6 albertel 890: }
891:
892: sub resource_output {
893: my ($feedurl) = @_;
1.46 albertel 894: my $usersaw=&Apache::lonnet::ssi_body($feedurl);
1.6 albertel 895: $usersaw=~s/\<body[^\>]*\>//gi;
896: $usersaw=~s/\<\/body\>//gi;
897: $usersaw=~s/\<html\>//gi;
898: $usersaw=~s/\<\/html\>//gi;
899: $usersaw=~s/\<head\>//gi;
900: $usersaw=~s/\<\/head\>//gi;
901: $usersaw=~s/action\s*\=/would_be_action\=/gi;
902: return $usersaw;
903: }
904:
905: sub clear_out_html {
1.39 www 906: my ($message,$override)=@_;
1.88 www 907: unless (&Apache::lonhtmlcommon::htmlareablocked()) { return $message; }
1.37 albertel 908: my $cid=$ENV{'request.course.id'};
1.39 www 909: if (($ENV{"course.$cid.allow_limited_html_in_feedback"} =~ m/yes/i) ||
910: ($override)) {
1.37 albertel 911: # allows <B> <I> <P> <A> <LI> <OL> <UL> <EM> <BR> <TT> <STRONG>
1.88 www 912: # <BLOCKQUOTE> <DIV .*> <DIV> <IMG> <M> <SPAN> <H1> <H2> <H3> <H4> <SUB>
913: # <SUP>
1.37 albertel 914: my %html=(B=>1, I=>1, P=>1, A=>1, LI=>1, OL=>1, UL=>1, EM=>1,
1.61 www 915: BR=>1, TT=>1, STRONG=>1, BLOCKQUOTE=>1, DIV=>1, IMG=>1,
1.88 www 916: M=>1, SUB=>1, SUP=>1, SPAN=>1,
917: H1=>1, H2=>1, H3=>1, H4=>1, H5=>1);
1.37 albertel 918:
919: $message =~ s/\<(\/?\s*(\w+)[^\>\<]*)/
1.48 albertel 920: {($html{uc($2)}&&(length($1)<1000))?"\<$1":"\<$1"}/ge;
1.37 albertel 921: $message =~ s/(\<?\s*(\w+)[^\<\>]*)\>/
1.48 albertel 922: {($html{uc($2)}&&(length($1)<1000))?"$1\>":"$1\>"}/ge;
1.37 albertel 923: } else {
924: $message=~s/\</\<\;/g;
925: $message=~s/\>/\>\;/g;
926: }
1.6 albertel 927: return $message;
928: }
929:
930: sub assemble_email {
1.40 albertel 931: my ($feedurl,$message,$prevattempts,$usersaw,$useranswer)=@_;
1.6 albertel 932: my $email=<<"ENDEMAIL";
933: Refers to <a href="$feedurl">$feedurl</a>
934:
935: $message
936: ENDEMAIL
937: my $citations=<<"ENDCITE";
938: <h2>Previous attempts of student (if applicable)</h2>
939: $prevattempts
1.63 albertel 940: <br /><hr />
1.6 albertel 941: <h2>Original screen output (if applicable)</h2>
942: $usersaw
1.40 albertel 943: <h2>Correct Answer(s) (if applicable)</h2>
944: $useranswer
1.6 albertel 945: ENDCITE
946: return ($email,$citations);
947: }
948:
1.35 www 949: sub secapply {
950: my $rec=shift;
1.36 www 951: my $defaultflag=shift;
952: $rec=~s/\s+//g;
953: $rec=~s/\@/\:/g;
954: my ($adr,$sections)=($rec=~/^([^\(]+)\(([^\)]+)\)/);
955: if ($sections) {
956: foreach (split(/\;/,$sections)) {
957: if (($_ eq $ENV{'request.course.sec'}) ||
958: ($defaultflag && ($_ eq '*'))) {
959: return $adr;
960: }
961: }
962: } else {
963: return $rec;
964: }
965: return '';
1.35 www 966: }
967:
1.6 albertel 968: sub decide_receiver {
1.36 www 969: my ($feedurl,$author,$question,$course,$policy,$defaultflag) = @_;
1.6 albertel 970: my $typestyle='';
971: my %to=();
1.36 www 972: if ($ENV{'form.author'}||$author) {
1.8 www 973: $typestyle.='Submitting as Author Feedback<br>';
1.6 albertel 974: $feedurl=~/^\/res\/(\w+)\/(\w+)\//;
975: $to{$2.':'.$1}=1;
976: }
1.36 www 977: if ($ENV{'form.question'}||$question) {
1.8 www 978: $typestyle.='Submitting as Question<br>';
1.24 harris41 979: foreach (split(/\,/,
980: $ENV{'course.'.$ENV{'request.course.id'}.'.question.email'})
981: ) {
1.36 www 982: my $rec=&secapply($_,$defaultflag);
983: if ($rec) { $to{$rec}=1; }
1.24 harris41 984: }
1.6 albertel 985: }
1.36 www 986: if ($ENV{'form.course'}||$course) {
1.63 albertel 987: $typestyle.='Submitting as Comment<br />';
1.24 harris41 988: foreach (split(/\,/,
989: $ENV{'course.'.$ENV{'request.course.id'}.'.comment.email'})
990: ) {
1.36 www 991: my $rec=&secapply($_,$defaultflag);
992: if ($rec) { $to{$rec}=1; }
1.24 harris41 993: }
1.6 albertel 994: }
1.36 www 995: if ($ENV{'form.policy'}||$policy) {
1.63 albertel 996: $typestyle.='Submitting as Policy Feedback<br />';
1.24 harris41 997: foreach (split(/\,/,
998: $ENV{'course.'.$ENV{'request.course.id'}.'.policy.email'})
999: ) {
1.36 www 1000: my $rec=&secapply($_,$defaultflag);
1001: if ($rec) { $to{$rec}=1; }
1.24 harris41 1002: }
1.6 albertel 1003: }
1.36 www 1004: if ((scalar(%to) eq '0') && (!$defaultflag)) {
1005: ($typestyle,%to)=
1006: &decide_receiver($feedurl,$author,$question,$course,$policy,1);
1007: }
1.6 albertel 1008: return ($typestyle,%to);
1.36 www 1009: }
1010:
1011: sub feedback_available {
1012: my ($question,$course,$policy)=@_;
1013: my ($typestyle,%to)=&decide_receiver('',0,$question,$course,$policy);
1014: return scalar(%to);
1.6 albertel 1015: }
1016:
1017: sub send_msg {
1.43 www 1018: my ($feedurl,$email,$citations,$attachmenturl,%to)=@_;
1.6 albertel 1019: my $status='';
1020: my $sendsomething=0;
1.24 harris41 1021: foreach (keys %to) {
1.6 albertel 1022: if ($_) {
1.22 www 1023: my $declutter=&Apache::lonnet::declutter($feedurl);
1.8 www 1024: unless (&Apache::lonmsg::user_normal_msg(split(/\:/,$_),
1.43 www 1025: 'Feedback ['.$declutter.']',$email,$citations,$feedurl,
1026: $attachmenturl)=~/ok/) {
1.63 albertel 1027: $status.='<br />'.&mt('Error sending message to').' '.$_.'<br />';
1.6 albertel 1028: } else {
1029: $sendsomething++;
1030: }
1031: }
1.24 harris41 1032: }
1.18 www 1033:
1034: my %record=&Apache::lonnet::restore('_feedback');
1035: my ($temp)=keys %record;
1036: unless ($temp=~/^error\:/) {
1037: my %newrecord=();
1038: $newrecord{'resource'}=$feedurl;
1039: $newrecord{'subnumber'}=$record{'subnumber'}+1;
1040: unless (&Apache::lonnet::cstore(\%newrecord,'_feedback') eq 'ok') {
1.63 albertel 1041: $status.='<br />'.&mt('Not registered').'<br />';
1.18 www 1042: }
1043: }
1044:
1.6 albertel 1045: return ($status,$sendsomething);
1046: }
1047:
1.13 www 1048: sub adddiscuss {
1.78 raeburn 1049: my ($symb,$email,$anon,$attachmenturl,$subject)=@_;
1.13 www 1050: my $status='';
1.92 albertel 1051: if (&discussion_open() &&
1.90 albertel 1052: &Apache::lonnet::allowed('pch',$ENV{'request.course.id'}.
1.23 www 1053: ($ENV{'request.course.sec'}?'/'.$ENV{'request.course.sec'}:''))) {
1.20 www 1054:
1.13 www 1055: my %contrib=('message' => $email,
1056: 'sendername' => $ENV{'user.name'},
1.26 www 1057: 'senderdomain' => $ENV{'user.domain'},
1058: 'screenname' => $ENV{'environment.screenname'},
1059: 'plainname' => $ENV{'environment.firstname'}.' '.
1060: $ENV{'environment.middlename'}.' '.
1061: $ENV{'environment.lastname'}.' '.
1.42 www 1062: $ENV{'enrironment.generation'},
1.78 raeburn 1063: 'attachmenturl'=> $attachmenturl,
1064: 'subject' => $subject);
1.65 www 1065: if ($ENV{'form.replydisc'}) {
1.66 www 1066: $contrib{'replyto'}=(split(/\:\:\:/,$ENV{'form.replydisc'}))[1];
1.65 www 1067: }
1.14 www 1068: if ($anon) {
1069: $contrib{'anonymous'}='true';
1070: }
1.13 www 1071: if (($symb) && ($email)) {
1.14 www 1072: $status='Adding to class discussion'.($anon?' (anonymous)':'').': '.
1.13 www 1073: &Apache::lonnet::store(\%contrib,$symb,$ENV{'request.course.id'},
1074: $ENV{'course.'.$ENV{'request.course.id'}.'.domain'},
1.17 www 1075: $ENV{'course.'.$ENV{'request.course.id'}.'.num'});
1.21 www 1076: my %storenewentry=($symb => time);
1.63 albertel 1077: $status.='<br />'.&mt('Updating discussion time').': '.
1.21 www 1078: &Apache::lonnet::put('discussiontimes',\%storenewentry,
1079: $ENV{'course.'.$ENV{'request.course.id'}.'.domain'},
1080: $ENV{'course.'.$ENV{'request.course.id'}.'.num'});
1.13 www 1081: }
1.17 www 1082: my %record=&Apache::lonnet::restore('_discussion');
1083: my ($temp)=keys %record;
1084: unless ($temp=~/^error\:/) {
1085: my %newrecord=();
1086: $newrecord{'resource'}=$symb;
1087: $newrecord{'subnumber'}=$record{'subnumber'}+1;
1.63 albertel 1088: $status.='<br />'.&mt('Registering').': '.
1.21 www 1089: &Apache::lonnet::cstore(\%newrecord,'_discussion');
1.20 www 1090: }
1091: } else {
1092: $status.='Failed.';
1.17 www 1093: }
1.63 albertel 1094: return $status.'<br />';
1.13 www 1095: }
1096:
1.33 www 1097: # ----------------------------------------------------------- Preview function
1098:
1099: sub show_preview {
1100: my $r=shift;
1101: my $message=&clear_out_html($ENV{'form.comment'});
1102: $message=~s/\n/\<br \/\>/g;
1103: $message=&Apache::lontexconvert::msgtexconverted($message);
1.78 raeburn 1104: my $subject=&clear_out_html($ENV{'form.subject'});
1105: $subject=~s/\n/\<br \/\>/g;
1106: $subject=&Apache::lontexconvert::msgtexconverted($subject);
1.33 www 1107: $r->print('<table border="2"><tr><td>'.
1.78 raeburn 1108: '<b>Subject:</b> '.$subject.'<br /><br />'.
1.33 www 1109: $message.'</td></tr></table>');
1110: }
1111:
1112: sub generate_preview_button {
1.65 www 1113: my $pre=&mt("Show Preview");
1.33 www 1114: return(<<ENDPREVIEW);
1115: <form name="preview" action="/adm/feedback?preview=1" method="post" target="preview">
1.78 raeburn 1116: <input type="hidden" name="subject">
1.33 www 1117: <input type="hidden" name="comment" />
1.65 www 1118: <input type="button" value="$pre"
1.99.2.4 albertel 1119: onClick="if (typeof(document.mailform.onsubmit)=='function') {document.mailform.onsubmit();};this.form.comment.value=document.mailform.comment.value;this.form.subject.value=document.mailform.subject.value;this.form.submit();" />
1.33 www 1120: </form>
1121: ENDPREVIEW
1122: }
1.71 www 1123:
1.99.2.10 albertel 1124: sub has_discussion {
1125: my $resourcesref = shift;
1126: my $navmap = Apache::lonnavmaps::navmap->new();
1127: my @allres=$navmap->retrieveResources();
1128: foreach my $resource (@allres) {
1129: if ($resource->hasDiscussion()) {
1130: my $ressymb;
1131: if ($resource->symb() =~ m-(___adm/\w+/\w+)/(\d+)/bulletinboard$-) {
1132: $ressymb = 'bulletin___'.$2.$1.'/'.$2.'/bulletinboard';
1133: } else {
1134: $ressymb = $resource->symb();
1135: }
1136: push @{$resourcesref}, $ressymb;
1137: }
1138: }
1.99.2.11! albertel 1139: $navmap->untieHashes();
1.99.2.10 albertel 1140: return;
1141: }
1142:
1.6 albertel 1143: sub handler {
1144: my $r = shift;
1.8 www 1145: if ($r->header_only) {
1.71 www 1146: &Apache::loncommon::content_type($r,'text/html');
1.8 www 1147: $r->send_http_header;
1148: return OK;
1149: }
1.15 www 1150:
1151: # --------------------------- Get query string for limited number of parameters
1152:
1.97 raeburn 1153: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
1.99.2.10 albertel 1154: ['hide','unhide','deldisc','postdata','preview','replydisc','threadedon','threadedoff','onlyunread','allposts','previous','markread','markonread','markondisp','modifydisp','changes','navtime','navurl']);
1155: if ($ENV{'form.navtime'}) {
1.99 raeburn 1156: my %discinfo = ();
1157: my @resources = ();
1.99.2.10 albertel 1158: &has_discussion(\@resources);
1.99 raeburn 1159: my $numitems = @resources;
1160: my $feedurl = '/adm/navmaps';
1161: if ($ENV{'form.navurl'}) {
1162: $feedurl .= '?'.$ENV{'form.navurl'};
1163: }
1164: my %lt = &Apache::lonlocal::texthash(
1165: 'mnpa' => 'Marked "New" posts as read in a total of',
1.99.2.10 albertel 1166: 'robb' => 'resources/bulletin boards.',
1167: 'twnp' => 'There are currently no resources or bulletin boards with unread discussion postings.'
1.99 raeburn 1168: );
1169: foreach (@resources) {
1170: # backward compatibility (bulletin boards used to be 'wrapped')
1171: my $ressymb=$_;
1172: if ($ressymb =~ m/bulletin___\d+___/) {
1173: unless ($ressymb =~ m|bulletin___\d+___adm/wrapper|) {
1174: $ressymb=~s|(bulletin___\d+___)|$1adm/wrapper/|;
1175: }
1176: }
1177: my $lastkey = $ressymb.'_lastread';
1.99.2.10 albertel 1178: $discinfo{$lastkey} = $ENV{'form.navtime'};
1179: }
1180: my $textline = "<b>$lt{'mnpa'} $numitems $lt{'robb'}</b>";
1181: if ($numitems > 0) {
1182: &Apache::lonnet::put('nohist_'.$ENV{'request.course.id'}.'_discuss',\%discinfo,$ENV{'user.domain'},$ENV{'user.name'});
1183: } else {
1184: $textline = "<b>$lt{'twnp'}</b>";
1.99 raeburn 1185: }
1186: &Apache::loncommon::content_type($r,'text/html');
1187: $r->send_http_header;
1188: $r->print (<<ENDREDIR);
1189: <html>
1190: <head>
1191: <title>New posts marked as read</title>
1192: <meta http-equiv="pragma" content="no-cache" />
1193: <meta HTTP-EQUIV="Refresh" CONTENT="2; url=$feedurl" />
1194: </head>
1195: <body bgcolor="#FFFFFF" onLoad='if (window.name!="loncapaclient") { this.document.reldt.submit(); self.close(); }'>
1196: <img align="right" src="/adm/lonIcons/lonlogos.gif" />
1.99.2.10 albertel 1197: $textline
1.99 raeburn 1198: <form name="reldt" action="$feedurl" target="loncapaclient">
1199: </form>
1.99.2.5 albertel 1200: <br /><a href="$feedurl">Continue</a>
1.99 raeburn 1201: </body>
1202: </html>
1203: ENDREDIR
1204: return OK;
1205: } elsif ($ENV{'form.modifydisp'}) {
1.84 raeburn 1206: &Apache::loncommon::content_type($r,'text/html');
1207: $r->send_http_header;
1.97 raeburn 1208: my $symb=$ENV{'form.modifydisp'};
1.84 raeburn 1209: my ($map,$ind,$url)=&Apache::lonnet::decode_symb($symb);
1.97 raeburn 1210: my $previous=$ENV{'form.previous'};
1211: my ($dispchg,$markchg) = split/_/,$ENV{'form.changes'};
1212: my $feedurl = &Apache::lonnet::clutter($url);
1.98 raeburn 1213: # backward compatibility (bulletin boards used to be 'wrapped')
1214: if ($feedurl=~m|^/adm/wrapper/adm/.*/bulletinboard$|) {
1215: $feedurl=~s|^/adm/wrapper||;
1216: }
1.97 raeburn 1217: &print_display_options($r,$symb,$previous,$dispchg,$markchg,$feedurl);
1218: return OK;
1219: } elsif (($ENV{'form.markondisp'}) || ($ENV{'form.markonread'}) || ($ENV{'form.allposts'}) || ($ENV{'form.onlyunread'}) ) {
1220: &Apache::loncommon::content_type($r,'text/html');
1221: $r->send_http_header;
1222: my $previous=$ENV{'form.previous'};
1223: my ($map,$ind,$url);
1224: if (($ENV{'form.markondisp'}) || ($ENV{'form.markonread'})) {
1225: # ---------------------- Modify setting for identification of 'NEW' posts in this discussion
1226: my $symb=$ENV{'form.markondisp'}?$ENV{'form.markondisp'}:$ENV{'form.markonread'};
1227: my $ressymb = $symb;
1228: ($map,$ind,$url)=&Apache::lonnet::decode_symb($symb);
1229: unless ($ressymb =~ m|bulletin___\d+___adm/wrapper|) {
1230: $ressymb=~s|(bulletin___\d+___)|$1adm/wrapper|;
1231: }
1232: my %discinfo = ();
1233: my $lastkey = $ressymb.'_lastread';
1234: my $ondispkey = $ressymb.'_markondisp';
1235: if ($ENV{'form.markondisp'}) {
1236: $discinfo{$lastkey} = time;
1237: $discinfo{$ondispkey} = 1;
1238: } elsif ($ENV{'form.markonread'}) {
1239: if ( $previous > 0 ) {
1240: $discinfo{$lastkey} = $previous;
1241: }
1242: $discinfo{$ondispkey} = 0;
1243: }
1244: &Apache::lonnet::put('nohist_'.$ENV{'request.course.id'}.'_discuss',\%discinfo,$ENV{'user.domain'},$ENV{'user.name'});
1.84 raeburn 1245: }
1.97 raeburn 1246: if (($ENV{'form.allposts'}) || ($ENV{'form.onlyunread'})) {
1247: # ----------------------------------------------------------------- Modify display setting for this discussion
1248: my $symb=$ENV{'form.allposts'}?$ENV{'form.allposts'}:$ENV{'form.onlyunread'};
1249: my $ressymb = $symb;
1250: ($map,$ind,$url)=&Apache::lonnet::decode_symb($symb);
1251: unless ($ressymb =~ m|bulletin___\d+___adm/wrapper|) {
1252: $ressymb=~s|(bulletin___\d+___)|$1adm/wrapper|;
1253: }
1254: my %discinfo = ();
1255: if ($ENV{'form.allposts'}) {
1256: $discinfo{$ressymb.'_showonlyunread'} = 0;
1257: } elsif ($ENV{'form.onlyunread'}) {
1258: $discinfo{$ressymb.'_showonlyunread'} = 1;
1.84 raeburn 1259: }
1.97 raeburn 1260: &Apache::lonnet::put('nohist_'.$ENV{'request.course.id'}.'_discuss',\%discinfo,$ENV{'user.domain'},$ENV{'user.name'});
1.84 raeburn 1261: }
1.97 raeburn 1262: if (($ENV{'form.markonread'}) || ($ENV{'form.allposts'}) || ($ENV{'form.onlyunread'}) ) {
1263: &redirect_back($r,&Apache::lonnet::clutter($url),&mt('Changed display status').'<br />','0','0','',$previous);
1264: } else {
1.84 raeburn 1265: &redirect_back($r,&Apache::lonnet::clutter($url),&mt('Changed display status').'<br />','0','0');
1266: }
1267: return OK;
1268: } elsif ($ENV{'form.markread'}) {
1269: # ----------------------------------------------------------------- Mark new posts as read
1270: &Apache::loncommon::content_type($r,'text/html');
1271: $r->send_http_header;
1272: my $symb=$ENV{'form.markread'};
1273: my $ressymb = $symb;
1274: my ($map,$ind,$url)=&Apache::lonnet::decode_symb($symb);
1275: unless ($ressymb =~ m|bulletin___\d+___adm/wrapper|) {
1276: $ressymb=~s|(bulletin___\d+___)|$1adm/wrapper|;
1.78 raeburn 1277: }
1.84 raeburn 1278: my %discinfo = ();
1279: my $lastkey = $ressymb.'_lastread';
1280: $discinfo{$lastkey} = time;
1281: &Apache::lonnet::put('nohist_'.$ENV{'request.course.id'}.'_discuss',\%discinfo,$ENV{'user.domain'},$ENV{'user.name'});
1282: &redirect_back($r,&Apache::lonnet::clutter($url),&mt('Changed reading status').'<br />','0','0');
1.78 raeburn 1283: return OK;
1284: } elsif (($ENV{'form.hide'}) || ($ENV{'form.unhide'})) {
1.15 www 1285: # ----------------------------------------------------------------- Hide/unhide
1.71 www 1286: &Apache::loncommon::content_type($r,'text/html');
1.15 www 1287: $r->send_http_header;
1288:
1289: my $entry=$ENV{'form.hide'}?$ENV{'form.hide'}:$ENV{'form.unhide'};
1290:
1291: my ($symb,$idx)=split(/\:\:\:/,$entry);
1.52 www 1292: my ($map,$ind,$url)=&Apache::lonnet::decode_symb($symb);
1.15 www 1293:
1294: my %contrib=&Apache::lonnet::restore($symb,$ENV{'request.course.id'},
1295: $ENV{'course.'.$ENV{'request.course.id'}.'.domain'},
1296: $ENV{'course.'.$ENV{'request.course.id'}.'.num'});
1297:
1298:
1299: my $currenthidden=$contrib{'hidden'};
1300:
1301: if ($ENV{'form.hide'}) {
1302: $currenthidden.='.'.$idx.'.';
1303: } else {
1304: $currenthidden=~s/\.$idx\.//g;
1305: }
1306: my %newhash=('hidden' => $currenthidden);
1.38 www 1307:
1308: &Apache::lonnet::store(\%newhash,$symb,$ENV{'request.course.id'},
1309: $ENV{'course.'.$ENV{'request.course.id'}.'.domain'},
1310: $ENV{'course.'.$ENV{'request.course.id'}.'.num'});
1311:
1312: &redirect_back($r,&Apache::lonnet::clutter($url),
1.80 raeburn 1313: &mt('Changed discussion status').'<br />','0','0','',$ENV{'form.previous'});
1.69 www 1314: } elsif (($ENV{'form.threadedon'}) || ($ENV{'form.threadedoff'})) {
1.72 albertel 1315: &Apache::loncommon::content_type($r,'text/html');
1316: $r->send_http_header;
1.69 www 1317: if ($ENV{'form.threadedon'}) {
1318: &Apache::lonnet::put('environment',{'threadeddiscussion' => 'on'});
1319: &Apache::lonnet::appenv('environment.threadeddiscussion' => 'on');
1320: } else {
1321: &Apache::lonnet::del('environment',['threadeddiscussion']);
1322: &Apache::lonnet::delenv('environment\.threadeddiscussion');
1.72 albertel 1323: }
1.69 www 1324: my $symb=$ENV{'form.threadedon'}?$ENV{'form.threadedon'}:$ENV{'form.threadedoff'};
1325: my ($map,$ind,$url)=&Apache::lonnet::decode_symb($symb);
1326: &redirect_back($r,&Apache::lonnet::clutter($url),
1.80 raeburn 1327: &mt('Changed discussion view mode').'<br />','0','0','',$ENV{'form.previous'});
1.38 www 1328: } elsif ($ENV{'form.deldisc'}) {
1329: # --------------------------------------------------------------- Hide for good
1.71 www 1330: &Apache::loncommon::content_type($r,'text/html');
1.38 www 1331: $r->send_http_header;
1332:
1333: my $entry=$ENV{'form.deldisc'};
1334:
1335: my ($symb,$idx)=split(/\:\:\:/,$entry);
1.52 www 1336: my ($map,$ind,$url)=&Apache::lonnet::decode_symb($symb);
1.38 www 1337:
1338: my %contrib=&Apache::lonnet::restore($symb,$ENV{'request.course.id'},
1339: $ENV{'course.'.$ENV{'request.course.id'}.'.domain'},
1340: $ENV{'course.'.$ENV{'request.course.id'}.'.num'});
1341:
1342:
1343: my $currentdeleted=$contrib{'deleted'};
1344:
1345: $currentdeleted.='.'.$idx.'.';
1346:
1347: my %newhash=('deleted' => $currentdeleted);
1.15 www 1348:
1349: &Apache::lonnet::store(\%newhash,$symb,$ENV{'request.course.id'},
1350: $ENV{'course.'.$ENV{'request.course.id'}.'.domain'},
1351: $ENV{'course.'.$ENV{'request.course.id'}.'.num'});
1352:
1.30 www 1353: &redirect_back($r,&Apache::lonnet::clutter($url),
1.80 raeburn 1354: &mt('Changed discussion status').'<br />','0','0','',$ENV{'form.previous'});
1.33 www 1355: } elsif ($ENV{'form.preview'}) {
1356: # -------------------------------------------------------- User wants a preview
1.76 albertel 1357: $r->content_type('text/html');
1358: $r->send_http_header;
1.33 www 1359: &show_preview($r);
1.15 www 1360: } else {
1361: # ------------------------------------------------------------- Normal feedback
1.6 albertel 1362: my $feedurl=$ENV{'form.postdata'};
1363: $feedurl=~s/^http\:\/\///;
1364: $feedurl=~s/^$ENV{'SERVER_NAME'}//;
1365: $feedurl=~s/^$ENV{'HTTP_HOST'}//;
1.62 www 1366: $feedurl=~s/\?.+$//;
1.8 www 1367:
1.66 www 1368: my $symb;
1369: if ($ENV{'form.replydisc'}) {
1370: $symb=(split(/\:\:\:/,$ENV{'form.replydisc'}))[0];
1371: my ($map,$id,$url)=&Apache::lonnet::decode_symb($symb);
1372: $feedurl=&Apache::lonnet::clutter($url);
1373: } else {
1374: $symb=&Apache::lonnet::symbread($feedurl);
1375: }
1.31 www 1376: unless ($symb) {
1377: $symb=$ENV{'form.symb'};
1378: if ($symb) {
1.52 www 1379: my ($map,$id,$url)=&Apache::lonnet::decode_symb($symb);
1.31 www 1380: $feedurl=&Apache::lonnet::clutter($url);
1381: }
1382: }
1.8 www 1383: my $goahead=1;
1384: if ($feedurl=~/\.(problem|exam|quiz|assess|survey|form)$/) {
1385: unless ($symb) { $goahead=0; }
1386: }
1.98 raeburn 1387: # backward compatibility (bulletin boards used to be 'wrapped')
1.73 albertel 1388: if ($feedurl=~m|^/adm/wrapper/adm/.*/bulletinboard$|) {
1389: $feedurl=~s|^/adm/wrapper||;
1390: }
1.8 www 1391: if ($goahead) {
1392: # Go ahead with feedback, no ambiguous reference
1.71 www 1393: &Apache::loncommon::content_type($r,'text/html');
1.8 www 1394: $r->send_http_header;
1.6 albertel 1395:
1.8 www 1396: if (
1.7 albertel 1397: (
1398: ($feedurl=~m:^/res:) && ($feedurl!~m:^/res/adm:)
1399: )
1400: ||
1401: ($ENV{'request.course.id'} && ($feedurl!~m:^/adm:))
1.31 www 1402: ||
1403: ($ENV{'request.course.id'} && ($symb=~/^bulletin\_\_\_/))
1.7 albertel 1404: ) {
1.6 albertel 1405: # --------------------------------------------------- Print login screen header
1406: unless ($ENV{'form.sendit'}) {
1407: my $options=&screen_header($feedurl);
1408: if ($options) {
1409: &mail_screen($r,$feedurl,$options);
1410: } else {
1411: &fail_redirect($r,$feedurl);
1412: }
1413: } else {
1414:
1415: # Get previous user input
1.9 albertel 1416: my $prevattempts=&Apache::loncommon::get_previous_attempt(
1.11 albertel 1417: $symb,$ENV{'user.name'},$ENV{'user.domain'},
1.9 albertel 1418: $ENV{'request.course.id'});
1.6 albertel 1419:
1420: # Get output from resource
1421: my $usersaw=&resource_output($feedurl);
1422:
1.50 albertel 1423: # Get resource answer (need to allow student to view grades for this to work)
1424: &Apache::lonnet::appenv(('allowed.vgr'=>'F'));
1.40 albertel 1425: my $useranswer=&Apache::loncommon::get_student_answers(
1426: $symb,$ENV{'user.name'},$ENV{'user.domain'},
1427: $ENV{'request.course.id'});
1.50 albertel 1428: &Apache::lonnet::delenv('allowed.vgr');
1.42 www 1429: # Get attachments, if any, and not too large
1430: my $attachmenturl='';
1431: if ($ENV{'form.attachment.filename'}) {
1432: unless (length($ENV{'form.attachment'})>131072) {
1.82 albertel 1433: $attachmenturl=&Apache::lonnet::userfileupload('attachment',undef,'feedback');
1.42 www 1434: }
1435: }
1.6 albertel 1436: # Filter HTML out of message (could be nasty)
1.39 www 1437: my $message=&clear_out_html($ENV{'form.comment'});
1.6 albertel 1438:
1439: # Assemble email
1.8 www 1440: my ($email,$citations)=&assemble_email($feedurl,$message,$prevattempts,
1.40 albertel 1441: $usersaw,$useranswer);
1442:
1.6 albertel 1443: # Who gets this?
1444: my ($typestyle,%to) = &decide_receiver($feedurl);
1445:
1446: # Actually send mail
1.43 www 1447: my ($status,$numsent)=&send_msg($feedurl,$email,$citations,
1448: $attachmenturl,%to);
1.13 www 1449:
1450: # Discussion? Store that.
1451:
1.32 albertel 1452: my $numpost=0;
1.13 www 1453: if ($ENV{'form.discuss'}) {
1.78 raeburn 1454: my $subject = &clear_out_html($ENV{'form.subject'});
1455: $typestyle.=&adddiscuss($symb,$message,0,$attachmenturl,$subject);
1.32 albertel 1456: $numpost++;
1.13 www 1457: }
1.6 albertel 1458:
1.14 www 1459: if ($ENV{'form.anondiscuss'}) {
1.78 raeburn 1460: my $subject = &clear_out_html($ENV{'form.subject'});
1461: $typestyle.=&adddiscuss($symb,$message,1,$attachmenturl,$subject);
1.32 albertel 1462: $numpost++;
1.14 www 1463: }
1464:
1465:
1.6 albertel 1466: # Receipt screen and redirect back to where came from
1.80 raeburn 1467: &redirect_back($r,$feedurl,$typestyle,$numsent,$numpost,$status,$ENV{'form.previous'});
1.6 albertel 1468:
1469: }
1.8 www 1470: } else {
1.7 albertel 1471: # Unable to give feedback
1.6 albertel 1472: &no_redirect_back($r,$feedurl);
1.8 www 1473: }
1474: } else {
1475: # Ambiguous Problem Resource
1.60 albertel 1476: if ( &Apache::lonnet::mod_perl_version() == 2 ) {
1.53 albertel 1477: &Apache::lonnet::cleanenv();
1.58 albertel 1478: }
1.53 albertel 1479: $r->internal_redirect('/adm/ambiguous');
1.6 albertel 1480: }
1.15 www 1481: }
1.6 albertel 1482: return OK;
1.1 www 1483: }
1484:
1485: 1;
1486: __END__
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>