--- loncom/interface/lonfeedback.pm 2004/07/21 23:57:24 1.101 +++ loncom/interface/lonfeedback.pm 2004/07/27 23:35:34 1.107 @@ -1,7 +1,7 @@ # The LearningOnline Network # Feedback # -# $Id: lonfeedback.pm,v 1.101 2004/07/21 23:57:24 raeburn Exp $ +# $Id: lonfeedback.pm,v 1.107 2004/07/27 23:35:34 www Exp $ # # Copyright Michigan State University Board of Trustees # @@ -36,6 +36,7 @@ use Apache::loncommon(); use Apache::lontexconvert(); use Apache::lonlocal; # must not have () use Apache::lonhtmlcommon(); +use Apache::lonspeller(); sub discussion_open { my ($status)=@_; @@ -222,8 +223,10 @@ sub list_discussion { $newpostsflag = 1; } my $hidden=($contrib{'hidden'}=~/\.$idx\./); + my $studenthidden=($contrib{'studenthidden'}=~/\.$idx\./); my $deleted=($contrib{'deleted'}=~/\.$idx\./); my $origindex='0.'; + my $numoldver=0; if ($contrib{$idx.':replyto'}) { if ( (($ENV{'environment.threadeddiscussion'}) && (($sortposts eq '') || ($sortposts eq 'ascdate'))) || ($sortposts eq 'thread')) { # this is a follow-up message @@ -247,13 +250,21 @@ sub list_discussion { } unless ((($hidden) && (!$seeid)) || ($deleted)) { $visible++; + if ($contrib{$idx.':history'}) { + if ($contrib{$idx.':history'} =~ /:/) { + my @oldversions = split/:/,$contrib{$idx.':history'}; + $numoldver = @oldversions; + } else { + $numoldver = 1; + } + } my $message=$contrib{$idx.':message'}; $message=~s/\n/\
/g; - $message=&Apache::lontexconvert::msgtexconverted($message); + $message=&Apache::lontexconvert::msgtexconverted($message,undef,$numoldver); my $subject=$contrib{$idx.':subject'}; if (defined($subject)) { $subject=~s/\n/\
/g; - $subject=&Apache::lontexconvert::msgtexconverted($subject); + $subject=&Apache::lontexconvert::msgtexconverted($subject,undef,$numoldver); } if ($contrib{$idx.':attachmenturl'}) { my ($fname) @@ -267,6 +278,9 @@ sub list_discussion { if ($message) { if ($hidden) { $message=''.$message.''; + if ($studenthidden) { + $message .='

Deleted by poster (student).'; + } } my $screenname=&Apache::loncommon::screenname( $contrib{$idx.':sendername'}, @@ -329,14 +343,29 @@ sub list_discussion { } else { @{$namesort{$lastname}{$firstname}} = ("$idx"); } - if ($seeid) { - if ($hidden) { - $sender.=' '; + $sender .= '" '.$target.'>'.&mt('Edit').''; unless ($seeid) { + $sender.=" '; + } + } + } + if ($seeid) { + if ($hidden) { + unless ($studenthidden) { + $sender.=' '.&mt('Make Visible').''; + } } else { $sender.=' '.&mt('Hide').''; } $sender.=' - '.&Apache::lonlocal::locallocaltime($postversions[$i]).' '; + } + $discussionitems[$idx] .= '
'; + } } } } @@ -520,6 +563,20 @@ sub list_discussion { # Print the discusssion if ($outputtarget ne 'tex') { my $colspan=$maxdepth+1; + $discussion.= qq| + + |; $discussion.=''; $discussion .='
'. ''; @@ -634,7 +691,7 @@ sub list_discussion { $threadinsert='
Reply: '.$thisdepth.''; } $discussionitems[$alldiscussion{$_}]=~s/<\/td>]*)>/$threadinsert<\/td>
/; - $discussionitems[$alldiscussion{$_}]=~s/]+)>(Hide|Delete|Reply|Submissions)<\/a>//g; + $discussionitems[$alldiscussion{$_}]=~s/]+)>(Edit|Hide|Delete|Reply|Submissions)<\/a>//g; $discussionitems[$alldiscussion{$_}]=~s/(|<\/b>|<\/a>|]+)>)//g; #FIXME xmlparse can't be safely called from inside xmlparse @@ -722,23 +779,84 @@ ENDDISCUSS sub mail_screen { my ($r,$feedurl,$options) = @_; my $bodytag=&Apache::loncommon::bodytag('Resource Feedback and Discussion', - '','onLoad="window.focus();"'); + '','onLoad="window.focus();setposttype();"'); my $title=&Apache::lonnet::gettitle($feedurl); if (!$title) { $title = $feedurl; } my $quote=''; my $subject = ''; + my $oldmessage = ''; my $prevtag = ''; - if ($ENV{'form.replydisc'}) { - my ($symb,$idx)=split(/\:\:\:/,$ENV{'form.replydisc'}); + my $parentmsg = ''; + my $anonscript = (</g; - $quote='
'.&Apache::lontexconvert::msgtexconverted($message).'
'; - if ($idx > 0) { - $subject = 'Re: '.$contrib{$idx.':subject'}; + if ($ENV{'form.replydisc'}) { + my $numoldver = 0; + if ($contrib{$idx.':history'}) { + if ($contrib{$idx.':history'} =~ /:/) { + my @oldversions = split/:/,$contrib{$idx.':history'}; + $numoldver = @oldversions; + } else { + $numoldver = 1; + } + } + my $message=$contrib{$idx.':message'}; + $message=~s/\n/\
/g; + $quote='
'.&Apache::lontexconvert::msgtexconverted($message,undef,$numoldver).'
'; + if ($idx > 0) { + if ($contrib{'subject'} =~ /::::\d+::::(.+)$/si) { + $subject = $1; + } else { + $subject = $contrib{$idx.':subject'}; + } + $subject = 'Re: '.$subject; + } + } else { + if ($contrib{$idx.':message'} =~ /::::\d+::::(.+)$/si) { + $oldmessage = $1; + } else { + $oldmessage = $contrib{$idx.':message'}; + } + $oldmessage=&HTML::Entities::encode($oldmessage,'<>&"'); + if ($contrib{$idx.':subject'} =~ /::::\d+::::(.+)$/si) { + $subject = $1; + } else { + $subject = $contrib{$idx.':subject'}; + } + if (defined($contrib{$idx.':replyto'})) { + $parentmsg = $contrib{$idx.':replyto'}; + } + my $anonflag = 0; + if ($contrib{$idx.':anonymous'}) { + $anonflag = 1; + } + $anonscript = (<print(<print(< The LearningOnline Network with CAPA @@ -795,12 +908,15 @@ $htmlheader } if (rec) { - $onsubmit + if (typeof(document.mailform.onsubmit)!='undefined') { + document.mailform.onsubmit(); + } document.mailform.submit(); } else { alert('Please check a feedback type.'); } } + $anonscript //--> @@ -810,7 +926,18 @@ $bodytag enctype="multipart/form-data"> $prevtag +END + if ($ENV{'form.replydisc'}) { + $r->print(< +END + } elsif ($ENV{'form.editdisc'}) { + $r->print(< + +END + } + $r->print(< $quote @@ -819,7 +946,7 @@ $quote $latexHelp Title:

-

Attachment (128 KB max size): @@ -1118,6 +1245,9 @@ sub print_showposters { } } my $crs='/'.$ENV{'request.course.id'}; + if ($ENV{'request.course.sec'}) { + $crs.='_'.$ENV{'request.course.sec'}; + } $crs=~s/\_/\//g; my $seeid=&Apache::lonnet::allowed('rin',$crs); my %contrib=&Apache::lonnet::restore($ressymb,$ENV{'request.course.id'}, @@ -1298,6 +1428,7 @@ ENDREDIR sub no_redirect_back { my ($r,$feedurl) = @_; + my $nofeed=&mt('Sorry, no feedback possible on this resource ...'); $r->print (< Feedback not sent @@ -1312,7 +1443,7 @@ ENDNOREDIR -Sorry, no feedback possible on this resource ... +$nofeed ENDNOREDIRTWO @@ -1322,7 +1453,7 @@ sub screen_header { my ($feedurl) = @_; my $msgoptions=''; my $discussoptions=''; - unless ($ENV{'form.replydisc'}) { + unless (($ENV{'form.replydisc'}) || ($ENV{'form.editdisc'})) { if (($feedurl=~/^\/res\//) && ($feedurl!~/^\/res\/adm/)) { $msgoptions= '

'. @@ -1379,25 +1510,25 @@ sub resource_output { sub clear_out_html { my ($message,$override)=@_; unless (&Apache::lonhtmlcommon::htmlareablocked()) { return $message; } +# Always allow the -tag + my %html=(M=>1); +# Check if more is allowed my $cid=$ENV{'request.course.id'}; if (($ENV{"course.$cid.allow_limited_html_in_feedback"} =~ m/yes/i) || ($override)) { # allows


      • #

        # - my %html=(B=>1, I=>1, P=>1, A=>1, LI=>1, OL=>1, UL=>1, EM=>1, - BR=>1, TT=>1, STRONG=>1, BLOCKQUOTE=>1, DIV=>1, IMG=>1, - M=>1, SUB=>1, SUP=>1, SPAN=>1, - H1=>1, H2=>1, H3=>1, H4=>1, H5=>1); - - $message =~ s/\<(\/?\s*(\w+)[^\>\<]*)/ + %html=(B=>1, I=>1, P=>1, A=>1, LI=>1, OL=>1, UL=>1, EM=>1, + BR=>1, TT=>1, STRONG=>1, BLOCKQUOTE=>1, DIV=>1, IMG=>1, + M=>1, SUB=>1, SUP=>1, SPAN=>1, + H1=>1, H2=>1, H3=>1, H4=>1, H5=>1); + } +# Do the substitution of everything that is not explicitly allowed + $message =~ s/\<(\/?\s*(\w+)[^\>\<]*)/ {($html{uc($2)}&&(length($1)<1000))?"\<$1":"\<$1"}/ge; - $message =~ s/(\]*)\>/ + $message =~ s/(\]*)\>/ {($html{uc($2)}&&(length($1)<1000))?"$1\>":"$1\>"}/ge; - } else { - $message=~s/\/\>\;/g; - } return $message; } @@ -1543,10 +1674,52 @@ sub adddiscuss { $contrib{'anonymous'}='true'; } if (($symb) && ($email)) { - $status='Adding to class discussion'.($anon?' (anonymous)':'').': '. - &Apache::lonnet::store(\%contrib,$symb,$ENV{'request.course.id'}, + if ($ENV{'form.editdisc'}) { + my %newcontrib = (); + $contrib{'ip'}=$ENV{'REMOTE_ADDR'}; + $contrib{'host'}=$Apache::lonnet::perlvar{'lonHostID'}; + $contrib{'timestamp'} = time; + $contrib{'history'} = ''; + my $numoldver = 0; + my ($oldsymb,$oldidx)=split(/\:\:\:/,$ENV{'form.editdisc'}); +# get timestamp for last post and history + my %oldcontrib=&Apache::lonnet::restore($oldsymb,$ENV{'request.course.id'}, + $ENV{'course.'.$ENV{'request.course.id'}.'.domain'}, + $ENV{'course.'.$ENV{'request.course.id'}.'.num'}); + if (defined($oldcontrib{$oldidx.':replyto'})) { + $contrib{'replyto'} = $oldcontrib{$oldidx.':replyto'}; + } + if (defined($oldcontrib{$oldidx.':history'})) { + if ($oldcontrib{$oldidx.':history'} =~ /:/) { + my @oldversions = split/:/,$oldcontrib{$oldidx.':history'}; + $numoldver = @oldversions; + } else { + $numoldver = 1; + } + $contrib{'history'} = $oldcontrib{$oldidx.':history'}.':'; + } + if (defined($oldcontrib{$oldidx.':subject'})) { + $contrib{'subject'} = $oldcontrib{$oldidx.':subject'}.'::::'.$numoldver.'::::'.$contrib{'subject'}; + } + if (defined($oldcontrib{$oldidx.':message'})) { + $contrib{'message'} = $oldcontrib{$oldidx.':message'}.'::::'.$numoldver.'::::'.$contrib{'message'}; + } + $contrib{'history'} .= $oldcontrib{$oldidx.':timestamp'}; + foreach (keys %contrib) { + my $key = $oldidx.':'.&Apache::lonnet::escape($oldsymb).':'.$_; + $newcontrib{$key} = $contrib{$_}; + } + my $put_reply = &Apache::lonnet::putstore($ENV{'request.course.id'}, + \%newcontrib, + $ENV{'course.'.$ENV{'request.course.id'}.'.domain'}, + $ENV{'course.'.$ENV{'request.course.id'}.'.num'}); + $status='Editing class discussion'.($anon?' (anonymous)':''); + } else { + $status='Adding to class discussion'.($anon?' (anonymous)':'').': '. + &Apache::lonnet::store(\%contrib,$symb,$ENV{'request.course.id'}, $ENV{'course.'.$ENV{'request.course.id'}.'.domain'}, $ENV{'course.'.$ENV{'request.course.id'}.'.num'}); + } my %storenewentry=($symb => time); $status.='
        '.&mt('Updating discussion time').': '. &Apache::lonnet::put('discussiontimes',\%storenewentry, @@ -1574,6 +1747,7 @@ sub show_preview { my $r=shift; my $message=&clear_out_html($ENV{'form.comment'}); $message=~s/\n/\
        /g; + $message=&Apache::lonspeller::markeduptext($message); $message=&Apache::lontexconvert::msgtexconverted($message); my $subject=&clear_out_html($ENV{'form.subject'}); $subject=~s/\n/\
        /g; @@ -1584,13 +1758,13 @@ sub show_preview { } sub generate_preview_button { - my $pre=&mt("Show Preview"); + my $pre=&mt("Show Preview and Check Spelling"); return(< +onClick="if (typeof(document.mailform.onsubmit)!='undefined') {document.mailform.onsubmit();};this.form.comment.value=document.mailform.comment.value;this.form.subject.value=document.mailform.subject.value;this.form.submit();" /> ENDPREVIEW } @@ -1606,7 +1780,7 @@ sub handler { # --------------------------- Get query string for limited number of parameters &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'}, - ['hide','unhide','deldisc','postdata','preview','replydisc','threadedon','threadedoff','onlyunread','allposts','previous','markread','markonread','markondisp','modifydisp','changes','navmaps','navurl','sortfilter','sortposts','applysort','rolefilter','statusfilter','sectionpick','posterlist','userpick']); + ['hide','unhide','deldisc','postdata','preview','replydisc','editdisc','threadedon','threadedoff','onlyunread','allposts','previous','markread','markonread','markondisp','modifydisp','changes','navmaps','navurl','sortfilter','sortposts','applysort','rolefilter','statusfilter','sectionpick','posterlist','userpick']); if ($ENV{'form.posterlist'}) { &Apache::loncommon::content_type($r,'text/html'); $r->send_http_header; @@ -1826,13 +2000,27 @@ ENDREDIR my $currenthidden=$contrib{'hidden'}; + my $currentstudenthidden=$contrib{'studenthidden'}; + + my $crs='/'.$ENV{'request.course.id'}; + if ($ENV{'request.course.sec'}) { + $crs.='_'.$ENV{'request.course.sec'}; + } + $crs=~s/\_/\//g; + my $seeid=&Apache::lonnet::allowed('rin',$crs); if ($ENV{'form.hide'}) { $currenthidden.='.'.$idx.'.'; + unless ($seeid) { + $currentstudenthidden.='.'.$idx.'.'; + } } else { $currenthidden=~s/\.$idx\.//g; } my %newhash=('hidden' => $currenthidden); + if ( ($ENV{'form.hide'}) && (!$seeid) ) { + $newhash{'studenthidden'} = $currentstudenthidden; + } &Apache::lonnet::store(\%newhash,$symb,$ENV{'request.course.id'}, $ENV{'course.'.$ENV{'request.course.id'}.'.domain'}, @@ -1899,6 +2087,10 @@ ENDREDIR $symb=(split(/\:\:\:/,$ENV{'form.replydisc'}))[0]; my ($map,$id,$url)=&Apache::lonnet::decode_symb($symb); $feedurl=&Apache::lonnet::clutter($url); + } elsif ($ENV{'form.editdisc'}) { + $symb=(split(/\:\:\:/,$ENV{'form.editdisc'}))[0]; + my ($map,$id,$url)=&Apache::lonnet::decode_symb($symb); + $feedurl=&Apache::lonnet::clutter($url); } else { $symb=&Apache::lonnet::symbread($feedurl); }