--- loncom/interface/lonwhatsnew.pm 2008/04/30 23:52:00 1.77 +++ loncom/interface/lonwhatsnew.pm 2009/12/14 22:24:31 1.98.2.1 @@ -1,5 +1,5 @@ # -# $Id: lonwhatsnew.pm,v 1.77 2008/04/30 23:52:00 raeburn Exp $ +# $Id: lonwhatsnew.pm,v 1.98.2.1 2009/12/14 22:24:31 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -42,6 +42,7 @@ use Time::Local; use GDBM_File; use lib '/home/httpd/lib/perl/'; use LONCAPA; +use HTML::Entities; #---------------------------- # handler @@ -99,7 +100,7 @@ sub handler { &Apache::lonhtmlcommon::clear_breadcrumbs(); &Apache::lonhtmlcommon::add_breadcrumb ({href=>'/adm/whatsnew', - text=>"Display Action Items"}); + text=>"What's New?"}); if (($command eq 'chgthreshold') && $checkallowed{'abovethreshold'}) { &Apache::lonhtmlcommon::add_breadcrumb ({href=>'/adm/whatsnew?command=chgthreshold&refpage='.$refpage, @@ -169,19 +170,19 @@ sub display_main_box { degdiff => 'Degree of difficulty', numstudents => 'Total number of students with submissions', ); - my %versions = &Apache::lonlocal::texthash ( + my %versions = ( -1 => "version changes since start of $lctype", 2592000 => 'version changes since last month', 604800 => 'version changes since last week', 86400 => 'version changes since yesterday', ); - my %newroles = &Apache::lonlocal::texthash ( + my %newroles = ( -1 => "roles which have become active since start of $lctype", 2592000 => 'roles which have become active since last month', 604800 => 'roles which have become active since last week', 86400 => 'roles which have become active since yesterday', ); - my %oldroles = &Apache::lonlocal::texthash ( + my %oldroles = ( -1 => "roles which expired since start of $lctype", 2592000 => 'roles which expired since last month', 604800 => 'roles which expired since last week', @@ -194,7 +195,7 @@ sub display_main_box { ); my %initpage = &Apache::lonlocal::texthash ( firstres => "first resource in the $lctype", - whatsnew => "what's new? page", + whatsnew => "What's New Page", userpref => 'your general user preferences', coursespecific => "specific setting for this $lctype", ); @@ -267,7 +268,7 @@ END '; } my $course_type=&Apache::loncommon::course_type(); - return &Apache::loncommon::start_page($course_type.' Action Items', + return &Apache::loncommon::start_page("What's New?", $scripttag); } @@ -281,6 +282,7 @@ END sub display_actions_box { my ($r,$command,$refpage,$threshold_titles,$interval_titles,$initpage, $cdom,$crs,$checkallowed) = @_; + my $custommenu = &Apache::loncommon::needs_gci_custom(); my $udom = $env{'user.domain'}; my $uname = $env{'user.name'}; my $cid = $env{'request.course.id'}; @@ -288,7 +290,7 @@ sub display_actions_box { my $lctype = lc($crstype); my %stulabel = ( 'Course' => 'students', - 'Group' => 'members', + 'Community' => 'members', ); my %lt = &Apache::lonlocal::texthash( 'yacc' => 'You are accessing an invalid course', @@ -327,7 +329,7 @@ sub display_actions_box { my %threshold = (); my %pagedesc = &Apache::lonlocal::texthash ( firstres => 'First resource', - whatsnew => "What's New? page", + whatsnew => "What's New Page", userpref => 'user preference', coursespecific => $lctype.' only', default => 'default', @@ -341,27 +343,32 @@ sub display_actions_box { return; } - if ($refpage eq 'start') { + my $header = ''; + if (($refpage eq 'start') && (!$custommenu)) { if (tie(my %bighash,'GDBM_File',$env{'request.course.fn'}.'.db', &GDBM_READER(),0640)) { - my $furl=$bighash{'first_url'}; + my $furl=&HTML::Entities::encode($bighash{'first_url'},'"<>&'); untie(%bighash); - $r->print(''.$lt{'gtfr'}. - '
'); + $header .= ''.$lt{'gtfr'}. + '
'; } } - $r->print(&mt('Page set to be displayed after you have selected a role in this '.$lctype).'.' + unless ($custommenu) { + $header .= &mt('Page set to be displayed after you have selected a role in this '.$lctype).'.' .' ' - .&mt('Currently: [_1]',$currinit) - .'.  ' -# &mt('Change for just this '.$lctype.'',$refpage).' '. -# &mt('or for all your courses.',$refpage).'

