#!/usr/bin/perl # # $Id: teststats.pl,v 1.39 2006/11/17 21:26:03 ddoughty Exp $ # # Source File: teststats.pl # Get config # use strict; use FileHandle; use Time::Local; use Data::Dumper; use URI::Escape; require 'sitecfg.pl'; require 'testlib.pl'; require 'tstatlib.pl'; require 'ui.pl'; require 'LikertData.pl'; use InMem ; #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 ); my $HBI_teststats_Debug = 0 ; &app_initialize; warn "INFO: " . __FILE__ . " running.\n" ; $FORM{"idlist"} =~ tr/\000/,/ ; # Change separator for multiple values from NULL to comma. HBI &LanguageSupportInit(); my $env_vars ; if ($HBI_teststats_Debug) { warn "teststats.pl ENV VARS\n" ; foreach $env_vars (sort keys %ENV) { warn "KEY $env_vars VAL $ENV{$env_vars}\n" ; } warn "teststats.pl ENV VARS END\n" ; } if ($HBI_teststats_Debug) { warn "teststats.pl FORM VARS\n" ; foreach $env_vars (sort keys %FORM) { warn "KEY $env_vars VAL $FORM{$env_vars}\n" ; } warn "teststats.pl FORM VARS END\n" ; } # If the flag is set to flip include-Exclude, Flip the inc values. if ($FORM{"Flip-Exclude-Include"}) { my @srkey; my $SRkey ; my $incUserID ; @srkeys = grep /^sr/, keys %FORM ; foreach $SRkey (@srkeys) { # next unless ($FORM{$SRkey} eq "Y") ; # The value is Y for Self-Registered. And N for Not-Self-Registered. $incUserID = $SRkey ; $incUserID =~ s/^sr// ; if ($FORM{"inc$incUserID"} eq $incUserID) { delete $FORM{"inc$incUserID"} ; } else { $FORM{"inc$incUserID"} = $incUserID ; } } } if ($HBI_teststats_Debug) { warn "teststats.pl FORM VARS\n" ; foreach $env_vars (sort keys %FORM) { warn "KEY $env_vars VAL $FORM{$env_vars}\n" ; } warn "teststats.pl FORM VARS END\n" ; } &get_session($FORM{'tid'}); &get_client_profile($SESSION{'clid'}); my @sortbys = qw(Name LoginID Date Score); my ($bExport,$idlist); if (exists $FORM{'grouping'} and $FORM{'grouping'} eq 'subset') { $idlist = &getIdlist($CLIENT{'clid'},$FORM{'idlist'}); } 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'}"; 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; } if (&get_session($FORM{'tid'})) { if ($FORM{'testsummary'} eq 'composite') { warn "Call show_test_composite $idlist " ; &show_test_composite($idlist); } elsif ($FORM{'testsummary'} eq 'bycnd') { warn "Call show_test_resultsbycnd $idlist " ; &show_test_resultsbycnd($idlist); } else { warn "Call extract_test_data " ; &extract_test_data(); } } if ($bExport) { exit(0); } sub extract_test_data() { &LanguageSupportInit(); &get_client_profile($SESSION{'clid'}); &get_test_profile($CLIENT{'clid'}, $FORM{'tstid'}); if ($FORM{'shwpending'}) { $testdir = $testpending; $testhdr = "Pending"; } else { $testdir = $testcomplete; $testhdr = "Completed Responses"; } my @filelist = &get_test_result_files($testdir, "$CLIENT{'clid'}","$TEST{'id'}"); my @converter; if ($SESSION{'uid'} ne '') { my $imaregistrar = &get_a_key("cnd.$CLIENT{'clid'}", $SESSION{'uid'}, "registrar"); if ($imaregistrar eq 'Y') { foreach $rotator (@filelist) { my @cnd = split(/\./, $rotator); my $creator = &get_a_key("cnd.$CLIENT{'clid'}", $cnd[1], "createdby"); push(@converter, $rotator) unless $creator ne $SESSION{'uid'}; } @filelist = @converter; } } else { &logger::logerr("No SESSION{uid} set!"); } 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{'cnddat'}) { push @colhdrs,"left:Date"; } if ($FORM{'excnd1'}) { push @colhdrs,"left:$CLIENT{'clcnd1'}"; } if ($FORM{'excnd2'}) { push @colhdrs,"left:$CLIENT{'clcnd2'}"; } if ($FORM{'excnd3'}) { push @colhdrs,"left:$CLIENT{'clcnd3'}"; } if ($FORM{'excnd4'}) { 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; $cnd1_filter = $FORM{'cnd1'}; $cnd2_filter = $FORM{'cnd2'}; $cnd3_filter = $FORM{'cnd3'}; $cnd4_filter = $FORM{'cnd4'}; ($i_am_grpowner, $grpmembers, $grpowners, $mygrp, $i_am_registrar) = &prepFilter($CLIENT{'clid'}); for ($fidx = 0; $fidx <= $#filelist; $fidx++ ) { $user = $filelist[$fidx]; $user =~ s/.$TEST{'id'}$//; $user =~ s/^$CLIENT{'clid'}.//; $filtered = &makeMeFilter($user, $CLIENT{'clid'}, $i_am_grpowner, $grpmembers, $grpowners, $mygrp, $i_am_registrar); if (!$filtered) { 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'}); } else { #print STDERR "$user from log.\n"; } if (not defined $history) { # no log file entry for this test #print STDERR "$user inferred from $testcomplete.$pathsep.$filelist[$fidx]\n"; my $mtime = (stat($testdir.$pathsep.$filelist[$fidx]))[9]; $history->{'end'} = $mtime; $history->{'start'} = $history->{'end'}; } $completedat = &format_date_time("yyyy-mm-dd", "1", "-10000", $history->{'end'}); $displaydate = &format_date_time("dd-mmm-yyyy", "1", "-10000", $history->{'end'}); if (&date_out_of_range($completedat,$datefm,$dateto)) { next; } 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{'cnddat'}) { $row=join($joint,$row,"$displaydate"); } if ($FORM{'excnd1'}) { $row=join($joint,$row,"$CANDIDATE{'cnd1'}"); } if ($FORM{'excnd2'}) { $row=join($joint,$row,"$CANDIDATE{'cnd2'}"); } if ($FORM{'excnd3'}) { $row=join($joint,$row,"$CANDIDATE{'cnd3'}"); } if ($FORM{'excnd4'}) { $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=(); &print_report_dataextract_header($#sorted+1,@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 $testhdr\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 $testhdr\n"; print "\n"; print "\t\n"; for $i (1 .. $#cols) { ($colalgn,$colhdr) = split(/:/,$cols[$i]); print "\t\t\n"; } print "\t<\TR>\n"; } } $^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; } elsif ($sortby eq 'Score') { #print STDERR "by Score\n"; my $scoreidx=$#{$rows[0]->{'columns'}}-1; return sort {$a->{'columns'}->[$scoreidx] <=> $b->{'columns'}->[$scoreidx];} @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 @converter; if ($SESSION{'uid'} ne '') { my $imaregistrar = &get_a_key("cnd.$CLIENT{'clid'}", $SESSION{'uid'}, "registrar"); if ($imaregistrar eq 'Y') { foreach $rotator (@filelist) { my @cnd = split(/\./, $rotator); my $creator = &get_a_key("cnd.$CLIENT{'clid'}", $cnd[1], "createdby"); push(@converter, $rotator) unless $creator ne $SESSION{'uid'}; } @filelist = @converter; } } else { &logger::logerr("No SESSION{uid} set!"); } my ($url) = ("$cgiroot/teststats.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; $cnd1_filter = $FORM{'cnd1'}; $cnd2_filter = $FORM{'cnd2'}; $cnd3_filter = $FORM{'cnd3'}; $cnd4_filter = $FORM{'cnd4'}; ($i_am_grpowner, $grpmembers, $grpowners, $mygrp, $i_am_registrar) = &prepFilter($CLIENT{'clid'}); for ($fidx = 0; $fidx <= $#filelist; $fidx++ ) { $user = $filelist[$fidx]; $user =~ s/.$TEST{'id'}$//; $user =~ s/^$CLIENT{'clid'}.//; $creator = &get_a_key("cnd.$CLIENT{'clid'}", $user, "createdby"); $filtered = &makeMeFilter($user, $CLIENT{'clid'}, $i_am_grpowner, $grpmembers, $grpowners, $mygrp, $i_am_registrar); if (!$filtered) { 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'}); } else { #print STDERR "$user from log.\n"; } if (not defined $history) { # no log file entry for this test #print STDERR "$user inferred from $testcomplete.$pathsep.$filelist[$fidx]\n"; my $mtime = (stat($testcomplete.$pathsep.$filelist[$fidx]))[9]; $history->{'end'} = $mtime; $history->{'start'} = $history->{'end'}; } $completedat = &format_date_time("yyyy-mm-dd", "1", "-10000", $history->{'end'}); $displaydate = &format_date_time("dd-mmm-yyyy", "1", "-10000", $history->{'end'}); my $excuser="inc$user"; if ($FORM{$excuser} || &date_out_of_range($completedat,$datefm,$dateto)) { 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'}; my @historic_tests = getHistoricTests($testcomplete,$CLIENT{'clid'},$FORM{'tstid'},$user); my $numhistoric = $#historic_tests; if ($numhistoric >= 0) { $row->{'numprevious'} = "".$numhistoric.""; } else { $row->{'numprevious'} = "No History"; } $historic_tests = (); 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]; } if ($TEST{'minpass'} ne '') { $pf = ($qsumry[2] >= $TEST{'minpass'}) ? 'P' : 'F'; } else { $pf = "N/A"; } push @{$row->{'columns'}},$qsumry[0],$qsumry[1],$qsumry[2], $pf; 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($#sorted+1,$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 = sprintf("%02d:%02d:%02d",reverse((gmtime($row->{'start'}))[0..2])); $end = sprintf("%02d:%02d:%02d",reverse((gmtime($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[-4] + $cols[-3]; my $params = "tid=$SESSION{'tid'}&clid=$CLIENT{'clid'}&cndid=". uri_escape($cols[1]). "&tstid=$FORM{'tstid'}&correct=$cols[-4]&incorrect=$cols[-3]&total=$total&percent=$cols[-2]"; print "\t\n"; print "\t\t\n"; print "\t\t\n"; print "\t\t\n"; } if ($bysubjflag) { print "\t\t\n"; 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-3; if ($bExport) { print "$cols[$fidx++]\t"; 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"; print "\t\t\n"; } } if ($bExport) { print "\n"; } else { print "\t\n"; } } } else { $j=$#cols-3; if ($bExport) { print "$cols[$j++]\t"; 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"; 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"; 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+4; if ($bysubj) { $colspan2+=6; $titlesfx=" (Subject Area)"; } else { $colspan2=11; } 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]$row->{'numprevious'}
$rowhdrs[$j]$cols[$qid]$symbol$cols[$fidx++]$cols[$fidx++]$cols[$fidx++]\%$cols[$fidx]
$start$end$duration$row->{'numprevious'}$cols[$j++]$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"; print "\t\t\n"; } else { print "\t\t\n"; 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\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

