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.
 
 
 
 
 
 

625 lines
28 KiB

#!/usr/bin/perl
#
# $Id: IntegroTeam.pl,v 1.13 2006/04/12 19:18:47 ddoughty Exp $
#
# Source File: Integro.pl
# Get config
use FileHandle;
use Time::Local;
use Data::Dumper;
use IntegroLib;
require 'sitecfg.pl';
require 'testlib.pl';
require 'tstatlib.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 $testinprog $testcomplete $testpending $cgiroot $pathsep $dataroot @rptparams);
&app_initialize;
$FORM{"idlist"} =~ tr/\000/,/ ; # Change separator for multiple values from NULL to comma. HBI
&LanguageSupportInit();
&get_client_profile($SESSION{'clid'});
if ($FORM{'tstid'}) {
&get_test_profile($CLIENT{'clid'}, $FORM{'tstid'});
} elsif (!$rptparams[0]) {
# Check for multiple tests
my @trecs = &get_test_list($CLIENT{'clid'}); #tests in an array
my @tmptrecs = ();
for (1 .. $#trecs) {
my ($id, $desc) = split(/&/, $trecs[$_]); #id=testid, descr=test description
if ($id =~ "^TAQ") {push @tmptrecs, join('&', "$desc", "$id");}
}
@trecs = sort @tmptrecs;
if ($#trecs > 0) {
# show test chooser
&print_test_chooser(@trecs);
}
}
# Make sure we have a valid session, and exit if we don't
if (not &get_session($FORM{'tid'})) {
exit(0);
}
# Get the group filters, if any
my ($idlist,$groups);
if (exists $FORM{'grouping'} and $FORM{'grouping'} eq 'subset') {
#my @tmp = split(/,/,$FORM{'idlist'});
my @tmp = param('idlist');
$FORM{'idlist'} = join(',', @tmp);
@{$groups}{@tmp} = @tmp;
$idlist = &getIdlist($CLIENT{'clid'},$FORM{'idlist'});
}
# Get the time stamp style
my $timestamp;
if ($FORM{'timestamp'} eq 'currenttime') {
$timestamp = scalar(localtime(time));
} elsif ($FORM{"timestamp"} eq 'custom' and $FORM{'customtime'} ne '') {
$timestamp = $FORM{'customtime'};
} elsif ($FORM{'timestamp'} eq 'mostrecent' and $FORM{'tstid'}) {
my $file = join($pathsep,$testcomplete,"$CLIENT{'clid'}.$FORM{'tstid'}.history");
my $fh = new FileHandle;
if ($fh->open($file)) {
my @history = map([split(/(?:<<>>|&)/,$_,4)],<$fh>);
#print "<pre>".Dumper(\@history)."</pre>";
if (defined $idlist) {
foreach (reverse @history) {
if (exists $idlist->{$_->[2]}) {
$timestamp = scalar(localtime(toGMSeconds($_->[0])));
last;
}
}
} else {
$timestamp = scalar(localtime(toGMSeconds($history[$#history]->[0])));
}
} else {
print STDERR "Could not open $file in Integro.pl\n";
}
}
if (defined $timestamp) {
$timestamp = "<font face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"3\"><b>$timestamp</b></font><br><BR>\n";
} else {
$timestamp = "<br>\n";
}
# Is this report for a specific canidate?
my $cndid;
#print STDERR "$FORM{'specificuser'} $FORM{'cndid'}\n";
if ($FORM{'specificuser'} and (not $idlist or $idlist->{$FORM{'cndid'}})) {
$cndid = $FORM{'cndid'};
}
# Generate the reports
if ($FORM{'reportname'} eq 'commeffect') {
&CommEffectReport($idlist, $groups, $timestamp, $cndid);
} elsif ($FORM{'reportname'} eq 'commeffectsummary') {
&CommEffectSummary($idlist, $groups, $timestamp);
} elsif ($FORM{'reportname'} eq 'trustlevel') {
&TrustLevelReport($idlist, $groups, $timestamp, $cndid);
} elsif ($FORM{'reportname'} eq 'trustlevelsummary') {
&TrustLevelSummary($idlist, $groups, $timestamp);
} elsif ($FORM{'reportname'} eq 'comments') {
&CommentsReport($idlist, $timestamp, 0);
} elsif ($FORM{'reportname'} eq 'comments2') {
&CommentsReport($idlist, $timestamp, 1);
} else {
&ReportChooser();
}
# 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 {
my $year = `date +%Y`;
return "<br><center><font face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"1\">Copyright (c) 2004-$year, Integro Leadership Institute<center></font></body>\n</html>\n";
}
sub ReportChooser {
# 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'});
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";
$js .= "\nfunction commIntegro(oform) {\n\t".
"oform.rptid.value='ACT-C-004';\n\t".
"oform.rptdesc.value='Test Statistics by Test'\n\t".
"oform.action='/cgi-bin/IntegroTS.pl';\n\t".
"oform.submit();\n};\n";
my $orgname = $CLIENT{'clnmc'};
my $uberheader;
my $test;
if ($FORM{'tstid'}) {
$test = $FORM{'tstid'};
} elsif ($rptparams[0]) {
$test = $rptparams[0];
} else {
$test = "TAQ01_10";
}
my ($tstid) = grep((/($test\s*)&/ && ($_=$1)),get_data("tests.$CLIENT{'clid'}"));
if (not $tstid) {
print HTMLHeader("Error! No Team Alignment Questionnaire Found.");
print "<h1>Error! No Team Alignment Questionnaire Found.</h1>\n";
print HTMLFooter();
}
my $grplist = getGroups($CLIENT{'clid'});
my @grplist = keys(%$grplist);
my $grplistlen = $#grplist + 2;
$js .= "var groups = new Array($grplistlen)\;\n";
foreach my $grp (@grplist) {
my $gidlist = getIdlist($CLIENT{'clid'}, $grp);
my @gidklist = keys(%$gidlist);
$js .= "groups[\"$grp\"] = [";
foreach my $cnd (@gidklist) {
$js .= "\"$cnd\", ";
}
if ($#gidklist > -1) { $js = substr($js,0,-2); }
$js .= "]\;\n";
$js .= "groups[\"$grp\"] = groups[\"$grp\"].sort()\;\n";
}
$js .= "groups[\"all\"] = [";
my $users = get_users($CLIENT{'clid'},"$tstid");
my @users = keys(%$users);
foreach my $cnd (@users) {
$js .= "\"$cnd\", ";
}
if ($#users + 1) { $js = substr($js,0,-2); }
$js .= "]\;\n";
$js .= "groups[\"all\"] = groups[\"all\"].sort()\;\n";
$js .= "function removeOptions(optionMenu) { \
var oml = optionMenu.options.length; \
for (var i=0; i < oml; i++) { \
optionMenu.remove(0); \
} \
} \
\
function addOptions(optionList, optionMenu) { \
var oml = optionMenu.options.length; \
for (var i=0; i < optionList.length; i++) { \
optionMenu[oml+i] = new Option(optionList[i], optionList[i]); \
} \
} ";
$js .= "function buildGroupList(optionListArray, optionListMenu, optionMenu) {\n\t".
" removeOptions(optionMenu);".
" for (var i=0; i<optionListMenu.options.length; i++) {".
" if (optionListMenu.options[i].selected) {".
" addOptions(optionListArray[optionListMenu.options[i].value], optionMenu);".
" }".
" }".
"};\n";
print HTMLHeader("Team Alignment Reports",$js);
print "<form name=\"integrorpt\" action=\"/cgi-bin/creports.pl\" method=\"Post\" target=\"rptwindow\" enctype=\"multipart/form-data\" >\n";
print "<input type=\"hidden\" name=\"tid\" value=\"$SESSION{'tid'}\">\n";
# For development purposes we hardcode the survey id.
# Fix this before production
print "<input type=hidden name=\"tstid\" value=\"$tstid\">\n";
print "<input type=hidden name=\"rptno\" value=\"$FORM{'rptno'}\">\n";
print "<input type=hidden name=\"rptdesc\" value=\"$REPORT{'rptdesc'}\">\n";
print "<input type=hidden name=\"rptid\" value=\"$REPORT{'rptid'}\">\n";
print "<input type=\"hidden\" name=\"reportname\" value=\"\">\n";
print "<center>\n<table border=\"1\">\n<caption>Team Alignment Reports</Caption>\n".
"<tr><td valign=\"top\"><input type=\"radio\" name=\"grouping\" value=\"all\" checked onClick=\"removeOptions(document.integrorpt.cndid); addOptions(groups['all'], this.form.cndid);\">All Groups</td>\n".
"<td valign=\"top\"><input type=\"radio\" name=\"grouping\" value=\"subset\" onClick=\"buildGroupList(groups, this.form.idlist, this.form.cndid)\">Choose Groups<br>\n".
"<select name=\"idlist\" onchange='this.form.grouping[1].click();' multiple>\n";
foreach (sort {$a->{'grpnme'} cmp $b->{'grpnme'}} values %$groups) {
print "<option value=\"$_->{'grpid'}\">$_->{'grpnme'}</option>\n";
}
print "</td><td valign=\"top\"><input type=\"checkbox\" name=\"specificuser\">Specific User<br>";
print "<select name=\"cndid\" onchange='this.form.specificuser.checked=true;'>\n";
#my $users = get_users($CLIENT{'clid'},"$tstid");
#print map("<option value=\"$_\">$_</option>\n",sort(keys(%$users)));
print "</select></td></tr>\n";
print "<tr><td colspan=\"3\"><table border=0><tr><td>Organization Name:</td><td><input type=\"text\" name=\"orgname\" value=\"$orgname\"></td></tr>\n";
print "<tr><td>Header Override:</td><td><input type=\"text\" name=\"uberheader\" value=\"$uberheader\"></td></tr></table></tr></td>\n";
print "<tr><td colspan=\"3\">Time Stamp:<ul style=\"list-style: none\">".
"<li><input type=\"radio\" name=\"timestamp\" value=\"mostrecent\" checked>Most Recent Survey Taken</li>".
"<li><input type=\"radio\" name=\"timestamp\" value=\"currenttime\">Current Time</li>".
"<li><input type=\"radio\" name=\"timestamp\" value=\"custom\">Custom Value: ".
"<input type=\"text\" name=\"customtime\"></li></tr></td>";
print "</table></center>\n";
print "<hr>\n";
print "<input type=\"checkbox\" name=\"pdf\">Display reports as PDF\n";
print "<p> <ul style=\"list-style: none\"><li><a href=\"javascript:parmsIntegro(document.integrorpt,'trustlevel');\">Team Trust Level Report</a></li>".
"<!--<li><a href=\"javascript:parmsIntegro(document.integrorpt,'trustlevelsummary');\">Team Trust Level Summary</a></li>--></ul></p>\n";
print "<p><ul style=\"list-style: none\"><li><a href=\"javascript:parmsIntegro(document.integrorpt,'commeffect');\">Team Alignment Report</a></li>".
"<!--<li><a href=\"javascript:parmsIntegro(document.integrorpt,'commeffectsummary');\">Team Alignment Summary</a></li>--></ul></p>\n";
print "<p>General Reports<ul style=\"list-style: none\"><li><a href=\"javascript:parmsIntegro(document.integrorpt,'comments');\">Comments</a></li>";
print "<li><a href=\"javascript:parmsIntegro(document.integrorpt,'comments2');\">Comments by Category</a></li>";
print "<input type=hidden name=\"testsummary\" value=\"composite\">\n";
print "<input type=hidden name=\"showcmts\" value=\"donot\">\n";
#my $commurl = "/cgi-bin/teststats.pl?tstid=SAS01".
# "&tid=$FORM{'tid'}&rptid=ACT-C-004&rptdesc=Test%20Statistics%20by%20Test".
# "&testsummary=composite&showcmts=donot";
print "<li><a href=\"javascript:commIntegro(document.integrorpt);\">Question Statistics</a></li></p>\n";
print "</form>";
print "<script language=\"JavaScript\">\n<!-- \n";
print "if (document.integrorpt.grouping[0].checked) { addOptions(groups['all'], document.integrorpt.cndid);} else { buildGroupList(groups, document.integrorpt.idlist, document.integrorpt.cndid)}";
print "\n -->\n</script>\n";
print HTMLFooter();
}
# Also known as the Group Alignment report
sub CommEffectReport {
my ($idlist,$groups,$timestamp,$cndid) = @_;
my $data = &CommEffectData($CLIENT{'clid'},$TEST{'id'},$idlist,$groups);
my $user;
if ($cndid) {$user = &CommEffectData($CLIENT{'clid'},$TEST{'id'},{$cndid => 1},$groups);&get_candidate_profile($CLIENT{'clid'},$cndid);}
my $claritysum = $data->{'organization'}->{'claritysum'};
my $approvalsum = $data->{'organization'}->{'approvalsum'};
my $histograms = $data->{'organization'}->{'histogram'};
print HTMLHeaderPlain("Team Alignment Report");
print "<Center><font face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"5\"><b>Team Alignment Questionnaire<br>Team Alignment Report </b><br>$CANDIDATE{'sal'} $CANDIDATE{'nmf'} $CANDIDATE{'nmm'} $CANDIDATE{'nml'}</font><br>\n";
print "<font face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"4\"><b>The Degree to which Team Members are in Alignment</b></font><br>\n";
print "<font face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"3\"><b>$FORM{'orgname'}</b></font><br>\n";
if ($FORM{'uberheader'} ne "") {
print "<font face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"3\"><b>".$FORM{'uberheader'}."</b></font><br>\n";
} elsif (defined $idlist) {
my $groups = getGroups($CLIENT{'clid'});
print "<font face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"3\"><b>Groups: "
.join(", ",map($groups->{$_}->{'grpnme'},split(/,/,$FORM{'idlist'})))."</b></font><br>\n";
} else {
#print "<font face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"3\"><b>Organization-wide Report</b></font><br>\n";
print "<font face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"3\"><b></b></font><br>\n";
}
print $timestamp;
print "<font face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"1\"><b><table border><tr><th>&nbsp;&nbsp;&nbsp;&nbsp;</th><th><font face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"1\"><b>Very Unclear</b></font></th><th>&nbsp;&nbsp;&nbsp;&nbsp;</th>".
"<th><font face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"1\"><b>Moderately Unclear</b></font></th><th>&nbsp;&nbsp;&nbsp;&nbsp;</th><th><font face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"1\"><b>Moderately Clear</b></font></th>".
"<th>&nbsp;&nbsp;&nbsp;&nbsp;</th><th><font face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"1\"><b>Very Clear</b></font></th><th><font face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"1\"><b>Team Clarity</b></font></th>".
"<th><font face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"1\"><b>Team Approval</b></font></th></tr>\n";
# fill in the rows
my $overall = {'clarity' => 0, 'approval' => 0};
foreach my $row (qw(Purpose Values Vision Goals Procedures Roles)) {
print "<tr><th>$row</th>";
for my $i (0..6) {
print "<td align=\"center\">";
if ($histograms->{$row}->{'Clarity'}->[$i]) {
if ($histograms->{$row}->{'Approval'}->[$i]->[2]) {
my $img = "/graphic/face-smile.gif";
if ($user and $user->{'organization'}->{'histogram'}->{$row}->{'Approval'}->[$i]->[2]) {
$img = "/graphic/face-smile-green.gif";
}
print "<img src=\"$img\"><sub>$histograms->{$row}->{'Approval'}->[$i]->[2]</sub><br>";
}
if ($histograms->{$row}->{'Approval'}->[$i]->[1]) {
my $img = "/graphic/face-red.gif";
if ($user and $user->{'organization'}->{'histogram'}->{$row}->{'Approval'}->[$i]->[1]) {
$img = "/graphic/face-red-green.gif";
}
print "<img src=\"$img\"><sub>$histograms->{$row}->{'Approval'}->[$i]->[1]</sub><br>";
}
if ($histograms->{$row}->{'Approval'}->[$i]->[0]) {
my $img = "/graphic/face-blue.gif";
if ($user and $user->{'organization'}->{'histogram'}->{$row}->{'Approval'}->[$i]->[0]) {
$img = "/graphic/face-blue-green.gif";
}
print "<img src=\"$img\"><sub>$histograms->{$row}->{'Approval'}->[$i]->[0]</sub>";
}
} else {
print "&nbsp;";
}
print "</td>";
}
printf "<td align=\"center\">%.1f %%</td>\n", $claritysum->{$row}->{'value'};
printf "<td align=\"center\">%.1f %%</td>\n", $approvalsum->{$row}->{'value'};
print "</tr>\n";
}
print "</table>\n<p>Position = Team Clarity</p>\n<p>Countenance = Personal Approval</p>\n";
#print "<table border><caption><b>Overall Team Alignment</b></caption>\n";
#printf "<tr><th>Clarity</th><td>%.1f %%</td></tr>\n", $data->{'organization'}->{'overallclarity'};
#printf "<tr><th>Approval</th><td>%.1f %%</td></tr>\n", $data->{'organization'}->{'overallapproval'};
#print "</table></b></font>\n";
print HTMLFooter();
}
sub CommEffectSummary {
my ($idlist,$groups,$timestamp) = @_;
my $data = &CommEffectData($CLIENT{'clid'},$TEST{'id'},$idlist,$groups);
$groups = getGroups($CLIENT{'clid'});
print HTMLHeaderPlain("Team Alignment Summary");
print "<Center><font face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"5\"><b>Team Alignment Questionnaire<br>Team Alignment Summary</i></b></font><br><br>\n";
print "<font face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"4\"><b>The degree to which Employees are Aligned with the Organization</b></font><br>\n";
print "<font face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"3\"><b>$FORM{'orgname'}</b></font><br>\n";
if (defined $idlist) {
my $groups = getGroups($CLIENT{'clid'});
print "<font face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"3\"><b>Summary for Groups: "
.join(", ",map($groups->{$_}->{'grpnme'},split(/,/,$FORM{'idlist'})))."</b></font><br>\n";
} else {
#print "<font face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"3\"><b>Organization-wide Report</b></font><br>\n";
print "<font face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"3\"><b></b></font><br>\n";
}
print $timestamp;
print "<font face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"1\"><b><table border>\n";
print "<tr><td>&nbsp;</th><th>Clarity</th><th>Approval</th></tr>\n";
print "<tr><td>Overall</td>";
printf "<td>%.1f %%</td>",$data->{'organization'}->{'overallclarity'};
printf "<td>%.1f %%</td></tr>\n", $data->{'organization'}->{'overallapproval'};
if (exists $data->{'groups'}) {
print "<tr><th colspan=3 align=\"left\">Group Breakdown</th></tr>\n";
print "<tr><th>Group</th><th>Clarity</th><th>Approval</th></tr>\n";
foreach my $grp (sort keys %{$data->{'groups'}}) {
print "<tr><td>$groups->{$grp}->{'grpnme'}</td>";
printf "<td>%.1f %%</td>", $data->{'groups'}->{$grp}->{'overallclarity'};
printf "<td>%.1f %%</td></tr>\n", $data->{'groups'}->{$grp}->{'overallapproval'};
}
}
print "</table></b></font>\n";
print HTMLFooter();
}
sub TrustLevelReport {
my ($idlist,$groups,$timestamp,$cndid) = @_;
my $data = &TrustLevelData($CLIENT{'clid'},$TEST{'id'},$idlist,$groups);
my $user;
if ($cndid) {$user = &TrustLevelData($CLIENT{'clid'},$TEST{'id'},{$cndid => 1},$groups);&get_candidate_profile($CLIENT{'clid'},$cndid);}
my $histograms = $data->{'organization'}->{'histogram'};
my $trust = $data->{'organization'}->{'trust'};
print HTMLHeaderPlain("Team Trust Level Report");
print "<center><font face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"5\"><b>Team Alignment Questionnaire<br>Team Trust Level Report</b><br>$CANDIDATE{'sal'} $CANDIDATE{'nmf'} $CANDIDATE{'nmm'} $CANDIDATE{'nml'} </font><br>\n";
print "<font face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"4\"><b>The level of Trust Building behaviors</b></font><br>\n";
print "<font face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"3\"><b>$FORM{'orgname'}</b></font><br>\n";
if ($FORM{'uberheader'} ne "") {
print "<font face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"3\"><b>".$FORM{'uberheader'}."</b></font><br>\n";
} elsif (defined $idlist) {
my $groups = getGroups($CLIENT{'clid'});
print "<font face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"3\"><b>Groups: "
.join(", ",map($groups->{$_}->{'grpnme'},split(/,/,$FORM{'idlist'})))."</b></font><br>\n";
} else {
#print "<font face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"3\"><b>Organization-wide Report</b></font><br>\n";
print "<font face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"3\"><b></b></font><br>\n";
}
print $timestamp;
print "<font face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"1\"><b><table border=\"1\"><tr><th>&nbsp;</th><th>&nbsp;</th><th>Team Trust Level</th></tr>\n";
my $baseurl;
if (defined($ENV{'SSL_PROTOCOL'})) {
$baseurl = "https://";
} else {
$baseurl = "http://";
}
$baseurl .= $ENV{'HTTP_HOST'};
$baseurl .= "/cgi-bin/bargraph.pl?labels=Low::::Medium::::High&title=Trust%20Level&ylabel=Respondents";
$baseurl .= "&xdim=500&ydim=150";
foreach my $row (qw(Congruence Openness Acceptance Reliability)) {
my $url;
if (not $user) {
$url = "$baseurl&values=".join(":",@{$histograms->{$row}});
} else {
my (@values,@values2);
for (my $i=0; $i < @{$histograms->{$row}}; $i++) {
if ($user->{'organization'}->{'histogram'}->{$row}->[$i]) {
push @values ,'';
push @values2 , $histograms->{$row}->[$i];
} else {
push @values2 ,'';
push @values , $histograms->{$row}->[$i];
}
}
$url = "$baseurl&values=".join(":",@values)."&values2=".join(":",@values2);
}
print "<tr><th>$row</th>";
print "<td><img src=\"$url\"></td>";
printf "<td align=\"center\">%.1f%% </td></tr>\n", $trust->{$row}->{'value'};
}
print "</table></b></font>\n";
#printf "<P><font face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"2\"><b>Overall Team Level of Trust</b></font> = %.1f %%.</p>\n",$data->{'organization'}->{'overalltrust'};
print HTMLFooter();
}
sub TrustLevelSummary {
my ($idlist,$groups,$timestamp) = @_;
my $data = TrustLevelData($CLIENT{'clid'},$TEST{'id'},$idlist,$groups);
$groups = getGroups($CLIENT{'clid'});
print HTMLHeaderPlain("Team Trust Level Summary");
print "<Center><font face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"5\"><b>Team Alignment Questionnaire<br>Team Trust Level Summary</b></font><br><br>\n";
print "<font face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"4\"><b>The level of Trust Building behaviors</b></font><br>\n";
print "<font face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"3\"><b>$FORM{'orgname'}</b></font><br>\n";
if ($FORM{'uberheader'} ne "") {
print "<font face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"3\"><b>".$FORM{'uberheader'}."</b></font><br>\n";
} elsif (defined $idlist) {
my $groups = getGroups($CLIENT{'clid'});
print "<font face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"3\"><b>Summary for Groups: "
.join(", ",map($groups->{$_}->{'grpnme'},split(/,/,$FORM{'idlist'})))."</b></font><br>\n";
} else {
#print "<font face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"3\"><b>Organization-wide Summary</b></font><br>\n";
print "<font face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"3\"><b></b></font><br>\n";
}
print $timestamp;
print "<font face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"1\"><b><table border>\n";
print "<tr><td>&nbsp;</th><th>Team Trust Level</th></tr>\n";
print "<tr><td>Overall</td>";
printf "<td>%.1f %%</td></tr>\n", $data->{'organization'}->{'overalltrust'};
if (exists $data->{'groups'}) {
print "<tr><th colspan=2 align=\"left\">Group Breakdown</th></tr>\n";
print "<tr><th>Group</th><th>Team Trust Level</th></tr>\n";
foreach my $grp (sort keys %{$data->{'groups'}}) {
print "<tr><td>$groups->{$grp}->{'grpnme'}</td>";
printf "<td>%.1f %%</td></tr>\n", $data->{'groups'}->{$grp}->{'overalltrust'};
}
}
print "</table></b></font>\n";
print HTMLFooter();
}
sub CommentsReport {
my ($idlist, $timestamp, $bycat) = @_;
my @filelist = &get_test_result_files($testcomplete, $CLIENT{'clid'},$TEST{'id'});
my @comments;
for (my $i=0; $i<=59; $i++) {$comments[$i] = [];}
my @questions = map([split(/&/,$_)],&get_question_list($TEST{'id'},$CLIENT{'clid'}));
foreach (@questions) {$_->[4] =~ s/:::.*$//;}
foreach my $file (@filelist) {
my $user = $file;
$user =~ s/.$TEST{'id'}$//;
$user =~ s/^$CLIENT{'clid'}.//;
if (defined $idlist and not $idlist->{$user}) {
next;
}
my ($answers,$usercomm) = &get_survey_results( $CLIENT{'clid'}, $user, $TEST{'id'});
for (my $i=1; $i<=58; $i++) {
if ($usercomm->[$i] == -1) {
$comments[$i] = -1;
} elsif ($usercomm->[$i]) {
push @{$comments[$i]},$usercomm->[$i];
warn "HBI user $user file $file index $i comment $usercomm->[$i] " ;
}
}
if ($answers->[59]) {
push @{$comments[59]},$answers->[59];
warn "HBI user $user file $file index set 59 comment $usercomm->[59] " ;
}
}
print HTMLHeaderPlain("Comments Report");
print "<center><font face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"5\"><b>Team Alignment Questionnaire<br>Comments Report</b></font><br><br>\n";
print "<font face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"3\"><b>$FORM{'orgname'}</b></font><br>\n";
if ($FORM{'uberheader'} ne "") {
print "<font face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"3\"><b>".$FORM{'uberheader'}."</b></font><br>\n";
} elsif (defined $idlist) {
my $groups = getGroups($CLIENT{'clid'});
print "<font face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"3\"><b>Groups: "
.join(", ",map($groups->{$_}->{'grpnme'},split(/,/,$FORM{'idlist'})))."</b></font><br>\n";
} else {
#print "<font face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"3\"><b>Organization-wide Report</b></font><br>\n";
print "<font face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"3\"><b></b></font><br>\n";
}
print $timestamp;
print "</center>\n";
print "<blockquote>\n";
my @outary = ();
for (my $i=1; $i <=40; $i++) {
if ($comments[$i] == -1) {
# inactive question
next;
}
$outary[$i] = "<hr width=\"100%\"><font face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"2\"><b>\n";
$outary[$i] .= "$questions[$i]->[0] - $questions[$i]->[4]<p>\n";
if (@{$comments[$i]}) {
$outary[$i] .= "<ul>\n";
foreach (@{$comments[$i]}) {
$outary[$i] .= "<li>$_</li>\n";
}
$outary[$i] .= "</ul>\n";
} else {
$outary[$i] .= "<ul><li><small><i>No Comments</i></small></li></ul>\n";
}
$outary[$i] .= "</b></font>\n";
}
# Read in .rgo file which defines question presentation order
my $out;
my $lookupfile = join($pathsep,$dataroot,"IntegroTAQ.rgo");
if ($bycat && -e $lookupfile) {
my $fh = new FileHandle;
if ($fh->open($lookupfile)) {
$out = "";
my @lines = <$fh>;
$fh->close();
shift @lines;
foreach (@lines) {
chomp;
my @line = split(/\&/,$_);
my $section = shift @line;
if ($section ne "") {
$out .= "<tr><td colspan=6><hr width=\"100\%\"></td></tr>\n";
$out .= "<tr><td colspan=6><font size=+1><b>$section</b></font></td></tr>\n";
}
foreach my $sub (@line) {
my ($subheader, $quess) = split(/:/,$sub);
if ($subheader ne "") {
$out .= "<hr width=100%><tr><td colspan=6><b>$subheader:</b></td></tr>\n";
}
my @ques = split(/\,/,$quess);
foreach my $quesid (@ques) {
$out .= $outary[$quesid];
}
}
}
print $out;
}
} else {
for (1 .. $#outary) {
print $outary[$_];
}
}
print "<hr width=\"100%\">\n";
print "</blockquote>\n";
#print "<pre>".Dumper(\@questions,\@comments)."</pre>\n";
print "<center>".HTMLFooter();
}
sub print_test_chooser {
my @trecs = @_;
my ($testscompleted, $testsinprogress, $testspending, $href, $tstoption, $tstoptions);
my $js = "function setTest(oform,test) {\n\t".
"oform.tstid.value=test;\n\t".
"oform.submit();\n};\n";
for (0 .. $#trecs) {
my ($desc,$id) = split(/&/, $trecs[$_]);
$testscompleted = CountTestFiles($testcomplete,$CLIENT{'clid'},$id);
$testsinprogress = CountTestFiles($testinprog, $CLIENT{'clid'},$id);
$testspending = CountTestFiles($testpending, $CLIENT{'clid'},$id);
$href="javascript:setTest(document.testform1,\'$id\')\;";
$tstoption =" <TR>
<TD valign=top><FONT SIZE=2><a href=\"$href\">$id</a></FONT></TD>
<TD valign=top><FONT SIZE=2>$desc</FONT></TD>
<TD align=right valign=top><FONT SIZE=2>$testscompleted</FONT></TD>
<TD align=right valign=top><FONT SIZE=2>$testsinprogress</FONT></TD>
<TD align=right valign=top><FONT SIZE=2>$testspending</FONT></TD>
</TR>\n";
$tstoptions = join('', $tstoptions, $tstoption);
}
print HTMLHeader("Integro Learning Custom Reports", $js);
print "<CENTER><B>Please choose the survey for which you would like reports:</B><br>
<form name=\"testform1\" action=\"/cgi-bin/creports.pl\" method=\"Post\">
<input type=\"hidden\" name=\"tid\" value=\"$SESSION{'tid'}\">
<input type=\"hidden\" name=\"tstid\" value=\"\">
<input type=hidden name=\"rptno\" value=\"$FORM{'rptno'}\">
</form>
<TABLE cellpadding=1 cellspacing=1 border=0 width=\"100\%\">
<TR><TD colspan=5><HR WIDTH=\"100\%\"></TD></TR>
<TR>
<TD valign=top><B><FONT SIZE=1>Test ID</FONT></B></TD>
<TD valign=top><B><FONT SIZE=1>Description</FONT></B></TD>
<TD align=right valign=top><B><FONT SIZE=1>Cmp</FONT></B></TD>
<TD align=right valign=top><B><FONT SIZE=1>InP</FONT></B></TD>
<TD align=right valign=top><B><FONT SIZE=1>Pnd</FONT></B></TD>
</TR>
<TR><TD colspan=5><HR WIDTH=\"100\%\"></TD></TR>
$tstoptions
<TR><TD colspan=5><HR WIDTH=\"100\%\"></TD></TR>
</TABLE>
";
print HTMLFooter();
exit();
}