--- loncom/interface/lonwhatsnew.pm 2009/02/24 16:16:35 1.90 +++ loncom/interface/lonwhatsnew.pm 2012/03/16 21:16:38 1.105 @@ -1,5 +1,5 @@ # -# $Id: lonwhatsnew.pm,v 1.90 2009/02/24 16:16:35 hauer Exp $ +# $Id: lonwhatsnew.pm,v 1.105 2012/03/16 21:16:38 www 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 { @@ -1160,10 +1170,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'); } @@ -1192,7 +1201,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 '') { @@ -1427,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; @@ -1466,13 +1474,13 @@ 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(''.$$ungraded{$res}{title}.''.$$ungraded{$res}{count}.''); } } elsif ($itemserror) { @@ -1835,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 { @@ -1859,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 { @@ -1897,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 { @@ -1952,35 +1959,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'}.' '); } }