--- loncom/interface/lonfeedback.pm 2006/11/30 04:05:47 1.224
+++ loncom/interface/lonfeedback.pm 2012/03/07 00:02:10 1.337
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Feedback
#
-# $Id: lonfeedback.pm,v 1.224 2006/11/30 04:05:47 raeburn Exp $
+# $Id: lonfeedback.pm,v 1.337 2012/03/07 00:02:10 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -41,21 +41,30 @@ use Apache::lonnavmaps;
use Apache::lonenc();
use Apache::lonrss();
use HTML::LCParser();
+#use HTML::Tidy::libXML;
use Apache::lonspeller();
use Apache::longroup;
use Cwd;
-use lib '/home/httpd/lib/perl/';
use LONCAPA;
sub discussion_open {
my ($status,$symb)=@_;
+# Advanced roles can always discuss
if ($env{'request.role.adv'}) { return 1; }
+# Get discussion closing date
+ my $close=&Apache::lonnet::EXT('resource.0.discussend',$symb);
+# If it is defined and in the future, the instructor wants this discussion to be open
+ if (defined($close) && $close ne '' && $close > time) {
+ return 1;
+ }
+# It was not explicitly open, check if the problem is available.
+# If the problem is not available, close the discussion
if (defined($status) &&
!($status eq 'CAN_ANSWER' || $status eq 'CANNOT_ANSWER'
|| $status eq 'OPEN')) {
return 0;
}
- my $close=&Apache::lonnet::EXT('resource.0.discussend',$symb);
+# The problem is available, but check if the instructor explictly closed discussion
if (defined($close) && $close ne '' && $close < time) {
return 0;
}
@@ -75,6 +84,9 @@ sub discussion_visible {
sub list_discussion {
my ($mode,$status,$ressymb,$imsextras,$group)=@_;
+ unless ($ressymb) { $ressymb=&Apache::lonnet::symbread(); }
+ unless ($ressymb) { return ''; }
+ $ressymb=&wrap_symb($ressymb);
my $outputtarget=$env{'form.grade_target'};
if (defined($env{'form.export'})) {
if($env{'form.export'}) {
@@ -86,19 +98,32 @@ sub list_discussion {
$outputtarget = 'export';
}
}
- if (not &discussion_visible($status)) { return ''; }
+ if (not &discussion_visible($status)) {
+ if ($mode ne 'board') {
+ &Apache::lonenc::check_encrypt(\$ressymb);
+ return '
'.&send_message_link($ressymb)."
";
+ }
+ }
if ($group ne '' && $mode eq 'board') {
if (&check_group_priv($group,'vgb') ne 'ok') {
return '';
}
}
- my ($blocked,$blocktext) = &blocking_posts('boards',1);
+ my ($blocked,$blocktext) =
+ &Apache::loncommon::blocking_status('boards');
if ($blocked) {
- return $blocktext;
+ $blocktext = '
'.$blocktext."";
+ &Apache::lonenc::check_encrypt(\$ressymb);
+ if ($mode ne 'board') {
+ $blocktext.=&send_message_link($ressymb).'
';
+ }else{
+ $blocktext.="";
+ }
+ return $blocktext;
}
- my @bgcols = ("#cccccc","#eeeeee");
+ my @bgcols = ("LC_disc_old_item","LC_disc_new_item");
my $discussiononly=0;
if ($mode eq 'board') { $discussiononly=1; }
unless ($env{'request.course.id'}) { return ''; }
@@ -108,12 +133,9 @@ sub list_discussion {
$crs.='_'.$env{'request.course.sec'};
}
$crs=~s/\_/\//g;
- 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|task)$/));
+ && ($ressymb=~/$LONCAPA::assess_re/));
my %usernamesort = ();
my %namesort =();
@@ -160,6 +182,7 @@ sub list_discussion {
my $cdom = $env{'course.'.$cid.'.domain'};
my $cnum = $env{'course.'.$cid.'.num'};
+ my $crstype = &Apache::loncommon::course_type();
# Get information about students and non-students in course for filtering display of posts
my %roleshash = ();
@@ -258,17 +281,12 @@ sub list_discussion {
my $maxdepth=0;
my %anonhash=();
my $anoncnt=0;
- my $target='';
- unless ($env{'browser.interface'} eq 'textual' ||
- $env{'environment.remote'} eq 'off' ) {
- $target='target="LONcom"';
- }
my $now = time;
$discinfo{$visitkey} = $visit;
&Apache::lonnet::put('nohist_'.$cid.'_discuss',\%discinfo,$env{'user.domain'},$env{'user.name'});
- &build_posting_display(\%usernamesort,\%subjectsort,\%namesort,\%notshown,\%newitem,\%dischash,\%shown,\%alldiscussion,\%imsitems,\%imsfiles,\%roleinfo,\@discussionitems,\@replies,\@depth,\@posters,\$maxdepth,\$visible,\$newpostsflag,\$current,$status,$viewgrades,$seeid,$prevread,$sortposts,$encsymb,$target,$readkey,$showunmark,$showonlyunread,$totposters,\@rolefilter,\@sectionpick,\@grouppick,$classgroups,$statusfilter,$toggkey,$outputtarget,\%anonhash,$anoncnt,$group);
+ &build_posting_display(\%usernamesort,\%subjectsort,\%namesort,\%notshown,\%newitem,\%dischash,\%shown,\%alldiscussion,\%imsitems,\%imsfiles,\%roleinfo,\@discussionitems,\@replies,\@depth,\@posters,\$maxdepth,\$visible,\$newpostsflag,\$current,$status,$viewgrades,$seeid,$prevread,$sortposts,$encsymb,$readkey,$showunmark,$showonlyunread,$totposters,\@rolefilter,\@sectionpick,\@grouppick,$classgroups,$statusfilter,$toggkey,$outputtarget,\%anonhash,$anoncnt,$group);
my $discussion='';
my $manifestfile;
@@ -278,10 +296,8 @@ sub list_discussion {
my $copyresult;
my $function = &Apache::loncommon::get_users_function();
- my $color = &Apache::loncommon::designparm($function.'.tabbg',
- $env{'user.domain'});
my %lt = &Apache::lonlocal::texthash(
- 'cuse' => 'Current discussion settings',
+ 'cuse' => 'My settings for this discussion',
'allposts' => 'All posts',
'unread' => 'New posts only',
'unmark' => 'Unread only',
@@ -303,6 +319,7 @@ sub list_discussion {
'dpwn' => 'Deleted posts will no longer be visible to you and other students',
'bwco' => 'but will continue to be visible to your instructor',
'depo' => 'Deleted posts will no longer be visible to you or anyone else.',
+ 'discussions' => 'DISCUSSIONS'
);
my $currdisp = $lt{'allposts'};
@@ -343,10 +360,10 @@ sub list_discussion {
$togglink = 'toggoff';
}
- $chglink .= '&changes='.$displinkA.'_'.$displinkB.'_'.$marklink.'_'.$togglink;
+ $chglink .= '&changes='.$displinkA.'_'.$displinkB.'_'.$marklink.'_'.$togglink;
if ($newpostsflag) {
- $chglink .= '&previous='.$prevread;
+ $chglink .= '&previous='.$prevread;
}
$chglink.=&group_args($group);
@@ -354,8 +371,7 @@ sub list_discussion {
# Print the discusssion
if ($outputtarget eq 'tex') {
$discussion.='{\tiny \vskip 0 mm\noindent\makebox[2 cm][b]{\hrulefill}'.
- '\textbf{DISCUSSIONS}\makebox[2 cm][b]{\hrulefill}'.
- '\vskip 0 mm\noindent\textbf{'.$lt{'cuse'}.'}:\vskip 0 mm'.
+ '\textbf{'.$lt{'discussions'}.'}\makebox[2 cm][b]{\hrulefill}\vskip 0 mm'.
'\noindent\textbf{'.$lt{'disa'}.'}: \textit{'.$currdisp.'}\vskip 0 mm'.
'\noindent\textbf{'.$lt{'npce'}.'}: \textit{'.$currmark.'}}';
} elsif ($outputtarget eq 'export') {
@@ -389,8 +405,7 @@ sub list_discussion {
my $manifestfilename = $tempexport.$manifest;
if ($manifestfile = Apache::File->new('>'.$manifestfilename)) {
$manifestok=1;
- print $manifestfile qq|
-
+ print $manifestfile qq|
- |;
- $discussion.='