'.
- ''.
+ my $discussion = ' '.
+ ''.
'';
my $escsymb=&escape($ressymb);
if ($visible) {
@@ -805,26 +814,38 @@ sub action_links_bar {
$discussion .= '&previous='.$prevread;
}
$discussion .= &group_args($group);
- $discussion .='">'.&mt('Chronological View').'
- '.&mt('Chronological View').' ';
+
+ my $otherviewurl='/adm/feedback?cmd=sortfilter&symb='.$escsymb.'&inhibitmenu=yes&modal=yes';
if ($newpostsflag) {
- $discussion .= '&previous='.$prevread;
+ $otherviewurl .= '&previous='.$prevread;
}
- $discussion .= &group_args($group);
- $discussion .='">'.&mt('Sorting/Filtering options').''.(' ' x2);
+ $otherviewurl .= &group_args($group);
+ $discussion .= &Apache::loncommon::modal_link($otherviewurl,&mt('Other Views ...'),800,340);
+ $discussion .= ' ';
}
$discussion .=''.&mt('Export').'? | ';
+ $discussion .= '">'.&mt('Export').'';
+ if (&Apache::lonnet::allowed('rin',$env{'request.course.id'})) {
+ $discussion .= ' ';
+ $discussion .=''.&mt('Undelete all deleted entries').'';
+ }
+ $discussion.='';
if ($newpostsflag) {
if (!$markondisp) {
$discussion .=''.
- &mt('Preferences on what is marked as NEW').
+ &mt('My general preferences on what is marked as NEW').
' '.&mt('Mark NEW posts no longer new').' | ';
@@ -867,9 +888,9 @@ sub postingform_display {
-
+
$lt{'note'}
-$lt{'title'}:
+$lt{'title'}:
ENDDISCUSS
if ($env{'form.origpage'}) {
@@ -893,22 +914,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 = ' '.$lt{'newa'}.' ';
if (@{$currnewattach} > 1) {
- $newattachmsg .= '';
- foreach my $item (@{$currnewattach}) {
+ $newattachmsg .= '';
+ foreach my $item (@{$currnewattach}) {
$item =~ m#.*/([^/]+)$#;
$newattachmsg .= '- '.$1.'
'."\n";
- }
- $newattachmsg .= ' '."\n";
- } else {
- $$currnewattach[0] =~ m#.*/([^/]+)$#;
- $newattachmsg .= ''.$1.' '."\n";
- }
+ }
+ $newattachmsg .= ' '."\n";
+ } else {
+ $$currnewattach[0] =~ m#.*/([^/]+)$#;
+ $newattachmsg .= ''.$1.' '."\n";
+ }
}
$postingform .= $newattachmsg;
$postingform .= &generate_preview_button();
@@ -916,22 +937,32 @@ 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'}:''));
if ((@{$grouppick} == 0) || (grep(/^all$/,@{$grouppick}))) {
$skip_group_check = 1;
}
+# Deletions and hiddens are just lists. Split them up into a hash for quicker lookup
my (%deletions,%hiddens);
if ($contrib{'deleted'}) {
my $deleted = $contrib{'deleted'};
@@ -945,6 +976,7 @@ sub build_posting_display {
$hidden =~ s/\.$//;
%hiddens = map { $_ => 1 } (split(/\.\./,$hidden));
}
+# Versions if store/restore are used to actually store the messages.
if ($contrib{'version'}) {
my $oldest = $contrib{'1:timestamp'};
if ($prevread eq '0') {
@@ -955,11 +987,48 @@ 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;
+# &Apache::lonnet::logthis(join(',',@theselikes)." Ave $ave StdDev $stddev $twominus $oneminus $oneplus $twoplus");
+#
+# 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'});
next if ($contrib{$idx.':hidden'});
+# If we get here, we are actually going to display the message - we don't know where and we don't know if we display
+# previous edits, but it counts as one entry
my $posttime = $contrib{$idx.':timestamp'};
if ($prevread <= $posttime) {
$$newpostsflag = 1;
@@ -988,7 +1057,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'} =~ /:/) {
@@ -1087,16 +1156,22 @@ sub build_posting_display {
@{$$namesort{$lastname}{$firstname}} = ("$idx");
}
if ($outputtarget ne 'tex') {
+ unless ($likes{$symb.':'.$idx.':likers'}=~/\,\Q$thisuser\E\,/) {
+ $sender.=' '.&discussion_link($symb,'','like',$idx,$$newpostsflag,$prevread,&group_args($group),&mt("Like this posting"));
+ }
+ unless ($likes{$symb.':'.$idx.':unlikers'}=~/\,\Q$thisuser\E\,/) {
+ $sender.=' '.&discussion_link($symb,'',,'unlike',$idx,$$newpostsflag,$prevread,&group_args($group),&mt("Unlike this posting"));
+ }
+ my $thislikes=$likes{$symb.':'.$idx.':likes'};
+ if ($thislikes>0) {
+ $sender.=' ('.&mt("[_1] likes",$thislikes).')';
+ } elsif ($thislikes<0) {
+ $sender.=' ('.&mt("[_1] unlikes",abs($thislikes)).')';
+ }
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.=
@@ -1129,7 +1195,7 @@ sub build_posting_display {
$sender .= &mt('Delete').'';
}
}
- } else {
+ } else {
if ($screenname) {
$sender=''.$screenname.'';
} else {
@@ -1156,33 +1222,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 = '';
@@ -1283,32 +1340,39 @@ sub build_posting_display {
unless ($$notshown{$idx} == 1) {
if ($prevread > 0 && $prevread <= $posttime) {
$$newitem{$idx} = 1;
- $$discussionitems[$idx] .= '
-
- '.&mt('NEW').' | ';
+ $$discussionitems[$idx] .= ''.&mt('NEW').' ';
} else {
$$newitem{$idx} = 0;
- $$discussionitems[$idx] .= '
-
- | ';
}
- $$discussionitems[$idx] .= ' '.
- ''.$subject.' '.
+ $$discussionitems[$idx] .= ''.$subject.' '.
$sender.' '.$vgrlink.' ('.
- &Apache::lonlocal::locallocaltime($posttime).') | ';
+ &Apache::lonlocal::locallocaltime($posttime).')';
if ($$dischash{$toggkey}) {
- $$discussionitems[$idx].=' '.
- $ctlink.' | ';
+ $$discussionitems[$idx].=' '.$ctlink;
+ }
+# Figure out size based on likes
+ my $thislikes=$likes{$symb.':'.$idx.':likes'};
+ my $likesize="100";
+ if ($thislikes>$twoplus) {
+ $likesize="200";
+ } elsif ($thislikes>$oneplus) {
+ $likesize="150";
}
- $$discussionitems[$idx].= ' '.
- $message.' ';
+ if ($thislikes<$twominus) {
+ $likesize="50";
+ } elsif ($thislikes<$oneminus) {
+ $likesize="75";
+ }
+ $$discussionitems[$idx].= '
'.
+ "".
+ $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].=' '.&mt('Earlier version(s) were posted on: ');
if ($contrib{$idx.':history'} =~ m/:/) {
@@ -1321,12 +1385,19 @@ sub build_posting_display {
$$discussionitems[$idx] .= ''.$version.'. - '.&Apache::lonlocal::locallocaltime($postversions[$i]).' ';
}
}
+# end of unless ($$notshown ...)
}
+# end of if ($message) ...
}
+# end of the else-branch of target being export
}
+# end of unless hidden or deleted
}
+# end of the loop over all discussion entries
}
+# end of "if there actually are any discussions
}
+# end of subroutine "build_posting_display"
}
sub filter_regexp {
@@ -1664,7 +1735,7 @@ END
$comment = &unescape($env{'form.comment'});
&process_attachments(\@currnewattach,\@currdelold,\@keepold);
}
- my $latexHelp=&Apache::loncommon::helpLatexCheatsheet(undef,undef,1);
+ my $latexHelp=&Apache::loncommon::helpLatexCheatsheet(undef,undef,1,($env{'form.modal'}?'popup':0));
my $send=&mt('Send');
my $alert = &mt('Please select a feedback type.');
my $js= < 'Resource Feedback and Discussion'}];
my %onload = ('onload' => 'window.focus();setposttype();');
+ my %parms=('add_entries' => \%onload);
+ if ($env{'form.modal'} ne 'yes') { 'bread_crumbs' => $brcrum }
my $start_page=
- &Apache::loncommon::start_page('Resource Feedback and Discussion',$js,
- {'add_entries' => \%onload,
- 'bread_crumbs' => $brcrum,});
+ &Apache::loncommon::start_page('Resource Feedback and Discussion',$js,\%parms);
if ($quote ne '') {
$quote = &HTML::Entities::decode($quote);
@@ -1734,14 +1805,18 @@ END
}
$quote=''.&Apache::lontexconvert::msgtexconverted($quote).' ';
}
-
+ my $header='';
+ unless ($env{'form.modal'}) {
+ $header="$restitle";
+ }
$r->print(<$restitle
+$header
|
|