[LON-CAPA-cvs] cvs: loncom /homework bridgetask.pm

albertel lon-capa-cvs@mail.lon-capa.org
Tue, 10 May 2005 16:44:35 -0000


This is a MIME encoded message

--albertel1115743475
Content-Type: text/plain

albertel		Tue May 10 12:44:35 2005 EDT

  Modified files:              
    /loncom/homework	bridgetask.pm 
  Log:
  - got a successful grading done
  
  
--albertel1115743475
Content-Type: text/plain
Content-Disposition: attachment; filename="albertel-20050510124435.txt"

Index: loncom/homework/bridgetask.pm
diff -u loncom/homework/bridgetask.pm:1.20 loncom/homework/bridgetask.pm:1.21
--- loncom/homework/bridgetask.pm:1.20	Tue May 10 12:03:44 2005
+++ loncom/homework/bridgetask.pm	Tue May 10 12:44:35 2005
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA 
 # definition of tags that give a structure to a document
 #
-# $Id: bridgetask.pm,v 1.20 2005/05/10 16:03:44 albertel Exp $
+# $Id: bridgetask.pm,v 1.21 2005/05/10 16:44:35 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -117,7 +117,7 @@
 	    $body_tag_start.=$uri.'">'.&add_grading_button()."</form>";
 	}
     }
-    if ($target eq 'web' || $target eq 'grade' || $target eq 'answer' ||
+    if ($target eq 'web' || ($target eq 'grade' && !$env{'form.webgrade'}) || $target eq 'answer' ||
 	$target eq 'tex') {
 	($status,$accessmsg,my $slot_name,$slot) = 
 	    &Apache::lonhomework::check_task_access('0');
@@ -180,10 +180,13 @@
 		}
 	    }
 	}