CandidateLoginIDDate# PreviousSubject AreasStartEndDuration# PreviousOverall
\ \;$subjects[$i]CorrectIncorrectScoreP/F

\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; my %Likert_points = () ; my %Likert_score = () ; &get_client_profile($SESSION{'clid'}); &get_test_profile($CLIENT{'clid'}, $FORM{'tstid'}); @filelist = &get_test_result_files($testcomplete, "$CLIENT{'clid'}","$TEST{'id'}"); my @converter; if ($SESSION{'uid'} ne '') { my $imaregistrar = &get_a_key("cnd.$CLIENT{'clid'}", $SESSION{'uid'}, "registrar"); if ($imaregistrar eq 'Y') { foreach $rotator (@filelist) { my @cnd = split(/\./, $rotator); my $creator = &get_a_key("cnd.$CLIENT{'clid'}", $cnd[1], "createdby"); push(@converter, $rotator) unless $creator ne $SESSION{'uid'}; } @filelist = @converter; } } else { &logger::logerr("No SESSION{uid} set!"); } # Get the questions for the test. @questions = &get_question_list($TEST{'id'},$CLIENT{'clid'}); $qhdr = shift @questions; # Load field ids into a hash. The key is the field id. The value is the array index. my @field_ids = split(/\&/, $qhdr) ; my %field_ids = () ; my @qstatsscores = () ; my @qstatssupercat = () ; my %qids_supercat = () ; my @qstatspts = () ; for (0 .. $#field_ids) { # The first field_ids is the hash, the second is the array. my $field_token = $field_ids[$_] ; $field_token =~ s/\s$// ; # Clean white space off the end. $field_ids{$field_token} = $_ ; } @sorted = sort @questions; @questions = @sorted; unshift @questions, $qhdr; @sorted = (); for (1 .. $#questions) { # Preprocess each of the questions, by loading data # about each of the questions into a series of arrays. # Each array has a specific kind of data about every question. # Do not process $questions[0] because that is the line with field ids. ($id,$qtp,$qim,$qil,$qtx,$qca,$qia,$qrm) = split(/\&/, $questions[$_]); my @Q_array = split(/\&/, $questions[$_]); my $SCat ; if ( $qtp eq 'nrt' ) { $qca = 'N/A'; } $qtx =~ s/\;/
/g; ($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 $qstatpts[$qid] = $Q_array[$field_ids{'pts'}] ; # Fill in Scores and Category for likert scale question. if ($qtp eq 'lik') { $qstatsscores[$qid] = $Q_array[$field_ids{'scores'}] ; $SCat = $Q_array[$field_ids{'supercat'}] ; $SCat =~ s/\s+$// ; $qstatssupercat[$qid] = $SCat ; } else { $SCat = "" ; $qstatsscores[$qid] = "" ; # Scores for likert scale question. $qstatssupercat[$qid] = "" ; # Category for likert scale question. } if ($qids_supercat{$SCat}) { push (@{$qids_supercat{$SCat}}, $qid) ; } else { $qids_supercat{$SCat} = [$qid] ; } # $qallans is all answers separated by semi-colons. 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' || $qtp eq 'lik') { 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"; ### DED 2/25/05 Assumes RC labels, not lblall ($qiar, $numqiar, $numqiac, $qiac) = split("::", $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 'N/A') { $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"; } if ($qtp eq 'esa') { $qallans =~ s/\,/\;/g; } $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') { ### ASSUMES rank=1..10 - need to allow for other ranks # Have to allow for [1..10] in # each answer, so make it big! $ncount = (($#qstato + 1) * 10) + 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 = (); } # End of Preprocessing questions. # HBI - Prepare to process answers from Candidates. $ncount = $#filelist + 1; @qucmts=(); my %question_has_comments = () ; $nresponses=$#filelist+1; # HBI - Loop for each Candidate. for (my $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'}); } else { #print STDERR "$user from log.\n"; } if (not defined $history) { # no log file entry for this test #print STDERR "$user inferred from $testcomplete.$pathsep.$filelist[$fidx]\n"; my $mtime = (stat($testcomplete.$pathsep.$filelist[$fidx]))[9]; $history->{'end'} = $mtime; $history->{'start'} = $history->{'end'}; } $completedat = &format_date_time("yyyy-mm-dd", "1", "-10000", $history->{'end'}); $displaydate = &format_date_time("dd-mmm-yyyy", "1", "-10000", $history->{'end'}); if (&date_out_of_range($completedat,$datefm,$dateto)) { $nresponses--; next; } if (defined $idlist and not $idlist->{$user}) { $nresponses--; next; } my $excuser="inc$user"; if ($FORM{$excuser}) { $nresponses--; next; } &get_test_sequence_for_reports( $CLIENT{'clid'}, $user, $TEST{'id'}); @qids = split(/\&/, $SUBTEST_QUESTIONS{2}); @qrsp = split(/\&/, $SUBTEST_RESPONSES{2}); @qsumry = split(/\&/, $SUBTEST_SUMMARY{2}); # warn "Client $CLIENT{'clid'}, User ID $user, Test $TEST{'id'} " ; # warn "SUBTEST_QUESTIONS $SUBTEST_QUESTIONS{2} \n"; # warn "SUBTEST_RESPONSES $SUBTEST_RESPONSES{2} \n"; # warn "SUBTEST_SUMMARY $SUBTEST_SUMMARY{2} \n"; if ($qsumry[5] eq "TIME EXPIRED") { @corincs = split(/\//, $qsumry[6]); } else { @corincs = split(/\//, $qsumry[5]); } @qsumry = (); @qsumry = split(/\&/, $SUBTEST_ANSWERS{2}); # warn "SUBTEST_ANSWERS $SUBTEST_ANSWERS{2} " ; @qansseq = (); $fqid=""; $fqididx=""; # HBI - Now loop thru each answer given by $user. # HBI - $_ will be the sequential number of the question. for (1 .. $#qids) { ($test,$qidx) = split(/\./, $qids[$_]); unless ($Comments{$qidx}) { $Comments{$qidx} = {} ; } unless ($Text_Responses{$qidx}) { $Text_Responses{$qidx} = {} ; } ($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 if ($qucmt ne '') { $qucmt =~ tr/+/ /; $qucmt =~ tr/'//d; if ($FORM{'anoncmts'}) { push @qucmts, "$qidx\&User $fidx\&$qucmt"; &InMem::InsertQuesComment($SESSION{'clid'}, "User $fidx", $FORM{'tstid'}, "complete", $_, $qucmt) ; $question_has_comments{$qidx} = 1 ; } else { push @qucmts, "$qidx\&$user\&$qucmt"; &InMem::InsertQuesComment($SESSION{'clid'}, $user, $FORM{'tstid'}, "complete", $_, $qucmt) ; $question_has_comments{$qidx} = 1 ; # warn "Comment $SESSION{'clid'}, $user, $FORM{'tstid'}, complete, $_, $qucmt \n" ; } } ### 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' || $qstatsqf[$fqid] eq 'lik') { @fqansseq=split(/\?/,$qansseq[$fqididx]); # warn "fqididx $fqididx qansseq $qansseq[$fqididx] " ; shift @fqansseq; @fans=split(/\&/,$FORM{'answer'}); # warn "answer $FORM{'answer'} " ; shift @fans; foreach $fans (@fans) { # warn "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; } # warn "fqididx II $fqididx qrsp $qrsp[$fqididx] fresp $fresp fmatch $fmatch " ; @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--; @fqucmts = @qucmts; @qucmts = (); foreach (@fqucmts) { if (!($_ =~ /\&$user\&/)) { push @qucmts, "$_"; } } 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 '') { $qresp = lc($qresp); # # 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; if ($qrsp[$_]) { if ($FORM{'anoncmts'}) { push @qresponses, "$qidx\&User $fidx\&$qrsp[$_]"; &InMem::InsertQuesResp($SESSION{'clid'}, "User $fidx", $FORM{'tstid'}, "complete", $_, $qrsp[$_]) ; } else { push @qresponses, "$qidx\&$user\&$qrsp[$_]"; &InMem::InsertQuesResp($SESSION{'clid'}, $user, $FORM{'tstid'}, "complete", $_, $qrsp[$_]) ; # warn "Response $SESSION{'clid'}, $user, $FORM{'tstid'}, complete, $_, $qrsp[$_] \n" ; } } $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; if ($qrsp[$_] ne '') { $qstatc[$qansord[$qrsp[$_]]]++; $found = 1; } unless ($found) { # increment "No Response" $qstatc[$#qstatc]++; } @qansord = (); } elsif ($qstatsqf[$qidx] eq 'lik') { # Process Likert Scale questions. my @Lik_score = split(/\,/ , $qstatsscores[$qidx]) ; $Likert_points{$qstatssupercat[$qidx]} += $qstatpts[$qidx] ; # warn "qidx $qidx supercat $qstatssupercat[$qidx] Likert_points $Likert_points{$qstatssupercat[$qidx]}" ; # warn "pts $qstatpts[$qidx] " ; # warn "qstatsqf $qstatsqf[$qidx] response $qrsp[$_] " ; ### DED Filter out "?" and "xxx" in qrsp so will match $qrsp[$_] =~ s/\?//g; $qrsp[$_] =~ s/xxx//g; @qansord = split(/\?/, $qansseq[$_]); shift @qansord; $found = 0; if ($qrsp[$_] ne '') { $qstatc[$qansord[$qrsp[$_]]]++; $Likert_score{$qstatssupercat[$qidx]} += $Lik_score[$qansord[$qrsp[$_]]] ; # warn "Inc answer ub $_ qrsp $qrsp[$_] qansord $qansord[$qrsp[$_]] qstatc $qstatc[$qansord[$qrsp[$_]]] " ; # warn "score $Lik_score[$_] qidx $qidx supercat $qstatssupercat[$qidx] TOT $Likert_score{$qstatssupercat[$qidx]} . " ; $found = 1; } unless ($found) { # increment "No Response" # No Response is zero points on the Likert Scale. $qstatc[$#qstatc]++; # warn "Inc No Resp. $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, $numqiar, $numqiac, $qiac) = split("::", $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, $numqiar, $numqiac, $qiac) = split("::", $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..10], so adjust index accordingly $irank = $iqstatc + $qresps[$iqresps] - 1; $qstatc[$irank]++; } $iqresps++; $iqstatc += 10; } } } } 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 = (); } } # HBI - End of loop for each Candidate. if ($#qucmts != -1) { @qsumry=sort @qucmts; @qucmts=@qsumry; @qsumry=(); } # HBI - Begin to write the html output. 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 (!($FORM{'exunans'} && $qstatsqc[$qid] < $FORM{'minunans'})) { if ($qstatsqf[$qid] eq 'obs') { if ($TEST{'seq'} ne 'svy' && $TEST{'seq'} ne 'dmg') { $sobs = " "; $sobsolete = join('', $sobsolete, $sobs); } } elsif ($qstatsqf[$qid] eq 'plc') { next; } 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 = ( $qstatsqf[$qid] eq 'nrt' ) ? 3 : 2; $rowspan2 = ( $qstatsqf[$qid] eq 'nrt' ) ? 3 : 2; } if (($FORM{'showcmts'} eq 'withq') && ($#qucmts != -1)) { $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, $numqiar, $numqiac, $qiac) = split("::", $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 " "; print "\n"; ##### ^ ADT - 7/03/2002 - End Delete ################################### } else { if ($TEST{'seq'} eq 'svy' || $TEST{'seq'} eq 'dmg') { $bs = ""; $be = ""; } else { $bs = ""; $be = ""; } print " \n"; } if (($FORM{'showcmts'} eq 'withq') && ($#qucmts != -1)) { print "\n"; } print " \n"; @qstato = (); @qstatc = (); @qstatp = (); } } } if (($FORM{'showcmts'} =~ /^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 += 10; } else { print ""; print ""; $i++; } } print "\n\n"; } print "\n
BREAKDOWN OF $incresponse RESPONSES
 $qiacol
 RankCnt Pct
$qiarow"; for $irank (1 .. 10) { print "$irank
"; } print "
"; for $irank (1 .. 10) { print "$qstatc[$i+$irank-1]
"; } print "
"; for $irank (1 .. 10) { 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[1]
$qstato[0]"; } else { print"$qstato[0]
$qstato[2]
$qstato[1]"; } print "
"; print "
\n"; print "
\nResponses:
\n"; for $i (0 .. $#qresponses) { @columns=split(/\&/, $qresponses[$i]); if ($columns[0] eq $qid) { print "$columns[1]\:
\n"; print STDERR ("HBIZ Response " . Dumper($columns[2]) . "\n" ) if ($HBI_teststats_Debug) ; 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 "
"; $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"; print "
\nComments:" ; if ($HBI_teststats_Debug) { print " HBI_teststats_Debug tested withq." ; } print "
\n"; for $i (0 .. $#qucmts) { @columns=split(/\&/, $qucmts[$i]); if ($columns[0] eq $qid) { print "$columns[1]\:
\n"; print STDERR ("HBIZ Comment " . Dumper($columns[2]) . "\n" ) if ($HBI_teststats_Debug) ; 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" ; print "" ; if ($HBI_teststats_Debug) { print " HBI_teststats_Debug tested atend." ; } print "
\n"; print "\n"; for (1 ..$#questions) { ($test,$qid) = split(/\./, $qstatsid[$_]); warn "HBI showcmts $FORM{'showcmts'} qid $qid question-comments $question_has_comments{$qid}\n" if ($HBI_teststats_Debug) ; next if (($FORM{'showcmts'} eq "atendwonocomm") and (! $question_has_comments{$qid}) ) ; 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"; } # for loop on the comments. } # for loop on the questions. 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
" ; my %SpecLikertReportClients = (sandbox => 1 ,tgwall => 1 ,rutgers => 1 ) ; # PRINT the NRT responses and comments by Likert category and user. - HBI if ($SpecLikertReportClients{$SESSION{'clid'}}) { print "

