--- loncom/interface/lonparmset.pm 2009/11/22 21:07:41 1.486 +++ loncom/interface/lonparmset.pm 2011/01/13 17:44:30 1.506 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Handler to set parameters for assessments # -# $Id: lonparmset.pm,v 1.486 2009/11/22 21:07:41 www Exp $ +# $Id: lonparmset.pm,v 1.506 2011/01/13 17:44:30 www 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 @@ -333,6 +302,7 @@ use Apache::lonlocal; use Apache::lonnavmaps; use Apache::longroup; use Apache::lonrss; +use HTML::Entities; use LONCAPA qw(:DEFAULT :match); @@ -921,6 +891,8 @@ sub startpage { {'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(< + + ENDHEAD } @@ -961,7 +935,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; } @@ -1245,8 +1219,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 +1296,8 @@ sub parmmenu { checkdates(); checkthis('weight','pscat'); checkthis('maxtries','pscat'); + checkthis('type','pscat'); + checkthis('problemstatus','pscat'); } function hideParms() { @@ -1350,7 +1327,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 +1381,7 @@ sub lookUpTableParameter { 'handgrade' => 'grading', 'maxtries' => 'tries', 'hinttries' => 'tries', + 'randomizeontries' => 'tries', 'type' => 'problem_appearance', 'problemstatus' => 'problem_appearance', 'display' => 'problem_appearance', @@ -1493,13 +1475,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 +1533,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 { @@ -1711,21 +1691,16 @@ 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 { - 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 = (); @@ -1770,35 +1745,58 @@ sub mapmenu { $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 @@ -1814,22 +1812,32 @@ 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()); } } @@ -2017,8 +2025,11 @@ sub assessparms { my @pscat=&Apache::loncommon::get_env_multiple('form.pscat'); my $pschp=$env{'form.pschp'}; + + my @psprt=&Apache::loncommon::get_env_multiple('form.psprt'); if (!@psprt) { $psprt[0]='0'; } + if (($env{'form.part'}) && ($psprt[0] ne 'all')) { $psprt[0]=$env{'form.part'}; } my $pssymb=''; my $parmlev=''; @@ -2086,7 +2097,7 @@ sub assessparms { $message="\n

\n".&mt("Full Name").": ". $name{'firstname'}.' '.$name{'middlename'}.' ' .$name{'lastname'}.' '.$name{'generation'}. - "
\n".&mt('ID').": ".$name{'id'}.'

'; + "
\n".&mt('Student/Employee ID').": ".$name{'id'}.'

'; } @usersgroups = &Apache::lonnet::get_users_groups( $udom,$uname,$env{'request.course.id'}); @@ -2114,10 +2125,14 @@ sub assessparms { my @markers=split(/\&\&\&/,$env{'form.pres_marker'}); my @values=split(/\&\&\&/,$env{'form.pres_value'}); my @types=split(/\&\&\&/,$env{'form.pres_type'}); + my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; + my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; + my $chome = $env{'course.'.$env{'request.course.id'}.'.home'}; + my ($got_chostname,$chostname,$cmajor,$cminor); + my $totalstored = 0; for (my $i=0;$i<=$#markers;$i++) { + my ($needsrelease,$needsnewer); if ($markers[$i] =~ /^[\d.]+\&0_availablestudent\&(1|2|3)$/) { - my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; - my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; my (@ok_slots,@fail_slots,@del_slots); my $courseopt=&Apache::lonnet::get_courseresdata($cnum,$cdom); my ($level,@all) = @@ -2147,21 +2162,42 @@ sub assessparms { } } } + } elsif ($markers[$i] =~ /_type\&\d+$/) { + $needsrelease = + $Apache::lonnet::needsrelease{'parameter:type:'.$values[$i]}; + if ($needsrelease) { + unless ($got_chostname) { + ($chostname,$cmajor,$cminor) = &questiontype_release_vars(); + $got_chostname = 1; + } + $needsnewer = &questiontype_releasecheck($values[$i], + $needsrelease, + $chostname, + $cmajor,$cminor); + } + } + if ($needsnewer) { + $message .= &oldversion_warning($values[$i],$chostname,$cmajor, + $cminor,$needsrelease); + } else { + $message.=&storeparm(split(/\&/,$markers[$i]), + $values[$i], + $types[$i], + $uname,$udom,$csec,$cgroup); + $totalstored ++; } - $message.=&storeparm(split(/\&/,$markers[$i]), - $values[$i], - $types[$i], - $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') - .'

