--- loncom/interface/lonparmset.pm 2008/07/01 01:35:28 1.403 +++ loncom/interface/lonparmset.pm 2008/12/03 21:20:57 1.418 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Handler to set parameters for assessments # -# $Id: lonparmset.pm,v 1.403 2008/07/01 01:35:28 raeburn Exp $ +# $Id: lonparmset.pm,v 1.418 2008/12/03 21:20:57 schafran Exp $ # # Copyright Michigan State University Board of Trustees # @@ -44,36 +44,11 @@ This module sets coursewide and assessme =head1 INTERNAL SUBROUTINES -=over 4 - -=cut - -################################################################### -################################################################### - -package Apache::lonparmset; - -use strict; -use Apache::lonnet; -use Apache::Constants qw(:common :http REDIRECT); -use Apache::lonhtmlcommon(); -use Apache::loncommon; -use GDBM_File; -use Apache::lonhomework; -use Apache::lonxml; -use Apache::lonlocal; -use Apache::lonnavmaps; -use Apache::longroup; -use Apache::lonrss; -use LONCAPA qw(:DEFAULT :match); - - -################################################## -################################################## +=over =pod -=item parmval +=item parmval() Figure out a cascading parameter. @@ -98,9 +73,282 @@ Returns: A list, the first item is the 2 - Map or Folder level for specific student 1 - resource level for specific student +=item parmval_by_symb() + +=item reset_caches() + +=item cacheparmhash() + +=item parmhash() + +=item symbcache() + +=item preset_defaults() + +=item date_sanity_info() + +=item storeparm() + +Store a parameter by symb + + Takes + - symb + - name of parameter + - level + - new value + - new type + - username + - userdomain + +=item log_parmset() + +=item storeparm_by_symb_inner() + +=item valout() + +Format a value for output. + +Inputs: $value, $type, $editable + +Returns: $value, formatted for output. If $type indicates it is a date, +localtime($value) is returned. +$editable will return an icon to click on + +=item plink() + +Produces a link anchor. + +Inputs: $type,$dis,$value,$marker,$return,$call + +Returns: scalar with html code for a link which will envoke the +javascript function 'pjump'. + +=item page_js() + +=item startpage() + +=item print_row() + +=item print_td() + +=item print_usergroups() + +=item parm_control_group() + +=item extractResourceInformation() : + +Given the course data hash, extractResourceInformation extracts lots of information about 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 : hash, id->type, where "type" contains the extension of the file, thus, I. + +=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?) + +=item * B : hash, part identification->text representation of part, where the text representation is "[Part $part]" + +=item * B : hash, full key to part->display value (what's display value?) + +=item * B : hash, ??? + +=item * B : ??? + +=item * B : hash, ??? + +=item * B : ?? + +=item * B : hash, id->full sym? + + + +=item isdateparm() + +=item parmmenu() + +=item partmenu() + +=item usermenu() + +=item displaymenu() + +=item mapmenu() + +=item levelmenu() + +=item sectionmenu() + +=item keysplit() + +=item keysinorder() + +=item keysinorder_bytype() + +=item keysindisplayorder() + +=item standardkeyorder() + +=item assessparms() : + +Show assessment data and parameters. This is a large routine that should +be simplified and shortened... someday. + +Inputs: $r + +Returns: nothing + +Variables used (guessed by Jeremy): + +=item * B: ParameterS CATegories? ends up a list of the types of parameters that exist, e.g., tol, weight, acc, opendate, duedate, answerdate, sig, maxtries, type. + +=item * B: ParameterS PaRTs? a list of the parts of a problem that we are displaying? Used to display only selected parts? + +=item * B<@catmarker> contains list of all possible parameters including part #s + +=item * B<$fullkeyp> contains the full part/id # for the extraction of proper parameters + +=item * B<$tempkeyp> contains part 0 only (no ids - ie, subparts) + When storing information, store as part 0 + When requesting information, request from full part + +=item crsenv() + +Show and set course data and parameters. This is a large routine that should +be simplified and shortened... someday. + +Inputs: $r + +Returns: nothing + +=item can_modify_catsettings() + +=item assign_course_categories() + +=item tablestart() + +=item tableend() + +=item extractuser() + +=item parse_listdata_key() + +=item listdata() + +=item date_interval_selector() + +=item get_date_interval_from_form() + +=item default_selector() + +=item string_selector() + +=item dateshift() + +=item newoverview() + +=item secgroup_lister() + +=item overview() + +=item clean_parameters() + +=item date_shift_one() + +=item date_shift_two() + +=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 + +=item print_main_menu() + +=item output_row() + +Set portfolio metadata + +=item order_meta_fields() + +=item addmetafield() + +=item setrestrictmeta() + +=item get_added_meta_fieldnames() + +=item get_deleted_meta_fieldnames() + +=item defaultsetter() + +=item components() + +=item load_parameter_names() + +=item parm_change_log() + +=item handler() : + +Main handler. Calls &assessparms and &crsenv subroutines. + + +=back + =cut -################################################## +################################################################### +################################################################### + +package Apache::lonparmset; + +use strict; +use Apache::lonnet; +use Apache::Constants qw(:common :http REDIRECT); +use Apache::lonhtmlcommon(); +use Apache::loncommon; +use GDBM_File; +use Apache::lonhomework; +use Apache::lonxml; +use Apache::lonlocal; +use Apache::lonnavmaps; +use Apache::longroup; +use Apache::lonrss; +use LONCAPA qw(:DEFAULT :match); + + sub parmval { my ($what,$id,$def,$uname,$udom,$csec,$cgroup,$courseopt)=@_; return &parmval_by_symb($what,&symbcache($id),$def,$uname,$udom,$csec, @@ -302,6 +550,8 @@ sub reset_caches { } } + + sub preset_defaults { my $type=shift; if (&rulescache($type.'_action') eq 'default') { @@ -316,7 +566,8 @@ sub preset_defaults { } } -################################################## + + sub date_sanity_info { my $checkdate=shift; @@ -325,14 +576,31 @@ sub date_sanity_info { my $crsprefix='course.'.$env{'request.course.id'}.'.'; if ($env{$crsprefix.'default_enrollment_end_date'}) { if ($checkdate>$env{$crsprefix.'default_enrollment_end_date'}) { - $result.='
'.&mt('After course enrollment end!'); + $result.='
' + .&mt('After course enrollment end!') + .'
'; } } if ($env{$crsprefix.'default_enrollment_start_date'}) { if ($checkdate<$env{$crsprefix.'default_enrollment_start_date'}) { - $result.='
'.&mt('Before course enrollment start!'); + $result.='
' + .&mt('Before course enrollment start!') + .'
'; } } +# Preparation for additional warnings about dates in the past/future. +# An improved, more context sensitive version is recommended, +# e.g. warn for due and answer dates which are defined before the corresponding open date, etc. +# if ($checkdate'; +# } +# if ($checkdate>time) { +# $result.='
' +# .'('.&mt('in the future').')' +# .'
'; +# } return $result; } ################################################## @@ -354,17 +622,6 @@ sub storeparm { &storeparm_by_symb(&symbcache($sresid),$spnam,$snum,$nval,$ntype,$uname,$udom,$csec,'',$cgroup); } -# -# Store a parameter by symb -# -# Takes -# - symb -# - name of parameter -# - level -# - new value -# - new type -# - username -# - userdomain my %recstack; sub storeparm_by_symb { my ($symb,$spnam,$snum,$nval,$ntype,$uname,$udom,$csec,$recflag,$cgroup)=@_; @@ -519,25 +776,7 @@ sub storeparm_by_symb_inner { return ''; } -################################################## -################################################## - -=pod - -=item valout - -Format a value for output. - -Inputs: $value, $type, $editable - -Returns: $value, formatted for output. If $type indicates it is a date, -localtime($value) is returned. -$editable will return an icon to click on -=cut - -################################################## -################################################## sub valout { my ($value,$type,$editable)=@_; my $result = ''; @@ -551,27 +790,38 @@ sub valout { } else { if ($type eq 'date_interval') { my ($sec,$min,$hour,$mday,$mon,$year)=gmtime($value); + my @timer; $year=$year-70; $mday--; if ($year) { - $result.=$year.' yrs '; +# $result.=&mt('[quant,_1,yr]',$year).' '; + push(@timer,&mt('[quant,_1,yr]',$year)); } if ($mon) { - $result.=$mon.' mths '; +# $result.=&mt('[quant,_1,mth]',$mon).' '; + push(@timer,&mt('[quant,_1,mth]',$mon)); } if ($mday) { - $result.=$mday.' days '; +# $result.=&mt('[quant,_1,day]',$mday).' '; + push(@timer,&mt('[quant,_1,day]',$mday)); } if ($hour) { - $result.=$hour.' hrs '; +# $result.=&mt('[quant,_1,hr]',$hour).' '; + push(@timer,&mt('[quant,_1,hr]',$hour)); } if ($min) { - $result.=$min.' mins '; +# $result.=&mt('[quant,_1,min]',$min).' '; + push(@timer,&mt('[quant,_1,min]',$min)); } if ($sec) { - $result.=$sec.' secs '; +# $result.=&mt('[quant,_1,sec]',$sec).' '; + push(@timer,&mt('[quant,_1,sec]',$sec)); } - $result=~s/\s+$//; +# $result=~s/\s+$//; + if (!@timer) { # Special case: all entries 0 -> display "0 secs" intead of empty field to keep this field editable + push(@timer,&mt('[quant,_1,sec]',0)); + } + $result.=join(", ",@timer); } elsif (&isdateparm($type)) { $result = &Apache::lonlocal::locallocaltime($value). &date_sanity_info($value); @@ -583,24 +833,7 @@ sub valout { return $result; } -################################################## -################################################## - -=pod - -=item plink - -Produces a link anchor. - -Inputs: $type,$dis,$value,$marker,$return,$call - -Returns: scalar with html code for a link which will envoke the -javascript function 'pjump'. -=cut - -################################################## -################################################## sub plink { my ($type,$dis,$value,$marker,$return,$call)=@_; my $winvalue=$value; @@ -683,6 +916,15 @@ sub startpage { my %loaditems = ('onunload' => "pclose()", 'onload' => "group_or_section('cgroup')",); + if ((($env{'form.command'} eq 'set') && ($env{'form.url'}) + && (!$env{'form.dis'})) || ($env{'form.symb'})) { + &Apache::lonhtmlcommon::add_breadcrumb({help=>'Problem_Parameters', + text=>"Problem Parameters"}); + } else { + &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=settable', + text=>"Table Mode", + help => 'Course_Setting_Parameters'}); + } my $start_page = &Apache::loncommon::start_page('Set/Modify Course Parameters', &page_js(), @@ -899,39 +1141,7 @@ sub parm_control_group { return($coursereply,$resultitem,$resultgroup,$resultlevel,$resulttype); } -=pod - -=item B: Given the course data hash, extractResourceInformation extracts lots of information about the course's resources into a variety of hashes. -Input: See list below: - -=over 4 - -=item B: An array that will contain all of the ids in the course. - -=item B: hash, id->type, where "type" contains the extension of the file, thus, I. - -=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?) - -=item B: hash, part identification->text representation of part, where the text representation is "[Part $part]" - -=item B: hash, full key to part->display value (what's display value?) - -=item B: hash, ??? - -=item B: ??? - -=item B: hash, ??? - -=item B: ?? - -=item B: hash, id->full sym? - -=back - -=cut sub extractResourceInformation { my $ids = shift; @@ -973,7 +1183,7 @@ sub extractResourceInformation { if (!exists($$allparms{$name}) || $$allparms{$name} =~ m/^\s*$/ ) { my $display= &Apache::lonnet::metadata($srcf,$key.'.display'); my $parmdis = $display; - $parmdis =~ s/\[Part.*$//g; + $parmdis =~ s/\s*\[Part.*$//g; $$allparms{$name}=$parmdis; if (ref($defkeytype)) { $$defkeytype{$name}= @@ -985,7 +1195,7 @@ sub extractResourceInformation { # allparts is a hash of all parts # my $part= &Apache::lonnet::metadata($srcf,$key.'.part'); - $$allparts{$part} = "Part: $part"; + $$allparts{$part} = &mt('Part: [_1]',$part); # # Remember all keys going with this resource # @@ -1025,8 +1235,6 @@ sub extractResourceInformation { } -################################################## -################################################## sub isdateparm { my $type=shift; @@ -1107,8 +1315,8 @@ ENDSCRIPT if ($$pscat[0] eq "all" || grep $_ eq $tempkey, @{$pscat}) { $r->print(' checked'); } - $r->print('>'.($$allparms{$tempkey}=~/\S/ ? $$allparms{$tempkey} - : $tempkey) + $r->print('>'.($$allparms{$tempkey}=~/\S/ ? &mt($$allparms{$tempkey}) + : &mt($tempkey)) .''); $cnt++; if ($cnt==3) { @@ -1116,21 +1324,46 @@ ENDSCRIPT $cnt=0; } } - $r->print(' - -Select All
-Select Common Only - -Add Problem Dates -Add Content Dates
-Add Discussion Settings -Add Visibilities
-Add Part Parameters - -Unselect All - -'); - $r->print(''); + $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').'' + .'' + .'
' + .'' + .'' + ); } sub partmenu { @@ -1160,21 +1393,18 @@ sub usermenu { my $chooseopt=&Apache::loncommon::select_dom_form($udom,'udom').' '. &Apache::loncommon::selectstudent_link('parmform','uname','udom'); my $selscript=&Apache::loncommon::studentbrowser_javascript(); - my %lt=&Apache::lonlocal::texthash( - 'se' => "Section", - 'gr' => "Group", - 'fu' => "For User", - 'oi' => "or ID", - 'ad' => "at Domain" - ); + my $sections=''; my %sectionhash = &Apache::loncommon::get_sections(); my $groups; my %grouphash = &Apache::longroup::coursegroups(); + my $g_s_header=''; + my $g_s_footer=''; + if (%sectionhash) { - $sections=$lt{'se'}.': print(< -$sections -$groups -
-$lt{'fu'} - -$lt{'oi'} - -$lt{'ad'} -$chooseopt - -ENDMENU + + if (%sectionhash || %grouphash) { + $g_s_header='
'.&mt('Group/Section').'
'; + $g_s_footer='
'; + } + + $r->print('' + .$g_s_header + .$sections + .$groups + .$g_s_footer + .'
'.&mt('User').'
' + .&mt('For User [_1] or Student/Employee ID [_2] at Domain [_3]' + ,'' + ,' ' + ,$chooseopt) + .'
' + .'
' + ); } sub displaymenu { @@ -1256,7 +1493,7 @@ sub displaymenu { $r->print('
'.&mt('Select Parameters to View').''. &mt('Select Parts to View').'
'); &parmmenu($r,$allparms,$pscat,$keyorder); - $r->print(''); + $r->print(''); &partmenu($r,$allparts,$psprt); $r->print('
'); } @@ -1398,36 +1635,7 @@ sub standardkeyorder { 'parameter_0_discusshide' => 20); } -################################################## -################################################## - -=pod - -=item assessparms - -Show assessment data and parameters. This is a large routine that should -be simplified and shortened... someday. - -Inputs: $r - -Returns: nothing - -Variables used (guessed by Jeremy): - -=over 4 -=item B: ParameterS CATegories? ends up a list of the types of parameters that exist, e.g., tol, weight, acc, opendate, duedate, answerdate, sig, maxtries, type. - -=item B: ParameterS PaRTs? a list of the parts of a problem that we are displaying? Used to display only selected parts? - -=item B: - -=back - -=cut - -################################################## -################################################## sub assessparms { my $r=shift; @@ -1899,7 +2107,7 @@ ENDTABLEHEADFOUR } $r->print('

' .&mt('Set Defaults for All Resources in [_1]Specifically for [_2][_3]' - ,$foldermap.'
$showtitle
' + ,$foldermap.'
'.$showtitle.'
' ,$tmp ,''.$coursename.'' ) @@ -2000,28 +2208,13 @@ ENDMAPONE } # end sub assessparms -################################################## -################################################## - -=pod - -=item crsenv - -Show and set course data and parameters. This is a large routine that should -be simplified and shortened... someday. -Inputs: $r - -Returns: nothing - -=cut - -################################################## -################################################## sub crsenv { my $r=shift; my $setoutput=''; + &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=crsenv', + text=>"Course Environment"}); my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs('Edit Course Environment'); my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'}; @@ -2126,6 +2319,8 @@ sub crsenv { $setoutput.=&mt('Set').' '.$name.' '.&mt('to').' '; if ($name =~ /^default_enrollment_(start|end)_date$/) { $setoutput .= &Apache::lonlocal::locallocaltime($value); + } elsif ($name eq 'categories') { + $setoutput .= $env{'form.categories_display'}; } else { $setoutput .= $value; } @@ -2355,6 +2550,8 @@ sub crsenv { 'categories' => ''.&mt('Categorize course').' '. &mt('Display Categories').'', + 'datelocale' + => ''.&mt('Locale used for course calendar').'', ); my @Display_Order = ('url','description','courseid','cloners'); (my $can_toggle_cat,$can_categorize) = &can_modify_catsettings($dom); @@ -2378,6 +2575,7 @@ sub crsenv { 'allow_discussion_post_editing', 'languages', 'timezone', + 'datelocale', 'nothideprivileged', 'rndseed', 'receiptalg', @@ -2399,7 +2597,9 @@ sub crsenv { 'disableexampointprint', 'task_messages','task_grading')); foreach my $parameter (sort(keys(%values))) { - unless (($parameter =~ m/^internal\./)||($parameter =~ m/^metadata\./)) { + unless (($parameter =~ m/^internal\./)||($parameter =~ m/^metadata\./) || + ($parameter =~ m/^selfenroll_/) || ($parameter =~ /_selfenroll$/) + || ($parameter eq 'type')) { if (! $descriptions{$parameter}) { $descriptions{$parameter}=$parameter; push(@Display_Order,$parameter); @@ -2429,6 +2629,32 @@ sub crsenv { &Apache::loncommon::select_timezone($parameter.'_value', $timezone, $onchange,$includeempty).''; + } elsif ($parameter eq 'datelocale') { + my $includeempty = 1; + my $locale_obj = &Apache::lonlocal::getdatelocale(); + my $currdatelocale; + if (ref($locale_obj)) { + $currdatelocale = $locale_obj->id(); + } + $output .= ''. + &Apache::loncommon::select_datelocale($parameter.'_value', + $currdatelocale, + $onchange,$includeempty).''; + } elsif ($parameter eq 'categories') { + my $catdisplay; + if ($values{'categories'} ne '') { + my @curritems = split(/\&/,$values{'categories'}); + foreach my $item (@curritems) { + my ($name,$parent,$pos) = split(/:/,$item); + $catdisplay .= &unescape($name).'&'; + } + $catdisplay =~ s/\&$//; + } + $output .= ''. + ''. + ''; } else { $output .= ''. &Apache::lonhtmlcommon::textbox($parameter.'_value', @@ -2539,21 +2765,28 @@ sub assign_course_categories { function updateCategories() { var newcategories = ''; + var unescapedcats = ''; if (document.chgcats.usecategory.length) { for (var i=0; i 0) { newcategories = newcategories.slice(0,-1); } + if (unescapedcats.length > 0) { + unescapedcats = unescapedcats.slice(0,-3); + } } else { if (document.chgcats.usecategory.checked == true) { newcategories = document.chgcats.usecategory.value; + unescapedcats = document.chgcats.catname.value; } } opener.document.envform.categories_value.value = newcategories; + opener.document.envform.categories_display.value = unescapedcats; opener.document.envform.categories_setparmval.checked = true; alert("$alert"); self.close(); @@ -2881,8 +3114,8 @@ sub listdata { $$resourcedata{$thiskey}, '',1,'',''). ''. -(($$resourcedata{$thiskey}!=0)?''. -&mt('Shift all dates based on this date').'':''). +(($$resourcedata{$thiskey}!=0)?''. +&mt('Shift all dates based on this date').'':''). &date_sanity_info($$resourcedata{$thiskey}) ); } elsif ($thistype eq 'date_interval') { @@ -3018,6 +3251,8 @@ sub newoverview { my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'}; my $crs = $env{'course.'.$env{'request.course.id'}.'.num'}; + &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=setoverview', + text=>"Overview Mode"}); my $start_page = &Apache::loncommon::start_page('Set Parameters'); my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs('Overview'); $r->print(<'/adm/parmset?action=setoverview', + text=>"Overview Mode"}); my $start_page=&Apache::loncommon::start_page('Modify Parameters'); my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs('Overview'); $r->print(<'/adm/parmset?action=cleanparameters', + text=>"Clean Parameters"}); my $start_page=&Apache::loncommon::start_page('Clean Parameters'); my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs('Clean'); $r->print(<print('

'. &mt('These parameters refer to resources that do not exist.'). '

'. - ''.'
'. + ''.'
'. '
'); $r->print(&Apache::loncommon::start_data_table(). ''. @@ -3285,7 +3524,7 @@ ENDOVER } } $r->print(&Apache::loncommon::end_data_table().'

'. - ''. + ''. '

'. &Apache::loncommon::end_page()); } @@ -3295,6 +3534,8 @@ sub date_shift_one { my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'}; my $crs = $env{'course.'.$env{'request.course.id'}.'.num'}; + &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=dateshift1&timebase='.$env{'form.timebase'}, + text=>"Shifting Dates"}); my $start_page=&Apache::loncommon::start_page('Shift Dates'); my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs('Shift'); $r->print(<'/adm/parmset?action=dateshift1&timebase='.$env{'form.timebase'}, + text=>"Shifting Dates"}); my $start_page=&Apache::loncommon::start_page('Shift Dates'); my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs('Shift'); $r->print(<print(&header()); + $r->print(&Apache::lonhtmlcommon::breadcrumbs('Parameter Manager')); $r->print(< @@ -3556,86 +3756,87 @@ ENDMAINFORMHEAD my $vgr = &Apache::lonnet::allowed('vgr',$env{'request.course.id'}); my $mgr = &Apache::lonnet::allowed('mgr',$env{'request.course.id'}); + my @menu = - ( { divider=>'Settings for Your Course', - }, - { text => 'Set Course Environment', - action => 'crsenv', - permission => $parm_permission, - help => 'Course_Environment', - }, - { text => 'Set Portfolio Metadata', - action => 'setrestrictmeta', - permission => $parm_permission, - }, - { text => 'Manage Course Slots', - url => '/adm/slotrequest?command=showslots', - permission => $vgr, - }, - { text => 'Reset Student Access Times', - url => '/adm/helper/resettimes.helper', - permission => $mgr, - }, - - { text => 'Set Parameter Setting Default Actions', - action => 'setdefaults', - permission => $parm_permission, - }, - { divider => 'New and Existing Parameter Settings for Your Resources', - }, - { text => 'Set/Modify Resource Parameters - Helper Mode', - url => '/adm/helper/parameter.helper', - permission => $parm_permission, - help => 'Parameter_Helper', - }, - { text => 'Set/Modify Resource Parameters - Overview Mode', - action => 'newoverview', - permission => $parm_permission, - help => 'Parameter_Overview', - }, - { text => 'Set/Modify Resource Parameters - Table Mode', - action => 'settable', - permission => $parm_permission, - help => 'Table_Mode', - }, - { divider => 'Existing Parameter Settings for Your Resources', - }, - { text => 'Modify Resource Parameters - Overview Mode', - action => 'setoverview', - permission => $parm_permission, - help => 'Parameter_Overview', - }, - { text => 'Parameter Change Log and Course Blog Posting/User Notification', - action => 'parameterchangelog', - permission => $parm_permission, - }, + ( { categorytitle=>'Settings for this Course', + items => [ + { linktext => 'Course Environment', + url => '/adm/parmset?action=crsenv', + permission => $parm_permission, + linktitle =>'Edit environment settings for this course.' , + icon => 'preferences-desktop-remote-desktop.png' , + #help => 'Course_Environment', + }, + { linktext => 'Portfolio Metadata', + url => '/adm/parmset?action=setrestrictmeta', + permission => $parm_permission, + linktitle => 'Restrict metadata for this course.' , + icon =>'contact-new.png' , + }, + { linktext => 'Manage Course Slots', + url => '/adm/slotrequest?command=showslots', + permission => $vgr, + linktitle =>'Manage slots for this course.' , + icon => 'format-justify-fill.png' , + }, + { linktext => 'Reset Student Access Times', + url => '/adm/helper/resettimes.helper', + permission => $mgr, + linktitle =>'Reset access times for folders/maps, resources or the course.' , + icon => 'start-here.png' , + }, + + { linktext => 'Set Parameter Setting Default Actions', + url => '/adm/parmset?action=setdefaults', + permission => $parm_permission, + linktitle =>'Set default actions for parameters.' , + icon => 'folder-new.png' , + }]}, + { categorytitle => 'New and Existing Parameter Settings for Resources', + items => [ + { linktext => 'Edit Resource Parameters - Helper Mode', + url => '/adm/helper/parameter.helper', + permission => $parm_permission, + linktitle =>'Set/Modify resource parameters in helper mode.' , + icon => 'dialog-information.png' , + #help => 'Parameter_Helper', + }, + { linktext => 'Edit Resource Parameters - Overview Mode', + url => '/adm/parmset?action=newoverview', + permission => $parm_permission, + linktitle =>'Set/Modify resource parameters in overview mode.' , + icon => 'edit-find.png' , + #help => 'Parameter_Overview', + }, + { linktext => 'Edit Resource Parameters - Table Mode', + url => '/adm/parmset?action=settable', + permission => $parm_permission, + linktitle =>'Set/Modify resource parameters in table mode.' , + icon => 'edit-copy.png' , + #help => 'Table_Mode', + }]}, + { categorytitle => 'Existing Parameter Settings for Resources', + items => [ + { linktext => 'Modify Resource Parameters - Overview Mode', + url => '/adm/parmset?action=setoverview', + permission => $parm_permission, + linktitle =>'Set/Modify existing resource parameters in overview mode.' , + icon => 'preferences-desktop-wallpaper.png' , + #help => 'Parameter_Overview', + }, + { linktext => 'Change Log', + url => '/adm/parmset?action=parameterchangelog', + permission => $parm_permission, + linktitle =>'View parameter and course blog posting/user notification change log.' , + icon => 'emblem-system.png' , + }]} ); - my $menu_html = ''; - foreach my $menu_item (@menu) { - if ($menu_item->{'divider'}) { - $menu_html .= '

'.&mt($menu_item->{'divider'}).'

'; - next; - } - next if (! $menu_item->{'permission'}); - $menu_html.='

'; - $menu_html.=''; - if (exists($menu_item->{'url'})) { - $menu_html.=qq{}; - } else { - $menu_html.= - qq{}; - } - $menu_html.= &mt($menu_item->{'text'}).''; - if (exists($menu_item->{'help'})) { - $menu_html.= - &Apache::loncommon::help_open_topic($menu_item->{'help'}); - } - $menu_html.='

'.$/; - } - $r->print($menu_html); + $r->print(&Apache::lonhtmlcommon::generate_menu(@menu)); return; } -### Set portfolio metadata + + + sub output_row { my ($r, $field_name, $field_text, $added_flag) = @_; my $output; @@ -3647,7 +3848,7 @@ sub output_row { } if (!($options =~ /deleted/)) { my @options= ( ['active', 'Show to student'], - ['stuadd', 'Provide text area for students to type catalog information'], + ['stuadd', 'Provide text area for students to type metadata'], ['choices','Provide choices for students to select from']); # ['onlyone','Student may select only one choice']); if ($added_flag) { @@ -3680,22 +3881,27 @@ sub output_row { $output .= &Apache::loncommon::continue_data_table_row(); $output .= ''.(' ' x 10).''; + '.&mt('Student may select multiple choices from list').''; $output .= &Apache::loncommon::end_data_table_row(); $output .= &Apache::loncommon::continue_data_table_row(); $output .= ''.(' ' x 10).''; + '.&mt('Student may select only one choice from list').''; $output .= &Apache::loncommon::end_data_table_row(); } return ($output); } + + + sub order_meta_fields { my ($r)=@_; my $idx = 1; my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'}; my $crs = $env{'course.'.$env{'request.course.id'}.'.num'}; $r->print(&Apache::loncommon::start_page('Order Metadata Fields')); + &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=addmetadata', + text=>"Add Metadata Field"}); &Apache::lonhtmlcommon::add_breadcrumb ({href=>"/adm/parmset?action=setrestrictmeta", text=>"Restrict Metadata"}, @@ -3772,6 +3978,8 @@ sub order_meta_fields { $r->print(''); return 'ok'; } + + sub continue { my $output; $output .= '
'; @@ -3779,8 +3987,12 @@ sub continue { $output .= ''; return ($output); } + + sub addmetafield { my ($r)=@_; + &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=addmetadata', + text=>"Add Metadata Field"}); $r->print(&Apache::loncommon::start_page('Add Metadata Field')); $r->print(&Apache::lonhtmlcommon::breadcrumbs('Add Metadata Field')); my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'}; @@ -3825,12 +4037,17 @@ sub addmetafield { } $r->print('
'); } + + + sub setrestrictmeta { my ($r)=@_; my $next_meta; my $output; my $item_num; my $put_result; + &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=setrestrictmeta', + text=>"Restrict Metadata"}); $r->print(&Apache::loncommon::start_page('Restrict Metadata')); $r->print(&Apache::lonhtmlcommon::breadcrumbs('Restrict Metadata')); my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'}; @@ -3908,7 +4125,9 @@ ENDenv $r->print(&Apache::loncommon::end_page()); return 'ok'; } -################################################## + + + sub get_added_meta_fieldnames { my ($cid) = @_; my %fields; @@ -3921,6 +4140,9 @@ sub get_added_meta_fieldnames { } return \%fields; } + + + sub get_deleted_meta_fieldnames { my ($cid) = @_; my %fields; @@ -3938,6 +4160,8 @@ sub get_deleted_meta_fieldnames { sub defaultsetter { my ($r) = @_; + &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=setdefaults', + text=>"Set Defaults"}); my $start_page = &Apache::loncommon::start_page('Parameter Setting Default Actions'); my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs('Defaults'); @@ -4134,6 +4358,8 @@ sub components { } my %standard_parms; + + sub load_parameter_names { open(my $config,"<$Apache::lonnet::perlvar{'lonTabDir'}/packages.tab"); while (my $configline=<$config>) { @@ -4163,13 +4389,12 @@ sub standard_parameter_names { } } -# -# Parameter Change Log -# sub parm_change_log { my ($r)=@_; + &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=settable', + text=>"Parameter Change Log"}); $r->print(&Apache::loncommon::start_page('Parameter Change Log')); $r->print(&Apache::lonhtmlcommon::breadcrumbs('Parameter Change Log')); @@ -4331,30 +4556,16 @@ sub check_for_course_info { return 0; } -################################################## -################################################## - -=pod - -=item * handler - -Main handler. Calls &assessparms and &crsenv subroutines. - -=cut - -################################################## -################################################## sub handler { my $r=shift; &reset_caches(); - if ($r->header_only) { - &Apache::loncommon::content_type($r,'text/html'); - $r->send_http_header; - return OK; - } + &Apache::loncommon::content_type($r,'text/html'); + $r->send_http_header; + return OK if $r->header_only; + &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'}, ['action','state', 'pres_marker', @@ -4378,12 +4589,6 @@ sub handler { my $exists = &check_for_course_info(); if ($env{'request.course.id'} && $parm_permission && $exists) { - - # Start Page - &Apache::loncommon::content_type($r,'text/html'); - $r->send_http_header; - - # # Main switch on form.action and form.state, as appropriate # @@ -4391,64 +4596,34 @@ sub handler { # the table mode if ((($env{'form.command'} eq 'set') && ($env{'form.url'}) && (!$env{'form.dis'})) || ($env{'form.symb'})) { - &Apache::lonhtmlcommon::add_breadcrumb({help=>'Problem_Parameters', - text=>"Problem Parameters"}); &assessparms($r); - } elsif (! exists($env{'form.action'})) { - $r->print(&header()); - $r->print(&Apache::lonhtmlcommon::breadcrumbs('Parameter Manager')); &print_main_menu($r,$parm_permission); - } elsif ($env{'form.action'} eq 'crsenv' && $parm_permission) { - &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=crsenv', - text=>"Course Environment"}); + } elsif ($env{'form.action'} eq 'crsenv') { &crsenv($r); - } elsif ($env{'form.action'} eq 'setoverview' && $parm_permission) { - &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=setoverview', - text=>"Overview Mode"}); + } elsif ($env{'form.action'} eq 'setoverview') { &overview($r); - } elsif ($env{'form.action'} eq 'addmetadata' && $parm_permission) { - &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=addmetadata', - text=>"Add Metadata Field"}); + } elsif ($env{'form.action'} eq 'addmetadata') { &addmetafield($r); - } elsif ($env{'form.action'} eq 'ordermetadata' && $parm_permission) { - &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=addmetadata', - text=>"Add Metadata Field"}); + } elsif ($env{'form.action'} eq 'ordermetadata') { &order_meta_fields($r); - } elsif ($env{'form.action'} eq 'setrestrictmeta' && $parm_permission) { - &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=setrestrictmeta', - text=>"Restrict Metadata"}); + } elsif ($env{'form.action'} eq 'setrestrictmeta') { &setrestrictmeta($r); - } elsif ($env{'form.action'} eq 'newoverview' && $parm_permission) { - &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=setoverview', - text=>"Overview Mode"}); + } elsif ($env{'form.action'} eq 'newoverview') { &newoverview($r); - } elsif ($env{'form.action'} eq 'setdefaults' && $parm_permission) { - &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=setdefaults', - text=>"Set Defaults"}); + } elsif ($env{'form.action'} eq 'setdefaults') { &defaultsetter($r); - } elsif ($env{'form.action'} eq 'settable' && $parm_permission) { - &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=settable', - text=>"Table Mode", - help => 'Course_Setting_Parameters'}); + } elsif ($env{'form.action'} eq 'settable') { &assessparms($r); - } elsif ($env{'form.action'} eq 'parameterchangelog' && $parm_permission) { - &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=settable', - text=>"Parameter Change Log"}); + } elsif ($env{'form.action'} eq 'parameterchangelog') { &parm_change_log($r); - } elsif ($env{'form.action'} eq 'cleanparameters' && $parm_permission) { - &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=cleanparameters', - text=>"Clean Parameters"}); + } elsif ($env{'form.action'} eq 'cleanparameters') { &clean_parameters($r); - } elsif ($env{'form.action'} eq 'dateshift1' && $parm_permission) { - &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=dateshift1&timebase='.$env{'form.timebase'}, - text=>"Shifting Dates"}); + } elsif ($env{'form.action'} eq 'dateshift1') { &date_shift_one($r); - } elsif ($env{'form.action'} eq 'dateshift2' && $parm_permission) { - &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=dateshift1&timebase='.$env{'form.timebase'}, - text=>"Shifting Dates"}); + } elsif ($env{'form.action'} eq 'dateshift2') { &date_shift_two($r); - } elsif ($env{'form.action'} eq 'categorizecourse' && $parm_permission) { + } elsif ($env{'form.action'} eq 'categorizecourse') { &assign_course_categories($r); } } else { @@ -4470,11 +4645,4 @@ sub handler { 1; __END__ -=pod - -=back - -=cut - -