#!/usr/bin/perl # # $Id: IntegroStats.pl,v 1.2 2005/10/31 17:03:34 ddoughty Exp $ # # Source File: IntegroStats.pl # Get config # use strict; use FileHandle; use Time::Local; use Data::Dumper; require 'sitecfg.pl'; require 'testlib.pl'; require 'tstatlib.pl'; require 'ui.pl'; #use strict; use vars qw(%FORM %SESSION %CLIENT %TEST_SESSION %SUBTEST_QUESTIONS %TEST %SUBTEST_SUMMARY %CANDIDATE %SUBTEST_ANSWERS); use vars qw($testcomplete $cgiroot $pathsep $dataroot ); &app_initialize; &LanguageSupportInit(); &get_session($FORM{'tid'}); #&get_client_profile($SESSION{'clid'}); my @sortbys = qw(Name LoginID Date); my ($bExport,$idlist); #print STDERR Dumper(\%FORM,\%CLIENT,\%SESSION); #if (exists $FORM{'grouping'} and $FORM{'grouping'} eq 'subset') { #$idlist = &getIdlist($CLIENT{'clid'},$FORM{'idlist'}); #} if ($FORM{'export'}) { print "Content-Type: application/doc\n\n"; $bExport=1; } elsif ($FORM{'csv'}) { print "Content-Type: text/x-csv\n\n"; } else { print "Content-Type: text/html\n\n"; $bExport=0; } #print STDERR Dumper(\%FORM,$idlist); if (&get_session($FORM{'tid'})) { if ($FORM{'testsummary'} eq 'composite') { &show_test_composite($idlist); } elsif ($FORM{'testsummary'} eq 'bycnd') { &show_test_resultsbycnd($idlist); } else { &extract_test_data(); } } if ($bExport) { exit(0); } sub extract_test_data() { &LanguageSupportInit(); &get_client_profile($SESSION{'clid'}); &get_test_profile($CLIENT{'clid'}, $FORM{'tstid'}); my @filelist = &get_test_result_files($testcomplete, "$CLIENT{'clid'}","$TEST{'id'}"); my @colhdrs=(); push @colhdrs,""; if ($FORM{'cndnme'}) { push @colhdrs,"left:Last Name"; push @colhdrs,"left:First Name"; push @colhdrs,"left:MI"; } push @colhdrs,"left:User ID"; if ($FORM{'cndeml'}) { push @colhdrs,"left:Email Address"; } if ($FORM{'cnd1'}) { push @colhdrs,"left:$CLIENT{'clcnd1'}"; } if ($FORM{'cnd2'}) { push @colhdrs,"left:$CLIENT{'clcnd2'}"; } if ($FORM{'cnd3'}) { push @colhdrs,"left:$CLIENT{'clcnd3'}"; } if ($FORM{'cnd4'}) { push @colhdrs,"left:$CLIENT{'clcnd4'}"; } if ($FORM{'cndscr'}) { push @colhdrs,"center:Correct"; push @colhdrs,"center:Incorrect"; push @colhdrs,"right:Score"; } my @dataflds=(); my @unsorted=(); my $row=""; my @qsumry=(); my $user=""; my $joint="\&"; my $colhdr; my $colalgn; my $fidx; for ($fidx = 0; $fidx <= $#filelist; $fidx++ ) { $user = $filelist[$fidx]; $user =~ s/.$TEST{'id'}$//; $user =~ s/^$CLIENT{'clid'}.//; my $excuser="inc$user"; if ($FORM{$excuser}) { next; } &get_test_sequence_for_reports( $CLIENT{'clid'}, $user, $TEST{'id'}); @qsumry = split(/\&/, $SUBTEST_SUMMARY{2}); &get_candidate_profile($CLIENT{'clid'},$user); if ($FORM{'cndnme'}) { $row=join($joint,$row,"$CANDIDATE{'nml'}"); $row=join($joint,$row,"$CANDIDATE{'nmf'}"); $row=join($joint,$row,"$CANDIDATE{'nmm'}"); } $row=join($joint,$row,"$user"); if ($FORM{'cndeml'}) { $row=join($joint,$row,"$CANDIDATE{'eml'}"); } if ($FORM{'cnd1'}) { $row=join($joint,$row,"$CANDIDATE{'cnd1'}"); } if ($FORM{'cnd2'}) { $row=join($joint,$row,"$CANDIDATE{'cnd2'}"); } if ($FORM{'cnd3'}) { $row=join($joint,$row,"$CANDIDATE{'cnd3'}"); } if ($FORM{'cnd4'}) { $row=join($joint,$row,"$CANDIDATE{'cnd4'}"); } if ($FORM{'cndscr'}) { $row=join('&',$row,$qsumry[0],$qsumry[1],$qsumry[2]); } push @unsorted, $row; $row=""; } my @sorted=sort @unsorted; @unsorted=(); my $rowcount=$#filelist+1; &print_report_dataextract_header($rowcount,@colhdrs,@colalign); my ($i); for $i (0 .. $#sorted) { @dataflds=split($joint, $sorted[$i]); if ($bExport) { for $i (1 .. $#dataflds) { print "$dataflds[$i]"; if ($i == $#dataflds) { print "\n"; } else { print "\t"; } } } else { print "\n"; for $i (1 .. $#dataflds) { ($colalgn,$colhdr) = split(/:/,$colhdrs[$i]); print "\t\t$dataflds[$i]\n"; } print "\n"; } } &print_report_bycnd_footer(); @sorted=(); } sub print_report_dataextract_header { my ($ncount,@cols)= @_; my $colhdr; my $colalgn; my $i; if ($bExport) { print "$TEST{'desc'} ($TEST{'id'})\n"; print "Raw Data Extraction\n"; print "$ncount Completed Responses\n"; for $i (1 .. $#cols) { ($colalgn,$colhdr) = split(/:/,$cols[$i]); print "$colhdr"; if ($i == $#cols) { print "\n"; } else { print "\t"; } } } else { print "\n"; print "\n"; print "\tTest Data Extraction\n"; print "\t\n"; print "\n"; print "\n"; print "
\n"; print "$TEST{'desc'} ($TEST{'id'})
\n"; print "Raw Data Extraction
\n"; print "$ncount Completed Responses\n"; print "\n"; print "\t\n"; for $i (1 .. $#cols) { ($colalgn,$colhdr) = split(/:/,$cols[$i]); print "\t\t\n"; } print "\t<\TR>\n"; } } sub date_out_of_range { my ($completedat,$datefm,$dateto) = @_; my @unsorted=(); push @unsorted, $completedat; push @unsorted, $datefm; push @unsorted, $dateto; my @sorted = sort @unsorted; my $bretyes = ($sorted[1] eq $unsorted[0]) ? 0 : 1; @unsorted=(); @sorted=(); return $bretyes; } $^W=1; sub sort_test_results { my ($sortby,@rows) = @_; if ($sortby eq 'Name') { #print STDERR "by Name\n"; return sort {$a->{'columns'}->[0] cmp $b->{'columns'}->[0];} @rows; } elsif ($sortby eq 'LoginID') { #print STDERR "by LoginID\n"; return sort {$a->{'columns'}->[1] cmp $b->{'columns'}->[1];} @rows; } elsif ($sortby eq 'Date') { #print STDERR "by Date\n"; return sort {$a->{'end'} <=> $b->{'end'};} @rows; } else { #print STDERR "by Nothing\n"; return @rows; } } sub show_test_resultsbycnd { &LanguageSupportInit(); &get_client_profile($SESSION{'clid'}); &get_test_profile($CLIENT{'clid'}, $FORM{'tstid'}); my @filelist = &get_test_result_files($testcomplete, "$CLIENT{'clid'}","$TEST{'id'}"); my ($url) = ("$cgiroot/IntegroStats.pl?"); if (not $FORM{'sortby'}) {$FORM{'sortby'}=$sortbys[0];} if (not $FORM{'reverse'}) {$FORM{'reverse'}=0;} foreach (keys %FORM) { if (($_ ne 'sortby') and ($_ ne 'reverse') and ($FORM{$_} !~ /\s+/)) { #print STDERR "$_=$FORM{$_}\n"; $url .= "&$_=$FORM{$_}"; } else { #print STDERR "NOT $_=$FORM{$_}\n"; } } my $csvurl = $url."&csv=1&sortby=$FORM{'sortby'}&reverse=".($FORM{'reverse'}?0:1); my $reverseurl = $url."&sortby=$FORM{'sortby'}&reverse=".($FORM{'reverse'}?0:1); my %sorturls; foreach my $sorter (@sortbys) { $sorturls{$sorter} = $url."&sortby=$sorter"; } my @sorted=(); my @unsorted=(); my $user; my $test; my $qidx; my $trash; my $subjskl; my $subj; my $sklvl; my $subjlist=","; my @qids=(); my @qsumry=(); my @corincs=(); my $bysubjflag = ($FORM{'statsbysubj'} ne '') ? 1 : 0; my @subjects=(); my @subjcnts=(); my @subjtot=(); my @subjmean=(); my @subjmedian=(); my @meanscore=split('\,',"0,0,0,0,100,0,0"); my @medianscore=(); my $i=0; my $j=0; my $fidx; my @rows=(); my $row={}; my @answ=(); my $qid; my $usrnm; my $nresultcount=$#filelist+1; my $mtime; my $completedat; my $displaydate; if ($FORM{'mofm'} < 10) { $FORM{'mofm'}="0$FORM{'mofm'}";} if ($FORM{'moto'} < 10) { $FORM{'moto'}="0$FORM{'moto'}";} if ($FORM{'dyfm'} < 10) { $FORM{'dyfm'}="0$FORM{'dyfm'}";} if ($FORM{'dyto'} < 10) { $FORM{'dyto'}="0$FORM{'dyto'}";} my $datefm="$FORM{'yrfm'}\-$FORM{'mofm'}\-$FORM{'dyfm'}"; my $dateto="$FORM{'yrto'}\-$FORM{'moto'}\-$FORM{'dyto'}"; for ($fidx = 0; $fidx <= $#filelist; $fidx++ ) { $user = $filelist[$fidx]; $user =~ s/.$TEST{'id'}$//; $user =~ s/^$CLIENT{'clid'}.//; my $history = get_testhistory_from_log($CLIENT{'clid'},$user,$FORM{'tstid'}); if (not defined $history) { $history = get_cnd_test_from_history($testcomplete,$CLIENT{'clid'},$user,$FORM{'tstid'}); } if (not defined $history) { # no log file entry for this test #print STDERR "$testcomplete.$pathsep.$filelist[$fidx]\n"; my $mtime = (stat($testcomplete.$pathsep.$filelist[$fidx]))[9]; $history->{'end'} = $mtime; $history->{'start'} = $history->{'end'}; #print STDERR Dumper($history); } #$trash=join($pathsep,$testcomplete,$filelist[$fidx]); #open (TMPFILE, "<$trash"); #$mtime = (stat(TMPFILE))[9]; #close TMPFILE; $completedat = &format_date_time("yyyy-mm-dd", "1", "-10000", $history->{'end'}); $displaydate = &format_date_time("dd-mmm-yyyy", "1", "-10000", $history->{'end'}); #print STDERR "$completedat $displaydate $datefm $dateto\n"; if (&date_out_of_range($completedat,$datefm,$dateto)) { $nresultcount--; next; } my $excuser="inc$user"; if ($FORM{$excuser}) { $nresultcount--; next; } &get_test_sequence_for_reports( $CLIENT{'clid'}, $user, $TEST{'id'}); @qids = split(/\&/, $SUBTEST_QUESTIONS{2}); @answ=split(/\&/,$SUBTEST_ANSWERS{2}); @qsumry = split(/\&/, $SUBTEST_SUMMARY{2}); @corincs = split(/\//, $qsumry[$#qsumry]); for $i (0 .. $#subjects) { $subjcnts[$i][0]=0; $subjcnts[$i][1]=0; $subjcnts[$i][2]=0; $subjcnts[$i][3]=0; } &get_candidate_profile($CLIENT{'clid'},$user); $usrnm="$CANDIDATE{'nml'}, $CANDIDATE{'nmf'} $CANDIDATE{'nmm'}"; $row={'columns' => [$usrnm,$user,$displaydate]}; $row->{'start'} = $history->{'start'}; $row->{'end'} = $history->{'end'}; #print STDERR "Survey = $TEST_SESSION{'srvy'}\n"; if ($SUBTEST_SUMMARY{2} ne 'Not Scored by Definition') { for $qid (1 .. $#qids) { ($test,$qidx) = split(/\./, $qids[$qid]); ($trash,$subjskl) = split(/::/, $answ[$qid]); ($subj,$sklvl,$trash)=split(/\.|\:/,$subjskl); unless ($subjlist =~ /\,$subj\,/i) { $subjlist = join('',$subjlist,"$subj\,"); push @subjects,"$subj"; $i=$#subjects; $subjcnts[$i][0]=0; # questions in subject area $subjcnts[$i][1]=0; # correct answers $subjcnts[$i][2]=0; # incorrect answers $subjcnts[$i][3]=0; # pct correct $subjtot[$i][0]=0; $subjtot[$i][1]=0; $subjtot[$i][2]=0; $subjtot[$i][3]=0; $subjmean[$i][0]=0; # population count $subjmean[$i][1]=0; # population value summation $subjmean[$i][2]=0; # population mean $subjmean[$i][3]=0; # population standard deviation $subjmean[$i][4]=100; # population range-low $subjmean[$i][5]=0; # population range-high } for $i (0 .. $#subjects) { if ($subj eq $subjects[$i]) { $subjcnts[$i][0]++; $subjtot[$i][0]++; if (substr($corincs[$qid],0,1) eq '1') { $subjcnts[$i][1]++; $subjtot[$i][1]++; } else { $subjcnts[$i][2]++; $subjtot[$i][2]++; } $subjcnts[$i][3]=int((($subjcnts[$i][1]/$subjcnts[$i][0])*100)); $subjtot[$i][3]=int((($subjtot[$i][1]/$subjtot[$i][0])*100)); last; } } } if ($bysubjflag) { for $i (0 .. $#subjects) { push @{$row->{'columns'}},$subjcnts[$i][0],$subjcnts[$i][1],$subjcnts[$i][2],$subjcnts[$i][3]; $subjmean[$i][0]++; $subjmean[$i][1]+=$subjcnts[$i][3]; $subjmean[$i][2]=int(($subjmean[$i][1]/$subjmean[$i][0])); #$subjmean[$i][4]=(($subjcnts[$i][3] < $subjmean[$i][4]) || ($subjmean[$i][4] == 0)) ? $subjcnts[$i][3] : $subjmean[$i][4]; $subjmean[$i][4]=($subjcnts[$i][3] < $subjmean[$i][4]) ? $subjcnts[$i][3] : $subjmean[$i][4]; $subjmean[$i][5]=($subjcnts[$i][3] > $subjmean[$i][5]) ? $subjcnts[$i][3] : $subjmean[$i][5]; $subjmedian[$i][$fidx]=$subjcnts[$i][3]; $subjcnts[$i][0]=0; $subjcnts[$i][1]=0; $subjcnts[$i][2]=0; $subjcnts[$i][3]=0; } } $meanscore[0]++; # data count $meanscore[1]+=$qsumry[2]; # sum of values $meanscore[2]=int(($meanscore[1]/$meanscore[0])); # unbiased population mean $meanscore[4]=($qsumry[2] < $meanscore[4]) ? $qsumry[2] : $meanscore[4]; $meanscore[5]=($qsumry[2] > $meanscore[5]) ? $qsumry[2] : $meanscore[5]; $medianscore[$fidx]=$qsumry[2]; } push @{$row->{'columns'}},$qsumry[0],$qsumry[1],$qsumry[2]; push @rows, $row; } @sorted=sort {$a <=> $b} @medianscore; $j=$#sorted/2; $i=$sorted[$j]; if (($#sorted % 2) == 0) { @medianscore=(); $medianscore[0]=$i; } else { $j++; $i+=$sorted[$j]; @medianscore=(); $medianscore[0]=int(($i/2)); } my @scores=(); for $i (0 .. $#subjects) { for $j (0 .. $#filelist) { $scores[$j]=$subjmedian[$i][$j]; } @sorted=sort {$a <=> $b} @scores; @scores=(); $j=$#sorted/2; $qid=$sorted[$j]; if (($#sorted % 2) == 0) { $subjmedian[$i][0]=$qid; } else { $j++; $qid+=$sorted[$j]; $subjmedian[$i][0]=int(($qid/2)); } } # The sorting block if ($FORM{'reverse'}) { @sorted = reverse &sort_test_results($FORM{'sortby'},@rows); } else { @sorted = &sort_test_results($FORM{'sortby'},@rows); } # end of the sorting block @rows=(); if ($FORM{'csv'}) { &print_report_bycnd_csv(@sorted); return; } my $colspan=&print_report_bycnd_header($nresultcount,$bysubjflag,\%sorturls,$FORM{'sortby'}, $csvurl,$reverseurl,@subjects); @unsorted=(); @subjcnts=(); my $symbol=""; my @cols=(); my @rowhdrs=('Questions','Correct','Incorrect','Pct Correct'); my $rowspan=($bysubjflag) ? ($#rowhdrs+1) : 1; foreach my $row (@sorted) { @cols=@{$row->{'columns'}}; my ($start,$end,$duration,$datestamp,$total); if ($bExport) { print "$cols[0]\t$cols[1]\t$cols[2]\t"; if ($bysubjflag) { print "\n";} } else { #($start,$end,$duration) = get_teststartend($CLIENT{'clid'},$cols[1],$FORM{'tstid'}); $start = sprintf("%02d:%02d:%02d",reverse((localtime($row->{'start'}))[0..2])); $end = sprintf("%02d:%02d:%02d",reverse((localtime($row->{'end'}))[0..2])); $duration = &fmtDuration($row->{'end'} - $row->{'start'}); if ($end == "Unknown" ) { $datestamp = ""; } else { my $gmend = sprintf("%02d:%02d:%02d",reverse((gmtime($row->{'end'}))[0..2])); $datestamp = "$cols[2] $gmend GMT"; $datestamp =~ s/ /_/g; } $total = $cols[3] + $cols[4]; print "\t\n"; print "\t\t\n"; print "\t\t\n"; print "\t\t\n"; } if ($bysubjflag) { for $j (0 .. $#rowhdrs) { $symbol=($j==3) ? "\%" : ""; if ($j > 0) { if ($bExport == 0) { print "\t\n"; } } if ($bExport) { print "\t\t$rowhdrs[$j]\t"; } else { print "\t\t\n"; } for $fidx (0 .. $#subjects) { $qid=($fidx*4)+$j+3; if ($bExport) { print "$cols[$qid]\t"; } else { print "\t\t\n"; } if ($j==3) { $subjmean[$fidx][3]+=(($subjmean[$fidx][2]-$cols[$qid])*($subjmean[$fidx][2]-$cols[$qid])); } } if ($j == 0) { $fidx=$#cols-2; if ($bExport) { print "$cols[$fidx++]\t"; print "$cols[$fidx++]\t"; print "$cols[$fidx]\t"; } else { print "\t\t\n"; print "\t\t\n"; print "\t\t\n"; } } if ($bExport) { print "\n"; } else { print "\t\n"; } } } else { $j=$#cols-2; if ($bExport) { print "$cols[$j++]\t"; print "$cols[$j++]\t"; print "$cols[$j]\n"; } else { print "\t\t\n"; print "\t\t\n"; print "\t\t\n"; if ($SUBTEST_SUMMARY{2} ne 'Not Scored by Definition') { print "\t\t\n"; print "\t\t\n"; print "\t\t\n"; } else { print "\t\t\n"; } print "\t\n"; } } if ($bysubjflag) { if ($bExport==0) { print "\t\n"; print "\t\t\n"; print "\t\n"; } } $meanscore[3]+=(($meanscore[2]-$cols[$#cols])*($meanscore[2]-$cols[$#cols])); @cols=(); } $meanscore[3]=int((sqrt($meanscore[3]/($#sorted+1)))); if ($bysubjflag) { @rowhdrs=('Questions','Correct','Incorrect','Pct Correct','Unbiased Mean','Std. Dev.','Range-Low','Range-High','Median'); $rowspan=$#rowhdrs+1; for $j (0 .. $#rowhdrs) { if ($bExport == 0) { print "\t\n"; } if ($j == 0) { if ($bExport) { print "\n\tComposite\t"; } else { print "\t\t\n"; } } else { if ($bExport) { print "\t\t"; } } if ($bExport) { print "$rowhdrs[$j]\t"; } else { print "\t\t\n"; } if ($j < 4) { $symbol=($j==3) ? "\%" : ""; for $fidx (0 .. $#subjects) { if ($bExport) { print "$subjtot[$fidx][$j]\t"; } else { print "\t\t\n"; } } if ($j == 0) { if ($bExport) { print "\t\t"; } else { print "\t\t\n"; } } elsif ($j == 3) { if ($bExport) { print "\tOverall\t"; } else { print "\t\t\n"; } } } else { $symbol="\%"; $i=$j-2; for $fidx (0 .. $#subjects) { if ($i == 6) { if ($bExport) { print "$subjmedian[$fidx][0]\t"; } else { print "\t\t\n"; } } else { if ($i==3) { $subjmean[$fidx][3]=int((sqrt(($subjmean[$fidx][3]/$subjmean[$fidx][0])))); if ($bExport) { print "$subjmean[$fidx][$i]\t"; } else { print "\t\t\n"; } } else { if ($bExport) { print "$subjmean[$fidx][$i]\t"; } else { print "\t\t\n"; } } } } $i=$j-2; if ($i==3) { if ($bExport) { print "\t$meanscore[$i]\t"; } else { print "\t\t\n"; } } elsif ($i==6) { if ($bExport) { print "\t$medianscore[0]\t"; } else { print "\t\t\n"; } } else { if ($bExport) { print "\t$meanscore[$i]\t"; } else { print "\t\t\n"; } } } if ($bExport) { print "\n"; } else { print "\t\n"; } } if ($bExport == 0) { print "\t\n"; print "\t\t\n"; print "\t\n"; } } elsif ($SUBTEST_SUMMARY{2} ne 'Not Scored by Definition') { @rowhdrs=('Unbiased Mean','Std. Dev.','Range-Low','Range-High','Median'); $rowspan=$#rowhdrs+1; $symbol="\%"; #print STDERR Dumper(\@meanscore); for $j (0 .. $#rowhdrs) { $i=$j+2; if ($bExport == 0) { print "\t\n"; } if ($j==0) { if ($bExport) { print "\tComposite\n"; } else { print "\t\t\n"; } } if ($bExport) { print "\t$rowhdrs[$j]\t"; } else { print "\t\t\n"; } if ($j==1) { if ($bExport) { print "\t\t$meanscore[$i]"; } else { print "\t\t\n"; } } elsif ($j==4) { if ($bExport) { print "\t\t$medianscore[0]"; } else { print "\t\t\n"; } } else { if ($bExport) { print "\t\t$meanscore[$i]"; } else { print "\t\t\n"; } } if ($bExport) { print "\n"; } else { print "\t\n"; } } if ($bExport == 0) { print "\t\n"; print "\t\t\n"; print "\t\n"; } } else { if ($bExport == 0) { print "\t\n"; print "\t\t\n"; print "\t\n"; } } &print_report_bycnd_footer(); @subjtot=(); @subjects=(); @sorted=(); } $^W=0; sub print_report_bycnd_header { my ($ncount,$bysubj,$sorturls,$sortby,$csvurl,$reverseurl,@subjects) = @_; my $i; my $titlesfx=""; my $nsubjects = $#subjects; my $colspan=$nsubjects+2; my $colspan2=$nsubjects+2; if ($bysubj) { $colspan2+=6; $titlesfx=" (Subject Area)"; } else { $colspan2=9; } my $sortspan = int($colspan2/8); # wac changed 4 to 8 to make columns closer if ($bExport) { print "$TEST{'desc'} ($TEST{'id'})\n"; print "Question$titlesfx Response Statistics\n"; print "$ncount Completed Responses\n"; print "Candidate\tDate\t"; if ($bysubj) { print "BD\t"; for $i (0 .. $nsubjects) { print "$subjects[$i]\t"; } }; print "TC\tTI\tTS\n"; } else { print "\n"; print "\n"; print "\tQuestion Response Statistics\n"; print "\t\n"; print "\n"; print "\n"; print "
\n"; print "$TEST{'desc'} ($TEST{'id'})
\n"; print "Question$titlesfx Response Statistics
\n"; print "$ncount Completed Responses\n"; print "
$colhdr
$cols[0]$cols[1]$cols[2]
$rowhdrs[$j]$cols[$qid]$symbol$cols[$fidx++]$cols[$fidx++]$cols[$fidx]\%
$start$end$duration$cols[$j++]$cols[$j++]$cols[$j]\%Not Scored by Definition

