--- loncom/interface/lonfeedback.pm 2012/03/17 02:55:15 1.348
+++ loncom/interface/lonfeedback.pm 2013/01/18 13:22:26 1.364
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Feedback
#
-# $Id: lonfeedback.pm,v 1.348 2012/03/17 02:55:15 raeburn Exp $
+# $Id: lonfeedback.pm,v 1.364 2013/01/18 13:22:26 bisitz Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -513,7 +513,9 @@ imscp_v1p1.xsd http://www.imsglobal.org/
my $currdepth = 0;
my $firstidx = $alldiscussion{$showposts[0]};
foreach my $post (@showposts) {
- unless (($sortposts eq 'thread') || (($sortposts eq '') && ($env{'environment.threadeddiscussion'})) || ($outputtarget eq 'export')) {
+ unless (($sortposts eq 'thread') ||
+ (($sortposts eq '') && (!$env{'environment.unthreadeddiscussion'})) ||
+ ($outputtarget eq 'export')) {
$alldiscussion{$post} = $post;
}
unless ( ($notshown{$alldiscussion{$post}} eq '1') || ($shown{$alldiscussion{$post}} == 0) ) {
@@ -819,7 +821,7 @@ sub can_see_hidden {
sub discussion_link {
my ($ressymb,$linktext,$cmd,$item,$flag,$prev,$adds,$title)=@_;
- my $link='/adm/feedback?inhibitmenu=yes&modal=yes&'.$cmd.'='.&escape($ressymb).':::'.$item;
+ my $link='/adm/feedback?inhibitmenu=yes&modal=yes&'.$cmd.'='.&escape($ressymb).':::'.$item;
if ($flag) { $link .= '&previous='.$prev; }
if ($adds) { $link .= $adds; }
my $width=600;
@@ -1054,6 +1056,7 @@ sub build_posting_display {
&filter_regexp($rolefilter,$sectionpick,$statusfilter);
$rolematch = $roleregexp.':'.$secregexp.':'.$statusregexp;
}
+ my %votestyle;
if ($seeid || $canvote) {
# 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++) {
@@ -1061,8 +1064,8 @@ sub build_posting_display {
next if ($contrib{$idx.':deleted'});
next if ($contrib{$idx.':hidden'});
unless ((($hiddens{$idx}) && (!$seehidden)) || ($deletions{$idx}) || (!$contrib{$idx.':message'})) {
+ push(@theselikes,$likes{$symb.':'.$idx.':likes'});
if ($likes{$symb.':'.$idx.':likes'} ne '') {
- push(@theselikes,$likes{$symb.':'.$idx.':likes'});
if (ref($likes{$symb.':'.$idx.':likers'}) eq 'HASH') {
if (exists($likes{$symb.':'.$idx.':likers'}{$thisuser})) {
$userlikes{$idx} = 1;
@@ -1099,6 +1102,29 @@ sub build_posting_display {
$twoplus=$ave+2.*$stddev;
$oneminus=$ave-$stddev;
$twominus=$ave-2.*$stddev;
+ if ($#theselikes>1) {
+ foreach my $class ('twoplus','oneplus','zero','oneminus','twominus') {
+ my $fontstyle = $env{'course.'.$env{'request.course.id'}.'.discussion_post_fonts_'.$class};
+ if ($fontstyle ne '') {
+ my ($size,$weight,$style,$other) = split(/,/,$fontstyle);
+ if ($size ne '') {
+ $votestyle{$class} .= 'font-size: '.$size.';';
+ }
+ if ($weight ne '') {
+ $votestyle{$class} .= 'font-weight: '.$weight.';';
+ }
+ if ($style ne '') {
+ $votestyle{$class} .= 'font-style: '.$style.';';
+ }
+ if ($other ne '') {
+ $votestyle{$class} .= $other;
+ }
+ if ($votestyle{$class} ne '') {
+ $votestyle{$class} = 'style="'.$votestyle{$class}.'"';
+ }
+ }
+ }
+ }
}
#
# This is now the real loop. Go through all entries, pick up what we need
@@ -1117,7 +1143,8 @@ sub build_posting_display {
my $origindex='0.';
my $numoldver=0;
if ($contrib{$idx.':replyto'}) {
- if ( (($env{'environment.threadeddiscussion'}) && ($sortposts eq '')) || ($sortposts eq 'thread') || ($outputtarget eq 'export')) {
+ if ( ((!$env{'environment.unthreadeddiscussion'}) && ($sortposts eq '')) ||
+ ($sortposts eq 'thread') || ($outputtarget eq 'export')) {
# this is a follow-up message
$original[$idx]=$original[$contrib{$idx.':replyto'}];
$$depth[$idx]=$$depth[$contrib{$idx.':replyto'}]+1;
@@ -1330,7 +1357,8 @@ sub build_posting_display {
}
if ($outputtarget eq 'export' || $message) {
my $thisindex=$idx;
- if ( (($env{'environment.threadeddiscussion'}) && ($sortposts eq '')) || ($sortposts eq 'thread') || ($outputtarget eq 'export')) {
+ if ( ((!$env{'environment.unthreadeddiscussion'}) && ($sortposts eq '')) ||
+ ($sortposts eq 'thread') || ($outputtarget eq 'export')) {
$thisindex=$origindex.substr('00'.$$replies[$$depth[$idx]],-2,2);
}
$$alldiscussion{$thisindex}=$idx;
@@ -1432,34 +1460,47 @@ sub build_posting_display {
$$discussionitems[$idx].=' '.$ctlink;
}
my $thislikes=$likes{$symb.':'.$idx.':likes'};
- my $likesize="100";
+ my $likestyle;
if ($seeid || $canvote) {
# Figure out size based on likes
+ my $class = 'zero';
my $thislikes=$likes{$symb.':'.$idx.':likes'};
if ($thislikes>$twoplus) {
- $likesize="200";
+ $class = 'twoplus';
} elsif ($thislikes>$oneplus) {
- $likesize="150";
+ $class = 'oneplus';
}
if ($thislikes<$twominus) {
- $likesize="50";
+ $class = 'twominus';
} elsif ($thislikes<$oneminus) {
- $likesize="75";
+ $class = 'oneminus';
}
+ $likestyle = $votestyle{$class};
}
# Actually glue in the message itself
$$discussionitems[$idx].= '
'. - "". + "". $message. ''; if ($canvote) { + my $ownpost; + if (($uname eq $env{'user.name'}) && + ($udom eq $env{'user.domain'})) { + $ownpost = 1; + } # Put in the like and unlike buttons - if (($uname eq $env{'user.name'}) && ($udom eq $env{'user.domain'})) { - my $novote = &mt('No voting for your own posts'); + if ($ownpost || (($hiddens{$idx}) && ($seehidden))) { + my $novote; + if ($ownpost) { + $novote = &mt('No voting for your own posts.'); + } else { + $novote = &mt('No voting for hidden posts.'); + } $$discussionitems[$idx].= ''. ' '. ''; + } else { if ($userlikes{$idx}) { $$discussionitems[$idx].=''; @@ -1792,6 +1833,7 @@ END $env{'course.'.$env{'request.course.id'}.'.domain'}, $env{'course.'.$env{'request.course.id'}.'.num'}); unless (($contrib{'hidden'}=~/\.$idx\./) || ($contrib{'deleted'}=~/\.$idx\./)) { + my $numoldver = 0; if ($contrib{$idx.':history'}) { if ($contrib{$idx.':history'} =~ /:/) { my @oldversions = split(/:/,$contrib{$idx.':history'}); @@ -1800,36 +1842,25 @@ END $numoldver = 1; } } - if ($env{'form.replydisc'}) { - if ($contrib{$idx.':history'}) { - if ($contrib{$idx.':history'} =~ /:/) { - my @oldversions = split(/:/,$contrib{$idx.':history'}); - $numoldver = @oldversions; - } else { - $numoldver = 1; - } + if ($idx > 0) { + my (%msgversions,%subversions,$htmldecode); + $htmldecode = 0; + if ($env{'form.replydisc'}) { + $htmldecode = 1; } - if ($idx > 0) { - my %msgversions = (); - &get_post_versions(\%msgversions,$contrib{$idx.':message'},0,$numoldver); + &get_post_versions(\%msgversions,$contrib{$idx.':message'},0,$numoldver); + &get_post_versions(\%subversions,$contrib{$idx.':subject'},$htmldecode, + $numoldver); + $subject = $subversions{$numoldver}; + if ($env{'form.replydisc'}) { $quote = $msgversions{$numoldver}; - } - if ($idx > 0) { - my %subversions = (); - &get_post_versions(\%subversions,$contrib{$idx.':subject'},1,$numoldver); - $subject = &mt('Re: ').$subversions{$numoldver}; - } - $subject = &HTML::Entities::encode($subject,'<>&"'); - } else { - $attachmenturls = $contrib{$idx.':attachmenturl'}; - if ($idx > 0) { - my %msgversions = (); - &get_post_versions(\%msgversions,$contrib{$idx.':message'},0,$numoldver); + $subject = &HTML::Entities::encode(&mt('Re: ').$subject,'<>&"'); + } else { $comment = $msgversions{$numoldver}; - my %subversions = (); - &get_post_versions(\%subversions,$contrib{$idx.':subject'},0,$numoldver); - $subject = $subversions{$numoldver}; } + } + if ($env{'form.editdisc'}) { + $attachmenturls = $contrib{$idx.':attachmenturl'}; if (defined($contrib{$idx.':replyto'})) { $parentmsg = $contrib{$idx.':replyto'}; } @@ -1921,7 +1952,7 @@ END my %onload = ('onload' => 'window.focus();setposttype();'); my %parms=('add_entries' => \%onload); - if ($env{'form.modal'} ne 'yes') { 'bread_crumbs' => $brcrum } + if ($env{'form.modal'} ne 'yes') { $parms{'bread_crumbs'} = $brcrum; } my $start_page= &Apache::loncommon::start_page('Resource Feedback and Discussion',$js,\%parms); @@ -1930,7 +1961,11 @@ END unless (&contains_block_html($quote)) { &newline_to_br(\$quote); } - $quote=''.&Apache::lontexconvert::msgtexconverted($quote).''; + $quote=&Apache::lonhtmlcommon::start_pick_box(). + &Apache::lonhtmlcommon::row_title(&mt('Quote')). + &Apache::lontexconvert::msgtexconverted($quote). + &Apache::lonhtmlcommon::row_closure(1). + &Apache::lonhtmlcommon::end_pick_box(); } my $header=''; unless ($env{'form.modal'}) { @@ -1958,24 +1993,27 @@ END } $r->print(<+END +$r->print(&Apache::lonhtmlcommon::start_pick_box()); +$r->print(< $textareaheader -
$latexHelp
END - $r->print(&Apache::lonhtmlcommon::start_pick_box()); + $r->print(&Apache::lonhtmlcommon::row_title(&mt('Subject'))); $r->print('
'); $r->print(&Apache::lonhtmlcommon::row_closure()); $r->print(&Apache::lonhtmlcommon::row_title(&mt('Message'))); - $r->print('