--- loncom/interface/lonparmset.pm 2009/10/23 18:16:24 1.473 +++ loncom/interface/lonparmset.pm 2010/12/24 16:48:46 1.505 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Handler to set parameters for assessments # -# $Id: lonparmset.pm,v 1.473 2009/10/23 18:16:24 amueller Exp $ +# $Id: lonparmset.pm,v 1.505 2010/12/24 16:48:46 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -248,37 +248,6 @@ Variables used (guessed by Jeremy): =item parse_key() -=item check_cloners() : - -Checks if new users included in list of allowed cloners -are valid users. Replaces supplied list with -cleaned list containing only users with valid usernames -and domains. - -Inputs: $clonelist, $oldcloner -where $clonelist is ref to array of requested cloners, -and $oldcloner is ref to array of currently allowed -cloners. - -Returns: string - comma separated list of requested -cloners (username:domain) who do not exist in system. - -=item change_clone() : - -Modifies the list of courses a user can clone (stored -in the user's environment.db file), called when a -change is made to the list of users allowed to clone -a course. - -Inputs: $action,$cloner -where $action is add or drop, and $cloner is identity of -user for whom cloning ability is to be changed in course. - - -=item check_cloners() - -=item change_clone() - =item header() Output html header for page @@ -903,7 +872,8 @@ sub startpage { my ($r) = @_; my %loaditems = ('onunload' => "pclose()", - 'onload' => "group_or_section('cgroup')",); + 'onload' => "showHide_courseContent(); group_or_section('cgroup')", + ); if ((($env{'form.command'} eq 'set') && ($env{'form.url'}) && (!$env{'form.dis'})) || ($env{'form.symb'})) { @@ -1159,81 +1129,80 @@ sub extractResourceInformation { my $navmap = Apache::lonnavmaps::navmap->new(); my @allres=$navmap->retrieveResources(undef,undef,1,undef,1); foreach my $resource (@allres) { - my $id=$resource->id(); + my $id=$resource->id(); my ($mapid,$resid)=split(/\./,$id); - if ($mapid eq '0') { next; } - $$ids[$#$ids+1]=$id; - my $srcf=$resource->src(); - $srcf=~/\.(\w+)$/; - $$typep{$id}=$1; - $$keyp{$id}=''; + if ($mapid eq '0') { next; } + $$ids[$#$ids+1]=$id; + my $srcf=$resource->src(); + $srcf=~/\.(\w+)$/; + $$typep{$id}=$1; + $$keyp{$id}=''; $$uris{$id}=$srcf; - foreach my $key (split(/\,/,&Apache::lonnet::metadata($srcf,'allpossiblekeys'))) { - next if ($key!~/^parameter_/); + foreach my $key (split(/\,/,&Apache::lonnet::metadata($srcf,'allpossiblekeys'))) { + next if ($key!~/^parameter_/); # Hidden parameters - next if (&Apache::lonnet::metadata($srcf,$key.'.hidden') eq 'parm'); + next if (&Apache::lonnet::metadata($srcf,$key.'.hidden') eq 'parm'); # # allparms is a hash of parameter names # - my $name=&Apache::lonnet::metadata($srcf,$key.'.name'); - if (!exists($$allparms{$name}) || $$allparms{$name} =~ m/^\s*$/ ) { - my ($display,$parmdis); - $display = &standard_parameter_names($name); - if ($display eq '') { - $display= &Apache::lonnet::metadata($srcf,$key.'.display'); - $parmdis = $display; - $parmdis =~ s/\s*\[Part.*$//g; - } else { - $parmdis = &mt($display); - } - $$allparms{$name}=$parmdis; - if (ref($defkeytype)) { - $$defkeytype{$name}= - &Apache::lonnet::metadata($srcf,$key.'.type'); - } - } + my $name=&Apache::lonnet::metadata($srcf,$key.'.name'); + if (!exists($$allparms{$name}) || $$allparms{$name} =~ m/^\s*$/ ) { + my ($display,$parmdis); + $display = &standard_parameter_names($name); + if ($display eq '') { + $display= &Apache::lonnet::metadata($srcf,$key.'.display'); + $parmdis = $display; + $parmdis =~ s/\s*\[Part.*$//g; + } else { + $parmdis = &mt($display); + } + $$allparms{$name}=$parmdis; + if (ref($defkeytype)) { + $$defkeytype{$name}= + &Apache::lonnet::metadata($srcf,$key.'.type'); + } + } # # allparts is a hash of all parts # - my $part= &Apache::lonnet::metadata($srcf,$key.'.part'); - $$allparts{$part} = &mt('Part: [_1]',$part); + my $part= &Apache::lonnet::metadata($srcf,$key.'.part'); + $$allparts{$part} = &mt('Part: [_1]',$part); # # Remember all keys going with this resource # - if ($$keyp{$id}) { - $$keyp{$id}.=','.$key; - } else { - $$keyp{$id}=$key; - } + if ($$keyp{$id}) { + $$keyp{$id}.=','.$key; + } else { + $$keyp{$id}=$key; + } # # Put in order # - unless ($$keyorder{$key}) { - $$keyorder{$key}=$keyordercnt; - $keyordercnt++; + unless ($$keyorder{$key}) { + $$keyorder{$key}=$keyordercnt; + $keyordercnt++; + } } - } - if (!exists($$mapp{$mapid})) { - $$mapp{$id}= - &Apache::lonnet::declutter($resource->enclosing_map_src()); - $$mapp{$mapid}=$$mapp{$id}; - $$allmaps{$mapid}=$$mapp{$id}; - if ($mapid eq '1') { - $$maptitles{$mapid}=&mt('Main Course Documents'); + if (!exists($$mapp{$mapid})) { + $$mapp{$id}= + &Apache::lonnet::declutter($resource->enclosing_map_src()); + $$mapp{$mapid}=$$mapp{$id}; + $$allmaps{$mapid}=$$mapp{$id}; + if ($mapid eq '1') { + $$maptitles{$mapid}=&mt('Main Course Documents'); + } else { + $$maptitles{$mapid}=&Apache::lonnet::gettitle($$mapp{$id}); + } + $$maptitles{$$mapp{$id}}=$$maptitles{$mapid}; + $$symbp{$mapid}=$$mapp{$id}.'___(all)'; } else { - $$maptitles{$mapid}= - &Apache::lonnet::gettitle($$mapp{$id}); + $$mapp{$id} = $$mapp{$mapid}; } - $$maptitles{$$mapp{$id}}=$$maptitles{$mapid}; - $$symbp{$mapid}=$$mapp{$id}.'___(all)'; - } else { - $$mapp{$id} = $$mapp{$mapid}; - } - $$symbp{$id}=&Apache::lonnet::encode_symb($$mapp{$id},$resid,$srcf); + $$symbp{$id}=&Apache::lonnet::encode_symb($$mapp{$id},$resid,$srcf); } } @@ -1245,8 +1214,9 @@ sub isdateparm { } # -# 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. +# parmmenu displays a list of the selected parameters. +# It also offers a link to show/hide the complete parameter list +# from which you can select all desired parameters. # sub parmmenu { my ($r,$allparms,$pscat,$keyorder)=@_; @@ -1321,6 +1291,8 @@ sub parmmenu { checkdates(); checkthis('weight','pscat'); checkthis('maxtries','pscat'); + checkthis('type','pscat'); + checkthis('problemstatus','pscat'); } function hideParms() { @@ -1350,7 +1322,7 @@ ENDSCRIPT $r->print(&mt('Selected Parameters:').'
'); #print out all possible parms and hide them by default - $r->print(''); + $r->print('
'); &shortCuts($r,$allparms,$pscat,$keyorder); + $r->print('
'); + + $r->print( + '

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

