--- loncom/interface/lonparmset.pm 2009/06/08 18:04:45 1.456 +++ loncom/interface/lonparmset.pm 2009/07/31 16:09:03 1.468 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Handler to set parameters for assessments # -# $Id: lonparmset.pm,v 1.456 2009/06/08 18:04:45 bisitz Exp $ +# $Id: lonparmset.pm,v 1.468 2009/07/31 16:09:03 amueller Exp $ # # Copyright Michigan State University Board of Trustees # @@ -1244,6 +1244,10 @@ sub isdateparm { return (($type=~/^date/) && (!($type eq 'date_interval'))); } +# +# This function prints a list of parameters, which were selected. It also display a link from which you can +# hide or show the complete parameter list, from which you can choose your parameters. +# sub parmmenu { my ($r,$allparms,$pscat,$keyorder)=@_; my $tempkey; @@ -1269,7 +1273,9 @@ sub parmmenu { } function checkthis(thisvalue, checkName) { - checkboxChecked(thisvalue); + + document.getElementById(thisvalue.concat("_li")).style.display = ""; + for (i=0; iprint(' style="display:none"'); } $r->print('>' - .($$allparms{$tempkey}=~/\s/ ? $$allparms{$tempkey} : $tempkey) + .($$allparms{$tempkey}=~/\S/ ? $$allparms{$tempkey} : $tempkey) .'' ); } @@ -1366,39 +1371,162 @@ ENDSCRIPT $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 category_order { + return ( + 'time_settings' => 1, + 'grading' => 2, + 'tries' => 3, + 'problem_appearance' => 4, + 'hiding' => 5, + 'behaviour_of_input_fields' => 6, + 'high_level_randomization' => 7, + 'slots' => 8, + 'file_submission' => 9, + 'misc' => 10 + ); + +} sub parmboxes { my ($r,$allparms,$pscat,$keyorder)=@_; my $tempkey; - + my $tempparameter; + my %categories = &categories; + my %category_order = &category_order(); + 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(''); } +# +# This function offers some links on the parameter section to get with one click a group a parameters +# sub shortCuts { my ($r,$allparms,$pscat,$keyorder)=@_; @@ -1571,6 +1702,9 @@ function group_or_section(caller) { ,$chooseopt)); } +# +# This function shows on table Mode the available Parameters for the selected Resources +# sub displaymenu { my ($r,$allparms,$allparts,$pscat,$psprt,$keyorder)=@_; $r->print(&Apache::lonhtmlcommon::topic_bar (2,&mt('Select Parameters'))); @@ -1586,18 +1720,119 @@ sub displaymenu { } sub mapmenu { - my ($r,$allmaps,$pschp,$maptitles)=@_; - + my ($r,$allmaps,$pschp,$maptitles, $symbp)=@_; + my %allmaps_inverted = reverse %$allmaps; + my $navmap = Apache::lonnavmaps::navmap->new(); + my $tree=[]; + my $treeinfo={}; + if (defined($navmap)) { + my $it=$navmap->getIterator(undef,undef,undef,1,undef,undef); + my $curRes; + my $depth = 0; + my %parent = (); + my $startcount = 5; + my $lastcontainer = $startcount; +# preparing what is to show ... + while ($curRes = $it->next()) { + if ($curRes == $it->BEGIN_MAP()) { + $depth++; + $parent{$depth}= $lastcontainer; + } + if ($curRes == $it->END_MAP()) { + $depth--; + $lastcontainer = $parent{$depth}; + } + if (ref($curRes)) { + my $symb = $curRes->symb(); + my $ressymb = $symb; + if (($curRes->is_sequence()) || ($curRes->is_page())) { + my $type = 'sequence'; + if ($curRes->is_page()) { + $type = 'page'; + } + my $id= $curRes->id(); + my $srcf = $curRes->src(); + my $resource_name = &Apache::lonnet::gettitle($srcf); + if(!exists($treeinfo->{$id})) { + push(@$tree,$id); + my $enclosing_map_folder = &Apache::lonnet::declutter($curRes->enclosing_map_src()); + $treeinfo->{$id} = { + depth => $depth, + type => $type, + name => $resource_name, + enclosing_map_folder => $enclosing_map_folder, + }; + } + } + } + } + } +# Show it ... $r->print(&Apache::lonhtmlcommon::row_title(&mt('Select Enclosing Map or Folder'))); - $r->print('' + .&mt('All Maps or Folders') + .'' + .&Apache::loncommon::end_data_table_row() + ); + my $whitespace = ''; + if (exists($$allmaps{1})) { + $r->print(&Apache::loncommon::start_data_table_row() + .''.$icon + .'' + .'' + .&Apache::loncommon::end_data_table_row() + ); + } + foreach my $id (@{$tree}) { + my ($mapid,$resid)=split(/\./,$id); + # Indentation + my $depth = $treeinfo->{$id}->{'depth'}; + my $indent; + for (my $i = 0; $i < $depth; $i++) { + $indent.= $whitespace; + } + $icon = ''; + if ($treeinfo->{$id}->{'type'} eq 'page') { + $icon = ''; + } + my $symb_name = $$symbp{$id}; + my ($front, $tail) = split (/___${resid}___/, $symb_name); + $symb_name = $tail; + $r->print(&Apache::loncommon::start_data_table_row() + .''.$indent.$icon + .'' + .'' + .&Apache::loncommon::end_data_table_row() + ); + } + $r->print(&Apache::loncommon::end_data_table()); } - $r->print(""); - } sub levelmenu { @@ -1777,6 +2012,7 @@ sub assessparms { } else { $udom=$r->dir_config('lonDefDomain'); } + my @pscat=&Apache::loncommon::get_env_multiple('form.pscat'); my $pschp=$env{'form.pschp'}; @@ -1918,7 +2154,10 @@ sub assessparms { $uname,$udom,$csec,$cgroup); } # ---------------------------------------------------------------- Done storing - $message.='

