#!/usr/bin/perl
#
# Source File: likert_wall_D_103.pl
#
# use strict;
# Get config
require 'sitecfg.pl';
require 'testlib.pl';
require 'tstatlib.pl';
require 'questionslib.pl';
use Data::Dumper;
require bargraph_multi ;
use vars qw(%FORM %SESSION %CLIENT %TEST_SESSION %SUBTEST_QUESTIONS %TEST
%SUBTEST_SUMMARY %CANDIDATE %SUBTEST_ANSWERS %SYSTEM %REPORT %GRPFIELD
%SUBTEST_RESPONSES @xlatphrase);
use vars qw($testcomplete $cgiroot $pathsep $dataroot @rptparams );
use vars qw($testinprog $testpending) ;
my ($last_index, $HBI_Debug) ;
my $HBI_Debug_FeedBack = 1 ;
my $HBI_Debug_Graph_Data = 1 ;
$HBI_Debug = 1 ; # Controls output of Debugging Data.
my $HBI_Debug_Sample_Numbers = 0 ;
$FORM{'frm'}="";
my %Month_Full =
("Jan" => "January", "Feb" => "February", "Mar" => "March",
"Apr" => "April", "May" => "May", "Jun" => "June",
"Jul" => "July", "Aug" => "August", "Sep" => "September",
"Oct" => "October", "Nov" => "November", "Dec" => "December") ;
&app_initialize;
if ($HBI_Debug) {warn "INFO: " . __FILE__ . " running frm IS $FORM{'frm'} " ;}
# frm == 3 code will print all Content info.
unless ($FORM{'frm'} == '3') {
print "Content-Type: text/html\n\n";
$bDisplay = 1;
}
# LIKERT Scale Test Reports by Candidate
if (&get_session($FORM{'tid'})) {
&LanguageSupportInit();
$REPORT{'rptid'}="";
@rptdefs = &get_data("reports.$SESSION{'clid'}");
@lbls = split(/&/, $rptdefs[0]);
foreach $rptdef (@rptdefs) {
chomp ($rptdef);
@flds = split(/&/, $rptdef);
if ($flds[0] eq $FORM{'rptno'}) {
for $i (0 .. $#lbls) {
$REPORT{$lbls[$i]} = $flds[$i];
$i++;
}
}
}
if ($FORM{'frm'} == '1') {
&show_index_candidates;
} elsif ($FORM{'frm'} == '2') {
&show_index_tests;
} elsif ($FORM{'frm'} == '3') {
&show_detail;
} elsif ($FORM{'frm'} == '4') {
&show_filter_options;
} elsif ($FORM{'frm'} == '5') {
&ReportChooser ;
} else {
print "\n";
# Most likely, this is frm == 0
print "
\n";
print "
\n";
print "\n";
}
} else {
warn __FILE__ . " running without a SESSION." ;
}
sub show_index_candidates {
&log_entry($SESSION{'clid'}, $SESSION{'uid'}, "2", "Exec Report $FORM{'rptno'}");
&get_client_profile($SESSION{'clid'});
print "
$REPORT{'rptid'} - $REPORT{'rptdesc'}
";
}
sub show_index_tests {
&log_entry($SESSION{'clid'}, $SESSION{'uid'}, "2", "Exec Report $FORM{'rptno'}");
&get_client_profile($SESSION{'clid'});
&get_candidate_profile( $SESSION{'clid'}, $FORM{'cndid'});
my $style = "SELECT {\"width: 200px;height: 200px;font-size: 8pt;\"}";
print "
$REPORT{'rptid'} - $REPORT{'rptdesc'}
";
&log_entry($SESSION{'clid'}, $SESSION{'uid'}, "3", "Exec Report $FORM{'rptno'} completed");
}
sub show_filter_options {
my $cndid;
my $cndname;
my @testdates;
my $iopt;
my $optval;
my $optdesc;
my $lstdates;
my $qcor;
my $qinc;
my $tscore;
my $trash;
my $j;
my $i;
my @tests;
my @tmpdates;
my $jscript;
my $colspan;
&log_entry($SESSION{'clid'}, $SESSION{'uid'}, "2", "Report Options $FORM{'rptno'}");
&get_client_profile($SESSION{'clid'});
&get_candidate_profile( $SESSION{'clid'}, $FORM{'cndid'});
@tests = split(/\,/,$FORM{'tstid'});
$cndname = join('', $CANDIDATE{'nml'}, ", ", $CANDIDATE{'nmf'}, " ", $CANDIDATE{'nmm'});
$cndid = $CANDIDATE{'uid'};
$lstdates = "\n");
$styles = "SELECT {\"font-size: 8pt;\"}\n";
$styles = join('',$styles,"INPUT {\"font-size: 8pt;height: 20px;\"}\n");
print "
$REPORT{'rptid'} - $REPORT{'rptdesc'}
";
}
sub show_detail {
my @tentries;
my @tcols;
my $i;
my $j;
my $k;
my $loidx;
my $hiidx;
my $loscore;
my $hiscore;
my $avgscore;
my $avgcount;
my @testdates;
my @found;
my $sgrepfor;
my $bDisplay;
my $timetaken;
my $testtitle;
my $tstdate;
my $testid;
my @tmparray;
my @tmpdates;
my @Report_Groups ;
my $RTF_PNG_Begin ;
my $RTF_PNG_Close ;
&log_entry($SESSION{'clid'}, $SESSION{'uid'}, "2", "Exec Report $FORM{'rptno'}");
@Report_Groups = split(/\000/, $FORM{'idlist'}) ;
if ($HBI_Debug) {
print "Content-Type: text/html\n\n";
print "\ \n" ;
print "\ \ SESSION HASH ARRAY\ \n" ;
foreach $key (sort keys (%SESSION)) {
print "KEY $key VAL $SESSION{$key}\ \n" ;
}
print "\ \ FORM HASH ARRAY\ \n" ;
foreach $key (sort keys (%FORM)) {
print "KEY $key VAL $FORM{$key}\ \n" ;
}
print "\ \ idlist ARRAY \@Report_Groups\ \n" ;
print "Length of \@Report_Groups is " . ($#Report_Groups + 1) . "\ \n" ;
foreach $key (@Report_Groups) {
print "Array element $key \ \n" ;
}
print "\ Dumper of \$FORM\{idlist\} " ;
print Dumper($FORM{'idlist'}) ;
print "\ \ \n" ;
my $lookatit = $FORM{'idlist'} ;
$lookatit =~ tr/\000/,/ ;
print Dumper($lookatit) ;
print "\ \ \n" ;
}
unless ($SESSION{'clid'}) {
warn "No Client ID in the session.\n" ;
warn "Client ID in the FORM is $FORM{'clid'}\n" ;
print "No Client ID in the session.\n" ;
print "\ \n" ;
exit 0 ;
}
&get_client_profile($SESSION{'clid'});
# populates the Assoc. array %CLIENT with data for the client id.
if ($HBI_Debug) {
print "\ \ CLIENT HASH ARRAY\ \n" ;
foreach $key (sort keys (%CLIENT)) {
print "KEY $key VAL $CLIENT{$key}\ \n" ;
}
}
unless ($FORM{'cndid'}) {
warn "No Candidate ID in the form.\n" ;
print "No Candidate ID in the form.\n" ;
print "\ \n" ;
exit 0 ;
}
&get_candidate_profile( $SESSION{'clid'}, $FORM{'cndid'});
$CANDIDATE{'full_name'} = $CANDIDATE{'nmf'} . " " ;
$CANDIDATE{'full_name'} .= $CANDIDATE{'nmm'} . ". " if ($CANDIDATE{'nmm'}) ;
$CANDIDATE{'full_name'} .= $CANDIDATE{'nml'} ;
$CANDIDATE{'File_Name'} = $CANDIDATE{'full_name'} ;
# warn "INFO: full name is X$CANDIDATE{'full_name'}X\n" ;
$CANDIDATE{'full_name'} = &RTFize($CANDIDATE{'full_name'}) ;
# warn "INFO: full name is X$CANDIDATE{'full_name'}X\n" ;
if ($HBI_Debug) {
print "\ \ CANDIDATE HASH ARRAY\ \n" ;
foreach $key (sort keys (%CANDIDATE)) {
print "KEY $key VAL $CANDIDATE{$key}\ \n" ;
}
}
# populates the Assoc. array %CANDIDATE with data for the candidate/user/student who took the test/survey.
# HBI - Go find the format of the test results.
# The original code supported multiple selected tests.
# This report does not support multiple tests.
unless ($CLIENT{'clid'}) {
warn "No Client ID in the CLIENT data.\n" ;
print "No Client ID in the CLIENT data.\n" ;
print "\ \n" ;
exit 0 ;
}
unless ($FORM{'tstid'}) {
warn "No Test ID in the form.\n" ;
print "No Test ID in the form.\n" ;
print "\ \n" ;
exit 0 ;
}
unless ($FORM{'tstid2'}) {
warn "No Group related Test ID in the form.\n" ;
print "No Group related Test ID in the form.\n" ;
print "\ \n" ;
exit 0 ;
}
&get_test_profile($CLIENT{'clid'}, $FORM{'tstid'});
# populates the Assoc. array %TEST with the characteristics of the test (but not the questions or answers).
unless ($FORM{'cndid'}) {
warn "No Candidate ID in the form.\n" ;
print "No Candidate ID in the form.\n" ;
print "\ \n" ;
exit 0 ;
}
$foo = get_test_sequence_for_reports($CLIENT{'clid'},$FORM{'cndid'}, $FORM{'tstid'});
# populates the Assoc. arrays %TEST_SESSION, %SUBTEST_QUESTIONS, %SUBTEST_ANSWERS, %SUBTEST_RESPONSES,
# and %SUBTEST_SUMMARY.
if ($HBI_Debug) {
print "\ \ SYSTEM HASH ARRAY\ \n" ;
foreach $key (sort keys (%SYSTEM)) {
print "KEY $key VAL $SYSTEM{$key}\ \n" ;
}
print "\ \ CLIENT HASH ARRAY\ \n" ;
foreach $key (sort keys (%CLIENT)) {
print "KEY $key VAL $CLIENT{$key}\ \n" ;
}
print "\ \ TEST HASH ARRAY\ \n" ;
foreach $key (sort keys (%TEST)) {
print "KEY $key VAL $TEST{$key}\ \n" ;
}
print "\ \ TEST_SESSION HASH ARRAY\ \n" ;
foreach $key (sort keys (%TEST_SESSION)) {
print "KEY $key VAL $TEST_SESSION{$key}\ \n" ;
}
print "\ \ SUBTEST_QUESTIONS HASH ARRAY\ \n" ;
foreach $key (sort keys (%SUBTEST_QUESTIONS)) {
print "KEY $key VAL $SUBTEST_QUESTIONS{$key}\ \n" ;
}
print "\ \ SUBTEST_ANSWERS HASH ARRAY\ \n" ;
foreach $key (sort keys (%SUBTEST_ANSWERS)) {
print "KEY $key VAL $SUBTEST_ANSWERS{$key}\ \n" ;
}
print "\ \ SUBTEST_RESPONSES HASH ARRAY\ \n" ;
foreach $key (sort keys (%SUBTEST_RESPONSES)) {
print "KEY $key VAL $SUBTEST_RESPONSES{$key}\ \n" ;
}
print "\ \ SUBTEST_SUMMARY XXX HASH ARRAY\ \n" ;
foreach $key (sort keys (%SUBTEST_SUMMARY)) {
print "KEY $key VAL $SUBTEST_SUMMARY{$key}\ \n" ;
}
} # end of if $HBI_Debug
my %supercat_total = () ; # Total points available for a category.
my %supercat_earned = () ; # Points earned for a category.
my %TGWall_Comments = () ; # Collected Text for questions and comments in a category.
my %TGWall_Comments_fnd = () ; # Collected Text for questions and comments in a category.
# The following values have a similar name, and are logically connected.
my $SUPERCAT_TOTAL = 0 ; # Total points available in all categories.
my $SUPERCAT_EARNED = 0 ; # Total points earned in all categories.
my $points, $weight, @scores, @correct_ans, @incorrect_ans, @all_ans ;
my $ques_type, $supercat, $scores, @responses, $responses ;
my @individ, $individ, @img_labels, @img_data , @Response_parts;
my $client = $SESSION{'clid'} ;
my $testid = $FORM{'tstid'} ;
my $candidate = $FORM{'cndid'} ;
my $testid2 = $FORM{'tstid2'} ;
my $MasterGroupHash = &get_group_hash($client) ;
my $grplist = {} ;
my $groupid ; my $HBI_Debug_Groups_800 = 0 ;
warn "INFO: grplist reference " . (ref $grplist) . "\n" if ($HBI_Debug_Groups_800) ;
foreach $groupid (@Report_Groups) {
$grplist->{$groupid} = $MasterGroupHash->{$groupid}->{'GroupMembersA'} ;
warn "INFO: Group ID $groupid \n" if ($HBI_Debug_Groups_800) ;
warn "INFO: Group members : " . join (" ", @{$grplist->{$groupid}}) . "\n" if ($HBI_Debug_Groups_800) ;
}
$SYSTEM{'FeedBackDate'} = "Date UNK" ;
$FeedBackDateTime = 0 ;
$full_history_OK = &get_full_history($testcomplete, $client, $testid2) ;
if ($HBI_Debug_FeedBack) {
my $FBClient; my $FBtest; my $FBcand ;
warn "INFO: FB Clients " . (join(" ", keys %{$FULL_HISTORY})) . "\n" ;
foreach $FBClient (keys %{$FULL_HISTORY}) {
warn "INFO: FB client $FBClient tests " . (join(" ", keys %{$FULL_HISTORY->{$FBClient}})) . "\n" ;
foreach $FBtest (keys %{$FULL_HISTORY->{$FBClient}}) {
warn "INFO: FB client $FBClient test $FBtest candidates " .
(join(" ", keys %{$FULL_HISTORY->{$FBClient}->{$FBtest}})) . "\n" ;
foreach $FBcand (keys %{$FULL_HISTORY->{$FBClient}->{$FBtest}}) {
warn "INFO: FB times $FBClient test $FBtest candidate $FBcand " .
(join(" ", keys %{$FULL_HISTORY->{$FBClient}->{$FBtest}->{$FBcand}})) . "\n" ;
}
}
}
}
my ($ret_all, $ret_grp, $ret_one, $ret_err) =
&GetTGWallLikertGrpData($client, $testid, $candidate, $testid2, $grplist, 1) ;
warn "ERROR: ", $ret_err, "\n" if ($ret_err) ;
#
# Build a bar chart for Candidates self evaluation vs the groups evaluation.
#
my $Data1 = [] ; # The data for the chart.
my $Category_ARef = [] ;
my $category ;
my $Legend1 = [] ; # The legends for the chart.
# load the labels for the x-axis.
push @{$Category_ARef}, (sort keys %{$ret_one}) ;
push @{$Category_ARef}, "Total" ;
push @{$Data1}, $Category_ARef ;
# Load the data for the self-evaluation.
my $Category_ARef2 ;
$Category_ARef2 = [] ;
print "\ Num. Detail Self-evaluation \ \n" if ($HBI_Debug_Graph_Data) ;
my $totavail = 0 ; my $totscore = 0 ;
foreach $category (sort keys %{$ret_one}) {
my $piavail = $ret_one->{$category}->{'PointsAvail'} ;
$totavail += $piavail ;
my $piscore = $ret_one->{$category}->{'PointsEarned'} ;
$totscore += $piscore ;
my $piaver = $piavail ? ($piscore/$piavail) : 0 ;
my $pinum = (int(100*$piaver + 0.5)) ;
push @{$Category_ARef2}, $pinum ;
print "Num. Detail Category $category piscore $piscore piavail $piavail piaver $piaver pinum $pinum \ \n"
if ($HBI_Debug_Graph_Data) ;
}
$piaver = $totavail ? ($totscore/$totavail) : 0 ;
$pinum = (int(100*$piaver + 0.5)) ;
print "Num. Total totscore $totscore totavail $totavail piaver $piaver pinum $pinum \ \n"
if ($HBI_Debug_Graph_Data) ;
push @{$Category_ARef2}, $pinum ;
push @{$Data1}, $Category_ARef2 ;
push @{$Legend1 }, $CANDIDATE{'nml'} ;
# Load the data for the Others evaluation.
$Category_ARef2 = [] ;
$totavail = 0 ; $totscore = 0 ;
print "\ Num. Detail Other-evaluation \ \n" if ($HBI_Debug_Graph_Data) ;
foreach $category (sort keys %{$ret_all}) {
$piavail = $ret_all->{$category}->{'PointsAvail'} ;
$totavail += $piavail ;
$piscore = $ret_all->{$category}->{'PointsEarned'} ;
$totscore += $piscore ;
$piaver = $piavail ? ($piscore/$piavail) : 0 ;
$pinum = (int(100*$piaver + 0.5)) ;
push @{$Category_ARef2}, $pinum ;
print "Num. Detail Category $category piscore $piscore piavail $piavail piaver $piaver pinum $pinum \ \n"
if ($HBI_Debug_Graph_Data) ;
}
$piaver = $totavail ? ($totscore/$totavail) : 0 ;
$pinum = (int(100*$piaver + 0.5)) ;
print "Num. Total totscore $totscore totavail $totavail piaver $piaver pinum $pinum \ \n"
if ($HBI_Debug_Graph_Data) ;
push @{$Category_ARef2}, $pinum ;
push @{$Data1}, $Category_ARef2 ;
push @{$Legend1 }, "360 Participants" ;
# Set up the graphing options.
my ($xdim, $ydim, $hbar, $title, $xlabel, $ylabel,
$ymax, $ymin, $yticknum, $t_margin, $b_margin, $l_margin, $r_margin,
$colorscheme, $bar_spacing, $bargroup_spacing,
$show_values, $x_label_position, $y_label_position, $transparent, $overwrite,
$interlaced, $bgclr, $fgclr, $boxclr, $accentclr, $shadowclr, $shadow_depth,
$labelclr, $axislabelclr, $legendclr, $valuesclr, $textclr, $dclrs, $borderclrs,
$cycle_clrs, $accent_treshold, $long_ticks, $tick_length, $x_ticks, $y_number_format,
$x_label_skip, $y_label_skip, $x_last_label_skip, $x_tick_offset, $x_all_ticks,
$x_label_position, $y_label_position, $x_labels_vertical, $x_plot_values, $y_plot_values,
$box_axis, $no_axes, $two_axes, $use_axis, $zero_axis, $zero_axis_only, $axis_space,
$text_space, $cumulate, $overwrite, $correct_width, $values_vertical, $values_space,
$values_format, $legend_placement, $legend_marker_width, $legend_marker_height, $lg_cols ) ;
$xdim = ( 6 * 72 ) ;
$ydim = ( 5 * 72 ) ;
$hbar = 1 ;
$title = "" ; # The title is in the text of the report above the chart.
$xlabel = "" ;
$ylabel = "Percentage" ;
$ymax = 100 ;
$ymin = 0 ;
$yticknum = 10 ;
$t_margin = 10 ;
$b_margin = 10 ;
$l_margin = 10 ;
$r_margin = 30 ;
$colorscheme = "lblue:lred" ;
$bar_spacing = 0 ;
$bargroup_spacing = 6 ;
$show_values = 1 ;
$x_label_position = undef ;
$y_label_position = undef ;
$transparent = undef ;
$overwrite = 0 ;
$interlaced = undef ;
$bgclr = undef ;
$fgclr = undef ;
$boxclr = "lgray" ;
$accentclr = undef ;
$shadowclr = undef ;
$shadow_depth = undef ;
$labelclr = undef ;
$axislabelclr = undef ;
$legendclr = undef ;
$valuesclr = undef ;
$textclr = undef ;
$dclrs = undef ; # Also handled by the $colorscheme string.
$borderclrs = undef ;
$cycle_clrs = undef ;
$accent_treshold = undef ;
$long_ticks = undef ;
$tick_length = undef ;
$x_ticks = undef ;
$y_number_format = undef ;
$x_label_skip = undef ;
$y_label_skip = undef ;
$x_last_label_skip = undef ;
$x_tick_offset = undef ;
$x_all_ticks = undef ;
$x_label_position = undef ;
$y_label_position = undef ;
$x_labels_vertical = undef ;
$x_plot_values = undef ;
$y_plot_values = undef ;
$box_axis = undef ;
$no_axes = undef ;
$two_axes = undef ;
$use_axis = undef ;
$zero_axis = undef ;
$zero_axis_only = undef ;
$axis_space = undef ;
$text_space = undef ;
$cumulate = undef ;
$overwrite = 0 ;
$correct_width = undef ;
$values_vertical = undef ;
$values_space = undef ;
$values_format = undef ;
$legend_placement = undef ;
$legend_marker_width = undef ;
$legend_marker_height = undef ;
$lg_cols = undef ;
warn "INFO: Dumping Data1\n" if ($HBI_Debug_Graph_Data) ;
warn Dumper($Data1) if ($HBI_Debug_Graph_Data) ;
# Draw the graph
my ($Graph1_obj, $Graph1_str) = &bargraph_multi::Build_Labeled_X_Axis_Graph_Str
($Data1, $Legend1, "png", $xdim, $ydim, $hbar, $title, $xlabel, $ylabel,
$ymax, $ymin, $yticknum, $t_margin, $b_margin, $l_margin, $r_margin,
$colorscheme, $bar_spacing, $bargroup_spacing,
$show_values, $x_label_position, $y_label_position, $transparent, $overwrite,
$interlaced, $bgclr, $fgclr, $boxclr, $accentclr, $shadowclr, $shadow_depth,
$labelclr, $axislabelclr, $legendclr, $valuesclr, $textclr, $dclrs, $borderclrs,
$cycle_clrs, $accent_treshold, $long_ticks, $tick_length, $x_ticks, $y_number_format,
$x_label_skip, $y_label_skip, $x_last_label_skip, $x_tick_offset, $x_all_ticks,
$x_labels_vertical, $x_plot_values, $y_plot_values,
$box_axis, $no_axes, $two_axes, $use_axis, $zero_axis, $zero_axis_only, $axis_space,
$text_space, $cumulate, $correct_width, $values_vertical, $values_space,
$values_format, $legend_placement, $legend_marker_width, $legend_marker_height, $lg_cols ) ;
my $Eol = "\r\n" ; my $lCurly = "\x7b" ; my $rCurly = "\x7d" ;
# $lCurly, and $rCurly are used as curly braces, so vim is not confused
# about matching perl code curly braces.
$RTF_PNG_Begin = $lCurly . '\\*\\shppict' ;
$RTF_PNG_Begin .= $lCurly . '\\pict\\pngblip' ;
$RTF_PNG_Begin .= "\\picw" . (${xdim} + 0) . " " ; # Width in pixels
$RTF_PNG_Begin .= "\\pich" . (${ydim} + 0) . " " ; # Height in pixels
$RTF_PNG_Begin .= "\\picwgoal" . (${xdim}*20) ; # width on the page in twips
$RTF_PNG_Begin .= "\\pichgoal" . (${ydim}*20) ; # Height on the page in twips.
$RTF_PNG_Begin .= $Eol ;
# I am using a pixel in a point. A point is 1/72 inches.
# A twip is 1/20 of a point.
$RTF_PNG_Begin .= "\\bliptag10000" ; # Unique identifier for the image.
$RTF_PNG_Begin .= $lCurly . '\\*\\blipuid ' ;
$RTF_PNG_Begin .= "00000000000000000000000000002710" ; # 32 numeric digits
$RTF_PNG_Begin .= $rCurly . $Eol ; # Ends blipuid.
$RTF_PNG_Close = $rCurly . $rCurly ; # Ends pict and shppict commands.
$RTF_PNG_Close .= $Eol ;
my $HBI_Debug_msg_str = "" ;
my $T_colors = "" ; # Normally this is a colon separated string of color names.
my $offset = 0 ;
my $length_line = 40 ;
my $len_left ;
my $part_data = "" ;
my $Hex_image ;
my $All_data_len = length $Graph1_str ;
do {
$len_left = $All_data_len - $offset ;
if ($len_left < $length_line) {$length_line = $len_left;}
$part_data .= unpack ("H*", substr($Graph1_str, $offset, $length_line)) ;
$part_data .= $Eol ;
$offset += $length_line ;
} while ($offset < $All_data_len ) ;
$SYSTEM{'Bargraph1'} = $RTF_PNG_Begin . $part_data . $RTF_PNG_Close ;
# Get the feed back date.
if ($FeedBackDateTime) {
my $date_ascii = gmtime($FeedBackDateTime) ;
chomp $date_ascii ;
my @date_parts = split (/ +/, $date_ascii) ;
my $mon_name = $date_parts[1] ;
if (exists $Month_Full{$mon_name}) {
$mon_name = $Month_Full{$mon_name} ;
} else {
warn "ERROR: Did not find full month name for $mon_name.\n" ;
}
my $year = $date_parts[4] ;
$SYSTEM{'FeedBackDate'} = $mon_name . " " . $year ;
} else {
warn "ERROR: FeedBackDateTime is unknown. Field in Automated Report is bogus." ;
}
# Get the current year for the copyright.
my $date_ascii = localtime ;
chomp $date_ascii ;
my @date_parts = split (/ +/, $date_ascii) ;
$SYSTEM{'CopyRightYear'} = $date_parts[4] ;
# Build the Feedback Comments.
my @CommSuperCats = sort keys %{$ret_all} ;
my @SuperCatQuestions ;
my $CommSuperCategory ; my $SuperCatQuestion ;
foreach $CommSuperCategory (@CommSuperCats) {
@SuperCatQuestions = keys %{$ret_all->{$CommSuperCategory}->{'Questions'}} ;
$SYSTEM{'ALL_Comments'} .= "\\par CATEGORY - $CommSuperCategory\n" ;
$SYSTEM{'ALL_Comments'} .= "\\par \n" ;
my @SortedQuestions = sort {$a <=> $b} @SuperCatQuestions ;
foreach $SuperCatQuestion (@SortedQuestions) {
$SYSTEM{'ALL_Comments'} .= "\\par Question " . ($SuperCatQuestion + 1) . " - " ;
$SYSTEM{'ALL_Comments'} .= ${$QUESTIONS_AG}[$SuperCatQuestion]->{'qtx'} . "\\par \n" ;
my $qComm = ${$QUESTIONS_AG}[$SuperCatQuestion]->{'comments'} ;
if ($qComm) {
$SYSTEM{'ALL_Comments'} .= $qComm ;
} else {
$SYSTEM{'ALL_Comments'} .= "\\par NO Comments.\\par \n" ;
}
}
}
#
# Build a bar chart for Candidates self evaluation vs the groups evaluation.
#
my $Data2 = [] ; # The data for the chart.
my @HBI_Debug_retall = (0, 0, 0, 0, 0) ;
$Category_ARef = [] ;
$category ;
my $Legend2 = [] ; # The legends for the chart.
# load the labels for the x-axis.
push @{$Category_ARef}, (sort keys %{$ret_one}) ;
push @{$Category_ARef}, "Total" ;
push @{$Data2}, $Category_ARef ;
# Load the data for the self-evaluation.
$Category_ARef2 = [] ; my $group_review ;
$totavail = 0 ; $totscore = 0 ;
my $tot_G_avail ; my $tot_G_score ;
my @Categories = (sort keys %{$ret_one}) ;
my (@Groupies, @Grp_Work_1, @Grp_Work_2) ;
@Grp_Work_1 = keys %{$ret_grp} ;
# The array above is the list of group ids.
# The array computed below is the list of group ids with manager in the group description.
@Grp_Work_2 = sort grep {$MasterGroupHash->{$_}->{'grpnme'} =~ m/manager/i} @Grp_Work_1 ;
push @Groupies, @Grp_Work_2 ;
@Grp_Work_2 = grep {$MasterGroupHash->{$_}->{'grpnme'} !~ m/manager/i} @Grp_Work_1 ;
@Grp_Work_1 = @Grp_Work_2 ;
@Grp_Work_2 = sort grep {$MasterGroupHash->{$_}->{'grpnme'} =~ m/direct/i} @Grp_Work_1 ;
push @Groupies, @Grp_Work_2 ;
@Grp_Work_2 = grep {$MasterGroupHash->{$_}->{'grpnme'} !~ m/direct/i} @Grp_Work_1 ;
@Grp_Work_1 = @Grp_Work_2 ;
@Grp_Work_2 = sort grep {$MasterGroupHash->{$_}->{'grpnme'} =~ m/peer/i} @Grp_Work_1 ;
push @Groupies, @Grp_Work_2 ;
@Grp_Work_2 = grep {$MasterGroupHash->{$_}->{'grpnme'} !~ m/peer/i} @Grp_Work_1 ;
@Grp_Work_1 = @Grp_Work_2 ;
@Grp_Work_2 = sort grep {$MasterGroupHash->{$_}->{'grpnme'} =~ m/other/i} @Grp_Work_1 ;
push @Groupies, @Grp_Work_2 ;
@Grp_Work_2 = grep {$MasterGroupHash->{$_}->{'grpnme'} !~ m/other/i} @Grp_Work_1 ;
push @Groupies, sort @Grp_Work_2 ;
if ($HBI_Debug_retall[0]) {
warn "INFO: ret_one Categories " . join(" ", @Categories) . "\n" ;
warn "INFO: ret_all Groups " . join(" ", @Groupies) . "\n" ;
}
my %Graph2_nums = () ;
my $Overall_Group = "Overall" ; my $Overall_Category = "Total" ;
my %Graph2_by_Group_nums = () ;
foreach $category (@Categories) {
$tot_G_avail = 0 ; $tot_G_score = 0 ;
foreach $group (@Groupies) {
$piavail = $ret_grp->{$group}->{$category}->{'PointsAvail'} ;
$piscore = $ret_grp->{$group}->{$category}->{'PointsEarned'} ;
$piaver = $piavail ? ($piscore/$piavail) : 0 ;
$pinum = (int(100*$piaver + 0.5)) ;
print "Num. Detail group $group Category $category piscore $piscore piavail $piavail piaver $piaver pinum $pinum \ \n"
if ($HBI_Debug_Graph_Data) ;
$Graph2_nums->{$category}->{$group} = $pinum ;
$totavail += $piavail ;
$totscore += $piscore ;
$tot_G_avail += $piavail ;
$tot_G_score += $piscore ;
$Graph2_by_Group_nums->{$group}->{'PointsAvail'} += $piavail ;
$Graph2_by_Group_nums->{$group}->{'PointsEarned'} += $piscore ;
}
$piaver = $tot_G_avail ? ($tot_G_score/$tot_G_avail) : 0 ;
$pinum = (int(100*$piaver + 0.5)) ;
$Graph2_nums->{$category}->{$Overall_Group} = $pinum ;
print "Num. group $Overall_Group Category $category tot_G_score $tot_G_score tot_G_avail $tot_G_avail piaver $piaver pinum $pinum \ \n"
if ($HBI_Debug_Graph_Data) ;
}
$category = $Overall_Category ;
$tot_G_avail = 0 ; $tot_G_score = 0 ;
foreach $group (@Groupies) {
$piavail = $Graph2_by_Group_nums->{$group}->{'PointsAvail'} ;
$piscore = $Graph2_by_Group_nums->{$group}->{'PointsEarned'} ;
$piaver = $piavail ? ($piscore/$piavail) : 0 ;
$pinum = (int(100*$piaver + 0.5)) ;
print "Num. group $group piscore $piscore piavail $piavail piaver $piaver pinum $pinum \ \n"
if ($HBI_Debug_Graph_Data) ;
$tot_G_avail += $piavail ;
$tot_G_score += $piscore ;
$Graph2_by_Group_nums->{$group}->{'pinum'} = $pinum ;
$Graph2_nums->{$category}->{$group} = $pinum ;
}
$piavail = $Graph2_by_Group_nums->{$Overall_Group}->{'PointsAvail'} = $tot_G_avail ;
$piscore = $Graph2_by_Group_nums->{$Overall_Group}->{'PointsEarned'} = $tot_G_score ;
$piaver = $piavail ? ($piscore/$piavail) : 0 ;
$pinum = (int(100*$piaver + 0.5)) ;
print "Num. OVERALL piscore $piscore piavail $piavail piaver $piaver pinum $pinum \ \n"
if ($HBI_Debug_Graph_Data) ;
$Graph2_by_Group_nums->{$Overall_Group}->{'pinum'} = $pinum ;
$Graph2_nums->{$Overall_Category}->{$Overall_Group} = $pinum ;
my $HBI_Debug_Load_Data = 0 ;
if ($HBI_Debug_Load_Data) {
warn "INFO: Load_Data Groups cnt " . ($#Groupies +1) . "\n" ;
warn "INFO: Groups " . (join " ", @Groupies) . "\n" ;
warn "INFO: Load_Data Categories cnt " . ($#Categories +1) . "\n" ;
warn "INFO: Categories " . (join " ", @Categories) . "\n" ;
}
foreach $group (@Groupies, $Overall_Group) {
$Category_ARef2 = [] ;
foreach $category (@Categories, $Overall_Category) {
push @{$Category_ARef2}, $Graph2_nums->{$category}->{$group} ;
}
push @{$Data2}, $Category_ARef2 ;
}
if ($HBI_Debug_Sample_Numbers) {
my $Sample_Number_Size = $#{$Category_ARef2} + 1 ;
$Category_ARef2 = [] ;
push @{$Category_ARef2}, 100, 0 ;
$Sample_Number_Size -- ;
$Sample_Number_Size -- ;
$Sample_Number_Size = ($Sample_Number_Size >= 0) ? $Sample_Number_Size : 0 ;
push @{$Category_ARef2}, ( (50) x $Sample_Number_Size) ;
}
foreach $group (@Groupies ) {
push @{$Legend2 }, $MasterGroupHash->{$group}->{'grpnme'} ;
}
push @{$Legend2 }, "Sample Test" if ($HBI_Debug_Sample_Numbers) ;
push @{$Legend2 }, $Overall_Group ;
# Set up the graphing options.
$xdim = ( 6 * 72 ) ;
$ydim = ( 7 * 72 ) ;
$hbar = 1 ;
$title = "" ;
$xlabel = "" ;
$ylabel = "" ;
$ymax = 100 ;
$ymin = 0 ;
$yticknum = 10 ;
$t_margin = 20 ;
$b_margin = 10 ;
$l_margin = 10 ;
$r_margin = 30 ;
$colorscheme = "red:blue:green:yellow:gray" ;
$bar_spacing = 0 ;
$bargroup_spacing = 2 ;
$show_values = 1 ;
$x_label_position = undef ;
$y_label_position = undef ;
$transparent = undef ;
$overwrite = undef ;
$interlaced = undef ;
$bgclr = undef ;
$fgclr = undef ;
$boxclr = "lgray" ;
$accentclr = undef ;
$shadowclr = undef ;
$shadow_depth = undef ;
$labelclr = undef ;
$axislabelclr = undef ;
$legendclr = undef ;
$valuesclr = undef ;
$textclr = undef ;
$dclrs = undef ; # Also handled by the $colorscheme string.
$borderclrs = undef ;
$cycle_clrs = undef ;
$accent_treshold = undef ;
$long_ticks = undef ;
$tick_length = undef ;
$x_ticks = undef ;
$y_number_format = undef ;
$x_label_skip = undef ;
$y_label_skip = undef ;
$x_last_label_skip = undef ;
$x_tick_offset = undef ;
$x_all_ticks = undef ;
$x_label_position = undef ;
$y_label_position = undef ;
$x_labels_vertical = undef ;
$x_plot_values = undef ;
$y_plot_values = undef ;
$box_axis = undef ;
$no_axes = undef ;
$two_axes = undef ;
$use_axis = undef ;
$zero_axis = undef ;
$zero_axis_only = undef ;
$axis_space = undef ;
$text_space = undef ;
$cumulate = undef ;
$overwrite = undef ;
$correct_width = undef ;
$values_vertical = undef ;
$values_space = undef ;
$values_format = undef ;
$legend_placement = "BC" ;
$legend_marker_width = undef ;
$legend_marker_height = undef ;
$lg_cols = undef ;
warn "INFO: Dumping Data2\n" if ($HBI_Debug_Graph_Data) ;
warn Dumper($Data2) if ($HBI_Debug_Graph_Data) ;
# Draw the graph
my ($Graph2_obj, $Graph2_str) = &bargraph_multi::Build_Labeled_X_Axis_Graph_Str
($Data2, $Legend2, "png", $xdim, $ydim, $hbar, $title, $xlabel, $ylabel,
$ymax, $ymin, $yticknum, $t_margin, $b_margin, $l_margin, $r_margin,
$colorscheme, $bar_spacing, $bargroup_spacing,
$show_values, $x_label_position, $y_label_position, $transparent, $overwrite,
$interlaced, $bgclr, $fgclr, $boxclr, $accentclr, $shadowclr, $shadow_depth,
$labelclr, $axislabelclr, $legendclr, $valuesclr, $textclr, $dclrs, $borderclrs,
$cycle_clrs, $accent_treshold, $long_ticks, $tick_length, $x_ticks, $y_number_format,
$x_label_skip, $y_label_skip, $x_last_label_skip, $x_tick_offset, $x_all_ticks,
$x_labels_vertical, $x_plot_values, $y_plot_values,
$box_axis, $no_axes, $two_axes, $use_axis, $zero_axis, $zero_axis_only, $axis_space,
$text_space, $cumulate, $correct_width, $values_vertical, $values_space,
$values_format, $legend_placement, $legend_marker_width, $legend_marker_height, $lg_cols ) ;
# $lCurly, and $rCurly are used as curly braces, so vim is not confused
# about matching perl code curly braces.
$RTF_PNG_Begin = $lCurly . '\\*\\shppict' ;
$RTF_PNG_Begin .= $lCurly . '\\pict\\pngblip' ;
$RTF_PNG_Begin .= "\\picw" . (${xdim} + 0) . " " ; # Width in pixels
$RTF_PNG_Begin .= "\\pich" . (${ydim} + 0) . " " ; # Height in pixels
$RTF_PNG_Begin .= "\\picwgoal" . (${xdim}*20) ; # width on the page in twips
$RTF_PNG_Begin .= "\\pichgoal" . (${ydim}*20) ; # Height on the page in twips.
$RTF_PNG_Begin .= $Eol ;
# I am using a pixel in a point. A point is 1/72 inches.
# A twip is 1/20 of a point.
$RTF_PNG_Begin .= "\\bliptag20000" ; # Unique identifier for the image.
$RTF_PNG_Begin .= $lCurly . '\\*\\blipuid ' ;
$RTF_PNG_Begin .= "00000000000000000000000000022710" ; # 32 numeric digits
$RTF_PNG_Begin .= $rCurly . $Eol ; # Ends blipuid.
$RTF_PNG_Close = $rCurly . $rCurly ; # Ends pict and shppict commands.
$RTF_PNG_Close .= $Eol ;
$HBI_Debug_msg_str = "" ;
$offset = 0 ;
$length_line = 40 ;
$len_left ;
$part_data = "" ;
$Hex_image ;
$All_data_len = length $Graph2_str ;
do {
$len_left = $All_data_len - $offset ;
if ($len_left < $length_line) {$length_line = $len_left;}
$part_data .= unpack ("H*", substr($Graph2_str, $offset, $length_line)) ;
$part_data .= $Eol ;
$offset += $length_line ;
} while ($offset < $All_data_len ) ;
$SYSTEM{'Bargraph2'} = $RTF_PNG_Begin . $part_data . $RTF_PNG_Close ;
if ($HBI_Debug) {
$last_index = $#{$QUESTIONS_AH} ;
if ($last_index == -1) {
print "\ \n" ;
print "\ \ QUESTIONS_AH HASH ARRAY is empty.\ \n" ;
print "\ \n" ;
} else {
print "\ \ QUESTIONS_AH HASH ARRAY Dump.\ \n" ;
foreach $index (0 .. $last_index) {
print "\ \n" ; # HBI
print "\ \ QUESTIONS_AH HASH ARRAY Element $index \ \n" ;
foreach $key (sort keys (%{${$QUESTIONS_AH}[$index]})) {
print "KEY $key VAL " ;
print "${$QUESTIONS_AH}[$index]->{$key}" ;
print "\ \n" ;
} # end foreach $key
} # end foreach $index
} # end of if $last_index
} # end of if $HBI_Debug
if ($HBI_Debug) {
$last_index = $#{$QUESTIONS_AG} ;
if ($last_index == -1) {
print "\ \n" ;
print "\ \ QUESTIONS_AG HASH ARRAY is empty.\ \n" ;
print "\ \n" ;
} else {
print "\ \ QUESTIONS_AG HASH ARRAY Dump.\ \n" ;
foreach $index (0 .. $last_index) {
print "\ \n" ; # HBI
print "\ \ QUESTIONS_AG HASH ARRAY Element $index \ \n" ;
foreach $key (sort keys (%{${$QUESTIONS_AG}[$index]})) {
print "KEY $key VAL " ;
print "${$QUESTIONS_AG}[$index]->{$key}" ;
print "\ \n" ;
} # end foreach $key
} # end foreach $index
} # end of if $last_index
} # end of if $HBI_Debug
# Now we are going to format the date the test was taken. <%=FORM.tdatesel%>
# Original text is like 05-Jul-2013_19:37:35_GMT
my $given_date_str = $FORM{'tdatesel'} ;
my $new_fmt_date ;
my ($day_month, $month_str, $cent_year) ;
if ($given_date_str =~ m/^(\d+)\-([^\-]+)\-(\d+)/ ) {
$day_month = $1 ;
$month_str = $2 ;
$cent_year = $3 ;
$month_str = $Month_Full{$month_str} if ($Month_Full{$month_str}) ;
$FORM{'tdatesel'} = &RTFize("$month_str $day_month, $cent_year") ;
}
$SYSTEM{'FeedBackDate'} = &RTFize($SYSTEM{'FeedBackDate'}) ;
if ($HBI_Debug) {
print "\ \n" ;
print "full name\ \n" ;
print $CANDIDATE{'full_name'} ;
print "\ \n" ;
print "Test Date\ \n" ;
print $FORM{'tdatesel'} ;
print "\ \n" ;
print "FeedBack Date\ \n" ;
print $SYSTEM{'FeedBackDate'} ;
print "\ \n" ;
print "Graphic Text\ \n" ;
print $SYSTEM{'Graphic_Text'} ;
print "\ \n" ;
print "Comments\ \n" ;
print $SYSTEM{'ALL_Comments'} ;
print "\ \n" ;
print "SYSTEM First Barchart\ \n" ;
print $SYSTEM{'Bargraph1'} ;
print "\ \n" ;
print "SYSTEM Second Barchart\ \n" ;
print $SYSTEM{'Bargraph2'} ;
print "\ \n" ;
exit 0 ;
}
&log_entry($SESSION{'clid'}, $SESSION{'uid'}, "3", "Exec Report $FORM{'rptno'} completed");
$OUTPUT_Format = "RTF" ;
print "Content-Type: text/rtf\n" ;
my $FName = $CANDIDATE{'File_Name'} ;
$FName =~ s/\W/_/g ;
print "Content-Disposition: attachment;filename=${FName}_360_report.rtf\n\n";
&show_template("TGWall_360_Blank_Report.rtf") ;
$OUTPUT_Format = "HTML" ;
}
################################################################################
#
# Subroutine Name
# GetTestHeader
#
# Description
# This subroutine returns the header of the test file
#
# Inputs
# $clientId -- The id of the client to search through
#
# Outputs
# None
#
# Returns
# @testFields -- An array of fields in the header
#
#adt080401###############################################################################
sub GetTestHeader
{
my $clientId = $_[0];
my @testList = &get_data("tests.$clientId");
my $testHdr = $testList[0];
my $testFields;
chop( $testHdr );
@testFields = split( /&/, $testHdr );
return @testFields;
}
#adt080401###############################################################################
#
# Subroutine Name
# GetTestsByOwner
#
# Description
# This subroutine searches through the test definition file of the given
# client for all the tests that are owned by the given user id or are public
#
# Inputs
# $clientId -- The id of the client to search through
# $ownedBy -- The name of the owner of the test to search for
#
# Outputs
# None
#
# Returns
# @tests -- An array of tests owned by the given user id
#
################################################################################
sub GetTestsByOwner
{
my $clientId = $_[0];
my $ownedBy = $_[1];
my %currHash;
my @testList = &get_data("tests.$clientId");
my @currField;
my @tests;
my $testHdr = $testList[0];
my $testFields;
my $testCntr;
@testFields = &GetTestHeader( $clientId );
for( $testCntr = 1; $testCntr < $#testList; $testCntr++ )
{
#print "$testList[$testCntr] \n";
chop( $testList[$testCntr] );
@currField = split( '&', $testList[$testCntr] );
for( 0 .. $#testFields )
{
$currHash{$testFields[$_]} = $currField[$_];
}
#print "$currHash{'ownedby'} - $ownedBy
";
if( ( $currHash{'ownedby'} eq $ownedBy ) || ( $currHash{'ownedby'} eq "" ) )
{
push( @tests, $testList[$testCntr] );
#print "$testList[$testCntr] \n";
}
}
return @tests;
}
#
# Return: Count of test result files in $dir matching regex with $clid
# and $testid, OR -1 if there was an error.
#
sub CountTestFilesByCnd {
my ($dir, $clid, $testid, $cndid) = @_;
if ( ! defined($dir) ) {
&logger::logerr("Undefined directory for client ID '$clid', testid '$testid'");
return -1;
}
if ( ! defined($clid) ) {
&logger::logerr("Undefined client ID for directory '$dir', testid '$testid'");
return -1;
}
if ( ! defined($testid) ) {
&logger::logerr("Undefined test ID for directory '$dir', client ID '$clid'");
return -1;
}
my $tstcount = scalar(get_matching_files($dir, "^$clid".'\.'."$cndid".'\.'."$testid\$"));
return $tstcount;
}
#
# Return: Count of test result files in $dir matching regex with $clid
# and $testid, OR -1 if there was an error.
#
sub CountHistoricTests {
my ($dir, $clid, $testid, $cndid) = @_;
if ( ! defined($dir) ) {
&logger::logerr("Undefined directory for client ID '$clid', testid '$testid'");
return -1;
}
if ( ! defined($clid) ) {
&logger::logerr("Undefined client ID for directory '$dir', testid '$testid'");
return -1;
}
if ( ! defined($testid) ) {
&logger::logerr("Undefined test ID for directory '$dir', client ID '$clid'");
return -1;
}
my $historyfile = join($pathsep,$dir,"$clid.$testid.history");
open (HISTFILE,"<$historyfile") or return 0;
my @histentries = ;
close HISTFILE;
my $sgrepfor=join('&',"\<\<\>\>$clid","$cndid","$testid","");
my @cndidentries = grep( /$sgrepfor/,@histentries);
my $tstcount = $#cndidentries + 1;
return $tstcount;
}
#
# Return: Count of cnd result files in $dir matching regex with $clid
# and $cndid, OR -1 if there was an error.
#
sub CountCndFiles {
my ($dir, $clid, $cndid) = @_;
if ( ! defined($dir) ) {
&logger::logerr("Undefined directory for client ID '$clid', cndid '$cndid'");
return -1;
}
if ( ! defined($clid) ) {
&logger::logerr("Undefined client ID for directory '$dir', cndid '$cndid'");
return -1;
}
if ( ! defined($cndid) ) {
&logger::logerr("Undefined cnd ID for directory '$dir', client ID '$clid'");
return -1;
}
return scalar(get_matching_files($dir, "^$clid".'\.'."$cndid".'\.\S+$'));
}
#
# Return: Sum of times taken during a test in seconds.
#
sub computeTestTime {
my ($dir, $clid, $testid, $cndid, $tstkey) = @_;
if ( ! defined($dir) ) {
&logger::logerr("Undefined directory for client ID '$clid', testid '$testid'");
return -1;
}
if ( ! defined($clid) ) {
&logger::logerr("Undefined client ID for directory '$dir', testid '$testid'");
return -1;
}
if ( ! defined($testid) ) {
&logger::logerr("Undefined test ID for directory '$dir', client ID '$clid'");
return -1;
}
my $timefile = join($pathsep,$dir,"$clid.$cndid.$testid.tim");
open (TLOGFILE,"<$timefile") or return 0;
my @tlogentries = ;
close TLOGFILE;
my $sgrepfor="^$tstkey\&(1)\.(2)\.(.*)\&$clid\&$cndid\&$testid\&(.*)";
my @cndidentries = grep( /$sgrepfor/,@tlogentries);
@tlogentries = ();
my $iidx;
my @tentrycols;
my $tottime;
$tottime = 0;
for $iidx (0 .. $#cndidentries) {
@tentrycols = split(/&/,$cndidentries[$iidx]);
$tottime += $tentrycols[7];
}
@tentrycols = ();
return $tottime;
}
sub formatTimeFromSeconds {
my ($t, $fmt) = @_;
my $h;
my $m;
my $s;
my $r;
my $j;
$m = int($t/60);
$s = $t - ($m * 60);
$h = int($m/60);
$m = $m - ($h * 60);
if ($fmt =~ m/h/i) {
$r = "00000$h";
$j=length($r)-2;
$r = substr($r,$j,2);
$fmt =~ s/h/$r/g;
}
if ($fmt =~ m/m/i) {
$r = "00000$m";
$j=length($r)-2;
$r = substr($r,$j,2);
$fmt =~ s/m/$r/g;
}
if ($fmt =~ m/s/i) {
$r = "00000$s";
$j=length($r)-2;
$r = substr($r,$j,2);
$fmt =~ s/s/$r/g;
}
return $fmt;
}
# Normally xdim was 400 and ydim was 100.
sub BuildBarGraph {
# This subroutine builds the HTML to get an image from an URL.
# The URL is a cgi-bin PERL script, with several parameters.
# The list parameters are: labels, values, and values2.
# The scalar parameters are: xdim, ydim, hbar, title, xlabel, ylabel, ymax, ymin, yticknum, colorscheme, $t_margin, $b_margin, $l_margin, $r_margin
# The first 3 parameters are references to three lists, which are mandatory.
# The values2 list may be an empty list. (and ignored.)
# The rest of the parameters are optional, but are order specific.
# Any parameter that is an empty string will be effectively ignored,
# but may be required to fill the list of parameters to a needed parm.
my @label_names, @value_points, @value2_points ;
my $labels_ref, $values_ref, $values2_ref ;
my $xdim, $ydim, $hbar, $title, $xlabel, $ylabel, $ymax, $ymin, $yticknum ;
my $colorscheme ;
my $t_margin, $b_margin, $l_margin, $r_margin ;
$labels_ref = $_[0] ;
@label_names = @{$labels_ref} ;
# @label_names is an array of character strings of the names of the bars on the graph.
$values_ref = $_[1] ;
@value_points = @{$values_ref} ;
# @value_points is an array of numeric values for each of the names in the first array.
# The sizes of the two arrays should be the same.
$values2_ref = $_[2] ;
@value2_points = @{$values2_ref} ;
shift ; shift ; shift ; # Remove the first 3 parms, to set up the next statement.
my ($xdim, $ydim, $hbar, $title, $xlabel, $ylabel, $ymax, $ymin, $yticknum, $colorscheme, $t_margin, $b_margin, $l_margin, $r_margin) = @_ ;
my $labels, $values, $values2 ;
# print ' label_names ' . "@label_names" . ' ' ;
# print ' value_points ' . "@value_points" . ' ' ;
if ($#label_names != $#value_points) {
print ' ERROR BuildBarGraph has different number of labels and data values. ' ;
}
$labels = join (":", map {munge($_)} @label_names ) ;
$values = join (":", map {munge($_)} @value_points ) ;
$values2 = join (":", map {munge($_)} @value2_points ) ;
# my $baseurl = "/cgi-bin/bargraph.pl?labels=$labels&title=Trust%20Level&ylabel=Respondents";
my $baseurl = "/cgi-bin/bargraph.pl?labels=$labels&values=$values" ;
if ($xdim or $xdim == 0) { $baseurl .= "&xdim=" . $xdim ; }
if ($ydim or $ydim == 0) { $baseurl .= "&ydim=" . $ydim ; }
if ($hbar or $hbar == 0) { $baseurl .= "&hbar=" . $hbar ; }
if ($title or $title == 0) { $baseurl .= "&title=" . munge( $title) ; }
if ($xlabel or $xlabel == 0) { $baseurl .= "&xlabel=" . munge( $xlabel) ; }
if ($ylabel or $ylabel == 0) { $baseurl .= "&ylabel=" . munge( $ylabel) ; }
if ($ymax or $ymax == 0) { $baseurl .= "&ymax=" . $ymax ; }
if ($ymin or $ymin == 0) { $baseurl .= "&ymin=" . $ymin ; }
if ($t_margin or $t_margin == 0) { $baseurl .= "&t_margin=" . $t_margin ; }
if ($b_margin or $b_margin == 0) { $baseurl .= "&b_margin=" . $b_margin ; }
if ($l_margin or $l_margin == 0) { $baseurl .= "&l_margin=" . $l_margin ; }
if ($r_margin or $r_margin == 0) { $baseurl .= "&r_margin=" . $r_margin ; }
if ($colorscheme) { $baseurl .= "&colorscheme=" . $colorscheme ; }
if ($yticknum or $yticknum == 0) { $baseurl .= "&yticknum=" . $yticknum ; }
return "";
}
############################################################################
#
# Function: munge( $string )
# Description: Do the normal munging to replace non-normal chars with %XX.
# Returns: a modified string with %XX patterns inserted
# Author: HBI, 2008/09/30
#
# The process is performed on strings that are sent as literal text,
# as part of an URL to be re-analyzed by a WEB server. The higher
# level application must do this once, and only once. This function
# assumes that the character string contains only 7 or 8 bit characters.
# This function cannot deal with multi-byte UTF-8 characters.
#
############################################################################
sub munge( $ ) {
my ($string) = @_;
$string =~ s/([^a-zA-Z0-9])/join('', '%', uc(unpack("H*",$1)))/eg;
return $string;
}
############################################################################
#
# Function: unmunge( $string )
# Description: Inverse operation of munge(), replace %XX with the real ascii.
# Returns: a modified string with %XX patterns replaced
# Author: efl, 11/2001
#
############################################################################
sub unmunge( $ ) {
my ($string) = @_;
$string =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C",hex($1))/eg;
return $string;
}
sub HTMLHeader {
return "\n\n$_[0]\n".
"\n\n".
"\n";
}
sub HTMLHeaderPlain {
return "\n\n$_[0]\n".
"\n\n".
"\n";
}
sub HTMLFooter {
my $year = `date +%Y`;
my $ionline;
if ($ENV{'SERVER_NAME'} =~ "integroonline.com") {
$ionline = " Copyright (c) $year, Integro Learning Company";
}
return "
Copyright (c) $year, ACTS Corporation$ionline
\n\n";
}
sub ReportChooser {
warn "INFO: ReportChooser Running " ;
my $HBI_Debug_ReportChooser = 0 ;
unless ($SESSION{'clid'}) {
warn "ERROR: No Client ID for the session.\n" ;
&show_illegal_access_warning ;
exit 0 ;
}
&get_client_profile($SESSION{'clid'});
unless (%CLIENT) {
warn "ERROR: No Client Data for the session. " ;
&show_illegal_access_warning ;
exit 0 ;
}
# Links w/javascript for chosing report
# Radio button to choose between all and select group(s)
# Menu box to chose one or more groups
my $groups = &getGroups($CLIENT{'clid'});
if ($HBI_Debug_ReportChooser) {
; # warn Dumper($groups) ;
}
my $js = "function parmsIntegro(oform,rpt) {\n\t".
"oform.reportname.value=rpt;\n\t".
"oform.action='/cgi-bin/creports.pl';\n\t".
"oform.submit();\n};\n";
my $organizationname = $CLIENT{'clnmc'};
my $uberheader;
my $TESTS = get_data_hash ("tests.$CLIENT{'clid'}") ;
if ($HBI_Debug_ReportChooser) {
; # print STDERR Dumper($TESTS) ;
}
my %TESTS = %$TESTS ;
my @test_list = () ;
my $ids ;
for $ids (keys %TESTS) {
# warn "ID $ids DATADESC $TESTS{$ids}->{'desc'} X" ;
push @test_list, [$TESTS{$ids}->{'desc'}, $ids] ;
}
if ($HBI_Debug_ReportChooser) {
warn "test_list count $#test_list X\n" ;
; # print STDERR Dumper(\@test_list) ;
}
my ($js1, $test_choice_html) = ret_test_chooser_mod(@test_list) ;
#print STDERR get_data("tests.$CLIENT{'clid'}");
#print STDERR "Test ID = $tstid\n";
print HTMLHeader("Learning Custom Reports",$js . $js1);
print "