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.
153 lines
7.2 KiB
153 lines
7.2 KiB
4 months ago
|
#!/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'} = "<IMG NAME=\"qimage\" SRC=\"$graphroot/noimageassigned.gif\" width=100 BORDER=0>";
|
||
|
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'} = "<A NAME=\"qimage\" HREF=\"$question->{'flr'}\" TARGET=\"illustrated\">Reference Page</A>";
|
||
|
}
|
||
|
if ($illusfile ne '') {
|
||
|
my @filesegs = split(/\./, $illusfile);
|
||
|
my $fext = $filesegs[$#filesegs];
|
||
|
@filesegs = () ;
|
||
|
if ($SYSTEM{'supportedimagemedia'} =~ m/$fext/i ) {
|
||
|
if ($question->{'qim'} eq '1') {
|
||
|
$question->{'illustration'} = "<A NAME=\"qimage\" HREF=\"$cgiroot/imagepop.pl?tid=$SESSION{'tid'}\&img=$clid.$question->{'id'}.$fext\" TARGET=\"illustrated\">Illustration</A>";
|
||
|
$question->{'defthumbnail'} = "<A NAME=\"qimage\" HREF=\"$cgiroot/imagepop.pl?tid=$SESSION{'tid'}\&img=$clid.$question->{'id'}.$fext\" TARGET=\"illustrated\"><IMG NAME=\"qimagetn\" SRC=\"$cgiroot/image.pl?tid=$SESSION{'tid'}\&img=$clid.$question->{'id'}.$fext\" width=100 BORDER=0></A>";
|
||
|
} else {
|
||
|
$question->{'illustration'} = "<IMG NAME=\"qimage\" SRC=\"$cgiroot/image.pl?tid=$SESSION{'tid'}\&img=$clid.$question->{'id'}.$fext\" BORDER=0>";
|
||
|
$question->{'defthumbnail'} = "<A NAME=\"qimage\" HREF=\"$cgiroot/imagepop.pl?tid=$SESSION{'tid'}\&img=$clid.$question->{'id'}.$fext\" TARGET=\"illustrated\"><IMG NAME=\"qimagetn\" SRC=\"$cgiroot/image.pl?tid=$SESSION{'tid'}\&img=$clid.$question->{'id'}.$fext\" width=100 BORDER=0></A>";
|
||
|
}
|
||
|
} elsif ($SYSTEM{'supportedvideomedia'} =~ m/$fext/i ) {
|
||
|
$question->{'illustration'} = "<EMBED SRC=\"$cgiroot/image.pl?tid=$SESSION{'tid'}\&img=$clid.$question->{'id'}.$fext\" AUTOSTART=\"TRUE\" LOOP=\"false\" VOLUME=\"100\" CONTROLS=\"console\" HIDDEN=\"false\">";
|
||
|
} elsif ($SYSTEM{'supportedaudiomedia'} =~ m/$fext/i ) {
|
||
|
$question->{'illustration'} = "<EMBED SRC=\"$cgiroot/image.pl?tid=$SESSION{'tid'}\&img=$clid.$question->{'id'}.$fext\" AUTOSTART=\"TRUE\" LOOP=\"false\" VOLUME=\"100\" WIDTH=\"100\" 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'}="
|
||
|
<FONT SIZE=\"4\">\ <br>
|
||
|
<b><i>$qflags[1]</i></b><br>
|
||
|
<TEXTAREA NAME=\"qcucmt\" cols=\"50\" rows=\"3\"
|
||
|
wrap=on onKeyPress=\"languagesupport(this)\"
|
||
|
onFocus=\"return tGotFocus(this)\"
|
||
|
onChange=\"return onConvert(this)\"></TEXTAREA>
|
||
|
</FONT><br>\n";
|
||
|
if (($question->{'layout'} eq '4') || ($question->{'layout'} eq '5') || ($question->{'qtyp'} eq 'nrt')) {
|
||
|
$question->{'promptcomments'}=join('',"\ <br>",$question->{'promptcomments'});
|
||
|
} else {
|
||
|
$question->{'promptcomments'}=join('',"<tr><td>",$question->{'promptcomments'},"</td></tr>");
|
||
|
}
|
||
|
}
|
||
|
# sac ^ end addition for comment input support
|
||
|
#return;
|
||
|
push @questions, $question;
|
||
|
}
|
||
|
return \@questions;
|
||
|
}
|
||
|
|
||
|
1 ; # End of library file.
|
||
|
|