You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1125 lines
35 KiB

#!/usr/bin/perl
#
# $Id: byquesrpt.pl,v 1.2 2004/08/13 14:32:58 ddoughty Exp $
#
# Source File: byquesrpt.pl
# Get config
use FileHandle;
#use Time::Local;
#use Data::Dumper;
require 'sitecfg.pl';
require 'testlib.pl';
require 'tstatlib.pl';
require 'qlib.pl';
#use strict;
use vars qw(%FORM %SESSION %CLIENT %TEST_SESSION %SUBTEST_QUESTIONS %TEST
%SUBTEST_SUMMARY %CANDIDATE %SUBTEST_ANSWERS %SYSTEM %REPORT
%SUBTEST_RESPONSES);
use vars qw($testcomplete $cgiroot $pathsep $dataroot );
&app_initialize;
&LanguageSupportInit();
#print STDERR Dumper(\%SESSION);
# Make sure we have a valid session, and exit if we don't
if (not &get_session($FORM{'tid'})) {
exit(0);
}
&get_client_profile($SESSION{'clid'});
# Generate the reports
if ($FORM{'reportname'} eq 'byques') {
&ByQuestionReport();
} elsif ($FORM{'reportname'} eq 'tests') {
print "Content-Type: text/html\n\n";
&show_template("testselect");
} elsif ($FORM{'reportname'} eq 'questions') {
&get_test_profile($CLIENT{'clid'}, $FORM{'tstid'});
&build_question_select_list();
&show_template("quesselect");
} elsif ($FORM{'reportname'} eq 'selectpg') {
print "Content-Type: text/html\n\n";
&show_template("selectpg");
} else {
&show_template("selectframe");
}
# There should only be function definitions beyond this point.
exit(0);
sub HTMLHeader {
return "<html>\n<head>\n<title>$_[0]</title>\n".
"<script language=\"JavaScript\">\n<!-- \n$_[1]\n -->\n</script>\n</head>\n".
"<BODY BACKGROUND=\"$SYSTEM{'BACKGROUND'}\" BGCOLOR=\"$SYSTEM{'BGCOLOR'}\"".
" TEXT=\"$SYSTEM{'TEXT'}\" LINK=\"$SYSTEM{'LINK'}\"".
" VLINK=\"$SYSTEM{'VLINK'}\" ALINK=\"$SYSTEM{'ALINK'}\">\n";
}
sub HTMLHeaderPlain {
return "<html>\n<head>\n<title>$_[0]</title>\n".
"<script language=\"JavaScript\">\n<!-- \n$_[1]\n -->\n</script>\n</head>\n".
"<BODY>\n";
}
sub HTMLFooter {
return "</body>\n</html>\n";
}
sub ByQuestionReport {
if ($FORM{'csv'}) {
print "Content-Disposition: attachment;filename=report.csv\n\n";
} else {
print "Content-Type: text/html\n\n";
print &HTMLHeaderPlain("Candidate Responses by Question");
}
&get_test_profile($CLIENT{'clid'}, $FORM{'tstid'});
&get_question_definition($TEST{'id'},$CLIENT{'clid'},$FORM{'qid'});
if ($FORM{'csv'}) {
&PrintByQuesCSVHeader();
} else {
&PrintByQuesHeader();
print "<TABLE cellpadding=3 cellspacing=2 border=0>\n";
}
my @filelist = &get_test_result_files($testcomplete, "$CLIENT{'clid'}","$TEST{'id'}");
for (my $fidx = 0; $fidx <= $#filelist; $fidx++ ) {
$user = $filelist[$fidx];
$user =~ s/.$TEST{'id'}$//;
$user =~ s/^$CLIENT{'clid'}.//;
&get_candidate_profile($CLIENT{'clid'}, $user);
&get_test_sequence_for_reports( $CLIENT{'clid'}, $user, $TEST{'id'});
if ($FORM{'csv'}) {
&PrintByQuesCSV();
} else {
&PrintByQues();
}
}
if (!$FORM{'csv'}) {
print "</TABLE>\n";
print &HTMLFooter();
}
}
sub PrintByQuesHeader {
if ($TEST{'seq'} eq 'svy' || $TEST{'seq'} eq 'dmg') {
@skilllevel = ( '','','','' );
$itemdescription = "Survey";
} elsif ($FORM{'remed'} == 1) {
$TEST{'seq'} = 'svy';
@skilllevel = ( '','','','' );
$itemdescription = "Test";
} else {
@skilllevel = ( 'Basic','Intermediate','Advanced','' );
$itemdescription = "Test";
}
my ($qsubj, $sklvl) = split(/\./, $QUESTION{'subj'});
if ($sklvl eq '') { $sklvl = 3; }
print "<CENTER><B><U>$itemdescription Results</U></B><BR>\n";
print "<B>Site: $CLIENT{'clid'}</B><BR>\n";
print "<B>Test: $TEST{'id'} - $TEST{'desc'}</B><BR>\n";
print "</CENTER>\n";
print "<TABLE cellpadding=3 cellspacing=2 border=0>\n";
print "<TR><TD colspan=3><HR WIDTH=\"100\%\"></TD></TR>\n";
print "<TR>\n";
if ($TEST{'seq'} eq 'svy' || $TEST{'seq'} eq 'dmg') {
print "<TD valign=\"top\">&nbsp;</TD>\n";
} else {
print "<TD valign=top align=right><B>ID:<BR>Subject:<BR>Skill Level:</B></TD>\n";
}
print "<TD valign=\"top\">$QUESTION{'id'} <BR>$qsubj <BR>$skilllevel[$sklvl] </TD>\n";
print "</TR>\n";
print "<TR>\n";
print "<TD valign=top align=right><B>Question:</B></TD>\n";
print "<TD valign=\"top\" colspan=2>$QUESTION{'qtx'}</TD>\n";
print "</TR>\n";
print "<TR><TD colspan=3><HR WIDTH=\"100\%\"></TD></TR>\n";
print "<TR>\n";
print "<TD valign=top><B>Login ID</B></TD>\n";
print "<TD colspan=2 valign=top><B>Name</B></TD>\n";
print "</TR>\n";
print "<TR>\n";
if ($TEST{'seq'} ne 'svy' && $TEST{'seq'} ne 'dmg') {
print "<TD valign=top><B>Credit</B></TD>\n";
} else {
print "<TD valign=top>&nbsp;</TD>\n";
}
print "<TD colspan=2 valign=top><B>Question Number</B></TD>\n";
print "</TR>\n";
print "<TR>\n";
print "<TD>\&nbsp;</TD>\n";
if ($TEST{'seq'} eq 'svy' || $TEST{'seq'} eq 'dmg') {
print "<TD valign=top><B>$itemdescription-Taker Response</B></TD>\n";
print "<TD>\&nbsp;</TD>\n";
} else {
print "<TD valign=top><B>Correct Response</B></TD>\n";
print "<TD valign=top><B>$itemdescription-Taker Response</B></TD>\n";
}
print "</TR>\n";
print "<TR><TD colspan=3><HR WIDTH=\"100\%\"></TD></TR>\n";
print "</TABLE>\n";
}
sub PrintByQues {
my $correctanswertag = "<FONT COLOR=\"green\" SIZE=1>$xlatphrase[137]</FONT>";
my $incorrectanswertag = "<FONT COLOR=\"red\" SIZE=1>$xlatphrase[692]</FONT>";
my $noanswertag = "<FONT COLOR=\"red\" SIZE=1>$xlatphrase[791]</FONT>";
my @myalbls=();
my @questions = split(/&/,$SUBTEST_QUESTIONS{2});
my @keyanswers = split(/&/,$SUBTEST_ANSWERS{2});
my @studentanswers = split(/&/,$SUBTEST_RESPONSES{2});
my ($correctans, $incorrectans, $score, $trash) = split(/&/, $SUBTEST_SUMMARY{2});
### Set the questionindex
for ($questionindex=1; $questionindex <= $#questions; $questionindex++) {
if ($questions[$questionindex] eq $FORM{'qid'}) {
last;
}
}
my $qtype = $QUESTION{'qtp'};
my $myqalb = $QUESTION{'qalb'};
my ($studentresponse,$studentcomments) = split(/::/,lc($studentanswers[$questionindex]));
$studentcomments = unmunge($studentcomments);
$studentcomments =~ s/\"/\&quot;/g;
$studentcomments =~ s/\+/" "/g;
# ^ sac start changes to support question optional comments
my ($keyresponse,$kflags) = split(/::/, lc($keyanswers[$questionindex]));
my $scoreable = 1;
my $credit = $noanswertag;
my $checked = "";
my $answerkey = "";
my $studentkey = "";
my $qanswermatch = "";
my @txts = ();
if ($TEST{'seq'} ne 'svy' && $TEST{'seq'} ne 'dmg') {
if ($qtype eq 'nrt') {
$scoreable = 0;
if ($studentresponse eq '') {
$credit = $noanswertag;
} else {
$credit = "unscoreable";
if ($keyresponse ne '') {
my ($manuallyscored,$keycomments) = split(/\./, $keyresponse);
}
# end ADT
}
$studentkey = "<U>$studentresponse</U>\n";
$studentkey =~ s/\%0D\%0A/\<br\>/g;
$studentkey = unmunge($studentkey);
}
if ($qtype eq 'tf') {
$answerkey = $keyresponse;
$studentkey = $studentresponse;
if ($studentkey eq $answerkey) {
$credit = $correctanswertag;
} else {
$credit = $incorrectanswertag;
if ($studentresponse eq '') { $credit = $noanswertag;}
}
}
if ($qtype eq 'esa') {
$answerkey = $keyresponse;
$studentkey = $studentresponse;
if ($answerkey =~ /\;/) {
@txts = split(/\;/, $keyresponse);
$credit = $incorrectanswertag;
foreach $answerkey (@txts) {
if (lc($studentresponse) eq lc($answerkey)) {
$credit = $correctanswertag;
}
}
$answerkey =~ s/\;/<br>/g;
} else {
if (lc($studentresponse) eq lc($keyresponse)) {
$credit = $correctanswertag;
} else {
$credit = $incorrectanswertag;
if ($studentresponse eq '') { $credit = $noanswertag;}
}
}
}
if ($qtype eq 'mcs') {
@myalbls=&set_answer_labels($myqalb);
$studentresponse =~ s/xxx//g;
push @txts, $QUESTION{'qca'};
@txts_wro = split(/\n/, $QUESTION{'qia'});
foreach $qia (@txts_wro) {
push @txts, $qia;
}
@kans = split(/\?/,$keyresponse);
foreach $j (1 .. $#kans) {
$jidx = $j-1;
@indexs = split(/=/, $kans[$j]);
$checked = ($indexs[1] == '1') ? " CHECKED" : "";
$answerkey = join('',$answerkey,"<input type=\"radio\"$checked>$myalbls[$jidx]. $txts[$indexs[0]]<BR>\n");
$checked = ($studentresponse =~ /$jidx/) ? " CHECKED" : "";
$studentkey = join('',$studentkey,"<input type=\"radio\"$checked>$myalbls[$jidx]. $txts[$indexs[0]]<BR>\n");
}
if ($studentkey eq $answerkey) {
$credit = $correctanswertag;
} else {
$credit = $incorrectanswertag;
if ($studentresponse eq '') { $credit = $noanswertag;}
}
}
if ($qtype eq 'mcm') {
@myalbls=&set_answer_labels($myqalb);
$studentresponse =~ s/xxx//g;
@txts = split(/\n/, $QUESTION{'qca'});
@txts_wro = split(/\n/, $QUESTION{'qia'});
foreach $qia (@txts_wro) {
push @txts, $qia;
}
@kans = split(/\?/,$keyresponse);
foreach $j (1 .. $#kans) {
$jidx = $j-1;
@indexs = split(/=/, $kans[$j]);
$checked = ($indexs[1] == '1') ? " CHECKED" : "";
$answerkey = join('',$answerkey,"<input type=\"checkbox\"$checked> $txts[$indexs[0]]<BR>\n");
$checked = ($studentresponse =~ /$jidx/) ? " CHECKED" : "";
$studentkey = join('',$studentkey,"<input type=\"checkbox\"$checked> $txts[$indexs[0]]<BR>\n");
}
if ($studentkey eq $answerkey) {
$credit = $correctanswertag;
} else {
$credit = $incorrectanswertag;
if ($studentresponse eq '') { $credit = $noanswertag;}
}
}
if ($qtype eq 'mch') {
$qanswermatch = "\&nbsp;<BR>\n";
@txts = split(/\n/, $QUESTION{'qca'});
@txts_wro = split(/\n/, $QUESTION{'qia'});
@ansopts = split(/\./, $keyresponse);
$anstype = shift @ansopts;
@albls=&set_answer_labels($anstype);
$keyresponse = "";
### DED-02 7/17/2002 Added following 2 lines
### and changed studentkey join below
### to allow for "?" delimiter in response
@studentresponse = split(/\?/, $studentresponse);
shift @studentresponse;
for (0 .. $#ansopts) {
$cansord[$ansopts[$_]] = $albls[$_];
$qanswermatch = join('',$qanswermatch, "<I>($cansord[$ansopts[$_]]) $txts_wro[$ansopts[$_]]</I><BR>\n");
}
foreach $cansord (@cansord) {
$keyresponse = join('', $keyresponse, $cansord);
}
for (0 .. $#ansopts) {
$answerkey = join('',$answerkey,"($cansord[$_]) $txts[$_]<BR>\n");
### DED-06 7/23/2002 added following if
### to print " " instead of "xxx"
### for blank response
if ( $studentresponse[$_] eq "xxx" ) {
$studentresponse[$_] = " ";
}
### DED-02 changed
#$studentkey = join('',$studentkey,"(",substr($studentresponse,$_,1),") $txts[$_]<BR>\n");
### to
$studentkey = join('',$studentkey,"(",$studentresponse[$_],") $txts[$_]<BR>\n");
}
@cansord = ();
### DED-02 vvv
$studentresponse="";
for (0 .. $#studentresponse) {
$studentresponse=join('', $studentresponse, $studentresponse[$_]);
}
### END DED-02
if ($studentresponse eq $keyresponse) {
$credit = $correctanswertag;
} else {
$studentresponse =~ s/x//g;
$credit = $incorrectanswertag;
if ($studentresponse eq '') { $credit = $noanswertag;}
}
}
if ($qtype eq 'ord') {
### DED 8/10/2002 Got rid of labels because
### "o" designator now working
@txts = split(/\n/, $QUESTION{'qca'});
@studentresponse = split(/\?/, $studentresponse);
shift @studentresponse;
@ansopts = split(/\./, $keyresponse);
$ansopt = shift @ansopts;
for (0 .. $#ansopts) {
$ansopt = $ansopts[$_];
$ansopt++;
$answerkey = join('',$answerkey,"($ansopt) $txts[$ansopts[$_]]<BR>\n");
### DED-07 7/23/2002 added following if
### to print " " instead of "xxx"
### for blank response
if ( $studentresponse[$_] eq "xxx" ) {
$studentresponse[$_] = " ";
}
### DED-03 changed
#$studentkey = join('',$studentkey,"(",substr($studentresponse,$_,1),") $txts[$ansopts[$_]]<BR>\n");
### to
$studentkey = join('',$studentkey,"(",$studentresponse[$_],") $txts[$ansopts[$_]]<BR>\n");
}
if ($studentkey eq $answerkey) {
$credit = $correctanswertag;
} else {
$credit = $incorrectanswertag;
if ($studentresponse eq '') { $credit = $noanswertag;}
}
}
} else {
if ($qtype eq 'nrt') {
$studentkey = "<U>$studentresponse</U>\n";
$studentkey =~ s/\%0D\%0A/\<br\>/g;
$studentkey = unmunge($studentkey);
}
if ($qtype eq 'tf') {
$studentkey = $studentresponse;
if ($studentresponse eq '') { $credit = $noanswertag;}
}
if ($qtype eq 'esa') {
$studentkey = $studentresponse;
if ($studentresponse eq '') { $credit = $noanswertag;}
}
if ($qtype eq 'mcs' || $qtype eq 'mca') {
@myalbls=&set_answer_labels($myqalb);
$studentresponse =~ s/xxx//g;
@txts = ();
if ($QUESTION{'qca'} ne '') {
push @txts, $QUESTION{'qca'};
}
@txts_wro = split(/\n/, $QUESTION{'qia'});
foreach $qia (@txts_wro) {
push @txts, $qia;
}
@kans = split(/\?/,$keyresponse);
foreach $j (1 .. $#kans) {
$jidx = $j-1;
@indexs = split(/=/, $kans[$j]);
$checked = ($studentresponse =~ /$jidx/) ? " CHECKED" : "";
$studentkey = join('',$studentkey,"<input type=\"radio\"$checked>($myalbls[$jidx]) $txts[$indexs[0]]<BR>\n");
}
if ($studentresponse eq '') { $credit = $noanswertag;}
}
if ($qtype eq 'mtx' || $qtype eq 'mtr') {
$studentkey="";
# Split qia into row and col headers
$qia = $QUESTION{'qia'};
$qia =~ s/\r/\n/g;
$qia =~ s/\n\n/\n/g;
($qrowhdr, $qcolhdr) = split(/RC/,$qia);
@qrowhdr = split(/\n/, $qrowhdr);
@qcolhdr = split(/\n/, $qcolhdr);
if ($qtype eq 'mtx') {
# Mark selections with "CHECKED"
@optvalues = split(/\?/, $studentresponse);
shift @optvalues;
$i=0;
foreach $row (0 .. $#qrowhdr)
{
foreach $col (0 .. $#qcolhdr)
{
if ($optvalues[$i] != "xxx")
{
$chmatrix[$row][$col]="CHECKED";
}
else
{
$chmatrix[$row][$col]="";
}
$i++;
}
}
} else {
# Mark selections with "SELECTED"
@optvalues = split(/\?/, $studentresponse);
shift @optvalues;
$i=0;
foreach $row (0 .. $#qrowhdr)
{
foreach $col (0 .. $#qcolhdr)
{
$rank = $optvalues[$i];
foreach $irank (0 .. 5)
{
if ($irank eq $rank)
{
$chmatrix[$i][$irank]="SELECTED";
}
else
{
$chmatrix[$i][$irank]="";
}
}
$i++;
}
}
}
# Build matrix html
$studentkey="<table border=2>\n<tr><td>&nbsp;</td>";
foreach (0 .. $#qcolhdr) {
$studentkey .= "<td>$qcolhdr[$_]</td>";
}
$studentkey .= "</tr>\n";
$i=0;
foreach $row (0 .. $#qrowhdr) {
$studentkey .= "<tr><td>$qrowhdr[$row]</td>";
foreach $col (0 .. $#qcolhdr) {
if ($qtype eq 'mtx') {
$studentkey .= "<td align=center><input type=checkbox name=\"qrs$row$col\" value=\"1\" $chmatrix[$row][$col]></td>";
} else {
$studentkey .= "<td align=center><select name=\"qrs$row$col\"><option value='' $chmatrix[$i][0]>\&nbsp\;</option><option value=1 $chmatrix[$i][1]>1</option><option value=2 $chmatrix[$i][2]>2</option><option value=3 $chmatrix[$i][3]>3</option><option value=4 $chmatrix[$i][4]>4</option><option value=5 $chmatrix[$i][5]>5</option></select></td>";
}
$i++;
}
$studentkey .= "</tr>\n";
}
$studentkey .= "</table>\n";
@qrowhdr = ();
@qcolhdr = ();
@chmatrix = ();
if ($studentresponse eq '') { $credit = $noanswertag;}
}
if ($qtype eq 'mcm') {
@myalbls=&set_answer_labels($myqalb);
$studentresponse =~ s/xxx//g;
@txts = ();
if ($QUESTION{'qca'} ne '') {
@txts = split(/\n/, $QUESTION{'qca'});
}
@txts_wro = split(/\n/, $QUESTION{'qia'});
foreach $qia (@txts_wro) {
push @txts, $qia;
}
@kans = split(/\?/,$keyresponse);
foreach $j (1 .. $#kans) {
$jidx = $j-1;
@indexs = split(/=/, $kans[$j]);
$checked = ($studentresponse =~ /$jidx/) ? " CHECKED" : "";
$studentkey = join('',$studentkey,"<input type=\"checkbox\"$checked>($myalbls[$jidx]) $txts[$indexs[0]]<BR>\n");
}
if ($studentresponse eq '') { $credit = $noanswertag;}
}
if ($qtype eq 'mch') {
### DED-04 7/17/2002 Same as DED-02
@studentresponse = split(/\?/, $studentresponse);
shift @studentresponse;
$qanswermatch = "\&nbsp;<BR>\n";
@txts = split(/\n/, $QUESTION{'qca'});
@txts_wro = split(/\n/, $QUESTION{'qia'});
@ansopts = split(/\./, $keyresponse);
$anstype = shift @ansopts;
@albls=&set_answer_labels($anstype);
$keyresponse = "";
for (0 .. $#ansopts) {
$cansord[$ansopts[$_]] = $albls[$_];
$qanswermatch = join('',$qanswermatch, "<I>($cansord[$ansopts[$_]]) $txts_wro[$ansopts[$_]]</I><BR>\n");
}
foreach $cansord (@cansord) {
$keyresponse = join('', $keyresponse, $cansord);
}
for (0 .. $#ansopts) {
$studentkey = join('',$studentkey,"(",$studentresponse[$_],") $txts[$_]<BR>\n");
}
@cansord = ();
$studentresponse =~ s/x//g;
if ($studentresponse eq '') { $credit = $noanswertag;}
}
if ($qtype eq 'ord') {
### DED-05 7/17/2002 Same as DED-02
@studentresponse = split(/\?/, $studentresponse);
shift @studentresponse;
@albls = &set_answer_labels($QUESTION{'qalb'});
@txts = split(/\n/, $QUESTION{'qca'});
@ansopts = split(/\./, $keyresponse);
$ansopt = shift @ansopts;
for (0 .. $#ansopts) {
$ansopt = $ansopts[$_];
$ansopt++;
$studentkey = join('',$studentkey,"(",$studentresponse[$_],") $txts[$ansopts[$_]]<BR>\n");
}
if ($studentresponse eq '') { $credit = $noanswertag;}
}
}
print "<TR>\n";
print "<TD valign=\"top\"><b>$user</b></TD>\n";
print "<TD colspan=2 valign=\"top\"><b>$CANDIDATE{'nmf'} $CANDIDATE{'nmm'} $CANDIDATE{'nml'}</b></TD>\n";
print "</TR>\n";
if ($TEST{'seq'} ne 'svy' && $TEST{'seq'} ne 'dmg') {
print "<TR>\n";
if ($scoreable || $credit eq $noanswertag) {
print "<TD valign=\"top\">$credit</TD>\n";
} else {
print "<TD valign=\"top\">nbsp;</TD>\n";
}
print "<TD colspan=2 valign=\"top\">$questionindex. </TD>\n";
print "</TR>\n";
print "<TR>\n";
if ($qanswermatch ne "") {
print "<TD colspan=3 valign=\"top\">\&nbsp;<BR>$qanswermatch</TD>\n";
}
print "</TR>\n";
print "<TR>\n";
print "<TD valign=\"top\">\&nbsp;</TD>\n";
if (($qtype eq 'nrt') && ($studentresponse ne '')) {
if ($keycomments eq '') {
print "<TD valign=\"top\" width=\"40\%\"><FONT SIZE=1>Comments:<BR></FONT><TEXTAREA name=\"cm$QUESTION{'id'}\" ROWS=5 COLS=30>$QUESTION{'qrm'}</TEXTAREA></TD>\n";
} else {
print "<TD valign=\"top\" width=\"40\%\"><FONT SIZE=1>Comments:<BR></FONT><TEXTAREA name=\"cm$QUESTION{'id'}\" ROWS=5 COLS=30>$keycomments</TEXTAREA></TD>\n";
}
} else {
print "<TD valign=\"top\" width=\"40\%\">$answerkey</TD>\n";
}
print "<TD valign=\"top\" width=\"40\%\">$studentkey</TD>\n";
print "</TR>\n";
if (($TEST{'remt'} ne '0') && ($TEST{'emlcndopt'} eq 'Y')
&& ($SESSION{'uac'} eq 'cnd')) {
print "<TR>\n";
print "<TD>&nbsp;</TD>\n";
print "<TD colspan=2 valign=\"top\">$QUESTION{'qrm'}</TD>\n";
print "</TR>\n";
}
if ($QUESTION{'qcmtprmpt'} eq 'Y') {
print "<TR>\n";
print "<TD valign=\"top\">&nbsp;<br></TD>\n";
print "<TD colspan=2 valign=\"top\"><i>\&nbsp;<BR><u>(Student Comments) $QUESTION{'qcprmpt'}</u><br>$studentcomments</i></TD>\n";
print "</TR>\n";
}
} else {
print "<TR>\n";
print "<TD valign=\"top\">&nbsp;</TD>\n";
print "<TD colspan=2 valign=\"top\">$questionindex. </TD>\n";
print "</TR>\n";
if ($qanswermatch ne "") {
print "<TR>\n";
print "<TD colspan=3 valign=\"top\">$qanswermatch</TD>\n";
print "</TR>\n";
}
print "<TR>\n";
print "<TD valign=\"top\">&nbsp;</TD>\n";
print "<TD colspan=2 valign=\"top\">$studentkey</TD>\n";
print "</TR>\n";
if (($TEST{'remt'} ne '0') && ($TEST{'emlcndopt'} eq 'Y')
&& ($SESSION{'uac'} eq 'cnd')) {
print "<TR>\n";
print "<TD>&nbsp;</TD>\n";
print "<TD colspan=2 valign=\"top\">$QUESTION{'qrm'}</TD>\n";
print "</TR>\n";
}
if ($QUESTION{'qcmtprmpt'} eq 'Y') {
print "<TR>\n";
print "<TD valign=\"top\">&nbsp;<br></TD>\n";
print "<TD colspan=2 valign=\"top\"><i>\&nbsp;<BR><u>(Student Comments) $QUESTION{'qcprmpt'}</u><br>$studentcomments</i></TD>\n";
print "</TR>\n";
}
}
print "<TR><TD colspan=3><HR WIDTH=\"100\%\"></TD></TR>\n";
### End of question printout
}
sub PrintByQuesCSVHeader {
if ($TEST{'seq'} eq 'svy' || $TEST{'seq'} eq 'dmg') {
@skilllevel = ( '','','','' );
$itemdescription = "Survey";
} elsif ($FORM{'remed'} == 1) {
$TEST{'seq'} = 'svy';
@skilllevel = ( '','','','' );
$itemdescription = "Test";
} else {
@skilllevel = ( 'Basic','Intermediate','Advanced','' );
$itemdescription = "Test";
}
my ($qsubj, $sklvl) = split(/\./, $QUESTION{'subj'});
if ($sklvl eq '') { $sklvl = 3; }
print "$itemdescription Results\n";
print "Site:,$CLIENT{'clid'}\n";
print "Test:,\"$TEST{'id'} - $TEST{'desc'}\"\n";
print "ID,Subject,Skill Level,Question\n";
print "$QUESTION{'id'},\"$qsubj\",$skilllevel[$sklvl],\"$QUESTION{'qtx'}\"\n";
print "Login ID,Name,";
if ($TEST{'seq'} ne 'svy' && $TEST{'seq'} ne 'dmg') {
print "Credit,Question Number,Correct Response,$itemdescription-Taker Response,Student Comments\n";
} else {
print "Question Number,$itemdescription-Taker Response,Student Comments\n";
}
}
sub PrintByQuesCSV {
my $correctanswertag = "$xlatphrase[137]";
my $incorrectanswertag = "$xlatphrase[692]";
my $noanswertag = "$xlatphrase[791]";
my @myalbls=();
my @questions = split(/&/,$SUBTEST_QUESTIONS{2});
my @keyanswers = split(/&/,$SUBTEST_ANSWERS{2});
my @studentanswers = split(/&/,$SUBTEST_RESPONSES{2});
my ($correctans, $incorrectans, $score, $trash) = split(/&/, $SUBTEST_SUMMARY{2});
### Set the questionindex
for ($questionindex=1; $questionindex <= $#questions; $questionindex++) {
if ($questions[$questionindex] eq $FORM{'qid'}) {
last;
}
}
my $qtype = $QUESTION{'qtp'};
my $myqalb = $QUESTION{'qalb'};
my ($studentresponse,$studentcomments) = split(/::/,lc($studentanswers[$questionindex]));
$studentcomments = unmunge($studentcomments);
$studentcomments =~ s/\"/\&quot;/g;
$studentcomments =~ s/\+/" "/g;
# ^ sac start changes to support question optional comments
my ($keyresponse,$kflags) = split(/::/, lc($keyanswers[$questionindex]));
my $scoreable = 1;
my $credit = $noanswertag;
my $checked = "";
my $answerkey = "";
my $studentkey = "";
my $qanswermatch = "";
my @txts = ();
if ($TEST{'seq'} ne 'svy' && $TEST{'seq'} ne 'dmg') {
if ($qtype eq 'nrt') {
$scoreable = 0;
if ($studentresponse eq '') {
$credit = $noanswertag;
} else {
$credit = "unscoreable";
if ($keyresponse ne '') {
my ($manuallyscored,$keycomments) = split(/\./, $keyresponse);
}
}
$studentkey = "$studentresponse";
$studentkey =~ s/\%0D\%0A/\;/g;
$studentkey = unmunge($studentkey);
}
if ($qtype eq 'tf') {
$answerkey = $keyresponse;
$studentkey = $studentresponse;
if ($studentkey eq $answerkey) {
$credit = $correctanswertag;
} else {
$credit = $incorrectanswertag;
if ($studentresponse eq '') { $credit = $noanswertag;}
}
}
if ($qtype eq 'esa') {
$answerkey = $keyresponse;
$studentkey = $studentresponse;
if ($answerkey =~ /\;/) {
@txts = split(/\;/, $keyresponse);
$credit = $incorrectanswertag;
foreach $answerkey (@txts) {
if (lc($studentresponse) eq lc($answerkey)) {
$credit = $correctanswertag;
}
}
} else {
if (lc($studentresponse) eq lc($keyresponse)) {
$credit = $correctanswertag;
} else {
$credit = $incorrectanswertag;
if ($studentresponse eq '') { $credit = $noanswertag;}
}
}
}
if ($qtype eq 'mcs') {
$studentresponse =~ s/xxx//g;
push @txts, $QUESTION{'qca'};
@txts_wro = split(/\n/, $QUESTION{'qia'});
foreach $qia (@txts_wro) {
push @txts, $qia;
}
@kans = split(/\?/,$keyresponse);
foreach $j (1 .. $#kans) {
$jidx = $j-1;
@indexs = split(/=/, $kans[$j]);
if ($indexs[1] == '1') {
$answerkey = $txts[$indexs[0]];
}
if ($studentresponse =~ /$jidx/) {
$studentkey = $txts[$indexs[0]];
}
}
if ($studentkey eq $answerkey) {
$credit = $correctanswertag;
} else {
$credit = $incorrectanswertag;
if ($studentresponse eq '') { $credit = $noanswertag;}
}
}
if ($qtype eq 'mcm') {
@myalbls=&set_answer_labels($myqalb);
$studentresponse =~ s/xxx//g;
@txts = split(/\n/, $QUESTION{'qca'});
@txts_wro = split(/\n/, $QUESTION{'qia'});
foreach $qia (@txts_wro) {
push @txts, $qia;
}
@kans = split(/\?/,$keyresponse);
foreach $j (1 .. $#kans) {
$jidx = $j-1;
@indexs = split(/=/, $kans[$j]);
if ($indexs[1] == '1') {
$answerkey = join('',$answerkey,"$txts[$indexs[0]]\;");
}
if ($studentresponse =~ /$jidx/) {
$studentkey = join('',$studentkey,"$txts[$indexs[0]]\;");
}
}
if ($studentkey) { $studentkey = substr($studentkey,0,-1) }
if ($answerkey) { $answerkey = substr($answerkey,0,-1) }
if ($studentkey eq $answerkey) {
$credit = $correctanswertag;
} else {
$credit = $incorrectanswertag;
if ($studentresponse eq '') { $credit = $noanswertag;}
}
}
if ($qtype eq 'mch') {
$qanswermatch = "\&nbsp;<BR>\n";
@txts = split(/\n/, $QUESTION{'qca'});
@txts_wro = split(/\n/, $QUESTION{'qia'});
@ansopts = split(/\./, $keyresponse);
$anstype = shift @ansopts;
@albls=&set_answer_labels($anstype);
$keyresponse = "";
### DED-02 7/17/2002 Added following 2 lines
### and changed studentkey join below
### to allow for "?" delimiter in response
@studentresponse = split(/\?/, $studentresponse);
shift @studentresponse;
for (0 .. $#ansopts) {
$cansord[$ansopts[$_]] = $albls[$_];
$qanswermatch = join('',$qanswermatch, "<I>($cansord[$ansopts[$_]]) $txts_wro[$ansopts[$_]]</I><BR>\n");
}
foreach $cansord (@cansord) {
$keyresponse = join('', $keyresponse, $cansord);
}
for (0 .. $#ansopts) {
$answerkey = join('',$answerkey,"($cansord[$_]) $txts[$_]<BR>\n");
### DED-06 7/23/2002 added following if
### to print " " instead of "xxx"
### for blank response
if ( $studentresponse[$_] eq "xxx" ) {
$studentresponse[$_] = " ";
}
### DED-02 changed
#$studentkey = join('',$studentkey,"(",substr($studentresponse,$_,1),") $txts[$_]<BR>\n");
### to
$studentkey = join('',$studentkey,"(",$studentresponse[$_],") $txts[$_]<BR>\n");
}
@cansord = ();
### DED-02 vvv
$studentresponse="";
for (0 .. $#studentresponse) {
$studentresponse=join('', $studentresponse, $studentresponse[$_]);
}
### END DED-02
if ($studentresponse eq $keyresponse) {
$credit = $correctanswertag;
} else {
$studentresponse =~ s/x//g;
$credit = $incorrectanswertag;
if ($studentresponse eq '') { $credit = $noanswertag;}
}
}
if ($qtype eq 'ord') {
### DED 8/10/2002 Got rid of labels because
### "o" designator now working
@txts = split(/\n/, $QUESTION{'qca'});
@studentresponse = split(/\?/, $studentresponse);
shift @studentresponse;
@ansopts = split(/\./, $keyresponse);
$ansopt = shift @ansopts;
for (0 .. $#ansopts) {
$ansopt = $ansopts[$_];
$ansopt++;
$answerkey = join('',$answerkey,"($ansopt) $txts[$ansopts[$_]]<BR>\n");
### DED-07 7/23/2002 added following if
### to print " " instead of "xxx"
### for blank response
if ( $studentresponse[$_] eq "xxx" ) {
$studentresponse[$_] = " ";
}
### DED-03 changed
#$studentkey = join('',$studentkey,"(",substr($studentresponse,$_,1),") $txts[$ansopts[$_]]<BR>\n");
### to
$studentkey = join('',$studentkey,"(",$studentresponse[$_],") $txts[$ansopts[$_]]<BR>\n");
}
if ($studentkey eq $answerkey) {
$credit = $correctanswertag;
} else {
$credit = $incorrectanswertag;
if ($studentresponse eq '') { $credit = $noanswertag;}
}
}
} else {
if ($qtype eq 'nrt') {
$studentkey = "$studentresponse";
$studentkey =~ s/\%0D\%0A/\;/g;
$studentkey = unmunge($studentkey);
}
if ($qtype eq 'tf') {
$studentkey = $studentresponse;
if ($studentresponse eq '') { $credit = $noanswertag;}
}
if ($qtype eq 'esa') {
$studentkey = $studentresponse;
if ($studentresponse eq '') { $credit = $noanswertag;}
}
if ($qtype eq 'mcs' || $qtype eq 'mca') {
$studentresponse =~ s/xxx//g;
@txts = ();
if ($QUESTION{'qca'} ne '') {
push @txts, $QUESTION{'qca'};
}
@txts_wro = split(/\n/, $QUESTION{'qia'});
foreach $qia (@txts_wro) {
push @txts, $qia;
}
@kans = split(/\?/,$keyresponse);
foreach $j (1 .. $#kans) {
$jidx = $j-1;
@indexs = split(/=/, $kans[$j]);
if ($studentresponse =~ /$jidx/) {
$studentkey = $txts[$indexs[0]];
}
}
if ($studentresponse eq '') { $credit = $noanswertag;}
}
if ($qtype eq 'mtx' || $qtype eq 'mtr') {
$studentkey="";
# Split qia into row and col headers
$qia = $QUESTION{'qia'};
$qia =~ s/\r/\n/g;
$qia =~ s/\n\n/\n/g;
($qrowhdr, $qcolhdr) = split(/RC/,$qia);
@qrowhdr = split(/\n/, $qrowhdr);
@qcolhdr = split(/\n/, $qcolhdr);
if ($qtype eq 'mtx') {
# Mark selections with "CHECKED"
@optvalues = split(/\?/, $studentresponse);
shift @optvalues;
$i=0;
foreach $row (0 .. $#qrowhdr)
{
foreach $col (0 .. $#qcolhdr)
{
if ($optvalues[$i] != "xxx")
{
$chmatrix[$row][$col]="CHECKED";
}
else
{
$chmatrix[$row][$col]="";
}
$i++;
}
}
} else {
# Mark selections with "SELECTED"
@optvalues = split(/\?/, $studentresponse);
shift @optvalues;
$i=0;
foreach $row (0 .. $#qrowhdr)
{
foreach $col (0 .. $#qcolhdr)
{
$rank = $optvalues[$i];
foreach $irank (0 .. 5)
{
if ($irank eq $rank)
{
$chmatrix[$i][$irank]="SELECTED";
}
else
{
$chmatrix[$i][$irank]="";
}
}
$i++;
}
}
}
# Build matrix html
$studentkey="<table border=2>\n<tr><td>&nbsp;</td>";
foreach (0 .. $#qcolhdr) {
$studentkey .= "<td>$qcolhdr[$_]</td>";
}
$studentkey .= "</tr>\n";
$i=0;
foreach $row (0 .. $#qrowhdr) {
$studentkey .= "<tr><td>$qrowhdr[$row]</td>";
foreach $col (0 .. $#qcolhdr) {
if ($qtype eq 'mtx') {
$studentkey .= "<td align=center><input type=checkbox name=\"qrs$row$col\" value=\"1\" $chmatrix[$row][$col]></td>";
} else {
$studentkey .= "<td align=center><select name=\"qrs$row$col\"><option value='' $chmatrix[$i][0]>\&nbsp\;</option><option value=1 $chmatrix[$i][1]>1</option><option value=2 $chmatrix[$i][2]>2</option><option value=3 $chmatrix[$i][3]>3</option><option value=4 $chmatrix[$i][4]>4</option><option value=5 $chmatrix[$i][5]>5</option></select></td>";
}
$i++;
}
$studentkey .= "</tr>\n";
}
$studentkey .= "</table>\n";
@qrowhdr = ();
@qcolhdr = ();
@chmatrix = ();
if ($studentresponse eq '') { $credit = $noanswertag;}
}
if ($qtype eq 'mcm') {
$studentresponse =~ s/xxx//g;
@txts = ();
if ($QUESTION{'qca'} ne '') {
@txts = split(/\n/, $QUESTION{'qca'});
}
@txts_wro = split(/\n/, $QUESTION{'qia'});
foreach $qia (@txts_wro) {
push @txts, $qia;
}
@kans = split(/\?/,$keyresponse);
foreach $j (1 .. $#kans) {
$jidx = $j-1;
@indexs = split(/=/, $kans[$j]);
if ($studentresponse =~ /$jidx/) {
$studentkey = join('',$studentkey,"$txts[$indexs[0]]\;");
}
}
if ($studentresponse eq '') { $credit = $noanswertag;}
}
if ($qtype eq 'mch') {
### DED-04 7/17/2002 Same as DED-02
@studentresponse = split(/\?/, $studentresponse);
shift @studentresponse;
$qanswermatch = "\&nbsp;<BR>\n";
@txts = split(/\n/, $QUESTION{'qca'});
@txts_wro = split(/\n/, $QUESTION{'qia'});
@ansopts = split(/\./, $keyresponse);
$anstype = shift @ansopts;
@albls=&set_answer_labels($anstype);
$keyresponse = "";
for (0 .. $#ansopts) {
$cansord[$ansopts[$_]] = $albls[$_];
$qanswermatch = join('',$qanswermatch, "<I>($cansord[$ansopts[$_]]) $txts_wro[$ansopts[$_]]</I><BR>\n");
}
foreach $cansord (@cansord) {
$keyresponse = join('', $keyresponse, $cansord);
}
for (0 .. $#ansopts) {
$studentkey = join('',$studentkey,"(",$studentresponse[$_],") $txts[$_]<BR>\n");
}
@cansord = ();
$studentresponse =~ s/x//g;
if ($studentresponse eq '') { $credit = $noanswertag;}
}
if ($qtype eq 'ord') {
### DED-05 7/17/2002 Same as DED-02
@studentresponse = split(/\?/, $studentresponse);
shift @studentresponse;
@albls = &set_answer_labels($QUESTION{'qalb'});
@txts = split(/\n/, $QUESTION{'qca'});
@ansopts = split(/\./, $keyresponse);
$ansopt = shift @ansopts;
for (0 .. $#ansopts) {
$ansopt = $ansopts[$_];
$ansopt++;
$studentkey = join('',$studentkey,"(",$studentresponse[$_],") $txts[$ansopts[$_]]<BR>\n");
}
if ($studentresponse eq '') { $credit = $noanswertag;}
}
}
print "$user,\"$CANDIDATE{'nmf'} $CANDIDATE{'nmm'} $CANDIDATE{'nml'}\",";
if ($TEST{'seq'} ne 'svy' && $TEST{'seq'} ne 'dmg') {
if ($scoreable || $credit eq $noanswertag) {
print "$credit,";
}
print "$questionindex,";
### Move to header and make part of "Question"
#if ($qanswermatch ne "") {
#print "$qanswermatch";
#}
### DED 8/11/04 What is this?
#if (($qtype eq 'nrt') && ($studentresponse ne '')) {
#if ($keycomments eq '') {
#print "<TD valign=\"top\" width=\"40\%\"><FONT SIZE=1>Comments:<BR></FONT><TEXTAREA name=\"cm$QUESTION{'id'}\" ROWS=5 COLS=30>$QUESTION{'qrm'}</TEXTAREA></TD>\n";
#} else {
#print "<TD valign=\"top\" width=\"40\%\"><FONT SIZE=1>Comments:<BR></FONT><TEXTAREA name=\"cm$QUESTION{'id'}\" ROWS=5 COLS=30>$keycomments</TEXTAREA></TD>\n";
#}
#} else {
print "\"$answerkey\",";
#}
print "\"$studentkey\",";
### DED 8/11/04 Don't include remediation
#if (($TEST{'remt'} ne '0') && ($TEST{'emlcndopt'} eq 'Y')
#&& ($SESSION{'uac'} eq 'cnd')) {
#print "<TR>\n";
#print "<TD>&nbsp;</TD>\n";
#print "<TD colspan=2 valign=\"top\">$QUESTION{'qrm'}</TD>\n";
#print "</TR>\n";
#}
if ($QUESTION{'qcmtprmpt'} eq 'Y') {
print "\"$studentcomments\"";
}
print "\n";
} else {
print "$questionindex,";
#if ($qanswermatch ne "") {
#print "<TR>\n";
#print "<TD colspan=3 valign=\"top\">$qanswermatch</TD>\n";
#print "</TR>\n";
#}
print "\"$studentkey\",";
### DED 8/11/04 Don't include remediation
#if (($TEST{'remt'} ne '0') && ($TEST{'emlcndopt'} eq 'Y')
#&& ($SESSION{'uac'} eq 'cnd')) {
#print "<TR>\n";
#print "<TD>&nbsp;</TD>\n";
#print "<TD colspan=2 valign=\"top\">$QUESTION{'qrm'}</TD>\n";
#print "</TR>\n";
#}
if ($QUESTION{'qcmtprmpt'} eq 'Y') {
print "\"$studentcomments\"";
}
print "\n";
}
### End of question printout
}