Composite$rowhdrs[$j]$subjtot[$fidx][$j]$symbol\ \;
Overall$subjmedian[$fidx][0]$symbol\&\#177$subjmean[$fidx][$i]$symbol$subjmean[$fidx][$i]$symbol\&\#177$meanscore[$i]$symbol$medianscore[0]$symbol$meanscore[$i]$symbol

Composite$rowhdrs[$j]\&\#177$meanscore[$i]$symbol$medianscore[0]$symbol$meanscore[$i]$symbol


\n"; print "\t\n"; print "\t\t\n"; print "\t\n"; print "\t\n"; print "\t\n"; print "\t\t\n"; print "\t\t\n"; print "\t\t\n"; if ($bysubj) { print "\t\t\n"; } else { print "\t\t\n"; print "\t\t\n"; print "\t\t\n"; } print "\t\t\n"; print "\t\n"; print "\t\n"; if ($bysubj) { print "\t\t\n"; for $i (0 .. $nsubjects) { print "\t\t\n"; } }; print "\t\t\n"; print "\t\t\n"; print "\t\t\n"; print "\t\n"; print "\t\n"; } return $colspan2; } sub print_report_bycnd_footer { if ($bExport) { return;} print "
\n"; foreach (@sortbys) { if ($_ ne $sortby) { print "\t\t\t{$_}\">Sort by $_
\n"; } else { print "\t\t\tSorted by $_
\n"; } } print "\t\t\t
"; print "CSV Report\n\t\t\t
 
