--- loncom/homework/bridgetask.pm 2005/12/06 10:13:15 1.88 +++ loncom/homework/bridgetask.pm 2005/12/21 18:08:28 1.90 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # definition of tags that give a structure to a document # -# $Id: bridgetask.pm,v 1.88 2005/12/06 10:13:15 albertel Exp $ +# $Id: bridgetask.pm,v 1.90 2005/12/21 18:08:28 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -81,11 +81,12 @@ sub proctor_check_auth { } if ($authenticated && $type eq 'Task') { my $version= - $Apache::lonhomework::results{'resource.version'}= - ++$Apache::lonhomework::history{'resource.version'}; - $Apache::lonhomework::results{"resource.$version.checkedin"}= + $Apache::lonhomework::history{'resource.0.version'}; + $version++; + $Apache::lonhomework::results{'resource.0.version'}=$version; + $Apache::lonhomework::results{"resource.$version.0.checkedin"}= $user.'@'.$domain; - $Apache::lonhomework::results{"resource.$version.checkedin.slot"}= + $Apache::lonhomework::results{"resource.$version.0.checkedin.slot"}= $slot_name; foreach my $key (keys(%Apache::lonhomework::history)) { if ($key=~/^resource\.0\./) { @@ -94,7 +95,7 @@ sub proctor_check_auth { } return 1; } elsif ($authenticated && $type eq 'problem') { - &Apache::lonxml::debug("authed #slot_name"); + &Apache::lonxml::debug("authed $slot_name"); $Apache::lonhomework::results{"resource.0.checkedin"}= $user.'@'.$domain; $Apache::lonhomework::results{"resource.0.checkedin.slot"}= @@ -109,11 +110,11 @@ sub get_version { my ($version,$previous); if ($env{'form.previousversion'} && $env{'form.previousversion'} ne 'current' && - defined($Apache::lonhomework::history{'resource.'.$env{'form.previousversion'}.'.status'})) { + defined($Apache::lonhomework::history{'resource.'.$env{'form.previousversion'}.'.0.status'})) { $version=$env{'form.previousversion'}; $previous=1; } else { - $version=$Apache::lonhomework::history{'resource.version'}; + $version=$Apache::lonhomework::history{'resource.0.version'}; $previous=0; } if (wantarray) { @@ -125,10 +126,10 @@ sub get_version { sub add_previous_version_button { my ($status)=@_; my $result; - if ($Apache::lonhomework::history{'resource.version'} eq '') { + if ($Apache::lonhomework::history{'resource.0.version'} eq '') { return ''; } - if ($Apache::lonhomework::history{'resource.version'} < 2 && + if ($Apache::lonhomework::history{'resource.0.version'} < 2 && $status ne 'NEEDS_CHECKIN') { return ''; } @@ -139,8 +140,8 @@ sub add_previous_version_button { "\n"; } my @to_show; - foreach my $test_version (1..$Apache::lonhomework::history{'resource.version'}) { - if (defined($Apache::lonhomework::history{'resource.'.$test_version.'.status'})) { + foreach my $test_version (1..$Apache::lonhomework::history{'resource.0.version'}) { + if (defined($Apache::lonhomework::history{'resource.'.$test_version.'.0.status'})) { push(@to_show,$test_version); } } @@ -322,7 +323,7 @@ sub internal_location { sub submission_time_stamp { my ($symb,$courseid,$udom,$uname)=&Apache::lonxml::whichuser(); my $submissiontime; - my $version=$Apache::lonhomework::history{'resource.version'}; + my $version=$Apache::lonhomework::history{'resource.0.version'}; for (my $v=$Apache::lonhomework::history{'version'};$v>0;$v--) { if (defined($Apache::lonhomework::history{$v.':resource.'.$version.'.0.bridgetask.portfiles'})) { $submissiontime=$Apache::lonhomework::history{$v.':timestamp'}; @@ -330,7 +331,7 @@ sub submission_time_stamp { } my $result; if ($submissiontime) { - my $slot_name=$Apache::lonhomework::history{'resource.'.$version.'.checkedin.slot'}; + my $slot_name=$Apache::lonhomework::history{'resource.'.$version.'.0.checkedin.slot'}; my %slot=&Apache::lonnet::get_slot($slot_name); my $diff = $slot{'endtime'} - $submissiontime; my ($color,$when)=('#FF6666','after'); @@ -426,7 +427,7 @@ sub start_Task { push(@Apache::inputtags::status,$status); $Apache::inputtags::slot_name=$slot_name; my $expression='$external::datestatus="'.$status.'";'; - $expression.='$external::gradestatus="'.$Apache::lonhomework::history{"resource.$version.solved"}.'";'; + $expression.='$external::gradestatus="'.$Apache::lonhomework::history{"resource.$version.0.solved"}.'";'; &Apache::run::run($expression,$safeeval); &Apache::lonxml::debug("Got $status"); $body_tag_start.=&add_previous_version_button($status); @@ -717,12 +718,12 @@ sub end_Task { DONEBUTTON } if (&show_task($status,$previous) && - $Apache::lonhomework::history{"resource.$version.status"} =~ /^(pass|fail)$/) { - my $bt_status=$Apache::lonhomework::history{"resource.$version.status"}; + $Apache::lonhomework::history{"resource.$version.0.status"} =~ /^(pass|fail)$/) { + my $bt_status=$Apache::lonhomework::history{"resource.$version.0.status"}; my $title=&Apache::lonnet::gettitle(); my $slot_name= - $Apache::lonhomework::history{"resource.$version.checkedin.slot"}; + $Apache::lonhomework::history{"resource.$version.0.checkedin.slot"}; my %slot=&Apache::lonnet::get_slot($slot_name); my $start_time= &Apache::lonlocal::locallocaltime($slot{'starttime'}); @@ -747,7 +748,7 @@ DONEBUTTON if ($Apache::bridgetask::dimensionmandatory{$dim_id} eq 'N') { $opt_count++; - if ($Apache::lonhomework::history{"resource.$version.$dim_id.status"} eq 'pass') { + if ($Apache::lonhomework::history{"resource.$version.0.$dim_id.status"} eq 'pass') { $opt_passed++; } } else { @@ -806,7 +807,7 @@ DONEBUTTON &Apache::lonhomework::showhash(%Apache::lonhomework::results); foreach my $dim_id (@Apache::bridgetask::dimensionlist) { my $status= - $Apache::lonhomework::results{"resource.$version.$dim_id.status"}; + $Apache::lonhomework::results{"resource.$version.0.$dim_id.status"}; my $mandatory= ($Apache::bridgetask::dimensionmandatory{$dim_id} ne 'N'); if ($status eq 'pass') { @@ -825,10 +826,10 @@ DONEBUTTON $mandatory_failed++; } &Apache::lonxml::debug("all dim ".join(':',@Apache::bridgetask::dimensionlist)."results -> m_f $mandatory_failed o_p $optional_passed u $ungraded r $review"); - $Apache::lonhomework::results{'resource.grader'}= + $Apache::lonhomework::results{'resource.0.regrader'}= $env{'user.name'}.'@'.$env{'user.domain'}; if ($review) { - $Apache::lonhomework::results{"resource.$version.status"}='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."); @@ -836,7 +837,7 @@ DONEBUTTON &move_between_queues($env{'form.queue'},'reviewqueue'); } } elsif ($ungraded) { - $Apache::lonhomework::results{"resource.$version.status"}='ungraded'; + $Apache::lonhomework::results{"resource.$version.0.status"}='ungraded'; if ($env{'form.queue'} eq 'reviewqueue' || $env{'form.queue'} eq 'none' ) { &Apache::lonxml::debug("moving back."); @@ -845,7 +846,7 @@ DONEBUTTON &check_queue_unlock($env{'form.queue'}); } } elsif ($mandatory_failed) { - $Apache::lonhomework::results{"resource.$version.status"}='fail'; + $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'; @@ -863,7 +864,7 @@ DONEBUTTON ["$version.0.bridgetask"]); } } else { - $Apache::lonhomework::results{"resource.$version.status"}='pass'; + $Apache::lonhomework::results{"resource.$version.0.status"}='pass'; $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'; @@ -880,8 +881,8 @@ DONEBUTTON ["$version.0.bridgetask"]); } } - $Apache::lonhomework::results{"resource.status"}= - $Apache::lonhomework::results{"resource.$version.status"}; + $Apache::lonhomework::results{"resource.0.status"}= + $Apache::lonhomework::results{"resource.$version.0.status"}; if (defined($Apache::lonhomework::results{"resource.$version.0.awarded"})) { $Apache::lonhomework::results{"resource.0.award"}= $Apache::lonhomework::results{"resource.$version.0.award"}; @@ -1461,9 +1462,9 @@ sub get_student_status { if ($type eq 'Task') { my %record = &Apache::lonnet::restore($symb,$env{'request.course.id'}, $udom,$uname); - $status{'status'}=$record{'resource.status'}; - $status{'version'}=$record{'resource.version'}; - $status{'grader'}=$record{'resource.grader'}; + $status{'status'}=$record{'resource.0.status'}; + $status{'version'}=$record{'resource.0.version'}; + $status{'grader'}=$record{'resource.0.regrader'}; } $status{'reviewqueue'}= &check_queue_for_key($cdom,$cnum,'reviewqueue', @@ -1570,10 +1571,10 @@ sub get_instance { foreach my $instance (@instances) { @Apache::scripttag::parser_env = @_; $result.=&Apache::scripttag::xmlparse($dimension{$instance.'.text'}); - if ($Apache::lonhomework::history{"resource.$version.status"} eq 'pass' || - $Apache::lonhomework::history{"resource.$version.status"} eq 'fail') { + if ($Apache::lonhomework::history{"resource.$version.0.status"} eq 'pass' || + $Apache::lonhomework::history{"resource.$version.0.status"} eq 'fail') { - my $dim_status=$Apache::lonhomework::history{"resource.$version.$dim.status"}; + my $dim_status=$Apache::lonhomework::history{"resource.$version.0.$dim.status"}; my $mandatory='Mandatory'; if ($Apache::bridgetask::dimensionmandatory{$dim} eq 'N') { $mandatory='Optional'; @@ -1593,12 +1594,12 @@ sub get_instance { if ($dimension{$instance.'.criteria.'.$id.'.mandatory'} eq 'N') { $opt_count++; - if ($Apache::lonhomework::history{"resource.$version.$dim.$instance.$id.status"} eq 'pass') { + if ($Apache::lonhomework::history{"resource.$version.0.$dim.$instance.$id.status"} eq 'pass') { $opt_passed++; } } else { $man_count++; - if ($Apache::lonhomework::history{"resource.$version.$dim.$instance.$id.status"} eq 'pass') { + if ($Apache::lonhomework::history{"resource.$version.0.$dim.$instance.$id.status"} eq 'pass') { $man_passed++; } } @@ -1612,8 +1613,8 @@ sub get_instance { $result=~s/\Q$internal_location\E/$dim_info/; foreach my $id (@{$dimension{$instance.'.criterias'}}) { - my $status=$Apache::lonhomework::history{"resource.$version.$dim.$instance.$id.status"}; - my $comment=$Apache::lonhomework::history{"resource.$version.$dim.$instance.$id.comment"}; + my $status=$Apache::lonhomework::history{"resource.$version.0.$dim.$instance.$id.status"}; + my $comment=$Apache::lonhomework::history{"resource.$version.0.$dim.$instance.$id.comment"}; my $mandatory=($dimension{$instance.'.criteria.'.$id.'.mandatory'} ne 'N'); if ($mandatory) { $mandatory='Mandatory'; @@ -1633,8 +1634,8 @@ sub get_instance { @Apache::scripttag::parser_env = @_; $result.=&Apache::scripttag::xmlparse($dimension{$instance.'.criteria.'.$id}); $result.='

