[LON-CAPA-cvs] cvs: loncom /interface lonstatistics.pm

minaeibi lon-capa-cvs@mail.lon-capa.org
Sat, 02 Mar 2002 23:22:32 -0000


minaeibi		Sat Mar  2 18:22:32 2002 EDT

  Modified files:              
    /loncom/interface	lonstatistics.pm 
  Log:
  Fixed bugs,
  New interface with re-arranging the problems according to HW sets.
  Added Student Status 
  
  
Index: loncom/interface/lonstatistics.pm
diff -u loncom/interface/lonstatistics.pm:1.5 loncom/interface/lonstatistics.pm:1.6
--- loncom/interface/lonstatistics.pm:1.5	Fri Mar  1 20:42:42 2002
+++ loncom/interface/lonstatistics.pm	Sat Mar  2 18:22:32 2002
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # (Publication Handler
 #
-# $Id: lonstatistics.pm,v 1.5 2002/03/02 01:42:42 minaeibi Exp $
+# $Id: lonstatistics.pm,v 1.6 2002/03/02 23:22:32 minaeibi Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -30,7 +30,7 @@
 # 5/05,7/09,7/25/01,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 Behrouz Minaei
+# 1/22, 2/1, 2/6, 2/25, 3/2 Behrouz Minaei
 ###
 
 package Apache::lonstatistics; 
@@ -75,7 +75,7 @@
 my $DiscFlag;
 my $HWN;
 my $P_Order;
