--- loncom/interface/lonwhatsnew.pm 2005/04/29 14:54:18 1.12 +++ loncom/interface/lonwhatsnew.pm 2005/12/22 22:39:49 1.38.2.2 @@ -1,5 +1,5 @@ # -# $Id: lonwhatsnew.pm,v 1.12 2005/04/29 14:54:18 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 @@ -54,34 +56,48 @@ sub handler { my $command = $env{'form.command'}; - if ($command eq '') { - $command = "info"; - } - &Apache::loncommon::content_type($r,'text/html'); $r->send_http_header; - $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"; + 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; } + 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(); - if ($command eq 'config') { + &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=config', - text=>"Configure display"}); + ({href=>'/adm/whatsnew?command=chgthreshold', + text=>"Change thresholds"}); $r->print(&Apache::lonhtmlcommon::breadcrumbs - (undef,'Course Action Items','Course_Action_Items_Config')); - } else { + (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=info', - text=>"Display Action Items"}); + ({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); + &display_main_box($r,$command,\%checkallowed); + return OK; } #------------------------------ @@ -91,33 +107,39 @@ 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); - my $selconfig; - my $selinfo; - if ($command eq 'config') { - $selinfo = 'selected="selected"'; - } else { - $selconfig = 'selected="selected"'; - } - my $picker = (' -
'); - + my $function = &Apache::loncommon::get_users_function(); + my $tabbg=&Apache::loncommon::designparm($function.'.tabbg',$domain); + $r->print('');
-
- if ($command eq 'config') {
- &display_config_box($r,$picker);
+
+ 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,$picker);
+ &display_actions_box($r,$tabbg,$command,\%threshold_titles,
+ \%interval_titles,$cdom,$crs,$checkallowed);
}
$r->print(< '); + return; } - if ($env{'request.role'}=~/^(su|dc|ad|li)/) { - $function='admin'; + + 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); + } + + 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,\%triggered,\@newdiscussions,\@tograde,\@bombs,\@warnings,$rowColor1,$rowColor2); - 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(' '); - return; + if ($result) { + $r->print($result.' '); } + $r->rflush(); - $r->print(''.$picker.'
'); -## BOMBS ## - $r->print(<<"END"); -
'); -# DEGDIFF AND AV. TRIES TRIGGERS - $r->print(<<"END"); -
'); - $r->print(' | ');
-
-## UNREAD COURSE DISCUSSION POSTS ##
- $r->print(<<"END");
-
'); -## MESSAGES ## - $r->print(<
- |
|
New critical messages in course | -||||||||||||
-
|
');
+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(' |