[LON-CAPA-cvs] cvs: loncom /interface/statistics lonstudentsubmissions.pm

albertel lon-capa-cvs@mail.lon-capa.org
Sat, 29 Apr 2006 18:01:18 -0000


albertel		Sat Apr 29 14:01:18 2006 EDT

  Modified files:              
    /loncom/interface/statistics	lonstudentsubmissions.pm 
  Log:
  - adding task support to the 'Student Submissions' data extraction
  
  
Index: loncom/interface/statistics/lonstudentsubmissions.pm
diff -u loncom/interface/statistics/lonstudentsubmissions.pm:1.41 loncom/interface/statistics/lonstudentsubmissions.pm:1.42
--- loncom/interface/statistics/lonstudentsubmissions.pm:1.41	Tue Apr 12 17:49:49 2005
+++ loncom/interface/statistics/lonstudentsubmissions.pm	Sat Apr 29 14:01:17 2006
@@ -1,6 +1,6 @@
 # The LearningOnline Network with CAPA
 #
-# $Id: lonstudentsubmissions.pm,v 1.41 2005/04/12 21:49:49 matthew Exp $
+# $Id: lonstudentsubmissions.pm,v 1.42 2006/04/29 18:01:17 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -190,6 +190,8 @@
             shift(@basic_headers);  # Get rid of 'Correct'
         }
         @headers = (@foils,@basic_headers);
+    } elsif (lc($resptype) eq 'task') {
+        @headers = ('Grader','Status',@basic_headers,'Submission');
     } else {
         @headers = ('Submission',@basic_headers);
     }
@@ -369,6 +371,14 @@
                                                      $response,
                                                      $single_response).
                                  '</td>');
+			} elsif (lc($resptype) eq 'task') {
+			    my $results = 
+				&html_task_results(\@headers,
+						   $prob,$partid,$respid,
+						   $response,$resptype);
+			    if ($results) {
+				push(@{$resp_data->{'real'}},$results);
+			    }
                         } else {
                             push(@{$resp_data->{'real'}},
                                  &html_non_essay_results(\@headers,
@@ -442,14 +452,27 @@
     }
     $resp_hash->{'Submission'} = 
         $response->[&Apache::loncoursedata::RDs_submission()];
-    $resp_hash->{'Award Detail'} = 
-        $response->[&Apache::loncoursedata::RDs_awarddetail()];
     $resp_hash->{'Time'} = 
         $response->[&Apache::loncoursedata::RDs_timestamp()];
     $resp_hash->{'Attempt'} =
         $response->[&Apache::loncoursedata::RDs_tries()];
     $resp_hash->{'Awarded'} = 
         $response->[&Apache::loncoursedata::RDs_awarded()];
+    if ($prob->is_task()) {
+	$resp_hash->{'Grader'} = 
+	    $response->[&Apache::loncoursedata::RDs_response_eval_2()];
+	if ($resp_hash->{'Attempt'} eq '0') {
+	    $resp_hash->{'Attempt'} = '';
+	}
+	$resp_hash->{'Award Detail'} = 
+	    $response->[&Apache::loncoursedata::RDs_part_award()];
+	$resp_hash->{'Status'} = 
+	    $response->[&Apache::loncoursedata::RDs_response_eval()];
+    } else {
+	$resp_hash->{'Award Detail'} = 
+	    $response->[&Apache::loncoursedata::RDs_awarddetail()];
+    }
+
     return $resp_hash;
 }
 
@@ -512,6 +535,20 @@
     return $submission;
 }
 
+sub html_task_results {
+    my ($headers,$prob,$partid,$respid,$response,$resptype) = @_;
+    if (! ref($headers) || ref($headers) ne 'ARRAY' || ! scalar(@$headers)) {
+        return '';
+    }
+
+    my @values;
+    @values = map { $response->{$_}; } @$headers;
+
+    my $td = '<td valign="top">';
+    my $str = $td.join('</td>'.$td,@values).'</td>';
+    return $str;
+}
+
 sub html_non_essay_results {
     my ($headers,$prob,$partid,$respid,$response,$resptype) = @_;
     if (! ref($headers) || ref($headers) ne 'ARRAY' || ! scalar(@$headers)) {
@@ -792,7 +829,9 @@
     my $submission = 
         &HTML::Entities::decode
         (&Apache::lonnet::unescape($response->{'Submission'}));
-    return () if (! defined($submission) || $submission eq '');
+    if (!$prob->is_task()) {
+	return () if (! defined($submission) || $submission eq '');
+    }
     $submission =~ s/\\\"/\"/g;
     $submission =~ s/\\\'/\'/g;
     if ($resptype eq 'radiobutton') {
@@ -1106,7 +1145,7 @@
     $Str .= '</tr>'."\n";
     $Str .= '</table>'."\n";
     #
-    $Str .= '<nobr>'.&mt('Status: [_1]',
+    $Str .= '<p><nobr>'.&mt('Status: [_1]',
                          '<input type="text" '.
                          'name="stats_status" size="60" value="" />').
             '</nobr>'.'</p>';