--- loncom/homework/lonhomework.pm 2003/02/25 23:18:22 1.110
+++ loncom/homework/lonhomework.pm 2003/05/13 01:18:37 1.125
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# The LON-CAPA Homework handler
#
-# $Id: lonhomework.pm,v 1.110 2003/02/25 23:18:22 albertel Exp $
+# $Id: lonhomework.pm,v 1.125 2003/05/13 01:18:37 www Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -50,6 +50,7 @@ use Apache::essayresponse();
use Apache::externalresponse();
use Apache::rankresponse();
use Apache::matchresponse();
+#use Apache::chemresponse();
use Apache::Constants qw(:common);
use HTML::Entities();
use Apache::loncommon();
@@ -60,16 +61,17 @@ BEGIN {
}
sub get_target {
- if ( $ENV{'request.state'} eq "published") {
+ if ($ENV{'request.state'} eq "published") {
if ( defined($ENV{'form.grade_target'} )
&& ($ENV{'form.grade_target'} eq 'tex')) {
return ($ENV{'form.grade_target'});
} elsif ( defined($ENV{'form.grade_target'} )
- && ($Apache::lonhomework::viewgrades == 'F' )) {
+ && ($Apache::lonhomework::viewgrades eq 'F' )) {
return ($ENV{'form.grade_target'});
}
- if ( defined($ENV{'form.submitted'})) {
+ if ( defined($ENV{'form.submitted'}) &&
+ ( !defined($ENV{'form.resetdata'}))) {
return ('grade', 'web');
} else {
return ('web');
@@ -206,12 +208,16 @@ sub check_access {
$datemsg = "was due on $lastdate, and answers will be available on $date";
}
if ($status eq 'CAN_ANSWER') {
- #check #tries
+ #check #tries, and if correct.
my $tries = $Apache::lonhomework::history{"resource.$id.tries"};
my $maxtries = &Apache::lonnet::EXT("resource.$id.maxtries");
if ( $tries eq '' ) { $tries = '0'; }
if ( $maxtries eq '' ) { $maxtries = '2'; }
if ($tries >= $maxtries) { $status = 'CANNOT_ANSWER'; }
+ if($Apache::lonhomework::history{"resource.$id.solved"}=~/^correct/
+ && lc($Apache::lonhomework::problemstatus) ne 'no') {
+ $status = 'CANNOT_ANSWER';
+ }
}
if (($status ne 'CLOSED') && ($Apache::lonhomework::type eq 'exam') &&
@@ -284,18 +290,19 @@ sub setuppermissions {
}
sub setupheader {
- my $request=$_[0];
- if ($ENV{'browser.mathml'}) {
- $request->content_type('text/xml');
- } else {
- $request->content_type('text/html');
- }
- if (!$Apache::lonxml::debug && ($ENV{'REQUEST_METHOD'} eq 'GET')) {
- &Apache::loncommon::no_cache($request);
- }
- $request->send_http_header;
- return OK if $request->header_only;
- return ''
+ my $request=$_[0];
+ if ($ENV{'browser.mathml'}) {
+ $request->content_type('text/xml');
+ } else {
+ $request->content_type('text/html');
+ }
+ $request->content_encoding('UTF-8');
+ if (!$Apache::lonxml::debug && ($ENV{'REQUEST_METHOD'} eq 'GET')) {
+ &Apache::loncommon::no_cache($request);
+ }
+ $request->send_http_header;
+ return OK if $request->header_only;
+ return ''
}
sub handle_save_or_undo {
@@ -370,17 +377,23 @@ sub analyze {
my %allparts;
my $rndseed=$ENV{'form.rndseed'};
&analyze_header($request);
+ my %prog_state=
+ &Apache::lonhtmlcommon::Create_PrgWin($request,'Analyze Progress',
+ 'Getting Problem Variants',
+ $ENV{'form.numtoanalyze'});
for(my $i=1;$i<$ENV{'form.numtoanalyze'}+1;$i++) {
+ &Apache::lonhtmlcommon::Increment_PrgWin($request,\%prog_state,
+ 'last problem');
my $subresult=&Apache::lonnet::ssi($request->uri,
('grade_target' => 'analyze'),
('rndseed' => $i));
&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'} };
+ my @parts;
+ if (defined(@{ $analyze{'parts'} })) {
+ @parts=@{ $analyze{'parts'} };
+ }
foreach my $part (@parts) {
if (!exists($allparts{$part})) {$allparts{$part}=1;};
if ($analyze{$part.'.type'} eq 'numericalresponse' ||
@@ -391,6 +404,8 @@ sub analyze {
}
}
}
+ &Apache::lonhtmlcommon::Update_PrgWin($request,\%prog_state,
+ 'Analyzing Results');
foreach my $part (keys(%allparts)) {
if (defined(@{ $overall{$part.'.answer'} })) {
$request->print('
Part '.$part.' |
');
@@ -404,6 +419,7 @@ sub analyze {
' is not analyzabale at this time');
}
}
+ &Apache::lonhtmlcommon::Close_PrgWin($request,\%prog_state);
&analyze_footer($request);
&Apache::lonhomework::showhash(%overall);
return $result;
@@ -413,7 +429,7 @@ sub editxmlmode {
my ($request,$file) = @_;
my $result;
my $problem=&Apache::lonnet::getfile($file);
- if ($problem == -1) {
+ if ($problem eq -1) {
&Apache::lonxml::error(" Unable to find $file");
$problem='';
}
@@ -429,7 +445,15 @@ sub editxmlmode {
&renderpage($request,$file);
} else {
my ($rows,$cols) = &Apache::edit::textarea_sizes(\$problem);
- my $xml_help = Apache::loncommon::help_open_topic("Problem_Editor_XML_Index",'Problem Editing Help');
+ my $xml_help = ''.
+ &Apache::loncommon::help_open_topic("Problem_Editor_XML_Index",'Problem Editing Help')
+ .' | '.
+ &Apache::loncommon::help_open_topic("Greek_Symbols",'Greek Symbols',
+ undef,undef,600)
+ .' | '.
+ &Apache::loncommon::help_open_topic("Other_Symbols",'Other Symbols',
+ undef,undef,600)
+ .' |
';
if ($cols > 80) { $cols = 80; }
if ($cols < 70) { $cols = 70; }
if ($rows < 20) { $rows = 20; }
@@ -461,7 +485,7 @@ sub renderpage {
foreach my $target (@targets) {
#my $t0 = [&gettimeofday()];
my $problem=&Apache::lonnet::getfile($file);
- if ($problem == -1) {
+ if ($problem eq -1) {
&Apache::lonxml::error(" Unable to find $file");
$problem='';
}
@@ -475,7 +499,7 @@ sub renderpage {
&Apache::lonxml::debug("Should be parsing now");
$result = &Apache::lonxml::xmlparse($request, $target, $problem,
&setup_vars($target),%mystyle);
-
+ undef($Apache::lonhomework::parsing_a_problem);
#$request->print("Result follows:");
if ($target eq 'modified') {
&handle_save_or_undo($request,\$problem,\$result);
@@ -490,6 +514,7 @@ sub renderpage {
#$result.="
Spent $td seconds processing target $target\n