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

bisitz bisitz@source.lon-capa.org
Mon, 30 Mar 2009 15:57:26 -0000


This is a MIME encoded message

--bisitz1238428646
Content-Type: text/plain

bisitz		Mon Mar 30 15:57:26 2009 EDT

  Modified files:              
    /loncom/interface	lonparmset.pm 
  Log:
  Introduce categories for course parameters (Course Environment):
  
  - Now, the huge amount of course parameters is split up in different categories
  - New list at top of screen provides overview of available categories and allows to directly jump to each category
  - "Save All" button and link back to overview list at bottom of each category available
  - Moved special input field creation to separate sub routine
    (which will most likely be extended in future time to provide more userfriendly input fields)
  
  
  Work in progress. Current version found to be functional, but several things are still to do:
  - Sort category output and sort parameter output of each category
  - Find useful categories and category names and assign the parameters to the categories
  - Don't display empty category tables
  - Move "Create New Environment Variable" to category with custom fields
  - Think of a solution where all categories are hidden by default and only those are shown which are wanted by the user
  - Think of another way to display the parameters to get rid of a new disadvantage: The category tables have currently different widths depending on the content
  
  
  
--bisitz1238428646
Content-Type: text/plain
Content-Disposition: attachment; filename="bisitz-20090330155726.txt"

Index: loncom/interface/lonparmset.pm
diff -u loncom/interface/lonparmset.pm:1.438 loncom/interface/lonparmset.pm:1.439
--- loncom/interface/lonparmset.pm:1.438	Sun Mar 29 18:25:33 2009
+++ loncom/interface/lonparmset.pm	Mon Mar 30 15:57:26 2009
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Handler to set parameters for assessments
 #
-# $Id: lonparmset.pm,v 1.438 2009/03/29 18:25:33 raeburn Exp $
+# $Id: lonparmset.pm,v 1.439 2009/03/30 15:57:26 bisitz Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -2512,7 +2512,14 @@
     my $SelectStyleFile=&mt('Select Style File');
     my $SelectSpreadsheetFile=&mt('Select Spreadsheet File');
     my $output='';
+    my $output_SB = ''; # will be replaced by "$output" when all changes are done
     my $can_categorize;
