--- loncom/interface/lonfeedback.pm 2003/11/03 20:34:54 1.65 +++ loncom/interface/lonfeedback.pm 2003/11/07 16:37:23 1.68 @@ -1,7 +1,7 @@ # The LearningOnline Network # Feedback # -# $Id: lonfeedback.pm,v 1.65 2003/11/03 20:34:54 www Exp $ +# $Id: lonfeedback.pm,v 1.68 2003/11/07 16:37:23 www Exp $ # # Copyright Michigan State University Board of Trustees # @@ -69,16 +69,42 @@ sub list_discussion { unless ($symb) { return ''; } my $seeid=&Apache::lonnet::allowed('rin',$crs); my $viewgrades=&Apache::lonnet::allowed('vgr',$crs); - my %discussionitems=(); + my @discussionitems=(); my %contrib=&Apache::lonnet::restore($symb,$ENV{'request.course.id'}, $ENV{'course.'.$ENV{'request.course.id'}.'.domain'}, $ENV{'course.'.$ENV{'request.course.id'}.'.num'}); + my $visible=0; + my @depth=(); + my @original=(); + my @index=(); + my @replies=(); + my %alldiscussion=(); + my $maxdepth=0; + if ($contrib{'version'}) { for (my $id=1;$id<=$contrib{'version'};$id++) { my $idx=$id; my $hidden=($contrib{'hidden'}=~/\.$idx\./); my $deleted=($contrib{'deleted'}=~/\.$idx\./); + my $origindex='0.'; + if ($contrib{$idx.':replyto'}) { +# this is a follow-up message + $original[$idx]=$original[$contrib{$idx.':replyto'}]; + $depth[$idx]=$depth[$contrib{$idx.':replyto'}]+1; + $origindex=$index[$contrib{$idx.':replyto'}]; + if ($depth[$idx]>$maxdepth) { $maxdepth=$depth[$idx]; } + } else { +# this is an original message + $original[$idx]=0; + $depth[$idx]=0; + } + if ($replies[$depth[$idx]]) { + $replies[$depth[$idx]]++; + } else { + $replies[$depth[$idx]]=1; + } unless ((($hidden) && (!$seeid)) || ($deleted)) { + $visible++; my $message=$contrib{$idx.':message'}; $message=~s/\n/\
/g; $message=&Apache::lontexconvert::msgtexconverted($message); @@ -140,7 +166,15 @@ sub list_discussion { $vgrlink=&Apache::loncommon::submlink('Submissions', $contrib{$idx.':sendername'},$contrib{$idx.':senderdomain'},$symb); } - $discussionitems{$idx}='

'.$sender.' '.$vgrlink.' ('. +#figure out at what position this needs to print + my $thisindex=$idx; +# if ($ENV{'request.discussions.threaded'}) { + if (1) { + $thisindex=$origindex.substr('00'.$replies[$depth[$idx]],-2,2); + } + $alldiscussion{$thisindex}=$idx; + $index[$idx]=$thisindex; + $discussionitems[$idx]='

'.$sender.' '.$vgrlink.' ('. localtime($contrib{$idx.':timestamp'}). '):

'.$message. '

'; @@ -148,9 +182,14 @@ sub list_discussion { } } } - my $discussion='
'; - foreach (sort { $a <=> $b } keys %discussionitems) { - $discussion.=$discussionitems{$_}; + my $discussion=''; + if ($visible) { + $discussion.=''; + foreach (sort { $a <=> $b } keys %alldiscussion) { + $discussion.="\n"; + } + $discussion.='
".$discussionitems[$alldiscussion{$_}]. + "
'; } if ($discussiononly) { $discussion.=(< + Please check at least one of the following feedback types: $options

My question/comment/feedback:

@@ -524,7 +564,7 @@ sub adddiscuss { $ENV{'enrironment.generation'}, 'attachmenturl'=> $attachmenturl); if ($ENV{'form.replydisc'}) { - $contrib{'replyto'}=$ENV{'form.replydisc'}; + $contrib{'replyto'}=(split(/\:\:\:/,$ENV{'form.replydisc'}))[1]; } if ($anon) { $contrib{'anonymous'}='true'; @@ -657,7 +697,14 @@ sub handler { $feedurl=~s/^$ENV{'HTTP_HOST'}//; $feedurl=~s/\?.+$//; - my $symb=&Apache::lonnet::symbread($feedurl); + my $symb; + if ($ENV{'form.replydisc'}) { + $symb=(split(/\:\:\:/,$ENV{'form.replydisc'}))[0]; + my ($map,$id,$url)=&Apache::lonnet::decode_symb($symb); + $feedurl=&Apache::lonnet::clutter($url); + } else { + $symb=&Apache::lonnet::symbread($feedurl); + } unless ($symb) { $symb=$ENV{'form.symb'}; if ($symb) {