version 1.270, 2005/11/22 16:36:05
|
version 1.368, 2007/06/19 20:14:31
|
Line 63 use Apache::lonhomework;
|
Line 63 use Apache::lonhomework;
|
use Apache::lonxml; |
use Apache::lonxml; |
use Apache::lonlocal; |
use Apache::lonlocal; |
use Apache::lonnavmaps; |
use Apache::lonnavmaps; |
|
use Apache::longroup; |
|
use Apache::lonrss; |
|
use LONCAPA qw(:DEFAULT :match); |
|
|
# --- Caches local to lonparmset |
# --- Caches local to lonparmset |
|
|
Line 90 Inputs: $what - a parameter spec (inclu
|
Line 93 Inputs: $what - a parameter spec (inclu
|
|
|
Returns: A list, the first item is the index into the remaining list of items of parm valuse that is the active one, the list consists of parm values at the 14 possible levels |
Returns: A list, the first item is the index into the remaining list of items of parm valuse that is the active one, the list consists of parm values at the 14 possible levels |
|
|
14 - General Course |
14- General Course |
13 - Map or Folder level in course |
13- Map or Folder level in course |
12- resource default |
12- resource default |
11- map default |
11- map default |
10 - resource level in course |
10- resource level in course |
9 - General for section |
9 - General for section |
8 - Map or Folder level for section |
8 - Map or Folder level for section |
7 - resource level in section |
7 - resource level in section |
Line 109 Returns: A list, the first item is the
|
Line 112 Returns: A list, the first item is the
|
|
|
################################################## |
################################################## |
sub parmval { |
sub parmval { |
my ($what,$id,$def,$uname,$udom,$csec,$cgroup)=@_; |
my ($what,$id,$def,$uname,$udom,$csec,$cgroup,$courseopt)=@_; |
return &parmval_by_symb($what,&symbcache($id),$def,$uname,$udom,$csec,$cgroup); |
return &parmval_by_symb($what,&symbcache($id),$def,$uname,$udom,$csec, |
|
$cgroup,$courseopt); |
} |
} |
|
|
sub parmval_by_symb { |
sub parmval_by_symb { |
my ($what,$symb,$def,$uname,$udom,$csec,$cgroup)=@_; |
my ($what,$symb,$def,$uname,$udom,$csec,$cgroup,$courseopt)=@_; |
# load caches |
# load caches |
|
|
&cacheparmhash(); |
&cacheparmhash(); |
|
|
my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; |
my $useropt; |
my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; |
if ($uname ne '' && $udom ne '') { |
my $useropt=&Apache::lonnet::get_userresdata($uname,$udom); |
$useropt = &Apache::lonnet::get_userresdata($uname,$udom); |
my $courseopt=&Apache::lonnet::get_courseresdata($cnum,$cdom); |
} |
|
|
my $result=''; |
my $result=''; |
my @outpar=(); |
my @outpar=(); |
# ----------------------------------------------------- Cascading lookup scheme |
# ----------------------------------------------------- Cascading lookup scheme |
my $map=(&Apache::lonnet::decode_symb($symb))[0]; |
my $map=(&Apache::lonnet::decode_symb($symb))[0]; |
|
$map = &Apache::lonnet::deversion($map); |
|
|
my $symbparm=$symb.'.'.$what; |
my $symbparm=$symb.'.'.$what; |
my $mapparm=$map.'___(all).'.$what; |
my $mapparm=$map.'___(all).'.$what; |
Line 172 sub parmval_by_symb {
|
Line 176 sub parmval_by_symb {
|
} |
} |
|
|
# ------------------------------------------------------ fourth, back to course |
# ------------------------------------------------------ fourth, back to course |
if (defined($csec)) { |
if ($csec ne '') { |
if (defined($$courseopt{$seclevel})) { |
if (defined($$courseopt{$seclevel})) { |
$outpar[9]=$$courseopt{$seclevel}; |
$outpar[9]=$$courseopt{$seclevel}; |
$result=9; |
$result=9; |
Line 187 sub parmval_by_symb {
|
Line 191 sub parmval_by_symb {
|
$result=7; |
$result=7; |
} |
} |
} |
} |
# ------------------------------------------------------ fifth, check gourse group |
# ------------------------------------------------------ fifth, check course group |
if (defined($cgroup)) { |
if ($cgroup ne '') { |
if (defined($$courseopt{$grplevel})) { |
if (defined($$courseopt{$grplevel})) { |
$outpar[6]=$$courseopt{$grplevel}; |
$outpar[6]=$$courseopt{$grplevel}; |
$result=6; |
$result=6; |
Line 205 sub parmval_by_symb {
|
Line 209 sub parmval_by_symb {
|
|
|
# ---------------------------------------------------------- fifth, check user |
# ---------------------------------------------------------- fifth, check user |
|
|
if (defined($uname)) { |
if ($uname ne '') { |
if (defined($$useropt{$courselevel})) { |
if (defined($$useropt{$courselevel})) { |
$outpar[3]=$$useropt{$courselevel}; |
$outpar[3]=$$useropt{$courselevel}; |
$result=3; |
$result=3; |
Line 268 sub resetrulescache {
|
Line 272 sub resetrulescache {
|
|
|
sub rulescache { |
sub rulescache { |
my $id=shift; |
my $id=shift; |
if ($rulesid ne $env{'request.course.id'}) { |
if ($rulesid ne $env{'request.course.id'} |
%rules=(); |
&& !defined($rules{$id})) { |
} |
|
unless (defined($rules{$id})) { |
|
my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'}; |
my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'}; |
my $crs = $env{'course.'.$env{'request.course.id'}.'.num'}; |
my $crs = $env{'course.'.$env{'request.course.id'}.'.num'}; |
%rules=&Apache::lonnet::dump('parmdefactions',$dom,$crs); |
%rules=&Apache::lonnet::dump('parmdefactions',$dom,$crs); |
Line 295 sub preset_defaults {
|
Line 297 sub preset_defaults {
|
} |
} |
|
|
################################################## |
################################################## |
|
|
|
sub date_sanity_info { |
|
my $checkdate=shift; |
|
unless ($checkdate) { return ''; } |
|
my $result=''; |
|
my $crsprefix='course.'.$env{'request.course.id'}.'.'; |
|
if ($env{$crsprefix.'default_enrollment_end_date'}) { |
|
if ($checkdate>$env{$crsprefix.'default_enrollment_end_date'}) { |
|
$result.='<br />'.&mt('After course enrollment end!'); |
|
} |
|
} |
|
if ($env{$crsprefix.'default_enrollment_start_date'}) { |
|
if ($checkdate<$env{$crsprefix.'default_enrollment_start_date'}) { |
|
$result.='<br />'.&mt('Before course enrollment start!'); |
|
} |
|
} |
|
return $result; |
|
} |
|
################################################## |
################################################## |
################################################## |
# |
# |
# Store a parameter by ID |
# Store a parameter by ID |
Line 310 sub preset_defaults {
|
Line 331 sub preset_defaults {
|
|
|
sub storeparm { |
sub storeparm { |
my ($sresid,$spnam,$snum,$nval,$ntype,$uname,$udom,$csec,$cgroup)=@_; |
my ($sresid,$spnam,$snum,$nval,$ntype,$uname,$udom,$csec,$cgroup)=@_; |
&storeparm_by_symb(&symbcache($sresid),$spnam,$snum,$nval,$ntype,$uname,$udom,$csec,$cgroup); |
&storeparm_by_symb(&symbcache($sresid),$spnam,$snum,$nval,$ntype,$uname,$udom,$csec,'',$cgroup); |
} |
} |
|
|
# |
# |
Line 327 sub storeparm {
|
Line 348 sub storeparm {
|
|
|
my %recstack; |
my %recstack; |
sub storeparm_by_symb { |
sub storeparm_by_symb { |
my ($symb,$spnam,$snum,$nval,$ntype,$uname,$udom,$csec,$cgroup,$recflag)=@_; |
my ($symb,$spnam,$snum,$nval,$ntype,$uname,$udom,$csec,$recflag,$cgroup)=@_; |
unless ($recflag) { |
unless ($recflag) { |
# first time call |
# first time call |
%recstack=(); |
%recstack=(); |
Line 370 sub storeparm_by_symb {
|
Line 391 sub storeparm_by_symb {
|
} |
} |
if ($active) { |
if ($active) { |
&storeparm_by_symb($symb,$newspnam,$snum,$newvalue,&rulescache($triggered.'_type'), |
&storeparm_by_symb($symb,$newspnam,$snum,$newvalue,&rulescache($triggered.'_type'), |
$uname,$udom,$csec,$cgroup,$recflag); |
$uname,$udom,$csec,$recflag,$cgroup); |
} |
} |
} |
} |
} |
} |
return ''; |
return ''; |
} |
} |
|
|
|
sub log_parmset { |
|
return &Apache::lonnet::instructor_log('parameterlog',@_); |
|
} |
|
|
sub storeparm_by_symb_inner { |
sub storeparm_by_symb_inner { |
# ---------------------------------------------------------- Get symb, map, etc |
# ---------------------------------------------------------- Get symb, map, etc |
my ($symb,$spnam,$snum,$nval,$ntype,$uname,$udom,$csec,$cgroup)=@_; |
my ($symb,$spnam,$snum,$nval,$ntype,$uname,$udom,$csec,$cgroup)=@_; |
# ---------------------------------------------------------- Construct prefixes |
# ---------------------------------------------------------- Construct prefixes |
$spnam=~s/\_([^\_]+)$/\.$1/; |
$spnam=~s/\_([^\_]+)$/\.$1/; |
my $map=(&Apache::lonnet::decode_symb($symb))[0]; |
my $map=(&Apache::lonnet::decode_symb($symb))[0]; |
|
$map = &Apache::lonnet::deversion($map); |
|
|
my $symbparm=$symb.'.'.$spnam; |
my $symbparm=$symb.'.'.$spnam; |
my $mapparm=$map.'___(all).'.$spnam; |
my $mapparm=$map.'___(all).'.$spnam; |
|
|
Line 433 sub storeparm_by_symb_inner {
|
Line 460 sub storeparm_by_symb_inner {
|
if ($delete) { |
if ($delete) { |
$reply=&Apache::lonnet::del |
$reply=&Apache::lonnet::del |
('resourcedata',[keys(%storecontent)],$cdom,$cnum); |
('resourcedata',[keys(%storecontent)],$cdom,$cnum); |
|
&log_parmset(\%storecontent,1); |
} else { |
} else { |
$reply=&Apache::lonnet::cput |
$reply=&Apache::lonnet::cput |
('resourcedata',\%storecontent,$cdom,$cnum); |
('resourcedata',\%storecontent,$cdom,$cnum); |
|
&log_parmset(\%storecontent); |
} |
} |
&Apache::lonnet::devalidatecourseresdata($cnum,$cdom); |
&Apache::lonnet::devalidatecourseresdata($cnum,$cdom); |
} else { |
} else { |
Line 456 sub storeparm_by_symb_inner {
|
Line 485 sub storeparm_by_symb_inner {
|
if ($delete) { |
if ($delete) { |
$reply=&Apache::lonnet::del |
$reply=&Apache::lonnet::del |
('resourcedata',[keys(%storecontent)],$udom,$uname); |
('resourcedata',[keys(%storecontent)],$udom,$uname); |
|
&log_parmset(\%storecontent,1,$uname,$udom); |
} else { |
} else { |
$reply=&Apache::lonnet::cput |
$reply=&Apache::lonnet::cput |
('resourcedata',\%storecontent,$udom,$uname); |
('resourcedata',\%storecontent,$udom,$uname); |
|
&log_parmset(\%storecontent,0,$uname,$udom); |
} |
} |
&Apache::lonnet::devalidateuserresdata($uname,$udom); |
&Apache::lonnet::devalidateuserresdata($uname,$udom); |
} |
} |
|
|
if ($reply=~/^error\:(.*)/) { |
if ($reply=~/^error\:(.*)/) { |
return "<font color=red>Write Error: $1</font>"; |
return "<span class=\"LC_error\">Write Error: $1</span>"; |
} |
} |
return ''; |
return ''; |
} |
} |
Line 478 sub storeparm_by_symb_inner {
|
Line 509 sub storeparm_by_symb_inner {
|
|
|
Format a value for output. |
Format a value for output. |
|
|
Inputs: $value, $type |
Inputs: $value, $type, $editable |
|
|
Returns: $value, formatted for output. If $type indicates it is a date, |
Returns: $value, formatted for output. If $type indicates it is a date, |
localtime($value) is returned. |
localtime($value) is returned. |
|
$editable will return an icon to click on |
|
|
=cut |
=cut |
|
|
################################################## |
################################################## |
################################################## |
################################################## |
sub valout { |
sub valout { |
my ($value,$type)=@_; |
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') { |
$result = ' '; |
if ($editable) { |
|
$result = '<span class="LC_clickhere">*</span>'; |
|
} else { |
|
$result=' '; |
|
} |
} else { |
} else { |
if ($type eq 'date_interval') { |
if ($type eq 'date_interval') { |
my ($sec,$min,$hour,$mday,$mon,$year)=gmtime($value); |
my ($sec,$min,$hour,$mday,$mon,$year)=gmtime($value); |
Line 518 sub valout {
|
Line 554 sub valout {
|
} |
} |
$result=~s/\s+$//; |
$result=~s/\s+$//; |
} elsif (&isdateparm($type)) { |
} elsif (&isdateparm($type)) { |
$result = localtime($value); |
$result = &Apache::lonlocal::locallocaltime($value). |
|
&date_sanity_info($value); |
} else { |
} else { |
$result = $value; |
$result = $value; |
} |
} |
Line 560 sub plink {
|
Line 597 sub plink {
|
return '<table width="100%"><tr valign="top" align="right"><td><a name="'.$marker.'" /></td></tr><tr><td align="center">'. |
return '<table width="100%"><tr valign="top" align="right"><td><a name="'.$marker.'" /></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."'".');">'. |
&valout($value,$type).'</a></td></tr></table>'; |
&valout($value,$type,1).'</a></td></tr></table>'; |
} |
} |
|
|
sub startpage { |
sub page_js { |
my $r=shift; |
|
my $loaditems = qq|onUnload="pclose()" onLoad="group_or_section('cgroup')"|; |
|
my $bodytag=&Apache::loncommon::bodytag('Set/Modify Course Parameters','', |
|
$loaditems); |
|
my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs(undef,'Table Mode Parameter Setting'); |
|
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 $html=&Apache::lonxml::xmlbegin(); |
|
$r->print(<<ENDHEAD); |
return(<<ENDJS); |
$html |
<script type="text/javascript"> |
<head> |
|
<title>LON-CAPA Course Parameters</title> |
|
<script> |
|
|
|
function pclose() { |
function pclose() { |
parmwin=window.open("/adm/rat/empty.html","LONCAPAparms", |
parmwin=window.open("/adm/rat/empty.html","LONCAPAparms", |
Line 618 $html
|
Line 648 $html
|
} |
} |
</script> |
</script> |
$selscript |
$selscript |
</head> |
ENDJS |
$bodytag |
|
|
} |
|
sub startpage { |
|
my ($r) = @_; |
|
|
|
my %loaditems = ('onunload' => "pclose()", |
|
'onload' => "group_or_section('cgroup')",); |
|
|
|
my $start_page = |
|
&Apache::loncommon::start_page('Set/Modify Course Parameters', |
|
&page_js(), |
|
{'add_entries' => \%loaditems,}); |
|
my $breadcrumbs = |
|
&Apache::lonhtmlcommon::breadcrumbs('Table Mode Parameter Setting','Table_Mode'); |
|
$r->print(<<ENDHEAD); |
|
$start_page |
$breadcrumbs |
$breadcrumbs |
<form method="post" action="/adm/parmset?action=settable" name="parmform"> |
<form method="post" action="/adm/parmset?action=settable" name="parmform"> |
<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"> |
<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,$defbgthree,$parmlev,$uname,$udom,$csec,$cgroup)=@_; |
$defbgtwo,$defbgthree,$parmlev,$uname,$udom,$csec,$cgroup,$usersgroups)=@_; |
|
my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; |
|
my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; |
|
my $courseopt=&Apache::lonnet::get_courseresdata($cnum,$cdom); |
# 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 |
my ($result,@outpar)=&parmval($$part{$which}.'.'.$$name{$which}, |
my ($result,@outpar)=&parmval($$part{$which}.'.'.$$name{$which}, |
$rid,$$default{$which},$uname,$udom,$csec,$cgroup); |
$rid,$$default{$which},$uname,$udom,$csec,$cgroup,$courseopt); |
# get the type for the parameters |
# get the type for the parameters |
# problem: these may not be set for all levels |
# problem: these may not be set for all levels |
my ($typeresult,@typeoutpar)=&parmval($$part{$which}.'.'. |
my ($typeresult,@typeoutpar)=&parmval($$part{$which}.'.'. |
$$name{$which}.'.type', |
$$name{$which}.'.type',$rid, |
$rid,$$defaulttype{$which},$uname,$udom,$csec,$cgroup); |
$$defaulttype{$which},$uname,$udom,$csec,$cgroup,$courseopt); |
# cascade down manually |
# cascade down manually |
my $cascadetype=$$defaulttype{$which}; |
my $cascadetype=$$defaulttype{$which}; |
for (my $i=14;$i>0;$i--) { |
for (my $i=14;$i>0;$i--) { |
Line 661 sub print_row {
|
Line 709 sub print_row {
|
} |
} |
my $automatic=&rulescache(($which=~/\_([^\_]+)$/)[0].'_triggers'); |
my $automatic=&rulescache(($which=~/\_([^\_]+)$/)[0].'_triggers'); |
if ($automatic) { |
if ($automatic) { |
$parm.='<font color="red"><br />'.&mt('Automatically sets').' '.join(', ',split(/\:/,$automatic)).'</font>'; |
$parm.='<span class="LC_warning"><br />'.&mt('Automatically sets').' '.join(', ',split(/\:/,$automatic)).'</span>'; |
} |
} |
$r->print('<td bgcolor='.$defbgone.'>'.$parm.'</td>'); |
$r->print('<td bgcolor='.$defbgone.'>'.$parm.'</td>'); |
|
|
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]); |
|
my ($othergrp,$grp_parm,$controlgrp); |
|
|
if ($parmlev eq 'general') { |
if ($parmlev eq 'general') { |
|
|
Line 692 sub print_row {
|
Line 742 sub print_row {
|
&print_td($r,13,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display); |
&print_td($r,13,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display); |
} |
} |
} else { |
} else { |
|
if ($uname) { |
|
if (@{$usersgroups} > 1) { |
|
my ($coursereply,$grp_parm,$controlgrp); |
|
($coursereply,$othergrp,$grp_parm,$controlgrp) = |
|
&print_usergroups($r,$$part{$which}.'.'.$$name{$which}, |
|
$rid,$cgroup,$defbgone,$usersgroups,$result,$courseopt); |
|
if ($coursereply && $result > 3) { |
|
if (defined($controlgrp)) { |
|
if ($cgroup ne $controlgrp) { |
|
$effective_parm = $grp_parm; |
|
$result = 0; |
|
} |
|
} |
|
} |
|
} |
|
} |
|
|
&print_td($r,14,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display); |
&print_td($r,14,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display); |
|
|
Line 711 sub print_row {
|
Line 777 sub print_row {
|
&print_td($r,5,$defbgthree,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display); |
&print_td($r,5,$defbgthree,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display); |
&print_td($r,4,$defbgthree,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display); |
&print_td($r,4,$defbgthree,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display); |
} |
} |
|
|
if ($uname) { |
if ($uname) { |
|
if ($othergrp) { |
|
$r->print($othergrp); |
|
} |
&print_td($r,3,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display); |
&print_td($r,3,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display); |
&print_td($r,2,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display); |
&print_td($r,2,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display); |
&print_td($r,1,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display); |
&print_td($r,1,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display); |
} |
} |
|
|
} # end of $parmlev if/else |
} # end of $parmlev if/else |
|
$r->print('<td bgcolor="#CCCCFF" align="center">'.$effective_parm.'</td>'); |
$r->print('<td bgcolor=#CCCCFF align="center">'. |
|
&valout($outpar[$result],$typeoutpar[$result]).'</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}); |
my $sessionvaltype=$typeoutpar[$result]; |
my $sessionvaltype=$typeoutpar[$result]; |
if (!defined($sessionvaltype)) { $sessionvaltype=$$defaulttype{$which}; } |
if (!defined($sessionvaltype)) { $sessionvaltype=$$defaulttype{$which}; } |
$r->print('<td bgcolor=#999999 align="center"><font color=#FFFFFF>'. |
$r->print('<td bgcolor="#999999" align="center"><font color="#FFFFFF">'. |
&valout($sessionval,$sessionvaltype).' '. |
&valout($sessionval,$sessionvaltype).' '. |
'</font></td>'); |
'</font></td>'); |
} |
} |
Line 750 sub print_td {
|
Line 817 sub print_td {
|
$r->print('</td>'."\n"); |
$r->print('</td>'."\n"); |
} |
} |
|
|
|
sub print_usergroups { |
|
my ($r,$what,$rid,$cgroup,$defbg,$usersgroups,$result,$courseopt) = @_; |
|
my $courseid = $env{'request.course.id'}; |
|
my $output; |
|
my $symb = &symbcache($rid); |
|
my $symbparm=$symb.'.'.$what; |
|
my $map=(&Apache::lonnet::decode_symb($symb))[0]; |
|
my $mapparm=$map.'___(all).'.$what; |
|
my ($coursereply,$resultitem,$resultgroup,$resultlevel,$resulttype) = |
|
&parm_control_group($courseid,$usersgroups,$symbparm,$mapparm,$what, |
|
$courseopt); |
|
my $bgcolor = $defbg; |
|
my $grp_parm; |
|
if (($coursereply) && ($cgroup ne $resultgroup)) { |
|
if ($result > 3) { |
|
$bgcolor = '"#AAFFAA"'; |
|
$grp_parm = &valout($coursereply,$resulttype); |
|
} |
|
$grp_parm = &valout($coursereply,$resulttype); |
|
$output = '<td bgcolor='.$bgcolor.' align="center">'; |
|
if ($resultgroup && $resultlevel) { |
|
$output .= '<small><b>'.$resultgroup.'</b> ('.$resultlevel.'): </small>'.$grp_parm; |
|
} else { |
|
$output .= ' '; |
|
} |
|
$output .= '</td>'; |
|
} else { |
|
$output .= '<td bgcolor='.$bgcolor.'> </td>'; |
|
} |
|
return ($coursereply,$output,$grp_parm,$resultgroup); |
|
} |
|
|
|
sub parm_control_group { |
|
my ($courseid,$usersgroups,$symbparm,$mapparm,$what,$courseopt) = @_; |
|
my ($coursereply,$resultitem,$resultgroup,$resultlevel,$resulttype); |
|
my $grpfound = 0; |
|
my @levels = ($symbparm,$mapparm,$what); |
|
my @levelnames = ('resource','map/folder','general'); |
|
foreach my $group (@{$usersgroups}) { |
|
if ($grpfound) { last; } |
|
for (my $i=0; $i<@levels; $i++) { |
|
my $item = $courseid.'.['.$group.'].'.$levels[$i]; |
|
if (defined($$courseopt{$item})) { |
|
$coursereply = $$courseopt{$item}; |
|
$resultitem = $item; |
|
$resultgroup = $group; |
|
$resultlevel = $levelnames[$i]; |
|
$resulttype = $$courseopt{$item.'.type'}; |
|
$grpfound = 1; |
|
last; |
|
} |
|
} |
|
} |
|
return($coursereply,$resultitem,$resultgroup,$resultlevel,$resulttype); |
|
} |
|
|
=pod |
=pod |
|
|
Line 813 sub extractResourceInformation {
|
Line 935 sub extractResourceInformation {
|
$$typep{$id}=$1; |
$$typep{$id}=$1; |
$$keyp{$id}=''; |
$$keyp{$id}=''; |
$$uris{$id}=$srcf; |
$$uris{$id}=$srcf; |
foreach (split(/\,/,&Apache::lonnet::metadata($srcf,'allpossiblekeys'))) { |
foreach my $key (split(/\,/,&Apache::lonnet::metadata($srcf,'allpossiblekeys'))) { |
if ($_=~/^parameter\_(.*)/) { |
next if ($key!~/^parameter_/); |
my $key=$_; |
|
# Hidden parameters |
# Hidden parameters |
if (&Apache::lonnet::metadata($srcf,$key.'.hidden') eq 'parm') { |
next if (&Apache::lonnet::metadata($srcf,$key.'.hidden') eq 'parm'); |
next; |
|
} |
|
my $display= &Apache::lonnet::metadata($srcf,$key.'.display'); |
|
my $name=&Apache::lonnet::metadata($srcf,$key.'.name'); |
|
my $part= &Apache::lonnet::metadata($srcf,$key.'.part'); |
|
# |
# |
# allparms is a hash of parameter names |
# allparms is a hash of parameter names |
# |
# |
|
my $name=&Apache::lonnet::metadata($srcf,$key.'.name'); |
|
if (!exists($$allparms{$name})) { |
|
my $display= &Apache::lonnet::metadata($srcf,$key.'.display'); |
my $parmdis = $display; |
my $parmdis = $display; |
$parmdis =~ s/\[Part.*$//g; |
$parmdis =~ s/\[Part.*$//g; |
$$allparms{$name}=$parmdis; |
$$allparms{$name}=$parmdis; |
$$defkeytype{$name}=&Apache::lonnet::metadata($srcf,$key.'.type'); |
if (ref($defkeytype)) { |
|
$$defkeytype{$name}= |
|
&Apache::lonnet::metadata($srcf,$key.'.type'); |
|
} |
|
} |
|
|
# |
# |
# allparts is a hash of all parts |
# allparts is a hash of all parts |
# |
# |
$$allparts{$part} = "Part: $part"; |
my $part= &Apache::lonnet::metadata($srcf,$key.'.part'); |
|
$$allparts{$part} = "Part: $part"; |
# |
# |
# Remember all keys going with this resource |
# 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 |
# Put in order |
# |
# |
unless ($$keyorder{$key}) { |
unless ($$keyorder{$key}) { |
$$keyorder{$key}=$keyordercnt; |
$$keyorder{$key}=$keyordercnt; |
$keyordercnt++; |
$keyordercnt++; |
} |
|
|
|
} |
} |
} |
} |
$$mapp{$id}= |
|
&Apache::lonnet::declutter($resource->enclosing_map_src()); |
|
$$mapp{$mapid}=$$mapp{$id}; |
if (!exists($$mapp{$mapid})) { |
$$allmaps{$mapid}=$$mapp{$id}; |
$$mapp{$id}= |
if ($mapid eq '1') { |
&Apache::lonnet::declutter($resource->enclosing_map_src()); |
$$maptitles{$mapid}='Main Course Documents'; |
$$mapp{$mapid}=$$mapp{$id}; |
|
$$allmaps{$mapid}=$$mapp{$id}; |
|
if ($mapid eq '1') { |
|
$$maptitles{$mapid}='Main Course Documents'; |
|
} else { |
|
$$maptitles{$mapid}= |
|
&Apache::lonnet::gettitle($$mapp{$id}); |
|
} |
|
$$maptitles{$$mapp{$id}}=$$maptitles{$mapid}; |
|
$$symbp{$mapid}=$$mapp{$id}.'___(all)'; |
} else { |
} else { |
$$maptitles{$mapid}=&Apache::lonnet::gettitle(&Apache::lonnet::clutter($$mapp{$id})); |
$$mapp{$id} = $$mapp{$mapid}; |
} |
} |
$$maptitles{$$mapp{$id}}=$$maptitles{$mapid}; |
|
$$symbp{$id}=&Apache::lonnet::encode_symb($$mapp{$id},$resid,$srcf); |
$$symbp{$id}=&Apache::lonnet::encode_symb($$mapp{$id},$resid,$srcf); |
$$symbp{$mapid}=$$mapp{$id}.'___(all)'; |
|
} |
} |
} |
} |
|
|
Line 942 sub parmmenu {
|
Line 1073 sub parmmenu {
|
</script> |
</script> |
ENDSCRIPT |
ENDSCRIPT |
$r->print(); |
$r->print(); |
$r->print("\n<table><tr>"); |
$r->print("\n<table id=\"LC_parm_overview_parm_menu\"><tr>"); |
my $cnt=0; |
my $cnt=0; |
foreach $tempkey (&keysindisplayorder($allparms,$keyorder)) { |
foreach $tempkey (&keysindisplayorder($allparms,$keyorder)) { |
$r->print("\n<td><font size='-1'><label><input type='checkbox' name='pscat' "); |
$r->print("\n<td><label><input type='checkbox' name='pscat' "); |
$r->print('value="'.$tempkey.'"'); |
$r->print('value="'.$tempkey.'"'); |
if ($$pscat[0] eq "all" || grep $_ eq $tempkey, @{$pscat}) { |
if ($$pscat[0] eq "all" || grep $_ eq $tempkey, @{$pscat}) { |
$r->print(' checked'); |
$r->print(' checked'); |
} |
} |
$r->print('>'.$$allparms{$tempkey}.'</label></font></td>'); |
$r->print('>'.$$allparms{$tempkey}.'</label></td>'); |
$cnt++; |
$cnt++; |
if ($cnt==3) { |
if ($cnt==3) { |
$r->print("</tr>\n<tr>"); |
$r->print("</tr>\n<tr>"); |
Line 958 ENDSCRIPT
|
Line 1089 ENDSCRIPT
|
} |
} |
} |
} |
$r->print(' |
$r->print(' |
</tr><tr><td> |
</tr><tr id=\"LC_parm_overview_parm_menu_selectors\"><td> |
<a href="javascript:checkall(true, \'pscat\')">Select All</a><br /> |
<a href="javascript:checkall(true, \'pscat\')">Select All</a><br /> |
<a href="javascript:checkstandard()">Select Common Only</a> |
<a href="javascript:checkstandard()">Select Common Only</a> |
</td><td> |
</td><td> |
Line 997 sub partmenu {
|
Line 1128 sub partmenu {
|
} |
} |
|
|
sub usermenu { |
sub usermenu { |
my ($r,$uname,$id,$udom,$csec,$cgroup,$parmlev)=@_; |
my ($r,$uname,$id,$udom,$csec,$cgroup,$parmlev,$usersgroups)=@_; |
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'); |
my $selscript=&Apache::loncommon::studentbrowser_javascript(); |
my $selscript=&Apache::loncommon::studentbrowser_javascript(); |
Line 1008 sub usermenu {
|
Line 1139 sub usermenu {
|
'oi' => "or ID", |
'oi' => "or ID", |
'ad' => "at Domain" |
'ad' => "at Domain" |
); |
); |
my %sectionhash=(); |
|
my $sections=''; |
my $sections=''; |
my $numsec = &Apache::loncommon::get_sections( |
my %sectionhash = &Apache::loncommon::get_sections(); |
$env{'course.'.$env{'request.course.id'}.'.domain'}, |
|
$env{'course.'.$env{'request.course.id'}.'.num'}, |
|
\%sectionhash); |
|
my $groups; |
my $groups; |
my %grouphash; |
my %grouphash = &Apache::longroup::coursegroups(); |
my $numgrp = &Apache::loncommon::coursegroups( |
|
\%grouphash, |
if (%sectionhash) { |
$env{'course.'.$env{'request.course.id'}.'.domain'}, |
|
$env{'course.'.$env{'request.course.id'}.'.num'}); |
|
if ($numsec > 0) { |
|
$sections=$lt{'se'}.': <select name="csec"'; |
$sections=$lt{'se'}.': <select name="csec"'; |
if ($numsec && $numgrp && $parmlev ne 'full') { |
if (%grouphash && $parmlev ne 'full') { |
$sections .= qq| onchange="group_or_section('csec')" |; |
$sections .= qq| onchange="group_or_section('csec')" |; |
} |
} |
$sections .= '>'; |
$sections .= '>'; |
foreach ('',sort keys %sectionhash) { |
foreach my $section ('',sort keys %sectionhash) { |
$sections.='<option value="'.$_.'"'. |
$sections.='<option value="'.$section.'" '. |
($_ eq $csec?'selected="selected"':'').'>'.$_.'</option>'; |
($section eq $csec?'selected="selected"':'').'>'.$section. |
|
'</option>'; |
} |
} |
$sections.='</select>'; |
$sections.='</select>'; |
} |
} |
if ($numsec && $numgrp && $parmlev ne 'full') { |
if (%sectionhash && %grouphash && $parmlev ne 'full') { |
$sections .= ' or '; |
$sections .= ' or '; |
$sections .= qq| |
$sections .= qq| |
<script type="text/javascript"> |
<script type="text/javascript"> |
Line 1058 function group_or_section(caller) {
|
Line 1184 function group_or_section(caller) {
|
</script> |
</script> |
|; |
|; |
} |
} |
if ($numgrp > 0) { |
|
|
if (%grouphash) { |
$groups=$lt{'gr'}.': <select name="cgroup"'; |
$groups=$lt{'gr'}.': <select name="cgroup"'; |
if ($numsec && $numgrp && $env{'form.action'} eq 'settable') { |
if (%sectionhash && $env{'form.action'} eq 'settable') { |
$groups .= qq| onchange="group_or_section('cgroup')" |; |
$groups .= qq| onchange="group_or_section('cgroup')" |; |
} |
} |
$groups .= '>'; |
$groups .= '>'; |
foreach ('',sort keys %grouphash) { |
foreach my $grp ('',sort keys %grouphash) { |
$groups.='<option value="'.$_.'"'. |
$groups.='<option value="'.$grp.'" '; |
($_ eq $cgroup?'selected="selected"':'').'>'. |
if ($grp eq $cgroup) { |
$_.'</option>'; |
unless ((defined($uname)) && ($grp eq '')) { |
|
$groups .= 'selected="selected" '; |
|
} |
|
} elsif (!defined($cgroup)) { |
|
if (@{$usersgroups} == 1) { |
|
if ($grp eq $$usersgroups[0]) { |
|
$groups .= 'selected="selected" '; |
|
} |
|
} |
|
} |
|
$groups .= '>'.$grp.'</option>'; |
} |
} |
$groups.='</select>'; |
$groups.='</select>'; |
} |
} |
Line 1127 sub levelmenu {
|
Line 1264 sub levelmenu {
|
|
|
sub sectionmenu { |
sub sectionmenu { |
my ($r,$selectedsections)=@_; |
my ($r,$selectedsections)=@_; |
my %sectionhash=(); |
my %sectionhash = &Apache::loncommon::get_sections(); |
my $sections=''; |
return if (!%sectionhash); |
my $numsec = &Apache::loncommon::get_sections( |
|
$env{'course.'.$env{'request.course.id'}.'.domain'}, |
$r->print('<select name="Section" multiple="true" size="8" >'); |
$env{'course.'.$env{'request.course.id'}.'.num'}, |
foreach my $s ('all',sort keys %sectionhash) { |
\%sectionhash); |
$r->print(' <option value="'.$s.'"'); |
if ($numsec) { |
foreach (@{$selectedsections}) { |
$r->print('<select name="Section" multiple="true" size="8" >'); |
if ($s eq $_) { |
foreach my $s ('all',sort keys %sectionhash) { |
$r->print(' selected'); |
$r->print(' <option value="'.$s.'"'); |
last; |
foreach (@{$selectedsections}) { |
|
if ($s eq $_) { |
|
$r->print(' selected'); |
|
last; |
|
} |
|
} |
} |
$r->print('>'.$s."</option>\n"); |
|
} |
} |
$r->print("</select>\n"); |
$r->print('>'.$s."</option>\n"); |
} |
} |
|
$r->print("</select>\n"); |
} |
} |
|
|
sub groupmenu { |
sub groupmenu { |
my ($r,$selectedgroups)=@_; |
my ($r,$selectedgroups)=@_; |
my %grouphash; |
my %grouphash = &Apache::longroup::coursegroups(); |
my $numgrp = &Apache::loncommon::coursegroups( |
return if (!%grouphash); |
\%grouphash, |
|
$env{'course.'.$env{'request.course.id'}.'.domain'}, |
$r->print('<select name="Group" multiple="true" size="8" >'); |
$env{'course.'.$env{'request.course.id'}.'.num'}); |
foreach my $group (sort(keys(%grouphash))) { |
if ($numgrp) { |
$r->print(' <option value="'.$group.'"'); |
$r->print('<select name="Group" multiple="true" size="8" >'); |
foreach (@{$selectedgroups}) { |
foreach my $group (sort(keys(%grouphash))) { |
if ($group eq $_) { |
$r->print(' <option value="'.$group.'"'); |
$r->print(' selected'); |
foreach (@{$selectedgroups}) { |
last; |
if ($group eq $_) { |
} |
$r->print(' selected'); |
} |
last; |
$r->print('>'.$group."</option>\n"); |
} |
|
} |
|
$r->print('>'.$group."</option>\n"); |
|
} |
|
$r->print("</select>\n"); |
|
} |
} |
|
$r->print("</select>\n"); |
} |
} |
|
|
|
|
Line 1294 sub assessparms {
|
Line 1422 sub assessparms {
|
my $uhome; |
my $uhome; |
my $csec; |
my $csec; |
my $cgroup; |
my $cgroup; |
|
my @usersgroups = (); |
|
|
my $coursename=$env{'course.'.$env{'request.course.id'}.'.description'}; |
my $coursename=$env{'course.'.$env{'request.course.id'}.'.description'}; |
|
|
Line 1364 sub assessparms {
|
Line 1493 sub assessparms {
|
$id=''; |
$id=''; |
} else { |
} else { |
$message= |
$message= |
"<font color=red>".&mt("Unknown ID")." '$id' ". |
'<span class="LC_error">'.&mt("Unknown ID")." '$id' ". |
&mt('at domain')." '$udom'</font>"; |
&mt('at domain')." '$udom'</span>"; |
} |
} |
} else { |
} else { |
$uname=$env{'form.uname'}; |
$uname=$env{'form.uname'}; |
Line 1376 sub assessparms {
|
Line 1505 sub assessparms {
|
$uhome=&Apache::lonnet::homeserver($uname,$udom); |
$uhome=&Apache::lonnet::homeserver($uname,$udom); |
if ($uhome eq 'no_host') { |
if ($uhome eq 'no_host') { |
$message= |
$message= |
"<font color=red>".&mt("Unknown user")." '$uname' ". |
'<span class="LC_error">'.&mt("Unknown user")." '$uname' ". |
&mt("at domain")." '$udom'</font>"; |
&mt("at domain")." '$udom'</span>"; |
$uname=''; |
$uname=''; |
} else { |
} else { |
$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="<font color=red>". |
$message='<span class="LC_error">'. |
&mt("User")." '$uname' ".&mt("at domain")." '$udom' ". |
&mt("User")." '$uname' ".&mt("at domain")." '$udom' ". |
&mt("not in this course")."</font>"; |
&mt("not in this course")."</span>"; |
$uname=''; |
$uname=''; |
$csec=$env{'form.csec'}; |
$csec=$env{'form.csec'}; |
$cgroup=$env{'form.cgroup'}; |
$cgroup=$env{'form.cgroup'}; |
Line 1396 sub assessparms {
|
Line 1525 sub assessparms {
|
$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('ID').": ".$name{'id'}.'<p>'; |
"<br />\n".&mt('ID').": ".$name{'id'}.'<p>'; |
} |
} |
my $grouplist = &Apache::lonnet::get_users_groups( |
@usersgroups = &Apache::lonnet::get_users_groups( |
$udom,$uname,$env{'request.course.id'}); |
$udom,$uname,$env{'request.course.id'}); |
if ($grouplist) { |
if (@usersgroups > 0) { |
my @groups = split(/:/,$grouplist); |
unless (grep(/^\Q$cgroup\E$/,@usersgroups)) { |
@groups = sort(@groups); |
$cgroup = $usersgroups[0]; |
$cgroup = $groups[0]; |
} |
} |
} |
} |
} |
} |
} |
Line 1444 sub assessparms {
|
Line 1573 sub assessparms {
|
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_'.$_.'" />'); |
} |
} |
|
|
if (!$pssymb) { |
if (!$pssymb) { |
Line 1459 sub assessparms {
|
Line 1588 sub assessparms {
|
&displaymenu($r,\%allparms,\%allparts,\@pscat,\@psprt,\%keyorder); |
&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(&mt('Specific Resource').": ".$resource. |
my $title = &Apache::lonnet::gettitle($pssymb); |
'<input type="hidden" value="'.$pssymb.'" name="symb">'. |
$r->print(&mt('Specific Resource: [_1] ([_2])',$title,$resource). |
|
'<input type="hidden" value="'.$pssymb.'" name="symb" />'. |
'<br /><label><b>'.&mt('Show all parts').': <input type="checkbox" name="psprt" value="all"'. |
'<br /><label><b>'.&mt('Show all parts').': <input type="checkbox" name="psprt" value="all"'. |
($env{'form.psprt'}?' checked="checked"':'').' /></b></label><br />'); |
($env{'form.psprt'}?' checked="checked"':'').' /></b></label><br />'); |
} |
} |
&usermenu($r,$uname,$id,$udom,$csec,$cgroup,$parmlev); |
&usermenu($r,$uname,$id,$udom,$csec,$cgroup,$parmlev,\@usersgroups); |
|
|
$r->print('<p>'.$message.'</p>'); |
$r->print('<p>'.$message.'</p>'); |
|
|
Line 1486 sub assessparms {
|
Line 1616 sub assessparms {
|
|
|
if ($parmlev eq 'full') { |
if ($parmlev eq 'full') { |
my $coursespan=$csec?8:5; |
my $coursespan=$csec?8:5; |
|
my $userspan=3; |
if ($cgroup ne '') { |
if ($cgroup ne '') { |
$coursespan += 3; |
$coursespan += 3; |
} |
} |
Line 1494 sub assessparms {
|
Line 1625 sub assessparms {
|
$r->print('<tr><td colspan=5></td>'); |
$r->print('<tr><td colspan=5></td>'); |
$r->print('<th colspan='.($coursespan).'>'.&mt('Any User').'</th>'); |
$r->print('<th colspan='.($coursespan).'>'.&mt('Any User').'</th>'); |
if ($uname) { |
if ($uname) { |
$r->print("<th colspan=3 rowspan=2>"); |
if (@usersgroups > 1) { |
|
$userspan ++; |
|
} |
|
$r->print('<th colspan="'.$userspan.'" rowspan="2">'); |
$r->print(&mt("User")." $uname ".&mt('at Domain')." $udom</th>"); |
$r->print(&mt("User")." $uname ".&mt('at Domain')." $udom</th>"); |
} |
} |
my %lt=&Apache::lonlocal::texthash( |
my %lt=&Apache::lonlocal::texthash( |
Line 1516 sub assessparms {
|
Line 1650 sub assessparms {
|
); |
); |
$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 $lt{'at'} $csudom)</th> |
<th rowspan=3>$lt{'csv'}<br />($csuname $lt{'at'} $csudom)</th> |
</tr><tr><td colspan=5></td><th colspan=2>$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> |
|
|
Line 1545 ENDTABLEHEADFOUR
|
Line 1679 ENDTABLEHEADFOUR
|
} |
} |
|
|
if ($uname) { |
if ($uname) { |
|
if (@usersgroups > 1) { |
|
$r->print('<th>'.&mt('Control by other group?').'</th>'); |
|
} |
$r->print('<th>'.&mt('general').'</th><th>'.&mt('for Enclosing Map or Folder').'</th><th>'.&mt('for Resource').'</th>'); |
$r->print('<th>'.&mt('general').'</th><th>'.&mt('for Enclosing Map or Folder').'</th><th>'.&mt('for Resource').'</th>'); |
} |
} |
|
|
Line 1605 ENDTABLEHEADFOUR
|
Line 1742 ENDTABLEHEADFOUR
|
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($uri); |
my $title=&Apache::lonnet::gettitle($symbp{$rid}); |
$r->print('<tr><td bgcolor='.$defbgone. |
$r->print('<tr><td bgcolor='.$defbgone. |
' rowspan='.$totalparms. |
' rowspan='.$totalparms. |
'><tt><font size=-1>'. |
'><tt><font size=-1>'. |
join(' / ',split(/\//,$uri)). |
join(' / ',split(/\//,$uri)). |
'</font></tt><p><b>'. |
'</font></tt><p><b>'. |
"<a href=\"javascript:openWindow('". |
"<a href=\"javascript:openWindow('". |
&Apache::lonnet::clutter($uri). |
&Apache::lonnet::clutter($uri).'?symb='. |
"', 'metadatafile', '450', '500', 'no', 'yes')\";". |
&escape($symbp{$rid}). |
" TARGET=_self>$title"); |
"', 'metadatafile', '450', '500', 'no', 'yes');\"". |
|
" target=\"_self\">$title"); |
|
|
if ($thistitle) { |
if ($thistitle) { |
$r->print(' ('.$thistitle.')'); |
$r->print(' ('.$thistitle.')'); |
Line 1637 ENDTABLEHEADFOUR
|
Line 1775 ENDTABLEHEADFOUR
|
&print_row($r,$_,\%part,\%name,\%symbp,$rid,\%default, |
&print_row($r,$_,\%part,\%name,\%symbp,$rid,\%default, |
\%type,\%display,$defbgone,$defbgtwo, |
\%type,\%display,$defbgone,$defbgtwo, |
$defbgthree,$parmlev,$uname,$udom,$csec, |
$defbgthree,$parmlev,$uname,$udom,$csec, |
$cgroup); |
$cgroup,\@usersgroups); |
} |
} |
} |
} |
} |
} |
Line 1811 ENDMAPONE
|
Line 1949 ENDMAPONE
|
} |
} |
|
|
if ($csec) {$r->print(&mt("Section")."<font color=\"red\"> <i>$csec</i></font>\n")}; |
if ($csec) {$r->print(&mt("Section")."<font color=\"red\"> <i>$csec</i></font>\n")}; |
if ($cgroup) {$r->print(&mt("Group")."<font color=\"red\"> <i>$csec</i></font>\n")}; |
if ($cgroup) {$r->print(&mt("Group")."<font color=\"red\"> <i>$cgroup</i></font>\n")}; |
$r->print("</h4>\n"); |
$r->print("</h4>\n"); |
#---------------------------------------------------------------- print table |
#---------------------------------------------------------------- print table |
$r->print('<p><table border="2">'); |
$r->print('<p><table border="2">'); |
Line 1828 ENDMAPONE
|
Line 1966 ENDMAPONE
|
$r->print("</table></center>"); |
$r->print("</table></center>"); |
} # end of $parmlev eq general |
} # end of $parmlev eq general |
} |
} |
$r->print('</form></body></html>'); |
$r->print('</form>'.&Apache::loncommon::end_page()); |
} # end sub assessparms |
} # end sub assessparms |
|
|
|
|
Line 1853 Returns: nothing
|
Line 1991 Returns: nothing
|
sub crsenv { |
sub crsenv { |
my $r=shift; |
my $r=shift; |
my $setoutput=''; |
my $setoutput=''; |
my $bodytag=&Apache::loncommon::bodytag( |
|
'Set Course Environment Parameters'); |
my $breadcrumbs = |
my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs(undef, |
&Apache::lonhtmlcommon::breadcrumbs('Edit Course Environment'); |
'Edit Course Environment'); |
|
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'}; |
|
|
Line 1879 sub crsenv {
|
Line 2016 sub crsenv {
|
('environment', |
('environment', |
{'top level map backup '.$bkuptime => $tmp[1] }, |
{'top level map backup '.$bkuptime => $tmp[1] }, |
$dom,$crs). |
$dom,$crs). |
'<br>'; |
'<br />'; |
} |
} |
# |
# |
# Deal with modified default spreadsheets |
# Deal with modified default spreadsheets |
Line 1907 sub crsenv {
|
Line 2044 sub crsenv {
|
if ($name =~ /^default_enrollment_(start|end)_date$/) { |
if ($name =~ /^default_enrollment_(start|end)_date$/) { |
$value=&Apache::lonhtmlcommon::get_date_from_form($name.'_value'); |
$value=&Apache::lonhtmlcommon::get_date_from_form($name.'_value'); |
} |
} |
|
# |
|
# Deal with the emails |
|
if ($name =~ /\.email$/) { |
|
my ($user,$domain) = split(/:/,$value); |
|
if (!defined($user) || !defined($domain)) { |
|
$setoutput.= '<br /> <span class="LC_error">'. |
|
&mt("Invalid email address specified, address must be of the form username:domain"). |
|
'</span>'; |
|
undef($value); |
|
} elsif (&Apache::lonnet::homeserver($user,$domain) eq 'no_host') { |
|
$setoutput.= '<br /> <span class="LC_error">'. |
|
&mt("Invalid email address specified, user [_1] is unknown.",$value). |
|
'</span>'; |
|
undef($value); |
|
} |
|
} |
# Get existing cloners |
# Get existing cloners |
my @oldcloner = (); |
my @oldcloner = (); |
if ($name eq 'cloners') { |
if ($name eq 'cloners') { |
Line 1957 sub crsenv {
|
Line 2110 sub crsenv {
|
} |
} |
} |
} |
} |
} |
|
|
|
my $start_table =&Apache::loncommon::start_data_table(); |
|
my $start_header_row=&Apache::loncommon::start_data_table_header_row(); |
|
my $end_header_row =&Apache::loncommon::end_data_table_header_row(); |
# ------------------------- Re-init course environment entries for this session |
# ------------------------- Re-init course environment entries for this session |
|
|
&Apache::lonnet::coursedescription($env{'request.course.id'}); |
&Apache::lonnet::coursedescription($env{'request.course.id'}, |
|
{'freshen_cache' => 1}); |
|
|
# -------------------------------------------------------- Get parameters again |
# -------------------------------------------------------- Get parameters again |
|
|
Line 1972 sub crsenv {
|
Line 2130 sub crsenv {
|
('url' => '<b>'.&mt('Top Level Map').'</b> '. |
('url' => '<b>'.&mt('Top Level Map').'</b> '. |
'<a href="javascript:openbrowser'. |
'<a href="javascript:openbrowser'. |
"('envform','url','sequence')\">". |
"('envform','url','sequence')\">". |
&mt('Select Map').'</a><br /><font color=red> '. |
&mt('Select Map').'</a><br /><span class="LC_warning"> '. |
&mt('Modification may make assessment data inaccessible'). |
&mt('Modification may make assessment data inaccessible'). |
'</font>', |
'</span>', |
'description' => '<b>'.&mt('Course Description').'</b>', |
'description' => '<b>'.&mt('Course Description').'</b>', |
'courseid' => '<b>'.&mt('Course ID or number'). |
'courseid' => '<b>'.&mt('Course ID or number'). |
'</b><br />'. |
'</b><br />'. |
Line 1985 sub crsenv {
|
Line 2143 sub crsenv {
|
'default_xml_style' => '<b>'.&mt('Default XML Style File').'</b> '. |
'default_xml_style' => '<b>'.&mt('Default XML Style File').'</b> '. |
'<a href="javascript:openbrowser'. |
'<a href="javascript:openbrowser'. |
"('envform','default_xml_style'". |
"('envform','default_xml_style'". |
",'sty')\">$SelectStyleFile</a><br>", |
",'sty')\">$SelectStyleFile</a><br />", |
'question.email' => '<b>'.&mt('Feedback Addresses for Resource Content Question'). |
'question.email' => '<b>'.&mt('Feedback Addresses for Resource Content Question'). |
'</b><br />(<tt>user:domain,'. |
'</b><br />(<tt>user:domain,'. |
'user:domain(section;section;...;*;...),...</tt>)', |
'user:domain(section;section;...;*;...),...</tt>)', |
|
'question.email.text' => '<b>'.&mt('Custom Text for Resource Content Question Option in Feedback'). |
|
'</b>', |
'comment.email' => '<b>'.&mt('Feedback Addresses for Course Content Comments').'</b><br />'. |
'comment.email' => '<b>'.&mt('Feedback Addresses for Course Content Comments').'</b><br />'. |
'(<tt>user:domain,user:domain(section;section;...;*;...),...</tt>)', |
'(<tt>user:domain,user:domain(section;section;...;*;...),...</tt>)', |
|
'comment.email.text' => '<b>'.&mt('Custom Text for Course Content Option in Feedback'). |
|
'</b>', |
'policy.email' => '<b>'.&mt('Feedback Addresses for Course Policy').'</b>'. |
'policy.email' => '<b>'.&mt('Feedback Addresses for Course Policy').'</b>'. |
'<br />(<tt>user:domain,user:domain(section;section;...;*;...),...</tt>)', |
'<br />(<tt>user:domain,user:domain(section;section;...;*;...),...</tt>)', |
|
'policy.email.text' => '<b>'.&mt('Custom Text for Course Policy Option in Feedback'). |
|
'</b>', |
'hideemptyrows' => '<b>'.&mt('Hide Empty Rows in Spreadsheets').'</b><br />'. |
'hideemptyrows' => '<b>'.&mt('Hide Empty Rows in Spreadsheets').'</b><br />'. |
'('.&mt('"[_1]" for default hiding','<tt>yes</tt>').')', |
'('.&mt('"[_1]" for default hiding','<tt>yes</tt>').')', |
'pageseparators' => '<b>'.&mt('Visibly Separate Items on Pages').'</b><br />'. |
'pageseparators' => '<b>'.&mt('Visibly Separate Items on Pages').'</b><br />'. |
Line 2038 sub crsenv {
|
Line 2202 sub crsenv {
|
=> '<b>'.&mt('Allow limited HTML in discussion posts').'</b><br />'. |
=> '<b>'.&mt('Allow limited HTML in discussion posts').'</b><br />'. |
'('.&mt('Set value to "[_1]" to allow',"<tt>yes</tt>").')', |
'('.&mt('Set value to "[_1]" to allow',"<tt>yes</tt>").')', |
'allow_discussion_post_editing' |
'allow_discussion_post_editing' |
=> '<b>'.&mt('Allow users to edit/delete their own discussion posts').'</b><br />'. |
=> '<b>'.&mt('Allow users with specified roles to edit/delete their own discussion posts').'</b><br />"<tt>st</tt>": '. |
'('.&mt('Set value to "[_1]" to allow',"<tt>yes</tt>").')', |
&mt('student').', "<tt>ta</tt>": '. |
|
'TA, "<tt>in</tt>": '. |
|
&mt('instructor').'; (<tt>'.&mt('role:section,role:section,..., e.g., st:001,st:002,in,cc would permit students in sections 001 and 002 and instructors in any section, and course coordinators to edit their own posts.').'</tt>)<br />'. |
|
'('.&mt('or set value to "[_1]" to allow all roles',"<tt>yes</tt>").')', |
'rndseed' |
'rndseed' |
=> '<b>'.&mt('Randomization algorithm used').'</b> <br />'. |
=> '<b>'.&mt('Randomization algorithm used').'</b> <br />'. |
'<font color="red">'.&mt('Modifying this will make problems').' '. |
'<span class="LC_error">'.&mt('Modifying this will make problems').' '. |
&mt('have different numbers and answers').'</font>', |
&mt('have different numbers and answers').'</span>', |
'receiptalg' |
'receiptalg' |
=> '<b>'.&mt('Receipt algorithm used').'</b> <br />'. |
=> '<b>'.&mt('Receipt algorithm used').'</b> <br />'. |
&mt('This controls how receipt numbers are generated.'), |
&mt('This controls how receipt numbers are generated.'), |
'suppress_tries' |
'suppress_tries' |
=> '<b>'.&mt('Suppress number of tries in printing').'</b>('. |
=> '<b>'.&mt('Suppress number of tries in printing').'</b><br />'. |
&mt('yes if supress').')', |
' ('.&mt('"[_1]" to suppress, anything else to not suppress','<tt>yes</tt>').')', |
'problem_stream_switch' |
'problem_stream_switch' |
=> '<b>'.&mt('Allow problems to be split over pages').'</b><br />'. |
=> '<b>'.&mt('Allow problems to be split over pages').'</b><br />'. |
' ('.&mt('"[_1]" if allowed, anything else if not','<tt>yes</tt>').')', |
' ('.&mt('"[_1]" if allowed, anything else if not','<tt>yes</tt>').')', |
Line 2058 sub crsenv {
|
Line 2225 sub crsenv {
|
' ('.&mt('supported types').': Letter [8 1/2x11 in], Legal [8 1/2x14 in],'. |
' ('.&mt('supported types').': Letter [8 1/2x11 in], Legal [8 1/2x14 in],'. |
' Tabloid [11x17 in], Executive [7 1/2x10 in], A2 [420x594 mm],'. |
' Tabloid [11x17 in], Executive [7 1/2x10 in], A2 [420x594 mm],'. |
' A3 [297x420 mm], A4 [210x297 mm], A5 [148x210 mm], A6 [105x148 mm])', |
' A3 [297x420 mm], A4 [210x297 mm], A5 [148x210 mm], A6 [105x148 mm])', |
|
'print_header_format' |
|
=> '<b>Print header format; substitutions</b>: %n student name %c course id %a assignment note, numbers after the % limit the field size', |
'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>)', |
Line 2069 sub crsenv {
|
Line 2238 sub crsenv {
|
'disable_receipt_display' |
'disable_receipt_display' |
=> '<b>'.&mt('Disable display of problem receipts').'</b><br />'. |
=> '<b>'.&mt('Disable display of problem receipts').'</b><br />'. |
' ('.&mt('"[_1]" to disable, anything else if not','<tt>yes</tt>').')', |
' ('.&mt('"[_1]" to disable, anything else if not','<tt>yes</tt>').')', |
|
'task_messages' |
|
=> '<b>'.&mt('Send message to student when clicking Done on Tasks').'</b><br /> ('.&mt('[_1] to send a message only to student, [_2] to send message to student and add record to user information page for instructors. Leave blank to disable.','<tt>only_student</tt>','<tt>student_and_user_notes_screen</tt>').')', |
'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' |
'disableexampointprint' |
=> '<b>'.&mt('Disable automatically printing point values onto exams.').'</b><br />'. |
=> '<b>'.&mt('Disable automatically printing point values onto exams.').'</b><br />'. |
' ('.&mt('"[_1]" to disable, anything else if not','<tt>yes</tt>').')', |
' ('.&mt('"[_1]" to disable, anything else if not','<tt>yes</tt>').')', |
|
'externalsyllabus' |
|
=> '<b>'.&mt('URL of Syllabus (not using internal handler)').'</b>', |
'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>', |
|
|
|
'texengine' |
|
=> '<b>'.&mt('Force all students in the course to use a specific math rendering engine.').'</b><br />'.&mt('(Valid options are [_1].)','"tth", "jsMath", "mimetex"').'</b>', |
); |
); |
my @Display_Order = ('url','description','courseid','cloners','grading', |
my @Display_Order = ('url','description','courseid','cloners','grading', |
|
'externalsyllabus', |
'default_xml_style','pageseparators', |
'default_xml_style','pageseparators', |
'question.email','comment.email','policy.email', |
'question.email','question.email.text','comment.email','comment.email.text','policy.email','policy.email.text', |
'student_classlist_view', |
'student_classlist_view', |
'plc.roles.denied','plc.users.denied', |
'plc.roles.denied','plc.users.denied', |
'pch.roles.denied','pch.users.denied', |
'pch.roles.denied','pch.users.denied', |
Line 2093 sub crsenv {
|
Line 2270 sub crsenv {
|
'problem_stream_switch', |
'problem_stream_switch', |
'suppress_tries', |
'suppress_tries', |
'default_paper_size', |
'default_paper_size', |
|
'print_header_format', |
'disable_receipt_display', |
'disable_receipt_display', |
'spreadsheet_default_classcalc', |
'spreadsheet_default_classcalc', |
'spreadsheet_default_studentcalc', |
'spreadsheet_default_studentcalc', |
Line 2101 sub crsenv {
|
Line 2279 sub crsenv {
|
'default_enrollment_start_date', |
'default_enrollment_start_date', |
'default_enrollment_end_date', |
'default_enrollment_end_date', |
'tthoptions', |
'tthoptions', |
|
'texengine', |
'disablesigfigs', |
'disablesigfigs', |
'disableexampointprint' |
'disableexampointprint', |
|
'task_messages' |
); |
); |
foreach my $parameter (sort(keys(%values))) { |
foreach my $parameter (sort(keys(%values))) { |
unless (($parameter =~ m/^internal\./)||($parameter =~ m/^metadata\./)) { |
unless (($parameter =~ m/^internal\./)||($parameter =~ m/^metadata\./)) { |
Line 2112 sub crsenv {
|
Line 2292 sub crsenv {
|
} |
} |
} |
} |
} |
} |
|
|
foreach my $parameter (@Display_Order) { |
foreach my $parameter (@Display_Order) { |
my $description = $descriptions{$parameter}; |
my $description = $descriptions{$parameter}; |
# onchange is javascript to automatically check the 'Set' button. |
# onchange is javascript to automatically check the 'Set' button. |
my $onchange = 'onFocus="javascript:window.document.forms'. |
my $onchange = 'onFocus="javascript:window.document.forms'. |
"['envform'].elements['".$parameter."_setparmval']". |
"['envform'].elements['".$parameter."_setparmval']". |
'.checked=true;"'; |
'.checked=true;"'; |
$output .= '<tr><td>'.$description.'</td>'; |
$output .= &Apache::loncommon::start_data_table_row(). |
|
'<td>'.$description.'</td>'; |
if ($parameter =~ /^default_enrollment_(start|end)_date$/) { |
if ($parameter =~ /^default_enrollment_(start|end)_date$/) { |
$output .= '<td>'. |
$output .= '<td>'. |
&Apache::lonhtmlcommon::date_setter('envform', |
&Apache::lonhtmlcommon::date_setter('envform', |
Line 2135 sub crsenv {
|
Line 2317 sub crsenv {
|
$output .= '<td>'. |
$output .= '<td>'. |
&Apache::lonhtmlcommon::checkbox($parameter.'_setparmval'). |
&Apache::lonhtmlcommon::checkbox($parameter.'_setparmval'). |
'</td>'; |
'</td>'; |
$output .= "</tr>\n"; |
$output .= &Apache::loncommon::end_data_table_row()."\n"; |
} |
} |
my $onchange = 'onFocus="javascript:window.document.forms'. |
my $onchange = 'onFocus="javascript:window.document.forms'. |
'[\'envform\'].elements[\'newp_setparmval\']'. |
'[\'envform\'].elements[\'newp_setparmval\']'. |
'.checked=true;"'; |
'.checked=true;"'; |
$output.='<tr><td><i>'.&mt('Create New Environment Variable').'</i><br />'. |
$output.=&Apache::loncommon::start_data_table_row(). |
|
'<td><i>'.&mt('Create New Environment Variable').'</i><br />'. |
'<input type="text" size=40 name="newp_name" '. |
'<input type="text" size=40 name="newp_name" '. |
$onchange.' /></td><td>'. |
$onchange.' /></td><td>'. |
'<input type="text" size=40 name="newp_value" '. |
'<input type="text" size=40 name="newp_value" '. |
$onchange.' /></td><td>'. |
$onchange.' /></td><td>'. |
'<input type="checkbox" name="newp_setparmval" /></td></tr>'; |
'<input type="checkbox" name="newp_setparmval" /></td>'. |
|
&Apache::loncommon::end_data_table_row()."\n"; |
} |
} |
my %lt=&Apache::lonlocal::texthash( |
my %lt=&Apache::lonlocal::texthash( |
'par' => 'Parameter', |
'par' => 'Parameter', |
Line 2157 sub crsenv {
|
Line 2341 sub crsenv {
|
my $Parameter=&mt('Parameter'); |
my $Parameter=&mt('Parameter'); |
my $Value=&mt('Value'); |
my $Value=&mt('Value'); |
my $Set=&mt('Set'); |
my $Set=&mt('Set'); |
my $browse_js=&Apache::loncommon::browser_and_searcher_javascript('parmset'); |
my $browse_js= |
my $html=&Apache::lonxml::xmlbegin(); |
'<script type="text/javascript" language="Javascript">'. |
$r->print(<<ENDenv); |
&Apache::loncommon::browser_and_searcher_javascript('parmset'). |
$html |
'</script>'; |
<head> |
|
<script type="text/javascript" language="Javascript" > |
my $start_page = |
$browse_js |
&Apache::loncommon::start_page('Set Course Environment', |
</script> |
$browse_js); |
<title>LON-CAPA Course Environment</title> |
my $end_page = |
</head> |
&Apache::loncommon::end_page(); |
$bodytag |
my $end_table=&Apache::loncommon::end_data_table(); |
|
$r->print(<<ENDENV); |
|
$start_page |
$breadcrumbs |
$breadcrumbs |
<form method="post" action="/adm/parmset?action=crsenv" name="envform"> |
<form method="post" action="/adm/parmset?action=crsenv" name="envform"> |
$setoutput |
$setoutput |
<p> |
$start_table |
<table border=2> |
$start_header_row |
<tr><th>$lt{'par'}</th><th>$lt{'val'}</th><th>$lt{'set'}?</th></tr> |
<th>$lt{'par'}</th><th>$lt{'val'}</th><th>$lt{'set'}?</th> |
|
$end_header_row |
$output |
$output |
</table> |
$end_table |
<input type="submit" name="crsenv" value="$lt{'sce'}"> |
<input type="submit" name="crsenv" value="$lt{'sce'}"> |
</form> |
</form> |
</body> |
$end_page |
</html> |
ENDENV |
ENDenv |
|
} |
} |
################################################## |
################################################## |
# Overview mode |
# Overview mode |
Line 2192 sub tablestart {
|
Line 2378 sub tablestart {
|
return ''; |
return ''; |
} else { |
} else { |
$tableopen=1; |
$tableopen=1; |
return '<table border="2"><tr><th>'.&mt('Parameter').'</th><th>'. |
return &Apache::loncommon::start_data_table().'<tr><th>'.&mt('Parameter').'</th><th>'. |
&mt('Delete').'</th><th>'.&mt('Set to ...').'</th></tr>'; |
&mt('Delete').'</th><th>'.&mt('Set to ...').'</th></tr>'; |
} |
} |
} |
} |
Line 2200 sub tablestart {
|
Line 2386 sub tablestart {
|
sub tableend { |
sub tableend { |
if ($tableopen) { |
if ($tableopen) { |
$tableopen=0; |
$tableopen=0; |
return '</table>'; |
return &Apache::loncommon::end_data_table(); |
} else { |
} else { |
return''; |
return''; |
} |
} |
Line 2214 sub readdata {
|
Line 2400 sub readdata {
|
|
|
my $classlist=&Apache::loncoursedata::get_classlist(); |
my $classlist=&Apache::loncoursedata::get_classlist(); |
foreach (keys %$classlist) { |
foreach (keys %$classlist) { |
# the following undefs are for 'domain', and 'username' respectively. |
if ($_=~/^($match_username)\:($match_domain)$/) { |
if ($_=~/^(\w+)\:(\w+)$/) { |
|
my ($tuname,$tudom)=($1,$2); |
my ($tuname,$tudom)=($1,$2); |
my $useropt=&Apache::lonnet::get_userresdata($tuname,$tudom); |
my $useropt=&Apache::lonnet::get_userresdata($tuname,$tudom); |
foreach my $userkey (keys %{$useropt}) { |
foreach my $userkey (keys %{$useropt}) { |
Line 2259 sub storedata {
|
Line 2444 sub storedata {
|
if (&Apache::lonnet::put('resourcedata',{$tkey=>$data, |
if (&Apache::lonnet::put('resourcedata',{$tkey=>$data, |
$tkey.'.type' => $typeof}, |
$tkey.'.type' => $typeof}, |
$tudom,$tuname) eq 'ok') { |
$tudom,$tuname) eq 'ok') { |
$r->print('<br />'.&mt('Stored modified parameter for').' '. |
&log_parmset({$tkey=>$data,$tkey.'.type' => $typeof},0,$tuname,$tudom); |
|
$r->print('<br />'.&mt('Saved modified parameter for').' '. |
&Apache::loncommon::plainname($tuname,$tudom)); |
&Apache::loncommon::plainname($tuname,$tudom)); |
} else { |
} else { |
$r->print('<h2><font color="red">'. |
$r->print('<div class="LC_error">'. |
&mt('Error storing parameters').'</font></h2>'); |
&mt('Error saving parameters').'</div>'); |
} |
} |
&Apache::lonnet::devalidateuserresdata($tuname,$tudom); |
&Apache::lonnet::devalidateuserresdata($tuname,$tudom); |
} else { |
} else { |
Line 2274 sub storedata {
|
Line 2460 sub storedata {
|
} elsif ($cmd eq 'del') { |
} elsif ($cmd eq 'del') { |
if ($tuname) { |
if ($tuname) { |
if (&Apache::lonnet::del('resourcedata',[$tkey],$tudom,$tuname) eq 'ok') { |
if (&Apache::lonnet::del('resourcedata',[$tkey],$tudom,$tuname) eq 'ok') { |
|
&log_parmset({$tkey=>''},1,$tuname,$tudom); |
$r->print('<br />'.&mt('Deleted parameter for').' '.&Apache::loncommon::plainname($tuname,$tudom)); |
$r->print('<br />'.&mt('Deleted parameter for').' '.&Apache::loncommon::plainname($tuname,$tudom)); |
} else { |
} else { |
$r->print('<h2><font color="red">'. |
$r->print('<div class="LC_error">'. |
&mt('Error deleting parameters').'</font></h2>'); |
&mt('Error deleting parameters').'</div>'); |
} |
} |
&Apache::lonnet::devalidateuserresdata($tuname,$tudom); |
&Apache::lonnet::devalidateuserresdata($tuname,$tudom); |
} else { |
} else { |
push (@deldata,$thiskey); |
push (@deldata,$thiskey,$thiskey.'.type'); |
} |
} |
} 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{$_}); |
Line 2291 sub storedata {
|
Line 2478 sub storedata {
|
if (&Apache::lonnet::put('resourcedata',{$tkey=>$data, |
if (&Apache::lonnet::put('resourcedata',{$tkey=>$data, |
$tkey.'.type' => $typeof}, |
$tkey.'.type' => $typeof}, |
$tudom,$tuname) eq 'ok') { |
$tudom,$tuname) eq 'ok') { |
$r->print('<br />'.&mt('Stored modified date for').' '.&Apache::loncommon::plainname($tuname,$tudom)); |
&log_parmset({$tkey=>$data,$tkey.'.type' => $typeof},0,$tuname,$tudom); |
|
$r->print('<br />'.&mt('Saved modified date for').' '.&Apache::loncommon::plainname($tuname,$tudom)); |
} else { |
} else { |
$r->print('<h2><font color="red">'. |
$r->print('<div class="LC_error">'. |
&mt('Error storing parameters').'</font></h2>'); |
&mt('Error saving parameters').'</div>'); |
} |
} |
&Apache::lonnet::devalidateuserresdata($tuname,$tudom); |
&Apache::lonnet::devalidateuserresdata($tuname,$tudom); |
} else { |
} else { |
Line 2311 sub storedata {
|
Line 2499 sub storedata {
|
my $putentries=$#newdatakeys+1; |
my $putentries=$#newdatakeys+1; |
if ($delentries) { |
if ($delentries) { |
if (&Apache::lonnet::del('resourcedata',\@deldata,$dom,$crs) eq 'ok') { |
if (&Apache::lonnet::del('resourcedata',\@deldata,$dom,$crs) eq 'ok') { |
|
my %loghash=map { $_ => '' } @deldata; |
|
&log_parmset(\%loghash,1); |
$r->print('<h2>'.&mt('Deleted [_1] parameter(s)</h2>',$delentries)); |
$r->print('<h2>'.&mt('Deleted [_1] parameter(s)</h2>',$delentries)); |
} else { |
} else { |
$r->print('<h2><font color="red">'. |
$r->print('<div class="LC_error">'. |
&mt('Error deleting parameters').'</font></h2>'); |
&mt('Error deleting parameters').'</div>'); |
} |
} |
&Apache::lonnet::devalidatecourseresdata($crs,$dom); |
&Apache::lonnet::devalidatecourseresdata($crs,$dom); |
} |
} |
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('<h3>'.&mt('Stored [_1] parameter(s)',$putentries/2).'</h3>'); |
&log_parmset(\%newdata,0); |
|
$r->print('<h3>'.&mt('Saved [_1] parameter(s)',$putentries/2).'</h3>'); |
} else { |
} else { |
$r->print('<h2><font color="red">'. |
$r->print('<div class="LC_error">'. |
&mt('Error storing parameters').'</font></h2>'); |
&mt('Error saving parameters').'</div>'); |
} |
} |
&Apache::lonnet::devalidatecourseresdata($crs,$dom); |
&Apache::lonnet::devalidatecourseresdata($crs,$dom); |
} |
} |
Line 2331 sub storedata {
|
Line 2522 sub storedata {
|
|
|
sub extractuser { |
sub extractuser { |
my $key=shift; |
my $key=shift; |
return ($key=~/^$env{'request.course.id'}.\[useropt\:(\w+)\:(\w+)\]\./); |
return ($key=~/^$env{'request.course.id'}.\[useropt\:($match_username)\:($match_domain)\]\./); |
} |
} |
|
|
sub listdata { |
sub listdata { |
Line 2389 sub listdata {
|
Line 2580 sub listdata {
|
my $section=&mt('All Students'); |
my $section=&mt('All Students'); |
if ($middle=~/^\[(.*)\]/) { |
if ($middle=~/^\[(.*)\]/) { |
my $issection=$1; |
my $issection=$1; |
if ($issection=~/^useropt\:(\w+)\:(\w+)/) { |
if ($issection=~/^useropt\:($match_username)\:($match_domain)/) { |
$section=&mt('User').": ".&Apache::loncommon::plainname($1,$2); |
$section=&mt('User').": ".&Apache::loncommon::plainname($1,$2); |
} else { |
} else { |
$section=&mt('Group/Section').': '.$issection; |
$section=&mt('Group/Section').': '.$issection; |
Line 2398 sub listdata {
|
Line 2589 sub listdata {
|
} |
} |
$middle=~s/\.+$//; |
$middle=~s/\.+$//; |
$middle=~s/^\.+//; |
$middle=~s/^\.+//; |
my $realm='<font color="red">'.&mt('All Resources').'</font>'; |
my $realm='<span class="LC_parm_scope_all">'.&mt('All Resources').'</span>'; |
if ($middle=~/^(.+)\_\_\_\(all\)$/) { |
if ($middle=~/^(.+)\_\_\_\(all\)$/) { |
$realm='<font color="green">'.&mt('Folder/Map').': '.&Apache::lonnet::gettitle($1).' <br /><font color="#aaaaaa" size="-2">('.$1.')</font></font>'; |
$realm='<span class="LC_parm_scope_folder">'.&mt('Folder/Map').': '.&Apache::lonnet::gettitle($1).' <br /><span class="LC_parm_folder">('.$1.')</span></span>'; |
} elsif ($middle) { |
} elsif ($middle) { |
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='<span class="LC_parm_scope_resource">'.&mt('Resource').': '.&Apache::lonnet::gettitle($middle).' <br /><span class="LC_parm_symb">('.$url.' in '.$map.' id: '.$id.')</span></span>'; |
} |
} |
if ($sortorder eq 'realmstudent') { |
if ($sortorder eq 'realmstudent') { |
if ($realm ne $oldrealm) { |
if ($realm ne $oldrealm) { |
Line 2430 sub listdata {
|
Line 2621 sub listdata {
|
} |
} |
if ($part ne $oldpart) { |
if ($part ne $oldpart) { |
$r->print(&tableend(). |
$r->print(&tableend(). |
"\n<font color='blue'>".&mt('Part').": $part</font>"); |
"\n<span class=\"LC_parm_part\">".&mt('Part').": $part</span>"); |
$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(). |
':</b></td><td><input type="checkbox" name="del_'. |
&Apache::loncommon::start_data_table_row(). |
|
'<td><b>'.&standard_parameter_names($name). |
|
'</b></td><td><input type="checkbox" name="del_'. |
$thiskey.'" /></td><td>'); |
$thiskey.'" /></td><td>'); |
$foundkeys++; |
$foundkeys++; |
if (&isdateparm($thistype)) { |
if (&isdateparm($thistype)) { |
Line 2456 sub listdata {
|
Line 2640 sub listdata {
|
&Apache::lonhtmlcommon::date_setter('parmform', |
&Apache::lonhtmlcommon::date_setter('parmform', |
$jskey, |
$jskey, |
$$resourcedata{$thiskey}, |
$$resourcedata{$thiskey}, |
'',1,'','',$hour,$min,$sec). |
'',1,'',''). |
'<input type="hidden" name="datepointer_'.$thiskey.'" value="'.$jskey.'" />' |
'<input type="hidden" name="datepointer_'.$thiskey.'" value="'.$jskey.'" />'. |
|
&date_sanity_info($$resourcedata{$thiskey}) |
); |
); |
} elsif ($thistype eq 'string_yesno') { |
} elsif ($thistype eq 'string_yesno') { |
my $showval; |
my $showval; |
if (defined($$resourcedata{$thiskey})) { |
if (defined($$resourcedata{$thiskey})) { |
$showval=$$resourcedata{$thiskey}; |
$showval=$$resourcedata{$thiskey}; |
} else { |
|
$showval=$val; |
|
} |
} |
$r->print('<label><input type="radio" name="set_'.$thiskey. |
$r->print('<label><input type="radio" name="set_'.$thiskey. |
'" value="yes"'); |
'" value="yes"'); |
Line 2482 sub listdata {
|
Line 2665 sub listdata {
|
my $showval; |
my $showval; |
if (defined($$resourcedata{$thiskey})) { |
if (defined($$resourcedata{$thiskey})) { |
$showval=$$resourcedata{$thiskey}; |
$showval=$$resourcedata{$thiskey}; |
} else { |
|
$showval=$val; |
|
} |
} |
$r->print('<input type="text" name="set_'.$thiskey.'" value="'. |
$r->print('<input type="text" name="set_'.$thiskey.'" value="'. |
$showval.'">'); |
$showval.'">'); |
} |
} |
$r->print('<input type="hidden" name="typeof_'.$thiskey.'" value="'. |
$r->print('<input type="hidden" name="typeof_'.$thiskey.'" value="'. |
$thistype.'">'); |
$thistype.'">'); |
$r->print('</td></tr>'); |
$r->print('</td>'.&Apache::loncommon::end_data_table_row()); |
} |
} |
} |
} |
return $foundkeys; |
return $foundkeys; |
} |
} |
|
|
sub newoverview { |
sub newoverview { |
my $r=shift; |
my ($r) = @_; |
my $bodytag=&Apache::loncommon::bodytag('Set Parameters'); |
|
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 $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs(undef,'Overview'); |
my $start_page = &Apache::loncommon::start_page('Set Parameters'); |
my $html=&Apache::lonxml::xmlbegin(); |
my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs('Overview'); |
$r->print(<<ENDOVER); |
$r->print(<<ENDOVER); |
$html |
$start_page |
<head> |
|
<title>LON-CAPA Parameters</title> |
|
</head> |
|
$bodytag |
|
$breadcrumbs |
$breadcrumbs |
<form method="post" action="/adm/parmset?action=newoverview" name="parmform"> |
<form method="post" action="/adm/parmset?action=newoverview" name="parmform"> |
ENDOVER |
ENDOVER |
Line 2564 ENDOVER
|
Line 2741 ENDOVER
|
|
|
# Menu to select levels, etc |
# Menu to select levels, etc |
|
|
$r->print('<table border="1"><tr><td>'); |
$r->print('<table id="LC_parm_overview_scope"> |
|
<tr><td class="LC_parm_overview_level_menu">'); |
&levelmenu($r,\%alllevs,$parmlev); |
&levelmenu($r,\%alllevs,$parmlev); |
if ($parmlev ne 'general') { |
if ($parmlev ne 'general') { |
$r->print('<td>'); |
$r->print('<td class="LC_parm_overview_map_menu">'); |
&mapmenu($r,\%allmaps,$pschp,\%maptitles); |
&mapmenu($r,\%allmaps,$pschp,\%maptitles); |
$r->print('</td>'); |
$r->print('</td>'); |
} |
} |
$r->print('</td></tr></table>'); |
$r->print('</td></tr></table>'); |
|
|
$r->print('<table border="1"><tr><td>'); |
$r->print('<table id="LC_parm_overview_controls"> |
|
<tr><td class="LC_parm_overview_parm_selectors">'); |
&parmmenu($r,\%allparms,\@pscat,\%keyorder); |
&parmmenu($r,\%allparms,\@pscat,\%keyorder); |
$r->print('</td><td><table border="0" cellspacing="0" cellpadding="0">'. |
$r->print('</td><td class="LC_parm_overview_restrictions"> |
'<tr><td>'.&mt('Parts').'</td><td></td><td>'.&mt('Section(s)'). |
<table class="LC_parm_overview_restrictions">'. |
'</td><td></td><td>'.&mt('Group(s)').'</td></tr><tr><td>'); |
'<tr><th>'.&mt('Parts').'</th><th>'.&mt('Section(s)'). |
|
'</th><th>'.&mt('Group(s)').'</th></tr><tr><td>'); |
&partmenu($r,\%allparts,\@psprt); |
&partmenu($r,\%allparts,\@psprt); |
$r->print('</td><td> </td><td>'); |
$r->print('</td><td>'); |
§ionmenu($r,\@selected_sections); |
§ionmenu($r,\@selected_sections); |
$r->print('</td><td> </td><td>'); |
$r->print('</td><td>'); |
&groupmenu($r,\@selected_groups); |
&groupmenu($r,\@selected_groups); |
$r->print('</td></tr></table>'); |
$r->print('</td></tr></table>'); |
$r->print('</td></tr></table>'); |
$r->print('</td></tr></table>'); |
Line 2615 ENDOVER
|
Line 2795 ENDOVER
|
&listdata($r,$resourcedata,$listdata,$sortorder); |
&listdata($r,$resourcedata,$listdata,$sortorder); |
} |
} |
$r->print(&tableend(). |
$r->print(&tableend(). |
((($env{'form.store'}) || ($env{'form.dis'}))?'<p><input type="submit" name="store" value="'.&mt('Store').'" /></p>':''). |
((($env{'form.store'}) || ($env{'form.dis'}))?'<p><input type="submit" name="store" value="'.&mt('Save').'" /></p>':''). |
'</form></body></html>'); |
'</form>'.&Apache::loncommon::end_page()); |
} |
} |
|
|
sub secgroup_lister { |
sub secgroup_lister { |
Line 2655 sub secgroup_lister {
|
Line 2835 sub secgroup_lister {
|
} |
} |
|
|
sub overview { |
sub overview { |
my $r=shift; |
my ($r) = @_; |
my $bodytag=&Apache::loncommon::bodytag('Modify Parameters'); |
|
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 $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs(undef,'Overview'); |
|
my $html=&Apache::lonxml::xmlbegin(); |
my $start_page=&Apache::loncommon::start_page('Modify Parameters'); |
|
my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs('Overview'); |
$r->print(<<ENDOVER); |
$r->print(<<ENDOVER); |
$html |
$start_page |
<head> |
|
<title>LON-CAPA Parameters</title> |
|
</head> |
|
$bodytag |
|
$breadcrumbs |
$breadcrumbs |
<form method="post" action="/adm/parmset?action=setoverview" name="parmform"> |
<form method="post" action="/adm/parmset?action=setoverview" name="parmform"> |
ENDOVER |
ENDOVER |
Line 2688 ENDOVER
|
Line 2864 ENDOVER
|
my $foundkeys=&listdata($r,$resourcedata,$resourcedata,$sortorder); |
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 parameters.')).'</p></form></body></html>'); |
($foundkeys?'<input type="submit" value="'.&mt('Modify Parameters').'" />':&mt('There are no parameters.')).'</p></form>'. |
|
&Apache::loncommon::end_page()); |
|
} |
|
|
|
sub clean_parameters { |
|
my ($r) = @_; |
|
my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'}; |
|
my $crs = $env{'course.'.$env{'request.course.id'}.'.num'}; |
|
|
|
my $start_page=&Apache::loncommon::start_page('Clean Parameters'); |
|
my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs('Clean'); |
|
$r->print(<<ENDOVER); |
|
$start_page |
|
$breadcrumbs |
|
<form method="post" action="/adm/parmset?action=cleanparameters" name="parmform"> |
|
ENDOVER |
|
# Store modified |
|
|
|
&storedata($r,$crs,$dom); |
|
|
|
# Read modified data |
|
|
|
my $resourcedata=&readdata($crs,$dom); |
|
|
|
# List data |
|
|
|
$r->print('<h3>'. |
|
&mt('These parameters refer to resources that do not exist.'). |
|
'</h3>'. |
|
'<input type="submit" value="'.&mt('Delete Checked Parameters').'" />'.'<br />'. |
|
'<br />'); |
|
$r->print(&Apache::loncommon::start_data_table(). |
|
'<tr>'. |
|
'<th>'.&mt('Delete').'</th>'. |
|
'<th>'.&mt('Parameter').'</th>'. |
|
'</tr>'); |
|
foreach my $thiskey (sort(keys(%{$resourcedata}))) { |
|
next if (!exists($resourcedata->{$thiskey.'.type'}) |
|
&& $thiskey=~/\.type$/); |
|
my %data = &parse_key($thiskey); |
|
if (exists($data{'realm_exists'}) |
|
&& !$data{'realm_exists'}) { |
|
$r->print(&Apache::loncommon::start_data_table_row(). |
|
'<tr>'. |
|
'<td><input type="checkbox" name="del_'.$thiskey.'" /></td>' ); |
|
|
|
$r->print('<td>'); |
|
my $display_value = $resourcedata->{$thiskey}; |
|
if (&isdateparm($resourcedata->{$thiskey.'.type'})) { |
|
$display_value = |
|
&Apache::lonlocal::locallocaltime($display_value); |
|
} |
|
$r->print(&mt('Parameter: "[_1]" with value: "[_2]"', |
|
&standard_parameter_names($data{'parameter_name'}), |
|
$resourcedata->{$thiskey})); |
|
$r->print('<br />'); |
|
if ($data{'scope_type'} eq 'all') { |
|
$r->print(&mt('All users')); |
|
} elsif ($data{'scope_type'} eq 'user') { |
|
$r->print(&mt('User: [_1]',join(':',@{$data{'scope'}}))); |
|
} elsif ($data{'scope_type'} eq 'section') { |
|
$r->print(&mt('Section: [_1]',$data{'scope'})); |
|
} elsif ($data{'scope_type'} eq 'group') { |
|
$r->print(&mt('Group: [_1]',$data{'scope'})); |
|
} |
|
$r->print('<br />'); |
|
if ($data{'realm_type'} eq 'all') { |
|
$r->print(&mt('All Resources')); |
|
} elsif ($data{'realm_type'} eq 'folder') { |
|
$r->print(&mt('Folder: [_1]'),$data{'realm'}); |
|
} elsif ($data{'realm_type'} eq 'symb') { |
|
my ($map,$resid,$url) = |
|
&Apache::lonnet::decode_symb($data{'realm'}); |
|
$r->print(&mt('Resource: [_1] <br /> with ID: [_2] <br /> in folder [_3]', |
|
$url,$resid,$map)); |
|
} |
|
$r->print(' <br /> '.&mt('Part: [_1]',$data{'parameter_part'})); |
|
$r->print('</td></tr>'); |
|
|
|
} |
|
} |
|
$r->print(&Apache::loncommon::end_data_table().'<p>'. |
|
'<input type="submit" value="'.&mt('Delete Checked Parameters').'" />'. |
|
'</p></form>'. |
|
&Apache::loncommon::end_page()); |
|
} |
|
|
|
sub parse_key { |
|
my ($key) = @_; |
|
my %data; |
|
my ($middle,$part,$name)= |
|
($key=~/^$env{'request.course.id'}\.(?:(.+)\.)*([\w\s]+)\.(\w+)$/); |
|
$data{'scope_type'} = 'all'; |
|
if ($middle=~/^\[(.*)\]/) { |
|
$data{'scope'} = $1; |
|
if ($data{'scope'}=~/^useropt\:($match_username)\:($match_domain)/) { |
|
$data{'scope_type'} = 'user'; |
|
$data{'scope'} = [$1,$2]; |
|
} else { |
|
#FIXME check for group scope |
|
$data{'scope_type'} = 'section'; |
|
} |
|
$middle=~s/^\[(.*)\]//; |
|
} |
|
$middle=~s/\.+$//; |
|
$middle=~s/^\.+//; |
|
$data{'realm_type'}='all'; |
|
if ($middle=~/^(.+)\_\_\_\(all\)$/) { |
|
$data{'realm'} = $1; |
|
$data{'realm_type'} = 'folder'; |
|
$data{'realm_title'} = &Apache::lonnet::gettitle($data{'realm'}); |
|
($data{'realm_exists'}) = &Apache::lonnet::is_on_map($data{'realm'}); |
|
&Apache::lonnet::logthis($1." siad ". $data{'realm_exists'} ); |
|
} elsif ($middle) { |
|
$data{'realm'} = $middle; |
|
$data{'realm_type'} = 'symb'; |
|
$data{'realm_title'} = &Apache::lonnet::gettitle($data{'realm'}); |
|
my ($map,$resid,$url) = &Apache::lonnet::decode_symb($data{'realm'}); |
|
$data{'realm_exists'} = &Apache::lonnet::symbverify($data{'realm'},$url); |
|
} |
|
|
|
$data{'parameter_part'} = $part; |
|
$data{'parameter_name'} = $name; |
|
|
|
return %data; |
} |
} |
|
|
################################################## |
################################################## |
################################################## |
################################################## |
|
|
=pod |
=pod |
|
|
=item check_cloners |
=item check_cloners |
Line 2837 Output html header for page
|
Line 3137 Output html header for page
|
################################################## |
################################################## |
################################################## |
################################################## |
sub header { |
sub header { |
my $html=&Apache::lonxml::xmlbegin(); |
return &Apache::loncommon::start_page('Parameter Manager'); |
my $bodytag=&Apache::loncommon::bodytag('Parameter Manager'); |
|
my $title = &mt('LON-CAPA Parameter Manager'); |
|
return(<<ENDHEAD); |
|
$html |
|
<head> |
|
<title>$title</title> |
|
</head> |
|
$bodytag |
|
ENDHEAD |
|
} |
} |
################################################## |
################################################## |
################################################## |
################################################## |
Line 2861 ENDMAINFORMHEAD
|
Line 3152 ENDMAINFORMHEAD
|
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 $vgr = &Apache::lonnet::allowed('vgr',$env{'request.course.id'}); |
my $vgr = &Apache::lonnet::allowed('vgr',$env{'request.course.id'}); |
|
my $mgr = &Apache::lonnet::allowed('mgr',$env{'request.course.id'}); |
|
|
my @menu = |
my @menu = |
( |
( { divider=>'Settings for Your Course', |
{ text => 'Set Course Environment Parameters', |
}, |
|
{ text => 'Set Course Environment', |
action => 'crsenv', |
action => 'crsenv', |
permission => $parm_permission, |
permission => $parm_permission, |
|
help => 'Course_Environment', |
}, |
}, |
{ text => 'Set Portfolio Metadata', |
{ text => 'Set Portfolio Metadata', |
action => 'setrestrictmeta', |
action => 'setrestrictmeta', |
permission => $parm_permission, |
permission => $parm_permission, |
}, |
}, |
{ text => 'Manange Course Slots', |
{ text => 'Manage Course Slots', |
url => '/adm/slotrequest?command=showslots', |
url => '/adm/slotrequest?command=showslots', |
permission => $vgr, |
permission => $vgr, |
}, |
}, |
{ divider => 1, |
{ text => 'Reset Student Access Times', |
|
url => '/adm/helper/resettimes.helper', |
|
permission => $mgr, |
|
}, |
|
|
|
{ text => 'Set Parameter Setting Default Actions', |
|
action => 'setdefaults', |
|
permission => $parm_permission, |
|
}, |
|
{ divider => 'New and Existing Parameter Settings for Your Resources', |
}, |
}, |
{ text => 'Set/Modify Resource Parameters - Helper Mode', |
{ text => 'Set/Modify Resource Parameters - Helper Mode', |
url => '/adm/helper/parameter.helper', |
url => '/adm/helper/parameter.helper', |
permission => $parm_permission, |
permission => $parm_permission, |
|
help => 'Parameter_Helper', |
}, |
}, |
{ text => 'Modify Resource Parameters - Overview Mode', |
{ text => 'Set/Modify Resource Parameters - Overview Mode', |
action => 'setoverview', |
|
permission => $parm_permission, |
|
}, |
|
{ text => 'Set Resource Parameters - Overview Mode', |
|
action => 'newoverview', |
action => 'newoverview', |
permission => $parm_permission, |
permission => $parm_permission, |
|
help => 'Parameter_Overview', |
}, |
}, |
{ text => 'Set/Modify Resource Parameters - Table Mode', |
{ text => 'Set/Modify Resource Parameters - Table Mode', |
action => 'settable', |
action => 'settable', |
permission => $parm_permission, |
permission => $parm_permission, |
help => 'Cascading_Parameters', |
help => 'Table_Mode', |
}, |
}, |
{ text => 'Set Parameter Setting Default Actions', |
{ divider => 'Existing Parameter Settings for Your Resources', |
action => 'setdefaults', |
}, |
|
{ text => 'Modify Resource Parameters - Overview Mode', |
|
action => 'setoverview', |
|
permission => $parm_permission, |
|
help => 'Parameter_Overview', |
|
}, |
|
{ text => 'Parameter Change Log and Course Blog Posting/User Notification', |
|
action => 'parameterchangelog', |
permission => $parm_permission, |
permission => $parm_permission, |
}, |
}, |
); |
); |
my $menu_html = ''; |
my $menu_html = ''; |
foreach my $menu_item (@menu) { |
foreach my $menu_item (@menu) { |
if ($menu_item->{'divider'}) { |
if ($menu_item->{'divider'}) { |
$menu_html .= '<hr />'; |
$menu_html .= '<h3>'.&mt($menu_item->{'divider'}).'</h3>'; |
next; |
next; |
} |
} |
next if (! $menu_item->{'permission'}); |
next if (! $menu_item->{'permission'}); |
$menu_html.='<p>'; |
$menu_html.='<p>'; |
$menu_html.='<font size="+1">'; |
$menu_html.='<span class="LC_parm_menu_item">'; |
if (exists($menu_item->{'url'})) { |
if (exists($menu_item->{'url'})) { |
$menu_html.=qq{<a href="$menu_item->{'url'}">}; |
$menu_html.=qq{<a href="$menu_item->{'url'}">}; |
} else { |
} else { |
$menu_html.= |
$menu_html.= |
qq{<a href="/adm/parmset?action=$menu_item->{'action'}">}; |
qq{<a href="/adm/parmset?action=$menu_item->{'action'}">}; |
} |
} |
$menu_html.= &mt($menu_item->{'text'}).'</a></font>'; |
$menu_html.= &mt($menu_item->{'text'}).'</a></span>'; |
if (exists($menu_item->{'help'})) { |
if (exists($menu_item->{'help'})) { |
$menu_html.= |
$menu_html.= |
&Apache::loncommon::help_open_topic($menu_item->{'help'}); |
&Apache::loncommon::help_open_topic($menu_item->{'help'}); |
Line 2927 ENDMAINFORMHEAD
|
Line 3235 ENDMAINFORMHEAD
|
} |
} |
### Set portfolio metadata |
### Set portfolio metadata |
sub output_row { |
sub output_row { |
my ($r, $field_name, $field_text) = @_; |
my ($r, $field_name, $field_text, $added_flag) = @_; |
my $output; |
my $output; |
my $options=$env{'course.'.$env{'request.course.id'}.'.metadata.'.$field_name.'.options'}; |
my $options=$env{'course.'.$env{'request.course.id'}.'.metadata.'.$field_name.'.options'}; |
my $values=$env{'course.'.$env{'request.course.id'}.'.metadata.'.$field_name.'.values'}; |
my $values=$env{'course.'.$env{'request.course.id'}.'.metadata.'.$field_name.'.values'}; |
unless (defined($options)) { |
if (!defined($options)) { |
$options = 'active,stuadd'; |
$options = 'active,stuadd'; |
$values = ''; |
$values = ''; |
} |
} |
$output.='<strong>'.$field_text.':</strong>'; |
if (!($options =~ /deleted/)) { |
$output.='<input name="'.$field_name.'_values" type="text" value="'.$values.'" size="80" /><br />'; |
my @options= ( ['active', 'Show to student'], |
|
['stuadd', 'Provide text area for students to type catalog information'], |
my @options= ( ['active', 'Show to student'], |
['choices','Provide choices for students to select from']); |
['onlyone','Student may select only one choice'], |
# ['onlyone','Student may select only one choice']); |
['stuadd', 'Student may type choices']); |
if ($added_flag) { |
foreach my $opt (@options) { |
push @options,['deleted', 'Delete Metadata Field']; |
my $checked = ($options =~ m/$opt->[0]/) ? ' checked="checked" ' : '' ; |
} |
$output.=(' 'x5).'<label><input type="checkbox" name="'. |
$output = &Apache::loncommon::start_data_table_row(); |
$field_name.'_'.$opt->[0].'" value="yes"'.$checked.' />'. |
$output .= '<td><span class="LC_metadata"><strong>'.$field_text.':</strong></span></td>'; |
&mt($opt->[1]).'</label> <br />'; |
$output .= &Apache::loncommon::end_data_table_row(); |
|
foreach my $opt (@options) { |
|
my $checked = ($options =~ m/$opt->[0]/) ? ' checked="checked" ' : '' ; |
|
$output .= &Apache::loncommon::continue_data_table_row(); |
|
$output .= '<td>'.(' ' x 5).'<span class="LC_metadata"><label> |
|
<input type="checkbox" name="'. |
|
$field_name.'_'.$opt->[0].'" value="yes"'.$checked.' />'. |
|
&mt($opt->[1]).'</label></span> </td>'; |
|
$output .= &Apache::loncommon::end_data_table_row(); |
|
} |
|
$output .= &Apache::loncommon::continue_data_table_row(); |
|
$output .= '<td>'.(' ' x 10).'<span class="LC_metadata"><input name="'.$field_name.'_values" type="text" value="'.$values.'" size="80" /></span></td>'; |
|
$output .= &Apache::loncommon::end_data_table_row(); |
|
my $multiple_checked; |
|
my $single_checked; |
|
if ($options =~ m/onlyone/) { |
|
$multiple_checked = ""; |
|
$single_checked = " CHECKED "; |
|
} else { |
|
$multiple_checked = " CHECKED "; |
|
$single_checked = ""; |
|
} |
|
$output .= &Apache::loncommon::continue_data_table_row(); |
|
$output .= '<td>'.(' ' x 10).'<span class="LC_metadata"> |
|
<input type="radio" name="'.$field_name.'_onlyone" value="multiple" '.$multiple_checked .'/> |
|
Student may select multiple choices from list</span></td>'; |
|
$output .= &Apache::loncommon::end_data_table_row(); |
|
$output .= &Apache::loncommon::continue_data_table_row(); |
|
$output .= '<td>'.(' ' x 10).'<span class="LC_metadata"> |
|
<input type="radio" name="'.$field_name.'_onlyone" value="single" '.$single_checked.'/> |
|
Student may select only one choice from list</span></td>'; |
|
$output .= &Apache::loncommon::end_data_table_row(); |
} |
} |
return ($output); |
return ($output); |
} |
} |
|
sub order_meta_fields { |
|
my ($r)=@_; |
|
my $idx = 1; |
|
my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'}; |
|
my $crs = $env{'course.'.$env{'request.course.id'}.'.num'}; |
|
$r->print(&Apache::loncommon::start_page('Order Metadata Fields')); |
|
&Apache::lonhtmlcommon::add_breadcrumb |
|
({href=>"/adm/parmset?action=setrestrictmeta", |
|
text=>"Restrict Metadata"}, |
|
{text=>"Order Metadata"}); |
|
$r->print(&Apache::lonhtmlcommon::breadcrumbs('Order Metadata')); |
|
if ($env{'form.storeorder'}) { |
|
my $newpos = $env{'form.newpos'} - 1; |
|
my $currentpos = $env{'form.currentpos'} - 1; |
|
my @neworder = (); |
|
my @oldorder = split /,/,$env{'course.'.$env{'request.course.id'}.'.metadata.addedorder'}; |
|
my $i; |
|
if ($newpos > $currentpos) { |
|
# moving stuff up |
|
for ($i=0;$i<$currentpos;$i++) { |
|
$neworder[$i]=$oldorder[$i]; |
|
} |
|
for ($i=$currentpos;$i<$newpos;$i++) { |
|
$neworder[$i]=$oldorder[$i+1]; |
|
} |
|
$neworder[$newpos]=$oldorder[$currentpos]; |
|
for ($i=$newpos+1;$i<=$#oldorder;$i++) { |
|
$neworder[$i]=$oldorder[$i]; |
|
} |
|
} else { |
|
# moving stuff down |
|
for ($i=0;$i<$newpos;$i++) { |
|
$neworder[$i]=$oldorder[$i]; |
|
} |
|
$neworder[$newpos]=$oldorder[$currentpos]; |
|
for ($i=$newpos+1;$i<$currentpos+1;$i++) { |
|
$neworder[$i]=$oldorder[$i-1]; |
|
} |
|
for ($i=$currentpos+1;$i<=$#oldorder;$i++) { |
|
$neworder[$i]=$oldorder[$i]; |
|
} |
|
} |
|
my $ordered_fields = join ",", @neworder; |
|
my $put_result = &Apache::lonnet::put('environment', |
|
{'metadata.addedorder'=>$ordered_fields},$dom,$crs); |
|
&Apache::lonnet::appenv('course.'.$env{'request.course.id'}.'.metadata.addedorder' => $ordered_fields); |
|
} |
|
my $fields = &get_added_meta_fieldnames($env{'request.course.id'}); |
|
my $ordered_fields; |
|
my @fields_in_order = split /,/,$env{'course.'.$env{'request.course.id'}.'.metadata.addedorder'}; |
|
if (!@fields_in_order) { |
|
# no order found, pick sorted order then create metadata.addedorder key. |
|
foreach my $key (sort keys %$fields) { |
|
push @fields_in_order, $key; |
|
$ordered_fields = join ",", @fields_in_order; |
|
} |
|
my $put_result = &Apache::lonnet::put('environment', |
|
{'metadata.addedorder'=>$ordered_fields},$dom,$crs); |
|
} |
|
$r->print('<table>'); |
|
my $num_fields = scalar(@fields_in_order); |
|
foreach my $key (@fields_in_order) { |
|
$r->print('<tr><td>'); |
|
$r->print('<form method="post" action="">'); |
|
$r->print('<select name="newpos" onChange="this.form.submit()">'); |
|
for (my $i = 1;$i le $num_fields;$i ++) { |
|
if ($i eq $idx) { |
|
$r->print('<option value="'.$i.'" SELECTED>('.$i.')</option>'); |
|
} else { |
|
$r->print('<option value="'.$i.'">'.$i.'</option>'); |
|
} |
|
} |
|
$r->print('</select></td><td>'); |
|
$r->print('<input type="hidden" name="currentpos" value="'.$idx.'" />'); |
|
$r->print('<input type="hidden" name="storeorder" value="true" />'); |
|
$r->print('</form>'); |
|
$r->print($$fields{$key}.'</td></tr>'); |
|
$idx ++; |
|
} |
|
$r->print('</table>'); |
|
return 'ok'; |
|
} |
|
sub continue { |
|
my $output; |
|
$output .= '<form action="" method="post">'; |
|
$output .= '<input type="hidden" name="action" value="setrestrictmeta" />'; |
|
$output .= '<input type="submit" value="Continue" />'; |
|
return ($output); |
|
} |
|
sub addmetafield { |
|
my ($r)=@_; |
|
$r->print(&Apache::loncommon::start_page('Add Metadata Field')); |
|
$r->print(&Apache::lonhtmlcommon::breadcrumbs('Add Metadata Field')); |
|
my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'}; |
|
my $crs = $env{'course.'.$env{'request.course.id'}.'.num'}; |
|
if (exists($env{'form.undelete'})) { |
|
my @meta_fields = &Apache::loncommon::get_env_multiple('form.undeletefield'); |
|
foreach my $meta_field(@meta_fields) { |
|
my $options = $env{'course.'.$env{'request.course.id'}.'.metadata.'.$meta_field.'.options'}; |
|
$options =~ s/deleted//; |
|
$options =~ s/,,/,/; |
|
my $put_result = &Apache::lonnet::put('environment', |
|
{'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(&continue()); |
|
} elsif (exists($env{'form.fieldname'})) { |
|
my $meta_field = $env{'form.fieldname'}; |
|
my $display_field = $env{'form.fieldname'}; |
|
$meta_field =~ s/\W/_/g; |
|
$meta_field =~ tr/A-Z/a-z/; |
|
my $put_result = &Apache::lonnet::put('environment', |
|
{'metadata.'.$meta_field.'.values'=>"", |
|
'metadata.'.$meta_field.'.added'=>"$display_field", |
|
'metadata.'.$meta_field.'.options'=>""},$dom,$crs); |
|
$r->print('Added new Metadata Field <strong>'.$env{'form.fieldname'}."</strong> with result ".$put_result.'<br />'); |
|
$r->print(&continue()); |
|
} else { |
|
my $fields = &get_deleted_meta_fieldnames($env{'request.course.id'}); |
|
if ($fields) { |
|
$r->print('You may undelete previously deleted fields.<br />Check those you wish to undelete and click Undelete.<br />'); |
|
$r->print('<form method="post" action="">'); |
|
foreach my $key(keys(%$fields)) { |
|
$r->print('<input type="checkbox" name="undeletefield" value="'.$key.'" />'.$$fields{$key}.'<br /'); |
|
} |
|
$r->print('<input type="submit" name="undelete" value="Undelete" />'); |
|
$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('<input type="text" name="fieldname" /><br />'); |
|
$r->print('<input type="submit" value="Add Metadata Field" />'); |
|
} |
|
$r->print('</form>'); |
|
} |
sub setrestrictmeta { |
sub setrestrictmeta { |
my ($r)=@_; |
my ($r)=@_; |
my $next_meta; |
my $next_meta; |
my $output; |
my $output; |
my $item_num; |
my $item_num; |
my $put_result; |
my $put_result; |
$r->print(&Apache::lonxml::xmlbegin()); |
$r->print(&Apache::loncommon::start_page('Restrict Metadata')); |
$r->print('<head> |
$r->print(&Apache::lonhtmlcommon::breadcrumbs('Restrict Metadata')); |
<title>LON-CAPA Restrict Metadata</title> |
|
</head>'); |
|
$r->print(&Apache::loncommon::bodytag('Restrict Metadata')); |
|
$r->print(&Apache::lonhtmlcommon::breadcrumbs(undef, |
|
'Restrict Metadata')); |
|
my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'}; |
my $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 $key_base = $env{'course.'.$env{'request.course.id'}.'.'}; |
my $key_base = $env{'course.'.$env{'request.course.id'}.'.'}; |
Line 2978 sub setrestrictmeta {
|
Line 3446 sub setrestrictmeta {
|
if ($env{'form.'.$meta_field.'_stuadd'}) { |
if ($env{'form.'.$meta_field.'_stuadd'}) { |
$options.='stuadd,'; |
$options.='stuadd,'; |
} |
} |
if ($env{'form.'.$meta_field.'_onlyone'}) { |
if ($env{'form.'.$meta_field.'_choices'}) { |
|
$options.='choices,'; |
|
} |
|
if ($env{'form.'.$meta_field.'_onlyone'} eq 'single') { |
$options.='onlyone,'; |
$options.='onlyone,'; |
} |
} |
if ($env{'form.'.$meta_field.'_active'}) { |
if ($env{'form.'.$meta_field.'_active'}) { |
$options.='active,'; |
$options.='active,'; |
} |
} |
|
if ($env{'form.'.$meta_field.'_deleted'}) { |
|
$options.='deleted,'; |
|
} |
my $name = $save_field; |
my $name = $save_field; |
$put_result = &Apache::lonnet::put('environment', |
$put_result = &Apache::lonnet::put('environment', |
{'metadata.'.$meta_field.'.options'=>$options, |
{'metadata.'.$meta_field.'.options'=>$options, |
Line 2993 sub setrestrictmeta {
|
Line 3467 sub setrestrictmeta {
|
} |
} |
} |
} |
} |
} |
&Apache::lonnet::coursedescription($env{'request.course.id'}); |
&Apache::lonnet::coursedescription($env{'request.course.id'}, |
|
{'freshen_cache' => 1}); |
|
# Get the default metadata fields |
my %metadata_fields = &Apache::lonmeta::fieldnames('portfolio'); |
my %metadata_fields = &Apache::lonmeta::fieldnames('portfolio'); |
|
# Now get possible added metadata fields |
|
my $added_metadata_fields = &get_added_meta_fieldnames($env{'request.course.id'}); |
|
my $row_alt = 1; |
|
$output .= &Apache::loncommon::start_data_table(); |
foreach my $field (sort(keys(%metadata_fields))) { |
foreach my $field (sort(keys(%metadata_fields))) { |
&Apache::lonnet::logthis ($field); |
|
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); |
|
<input type="submit" name="restrictmeta" value="Save" /> |
|
</form><br /> |
|
<form method="post" action="/adm/parmset?action=addmetadata" name="form1"> |
|
<input type="submit" name="restrictmeta" value="Add a Metadata Field" /> |
|
</form> |
|
<br /> |
|
<form method="post" action="/adm/parmset?action=ordermetadata" name="form2"> |
|
<input type="submit" name="restrictmeta" value="Order Metadata Fields" /> |
|
ENDButtons |
|
my $added_flag = 1; |
|
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, $row_alt); |
|
} |
|
$output .= &Apache::loncommon::end_data_table(); |
$r->print(<<ENDenv); |
$r->print(<<ENDenv); |
<form method="post" action="/adm/parmset?action=setrestrictmeta" name="form"> |
<form method="post" action="/adm/parmset?action=setrestrictmeta" name="form"> |
<p> |
|
$output |
$output |
<input type="submit" name="restrictmeta" value="Update Metadata Restrictions"> |
$buttons |
</form> |
</form> |
ENDenv |
ENDenv |
$r->print('</body> |
$r->print(&Apache::loncommon::end_page()); |
</html>'); |
|
return 'ok'; |
return 'ok'; |
} |
} |
################################################## |
################################################## |
|
sub get_added_meta_fieldnames { |
|
my ($cid) = @_; |
|
my %fields; |
|
foreach my $key(%env) { |
|
if ($key =~ m/\Q$cid\E\.metadata\.(.+)\.added$/) { |
|
my $field_name = $1; |
|
my ($display_field_name) = $env{$key}; |
|
$fields{$field_name} = $display_field_name; |
|
} |
|
} |
|
return \%fields; |
|
} |
|
sub get_deleted_meta_fieldnames { |
|
my ($cid) = @_; |
|
my %fields; |
|
foreach my $key(%env) { |
|
if ($key =~ m/\Q$cid\E\.metadata\.(.+)\.added$/) { |
|
my $field_name = $1; |
|
if ($env{'course.'.$env{'request.course.id'}.'.metadata.'.$field_name.'.options'} =~ m/deleted/) { |
|
my ($display_field_name) = $env{$key}; |
|
$fields{$field_name} = $display_field_name; |
|
} |
|
} |
|
} |
|
return \%fields; |
|
} |
sub defaultsetter { |
sub defaultsetter { |
my $r=shift; |
my ($r) = @_; |
my $bodytag=&Apache::loncommon::bodytag('Parameter Setting Default Actions'); |
|
my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'}; |
my $start_page = |
my $crs = $env{'course.'.$env{'request.course.id'}.'.num'}; |
&Apache::loncommon::start_page('Parameter Setting Default Actions'); |
my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs(undef,'Defaults'); |
my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs('Defaults'); |
my $html=&Apache::lonxml::xmlbegin(); |
|
$r->print(<<ENDDEFHEAD); |
$r->print(<<ENDDEFHEAD); |
$html |
$start_page |
<head> |
|
<title>LON-CAPA Parameters</title> |
|
</head> |
|
$bodytag |
|
$breadcrumbs |
$breadcrumbs |
<form method="post" action="/adm/parmset?action=setdefaults" name="defaultform"> |
<form method="post" action="/adm/parmset?action=setdefaults" name="defaultform"> |
ENDDEFHEAD |
ENDDEFHEAD |
|
|
|
my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'}; |
|
my $crs = $env{'course.'.$env{'request.course.id'}.'.num'}; |
my @ids=(); |
my @ids=(); |
my %typep=(); |
my %typep=(); |
my %keyp=(); |
my %keyp=(); |
Line 3110 ENDDEFHEAD
|
Line 3627 ENDDEFHEAD
|
} |
} |
$r->print(&mt('Manual setting rules apply to all interfaces.').'<br />'. |
$r->print(&mt('Manual setting rules apply to all interfaces.').'<br />'. |
&mt('Automatic setting rules apply to table mode interfaces only.')); |
&mt('Automatic setting rules apply to table mode interfaces only.')); |
$r->print("\n<table border='1'><tr><th>".&mt('Rule for parameter').'</th><th>'. |
$r->print("\n".&Apache::loncommon::start_data_table(). |
&mt('Action').'</th><th>'.&mt('Value').'</th></tr>'); |
&Apache::loncommon::start_data_table_header_row(). |
|
"<th>".&mt('Rule for parameter').'</th><th>'. |
|
&mt('Action').'</th><th>'.&mt('Value').'</th>'. |
|
&Apache::loncommon::end_data_table_header_row()); |
foreach my $tempkey (&keysindisplayorder(\%allparms,\%keyorder)) { |
foreach my $tempkey (&keysindisplayorder(\%allparms,\%keyorder)) { |
unless ($tempkey) { next; } |
unless ($tempkey) { next; } |
$r->print("\n<tr><td>".$allparms{$tempkey}."\n<br />(".$tempkey.')</td><td>'); |
$r->print("\n".&Apache::loncommon::start_data_table_row(). |
|
"<td>".$allparms{$tempkey}."\n<br />(".$tempkey.')</td><td>'); |
my $action=&rulescache($tempkey.'_action'); |
my $action=&rulescache($tempkey.'_action'); |
$r->print('<select name="'.$tempkey.'_action">'); |
$r->print('<select name="'.$tempkey.'_action">'); |
if (&isdateparm($defkeytype{$tempkey})) { |
if (&isdateparm($defkeytype{$tempkey})) { |
Line 3163 ENDYESNO
|
Line 3684 ENDYESNO
|
} else { |
} else { |
$r->print('<input type="text" size="20" name="'.$tempkey.'_value" value="'.&rulescache($tempkey.'_value').'" />'); |
$r->print('<input type="text" size="20" name="'.$tempkey.'_value" value="'.&rulescache($tempkey.'_value').'" />'); |
} |
} |
$r->print('</td></tr>'); |
$r->print('</td>'.&Apache::loncommon::end_data_table_row()); |
} |
} |
$r->print("</table>\n<input type='submit' name='storerules' value='". |
$r->print(&Apache::loncommon::end_data_table(). |
&mt('Store Rules')."' /></form>\n</body>\n</html>"); |
"\n<input type='submit' name='storerules' value='". |
|
&mt('Save Rules')."' /></form>\n". |
|
&Apache::loncommon::end_page()); |
return; |
return; |
} |
} |
|
|
|
sub components { |
|
my ($key,$uname,$udom,$exeuser,$exedomain,$typeflag)=@_; |
|
|
|
if ($typeflag) { |
|
$key=~s/\.type$//; |
|
} |
|
|
|
my ($middle,$part,$name)= |
|
($key=~/^$env{'request.course.id'}\.(?:(.+)\.)*([\w\s]+)\.(\w+)$/); |
|
my $issection; |
|
|
|
my $section=&mt('All Students'); |
|
if ($middle=~/^\[(.*)\]/) { |
|
$issection=$1; |
|
$section=&mt('Group/Section').': '.$issection; |
|
$middle=~s/^\[(.*)\]//; |
|
} |
|
$middle=~s/\.+$//; |
|
$middle=~s/^\.+//; |
|
if ($uname) { |
|
$section=&mt('User').": ".&Apache::loncommon::plainname($uname,$udom); |
|
$issection=''; |
|
} |
|
my $realm='<span class="LC_parm_scope_all">'.&mt('All Resources').'</span>'; |
|
my $realmdescription=&mt('all resources'); |
|
if ($middle=~/^(.+)\_\_\_\(all\)$/) { |
|
$realm='<span class="LC_parm_scope_folder">'.&mt('Folder/Map').': '.&Apache::lonnet::gettitle($1).' <span class="LC_parm_folder"><br />('.$1.')</span></span>'; |
|
$realmdescription=&mt('folder').' '.&Apache::lonnet::gettitle($1); |
|
} elsif ($middle) { |
|
my ($map,$id,$url)=&Apache::lonnet::decode_symb($middle); |
|
$realm='<span class="LC_parm_scope_resource">'.&mt('Resource').': '.&Apache::lonnet::gettitle($middle).' <br /><span class="LC_parm_symb">('.$url.' in '.$map.' id: '.$id.')</span></span>'; |
|
$realmdescription=&mt('resource').' '.&Apache::lonnet::gettitle($middle); |
|
} |
|
my $what=$part.'.'.$name; |
|
return ($realm,$section,$name,$part, |
|
$what,$middle,$uname,$udom,$issection,$realmdescription); |
|
} |
|
|
|
my %standard_parms; |
|
sub load_parameter_names { |
|
open(my $config,"<$Apache::lonnet::perlvar{'lonTabDir'}/packages.tab"); |
|
while (my $configline=<$config>) { |
|
if ($configline !~ /\S/ || $configline=~/^\#/) { next; } |
|
chomp($configline); |
|
my ($short,$plain)=split(/:/,$configline); |
|
my (undef,$name,$type)=split(/\&/,$short,3); |
|
if ($type eq 'display') { |
|
$standard_parms{$name} = $plain; |
|
} |
|
} |
|
close($config); |
|
$standard_parms{'int_pos'} = 'Positive Integer'; |
|
$standard_parms{'int_zero_pos'} = 'Positive Integer or Zero'; |
|
%standard_parms=&Apache::lonlocal::texthash(%standard_parms); |
|
} |
|
|
|
sub standard_parameter_names { |
|
my ($name)=@_; |
|
if (!%standard_parms) { |
|
&load_parameter_names(); |
|
} |
|
if ($standard_parms{$name}) { |
|
return $standard_parms{$name}; |
|
} else { |
|
return $name; |
|
} |
|
} |
|
|
|
# |
|
# Parameter Change Log |
|
# |
|
|
|
|
|
sub parm_change_log { |
|
my ($r)=@_; |
|
$r->print(&Apache::loncommon::start_page('Parameter Change Log')); |
|
$r->print(&Apache::lonhtmlcommon::breadcrumbs('Parameter Change Log')); |
|
|
|
my %parmlog=&Apache::lonnet::dump('nohist_parameterlog', |
|
$env{'course.'.$env{'request.course.id'}.'.domain'}, |
|
$env{'course.'.$env{'request.course.id'}.'.num'}); |
|
|
|
if ((keys(%parmlog))[0]=~/^error\:/) { undef(%parmlog); } |
|
|
|
$r->print('<form action="/adm/parmset?action=parameterchangelog" |
|
method="post" name="parameterlog">'); |
|
|
|
my %saveable_parameters = ('show' => 'scalar',); |
|
&Apache::loncommon::store_course_settings('parameter_log', |
|
\%saveable_parameters); |
|
&Apache::loncommon::restore_course_settings('parameter_log', |
|
\%saveable_parameters); |
|
$r->print(&Apache::loncommon::display_filter(). |
|
'<label>'.&Apache::lonhtmlcommon::checkbox('includetypes',$env{'form.includetypes'},'1'). |
|
' '.&mt('Include parameter types').'</label>'. |
|
'<input type="submit" value="'.&mt('Display').'" /></form>'); |
|
|
|
my $courseopt=&Apache::lonnet::get_courseresdata($env{'course.'.$env{'request.course.id'}.'.num'}, |
|
$env{'course.'.$env{'request.course.id'}.'.domain'}); |
|
$r->print(&Apache::loncommon::start_data_table().&Apache::loncommon::start_data_table_header_row(). |
|
'<th>'.&mt('Time').'</th><th>'.&mt('User').'</th><th>'.&mt('Extent').'</th><th>'.&mt('Users').'</th><th>'. |
|
&mt('Parameter').'</th><th>'.&mt('Part').'</th><th>'.&mt('New Value').'</th><th>'.&mt('Announce').'</th>'. |
|
&Apache::loncommon::end_data_table_header_row()); |
|
my $shown=0; |
|
my $folder=''; |
|
if ($env{'form.displayfilter'} eq 'currentfolder') { |
|
my $last=''; |
|
if (tie(my %hash,'GDBM_File',$env{'request.course.fn'}.'_symb.db', |
|
&GDBM_READER(),0640)) { |
|
$last=$hash{'last_known'}; |
|
untie(%hash); |
|
} |
|
if ($last) { ($folder) = &Apache::lonnet::decode_symb($last); } |
|
} |
|
foreach my $id (sort |
|
{ |
|
if ($parmlog{$b}{'exe_time'} ne $parmlog{$a}{'exe_time'}) { |
|
return $parmlog{$b}{'exe_time'} <=>$parmlog{$a}{'exe_time'} |
|
} |
|
my $aid = (split('00000',$a))[-1]; |
|
my $bid = (split('00000',$b))[-1]; |
|
return $bid<=>$aid; |
|
} (keys(%parmlog))) { |
|
my @changes=keys(%{$parmlog{$id}{'logentry'}}); |
|
my $count = 0; |
|
my $time = |
|
&Apache::lonlocal::locallocaltime($parmlog{$id}{'exe_time'}); |
|
my $plainname = |
|
&Apache::loncommon::plainname($parmlog{$id}{'exe_uname'}, |
|
$parmlog{$id}{'exe_udom'}); |
|
my $about_me_link = |
|
&Apache::loncommon::aboutmewrapper($plainname, |
|
$parmlog{$id}{'exe_uname'}, |
|
$parmlog{$id}{'exe_udom'}); |
|
my $send_msg_link=''; |
|
if ((($parmlog{$id}{'exe_uname'} ne $env{'user.name'}) |
|
|| ($parmlog{$id}{'exe_udom'} ne $env{'user.domain'}))) { |
|
$send_msg_link ='<br />'. |
|
&Apache::loncommon::messagewrapper(&mt('Send message'), |
|
$parmlog{$id}{'exe_uname'}, |
|
$parmlog{$id}{'exe_udom'}); |
|
} |
|
my $row_start=&Apache::loncommon::start_data_table_row(); |
|
my $makenewrow=0; |
|
my %istype=(); |
|
my $output; |
|
foreach my $changed (reverse(sort(@changes))) { |
|
my $value=$parmlog{$id}{'logentry'}{$changed}; |
|
my $typeflag = ($changed =~/\.type$/ && |
|
!exists($parmlog{$id}{'logentry'}{$changed.'.type'})); |
|
my ($realm,$section,$parmname,$part,$what,$middle,$uname,$udom,$issection,$realmdescription)= |
|
&components($changed,$parmlog{$id}{'uname'},$parmlog{$id}{'udom'},undef,undef,$typeflag); |
|
if ($env{'form.displayfilter'} eq 'currentfolder') { |
|
if ($folder) { |
|
if ($middle!~/^\Q$folder\E/) { next; } |
|
} |
|
} |
|
if ($typeflag) { |
|
$istype{$parmname}=$value; |
|
if (!$env{'form.includetypes'}) { next; } |
|
} |
|
$count++; |
|
if ($makenewrow) { |
|
$output .= $row_start; |
|
} else { |
|
$makenewrow=1; |
|
} |
|
$output .='<td>'.$realm.'</td><td>'.$section.'</td><td>'. |
|
&standard_parameter_names($parmname).'</td><td>'. |
|
($part?&mt('Part: [_1]',$part):&mt('All Parts')).'</td><td>'; |
|
my $stillactive=0; |
|
if ($parmlog{$id}{'delflag'}) { |
|
$output .= &mt('Deleted'); |
|
} else { |
|
if ($typeflag) { |
|
$output .= &mt('Type: [_1]',&standard_parameter_names($value)); |
|
} else { |
|
my ($level,@all)=&parmval_by_symb($what,$middle,&Apache::lonnet::metadata($middle,$what), |
|
$uname,$udom,$issection,$issection,$courseopt); |
|
if (&isdateparm($istype{$parmname})) { |
|
$output .= &Apache::lonlocal::locallocaltime($value); |
|
} else { |
|
$output .= $value; |
|
} |
|
if ($value ne $all[$level]) { |
|
$output .= '<br /><span class="LC_warning">'.&mt('Not active anymore').'</span>'; |
|
} else { |
|
$stillactive=1; |
|
} |
|
} |
|
} |
|
$output .= '</td><td>'; |
|
if ($stillactive) { |
|
my $title=&mt('Changed [_1]',&standard_parameter_names($parmname)); |
|
my $description=&mt('Changed [_1] for [_2] to [_3]',&standard_parameter_names($parmname),$realmdescription, |
|
(&isdateparm($istype{$parmname})?&Apache::lonlocal::locallocaltime($value):$value)); |
|
if (($uname) && ($udom)) { |
|
$output .= |
|
&Apache::loncommon::messagewrapper('Notify User', |
|
$uname,$udom,$title, |
|
$description); |
|
} else { |
|
$output .= |
|
&Apache::lonrss::course_blog_link($id,$title, |
|
$description); |
|
} |
|
} |
|
$output .= '</td>'.&Apache::loncommon::end_data_table_row(); |
|
} |
|
if ($env{'form.displayfilter'} eq 'containing') { |
|
my $wholeentry=$about_me_link.':'. |
|
$parmlog{$id}{'exe_uname'}.':'.$parmlog{$id}{'exe_udom'}.':'. |
|
$output; |
|
if ($wholeentry!~/\Q$env{'form.containingphrase'}\E/i) { next; } |
|
} |
|
if ($count) { |
|
$r->print($row_start.'<td rowspan="'.$count.'">'.$time.'</td> |
|
<td rowspan="'.$count.'">'.$about_me_link. |
|
'<br /><tt>'.$parmlog{$id}{'exe_uname'}. |
|
':'.$parmlog{$id}{'exe_udom'}.'</tt>'. |
|
$send_msg_link.'</td>'.$output); |
|
$shown++; |
|
} |
|
if (!($env{'form.show'} eq &mt('all') |
|
|| $shown<=$env{'form.show'})) { last; } |
|
} |
|
$r->print(&Apache::loncommon::end_data_table()); |
|
$r->print(&Apache::loncommon::end_page()); |
|
} |
|
|
|
sub check_for_course_info { |
|
my $navmap = Apache::lonnavmaps::navmap->new(); |
|
return 1 if ($navmap); |
|
return 0; |
|
} |
|
|
################################################## |
################################################## |
################################################## |
################################################## |
|
|
Line 3205 sub handler {
|
Line 3964 sub handler {
|
&Apache::lonhtmlcommon::add_breadcrumb({href=>"/adm/parmset", |
&Apache::lonhtmlcommon::add_breadcrumb({href=>"/adm/parmset", |
text=>"Parameter Manager", |
text=>"Parameter Manager", |
faq=>10, |
faq=>10, |
bug=>'Instructor Interface'}); |
bug=>'Instructor Interface', |
|
help => 'Parameter_Manager'}); |
|
|
# ----------------------------------------------------- Needs to be in a course |
# ----------------------------------------------------- Needs to be in a course |
my $parm_permission = |
my $parm_permission = |
(&Apache::lonnet::allowed('opa',$env{'request.course.id'}) || |
(&Apache::lonnet::allowed('opa',$env{'request.course.id'}) || |
&Apache::lonnet::allowed('opa',$env{'request.course.id'}.'/'. |
&Apache::lonnet::allowed('opa',$env{'request.course.id'}.'/'. |
$env{'request.course.sec'})); |
$env{'request.course.sec'})); |
if ($env{'request.course.id'} && $parm_permission) { |
my $exists = &check_for_course_info(); |
|
|
|
if ($env{'request.course.id'} && $parm_permission && $exists) { |
|
|
# Start Page |
# Start Page |
&Apache::loncommon::content_type($r,'text/html'); |
&Apache::loncommon::content_type($r,'text/html'); |
Line 3230 sub handler {
|
Line 3992 sub handler {
|
# the table mode |
# the table mode |
if ((($env{'form.command'} eq 'set') && ($env{'form.url'}) |
if ((($env{'form.command'} eq 'set') && ($env{'form.url'}) |
&& (!$env{'form.dis'})) || ($env{'form.symb'})) { |
&& (!$env{'form.dis'})) || ($env{'form.symb'})) { |
|
&Apache::lonhtmlcommon::add_breadcrumb({help=>'Problem_Parameters', |
|
text=>"Problem Parameters"}); |
&assessparms($r); |
&assessparms($r); |
|
|
} elsif (! exists($env{'form.action'})) { |
} elsif (! exists($env{'form.action'})) { |
$r->print(&header()); |
$r->print(&header()); |
$r->print(&Apache::lonhtmlcommon::breadcrumbs(undef, |
$r->print(&Apache::lonhtmlcommon::breadcrumbs('Parameter Manager')); |
'Parameter Manager')); |
|
&print_main_menu($r,$parm_permission); |
&print_main_menu($r,$parm_permission); |
} 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', |
Line 3245 sub handler {
|
Line 4008 sub handler {
|
&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 'addmetadata' && $parm_permission) { |
|
&Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=addmetadata', |
|
text=>"Add Metadata Field"}); |
|
&addmetafield($r); |
|
} elsif ($env{'form.action'} eq 'ordermetadata' && $parm_permission) { |
|
&Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=addmetadata', |
|
text=>"Add Metadata Field"}); |
|
&order_meta_fields($r); |
} elsif ($env{'form.action'} eq 'setrestrictmeta' && $parm_permission) { |
} elsif ($env{'form.action'} eq 'setrestrictmeta' && $parm_permission) { |
&Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=setrestrictmeta', |
&Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=setrestrictmeta', |
text=>"Restrict Metadata"}); |
text=>"Restrict Metadata"}); |
Line 3262 sub handler {
|
Line 4033 sub handler {
|
text=>"Table Mode", |
text=>"Table Mode", |
help => 'Course_Setting_Parameters'}); |
help => 'Course_Setting_Parameters'}); |
&assessparms($r); |
&assessparms($r); |
} |
} elsif ($env{'form.action'} eq 'parameterchangelog' && $parm_permission) { |
|
&Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=settable', |
|
text=>"Parameter Change Log"}); |
|
&parm_change_log($r); |
|
} elsif ($env{'form.action'} eq 'cleanparameters' && $parm_permission) { |
|
&Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=cleanparameters', |
|
text=>"Clean Parameters"}); |
|
&clean_parameters($r); |
|
} |
} else { |
} else { |
# ----------------------------- Not in a course, or not allowed to modify parms |
# ----------------------------- Not in a course, or not allowed to modify parms |
$env{'user.error.msg'}= |
if ($exists) { |
"/adm/parmset:opa:0:0:Cannot modify assessment parameters"; |
$env{'user.error.msg'}= |
|
"/adm/parmset:opa:0:0:Cannot modify assessment parameters"; |
|
} else { |
|
$env{'user.error.msg'}= |
|
"/adm/parmset::0:1:Course environment gone, reinitialize the course"; |
|
} |
return HTTP_NOT_ACCEPTABLE; |
return HTTP_NOT_ACCEPTABLE; |
} |
} |
return OK; |
return OK; |