version 1.198, 2005/06/02 13:15:05
|
version 1.207, 2005/06/04 15:26:13
|
Line 66 use Apache::lonnavmaps;
|
Line 66 use Apache::lonnavmaps;
|
|
|
# --- Caches local to lonparmset |
# --- Caches local to lonparmset |
|
|
my $courseoptid=''; |
my $parmhashid; |
my %courseopt=(); |
my %parmhash; |
my $useroptid=''; |
my $symbsid; |
my %useropt=(); |
my %symbs; |
my $parmhashid=''; |
|
my %parmhash=(); |
|
|
|
# --- end local caches |
# --- end local caches |
|
|
# |
|
# FIXME: get rid of items below |
|
# |
|
my @ids; |
|
my %symbp; |
|
my %mapp; |
|
my %typep; |
|
my %keyp; |
|
my %uris; |
|
my %maptitles; |
|
|
|
################################################## |
################################################## |
################################################## |
################################################## |
|
|
Line 116 Returns: A list, the first item is the
|
Line 103 Returns: A list, the first item is the
|
=cut |
=cut |
|
|
################################################## |
################################################## |
################################################## |
|
sub parmval { |
sub parmval { |
my ($what,$id,$def,$uname,$udom,$csec)=@_; |
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 |
# load caches |
|
|
&cacheparmhash(); |
&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 $seclevel=$env{'request.course.id'}.'.['.$csec.'].'.$what; |
my $seclevelr=$env{'request.course.id'}.'.['.$csec.'].'.$symbparm; |
my $seclevelr=$env{'request.course.id'}.'.['.$csec.'].'.$symbparm; |
Line 141 sub parmval {
|
Line 140 sub parmval {
|
|
|
# --------------------------------------------------------- first, check course |
# --------------------------------------------------------- first, check course |
|
|
if (defined($courseopt{$courselevel})) { |
if (defined($$courseopt{$courselevel})) { |
$outpar[11]=$courseopt{$courselevel}; |
$outpar[11]=$$courseopt{$courselevel}; |
$result=11; |
$result=11; |
} |
} |
|
|
if (defined($courseopt{$courselevelm})) { |
if (defined($$courseopt{$courselevelm})) { |
$outpar[10]=$courseopt{$courselevelm}; |
$outpar[10]=$$courseopt{$courselevelm}; |
$result=10; |
$result=10; |
} |
} |
|
|
Line 160 sub parmval {
|
Line 159 sub parmval {
|
my $thisparm=$parmhash{$symbparm}; |
my $thisparm=$parmhash{$symbparm}; |
if (defined($thisparm)) { $outpar[8]=$thisparm; $result=8; } |
if (defined($thisparm)) { $outpar[8]=$thisparm; $result=8; } |
|
|
if (defined($courseopt{$courselevelr})) { |
if (defined($$courseopt{$courselevelr})) { |
$outpar[7]=$courseopt{$courselevelr}; |
$outpar[7]=$$courseopt{$courselevelr}; |
$result=7; |
$result=7; |
} |
} |
|
|
# ------------------------------------------------------ fourth, back to course |
# ------------------------------------------------------ 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; |
} |
} |
} |
} |
Line 185 sub parmval {
|
Line 184 sub parmval {
|
# ---------------------------------------------------------- fifth, 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; |
} |
} |
} |
} |
Line 218 sub cacheparmhash {
|
Line 217 sub cacheparmhash {
|
} |
} |
} |
} |
|
|
sub cacheuseropt { |
sub resetsymbcache { |
my ($uname,$udom)=@_; |
$symbsid=''; |
} |
} |
|
|
sub cachecourseopt { |
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}; |
} |
} |
|
|
################################################## |
################################################## |
Line 241 sub cachecourseopt {
|
Line 256 sub cachecourseopt {
|
|
|
sub storeparm { |
sub storeparm { |
my ($sresid,$spnam,$snum,$nval,$ntype,$uname,$udom,$csec)=@_; |
my ($sresid,$spnam,$snum,$nval,$ntype,$uname,$udom,$csec)=@_; |
my $navmap = Apache::lonnavmaps::navmap->new(); |
&storeparm_by_symb(&symbcache($sresid),$spnam,$snum,$nval,$ntype,$uname,$udom,$csec); |
if ($sresid=~/\./) { |
|
my $resource=$navmap->getById($sresid); |
|
&storeparm_by_symb($resource->symb(),$spnam,$snum,$nval,$ntype,$uname,$udom,$csec); |
|
} else { |
|
my $resource=$navmap->getByMapPc($sresid); |
|
&storeparm_by_symb(&Apache::lonnet::declutter($resource->src()),$spnam,$snum,$nval,$ntype,$uname,$udom,$csec); |
|
} |
|
} |
} |
|
|
# |
# |
Line 296 sub storeparm_by_symb {
|
Line 304 sub storeparm_by_symb {
|
if ($snum>3) { |
if ($snum>3) { |
# ---------------------------------------------------------------- Store Course |
# ---------------------------------------------------------------- Store Course |
# |
# |
|
my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; |
|
my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; |
# Expire sheets |
# Expire sheets |
&Apache::lonnet::expirespread('','','studentcalc'); |
&Apache::lonnet::expirespread('','','studentcalc'); |
if (($snum==7) || ($snum==4)) { |
if (($snum==7) || ($snum==4)) { |
Line 308 sub storeparm_by_symb {
|
Line 318 sub storeparm_by_symb {
|
# Store parameter |
# Store parameter |
if ($delete) { |
if ($delete) { |
$reply=&Apache::lonnet::del |
$reply=&Apache::lonnet::del |
('resourcedata',[keys(%storecontent)], |
('resourcedata',[keys(%storecontent)],$cdom,$cnum); |
$env{'course.'.$env{'request.course.id'}.'.domain'}, |
|
$env{'course.'.$env{'request.course.id'}.'.num'}); |
|
} else { |
} else { |
$reply=&Apache::lonnet::cput |
$reply=&Apache::lonnet::cput |
('resourcedata',\%storecontent, |
('resourcedata',\%storecontent,$cdom,$cnum); |
$env{'course.'.$env{'request.course.id'}.'.domain'}, |
|
$env{'course.'.$env{'request.course.id'}.'.num'}); |
|
} |
} |
|
&Apache::lonnet::devalidatecourseresdata($cnum,$cdom); |
} else { |
} else { |
# ------------------------------------------------------------------ Store User |
# ------------------------------------------------------------------ Store User |
# |
# |
Line 439 sub plink {
|
Line 446 sub plink {
|
&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,$id,$udom,$csec,$uname,$have_assessments)=@_; |
|
|
my $bodytag=&Apache::loncommon::bodytag('Set/Modify Course Parameters','', |
my $bodytag=&Apache::loncommon::bodytag('Set/Modify Course Parameters','', |
'onUnload="pclose()"'); |
'onUnload="pclose()"'); |
my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs(undef,'Table'); |
my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs(undef,'Table Mode Parameter Setting'); |
my $chooseopt=&Apache::loncommon::select_dom_form($udom,'udom').' '. |
my $chooseopt=&Apache::loncommon::select_dom_form($udom,'udom').' '. |
&Apache::loncommon::selectstudent_link('parmform','uname','udom'); |
&Apache::loncommon::selectstudent_link('parmform','uname','udom'); |
my $selscript=&Apache::loncommon::studentbrowser_javascript(); |
my $selscript=&Apache::loncommon::studentbrowser_javascript(); |
my $pjump_def = &Apache::lonhtmlcommon::pjump_javascript_definition(); |
my $pjump_def = &Apache::lonhtmlcommon::pjump_javascript_definition(); |
my %lt=&Apache::lonlocal::texthash( |
my %lt=&Apache::lonlocal::texthash( |
'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", |
'captm' => "Course Assessments Parameters - Table Mode", |
'sg' => "Section/Group", |
'sg' => "Section/Group", |
'fu' => "For User", |
'fu' => "For User", |
'oi' => "or ID", |
'oi' => "or ID", |
'ad' => "at Domain" |
'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"); |
|
my $html=&Apache::lonxml::xmlbegin(); |
my $html=&Apache::lonxml::xmlbegin(); |
$r->print(<<ENDHEAD); |
$r->print(<<ENDHEAD); |
$html |
$html |
Line 516 $selscript
|
Line 513 $selscript
|
</head> |
</head> |
$bodytag |
$bodytag |
$breadcrumbs |
$breadcrumbs |
$overallhelp |
|
ENDHEAD |
ENDHEAD |
|
|
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 |
|
} |
|
my %sectionhash=(); |
my %sectionhash=(); |
my $sections=''; |
my $sections=''; |
if (&Apache::loncommon::get_sections( |
if (&Apache::loncommon::get_sections( |
Line 556 ENDHEAD2
|
Line 532 ENDHEAD2
|
<h4>$lt{'captm'}</h4> |
<h4>$lt{'captm'}</h4> |
ENDHEAD3 |
ENDHEAD3 |
|
|
if (!$have_assesments) { |
if (!$have_assessments) { |
$r->print('<font color="red">'.&mt('There are no assesment parameters in this course to set.').'</font><br />'); |
$r->print('<font color="red">'.&mt('There are no assessment parameters in this course to set.').'</font><br />'); |
} else { |
} else { |
$r->print(<<ENDHEAD); |
$r->print(<<ENDHEAD); |
<b> |
<b> |
Line 578 ENDHEAD
|
Line 554 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,$uname,$udom,$csec)=@_; |
$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 |
Line 600 sub print_row {
|
Line 576 sub print_row {
|
} |
} |
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 635 sub print_row {
|
Line 611 sub print_row {
|
|
|
&print_td($r,11,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display); |
&print_td($r,11,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display); |
|
|
if ($parmlev eq 'brief') { |
&print_td($r,10,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display); |
|
&print_td($r,9,'#FFDDDD',$result,\@outpar,$mprefix,$_,\@typeoutpar,$display); |
&print_td($r,7,$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); |
if ($csec) { |
|
&print_td($r,4,$defbgtwo,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display); |
if ($csec) { |
} |
&print_td($r,6,$defbgtwo,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display); |
if ($uname) { |
&print_td($r,5,$defbgtwo,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display); |
&print_td($r,1,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display); |
&print_td($r,4,$defbgtwo,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display); |
} |
} |
} else { |
if ($uname) { |
|
&print_td($r,3,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display); |
&print_td($r,10,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display); |
&print_td($r,2,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display); |
&print_td($r,9,'#FFDDDD',$result,\@outpar,$mprefix,$_,\@typeoutpar,$display); |
&print_td($r,1,$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); |
|
|
|
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 700 sub print_td {
|
Line 659 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 839 Variables used (guessed by Jeremy):
|
Line 799 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 %allkeys=(); |
my %allmaps=(); |
my %allmaps=(); |
Line 859 sub assessparms {
|
Line 828 sub assessparms {
|
my %allparts; |
my %allparts; |
|
|
my %defp; |
my %defp; |
%courseopt=(); |
|
%useropt=(); |
|
|
|
@ids=(); |
@ids=(); |
%symbp=(); |
%symbp=(); |
Line 885 sub assessparms {
|
Line 852 sub assessparms {
|
|
|
my $pssymb=''; |
my $pssymb=''; |
my $parmlev=''; |
my $parmlev=''; |
my $trimheader=''; |
|
my $prevvisit=$env{'form.prevvisit'}; |
my $prevvisit=$env{'form.prevvisit'}; |
|
|
unless ($env{'form.parmlev'}) { |
unless ($env{'form.parmlev'}) { |
Line 904 sub assessparms {
|
Line 870 sub assessparms {
|
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'}=''; |
} |
} |
Line 970 sub assessparms {
|
Line 934 sub assessparms {
|
|
|
# ---------------------------------------------------------- Anything to store? |
# ---------------------------------------------------------- Anything to store? |
if ($env{'form.pres_marker'}) { |
if ($env{'form.pres_marker'}) { |
$message.=&storeparm(split(/\&/,$env{'form.pres_marker'}), |
my @markers=split(/\&\&\&/,$env{'form.pres_marker'}); |
$env{'form.pres_value'}, |
my @values=split(/\&\&\&/,$env{'form.pres_value'}); |
$env{'form.pres_type'}, |
my @types=split(/\&\&\&/,$env{'form.pres_type'}); |
$uname,$udom,$csec); |
for (my $i=0;$i<=$#markers;$i++) { |
|
$message.=&storeparm(split(/\&/,$markers[$i]), |
|
$values[$i], |
|
$types[$i], |
|
$uname,$udom,$csec); |
|
} |
# ---------------------------------------------------------------- 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 |
# ------------------------------------------------------------------- Sort this |
|
|
@ids=sort { |
@ids=sort { |
Line 1010 sub assessparms {
|
Line 964 sub assessparms {
|
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,$id,$udom,$csec,$uname,scalar(keys(%allkeys))); |
if (scalar(keys(%allkeys)) eq 0) { $have_assesments=0; } |
|
|
|
$trimheader = 'yes'; |
|
&startpage($r,$id,$udom,$csec,$uname,$have_assesments,$trimheader); |
|
|
|
# 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">'); |
$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', |
Line 1194 sub assessparms {
|
Line 1140 sub assessparms {
|
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 1331 ENDTABLEHEADFOUR
|
Line 1277 ENDTABLEHEADFOUR
|
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,$uname,$udom,$csec); |
$parmlev,$uname,$udom,$csec); |
} |
} |
Line 1340 ENDTABLEHEADFOUR
|
Line 1286 ENDTABLEHEADFOUR
|
} # 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 1439 ENDMAPONE
|
Line 1385 ENDMAPONE
|
|
|
foreach (sort keys %name) { |
foreach (sort keys %name) { |
$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,$uname,$udom,$csec); |
$parmlev,$uname,$udom,$csec); |
# $r->print("<tr><td>resource.$part{$_}.$name{$_},$symbp{$mapid}</td></tr>\n"); |
# $r->print("<tr><td>resource.$part{$_}.$name{$_},$symbp{$mapid}</td></tr>\n"); |
Line 1517 ENDMAPONE
|
Line 1463 ENDMAPONE
|
|
|
foreach (sort keys %name) { |
foreach (sort keys %name) { |
$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,$uname,$udom,$csec); |
\%type,\%display,$defbgone,$defbgtwo,$parmlev,$uname,$udom,$csec); |
# $r->print("<tr><td>resource.$part{$_}.$name{$_},$symbp{$mapid}</td></tr>\n"); |
# $r->print("<tr><td>resource.$part{$_}.$name{$_},$symbp{$mapid}</td></tr>\n"); |
} |
} |
Line 1859 $output
|
Line 1805 $output
|
ENDenv |
ENDenv |
} |
} |
################################################## |
################################################## |
|
# Overview mode |
|
################################################## |
my $tableopen; |
my $tableopen; |
|
|
sub tablestart { |
sub tablestart { |
Line 1881 sub tableend {
|
Line 1828 sub tableend {
|
} |
} |
} |
} |
|
|
|
sub readdata { |
|
my ($crs,$dom)=@_; |
|
# Read coursedata |
|
my $resourcedata=&Apache::lonnet::get_courseresdata($crs,$dom); |
|
# Read userdata |
|
|
|
my $classlist=&Apache::loncoursedata::get_classlist(); |
|
foreach (keys %$classlist) { |
|
# the following undefs are for 'domain', and 'username' respectively. |
|
if ($_=~/^(\w+)\:(\w+)$/) { |
|
my ($tuname,$tudom)=($1,$2); |
|
my $useropt=&Apache::lonnet::get_userresdata($tuname,$tudom); |
|
foreach my $userkey (keys %{$useropt}) { |
|
if ($userkey=~/^$env{'request.course.id'}/) { |
|
my $newkey=$userkey; |
|
$newkey=~s/^($env{'request.course.id'}\.)/$1\[useropt\:$tuname\:$tudom\]\./; |
|
$$resourcedata{$newkey}=$$useropt{$userkey}; |
|
} |
|
} |
|
} |
|
} |
|
return $resourcedata; |
|
} |
|
|
|
sub extractuser { |
|
my $key=shift; |
|
return ($key=~/^$env{'request.course.id'}.\[useropt\:(\w+)\:(\w+)\]\./); |
|
} |
|
|
sub overview { |
sub overview { |
my $r=shift; |
my $r=shift; |
my $bodytag=&Apache::loncommon::bodytag( |
my $bodytag=&Apache::loncommon::bodytag( |
Line 1900 $breadcrumbs
|
Line 1876 $breadcrumbs
|
<input type="hidden" name="overview" value="1" /> |
<input type="hidden" name="overview" value="1" /> |
ENDOVER |
ENDOVER |
# Setting |
# Setting |
my %olddata=&Apache::lonnet::dump('resourcedata',$dom,$crs); |
# 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=(); |
Line 1909 ENDOVER
|
Line 1887 ENDOVER
|
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; } |
if ($$olddata{$thiskey} ne $data) { |
|
if ($tuname) { |
|
if (&Apache::lonnet::put('resourcedata',{$tkey=>$data},$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; |
|
} |
|
} |
} 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; } |
if (defined($data) and $$olddata{$thiskey} ne $data) { |
|
if ($tuname) { |
|
if (&Apache::lonnet::put('resourcedata',{$tkey=>$data},$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; |
|
} |
|
} |
} |
} |
} |
} |
} |
} |
# 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 1931 ENDOVER
|
Line 1949 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') { |
Line 1939 ENDOVER
|
Line 1958 ENDOVER
|
$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 |
# Read modified data |
my %resourcedata=&Apache::lonnet::dump('resourcedata',$dom,$crs); |
|
|
my $resourcedata=&readdata($crs,$dom); |
|
|
|
# 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 keys %{$resourcedata}) { |
if ($resourcedata{$thiskey.'.type'}) { |
if ($$resourcedata{$thiskey.'.type'}) { |
my ($course,$middle,$part,$name)= |
my ($middle,$part,$name)= |
($thiskey=~/^(\w+)\.(?:(.+)\.)*([\w\s]+)\.(\w+)$/); |
($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 1987 ENDOVER
|
Line 2017 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 ($$resourcedata{$thiskey.'.type'}=~/^date/) { |
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}). |
'<input type="hidden" name="datepointer_'.$thiskey.'" value="'.$jskey.'" />' |
'<input type="hidden" name="datepointer_'.$thiskey.'" value="'.$jskey.'" />' |
); |
); |
} 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('</td></tr>'); |
$r->print('</td></tr>'); |
} |
} |
Line 2134 ENDMAINFORMHEAD
|
Line 2164 ENDMAINFORMHEAD
|
my @menu = |
my @menu = |
( |
( |
{ text => 'Set Course Environment Parameters', |
{ text => 'Set Course Environment Parameters', |
help => 'Course_Setting_Parameters', |
action => 'crsenv', |
action => 'crsenv', |
|
permission => $parm_permission, |
permission => $parm_permission, |
}, |
}, |
{ text => 'Set/Modify Course Assessment Parameters - Helper Mode', |
{ text => 'Set/Modify Course Assessment Parameters - Helper Mode', |
Line 2149 ENDMAINFORMHEAD
|
Line 2178 ENDMAINFORMHEAD
|
{ text => 'Set/Modify Course Assessment Parameters - Table Mode', |
{ text => 'Set/Modify Course Assessment Parameters - Table Mode', |
action => 'settable', |
action => 'settable', |
permission => $parm_permission, |
permission => $parm_permission, |
|
help => 'Cascading_Parameters', |
}, |
}, |
# { text => 'Set Parameter Default Preferences', |
# { text => 'Set Parameter Default Preferences', |
# help => 'Course_View_Class_List', |
# help => 'Course_View_Class_List', |
Line 2203 sub handler {
|
Line 2233 sub handler {
|
return OK; |
return OK; |
} |
} |
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'}, |
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'}, |
['action','state']); |
['action','state', |
|
'pres_marker', |
|
'pres_value', |
|
'pres_type', |
|
'udom','uname']); |
|
|
# ----------------------------------------------------------- Clear out garbage |
|
|
|
%courseopt=(); |
|
%useropt=(); |
|
%parmhash=(); |
|
|
|
@ids=(); |
|
%symbp=(); |
|
%mapp=(); |
|
%typep=(); |
|
%keyp=(); |
|
|
|
%maptitles=(); |
|
|
|
&Apache::lonhtmlcommon::clear_breadcrumbs(); |
&Apache::lonhtmlcommon::clear_breadcrumbs(); |
&Apache::lonhtmlcommon::add_breadcrumb({href=>"/adm/parmset", |
&Apache::lonhtmlcommon::add_breadcrumb({href=>"/adm/parmset", |
text=>"Parameter Manager", |
text=>"Parameter Manager", |
faq=>9, |
faq=>10, |
bug=>'Instructor Interface'}); |
bug=>'Instructor Interface'}); |
|
|
# ----------------------------------------------------- Needs to be in a course |
# ----------------------------------------------------- Needs to be in a course |
my $parm_permission = |
my $parm_permission = |
(&Apache::lonnet::allowed('opa',$env{'request.course.id'}) || |
(&Apache::lonnet::allowed('opa',$env{'request.course.id'}) || |
Line 2235 sub handler {
|
Line 2257 sub handler {
|
&Apache::loncommon::content_type($r,'text/html'); |
&Apache::loncommon::content_type($r,'text/html'); |
$r->send_http_header; |
$r->send_http_header; |
|
|
|
|
|
# id numbers can change on re-ordering of folders |
|
|
|
&resetsymbcache(); |
|
|
# |
# |
# Main switch on form.action and form.state, as appropriate |
# Main switch on form.action and form.state, as appropriate |
# |
# |
Line 2261 sub handler {
|
Line 2288 sub handler {
|
&overview($r); |
&overview($r); |
} elsif ($env{'form.action'} eq 'settable' && $parm_permission) { |
} elsif ($env{'form.action'} eq 'settable' && $parm_permission) { |
&Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=settable', |
&Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=settable', |
text=>"Table Mode"}); |
text=>"Table Mode", |
|
help => 'Course_Setting_Parameters'}); |
&assessparms($r); |
&assessparms($r); |
} |
} |
|
|