--- loncom/interface/lonwhatsnew.pm 2016/08/07 02:06:00 1.105.2.11 +++ loncom/interface/lonwhatsnew.pm 2013/03/05 22:51:48 1.111 @@ -1,5 +1,5 @@ # -# $Id: lonwhatsnew.pm,v 1.105.2.11 2016/08/07 02:06:00 raeburn Exp $ +# $Id: lonwhatsnew.pm,v 1.111 2013/03/05 22:51:48 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -598,10 +598,6 @@ sub display_actions_box { if ($needitems) { $itemserror = &getitems(\%unread,\%ungraded,\%bombed,\%triggered,\%changed,\@newdiscussions,\@tograde,\@bombs,\@warnings,\%threshold,$cdom,$crs,\%res_title,\%show,$starttime,$countunread); } - my $classlist; - if ($show{'oldroles'} || $show{'newroles'} || $show{'crslogin'}) { - $classlist = &Apache::loncoursedata::get_classlist(); - } if ($show{'coursenormalmail'}) { $msgcount = &getnormalmail(\@newmsgs); } @@ -609,10 +605,10 @@ sub display_actions_box { $critmsgcount = &getcritmail(\@critmsgs); } if ($show{'oldroles'}) { - $expirecount = &getexpired(\%expired,$expiredstart,'previous',$classlist); + $expirecount = &getexpired(\%expired,$expiredstart,'previous'); } if ($show{'newroles'}) { - $activecount = &getactivated(\%activated,$activatedstart,'active',$classlist); + $activecount = &getactivated(\%activated,$activatedstart,'active'); } if ($show{'crslogin'}) { $logincount = &getloggedin($cdom,$crs,\%loggedin,$crsloginstart); @@ -645,7 +641,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,$itemserror,\%loggedin,$logincount,$classlist); + &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,\%loggedin,$logincount); $displayed ++; } } @@ -692,7 +688,7 @@ sub display_threshold_config { foreach my $type (@thresholditems) { my $parameter = $env{'request.course.id'}.':threshold_'.$type; # onchange is javascript to automatically check the 'Set' button. - my $onchange = 'onfocus="javascript:window.document.forms'. + my $onchange = 'onFocus="javascript:window.document.forms'. "['thresholdform'].elements['".$parameter."_setparmval']". '.checked=true;"'; $r->print(&Apache::loncommon::start_data_table_row()."\n". @@ -799,7 +795,7 @@ function toggle_countunread(choice) { .'
' .&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.'') + .&mt('Currently set to [_1].',''.$current.'.') ); $r->print('