"; print "Change to ".($FORM{'reverse'}?'ascending':'descending')."\n\t\t

CandidateLoginIDDateSubject AreasStartEndDurationOverall
\ \;$subjects[$i]CorrectIncorrectScore

\n"; print "\n"; print "\n"; } sub print_report_bycnd_csv { print "userid,testname,date,score\n"; my %testlookup; my $lookupfile = join($pathsep,$dataroot,"namelookup.$CLIENT{'clid'}"); #print STDERR "Opening $lookupfile\n"; if (-e $lookupfile) { my $fh = new FileHandle; if ($fh->open($lookupfile)) { while ($_ = <$fh>) { chomp; my @line = split(/\s+/,$_,2); $testlookup{$line[0]} = $line[1]; } } } foreach (@_) { my @row = @{$_->{'columns'}}; my ($userid,$testid,$date,$score) = ($row[1],$TEST{'id'},$row[2],$row[$#row]); if ($testlookup{$testid}) {$testid = $testlookup{$testid};} print join(',',$userid,$testid,$date,$score)."\n"; } } sub show_test_composite { my ($idlist) = @_; &LanguageSupportInit(); $mymsg = ""; my $nresponses=0; #&get_client_profile($SESSION{'clid'}); &get_test_profile("integroleadership", $FORM{'tstid'}); @questions = &get_question_list($TEST{'id'},"integroleadership"); $qhdr = shift @questions; @sorted = sort @questions; @questions = @sorted; unshift @questions, $qhdr; @sorted = (); my @client_data = get_client_list(); shift @client_data; foreach (@client_data) { ($clientID, $trash) = split('&', $_); push(@filelist, &get_test_result_files($testcomplete, "$clientID", "$TEST{'id'}")); } #@client_data = (); for (1 .. $#questions) { ($id,$qtp,$qim,$qil,$qtx,$qca,$qia,$qrm) = split(/\&/, $questions[$_]); if ( $qtp eq 'nrt' ) { $qca = 'N/A'; } $qtx =~ s/\;/
/g; #$qtx = $qtx; ($test,$qid) = split(/\./, $id); $qstatsid[$qid] = $id; $qstatsqc[$qid] = 0; # occurrences of question $qstatsqp[$qid] = 0; # percent occurrences of question $qstatsqt[$qid] = $qtx; # question text if ($qil eq 'Y') { $qstatsqf[$qid] = "obs"; # question type } else { $qstatsqf[$qid] = $qtp; # question type $qallans = ""; if ($qtp eq 'tf') { $qallans = "$qca\;$qia\;$xlatphrase[670]"; #670=No Response } elsif ($qtp eq 'mcs' || $qtp eq 'mca') { if ($qca eq '') { $qallans = "$qia\;$xlatphrase[670]"; } else { $qallans = "$qca\;$qia\;$xlatphrase[670]"; } } elsif ($qtp eq 'mtx' || $qtp eq 'mtr') { # DED When qca is saved correctly in tdef, # put this back and delte rest: # $qallans = "$qca"; ($qiar, $qiac) = split("RC", $qia); @qiar = split("\;", $qiar); @qiac = split("\;", $qiac); $qallans = ""; foreach $qiarow (@qiar) { foreach $qiacol (@qiac) { $qallans .= "xxx\;"; } } } elsif ($qtp eq 'mcm') { if ($qca eq '') { $qallans = "$qia"; } else { $qallans = "$qca\;$qia"; } } elsif ($qtp eq 'esa') { if ($qca eq '') { $qallans = ""; } else { $qallans = "$qca"; } } elsif ($qtp eq 'nrt') { if ($qca eq '') { $qallans = "Other\;$xlatphrase[670]"; } else { $qallans = "$qca\;Other\;$xlatphrase[670]"; } } elsif ($qtp eq 'mch') { @qcans = split(/\;/, $qca); @qians = split(/\;/, $qia); for (my $i = 0; $i <= $#qcans; $i++ ) { $qallans = join('', $qallans, "$qcans[$i]===$qians[$i]
"); } } elsif ($qtp eq 'ord') { $qallans = "$qca"; } $qallans =~ s/\;\;/\;/g; $qstatsqr[$qid] = $qallans; # response options $fqstatsqr[$qid] = $qallans; ### DED for FBQ $qstatsqw[$qid] = (); if (($qtp eq 'mch') || ($qtp eq 'ord')) { if ($qtp eq 'mch') { @qstato = split(/
/, $qallans); } else { @qstato = split(/\;/, $qallans); } $ncount = $#qstato + 1; $ncount = int(($ncount * ($ncount + 1)) + 3); for (my $i = 0; $i <= $ncount; $i++ ) { $qstatsqrc[$qid] = join('', $qstatsqrc[$qid], "0\;"); # response option count $qstatsqrp[$qid] = join('', $qstatsqrp[$qid], "0\;"); # response option percentage } } elsif ($qtp eq 'mcm' || $qtp eq 'esa' || $qtp eq 'mtx' || $qtp eq 'mtr') { @qstato = split(/\;/, $qallans); if ($qtp eq 'mtr') { # Have to allow for [1..5] in # each answer, so make it big! $ncount = (($#qstato + 1) * 5) + 3; } else { $ncount = $#qstato + 3; } for (my $i = 0; $i <= $ncount; $i++ ) { $qstatsqrc[$qid] = join('', $qstatsqrc[$qid], "0\;"); # response option count $qstatsqrp[$qid] = join('', $qstatsqrp[$qid], "0\;"); # response option percentage } } else { @qstato = split(/\;/, $qallans); foreach $qstat (@qstato) { $qstatsqrc[$qid] = join('', $qstatsqrc[$qid], "0\;"); # response option count $qstatsqrp[$qid] = join('', $qstatsqrp[$qid], "0\;"); # response option percentage } } } @qstato = (); } $ncount = $#filelist + 1; @qucmts=(); $nresponses=$#filelist+1; for (my $fidx = 0; $fidx <= $#filelist; $fidx++ ) { $tmpclientID = $filelist[$fidx]; $tmpclientID =~ s/^([\w]+).//; $clientID = $1; $user = $filelist[$fidx]; $user =~ s/.$TEST{'id'}$//; $user =~ s/^$clientID.//; #print STDERR "----> ClientID: $clientID User: $user\n"; if (defined $idlist and not $idlist->{$user}) { $nresponses--; next; } my $excuser="inc$user"; if ($FORM{$excuser}) { $nresponses--; next; } &get_test_sequence_for_reports( $clientID, $user, $TEST{'id'}); @qids = split(/\&/, $SUBTEST_QUESTIONS{2}); @qrsp = split(/\&/, $SUBTEST_RESPONSES{2}); @qsumry = split(/\&/, $SUBTEST_SUMMARY{2}); @corincs = split(/\//, $qsumry[5]); @qsumry = (); @qsumry = split(/\&/, $SUBTEST_ANSWERS{2}); @qansseq = (); $fqid=""; $fqididx=""; for (1 .. $#qids) { ($test,$qidx) = split(/\./, $qids[$_]); ($qansord,$trash) = split(/::/, $qsumry[$_]); $qansord =~ s/\=([0-1])//g; $qansseq[$_] = $qansord; ($qresp,$qucmt) = split(/::/, $qrsp[$_]); $qresp=~ tr/+/ /; $qresp=~ tr/'//d; $qrsp[$_]=$qresp; ##### v ADT - 7/03/2002 ################################################ # Added code to print NRT answers in the form of the comments ######################################################################## push @qresponses, "$qidx\&$user\&$qresp"; ##### ^ ADT - 7/03/2002 ################################################ if ($qucmt ne '') { $qucmt =~ tr/+/ /; $qucmt =~ tr/'//d; push @qucmts, "$qidx\&$user\&$qucmt"; } ### DED 10/28/2002 Support for filter-by-question (FBQ) if ($FORM{'question'} eq $qids[$_]) { $fqididx=$_; ($trash,$fqid)=split(/\./,$qids[$_]); } } ### DED 10/28/2002 Support for filter-by-question (fbq) #print "

