[LON-CAPA-cvs] cvs: loncom /interface courseprefs.pm lonfeedback.pm
raeburn
raeburn at source.lon-capa.org
Fri Jun 22 16:33:15 EDT 2012
raeburn Fri Jun 22 20:33:15 2012 EDT
Modified files:
/loncom/interface lonfeedback.pm courseprefs.pm
Log:
- Display of discussion posts where liking/unliking is enabled.
- Styles used for posted text based on classification
(mean +/- 1sigma; mean +/- 2sigma etc.) are now configurable from
course settings.
- Default is for no change to display of text.
-------------- next part --------------
Index: loncom/interface/lonfeedback.pm
diff -u loncom/interface/lonfeedback.pm:1.357 loncom/interface/lonfeedback.pm:1.358
--- loncom/interface/lonfeedback.pm:1.357 Sun Jun 17 15:30:37 2012
+++ loncom/interface/lonfeedback.pm Fri Jun 22 20:33:15 2012
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Feedback
#
-# $Id: lonfeedback.pm,v 1.357 2012/06/17 15:30:37 raeburn Exp $
+# $Id: lonfeedback.pm,v 1.358 2012/06/22 20:33:15 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -1056,6 +1056,7 @@
&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++) {
@@ -1101,6 +1102,29 @@
$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
@@ -1436,24 +1460,26 @@
$$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].= '<br /><blockquote>'.
- "<div style='font-size:$likesize%'>".
+ "<div $likestyle>".
$message.
'</div></blockquote>';
if ($canvote) {
Index: loncom/interface/courseprefs.pm
diff -u loncom/interface/courseprefs.pm:1.49 loncom/interface/courseprefs.pm:1.50
--- loncom/interface/courseprefs.pm:1.49 Wed Feb 15 21:36:30 2012
+++ loncom/interface/courseprefs.pm Fri Jun 22 20:33:15 2012
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Handler to set configuration settings for a course
#
-# $Id: courseprefs.pm,v 1.49 2012/02/15 21:36:30 raeburn Exp $
+# $Id: courseprefs.pm,v 1.50 2012/06/22 20:33:15 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -399,7 +399,8 @@
ordered => ['pch.roles.denied','pch.users.denied',
'plc.roles.denied','plc.users.denied',
'allow_limited_html_in_feedback',
- 'allow_discussion_post_editing'],
+ 'allow_discussion_post_editing',
+ 'discussion_post_fonts'],
itemtext => {
'pch.roles.denied' => 'No Resource Discussion',
'pch.users.denied' => 'No Resource Discussion',
@@ -407,6 +408,7 @@
'plc.users.denied' => 'No Chat room use',
allow_limited_html_in_feedback => 'Allow limited HTML in discussion',
allow_discussion_post_editing => 'Users can edit/delete own discussion posts',
+ discussion_post_fonts => 'Discussion post fonts based on likes/unlikes',
},
},
'classlists' =>
@@ -987,6 +989,35 @@
}
}
$newvalues{$entry} =~ s/,$//;
+ } elsif ($entry eq 'discussion_post_fonts') {
+ my ($classorder,$classtitles) = &discussion_vote_classes();
+ my $fontchange = 0;
+ foreach my $class (@{$classorder}) {
+ my $ext_entry = $entry.'_'.$class;
+ my $size = $env{'form.'.$ext_entry.'_size'};
+ my $unit = $env{'form.'.$ext_entry.'_unit'};
+ my $weight = $env{'form.'.$ext_entry.'_weight'};
+ my $style = $env{'form.'.$ext_entry.'_style'};
+ my $other = $env{'form.'.$ext_entry.'_other'};
+ $size =~ s/,//g;
+ $unit =~ s/,//g;
+ $weight =~ s/,//g;
+ $style =~ s/,//g;
+ $other =~ s/[^\w;:\s\-\%.]//g;
+ $other =~ s/(^\s+|\s+$)//g;
+ $newvalues{$ext_entry} = join(',',($size.$unit,$weight,$style,$other));
+ my $current = $values->{$ext_entry};
+ if ($values->{$ext_entry} eq '') {
+ $current = ',,,';
+ }
+ if ($newvalues{$ext_entry} ne $current) {
+ $changes->{$ext_entry} = $newvalues{$ext_entry};
+ $fontchange ++;
+ }
+ }
+ if ($fontchange) {
+ $changes->{$entry} = 1;
+ }
} elsif ($entry eq 'nothideprivileged') {
my @curr_nothide;
my @new_nothide;
@@ -1090,7 +1121,7 @@
} else {
$newvalues{$entry} = $env{'form.'.$entry};
}
- unless ($entry eq 'co-owners') {
+ unless (($entry eq 'co-owners') || ($entry eq 'discussion_post_fonts')) {
if ($newvalues{$entry} ne $values->{$entry}) {
$changes->{$entry} = $newvalues{$entry};
}
@@ -1217,7 +1248,7 @@
my ($displayname,$text);
$text = $prefs->{$item}->{'itemtext'}{$key};
my $displayval;
- unless ($key eq 'co-owners') {
+ unless (($key eq 'co-owners') || ($key eq 'discussion_post_fonts')) {
$displayval = $changes->{$item}{$key};
}
if ($item eq 'feedback') {
@@ -1253,6 +1284,36 @@
}
$displayval = join(', ', at longroles);
}
+ } elsif ($key eq 'discussion_post_fonts') {
+ my ($classorder,$classtitles)=&discussion_vote_classes();
+ my ($styleorder,$styleitems)=&discussion_vote_styles();
+ my $count = 1;
+ my $total = scalar(keys(%{$changes->{$item}}));
+ foreach my $class (@{$classorder}) {
+ $count ++;
+ next unless ($changes->{$item}{$key.'_'.$class});
+ my @vals = split(/,/,$changes->{$item}{$key.'_'.$class});
+ my $showval = '';
+ for (my $i=0; $i<@{$styleorder}; $i++) {
+ if ($vals[$i] ne '') {
+ $showval .= 'font-'.$styleorder->[$i].': '.$vals[$i].'; ';
+ }
+ }
+ if ($vals[3] ne '') {
+ $showval .= $vals[3];
+ }
+ if ($showval ne '') {
+ $displayval .= $classtitles->{$class}.':{ '.
+ $showval.'}';
+ $storehash{$key.'_'.$class} = $changes->{$item}{$key.'_'.$class};
+ } else {
+ $displayval .= $classtitles->{$class}.': '.&mt('None');
+ push(@delkeys,$key.'_'.$class);
+ }
+ unless ($count == $total) {
+ $displayval .= (' 'x2);
+ }
+ }
}
$displayname = &mt($text);
}
@@ -1352,7 +1413,9 @@
}
}
} else {
- $storehash{$key} = $changes->{$item}{$key};
+ unless ($key eq 'discussion_post_fonts') {
+ $storehash{$key} = $changes->{$item}{$key};
+ }
}
}
if ($key eq 'cloners') {
@@ -2970,6 +3033,11 @@
text => '<b>'.&mt($itemtext->{'allow_discussion_post_editing'}).'</b>',
input => 'checkbox',
},
+ 'discussion_post_fonts' => {
+ text => '<b>'.&mt($itemtext->{'discussion_post_fonts'}).'</b>',
+ input => 'textbox',
+ size => '20',
+ },
);
my $datatable;
my $count;
@@ -3009,6 +3077,17 @@
&Apache::loncommon::end_data_table_row().
&role_checkboxes($cdom,$cnum,$item,$settings,1).
&Apache::loncommon::end_data_table();
+ } elsif ($item eq 'discussion_post_fonts') {
+ $datatable .= &Apache::loncommon::start_data_table().
+ &Apache::loncommon::start_data_table_row().
+ '<th align="center">'.&mt('Sum of likes/dislikes').'</th>'.
+ '<th align="center">'.&mt('font-size').'</th>'.
+ '<th align="center">'.&mt('font-weight').'</th>'.
+ '<th align="center">'.&mt('font-style').'</th>'.
+ '<th align="center">'.&mt('Other css').'</th>'.
+ &Apache::loncommon::end_data_table_row().
+ &set_discussion_fonts($cdom,$cnum,$item,$settings).
+ &Apache::loncommon::end_data_table();
}
$datatable .= &item_table_row_end();
}
@@ -3130,6 +3209,75 @@
return $output;
}
+sub set_discussion_fonts {
+ my ($cdom,$cnum,$item,$settings) = @_;
+ my ($classorder,$classtitles) = &discussion_vote_classes();
+ my ($styleorder,$styleitems) = &discussion_vote_styles();
+ my $output;
+ if (ref($classorder) eq 'ARRAY') {
+ foreach my $cat (@{$classorder}) {
+ my %curr = ();
+ ($curr{'size'},$curr{'weight'},$curr{'style'},$curr{'other'}) =
+ split(/,/,$settings->{'discussion_post_fonts_'.$cat});
+ $output .= &Apache::loncommon::start_data_table_row().
+ '<td>'.$classtitles->{$cat}.'</td>';
+ if (ref($styleorder) eq 'ARRAY') {
+ foreach my $item (@{$styleorder}) {
+ $output .= '<td><span class="LC_nobreak">';
+ my $selitem = $item;
+ if ($item eq 'size') {
+ my ($currsize,$currunit);
+ if ($curr{'size'} =~ /^(\d+)(px|%)$/) {
+ ($currsize,$currunit) = ($1,$2);
+ $curr{'size'} = $currunit;
+ }
+ $output .= '<input type="textbox" name="discussion_post_fonts_'.$cat.'_'.$item.'" value="'.$currsize.'" size="5">'.
+ ' ';
+ $selitem = 'unit';
+ }
+ if ((ref($styleitems) eq 'HASH') && (ref($styleitems->{$item}) eq 'ARRAY')) {
+ $output .= '<select name="discussion_post_fonts_'.$cat.'_'.$selitem.'">';
+ foreach my $val (@{$styleitems->{$item}}) {
+ my $sel;
+ if ($val eq $curr{$item}) {
+ $sel = ' selected="selected"';
+ }
+ $output .= '<option value="'.$val.'"'.$sel.'>'.$val.'</option>';
+ }
+ }
+ }
+ }
+ $output .= '</span></td><td><input type="textbox" size="10" name="discussion_post_fonts_'.$cat.'_other" value="'.$curr{'other'}.'" /></td>';
+ }
+ $output .= &Apache::loncommon::end_data_table_row();
+ }
+ return $output;
+}
+
+sub discussion_vote_classes {
+ my $classorder = ['twoplus','oneplus','zero','oneminus','twominus'];
+ my %classtitles = &Apache::lonlocal::texthash(
+ 'twoplus' => 'Two sigma above mean',
+ 'oneplus' => 'One sigma above mean',
+ 'zero' => 'Within one sigma of mean',
+ 'oneminus' => 'One sigma below mean',
+ 'twominus' => 'Two sigma below mean',
+ );
+ return ($classorder,\%classtitles);
+}
+
+sub discussion_vote_styles {
+ my $styleorder = ['size','weight','style'];
+ my $styleitems = {
+ size => ['','px','%','xx-small','x-small','small','medium','large',
+ 'x-large','xx-large','smaller','larger'],
+ weight => ['','normal','bold','bolder','lighter','100','200','300','400',
+ '500','600','700','800','900'],
+ style => ['','normal','italic','oblique'],
+ };
+ return ($styleorder,$styleitems);
+}
+
sub print_classlists {
my ($position,$cdom,$settings,$itemtext,$rowtotal,$crstype) = @_;
my @ordered;
@@ -3472,7 +3620,8 @@
unless (($parameter =~ m/^internal\./)||($parameter =~ m/^metadata\./) ||
($parameter =~ m/^selfenroll_/) || ($parameter =~ /_selfenroll$/)
|| ($parameter eq 'type') ||
- ($parameter =~ m/^(cc|co|in|ta|ep|ad|st)\.plaintext$/)) {
+ ($parameter =~ m/^(cc|co|in|ta|ep|ad|st)\.plaintext$/)
+ || ($parameter =~ m/^discussion_post_fonts/)) {
push(@ordered,$parameter);
}
}
More information about the LON-CAPA-cvs
mailing list