version 1.1, 2000/11/20 22:56:01
|
version 1.2, 2000/11/21 12:22:29
|
Line 9
|
Line 9
|
# |
# |
# 10/11,10/12,10/16 Gerd Kortemeyer) |
# 10/11,10/12,10/16 Gerd Kortemeyer) |
# |
# |
# 11/20 Gerd Kortemeyer |
# 11/20,11/21 Gerd Kortemeyer |
|
|
package Apache::lonparmset; |
package Apache::lonparmset; |
|
|
Line 18 use Apache::lonnet;
|
Line 18 use Apache::lonnet;
|
use Apache::Constants qw(:common :http REDIRECT); |
use Apache::Constants qw(:common :http REDIRECT); |
use GDBM_File; |
use GDBM_File; |
|
|
|
my %courseopt; |
|
my %useropt; |
|
my %bighash; |
|
my %parmhash; |
|
|
|
my @srcp; |
|
my @typep; |
|
my @resp; |
|
my @mapp; |
|
my @symbp; |
|
|
|
my $uname; |
|
my $udom; |
|
my $uhome; |
|
|
|
my $csec; |
|
|
|
# -------------------------------------------- Figure out a cascading parameter |
|
|
|
sub parmval { |
|
my ($what,$idx)=@_; |
|
# ----------------------------------------------------- Cascading lookup scheme |
|
my $symbparm=$symbp[$idx].'.'.$what; |
|
my $reslevel= |
|
$ENV{'request.course.id'}.'.'.$symbparm; |
|
my $seclevel= |
|
$ENV{'request.course.id'}.'.'. |
|
$ENV{'request.course.sec'}.'.'.$what; |
|
my $courselevel= |
|
$ENV{'request.course.id'}.'.'.$what; |
|
|
|
# ----------------------------------------------------------- first, check user |
|
|
|
if ($useropt{$reslevel}) { return $useropt{$reslevel}; } |
|
if ($useropt{$seclevel}) { return $useropt{$seclevel}; } |
|
if ($useropt{$courselevel}) { return $useropt{$courselevel}; } |
|
|
|
# -------------------------------------------------------- second, check course |
|
|
|
if ($courseopt{$reslevel}) { return $courseopt{$reslevel}; } |
|
if ($courseopt{$seclevel}) { return $courseopt{$seclevel}; } |
|
if ($courseopt{$courselevel}) { return $courseopt{$courselevel}; } |
|
|
|
# ------------------------------------------------------ third, check map parms |
|
|
|
my $thisparm=$parmhash{$symbparm}; |
|
if ($thisparm) { return $thisparm; } |
|
|
|
|
|
# --------------------------------------------- last, look in resource metadata |
|
|
|
my $filename='/home/httpd/res/'.$srcp[$idx].'.meta'; |
|
if (-e $filename) { |
|
my @content; |
|
{ |
|
my $fh=Apache::File->new($filename); |
|
@content=<$fh>; |
|
} |
|
if (join('',@content)=~ |
|
/\<$what[^\>]*\>([^\<]*)\<\/$what\>/) { |
|
return $1; |
|
} |
|
} |
|
return ''; |
|
} |
|
|
# ================================================================ Main Handler |
# ================================================================ Main Handler |
|
|
sub handler { |
sub handler { |
Line 33 sub handler {
|
Line 99 sub handler {
|
|
|
if (($ENV{'request.course.fn'}) && |
if (($ENV{'request.course.fn'}) && |
(&Apache::lonnet::allowed('opa',$ENV{'request.course.id'}))) { |
(&Apache::lonnet::allowed('opa',$ENV{'request.course.id'}))) { |
|
# -------------------------------------------------------- Variable declaration |
|
|
|
%courseopt=(); |
|
%useropt=(); |
|
%bighash=(); |
|
|
|
@srcp=(); |
|
@typep=(); |
|
@resp=(); |
|
@mapp=(); |
|
@symbp=(); |
|
|
|
$uname=$ENV{'form.uname'}; |
|
$udom=$ENV{'form.udom'}; |
|
unless ($udom) { $uname=''; } |
|
$uhome=''; |
|
if ($uname) { |
|
$uhome=&Apache::lonnet::homeserver($uname,$udom); |
|
} |
|
|
|
$csec=$ENV{'form.csec'}; |
|
|
|
# ------------------------------------------------------------------- Tie hashs |
|
if ((tie(%bighash,'GDBM_File',$ENV{'request.course.fn'}.'.db', |
|
&GDBM_READER,0640)) && |
|
(tie(%parmhash,'GDBM_File', |
|
$ENV{'request.course.fn'}.'_parms.db',&GDBM_READER,0640))) { |
|
|
|
# -------------------------------------------------------------- Get coursedata |
|
my $reply=&Apache::lonnet::reply('dump:'. |
|
$ENV{'course.'.$ENV{'request.course.id'}.'.domain'}.':'. |
|
$ENV{'course.'.$ENV{'request.course.id'}.'.num'}.':resourcedata', |
|
$ENV{'course.'.$ENV{'request.course.id'}.'.home'}); |
|
if ($reply!~/^error\:/) { |
|
map { |
|
my ($name,$value)=split(/\=/,$_); |
|
$courseopt{unescape($name)}=unescape($value); |
|
} split(/\&/,$reply); |
|
} |
|
# --------------------------------------------------- Get userdata (if present) |
|
if ($uname) { |
|
my $reply= |
|
&Apache::lonnet::reply('dump:'.$udom.':'.$uname.':resourcedata',$uhome); |
|
if ($reply!~/^error\:/) { |
|
map { |
|
my ($name,$value)=split(/\=/,$_); |
|
$useropt{unescape($name)}=unescape($value); |
|
} split(/\&/,$reply); |
|
} |
|
} |
|
# --------------------------------------------------------- Get all assessments |
|
map { |
|
if ($_=~/^src\_(\d+)\.(\d+)$/) { |
|
my $mapid=$1; |
|
my $resid=$2; |
|
if ($bighash{$_}=~/\.(problem|exam|quiz|assess|survey|form)$/) { |
|
$typep[$#typep+1]=$1; |
|
$mapp[$#mapp+1]=$mapid; |
|
$resp[$#resp+1]=$resid; |
|
$srcp[$#srcp+1]=&Apache::lonnet::declutter($bighash{$_}); |
|
$symbp[$#symbp+1]= |
|
&Apache::lonnet::declutter($bighash{'map_id_'.$mapid}). |
|
'___'.$resid.'___'.$srcp[$#srcp]; |
|
} |
|
} |
|
} keys %bighash; |
|
# ------------------------------------------------------------------- Sort this |
|
|
my %bighash; |
# ------------------------------------------------------------------ Start page |
if (tie(%bighash,'GDBM_File',$ENV{'request.course.fn'}.'.db', |
|
&GDBM_READER,0640)) { |
|
$r->content_type('text/html'); |
$r->content_type('text/html'); |
$r->send_http_header; |
$r->send_http_header; |
$r->print('<html><body bgcolor="#FFFFFF">'); |
$r->print('<html><body bgcolor="#FFFFFF">'); |
|
|
$r->print('</body></html>'); |
$r->print('</body></html>'); |
untie(%bighash); |
untie(%bighash); |
|
untie(%parmhash); |
} |
} |
} else { |
} else { |
# ----------------------------- Not in a course, or not allowed to modify parms |
# ----------------------------- Not in a course, or not allowed to modify parms |