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

banghart lon-capa-cvs@mail.lon-capa.org
Tue, 14 Feb 2006 15:11:10 -0000


banghart		Tue Feb 14 10:11:10 2006 EDT

  Modified files:              
    /loncom/homework	grades.pm 
  Log:
  	Saving work in progress. Not tested. Not to count on 
  	any affected function working, yet.
  
  
Index: loncom/homework/grades.pm
diff -u loncom/homework/grades.pm:1.312 loncom/homework/grades.pm:1.313
--- loncom/homework/grades.pm:1.312	Mon Feb 13 17:11:51 2006
+++ loncom/homework/grades.pm	Tue Feb 14 10:11:09 2006
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # The LON-CAPA Grading handler
 #
-# $Id: grades.pm,v 1.312 2006/02/13 22:11:51 banghart Exp $
+# $Id: grades.pm,v 1.313 2006/02/14 15:11:09 banghart Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1386,10 +1386,8 @@
 #--- displays the grading box, used in essay type problem and grading by page/sequence
 sub gradeBox {
     my ($request,$symb,$uname,$udom,$counter,$partid,$record) = @_;
-
     my $checkIcon = '<img src="'.$request->dir_config('lonIconsURL').
 	'/check.gif" height="16" border="0" />';
-
     my $wgt    = &Apache::lonnet::EXT('resource.'.$partid.'.weight',$symb,$udom,$uname);
     my $wgtmsg = ($wgt > 0 ? '(problem weight)' : 
 		  '<font color="red">problem weight assigned by computer</font>');
@@ -1397,19 +1395,15 @@
     my $score  = ($$record{'resource.'.$partid.'.awarded'} eq '' ?
 		  '' : $$record{'resource.'.$partid.'.awarded'}*$wgt);
     my $result='<input type="hidden" name="WGT'.$counter.'_'.$partid.'" value="'.$wgt.'" />'."\n";
-
     my $display_part=&get_display_part($partid,undef,$symb);
-
     my %last_resets = &get_last_resets($symb,$env{'request.course.id'},
 				       [$partid]);
     my $aggtries = $$record{'resource.'.$partid.'.tries'};
     if ($last_resets{$partid}) {
         $aggtries = &get_num_tries($record,$last_resets{$partid},$partid);
     }
-
     $result.='<table border="0"><tr><td>'.
 	'<b>Part: </b>'.$display_part.' <b>Points: </b></td><td>'."\n";
-
     my $ctr = 0;
     $result.='<table border="0"><tr>'."\n";  # display radio buttons in a nice table 10 across
     while ($ctr<=$wgt) {
@@ -1421,7 +1415,6 @@
 	$ctr++;
     }
     $result.='</tr></table>';
-
     $result.='</td><td>&nbsp;<b>or</b>&nbsp;</td>'."\n";
     $result.='<td><input type="text" name="GD_BOX'.$counter.'_'.$partid.'"'.
 	($score ne ''? ' value = "'.$score.'"':'').' size="4" '.
@@ -1430,7 +1423,6 @@
     $result.='<td>/'.$wgt.' '.$wgtmsg.
 	($$record{'resource.'.$partid.'.solved'} eq 'correct_by_student' ? '&nbsp;'.$checkIcon : '').
 	' </td><td>'."\n";
-
     $result.='<select name="GD_SEL'.$counter.'_'.$partid.'" '.
 	'onChange="javascript:clearRadBox(this.form,\''.$counter.'_'.$partid.'\')" >'."\n";
     if ($$record{'resource.'.$partid.'.solved'} eq 'excused') {
@@ -1451,6 +1443,18 @@
         '<input type="hidden" name="aggtries'.$counter.'_'.$partid.'" value="'.
         $aggtries.'" />'."\n";
     $result.='</td></tr></table>'."\n";
+    my $files=&get_submitted_files($udom,$uname,$partid,$counter,$record);
+    if (@$files) {
+        my $file_counter = 0;
+	foreach my $file (@$files) {
+            $result.=' Return commented document to student. <input type="file" name="part'.$partid.'_returndoc';
+            $result.=$file_counter.'" />'."\n";
+            $result.='<input type="hidden" name="respid" value="'.$counter.'" />';
+            $result.='<input type="hidden" name="returndocorig'.$file_counter.'" value="'.$file.'" />';
+        }
+    }
+
+    
     return $result;
 }
 
@@ -1792,31 +1796,23 @@
 			$lastsubonly.='<tr><td bgcolor="#ffffe6"><b>Part:</b> '.
 			    $display_part.' <font color="#999999">( ID '.$respid.
 			    ' )</font>&nbsp; &nbsp;';
-			my @files;
-			if ($record{"resource.$partid.$respid.portfiles"}) {
-			    my $file_url = '/uploaded/'.$udom.'/'.$uname.'/portfolio';
-			    foreach my $file (split(',',$record{"resource.$partid.$respid.portfiles"})) {
-				push(@files,$file_url.$file);
-			    
-				&Apache::lonnet::logthis("found a portfolio file".$record{"resource.$partid.$respid.portfiles"});
-				&Apache::lonnet::logthis("uploaded URL file".$record{"resource.$partid.$respid.uploadedurl"});
-			    }
-			}
-			if ($record{"resource.$partid.$respid.uploadedurl"}) {
-			    push(@files,$record{"resource.$partid.$respid.uploadedurl"});
-			}
-			if (@files) {
+			my $files=&get_submitted_files($udom,$uname,$partid,$respid,\%record);
+#			if ($record{"resource.$partid.$respid.portfiles"}) {
+#			    my $file_url = '/uploaded/'.$udom.'/'.$uname.'/portfolio';
+#			    foreach my $file (split(',',$record{"resource.$partid.$respid.portfiles"})) {
+#				push(@files,$file_url.$file);
+#			    }
+#			}
+#			if ($record{"resource.$partid.$respid.uploadedurl"}) {
+#			    push(@files,$record{"resource.$partid.$respid.uploadedurl"});
+#			}
+			if (@$files) {
 			    $lastsubonly.='<br /><font color="red" size="1">Like all files provided by users, this file may contain virusses</font><br />';
 			    my $file_counter = 0;
-			    foreach my $file (@files) {
+			    foreach my $file (@$files) {
 			        $file_counter ++;
 				&Apache::lonnet::allowuploaded('/adm/grades',$file);
 				$lastsubonly.='<br /><a href="'.$file.'" target="lonGRDs"><img src="'.&Apache::loncommon::icon($file).'" border=0"> '.$file.'</a>';
-				$lastsubonly.=' Return commented document to student. <input type="file" name="part'.$partid.'_returndoc';
-				$lastsubonly.=$file_counter.'" />'."\n";
-				$lastsubonly.='<input type="hidden" name="respid" value="'.$respid.'" />';
-				$lastsubonly.='<input type="hidden" name="returndocorig'.$file_counter.'" value="'.$file.'" />';
-
 			    }
 			    $lastsubonly.='<br />';
 			}
@@ -2351,7 +2347,20 @@
     }
     return ('',$pts,$wgt);
 }
-
+sub get_submitted_files {
+    my ($udom,$uname,$partid,$respid,$record) = @_;
+    my @files;
+    if ($$record{"resource.$partid.$respid.portfiles"}) {
+        my $file_url = '/uploaded/'.$udom.'/'.$uname.'/portfolio';
+        foreach my $file (split(',',$$record{"resource.$partid.$respid.portfiles"})) {
+    	    push(@files,$file_url.$file);
+        }
+    }
+    if ($$record{"resource.$partid.$respid.uploadedurl"}) {
+        push(@files,$$record{"resource.$partid.$respid.uploadedurl"});
+    }
+    return (\@files);
+}
 # ----------- Provides number of tries since last reset.
 sub get_num_tries {
     my ($record,$last_reset,$part) = @_;