[LON-CAPA-cvs] cvs: loncom /interface lonparmset.pm
amueller
amueller@source.lon-capa.org
Wed, 01 Jul 2009 14:35:48 -0000
amueller Wed Jul 1 14:35:48 2009 EDT
Modified files:
/loncom/interface lonparmset.pm
Log:
First try in categorizing the displayed parameter on parmset screen.
Mostly is done by hand(configuration).
-sub categories defined the categories
-sub lookUpTableParameter works as a look up Table. I found almost 37
Parameters during runtime sessions with different courses as course coordinator.
If you find new parameter or if you want to define new parameter, you should put them
in this table. Otherwise they would be put under the 'misc' category.
-sub whatIsMyCategory: reassemble the list of parameters in the actual course in
categories by looking up in the look up table. The reassembling is only for the parameters
which are shown in the course. The Information for the parameters come from sub extractResourceInformation.
-sub keysindisplayorderCategory: new function thet help to produce the sorting order.
-Define of new program flow in sub parmboxes to use the new introduced datastructures and
subroutines.
Index: loncom/interface/lonparmset.pm
diff -u loncom/interface/lonparmset.pm:1.464 loncom/interface/lonparmset.pm:1.465
--- loncom/interface/lonparmset.pm:1.464 Tue Jun 30 14:59:17 2009
+++ loncom/interface/lonparmset.pm Wed Jul 1 14:35:47 2009
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Handler to set parameters for assessments
#
-# $Id: lonparmset.pm,v 1.464 2009/06/30 14:59:17 bisitz Exp $
+# $Id: lonparmset.pm,v 1.465 2009/07/01 14:35:47 amueller Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -1368,42 +1368,151 @@
$r->print(&Apache::lonhtmlcommon::row_closure(1));
}
+# return a hash
+sub categories {
+ return ('time_settings' => 'Time Settings',
+ 'grading' => 'Grading',
+ 'tries' => 'Tries',
+ 'problem_appearance' => 'Problem Appearance',
+ 'behaviour_of_input_fields' => 'Behaviour of Input Fields',
+ 'hiding' => 'Hiding',
+ 'high_level_randomization' => 'High Level Randomization',
+ 'slots' => 'Slots',
+ 'file_submission' => 'File Submission',
+ 'misc' => 'Miscellaneous' );
+}
+
+# return a hash. Like a look-up table
+sub lookUpTableParameter {
+
+ return (
+ 'opendate' => 'time_settings',
+ 'duedate' => 'time_settings',
+ 'answerdate' => 'time_settings',
+ 'interval' => 'time_settings',
+ 'contentopen' => 'time_settings',
+ 'contentclose' => 'time_settings',
+ 'discussend' => 'time_settings',
+ 'weight' => 'grading',
+ 'handgrade' => 'grading',
+ 'maxtries' => 'tries',
+ 'hinttries' => 'tries',
+ 'type' => 'problem_appearance',
+ 'problemstatus' => 'problem_appearance',
+ 'display' => 'problem_appearance',
+ 'ordered' => 'problem_appearance',
+ 'numbubbles' => 'problem_appearance',
+ 'tol' => 'behaviour_of_input_fields',
+ 'sig' => 'behaviour_of_input_fields',
+ 'turnoffunit' => 'behaviour_of_input_fields',
+ 'hiddenresource' => 'hiding',
+ 'hiddenparts' => 'hiding',
+ 'discusshide' => 'hiding',
+ 'buttonshide' => 'hiding',
+ 'turnoffeditor' => 'hiding',
+ 'encrypturl' => 'hiding',
+ 'randomorder' => 'high_level_randomization',
+ 'randompick' => 'high_level_randomization',
+ 'available' => 'slots',
+ 'useslots' => 'slots',
+ 'availablestudent' => 'slots',
+ 'uploadedfiletypes' => 'file_submission',
+ 'maxfilesize' => 'file_submission',
+ 'cssfile' => 'misc',
+ 'mapalias' => 'misc',
+ 'acc' => 'misc',
+ 'maxcollaborators' => 'misc',
+ 'scoreformat' => 'misc',
+
+ );
+}
+
+sub whatIsMyCategory {
+ my $name = shift;
+ my $catList = shift;
+ my @list;
+ my %lookUpList = &lookUpTableParameter; #Initilize the lookupList
+ my $cat = $lookUpList{$name};
+ if (defined($cat)) {
+ if (!defined($$catList{$cat})){
+ push @list, ($name);
+ $$catList{$cat} = \@list;
+ } else {
+ push @{${$catList}{$cat}}, ($name);
+ }
+ } else {
+ if (!defined($$catList{'misc'})){
+ push @list, ($name);
+ $$catList{'misc'} = \@list;
+ } else {
+ push @{${$catList}{'misc'}}, ($name);
+ }
+ }
+}
+
+sub keysindisplayorderCategory {
+ my ($name,$keyorder)=@_;
+ return sort {
+ $$keyorder{'parameter_0_'.$a} <=> $$keyorder{'parameter_0_'.$b};
+ } ( @{$name});
+}
+
sub parmboxes {
my ($r,$allparms,$pscat,$keyorder)=@_;
my $tempkey;
+ my $tempparameter;
+ my %categories = &categories;
+ my %categoryList = (
+ 'time_settings' => [],
+ 'grading' => [],
+ 'tries' => [],
+ 'problem_appearance' => [],
+ 'behaviour_of_input_fields' => [],
+ 'hiding' => [],
+ 'high_level_randomization' => [],
+ 'slots' => [],
+ 'file_submission' => [],
+ 'misc' => [],
+ );
+ foreach $tempparameter (keys %$allparms) {
+ &whatIsMyCategory($tempparameter, \%categoryList);
+ }
#part to print the parm-list
$r->print('<fieldset id="LC_parm_overview_parm_menu" style="display:none">'
.'<legend>'.&mt('Parameter').'</legend>'
."\n"
.'<table>'
);
- my $cnt=0;
- $r->print('<tr>');
- foreach $tempkey (&keysindisplayorder($allparms,$keyorder)) {
- $r->print("\n".'<td><label><input type="checkbox" name="pscat" ');
- $r->print('value="'.$tempkey.'" ');
- $r->print('onclick="checkboxChecked(\''.$tempkey.'\')"');
- if ($$pscat[0] eq "all" || grep $_ eq $tempkey, @{$pscat}) {
- $r->print(' checked="checked"');
- }
- $r->print(' />'.($$allparms{$tempkey}=~/\S/ ? $$allparms{$tempkey}
- : $tempkey)
- .'</label></td>');
- $cnt++;
- if ($cnt==4) {
- $r->print("</tr>\n<tr>");
- $cnt=0;
- }
- }
- $r->print('</tr>'
- .'</table>'
- .'<hr />'
- .'<a href="javascript:hideParms()">'
- .&mt('Hide')
- .'</a>'
+ #Print parameters
+ my ($category, $list) = undef;
+ while (($category, $list) = each %categoryList) {
+ if(@$list == 0) {
+ next;
+ } else {
+ $r->print('<tr>');
+ $r->print('<td><b>' .&mt($categories{$category}).'</b></td> </tr> <tr>');
+ foreach $tempkey (&keysindisplayorderCategory($list,$keyorder)) {
+ $r->print("\n".'<td><label><input type="checkbox" name="pscat" ');
+ $r->print('value="'.$tempkey.'" ');
+ $r->print('onclick="checkboxChecked(\''.$tempkey.'\')"');
+ if ($$pscat[0] eq "all" || grep $_ eq $tempkey, @{$pscat}) {
+ $r->print(' checked="checked"');
+ }
+ $r->print(' />'.($$allparms{$tempkey}=~/\S/ ? $$allparms{$tempkey}
+ : $tempkey)
+ .'</label></td>');
+ }
+ $r->print('</tr>');
+ }
+ }
+ $r->print( '</table>'
+ .'<hr />'
+ .'<a href="javascript:hideParms()">'
+ .&mt('Hide')
+ .'</a>'
);
#&shortCuts($r,$allparms,$pscat,$keyorder);