+    my %lt=&Apache::lonlocal::texthash(
+               'par'   => 'Parameter',
+               'val'   => 'Value',
+               'set'   => 'Set?',
+               'sav'   => 'Save',
+           );
     if (! exists($values{'con_lost'})) {
         my %descriptions=
 	    ('url'            => '<b>'.&mt('Top Level Map').'</b><br />'.
@@ -2662,70 +2669,87 @@
                  => '<b>'.&mt('Replacement titles for standard course roles').'</b><br />'.
                     '('.&mt('To replace the standard title for a course role, enter the title you wish to use, otherwise leave blank.').')',
              );
-        my @Display_Order = ('url','description','courseid','cloners');
-        (my $can_toggle_cat,$can_categorize) = &can_modify_catsettings($dom);
-        if ($can_toggle_cat) {
-            push(@Display_Order,'hidefromcat');
-        }
-        if ($can_categorize) {
-            push(@Display_Order,'categories');
-        }
-        push (@Display_Order,('grading',
-                             'externalsyllabus',
-                             'default_xml_style','pageseparators',
-                             'question.email','question.email.text','comment.email',
-                             'comment.email.text','policy.email','policy.email.text',
-                             'student_classlist_view',
-                             'student_classlist_opt_in',
-                             'student_classlist_portfiles',
-                             'plc.roles.denied','plc.users.denied',
-                             'pch.roles.denied','pch.users.denied',
-                             'allow_limited_html_in_feedback',
-                             'allow_discussion_post_editing',
-                             'languages',
-                             'timezone',
-                             'datelocale',
-                             'rolenames',
-			     'nothideprivileged',
-                             'rndseed',
-                             'receiptalg',
-                             'problem_stream_switch',
-			     'suppress_tries',
-                             'suppress_embed_prompt',
-                             'default_paper_size',
-			     'print_header_format',
-                             'disable_receipt_display',
-                             'spreadsheet_default_classcalc',
-                             'spreadsheet_default_studentcalc',
-                             'spreadsheet_default_assesscalc', 
-                             'hideemptyrows',
-                             'default_enrollment_start_date',
-                             'default_enrollment_end_date',
-			     'tthoptions',
-			     'texengine',
-			     'disablesigfigs',
-			     'disableexampointprint',
-			     'task_messages','task_grading'));
-	foreach my $parameter (sort(keys(%values))) {
-            unless (($parameter =~ m/^internal\./)||($parameter =~ m/^metadata\./) ||
-                    ($parameter =~ m/^selfenroll_/) || ($parameter =~ /_selfenroll$/)
-                    || ($parameter eq 'type') || 
-                    ($parameter =~ m/^(cc|in|ta|ep|ad|st)\.plaintext$/)) {
-                if (! $descriptions{$parameter}) {
-                    $descriptions{$parameter}=$parameter;
-                    push(@Display_Order,$parameter);
-                }
-            }
-	}
-	
-        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['".$parameter."_setparmval']".
-                '.checked=true;"';
-            $output .= &Apache::loncommon::start_data_table_row().
-		'<td>'.$description.'</td>';
+
+
+# The following code is kept to have access to the old version of display order
+
+#        my @Display_Order = ('url','description','courseid','cloners');
+#        (my $can_toggle_cat,$can_categorize) = &can_modify_catsettings($dom);
+#        if ($can_toggle_cat) {
+#            push(@Display_Order,'hidefromcat');
+#        }
+#        if ($can_categorize) {
+#            push(@Display_Order,'categories');
+#        }
+#        push (@Display_Order,('grading',
+#                             'externalsyllabus',
+#                             'default_xml_style','pageseparators',
+#                             'question.email','question.email.text','comment.email',
+#                             'comment.email.text','policy.email','policy.email.text',
+#                             'student_classlist_view',
+#                             'student_classlist_opt_in',
+#                             'student_classlist_portfiles',
+#                             'plc.roles.denied','plc.users.denied',
+#                             'pch.roles.denied','pch.users.denied',
+#                             'allow_limited_html_in_feedback',
+#                             'allow_discussion_post_editing',
+#                             'languages',
+#                             'timezone',
+#                             'datelocale',
+#                             'rolenames',
+#			     'nothideprivileged',
+#                             'rndseed',
+#                             'receiptalg',
+#                             'problem_stream_switch',
+#			     'suppress_tries',
+#                             'suppress_embed_prompt',
+#                             'default_paper_size',
+#			     'print_header_format',
+#                             'disable_receipt_display',
+#                             'spreadsheet_default_classcalc',
+#                             'spreadsheet_default_studentcalc',
+#                             'spreadsheet_default_assesscalc', 
+#                             'hideemptyrows',
+#                             'default_enrollment_start_date',
+#                             'default_enrollment_end_date',
+#			     'tthoptions',
+#			     'texengine',
+#			     'disablesigfigs',
+#			     'disableexampointprint',
+#			     'task_messages','task_grading'));
+#	foreach my $parameter (sort(keys(%values))) {
+#            unless (($parameter =~ m/^internal\./)||($parameter =~ m/^metadata\./) ||
+#                    ($parameter =~ m/^selfenroll_/) || ($parameter =~ /_selfenroll$/)
+#                    || ($parameter eq 'type') || 
+#                    ($parameter =~ m/^(cc|in|ta|ep|ad|st)\.plaintext$/)) {
+#                if (! $descriptions{$parameter}) {
+#                    $descriptions{$parameter}=$parameter;
+#                    push(@Display_Order,$parameter);
+#                }
+#            }
+#	}
+
+
+
+
+# ----------------------------------------------------------------
+# Begin: New Version with Parameter Categories
+
+    sub parameter_row {
+    # Create parameter line for course environment screen
+        my ($parameter, $description) = @_;
+        my $output = '';
+
+        # Column 1/3: Descritive text of current parameter
+        $output = &Apache::loncommon::start_data_table_row()
+                 .'<td>'.$description.'</td>';
+
+        # Column 2/3: Input field (Sometimes special field(s), depending on parameter)
+# -------------------------------
+        # onchange is javascript to automatically check the 'Set' button.
+        my $onchange = 'onFocus="javascript:window.document.forms'
+                      ."['envform'].elements['".$parameter."_setparmval']"
+                      .'.checked=true;"';
             if ($parameter =~ /^default_enrollment_(start|end)_date$/) {
                 $output .= '<td>'.
                     &Apache::lonhtmlcommon::date_setter('envform',
@@ -2786,19 +2810,294 @@
                            $values{'categories'}.'" />'.
                            '<input type="textbox" name="categories_display" value="'.
                            $catdisplay.'" readonly="readonly" size="40" /></td>';
-            } else {
-                $output .= '<td>'.
-                    &Apache::lonhtmlcommon::textbox($parameter.'_value',
-                                                    $values{$parameter},
-                                                    40,$onchange).'</td>';
-            }
-            unless ($parameter eq 'rolenames') {
-                $output .= '<td>'.
-                           &Apache::lonhtmlcommon::checkbox($parameter.'_setparmval').
-                           '</td>';
+            } else { # Display default textbox in all other cases
+                $output .= '<td>'
+                          .&Apache::lonhtmlcommon::textbox($parameter.'_value',
+                                                           $values{$parameter},
+                                                           40,
+                                                           $onchange)
+                          .'</td>';
+# -------------------------------
             }
-            $output .= &Apache::loncommon::end_data_table_row()."\n";
-	}
+
+        # Column 3/3: Check Box (in most cases)
+        unless ($parameter eq 'rolenames') {
+            $output .= '<td>'
+                      .&Apache::lonhtmlcommon::checkbox($parameter.'_setparmval')
+                      .'</td>';
+        }
+        $output .= &Apache::loncommon::end_data_table_row();
+
+        return $output;
+    }
+
+
+
+
+    # Parameter Category Names
+    my %parm_cat_names = &Apache::lonlocal::texthash (
+        'cat_0'      => 'Parameter Category Zero',
+        'cat_1'      => 'Parameter Category One',
+        'cat_2'      => 'Parameter Category Two',
+        'cat_3'      => 'Parameter Category Three',
+        'cat_4'      => 'Parameter Category Four',
+        'cat_5'      => 'Parameter Category Five',
+        'cat_6'      => 'Parameter Category Six',
+        'cat_7'      => 'Parameter Category Seven',
+        'cat_can'    => 'Parameter Category Can',
+        'cat_custom' => 'Parameter Category Custom',
+    );
+
+    # Link Parameter Categories with Parameters
+    my %parm_cat_parms = (
+        'cat_0' => [
+            'url',
+            'description',
+            'courseid',
+            'cloners'
+        ],
+        'cat_1' => [
+            'grading',
+            'externalsyllabus',
+            'default_xml_style',
+            'pageseparators'
+        ],
+        'cat_2' => [
+            'question.email',
+            'question.email.text',
+            'comment.email',
+            'comment.email.text',
+            'policy.email',
+            'policy.email.text',
+        ],
+        'cat_3' => [
+            'student_classlist_view',
+            'student_classlist_opt_in',
+            'student_classlist_portfiles',
+            'plc.roles.denied',
+            'plc.users.denied',
+            'pch.roles.denied',
+            'pch.users.denied',
+            'allow_limited_html_in_feedback',
+            'allow_discussion_post_editing',
+        ],
+        'cat_4' => [
+            'languages',
+            'timezone',
+            'datelocale',
+            'rolenames',
+            'nothideprivileged',
+            'rndseed',
+            'receiptalg',
+            'problem_stream_switch',
+            'suppress_tries',
+            'suppress_embed_prompt',
+            'default_paper_size',
+            'print_header_format',
+            'disable_receipt_display',
+        ],
+        'cat_5' => [
+            'spreadsheet_default_classcalc',
+            'spreadsheet_default_studentcalc',
+            'spreadsheet_default_assesscalc',
+            'hideemptyrows',
+        ],
+        'cat_6' => [
+            'default_enrollment_start_date',
+            'default_enrollment_end_date',
+        ],
+        'cat_7' => [
+            'tthoptions',
+            'texengine',
+            'disablesigfigs',
+            'disableexampointprint',
+            'task_messages',
+            'task_grading',
+        ],
+    );
+
+    # Add special parameters depending on special context to parameter categories hash
+    my @can_cats;
+    (my $can_toggle_cat,$can_categorize) = &can_modify_catsettings($dom);
+    if ($can_toggle_cat) {
+        push(@can_cats,'hidefromcat');
+    }
+    if ($can_categorize) {
+        push(@can_cats,'categories');
+    }
+    $parm_cat_parms{'cat_can'} = [@can_cats];
+
+    # Add custom parameters to parameter categories hash
+    my @custom_cats;
+    foreach my $parameter (sort(keys(%values))) {
+        unless (($parameter =~ m/^internal\./)||($parameter =~ m/^metadata\./) ||
+                ($parameter =~ m/^selfenroll_/) || ($parameter =~ /_selfenroll$/)
+                || ($parameter eq 'type') ||
+                ($parameter =~ m/^(cc|in|ta|ep|ad|st)\.plaintext$/)) {
+            if (! $descriptions{$parameter}) {
+                $descriptions{$parameter}=$parameter;
+                push(@custom_cats,$parameter);
+            }
+        }
+    }
+    $parm_cat_parms{'cat_custom'} = [@custom_cats];
+
+
+# Old output structure:
+
+#$start_table
+#$start_header_row
+#<th>$lt{'par'}</th><th>$lt{'val'}</th><th>$lt{'set'}</th>
+#$end_header_row
+#$output
+#$end_table
+
+
+# Display Parameter List Overview
+# Provide hyperlinks to detailed parameter settings
+$output_SB .= '<a name="parmlist" />'
+             .'<h2>'.&mt('Course Parameter Overview').'</h2>'
+             .'<div class="LC_ContentBox">'
+             .'<ul>';
+foreach my $catkey (keys(%parm_cat_names)) {
+    $output_SB .= '<li>'
+                 .'<a href="#parmlist_'.$catkey.'">'
+                 .$parm_cat_names{$catkey}
+                 .'</a>'
+                 .'</li>';
+}
+$output_SB .= '</ul>'
+            .'</div>';
+
+
+# Display Parameter Details
+my $buttons='<div align="right">'
+           .'<input type="submit" name="crsenv" value="'.&mt('Save All').'" />'
+           .'<br /><a href="#parmlist">'.&mt('Back to Parameter List').'</a>'
+           .'</div>';
+
+$output_SB .= '<h2>'.&mt('Course Parameters').'</h2>';
+
+foreach my $catkey (keys(%parm_cat_names)) {
+    $output_SB .= &Apache::loncommon::start_data_table();
+    $output_SB .= &Apache::loncommon::start_data_table_empty_row()
+                 .'<td colspan="3">'
+                 .'<a name="parmlist_'.$catkey.'" />'
+                 .'<h3>'.$parm_cat_names{$catkey}.'</h3>'
+                 .'</td>'
+                 .&Apache::loncommon::end_data_table_empty_row
+                 .&Apache::loncommon::start_data_table_header_row()
+                 .'<th>'.$lt{'par'}.'</th><th>'.$lt{'val'}.'</th><th>'.$lt{'set'}.'</th>'
+                 .&Apache::loncommon::end_data_table_header_row();
+
+    foreach my $parameter (@{$parm_cat_parms{$catkey}}) {
+        my $description = $descriptions{$parameter};
+        $output_SB .= &parameter_row($parameter, $description);
+    }
+    $output_SB .= &Apache::loncommon::start_data_table_empty_row()
+                 .'<td colspan="3">'
+                 .$buttons
+                 .'</td>'
+                 .&Apache::loncommon::end_data_table_empty_row;
+    $output_SB .= &Apache::loncommon::end_data_table()
+                . '<br />';
+}
+
+$output_SB .= '</div>';
+
+# End: New Version with Parameter Categories
+# ----------------------------------------------------------------
+
+
+#	# Display Parameter table
+#        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['".$parameter."_setparmval']".
+#                '.checked=true;"';
+#            $output .= &Apache::loncommon::start_data_table_row().
+#		'<td>'.$description.'</td>';
+#
+#
+#
+## -------------------------------
+#            if ($parameter =~ /^default_enrollment_(start|end)_date$/) {
+#                $output .= '<td>'.
+#                    &Apache::lonhtmlcommon::date_setter('envform',
+#                                                        $parameter.'_value',
+#                                                        $values{$parameter},
+#                                                        $onchange).
+#                                                        '</td>';
+#            } elsif ($parameter eq 'timezone') {
+#                my $includeempty = 1;
+#                my $timezone = &Apache::lonlocal::gettimezone();
+#                $output .= '<td>'.
+#                    &Apache::loncommon::select_timezone($parameter.'_value',
+#                                                        $timezone,
+#                                                        $onchange,$includeempty).'</td>';
+#            } elsif ($parameter eq 'datelocale') {
+#                my $includeempty = 1;
+#                my $locale_obj = &Apache::lonlocal::getdatelocale();
+#                my $currdatelocale;
+#                if (ref($locale_obj)) {
+#                    $currdatelocale = $locale_obj->id();
+#                }
+#                $output .= '<td>'.
+#                    &Apache::loncommon::select_datelocale($parameter.'_value',
+#                                                          $currdatelocale,
+#                                                          $onchange,$includeempty).'</td>';
+#            } elsif ($parameter eq 'rolenames') {
+#                $output.= '<td><table>';
+#                foreach my $role ('cc','in','ta','ep','ad','st') {
+#                    my $onchange = 'onFocus="javascript:window.document.forms'.
+#                                   "['envform'].elements['".
+#                                   $parameter.'_'.$role."_setparmval']".
+#                                   '.checked=true;"';
+#                    $output.= '<tr><td>'.&Apache::lonnet::plaintext($role,$crstype,undef,1).
+#                              '</td><td>'.
+#                              &Apache::lonhtmlcommon::textbox($parameter.'_'.$role.'_value',
+#                                                    $values{$role.'.plaintext'},
+#                                                    15,$onchange).
+#                              '</td></tr>';
+#                }
+#                $output .= '</table></td><td><table>';
+#                foreach my $role ('cc','in','ta','ep','ad','st') {
+#                    $output .= '<tr><td>'.&Apache::lonhtmlcommon::checkbox($parameter.'_'.$role.'_setparmval').
+#                              '</td></tr>';
+#                }
+#                $output .= '</table></td>';
+#            } elsif ($parameter eq 'categories') {
+#                my $catdisplay;
+#                if ($values{'categories'} ne '') {
+#                    my @curritems = split(/\&/,$values{'categories'});
+#                    foreach my $item (@curritems) {
+#                        my ($name,$parent,$pos) = split(/:/,$item);
+#                        $catdisplay .= &unescape($name).'&';
+#                    }
+#                    $catdisplay =~ s/\&$//;
+#                } 
+#                $output .= '<td>'.
+#                           '<input type="hidden" name="categories_value" value="'.
+#                           $values{'categories'}.'" />'.
+#                           '<input type="textbox" name="categories_display" value="'.
+#                           $catdisplay.'" readonly="readonly" size="40" /></td>';
+#            } else {
+#                $output .= '<td>'.
+#                    &Apache::lonhtmlcommon::textbox($parameter.'_value',
+#                                                    $values{$parameter},
+#                                                    40,$onchange).'</td>';
+#            }
+# -------------------------------
+
+
+#            unless ($parameter eq 'rolenames') {
+#                $output .= '<td>'.
+#                           &Apache::lonhtmlcommon::checkbox($parameter.'_setparmval').
+#                           '</td>';
+#            }
+#            $output .= &Apache::loncommon::end_data_table_row()."\n";
+#	}
         my $onchange = 'onFocus="javascript:window.document.forms'.
             '[\'envform\'].elements[\'newp_setparmval\']'.
             '.checked=true;"';
@@ -2811,12 +3110,6 @@
 	    '<input type="checkbox" name="newp_setparmval" /></td>'.
 	    &Apache::loncommon::end_data_table_row()."\n";
     }
-    my %lt=&Apache::lonlocal::texthash(
-		    'par'   => 'Parameter',
-		    'val'   => 'Value',
-		    'set'   => 'Set?',
-		    'sav'   => 'Save'
-				       );
 
     my $Parameter=&mt('Parameter');
     my $Value=&mt('Value');
@@ -2849,6 +3142,8 @@
 $breadcrumbs
 <form method="post" action="/adm/parmset?action=crsenv" name="envform">
 $setoutput
+$output_SB
+<hr class="LC_edit_problem_divide" />
 <div><input type="submit" name="crsenv" value="$lt{'sav'}" /></div>
 $start_table
 $start_header_row

--bisitz1238428646--