--- loncom/interface/lonwhatsnew.pm 2005/05/23 23:06:23 1.13 +++ loncom/interface/lonwhatsnew.pm 2005/06/03 19:33:37 1.16 @@ -1,5 +1,5 @@ # -# $Id: lonwhatsnew.pm,v 1.13 2005/05/23 23:06:23 raeburn Exp $ +# $Id: lonwhatsnew.pm,v 1.16 2005/06/03 19:33:37 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -85,6 +85,7 @@ sub handler { (undef,'Course Action Items','Course_Action_Items_Display')); } &display_main_box($r,$command); + return OK; } #------------------------------ @@ -104,10 +105,13 @@ sub display_main_box { degdiff => 'Degree of difficulty', numstudents => 'Total number of students with submissions', ); + my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; + my $crs = $env{'course.'.$env{'request.course.id'}.'.num'}; + if ($command eq 'chgthreshold') { - &display_config_box($r,$command,$tabbg,\%threshold_titles); + &display_config_box($r,$command,$tabbg,\%threshold_titles,$cdom,$crs); } else { - &display_actions_box($r,$command,\%threshold_titles); + &display_actions_box($r,$command,\%threshold_titles,$cdom,$crs); } $r->print(< @@ -145,7 +149,7 @@ ENDHEAD #------------------------------- sub display_actions_box() { - my ($r,$command,$threshold_titles) = @_; + my ($r,$command,$threshold_titles,$cdom,$crs) = @_; my $rowColor1 = "#ffffff"; my $rowColor2 = "#eeeeee"; @@ -161,6 +165,7 @@ sub display_actions_box() { my @tograde = (); my @bombs = (); my @warnings = (); + my %res_title = (); my $domain=&Apache::loncommon::determinedomain(); my $function; @@ -186,8 +191,6 @@ sub display_actions_box() { } my $result; - my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; - my $crs = $env{'course.'.$env{'request.course.id'}.'.num'}; if ($command eq 'reset') { $result = &process_reset($cdom,$crs); @@ -199,7 +202,7 @@ sub display_actions_box() { } &get_curr_thresholds(\%threshold,$cdom,$crs); - &getitems(\%unread,\%ungraded,\%bombed,\%triggered,\@newdiscussions,\@tograde,\@bombs,\@warnings,$rowColor1,$rowColor2,\%threshold,$cdom,$crs); + &getitems(\%unread,\%ungraded,\%bombed,\%triggered,\@newdiscussions,\@tograde,\@bombs,\@warnings,$rowColor1,$rowColor2,\%threshold,$cdom,$crs,%res_title); my ($msgcount,$critmsgcount) = &getmail(\@newmsgs,\@critmsgs); $r->print('
'); -# @bombs = sort { &cmp_title($a,$b) } @bombs; + @bombs = sort { &cmp_title($a,$b,\%res_title) } @bombs; foreach my $bomb (@bombs) { if ($bombnum %2 == 1) { $rowColor = $rowColor1; @@ -282,13 +285,13 @@ END
'); @@ -253,7 +256,7 @@ END my $bombnum = 0; if (@bombs > 0) { $r->print('
ResourceNumber of errors
- +
END my $warningnum = 0; if (@warnings > 0) { -# @warnings = sort { &cmp_title($a,$b) } @warnings; + @warnings = sort { &cmp_title($a,$b,\%res_title) } @warnings; $r->print(''. - ' '."\n"); $r->print(''); foreach my $res (@warnings) { if ($warningnum %2 == 1) { @@ -329,7 +332,7 @@ END if (@newdiscussions > 0) { $r->print(''); -# @newdiscussions = sort { &cmp_title($a,$b) } @newdiscussions; + @newdiscussions = sort { &cmp_title($a,$b,\%res_title) } @newdiscussions; my $rowNum = 0; foreach my $ressymb (@newdiscussions) { my $forum_title = $unread{$ressymb}{'title'}; @@ -436,7 +439,7 @@ END #------------------------------- sub display_config_box() { - my ($r,$command,$tabbg,$threshold_titles) = @_; + my ($r,$command,$tabbg,$threshold_titles,$cdom,$crs) = @_; my %threshold = (); my $rowColor1 = "#ffffff"; my $rowColor2 = "#eeeeee"; @@ -448,7 +451,7 @@ sub display_config_box() { degdiff => 'Degree of difficulty', numstudents => 'Total number of students with submissions', ); - &get_curr_thresholds(\%threshold); + &get_curr_thresholds(\%threshold,$cdom,$crs); $r->print('
ResourcePartNum. studentsAv. AttemptsDeg. DiffLast ResetReset Count?
LocationTypeNumber of new posts
@@ -494,7 +497,7 @@ sub display_config_box() { } sub getitems { - my ($unread,$ungraded,$bombed,$triggered,$newdiscussions,$tograde,$bombs,$warnings,$rowColor1,$rowColor2,$threshold,$cdom,$crs) = @_; + my ($unread,$ungraded,$bombed,$triggered,$newdiscussions,$tograde,$bombs,$warnings,$rowColor1,$rowColor2,$threshold,$cdom,$crs,$res_title) = @_; my $navmap = Apache::lonnavmaps::navmap->new(); my @allres=$navmap->retrieveResources(); my %discussiontime = &Apache::lonnet::dump('discussiontimes',$cdom,$crs); @@ -506,7 +509,6 @@ sub getitems { my %resourcetracker = &Apache::lonnet::dump('nohist_resourcetracker', $cdom,$crs); - my %res_title; my $warningnum = 0; foreach my $key (keys(%lastread)) { my $newkey = $key; @@ -522,7 +524,7 @@ sub getitems { %{$$triggered{$symb}} = (); $$triggered{$symb}{numparts} = 0; my $title = $resource->compTitle(); - $res_title{$symb} = $title; + $$res_title{$symb} = $title; my $ressymb = $resource->wrap_symb(); # Check for unread discussion postings if (defined($discussiontime{$ressymb})) { @@ -615,6 +617,7 @@ sub getitems { } if ($users > 0) { $av_attempts = $attempts/$users; + $av_attempts = sprintf("%.2f",$av_attempts); } if ((($degdiff ne '' && $degdiff >= $$threshold{'degdiff'}) || ($av_attempts ne '' && $av_attempts >= $$threshold{'av_attempts'})) && ($users >= $$threshold{'numstudents'})) { $stats{$part}{degdiff} = $degdiff; @@ -667,8 +670,8 @@ sub get_counter_resets { my $lastreset = 'None'; if ($$resethash{'version'}) { for (my $version=1;$version<=$$resethash{'version'};$version++) { - if (exists($$resethash{$version.':'.$part.'prev_attempts'})) { - $lastreset = $$resethash{$version.':timestamp'}; + if (exists($$resethash{$version.':'.$part."\0".'prev_attempts'})) { + $lastreset = $$resethash{$version.':timestamp'}; } } } @@ -728,7 +731,7 @@ sub process_reset { $result =~ s/; $//; $result .= '
'; } else { - $result = $title.' -part '.$part.': '.&mt('Unable to reset counters to zero due to ').$putresult.'.
'."\n"; + $result = $title.' -part '.$part.': '.&mt('Unable to reset counters to zero due to [_1]',$putresult).'.
'."\n"; } } return $result; @@ -736,7 +739,7 @@ sub process_reset { sub process_update { my ($dom,$crs,$threshold_titles) = @_; - my $setoutput = 'Changes to threshold(s):
'; + my $setoutput = 'Changes to threshold(s) for problem tracking:
'; foreach (keys %env) { next if ($_!~/^form\.(.+)\_setparmval$/); my $name = $1; @@ -747,10 +750,13 @@ sub process_update { my ($shortname) = ($name =~ /^internal\.threshold_(.+)$/); if ($put_result eq 'ok') { - $setoutput.=&mt('Set threshold for').' '.$$threshold_titles{$shortname}.' '.&mt('to').' '.$value.'.
'; - } else { - $setoutput.=&mt('Unable to set threshold for').' '.$name.' '.&mt('to'). - ' '.$value.' '.&mt('due to').' '.$put_result.'.
'; + $setoutput.=&mt('Set threshold for [_1] to [_2]', + ''.$$threshold_titles{$shortname}.'', + ''.$value.'').'
'; + } else { + $setoutput.=&mt('Unable to set threshold for [_1] to [_2] due to [_3].', + ''.$name.'',''.$value.'', + ''.$put_result.'').'
'; } } } @@ -819,7 +825,8 @@ sub getmail { } sub cmp_title { - my ($atitle,$btitle) = (lc($_[0]->compTitle),lc($_[1]->compTitle)); + my ($a,$b,$res_title) = @_; + my ($atitle,$btitle) = (lc($$res_title{$a}),lc($$res_title{$b})); $atitle=~s/^\s*//; $btitle=~s/^\s*//; return $atitle cmp $btitle;