[LON-CAPA-cvs] cvs: rat /client parameter.html loncom/homework lonhomework.pm structuretags.pm

albertel lon-capa-cvs@mail.lon-capa.org
Fri, 10 Feb 2006 23:45:03 -0000


albertel		Fri Feb 10 18:45:03 2006 EDT

  Modified files:              
    /loncom/homework	lonhomework.pm structuretags.pm 
    /rat/client	parameter.html 
  Log:
  - BUG#4149 - practice problems
  
  
  
Index: loncom/homework/lonhomework.pm
diff -u loncom/homework/lonhomework.pm:1.233 loncom/homework/lonhomework.pm:1.234
--- loncom/homework/lonhomework.pm:1.233	Fri Feb 10 13:36:37 2006
+++ loncom/homework/lonhomework.pm	Fri Feb 10 18:44:53 2006
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # The LON-CAPA Homework handler
 #
-# $Id: lonhomework.pm,v 1.233 2006/02/10 18:36:37 albertel Exp $
+# $Id: lonhomework.pm,v 1.234 2006/02/10 23:44:53 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -990,15 +990,6 @@
     &Apache::lonxml::debug("Problem Mode ".$env{'form.problemmode'});
     my ($symb) = &Apache::lonxml::whichuser();
     &Apache::lonxml::debug('symb is '.$symb);
