--- loncom/homework/bridgetask.pm 2005/05/13 15:34:50 1.24 +++ loncom/homework/bridgetask.pm 2005/05/19 21:22:44 1.25 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # definition of tags that give a structure to a document # -# $Id: bridgetask.pm,v 1.24 2005/05/13 15:34:50 albertel Exp $ +# $Id: bridgetask.pm,v 1.25 2005/05/19 21:22:44 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -83,8 +83,25 @@ sub proctor_check_auth { return 0; } +sub get_version { + if ($env{'form.previousversion'} && + defined($Apache::lonhomework::history{'resource.'.$env{'form.previousversion'}.'.status'})) { + return $env{'form.previousversion'}; + } + return $Apache::lonhomework::history{'resource.version'}; +} + sub add_previous_version_button { + my ($status)=@_; my $result; + if ($Apache::lonhomework::history{'resource.version'} eq '0') { + return ''; + } + my $version=&get_version(); + if ($version ne $Apache::lonhomework::history{'resource.version'}) { + return ''; + } + $result.=&mt(' Show a previously done version: [_1]',''); @@ -100,7 +117,10 @@ sub add_grading_button { } sub add_request_another_attempt_button { - + my $result; + $result.=' '; + return $result; } sub start_Task { @@ -118,7 +138,6 @@ sub start_Task { &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) { $body_tag_start.='
'."\n"; } } - if ($Apache::lonhomework::history{'resource.status'} eq 'fail') { + my $version=&get_version(); + if ($Apache::lonhomework::history{"resource.$version.status"} eq 'fail') { $result.='

'.&mt('Did not pass').'

'; - $result.=&request_another_attempt_button(); + $result.=&add_request_another_attempt_button(); } - if ($Apache::lonhomework::history{'resource.status'} eq 'pass') { + if ($Apache::lonhomework::history{"resource.$version.status"} eq 'pass') { $result.='

'.&mt('Passed').'

