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

albertel lon-capa-cvs@mail.lon-capa.org
Sun, 19 Mar 2006 21:29:51 -0000


albertel		Sun Mar 19 16:29:51 2006 EDT

  Modified files:              
    /loncom/homework	grades.pm 
  Log:
  - more informative display in PGRD
  
  
Index: loncom/homework/grades.pm
diff -u loncom/homework/grades.pm:1.334 loncom/homework/grades.pm:1.335
--- loncom/homework/grades.pm:1.334	Mon Mar 13 16:10:34 2006
+++ loncom/homework/grades.pm	Sun Mar 19 16:29:50 2006
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # The LON-CAPA Grading handler
 #
-# $Id: grades.pm,v 1.334 2006/03/13 21:10:34 albertel Exp $
+# $Id: grades.pm,v 1.335 2006/03/19 21:29:50 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -118,9 +118,10 @@
     my %seen = ();
     my (@partlist,%handgrade,%responseType);
     foreach (split(/,/,&Apache::lonnet::metadata($url,'packages'))) {
-	if (/^\w+response_.*/) {
+	if (/^\w+response_.*/ || /^Task_/) {
 	    my ($responsetype,$part) = split(/_/,$_,2);
 	    my ($partid,$respid) = split(/_/,$part);
+	    if ($responsetype eq 'Task') { $respid='0'; }
 	    if (&Apache::loncommon::check_if_partid_hidden($partid,$symb)) {
 		next;
 	    }
@@ -205,7 +206,8 @@
     return ($analyze{"$partid.$respid.shown"});
 }
 #--- Clean response type for display
-#--- Currently filters option/rank/radiobutton/match/essay response types only.
+#--- Currently filters option/rank/radiobutton/match/essay/Task
+#        response types only.
 sub cleanRecord {
     my ($answer,$response,$symb,$partid,$respid,$record,$order,$version) = @_;
     my $grayFont = '<font color="#999999">';
@@ -288,6 +290,37 @@
 	my $jme=$record->{$version."resource.$partid.$respid.molecule"};
 	$result.=&Apache::chemresponse::jme_img($jme,$answer,400);
 	return $result;
+    } elsif ( $response eq 'Task') {
+	if ( $answer eq 'SUBMITTED') {
+	    my $files = $record->{$version."resource.$respid.$partid.bridgetask.portfiles"};
+	    my $result = &Apache::bridgetask::file_list($files);
+	    return $result;
+	} elsif ( grep(/^\Q$version\E.*?\.instance$/, keys(%{$record})) ) {
+	    my @matches = grep(/^\Q$version\E.*?\.instance$/,
+			       keys(%{$record}));
+	    return join('<br />',($version,@matches));
+			       
+			       
+	} else {
+	    my $result =
+		'<p>'
+		.&mt('Overall result: [_1]',
+		     $record->{$version."resource.$respid.$partid.status"})
+		.'</p>';
+	    
+	    $result .= '<ul>';
+	    my @grade = grep(/^\Q${version}resource.$respid.$partid.\E[^.]*[.]status$/,
+			     keys(%{$record}));
+	    foreach my $grade (sort(@grade)) {
+		my ($dim) = ($grade =~/[.]([^.]+)[.]status$/);
+		$result.= '<li>'.&mt("Dimension: [_1], status [_2] ",
+				     $dim, $record->{$grade}).
+			  '</li>';
+	    }
+	    $result.='</ul>';
+	    return $result;
+	}
+       
     }
     return $answer;
 }
@@ -1841,7 +1874,7 @@
 			    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.='<br /><a href="'.$file.'?rawmode=1" target="lonGRDs"><img src="'.&Apache::loncommon::icon($file).'" border=0"> '.$file.'</a>';
 			    }
 			    $lastsubonly.='<br />';
 			}