-    if ($env{'request.state'} eq "construct" || $symb eq '') {
-	if ($env{'form.resetdata'} eq &mt('Reset Submissions') ||
-	    $env{'form.resetdata'} eq &mt('New Problem Variation') ||
-	    $env{'form.newrandomization'} eq &mt('New Randomization')) {
-	    my ($symb,$courseid,$domain,$name) = &Apache::lonxml::whichuser();
-	    &Apache::lonnet::tmpreset($symb,'',$domain,$name);
-	    &Apache::lonxml::debug("Attempt reset");
-	}
-    }
     if ($env{'request.state'} eq "construct") {
 	if ( -e $file ) {
 	    &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
Index: loncom/homework/structuretags.pm
diff -u loncom/homework/structuretags.pm:1.332 loncom/homework/structuretags.pm:1.333
--- loncom/homework/structuretags.pm:1.332	Fri Jan 27 18:36:48 2006
+++ loncom/homework/structuretags.pm	Fri Feb 10 18:44:53 2006
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA 
 # definition of tags that give a structure to a document
 #
-# $Id: structuretags.pm,v 1.332 2006/01/27 23:36:48 albertel Exp $
+# $Id: structuretags.pm,v 1.333 2006/02/10 23:44:53 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -186,8 +186,10 @@
     my ($safeeval)=@_;
     my $rndseed;
     my ($symb)=&Apache::lonxml::whichuser();
-    if ($env{'request.state'} eq "construct" || $symb eq '' ||
-          $Apache::lonhomework::history{'resource.CODE'}) {
+    if ($env{'request.state'} eq "construct" 
+	|| $symb eq '' 
+	|| $Apache::lonhomework::type eq 'practice'
+	|| $Apache::lonhomework::history{'resource.CODE'}) {
 	&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
 						['rndseed']);
 	$rndseed=$env{'form.rndseed'};
@@ -330,9 +332,19 @@
     %Apache::lonhomework::results=();
     %Apache::lonhomework::history=();
     my ($symb,$courseid,$domain,$name) = &Apache::lonxml::whichuser();
-    if ($env{'request.state'} eq 'construct' || $symb eq '') {
+    if ($env{'request.state'} eq 'construct' 
+	|| $symb eq ''
+	|| $Apache::lonhomework::type eq 'practice') {
+	
+	my $namespace = $symb || $env{'request.uri'};
+	if ($env{'form.resetdata'} eq &mt('Reset Submissions') ||
+	    $env{'form.resetdata'} eq &mt('New Problem Variation') ||
+	    $env{'form.newrandomization'} eq &mt('New Randomization')) {
+	    &Apache::lonnet::tmpreset($namespace,'',$domain,$name);
+	    &Apache::lonxml::debug("Attempt reset");
+	}
 	%Apache::lonhomework::history=
-	    &Apache::lonnet::tmprestore($env{'request.uri'},'',$domain,$name);
+	    &Apache::lonnet::tmprestore($namespace,'',$domain,$name);
 	my ($temp)=keys %Apache::lonhomework::history ;
 	&Apache::lonxml::debug("Return message of $temp");
     } else {
@@ -356,10 +368,13 @@
 	my @remove = grep(/^INTERNAL_/,keys(%Apache::lonhomework::results));
 	delete(@Apache::lonhomework::results{@remove});
 	my ($symb,$courseid,$domain,$name) = &Apache::lonxml::whichuser();
-	if ($env{'request.state'} eq 'construct' || $symb eq '') {
+	if ($env{'request.state'} eq 'construct' 
+	    || $symb eq ''
+	    || $Apache::lonhomework::type eq 'practice') {
+	    my $namespace = $symb || $env{'request.uri'};
 	    $Apache::lonhomework::results{'rndseed'}=$env{'form.rndseed'};
 	    $result=&Apache::lonnet::tmpstore(\%Apache::lonhomework::results,
-					$env{'request.uri'},'',$domain,$name);
+					      $namespace,'',$domain,$name);
 	    &Apache::lonxml::debug('Construct Store return message:'.$result);
 	} else {
 	    $result=&Apache::lonnet::cstore(\%Apache::lonhomework::results,
@@ -602,14 +617,15 @@
 	#handle rand seed in construction space
 	my $rndseed=&setup_rndseed($safeeval);
 	my ($symb)=&Apache::lonxml::whichuser();
-	if ($env{'request.state'} ne "construct" && $symb eq '') {
+	if ($env{'request.state'} ne "construct" && 
+	    ($symb eq '' || $Apache::lonhomework::type eq 'practice')) {
 	    $form_tag_start.='<input type="hidden" name="rndseed" value="'.
 		$rndseed.'" />'.
 		    '<input type="submit" name="resetdata"
                              value="'.&mt('New Problem Variation').'" />'.
 		    '<input type="hidden" name="username"
                              value="'.$env{'form.username'}.'" />';
-	    if ($env{'user.adv'}) {
+	    if ($env{'request.role.adv'}) {
 		$form_tag_start.=
 		    ' <label><input type="checkbox" name="showallfoils" ';
 		if (defined($env{'form.showallfoils'})) {
Index: rat/client/parameter.html
diff -u rat/client/parameter.html:1.34 rat/client/parameter.html:1.35
--- rat/client/parameter.html:1.34	Thu Aug 11 17:31:46 2005
+++ rat/client/parameter.html	Fri Feb 10 18:45:02 2006
@@ -3,7 +3,7 @@
 The LearningOnline Network with CAPA
 Parameter Input Window
 //
-// $Id: parameter.html,v 1.34 2005/08/11 21:31:46 albertel Exp $
+// $Id: parameter.html,v 1.35 2006/02/10 23:45:02 albertel Exp $
 //
 // Copyright Michigan State University Board of Trustees
 //
@@ -570,10 +570,10 @@
                ' type="radio" '+callradiostringeval('problem'));
            if (svalue=='problem') { choicewrite(' checked'); }
            choicewrite('> Standard Problem</label><br />');
-           choicewrite('<label><input name="stringval" value="quiz"'+
-                  ' type="radio" '+callradiostringeval('quiz'));
-           if (svalue=='quiz') { choicewrite(' checked'); }
-           choicewrite('> Quiz</label><br />');
+           choicewrite('<label><input name="stringval" value="practice"'+
+                  ' type="radio" '+callradiostringeval('practice'));
+           if (svalue=='practice') { choicewrite(' checked'); }
+           choicewrite('> Practice</label><br />');
            choicewrite('<label><input name="stringval" value="exam"'+
                   ' type="radio" '+callradiostringeval('exam'));
            if (svalue=='exam') { choicewrite(' checked'); }