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

albertel lon-capa-cvs@mail.lon-capa.org
Tue, 10 May 2005 20:58:38 -0000


albertel		Tue May 10 16:58:38 2005 EDT

  Modified files:              
    /loncom/homework	bridgetask.pm lonhomework.pm 
  Log:
  - moving to versioning that datums seems like ti will be better in the future
  
  
Index: loncom/homework/bridgetask.pm
diff -u loncom/homework/bridgetask.pm:1.22 loncom/homework/bridgetask.pm:1.23
--- loncom/homework/bridgetask.pm:1.22	Tue May 10 16:29:26 2005
+++ loncom/homework/bridgetask.pm	Tue May 10 16:58:38 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.22 2005/05/10 20:29:26 albertel Exp $
+# $Id: bridgetask.pm,v 1.23 2005/05/10 20:58:38 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -69,9 +69,12 @@
 	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;
 	    }
@@ -130,7 +133,7 @@
 	push(@Apache::inputtags::status,$status);
 	$Apache::inputtags::slot_name=$slot_name;
 	my $expression='$external::datestatus="'.$status.'";';
-	$expression.='$external::gradestatus="'.$Apache::lonhomework::history{"resource.0.solved"}.'";';
+	$expression.='$external::gradestatus="'.$Apache::lonhomework::history{"resource.$version.solved"}.'";';
 	&Apache::run::run($expression,$safeeval);
 	&Apache::lonxml::debug("Got $status");
 	if (( $status eq 'CLOSED' ) ||
@@ -236,6 +239,7 @@
     my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
     my $result='';
     my $status=$Apache::inputtags::status['-1'];
+    my $version=$Apache::lonhomework::history{'resource.version'};
     if ($target eq 'grade' || $target eq 'web' || $target eq 'answer' ||
 	$target eq 'tex') {
 	if (
@@ -245,7 +249,8 @@
 	    if ($target eq 'web') {
 		if ($status eq 'CAN_ANSWER') {
 		    $result.="\n".'<table border="1">'.
-			&Apache::inputtags::file_selector('0',"bridgetask","*",
+			&Apache::inputtags::file_selector($version,
+							  "bridgetask","*",
 							  'portfolioonly').
 							  "</table>";
 		    $result.=&Apache::inputtags::gradestatus('0');
@@ -260,11 +265,11 @@
 	    &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') {
@@ -309,11 +314,11 @@
 		&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.award"}='EXACT_ANS';
 		&remove_from_queue();
 	    } else {
 		$Apache::lonhomework::results{'resource.status'}='pass';
-		$Apache::lonhomework::results{"resource.0.award"}='INCORRECT';
+		$Apache::lonhomework::results{"resource.$version.award"}='INCORRECT';
 		&remove_from_queue();
 	    }
 	    &Apache::structuretags::finalize_storage();
@@ -645,7 +650,7 @@
 		$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.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.='<a href="'.$file.'" target="lonGRDs"><img src="'.
Index: loncom/homework/lonhomework.pm
diff -u loncom/homework/lonhomework.pm:1.207 loncom/homework/lonhomework.pm:1.208
--- loncom/homework/lonhomework.pm:1.207	Tue May 10 16:29:26 2005
+++ loncom/homework/lonhomework.pm	Tue May 10 16:58:38 2005
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # The LON-CAPA Homework handler
 #
-# $Id: lonhomework.pm,v 1.207 2005/05/10 20:29:26 albertel Exp $
+# $Id: lonhomework.pm,v 1.208 2005/05/10 20:58:38 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -168,10 +168,12 @@
 sub proctor_checked_in {
     my ($slot_name,$slot)=@_;
     my @allowed=split(",",$slot->{'proctor'});
+    my $version=$Apache::lonhomework::history{'resource.version'};
     foreach my $possible (@allowed) { 
-	if ($Apache::lonhomework::history{'resource.checkedin'} eq $possible &&
-	    $Apache::lonhomework::history{'resource.checkedin.slot'} eq 
-	        $slot_name ) {
+	if ($Apache::lonhomework::history{"resource.$version.checkedin"} eq
+	    $possible &&
+	    $Apache::lonhomework::history{"resource.$version.checkedin.slot"}
+	       eq $slot_name) {
 	    return 1;
 	}
     }
@@ -239,10 +241,10 @@
     if ($env{'request.state'} eq "construct") {
 	return ($status,$datemsg);
     }
-    
-    if ($Apache::lonhomework::history{'resource.checkedin'}) {
-	if ($Apache::lonhomework::history{'resource.status'} eq 'pass' ||
-	    $Apache::lonhomework::history{'resource.status'} eq 'fail') {
+    my $version=$Apache::lonhomework::history{'resource.version'};
+    if ($Apache::lonhomework::history{"resource.$version.checkedin"}) {
+	if ($Apache::lonhomework::history{"resource.$version.status"} eq 'pass' ||
+	    $Apache::lonhomework::history{"resource.$version.status"} eq 'fail') {
 	    return ('SHOW_ANSWER');
 	}
     }
@@ -273,7 +275,7 @@
 	$slotstatus='CAN_ANSWER';
     }
     if ( ($slotstatus eq 'NOT_IN_A_SLOT' || $slotstatus eq 'NEEDS_CHECKIN') && 
-	$Apache::lonhomework::history{'resource.checkedin'}) {
+	$Apache::lonhomework::history{"resource.$version.checkedin"}) {
 	return ('WAITING_FOR_GRADE');
     }
     return ($slotstatus,$datemsg,$slot_name,$returned_slot);