version 1.176, 2004/10/15 22:29:31
|
version 1.222, 2005/06/14 15:43:54
|
Line 62 use GDBM_File;
|
Line 62 use GDBM_File;
|
use Apache::lonhomework; |
use Apache::lonhomework; |
use Apache::lonxml; |
use Apache::lonxml; |
use Apache::lonlocal; |
use Apache::lonlocal; |
|
use Apache::lonnavmaps; |
|
|
my %courseopt; |
# --- Caches local to lonparmset |
my %useropt; |
|
|
my $parmhashid; |
my %parmhash; |
my %parmhash; |
|
my $symbsid; |
|
my %symbs; |
|
my $rulesid; |
|
my %rules; |
|
|
my @ids; |
# --- end local caches |
my %symbp; |
|
my %mapp; |
|
my %typep; |
|
my %keyp; |
|
|
|
my %maptitles; |
|
|
|
my $uname; |
|
my $udom; |
|
my $uhome; |
|
my $csec; |
|
my $coursename; |
|
|
|
################################################## |
################################################## |
################################################## |
################################################## |
Line 96 Inputs: $what - a parameter spec (inclu
|
Line 90 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 11 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 11 possible levels |
|
|
11- resource default |
11 - General Course |
10- map default |
10 - Map or Folder level in course |
9 - General Course |
9- resource default |
8 - Map or Folder level in course |
8- map default |
7 - resource level in course |
7 - resource level in course |
6 - General for section |
6 - General for section |
5 - Map or Folder level for section |
5 - Map or Folder level for section |
Line 111 Returns: A list, the first item is the
|
Line 105 Returns: A list, the first item is the
|
=cut |
=cut |
|
|
################################################## |
################################################## |
################################################## |
|
sub parmval { |
sub parmval { |
my ($what,$id,$def)=@_; |
my ($what,$id,$def,$uname,$udom,$csec)=@_; |
|
return &parmval_by_symb($what,&symbcache($id),$def,$uname,$udom,$csec); |
|
} |
|
|
|
sub parmval_by_symb { |
|
my ($what,$symb,$def,$uname,$udom,$csec)=@_; |
|
# load caches |
|
|
|
&cacheparmhash(); |
|
|
|
my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; |
|
my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; |
|
my $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 $symbparm=$symbp{$id}.'.'.$what; |
my $symbparm=$symb.'.'.$what; |
my $mapparm=$mapp{$id}.'___(all).'.$what; |
my $mapparm=$map.'___(all).'.$what; |
|
|
my $seclevel=$ENV{'request.course.id'}.'.['.$csec.'].'.$what; |
|
my $seclevelr=$ENV{'request.course.id'}.'.['.$csec.'].'.$symbparm; |
|
my $seclevelm=$ENV{'request.course.id'}.'.['.$csec.'].'.$mapparm; |
|
|
|
my $courselevel=$ENV{'request.course.id'}.'.'.$what; |
my $seclevel=$env{'request.course.id'}.'.['.$csec.'].'.$what; |
my $courselevelr=$ENV{'request.course.id'}.'.'.$symbparm; |
my $seclevelr=$env{'request.course.id'}.'.['.$csec.'].'.$symbparm; |
my $courselevelm=$ENV{'request.course.id'}.'.'.$mapparm; |
my $seclevelm=$env{'request.course.id'}.'.['.$csec.'].'.$mapparm; |
|
|
# -------------------------------------------------------- first, check default |
my $courselevel=$env{'request.course.id'}.'.'.$what; |
|
my $courselevelr=$env{'request.course.id'}.'.'.$symbparm; |
|
my $courselevelm=$env{'request.course.id'}.'.'.$mapparm; |
|
|
if (defined($def)) { $outpar[11]=$def; $result=11; } |
|
|
|
# ----------------------------------------------------- second, check map parms |
|
|
|
my $thisparm=$parmhash{$symbparm}; |
|
if (defined($thisparm)) { $outpar[10]=$thisparm; $result=10; } |
|
|
|
# --------------------------------------------------------- third, check course |
# --------------------------------------------------------- first, check course |
|
|
if (defined($courseopt{$courselevel})) { |
if (defined($$courseopt{$courselevel})) { |
$outpar[9]=$courseopt{$courselevel}; |
$outpar[11]=$$courseopt{$courselevel}; |
$result=9; |
$result=11; |
} |
} |
|
|
if (defined($courseopt{$courselevelm})) { |
if (defined($$courseopt{$courselevelm})) { |
$outpar[8]=$courseopt{$courselevelm}; |
$outpar[10]=$$courseopt{$courselevelm}; |
$result=8; |
$result=10; |
} |
} |
|
|
if (defined($courseopt{$courselevelr})) { |
# ------------------------------------------------------- second, check default |
$outpar[7]=$courseopt{$courselevelr}; |
|
|
if (defined($def)) { $outpar[9]=$def; $result=9; } |
|
|
|
# ------------------------------------------------------ third, check map parms |
|
|
|
my $thisparm=$parmhash{$symbparm}; |
|
if (defined($thisparm)) { $outpar[8]=$thisparm; $result=8; } |
|
|
|
if (defined($$courseopt{$courselevelr})) { |
|
$outpar[7]=$$courseopt{$courselevelr}; |
$result=7; |
$result=7; |
} |
} |
|
|
|
# ------------------------------------------------------ fourth, back to course |
if (defined($csec)) { |
if (defined($csec)) { |
if (defined($courseopt{$seclevel})) { |
if (defined($$courseopt{$seclevel})) { |
$outpar[6]=$courseopt{$seclevel}; |
$outpar[6]=$$courseopt{$seclevel}; |
$result=6; |
$result=6; |
} |
} |
if (defined($courseopt{$seclevelm})) { |
if (defined($$courseopt{$seclevelm})) { |
$outpar[5]=$courseopt{$seclevelm}; |
$outpar[5]=$$courseopt{$seclevelm}; |
$result=5; |
$result=5; |
} |
} |
|
|
if (defined($courseopt{$seclevelr})) { |
if (defined($$courseopt{$seclevelr})) { |
$outpar[4]=$courseopt{$seclevelr}; |
$outpar[4]=$$courseopt{$seclevelr}; |
$result=4; |
$result=4; |
} |
} |
} |
} |
|
|
# ---------------------------------------------------------- fourth, check user |
# ---------------------------------------------------------- fifth, check user |
|
|
if (defined($uname)) { |
if (defined($uname)) { |
if (defined($useropt{$courselevel})) { |
if (defined($$useropt{$courselevel})) { |
$outpar[3]=$useropt{$courselevel}; |
$outpar[3]=$$useropt{$courselevel}; |
$result=3; |
$result=3; |
} |
} |
|
|
if (defined($useropt{$courselevelm})) { |
if (defined($$useropt{$courselevelm})) { |
$outpar[2]=$useropt{$courselevelm}; |
$outpar[2]=$$useropt{$courselevelm}; |
$result=2; |
$result=2; |
} |
} |
|
|
if (defined($useropt{$courselevelr})) { |
if (defined($$useropt{$courselevelr})) { |
$outpar[1]=$useropt{$courselevelr}; |
$outpar[1]=$$useropt{$courselevelr}; |
$result=1; |
$result=1; |
} |
} |
} |
} |
return ($result,@outpar); |
return ($result,@outpar); |
} |
} |
|
|
|
sub resetparmhash { |
|
$parmhashid=''; |
|
} |
|
|
|
sub cacheparmhash { |
|
if ($parmhashid eq $env{'request.course.fn'}) { return; } |
|
my %parmhashfile; |
|
if (tie(%parmhashfile,'GDBM_File', |
|
$env{'request.course.fn'}.'_parms.db',&GDBM_READER(),0640)) { |
|
%parmhash=%parmhashfile; |
|
untie %parmhashfile; |
|
$parmhashid=$env{'request.course.fn'}; |
|
} |
|
} |
|
|
|
sub resetsymbcache { |
|
$symbsid=''; |
|
} |
|
|
|
sub symbcache { |
|
my $id=shift; |
|
if ($symbsid ne $env{'request.course.id'}) { |
|
%symbs=(); |
|
} |
|
unless ($symbs{$id}) { |
|
my $navmap = Apache::lonnavmaps::navmap->new(); |
|
if ($id=~/\./) { |
|
my $resource=$navmap->getById($id); |
|
$symbs{$id}=$resource->symb(); |
|
} else { |
|
my $resource=$navmap->getByMapPc($id); |
|
$symbs{$id}=&Apache::lonnet::declutter($resource->src()); |
|
} |
|
$symbsid=$env{'request.course.id'}; |
|
} |
|
return $symbs{$id}; |
|
} |
|
|
|
sub resetrulescache { |
|
$rulesid=''; |
|
} |
|
|
|
sub rulescache { |
|
my $id=shift; |
|
if ($rulesid ne $env{'request.course.id'}) { |
|
%rules=(); |
|
} |
|
unless ($rules{$id}) { |
|
my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'}; |
|
my $crs = $env{'course.'.$env{'request.course.id'}.'.num'}; |
|
my %rules=&Apache::lonnet::dump('parmdefactions',$dom,$crs); |
|
$rulesid=$env{'request.course.id'}; |
|
} |
|
return $rules{$id}; |
|
} |
|
|
|
################################################## |
|
################################################## |
|
# |
|
# Store a parameter by ID |
|
# |
|
# Takes |
|
# - resource id |
|
# - name of parameter |
|
# - level |
|
# - new value |
|
# - new type |
|
# - username |
|
# - userdomain |
|
|
|
sub storeparm { |
|
my ($sresid,$spnam,$snum,$nval,$ntype,$uname,$udom,$csec)=@_; |
|
&storeparm_by_symb(&symbcache($sresid),$spnam,$snum,$nval,$ntype,$uname,$udom,$csec); |
|
} |
|
|
|
# |
|
# Store a parameter by symb |
|
# |
|
# Takes |
|
# - symb |
|
# - name of parameter |
|
# - level |
|
# - new value |
|
# - new type |
|
# - username |
|
# - userdomain |
|
|
|
sub storeparm_by_symb { |
|
# ---------------------------------------------------------- Get symb, map, etc |
|
my ($symb,$spnam,$snum,$nval,$ntype,$uname,$udom,$csec)=@_; |
|
# ---------------------------------------------------------- Construct prefixes |
|
$spnam=~s/\_([^\_]+)$/\.$1/; |
|
my $map=(&Apache::lonnet::decode_symb($symb))[0]; |
|
my $symbparm=$symb.'.'.$spnam; |
|
my $mapparm=$map.'___(all).'.$spnam; |
|
|
|
my $seclevel=$env{'request.course.id'}.'.['.$csec.'].'.$spnam; |
|
my $seclevelr=$env{'request.course.id'}.'.['.$csec.'].'.$symbparm; |
|
my $seclevelm=$env{'request.course.id'}.'.['.$csec.'].'.$mapparm; |
|
|
|
my $courselevel=$env{'request.course.id'}.'.'.$spnam; |
|
my $courselevelr=$env{'request.course.id'}.'.'.$symbparm; |
|
my $courselevelm=$env{'request.course.id'}.'.'.$mapparm; |
|
|
|
my $storeunder=''; |
|
if (($snum==11) || ($snum==3)) { $storeunder=$courselevel; } |
|
if (($snum==10) || ($snum==2)) { $storeunder=$courselevelm; } |
|
if (($snum==7) || ($snum==1)) { $storeunder=$courselevelr; } |
|
if ($snum==6) { $storeunder=$seclevel; } |
|
if ($snum==5) { $storeunder=$seclevelm; } |
|
if ($snum==4) { $storeunder=$seclevelr; } |
|
|
|
my $delete; |
|
if ($nval eq '') { $delete=1;} |
|
my %storecontent = ($storeunder => $nval, |
|
$storeunder.'.type' => $ntype); |
|
my $reply=''; |
|
if ($snum>3) { |
|
# ---------------------------------------------------------------- Store Course |
|
# |
|
my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; |
|
my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; |
|
# Expire sheets |
|
&Apache::lonnet::expirespread('','','studentcalc'); |
|
if (($snum==7) || ($snum==4)) { |
|
&Apache::lonnet::expirespread('','','assesscalc',$symb); |
|
} elsif (($snum==8) || ($snum==5)) { |
|
&Apache::lonnet::expirespread('','','assesscalc',$map); |
|
} else { |
|
&Apache::lonnet::expirespread('','','assesscalc'); |
|
} |
|
# Store parameter |
|
if ($delete) { |
|
$reply=&Apache::lonnet::del |
|
('resourcedata',[keys(%storecontent)],$cdom,$cnum); |
|
} else { |
|
$reply=&Apache::lonnet::cput |
|
('resourcedata',\%storecontent,$cdom,$cnum); |
|
} |
|
&Apache::lonnet::devalidatecourseresdata($cnum,$cdom); |
|
} else { |
|
# ------------------------------------------------------------------ Store User |
|
# |
|
# Expire sheets |
|
&Apache::lonnet::expirespread($uname,$udom,'studentcalc'); |
|
if ($snum==1) { |
|
&Apache::lonnet::expirespread |
|
($uname,$udom,'assesscalc',$symb); |
|
} elsif ($snum==2) { |
|
&Apache::lonnet::expirespread |
|
($uname,$udom,'assesscalc',$map); |
|
} else { |
|
&Apache::lonnet::expirespread($uname,$udom,'assesscalc'); |
|
} |
|
# Store parameter |
|
if ($delete) { |
|
$reply=&Apache::lonnet::del |
|
('resourcedata',[keys(%storecontent)],$udom,$uname); |
|
} else { |
|
$reply=&Apache::lonnet::cput |
|
('resourcedata',\%storecontent,$udom,$uname); |
|
} |
|
&Apache::lonnet::devalidateuserresdata($uname,$udom); |
|
} |
|
|
|
if ($reply=~/^error\:(.*)/) { |
|
return "<font color=red>Write Error: $1</font>"; |
|
} |
|
return ''; |
|
} |
|
|
################################################## |
################################################## |
################################################## |
################################################## |
|
|
Line 240 sub valout {
|
Line 423 sub valout {
|
$result.=$sec.' secs '; |
$result.=$sec.' secs '; |
} |
} |
$result=~s/\s+$//; |
$result=~s/\s+$//; |
} elsif ($type=~/^date/) { |
} elsif (&isdateparm($type)) { |
$result = localtime($value); |
$result = localtime($value); |
} else { |
} else { |
$result = $value; |
$result = $value; |
Line 271 sub plink {
|
Line 454 sub plink {
|
my ($type,$dis,$value,$marker,$return,$call)=@_; |
my ($type,$dis,$value,$marker,$return,$call)=@_; |
my $winvalue=$value; |
my $winvalue=$value; |
unless ($winvalue) { |
unless ($winvalue) { |
if ($type=~/^date/) { |
if (&isdateparm($type)) { |
$winvalue=$ENV{'form.recent_'.$type}; |
$winvalue=$env{'form.recent_'.$type}; |
} else { |
} else { |
$winvalue=$ENV{'form.recent_'.(split(/\_/,$type))[0]}; |
$winvalue=$env{'form.recent_'.(split(/\_/,$type))[0]}; |
} |
} |
} |
} |
|
|
|
|
return |
return |
'<a href="javascript:pjump('."'".$type."','".$dis."','".$winvalue."','" |
'<a href="javascript:pjump('."'".$type."','".$dis."','".$winvalue."','" |
.$marker."','".$return."','".$call."'".');">'. |
.$marker."','".$return."','".$call."'".');">'. |
&valout($value,$type).'</a><a name="'.$marker.'"></a>'; |
&valout($value,$type).'</a><a name="'.$marker.'"></a>'; |
} |
} |
|
|
|
|
sub startpage { |
sub startpage { |
my ($r,$id,$udom,$csec,$uname,$have_assesments,$trimheader)=@_; |
my $r=shift; |
|
|
my $bodytag=&Apache::loncommon::bodytag('Set/Modify Course Parameters','', |
my $bodytag=&Apache::loncommon::bodytag('Set/Modify Course Parameters','', |
'onUnload="pclose()"'); |
'onUnload="pclose()"'); |
my $chooseopt=&Apache::loncommon::select_dom_form($udom,'udom').' '. |
my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs(undef,'Table Mode Parameter Setting'); |
&Apache::loncommon::selectstudent_link('parmform','uname','udom'); |
|
my $selscript=&Apache::loncommon::studentbrowser_javascript(); |
my $selscript=&Apache::loncommon::studentbrowser_javascript(); |
my $pjump_def = &Apache::lonhtmlcommon::pjump_javascript_definition(); |
my $pjump_def = &Apache::lonhtmlcommon::pjump_javascript_definition(); |
my %lt=&Apache::lonlocal::texthash( |
my $html=&Apache::lonxml::xmlbegin(); |
'cep' => "Course Environment Parameters", |
|
'scep' => "Set Course Environment Parameters", |
|
'smcap' => "Set/Modify Course Assessment Parameter", |
|
'mcap' => "Modify Course Assessment Parameters", |
|
'caphm' => "Course Assessment Parameter - Helper Mode", |
|
'capom' => "Course Assessment Parameters - Overview Mode", |
|
'captm' => "Course Assessments Parameters - Table Mode", |
|
'sg' => "Section/Group", |
|
'fu' => "For User", |
|
'oi' => "or ID", |
|
'ad' => "at Domain" |
|
); |
|
my $overallhelp= |
|
&Apache::loncommon::help_open_menu('','Setting Parameters','Course_Setting_Parameters','',10,'Instructor Interface'); |
|
my $assessparmhelp=&Apache::loncommon::help_open_topic("Cascading_Parameters","Assessment Parameters"); |
|
$r->print(<<ENDHEAD); |
$r->print(<<ENDHEAD); |
<html> |
$html |
<head> |
<head> |
<title>LON-CAPA Course Parameters</title> |
<title>LON-CAPA Course Parameters</title> |
<script> |
<script> |
Line 357 sub startpage {
|
Line 525 sub startpage {
|
$selscript |
$selscript |
</head> |
</head> |
$bodytag |
$bodytag |
$overallhelp |
$breadcrumbs |
ENDHEAD |
<form method="post" action="/adm/parmset?action=settable" name="parmform"> |
|
|
unless ($trimheader) {$r->print(<<ENDHEAD2); |
|
<form method="post" action="/adm/parmset" name="envform"> |
|
<h4>$lt{'cep'}</h4> |
|
<input type="submit" name="crsenv" value="$lt{'scep'}" /> |
|
</form> |
|
<hr /> |
|
$assessparmhelp |
|
<form method="post" action="/adm/helper/parameter.helper" name="helpform"> |
|
<h4>$lt{'caphm'}</h4> |
|
<input type="submit" value="$lt{'smcap'}" /> |
|
</form> |
|
<hr /> |
|
<form method="post" action="/adm/parmset" name="overview"> |
|
<h4>$lt{'capom'}</h4> |
|
<input type="submit" name="overview" value="$lt{'mcap'}" /> |
|
</form> |
|
<hr /> |
|
ENDHEAD2 |
|
} |
|
$r->print(<<ENDHEAD3); |
|
<form method="post" action="/adm/parmset" name="parmform"> |
|
<h4>$lt{'captm'}</h4> |
|
ENDHEAD3 |
|
|
|
if (!$have_assesments) { |
|
$r->print('<font color="red">'.&mt('There are no assesment parameters in this course to set.').'</font><br />'); |
|
} else { |
|
$r->print(<<ENDHEAD); |
|
<b> |
|
$lt{'sg'}: |
|
<input type="text" value="$csec" size="6" name="csec"> |
|
<br> |
|
$lt{'fu'} |
|
<input type="text" value="$uname" size="12" name="uname"> |
|
$lt{'oi'} |
|
<input type="text" value="$id" size="12" name="id"> |
|
$lt{'ad'} |
|
$chooseopt |
|
</b> |
|
<input type="hidden" value='' name="pres_value"> |
<input type="hidden" value='' name="pres_value"> |
<input type="hidden" value='' name="pres_type"> |
<input type="hidden" value='' name="pres_type"> |
<input type="hidden" value='' name="pres_marker"> |
<input type="hidden" value='' name="pres_marker"> |
|
<input type="hidden" value='1' name="prevvisit"> |
ENDHEAD |
ENDHEAD |
} |
|
} |
} |
|
|
|
|
sub print_row { |
sub print_row { |
my ($r,$which,$part,$name,$rid,$default,$defaulttype,$display,$defbgone, |
my ($r,$which,$part,$name,$symbp,$rid,$default,$defaulttype,$display,$defbgone, |
$defbgtwo,$parmlev)=@_; |
$defbgtwo,$parmlev,$uname,$udom,$csec)=@_; |
# 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}); |
$rid,$$default{$which},$uname,$udom,$csec); |
# 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,$$defaulttype{$which}); |
$rid,$$defaulttype{$which},$uname,$udom,$csec); |
# cascade down manually |
# cascade down manually |
my $cascadetype=$defaulttype; |
my $cascadetype=$$defaulttype{$which}; |
for (my $i=$#typeoutpar;$i>0;$i--) { |
for (my $i=11;$i>0;$i--) { |
if ($typeoutpar[$i]) { |
if ($typeoutpar[$i]) { |
$cascadetype=$typeoutpar[$i]; |
$cascadetype=$typeoutpar[$i]; |
} else { |
} else { |
$typeoutpar[$i]=$cascadetype; |
$typeoutpar[$i]=$cascadetype; |
} |
} |
} |
} |
|
|
my $parm=$$display{$which}; |
my $parm=$$display{$which}; |
|
|
if ($parmlev eq 'full' || $parmlev eq 'brief') { |
if ($parmlev eq 'full') { |
$r->print('<td bgcolor='.$defbgtwo.' align="center">' |
$r->print('<td bgcolor='.$defbgtwo.' align="center">' |
.$$part{$which}.'</td>'); |
.$$part{$which}.'</td>'); |
} else { |
} else { |
Line 450 sub print_row {
|
Line 578 sub print_row {
|
} elsif ($csec) { |
} elsif ($csec) { |
&print_td($r,6,$defbgtwo,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display); |
&print_td($r,6,$defbgtwo,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display); |
} else { |
} else { |
&print_td($r,9,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display); |
&print_td($r,11,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display); |
} |
} |
} elsif ($parmlev eq 'map') { |
} elsif ($parmlev eq 'map') { |
|
|
Line 459 sub print_row {
|
Line 587 sub print_row {
|
} elsif ($csec) { |
} elsif ($csec) { |
&print_td($r,5,$defbgtwo,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display); |
&print_td($r,5,$defbgtwo,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display); |
} else { |
} else { |
&print_td($r,8,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display); |
&print_td($r,10,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display); |
} |
} |
} else { |
} else { |
|
|
&print_td($r,11,'#FFDDDD',$result,\@outpar,$mprefix,$_,\@typeoutpar,$display); |
&print_td($r,11,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display); |
|
|
if ($parmlev eq 'brief') { |
|
|
|
&print_td($r,7,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display); |
|
|
|
if ($csec) { |
|
&print_td($r,4,$defbgtwo,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display); |
|
} |
|
if ($uname) { |
|
&print_td($r,1,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display); |
|
} |
|
} else { |
|
|
|
&print_td($r,10,'#FFDDDD',$result,\@outpar,$mprefix,$_,\@typeoutpar,$display); |
&print_td($r,10,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display); |
&print_td($r,9,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display); |
&print_td($r,9,'#FFDDDD',$result,\@outpar,$mprefix,$_,\@typeoutpar,$display); |
&print_td($r,8,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display); |
&print_td($r,8,'#FFDDDD',$result,\@outpar,$mprefix,$_,\@typeoutpar,$display); |
&print_td($r,7,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display); |
&print_td($r,7,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display); |
|
|
|
if ($csec) { |
|
&print_td($r,6,$defbgtwo,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display); |
|
&print_td($r,5,$defbgtwo,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display); |
|
&print_td($r,4,$defbgtwo,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display); |
|
} |
|
if ($uname) { |
|
&print_td($r,3,$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); |
|
} |
|
|
if ($csec) { |
|
&print_td($r,6,$defbgtwo,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display); |
|
&print_td($r,5,$defbgtwo,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display); |
|
&print_td($r,4,$defbgtwo,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display); |
|
} |
|
if ($uname) { |
|
&print_td($r,3,$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); |
|
} |
|
} # end of $brief if/else |
|
} # end of $parmlev if/else |
} # end of $parmlev if/else |
|
|
$r->print('<td bgcolor=#CCCCFF align="center">'. |
$r->print('<td bgcolor=#CCCCFF align="center">'. |
&valout($outpar[$result],$typeoutpar[$result]).'</td>'); |
&valout($outpar[$result],$typeoutpar[$result]).'</td>'); |
|
|
if ($parmlev eq 'full' || $parmlev eq 'brief') { |
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}); |
|
|
# this doesn't seem to work, and I don't think is correct |
|
# my $sessionvaltype=&Apache::lonnet::EXT('resource.'.$$part{$which}. |
|
# '.'.$$name{$which}.'.type',$symbp{$rid}); |
|
# this seems to work |
|
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>'. |
Line 520 sub print_td {
|
Line 631 sub print_td {
|
my ($r,$which,$defbg,$result,$outpar,$mprefix,$value,$typeoutpar,$display)=@_; |
my ($r,$which,$defbg,$result,$outpar,$mprefix,$value,$typeoutpar,$display)=@_; |
$r->print('<td bgcolor='.(($result==$which)?'"#AAFFAA"':$defbg). |
$r->print('<td bgcolor='.(($result==$which)?'"#AAFFAA"':$defbg). |
' align="center">'); |
' align="center">'); |
if ($which<10) { |
if ($which<8 || $which > 9) { |
$r->print(&plink($$typeoutpar[$which], |
$r->print(&plink($$typeoutpar[$which], |
$$display{$value},$$outpar[$which], |
$$display{$value},$$outpar[$which], |
$mprefix."$which",'parmform.pres','psub')); |
$mprefix."$which",'parmform.pres','psub')); |
Line 530 sub print_td {
|
Line 641 sub print_td {
|
$r->print('</td>'."\n"); |
$r->print('</td>'."\n"); |
} |
} |
|
|
|
|
=pod |
=pod |
|
|
=item B<extractResourceInformation>: Given the course data hash, extractResourceInformation extracts lots of information about the course's resources into a variety of hashes. |
=item B<extractResourceInformation>: Given the course data hash, extractResourceInformation extracts lots of information about the course's resources into a variety of hashes. |
Line 565 Input: See list below:
|
Line 677 Input: See list below:
|
=cut |
=cut |
|
|
sub extractResourceInformation { |
sub extractResourceInformation { |
my $bighash = shift; |
|
my $ids = shift; |
my $ids = shift; |
my $typep = shift; |
my $typep = shift; |
my $keyp = shift; |
my $keyp = shift; |
my $allparms = shift; |
my $allparms = shift; |
my $allparts = shift; |
my $allparts = shift; |
my $allkeys = shift; |
|
my $allmaps = shift; |
my $allmaps = shift; |
my $fcat = shift; |
|
my $defp = shift; |
|
my $mapp = shift; |
my $mapp = shift; |
my $symbp = shift; |
my $symbp = shift; |
my $maptitles=shift; |
my $maptitles=shift; |
|
my $uris=shift; |
foreach (keys %$bighash) { |
my $keyorder=shift; |
if ($_=~/^src\_(\d+)\.(\d+)$/) { |
my $defkeytype=shift; |
# there are no resources in the 0 level |
|
if ($1 eq '0') { next; } |
my $keyordercnt=100; |
my $mapid=$1; |
|
my $resid=$2; |
my $navmap = Apache::lonnavmaps::navmap->new(); |
my $id=$mapid.'.'.$resid; |
my @allres=$navmap->retrieveResources(undef,undef,1,undef,1); |
my $srcf=$$bighash{$_}; |
foreach my $resource (@allres) { |
if (1) { |
my $id=$resource->id(); |
$srcf=~/\.(\w+)$/; |
my ($mapid,$resid)=split(/\./,$id); |
$$ids[$#$ids+1]=$id; |
if ($mapid eq '0') { next; } |
$$typep{$id}=$1; |
$$ids[$#$ids+1]=$id; |
$$keyp{$id}=''; |
my $srcf=$resource->src(); |
foreach (split(/\,/,&Apache::lonnet::metadata($srcf,'allpossiblekeys'))) { |
$srcf=~/\.(\w+)$/; |
if ($_=~/^parameter\_(.*)/) { |
$$typep{$id}=$1; |
my $key=$_; |
$$keyp{$id}=''; |
my $allkey=$1; |
$$uris{$id}=$srcf; |
$allkey=~s/\_/\./g; |
foreach (split(/\,/,&Apache::lonnet::metadata($srcf,'allpossiblekeys'))) { |
if (&Apache::lonnet::metadata($srcf,$key.'.hidden') eq |
if ($_=~/^parameter\_(.*)/) { |
'parm') { |
my $key=$_; |
next; #hide hidden things |
# Hidden parameters |
} |
if (&Apache::lonnet::metadata($srcf,$key.'.hidden') eq 'parm') { |
my $display= &Apache::lonnet::metadata($srcf,$key.'.display'); |
next; |
my $name=&Apache::lonnet::metadata($srcf,$key.'.name'); |
|
my $part= &Apache::lonnet::metadata($srcf,$key.'.part'); |
|
my $parmdis = $display; |
|
$parmdis =~ s|(\[Part.*$)||g; |
|
my $partkey = $part; |
|
$partkey =~ tr|_|.|; |
|
$$allparms{$name} = $parmdis; |
|
$$allparts{$part} = "[Part $part]"; |
|
$$allkeys{$allkey}=$display; |
|
if ($allkey eq $fcat) { |
|
$$defp{$id}= &Apache::lonnet::metadata($srcf,$key); |
|
} |
|
if ($$keyp{$id}) { |
|
$$keyp{$id}.=','.$key; |
|
} else { |
|
$$keyp{$id}=$key; |
|
} |
|
} |
|
} |
} |
$$mapp{$id}= |
my $display= &Apache::lonnet::metadata($srcf,$key.'.display'); |
&Apache::lonnet::declutter($$bighash{'map_id_'.$mapid}); |
my $name=&Apache::lonnet::metadata($srcf,$key.'.name'); |
$$mapp{$mapid}=$$mapp{$id}; |
my $part= &Apache::lonnet::metadata($srcf,$key.'.part'); |
$$allmaps{$mapid}=$$mapp{$id}; |
# |
if ($mapid eq '1') { |
# allparms is a hash of parameter names |
$$maptitles{$mapid}='Main Course Documents'; |
# |
|
my $parmdis = $display; |
|
$parmdis =~ s/\[Part.*$//g; |
|
$$allparms{$name}=$parmdis; |
|
$$defkeytype{$name}=&Apache::lonnet::metadata($srcf,$key.'.type'); |
|
# |
|
# allparts is a hash of all parts |
|
# |
|
$$allparts{$part} = "Part: $part"; |
|
# |
|
# Remember all keys going with this resource |
|
# |
|
if ($$keyp{$id}) { |
|
$$keyp{$id}.=','.$key; |
} else { |
} else { |
$$maptitles{$mapid}= |
$$keyp{$id}=$key; |
$$bighash{'title_'.$$bighash{'ids_'.&Apache::lonnet::clutter($$mapp{$id})}}; |
} |
|
# |
|
# Put in order |
|
# |
|
unless ($$keyorder{$key}) { |
|
$$keyorder{$key}=$keyordercnt; |
|
$keyordercnt++; |
} |
} |
$$maptitles{$$mapp{$id}}=$$maptitles{$mapid}; |
|
$$symbp{$id}=$$mapp{$id}. |
|
'___'.$resid.'___'. |
|
&Apache::lonnet::declutter($srcf); |
|
$$symbp{$mapid}=$$mapp{$id}.'___(all)'; |
|
} |
} |
} |
} |
|
$$mapp{$id}= |
|
&Apache::lonnet::declutter($resource->enclosing_map_src()); |
|
$$mapp{$mapid}=$$mapp{$id}; |
|
$$allmaps{$mapid}=$$mapp{$id}; |
|
if ($mapid eq '1') { |
|
$$maptitles{$mapid}='Main Course Documents'; |
|
} else { |
|
$$maptitles{$mapid}=&Apache::lonnet::gettitle(&Apache::lonnet::clutter($$mapp{$id})); |
|
} |
|
$$maptitles{$$mapp{$id}}=$$maptitles{$mapid}; |
|
$$symbp{$id}=&Apache::lonnet::encode_symb($$mapp{$id},$resid,$srcf); |
|
$$symbp{$mapid}=$$mapp{$id}.'___(all)'; |
} |
} |
} |
} |
|
|
|
|
|
################################################## |
|
################################################## |
|
|
|
sub isdateparm { |
|
my $type=shift; |
|
return (($type=~/^date/) && (!($type eq 'date_interval'))); |
|
} |
|
|
|
sub parmmenu { |
|
my ($r,$allparms,$pscat,$keyorder)=@_; |
|
my $tempkey; |
|
$r->print(<<ENDSCRIPT); |
|
<script type="text/javascript"> |
|
function checkall(value, checkName) { |
|
for (i=0; i<document.forms.parmform.elements.length; i++) { |
|
ele = document.forms.parmform.elements[i]; |
|
if (ele.name == checkName) { |
|
document.forms.parmform.elements[i].checked=value; |
|
} |
|
} |
|
} |
|
|
|
function checkthis(thisvalue, checkName) { |
|
for (i=0; i<document.forms.parmform.elements.length; i++) { |
|
ele = document.forms.parmform.elements[i]; |
|
if (ele.name == checkName) { |
|
if (ele.value == thisvalue) { |
|
document.forms.parmform.elements[i].checked=true; |
|
} |
|
} |
|
} |
|
} |
|
|
|
function checkdates() { |
|
checkthis('duedate','pscat'); |
|
checkthis('opendate','pscat'); |
|
checkthis('answerdate','pscat'); |
|
} |
|
|
|
function checkdisset() { |
|
checkthis('discussend','pscat'); |
|
checkthis('discusshide','pscat'); |
|
} |
|
|
|
function checkcontdates() { |
|
checkthis('contentopen','pscat'); |
|
checkthis('contentclose','pscat'); |
|
} |
|
|
|
|
|
function checkvisi() { |
|
checkthis('hiddenresource','pscat'); |
|
checkthis('encrypturl','pscat'); |
|
checkthis('problemstatus','pscat'); |
|
checkthis('contentopen','pscat'); |
|
checkthis('opendate','pscat'); |
|
} |
|
|
|
function checkparts() { |
|
checkthis('hiddenparts','pscat'); |
|
checkthis('display','pscat'); |
|
checkthis('ordered','pscat'); |
|
} |
|
|
|
function checkstandard() { |
|
checkall(false,'pscat'); |
|
checkdates(); |
|
checkthis('weight','pscat'); |
|
checkthis('maxtries','pscat'); |
|
} |
|
|
|
</script> |
|
ENDSCRIPT |
|
$r->print(); |
|
$r->print("\n<table><tr>"); |
|
my $cnt=0; |
|
foreach $tempkey (&keysindisplayorder($allparms,$keyorder)) { |
|
$r->print("\n<td><font size='-1'><input type='checkbox' name='pscat' "); |
|
$r->print('value="'.$tempkey.'"'); |
|
if ($$pscat[0] eq "all" || grep $_ eq $tempkey, @{$pscat}) { |
|
$r->print(' checked'); |
|
} |
|
$r->print('>'.$$allparms{$tempkey}.'</font></td>'); |
|
$cnt++; |
|
if ($cnt==3) { |
|
$r->print("</tr>\n<tr>"); |
|
$cnt=0; |
|
} |
|
} |
|
$r->print(' |
|
</tr><tr><td> |
|
<a href="javascript:checkall(true, \'pscat\')">Select All</a><br /> |
|
<a href="javascript:checkstandard()">Select Common Only</a> |
|
</td><td> |
|
<a href="javascript:checkdates()">Add Problem Dates</a> |
|
<a href="javascript:checkcontdates()">Add Content Dates</a><br /> |
|
<a href="javascript:checkdisset()">Add Discussion Settings</a> |
|
<a href="javascript:checkvisi()">Add Visibilities</a><br /> |
|
<a href="javascript:checkparts()">Add Part Parameters</a> |
|
</td><td> |
|
<a href="javascript:checkall(false, \'pscat\')">Unselect All</a> |
|
</td> |
|
'); |
|
$r->print('</tr></table>'); |
|
} |
|
|
|
sub partmenu { |
|
my ($r,$allparts,$psprt)=@_; |
|
$r->print('<select multiple name="psprt" size="8">'); |
|
$r->print('<option value="all"'); |
|
$r->print(' selected') unless (@{$psprt}); |
|
$r->print('>'.&mt('All Parts').'</option>'); |
|
my %temphash=(); |
|
foreach (@{$psprt}) { $temphash{$_}=1; } |
|
foreach my $tempkey (sort keys %{$allparts}) { |
|
unless ($tempkey =~ /\./) { |
|
$r->print('<option value="'.$tempkey.'"'); |
|
if ($$psprt[0] eq "all" || $temphash{$tempkey}) { |
|
$r->print(' selected'); |
|
} |
|
$r->print('>'.$$allparts{$tempkey}.'</option>'); |
|
} |
|
} |
|
$r->print('</select>'); |
|
} |
|
|
|
sub usermenu { |
|
my ($r,$uname,$id,$udom,$csec)=@_; |
|
my $chooseopt=&Apache::loncommon::select_dom_form($udom,'udom').' '. |
|
&Apache::loncommon::selectstudent_link('parmform','uname','udom'); |
|
my $selscript=&Apache::loncommon::studentbrowser_javascript(); |
|
my %lt=&Apache::lonlocal::texthash( |
|
'sg' => "Section/Group", |
|
'fu' => "For User", |
|
'oi' => "or ID", |
|
'ad' => "at Domain" |
|
); |
|
my %sectionhash=(); |
|
my $sections=''; |
|
if (&Apache::loncommon::get_sections( |
|
$env{'course.'.$env{'request.course.id'}.'.domain'}, |
|
$env{'course.'.$env{'request.course.id'}.'.num'}, |
|
\%sectionhash)) { |
|
$sections=$lt{'sg'}.': <select name="csec">'; |
|
foreach ('',sort keys %sectionhash) { |
|
$sections.='<option value="'.$_.'"'. |
|
($_ eq $csec?'selected="selected"':'').'>'.$_.'</option>'; |
|
} |
|
$sections.='</select>'; |
|
} |
|
$r->print(<<ENDMENU); |
|
<b> |
|
$sections |
|
<br /> |
|
$lt{'fu'} |
|
<input type="text" value="$uname" size="12" name="uname" /> |
|
$lt{'oi'} |
|
<input type="text" value="$id" size="12" name="id" /> |
|
$lt{'ad'} |
|
$chooseopt |
|
</b> |
|
ENDMENU |
|
} |
|
|
|
sub displaymenu { |
|
my ($r,$allparms,$allparts,$pscat,$psprt,$keyorder)=@_; |
|
$r->print('<table border="1"><tr><th>'.&mt('Select Parameters to View').'</th><th>'. |
|
&mt('Select Parts to View').'</th></tr><tr><td>'); |
|
&parmmenu($r,$allparms,$pscat,$keyorder); |
|
$r->print('</td><td>'); |
|
&partmenu($r,$allparts,$psprt); |
|
$r->print('</td></tr></table>'); |
|
} |
|
|
|
sub mapmenu { |
|
my ($r,$allmaps,$pschp,$maptitles)=@_; |
|
$r->print(&mt('Select Enclosing Map or Folder').' '); |
|
$r->print('<select name="pschp">'); |
|
$r->print('<option value="all">'.&mt('All Maps or Folders').'</option>'); |
|
foreach (sort {$$allmaps{$a} cmp $$allmaps{$b}} keys %{$allmaps}) { |
|
$r->print('<option value="'.$_.'"'); |
|
if (($pschp eq $_)) { $r->print(' selected'); } |
|
$r->print('>'.$$maptitles{$_}.($$allmaps{$_}!~/^uploaded/?' ['.$$allmaps{$_}.']':'').'</option>'); |
|
} |
|
$r->print("</select>"); |
|
} |
|
|
|
sub levelmenu { |
|
my ($r,$alllevs,$parmlev)=@_; |
|
$r->print(&mt('Select Parameter Level'). |
|
&Apache::loncommon::help_open_topic('Course_Parameter_Levels').' '); |
|
$r->print('<select name="parmlev">'); |
|
foreach (reverse sort keys %{$alllevs}) { |
|
$r->print('<option value="'.$$alllevs{$_}.'"'); |
|
if ($parmlev eq $$alllevs{$_}) { |
|
$r->print(' selected'); |
|
} |
|
$r->print('>'.$_.'</option>'); |
|
} |
|
$r->print("</select>"); |
|
} |
|
|
|
|
|
sub sectionmenu { |
|
my ($r,$selectedsections)=@_; |
|
my %sectionhash=(); |
|
|
|
if (&Apache::loncommon::get_sections( |
|
$env{'course.'.$env{'request.course.id'}.'.domain'}, |
|
$env{'course.'.$env{'request.course.id'}.'.num'}, |
|
\%sectionhash)) { |
|
$r->print('<select name="Section" multiple="true" size="8" >'); |
|
foreach my $s ('all',sort keys %sectionhash) { |
|
$r->print(' <option value="'.$s.'"'); |
|
foreach (@{$selectedsections}) { |
|
if ($s eq $_) { |
|
$r->print(' selected'); |
|
last; |
|
} |
|
} |
|
$r->print('>'.$s."</option>\n"); |
|
} |
|
$r->print("</select>\n"); |
|
} |
|
} |
|
|
|
sub keysplit { |
|
my $keyp=shift; |
|
return (split(/\,/,$keyp)); |
|
} |
|
|
|
sub keysinorder { |
|
my ($name,$keyorder)=@_; |
|
return sort { |
|
$$keyorder{$a} <=> $$keyorder{$b}; |
|
} (keys %{$name}); |
|
} |
|
|
|
sub keysindisplayorder { |
|
my ($name,$keyorder)=@_; |
|
return sort { |
|
$$keyorder{'parameter_0_'.$a} <=> $$keyorder{'parameter_0_'.$b}; |
|
} (keys %{$name}); |
|
} |
|
|
|
sub sortmenu { |
|
my ($r,$sortorder)=@_; |
|
$r->print('<br /><input type="radio" name="sortorder" value="realmstudent"'); |
|
if ($sortorder eq 'realmstudent') { |
|
$r->print(' checked="on"'); |
|
} |
|
$r->print(' />'.&mt('Sort by realm first, then student (group/section)')); |
|
$r->print('<br /><input type="radio" name="sortorder" value="studentrealm"'); |
|
if ($sortorder eq 'studentrealm') { |
|
$r->print(' checked="on"'); |
|
} |
|
$r->print(' />'.&mt('Sort by student (group/section) first, then realm')); |
|
} |
|
|
|
sub standardkeyorder { |
|
return ('parameter_0_opendate' => 1, |
|
'parameter_0_duedate' => 2, |
|
'parameter_0_answerdate' => 3, |
|
'parameter_0_interval' => 4, |
|
'parameter_0_weight' => 5, |
|
'parameter_0_maxtries' => 6, |
|
'parameter_0_hinttries' => 7, |
|
'parameter_0_contentopen' => 8, |
|
'parameter_0_contentclose' => 9, |
|
'parameter_0_type' => 10, |
|
'parameter_0_problemstatus' => 11, |
|
'parameter_0_hiddenresource' => 12, |
|
'parameter_0_hiddenparts' => 13, |
|
'parameter_0_display' => 14, |
|
'parameter_0_ordered' => 15, |
|
'parameter_0_tol' => 16, |
|
'parameter_0_sig' => 17, |
|
'parameter_0_turnoffunit' => 18, |
|
'parameter_0_discussend' => 19, |
|
'parameter_0_discusshide' => 20); |
|
} |
|
|
################################################## |
################################################## |
################################################## |
################################################## |
|
|
Line 674 Variables used (guessed by Jeremy):
|
Line 1074 Variables used (guessed by Jeremy):
|
sub assessparms { |
sub assessparms { |
|
|
my $r=shift; |
my $r=shift; |
|
|
|
my @ids=(); |
|
my %symbp=(); |
|
my %mapp=(); |
|
my %typep=(); |
|
my %keyp=(); |
|
my %uris=(); |
|
my %maptitles=(); |
|
|
# -------------------------------------------------------- Variable declaration |
# -------------------------------------------------------- Variable declaration |
my %allkeys=(); |
|
my %allmaps=(); |
my %allmaps=(); |
my %alllevs=(); |
my %alllevs=(); |
|
|
|
my $uname; |
|
my $udom; |
|
my $uhome; |
|
my $csec; |
|
|
|
my $coursename=$env{'course.'.$env{'request.course.id'}.'.description'}; |
|
|
$alllevs{'Resource Level'}='full'; |
$alllevs{'Resource Level'}='full'; |
# $alllevs{'Resource Level [BRIEF]'}='brief'; |
$alllevs{'Map/Folder Level'}='map'; |
$alllevs{'Map Level'}='map'; |
|
$alllevs{'Course Level'}='general'; |
$alllevs{'Course Level'}='general'; |
|
|
my %allparms; |
my %allparms; |
my %allparts; |
my %allparts; |
|
# |
my %defp; |
# Order in which these parameters will be displayed |
%courseopt=(); |
# |
%useropt=(); |
my %keyorder=&standardkeyorder(); |
my %bighash=(); |
|
|
|
@ids=(); |
@ids=(); |
%symbp=(); |
%symbp=(); |
Line 698 sub assessparms {
|
Line 1112 sub assessparms {
|
|
|
my $message=''; |
my $message=''; |
|
|
$csec=$ENV{'form.csec'}; |
$csec=$env{'form.csec'}; |
if ($udom=$ENV{'form.udom'}) { |
|
} elsif ($udom=$ENV{'request.role.domain'}) { |
if ($udom=$env{'form.udom'}) { |
} elsif ($udom=$ENV{'user.domain'}) { |
} elsif ($udom=$env{'request.role.domain'}) { |
|
} elsif ($udom=$env{'user.domain'}) { |
} else { |
} else { |
$udom=$r->dir_config('lonDefDomain'); |
$udom=$r->dir_config('lonDefDomain'); |
} |
} |
|
|
my @pscat=&Apache::loncommon::get_env_multiple('form.pscat'); |
my @pscat=&Apache::loncommon::get_env_multiple('form.pscat'); |
my $pschp=$ENV{'form.pschp'}; |
my $pschp=$env{'form.pschp'}; |
my @psprt=&Apache::loncommon::get_env_multiple('form.psprt'); |
my @psprt=&Apache::loncommon::get_env_multiple('form.psprt'); |
if (!@psprt) { $psprt[0]='0'; } |
if (!@psprt) { $psprt[0]='0'; } |
my $showoptions=$ENV{'form.showoptions'}; |
|
|
|
my $pssymb=''; |
my $pssymb=''; |
my $parmlev=''; |
my $parmlev=''; |
my $trimheader=''; |
|
my $prevvisit=$ENV{'form.prevvisit'}; |
|
|
|
# unless ($parmlev==$ENV{'form.parmlev'}) { |
|
# $parmlev = 'full'; |
|
# } |
|
|
|
unless ($ENV{'form.parmlev'}) { |
unless ($env{'form.parmlev'}) { |
$parmlev = 'map'; |
$parmlev = 'map'; |
} else { |
} else { |
$parmlev = $ENV{'form.parmlev'}; |
$parmlev = $env{'form.parmlev'}; |
} |
} |
|
|
# ----------------------------------------------- Was this started from grades? |
# ----------------------------------------------- Was this started from grades? |
|
|
if (($ENV{'form.command'} eq 'set') && ($ENV{'form.url'}) |
if (($env{'form.command'} eq 'set') && ($env{'form.url'}) |
&& (!$ENV{'form.dis'})) { |
&& (!$env{'form.dis'})) { |
my $url=$ENV{'form.url'}; |
my $url=$env{'form.url'}; |
$url=~s-^http://($ENV{'SERVER_NAME'}|$ENV{'HTTP_HOST'})--; |
$url=~s-^http://($ENV{'SERVER_NAME'}|$ENV{'HTTP_HOST'})--; |
$pssymb=&Apache::lonnet::symbread($url); |
$pssymb=&Apache::lonnet::symbread($url); |
if (!@pscat) { @pscat=('all'); } |
if (!@pscat) { @pscat=('all'); } |
$pschp=''; |
$pschp=''; |
$parmlev = 'full'; |
$parmlev = 'full'; |
$trimheader='yes'; |
} elsif ($env{'form.symb'}) { |
} elsif ($ENV{'form.symb'}) { |
$pssymb=$env{'form.symb'}; |
$pssymb=$ENV{'form.symb'}; |
|
if (!@pscat) { @pscat=('all'); } |
if (!@pscat) { @pscat=('all'); } |
$pschp=''; |
$pschp=''; |
$parmlev = 'full'; |
$parmlev = 'full'; |
$trimheader='yes'; |
|
} else { |
} else { |
$ENV{'form.url'}=''; |
$env{'form.url'}=''; |
} |
} |
|
|
my $id=$ENV{'form.id'}; |
my $id=$env{'form.id'}; |
if (($id) && ($udom)) { |
if (($id) && ($udom)) { |
$uname=(&Apache::lonnet::idget($udom,$id))[1]; |
$uname=(&Apache::lonnet::idget($udom,$id))[1]; |
if ($uname) { |
if ($uname) { |
Line 759 sub assessparms {
|
Line 1165 sub assessparms {
|
&mt('at domain')." '$udom'</font>"; |
&mt('at domain')." '$udom'</font>"; |
} |
} |
} else { |
} else { |
$uname=$ENV{'form.uname'}; |
$uname=$env{'form.uname'}; |
} |
} |
unless ($udom) { $uname=''; } |
unless ($udom) { $uname=''; } |
$uhome=''; |
$uhome=''; |
Line 772 sub assessparms {
|
Line 1178 sub assessparms {
|
$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="<font color=red>". |
&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")."</font>"; |
$uname=''; |
$uname=''; |
$csec=$ENV{'form.csec'}; |
$csec=$env{'form.csec'}; |
} else { |
} else { |
my %name=&Apache::lonnet::userenvironment($udom,$uname, |
my %name=&Apache::lonnet::userenvironment($udom,$uname, |
('firstname','middlename','lastname','generation','id')); |
('firstname','middlename','lastname','generation','id')); |
Line 792 sub assessparms {
|
Line 1198 sub assessparms {
|
|
|
unless ($csec) { $csec=''; } |
unless ($csec) { $csec=''; } |
|
|
my $fcat=$ENV{'form.fcat'}; |
|
unless ($fcat) { $fcat=''; } |
|
|
|
# ------------------------------------------------------------------- Tie hashs |
|
if (!(tie(%bighash,'GDBM_File',$ENV{'request.course.fn'}.'.db', |
|
&GDBM_READER(),0640))) { |
|
$r->print("Unable to access course data. (File $ENV{'request.course.fn'}.db not tieable)"); |
|
return ; |
|
} |
|
if (!(tie(%parmhash,'GDBM_File', |
|
$ENV{'request.course.fn'}.'_parms.db',&GDBM_READER(),0640))) { |
|
$r->print("Unable to access parameter data. (File $ENV{'request.course.fn'}_parms.db not tieable)"); |
|
return ; |
|
} |
|
|
|
# --------------------------------------------------------- Get all assessments |
# --------------------------------------------------------- Get all assessments |
extractResourceInformation(\%bighash, \@ids, \%typep,\%keyp, \%allparms, \%allparts, \%allkeys, \%allmaps, $fcat, \%defp, \%mapp, \%symbp,\%maptitles); |
&extractResourceInformation(\@ids, \%typep,\%keyp, \%allparms, \%allparts, \%allmaps, |
|
\%mapp, \%symbp,\%maptitles,\%uris, |
|
\%keyorder); |
|
|
$mapp{'0.0'} = ''; |
$mapp{'0.0'} = ''; |
$symbp{'0.0'} = ''; |
$symbp{'0.0'} = ''; |
|
|
# ---------------------------------------------------------- Anything to store? |
# ---------------------------------------------------------- Anything to store? |
if ($ENV{'form.pres_marker'}) { |
if ($env{'form.pres_marker'}) { |
my ($sresid,$spnam,$snum)=split(/\&/,$ENV{'form.pres_marker'}); |
my @markers=split(/\&\&\&/,$env{'form.pres_marker'}); |
$spnam=~s/\_([^\_]+)$/\.$1/; |
my @values=split(/\&\&\&/,$env{'form.pres_value'}); |
# ---------------------------------------------------------- Construct prefixes |
my @types=split(/\&\&\&/,$env{'form.pres_type'}); |
|
for (my $i=0;$i<=$#markers;$i++) { |
my $symbparm=$symbp{$sresid}.'.'.$spnam; |
$message.=&storeparm(split(/\&/,$markers[$i]), |
my $mapparm=$mapp{$sresid}.'___(all).'.$spnam; |
$values[$i], |
|
$types[$i], |
my $seclevel=$ENV{'request.course.id'}.'.['.$csec.'].'.$spnam; |
$uname,$udom,$csec); |
my $seclevelr=$ENV{'request.course.id'}.'.['.$csec.'].'.$symbparm; |
|
my $seclevelm=$ENV{'request.course.id'}.'.['.$csec.'].'.$mapparm; |
|
|
|
my $courselevel=$ENV{'request.course.id'}.'.'.$spnam; |
|
my $courselevelr=$ENV{'request.course.id'}.'.'.$symbparm; |
|
my $courselevelm=$ENV{'request.course.id'}.'.'.$mapparm; |
|
|
|
my $storeunder=''; |
|
if (($snum==9) || ($snum==3)) { $storeunder=$courselevel; } |
|
if (($snum==8) || ($snum==2)) { $storeunder=$courselevelm; } |
|
if (($snum==7) || ($snum==1)) { $storeunder=$courselevelr; } |
|
if ($snum==6) { $storeunder=$seclevel; } |
|
if ($snum==5) { $storeunder=$seclevelm; } |
|
if ($snum==4) { $storeunder=$seclevelr; } |
|
|
|
my $delete; |
|
if ($ENV{'form.pres_value'} eq '') { $delete=1;} |
|
my %storecontent = ($storeunder => $ENV{'form.pres_value'}, |
|
$storeunder.'.type' => $ENV{'form.pres_type'}); |
|
my $reply=''; |
|
if ($snum>3) { |
|
# ---------------------------------------------------------------- Store Course |
|
# |
|
# Expire sheets |
|
&Apache::lonnet::expirespread('','','studentcalc'); |
|
if (($snum==7) || ($snum==4)) { |
|
&Apache::lonnet::expirespread('','','assesscalc',$symbp{$sresid}); |
|
} elsif (($snum==8) || ($snum==5)) { |
|
&Apache::lonnet::expirespread('','','assesscalc',$mapp{$sresid}); |
|
} else { |
|
&Apache::lonnet::expirespread('','','assesscalc'); |
|
} |
|
# Store parameter |
|
if ($delete) { |
|
$reply=&Apache::lonnet::del |
|
('resourcedata',[keys(%storecontent)], |
|
$ENV{'course.'.$ENV{'request.course.id'}.'.domain'}, |
|
$ENV{'course.'.$ENV{'request.course.id'}.'.num'}); |
|
} else { |
|
$reply=&Apache::lonnet::cput |
|
('resourcedata',\%storecontent, |
|
$ENV{'course.'.$ENV{'request.course.id'}.'.domain'}, |
|
$ENV{'course.'.$ENV{'request.course.id'}.'.num'}); |
|
} |
|
} else { |
|
# ------------------------------------------------------------------ Store User |
|
# |
|
# Expire sheets |
|
&Apache::lonnet::expirespread($uname,$udom,'studentcalc'); |
|
if ($snum==1) { |
|
&Apache::lonnet::expirespread |
|
($uname,$udom,'assesscalc',$symbp{$sresid}); |
|
} elsif ($snum==2) { |
|
&Apache::lonnet::expirespread |
|
($uname,$udom,'assesscalc',$mapp{$sresid}); |
|
} else { |
|
&Apache::lonnet::expirespread($uname,$udom,'assesscalc'); |
|
} |
|
# Store parameter |
|
if ($delete) { |
|
$reply=&Apache::lonnet::del |
|
('resourcedata',[keys(%storecontent)],$udom,$uname); |
|
} else { |
|
$reply=&Apache::lonnet::cput |
|
('resourcedata',\%storecontent,$udom,$uname); |
|
} |
|
} |
|
|
|
if ($reply=~/^error\:(.*)/) { |
|
$message.="<font color=red>Write Error: $1</font>"; |
|
} |
} |
# ---------------------------------------------------------------- Done storing |
# ---------------------------------------------------------------- Done storing |
$message.='<h3>'.&mt('Changes can take up to 10 minutes before being active for all students.').&Apache::loncommon::help_open_topic('Caching').'</h3>'; |
$message.='<h3>'.&mt('Changes can take up to 10 minutes before being active for all students.').&Apache::loncommon::help_open_topic('Caching').'</h3>'; |
} |
} |
# --------------------------------------------- Devalidate cache for this child |
|
&Apache::lonnet::devalidatecourseresdata( |
|
$ENV{'course.'.$ENV{'request.course.id'}.'.num'}, |
|
$ENV{'course.'.$ENV{'request.course.id'}.'.domain'}); |
|
&Apache::lonnet::clear_EXT_cache_status(); |
|
# -------------------------------------------------------------- Get coursedata |
|
%courseopt = &Apache::lonnet::dump |
|
('resourcedata', |
|
$ENV{'course.'.$ENV{'request.course.id'}.'.domain'}, |
|
$ENV{'course.'.$ENV{'request.course.id'}.'.num'}); |
|
# --------------------------------------------------- Get userdata (if present) |
|
if ($uname) { |
|
%useropt=&Apache::lonnet::dump('resourcedata',$udom,$uname); |
|
} |
|
|
|
# ------------------------------------------------------------------- Sort this |
|
|
|
@ids=sort { |
|
if ($fcat eq '') { |
|
$a<=>$b; |
|
} else { |
|
my ($result,@outpar)=&parmval($fcat,$a,$defp{$a}); |
|
my $aparm=$outpar[$result]; |
|
($result,@outpar)=&parmval($fcat,$b,$defp{$b}); |
|
my $bparm=$outpar[$result]; |
|
1*$aparm<=>1*$bparm; |
|
} |
|
} @ids; |
|
#----------------------------------------------- if all selected, fill in array |
#----------------------------------------------- if all selected, fill in array |
if ($pscat[0] eq "all" || !@pscat) {@pscat = (keys %allparms);} |
if ($pscat[0] eq "all") {@pscat = (keys %allparms);} |
|
if (!@pscat) { @pscat=('duedate','opendate','answerdate','weight','maxtries') }; |
if ($psprt[0] eq "all" || !@psprt) {@psprt = (keys %allparts);} |
if ($psprt[0] eq "all" || !@psprt) {@psprt = (keys %allparts);} |
# ------------------------------------------------------------------ Start page |
# ------------------------------------------------------------------ Start page |
|
|
my $have_assesments=1; |
&startpage($r); |
if (scalar(keys(%allkeys)) eq 0) { $have_assesments=0; } |
|
|
|
&startpage($r,$id,$udom,$csec,$uname,$have_assesments,$trimheader); |
|
|
|
if (!$have_assesments) { |
|
untie(%bighash); |
|
untie(%parmhash); |
|
return ''; |
|
} |
|
# if ($ENV{'form.url'}) { |
|
# $r->print('<input type="hidden" value="'.$ENV{'form.url'}. |
|
# '" name="url"><input type="hidden" name="command" value="set">'); |
|
# } |
|
$r->print('<input type="hidden" value="true" name="prevvisit">'); |
|
|
|
foreach ('tolerance','date_default','date_start','date_end', |
foreach ('tolerance','date_default','date_start','date_end', |
'date_interval','int','float','string') { |
'date_interval','int','float','string') { |
$r->print('<input type="hidden" value="'. |
$r->print('<input type="hidden" value="'. |
$ENV{'form.recent_'.$_}.'" name="recent_'.$_.'">'); |
$env{'form.recent_'.$_}.'" name="recent_'.$_.'">'); |
} |
} |
|
|
$r->print('<h2>'.$message.'</h2><table>'); |
|
|
|
my $submitmessage = &mt('Update Section or Specific User'); |
|
if (!$pssymb) { |
if (!$pssymb) { |
$r->print('<tr><td>'.&mt('Select Parameter Level'). |
$r->print('<table border="1"><tr><td>'); |
&Apache::loncommon::help_open_topic('Course_Parameter_Levels'). |
&levelmenu($r,\%alllevs,$parmlev); |
'</td><td colspan="2">'); |
|
$r->print('<select name="parmlev">'); |
|
foreach (reverse sort keys %alllevs) { |
|
$r->print('<option value="'.$alllevs{$_}.'"'); |
|
if ($parmlev eq $alllevs{$_}) { |
|
$r->print(' selected'); |
|
} |
|
$r->print('>'.$_.'</option>'); |
|
} |
|
$r->print("</select></td>\n"); |
|
|
|
$r->print('</tr>'); |
|
if ($parmlev ne 'general') { |
if ($parmlev ne 'general') { |
$r->print('<tr><td>'.&mt('Select Enclosing Map or Folder').'</td>'); |
$r->print('<td>'); |
$r->print('<td colspan="2"><select name="pschp">'); |
&mapmenu($r,\%allmaps,$pschp,\%maptitles); |
$r->print('<option value="all">'.&mt('All Maps or Folders').'</option>'); |
$r->print('</td>'); |
foreach (sort {$allmaps{$a} cmp $allmaps{$b}} keys %allmaps) { |
|
$r->print('<option value="'.$_.'"'); |
|
if (($pschp eq $_)) { $r->print(' selected'); } |
|
$r->print('>'.$maptitles{$_}.($allmaps{$_}!~/^uploaded/?' ['.$allmaps{$_}.']':'').'</option>'); |
|
} |
|
$r->print("</select></td></tr>\n"); |
|
} |
} |
|
$r->print('</td></tr></table>'); |
|
&displaymenu($r,\%allparms,\%allparts,\@pscat,\@psprt,\%keyorder); |
} else { |
} else { |
my ($map,$id,$resource)=&Apache::lonnet::decode_symb($pssymb); |
my ($map,$id,$resource)=&Apache::lonnet::decode_symb($pssymb); |
$r->print("<tr><td>".&mt('Specific Resource')."</td><td>$resource</td>"); |
$r->print(&mt('Specific Resource').": ".$resource. |
$r->print('<td><input type="submit" name="dis" value="'.$submitmessage.'"></td>'); |
'<input type="hidden" value="'.$pssymb.'" name="symb"><br />'); |
$r->print('</tr>'); |
|
$r->print('<input type="hidden" value="'.$pssymb.'" name="symb">'); |
|
} |
|
|
|
$r->print('<tr><td colspan="3"><hr /><input type="checkbox"'); |
|
if ($showoptions eq 'show') {$r->print(" checked ");} |
|
$r->print(' name="showoptions" value="show">'.&mt('Show More Options').'<hr /></td></tr>'); |
|
# $r->print("<tr><td>Show: $showoptions</td></tr>"); |
|
# $r->print("<tr><td>pscat: @pscat</td></tr>"); |
|
# $r->print("<tr><td>psprt: @psprt</td></tr>"); |
|
# $r->print("<tr><td>fcat: $fcat</td></tr>"); |
|
|
|
if ($showoptions eq 'show') { |
|
my $tempkey; |
|
|
|
$r->print('<tr><td colspan="3" align="center">'.&mt('Select Parameters to View').'</td></tr>'); |
|
|
|
$r->print('<tr><td colspan="2"><table><tr>'); |
|
my $cnt=0; |
|
foreach $tempkey (sort { $allparms{$a} cmp $allparms{$b} } |
|
keys %allparms ) { |
|
++$cnt; |
|
$r->print('</tr><tr>') if ($cnt%2); |
|
$r->print('<td><input type="checkbox" name="pscat" '); |
|
$r->print('value="'.$tempkey.'"'); |
|
if ($pscat[0] eq "all" || grep $_ eq $tempkey, @pscat) { |
|
$r->print(' checked'); |
|
} |
|
$r->print('>'.$allparms{$tempkey}.'</td>'); |
|
} |
|
$r->print(' |
|
</tr><tr><td> |
|
<script type="text/javascript"> |
|
function checkall(value, checkName) { |
|
for (i=0; i<document.forms.parmform.elements.length; i++) { |
|
ele = document.forms.parmform.elements[i]; |
|
if (ele.name == checkName) { |
|
document.forms.parmform.elements[i].checked=value; |
|
} |
|
} |
|
} |
} |
</script> |
&usermenu($r,$uname,$id,$udom,$csec); |
<input type="button" onclick="checkall(true, \'pscat\')" value="Select All" /> |
|
</td><td> |
|
<input type="button" onclick="checkall(false, \'pscat\')" value="Unselect All" /> |
|
</td> |
|
'); |
|
$r->print('</tr></table>'); |
|
|
|
# $r->print('<tr><td>Select Parts</td><td>'); |
$r->print('<p>'.$message.'</p>'); |
$r->print('<td><select multiple name="psprt" size="5">'); |
|
$r->print('<option value="all"'); |
|
$r->print(' selected') unless (@psprt); |
|
$r->print('>'.&mt('All Parts').'</option>'); |
|
my %temphash=(); |
|
foreach (@psprt) { $temphash{$_}=1; } |
|
foreach $tempkey (sort keys %allparts) { |
|
unless ($tempkey =~ /\./) { |
|
$r->print('<option value="'.$tempkey.'"'); |
|
if ($psprt[0] eq "all" || $temphash{$tempkey}) { |
|
$r->print(' selected'); |
|
} |
|
$r->print('>'.$allparts{$tempkey}.'</option>'); |
|
} |
|
} |
|
$r->print('</select></td></tr><tr><td colspan="3"><hr /></td></tr>'); |
|
|
|
$r->print('<tr><td>'.&mt('Sort list by').'</td><td>'); |
|
$r->print('<select name="fcat">'); |
|
$r->print('<option value="">'.&mt('Enclosing Map or Folder').'</option>'); |
|
foreach (sort keys %allkeys) { |
|
$r->print('<option value="'.$_.'"'); |
|
if ($fcat eq $_) { $r->print(' selected'); } |
|
$r->print('>'.$allkeys{$_}.'</option>'); |
|
} |
|
$r->print('</select></td>'); |
|
|
|
$r->print('</tr><tr><td colspan="3"><hr /></td></tr>'); |
$r->print('<br /><input type="submit" name="dis" value="'.&mt("Update Parameter Display").'" />'); |
|
|
} else { # hide options - include any necessary extras here |
|
|
|
$r->print('<input type="hidden" name="fcat" value="'.$fcat.'">'."\n"); |
|
|
|
unless (@pscat) { |
|
foreach (keys %allparms ) { |
|
$r->print('<input type="hidden" name="pscat" value="'.$_.'">'."\n"); |
|
} |
|
} else { |
|
foreach (@pscat) { |
|
$r->print('<input type="hidden" name="pscat" value="'.$_.'">'."\n"); |
|
} |
|
} |
|
|
|
unless (@psprt) { |
|
foreach (keys %allparts ) { |
|
$r->print('<input type="hidden" name="psprt" value="'.$_.'">'."\n"); |
|
} |
|
} else { |
|
foreach (@psprt) { |
|
$r->print('<input type="hidden" name="psprt" value="'.$_.'">'."\n"); |
|
} |
|
} |
|
|
|
} |
|
$r->print('</table><br />'); |
|
if (($prevvisit) || ($pschp) || ($pssymb)) { |
|
$submitmessage = &mt("Update Course Assessment Parameter Display"); |
|
} else { |
|
$submitmessage = &mt("Set/Modify Course Assessment Parameters"); |
|
} |
|
$r->print('<input type="submit" name="dis" value="'.$submitmessage.'">'); |
|
|
|
# my @temp_psprt; |
|
# foreach my $t (@psprt) { |
|
# push(@temp_psprt, grep {eval (/^$t\./ || ($_ == $t))} (keys %allparts)); |
|
# } |
|
|
|
# @psprt = @temp_psprt; |
|
|
|
my @temp_pscat; |
my @temp_pscat; |
map { |
map { |
Line 1112 sub assessparms {
|
Line 1263 sub assessparms {
|
|
|
@pscat = @temp_pscat; |
@pscat = @temp_pscat; |
|
|
if (($prevvisit) || ($pschp) || ($pssymb)) { |
if (($env{'form.prevvisit'}) || ($pschp) || ($pssymb)) { |
# ----------------------------------------------------------------- Start Table |
# ----------------------------------------------------------------- Start Table |
my @catmarker=map { tr|.|_|; 'parameter_'.$_; } @pscat; |
my @catmarker=map { tr|.|_|; 'parameter_'.$_; } @pscat; |
my $csuname=$ENV{'user.name'}; |
my $csuname=$env{'user.name'}; |
my $csudom=$ENV{'user.domain'}; |
my $csudom=$env{'user.domain'}; |
|
|
if ($parmlev eq 'full' || $parmlev eq 'brief') { |
if ($parmlev eq 'full') { |
my $coursespan=$csec?8:5; |
my $coursespan=$csec?8:5; |
$r->print('<p><table border=2>'); |
$r->print('<p><table border=2>'); |
$r->print('<tr><td colspan=5></td>'); |
$r->print('<tr><td colspan=5></td>'); |
Line 1147 sub assessparms {
|
Line 1298 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{'rl'}</th> |
</tr><tr><td colspan=5></td><th colspan=2>$lt{'ic'}</th><th colspan=2>$lt{'rl'}</th> |
<th colspan=3>$lt{'ic'}</th> |
<th colspan=1>$lt{'ic'}</th> |
|
|
ENDTABLETWO |
ENDTABLETWO |
if ($csec) { |
if ($csec) { |
$r->print("<th colspan=3>". |
$r->print("<th colspan=3>". |
Line 1157 ENDTABLETWO
|
Line 1309 ENDTABLETWO
|
$r->print(<<ENDTABLEHEADFOUR); |
$r->print(<<ENDTABLEHEADFOUR); |
</tr><tr><th>$lt{'aut'}</th><th>$lt{'type'}</th> |
</tr><tr><th>$lt{'aut'}</th><th>$lt{'type'}</th> |
<th>$lt{'emof'}</th><th>$lt{'part'}</th><th>$lt{'pn'}</th> |
<th>$lt{'emof'}</th><th>$lt{'part'}</th><th>$lt{'pn'}</th> |
<th>$lt{'def'}</th><th>$lt{'femof'}</th> |
<th>$lt{'gen'}</th><th>$lt{'foremf'}</th> |
<th>$lt{'gen'}</th><th>$lt{'foremf'}</th><th>$lt{'fr'}</th> |
<th>$lt{'def'}</th><th>$lt{'femof'}</th><th>$lt{'fr'}</th> |
ENDTABLEHEADFOUR |
ENDTABLEHEADFOUR |
|
|
if ($csec) { |
if ($csec) { |
Line 1184 ENDTABLEHEADFOUR
|
Line 1336 ENDTABLEHEADFOUR
|
|| |
|| |
($pssymb && $pssymb eq $symbp{$rid})) { |
($pssymb && $pssymb eq $symbp{$rid})) { |
# ------------------------------------------------------ Entry for one resource |
# ------------------------------------------------------ Entry for one resource |
if ($defbgone eq '"E0E099"') { |
if ($defbgone eq '"#E0E099"') { |
$defbgone='"E0E0DD"'; |
$defbgone='"#E0E0DD"'; |
} else { |
} else { |
$defbgone='"E0E099"'; |
$defbgone='"#E0E099"'; |
} |
} |
if ($defbgtwo eq '"FFFF99"') { |
if ($defbgtwo eq '"#FFFF99"') { |
$defbgtwo='"FFFFDD"'; |
$defbgtwo='"#FFFFDD"'; |
} else { |
} else { |
$defbgtwo='"FFFF99"'; |
$defbgtwo='"#FFFF99"'; |
} |
} |
my $thistitle=''; |
my $thistitle=''; |
my %name= (); |
my %name= (); |
Line 1201 ENDTABLEHEADFOUR
|
Line 1353 ENDTABLEHEADFOUR
|
my %display=(); |
my %display=(); |
my %type= (); |
my %type= (); |
my %default=(); |
my %default=(); |
my $uri=&Apache::lonnet::declutter($bighash{'src_'.$rid}); |
my $uri=&Apache::lonnet::declutter($uris{$rid}); |
|
|
foreach (split(/\,/,$keyp{$rid})) { |
foreach (&keysplit($keyp{$rid})) { |
my $tempkeyp = $_; |
my $tempkeyp = $_; |
if (grep $_ eq $tempkeyp, @catmarker) { |
if (grep $_ eq $tempkeyp, @catmarker) { |
$part{$_}=&Apache::lonnet::metadata($uri,$_.'.part'); |
$part{$_}=&Apache::lonnet::metadata($uri,$_.'.part'); |
Line 1219 ENDTABLEHEADFOUR
|
Line 1371 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=$bighash{'title_'.$rid}; |
my $title=&Apache::lonnet::gettitle($uri); |
$title=~s/\:/:/g; |
|
$r->print('<tr><td bgcolor='.$defbgone. |
$r->print('<tr><td bgcolor='.$defbgone. |
' rowspan='.$totalparms. |
' rowspan='.$totalparms. |
'><tt><font size=-1>'. |
'><tt><font size=-1>'. |
Line 1248 ENDTABLEHEADFOUR
|
Line 1399 ENDTABLEHEADFOUR
|
|
|
$r->print('</font></tt></td>'); |
$r->print('</font></tt></td>'); |
|
|
foreach (sort keys %name) { |
foreach (&keysinorder(\%name,\%keyorder)) { |
unless ($firstrow) { |
unless ($firstrow) { |
$r->print('<tr>'); |
$r->print('<tr>'); |
} else { |
} else { |
undef $firstrow; |
undef $firstrow; |
} |
} |
|
|
&print_row($r,$_,\%part,\%name,$rid,\%default, |
&print_row($r,$_,\%part,\%name,\%symbp,$rid,\%default, |
\%type,\%display,$defbgone,$defbgtwo, |
\%type,\%display,$defbgone,$defbgtwo, |
$parmlev); |
$parmlev,$uname,$udom,$csec); |
} |
} |
} |
} |
} |
} |
} # end foreach ids |
} # end foreach ids |
# -------------------------------------------------- End entry for one resource |
# -------------------------------------------------- End entry for one resource |
$r->print('</table>'); |
$r->print('</table>'); |
} # end of brief/full |
} # end of full |
#--------------------------------------------------- Entry for parm level map |
#--------------------------------------------------- Entry for parm level map |
if ($parmlev eq 'map') { |
if ($parmlev eq 'map') { |
my $defbgone = '"E0E099"'; |
my $defbgone = '"E0E099"'; |
Line 1301 ENDTABLEHEADFOUR
|
Line 1452 ENDTABLEHEADFOUR
|
# $r->print("$mapid:$map: $rid <br /> \n"); |
# $r->print("$mapid:$map: $rid <br /> \n"); |
|
|
if ($map eq $mapid) { |
if ($map eq $mapid) { |
my $uri=&Apache::lonnet::declutter($bighash{'src_'.$rid}); |
my $uri=&Apache::lonnet::declutter($uris{$rid}); |
# $r->print("Keys: $keyp{$rid} <br />\n"); |
# $r->print("Keys: $keyp{$rid} <br />\n"); |
|
|
#-------------------------------------------------------------------- |
#-------------------------------------------------------------------- |
Line 1311 ENDTABLEHEADFOUR
|
Line 1462 ENDTABLEHEADFOUR
|
# When storing information, store as part 0 |
# When storing information, store as part 0 |
# When requesting information, request from full part |
# When requesting information, request from full part |
#------------------------------------------------------------------- |
#------------------------------------------------------------------- |
foreach (split(/\,/,$keyp{$rid})) { |
foreach (&keysplit($keyp{$rid})) { |
my $tempkeyp = $_; |
my $tempkeyp = $_; |
my $fullkeyp = $tempkeyp; |
my $fullkeyp = $tempkeyp; |
$tempkeyp =~ s/_\w+_/_0_/; |
$tempkeyp =~ s/_\w+_/_0_/; |
Line 1361 ENDMAPONE
|
Line 1512 ENDMAPONE
|
$r->print('<th>'.&mt('Default Value').'</th>'); |
$r->print('<th>'.&mt('Default Value').'</th>'); |
$r->print('<th>'.&mt('Parameter in Effect').'</th></tr>'); |
$r->print('<th>'.&mt('Parameter in Effect').'</th></tr>'); |
|
|
foreach (sort keys %name) { |
foreach (&keysinorder(\%name,\%keyorder)) { |
$r->print('<tr>'); |
$r->print('<tr>'); |
&print_row($r,$_,\%part,\%name,$mapid,\%default, |
&print_row($r,$_,\%part,\%name,\%symbp,$mapid,\%default, |
\%type,\%display,$defbgone,$defbgtwo, |
\%type,\%display,$defbgone,$defbgtwo, |
$parmlev); |
$parmlev,$uname,$udom,$csec); |
# $r->print("<tr><td>resource.$part{$_}.$name{$_},$symbp{$mapid}</td></tr>\n"); |
|
} |
} |
$r->print("</table></center>"); |
$r->print("</table></center>"); |
} # end each map |
} # end each map |
Line 1389 ENDMAPONE
|
Line 1539 ENDMAPONE
|
foreach (@ids) { |
foreach (@ids) { |
my $rid = $_; |
my $rid = $_; |
|
|
my $uri=&Apache::lonnet::declutter($bighash{'src_'.$rid}); |
my $uri=&Apache::lonnet::declutter($uris{$rid}); |
|
|
#-------------------------------------------------------------------- |
#-------------------------------------------------------------------- |
# @catmarker contains list of all possible parameters including part #s |
# @catmarker contains list of all possible parameters including part #s |
Line 1398 ENDMAPONE
|
Line 1548 ENDMAPONE
|
# When storing information, store as part 0 |
# When storing information, store as part 0 |
# When requesting information, request from full part |
# When requesting information, request from full part |
#------------------------------------------------------------------- |
#------------------------------------------------------------------- |
foreach (split(/\,/,$keyp{$rid})) { |
foreach (&keysplit($keyp{$rid})) { |
my $tempkeyp = $_; |
my $tempkeyp = $_; |
my $fullkeyp = $tempkeyp; |
my $fullkeyp = $tempkeyp; |
$tempkeyp =~ s/_\w+_/_0_/; |
$tempkeyp =~ s/_\w+_/_0_/; |
Line 1439 ENDMAPONE
|
Line 1589 ENDMAPONE
|
$r->print('<th>'.&mt('Default Value').'</th>'); |
$r->print('<th>'.&mt('Default Value').'</th>'); |
$r->print('<th>'.&mt('Parameter in Effect').'</th></tr>'); |
$r->print('<th>'.&mt('Parameter in Effect').'</th></tr>'); |
|
|
foreach (sort keys %name) { |
foreach (&keysinorder(\%name,\%keyorder)) { |
$r->print('<tr>'); |
$r->print('<tr>'); |
&print_row($r,$_,\%part,\%name,$mapid,\%default, |
&print_row($r,$_,\%part,\%name,\%symbp,$mapid,\%default, |
\%type,\%display,$defbgone,$defbgtwo,$parmlev); |
\%type,\%display,$defbgone,$defbgtwo,$parmlev,$uname,$udom,$csec); |
# $r->print("<tr><td>resource.$part{$_}.$name{$_},$symbp{$mapid}</td></tr>\n"); |
|
} |
} |
$r->print("</table></center>"); |
$r->print("</table></center>"); |
} # end of $parmlev eq general |
} # end of $parmlev eq general |
} |
} |
$r->print('</form></body></html>'); |
$r->print('</form></body></html>'); |
untie(%bighash); |
|
untie(%parmhash); |
|
} # end sub assessparms |
} # end sub assessparms |
|
|
|
|
Line 1477 sub crsenv {
|
Line 1624 sub crsenv {
|
my $setoutput=''; |
my $setoutput=''; |
my $bodytag=&Apache::loncommon::bodytag( |
my $bodytag=&Apache::loncommon::bodytag( |
'Set Course Environment Parameters'); |
'Set Course Environment Parameters'); |
my $dom = $ENV{'course.'.$ENV{'request.course.id'}.'.domain'}; |
my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs(undef, |
my $crs = $ENV{'course.'.$ENV{'request.course.id'}.'.num'}; |
'Edit Course Environment'); |
|
my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'}; |
|
my $crs = $env{'course.'.$env{'request.course.id'}.'.num'}; |
|
|
# |
# |
# Go through list of changes |
# Go through list of changes |
foreach (keys %ENV) { |
foreach (keys %env) { |
next if ($_!~/^form\.(.+)\_setparmval$/); |
next if ($_!~/^form\.(.+)\_setparmval$/); |
my $name = $1; |
my $name = $1; |
my $value = $ENV{'form.'.$name.'_value'}; |
my $value = $env{'form.'.$name.'_value'}; |
if ($name eq 'newp') { |
if ($name eq 'newp') { |
$name = $ENV{'form.newp_name'}; |
$name = $env{'form.newp_name'}; |
} |
} |
if ($name eq 'url') { |
if ($name eq 'url') { |
$value=~s/^\/res\///; |
$value=~s/^\/res\///; |
Line 1527 sub crsenv {
|
Line 1676 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'); |
} |
} |
|
# Get existing cloners |
|
my @oldcloner = (); |
|
if ($name eq 'cloners') { |
|
my %clonenames=&Apache::lonnet::dump('environment',$dom,$crs,'cloners'); |
|
if ($clonenames{'cloners'} =~ /,/) { |
|
@oldcloner = split/,/,$clonenames{'cloners'}; |
|
} else { |
|
$oldcloner[0] = $clonenames{'cloners'}; |
|
} |
|
} |
# |
# |
# Let the user know we made the changes |
# Let the user know we made the changes |
if ($name && defined($value)) { |
if ($name && defined($value)) { |
|
if ($name eq 'cloners') { |
|
$value =~ s/^,//; |
|
$value =~ s/,$//; |
|
} |
my $put_result = &Apache::lonnet::put('environment', |
my $put_result = &Apache::lonnet::put('environment', |
{$name=>$value},$dom,$crs); |
{$name=>$value},$dom,$crs); |
if ($put_result eq 'ok') { |
if ($put_result eq 'ok') { |
$setoutput.=&mt('Set').' <b>'.$name.'</b> '.&mt('to').' <b>'.$value.'</b>.<br />'; |
$setoutput.=&mt('Set').' <b>'.$name.'</b> '.&mt('to').' <b>'.$value.'</b>.<br />'; |
|
if ($name eq 'cloners') { |
|
&change_clone($value,\@oldcloner); |
|
} |
|
# Flush the course logs so course description is immediately updated |
|
if ($name eq 'description' && defined($value)) { |
|
&Apache::lonnet::flushcourselogs(); |
|
} |
} else { |
} else { |
$setoutput.=&mt('Unable to set').' <b>'.$name.'</b> '.&mt('to'). |
$setoutput.=&mt('Unable to set').' <b>'.$name.'</b> '.&mt('to'). |
' <b>'.$value.'</b> '.&mt('due to').' '.$put_result.'.<br />'; |
' <b>'.$value.'</b> '.&mt('due to').' '.$put_result.'.<br />'; |
Line 1542 sub crsenv {
|
Line 1712 sub crsenv {
|
} |
} |
# ------------------------- 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'}); |
|
|
# -------------------------------------------------------- Get parameters again |
# -------------------------------------------------------- Get parameters again |
|
|
Line 1562 sub crsenv {
|
Line 1732 sub crsenv {
|
'courseid' => '<b>'.&mt('Course ID or number'). |
'courseid' => '<b>'.&mt('Course ID or number'). |
'</b><br />'. |
'</b><br />'. |
'('.&mt('internal').', '.&mt('optional').')', |
'('.&mt('internal').', '.&mt('optional').')', |
|
'cloners' => '<b>'.&mt('Users allowed to clone course').'</b><br /><tt>(user:domain,user:domain)</tt><br />'.&mt('Users with active Course Coordinator role in the course automatically have the right to clone it, and can be omitted from list.'), |
'grading' => '<b>'.&mt('Grading').'</b><br />'. |
'grading' => '<b>'.&mt('Grading').'</b><br />'. |
'<tt>"standard", "external", or "spreadsheet"</tt> '.&Apache::loncommon::help_open_topic('GradingOptions'), |
'<tt>"standard", "external", or "spreadsheet"</tt> '.&Apache::loncommon::help_open_topic('GradingOptions'), |
'default_xml_style' => '<b>'.&mt('Default XML Style File').'</b> '. |
'default_xml_style' => '<b>'.&mt('Default XML Style File').'</b> '. |
Line 1643 sub crsenv {
|
Line 1814 sub crsenv {
|
'anonymous_quiz' |
'anonymous_quiz' |
=> '<b>'.&mt('Anonymous quiz/exam').'</b><br />'. |
=> '<b>'.&mt('Anonymous quiz/exam').'</b><br />'. |
' (<tt><b>'.&mt('yes').'</b> '.&mt('to avoid print students names').' </tt>)', |
' (<tt><b>'.&mt('yes').'</b> '.&mt('to avoid print students names').' </tt>)', |
'default_enrollment_start_date' => '<b>'.&mt('Default beginning date when enrolling students').'</b>', |
'default_enrollment_start_date' => '<b>'.&mt('Default beginning date for student access.').'</b>', |
'default_enrollment_end_date' => '<b>'.&mt('Default ending date when enrolling students').'</b>', |
'default_enrollment_end_date' => '<b>'.&mt('Default ending date for student access.').'</b>', |
'nothideprivileged' => '<b>'.&mt('Privileged users that should not be hidden on staff listings').'</b>'. |
'nothideprivileged' => '<b>'.&mt('Privileged users that should not be hidden on staff listings').'</b>'. |
'<br />(<tt>user:domain,user:domain,...</tt>)', |
'<br />(<tt>user:domain,user:domain,...</tt>)', |
'languages' => '<b>'.&mt('Languages used').'</b>', |
'languages' => '<b>'.&mt('Languages used').'</b>', |
Line 1657 sub crsenv {
|
Line 1828 sub crsenv {
|
'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>' |
); |
); |
my @Display_Order = ('url','description','courseid','grading', |
my @Display_Order = ('url','description','courseid','cloners','grading', |
'default_xml_style','pageseparators', |
'default_xml_style','pageseparators', |
'question.email','comment.email','policy.email', |
'question.email','comment.email','policy.email', |
'student_classlist_view', |
'student_classlist_view', |
Line 1736 sub crsenv {
|
Line 1907 sub crsenv {
|
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=&Apache::loncommon::browser_and_searcher_javascript('parmset'); |
$r->print(<<ENDENV); |
my $html=&Apache::lonxml::xmlbegin(); |
<html> |
$r->print(<<ENDenv); |
|
$html |
|
<head> |
<script type="text/javascript" language="Javascript" > |
<script type="text/javascript" language="Javascript" > |
$browse_js |
$browse_js |
</script> |
</script> |
<head> |
|
<title>LON-CAPA Course Environment</title> |
<title>LON-CAPA Course Environment</title> |
</head> |
</head> |
$bodytag |
$bodytag |
<form method="post" action="/adm/parmset" name="envform"> |
$breadcrumbs |
|
<form method="post" action="/adm/parmset?action=crsenv" name="envform"> |
$setoutput |
$setoutput |
<p> |
<p> |
<table border=2> |
<table border=2> |
Line 1756 $output
|
Line 1929 $output
|
</form> |
</form> |
</body> |
</body> |
</html> |
</html> |
ENDENV |
ENDenv |
} |
} |
################################################## |
################################################## |
|
# Overview mode |
|
################################################## |
my $tableopen; |
my $tableopen; |
|
|
sub tablestart { |
sub tablestart { |
Line 1781 sub tableend {
|
Line 1955 sub tableend {
|
} |
} |
} |
} |
|
|
sub overview { |
sub readdata { |
my $r=shift; |
my ($crs,$dom)=@_; |
my $bodytag=&Apache::loncommon::bodytag( |
# Read coursedata |
'Set/Modify Course Assessment Parameters'); |
my $resourcedata=&Apache::lonnet::get_courseresdata($crs,$dom); |
my $dom = $ENV{'course.'.$ENV{'request.course.id'}.'.domain'}; |
# Read userdata |
my $crs = $ENV{'course.'.$ENV{'request.course.id'}.'.num'}; |
|
$r->print(<<ENDOVER); |
my $classlist=&Apache::loncoursedata::get_classlist(); |
<html> |
foreach (keys %$classlist) { |
<head> |
# the following undefs are for 'domain', and 'username' respectively. |
<title>LON-CAPA Course Environment</title> |
if ($_=~/^(\w+)\:(\w+)$/) { |
</head> |
my ($tuname,$tudom)=($1,$2); |
$bodytag |
my $useropt=&Apache::lonnet::get_userresdata($tuname,$tudom); |
<form method="post" action="/adm/parmset" name="overviewform"> |
foreach my $userkey (keys %{$useropt}) { |
<input type="hidden" name="overview" value="1" /> |
if ($userkey=~/^$env{'request.course.id'}/) { |
ENDOVER |
my $newkey=$userkey; |
|
$newkey=~s/^($env{'request.course.id'}\.)/$1\[useropt\:$tuname\:$tudom\]\./; |
|
$$resourcedata{$newkey}=$$useropt{$userkey}; |
|
} |
|
} |
|
} |
|
} |
|
return $resourcedata; |
|
} |
|
|
|
|
# Setting |
# Setting |
my %olddata=&Apache::lonnet::dump('resourcedata',$dom,$crs); |
|
|
sub storedata { |
|
my ($r,$crs,$dom)=@_; |
|
# Set userlevel immediately |
|
# Do an intermediate store of course level |
|
my $olddata=&readdata($crs,$dom); |
my %newdata=(); |
my %newdata=(); |
undef %newdata; |
undef %newdata; |
my @deldata=(); |
my @deldata=(); |
undef @deldata; |
undef @deldata; |
foreach (keys %ENV) { |
foreach (keys %env) { |
if ($_=~/^form\.([a-z]+)\_(.+)$/) { |
if ($_=~/^form\.([a-z]+)\_(.+)$/) { |
my $cmd=$1; |
my $cmd=$1; |
my $thiskey=$2; |
my $thiskey=$2; |
|
my ($tuname,$tudom)=&extractuser($thiskey); |
|
my $tkey=$thiskey; |
|
if ($tuname) { |
|
$tkey=~s/\.\[useropt\:$tuname\:$tudom\]\./\./; |
|
} |
if ($cmd eq 'set') { |
if ($cmd eq 'set') { |
my $data=$ENV{$_}; |
my $data=$env{$_}; |
if ($olddata{$thiskey} ne $data) { $newdata{$thiskey}=$data; } |
my $typeof=$env{'form.typeof_'.$thiskey}; |
|
if ($$olddata{$thiskey} ne $data) { |
|
if ($tuname) { |
|
if (&Apache::lonnet::put('resourcedata',{$tkey=>$data, |
|
$tkey.'.type' => $typeof}, |
|
$tudom,$tuname) eq 'ok') { |
|
$r->print('<br />'.&mt('Stored modified parameter for').' '. |
|
&Apache::loncommon::plainname($tuname,$tudom)); |
|
} else { |
|
$r->print('<h2><font color="red">'. |
|
&mt('Error storing parameters').'</font></h2>'); |
|
} |
|
&Apache::lonnet::devalidateuserresdata($tuname,$tudom); |
|
} else { |
|
$newdata{$thiskey}=$data; |
|
$newdata{$thiskey.'.type'}=$typeof; |
|
} |
|
} |
} elsif ($cmd eq 'del') { |
} elsif ($cmd eq 'del') { |
push (@deldata,$thiskey); |
if ($tuname) { |
|
if (&Apache::lonnet::del('resourcedata',[$tkey],$tudom,$tuname) eq 'ok') { |
|
$r->print('<br />'.&mt('Deleted parameter for').' '.&Apache::loncommon::plainname($tuname,$tudom)); |
|
} else { |
|
$r->print('<h2><font color="red">'. |
|
&mt('Error deleting parameters').'</font></h2>'); |
|
} |
|
&Apache::lonnet::devalidateuserresdata($tuname,$tudom); |
|
} else { |
|
push (@deldata,$thiskey); |
|
} |
} 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{$_}); |
if (defined($data) and $olddata{$thiskey} ne $data) { $newdata{$thiskey}=$data; } |
my $typeof=$env{'form.typeof_'.$thiskey}; |
|
if (defined($data) and $$olddata{$thiskey} ne $data) { |
|
if ($tuname) { |
|
if (&Apache::lonnet::put('resourcedata',{$tkey=>$data, |
|
$tkey.'.type' => $typeof}, |
|
$tudom,$tuname) eq 'ok') { |
|
$r->print('<br />'.&mt('Stored modified date for').' '.&Apache::loncommon::plainname($tuname,$tudom)); |
|
} else { |
|
$r->print('<h2><font color="red">'. |
|
&mt('Error storing parameters').'</font></h2>'); |
|
} |
|
&Apache::lonnet::devalidateuserresdata($tuname,$tudom); |
|
} else { |
|
$newdata{$thiskey}=$data; |
|
$newdata{$thiskey.'.type'}=$typeof; |
|
} |
|
} |
} |
} |
} |
} |
} |
} |
# Store |
# Store all course level |
my $delentries=$#deldata+1; |
my $delentries=$#deldata+1; |
my @newdatakeys=keys %newdata; |
my @newdatakeys=keys %newdata; |
my $putentries=$#newdatakeys+1; |
my $putentries=$#newdatakeys+1; |
Line 1828 ENDOVER
|
Line 2065 ENDOVER
|
$r->print('<h2><font color="red">'. |
$r->print('<h2><font color="red">'. |
&mt('Error deleting parameters').'</font></h2>'); |
&mt('Error deleting parameters').'</font></h2>'); |
} |
} |
|
&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('<h2>'.&mt('Stored [_1] parameter(s)</h2>',$putentries)); |
$r->print('<h3>'.&mt('Stored [_1] parameter(s)',$putentries/2).'</h3>'); |
} else { |
} else { |
$r->print('<h2><font color="red">'. |
$r->print('<h2><font color="red">'. |
&mt('Error storing parameters').'</font></h2>'); |
&mt('Error storing parameters').'</font></h2>'); |
} |
} |
|
&Apache::lonnet::devalidatecourseresdata($crs,$dom); |
} |
} |
# Read and display |
} |
my %resourcedata=&Apache::lonnet::dump('resourcedata',$dom,$crs); |
|
|
sub extractuser { |
|
my $key=shift; |
|
return ($key=~/^$env{'request.course.id'}.\[useropt\:(\w+)\:(\w+)\]\./); |
|
} |
|
|
|
sub listdata { |
|
my ($r,$resourcedata,$listdata,$sortorder)=@_; |
|
# Start list output |
|
|
my $oldsection=''; |
my $oldsection=''; |
my $oldrealm=''; |
my $oldrealm=''; |
my $oldpart=''; |
my $oldpart=''; |
my $pointer=0; |
my $pointer=0; |
$tableopen=0; |
$tableopen=0; |
my $foundkeys=0; |
my $foundkeys=0; |
foreach my $thiskey (sort keys %resourcedata) { |
foreach my $thiskey (sort { |
if ($resourcedata{$thiskey.'.type'}) { |
if ($sortorder eq 'realmstudent') { |
my ($course,$middle,$part,$name)= |
my ($astudent,$arealm)=($a=~/^$env{'request.course.id'}\.([^\.]+)\.(.+)\.[^\.]+$/); |
($thiskey=~/^(\w+)\.(?:(.+)\.)*([\w\s]+)\.(\w+)$/); |
my ($bstudent,$brealm)=($b=~/^$env{'request.course.id'}\.([^\.]+)\.(.+)\.[^\.]+$/); |
|
($arealm cmp $brealm) || ($astudent cmp $bstudent); |
|
} else { |
|
$a cmp $b; |
|
} |
|
} keys %{$listdata}) { |
|
if ($$listdata{$thiskey.'.type'}) { |
|
my $thistype=$$listdata{$thiskey.'.type'}; |
|
if ($$resourcedata{$thiskey.'.type'}) { |
|
$thistype=$$resourcedata{$thiskey.'.type'}; |
|
} |
|
my ($middle,$part,$name)= |
|
($thiskey=~/^$env{'request.course.id'}\.(?:(.+)\.)*([\w\s]+)\.(\w+)$/); |
my $section=&mt('All Students'); |
my $section=&mt('All Students'); |
if ($middle=~/^\[(.*)\]\./) { |
if ($middle=~/^\[(.*)\]/) { |
$section=&mt('Group/Section').': '.$1; |
my $issection=$1; |
$middle=~s/^\[(.*)\]\.//; |
if ($issection=~/^useropt\:(\w+)\:(\w+)/) { |
|
$section=&mt('User').": ".&Apache::loncommon::plainname($1,$2); |
|
} else { |
|
$section=&mt('Group/Section').': '.$issection; |
|
} |
|
$middle=~s/^\[(.*)\]//; |
} |
} |
$middle=~s/\.$//; |
$middle=~s/\.+$//; |
|
$middle=~s/^\.+//; |
my $realm='<font color="red">'.&mt('All Resources').'</font>'; |
my $realm='<font color="red">'.&mt('All Resources').'</font>'; |
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='<font color="green">'.&mt('Folder/Map').': '.&Apache::lonnet::gettitle($1).' <br /><font color="#aaaaaa" size="-2">('.$1.')</font></font>'; |
Line 1862 ENDOVER
|
Line 2128 ENDOVER
|
my ($map,$id,$url)=&Apache::lonnet::decode_symb($middle); |
my ($map,$id,$url)=&Apache::lonnet::decode_symb($middle); |
$realm='<font color="orange">'.&mt('Resource').': '.&Apache::lonnet::gettitle($middle).' <br /><font color="#aaaaaa" size="-2">('.$url.' in '.$map.' id: '.$id.')</font></font>'; |
$realm='<font color="orange">'.&mt('Resource').': '.&Apache::lonnet::gettitle($middle).' <br /><font color="#aaaaaa" size="-2">('.$url.' in '.$map.' id: '.$id.')</font></font>'; |
} |
} |
if ($section ne $oldsection) { |
if ($sortorder eq 'realmstudent') { |
$r->print(&tableend()."\n<hr /><h1>$section</h1>"); |
if ($realm ne $oldrealm) { |
$oldsection=$section; |
$r->print(&tableend()."\n<hr /><h1>$realm</h1>"); |
$oldrealm=''; |
$oldrealm=$realm; |
} |
$oldsection=''; |
if ($realm ne $oldrealm) { |
} |
$r->print(&tableend()."\n<h2>$realm</h2>"); |
if ($section ne $oldsection) { |
$oldrealm=$realm; |
$r->print(&tableend()."\n<h2>$section</h2>"); |
$oldpart=''; |
$oldsection=$section; |
|
$oldpart=''; |
|
} |
|
} else { |
|
if ($section ne $oldsection) { |
|
$r->print(&tableend()."\n<hr /><h1>$section</h1>"); |
|
$oldsection=$section; |
|
$oldrealm=''; |
|
} |
|
if ($realm ne $oldrealm) { |
|
$r->print(&tableend()."\n<h2>$realm</h2>"); |
|
$oldrealm=$realm; |
|
$oldpart=''; |
|
} |
} |
} |
if ($part ne $oldpart) { |
if ($part ne $oldpart) { |
$r->print(&tableend(). |
$r->print(&tableend(). |
"\n<h3><font color='blue'>".&mt('Part').": $part</font></h3>"); |
"\n<font color='blue'>".&mt('Part').": $part</font>"); |
$oldpart=$part; |
$oldpart=$part; |
} |
} |
# |
# |
Line 1884 ENDOVER
|
Line 2163 ENDOVER
|
':</b></td><td><input type="checkbox" name="del_'. |
':</b></td><td><input type="checkbox" name="del_'. |
$thiskey.'" /></td><td>'); |
$thiskey.'" /></td><td>'); |
$foundkeys++; |
$foundkeys++; |
if ($resourcedata{$thiskey.'.type'}=~/^date/) { |
if (&isdateparm($thistype)) { |
my $jskey='key_'.$pointer; |
my $jskey='key_'.$pointer; |
$pointer++; |
$pointer++; |
$r->print( |
$r->print( |
&Apache::lonhtmlcommon::date_setter('overviewform', |
&Apache::lonhtmlcommon::date_setter('overviewform', |
$jskey, |
$jskey, |
$resourcedata{$thiskey}). |
$$resourcedata{$thiskey}, |
|
'',1). |
'<input type="hidden" name="datepointer_'.$thiskey.'" value="'.$jskey.'" />' |
'<input type="hidden" name="datepointer_'.$thiskey.'" value="'.$jskey.'" />' |
); |
); |
|
} elsif ($thistype eq 'string_yesno') { |
|
$r->print('<label><input type="radio" name="set_'.$thiskey. |
|
'" value="yes"'); |
|
if ($$resourcedata{$thiskey} eq 'yes') { |
|
$r->print(' checked="checked"'); |
|
} |
|
$r->print(' />'.&mt('Yes').'</label> '); |
|
$r->print('<label><input type="radio" name="set_'.$thiskey. |
|
'" value="no"'); |
|
if ($$resourcedata{$thiskey} eq 'no') { |
|
$r->print(' checked="checked"'); |
|
} |
|
$r->print(' />'.&mt('No').'</label>'); |
} else { |
} else { |
$r->print( |
$r->print('<input type="text" name="set_'.$thiskey.'" value="'. |
'<input type="text" name="set_'.$thiskey.'" value="'. |
$$resourcedata{$thiskey}.'">'); |
$resourcedata{$thiskey}.'">'); |
|
} |
} |
|
$r->print('<input type="hidden" name="typeof_'.$thiskey.'" value="'. |
|
$thistype.'">'); |
$r->print('</td></tr>'); |
$r->print('</td></tr>'); |
} |
} |
} |
} |
|
return $foundkeys; |
|
} |
|
|
|
sub newoverview { |
|
my $r=shift; |
|
my $bodytag=&Apache::loncommon::bodytag('Set Parameters'); |
|
my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'}; |
|
my $crs = $env{'course.'.$env{'request.course.id'}.'.num'}; |
|
my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs(undef,'Overview'); |
|
my $html=&Apache::lonxml::xmlbegin(); |
|
$r->print(<<ENDOVER); |
|
$html |
|
<head> |
|
<title>LON-CAPA Parameters</title> |
|
</head> |
|
$bodytag |
|
$breadcrumbs |
|
<form method="post" action="/adm/parmset?action=newoverview" name="parmform"> |
|
ENDOVER |
|
my @ids=(); |
|
my %typep=(); |
|
my %keyp=(); |
|
my %allparms=(); |
|
my %allparts=(); |
|
my %allmaps=(); |
|
my %mapp=(); |
|
my %symbp=(); |
|
my %maptitles=(); |
|
my %uris=(); |
|
my %keyorder=&standardkeyorder(); |
|
my %defkeytype=(); |
|
|
|
my %alllevs=(); |
|
$alllevs{'Resource Level'}='full'; |
|
$alllevs{'Map/Folder Level'}='map'; |
|
$alllevs{'Course Level'}='general'; |
|
|
|
my $csec=$env{'form.csec'}; |
|
|
|
my @pscat=&Apache::loncommon::get_env_multiple('form.pscat'); |
|
my $pschp=$env{'form.pschp'}; |
|
my @psprt=&Apache::loncommon::get_env_multiple('form.psprt'); |
|
if (!@psprt) { $psprt[0]='0'; } |
|
|
|
my @selected_sections = |
|
&Apache::loncommon::get_env_multiple('form.Section'); |
|
@selected_sections = ('all') if (! @selected_sections); |
|
foreach (@selected_sections) { |
|
if ($_ eq 'all') { |
|
@selected_sections = ('all'); |
|
} |
|
} |
|
|
|
my $pssymb=''; |
|
my $parmlev=''; |
|
|
|
unless ($env{'form.parmlev'}) { |
|
$parmlev = 'map'; |
|
} else { |
|
$parmlev = $env{'form.parmlev'}; |
|
} |
|
|
|
&extractResourceInformation(\@ids, \%typep,\%keyp, \%allparms, \%allparts, \%allmaps, |
|
\%mapp, \%symbp,\%maptitles,\%uris, |
|
\%keyorder,\%defkeytype); |
|
|
|
# Menu to select levels, etc |
|
|
|
$r->print('<table border="1"><tr><td>'); |
|
&levelmenu($r,\%alllevs,$parmlev); |
|
if ($parmlev ne 'general') { |
|
$r->print('<td>'); |
|
&mapmenu($r,\%allmaps,$pschp,\%maptitles); |
|
$r->print('</td>'); |
|
} |
|
$r->print('</td></tr></table>'); |
|
|
|
$r->print('<table border="1"><tr><td>'); |
|
&parmmenu($r,\%allparms,\@pscat,\%keyorder); |
|
$r->print('</td><td>'); |
|
&partmenu($r,\%allparts,\@psprt); |
|
$r->print('</td><td>'); |
|
§ionmenu($r,\@selected_sections); |
|
|
|
$r->print('</td></tr></table>'); |
|
|
|
my $sortorder=$env{'form.sortorder'}; |
|
unless ($sortorder) { $sortorder='realmstudent'; } |
|
&sortmenu($r,$sortorder); |
|
|
|
$r->print('<p><input type="submit" name="dis" value="'.&mt('Display').'" /></p>'); |
|
|
|
# Build the list data hash from the specified parms |
|
|
|
my $listdata; |
|
%{$listdata}=(); |
|
|
|
foreach my $cat (@pscat) { |
|
foreach my $section (@selected_sections) { |
|
foreach my $part (@psprt) { |
|
my $rootparmkey=$env{'request.course.id'}; |
|
if (($section ne 'all') && ($section ne 'none') && ($section)) { |
|
$rootparmkey.='.['.$section.']'; |
|
} |
|
if ($parmlev eq 'general') { |
|
# course-level parameter |
|
my $newparmkey=$rootparmkey.'.'.$part.'.'.$cat; |
|
$$listdata{$newparmkey}=1; |
|
$$listdata{$newparmkey.'.type'}=$defkeytype{$cat}; |
|
} elsif ($parmlev eq 'map') { |
|
# map-level parameter |
|
foreach my $mapid (keys %allmaps) { |
|
if (($pschp ne 'all') && ($pschp ne $mapid)) { next; } |
|
my $newparmkey=$rootparmkey.'.'.$allmaps{$mapid}.'___(all).'.$part.'.'.$cat; |
|
$$listdata{$newparmkey}=1; |
|
$$listdata{$newparmkey.'.type'}=$defkeytype{$cat}; |
|
} |
|
} else { |
|
# resource-level parameter |
|
foreach my $rid (@ids) { |
|
my ($map,$resid,$url)=&Apache::lonnet::decode_symb($symbp{$rid}); |
|
if (($pschp ne 'all') && ($allmaps{$pschp} ne $map)) { next; } |
|
my $newparmkey=$rootparmkey.'.'.$symbp{$rid}.'.'.$part.'.'.$cat; |
|
$$listdata{$newparmkey}=1; |
|
$$listdata{$newparmkey.'.type'}=$defkeytype{$cat}; |
|
} |
|
} |
|
} |
|
} |
|
} |
|
|
|
if (($env{'form.store'}) || ($env{'form.dis'})) { |
|
|
|
if ($env{'form.store'}) { &storedata($r,$crs,$dom); } |
|
|
|
# Read modified data |
|
|
|
my $resourcedata=&readdata($crs,$dom); |
|
|
|
# List data |
|
|
|
&listdata($r,$resourcedata,$listdata,$sortorder); |
|
} |
|
$r->print(&tableend(). |
|
((($env{'form.store'}) || ($env{'form.dis'}))?'<p><input type="submit" name="store" value="'.&mt('Store').'" /></p>':''). |
|
'</form></body></html>'); |
|
} |
|
|
|
sub overview { |
|
my $r=shift; |
|
my $bodytag=&Apache::loncommon::bodytag('Modify Parameters'); |
|
my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'}; |
|
my $crs = $env{'course.'.$env{'request.course.id'}.'.num'}; |
|
my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs(undef,'Overview'); |
|
my $html=&Apache::lonxml::xmlbegin(); |
|
$r->print(<<ENDOVER); |
|
$html |
|
<head> |
|
<title>LON-CAPA Parameters</title> |
|
</head> |
|
$bodytag |
|
$breadcrumbs |
|
<form method="post" action="/adm/parmset?action=setoverview" name="overviewform"> |
|
ENDOVER |
|
# Store modified |
|
|
|
&storedata($r,$crs,$dom); |
|
|
|
# Read modified data |
|
|
|
my $resourcedata=&readdata($crs,$dom); |
|
|
|
|
|
my $sortorder=$env{'form.sortorder'}; |
|
unless ($sortorder) { $sortorder='realmstudent'; } |
|
&sortmenu($r,$sortorder); |
|
|
|
# List data |
|
|
|
my $foundkeys=&listdata($r,$resourcedata,$resourcedata,$sortorder); |
|
|
$r->print(&tableend().'<p>'. |
$r->print(&tableend().'<p>'. |
($foundkeys?'<input type="submit" value="'.&mt('Modify Parameters').'" />':&mt('There are no course or section parameters.')).'</p></form></body></html>'); |
($foundkeys?'<input type="submit" value="'.&mt('Modify Parameters').'" />':&mt('There are no parameters.')).'</p></form></body></html>'); |
|
} |
|
|
|
################################################## |
|
################################################## |
|
|
|
=pod |
|
|
|
=item change clone |
|
|
|
Modifies the list of courses a user can clone (stored |
|
in the user's environemnt.db file), called when a |
|
change is made to the list of users allowed to clone |
|
a course. |
|
|
|
Inputs: $action,$cloner |
|
where $action is add or drop, and $cloner is identity of |
|
user for whom cloning ability is to be changed in course. |
|
|
|
Returns: |
|
|
|
=cut |
|
|
|
################################################## |
|
################################################## |
|
|
|
|
|
sub change_clone { |
|
my ($clonelist,$oldcloner) = @_; |
|
my ($uname,$udom); |
|
my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; |
|
my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; |
|
my $clone_crs = $cnum.':'.$cdom; |
|
|
|
if ($cnum && $cdom) { |
|
my @allowclone = (); |
|
if ($clonelist =~ /,/) { |
|
@allowclone = split/,/,$clonelist; |
|
} else { |
|
$allowclone[0] = $clonelist; |
|
} |
|
foreach my $currclone (@allowclone) { |
|
if (!grep/^$currclone$/,@$oldcloner) { |
|
($uname,$udom) = split/:/,$currclone; |
|
if ($uname && $udom) { |
|
unless (&Apache::lonnet::homeserver($uname,$udom) eq 'no_host') { |
|
my %currclonecrs = &Apache::lonnet::dump('environment',$udom,$uname,'cloneable'); |
|
if ($currclonecrs{'cloneable'} !~ /\Q$clone_crs\E/) { |
|
if ($currclonecrs{'cloneable'} eq '') { |
|
$currclonecrs{'cloneable'} = $clone_crs; |
|
} else { |
|
$currclonecrs{'cloneable'} .= ','.$clone_crs; |
|
} |
|
&Apache::lonnet::put('environment',\%currclonecrs,$udom,$uname); |
|
} |
|
} |
|
} |
|
} |
|
} |
|
foreach my $oldclone (@$oldcloner) { |
|
if (!grep/^$oldclone$/,@allowclone) { |
|
($uname,$udom) = split/:/,$oldclone; |
|
if ($uname && $udom) { |
|
unless (&Apache::lonnet::homeserver($uname,$udom) eq 'no_host') { |
|
my %currclonecrs = &Apache::lonnet::dump('environment',$udom,$uname,'cloneable'); |
|
my %newclonecrs = (); |
|
if ($currclonecrs{'cloneable'} =~ /\Q$clone_crs\E/) { |
|
if ($currclonecrs{'cloneable'} =~ /,/) { |
|
my @currclonecrs = split/,/,$currclonecrs{'cloneable'}; |
|
foreach (@currclonecrs) { |
|
unless ($_ eq $clone_crs) { |
|
$newclonecrs{'cloneable'} .= $_.','; |
|
} |
|
} |
|
$newclonecrs{'cloneable'} =~ s/,$//; |
|
} else { |
|
$newclonecrs{'cloneable'} = ''; |
|
} |
|
&Apache::lonnet::put('environment',\%newclonecrs,$udom,$uname); |
|
} |
|
} |
|
} |
|
} |
|
} |
|
} |
|
} |
|
|
|
|
|
################################################## |
|
################################################## |
|
|
|
=pod |
|
|
|
=item * header |
|
|
|
Output html header for page |
|
|
|
=cut |
|
|
|
################################################## |
|
################################################## |
|
sub header { |
|
my $html=&Apache::lonxml::xmlbegin(); |
|
my $bodytag=&Apache::loncommon::bodytag('Parameter Manager'); |
|
my $title = &mt('LON-CAPA Parameter Manager'); |
|
return(<<ENDHEAD); |
|
$html |
|
<head> |
|
<title>$title</title> |
|
</head> |
|
$bodytag |
|
ENDHEAD |
|
} |
|
################################################## |
|
################################################## |
|
sub print_main_menu { |
|
my ($r,$parm_permission)=@_; |
|
# |
|
$r->print(<<ENDMAINFORMHEAD); |
|
<form method="post" enctype="multipart/form-data" |
|
action="/adm/parmset" name="studentform"> |
|
ENDMAINFORMHEAD |
|
# |
|
my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; |
|
my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; |
|
my @menu = |
|
( |
|
{ text => 'Set Course Environment Parameters', |
|
action => 'crsenv', |
|
permission => $parm_permission, |
|
}, |
|
{ text => 'Set/Modify Resource Parameters - Helper Mode', |
|
url => '/adm/helper/parameter.helper', |
|
permission => $parm_permission, |
|
}, |
|
{ text => 'Modify Resource Parameters - Overview Mode', |
|
action => 'setoverview', |
|
permission => $parm_permission, |
|
}, |
|
{ text => 'Set Resource Parameters - Overview Mode', |
|
action => 'newoverview', |
|
permission => $parm_permission, |
|
}, |
|
{ text => 'Set/Modify Resource Parameters - Table Mode', |
|
action => 'settable', |
|
permission => $parm_permission, |
|
help => 'Cascading_Parameters', |
|
}, |
|
{ text => 'Set Parameter Setting Default Actions', |
|
action => 'setdefaults', |
|
permission => $parm_permission, |
|
}, |
|
); |
|
my $menu_html = ''; |
|
foreach my $menu_item (@menu) { |
|
next if (! $menu_item->{'permission'}); |
|
$menu_html.='<p>'; |
|
$menu_html.='<font size="+1">'; |
|
if (exists($menu_item->{'url'})) { |
|
$menu_html.=qq{<a href="$menu_item->{'url'}">}; |
|
} else { |
|
$menu_html.= |
|
qq{<a href="/adm/parmset?action=$menu_item->{'action'}">}; |
|
} |
|
$menu_html.= &mt($menu_item->{'text'}).'</a></font>'; |
|
if (exists($menu_item->{'help'})) { |
|
$menu_html.= |
|
&Apache::loncommon::help_open_topic($menu_item->{'help'}); |
|
} |
|
$menu_html.='</p>'.$/; |
|
} |
|
$r->print($menu_html); |
|
return; |
|
} |
|
|
|
|
|
################################################## |
|
|
|
sub defaultsetter { |
|
my $r=shift; |
|
my $bodytag=&Apache::loncommon::bodytag('Parameter Setting Default Actions'); |
|
my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'}; |
|
my $crs = $env{'course.'.$env{'request.course.id'}.'.num'}; |
|
my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs(undef,'Defaults'); |
|
my $html=&Apache::lonxml::xmlbegin(); |
|
$r->print(<<ENDDEFHEAD); |
|
$html |
|
<head> |
|
<title>LON-CAPA Parameters</title> |
|
</head> |
|
$bodytag |
|
$breadcrumbs |
|
<form method="post" action="/adm/parmset?action=setdefaults" name="defaultform"> |
|
ENDDEFHEAD |
|
if ($env{'form.storerules'}) { |
|
# storage here |
|
&resetrulescache(); |
|
} |
|
my @ids=(); |
|
my %typep=(); |
|
my %keyp=(); |
|
my %allparms=(); |
|
my %allparts=(); |
|
my %allmaps=(); |
|
my %mapp=(); |
|
my %symbp=(); |
|
my %maptitles=(); |
|
my %uris=(); |
|
my %keyorder=&standardkeyorder(); |
|
my %defkeytype=(); |
|
|
|
&extractResourceInformation(\@ids, \%typep,\%keyp, \%allparms, \%allparts, \%allmaps, |
|
\%mapp, \%symbp,\%maptitles,\%uris, |
|
\%keyorder,\%defkeytype); |
|
my %lt=&Apache::lonlocal::texthash('hours' => 'Hours', |
|
'min' => 'Minutes', |
|
'sec' => 'Seconds', |
|
'yes' => 'Yes', |
|
'no' => 'No'); |
|
my @standardoptions=('','default'); |
|
my @standarddisplay=('',&mt('Default value when manually setting')); |
|
my @dateoptions=('','default'); |
|
my @datedisplay=('',&mt('Default value when manually setting')); |
|
foreach my $tempkey (&keysindisplayorder(\%allparms,\%keyorder)) { |
|
unless ($tempkey) { next; } |
|
push @standardoptions,'when_setting_'.$tempkey; |
|
push @standarddisplay,&mt('Automatically set when setting ').$tempkey; |
|
if (&isdateparm($defkeytype{$tempkey})) { |
|
push @dateoptions,'later_than_'.$tempkey; |
|
push @datedisplay,&mt('Automatically set later than ').$tempkey; |
|
push @dateoptions,'earlier_than_'.$tempkey; |
|
push @datedisplay,&mt('Automatically set earlier than ').$tempkey; |
|
} |
|
} |
|
$r->print("\n<table border='1'><tr><th>".&mt('Rule for parameter').'</th><th>'. |
|
&mt('Action').'</th><th>'.&mt('Value').'</th></tr>'); |
|
foreach my $tempkey (&keysindisplayorder(\%allparms,\%keyorder)) { |
|
unless ($tempkey) { next; } |
|
$r->print("\n<tr><td>".$allparms{$tempkey}."\n<br />(".$tempkey.')</td><td>'); |
|
|
|
my $action=&rulescache($tempkey.'_action'); |
|
$r->print('<select name="'.$tempkey.'_action">'); |
|
if (&isdateparm($defkeytype{$tempkey})) { |
|
for (my $i=0;$i<=$#dateoptions;$i++) { |
|
if ($dateoptions[$i]=~/\_$tempkey$/) { next; } |
|
$r->print("\n<option value='$dateoptions[$i]'". |
|
($dateoptions[$i] eq $action?' selected="selected"':''). |
|
">$datedisplay[$i]</option>"); |
|
} |
|
} else { |
|
for (my $i=0;$i<=$#standardoptions;$i++) { |
|
if ($standardoptions[$i]=~/\_$tempkey$/) { next; } |
|
$r->print("\n<option value='$standardoptions[$i]'". |
|
($standardoptions[$i] eq $action?' selected="selected"':''). |
|
">$standarddisplay[$i]</option>"); |
|
} |
|
} |
|
$r->print('</select>'); |
|
|
|
|
|
$r->print("\n</td><td>\n"); |
|
|
|
if (&isdateparm($defkeytype{$tempkey})) { |
|
my $hours=&rulescache($tempkey.'_hours'); |
|
my $min=&rulescache($tempkey.'_min'); |
|
my $sec=&rulescache($tempkey.'_sec'); |
|
$r->print(<<ENDINPUTDATE); |
|
<input name="$tempkey\_hours" type="text" size="4" value="$hours" />$lt{'hours'}<br /> |
|
<input name="$tempkey\_min" type="text" size="4" value="$min" />$lt{'min'}<br /> |
|
<input name="$tempkey\_sec" type="text" size="4" value="$sec" />$lt{'sec'} |
|
ENDINPUTDATE |
|
} elsif ($defkeytype{$tempkey} eq 'string_yesno') { |
|
my $yeschecked=''; |
|
my $nochecked=''; |
|
if (&rulescache($tempkey.'_value') eq 'yes') { $yeschecked='checked="checked"'; } |
|
if (&rulescache($tempkey.'_value') eq 'no') { $nochecked='checked="checked"'; } |
|
|
|
$r->print(<<ENDYESNO); |
|
<label><input type="radio" name="$tempkey" value="yes" $yeschecked /> $lt{'yes'}</label><br /> |
|
<label><input type="radio" name="$tempkey" value="no" $nochecked /> $lt{'no'}</label> |
|
ENDYESNO |
|
} else { |
|
$r->print('<input type="text" size="20" name="'.$tempkey.'" value="'.&rulescache($tempkey.'_value').'" />'); |
|
} |
|
$r->print('</td></tr>'); |
|
} |
|
$r->print("</table></form></body></html>"); |
|
return; |
} |
} |
|
|
################################################## |
################################################## |
Line 1916 ENDOVER
|
Line 2677 ENDOVER
|
Main handler. Calls &assessparms and &crsenv subroutines. |
Main handler. Calls &assessparms and &crsenv subroutines. |
|
|
=cut |
=cut |
|
|
################################################## |
################################################## |
################################################## |
################################################## |
use Data::Dumper; |
# use Data::Dumper; |
|
|
sub handler { |
sub handler { |
my $r=shift; |
my $r=shift; |
|
|
Line 1928 sub handler {
|
Line 2689 sub handler {
|
$r->send_http_header; |
$r->send_http_header; |
return OK; |
return OK; |
} |
} |
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'}); |
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'}, |
|
['action','state', |
|
'pres_marker', |
|
'pres_value', |
|
'pres_type', |
|
'udom','uname','symb']); |
|
|
# ----------------------------------------------------------- Clear out garbage |
|
|
|
%courseopt=(); |
&Apache::lonhtmlcommon::clear_breadcrumbs(); |
%useropt=(); |
&Apache::lonhtmlcommon::add_breadcrumb({href=>"/adm/parmset", |
%parmhash=(); |
text=>"Parameter Manager", |
|
faq=>10, |
@ids=(); |
bug=>'Instructor Interface'}); |
%symbp=(); |
|
%mapp=(); |
|
%typep=(); |
|
%keyp=(); |
|
|
|
%maptitles=(); |
|
|
|
# ----------------------------------------------------- Needs to be in a course |
# ----------------------------------------------------- Needs to be in a course |
|
my $parm_permission = |
|
(&Apache::lonnet::allowed('opa',$env{'request.course.id'}) || |
|
&Apache::lonnet::allowed('opa',$env{'request.course.id'}.'/'. |
|
$env{'request.course.sec'})); |
|
if ($env{'request.course.id'} && $parm_permission) { |
|
|
if (($ENV{'request.course.id'}) && |
# Start Page |
(&Apache::lonnet::allowed('opa',$ENV{'request.course.id'}) || |
|
&Apache::lonnet::allowed('opa',$ENV{'request.course.id'}.'/'. |
|
$ENV{'request.course.sec'}) |
|
)) { |
|
|
|
&Apache::loncommon::content_type($r,'text/html'); |
&Apache::loncommon::content_type($r,'text/html'); |
$r->send_http_header; |
$r->send_http_header; |
|
|
$coursename=$ENV{'course.'.$ENV{'request.course.id'}.'.description'}; |
|
|
|
if (($ENV{'form.crsenv'}) || (!$ENV{'request.course.fn'})) { |
|
# ---------------------------------------------- This is for course environment |
# id numbers can change on re-ordering of folders |
# -------------------------- also call if toplevel map coudl not be initialized |
|
&crsenv($r); |
&resetsymbcache(); |
} elsif ($ENV{'form.overview'}) { |
|
# --------------------------------------------------------------- Overview mode |
# |
|
# Main switch on form.action and form.state, as appropriate |
|
# |
|
# Check first if coming from someone else headed directly for |
|
# the table mode |
|
if ((($env{'form.command'} eq 'set') && ($env{'form.url'}) |
|
&& (!$env{'form.dis'})) || ($env{'form.symb'})) { |
|
&assessparms($r); |
|
|
|
} elsif (! exists($env{'form.action'})) { |
|
$r->print(&header()); |
|
$r->print(&Apache::lonhtmlcommon::breadcrumbs(undef, |
|
'Parameter Manager')); |
|
&print_main_menu($r,$parm_permission); |
|
} elsif ($env{'form.action'} eq 'crsenv' && $parm_permission) { |
|
&Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=crsenv', |
|
text=>"Course Environment"}); |
|
$r->print(&Apache::lonhtmlcommon::breadcrumbs(undef, |
|
'Edit Course Environment')); |
|
&crsenv($r); |
|
} elsif ($env{'form.action'} eq 'setoverview' && $parm_permission) { |
|
&Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=setoverview', |
|
text=>"Overview Mode"}); |
&overview($r); |
&overview($r); |
} else { |
} elsif ($env{'form.action'} eq 'newoverview' && $parm_permission) { |
# --------------------------------------------------------- Bring up assessment |
&Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=setoverview', |
|
text=>"Overview Mode"}); |
|
&newoverview($r); |
|
} elsif ($env{'form.action'} eq 'setdefaults' && $parm_permission) { |
|
&Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=setdefaults', |
|
text=>"Set Defaults"}); |
|
&defaultsetter($r); |
|
} elsif ($env{'form.action'} eq 'settable' && $parm_permission) { |
|
&Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=settable', |
|
text=>"Table Mode", |
|
help => 'Course_Setting_Parameters'}); |
&assessparms($r); |
&assessparms($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'}= |
$env{'user.error.msg'}= |
"/adm/parmset:opa:0:0:Cannot modify assessment parameters"; |
"/adm/parmset:opa:0:0:Cannot modify assessment parameters"; |
return HTTP_NOT_ACCEPTABLE; |
return HTTP_NOT_ACCEPTABLE; |
} |
} |