[LON-CAPA-cvs] cvs: loncom /interface lonstatistics.pm
minaeibi
lon-capa-cvs@mail.lon-capa.org
Thu, 16 May 2002 01:27:05 -0000
This is a MIME encoded message
--minaeibi1021512425
Content-Type: text/plain
minaeibi Wed May 15 21:27:05 2002 EDT
Modified files:
/loncom/interface lonstatistics.pm
Log:
Fixed some bugs in analysis problem's graph
--minaeibi1021512425
Content-Type: text/plain
Content-Disposition: attachment; filename="minaeibi-20020515212705.txt"
Index: loncom/interface/lonstatistics.pm
diff -u loncom/interface/lonstatistics.pm:1.18 loncom/interface/lonstatistics.pm:1.19
--- loncom/interface/lonstatistics.pm:1.18 Tue May 14 19:17:06 2002
+++ loncom/interface/lonstatistics.pm Wed May 15 21:27:05 2002
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# (Publication Handler
#
-# $Id: lonstatistics.pm,v 1.18 2002/05/14 23:17:06 minaeibi Exp $
+# $Id: lonstatistics.pm,v 1.19 2002/05/16 01:27:05 minaeibi Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -31,7 +31,7 @@
# 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 Behrouz Minaei
-# 5/12, 5/14 Behrouz Minaei
+# 5/12, 5/14, 5/15 Behrouz Minaei
#
###
@@ -119,6 +119,7 @@
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;
@@ -150,7 +151,9 @@
my ($InpStr, $Int_No)=@_;
my ($rid,$part)=split(/\:/,substr($InpStr,8));
$ConceptData{"Interval"}=$Int_No;
+ #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};
@@ -158,6 +161,7 @@
$r->print('<br><b>'.$URI.'</b>');
$r->rflush();
+ #Java script Progress window
&Create_PrgWin();
&Update_PrgWin("Starting to analyze problem");
for (my $index=0;$index<=$#students;$index++) {
@@ -166,6 +170,7 @@
}
&Close_PrgWin();
+ $r->print('<br>');
for (my $k=0; $k<$Int_No; $k++ ) {
&DrawGraph($k,$Src);
}
@@ -218,34 +223,35 @@
"\n"."<td bgcolor=#FFDDDD> ".$data2[$n]." </td>".
"\n"."</tr>";
}
- $Str.='<td></td><td><b>From:['.localtime($ConceptData{'Int.'.($k-1)}).
- '] To: ['.localtime($ConceptData{"Int.$k"}).
- "]</b></td><td>$Correct</td><td>$Wrong</td>";
+#$Apache::lonxml::debug=1;
+#&Apache::lonhomework::showhash(%ConceptData);
+#$Apache::lonxml::debug=0;
+
+# $Str.='<td></td><td><b>From:['.localtime($ConceptData{'Int.$k'}).
+# '] To: ['.localtime($ConceptData{'Int.'.($k+1)}).
+# "]</b></td><td>$Correct</td><td>$Wrong</td>";#
$Str .= "\n".'</table>';
- $r->print($Str);
+# $r->print($Str);
if ( $Max > 1 ) {
$Max += (10 - $Max % 10);
$Max = int($Max);
} else { $Max = 1; }
- if ( $Max > 1 ) {
- $Max += (10 - $Max % 10);
- $Max = int($Max);
- } else { $Max = 1; }
- my $Titr=($ConceptData{'Interval'}>1) ? $Src.'_interval_'.$k : $Src;
+
+ 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('<br><IMG src="/cgi-bin/graph.gif?'.$GData.'" />');
+ $r->print('<IMG src="/cgi-bin/graph.gif?'.$GData.'" border=1/>');
}
sub AnalyzeProblem {
-# -------------------------------- Selecting the number of intervals
+ # selecting the number of intervals
my $OpSel='';
my $CurInt = $ENV{'form.interval'};
if ($CurInt eq '') {$CurMap = '1';}
@@ -259,6 +265,7 @@
$Ptr .= '</select>'."\n";
$r->print( $Ptr );
+ #the table of option response problems
$r->print('<br><b> Option Response Problems in this course:</b><br><br>');
my $Str = "\n".'<table border=2>'.
"\n".'<tr>'.
@@ -289,6 +296,7 @@
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)} &&
@@ -297,6 +305,7 @@
}
+#restore the student submissions and finding the result
sub OpStatus {
my ($rid,$student)=@_;
my ($uname,$udom)=split(/\:/,$student);
@@ -573,6 +582,7 @@
# ------------------------------------------- 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'}".
@@ -995,7 +1005,6 @@
@list = sort (@list);
-
&Discriminant();
$OpSel2='';
@@ -1136,6 +1145,8 @@
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;
@@ -1295,6 +1306,26 @@
$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 {
@@ -1307,34 +1338,37 @@
$firstres=$hash{'map_start_/res/'.$ENV{'request.course.uri'}};
$lastres=$hash{'map_finish_/res/'.$ENV{'request.course.uri'}};
if (($firstres) && ($lastres)) {
- #my %result = &Apache::lonnet::dump('classlist',$sdom,$sname);
+# 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; }
+
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;
@@ -1374,6 +1408,74 @@
}
+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('<h1>Could not access course data</h1>');
+ }
+ $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('<h3>Undefined course sequence</h3>');
+ }
+}
+
+
sub Title {
$r->print('<html><head><title>LON-CAPA Statistics</title></head>');
$r->print('<body bgcolor="#FFFFFF">'.
@@ -1387,10 +1489,12 @@
$r->rflush();
}
+
sub CreateForm {
$r->print("\n".'<form name=stat method=post action="/adm/statistics" >');
my $content = $ENV{'form.sort'};
- if (!($ENV{'form.showcsv'}) && ($content eq '' || $content eq 'Return to Menu')) {
+ if (!($ENV{'form.showcsv'}) && #|| !($ENV{'csv'})) &&
+ ($content eq '' || $content eq 'Return to Menu')) {
my $Ptr = '<h3>';
$Ptr .= '<input type=submit name=sort value="Problem Stats"/>';
$Ptr .= '<br><br>';
@@ -1401,6 +1505,7 @@
$r->print( $Ptr );
}
else {
+ &ClassList();
if ( $content eq 'Student Assessment' ||
$content eq 'Create Student Report' ) {
&MapSecOptions();
@@ -1420,13 +1525,13 @@
sub Menu {
&initial();
- #$Apache::lonxml::debug=1;
- #&Apache::lonhomework::showhash(%ENV);
- #$Apache::lonxml::debug=0;
+# $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 eq 'DoDiff Graph' || $InpStr eq '%Wrong Graph' ) {
@@ -1497,7 +1602,7 @@
sub MapSecOptions {
# ----------------------------------- Loading the Maps Combobox
- my $Ptr = '';
+ my $Ptr = '<br>';
$Ptr .= '<input type="submit" name="sort" value="Return to Menu" />';
$Ptr .= '<br><b> Select Map </b>'."\n".
'<select name="maps">'."\n".
--minaeibi1021512425--