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

albertel lon-capa-cvs@mail.lon-capa.org
Thu, 03 Apr 2003 20:05:21 -0000


albertel		Thu Apr  3 15:05:21 2003 EDT

  Modified files:              
    /loncom/homework	lonhomework.pm structuretags.pm 
  Log:
  - can now try out problems in res space, 
  
  
Index: loncom/homework/lonhomework.pm
diff -u loncom/homework/lonhomework.pm:1.117 loncom/homework/lonhomework.pm:1.118
--- loncom/homework/lonhomework.pm:1.117	Tue Mar 25 18:07:07 2003
+++ loncom/homework/lonhomework.pm	Thu Apr  3 15:05:21 2003
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # The LON-CAPA Homework handler
 #
-# $Id: lonhomework.pm,v 1.117 2003/03/25 23:07:07 albertel Exp $
+# $Id: lonhomework.pm,v 1.118 2003/04/03 20:05:21 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -69,7 +69,8 @@
       return ($ENV{'form.grade_target'});
     }
  
-    if ( defined($ENV{'form.submitted'})) {
+    if ( defined($ENV{'form.submitted'}) &&
+	 ( !defined($ENV{'form.resetdata'}))) {
       return ('grade', 'web');
     } else {
       return ('web');
@@ -631,11 +632,16 @@
     }
   }
 
+  my ($symb) = &Apache::lonxml::whichuser();
+  &Apache::lonxml::debug('symb is '.$symb);
+  if ($ENV{'request.state'} eq "construct" || $symb eq '') {
+      if ($ENV{'form.resetdata'} eq 'Reset Submissions' ||
+	  $ENV{'form.resetdata'} eq 'New Problem Variation' ) {
+	  my ($symb,$courseid,$domain,$name) = &Apache::lonxml::whichuser();
+	  &Apache::lonnet::tmpreset($symb,'',$domain,$name);
+      }
+  }
   if ($ENV{'request.state'} eq "construct") {
-    if ($ENV{'form.resetdata'} eq 'Reset Submissions') {
-      my ($symb,$courseid,$domain,$name) = &Apache::lonxml::whichuser();
-      &Apache::lonnet::tmpreset($symb,'',$domain,$name);
-    }
     if ( -e $file ) {
       if (!(defined $ENV{'form.problemmode'})) {
 	#first visit to problem in construction space
Index: loncom/homework/structuretags.pm
diff -u loncom/homework/structuretags.pm:1.161 loncom/homework/structuretags.pm:1.162
--- loncom/homework/structuretags.pm:1.161	Thu Apr  3 12:44:12 2003
+++ loncom/homework/structuretags.pm	Thu Apr  3 15:05:21 2003
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA 
 # definition of tags that give a structure to a document
 #
-# $Id: structuretags.pm,v 1.161 2003/04/03 17:44:12 albertel Exp $
+# $Id: structuretags.pm,v 1.162 2003/04/03 20:05:21 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -107,7 +107,7 @@
 	    my ($symb)=&Apache::lonxml::whichuser();
 	    if ($symb eq '') {
 		my $help = &Apache::loncommon::help_open_topic("Ambiguous_Reference");
-		$help="Browsing or <a href=\"/adm/ambiguous\">ambiguous</a> reference, submissions ignored $help<br />";
+		$help="Browsing resource, all submissions are temporary.<br />";
 		$body_tag_start.=$help;
 	    }
 	}
@@ -135,9 +135,17 @@
 sub setup_rndseed {
     my ($safeeval)=@_;
     my $rndseed;
-    if ($ENV{'request.state'} eq "construct") {
+    my ($symb)=&Apache::lonxml::whichuser();
+    if ($ENV{'request.state'} eq "construct" || $symb eq '') {
 	$rndseed=$ENV{'form.rndseed'};
 	if (!$rndseed) {
+	    $rndseed=$Apache::lonhomework::history{'rndseed'};
+	    if (!$rndseed) {
+		$rndseed=time;
+		$ENV{'form.rndseed'}=$rndseed;
+	    }
+	}
+	if ($ENV{'form.resetdata'} eq 'New Problem Variation') {
 	    $rndseed=time;
 	    $ENV{'form.rndseed'}=$rndseed;
 	}
@@ -186,8 +194,9 @@
 
 sub initialize_storage {
     %Apache::lonhomework::results=();
+    %Apache::lonhomework::history=();
     my ($symb,$courseid,$domain,$name) = &Apache::lonxml::whichuser();
-    if ($ENV{'request.state'} eq 'construct') {
+    if ($ENV{'request.state'} eq 'construct' || $symb eq '') {
 	%Apache::lonhomework::history=
 	    &Apache::lonnet::tmprestore($ENV{'request.uri'},'',$domain,$name);
 	my ($temp)=keys %Apache::lonhomework::history ;
@@ -210,7 +219,8 @@
     my ($temp) = keys %Apache::lonhomework::results;
     if ( $temp ne '' ) {
 	my ($symb,$courseid,$domain,$name) = &Apache::lonxml::whichuser();
-	if ($ENV{'request.state'} eq 'construct') {
+	if ($ENV{'request.state'} eq 'construct' || $symb eq '') {
+	    $Apache::lonhomework::results{'rndseed'}=$ENV{'form.rndseed'};
 	    $result=&Apache::lonnet::tmpstore(\%Apache::lonhomework::results,
 					$ENV{'request.uri'},'',$domain,$name);
 	    &Apache::lonxml::debug('Construct Store return message:'.$result);
@@ -308,6 +318,13 @@
 
 	#handle rand seed in construction space
 	my $rndseed=&setup_rndseed($safeeval);
+	my ($symb)=&Apache::lonxml::whichuser();
+	if ($ENV{'request.state'} ne "construct" || $symb eq '') {
+	    $form_tag_start.='<input type="hidden" name="rndseed" value="'.
+		$rndseed.'" />'.
+		    '<input type="submit" name="resetdata"
+                             value="New Problem Variation" />';
+	}
 	($status,$accessmsg) = &Apache::lonhomework::check_access('0');
 	push (@Apache::inputtags::status,$status);
 	my $expression='$external::datestatus="'.$status.'";';