--- loncom/interface/lonwhatsnew.pm 2010/09/19 15:05:59 1.98.2.4 +++ loncom/interface/lonwhatsnew.pm 2013/03/05 23:42:37 1.105.2.5 @@ -1,5 +1,5 @@ # -# $Id: lonwhatsnew.pm,v 1.98.2.4 2010/09/19 15:05:59 raeburn Exp $ +# $Id: lonwhatsnew.pm,v 1.105.2.5 2013/03/05 23:42:37 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; } @@ -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 +897,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 +910,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 +927,6 @@ sub display_launcher { } elsif ($action eq 'crslogin') { #LAST LOGIN &display_crslogins($r,$logincount,$loggedin,$interval->{'crslogin'}, $crstype); - } } &end_box($r); @@ -953,7 +937,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 +997,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 +1071,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 +1081,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 +1106,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 +1133,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 +1149,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 +1241,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 +1252,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 +1277,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 +1308,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 '') { @@ -1371,28 +1345,26 @@ sub getactivated { my (%stucounted,%advcounted); my $activatedcount = 0; if (keys(%changes) > 0) { - foreach my $chg (sort { $b <=> $a } (keys(%changes))) { + foreach my $chg (keys(%changes)) { if (ref($changes{$chg}) eq 'HASH') { - my $timestamp = $changes{$chg}{'exe_time'}; - if ($timestamp) { - if ($rolechgtime > 0) { - if ($timestamp < $rolechgtime) { - last; - } - } + next if ($changes{$chg}{'delflag'}); + if ($rolechgtime > 0) { + next if ($changes{$chg}{'exe_time'} < $rolechgtime); + } + if ($changes{$chg}{'exe_time'}) { + my $timestamp = $changes{$chg}{'exe_time'}; if (ref($changes{$chg}{'logentry'}) eq 'HASH') { - next if ($changes{$chg}{'delflag'}); - my $start = $changes{$chg}{'logentry'}{'start'}; my $end = $changes{$chg}{'logentry'}{'end'}; - my $section = $changes{$chg}{'logentry'}{'section'}; - my $role = $changes{$chg}{'logentry'}{'role'}; - my $uname = $changes{$chg}{'uname'}; - my $udom = $changes{$chg}{'udom'}; next if ($end && $end <= $now); + my $start = $changes{$chg}{'logentry'}{'start'}; + next if ($start >= $timestamp); + my $section = $changes{$chg}{'logentry'}{'section'}; if (($viewablesec ne '') && ($section ne '')) { next if ($viewablesec ne $section); } - next if ($start >= $timestamp); + my $role = $changes{$chg}{'logentry'}{'role'}; + my $uname = $changes{$chg}{'uname'}; + my $udom = $changes{$chg}{'udom'}; if ($role eq 'st') { $stucounted{$uname.':'.$udom.':'.$section} = $start.':'.$end; } else { @@ -1583,7 +1555,7 @@ sub getloggedin { } } return $logincount; -} +} sub checkversions { my ($cdom,$crs,$navmap,$changed,$starttime) = @_; @@ -1601,7 +1573,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 +1616,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 +1657,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 +1671,13 @@ 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('
'. - ' '."\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++; @@ -1753,15 +1703,13 @@ sub display_abovethreshold { if (ref($$triggered{$res}{text}) eq 'ARRAY') { if (@{$$triggered{$res}{text}} > 1) { for (my $i=1; $i<@{$$triggered{$res}{text}}; $i++) { - $r->print(''. + $r->print(''. $$triggered{$res}{text}[$i].''); } } } } - unless ($custommenu) { - $r->print('
'); - } + $r->print('
'); } elsif ($itemserror) { $r->print(''.$itemserror.''); } else { @@ -1872,7 +1820,7 @@ sub display_crslogins { 'number' => 'Total number of logins', ); if ($logincount) { - + my $hdr = ''. ''.$lt{'user'}.''. ''.$lt{'role'}.''. @@ -1914,18 +1862,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 .= '