--- loncom/interface/lonparmset.pm 2009/06/03 17:17:03 1.453 +++ loncom/interface/lonparmset.pm 2009/07/01 14:35:47 1.465 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Handler to set parameters for assessments # -# $Id: lonparmset.pm,v 1.453 2009/06/03 17:17:03 schualex Exp $ +# $Id: lonparmset.pm,v 1.465 2009/07/01 14:35:47 amueller Exp $ # # Copyright Michigan State University Board of Trustees # @@ -854,7 +854,7 @@ sub page_js { return(< - +// $selscript ENDJS @@ -1248,6 +1249,7 @@ sub parmmenu { my $tempkey; $r->print(< +// ENDSCRIPT - $r->print(); $r->print(&Apache::lonhtmlcommon::row_title(&mt('Select Parameters to View'))); #part to print selected parms overview - $r->print('' - .'' - .''); - $r->print(''); - $r->print('' - .'

'.&mt('Selected Parameters').': '); - - #print out all possible parms and hide it - $r->print('

'); - $r->print('
    '); + $r->print(&mt('Selected Parameters:').'
    '); + + #print out all possible parms and hide them by default + $r->print('
      '); foreach $tempkey (&keysindisplayorder($allparms,$keyorder)) { $r->print('
    • print('style="display:none"'); + $r->print(' style="display:none"'); } - - $r->print('>'.($$allparms{$tempkey}=~/\s/ ? $$allparms{$tempkey} : $tempkey).'
    • '); - } - $r->print('('.&mt('add more parameter').')' - .'

'); + $r->print('>' + .($$allparms{$tempkey}=~/\S/ ? $$allparms{$tempkey} : $tempkey) + .'' + ); + } + $r->print('' + .'

' + .&mt('Show detailed Parameter Selection') + .'

' + ); &shortCuts($r,$allparms,$pscat,$keyorder); - $r->print(''); + $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('
'); + $r->print(''); } sub shortCuts { my ($r,$allparms,$pscat,$keyorder)=@_; @@ -1406,7 +1524,7 @@ sub shortCuts { #part to print out the shortcuts for parmselection $r->print('' .'' .'' + .&Apache::loncommon::end_data_table_row() + ); + my $whitespace = ''; + foreach my $mapid (@{$tree}) { + # Indentation + my $depth = $treeinfo->{$mapid}->{'depth'}; + my $indent; + for (my $i = 0; $i < $depth; $i++) { + $indent.= $whitespace; + } + $icon = ''; + if ($treeinfo->{$mapid}->{'type'} eq 'page') { + $icon = ''; + } + $r->print(&Apache::loncommon::start_data_table_row() + .'' + .&Apache::loncommon::end_data_table_row() + ); + } + $r->print(&Apache::loncommon::end_data_table()); } - $r->print(""); - } sub levelmenu { @@ -1908,7 +2097,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);} @@ -1925,6 +2117,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 parameter selection boxes if (!$pssymb) { $r->print(&Apache::lonhtmlcommon::topic_bar (1,&mt('General Parameters'))); $r->print(&Apache::lonhtmlcommon::start_pick_box()); @@ -1954,10 +2167,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 { @@ -2865,7 +3099,7 @@ ENDOVER #$r->print('
' - .'
'.&mt('Parameter Selection').'' + .'
'.&mt('Parameter Selection').'' .'' .'• '.&mt('Select All').'' .'' @@ -1421,7 +1539,7 @@ sub shortCuts { .'
' .'
' - .'
'.&mt('Add Selection for...').'' + .'
'.&mt('Add Selection for...').'' .'' .'• '.&mt('Problem Dates').'' .'' @@ -1500,6 +1618,7 @@ sub usermenu { $sections .= ' '.&mt('or').' '; $sections .= qq| |; } else { $sections .= qq| |; } @@ -1565,7 +1687,6 @@ sub displaymenu { $r->print(&Apache::lonhtmlcommon::topic_bar (2,&mt('Select Parameters'))); $r->print(&Apache::lonhtmlcommon::start_pick_box()); &parmmenu($r,$allparms,$pscat,$keyorder); - #$r->print(&Apache::lonhtmlcommon::row_closure()); $r->print(&Apache::lonhtmlcommon::end_pick_box()); &parmboxes($r,$allparms,$pscat,$keyorder); $r->print(&Apache::lonhtmlcommon::start_pick_box()); @@ -1577,17 +1698,85 @@ sub displaymenu { sub mapmenu { my ($r,$allmaps,$pschp,$maptitles)=@_; - + 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; + + while ($curRes = $it->next()) { + if ($curRes == $it->BEGIN_MAP()) { + $depth++; + } + if ($curRes == $it->END_MAP()) { + $depth--; + } + if (ref($curRes)) { + if (($curRes->is_sequence()) || ($curRes->is_page())) { + my $type = 'sequence'; + if ($curRes->is_page()) { + $type = 'page'; + } + my $id= $curRes->id(); + my ($mapid,$resid)=split(/\./,$id); + if(!exists($treeinfo->{$mapid})) { + push(@$tree,$mapid); + $treeinfo->{$mapid} = { + depth => $depth, + type => $type, + }; + } + } + } + } + } + $r->print(&Apache::lonhtmlcommon::row_title(&mt('Select Enclosing Map or Folder'))); - $r->print('
'.$icon + .''.$indent.$icon + .'' + .'
#
'); - $r->print('
'); + $r->print('
'); #$r->print('

Step 1

'); $r->print('
'); $r->print(&Apache::lonhtmlcommon::start_pick_box()); @@ -2883,11 +3117,10 @@ ENDOVER #$r->print(' #
'); - $r->print('
'); + $r->print('
'); $r->print('
'); $r->print(&Apache::lonhtmlcommon::start_pick_box()); &parmmenu($r,\%allparms,\@pscat,\%keyorder); - #$r->print(&Apache::lonhtmlcommon::row_closure()); $r->print(&Apache::lonhtmlcommon::end_pick_box()); &parmboxes($r,\%allparms,\@pscat,\%keyorder); $r->print(&Apache::lonhtmlcommon::start_pick_box()); @@ -2907,7 +3140,7 @@ ENDOVER $r->print(&Apache::lonhtmlcommon::end_pick_box()); $r->print('
'); - $r->print('
'); + $r->print('
'); $r->print('
'); my $sortorder=$env{'form.sortorder'}; unless ($sortorder) { $sortorder='realmstudent'; }