'; + if ($totalstored) { + $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);} - if (!@pscat) { @pscat=('duedate','opendate','answerdate','weight','maxtries') }; + if (!@pscat) { @pscat=('duedate','opendate','answerdate','weight','maxtries','type','problemstatus') }; if ($psprt[0] eq "all" || !@psprt) {@psprt = (keys %allparts);} # ------------------------------------------------------------------ Start page @@ -2188,7 +2224,6 @@ function parmsel_show() { ENDPARMSELSCRIPT - # Display Unit 1 "General Parameters" if (!$pssymb) { my $parmselhiddenstyle=' style="display:none"'; if($env{'form.hideparmsel'} eq 'hidden') { @@ -2197,6 +2232,7 @@ ENDPARMSELSCRIPT $r->print('
'); } + # Step 1 $r->print(&Apache::lonhtmlcommon::topic_bar(1,&mt('Resource Specification'))); $r->print(< @@ -2219,26 +2255,33 @@ 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(&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()); - #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('

'); +# +# This produces the headers +# $r->print(''); $r->print(''); if ($uname) { @@ -2311,7 +2364,6 @@ COURSECONTENTSCRIPT my %lt=&Apache::lonlocal::texthash( 'pie' => "Parameter in Effect", 'csv' => "Current Session Value", - 'at' => 'at', 'rl' => "Resource Level", 'ic' => 'in Course', 'aut' => "Assessment URL and Title", @@ -2327,7 +2379,7 @@ COURSECONTENTSCRIPT ); $r->print(<$lt{'pie'} - + @@ -2363,7 +2415,9 @@ ENDTABLEHEADFOUR } $r->print(''); - +# +# Done with the headers +# my $defbgone=''; my $defbgtwo=''; my $defbgthree = ''; @@ -2403,11 +2457,19 @@ ENDTABLEHEADFOUR my %default=(); my $uri=&Apache::lonnet::declutter($uris{$rid}); + my $filter=$env{'form.filter'}; + foreach (&keysplit($keyp{$rid})) { my $tempkeyp = $_; if (grep $_ eq $tempkeyp, @catmarker) { + my $parmname=&Apache::lonnet::metadata($uri,$_.'.name'); +# We may only want certain parameters listed + if ($filter) { + unless ($filter=~/\Q$parmname\E/) { next; } + } + $name{$_}=$parmname; $part{$_}=&Apache::lonnet::metadata($uri,$_.'.part'); - $name{$_}=&Apache::lonnet::metadata($uri,$_.'.name'); + my $parmdis=&Apache::lonnet::metadata($uri,$_.'.display'); if ($allparms{$name{$_}} ne '') { my $identifier; @@ -2745,8 +2807,9 @@ sub storedata { undef %newdata; my @deldata=(); undef @deldata; - foreach (keys %env) { - if ($_=~/^form\.([a-z]+)\_(.+)$/) { + my ($got_chostname,$chostname,$cmajor,$cminor); + foreach my $key (keys(%env)) { + if ($key =~ /^form\.([a-z]+)\_(.+)$/) { my $cmd=$1; my $thiskey=$2; my ($tuname,$tudom)=&extractuser($thiskey); @@ -2757,11 +2820,29 @@ sub storedata { if ($cmd eq 'set' || $cmd eq 'datepointer' || $cmd eq 'dateinterval') { my ($data, $typeof, $text); if ($cmd eq 'set') { - $data=$env{$_}; + $data=$env{$key}; $typeof=$env{'form.typeof_'.$thiskey}; $text = &mt('Saved modified parameter for'); + if ($typeof eq 'string_questiontype') { + my ($needsrelease,$needsnewer); + $needsrelease = $Apache::lonnet::needsrelease{'parameter:type:'.$data}; + if ($needsrelease) { + unless ($got_chostname) { + ($chostname,$cmajor,$cminor)=&questiontype_release_vars(); + $got_chostname = 1; + } + $needsnewer = &questiontype_releasecheck($data,$needsrelease, + $chostname,$cmajor, + $cminor); + } + if ($needsnewer) { + $r->print('
'.&oldversion_warning($data,$chostname,$cmajor, + $cminor,$needsrelease)); + next; + } + } } elsif ($cmd eq 'datepointer') { - $data=&Apache::lonhtmlcommon::get_date_from_form($env{$_}); + $data=&Apache::lonhtmlcommon::get_date_from_form($env{$key}); $typeof=$env{'form.typeof_'.$thiskey}; $text = &mt('Saved modified date for'); } elsif ($cmd eq 'dateinterval') { @@ -3016,7 +3097,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 .= ''; @@ -3055,8 +3136,24 @@ my %strings = [ 'answer', 'Yes, and show correct answer if they exceed the maximum number of tries.' ], [ 'no', 'No, don\'t show correct/incorrect feedback.' ], [ 'no_feedback_ever', 'No, show no feedback at all.' ]], + 'string_questiontype' + => [[ 'problem', 'Standard Problem'], + [ 'survey', 'Survey'], + [ 'anonsurveycred', 'Anonymous Survey (credit for submission)'], + [ 'exam', 'Exam'], + [ 'anonsurvey', 'Anonymous Survey'], + [ 'randomizetry', 'New Randomization Each N Tries (default N=1)'], + [ 'practice', 'Practice'], + [ 'surveycred', 'Survey (credit for submission)']], ); +sub standard_string_options { + my ($string_type) = @_; + if (ref($strings{$string_type}) eq 'ARRAY') { + return $strings{$string_type}; + } + return; +} sub string_selector { my ($thistype, $thiskey, $showval) = @_; @@ -3065,15 +3162,73 @@ sub string_selector { return &default_selector($thiskey,$showval); } + my %skiptype; + if ($thistype eq 'string_questiontype') { + my ($got_chostname,$chostname,$cmajor,$cminor); + foreach my $possibilities (@{ $strings{$thistype} }) { + next unless (ref($possibilities) eq 'ARRAY'); + my ($name, $description) = @{ $possibilities }; + my $needsrelease=$Apache::lonnet::needsrelease{'parameter:type:'.$name}; + if ($needsrelease) { + unless ($got_chostname) { + ($chostname,$cmajor,$cminor)=&questiontype_release_vars(); + $got_chostname = 1; + } + my $needsnewer=&questiontype_releasecheck($name,$needsrelease, + $chostname,$cmajor, + $cminor); + if ($needsnewer) { + $skiptype{$name} = 1; + } + } + } + } + my $result; - foreach my $possibilities (@{ $strings{$thistype} }) { - my ($name, $description) = @{ $possibilities }; - $result .= ''; + } + $result .= ''; + $i++; + } + $rem = @{ $strings{$thistype} }%($numinrow); + my $colsleft = $numinrow - $rem; + if ($colsleft > 1 ) { + $result .= ''; + } elsif ($colsleft == 1) { + $result .= ''; + } + $result .= ''; } - $result .= ' />'.&mt($description).' '; + if ($result) { + $result = '
'.&mt('Any User').'$lt{'csv'}
($csuname $lt{'at'} $csudom)
$lt{'csv'}
($csuname:$csudom)
$lt{'ic'}$lt{'rl'} $lt{'ic'}
'. + ''. + '  
'.$result.'
'; } return $result; } @@ -3150,6 +3305,7 @@ ENDOVER my @pscat=&Apache::loncommon::get_env_multiple('form.pscat'); my $pschp=$env{'form.pschp'}; + my @psprt=&Apache::loncommon::get_env_multiple('form.psprt'); if (!@psprt) { $psprt[0]='0'; } @@ -3182,26 +3338,19 @@ ENDOVER } # Menu to select levels, etc - #$r->print(' - # '); } $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,\%symbp); - #$r->print('
'); - #$r->print(' - #
'); $r->print('
'); $r->print('
'); $r->print(&Apache::lonhtmlcommon::start_pick_box()); @@ -3210,7 +3359,6 @@ 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(''. '
'.&mt('Parts').''.&mt('Section(s)'). ''.&mt('Group(s)').'
'); @@ -3507,123 +3655,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'); } @@ -3651,25 +3682,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, @@ -3719,7 +3737,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)); @@ -4563,6 +4581,49 @@ sub check_for_course_info { return 0; } +sub questiontype_release_vars { + my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; + my $chome = $env{'course.'.$env{'request.course.id'}.'.home'}; + my $chostname = &Apache::lonnet::hostname($chome); + my ($cmajor,$cminor) = + split(/\./,&Apache::lonnet::get_server_loncaparev($cdom,$chome)); + return ($chostname,$cmajor,$cminor); +} + +sub questiontype_releasecheck { + my ($questiontype,$needsrelease,$chostname,$cmajor,$cminor) = @_; + my $needsnewer; + my ($needsmajor,$needsminor) = split(/\./,$needsrelease); + if (($cmajor < $needsmajor) || + ($cmajor == $needsmajor && $cminor < $needsminor)) { + $needsnewer = 1; + } else { + &Apache::lonnet::update_released_required($Apache::lonnet::needsrelease{'parameter:type:'.$questiontype}); + } + return $needsnewer; +} + +sub oldversion_warning { + my ($questiontype,$chostname,$cmajor,$cminor,$needsrelease) = @_; + my $desc; + if (ref($strings{'string_questiontype'}) eq 'ARRAY') { + foreach my $possibilities (@{ $strings{'string_questiontype'} }) { + next unless (ref($possibilities) eq 'ARRAY'); + my ($name, $description) = @{ $possibilities }; + if ($name eq $questiontype) { + $desc = $description; + last; + } + } + } + return '

'. + &mt('Question Type was [_1]not[_2] set to [_3].', + '','','"'.$desc.'"').'
'. + &mt('LON-CAPA version ([_1]) installed on home server ([_2]) does not meet version requirements ([_3] or newer).', + $cmajor.'.'.$cminor,$chostname, + $needsrelease). + '

'; +} sub handler { my $r=shift; @@ -4578,6 +4639,7 @@ sub handler { 'pres_marker', 'pres_value', 'pres_type', + 'filter','part', 'udom','uname','symb','serial','timebase']); @@ -4629,8 +4691,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