--- loncom/interface/lonwhatsnew.pm 2008/08/26 01:12:16 1.80
+++ loncom/interface/lonwhatsnew.pm 2011/03/31 17:54:10 1.103
@@ -1,5 +1,5 @@
#
-# $Id: lonwhatsnew.pm,v 1.80 2008/08/26 01:12:16 raeburn Exp $
+# $Id: lonwhatsnew.pm,v 1.103 2011/03/31 17:54:10 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
@@ -87,7 +88,7 @@ sub handler {
if ( ! $env{'request.course.fn'} || ! $checkallowed{'whatsnew'}) {
# Not in a course, or no whn priv in course
- $env{'user.error.msg'}="/adm/whatsnew::whn:0:0:Cannot display what's new page";
+ $env{'user.error.msg'}="/adm/whatsnew:whn:0:0:Cannot display what's new page";
return HTTP_NOT_ACCEPTABLE;
}
@@ -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,
@@ -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);
}
@@ -288,7 +289,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 +328,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,25 +342,30 @@ sub display_actions_box {
return;
}
+ my $header = '';
if ($refpage eq 'start') {
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).'.'
+ $header .= &mt('Page set to be displayed after you have selected a role in this '.$lctype).'.'
.' '
.&mt('Currently: [_1].',''.$currinit.'')
.' '
- .&mt('Change for just [_1]this course[_2]'
- .' or for all [_3]your courses[_2].'
+ .&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);
@@ -376,12 +382,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();
@@ -488,8 +496,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);
@@ -531,7 +540,7 @@ sub display_actions_box {
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 ++;
}
}
@@ -591,7 +600,7 @@ sub display_threshold_config {
&Apache::loncommon::end_data_table_row());
}
$r->print(&Apache::loncommon::end_data_table()."\n".
- '
+ '
');
@@ -647,7 +656,7 @@ sub display_interval_config {
}
$r->print('
');
+ &mt('Save').'" />');
return;
}
@@ -677,7 +686,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('
');
@@ -716,7 +731,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'}
@@ -778,23 +793,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
@@ -817,6 +832,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;});
@@ -875,6 +894,7 @@ sub getitems {
}
}
+ return;
}
sub check_discussions {
@@ -954,6 +974,9 @@ sub check_thresholds {
if ($resource->handgrade($part) eq 'yes') {
next;
}
+ if ($resource->is_anonsurvey($part)) {
+ next;
+ }
if ($resource->is_survey($part)) {
next;
}
@@ -1110,7 +1133,7 @@ sub process_reset {
sub process_update {
my ($uname,$udom,$threshold_titles) = @_;
- my $setoutput = ''.&mt('Changes to threshold(s) for problem tracking:').' ';
+ my $setoutput = ''.&mt('Changes to threshold(s) for problem tracking:').'
';
foreach (keys %env) {
next if ($_!~/^form\.(.+)\_setparmval$/);
my $name = $1;
@@ -1121,17 +1144,17 @@ sub process_update {
my ($shortname) = ($name =~ /^\Q$env{'request.course.id'}\E:threshold_(.+)$/);
if ($put_result eq 'ok') {
- $setoutput.=&mt('Set threshold for [_1] to [_2]',
+ $setoutput.= &Apache::lonhtmlcommon::confirm_success(&mt('Set threshold for [_1] to [_2]',
''.$$threshold_titles{$shortname}.'',
- ''.$value.'').' ';
+ ''.$value.'').' ');
} else {
- $setoutput.=&mt('Unable to set threshold for [_1] to [_2] due to [_3].',
+ $setoutput.= &Apache::lonhtmlcommon::confirm_success(&mt('Unable to set threshold for [_1] to [_2] due to [_3].',
''.$name.'',''.$value.'',
- ''.$put_result.'').' ';
+ ''.$put_result.'').' ',1);
}
}
}
- return $setoutput;
+ return &Apache::loncommon::confirmwrapper($setoutput);
}
sub getnormalmail {
@@ -1146,10 +1169,9 @@ sub getnormalmail {
&Apache::lonmsg::unpackmsgid($msgid);
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');
}
@@ -1178,7 +1200,6 @@ sub getcritmail {
&Apache::lonmsg::unpackmsgid($msgid);
if (($fromcid) && ($fromcid eq $env{'request.course.id'})) {
if (defined($sendtime) && $sendtime!~/error/) {
- my $numsendtime = $sendtime;
$sendtime = &Apache::lonlocal::locallocaltime($sendtime);
$critmsgcount ++;
if ($shortsubj eq '') {
@@ -1438,7 +1459,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',
@@ -1452,22 +1473,24 @@ sub display_handgrade {
foreach my $res (@{$tograde}) {
$rowNum ++;
my $css_class = $rowNum%2?' class="LC_odd_row"':'';
- my ($map,$id,$url)=&Apache::lonnet::decode_symb($res);
- my $linkurl=&Apache::lonnet::clutter($url);
- $linkurl .= '?symb='.&escape($res);
+ my $linkurl='/adm/grades';
if ($$ungraded{$res}{'enclink'}) {
- $linkurl =
- $$ungraded{$res}{'enclink'}.'?symb='.$$ungraded{$res}{'encsymb'};
- }
+ $linkurl.='?symb='.$$ungraded{$res}{'encsymb'};
+ } else {
+ $linkurl.='?symb='.&escape($res);
+ }
+ $linkurl.='&command=ungraded';
$r->print('
');
}
}
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',
@@ -1486,6 +1509,8 @@ sub display_haserrors {
'
'.
$$bombed{$bomb}{errorcount}.'
');
}
+ } elsif ($itemserror) {
+ $r->print('
'.$itemserror.'
');
} else {
$r->print('
'.$lt{'noer'}.'
');
}
@@ -1493,7 +1518,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',
@@ -1549,13 +1574,15 @@ 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',
@@ -1582,6 +1609,8 @@ sub display_versionchanges {
$$changed{$item}{'current'}.'
'.
$$changed{$item}{'version'}.'
');
}
+ } elsif ($itemserror) {
+ $r->print('
'.$itemserror.'
');
} else {
$r->print('
'
.&mt('No '.$interval).'
');
@@ -1647,7 +1676,7 @@ sub display_rolechanges {
}
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',
@@ -1677,7 +1706,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'};
@@ -1695,6 +1724,8 @@ sub display_coursediscussion {
}
$r->print("\n");
}
+ } elsif ($itemserror) {
+ $r->print('
'.$itemserror.'
');
} else {
$r->print('
'.$lt{'noun'}.'
');
}
@@ -1811,19 +1842,19 @@ sub store_interval_setting {
\%interval_settings,$udom,$uname);
if ($outcome eq 'ok') {
if (ref($interval_titles->{$context}) eq 'HASH') {
- $result = &mt('New filter setting: [_1].',''.
- $interval_titles->{$context}->{$env{'form.interval'}}.'').' ';
+ $result = &Apache::lonhtmlcommon::confirm_success(&mt('New filter setting: [_1].',''.
+ $interval_titles->{$context}->{$env{'form.interval'}}.'').' ');
}
} else {
my $lctype = lc(&Apache::loncommon::course_type());
&Apache::lonnet::logthis('Error saving whatsnew '.$context.' interval setting'.
' '.$outcome.' for '.$uname.':'.$udom.' in '.$lctype.' '.$cid);
- $result = &mt('Unable to set interval to [_1] due to [_2].',
+ $result = &Apache::lonhtmlcommon::confirm_success(&mt('Unable to set interval to [_1] due to [_2].',
''.$interval_titles->{$context}->{$env{'form.interval'}}.'',
- ''.$outcome.'. ');
+ ''.$outcome.''),1);
}
}
- return $result;
+ return &Apache::loncommon::confirmwrapper($result);
}
sub store_discussion_setting {
@@ -1835,20 +1866,20 @@ sub store_discussion_setting {
my $outcome = &Apache::lonnet::put('nohist_whatsnew',
\%discussion_settings,$udom,$uname);
if ($outcome eq 'ok') {
- $result = &mt('Count unread posts in discussions display set to [_1]',
- ''.&mt($env{'form.countunread'}).'').' ';
+ $result = &Apache::lonhtmlcommon::confirm_success(&mt('Count unread posts in discussions display set to [_1]',
+ ''.&mt($env{'form.countunread'}).'').' ');
} else {
my $lctype = lc(&Apache::loncommon::course_type());
&Apache::lonnet::logthis('Error saving whatsnew countunread setting'.
' '.$outcome.' for '.$uname.':'.$udom.' in '.$lctype.' '.$cid);
- $result = &mt('Unable to set "number unread posts display" to [_1]'.
+ $result = &Apache::lonhtmlcommon::confirm_success(&mt('Unable to set "number unread posts display" to [_1]'.
' due to [_2].',
''.&mt($env{'form.countunread'}).'',
- ''.$outcome.'. ');
+ ''.$outcome.''),1);
}
}
- return $result;
+ return &Apache::loncommon::confirmwrapper($result);
}
sub store_courseinit_setting {
@@ -1873,27 +1904,29 @@ 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 = &Apache::lonhtmlcommon::confirm_success(&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 = &Apache::lonhtmlcommon::confirm_success(&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 '.
'setting: '.$outcome.' for '.$uname.
':'.$udom.' in '.$lctype.' '.$cid);
if ($page_control eq 'global preferences') {
- $result = &mt('Unable to set control of page display to [_1]'.
+ $result = &Apache::lonhtmlcommon::confirm_success(&mt('Unable to set control of page display to [_1]'.
' due to [_2].',
''.$page_control.'',
- ''.$outcome.'. ');
+ ''.$outcome.''),1);
} 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 = &Apache::lonhtmlcommon::confirm_success(&mt('Unable to set page display, after role selection, for this '.$lctype.' to [_1] due to [_2].'
+ ,''.$$initpage{$env{'form.courseinit_page'}}.''
+ ,''.$outcome.''),1);
}
}
}
}
- return $result;
+ return &Apache::loncommon::confirmwrapper($result);
}
sub start_box {
@@ -1925,35 +1958,35 @@ sub start_box {
if ($$show{$caller}) {
$r->print('