version 1.206, 2005/05/03 00:05:41
|
version 1.212, 2005/07/12 21:50:05
|
Line 85 sub get_target {
|
Line 85 sub get_target {
|
return ($env{'form.grade_target'}); |
return ($env{'form.grade_target'}); |
} elsif ( defined($env{'form.grade_target'} ) |
} elsif ( defined($env{'form.grade_target'} ) |
&& ($Apache::lonhomework::viewgrades eq 'F' )) { |
&& ($Apache::lonhomework::viewgrades eq 'F' )) { |
if ($env{'form.grade_target'} eq 'webgrade') { |
return ($env{'form.grade_target'}); |
if ($Apache::lonhomework::modifygrades eq 'F' ) { |
} |
return ($env{'form.grade_target'}); |
if ($env{'form.webgrade'} && |
} |
$Apache::lonhomework::modifygrades eq 'F') { |
} else { |
return ('grade','webgrade'); |
return ($env{'form.grade_target'}); |
|
} |
|
} |
} |
if ( defined($env{'form.submitted'}) && |
if ( defined($env{'form.submitted'}) && |
( !defined($env{'form.resetdata'})) && |
( !defined($env{'form.resetdata'})) && |
Line 126 sub get_target {
|
Line 124 sub get_target {
|
if ( $env{'form.submit'} eq &mt('Submit Changes and View') ) { |
if ( $env{'form.submit'} eq &mt('Submit Changes and View') ) { |
return ('modified','web','answer'); |
return ('modified','web','answer'); |
} else { |
} else { |
return ('modified','edit'); |
return ('modified','no_output_web','edit'); |
} |
} |
} else { |
} else { |
return ('edit'); |
return ('no_output_web','edit'); |
} |
} |
} else { |
} else { |
return ('web'); |
return ('web'); |
Line 168 sub send_footer {
|
Line 166 sub send_footer {
|
} |
} |
|
|
sub proctor_checked_in { |
sub proctor_checked_in { |
my ($slot)=@_; |
my ($slot_name,$slot)=@_; |
my @allowed=split(",",$slot->{'proctor'}); |
my @allowed=split(",",$slot->{'proctor'}); |
|
my $version=$Apache::lonhomework::history{'resource.version'}; |
foreach my $possible (@allowed) { |
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; |
return 1; |
} |
} |
} |
} |
Line 226 sub check_ip_acc {
|
Line 228 sub check_ip_acc {
|
} |
} |
|
|
sub check_task_access { |
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; |
my ($status,$datemsg)=&check_access; |
if ($status eq 'SHOW_ANSWER' || |
if ($status eq 'SHOW_ANSWER' || |
$status eq 'CLOSED' || |
$status eq 'CLOSED' || |
Line 238 sub check_task_access {
|
Line 241 sub check_task_access {
|
if ($env{'request.state'} eq "construct") { |
if ($env{'request.state'} eq "construct") { |
return ($status,$datemsg); |
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 ($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) { |
# if (!@slots) { |
# return ($status,$datemsg); |
# return ($status,$datemsg); |
# } |
# } |
Line 261 sub check_task_access {
|
Line 271 sub check_task_access {
|
} |
} |
} |
} |
if ($slotstatus eq 'NEEDS_CHECKIN' && |
if ($slotstatus eq 'NEEDS_CHECKIN' && |
&proctor_checked_in($returned_slot)) { |
&proctor_checked_in($slot_name,$returned_slot)) { |
&Apache::lonxml::debug("protoctor checked in"); |
&Apache::lonxml::debug("protoctor checked in"); |
$slotstatus='CAN_ANSWER'; |
$slotstatus='CAN_ANSWER'; |
} |
} |
|
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); |
return ($slotstatus,$datemsg,$slot_name,$returned_slot); |
} |
} |
|
|
Line 302 sub check_access {
|
Line 320 sub check_access {
|
&Apache::lonxml::debug("checking for part :$id:"); |
&Apache::lonxml::debug("checking for part :$id:"); |
&Apache::lonxml::debug("time:".time); |
&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") { |
if ($env{'request.state'} ne "construct") { |
my $allowed=&check_ip_acc(&Apache::lonnet::EXT("resource.$id.acc")); |
my $allowed=&check_ip_acc(&Apache::lonnet::EXT("resource.$id.acc")); |
if (!$allowed && ($Apache::lonhomework::browse ne 'F')) { |
if (!$allowed && ($Apache::lonhomework::browse ne 'F')) { |
Line 354 sub check_access {
|
Line 375 sub check_access {
|
$datemsg = &mt("was due on")." $lastdate".&mt(", and answers will be available on")." $date"; |
$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. |
#check #tries, and if correct. |
my $tries = $Apache::lonhomework::history{"resource.$id.tries"}; |
my $tries = $Apache::lonhomework::history{"resource.$id.tries"}; |
my $maxtries = &Apache::lonnet::EXT("resource.$id.maxtries"); |
my $maxtries = &Apache::lonnet::EXT("resource.$id.maxtries"); |
Line 715 sub editxmlmode {
|
Line 737 sub editxmlmode {
|
# Render the page in whatever target desired. |
# Render the page in whatever target desired. |
# |
# |
sub renderpage { |
sub renderpage { |
my ($request,$file) = @_; |
my ($request,$file,$targets) = @_; |
|
|
my (@targets) = &get_target(); |
my @targets = @{$targets || [&get_target()]}; |
&Apache::lonhomework::showhashsubset(\%env,'form.'); |
&Apache::lonhomework::showhashsubset(\%env,'form.'); |
&Apache::lonxml::debug("Running targets ".join(':',@targets)); |
&Apache::lonxml::debug("Running targets ".join(':',@targets)); |
my $overall_result; |
my $overall_result; |
Line 730 sub renderpage {
|
Line 752 sub renderpage {
|
# $request->print(" You most likely shouldn't see me."); |
# $request->print(" You most likely shouldn't see me."); |
#} |
#} |
#my $t0 = [&gettimeofday()]; |
#my $t0 = [&gettimeofday()]; |
|
my $output=1; |
|
if ($target eq 'no_output_web') { |
|
$target = 'web'; $output=0; |
|
} |
my $problem=&Apache::lonnet::getfile($file); |
my $problem=&Apache::lonnet::getfile($file); |
if ($problem eq -1) { |
if ($problem eq -1) { |
&Apache::lonxml::error("<b> ".&mt('Unable to find')." <i>$file</i></b>"); |
&Apache::lonxml::error("<b> ".&mt('Unable to find')." <i>$file</i></b>"); |
Line 737 sub renderpage {
|
Line 763 sub renderpage {
|
} |
} |
|
|
my %mystyle; |
my %mystyle; |
my $result = ''; |
|
if ($target eq 'analyze') { %Apache::lonhomework::analyze=(); } |
if ($target eq 'analyze') { %Apache::lonhomework::analyze=(); } |
if ($target eq 'answer') { &showhash(%Apache::lonhomework::history); } |
if ($target eq 'answer') { &showhash(%Apache::lonhomework::history); } |
if ($target eq 'web') {&Apache::lonhomework::showhashsubset(\%env,'^form');} |
if ($target eq 'web') {&Apache::lonhomework::showhashsubset(\%env,'^form');} |
|
|
&Apache::lonxml::debug("Should be parsing now"); |
&Apache::lonxml::debug("Should be parsing now"); |
$result = &Apache::lonxml::xmlparse($request, $target, $problem, |
my $result = &Apache::lonxml::xmlparse($request, $target, $problem, |
&setup_vars($target),%mystyle); |
&setup_vars($target),%mystyle); |
undef($Apache::lonhomework::parsing_a_problem); |
undef($Apache::lonhomework::parsing_a_problem); |
|
if (!$output) { $result = &Apache::lonxml::message_location(); } |
#$request->print("Result follows:"); |
#$request->print("Result follows:"); |
if ($target eq 'modified') { |
if ($target eq 'modified') { |
&handle_save_or_undo($request,\$problem,\$result); |
&handle_save_or_undo($request,\$problem,\$result); |
Line 930 sub handler {
|
Line 956 sub handler {
|
&renderpage($request,$file); |
&renderpage($request,$file); |
} elsif ($env{'form.problemmode'} eq &mt('EditXML') || |
} elsif ($env{'form.problemmode'} eq &mt('EditXML') || |
$env{'form.problemmode'} eq 'EditXML') { |
$env{'form.problemmode'} eq 'EditXML') { |
|
&renderpage($request,$file,['no_output_web']); |
&editxmlmode($request,$file); |
&editxmlmode($request,$file); |
} elsif ($env{'form.problemmode'} eq &mt('Calculate answers')) { |
} elsif ($env{'form.problemmode'} eq &mt('Calculate answers')) { |
&analyze($request,$file); |
&analyze($request,$file); |