--- loncom/interface/lonstatistics.pm 2002/05/13 13:50:45 1.15 +++ loncom/interface/lonstatistics.pm 2002/05/16 01:27:05 1.19 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # (Publication Handler # -# $Id: lonstatistics.pm,v 1.15 2002/05/13 13:50:45 minaeibi Exp $ +# $Id: lonstatistics.pm,v 1.19 2002/05/16 01:27:05 minaeibi Exp $ # # Copyright Michigan State University Board of Trustees # @@ -30,7 +30,8 @@ # 5/5,7/9,7/25/1,8/11,9/13,9/26,10/5,10/9,10/22,10/26 Behrouz Minaei # 11/1,11/4,11/16,12/14,12/16,12/18,12/20,12/31 Behrouz Minaei # YEAR=2002 -# 1/22,2/1,2/6,2/25,3/2,3/6,3/17,3/21,3/22,3/26,4/7,5/6,5/12 Behrouz Minaei +# 1/22,2/1,2/6,2/25,3/2,3/6,3/17,3/21,3/22,3/26,4/7,5/6 Behrouz Minaei +# 5/12, 5/14, 5/15 Behrouz Minaei # ### @@ -84,7 +85,6 @@ my %Header = (0,"Homework Sets Order",1, 4,"Mean",5,"#YES",6,"#yes",7,"%Wrng",8,"DoDiff", 9,"S.D.",10,"Skew.",11,"D.F.1st",12,"D.F.2nd"); my %Answer = (); -my @shown; sub InitAnalysis { my ($rid, $student)=@_; @@ -116,18 +116,10 @@ sub InitAnalysis { chop($conc); @Concepts=split(/\@/,$conc); - my $show=''; - foreach my $elm (@{$Answer{"$parts.shown"}}) { - $show.="$elm@"; - } - chop($show); - @shown=split(/\@/,$show); -# $r->print("
shown:".$show); -# $r->rflush(); - foreach my $concept (@{$Answer{"$parts.concepts"}}) { foreach my $foil (@{$Answer{"$parts.concept.$concept"}}) { $foil_to_concept{$foil} = $concept; + #$ConceptData{$foil} = $Answer{"$parts.foil.value.$foil"}; } } return $symb; @@ -135,13 +127,11 @@ sub InitAnalysis { sub Interval { - my $symb=shift; + my ($rid,$part,$symb)=@_; my $Int=$ConceptData{"Interval"}; - my $due = &Apache::lonnet::EXT('resource.0.duedate',$symb)+1; - my $opn = &Apache::lonnet::EXT('resource.0.opendate',$symb); + my $due = &Apache::lonnet::EXT('resource.$part.duedate',$symb)+1; + my $opn = &Apache::lonnet::EXT('resource.$part.opendate',$symb); my $add=int(($due-$opn)/$Int); -# $r->print("
$opn, to $due add=$add int=$Int"); - #$r->rflush(); $ConceptData{"Int.0"}=$opn; for (my $i=1;$i<$Int;$i++) { $ConceptData{"Int.$i"}=$opn+$i*$add; @@ -158,69 +148,54 @@ sub Interval { sub ShowOpGraph { - my ($InpStr, $Int_No)=@_; - - $r->print(< - - function display(name) { - document.forms.displayform.elements.dis.value=name; - window.status=name; - } - function cleardisplay() { - document.forms.displayform.elements.dis.value=''; - window.status='No Concept in particular'; - } - - -ENDPOP - - &Create_PrgWin(); - &Update_PrgWin("Starting to analyze problem"); - my $rid=substr($InpStr,8); + my ($rid,$part)=split(/\:/,substr($InpStr,8)); $ConceptData{"Interval"}=$Int_No; - &Interval(&InitAnalysis($rid,$students[0])); + #Initialize the option response true answers + my $symb=&InitAnalysis($rid,$students[0]); + #compute the intervals + &Interval($rid,$part,$symb); my $URI = $hash{'src_'.$rid}; my $Src = $hash{'title_'.$rid}; $Src =~ s/\ /"_"/eg; $r->print('
'.$URI.''); - for (my $n=1; $n<=$#Concepts+1; $n++ ) { - my $tmp=$Concepts[$n-1]; - $tmp =~ s/print("
Concept $n:$tmp"); - } - $r->rflush(); + #Java script Progress window + &Create_PrgWin(); + &Update_PrgWin("Starting to analyze problem"); for (my $index=0;$index<=$#students;$index++) { &Update_PrgWin($index); &OpStatus($rid,$students[$index]); } &Close_PrgWin(); + $r->print('
'); + for (my $k=0; $k<$Int_No; $k++ ) { + &DrawGraph($k,$Src); + } #$Apache::lonxml::debug=1; #&Apache::lonhomework::showhash(%ConceptData); #$Apache::lonxml::debug=0; - - for (my $k=0; $k<$Int_No; $k++ ) { - my $data1=''; - my $data2=''; - &DrawGraph(&AdjustData($k).'+'.$Src.'+'.($k+1)); - } my $Answ=&Apache::lonnet::ssi($URI); $r->print("
Here you can see the Problem:
$Answ"); } -sub AdjustData { - my $k=shift; + +sub DrawGraph { + my ($k,$Src)=@_; my $Max=0; my @data1; my @data2; + my $Correct=0; + my $Wrong=0; + # Adjust Data and find the Max for (my $n=0; $n<=$#Concepts; $n++ ) { my $tmp=$Concepts[$n]; $data1[$n]=$ConceptData{"$tmp.$k.true"}; + $Correct+=$data1[$n]; $data2[$n]=$ConceptData{"$tmp.$k.false"}; + $Wrong+=$data2[$n]; my $Sum=$data1[$n]+$data2[$n]; if ( $Max<$Sum ) {$Max=$Sum;} } @@ -229,72 +204,54 @@ sub AdjustData { $data2[$n]+=$Max-($data1[$n]+$data2[$n]); } } - return join(',',@data1).'+'. - join(',',@data2).'+'. - $Max.'+'.($#data1+1); -} + my $P_No = $#data1+1; +# $r->print('
From: ['.localtime($ConceptData{'Int.'.($k-1)}). +# '] To: ['.localtime($ConceptData{"Int.$k"}).']'); + my $Str = "\n".''. + "\n".''. + "\n".''. + "\n".''. + "\n".''. + "\n".''. + "\n".''; + + for (my $n=0; $n<=$#Concepts; $n++ ) { + $Str .= "\n"."". + "\n"."". + "\n"."". + "\n"."". + "\n"."". + "\n".""; + } +#$Apache::lonxml::debug=1; +#&Apache::lonhomework::showhash(%ConceptData); +#$Apache::lonxml::debug=0; +# $Str.='";# -sub DrawGraph { - my $data=shift; - my($data1,$data2,$Max,$P_No,$Src,$k)=split(/\+/,$data); + $Str .= "\n".'
# Concept Correct Wrong
".($n+1)." ".$Concepts[$n]." ".$data1[$n]." ".$data2[$n]."
From:['.localtime($ConceptData{'Int.$k'}). +# '] To: ['.localtime($ConceptData{'Int.'.($k+1)}). +# "]$Correct$Wrong
'; - my $Str="\n".''. - "\n".''. - "\n".''. - "\n".''. - "\n".''. - "\n".''. - "\n".''. - "\n"."". - "\n"."". - "\n"."". - "\n"."". - "\n"."". - "\n"."
Correct Answers Wrong Answers From To
$data1 $data2 ".localtime($ConceptData{'Int.'.($k-1)})." ".localtime($ConceptData{'Int.'.$k}-1)."
"; - $r->print($Str); +# $r->print($Str); -# $r->print('
Correct Answers: '.$data1. -# '
Wrong Answers: '.$data2); -# $r->print('
From: '.localtime($ConceptData{'Int.'.($k-1)}). -# '
To: '.localtime($ConceptData{"Int.$k"})); - -# if ( $Max > 1 ) { -# $Max += (10 - $Max % 10); -# $Max = int($Max); -# } -# else { $Max = 1; } - my $Titr=($ConceptData{'Interval'}>1) ? $Src.'_interval_'.$k : $Src; - $GData=$Titr.'&'.'Answers'.'&'.$Max.'&'.$P_No.'&'.$data1.'&'.$data2; - if($ConceptData{'Interval'}>1){ - $r->print('
'); - return; - } - $r->print('
Move your mouse over a bar to find out the concept'); - my $ptr=''; - $ptr.="\n".'
'; - $ptr.="\n".'

'. - "\n".''; - my $gap=12; - my $Size=340; - my $barsize=($P_No) ? int($Size/$P_No) : 1; - for (my $i=0; $i<$P_No; $i++) { - my $x1=80+$gap*$i+($i*$barsize); - my $x2=$x1+$barsize; - my $y1=25; - my $y2=350; - my $j=$i+1; - $ptr.="\n".''; - } - $ptr.="\n".''; - $ptr.="\n".'

'; - $r->print('
'.$ptr.'
'); + if ( $Max > 1 ) { + $Max += (10 - $Max % 10); + $Max = int($Max); + } else { $Max = 1; } + + + my $Titr=($ConceptData{'Interval'}>1) ? $Src.'_interval_'.($k+1) : $Src; +# $GData=$Titr.'&Concepts'.'&'.'Answers'.'&'.$Max.'&'.$P_No.'&'.$data1.'&'.$data2; + $GData="$Titr&Concepts&Answers&$Max&$P_No&". + (join(',',@data1)).'&'.(join(',',@data2)); + + $r->print(''); } sub AnalyzeProblem { -# -------------------------------- Selecting the number of intervals + # selecting the number of intervals my $OpSel=''; my $CurInt = $ENV{'form.interval'}; if ($CurInt eq '') {$CurMap = '1';} @@ -308,6 +265,7 @@ sub AnalyzeProblem { $Ptr .= ''."\n"; $r->print( $Ptr ); + #the table of option response problems $r->print('
Option Response Problems in this course:

'); my $Str = "\n".''. "\n".''. @@ -319,13 +277,14 @@ sub AnalyzeProblem { my $P_No=1; foreach (sort keys %OpResp) { - my $Temp = ''.$hash{'title_'.$OpResp{$_}}.''; + my ($rid,$part)=split(/\:/,$OpResp{$_}); + my $Temp = ''.$hash{'title_'.$rid}.''; $Str .= "\n"."". "\n"."". "\n"."". - "\n"."". - "\n"."'. + "\n"."". + "\n"."'. "\n".""; $P_No++; } @@ -337,6 +296,7 @@ sub AnalyzeProblem { sub Decide { + #deciding the true or false answer belongs to each interval my ($type,$foil,$time)=@_; my $k=0; while ($time>$ConceptData{'Int.'.($k+1)} && @@ -345,6 +305,7 @@ sub Decide { } +#restore the student submissions and finding the result sub OpStatus { my ($rid,$student)=@_; my ($uname,$udom)=split(/\:/,$student); @@ -356,47 +317,32 @@ sub OpStatus { my @True = (); my @False = (); my $flag=0; - @shown=(); if ($reshash{'version'}) { + my $tries=0; + &Apache::lonhomework::showhash(%Answer); for (my $version=1;$version<=$reshash{'version'};$version++) { my $time=$reshash{"$version:timestamp"}; - foreach (sort(split(/\:/,$reshash{$version.':keys'}))) { - if (($_=~/\.(\w+)\.(\w+)\.submission$/)) { - my $Id1 = $1; - my $Id2 = $2; - my $Resp = $reshash{$_}; + + foreach my $key (sort(split(/\:/,$reshash{$version.':keys'}))) { + if (($key=~/\.(\w+)\.(\w+)\.submission$/)) { + my $Id1 = $1; my $Id2 = $2; + #check if this is a repeat submission, if so skip it + if ($reshash{"$version:resource.$Id1.previous"}) { next; } + #if no solved this wasn't a real submission, ignore it + if (!defined($reshash{"$version:resource.$Id1.solved"})) { + &Apache::lonxml::debug("skipping "); + next; + } + my $Resp = $reshash{"$version:$key"}; my %submission=&Apache::lonnet::str2hash($Resp); foreach (keys %submission) { my $Ansr = $Answer{"$Id1.$Id2.foil.value.$_"}; - #$r->print("
shown: ".join(',',@shown)." size=$#shown"); if ($submission{$_}) { - #if($#shown==-1){ - #my @str=split(/\&/,$Resp); - #my $garb; - #for(my $j=0;$j<=$#str;$j++){ - # ($shown[$j],$garb)=split(/\=/,$str[$j]); - #} - ##$r->print("
shown: ".join(',',@shown)." size=$#shown"); - #} if ($submission{$_} eq $Ansr) { &Decide("true",$_,$time ); } else {&Decide("false",$_,$time );} } - #else { - # if ($#shown==-1 && $flag==0) { - # $flag++; - # &InitAnalysis($rid,$student); - # } - # my @erl=split(/\:/,$_); - # for (my $i=0;$i<=$#shown; $i++){ - # my $Ans=$Answer{"$Id1.$Id2.foil.value.$shown[$i]"}; - # if ($erl[$i] eq $Ans) { - # &Decide("true",$shown[$i],$time); - # } - # else {&Decide("false",$shown[$i],$time);} - # } - #} } } } @@ -600,11 +546,17 @@ sub StudentReport { } sub CreateTable { + my ($Hd, $Hid)=@_; + if ($ENV{'form.showcsv'}) { + if ( $Hd == 1 ) { + $r->print('
"'.$hash{'title_'.$Hid}.'","'.$hash{'src_'.$Hid}.'"'); + } + return; + } my $ColNo=0; foreach (keys(%Header)){ $ColNo++; } - my ($Hd, $Hid)=@_; if ( $Hd == 1 ) { $r->print('
'.$hash{'title_'.$Hid}.''); @@ -621,12 +573,16 @@ sub CreateTable { } sub CloseTable { + if ($ENV{'form.showcsv'}) { + return; + } $r->print("\n".'
$P_No ".$Temp." ".$hash{'src_'.$OpResp{$_}}." ".''.' ".$hash{'src_'.$rid}." ".''.'
'."\n"); $r->rflush(); } # ------------------------------------------- Prepare Statistics Table sub PreStatTable { + my $CacheDB = "/home/httpd/perl/tmp/$ENV{'user.name'}". "_$ENV{'user.domain'}_$cid\_statistics.db"; my $GraphDB = "/home/httpd/perl/tmp/$ENV{'user.name'}". @@ -659,8 +615,8 @@ sub PreStatTable { $Ptr .= '
'.
     '  #Stdnts: Total Number of Students opened the problem.
'. ' Tries : Total Number of Tries for solving the problem.
'. - ' Mod : Maximunm Number of Tries for solving the problem.
'. - ' Mean : Average Number of the tries. [ Tries / #Stdnts ]
'. + ' Max : Maximunm Number of Tries for solving the problem.
'. + ' Avg. : Average Number of the tries. [ Tries / #Stdnts ]
'. ' #YES : Number of students solved the problem correctly.
'. ' #yes : Number of students solved the problem by override.
'. ' %Wrng : Percentage of students tried to solve the problem but'. @@ -668,10 +624,10 @@ sub PreStatTable { # ' DoDiff : Degree of Difficulty of the problem. [ Tries/(#YES+#yes+0.1) ]
'. Kashy formula ' DoDiff : Degree of Difficulty of the problem. [ 1 - ((#YES+#yes) / Tries) ]
'. #Gerd formula ' S.D. : Standard Deviation of the tries.'. - '[ sqrt(sum((Xi - Mean)^2)) / (#Stdnts-1)'. + '[ sqrt(sum((Xi - Avg.)^2)) / (#Stdnts-1)'. ' where Xi denotes every student\'s tries ]
'. ' Skew. : Skewness of the students tries.'. - ' [ (sqrt( sum((Xi - Mean)^3) / #Stdnts)) / (S.D.^3) ]
'. + ' [ (sqrt( sum((Xi - Avg.)^3) / #Stdnts)) / (S.D.^3) ]
'. ' Dis.F. : Discrimination Factor: A Standard for '. 'evaluating the problem according to a Criterion
'. ' [Applied Criterion in %27 Upper Students - '. @@ -683,6 +639,11 @@ sub PreStatTable { '
'; $r->print($Ptr); + + $r->print('Output CSV format: print(' checked'); } + $r->print('>'); + $r->rflush(); if ((-e "$CacheDB")&&($ENV{'form.sort'} ne 'Recalculate Statistics')) { @@ -944,9 +905,8 @@ sub tracetable { foreach my $K(split(/\,/,&Apache::lonnet::metadata($meta,'packages'))) { if ($K=~/^optionresponse\_($Part)\_(\w+)$/) { #$r->print('
'.$_.'...'.$P_Order.'---'.$Part); - $OpResp{$P_Order}=$frid; + $OpResp{$P_Order}="$frid:$Part"; } - } } } @@ -968,7 +928,7 @@ sub tracetable { foreach (split(/\,/,&Apache::lonnet::metadata($meta,'packages'))) { if ($_=~/^optionresponse\_($Part)\_(\w+)$/) { #$r->print('
'.$_.'...'.$P_Order.'---'.$Part); - $OpResp{$P_Order}=$rid; + $OpResp{$P_Order}="$rid:$Part";; } } @@ -1045,7 +1005,6 @@ sub Build_Statistics { @list = sort (@list); - &Discriminant(); $OpSel2=''; @@ -1186,6 +1145,8 @@ sub Cache_Statistics { my $Useful; my $UnUseful; my %myHeader = reverse( %Header ); + #&Apache::lonnet::delenv('form_'); + #&Apache::lonnet::delenv('test'); $Pos = $myHeader{$ENV{'form.sort'}}; if ($Pos > 0) {$Pos++;} $p_count = 0; @@ -1233,7 +1194,28 @@ sub TableRow { my ($Str,$Idx,$RealIdx)=@_; my($PrOrd,$Temp,$StdNo,$TotalTries,$MxTries,$Avg,$YES,$Override, $Wrng,$DoD,$SD,$Sk,$_D1,$_D2,$Prob)=split(/\&/,$Str); - my $Ptr = "\n".''. + if ($ENV{'form.showcsv'}) { + my ($ResId,$Dummy)=split(/\*/,$Prob); + my $Ptr = "\n".'
'. + "\n".'"'.($RealIdx+1).'",'. + "\n".'"'.$hash{'title_'.$ResId}.$Dummy.'",'. + "\n".'"'.$hash{'src_'.$ResId}.'",'. + "\n".'"'.$StdNo.'",'. + "\n".'"'.$TotalTries.'",'. + "\n".'"'.$MxTries.'",'. + "\n".'"'.$Avg.'",'. + "\n".'"'.$YES.'",'. + "\n".'"'.$Override.'",'. + "\n".'"'.$Wrng.'",'. + "\n".'"'.$DoD.'",'. + "\n".'"'.$SD.'",'. + "\n".'"'.$Sk.'",'. + "\n".'"'.$_D1.'",'. + "\n".'"'.$_D2.'"'; + $r->print("\n".$Ptr); + } + else{ + my $Ptr = "\n".''. "\n".''.($RealIdx+1).''. # "\n".''.$PrOrd.$Temp.''. "\n".''.$Temp.''. @@ -1249,14 +1231,15 @@ sub TableRow { "\n".' '.$Sk.''. "\n".' '.$_D1.''. "\n".' '.$_D2.''; - $r->print("\n".$Ptr.'' ); + $r->print("\n".$Ptr.'' ); + } $GraphDat{$RealIdx}=$DoD.':'.$Wrng; } # ------------------------------------------- Prepare data for Graphical chart sub GetGraphData { - my $Tag = shift; + my $ylab = shift; my $Col; my $data=''; my $count = 0; @@ -1267,12 +1250,12 @@ sub GetGraphData { foreach (keys %GraphDat) {delete $GraphDat{$_};} if (-e "$GraphDB") { if (tie(%GraphDat,'GDBM_File',"$GraphDB",&GDBM_READER,0640)) { - if ( $Tag eq 'DoDiff Graph' ) { - $Tag = 'Degree-of-Difficulty'; + if ( $ylab eq 'DoDiff Graph' ) { + $ylab = 'Degree-of-Difficulty'; $Col = 0; } else { - $Tag = 'Wrong-Percentage'; + $ylab = 'Wrong-Percentage'; $Col = 1; } foreach (sort NumericSort keys %GraphDat) { @@ -1290,7 +1273,7 @@ sub GetGraphData { untie(%GraphDat); my $Course = $ENV{'course.'.$cid.'.description'}; $Course =~ s/\ /"_"/eg; - $GData=$Course.'&'.$Tag.'&'.$Max.'&'.$count.'&'.$data; + $GData=$Course.'&'.'Problems'.'&'.$ylab.'&'.$Max.'&'.$count.'&'.$data; } else { $r->print("Unable to tie hash to db file"); @@ -1323,6 +1306,26 @@ sub initial { $HWN=$P_Order; } +# my $CacheDB = "/home/httpd/perl/tmp/$ENV{'user.name'}". +# "_$ENV{'user.domain'}_$cid\_classlist.db"; +# if (-e "$CacheDB") { +# if (tie(%students,'GDBM_File',"$CacheDB",&GDBM_READER,0640)) { +# &CachClassList(); +# } +# else { +# $r->print("Unable to tie hash to db file"); +# } +# } +# else { +# if (tie(%students,'GDBM_File',$CacheDB,&GDBM_WRCREAT,0640)) { +# &MakeClassList(); +# } +# else { +# $r->print("Unable to tie hash to db file"); +# } +# } +# untie(%students); + sub ClassList { @@ -1335,38 +1338,37 @@ sub ClassList { $firstres=$hash{'map_start_/res/'.$ENV{'request.course.uri'}}; $lastres=$hash{'map_finish_/res/'.$ENV{'request.course.uri'}}; if (($firstres) && ($lastres)) { -# ----------------------------------------------------------------- Render page - my $classlst=&Apache::lonnet::reply - ('dump:'.$cdom.':'.$cnum.':classlist',$chome); +# my %students = &Apache::lonnet::dump('classlist',$cdom,$cnum); +# $Apache::lonxml::debug=1; +# &Apache::lonhomework::showhash(%students); +# $Apache::lonxml::debug=0; +# my $StudNo = 0; +# my $now=time; +# my ($temp)=keys(%students); +# unless ($temp=~/^error\:/) { +# foreach my $KeyPoint(sort keys(%students)) { + my $classlst=&Apache::lonnet::reply('dump:'.$cdom.':'.$cnum.':classlist',$chome); my $StudNo = 0; my $now=time; unless ($classlst=~/^error\:/) { - foreach (sort split(/\&/,$classlst)) { - my ($name,$value)=split(/\=/,$_); + foreach my $KeyPoint(sort split(/\&/,$classlst)) { + my ($name,$value)=split(/\=/,$KeyPoint); my ($end,$start)=split(/\:/,&Apache::lonnet::unescape($value)); - $name=&Apache::lonnet::unescape($name); - my ($sname,$sdom)=split(/\:/,$name); my $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; } -#//new -# $Status = 'Any'; -#end new + if ($active) { my $thisindex=$#students+1; $name=&Apache::lonnet::unescape($name); $students[$thisindex]=$name; my ($sname,$sdom)=split(/\:/,$name); - #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)); my $ssec=&usection($sdom,$sname,$cid,$Status); -# if ($ssec==-1 ) {next;} if ($ssec==-1 || $ssec eq 'adm' ) {next;} $ssec=($ssec) ? $ssec : '(none)'; #$ssec=(int($ssec)) ? int($ssec) : $ssec; @@ -1406,6 +1408,74 @@ sub ClassList { } +sub ClassListnew { + + &GetStatus(); + + $cid=$ENV{'request.course.id'}; + my $chome=$ENV{'course.'.$cid.'.home'}; + my ($cdom,$cnum)=split(/\_/,$cid); +# ----------------------- Get first and last resource, see if there is anything + $firstres=$hash{'map_start_/res/'.$ENV{'request.course.uri'}}; + $lastres=$hash{'map_finish_/res/'.$ENV{'request.course.uri'}}; + if (($firstres) && ($lastres)) { + + my %students = &Apache::lonnet::dump('classlist',$cdom,$cnum); + my $StudNo = 0; + my $now=time; + my ($temp)=keys(%students); + unless ($temp=~/^error\:/) { + foreach (sort keys(%students)) { + my ($name,$value)=split(/\=/,$_); + my ($end,$start)=split(/\:/,&Apache::lonnet::unescape($value)); + $name=&Apache::lonnet::unescape($name); + my ($sname,$sdom)=split(/\:/,$name); + my $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; + $name=&Apache::lonnet::unescape($name); + $students[$thisindex]=$name; + my ($sname,$sdom)=split(/\:/,$name); + #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)); + my $ssec=&usection($sdom,$sname,$cid,$Status); +# if ($ssec==-1 ) {next;} + if ($ssec==-1 || $ssec eq 'adm' ) {next;} + $ssec=($ssec) ? $ssec : '(none)'; + #$ssec=(int($ssec)) ? int($ssec) : $ssec; + $section{$ssec}=$ssec; + if ($CurSec eq 'All Sections' || $ssec eq $CurSec) { + $students[$StudNo]=$name; + $StuBox{$sname}=$sdom; + } + $StudNo++; + } + } + } + else { + $r->print('

Could not access course data

'); + } + $r->print("Total number of students : ".($#students+1)); + $r->rflush(); +# --------------- Find all assessments and put them into some linear-like order + &tracetable($firstres,'&'.$lastres.'&'); + } + +# ------------------------------------------------------------- End render page + else { + $r->print('

Undefined course sequence

'); + } +} + + sub Title { $r->print('LON-CAPA Statistics'); $r->print(''. @@ -1419,10 +1489,12 @@ sub Title { $r->rflush(); } + sub CreateForm { $r->print("\n".'
'); my $content = $ENV{'form.sort'}; - if ($content eq '' || $content eq 'Return to Menu') { + if (!($ENV{'form.showcsv'}) && #|| !($ENV{'csv'})) && + ($content eq '' || $content eq 'Return to Menu')) { my $Ptr = '

'; $Ptr .= ''; $Ptr .= '

'; @@ -1433,6 +1505,7 @@ sub CreateForm { $r->print( $Ptr ); } else { + &ClassList(); if ( $content eq 'Student Assessment' || $content eq 'Create Student Report' ) { &MapSecOptions(); @@ -1452,15 +1525,15 @@ sub CreateForm { sub Menu { &initial(); +# $Apache::lonxml::debug=1; +# &Apache::lonhomework::showhash(%ENV); +# $Apache::lonxml::debug=0; &Title(); - &ClassList(); my $InpStr = $ENV{'form.sort'}; if ($InpStr=~/^Analyze\_/) { + &ClassList(); &ShowOpGraph($InpStr,$ENV{'form.interval'}); } - #elsif ($InpStr=~/^View\_/) { -# &ShowStG(); - # } elsif ( $InpStr eq 'DoDiff Graph' || $InpStr eq '%Wrong Graph' ) { &GetGraphData($InpStr); $r->print(''); @@ -1530,7 +1603,7 @@ sub GetStatus { sub MapSecOptions { # ----------------------------------- Loading the Maps Combobox my $Ptr = '
'; - $Ptr .= '
'; + $Ptr .= ''; $Ptr .= '
Select   Map     '."\n". '