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

albertel lon-capa-cvs@mail.lon-capa.org
Fri, 20 May 2005 18:53:54 -0000


albertel		Fri May 20 14:53:54 2005 EDT

  Modified files:              
    /loncom/homework	bridgetask.pm essayresponse.pm inputtags.pm 
  Log:
  - couple more version.0 tweaks
  - need to reset standr lon-capa status bits on creation of new version
  
  
Index: loncom/homework/bridgetask.pm
diff -u loncom/homework/bridgetask.pm:1.27 loncom/homework/bridgetask.pm:1.28
--- loncom/homework/bridgetask.pm:1.27	Fri May 20 14:07:29 2005
+++ loncom/homework/bridgetask.pm	Fri May 20 14:53:53 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.27 2005/05/20 18:07:29 albertel Exp $
+# $Id: bridgetask.pm,v 1.28 2005/05/20 18:53:53 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -76,6 +76,11 @@
 		    $user.'@'.$domain;
 		$Apache::lonhomework::results{"resource.$version.checkedin.slot"}=
 		    $slot_name;
+		foreach my $key (keys(%Apache::lonhomework::history)) {
+		    if ($key=~/^resource\.0\./) {
+			$Apache::lonhomework::results{$key}='';
+		    }
+		}
 		return 1;
 	    }
 	}
@@ -271,7 +276,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.0",
+							  "bridgetask","*",
 							  'portfolioonly').
 							  "</table>";
 		    $result.=&Apache::inputtags::gradestatus('0');