FormQues= $FORM{'question'} Ans= $FORM{'answer'} Qansseq= $qansseq[$fqididx]

\n"; if ($fqid ne "" && $FORM{'answer'} ne "") { $fmatch=0; if ($qstatsqf[$fqid] eq 'mcs' || $qstatsqf[$fqid] eq 'mca') { @fqansseq=split(/\?/,$qansseq[$fqididx]); shift @fqansseq; @fans=split(/\&/,$FORM{'answer'}); shift @fans; foreach $fans (@fans) { @ffresp=(); $fresp=""; for (0 .. $#fqansseq) { $fqseqans[$fqansseq[$_]]=$_; $ffresp[$_]="xxx"; } if ($fans ne "No+Response") { $ffresp[$fqseqans[$fans]]=$fqseqans[$fans]; } if ($ffresp[0] eq "") { $fresp=""; } else { foreach (@ffresp) { $fresp=join('?',$fresp,$_); } } if ($qrsp[$fqididx] eq $fresp && $fresp ne "") { $fmatch=1; } @ffresp=(); if ($fmatch == 1) { break; } } @fqansseq=(); @fans=(); } elsif ($qstatsqf[$fqid] eq 'mcm') { @fqansseq=split(/\?/,$qansseq[$fqididx]); shift @fqansseq; @fans=split(/\&/,$FORM{'answer'}); shift @fans; @ffresp=(); $fresp=""; for (0 .. $#fqansseq) { $fqseqans[$fqansseq[$_]]=$_; $ffresp[$_]="xxx"; } if ($fans[0] ne "No+Response") { foreach (@fans) { $ffresp[$fqseqans[$_]]=$fqseqans[$_]; } } if ($ffresp[0] eq "") { $fresp=""; } else { foreach (@ffresp) { $fresp=join('?',$fresp,$_); } } if ($qrsp[$fqididx] eq $fresp && $fresp ne "") { $fmatch=1; } @fqansseq=(); @fans=(); @ffresp=(); } elsif ($qstatsqf[$fqid] eq 'tf') { if ($FORM{'answer'} eq "\&0" ) { $fresp=$qansseq[$fqididx]; } elsif ($FORM{'answer'} eq "\&1" ) { SWITCH: for ($qansseq[$fqididx]) { $fresp = /TRUE/ && "FALSE" || /FALSE/ && "TRUE" || /YES/ && "NO" || /NO/ && "YES" || "bad"; } } elsif ($FORM{'answer'} eq "\&No+Response") { $fresp=""; } else { $fresp="bad"; } if ($qrsp[$fqididx] eq $fresp && $fresp ne "bad") { $fmatch=1; } } elsif ($qstatsqf[$fqid] eq 'esa') { ($fqstatsqr,$trash)=split(/;Other/,$fqstatsqr[$fqid]); @fqr=split(/\;/,$fqstatsqr); @fans=split(/\&/,$FORM{'answer'}); shift @fans; if ($fans[0] eq "No+Response") { $fqr=""; if ($fqr eq $qrsp[$fqididx]) { $fmatch=1; } } else { foreach (@fans) { $fqr=lc($fqr[$_]); $fqrsp=lc($qrsp[$fqididx]); if ($fqr eq $fqrsp && $fqr ne "") { $fmatch=1; last; } } } @fqr=(); @fans=(); } #print "