'.&mt('Changes can take up to 10 minutes before being active for all students.').&Apache::loncommon::help_open_topic('Caching').'

'; + $message.='

' + .&mt('Changes can take up to 10 minutes before being active for all students.') + .&Apache::loncommon::help_open_topic('Caching') + .'

'; } #----------------------------------------------- if all selected, fill in array if ($pscat[0] eq "all") {@pscat = (keys %allparms);} @@ -1935,6 +2174,27 @@ sub assessparms { '" name="recent_'.$_.'" />'); } + # ----- Start Parameter Selection + + # Hide parm selection? + $r->print(< +// + +ENDPARMSELSCRIPT + my $parmselhiddenstyle=' style="display:none"'; + if($env{'form.hideparmsel'} eq 'hidden') { + $r->print('
'); + } else { + $r->print('
'); + } + + # Display Unit 1 "General Parameters" if (!$pssymb) { $r->print(&Apache::lonhtmlcommon::topic_bar (1,&mt('General Parameters'))); $r->print(&Apache::lonhtmlcommon::start_pick_box()); @@ -1943,12 +2203,12 @@ sub assessparms { if ($parmlev ne 'general') { $r->print(&Apache::lonhtmlcommon::row_closure()); - &mapmenu($r,\%allmaps,$pschp,\%maptitles); + &mapmenu($r,\%allmaps,$pschp,\%maptitles, \%symbp); } $r->print(&Apache::lonhtmlcommon::row_closure(1)); $r->print(&Apache::lonhtmlcommon::end_pick_box()); - + #Display Unit 2 "Select Parameter" &displaymenu($r,\%allparms,\%allparts,\@pscat,\@psprt,\%keyorder); } else { my ($map,$id,$resource)=&Apache::lonnet::decode_symb($pssymb); @@ -1964,10 +2224,31 @@ sub assessparms { $r->print(&Apache::lonhtmlcommon::row_closure(1)); $r->print(&Apache::lonhtmlcommon::end_pick_box()); + # parm selection is shown: display parm update button + $r->print('

' + .'' + .'' + .'

' + ); + + $r->print('
'); + # ----- End Parameter Selection + + # Offer link to display parameter selection again + $r->print(''); - $r->print('

'.$message.'

'); + # Display Messages + $r->print('
'.$message.'
'); - $r->print('
'); my @temp_pscat; map {