@@ -283,14 +289,18 @@
 	}
 	if ($target eq 'grade' && !$env{'form.webgrade'}) {
 	    my $award='SUBMITTED';
-	    &Apache::essayresponse::file_submission('0','bridgetask',
+	    &Apache::essayresponse::file_submission("$version.0",'bridgetask',
 						    'portfiles',\$award);
 	    if ($award eq 'SUBMITTED' &&
-		$Apache::lonhomework::results{"resource.$version.bridgetask.portfiles"}) {
-		$Apache::lonhomework::results{"resource.$version.tries"}=
-		    1+$Apache::lonhomework::history{"resource.$version.tries"};
+		$Apache::lonhomework::results{"resource.$version.0.bridgetask.portfiles"}) {
+		$Apache::lonhomework::results{"resource.0.tries"}=
+		    $Apache::lonhomework::results{"resource.$version.0.tries"}=
+		    1+$Apache::lonhomework::history{"resource.$version.0.tries"};
+
+		$Apache::lonhomework::results{"resource.0.award"}=
+		    $Apache::lonhomework::results{"resource.$version.0.award"}=
+		    $award;
 	    }
-	    $Apache::lonhomework::results{"resource.$version.award"}=$award;
 	    &Apache::lonhomework::showhash(%Apache::lonhomework::results);
 	    &Apache::structuretags::finalize_storage();
 	    if ($award eq 'SUBMITTED') {
@@ -348,7 +358,7 @@
 	    }
 	    $Apache::lonhomework::results{"resource.status"}=
 		$Apache::lonhomework::results{"resource.$version.status"};
-	    if (defined($Apache::lonhomework::results{"resource.$version.awarded"})) {
+	    if (defined($Apache::lonhomework::results{"resource.$version.0.awarded"})) {
 		$Apache::lonhomework::results{"resource.0.award"}=
 		    $Apache::lonhomework::results{"resource.$version.award"};
 		$Apache::lonhomework::results{"resource.0.awarded"}=
Index: loncom/homework/essayresponse.pm
diff -u loncom/homework/essayresponse.pm:1.66 loncom/homework/essayresponse.pm:1.67
--- loncom/homework/essayresponse.pm:1.66	Tue May  3 15:22:58 2005
+++ loncom/homework/essayresponse.pm	Fri May 20 14:53:53 2005
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # essay (ungraded) style responses
 #
-# $Id: essayresponse.pm,v 1.66 2005/05/03 19:22:58 albertel Exp $
+# $Id: essayresponse.pm,v 1.67 2005/05/20 18:53:53 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -154,9 +154,11 @@
 sub file_submission {
     my ($part,$id,$which,$award,$uploadedflag)=@_;
     my $files;
-    if ($which eq 'portfiles') { $files= $env{'form.HWPORT'.$part.'_'.$id}; }
+    my $jspart=$part;
+    $jspart=~s/\./_/g;
+    if ($which eq 'portfiles') { $files= $env{'form.HWPORT'.$jspart.'_'.$id}; }
     if ($which eq 'filename') {
-	$files = $env{'form.HWFILE'.$part.'_'.$id.'.filename'};
+	$files = $env{'form.HWFILE'.$jspart.'_'.$id.'.filename'};
     }
     
     if ($files =~ /[^\s]/) {
@@ -187,7 +189,7 @@
 	    $Apache::lonhomework::results{"resource.$part.$id.uploadedfile"}=
 		$files;
 	    $Apache::lonhomework::results{"resource.$part.$id.uploadedurl"}=
-		&Apache::lonnet::userfileupload('HWFILE'.$part.'_'.$id,undef,
+		&Apache::lonnet::userfileupload('HWFILE'.$jspart.'_'.$id,undef,
 						'essayresponse');
 	}
     } elsif ($which eq 'portfiles' &&
Index: loncom/homework/inputtags.pm
diff -u loncom/homework/inputtags.pm:1.166 loncom/homework/inputtags.pm:1.167
--- loncom/homework/inputtags.pm:1.166	Fri Apr  8 15:39:32 2005
+++ loncom/homework/inputtags.pm	Fri May 20 14:53:53 2005
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # input  definitons
 #
-# $Id: inputtags.pm,v 1.166 2005/04/08 19:39:32 albertel Exp $
+# $Id: inputtags.pm,v 1.167 2005/05/20 18:53:53 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -305,6 +305,10 @@
 sub file_selector {
     my ($part,$id,$uploadedfiletypes,$which)=@_;
     if (!$uploadedfiletypes) { return ''; }
+
+    my $jspart=$part;
+    $jspart=~s/\./_/g;
+
     my $result;
     
     $result.='<tr><td>';
@@ -315,7 +319,7 @@
     if ($which eq 'uploadonly' || $which eq 'both') { 
 	$result.=&mt('Submit a file: (only one file can be uploaded)').
 	    ' <br /><input type="file" size="50" name="HWFILE'.
-	    $part.'_'.$id.'" /><br />';
+	    $jspart.'_'.$id.'" /><br />';
 	my $uploadedfile= &HTML::Entities::encode($Apache::lonhomework::history{"resource.$part.$id.uploadedfile"},'<>&"');
 
 	if ($uploadedfile) {
@@ -334,9 +338,9 @@
 	$result.='<br />'.'<strong>'.&mt('OR:').'</strong><br />';
     }
     if ($which eq 'portfolioonly' || $which eq 'both') { 
-	$result.='<a href='."'".'javascript:void(window.open("/adm/portfolio?mode=selectfile&amp;fieldname=HWPORT'.$part.'_'.$id.'","cat","height=600,width=800,scrollbars=1,resizable=1,menubar=2,location=1"))'."'".'>'.
+	$result.='<a href='."'".'javascript:void(window.open("/adm/portfolio?mode=selectfile&amp;fieldname=HWPORT'.$jspart.'_'.$id.'","cat","height=600,width=800,scrollbars=1,resizable=1,menubar=2,location=1"))'."'".'>'.
 	    &mt('Select Portfolio Files').'</a><br />'.
-	    '<input type="text" size="50" name="HWPORT'.$part.'_'.$id.'" value="" />'.
+	    '<input type="text" size="50" name="HWPORT'.$jspart.'_'.$id.'" value="" />'.
 	    '<br />';
 	if ($Apache::lonhomework::history{"resource.$part.$id.portfiles"}=~/[^\s]/){
 	    my @filelist;