FQid= $fqid Qtp= $qstatsqf[$fqid] Qstatsid= $qstatsid[$fqid] Fresp= $fresp Qrsp=$qrsp[$fqididx]

\n"; if ($fmatch == 0) { ### Don't count this one #print "...Skipping..."; $nresponses--; next; } $fresp=""; } ### DED End fbq support @qsumry=(); for (1 .. $#qids) { ($test,$qidx) = split(/\./, $qids[$_]); if ($qstatsqf[$qidx] ne 'obs') { $qstatsqc[$qidx]++; $qstatsqp[$qidx] = format_percent(($qstatsqc[$qidx] / $ncount), { fmt => "%.0f" } ); @qstatc = split(/\;/, $qstatsqrc[$qidx]); @qstatp = split(/\;/, $qstatsqrp[$qidx]); if ($qstatsqf[$qidx] eq 'tf') { @qstato = split(/\;/, $qstatsqr[$qidx]); if ($qrsp[$_] eq $qstato[0]) { $qstatc[0]++; } elsif ($qrsp[$_] eq $qstato[1]) { $qstatc[1]++; } else { $qstatc[2]++; } }elsif ($qstatsqf[$qidx] eq 'esa'){ $ncountidx = $#qstatc - 2; $qresp = $qrsp[$_]; $qresp =~ s/\+/ /g; if ($qresp ne '') { # # if answered, Determine from the score summary # if answered correctly # $corinc = substr($corincs[$_], 0, 1); if ($corinc == 0) { $ncountidx++; } $qstatc[$ncountidx]++; if ($corinc == 1) { @qansord = split(/\;/, $qansseq[$_]); for $q (0 .. $#qansord) { if ($qansord[$q] eq $qresp) { $qstatc[$q]++; last; } } } else { # incorrect $found=0; @qstatw=split(/\;/,$qstatsqw[$qidx]); shift(@qstatw); for $q (0 .. $#qstatw) { if ($qstatw[$q] eq $qresp) { $qstatsqwc[$q]++; $found=1; last; } } if ($found != 1) { $qstatsqwc[$#qstatw+1]=1; $qstatsqw[$qidx]=join(';',$qstatsqw[$qidx],$qresp); } @qstatq=(); } } else { $qstatc[$#qstatc]++; } @qansord = (); }elsif ($qstatsqf[$qidx] eq 'nrt'){ if ($qrsp[$_] ne '') { $qstatc[1]++; $qrsp[$_] =~ s/\;/\:/g; $qrsp[$_] =~ s/\r//g; $qrsp[$_] =~ s/\n/\\n/g; $qstatsqr[$qidx] = join('
',$qstatsqr[$qidx],$qrsp[$_]); } else { $qstatc[2]++; } } elsif ($qstatsqf[$qidx] eq 'mcs' || $qstatsqf[$qidx] eq 'mca') { ### DED Filter out "?" and "xxx" in qrsp so will match $qrsp[$_] =~ s/\?//g; $qrsp[$_] =~ s/xxx//g; @qansord = split(/\?/, $qansseq[$_]); shift @qansord; $found = 0; ### DED 10/09/02 Changed to allow for ### randomized answers #for (my $i = 0; $i <= $#qansord; $i++ ) { #if (("$qansord[$i]" eq "$qrsp[$_]") && ($qrsp[$_] ne '')) { if ($qrsp[$_] ne '') { $qstatc[$qansord[$qrsp[$_]]]++; $found = 1; } #} unless ($found) { # increment "No Response" $qstatc[$#qstatc]++; } @qansord = (); } elsif ($qstatsqf[$qidx] eq 'mtx') { $ncountidx = $#qstatc - 2; $qresp = $qrsp[$_]; $qresp =~ s/xxx//g; $qresp =~ s/\?//g; if ($qresp ne '') { # # if answered, Determine from the score summary # if answered correctly # $corinc = substr($corincs[$_], 0, 1); if ($corinc == 0) { $ncountidx++; } $qstatc[$ncountidx]++; if ($corinc == 0) { ($id,$qtp,$qim,$qil,$qtx,$qca,$qia,$qrm) = split(/\&/, $questions[$qidx]); ($qiar, $qiac) = split("RC", $qia); @qiar = split("\;", $qiar); @qiac = split("\;", $qiac); # skipping answer sequence part (no rand answ) $holding3 = $_; @qresps = split(/\?/, $qrsp[$_]); shift @qresps; $i=0; foreach $qiarow (@qiar) { foreach $qiacol (@qiac) { if ($qresps[$i] ne "xxx") { $qstatc[$i]++; } $i++; } } } } else { # increment No Response counter $qstatc[$#qstatc]++; } @qansord = (); $_ = $holding3; } elsif ($qstatsqf[$qidx] eq 'mtr') { $ncountidx = $#qstatc - 2; $qresp = $qrsp[$_]; $qresp =~ s/xxx//g; $qresp =~ s/\?//g; if ($qresp ne '') { # # if answered, Determine from the score summary # if answered correctly # $corinc = substr($corincs[$_], 0, 1); if ($corinc == 0) { $ncountidx++; } $qstatc[$ncountidx]++; if ($corinc == 0) { ($id,$qtp,$qim,$qil,$qtx,$qca,$qia,$qrm) = split(/\&/, $questions[$qidx]); ($qiar, $qiac) = split("RC", $qia); @qiar = split("\;", $qiar); @qiac = split("\;", $qiac); # skipping answer sequence part (no rand answ) $holding3 = $_; @qresps = split(/\?/, $qrsp[$_]); shift @qresps; $iqresps=0; $iqstatc=0; foreach $qiarow (@qiar) { foreach $qiacol (@qiac) { if ($qresps[$iqresps] ne "xxx") { # $qresps[$iqresps] will be [1..5], so adjust index accordingly $irank = $iqstatc + $qresps[$iqresps] - 1; $qstatc[$irank]++; } $iqresps++; $iqstatc += 5; } } } } else { # increment No Response counter $qstatc[$#qstatc]++; } @qansord = (); $_ = $holding3; } elsif ($qstatsqf[$qidx] eq 'mcm') { $ncountidx = $#qstatc - 2; $qresp = $qrsp[$_]; $qresp =~ s/xxx//g; $qresp =~ s/\?//g; if ($qresp ne '') { # # if answered, Determine from the score summary # if answered correctly # $corinc = substr($corincs[$_], 0, 1); if ($corinc == 0) { $ncountidx++; } $qstatc[$ncountidx]++; if ($corinc == 0) { @qansord = split(/\?/, $qansseq[$_]); shift @qansord; $holding3 = $_; #$found = 0; ### DED 10/18/02 Changed to allow for ### randomized answers & new format @qresps = split(/\?/, $qrsp[$_]); shift @qresps; foreach $qresp (@qresps) { if ($qresp ne "xxx") { $qstatc[$qansord[$qresp]]++; } } } } else { $qstatc[$#qstatc]++; } @qansord = (); $_ = $holding3; } elsif ($qstatsqf[$qidx] eq 'mch') { $ncountidx = $#qstatc - 2; $qresp = $qrsp[$_]; $qresp =~ s/xxx//g; $qresp =~ s/\?//g; if ($qresp ne '') { # # if answered, Determine from the score summary # if answered correctly # $corinc = substr($corincs[$_], 0, 1); if ($corinc == 0) { $ncountidx++; } $qstatc[$ncountidx]++; ### DED 10/18/02 Changed for ### random answers and new format # # Count occurrence of each match # $qansseq[$qidx] [Wrong! DED] # $qansseq[$_] # &a.3.2.0.6.5.8.4.7.1::MATCH.0:1:1:0 # $qrsp[$_] # &dgihbfcea [Old format] # &?d?g?i?h?b?f?c?e?a [New] #$qansseq[$qidx] =~ s/\&//g; $qansseq[$_] =~ s/\&//g; $qrsp[$_] =~ s/\&//g; $qrsp[$_] =~ s/ //g; #@corord = split(/\./, $qansseq[$qidx]); @corord = split(/\./, $qansseq[$_]); #@selord = split(//,$qrsp[$_]); @selord = split(/\?/,$qrsp[$_]); shift @selord; $corhold = $_; if ($corinc == 0) { for (0 .. $#selord) { if ($selord[$_] ne 'xxx') { ($x = &get_label_index($corord[0],$selord[$_]))++; $y = $corord[$x]; #$ncountidx = int($_ * $#corord + $y); $ncountidx = int($y * $#corord + $_); } else { $ncountidx = int(($#corord * $#corord ) + $_); } $qstatc[$ncountidx]++; } } $_ = $corhold; @selord = (); @corord = (); } else { $qstatc[$#qstatc]++; } } elsif ($qstatsqf[$qidx] eq 'ord') { $ncountidx = $#qstatc - 2; $qresp = $qrsp[$_]; $qresp =~ s/xxx//g; ### DED 10/18/02 Changed for ### random answers and new format $qresp =~ s/\?//g; if ($qresp ne '') { # # if answered, Determine from the score summary # if answered correctly # $corinc = substr($corincs[$_], 0, 1); if ($corinc == 0) { $ncountidx++; } $qstatc[$ncountidx]++; # # Count occurrence of each incorrect order # &o.2.3.4.1.0::ORDERED.0:1:1:0 # &34521 [Old format] # &?3?4?5?2?1 [New] # #$qansseq[$qidx] =~ s/\&//g; $qansseq[$_] =~ s/\&//g; $qrsp[$_] =~ s/\&//g; #@corord = split(/\./, $qansseq[$qidx]); @corord = split(/\./, $qansseq[$_]); #@selord = split(//,$qrsp[$_]); @selord = split(/\?/,$qrsp[$_]); shift @selord; $corhold = $_; if ($corinc == 0) { for (1 .. $#corord) { $ncountidx = int(($corord[$_]) * $#corord); $x = int($_ - 1); if ($selord[$x] ne 'xxx') { $ncountidx = $ncountidx + int($selord[$x]) - 1; } else { $ncountidx = int(($#corord * $#corord) + $_ - 1); } $qstatc[$ncountidx]++; } } $_ = $corhold; @selord = (); @corord = (); } else { $qstatc[$#qstatc]++; } } ### DED 8/20/2002 If checked, don't count ### "No Response" in statistics if ($FORM{'exnoresp'}) { if ($qstatsqc[$qidx] > $qstatc[$#qstatc]) { $denom = $qstatsqc[$qidx] - $qstatc[$#qstatc]; } else { $denom = 1; } for (my $i = 0; $i <= $#qstatc-1; $i++ ) { $qstatp[$i] = format_percent($qstatc[$i] / $denom); } } else { for (my $i = 0; $i <= $#qstatc; $i++ ) { $qstatp[$i] = format_percent($qstatc[$i] / $qstatsqc[$qidx]); } } $qstatsqrc[$qidx] = ""; foreach $qstat (@qstatc) { $qstatsqrc[$qidx] = join('', $qstatsqrc[$qidx], "$qstat\;"); } $qstatsqrp[$qidx] = ""; ### DED 8/22/2002 Exclude "No Response" ### from statistics if ($FORM{'exnoresp'}) { $count = $#qstatc-1; } else { $count = $#qstatp } for (0 .. $count) { $qstatsqrp[$qidx] = join('', $qstatsqrp[$qidx], "$qstatp[$_]\;"); } } if (($qstatsqf[$qidx] eq 'mcm') || ($qstatsqf[$qidx] eq 'mch') || ($qstatsqf[$qidx] eq 'ord') || ($qstatsqf[$qidx] eq 'mtx') || ($qstatsqf[$qidx] eq 'mtr')) { $npctidxend = $#qstatc - 3; $nincidx = $#qstatc - 1; $ntotinc = $qstatc[$nincidx]; for (my $i = 0; $i <= $npctidxend; $i++ ) { if ($ntotinc == 0) { $qstatp[$i] = 0; } else { $qstatp[$i] = format_percent($qstatc[$i] / $ntotinc); } } $qstatsqrp[$qidx] = ""; foreach $qstat (@qstatp) { $qstatsqrp[$qidx] = join('', $qstatsqrp[$qidx], "$qstat\;"); } } elsif ($qstatsqf[$qidx] eq 'esa') { $npctidxend = $#qstatc - 3; $ncoridx = $#qstatc - 2; $nincidx = $#qstatc - 1; $ntotcor = $qstatc[$ncoridx]; $ntotinc = $qstatc[$nincidx]; for (my $i = 0; $i <= $npctidxend; $i++ ) { if ($ntotcor == 0) { $qstatp[$i] = 0; } else { $qstatp[$i] = format_percent($qstatc[$i] / $ntotcor); } } $qstatsqrp[$qidx] = ""; foreach $qstat (@qstatp) { $qstatsqrp[$qidx] = join('', $qstatsqrp[$qidx], "$qstat\;"); } $nincidx = $#qstatc - 1; $ntotinc = $qstatc[$nincidx]; for (my $i = 0; $i <= $#qstatsqwc; $i++ ) { if ($ntotinc == 0) { $qstatsqwp[$i] = 0; } else { $qstatsqwp[$i] = format_percent($qstatsqwc[$i] / $ntotinc); } } } @qstato = (); @qstatc = (); @qstatp = (); } } if ($#qucmts != -1) { @qsumry=sort @qucmts; @qucmts=@qsumry; @qsumry=(); } print "

