--- loncom/homework/bridgetask.pm 2006/11/06 17:50:17 1.184.2.4 +++ loncom/homework/bridgetask.pm 2006/10/17 15:11:11 1.185 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # definition of tags that give a structure to a document # -# $Id: bridgetask.pm,v 1.184.2.4 2006/11/06 17:50:17 albertel Exp $ +# $Id: bridgetask.pm,v 1.185 2006/10/17 15:11:11 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -43,7 +43,7 @@ use LONCAPA; BEGIN { - &Apache::lonxml::register('Apache::bridgetask',('Task','IntroParagraph','Dimension','Question','QuestionText','Setup','Instance','InstanceText','Criteria','GraderNote','ClosingParagraph')); + &Apache::lonxml::register('Apache::bridgetask',('Task','IntroParagraph','Dimension','Question','QuestionText','Setup','Instance','InstanceText','Criteria','ClosingParagraph')); } my %dimension; @@ -105,7 +105,7 @@ sub check_in { sub check_in_sequence { my ($user,$domain,$slot_name) = @_; my $navmap = Apache::lonnavmaps::navmap->new(); - my ($symb) = &Apache::lonxml::whichuser(); + my ($symb) = &Apache::lonnet::whichuser(); my ($map) = &Apache::lonnet::decode_symb($symb); my @resources = $navmap->retrieveResources($map, sub { $_[0]->is_problem() },0,0); @@ -225,7 +225,7 @@ sub add_previous_version_button { } sub add_grading_button { - my (undef,$cid)=&Apache::lonxml::whichuser(); + my (undef,$cid)=&Apache::lonnet::whichuser(); my $cnum=$env{'course.'.$cid.'.num'}; my $cdom=$env{'course.'.$cid.'.domain'}; my %sections = &Apache::loncommon::get_sections($cdom,$cnum); @@ -326,22 +326,9 @@ sub style { my ($target) = @_; if ($target eq 'web' || $target eq 'webgrade') { - my $style = (< STYLE - if ($env{'browser.type'} eq 'explorer' - && $env{'browser.os'} eq 'win' ) { - if ($env{'browser.version'} < 7) { - $style .= (< -STYLE - } else { - $style .= (< -STYLE - } - } - return $style; } return; } @@ -401,7 +388,7 @@ sub internal_location { } sub submission_time_stamp { - my ($symb,$courseid,$udom,$uname)=&Apache::lonxml::whichuser(); + my ($symb,$courseid,$udom,$uname)=&Apache::lonnet::whichuser(); my $submissiontime; my $version=$Apache::lonhomework::history{'resource.0.version'}; for (my $v=$Apache::lonhomework::history{'version'};$v>0;$v--) { @@ -439,7 +426,7 @@ sub submission_time_stamp { sub file_list { my ($files,$uname,$udom) = @_; if (!defined($uname) || !defined($udom)) { - (undef,undef,$udom,$uname) = &Apache::lonxml::whichuser(); + (undef,undef,$udom,$uname) = &Apache::lonnet::whichuser(); } my $file_url = '/uploaded/'.$udom.'/'.$uname.'/portfolio/'; @@ -500,7 +487,7 @@ sub done_screen { my ($version) = @_; my $title=&Apache::lonnet::gettitle(); my @files=split(',',$Apache::lonhomework::history{'resource.'.$version.'.0.bridgetask.portfiles'}); - my (undef,undef,$domain,$user)= &Apache::lonxml::whichuser(); + my (undef,undef,$domain,$user)= &Apache::lonnet::whichuser(); my $files = '
    '; my $msg; foreach my $file (@files) { @@ -844,7 +831,7 @@ sub get_key_todo { if (defined($env{'form.regradeaspecificsubmission'}) && defined($env{'form.gradinguser'}) && defined($env{'form.gradingdomain'}) ) { - my ($symb,$cid)=&Apache::lonxml::whichuser(); + my ($symb,$cid)=&Apache::lonnet::whichuser(); my $cnum = $env{'course.'.$cid.'.num'}; my $cdom = $env{'course.'.$cid.'.domain'}; my $uname = $env{'form.gradinguser'}; @@ -1155,14 +1142,35 @@ DONEBUTTON $env{'user.name'}.':'.$env{'user.domain'}; if ($review) { $Apache::lonhomework::results{"resource.$version.0.status"}='review'; + if ($env{'form.queue'} eq 'reviewqueue') { + &check_queue_unlock($env{'form.queue'}); + &Apache::lonxml::debug(" still needs review not changing status."); + } else { + if ($env{'form.queue'} ne 'none') { + &move_between_queues($env{'form.queue'},'reviewqueue'); + } else { + &add_to_queue('reviewqueue',\%queue_data); + } + } } elsif ($ungraded) { $Apache::lonhomework::results{"resource.$version.0.status"}='ungraded'; + if ($env{'form.queue'} eq 'reviewqueue') { + &Apache::lonxml::debug("moving back."); + &move_between_queues($env{'form.queue'}, + 'gradingqueue'); + } elsif ($env{'form.queue'} eq 'none' ) { + &add_to_queue('gradingqueue',\%queue_data); + } else { + &check_queue_unlock($env{'form.queue'}); + } } elsif ($mandatory_failed) { $Apache::lonhomework::results{"resource.$version.0.status"}='fail'; $Apache::lonhomework::results{"resource.$version.0.solved"}='incorrect_by_override'; $Apache::lonhomework::results{"resource.$version.0.award"}='INCORRECT'; $Apache::lonhomework::results{"resource.$version.0.awarded"}='0'; - my ($symb,$courseid,$udom,$uname)=&Apache::lonxml::whichuser(); + &remove_from_queue($env{'form.queue'}); + + my ($symb,$courseid,$udom,$uname)=&Apache::lonnet::whichuser(); if ($env{'form.regrade'} ne 'yes') { $Apache::lonhomework::results{"resource.$version.0.bridgetask.portfiles"}= @@ -1178,7 +1186,9 @@ DONEBUTTON $Apache::lonhomework::results{"resource.$version.0.solved"}='correct_by_override'; $Apache::lonhomework::results{"resource.$version.0.award"}='EXACT_ANS'; $Apache::lonhomework::results{"resource.$version.0.awarded"}='1'; - my ($symb,$courseid,$udom,$uname)=&Apache::lonxml::whichuser(); + &remove_from_queue($env{'form.queue'}); + + my ($symb,$courseid,$udom,$uname)=&Apache::lonnet::whichuser(); if ($env{'form.regrade'} ne 'yes') { $Apache::lonhomework::results{"resource.$version.0.bridgetask.portfiles"}= $Apache::lonhomework::history{"resource.$version.0.bridgetask.portfiles"}; @@ -1201,34 +1211,6 @@ DONEBUTTON } &minimize_storage(); &Apache::structuretags::finalize_storage(); - - # data stored, now handle queue - if ($review) { - if ($env{'form.queue'} eq 'reviewqueue') { - &check_queue_unlock($env{'form.queue'}); - &Apache::lonxml::debug(" still needs review not changing status."); - } else { - if ($env{'form.queue'} ne 'none') { - &move_between_queues($env{'form.queue'},'reviewqueue'); - } else { - &add_to_queue('reviewqueue',\%queue_data); - } - } - } elsif ($ungraded) { - if ($env{'form.queue'} eq 'reviewqueue') { - &Apache::lonxml::debug("moving back."); - &move_between_queues($env{'form.queue'}, - 'gradingqueue'); - } elsif ($env{'form.queue'} eq 'none' ) { - &add_to_queue('gradingqueue',\%queue_data); - } else { - &check_queue_unlock($env{'form.queue'}); - } - } elsif ($mandatory_failed) { - &remove_from_queue($env{'form.queue'}); - } else { - &remove_from_queue($env{'form.queue'}); - } } if (exists($Apache::lonhomework::results{'INTERNAL_store'})) { # instance generation occured and hasn't yet been stored @@ -1286,7 +1268,7 @@ sub move_between_queues { sub check_queue_unlock { my ($queue,$key,$allow_not_me)=@_; if ($queue eq 'none') { return 'ok'; } - my ($symb,$cid,$udom,$uname)=&Apache::lonxml::whichuser(); + my ($symb,$cid,$udom,$uname)=&Apache::lonnet::whichuser(); if (!defined($key)) { $key="$symb\0queue\0$uname:$udom"; } @@ -1309,7 +1291,7 @@ sub in_queue { if ($queue eq 'none') { return 0; } if (!defined($symb) || !defined($cdom) || !defined($cnum) || !defined($udom) || !defined($uname)) { - ($symb,my $cid,$udom,$uname)=&Apache::lonxml::whichuser(); + ($symb,my $cid,$udom,$uname)=&Apache::lonnet::whichuser(); $cnum=$env{'course.'.$cid.'.num'}; $cdom=$env{'course.'.$cid.'.domain'}; } @@ -1328,7 +1310,7 @@ sub remove_from_queue { if ($queue eq 'none') { return 'ok'; } if (!defined($symb) || !defined($cdom) || !defined($cnum) || !defined($udom) || !defined($uname)) { - ($symb,my $cid,$udom,$uname)=&Apache::lonxml::whichuser(); + ($symb,my $cid,$udom,$uname)=&Apache::lonnet::whichuser(); $cnum=$env{'course.'.$cid.'.num'}; $cdom=$env{'course.'.$cid.'.domain'}; } @@ -1353,7 +1335,7 @@ sub setup_env_for_other_user { sub get_queue_data { my ($queue,$udom,$uname)=@_; - my ($symb,$cid,$other_udom,$other_uname)=&Apache::lonxml::whichuser(); + my ($symb,$cid,$other_udom,$other_uname)=&Apache::lonnet::whichuser(); if (!$uname || !$udom) { $uname=$other_uname; $udom =$other_udom; @@ -1399,7 +1381,7 @@ sub check_queue_for_key { sub add_to_queue { my ($queue,$user_data)=@_; if ($queue eq 'none') { return 'ok'; } - my ($symb,$cid,$udom,$uname)=&Apache::lonxml::whichuser(); + my ($symb,$cid,$udom,$uname)=&Apache::lonnet::whichuser(); if (!$cid || $env{'request.state'} eq 'construct') { return 'no_queue'; } @@ -1437,7 +1419,7 @@ sub get_limited_classlist { sub show_queue { my ($queue,$with_selects)=@_; my $result; - my ($symb,$cid,$udom,$uname)=&Apache::lonxml::whichuser(); + my ($symb,$cid,$udom,$uname)=&Apache::lonnet::whichuser(); my $cnum=$env{'course.'.$cid.'.num'}; my $cdom=$env{'course.'.$cid.'.domain'}; @@ -1564,7 +1546,7 @@ FORM sub get_queue_counts { my ($queue)=@_; my $result; - my ($symb,$cid,$udom,$uname)=&Apache::lonxml::whichuser(); + my ($symb,$cid,$udom,$uname)=&Apache::lonnet::whichuser(); my $cnum=$env{'course.'.$cid.'.num'}; my $cdom=$env{'course.'.$cid.'.domain'}; @@ -1581,6 +1563,7 @@ sub get_queue_counts { foreach my $key (sort(keys(%queue))) { my ($symb,$uname,$udom) = &decode_queue_key($key); if (!defined($classlist->{$uname.':'.$udom})) { next; } + if ($key=~/locked$/) { $locks++; } elsif ($key=~/timestamp$/) { @@ -1621,7 +1604,7 @@ sub decode_queue_key { sub queue_key_locked { my ($queue,$key,$cdom,$cnum)=@_; if (!defined($cdom) || !defined($cnum)) { - my (undef,$cid)=&Apache::lonxml::whichuser(); + my (undef,$cid)=&Apache::lonnet::whichuser(); $cnum=$env{'course.'.$cid.'.num'}; $cdom=$env{'course.'.$cid.'.domain'}; } @@ -1733,7 +1716,7 @@ sub find_mid_grade { sub lock_key { my ($queue,$todo)=@_; my $me=$env{'user.name'}.':'.$env{'user.domain'}; - my (undef,$cid)=&Apache::lonxml::whichuser(); + my (undef,$cid)=&Apache::lonnet::whichuser(); my $cnum=$env{'course.'.$cid.'.num'}; my $cdom=$env{'course.'.$cid.'.domain'}; my $success=&Apache::lonnet::newput($queue,{"$todo\0locked"=> $me}, @@ -1748,7 +1731,7 @@ sub lock_key { sub get_queue_symb_status { my ($queue,$symb,$cdom,$cnum) = @_; if (!defined($cdom) || !defined($cnum)) { - my (undef,$cid)=&Apache::lonxml::whichuser(); + my (undef,$cid)=&Apache::lonnet::whichuser(); $cnum=$env{'course.'.$cid.'.num'}; $cdom=$env{'course.'.$cid.'.domain'}; } @@ -1772,7 +1755,7 @@ sub get_queue_symb_status { sub get_from_queue { my ($queue)=@_; my $result; - my ($symb,$cid,$udom,$uname)=&Apache::lonxml::whichuser(); + my ($symb,$cid,$udom,$uname)=&Apache::lonnet::whichuser(); my $cnum=$env{'course.'.$cid.'.num'}; my $cdom=$env{'course.'.$cid.'.domain'}; my $todo=&find_mid_grade($queue,$symb,$cdom,$cnum); @@ -1848,7 +1831,7 @@ sub get_from_queue { } sub select_user { - my ($symb,$cid)=&Apache::lonxml::whichuser(); + my ($symb,$cid)=&Apache::lonnet::whichuser(); my @chosen_sections= &Apache::loncommon::get_env_multiple('form.chosensections'); @@ -2177,7 +2160,7 @@ sub get_criteria { } else { my $dim_status=$Apache::lonhomework::history{"resource.$version.0.$dim.status"}; my $mandatory='Mandatory'; - if (&Apache::lonxml::get_param('Mandatory',$parstack,$safeeval) eq 'N') { + if ($Apache::bridgetask::dimensionmandatory{$dim} eq 'N') { $mandatory='Optional'; } my $dim_info="
    \n"; @@ -2224,6 +2207,33 @@ sub get_criteria { $result.=$dimension{$id}{'result'}; next; } + my $status= &get_criteria('status', $version,$dim,$id); + my $comment=&get_criteria('comment',$version,$dim,$id); + my $mandatory=($dimension{$dim}{'criteria.'.$id.'.mandatory'} ne 'N'); + if ($mandatory) { + $mandatory='Mandatory'; + } else { + $mandatory='Optional'; + } + if ($status eq 'fail') { + } elsif ($status eq 'pass') { + } else { + &Apache::lonxml::error("Student viewing a graded bridgetask was shown a status of $status"); + } + my $status_display=$status; + $status_display=~s/^([a-z])/uc($1)/e; + $result.= + '

    ' + .$mandatory.' Criteria

    '; + $result.= + &nested_parse(\$dimension{$dim}{'criteria.'.$id}, + [@_],{'set_dim_id' => $id}); + $result.='

    '.$status_display.'

    '; + if ($comment) { + $result.='

    '. + &mt('Comment: [_1]',$comment).'

    '; + } + $result.='
    '; } } } @@ -2481,7 +2491,6 @@ sub end_InstanceText { sub start_Criteria { my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_; my $criteria=&Apache::lonxml::get_all_text('/criteria',$parser,$style); - my $result = ''; if ($target eq 'web' || $target eq 'webgrade' || $target eq 'grade') { my $dim = &get_dim_id(); my $id=&get_id($parstack,$safeeval); @@ -2499,67 +2508,17 @@ sub start_Criteria { $dimension{$dim}{'criteria.'.$id.'.mandatory'}= &Apache::lonxml::get_param('Mandatory',$parstack,$safeeval); push(@{$dimension{$dim}{'criterias'}},$id); - - my $version=&get_version(); - my $task_status = - $Apache::lonhomework::history{"resource.$version.0.status"}; - if ($target eq 'web' - && ($task_status eq 'pass' || $task_status eq 'fail')) { - my $status= &get_criteria('status', $version,$dim,$id); - my $comment=&get_criteria('comment',$version,$dim,$id); - my $mandatory=($dimension{$dim}{'criteria.'.$id.'.mandatory'} ne 'N'); - if ($mandatory) { - $mandatory='Mandatory'; - } else { - $mandatory='Optional'; - } - my $status_display=$status; - $status_display=~s/^([a-z])/uc($1)/e; - $result.= - '

    ' - .$mandatory.' Criteria

    '; - $result.= - &nested_parse(\$dimension{$dim}{'criteria.'.$id},[@_]); - $result.='

    '.$status_display.'

    '; - if ($comment =~ /\w/) { - $result.='

    '. - &mt('Comment: [_1]',$comment).'

    '; - } - $result.='
    '; - } } } - return $result; + return ''; } sub end_Criteria { } -sub start_GraderNote { - my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_; - - if ($target eq 'webgrade') { - return '
    '. - &mt('Note to graders:').''; - } - my $note=&Apache::lonxml::get_all_text('/gradernote',$parser,$style); - return; -} - -sub end_GraderNote { - my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_; - - if ($target eq 'webgrade') { - return '
    '; - } - return; -} - - - sub proctor_validation_screen { my ($slot) = @_; - my (undef,undef,$domain,$user) = &Apache::lonxml::whichuser(); + my (undef,undef,$domain,$user) = &Apache::lonnet::whichuser(); my $url=&Apache::lonnet::studentphoto($domain,$user,'jpg'); my $name=&Apache::loncommon::plainname($user,$domain);