--- loncom/interface/lonparmset.pm 2009/10/23 18:16:24 1.473 +++ loncom/interface/lonparmset.pm 2012/10/04 13:41:10 1.527 @@ -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.527 2012/10/04 13:41:10 bisitz Exp $ # # Copyright Michigan State University Board of Trustees # @@ -137,33 +137,41 @@ javascript function 'pjump'. =item extractResourceInformation() : -Given the course data hash, extractResourceInformation extracts lots of information about the course's resources into a variety of hashes. + extractResourceInformation extracts lots of information about all of the the course's resources into a variety of hashes. Input: See list below: -=item * B : An array that will contain all of the ids in the course. +=item * B : Current username -=item * B : hash, id->type, where "type" contains the extension of the file, thus, I. +=item * B : Domain of current user. -=item * B : hash, id->key list, will contain a comma separated list of the meta-data keys available for the given id +=item * b : hash, name of parameter->display value (what is the display value?) +Outputs: See list below: -=item * B : hash, part identification->text representation of part, where the text representation is "[Part $part]" +=item * B (out) : An array that will contain all of the ids in the course. -=item * B : hash, full key to part->display value (what's display value?) +=item * B(out) : hash, id->type, where "type" contains the extension of the file, thus, I. -=item * B : hash, ??? +=item * B (out) : hash, id->key list, will contain a comma separated list of the meta-data keys available for the given id -=item * B : ??? +=item * B (out) : hash, name of parameter->display value (what is the display value?) -=item * B : hash, ??? +=item * B (out) : hash, part identification->text representation of part, where the text representation is "[Part $part]" + +=item * B (out) : hash, ??? =item * B : ?? =item * B : hash, id->full sym? +=item * B + +=item * B + +=item * B +=item * B =item isdateparm() @@ -196,8 +204,8 @@ Input: See list below: Show assessment data and parameters. This is a large routine that should be simplified and shortened... someday. -Inputs: $r - +Inputs: $r - the Apache request object. + Returns: nothing Variables used (guessed by Jeremy): @@ -248,37 +256,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 @@ -333,9 +310,31 @@ use Apache::lonlocal; use Apache::lonnavmaps; use Apache::longroup; use Apache::lonrss; +use HTML::Entities; use LONCAPA qw(:DEFAULT :match); +sub startSettingsScreen { + my ($r,$mode)=@_; + + $r->print("\n".''."\n"); + $r->print('
'); +} + +sub endSettingsScreen { + my ($r)=@_; + $r->print('
'); +} + + + sub parmval { my ($what,$id,$def,$uname,$udom,$csec,$cgroup,$courseopt)=@_; return &parmval_by_symb($what,&symbcache($id),$def,$uname,$udom,$csec, @@ -662,7 +661,7 @@ sub storeparm_by_symb { } sub log_parmset { - return &Apache::lonnet::instructor_log('parameterlog',@_); + return &Apache::lonnet::write_log('course','parameterlog',@_); } sub storeparm_by_symb_inner { @@ -814,6 +813,7 @@ sub valout { &date_sanity_info($value); } else { $result = $value; + $result=~s/\,/\, /gs; $result = &HTML::Entities::encode($result,'"<>&'); } } @@ -855,16 +855,10 @@ sub page_js { return(< // + $selscript ENDJS } + +sub showhide_js { + return <<"COURSECONTENTSCRIPT"; + +function showHide_courseContent() { + var parmlevValue=document.getElementById("parmlev").value; + if (parmlevValue == 'general') { + document.getElementById('mapmenu').style.display="none"; + } else { + if ((parmlevValue == "full") || (parmlevValue == "map")) { + document.getElementById('mapmenu').style.display =""; + } else { + document.getElementById('mapmenu').style.display="none"; + } + } + return; +} + +COURSECONTENTSCRIPT +} + sub startpage { - my ($r) = @_; + my ($r,$psymb) = @_; - my %loaditems = ('onunload' => "pclose()", - 'onload' => "group_or_section('cgroup')",); + my %loaditems = ( + 'onload' => "group_or_section('cgroup')", + ); + if (!$psymb) { + $loaditems{'onload'} = "showHide_courseContent(); group_or_section('cgroup'); resize_scrollbox('mapmenuscroll','1','1');"; + } if ((($env{'form.command'} eq 'set') && ($env{'form.url'}) && (!$env{'form.dis'})) || ($env{'form.symb'})) { @@ -914,20 +935,31 @@ sub startpage { text=>"Table Mode", help => 'Course_Setting_Parameters'}); } + my $js = &page_js().' + +'; my $start_page = - &Apache::loncommon::start_page('Set/Modify Course Parameters', - &page_js(), - {'add_entries' => \%loaditems,}); + &Apache::loncommon::start_page('Set/Modify Course Parameters',$js, + {'add_entries' => \%loaditems,}); my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs('Table Mode Parameter Setting','Table_Mode'); + my $escfilter=&Apache::lonhtmlcommon::entity_encode($env{'form.filter'}); + my $escpart=&Apache::lonhtmlcommon::entity_encode($env{'form.part'}); + $r->print($start_page.$breadcrumbs); + &startSettingsScreen($r,'parmset'); $r->print(< + + ENDHEAD } @@ -960,7 +992,7 @@ sub print_row { if ($parmlev eq 'full') { $r->print('' - .$$part{$which}.''); + .($$part{$which} eq '0'?'0 ('.&mt('default').')':$$part{$which}).''); } else { $parm=~s|\[.*\]\s||g; } @@ -1159,81 +1191,81 @@ 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 +1277,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)=@_; @@ -1267,14 +1300,12 @@ sub parmmenu { ele = document.forms.parmform.elements[i]; if (ele.name == checkName) { document.forms.parmform.elements[i].checked=value; - document.getElementById(document.forms.parmform.elements[i].value.concat(li)).style.display = displayOverview; } } } function checkthis(thisvalue, checkName) { - document.getElementById(thisvalue.concat("_li")).style.display = ""; for (i=0; i ENDSCRIPT - $r->print(&Apache::lonhtmlcommon::row_title(&mt('Select Parameters to View'))); - - #part to print selected parms overview - $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('>' - .($$allparms{$tempkey}=~/\S/ ? $$allparms{$tempkey} : $tempkey) - .'
  • ' - ); - } - $r->print('
