[LON-CAPA-cvs] cvs: loncom /homework lonhomework.pm
albertel
lon-capa-cvs@mail.lon-capa.org
Tue, 25 Feb 2003 18:49:05 -0000
albertel Tue Feb 25 13:49:05 2003 EDT
Modified files:
/loncom/homework lonhomework.pm
Log:
- analyze set works for string/formula response now
Index: loncom/homework/lonhomework.pm
diff -u loncom/homework/lonhomework.pm:1.108 loncom/homework/lonhomework.pm:1.109
--- loncom/homework/lonhomework.pm:1.108 Thu Feb 13 16:14:35 2003
+++ loncom/homework/lonhomework.pm Tue Feb 25 13:49:05 2003
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# The LON-CAPA Homework handler
#
-# $Id: lonhomework.pm,v 1.108 2003/02/13 21:14:35 albertel Exp $
+# $Id: lonhomework.pm,v 1.109 2003/02/25 18:49:05 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -339,7 +339,9 @@
sub analyze_header {
my ($request) = @_;
- my $result.='<html><body bgcolor="#FFFFFF">
+ my $result.='<html>
+ <head><title>Analyzing a problem</title></head>
+ <body bgcolor="#FFFFFF">
<form name="lonhomework" method="POST" action="'.
$ENV{'request.uri'}.'">
<input type="submit" name="problemmode" value="EditXML" />
@@ -353,6 +355,13 @@
$request->rflush();
}
+sub analyze_footer {
+ my ($request) = @_;
+ my $result='</body></html>';
+ $request->print($result);
+ $request->rflush();
+}
+
sub analyze {
my ($request,$file) = @_;
&Apache::lonxml::debug("Analyze");
@@ -368,23 +377,34 @@
&Apache::lonxml::debug(":$subresult:");
(my $garbage,$subresult)=split(/_HASH_REF__/,$subresult,2);
my %analyze=&Apache::lonnet::str2hash($subresult);
+ $Apache::lonxml::debug=1;
&Apache::lonhomework::showhash(%analyze);
+ $Apache::lonxml::debug=0;
my @parts = @{ $analyze{'parts'} };
foreach my $part (@parts) {
if (!exists($allparts{$part})) {$allparts{$part}=1;};
- if ($analyze{$part.'.type'} eq 'numericalresponse') {
+ if ($analyze{$part.'.type'} eq 'numericalresponse' ||
+ $analyze{$part.'.type'} eq 'stringresponse' ||
+ $analyze{$part.'.type'} eq 'formularesponse' ) {
push( @{ $overall{$part.'.answer'} },
[@{ $analyze{$part.'.answer'} }]);
}
}
}
foreach my $part (keys(%allparts)) {
- $request->print('<table><tr><td>Part '.$part.'</td></tr>');
- foreach my $answer (sort {$a->[0] <=> $b->[0]} (@{ $overall{$part.'.answer'} })) {
- $request->print('<tr><td>'.join('</td><td>',@{ $answer }).
- '</td></tr>');
+ if (defined(@{ $overall{$part.'.answer'} })) {
+ $request->print('<table><tr><td>Part '.$part.'</td></tr>');
+ foreach my $answer (sort {$a->[0] <=> $b->[0]} (@{ $overall{$part.'.answer'} })) {
+ $request->print('<tr><td>'.join('</td><td>',@{ $answer }).
+ '</td></tr>');
+ }
+ $request->print('</table>');
+ } else {
+ $request->print('<p>Part '.$part.
+ ' is not analyzabale at this time</p>');
}
}
+ &analyze_footer($request);
&Apache::lonhomework::showhash(%overall);
return $result;
}
@@ -448,7 +468,7 @@
my %mystyle;
my $result = '';
- if ($target eq 'analyze') { %Apache::lonhomework::anaylze=(); }
+ if ($target eq 'analyze') { %Apache::lonhomework::analyze=(); }
if ($target eq 'answer') { &showhash(%Apache::lonhomework::history); }
if ($target eq 'web') {&Apache::lonhomework::showhashsubset(\%ENV,'^form');}