' + ); $r->print(&Apache::lonhtmlcommon::row_closure(1)); } @@ -1400,6 +1376,7 @@ sub lookUpTableParameter { 'handgrade' => 'grading', 'maxtries' => 'tries', 'hinttries' => 'tries', + 'randomizeontries' => 'tries', 'type' => 'problem_appearance', 'problemstatus' => 'problem_appearance', 'display' => 'problem_appearance', @@ -1493,13 +1470,24 @@ sub parmboxes { 'slots' => [], 'file_submission' => [], 'misc' => [], - ); + ); + my $hidelink = + '

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

' + ."\n"; +; foreach $tempparameter (keys %$allparms) { &whatIsMyCategory($tempparameter, \%categoryList); } #part to print the parm-list - $r->print(''); + $r->print( + "\n" + .$hidelink + ."\n" + ); } # # This function offers some links on the parameter section to get with one click a group a parameters @@ -1541,45 +1528,33 @@ sub parmboxes { sub shortCuts { my ($r,$allparms,$pscat,$keyorder)=@_; - #part to print out the shortcuts for parmselection - $r->print('' - .'' - .'' - .'
' - .'
'.&mt('Parameter Selection').'' - .'' - .'• '.&mt('Select All').'' - .'' - .'
' - .'' - .'• '.&mt('Select Common Only').'' - .'' - .'
' - .'' - .'• '.&mt('Unselect All').'' - .'' - .'
' - .'
' - .'
'.&mt('Add Selection for...').'' - .'' - .'• '.&mt('Problem Dates').'' - .'' - .'' - .' • '.&mt('Content Dates').'' - .'' -# .'
' - .'' - .' • '.&mt('Discussion Settings').'' - .'' - .'' - .' • '.&mt('Visibilities').'' - .'' -# .'
' - .'' - .' • '.&mt('Part Parameters').'' - .'' - .'
' - .'
'); + # Parameter Selection + $r->print( + &Apache::lonhtmlcommon::start_funclist(&mt('Parameter Selection')) + .&Apache::lonhtmlcommon::add_item_funclist( + ''.&mt('Select All').'') + .&Apache::lonhtmlcommon::add_item_funclist( + ''.&mt('Select Common Only').'') + .&Apache::lonhtmlcommon::add_item_funclist( + ''.&mt('Unselect All').'') + .&Apache::lonhtmlcommon::end_funclist() + ); + + # Add Selection for... + $r->print( + &Apache::lonhtmlcommon::start_funclist(&mt('Add Selection for...')) + .&Apache::lonhtmlcommon::add_item_funclist( + ''.&mt('Problem Dates').'') + .&Apache::lonhtmlcommon::add_item_funclist( + ''.&mt('Content Dates').'') + .&Apache::lonhtmlcommon::add_item_funclist( + ''.&mt('Discussion Settings').'') + .&Apache::lonhtmlcommon::add_item_funclist( + ''.&mt('Visibilities').'') + .&Apache::lonhtmlcommon::add_item_funclist( + ''.&mt('Part Parameters').'') + .&Apache::lonhtmlcommon::end_funclist() + ); } sub partmenu { @@ -1707,26 +1682,20 @@ function group_or_section(caller) { # sub displaymenu { my ($r,$allparms,$allparts,$pscat,$psprt,$keyorder)=@_; - $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::end_pick_box()); &parmboxes($r,$allparms,$pscat,$keyorder); - $r->print(&Apache::lonhtmlcommon::start_pick_box()); - $r->print(&Apache::lonhtmlcommon::row_title(&mt('Select Parts to View'))); - &partmenu($r,$allparts,$psprt); - $r->print(&Apache::lonhtmlcommon::row_closure(1)); - $r->print(&Apache::lonhtmlcommon::end_pick_box()); } sub mapmenu { - my ($r,$allmaps,$pschp,$maptitles, $symbp)=@_; + 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 $it=$navmap->getIterator(undef,undef,undef,1,1,undef); my $curRes; my $depth = 0; my %parent = (); @@ -1768,38 +1737,61 @@ sub mapmenu { } } # Show it ... - $r->print(&Apache::lonhtmlcommon::row_title(&mt('Select Enclosing Map or Folder'))); + $r->print(&Apache::lonhtmlcommon::row_title(&mt('Select Enclosing Map or Folder'),'','',' id="mapmenu"')); if ((ref($tree) eq 'ARRAY') && (ref($treeinfo) eq 'HASH')) { my $icon = ''; - $r->print(&Apache::loncommon::start_data_table() - .&Apache::loncommon::start_data_table_row() - .''.$icon - .'' - .&Apache::loncommon::end_data_table_row() + my $whitespace = + ''; + + # Info about selectable folders/maps + $r->print( + '
' + .&mt('You can only select those maps and folders which can be currently parameterized.') + # .' '.&Apache::loncommon::help_open_topic('...') # Later: Add further help + .'
' ); - my $whitespace = ''; + + + $r->print(&Apache::loncommon::start_data_table()); + + # Display row: "All Maps or Folders" + $r->print( + &Apache::loncommon::start_data_table_row() + .'' + .'' + .'
' + .&Apache::loncommon::end_data_table_row() + ); + + # Display row: "Main Course Documents" if (exists($$allmaps{1})) { - $r->print(&Apache::loncommon::start_data_table_row() - .''.$icon - .'' + .'' + .&Apache::loncommon::end_data_table_row() ); } + + # Display rows for all course maps and folders foreach my $id (@{$tree}) { my ($mapid,$resid)=split(/\./,$id); # Indentation @@ -1815,31 +1807,43 @@ sub mapmenu { 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()); } } +# Build up the select Box to choose if your parameter specification should work for the resource, map/folder or the course level +# The value of default selection in the select box is set by the value that is given by the argument in $parmlev. sub levelmenu { my ($r,$alllevs,$parmlev)=@_; $r->print(&Apache::lonhtmlcommon::row_title(&mt('Select Parameter Level').&Apache::loncommon::help_open_topic('Course_Parameter_Levels'))); - $r->print(''); foreach (reverse sort keys %{$alllevs}) { $r->print('