--- loncom/interface/lonfeedback.pm 2012/01/06 20:05:59 1.326
+++ loncom/interface/lonfeedback.pm 2012/01/10 00:54:05 1.331
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Feedback
#
-# $Id: lonfeedback.pm,v 1.326 2012/01/06 20:05:59 www Exp $
+# $Id: lonfeedback.pm,v 1.331 2012/01/10 00:54:05 www Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -759,7 +759,7 @@ END
sub discussion_link {
- my ($ressymb,$linktext,$cmd,$item,$flag,$prev,$adds)=@_;
+ my ($ressymb,$linktext,$cmd,$item,$flag,$prev,$adds,$title)=@_;
my $link='/adm/feedback?inhibitmenu=yes&modal=yes&'.$cmd.'='.&escape($ressymb).':::'.$item;
if ($flag) { $link .= '&previous='.$prev; }
if ($adds) { $link .= $adds; }
@@ -769,7 +769,7 @@ sub discussion_link {
$width=300;
$height=200;
}
- return &Apache::loncommon::modal_link($link,$linktext,$width,$height);
+ return &Apache::loncommon::modal_link($link,$linktext,$width,$height,undef,undef,$title);
}
@@ -787,10 +787,12 @@ sub send_feedback_link {
sub send_message_link {
my ($ressymb) = @_;
my $output = ''.
- '
';
+ &discussion_link($ressymb,
+ '
',
+ 'sendmessageonly').
+ '';
return $output;
}
@@ -827,7 +829,17 @@ sub action_links_bar {
$discussion .= '&previous='.$prevread;
}
$discussion .= &group_args($group);
- $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 .='
-
+
$lt{'note'}
-$lt{'title'}:
+$lt{'title'}:
ENDDISCUSS
if ($env{'form.origpage'}) {
@@ -1145,10 +1157,10 @@ sub build_posting_display {
}
if ($outputtarget ne 'tex') {
unless ($likes{$symb.':'.$idx.':likers'}=~/\,\Q$thisuser\E\,/) {
- $sender.=' '.&discussion_link($symb,&mt('Like'),'like',$idx,$$newpostsflag,$prevread,&group_args($group));
+ $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,&mt('Unlike'),'unlike',$idx,$$newpostsflag,$prevread,&group_args($group));
+ $sender.=' '.&discussion_link($symb,' ',,'unlike',$idx,$$newpostsflag,$prevread,&group_args($group),&mt("Unlike this posting"));
}
my $thislikes=$likes{$symb.':'.$idx.':likes'};
if ($thislikes>0) {
@@ -2713,8 +2725,8 @@ sub screen_header {
unless (($env{'form.replydisc'}) || ($env{'form.editdisc'})) {
if (($feedurl=~/^\/res\//) && ($feedurl!~/^\/res\/adm/) && ($env{'user.adv'})) {
$msgoptions=
- '';
+ ' ';
}
my %optionhash=();
foreach my $type ('question','comment','policy') {
@@ -2722,20 +2734,20 @@ sub screen_header {
}
if (&feedback_available(1)) {
$msgoptions.=
- '';
+ ' ';
}
if (&feedback_available(0,1)) {
$msgoptions.=
- '';
+ ' ';
}
if (&feedback_available(0,0,1)) {
$msgoptions.=
- ' '.
+ ' '.
($optionhash{'policy'}?$optionhash{'policy'}:$crspolicy).
- ' ';
+ ' ';
}
}
if (($env{'request.course.id'}) && (!$env{'form.sendmessageonly'})) {
@@ -2923,7 +2935,7 @@ sub storefeedbackpoints {
my %record=('grader_user' => $env{'user.name'},
'grader_domain' => $env{'user.domain'},
'points' => $points);
- return &Apache::lonnet::cstore(\%record,'_feedback');
+ return &Apache::lonnet::cstore(\%record,'_feedback',$course,$udom,$uname);
}
# Store feedback "likes"
@@ -2943,7 +2955,7 @@ sub storefeedbacklikes {
'likes_domain' => $env{'user.domain'},
'likes' => $likes,
'totallikes' => $totallikes);
- return &Apache::lonnet::cstore(\%newrecord,'_feedback');
+ return &Apache::lonnet::cstore(\%newrecord,'_feedback',$course,$udom,$uname);
}
@@ -3076,9 +3088,31 @@ sub getdiscussionrecords {
sub getdiscussionstats {
my %record=&getdiscussionrecords(@_);
- return ($record{'subnumber'},$record{'points'},$record{'totallikes'});
+ return ($record{'subnumber'},$record{'points'},$record{'totallikes'},$record{'totalvotes'});
}
+# Calculate discussion karma
+
+sub calcdiscussionkarma {
+ my ($subs,$pts,$likes,$votes)=&getdiscussionstats(@_);
+ my $karma=0;
+ if ($votes>0) {
+ $karma=int(.1+5.*(1.-exp(-$subs/10.))*$likes/$votes);
+ if ($karma<0) { $karma=0; }
+ if ($karma>5) { $karma=5; }
+ }
+ return $karma;
+}
+
+# Update karma
+
+sub updatekarma {
+ my ($uname,$udom,$course)=@_;
+ unless ($uname) { $uname=$env{'user.name'}; }
+ unless ($udom) { $udom=$env{'user.domain'}; }
+ unless ($course) { $course=$env{'request.course.id'}; }
+ my $karma=&calcdiscussionkarma($uname,$udom,$course);
+}
# Store discussion credit
@@ -3091,7 +3125,7 @@ sub storediscussionpoints {
my %record=('grader_user' => $env{'user.name'},
'grader_domain' => $env{'user.domain'},
'points' => $points);
- return &Apache::lonnet::cstore(\%record,'_discussion');
+ return &Apache::lonnet::cstore(\%record,'_discussion',$course,$udom,$uname);
}
# Store discussion "likes"
@@ -3106,12 +3140,15 @@ sub storediscussionlikes {
unless ($course) { $course=$env{'request.course.id'}; }
my %record=&getdiscussionrecords($uname,$udom,$course);
my $totallikes=$record{'totallikes'};
+ my $totalvotes=$record{'totalvotes'};
$totallikes+=$likes;
+ $totalvotes++;
my %newrecord=('likes_user' => $env{'user.name'},
'likes_domain' => $env{'user.domain'},
'likes' => $likes,
- 'totallikes' => $totallikes);
- return &Apache::lonnet::cstore(\%newrecord,'_discussion');
+ 'totallikes' => $totallikes,
+ 'totalvotes' => $totalvotes);
+ return &Apache::lonnet::cstore(\%newrecord,'_discussion',$course,$udom,$uname);
}
sub get_discussion_info {
@@ -3642,7 +3679,7 @@ sub handler {
# --------------------------- Get query string for limited number of parameters
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
- ['like','unlike','modal','hide','unhide','deldisc','postdata','preview','replydisc','editdisc','cmd','symb','onlyunread','allposts','onlyunmark','previous','markread','markonread','markondisp','toggoff','toggon','modifydisp','changes','navtime','navmaps','navurl','sortposts','applysort','rolefilter','statusfilter','sectionpick','groupick','posterlist','userpick','attach','origpage','currnewattach','deloldattach','keepold','allversions','export','sendmessageonly','group','ref']);
+ ['like','unlike','modal','hide','unhide','deldisc','undeleteall','postdata','preview','replydisc','editdisc','cmd','symb','onlyunread','allposts','onlyunmark','previous','markread','markonread','markondisp','toggoff','toggon','modifydisp','changes','navtime','navmaps','navurl','sortposts','applysort','rolefilter','statusfilter','sectionpick','groupick','posterlist','userpick','attach','origpage','currnewattach','deloldattach','keepold','allversions','export','sendmessageonly','group','ref']);
my $group = $env{'form.group'};
my %attachmax = (
text => &mt('(128 KB max size)'),
@@ -4075,6 +4112,24 @@ ENDREDIR
&Apache::loncommon::end_page();
$r->print($start_page.$discussion.$end_page);
return OK;
+
+ } elsif ($env{'form.undeleteall'}) {
+ &Apache::loncommon::content_type($r,'text/html');
+ $r->send_http_header;
+ my ($symb,$feedurl) = &get_feedurl_and_clean_symb($env{'form.undeleteall'});
+ $r->print(&Apache::loncommon::start_page('Undelete all deleted discussion entries'));
+ if (&Apache::lonnet::allowed('rin',$env{'request.course.id'})) {
+ if (&Apache::lonnet::store({'deleted' => ''},$symb,$env{'request.course.id'},
+ $env{'course.'.$env{'request.course.id'}.'.domain'},
+ $env{'course.'.$env{'request.course.id'}.'.num'}) eq 'ok') {
+ $r->print(&Apache::lonhtmlcommon::confirm_success(&mt("Undeleted all entries")));
+ } else {
+ $r->print(&Apache::lonhtmlcommon::confirm_success(&mt("Failed to undelete entries"),1));
+ }
+ $r->print(" ".&mt("Return and reload")."");
+ }
+ $r->print(&Apache::loncommon::end_page());
+ return OK;
} else {
# ------------------------------------------------------------- Normal feedback
my $feedurl=$env{'form.postdata'};
@@ -4090,6 +4145,8 @@ ENDREDIR
$symb=(split(/\:\:\:/,$env{'form.editdisc'}))[0];
} elsif ($env{'form.origpage'}) {
$symb="";
+ } elsif ($env{'form.sendmessageonly'}) {
+ $symb=(split(/\:\:\:/,$env{'form.sendmessageonly'}))[0];
} else {
$symb=&Apache::lonnet::symbread($feedurl);
}
|