version 1.2, 2001/01/31 23:28:06
|
version 1.24, 2001/12/18 20:06:05
|
Line 11
|
Line 11
|
# 08/30,08/31,09/06,09/14,09/15,09/16,09/19,09/20,09/21,09/23, |
# 08/30,08/31,09/06,09/14,09/15,09/16,09/19,09/20,09/21,09/23, |
# 10/02,10/10,10/14,10/16,10/18,10/19,10/31,11/6,11/14,11/16 Gerd Kortemeyer) |
# 10/02,10/10,10/14,10/16,10/18,10/19,10/31,11/6,11/14,11/16 Gerd Kortemeyer) |
# |
# |
# 3/1/1,6/1,17/1,29/1,30/1 Gerd Kortemeyer) |
# 3/1/1,6/1,17/1,29/1,30/1,31/1 Gerd Kortemeyer) |
# |
# 7/10/01 Behrouz Minaei |
# 1/31 Gerd Kortemeyer |
# 9/8 Gerd Kortemeyer |
|
# 10/18/01, 10/19/01 Behrouz Minaei |
|
# 11/17/01, 11/22/01, 11/24/01, 11/28/01 Behrouz Minaei |
|
# 12/18/01 Behrouz Minaei |
|
|
package Apache::lonchart; |
package Apache::lonchart; |
|
|
Line 31 my @students;
|
Line 34 my @students;
|
|
|
# ------------------------------------------------------------- Find out status |
# ------------------------------------------------------------- Find out status |
|
|
sub astatus { |
sub ExtractStudentData { |
my ($rid,$student)=@_; |
my ($index,$coid)=@_; |
my ($uname,$udom)=split(/\:/,$student); |
my ($sname,$sdom) = split( /\:/, $students[$index] ); |
my $code=' '; |
my $shome=&Apache::lonnet::homeserver( $sname,$sdom ); |
$rid=~/(\d+)\.(\d+)/; |
my $reply=&Apache::lonnet::reply('dump:'.$sdom.':'.$sname.':'.$coid,$shome ); |
my $symb=&Apache::lonnet::declutter($hash{'map_id_'.$1}).'___'.$2.'___'. |
my %result=(); |
&Apache::lonnet::declutter($hash{'src_'.$rid}); |
my $ResId; |
my $answer=&Apache::lonnet::reply( |
my $Code; |
"restore:$udom:$uname:". |
my $Tries; |
$ENV{'request.course.id'}.':'. |
my $Wrongs; |
&Apache::lonnet::escape($symb), |
my %TempHash; |
&Apache::lonnet::homeserver($uname,$udom)); |
my $Version; |
my %returnhash=(); |
my $ProbNo; |
map { |
my $PrTotal; |
my ($name,$value)=split(/\=/,$_); |
my $LatestVersion; |
$returnhash{&Apache::lonnet::unescape($name)}= |
my $Str=substr($students[$index]. |
&Apache::lonnet::unescape($value); |
' ',0,14).' ! '. |
} split(/\&/,$answer); |
substr($rowlabels[$index]. |
if ($returnhash{'version'}) { |
' ',0,45).' ! '; |
my $version; |
unless ($reply=~/^error\:/) { |
for ($version=1;$version<=$returnhash{'version'};$version++) { |
map { |
map { |
my ($name,$value)=split(/\=/,&Apache::lonnet::unescape($_)); |
$returnhash{$_}=$returnhash{$version.':'.$_}; |
$result{$name}=$value; |
} split(/\:/,$returnhash{$version.':keys'}); |
} split(/\&/,$reply); |
} |
$ProbNo = 0; |
my $totaltries=0; |
$PrTotal = 0; |
map { |
my $IterationNo = 0; |
if (($_=~/\.(\w+)\.solved$/) && ($_!~/^\d+\:/)) { |
foreach $ResId (@cols) { |
my $part=$1; |
if ($IterationNo == 0) {$IterationNo++; next;} |
if ($returnhash{$_} eq 'correct_by_student') { |
if (!$ResId) { |
unless (($code eq '.') || ($code eq '-')) { $code='*'; } |
my $PrNo = sprintf( "%3d", $ProbNo ); |
$totaltries+=$returnhash{'resource.'.$part.'.tries'}; |
$Str .= ' '.'<font color="#007700">'.$PrNo.'</font> '; |
} elsif ($returnhash{$_} eq 'correct_by_override') { |
$PrTotal += $ProbNo; |
unless (($code eq '.') || ($code eq '-')) { $code='+'; } |
$ProbNo=0; |
} elsif ($returnhash{$_} eq 'incorrect_attempted') { |
next; |
$code='.'; |
} |
} elsif ($returnhash{$_} eq 'incorrect_by_override') { |
$ResId=~/(\d+)\.(\d+)/; |
$code='-'; |
my $meta=$hash{'src_'.$ResId}; |
} elsif ($returnhash{$_} eq 'excused') { |
my $PartNo = 0; |
unless (($code eq '.') || ($code eq '-')) { $code='x'; } |
undef %TempHash; |
} |
map { |
} |
if ($_=~/^stores\_(\d+)\_tries$/) { |
} keys %returnhash; |
my $Part=&Apache::lonnet::metadata($meta,$_.'.part'); |
if (($code eq '*') && ($totaltries<10)) { $code="$totaltries"; } |
if ( $TempHash{"$Part"} eq '' ) { |
|
$TempHash{"$Part"} = $Part; |
|
$TempHash{$PartNo}=$Part; |
|
$TempHash{"$Part.Code"} = ' '; |
|
$PartNo++; |
|
} |
|
} |
|
} split(/\,/,&Apache::lonnet::metadata($meta,'keys')); |
|
|
|
my $Prob = &Apache::lonnet::declutter( $hash{'map_id_'.$1} ). |
|
'___'.$2.'___'. |
|
&Apache::lonnet::declutter( $hash{'src_'.$ResId} ); |
|
$Code=' '; |
|
$Tries = 0; |
|
$LatestVersion = $result{"version:$Prob"}; |
|
|
|
if ( $LatestVersion ) { |
|
for ( my $Version=1; $Version<=$LatestVersion; $Version++ ) { |
|
my $vkeys = $result{"$Version:keys:$Prob"}; |
|
my @keys = split(/\:/,$vkeys); |
|
|
|
foreach my $Key (@keys) { |
|
if (($Key=~/\.(\w+)\.solved$/) && ($Key!~/^\d+\:/)) { |
|
my $Part = $1; |
|
$Tries = $result{"$Version:$Prob:resource.$Part.tries"}; |
|
$TempHash{"$Part.Tries"}=($Tries) ? $Tries : 0; |
|
my $Val = $result{"$Version:$Prob:resource.$Part.solved"}; |
|
if ($Val eq 'correct_by_student'){$Code='*';} |
|
elsif ($Val eq 'correct_by_override'){$Code = '+';} |
|
elsif ($Val eq 'incorrect_attempted'){$Code = '.';} |
|
elsif ($Val eq 'incorrect_by_override'){$Code = '-';} |
|
elsif ($Val eq 'excused'){$Code = 'x';} |
|
elsif ($Val eq 'ungraded_attempted'){$Code = '#';} |
|
else {$Code = ' ';} |
|
$TempHash{"$Part.Code"} = $Code; |
|
} |
|
} |
|
} |
|
for ( my $n = 0; $n < $PartNo; $n++ ) { |
|
my $part = $TempHash{$n}; |
|
if ($TempHash{"$part.Code"} eq '*') { |
|
$ProbNo++; |
|
if (($TempHash{"$part.Tries"}<10) || |
|
($TempHash{"$part.Tries"} eq '')) { |
|
$TempHash{"$part.Code"}=$TempHash{"$part.Tries"}; |
|
} |
|
} |
|
$Str .= $TempHash{"$part.Code"}; |
|
} |
|
} |
|
else {for(my $n=0; $n<$PartNo; $n++) {$Str.=' ';}} |
|
} |
} |
} |
return $code; |
my $PrTot = sprintf( "%5d", $PrTotal ); |
|
$Str .= ' '.'<font color="#000088">'.$PrTot.'</font> '; |
|
|
|
return $Str ; |
} |
} |
|
|
|
|
# ------------------------------------------------------------ Build page table |
# ------------------------------------------------------------ Build page table |
|
|
sub tracetable { |
sub tracetable { |
my ($rid,$beenhere)=@_; |
my ($rid,$beenhere)=@_; |
unless ($beenhere=~/\&$rid\&/) { |
unless ($beenhere=~/\&$rid\&/) { |
$beenhere.=$rid.'&'; |
$beenhere.=$rid.'&'; |
|
# new ... updating the map according to sequence and page |
if (defined($hash{'is_map_'.$rid})) { |
if (defined($hash{'is_map_'.$rid})) { |
if ($hash{'map_type_'.$hash{'map_pc_'.$hash{'src_'.$rid}}} |
my $cmap=$hash{'map_type_'.$hash{'map_pc_'.$hash{'src_'.$rid}}}; |
eq 'sequence') { |
if ( $cmap eq 'sequence' || $cmap eq 'page' ) { |
$cols[$#cols+1]=0; |
$cols[$#cols+1]=0; |
} |
} |
if ((defined($hash{'map_start_'.$hash{'src_'.$rid}})) && |
if ((defined($hash{'map_start_'.$hash{'src_'.$rid}})) && |
Line 124 sub tracetable {
|
Line 183 sub tracetable {
|
# ================================================================ Main Handler |
# ================================================================ Main Handler |
|
|
sub handler { |
sub handler { |
|
|
|
undef %hash; |
|
undef @students; |
|
undef @cols; |
|
undef @rowlabels; |
|
|
my $r=shift; |
my $r=shift; |
|
|
if (&Apache::lonnet::allowed('vgr',$ENV{'request.course.id'})) { |
if (&Apache::lonnet::allowed('vgr',$ENV{'request.course.id'})) { |
Line 165 sub handler {
|
Line 230 sub handler {
|
# ---------------------------------------------------------------- Course title |
# ---------------------------------------------------------------- Course title |
|
|
$r->print('<h1>'. |
$r->print('<h1>'. |
$ENV{'course.'.$ENV{'request.course.id'}.'.description'}.'</h1>'); |
$ENV{'course.'.$ENV{'request.course.id'}.'.description'}.'</h1><h3>'. |
|
localtime()."</h3><p><pre>1..9: correct by student in 1..9 tries\n". |
|
" *: correct by student in more than 9 tries\n". |
|
" +: correct by override\n". |
|
" -: incorrect by override\n". |
|
" .: incorrect attempted\n". |
|
" #: ungraded attempted\n". |
|
" : not attempted\n". |
|
" x: excused</pre><p>"); |
|
|
# ------------------------------- This is going to take a while, produce output |
# ------------------------------- This is going to take a while, produce output |
|
|
$r->rflush(); |
$r->rflush(); |
Line 186 sub handler {
|
Line 258 sub handler {
|
|
|
# ---------------------------------------------- Read class list and row labels |
# ---------------------------------------------- Read class list and row labels |
|
|
undef @rowlabels; |
|
undef @students; |
|
|
|
my $classlst=&Apache::lonnet::reply |
my $classlst=&Apache::lonnet::reply |
('dump:'.$cdom.':'.$cnum.':classlist',$chome); |
('dump:'.$cdom.':'.$cnum.':classlist',$chome); |
my $now=time; |
my $now=time; |
Line 209 sub handler {
|
Line 278 sub handler {
|
'Data not available: '.$name; |
'Data not available: '.$name; |
} else { |
} else { |
my %reply=&Apache::lonnet::idrget($sdom,$sname); |
my %reply=&Apache::lonnet::idrget($sdom,$sname); |
my $reply=&Apache::lonnet::reply('get:'.$sdom.':'.$sname. |
my $reply=&Apache::lonnet::reply('get:'.$sdom.':'.$sname. |
':environment:firstname&middlename&lastname&generation', |
':environment:lastname&generation&firstname&middlename', |
&Apache::lonnet::homeserver($sname,$sdom)); |
&Apache::lonnet::homeserver($sname,$sdom)); |
$rowlabels[$thisindex]= |
$rowlabels[$thisindex]= |
$ssec.' '.$reply{$sname}.' '; |
sprintf('%3s',$ssec).' '.$reply{$sname}.' '; |
|
my $i=0; |
map { |
map { |
$rowlabels[$thisindex].=&Apache::lonnet::unescape($_).' '; |
$i++; |
|
if ( $_ ne '') { |
|
$rowlabels[$thisindex].=&Apache::lonnet::unescape($_).' '; |
|
} |
|
if ($i == 2) { |
|
chop($rowlabels[$thisindex]); |
|
$rowlabels[$thisindex].=', '; |
|
} |
} split(/\&/,$reply); |
} split(/\&/,$reply); |
|
|
} |
} |
} |
} |
} sort split(/\&/,$classlst); |
} sort split(/\&/,$classlst); |
Line 238 sub handler {
|
Line 316 sub handler {
|
$r->print('<p><pre>'); |
$r->print('<p><pre>'); |
my $index; |
my $index; |
for ($index=0;$index<=$#students;$index++) { |
for ($index=0;$index<=$#students;$index++) { |
$r->print( |
$r->print(&ExtractStudentData($index,$cid).'<br>'); |
substr($students[$index]. |
|
' ',0,14).' ! '. |
|
substr($rowlabels[$index]. |
|
' ',0,45).' ! '); |
|
map { |
|
if ($_) { |
|
$r->print(&astatus($_,$students[$index])); |
|
} else { |
|
$r->print(' ! '); |
|
} |
|
} @cols; |
|
$r->print("\n"); |
|
$r->rflush(); |
$r->rflush(); |
} |
} |
$r->print('</pre>'); |
$r->print('</pre>'); |