@@ -3842,6 +3875,7 @@
 sub displaySubByDates {
     my ($symb,$record,$parts,$responseType,$checkIcon,$uname,$udom) = @_;
     my $isCODE=0;
+    my $isTask = ($symb =~/\.task$/);
     if (exists($record->{'resource.CODE'})) { $isCODE=1; }
     my $studentTable='<table border="0" width="100%"><tr><td bgcolor="#777777">'.
 	'<table border="0" width="100%"><tr bgcolor="#e6ffff">'.
@@ -3856,8 +3890,17 @@
     if (!exists($$record{'1:timestamp'})) {
 	return '<br />&nbsp;<font color="red">Nothing submitted - no attempts</font><br />';
     }
+
+    my $interaction;
     for ($version=1;$version<=$$record{'version'};$version++) {
 	my $timestamp = scalar(localtime($$record{$version.':timestamp'}));
+	if (exists($$record{$version.':resource.0.version'})) {
+	    $interaction = $$record{$version.':resource.0.version'};
+	}
+
+	my $where = ($isTask ? "$version:resource.$interaction"
+		             : "$version:resource");
+	#&Apache::lonnet::logthis(" got $where");
 	$studentTable.='<tr bgcolor="#ffffff" valign="top"><td>'.$timestamp.'</td>';
 	if ($isCODE) {
 	    $studentTable.='<td>'.$record->{$version.':resource.CODE'}.'</td>';
@@ -3865,23 +3908,30 @@
 	my @versionKeys = split(/\:/,$$record{$version.':keys'});
 	my @displaySub = ();
 	foreach my $partid (@{$parts}) {
-	    my @matchKey = sort(grep /^resource\.\Q$partid\E\..*?\.submission$/,@versionKeys);
+	    my @matchKey = ($isTask ? sort(grep /^resource\.\d+\.\Q$partid\E\.award$/,@versionKeys)
+			            : sort(grep /^resource\.\Q$partid\E\..*?\.submission$/,@versionKeys));
+	    
+
 #	    next if ($$record{"$version:resource.$partid.solved"} eq '');
 	    my $display_part=&get_display_part($partid,$symb);
 	    foreach my $matchKey (@matchKey) {
 		if (exists($$record{$version.':'.$matchKey}) &&
 		    $$record{$version.':'.$matchKey} ne '') {
-		    my ($responseId)=($matchKey=~ /^resource\.\Q$partid\E\.(.*?)\.submission$/);
+
+		    my ($responseId)= ($isTask ? ($matchKey=~ /^resource\.(.*?)\.\Q$partid\E\.award$/)
+				               : ($matchKey=~ /^resource\.\Q$partid\E\.(.*?)\.submission$/));
+		    #&Apache::lonnet::logthis("match $matchKey $responseId (".$$record{$version.':'.$matchKey});
 		    $displaySub[0].='<b>Part:</b>&nbsp;'.$display_part.'&nbsp;';
 		    $displaySub[0].='<font color="#999999">(ID&nbsp;'.
 			$responseId.')</font>&nbsp;<b>';
-		    if ($$record{"$version:resource.$partid.tries"} eq '') {
+		    if ($$record{"$where.$partid.tries"} eq '') {
 			$displaySub[0].='Trial&nbsp;not&nbsp;counted';
 		    } else {
 			$displaySub[0].='Trial&nbsp;'.
-			    $$record{"$version:resource.$partid.tries"};
+			    $$record{"$where.$partid.tries"};
 		    }
-		    my $responseType=$responseType->{$partid}->{$responseId};
+		    my $responseType=($isTask ? 'Task'
+                                              : $responseType->{$partid}->{$responseId});
 		    if (!exists($orders{$partid})) { $orders{$partid}={}; }
 		    if (!exists($orders{$partid}->{$responseId})) {
 			$orders{$partid}->{$responseId}=
@@ -3891,14 +3941,24 @@
 			&cleanRecord($$record{$version.':'.$matchKey},$responseType,$symb,$partid,$responseId,$record,$orders{$partid}->{$responseId},"$version:").'<br />';
 		}
 	    }
-	    if (exists $$record{"$version:resource.$partid.award"}) {
+	    if (exists($$record{"$where.$partid.checkedin"})) {
+		$displaySub[1].='Checked in by '.
+		    $$record{"$where.$partid.checkedin"}.' into slot '.
+		    $$record{"$where.$partid.checkedin.slot"}.
+		    '<br />';
+	    }
+	    if (exists $$record{"$where.$partid.award"}) {
 		$displaySub[1].='<b>Part:</b>&nbsp;'.$display_part.' &nbsp;'.
-		    lc($$record{"$version:resource.$partid.award"}).' '.
-		    $mark{$$record{"$version:resource.$partid.solved"}}.
+		    lc($$record{"$where.$partid.award"}).' '.
+		    $mark{$$record{"$where.$partid.solved"}}.
 		    '<br />';
 	    }
-	    if (exists $$record{"$version:resource.$partid.regrader"}) {
-		$displaySub[2].=$$record{"$version:resource.$partid.regrader"}.
+	    if (exists $$record{"$where.$partid.regrader"}) {
+		$displaySub[2].=$$record{"$where.$partid.regrader"}.
+		    ' (<b>'.&mt('Part').':</b> '.$display_part.')';
+	    } elsif ($$record{"$version:resource.$partid.regrader"} =~ /\S/) {
+		$displaySub[2].=
+		    $$record{"$version:resource.$partid.regrader"}.
 		    ' (<b>'.&mt('Part').':</b> '.$display_part.')';
 	    }
 	}
@@ -4637,7 +4697,6 @@
 	    $to_remember{$i}=1;
 	}
     }
-    &Apache::lonnet::logthis('remembering '.join(':',%to_remember));
     &scan_data($scan_data,'remember_skipping',join(':',%to_remember));
     &scantron_putfile(undef,$scan_data);
 }
@@ -5559,7 +5618,6 @@
 sub valid_file {
     my ($requested_file)=@_;
     foreach my $filename (sort(&scantron_filenames())) {
-	&Apache::lonnet::logthis("$requested_file  $filename");
 	if ($requested_file eq $filename) { return 1; }
     }
     return 0;