--- loncom/interface/lonwhatsnew.pm 2005/12/05 19:27:53 1.35 +++ loncom/interface/lonwhatsnew.pm 2005/12/22 03:39:39 1.42 @@ -1,5 +1,5 @@ # -# $Id: lonwhatsnew.pm,v 1.35 2005/12/05 19:27:53 raeburn Exp $ +# $Id: lonwhatsnew.pm,v 1.42 2005/12/22 03:39:39 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -52,41 +52,69 @@ sub handler { $r->send_http_header; return OK; } - &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['command']); + &Apache::loncommon::get_unprocessed_cgi( + $ENV{'QUERY_STRING'},['command','refpage']); - my $command; - if ($env{'form.action'} eq 'reset') { - $command = 'reset'; - } elsif ($env{'form.action'} eq 'update') { - $command = 'update'; - } else { - $command = $env{'form.command'}; - } + my $command = $env{'form.command'}; + my $refpage = $env{'form.refpage'}; &Apache::loncommon::content_type($r,'text/html'); $r->send_http_header; - $r->print(&display_header($command)); - 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"; + my $crsid = $env{'request.course.id'}; + $crsid =~ s/_/\//; + if ((!($env{'request.course.fn'})) || + (!(&Apache::lonnet::allowed('whn', + $env{'request.course.id'})))) { + # Not in a course, or no role in course + $env{'user.error.msg'}="/adm/whatsnew::whn:0:0:Cannot display what's new page"; 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(); + &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=threshold', + ({href=>'/adm/whatsnew?command=chgthreshold&refpage='.$refpage, text=>"Change thresholds"}); $r->print(&Apache::lonhtmlcommon::breadcrumbs - (undef,'Course Action Items','Course_Action_Items_Thresholds')); - } else { + (undef,"What's New?",'Course_Action_Items_Thresholds')); + } elsif (($command eq 'chginterval') && (&Apache::lonnet::allowed('vgr',$env{'request.course.id'}))) { &Apache::lonhtmlcommon::add_breadcrumb - ({href=>'/adm/whatsnew', - text=>"Display Action Items"}); + ({href=>'/adm/whatsnew?command=chginterval&refpage='.$refpage, + text=>"Change interval"}); + $r->print(&Apache::lonhtmlcommon::breadcrumbs + (undef,"What's New?",'Course_Action_Items_Intervals')); + } elsif (($command eq 'chgdisc') && (&Apache::lonnet::allowed('pch',$env{'request.course.id'}))) { + &Apache::lonhtmlcommon::add_breadcrumb + ({href=>'/adm/whatsnew?command=chgdisc&refpage='.$refpage, + text=>"Change discussion display"}); + $r->print(&Apache::lonhtmlcommon::breadcrumbs + (undef,"What's New?",'Course_Action_Items_Intervals')); + } elsif ($command eq 'courseinit') { + &Apache::lonhtmlcommon::add_breadcrumb + ({href=>'/adm/whatsnew?command=courseinit&refpage='.$refpage, + text=>"Course initialization preference"}); $r->print(&Apache::lonhtmlcommon::breadcrumbs - (undef,'Course Action Items','Course_Action_Items_Display')); + (undef,"What's New?",'Course_Action_Items_Initialization')); + } else { + $r->print(&Apache::lonhtmlcommon::breadcrumbs + (undef,"What's New?",'Course_Action_Items_Display')); } - &display_main_box($r,$command); + &display_main_box($r,$command,$refpage,\%checkallowed); return OK; } @@ -97,23 +125,49 @@ sub handler { #------------------------------ sub display_main_box { - my ($r,$command) = @_; + my ($r,$command,$refpage,$checkallowed) = @_; my $domain=&Apache::loncommon::determinedomain(); - my $tabbg=&Apache::loncommon::designparm('coordinator.tabbg',$domain); + my $function = &Apache::loncommon::get_users_function(); + my $tabbg=&Apache::loncommon::designparm($function.'.tabbg',$domain); $r->print('
');
- my %threshold_titles = (
+ my %threshold_titles = &Apache::lonlocal::texthash (
av_attempts => 'Average number of attempts',
degdiff => 'Degree of difficulty',
numstudents => 'Total number of students with submissions',
);
+
+ my %interval_titles = &Apache::lonlocal::texthash (
+ -1 => 'since start of course',
+ 2592000 => 'since last month',
+ 604800 => 'since last week',
+ 86400 => 'since yesterday',
+ );
+
+ my %initpage = &Apache::lonlocal::texthash (
+ firstres => 'first resource in the course',
+ whatsnew => "what's new? page",
+ userpref => 'your general user preferences',
+ coursespecific => 'specific setting for this course',
+ );
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_config_box($r,$command,$tabbg,\%threshold_titles,$cdom,$crs);
+ if (($command eq 'chgthreshold') &&
+ (&Apache::lonnet::allowed('vgr',$env{'request.course.id'}))) {
+ &display_threshold_config($r,$refpage,$tabbg,\%threshold_titles,
+ $cdom,$crs);
+ } elsif (($command eq 'chginterval') &&
+ (&Apache::lonnet::allowed('opa',$env{'request.course.id'}))) {
+ &display_interval_config($r,$refpage,\%interval_titles);
+ } elsif (($command eq 'chgdisc') &&
+ (&Apache::lonnet::allowed('pch',$env{'request.course.id'}))) {
+ &display_discussion_config($r,$refpage);
+ } elsif ($command eq 'courseinit') {
+ &courseinit_config($r,$refpage,\%initpage);
} else {
- &display_actions_box($r,$command,\%threshold_titles,$cdom,$crs);
+ &display_actions_box($r,$tabbg,$command,$refpage,\%threshold_titles,
+ \%interval_titles,\%initpage,$cdom,$crs,$checkallowed);
}
$r->print(< '); + unless ($cid) { + $r->print(' '); return; } - 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, - ); + if ($refpage eq 'start') { + if (tie(my %bighash,'GDBM_File',$env{'request.course.fn'}.'.db', + &GDBM_READER(),0640)) { + my $furl=$bighash{'first_url'}; + untie(%bighash); + $r->print(''.$lt{'gtfr'}. + ' '); + } + } + $r->print($lt{'pgse'}.' '.&mt('Currently: [_1]',''.$currinit.''). + ' '); + + if ($command eq 'reset') { + $result = &process_reset($cdom,$crs); + } elsif ($command eq 'update') { + $result = &process_update($uname,$udom,$threshold_titles); + } elsif ($command eq 'newinterval') { + $result = &store_interval_setting($uname,$udom,$cid,$interval_titles); + } elsif ($command eq 'newdiscconf') { + $result = &store_discussion_setting($uname,$udom,$cid); + } + + my $store_result=&store_display_settings($uname,$udom,$cid,$checkallowed); + + 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); + } - my $timediff = 604800; - my %display_settings = &get_display_settings(); + if ($result) { + $r->print($result.' '); + } + $r->rflush(); + + + my %display_settings = &get_display_settings($uname,$udom,$cid); + my $timediff = $display_settings{$cid.':interval'}; + unless (defined($timediff)) { $timediff = 604800; } my $now = time; - my %intervals = ( - -1 => 'since start of course', - 2592000 => 'since last month', - 604800 => 'since last week', - 86400 => 'since yesterday', - ); - my $interval = $intervals{$timediff}; + my $interval = $$interval_titles{$timediff}; if ($timediff == -1) { $timediff = time; } my $starttime = $now - $timediff; + my $countunread = $display_settings{$cid.':countunread'}; + unless (defined($countunread)) { + $countunread = 'on'; + } 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 message', + coursenormalmail => 'New course messages', coursecritmail => 'New critical messages in course', ); - if ($checkallowed{'abovethreshold'}) { - &get_curr_thresholds(\%threshold,$cdom,$crs); + if ($$checkallowed{'abovethreshold'}) { + &get_curr_thresholds(\%threshold,$uname,$udom,$cid,$cdom,$crs); } $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'}; my @actionorder = ('handgrading','haserrors','abovethreshold','versionchanges','coursediscussion','coursenormalmail','coursecritmail'); - foreach my $key (keys(%checkallowed)) { + foreach my $key (keys(%{$checkallowed})) { $show{$key} = 0; - if ($checkallowed{$key}) { - unless ($display_settings{$key} eq 'off') { + if ($$checkallowed{$key}) { + unless ($display_settings{$cid.':'.$key} eq 'hide') { $show{$key} = 1; } } @@ -258,28 +381,8 @@ sub display_actions_box() { } } - - if (tie(my %bighash,'GDBM_File',$env{'request.course.fn'}.'.db', - &GDBM_READER(),0640)) { - my $furl=$bighash{'first_url'}; - $r->print('Go to first resource Change your preferences to suppress display of this screen when accessing courses as Course Coordinator in the future. '); - untie(%bighash); - } - - my $result; - - if ($command eq 'reset') { - $result = &process_reset($cdom,$crs); - } elsif ($command eq 'update') { - $result = &process_update($cdom,$crs,$threshold_titles); - } - if ($result) { - $r->print($result.' '); - } - $r->rflush(); - if ($needitems) { - &getitems(\%unread,\%ungraded,\%bombed,\%triggered,\%changed,\@newdiscussions,\@tograde,\@bombs,\@warnings,$rowColor1,$rowColor2,\%threshold,$cdom,$crs,\%res_title,\%show,$starttime); + &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); @@ -288,19 +391,31 @@ sub display_actions_box() { &getcritmail(\@critmsgs); } - $r->print(qq|Hide All Show All|); + $r->print(qq|$lt{'hial'} + $lt{'shal'} + |