--- loncom/interface/lonwhatsnew.pm 2010/08/10 03:28:53 1.98.2.3 +++ loncom/interface/lonwhatsnew.pm 2012/08/27 15:27:58 1.105.2.2 @@ -1,5 +1,5 @@ # -# $Id: lonwhatsnew.pm,v 1.98.2.3 2010/08/10 03:28:53 raeburn Exp $ +# $Id: lonwhatsnew.pm,v 1.105.2.2 2012/08/27 15:27:58 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -89,7 +89,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; } @@ -197,10 +197,10 @@ sub display_main_box { 86400 => 'roles which expired since yesterday', ); my %crslogins = ( - -1 => 'last login for anyone who has ever logged in', - 2592000 => 'last login for users in last 30 days', - 604800 => 'last login for users in last 7 days', - 86400 => 'last login for users in last 24 hours', + -1 => 'last logins for anyone who has ever logged in', + 2592000 => 'last logins for users in last 30 days', + 604800 => 'last logins for users in last 7 days', + 86400 => 'last logins for users in last 24 hours', ); my %interval_titles = ( versions => \%versions, @@ -237,7 +237,7 @@ sub display_main_box { &display_interval_config($r,$refpage,\%interval_titles,'oldroles'); } elsif (($command eq 'chgcrslogininterval') && $checkallowed->{'crslogin'}) { - &display_interval_config($r,$refpage,\%interval_titles,'crslogin'); + &display_interval_config($r,$refpage,\%interval_titles,'crslogin'); } else { &display_actions_box($r,$command,$refpage,\%threshold_titles, \%interval_titles,\%initpage,$cdom,$crs,$checkallowed); @@ -263,7 +263,7 @@ sub display_header { my $scripttag; unless ($command eq 'chgthreshold' || $command eq 'chginterval' || - $command eq 'chgoldroleinterval' || + $command eq 'chgoldroleinterval' || $command eq 'chgnewroleinterval' || $command eq 'chgcrslogininterval') { $scripttag = <<"END"; '); $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.') @@ -912,10 +887,10 @@ sub display_launcher { $tograde,$ungraded,$bombs,$bombed,$changed,$warnings,$triggered, $newdiscussions,$unread,$msgcount,$newmsgs,$critmsgcount,$critmsgs, $interval,$countunread,$expired,$expirecount,$activated,$activecount, - $crstype,$itemserror,$loggedin,$logincount,$custommenu) = @_; + $crstype,$itemserror,$loggedin,$logincount) = @_; if ($$checkallowed{$action}) { - &start_box($r,$show,$headings,$action,$refpage,$action,$custommenu); + &start_box($r,$show,$headings,$action,$refpage); if ($$show{$action}) { if ($action eq 'handgrading') { # UNGRADED ITEMS &display_handgrade($r,$tograde,$ungraded,$itemserror); @@ -925,7 +900,7 @@ sub display_launcher { &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,$itemserror,$custommenu); + $res_title,$itemserror); } elsif ($action eq 'coursediscussion') { # UNREAD COURSE DISCUSSION &display_coursediscussion($r,$newdiscussions,$unread, $countunread,$res_title,$itemserror); @@ -942,7 +917,6 @@ sub display_launcher { } elsif ($action eq 'crslogin') { #LAST LOGIN &display_crslogins($r,$logincount,$loggedin,$interval->{'crslogin'}, $crstype); - } } &end_box($r); @@ -953,7 +927,7 @@ sub display_launcher { sub getitems { my ($unread,$ungraded,$bombed,$triggered,$changed,$newdiscussions, $tograde,$bombs,$warnings,$threshold,$cdom,$crs,$res_title,$show, - $starttime,$countunread,$custommenu) = @_; + $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].','','').'
'; @@ -1013,7 +987,7 @@ sub getitems { # Maxtries and degree of difficulty for problem parts, unless handgradeable if ($$show{'abovethreshold'}) { &check_thresholds($resource,$symb,\%resourcetracker, - $triggered,$threshold,$warnings,$custommenu); + $triggered,$threshold,$warnings); } } @@ -1087,7 +1061,7 @@ sub check_bombed { } sub check_thresholds { - my ($resource,$symb,$resourcetracker,$triggered,$threshold,$warnings,$custommenu) = @_; + my ($resource,$symb,$resourcetracker,$triggered,$threshold,$warnings) = @_; # Compile maxtries and degree of difficulty for problem parts, unless handgradeable my @parts = @{$resource->parts()}; my %stats; @@ -1097,6 +1071,9 @@ sub check_thresholds { if ($resource->handgrade($part) eq 'yes') { next; } + if ($resource->is_anonsurvey($part)) { + next; + } if ($resource->is_survey($part)) { next; } @@ -1119,6 +1096,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; @@ -1145,17 +1123,12 @@ sub check_thresholds { $$triggered{$symb}{text}[$partcount] = ' '.&mt('single part').''; } - if ($custommenu) { - $$triggered{$symb}{text}[$partcount] .= ' - '.$stats{$part}{users}.''; - } else { - $$triggered{$symb}{text}[$partcount] .= ' - '.$stats{$part}{users}.' - '.$stats{$part}{attempts}.' - '.$stats{$part}{degdiff}.' - '.$lastreset{$part}.' - '; - } + $$triggered{$symb}{text}[$partcount] .= ' + '.$stats{$part}{users}.' + '.$stats{$part}{attempts}.' + '.$stats{$part}{degdiff}.' + '.$lastreset{$part}.' + '; $partcount ++; } $$triggered{$symb}{numparts} = $partcount; @@ -1166,14 +1139,7 @@ sub check_thresholds { sub get_curr_thresholds { - my ($threshold,$uname,$udom,$cid,$cdom,$crs,$custommenu) = @_; - if ($custommenu) { - %$threshold = (av_attempts => 0, - degdiff => 0.00000000000000, - numstudents => 1 - ); - return; - } + my ($threshold,$uname,$udom,$cid,$cdom,$crs) = @_; # set default values %$threshold = (av_attempts => 2, degdiff => 0.5, @@ -1265,7 +1231,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; @@ -1276,17 +1242,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 { @@ -1301,7 +1267,6 @@ 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); $msgcount ++; @@ -1333,7 +1298,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 '') { @@ -1583,7 +1547,7 @@ sub getloggedin { } } return $logincount; -} +} sub checkversions { my ($cdom,$crs,$navmap,$changed,$starttime) = @_; @@ -1601,7 +1565,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; @@ -1644,9 +1608,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) { @@ -1685,7 +1649,7 @@ sub display_haserrors { } sub display_abovethreshold { - my ($r,$refpage,$warnings,$triggered,$res_title,$itemserror,$custommenu) = @_; + my ($r,$refpage,$warnings,$triggered,$res_title,$itemserror) = @_; my %lt = &Apache::lonlocal::texthash( reso => 'Resource', part => 'Part', @@ -1699,35 +1663,16 @@ sub display_abovethreshold { ); if (@{$warnings} > 0) { @{$warnings} = sort { &cmp_title($a,$b,$res_title) } @{$warnings}; - if ($custommenu) { - my (%bynum,@overthresh); - foreach my $item (@{$warnings}) { - my ($probnum) = ($res_title->{$item} =~ /^Problem\s+(\d+)$/); - if ($probnum ne '') { - $bynum{$probnum} = $item; - } - } - foreach my $num (sort { $a <=> $b } keys(%bynum)) { - push(@overthresh,$bynum{$num}); - } - @{$warnings} = @overthresh; - } - if ($custommenu) { - $r->print(''. - ''.$lt{'reso'}.''. - ''.$lt{'part'}.''.$lt{'nust'}.''); - } else { - $r->print('
'. + $r->print(''. ' '."\n". ' '. "\n"); - $r->print(''. - ''.$lt{'reso'}.''. - ''.$lt{'part'}.''.$lt{'nust'}.''. - ''.$lt{'avat'}.''.$lt{'dedi'}.''. - ''.$lt{'lare'}.''. - $lt{'reco'}.''); - } + $r->print(''. + ''.$lt{'reso'}.''. + ''.$lt{'part'}.''.$lt{'nust'}.''. + ''.$lt{'avat'}.''.$lt{'dedi'}.''. + ''.$lt{'lare'}.''. + $lt{'reco'}.''); my $row; foreach my $res (@{$warnings}) { $row++; @@ -1759,9 +1704,7 @@ sub display_abovethreshold { } } } - unless ($custommenu) { - $r->print('
'); - } + $r->print('
'); } elsif ($itemserror) { $r->print(''.$itemserror.''); } else { @@ -1872,7 +1815,7 @@ sub display_crslogins { 'number' => 'Total number of logins', ); if ($logincount) { - + my $hdr = ''. ''.$lt{'user'}.''. ''.$lt{'role'}.''. @@ -1914,18 +1857,18 @@ sub display_crslogins { } my $table; foreach my $person (sort(keys(%bylastname))) { - if (ref($bylastname{$person}) eq 'ARRAY') { - foreach my $item (@{$bylastname{$person}}) { + if (ref($bylastname{$person}) eq 'ARRAY') { + foreach my $item (@{$bylastname{$person}}) { $numlogin ++; my $css_class = $numlogin%2?' class="LC_odd_row"':''; - $table .= '