--- loncom/homework/lonhomework.pm 2005/04/29 21:22:33 1.205 +++ loncom/homework/lonhomework.pm 2005/07/13 19:48:07 1.213 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # The LON-CAPA Homework handler # -# $Id: lonhomework.pm,v 1.205 2005/04/29 21:22:33 albertel Exp $ +# $Id: lonhomework.pm,v 1.213 2005/07/13 19:48:07 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -85,13 +85,11 @@ sub get_target { return ($env{'form.grade_target'}); } elsif ( defined($env{'form.grade_target'} ) && ($Apache::lonhomework::viewgrades eq 'F' )) { - if ($env{'form.grade_target'} eq 'webgrade') { - if ($Apache::lonhomework::modifygrades eq 'F' ) { - return ($env{'form.grade_target'}); - } - } else { - return ($env{'form.grade_target'}); - } + return ($env{'form.grade_target'}); + } + if ($env{'form.webgrade'} && + $Apache::lonhomework::modifygrades eq 'F') { + return ('grade','webgrade'); } if ( defined($env{'form.submitted'}) && ( !defined($env{'form.resetdata'})) && @@ -126,10 +124,10 @@ sub get_target { if ( $env{'form.submit'} eq &mt('Submit Changes and View') ) { return ('modified','web','answer'); } else { - return ('modified','edit'); + return ('modified','no_output_web','edit'); } } else { - return ('edit'); + return ('no_output_web','edit'); } } else { return ('web'); @@ -168,10 +166,14 @@ sub send_footer { } sub proctor_checked_in { - my ($slot)=@_; + my ($slot_name,$slot)=@_; my @allowed=split(",",$slot->{'proctor'}); + my $version=$Apache::lonhomework::history{'resource.version'}; foreach my $possible (@allowed) { - if ($Apache::lonhomework::history{'resource.checkedin'} eq $possible) { + if ($Apache::lonhomework::history{"resource.$version.checkedin"} eq + $possible && + $Apache::lonhomework::history{"resource.$version.checkedin.slot"} + eq $slot_name) { return 1; } } @@ -226,7 +228,8 @@ sub check_ip_acc { } sub check_task_access { - #does it pass normal muster + # does it pass normal muster + # yes we really do want the default args passing my ($status,$datemsg)=&check_access; if ($status eq 'SHOW_ANSWER' || $status eq 'CLOSED' || @@ -238,14 +241,21 @@ sub check_task_access { if ($env{'request.state'} eq "construct") { return ($status,$datemsg); } - + my $version=$Apache::lonhomework::history{'resource.version'}; + if ($Apache::lonhomework::history{"resource.$version.checkedin"} && + $Apache::lonhomework::history{"resource.$version.status"} eq 'pass') { + return ('SHOW_ANSWER'); + } my ($id)=@_; - my @slots=split(':',&Apache::lonnet::EXT("resource.$id.available")); + my @slots= + (split(':',&Apache::lonnet::EXT("resource.$id.availablestudent")), + split(':',&Apache::lonnet::EXT("resource.$id.available"))); + # if (!@slots) { # return ($status,$datemsg); # } my $slotstatus='NOT_IN_A_SLOT'; - my $returned_slot; + my ($returned_slot,$slot_name); foreach my $slot (@slots) { &Apache::lonxml::debug("getting $slot"); my %slot=&Apache::lonnet::get_slot($slot); @@ -256,15 +266,24 @@ sub check_task_access { &Apache::lonxml::debug("$slot is good"); $slotstatus='NEEDS_CHECKIN'; $returned_slot=\%slot; + $slot_name=$slot; last; } } if ($slotstatus eq 'NEEDS_CHECKIN' && - &proctor_checked_in($returned_slot)) { + &proctor_checked_in($slot_name,$returned_slot)) { &Apache::lonxml::debug("protoctor checked in"); $slotstatus='CAN_ANSWER'; } - return ($slotstatus,$datemsg,$returned_slot); + if ( $slotstatus eq 'NOT_IN_A_SLOT' && + $Apache::lonhomework::history{"resource.$version.checkedin"}) { + if ($Apache::lonhomework::history{"resource.$version.status"} eq 'fail') { + return ('SHOW_ANSWER'); + } else { + return ('WAITING_FOR_GRADE'); + } + } + return ($slotstatus,$datemsg,$slot_name,$returned_slot); } # JB, 9/24/2002: Any changes in this function may require a change @@ -301,6 +320,9 @@ sub check_access { &Apache::lonxml::debug("checking for part :$id:"); &Apache::lonxml::debug("time:".time); + my ($symb)=&Apache::lonxml::whichuser(); + &Apache::lonxml::debug("symb:".$symb); + #if ($env{'request.state'} ne "construct" && $symb ne '') { if ($env{'request.state'} ne "construct") { my $allowed=&check_ip_acc(&Apache::lonnet::EXT("resource.$id.acc")); if (!$allowed && ($Apache::lonhomework::browse ne 'F')) { @@ -353,7 +375,8 @@ sub check_access { $datemsg = &mt("was due on")." $lastdate".&mt(", and answers will be available on")." $date"; } } - if ($status eq 'CAN_ANSWER') { + if ($status eq 'CAN_ANSWER' || + (($Apache::lonhomework::browse eq 'F') && ($status eq 'CLOSED'))) { #check #tries, and if correct. my $tries = $Apache::lonhomework::history{"resource.$id.tries"}; my $maxtries = &Apache::lonnet::EXT("resource.$id.maxtries"); @@ -688,7 +711,9 @@ sub editxmlmode { $bodytag=&Apache::loncommon::bodytag(); } my $html=&Apache::lonxml::xmlbegin(); - $result.=$html.$bodytag.&Apache::lonxml::message_location().' + $result.=$html.$bodytag. + &renderpage($request,$file,['no_output_web'],1). + &Apache::lonxml::message_location().'