--- loncom/interface/lonparmset.pm 2020/01/15 00:38:38 1.522.2.26.2.1 +++ loncom/interface/lonparmset.pm 2020/02/12 19:54:47 1.522.2.27 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Handler to set parameters for assessments # -# $Id: lonparmset.pm,v 1.522.2.26.2.1 2020/01/15 00:38:38 raeburn Exp $ +# $Id: lonparmset.pm,v 1.522.2.27 2020/02/12 19:54:47 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -767,17 +767,7 @@ sub valout { } } else { if ($type eq 'date_interval') { - my ($totalsecs,$donesuffix) = split(/_/,$value,2); - my ($usesdone,$donebuttontext,$proctor,$secretkey); - if ($donesuffix =~ /^done\:([^\:]+)\:(.*)$/) { - $donebuttontext = $1; - (undef,$proctor,$secretkey) = split(/_/,$2); - $usesdone = 'done'; - } elsif ($donesuffix =~ /^done(|_.+)$/) { - $donebuttontext = &mt('Done'); - ($usesdone,$proctor,$secretkey) = split(/_/,$donesuffix); - } - my ($sec,$min,$hour,$mday,$mon,$year)=gmtime($totalsecs); + my ($sec,$min,$hour,$mday,$mon,$year)=gmtime($value); my @timer; $year=$year-70; $mday--; @@ -810,13 +800,6 @@ sub valout { push(@timer,&mt('[quant,_1,sec]',0)); } $result.=join(", ",@timer); - if ($usesdone eq 'done') { - if ($secretkey) { - $result .= ' '.&mt('+ "[_1]" with proctor key: [_2]',$donebuttontext,$secretkey); - } else { - $result .= ' + "'.$donebuttontext.'"'; - } - } } elsif (&isdateparm($type)) { $result = &Apache::lonlocal::locallocaltime($value). &date_sanity_info($value); @@ -834,12 +817,8 @@ sub plink { my ($type,$dis,$value,$marker,$return,$call)=@_; my $winvalue=$value; unless ($winvalue) { - if ((&isdateparm($type)) || (&is_specialstring($type))) { + if (&isdateparm($type)) { $winvalue=$env{'form.recent_'.$type}; - } elsif ($type eq 'string_yesno') { - if ($env{'form.recent_string'} =~ /^(yes|no)$/i) { - $winvalue=$env{'form.recent_string'}; - } } else { $winvalue=$env{'form.recent_'.(split(/\_/,$type))[0]}; } @@ -872,22 +851,20 @@ sub page_js { $pjump_def function psub() { - var specstring = /^string_!(yesno|any)/i; if (document.parmform.pres_marker.value!='') { document.parmform.action+='#'+document.parmform.pres_marker.value; var typedef=new Array(); typedef=document.parmform.pres_type.value.split('_'); - if (document.parmform.pres_type.value!='') { - if ((typedef[0]=='date') || - (specstring.test(document.parmform.pres_type.value))) { - eval('document.parmform.recent_'+ - document.parmform.pres_type.value+ - '.value=document.parmform.pres_value.value;'); - } else { - eval('document.parmform.recent_'+typedef[0]+ - '.value=document.parmform.pres_value.value;'); - } + if (document.parmform.pres_type.value!='') { + if (typedef[0]=='date') { + eval('document.parmform.recent_'+ + document.parmform.pres_type.value+ + '.value=document.parmform.pres_value.value;'); + } else { + eval('document.parmform.recent_'+typedef[0]+ + '.value=document.parmform.pres_value.value;'); } + } document.parmform.submit(); } else { document.parmform.pres_value.value=''; @@ -929,97 +906,6 @@ function showHide_courseContent() { COURSECONTENTSCRIPT } -sub validateparms_js { - return <<'ENDSCRIPT'; - -function validateParms() { - var ipallowRegExp = /^setipallow_/; - var ipdenyRegExp = /^setipdeny_/; - var patternIP = /[\[\]\*\.a-zA-Z\d\-]+/; - if ((document.parmform.elements.length != 'undefined') && (document.parmform.elements.length) != 'null') { - if (document.parmform.elements.length) { - for (i=0; i$remove'); - }); - - \$(wrapper).delegate(".LC_remove_ipacc","click", function(e){ - e.preventDefault(); \$(this).closest("div").remove(); - }) -}); - - -END -} - -sub done_proctor_js { - return <<"END"; -function toggleSecret(form,radio,key) { - var radios = form[radio+key]; - if (radios.length) { - for (var i=0; i'. + $stuonly.'  '. + ''; my $sections=''; my %sectionhash = &Apache::loncommon::get_sections(); @@ -2258,25 +2164,124 @@ sub assessparms { $csec=&Apache::lonnet::getsection($udom,$uname, $env{'request.course.id'}); if ($csec eq '-1') { - $message=''. - &mt("User")." '$uname' ".&mt("at domain")." '$udom' ". - &mt("not in this course").""; - $uname=''; - $csec=$env{'form.csec'}; + my $crstype = $env{'course.'.$env{'request.course.id'}.'.type'}; + if ($env{'form.userroles'} eq 'any') { + if (($env{'user.name'} eq $uname) && ($env{'user.domain'} eq $udom)) { + $csec = $env{'request.course.sec'}; + $message = ''; + if ($crstype eq 'Community') { + $message .= &mt('User [_1] at domain [_2] has a non-member role in this community', + $uname,$udom); + } else { + $message .= &mt('User [_1] at domain [_2] has a non-student role in this course', + $uname,$udom); + } + $message .= ''; + } else { + my @possroles = ('in','ep','ta','cr'); + if ($crstype eq 'Community') { + unshift(@possroles,'co'); + } else { + unshift(@possroles,'cc'); + } + my %not_student_roles = + &Apache::lonnet::get_my_roles($uname,$udom,'userroles',['active'], + \@possroles,[$udom],1,1); + my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; + my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; + my %sections_by_role; + foreach my $role (keys(%not_student_roles)) { + if ($role =~ /^\Q$cnum:$cdom:\E([^:]+):(|[^:]+)$/) { + my ($rolename,$sec) = ($1,$2); + if ($rolename =~ m{^cr/}) { + $rolename = 'cr'; + } + push(@{$sections_by_role{$rolename}},$sec); + } + } + my $numroles = scalar(keys(%sections_by_role)); + if ($numroles) { + foreach my $role (@possroles) { + if (ref($sections_by_role{$role}) eq 'ARRAY') { + my @secs = sort { $a <=> $b } @{$sections_by_role{$role}}; + $csec = $secs[0]; + last; + } + } + } + if ($csec eq '-1') { + $message = ''; + if ($crstype eq 'Community') { + $message .= &mt('User [_1] at domain [_2] does not have a role in this community', + $uname,$udom); + } else { + $message .= &mt('User [_1] at domain [_2] does not have a role in this course', + $uname,$udom); + } + $message .= ''; + $uname=''; + if ($env{'request.course.sec'} ne '') { + $csec=$env{'request.course.sec'}; + } else { + $csec=$env{'form.csec'}; + } + $cgroup=$env{'form.cgroup'}; + } else { + $message = ''; + if ($crstype eq 'Community') { + $message .= &mt('User [_1] at domain [_2] has a non-member role in this community', + $uname,$udom); + } else { + $message .= &mt('User [_1] at domain [_2] has a non-student role in this course', + $uname,$udom); + } + $message .= ''; + } + } + } else { + $message = ''; + if ($crstype eq 'Community') { + $message .= &mt('User [_1] at domain [_2] does not have a member role in this community', + $uname,$udom); + } else { + $message .= &mt('User [_1] at domain [_2] does not have a student role in this course', + $uname,$udom); + } + $message .= ''; + $uname=''; + if ($env{'request.course.sec'} ne '') { + $csec=$env{'request.course.sec'}; + } else { + $csec=$env{'form.csec'}; + } + $cgroup=$env{'form.cgroup'}; + } + } elsif ($env{'request.course.sec'} ne '') { + if ($csec ne $env{'request.course.sec'}) { + $message=''. + &mt("User '[_1]' at domain '[_2]' not in section '[_3]'", + $uname,$udom,$env{'request.course.sec'}). + ''; + $uname=''; + $csec=$env{'request.course.sec'}; + } $cgroup=$env{'form.cgroup'}; - } else { + } + if ($uname ne '') { my %name=&Apache::lonnet::userenvironment($udom,$uname, ('firstname','middlename','lastname','generation','id')); - $message="\n

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

