version 1.222, 2005/06/14 15:43:54
|
version 1.261, 2005/10/17 21:33:52
|
Line 251 sub rulescache {
|
Line 251 sub rulescache {
|
if ($rulesid ne $env{'request.course.id'}) { |
if ($rulesid ne $env{'request.course.id'}) { |
%rules=(); |
%rules=(); |
} |
} |
unless ($rules{$id}) { |
unless (defined($rules{$id})) { |
my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'}; |
my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'}; |
my $crs = $env{'course.'.$env{'request.course.id'}.'.num'}; |
my $crs = $env{'course.'.$env{'request.course.id'}.'.num'}; |
my %rules=&Apache::lonnet::dump('parmdefactions',$dom,$crs); |
%rules=&Apache::lonnet::dump('parmdefactions',$dom,$crs); |
$rulesid=$env{'request.course.id'}; |
$rulesid=$env{'request.course.id'}; |
} |
} |
return $rules{$id}; |
return $rules{$id}; |
} |
} |
|
|
|
sub preset_defaults { |
|
my $type=shift; |
|
if (&rulescache($type.'_action') eq 'default') { |
|
# yes, there is something |
|
return (&rulescache($type.'_hours'), |
|
&rulescache($type.'_min'), |
|
&rulescache($type.'_sec'), |
|
&rulescache($type.'_value')); |
|
} else { |
|
# nothing there or something else |
|
return ('','','','',''); |
|
} |
|
} |
|
|
################################################## |
################################################## |
################################################## |
################################################## |
# |
# |
Line 291 sub storeparm {
|
Line 305 sub storeparm {
|
# - username |
# - username |
# - userdomain |
# - userdomain |
|
|
|
my %recstack; |
sub storeparm_by_symb { |
sub storeparm_by_symb { |
|
my ($symb,$spnam,$snum,$nval,$ntype,$uname,$udom,$csec,$recflag)=@_; |
|
unless ($recflag) { |
|
# first time call |
|
%recstack=(); |
|
$recflag=1; |
|
} |
|
# store parameter |
|
&storeparm_by_symb_inner |
|
($symb,$spnam,$snum,$nval,$ntype,$uname,$udom,$csec); |
|
my ($prefix,$parm)=($spnam=~/^(.*[\_\.])([^\_\.]+)$/); |
|
# remember that this was set |
|
$recstack{$parm}=1; |
|
# what does this trigger? |
|
foreach my $triggered (split(/\:/,&rulescache($parm.'_triggers'))) { |
|
# don't backfire |
|
unless ((!$triggered) || ($recstack{$triggered})) { |
|
my $action=&rulescache($triggered.'_action'); |
|
my ($whichaction,$whichparm)=($action=~/^(.*\_)([^\_]+)$/); |
|
# set triggered parameter on same level |
|
my $newspnam=$prefix.$triggered; |
|
my $newvalue=''; |
|
my $active=1; |
|
if ($action=~/^when\_setting/) { |
|
# are there restrictions? |
|
if (&rulescache($triggered.'_triggervalue')=~/\w/) { |
|
$active=0; |
|
foreach my $possiblevalue (split(/\s*\,\s*/,&rulescache($triggered.'_triggervalue'))) { |
|
if (lc($possiblevalue) eq lc($nval)) { $active=1; } |
|
} |
|
} |
|
$newvalue=&rulescache($triggered.'_value'); |
|
} else { |
|
my $totalsecs=((&rulescache($triggered.'_days')*24+&rulescache($triggered.'_hours'))*60+&rulescache($triggered.'_min'))*60+&rulescache($triggered.'_sec'); |
|
if ($action=~/^later\_than/) { |
|
$newvalue=$nval+$totalsecs; |
|
} else { |
|
$newvalue=$nval-$totalsecs; |
|
} |
|
} |
|
if ($active) { |
|
&storeparm_by_symb($symb,$newspnam,$snum,$newvalue,&rulescache($triggered.'_type'), |
|
$uname,$udom,$csec,$recflag); |
|
} |
|
} |
|
} |
|
return ''; |
|
} |
|
|
|
sub storeparm_by_symb_inner { |
# ---------------------------------------------------------- Get symb, map, etc |
# ---------------------------------------------------------- Get symb, map, etc |
my ($symb,$spnam,$snum,$nval,$ntype,$uname,$udom,$csec)=@_; |
my ($symb,$spnam,$snum,$nval,$ntype,$uname,$udom,$csec)=@_; |
# ---------------------------------------------------------- Construct prefixes |
# ---------------------------------------------------------- Construct prefixes |
Line 460 sub plink {
|
Line 524 sub plink {
|
$winvalue=$env{'form.recent_'.(split(/\_/,$type))[0]}; |
$winvalue=$env{'form.recent_'.(split(/\_/,$type))[0]}; |
} |
} |
} |
} |
|
my ($parmname)=((split(/\&/,$marker))[1]=~/\_([^\_]+)$/); |
|
my ($hour,$min,$sec,$val)=&preset_defaults($parmname); |
|
unless (defined($winvalue)) { $winvalue=$val; } |
return |
return |
'<a href="javascript:pjump('."'".$type."','".$dis."','".$winvalue."','" |
'<a href="javascript:pjump('."'".$type."','".$dis."','".$winvalue."','" |
.$marker."','".$return."','".$call."'".');">'. |
.$marker."','".$return."','".$call."','".$hour."','".$min."','".$sec."'".');">'. |
&valout($value,$type).'</a><a name="'.$marker.'"></a>'; |
&valout($value,$type).'</a><a name="'.$marker.'"></a>'; |
} |
} |
|
|
Line 564 sub print_row {
|
Line 629 sub print_row {
|
} else { |
} else { |
$parm=~s|\[.*\]\s||g; |
$parm=~s|\[.*\]\s||g; |
} |
} |
|
my $automatic=&rulescache(($which=~/\_([^\_]+)$/)[0].'_triggers'); |
|
if ($automatic) { |
|
$parm.='<font color="red"><br />'.&mt('Automatically sets').' '.join(', ',split(/\:/,$automatic)).'</font>'; |
|
} |
$r->print('<td bgcolor='.$defbgone.'>'.$parm.'</td>'); |
$r->print('<td bgcolor='.$defbgone.'>'.$parm.'</td>'); |
|
|
my $thismarker=$which; |
my $thismarker=$which; |
Line 836 ENDSCRIPT
|
Line 904 ENDSCRIPT
|
$r->print("\n<table><tr>"); |
$r->print("\n<table><tr>"); |
my $cnt=0; |
my $cnt=0; |
foreach $tempkey (&keysindisplayorder($allparms,$keyorder)) { |
foreach $tempkey (&keysindisplayorder($allparms,$keyorder)) { |
$r->print("\n<td><font size='-1'><input type='checkbox' name='pscat' "); |
$r->print("\n<td><font size='-1'><label><input type='checkbox' name='pscat' "); |
$r->print('value="'.$tempkey.'"'); |
$r->print('value="'.$tempkey.'"'); |
if ($$pscat[0] eq "all" || grep $_ eq $tempkey, @{$pscat}) { |
if ($$pscat[0] eq "all" || grep $_ eq $tempkey, @{$pscat}) { |
$r->print(' checked'); |
$r->print(' checked'); |
} |
} |
$r->print('>'.$$allparms{$tempkey}.'</font></td>'); |
$r->print('>'.$$allparms{$tempkey}.'</label></font></td>'); |
$cnt++; |
$cnt++; |
if ($cnt==3) { |
if ($cnt==3) { |
$r->print("</tr>\n<tr>"); |
$r->print("</tr>\n<tr>"); |
Line 850 ENDSCRIPT
|
Line 918 ENDSCRIPT
|
} |
} |
$r->print(' |
$r->print(' |
</tr><tr><td> |
</tr><tr><td> |
<a href="javascript:checkall(true, \'pscat\')">Select All</a><br /> |
<a href="javascript:checkall(true, \'pscat\')">Select All</a><br /> |
<a href="javascript:checkstandard()">Select Common Only</a> |
<a href="javascript:checkstandard()">Select Common Only</a> |
</td><td> |
</td><td> |
<a href="javascript:checkdates()">Add Problem Dates</a> |
<a href="javascript:checkdates()">Add Problem Dates</a> |
<a href="javascript:checkcontdates()">Add Content Dates</a><br /> |
<a href="javascript:checkcontdates()">Add Content Dates</a><br /> |
<a href="javascript:checkdisset()">Add Discussion Settings</a> |
<a href="javascript:checkdisset()">Add Discussion Settings</a> |
<a href="javascript:checkvisi()">Add Visibilities</a><br /> |
<a href="javascript:checkvisi()">Add Visibilities</a><br /> |
<a href="javascript:checkparts()">Add Part Parameters</a> |
<a href="javascript:checkparts()">Add Part Parameters</a> |
</td><td> |
</td><td> |
<a href="javascript:checkall(false, \'pscat\')">Unselect All</a> |
<a href="javascript:checkall(false, \'pscat\')">Unselect All</a> |
</td> |
</td> |
'); |
'); |
$r->print('</tr></table>'); |
$r->print('</tr></table>'); |
Line 873 sub partmenu {
|
Line 941 sub partmenu {
|
$r->print('>'.&mt('All Parts').'</option>'); |
$r->print('>'.&mt('All Parts').'</option>'); |
my %temphash=(); |
my %temphash=(); |
foreach (@{$psprt}) { $temphash{$_}=1; } |
foreach (@{$psprt}) { $temphash{$_}=1; } |
foreach my $tempkey (sort keys %{$allparts}) { |
foreach my $tempkey (sort { |
|
if ($a==$b) { return ($a cmp $b) } else { return ($a <=> $b); } |
|
} keys(%{$allparts})) { |
unless ($tempkey =~ /\./) { |
unless ($tempkey =~ /\./) { |
$r->print('<option value="'.$tempkey.'"'); |
$r->print('<option value="'.$tempkey.'"'); |
if ($$psprt[0] eq "all" || $temphash{$tempkey}) { |
if ($$psprt[0] eq "all" || $temphash{$tempkey}) { |
Line 935 sub displaymenu {
|
Line 1005 sub displaymenu {
|
|
|
sub mapmenu { |
sub mapmenu { |
my ($r,$allmaps,$pschp,$maptitles)=@_; |
my ($r,$allmaps,$pschp,$maptitles)=@_; |
$r->print(&mt('Select Enclosing Map or Folder').' '); |
$r->print('<b>'.&mt('Select Enclosing Map or Folder').'</b> '); |
$r->print('<select name="pschp">'); |
$r->print('<select name="pschp">'); |
$r->print('<option value="all">'.&mt('All Maps or Folders').'</option>'); |
$r->print('<option value="all">'.&mt('All Maps or Folders').'</option>'); |
foreach (sort {$$allmaps{$a} cmp $$allmaps{$b}} keys %{$allmaps}) { |
foreach (sort {$$allmaps{$a} cmp $$allmaps{$b}} keys %{$allmaps}) { |
Line 948 sub mapmenu {
|
Line 1018 sub mapmenu {
|
|
|
sub levelmenu { |
sub levelmenu { |
my ($r,$alllevs,$parmlev)=@_; |
my ($r,$alllevs,$parmlev)=@_; |
$r->print(&mt('Select Parameter Level'). |
$r->print('<b>'.&mt('Select Parameter Level'). |
&Apache::loncommon::help_open_topic('Course_Parameter_Levels').' '); |
&Apache::loncommon::help_open_topic('Course_Parameter_Levels').'</b> '); |
$r->print('<select name="parmlev">'); |
$r->print('<select name="parmlev">'); |
foreach (reverse sort keys %{$alllevs}) { |
foreach (reverse sort keys %{$alllevs}) { |
$r->print('<option value="'.$$alllevs{$_}.'"'); |
$r->print('<option value="'.$$alllevs{$_}.'"'); |
Line 997 sub keysinorder {
|
Line 1067 sub keysinorder {
|
} (keys %{$name}); |
} (keys %{$name}); |
} |
} |
|
|
|
sub keysinorder_bytype { |
|
my ($name,$keyorder)=@_; |
|
return sort { |
|
my $ta=(split('_',$a))[-1]; |
|
my $tb=(split('_',$b))[-1]; |
|
if ($$keyorder{'parameter_0_'.$ta} == $$keyorder{'parameter_0_'.$tb}) { |
|
return ($a cmp $b); |
|
} |
|
$$keyorder{'parameter_0_'.$ta} <=> $$keyorder{'parameter_0_'.$tb}; |
|
} (keys %{$name}); |
|
} |
|
|
sub keysindisplayorder { |
sub keysindisplayorder { |
my ($name,$keyorder)=@_; |
my ($name,$keyorder)=@_; |
return sort { |
return sort { |
Line 1006 sub keysindisplayorder {
|
Line 1088 sub keysindisplayorder {
|
|
|
sub sortmenu { |
sub sortmenu { |
my ($r,$sortorder)=@_; |
my ($r,$sortorder)=@_; |
$r->print('<br /><input type="radio" name="sortorder" value="realmstudent"'); |
$r->print('<br /><label><input type="radio" name="sortorder" value="realmstudent"'); |
if ($sortorder eq 'realmstudent') { |
if ($sortorder eq 'realmstudent') { |
$r->print(' checked="on"'); |
$r->print(' checked="on"'); |
} |
} |
$r->print(' />'.&mt('Sort by realm first, then student (group/section)')); |
$r->print(' />'.&mt('Sort by realm first, then student (group/section)')); |
$r->print('<br /><input type="radio" name="sortorder" value="studentrealm"'); |
$r->print('</label><br /><label><input type="radio" name="sortorder" value="studentrealm"'); |
if ($sortorder eq 'studentrealm') { |
if ($sortorder eq 'studentrealm') { |
$r->print(' checked="on"'); |
$r->print(' checked="on"'); |
} |
} |
$r->print(' />'.&mt('Sort by student (group/section) first, then realm')); |
$r->print(' />'.&mt('Sort by student (group/section) first, then realm'). |
|
'</label>'); |
} |
} |
|
|
sub standardkeyorder { |
sub standardkeyorder { |
Line 1247 sub assessparms {
|
Line 1330 sub assessparms {
|
} else { |
} else { |
my ($map,$id,$resource)=&Apache::lonnet::decode_symb($pssymb); |
my ($map,$id,$resource)=&Apache::lonnet::decode_symb($pssymb); |
$r->print(&mt('Specific Resource').": ".$resource. |
$r->print(&mt('Specific Resource').": ".$resource. |
'<input type="hidden" value="'.$pssymb.'" name="symb"><br />'); |
'<input type="hidden" value="'.$pssymb.'" name="symb">'. |
|
'<br /><label><b>'.&mt('Show all parts').': <input type="checkbox" name="psprt" value="all"'. |
|
($env{'form.psprt'}?' checked="checked"':'').' /></b></label><br />'); |
} |
} |
&usermenu($r,$uname,$id,$udom,$csec); |
&usermenu($r,$uname,$id,$udom,$csec); |
|
|
Line 1392 ENDTABLEHEADFOUR
|
Line 1477 ENDTABLEHEADFOUR
|
|
|
$r->print('<td bgcolor='.$defbgone. |
$r->print('<td bgcolor='.$defbgone. |
' rowspan='.$totalparms. |
' rowspan='.$totalparms. |
'><tt><font size=-1>'); |
'>'.$maptitles{$mapp{$rid}}.'</td>'); |
|
|
$r->print(' / res / '); |
foreach (&keysinorder_bytype(\%name,\%keyorder)) { |
$r->print(join(' / ', split(/\//,$mapp{$rid}))); |
|
|
|
$r->print('</font></tt></td>'); |
|
|
|
foreach (&keysinorder(\%name,\%keyorder)) { |
|
unless ($firstrow) { |
unless ($firstrow) { |
$r->print('<tr>'); |
$r->print('<tr>'); |
} else { |
} else { |
Line 1689 sub crsenv {
|
Line 1769 sub crsenv {
|
# |
# |
# Let the user know we made the changes |
# Let the user know we made the changes |
if ($name && defined($value)) { |
if ($name && defined($value)) { |
|
my $failed_cloners; |
if ($name eq 'cloners') { |
if ($name eq 'cloners') { |
|
$value =~ s/\s//g; |
$value =~ s/^,//; |
$value =~ s/^,//; |
$value =~ s/,$//; |
$value =~ s/,$//; |
|
# check requested clones are valid users. |
|
$failed_cloners = &check_cloners(\$value,\@oldcloner); |
} |
} |
my $put_result = &Apache::lonnet::put('environment', |
my $put_result = &Apache::lonnet::put('environment', |
{$name=>$value},$dom,$crs); |
{$name=>$value},$dom,$crs); |
Line 1708 sub crsenv {
|
Line 1792 sub crsenv {
|
$setoutput.=&mt('Unable to set').' <b>'.$name.'</b> '.&mt('to'). |
$setoutput.=&mt('Unable to set').' <b>'.$name.'</b> '.&mt('to'). |
' <b>'.$value.'</b> '.&mt('due to').' '.$put_result.'.<br />'; |
' <b>'.$value.'</b> '.&mt('due to').' '.$put_result.'.<br />'; |
} |
} |
|
if (($name eq 'cloners') && ($failed_cloners)) { |
|
$setoutput.= &mt('Unable to include').' - <b>'.$failed_cloners.'</b>, '. |
|
&mt('reason').' - '.&mt('LON-CAPA user(s) do(es) not exist'). |
|
'.<br />'.&mt('Please '). |
|
' <a href="/adm/createuser">'. |
|
&mt('add the user(s)').'</a>, '. |
|
&mt('and then return to the '). |
|
'<a href="/admparmset?action=crsenv">'. |
|
&mt('Course Parameters page').'</a> '. |
|
&mt('to add the new user(s) to the list of possible cloners'). |
|
'.<br />'; |
|
} |
} |
} |
} |
} |
# ------------------------- Re-init course environment entries for this session |
# ------------------------- Re-init course environment entries for this session |
Line 1825 sub crsenv {
|
Line 1921 sub crsenv {
|
'disablesigfigs' |
'disablesigfigs' |
=> '<b>'.&mt('Disable checking of Significant Figures').'</b><br />'. |
=> '<b>'.&mt('Disable checking of Significant Figures').'</b><br />'. |
' ('.&mt('"[_1]" to disable, anything else if not','<tt>yes</tt>').')', |
' ('.&mt('"[_1]" to disable, anything else if not','<tt>yes</tt>').')', |
|
'disableexampointprint' |
|
=> '<b>'.&mt('Disable automatically printing point values onto exams.').'</b><br />'. |
|
' ('.&mt('"[_1]" to disable, anything else if not','<tt>yes</tt>').')', |
'tthoptions' |
'tthoptions' |
=> '<b>'.&mt('Default set of options to pass to tth/m when converting tex').'</b>' |
=> '<b>'.&mt('Default set of options to pass to tth/m when converting tex').'</b>' |
); |
); |
Line 1851 sub crsenv {
|
Line 1950 sub crsenv {
|
'default_enrollment_start_date', |
'default_enrollment_start_date', |
'default_enrollment_end_date', |
'default_enrollment_end_date', |
'tthoptions', |
'tthoptions', |
'disablesigfigs' |
'disablesigfigs', |
|
'disableexampointprint' |
); |
); |
foreach my $parameter (sort(keys(%values))) { |
foreach my $parameter (sort(keys(%values))) { |
unless ($parameter =~ m/^internal\./) { |
unless (($parameter =~ m/^internal\./)||($parameter =~ m/^metadata\./)) { |
if (! $descriptions{$parameter}) { |
if (! $descriptions{$parameter}) { |
$descriptions{$parameter}=$parameter; |
$descriptions{$parameter}=$parameter; |
push(@Display_Order,$parameter); |
push(@Display_Order,$parameter); |
Line 2093 sub listdata {
|
Line 2193 sub listdata {
|
my $pointer=0; |
my $pointer=0; |
$tableopen=0; |
$tableopen=0; |
my $foundkeys=0; |
my $foundkeys=0; |
|
my %keyorder=&standardkeyorder(); |
foreach my $thiskey (sort { |
foreach my $thiskey (sort { |
if ($sortorder eq 'realmstudent') { |
if ($sortorder eq 'realmstudent') { |
my ($astudent,$arealm)=($a=~/^$env{'request.course.id'}\.([^\.]+)\.(.+)\.[^\.]+$/); |
my ($astudent,$arealm)=($a=~/^\Q$env{'request.course.id'}\E\.\[([^\.]+)\]\.(.+)\.[^\.]+$/); |
my ($bstudent,$brealm)=($b=~/^$env{'request.course.id'}\.([^\.]+)\.(.+)\.[^\.]+$/); |
my ($bstudent,$brealm)=($b=~/^\Q$env{'request.course.id'}\E\.\[([^\.]+)\]\.(.+)\.[^\.]+$/); |
($arealm cmp $brealm) || ($astudent cmp $bstudent); |
if (!defined($astudent)) { |
|
($arealm)=($a=~/^\Q$env{'request.course.id'}\E\.(.+)$/); |
|
} |
|
if (!defined($bstudent)) { |
|
($brealm)=($b=~/^\Q$env{'request.course.id'}\E\.(.+)$/); |
|
} |
|
$arealm=~s/\.type//; |
|
my ($ares, $aparm) = ($arealm=~/^(.*)\.(.*)$/); |
|
$aparm=$keyorder{'parameter_0_'.$aparm}; |
|
$brealm=~s/\.type//; |
|
my ($bres, $bparm) = ($brealm=~/^(.*)\.(.*)$/); |
|
$bparm=$keyorder{'parameter_0_'.$bparm}; |
|
if ($ares eq $bres) { |
|
if (defined($aparm) && defined($bparm)) { |
|
($aparm <=> $bparm); |
|
} elsif (defined($aparm)) { |
|
-1; |
|
} elsif (defined($bparm)) { |
|
1; |
|
} else { |
|
($arealm cmp $brealm) || ($astudent cmp $bstudent); |
|
} |
|
} else { |
|
($arealm cmp $brealm) || ($astudent cmp $bstudent); |
|
} |
} else { |
} else { |
$a cmp $b; |
$a cmp $b; |
} |
} |
} keys %{$listdata}) { |
} keys %{$listdata}) { |
|
|
if ($$listdata{$thiskey.'.type'}) { |
if ($$listdata{$thiskey.'.type'}) { |
my $thistype=$$listdata{$thiskey.'.type'}; |
my $thistype=$$listdata{$thiskey.'.type'}; |
if ($$resourcedata{$thiskey.'.type'}) { |
if ($$resourcedata{$thiskey.'.type'}) { |
Line 2157 sub listdata {
|
Line 2283 sub listdata {
|
$oldpart=$part; |
$oldpart=$part; |
} |
} |
# |
# |
|
# Preset defaults? |
|
# |
|
my ($hour,$min,$sec,$val)=('','','',''); |
|
unless ($$resourcedata{$thiskey}) { |
|
my ($parmname)=($thiskey=~/\.(\w+)$/); |
|
($hour,$min,$sec,$val)=&preset_defaults($parmname); |
|
} |
|
|
|
# |
# Ready to print |
# Ready to print |
# |
# |
$r->print(&tablestart().'<tr><td><b>'.$name. |
$r->print(&tablestart().'<tr><td><b>'.$name. |
Line 2167 sub listdata {
|
Line 2302 sub listdata {
|
my $jskey='key_'.$pointer; |
my $jskey='key_'.$pointer; |
$pointer++; |
$pointer++; |
$r->print( |
$r->print( |
&Apache::lonhtmlcommon::date_setter('overviewform', |
&Apache::lonhtmlcommon::date_setter('parmform', |
$jskey, |
$jskey, |
$$resourcedata{$thiskey}, |
$$resourcedata{$thiskey}, |
'',1). |
'',1,'','',$hour,$min,$sec). |
'<input type="hidden" name="datepointer_'.$thiskey.'" value="'.$jskey.'" />' |
'<input type="hidden" name="datepointer_'.$thiskey.'" value="'.$jskey.'" />' |
); |
); |
} elsif ($thistype eq 'string_yesno') { |
} elsif ($thistype eq 'string_yesno') { |
|
my $showval; |
|
if (defined($$resourcedata{$thiskey})) { |
|
$showval=$$resourcedata{$thiskey}; |
|
} else { |
|
$showval=$val; |
|
} |
$r->print('<label><input type="radio" name="set_'.$thiskey. |
$r->print('<label><input type="radio" name="set_'.$thiskey. |
'" value="yes"'); |
'" value="yes"'); |
if ($$resourcedata{$thiskey} eq 'yes') { |
if ($showval eq 'yes') { |
$r->print(' checked="checked"'); |
$r->print(' checked="checked"'); |
} |
} |
$r->print(' />'.&mt('Yes').'</label> '); |
$r->print(' />'.&mt('Yes').'</label> '); |
$r->print('<label><input type="radio" name="set_'.$thiskey. |
$r->print('<label><input type="radio" name="set_'.$thiskey. |
'" value="no"'); |
'" value="no"'); |
if ($$resourcedata{$thiskey} eq 'no') { |
if ($showval eq 'no') { |
$r->print(' checked="checked"'); |
$r->print(' checked="checked"'); |
} |
} |
$r->print(' />'.&mt('No').'</label>'); |
$r->print(' />'.&mt('No').'</label>'); |
} else { |
} else { |
|
my $showval; |
|
if (defined($$resourcedata{$thiskey})) { |
|
$showval=$$resourcedata{$thiskey}; |
|
} else { |
|
$showval=$val; |
|
} |
$r->print('<input type="text" name="set_'.$thiskey.'" value="'. |
$r->print('<input type="text" name="set_'.$thiskey.'" value="'. |
$$resourcedata{$thiskey}.'">'); |
$showval.'">'); |
} |
} |
$r->print('<input type="hidden" name="typeof_'.$thiskey.'" value="'. |
$r->print('<input type="hidden" name="typeof_'.$thiskey.'" value="'. |
$thistype.'">'); |
$thistype.'">'); |
Line 2357 $html
|
Line 2504 $html
|
</head> |
</head> |
$bodytag |
$bodytag |
$breadcrumbs |
$breadcrumbs |
<form method="post" action="/adm/parmset?action=setoverview" name="overviewform"> |
<form method="post" action="/adm/parmset?action=setoverview" name="parmform"> |
ENDOVER |
ENDOVER |
# Store modified |
# Store modified |
|
|
Line 2384 ENDOVER
|
Line 2531 ENDOVER
|
################################################## |
################################################## |
|
|
=pod |
=pod |
|
|
=item change clone |
=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 |
Modifies the list of courses a user can clone (stored |
in the user's environemnt.db file), called when a |
in the user's environment.db file), called when a |
change is made to the list of users allowed to clone |
change is made to the list of users allowed to clone |
a course. |
a course. |
|
|
Inputs: $action,$cloner |
Inputs: $action,$cloner |
where $action is add or drop, and $cloner is identity of |
where $action is add or drop, and $cloner is identity of |
user for whom cloning ability is to be changed in course. |
user for whom cloning ability is to be changed in course. |
|
|
Returns: |
|
|
|
=cut |
=cut |
|
|
################################################## |
################################################## |
################################################## |
################################################## |
|
|
|
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/^$currclone$/,@$oldcloner) { |
|
my ($uname,$udom) = split/:/,$currclone; |
|
if ($uname && $udom) { |
|
if (&Apache::lonnet::homeserver($uname,$udom) eq 'no_host') { |
|
$disallowed .= $currclone.','; |
|
} else { |
|
$clean_clonelist .= $currclone.','; |
|
} |
|
} |
|
} else { |
|
$clean_clonelist .= $currclone.','; |
|
} |
|
} |
|
if ($disallowed) { |
|
$disallowed =~ s/,$//; |
|
} |
|
if ($clean_clonelist) { |
|
$clean_clonelist =~ s/,$//; |
|
} |
|
$$clonelist = $clean_clonelist; |
|
return $disallowed; |
|
} |
|
|
sub change_clone { |
sub change_clone { |
my ($clonelist,$oldcloner) = @_; |
my ($clonelist,$oldcloner) = @_; |
Line 2412 sub change_clone {
|
Line 2610 sub change_clone {
|
my $clone_crs = $cnum.':'.$cdom; |
my $clone_crs = $cnum.':'.$cdom; |
|
|
if ($cnum && $cdom) { |
if ($cnum && $cdom) { |
my @allowclone = (); |
my @allowclone; |
if ($clonelist =~ /,/) { |
&extract_cloners($clonelist,\@allowclone); |
@allowclone = split/,/,$clonelist; |
|
} else { |
|
$allowclone[0] = $clonelist; |
|
} |
|
foreach my $currclone (@allowclone) { |
foreach my $currclone (@allowclone) { |
if (!grep/^$currclone$/,@$oldcloner) { |
if (!grep/^$currclone$/,@$oldcloner) { |
($uname,$udom) = split/:/,$currclone; |
($uname,$udom) = split/:/,$currclone; |
Line 2508 ENDMAINFORMHEAD
|
Line 2702 ENDMAINFORMHEAD
|
action => 'crsenv', |
action => 'crsenv', |
permission => $parm_permission, |
permission => $parm_permission, |
}, |
}, |
|
{ text => 'Set Portfolio Metadata', |
|
action => 'setrestrictmeta', |
|
permission => $parm_permission, |
|
}, |
{ text => 'Set/Modify Resource Parameters - Helper Mode', |
{ text => 'Set/Modify Resource Parameters - Helper Mode', |
url => '/adm/helper/parameter.helper', |
url => '/adm/helper/parameter.helper', |
permission => $parm_permission, |
permission => $parm_permission, |
Line 2551 ENDMAINFORMHEAD
|
Line 2749 ENDMAINFORMHEAD
|
$r->print($menu_html); |
$r->print($menu_html); |
return; |
return; |
} |
} |
|
### Set portfolio metadata |
|
sub output_row { |
|
my ($r, $field_name, $field_text) = @_; |
|
my $output; |
|
my $options=$env{'course.'.$env{'request.course.id'}.'.'.$field_name.'.options'}; |
|
my $values=$env{'course.'.$env{'request.course.id'}.'.'.$field_name.'.values'}; |
|
my $checked; |
|
unless (defined($options)) { |
|
$options = 'active,stuadd'; |
|
$values = ''; |
|
} |
|
$output.='<strong>'.$field_text.':</strong>'; |
|
$output.='<input name="'.$field_name.'_values" type="text" value="'.$values.'" /><br />'; |
|
if ($options =~ m/active/) { |
|
$checked = ' checked="checked" '; |
|
} else { |
|
$checked = ' '; |
|
} |
|
$output.=' <input type="checkbox" name="'.$field_name.'_active" value="yes"'.$checked.' />'; |
|
$output.='Show to student <br />'; |
|
if ($options =~ m/onlyone/) { |
|
$checked = ' checked="checked" '; |
|
} else { |
|
$checked = ' '; |
|
} |
|
$output.=' <input type="checkbox" name="'.$field_name.'_onlyone" value="yes"'.$checked.' />'; |
|
$output.='Student may select only one choice <br />'; |
|
if ($options =~ m/stuadd/) { |
|
$checked = ' checked="checked" '; |
|
} else { |
|
$checked = ' '; |
|
} |
|
$output.=' <input type="checkbox" name="'.$field_name.'_stuadd" value="yes"'.$checked.' />'; |
|
$output.='Student may type choices <br />'; |
|
return ($output); |
|
} |
|
|
|
sub setrestrictmeta { |
|
my ($r)=@_; |
|
my $next_meta; |
|
my $output; |
|
my $item_num; |
|
my $put_result; |
|
$r->print(&Apache::lonxml::xmlbegin()); |
|
$r->print('<head> |
|
<title>LON-CAPA Restrict Metadata</title> |
|
</head>'); |
|
$r->print(&Apache::loncommon::bodytag('Restrict Metadata')); |
|
$r->print(&Apache::lonhtmlcommon::breadcrumbs(undef, |
|
'Restrict Metadata')); |
|
my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'}; |
|
my $crs = $env{'course.'.$env{'request.course.id'}.'.num'}; |
|
my $key_base = $env{'course.'.$env{'request.course.id'}.'.'}; |
|
my $save_field = ''; |
|
if ($env{'form.restrictmeta'}) { |
|
foreach my $field (sort(keys(%env))) { |
|
if ($field=~m/^form.(.+)_(.+)$/) { |
|
my $options; |
|
my $meta_field = $1; |
|
my $meta_key = $2; |
|
if ($save_field ne $meta_field) { |
|
$save_field = $meta_field; |
|
if ($env{'form.'.$meta_field.'_stuadd'}) { |
|
$options.='stuadd,'; |
|
} |
|
if ($env{'form.'.$meta_field.'_onlyone'}) { |
|
$options.='onlyone,'; |
|
} |
|
if ($env{'form.'.$meta_field.'_active'}) { |
|
$options.='active,'; |
|
} |
|
my $name = $save_field; |
|
$put_result = &Apache::lonnet::put('environment', |
|
{$meta_field.'.options'=>$options, |
|
$meta_field.'.values'=>$env{'form.'.$meta_field.'_values'}, |
|
},$dom,$crs); |
|
} |
|
} |
|
} |
|
} |
|
&Apache::lonnet::coursedescription($env{'request.course.id'}); |
|
my %metadata_fields = &Apache::lonmeta::fieldnames('portfolio'); |
|
foreach my $field (sort(keys(%metadata_fields))) { |
|
$output.= &output_row($r, $field, $metadata_fields{$field}); |
|
} |
|
$r->print(<<ENDenv); |
|
<form method="post" action="/adm/parmset?action=setrestrictmeta" name="form"> |
|
<p> |
|
$output |
|
<input type="submit" name="restrictmeta" value="Update Metadata Restrictions"> |
|
</form> |
|
ENDenv |
|
$r->print('</body> |
|
</html>'); |
|
return 'ok'; |
|
} |
################################################## |
################################################## |
|
|
sub defaultsetter { |
sub defaultsetter { |
Line 2571 $bodytag
|
Line 2863 $bodytag
|
$breadcrumbs |
$breadcrumbs |
<form method="post" action="/adm/parmset?action=setdefaults" name="defaultform"> |
<form method="post" action="/adm/parmset?action=setdefaults" name="defaultform"> |
ENDDEFHEAD |
ENDDEFHEAD |
if ($env{'form.storerules'}) { |
|
# storage here |
|
&resetrulescache(); |
|
} |
|
my @ids=(); |
my @ids=(); |
my %typep=(); |
my %typep=(); |
my %keyp=(); |
my %keyp=(); |
Line 2591 ENDDEFHEAD
|
Line 2879 ENDDEFHEAD
|
&extractResourceInformation(\@ids, \%typep,\%keyp, \%allparms, \%allparts, \%allmaps, |
&extractResourceInformation(\@ids, \%typep,\%keyp, \%allparms, \%allparts, \%allmaps, |
\%mapp, \%symbp,\%maptitles,\%uris, |
\%mapp, \%symbp,\%maptitles,\%uris, |
\%keyorder,\%defkeytype); |
\%keyorder,\%defkeytype); |
my %lt=&Apache::lonlocal::texthash('hours' => 'Hours', |
if ($env{'form.storerules'}) { |
|
my %newrules=(); |
|
my @delrules=(); |
|
my %triggers=(); |
|
foreach my $key (keys(%env)) { |
|
if ($key=~/^form\.(\w+)\_action$/) { |
|
my $tempkey=$1; |
|
my $action=$env{$key}; |
|
if ($action) { |
|
$newrules{$tempkey.'_action'}=$action; |
|
if ($action ne 'default') { |
|
my ($whichaction,$whichparm)=($action=~/^(.*\_)([^\_]+)$/); |
|
$triggers{$whichparm}.=$tempkey.':'; |
|
} |
|
$newrules{$tempkey.'_type'}=$defkeytype{$tempkey}; |
|
if (&isdateparm($defkeytype{$tempkey})) { |
|
$newrules{$tempkey.'_days'}=$env{'form.'.$tempkey.'_days'}; |
|
$newrules{$tempkey.'_hours'}=$env{'form.'.$tempkey.'_hours'}; |
|
$newrules{$tempkey.'_min'}=$env{'form.'.$tempkey.'_min'}; |
|
$newrules{$tempkey.'_sec'}=$env{'form.'.$tempkey.'_sec'}; |
|
} else { |
|
$newrules{$tempkey.'_value'}=$env{'form.'.$tempkey.'_value'}; |
|
$newrules{$tempkey.'_triggervalue'}=$env{'form.'.$tempkey.'_triggervalue'}; |
|
} |
|
} else { |
|
push(@delrules,$tempkey.'_action'); |
|
push(@delrules,$tempkey.'_type'); |
|
push(@delrules,$tempkey.'_hours'); |
|
push(@delrules,$tempkey.'_min'); |
|
push(@delrules,$tempkey.'_sec'); |
|
push(@delrules,$tempkey.'_value'); |
|
} |
|
} |
|
} |
|
foreach my $key (keys %allparms) { |
|
$newrules{$key.'_triggers'}=$triggers{$key}; |
|
} |
|
&Apache::lonnet::put('parmdefactions',\%newrules,$dom,$crs); |
|
&Apache::lonnet::del('parmdefactions',\@delrules,$dom,$crs); |
|
&resetrulescache(); |
|
} |
|
my %lt=&Apache::lonlocal::texthash('days' => 'Days', |
|
'hours' => 'Hours', |
'min' => 'Minutes', |
'min' => 'Minutes', |
'sec' => 'Seconds', |
'sec' => 'Seconds', |
'yes' => 'Yes', |
'yes' => 'Yes', |
Line 2611 ENDDEFHEAD
|
Line 2941 ENDDEFHEAD
|
push @datedisplay,&mt('Automatically set earlier than ').$tempkey; |
push @datedisplay,&mt('Automatically set earlier than ').$tempkey; |
} |
} |
} |
} |
|
$r->print(&mt('Manual setting rules apply to all interfaces.').'<br />'. |
|
&mt('Automatic setting rules apply to table mode interfaces only.')); |
$r->print("\n<table border='1'><tr><th>".&mt('Rule for parameter').'</th><th>'. |
$r->print("\n<table border='1'><tr><th>".&mt('Rule for parameter').'</th><th>'. |
&mt('Action').'</th><th>'.&mt('Value').'</th></tr>'); |
&mt('Action').'</th><th>'.&mt('Value').'</th></tr>'); |
foreach my $tempkey (&keysindisplayorder(\%allparms,\%keyorder)) { |
foreach my $tempkey (&keysindisplayorder(\%allparms,\%keyorder)) { |
unless ($tempkey) { next; } |
unless ($tempkey) { next; } |
$r->print("\n<tr><td>".$allparms{$tempkey}."\n<br />(".$tempkey.')</td><td>'); |
$r->print("\n<tr><td>".$allparms{$tempkey}."\n<br />(".$tempkey.')</td><td>'); |
|
|
my $action=&rulescache($tempkey.'_action'); |
my $action=&rulescache($tempkey.'_action'); |
$r->print('<select name="'.$tempkey.'_action">'); |
$r->print('<select name="'.$tempkey.'_action">'); |
if (&isdateparm($defkeytype{$tempkey})) { |
if (&isdateparm($defkeytype{$tempkey})) { |
Line 2635 ENDDEFHEAD
|
Line 2966 ENDDEFHEAD
|
} |
} |
} |
} |
$r->print('</select>'); |
$r->print('</select>'); |
|
unless (&isdateparm($defkeytype{$tempkey})) { |
|
$r->print("\n<br />".&mt('Triggering value(s) of other parameter (optional, comma-separated):'). |
|
'<input type="text" size="20" name="'.$tempkey.'_triggervalue" value="'.&rulescache($tempkey.'_triggervalue').'" />'); |
|
} |
$r->print("\n</td><td>\n"); |
$r->print("\n</td><td>\n"); |
|
|
if (&isdateparm($defkeytype{$tempkey})) { |
if (&isdateparm($defkeytype{$tempkey})) { |
|
my $days=&rulescache($tempkey.'_days'); |
my $hours=&rulescache($tempkey.'_hours'); |
my $hours=&rulescache($tempkey.'_hours'); |
my $min=&rulescache($tempkey.'_min'); |
my $min=&rulescache($tempkey.'_min'); |
my $sec=&rulescache($tempkey.'_sec'); |
my $sec=&rulescache($tempkey.'_sec'); |
$r->print(<<ENDINPUTDATE); |
$r->print(<<ENDINPUTDATE); |
|
<input name="$tempkey\_days" type="text" size="4" value="$days" />$lt{'days'}<br /> |
<input name="$tempkey\_hours" type="text" size="4" value="$hours" />$lt{'hours'}<br /> |
<input name="$tempkey\_hours" type="text" size="4" value="$hours" />$lt{'hours'}<br /> |
<input name="$tempkey\_min" type="text" size="4" value="$min" />$lt{'min'}<br /> |
<input name="$tempkey\_min" type="text" size="4" value="$min" />$lt{'min'}<br /> |
<input name="$tempkey\_sec" type="text" size="4" value="$sec" />$lt{'sec'} |
<input name="$tempkey\_sec" type="text" size="4" value="$sec" />$lt{'sec'} |
Line 2655 ENDINPUTDATE
|
Line 2990 ENDINPUTDATE
|
if (&rulescache($tempkey.'_value') eq 'no') { $nochecked='checked="checked"'; } |
if (&rulescache($tempkey.'_value') eq 'no') { $nochecked='checked="checked"'; } |
|
|
$r->print(<<ENDYESNO); |
$r->print(<<ENDYESNO); |
<label><input type="radio" name="$tempkey" value="yes" $yeschecked /> $lt{'yes'}</label><br /> |
<label><input type="radio" name="$tempkey\_value" value="yes" $yeschecked /> $lt{'yes'}</label><br /> |
<label><input type="radio" name="$tempkey" value="no" $nochecked /> $lt{'no'}</label> |
<label><input type="radio" name="$tempkey\_value" value="no" $nochecked /> $lt{'no'}</label> |
ENDYESNO |
ENDYESNO |
} else { |
} else { |
$r->print('<input type="text" size="20" name="'.$tempkey.'" value="'.&rulescache($tempkey.'_value').'" />'); |
$r->print('<input type="text" size="20" name="'.$tempkey.'_value" value="'.&rulescache($tempkey.'_value').'" />'); |
} |
} |
$r->print('</td></tr>'); |
$r->print('</td></tr>'); |
} |
} |
$r->print("</table></form></body></html>"); |
$r->print("</table>\n<input type='submit' name='storerules' value='". |
|
&mt('Store Rules')."' /></form>\n</body>\n</html>"); |
return; |
return; |
} |
} |
|
|
Line 2681 Main handler. Calls &assessparms and &c
|
Line 3017 Main handler. Calls &assessparms and &c
|
################################################## |
################################################## |
# use Data::Dumper; |
# use Data::Dumper; |
|
|
|
|
sub handler { |
sub handler { |
my $r=shift; |
my $r=shift; |
|
|
Line 2694 sub handler {
|
Line 3031 sub handler {
|
'pres_marker', |
'pres_marker', |
'pres_value', |
'pres_value', |
'pres_type', |
'pres_type', |
'udom','uname','symb']); |
'udom','uname','symb','serial']); |
|
|
|
|
&Apache::lonhtmlcommon::clear_breadcrumbs(); |
&Apache::lonhtmlcommon::clear_breadcrumbs(); |
Line 2736 sub handler {
|
Line 3073 sub handler {
|
} elsif ($env{'form.action'} eq 'crsenv' && $parm_permission) { |
} elsif ($env{'form.action'} eq 'crsenv' && $parm_permission) { |
&Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=crsenv', |
&Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=crsenv', |
text=>"Course Environment"}); |
text=>"Course Environment"}); |
$r->print(&Apache::lonhtmlcommon::breadcrumbs(undef, |
|
'Edit Course Environment')); |
|
&crsenv($r); |
&crsenv($r); |
} elsif ($env{'form.action'} eq 'setoverview' && $parm_permission) { |
} elsif ($env{'form.action'} eq 'setoverview' && $parm_permission) { |
&Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=setoverview', |
&Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=setoverview', |
text=>"Overview Mode"}); |
text=>"Overview Mode"}); |
&overview($r); |
&overview($r); |
|
} elsif ($env{'form.action'} eq 'setrestrictmeta' && $parm_permission) { |
|
&Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=setrestrictmeta', |
|
text=>"Restrict Metadata"}); |
|
&setrestrictmeta($r); |
} elsif ($env{'form.action'} eq 'newoverview' && $parm_permission) { |
} elsif ($env{'form.action'} eq 'newoverview' && $parm_permission) { |
&Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=setoverview', |
&Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=setoverview', |
text=>"Overview Mode"}); |
text=>"Overview Mode"}); |