--- loncom/homework/lonsimpleproblemedit.pm	2003/07/09 06:23:20	1.2
+++ loncom/homework/lonsimpleproblemedit.pm	2003/11/04 19:18:16	1.8
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Simple Problem Parameter Setting "Editor"
 #
-# $Id: lonsimpleproblemedit.pm,v 1.2 2003/07/09 06:23:20 www Exp $
+# $Id: lonsimpleproblemedit.pm,v 1.8 2003/11/04 19:18:16 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -32,6 +32,7 @@ use strict;
 use Apache::Constants qw(:common :http);
 use Apache::loncommon;
 use Apache::lonnet;
+use Apache::lonlocal;
 
 my %qparms;
 my $prefix;
@@ -60,6 +61,7 @@ sub rawrendering {
     $ENV{'user.name'}=time;
     $ENV{'user.domain'}=time;
     my $result = &Apache::lonxml::xmlparse($request,'web', $problem);
+    undef($Apache::lonhomework::parsing_a_problem);
     $ENV{'user.name'}=$uname;
     $ENV{'user.domain'}=$udom;
     $result=~s/^.*\<body[^\>]*\>//si;
@@ -132,17 +134,17 @@ sub handler {
     my $r = shift;
 
     if ($r->header_only) {
-        $r->content_type('text/html');
+        &Apache::loncommon::content_type($r,'text/html');
         $r->send_http_header;
         return OK;
     }
 
 # -------------------------------------------------------------------- Allowed?
-    unless (&Apache::lonnet::allowed('srm',$ENV{'request.course.id'})) {
+    unless (&Apache::lonnet::allowed('mdc',$ENV{'request.course.id'})) {
 	return HTTP_NOT_ACCEPTABLE; 
     }
 # ----------------------------------------------------------------- Send header
-    $r->content_type('text/html');
+    &Apache::loncommon::content_type($r,'text/html');
     $r->send_http_header;
 # ----------------------------------------------------- Figure out where we are
     my $uri=$r->uri;
@@ -167,6 +169,7 @@ sub handler {
 	    }
             $ENV{'form.options'}="('".join("','",keys %curoptions)."')";
 	}
+	$ENV{'form.hiddenparts'}='!'.$ENV{'form.questiontype'};
         foreach (keys %ENV) {
 	    if ($_=~/^form\.(\w+)$/) {
                 my $parm=$1;
@@ -204,13 +207,16 @@ ENDDOCUMENT
 # Question Type        
 	my %questiontypes=('radio'  => 
                                '1 out of N multiple choice (radio button)',
-			   'option' => 'Option Response');
+			   'option' => 'Option response',
+                           'string' => 'Short string response',
+                           'essay'  => 'Essay, open end');
         $qtype=$qparms{$prefix.'questiontype'};
         unless (defined($qtype)) { $qtype='radio'; }
         unless ($questiontypes{$qtype}) { $qtype='radio'; }
-        $r->print('Question Type: '.&Apache::loncommon::select_form
+        $r->print('<b>Question Type: '.&Apache::loncommon::select_form
 	                               ($qtype,'questiontype',%questiontypes).
-                  '<p>&nbsp;</p>');
+  '</b><br /><input type="submit" value="'.&mt('Store Changes').
+  '" /><p>&nbsp;</p>');
 # Question Text
         $r->print(&questiontext());
 # Radio, Option ===
@@ -227,7 +233,8 @@ ENDDOCUMENT
             unless ($randomizes{$randomize}) { $randomize='yes'; }
 	    $r->print(
 		  '<table bgcolor="#00ee44" cellspacing="4" cellpadding="2">'.
-	          '<tr><td>Max number of foils displayed: <input type="text" size="3" name="maxfoils" value="'.$maxfoils.'" />&nbsp;&nbsp;'.
+	          '<tr><td>'.&mt('Max number of foils displayed').
+': <input type="text" size="3" name="maxfoils" value="'.$maxfoils.'" />&nbsp;&nbsp;'.
 		      &Apache::loncommon::select_form
 		      ($randomize,'randomize',%randomizes).
 		  '</td></tr><tr><td bgcolor="#AAAAAA">');
@@ -240,7 +247,8 @@ ENDDOCUMENT
 		  '<table bgcolor="#ffcc22" cellspacing="4" cellpadding="2">'.
 		  '<tr><td><input type="hidden" name="options" value="'.
                   $options.'" />Add new option: '.
-          '<input type="text" name="newopt" size="15" />Delete an option: '.
+          '<input type="text" name="newopt" size="15" />'.
+          &mt('Delete an option').': '.
           &Apache::loncommon::select_form('','delopt',('' => '',%optionshash)).
           '</td></tr><tr><td>');
 	    }
@@ -255,14 +263,33 @@ ENDDOCUMENT
 
 # End Response
 	    $r->print('</td></tr></table><br />');
+# Hint
+	    $r->print(&hint());
 	}
+	if ($qtype eq 'string') {
+            my %stringtypes=(
+	       'cs' => 'Case sensitive',
+	       'ci' => 'Case Insensitive',
+	       'mc' => 'Multiple Choice, Order of characters unchecked');
+            my $stringanswer=$qparms{$prefix.'stringanswer'};
+            unless (defined($stringanswer)) { $stringanswer=''; }
+            my $stringtype=$qparms{$prefix.'stringtype'};
+            unless (defined($stringtype)) { $stringtype='cs'; }
+            unless ($stringtypes{$stringtype}) { $stringtype='cs'; }
+	    $r->print(
+		  '<table bgcolor="#00ee44" cellspacing="4" cellpadding="2">'.
+	          '<tr><td>'.&mt('Correct answer').': <input type="text" size="20" name="stringanswer" value="'.$stringanswer.'" />&nbsp;&nbsp;'.
+		      &Apache::loncommon::select_form
+		      ($stringtype,'stringtype',%stringtypes).
+		  '</td></tr></table><br />');
 # Hint
-        $r->print(&hint());
+	    $r->print(&hint());
+	}
 # Store Button
 	$r->print(
-  '<input type="submit" name="storeproblem" value="Store Changes" /></form>');
+  '<input type="submit" value="'.&mt('Store Changes').'" /></form>');
     } else {
-	$r->print('Could not identify problem.');
+	$r->print(&mt('Could not identify problem.'));
     }
     $r->print('</body></html>');
     return OK;