[LON-CAPA-cvs] cvs: loncom /homework grades.pm

raeburn lon-capa-cvs-allow@mail.lon-capa.org
Tue, 24 Jun 2008 18:54:37 -0000


This is a MIME encoded message

--raeburn1214333677
Content-Type: text/plain

raeburn		Tue Jun 24 14:54:37 2008 EDT

  Modified files:              
    /loncom/homework	grades.pm 
  Log:
  - style - push(), sort(). keys(), eliminate $_
  
  
--raeburn1214333677
Content-Type: text/plain
Content-Disposition: attachment; filename="raeburn-20080624145437.txt"

Index: loncom/homework/grades.pm
diff -u loncom/homework/grades.pm:1.523 loncom/homework/grades.pm:1.524
--- loncom/homework/grades.pm:1.523	Tue Jun 24 13:42:01 2008
+++ loncom/homework/grades.pm	Tue Jun 24 14:54:36 2008
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # The LON-CAPA Grading handler
 #
-# $Id: grades.pm,v 1.523 2008/06/24 17:42:01 raeburn Exp $
+# $Id: grades.pm,v 1.524 2008/06/24 18:54:36 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -240,8 +240,8 @@
     my %resptype = ();
     my $hdgrade='no';
     my %partsseen;
-    foreach my $partID (sort keys(%$responseType)) {
-	foreach my $resID (sort keys(%{ $responseType->{$partID} })) {
+    foreach my $partID (sort(keys(%$responseType))) {
+	foreach my $resID (sort(keys(%{ $responseType->{$partID} }))) {
 	    my $handgrade=$$handgrade{$partID.'_'.$resID};
 	    my $responsetype = $responseType->{$partID}->{$resID};
 	    $hdgrade = $handgrade if ($handgrade eq 'yes');
@@ -1030,7 +1030,7 @@
 	       '&nbsp;'.$section.($group ne '' ?'/'.$group:'').'</td>'."\n";
 
 	    if ($env{'form.showgrading'} eq 'yes' && $submitonly ne 'all') {
-		foreach (sort keys(%status)) {
+		foreach (sort(keys(%status))) {
 		    next if ($_ =~ /^resource.*?submitted_by$/);
 		    $gradeTable.='<td align="center">&nbsp;'.&mt($status{$_}).'&nbsp;</td>'."\n";
 		}
@@ -2225,8 +2225,8 @@
 	$seen{$partid}++;
 	next if ($$handgrade{$part_resp} ne 'yes' 
 		 && $env{'form.lastSub'} eq 'hdgrade');
-	push @partlist,$partid;
-	push @gradePartRespid,$partid.'.'.$respid;
+	push(@partlist,$partid);
+	push(@gradePartRespid,$partid.'.'.$respid);
 	$request->print(&gradeBox($request,$symb,$uname,$udom,$counter,$partid,\%record));
     }
     $request->print('</div></div>');
@@ -2553,7 +2553,7 @@
 
     my (@parsedlist,@nextlist);
     my ($nextflg) = 0;
-    foreach (sort 
+    foreach my $item (sort 
 	     {
 		 if (lc($$fullname{$a}) ne lc($$fullname{$b})) {
 		     return (lc($$fullname{$a}) cmp lc($$fullname{$b}));
@@ -2561,12 +2561,12 @@
 		 return $a cmp $b;
 	     } (keys(%$fullname))) {
 	if ($nextflg == 1 && $button =~ /Next$/) {
-	    push @parsedlist,$_;
+	    push(@parsedlist,$item);
 	}
-	$nextflg = 1 if ($_ eq $laststu);
+	$nextflg = 1 if ($item eq $laststu);
 	if ($button eq 'Previous') {
-	    last if ($_ eq $firststu);
-	    push @parsedlist,$_;
+	    last if ($item eq $firststu);
+	    push(@parsedlist,$item);
 	}
     }
     $ctr = 0;
@@ -2589,11 +2589,11 @@
 	    my $submitted = 0;
 	    my $ungraded = 0;
 	    my $incorrect = 0;
-	    foreach (keys(%status)) {
-		$submitted = 1 if ($status{$_} ne 'nothing');
-		$ungraded = 1 if ($status{$_} =~ /^ungraded/);
-		$incorrect = 1 if ($status{$_} =~ /^incorrect/);
-		my ($foo,$partid,$foo1) = split(/\./,$_);
+	    foreach my $item (keys(%status)) {
+		$submitted = 1 if ($status{$item} ne 'nothing');
+		$ungraded = 1 if ($status{$item} =~ /^ungraded/);
+		$incorrect = 1 if ($status{$item} =~ /^incorrect/);
+		my ($foo,$partid,$foo1) = split(/\./,$item);
 		if ($status{'resource.'.$partid.'.submitted_by'} ne '') {
 		    $submitted = 0;
 		}
@@ -2604,7 +2604,7 @@
 	    next if (!$ungraded && ($submitonly eq 'graded'));
 	    next if (!$incorrect && $submitonly eq 'incorrect');
 	}
-	push @nextlist,$student if ($ctr < $ntstu);
+	push(@nextlist,$student) if ($ctr < $ntstu);
 	last if ($ctr == $ntstu);
 	$ctr++;
     }
@@ -2612,7 +2612,7 @@
     $ctr = 0;
     my $total = scalar(@nextlist)-1;
 
-    foreach (sort @nextlist) {
+    foreach (sort(@nextlist)) {
 	my ($uname,$udom,$submitter) = split(/:/);
 	$env{'form.student'}  = $uname;
 	$env{'form.userdom'}  = $udom;
@@ -2658,7 +2658,7 @@
 	    }
 	} elsif ($dropMenu eq 'reset status'
 		 && exists($record{'resource.'.$new_part.'.solved'})) { #don't bother if no old records -> no attempts
-	    foreach my $key (keys (%record)) {
+	    foreach my $key (keys(%record)) {
 		if ($key=~/^resource\.\Q$new_part\E\./) { $newrecord{$key} = ''; }
 	    }
 	    $newrecord{'resource.'.$new_part.'.regrader'}=
@@ -2693,7 +2693,7 @@
                 &handback_files($request,$symb,$stuname,$domain,$newflg,$new_part,\%newrecord);
 		next;
 	    } else {
-	        push @parts_graded, $new_part;
+	        push(@parts_graded,$new_part);
 	    }
 	    if ($record{'resource.'.$new_part.'.awarded'} ne $partial) {
 		$newrecord{'resource.'.$new_part.'.awarded'}  = $partial;
@@ -2720,7 +2720,7 @@
 	        $record{'resource.'.$new_part.'.solved'} eq 'incorrect_by_override' ||
 	        $dropMenu eq 'reset status')
 	   {
-	    push (@version_parts,$new_part);
+	    push(@version_parts,$new_part);
 	}
     }
     my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
@@ -2893,7 +2893,7 @@
     if ($aggtries == $totaltries) {
         $decrement{'users'} = 1;
     }
-    foreach my $type (keys (%decrement)) {
+    foreach my $type (keys(%decrement)) {
         $$aggregate{$symb."\0".$part."\0".$type} = -$decrement{$type};
     }
     return;
@@ -3294,7 +3294,7 @@
 	$display =~ s|^Number of Attempts|Tries<br />|; # makes the column narrower
 	if  (!$display) { $display = &Apache::lonnet::metadata($url,$part.'.name'); }
 	my ($partid) = &split_part_type($part);
-        push(@partids, $partid);
+        push(@partids,$partid);
 	my $display_part=&get_display_part($partid,$symb);
 	if ($display =~ /^Partial Credit Factor/) {
 	    $result.='<th>'.
@@ -3448,7 +3448,7 @@
     my $header;
     while ($ctr < $env{'form.totalparts'}) {
 	my $partid = $env{'form.partid_'.$ctr};
-	push @partid,$partid;
+	push(@partid,$partid);
 	$weight{$partid} = $env{'form.weight_'.$partid};
 	$ctr++;
     }
@@ -6847,7 +6847,7 @@
 	foreach my $question (@{$arg}) {
 	    my @linenums = &prompt_for_corrections($r,$question,$scan_config,
                                                    $scan_record, $error);
-            push (@lines_to_correct,@linenums);
+            push(@lines_to_correct,@linenums);
 	}
         $r->print(&verify_bubbles_checked(@lines_to_correct));
     } elsif ($error eq 'missingbubble') {
@@ -6867,7 +6867,7 @@
 	foreach my $question (@{$arg}) {
 	    my @linenums = &prompt_for_corrections($r,$question,$scan_config,
                                                    $scan_record, $error);
-            push (@lines_to_correct,@linenums);
+            push(@lines_to_correct,@linenums);
 	}
         $r->print(&verify_bubbles_checked(@lines_to_correct));
     } else {
@@ -7025,7 +7025,7 @@
         my $selected = $$scan_record{"scantron.$current_line.answer"};
 	&scantron_bubble_selector($r,$scan_config,$current_line, 
 	        		  $questionnum,$error,split('', $selected));
-        push (@linenums,$current_line);
+        push(@linenums,$current_line);
 	$current_line++;
     }
     if ($lines > 1) {
@@ -7241,7 +7241,7 @@
 				     $line,'duplicateCODE',$usedCODEs{$CODE});
 	    return(1,$currentphase);
 	}
-	push (@{$usedCODEs{$CODE}},$$scan_record{'scantron.PaperID'});
+	push(@{$usedCODEs{$CODE}},$$scan_record{'scantron.PaperID'});
     }
     return (0,$currentphase+1);
 }
@@ -7375,7 +7375,7 @@
                 if (($analysis{$part_id.'.type'} eq 'essayresponse') ||
                     ($analysis{$part_id.'.type'} eq 'reactionresponse') ||
                     ($analysis{$part_id.'.type'} eq 'organicresponse')) {
-                    push (@allparts,$part_id);
+                    push(@allparts,$part_id);
                 }
             }
         }
@@ -8163,25 +8163,25 @@
                  });
     $fields{'command'} = 'csvform';
     $url = &Apache::lonhtmlcommon::build_url('grades/',\%fields);
-    push (@menu, { url => $url,
+    push(@menu, { url => $url,
                    name => &mt('Upload Scores'),
                    short_description => 
             &mt('Specify a file containing the class scores for current resource.')});
     $fields{'command'} = 'processclicker';
     $url = &Apache::lonhtmlcommon::build_url('grades/',\%fields);
-    push (@menu, { url => $url,
+    push(@menu, { url => $url,
                    name => &mt('Process Clicker'),
                    short_description => 
             &mt('Specify a file containing the clicker information for this resource.')});
     $fields{'command'} = 'scantron_selectphase';
     $url = &Apache::lonhtmlcommon::build_url('grades/',\%fields);
-    push (@menu, { url => $url,
+    push(@menu, { url => $url,
                    name => &mt('Grade/Manage/Review Scantron Forms'),
                    short_description => 
             &mt('Grade scantron exams, upload/download scantron data files, and review previously graded scantron exams.')});
     $fields{'command'} = 'verify';
     $url = &Apache::lonhtmlcommon::build_url('grades/',\%fields);
-    push (@menu, { url => "",
+    push(@menu, { url => "",
                    name => &mt('Verify Receipt'),
                    short_description => 
             &mt('')});
@@ -8337,7 +8337,7 @@
              <div class="LC_grade_select_mode_selector_body">
 	       <select name="section" multiple="multiple" size="5">'."\n";
     if (ref($sections)) {
-	foreach my $section (sort (@$sections)) {
+	foreach my $section (sort(@$sections)) {
 	    $result.='<option value="'.$section.'" '.
 		($saveSec eq $section ? 'selected="selected"':'').'>'.$section.'</option>'."\n";
 	}
@@ -8841,7 +8841,7 @@
         $id=~s/[\-\:]//g;
         $idresponses{$id}[$number]=$entries[6];
     }
-    foreach my $id (keys %idresponses) {
+    foreach my $id (keys(%idresponses)) {
        $$responses{$id}=join(',',@{$idresponses{$id}});
        $$responses{$id}=~s/^\s*\,//;
     }

--raeburn1214333677--