--- loncom/interface/lonfeedback.pm 2010/04/14 13:58:11 1.292
+++ loncom/interface/lonfeedback.pm 2012/03/16 02:59:01 1.346
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Feedback
#
-# $Id: lonfeedback.pm,v 1.292 2010/04/14 13:58:11 wenzelju Exp $
+# $Id: lonfeedback.pm,v 1.346 2012/03/16 02:59:01 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -49,13 +49,22 @@ 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;
}
@@ -73,6 +82,26 @@ sub discussion_visible {
return 1;
}
+sub discussion_vote_available {
+ my ($status,$symb)=@_;
+ my $canvote=&Apache::lonnet::EXT('resource.0.discussvote',$symb);
+ if ((lc($canvote) eq 'yes') ||
+ ((lc($canvote) eq 'notended') && (&discussion_open($status,$symb)))) {
+ return 1;
+ }
+}
+
+sub get_realsymb {
+ my ($symb) = @_;
+ my $realsymb = $symb;
+ if ($symb=~/^bulletin___/) {
+ my $filename=(&Apache::lonnet::decode_symb($symb))[2];
+ $filename=~s{^adm/wrapper/}{};
+ $realsymb=&Apache::lonnet::symbread($filename);
+ }
+ return $realsymb;
+}
+
sub list_discussion {
my ($mode,$status,$ressymb,$imsextras,$group)=@_;
unless ($ressymb) { $ressymb=&Apache::lonnet::symbread(); }
@@ -126,7 +155,7 @@ sub list_discussion {
$crs=~s/\_/\//g;
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 =();
@@ -256,6 +285,11 @@ sub list_discussion {
} else {
$seeid=&Apache::lonnet::allowed('rin',$crs);
}
+
+# Is voting on discussions available
+ my $realsymb = &get_realsymb($ressymb);
+ my $canvote = &discussion_vote_available($status,$realsymb);
+
my @discussionitems=();
my %shown = ();
my @posteridentity=();
@@ -272,13 +306,12 @@ sub list_discussion {
my $maxdepth=0;
my %anonhash=();
my $anoncnt=0;
- my $target='';
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,$canvote,$prevread,$sortposts,$encsymb,$readkey,$showunmark,$showonlyunread,$totposters,\@rolefilter,\@sectionpick,\@grouppick,$classgroups,$statusfilter,$toggkey,$outputtarget,\%anonhash,$anoncnt,$group);
my $discussion='';
my $manifestfile;
@@ -288,10 +321,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',
@@ -313,6 +344,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'};
@@ -364,8 +396,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') {
@@ -433,7 +464,7 @@ imscp_v1p1.xsd http://www.imsglobal.org/
}
|);
$discussion.='