#!/usr/bin/perl # # $Id: $ # # Source File: questionslib.pl # --- Originally pulled from testdata.pl and converted to a library PERL file. # Get config use FileHandle; use Reporter; use Data::Dumper; require 'cybertestlib.pl' ; require 'sitecfg.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 $testgraphic $graphroot); sub get_question_definitions { my ($clid, $testid) = @_; my $qcount = 0; my @questions = () ; my @qrecs = &get_question_list($testid, $clid); chomp $qrecs[0]; my @flds = split(/&/,shift(@qrecs)); foreach my $qrec (@qrecs) { chomp ($qrec); #($id, $qtyp) = split(/&/, $qrec); my @rowdata = split(/&/, $qrec); my $i=0; my $question = {}; @{$question}{@flds} = @rowdata; ($question->{'subj'},$question->{'skilllevel'}) = split(/\./,$question->{'subj'}); $question->{'tf'} = ($question->{'qtp'} eq 'tf') ? "SELECTED" : ""; $question->{'mcs'} = ($question->{'qtp'} eq 'mcs') ? "SELECTED" : ""; $question->{'mcm'} = ($question->{'qtp'} eq 'mcm') ? "SELECTED" : ""; $question->{'esa'} = ($question->{'qtp'} eq 'esa') ? "SELECTED" : ""; $question->{'nrt'} = ($question->{'qtp'} eq 'nrt') ? "SELECTED" : ""; $question->{'qtx'} =~ s/\;/\n/g; $question->{'qca'} =~ s/\;/\n/g; $question->{'qia'} =~ s/\;/\n/g; $question->{'lbla'} = ($question->{'qalb'} eq 'a') ? "SELECTED" : ""; $question->{'lblA'} = ($question->{'qalb'} eq 'A') ? "SELECTED" : ""; $question->{'lbln'} = ($question->{'qalb'} eq 'n') ? "SELECTED" : ""; $question->{'lblr'} = ($question->{'qalb'} eq 'r') ? "SELECTED" : ""; $question->{'lblR'} = ($question->{'qalb'} eq 'R') ? "SELECTED" : ""; $question->{'tft'} = ($question->{'qtp'} eq 'tf' && $question->{'qca'} eq 'TRUE') ? "CHECKED" : ""; $question->{'tff'} = ($question->{'qtp'} eq 'tf' && $question->{'qca'} eq'FALSE') ? "CHECKED" : ""; $question->{'tfy'} = ($question->{'qtp'} eq 'tf' && $question->{'qca'} eq 'YES') ? "CHECKED" : ""; $question->{'tfn'} = ($question->{'qtp'} eq 'tf' && $question->{'qca'} eq'NO') ? "CHECKED" : ""; $question->{'qim0'} = ($question->{'qim'} eq '0') ? "SELECTED" : ""; $question->{'qim1'} = ""; $question->{'qim2'} = ""; my $illus = join($pathsep, $testgraphic, "$clid.$question->{'id'}"); my $supportedmedia = join(';', $SYSTEM{'supportedimagemedia'}, $SYSTEM{'supportedaudiomedia'}, $SYSTEM{'supportedvideomedia'}); my $illusfile = &file_exists_with_extension($illus, $supportedmedia); $question->{'illustration'} = ""; $question->{'defthumbnail'} = ""; if ($question->{'qim'} eq '1') { $question->{'qim1'} = "SELECTED"; } elsif ($question->{'qim'} eq '2') { $question->{'qim2'} = "SELECTED"; } elsif ($question->{'qim'} eq '3' ) { $question->{'qim3'} = "SELECTED"; $question->{'illustration'} = "{'flr'}\" TARGET=\"illustrated\">Reference Page"; } if ($illusfile ne '') { my @filesegs = split(/\./, $illusfile); my $fext = $filesegs[$#filesegs]; @filesegs = () ; my $IllustrationLabel = "" ; if ($fext =~ /pdf$/i ) { $IllustrationLabel = "Click Here" ; } else { $IllustrationLabel = "Illustration" ; } if ($SYSTEM{'supportedimagemedia'} =~ m/$fext/i ) { if ($question->{'qim'} eq '1') { $question->{'illustration'} = "{'id'}.$fext\" TARGET=\"illustrated\">$IllustrationLabel"; $question->{'defthumbnail'} = "{'id'}.$fext\" TARGET=\"illustrated\">{'id'}.$fext\" width=100 BORDER=0>"; } else { $question->{'illustration'} = "{'id'}.$fext\" BORDER=0>"; $question->{'defthumbnail'} = "{'id'}.$fext\" TARGET=\"illustrated\">{'id'}.$fext\" width=100 BORDER=0>"; } } elsif ($SYSTEM{'supportedvideomedia'} =~ m/$fext/i ) { $question->{'illustration'} = "{'id'}.$fext\" AUTOSTART=\"TRUE\" LOOP=\"false\" VOLUME=\"100\" CONTROLS=\"console\" HIDDEN=\"false\">"; } elsif ($SYSTEM{'supportedaudiomedia'} =~ m/$fext/i ) { $question->{'illustration'} = "{'id'}.$fext\" AUTOSTART=\"TRUE\" LOOP=\"false\" VOLUME=\"100\" WIDTH=\"300\" HEIGHT=\"50\" CONTROLS=\"small console\" HIDDEN=\"false\">"; } } #if ($question->{'qnxt'} eq '' ) { #$question->{'qnxt'} = ($qcount < $#qrecs) ? $qcount + 1 : $#qrecs; #} else { #if ($question->{'qnxt'} > $#qrecs) { #$question->{'qnxt'} = $#qrecs; #} #} #if ($question->{'qprv'} eq '' ) { #$question->{'qprv'} = ($qcount == 1) ? 1 : $qcount - 1; #} else { #if ($question->{'qprv'} > $#qrecs) { #$question->{'qprv'} = $#qrecs; #} #} $question->{'totdef'} = $#qrecs; $question->{'chkobs'} = ($question->{'qil'} eq 'Y') ? "CHECKED" : ""; if ($question->{'qtx'} =~ /:::/) { ($question->{'qtx'}, $question->{'left_be'}, $question->{'right_be'}) = split(/:::/, $question->{'qtx'}); } if ($question->{'layout'} =~ /:/) { ($question->{'layout'}, $question->{'anslay'}) = split(/:/, $question->{'layout'}); $question->{'anslayhchk'} = ($question->{'anslay'} eq 'h') ? "CHECKED" : ""; } else { $question->{'anslay'} = ""; } $question->{'anslayvchk'} = ($question->{'anslay'} ne 'h') ? "CHECKED" : ""; $question->{'layout2chk'} = ($question->{'layout'} eq '2') ? "CHECKED" : ""; $question->{'layout3chk'} = ($question->{'layout'} eq '3') ? "CHECKED" : ""; $question->{'layout4chk'} = ($question->{'layout'} eq '4') ? "CHECKED" : ""; $question->{'layout5chk'} = ($question->{'layout'} eq '5') ? "CHECKED" : ""; $question->{'layout1chk'} = ($question->{'layout'} eq '1') ? "CHECKED" : ""; if ($question->{'layout'} eq '') { $question->{'layout'} = '1'; $question->{'layout1chk'} = "CHECKED"; } # sac v start addition for comment input support my @qflags = split(/\./,$question->{'flags'}); $question->{'qcmtprmpt'} = $qflags[0]; $question->{'chkqccmt'} = ($qflags[0] eq 'Y') ? "CHECKED" : ""; $question->{'qcprmpt'} = ($qflags[0] eq 'Y') ? $qflags[1] : ""; $question->{'promptcomments'}=""; if ($qflags[0] eq 'Y') { $question->{'promptcomments'}="
$qflags[1]

\n"; if (($question->{'layout'} eq '4') || ($question->{'layout'} eq '5') || ($question->{'qtyp'} eq 'nrt')) { $question->{'promptcomments'}=join('',"\ 
",$question->{'promptcomments'}); } else { $question->{'promptcomments'}=join('',"",$question->{'promptcomments'},""); } } # sac ^ end addition for comment input support #return; push @questions, $question; } return \@questions; } 1 ; # End of library file.