--- loncom/interface/lonfeedback.pm 2004/07/23 19:58:40 1.104
+++ loncom/interface/lonfeedback.pm 2004/11/15 21:51:19 1.134
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Feedback
#
-# $Id: lonfeedback.pm,v 1.104 2004/07/23 19:58:40 albertel Exp $
+# $Id: lonfeedback.pm,v 1.134 2004/11/15 21:51:19 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -36,15 +36,20 @@ use Apache::loncommon();
use Apache::lontexconvert();
use Apache::lonlocal; # must not have ()
use Apache::lonhtmlcommon();
+use Apache::lonnavmaps;
+use Apache::lonenc();
+use HTML::LCParser();
+use Apache::lonspeller();
+use Cwd;
sub discussion_open {
- my ($status)=@_;
+ my ($status,$symb)=@_;
if (defined($status) &&
!($status eq 'CAN_ANSWER' || $status eq 'CANNOT_ANSWER'
|| $status eq 'OPEN')) {
return 0;
}
- my $close=&Apache::lonnet::EXT('resource.0.discussend');
+ my $close=&Apache::lonnet::EXT('resource.0.discussend',$symb);
if (defined($close) && $close ne '' && $close < time) {
return 0;
}
@@ -56,16 +61,20 @@ sub discussion_visible {
if (not &discussion_open($status)) {
my $hidden=&Apache::lonnet::EXT('resource.0.discusshide');
if (lc($hidden) eq 'yes' or $hidden eq '' or !defined($hidden)) {
- return 0;
+ if (!$ENV{'request.role.adv'}) { return 0; }
}
}
return 1;
}
sub list_discussion {
- my ($mode,$status,$symb)=@_;
-
+ my ($mode,$status,$ressymb)=@_;
my $outputtarget=$ENV{'form.grade_target'};
+ if (defined($ENV{'form.export'})) {
+ if($ENV{'form.export'}) {
+ $outputtarget = 'export';
+ }
+ }
if (not &discussion_visible($status)) { return ''; }
my @bgcols = ("#cccccc","#eeeeee");
my $discussiononly=0;
@@ -77,30 +86,31 @@ sub list_discussion {
$crs.='_'.$ENV{'request.course.sec'};
}
$crs=~s/\_/\//g;
- unless ($symb) {
- $symb=&Apache::lonnet::symbread();
- }
- unless ($symb) { return ''; }
+ unless ($ressymb) { $ressymb=&Apache::lonnet::symbread(); }
+ unless ($ressymb) { return ''; }
+ $ressymb=&wrap_symb($ressymb);
+ my $encsymb=&Apache::lonenc::check_encrypt($ressymb);
+ my $viewgrades=(&Apache::lonnet::allowed('vgr',$crs)
+ && ($ressymb=~/\.(problem|exam|quiz|assess|survey|form)$/));
+
my %usernamesort = ();
my %namesort =();
my %subjectsort = ();
-# 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 $markkey = $ressymb.'_showonlyunmark',
my $visitkey = $ressymb.'_visit';
my $ondispkey = $ressymb.'_markondisp';
my $userpickkey = $ressymb.'_userpick';
- my %dischash = &Apache::lonnet::get('nohist_'.$ENV{'request.course.id'}.'_discuss',[$lastkey,$showkey,$visitkey,$ondispkey,$userpickkey],$ENV{'user.domain'},$ENV{'user.name'});
+ my $toggkey = $ressymb.'_readtoggle';
+ my $readkey = $ressymb.'_read';
+
+ my %dischash = &Apache::lonnet::get('nohist_'.$ENV{'request.course.id'}.'_discuss',[$lastkey,$showkey,$markkey,$visitkey,$ondispkey,$userpickkey,$toggkey,$readkey],$ENV{'user.domain'},$ENV{'user.name'});
my %discinfo = ();
my $showonlyunread = 0;
+ my $showunmark = 0;
my $markondisp = 0;
my $prevread = 0;
my $previous = 0;
@@ -111,7 +121,6 @@ sub list_discussion {
# Retain identification of "NEW" posts identified in last display, if continuing 'previous' browsing of posts.
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['previous','sortposts','rolefilter','statusfilter','sectionpick','totposters']);
my $sortposts = $ENV{'form.sortposts'};
- my $rolefilter = $ENV{'form.rolefilter'};
my $statusfilter = $ENV{'form.statusfilter'};
my $sectionpick = $ENV{'form.sectionpick'};
my $totposters = $ENV{'form.totposters'};
@@ -123,11 +132,12 @@ sub list_discussion {
$prevread = $dischash{$lastkey};
}
}
+ &Apache::lonnet::logthis("\n last read r symb ".$lastkey);
-# Get information about students and non-stundents in course for filtering display of posts
+# Get information about students and non-students in course for filtering display of posts
my %roleshash = ();
my %roleinfo = ();
- if ($rolefilter) {
+ if ($ENV{'form.rolefilter'}) {
%roleshash = &Apache::lonnet::dump('nohist_userroles',$ENV{'course.'.$ENV{'request.course.id'}.'.domain'},$ENV{'course.'.$ENV{'request.course.id'}.'.num'});
foreach (keys %roleshash) {
my ($role,$uname,$udom,$sec) = split/:/,$_;
@@ -153,48 +163,54 @@ sub list_discussion {
}
# Get discussion display default settings for user
- my %userenv = &Apache::lonnet::get('environment',['discdisplay','discmarkread'],$ENV{'user.domain'},$ENV{'user.name'});
- my $discdisplay=$userenv{'discdisplay'};
- if ($discdisplay eq 'unread') {
+ if ($ENV{'environment.discdisplay'} eq 'unread') {
$showonlyunread = 1;
}
- my $discmarkread=$userenv{'discmarkread'};
- if ($discmarkread eq 'ondisp') {
+ if ($ENV{'environment.discmarkread'} eq 'ondisp') {
$markondisp = 1;
}
# Override user's default if user specified display setting for this discussion
if (defined($dischash{$ondispkey})) {
- $markondisp = $dischash{$ondispkey};
+ unless ($dischash{$ondispkey} eq '') {
+ $markondisp = $dischash{$ondispkey};
+ }
}
if ($markondisp) {
$discinfo{$lastkey} = time;
}
if (defined($dischash{$showkey})) {
- $showonlyunread = $dischash{$showkey};
+ unless ($dischash{$showkey} eq '') {
+ $showonlyunread = $dischash{$showkey};
+ }
+ }
+
+ if (defined($dischash{$markkey})) {
+ unless ($dischash{$markkey} eq '') {
+ $showunmark = $dischash{$markkey};
+ }
}
if (defined($dischash{$visitkey})) {
- $visit = $dischash{$visitkey};
+ unless ($dischash{$visitkey} eq '') {
+ $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=();
my %shown = ();
my @posteridentity=();
- my %contrib=&Apache::lonnet::restore($ressymb,$ENV{'request.course.id'},
- $ENV{'course.'.$ENV{'request.course.id'}.'.domain'},
- $ENV{'course.'.$ENV{'request.course.id'}.'.num'});
+
+ my $current=0;
my $visible=0;
my @depth=();
- my @original=();
- my @index=();
- my @replies=();
+ my @replies = ();
my %alldiscussion=();
+ my %imsitems=();
+ my %imsfiles=();
my %notshown = ();
my %newitem = ();
my $maxdepth=0;
@@ -204,317 +220,19 @@ sub list_discussion {
$ENV{'environment.remote'} eq 'off' ) {
$target='target="LONcom"';
}
-
+
my $now = time;
$discinfo{$visitkey} = $visit;
&Apache::lonnet::put('nohist_'.$ENV{'request.course.id'}.'_discuss',\%discinfo,$ENV{'user.domain'},$ENV{'user.name'});
-
- if ($contrib{'version'}) {
- my $oldest = $contrib{'1:timestamp'};
- if ($prevread eq '0') {
- $prevread = $oldest-1;
- }
- for (my $id=1;$id<=$contrib{'version'};$id++) {
- my $idx=$id;
- my $posttime = $contrib{$idx.':timestamp'};
- if ($prevread <= $posttime) {
- $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
- $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 {
- $original[$idx]=0;
- $depth[$idx]=0;
- }
- } 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++;
- 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,undef,$numoldver);
- my $subject=$contrib{$idx.':subject'};
- if (defined($subject)) {
- $subject=~s/\n/\
/g;
- $subject=&Apache::lontexconvert::msgtexconverted($subject,undef,$numoldver);
- }
- if ($contrib{$idx.':attachmenturl'}) {
- my ($fname)
- =($contrib{$idx.':attachmenturl'}=~m|/([^/]+)$|);
- &Apache::lonnet::allowuploaded('/adm/feedback',
- $contrib{$idx.':attachmenturl'});
- $message.='
'.&mt('Attachment'). - ': '. - $fname.'
'; - } - if ($message) { - if ($hidden) { - $message=''.$message.''; - if ($studenthidden) { - $message .='NEW | '; - } else { - $newitem{$idx} = 0; - $discussionitems[$idx] .= ' -
'; - } - $discussionitems[$idx] .= ' | '. - ''.$subject.' '. - $sender.' '.$vgrlink.' ('. - localtime($posttime).') |
'.$message.''; - if ($contrib{$idx.':history'}) { - my @postversions = (); - $discussionitems[$idx] .= '