version 1.207, 2005/06/04 15:26:13
|
version 1.252, 2005/09/28 13:29:17
|
Line 70 my $parmhashid;
|
Line 70 my $parmhashid;
|
my %parmhash; |
my %parmhash; |
my $symbsid; |
my $symbsid; |
my %symbs; |
my %symbs; |
|
my $rulesid; |
|
my %rules; |
|
|
# --- end local caches |
# --- end local caches |
|
|
Line 240 sub symbcache {
|
Line 242 sub symbcache {
|
return $symbs{$id}; |
return $symbs{$id}; |
} |
} |
|
|
|
sub resetrulescache { |
|
$rulesid=''; |
|
} |
|
|
|
sub rulescache { |
|
my $id=shift; |
|
if ($rulesid ne $env{'request.course.id'}) { |
|
%rules=(); |
|
} |
|
unless (defined($rules{$id})) { |
|
my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'}; |
|
my $crs = $env{'course.'.$env{'request.course.id'}.'.num'}; |
|
%rules=&Apache::lonnet::dump('parmdefactions',$dom,$crs); |
|
$rulesid=$env{'request.course.id'}; |
|
} |
|
return $rules{$id}; |
|
} |
|
|
|
sub preset_defaults { |
|
my $type=shift; |
|
if (&rulescache($type.'_action') eq 'default') { |
|
# yes, there is something |
|
return (&rulescache($type.'_hours'), |
|
&rulescache($type.'_min'), |
|
&rulescache($type.'_sec'), |
|
&rulescache($type.'_value')); |
|
} else { |
|
# nothing there or something else |
|
return ('','','','',''); |
|
} |
|
} |
|
|
################################################## |
################################################## |
################################################## |
################################################## |
# |
# |
Line 271 sub storeparm {
|
Line 305 sub storeparm {
|
# - username |
# - username |
# - userdomain |
# - userdomain |
|
|
|
my %recstack; |
sub storeparm_by_symb { |
sub storeparm_by_symb { |
|
my ($symb,$spnam,$snum,$nval,$ntype,$uname,$udom,$csec,$recflag)=@_; |
|
unless ($recflag) { |
|
# first time call |
|
%recstack=(); |
|
$recflag=1; |
|
} |
|
# store parameter |
|
&storeparm_by_symb_inner |
|
($symb,$spnam,$snum,$nval,$ntype,$uname,$udom,$csec); |
|
my ($prefix,$parm)=($spnam=~/^(.*[\_\.])([^\_\.]+)$/); |
|
# remember that this was set |
|
$recstack{$parm}=1; |
|
# what does this trigger? |
|
foreach my $triggered (split(/\:/,&rulescache($parm.'_triggers'))) { |
|
# don't backfire |
|
unless ((!$triggered) || ($recstack{$triggered})) { |
|
my $action=&rulescache($triggered.'_action'); |
|
my ($whichaction,$whichparm)=($action=~/^(.*\_)([^\_]+)$/); |
|
# set triggered parameter on same level |
|
my $newspnam=$prefix.$triggered; |
|
my $newvalue=''; |
|
my $active=1; |
|
if ($action=~/^when\_setting/) { |
|
# are there restrictions? |
|
if (&rulescache($triggered.'_triggervalue')=~/\w/) { |
|
$active=0; |
|
foreach my $possiblevalue (split(/\s*\,\s*/,&rulescache($triggered.'_triggervalue'))) { |
|
if (lc($possiblevalue) eq lc($nval)) { $active=1; } |
|
} |
|
} |
|
$newvalue=&rulescache($triggered.'_value'); |
|
} else { |
|
my $totalsecs=((&rulescache($triggered.'_days')*24+&rulescache($triggered.'_hours'))*60+&rulescache($triggered.'_min'))*60+&rulescache($triggered.'_sec'); |
|
if ($action=~/^later\_than/) { |
|
$newvalue=$nval+$totalsecs; |
|
} else { |
|
$newvalue=$nval-$totalsecs; |
|
} |
|
} |
|
if ($active) { |
|
&storeparm_by_symb($symb,$newspnam,$snum,$newvalue,&rulescache($triggered.'_type'), |
|
$uname,$udom,$csec,$recflag); |
|
} |
|
} |
|
} |
|
return ''; |
|
} |
|
|
|
sub storeparm_by_symb_inner { |
# ---------------------------------------------------------- Get symb, map, etc |
# ---------------------------------------------------------- Get symb, map, etc |
my ($symb,$spnam,$snum,$nval,$ntype,$uname,$udom,$csec)=@_; |
my ($symb,$spnam,$snum,$nval,$ntype,$uname,$udom,$csec)=@_; |
# ---------------------------------------------------------- Construct prefixes |
# ---------------------------------------------------------- Construct prefixes |
Line 403 sub valout {
|
Line 487 sub valout {
|
$result.=$sec.' secs '; |
$result.=$sec.' secs '; |
} |
} |
$result=~s/\s+$//; |
$result=~s/\s+$//; |
} elsif ($type=~/^date/) { |
} elsif (&isdateparm($type)) { |
$result = localtime($value); |
$result = localtime($value); |
} else { |
} else { |
$result = $value; |
$result = $value; |
Line 434 sub plink {
|
Line 518 sub plink {
|
my ($type,$dis,$value,$marker,$return,$call)=@_; |
my ($type,$dis,$value,$marker,$return,$call)=@_; |
my $winvalue=$value; |
my $winvalue=$value; |
unless ($winvalue) { |
unless ($winvalue) { |
if ($type=~/^date/) { |
if (&isdateparm($type)) { |
$winvalue=$env{'form.recent_'.$type}; |
$winvalue=$env{'form.recent_'.$type}; |
} else { |
} else { |
$winvalue=$env{'form.recent_'.(split(/\_/,$type))[0]}; |
$winvalue=$env{'form.recent_'.(split(/\_/,$type))[0]}; |
} |
} |
} |
} |
|
my ($parmname)=((split(/\&/,$marker))[1]=~/\_([^\_]+)$/); |
|
my ($hour,$min,$sec,$val)=&preset_defaults($parmname); |
|
unless (defined($winvalue)) { $winvalue=$val; } |
return |
return |
'<a href="javascript:pjump('."'".$type."','".$dis."','".$winvalue."','" |
'<a href="javascript:pjump('."'".$type."','".$dis."','".$winvalue."','" |
.$marker."','".$return."','".$call."'".');">'. |
.$marker."','".$return."','".$call."','".$hour."','".$min."','".$sec."'".');">'. |
&valout($value,$type).'</a><a name="'.$marker.'"></a>'; |
&valout($value,$type).'</a><a name="'.$marker.'"></a>'; |
} |
} |
|
|
sub startpage { |
sub startpage { |
my ($r,$id,$udom,$csec,$uname,$have_assessments)=@_; |
my $r=shift; |
|
|
my $bodytag=&Apache::loncommon::bodytag('Set/Modify Course Parameters','', |
my $bodytag=&Apache::loncommon::bodytag('Set/Modify Course Parameters','', |
'onUnload="pclose()"'); |
'onUnload="pclose()"'); |
my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs(undef,'Table Mode Parameter Setting'); |
my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs(undef,'Table Mode Parameter Setting'); |
my $chooseopt=&Apache::loncommon::select_dom_form($udom,'udom').' '. |
|
&Apache::loncommon::selectstudent_link('parmform','uname','udom'); |
|
my $selscript=&Apache::loncommon::studentbrowser_javascript(); |
my $selscript=&Apache::loncommon::studentbrowser_javascript(); |
my $pjump_def = &Apache::lonhtmlcommon::pjump_javascript_definition(); |
my $pjump_def = &Apache::lonhtmlcommon::pjump_javascript_definition(); |
my %lt=&Apache::lonlocal::texthash( |
|
'captm' => "Course Assessments Parameters - Table Mode", |
|
'sg' => "Section/Group", |
|
'fu' => "For User", |
|
'oi' => "or ID", |
|
'ad' => "at Domain" |
|
); |
|
my $html=&Apache::lonxml::xmlbegin(); |
my $html=&Apache::lonxml::xmlbegin(); |
$r->print(<<ENDHEAD); |
$r->print(<<ENDHEAD); |
$html |
$html |
Line 513 $selscript
|
Line 591 $selscript
|
</head> |
</head> |
$bodytag |
$bodytag |
$breadcrumbs |
$breadcrumbs |
ENDHEAD |
|
my %sectionhash=(); |
|
my $sections=''; |
|
if (&Apache::loncommon::get_sections( |
|
$env{'course.'.$env{'request.course.id'}.'.domain'}, |
|
$env{'course.'.$env{'request.course.id'}.'.num'}, |
|
\%sectionhash)) { |
|
$sections=$lt{'sg'}.': <select name="csec">'; |
|
foreach ('',sort keys %sectionhash) { |
|
$sections.='<option value="'.$_.'"'. |
|
($_ eq $csec?'selected="selected"':'').'>'.$_.'</option>'; |
|
} |
|
$sections.='</select>'; |
|
} |
|
$r->print(<<ENDHEAD3); |
|
<form method="post" action="/adm/parmset?action=settable" name="parmform"> |
<form method="post" action="/adm/parmset?action=settable" name="parmform"> |
<h4>$lt{'captm'}</h4> |
|
ENDHEAD3 |
|
|
|
if (!$have_assessments) { |
|
$r->print('<font color="red">'.&mt('There are no assessment parameters in this course to set.').'</font><br />'); |
|
} else { |
|
$r->print(<<ENDHEAD); |
|
<b> |
|
$sections |
|
<br /> |
|
$lt{'fu'} |
|
<input type="text" value="$uname" size="12" name="uname" /> |
|
$lt{'oi'} |
|
<input type="text" value="$id" size="12" name="id" /> |
|
$lt{'ad'} |
|
$chooseopt |
|
</b> |
|
<input type="hidden" value='' name="pres_value"> |
<input type="hidden" value='' name="pres_value"> |
<input type="hidden" value='' name="pres_type"> |
<input type="hidden" value='' name="pres_type"> |
<input type="hidden" value='' name="pres_marker"> |
<input type="hidden" value='' name="pres_marker"> |
|
<input type="hidden" value='1' name="prevvisit"> |
ENDHEAD |
ENDHEAD |
} |
|
} |
} |
|
|
|
|
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,$parmlev,$uname,$udom,$csec)=@_; |
$defbgtwo,$parmlev,$uname,$udom,$csec)=@_; |
Line 582 sub print_row {
|
Line 629 sub print_row {
|
} else { |
} else { |
$parm=~s|\[.*\]\s||g; |
$parm=~s|\[.*\]\s||g; |
} |
} |
|
my $automatic=&rulescache(($which=~/\_([^\_]+)$/)[0].'_triggers'); |
|
if ($automatic) { |
|
$parm.='<font color="red"><br />'.&mt('Automatically sets').' '.join(', ',split(/\:/,$automatic)).'</font>'; |
|
} |
$r->print('<td bgcolor='.$defbgone.'>'.$parm.'</td>'); |
$r->print('<td bgcolor='.$defbgone.'>'.$parm.'</td>'); |
|
|
my $thismarker=$which; |
my $thismarker=$which; |
Line 700 sub extractResourceInformation {
|
Line 750 sub extractResourceInformation {
|
my $keyp = shift; |
my $keyp = shift; |
my $allparms = shift; |
my $allparms = shift; |
my $allparts = shift; |
my $allparts = shift; |
my $allkeys = shift; |
|
my $allmaps = shift; |
my $allmaps = shift; |
my $fcat = shift; |
|
my $defp = shift; |
|
my $mapp = shift; |
my $mapp = shift; |
my $symbp = shift; |
my $symbp = shift; |
my $maptitles=shift; |
my $maptitles=shift; |
my $uris=shift; |
my $uris=shift; |
|
my $keyorder=shift; |
|
my $defkeytype=shift; |
|
|
|
my $keyordercnt=100; |
|
|
my $navmap = Apache::lonnavmaps::navmap->new(); |
my $navmap = Apache::lonnavmaps::navmap->new(); |
my @allres=$navmap->retrieveResources(undef,undef,1,undef,1); |
my @allres=$navmap->retrieveResources(undef,undef,1,undef,1); |
Line 725 sub extractResourceInformation {
|
Line 775 sub extractResourceInformation {
|
foreach (split(/\,/,&Apache::lonnet::metadata($srcf,'allpossiblekeys'))) { |
foreach (split(/\,/,&Apache::lonnet::metadata($srcf,'allpossiblekeys'))) { |
if ($_=~/^parameter\_(.*)/) { |
if ($_=~/^parameter\_(.*)/) { |
my $key=$_; |
my $key=$_; |
my $allkey=$1; |
# Hidden parameters |
$allkey=~s/\_/\./g; |
if (&Apache::lonnet::metadata($srcf,$key.'.hidden') eq 'parm') { |
if (&Apache::lonnet::metadata($srcf,$key.'.hidden') eq |
next; |
'parm') { |
|
next; #hide hidden things |
|
} |
} |
my $display= &Apache::lonnet::metadata($srcf,$key.'.display'); |
my $display= &Apache::lonnet::metadata($srcf,$key.'.display'); |
my $name=&Apache::lonnet::metadata($srcf,$key.'.name'); |
my $name=&Apache::lonnet::metadata($srcf,$key.'.name'); |
my $part= &Apache::lonnet::metadata($srcf,$key.'.part'); |
my $part= &Apache::lonnet::metadata($srcf,$key.'.part'); |
|
# |
|
# allparms is a hash of parameter names |
|
# |
my $parmdis = $display; |
my $parmdis = $display; |
$parmdis =~ s|(\[Part.*)$||g; |
$parmdis =~ s/\[Part.*$//g; |
my $partkey = $part; |
$$allparms{$name}=$parmdis; |
$partkey =~ tr|_|.|; |
$$defkeytype{$name}=&Apache::lonnet::metadata($srcf,$key.'.type'); |
$$allparms{$name} = $parmdis; |
# |
$$allparts{$part} = "[Part $part]"; |
# allparts is a hash of all parts |
$$allkeys{$allkey}=$display; |
# |
if ($allkey eq $fcat) { |
$$allparts{$part} = "Part: $part"; |
$$defp{$id}= &Apache::lonnet::metadata($srcf,$key); |
# |
} |
# Remember all keys going with this resource |
|
# |
if ($$keyp{$id}) { |
if ($$keyp{$id}) { |
$$keyp{$id}.=','.$key; |
$$keyp{$id}.=','.$key; |
} else { |
} else { |
$$keyp{$id}=$key; |
$$keyp{$id}=$key; |
} |
} |
|
# |
|
# Put in order |
|
# |
|
unless ($$keyorder{$key}) { |
|
$$keyorder{$key}=$keyordercnt; |
|
$keyordercnt++; |
|
} |
|
|
} |
} |
} |
} |
$$mapp{$id}= |
$$mapp{$id}= |
Line 766 sub extractResourceInformation {
|
Line 826 sub extractResourceInformation {
|
} |
} |
} |
} |
|
|
|
|
|
################################################## |
|
################################################## |
|
|
|
sub isdateparm { |
|
my $type=shift; |
|
return (($type=~/^date/) && (!($type eq 'date_interval'))); |
|
} |
|
|
|
sub parmmenu { |
|
my ($r,$allparms,$pscat,$keyorder)=@_; |
|
my $tempkey; |
|
$r->print(<<ENDSCRIPT); |
|
<script type="text/javascript"> |
|
function checkall(value, checkName) { |
|
for (i=0; i<document.forms.parmform.elements.length; i++) { |
|
ele = document.forms.parmform.elements[i]; |
|
if (ele.name == checkName) { |
|
document.forms.parmform.elements[i].checked=value; |
|
} |
|
} |
|
} |
|
|
|
function checkthis(thisvalue, checkName) { |
|
for (i=0; i<document.forms.parmform.elements.length; i++) { |
|
ele = document.forms.parmform.elements[i]; |
|
if (ele.name == checkName) { |
|
if (ele.value == thisvalue) { |
|
document.forms.parmform.elements[i].checked=true; |
|
} |
|
} |
|
} |
|
} |
|
|
|
function checkdates() { |
|
checkthis('duedate','pscat'); |
|
checkthis('opendate','pscat'); |
|
checkthis('answerdate','pscat'); |
|
} |
|
|
|
function checkdisset() { |
|
checkthis('discussend','pscat'); |
|
checkthis('discusshide','pscat'); |
|
} |
|
|
|
function checkcontdates() { |
|
checkthis('contentopen','pscat'); |
|
checkthis('contentclose','pscat'); |
|
} |
|
|
|
|
|
function checkvisi() { |
|
checkthis('hiddenresource','pscat'); |
|
checkthis('encrypturl','pscat'); |
|
checkthis('problemstatus','pscat'); |
|
checkthis('contentopen','pscat'); |
|
checkthis('opendate','pscat'); |
|
} |
|
|
|
function checkparts() { |
|
checkthis('hiddenparts','pscat'); |
|
checkthis('display','pscat'); |
|
checkthis('ordered','pscat'); |
|
} |
|
|
|
function checkstandard() { |
|
checkall(false,'pscat'); |
|
checkdates(); |
|
checkthis('weight','pscat'); |
|
checkthis('maxtries','pscat'); |
|
} |
|
|
|
</script> |
|
ENDSCRIPT |
|
$r->print(); |
|
$r->print("\n<table><tr>"); |
|
my $cnt=0; |
|
foreach $tempkey (&keysindisplayorder($allparms,$keyorder)) { |
|
$r->print("\n<td><font size='-1'><label><input type='checkbox' name='pscat' "); |
|
$r->print('value="'.$tempkey.'"'); |
|
if ($$pscat[0] eq "all" || grep $_ eq $tempkey, @{$pscat}) { |
|
$r->print(' checked'); |
|
} |
|
$r->print('>'.$$allparms{$tempkey}.'</label></font></td>'); |
|
$cnt++; |
|
if ($cnt==3) { |
|
$r->print("</tr>\n<tr>"); |
|
$cnt=0; |
|
} |
|
} |
|
$r->print(' |
|
</tr><tr><td> |
|
<a href="javascript:checkall(true, \'pscat\')">Select All</a><br /> |
|
<a href="javascript:checkstandard()">Select Common Only</a> |
|
</td><td> |
|
<a href="javascript:checkdates()">Add Problem Dates</a> |
|
<a href="javascript:checkcontdates()">Add Content Dates</a><br /> |
|
<a href="javascript:checkdisset()">Add Discussion Settings</a> |
|
<a href="javascript:checkvisi()">Add Visibilities</a><br /> |
|
<a href="javascript:checkparts()">Add Part Parameters</a> |
|
</td><td> |
|
<a href="javascript:checkall(false, \'pscat\')">Unselect All</a> |
|
</td> |
|
'); |
|
$r->print('</tr></table>'); |
|
} |
|
|
|
sub partmenu { |
|
my ($r,$allparts,$psprt)=@_; |
|
$r->print('<select multiple name="psprt" size="8">'); |
|
$r->print('<option value="all"'); |
|
$r->print(' selected') unless (@{$psprt}); |
|
$r->print('>'.&mt('All Parts').'</option>'); |
|
my %temphash=(); |
|
foreach (@{$psprt}) { $temphash{$_}=1; } |
|
foreach my $tempkey (sort { |
|
if ($a==$b) { return ($a cmp $b) } else { return ($a <=> $b); } |
|
} keys(%{$allparts})) { |
|
unless ($tempkey =~ /\./) { |
|
$r->print('<option value="'.$tempkey.'"'); |
|
if ($$psprt[0] eq "all" || $temphash{$tempkey}) { |
|
$r->print(' selected'); |
|
} |
|
$r->print('>'.$$allparts{$tempkey}.'</option>'); |
|
} |
|
} |
|
$r->print('</select>'); |
|
} |
|
|
|
sub usermenu { |
|
my ($r,$uname,$id,$udom,$csec)=@_; |
|
my $chooseopt=&Apache::loncommon::select_dom_form($udom,'udom').' '. |
|
&Apache::loncommon::selectstudent_link('parmform','uname','udom'); |
|
my $selscript=&Apache::loncommon::studentbrowser_javascript(); |
|
my %lt=&Apache::lonlocal::texthash( |
|
'sg' => "Section/Group", |
|
'fu' => "For User", |
|
'oi' => "or ID", |
|
'ad' => "at Domain" |
|
); |
|
my %sectionhash=(); |
|
my $sections=''; |
|
if (&Apache::loncommon::get_sections( |
|
$env{'course.'.$env{'request.course.id'}.'.domain'}, |
|
$env{'course.'.$env{'request.course.id'}.'.num'}, |
|
\%sectionhash)) { |
|
$sections=$lt{'sg'}.': <select name="csec">'; |
|
foreach ('',sort keys %sectionhash) { |
|
$sections.='<option value="'.$_.'"'. |
|
($_ eq $csec?'selected="selected"':'').'>'.$_.'</option>'; |
|
} |
|
$sections.='</select>'; |
|
} |
|
$r->print(<<ENDMENU); |
|
<b> |
|
$sections |
|
<br /> |
|
$lt{'fu'} |
|
<input type="text" value="$uname" size="12" name="uname" /> |
|
$lt{'oi'} |
|
<input type="text" value="$id" size="12" name="id" /> |
|
$lt{'ad'} |
|
$chooseopt |
|
</b> |
|
ENDMENU |
|
} |
|
|
|
sub displaymenu { |
|
my ($r,$allparms,$allparts,$pscat,$psprt,$keyorder)=@_; |
|
$r->print('<table border="1"><tr><th>'.&mt('Select Parameters to View').'</th><th>'. |
|
&mt('Select Parts to View').'</th></tr><tr><td>'); |
|
&parmmenu($r,$allparms,$pscat,$keyorder); |
|
$r->print('</td><td>'); |
|
&partmenu($r,$allparts,$psprt); |
|
$r->print('</td></tr></table>'); |
|
} |
|
|
|
sub mapmenu { |
|
my ($r,$allmaps,$pschp,$maptitles)=@_; |
|
$r->print('<b>'.&mt('Select Enclosing Map or Folder').'</b> '); |
|
$r->print('<select name="pschp">'); |
|
$r->print('<option value="all">'.&mt('All Maps or Folders').'</option>'); |
|
foreach (sort {$$allmaps{$a} cmp $$allmaps{$b}} keys %{$allmaps}) { |
|
$r->print('<option value="'.$_.'"'); |
|
if (($pschp eq $_)) { $r->print(' selected'); } |
|
$r->print('>'.$$maptitles{$_}.($$allmaps{$_}!~/^uploaded/?' ['.$$allmaps{$_}.']':'').'</option>'); |
|
} |
|
$r->print("</select>"); |
|
} |
|
|
|
sub levelmenu { |
|
my ($r,$alllevs,$parmlev)=@_; |
|
$r->print('<b>'.&mt('Select Parameter Level'). |
|
&Apache::loncommon::help_open_topic('Course_Parameter_Levels').'</b> '); |
|
$r->print('<select name="parmlev">'); |
|
foreach (reverse sort keys %{$alllevs}) { |
|
$r->print('<option value="'.$$alllevs{$_}.'"'); |
|
if ($parmlev eq $$alllevs{$_}) { |
|
$r->print(' selected'); |
|
} |
|
$r->print('>'.$_.'</option>'); |
|
} |
|
$r->print("</select>"); |
|
} |
|
|
|
|
|
sub sectionmenu { |
|
my ($r,$selectedsections)=@_; |
|
my %sectionhash=(); |
|
|
|
if (&Apache::loncommon::get_sections( |
|
$env{'course.'.$env{'request.course.id'}.'.domain'}, |
|
$env{'course.'.$env{'request.course.id'}.'.num'}, |
|
\%sectionhash)) { |
|
$r->print('<select name="Section" multiple="true" size="8" >'); |
|
foreach my $s ('all',sort keys %sectionhash) { |
|
$r->print(' <option value="'.$s.'"'); |
|
foreach (@{$selectedsections}) { |
|
if ($s eq $_) { |
|
$r->print(' selected'); |
|
last; |
|
} |
|
} |
|
$r->print('>'.$s."</option>\n"); |
|
} |
|
$r->print("</select>\n"); |
|
} |
|
} |
|
|
|
sub keysplit { |
|
my $keyp=shift; |
|
return (split(/\,/,$keyp)); |
|
} |
|
|
|
sub keysinorder { |
|
my ($name,$keyorder)=@_; |
|
return sort { |
|
$$keyorder{$a} <=> $$keyorder{$b}; |
|
} (keys %{$name}); |
|
} |
|
|
|
sub keysinorder_bytype { |
|
my ($name,$keyorder)=@_; |
|
return sort { |
|
my $ta=(split('_',$a))[-1]; |
|
my $tb=(split('_',$b))[-1]; |
|
if ($$keyorder{'parameter_0_'.$ta} == $$keyorder{'parameter_0_'.$tb}) { |
|
return ($a cmp $b); |
|
} |
|
$$keyorder{'parameter_0_'.$ta} <=> $$keyorder{'parameter_0_'.$tb}; |
|
} (keys %{$name}); |
|
} |
|
|
|
sub keysindisplayorder { |
|
my ($name,$keyorder)=@_; |
|
return sort { |
|
$$keyorder{'parameter_0_'.$a} <=> $$keyorder{'parameter_0_'.$b}; |
|
} (keys %{$name}); |
|
} |
|
|
|
sub sortmenu { |
|
my ($r,$sortorder)=@_; |
|
$r->print('<br /><label><input type="radio" name="sortorder" value="realmstudent"'); |
|
if ($sortorder eq 'realmstudent') { |
|
$r->print(' checked="on"'); |
|
} |
|
$r->print(' />'.&mt('Sort by realm first, then student (group/section)')); |
|
$r->print('</label><br /><label><input type="radio" name="sortorder" value="studentrealm"'); |
|
if ($sortorder eq 'studentrealm') { |
|
$r->print(' checked="on"'); |
|
} |
|
$r->print(' />'.&mt('Sort by student (group/section) first, then realm'). |
|
'</label>'); |
|
} |
|
|
|
sub standardkeyorder { |
|
return ('parameter_0_opendate' => 1, |
|
'parameter_0_duedate' => 2, |
|
'parameter_0_answerdate' => 3, |
|
'parameter_0_interval' => 4, |
|
'parameter_0_weight' => 5, |
|
'parameter_0_maxtries' => 6, |
|
'parameter_0_hinttries' => 7, |
|
'parameter_0_contentopen' => 8, |
|
'parameter_0_contentclose' => 9, |
|
'parameter_0_type' => 10, |
|
'parameter_0_problemstatus' => 11, |
|
'parameter_0_hiddenresource' => 12, |
|
'parameter_0_hiddenparts' => 13, |
|
'parameter_0_display' => 14, |
|
'parameter_0_ordered' => 15, |
|
'parameter_0_tol' => 16, |
|
'parameter_0_sig' => 17, |
|
'parameter_0_turnoffunit' => 18, |
|
'parameter_0_discussend' => 19, |
|
'parameter_0_discusshide' => 20); |
|
} |
|
|
################################################## |
################################################## |
################################################## |
################################################## |
|
|
Line 809 sub assessparms {
|
Line 1167 sub assessparms {
|
my %maptitles=(); |
my %maptitles=(); |
|
|
# -------------------------------------------------------- Variable declaration |
# -------------------------------------------------------- Variable declaration |
my %allkeys=(); |
|
my %allmaps=(); |
my %allmaps=(); |
my %alllevs=(); |
my %alllevs=(); |
|
|
Line 821 sub assessparms {
|
Line 1179 sub assessparms {
|
my $coursename=$env{'course.'.$env{'request.course.id'}.'.description'}; |
my $coursename=$env{'course.'.$env{'request.course.id'}.'.description'}; |
|
|
$alllevs{'Resource Level'}='full'; |
$alllevs{'Resource Level'}='full'; |
$alllevs{'Map Level'}='map'; |
$alllevs{'Map/Folder Level'}='map'; |
$alllevs{'Course Level'}='general'; |
$alllevs{'Course Level'}='general'; |
|
|
my %allparms; |
my %allparms; |
my %allparts; |
my %allparts; |
|
# |
my %defp; |
# Order in which these parameters will be displayed |
|
# |
|
my %keyorder=&standardkeyorder(); |
|
|
@ids=(); |
@ids=(); |
%symbp=(); |
%symbp=(); |
Line 848 sub assessparms {
|
Line 1208 sub assessparms {
|
my $pschp=$env{'form.pschp'}; |
my $pschp=$env{'form.pschp'}; |
my @psprt=&Apache::loncommon::get_env_multiple('form.psprt'); |
my @psprt=&Apache::loncommon::get_env_multiple('form.psprt'); |
if (!@psprt) { $psprt[0]='0'; } |
if (!@psprt) { $psprt[0]='0'; } |
my $showoptions=$env{'form.showoptions'}; |
|
|
|
my $pssymb=''; |
my $pssymb=''; |
my $parmlev=''; |
my $parmlev=''; |
my $prevvisit=$env{'form.prevvisit'}; |
|
|
|
unless ($env{'form.parmlev'}) { |
unless ($env{'form.parmlev'}) { |
$parmlev = 'map'; |
$parmlev = 'map'; |
Line 923 sub assessparms {
|
Line 1281 sub assessparms {
|
|
|
unless ($csec) { $csec=''; } |
unless ($csec) { $csec=''; } |
|
|
my $fcat=$env{'form.fcat'}; |
|
unless ($fcat) { $fcat=''; } |
|
|
|
# --------------------------------------------------------- Get all assessments |
# --------------------------------------------------------- Get all assessments |
&extractResourceInformation(\@ids, \%typep,\%keyp, \%allparms, \%allparts, \%allkeys, \%allmaps, $fcat, \%defp, \%mapp, \%symbp,\%maptitles,\%uris); |
&extractResourceInformation(\@ids, \%typep,\%keyp, \%allparms, \%allparts, \%allmaps, |
|
\%mapp, \%symbp,\%maptitles,\%uris, |
|
\%keyorder); |
|
|
$mapp{'0.0'} = ''; |
$mapp{'0.0'} = ''; |
$symbp{'0.0'} = ''; |
$symbp{'0.0'} = ''; |
Line 946 sub assessparms {
|
Line 1303 sub assessparms {
|
# ---------------------------------------------------------------- Done storing |
# ---------------------------------------------------------------- Done storing |
$message.='<h3>'.&mt('Changes can take up to 10 minutes before being active for all students.').&Apache::loncommon::help_open_topic('Caching').'</h3>'; |
$message.='<h3>'.&mt('Changes can take up to 10 minutes before being active for all students.').&Apache::loncommon::help_open_topic('Caching').'</h3>'; |
} |
} |
# ------------------------------------------------------------------- Sort this |
|
|
|
@ids=sort { |
|
if ($fcat eq '') { |
|
$a<=>$b; |
|
} else { |
|
my ($result,@outpar)=&parmval($fcat,$a,$defp{$a},$uname,$udom,$csec); |
|
my $aparm=$outpar[$result]; |
|
($result,@outpar)=&parmval($fcat,$b,$defp{$b},$uname,$udom,$csec); |
|
my $bparm=$outpar[$result]; |
|
1*$aparm<=>1*$bparm; |
|
} |
|
} @ids; |
|
#----------------------------------------------- if all selected, fill in array |
#----------------------------------------------- if all selected, fill in array |
if ($pscat[0] eq "all" || !@pscat) {@pscat = (keys %allparms);} |
if ($pscat[0] eq "all") {@pscat = (keys %allparms);} |
|
if (!@pscat) { @pscat=('duedate','opendate','answerdate','weight','maxtries') }; |
if ($psprt[0] eq "all" || !@psprt) {@psprt = (keys %allparts);} |
if ($psprt[0] eq "all" || !@psprt) {@psprt = (keys %allparts);} |
# ------------------------------------------------------------------ Start page |
# ------------------------------------------------------------------ Start page |
|
|
&startpage($r,$id,$udom,$csec,$uname,scalar(keys(%allkeys))); |
&startpage($r); |
|
|
$r->print('<input type="hidden" value="true" name="prevvisit">'); |
|
|
|
foreach ('tolerance','date_default','date_start','date_end', |
foreach ('tolerance','date_default','date_start','date_end', |
'date_interval','int','float','string') { |
'date_interval','int','float','string') { |
$r->print('<input type="hidden" value="'. |
$r->print('<input type="hidden" value="'. |
$env{'form.recent_'.$_}.'" name="recent_'.$_.'">'); |
$env{'form.recent_'.$_}.'" name="recent_'.$_.'">'); |
} |
} |
|
|
$r->print('<h2>'.$message.'</h2><table>'); |
|
|
|
my $submitmessage = &mt('Update Section or Specific User'); |
|
if (!$pssymb) { |
if (!$pssymb) { |
$r->print('<tr><td>'.&mt('Select Parameter Level'). |
$r->print('<table border="1"><tr><td>'); |
&Apache::loncommon::help_open_topic('Course_Parameter_Levels'). |
&levelmenu($r,\%alllevs,$parmlev); |
'</td><td colspan="2">'); |
|
$r->print('<select name="parmlev">'); |
|
foreach (reverse sort keys %alllevs) { |
|
$r->print('<option value="'.$alllevs{$_}.'"'); |
|
if ($parmlev eq $alllevs{$_}) { |
|
$r->print(' selected'); |
|
} |
|
$r->print('>'.$_.'</option>'); |
|
} |
|
$r->print("</select></td>\n"); |
|
|
|
$r->print('</tr>'); |
|
if ($parmlev ne 'general') { |
if ($parmlev ne 'general') { |
$r->print('<tr><td>'.&mt('Select Enclosing Map or Folder').'</td>'); |
$r->print('<td>'); |
$r->print('<td colspan="2"><select name="pschp">'); |
&mapmenu($r,\%allmaps,$pschp,\%maptitles); |
$r->print('<option value="all">'.&mt('All Maps or Folders').'</option>'); |
$r->print('</td>'); |
foreach (sort {$allmaps{$a} cmp $allmaps{$b}} keys %allmaps) { |
|
$r->print('<option value="'.$_.'"'); |
|
if (($pschp eq $_)) { $r->print(' selected'); } |
|
$r->print('>'.$maptitles{$_}.($allmaps{$_}!~/^uploaded/?' ['.$allmaps{$_}.']':'').'</option>'); |
|
} |
|
$r->print("</select></td></tr>\n"); |
|
} |
} |
|
$r->print('</td></tr></table>'); |
|
&displaymenu($r,\%allparms,\%allparts,\@pscat,\@psprt,\%keyorder); |
} else { |
} else { |
my ($map,$id,$resource)=&Apache::lonnet::decode_symb($pssymb); |
my ($map,$id,$resource)=&Apache::lonnet::decode_symb($pssymb); |
$r->print("<tr><td>".&mt('Specific Resource')."</td><td>$resource</td>"); |
$r->print(&mt('Specific Resource').": ".$resource. |
$r->print('<td><input type="submit" name="dis" value="'.$submitmessage.'"></td>'); |
'<input type="hidden" value="'.$pssymb.'" name="symb">'. |
$r->print('</tr>'); |
'<br /><label><b>'.&mt('Show all parts').': <input type="checkbox" name="psprt" value="all"'. |
$r->print('<input type="hidden" value="'.$pssymb.'" name="symb">'); |
($env{'form.psprt'}?' checked="checked"':'').' /></b></label><br />'); |
} |
|
|
|
$r->print('<tr><td colspan="3"><hr /><label><input type="checkbox"'); |
|
if ($showoptions eq 'show') {$r->print(" checked ");} |
|
$r->print(' name="showoptions" value="show" />'.&mt('Show More Options').'</label><hr /></td></tr>'); |
|
# $r->print("<tr><td>Show: $showoptions</td></tr>"); |
|
# $r->print("<tr><td>pscat: @pscat</td></tr>"); |
|
# $r->print("<tr><td>psprt: @psprt</td></tr>"); |
|
# $r->print("<tr><td>fcat: $fcat</td></tr>"); |
|
|
|
if ($showoptions eq 'show') { |
|
my $tempkey; |
|
|
|
$r->print('<tr><td colspan="3" align="center">'.&mt('Select Parameters to View').'</td></tr>'); |
|
|
|
$r->print('<tr><td colspan="2"><table><tr>'); |
|
my $cnt=0; |
|
foreach $tempkey (sort { $allparms{$a} cmp $allparms{$b} } |
|
keys %allparms ) { |
|
++$cnt; |
|
$r->print('</tr><tr>') if ($cnt%2); |
|
$r->print('<td><input type="checkbox" name="pscat" '); |
|
$r->print('value="'.$tempkey.'"'); |
|
if ($pscat[0] eq "all" || grep $_ eq $tempkey, @pscat) { |
|
$r->print(' checked'); |
|
} |
|
$r->print('>'.$allparms{$tempkey}.'</td>'); |
|
} |
|
$r->print(' |
|
</tr><tr><td> |
|
<script type="text/javascript"> |
|
function checkall(value, checkName) { |
|
for (i=0; i<document.forms.parmform.elements.length; i++) { |
|
ele = document.forms.parmform.elements[i]; |
|
if (ele.name == checkName) { |
|
document.forms.parmform.elements[i].checked=value; |
|
} |
|
} |
|
} |
} |
</script> |
&usermenu($r,$uname,$id,$udom,$csec); |
<input type="button" onclick="checkall(true, \'pscat\')" value="Select All" /> |
|
</td><td> |
|
<input type="button" onclick="checkall(false, \'pscat\')" value="Unselect All" /> |
|
</td> |
|
'); |
|
$r->print('</tr></table>'); |
|
|
|
# $r->print('<tr><td>Select Parts</td><td>'); |
$r->print('<p>'.$message.'</p>'); |
$r->print('<td><select multiple name="psprt" size="5">'); |
|
$r->print('<option value="all"'); |
|
$r->print(' selected') unless (@psprt); |
|
$r->print('>'.&mt('All Parts').'</option>'); |
|
my %temphash=(); |
|
foreach (@psprt) { $temphash{$_}=1; } |
|
foreach $tempkey (sort keys %allparts) { |
|
unless ($tempkey =~ /\./) { |
|
$r->print('<option value="'.$tempkey.'"'); |
|
if ($psprt[0] eq "all" || $temphash{$tempkey}) { |
|
$r->print(' selected'); |
|
} |
|
$r->print('>'.$allparts{$tempkey}.'</option>'); |
|
} |
|
} |
|
$r->print('</select></td></tr><tr><td colspan="3"><hr /></td></tr>'); |
|
|
|
$r->print('<tr><td>'.&mt('Sort list by').'</td><td>'); |
$r->print('<br /><input type="submit" name="dis" value="'.&mt("Update Parameter Display").'" />'); |
$r->print('<select name="fcat">'); |
|
$r->print('<option value="">'.&mt('Enclosing Map or Folder').'</option>'); |
|
foreach (sort keys %allkeys) { |
|
$r->print('<option value="'.$_.'"'); |
|
if ($fcat eq $_) { $r->print(' selected'); } |
|
$r->print('>'.$allkeys{$_}.'</option>'); |
|
} |
|
$r->print('</select></td>'); |
|
|
|
$r->print('</tr><tr><td colspan="3"><hr /></td></tr>'); |
|
|
|
} else { # hide options - include any necessary extras here |
|
|
|
$r->print('<input type="hidden" name="fcat" value="'.$fcat.'">'."\n"); |
|
|
|
unless (@pscat) { |
|
foreach (keys %allparms ) { |
|
$r->print('<input type="hidden" name="pscat" value="'.$_.'">'."\n"); |
|
} |
|
} else { |
|
foreach (@pscat) { |
|
$r->print('<input type="hidden" name="pscat" value="'.$_.'">'."\n"); |
|
} |
|
} |
|
|
|
unless (@psprt) { |
|
foreach (keys %allparts ) { |
|
$r->print('<input type="hidden" name="psprt" value="'.$_.'">'."\n"); |
|
} |
|
} else { |
|
foreach (@psprt) { |
|
$r->print('<input type="hidden" name="psprt" value="'.$_.'">'."\n"); |
|
} |
|
} |
|
|
|
} |
|
$r->print('</table><br />'); |
|
if (($prevvisit) || ($pschp) || ($pssymb)) { |
|
$submitmessage = &mt("Update Course Assessment Parameter Display"); |
|
} else { |
|
$submitmessage = &mt("Set/Modify Course Assessment Parameters"); |
|
} |
|
$r->print('<input type="submit" name="dis" value="'.$submitmessage.'">'); |
|
|
|
# my @temp_psprt; |
|
# foreach my $t (@psprt) { |
|
# push(@temp_psprt, grep {eval (/^$t\./ || ($_ == $t))} (keys %allparts)); |
|
# } |
|
|
|
# @psprt = @temp_psprt; |
|
|
|
my @temp_pscat; |
my @temp_pscat; |
map { |
map { |
Line 1134 sub assessparms {
|
Line 1348 sub assessparms {
|
|
|
@pscat = @temp_pscat; |
@pscat = @temp_pscat; |
|
|
if (($prevvisit) || ($pschp) || ($pssymb)) { |
if (($env{'form.prevvisit'}) || ($pschp) || ($pssymb)) { |
# ----------------------------------------------------------------- Start Table |
# ----------------------------------------------------------------- Start Table |
my @catmarker=map { tr|.|_|; 'parameter_'.$_; } @pscat; |
my @catmarker=map { tr|.|_|; 'parameter_'.$_; } @pscat; |
my $csuname=$env{'user.name'}; |
my $csuname=$env{'user.name'}; |
Line 1226 ENDTABLEHEADFOUR
|
Line 1440 ENDTABLEHEADFOUR
|
my %default=(); |
my %default=(); |
my $uri=&Apache::lonnet::declutter($uris{$rid}); |
my $uri=&Apache::lonnet::declutter($uris{$rid}); |
|
|
foreach (split(/\,/,$keyp{$rid})) { |
foreach (&keysplit($keyp{$rid})) { |
my $tempkeyp = $_; |
my $tempkeyp = $_; |
if (grep $_ eq $tempkeyp, @catmarker) { |
if (grep $_ eq $tempkeyp, @catmarker) { |
$part{$_}=&Apache::lonnet::metadata($uri,$_.'.part'); |
$part{$_}=&Apache::lonnet::metadata($uri,$_.'.part'); |
Line 1263 ENDTABLEHEADFOUR
|
Line 1477 ENDTABLEHEADFOUR
|
|
|
$r->print('<td bgcolor='.$defbgone. |
$r->print('<td bgcolor='.$defbgone. |
' rowspan='.$totalparms. |
' rowspan='.$totalparms. |
'><tt><font size=-1>'); |
'>'.$maptitles{$mapp{$rid}}.'</td>'); |
|
|
$r->print(' / res / '); |
|
$r->print(join(' / ', split(/\//,$mapp{$rid}))); |
|
|
|
$r->print('</font></tt></td>'); |
|
|
|
foreach (sort keys %name) { |
foreach (&keysinorder_bytype(\%name,\%keyorder)) { |
unless ($firstrow) { |
unless ($firstrow) { |
$r->print('<tr>'); |
$r->print('<tr>'); |
} else { |
} else { |
Line 1333 ENDTABLEHEADFOUR
|
Line 1542 ENDTABLEHEADFOUR
|
# When storing information, store as part 0 |
# When storing information, store as part 0 |
# When requesting information, request from full part |
# When requesting information, request from full part |
#------------------------------------------------------------------- |
#------------------------------------------------------------------- |
foreach (split(/\,/,$keyp{$rid})) { |
foreach (&keysplit($keyp{$rid})) { |
my $tempkeyp = $_; |
my $tempkeyp = $_; |
my $fullkeyp = $tempkeyp; |
my $fullkeyp = $tempkeyp; |
$tempkeyp =~ s/_\w+_/_0_/; |
$tempkeyp =~ s/_\w+_/_0_/; |
Line 1383 ENDMAPONE
|
Line 1592 ENDMAPONE
|
$r->print('<th>'.&mt('Default Value').'</th>'); |
$r->print('<th>'.&mt('Default Value').'</th>'); |
$r->print('<th>'.&mt('Parameter in Effect').'</th></tr>'); |
$r->print('<th>'.&mt('Parameter in Effect').'</th></tr>'); |
|
|
foreach (sort keys %name) { |
foreach (&keysinorder(\%name,\%keyorder)) { |
$r->print('<tr>'); |
$r->print('<tr>'); |
&print_row($r,$_,\%part,\%name,\%symbp,$mapid,\%default, |
&print_row($r,$_,\%part,\%name,\%symbp,$mapid,\%default, |
\%type,\%display,$defbgone,$defbgtwo, |
\%type,\%display,$defbgone,$defbgtwo, |
$parmlev,$uname,$udom,$csec); |
$parmlev,$uname,$udom,$csec); |
# $r->print("<tr><td>resource.$part{$_}.$name{$_},$symbp{$mapid}</td></tr>\n"); |
|
} |
} |
$r->print("</table></center>"); |
$r->print("</table></center>"); |
} # end each map |
} # end each map |
Line 1420 ENDMAPONE
|
Line 1628 ENDMAPONE
|
# When storing information, store as part 0 |
# When storing information, store as part 0 |
# When requesting information, request from full part |
# When requesting information, request from full part |
#------------------------------------------------------------------- |
#------------------------------------------------------------------- |
foreach (split(/\,/,$keyp{$rid})) { |
foreach (&keysplit($keyp{$rid})) { |
my $tempkeyp = $_; |
my $tempkeyp = $_; |
my $fullkeyp = $tempkeyp; |
my $fullkeyp = $tempkeyp; |
$tempkeyp =~ s/_\w+_/_0_/; |
$tempkeyp =~ s/_\w+_/_0_/; |
Line 1461 ENDMAPONE
|
Line 1669 ENDMAPONE
|
$r->print('<th>'.&mt('Default Value').'</th>'); |
$r->print('<th>'.&mt('Default Value').'</th>'); |
$r->print('<th>'.&mt('Parameter in Effect').'</th></tr>'); |
$r->print('<th>'.&mt('Parameter in Effect').'</th></tr>'); |
|
|
foreach (sort keys %name) { |
foreach (&keysinorder(\%name,\%keyorder)) { |
$r->print('<tr>'); |
$r->print('<tr>'); |
&print_row($r,$_,\%part,\%name,\%symbp,$mapid,\%default, |
&print_row($r,$_,\%part,\%name,\%symbp,$mapid,\%default, |
\%type,\%display,$defbgone,$defbgtwo,$parmlev,$uname,$udom,$csec); |
\%type,\%display,$defbgone,$defbgtwo,$parmlev,$uname,$udom,$csec); |
# $r->print("<tr><td>resource.$part{$_}.$name{$_},$symbp{$mapid}</td></tr>\n"); |
|
} |
} |
$r->print("</table></center>"); |
$r->print("</table></center>"); |
} # end of $parmlev eq general |
} # end of $parmlev eq general |
Line 1562 sub crsenv {
|
Line 1769 sub crsenv {
|
# |
# |
# Let the user know we made the changes |
# Let the user know we made the changes |
if ($name && defined($value)) { |
if ($name && defined($value)) { |
|
my $failed_cloners; |
if ($name eq 'cloners') { |
if ($name eq 'cloners') { |
|
$value =~ s/\s//g; |
$value =~ s/^,//; |
$value =~ s/^,//; |
$value =~ s/,$//; |
$value =~ s/,$//; |
|
# check requested clones are valid users. |
|
$failed_cloners = &check_cloners(\$value,\@oldcloner); |
} |
} |
my $put_result = &Apache::lonnet::put('environment', |
my $put_result = &Apache::lonnet::put('environment', |
{$name=>$value},$dom,$crs); |
{$name=>$value},$dom,$crs); |
Line 1581 sub crsenv {
|
Line 1792 sub crsenv {
|
$setoutput.=&mt('Unable to set').' <b>'.$name.'</b> '.&mt('to'). |
$setoutput.=&mt('Unable to set').' <b>'.$name.'</b> '.&mt('to'). |
' <b>'.$value.'</b> '.&mt('due to').' '.$put_result.'.<br />'; |
' <b>'.$value.'</b> '.&mt('due to').' '.$put_result.'.<br />'; |
} |
} |
|
if (($name eq 'cloners') && ($failed_cloners)) { |
|
$setoutput.= &mt('Unable to include').' - <b>'.$failed_cloners.'</b>, '. |
|
&mt('reason').' - '.&mt('LON-CAPA user(s) do(es) not exist'). |
|
'.<br />'.&mt('Please '). |
|
' <a href="/adm/createuser">'. |
|
&mt('add the user(s)').'</a>, '. |
|
&mt('and then return to the '). |
|
'<a href="/admparmset?action=crsenv">'. |
|
&mt('Course Parameters page').'</a> '. |
|
&mt('to add the new user(s) to the list of possible cloners'). |
|
'.<br />'; |
|
} |
} |
} |
} |
} |
# ------------------------- Re-init course environment entries for this session |
# ------------------------- Re-init course environment entries for this session |
Line 1687 sub crsenv {
|
Line 1910 sub crsenv {
|
'anonymous_quiz' |
'anonymous_quiz' |
=> '<b>'.&mt('Anonymous quiz/exam').'</b><br />'. |
=> '<b>'.&mt('Anonymous quiz/exam').'</b><br />'. |
' (<tt><b>'.&mt('yes').'</b> '.&mt('to avoid print students names').' </tt>)', |
' (<tt><b>'.&mt('yes').'</b> '.&mt('to avoid print students names').' </tt>)', |
'default_enrollment_start_date' => '<b>'.&mt('Default beginning date when enrolling students').'</b>', |
'default_enrollment_start_date' => '<b>'.&mt('Default beginning date for student access.').'</b>', |
'default_enrollment_end_date' => '<b>'.&mt('Default ending date when enrolling students').'</b>', |
'default_enrollment_end_date' => '<b>'.&mt('Default ending date for student access.').'</b>', |
'nothideprivileged' => '<b>'.&mt('Privileged users that should not be hidden on staff listings').'</b>'. |
'nothideprivileged' => '<b>'.&mt('Privileged users that should not be hidden on staff listings').'</b>'. |
'<br />(<tt>user:domain,user:domain,...</tt>)', |
'<br />(<tt>user:domain,user:domain,...</tt>)', |
'languages' => '<b>'.&mt('Languages used').'</b>', |
'languages' => '<b>'.&mt('Languages used').'</b>', |
Line 1698 sub crsenv {
|
Line 1921 sub crsenv {
|
'disablesigfigs' |
'disablesigfigs' |
=> '<b>'.&mt('Disable checking of Significant Figures').'</b><br />'. |
=> '<b>'.&mt('Disable checking of Significant Figures').'</b><br />'. |
' ('.&mt('"[_1]" to disable, anything else if not','<tt>yes</tt>').')', |
' ('.&mt('"[_1]" to disable, anything else if not','<tt>yes</tt>').')', |
|
'disableexampointprint' |
|
=> '<b>'.&mt('Disable automatically printing point values onto exams.').'</b><br />'. |
|
' ('.&mt('"[_1]" to disable, anything else if not','<tt>yes</tt>').')', |
'tthoptions' |
'tthoptions' |
=> '<b>'.&mt('Default set of options to pass to tth/m when converting tex').'</b>' |
=> '<b>'.&mt('Default set of options to pass to tth/m when converting tex').'</b>' |
); |
); |
Line 1724 sub crsenv {
|
Line 1950 sub crsenv {
|
'default_enrollment_start_date', |
'default_enrollment_start_date', |
'default_enrollment_end_date', |
'default_enrollment_end_date', |
'tthoptions', |
'tthoptions', |
'disablesigfigs' |
'disablesigfigs', |
|
'disableexampointprint' |
); |
); |
foreach my $parameter (sort(keys(%values))) { |
foreach my $parameter (sort(keys(%values))) { |
unless ($parameter =~ m/^internal\./) { |
unless (($parameter =~ m/^internal\./)||($parameter =~ m/^metadata\./)) { |
if (! $descriptions{$parameter}) { |
if (! $descriptions{$parameter}) { |
$descriptions{$parameter}=$parameter; |
$descriptions{$parameter}=$parameter; |
push(@Display_Order,$parameter); |
push(@Display_Order,$parameter); |
Line 1852 sub readdata {
|
Line 2079 sub readdata {
|
return $resourcedata; |
return $resourcedata; |
} |
} |
|
|
sub extractuser { |
|
my $key=shift; |
|
return ($key=~/^$env{'request.course.id'}.\[useropt\:(\w+)\:(\w+)\]\./); |
|
} |
|
|
|
sub overview { |
|
my $r=shift; |
|
my $bodytag=&Apache::loncommon::bodytag( |
|
'Set/Modify Course Assessment Parameters'); |
|
my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'}; |
|
my $crs = $env{'course.'.$env{'request.course.id'}.'.num'}; |
|
my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs(undef,'Overview'); |
|
my $html=&Apache::lonxml::xmlbegin(); |
|
$r->print(<<ENDOVER); |
|
$html |
|
<head> |
|
<title>LON-CAPA Course Environment</title> |
|
</head> |
|
$bodytag |
|
$breadcrumbs |
|
<form method="post" action="/adm/parmset?action=setoverview" name="overviewform"> |
|
<input type="hidden" name="overview" value="1" /> |
|
ENDOVER |
|
# Setting |
# Setting |
|
|
|
sub storedata { |
|
my ($r,$crs,$dom)=@_; |
# Set userlevel immediately |
# Set userlevel immediately |
# Do an intermediate store of course level |
# Do an intermediate store of course level |
my $olddata=&readdata($crs,$dom); |
my $olddata=&readdata($crs,$dom); |
Line 1894 ENDOVER
|
Line 2102 ENDOVER
|
} |
} |
if ($cmd eq 'set') { |
if ($cmd eq 'set') { |
my $data=$env{$_}; |
my $data=$env{$_}; |
if ($$olddata{$thiskey} ne $data) { |
my $typeof=$env{'form.typeof_'.$thiskey}; |
|
if ($$olddata{$thiskey} ne $data) { |
if ($tuname) { |
if ($tuname) { |
if (&Apache::lonnet::put('resourcedata',{$tkey=>$data},$tudom,$tuname) eq 'ok') { |
if (&Apache::lonnet::put('resourcedata',{$tkey=>$data, |
|
$tkey.'.type' => $typeof}, |
|
$tudom,$tuname) eq 'ok') { |
$r->print('<br />'.&mt('Stored modified parameter for').' '. |
$r->print('<br />'.&mt('Stored modified parameter for').' '. |
&Apache::loncommon::plainname($tuname,$tudom)); |
&Apache::loncommon::plainname($tuname,$tudom)); |
} else { |
} else { |
Line 1906 ENDOVER
|
Line 2117 ENDOVER
|
&Apache::lonnet::devalidateuserresdata($tuname,$tudom); |
&Apache::lonnet::devalidateuserresdata($tuname,$tudom); |
} else { |
} else { |
$newdata{$thiskey}=$data; |
$newdata{$thiskey}=$data; |
} |
$newdata{$thiskey.'.type'}=$typeof; |
|
} |
} |
} |
} elsif ($cmd eq 'del') { |
} elsif ($cmd eq 'del') { |
if ($tuname) { |
if ($tuname) { |
Line 1922 ENDOVER
|
Line 2134 ENDOVER
|
} |
} |
} elsif ($cmd eq 'datepointer') { |
} elsif ($cmd eq 'datepointer') { |
my $data=&Apache::lonhtmlcommon::get_date_from_form($env{$_}); |
my $data=&Apache::lonhtmlcommon::get_date_from_form($env{$_}); |
|
my $typeof=$env{'form.typeof_'.$thiskey}; |
if (defined($data) and $$olddata{$thiskey} ne $data) { |
if (defined($data) and $$olddata{$thiskey} ne $data) { |
if ($tuname) { |
if ($tuname) { |
if (&Apache::lonnet::put('resourcedata',{$tkey=>$data},$tudom,$tuname) eq 'ok') { |
if (&Apache::lonnet::put('resourcedata',{$tkey=>$data, |
|
$tkey.'.type' => $typeof}, |
|
$tudom,$tuname) eq 'ok') { |
$r->print('<br />'.&mt('Stored modified date for').' '.&Apache::loncommon::plainname($tuname,$tudom)); |
$r->print('<br />'.&mt('Stored modified date for').' '.&Apache::loncommon::plainname($tuname,$tudom)); |
} else { |
} else { |
$r->print('<h2><font color="red">'. |
$r->print('<h2><font color="red">'. |
Line 1932 ENDOVER
|
Line 2147 ENDOVER
|
} |
} |
&Apache::lonnet::devalidateuserresdata($tuname,$tudom); |
&Apache::lonnet::devalidateuserresdata($tuname,$tudom); |
} else { |
} else { |
$newdata{$thiskey}=$data; |
$newdata{$thiskey}=$data; |
|
$newdata{$thiskey.'.type'}=$typeof; |
} |
} |
} |
} |
} |
} |
Line 1953 ENDOVER
|
Line 2169 ENDOVER
|
} |
} |
if ($putentries) { |
if ($putentries) { |
if (&Apache::lonnet::put('resourcedata',\%newdata,$dom,$crs) eq 'ok') { |
if (&Apache::lonnet::put('resourcedata',\%newdata,$dom,$crs) eq 'ok') { |
$r->print('<h2>'.&mt('Stored [_1] parameter(s)</h2>',$putentries)); |
$r->print('<h3>'.&mt('Stored [_1] parameter(s)',$putentries/2).'</h3>'); |
} else { |
} else { |
$r->print('<h2><font color="red">'. |
$r->print('<h2><font color="red">'. |
&mt('Error storing parameters').'</font></h2>'); |
&mt('Error storing parameters').'</font></h2>'); |
} |
} |
&Apache::lonnet::devalidatecourseresdata($crs,$dom); |
&Apache::lonnet::devalidatecourseresdata($crs,$dom); |
} |
} |
# Read modified data |
} |
|
|
my $resourcedata=&readdata($crs,$dom); |
sub extractuser { |
|
my $key=shift; |
|
return ($key=~/^$env{'request.course.id'}.\[useropt\:(\w+)\:(\w+)\]\./); |
|
} |
|
|
|
sub listdata { |
|
my ($r,$resourcedata,$listdata,$sortorder)=@_; |
# Start list output |
# Start list output |
|
|
my $oldsection=''; |
my $oldsection=''; |
Line 1972 ENDOVER
|
Line 2193 ENDOVER
|
my $pointer=0; |
my $pointer=0; |
$tableopen=0; |
$tableopen=0; |
my $foundkeys=0; |
my $foundkeys=0; |
foreach my $thiskey (sort keys %{$resourcedata}) { |
my %keyorder=&standardkeyorder(); |
if ($$resourcedata{$thiskey.'.type'}) { |
foreach my $thiskey (sort { |
|
if ($sortorder eq 'realmstudent') { |
|
my ($astudent,$arealm)=($a=~/^\Q$env{'request.course.id'}\E\.\[([^\.]+)\]\.(.+)\.[^\.]+$/); |
|
my ($bstudent,$brealm)=($b=~/^\Q$env{'request.course.id'}\E\.\[([^\.]+)\]\.(.+)\.[^\.]+$/); |
|
if (!defined($astudent)) { |
|
($arealm)=($a=~/^\Q$env{'request.course.id'}\E\.(.+)$/); |
|
} |
|
if (!defined($bstudent)) { |
|
($brealm)=($b=~/^\Q$env{'request.course.id'}\E\.(.+)$/); |
|
} |
|
$arealm=~s/\.type//; |
|
my ($ares, $aparm) = ($arealm=~/^(.*)\.(.*)$/); |
|
$aparm=$keyorder{'parameter_0_'.$aparm}; |
|
$brealm=~s/\.type//; |
|
my ($bres, $bparm) = ($brealm=~/^(.*)\.(.*)$/); |
|
$bparm=$keyorder{'parameter_0_'.$bparm}; |
|
if ($ares eq $bres) { |
|
if (defined($aparm) && defined($bparm)) { |
|
($aparm <=> $bparm); |
|
} elsif (defined($aparm)) { |
|
-1; |
|
} elsif (defined($bparm)) { |
|
1; |
|
} else { |
|
($arealm cmp $brealm) || ($astudent cmp $bstudent); |
|
} |
|
} else { |
|
($arealm cmp $brealm) || ($astudent cmp $bstudent); |
|
} |
|
} else { |
|
$a cmp $b; |
|
} |
|
} keys %{$listdata}) { |
|
|
|
if ($$listdata{$thiskey.'.type'}) { |
|
my $thistype=$$listdata{$thiskey.'.type'}; |
|
if ($$resourcedata{$thiskey.'.type'}) { |
|
$thistype=$$resourcedata{$thiskey.'.type'}; |
|
} |
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'); |
Line 1995 ENDOVER
|
Line 2254 ENDOVER
|
my ($map,$id,$url)=&Apache::lonnet::decode_symb($middle); |
my ($map,$id,$url)=&Apache::lonnet::decode_symb($middle); |
$realm='<font color="orange">'.&mt('Resource').': '.&Apache::lonnet::gettitle($middle).' <br /><font color="#aaaaaa" size="-2">('.$url.' in '.$map.' id: '.$id.')</font></font>'; |
$realm='<font color="orange">'.&mt('Resource').': '.&Apache::lonnet::gettitle($middle).' <br /><font color="#aaaaaa" size="-2">('.$url.' in '.$map.' id: '.$id.')</font></font>'; |
} |
} |
if ($section ne $oldsection) { |
if ($sortorder eq 'realmstudent') { |
$r->print(&tableend()."\n<hr /><h1>$section</h1>"); |
if ($realm ne $oldrealm) { |
$oldsection=$section; |
$r->print(&tableend()."\n<hr /><h1>$realm</h1>"); |
$oldrealm=''; |
$oldrealm=$realm; |
} |
$oldsection=''; |
if ($realm ne $oldrealm) { |
} |
$r->print(&tableend()."\n<h2>$realm</h2>"); |
if ($section ne $oldsection) { |
$oldrealm=$realm; |
$r->print(&tableend()."\n<h2>$section</h2>"); |
$oldpart=''; |
$oldsection=$section; |
|
$oldpart=''; |
|
} |
|
} else { |
|
if ($section ne $oldsection) { |
|
$r->print(&tableend()."\n<hr /><h1>$section</h1>"); |
|
$oldsection=$section; |
|
$oldrealm=''; |
|
} |
|
if ($realm ne $oldrealm) { |
|
$r->print(&tableend()."\n<h2>$realm</h2>"); |
|
$oldrealm=$realm; |
|
$oldpart=''; |
|
} |
} |
} |
if ($part ne $oldpart) { |
if ($part ne $oldpart) { |
$r->print(&tableend(). |
$r->print(&tableend(). |
"\n<h3><font color='blue'>".&mt('Part').": $part</font></h3>"); |
"\n<font color='blue'>".&mt('Part').": $part</font>"); |
$oldpart=$part; |
$oldpart=$part; |
} |
} |
# |
# |
|
# Preset defaults? |
|
# |
|
my ($hour,$min,$sec,$val)=('','','',''); |
|
unless ($$resourcedata{$thiskey}) { |
|
my ($parmname)=($thiskey=~/\.(\w+)$/); |
|
($hour,$min,$sec,$val)=&preset_defaults($parmname); |
|
} |
|
|
|
# |
# Ready to print |
# Ready to print |
# |
# |
$r->print(&tablestart().'<tr><td><b>'.$name. |
$r->print(&tablestart().'<tr><td><b>'.$name. |
':</b></td><td><input type="checkbox" name="del_'. |
':</b></td><td><input type="checkbox" name="del_'. |
$thiskey.'" /></td><td>'); |
$thiskey.'" /></td><td>'); |
$foundkeys++; |
$foundkeys++; |
if ($$resourcedata{$thiskey.'.type'}=~/^date/) { |
if (&isdateparm($thistype)) { |
my $jskey='key_'.$pointer; |
my $jskey='key_'.$pointer; |
$pointer++; |
$pointer++; |
$r->print( |
$r->print( |
&Apache::lonhtmlcommon::date_setter('overviewform', |
&Apache::lonhtmlcommon::date_setter('parmform', |
$jskey, |
$jskey, |
$$resourcedata{$thiskey}). |
$$resourcedata{$thiskey}, |
|
'',1,'','',$hour,$min,$sec). |
'<input type="hidden" name="datepointer_'.$thiskey.'" value="'.$jskey.'" />' |
'<input type="hidden" name="datepointer_'.$thiskey.'" value="'.$jskey.'" />' |
); |
); |
|
} elsif ($thistype eq 'string_yesno') { |
|
my $showval; |
|
if (defined($$resourcedata{$thiskey})) { |
|
$showval=$$resourcedata{$thiskey}; |
|
} else { |
|
$showval=$val; |
|
} |
|
$r->print('<label><input type="radio" name="set_'.$thiskey. |
|
'" value="yes"'); |
|
if ($showval eq 'yes') { |
|
$r->print(' checked="checked"'); |
|
} |
|
$r->print(' />'.&mt('Yes').'</label> '); |
|
$r->print('<label><input type="radio" name="set_'.$thiskey. |
|
'" value="no"'); |
|
if ($showval eq 'no') { |
|
$r->print(' checked="checked"'); |
|
} |
|
$r->print(' />'.&mt('No').'</label>'); |
} else { |
} else { |
$r->print( |
my $showval; |
'<input type="text" name="set_'.$thiskey.'" value="'. |
if (defined($$resourcedata{$thiskey})) { |
$$resourcedata{$thiskey}.'">'); |
$showval=$$resourcedata{$thiskey}; |
|
} else { |
|
$showval=$val; |
|
} |
|
$r->print('<input type="text" name="set_'.$thiskey.'" value="'. |
|
$showval.'">'); |
} |
} |
|
$r->print('<input type="hidden" name="typeof_'.$thiskey.'" value="'. |
|
$thistype.'">'); |
$r->print('</td></tr>'); |
$r->print('</td></tr>'); |
} |
} |
} |
} |
|
return $foundkeys; |
|
} |
|
|
|
sub newoverview { |
|
my $r=shift; |
|
my $bodytag=&Apache::loncommon::bodytag('Set Parameters'); |
|
my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'}; |
|
my $crs = $env{'course.'.$env{'request.course.id'}.'.num'}; |
|
my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs(undef,'Overview'); |
|
my $html=&Apache::lonxml::xmlbegin(); |
|
$r->print(<<ENDOVER); |
|
$html |
|
<head> |
|
<title>LON-CAPA Parameters</title> |
|
</head> |
|
$bodytag |
|
$breadcrumbs |
|
<form method="post" action="/adm/parmset?action=newoverview" name="parmform"> |
|
ENDOVER |
|
my @ids=(); |
|
my %typep=(); |
|
my %keyp=(); |
|
my %allparms=(); |
|
my %allparts=(); |
|
my %allmaps=(); |
|
my %mapp=(); |
|
my %symbp=(); |
|
my %maptitles=(); |
|
my %uris=(); |
|
my %keyorder=&standardkeyorder(); |
|
my %defkeytype=(); |
|
|
|
my %alllevs=(); |
|
$alllevs{'Resource Level'}='full'; |
|
$alllevs{'Map/Folder Level'}='map'; |
|
$alllevs{'Course Level'}='general'; |
|
|
|
my $csec=$env{'form.csec'}; |
|
|
|
my @pscat=&Apache::loncommon::get_env_multiple('form.pscat'); |
|
my $pschp=$env{'form.pschp'}; |
|
my @psprt=&Apache::loncommon::get_env_multiple('form.psprt'); |
|
if (!@psprt) { $psprt[0]='0'; } |
|
|
|
my @selected_sections = |
|
&Apache::loncommon::get_env_multiple('form.Section'); |
|
@selected_sections = ('all') if (! @selected_sections); |
|
foreach (@selected_sections) { |
|
if ($_ eq 'all') { |
|
@selected_sections = ('all'); |
|
} |
|
} |
|
|
|
my $pssymb=''; |
|
my $parmlev=''; |
|
|
|
unless ($env{'form.parmlev'}) { |
|
$parmlev = 'map'; |
|
} else { |
|
$parmlev = $env{'form.parmlev'}; |
|
} |
|
|
|
&extractResourceInformation(\@ids, \%typep,\%keyp, \%allparms, \%allparts, \%allmaps, |
|
\%mapp, \%symbp,\%maptitles,\%uris, |
|
\%keyorder,\%defkeytype); |
|
|
|
# Menu to select levels, etc |
|
|
|
$r->print('<table border="1"><tr><td>'); |
|
&levelmenu($r,\%alllevs,$parmlev); |
|
if ($parmlev ne 'general') { |
|
$r->print('<td>'); |
|
&mapmenu($r,\%allmaps,$pschp,\%maptitles); |
|
$r->print('</td>'); |
|
} |
|
$r->print('</td></tr></table>'); |
|
|
|
$r->print('<table border="1"><tr><td>'); |
|
&parmmenu($r,\%allparms,\@pscat,\%keyorder); |
|
$r->print('</td><td>'); |
|
&partmenu($r,\%allparts,\@psprt); |
|
$r->print('</td><td>'); |
|
§ionmenu($r,\@selected_sections); |
|
|
|
$r->print('</td></tr></table>'); |
|
|
|
my $sortorder=$env{'form.sortorder'}; |
|
unless ($sortorder) { $sortorder='realmstudent'; } |
|
&sortmenu($r,$sortorder); |
|
|
|
$r->print('<p><input type="submit" name="dis" value="'.&mt('Display').'" /></p>'); |
|
|
|
# Build the list data hash from the specified parms |
|
|
|
my $listdata; |
|
%{$listdata}=(); |
|
|
|
foreach my $cat (@pscat) { |
|
foreach my $section (@selected_sections) { |
|
foreach my $part (@psprt) { |
|
my $rootparmkey=$env{'request.course.id'}; |
|
if (($section ne 'all') && ($section ne 'none') && ($section)) { |
|
$rootparmkey.='.['.$section.']'; |
|
} |
|
if ($parmlev eq 'general') { |
|
# course-level parameter |
|
my $newparmkey=$rootparmkey.'.'.$part.'.'.$cat; |
|
$$listdata{$newparmkey}=1; |
|
$$listdata{$newparmkey.'.type'}=$defkeytype{$cat}; |
|
} elsif ($parmlev eq 'map') { |
|
# map-level parameter |
|
foreach my $mapid (keys %allmaps) { |
|
if (($pschp ne 'all') && ($pschp ne $mapid)) { next; } |
|
my $newparmkey=$rootparmkey.'.'.$allmaps{$mapid}.'___(all).'.$part.'.'.$cat; |
|
$$listdata{$newparmkey}=1; |
|
$$listdata{$newparmkey.'.type'}=$defkeytype{$cat}; |
|
} |
|
} else { |
|
# resource-level parameter |
|
foreach my $rid (@ids) { |
|
my ($map,$resid,$url)=&Apache::lonnet::decode_symb($symbp{$rid}); |
|
if (($pschp ne 'all') && ($allmaps{$pschp} ne $map)) { next; } |
|
my $newparmkey=$rootparmkey.'.'.$symbp{$rid}.'.'.$part.'.'.$cat; |
|
$$listdata{$newparmkey}=1; |
|
$$listdata{$newparmkey.'.type'}=$defkeytype{$cat}; |
|
} |
|
} |
|
} |
|
} |
|
} |
|
|
|
if (($env{'form.store'}) || ($env{'form.dis'})) { |
|
|
|
if ($env{'form.store'}) { &storedata($r,$crs,$dom); } |
|
|
|
# Read modified data |
|
|
|
my $resourcedata=&readdata($crs,$dom); |
|
|
|
# List data |
|
|
|
&listdata($r,$resourcedata,$listdata,$sortorder); |
|
} |
|
$r->print(&tableend(). |
|
((($env{'form.store'}) || ($env{'form.dis'}))?'<p><input type="submit" name="store" value="'.&mt('Store').'" /></p>':''). |
|
'</form></body></html>'); |
|
} |
|
|
|
sub overview { |
|
my $r=shift; |
|
my $bodytag=&Apache::loncommon::bodytag('Modify Parameters'); |
|
my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'}; |
|
my $crs = $env{'course.'.$env{'request.course.id'}.'.num'}; |
|
my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs(undef,'Overview'); |
|
my $html=&Apache::lonxml::xmlbegin(); |
|
$r->print(<<ENDOVER); |
|
$html |
|
<head> |
|
<title>LON-CAPA Parameters</title> |
|
</head> |
|
$bodytag |
|
$breadcrumbs |
|
<form method="post" action="/adm/parmset?action=setoverview" name="parmform"> |
|
ENDOVER |
|
# Store modified |
|
|
|
&storedata($r,$crs,$dom); |
|
|
|
# Read modified data |
|
|
|
my $resourcedata=&readdata($crs,$dom); |
|
|
|
|
|
my $sortorder=$env{'form.sortorder'}; |
|
unless ($sortorder) { $sortorder='realmstudent'; } |
|
&sortmenu($r,$sortorder); |
|
|
|
# List data |
|
|
|
my $foundkeys=&listdata($r,$resourcedata,$resourcedata,$sortorder); |
|
|
$r->print(&tableend().'<p>'. |
$r->print(&tableend().'<p>'. |
($foundkeys?'<input type="submit" value="'.&mt('Modify Parameters').'" />':&mt('There are no course or section parameters.')).'</p></form></body></html>'); |
($foundkeys?'<input type="submit" value="'.&mt('Modify Parameters').'" />':&mt('There are no parameters.')).'</p></form></body></html>'); |
} |
} |
|
|
################################################## |
################################################## |
################################################## |
################################################## |
|
|
=pod |
=pod |
|
|
=item change clone |
=item check_cloners |
|
|
|
Checks if new users included in list of allowed cloners |
|
are valid users. Replaces supplied list with |
|
cleaned list containing only users with valid usernames |
|
and domains. |
|
|
|
Inputs: $clonelist, $oldcloner |
|
where $clonelist is ref to array of requested cloners, |
|
and $oldcloner is ref to array of currently allowed |
|
cloners. |
|
|
|
Returns: string - comma separated list of requested |
|
cloners (username:domain) who do not exist in system. |
|
|
|
=item change_clone |
|
|
Modifies the list of courses a user can clone (stored |
Modifies the list of courses a user can clone (stored |
in the user's environemnt.db file), called when a |
in the user's environment.db file), called when a |
change is made to the list of users allowed to clone |
change is made to the list of users allowed to clone |
a course. |
a course. |
|
|
Inputs: $action,$cloner |
Inputs: $action,$cloner |
where $action is add or drop, and $cloner is identity of |
where $action is add or drop, and $cloner is identity of |
user for whom cloning ability is to be changed in course. |
user for whom cloning ability is to be changed in course. |
|
|
Returns: |
|
|
|
=cut |
=cut |
|
|
################################################## |
################################################## |
################################################## |
################################################## |
|
|
|
sub extract_cloners { |
|
my ($clonelist,$allowclone) = @_; |
|
if ($clonelist =~ /,/) { |
|
@{$allowclone} = split/,/,$clonelist; |
|
} else { |
|
$$allowclone[0] = $clonelist; |
|
} |
|
} |
|
|
|
|
|
sub check_cloners { |
|
my ($clonelist,$oldcloner) = @_; |
|
my ($clean_clonelist,$disallowed); |
|
my @allowclone = (); |
|
&extract_cloners($$clonelist,\@allowclone); |
|
foreach my $currclone (@allowclone) { |
|
if (!grep/^$currclone$/,@$oldcloner) { |
|
my ($uname,$udom) = split/:/,$currclone; |
|
if ($uname && $udom) { |
|
if (&Apache::lonnet::homeserver($uname,$udom) eq 'no_host') { |
|
$disallowed .= $currclone.','; |
|
} else { |
|
$clean_clonelist .= $currclone.','; |
|
} |
|
} |
|
} else { |
|
$clean_clonelist .= $currclone.','; |
|
} |
|
} |
|
if ($disallowed) { |
|
$disallowed =~ s/,$//; |
|
} |
|
if ($clean_clonelist) { |
|
$clean_clonelist =~ s/,$//; |
|
} |
|
$$clonelist = $clean_clonelist; |
|
return $disallowed; |
|
} |
|
|
sub change_clone { |
sub change_clone { |
my ($clonelist,$oldcloner) = @_; |
my ($clonelist,$oldcloner) = @_; |
Line 2071 sub change_clone {
|
Line 2610 sub change_clone {
|
my $clone_crs = $cnum.':'.$cdom; |
my $clone_crs = $cnum.':'.$cdom; |
|
|
if ($cnum && $cdom) { |
if ($cnum && $cdom) { |
my @allowclone = (); |
my @allowclone; |
if ($clonelist =~ /,/) { |
&extract_cloners($clonelist,\@allowclone); |
@allowclone = split/,/,$clonelist; |
|
} else { |
|
$allowclone[0] = $clonelist; |
|
} |
|
foreach my $currclone (@allowclone) { |
foreach my $currclone (@allowclone) { |
if (!grep/^$currclone$/,@$oldcloner) { |
if (!grep/^$currclone$/,@$oldcloner) { |
($uname,$udom) = split/:/,$currclone; |
($uname,$udom) = split/:/,$currclone; |
Line 2167 ENDMAINFORMHEAD
|
Line 2702 ENDMAINFORMHEAD
|
action => 'crsenv', |
action => 'crsenv', |
permission => $parm_permission, |
permission => $parm_permission, |
}, |
}, |
{ text => 'Set/Modify Course Assessment Parameters - Helper Mode', |
{ text => 'Set Instructor Defined Metadata', |
|
action => 'setinstmeta', |
|
permission => $parm_permission, |
|
}, |
|
{ text => 'Set/Modify Resource Parameters - Helper Mode', |
url => '/adm/helper/parameter.helper', |
url => '/adm/helper/parameter.helper', |
permission => $parm_permission, |
permission => $parm_permission, |
}, |
}, |
{ text => 'Modify Course Assessment Parameters - Overview Mode', |
{ text => 'Modify Resource Parameters - Overview Mode', |
action => 'setoverview', |
action => 'setoverview', |
permission => $parm_permission, |
permission => $parm_permission, |
|
}, |
|
{ text => 'Set Resource Parameters - Overview Mode', |
|
action => 'newoverview', |
|
permission => $parm_permission, |
}, |
}, |
{ text => 'Set/Modify Course Assessment Parameters - Table Mode', |
{ text => 'Set/Modify Resource Parameters - Table Mode', |
action => 'settable', |
action => 'settable', |
permission => $parm_permission, |
permission => $parm_permission, |
help => 'Cascading_Parameters', |
help => 'Cascading_Parameters', |
}, |
}, |
# { text => 'Set Parameter Default Preferences', |
{ text => 'Set Parameter Setting Default Actions', |
# help => 'Course_View_Class_List', |
action => 'setdefaults', |
# action => 'setdefaults', |
permission => $parm_permission, |
# permission => $parm_permission, |
}, |
# }, |
|
); |
); |
my $menu_html = ''; |
my $menu_html = ''; |
foreach my $menu_item (@menu) { |
foreach my $menu_item (@menu) { |
Line 2207 ENDMAINFORMHEAD
|
Line 2749 ENDMAINFORMHEAD
|
$r->print($menu_html); |
$r->print($menu_html); |
return; |
return; |
} |
} |
|
### Set instructor defined metadata |
|
sub output_row { |
|
my ($field_name) = @_; |
|
my $output; |
|
my $meta_hash_ref=$env{'course.'.$env{'request.course.id'}.'.metadata.'.$field_name}; |
|
my $values=$$meta_hash_ref{'values'}; |
|
my $checked; |
|
unless (defined($$meta_hash_ref{'active'})) { |
|
$$meta_hash_ref{'active'} = 'no'; |
|
$$meta_hash_ref{'stu_add_values'} = 'yes'; |
|
$$meta_hash_ref{'values'} = 'Type a list of values separated by commas.'; |
|
$$meta_hash_ref{'stu_pick_many'} = 'yes'; |
|
} |
|
$output.='<tr><td><strong>'.$field_name.'</strong></td>'; |
|
$output.='<td><input name="'.$field_name.'_values" type="text" value="'.$$meta_hash_ref{'values'}.'" /></td>'; |
|
if ($$meta_hash_ref{'stu_add_values'}eq'yes') { |
|
$checked = ' CHECKED '; |
|
} else { |
|
$checked = ' '; |
|
} |
|
$output.='<td><center><input type="checkbox" name="'.$field_name.'_onlyone"" value="one"'.$checked.' /></center></td>'; |
|
if ($$meta_hash_ref{'stu_pick_many'}eq'yes') { |
|
$checked = ' CHECKED '; |
|
} else { |
|
$checked = ' '; |
|
} |
|
$output.='<td><input type="checkbox" name="'.$field_name.'_stuadd" value="one"'.$checked.' /></td>'; |
|
$output.='</tr>'; |
|
|
|
return ($output); |
|
} |
|
sub setinstmeta { |
|
my ($r)=@_; |
|
my $next_meta; |
|
my $output; |
|
my $item_num; |
|
my $put_result; |
|
$r->print(&Apache::lonxml::xmlbegin()); |
|
$r->print('<head> |
|
<title>LON-CAPA Set Instructor Metadata</title> |
|
</head>'); |
|
$r->print(&Apache::loncommon::bodytag('Set Instructor Metadata')); |
|
$r->print(&Apache::lonhtmlcommon::breadcrumbs(undef, |
|
'Set Instructor Metadata')); |
|
my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'}; |
|
my $crs = $env{'course.'.$env{'request.course.id'}.'.num'}; |
|
my $key_base = $env{'course.'.$env{'request.course.id'}.'.metadata.'}; |
|
my $save_field = ''; |
|
my %meta_hash; |
|
if ($env{'form.instmeta'}) { |
|
foreach my $field (sort %env) { |
|
if ($field=~m/^form.(.+)_(.+)$/) { |
|
my $meta_field = $1; |
|
my $meta_key = $2; |
|
if ($save_field eq $meta_field) { |
|
%meta_hash = {$meta_key=>[$env{$field}]}; |
|
} else { |
|
if ($save_field ne '') { |
|
%meta_hash = {active=>'yes'}; |
|
my $value = \%meta_hash; |
|
my $name = $save_field; |
|
$r->print('Saving '.$name.' meta<br />'); |
|
$put_result = &Apache::lonnet::put('environment', |
|
{$name=>$value},$dom,$crs); |
|
} |
|
$save_field = $meta_field; |
|
%meta_hash = {$meta_key=>[$env{$field}]}; |
|
} |
|
} |
|
|
|
|
|
} |
|
%meta_hash = {active=>'yes'}; |
|
my $value = \%meta_hash; |
|
my $name = $save_field; |
|
$r->print('Saving '.$name.' meta<br />'); |
|
$put_result = &Apache::lonnet::put('environment', |
|
{$name=>$value},$dom,$crs); |
|
} |
|
foreach my $field (%env) { |
|
# start by looking for populated fields |
|
if ($field=~m/type(\d+)/) { |
|
my $name; |
|
my $value; |
|
$put_result = &Apache::lonnet::put('environment', |
|
{$name=>$value},$dom,$crs); |
|
$put_result = &Apache::lonnet::put('environment', |
|
{$name=>$value},$dom,$crs); |
|
} |
|
if ($field=~m/newfield/) { |
|
my $name = 'metadata.'.$env{'form.titlenew'}; |
|
my %meta_hash = {values=>[$env{'form.valuesnew'}], |
|
allow_pick=>'many', |
|
allow_type=>'no'}; |
|
|
|
my $value = \%meta_hash; |
|
$put_result = &Apache::lonnet::put('environment', |
|
{$name=>$value},$dom,$crs); |
|
} |
|
} |
|
&Apache::lonnet::coursedescription($env{'request.course.id'}); |
|
$output.= &output_row("Title"); |
|
$output.= &output_row("Subject"); |
|
$output.= &output_row("Keywords"); |
|
# foreach my $key (sort keys %env) { |
|
# if ($key=~m/^course\.$env{'request.course.id'}\.metadata\.(.+)$/) { |
|
# my $meta_data_item = $1; |
|
# my $meta_hash=$env{$key}; |
|
# # keys are 'values', stu_pick_many, stu_add_values, active |
|
# |
|
# $output.='<tr><td>'.$meta_data_item.'</td>'; |
|
# $output.='<td>Select one: <input type="checkbox" name="" value="one" /><br />'; |
|
# $output.='Select many: <input type="checkbox" name="type" value="many" /></td>'; |
|
# $output.='<td><input name="values" type="text" value="$env{$key_base.$item_num.'.'" /></td></tr>'; |
|
# } |
|
# } |
|
# $output.='<tr><td><i>Create new instructor metadata item</i><br />'; |
|
# $output.='<input type="text" name="titlenew" /></td>'; |
|
# $output.='<td>students must pick only one: <input type="checkbox" name="pickonenew" value="one" /><br />'; |
|
# $output.='Allow student to type extra info: <input type="checkbox" name="typeextranew" value="extra" /></td>'; |
|
# $output.='<td><input name="valuesnew" type="text" value="" /></td></tr>'; |
|
# $output.='<input type="hidden" name="serial" value="'.$next_meta.'" />'; |
|
# $output.='<input type="hidden" name="state" value="save" /></tr>'; |
|
$r->print(<<ENDenv); |
|
<form method="post" action="/adm/parmset?action=setinstmeta" name="form"> |
|
|
|
<p> |
|
<table border=2> |
|
<tr><th>Metadata Item</th><th>Values</th><th>Only One Choice</th><th>Student Can Add Choices</th></tr> |
|
$output |
|
</table> |
|
<input type="submit" name="instmeta" value="Update Instructor Metadata"> |
|
</form> |
|
|
|
ENDenv |
|
|
|
|
|
$r->print('</body> |
|
</html>'); |
|
return 'ok'; |
|
} |
|
################################################## |
|
|
|
sub defaultsetter { |
|
my $r=shift; |
|
my $bodytag=&Apache::loncommon::bodytag('Parameter Setting Default Actions'); |
|
my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'}; |
|
my $crs = $env{'course.'.$env{'request.course.id'}.'.num'}; |
|
my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs(undef,'Defaults'); |
|
my $html=&Apache::lonxml::xmlbegin(); |
|
$r->print(<<ENDDEFHEAD); |
|
$html |
|
<head> |
|
<title>LON-CAPA Parameters</title> |
|
</head> |
|
$bodytag |
|
$breadcrumbs |
|
<form method="post" action="/adm/parmset?action=setdefaults" name="defaultform"> |
|
ENDDEFHEAD |
|
my @ids=(); |
|
my %typep=(); |
|
my %keyp=(); |
|
my %allparms=(); |
|
my %allparts=(); |
|
my %allmaps=(); |
|
my %mapp=(); |
|
my %symbp=(); |
|
my %maptitles=(); |
|
my %uris=(); |
|
my %keyorder=&standardkeyorder(); |
|
my %defkeytype=(); |
|
|
|
&extractResourceInformation(\@ids, \%typep,\%keyp, \%allparms, \%allparts, \%allmaps, |
|
\%mapp, \%symbp,\%maptitles,\%uris, |
|
\%keyorder,\%defkeytype); |
|
if ($env{'form.storerules'}) { |
|
my %newrules=(); |
|
my @delrules=(); |
|
my %triggers=(); |
|
foreach my $key (keys(%env)) { |
|
if ($key=~/^form\.(\w+)\_action$/) { |
|
my $tempkey=$1; |
|
my $action=$env{$key}; |
|
if ($action) { |
|
$newrules{$tempkey.'_action'}=$action; |
|
if ($action ne 'default') { |
|
my ($whichaction,$whichparm)=($action=~/^(.*\_)([^\_]+)$/); |
|
$triggers{$whichparm}.=$tempkey.':'; |
|
} |
|
$newrules{$tempkey.'_type'}=$defkeytype{$tempkey}; |
|
if (&isdateparm($defkeytype{$tempkey})) { |
|
$newrules{$tempkey.'_days'}=$env{'form.'.$tempkey.'_days'}; |
|
$newrules{$tempkey.'_hours'}=$env{'form.'.$tempkey.'_hours'}; |
|
$newrules{$tempkey.'_min'}=$env{'form.'.$tempkey.'_min'}; |
|
$newrules{$tempkey.'_sec'}=$env{'form.'.$tempkey.'_sec'}; |
|
} else { |
|
$newrules{$tempkey.'_value'}=$env{'form.'.$tempkey.'_value'}; |
|
$newrules{$tempkey.'_triggervalue'}=$env{'form.'.$tempkey.'_triggervalue'}; |
|
} |
|
} else { |
|
push(@delrules,$tempkey.'_action'); |
|
push(@delrules,$tempkey.'_type'); |
|
push(@delrules,$tempkey.'_hours'); |
|
push(@delrules,$tempkey.'_min'); |
|
push(@delrules,$tempkey.'_sec'); |
|
push(@delrules,$tempkey.'_value'); |
|
} |
|
} |
|
} |
|
foreach my $key (keys %allparms) { |
|
$newrules{$key.'_triggers'}=$triggers{$key}; |
|
} |
|
&Apache::lonnet::put('parmdefactions',\%newrules,$dom,$crs); |
|
&Apache::lonnet::del('parmdefactions',\@delrules,$dom,$crs); |
|
&resetrulescache(); |
|
} |
|
my %lt=&Apache::lonlocal::texthash('days' => 'Days', |
|
'hours' => 'Hours', |
|
'min' => 'Minutes', |
|
'sec' => 'Seconds', |
|
'yes' => 'Yes', |
|
'no' => 'No'); |
|
my @standardoptions=('','default'); |
|
my @standarddisplay=('',&mt('Default value when manually setting')); |
|
my @dateoptions=('','default'); |
|
my @datedisplay=('',&mt('Default value when manually setting')); |
|
foreach my $tempkey (&keysindisplayorder(\%allparms,\%keyorder)) { |
|
unless ($tempkey) { next; } |
|
push @standardoptions,'when_setting_'.$tempkey; |
|
push @standarddisplay,&mt('Automatically set when setting ').$tempkey; |
|
if (&isdateparm($defkeytype{$tempkey})) { |
|
push @dateoptions,'later_than_'.$tempkey; |
|
push @datedisplay,&mt('Automatically set later than ').$tempkey; |
|
push @dateoptions,'earlier_than_'.$tempkey; |
|
push @datedisplay,&mt('Automatically set earlier than ').$tempkey; |
|
} |
|
} |
|
$r->print(&mt('Manual setting rules apply to all interfaces.').'<br />'. |
|
&mt('Automatic setting rules apply to table mode interfaces only.')); |
|
$r->print("\n<table border='1'><tr><th>".&mt('Rule for parameter').'</th><th>'. |
|
&mt('Action').'</th><th>'.&mt('Value').'</th></tr>'); |
|
foreach my $tempkey (&keysindisplayorder(\%allparms,\%keyorder)) { |
|
unless ($tempkey) { next; } |
|
$r->print("\n<tr><td>".$allparms{$tempkey}."\n<br />(".$tempkey.')</td><td>'); |
|
my $action=&rulescache($tempkey.'_action'); |
|
$r->print('<select name="'.$tempkey.'_action">'); |
|
if (&isdateparm($defkeytype{$tempkey})) { |
|
for (my $i=0;$i<=$#dateoptions;$i++) { |
|
if ($dateoptions[$i]=~/\_$tempkey$/) { next; } |
|
$r->print("\n<option value='$dateoptions[$i]'". |
|
($dateoptions[$i] eq $action?' selected="selected"':''). |
|
">$datedisplay[$i]</option>"); |
|
} |
|
} else { |
|
for (my $i=0;$i<=$#standardoptions;$i++) { |
|
if ($standardoptions[$i]=~/\_$tempkey$/) { next; } |
|
$r->print("\n<option value='$standardoptions[$i]'". |
|
($standardoptions[$i] eq $action?' selected="selected"':''). |
|
">$standarddisplay[$i]</option>"); |
|
} |
|
} |
|
$r->print('</select>'); |
|
unless (&isdateparm($defkeytype{$tempkey})) { |
|
$r->print("\n<br />".&mt('Triggering value(s) of other parameter (optional, comma-separated):'). |
|
'<input type="text" size="20" name="'.$tempkey.'_triggervalue" value="'.&rulescache($tempkey.'_triggervalue').'" />'); |
|
} |
|
$r->print("\n</td><td>\n"); |
|
|
|
if (&isdateparm($defkeytype{$tempkey})) { |
|
my $days=&rulescache($tempkey.'_days'); |
|
my $hours=&rulescache($tempkey.'_hours'); |
|
my $min=&rulescache($tempkey.'_min'); |
|
my $sec=&rulescache($tempkey.'_sec'); |
|
$r->print(<<ENDINPUTDATE); |
|
<input name="$tempkey\_days" type="text" size="4" value="$days" />$lt{'days'}<br /> |
|
<input name="$tempkey\_hours" type="text" size="4" value="$hours" />$lt{'hours'}<br /> |
|
<input name="$tempkey\_min" type="text" size="4" value="$min" />$lt{'min'}<br /> |
|
<input name="$tempkey\_sec" type="text" size="4" value="$sec" />$lt{'sec'} |
|
ENDINPUTDATE |
|
} elsif ($defkeytype{$tempkey} eq 'string_yesno') { |
|
my $yeschecked=''; |
|
my $nochecked=''; |
|
if (&rulescache($tempkey.'_value') eq 'yes') { $yeschecked='checked="checked"'; } |
|
if (&rulescache($tempkey.'_value') eq 'no') { $nochecked='checked="checked"'; } |
|
|
|
$r->print(<<ENDYESNO); |
|
<label><input type="radio" name="$tempkey\_value" value="yes" $yeschecked /> $lt{'yes'}</label><br /> |
|
<label><input type="radio" name="$tempkey\_value" value="no" $nochecked /> $lt{'no'}</label> |
|
ENDYESNO |
|
} else { |
|
$r->print('<input type="text" size="20" name="'.$tempkey.'_value" value="'.&rulescache($tempkey.'_value').'" />'); |
|
} |
|
$r->print('</td></tr>'); |
|
} |
|
$r->print("</table>\n<input type='submit' name='storerules' value='". |
|
&mt('Store Rules')."' /></form>\n</body>\n</html>"); |
|
return; |
|
} |
|
|
################################################## |
################################################## |
################################################## |
################################################## |
Line 2223 Main handler. Calls &assessparms and &c
|
Line 3060 Main handler. Calls &assessparms and &c
|
=cut |
=cut |
################################################## |
################################################## |
################################################## |
################################################## |
use Data::Dumper; |
# use Data::Dumper; |
|
|
sub handler { |
sub handler { |
my $r=shift; |
my $r=shift; |
|
|
Line 2237 sub handler {
|
Line 3075 sub handler {
|
'pres_marker', |
'pres_marker', |
'pres_value', |
'pres_value', |
'pres_type', |
'pres_type', |
'udom','uname']); |
'udom','uname','symb','serial']); |
|
|
|
|
&Apache::lonhtmlcommon::clear_breadcrumbs(); |
&Apache::lonhtmlcommon::clear_breadcrumbs(); |
Line 2279 sub handler {
|
Line 3117 sub handler {
|
} elsif ($env{'form.action'} eq 'crsenv' && $parm_permission) { |
} elsif ($env{'form.action'} eq 'crsenv' && $parm_permission) { |
&Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=crsenv', |
&Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=crsenv', |
text=>"Course Environment"}); |
text=>"Course Environment"}); |
$r->print(&Apache::lonhtmlcommon::breadcrumbs(undef, |
|
'Edit Course Environment')); |
|
&crsenv($r); |
&crsenv($r); |
} elsif ($env{'form.action'} eq 'setoverview' && $parm_permission) { |
} elsif ($env{'form.action'} eq 'setoverview' && $parm_permission) { |
&Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=setoverview', |
&Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=setoverview', |
text=>"Overview Mode"}); |
text=>"Overview Mode"}); |
&overview($r); |
&overview($r); |
} elsif ($env{'form.action'} eq 'settable' && $parm_permission) { |
} elsif ($env{'form.action'} eq 'setinstmeta' && $parm_permission) { |
|
&Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=setinstmeta', |
|
text=>"Instructor Metadata"}); |
|
&setinstmeta($r); |
|
} elsif ($env{'form.action'} eq 'newoverview' && $parm_permission) { |
|
&Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=setoverview', |
|
text=>"Overview Mode"}); |
|
&newoverview($r); |
|
} elsif ($env{'form.action'} eq 'setdefaults' && $parm_permission) { |
|
&Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=setdefaults', |
|
text=>"Set Defaults"}); |
|
&defaultsetter($r); |
|
} elsif ($env{'form.action'} eq 'settable' && $parm_permission) { |
&Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=settable', |
&Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=settable', |
text=>"Table Mode", |
text=>"Table Mode", |
help => 'Course_Setting_Parameters'}); |
help => 'Course_Setting_Parameters'}); |