--- loncom/homework/bridgetask.pm	2005/10/03 21:30:58	1.65
+++ loncom/homework/bridgetask.pm	2005/10/14 16:23:39	1.70
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA 
 # definition of tags that give a structure to a document
 #
-# $Id: bridgetask.pm,v 1.65 2005/10/03 21:30:58 albertel Exp $
+# $Id: bridgetask.pm,v 1.70 2005/10/14 16:23:39 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -335,11 +335,41 @@ sub submission_time_stamp {
     return $result;
 }
 
+sub webgrade_standard_info {
+    my ($version)=&get_version();
+    my (undef,undef,$udom,$uname) = &Apache::lonxml::whichuser();
+    my $file_url = '/uploaded/'.$udom.'/'.$uname.'/portfolio/';
+    my $file_list="<ul>\n";
+    foreach my $partial_file (split(',',$Apache::lonhomework::history{"resource.$version.0.bridgetask.portfiles"})) {
+	my $file=$file_url.$partial_file;
+	$file=~s|/+|/|g;
+	&Apache::lonnet::allowuploaded('/adm/bridgetask',$file);
+	$file_list.='<li><nobr><a href="'.$file.'" target="lonGRDs"><img src="'.
+	    &Apache::loncommon::icon($file).'" border=0"> '.$file.
+	    '</a></nobr></li>'."\n";
+    }
+    $file_list.="</ul>\n";
+
+    my %lt=&Apache::lonlocal::texthash('done' => 'Done',
+				       'stop' => 'Stop',
+				       );
+				       
+    my $result=<<INFO;
+<div class="handininfo">
+  <input type="submit" name="next" value="$lt{'done'}" />
+  <input type="submit" name="stop" value="$lt{'stop'}" />
+  $file_list
+</div>
+INFO
+    return $result;
+}
+
 sub start_Task {
     my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
 
     my ($status,$accessmsg,$slot);
     if ($target ne 'webgrade') {
+	&Apache::structuretags::init_problem_globals('Task');
 	&Apache::structuretags::initialize_storage();
 	&Apache::lonhomework::showhash(%Apache::lonhomework::history);
     } 
@@ -395,12 +425,12 @@ sub start_Task {
 		    $msg.='<h1>'.&mt('Your submission is in the grading queue.').'</h1>';
 		} elsif ($env{'form.donescreen'}) {
 		    my $title=&Apache::lonnet::gettitle();
-		    my $files=$Apache::lonhomework::history{'resource.'.$version.'.0.bridgetask.portfiles'};
-		    $result.= $head_tag_start.'</head>'.$body_tag_start;
+		    my @files=split(',',$Apache::lonhomework::history{'resource.'.$version.'.0.bridgetask.portfiles'});
+		    my $files='<ul><li>'.join('</li><li>',@files).'</li></ul>';
 		    $result.=<<DONESCREEN;
 <h2>$title</h2>
 <p> Files submitted: $files </p>
-<p> You are now done with the Bridge Task </p>
+<p> You are now done with this Bridge Task </p>
 <hr />
 <p> <a href="/adm/logout">Logout</a> </p>
 <p> <a href="/adm/roles">Change to a different course</a> </p>
@@ -511,6 +541,7 @@ DONESCREEN
                                value="'.$sec.'" />';
 		}
 	    }
