--- loncom/interface/lonfeedback.pm 2012/03/07 01:26:48 1.290.2.7.2.2
+++ loncom/interface/lonfeedback.pm 2011/12/12 03:04:30 1.312
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Feedback
#
-# $Id: lonfeedback.pm,v 1.290.2.7.2.2 2012/03/07 01:26:48 raeburn Exp $
+# $Id: lonfeedback.pm,v 1.312 2011/12/12 03:04:30 www Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -58,15 +58,15 @@ sub discussion_open {
return 1;
}
# It was not explicitly open, check if the problem is available.
-# If the problem is not available, close the discussion
+# 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;
+ !($status eq 'CAN_ANSWER' || $status eq 'CANNOT_ANSWER'
+ || $status eq 'OPEN')) {
+ return 0;
}
# The problem is available, but check if the instructor explictly closed discussion
if (defined($close) && $close ne '' && $close < time) {
- return 0;
+ return 0;
}
return 1;
}
@@ -135,7 +135,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 =();
@@ -281,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;
@@ -425,7 +420,6 @@ imscp_v1p1.xsd http://www.imsglobal.org/
}
} else {
my $colspan=$maxdepth+1;
-#JW
$discussion.= &Apache::lonhtmlcommon::scripttag(qq|
function verifydelete (caller,symb,idx,newflag,previous,groupparm) {
var symbparm = symb+':::'+idx
@@ -728,8 +722,8 @@ END
}
}
if ((&discussion_open($status)) && ($outputtarget ne 'tex')) {
- if (($group ne '') && ($mode eq 'board')) {
- if ((&check_group_priv($group,'pgd') eq 'ok') &&
+ if (($group ne '') && ($mode eq 'board')) {
+ if ((&check_group_priv($group,'pgd') eq 'ok') &&
($ressymb =~ m{^bulletin___\d+___adm/wrapper/adm/\Q$cdom\E/\Q$cnum\E/\d+/bulletinboard$})) {
$discussion .=
&postingform_display($mode,$ressymb,$now,$subject,
@@ -741,10 +735,10 @@ END
if (&Apache::lonnet::allowed('pch',$env{'request.course.id'}.
($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:''))) {
- $discussion.=
- &postingform_display($mode,$ressymb,$now,$subject,
- $comment,$outputtarget,$attachnum,
- $currnewattach,$currdelold,'',$crstype);
+ $discussion.=
+ &postingform_display($mode,$ressymb,$now,$subject,
+ $comment,$outputtarget,$attachnum,
+ $currnewattach,$currdelold,'',$crstype);
} else {
$discussion.= ''.
&mt('This discussion is closed.').'';
@@ -761,7 +755,7 @@ END
&Apache::lonnet::allowed('pch',
$env{'request.course.id'}.
($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:''))) {
- $discussion.= &send_feedback_link($ressymb,$target);
+ $discussion.= &send_feedback_link($ressymb);
if ($env{'request.role.adv'}) {
my $close = &Apache::lonnet::EXT('resource.0.discussend',$ressymb);
if (defined($close) && $close ne '' && $close < time) {
@@ -769,7 +763,7 @@ END
&Apache::lonnet::plaintext('st',$crstype));
}
}
- } else {
+ } else {
$discussion.= ''.&mt('This discussion is closed.').'';
}
$discussion.= &send_message_link($ressymb).'';
@@ -777,26 +771,25 @@ END
return $discussion;
}
+
sub discussion_link {
- my ($ressymb,$linktext,$cmd,$item,$flag,$prev,$adds,$title) = @_;
- my $link = '';
- return $link;
+ my ($ressymb,$linktext,$cmd,$item,$flag,$prev,$adds)=@_;
+ my $link='/adm/feedback?inhibitmenu=yes&modal=yes&'.$cmd.'='.&escape($ressymb).':::'.$item;
+ if ($flag) { $link .= '&previous='.$prev; }
+ if ($adds) { $link .= $adds; }
+ return &Apache::loncommon::modal_link($link,$linktext,600,600);
}
+
sub send_feedback_link {
- my ($ressymb,$target) = @_;
- my $output = ''.
- ' '.
- '';
- return $output;
+ my ($ressymb) = @_;
+ return ''.
+ &discussion_link($ressymb,
+ '';
}
sub send_message_link {
@@ -915,22 +908,22 @@ ENDDISCUSS
}
$postingform .= "\n";
$postingform .= &generate_attachments_button('',$attachnum,$ressymb,
- $now,$currnewattach,
- $currdelold,'',$mode,
- $blockblog);
+ $now,$currnewattach,
+ $currdelold,'',$mode,
+ $blockblog);
if ((ref($currnewattach) eq 'ARRAY') && (@{$currnewattach} > 0)) {
$newattachmsg = ' ',
+ 'replydisc').
+ '
'.$lt{'newa'}.'
';
if (@{$currnewattach} > 1) {
- $newattachmsg .= '';
- foreach my $item (@{$currnewattach}) {
+ $newattachmsg .= '
'."\n";
+ } else {
+ $$currnewattach[0] =~ m#.*/([^/]+)$#;
+ $newattachmsg .= ''.$1.'';
+ foreach my $item (@{$currnewattach}) {
$item =~ m#.*/([^/]+)$#;
$newattachmsg .= '
'."\n";
- } else {
- $$currnewattach[0] =~ m#.*/([^/]+)$#;
- $newattachmsg .= ''.$1.'
'."\n";
- }
+ }
+ $newattachmsg .= '
'."\n";
+ }
}
$postingform .= $newattachmsg;
$postingform .= &generate_preview_button();
@@ -938,25 +931,16 @@ ENDDISCUSS
}
sub build_posting_display {
- my ($usernamesort,$subjectsort,$namesort,$notshown,$newitem,$dischash,$shown,$alldiscussion,$imsitems,$imsfiles,$roleinfo,$discussionitems,$replies,$depth,$posters,$maxdepth,$visible,$newpostsflag,$current,$status,$viewgrades,$seeid,$prevread,$sortposts,$ressymb,$target,$readkey,$showunmark,$showonlyunread,$totposters,$rolefilter,$sectionpick,$grouppick,$classgroups,$statusfilter,$toggkey,$outputtarget,$anonhash,$anoncnt,$group) = @_;
+ my ($usernamesort,$subjectsort,$namesort,$notshown,$newitem,$dischash,$shown,$alldiscussion,$imsitems,$imsfiles,$roleinfo,$discussionitems,$replies,$depth,$posters,$maxdepth,$visible,$newpostsflag,$current,$status,$viewgrades,$seeid,$prevread,$sortposts,$ressymb,$readkey,$showunmark,$showonlyunread,$totposters,$rolefilter,$sectionpick,$grouppick,$classgroups,$statusfilter,$toggkey,$outputtarget,$anonhash,$anoncnt,$group) = @_;
my @original=();
my @index=();
my $skip_group_check = 0;
my $symb=&Apache::lonenc::check_decrypt($ressymb);
my $escsymb=&escape($ressymb);
-# These are the discussion contributions
my %contrib=&Apache::lonnet::restore($symb,$env{'request.course.id'},
$env{'course.'.$env{'request.course.id'}.'.domain'},
$env{'course.'.$env{'request.course.id'}.'.num'});
-# And these are the likes/unlikes
- my %likes=&Apache::lonnet::dump('disclikes',
- $env{'course.'.$env{'request.course.id'}.'.domain'},
- $env{'course.'.$env{'request.course.id'}.'.num'},
- '^'.$symb.':');
- my $thisuser=$env{'user.name'}.':'.$env{'user.domain'};
-# Array with likes to figure out averages, etc.
- my @theselikes=();
-# Is the user allowed to see the real name behind anonymous postings?
+
my $see_anonymous =
&Apache::lonnet::allowed('rin',$env{'request.course.id'}.($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:''));
@@ -986,41 +970,7 @@ sub build_posting_display {
($skiptest,$roleregexp,$secregexp,$statusregexp) =
&filter_regexp($rolefilter,$sectionpick,$statusfilter);
$rolematch = $roleregexp.':'.$secregexp.':'.$statusregexp;
- }
-# We need to go through this twice, first to get the likes/dislikes, then to actually build the display
- for (my $id=1;$id<=$contrib{'version'};$id++) {
- my $idx=$id;
- next if ($contrib{$idx.':deleted'});
- next if ($contrib{$idx.':hidden'});
- unless ((($hiddens{$idx}) && (!$seeid)) || ($deletions{$idx}) || (!$contrib{$idx.':message'})) {
- push(@theselikes,$likes{$symb.':'.$idx.':likes'});
- }
- }
-# Figure out average likes and standard deviation if there are enough discussions to warrant that
- my $ave=0;
- my $stddev=10000;
- if ($#theselikes>1) {
- my $sum=0;
- my $num=$#theselikes+1;
- foreach my $thislike (@theselikes) {
- $sum+=$thislike;
- }
- $ave=$sum/$num;
- my $sumsq=0;
- foreach my $thislike (@theselikes) {
- $sumsq+=($thislike-$ave)*($thislike-$ave);
- }
- $stddev=sqrt($sumsq/$num);
- }
-# Now we know the average likes $ave and the standard deviation $stddev
-# Get the boundaries for markup
- my $oneplus=$ave+$stddev;
- my $twoplus=$ave+2.*$stddev;
- my $oneminus=$ave-$stddev;
- my $twominus=$ave-2.*$stddev;
-#
-# This is now the real loop. Go through all entries, pick up what we need
-#
+ }
for (my $id=1;$id<=$contrib{'version'};$id++) {
my $idx=$id;
next if ($contrib{$idx.':deleted'});
@@ -1053,7 +1003,7 @@ sub build_posting_display {
} else {
$$replies[$$depth[$idx]]=1;
}
- unless ((($hiddens{$idx}) && (!$seeid)) || ($deletions{$idx})) {
+ unless ((($hiddens{$idx}) && (!$seeid)) || ($deletions{$idx})) {
$$visible++;
if ($contrib{$idx.':history'}) {
if ($contrib{$idx.':history'} =~ /:/) {
@@ -1068,7 +1018,7 @@ sub build_posting_display {
my %subjects = ();
my %attachtxt = ();
my %allattachments = ();
- my ($screenname,$plainname,$showaboutme);
+ my ($screenname,$plainname);
my $sender = &mt('Anonymous');
# Anonymous users getting number within a discussion
# Since idx is in static order, this should give the same sequence every time.
@@ -1078,7 +1028,7 @@ sub build_posting_display {
$$anonhash{$key}=&mt('Anonymous').' '.$anoncnt;
}
my ($message,$subject,$vgrlink,$ctlink);
- &get_post_contents(\%contrib,$idx,$seeid,$outputtarget,\%messages,\%subjects,\%allattachments,\%attachtxt,$imsfiles,\$screenname,\$plainname,\$showaboutme,$numoldver);
+ &get_post_contents(\%contrib,$idx,$seeid,$outputtarget,\%messages,\%subjects,\%allattachments,\%attachtxt,$imsfiles,\$screenname,\$plainname,$numoldver);
# Set up for sorting by subject
@@ -1108,18 +1058,12 @@ sub build_posting_display {
}
}
if (!$contrib{$idx.':anonymous'} || $see_anonymous) {
- if ($showaboutme) {
- $sender = &Apache::loncommon::aboutmewrapper(
- $plainname,
- $contrib{$idx.':sendername'},
- $contrib{$idx.':senderdomain'});
- } else {
- $sender = $plainname;
- }
- if ($see_anonymous) {
- $sender .= ' ('.$contrib{$idx.':sendername'}.':'.
- $contrib{$idx.':senderdomain'}.')';
- }
+ $sender=&Apache::loncommon::aboutmewrapper(
+ $plainname,
+ $contrib{$idx.':sendername'},
+ $contrib{$idx.':senderdomain'}).' ('.
+ $contrib{$idx.':sendername'}.':'.
+ $contrib{$idx.':senderdomain'}.')';
$sender = ''.$sender.'';
if ($contrib{$idx.':anonymous'}) {
$sender.=' ['.$$anonhash{$key}.'] '.
@@ -1160,14 +1104,8 @@ sub build_posting_display {
if ($outputtarget ne 'tex') {
if (&editing_allowed($escsymb.':::'.$idx,$group)) {
if (($env{'user.domain'} eq $contrib{$idx.':senderdomain'}) && ($env{'user.name'} eq $contrib{$idx.':sendername'})) {
- $sender.=' '.&mt('Edit').'';
-
+ $sender.=' '.
+ &discussion_link($symb,&mt('Edit'),'editdisc',$idx,$$newpostsflag,$prevread,&group_args($group));
unless ($seeid) {
my $grpargs = &group_args($group);
$sender.=" '.&mt('Make Visible').'';
+ $sender.=' '.
+ &discussion_link($symb,&mt('Make Visible'),'unhide',$idx,$$newpostsflag,$prevread,&group_args($group));
}
} else {
- $sender.=' '.&mt('Hide').'';
+ $sender.=' '.
+ &discussion_link($symb,&mt('Hide'),'hide',$idx,$$newpostsflag,$prevread,&group_args($group));
}
my $grpargs = &group_args($group);
$sender.=
@@ -1200,7 +1129,7 @@ sub build_posting_display {
$sender .= &mt('Delete').'';
}
}
- } else {
+ } else {
if ($screenname) {
$sender=''.$screenname.'';
} else {
@@ -1227,33 +1156,24 @@ sub build_posting_display {
}
}
if ($outputtarget ne 'tex') {
- if (&discussion_open($status)) {
+ if (&discussion_open($status)) {
if (($group ne '') &&
(&check_group_priv($group,'pgd') eq 'ok')) {
- $sender.=' '.&mt('Reply').'';
+ $sender.=' '.
+ &discussion_link($symb,&mt('Reply'),'replydisc',$idx,$$newpostsflag,$prevread,&group_args($group));
} elsif (&Apache::lonnet::allowed('pch',
$env{'request.course.id'}.
($env{'request.course.sec'}?'/'.
$env{'request.course.sec'}:''))) {
- $sender.=' '.&mt('Reply').'';
+ $sender.=' '.
+ &discussion_link($symb,&mt('Reply'),'replydisc',$idx,$$newpostsflag,$prevread);
}
}
- if ($viewgrades) {
+ if ($viewgrades) {
$vgrlink=&Apache::loncommon::submlink(&mt('Submissions'),
$contrib{$idx.':sendername'},$contrib{$idx.':senderdomain'},$ressymb);
}
- if ($$dischash{$readkey}=~/\.$idx\./) {
+ if ($$dischash{$readkey}=~/\.$idx\./) {
$ctlink = '';
} else {
$ctlink = '';
@@ -1371,48 +1291,14 @@ sub build_posting_display {
$$discussionitems[$idx].='
'. - "'; -# Put in the like and unlike buttons - unless ($likes{$symb.':'.$idx.':likers'}=~/\,\Q$thisuser\E\,/) { - $$discussionitems[$idx].=' '.&discussion_link($symb,'','like',$idx,$$newpostsflag,$prevread,&group_args($group),&mt("Like this posting")); - } else { - $$discussionitems[$idx].=''; - } - unless ($likes{$symb.':'.$idx.':unlikers'}=~/\,\Q$thisuser\E\,/) { - $$discussionitems[$idx].=' '.&discussion_link($symb,'','unlike',$idx,$$newpostsflag,$prevread,&group_args($group),&mt("Unlike this posting")); - } else { - $$discussionitems[$idx].=''; - } - my $thislikes=$likes{$symb.':'.$idx.':likes'}; - if ($thislikes>0) { - $$discussionitems[$idx].=' ('.&mt("[_1] likes",$thislikes).')'; - } elsif ($thislikes<0) { - $$discussionitems[$idx].=' ('.&mt("[_1] unlikes",abs($thislikes)).')'; - } + $message.''; if ($contrib{$idx.':history'}) { my @postversions = (); $$discussionitems[$idx] .= &mt('This post has been edited by the author.'); if ($seeid) { - $$discussionitems[$idx] .= ' '.&mt('Display all versions').''; + $$discussionitems[$idx] .= ' '. + &discussion_link($symb,&mt('Display all versions'),'allversions',$idx,$$newpostsflag,$prevread,&group_args($group)); } $$discussionitems[$idx].='". - $message. - '
'.&Apache::lontexconvert::msgtexconverted($quote).''; } - + my $header=''; + unless ($env{'form.modal'}) { + $header="