@@ -901,7 +897,7 @@ 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,$classlist) = @_; + $crstype,$itemserror,$loggedin,$logincount) = @_; if ($$checkallowed{$action}) { &start_box($r,$show,$headings,$action,$refpage); @@ -924,13 +920,13 @@ sub display_launcher { &display_coursecritmail($r,$critmsgcount,$critmsgs); } elsif ($action eq 'newroles') { # ACTIVATED ROLES &display_rolechanges($r,$activecount,$activated,$interval->{'newroles'}, - $crstype,$classlist); + $crstype); } elsif ($action eq 'oldroles') { # EXPIRED ROLES &display_rolechanges($r,$expirecount,$expired,$interval->{'oldroles'}, - $crstype,$classlist); + $crstype); } elsif ($action eq 'crslogin') { #LAST LOGIN &display_crslogins($r,$logincount,$loggedin,$interval->{'crslogin'}, - $crstype,$classlist); + $crstype); } } &end_box($r); @@ -1164,7 +1160,7 @@ sub get_curr_thresholds { my $thresholdcount = 0; my ($tmp) = %thresholdsettings; unless ($tmp =~ /^(con_lost|error|no_such_host)/i) { - foreach my $item (keys(%{$threshold})) { + foreach my $item (keys %{$threshold}) { if (exists($thresholdsettings{$cid.':threshold_'.$item})) { $$threshold{$item} = $thresholdsettings{$cid.':threshold_'.$item}; @@ -1179,7 +1175,7 @@ sub get_curr_thresholds { $cdom,$crs,'internal.threshold'); my ($temp) = %coursesettings; unless ($temp =~ /^(con_lost|error|no_such_host)/i) { - foreach my $item (keys(%{$threshold})) { + foreach my $item (keys %{$threshold}) { unless (exists($thresholdsettings{$cid.':threshold_'.$item})) { if (exists($coursesettings{'internal.threshold_'.$item})) { $$threshold{$item} = @@ -1246,13 +1242,9 @@ sub process_reset { sub process_update { my ($uname,$udom,$threshold_titles) = @_; my $setoutput = ''.&mt('Changes to threshold(s) for problem tracking:').'

'; - foreach my $key (keys(%env)) { - my $name; - if ($key =~/^form\.(.+)\_setparmval$/) { - $name = $1; - } else { - next; - } + foreach (keys %env) { + next if ($_!~/^form\.(.+)\_setparmval$/); + my $name = $1; my $value = $env{'form.'.$name.'_value'}; if ($name && defined($value) && ($value ne '')) { my $put_result = &Apache::lonnet::put('nohist_whatsnew', @@ -1275,36 +1267,29 @@ sub process_update { sub getnormalmail { my ($newmsgs) = @_; -# Check for unread messages in user's INBOX (which were sent in context of current course). +# Check for unread mail in course my $msgcount = 0; - my @messages = &Apache::lonnet::getkeys('nohist_email'); - return $msgcount if (!@messages); - my %emailstatus = &Apache::lonnet::dump('email_status'); - foreach my $msgid (sort(@messages)) { - if ((!$emailstatus{$msgid}) || ($emailstatus{$msgid} eq 'new')) { - my $skipstatus; - if ($emailstatus{$msgid} eq 'new') { - $skipstatus = 1; - } - my ($sendtime,$shortsubj,$fromname,$fromdom,$status,$fromcid)= - &Apache::lonmsg::unpackmsgid($msgid,undef,$skipstatus,undef, - $env{'request.course.id'}); - if (($fromcid) && ($fromcid eq $env{'request.course.id'})) { - if (defined($sendtime) && $sendtime!~/error/) { - if (($emailstatus{$msgid} eq 'new') || ($status eq 'new')) { - $sendtime = &Apache::lonlocal::locallocaltime($sendtime); - $msgcount ++; - if ($shortsubj eq '') { - $shortsubj = &mt('No subject'); - } - push(@{$newmsgs}, { - msgid => $msgid, - sendtime => $sendtime, - shortsub => $shortsubj, - from => $fromname, - fromdom => $fromdom - }); + + my @messages = sort(&Apache::lonnet::getkeys('nohist_email')); + foreach my $message (@messages) { + my $msgid=&escape($message); + my ($sendtime,$shortsubj,$fromname,$fromdom,$status,$fromcid)= + &Apache::lonmsg::unpackmsgid($msgid); + if (($fromcid) && ($fromcid eq $env{'request.course.id'})) { + if (defined($sendtime) && $sendtime!~/error/) { + if ($status eq 'new') { + $sendtime = &Apache::lonlocal::locallocaltime($sendtime); + $msgcount ++; + if ($shortsubj eq '') { + $shortsubj = &mt('No subject'); } + push(@{$newmsgs}, { + msgid => $msgid, + sendtime => $sendtime, + shortsub => $shortsubj, + from => $fromname, + fromdom => $fromdom + }); } } } @@ -1314,14 +1299,13 @@ sub getnormalmail { sub getcritmail { my ($critmsgs) = @_; -# Check for critical messages which were sent in context of current course. +# Check for critical messages in course my %what=&Apache::lonnet::dump('critical'); my $result = ''; my $critmsgcount = 0; foreach my $msgid (sort(keys(%what))) { my ($sendtime,$shortsubj,$fromname,$fromdom,$status,$fromcid)= - &Apache::lonmsg::unpackmsgid($msgid,undef,1,undef, - $env{'request.course.id'}); + &Apache::lonmsg::unpackmsgid($msgid); if (($fromcid) && ($fromcid eq $env{'request.course.id'})) { if (defined($sendtime) && $sendtime!~/error/) { $sendtime = &Apache::lonlocal::locallocaltime($sendtime); @@ -1343,13 +1327,13 @@ sub getcritmail { } sub getexpired { - my ($rolechgs,$rolechgtime,$status,$classlist) = @_; - my $expirecount = &getrolechanges($rolechgs,$rolechgtime,$status,$classlist); + my ($rolechgs,$rolechgtime,$status) = @_; + my $expirecount = &getrolechanges($rolechgs,$rolechgtime,$status); return $expirecount; } sub getactivated { - my ($rolechgs,$rolechgtime,$status,$classlist) = @_; + my ($rolechgs,$rolechgtime,$status) = @_; my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; my $now = time(); @@ -1363,24 +1347,24 @@ sub getactivated { if (keys(%changes) > 0) { foreach my $chg (keys(%changes)) { if (ref($changes{$chg}) eq 'HASH') { - next if ($changes{$chg}{'delflag'}); if ($rolechgtime > 0) { - next if ($changes{$chg}{'exe_time'} < $rolechgtime); + 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') { - my $end = $changes{$chg}{'logentry'}{'end'}; - next if ($end && $end <= $now); + next if ($changes{$chg}{'delflag'}); my $start = $changes{$chg}{'logentry'}{'start'}; - next if ($start >= $timestamp); + my $end = $changes{$chg}{'logentry'}{'end'}; my $section = $changes{$chg}{'logentry'}{'section'}; - if (($viewablesec ne '') && ($section ne '')) { - next if ($viewablesec ne $section); - } my $role = $changes{$chg}{'logentry'}{'role'}; my $uname = $changes{$chg}{'uname'}; my $udom = $changes{$chg}{'udom'}; + next if ($end && $end <= $now); + if (($viewablesec ne '') && ($section ne '')) { + next if ($viewablesec ne $section); + } + next if ($start >= $timestamp); if ($role eq 'st') { $stucounted{$uname.':'.$udom.':'.$section} = $start.':'.$end; } else { @@ -1400,13 +1384,12 @@ sub getactivated { } } } - $activatedcount += &getrolechanges($rolechgs,$rolechgtime,$status,$classlist,\%stucounted, - \%advcounted); + $activatedcount += &getrolechanges($rolechgs,$rolechgtime,$status,\%stucounted,\%advcounted); return $activatedcount; } sub getrolechanges { - my ($rolechgs,$rolechgtime,$status,$classlist,$stucountref,$advcountref) = @_; + my ($rolechgs,$rolechgtime,$status,$stucountref,$advcountref) = @_; my (%stucounted,%advcounted); if (ref($stucountref) eq 'HASH') { %stucounted = %{$stucountref}; @@ -1424,64 +1407,63 @@ sub getrolechanges { my ($permission,$allowed) = &Apache::lonuserutils::get_permission($context); my $viewablesec = &Apache::lonuserutils::viewable_section($permission); + my $classlist = &Apache::loncoursedata::get_classlist(); my $secidx = &Apache::loncoursedata::CL_SECTION(); my $startidx = &Apache::loncoursedata::CL_START(); my $endidx = &Apache::loncoursedata::CL_END(); my $rolechgcount = 0; - if (ref($classlist) eq 'HASH') { - foreach my $key (keys(%{$classlist})) { - my ($userstatus,$eventtime); - my $student = $classlist->{$key}; - if (ref($student) eq 'ARRAY') { - my $start = $student->[$startidx]; - my $end = $student->[$endidx]; - my $sec = $student->[$secidx]; - my ($stuname,$studom) = split(/:/,$key); - if ($status eq 'active') { - if (exists($stucounted{$key.':'.$sec})) { - next; - } + foreach my $key (keys(%{$classlist})) { + my ($userstatus,$eventtime); + my $student = $classlist->{$key}; + if (ref($student) eq 'ARRAY') { + my $start = $student->[$startidx]; + my $end = $student->[$endidx]; + my $sec = $student->[$secidx]; + my ($stuname,$studom) = split(/:/,$key); + if ($status eq 'active') { + if (exists($stucounted{$key.':'.$sec})) { + next; } - if (($end == 0) || ($end > $start)) { - if ($start <= $now) { - if ($end && $end < $now) { - if ($rolechgtime > 0) { - if ($end > $rolechgtime) { - $userstatus = 'previous'; - } - } else { + } + if (($end == 0) || ($end > $start)) { + if ($start <= $now) { + if ($end && $end < $now) { + if ($rolechgtime > 0) { + if ($end > $rolechgtime) { $userstatus = 'previous'; } } else { - if ($rolechgtime > 0) { - if ($start >= $rolechgtime) { - $userstatus = 'active'; - } - } else { + $userstatus = 'previous'; + } + } else { + if ($rolechgtime > 0) { + if ($start >= $rolechgtime) { $userstatus = 'active'; } + } else { + $userstatus = 'active'; } } } - next if ($userstatus ne $status); - if ($status eq 'active') { - $eventtime = $start; - } else { - $eventtime = $end; - } - if (($viewablesec ne '') && ($sec ne '')) { - next if ($viewablesec ne $sec); - } - my %chginfo = ( - 'section' => $sec, - 'uname' => $stuname, - 'udom' => $studom, - 'role' => 'st', - 'status' => $userstatus, - ); - $rolechgcount ++; - push(@{$rolechgs->{$eventtime}},\%chginfo); } + next if ($userstatus ne $status); + if ($status eq 'active') { + $eventtime = $start; + } else { + $eventtime = $end; + } + if (($viewablesec ne '') && ($sec ne '')) { + next if ($viewablesec ne $sec); + } + my %chginfo = ( + 'section' => $sec, + 'uname' => $stuname, + 'udom' => $studom, + 'role' => 'st', + 'status' => $userstatus, + ); + $rolechgcount ++; + push (@{$rolechgs->{$eventtime}},\%chginfo); } } my %advrolehash = &Apache::lonnet::get_my_roles($cnum,$cdom,undef, @@ -1630,13 +1612,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) { @@ -1773,7 +1755,7 @@ sub display_versionchanges { } sub display_rolechanges { - my ($r,$chgcount,$changed,$interval,$crstype,$classlist) = @_; + my ($r,$chgcount,$changed,$interval,$crstype) = @_; my $now = time(); my %lt = &Apache::lonlocal::texthash( 'user' => 'User', @@ -1792,7 +1774,6 @@ sub display_rolechanges { if (ref($changed) eq 'HASH') { my @changes = sort { $b <=> $a } (keys(%{$changed})); my $changenum = 0; - my $fullnameidx = &Apache::loncoursedata::CL_FULLNAME(); foreach my $item (@changes) { if (ref($changed->{$item}) eq 'ARRAY') { foreach my $chg (@{$changed->{$item}}) { @@ -1810,14 +1791,8 @@ sub display_rolechanges { my $udom = $chg->{'udom'}; $changenum ++; my $css_class = $changenum%2?' class="LC_odd_row"':''; - my $fullname; - if (ref($classlist->{$uname.':'.$udom}) eq 'ARRAY') { - $fullname = $classlist->{$uname.':'.$udom}->[$fullnameidx]; - } else { - $fullname = &Apache::loncommon::plainname($uname,$udom,'lastname'); - } my $link = - &Apache::loncommon::aboutmewrapper($fullname,$uname,$udom); + &Apache::loncommon::aboutmewrapper(&Apache::loncommon::plainname($uname,$udom),$uname,$udom); $r->print(''. ''.&Apache::lonlocal::locallocaltime($item).''. ''.$link.''. @@ -1837,8 +1812,7 @@ sub display_rolechanges { } sub display_crslogins { - my ($r,$logincount,$loggedin,$interval,$crstype,$classlist) = @_; - return unless (ref($classlist) eq 'HASH'); + my ($r,$logincount,$loggedin,$interval,$crstype) = @_; my %lt = &Apache::lonlocal::texthash( 'user' => 'User', 'role' => 'Role', @@ -1859,7 +1833,6 @@ sub display_crslogins { if (ref($loggedin) eq 'HASH') { my @logins = sort { $b <=> $a } (keys(%{$loggedin})); my $numlogin = 0; - my $fullnameidx = &Apache::loncoursedata::CL_FULLNAME(); foreach my $item (@logins) { if (ref($loggedin->{$item}) eq 'ARRAY') { foreach my $user (@{$loggedin->{$item}}) { @@ -1876,12 +1849,7 @@ sub display_crslogins { $counts{$user->{'role'}}{$section} ++; my $uname = $user->{'uname'}; my $udom = $user->{'udom'}; - my $fullname; - if (ref($classlist->{$uname.':'.$udom}) eq 'ARRAY') { - $fullname = $classlist->{$uname.':'.$udom}->[$fullnameidx]; - } else { - $fullname = &Apache::loncommon::plainname($uname,$udom,'lastname'); - } + my $fullname = &Apache::loncommon::plainname($uname,$udom,'lastname'); my $link = &Apache::loncommon::aboutmewrapper($fullname,$uname,$udom); push(@{$bylastname{$fullname}}, @@ -1958,7 +1926,7 @@ sub display_coursediscussion { my $forum_title = $$unread{$ressymb}{'title'}; my $type = 'Resource'; my $feedurl=&Apache::lonfeedback::get_feedurl($ressymb); - my $disclink = $feedurl.'?symb='.&escape($$unread{$ressymb}{symb}); + my $disclink = $feedurl.'?symb='. &escape($$unread{$ressymb}{symb}); if ($feedurl =~ /bulletinboard/) { $type = 'Discussion Board'; }