--- loncom/interface/lonparmset.pm 2009/11/08 19:51:22 1.480 +++ loncom/interface/lonparmset.pm 2010/06/18 11:11:08 1.498 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Handler to set parameters for assessments # -# $Id: lonparmset.pm,v 1.480 2009/11/08 19:51:22 amueller Exp $ +# $Id: lonparmset.pm,v 1.498 2010/06/18 11:11:08 bisitz 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,8 +872,7 @@ sub startpage { my ($r) = @_; my %loaditems = ('onunload' => "pclose()", - 'onload' => "group_or_section('cgroup')", - 'onload' => "showHide_courseContent()", + 'onload' => "showHide_courseContent(); group_or_section('cgroup')", ); if ((($env{'form.command'} eq 'set') && ($env{'form.url'}) @@ -1362,13 +1330,17 @@ ENDSCRIPT .'' ); } - $r->print('' - .'

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

' - ); + $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)); } @@ -1494,13 +1466,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 @@ -1542,45 +1524,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 { @@ -1712,11 +1682,6 @@ sub displaymenu { &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 { @@ -1768,38 +1733,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,26 +1803,38 @@ 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)=@_; @@ -2186,16 +2186,16 @@ function parmsel_show() { // ]]> ENDPARMSELSCRIPT - my $parmselhiddenstyle=' style="display:none"'; - if($env{'form.hideparmsel'} eq 'hidden') { - $r->print('
'); - } else { - $r->print('
'); - } - - # Display Unit 1 "General Parameters" if (!$pssymb) { + my $parmselhiddenstyle=' style="display:none"'; + if($env{'form.hideparmsel'} eq 'hidden') { + $r->print('
'); + } else { + $r->print('
'); + } + + # Step 1 $r->print(&Apache::lonhtmlcommon::topic_bar(1,&mt('Resource Specification'))); $r->print(< @@ -2218,56 +2218,66 @@ COURSECONTENTSCRIPT $r->print(&Apache::lonhtmlcommon::start_pick_box()); &levelmenu($r,\%alllevs,$parmlev); - $r->print(&Apache::lonhtmlcommon::row_closure(1)); - $r->print(&Apache::lonhtmlcommon::end_pick_box()); - $r->print('
'); - $r->print(&Apache::lonhtmlcommon::start_pick_box()); + $r->print(&Apache::lonhtmlcommon::row_closure()); &mapmenu($r,\%allmaps,$pschp,\%maptitles, \%symbp); + $r->print(&Apache::lonhtmlcommon::row_closure()); + $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()); - $r->print('
'); - #Display Unit 2 "Select Parameter" + + # Step 2 $r->print(&Apache::lonhtmlcommon::topic_bar(2,&mt('Parameter Specification'))); &displaymenu($r,\%allparms,\%allparts,\@pscat,\@psprt,\%keyorder); + + # Step 3 $r->print(&Apache::lonhtmlcommon::topic_bar(3,&mt('User Specification (optional)'))); + $r->print(&Apache::lonhtmlcommon::start_pick_box()); + &usermenu($r,$uname,$id,$udom,$csec,$cgroup,$parmlev,\@usersgroups); + $r->print(&Apache::lonhtmlcommon::row_closure(1)); + $r->print(&Apache::lonhtmlcommon::end_pick_box()); + + # Update Display Button + $r->print('

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

'); + $r->print('
'); + + # Offer link to display parameter selection again + $r->print(''); } else { # parameter screen for a single resource. - my ($map,$id,$resource)=&Apache::lonnet::decode_symb($pssymb); + my ($map,$iid,$resource)=&Apache::lonnet::decode_symb($pssymb); my $title = &Apache::lonnet::gettitle($pssymb); $r->print(&mt('Specific Resource: [_1] ([_2])',$title,$resource). ''. - '

'); - $r->print(&Apache::lonhtmlcommon::topic_bar('',&mt('User Specification (optional)'))); - } - $r->print(&Apache::lonhtmlcommon::start_pick_box()); - &usermenu($r,$uname,$id,$udom,$csec,$cgroup,$parmlev,\@usersgroups); - $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(&Apache::lonhtmlcommon::topic_bar('',&mt('Additional Display Specification (optional)'))); + $r->print(&Apache::lonhtmlcommon::start_pick_box()); + $r->print(&Apache::lonhtmlcommon::row_title(&mt('Select Parts to View')). + ''); + &usermenu($r,$uname,$id,$udom,$csec,$cgroup,$parmlev,\@usersgroups); + $r->print(&Apache::lonhtmlcommon::row_closure(1)); + $r->print(&Apache::lonhtmlcommon::end_pick_box()); + $r->print('

