version 1.24, 2002/02/11 18:32:22
|
version 1.26, 2002/02/14 22:13:36
|
Line 129 sub parmval {
|
Line 129 sub parmval {
|
# ------------------------------------------------------- second, check course |
# ------------------------------------------------------- second, check course |
if ($csec) { |
if ($csec) { |
if ($courseopt{$seclevelr}) { return $courseopt{$seclevelr}; } |
if ($courseopt{$seclevelr}) { return $courseopt{$seclevelr}; } |
if ($courseopt{$seclevelm}) { return $courseopt{$seclevelm}; } |
if ($courseopt{$seclevelm}) { return $courseopt{$seclevelm}; } |
if ($courseopt{$seclevel}) { return $courseopt{$seclevel}; } |
if ($courseopt{$seclevel}) { return $courseopt{$seclevel}; } |
} |
} |
|
|
Line 144 sub parmval {
|
Line 144 sub parmval {
|
|
|
# ----------------------------------------------------- fourth , check default |
# ----------------------------------------------------- fourth , check default |
|
|
return &Apache::lonnet::metadata($fn,$rwhat.'.default'); |
my $default=&Apache::lonnet::metadata($fn,$rwhat.'.default'); |
|
if ($default) { return $default} |
|
|
|
# --------------------------------------------------- fifth , cascade up parts |
|
|
|
my ($space,@qualifier)=split(/\./,$rwhat); |
|
my $qualifier=join('.',@qualifier); |
|
unless ($space eq '0') { |
|
my ($part,$id)=split(/\_/,$space); |
|
if ($id) { |
|
my $partgeneral=&parmval($part.".$qualifier",$symb); |
|
if ($partgeneral) { return $partgeneral; } |
|
} else { |
|
my $resourcegeneral=&parmval("0.$qualifier",$symb); |
|
if ($resourcegeneral) { return $resourcegeneral; } |
|
} |
|
} |
|
return ''; |
} |
} |
|
|
|
|
|
|
# ------------------------------------------------------------- Find out status |
# ------------------------------------------------------------- Find out status |
|
# return codes |
|
# tcode (timecode) |
|
# 1: will open later |
|
# 2: is open and not past due yet |
|
# 3: is past due date |
|
# 4: due in the next 24 hours |
|
# |
|
# code (curent solved status) |
|
# 1: not attempted |
|
# 2: attempted but wrong, or incorrect by instructor |
|
# 3: solved or correct by instructor |
|
# "excused" needs to be supported, but is not yet. Could be code=4. |
sub astatus { |
sub astatus { |
my $rid=shift; |
my $rid=shift; |
my $code=1; |
my $code=1; |
Line 158 sub astatus {
|
Line 186 sub astatus {
|
$rid=~/(\d+)\.(\d+)/; |
$rid=~/(\d+)\.(\d+)/; |
my $symb=&Apache::lonnet::declutter($hash{'map_id_'.$1}).'___'.$2.'___'. |
my $symb=&Apache::lonnet::declutter($hash{'map_id_'.$1}).'___'.$2.'___'. |
&Apache::lonnet::declutter($hash{'src_'.$rid}); |
&Apache::lonnet::declutter($hash{'src_'.$rid}); |
|
$Apache::lonxml::debug=1; |
my %duedate=(); |
my %duedate=(); |
my %opendate=(); |
my %opendate=(); |
my %answerdate=(); |
my %answerdate=(); |
map { |
# need to always check part 0's open/due/answer status |
|
foreach (sort(split(/\,/,&Apache::lonnet::metadata($hash{'src_'.$rid},'keys')))) { |
if ($_=~/^parameter\_(.*)\_opendate$/) { |
if ($_=~/^parameter\_(.*)\_opendate$/) { |
my $part=$1; |
my $part=$1; |
$duedate{$part}=&parmval($part.'.duedate',$symb); |
$duedate{$part}=&parmval($part.'.duedate',$symb); |
$opendate{$part}=&parmval($part.'.opendate',$symb); |
$opendate{$part}=&parmval($part.'.opendate',$symb); |
$answerdate{$part}=&parmval($part.'.answerdate',$symb); |
$answerdate{$part}=&parmval($part.'.answerdate',$symb); |
} |
} |
} sort split(/\,/,&Apache::lonnet::metadata($hash{'src_'.$rid},'keys')); |
} |
|
|
my $now=time; |
my $now=time; |
my $tcode=0; |
my $tcode=0; |
|
|
my %returnhash=&Apache::lonnet::restore($symb); |
my %returnhash=&Apache::lonnet::restore($symb); |
|
|
map { |
foreach (sort(keys(%opendate))) { |
my $duedate=$duedate{$_}; |
my $duedate=$duedate{$_}; |
my $opendate=$opendate{$_}; |
my $opendate=$opendate{$_}; |
my $answerdate=$answerdate{$_}; |
my $answerdate=$answerdate{$_}; |
my $preface=''; |
my $preface=''; |
unless ($_ eq '0') { $preface=' Part: '.$_.' '; } |
unless ($_ eq '0') { $preface=' Part: '.$_.' '; } |
if ($opendate) { |
if ($opendate) { |
if ($now<$duedate) { |
if ($now<$duedate || (!$duedate)) { |
unless ($tcode==4) { $tcode=2; } |
unless ($tcode==4) { $tcode=2; } |
$ctext.=$preface.'Due: '.localtime($duedate); |
if ($duedate) { |
if ($now<$opendate) { |
$ctext.=$preface.'Due: '.localtime($duedate); |
unless ($tcode) { $tcode=1; } |
} else { |
|
$ctext.=$preface.'No Due Date'; |
|
} |
|
if ($now<$opendate) { |
|
unless ($tcode) { $tcode=1; } |
$ctext.=$preface.'Open: '.localtime($opendate); |
$ctext.=$preface.'Open: '.localtime($opendate); |
} |
} |
if ($duedate-$now<86400) { |
if ($duedate && $duedate-$now<86400) { |
$tcode=4; |
$tcode=4; |
$ctext.=$preface.'Due: '.localtime($duedate); |
$ctext.=$preface.'Due: '.localtime($duedate); |
} |
} |
} else { |
} else { |
unless (($tcode==4) || ($tcode eq 2)) { $tcode=3; } |
unless (($tcode==4) || ($tcode eq 2)) { $tcode=3; } |
if ($now<$answerdate) { |
if ($now<$answerdate) { |
$ctext.='Answer: '.localtime($duedate); |
$ctext.='Answer: '.localtime($duedate); |
} |
} |
} |
} |
Line 205 sub astatus {
|
Line 237 sub astatus {
|
} |
} |
|
|
my $status=$returnhash{'resource.'.$_.'.solved'}; |
my $status=$returnhash{'resource.'.$_.'.solved'}; |
|
|
if ($status eq 'correct_by_student') { |
if ($status eq 'correct_by_student') { |
unless ($code==2) { $code=3; } |
unless ($code==2) { $code=3; } |
$ctext.=' solved'; |
$ctext.=' solved'; |
Line 216 sub astatus {
|
Line 248 sub astatus {
|
$code=2; |
$code=2; |
$ctext.=' ('. |
$ctext.=' ('. |
($returnhash{'resource.'.$_.'.tries'}? |
($returnhash{'resource.'.$_.'.tries'}? |
$returnhash{'resource.'.$_.'.tries'}:'0').'/'. |
$returnhash{'resource.'.$_.'.tries'}:'0'); |
&parmval($_.'.maxtries',$symb).' tries)'; |
my $numtries = &parmval($_.'.maxtries',$symb); |
|
if ($numtries) { $ctext.='/'.$numtries.' tries'; } |
|
$ctext.=')'; |
} elsif ($status eq 'incorrect_by_override') { |
} elsif ($status eq 'incorrect_by_override') { |
$code=2; |
$code=2; |
$ctext.=' override'; |
$ctext.=' override'; |
Line 225 sub astatus {
|
Line 259 sub astatus {
|
unless ($code==2) { $code=3; } |
unless ($code==2) { $code=3; } |
$ctext.=' excused'; |
$ctext.=' excused'; |
} |
} |
|
} |
} sort keys %opendate; |
|
|
|
return 'p'.$code.$tcode.'"'.$ctext.'"'; |
return 'p'.$code.$tcode.'"'.$ctext.'"'; |
} |
} |
Line 298 sub tracetable {
|
Line 331 sub tracetable {
|
if (defined($hash{'to_'.$rid})) { |
if (defined($hash{'to_'.$rid})) { |
my $mincond=1; |
my $mincond=1; |
my $next=''; |
my $next=''; |
map { |
foreach (split(/\,/,$hash{'to_'.$rid})) { |
my $thiscond= |
my $thiscond= |
&Apache::lonnet::directcondval($hash{'condid_'.$hash{'undercond_'.$_}}); |
&Apache::lonnet::directcondval($hash{'condid_'.$hash{'undercond_'.$_}}); |
if ($thiscond>=$mincond) { |
if ($thiscond>=$mincond) { |
Line 309 sub tracetable {
|
Line 342 sub tracetable {
|
} |
} |
if ($thiscond>$mincond) { $mincond=$thiscond; } |
if ($thiscond>$mincond) { $mincond=$thiscond; } |
} |
} |
} split(/\,/,$hash{'to_'.$rid}); |
} |
map { |
foreach (split(/\,/,$next)) { |
my ($linkid,$condval)=split(/\:/,$_); |
my ($linkid,$condval)=split(/\:/,$_); |
if ($condval>=$mincond) { |
if ($condval>=$mincond) { |
my $now=&tracetable($sofar,$hash{'goesto_'.$linkid},$beenhere); |
my $now=&tracetable($sofar,$hash{'goesto_'.$linkid},$beenhere); |
if ($now>$further) { $further=$now; } |
if ($now>$further) { $further=$now; } |
} |
} |
} split(/\,/,$next); |
} |
|
|
} |
} |
} |
} |
Line 340 sub handler {
|
Line 373 sub handler {
|
$r->send_http_header; |
$r->send_http_header; |
return OK; |
return OK; |
} |
} |
|
|
my $requrl=$r->uri; |
my $requrl=$r->uri; |
# ----------------------------------------------------------------- Tie db file |
# ----------------------------------------------------------------- Tie db file |
if ($ENV{'request.course.fn'}) { |
if ($ENV{'request.course.fn'}) { |
Line 381 sub handler {
|
Line 413 sub handler {
|
$courserdatas{$cid.'.last_cache'}=time; |
$courserdatas{$cid.'.last_cache'}=time; |
} |
} |
} |
} |
map { |
foreach (split(/\&/,$courserdatas{$cid})) { |
my ($name,$value)=split(/\=/,$_); |
my ($name,$value)=split(/\=/,$_); |
$courseopt{$userprefix.&Apache::lonnet::unescape($name)}= |
$courseopt{$userprefix.&Apache::lonnet::unescape($name)}= |
&Apache::lonnet::unescape($value); |
&Apache::lonnet::unescape($value); |
} split(/\&/,$courserdatas{$cid}); |
} |
# --------------------------------------------------- Get userdata (if present) |
# --------------------------------------------------- Get userdata (if present) |
unless |
unless |
((time-$userrdatas{$uname.'___'.$udom.'.last_cache'})<240) { |
((time-$userrdatas{$uname.'___'.$udom.'.last_cache'})<240) { |
Line 396 sub handler {
|
Line 428 sub handler {
|
$userrdatas{$uname.'___'.$udom.'.last_cache'}=time; |
$userrdatas{$uname.'___'.$udom.'.last_cache'}=time; |
} |
} |
} |
} |
map { |
foreach (split(/\&/,$userrdatas{$uname.'___'.$udom})) { |
my ($name,$value)=split(/\=/,$_); |
my ($name,$value)=split(/\=/,$_); |
$useropt{$userprefix.&Apache::lonnet::unescape($name)}= |
$useropt{$userprefix.&Apache::lonnet::unescape($name)}= |
&Apache::lonnet::unescape($value); |
&Apache::lonnet::unescape($value); |
} split(/\&/,$userrdatas{$uname.'___'.$udom}); |
} |
} |
} |
|
|
@rows=(); |
@rows=(); |
Line 551 sub handler {
|
Line 583 sub handler {
|
$adde='</th>'; |
$adde='</th>'; |
} |
} |
if ($rid=~/^p(\d)(\d)\"([\w\: \(\)\/\,]*)\"(.+)/) { |
if ($rid=~/^p(\d)(\d)\"([\w\: \(\)\/\,]*)\"(.+)/) { |
|
# sub astatus describes what code/tcode mean |
my $code=$1; |
my $code=$1; |
my $tcode=$2; |
my $tcode=$2; |
my $ctext=$3; |
my $ctext=$3; |
Line 566 sub handler {
|
Line 599 sub handler {
|
$add='<td bgcolor="#FFFFAA">'; |
$add='<td bgcolor="#FFFFAA">'; |
} |
} |
if ($tcode eq '4') { |
if ($tcode eq '4') { |
$add='<td bgcolor="#FFFF33"><blink>'; |
$add='<td bgcolor="#FFFF33">'; |
$adde='</blink></td>'; |
$adde='</td>'; |
} |
} |
} |
} |
$hwk='<font color="#888811"><b>'; |
$hwk='<font color="#888811"><b>'; |