[LON-CAPA-cvs] cvs: loncom /interface lonfeedback.pm
www
lon-capa-cvs@mail.lon-capa.org
Fri, 07 Nov 2003 16:37:23 -0000
www Fri Nov 7 11:37:23 2003 EDT
Modified files:
/loncom/interface lonfeedback.pm
Log:
Saving my work on threaded discussions.
Index: loncom/interface/lonfeedback.pm
diff -u loncom/interface/lonfeedback.pm:1.67 loncom/interface/lonfeedback.pm:1.68
--- loncom/interface/lonfeedback.pm:1.67 Mon Nov 3 22:32:55 2003
+++ loncom/interface/lonfeedback.pm Fri Nov 7 11:37:23 2003
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Feedback
#
-# $Id: lonfeedback.pm,v 1.67 2003/11/04 03:32:55 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,40 @@
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'};
@@ -142,7 +166,15 @@
$vgrlink=&Apache::loncommon::submlink('Submissions',
$contrib{$idx.':sendername'},$contrib{$idx.':senderdomain'},$symb);
}
- $discussionitems{$idx}='<p><b>'.$sender.'</b> '.$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]='<p><b>'.$sender.'</b> '.$vgrlink.' ('.
localtime($contrib{$idx.':timestamp'}).
'):<blockquote>'.$message.
'</blockquote></p>';
@@ -153,8 +185,8 @@
my $discussion='';
if ($visible) {
$discussion.='<table bgcolor="#AAAAAA" cellpadding="2" cellspacing="2" border="0">';
- foreach (sort { $a <=> $b } keys %discussionitems) {
- $discussion.="\n<tr bgcolor='#CCCCCC'><td>".$discussionitems{$_}.
+ foreach (sort { $a <=> $b } keys %alldiscussion) {
+ $discussion.="\n<tr bgcolor='#CCCCCC'><td>".$discussionitems[$alldiscussion{$_}].
"</td></tr>";
}
$discussion.='</table>';
@@ -241,6 +273,7 @@
<form action="/adm/feedback" method="post" name="mailform"
enctype="multipart/form-data">
<input type="hidden" name="postdata" value="$feedurl" />
+<input type="hidden" name="replydisc" value="$ENV{'form.replydisc'}" />
Please check at least one of the following feedback types:
$options<hr />
<p>My question/comment/feedback:</p>