'.$status_display.'

'; - if ($Apache::lonhomework::history{"resource.$version.$dim.$instance.$id.comment"}) { - $result.='

'.$Apache::lonhomework::history{"resource.$version.$dim.$instance.$id.comment"}.'

'; + if ($Apache::lonhomework::history{"resource.$version.0.$dim.$instance.$id.comment"}) { + $result.='

'.$Apache::lonhomework::history{"resource.$version.0.$dim.$instance.$id.comment"}.'

'; } $result.=''; } @@ -1648,7 +1649,7 @@ sub get_instance { &Apache::scripttag::xmlparse($dimension{$instance.'.text'}); foreach my $id (@{$dimension{$instance.'.criterias'}}) { my $link='criteria_'.$instance.'_'.$id; - my $status=$Apache::lonhomework::history{"resource.$version.$dim.$instance.$id.status"}; + my $status=$Apache::lonhomework::history{"resource.$version.0.$dim.$instance.$id.status"}; $result.=''. ''. ''. @@ -1659,7 +1660,7 @@ sub get_instance { #$dimension{$instance.'.criteria.'.$id}. ''. 'Additional Comment for Student
'. - ''. + ''. ''. ''. '
'. @@ -1679,8 +1680,8 @@ sub get_instance { my $ungraded=0; my $review=0; foreach my $id (@{$dimension{$instance.'.criterias'}}) { - my $status=$Apache::lonhomework::results{"resource.$version.$dim.$instance.$id.status"}=$env{'form.HWVAL_criteria_'.$instance.'_'.$id}; - $Apache::lonhomework::results{"resource.$version.$dim.$instance.$id.comment"}=$env{'form.HWVAL_comment_criteria_'.$instance.'_'.$id}; + my $status=$Apache::lonhomework::results{"resource.$version.0.$dim.$instance.$id.status"}=$env{'form.HWVAL_criteria_'.$instance.'_'.$id}; + $Apache::lonhomework::results{"resource.$version.0.$dim.$instance.$id.comment"}=$env{'form.HWVAL_comment_criteria_'.$instance.'_'.$id}; my $mandatory=($dimension{$instance.'.criteria.'.$id.'.mandatory'} ne 'N'); if ($status eq 'pass') { if (!$mandatory) { $optional_passed++; } @@ -1699,13 +1700,13 @@ sub get_instance { } &Apache::lonxml::debug("all instance ".join(':',@{$dimension{$instance.'.criterias'}})." results -> m_f $mandatory_failed o_p $optional_passed u $ungraded r $review"); if ($review) { - $Apache::lonhomework::results{"resource.$version.$dim.status"}= + $Apache::lonhomework::results{"resource.$version.0.$dim.status"}= 'review'; } elsif ($ungraded) { - $Apache::lonhomework::results{"resource.$version.$dim.status"}= + $Apache::lonhomework::results{"resource.$version.0.$dim.status"}= 'ungraded'; } elsif ($mandatory_failed) { - $Apache::lonhomework::results{"resource.$version.$dim.status"}= + $Apache::lonhomework::results{"resource.$version.0.$dim.status"}= 'fail'; } else { $Apache::lonhomework::results{"resource.$version.$dim.status"}=