'); - .&mt('Change for just [_1]this course[_2]' - .' or for all [_3]your courses[_2].' + .&mt('Currently: [_1].',''.$currinit.'') + .'  ' + .&mt('[_1]Change[_2] for just [_3]this '.$lctype.'[_4] or for [_5]all your courses/communities[_6].' + ,'' + ,'' ,'' ,'' - ,'') - .'

'); + ,'
' + ,'') + .' '; + + $r->print(&Apache::loncommon::head_subbox($header)); + } if ($command eq 'reset') { $result = &process_reset($cdom,$crs); @@ -378,12 +385,14 @@ sub display_actions_box { unless ($store_result eq 'ok') { &Apache::lonnet::logthis('Error saving whatsnew settings: '. $store_result.' for '.'user '.$uname.':'.$udom.' in '.$lctype.' '.$cid); - $result .= &mt('Unable to save visibility settings due to [_1]', - $store_result); + $result .= '' + .&mt('Unable to save visibility settings due to [_1]', + $store_result) + .''; } if ($result) { - $r->print($result.'
'); + $r->print($result.'
'); } $r->rflush(); @@ -402,13 +411,13 @@ sub display_actions_box { ); if ($timediff{'versions'} == -1) { - $headings{'versionchanges'} = 'Resources in '.$lctype.' with version changes since start of '.$lctype; + $headings{'versionchanges'} = &mt('Resources in '.$lctype.' with version changes since start of '.$lctype); } elsif ($timediff{'versions'} == 2592000) { - $headings{'versionchanges'} = 'Resources in '.$lctype.' with version changes since last month'; + $headings{'versionchanges'} = &mt('Resources in '.$lctype.' with version changes since last month'); } elsif ($timediff{'versions'} == 604800) { - $headings{'versionchanges'} = 'Resources in '.$lctype.' with version changes since last week'; + $headings{'versionchanges'} = &mt('Resources in '.$lctype.' with version changes since last week'); } elsif ($timediff{'versions'} == 86400) { - $headings{'versionchanges'} = 'Resources in '.$lctype.' with version changes since yesterday'; + $headings{'versionchanges'} = &mt('Resources in '.$lctype.' with version changes since yesterday'); } $timediff{'oldroles'} = $display_settings{$cid.':oldroleinterval'}; @@ -416,13 +425,13 @@ sub display_actions_box { $interval{'oldroles'} = $interval_titles->{'oldroles'}->{$timediff{'oldroles'}}; if ($timediff{'oldroles'} == -1) { - $headings{'oldroles'} = 'Roles for which access to '.$lctype.' has expired since start of '.$lctype; + $headings{'oldroles'} = &mt('Roles for which access to '.$lctype.' has expired since start of '.$lctype); } elsif ($timediff{'oldroles'} == 2592000) { - $headings{'oldroles'} = 'Roles for which access to '.$lctype.' has expired since last month'; + $headings{'oldroles'} = &mt('Roles for which access to '.$lctype.' has expired since last month'); } elsif ($timediff{'oldroles'} == 604800) { - $headings{'oldroles'} = 'Roles for which access to '.$lctype.' has expired since last week'; + $headings{'oldroles'} = &mt('Roles for which access to '.$lctype.' has expired since last week'); } elsif ($timediff{'oldroles'} == 86400) { - $headings{'oldroles'} = 'Roles for which access to '.$lctype.' has expired since yesterday'; + $headings{'oldroles'} = &mt('Roles for which access to '.$lctype.' has expired since yesterday'); } $timediff{'newroles'} = $display_settings{$cid.':newroleinterval'}; @@ -430,13 +439,13 @@ sub display_actions_box { $interval{'newroles'} = $interval_titles->{'newroles'}->{$timediff{'newroles'}}; if ($timediff{'newroles'} == -1) { - $headings{'newroles'} = 'Roles for which access to '.$lctype.' has become available since start of '.$lctype; + $headings{'newroles'} = &mt('Roles for which access to '.$lctype.' has become available since start of '.$lctype); } elsif ($timediff{'newroles'} == 2592000) { - $headings{'newroles'} = 'Roles for which access to '.$lctype.' has become available since last month'; + $headings{'newroles'} = &mt('Roles for which access to '.$lctype.' has become available since last month'); } elsif ($timediff{'newroles'} == 604800) { - $headings{'newroles'} = 'Roles for which access to '.$lctype.' has become available since last week'; + $headings{'newroles'} = &mt('Roles for which access to '.$lctype.' has become available since last week'); } elsif ($timediff{'newroles'} == 86400) { - $headings{'newroles'} = 'Roles for which access to '.$lctype.' has become available since yesterday'; + $headings{'newroles'} = &mt('Roles for which access to '.$lctype.' has become available since yesterday'); } my $now = time; @@ -464,11 +473,16 @@ sub display_actions_box { } $headings{'abovethreshold'} = - &mt('Problems with av. attempts ≥ [_1] or deg. difficulty ≥ [_2]
and total number of '.$stulabel{$crstype}.' with submissions ≥ [_3]', + &mt('(Problems with av. attempts ≥ [_1] or deg. difficulty ≥ [_2]) [_3] and total number of '.$stulabel{$crstype}.' with submissions ≥ [_4]', $threshold{'av_attempts'},$threshold{'degdiff'}, - $threshold{'numstudents'}); + '
',$threshold{'numstudents'}); - my @actionorder = ('handgrading','haserrors','abovethreshold','versionchanges','coursediscussion','coursenormalmail','coursecritmail','newroles','oldroles'); + my @actionorder; + if ($custommenu) { + @actionorder = ('coursenormalmail','coursecritmail','newroles','oldroles'); + } else { + @actionorder = ('handgrading','haserrors','abovethreshold','versionchanges','coursediscussion','coursenormalmail','coursecritmail','newroles','oldroles'); + } foreach my $key (keys(%{$checkallowed})) { if ($key =~ /_section$/) { next; } @@ -490,8 +504,9 @@ sub display_actions_box { } } + my $itemserror; if ($needitems) { - &getitems(\%unread,\%ungraded,\%bombed,\%triggered,\%changed,\@newdiscussions,\@tograde,\@bombs,\@warnings,\%threshold,$cdom,$crs,\%res_title,\%show,$starttime,$countunread); + $itemserror = &getitems(\%unread,\%ungraded,\%bombed,\%triggered,\%changed,\@newdiscussions,\@tograde,\@bombs,\@warnings,\%threshold,$cdom,$crs,\%res_title,\%show,$starttime,$countunread); } if ($show{'coursenormalmail'}) { $msgcount = &getnormalmail(\@newmsgs); @@ -528,12 +543,15 @@ sub display_actions_box { } my $halfway = 4; # my $halfway = int($totalboxes/2) + $totalboxes%2; + if ($custommenu) { + $halfway = 2; + } foreach my $actionitem (@actionorder) { if ($$checkallowed{$actionitem}) { if ($displayed == $halfway) { $r->print(' '); } - &display_launcher($r,$actionitem,$refpage,$checkallowed,\%show,\%headings,\%res_title,\@tograde,\%ungraded,\@bombs,\%bombed,\%changed,\@warnings,\%triggered,\@newdiscussions,\%unread,$msgcount,\@newmsgs,$critmsgcount,\@critmsgs,\%interval,$countunread,\%expired,$expirecount,\%activated,$activecount,$crstype); + &display_launcher($r,$actionitem,$refpage,$checkallowed,\%show,\%headings,\%res_title,\@tograde,\%ungraded,\@bombs,\%bombed,\%changed,\@warnings,\%triggered,\@newdiscussions,\%unread,$msgcount,\@newmsgs,$critmsgcount,\@critmsgs,\%interval,$countunread,\%expired,$expirecount,\%activated,$activecount,$crstype,$itemserror); $displayed ++; } } @@ -593,7 +611,7 @@ sub display_threshold_config { &Apache::loncommon::end_data_table_row()); } $r->print(&Apache::loncommon::end_data_table()."\n". - '
+ '
'); @@ -637,19 +655,19 @@ sub display_interval_config { '. &mt('Display:').'    '); + &mt('Save').'" />'); return; } @@ -679,7 +697,13 @@ function toggle_countunread(choice) { document.discussionswitch.submit(); } '); - $r->print('
'.&mt('Choose whether or not to display a count of the number of new posts for each resource or bulletin board which has unread posts.').'
'.&mt("This can increase the time taken to gather data for the 'What's New?' page by a few seconds.").'  '.&mt("Currently set to $current.")); + $r->print('
' + .&mt('Choose whether or not to display a count of the number of new posts for each resource or discussion board which has unread posts.') + .'
' + .&mt("This can increase the time taken to gather data for the [_1]What's New Page[_2] by a few seconds.",'','') + .'  ' + .&mt('Currently set to [_1].',''.$current.'.') + ); $r->print('

