--- loncom/homework/bridgetask.pm 2005/05/03 05:31:51 1.15 +++ loncom/homework/bridgetask.pm 2005/05/09 21:55:01 1.19 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # definition of tags that give a structure to a document # -# $Id: bridgetask.pm,v 1.15 2005/05/03 05:31:51 albertel Exp $ +# $Id: bridgetask.pm,v 1.19 2005/05/09 21:55:01 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -95,14 +95,17 @@ sub add_grading_button { sub start_Task { my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_; - &Apache::structuretags::initialize_storage(); - &Apache::lonhomework::showhash(%Apache::lonhomework::history); my ($status,$accessmsg,$slot); + if ($target ne 'webgrade') { + &Apache::structuretags::initialize_storage(); + &Apache::lonhomework::showhash(%Apache::lonhomework::history); + } + $Apache::lonhomework::parsing_a_task=1; #should get back a or the neccesary stuff to start XML/MathML my ($result,$head_tag_start,$body_tag_start,$form_tag_start)= &Apache::structuretags::page_start($target,$token,$tagstack,$parstack,$parser,$safeeval); - + if ($target eq 'web') { $body_tag_start.=&add_previous_version_button(); if ($Apache::lonhomework::modifygrades) { @@ -177,15 +180,21 @@ sub start_Task { } } elsif ($target eq 'webgrade') { $result.=$head_tag_start.$body_tag_start.$form_tag_start; + $result.= + ''; $result.=&show_queue(); my $todo=&get_from_queue(); if ($todo) { + &setup_env_for_other_user($todo,$safeeval); my ($symb,$uname,$udom)=&decode_queue_key($todo); - $result.="\n".'
Found'. - $symb.':'.$uname.':'.$udom.'
'; + $result.="\n".'
Found '. + &Apache::lonnet::gettitle($symb).' for '.$uname.' at '.$udom.'
'; $result.=''; + &Apache::lonnet::escape($todo).'" />'; $Apache::bridgetask::queue_key=$todo; + &Apache::structuretags::initialize_storage(); + &Apache::lonhomework::showhash(%Apache::lonhomework::history); + $result.="\n".''; } else { $result.="\n". '
No user to be graded.
'; @@ -238,7 +247,7 @@ sub end_Task { } } } elsif ($target eq 'webgrade') { - $result.="\n
"; + $result.="\n
"; $result.=' '; $result.='[0]; - my %slot_data=&Apache::lonnet::get_slot($slot); - $result.="End time: ".&Apache::lonlocal::locallocaltime($slot_data{'endtime'}).""; + if ($key=~/locked$/) { + my ($symb,$uname,$udom) = &decode_queue_key($key); + my $title=&Apache::lonnet::gettitle($symb); + $result.="$title$uname"; + $result.='lock'.$queue{$key}.''; + } elsif ($key=~/timestamp$/) { + my ($symb,undef) = split("\0",$key); + my $title=&Apache::lonnet::gettitle($symb); + $result.="$title"; + $result.='last queue modification time'. + &Apache::lonlocal::locallocaltime($queue{$key}).""; + } else { + my ($symb,$uname,$udom) = &decode_queue_key($key); + my $title=&Apache::lonnet::gettitle($symb); + $result.="$title$uname"; + my $slot=$queue{$key}->[0]; + my %slot_data=&Apache::lonnet::get_slot($slot); + $result.='queue entryEnd time: '.&Apache::lonlocal::locallocaltime($slot_data{'endtime'}).""; + } } $result.="
\n"; return $result; @@ -305,12 +335,12 @@ sub queue_key_locked { sub pick_from_queue_data { my ($check_section,$queue,$cdom,$cnum)=@_; - foreach my $key (sort(keys(%$queue))) { + foreach my $key (keys(%$queue)) { my ($symb,$uname,$udom)=&decode_queue_key($key); if ($check_section) { my $section=&Apache::lonnet::getsection($uname,$udom); - if ($section ne $check_section) { - &Apache::lonnet::logthis("not my sec"); + if ($section eq $check_section) { + &Apache::lonnet::logthis("my sec"); next; } } @@ -331,7 +361,7 @@ sub pick_from_queue_data { sub find_mid_grade { my ($symb,$cdom,$cnum)=@_; - my $todo=$env{'form.gradingkey'}; + my $todo=&Apache::lonnet::unescape($env{'form.gradingkey'}); my $me=$env{'user.name'}.'@'.$env{'user.domain'}; if ($todo) { my $who=&queue_key_locked($todo,$cdom,$cnum); @@ -359,6 +389,7 @@ sub get_from_queue { # FIXME need to find if I am 'mid grading' $todo=&find_mid_grade($symb,$cdom,$cnum); &Apache::lonnet::logthis("found ".join(':',&decode_queue_key($todo))); + if ($todo) { return $todo; } while (1) { my $starttime=time; &Apache::lonnet::put('gradingqueue',{"$symb\0timestamp"=>$starttime}, @@ -438,11 +469,18 @@ sub end_ClosingParagraph { return $result; } +sub get_id { + my ($parstack,$safeeval)=@_; + my $id=&Apache::lonxml::get_param('id',$parstack,$safeeval); + if (!$id) { $id=$Apache::lonxml::curdepth; } + return $id; +} + my %dimension; sub start_Dimension { my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_; undef(%dimension); - my $dim_id=$Apache::lonxml::curdepth; + my $dim_id=&get_id($parstack,$safeeval); $Apache::bridgetask::dimension=$dim_id; push(@Apache::bridgetask::dimensionlist,$dim_id); undef(@Apache::bridgetask::instance); @@ -458,22 +496,50 @@ sub get_instance { return $order[0]; } -sub end_Dimension { - my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_; - my $result; - if ($target eq 'web') { - my $instance=&get_instance(); - $result=$dimension{'intro'}.$dimension{$instance.'.text'}; - } elsif ($target eq 'webgrade') { +{ + my $last_link; + sub end_Dimension { + my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_; + my $result; my $instance=&get_instance(); - $result.="\n".''; - foreach my $id (@{$dimension{$instance.'.criterias'}}) { - $result.=''; + if ($target eq 'web') { + $result=$dimension{'intro'}.$dimension{$instance.'.text'}; + } elsif ($target eq 'webgrade') { + foreach my $id (@{$dimension{$instance.'.criterias'}}) { + my $link='criteria_'.$instance.'_'.$id; + $result.=''. + ''. + ''. + ''; + $last_link=$link; + } + } elsif ($target eq 'grade') { + my $optional_passed=0; + foreach my $id (@{$dimension{$instance.'.criterias'}}) { + if ($env{'form.HWVAL_criteria_'.$instance.'_'.$id} eq 'pass') { + } elsif ($env{'form.HWVAL_criteria_'.$instance.'_'.$id} eq 'fail') { + } elsif ($env{'form.HWVAL_criteria_'.$instance.'_'.$id} eq 'ungraded') { + } elsif ($env{'form.HWVAL_criteria_'.$instance.'_'.$id} eq 'review') { + } + } } - $result.='
'. - $dimension{$instance.'.criteria.'.$id}.'
'. + ''. + ''. + '
'. + #$dimension{$instance.'.criteria.'.$id}. + '
Additional Comment for Student
'. + ''. + '
'. + '
'. + '
'. + '
'. + '
'. + '
'. + 'Prev
'. + 'Next
'. + '
'; + return $result; } - return $result; } sub start_IntroParagraph { @@ -500,9 +566,12 @@ sub end_IntroParagraph { sub start_Instance { my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_; - push(@{$dimension{'instances'}},$Apache::lonxml::curdepth); - push(@Apache::bridgetask::instance,$Apache::lonxml::curdepth); - push(@Apache::bridgetask::instancelist,$Apache::lonxml::curdepth); + my $id=&get_id($parstack,$safeeval); + push(@{$dimension{'instances'}},$id); + push(@Apache::bridgetask::instance,$id); + push(@Apache::bridgetask::instancelist,$id); + $dimension{$instance_id.'.optionalrequired'}= + &Apache::lonxml::get_param('OptionalRequired',$parstack,$safeeval); return ''; } @@ -541,8 +610,10 @@ sub end_Criteria { my $instance_id=$Apache::bridgetask::instance[-1]; if ($target eq 'web' || $target eq 'webgrade') { my $criteria=&Apache::lonxml::endredirection(); - my $id=$Apache::lonxml::curdepth; + my $id=&get_id($parstack,$safeeval); $dimension{$instance_id.'.criteria.'.$id}=$criteria; + $dimension{$instance_id.'.criteria.'.$id.'.mandatory'}= + &Apache::lonxml::get_param('Mandatory',$parstack,$safeeval); push(@{$dimension{$instance_id.'.criterias'}},$id); } return '';