--- loncom/homework/lonhomework.pm 2001/08/17 14:24:29 1.53 +++ loncom/homework/lonhomework.pm 2001/08/29 10:18:10 1.59 @@ -1,7 +1,7 @@ # The LON-CAPA Homework handler # Guy Albertelli # 11/30 Gerd Kortemeyer -# 6/1 Gerd Kortemeyer +# 6/1,8/17,8/18 Gerd Kortemeyer package Apache::lonhomework; use strict; @@ -10,6 +10,7 @@ use Apache::lonxml; use Apache::lonnet; use Apache::inputtags; use Apache::structuretags; +use Apache::randomlabel; use Apache::response; use Apache::hint; use Apache::outputtags; @@ -131,6 +132,13 @@ sub check_access { if ( $maxtries eq '' ) { $maxtries = '2'; } if ($tries >= $maxtries) { $status = 'CANNOT_ANSWER'; } } + + if (($status ne 'CLOSED') && ($Apache::lonhomework::type eq 'exam') && + (!$Apache::lonhomework::history{"resource.0.outtoken"})) { + return ('UNCHECKEDOUT','needs to be checked out'); + } + + &Apache::lonxml::debug("sending back :$status:$datemsg:"); if (($Apache::lonhomework::browse eq 'F') && ($status eq 'CLOSED')) { &Apache::lonxml::debug("should be allowed to browse a resource when closed"); @@ -218,11 +226,6 @@ sub renderpage { my $result = ''; &Apache::inputtags::initialize_inputtags; &Apache::edit::initialize_edit; - %Apache::lonhomework::results=(); - %Apache::lonhomework::history=&Apache::lonnet::restore(); - #ignore error conditions - my ($temp)=keys %Apache::lonhomework::history ; - if ($temp =~ m/^error:.*/) { %Apache::lonhomework::history=(); } if ($target eq 'web') { if (&Apache::lonnet::symbread() eq '') { if ($ENV{'request.state'} eq "construct") { @@ -255,14 +258,6 @@ sub renderpage { $request->print($result); } #$request->print(":Result ends"); - if ($target eq 'grade') { &showhash(%Apache::lonhomework::results); } - - #store new values - my ($temp) = keys %Apache::lonhomework::results; - if ( $temp ne '' ) { - &Apache::lonxml::debug("Store return message:". - &Apache::lonnet::cstore(\%Apache::lonhomework::results)); - } #my $td=&tv_interval($t0); } }