' .'' .'' - .'

' - ); - - $r->print('
'); - # ----- End Parameter Selection - - # Offer link to display parameter selection again - $r->print(''); } - $r->print('>' - .'' - .&mt('Change Parameter Selection') - .'' - .'

' - ); + # ----- End Parameter Selection # Display Messages $r->print('
'.$message.'
'); @@ -3012,7 +3022,7 @@ sub date_interval_selector { my %select = ((map {$_ => $_} (0..$max)), 'select_form_order' => [0..$max]); $result .= &Apache::loncommon::select_form($amount,$name.'_'.$thiskey, - %select); + \%select); $result .= ' '.&mt($name); } $result .= ''; @@ -3174,30 +3184,23 @@ ENDOVER \%keyorder,\%defkeytype); if (grep {$_ eq 'all'} (@psprt)) { - @psprt = keys(%allparts); + @psprt = keys(%allparts); } # Menu to select levels, etc - #$r->print(' - # '); + &mapmenu($r,\%allmaps,$pschp,\%maptitles,\%symbp); } $r->print(&Apache::lonhtmlcommon::row_closure(1)); $r->print(&Apache::lonhtmlcommon::end_pick_box()); $r->print(''); - #$r->print('
'); $r->print('
'); #$r->print('

Step 1

'); $r->print('
'); $r->print(&Apache::lonhtmlcommon::start_pick_box()); &levelmenu($r,\%alllevs,$parmlev); if ($parmlev ne 'general') { - #$r->print('
'); $r->print(&Apache::lonhtmlcommon::row_closure()); - &mapmenu($r,\%allmaps,$pschp,\%maptitles); - #$r->print('
'); - #$r->print(' - #
'); $r->print('
'); $r->print('
'); $r->print(&Apache::lonhtmlcommon::start_pick_box()); @@ -3206,8 +3209,7 @@ ENDOVER &parmboxes($r,\%allparms,\@pscat,\%keyorder); $r->print(&Apache::lonhtmlcommon::start_pick_box()); $r->print(&Apache::lonhtmlcommon::row_title(&mt('Select Parts to View'))); - #$r->print('
'. - $r->print(''. + $r->print('
'. '
'.&mt('Parts').''.&mt('Section(s)'). ''.&mt('Group(s)').'
'); &partmenu($r,\%allparts,\@psprt); @@ -3242,15 +3244,15 @@ ENDOVER if (($env{'form.store'}) || ($env{'form.dis'})) { - if ($env{'form.store'}) { &storedata($r,$crs,$dom); } + if ($env{'form.store'}) { &storedata($r,$crs,$dom); } # Read modified data - my $resourcedata=&readdata($crs,$dom); + my $resourcedata=&readdata($crs,$dom); # List data - &listdata($r,$resourcedata,$listdata,$sortorder); + &listdata($r,$resourcedata,$listdata,$sortorder); } $r->print(&tableend(). ((($env{'form.store'}) || ($env{'form.dis'}))?'