\n" ; # print "
\n" ; print "

Comments

\n" ; print "

\n" ; my $outcat ; my $rpy ; my @qid_list ; my @Cat_Users = keys %{$GlobalData->{'CLIENTS'}->{$SESSION{'clid'}}->{'CANDIDATES'}} ; # print "Number of Users is $#Cat_Users " . join(" ", @Cat_Users) . "
\n" ; foreach $outcat (sort keys %qids_supercat) { @qid_list = @{$qids_supercat{$outcat}} ; # print "Number of Questions is $#qid_list " . join(" ", @qid_list) . "
\n" ; print "

" ; print "CATEGORY - " . $outcat if ($outcat) ; print "
\n" ; foreach $qid (@qid_list) { warn "HBIX showcmts $FORM{'showcmts'} qid $qid question-comments $question_has_comments{$qid}\n" if ($HBI_teststats_Debug) ; next if (($FORM{'showcmts'} eq "atendwonocomm") and (! $question_has_comments{$qid}) ) ; $qid =~ s/^[\s0]+// ; # Trim leading zeros and white space. print "
\n" ; print "Question $qid - $qstatsqt[$qid]\n" ; print "
\n" ; foreach $user (sort @Cat_Users) { $rpy = $GlobalData->{'CLIENTS'}->{$SESSION{'clid'}}->{'CANDIDATES'}->{$user}->{'Tests'}->{$FORM{'tstid'}}->{"complete"}->{$qid}->{'Resp'} ; if ($rpy) { # print "User - $user - Reply - $rpy
\n" ; print "$rpy
\n" ; } $rpy = $GlobalData->{'CLIENTS'}->{$SESSION{'clid'}}->{'CANDIDATES'}->{$user}->{'Tests'}->{$FORM{'tstid'}}->{"complete"}->{$qid}->{'Comment'} ; if ($rpy) { # print "User - $user - Comment - $rpy
\n" ; print "$rpy
\n" ; } } } } print "

