--- loncom/interface/Attic/lonchart.pm 2002/02/28 23:25:50 1.34
+++ loncom/interface/Attic/lonchart.pm 2002/05/30 13:08:34 1.40
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# (Publication Handler
#
-# $Id: lonchart.pm,v 1.34 2002/02/28 23:25:50 minaeibi Exp $
+# $Id: lonchart.pm,v 1.40 2002/05/30 13:08:34 stredwic Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -25,7 +25,6 @@
#
# http://www.lon-capa.org/
#
-#
# Homework Performance Chart
#
# (Navigate Maps Handler
@@ -70,9 +69,7 @@ my $r;
sub ExtractStudentData {
my ($index,$coid)=@_;
my ($sname,$sdom) = split( /\:/, $students[$index] );
- my $shome=&Apache::lonnet::homeserver( $sname,$sdom );
- my $reply=&Apache::lonnet::reply('dump:'.$sdom.':'.$sname.':'.$coid,$shome );
- my %result=();
+ my %result=&Apache::lonnet::dump($coid,$sdom,$sname);
my $ResId;
my $Code;
my $Tries;
@@ -87,92 +84,102 @@ sub ExtractStudentData {
' ',0,14).' ! '.
substr($rowlabels[$index].
' ',0,45).' ! ';
- unless ($reply=~/^error\:/) {
- foreach (split(/\&/,$reply)) {
- my ($name,$value)=split(/\=/,&Apache::lonnet::unescape($_));
- $result{$name}=$value;
- }
- $ProbNo = 0;
- $ProbTotal = 0;
- $ProbSolved = 0;
- my $IterationNo = 0;
- foreach $ResId (@cols) {
- if ($IterationNo == 0) {$IterationNo++; next;}
- if (!$ResId) {
- my $PrNo = sprintf( "%3d", $ProbNo );
- $Str .= ' '.''.$PrNo.' ';
- $ProbSolved += $ProbNo;
- $ProbNo=0;
- next;
- }
- $ResId=~/(\d+)\.(\d+)/;
- my $meta=$hash{'src_'.$ResId};
- my $PartNo = 0;
- undef %TempHash;
- foreach (split(/\,/,&Apache::lonnet::metadata($meta,'keys'))) {
- if ($_=~/^stores\_(\d+)\_tries$/) {
- my $Part=&Apache::lonnet::metadata($meta,$_.'.part');
- if ( $TempHash{"$Part"} eq '' ) {
- $TempHash{"$Part"} = $Part;
- $TempHash{$PartNo}=$Part;
- $TempHash{"$Part.Code"} = ' ';
- $PartNo++;
- }
+
+ my($checkForError)=keys (%result);
+ if($checkForError =~ /^(con_lost|error|no_such_host)/i) {
+ my $PrTot = sprintf( "%5d", $ProbTotal );
+ my $PrSvd = sprintf( "%5d", $ProbSolved );
+ $Str .= ' '.''.$PrSvd.' /'.$PrTot.' ';
+ return $Str;
+ }
+
+ $ProbNo = 0;
+ $ProbTotal = 0;
+ $ProbSolved = 0;
+ my $IterationNo = 0;
+ foreach $ResId (@cols) {
+ if ($IterationNo == 0) {$IterationNo++; next;}
+ if (!$ResId) {
+ my $PrNo = sprintf( "%3d", $ProbNo );
+ $Str .= ' '.''.$PrNo.' ';
+ $ProbSolved += $ProbNo;
+ $ProbNo=0;
+ next;
+ }
+ $ResId=~/(\d+)\.(\d+)/;
+ my $meta=$hash{'src_'.$ResId};
+ my $PartNo = 0;
+ undef %TempHash;
+ foreach (split(/\,/,&Apache::lonnet::metadata($meta,'keys'))) {
+ if ($_=~/^stores\_(\d+)\_tries$/) {
+ my $Part=&Apache::lonnet::metadata($meta,$_.'.part');
+ if ( $TempHash{"$Part"} eq '' ) {
+ $TempHash{"$Part"} = $Part;
+ $TempHash{$PartNo}=$Part;
+ $TempHash{"$Part.Code"} = ' ';
+ $PartNo++;
}
- }
+ }
+ }
- my $Prob = &Apache::lonnet::declutter( $hash{'map_id_'.$1} ).
+ my $Prob = &Apache::lonnet::symbclean(
+ &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};
- my $Code = $TempHash{"$part.Code"};
- if ( $Code eq '*') {
- $ProbNo++;
- if (($TempHash{"$part.Tries"}<10) ||
- ($TempHash{"$part.Tries"} eq '')) {
- $TempHash{"$part.Code"}=$TempHash{"$part.Tries"};
- }
- }
- elsif ( $Code eq '+' ) {$ProbNo++;}
- $Str .= $TempHash{"$part.Code"};
- if ( $Code ne 'x' ) {$ProbTotal++;}
+ &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;
+ }
}
- }
- else {
- for(my $n=0; $n<$PartNo; $n++) {
- $Str.=' ';
- $ProbTotal++;
+ }
+# Actually append problem to output (all parts)
+ $Str.='';
+ for ( my $n = 0; $n < $PartNo; $n++ ) {
+ my $part = $TempHash{$n};
+ my $Code = $TempHash{"$part.Code"};
+ if ( $Code eq '*') {
+ $ProbNo++;
+ if (($TempHash{"$part.Tries"}<10) ||
+ ($TempHash{"$part.Tries"} eq '')) {
+ $TempHash{"$part.Code"}=$TempHash{"$part.Tries"};
+ }
}
+ elsif ( $Code eq '+' ) {$ProbNo++;}
+ $Str .= $TempHash{"$part.Code"};
+ if ( $Code ne 'x' ) {$ProbTotal++;}
+ }
+ $Str.='';
+ } else {
+ for(my $n=0; $n<$PartNo; $n++) {
+ $Str.=' ';
+ $ProbTotal++;
}
- }
+ }
}
+
my $PrTot = sprintf( "%5d", $ProbTotal );
my $PrSvd = sprintf( "%5d", $ProbSolved );
$Str .= ' '.''.$PrSvd.' /'.$PrTot.' ';
@@ -224,57 +231,43 @@ sub tracetable {
}
}
-
-sub usection2 {
+sub usection {
my ($udom,$unam,$courseid,$ActiveFlag)=@_;
$courseid=~s/\_/\//g;
$courseid=~s/^(\w)/\/$1/;
- foreach my $elem(split(/\&/,&Apache::lonnet::reply('dump:'.$udom.':'.$unam.':roles',
- &Apache::lonnet::homeserver($unam,$udom)))) {
- my ($key,$value)=split(/\=/,$elem);
- $key=&Apache::lonnet::unescape($key);
- if ($key=~/^$courseid(?:\/)*(\w+)*\_st$/) {
- my $section=$1;
- if ($key eq $courseid.'_st') { $section=''; }
- my ($dummy,$end,$start)=split(/\_/,&Apache::lonnet::unescape($value));
- my $now=time;
- my $notactive=0;
- if ($start) {
- if ($now<$start) { $notactive=1; }
- }
- if ($end) {
- if ($now>$end) { $notactive=1; }
- }
- if ($ActiveFlag == 1) { $notactive=0; }
- unless ($notactive) { return $section; }
- }
- }
- return '-1';
-}
+ my %result=&Apache::lonnet::dump('roles',$udom,$unam);
-sub usection {
- my ($udom,$unam,$courseid)=@_;
- $courseid=~s/\_/\//g;
- $courseid=~s/^(\w)/\/$1/;
- foreach (split(/\&/,&Apache::lonnet::reply('dump:'.
- $udom.':'.$unam.':roles',
- &Apache::lonnet::homeserver($unam,$udom)))){
- my ($key,$value)=split(/\=/,$_);
- $key=&Apache::lonnet::unescape($key);
+ my($checkForError)=keys (%result);
+ if($checkForError =~ /^(con_lost|error|no_such_host)/i) {
+ return -1;
+ }
+
+ foreach my $key (keys (%result)) {
+ my $value = $result{$key};
if ($key=~/^$courseid(?:\/)*(\w+)*\_st$/) {
my $section=$1;
if ($key eq $courseid.'_st') { $section=''; }
- my ($dummy,$end,$start)=split(/\_/,&Apache::lonnet::unescape($value));
-# $section=($section) ? $section : '(none)';
-# $section=(int($section)) ? int($section) : $section;
-# $r->print($unam.'...'.$section.'
');
+ my ($dummy,$end,$start)=split(/\_/,$value);
+ if ( $ActiveFlag ne 'Any' ) {
+ my $now=time;
+ my $notactive=0;
+ if ($start) {
+ if ($now<$start) { $notactive=1; }
+ }
+ if ($end) {
+ if ($now>$end) { $notactive=1; }
+ }
+ if ((($ActiveFlag eq 'Expired') && $notactive == 1) ||
+ (($ActiveFlag eq 'Active') && $notactive == 0 ) ) {
+ return $section;
+ }
+ else { return '-1'; }
+ }
return $section;
}
}
- #} split(/\&/,&Apache::lonnet::reply('dump:'.$udom.':'.$unam.':roles',
- # &Apache::lonnet::homeserver($unam,$udom)));
- return '';
+ return '-1';
}
sub BuildChart {
@@ -287,35 +280,39 @@ sub BuildChart {
my $chome=$ENV{'course.'.$cid.'.home'};
my ($cdom,$cnum)=split(/\_/,$cid);
# ---------------------------------------------- Read class list and row labels
- my $classlst=&Apache::lonnet::reply
- ('dump:'.$cdom.':'.$cnum.':classlist',$chome);
- my $now=time;
- unless ($classlst=~/^error\:/) {
- foreach my $KeyPoint(sort split(/\&/,$classlst)) {
- my ($name,$value)=split(/\=/,$KeyPoint);
- my ($end,$start)=split(/\:/,&Apache::lonnet::unescape($value));
- my $active=1;
- if (($end) && ($now>$end)) { $active=0; }
-
- if ($ENV{'form.active'} eq 'All Students') { $active=1; }
+ my %classlist=&Apache::lonnet::dump('classlist',$cdom,$cnum);
+ my($checkForError)=keys (%classlist);
+ if($checkForError =~ /^(con_lost|error|no_such_host)/i) {
+ $r->print('
'); for ( my $n; $n < $count; $n++) { - my ($dummy, $Line) = split(/\*/,$list[$n]); - $r->print($Line.''); } @@ -525,10 +523,3 @@ sub handler { } 1; __END__ - - - - - - -
'); + $r->print($CachData{$list{$order[$n]}}.'
'); } $r->print('