':''). @@ -3503,123 +3505,6 @@ sub parse_key { } - -sub extract_cloners { - my ($clonelist,$allowclone) = @_; - if ($clonelist =~ /,/) { - @{$allowclone} = split(/,/,$clonelist); - } else { - $$allowclone[0] = $clonelist; - } -} - -sub check_cloners { - my ($clonelist,$oldcloner) = @_; - my ($clean_clonelist,%disallowed); - my @allowclone = (); - &extract_cloners($$clonelist,\@allowclone); - foreach my $currclone (@allowclone) { - if (!grep(/^\Q$currclone\E$/,@$oldcloner)) { - if ($currclone eq '*') { - $clean_clonelist .= $currclone.','; - } else { - my ($uname,$udom) = split(/:/,$currclone); - if ($uname eq '*') { - if ($udom =~ /^$match_domain$/) { - if (!&Apache::lonnet::domain($udom)) { - $disallowed{'domain'} .= $currclone.','; - } else { - $clean_clonelist .= $currclone.','; - } - } else { - $disallowed{'format'} .= $currclone.','; - } - } elsif ($currclone !~/^($match_username)\:($match_domain)$/) { - $disallowed{'format'} .= $currclone.','; - } else { - if (&Apache::lonnet::homeserver($uname,$udom) eq 'no_host') { - $disallowed{'newuser'} .= $currclone.','; - } else { - $clean_clonelist .= $currclone.','; - } - } - } - } else { - $clean_clonelist .= $currclone.','; - } - } - foreach my $key (keys(%disallowed)) { - $disallowed{$key} =~ s/,$//; - } - if ($clean_clonelist) { - $clean_clonelist =~ s/,$//; - } - $$clonelist = $clean_clonelist; - return %disallowed; -} - -sub change_clone { - my ($clonelist,$oldcloner) = @_; - my ($uname,$udom); - my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; - my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; - my $clone_crs = $cnum.':'.$cdom; - - if ($cnum && $cdom) { - my @allowclone; - &extract_cloners($clonelist,\@allowclone); - foreach my $currclone (@allowclone) { - if (!grep(/^$currclone$/,@$oldcloner)) { - if ($currclone ne '*') { - ($uname,$udom) = split(/:/,$currclone); - if ($uname && $udom && $uname ne '*') { - if (&Apache::lonnet::homeserver($uname,$udom) ne 'no_host') { - my %currclonecrs = &Apache::lonnet::dump('environment',$udom,$uname,'cloneable'); - if ($currclonecrs{'cloneable'} !~ /\Q$clone_crs\E/) { - if ($currclonecrs{'cloneable'} eq '') { - $currclonecrs{'cloneable'} = $clone_crs; - } else { - $currclonecrs{'cloneable'} .= ','.$clone_crs; - } - &Apache::lonnet::put('environment',\%currclonecrs,$udom,$uname); - } - } - } - } - } - } - foreach my $oldclone (@$oldcloner) { - if (!grep(/^\Q$oldclone\E$/,@allowclone)) { - if ($oldclone ne '*') { - ($uname,$udom) = split(/:/,$oldclone); - if ($uname && $udom && $uname ne '*' ) { - if (&Apache::lonnet::homeserver($uname,$udom) ne 'no_host') { - my %currclonecrs = &Apache::lonnet::dump('environment',$udom,$uname,'cloneable'); - my %newclonecrs = (); - if ($currclonecrs{'cloneable'} =~ /\Q$clone_crs\E/) { - if ($currclonecrs{'cloneable'} =~ /,/) { - my @currclonecrs = split/,/,$currclonecrs{'cloneable'}; - foreach my $crs (@currclonecrs) { - if ($crs ne $clone_crs) { - $newclonecrs{'cloneable'} .= $crs.','; - } - } - $newclonecrs{'cloneable'} =~ s/,$//; - } else { - $newclonecrs{'cloneable'} = ''; - } - &Apache::lonnet::put('environment',\%newclonecrs,$udom,$uname); - } - } - } - } - } - } - } -} - - - sub header { return &Apache::loncommon::start_page('Parameter Manager'); } @@ -3647,25 +3532,12 @@ ENDMAINFORMHEAD my @menu = ( { categorytitle=>"Settings for this $crstype", items => [ - { linktext => "$crstype Configuration", - url => '/adm/courseprefs?origin=params', - permission => $parm_permission, - linktitle => "Edit $lc_crstype configuration." , - 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 $lc_crstype." , icon =>'contact-new.png' , }, - { linktext => "Manage $crstype Slots", - url => '/adm/slotrequest?command=showslots', - permission => $vgr, - linktitle => "Manage slots for this $lc_crstype." , - icon => 'format-justify-fill.png' , - }, { linktext => 'Reset Student Access Times', url => '/adm/helper/resettimes.helper', permission => $mgr, @@ -3715,7 +3587,7 @@ ENDMAINFORMHEAD url => '/adm/parmset?action=parameterchangelog', permission => $parm_permission, linktitle =>"View parameter and $lc_crstype blog posting/user notification change log." , - icon => 'emblem-system.png' , + icon => 'document-properties.png', }]} ); $r->print(&Apache::lonhtmlcommon::generate_menu(@menu)); @@ -4625,8 +4497,6 @@ sub handler { &date_shift_one($r); } elsif ($env{'form.action'} eq 'dateshift2') { &date_shift_two($r); - } elsif ($env{'form.action'} eq 'categorizecourse') { - &assign_course_categories($r); } } else { # ----------------------------- Not in a course, or not allowed to modify parms