$TEST{'desc'} ($TEST{'id'})
Question Response Statistics
"; if (defined $idlist) { print "Groups: ".join(", ",split(/,/,$FORM{'idlist'}))."
\n"; } print "$nresponses Completed Responses "; $sobsolete = ""; if ($TEST{'seq'} eq 'svy' || $TEST{'seq'} eq 'dmg') { $incresponse = ""; } else { $incresponse = "INCORRECT"; } for (1 ..$#questions) { ($test,$qid) = split(/\./, $qstatsid[$_]); if ($qstatsqf[$qid] eq 'obs') { if ($TEST{'seq'} ne 'svy' && $TEST{'seq'} ne 'dmg') { $sobs = " "; $sobsolete = join('', $sobsolete, $sobs); } } else { if (($qstatsqf[$qid] eq 'mcm') || ($qstatsqf[$qid] eq 'mch') || ($qstatsqf[$qid] eq 'ord') || ($qstatsqf[$qid] eq 'esa') || ($qstatsqf[$qid] eq 'mtx') || ($qstatsqf[$qid] eq 'mtr')) { if ($qstatsqf[$qid] eq 'mch') { @qstato = split(/
/, $qstatsqr[$qid]); } else { @qstato = split(/\;/, $qstatsqr[$qid]); } if ($qstatsqf[$qid] eq 'esa') { @qstatw = split(/\;/, $qstatsqw[$qid]); shift @qstatw; } $rowspan1 = ($TEST{'seq'} ne 'svy' && $TEST{'seq'} ne 'dmg') ? 5 : 4; $rowspan2 = ($TEST{'seq'} ne 'svy' && $TEST{'seq'} ne 'dmg') ? 5 : 4; } else { @qstato = split(/\;/, $qstatsqr[$qid]); if ( $qstatsqf[$qid] eq 'nrt' ){ $qstato[1] =~ s/\/\//
/g; $qstato[1] =~ s/\//
/g; $qstato[1] =~ s/:/
/g; $qstato[1] =~ s/\+/ /g; } $rowspan1 = 2; $rowspan2 = 2; } if ($FORM{'showcmts'} eq 'withq') { $rowspan1++; $rowspan2++; } print " "; @qstatc = split(/\;/, $qstatsqrc[$qid]); @qstatp = split(/\;/, $qstatsqrp[$qid]); if (($qstatsqf[$qid] eq 'mcm') || ($qstatsqf[$qid] eq 'mch') || ($qstatsqf[$qid] eq 'ord') || $qstatsqf[$qid] eq 'esa' || $qstatsqf[$qid] eq 'mtx' || $qstatsqf[$qid] eq 'mtr') { $ncountidx = $#qstatc - 2; $qstatccor = $qstatc[$ncountidx]; $qstatpcor = $qstatp[$ncountidx]; $qstatcinc = $qstatc[$ncountidx+1]; $qstatpinc = $qstatp[$ncountidx+1]; $qstatcnor = $qstatc[$ncountidx+2]; $qstatpnor = $qstatp[$ncountidx+2]; if ($TEST{'seq'} ne svy && $TEST{'seq'} ne dmg) { print " "; print " "; } else { print " "; } print " "; if ($FORM{'exnoresp'}) { print "\n"; } else { print "\n"; } print " "; } if (($qstatsqf[$qid] eq 'mch') || ($qstatsqf[$qid] eq 'ord')) { if ($qstatsqf[$qid] eq 'mch') { $sphrase = "(matched to \>\;\>\;\>\;)"; @matchwords = (); @matchtos = (); foreach $qstat (@qstato) { ($matchword, $matchto) = split(/\=\=\=/, $qstat); push @matchwords, $matchword; push @matchtos, $matchto; } push @matchtos, "Left Blank"; } else { $sphrase = "(ordered as number \>\;\>\;\>\;)"; @matchwords = (); @matchtos = @qstato; $matchidx = 1; foreach $qstat (@qstato) { push @matchwords, "$matchidx"; $matchidx++; } push @matchtos, "Not Used"; } $colspan = int((($#matchwords + 1) * 2) + 1); print ""; } elsif ($qstatsqf[$qid] eq 'mtx' || $qstatsqf[$qid] eq 'mtr') { ($id,$qtp,$qim,$qil,$qtx,$qca,$qia,$qrm) = split(/\&/, $questions[$qid]); ($qiar, $qiac) = split("RC", $qia); @qiar = split("\;", $qiar); @qiac = split("\;", $qiac); $holdmcm = $_; if ($qstatsqf[$qid] eq 'mtr') { $colspan = ($#qiac + 1) * 3 + 1; $colspan2 = 3; } else { $colspan = ($#qiac + 1) * 2 + 1; $colspan2 = 2; } print " "; } elsif ($qstatsqf[$qid] eq 'mcm') { print " "; } elsif ($qstatsqf[$qid] eq 'esa') { print " "; } elsif ($qstatsqf[$qid] eq 'nrt' ) { ##### v ADT - 7/03/2002 ################################################ # If you want to remove the NRT statistics, delete between these comments ######################################################################## print " "; ##### ^ ADT - 7/03/2002 - End Delete ################################### ##### v ADT - 7/03/2002 ################################################ # Added code to print NRT answers in the form of the comments ######################################################################## #print "\n\t\n\t\t\n\t\n"; ##### ^ ADT - 7/03/2002 ################################################ } else { if ($TEST{'seq'} eq 'svy' || $TEST{'seq'} eq 'dmg') { $bs = ""; $be = ""; } else { $bs = ""; $be = ""; } print " \n"; } if (($FORM{'showcmts'} eq 'withq') && ($#qucmts != -1)) { ##### v ADT - 7/03/2002 ################################################ # Modified code to add the comments to the same table cell as the # answers if the question is a Narrative question ######################################################################## if( $qstatsqf[$qid] ne 'nrt' ) { print "\t\n\t\t\n"; } print " \n"; @qstato = (); @qstatc = (); @qstatp = (); } } if (($FORM{'showcmts'} eq 'atend') && ($#qucmts != -1)) { print "\n"; print "\n"; print "\n\n"; } @qucmts=(); if ($FORM{'showobs'}) { print "$sobsolete"; } print "

ID Occ Pct Question Text
Cnt Pct Options

$qstatsid[$_] INACTIVE $qstatsqt[$qid]

$qstatsid[$_] $qstatsqc[$qid] $qstatsqp[$qid]\% $qstatsqt[$qid]
$qstatccor $qstatpcor\% $xlatphrase[137]
$qstatcinc $qstatpinc\% INCORRECT
$qstatcinc $qstatpinc\% RESPONSES
$qstatcnor $qstatpnor\%$xlatphrase[670]
"; foreach $matchword (@matchwords) { print " "; } print " "; foreach $matchword (@matchwords) { print " "; } print " "; $matchidx = 0; foreach $matchto (@matchtos) { print " "; if ($matchto eq $matchtos[$#matchtos]) { print " "; } else { print " "; } foreach $matchword (@matchwords) { print " "; $matchidx++; } print " "; } print "
BREAKDOWN OF $incresponse RESPONSES
$sphrase$matchword
Cnt Pct
$matchto$matchto$qstatc[$matchidx] $qstatp[$matchidx]\%
"; foreach $qiacol (@qiac) { print ""; } print "\n"; foreach $qiacol (@qiac) { if ($qstatsqf[$qid] eq 'mtr') { print ""; } print ""; } print "\n\n"; $i=0; foreach $qiarow (@qiar) { print ""; foreach $qiacol (@qiac) { if ($qstatsqf[$qid] eq 'mtr') { print ""; print ""; print ""; $i += 5; } else { print ""; print ""; $i++; } } print "\n\n"; } print "\n
BREAKDOWN OF $incresponse RESPONSES
 $qiacol
 RankCnt Pct
$qiarow"; for $irank (1 .. 5) { print "$irank
"; } print "
"; for $irank (1 .. 5) { print "$qstatc[$i+$irank-1]
"; } print "
"; for $irank (1 .. 5) { print "$qstatp[$i+$irank-1]\%
"; } print "
$qstatc[$i]$qstatp[$i]\%
BREAKDOWN OF $incresponse RESPONSES
Response Option Cnt Pct
"; foreach $qstat (@qstato) { print "$qstat
"; } print "
"; $holdmcm = $_; $endidx = $#qstatc - 3; for (0 .. $endidx) { print "$qstatc[$_]
"; } print "
"; for (0 .. $endidx) { print "$qstatp[$_]\%
"; } $_ = $holdmcm; print "
BREAKDOWN OF $xlatphrase[137] RESPONSES
Response Option Cnt Pct
"; foreach $qstat (@qstato) { print "$qstat
"; } print "
"; $holdmcm = $_; $endidx = $#qstatc - 3; for (0 .. $endidx) { print "$qstatc[$_]
"; } print "
"; for (0 .. $endidx) { print "$qstatp[$_]\%
"; } $_ = $holdmcm; print "

"; print "
BREAKDOWN OF $incresponse RESPONSES
Response Option Cnt Pct
"; foreach $qstat (@qstatw) { print "$qstat
"; } print "
"; $holdmcm = $_; foreach (@qstatsqwc) { print "$_
"; } print "
"; foreach (@qstatsqwp) { print "$_\%
"; } $_ = $holdmcm; print "

"; if ($TEST{'seq'} eq 'svy' || $TEST{'seq'} eq 'dmg') { print"$qstatc[2]
$qstatc[1]"; } else { print"$qstatc[0]
$qstatc[2]
$qstatc[1]"; } print "
"; if ($FORM{'exnoresp'}) { if ($TEST{'seq'} eq 'svy' || $TEST{'seq'} eq 'dmg') { print" 
$qstatp[1]\%"; } else { print"$qstatp[0]\%
 
$qstatp[1]\%"; } } else { if ($TEST{'seq'} eq 'svy' || $TEST{'seq'} eq 'dmg') { print"$qstatp[2]\%
$qstatp[1]\%"; } else { print"$qstatp[0]\%
$qstatp[2]\%
$qstatp[1]\%"; } } print "
"; if ($TEST{'seq'} eq 'svy' || $TEST{'seq'} eq 'dmg') { print"$qstato[2]
$qstato[1]"; } else { print"$qstato[0]
$qstato[2]
$qstato[1]"; } print "
"; #print "\n\t\t\t\n\t\t\t\t\n"; #print "\t\t\t\t\t\n"; #print "\t\t\t\t\t\n"; #print "\t\t\t\t\n"; #print "\t\t\t
Answers:
"; #for $i (0 .. $#qresponses) { #@columns=split(/\&/, $qresponses[$i]); #if ($columns[0] eq $qid) { #print "$columns[1]\:
\n"; #while (length($columns[2]) > 50) { #$j=index($columns[2]," ",45); #if ($j==-1) { #$qresponse=substr($columns[2],0,50); #$columns[2]=substr($columns[2],50); #} else { #$qresponse=substr($columns[2],0,$j); #$j++; #$columns[2]=substr($columns[2],$j); #} #print "$qresponse
\n"; #} #print "$columns[2]
\n"; #} #} # #print "
\n\t\t
"; $boldtag = $bs; $boldtagend = $be; foreach $qstat (@qstatc) { print "$boldtag$qstat$boldtagend
"; $boldtag = ""; $boldtagend = ""; } print "
"; $boldtag = $bs; $boldtagend = $be; foreach $qstat (@qstatp) { print "$boldtag$qstat\%$boldtagend
"; $boldtag = ""; $boldtagend = ""; } print "
"; $boldtag = $bs; $boldtagend = $be; foreach $qstat (@qstato) { print "$boldtag$qstat$boldtagend
"; $boldtag = ""; $boldtagend = ""; } print "
\n\t\t\t"; } print "
\nComments:
\n"; ##### ^ ADT - 7/03/2002 ################################################ for $i (0 .. $#qucmts) { @columns=split(/\&/, $qucmts[$i]); if ($columns[0] eq $qid) { print "$columns[1]\:
\n"; while (length($columns[2]) > 50) { $j=index($columns[2]," ",45); if ($j==-1) { $qucmt=substr($columns[2],0,50); $columns[2]=substr($columns[2],50); } else { $qucmt=substr($columns[2],0,$j); $j++; $columns[2]=substr($columns[2],$j); } print "$qucmt
\n"; } print "$columns[2]
\n"; } } print "


Comments
\n"; print "\n"; for (1 ..$#questions) { ($test,$qid) = split(/\./, $qstatsid[$_]); if ($qstatsqf[$qid] ne 'obs') { for $i (0 .. $#qucmts) { @columns=split(/\&/, $qucmts[$i]); if ($columns[0] eq $qid) { print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; } } print "\n"; } } print "\n\n
IDUserComments
$qstatsid[$_]$columns[1]\n"; while (length($columns[2]) > 70) { $j=index($columns[2]," ",65); if ($j==-1) { $qucmt=substr($columns[2],0,70); $columns[2]=substr($columns[2],70); } else { $qucmt=substr($columns[2],0,$j); $j++; $columns[2]=substr($columns[2],$j); } print "$qucmt
\n"; } print "$columns[2]
\n"; print "

\n
"; } # # #