--- loncom/interface/lonfeedback.pm 2004/04/28 21:13:13 1.78
+++ loncom/interface/lonfeedback.pm 2004/05/05 23:04:57 1.81
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Feedback
#
-# $Id: lonfeedback.pm,v 1.78 2004/04/28 21:13:13 raeburn Exp $
+# $Id: lonfeedback.pm,v 1.81 2004/05/05 23:04:57 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -56,28 +56,47 @@ sub list_discussion {
}
unless ($symb) { return ''; }
- my %dischash = &Apache::lonnet::restore($symb,$ENV{'request.course.id'}.'_discuss',$ENV{'user.domain'},$ENV{'user.name'});
- my %readids = ();
- my $showonlyunread;
- foreach my $key (keys %dischash) {
- if ($key eq 'showonlyunread') {
- $showonlyunread = $dischash{$key};
- } else {
- if ($dischash{$key} eq 'read') {
- $readids{$key} = 1;
- }
+# backward compatibility (bulletin boards used to be 'wrapped')
+ my $ressymb=$symb;
+ if ($mode eq 'board') {
+ unless ($ressymb =~ m|bulletin___\d+___adm/wrapper|) {
+ $ressymb=~s|(bulletin___\d+___)|$1adm/wrapper|;
}
}
+# Get discussion display settings for this discussion
+ my $lastkey = $ressymb.'_lastread';
+ my $showkey = $ressymb.'_showonlyunread';
+ my $visitkey = $ressymb.'_visit';
+ my %dischash = &Apache::lonnet::get('nohist_'.$ENV{'request.course.id'}.'_discuss',[$lastkey,$showkey,$visitkey],$ENV{'user.domain'},$ENV{'user.name'});
+ my $showonlyunread = 0;
+ my $prevread = 0;
+ my $previous = 0;
+ my $visit = 0;
+ my $newpostsflag = 0;
+
+# Retain identification of "NEW" posts identified in last display, if continuing 'previous' browsing of posts.
+ &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['previous']);
+ $previous = $ENV{'form.previous'};
+ if ($previous > 0) {
+ $prevread = $previous;
+ } elsif (defined($dischash{$lastkey})) {
+ $prevread = $dischash{$lastkey};
+ }
+
+ if (defined($dischash{$showkey})) {
+ $showonlyunread = $dischash{$showkey};
+ }
+
+ if (defined($dischash{$visitkey})) {
+ $visit = $dischash{$visitkey};
+ }
+ $visit ++;
+
my $seeid=&Apache::lonnet::allowed('rin',$crs);
my $viewgrades=(&Apache::lonnet::allowed('vgr',$crs)
&& ($symb=~/\.(problem|exam|quiz|assess|survey|form)$/));
my @discussionitems=();
- # backward compatibility (bulletin boards used to be 'wrapped')
- my $ressymb=$symb;
- if ($mode eq 'board') {
- $ressymb=~s|(bulletin___\d+___)|$1adm/wrapper|;
- }
my %contrib=&Apache::lonnet::restore($ressymb,$ENV{'request.course.id'},
$ENV{'course.'.$ENV{'request.course.id'}.'.domain'},
$ENV{'course.'.$ENV{'request.course.id'}.'.num'});
@@ -87,6 +106,7 @@ sub list_discussion {
my @index=();
my @replies=();
my %alldiscussion=();
+ my %notshown = ();
my $maxdepth=0;
my $target='';
@@ -94,9 +114,21 @@ sub list_discussion {
$ENV{'environment.remote'} eq 'off' ) {
$target='target="LONcom"';
}
+
+ my $now = time;
+ my %discinfo = ();
+ $discinfo{$visitkey} = $visit;
+ $discinfo{$lastkey} = $now;
+
+ &Apache::lonnet::put('nohist_'.$ENV{'request.course.id'}.'_discuss',\%discinfo,$ENV{'user.domain'},$ENV{'user.name'});
+
if ($contrib{'version'}) {
for (my $id=1;$id<=$contrib{'version'};$id++) {
my $idx=$id;
+ my $posttime = $contrib{$idx.':timestamp'};
+ if ($prevread > 0 && $prevread <= $posttime) {
+ $newpostsflag = 1;
+ }
my $hidden=($contrib{'hidden'}=~/\.$idx\./);
my $deleted=($contrib{'deleted'}=~/\.$idx\./);
my $origindex='0.';
@@ -160,13 +192,25 @@ sub list_discussion {
if ($seeid) {
if ($hidden) {
$sender.=' '.&mt('Make Visible').'';
+ $ressymb.':::'.$idx;
+ if ($newpostsflag) {
+ $sender .= '&previous='.$prevread;
+ }
+ $sender .= '">'.&mt('Make Visible').'';
} else {
$sender.=' '.&mt('Hide').'';
+ $ressymb.':::'.$idx;
+ if ($newpostsflag) {
+ $sender .= '&previous='.$prevread;
+ }
+ $sender .= '">'.&mt('Hide').'';
}
$sender.=' '.&mt('Delete').'';
+ $ressymb.':::'.$idx;
+ if ($newpostsflag) {
+ $sender .= '&previous='.$prevread;
+ }
+ $sender .= '">'.&mt('Delete').'';
}
} else {
if ($screenname) {
@@ -177,19 +221,13 @@ sub list_discussion {
$ENV{'request.course.id'}.
($ENV{'request.course.sec'}?'/'.$ENV{'request.course.sec'}:''))) {
$sender.=' '.&mt('Reply').'';
+ $ressymb.':::'.$idx;
+ if ($newpostsflag) {
+ $sender .= '&previous='.$prevread;
+ }
+ $sender .= '" '.$target.'>'.&mt('Reply').'';
}
my $vgrlink;
- my $ctlink;
- if ($readids{$idx} == 1) {
- $ctlink = ''.&mt('Mark unread').'? '.
- '';
- } else {
- $ctlink = ''.&mt('Mark read').'? '.
- '';
- }
if ($viewgrades) {
$vgrlink=&Apache::loncommon::submlink('Submissions',
$contrib{$idx.':sendername'},$contrib{$idx.':senderdomain'},$symb);
@@ -201,62 +239,77 @@ sub list_discussion {
}
$alldiscussion{$thisindex}=$idx;
$index[$idx]=$thisindex;
- $discussionitems[$idx]='
'.
- ''.$subject.' '.
- $sender.' '.$vgrlink.' ('.
- localtime($contrib{$idx.':timestamp'}).
- ') | '.$ctlink.' |
';
- if ($showonlyunread && $readids{$idx}) {
- $discussionitems[$idx] .= 'Check "Show all posts?" or "Mark unread?", then "Save read settings" to display message |
';
+ my $spansize = 2;
+ if ($showonlyunread && $prevread > $posttime) {
+ $notshown{$idx} = 1;
} else {
- $discussionitems[$idx] .= ''.$message.'
';
+ $discussionitems[$idx]='';
+ if ($prevread > 0 && $prevread <= $posttime) {
+ $discussionitems[$idx] .= 'NEW | ';
+ }
+ $discussionitems[$idx] .= ' '.
+ ''.$subject.' '.
+ $sender.' '.$vgrlink.' ('.
+ localtime($posttime).') |
'.
+ '
'.$message.'
';
}
}
}
}
}
+
my $discussion='';
if ($visible) {
-# Print a the discusssion
- $discussion .= '';
+ }
+ $discussion.='
';
}
if ($discussiononly) {
$discussion.=(</g;
$quote=''.&Apache::lontexconvert::msgtexconverted($message).'
';
- $subject = 'Re: '.$contrib{$idx.':subject'};
+ if ($idx > 0) {
+ $subject = 'Re: '.$contrib{$idx.':subject'};
+ }
+ }
+ if ($ENV{'form.previous'}) {
+ $prevtag = '';
}
}
my $latexHelp = Apache::loncommon::helpLatexCheatsheet();
@@ -364,6 +423,7 @@ $bodytag
$title