-my %Header = (0,"Homework Problems",1,"#Stdnts",2,"Tries",3,"Mod",
+my %Header = (0,"Homework Sets Order",1,"#Stdnts",2,"Tries",3,"Mod",
               4,"Mean",5,"#YES",6,"#yes",7,"%Wrng",8,"DoDiff",
               9,"S.D.",10,"Skew.",11,"Map");
 #             11,"Dis.F.",12,"Resourse URL");
@@ -244,9 +244,22 @@
                   "_$ENV{'user.domain'}_$cid\_graph.db";
     my $CachDisFac = "/home/httpd/perl/tmp/$ENV{'user.name'}".
 		     "_$ENV{'user.domain'}_$cid\_DiscFactor.db";
-    $r->print('<br><input type="submit" name="sort" value="Recalculate Statistics" />');
+    my $OpSel11='';
+    my $OpSel12='';
+    my $OpSel13='';
+    my $Status = $ENV{'form.status'};
+    if ( $Status eq 'Any' ) { $OpSel13='selected'; }
+    elsif ($Status eq 'Expired' ) { $OpSel12 = 'selected'; }
+    else { $OpSel11 = 'selected'; }
 
     my $Ptr = '';
+    $Ptr .= '<br><b> Student Status: &nbsp; </b>'."\n".
+            '<select name="status">'. 
+            '<option '.$OpSel11.' >Active</option>'."\n".
+            '<option '.$OpSel12.' >Expired</option>'."\n".
+	    '<option '.$OpSel13.' >Any</option> </select> '."\n";
+    $Ptr .= '&nbsp;&nbsp;&nbsp;';
+    $Ptr .= '<input type=submit name=sort value="Recalculate Statistics"/>'."\n";
 
     $Ptr .= '<br><b> Sorting Type: &nbsp; </b>'."\n".
             '<select name="order"> <option '.$OpSel1.' >Ascending</option>'."\n".
@@ -312,24 +325,37 @@
 # ------------------------------------- Find the section of student in a course
 
 sub usection {
-    my ($udom,$unam,$courseid)=@_;
+    my ($udom,$unam,$courseid,$ActiveFlag)=@_;
     $courseid=~s/\_/\//g;
     $courseid=~s/^(\w)/\/$1/;
-    map {
+    foreach (split(/\&/,&Apache::lonnet::reply('dump:'.
+             $udom.':'.$unam.':roles',
+             &Apache::lonnet::homeserver($unam,$udom)))){
         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.'<br>');
+	    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';
 }
 
 
@@ -553,7 +579,7 @@
 }
 
 sub MySort {          
-    if ( $Pos > 0 && $Pos < 11 ) {
+    if ( $Pos > 0 ) {
 	if ($ENV{'form.order'} eq 'Descending') {$b <=> $a;}
 	else { $a <=> $b; }
     }
@@ -567,7 +593,7 @@
     $r->print(<<ENDPOP);
     <script>
     popwin=open('','popwin','width=400,height=100');
-    popwin.document.writeln('<html><body bgcolor="#7777EE">'+
+    popwin.document.writeln('<html><body bgcolor="#88CC88">'+
       '<title>LON-CAPA Statistics</title>'+
       '<h4>Computation Progress</h4>'+
       '<form name=popremain>'+
@@ -701,7 +727,7 @@
 	    my $join = $PrOrd.':'.$Temp.':'.$StdNo.':'.
                        $TotalTries.':'.$MxTries.':'.$Avg.':'.
                        $YES.':'.$Override.':'.$Wrng.':'.$DoD.':'.
-		       $SD.':'.$Sk.':'.$Map.':'.$Prob;
+		       $SD.':'.$Sk.':'.$Prob;
 	    $CachData{($p_count-1)}=$join;
 
 	    $urlres=~/^(\w+)\/(\w+)/;
@@ -727,7 +753,7 @@
     $p_count = 0;
     foreach my $key( keys %CachData) { 
 	my @Temp=split(/\:/,$CachData{$key});
-	if ( $Pos == 0 || $Pos == 11 ) {
+	if ( $Pos == 0 ) {
 	    ($UnUseful,$Useful)=split(/\>/,$Temp[$Pos]);
 	}
 	else {
@@ -767,7 +793,7 @@
 sub TableRow {
     my ($Str,$Idx,$RealIdx)=@_;
     my($PrOrd,$Temp,$StdNo,$TotalTries,$MxTries,$Avg,$YES,
-       $Override,$Wrng,$DoD,$SD,$Sk,$res,$Prob)=split(/\:/,$Str);	
+       $Override,$Wrng,$DoD,$SD,$Sk,$Prob)=split(/\:/,$Str);	
     $r->print( "\n".'<tr>'.
                "\n".'<td>'.($RealIdx+1).'</td>'.
                "\n".'<td bgcolor="#FFFFFF">'.$Temp.'</td>'.
@@ -866,23 +892,42 @@
 	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(/\=/,$_);
 		my ($end,$start)=split(/\:/,&Apache::lonnet::unescape($value));
 		$name=&Apache::lonnet::unescape($name);
 		my ($sname,$sdom)=split(/\:/,$name);
-		my $ssec=&Apache::lonnet::usection($sdom,$sname,$cid);
-                if ($ssec==-1) {next;}
-		$ssec=($ssec) ? $ssec : '(none)';
-		#$ssec=(int($ssec)) ? int($ssec) : $ssec;
-		#$r->print($sname.'...'.$ssec.'<br>');
-		$section{$ssec}=$ssec;
-		if ($CurSec eq 'All Sections' || $ssec eq $CurSec) {
-		    $students[$StudNo]=$name;
-		    $StuBox{$sname}=$ssec;
-		}
-		$StudNo++;
+		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;}
+		    $ssec=($ssec) ? $ssec : '(none)';
+		    #$ssec=(int($ssec)) ? int($ssec) : $ssec;
+		    #$r->print($sname.'...'.$ssec.'<br>');
+		    $section{$ssec}=$ssec;
+		    if ($CurSec eq 'All Sections' || $ssec eq $CurSec) {
+			$students[$StudNo]=$name;
+			$StuBox{$sname}=$ssec;
+		    }
+		    $StudNo++;
+	        }
 	    }
 	}
 	else {