'; - } - @usersgroups = &Apache::lonnet::get_users_groups( - $udom,$uname,$env{'request.course.id'}); - if (@usersgroups > 0) { - unless (grep(/^\Q$cgroup\E$/,@usersgroups)) { - $cgroup = $usersgroups[0]; + $message .= "\n

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

'; + @usersgroups = &Apache::lonnet::get_users_groups( + $udom,$uname,$env{'request.course.id'}); + if (@usersgroups > 0) { + unless (grep(/^\Q$cgroup\E$/,@usersgroups)) { + $cgroup = $usersgroups[0]; + } + } else { + $cgroup = ''; } } } @@ -2401,14 +2406,11 @@ sub assessparms { &startpage($r,$pssymb); - foreach my $item ('tolerance','date_default','date_start','date_end', - 'date_interval','int','float','string','string_lenient', - 'string_examcode','string_deeplink','string_discussvote', - 'string_useslots','string_problemstatus','string_ip', - 'string_questiontype') { + foreach ('tolerance','date_default','date_start','date_end', + 'date_interval','int','float','string') { $r->print(''). - '" name="recent_'.$item.'" />'); + &HTML::Entities::encode($env{'form.recent_'.$_},'"&<>'). + '" name="recent_'.$_.'" />'); } # ----- Start Parameter Selection @@ -3020,7 +3022,6 @@ sub storedata { if ($key =~ /^form\.([a-z]+)\_(.+)$/) { my $cmd=$1; my $thiskey=$2; - next if ($cmd eq 'setipallow' || $cmd eq 'setipdeny'); my ($tuname,$tudom)=&extractuser($thiskey); my $tkey=$thiskey; if ($tuname) { @@ -3189,6 +3190,7 @@ sub listdata { $tableopen=0; my $foundkeys=0; my %keyorder=&standardkeyorder(); + my $readonlyall = $readonly; my ($secidx,%grouphash); if (($env{'request.course.sec'} ne '') && ($caller eq 'overview')) { @@ -3249,6 +3251,7 @@ sub listdata { my ($middle,$part,$name)= ($thiskey=~/^$env{'request.course.id'}\.(?:(.+)\.)*([\w\s]+)\.(\w+)$/); my $section=&mt('All Students'); + $readonly = $readonlyall; if ($middle=~/^\[(.*)\]/) { my $issection=$1; if ($issection=~/^useropt\:($match_username)\:($match_domain)/) { @@ -3351,7 +3354,7 @@ sub listdata { ); } } elsif ($thistype eq 'date_interval') { - $r->print(&date_interval_selector($thiskey,$name, + $r->print(&date_interval_selector($thiskey, $$resourcedata{$thiskey},$readonly)); } elsif ($thistype =~ m/^string/) { $r->print(&string_selector($thistype,$thiskey, @@ -3371,9 +3374,8 @@ sub listdata { sub date_interval_selector { - my ($thiskey, $pname, $showval, $readonly) = @_; - my ($result,%skipval); - my $currval = $showval; + my ($thiskey, $showval, $readonly) = @_; + my $result; foreach my $which (['days', 86400, 31], ['hours', 3600, 23], ['minutes', 60, 59], @@ -3387,51 +3389,6 @@ sub date_interval_selector { \%select,'',$readonly); $result .= ' '.&mt($name); } - if ($pname eq 'interval') { - unless ($skipval{'done'}) { - my $checkedon = ''; - my $checkedproc = ''; - my $currproctorkey = ''; - my $currprocdisplay = 'hidden'; - my $currdonetext = &mt('Done'); - my $checkedoff = ' checked="checked"'; - if ($currval =~ /^(?:\d+)_done$/) { - $checkedon = ' checked="checked"'; - $checkedoff = ''; - } elsif ($currval =~ /^(?:\d+)_done\:([^\:]+)\:$/) { - $currdonetext = $1; - $checkedon = ' checked="checked"'; - $checkedoff = ''; - } elsif ($currval =~ /^(?:\d+)_done_proctor_(.+)$/) { - $currproctorkey = $1; - $checkedproc = ' checked="checked"'; - $checkedoff = ''; - $currprocdisplay = 'text'; - } elsif ($currval =~ /^(?:\d+)_done\:([^\:]+)\:_proctor_(.+)$/) { - $currdonetext = $1; - $currproctorkey = $2; - $checkedproc = ' checked="checked"'; - $checkedoff = ''; - $currprocdisplay = 'text'; - } - my $onclick = ' onclick="toggleSecret(this.form,'."'done_','$thiskey'".');"'; - my $disabled; - if ($readonly) { - $disabled = ' disabled="disabled"'; - } - $result .= '
'.&mt('Include "done" button'). - ''.(' 'x2). - ''.(' 'x2). - ''. - '&').'"'.$disabled.' />
'. - ''.&mt('Button text').': '. - '&').'"'.$disabled.' />'; - } - } unless ($readonly) { $result .= ''; } @@ -3464,68 +3421,6 @@ sub default_selector { return ''; } -sub string_ip_selector { - my ($thiskey, $showval, $readonly) = @_; - my %access = ( - allow => [], - deny => [], - ); - if ($showval ne '') { - my @current; - if ($showval =~ /,/) { - @current = split(/,/,$showval); - } else { - @current = ($showval); - } - foreach my $item (@current) { - if ($item =~ /^\!([\[\]a-zA-Z\.\d\*\-]+)$/) { - push(@{$access{'deny'}},$1); - } elsif ($item =~ /^([\[\]a-zA-Z\.\d\*\-]+)$/) { - push(@{$access{'allow'}},$item); - } - } - } - if (!@{$access{'allow'}}) { - @{$access{'allow'}} = (''); - } - if (!@{$access{'deny'}}) { - @{$access{'deny'}} = (''); - } - my ($disabled,$addmore); - if ($readonly) { - $disabled=' disabled="disabled"'; - } else { - $addmore = "\n".''; - } - my $output = ' -'; - foreach my $acctype ('allow','deny') { - $output .= ' -'; - } - $output .= ' - -
'.&mt('Allow from').''.&mt('Deny from').'
-
-
'."\n"; - my $num = 0; - foreach my $curr (@{$access{$acctype}}) { - $output .= '
'; - if ($num > 0) { - $output .= ''.&mt('Remove').''; - } - $output .= '
'."\n"; - $num ++; - } - $output .= ' -
'.$addmore.' -
-
'."\n"; - return $output; -} - -{ - my %strings = ( 'string_yesno' @@ -3553,9 +3448,6 @@ my %strings = => [['yes','Yes'], ['notended','Yes, unless discussion ended'], ['no','No']], - 'string_ip' - => [['_allowfrom_','Hostname(s), or IP(s) from which access is allowed'], - ['_denyfrom_','Hostname(s) or IP(s) from which access is disallowed']], ); sub standard_string_options { @@ -3596,10 +3488,6 @@ sub string_selector { } } } - - if ($thistype eq 'string_ip') { - return &string_ip_selector($thiskey,$showval,$readonly); - } my ($result,$disabled); @@ -3654,63 +3542,27 @@ sub string_selector { return $result; } -sub oldversion_warning { - my ($name,$value,$chostname,$cmajor,$cminor,$needsrelease) = @_; - my $desc; - my %stringtypes = ( - type => 'string_questiontype', - lenient => 'string_lenient', - retrypartial => 'string_yesno', - discussvote => 'string_discussvote', - examcode => 'string_examcode', - ); - if (exists($stringtypes{$name})) { - if ($name eq 'examcode') { - $desc = $value; - } elsif (ref($strings{$stringtypes{$name}}) eq 'ARRAY') { - foreach my $possibilities (@{ $strings{$stringtypes{$name}} }) { - next unless (ref($possibilities) eq 'ARRAY'); - my ($parmval, $description) = @{ $possibilities }; - if ($parmval eq $value) { - $desc = $description; - last; - } - } - } - } elsif (($name eq 'printstartdate') || ($name eq 'printenddate')) { - my $now = time; - if ($value =~ /^\d+$/) { - if ($name eq 'printstartdate') { - if ($value > $now) { - $desc = &Apache::lonlocal::locallocaltime($value); - } - } elsif ($name eq 'printenddate') { - if ($value < $now) { - $desc = &Apache::lonlocal::locallocaltime($value); - } - } - } - } - my $standard_name = &standard_parameter_names($name); - return '

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