+	    if ($webgrade eq 'yes') { $result.=&webgrade_standard_info(); }
 	}
     } else {
 	# page_start returned a starting result, delete it if we don't need it
@@ -618,10 +649,7 @@ sub end_Task {
     my ($version,$previous)=&get_version();
     if ($target eq 'grade' || $target eq 'web' || $target eq 'answer' ||
 	$target eq 'tex') {
-	if (
-	    (($target eq 'web') && ($env{'request.state'} ne 'construct')) ||
-	    ($target eq 'answer') || ($target eq 'tex')
-	   ) {
+	if ($target eq 'web' || $target eq 'answer' || $target eq 'tex') {
 	    if ($target eq 'web') {
 		if (&show_task($status,$previous)) {
 		    $result.=&Apache::lonxml::endredirection();
@@ -827,9 +855,14 @@ DONEBUTTON
 	#    &mt('Save Partial Grade and Continue Grading').'" /> ';
 	$result.='</form>'.&Apache::loncommon::endbodytag().'</html>';
     } elsif ($target eq 'meta') {
-	$result.='<parameter part="0" package="Task"></parameter>'."\n";
-	#$result.=&Apache::response::meta_part_order();
-	#$result.=&Apache::response::meta_response_order();
+	$result.=&Apache::response::meta_package_write('Task');
+        $result.=&meta_stores_write('solved','string','Problem Status');
+	$result.=&meta_stores_write('tries','int_zeropos',
+				    'Number of Attempts');
+	$result.=&meta_stores_write('awarded','float',
+				    'Partial Credit Factor');
+	$result.=&meta_stores_write('status','string',
+				    'Bridge Task Status');
     }
     undef($Apache::lonhomework::parsing_a_task);
     return $result;
@@ -1089,6 +1122,8 @@ sub queue_key_locked {
 sub pick_from_queue_data {
     my ($queue,$check_section,$queuedata,$cdom,$cnum)=@_;
     foreach my $key (keys(%$queuedata)) {
+	if ($key =~ /\0locked$/) { next; }
+	if ($key =~ /\0timestamp$/) { next; }
 	my ($symb,$uname,$udom)=&decode_queue_key($key);
 	if ($check_section) {
 	    my $section=&Apache::lonnet::getsection($uname,$udom);
@@ -1421,8 +1456,7 @@ sub get_instance {
 		    }
 		}
 		if ($man_passed eq $man_count) { $man_passed='all'; }
-		my $opt_req=&Apache::lonxml::get_param('OptionalRequired',
-						       $parstack,$safeeval);
+		my $opt_req=$dimension{$instance.'.optionalrequired'};
 		if ($opt_req !~ /\S/) { $opt_req='0'; }
 		$dim_info.="\n<p>".&mt('You passed [_1] of the [_2] mandatory components and [_3] of the [_4] optional components, of which you were required to pass [_5].',$man_passed,$man_count,$opt_passed,$opt_count,$opt_req)."</p>\n</div>";
 
@@ -1487,23 +1521,7 @@ sub get_instance {
 		    '<td>'.
 		    '<a href="#'.$last_link.'">Prev</a><br />'.
 		    '<a href="#next_'.$link.'">Next</a><br /><br /><br />'.
-		    '<input type="submit" name="next" value="'.
-		    &mt('Done').'" /> '.
-		    '<input type="submit" name="stop" value="'.
-		    &mt('Stop').'" /> '.
 		    '</td></tr>';
-		$result.='<tr><td colspan="4">';
-		my (undef,undef,$udom,$uname) = &Apache::lonxml::whichuser();
-		my $file_url = '/uploaded/'.$udom.'/'.$uname.'/portfolio/';
-		foreach my $partial_file (split(',',$Apache::lonhomework::history{"resource.$version.0.bridgetask.portfiles"})) {
-		    my $file=$file_url.$partial_file;
-		    $file=~s|/+|/|g;
-		    &Apache::lonnet::allowuploaded('/adm/bridgetask',$file);
-		    $result.='<nobr><a href="'.$file.'" target="lonGRDs"><img src="'.
-			&Apache::loncommon::icon($file).'" border=0"> '.$file.
-			'</a></nobr> ';
-		}
-		$result.='</td></tr>';
 		$last_link=$link;
 	    }
 	} elsif ($target eq 'grade' && $env{'form.webgrade'}) {
@@ -1544,6 +1562,9 @@ sub get_instance {
 		$Apache::lonhomework::results{"resource.$version.$dim.status"}=
 		    'pass';
 	    }
+	} else {
+	    # any other targets no output
+	    undef($result);
 	}
 	return $result;
     }