[LON-CAPA-cvs] cvs: loncom /interface lonhtmlcommon.pm lonparmset.pm

matthew lon-capa-cvs@mail.lon-capa.org
Fri, 20 Jun 2003 16:13:06 -0000


This is a MIME encoded message

--matthew1056125586
Content-Type: text/plain

matthew		Fri Jun 20 12:13:06 2003 EDT

  Modified files:              
    /loncom/interface	lonhtmlcommon.pm lonparmset.pm 
  Log:
  lonparmset:
      Added 'default_enrollment_(start|end)_date' parameters.
      Added @Display_Order to allow us to group the parameters in some fashion.
      Use lonhtmlcommon::textbox and lonhtmlcommon::checkbox.
  lonhtmlcommon:
      Added &textbox and &checkbox subroutines
      Modified &date_setter to wrap the form in <nobr> ... </nobr>
      Modified &date_setter to take another parameter ($special) which is
          output for each element in the form.  This lets lonparmset do
          its checkbox for setting thingy.
  
  
--matthew1056125586
Content-Type: text/plain
Content-Disposition: attachment; filename="matthew-20030620121306.txt"

Index: loncom/interface/lonhtmlcommon.pm
diff -u loncom/interface/lonhtmlcommon.pm:1.25 loncom/interface/lonhtmlcommon.pm:1.26
--- loncom/interface/lonhtmlcommon.pm:1.25	Thu Jun 19 11:02:37 2003
+++ loncom/interface/lonhtmlcommon.pm	Fri Jun 20 12:13:06 2003
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # a pile of common html routines
 #
-# $Id: lonhtmlcommon.pm,v 1.25 2003/06/19 15:02:37 matthew Exp $
+# $Id: lonhtmlcommon.pm,v 1.26 2003/06/20 16:13:06 matthew Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -58,6 +58,45 @@
 use Time::Local;
 use strict;
 
+
+##############################################
+##############################################
+
+=pod
+
+=item textbox
+
+=cut
+
+##############################################
+##############################################
+sub textbox {
+    my ($name,$value,$size,$special) = @_;
+    $size = 40 if (! defined($size));
+    my $Str = '<input type="text" name="'.$name.'" size="'.$size.'" '.
+        'value="'.$value.'" '.$special.' />';
+    return $Str;
+}
+
+##############################################
+##############################################
+
+=pod
+
+=item checkbox
+
+=cut
+
+##############################################
+##############################################
+sub checkbox {
+    my ($name) = @_;
+    my $Str = '<input type="checkbox" name="'.$name.'" />';
+    return $Str;
+}
+
+
+
 ##############################################
 ##############################################
 
@@ -85,6 +124,11 @@
 An undefined value is taken to indicate the value is the current time.
 Also, to be explicit, a value of 'now' also indicates the current time.
 
+=item $special
+
+Additional html/javascript to be associated with each element in
+the date_setter.  See lonparmset for example usage.
+
 =back
 
 Bugs
@@ -96,7 +140,7 @@
 ##############################################
 ##############################################
 sub date_setter {
-    my ($formname,$dname,$currentvalue) = @_;
+    my ($formname,$dname,$currentvalue,$special) = @_;
     if (! defined($currentvalue) || $currentvalue eq 'now') {
         $currentvalue = time;
     }
@@ -139,7 +183,7 @@
     }
 </script>
 ENDJS
-    $result .= "  <select name=\"$dname\_month\" ".
+    $result .= "  <nobr><select name=\"$dname\_month\" ".$special.' '.
         "onChange=\"javascript:$dname\_checkday()\" >\n";
     my @Months = qw/January February  March     April   May      June 
                     July    August    September October November December/;
@@ -152,13 +196,13 @@
     }
     $result .= "  </select>\n";
     $result .= "  <input type=\"text\" name=\"$dname\_day\" ".
-            "value=\"$mday\" size=\"3\" ".
+            "value=\"$mday\" size=\"3\" ".$special.' '.
             "onChange=\"javascript:$dname\_checkday()\" />\n";
     $result .= "  <input type=\"year\" name=\"$dname\_year\" ".
-            "value=\"$year\" size=\"5\" ".
+            "value=\"$year\" size=\"5\" ".$special.' '.
             "onChange=\"javascript:$dname\_checkday()\" />\n";
     $result .= "&nbsp;&nbsp;";
-    $result .= "  <select name=\"$dname\_hour\" >\n";
+    $result .= "  <select name=\"$dname\_hour\" ".$special." >\n";
     for (my $h = 0;$h<24;$h++) {
         $result .= "      <option value=\"$h\" ";
         $result .= "selected " if ($hour == $h);
@@ -175,11 +219,11 @@
         $result .= " </option>\n";
     } 
     $result .= "  </select>\n";