'; -} - -} - # # Shift all start and end dates by $shift # sub dateshift { - my ($shift)=@_; + my ($shift,$numchanges)=@_; my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'}; my $crs = $env{'course.'.$env{'request.course.id'}.'.num'}; + my $sec = $env{'request.course.sec'}; + my $secgrpregex; + if ($sec ne '') { + my @groups; + if ($env{'request.course.groups'} ne '') { + @groups = split(/:/,$env{'request.course.groups'}); + } + if (@groups) { + $secgrpregex = '(?:'.join('|',($sec,@groups)).')'; + } else { + $secgrpregex = $sec; + } + } my %data=&Apache::lonnet::dump('resourcedata',$dom,$crs); # ugly retro fix for broken version of types foreach my $key (keys %data) { @@ -3725,7 +3577,11 @@ sub dateshift { # go through all parameters and look for dates foreach my $key (keys %data) { if ($data{$key.'.type'}=~/^date_(start|end)$/) { + if ($sec ne '') { + next unless ($key =~ /^$env{'request.course.id'}\.\[$secgrpregex\]\./); + } my $newdate=$data{$key}+$shift; + $$numchanges ++; $storecontent{$key}=$newdate; } } @@ -3759,7 +3615,6 @@ sub newoverview { '. &Apache::lonhtmlcommon::resize_scrollbox_js('params')."\n". &showhide_js()."\n". - &done_proctor_js()."\n". '// ]]> '; @@ -3949,19 +3804,13 @@ sub overview { my ($r,$parm_permission) = @_; my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'}; my $crs = $env{'course.'.$env{'request.course.id'}.'.num'}; - my $crstype = $env{'course.'.$env{'request.course.id'}.'.type'}; - my $js = ''."\n"; my $readonly = 1; if ($parm_permission->{'edit'}) { undef($readonly); } &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=setoverview', text=>"Overview Mode"}); - my $start_page=&Apache::loncommon::start_page('Modify Parameters',$js); + my $start_page=&Apache::loncommon::start_page('Modify Parameters'); my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs('Overview'); $r->print($start_page.$breadcrumbs); $r->print('
'); @@ -4091,9 +3940,21 @@ sub date_shift_one { my ($r) = @_; my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'}; my $crs = $env{'course.'.$env{'request.course.id'}.'.num'}; - + my $sec = $env{'request.course.sec'}; &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=dateshift1&timebase='.$env{'form.timebase'}, text=>"Shifting Dates"}); + my $submit_text = &mt('Shift all dates accordingly'); + if ($sec ne '') { + my @groups; + if ($env{'request.course.groups'} ne '') { + @groups = split(/:/,$env{'request.course.groups'}); + } + if (@groups) { + $submit_text = &mt("Shift dates set just for your section/group(s), accordingly"); + } else { + $submit_text = &mt("Shift dates set just for your section, accordingly"); + } + } my $start_page=&Apache::loncommon::start_page('Shift Dates'); my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs('Shift'); $r->print($start_page.$breadcrumbs); @@ -4108,7 +3969,7 @@ sub date_shift_one { ''. ''. ''. - '
'); + ''); $r->print(&Apache::loncommon::end_page()); } @@ -4116,20 +3977,54 @@ sub date_shift_two { my ($r) = @_; my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'}; my $crs = $env{'course.'.$env{'request.course.id'}.'.num'}; + my $sec = $env{'request.course.sec'}; &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($start_page.$breadcrumbs); my $timeshifted=&Apache::lonhtmlcommon::get_date_from_form('timeshifted'); - $r->print('

'.&mt('Shift Dates').'

'. - '

'.&mt('Shifting all dates such that [_1] becomes [_2]', - &Apache::lonlocal::locallocaltime($env{'form.timebase'}), - &Apache::lonlocal::locallocaltime($timeshifted)).'

'); + $r->print('

'.&mt('Shift Dates').'

'); + if ($sec ne '') { + my @groups; + if ($env{'request.course.groups'} ne '') { + @groups = split(/:/,$env{'request.course.groups'}); + } + if (@groups) { + $r->print('

'. + &mt("Shift dates set just for your section/group(s), such that [_1] becomes [_2]", + &Apache::lonlocal::locallocaltime($env{'form.timebase'}), + &Apache::lonlocal::locallocaltime($timeshifted)). + '

'); + } else { + $r->print('

'. + &mt("Shift dates set just for your section, such that [_1] becomes [_2]", + &Apache::lonlocal::locallocaltime($env{'form.timebase'}), + &Apache::lonlocal::locallocaltime($timeshifted)). + '

'); + } + } else { + $r->print('

'.&mt('Shifting all dates such that [_1] becomes [_2]', + &Apache::lonlocal::locallocaltime($env{'form.timebase'}), + &Apache::lonlocal::locallocaltime($timeshifted)). + '

'); + } my $delta=$timeshifted-$env{'form.timebase'}; - &dateshift($delta); + my $numchanges = 0; + my $result = &dateshift($delta,\$numchanges); + if ($result eq 'ok') { + $r->print( + &Apache::lonhtmlcommon::confirm_success(&mt('Completed shifting of [quant,_1,date setting]', + $numchanges))); + } elsif ($result eq 'con_delayed') { + $r->print( + &Apache::lonhtmlcommon::confirm_success(&mt('Queued shifting of [quant,_1,date setting]', + $numchanges))); + } else { + $r->print( + &Apache::lonhtmlcommon::confirm_success(&mt('An error occurred attempting to shift dates'),1)); + } $r->print( - &Apache::lonhtmlcommon::confirm_success(&mt('Done')). '

'. &Apache::lonhtmlcommon::actionbox( [''.&mt('Content and Problem Settings').''])); @@ -4944,6 +4839,12 @@ sub parm_change_log { } if ($last) { ($folder) = &Apache::lonnet::decode_symb($last); } } + my $numgroups = 0; + my @groups; + if ($env{'request.course.groups'} ne '') { + @groups = split(/:/,$env{'request.course.groups'}); + $numgroups = scalar(@groups); + } foreach my $id (sort { if ($parmlog{$b}{'exe_time'} ne $parmlog{$a}{'exe_time'}) { @@ -4984,7 +4885,8 @@ sub parm_change_log { my ($realm,$section,$parmname,$part,$what,$middle,$uname,$udom,$issection,$realmdescription)= &components($changed,$parmlog{$id}{'uname'},$parmlog{$id}{'udom'},undef,undef,$typeflag); if ($env{'request.course.sec'} ne '') { - next if (($issection ne '') && ($issection ne $env{'request.course.sec'})); + next if (($issection ne '') && (!(($issection eq $env{'request.course.sec'}) || + ($numgroups && (grep(/^\Q$issection\E$/,@groups)))))); if ($uname ne '') { my $stusection = &Apache::lonnet::getsection($uname,$udom,$env{'request.course.id'}); next if (($stusection ne '-1') && ($stusection ne $env{'request.course.sec'})); @@ -5206,6 +5108,53 @@ sub parameter_releasecheck { return $needsnewer; } +sub oldversion_warning { + my ($name,$value,$chostname,$cmajor,$cminor,$needsrelease) = @_; + my $desc; + my %stringtypes = ( + type => 'string_questiontype', + lenient => 'string_lenient', + retrypartial => 'string_yesno', + discussvote => 'string_discussvote', + examcode => 'string_examcode', + ); + if (exists($stringtypes{$name})) { + if ($name eq 'examcode') { + $desc = $value; + } elsif (ref($strings{$stringtypes{$name}}) eq 'ARRAY') { + foreach my $possibilities (@{ $strings{$stringtypes{$name}} }) { + next unless (ref($possibilities) eq 'ARRAY'); + my ($parmval, $description) = @{ $possibilities }; + if ($parmval eq $value) { + $desc = $description; + last; + } + } + } + } elsif (($name eq 'printstartdate') || ($name eq 'printenddate')) { + my $now = time; + if ($value =~ /^\d+$/) { + if ($name eq 'printstartdate') { + if ($value > $now) { + $desc = &Apache::lonlocal::locallocaltime($value); + } + } elsif ($name eq 'printenddate') { + if ($value < $now) { + $desc = &Apache::lonlocal::locallocaltime($value); + } + } + } + } + my $standard_name = &standard_parameter_names($name); + return '

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

'; +} + sub get_permission { my %permission; my $allowed = 0;