\n" ; } # end of Executing Likert comments. print "


\n" ; # FINISHED - PRINT the NRT responses and comments by Likert category and user. # Printing the raw Likert Scale data openly. # if (%Likert_points) { # print "Likert Category and scores. \\n" ; # for $cat (sort keys %Likert_points) { # print "$cat $Likert_points{$cat} $Likert_score{$cat}\\n" ; # } # } if (%Likert_points) { my ($Tot_possible, $Tot_earned) ; $Tot_possible = $Tot_earned = 0; print "

\n" ; print "\n" ; print "" ; print "\n" ; print "\n" ; print "" ; print "" ; print "" ; print "" ; print "" ; print "\n" ; my $percent ; my @img_labels = () ; my @img_data = () ; for $cat (sort keys %Likert_points) { $percent = int ((100.0 * $Likert_score{$cat} / $Likert_points{$cat}) +0.5) ; push @img_labels, $cat ; push @img_data, $percent ; print "" ; print "" ; print "" ; $Tot_possible += $Likert_points{$cat} ; print "" ; $Tot_earned += $Likert_score{$cat} ; print "" ; print "\n" ; } # Print a total Line. print "" ; $cat = "Total" ; print "" ; print "" ; print "" ; $percent = int ((100.0 * $Tot_earned / $Tot_possible) +0.5) ; push @img_labels, $cat ; push @img_data, $percent ; print "" ; print "\n" ; # Finish the table. print "
Likert Category and scores
CategoryPossibleEarned\% Earned
$cat$Likert_points{$cat}$Likert_score{$cat}" ; printf "%i", $percent ; print " \%" ; print "
$cat$Tot_possible$Tot_earned" ; printf "%i", $percent ; print " \%" ; print "
\n" ; print "




\n" ; # The list parameters are: labels, values, and values2. my @values2, $xdim, $ydim, $hbar, $title, $xlabel, $ylabel, $ymax, $ymin, $yticknum, $colorscheme ; # The scalar parameters are: xdim, ydim, hbar, title, xlabel, ylabel, ymax, ymin, yticknum @values2 = () ; ($xdim, $ydim, $hbar, $title, $xlabel, $ylabel, $ymax, $ymin, $yticknum, $colorscheme) = (800, 300, 1, "Likert Category Percents", "Category", "Percent for Category", 100, 0, 10, 1) ; $ydim = $#img_data * 20 + 50 ; my $ymax = 100 ; $ydim = $ymax if ($ydim < $ymax) ; ($t_margin, $b_margin, $l_margin, $r_margin) = (0, 0, 0, 30) ; print BuildBarGraph(\@img_labels, \@img_data, \@values2, $xdim, $ydim, $hbar, $title, $xlabel, $ylabel, $ymax, $ymin, $yticknum, $colorscheme, $t_margin, $b_margin, $l_margin, $r_margin) ; print "\\n" ; print "




\n" ; } print " "; }