--- loncom/interface/lonwhatsnew.pm 2005/04/11 12:20:23 1.6
+++ loncom/interface/lonwhatsnew.pm 2005/12/22 22:39:49 1.38.2.2
@@ -1,5 +1,5 @@
#
-# $Id: lonwhatsnew.pm,v 1.6 2005/04/11 12:20:23 raeburn Exp $
+# $Id: lonwhatsnew.pm,v 1.38.2.2 2005/12/22 22:39:49 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -35,8 +35,10 @@ use Apache::lonhtmlcommon();
use Apache::lonlocal;
use Apache::loncoursedata();
use Apache::lonnavmaps();
+use Apache::lonuserstate;
use Apache::Constants qw(:common :http);
use Time::Local;
+use GDBM_File;
#----------------------------
# handler
@@ -45,22 +47,57 @@ use Time::Local;
sub handler {
my $r = shift;
+ if ($r->header_only) {
+ &Apache::loncommon::content_type($r,'text/html');
+ $r->send_http_header;
+ return OK;
+ }
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['command']);
my $command = $env{'form.command'};
- if ($command eq '') {
- $command = "info";
- }
-
- $r->print(&display_header());
- if (! (($env{'request.course.fn'}) && (&Apache::lonnet::allowed('vsa',$env{'request.course.id'})))) {
- # Not in a course, or not allowed to modify parms
- $env{'user.error.msg'}="/adm/whatsnew:vsa:0:0:Cannot display student activity";
+ &Apache::loncommon::content_type($r,'text/html');
+ $r->send_http_header;
+ if (! (($env{'request.course.fn'}) && (&Apache::lonnet::allowed('bre',$env{'request.course.id'})))) {
+ # Not in a course, or not allowed to view action items
+ $env{'user.error.msg'}="/adm/whatsnew:bre:0:0:Cannot display what's new screen";
return HTTP_NOT_ACCEPTABLE;
}
- &display_main_box($r,$command);
+ my %checkallowed = (
+ coursediscussion => &Apache::lonnet::allowed('pch',$env{'request.course.id'}),
+ handgrading => &Apache::lonnet::allowed('mgr',$env{'request.course.id'}),
+ abovethreshold => &Apache::lonnet::allowed('vgr',$env{'request.course.id'}),
+ haserrors => &Apache::lonnet::allowed('opa',$env{'request.course.id'}),
+ versionchanges => &Apache::lonnet::allowed('opa',$env{'request.course.id'}),
+ coursenormalmail => 1,
+ coursecritmail => 1,
+ );
+
+ $r->print(&display_header($command,\%checkallowed));
+
+ &Apache::lonhtmlcommon::clear_breadcrumbs();
+ &Apache::lonhtmlcommon::add_breadcrumb
+ ({href=>'/adm/whatsnew',
+ text=>"Display Action Items"});
+ if (($command eq 'chgthreshold') && (&Apache::lonnet::allowed('vgr',$env{'request.course.id'}))) {
+ &Apache::lonhtmlcommon::add_breadcrumb
+ ({href=>'/adm/whatsnew?command=chgthreshold',
+ text=>"Change thresholds"});
+ $r->print(&Apache::lonhtmlcommon::breadcrumbs
+ (undef,'Course Action Items','Course_Action_Items_Thresholds'));
+ } elsif (($command eq 'chginterval') && (&Apache::lonnet::allowed('vgr',$env{'request.course.id'}))) {
+ &Apache::lonhtmlcommon::add_breadcrumb
+ ({href=>'/adm/whatsnew?command=chginterval',
+ text=>"Change interval"});
+ $r->print(&Apache::lonhtmlcommon::breadcrumbs
+ (undef,'Course Action Items','Course_Action_Items_Intervals'));
+ } else {
+ $r->print(&Apache::lonhtmlcommon::breadcrumbs
+ (undef,'Course Action Items','Course_Action_Items_Display'));
+ }
+ &display_main_box($r,$command,\%checkallowed);
+ return OK;
}
#------------------------------
@@ -70,66 +107,41 @@ sub handler {
#------------------------------
sub display_main_box {
- my ($r,$command) = @_;
+ my ($r,$command,$checkallowed) = @_;
my $domain=&Apache::loncommon::determinedomain();
- my $tabbg=&Apache::loncommon::designparm('coordinator.tabbg',$domain);
- $r->print(<
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Course Action Items
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-END_OF_BLOCK
- &display_nav_box($r,$command);
- $r->print('
');
- $r->print('');
-
- if ($command eq 'config') {
- &display_config_box($r);
+ my $function = &Apache::loncommon::get_users_function();
+ my $tabbg=&Apache::loncommon::designparm($function.'.tabbg',$domain);
+
+ $r->print('');
+
+ my %threshold_titles = (
+ av_attempts => 'Average number of attempts',
+ degdiff => 'Degree of difficulty',
+ numstudents => 'Total number of students with submissions',
+ );
+
+ my %interval_titles = (
+ -1 => 'since start of course',
+ 2592000 => 'since last month',
+ 604800 => 'since last week',
+ 86400 => 'since yesterday',
+ );
+
+ my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
+ my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
+
+ if (($command eq 'chgthreshold') &&
+ (&Apache::lonnet::allowed('vgr',$env{'request.course.id'}))) {
+ &display_threshold_config($r,$command,$tabbg,\%threshold_titles,
+ $cdom,$crs);
+ } elsif (($command eq 'chginterval') &&
+ (&Apache::lonnet::allowed('opa',$env{'request.course.id'}))) {
+ &display_interval_config($r,\%interval_titles);
} else {
- &display_actions_box($r);
+ &display_actions_box($r,$tabbg,$command,\%threshold_titles,
+ \%interval_titles,$cdom,$crs,$checkallowed);
}
$r->print(<
-
-
-
-
-
-
-
-
-
-
-
@@ -138,37 +150,6 @@ END_OF_BLOCK
END_OF_BLOCK
}
-#------------------------------
-# display_nav_box
-#
-# Display the navigation box
-#------------------------------
-
-sub display_nav_box {
- my ($r,$command) = @_;
- $r->print(''."\n");
- if ($command eq "info") {
- $r->print('');
- $r->print('Action Items ');
- $r->print(' ');
- } else {
- $r->print('');
- $r->print('Current Action Items ');
- $r->print(' ');
- }
- $r->print(' ');
- if ($command eq "config") {
- $r->print('');
- $r->print('Display options ');
- $r->print(' ');
- } else {
- $r->print('');
- $r->print('Display options ');
- $r->print(' ');
- }
- $r->print('
');
-}
-
#-------------------------------
# display_header
#
@@ -177,12 +158,36 @@ sub display_nav_box {
#-------------------------------
sub display_header{
+ my ($command,$checkallowed) = @_;
my $html=&Apache::lonxml::xmlbegin();
my $bodytag=&Apache::loncommon::bodytag('Course Action Items');
+ my $scripttag;
+ unless ($command eq 'chgthreshold' || $command eq 'chginterval') {
+ $scripttag = <<"END";
+
+';
+ }
return(<
Course Action Items
+$scripttag
$bodytag
ENDHEAD
@@ -196,329 +201,689 @@ ENDHEAD
#-------------------------------
sub display_actions_box() {
- my $r = shift;
+ my ($r,$tabbg,$command,$threshold_titles,$interval_titles,
+ $cdom,$crs,$checkallowed) = @_;
my $rowColor1 = "#ffffff";
my $rowColor2 = "#eeeeee";
- my $rowColor;
+
+ my $udom = $env{'user.domain'};
+ my $uname = $env{'user.name'};
+ my $cid = $env{'request.course.id'};
+
+ my %lt = &Apache::lonlocal::texthash(
+ 'yacc' => 'You are accessing an invalid course.',
+ 'gtfr' => 'Go to first resource',
+ 'chyp' => 'Change your preferences',
+ 'tsup' => 'to suppress display of this screen when accessing'.
+ ' this course in the future.',
+ 'hial' => 'Hide all',
+ 'shal' => 'Show all',
+ );
my %unread = ();
my %ungraded = ();
my %bombed = ();
+ my %triggered = ();
+ my %changed = ();
my @newmsgs = ();
my @critmsgs = ();
my @newdiscussions = ();
my @tograde = ();
my @bombs = ();
+ my @warnings = ();
+ my $msgcount = 0;
+ my $critmsgcount = 0;
- my $domain=&Apache::loncommon::determinedomain();
- my $function;
- if ($env{'request.role'}=~/^(cc|in|ta|ep)/) {
- $function='coordinator';
+ my %res_title = ();
+ my %show = ();
+ my $needitems = 0;
+ my $boxcount = 0;
+
+ my %threshold = (
+ av_attempts => 2,
+ degdiff => 0.5,
+ numstudents => 2,
+ );
+
+ unless ($cid) {
+ $r->print(''.$lt{'yacc'}.' ');
+ return;
+ }
+
+ if (tie(my %bighash,'GDBM_File',$env{'request.course.fn'}.'.db',
+ &GDBM_READER(),0640)) {
+ my $furl=$bighash{'first_url'};
+ $r->print(''.$lt{'gtfr'}.
+ ' '.
+ ' '.$lt{'chyp'}.' '.$lt{'tsup'}.' ');
+ untie(%bighash);
}
- if ($env{'request.role'}=~/^(su|dc|ad|li)/) {
- $function='admin';
+
+ my $result;
+
+ if ($command eq 'reset') {
+ $result = &process_reset($cdom,$crs);
+ } elsif ($command eq 'update') {
+ $result = &process_update($cdom,$crs,$threshold_titles);
+ } elsif ($command eq 'newinterval') {
+ $result = &store_interval_setting($uname,$udom,$cid,$interval_titles);
}
- my $pgbg=&Apache::loncommon::designparm($function.'.pgbg',$domain);
- my $tabbg=&Apache::loncommon::designparm($function.'.tabbg',$domain);
+ my $store_result=&store_display_settings($uname,$udom,$cid,$checkallowed);
- &getitems(\%unread,\%ungraded,\%bombed,\@newdiscussions,\@tograde,\@bombs);
- my ($msgcount,$critmsgcount) = &getmail(\@newmsgs,\@critmsgs);
+ unless ($store_result eq 'ok') {
+ &Apache::lonnet::logthis('Error storing whatsnew settings: '.
+ $store_result.' for '.'user '.$uname.':'.$udom.' in course '.$cid);
+ $result .= &mt('Unable to store visibility settings due to [_1]',
+ $store_result);
+ }
- unless ($env{'request.course.id'}) {
- $r->print('You are accessing an invalid course ');
- return;
+ if ($result) {
+ $r->print($result.' ');
}
+ $r->rflush();
- $r->print('Course Action Items ');
-## UNREAD COURSE DISCUSSION POSTS ##
- $r->print(<<"END");
-
-
-
-
- Unread course discussion posts:
-
-
-
-
-END
+ my %display_settings = &get_display_settings($uname,$udom,$cid);
+ my $timediff = $display_settings{$cid.':interval'};
+ unless (defined($timediff)) { $timediff = 604800; }
+ my $now = time;
+ my $interval = $$interval_titles{$timediff};
+ if ($timediff == -1) {
+ $timediff = time;
+ }
+ my $starttime = $now - $timediff;
+ my $countunread = 1;
+
+ my %headings = &Apache::lonlocal::texthash(
+ coursediscussion => 'Unread course discussion posts',
+ handgrading => 'Problems requiring handgrading',
+ haserrors => 'Problems with errors',
+ versionchanges => 'Resources in course with version changes '.$interval,
+ coursenormalmail => 'New course messages',
+ coursecritmail => 'New critical messages in course',
+ );
- if (@newdiscussions > 0) {
-# @newdiscussions = sort { &cmp_title($a,$b) } @newdiscussions;
- my $rowNum = 0;
- foreach my $ressymb (@newdiscussions) {
- my $forum_title = $unread{$ressymb}{'title'};
- my $feedurl=&Apache::lonfeedback::get_feedurl($ressymb);
- my $unreadnum = keys(%{$unread{$ressymb}});
- $unreadnum = $unreadnum - 2;
- if ($unreadnum > 0) {
- if ($rowNum %2 == 1) {
- $rowColor = $rowColor1;
- } else {
- $rowColor = $rowColor2;
- }
- $r->print(''.$forum_title.': '.$unreadnum.' ');
- $rowNum ++;
- }
- }
- } else {
- $r->print(' No unread posts in course discussions ');
+ if ($$checkallowed{'abovethreshold'}) {
+ &get_curr_thresholds(\%threshold,$cdom,$crs);
}
- $r->print('
');
-## UNGRADED ITEMS ##
- $r->print(<
-
-
-
- Problems requiring handgrading:
-
-
-
-END
+ $headings{'abovethreshold'} = &mt('Problems with av. attempts').' ≥ '.$threshold{'av_attempts'}.' '.&mt('or deg. difficulty').' ≥ '.$threshold{'degdiff'}.' '.&mt('and total number of students with submissions').' ≥ '.$threshold{'numstudents'};
- if (@tograde > 0) {
- $r->print('Problem Name Number ungraded ');
- my $rowNum = 0;
- foreach my $res (@tograde) {
- if ($rowNum %2 == 1) {
- $rowColor = $rowColor1;
- } else {
- $rowColor = $rowColor2;
+ my @actionorder = ('handgrading','haserrors','abovethreshold','versionchanges','coursediscussion','coursenormalmail','coursecritmail');
+
+ foreach my $key (keys(%{$checkallowed})) {
+ $show{$key} = 0;
+ if ($$checkallowed{$key}) {
+ unless ($display_settings{$cid.':'.$key} eq 'hide') {
+ $show{$key} = 1;
}
-
- $r->print(''.$ungraded{$res}{title}.' '.$ungraded{$res}{count}.' ');
- $rowNum ++;
}
- } else {
- $r->print(' No problems require handgrading ');
}
- $r->print('
');
- $r->print(' ');
-## MESSAGES ##
- $r->print(<
-
-
-
-
- New course messages
-
-
-
-
-END
- if ($msgcount > 0) {
- my $rowNum = 0;
- my $mailcount = 1;
- foreach my $msg (@newmsgs) {
- if ($rowNum %2 == 1) {
- $rowColor = $rowColor1;
- } else {
- $rowColor = $rowColor2;
+ foreach my $item (@actionorder) {
+ unless ($item eq 'coursenormalmail' || $item eq 'coursecritmail') {
+ if ($show{$item}) {
+ $needitems = 1;
+ last;
}
- $r->print(''.$mailcount.'. '.$msg->{'shortsub'}.' '.$msg->{'from'}.'@'.$msg->{'fromdom'}.' '.$msg->{'sendtime'}.' ');
- $rowNum ++;
- $mailcount ++;
}
- } else {
- $r->print('No new course messages ');
}
- $r->print('
');
+ if ($needitems) {
+ &getitems(\%unread,\%ungraded,\%bombed,\%triggered,\%changed,\@newdiscussions,\@tograde,\@bombs,\@warnings,$rowColor1,$rowColor2,\%threshold,$cdom,$crs,\%res_title,\%show,$starttime,$countunread);
+ }
+ if ($show{'coursenormalmail'}) {
+ &getnormalmail(\@newmsgs);
+ }
+ if ($show{'coursecritmail'}) {
+ &getcritmail(\@critmsgs);
+ }
- $r->print(<
-
-
-
-
- New critical messages in course
-
-
-
-END
+ $r->print(qq|$lt{'hial'}
+ $lt{'shal'}
+ ');
+
+ my $displayed = 0;
+ my $totalboxes = keys(%{$checkallowed});
+ my $halfway = int($totalboxes/2) + $totalboxes%2;
+ foreach my $actionitem (@actionorder) {
+ if ($$checkallowed{$actionitem}) {
+ if ($displayed == $halfway) {
+ $r->print(' ');
}
- $r->print(' '.$mailcount.'. '.$msg->{'shortsub'}.' '.$msg->{'from'}.'@'.$msg->{'fromdom'}.' '.$msg->{'sendtime'}.' ');
- $rowNum ++;
- $mailcount ++;
+ &display_launcher($r,$actionitem,$checkallowed,$tabbg,$rowColor1,$rowColor2,\%show,\%headings,\%res_title,\@tograde,\%ungraded,\@bombs,\%bombed,\%changed,\@warnings,\%triggered,\@newdiscussions,\%unread,$msgcount,\@newmsgs,$critmsgcount,\@critmsgs,$interval,$countunread);
+ $displayed ++;
}
- } else {
- $r->print('No unread critical messages in course ');
}
-
- $r->print('
');
+ $r->print('
+
+
+
+
+
+
+ ');
+}
-## BOMBS ##
- $r->print(<
+#-------------------------------
+# display_threshold_config
+#
+# Display the threshold setting screen
+#
+#-------------------------------
+
+sub display_threshold_config {
+ my ($r,$command,$tabbg,$threshold_titles,$cdom,$crs) = @_;
+ my %threshold = ();
+ my $rowColor1 = "#ffffff";
+ my $rowColor2 = "#eeeeee";
+ my $rowColor;
+
+ my @thresholditems = ("av_attempts","degdiff","numstudents");
+ my %threshold_titles = (
+ av_attempts => 'Average number of attempts',
+ degdiff => 'Degree of difficulty',
+ numstudents => 'Total number of students with submissions',
+ );
+ &get_curr_thresholds(\%threshold,$cdom,$crs);
+
+ $r->print(''.
+ ' '."\n");
+ $r->print(''.$lt{'reso'}.' '.$lt{'part'}.' '.$lt{'nust'}.' '.$lt{'avat'}.' '.$lt{'dedi'}.' '.$lt{'lare'}.' '.$lt{'reco'}.' ');
+ foreach my $res (@{$warnings}) {
+ if ($warningnum %2 == 1) {
+ $rowColor = $rowColor1;
+ } else {
+ $rowColor = $rowColor2;
+ }
+ my ($map,$id,$url)=&Apache::lonnet::decode_symb($res);
+ my $linkurl=&Apache::lonnet::clutter($url);
+ my $rowspan;
+ if ($$triggered{$res}{numparts} > 1) {
+ $rowspan = 'rowspan="'.$$triggered{$res}{numparts}.'"';
+ }
+ $linkurl .= '?symb='.&Apache::lonnet::escape($res);
+ $r->print(''.$$triggered{$res}{title}.' '.$$triggered{$res}{text});
+ $warningnum ++;
+ }
+ $r->print(' ');
+ } else {
+ $r->print(''.$lt{'nopr'}.' ');
+ }
+}
+
+sub display_versionchanges {
+ my ($r,$changed,$res_title,$rowColor1,$rowColor2,$interval) = @_;
+ my %lt = &Apache::lonlocal::texthash(
+ 'reso' => 'Resource',
+ 'revd' => 'Last revised',
+ 'newv' => 'New version',
+ 'veru' => 'Version used',
+ 'noup' => 'No updated versions',
+ );
+ my $rowColor;
+ if (keys(%{$changed}) > 0) {
+ $r->print(''.$lt{'reso'}.' '.$lt{'revd'}.' '.$lt{'newv'}.' '.$lt{'veru'}.' ');
+
+
+ my @changes = sort { &cmp_title($a,$b,$res_title) } keys(%{$changed});
+ my $changenum = 0;
+ foreach my $item (@changes) {
+ if ($changenum %2 == 1) {
+ $rowColor = $rowColor1;
+ } else {
+ $rowColor = $rowColor2;
+ }
+ my ($map,$id,$url)=&Apache::lonnet::decode_symb($item);
+ my $linkurl=&Apache::lonnet::clutter($url);
+ $linkurl .= '?symb='.&Apache::lonnet::escape($item);
+
+ $r->print(''.$$res_title{$item}.' '.$$changed{$item}{'revdate'}.' '.$$changed{$item}{'current'}.' '.$$changed{$item}{'version'}.' ');
+ $changenum ++;
+ }
+ } else {
+ $r->print(''.$lt{'noup'}.' '.$interval.' ');
+ }
+ return;
+}
+
+sub display_coursediscussion {
+ my ($r,$newdiscussions,$unread,$countunread,$res_title,$rowColor1,
+ $rowColor2) = @_;
+ my %lt = &Apache::lonlocal::texthash(
+ 'loca' => 'Location',
+ 'type' => 'Type',
+ 'numn' => 'Number of new posts',
+ 'noun' => 'No unread posts in course discussions',
+ 'tmlp' => 'Time of last post',
+ );
+ my $rowColor;
+ if (@{$newdiscussions} > 0) {
+ $r->print(''.$lt{'loca'}.
+ ' '.$lt{'type'}.
+ ' ');
+ if ($countunread) {
+ $r->print(''.$lt{'tmlp'}.' '.
+ ''.$lt{'numn'}.
+ ' ');
+ } else {
+ $r->print(''.$lt{'tmlp'}.
+ ' ');
+ }
+ $r->print(" \n");
+ @{$newdiscussions} = sort { &cmp_title($a,$b,$res_title) }
+ @{$newdiscussions};
+ my $rowNum = 0;
+ foreach my $ressymb (@{$newdiscussions}) {
+ my $forum_title = $$unread{$ressymb}{'title'};
+ my $type = 'Resource';
+ my $feedurl=&Apache::lonfeedback::get_feedurl($ressymb);
+ if ($feedurl =~ /bulletinboard/) {
+ $type = 'Bulletin Board';
+ }
+ if ($rowNum %2 == 1) {
+ $rowColor = $rowColor1;
+ } else {
+ $rowColor = $rowColor2;
+ }
+ my $lastpost = &Apache::lonnavmaps::timeToHumanString(
+ $$unread{$ressymb}{'lastpost'});
+ $r->print(''.$forum_title.' '.$type.' ');
+ if ($countunread) {
+ my $unreadnum = $$unread{$ressymb}{'unreadcount'};
+ $r->print(''.$lastpost.' '.
+ '',$unreadnum.' ');
+ } else {
+ $r->print(''.$lastpost.' ');
+ }
+ $r->print(" \n");
+ $rowNum ++;
+ }
+ } else {
+ $r->print(' '.
+ $lt{'noun'}.' ');
+ }
+}
+
+sub display_coursenormalmail {
+ my ($r,$msgcount,$newmsgs,$rowColor1,$rowColor2) = @_;
+ my $rowColor;
+ if ($msgcount > 0) {
+ $r->print(''.&mt('Number').' '.&mt('Subject').' '.&mt('Sender').' '.&mt('Date/Time').' ');
+ my $rowNum = 0;
+ my $mailcount = 1;
+ foreach my $msg (@{$newmsgs}) {
+ if ($rowNum %2 == 1) {
+ $rowColor = $rowColor1;
+ } else {
+ $rowColor = $rowColor2;
+ }
+ $r->print(''.$mailcount.'. '.$msg->{'shortsub'}.' '.$msg->{'from'}.'@'.$msg->{'fromdom'}.' '.$msg->{'sendtime'}.' ');
+ $rowNum ++;
+ $mailcount ++;
+ }
+ } else {
+ $r->print(''.&mt('No new course messages').' ');
+ }
+}
+
+sub display_coursecritmail {
+ my ($r,$critmsgcount,$critmsgs,$rowColor1,$rowColor2) = @_;
+ my $rowColor;
+ if ($critmsgcount > 0) {
+ $r->print(''.&mt('Number').' '.&mt('Subject').' '.&mt('Sender').' '.&mt('Date/Time').' ');
+ my $rowNum = 0;
+ my $mailcount = 1;
+ foreach my $msg (@{$critmsgs}) {
+ if ($rowNum %2 == 1) {
+ $rowColor = $rowColor1;
+ } else {
+ $rowColor = $rowColor2;
+ }
+ $r->print(''.$mailcount.'. '.$msg->{'shortsub'}.' '.$msg->{'from'}.'@'.$msg->{'fromdom'}.' '.$msg->{'sendtime'}.' ');
+ $rowNum ++;
+ $mailcount ++;
+ }
+ } else {
+ $r->print(''.&mt('No unread critical messages in course').' ');
+ }
}
sub cmp_title {
- my ($atitle,$btitle) = (lc($_[0]->compTitle),lc($_[1]->compTitle));
+ my ($a,$b,$res_title) = @_;
+ my ($atitle,$btitle) = (lc($$res_title{$a}),lc($$res_title{$b}));
$atitle=~s/^\s*//;
$btitle=~s/^\s*//;
return $atitle cmp $btitle;
}
+sub get_display_settings {
+ my ($uname,$udom,$cid) = @_;
+ my %settings = &Apache::lonnet::dump('nohist_whatsnew',$udom,$uname,$cid);
+ my ($tmp) = keys(%settings);
+ if ($tmp=~/^(con_lost|error|no_such_host)/i) {
+ %settings = ();
+ unless ($tmp =~ /^error: 2 /) {
+ &Apache::lonnet::logthis('Error retrieving whatsnew settings: '.
+ $tmp.' for '.$uname.':'.$udom.
+ ' for course: '.$cid);
+
+ }
+ }
+ return %settings;
+}
+
+sub store_display_settings {
+ my ($uname,$udom,$cid,$checkallowed) = @_;
+ my %whatsnew_settings;
+ my $result;
+ foreach my $key (keys(%{$checkallowed})) {
+ if (exists($env{'form.display_'.$key})) {
+ unless ($env{'form.display_'.$key} eq '') {
+ $whatsnew_settings{$cid.':'.$key} = $env{'form.display_'.$key};
+ }
+ }
+ }
+ if (keys(%whatsnew_settings)) {
+ $result = &Apache::lonnet::put('nohist_whatsnew',\%whatsnew_settings,
+ $udom,$uname);
+ } else {
+ $result = 'ok';
+ }
+ return $result;
+}
+
+sub store_interval_setting {
+ my ($uname,$udom,$cid,$interval_titles) = @_;
+ my %interval_settings = ();
+ my $result;
+ if (defined($env{'form.interval'})) {
+ $interval_settings{$cid.':interval'} = $env{'form.interval'};
+ my $outcome = &Apache::lonnet::put('nohist_whatsnew',
+ \%interval_settings,$udom,$uname);
+ if ($outcome eq 'ok') {
+ $result = &mt('Interval set to version changes [_1]',
+ ''.$$interval_titles{$env{'form.interval'}}.' ');
+
+ } else {
+ &Apache::lonnet::logthis('Error storing whatsnew interval setting'.
+ ' '.$outcome.' for '.$uname.':'.$udom.' in course '.$cid);
+ $result = &mt('Unable to set interval to [_1] due to [_2].',
+ ''.$$interval_titles{$env{'form.interval'}}.' ',
+ ''.$outcome.' . ');
+ }
+ }
+ return $result;
+}
+
+sub start_box {
+ my ($r,$tabbg,$show,$heading,$caller) = @_;
+ my %lt = &Apache::lonlocal::texthash(
+ chth => 'Change thresholds?',
+ chin => 'Change interval?',
+ );
+ my $showhide;
+ if ($$show{$caller}) {
+ $showhide = 'Hide ';
+
+ } else {
+ $showhide = 'Show ';
+ }
+
+ $r->print('
+
+
+
+
+
+
+
+
+ '.$$heading{$caller}.'
+ '.$showhide.'
+
+
+
+ ');
+ if (($caller eq 'abovethreshold') && ($$show{$caller})) {
+ $r->print('
+
+ '.$lt{'chth'}.'
+ ');
+ } elsif (($caller eq 'versionchanges') && ($$show{$caller})) {
+ $r->print('
+
+ '.$lt{'chin'}.'
+ ');
+ }
+ $r->print('
+
+
+
+');
+ return;
+}
+
+sub end_box {
+ my ($r) = shift;
+ $r->print('
+
+
+
+
+
+
+
');
+ return;
+}
+
+1;