[LON-CAPA-cvs] cvs: loncom /homework lonhomework.pm structuretags.pm
albertel
lon-capa-cvs@mail.lon-capa.org
Tue, 12 Nov 2002 05:05:27 -0000
albertel Tue Nov 12 00:05:27 2002 EDT
Modified files:
/loncom/homework lonhomework.pm structuretags.pm
Log:
- first pass at an anaylez problem feature
- only works with numericalresponse
- supports multiple parts
- supports multianswer numericalresponse
- needs to look prettier
- needs a graph
Index: loncom/homework/lonhomework.pm
diff -u loncom/homework/lonhomework.pm:1.100 loncom/homework/lonhomework.pm:1.101
--- loncom/homework/lonhomework.pm:1.100 Sun Nov 10 10:39:37 2002
+++ loncom/homework/lonhomework.pm Tue Nov 12 00:05:26 2002
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# The LON-CAPA Homework handler
#
-# $Id: lonhomework.pm,v 1.100 2002/11/10 15:39:37 albertel Exp $
+# $Id: lonhomework.pm,v 1.101 2002/11/12 05:05:26 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -309,14 +309,57 @@
return $error;
}
+sub analyze_header {
+ my ($request) = @_;
+ my $result.='<html><body bgcolor="#FFFFFF">
+ <form name="lonhomework" method="POST" action="'.
+ $ENV{'request.uri'}.'">
+ <input type="submit" name="problemmode" value="EditXML" />
+ <input type="submit" name="problemmode" value="Edit" />
+ <hr />
+ <input type="submit" name="submit" value="View" />
+ <hr />
+ List of possible answers:
+ </form>';
+ $request->print($result);
+ $request->rflush();
+}
+
sub analyze {
- my ($request,$file) = @_;
- &Apache::lonxml::debug("Analyze");
- my $result=&Apache::lonnet::ssi($request->uri,('grade_target' => 'analyze'));
- &Apache::lonxml::debug(":$result:");
- (my $garbage,$result)=split(/_HASH_REF__/,$result,2);
- &showhash(&Apache::lonnet::str2hash($result));
- return $result;
+ my ($request,$file) = @_;
+ &Apache::lonxml::debug("Analyze");
+ my $result;
+ my %overall;
+ my %allparts;
+ my $rndseed=$ENV{'form.rndseed'};
+ srand($rndseed);
+ &analyze_header($request);
+ for(my $i;$i<$ENV{'form.numtoanalyze'};$i++) {
+ my $subresult=&Apache::lonnet::ssi($request->uri,
+ ('grade_target' => 'analyze'),
+ ('rndseed' => rand));
+ #&Apache::lonxml::debug(":$subresult:");
+ (my $garbage,$subresult)=split(/_HASH_REF__/,$subresult,2);
+ my %analyze=&Apache::lonnet::str2hash($subresult);
+ &Apache::lonhomework::showhash(%analyze);
+ my @parts = @{ $analyze{'parts'} };
+ foreach my $part (@parts) {
+ if (!exists($allparts{$part})) {$allparts{$part}=1;};
+ if ($analyze{$part.'.type'} eq 'numericalresponse') {
+ 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>');
+ }
+ }
+ &Apache::lonhomework::showhash(%overall);
+ return $result;
}
sub editxmlmode {
Index: loncom/homework/structuretags.pm
diff -u loncom/homework/structuretags.pm:1.135 loncom/homework/structuretags.pm:1.136
--- loncom/homework/structuretags.pm:1.135 Mon Nov 11 17:37:23 2002
+++ loncom/homework/structuretags.pm Tue Nov 12 00:05:27 2002
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# definition of tags that give a structure to a document
#
-# $Id: structuretags.pm,v 1.135 2002/11/11 22:37:23 www Exp $
+# $Id: structuretags.pm,v 1.136 2002/11/12 05:05:27 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -138,6 +138,7 @@
$rndseed=time;
$ENV{'form.rndseed'}=$rndseed;
}
+ &Apache::lonxml::debug("Setting rndseed to $rndseed");
&Apache::run::run('$external::randomseed='.$rndseed.';',$safeeval);
}
return $rndseed;
@@ -174,10 +175,9 @@
<hr />';
my $numtoanalyze=$ENV{'form.numtoanalyze'};
if (!$numtoanalyze) { $numtoanalyze=100; }
- #DISABLED for now.
- #$result.= '<input type="submit" name="problemmode" value="Answer Distribution" />
-# <input type="text" name="numtoanalyze" value="'.
-# $numtoanalyze.'" size="5" /> <hr />';
+ $result.= '<input type="submit" name="problemmode" value="Answer Distribution" />
+ <input type="text" name="numtoanalyze" value="'.
+ $numtoanalyze.'" size="5" /> <hr />';
return $result;
}
@@ -281,6 +281,7 @@
&page_start($target,$token,$tagstack,$parstack,$parser,$safeeval);
if ($target eq 'tex' and $ENV{'request.symb'} =~ m/\.page_/) { $result = '';}
+ if ($target eq 'analyze') { my $rndseed=&setup_rndseed($safeeval); }
if ($target eq 'web' || $target eq 'grade' || $target eq 'answer' || $target eq 'tex') {
#handle exam checkout
if ($Apache::lonhomework::type eq 'exam') {