@@ -689,9 +713,9 @@ function toggle_countunread(choice) { $r->print('
-         - '. + (' ' x7). + '
'); @@ -718,7 +742,7 @@ sub courseinit_config { 'anis' => 'and is set to display', 'padc' => 'Page display controlled by', 'chce' => 'Choose '.$lctype.' entry', - 'moce' => 'Modify '.$lctype.' entry', + 'moce' => 'Save', ); $r->print(<<"END");
$lt{'chwp'} @@ -780,23 +804,23 @@ sub display_launcher { $tograde,$ungraded,$bombs,$bombed,$changed,$warnings,$triggered, $newdiscussions,$unread,$msgcount,$newmsgs,$critmsgcount,$critmsgs, $interval,$countunread,$expired,$expirecount,$activated,$activecount, - $crstype) = @_; + $crstype,$itemserror) = @_; if ($$checkallowed{$action}) { &start_box($r,$show,$headings,$action,$refpage,$action); if ($$show{$action}) { if ($action eq 'handgrading') { # UNGRADED ITEMS - &display_handgrade($r,$tograde,$ungraded); + &display_handgrade($r,$tograde,$ungraded,$itemserror); } elsif ($action eq 'haserrors') { # BOMBS - &display_haserrors($r,$bombs,$bombed,$res_title); + &display_haserrors($r,$bombs,$bombed,$res_title,$itemserror); } elsif ($action eq 'versionchanges') { # VERSION CHANGES - &display_versionchanges($r,$changed,$res_title,$interval->{'versions'}); + &display_versionchanges($r,$changed,$res_title,$interval->{'versions'},$itemserror); } elsif ($action eq 'abovethreshold') { # DEGDIFF/AV. TRIES TRIGGERS &display_abovethreshold($r,$refpage,$warnings,$triggered, - $res_title); + $res_title,$itemserror); } elsif ($action eq 'coursediscussion') { # UNREAD COURSE DISCUSSION &display_coursediscussion($r,$newdiscussions,$unread, - $countunread,$res_title); + $countunread,$res_title,$itemserror); } elsif ($action eq 'coursenormalmail') { # NORMAL MESSAGES &display_coursenormalmail($r,$msgcount,$newmsgs); } elsif ($action eq 'coursecritmail') { # CRITICAL MESSAGES @@ -819,6 +843,10 @@ sub getitems { $tograde,$bombs,$warnings,$threshold,$cdom,$crs,$res_title,$show, $starttime,$countunread) = @_; my $navmap = Apache::lonnavmaps::navmap->new(); + if (!defined($navmap)) { + my $itemserror = ''.&mt('An error occurred retrieving information about the course.').'
'.&mt('It is recommended that you [_1]re-select the course[_2].','','').'
'; + return $itemserror; + } # force retrieve Resource to seed the part id cache we'll need it later my @allres=$navmap->retrieveResources(undef, sub {if ($_[0]->is_problem) { $_[0]->parts();} return 1;}); @@ -877,6 +905,7 @@ sub getitems { } } + return; } sub check_discussions { @@ -1149,9 +1178,9 @@ sub getnormalmail { if (($fromcid) && ($fromcid eq $env{'request.course.id'})) { if (defined($sendtime) && $sendtime!~/error/) { my $numsendtime = $sendtime; - $sendtime = &Apache::lonlocal::locallocaltime($sendtime); if ($status eq 'new') { - $msgcount ++; + $sendtime = &Apache::lonlocal::locallocaltime($sendtime); + $msgcount ++; if ($shortsubj eq '') { $shortsubj = &mt('No subject'); } @@ -1222,8 +1251,8 @@ sub getactivated { if (ref($changes{$chg}) eq 'HASH') { my $timestamp = $changes{$chg}{'exe_time'}; if ($timestamp) { - if ($rolechgtime > -1) { - if ($now - $rolechgtime < $timestamp) { + if ($rolechgtime > 0) { + if ($timestamp < $rolechgtime) { last; } } @@ -1440,7 +1469,7 @@ sub checkversions { } sub display_handgrade { - my ($r,$tograde,$ungraded) = @_; + my ($r,$tograde,$ungraded,$itemserror) = @_; my %lt = &Apache::lonlocal::texthash( 'prna' => 'Problem Name', 'nmun' => 'Number ungraded', @@ -1463,13 +1492,15 @@ sub display_handgrade { } $r->print(''.$$ungraded{$res}{title}.''.$$ungraded{$res}{count}.''); } + } elsif ($itemserror) { + $r->print(''.$itemserror.''); } else { $r->print(''.$lt{'nopr'}.''); } } sub display_haserrors { - my ($r,$bombs,$bombed,$res_title) = @_; + my ($r,$bombs,$bombed,$res_title,$itemserror) = @_; my $bombnum = 0; my %lt = &Apache::lonlocal::texthash( reso => 'Resource', @@ -1488,6 +1519,8 @@ sub display_haserrors { ''. $$bombed{$bomb}{errorcount}.''); } + } elsif ($itemserror) { + $r->print(''.$itemserror.''); } else { $r->print(''.$lt{'noer'}.''); } @@ -1495,7 +1528,7 @@ sub display_haserrors { } sub display_abovethreshold { - my ($r,$refpage,$warnings,$triggered,$res_title) = @_; + my ($r,$refpage,$warnings,$triggered,$res_title,$itemserror) = @_; my %lt = &Apache::lonlocal::texthash( reso => 'Resource', part => 'Part', @@ -1551,19 +1584,20 @@ sub display_abovethreshold { } } $r->print('
'); + } elsif ($itemserror) { + $r->print(''.$itemserror.''); } else { $r->print(''.$lt{'nopr'}.''); } } sub display_versionchanges { - my ($r,$changed,$res_title,$interval) = @_; + my ($r,$changed,$res_title,$interval,$itemserror) = @_; my %lt = &Apache::lonlocal::texthash( 'reso' => 'Resource', 'revd' => 'Last revised', 'newv' => 'New version', 'veru' => 'Version used', - 'noup' => 'No', ); if (keys(%{$changed}) > 0) { $r->print(''. @@ -1585,9 +1619,11 @@ sub display_versionchanges { $$changed{$item}{'current'}.''. $$changed{$item}{'version'}.''); } + } elsif ($itemserror) { + $r->print(''.$itemserror.''); } else { - $r->print(''.$lt{'noup'}. - ' '.$interval.''); + $r->print('' + .&mt('No '.$interval).''); } return; } @@ -1601,7 +1637,6 @@ sub display_rolechanges { 'role' => 'Role', 'sec' => 'Section', 'status' => 'Status', - 'norc' => 'There are no ', ); if ($chgcount) { $r->print(''. @@ -1644,14 +1679,14 @@ sub display_rolechanges { } } } else { - $r->print(''.$lt{'norc'}. - ' '.$interval.''); + $r->print('' + .&mt('There are no '.$interval).''); } return; } sub display_coursediscussion { - my ($r,$newdiscussions,$unread,$countunread,$res_title) = @_; + my ($r,$newdiscussions,$unread,$countunread,$res_title,$itemserror) = @_; my $lctype = lc(&Apache::loncommon::course_type()); my %lt = &Apache::lonlocal::texthash( 'loca' => 'Location', @@ -1681,7 +1716,7 @@ sub display_coursediscussion { my $feedurl=&Apache::lonfeedback::get_feedurl($ressymb); my $disclink = $feedurl.'?symb='.$$unread{$ressymb}{symb}; if ($feedurl =~ /bulletinboard/) { - $type = 'Bulletin Board'; + $type = 'Discussion Board'; } if ($$unread{$ressymb}{'enclink'}) { $disclink = $$unread{$ressymb}{'enclink'}.'?symb='.$$unread{$ressymb}{'encsymb'}; @@ -1699,6 +1734,8 @@ sub display_coursediscussion { } $r->print("\n"); } + } elsif ($itemserror) { + $r->print(''.$itemserror.''); } else { $r->print(''.$lt{'noun'}.''); } @@ -1877,9 +1914,10 @@ sub store_courseinit_setting { \%courseinit_settings,$udom,$uname); if ($outcome eq 'ok') { if ($page_control eq 'global preferences') { - $result = &mt("Page displayed after role selection in $lctype now set by user's global preferences."); + $result = &mt("Page displayed after role selection in $lctype now set by [_1]user's global preferences[_2].",'',''); } else { - $result = &mt('Page displayed after role selection in this '.$lctype.' set to [_2]',$lctype,$$initpage{$env{'form.courseinit_page'}}); + $result = &mt('Page displayed after role selection in this '.$lctype.' set to [_1].' + ,''.$$initpage{$env{'form.courseinit_page'}}.''); } } else { &Apache::lonnet::logthis('Error saving whatsnew courseinit '. @@ -1891,8 +1929,10 @@ sub store_courseinit_setting { ''.$page_control.'', ''.$outcome.'.
'); } else { - $result = &mt('Unable to set page display, after role selection, for this '.$lctype.' to [_2] due to [_3].
', - $$initpage{$env{'form.courseinit_page'}},$outcome); + $result = &mt('Unable to set page display, after role selection, for this '.$lctype.' to [_1] due to [_2].' + ,''.$$initpage{$env{'form.courseinit_page'}}.'' + ,''.$outcome.'') + .'
'; } } } @@ -1929,35 +1969,35 @@ sub start_box { if ($$show{$caller}) { $r->print(' - '.$lt{'chth'}.' + '.$lt{'chth'}.' '); } } elsif (($caller eq 'versionchanges') && ($$show{$caller})) { if ($$show{$caller}) { $r->print(' - '.$lt{'chin'}.' + '.$lt{'chin'}.' '); } } elsif ($caller eq 'coursediscussion') { if ($$show{$caller}) { $r->print(' - '.$lt{'chop'}.' + '.$lt{'chop'}.' '); } } elsif (($caller eq 'newroles') && ($$show{$caller})) { if ($$show{$caller}) { $r->print(' - '.$lt{'chin'}.' + '.$lt{'chin'}.' '); } } elsif (($caller eq 'oldroles') && ($$show{$caller})) { if ($$show{$caller}) { $r->print(' - '.$lt{'chin'}.' + '.$lt{'chin'}.' '); } }