[LON-CAPA-cvs] cvs: loncom /interface lonparmset.pm
bisitz
bisitz@source.lon-capa.org
Tue, 31 Mar 2009 17:04:16 -0000
This is a MIME encoded message
--bisitz1238519056
Content-Type: text/plain
bisitz Tue Mar 31 17:04:16 2009 EDT
Modified files:
/loncom/interface lonparmset.pm
Log:
Categories for Course Parameters:
- Category display order is sorted now
(Parameters in each category are already displayed sorted)
- Overview box: Corrected and added styles
- Moved "Create New Environment Variable" row to category with custom fields
- Empty categories aren't shown anymore
(currently applies to "cat_can" only, but works for all categories)
- Consistent Wording: Course Parameter Overview
- Added and updated some comments
- Deleted outdated code
(the old way of sorting the parameters,to display the old uncategorized parameter table, ...)
--bisitz1238519056
Content-Type: text/plain
Content-Disposition: attachment; filename="bisitz-20090331170416.txt"
Index: loncom/interface/lonparmset.pm
diff -u loncom/interface/lonparmset.pm:1.440 loncom/interface/lonparmset.pm:1.441
--- loncom/interface/lonparmset.pm:1.440 Tue Mar 31 14:08:20 2009
+++ loncom/interface/lonparmset.pm Tue Mar 31 17:04:15 2009
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Handler to set parameters for assessments
#
-# $Id: lonparmset.pm,v 1.440 2009/03/31 14:08:20 bisitz Exp $
+# $Id: lonparmset.pm,v 1.441 2009/03/31 17:04:15 bisitz Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -2498,9 +2498,6 @@
}
}
- my $start_table =&Apache::loncommon::start_data_table();
- my $start_header_row=&Apache::loncommon::start_data_table_header_row();
- my $end_header_row =&Apache::loncommon::end_data_table_header_row();
# ------------------------- Re-init course environment entries for this session
&Apache::lonnet::coursedescription($env{'request.course.id'},
@@ -2671,81 +2668,22 @@
);
-# 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
+ # Create parameter row 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>';
+ # Start Parameter Row
+ my $output = &Apache::loncommon::start_data_table_row();
+
+ # Column 1/3: Descriptive text of current parameter
+ $output .= '<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']"
@@ -2817,7 +2755,6 @@
40,
$onchange)
.'</td>';
-# -------------------------------
}
# Column 3/3: Check Box (in most cases)
@@ -2826,12 +2763,12 @@
.&Apache::lonhtmlcommon::checkbox($parameter.'_setparmval')
.'</td>';
}
+
+ # End Parameter Row
$output .= &Apache::loncommon::end_data_table_row();
return $output;
- }
-
-
+ } # End sub parameter_row
# Parameter Category Names
@@ -2848,7 +2785,22 @@
'cat_custom' => 'Parameter Category Custom',
);
+ # Display Order of Parameter Categories
+ my @Display_Order = (
+ 'cat_0',
+ 'cat_1',
+ 'cat_2',
+ 'cat_3',
+ 'cat_4',
+ 'cat_5',
+ 'cat_6',
+ 'cat_7',
+ 'cat_can',
+ 'cat_custom',
+ );
+
# Link Parameter Categories with Parameters
+ # Order of parameters is display order
my %parm_cat_parms = (
'cat_0' => [
'url',
@@ -2927,7 +2879,7 @@
}
$parm_cat_parms{'cat_can'} = [@can_cats];
- # Add custom parameters to parameter categories hash
+ # Add custom parameters to custom parameter category
my @custom_cats;
foreach my $parameter (sort(keys(%values))) {
unless (($parameter =~ m/^internal\./)||($parameter =~ m/^metadata\./) ||
@@ -2943,23 +2895,14 @@
$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
+# Display Course Parameter Overview
# Provide hyperlinks to detailed parameter settings
$output_SB .= '<a name="parmlist" />'
- .'<h2>'.&mt('Course Parameter Overview').'</h2>'
- .'<div class="LC_ContentBox">'
+ .'<div class="LC_ContentBoxSpecial">'
+ .'<h2 class="LC_hcell">'.&mt('Course Parameter Overview').'</h2>'
.'<ul>';
-foreach my $catkey (keys(%parm_cat_names)) {
+foreach my $catkey (@Display_Order) {
+ if (!@{$parm_cat_parms{$catkey}}) { next; } # Only display non-empty categories
$output_SB .= '<li>'
.'<a href="#parmlist_'.$catkey.'">'
.$parm_cat_names{$catkey}
@@ -2970,15 +2913,16 @@
.'</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>'
+ .'<br /><a href="#parmlist">'.&mt('Back to Course Parameter Overview').'</a>'
.'</div>';
+# Display all Parameters grouped by categories
$output_SB .= '<h2>'.&mt('Course Parameters').'</h2>';
-foreach my $catkey (keys(%parm_cat_names)) {
+foreach my $catkey (@Display_Order) {
+ if (!@{$parm_cat_parms{$catkey}}) { next; } # Only display non-empty categories
$output_SB .= &Apache::loncommon::start_data_table();
$output_SB .= &Apache::loncommon::start_data_table_empty_row()
.'<td colspan="3">'
@@ -2994,126 +2938,39 @@
my $description = $descriptions{$parameter};
$output_SB .= ¶meter_row($parameter, $description);
}
+ # Add special row to custom category
+ # Offer possibilty to create a new environment variable
+ if ($catkey eq 'cat_custom') {
+ my $onchange = 'onFocus="javascript:window.document.forms'
+ .'[\'envform\'].elements[\'newp_setparmval\']'
+ .'.checked=true;"';
+ $output_SB .= &Apache::loncommon::start_data_table_row()
+ .'<td>'
+ .'<i>'.&mt('Create New Environment Variable').'</i><br />'
+ .'<input type="text" size="40" name="newp_name" '.$onchange.' />'
+ .'</td><td>'
+ .'<input type="text" size="40" name="newp_value" '.$onchange.' />'
+ .'</td><td>'
+ .'<input type="checkbox" name="newp_setparmval" /></td>'
+ .&Apache::loncommon::end_data_table_row();
+ }
+ # Add buttons row at end of each category
$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;"';
- $output.=&Apache::loncommon::start_data_table_row().
- '<td><i>'.&mt('Create New Environment Variable').'</i><br />'.
- '<input type="text" size="40" name="newp_name" '.
- $onchange.' /></td><td>'.
- '<input type="text" size="40" name="newp_value" '.
- $onchange.' /></td><td>'.
- '<input type="checkbox" name="newp_setparmval" /></td>'.
- &Apache::loncommon::end_data_table_row()."\n";
- }
-
- my $Parameter=&mt('Parameter');
- my $Value=&mt('Value');
- my $Set=&mt('Set');
+ }
+
my ($jscript,$categorize_js);
my $browse_js = &Apache::loncommon::browser_and_searcher_javascript('parmset');
if ($can_categorize) {
@@ -3136,22 +2993,12 @@
$jscript);
my $end_page =
&Apache::loncommon::end_page();
- my $end_table=&Apache::loncommon::end_data_table();
$r->print(<<ENDENV);
$start_page
$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
-<th>$lt{'par'}</th><th>$lt{'val'}</th><th>$lt{'set'}</th>
-$end_header_row
-$output
-$end_table
-<input type="submit" name="crsenv" value="$lt{'sav'}" />
</form>
$end_page
ENDENV
--bisitz1238519056--