' - .'

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

' - ); + $r->print('
'); &shortCuts($r,$allparms,$pscat,$keyorder); - - $r->print(&Apache::lonhtmlcommon::row_closure(1)); + $r->print('
'); } # return a hash sub categories { @@ -1396,10 +1390,13 @@ sub lookUpTableParameter { 'contentopen' => 'time_settings', 'contentclose' => 'time_settings', 'discussend' => 'time_settings', + 'printopendate' => 'time_settings', + 'printclosedate' => 'time_settings', 'weight' => 'grading', 'handgrade' => 'grading', 'maxtries' => 'tries', 'hinttries' => 'tries', + 'randomizeontries' => 'tries', 'type' => 'problem_appearance', 'problemstatus' => 'problem_appearance', 'display' => 'problem_appearance', @@ -1426,6 +1423,9 @@ sub lookUpTableParameter { 'acc' => 'misc', 'maxcollaborators' => 'misc', 'scoreformat' => 'misc', + 'lenient' => 'grading', + 'retrypartial' => 'tries', + 'discussvote' => 'misc', ); } @@ -1493,47 +1493,39 @@ sub parmboxes { 'slots' => [], 'file_submission' => [], 'misc' => [], - ); + ); + foreach $tempparameter (keys %$allparms) { &whatIsMyCategory($tempparameter, \%categoryList); } #part to print the parm-list - $r->print(''); + $r->print("\n"); } # # This function offers some links on the parameter section to get with one click a group a parameters @@ -1541,51 +1533,43 @@ 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 { my ($r,$allparts,$psprt)=@_; + my $selsize = 1+scalar(keys(%{$allparts})); + if ($selsize > 8) { + $selsize = 8; + } - $r->print(''); $r->print(''); @@ -1706,27 +1690,29 @@ function group_or_section(caller) { # 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'))); + my ($r,$allparms,$pscat,$psprt,$keyorder)=@_; + $r->print(&Apache::lonhtmlcommon::start_pick_box()); + $r->print(&Apache::lonhtmlcommon::row_title(&mt('Select Parameters to View'))); + &parmmenu($r,$allparms,$pscat,$keyorder); - $r->print(&Apache::lonhtmlcommon::end_pick_box()); + $r->print(&Apache::loncommon::start_scrollbox()); &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::loncommon::end_scrollbox()); + $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 +1754,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 maps and folders which have modifiable settings.') + .' '.&Apache::loncommon::help_open_topic('Parameter_Set_Folder') + .'
' + ); + + $r->print(&Apache::loncommon::start_scrollbox(undef,undef,undef,'mapmenuscroll')); + $r->print(&Apache::loncommon::start_data_table(undef,'mapmenuinner')); + + # Display row: "All Maps or Folders" + $r->print( + &Apache::loncommon::start_data_table_row(undef,'picklevel') + .'' + .'' + .'
' + .&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 +1824,45 @@ 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()); + + $r->print(&Apache::loncommon::end_data_table(). + '
'. + &Apache::loncommon::end_scrollbox()); } } +# 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('