-    $result .= "  <input type=\"text\" name=\"$dname\_minute\" ".
+    $result .= "  <input type=\"text\" name=\"$dname\_minute\" ".$special.' '.
         "value=\"$min\" size=\"3\" /> m\n";
-    $result .= "  <input type=\"text\" name=\"$dname\_second\" ".
+    $result .= "  <input type=\"text\" name=\"$dname\_second\" ".$special.' '.
         "value=\"$sec\" size=\"3\" /> s\n";
-    $result .= "<!-- end $dname date setting form -->\n";
+    $result .= "</nobr>\n<!-- end $dname date setting form -->\n";
     return $result;
 }
 
Index: loncom/interface/lonparmset.pm
diff -u loncom/interface/lonparmset.pm:1.106 loncom/interface/lonparmset.pm:1.107
--- loncom/interface/lonparmset.pm:1.106	Fri Jun 20 10:56:09 2003
+++ loncom/interface/lonparmset.pm	Fri Jun 20 12:13:06 2003
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Handler to set parameters for assessments
 #
-# $Id: lonparmset.pm,v 1.106 2003/06/20 14:56:09 www Exp $
+# $Id: lonparmset.pm,v 1.107 2003/06/20 16:13:06 matthew Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1433,6 +1433,11 @@
             }
         }
         #
+        # Deal with the enrollment dates
+        if ($name =~ /^default_enrollment_(start|end)_date$/) {
+            $value=&Apache::lonhtmlcommon::get_date_from_form($name.'_value');
+        }
+        #
         # Let the user know we made the changes
         if ($name) {
             my $put_result = &Apache::lonnet::put('environment',
@@ -1510,23 +1515,56 @@
                     'have different numbers and answers</font>',
              'problem_stream_switch'
                  => '<b>Allow problems to be split over pages</b><br />'.
-                    ' (<tt><b>yes</b> if allow anything else if not</tt>)'
-             );
-	foreach (keys(%values)) {
-	    unless ($descriptions{$_}) {
-		$descriptions{$_}=$_;
+                    ' (<tt><b>yes</b> if allow anything else if not</tt>)',
+             'default_enrollment_start_date' => 'The default beginning date '.
+                                                'for enrolled students.',
+             'default_enrollment_end_date'   => 'The default ending date '.
+                                                'for enrolled students.',
+             ); 
+        my @Display_Order = ('url','description','courseid',
+                             'default_xml_style','pageseparators',
+                             'question.email','comment.email','policy.email',
+                             'pch.roles.denied','pch.users.denied',
+                             'allow_limited_html_in_feedback',
+                             'rndseed',
+                             'problem_stream_switch',
+                             'spreadsheet_default_classcalc',
+                             'spreadsheet_default_studentcalc',
+                             'spreadsheet_default_assesscalc', 
+                             'hideemptyrows',
+                             'default_enrollment_start_date',
+                             'default_enrollment_end_date',
+                             );
+	foreach my $parameter (sort(keys(%values))) {
+	    if (! $descriptions{$parameter}) {
+                $descriptions{$parameter}=$parameter;
+                push(@Display_Order,$parameter);
 	    }
 	}
-	foreach (sort keys %descriptions) {
+        foreach my $parameter (@Display_Order) {
+            my $description = $descriptions{$parameter};
             # onchange is javascript to automatically check the 'Set' button.
             my $onchange = 'onFocus="javascript:window.document.forms'.
-                '[\'envform\'].elements[\''.$_.'_setparmval\']'.
+                "['envform'].elements['".$parameter."_setparmval']".
                 '.checked=true;"';
-	    $output.='<tr><td>'.$descriptions{$_}.'</td>'.
-                '<td><input name="'.$_.'_value" size=40 '.
-                'value="'.$values{$_}.'" '.$onchange.' /></td>'.
-                '<td><input type=checkbox name="'.$_.'_setparmval"></td>'.
-                '</tr>'."\n";
+            $output .= '<tr><td>'.$description.'</td>';
+            if ($parameter =~ /^default_enrollment_(start|end)_date$/) {
+                $output .= '<td>'.
+                    &Apache::lonhtmlcommon::date_setter('envform',
+                                                        $parameter.'_value',
+                                                        $values{$parameter},
+                                                        $onchange).
+                                                        '</td>';
+            } else {
+                $output .= '<td>'.
+                    &Apache::lonhtmlcommon::textbox($parameter.'_value',
+                                                    $values{$parameter},
+                                                    40,$onchange).'</td>';
+            }
+            $output .= '<td>'.
+                &Apache::lonhtmlcommon::checkbox($parameter.'_setparmval').
+                '</td>';
+            $output .= "</tr>\n";
 	}
         my $onchange = 'onFocus="javascript:window.document.forms'.
             '[\'envform\'].elements[\'newp_setparmval\']'.

--matthew1056125586--