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

albertel lon-capa-cvs@mail.lon-capa.org
Thu, 03 Nov 2005 21:29:57 -0000


albertel		Thu Nov  3 16:29:57 2005 EDT

  Modified files:              
    /loncom/homework	bridgetask.pm structuretags.pm 
  Log:
  - Enabling CSTR actions on BT (EditXML / differnt randomizations / reset)
  
  
Index: loncom/homework/bridgetask.pm
diff -u loncom/homework/bridgetask.pm:1.73 loncom/homework/bridgetask.pm:1.74
--- loncom/homework/bridgetask.pm:1.73	Mon Oct 24 14:40:21 2005
+++ loncom/homework/bridgetask.pm	Thu Nov  3 16:29:57 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.73 2005/10/24 18:40:21 albertel Exp $
+# $Id: bridgetask.pm,v 1.74 2005/11/03 21:29:57 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -382,6 +382,9 @@
 	&Apache::structuretags::init_problem_globals('Task');
 	&Apache::structuretags::initialize_storage();
 	&Apache::lonhomework::showhash(%Apache::lonhomework::history);
+	if ($env{'request.state'} eq 'construct') {
+	    &Apache::structuretags::setup_rndseed($safeeval);
+	}
     } 
 
     $Apache::lonhomework::parsing_a_task=1;
@@ -389,7 +392,7 @@
     my ($result,$head_tag_start,$body_tag_start,$form_tag_start)=
 	&Apache::structuretags::page_start($target,$token,$tagstack,$parstack,$parser,$safeeval);
     
-    if ($target eq 'web') {
+    if ($target eq 'web' && $env{'request.state'} ne 'construct') {
 	if ($Apache::lonhomework::modifygrades) {
 	    $body_tag_start.='<form name="gradesubmission" method="POST" action="';
 	    my $uri=$env{'request.uri'};
@@ -406,6 +409,9 @@
 	    }
 	}
     }
+    if ($target eq 'web' && $env{'request.state'} eq 'construct') {
+	$form_tag_start.=&Apache::structuretags::problem_web_to_edit_header($env{'form.rndseed'});
+    }
     if ($target eq 'web' || ($target eq 'grade' && !$env{'form.webgrade'}) || $target eq 'answer' ||
 	$target eq 'tex') {
 	my ($version,$previous)=&get_version();
@@ -422,6 +428,9 @@
 	    my $bodytext=&Apache::lonxml::get_all_text("/task",$parser);
 	    if ( $target eq "web" ) {
 		$result.= $head_tag_start.'</head>'.$body_tag_start;
+		if ($env{'request.state'} eq 'construct') {
+		    $result.=$form_tag_start;
+		}
 		my $msg;
 		if ($status eq 'UNAVAILABLE') {
 		    $msg.='<h1>'.&mt('Unable to determine if this resource is open due to network problems. Please try again later.').'</h1>';
@@ -553,6 +562,13 @@
 	    }
 	    if ($webgrade eq 'yes') { $result.=&webgrade_standard_info(); }
 	}
+    } elsif ($target eq 'edit') {
+	$result.=$head_tag_start."</head>".$body_tag_start.$form_tag_start.
+	    &Apache::structuretags::problem_edit_header();
+	$Apache::lonxml::warnings_error_header=
+	    &mt("Editor Errors - these errors might not effect the running of the problem, but they will likely cause problems with further use of the Edit mode. Please use the EditXML mode to fix these errors.")."<br />";
+	my $temp=&Apache::edit::insertlist($target,$token);
+	$result.=$temp;
     } else {
 	# page_start returned a starting result, delete it if we don't need it
 	$result = '';
Index: loncom/homework/structuretags.pm
diff -u loncom/homework/structuretags.pm:1.312 loncom/homework/structuretags.pm:1.313
--- loncom/homework/structuretags.pm:1.312	Thu Nov  3 12:55:12 2005
+++ loncom/homework/structuretags.pm	Thu Nov  3 16:29:57 2005
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA 
 # definition of tags that give a structure to a document
 #
-# $Id: structuretags.pm,v 1.312 2005/11/03 17:55:12 albertel Exp $
+# $Id: structuretags.pm,v 1.313 2005/11/03 21:29:57 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -245,9 +245,11 @@
 
 sub problem_web_to_edit_header {
     my ($rndseed)=@_;
-    my $result.='<input type="hidden" name="problemmode" value="'.&mt('View').'" />
-             <input type="submit" name="problemmode" accesskey="e" value="'.&mt('Edit').'" />
-             <input type="submit" name="problemmode" accesskey="x" value="'.&mt('EditXML').'" />
+    my $result.='<input type="hidden" name="problemmode" value="'.&mt('View').'" />';
+    if (!$Apache::lonhomework::parsing_a_task) {
+	$result .= '<input type="submit" name="problemmode" accesskey="e" value="'.&mt('Edit').'" />';
+    }
+    $result .= '<input type="submit" name="problemmode" accesskey="x" value="'.&mt('EditXML').'" />
              <input type="submit" name="newrandomization" accesskey="a" value="'.&mt('New Randomization').'" />
              <input type="submit" name="resetdata" accesskey="r" value="'.&mt('Reset Submissions').'" />
              <nobr><input type="submit" name="changerandseed" value="'.&mt('Change Random Seed To:').'" />
@@ -259,7 +261,8 @@
     $result.= ' />'.&mt('&nbsp;Show&nbsp;All&nbsp;Foils').
 	&Apache::loncommon::help_open_topic('Problem_Editor_Testing_Area','Testing Problems').
 	'</label><hr />';
-    $result.="
+    if (!$Apache::lonhomework::parsing_a_task) {
+	$result.="
 <nobr>
 Problem Status:
 <select name='problemstate'>
@@ -290,15 +293,16 @@
 </nobr>
 <input type='submit' name='changeproblemmode' value='".&mt("Change")."' />
 <hr />";
-    my $numtoanalyze=$env{'form.numtoanalyze'};
-    if (!$numtoanalyze) { $numtoanalyze=20; }
-    $result.= '<input type="submit" name="problemmode" value='.
-	&mt('"Calculate answers').'" /> for
+	my $numtoanalyze=$env{'form.numtoanalyze'};
+	if (!$numtoanalyze) { $numtoanalyze=20; }
+	$result.= '<input type="submit" name="problemmode" value='.
+	    &mt('"Calculate answers').'" /> for
              <input type="text" name="numtoanalyze" value="'.
 	     $numtoanalyze.'" size="5" /> '.&mt('versions of this problem').
 	     '.'.&Apache::loncommon::help_open_topic("Analyze_Problem",
 						     '',undef,undef,300).
 						     '<hr />';
+    }
     return $result;
 }