--- loncom/interface/Attic/lonchart.pm 2002/02/28 23:35:31 1.35 +++ loncom/interface/Attic/lonchart.pm 2002/05/09 17:06:09 1.38 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # (Publication Handler # -# $Id: lonchart.pm,v 1.35 2002/02/28 23:35:31 albertel Exp $ +# $Id: lonchart.pm,v 1.38 2002/05/09 17:06:09 www Exp $ # # Copyright Michigan State University Board of Trustees # @@ -25,7 +25,6 @@ # # http://www.lon-capa.org/ # -# # Homework Performance Chart # # (Navigate Maps Handler @@ -121,9 +120,10 @@ sub ExtractStudentData { } } - 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} ); + &Apache::lonnet::declutter( $hash{'src_'.$ResId} )); $Code=' '; $Tries = 0; $LatestVersion = $result{"version:$Prob"}; @@ -149,7 +149,11 @@ sub ExtractStudentData { $TempHash{"$Part.Code"} = $Code; } } - } + } +# Actually append problem to output (all parts) + $Str.=''; for ( my $n = 0; $n < $PartNo; $n++ ) { my $part = $TempHash{$n}; my $Code = $TempHash{"$part.Code"}; @@ -164,6 +168,7 @@ sub ExtractStudentData { $Str .= $TempHash{"$part.Code"}; if ( $Code ne 'x' ) {$ProbTotal++;} } + $Str.=''; } else { for(my $n=0; $n<$PartNo; $n++) { @@ -224,37 +229,8 @@ sub tracetable { } } - -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)=@_; + my ($udom,$unam,$courseid,$ActiveFlag)=@_; $courseid=~s/\_/\//g; $courseid=~s/^(\w)/\/$1/; foreach (split(/\&/,&Apache::lonnet::reply('dump:'. @@ -266,15 +242,25 @@ sub usection { 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.'
'); + 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 { @@ -295,9 +281,13 @@ sub BuildChart { 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 $Status=$ENV{'form.status'}; + $Status = ($Status) ? $Status : 'Active'; + if ( ( ($end) && $now > $end ) && + ( ($Status eq 'Active') ) ) { $active=0; } + + if ( ($Status eq 'Expired') && + ($end == 0 || $now < $end) ) { $active=0; } if ($active) { my $thisindex=$#students+1; @@ -305,13 +295,12 @@ sub BuildChart { $students[$thisindex]=$name; my ($sname,$sdom)=split(/\:/,$name); $PreCol[$thisindex]=$sname.':'; - - my $ssec=&usection($sdom,$sname,$cid);#,$active); - + my $ssec=&usection($sdom,$sname,$cid,$Status); if ($ssec==-1) { $rowlabels[$thisindex]= 'Data not available: '.$name; - } else { + } + else { my %reply=&Apache::lonnet::idrget($sdom,$sname); my $reply=&Apache::lonnet::reply('get:'.$sdom.':'.$sname. ':environment:lastname&generation&firstname&middlename', @@ -365,7 +354,10 @@ sub BuildChart { sub CreateForm { my $OpSel1=''; my $OpSel2=''; - if ( $ENV{'form.active'} eq 'All Students' ) { $OpSel2='selected'; } + my $OpSel3=''; + my $Status = $ENV{'form.status'}; + if ( $Status eq 'Any' ) { $OpSel3='selected'; } + elsif ($Status eq 'Expired' ) { $OpSel2 = 'selected'; } else { $OpSel1 = 'selected'; } my $Ptr = '
'."\n"; @@ -377,9 +369,11 @@ sub CreateForm { $Ptr .= '   '; $Ptr .= ''."\n"; $Ptr .= '

'; - $Ptr .= ' Activation Area:   '."\n". - ' '."\n"; + $Ptr .= ' Student Status:   '."\n". + ' '."\n"; $Ptr .= '   '; $Ptr .= ''."\n"; $Ptr .= '
'."\n"; @@ -524,10 +518,3 @@ sub handler { } 1; __END__ - - - - - - -