-    } elsif ($target eq 'webgrade') {
-	$result.=$head_tag_start.$body_tag_start.$form_tag_start;
-	$result.='<input type="hidden" name="webgrade" value="yes" />';
-	$result.=&show_queue();
+    } elsif ( ($target eq 'grade' && $env{'form.webgrade'}) ||
+	      $target eq 'webgrade') {
+	if ($target eq 'webgrade') {
+	    $result.=$head_tag_start.$body_tag_start.$form_tag_start;
+	    $result.='<input type="hidden" name="webgrade" value="yes" />';
+	    $result.=&show_queue();
+	}
 	my $todo=&get_from_queue();
 	if ($todo) {
 	    &setup_env_for_other_user($todo,$safeeval);
@@ -197,11 +200,12 @@
 	    &Apache::lonhomework::showhash(%Apache::lonhomework::history);
 	    $result.="\n".'<table width="100%" style="width:100%" border="1">';
 	} else {
-	    $result.="\n".
-		'<table><tr><td>No user to be graded.</td></tr></table>';
+	    if ($target eq 'webgrade') {
+		$result.="\n".
+		    '<table><tr><td>No user to be graded.</td></tr></table>';
+	    }
 	    my $bodytext=&Apache::lonxml::get_all_text("/task",$parser);
 	}
-	
     } else {
 	# page_start returned a starting result, delete it if we don't need it
 	$result = '';
@@ -256,9 +260,10 @@
 	    my $mandatory_failed=0;
 	    my $ungraded=0;
 	    my $review=0;   
+	    &Apache::lonhomework::showhash(%Apache::lonhomework::results);
 	    foreach my $dim_id (@Apache::bridgetask::dimensionlist) {
 		my $status=
-		    $Apache::lonhomeork::results{"resource.$dim_id.status"};
+		    $Apache::lonhomework::results{"resource.$dim_id.status"};
 		my $mandatory=
 		    ($Apache::bridgetask::dimensionmandatory{$dim_id} ne 'N');
 		if ($status eq 'pass') {
@@ -274,23 +279,25 @@
 	    if ($optional_passed < $optional_required) {
 		$mandatory_failed++;
 	    }
-	    $Apache::lonhomeork::results{'resource.grader'}=
+	    &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'}=
 		$env{'user.name'}.'@'.$env{'user.domain'};
 	    if ($review) {
-		$Apache::lonhomeork::results{'resource.status'}='review';
+		$Apache::lonhomework::results{'resource.status'}='review';
 		&move_to_review_queue();
 	    } elsif ($ungraded) {
-		$Apache::lonhomeork::results{'resource.status'}='ungraded';
+		$Apache::lonhomework::results{'resource.status'}='ungraded';
 		&check_queue_unlock();
 	    } elsif ($mandatory_failed) {
-		$Apache::lonhomeork::results{'resource.status'}='fail';
+		$Apache::lonhomework::results{'resource.status'}='fail';
 		$Apache::lonhomework::results{"resource.0.award"}='EXACT_ANS';
 		&remove_from_queue();
 	    } else {
-		$Apache::lonhomeork::results{'resource.status'}='pass';
+		$Apache::lonhomework::results{'resource.status'}='pass';
 		$Apache::lonhomework::results{"resource.0.award"}='INCORRECT';
 		&remove_from_queue();
 	    }
+	    &Apache::structuretags::finalize_storage();
 	}
     } elsif ($target eq 'webgrade') {
 	$result.="</table>\n<hr />";
@@ -312,6 +319,18 @@
     return $result;
 }
 
+sub move_to_review_queue {
+    &Apache::lonxml::debug("Want to move");
+}
+
+sub check_queue_unlock {
+    &Apache::lonxml::debug("Want to unlock?");
+}
+
+sub remove_from_queue {
+    &Apache::lonxml::debug("Want to remove. Done?");
+}
+
 sub setup_env_for_other_user {
     my ($queue_key,$safeeval)=@_;
     my ($symb,$uname,$udom)=&decode_queue_key($queue_key);
@@ -554,13 +573,14 @@
     sub end_Dimension {
 	my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
 	my $result;
+	my $dim_id=&get_id($parstack,$safeeval);
 	my $instance=&get_instance();
 	if ($target eq 'web') {
 	    $result=$dimension{'intro'}.$dimension{$instance.'.text'};
 	} elsif ($target eq 'webgrade') {
 	    foreach my $id (@{$dimension{$instance.'.criterias'}}) {
 		my $link='criteria_'.$instance.'_'.$id;
-		my $status=$Apache::lonhomeork::history{'resource.'.$instance.'.'.$id.'.status'};
+		my $status=$Apache::lonhomework::history{'resource.'.$instance.'.'.$id.'.status'};
 		$result.='<tr><td width="100%" valign="top">'.
 		    '<a name="'.$link.'" />'.
 		    '<a name="next_'.$last_link.'" />'.
@@ -568,7 +588,7 @@
 		    #$dimension{$instance.'.criteria.'.$id}.
 		    '</td>'.
 		    '<td><nobr>Additional Comment for Student</nobr> <br />'.
-		    '<textarea style="width:100%" rows="8" width="25" wrap="hard" name="HWVAL_comment_'.$link.'">'.&HTML::Entities::encode($Apache::lonhomeork::history{'resource.'.$instance.'.'.$id.'.comment'}).'</textarea>'.
+		    '<textarea style="width:100%" rows="8" width="25" wrap="hard" name="HWVAL_comment_'.$link.'">'.&HTML::Entities::encode($Apache::lonhomework::history{'resource.'.$instance.'.'.$id.'.comment'}).'</textarea>'.
 		    '</td>'.
 		    '<td>'.
 		    '<nobr><label><input type="radio" name="HWVAL_'.$link.'" value="ungraded" '.($status eq 'ungraded' || !$status ? 'checked="checked"':'').'/>Ungraded</label></nobr><br />'.
@@ -590,30 +610,33 @@
 	    my $ungraded=0;
 	    my $review=0;
 	    foreach my $id (@{$dimension{$instance.'.criterias'}}) {
-		my $status=$Apache::lonhomeork::results{'resource.'.$instance.'.'.$id.'.status'}=$env{'form.HWVAL_criteria_'.$instance.'_'.$id};
-		$Apache::lonhomeork::results{'resource.'.$instance.'.'.$id.'.comment'}=$env{'form.HWVAL_comment_'.$instance.'_'.$id};
+		my $status=$Apache::lonhomework::results{'resource.'.$instance.'.'.$id.'.status'}=$env{'form.HWVAL_criteria_'.$instance.'_'.$id};
+		$Apache::lonhomework::results{'resource.'.$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++; }
 		} elsif ($status eq 'fail') {
 		    if ($mandatory) { $mandatory_failed++; }
-		} elsif ($status eq 'ungraded') {
-		    $ungraded++;
 		} elsif ($status eq 'review') {
 		    $review++;
+		} elsif ($status eq 'ungraded') {
+		    $ungraded++;
+		} else {
+		    &Apache::lonxml::error("got wierd status --$status--");
 		}
 	    }
 	    if ($optional_passed < $dimension{$instance.'.optionalrequired'}) {
 		$mandatory_failed++;
 	    }
+	    &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::lonhomeork::results{'resource.'.$instance.'.status'}='review';
+		$Apache::lonhomework::results{'resource.'.$dim_id.'.status'}='review';
 	    } elsif ($ungraded) {
-		$Apache::lonhomeork::results{'resource.'.$instance.'.status'}='ungraded';
+		$Apache::lonhomework::results{'resource.'.$dim_id.'.status'}='ungraded';
 	    } elsif ($mandatory_failed) {
-		$Apache::lonhomeork::results{'resource.'.$instance.'.status'}='fail';
+		$Apache::lonhomework::results{'resource.'.$dim_id.'.status'}='fail';
 	    } else {
-		$Apache::lonhomeork::results{'resource.'.$instance.'.status'}='pass';
+		$Apache::lonhomework::results{'resource.'.$dim_id.'.status'}='pass';
 	    }
 	}
 	return $result;
@@ -677,7 +700,7 @@
 
 sub start_Criteria {
     my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
-    if ($target eq 'web' || $target eq 'webgrade') {
+    if ($target eq 'web' || $target eq 'webgrade' || $target eq 'grade') {
 	&Apache::lonxml::startredirection();
     }
     return '';
@@ -686,7 +709,7 @@
 sub end_Criteria {
     my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
     my $instance_id=$Apache::bridgetask::instance[-1];
-    if ($target eq 'web' || $target eq 'webgrade') {
+    if ($target eq 'web' || $target eq 'webgrade' || $target eq 'grade') {
 	my $criteria=&Apache::lonxml::endredirection();
 	my $id=&get_id($parstack,$safeeval);
 	$dimension{$instance_id.'.criteria.'.$id}=$criteria;

--albertel1115743475--