--- loncom/interface/Attic/lonchart.pm 2002/02/19 18:58:10 1.30
+++ loncom/interface/Attic/lonchart.pm 2002/02/28 23:14:57 1.33
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# (Publication Handler
#
-# $Id: lonchart.pm,v 1.30 2002/02/19 18:58:10 minaeibi Exp $
+# $Id: lonchart.pm,v 1.33 2002/02/28 23:14:57 minaeibi Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -43,7 +43,7 @@
# 9/8 Gerd Kortemeyer
# 10/1, 10/19, 11/17, 11/22, 11/24, 11/28 12/18 Behrouz Minaei
# YEAR=2002
-# 2/1, 2/6, 2/19 Behrouz Minaei
+# 2/1, 2/6, 2/19, 2/28 Behrouz Minaei
#
###
@@ -64,7 +64,7 @@ my @rowlabels;
my @students;
my @PreCol;
my $r;
-
+
# ------------------------------------------------------------- Find out status
sub ExtractStudentData {
@@ -88,10 +88,10 @@ sub ExtractStudentData {
substr($rowlabels[$index].
' ',0,45).' ! ';
unless ($reply=~/^error\:/) {
- map {
+ foreach (split(/\&/,$reply)) {
my ($name,$value)=split(/\=/,&Apache::lonnet::unescape($_));
$result{$name}=$value;
- } split(/\&/,$reply);
+ }
$ProbNo = 0;
$ProbTotal = 0;
$ProbSolved = 0;
@@ -109,7 +109,7 @@ sub ExtractStudentData {
my $meta=$hash{'src_'.$ResId};
my $PartNo = 0;
undef %TempHash;
- map {
+ foreach (split(/\,/,&Apache::lonnet::metadata($meta,'keys'))) {
if ($_=~/^stores\_(\d+)\_tries$/) {
my $Part=&Apache::lonnet::metadata($meta,$_.'.part');
if ( $TempHash{"$Part"} eq '' ) {
@@ -119,7 +119,7 @@ sub ExtractStudentData {
$PartNo++;
}
}
- } split(/\,/,&Apache::lonnet::metadata($meta,'keys'));
+ }
my $Prob = &Apache::lonnet::declutter( $hash{'map_id_'.$1} ).
'___'.$2.'___'.
@@ -217,14 +217,63 @@ sub tracetable {
}
}
if (defined($hash{'to_'.$rid})) {
- map {
+ foreach (split(/\,/,$hash{'to_'.$rid})){
&tracetable($hash{'goesto_'.$_},$beenhere);
- } split(/\,/,$hash{'to_'.$rid});
+ }
}
}
}
+sub usection2 {
+ 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';
+}
+
+
+sub usection {
+ my ($udom,$unam,$courseid)=@_;
+ $courseid=~s/\_/\//g;
+ $courseid=~s/^(\w)/\/$1/;
+ map {
+ my ($key,$value)=split(/\=/,$_);
+ $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));
+# $section=($section) ? $section : '(none)';
+# $section=(int($section)) ? int($section) : $section;
+# $r->print($unam.'...'.$section.'
');
+ return $section;
+ }
+ } split(/\&/,&Apache::lonnet::reply('dump:'.$udom.':'.$unam.':roles',
+ &Apache::lonnet::homeserver($unam,$udom)));
+ return '';
+}
+
sub BuildChart {
# ----------------------- Get first and last resource, see if there is anything
my $firstres=$hash{'map_start_/res/'.$ENV{'request.course.uri'}};
@@ -239,32 +288,37 @@ sub BuildChart {
('dump:'.$cdom.':'.$cnum.':classlist',$chome);
my $now=time;
unless ($classlst=~/^error\:/) {
- map {
- my ($name,$value)=split(/\=/,$_);
+ 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; }
+
if ($active) {
my $thisindex=$#students+1;
$name=&Apache::lonnet::unescape($name);
$students[$thisindex]=$name;
my ($sname,$sdom)=split(/\:/,$name);
$PreCol[$thisindex]=$sname.':';
- my $ssec=&Apache::lonnet::usection($sdom,$sname,$cid);
+
+ my $ssec=&usection($sdom,$sname,$cid);#,$active);
+
if ($ssec==-1) {
$rowlabels[$thisindex]=
'Data not available: '.$name;
} else {
my %reply=&Apache::lonnet::idrget($sdom,$sname);
my $reply=&Apache::lonnet::reply('get:'.$sdom.':'.$sname.
- ':environment:lastname&generation&firstname&middlename',
- &Apache::lonnet::homeserver($sname,$sdom));
+ ':environment:lastname&generation&firstname&middlename',
+ &Apache::lonnet::homeserver($sname,$sdom));
#$ssec=(int($ssec)) ? int($ssec) : $ssec;
- $rowlabels[$thisindex]=
- sprintf('%3s',$ssec).' '.$reply{$sname}.' ';
- $PreCol[$thisindex] .= $reply.':'.$ssec;
+ my $sec=sprintf('%3s',$ssec);
+ $rowlabels[$thisindex]=$sec.' '.$reply{$sname}.' ';
+ $PreCol[$thisindex] .= $reply.':'.$sec;
my $i=0;
- map {
+ foreach (split(/\&/,$reply)) {
$i++;
if ( $_ ne '') {
$rowlabels[$thisindex].=&Apache::lonnet::unescape($_).' ';
@@ -273,10 +327,10 @@ sub BuildChart {
chop($rowlabels[$thisindex]);
$rowlabels[$thisindex].=', ';
}
- } split(/\&/,$reply);
+ }
}
}
- } sort split(/\&/,$classlst);
+ }
} else {
$r->print('