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

albertel lon-capa-cvs@mail.lon-capa.org
Thu, 16 Feb 2006 01:24:39 -0000


albertel		Wed Feb 15 20:24:39 2006 EDT

  Modified files:              
    /loncom/homework	lonhomework.pm 
  Log:
  - when slot access control occurs, after they get a Task correct it needs to go 
    into SHOW_ANSWER mode
  
  
Index: loncom/homework/lonhomework.pm
diff -u loncom/homework/lonhomework.pm:1.234 loncom/homework/lonhomework.pm:1.235
--- loncom/homework/lonhomework.pm:1.234	Fri Feb 10 18:44:53 2006
+++ loncom/homework/lonhomework.pm	Wed Feb 15 20:24:39 2006
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # The LON-CAPA Homework handler
 #
-# $Id: lonhomework.pm,v 1.234 2006/02/10 23:44:53 albertel Exp $
+# $Id: lonhomework.pm,v 1.235 2006/02/16 01:24:39 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -297,12 +297,15 @@
 	$slotstatus='CAN_ANSWER';
     }
 
-    my ($got_grade,$checkedin);
+    my ($is_correct,$got_grade,$checkedin);
     if ($type eq 'Task') {
 	my $version=$Apache::lonhomework::history{'resource.0.version'};
 	$got_grade = 
 	    ($Apache::lonhomework::history{"resource.$version.0.status"} 
 	     =~ /^(?:pass|fail)$/);
+	$is_correct =  
+	    ($Apache::lonhomework::history{"resource.$version.0.status"} eq 'pass'
+	     || $Apache::lonhomework::history{"resource.0.solved"} =~ /^correct_/ );
 	$checkedin =
 	    $Apache::lonhomework::history{"resource.$version.0.checkedin"};
     } elsif ($type eq 'problem') {
@@ -310,6 +313,8 @@
 	$checkedin = $Apache::lonhomework::history{"resource.0.checkedin"};
     }
     
+    &Apache::lonxml::debug(" slot is $slotstatus checkedin ($checkedin) got_grade ($got_grade) is_correct ($is_correct)");
+    
     if ($slotstatus eq 'NOT_IN_A_SLOT' 
 	&& $checkedin ) {
 
@@ -320,6 +325,9 @@
 	}
 
     }
+    if ( $is_correct) {
+	return ('SHOW_ANSWER');
+    }
     if ( $status eq 'CANNOT_ANSWER' && 
 	 ($slotstatus ne 'NEEDS_CHECKIN' && $slotstatus ne 'NOT_IN_A_SLOT')) {
 	return ($status,$datemsg);