'; } } @@ -240,7 +261,7 @@ sub end_Task { my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_; my $result=''; my $status=$Apache::inputtags::status['-1']; - my $version=$Apache::lonhomework::history{'resource.version'}; + my $version=&get_version(); if ($target eq 'grade' || $target eq 'web' || $target eq 'answer' || $target eq 'tex') { if ( @@ -288,7 +309,7 @@ sub end_Task { &Apache::lonhomework::showhash(%Apache::lonhomework::results); foreach my $dim_id (@Apache::bridgetask::dimensionlist) { my $status= - $Apache::lonhomework::results{"resource.$dim_id.status"}; + $Apache::lonhomework::results{"resource.$version.$dim_id.status"}; my $mandatory= ($Apache::bridgetask::dimensionmandatory{$dim_id} ne 'N'); if ($status eq 'pass') { @@ -308,20 +329,34 @@ sub end_Task { $Apache::lonhomework::results{'resource.grader'}= $env{'user.name'}.'@'.$env{'user.domain'}; if ($review) { - $Apache::lonhomework::results{'resource.status'}='review'; + $Apache::lonhomework::results{"resource.$version.status"}='review'; &move_to_review_queue(); } elsif ($ungraded) { - $Apache::lonhomework::results{'resource.status'}='ungraded'; + $Apache::lonhomework::results{"resource.$version.status"}='ungraded'; &check_queue_unlock(); } elsif ($mandatory_failed) { - $Apache::lonhomework::results{'resource.status'}='fail'; - $Apache::lonhomework::results{"resource.$version.award"}='EXACT_ANS'; + $Apache::lonhomework::results{"resource.$version.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'; &remove_from_queue(); } else { - $Apache::lonhomework::results{'resource.status'}='pass'; - $Apache::lonhomework::results{"resource.$version.award"}='INCORRECT'; + $Apache::lonhomework::results{"resource.$version.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'; &remove_from_queue(); } + $Apache::lonhomework::results{'resource.status'}= + $Apache::lonhomework::results{'resource.$version.status'}; + if (defined($Apache::lonhomework::results{'resource.$version.awarded'})) { + $Apache::lonhomework::results{'resource.0.award'}= + $Apache::lonhomework::results{'resource.$version.award'}; + $Apache::lonhomework::results{'resource.0.awarded'}= + $Apache::lonhomework::results{'resource.$version.awarded'}; + $Apache::lonhomework::results{'resource.0.solved'}= + $Apache::lonhomework::results{'resource.$version.solved'}; + } &Apache::structuretags::finalize_storage(); } } elsif ($target eq 'webgrade') { @@ -598,15 +633,16 @@ sub get_instance { sub end_Dimension { my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_; my $result; - my $dim_id=&get_id($parstack,$safeeval); + my $dim=&get_id($parstack,$safeeval); my $instance=&get_instance(); + my $version=&get_version(); if ($target eq 'web') { $result=$dimension{'intro'}.$dimension{$instance.'.text'}; - if ($Apache::lonhomework::history{'resource.status'} eq 'pass' || - $Apache::lonhomework::history{'resource.status'} eq 'fail') { + if ($Apache::lonhomework::history{'resource.$version.status'} eq 'pass' || + $Apache::lonhomework::history{'resource.$version.status'} eq 'fail') { foreach my $id (@{$dimension{$instance.'.criterias'}}) { - my $status=$Apache::lonhomework::history{"resource.$dim_id.$instance.$id.status"}; - my $comment=$Apache::lonhomework::history{"resource.$dim_id.$instance.$id.comment"}; + my $status=$Apache::lonhomework::history{"resource.$version.$dim.$instance.$id.status"}; + my $comment=$Apache::lonhomework::history{"resource.$version.$dim.$instance.$id.comment"}; $result.='
'; if ($status eq 'fail') { $result.=''.&mt('Did not pass').''; @@ -616,18 +652,17 @@ sub get_instance { &Apache::lonxml::error("Student viewing a graded bridgetask was show a status of $status"); } $result.='
'; - if ($Apache::lonhomework::history{"resource.$dim_id.$instance.$id.comment"}) { - $result.=&mt('Comment from grader: ').$Apache::lonhomework::history{"resource.$dim_id.$instance.$id.comment"}.'
'; + if ($Apache::lonhomework::history{"resource.$version.$dim.$instance.$id.comment"}) { + $result.=&mt('Comment from grader: ').$Apache::lonhomework::history{"resource.$version.$dim.$instance.$id.comment"}.'
'; } $result.=$dimension{$instance.'.criteria.'.$id}. '
'; } } } elsif ($target eq 'webgrade') { - my $version=$Apache::lonhomework::history{'resource.version'}; foreach my $id (@{$dimension{$instance.'.criterias'}}) { my $link='criteria_'.$instance.'_'.$id; - my $status=$Apache::lonhomework::history{"resource.$dim_id.$instance.$id.status"}; + my $status=$Apache::lonhomework::history{"resource.$version.$dim.$instance.$id.status"}; $result.=''. ''. ''. @@ -635,7 +670,7 @@ sub get_instance { #$dimension{$instance.'.criteria.'.$id}. ''. 'Additional Comment for Student
'. - ''. + ''. ''. ''. '
'. @@ -668,8 +703,8 @@ sub get_instance { my $ungraded=0; my $review=0; foreach my $id (@{$dimension{$instance.'.criterias'}}) { - my $status=$Apache::lonhomework::results{"resource.$dim_id.$instance.$id.status"}=$env{'form.HWVAL_criteria_'.$instance.'_'.$id}; - $Apache::lonhomework::results{"resource.$dim_id.$instance.$id.comment"}=$env{'form.HWVAL_comment_criteria_'.$instance.'_'.$id}; + 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 $mandatory=($dimension{$instance.'.criteria.'.$id.'.mandatory'} ne 'N'); if ($status eq 'pass') { if (!$mandatory) { $optional_passed++; } @@ -688,16 +723,16 @@ 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.$dim_id.status"}= + $Apache::lonhomework::results{"resource.$version.$dim.status"}= 'review'; } elsif ($ungraded) { - $Apache::lonhomework::results{"resource.$dim_id.status"}= + $Apache::lonhomework::results{"resource.$version.$dim.status"}= 'ungraded'; } elsif ($mandatory_failed) { - $Apache::lonhomework::results{"resource.$dim_id.status"}= + $Apache::lonhomework::results{"resource.$version.$dim.status"}= 'fail'; } else { - $Apache::lonhomework::results{"resource.$dim_id.status"}= + $Apache::lonhomework::results{"resource.$version.$dim.status"}= 'pass'; } }