--- loncom/homework/bridgetask.pm 2005/05/10 20:29:26 1.22 +++ 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.22 2005/05/10 20:29:26 albertel Exp $ +# $Id: bridgetask.pm,v 1.25 2005/05/19 21:22:44 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -69,9 +69,12 @@ sub proctor_check_auth { if ($puser eq $user && $pdom eq $domain) { my $authhost=&Apache::lonnet::authenticate($puser,$env{'form.proctorpassword'},$pdom); if ($authhost ne 'no_host') { - $Apache::lonhomework::results{'resource.checkedin'}= + my $version= + $Apache::lonhomework::results{'resource.version'}= + $Apache::lonhomework::history{'resource.version'}++; + $Apache::lonhomework::results{"resource.$version.checkedin"}= $user.'@'.$domain; - $Apache::lonhomework::results{'resource.checkedin.slot'}= + $Apache::lonhomework::results{"resource.$version.checkedin.slot"}= $slot_name; return 1; } @@ -80,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]',''); @@ -97,7 +117,10 @@ sub add_grading_button { } sub add_request_another_attempt_button { - + my $result; + $result.=' '; + return $result; } sub start_Task { @@ -115,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').'

'; } } @@ -236,6 +261,7 @@ sub end_Task { my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_; my $result=''; my $status=$Apache::inputtags::status['-1']; + my $version=&get_version(); if ($target eq 'grade' || $target eq 'web' || $target eq 'answer' || $target eq 'tex') { if ( @@ -245,7 +271,8 @@ sub end_Task { if ($target eq 'web') { if ($status eq 'CAN_ANSWER') { $result.="\n".''. - &Apache::inputtags::file_selector('0',"bridgetask","*", + &Apache::inputtags::file_selector($version, + "bridgetask","*", 'portfolioonly'). "
"; $result.=&Apache::inputtags::gradestatus('0'); @@ -260,11 +287,11 @@ sub end_Task { &Apache::essayresponse::file_submission('0','bridgetask', 'portfiles',\$award); if ($award eq 'SUBMITTED' && - $Apache::lonhomework::results{"resource.0.bridgetask.portfiles"}) { - $Apache::lonhomework::results{"resource.0.tries"}= - 1+$Apache::lonhomework::history{"resource.0.tries"}; + $Apache::lonhomework::results{"resource.$version.bridgetask.portfiles"}) { + $Apache::lonhomework::results{"resource.$version.tries"}= + 1+$Apache::lonhomework::history{"resource.$version.tries"}; } - $Apache::lonhomework::results{"resource.0.award"}=$award; + $Apache::lonhomework::results{"resource.$version.award"}=$award; &Apache::lonhomework::showhash(%Apache::lonhomework::results); &Apache::structuretags::finalize_storage(); if ($award eq 'SUBMITTED') { @@ -282,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') { @@ -302,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.0.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.0.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') { @@ -592,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').''; @@ -610,8 +652,8 @@ 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}. '
'; @@ -620,7 +662,7 @@ sub get_instance { } elsif ($target eq 'webgrade') { 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.=''. ''. ''. @@ -628,7 +670,7 @@ sub get_instance { #$dimension{$instance.'.criteria.'.$id}. ''. 'Additional Comment for Student
'. - ''. + ''. ''. ''. '
'. @@ -645,7 +687,7 @@ sub get_instance { $result.=''; my (undef,undef,$udom,$uname) = &Apache::lonxml::whichuser(); my $file_url = '/uploaded/'.$udom.'/'.$uname.'/portfolio'; - foreach my $partial_file (split(',',$Apache::lonhomework::history{"resource.0.bridgetask.portfiles"})) { + foreach my $partial_file (split(',',$Apache::lonhomework::history{"resource.$version.bridgetask.portfiles"})) { my $file=$file_url.$partial_file; &Apache::lonnet::allowuploaded('/adm/bridgetask',$file); $result.='
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'; } }