[LON-CAPA-cvs] cvs: loncom /homework edit.pm /homework/caparesponse caparesponse.pm

albertel lon-capa-cvs@mail.lon-capa.org
Thu, 07 Nov 2002 19:45:17 -0000


albertel		Thu Nov  7 14:45:17 2002 EDT

  Modified files:              
    /loncom/homework	edit.pm 
    /loncom/homework/caparesponse	caparesponse.pm 
  Log:
  - <stringresponse> edit mode much prettier
  - reduce the vertical space use with the insert list
  - reduce the horizontal space used with nested tags
  
  
Index: loncom/homework/edit.pm
diff -u loncom/homework/edit.pm:1.38 loncom/homework/edit.pm:1.39
--- loncom/homework/edit.pm:1.38	Sun Nov  3 14:16:19 2002
+++ loncom/homework/edit.pm	Thu Nov  7 14:45:16 2002
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA 
 # edit mode helpers
 #
-# $Id: edit.pm,v 1.38 2002/11/03 19:16:19 www Exp $
+# $Id: edit.pm,v 1.39 2002/11/07 19:45:16 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -99,20 +99,25 @@
   }
   $Apache::edit::colordepth++;
   push(@Apache::edit::inserttag,$token->[1]);
-  my $result="<p align=\"right\"><table bgcolor=\"$color\" width=\"95%\" border=\"2\">";
+  my $result='<p align="right">';
+  $result.='<table bgcolor="'.$color.'" width="99%" border="2">';
   return $result;
 }
 
 sub end_table {
   $Apache::edit::colordepth--;
-  my $result="</table></p>";
-  $result.=
-	"<p><table width=\"100%\"><tr><td>".
-        &innerinsertlist('edit',
- (defined($Apache::edit::inserttag[-2])?$Apache::edit::inserttag[-2]:'problem')
-,
- (defined($Apache::edit::inserttag[-1])?$Apache::edit::inserttag[-1]:'')).
-        "</td></tr></table></p>";
+  my $result='</table></p>';
+  $result.="<table><tr><td>";
+
+  my ($tagname,$closingtag);
+  if (defined($Apache::edit::inserttag[-2])) {
+    $tagname=$Apache::edit::inserttag[-2];
+  } else {$tagname='problem';}
+  if (defined($Apache::edit::inserttag[-1])) {
+    $closingtag=$Apache::edit::inserttag[-1];
+  }
+  $result.=&innerinsertlist('edit',$tagname,$closingtag).
+    "</td></tr></table>";
   pop(@Apache::edit::inserttag);
   return $result;
 }
@@ -453,46 +458,61 @@
 }
 
 sub select_arg {
-  my ($description,$name,$list,$token) = @_;
-  my $result;
-  my $optionlist="";
-  my $selected=$token->[2]{$name};
-  foreach my $option (@$list) {
-    if ( $selected eq $option ) {
-      $optionlist.="<option selected=\"on\">$option</option>\n";
-    } else {
-      $optionlist.="<option>$option</option>\n";
+    my ($description,$name,$list,$token) = @_;
+    my $result;
+    my $optionlist="";
+    my $selected=$token->[2]{$name};
+    foreach my $option (@$list) {
+	my $value;
+	if ( ref($option) eq 'ARRAY') {
+	    $value='value="'.$$option[0].'"';
+	    $option=$$option[1];
+	} else {
+	    $value='value="'.$option.'"';
+	}
+	if ( $selected eq $option ) {
+	    $optionlist.="<option $value selected=\"on\">$option</option>\n";
+	} else {
+	    $optionlist.="<option $value >$option</option>\n";
+	}
     }
-  }
-  $result.=$description.'<select name="'."$Apache::lonxml::curdepth.$name".'">
+    $result.=$description.'<select name="'.
+	"$Apache::lonxml::curdepth.$name".'">
        '.$optionlist.'
       </select>';
-  return $result;
+    return $result;
 }
 
 sub select_or_text_arg {
-  my ($description,$name,$list,$token,$size) = @_;
-  my $result;
-  my $optionlist="";
-  my $found=0;
-  my $selected=$token->[2]{$name};
-  foreach my $option (@$list) {
-    if ( $selected eq $option ) {
-      $optionlist.="<option selected=\"on\">$option</option>\n";
-      $found=1;
-    } else {
-      $optionlist.="<option>$option</option>\n";
-    }
-  }
-  $optionlist.="<option value=\"TYPEDINVALUE\">Type in value</option>\n";
-  if (($found) || (!$selected)) {
-    $result.=$description.'<select name="'."$Apache::lonxml::curdepth.$name".'">
+    my ($description,$name,$list,$token,$size) = @_;
+    my $result;
+    my $optionlist="";
+    my $found=0;
+    my $selected=$token->[2]{$name};
+    foreach my $option (@$list) {
+	my $value;
+	if ( ref($option) eq 'ARRAY') {
+	    $value='value="'.$$option[0].'"';
+	    $option=$$option[1];
+	} else {
+	    $value='value="'.$option.'"';
+	}
+	if ( $selected eq $option ) {
+	    $optionlist.="<option $value selected=\"on\">$option</option>\n";
+	    $found=1;
+	} else {
+	    $optionlist.="<option $value>$option</option>\n";
+	}
+    }
+    $optionlist.="<option value=\"TYPEDINVALUE\">Type in value</option>\n";
+    if (($found) || (!$selected)) {
+	$result.=$description.'<select name="'."$Apache::lonxml::curdepth.$name".'">
        '.$optionlist.'
       </select>';
-  } else {
-    $result.=&text_arg($description,$name,$token,$size);
-  }
-  return $result;
+    } else {
+	$result.=&text_arg($description,$name,$token,$size);
+    }
+    return $result;
 }
 
 #----------------------------------------------------- browse
Index: loncom/homework/caparesponse/caparesponse.pm
diff -u loncom/homework/caparesponse/caparesponse.pm:1.69 loncom/homework/caparesponse/caparesponse.pm:1.70
--- loncom/homework/caparesponse/caparesponse.pm:1.69	Thu Nov  7 10:12:23 2002
+++ loncom/homework/caparesponse/caparesponse.pm	Thu Nov  7 14:45:16 2002
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # caparesponse definition
 #
-# $Id: caparesponse.pm,v 1.69 2002/11/07 15:12:23 sakharuk Exp $
+# $Id: caparesponse.pm,v 1.70 2002/11/07 19:45:16 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -89,7 +89,8 @@
       $result.=&Apache::edit::text_arg('Format:','format',$token,4);
     } elsif ($token->[1] eq 'stringresponse') {
       $result.=&Apache::edit::select_arg('Type:','type',
-					 ['cs','ci','mc'],$token);
+		 [['cs','Case Sensitive'],['ci','Case Insensitive'],
+		  ['mc','Case Insensitive, Any Order']],$token);
     } elsif ($token->[1] eq 'formularesponse') {
       $result.=&Apache::edit::text_arg('Sample Points:','samples',$token,40);
     }