print( $Ptr );
+ #the table of option response problems
$r->print(' Option Response Problems in this course: ');
my $Str = "\n".''.
"\n".''.
"\n".' # '.
"\n".' Problem Title '.
- "\n".' Resouse '.
+ "\n".' Resource '.
"\n".' Address '.
"\n".' ';
@@ -335,6 +365,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)} &&
@@ -343,6 +374,7 @@ sub Decide {
}
+#restore the student submissions and finding the result
sub OpStatus {
my ($rid,$student)=@_;
my ($uname,$udom)=split(/\:/,$student);
@@ -354,47 +386,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 = $ConceptData{"$_"};
- #my $Ansr = $Answer{"$Id1.$Id2.foil.value.$_"};
- #$r->print(" shown: ".join(',',@shown)." size=$#shown");
+ my $Ansr = $Answer{"$Id1.$Id2.foil.value.$_"};
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);}
- # }
- #}
}
}
}
@@ -506,7 +523,7 @@ sub StudentReport {
"\n".' Tries '.
"\n".'';
my ($temp)=keys(%result);
- unless ($temp=~/^error\:/) {
+ unless ($temp=~/^(con_lost|error|no_such_host)/i) {
foreach my $CurCol (@cols) {
if (!$CurCol){
my $Set=&Apache::lonnet::declutter($hash{'map_id_'.$1});
@@ -598,11 +615,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}.' ');
@@ -619,12 +642,16 @@ sub CreateTable {
}
sub CloseTable {
+ if ($ENV{'form.showcsv'}) {
+ return;
+ }
$r->print("\n".'
'."\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'}".
@@ -657,7 +684,7 @@ 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. '.
+ ' Mod : Maximunm Number of Tries for solving the problem. '.
' Mean : Average Number of the tries. [ Tries / #Stdnts ] '.
' #YES : Number of students solved the problem correctly. '.
' #yes : Number of students solved the problem by override. '.
@@ -681,6 +708,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')) {
@@ -717,15 +749,18 @@ sub usection {
my ($udom,$unam,$courseid,$ActiveFlag)=@_;
$courseid=~s/\_/\//g;
$courseid=~s/^(\w)/\/$1/;
- foreach (split(/\&/,&Apache::lonnet::reply('dump:'.
- $udom.':'.$unam.':roles',
- &Apache::lonnet::homeserver($unam,$udom)))){
- my ($key,$value)=split(/\=/,$_);
- $key=&Apache::lonnet::unescape($key);
+
+ my %result=&Apache::lonnet::dump('roles',$udom,$unam);
+ my ($checkForResult)=keys(%result);
+ if ($checkForResult=~/^(con_lost|error|no_such_host)/i) {
+ return -1;
+ }
+ foreach my $key (keys (%result)) {
+ my $value=$result{$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 ($dummy,$end,$start)=split(/\_/,$value);
if ( $ActiveFlag ne 'Any' ) {
my $now=time;
my $notactive=0;
@@ -772,7 +807,7 @@ sub ExtractStudentData {
my $SecLimit;
my $MapLimit;
my ($temp)=keys(%result);
- unless ($temp=~/^error\:/) {
+ unless ($temp=~/^(con_lost|error|no_such_host)/i) {
foreach my $CurCol(@cols) {
($PrOrd,$ResId)=split(/\:/,$CurCol);
if ( !$CurCol ) { next; }
@@ -895,6 +930,7 @@ sub ExtractStudentData {
}
+
# ------------------------------------------------------------ Build page table
sub tracetable {
my ($rid,$beenhere)=@_;
@@ -1042,7 +1078,6 @@ sub Build_Statistics {
@list = sort (@list);
-
&Discriminant();
$OpSel2='';
@@ -1182,6 +1217,7 @@ sub Cache_Statistics {
my @list = ();
my $Useful;
my $UnUseful;
+# $r->print(' '."\n");
my %myHeader = reverse( %Header );
$Pos = $myHeader{$ENV{'form.sort'}};
if ($Pos > 0) {$Pos++;}
@@ -1230,7 +1266,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.' '.
@@ -1246,7 +1303,8 @@ sub TableRow {
"\n".' '.$Sk.' '.
"\n".' '.$_D1.' '.
"\n".' '.$_D2.' ';
- $r->print("\n".$Ptr.' ' );
+ $r->print("\n".$Ptr.'' );
+ }
$GraphDat{$RealIdx}=$DoD.':'.$Wrng;
}
@@ -1320,50 +1378,72 @@ 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 {
&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)) {
-# ----------------------------------------------------------------- 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 $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 %classlist=&Apache::lonnet::dump('classlist',$cdom,$cnum);
+
+ my ($checkForError)=keys(%result);
+ if($checkForError=~/^(con_lost|error|no_such_host)/i) {
+ $r->print('Could not access course data ');
+ } else {
+ foreach my $name (keys (%classlist)) {
+ my $value=$classlist{$name};
+ my ($end,$start)=split(/\:/,$value);
my $active=1;
my $Status=$ENV{'form.status'};
$Status = ($Status) ? $Status : 'Active';
if ( ( ($end) && $now > $end ) &&
- ( ($Status eq 'Active') ) ) { $active=0; }
+ ( ($Status eq 'Active') ) ) { $active=0; }
if ( ($Status eq 'Expired') &&
- ($end == 0 || $now < $end) ) { $active=0; }
-#//new
-# $Status = 'Any';
-#end new
+ ($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;
@@ -1373,12 +1453,10 @@ sub ClassList {
$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
@@ -1416,10 +1494,12 @@ sub Title {
$r->rflush();
}
+
sub CreateForm {
$r->print("\n".'