--- loncom/interface/lonwhatsnew.pm 2009/05/04 21:44:54 1.92
+++ loncom/interface/lonwhatsnew.pm 2012/05/10 19:01:40 1.105.2.1
@@ -1,5 +1,5 @@
#
-# $Id: lonwhatsnew.pm,v 1.92 2009/05/04 21:44:54 lueken Exp $
+# $Id: lonwhatsnew.pm,v 1.105.2.1 2012/05/10 19:01:40 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;
}
@@ -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',
@@ -341,27 +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('[_1]Change[_2] for just [_3]this course[_4] or for all [_5]your courses[_6].'
+ .&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 +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();
@@ -968,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;
}
@@ -990,6 +999,7 @@ sub check_thresholds {
$av_attempts = $attempts/$users;
$av_attempts = sprintf("%.2f",$av_attempts);
}
+ &Apache::lonnet::statslog($symb,$part,$users,$av_attempts,$degdiff);
if ((($degdiff ne '' && $degdiff >= $$threshold{'degdiff'}) || ($av_attempts ne '' && $av_attempts >= $$threshold{'av_attempts'})) && ($users >= $$threshold{'numstudents'})) {
$stats{$part}{degdiff} = $degdiff;
$stats{$part}{attempts} = $av_attempts;
@@ -1124,7 +1134,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;
@@ -1135,17 +1145,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 {
@@ -1153,8 +1163,6 @@ sub getnormalmail {
# Check for unread mail in course
my $msgcount = 0;
- my $datetime;
-
my @messages = sort(&Apache::lonnet::getkeys('nohist_email'));
foreach my $message (@messages) {
my $msgid=&escape($message);
@@ -1162,9 +1170,8 @@ sub getnormalmail {
&Apache::lonmsg::unpackmsgid($msgid);
if (($fromcid) && ($fromcid eq $env{'request.course.id'})) {
if (defined($sendtime) && $sendtime!~/error/) {
- my $numsendtime = $sendtime;
if ($status eq 'new') {
- $sendtime = &Apache::lonlocal::locallocaltime($sendtime,'',\$datetime);
+ $sendtime = &Apache::lonlocal::locallocaltime($sendtime);
$msgcount ++;
if ($shortsubj eq '') {
$shortsubj = &mt('No subject');
@@ -1188,15 +1195,13 @@ sub getcritmail {
# Check for critical messages in course
my %what=&Apache::lonnet::dump('critical');
my $result = '';
- my $datetime;
my $critmsgcount = 0;
foreach my $msgid (sort(keys(%what))) {
my ($sendtime,$shortsubj,$fromname,$fromdom,$status,$fromcid)=
&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,'',\$datetime);
+ $sendtime = &Apache::lonlocal::locallocaltime($sendtime);
$critmsgcount ++;
if ($shortsubj eq '') {
$shortsubj = &mt('No subject');
@@ -1430,7 +1435,7 @@ sub checkversions {
'lastrevisiondate');
$revdate = &Apache::lonlocal::locallocaltime($revdate);
my $linkurl=&Apache::lonnet::clutter($key);
- my $usedversion=$navmap->usedVersion('version_'.$linkurl);
+ my $usedversion=$navmap->usedVersion($linkurl);
my @resources = $navmap->getResourceByUrl($linkurl,1);
if (($usedversion) && ($usedversion ne 'mostrecent')) {
$version = $usedversion;
@@ -1473,9 +1478,9 @@ sub display_handgrade {
my $linkurl=&Apache::lonnet::clutter($url);
$linkurl .= '?symb='.&escape($res);
if ($$ungraded{$res}{'enclink'}) {
- $linkurl =
+ $linkurl =
$$ungraded{$res}{'enclink'}.'?symb='.$$ungraded{$res}{'encsymb'};
- }
+ }
$r->print(''.$$ungraded{$res}{title}.' | '.$$ungraded{$res}{count}.' |
');
}
} elsif ($itemserror) {
@@ -1617,7 +1622,6 @@ sub display_versionchanges {
sub display_rolechanges {
my ($r,$chgcount,$changed,$interval,$crstype) = @_;
my $now = time();
- my $datetime;
my %lt = &Apache::lonlocal::texthash(
'user' => 'User',
'tich' => 'Time of change',
@@ -1655,7 +1659,7 @@ sub display_rolechanges {
my $link =
&Apache::loncommon::aboutmewrapper(&Apache::loncommon::plainname($uname,$udom),$uname,$udom);
$r->print(''.
- ''.&Apache::lonlocal::locallocaltime($item,'',\$datetime).' | '.
+ ''.&Apache::lonlocal::locallocaltime($item).' | '.
''.$link.' | '.
''.$role.' | '.
''.$section.' | '.
@@ -1839,19 +1843,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 {
@@ -1863,20 +1867,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 {
@@ -1901,30 +1905,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 [_1]user's global preferences[_2].",'','');
+ $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 [_1].'
- ,''.$$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 [_1] due to [_2].'
+ $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.'')
- .'
';
+ ,''.$outcome.''),1);
}
}
}
}
- return $result;
+ return &Apache::loncommon::confirmwrapper($result);
}
sub start_box {
@@ -1956,35 +1959,35 @@ sub start_box {
if ($$show{$caller}) {
$r->print('
-
+
');
}
} elsif (($caller eq 'versionchanges') && ($$show{$caller})) {
if ($$show{$caller}) {
$r->print('
-
+
');
}
} elsif ($caller eq 'coursediscussion') {
if ($$show{$caller}) {
$r->print('
-
+
');
}
} elsif (($caller eq 'newroles') && ($$show{$caller})) {
if ($$show{$caller}) {
$r->print('
-
+
');
}
} elsif (($caller eq 'oldroles') && ($$show{$caller})) {
if ($$show{$caller}) {
$r->print('
-
+
');
}
}