version 1.573, 2017/07/04 21:20:14
|
version 1.600, 2021/06/12 22:06:32
|
Line 36 lonparmset - Handler to set parameters f
|
Line 36 lonparmset - Handler to set parameters f
|
|
|
=head1 SYNOPSIS |
=head1 SYNOPSIS |
|
|
lonparmset provides an interface to setting course parameters. |
lonparmset provides an interface to setting content parameters in a |
|
course. |
|
|
It contains all the code for the "Content and Problem Settings" UI, except |
It contains all the code for the "Content and Problem Settings" UI, except |
for the helpers parameter.helper and resettimes.helper, and lonhelper.pm, |
for the helpers parameter.helper and resettimes.helper, and lonhelper.pm, |
Line 137 javascript function 'pjump'.
|
Line 138 javascript function 'pjump'.
|
|
|
=item print_td() |
=item print_td() |
|
|
=item print_usergroups() |
=item check_other_groups() |
|
|
=item parm_control_group() |
=item parm_control_group() |
|
|
Line 846 sub storeparm_by_symb_inner {
|
Line 847 sub storeparm_by_symb_inner {
|
my $courselevelm=$env{'request.course.id'}.'.'.$mapparm; |
my $courselevelm=$env{'request.course.id'}.'.'.$mapparm; |
|
|
my $storeunder=''; |
my $storeunder=''; |
|
my $possreplace=''; |
if (($snum==18) || ($snum==4)) { $storeunder=$courselevel; } |
if (($snum==18) || ($snum==4)) { $storeunder=$courselevel; } |
if (($snum==17) || ($snum==3)) { $storeunder=$courseleveli; } |
if (($snum==17) || ($snum==3)) { |
if (($snum==16) || ($snum==2)) { $storeunder=$courselevelm; } |
$storeunder=$courseleveli; |
|
$possreplace=$courselevelm; |
|
} |
|
if (($snum==16) || ($snum==2)) { |
|
$storeunder=$courselevelm; |
|
$possreplace=$courseleveli; |
|
} |
if (($snum==13) || ($snum==1)) { $storeunder=$courselevelr; } |
if (($snum==13) || ($snum==1)) { $storeunder=$courselevelr; } |
if ($snum==12) { $storeunder=$seclevel; } |
if ($snum==12) { $storeunder=$seclevel; } |
if ($snum==11) { $storeunder=$secleveli; } |
if ($snum==11) { |
if ($snum==10) { $storeunder=$seclevelm; } |
$storeunder=$secleveli; |
|
$possreplace=$seclevelm; |
|
} |
|
if ($snum==10) { |
|
$storeunder=$seclevelm; |
|
$possreplace=$secleveli; |
|
} |
if ($snum==9) { $storeunder=$seclevelr; } |
if ($snum==9) { $storeunder=$seclevelr; } |
if ($snum==8) { $storeunder=$grplevel; } |
if ($snum==8) { $storeunder=$grplevel; } |
if ($snum==7) { $storeunder=$grpleveli; } |
if ($snum==7) { |
if ($snum==6) { $storeunder=$grplevelm; } |
$storeunder=$grpleveli; |
|
$possreplace=$grplevelm; |
|
} |
|
if ($snum==6) { |
|
$storeunder=$grplevelm; |
|
$possreplace=$grpleveli; |
|
} |
if ($snum==5) { $storeunder=$grplevelr; } |
if ($snum==5) { $storeunder=$grplevelr; } |
|
|
|
|
Line 875 sub storeparm_by_symb_inner {
|
Line 895 sub storeparm_by_symb_inner {
|
&Apache::lonnet::expirespread('','','studentcalc'); |
&Apache::lonnet::expirespread('','','studentcalc'); |
if (($snum==13) || ($snum==9) || ($snum==5)) { |
if (($snum==13) || ($snum==9) || ($snum==5)) { |
&Apache::lonnet::expirespread('','','assesscalc',$symb); |
&Apache::lonnet::expirespread('','','assesscalc',$symb); |
} elsif (($snum==14) || ($snum==10) || ($snum==6)) { |
} elsif (($snum==17) || ($snum==16) || ($snum==11) || ($snum==10) || ($snum==7) || ($snum==6)) { |
&Apache::lonnet::expirespread('','','assesscalc',$map); |
&Apache::lonnet::expirespread('','','assesscalc',$map); |
} else { |
} else { |
&Apache::lonnet::expirespread('','','assesscalc'); |
&Apache::lonnet::expirespread('','','assesscalc'); |
Line 889 sub storeparm_by_symb_inner {
|
Line 909 sub storeparm_by_symb_inner {
|
$reply=&Apache::lonnet::cput |
$reply=&Apache::lonnet::cput |
('resourcedata',\%storecontent,$cdom,$cnum); |
('resourcedata',\%storecontent,$cdom,$cnum); |
&log_parmset(\%storecontent); |
&log_parmset(\%storecontent); |
|
if ($possreplace) { |
|
my $resdata = &Apache::lonnet::get_courseresdata($cnum,$cdom); |
|
if (ref($resdata) eq 'HASH') { |
|
if (exists($resdata->{$possreplace})) { |
|
if (&Apache::lonnet::del |
|
('resourcedata',[$possreplace,$possreplace.'.type'],$cdom,$cnum) eq 'ok') { |
|
&log_parmset({$possreplace => '', $possreplace.'.type' => $ntype},1); |
|
} |
|
} |
|
} |
|
} |
} |
} |
&Apache::lonnet::devalidatecourseresdata($cnum,$cdom); |
&Apache::lonnet::devalidatecourseresdata($cnum,$cdom); |
} else { |
} else { |
Line 899 sub storeparm_by_symb_inner {
|
Line 930 sub storeparm_by_symb_inner {
|
if ($snum==1) { |
if ($snum==1) { |
&Apache::lonnet::expirespread |
&Apache::lonnet::expirespread |
($uname,$udom,'assesscalc',$symb); |
($uname,$udom,'assesscalc',$symb); |
} elsif ($snum==2) { |
} elsif (($snum==2) || ($snum==3)) { |
&Apache::lonnet::expirespread |
&Apache::lonnet::expirespread |
($uname,$udom,'assesscalc',$map); |
($uname,$udom,'assesscalc',$map); |
} else { |
} else { |
Line 914 sub storeparm_by_symb_inner {
|
Line 945 sub storeparm_by_symb_inner {
|
$reply=&Apache::lonnet::cput |
$reply=&Apache::lonnet::cput |
('resourcedata',\%storecontent,$udom,$uname); |
('resourcedata',\%storecontent,$udom,$uname); |
&log_parmset(\%storecontent,0,$uname,$udom); |
&log_parmset(\%storecontent,0,$uname,$udom); |
|
if ($possreplace) { |
|
my $resdata = &Apache::lonnet::get_userresdata($uname,$udom); |
|
if (ref($resdata) eq 'HASH') { |
|
if (exists($resdata->{$possreplace})) { |
|
if (&Apache::lonnet::del |
|
('resourcedata',[$possreplace,$possreplace.'.type'],$udom,$uname) eq 'ok') { |
|
&log_parmset({$possreplace => '',$possreplace.'.type' => $ntype},1, |
|
$uname,$udom); |
|
} |
|
} |
|
} |
|
} |
} |
} |
&Apache::lonnet::devalidateuserresdata($uname,$udom); |
&Apache::lonnet::devalidateuserresdata($uname,$udom); |
} |
} |
Line 933 sub storeparm_by_symb_inner {
|
Line 976 sub storeparm_by_symb_inner {
|
# |
# |
# @param {string} $value - the parameter value |
# @param {string} $value - the parameter value |
# @param {string} $type - the parameter type |
# @param {string} $type - the parameter type |
# @param {string} $name - the parameter name (unused) |
|
# @param {boolean} $editable - Set to true to get an icon when no value is defined. |
# @param {boolean} $editable - Set to true to get an icon when no value is defined. |
sub valout { |
sub valout { |
my ($value,$type,$name,$editable)=@_; |
my ($value,$type,$editable)=@_; |
my $result = ''; |
my $result = ''; |
# Values of zero are valid. |
# Values of zero are valid. |
if (! $value && $value ne '0') { |
if (! $value && $value ne '0') { |
Line 1022 sub valout {
|
Line 1064 sub valout {
|
# @param {string} $marker - identifier for the parameter, "resource id&part_parameter name&level", will be passed as pres_marker when the user submits a change. |
# @param {string} $marker - identifier for the parameter, "resource id&part_parameter name&level", will be passed as pres_marker when the user submits a change. |
# @param {string} $return - prefix for the name of the form and field names that will be used to submit the form ('parmform.pres') |
# @param {string} $return - prefix for the name of the form and field names that will be used to submit the form ('parmform.pres') |
# @param {string} $call - javascript function to call to submit the form ('psub') |
# @param {string} $call - javascript function to call to submit the form ('psub') |
|
# @param {boolean} $recursive - true if link is for a map/folder where parameter is currently set to be recursive. |
|
# @param {string} $extra - optional additional information to send as tenth arg in call to javascript pjump function. |
sub plink { |
sub plink { |
my ($type,$dis,$value,$marker,$return,$call)=@_; |
my ($type,$dis,$value,$marker,$return,$call,$recursive,$extra)=@_; |
my $winvalue=$value; |
my $winvalue=$value; |
unless ($winvalue) { |
unless ($winvalue) { |
if (&isdateparm($type)) { |
if (&isdateparm($type) || (&is_specialstring($type))) { |
$winvalue=$env{'form.recent_'.$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 { |
} else { |
$winvalue=$env{'form.recent_'.(split(/\_/,$type))[0]}; |
$winvalue=$env{'form.recent_'.(split(/\_/,$type))[0]}; |
} |
} |
Line 1035 sub plink {
|
Line 1083 sub plink {
|
my ($parmname)=((split(/\&/,$marker))[1]=~/\_([^\_]+)$/); |
my ($parmname)=((split(/\&/,$marker))[1]=~/\_([^\_]+)$/); |
my ($hour,$min,$sec,$val)=&preset_defaults($parmname); |
my ($hour,$min,$sec,$val)=&preset_defaults($parmname); |
unless (defined($winvalue)) { $winvalue=$val; } |
unless (defined($winvalue)) { $winvalue=$val; } |
my $valout = &valout($value,$type,$parmname,1); |
my $valout = &valout($value,$type,1); |
my $unencmarker = $marker; |
my $unencmarker = $marker; |
foreach my $item (\$type, \$dis, \$winvalue, \$marker, \$return, \$call, |
foreach my $item (\$type, \$dis, \$winvalue, \$marker, \$return, \$call, |
\$hour, \$min, \$sec) { |
\$hour, \$min, \$sec, \$extra) { |
$$item = &HTML::Entities::encode($$item,'"<>&'); |
$$item = &HTML::Entities::encode($$item,'"<>&'); |
$$item =~ s/\'/\\\'/g; |
$$item =~ s/\'/\\\'/g; |
} |
} |
return '<table width="100%"><tr valign="top" align="right"><td><a name="'.$unencmarker.'" /></td></tr><tr><td align="center">'. |
return '<table width="100%"><tr valign="top" align="right"><td><a name="'.$unencmarker.'" /></td></tr><tr><td align="center">'. |
'<a href="javascript:pjump('."'".$type."','".$dis."','".$winvalue."','" |
'<a href="javascript:pjump('."'".$type."','".$dis."','".$winvalue."','" |
.$marker."','".$return."','".$call."','".$hour."','".$min."','".$sec."'".');">'. |
.$marker."','".$return."','".$call."','".$hour."','".$min."','".$sec."','".$extra."'".');">'. |
$valout.'</a></td></tr></table>'; |
$valout.'</a></td></tr>'.($recursive?'<tr><td align="center" class="LC_parm_recursive">'. |
|
&mt('recursive').'</td></tr>' : '').'</table>'; |
|
|
} |
} |
|
|
# Javascript for table mode. |
# Javascript for table mode. |
Line 1061 sub page_js {
|
Line 1111 sub page_js {
|
$pjump_def |
$pjump_def |
|
|
function psub() { |
function psub() { |
|
var specstring = /^string_!(yesno|any)/i; |
if (document.parmform.pres_marker.value!='') { |
if (document.parmform.pres_marker.value!='') { |
document.parmform.action+='#'+document.parmform.pres_marker.value; |
document.parmform.action+='#'+document.parmform.pres_marker.value; |
var typedef=new Array(); |
var typedef=new Array(); |
typedef=document.parmform.pres_type.value.split('_'); |
typedef=document.parmform.pres_type.value.split('_'); |
if (document.parmform.pres_type.value!='') { |
if (document.parmform.pres_type.value!='') { |
if (typedef[0]=='date') { |
if ((typedef[0]=='date') || |
|
(specstring.test(document.parmform.pres_type.value))) { |
eval('document.parmform.recent_'+ |
eval('document.parmform.recent_'+ |
document.parmform.pres_type.value+ |
document.parmform.pres_type.value+ |
'.value=document.parmform.pres_value.value;'); |
'.value=document.parmform.pres_value.value;'); |
Line 1189 function validateParms() {
|
Line 1241 function validateParms() {
|
var tailLenient = /\.lenient$/; |
var tailLenient = /\.lenient$/; |
var patternRelWeight = /^\-?[\d.]+$/; |
var patternRelWeight = /^\-?[\d.]+$/; |
var patternLenientStd = /^(yes|no|default)$/; |
var patternLenientStd = /^(yes|no|default)$/; |
|
var ipRegExp = /^setip/; |
var ipallowRegExp = /^setipallow_/; |
var ipallowRegExp = /^setipallow_/; |
var ipdenyRegExp = /^setipdeny_/; |
var ipdenyRegExp = /^setipdeny_/; |
|
var deeplinkRegExp = /^deeplink_/; |
|
var dlListScopeRegExp = /^deeplink_(listing|scope)_/; |
|
var dlLinkUrlsRegExp = /^deeplink_urls_/; |
|
var dlLtiRegExp = /^deeplink_lti_/; |
|
var dlKeyRegExp = /^deeplink_key_/; |
|
var dlMenusRegExp = /^deeplink_menus_/; |
|
var dlCollsRegExp = /^deeplink_colls_/; |
var patternIP = /[\[\]\*\.a-zA-Z\d\-]+/; |
var patternIP = /[\[\]\*\.a-zA-Z\d\-]+/; |
if ((document.parmform.elements.length != 'undefined') && (document.parmform.elements.length) != 'null') { |
if ((document.parmform.elements.length != 'undefined') && (document.parmform.elements.length) != 'null') { |
if (document.parmform.elements.length) { |
if (document.parmform.elements.length) { |
for (i=0; i<document.parmform.elements.length; i++) { |
for (i=0; i<document.parmform.elements.length; i++) { |
var name=document.parmform.elements[i].name; |
var name=document.parmform.elements[i].name; |
if (textRegExp.test(name)) { |
if (textRegExp.test(name)) { |
var identifier = name.replace(textRegExp,''); |
var identifier = name.replace(textRegExp,''); |
if (tailLenient.test(identifier)) { |
if (tailLenient.test(identifier)) { |
if (document.parmform.elements['set_'+identifier].length) { |
if (document.parmform.elements['set_'+identifier].length) { |
Line 1219 function validateParms() {
|
Line 1279 function validateParms() {
|
} |
} |
} |
} |
} |
} |
} else { |
} else if (ipRegExp.test(name)) { |
if (ipallowRegExp.test(name)) { |
if (ipallowRegExp.test(name)) { |
var identifier = name.replace(ipallowRegExp,''); |
var identifier = name.replace(ipallowRegExp,''); |
var possallow = document.parmform.elements[i].value; |
var possallow = document.parmform.elements[i].value; |
Line 1228 function validateParms() {
|
Line 1288 function validateParms() {
|
if (document.parmform.elements['set_'+identifier].value) { |
if (document.parmform.elements['set_'+identifier].value) { |
possallow = ','+possallow; |
possallow = ','+possallow; |
} |
} |
document.parmform.elements['set_'+identifier].value += possallow; |
document.parmform.elements['set_'+identifier].value += possallow; |
} |
} |
} else { |
} else if (ipdenyRegExp.test(name)) { |
if (ipdenyRegExp.test(name)) { |
var identifier = name.replace(ipdenyRegExp,''); |
var identifier = name.replace(ipdenyRegExp,''); |
var possdeny = document.parmform.elements[i].value; |
var possdeny = document.parmform.elements[i].value; |
possdeny = possdeny.replace(/^\s+|\s+$/g,''); |
possdeny = possdeny.replace(/^\s+|\s+$/g,''); |
if (patternIP.test(possdeny)) { |
if (patternIP.test(possdeny)) { |
possdeny = '!'+possdeny; |
possdeny = '!'+possdeny; |
if (document.parmform.elements['set_'+identifier].value) { |
|
possdeny = ','+possdeny; |
|
} |
|
document.parmform.elements['set_'+identifier].value += possdeny; |
|
} |
|
} |
|
} else if (deeplinkRegExp.test(name)) { |
|
if (dlListScopeRegExp.test(name)) { |
|
var identifier = name.replace(dlListScopeRegExp,''); |
|
var idx = document.parmform.elements[i].selectedIndex; |
|
if (idx > 0) { |
|
var possdeeplink = document.parmform.elements[i].options[idx].value |
|
possdeeplink = possdeeplink.replace(/^\s+|\s+$/g,''); |
|
if (document.parmform.elements['set_'+identifier].value) { |
|
possdeeplink = ','+possdeeplink; |
|
} |
|
document.parmform.elements['set_'+identifier].value += possdeeplink; |
|
} |
|
} else if (dlLinkUrlsRegExp.test(name)) { |
|
if (document.parmform.elements[i].checked) { |
|
var identifier = name.replace(dlLinkUrlsRegExp,''); |
|
var posslinkurl = document.parmform.elements[i].value; |
|
posslinkurl = posslinkurl.replace(/^\s+|\s+$/g,''); |
|
if (document.parmform.elements['set_'+identifier].value) { |
|
posslinkurl = ','+posslinkurl; |
|
} |
|
document.parmform.elements['set_'+identifier].value += posslinkurl; |
|
} |
|
} else if (dlLtiRegExp.test(name)) { |
|
var identifier = name.replace(dlLtiRegExp,''); |
|
if (isRadioSet('deeplink_urls_'+identifier,'lti')) { |
|
var posslti = document.parmform.elements[i].value; |
|
posslti = posslti.replace(/\D+/g,''); |
|
if (posslti.length) { |
|
if (document.parmform.elements['set_'+identifier].value) { |
|
posslti = ':'+posslti; |
|
} |
|
document.parmform.elements['set_'+identifier].value += posslti; |
|
} else { |
|
document.parmform.elements['set_'+identifier].value = ''; |
|
alert("A link type of 'deep with LTI launch' was selected but no LTI launcher was selected.\nPlease select one, or choose a different supported link type."); |
|
return false; |
|
} |
|
} |
|
} else if (dlKeyRegExp.test(name)) { |
|
var identifier = name.replace(dlKeyRegExp,''); |
|
if (isRadioSet('deeplink_urls_'+identifier,'key')) { |
|
var posskey = document.parmform.elements[i].value; |
|
posskey = posskey.replace(/^\s+|\s+$/g,''); |
|
var origlength = posskey.length; |
|
posskey = posskey.replace(/[^a-zA-Z\d_.!@#$%^&*()+=-]/g,''); |
|
var newlength = posskey.length; |
|
if (newlength > 0) { |
|
var change = origlength - newlength; |
|
if (change) { |
|
alert(change+' disallowed character(s) removed from deeplink key'); |
|
} |
|
if (document.parmform.elements['set_'+identifier].value) { |
|
posskey = ':'+posskey; |
|
} |
|
document.parmform.elements['set_'+identifier].value += posskey; |
|
} else { |
|
document.parmform.elements['set_'+identifier].value = ''; |
|
if (newlength < origlength) { |
|
alert("A link type of 'deep with key' was selected but the key value was blank, after removing disallowed characters.\nPlease enter a key using one or more of: a-zA-Z0-9_.!@#$%^&*()+=-"); |
|
} else { |
|
alert("A link type of 'deep with key' was selected but the key value was blank.\nPlease enter a key."); |
|
} |
|
return false; |
|
} |
|
} |
|
} else if (dlMenusRegExp.test(name)) { |
|
if (document.parmform.elements[i].checked) { |
|
var identifier = name.replace(dlMenusRegExp,''); |
|
var posslinkmenu = document.parmform.elements[i].value; |
|
posslinkmenu = posslinkmenu.replace(/^\s+|\s+$/g,''); |
|
if (posslinkmenu == 'std') { |
|
posslinkmenu = '0'; |
if (document.parmform.elements['set_'+identifier].value) { |
if (document.parmform.elements['set_'+identifier].value) { |
possdeny = ','+possdeny; |
posslinkmenu = ','+posslinkmenu; |
} |
} |
document.parmform.elements['set_'+identifier].value += possdeny; |
document.parmform.elements['set_'+identifier].value += posslinkmenu; |
} |
} |
} |
} |
|
} else if (dlCollsRegExp.test(name)) { |
|
var identifier = name.replace(dlCollsRegExp,''); |
|
if (isRadioSet('deeplink_menus_'+identifier,'colls')) { |
|
var posslinkmenu = document.parmform.elements[i].value; |
|
if (document.parmform.elements['set_'+identifier].value) { |
|
posslinkmenu = ','+posslinkmenu; |
|
} |
|
document.parmform.elements['set_'+identifier].value += posslinkmenu; |
|
} |
} |
} |
} |
} |
} |
} |
Line 1251 function validateParms() {
|
Line 1397 function validateParms() {
|
return true; |
return true; |
} |
} |
|
|
|
function isRadioSet(name,expected) { |
|
var menuitems = document.getElementsByName(name); |
|
var radioLength = menuitems.length; |
|
result = false; |
|
if (radioLength > 1) { |
|
for (var j=0; j<radioLength; j++) { |
|
if (menuitems[j].checked) { |
|
if (menuitems[j].value == expected) { |
|
result = true; |
|
break; |
|
} |
|
} |
|
} |
|
} |
|
return result; |
|
} |
|
|
ENDSCRIPT |
ENDSCRIPT |
} |
} |
|
|
Line 1305 END
|
Line 1468 END
|
|
|
} |
} |
|
|
|
# Javascript function toggle |
|
sub deeplink_js { |
|
return <<"END"; |
|
function toggleDeepLink(form,item,key) { |
|
var radios = form['deeplink_'+item+'_'+key]; |
|
if (radios.length) { |
|
var keybox; |
|
if (document.getElementById('deeplink_key_'+item+'_'+key)) { |
|
keybox = document.getElementById('deeplink_key_'+item+'_'+key); |
|
} |
|
var divoption; |
|
if (item == 'urls') { |
|
divoption = 'lti' |
|
} else { |
|
if (item == 'menus') { |
|
divoption = 'colls'; |
|
} |
|
} |
|
var seldiv; |
|
if (document.getElementById('deeplinkdiv_'+divoption+'_'+item+'_'+key)) { |
|
seldiv = document.getElementById('deeplinkdiv_'+divoption+'_'+item+'_'+key); |
|
} |
|
for (var i=0; i<radios.length; i++) { |
|
if (radios[i].checked) { |
|
if (radios[i].value == divoption) { |
|
seldiv.style.display = 'inline-block'; |
|
if (item == 'urls') { |
|
keybox.type = 'hidden'; |
|
keybox.value = ''; |
|
} |
|
} else { |
|
if (seldiv != '') { |
|
seldiv.style.display = 'none'; |
|
form['deeplink_'+divoption+'_'+key].selectedIndex = 0; |
|
} |
|
if (item == 'urls') { |
|
if (radios[i].value == 'key') { |
|
keybox.type = 'text'; |
|
} else { |
|
keybox.type = 'hidden'; |
|
} |
|
} |
|
} |
|
} |
|
} |
|
} |
|
} |
|
END |
|
|
|
} |
|
|
# Prints HTML page start for table mode. |
# Prints HTML page start for table mode. |
# @param {Apache2::RequestRec} $r - the Apache request |
# @param {Apache2::RequestRec} $r - the Apache request |
# @param {string} $psymb - resource symb |
# @param {string} $psymb - resource symb |
Line 1380 ENDHEAD
|
Line 1594 ENDHEAD
|
# @param {string} $cgroup - group name |
# @param {string} $cgroup - group name |
# @param {array reference} $usersgroups - list of groups the user belongs to, if any |
# @param {array reference} $usersgroups - list of groups the user belongs to, if any |
# @param {boolean} $noeditgrp - true if no edit is allowed for group level parameters |
# @param {boolean} $noeditgrp - true if no edit is allowed for group level parameters |
# @param {boolean} $readonly - true if no editing allowed. |
# @param {boolean} $readonly - true if no editing allowed. |
|
# @param {array reference} - $recurseup - list of maps containing current one, ending at top-level. |
|
# @param {hash reference} - $maptitles - - hash map id or src -> map title |
|
# @param {hash reference} - $allmaps_inverted - hash map src -> map pc |
|
# @param {scalar reference} - $reclinks - number of "parameter in effect" cells with link to map where recursive param was set |
sub print_row { |
sub print_row { |
my ($r,$which,$part,$name,$symbp,$rid,$default,$defaulttype,$display,$defbgone, |
my ($r,$which,$part,$name,$symbp,$rid,$default,$defaulttype,$display,$defbgone, |
$defbgtwo,$defbgthree,$parmlev,$uname,$udom,$csec,$cgroup,$usersgroups,$noeditgrp, |
$defbgtwo,$defbgthree,$parmlev,$uname,$udom,$csec,$cgroup,$usersgroups,$noeditgrp, |
$readonly)=@_; |
$readonly,$recurseup,$maptitles,$allmaps_inverted,$reclinks)=@_; |
my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; |
my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; |
my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; |
my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; |
my $courseopt=&Apache::lonnet::get_courseresdata($cnum,$cdom); |
my $courseopt=&Apache::lonnet::get_courseresdata($cnum,$cdom); |
|
my $numlinks = 0; |
|
|
# get the values for the parameter in cascading order |
# get the values for the parameter in cascading order |
# empty levels will remain empty |
# empty levels will remain empty |
Line 1424 sub print_row {
|
Line 1643 sub print_row {
|
my $thismarker=$which; |
my $thismarker=$which; |
$thismarker=~s/^parameter\_//; |
$thismarker=~s/^parameter\_//; |
my $mprefix=$rid.'&'.$thismarker.'&'; |
my $mprefix=$rid.'&'.$thismarker.'&'; |
my $effective_parm = &valout($outpar[$result],$typeoutpar[$result],$thismarker); |
my ($parmname)=($thismarker=~/\_([^\_]+)$/); |
my ($othergrp,$grp_parm,$controlgrp); |
my ($othergrp,$grp_parm,$controlgrp,$effective_parm,$effparm_rec,$effparm_level, |
|
$eff_groupparm,$recurse_check,$recursinfo,$extra); |
|
if ((ref($recurseup) eq 'ARRAY') && (@{$recurseup} > 0)) { |
|
if ($result eq '') { |
|
$recurse_check = 1; |
|
} elsif (($uname ne '') && ($result > 3)) { |
|
$recurse_check = 1; |
|
} elsif (($cgroup ne '') && ($result > 7)) { |
|
$recurse_check = 1; |
|
} elsif (($csec ne '') && ($result > 11)) { |
|
$recurse_check = 1; |
|
} elsif ($result > 17) { |
|
$recurse_check = 1; |
|
} |
|
if ($recurse_check) { |
|
my $what = $$part{$which}.'.'.$$name{$which}; |
|
my $prefix; |
|
if (($uname ne '') && ($udom ne '')) { |
|
my $useropt = &Apache::lonnet::get_userresdata($uname,$udom); |
|
$prefix = $env{'request.course.id'}; |
|
$recursinfo = &get_recursive($recurseup,$useropt,$what,$prefix); |
|
if (ref($recursinfo) eq 'ARRAY') { |
|
$effparm_rec = 1; |
|
$effparm_level = &mt('user: [_1]',$uname); |
|
} |
|
} |
|
if (($cgroup ne '') && (!$effparm_rec)) { |
|
$prefix = $env{'request.course.id'}.'.['.$cgroup.']'; |
|
$recursinfo = &get_recursive($recurseup,$courseopt,$what,$prefix); |
|
if (ref($recursinfo) eq 'ARRAY') { |
|
$effparm_rec = 1; |
|
$effparm_level = &mt('group: [_1]',$cgroup); |
|
} |
|
} |
|
if (($csec ne '') && (!$effparm_rec)) { |
|
$prefix = $env{'request.course.id'}.'.['.$csec.']'; |
|
$recursinfo = &get_recursive($recurseup,$courseopt,$what,$prefix); |
|
if (ref($recursinfo) eq 'ARRAY') { |
|
$effparm_rec = 1; |
|
$effparm_level = &mt('section: [_1]',$csec); |
|
} |
|
} |
|
if (!$effparm_rec) { |
|
$prefix = $env{'request.course.id'}; |
|
$recursinfo = &get_recursive($recurseup,$courseopt,$what,$prefix); |
|
if (ref($recursinfo) eq 'ARRAY') { |
|
$effparm_rec = 1; |
|
} |
|
} |
|
} |
|
} |
|
if ((!$effparm_rec) && ($result == 17 || $result == 11 || $result == 7 || $result == 3)) { |
|
$effparm_rec = 1; |
|
} |
|
if ((!$effparm_rec) && |
|
(($$name{$which} eq 'encrypturl') || ($$name{$which} eq 'hiddenresource')) && |
|
($result == 16 || $result == 10 || $result == 6 || $result == 2)) { |
|
$effparm_rec = 1; |
|
} |
|
if ($parmname eq 'deeplink') { |
|
my %posslti; |
|
my %lti = |
|
&Apache::lonnet::get_domain_lti($env{'course.'.$env{'request.course.id'}.'.domain'}, |
|
'provider'); |
|
foreach my $item (keys(%lti)) { |
|
if (ref($lti{$item}) eq 'HASH') { |
|
unless ($lti{$item}{'requser'}) { |
|
$posslti{$item} = $lti{$item}{'consumer'}; |
|
} |
|
} |
|
} |
|
if (keys(%posslti)) { |
|
$extra = 'lti_'; |
|
foreach my $lti (sort { $a <=> $b } keys(%posslti)) { |
|
$extra .= $lti.':'.&escape(&escape($posslti{$lti})).','; |
|
} |
|
$extra =~ s/,$//; |
|
} |
|
if ($env{'course.'.$env{'request.course.id'}.'.menucollections'}) { |
|
my @colls; |
|
foreach my $item (split(/;/,$env{'course.'.$env{'request.course.id'}.'.menucollections'})) { |
|
my ($num,$value) = split(/\%/,$item); |
|
if ($num =~ /^\d+$/) { |
|
push(@colls,$num); |
|
} |
|
} |
|
if (@colls) { |
|
if ($extra) { |
|
$extra .= '&'; |
|
} |
|
$extra .= 'menus_'.join(',',@colls); |
|
} |
|
} |
|
} |
if ($parmlev eq 'general') { |
if ($parmlev eq 'general') { |
if ($uname) { |
if ($uname) { |
&print_td($r,4,$defbgone,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,'',$readonly); |
&print_td($r,4,$defbgone,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,'',$readonly,'',$extra); |
} elsif ($cgroup) { |
} elsif ($cgroup) { |
&print_td($r,8,$defbgthree,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,$noeditgrp,$readonly); |
&print_td($r,8,$defbgthree,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,$noeditgrp,$readonly,'',$extra); |
} elsif ($csec) { |
} elsif ($csec) { |
&print_td($r,12,$defbgtwo,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,'',$readonly); |
&print_td($r,12,$defbgtwo,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,'',$readonly,'',$extra); |
} else { |
} else { |
&print_td($r,18,$defbgone,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,'',$readonly); |
&print_td($r,18,$defbgone,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,'',$readonly,'',$extra); |
} |
} |
} elsif ($parmlev eq 'map') { |
} elsif ($parmlev eq 'map') { |
if ($uname) { |
if ($uname) { |
&print_td($r,3,$defbgone,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,'',$readonly); |
&print_td($r,2,$defbgone,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,'',$readonly,1,$extra); |
&print_td($r,2,$defbgone,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,'',$readonly); |
|
} elsif ($cgroup) { |
} elsif ($cgroup) { |
&print_td($r,7,$defbgthree,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,$noeditgrp,$readonly); |
&print_td($r,6,$defbgthree,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,$noeditgrp,$readonly,1,$extra); |
&print_td($r,6,$defbgthree,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,$noeditgrp,$readonly); |
|
} elsif ($csec) { |
} elsif ($csec) { |
&print_td($r,11,$defbgtwo,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,'',$readonly); |
&print_td($r,10,$defbgtwo,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,'',$readonly,1,$extra); |
&print_td($r,10,$defbgtwo,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,'',$readonly); |
|
} else { |
} else { |
&print_td($r,17,$defbgone,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,'',$readonly); |
&print_td($r,16,$defbgone,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,'',$readonly,1,$extra); |
&print_td($r,16,$defbgone,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,'',$readonly); |
|
} |
} |
} else { |
} else { |
if ($uname) { |
if ($uname) { |
if (@{$usersgroups} > 1) { |
if (@{$usersgroups} > 1) { |
my ($coursereply,$grp_parm,$controlgrp); |
(my $coursereply,$othergrp,$grp_parm,$controlgrp,my $grp_is_rec) = |
($coursereply,$othergrp,$grp_parm,$controlgrp) = |
&check_other_groups($$part{$which}.'.'.$$name{$which}, |
&print_usergroups($r,$$part{$which}.'.'.$$name{$which}, |
|
$rid,$cgroup,$defbgone,$usersgroups,$result,$courseopt); |
$rid,$cgroup,$defbgone,$usersgroups,$result,$courseopt); |
if ($coursereply && $result > 4) { |
if (($coursereply) && ($result > 4)) { |
if (defined($controlgrp)) { |
if (defined($controlgrp)) { |
if ($cgroup ne $controlgrp) { |
if ($cgroup ne $controlgrp) { |
$effective_parm = $grp_parm; |
$eff_groupparm = $grp_parm; |
$result = 0; |
undef($result); |
|
undef($effparm_rec); |
|
if ($grp_is_rec) { |
|
$effparm_rec = 1; |
|
} |
} |
} |
} |
} |
} |
} |
} |
} |
} |
} |
|
|
&print_td($r,18,$defbgone,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,'',$readonly); |
&print_td($r,18,$defbgone,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,'',$readonly,'',$extra); |
&print_td($r,17,$defbgone,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,'',$readonly); |
&print_td($r,16,$defbgone,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,'',$readonly,1,$extra); |
&print_td($r,16,$defbgone,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,'',$readonly); |
&print_td($r,15,'#FFDDDD',$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,'',$readonly,'',$extra); |
&print_td($r,15,'#FFDDDD',$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,'',$readonly); |
&print_td($r,14,'#FFDDDD',$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,'',$readonly,'',$extra); |
&print_td($r,14,'#FFDDDD',$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,'',$readonly); |
&print_td($r,13,$defbgone,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,'',$readonly,'',$extra); |
&print_td($r,13,$defbgone,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,'',$readonly); |
|
|
|
if ($csec) { |
if ($csec) { |
&print_td($r,12,$defbgtwo,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,'',$readonly); |
&print_td($r,12,$defbgtwo,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,'',$readonly,'',$extra); |
&print_td($r,11,$defbgtwo,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,'',$readonly); |
&print_td($r,10,$defbgtwo,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,'',$readonly,1,$extra); |
&print_td($r,10,$defbgtwo,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,'',$readonly); |
&print_td($r,9,$defbgtwo,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,'',$readonly,'',$extra); |
&print_td($r,9,$defbgtwo,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,'',$readonly); |
|
} |
} |
|
|
if ($cgroup) { |
if ($cgroup) { |
&print_td($r,8,$defbgthree,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,$noeditgrp,$readonly); |
&print_td($r,8,$defbgthree,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,$noeditgrp,$readonly,'',$extra); |
&print_td($r,7,$defbgthree,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,$noeditgrp,$readonly); |
&print_td($r,6,$defbgthree,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,$noeditgrp,$readonly,1,$extra); |
&print_td($r,6,$defbgthree,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,$noeditgrp,$readonly); |
&print_td($r,5,$defbgthree,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,$noeditgrp.$readonly,'',$extra); |
&print_td($r,5,$defbgthree,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,$noeditgrp.$readonly); |
|
} |
} |
|
|
if ($uname) { |
if ($uname) { |
if ($othergrp) { |
if ($othergrp) { |
$r->print($othergrp); |
$r->print($othergrp); |
} |
} |
&print_td($r,4,$defbgone,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,'',$readonly); |
&print_td($r,4,$defbgone,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,'',$readonly,'',$extra); |
&print_td($r,3,$defbgone,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,'',$readonly); |
&print_td($r,2,$defbgone,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,'',$readonly,1,$extra); |
&print_td($r,2,$defbgone,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,'',$readonly); |
&print_td($r,1,$defbgone,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,'',$readonly,'',$extra); |
&print_td($r,1,$defbgone,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,'',$readonly); |
|
} |
} |
|
|
} # end of $parmlev if/else |
} # end of $parmlev if/else |
$r->print('<td style="background-color:#CCCCFF;" align="center">'.$effective_parm.'</td>'); |
if (ref($recursinfo) eq 'ARRAY') { |
|
my $rectitle = &mt('recursive'); |
|
if ((ref($maptitles) eq 'HASH') && (exists($maptitles->{$recursinfo->[2]}))) { |
|
if ((ref($allmaps_inverted) eq 'HASH') && (exists($allmaps_inverted->{$recursinfo->[2]}))) { |
|
$rectitle = &mt('set in: [_1]','"'. |
|
'<a href="javascript:pjumprec('."'".$allmaps_inverted->{$recursinfo->[2]}."',". |
|
"'$parmname','$$part{$which}'".');">'. |
|
$maptitles->{$recursinfo->[2]}.'</a>"'); |
|
|
|
$numlinks ++; |
|
} |
|
} |
|
my ($parmname)=($thismarker=~/\_([^\_]+)$/); |
|
$effective_parm = &valout($recursinfo->[0],$recursinfo->[1]); |
|
$r->print('<td style="background-color:#CCCCFF;" align="center">'.$effective_parm. |
|
'<br /><span class="LC_parm_recursive">'.$rectitle.' '. |
|
$effparm_level.'</span></td>'); |
|
} else { |
|
if ($result) { |
|
$effective_parm = &valout($outpar[$result],$typeoutpar[$result]); |
|
} |
|
if ($eff_groupparm) { |
|
$effective_parm = $eff_groupparm; |
|
} |
|
$r->print('<td style="background-color:#CCCCFF;" align="center">'.$effective_parm. |
|
($effparm_rec?'<br /><span class="LC_parm_recursive">'.&mt('recursive'). |
|
'</span>':'').'</td>'); |
|
} |
if ($parmlev eq 'full') { |
if ($parmlev eq 'full') { |
my $sessionval=&Apache::lonnet::EXT('resource.'.$$part{$which}. |
my $sessionval=&Apache::lonnet::EXT('resource.'.$$part{$which}. |
'.'.$$name{$which},$$symbp{$rid}); |
'.'.$$name{$which},$$symbp{$rid}); |
Line 1511 sub print_row {
|
Line 1842 sub print_row {
|
$sessionvaltype=$$defaulttype{$which}; |
$sessionvaltype=$$defaulttype{$which}; |
} |
} |
$r->print('<td style="background-color:#999999;" align="center"><font color="#FFFFFF">'. |
$r->print('<td style="background-color:#999999;" align="center"><font color="#FFFFFF">'. |
&valout($sessionval,$sessionvaltype,$$name{$which}).' '. |
&valout($sessionval,$sessionvaltype).' '. |
'</font></td>'); |
'</font></td>'); |
} |
} |
$r->print('</tr>'); |
$r->print('</tr>'); |
$r->print("\n"); |
$r->print("\n"); |
|
if (($numlinks) && (ref($reclinks))) { |
|
$$reclinks = $numlinks; |
|
} |
} |
} |
|
|
# Prints a cell for table mode. |
# Prints a cell for table mode. |
Line 1535 sub print_row {
|
Line 1869 sub print_row {
|
# @param {hash reference} $display - parameter key -> full title for the parameter |
# @param {hash reference} $display - parameter key -> full title for the parameter |
# @param {boolean} $noeditgrp - true if no edit is allowed for group level parameters |
# @param {boolean} $noeditgrp - true if no edit is allowed for group level parameters |
# @param {boolean} $readonly -true if editing not allowed. |
# @param {boolean} $readonly -true if editing not allowed. |
|
# @param {boolean} $ismaplevel - true if level is for a map. |
|
# @param {string} $extra - extra information to pass to plink. |
sub print_td { |
sub print_td { |
my ($r,$which,$defbg,$result,$outpar,$mprefix,$value,$typeoutpar,$display,$noeditgrp,$readonly)=@_; |
my ($r,$which,$defbg,$result,$outpar,$mprefix,$value,$typeoutpar,$display, |
$r->print('<td style="background-color:'.(($result==$which)?'#AAFFAA':$defbg). |
$noeditgrp,$readonly,$ismaplevel,$extra)=@_; |
|
my ($ineffect,$recursive,$currval,$currtype,$currlevel); |
|
$ineffect = 0; |
|
$currval = $$outpar[$which]; |
|
$currtype = $$typeoutpar[$which]; |
|
$currlevel = $which; |
|
if (($result) && ($result == $which)) { |
|
$ineffect = 1; |
|
} |
|
if ($ismaplevel) { |
|
if ($mprefix =~ /(hiddenresource|encrypturl)\&/) { |
|
if (($result) && ($result == $which)) { |
|
$recursive = 1; |
|
} |
|
} elsif ($$outpar[$which+1] ne '') { |
|
$recursive = 1; |
|
$currlevel = $which+1; |
|
$currval = $$outpar[$currlevel]; |
|
$currtype = $$typeoutpar[$currlevel]; |
|
if (($result) && ($result == $currlevel)) { |
|
$ineffect = 1; |
|
} |
|
} |
|
} |
|
$r->print('<td style="background-color:'.($ineffect?'#AAFFAA':$defbg). |
';" align="center">'); |
';" align="center">'); |
my $nolink = 0; |
my $nolink = 0; |
if ($readonly) { |
if ($readonly) { |
$nolink = 1; |
$nolink = 1; |
} else { |
} else { |
if ($which == 14 || $which == 15) { |
if ($which == 14 || $which == 15 || $mprefix =~ /mapalias\&$/) { |
$nolink = 1; |
$nolink = 1; |
} elsif (($env{'request.course.sec'} ne '') && ($which > 12)) { |
} elsif (($env{'request.course.sec'} ne '') && ($which > 12)) { |
$nolink = 1; |
$nolink = 1; |
Line 1552 sub print_td {
|
Line 1912 sub print_td {
|
$nolink = 1; |
$nolink = 1; |
} |
} |
} elsif ($mprefix =~ /availablestudent\&$/) { |
} elsif ($mprefix =~ /availablestudent\&$/) { |
if ($which > 4) { |
$nolink = 1; |
$nolink = 1; |
|
} |
|
} elsif ($mprefix =~ /examcode\&$/) { |
} elsif ($mprefix =~ /examcode\&$/) { |
unless ($which == 2) { |
unless ($which == 2) { |
$nolink = 1; |
$nolink = 1; |
} |
} |
} elsif ($mprefix =~ /(encrypturl|hiddenresource)/) { |
|
if ($which == 16 || $which == 10 || $which == 6 || $which == 2) { |
|
$nolink = 1; |
|
} |
|
} |
} |
} |
} |
if ($nolink) { |
if ($nolink) { |
$r->print(&valout($$outpar[$which],$$typeoutpar[$which],$mprefix)); |
my ($parmname)=((split(/\&/,$mprefix))[1]=~/\_([^\_]+)$/); |
# FIXME: probably a good thing that mprefix is not used in valout, because it does not look like a parameter name ! |
$r->print(&valout($currval,$currtype)); |
} else { |
} else { |
$r->print(&plink($$typeoutpar[$which], |
$r->print(&plink($currtype, |
$$display{$value},$$outpar[$which], |
$$display{$value},$currval, |
$mprefix."$which",'parmform.pres','psub')); |
$mprefix.$currlevel,'parmform.pres','psub',$recursive, |
|
$extra)); |
} |
} |
$r->print('</td>'."\n"); |
$r->print('</td>'."\n"); |
} |
} |
|
|
# FIXME: Despite the name, this does not print anything, the $r parameter is unused. |
|
# Returns HTML and other info for the cell added when a user is selected |
# Returns HTML and other info for the cell added when a user is selected |
# and that user is in several groups. This is the cell with the title "Control by other group". |
# and that user is in several groups. This is the cell with the title "Control by other group". |
# |
# |
# @param {Apache2::RequestRec} $r - the Apache request (unused) |
|
# @param {string} $what - parameter part.'.'.parameter name |
# @param {string} $what - parameter part.'.'.parameter name |
# @param {string} $rid - resource id |
# @param {string} $rid - resource id |
# @param {string} $cgroup - group name |
# @param {string} $cgroup - group name |
Line 1588 sub print_td {
|
Line 1941 sub print_td {
|
# @param {array reference} $usersgroups - list of groups the user belongs to, if any |
# @param {array reference} $usersgroups - list of groups the user belongs to, if any |
# @param {integer} $result - level |
# @param {integer} $result - level |
# @param {hash reference} $courseopt - course parameters hash (result of lonnet::get_courseresdata, dump of course's resourcedata.db) |
# @param {hash reference} $courseopt - course parameters hash (result of lonnet::get_courseresdata, dump of course's resourcedata.db) |
# @returns {Array} - array (parameter value for the other group, HTML for the cell, HTML with the value, name of the other group) |
# @returns {Array} - array (parameter value for the other group, HTML for the cell, HTML with the value, name of the other group, true if recursive) |
sub print_usergroups { |
sub check_other_groups { |
my ($r,$what,$rid,$cgroup,$defbg,$usersgroups,$result,$courseopt) = @_; |
my ($what,$rid,$cgroup,$defbg,$usersgroups,$result,$courseopt) = @_; |
my $courseid = $env{'request.course.id'}; |
my $courseid = $env{'request.course.id'}; |
my $output; |
my $output; |
my $symb = &symbcache($rid); |
my $symb = &symbcache($rid); |
Line 1602 sub print_usergroups {
|
Line 1955 sub print_usergroups {
|
&parm_control_group($courseid,$usersgroups,$symbparm,$mapparm, |
&parm_control_group($courseid,$usersgroups,$symbparm,$mapparm, |
$recurseparm,$what,$courseopt); |
$recurseparm,$what,$courseopt); |
my $bgcolor = $defbg; |
my $bgcolor = $defbg; |
my $grp_parm; |
my ($grp_parm,$grp_is_rec); |
if (($coursereply) && ($cgroup ne $resultgroup)) { |
if (($coursereply) && ($cgroup ne $resultgroup)) { |
|
my ($parmname) = ($what =~ /\.([^.]+)$/); |
if ($result > 3) { |
if ($result > 3) { |
$bgcolor = '#AAFFAA'; |
$bgcolor = '#AAFFAA'; |
$grp_parm = &valout($coursereply,$resulttype,$what); |
|
} |
} |
$grp_parm = &valout($coursereply,$resulttype,$what); |
$grp_parm = &valout($coursereply,$resulttype); |
$output = '<td style="background-color:'.$bgcolor.';" align="center">'; |
$output = '<td style="background-color:'.$bgcolor.';" align="center">'; |
if ($resultgroup && $resultlevel) { |
if ($resultgroup && $resultlevel) { |
$output .= '<small><b>'.$resultgroup.'</b> ('.$resultlevel.'): </small>'.$grp_parm; |
if ($resultlevel eq 'recursive') { |
|
$resultlevel = 'map/folder'; |
|
$grp_is_rec = 1; |
|
} |
|
$output .= '<small><b>'.$resultgroup.'</b> ('.$resultlevel.'): </small>'.$grp_parm. |
|
($grp_is_rec?'<span class="LC_parm_recursive">'.&mt('recursive').'</span>':''); |
|
|
} else { |
} else { |
$output .= ' '; |
$output .= ' '; |
} |
} |
Line 1619 sub print_usergroups {
|
Line 1978 sub print_usergroups {
|
} else { |
} else { |
$output .= '<td style="background-color:'.$bgcolor.';"> </td>'; |
$output .= '<td style="background-color:'.$bgcolor.';"> </td>'; |
} |
} |
return ($coursereply,$output,$grp_parm,$resultgroup); |
return ($coursereply,$output,$grp_parm,$resultgroup,$grp_is_rec); |
} |
} |
|
|
# Looks for a group with a defined parameter for given user and parameter. |
# Looks for a group with a defined parameter for given user and parameter. |
# Used by print_usergroups. |
# Used by check_other_groups. |
# |
# |
# @param {string} $courseid - the course id |
# @param {string} $courseid - the course id |
# @param {array reference} $usersgroups - list of groups the user belongs to, if any |
# @param {array reference} $usersgroups - list of groups the user belongs to, if any |
Line 1700 sub extractResourceInformation {
|
Line 2059 sub extractResourceInformation {
|
my $srcf=$resource->src(); |
my $srcf=$resource->src(); |
$srcf=~/\.(\w+)$/; |
$srcf=~/\.(\w+)$/; |
$$typep{$id}=$1; |
$$typep{$id}=$1; |
|
my $toolsymb; |
|
if ($srcf =~ /ext\.tool$/) { |
|
$toolsymb = $resource->symb(); |
|
} |
$$keyp{$id}=''; |
$$keyp{$id}=''; |
$$uris{$id}=$srcf; |
$$uris{$id}=$srcf; |
|
|
foreach my $key (split(/\,/,&Apache::lonnet::metadata($srcf,'allpossiblekeys'))) { |
foreach my $key (split(/\,/,&Apache::lonnet::metadata($srcf,'allpossiblekeys',$toolsymb))) { |
next if ($key!~/^parameter_/); |
next if ($key!~/^parameter_/); |
|
|
# Hidden parameters |
# Hidden parameters |
next if (&Apache::lonnet::metadata($srcf,$key.'.hidden') eq 'parm'); |
next if (&Apache::lonnet::metadata($srcf,$key.'.hidden',$toolsymb) eq 'parm'); |
# |
# |
# allparms is a hash of parameter names |
# allparms is a hash of parameter names |
# |
# |
my $name=&Apache::lonnet::metadata($srcf,$key.'.name'); |
my $name=&Apache::lonnet::metadata($srcf,$key.'.name',$toolsymb); |
if (!exists($$allparms{$name}) || $$allparms{$name} =~ m/^\s*$/ ) { |
if (!exists($$allparms{$name}) || $$allparms{$name} =~ m/^\s*$/ ) { |
my ($display,$parmdis); |
my ($display,$parmdis); |
$display = &standard_parameter_names($name); |
$display = &standard_parameter_names($name); |
if ($display eq '') { |
if ($display eq '') { |
$display= &Apache::lonnet::metadata($srcf,$key.'.display'); |
$display= &Apache::lonnet::metadata($srcf,$key.'.display',$toolsymb); |
$parmdis = $display; |
$parmdis = $display; |
$parmdis =~ s/\s*\[Part.*$//g; |
$parmdis =~ s/\s*\[Part.*$//g; |
} else { |
} else { |
Line 1725 sub extractResourceInformation {
|
Line 2088 sub extractResourceInformation {
|
$$allparms{$name}=$parmdis; |
$$allparms{$name}=$parmdis; |
if (ref($defkeytype)) { |
if (ref($defkeytype)) { |
$$defkeytype{$name}= |
$$defkeytype{$name}= |
&Apache::lonnet::metadata($srcf,$key.'.type'); |
&Apache::lonnet::metadata($srcf,$key.'.type',$toolsymb); |
} |
} |
} |
} |
|
|
# |
# |
# allparts is a hash of all parts |
# allparts is a hash of all parts |
# |
# |
my $part= &Apache::lonnet::metadata($srcf,$key.'.part'); |
my $part= &Apache::lonnet::metadata($srcf,$key.'.part',$toolsymb); |
$$allparts{$part} = &mt('Part: [_1]',$part); |
$$allparts{$part} = &mt('Part: [_1]',$part); |
# |
# |
# Remember all keys going with this resource |
# Remember all keys going with this resource |
Line 1773 sub extractResourceInformation {
|
Line 2136 sub extractResourceInformation {
|
} |
} |
} |
} |
|
|
|
sub get_recursive { |
|
my ($recurseup,$resdata,$what,$prefix) = @_; |
|
if ((ref($resdata) eq 'HASH') && (ref($recurseup) eq 'ARRAY')) { |
|
foreach my $item (@{$recurseup}) { |
|
my $norecursechk=$prefix.'.'.$item.'___(all).'.$what; |
|
if (defined($resdata->{$norecursechk})) { |
|
if ($what =~ /\.(encrypturl|hiddenresource)$/) { |
|
my $type = $resdata->{$norecursechk.'.type'}; |
|
return [$resdata->{$norecursechk},$type,$item]; |
|
} else { |
|
last; |
|
} |
|
} |
|
my $recursechk=$prefix.'.'.$item.'___(rec).'.$what; |
|
if (defined($resdata->{$recursechk})) { |
|
my $type = $resdata->{$recursechk.'.type'}; |
|
return [$resdata->{$recursechk},$type,$item]; |
|
} |
|
} |
|
} |
|
return; |
|
} |
|
|
|
|
# Tells if a parameter type is a date. |
# Tells if a parameter type is a date. |
# |
# |
Line 1783 sub isdateparm {
|
Line 2169 sub isdateparm {
|
return (($type=~/^date/) && (!($type eq 'date_interval'))); |
return (($type=~/^date/) && (!($type eq 'date_interval'))); |
} |
} |
|
|
|
# Determine if parameter type is specialized string type (i.e., |
|
# not just string or string_yesno. |
|
|
|
sub is_specialstring { |
|
my $type=shift; |
|
return (($type=~/^string_/) && (($type ne 'string_yesno'))); |
|
} |
|
|
# Prints the HTML and Javascript to select parameters, with various shortcuts. |
# Prints the HTML and Javascript to select parameters, with various shortcuts. |
# FIXME: remove unused parameters |
|
# |
# |
# @param {Apache2::RequestRec} $r - the Apache request (unused) |
# @param {Apache2::RequestRec} $r - the Apache request |
# @param {hash reference} $allparms - hash parameter name -> parameter title |
|
# @param {array reference} $pscat - list of selected parameter names (unused) |
|
# @param {hash reference} $keyorder - hash parameter key -> appearance rank (unused) |
|
sub parmmenu { |
sub parmmenu { |
my ($r,$allparms,$pscat,$keyorder)=@_; |
my ($r)=@_; |
my $tempkey; |
|
$r->print(<<ENDSCRIPT); |
$r->print(<<ENDSCRIPT); |
<script type="text/javascript"> |
<script type="text/javascript"> |
// <![CDATA[ |
// <![CDATA[ |
Line 1869 sub parmmenu {
|
Line 2258 sub parmmenu {
|
ENDSCRIPT |
ENDSCRIPT |
|
|
$r->print('<hr />'); |
$r->print('<hr />'); |
&shortCuts($r,$allparms,$pscat,$keyorder); |
&shortCuts($r); |
$r->print('<hr />'); |
$r->print('<hr />'); |
} |
} |
|
|
Line 1923 sub lookUpTableParameter {
|
Line 2312 sub lookUpTableParameter {
|
'buttonshide' => 'hiding', |
'buttonshide' => 'hiding', |
'turnoffeditor' => 'hiding', |
'turnoffeditor' => 'hiding', |
'encrypturl' => 'hiding', |
'encrypturl' => 'hiding', |
|
'deeplink' => 'hiding', |
'randomorder' => 'high_level_randomization', |
'randomorder' => 'high_level_randomization', |
'randompick' => 'high_level_randomization', |
'randompick' => 'high_level_randomization', |
'available' => 'slots', |
'available' => 'slots', |
Line 1938 sub lookUpTableParameter {
|
Line 2328 sub lookUpTableParameter {
|
'lenient' => 'grading', |
'lenient' => 'grading', |
'retrypartial' => 'tries', |
'retrypartial' => 'tries', |
'discussvote' => 'misc', |
'discussvote' => 'misc', |
'examcode' => 'high_level_randomization', |
'examcode' => 'high_level_randomization', |
); |
); |
} |
} |
|
|
# Adds the given parameter name to an array of arrays listing all parameters for each category. |
# Adds the given parameter name to an array of arrays listing all parameters for each category. |
Line 2033 sub parmboxes {
|
Line 2423 sub parmboxes {
|
$r->print('<div class="LC_Box LC_400Box">' |
$r->print('<div class="LC_Box LC_400Box">' |
.'<h4 class="LC_hcell">'.&mt($categories{$key}).'</h4>'."\n"); |
.'<h4 class="LC_hcell">'.&mt($categories{$key}).'</h4>'."\n"); |
foreach my $tempkey (&keysindisplayorderCategory($categoryList{$key},$keyorder)) { |
foreach my $tempkey (&keysindisplayorderCategory($categoryList{$key},$keyorder)) { |
|
next if ($tempkey eq ''); |
$r->print('<span class="LC_nobreak">' |
$r->print('<span class="LC_nobreak">' |
.'<label><input type="checkbox" name="pscat" ' |
.'<label><input type="checkbox" name="pscat" ' |
.'value="'.$tempkey.'" '); |
.'value="'.$tempkey.'" '); |
Line 2049 sub parmboxes {
|
Line 2440 sub parmboxes {
|
} |
} |
|
|
# Prints HTML with shortcuts to select groups of parameters in one click, or deselect all. |
# Prints HTML with shortcuts to select groups of parameters in one click, or deselect all. |
# FIXME: remove unused parameters |
|
# |
# |
# @param {Apache2::RequestRec} $r - the Apache request |
# @param {Apache2::RequestRec} $r - the Apache request |
# @param {hash reference} $allparms - hash parameter name -> parameter title (unused) |
|
# @param {array reference} $pscat - list of selected parameter names (unused) |
|
# @param {hash reference} $keyorder - hash parameter key -> appearance rank (unused) |
|
sub shortCuts { |
sub shortCuts { |
my ($r,$allparms,$pscat,$keyorder)=@_; |
my ($r)=@_; |
|
|
# Parameter Selection |
# Parameter Selection |
$r->print( |
$r->print( |
Line 2135 sub partmenu {
|
Line 2522 sub partmenu {
|
sub usermenu { |
sub usermenu { |
my ($r,$uname,$id,$udom,$csec,$cgroup,$parmlev,$usersgroups,$pssymb)=@_; |
my ($r,$uname,$id,$udom,$csec,$cgroup,$parmlev,$usersgroups,$pssymb)=@_; |
my $chooseopt=&Apache::loncommon::select_dom_form($udom,'udom').' '. |
my $chooseopt=&Apache::loncommon::select_dom_form($udom,'udom').' '. |
&Apache::loncommon::selectstudent_link('parmform','uname','udom'); |
&Apache::loncommon::selectstudent_link('parmform','uname','udom','condition'). |
my $selscript=&Apache::loncommon::studentbrowser_javascript(); |
&Apache::lonhtmlcommon::scripttag(<<ENDJS); |
|
function setCourseadv(form,caller) { |
|
if (caller.value == 'st') { |
|
form.courseadv.value = 'none'; |
|
} else { |
|
form.courseadv.value = ''; |
|
} |
|
return; |
|
} |
|
ENDJS |
|
|
|
my (%chkroles,$stuonly,$courseadv); |
|
if ($env{'form.userroles'} eq 'any') { |
|
$chkroles{'any'} = ' checked="checked"'; |
|
} else { |
|
$chkroles{'st'} = ' checked="checked"'; |
|
$courseadv = 'none'; |
|
} |
|
my $crstype = $env{'course.'.$env{'request.course.id'}.'.type'}; |
|
if ($crstype eq 'Community') { |
|
$stuonly = &mt('member only'); |
|
} else { |
|
$stuonly = &mt('student only'); |
|
} |
|
$chooseopt .= '<br /><span class="LC_cusr_subheading">'. |
|
&mt("User's role").': '. |
|
'<label><input type="radio" name="userroles" value="st"'.$chkroles{'st'}.' onclick="setCourseadv(this.form,this);" />'. |
|
$stuonly.'</label> '. |
|
'<label><input type="radio" name="userroles" value="any"'.$chkroles{'any'}.' onclick="setCourseadv(this.form,this);" />'. |
|
&mt('any role').'</label><input type="hidden" id="courseadv" name="courseadv" value="'.$courseadv.'" /></span>'; |
my $sections=''; |
my $sections=''; |
my %sectionhash = &Apache::loncommon::get_sections(); |
my %sectionhash = &Apache::loncommon::get_sections(); |
|
|
Line 2146 sub usermenu {
|
Line 2561 sub usermenu {
|
if (($pssymb) || &Apache::lonnet::allowed('mdg',$env{'request.course.id'})) { |
if (($pssymb) || &Apache::lonnet::allowed('mdg',$env{'request.course.id'})) { |
%grouphash = &Apache::longroup::coursegroups(); |
%grouphash = &Apache::longroup::coursegroups(); |
} elsif ($env{'request.course.groups'} ne '') { |
} elsif ($env{'request.course.groups'} ne '') { |
map { $grouphash{$_} = 1; } split(/,/,$env{'request.course.groups'}); |
map { $grouphash{$_} = 1; } split(/:/,$env{'request.course.groups'}); |
} |
} |
|
|
my $g_s_header=''; |
my $g_s_header=''; |
Line 2204 function group_or_section(caller) {
|
Line 2619 function group_or_section(caller) {
|
} |
} |
|
|
if (%grouphash) { |
if (%grouphash) { |
$groups=&mt('Group:').' <select name="cgroup"'; |
$groups=&mt('Group').': <select name="cgroup"'; |
if (%sectionhash && $env{'form.action'} eq 'settable' && $currsec eq '') { |
if (%sectionhash && $env{'form.action'} eq 'settable' && $currsec eq '') { |
$groups .= qq| onchange="group_or_section('cgroup')" |; |
$groups .= qq| onchange="group_or_section('cgroup')" |; |
} |
} |
Line 2249 function group_or_section(caller) {
|
Line 2664 function group_or_section(caller) {
|
# @param {Apache2::RequestRec} $r - the Apache request |
# @param {Apache2::RequestRec} $r - the Apache request |
# @param {hash reference} $allparms - hash parameter name -> parameter title |
# @param {hash reference} $allparms - hash parameter name -> parameter title |
# @param {array reference} $pscat - list of selected parameter names |
# @param {array reference} $pscat - list of selected parameter names |
# @param {array reference} $psprt - list of selected parameter parts (unused) |
|
# @param {hash reference} $keyorder - hash parameter key -> appearance rank |
# @param {hash reference} $keyorder - hash parameter key -> appearance rank |
# @param {string} [$divid] - name used to give an id to the HTML element for the scroll box |
# @param {string} [$divid] - name used to give an id to the HTML element for the scroll box |
sub displaymenu { |
sub displaymenu { |
my ($r,$allparms,$pscat,$psprt,$keyorder,$divid)=@_; |
my ($r,$allparms,$pscat,$keyorder,$divid)=@_; |
|
|
$r->print(&Apache::lonhtmlcommon::start_pick_box()); |
$r->print(&Apache::lonhtmlcommon::start_pick_box()); |
$r->print(&Apache::lonhtmlcommon::row_title(&mt('Select Parameters to View'))); |
$r->print(&Apache::lonhtmlcommon::row_title(&mt('Select Parameters to View'))); |
|
|
&parmmenu($r,$allparms,$pscat,$keyorder); # only $allparms is used by parmmenu |
&parmmenu($r); |
$r->print(&Apache::loncommon::start_scrollbox('480px','440px','200px',$divid)); |
$r->print(&Apache::loncommon::start_scrollbox('480px','440px','200px',$divid)); |
&parmboxes($r,$allparms,$pscat,$keyorder); |
&parmboxes($r,$allparms,$pscat,$keyorder); |
$r->print(&Apache::loncommon::end_scrollbox()); |
$r->print(&Apache::loncommon::end_scrollbox()); |
Line 2491 sub groupmenu {
|
Line 2905 sub groupmenu {
|
if (&Apache::lonnet::allowed('mdg',$env{'request.course.id'})) { |
if (&Apache::lonnet::allowed('mdg',$env{'request.course.id'})) { |
%grouphash = &Apache::longroup::coursegroups(); |
%grouphash = &Apache::longroup::coursegroups(); |
} elsif ($env{'request.course.groups'} ne '') { |
} elsif ($env{'request.course.groups'} ne '') { |
map { $grouphash{$_} = 1; } split(/,/,$env{'request.course.groups'}); |
map { $grouphash{$_} = 1; } split(/:/,$env{'request.course.groups'}); |
} |
} |
return '' if (!%grouphash); |
return '' if (!%grouphash); |
|
|
Line 2657 sub assessparms {
|
Line 3071 sub assessparms {
|
my %uris=(); # hash resource/map id -> resource src |
my %uris=(); # hash resource/map id -> resource src |
my %maptitles=(); # hash map pc or src -> map title |
my %maptitles=(); # hash map pc or src -> map title |
my %allmaps=(); # hash map pc -> map src |
my %allmaps=(); # hash map pc -> map src |
|
my %allmaps_inverted=(); # hash map src -> map pc |
my %alllevs=(); # hash English level title -> value |
my %alllevs=(); # hash English level title -> value |
|
|
my $uname; # selected user name |
my $uname; # selected user name |
Line 2665 sub assessparms {
|
Line 3080 sub assessparms {
|
my $csec; # selected section name |
my $csec; # selected section name |
my $cgroup; # selected group name |
my $cgroup; # selected group name |
my @usersgroups = (); # list of the user groups |
my @usersgroups = (); # list of the user groups |
|
my $numreclinks = 0; |
|
|
my $coursename=$env{'course.'.$env{'request.course.id'}.'.description'}; |
my $coursename=$env{'course.'.$env{'request.course.id'}.'.description'}; |
|
|
Line 2698 sub assessparms {
|
Line 3114 sub assessparms {
|
if ($cgroup ne '') { |
if ($cgroup ne '') { |
unless (&Apache::lonnet::allowed('mdg',$env{'request.course.id'})) { |
unless (&Apache::lonnet::allowed('mdg',$env{'request.course.id'})) { |
if (($env{'request.course.groups'} eq '') || |
if (($env{'request.course.groups'} eq '') || |
(!grep(/^\Q$cgroup\E$/,split(/,/,$env{'request.course.groups'})))) { |
(!grep(/^\Q$cgroup\E$/,split(/:/,$env{'request.course.groups'})))) { |
$noeditgrp = 1; |
$noeditgrp = 1; |
} |
} |
} |
} |
Line 2778 sub assessparms {
|
Line 3194 sub assessparms {
|
$csec=&Apache::lonnet::getsection($udom,$uname, |
$csec=&Apache::lonnet::getsection($udom,$uname, |
$env{'request.course.id'}); |
$env{'request.course.id'}); |
if ($csec eq '-1') { |
if ($csec eq '-1') { |
$message= |
my $crstype = $env{'course.'.$env{'request.course.id'}.'.type'}; |
'<p class="LC_warning">'. |
if ($env{'form.userroles'} eq 'any') { |
&mt('User [_1] at domain [_2] not in this course', |
if (($env{'user.name'} eq $uname) && ($env{'user.domain'} eq $udom)) { |
"'".$uname."'","'".$udom."'"). |
$csec = $env{'request.course.sec'}; |
'</p>'; |
$message = '<span class="LC_info">'; |
$uname=''; |
if ($crstype eq 'Community') { |
$csec=$env{'form.csec'}; |
$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 .= '</span>'; |
|
} 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 = '<span class="LC_warning">'; |
|
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 .= '</span>'; |
|
$uname=''; |
|
if ($env{'request.course.sec'} ne '') { |
|
$csec=$env{'request.course.sec'}; |
|
} else { |
|
$csec=$env{'form.csec'}; |
|
} |
|
$cgroup=$env{'form.cgroup'}; |
|
} else { |
|
$message = '<span class="LC_info">'; |
|
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 .= '</span>'; |
|
} |
|
} |
|
} else { |
|
$message = '<span class="LC_warning">'; |
|
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 .= '</span>'; |
|
$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='<span class="LC_warning">'. |
|
&mt("User '[_1]' at domain '[_2]' not in section '[_3]'", |
|
$uname,$udom,$env{'request.course.sec'}). |
|
'</span>'; |
|
$uname=''; |
|
$csec=$env{'request.course.sec'}; |
|
} |
$cgroup=$env{'form.cgroup'}; |
$cgroup=$env{'form.cgroup'}; |
} else { |
} |
|
if ($uname ne '') { |
my %name=&Apache::lonnet::userenvironment($udom,$uname, |
my %name=&Apache::lonnet::userenvironment($udom,$uname, |
('firstname','middlename','lastname','generation','id')); |
('firstname','middlename','lastname','generation','id')); |
$message="\n<p>\n".&mt("Full Name").": ". |
$message .= "\n<p>\n".&mt('Full Name').': ' |
$name{'firstname'}.' '.$name{'middlename'}.' ' |
.$name{'firstname'}.' '.$name{'middlename'}.' ' |
.$name{'lastname'}.' '.$name{'generation'}. |
.$name{'lastname'}.' '.$name{'generation'} |
"<br />\n".&mt('Student/Employee ID').": ".$name{'id'}.'<p>'; |
."<br />\n".&mt('Student/Employee ID').': '.$name{'id'}.'</p>'; |
} |
@usersgroups = &Apache::lonnet::get_users_groups( |
@usersgroups = &Apache::lonnet::get_users_groups( |
$udom,$uname,$env{'request.course.id'}); |
$udom,$uname,$env{'request.course.id'}); |
if (@usersgroups > 0) { |
if (@usersgroups > 0) { |
unless (grep(/^\Q$cgroup\E$/,@usersgroups)) { |
unless (grep(/^\Q$cgroup\E$/,@usersgroups)) { |
$cgroup = $usersgroups[0]; |
$cgroup = $usersgroups[0]; |
} |
|
} else { |
|
$cgroup = ''; |
} |
} |
} |
} |
} |
} |
Line 2812 sub assessparms {
|
Line 3325 sub assessparms {
|
\%mapp, \%symbp,\%maptitles,\%uris, |
\%mapp, \%symbp,\%maptitles,\%uris, |
\%keyorder); |
\%keyorder); |
|
|
|
%allmaps_inverted = reverse(%allmaps); |
|
|
$mapp{'0.0'} = ''; |
$mapp{'0.0'} = ''; |
$symbp{'0.0'} = ''; |
$symbp{'0.0'} = ''; |
|
|
Line 2976 sub assessparms {
|
Line 3491 sub assessparms {
|
.'</p>'; |
.'</p>'; |
} |
} |
} |
} |
|
|
#----------------------------------------------- if all selected, fill in array |
#----------------------------------------------- if all selected, fill in array |
if ($pscat[0] eq "all") { |
if ($pscat[0] eq "all") { |
@pscat = (keys(%allparms)); |
@pscat = (keys(%allparms)); |
Line 2992 sub assessparms {
|
Line 3508 sub assessparms {
|
&startpage($r,$pssymb,$crstype); |
&startpage($r,$pssymb,$crstype); |
|
|
foreach my $item ('tolerance','date_default','date_start','date_end', |
foreach my $item ('tolerance','date_default','date_start','date_end', |
'date_interval','int','float','string') { |
'date_interval','int','float','string','string_lenient', |
|
'string_examcode','string_deeplink','string_discussvote', |
|
'string_useslots','string_problemstatus','string_ip', |
|
'string_questiontype') { |
$r->print('<input type="hidden" value="'. |
$r->print('<input type="hidden" value="'. |
&HTML::Entities::encode($env{'form.recent_'.$item},'"&<>'). |
&HTML::Entities::encode($env{'form.recent_'.$item},'"&<>'). |
'" name="recent_'.$item.'" />'); |
'" name="recent_'.$item.'" />'); |
Line 3042 ENDPARMSELSCRIPT
|
Line 3561 ENDPARMSELSCRIPT
|
|
|
# Step 2 |
# Step 2 |
$r->print(&Apache::lonhtmlcommon::topic_bar(2,&mt('Parameter Specification'),'parmstep2')); |
$r->print(&Apache::lonhtmlcommon::topic_bar(2,&mt('Parameter Specification'),'parmstep2')); |
&displaymenu($r,\%allparms,\@pscat,\@psprt,\%keyorder,'parmmenuscroll'); |
&displaymenu($r,\%allparms,\@pscat,\%keyorder,'parmmenuscroll'); |
|
|
# Step 3 |
# Step 3 |
$r->print(&Apache::lonhtmlcommon::topic_bar(3,&mt('User Specification (optional)'),'parmstep3')); |
$r->print(&Apache::lonhtmlcommon::topic_bar(3,&mt('User Specification (optional)'),'parmstep3')); |
Line 3118 ENDPARMSELSCRIPT
|
Line 3637 ENDPARMSELSCRIPT
|
# |
# |
# This produces the cascading table output of parameters |
# This produces the cascading table output of parameters |
# |
# |
my $coursespan=$csec?10:6; |
my $coursespan=$csec?8:5; |
my $userspan=4; |
my $userspan=3; |
if ($cgroup ne '') { |
if ($cgroup ne '') { |
$coursespan += 4; |
$coursespan += 3; |
} |
} |
|
|
$r->print(&Apache::loncommon::start_data_table()); |
$r->print(&Apache::loncommon::start_data_table()); |
Line 3151 ENDPARMSELSCRIPT
|
Line 3670 ENDPARMSELSCRIPT
|
'femof' => 'from Enclosing Map or Folder', |
'femof' => 'from Enclosing Map or Folder', |
'gen' => 'general', |
'gen' => 'general', |
'foremf' => 'for Enclosing Map or Folder', |
'foremf' => 'for Enclosing Map or Folder', |
'formfr' => 'for Map or Folder (recursive)', |
|
'fr' => 'for Resource' |
'fr' => 'for Resource' |
); |
); |
$r->print(<<ENDTABLETWO); |
$r->print(<<ENDTABLETWO); |
<th rowspan="3">$lt{'pie'}</th> |
<th rowspan="3">$lt{'pie'}</th> |
<th rowspan="3">$lt{'csv'}<br />($csuname:$csudom)</th> |
<th rowspan="3">$lt{'csv'}<br />($csuname:$csudom)</th> |
</tr><tr><td colspan="5"></td><th colspan="3">$lt{'ic'}</th><th colspan="2">$lt{'rl'}</th> |
</tr><tr><td colspan="5"></td><th colspan="2">$lt{'ic'}</th><th colspan="2">$lt{'rl'}</th> |
<th colspan="1">$lt{'ic'}</th> |
<th colspan="1">$lt{'ic'}</th> |
|
|
ENDTABLETWO |
ENDTABLETWO |
if ($csec) { |
if ($csec) { |
$r->print('<th colspan="4">'. |
$r->print('<th colspan="3">'. |
&mt("in Section")." $csec</th>"); |
&mt("in Section")." $csec</th>"); |
} |
} |
if ($cgroup) { |
if ($cgroup) { |
$r->print('<th colspan="4">'. |
$r->print('<th colspan="3">'. |
&mt("in Group")." $cgroup</th>"); |
&mt("in Group")." $cgroup</th>"); |
} |
} |
$r->print(<<ENDTABLEHEADFOUR); |
$r->print(<<ENDTABLEHEADFOUR); |
</tr><tr><th>$lt{'aut'}</th><th>$lt{'type'}</th> |
</tr><tr><th>$lt{'aut'}</th><th>$lt{'type'}</th> |
<th>$lt{'emof'}</th><th>$lt{'part'}</th><th>$lt{'pn'}</th> |
<th>$lt{'emof'}</th><th>$lt{'part'}</th><th>$lt{'pn'}</th> |
<th>$lt{'gen'}</th><th>$lt{'formfr'}</th><th>$lt{'foremf'}</th> |
<th>$lt{'gen'}</th><th>$lt{'foremf'}</th> |
<th>$lt{'def'}</th><th>$lt{'femof'}</th><th>$lt{'fr'}</th> |
<th>$lt{'def'}</th><th>$lt{'femof'}</th><th>$lt{'fr'}</th> |
ENDTABLEHEADFOUR |
ENDTABLEHEADFOUR |
|
|
if ($csec) { |
if ($csec) { |
$r->print('<th>'.$lt{'gen'}.'</th><th>'.$lt{'formfr'}.'</th><th>'.$lt{'foremf'}.'</th><th>'.$lt{'fr'}.'</th>'); |
$r->print('<th>'.$lt{'gen'}.'</th><th>'.$lt{'foremf'}.'</th><th>'.$lt{'fr'}.'</th>'); |
} |
} |
|
|
if ($cgroup) { |
if ($cgroup) { |
$r->print('<th>'.$lt{'gen'}.'</th><th>'.$lt{'formfr'}.'</th><th>'.&mt('foremf').'</th><th>'.$lt{'fr'}.'</th>'); |
$r->print('<th>'.$lt{'gen'}.'</th><th>'.$lt{'foremf'}.'</th><th>'.$lt{'fr'}.'</th>'); |
} |
} |
|
|
if ($uname) { |
if ($uname) { |
if (@usersgroups > 1) { |
if (@usersgroups > 1) { |
$r->print('<th>'.&mt('Control by other group?').'</th>'); |
$r->print('<th>'.&mt('Control by other group?').'</th>'); |
} |
} |
$r->print('<th>'.$lt{'gen'}.'</th><th>'.$lt{'formfr'}.'</th><th>'.$lt{'foremf'}.'</th><th>'.$lt{'fr'}.'</th>'); |
$r->print('<th>'.$lt{'gen'}.'</th><th>'.$lt{'foremf'}.'</th><th>'.$lt{'fr'}.'</th>'); |
} |
} |
|
|
$r->print('</tr>'); |
$r->print('</tr>'); |
Line 3202 ENDTABLEHEADFOUR
|
Line 3720 ENDTABLEHEADFOUR
|
foreach my $rid (@ids) { |
foreach my $rid (@ids) { |
|
|
my ($inmapid)=($rid=~/\.(\d+)$/); |
my ($inmapid)=($rid=~/\.(\d+)$/); |
|
|
if ((!$pssymb && |
if ((!$pssymb && |
(($pschp eq 'all') || ($allmaps{$pschp} eq $mapp{$rid}))) |
(($pschp eq 'all') || ($allmaps{$pschp} eq $mapp{$rid}))) |
|| |
|| |
Line 3232 ENDTABLEHEADFOUR
|
Line 3749 ENDTABLEHEADFOUR
|
my %type= (); |
my %type= (); |
my %default=(); |
my %default=(); |
my $uri=&Apache::lonnet::declutter($uris{$rid}); |
my $uri=&Apache::lonnet::declutter($uris{$rid}); |
|
my $toolsymb; |
|
if ($uri =~ /ext\.tool$/) { |
|
$toolsymb = $symbp{$rid}; |
|
} |
|
|
my $filter=$env{'form.filter'}; |
my $filter=$env{'form.filter'}; |
foreach my $tempkeyp (&keysplit($keyp{$rid})) { |
foreach my $tempkeyp (&keysplit($keyp{$rid})) { |
if (grep $_ eq $tempkeyp, @catmarker) { |
if (grep $_ eq $tempkeyp, @catmarker) { |
my $parmname=&Apache::lonnet::metadata($uri,$tempkeyp.'.name'); |
my $parmname=&Apache::lonnet::metadata($uri,$tempkeyp.'.name',$toolsymb); |
# We may only want certain parameters listed |
# We may only want certain parameters listed |
if ($filter) { |
if ($filter) { |
unless ($filter=~/\Q$parmname\E/) { next; } |
unless ($filter=~/\Q$parmname\E/) { next; } |
} |
} |
$name{$tempkeyp}=$parmname; |
$name{$tempkeyp}=$parmname; |
$part{$tempkeyp}=&Apache::lonnet::metadata($uri,$tempkeyp.'.part'); |
$part{$tempkeyp}=&Apache::lonnet::metadata($uri,$tempkeyp.'.part',$toolsymb); |
|
|
my $parmdis=&Apache::lonnet::metadata($uri,$tempkeyp.'.display'); |
my $parmdis=&Apache::lonnet::metadata($uri,$tempkeyp.'.display',$toolsymb); |
if ($allparms{$name{$tempkeyp}} ne '') { |
if ($allparms{$name{$tempkeyp}} ne '') { |
my $identifier; |
my $identifier; |
if ($parmdis =~ /(\s*\[Part.*)$/) { |
if ($parmdis =~ /(\s*\[Part.*)$/) { |
Line 3256 ENDTABLEHEADFOUR
|
Line 3777 ENDTABLEHEADFOUR
|
} |
} |
unless ($display{$tempkeyp}) { $display{$tempkeyp}=''; } |
unless ($display{$tempkeyp}) { $display{$tempkeyp}=''; } |
$display{$tempkeyp}.=' ('.$name{$tempkeyp}.')'; |
$display{$tempkeyp}.=' ('.$name{$tempkeyp}.')'; |
$default{$tempkeyp}=&Apache::lonnet::metadata($uri,$tempkeyp); |
$default{$tempkeyp}=&Apache::lonnet::metadata($uri,$tempkeyp,$toolsymb); |
$type{$tempkeyp}=&Apache::lonnet::metadata($uri,$tempkeyp.'.type'); |
$type{$tempkeyp}=&Apache::lonnet::metadata($uri,$tempkeyp.'.type',$toolsymb); |
$thistitle=&Apache::lonnet::metadata($uri,$tempkeyp.'.title'); |
$thistitle=&Apache::lonnet::metadata($uri,$tempkeyp.'.title',$toolsymb); |
} |
} |
} |
} |
my $totalparms=scalar(keys(%name)); |
my $totalparms=scalar(keys(%name)); |
if ($totalparms>0) { |
if ($totalparms>0) { |
my $firstrow=1; |
my $firstrow=1; |
my $title=&Apache::lonnet::gettitle($symbp{$rid}); |
my $title=&Apache::lonnet::gettitle($symbp{$rid}); |
|
my $navmap = Apache::lonnavmaps::navmap->new(); |
|
my @recurseup; |
|
if (ref($navmap) && $mapp{$rid}) { |
|
@recurseup = $navmap->recurseup_maps($mapp{$rid}); |
|
} |
$r->print('<tr><td style="background-color:'.$defbgone.';"'. |
$r->print('<tr><td style="background-color:'.$defbgone.';"'. |
' rowspan='.$totalparms. |
' rowspan='.$totalparms. |
'><tt><font size="-1">'. |
'><tt><font size="-1">'. |
Line 3296 ENDTABLEHEADFOUR
|
Line 3822 ENDTABLEHEADFOUR
|
&print_row($r,$item,\%part,\%name,\%symbp,$rid,\%default, |
&print_row($r,$item,\%part,\%name,\%symbp,$rid,\%default, |
\%type,\%display,$defbgone,$defbgtwo, |
\%type,\%display,$defbgone,$defbgtwo, |
$defbgthree,$parmlev,$uname,$udom,$csec, |
$defbgthree,$parmlev,$uname,$udom,$csec, |
$cgroup,\@usersgroups,$noeditgrp,$readonly); |
$cgroup,\@usersgroups,$noeditgrp,$readonly, |
|
\@recurseup,\%maptitles,\%allmaps_inverted, |
|
\$numreclinks); |
} |
} |
} |
} |
} |
} |
Line 3342 ENDTABLEHEADFOUR
|
Line 3870 ENDTABLEHEADFOUR
|
|
|
if ($map eq $mapid) { |
if ($map eq $mapid) { |
my $uri=&Apache::lonnet::declutter($uris{$rid}); |
my $uri=&Apache::lonnet::declutter($uris{$rid}); |
|
my $toolsymb; |
|
if ($uri =~ /ext\.tool$/) { |
|
$toolsymb = $symbp{$rid}; |
|
} |
|
|
# $r->print("Keys: $keyp{$rid} <br />\n"); |
# $r->print("Keys: $keyp{$rid} <br />\n"); |
|
|
#-------------------------------------------------------------------- |
#-------------------------------------------------------------------- |
Line 3357 ENDTABLEHEADFOUR
|
Line 3890 ENDTABLEHEADFOUR
|
|
|
if ((grep $_ eq $fullkeyp, @catmarker) &&(!$name{$tempkeyp})) { |
if ((grep $_ eq $fullkeyp, @catmarker) &&(!$name{$tempkeyp})) { |
$part{$tempkeyp}="0"; |
$part{$tempkeyp}="0"; |
$name{$tempkeyp}=&Apache::lonnet::metadata($uri,$fullkeyp.'.name'); |
$name{$tempkeyp}=&Apache::lonnet::metadata($uri,$fullkeyp.'.name',$toolsymb); |
my $parmdis=&Apache::lonnet::metadata($uri,$fullkeyp.'.display'); |
my $parmdis=&Apache::lonnet::metadata($uri,$fullkeyp.'.display',$toolsymb); |
if ($allparms{$name{$tempkeyp}} ne '') { |
if ($allparms{$name{$tempkeyp}} ne '') { |
my $identifier; |
my $identifier; |
if ($parmdis =~ /(\s*\[Part.*)$/) { |
if ($parmdis =~ /(\s*\[Part.*)$/) { |
Line 3371 ENDTABLEHEADFOUR
|
Line 3904 ENDTABLEHEADFOUR
|
unless ($display{$tempkeyp}) { $display{$tempkeyp}=''; } |
unless ($display{$tempkeyp}) { $display{$tempkeyp}=''; } |
$display{$tempkeyp}.=' ('.$name{$tempkeyp}.')'; |
$display{$tempkeyp}.=' ('.$name{$tempkeyp}.')'; |
$display{$tempkeyp} =~ s/_\w+_/_0_/; |
$display{$tempkeyp} =~ s/_\w+_/_0_/; |
$default{$tempkeyp}=&Apache::lonnet::metadata($uri,$fullkeyp); |
$default{$tempkeyp}=&Apache::lonnet::metadata($uri,$fullkeyp,$toolsymb); |
$type{$tempkeyp}=&Apache::lonnet::metadata($uri,$fullkeyp.'.type'); |
$type{$tempkeyp}=&Apache::lonnet::metadata($uri,$fullkeyp.'.type',$toolsymb); |
} |
} |
} # end loop through keys |
} # end loop through keys |
} |
} |
Line 3409 ENDTABLEHEADFOUR
|
Line 3942 ENDTABLEHEADFOUR
|
$r->print('<p>'.&Apache::loncommon::start_data_table() |
$r->print('<p>'.&Apache::loncommon::start_data_table() |
.&Apache::loncommon::start_data_table_header_row() |
.&Apache::loncommon::start_data_table_header_row() |
.'<th>'.&mt('Parameter Name').'</th>' |
.'<th>'.&mt('Parameter Name').'</th>' |
.'<th>'.&mt('Recursive Value').'</th>' |
.'<th>'.&mt('Value').'</th>' |
.'<th>'.&mt('Non-Recursive Value').'</th>' |
|
.'<th>'.&mt('Parameter in Effect').'</th>' |
.'<th>'.&mt('Parameter in Effect').'</th>' |
.&Apache::loncommon::end_data_table_header_row() |
.&Apache::loncommon::end_data_table_header_row() |
); |
); |
|
|
|
my $navmap = Apache::lonnavmaps::navmap->new(); |
|
my @recurseup; |
|
if (ref($navmap)) { |
|
my $mapres = $navmap->getByMapPc($mapid); |
|
if (ref($mapres)) { |
|
@recurseup = $navmap->recurseup_maps($mapres->src()); |
|
} |
|
} |
|
|
|
|
foreach my $item (&keysinorder(\%name,\%keyorder)) { |
foreach my $item (&keysinorder(\%name,\%keyorder)) { |
$r->print(&Apache::loncommon::start_data_table_row()); |
$r->print(&Apache::loncommon::start_data_table_row()); |
&print_row($r,$item,\%part,\%name,\%symbp,$mapid,\%default, |
&print_row($r,$item,\%part,\%name,\%symbp,$mapid,\%default, |
\%type,\%display,$defbgone,$defbgtwo,$defbgthree, |
\%type,\%display,$defbgone,$defbgtwo,$defbgthree, |
$parmlev,$uname,$udom,$csec,$cgroup,'',$noeditgrp, |
$parmlev,$uname,$udom,$csec,$cgroup,'',$noeditgrp, |
$readonly); |
$readonly,\@recurseup,\%maptitles,\%allmaps_inverted, |
|
\$numreclinks); |
} |
} |
$r->print(&Apache::loncommon::end_data_table().'</p>' |
$r->print(&Apache::loncommon::end_data_table().'</p>' |
.'</div>' |
.'</div>' |
Line 3447 ENDTABLEHEADFOUR
|
Line 3990 ENDTABLEHEADFOUR
|
my $rid = $id; |
my $rid = $id; |
|
|
my $uri=&Apache::lonnet::declutter($uris{$rid}); |
my $uri=&Apache::lonnet::declutter($uris{$rid}); |
|
my $toolsymb; |
|
if ($uri =~ /ext\.tool$/) { |
|
$toolsymb = $symbp{$rid}; |
|
} |
|
|
#-------------------------------------------------------------------- |
#-------------------------------------------------------------------- |
# @catmarker contains list of all possible parameters including part #s |
# @catmarker contains list of all possible parameters including part #s |
Line 3460 ENDTABLEHEADFOUR
|
Line 4007 ENDTABLEHEADFOUR
|
$tempkeyp =~ s/_\w+_/_0_/; |
$tempkeyp =~ s/_\w+_/_0_/; |
if ((grep $_ eq $fullkeyp, @catmarker) &&(!$name{$tempkeyp})) { |
if ((grep $_ eq $fullkeyp, @catmarker) &&(!$name{$tempkeyp})) { |
$part{$tempkeyp}="0"; |
$part{$tempkeyp}="0"; |
$name{$tempkeyp}=&Apache::lonnet::metadata($uri,$fullkeyp.'.name'); |
$name{$tempkeyp}=&Apache::lonnet::metadata($uri,$fullkeyp.'.name',$toolsymb); |
my $parmdis=&Apache::lonnet::metadata($uri,$fullkeyp.'.display'); |
my $parmdis=&Apache::lonnet::metadata($uri,$fullkeyp.'.display',$toolsymb); |
if ($allparms{$name{$tempkeyp}} ne '') { |
if ($allparms{$name{$tempkeyp}} ne '') { |
my $identifier; |
my $identifier; |
if ($parmdis =~ /(\s*\[Part.*)$/) { |
if ($parmdis =~ /(\s*\[Part.*)$/) { |
Line 3474 ENDTABLEHEADFOUR
|
Line 4021 ENDTABLEHEADFOUR
|
unless ($display{$tempkeyp}) { $display{$tempkeyp}=''; } |
unless ($display{$tempkeyp}) { $display{$tempkeyp}=''; } |
$display{$tempkeyp}.=' ('.$name{$tempkeyp}.')'; |
$display{$tempkeyp}.=' ('.$name{$tempkeyp}.')'; |
$display{$tempkeyp} =~ s/_\w+_/_0_/; |
$display{$tempkeyp} =~ s/_\w+_/_0_/; |
$default{$tempkeyp}=&Apache::lonnet::metadata($uri,$fullkeyp); |
$default{$tempkeyp}=&Apache::lonnet::metadata($uri,$fullkeyp,$toolsymb); |
$type{$tempkeyp}=&Apache::lonnet::metadata($uri,$fullkeyp.'.type'); |
$type{$tempkeyp}=&Apache::lonnet::metadata($uri,$fullkeyp.'.type',$toolsymb); |
} |
} |
} # end loop through keys |
} # end loop through keys |
} # end loop through ids |
} # end loop through ids |
Line 3520 ENDMAPONE
|
Line 4067 ENDMAPONE
|
} # end of $parmlev eq general |
} # end of $parmlev eq general |
} |
} |
$r->print('</form>'); |
$r->print('</form>'); |
|
if ($numreclinks) { |
|
$r->print(<<"END"); |
|
<form name="recurseform" action="/adm/parmset?action=settable" method="post"> |
|
<input type="hidden" name="pschp" /> |
|
<input type="hidden" name="pscat" /> |
|
<input type="hidden" name="psprt" /> |
|
<input type="hidden" name="hideparmsel" value="hidden" /> |
|
</form> |
|
<script type="text/javascript"> |
|
function pjumprec(rid,name,part) { |
|
document.forms.recurseform.pschp.value = rid; |
|
document.forms.recurseform.pscat.value = name; |
|
document.forms.recurseform.psprt.value = part; |
|
document.forms.recurseform.submit(); |
|
return false; |
|
} |
|
</script> |
|
END |
|
} |
&endSettingsScreen($r); |
&endSettingsScreen($r); |
$r->print(&Apache::loncommon::end_page()); |
$r->print(&Apache::loncommon::end_page()); |
} # end sub assessparms |
} # end sub assessparms |
Line 3536 my $tableopen; # boolean, true if HTML t
|
Line 4102 my $tableopen; # boolean, true if HTML t
|
# @param {boolean} $readonly - true if values cannot be edited (otherwise more columns are added) |
# @param {boolean} $readonly - true if values cannot be edited (otherwise more columns are added) |
# @returns {string} |
# @returns {string} |
sub tablestart { |
sub tablestart { |
my ($readonly) = @_; |
my ($readonly,$is_map) = @_; |
if ($tableopen) { |
if ($tableopen) { |
return ''; |
return ''; |
} else { |
} else { |
Line 3545 sub tablestart {
|
Line 4111 sub tablestart {
|
if ($readonly) { |
if ($readonly) { |
$output .= '<th>'.&mt('Current value').'</th>'; |
$output .= '<th>'.&mt('Current value').'</th>'; |
} else { |
} else { |
$output .= '<th>'.&mt('Delete').'</th><th>'.&mt('Set to ...').'</th>'; |
$output .= '<th>'.&mt('Delete').'</th>'. |
|
'<th>'.&mt('Set to ...').'</th>'; |
|
if ($is_map) { |
|
$output .= '<th>'.&mt('Recursive?').'</th>'; |
|
} |
} |
} |
$output .= '</tr>'; |
$output .= '</tr>'; |
return $output; |
return $output; |
Line 3601 sub readdata {
|
Line 4171 sub readdata {
|
# Stores parameter data, using form parameters directly. |
# Stores parameter data, using form parameters directly. |
# |
# |
# Uses the following form parameters. The variable part in the names is a resourcedata key (except for a modification for user data). |
# Uses the following form parameters. The variable part in the names is a resourcedata key (except for a modification for user data). |
# set_* (except settext, setipallow, setipdeny) - set a parameter value |
# set_* (except settext, setipallow, setipdeny, setdeeplink) - set a parameter value |
# del_* - remove a parameter |
# del_* - remove a parameter |
# datepointer_* - set a date parameter (value is key_* refering to a set of other form parameters) |
# datepointer_* - set a date parameter (value is key_* refering to a set of other form parameters) |
# dateinterval_* - set a date interval parameter (value refers to more form parameters) |
# dateinterval_* - set a date interval parameter (value refers to more form parameters) |
Line 3624 sub storedata {
|
Line 4194 sub storedata {
|
my %newdata=(); |
my %newdata=(); |
undef %newdata; |
undef %newdata; |
my @deldata=(); |
my @deldata=(); |
|
my @delrec=(); |
|
my @delnonrec=(); |
undef @deldata; |
undef @deldata; |
my ($got_chostname,$chostname,$cmajor,$cminor); |
my ($got_chostname,$chostname,$cmajor,$cminor); |
my $now = time; |
my $now = time; |
Line 3631 sub storedata {
|
Line 4203 sub storedata {
|
if ($key =~ /^form\.([a-z]+)\_(.+)$/) { |
if ($key =~ /^form\.([a-z]+)\_(.+)$/) { |
my $cmd=$1; |
my $cmd=$1; |
my $thiskey=$2; |
my $thiskey=$2; |
next if ($cmd eq 'settext' || $cmd eq 'setipallow' || $cmd eq 'setipdeny'); |
my ($altkey,$recursive,$tkey,$tkeyrec,$tkeynonrec); |
|
next if ($cmd eq 'rec' || $cmd eq 'settext' || $cmd eq 'setipallow' || $cmd eq 'setipdeny' || $cmd eq 'setdeeplink'); |
|
if ((($cmd eq 'set') || ($cmd eq 'datepointer') || ($cmd eq 'dateinterval') || ($cmd eq 'del')) && |
|
($thiskey =~ /(?:sequence|page)\Q___(all)\E/)) { |
|
unless ($thiskey =~ /(encrypturl|hiddenresource)$/) { |
|
$altkey = $thiskey; |
|
$altkey =~ s/\Q___(all)\E/___(rec)/; |
|
if ($env{'form.rec_'.$thiskey}) { |
|
$recursive = 1; |
|
} |
|
} |
|
} |
my ($tuname,$tudom)=&extractuser($thiskey); |
my ($tuname,$tudom)=&extractuser($thiskey); |
my $tkey=$thiskey; |
|
if ($tuname) { |
if ($tuname) { |
|
$tkey=$thiskey; |
$tkey=~s/\.\[useropt\:$tuname\:$tudom\]\./\./; |
$tkey=~s/\.\[useropt\:$tuname\:$tudom\]\./\./; |
|
if ($altkey) { |
|
$tkeynonrec = $tkey; |
|
$tkeyrec = $altkey; |
|
$tkeyrec=~s/\.\[useropt\:$tuname\:$tudom\]\./\./; |
|
} |
} |
} |
if ($cmd eq 'set' || $cmd eq 'datepointer' || $cmd eq 'dateinterval') { |
if ($cmd eq 'set' || $cmd eq 'datepointer' || $cmd eq 'dateinterval') { |
my ($data, $typeof, $text, $name, $valchk, $valmatch, $namematch); |
my ($data, $typeof, $text, $name, $valchk, $valmatch, $namematch); |
Line 3647 sub storedata {
|
Line 4235 sub storedata {
|
$text = &mt('Saved modified parameter for'); |
$text = &mt('Saved modified parameter for'); |
if ($typeof eq 'string_questiontype') { |
if ($typeof eq 'string_questiontype') { |
$name = 'type'; |
$name = 'type'; |
} elsif ($typeof eq 'string_lenient') { |
} elsif (($typeof eq 'string_lenient') || ($typeof eq 'string_deeplink')) { |
$name = 'lenient'; |
($name) = ($typeof =~ /^string_(lenient|deeplink)$/); |
my $stringmatch = &standard_string_matches($typeof); |
my $stringmatch = &standard_string_matches($typeof); |
if (ref($stringmatch) eq 'ARRAY') { |
if (ref($stringmatch) eq 'ARRAY') { |
foreach my $item (@{$stringmatch}) { |
foreach my $item (@{$stringmatch}) { |
Line 3719 sub storedata {
|
Line 4307 sub storedata {
|
$typeof=$env{'form.typeof_'.$thiskey}; |
$typeof=$env{'form.typeof_'.$thiskey}; |
$text = &mt('Saved modified date for'); |
$text = &mt('Saved modified date for'); |
} |
} |
if ($thiskey =~ m{\.(?:sequence|page)___\(rec\)}) { |
if ($recursive) { |
$namematch = 'maplevelrecurse'; |
$namematch = 'maplevelrecurse'; |
} |
} |
if (($name ne '') || ($namematch ne '')) { |
if (($name ne '') || ($namematch ne '')) { |
Line 3766 sub storedata {
|
Line 4354 sub storedata {
|
next; |
next; |
} |
} |
} |
} |
if (defined($data) and $$olddata{$thiskey} ne $data) { |
my ($reconlychg,$haschange,$storekey); |
if ($tuname) { |
if ($tuname) { |
if (&Apache::lonnet::put('resourcedata',{$tkey=>$data, |
my $ustorekey; |
$tkey.'.type' => $typeof}, |
if ($altkey) { |
$tudom,$tuname) eq 'ok') { |
if ($recursive) { |
&log_parmset({$tkey=>$data,$tkey.'.type' => $typeof},0,$tuname,$tudom); |
if (exists($$olddata{$thiskey})) { |
$r->print('<br />'.$text.' '. |
if ($$olddata{$thiskey} eq $data) { |
&Apache::loncommon::plainname($tuname,$tudom)); |
$reconlychg = 1; |
|
} |
|
&Apache::lonnet::del('resourcedata',[$tkeynonrec,$tkeynonrec.'.type'],$tudom,$tuname); |
|
} |
|
if (exists($$olddata{$altkey})) { |
|
if (defined($data) && $$olddata{$altkey} ne $data) { |
|
$haschange = 1; |
|
} |
|
} elsif ((!$reconlychg) && ($data ne '')) { |
|
$haschange = 1; |
|
} |
|
$ustorekey = $tkeyrec; |
|
} else { |
|
if (exists($$olddata{$altkey})) { |
|
if ($$olddata{$altkey} eq $data) { |
|
$reconlychg = 1; |
|
} |
|
&Apache::lonnet::del('resourcedata',[$tkeyrec,$tkeyrec.'.type'],$tudom,$tuname); |
|
} |
|
if (exists($$olddata{$thiskey})) { |
|
if (defined($data) && $$olddata{$thiskey} ne $data) { |
|
$haschange = 1; |
|
} |
|
} elsif ((!$reconlychg) && ($data ne '')) { |
|
$haschange = 1; |
|
} |
|
$ustorekey = $tkeynonrec; |
|
} |
|
} else { |
|
if (exists($$olddata{$tkey})) { |
|
if (defined($data) && $$olddata{$tkey} ne $data) { |
|
$haschange = 1; |
|
} |
|
$ustorekey = $tkey; |
|
} |
|
} |
|
if ($haschange || $reconlychg) { |
|
unless ($env{'form.del_'.$thiskey}) { |
|
if (&Apache::lonnet::put('resourcedata',{$ustorekey=>$data, |
|
$ustorekey.'.type' => $typeof}, |
|
$tudom,$tuname) eq 'ok') { |
|
&log_parmset({$ustorekey=>$data,$ustorekey.'.type' => $typeof},0,$tuname,$tudom); |
|
$r->print('<br />'.$text.' '. |
|
&Apache::loncommon::plainname($tuname,$tudom)); |
|
} else { |
|
$r->print('<div class="LC_error">'. |
|
&mt('Error saving parameters').'</div>'); |
|
} |
|
&Apache::lonnet::devalidateuserresdata($tuname,$tudom); |
|
} |
|
} |
|
} else { |
|
if ($altkey) { |
|
if ($recursive) { |
|
if (exists($$olddata{$thiskey})) { |
|
if ($$olddata{$thiskey} eq $data) { |
|
$reconlychg = 1; |
|
} |
|
push(@delnonrec,($thiskey,$thiskey.'.type')); |
|
} |
|
if (exists($$olddata{$altkey})) { |
|
if (defined($data) && $$olddata{$altkey} ne $data) { |
|
$haschange = 1; |
|
} |
|
} elsif (($data ne '') && (!$reconlychg)) { |
|
$haschange = 1; |
|
} |
|
$storekey = $altkey; |
} else { |
} else { |
$r->print('<div class="LC_error">'. |
if (exists($$olddata{$altkey})) { |
&mt('Error saving parameters').'</div>'); |
if ($$olddata{$altkey} eq $data) { |
|
$reconlychg = 1; |
|
} |
|
push(@delrec,($altkey,$altkey.'.type')); |
|
} |
|
if (exists($$olddata{$thiskey})) { |
|
if (defined($data) && $$olddata{$thiskey} ne $data) { |
|
$haschange = 1; |
|
} |
|
} elsif (($data ne '') && (!$reconlychg)) { |
|
$haschange = 1; |
|
} |
|
$storekey = $thiskey; |
} |
} |
&Apache::lonnet::devalidateuserresdata($tuname,$tudom); |
|
} else { |
} else { |
$newdata{$thiskey}=$data; |
if (defined($data) && $$olddata{$thiskey} ne $data) { |
$newdata{$thiskey.'.type'}=$typeof; |
$haschange = 1; |
|
$storekey = $thiskey; |
|
} |
|
} |
|
} |
|
if ($reconlychg || $haschange) { |
|
unless ($env{'form.del_'.$thiskey}) { |
|
$newdata{$storekey}=$data; |
|
$newdata{$storekey.'.type'}=$typeof; |
} |
} |
} |
} |
} elsif ($cmd eq 'del') { |
} elsif ($cmd eq 'del') { |
if ($tuname) { |
if ($tuname) { |
if (&Apache::lonnet::del('resourcedata',[$tkey],$tudom,$tuname) eq 'ok') { |
my $error; |
&log_parmset({$tkey=>''},1,$tuname,$tudom); |
if ($altkey) { |
$r->print('<br />'.&mt('Deleted parameter for').' '.&Apache::loncommon::plainname($tuname,$tudom)); |
if (exists($$olddata{$altkey})) { |
|
if (&Apache::lonnet::del('resourcedata',[$tkeyrec,$tkeyrec.'.type'],$tudom,$tuname) eq 'ok') { |
|
&log_parmset({$tkeyrec=>''},1,$tuname,$tudom); |
|
if ($recursive) { |
|
$r->print('<br />'.&mt('Deleted parameter for').' '.&Apache::loncommon::plainname($tuname,$tudom)); |
|
} |
|
} elsif ($recursive) { |
|
$error = 1; |
|
} |
|
} |
|
if (exists($$olddata{$thiskey})) { |
|
if (&Apache::lonnet::del('resourcedata',[$tkeynonrec,$tkeynonrec.'.type'],$tudom,$tuname) eq 'ok') { |
|
&log_parmset({$tkeynonrec=>''},1,$tuname,$tudom); |
|
unless ($recursive) { |
|
$r->print('<br />'.&mt('Deleted parameter for').' '.&Apache::loncommon::plainname($tuname,$tudom)); |
|
} |
|
} elsif (!$recursive) { |
|
$error = 1; |
|
} |
|
} |
} else { |
} else { |
|
if (exists($$olddata{$thiskey})) { |
|
if (&Apache::lonnet::del('resourcedata',[$tkey,$tkey.'.type'],$tudom,$tuname) eq 'ok') { |
|
&log_parmset({$tkey=>''},1,$tuname,$tudom); |
|
$r->print('<br />'.&mt('Deleted parameter for').' '.&Apache::loncommon::plainname($tuname,$tudom)); |
|
} else { |
|
$error = 1; |
|
} |
|
} |
|
} |
|
if ($error) { |
$r->print('<div class="LC_error">'. |
$r->print('<div class="LC_error">'. |
&mt('Error deleting parameters').'</div>'); |
&mt('Error deleting parameters').'</div>'); |
} |
} |
&Apache::lonnet::devalidateuserresdata($tuname,$tudom); |
&Apache::lonnet::devalidateuserresdata($tuname,$tudom); |
} else { |
} else { |
push (@deldata,$thiskey,$thiskey.'.type'); |
if ($altkey) { |
|
if (exists($$olddata{$altkey})) { |
|
unless (grep(/^\Q$altkey\E$/,@delrec)) { |
|
push(@deldata,($altkey,$altkey.'.type')); |
|
} |
|
} |
|
if (exists($$olddata{$thiskey})) { |
|
unless (grep(/^\Q$thiskey\E$/,@delnonrec)) { |
|
push(@deldata,($thiskey,$thiskey.'.type')); |
|
} |
|
} |
|
} elsif (exists($$olddata{$thiskey})) { |
|
push(@deldata,($thiskey,$thiskey.'.type')); |
|
} |
} |
} |
} |
} |
} |
} |
} |
} |
# Store all course level |
# Store all course level |
my $delentries=$#deldata+1; |
my $delentries=$#deldata+1; |
|
my @alldels; |
|
if (@delrec) { |
|
push(@alldels,@delrec); |
|
} |
|
if (@delnonrec) { |
|
push(@alldels,@delnonrec); |
|
} |
|
if (@deldata) { |
|
push(@alldels,@deldata); |
|
} |
my @newdatakeys=keys(%newdata); |
my @newdatakeys=keys(%newdata); |
my $putentries=$#newdatakeys+1; |
my $putentries=$#newdatakeys+1; |
if ($delentries) { |
my ($delresult,$devalidate); |
if (&Apache::lonnet::del('resourcedata',\@deldata,$dom,$crs) eq 'ok') { |
if (@alldels) { |
my %loghash=map { $_ => '' } @deldata; |
if (&Apache::lonnet::del('resourcedata',\@alldels,$dom,$crs) eq 'ok') { |
|
my %loghash=map { $_ => '' } @alldels; |
&log_parmset(\%loghash,1); |
&log_parmset(\%loghash,1); |
$r->print('<h2>'.&mt('Deleted [quant,_1,parameter]',$delentries/2).'</h2>'); |
if ($delentries) { |
} else { |
$r->print('<h2>'.&mt('Deleted [quant,_1,parameter]',$delentries/2).'</h2>'); |
|
} |
|
} elsif ($delentries) { |
$r->print('<div class="LC_error">'. |
$r->print('<div class="LC_error">'. |
&mt('Error deleting parameters').'</div>'); |
&mt('Error deleting parameters').'</div>'); |
} |
} |
&Apache::lonnet::devalidatecourseresdata($crs,$dom); |
$devalidate = 1; |
} |
} |
if ($putentries) { |
if ($putentries) { |
if (&Apache::lonnet::put('resourcedata',\%newdata,$dom,$crs) eq 'ok') { |
if (&Apache::lonnet::put('resourcedata',\%newdata,$dom,$crs) eq 'ok') { |
Line 3823 sub storedata {
|
Line 4552 sub storedata {
|
$r->print('<div class="LC_error">'. |
$r->print('<div class="LC_error">'. |
&mt('Error saving parameters').'</div>'); |
&mt('Error saving parameters').'</div>'); |
} |
} |
|
$devalidate = 1; |
|
} |
|
if ($devalidate) { |
&Apache::lonnet::devalidatecourseresdata($crs,$dom); |
&Apache::lonnet::devalidatecourseresdata($crs,$dom); |
} |
} |
} |
} |
Line 3883 sub listdata {
|
Line 4615 sub listdata {
|
$tableopen=0; |
$tableopen=0; |
my $foundkeys=0; |
my $foundkeys=0; |
my %keyorder=&standardkeyorder(); |
my %keyorder=&standardkeyorder(); |
|
my $readonlyall = $readonly; |
|
|
my ($secidx,%grouphash); |
my ($secidx,%grouphash); |
if (($env{'request.course.sec'} ne '') && ($caller eq 'overview')) { |
if (($env{'request.course.sec'} ne '') && ($caller eq 'overview')) { |
Line 3890 sub listdata {
|
Line 4623 sub listdata {
|
if (&Apache::lonnet::allowed('mdg',$env{'request.course.id'})) { |
if (&Apache::lonnet::allowed('mdg',$env{'request.course.id'})) { |
%grouphash = &Apache::longroup::coursegroups(); |
%grouphash = &Apache::longroup::coursegroups(); |
} elsif ($env{'request.course.groups'} ne '') { |
} elsif ($env{'request.course.groups'} ne '') { |
map { $grouphash{$_} = 1; } split(/,/,$env{'request.course.groups'}); |
map { $grouphash{$_} = 1; } split(/:/,$env{'request.course.groups'}); |
} |
} |
} |
} |
|
|
foreach my $thiskey (sort { |
foreach my $key (sort { |
my ($astudent,$ares,$apart,$aparm) = &parse_listdata_key($a,$listdata); |
my ($astudent,$ares,$apart,$aparm) = &parse_listdata_key($a,$listdata); |
my ($bstudent,$bres,$bpart,$bparm) = &parse_listdata_key($b,$listdata); |
my ($bstudent,$bres,$bpart,$bparm) = &parse_listdata_key($b,$listdata); |
|
|
Line 3934 sub listdata {
|
Line 4667 sub listdata {
|
|
|
$result; |
$result; |
|
|
} keys(%{$listdata})) { # foreach my $thiskey |
} keys(%{$listdata})) { # foreach my $key |
|
my $thiskey = $key; |
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 3944 sub listdata {
|
Line 4677 sub listdata {
|
my ($middle,$part,$name)= |
my ($middle,$part,$name)= |
($thiskey=~/^$env{'request.course.id'}\.(?:(.+)\.)*([\w\s\-]+)\.(\w+)$/); |
($thiskey=~/^$env{'request.course.id'}\.(?:(.+)\.)*([\w\s\-]+)\.(\w+)$/); |
my $section=&mt('All Students'); |
my $section=&mt('All Students'); |
|
$readonly = $readonlyall; |
|
my $userscope; |
|
my $showval = $$resourcedata{$thiskey}; |
if ($middle=~/^\[(.*)\]/) { |
if ($middle=~/^\[(.*)\]/) { |
my $issection=$1; |
my $issection=$1; |
if ($issection=~/^useropt\:($match_username)\:($match_domain)/) { |
if ($issection=~/^useropt\:($match_username)\:($match_domain)/) { |
Line 3956 sub listdata {
|
Line 4692 sub listdata {
|
} |
} |
} |
} |
$section=&mt('User').": ".&Apache::loncommon::plainname($stuname,$studom); |
$section=&mt('User').": ".&Apache::loncommon::plainname($stuname,$studom); |
|
$userscope = 1; |
} else { |
} else { |
if (($env{'request.course.sec'} ne '') && ($caller eq 'overview')) { |
if (($env{'request.course.sec'} ne '') && ($caller eq 'overview')) { |
if (exists($grouphash{$issection})) { |
if (exists($grouphash{$issection})) { |
Line 3976 sub listdata {
|
Line 4713 sub listdata {
|
$middle=~s/\.+$//; |
$middle=~s/\.+$//; |
$middle=~s/^\.+//; |
$middle=~s/^\.+//; |
my $realm='<span class="LC_parm_scope_all">'.&mt('All Resources').'</span>'; |
my $realm='<span class="LC_parm_scope_all">'.&mt('All Resources').'</span>'; |
if ($middle=~/^(.+)\_\_\_\((all|rec)\)$/) { |
my ($is_map,$is_recursive,$mapurl,$maplevel); |
my $mapurl = $1; |
if ($caller eq 'overview') { |
my $maplevel = $2; |
if ($middle=~/^(.+)\_\_\_\((all|rec)\)$/) { |
|
$mapurl = $1; |
|
$maplevel = $2; |
|
$is_map = 1; |
|
} |
|
} elsif ($caller eq 'newoverview') { |
|
if ($middle=~/^(.+)\_\_\_\((all)\)$/) { |
|
$mapurl = $1; |
|
$maplevel = $2; |
|
$is_map = 1; |
|
} |
|
} |
|
if ($is_map) { |
my $leveltitle = &mt('Folder/Map'); |
my $leveltitle = &mt('Folder/Map'); |
if ($maplevel eq 'rec') { |
unless (($name eq 'hiddenresource') || ($name eq 'encrypturl')) { |
$leveltitle = &mt('Recursive'); |
if ($caller eq 'newoverview') { |
|
my $altkey = $thiskey; |
|
$altkey =~ s/\Q___(all)\E/___(rec)/; |
|
if ((exists($$resourcedata{$altkey})) & (!exists($$resourcedata{$thiskey}))) { |
|
$is_recursive = 1; |
|
if ($$resourcedata{$altkey.'.type'}) { |
|
$thistype=$$resourcedata{$altkey.'.type'}; |
|
} |
|
$showval = $$resourcedata{$altkey}; |
|
} |
|
} elsif (($caller eq 'overview') && ($maplevel eq 'rec')) { |
|
$thiskey =~ s/\Q___(rec)\E/___(all)/; |
|
$is_recursive = 1; |
|
} |
} |
} |
$realm='<span class="LC_parm_scope_folder">'.$leveltitle.': '.&Apache::lonnet::gettitle($mapurl).' <br /><span class="LC_parm_folder">('.$mapurl.')</span></span>'; |
$realm='<span class="LC_parm_scope_folder">'.$leveltitle.': '.&Apache::lonnet::gettitle($mapurl).' <br /><span class="LC_parm_folder">('.$mapurl.')</span></span>'; |
} elsif ($middle) { |
} elsif ($middle) { |
Line 4023 sub listdata {
|
Line 4785 sub listdata {
|
# Ready to print |
# Ready to print |
# |
# |
my $parmitem = &standard_parameter_names($name); |
my $parmitem = &standard_parameter_names($name); |
$r->print(&tablestart($readonly). |
$r->print(&tablestart($readonly,$is_map). |
&Apache::loncommon::start_data_table_row(). |
&Apache::loncommon::start_data_table_row(). |
'<td><b>'.&mt($parmitem). |
'<td><b>'.&mt($parmitem). |
'</b></td>'); |
'</b></td>'); |
unless ($readonly) { |
unless ($readonly) { |
|
my $disabled; |
|
if (($name eq 'availablestudent') && |
|
(($showval eq '') || ($userscope))) { |
|
$disabled = ' disabled="disabled"'; |
|
} |
$r->print('<td><input type="checkbox" name="del_'. |
$r->print('<td><input type="checkbox" name="del_'. |
$thiskey.'" /></td>'); |
$thiskey.'"'.$disabled.' /></td>'); |
} |
} |
$r->print('<td>'); |
$r->print('<td>'); |
$foundkeys++; |
$foundkeys++; |
Line 4043 sub listdata {
|
Line 4810 sub listdata {
|
$r->print( |
$r->print( |
&Apache::lonhtmlcommon::date_setter('parmform', |
&Apache::lonhtmlcommon::date_setter('parmform', |
$jskey, |
$jskey, |
$$resourcedata{$thiskey}, |
$showval, |
'',1,$state)); |
'',1,$state)); |
unless ($readonly) { |
unless ($readonly) { |
$r->print( |
$r->print( |
'<input type="hidden" name="datepointer_'.$thiskey.'" value="'.$jskey.'" />'. |
'<input type="hidden" name="datepointer_'.$thiskey.'" value="'.$jskey.'" />'. |
(($$resourcedata{$thiskey}!=0)?'<span class="LC_nobreak"><a href="/adm/parmset?&action=dateshift1&timebase='.$$resourcedata{$thiskey}.'">'. |
(($showval!=0)?'<span class="LC_nobreak"><a href="/adm/parmset?&action=dateshift1&timebase='.$showval.'">'. |
&mt('Shift all dates based on this date').'</a></span>':''). |
&mt('Shift all dates based on this date').'</a></span>':''). |
&date_sanity_info($$resourcedata{$thiskey}) |
&date_sanity_info($showval) |
); |
); |
} |
} |
} elsif ($thistype eq 'date_interval') { |
} elsif ($thistype eq 'date_interval') { |
$r->print(&date_interval_selector($thiskey,$name, |
$r->print(&date_interval_selector($thiskey,$name, |
$$resourcedata{$thiskey},$readonly)); |
$showval,$readonly)); |
} elsif ($thistype =~ m/^string/) { |
} elsif ($thistype =~ m/^string/) { |
|
if ($name eq 'availablestudent') { |
|
$readonly = 1; |
|
} |
$r->print(&string_selector($thistype,$thiskey, |
$r->print(&string_selector($thistype,$thiskey, |
$$resourcedata{$thiskey},$name,$readonly)); |
$showval,$name,$readonly)); |
} else { |
} else { |
$r->print(&default_selector($thiskey,$$resourcedata{$thiskey},$readonly)); |
$r->print(&default_selector($thiskey,$showval,$readonly)); |
} |
} |
unless ($readonly) { |
unless ($readonly) { |
$r->print('<input type="hidden" name="typeof_'.$thiskey.'" value="'. |
$r->print('<input type="hidden" name="typeof_'.$thiskey.'" value="'. |
$thistype.'" />'); |
$thistype.'" />'); |
} |
} |
$r->print('</td>'.&Apache::loncommon::end_data_table_row()); |
$r->print('</td>'); |
|
if ($is_map) { |
|
if (($name eq 'encrypturl') || ($name eq 'hiddenresource')) { |
|
$r->print('<td><table><tr><td>'.&mt('Yes').'</td></tr></table></td>'); |
|
} else { |
|
my ($disabled,$recon,$recoff); |
|
if ($readonly) { |
|
$disabled = ' disabled="disabled"'; |
|
} |
|
if ($is_recursive) { |
|
$recon = ' checked="checked"'; |
|
} else { |
|
$recoff = ' checked="checked"'; |
|
} |
|
$r->print('<td><table><tr><td><label><input type="radio" name="rec_'.$thiskey.'" value="1"'.$recon.$disabled.' />'.&mt('Yes').'</label>'. |
|
'</td><td><label><input type="radio" name="rec_'.$thiskey.'" value="0"'.$recoff.$disabled.' />'.&mt('No').'</label></td></tr></table></td>'); |
|
} |
|
} |
|
$r->print(&Apache::loncommon::end_data_table_row()); |
} |
} |
} |
} |
return $foundkeys; |
return $foundkeys; |
Line 4191 sub string_ip_selector {
|
Line 4979 sub string_ip_selector {
|
return $output; |
return $output; |
} |
} |
|
|
|
sub string_deeplink_selector { |
|
my ($thiskey, $showval, $readonly) = @_; |
|
my (@components,%values,@current,%titles,%options,%optiontext,%defaults, |
|
%selectnull,%posslti,@possmenus); |
|
@components = ('listing','scope','urls','menus'); |
|
%titles = &Apache::lonlocal::texthash ( |
|
listing => 'In Contents and/or Gradebook', |
|
scope => 'Access scope for link', |
|
urls => 'Supported link types', |
|
menus => 'Menu Items Displayed', |
|
); |
|
%options = ( |
|
listing => ['full','absent','grades','details','datestatus'], |
|
scope => ['res','map','rec'], |
|
urls => ['any','only','key','lti'], |
|
menus => ['std','colls'], |
|
); |
|
%optiontext = &Apache::lonlocal::texthash ( |
|
full => 'Listed (linked) in both', |
|
absent => 'Not listed', |
|
grades => 'Listed in grades only', |
|
details => 'Listed (unlinked) in both', |
|
datestatus => 'Listed (unlinked) inc. status in both', |
|
res => 'resource only', |
|
map => 'enclosing map/folder', |
|
rec => 'recursive map/folder', |
|
any => 'regular + deep', |
|
only => 'deep only', |
|
key => 'deep with key', |
|
lti => 'deep with LTI launch', |
|
std => 'Standard (all menus)', |
|
colls => 'Numbered collection', |
|
); |
|
%selectnull = &Apache::lonlocal::texthash ( |
|
lti => 'Select Provider', |
|
colls => 'Select', |
|
); |
|
if ($showval =~ /,/) { |
|
%values=(); |
|
@current = split(/,/,$showval); |
|
($values{'listing'}) = ($current[0] =~ /^(full|absent|grades|details|datestatus)$/); |
|
($values{'scope'}) = ($current[1] =~ /^(res|map|rec)$/); |
|
($values{'urls'}) = ($current[2] =~ /^(any|only|key:[a-zA-Z\d_.!\@#\$%^&*()+=-]+|lti:\d+)$/); |
|
($values{'menus'}) = ($current[3] =~ /^(\d+)$/); |
|
} else { |
|
$defaults{'listing'} = 'full'; |
|
$defaults{'scope'} = 'res'; |
|
$defaults{'urls'} = 'any'; |
|
$defaults{'menus'} = '0'; |
|
} |
|
my $disabled; |
|
if ($readonly) { |
|
$disabled=' disabled="disabled"'; |
|
} |
|
my %lti = |
|
&Apache::lonnet::get_domain_lti($env{'course.'.$env{'request.course.id'}.'.domain'}, |
|
'provider'); |
|
foreach my $item (keys(%lti)) { |
|
if (ref($lti{$item}) eq 'HASH') { |
|
unless ($lti{$item}{'requser'}) { |
|
$posslti{$item} = $lti{$item}{'consumer'}; |
|
} |
|
} |
|
} |
|
if ($env{'course.'.$env{'request.course.id'}.'.menucollections'}) { |
|
foreach my $item (split(/;/,$env{'course.'.$env{'request.course.id'}.'.menucollections'})) { |
|
my ($num,$value) = split(/\%/,$item); |
|
if ($num =~ /^\d+$/) { |
|
push(@possmenus,$num); |
|
} |
|
} |
|
} |
|
|
|
my $output = '<input type="hidden" name="set_'.$thiskey.'" /><table><tr>'; |
|
foreach my $item (@components) { |
|
$output .= '<th>'.$titles{$item}.'</th>'; |
|
} |
|
$output .= '</tr><tr>'; |
|
foreach my $item (@components) { |
|
$output .= '<td>'; |
|
if (($item eq 'urls') || ($item eq 'menus')) { |
|
my $selected = $values{$item}; |
|
foreach my $option (@{$options{$item}}) { |
|
if (($item eq 'urls') && ($option eq 'lti')) { |
|
next unless (keys(%posslti)); |
|
} elsif (($item eq 'menus') && ($option eq 'colls')) { |
|
next unless (@possmenus); |
|
} |
|
my $checked; |
|
if ($item eq 'menus') { |
|
if (($selected =~ /^\d+$/) && (@possmenus) && |
|
(grep(/^\Q$selected\E$/,@possmenus))) { |
|
if ($option eq 'colls') { |
|
$checked = ' checked="checked"'; |
|
} |
|
} elsif (($option eq 'std') && ($selected == 0) && ($selected ne '')) { |
|
$checked = ' checked="checked"'; |
|
} |
|
} elsif ($selected =~ /^\Q$option\E/) { |
|
$checked = ' checked="checked"'; |
|
} |
|
my $onclick; |
|
unless ($readonly) { |
|
my $esc_key = &js_escape($thiskey); |
|
$onclick = ' onclick="toggleDeepLink(this.form,'."'$item','$esc_key'".');"'; |
|
} |
|
$output .= '<span class="LC_nobreak"><label>'. |
|
'<input type="radio" name="deeplink_'.$item.'_'.$thiskey.'" value="'.$option.'"'.$onclick.$disabled.$checked.' />'."\n". |
|
$optiontext{$option}.'</label>'; |
|
if (($item eq 'urls') && ($option eq 'key')) { |
|
my $visibility="hidden"; |
|
my $currkey; |
|
if ($checked) { |
|
$visibility = "text"; |
|
$currkey = (split(/\:/,$values{$item}))[1]; |
|
} |
|
$output .= ' '. |
|
'<input type="'.$visibility.'" name="deeplink_'.$option.'_'.$thiskey.'" id="deeplink_'.$option.'_'.$item.'_'.$thiskey.'" value="'.$currkey.'" size="10"'.$disabled.' />'; |
|
} elsif (($option eq 'lti') || ($option eq 'colls')) { |
|
my $display="none"; |
|
my ($current,$blankcheck,@possibles); |
|
if ($checked) { |
|
$display = 'inline-block'; |
|
if ($option eq 'lti') { |
|
$current = (split(/\:/,$selected))[1]; |
|
} else { |
|
$current = $selected; |
|
} |
|
} else { |
|
$blankcheck = ' selected="selected"'; |
|
} |
|
if ($option eq 'lti') { |
|
@possibles = keys(%posslti); |
|
} else { |
|
@possibles = @possmenus; |
|
} |
|
$output .= '<div id="deeplinkdiv_'.$option.'_'.$item.'_'.$thiskey.'"'. |
|
' style="display: '.$display.'"> <select name="'. |
|
'deeplink_'.$option.'_'.$thiskey.'"'.$disabled.'>'; |
|
if (@possibles > 1) { |
|
$output .= '<option value=""'.$blankcheck.'>'.$selectnull{$option}. |
|
'</option>'."\n"; |
|
} |
|
foreach my $poss (sort { $a <=> $b } @possibles) { |
|
my $selected; |
|
if (($poss == $current) || (scalar(@possibles) ==1)) { |
|
$selected = ' selected="selected"'; |
|
} |
|
my $shown = $poss; |
|
if ($option eq 'lti') { |
|
$shown = $posslti{$poss}; |
|
} |
|
$output .= '<option value="'.$poss.'"'.$selected.'>'.$shown.'</option>'; |
|
} |
|
$output .= '</select></div>'; |
|
} |
|
$output .= '</span> '; |
|
} |
|
} else { |
|
my $selected = $values{$item}; |
|
my $defsel; |
|
if ($selected eq '') { |
|
$defsel = ' selected="selected"'; |
|
} |
|
$output .= '<select name="deeplink_'.$item.'_'.$thiskey.'"'.$disabled.'>'."\n". |
|
'<option value=""'.$defsel.'>'.&mt('Please select').'</option>'."\n"; |
|
foreach my $option (@{$options{$item}}) { |
|
$output .= '<option value="'.$option.'"'; |
|
if ($option eq $selected) { |
|
$output .= ' selected="selected"'; |
|
} |
|
$output .= '>'.$optiontext{$option}.'</option>'; |
|
} |
|
$output .= '</select>'; |
|
} |
|
$output .= '</td>'; |
|
} |
|
$output .= '</tr></table>'."\n"; |
|
return $output; |
|
} |
|
|
|
|
{ # block using some constants related to parameter types (overview mode) |
{ # block using some constants related to parameter types (overview mode) |
|
|
Line 4224 my %strings =
|
Line 5193 my %strings =
|
['no','No']], |
['no','No']], |
'string_ip' |
'string_ip' |
=> [['_allowfrom_','Hostname(s), or IP(s) from which access is allowed'], |
=> [['_allowfrom_','Hostname(s), or IP(s) from which access is allowed'], |
['_denyfrom_',], 'Hostname(s) or IP(s) from which access is disallowed'], |
['_denyfrom_','Hostname(s) or IP(s) from which access is disallowed']], |
); |
'string_deeplink' |
|
=> [['on','Set choices for link protection, resource listing, access scope, and shown menu items']], |
|
); |
|
|
|
|
my %stringmatches = ( |
my %stringmatches = ( |
'string_lenient' |
'string_lenient' |
Line 4233 my %stringmatches = (
|
Line 5205 my %stringmatches = (
|
'string_ip' |
'string_ip' |
=> [['_allowfrom_','[^\!]+'], |
=> [['_allowfrom_','[^\!]+'], |
['_denyfrom_','\!']], |
['_denyfrom_','\!']], |
|
'string_deeplink' |
|
=> [['on','^(full|absent|grades|details|datestatus)\,(res|map|rec)\,(any|only|key\:\w+|lti\:\d+)\,(\d+|)$']], |
); |
); |
|
|
my %stringtypes = ( |
my %stringtypes = ( |
Line 4242 my %stringtypes = (
|
Line 5216 my %stringtypes = (
|
discussvote => 'string_discussvote', |
discussvote => 'string_discussvote', |
examcode => 'string_examcode', |
examcode => 'string_examcode', |
acc => 'string_ip', |
acc => 'string_ip', |
|
deeplink => 'string_deeplink', |
); |
); |
|
|
# Returns the possible values and titles for a given string type, or undef if there are none. |
# Returns the possible values and titles for a given string type, or undef if there are none. |
Line 4301 sub string_selector {
|
Line 5276 sub string_selector {
|
($thistype eq 'string_lenient') || |
($thistype eq 'string_lenient') || |
($thistype eq 'string_discussvote') || |
($thistype eq 'string_discussvote') || |
($thistype eq 'string_ip') || |
($thistype eq 'string_ip') || |
|
($thistype eq 'string_deeplink') || |
($name eq 'retrypartial')) { |
($name eq 'retrypartial')) { |
my ($got_chostname,$chostname,$cmajor,$cminor); |
my ($got_chostname,$chostname,$cmajor,$cminor); |
foreach my $possibilities (@{ $strings{$thistype} }) { |
foreach my $possibilities (@{ $strings{$thistype} }) { |
Line 4339 sub string_selector {
|
Line 5315 sub string_selector {
|
|
|
if ($thistype eq 'string_ip') { |
if ($thistype eq 'string_ip') { |
return &string_ip_selector($thiskey,$showval,$readonly); |
return &string_ip_selector($thiskey,$showval,$readonly); |
|
} elsif ($thistype eq 'string_deeplink') { |
|
return &string_deeplink_selector($thiskey,$showval,$readonly); |
} |
} |
|
|
my ($result,$disabled); |
my ($result,$disabled); |
Line 4694 sub oldversion_warning {
|
Line 5672 sub oldversion_warning {
|
# @param {integer} $shift - time to shift, in seconds |
# @param {integer} $shift - time to shift, in seconds |
# @returns {string} - error name or 'ok' |
# @returns {string} - error name or 'ok' |
sub dateshift { |
sub dateshift { |
my ($shift)=@_; |
my ($shift,$numchanges)=@_; |
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 $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); |
my %data=&Apache::lonnet::dump('resourcedata',$dom,$crs); |
# ugly retro fix for broken version of types |
# ugly retro fix for broken version of types |
foreach my $key (keys(%data)) { |
foreach my $key (keys(%data)) { |
Line 4711 sub dateshift {
|
Line 5702 sub dateshift {
|
# go through all parameters and look for dates |
# go through all parameters and look for dates |
foreach my $key (keys(%data)) { |
foreach my $key (keys(%data)) { |
if ($data{$key.'.type'}=~/^date_(start|end)$/) { |
if ($data{$key.'.type'}=~/^date_(start|end)$/) { |
|
if ($sec ne '') { |
|
next unless ($key =~ /^$env{'request.course.id'}\.\[$secgrpregex\]\./); |
|
} |
my $newdate=$data{$key}+$shift; |
my $newdate=$data{$key}+$shift; |
|
$$numchanges ++; |
$storecontent{$key}=$newdate; |
$storecontent{$key}=$newdate; |
} |
} |
} |
} |
Line 4753 sub newoverview {
|
Line 5748 sub newoverview {
|
&validateparms_js()."\n". |
&validateparms_js()."\n". |
&ipacc_boxes_js()."\n". |
&ipacc_boxes_js()."\n". |
&done_proctor_js()."\n". |
&done_proctor_js()."\n". |
|
&deeplink_js()."\n". |
'// ]]> |
'// ]]> |
</script> |
</script> |
'; |
'; |
Line 4839 ENDOVER
|
Line 5835 ENDOVER
|
|
|
$r->print('<div class="LC_Box">'); |
$r->print('<div class="LC_Box">'); |
$r->print('<div>'); |
$r->print('<div>'); |
&displaymenu($r,\%allparms,\@pscat,\%keyorder); # FIXME: wrong parameters, could make keysindisplayorderCategory crash because $keyorder is undefined |
&displaymenu($r,\%allparms,\@pscat,\%keyorder); |
$r->print(&Apache::lonhtmlcommon::start_pick_box()); |
$r->print(&Apache::lonhtmlcommon::start_pick_box()); |
$r->print(&Apache::lonhtmlcommon::row_title(&mt('Select Parts to View'))); |
$r->print(&Apache::lonhtmlcommon::row_title(&mt('Select Parts to View'))); |
my $sectionselector = §ionmenu(\@selected_sections); |
my $sectionselector = §ionmenu(\@selected_sections); |
Line 4940 sub secgroup_lister {
|
Line 5936 sub secgroup_lister {
|
my $newparmkey=$rootparmkey.'.'.$$allmaps{$mapid}.'___(all).'.$part.'.'.$cat; |
my $newparmkey=$rootparmkey.'.'.$$allmaps{$mapid}.'___(all).'.$part.'.'.$cat; |
$$listdata{$newparmkey}=1; |
$$listdata{$newparmkey}=1; |
$$listdata{$newparmkey.'.type'}=$$defkeytype{$cat}; |
$$listdata{$newparmkey.'.type'}=$$defkeytype{$cat}; |
$newparmkey=$rootparmkey.'.'.$$allmaps{$mapid}.'___(rec).'.$part.'.'.$cat; |
|
$$listdata{$newparmkey}=1; |
|
$$listdata{$newparmkey.'.type'}=$$defkeytype{$cat}; |
|
} |
} |
} else { |
} else { |
# resource-level parameter |
# resource-level parameter |
Line 4977 sub overview {
|
Line 5970 sub overview {
|
&validateparms_js()."\n". |
&validateparms_js()."\n". |
&ipacc_boxes_js()."\n". |
&ipacc_boxes_js()."\n". |
&done_proctor_js()."\n". |
&done_proctor_js()."\n". |
|
&deeplink_js()."\n". |
'// ]]>'."\n". |
'// ]]>'."\n". |
'</script>'."\n"; |
'</script>'."\n"; |
&Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=setoverview', |
&Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=setoverview', |
Line 5088 ENDOVER
|
Line 6082 ENDOVER
|
$r->print(&mt('All users')); |
$r->print(&mt('All users')); |
} elsif ($data{'scope_type'} eq 'user') { |
} elsif ($data{'scope_type'} eq 'user') { |
$r->print(&mt('User: [_1]',join(':',@{$data{'scope'}}))); |
$r->print(&mt('User: [_1]',join(':',@{$data{'scope'}}))); |
} elsif ($data{'scope_type'} eq 'section') { |
} elsif ($data{'scope_type'} eq 'secgroup') { |
$r->print(&mt('Section: [_1]',$data{'scope'})); |
$r->print(&mt('Group/Section: [_1]',$data{'scope'})); |
} elsif ($data{'scope_type'} eq 'group') { |
|
$r->print(&mt('Group: [_1]',$data{'scope'})); |
|
} |
} |
$r->print('<br />'); |
$r->print('<br />'); |
if ($data{'realm_type'} eq 'all') { |
if ($data{'realm_type'} eq 'all') { |
Line 5126 sub date_shift_one {
|
Line 6118 sub date_shift_one {
|
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 $crstype = $env{'course.'.$env{'request.course.id'}.'.type'}; |
my $crstype = $env{'course.'.$env{'request.course.id'}.'.type'}; |
|
my $sec = $env{'request.course.sec'}; |
&Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=dateshift1&timebase='.$env{'form.timebase'}, |
&Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=dateshift1&timebase='.$env{'form.timebase'}, |
text=>"Shifting Dates"}); |
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 $start_page=&Apache::loncommon::start_page('Shift Dates'); |
my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs('Shift'); |
my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs('Shift'); |
$r->print($start_page.$breadcrumbs); |
$r->print($start_page.$breadcrumbs); |
Line 5144 sub date_shift_one {
|
Line 6148 sub date_shift_one {
|
'</td></tr></table>'. |
'</td></tr></table>'. |
'<input type="hidden" name="action" value="dateshift2" />'. |
'<input type="hidden" name="action" value="dateshift2" />'. |
'<input type="hidden" name="timebase" value="'.$env{'form.timebase'}.'" />'. |
'<input type="hidden" name="timebase" value="'.$env{'form.timebase'}.'" />'. |
'<input type="submit" value="'.&mt('Shift all dates accordingly').'" /></form>'); |
'<input type="submit" value="'.$submit_text.'" /></form>'); |
&endSettingsScreen($r); |
&endSettingsScreen($r); |
$r->print(&Apache::loncommon::end_page()); |
$r->print(&Apache::loncommon::end_page()); |
} |
} |
Line 5156 sub date_shift_two {
|
Line 6160 sub date_shift_two {
|
my ($r) = @_; |
my ($r) = @_; |
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 $sec = $env{'request.course.sec'}; |
my $crstype = $env{'course.'.$env{'request.course.id'}.'.type'}; |
my $crstype = $env{'course.'.$env{'request.course.id'}.'.type'}; |
&Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=dateshift1&timebase='.$env{'form.timebase'}, |
&Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=dateshift1&timebase='.$env{'form.timebase'}, |
text=>"Shifting Dates"}); |
text=>"Shifting Dates"}); |
Line 5164 sub date_shift_two {
|
Line 6169 sub date_shift_two {
|
$r->print($start_page.$breadcrumbs); |
$r->print($start_page.$breadcrumbs); |
&startSettingsScreen($r,'parmset',$crstype); |
&startSettingsScreen($r,'parmset',$crstype); |
my $timeshifted=&Apache::lonhtmlcommon::get_date_from_form('timeshifted'); |
my $timeshifted=&Apache::lonhtmlcommon::get_date_from_form('timeshifted'); |
$r->print('<h2>'.&mt('Shift Dates').'</h2>'. |
$r->print('<h2>'.&mt('Shift Dates').'</h2>'); |
'<p>'.&mt('Shifting all dates such that [_1] becomes [_2]', |
if ($sec ne '') { |
&Apache::lonlocal::locallocaltime($env{'form.timebase'}), |
my @groups; |
&Apache::lonlocal::locallocaltime($timeshifted)).'</p>'); |
if ($env{'request.course.groups'} ne '') { |
|
@groups = split(/:/,$env{'request.course.groups'}); |
|
} |
|
if (@groups) { |
|
$r->print('<p>'. |
|
&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)). |
|
'</p>'); |
|
} else { |
|
$r->print('<p>'. |
|
&mt("Shift dates set just for your section, such that [_1] becomes [_2]", |
|
&Apache::lonlocal::locallocaltime($env{'form.timebase'}), |
|
&Apache::lonlocal::locallocaltime($timeshifted)). |
|
'</p>'); |
|
} |
|
} else { |
|
$r->print('<p>'.&mt('Shifting all dates such that [_1] becomes [_2]', |
|
&Apache::lonlocal::locallocaltime($env{'form.timebase'}), |
|
&Apache::lonlocal::locallocaltime($timeshifted)). |
|
'</p>'); |
|
} |
my $delta=$timeshifted-$env{'form.timebase'}; |
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( |
$r->print( |
&Apache::lonhtmlcommon::confirm_success(&mt('Done')). |
|
'<br /><br />'. |
'<br /><br />'. |
&Apache::lonhtmlcommon::actionbox( |
&Apache::lonhtmlcommon::actionbox( |
['<a href="/adm/parmset">'.&mt('Content and Problem Settings').'</a>'])); |
['<a href="/adm/parmset">'.&mt('Content and Problem Settings').'</a>'])); |
Line 5198 sub parse_key {
|
Line 6236 sub parse_key {
|
$data{'scope_type'} = 'user'; |
$data{'scope_type'} = 'user'; |
$data{'scope'} = [$1,$2]; |
$data{'scope'} = [$1,$2]; |
} else { |
} else { |
#FIXME check for group scope |
$data{'scope_type'} = 'secgroup'; |
$data{'scope_type'} = 'section'; |
|
} |
} |
$middle=~s/^\[(.*)\]//; |
$middle=~s/^\[(.*)\]//; |
} |
} |
Line 5545 sub continue {
|
Line 6582 sub continue {
|
my $output; |
my $output; |
$output .= '<form action="" method="post">'; |
$output .= '<form action="" method="post">'; |
$output .= '<input type="hidden" name="action" value="setrestrictmeta" />'; |
$output .= '<input type="hidden" name="action" value="setrestrictmeta" />'; |
$output .= '<input type="submit" value="Continue" />'; |
$output .= '<input type="submit" value="'.&mt('Continue').'" />'; |
return ($output); |
return ($output); |
} |
} |
|
|
Line 5573 sub addmetafield {
|
Line 6610 sub addmetafield {
|
my $put_result = &Apache::lonnet::put('environment', |
my $put_result = &Apache::lonnet::put('environment', |
{'metadata.'.$meta_field.'.options'=>$options},$dom,$crs); |
{'metadata.'.$meta_field.'.options'=>$options},$dom,$crs); |
|
|
$r->print('Undeleted Metadata Field <strong>'.$env{'course.'.$env{'request.course.id'}.'.metadata.'.$meta_field.'.added'}."</strong> with result ".$put_result.'<br />'); |
$r->print(&mt('Undeleted Metadata Field [_1] with result [_2]', |
|
'<strong>'.$env{'course.'.$env{'request.course.id'}.'.metadata.'.$meta_field.'.added'}. |
|
'</strong>',$put_result). |
|
'<br />'); |
} |
} |
$r->print(&continue()); |
$r->print(&continue()); |
} elsif (exists($env{'form.fieldname'})) { |
} elsif (exists($env{'form.fieldname'})) { |
Line 5585 sub addmetafield {
|
Line 6625 sub addmetafield {
|
{'metadata.'.$meta_field.'.values'=>"", |
{'metadata.'.$meta_field.'.values'=>"", |
'metadata.'.$meta_field.'.added'=>"$display_field", |
'metadata.'.$meta_field.'.added'=>"$display_field", |
'metadata.'.$meta_field.'.options'=>""},$dom,$crs); |
'metadata.'.$meta_field.'.options'=>""},$dom,$crs); |
$r->print('Added new Metadata Field <strong>'.$env{'form.fieldname'}."</strong> with result ".$put_result.'<br />'); |
$r->print(&mt('Added new Metadata Field [_1] with result [_2]', |
|
'<strong>'.$env{'form.fieldname'}.'</strong>',$put_result). |
|
'<br />'); |
$r->print(&continue()); |
$r->print(&continue()); |
} else { |
} else { |
my $fields = &get_deleted_meta_fieldnames($env{'request.course.id'}); |
my $fields = &get_deleted_meta_fieldnames($env{'request.course.id'}); |
if ($fields) { |
if ($fields) { |
$r->print('You may undelete previously deleted fields.<br />Check those you wish to undelete and click Undelete.<br />'); |
$r->print(&mt('You may undelete previously deleted fields.'). |
|
'<br />'. |
|
&mt('Check those you wish to undelete and click Undelete.'). |
|
'<br />'); |
$r->print('<form method="post" action="">'); |
$r->print('<form method="post" action="">'); |
foreach my $key(keys(%$fields)) { |
foreach my $key(keys(%$fields)) { |
$r->print('<input type="checkbox" name="undeletefield" value="'.$key.'" />'.$$fields{$key}.'<br /'); |
$r->print('<label><input type="checkbox" name="undeletefield" value="'.$key.'" />'.$$fields{$key}.'</label><br /'); |
} |
} |
$r->print('<input type="submit" name="undelete" value="Undelete" />'); |
$r->print('<input type="submit" name="undelete" value="'.&mt('Undelete').'" />'); |
$r->print('</form>'); |
$r->print('</form>'); |
} |
} |
$r->print('<hr /><strong>Or</strong> you may enter a new metadata field name.<form method="post" action="/adm/parmset?action=addmetadata">'); |
$r->print('<hr />'. |
|
&mt('[_1]Or[_2] you may enter a new metadata field name.', |
|
'<strong>','</strong>'). |
|
'<form method="post" action="/adm/parmset?action=addmetadata">'); |
$r->print('<input type="text" name="fieldname" /><br />'); |
$r->print('<input type="text" name="fieldname" /><br />'); |
$r->print('<input type="submit" value="Add Metadata Field" />'); |
$r->print('<input type="submit" value="'.&mt('Add Metadata Field').'" />'); |
|
$r->print('</form>'); |
} |
} |
$r->print('</form>'); |
|
&endSettingsScreen($r); |
&endSettingsScreen($r); |
} |
} |
|
|
Line 5627 sub setrestrictmeta {
|
Line 6675 sub setrestrictmeta {
|
&startSettingsScreen($r,'parmset',$crstype); |
&startSettingsScreen($r,'parmset',$crstype); |
my $key_base = $env{'course.'.$env{'request.course.id'}.'.'}; |
my $key_base = $env{'course.'.$env{'request.course.id'}.'.'}; |
my $save_field = ''; |
my $save_field = ''; |
|
my %lt = &Apache::lonlocal::texthash( |
|
addm => 'Add Metadata Field', |
|
ordm => 'Order Metadata Fields', |
|
save => 'Save', |
|
); |
if ($env{'form.restrictmeta'}) { |
if ($env{'form.restrictmeta'}) { |
foreach my $field (sort(keys(%env))) { |
foreach my $field (sort(keys(%env))) { |
if ($field=~m/^form.(.+)_(.+)$/) { |
if ($field=~m/^form.(.+)_(.+)$/) { |
Line 5665 sub setrestrictmeta {
|
Line 6718 sub setrestrictmeta {
|
my %metadata_fields = &Apache::lonmeta::fieldnames('portfolio'); |
my %metadata_fields = &Apache::lonmeta::fieldnames('portfolio'); |
# Now get possible added metadata fields |
# Now get possible added metadata fields |
my $added_metadata_fields = &get_added_meta_fieldnames($env{'request.course.id'}); |
my $added_metadata_fields = &get_added_meta_fieldnames($env{'request.course.id'}); |
my $row_alt = 1; |
|
$output .= &Apache::loncommon::start_data_table(); |
$output .= &Apache::loncommon::start_data_table(); |
foreach my $field (sort(keys(%metadata_fields))) { |
foreach my $field (sort(keys(%metadata_fields))) { |
if ($field ne 'courserestricted') { |
if ($field ne 'courserestricted') { |
$row_alt = $row_alt ? 0 : 1; |
$output.= &output_row($r,$field,$metadata_fields{$field}); |
$output.= &output_row($r, $field, $metadata_fields{$field}); |
|
} |
} |
} |
} |
my $buttons = (<<ENDButtons); |
my $buttons = (<<ENDButtons); |
<input type="submit" name="restrictmeta" value="Save" /> |
<input type="submit" name="restrictmeta" value="$lt{'save'}" /> |
</form><br /> |
</form><br /> |
<form method="post" action="/adm/parmset?action=addmetadata" name="form1"> |
<form method="post" action="/adm/parmset?action=addmetadata" name="form1"> |
<input type="submit" name="restrictmeta" value="Add a Metadata Field" /> |
<input type="submit" name="restrictmeta" value="$lt{'addm'}" /> |
</form> |
</form> |
<br /> |
<br /> |
<form method="post" action="/adm/parmset?action=ordermetadata" name="form2"> |
<form method="post" action="/adm/parmset?action=ordermetadata" name="form2"> |
<input type="submit" name="restrictmeta" value="Order Metadata Fields" /> |
<input type="submit" name="restrictmeta" value="$lt{'ordm'}" /> |
ENDButtons |
ENDButtons |
my $added_flag = 1; |
my $added_flag = 1; |
foreach my $field (sort(keys(%$added_metadata_fields))) { |
foreach my $field (sort(keys(%$added_metadata_fields))) { |
$row_alt = $row_alt ? 0 : 1; |
$output.= &output_row($r,$field,$$added_metadata_fields{$field},$added_flag); |
$output.= &output_row($r, $field, $$added_metadata_fields{$field},$added_flag, $row_alt); # FIXME: wrong parameters |
|
} |
} |
$output .= &Apache::loncommon::end_data_table(); |
$output .= &Apache::loncommon::end_data_table(); |
$r->print(<<ENDenv); |
$r->print(<<ENDenv); |
Line 5925 ENDYESNO
|
Line 6975 ENDYESNO
|
# $issection - section or group name |
# $issection - section or group name |
# $realmdescription - title for the parameter level and resource (without using HTML) |
# $realmdescription - title for the parameter level and resource (without using HTML) |
# |
# |
# FIXME: remove unused fields. |
|
# |
|
# @param {string} $key - parameter log key |
# @param {string} $key - parameter log key |
# @param {string} $uname - user name |
# @param {string} $uname - user name |
# @param {string} $udom - user domain |
# @param {string} $udom - user domain |
# @param {string} $exeuser - unused |
|
# @param {string} $exedomain - unused |
|
# @param {boolean} $typeflag - .type log entry |
# @param {boolean} $typeflag - .type log entry |
# @returns {Array} |
# @returns {Array} |
sub components { |
sub components { |
my ($key,$uname,$udom,$exeuser,$exedomain,$typeflag)=@_; |
my ($key,$uname,$udom,$typeflag)=@_; |
|
|
if ($typeflag) { |
if ($typeflag) { |
$key=~s/\.type$//; |
$key=~s/\.type$//; |
Line 5987 my %standard_parms_types; # hash paramet
|
Line 7033 my %standard_parms_types; # hash paramet
|
|
|
# Reads parameter info from packages.tab into %standard_parms. |
# Reads parameter info from packages.tab into %standard_parms. |
sub load_parameter_names { |
sub load_parameter_names { |
open(my $config,"<$Apache::lonnet::perlvar{'lonTabDir'}/packages.tab"); |
open(my $config,"<","$Apache::lonnet::perlvar{'lonTabDir'}/packages.tab"); |
while (my $configline=<$config>) { |
while (my $configline=<$config>) { |
if ($configline !~ /\S/ || $configline=~/^\#/) { next; } |
if ($configline !~ /\S/ || $configline=~/^\#/) { next; } |
chomp($configline); |
chomp($configline); |
Line 6002 sub load_parameter_names {
|
Line 7048 sub load_parameter_names {
|
close($config); |
close($config); |
$standard_parms{'int_pos'} = 'Positive Integer'; |
$standard_parms{'int_pos'} = 'Positive Integer'; |
$standard_parms{'int_zero_pos'} = 'Positive Integer or Zero'; |
$standard_parms{'int_zero_pos'} = 'Positive Integer or Zero'; |
|
$standard_parms{'scoreformat'} = 'Format for display of score'; |
} |
} |
|
|
# Returns a parameter title for standard parameters, the name for others. |
# Returns a parameter title for standard parameters, the name for others. |
Line 6112 sub parm_change_log {
|
Line 7159 sub parm_change_log {
|
} |
} |
if ($last) { ($folder) = &Apache::lonnet::decode_symb($last); } |
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 { |
foreach my $id (sort { |
if ($parmlog{$b}{'exe_time'} ne $parmlog{$a}{'exe_time'}) { |
if ($parmlog{$b}{'exe_time'} ne $parmlog{$a}{'exe_time'}) { |
return $parmlog{$b}{'exe_time'} <=>$parmlog{$a}{'exe_time'} |
return $parmlog{$b}{'exe_time'} <=>$parmlog{$a}{'exe_time'} |
Line 6149 sub parm_change_log {
|
Line 7202 sub parm_change_log {
|
my $typeflag = ($changed =~/\.type$/ && |
my $typeflag = ($changed =~/\.type$/ && |
!exists($parmlog{$id}{'logentry'}{$changed.'.type'})); |
!exists($parmlog{$id}{'logentry'}{$changed.'.type'})); |
my ($realm,$section,$parmname,$part,$what,$middle,$uname,$udom,$issection,$realmdescription)= |
my ($realm,$section,$parmname,$part,$what,$middle,$uname,$udom,$issection,$realmdescription)= |
&components($changed,$parmlog{$id}{'uname'},$parmlog{$id}{'udom'},undef,undef,$typeflag); |
&components($changed,$parmlog{$id}{'uname'},$parmlog{$id}{'udom'},$typeflag); |
if ($env{'request.course.sec'} ne '') { |
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 '') { |
if ($uname ne '') { |
my $stusection = &Apache::lonnet::getsection($uname,$udom,$env{'request.course.id'}); |
my $stusection = &Apache::lonnet::getsection($uname,$udom,$env{'request.course.id'}); |
next if (($stusection ne '-1') && ($stusection ne $env{'request.course.sec'})); |
next if (($stusection ne '-1') && ($stusection ne $env{'request.course.sec'})); |
Line 6185 sub parm_change_log {
|
Line 7239 sub parm_change_log {
|
$parmitem = &mt($parmitem); |
$parmitem = &mt($parmitem); |
$output .= &mt('Type: [_1]',$parmitem); |
$output .= &mt('Type: [_1]',$parmitem); |
} else { |
} else { |
|
my $toolsymb; |
|
if ($middle =~ /ext\.tool$/) { |
|
$toolsymb = $middle; |
|
} |
my ($level,@all)=&parmval_by_symb($what,$middle, |
my ($level,@all)=&parmval_by_symb($what,$middle, |
&Apache::lonnet::metadata($middle,$what), |
&Apache::lonnet::metadata($middle,$what,$toolsymb), |
$uname,$udom,$issection,$issection,$courseopt); |
$uname,$udom,$issection,$issection,$courseopt); |
my $showvalue = $value; |
my $showvalue = $value; |
if ($istype{$parmname} eq '') { |
if ($istype{$parmname} eq '') { |