home *** CD-ROM | disk | FTP | other *** search
/ bombers.k12.ar.us / bombers.k12.ar.us.tar / bombers.k12.ar.us / survey_unconfigured / ResultsOverview.asp < prev    next >
Text File  |  2006-10-25  |  84KB  |  1,904 lines

  1. <!--#Include File="Include/Top_inc.asp"-->
  2. <%
  3. '***********************************************************************
  4. '   Application: SelectSurveyASP Advanced v8.1.11
  5. '   Author: Aaron Baril for ClassApps.com
  6. '   Page Description: This page is the top-level report for each survey.
  7. '
  8. '   COPYRIGHT NOTICE
  9. '
  10. '   See attached Software License Agreement
  11. '
  12. '   (c) Copyright 2002 - 2006 by ClassApps.com.  All rights reserved.
  13. '***********************************************************************
  14.  
  15. %>
  16. <!--#Include File="Include/Config_inc.asp"-->
  17. <!--#Include File="Include/SurveyUtility_inc.asp"-->
  18. <!--#Include File="Include/Utility_inc.asp"-->
  19. <!--#Include File="Include/adovbs_inc.asp"-->
  20. <!--#Include File="Include/CurrentUser_inc.asp"-->
  21. <!--#Include File="Include/Constants_inc.asp"-->
  22. <!--#Include File="Include/Collection_inc.asp"-->
  23. <!--#Include File="Include/SurveySecurity_inc.asp"-->
  24. <!--#Include File="Include/ReportShare_inc.asp"-->
  25. <!--#Include File="Include/SurveyReportFilter_inc.asp"-->
  26. <%
  27.  
  28. On Error Resume Next
  29.  
  30. 'set objError = Server.GetLastError()
  31. 'response.write objError.Description
  32.  
  33.  
  34.     'If the report share security ID is being passed to the page, save it and get the survey ID from it.  Otherwise,
  35.     'if there is a report share security in session, extract the survey ID from that.  Finally, if neither of those cases
  36.     'is valid, extract the survey ID from the querystring.
  37.     If Len(Request.QueryString("SID")) > 0 Then
  38.         lngSurveyID = CreateReportShareSessionString(Request.QueryString("SID"))
  39.  
  40.         'If report sharing is disabled for this survey, redirect to the access denied page
  41.         If IsReportSharingEnabled(lngSurveyID) = False Then
  42.             Response.Redirect "AccessDenied.asp?SurveyID=" & lngSurveyID & "&Reason=" & SUR_ACCESS_DENIED_REPORT_SHARING_DISABLED
  43.         End If
  44.     ElseIf Len(Session(SUR_REPORT_SHARE_SESSION_STRING)) > 0 Then
  45.         'Get the survey ID from the report sharing session information
  46.         lngSurveyID = CLng(GetValueFromReportShareSessionString(SUR_REPORT_SHARE_FIELD_SURVEY_ID))
  47.     Else
  48.         lngSurveyID = Request.QueryString("SurveyID")
  49.     End If
  50.  
  51.     'If the viewable reports are none because the share is inactive, redirect to the access denied page with an
  52.     'appropriate error.
  53.     If GetValueFromReportShareSessionString(SUR_REPORT_SHARE_FIELD_VIEWABLE_REPORTS) = SUR_VIEWABLE_REPORT_NONE Then
  54.         Response.Redirect "AccessDenied.asp?SurveyID=" & lngSurveyID & "&Reason=" & SUR_ACCESS_DENIED_REPORT_SHARE_INACTIVE
  55.     End If
  56.  
  57.     'Check to see if the user can view the overview results report.
  58.     If CanUserViewOverviewReport(lngSurveyID) = False Then
  59.         Response.Redirect "AccessDenied.asp?SurveyID=" & lngSurveyID & "&Reason=" & SUR_ACCESS_DENIED_NOT_PERMISSION_TO_VIEW_REPORT
  60.     End If
  61.  
  62.     Dim strSQL
  63.     Dim lngSurveyID
  64.     Dim lngQuestionNumber
  65.     Dim strItemText
  66.     Dim i
  67.     Dim lngItemID
  68.     Dim lngItemTypeID
  69.     Dim strOtherText
  70.     Dim lngTextResponseCount
  71.     Dim strAnswersCollection
  72.     Dim strUniqueRespondentsPerAnswerCollection
  73.     Dim strAnswerIDsCollection
  74.     Dim rsSurvey
  75.     Dim rsQuestions
  76.     Dim rsAnswers
  77.     Dim strTemp
  78.     Dim rsSubItems
  79.     Dim rsDisplayFilter
  80.     Dim lngResponseCount
  81.     Dim vaAnswers
  82.     Dim flgOther
  83.     Dim strTitle
  84.     Dim lngTotalRespondents
  85.     Dim lngFilteredRespondents
  86.     Dim lngSkippedTotal
  87.     Dim lngColspanCount
  88.     Dim lngNumberTotal
  89.     Dim lngAnswerCount
  90.     Dim lngCurrentResponseID
  91.     Dim lngCurrentSubItemID
  92.     Dim lngRowTotal
  93.     Dim lngRowAverage
  94.     Dim lngBeginningNumber
  95.     Dim lngEndingNumber
  96.     Dim lngPercentage
  97.     Dim lngHighestAverage
  98.     Dim lngTemp
  99.     Dim strReportFilters
  100.     Dim strQuestionNumberingFormat
  101.     Dim lngCurrentItemNumber
  102.     Dim strSelected
  103.     Dim strItemAlias
  104.     Dim lngReportFilterCount
  105.     Dim lngUniqueRespondentCount
  106.     Dim lngTotalPoints
  107.     Dim flgHighlightResponses
  108.     Dim rsHighlightResponses
  109.     Dim strHighlightResponses
  110.     Dim lngResponseID
  111.  
  112.     'Initialization
  113.     Set rsSurvey = Server.CreateObject("ADODB.Recordset")
  114.     Set rsSubItems = Server.CreateObject("ADODB.Recordset")
  115.     Set rsQuestions = Server.CreateObject("ADODB.Recordset")
  116.     Set rsAnswers = Server.CreateObject("ADODB.Recordset")
  117.     Set rsDisplayFilter = Server.CreateObject("ADODB.Recordset")
  118.     lngQuestionNumber = 1
  119.  
  120.     'Get general information about the survey
  121.     strSQL = "SELECT title, response_count, question_numbering_format, launched_date, closed_date, " & _
  122.              "status, highlight_responses_yn, report_sharing_enabled_yn " & _
  123.              "FROM sur_survey " & _
  124.              "WHERE survey_id  = " & lngSurveyID
  125.  
  126.     rsSurvey.Open ConvertSQL(strSQL), SURVEY_APP_CONNECTION, adOpenDynamic, , adCmdText
  127.     rsSurvey.MoveFirst
  128.     strTitle = rsSurvey("title")
  129.     lngTotalRespondents = CLng(rsSurvey("response_count"))
  130.     lngFilteredRespondents = GetFilteredRespondentCount(lngSurveyID)
  131.  
  132.     strQuestionNumberingFormat = rsSurvey("question_numbering_format")
  133.  
  134.  
  135.     'If the user's responses should be highlighted, check to see if the user has taken the survey. If so,
  136.     'select all of the user's responses.
  137.     If rsSurvey("highlight_responses_yn") = SUR_BOOLEAN_POSITIVE Then
  138.         'Get the response ID for this user from the cookie
  139.         lngResponseID = Request.Cookies(SUR_APPLICATION_COOKIE)(SUR_COOKIE_SURVEY & Request.ServerVariables("REMOTE_ADDR") & lngSurveyID)
  140.  
  141.         'If there is no response ID, do not highlight responses
  142.         If Len(lngResponseID) = 0 Then
  143.             flgHighlightResponses = False
  144.         Else
  145.             flgHighlightResponses = True
  146.  
  147.             'Create a recordset of the responses for this user's response
  148.             Set rsHighlightResponses = Server.CreateObject("ADODB.Recordset")
  149.             strSQL = "SELECT answer_id, subitem_id, item_id, answer_text, other_text " & _
  150.                      "FROM sur_response_answer " & _
  151.                      "WHERE response_id = " & lngResponseID
  152.             rsHighlightResponses.Open ConvertSQL(strSQL), SURVEY_APP_CONNECTION, adOpenDynamic, , adCmdText
  153.  
  154.             'Create a string with all of the user's responses in it.  This string is used for comparisons later on.
  155.             strHighlightResponses = "|"
  156.             If Not rsHighlightResponses.EOF Then
  157.                 Do While Not rsHighlightResponses.EOF
  158.                     If Len(rsHighlightResponses("answer_id")) > 0 And IsNull(rsHighlightResponses("answer_id")) = False And rsHighlightResponses("answer_id") > 0 Then
  159.                         strTemp = strTemp & "AnswerID" & rsHighlightResponses("answer_id")
  160.                     End If
  161.                     If Len(rsHighlightResponses("subitem_id")) > 0 And IsNull(rsHighlightResponses("subitem_id")) = False And rsHighlightResponses("subitem_id") > 0 Then
  162.                         strTemp = strTemp & "SubItemID" & rsHighlightResponses("subitem_id")
  163.                     End If
  164.                     If rsHighlightResponses("answer_text") = SUR_ANSWER_TEXT_OTHER_SELECTED Then
  165.                         strTemp = strTemp & "ItemID" & rsHighlightResponses("item_id") & SUR_ANSWER_TEXT_OTHER_SELECTED
  166.                     Else
  167.                         If rsHighlightResponses("answer_text") <> SUR_ANSWER_TEXT_NULL Then
  168.                             strTemp = strTemp & "ItemID" & rsHighlightResponses("item_id") & rsHighlightResponses("answer_text")
  169.                         End If
  170.                     End If
  171.                     strHighlightResponses = strHighlightResponses & strTemp & "|"
  172.                     strTemp = ""
  173.                     rsHighlightResponses.MoveNext
  174.  
  175.                 Loop
  176.             End If
  177.  
  178.             'Clean up
  179.             rsHighlightResponses.Close
  180.             Set rsHighlightResponses = Nothing
  181.         End If
  182.     Else
  183.         flgHighlightResponses = False
  184.     End If
  185.  
  186. %>
  187.  
  188. <html>
  189. <head>
  190.     <title>Survey Results -- Overview</title>
  191.     <link rel="stylesheet" href="Resources/StyleSheet/SurveyStyle.css">
  192. </head>
  193.  
  194. <script language="JavaScript">
  195. function displayFilterSelected()
  196. {
  197.     document.forms['frmDisplayFilter'].submit();
  198. }
  199. </script>
  200.  
  201. <body class="MainBodyStyle">
  202.  
  203. <!--#Include File="Include/FrameworkTop_inc.asp"-->
  204.  
  205. <table border="0" cellspacing="0" cellpadding="0" width="754" class="MediumBlueBackgroundColor">
  206.     <tr>
  207.         <td height="36" valign="center">
  208.               <span class="H1HeadingStyle"><a name="skipnav" tabindex="1">Survey Results -- Overview</a></span>
  209.         </td>
  210.         <td valign="middle" align="right">
  211. <%
  212.             'Only display the buttons if there are results that matched the filter criteria
  213.             If lngFilteredRespondents > 0 Then
  214.                 'Display the Export Data button if the user is the owner or is an admin or if the user has been granted
  215.                 'export data permission via report sharing
  216.                 If IsUserOwnerOrAdmin(lngSurveyID) = True Then
  217. %>
  218.                     <a href="ExportData.asp?DisplayHeader=<%=SUR_HEADER_DISPLAY_ON%>&SurveyID=<%=lngSurveyID%>&SurveyName=<%=strTitle%>"><img border="0" alt="Export data to a CSV or Excel" name="btnExportData" src="Resources/Buttons/ExportData.gif"></a>
  219. <%
  220.                 ElseIf GetValueFromReportShareSessionString(SUR_REPORT_SHARE_FIELD_EXPORT_DATA) = SUR_BOOLEAN_POSITIVE Then
  221. %>
  222.                     <a href="ExportData.asp?DisplayHeader=<%=SUR_HEADER_DISPLAY_ON%>&SID=<%=Request.QueryString("SID")%>&SurveyID=<%=lngSurveyID%>&SurveyName=<%=strTitle%>"><img border="0" alt="Export data to a CSV or Excel" name="btnExportData" src="Resources/Buttons/ExportData.gif"></a>
  223. <%
  224.                 End If
  225.  
  226.                 'Display the button to the individual reports if the user has permission to view them
  227.                 If Len(Request.QueryString("SID")) > 0 Then
  228. %>
  229.                     <a href="ResultsIndividual.asp?DisplayHeader=<%=Request.QueryString("DisplayHeader")%>&SID=<%=Request.QueryString("SID")%>&SurveyID=<%=lngSurveyID%>"><img border="0" alt="View individual results for this survey" name="btnIndividualResponses" src="Resources/Buttons/IndividualResponses.gif"></a>
  230. <%
  231.                 ElseIf CanUserViewIndividualReport(lngSurveyID) = True Then
  232. %>
  233.                     <a href="ResultsIndividual.asp?DisplayHeader=<%=Request.QueryString("DisplayHeader")%>&SurveyID=<%=lngSurveyID%>"><img border="0" alt="View individual results for this survey" name="btnIndividualResponses" src="Resources/Buttons/IndividualResponses.gif"></a>
  234. <%
  235.                 End If
  236.             End If
  237.  
  238. %>
  239.         </td>
  240.         <td width="7"></td>
  241.     </tr>
  242. </table>
  243.  
  244. <!--#Include File="Include/FrameworkTop2_inc.asp"-->
  245.  
  246. <table width="740" border="0" cellpadding="0" cellspacing="0" class="WhiteBackgroundColor">
  247. <form name="frmDisplayFilter" action="ResultsOverview.asp?SurveyID=<%=lngSurveyID%>&DisplayHeader=<%=Request.QueryString("DisplayHeader")%>" method="POST">
  248.     <tr>
  249.         <td width="740">
  250.             <table border="0" width="740" cellpadding="4" cellspacing="0" class="WhiteBackgroundColor">
  251.                 <tr class="LightGrayBackgroundColor">
  252.                     <td width="1"></td>
  253.                     <td colspan="3" align="left" height="36" valign="center">
  254.                         <span class="H2HeadingStyle"><%=strTitle%></span>
  255.                     </td>
  256.                     <td colspan="2" align="right" valign="top">
  257. <%
  258.                         If flgHighlightResponses = True Then
  259. %>
  260.                             <table border="0" cellspacing="0" cellpadding="0" width="160">
  261.                                 <tr>
  262.                                     <td width="50" align="right">
  263.                                         <img alt="You submitted this response" border="0" src="<%=SUR_HIGHLIGHT_RESPONSES_IMAGE_PATH%>"> 
  264.                                     </td>
  265.                                     <td width="110" align="left" valign="middle">
  266.                                         <span class="Normal">
  267.                                              = Your Response
  268.                                         </span>
  269.                                     </td>
  270.                                 </tr>
  271.                             </table>
  272. <%
  273.                         End If
  274. %>
  275.                     </td>
  276.                     <td colspan="2" width="1"></td>
  277.                 </tr>
  278.                 <tr>
  279.                     <td width="1" rowspan="50"></td>
  280.                     <td width="125">
  281.                         <span class="NormalBold">Respondents:</span>
  282.                     </td>
  283.                     <td width="243">
  284.                         <span class="Normal"><%=lngFilteredRespondents%> displayed, <%=lngTotalRespondents%> total</span>
  285.                     </td>
  286.                     <td width="110">
  287.                         <span class="NormalBold">Status:</span>
  288.                     </td>
  289.                     <td colspan="2" width="258">
  290.                         <span class="Normal"><%=rsSurvey("status")%></span>
  291.                     </td>
  292.                     <td width="1" rowspan="50"></td>
  293.                 </tr>
  294.                 <tr>
  295.                     <td>
  296.                         <span class="NormalBold">Launched Date:</span>
  297.                     </td>
  298.                     <td>
  299.                         <span class="Normal"><%=CustomDateFormatDisplay(DateValue(rsSurvey("launched_date")))%></span>
  300.                     </td>
  301.                     <td>
  302.                         <span class="NormalBold">Closed Date:</span>
  303.                     </td>
  304.                     <td colspan="2">
  305.                         <span class="Normal">
  306. <%
  307.                             If Len(rsSurvey("closed_date")) > 0 Then
  308.                                 Response.Write CustomDateFormatDisplay(DateValue(rsSurvey("closed_date")))
  309.                             Else
  310.                                 Response.Write "N/A"
  311.                             End If
  312. %>
  313.                         </span>
  314.                     </td>
  315.                 </tr>
  316.                 <tr>
  317.                     <td>
  318.                         <span class="NormalBold"><label for="cboDisplay">Display:</label></span>
  319.                     </td>
  320.                     <td colspan="2">
  321.                         <select style="width:365px" name="cboDisplay" id="cboDisplay" onChange="displayFilterSelected();">
  322.                             <option value="All">Display all pages and questions</option>
  323. <%
  324.                             'Load the combo box at the top of the page used for filter to view
  325.                             'either individual pages or individual questions
  326.                             strSQL = "SELECT page_number, m.item_id, item_text, item_alias " & _
  327.                                      "FROM sur_survey_to_item_mapping m, sur_item i, sur_item_type it " & _
  328.                                      "WHERE m.item_id = i.item_id " & _
  329.                                      "AND it.item_type_id = i.item_type_id " & _
  330.                                      "AND survey_id = " & lngSurveyID & _
  331.                                      " AND question_yn = " & SQLEncode(SUR_BOOLEAN_POSITIVE) & _
  332.                                      " ORDER BY page_number, m.order_number"
  333.                             rsDisplayFilter.Open ConvertSQL(strSQL), SURVEY_APP_CONNECTION, adOpenDynamic, , adCmdText
  334.                             rsDisplayFilter.MoveFirst
  335.                             lngTemp = CLng(-1)
  336.  
  337.                             Do While Not rsDisplayFilter.EOF
  338.                                 'Increment the current page number
  339.                                 lngCurrentItemNumber = lngCurrentItemNumber + 1
  340.  
  341.                                 'If this is a new page, add an entry to display the page
  342.                                 If lngTemp <> rsDisplayFilter("page_number") Then
  343.                                     'If the numbering format is within each page, re-initialize the page
  344.                                     'number back to the beginning
  345.                                     If strQuestionNumberingFormat = SUR_QUESTION_NUMBERING_EACH_PAGE Then
  346.                                         lngCurrentItemNumber = 1
  347.                                     End If
  348.  
  349.                                     'Extract the current page number
  350.                                     lngTemp = rsDisplayFilter("page_number")
  351.  
  352.                                     'Determine whether or not this item should be selected
  353.                                     If Request.Form("cboDisplay") = "ITEMNUMBER" & lngCurrentItemNumber & "PAGE" & lngTemp Then
  354.                                         'Initialize the question number, used for display purposes, to the current question number
  355.                                         lngQuestionNumber = lngCurrentItemNumber
  356.                                         strSelected = "SELECTED"
  357.                                     Else
  358.                                         strSelected = ""
  359.                                     End If
  360. %>
  361.                                     <option <%=strSelected%> value="ITEMNUMBER<%=lngCurrentItemNumber%>PAGE<%=lngTemp%>">   Page <%=lngTemp%></option>
  362. <%
  363.                                 End If
  364.  
  365.                                 'Determine whether or not this item should be selected
  366.                                 If Request.Form("cboDisplay") = "ITEMNUMBER" & lngCurrentItemNumber & "ITEMID" & rsDisplayFilter("item_id") Then
  367.                                     'Initialize the question number, used for display purposes, to the current question number
  368.                                     lngQuestionNumber = lngCurrentItemNumber
  369.                                     strSelected = "SELECTED"
  370.                                 Else
  371.                                     strSelected = ""
  372.                                 End If
  373.  
  374.                                 'If a question alias was supplied, use that instead of the question.  Otherwise, use
  375.                                 'the actual question text.
  376.                                 strItemText = Trim(rsDisplayFilter("item_text"))
  377.                                 strItemAlias = RemoveLineFeeds(Trim(rsDisplayFilter("item_alias")))
  378.                                 If Len(strItemAlias) > 0 Then
  379.                                     strItemText = strItemAlias
  380.                                 End If
  381.                                 strItemText = RemovePipeTokens(strItemText)
  382.  
  383.                                 'Reduce the length of the question to fit in the combo box
  384.                                 If Len(strItemText) > 50 Then
  385.                                     'Make sure there's at least one space in the string before trying to break on a space.
  386.                                     'Otherwise, just take the 50 left-most characters
  387.                                     If InStr(strItemText, " ") > 0 Then
  388.                                         strItemText = Trim(Left(strItemText, InStr(40, strItemText, " "))) & "..."
  389.                                     Else
  390.                                         strItemText = Trim(Left(strItemText, 50)) & "..."
  391.                                     End If
  392.                                 End If
  393. %>
  394.                                 <option <%=strSelected%> value="ITEMNUMBER<%=lngCurrentItemNumber%>ITEMID<%=rsDisplayFilter("item_id")%>">        <%=lngCurrentItemNumber & ". " & strItemText%></option>
  395. <%
  396.                                 rsDisplayFilter.MoveNext
  397.                             Loop
  398.  
  399.                             'Clean Up
  400.                             rsDisplayFilter.Close
  401.                             Set rsDisplayFilter = Nothing
  402. %>
  403.                         </select>
  404.                     </td>
  405.                     <td width="175" align="right">
  406. <%
  407.                         'Optinally display the report filter button
  408.                         If CanUserFilterReports() = True Then
  409. %>
  410.                             <a href="ReportFilterList.asp?SurveyName=<%=Server.URLEncode(strTitle)%>&Nav=ResultsOverview&SurveyID=<%=lngSurveyID%>&DisplayHeader=<%=Request.QueryString("DisplayHeader")%>"><img border="0" alt="Manage filters for this survey" name="btnManageFilters" src="Resources/Buttons/ManageFilters.gif"></a>
  411. <%
  412.                         End If
  413. %>
  414.                     </td>
  415.                     <td width="83" align="left" valign="top">
  416.                          
  417. <%
  418.                         'Optinally display the report filter button
  419.                         If CanUserFilterReports() = True Then
  420. %>
  421.                             <span class="InlineHelpSpanStyle">
  422. <%
  423.                                 'Display the number of report filters
  424.                                 lngReportFilterCount = GetReportFilterCount(lngSurveyID)
  425.                                 If lngReportFilterCount = 1 Then
  426. %>
  427.                                     <%=lngReportFilterCount%> filter
  428. <%
  429.                                 Else '0 or more than 1 filter
  430. %>
  431.                                     <%=lngReportFilterCount%> filters
  432. <%
  433.                                 End If
  434. %>
  435.                             </span>
  436. <%
  437.                         End If
  438. %>
  439.                     </td>
  440.                 </tr>
  441. <%
  442.                 'Only survey owners or administrators can have access to the results sharing functionality
  443.                 If IsUserOwnerOrAdmin(lngSurveyID) = True Then
  444. %>
  445.                     <tr>
  446.                         <td colspan="3"> </td>
  447.                         <td align="right">
  448.                             <a href="ReportShareList.asp?SurveyName=<%=Server.URLEncode(strTitle)%>&SurveyID=<%=lngSurveyID%>"><img border="0" alt="Configure results sharing for this survey" name="btnManageFilters" src="Resources/Buttons/ShareResults.gif"></a>
  449.                         </td>
  450.                         <td>
  451.                              
  452.                             <span class="InlineHelpSpanStyle">
  453. <%
  454.                                 If rsSurvey("report_sharing_enabled_yn") = SUR_BOOLEAN_POSITIVE Then
  455.                                     Response.Write "Enabled"
  456.                                 Else
  457.                                     Response.Write "Disabled"
  458.                                 End If
  459. %>
  460.                             </span>
  461.                         </td>
  462.                         <td width="1" rowspan="50"></td>
  463.                     </tr>
  464. <%
  465.                 End If
  466. %>
  467.             </table>
  468.         </td>
  469. <%
  470.         'Clean up
  471.         rsSurvey.Close
  472.         Set rsSurvey = Nothing
  473. %>
  474.     </tr>
  475. </form>
  476. </table>
  477. <br>
  478. <%
  479.     'Get all of the answers for the survey
  480.     strSQL = "SELECT ra.response_id, ra.subitem_id, m.item_id AS item_id, ra.answer_id AS ResponseAnswerID, " & _
  481.              "ia.answer_value, ra.answer_text AS ResponseAnswerText, ra.other_text AS ResponseOtherText " & _
  482.              "FROM sur_survey_to_item_mapping m INNER JOIN (sur_response_answer ra LEFT JOIN sur_item_answer ia " & _
  483.              "ON ra.answer_id = ia.answer_id) ON m.item_id = ra.item_id " & _
  484.              "WHERE m.item_id = ra.item_id "
  485.  
  486.     'If the user selected a filter other than display all, filter the answers
  487.     If Len(Request.Form("cboDisplay")) > 0 And Request.Form("cboDisplay") <> "All" Then
  488.         'If the user selected a page, filter on the page
  489.         If InStr(Request.Form("cboDisplay"), "PAGE") > 0 Then
  490.             strSQL = strSQL & " AND m.page_number = " & Mid(Request.Form("cboDisplay"), InStr(Request.Form("cboDisplay"), "PAGE") + 4, Len(Request.Form("cboDisplay")) - (InStr(Request.Form("cboDisplay"), "PAGE") - 3))
  491.         End If
  492.  
  493.         'If the user selected a question, display only that question
  494.         If InStr(Request.Form("cboDisplay"), "ITEMID") > 0 Then
  495.             strSQL = strSQL & " AND m.item_id = " & Mid(Request.Form("cboDisplay"), InStr(Request.Form("cboDisplay"), "ITEMID") + 6, Len(Request.Form("cboDisplay")) - (InStr(Request.Form("cboDisplay"), "ITEMID") - 5))
  496.         End If
  497.     End If
  498.  
  499.     'If there are report filters, display only the data from questions that match the filter criteria
  500.     strReportFilters = GetFilteredResponseList(lngSurveyID)
  501.     If CStr(strReportFilters) <> SUR_REPORT_FILTER_NO_ACTIVE_FILTERS Then
  502.         strSQL = strSQL & " AND response_id IN(" & strReportFilters & ")"
  503.     End If
  504.  
  505.     'Complete the SQL statement and open the recordset
  506.     strSQL = strSQL & " AND m.survey_id = " & lngSurveyID & _
  507.                       " ORDER BY m.order_number, ra.response_id"
  508.     rsAnswers.Open ConvertSQL(strSQL), SURVEY_APP_CONNECTION, adOpenDynamic, , adCmdText
  509.  
  510.     'Check to see if there are any results; if not, display a message indicating that there are no results
  511.     If rsAnswers.EOF = True Then
  512. %>
  513.         <table border="0" cellpadding="6" width="740" cellspacing="0" class="WhiteBackgroundColor">
  514.             <tr class="LightGrayBackgroundColor">
  515.                 <td width="1"></td>
  516.                 <td height="36" valign="center">
  517.                     <span class="H2HeadingStyle">No Matching Responses</span>
  518.                 </td>
  519.                 <td width="1"> </td>
  520.             </tr>
  521.             <tr class="WhiteBackgroundColor">
  522.                 <td width="1"></td>
  523.                 <td>
  524.                     <br>
  525.                     <span class="Normal">
  526.                         There are no responses for this survey that match the specified filter criteria.
  527.                         <br><br>
  528.                         To see results for this survey, you should modify the report filters by clicking the
  529.                         "Manage Filters" button above.  From the report filters page, you can modify the filters as desired.
  530.                         Alternately, to see the full set of responses for this survey, either delete all filters or set all
  531.                         filters to inactive.
  532.                         <br><br>
  533.                     </span>
  534.                 </td>
  535.                 <td width="1"></td>
  536.             </tr>
  537.         </table>
  538.         </body></html>
  539. <!--#Include File="Include/FrameworkBottom_inc.asp"-->
  540. <%
  541.         Response.end
  542.     End If
  543.  
  544.     'Get all of the questions for the survey.  This query selects only the items associated with the survey that are
  545.     'actually questions.  This particular SQL statement uses ANSI-standard SQL with "INNER JOIN" and "LEFT JOIN" syntax
  546.     'so that it will work against both Access and SQL Server.
  547.     strSQL = "SELECT minimum_value, maximum_value, sur_item.item_id As item_id, " & _
  548.                 "sur_item.item_type_id As item_type_id, other_yn, " & _
  549.                 "answer_id, sur_item_answer.answer_text As ItemAnswerText, other_text, item_alias, item_text " & _
  550.                 "FROM ((sur_item INNER JOIN sur_survey_to_item_mapping " & _
  551.                 "ON sur_item.item_id = sur_survey_to_item_mapping.item_id) " & _
  552.                 "INNER JOIN sur_item_type " & _
  553.                 "ON sur_item.item_type_id = sur_item_type.item_type_id) " & _
  554.                 "LEFT JOIN sur_item_answer ON sur_item.item_id = sur_item_answer.item_id " & _
  555.                 "WHERE question_yn = " & SQLEncode(SUR_BOOLEAN_POSITIVE)
  556.     'If the user selected a filter other than display all, filter the answers
  557.     If Len(Request.Form("cboDisplay")) > 0 And Request.Form("cboDisplay") <> "All" Then
  558.         'If the user selected a page, filter on the page
  559.         If InStr(Request.Form("cboDisplay"), "PAGE") > 0 Then
  560.             strSQL = strSQL & " AND sur_survey_to_item_mapping.page_number = " & Mid(Request.Form("cboDisplay"), InStr(Request.Form("cboDisplay"), "PAGE") + 4, Len(Request.Form("cboDisplay")) - (InStr(Request.Form("cboDisplay"), "PAGE") - 3))
  561.         End If
  562.  
  563.         'If the user selected a question, display only that question
  564.         If InStr(Request.Form("cboDisplay"), "ITEMID") > 0 Then
  565.             strSQL = strSQL & " AND sur_item.item_id = " & Mid(Request.Form("cboDisplay"), InStr(Request.Form("cboDisplay"), "ITEMID") + 6, Len(Request.Form("cboDisplay")) - (InStr(Request.Form("cboDisplay"), "ITEMID") - 5))
  566.         End If
  567.     End If
  568.  
  569.     'Complete the SQL statement and open the recordset
  570.     strSQL = strSQL & " AND sur_survey_to_item_mapping.survey_id = " & lngSurveyID & _
  571.                 " ORDER BY sur_survey_to_item_mapping.order_number, sur_item_answer.order_number"
  572.     rsQuestions.Open ConvertSQL(strSQL), SURVEY_APP_CONNECTION, adOpenDynamic, , adCmdText
  573.  
  574.  
  575.     'Loop through the questions, calculating the the number of responses for each answer.
  576.     Do While Not rsQuestions.EOF
  577.         'If a question alias was supplied, use that instead of the question.  Otherwise, use
  578.         'the actual question text.
  579.         strItemText = Trim(rsQuestions("item_text"))
  580.         strItemAlias = RemoveLineFeeds(Trim(rsQuestions("item_alias")))
  581.         If Len(strItemAlias) > 0 Then
  582.             strItemText = strItemAlias
  583.         End If
  584.         strItemText = RemovePipeTokens(strItemText)
  585.  
  586.         'Initialization for each question
  587.         lngItemID = rsQuestions("item_id")
  588.         lngItemTypeID = rsQuestions("item_type_id")
  589.         flgOther = rsQuestions("other_yn")
  590.         strOtherText = rsQuestions("other_text")
  591.         strAnswersCollection = ""
  592.         strAnswerIDsCollection = ""
  593.         strUniqueRespondentsPerAnswerCollection = ""
  594.         lngResponseCount = 0
  595.         lngSkippedTotal = 0
  596.         lngAnswerCount = 0
  597.         lngCurrentResponseID = -1
  598.         lngCurrentSubItemID = -1
  599.         lngCurrentResponseID = -1
  600.         lngUniqueRespondentCount = 0
  601.         lngTotalPoints = 0
  602.  
  603.         'If the current question has subitems, query to obtain the list of subitems
  604.         If lngItemTypeID = SUR_ITEM_CONSTANT_SUM Or lngItemTypeID = SUR_ITEM_RANKING Or lngItemTypeID = SUR_ITEM_MATRIX_SINGLE_SELECT_OPTIONS Or lngItemTypeID = SUR_ITEM_MATRIX_RATING_SCALE Or lngItemTypeID = SUR_ITEM_MATRIX_MULTISELECT_CHECKBOXES Or lngItemTypeID = SUR_ITEM_MATRIX_TEXT_BOXES Or lngItemTypeID = SUR_ITEM_OPEN_ENDED_ONE_OR_MORE_LINES Then
  605.             strSQL = "SELECT subitem_id, subitem_text " & _
  606.                         "FROM sur_subitem " & _
  607.                         "WHERE item_id = " & lngItemID & _
  608.                         " ORDER BY order_number"
  609.             rsSubItems.Open ConvertSQL(strSQL), SURVEY_APP_CONNECTION, adOpenDynamic, , adCmdText
  610.         End If
  611.  
  612.  
  613.         'Depending on the type of question, process the results differently
  614.         If lngItemTypeID = SUR_ITEM_MULTISELECT_CHECKBOXES Or lngItemTypeID = SUR_ITEM_SINGLE_SELECT_DROPDOWN Or lngItemTypeID = SUR_ITEM_SINGLE_SELECT_OPTIONS Then 'Radio buttons, checkboxes, dropdown
  615.             'Build a string of name/value pairs by looping through the question recordset (which also has pre-defined answers).
  616.             'This string is logically a collection of name/value pairs separated by semi-colons (;) in the format
  617.             'Vanilla;6;Chocolate;7;Strawberry;1.  This section sets the collection to values of 0 for all possible answers.
  618.             'Also create a collection of answer ID's to answer text for displaying the results.
  619.             Do While lngItemID = rsQuestions("item_id")
  620.                 'When adding each possible answer to the collection, initialize to 0
  621.                 strAnswersCollection = strAnswersCollection & rsQuestions("answer_id") & "|0|"
  622.  
  623.                 'Add all of the ID/Value pairs to another collection for display purposes later
  624.                 strAnswerIDsCollection = strAnswerIDsCollection & rsQuestions("answer_id") & "|" & rsQuestions("ItemAnswerText") &"|"
  625.                 rsQuestions.MoveNext
  626.                 If rsQuestions.EOF = True Then
  627.                     Exit Do
  628.                 End If
  629.             Loop
  630.  
  631.  
  632.  
  633.             'Add one more name/value pair to the collection for null answers.
  634.             strAnswersCollection = strAnswersCollection & SUR_ANSWER_TEXT_NULL & "|0|"
  635.  
  636.             'If the question has an "Other" answer, add another name/value pair to the collection for "Other" responses.
  637.             If flgOther = SUR_BOOLEAN_POSITIVE Then
  638.                 strAnswersCollection = strAnswersCollection & SUR_ANSWER_TEXT_OTHER_SELECTED & "|0|"
  639.             End If
  640.  
  641.             'Call a function that strips off all extra semi-colons
  642.             strAnswersCollection = CleanAnswersCollectionPipe(strAnswersCollection)
  643.             strAnswerIDsCollection = CleanAnswersCollectionPipe(strAnswerIDsCollection)
  644.  
  645.  
  646.             'Loop through the actual answers and increment the counts for each.  The counts are incremented in
  647.             'the helper function, IncrementCountInCollectionPipe
  648.             If Not rsAnswers.EOF Then
  649.                 Do While lngItemID = rsAnswers("item_id")
  650.                     'Track the number of responses
  651.                     lngResponseCount = lngResponseCount + 1
  652.  
  653.                     'Track the number of unique respondents
  654.                     If lngCurrentResponseID <> rsAnswers("response_id") Then
  655.                         lngUniqueRespondentCount = lngUniqueRespondentCount + 1
  656.                         lngCurrentResponseID = rsAnswers("response_id")
  657.                     End If
  658.  
  659.                     'If the ID is NULL (-1), a text response was recorded
  660.                     If CStr(rsAnswers("ResponseAnswerID")) = CStr(SUR_ANSWER_ID_NULL) Then
  661.                         strAnswersCollection = IncrementCountInCollectionPipe(strAnswersCollection, CStr(rsAnswers("ResponseAnswerText")))
  662.                     Else 'An ID response was recorded
  663.                         strAnswersCollection = IncrementCountInCollectionPipe(strAnswersCollection, CStr(rsAnswers("ResponseAnswerID")))
  664.  
  665.                         'If there are points assigned to this item, add them up
  666.                         If IsNull(rsAnswers("answer_value")) = False Then
  667.                             lngTotalPoints = lngTotalPoints + CLng(rsAnswers("answer_value"))
  668.                         End If
  669.                     End If
  670.                     rsAnswers.MoveNext
  671.                     If rsAnswers.EOF = True Then
  672.                         Exit Do
  673.                     End If
  674.                 Loop
  675.             End If
  676.  
  677.         ElseIf lngItemTypeID = SUR_ITEM_YES_NO Or lngItemTypeID = SUR_ITEM_TRUE_FALSE Then
  678.             'Build a string of name/value pairs.  For either Yes/No or True/False question, the values are already known,
  679.             'so there's no need to loop through the answers recordset.
  680.             'This string is logically a collection of name/value pairs separated by semi-colons (;) in the format
  681.             'Vanilla;6;Chocolate;7;Strawberry;1.  This section sets the collection to values of 0 for all possible answers.
  682.             'Also create a collection of answer ID's to answer text for displaying the results.
  683.             If lngItemTypeID = SUR_ITEM_YES_NO Then
  684.                 strAnswersCollection = strAnswersCollection & SUR_YES_NO_QUESTION_VALUE_YES & "|0|"
  685.                 strAnswersCollection = strAnswersCollection & SUR_YES_NO_QUESTION_VALUE_NO & "|0|"
  686.             Else 'SUR_ITEM_TRUE_FALSE
  687.                 strAnswersCollection = strAnswersCollection & SUR_TRUE_FALSE_QUESTION_VALUE_TRUE & "|0|"
  688.                 strAnswersCollection = strAnswersCollection & SUR_TRUE_FALSE_QUESTION_VALUE_FALSE & "|0|"
  689.             End If
  690.  
  691.             'Add one more name/value pair to the collection for null answers.
  692.             strAnswersCollection = strAnswersCollection & SUR_ANSWER_TEXT_NULL & "|0|"
  693.  
  694.             'Call a function that strips off all extra semi-colons
  695.             strAnswersCollection = CleanAnswersCollectionPipe(strAnswersCollection)
  696.  
  697.             'Loop through the actual answers and increment the counts for each.  The counts are incremented in
  698.             'the helper function, IncrementCountInCollectionPipe
  699.             If Not rsAnswers.EOF Then
  700.                 Do While lngItemID = rsAnswers("item_id")
  701.                     'Track the number of responses
  702.                     lngResponseCount = lngResponseCount + 1
  703.  
  704.                     'Track the number of unique respondents
  705.                     If lngCurrentResponseID <> rsAnswers("response_id") Then
  706.                         lngUniqueRespondentCount = lngUniqueRespondentCount + 1
  707.                         lngCurrentResponseID = rsAnswers("response_id")
  708.                     End If
  709.  
  710.                     strAnswersCollection = IncrementCountInCollectionPipe(strAnswersCollection, CStr(rsAnswers("ResponseAnswerText")))
  711.                     rsAnswers.MoveNext
  712.                     If rsAnswers.EOF = True Then
  713.                         Exit Do
  714.                     End If
  715.                 Loop
  716.             End If
  717.  
  718.             'Advance to the next question
  719.             rsQuestions.MoveNext
  720.         ElseIf lngItemTypeID = SUR_ITEM_CONSTANT_SUM Or lngItemTypeID = SUR_ITEM_RANKING Then
  721.             'Build a string of name/value pairs by looping through the subitem recordset.
  722.             'This string is logically a collection of name/value pairs separated by semi-colons (;) in the format
  723.             'SIDxxx;6;SIDxxx;7;SIDxxx;1, where xxx represents the subitem ID'..  This section sets the collection to values
  724.             'of 0 for all possible answers.  Also create a collection of subitem ID's to subitem text for displaying
  725.             'the results.
  726.             Do While Not rsSubItems.EOF
  727.                 'When adding each possible answer to the answer collection, initialize to 0
  728.                 strAnswersCollection = strAnswersCollection & "SID" & rsSubItems("subitem_id") & "|0|"
  729.  
  730.                 'The unique respondent per answer collection starts off the same as teh answers collection
  731.                 strUniqueRespondentsPerAnswerCollection = strAnswersCollection
  732.  
  733.                 'Add all of the ID/Value pairs to another collection for display purposes later
  734.                 strAnswerIDsCollection = strAnswerIDsCollection & "SID" & rsSubItems("subitem_id") & "|" & rsSubItems("subitem_text") &"|"
  735.                 rsSubItems.MoveNext
  736.             Loop
  737.  
  738.             'Add one more name/value pair to the collection for null answers.
  739.             strAnswersCollection = strAnswersCollection & SUR_ANSWER_TEXT_NULL & "|0|"
  740.  
  741.             'Call a function that strips off all extra semi-colons
  742.             strAnswersCollection = CleanAnswersCollectionPipe(strAnswersCollection)
  743.             strAnswerIDsCollection = CleanAnswersCollectionPipe(strAnswerIDsCollection)
  744.             strUniqueRespondentsPerAnswerCollection = CleanAnswersCollectionPipe(strUniqueRespondentsPerAnswerCollection)
  745.  
  746.             'Loop through the actual answers and increment the counts for each.  The counts are incremented in
  747.             'the helper function, IncrementCountInCollectionPipe
  748.             If Not rsAnswers.EOF Then
  749.                 Do While lngItemID = rsAnswers("item_id")
  750.                     'Track the number of responses
  751.                     lngResponseCount = lngResponseCount + 1
  752.  
  753.                     'Track the number of unique respondents
  754.                     If lngCurrentResponseID <> rsAnswers("response_id") Then
  755.                         lngUniqueRespondentCount = lngUniqueRespondentCount + 1
  756.                         lngCurrentResponseID = rsAnswers("response_id")
  757.                     End If
  758.  
  759.                     'Increment the appropriate subitem in the collection.  If the subitem_id is Null, record a non-response
  760.                     If CStr(rsAnswers("ResponseAnswerText")) = CStr(SUR_ANSWER_TEXT_NULL) Then
  761.                         strAnswersCollection = IncrementCountInCollectionPipe(strAnswersCollection, SUR_ANSWER_TEXT_NULL)
  762.                     Else 'An ID response was recorded
  763.                         'Track the total for each answer, and the total response count for each answer.  These two values
  764.                         'will enable us to determine the average
  765.                         strAnswersCollection = IncrementTotalInCollectionPipe(strAnswersCollection, "SID" & CStr(rsAnswers("subitem_id")), CLng(rsAnswers("ResponseAnswerText")))
  766.                         strUniqueRespondentsPerAnswerCollection = IncrementCountInCollectionPipe(strUniqueRespondentsPerAnswerCollection, "SID" & CStr(rsAnswers("subitem_id")))
  767.                     End If
  768.  
  769.                     rsAnswers.MoveNext
  770.                     If rsAnswers.EOF = True Then
  771.                         Exit Do
  772.                     End If
  773.                 Loop
  774.             End If
  775.  
  776.             'Advance to the next question
  777.             rsQuestions.MoveNext
  778.         ElseIf lngItemTypeID = SUR_ITEM_OPEN_ENDED_ONE_OR_MORE_LINES Then
  779.             'Build a string of name/value pairs by looping through the subitem recordset.
  780.             'This string is logically a collection of name/value pairs separated by semi-colons (;) in the format
  781.             'SIDxxx;6;SIDxxx;7;SIDxxx;1, where xxx represents the subitem ID'..  This section sets the collection to values
  782.             'of 0 for all possible answers.  Also create a collection of subitem ID's to subitem text for displaying
  783.             'the results.
  784.             Do While Not rsSubItems.EOF
  785.                 'When adding each possible answer to the collection, initialize to 0
  786.                 strAnswersCollection = strAnswersCollection & "SID" & rsSubItems("subitem_id") & "|0|"
  787.  
  788.                 'Add all of the ID/Value pairs to another collection for display purposes later
  789.                 strAnswerIDsCollection = strAnswerIDsCollection & "SID" & rsSubItems("subitem_id") & "|" & rsSubItems("subitem_text") &"|"
  790.                 rsSubItems.MoveNext
  791.             Loop
  792.  
  793.             'Add one more name/value pair to the collection for null answers.
  794.             strAnswersCollection = strAnswersCollection & SUR_ANSWER_TEXT_NULL & "|0|"
  795.  
  796.             'Call a function that strips off all extra semi-colons
  797.             strAnswersCollection = CleanAnswersCollectionPipe(strAnswersCollection)
  798.             strAnswerIDsCollection = CleanAnswersCollectionPipe(strAnswerIDsCollection)
  799.  
  800.             'Loop through the actual answers and increment the counts for each.  The counts are incremented in
  801.             'the helper function, IncrementCountInCollectionPipe
  802.             If Not rsAnswers.EOF Then
  803.                 Do While lngItemID = rsAnswers("item_id")
  804.                     'Track the number of responses
  805.                     lngResponseCount = lngResponseCount + 1
  806.  
  807.                     'Track the number of unique respondents
  808.                     If lngCurrentResponseID <> rsAnswers("response_id") Then
  809.                         lngUniqueRespondentCount = lngUniqueRespondentCount + 1
  810.                         lngCurrentResponseID = rsAnswers("response_id")
  811.                     End If
  812.  
  813.                     'Increment the appropriate subitem in the collection.  If the subitem_id is Null, record a non-response
  814.                     If CStr(rsAnswers("ResponseAnswerText")) = CStr(SUR_ANSWER_TEXT_NULL) Then
  815.                         strAnswersCollection = IncrementCountInCollectionPipe(strAnswersCollection, SUR_ANSWER_TEXT_NULL)
  816.                     Else 'An ID response was recorded
  817.                         strAnswersCollection = IncrementCountInCollectionPipe(strAnswersCollection, "SID" & CStr(rsAnswers("subitem_id")))
  818.                     End If
  819.  
  820.                     rsAnswers.MoveNext
  821.                     If rsAnswers.EOF = True Then
  822.                         Exit Do
  823.                     End If
  824.                 Loop
  825.             End If
  826.  
  827.             'Advance to the next question
  828.             rsQuestions.MoveNext
  829.         ElseIf lngItemTypeID = SUR_ITEM_MATRIX_TEXT_BOXES Then
  830.             'Build a string of name/value pairs by looping through the subitem recordset.
  831.             'This string is logically a collection of name/value pairs separated by semi-colons (;) in the format
  832.             'SIDxxx;6;SIDxxx;7;SIDxxx;1, where xxx represents the subitem ID'..  This section sets the collection to values
  833.             'of 0 for all possible answers.  Also create a collection of subitem ID's to subitem text for displaying
  834.             'the results.
  835.             Do While Not rsSubItems.EOF
  836.                 'When adding each possible answer to the collection, initialize to 0
  837.                 strAnswersCollection = strAnswersCollection & "SID" & rsSubItems("subitem_id") & "|0|"
  838.  
  839.                 'Add all of the ID/Value pairs to another collection for display purposes later
  840.                 strAnswerIDsCollection = strAnswerIDsCollection & "SID" & rsSubItems("subitem_id") & "|" & rsSubItems("subitem_text") &"|"
  841.                 rsSubItems.MoveNext
  842.             Loop
  843.  
  844.             'Add one more name/value pair to the collection for null answers.
  845.             strAnswersCollection = strAnswersCollection & SUR_ANSWER_TEXT_NULL & "|0|"
  846.  
  847.             'Call a function that strips off all extra semi-colons
  848.             strAnswersCollection = CleanAnswersCollectionPipe(strAnswersCollection)
  849.             strAnswerIDsCollection = CleanAnswersCollectionPipe(strAnswerIDsCollection)
  850.  
  851.             'Loop through the actual answers and increment the counts for each.  The counts are incremented in
  852.             'the helper function, IncrementCountInCollectionPipe
  853.             If Not rsAnswers.EOF Then
  854.                 Do While lngItemID = rsAnswers("item_id")
  855.                     'Track the number of responses
  856.                     lngResponseCount = lngResponseCount + 1
  857.  
  858.                     'Track the number of unique respondents
  859.                     If lngCurrentResponseID <> rsAnswers("response_id") Then
  860.                         lngUniqueRespondentCount = lngUniqueRespondentCount + 1
  861. '                        lngCurrentResponseID = rsAnswers("response_id")
  862.                     End If
  863.  
  864.                     'Increment the appropriate subitem in the collection.  If the subitem_id is Null, record a non-response
  865.                     If CStr(rsAnswers("ResponseAnswerID")) = CStr(SUR_ANSWER_ID_NULL) Then
  866.                         strAnswersCollection = IncrementCountInCollectionPipe(strAnswersCollection, SUR_ANSWER_TEXT_NULL)
  867.                     Else 'An ID response was recorded
  868.                         strAnswersCollection = IncrementCountInCollectionPipe(strAnswersCollection, "SID" & CStr(rsAnswers("subitem_id")))
  869.                     End If
  870.  
  871.                     rsAnswers.MoveNext
  872.                     If rsAnswers.EOF = True Then
  873.                         Exit Do
  874.                     End If
  875.                 Loop
  876.             End If
  877.  
  878.             'Advance to the next question
  879.             lngItemID = rsQuestions("item_id")
  880.             Do While lngItemID = rsQuestions("item_id")
  881.                 rsQuestions.MoveNext
  882.                 If rsQuestions.EOF = True Then
  883.                     Exit Do
  884.                 End If
  885.             Loop
  886.         ElseIf lngItemTypeID = SUR_ITEM_MATRIX_SINGLE_SELECT_OPTIONS Or lngItemTypeID = SUR_ITEM_MATRIX_MULTISELECT_CHECKBOXES Then
  887.             'Build a string of name/value pairs by looping through the question recordset (which also has pre-defined answers).
  888.             'This string is logically a collection of name/value pairs separated by semi-colons (;) in the format
  889.             'SIDxxxAIDyyy;6;SIDxxxAIDyyy;7;SIDxxxAIDyyy;1, where xxx represents the subitem ID and yyy represents the
  890.             'answer ID.  This section sets the collection to values of 0 for all possible answers.  Also create a
  891.             'collection of subitem ID's to subitem text for displaying the results.
  892.             Do While lngItemID = rsQuestions("item_id")
  893.                 'The outer loop goes through the answer ID's (the columns), while the inner loop goes through the subitems
  894.                 '(the rows).
  895.                 rsSubItems.MoveFirst
  896.                 Do While Not rsSubItems.EOF
  897.                     'When adding each possible answer to the collection, initialize to 0
  898.                     strAnswersCollection = strAnswersCollection & "SID" & rsSubItems("subitem_id") & "AID" & rsQuestions("answer_id") & "|0|"
  899.                     rsSubItems.MoveNext
  900.                 Loop
  901.  
  902.                 'Add all of the ID/Value pairs to another collection for display purposes later
  903.                 strAnswerIDsCollection = strAnswerIDsCollection & rsQuestions("answer_id") & "|" & rsQuestions("ItemAnswerText") & "|"
  904.  
  905.                 'Record the total number of answers, which is needed to correctly render matrix questions below
  906.                 lngAnswerCount = lngAnswerCount + 1
  907.  
  908.                 rsQuestions.MoveNext
  909.                 If rsQuestions.EOF = True Then
  910.                     Exit Do
  911.                 End If
  912.             Loop
  913.  
  914.             'Initialize the collection for tracking the number of responses per subitem
  915.             rsSubItems.MoveFirst
  916.             Do While Not rsSubItems.EOF
  917.                 'When adding each possible answer to the collection, initialize to 0
  918.                 strUniqueRespondentsPerAnswerCollection = strUniqueRespondentsPerAnswerCollection & rsSubItems("subitem_id") & "|0|"
  919.                 rsSubItems.MoveNext
  920.             Loop
  921.  
  922.             'Add one more name/value pair to the collection for null answers.
  923.             strAnswersCollection = strAnswersCollection & SUR_ANSWER_TEXT_NULL & "|0|"
  924.  
  925.             'Call a function that strips off all extra semi-colons
  926.             strAnswersCollection = CleanAnswersCollectionPipe(strAnswersCollection)
  927.             strAnswerIDsCollection = CleanAnswersCollectionPipe(strAnswerIDsCollection)
  928.             strUniqueRespondentsPerAnswerCollection = CleanAnswersCollectionPipe(strUniqueRespondentsPerAnswerCollection)
  929.  
  930.             'Loop through the actual answers and increment the counts for each.  The counts are incremented in
  931.             'the helper function, IncrementCountInCollectionPipe
  932.             If Not rsAnswers.EOF Then
  933.                 Do While lngItemID = rsAnswers("item_id")
  934.                     'Track the number of responses
  935.                     lngResponseCount = lngResponseCount + 1
  936.  
  937.                     'Track the number of unique respondents
  938.                     If lngCurrentResponseID <> rsAnswers("response_id") Then
  939.                         lngUniqueRespondentCount = lngUniqueRespondentCount + 1
  940.                     End If
  941.  
  942.                     'Increment the appropriate subitem in the collection.  If the subitem_id is Null, record a non-response
  943.                     If CStr(rsAnswers("ResponseAnswerID")) = CStr(SUR_ANSWER_ID_NULL) Then
  944.                         strAnswersCollection = IncrementCountInCollectionPipe(strAnswersCollection, SUR_ANSWER_TEXT_NULL)
  945.                     Else 'An ID response was recorded
  946.                         strAnswersCollection = IncrementCountInCollectionPipe(strAnswersCollection, "SID" & CStr(rsAnswers("subitem_id")) & "AID" & CStr(rsAnswers("ResponseAnswerID")))
  947.  
  948.                         'Track the number of unique respondents per row by adding one to the count for each response.
  949.                         If lngItemTypeID = SUR_ITEM_MATRIX_SINGLE_SELECT_OPTIONS Or lngItemTypeID = SUR_ITEM_MATRIX_RATING_SCALE Then
  950.                             strUniqueRespondentsPerAnswerCollection = IncrementCountInCollectionPipe(strUniqueRespondentsPerAnswerCollection, CStr(rsAnswers("subitem_id")))
  951.                         Else 'SUR_ITEM_MATRIX_MULTISELECT_CHECKBOXES
  952.                             If lngCurrentResponseID <> rsAnswers("response_id") Or lngCurrentSubItemID <> rsAnswers("subitem_id") Then
  953.                                 strUniqueRespondentsPerAnswerCollection = IncrementCountInCollectionPipe(strUniqueRespondentsPerAnswerCollection, CStr(rsAnswers("subitem_id")))
  954.                             End If
  955.                             lngCurrentResponseID = rsAnswers("response_id")
  956.                             lngCurrentSubItemID = rsAnswers("subitem_id")
  957.                         End If
  958.                     End If
  959.  
  960.                     rsAnswers.MoveNext
  961.                     If rsAnswers.EOF = True Then
  962.                         Exit Do
  963.                     End If
  964.                 Loop
  965.             End If
  966.  
  967.         ElseIf lngItemTypeID = SUR_ITEM_MATRIX_RATING_SCALE Then
  968.             'Get the beginning and ending numbers for the rating scale
  969.             lngBeginningNumber = rsQuestions("minimum_value")
  970.             lngEndingNumber = rsQuestions("maximum_value")
  971.  
  972.             'Record the total number of answers, which is needed to correctly render matrix questions below
  973.             lngAnswerCount = lngEndingNumber - lngBeginningNumber + 1
  974.  
  975.             'Build a string of name/value pairs by looping from the beginning to the ending value of the rating scale.
  976.             'This string is logically a collection of name/value pairs separated by semi-colons (;) in the format
  977.             'SIDxxxAIDyyy;6;SIDxxxAIDyyy;7;SIDxxxAIDyyy;1, where xxx represents the subitem ID and yyy represents the
  978.             'the numeric value of the number in the rating scale.  This section sets the collection to values of 0 for
  979.             'all possible answers.  Also create a collection of subitem ID's to subitem text for displaying the results.
  980.             Do While CLng(lngBeginningNumber) <= CLng(lngEndingNumber)
  981.                 'The outer loop goes through the answer ID's (the columns), while the inner loop goes through the subitems
  982.                 '(the rows).
  983.                 rsSubItems.MoveFirst
  984.                 Do While Not rsSubItems.EOF
  985.                     'When adding each possible answer to the collection, initialize to 0
  986.                     strAnswersCollection = strAnswersCollection & "SID" & rsSubItems("subitem_id") & "AID" & lngBeginningNumber & "|0|"
  987.                     rsSubItems.MoveNext
  988.                 Loop
  989.  
  990.                 'Add all of the ID/Value pairs to another collection for display purposes later
  991.                 strAnswerIDsCollection = strAnswerIDsCollection & CStr(lngBeginningNumber) & "|" & CStr(lngBeginningNumber) & "|"
  992.  
  993.                 'Incremenet the current number in the rating scale
  994.                 lngBeginningNumber = lngBeginningNumber + 1
  995.             Loop
  996.  
  997.             'Initialize the collection for tracking the number of responses per subitem
  998.             rsSubItems.MoveFirst
  999.             Do While Not rsSubItems.EOF
  1000.                 'When adding each possible answer to the collection, initialize to 0
  1001.                 strUniqueRespondentsPerAnswerCollection = strUniqueRespondentsPerAnswerCollection & rsSubItems("subitem_id") & "|0|"
  1002.                 rsSubItems.MoveNext
  1003.             Loop
  1004.  
  1005.             'Add one more name/value pair to the collection for null answers.
  1006.             strAnswersCollection = strAnswersCollection & SUR_ANSWER_TEXT_NULL & "|0|"
  1007.  
  1008.             'Call a function that strips off all extra semi-colons
  1009.             strAnswersCollection = CleanAnswersCollectionPipe(strAnswersCollection)
  1010.             strAnswerIDsCollection = CleanAnswersCollectionPipe(strAnswerIDsCollection)
  1011.             strUniqueRespondentsPerAnswerCollection = CleanAnswersCollectionPipe(strUniqueRespondentsPerAnswerCollection)
  1012.  
  1013.             'Loop through the actual answers and increment the counts for each.  The counts are incremented in
  1014.             'the helper function, IncrementCountInCollectionPipe
  1015.             If Not rsAnswers.EOF Then
  1016.                 Do While lngItemID = rsAnswers("item_id")
  1017.                     'Track the number of responses
  1018.                     lngResponseCount = lngResponseCount + 1
  1019.  
  1020.                     'Track the number of unique respondents
  1021.                     If lngCurrentResponseID <> rsAnswers("response_id") Then
  1022.                         lngUniqueRespondentCount = lngUniqueRespondentCount + 1
  1023.                         lngCurrentResponseID = rsAnswers("response_id")
  1024.                     End If
  1025.  
  1026.                     'Increment the appropriate subitem in the collection.  If the subitem_id is Null, record a non-response
  1027.                     If CStr(rsAnswers("ResponseAnswerID")) = CStr(SUR_ANSWER_ID_NULL) Then
  1028.                         strAnswersCollection = IncrementCountInCollectionPipe(strAnswersCollection, SUR_ANSWER_TEXT_NULL)
  1029.                     Else 'An ID response was recorded
  1030.                         strAnswersCollection = IncrementCountInCollectionPipe(strAnswersCollection, "SID" & CStr(rsAnswers("subitem_id")) & "AID" & CStr(rsAnswers("ResponseAnswerID")))
  1031.  
  1032.                         'Track the number of unique respondents per row by adding one to the count for each response.
  1033.                         strUniqueRespondentsPerAnswerCollection = IncrementCountInCollectionPipe(strUniqueRespondentsPerAnswerCollection, CStr(rsAnswers("subitem_id")))
  1034.                     End If
  1035.  
  1036.                     rsAnswers.MoveNext
  1037.                     If rsAnswers.EOF = True Then
  1038.                         Exit Do
  1039.                     End If
  1040.                 Loop
  1041.             End If
  1042.  
  1043.             'Move to the next question
  1044.             rsQuestions.MoveNext
  1045.         ElseIf lngItemTypeID = SUR_ITEM_OPEN_ENDED_ONE_LINE Or lngItemTypeID = SUR_ITEM_OPEN_ENDED_COMMENTS_BOX Or lngItemTypeID = SUR_ITEM_DATE Or lngItemTypeID = SUR_ITEM_NUMBER Or lngItemTypeID = SUR_ITEM_DATABASE_DROPDOWN Then 'Text
  1046.             'Get the number of responses and non-responses
  1047.             lngSkippedTotal = 0
  1048.             lngTextResponseCount = 0
  1049.             lngNumberTotal = 0
  1050.  
  1051.             'If there are no more answers, the next question was not answered.
  1052.             If Not rsAnswers.EOF Then
  1053.                 'Loop through the actual answers and count them.
  1054.                 Do While lngItemID = rsAnswers("item_id")
  1055.                     'Track the number of responses
  1056.                     lngResponseCount = lngResponseCount + 1
  1057.  
  1058.                     'Track the number of unique respondents
  1059.                     lngUniqueRespondentCount = lngUniqueRespondentCount + 1
  1060.  
  1061.                     'Calculate the number of skipped responses
  1062.                     If rsAnswers("ResponseAnswerText") = SUR_ANSWER_TEXT_NULL Then
  1063.                         lngSkippedTotal = lngSkippedTotal + 1
  1064.                     Else
  1065.                         lngTextResponseCount = lngTextResponseCount + 1
  1066.  
  1067.                         'For number questions, track the total
  1068.                         If lngItemTypeID = SUR_ITEM_NUMBER Then
  1069.                             lngNumberTotal = lngNumberTotal + CLng(rsAnswers("ResponseAnswerText"))
  1070.                         End If
  1071.                     End If
  1072.                     rsAnswers.MoveNext
  1073.                     If rsAnswers.EOF = True Then
  1074.                         Exit Do
  1075.                     End If
  1076.                 Loop
  1077.             Else
  1078.                 'There are no answers at all to this item, so set the response counts equal to the total number of
  1079.                 'respondents in order to trigger a display of "No results" below.
  1080.                 lngSkippedTotal = lngFilteredRespondents
  1081.                 lngResponseCount = lngFilteredRespondents
  1082.             End If
  1083.  
  1084.             'Advance to the next question
  1085.             rsQuestions.MoveNext
  1086.  
  1087.         Else
  1088.             'Should never get here.  All non-question items (image, heading, HTML, etc.) were filtered out in
  1089.             'the query above.
  1090.         End If
  1091. %>
  1092.         <table cellpadding="0" width="740" border="0" cellspacing="0" class="LightGrayBackgroundColor">
  1093.             <tr>
  1094.                 <td>
  1095.                     <table border="0" width="736" cellpadding="2" cellspacing="1">
  1096.                         <tr>
  1097. <%
  1098.                             Select Case lngItemTypeID
  1099.                                 Case SUR_ITEM_MATRIX_TEXT_BOXES, SUR_ITEM_CONSTANT_SUM, SUR_ITEM_RANKING, SUR_ITEM_NUMBER
  1100.                                     lngColspanCount = 3
  1101.                                 Case SUR_ITEM_SINGLE_SELECT_DROPDOWN, SUR_ITEM_SINGLE_SELECT_OPTIONS, SUR_ITEM_MULTISELECT_CHECKBOXES, SUR_ITEM_YES_NO, SUR_ITEM_TRUE_FALSE, SUR_ITEM_OPEN_ENDED_ONE_OR_MORE_LINES
  1102.                                     lngColspanCount = 4
  1103.                                 Case SUR_ITEM_OPEN_ENDED_ONE_LINE, SUR_ITEM_DATABASE_DROPDOWN, SUR_ITEM_OPEN_ENDED_COMMENTS_BOX, SUR_ITEM_DATE
  1104.                                     lngColspanCount = 2
  1105.                                 Case SUR_ITEM_MATRIX_SINGLE_SELECT_OPTIONS, SUR_ITEM_MATRIX_MULTISELECT_CHECKBOXES
  1106.                                     lngColspanCount = 3 + lngAnswerCount - 1
  1107.                                 Case SUR_ITEM_MATRIX_RATING_SCALE
  1108.                                     lngColspanCount = 3 + lngAnswerCount
  1109.                             End Select
  1110. %>
  1111.                             <td colspan="<%=lngColspanCount + lngAnswerCount%>" valign="center" width="736">
  1112.                                 <table border="0" width="732" cellpadding="0" cellspacing="0">
  1113.                                     <tr>
  1114.                                         <td valign="center" width="36" height="36">
  1115.                                             <span class="ReportAnswerNumberSpanStyle"><%=lngQuestionNumber%>.</span>
  1116.                                         </td>
  1117.                                         <td valign="center" width="696">
  1118.                                             <span class="Normal"><%=strItemText%><br></span>
  1119.                                         </td>
  1120.                                     </tr>
  1121.                                 </table>
  1122.                             </td>
  1123.                         </tr>
  1124. <%
  1125.                         Select Case lngItemTypeID
  1126.                             Case SUR_ITEM_CONSTANT_SUM, SUR_ITEM_RANKING, SUR_ITEM_NUMBER
  1127. %>
  1128.                                 <tr>
  1129.                                     <td width="195" class="WhiteBackgroundColor"> </td>
  1130.                                     <td width="474" class="WhiteBackgroundColor"> </td>
  1131.                                     <td width="65" align="center" class="WhiteBackgroundColor">
  1132.                                         <span class="NormalBold">
  1133. <%
  1134.                                             'Change the header depending on the question type
  1135.                                             If lngItemTypeID = SUR_ITEM_RANKING Then
  1136. %>
  1137.                                                 Ranking Average
  1138. <%
  1139.                                             Else
  1140. %>
  1141.                                                 Response Average
  1142. <%
  1143.                                             End If
  1144. %>
  1145.                                         </span>
  1146.                                     </td>
  1147.                                 </tr>
  1148. <%
  1149.                             Case SUR_ITEM_OPEN_ENDED_ONE_OR_MORE_LINES, SUR_ITEM_SINGLE_SELECT_DROPDOWN, SUR_ITEM_SINGLE_SELECT_OPTIONS, SUR_ITEM_MULTISELECT_CHECKBOXES, SUR_ITEM_YES_NO, SUR_ITEM_TRUE_FALSE
  1150. %>
  1151.                                 <tr>
  1152.                                     <td width="606" colspan="2" class="WhiteBackgroundColor"> </td>
  1153.                                     <td width="65" align="center" class="WhiteBackgroundColor">
  1154.                                         <span class="NormalBold">Response Total</span>
  1155.                                     </td>
  1156.                                     <td width="65" align="center" class="WhiteBackgroundColor">
  1157.                                         <span class="NormalBold">Response Percent</span>
  1158.                                     </td>
  1159.                                 </tr>
  1160. <%
  1161.                             Case SUR_ITEM_OPEN_ENDED_ONE_LINE, SUR_ITEM_OPEN_ENDED_COMMENTS_BOX, SUR_ITEM_DATE, SUR_ITEM_DATABASE_DROPDOWN
  1162.  
  1163.                             Case SUR_ITEM_MATRIX_SINGLE_SELECT_OPTIONS, SUR_ITEM_MATRIX_MULTISELECT_CHECKBOXES
  1164. %>
  1165.                                 <tr>
  1166.                                     <td width="195" class="WhiteBackgroundColor"> </td>
  1167. <%
  1168.  
  1169.                                     'Create an array of all the name value pairs for the answers
  1170.                                     vaAnswers = Split(strAnswerIDsCollection, "|")
  1171.  
  1172.                                     'Loop through the answers array.  Do a Step 2 because every other item in the array is the value
  1173.                                     'for the item.
  1174.                                     For i = 0 To UBound(vaAnswers) Step 2
  1175. %>
  1176.                                         <td width="<%=476/lngAnswerCount%>" align="center" class="WhiteBackgroundColor"><span class="NormalBold"><%=GetValueFromCollectionPipe(strAnswerIDsCollection, vaAnswers(i))%></span></td>
  1177. <%
  1178.                                     Next
  1179. %>
  1180.                                     <td align="center" width="65" class="WhiteBackgroundColor">
  1181.                                         <span class="NormalBold">
  1182.                                                 Response Total
  1183.                                         </span>
  1184.                                     </td>
  1185.                                 </tr>
  1186. <%
  1187.                             Case SUR_ITEM_MATRIX_RATING_SCALE
  1188. %>
  1189.                                 <tr>
  1190.                                     <td width="195" class="WhiteBackgroundColor"> </td>
  1191. <%
  1192.  
  1193.                                     'Create an array of all the name value pairs for the answers
  1194.                                     vaAnswers = Split(strAnswerIDsCollection, "|")
  1195.  
  1196.                                     'Loop through the answers array.  Do a Step 2 because every other item in the array is the value
  1197.                                     'for the item.
  1198.                                     For i = 0 To UBound(vaAnswers) Step 2
  1199. %>
  1200.                                         <td width="<%=411/lngAnswerCount%>" align="center" class="WhiteBackgroundColor"><span class="NormalBold"><%=GetValueFromCollectionPipe(strAnswerIDsCollection, vaAnswers(i))%></span></td>
  1201. <%
  1202.                                     Next
  1203. %>
  1204.                                     <td align="center" width="65" class="WhiteBackgroundColor">
  1205.                                         <span class="NormalBold">
  1206.                                                 Response Total
  1207.                                         </span>
  1208.                                     </td>
  1209.                                     <td align="center" width="65" class="WhiteBackgroundColor">
  1210.                                         <span class="NormalBold">
  1211.                                                 Response Average
  1212.                                         </span>
  1213.                                     </td>
  1214.                                 </tr>
  1215. <%
  1216.                             Case SUR_ITEM_MATRIX_TEXT_BOXES
  1217. %>
  1218.                                 <tr>
  1219.                                     <td width="195" class="WhiteBackgroundColor"> </td>
  1220.                                     <td width="476" class="WhiteBackgroundColor"> </td>
  1221.                                     <td align="center" width="65" class="WhiteBackgroundColor">
  1222.                                         <span class="NormalBold">Response Total</span>
  1223.                                     </td>
  1224.                                 </tr>
  1225. <%
  1226.                         End Select
  1227.  
  1228.                         'Set up the first row (headers) for each answer.
  1229.                         If lngItemTypeID = SUR_ITEM_OPEN_ENDED_ONE_LINE Or lngItemTypeID = SUR_ITEM_OPEN_ENDED_COMMENTS_BOX Or lngItemTypeID = SUR_ITEM_DATE Or lngItemTypeID = SUR_ITEM_DATABASE_DROPDOWN Then 'Text
  1230. %>
  1231.                             <tr>
  1232.                                 <td colspan="2" align="right" class="WhiteBackgroundColor">
  1233. <%
  1234.                                     'Either display a link to get to the answers, or, if there are no answers
  1235.                                     'to this question, display a message that says no answers
  1236.                                     If lngTextResponseCount > 0 Then
  1237.                                         'Display an image if the user selected this response
  1238.                                         If flgHighlightResponses = True And InStr(strHighlightResponses, "ItemID" & lngItemID) > 0 Then
  1239. %>
  1240.                                             <img alt="You submitted this response" border="0" src="<%=SUR_HIGHLIGHT_RESPONSES_IMAGE_PATH%>">
  1241. <%
  1242.                                         End If
  1243.  
  1244.                                         'Make sure that if the user is using report sharing, they still have access
  1245.                                         'to view the open ended responses.
  1246.                                         If CanUserViewOpenEndedResponses() = True Then
  1247. %>
  1248.                                             <span class="Normal">View responses to this question</span>
  1249.                                             <a href="ResultsText.asp?DisplayHeader=<%=Request.QueryString("DisplayHeader")%>&ItemID=<%=lngItemID%>&ItemNumber=<%=lngQuestionNumber%>&SurveyID=<%=lngSurveyID%>&Type=Text&ItemTypeID=<%=lngItemTypeID%>"><img alt="View individual responses to this question" border="0" src="Resources/Buttons/ViewSmall.gif" onMouseOver="this.style.cursor='hand'"></a>  
  1250. <%
  1251.                                         Else
  1252. %>
  1253.                                             <span class="Normal">You do not have permission to view the responses to this question.</span>
  1254. <%
  1255.                                         End If
  1256.                                     Else
  1257. %>
  1258.                                         <span class="Normal">No responses were entered for this question.</span>  
  1259. <%
  1260.                                     End If
  1261.  
  1262. %>
  1263.                                 </td>
  1264.                             </tr>
  1265. <%
  1266.                         ElseIf lngItemTypeID = SUR_ITEM_NUMBER Then 'Text
  1267. %>
  1268.                             <tr>
  1269. <%
  1270.                                 'Either display a link to get to the answers, or, if there are no answers
  1271.                                 'to this question, display a message that says no answers
  1272.                                 If lngTextResponseCount > 0 Then
  1273. %>
  1274.                                     <td colspan="2" align="right" class="WhiteBackgroundColor">
  1275. <%
  1276.                                         'Display an image if the user selected this response
  1277.                                         If flgHighlightResponses = True And InStr(strHighlightResponses, "ItemID" & lngItemID) > 0 Then
  1278. %>
  1279.                                             <img alt="You submitted this response" border="0" src="<%=SUR_HIGHLIGHT_RESPONSES_IMAGE_PATH%>">
  1280. <%
  1281.                                         End If
  1282.  
  1283.                                         'Make sure that if the user is using report sharing, they still have access
  1284.                                         'to view the open ended responses.
  1285.                                         If CanUserViewOpenEndedResponses() = True Then
  1286. %>
  1287.                                             <span class="Normal">View responses to this question</span>
  1288.                                             <a href="ResultsText.asp?DisplayHeader=<%=Request.QueryString("DisplayHeader")%>&ItemID=<%=lngItemID%>&ItemNumber=<%=lngQuestionNumber%>&SurveyID=<%=lngSurveyID%>&Type=Text&ItemTypeID=<%=lngItemTypeID%>"><img alt="View individual responses to this question" border="0" src="Resources/Buttons/ViewSmall.gif" onMouseOver="this.style.cursor='hand'"></a>  
  1289. <%
  1290.                                         Else
  1291. %>
  1292.                                             <span class="Normal">You do not have permission to view the responses to this question.</span>
  1293. <%
  1294.                                         End If
  1295. %>
  1296.                                     </td>
  1297.                                     <td align="center" class="WhiteBackgroundColor">
  1298.                                         <span class="NormalBold"><%=FormatNumber(lngNumberTotal/lngTextResponseCount, 1)%></span>
  1299.                                     </td>
  1300. <%
  1301.                                 Else
  1302. %>
  1303.                                     <td colspan="2" align="left" class="WhiteBackgroundColor">
  1304.                                         <span class="Normal">No responses were entered for this question.</span>  
  1305.                                     </td>
  1306.                                     <td align="center" class="WhiteBackgroundColor">
  1307.                                         <span class="NormalBold">N/A</span>
  1308.                                     </td>
  1309. <%
  1310.                                 End If
  1311. %>
  1312.                             </tr>
  1313. <%
  1314.                         ElseIf lngItemTypeID = SUR_ITEM_TRUE_FALSE Or lngItemTypeID = SUR_ITEM_YES_NO Or lngItemTypeID = SUR_ITEM_MULTISELECT_CHECKBOXES Or lngItemTypeID = SUR_ITEM_SINGLE_SELECT_DROPDOWN Or lngItemTypeID = SUR_ITEM_SINGLE_SELECT_OPTIONS Then
  1315.                             'This section displays the results for questions that have multiple pre-canned answer
  1316.                             'possibilities (checkboxes, dropdown, or radio buttons)
  1317.  
  1318.                             'Create an array of all the name value pairs for the answers
  1319.                             vaAnswers = Split(strAnswersCollection, "|")
  1320.  
  1321.                             'Get the total number of skipped items
  1322.                             For i = 0 To UBound(vaAnswers) Step 2
  1323.                                 If vaAnswers(i) = SUR_ANSWER_TEXT_NULL Then
  1324.                                     'If this entry is a null answer, it's a skipped answer, so record the total
  1325.                                     'number of skipped answers for display below
  1326.                                     lngSkippedTotal = CLng(GetValueFromCollectionPipe(strAnswersCollection, vaAnswers(i)))
  1327.                                 End If
  1328.                             Next
  1329.  
  1330.                             'Loop through the answers array.  Do a Step 2 because every other item in the array is the value
  1331.                             'for the item.
  1332.                             For i = 0 To UBound(vaAnswers) Step 2
  1333.                                 'Ignore the null response, which is a skipped question and was accounted for above
  1334.                                 If vaAnswers(i) <> SUR_ANSWER_TEXT_NULL Then
  1335. %>
  1336.                                     <tr>
  1337.                                         <td width="195" class="WhiteBackgroundColor">
  1338.                                             <span class="Normal">
  1339. <%
  1340.                                             'Display the "Other" responses
  1341.                                             If vaAnswers(i) = SUR_ANSWER_TEXT_OTHER_SELECTED Then
  1342. %>
  1343.                                                 <%=strOtherText%>
  1344. <%
  1345.                                                 If CLng(vaAnswers(i + 1)) > 0 And CanUserViewOpenEndedResponses() = True Then
  1346. %>
  1347.                                                     <a href="ResultsText.asp?DisplayHeader=<%=Request.QueryString("DisplayHeader")%>&ItemID=<%=lngItemID%>&ItemNumber=<%=lngQuestionNumber%>&SurveyID=<%=lngSurveyID%>&Type=Other&ItemTypeID=<%=lngItemTypeID%>"><img alt="View individual responses to this question" border="0" src="Resources/Buttons/ViewSmall.gif" onMouseOver="this.style.cursor='hand'"></a>
  1348. <%
  1349.                                                 End If
  1350.  
  1351.                                                 'Display an image if the user selected this response
  1352.                                                 If flgHighlightResponses = True And InStr(strHighlightResponses, "ItemID" & lngItemID & SUR_ANSWER_TEXT_OTHER_SELECTED) > 0 Then
  1353. %>
  1354.                                                     <img alt="You submitted this response" border="0" src="<%=SUR_HIGHLIGHT_RESPONSES_IMAGE_PATH%>">
  1355. <%
  1356.                                                 End If
  1357.                                             Else
  1358.                                                 'Extract the answer text value that corresponds to the answer ID, and display
  1359.                                                 'the text
  1360.                                                 If lngItemTypeID = SUR_ITEM_TRUE_FALSE Or lngItemTypeID = SUR_ITEM_YES_NO Then
  1361. %>
  1362.                                                     <%=vaAnswers(i)%>
  1363. <%
  1364.                                                     'Display an image if the user selected this response
  1365.                                                     If flgHighlightResponses = True And InStr(strHighlightResponses, "ItemID" & lngItemID & vaAnswers(i)) > 0 Then
  1366. %>
  1367.                                                         <img alt="You submitted this response" border="0" src="<%=SUR_HIGHLIGHT_RESPONSES_IMAGE_PATH%>">
  1368. <%
  1369.                                                     End If
  1370.                                                 Else
  1371. %>
  1372.                                                     <%=GetValueFromCollectionPipe(strAnswerIDsCollection, vaAnswers(i))%>
  1373. <%
  1374.                                                     'Display an image if the user selected this response
  1375.                                                     If flgHighlightResponses = True And InStr(strHighlightResponses, "AnswerID" & vaAnswers(i)) > 0 Then
  1376. %>
  1377.                                                         <img alt="You submitted this response" border="0" src="<%=SUR_HIGHLIGHT_RESPONSES_IMAGE_PATH%>">
  1378. <%
  1379.                                                     End If
  1380.                                                 End If
  1381.                                             End If
  1382. %>
  1383.                                             </span>
  1384.                                         </td>
  1385.                                         <td valign="middle" width="405" align="left" class="WhiteBackgroundColor">
  1386. <%
  1387.                                             'Calculate the percentage.  When displaying the image, multiply times four, since the available
  1388.                                             'real estate is 400 pixels wide
  1389.                                             'If CLng(vaAnswers(i + 1)) = 0 Then
  1390.                                             If vaAnswers(i + 1) = "0" Then
  1391.                                                 lngPercentage = 0
  1392. %>
  1393.                                                 <img width="1" border="0" src="Resources/Images/InvisibleBar.gif" alt="Visual spacer" height="12">
  1394. <%
  1395.                                             Else
  1396.                                                 If lngUniqueRespondentCount - lngSkippedTotal = 0 Then
  1397.                                                     lngPercentage = 0
  1398.                                                 Else
  1399.                                                     lngPercentage = CLng((CLng(vaAnswers(i + 1))/(lngUniqueRespondentCount - lngSkippedTotal)) * 100)
  1400.                                                 End If
  1401. %>
  1402.                                                 <img width="<%=lngPercentage * 4%>" border="0" src="Resources/Images/Bar.gif" height="12" alt="Response equal to <%=lngPercentage%>">
  1403. <%
  1404.                                             End If
  1405. %>
  1406.                                         </td>
  1407.                                         <td align="center" class="WhiteBackgroundColor">
  1408.                                             <span class="NormalBold">
  1409.                                                 <%=CLng(vaAnswers(i + 1))%>
  1410.                                             </span>
  1411.                                         </td>
  1412.                                         <td align="center" class="WhiteBackgroundColor">
  1413.                                             <span class="NormalBold">
  1414.                                                 <%=lngPercentage%>%
  1415.                                             </span>
  1416.                                         </td>
  1417.                                     </tr>
  1418. <%
  1419.                                 End If
  1420.                             Next 'Loop through values
  1421.                         ElseIf lngItemTypeID = SUR_ITEM_MATRIX_TEXT_BOXES Then
  1422.                             'This section displays the results for questions that have multiple pre-canned answer
  1423.                             'possibilities (checkboxes, dropdown, or radio buttons)
  1424.  
  1425.                             'Create an array of all the name value pairs for the answers
  1426.                             vaAnswers = Split(strAnswersCollection, "|")
  1427.  
  1428.                             'Get the total number of skipped items
  1429.                             For i = 0 To UBound(vaAnswers) Step 2
  1430.                                 If vaAnswers(i) = SUR_ANSWER_TEXT_NULL Then
  1431.                                     'If this entry is a null answer, it's a skipped answer, so record the total
  1432.                                     'number of skipped answers for display below
  1433.                                     lngSkippedTotal = CLng(GetValueFromCollectionPipe(strAnswersCollection, vaAnswers(i)))
  1434.                                 End If
  1435.                             Next
  1436.  
  1437.                             'Loop through the answers array.  Do a Step 2 because every other item in the array is the value
  1438.                             'for the item.
  1439.                             For i = 0 To UBound(vaAnswers) Step 2
  1440.                                 'Ignore the null response, which is a skipped question and was accounted for above
  1441.                                 If vaAnswers(i) <> SUR_ANSWER_TEXT_NULL Then
  1442. %>
  1443.                                     <tr>
  1444.                                         <td colspan="2" height="22" class="WhiteBackgroundColor">
  1445.                                             <span class="Normal">
  1446. <%
  1447.                                             'Display the non-responses
  1448.                                             If vaAnswers(i) = SUR_ANSWER_TEXT_NULL Then
  1449. %>
  1450.                                                 <span class="NormalItalic"><%=SUR_ANSWER_NULL_DISPLAY%></span>
  1451. <%
  1452.                                             Else
  1453.                                                 'Only display the button that links to the details if there is at least one response
  1454.                                                 If CLng(vaAnswers(i + 1)) > 0 And CanUserViewOpenEndedResponses() = True Then
  1455. %>
  1456.                                                     <a href="ResultsText.asp?DisplayHeader=<%=Request.QueryString("DisplayHeader")%>&ItemID=<%=lngItemID%>&SubItemID=<%=Mid(vaAnswers(i), 4, Len(vaAnswers(i)) - 3)%>&SubItemText=<%=Server.URLEncode(GetValueFromCollectionPipe(strAnswerIDsCollection, vaAnswers(i)))%>&ItemNumber=<%=lngQuestionNumber%>&SurveyID=<%=lngSurveyID%>&Type=Text&ItemTypeID=<%=lngItemTypeID%>"><img alt="View individual responses to this question" border="0" src="Resources/Buttons/ViewSmall.gif" onMouseOver="this.style.cursor='hand'"></a>  
  1457. <%
  1458.                                                 End If
  1459. %>
  1460.                                                 <%=GetValueFromCollectionPipe(strAnswerIDsCollection, vaAnswers(i))%>
  1461. <%
  1462.                                                 'Only display the star if the user gave a response in this row
  1463.                                                 If flgHighlightResponses = True And InStr(strHighlightResponses, "SubItemID" & Mid(vaAnswers(i), 4, Len(vaAnswers(i)) - 3)) > 0 Then
  1464. %>
  1465.                                                     <img alt="You submitted this response" border="0" src="<%=SUR_HIGHLIGHT_RESPONSES_IMAGE_PATH%>">
  1466. <%
  1467.                                                 End If
  1468.                                             End If
  1469. %>
  1470.                                             </span>
  1471.                                         </td>
  1472.                                         <td align="center" class="WhiteBackgroundColor">
  1473.                                             <span class="NormalBold">
  1474.                                                 <%=CLng(vaAnswers(i + 1))%>
  1475.                                             </span>
  1476.                                         </td>
  1477.                                     </tr>
  1478. <%
  1479.                                 End If
  1480.                             Next 'Loop through values
  1481.                         ElseIf lngItemTypeID = SUR_ITEM_OPEN_ENDED_ONE_OR_MORE_LINES Then
  1482.                             'This section displays the results for questions that have multiple pre-canned answer
  1483.                             'possibilities (checkboxes, dropdown, or radio buttons)
  1484.  
  1485.                             'Create an array of all the name value pairs for the answers
  1486.                             vaAnswers = Split(strAnswersCollection, "|")
  1487.  
  1488.                             'Get the total number of skipped items
  1489.                             For i = 0 To UBound(vaAnswers) Step 2
  1490.                                 If vaAnswers(i) = SUR_ANSWER_TEXT_NULL Then
  1491.                                     'If this entry is a null answer, it's a skipped answer, so record the total
  1492.                                     'number of skipped answers for display below
  1493.                                     lngSkippedTotal = CLng(GetValueFromCollectionPipe(strAnswersCollection, vaAnswers(i)))
  1494.                                 End If
  1495.                             Next
  1496.  
  1497.                             'Loop through the answers array.  Do a Step 2 because every other item in the array is the value
  1498.                             'for the item.
  1499.                             For i = 0 To UBound(vaAnswers) Step 2
  1500.                                 'Ignore the null response, which is a skipped question and was accounted for above
  1501.                                 If vaAnswers(i) <> SUR_ANSWER_TEXT_NULL Then
  1502. %>
  1503.                                     <tr>
  1504.                                         <td width="195" class="WhiteBackgroundColor">
  1505.                                             <span class="Normal">
  1506. <%
  1507.                                             'Display the non-responses
  1508.                                             If vaAnswers(i) = SUR_ANSWER_TEXT_NULL Then
  1509. %>
  1510.                                                 <span class="NormalItalic"><%=SUR_ANSWER_NULL_DISPLAY%></span>
  1511. <%
  1512.                                             Else
  1513.                                                 'Only display the button with a link to the details if there was at least one answer entered
  1514.                                                 If CLng(vaAnswers(i + 1)) > 0 And CanUserViewOpenEndedResponses() = True Then
  1515. %>
  1516.                                                     <a href="ResultsText.asp?DisplayHeader=<%=Request.QueryString("DisplayHeader")%>&ItemID=<%=lngItemID%>&SubItemID=<%=Mid(vaAnswers(i), 4, Len(vaAnswers(i)) - 3)%>&SubItemText=<%=Server.URLEncode(GetValueFromCollectionPipe(strAnswerIDsCollection, vaAnswers(i)))%>&ItemNumber=<%=lngQuestionNumber%>&SurveyID=<%=lngSurveyID%>&Type=Text&ItemTypeID=<%=lngItemTypeID%>"><img alt="View individual responses to this question" border="0" src="Resources/Buttons/ViewSmall.gif" onMouseOver="this.style.cursor='hand'"></a>  
  1517. <%
  1518.                                                 End If
  1519. %>
  1520.                                                 <%=GetValueFromCollectionPipe(strAnswerIDsCollection, vaAnswers(i))%>
  1521. <%
  1522.                                                 'Only display the star if the user gave a response in this row
  1523.                                                 If flgHighlightResponses = True And InStr(strHighlightResponses, "SubItemID" & Mid(vaAnswers(i), 4)) > 0 Then
  1524. %>
  1525.                                                     <img alt="You submitted this response" border="0" src="<%=SUR_HIGHLIGHT_RESPONSES_IMAGE_PATH%>">
  1526. <%
  1527.                                                 End If
  1528.                                             End If
  1529. %>
  1530.                                             </span>
  1531.                                         </td>
  1532.                                         <td width="411" align="left" class="WhiteBackgroundColor">
  1533. <%
  1534.                                             'Calculate the percentage.  When displaying the image, multiply times four, since the available
  1535.                                             'real estate is 400 pixels wide
  1536.                                             If CLng(vaAnswers(i + 1)) = 0 Then
  1537.                                                 lngPercentage = 0
  1538. %>
  1539.                                                 <img width="1" border="0" src="Resources/Images/InvisibleBar.gif" height="12" alt="Visual spacer">
  1540. <%
  1541.                                             Else
  1542.                                                 lngPercentage = CLng((CLng(vaAnswers(i + 1))/(lngFilteredRespondents - lngSkippedTotal)) * 100)
  1543. %>
  1544.                                                 <img width="<%=lngPercentage * 4%>" border="0" src="Resources/Images/Bar.gif" height="12" alt="Response equal to <%=lngPercentage%>">
  1545. <%
  1546.                                             End If
  1547. %>
  1548.                                         </td>
  1549.                                         <td align="center" class="WhiteBackgroundColor">
  1550.                                             <span class="NormalBold">
  1551.                                                 <%=CLng(vaAnswers(i + 1))%>
  1552.                                             </span>
  1553.                                         </td>
  1554.                                         <td align="center" class="WhiteBackgroundColor">
  1555.                                             <span class="NormalBold">
  1556.                                                 <%=lngPercentage%>%
  1557.                                             </span>
  1558.                                         </td>
  1559.                                     </tr>
  1560. <%
  1561.                                 End If
  1562.                             Next 'Loop through values
  1563.                         ElseIf lngItemTypeID = SUR_ITEM_MATRIX_SINGLE_SELECT_OPTIONS Or lngItemTypeID = SUR_ITEM_MATRIX_MULTISELECT_CHECKBOXES Then
  1564.                             'This section displays the results for matrix questions with multiple predefined responses
  1565.  
  1566.                             'Get the total number of skipped items
  1567.                             lngSkippedTotal = CLng(GetValueFromCollectionPipe(strAnswersCollection, SUR_ANSWER_TEXT_NULL))
  1568.  
  1569.                             'Create an array of all the name value pairs for the answers
  1570.                             vaAnswers = Split(strAnswerIDsCollection, "|")
  1571.  
  1572.                             'Loop through the subitems collection, outputting the responses for each
  1573.                             rsSubItems.MoveFirst
  1574.                             Do While Not rsSubItems.EOF
  1575.                                 lngRowTotal = 0
  1576. %>
  1577.                                 <tr>
  1578.                                     <td align="left" valign="center" class="WhiteBackgroundColor">
  1579.                                         <span class="Normal"><%=rsSubItems("subitem_text")%></span>
  1580.                                     </td>
  1581. <%
  1582.                                     'Loop through the answers array.  Do a Step 2 because every other item in the array
  1583.                                     'is the value for the item.
  1584.                                     For i = 0 To UBound(vaAnswers) Step 2
  1585.                                         lngRowTotal = lngRowTotal + CLng(GetValueFromCollectionPipe(strAnswersCollection, "SID" & rsSubItems("subitem_id") & "AID" & vaAnswers(i)))
  1586. %>
  1587.                                         <td align="center" valign="center" class="WhiteBackgroundColor">
  1588.                                             <span class="Normal">
  1589. <%
  1590.                                                 'If 0, display 0%, to avoid dividing by zero.
  1591.                                                 If GetValueFromCollectionPipe(strUniqueRespondentsPerAnswerCollection, rsSubItems("subitem_id")) = "0" Then
  1592.                                                     Response.Write "0% (0)"
  1593.                                                 Else
  1594. %>
  1595.                                                     <%=CLng((CLng(GetValueFromCollectionPipe(strAnswersCollection, "SID" & rsSubItems("subitem_id") & "AID" & vaAnswers(i)))/(GetValueFromCollectionPipe(strUniqueRespondentsPerAnswerCollection, rsSubItems("subitem_id")))) * 100) & "%"%> (<%=GetValueFromCollectionPipe(strAnswersCollection, "SID" & rsSubItems("subitem_id") & "AID" & vaAnswers(i))%>)
  1596. <%
  1597.                                                 End If
  1598. %>
  1599.                                             </span>
  1600. <%
  1601.                                             'Display an image if the user selected this response
  1602.                                             If flgHighlightResponses = True And InStr(strHighlightResponses, "AnswerID" & vaAnswers(i) & "SubItemID" & rsSubItems("subitem_id")) > 0 Then
  1603. %>
  1604.                                                 <img alt="You submitted this response" border="0" src="<%=SUR_HIGHLIGHT_RESPONSES_IMAGE_PATH%>">
  1605. <%
  1606.                                             End If
  1607. %>
  1608.                                         </td>
  1609. <%
  1610.                                     Next
  1611. %>
  1612.                                     <td align="center" valign="center" class="WhiteBackgroundColor">
  1613.                                         <span class="NormalBold">
  1614. <%
  1615.                                             'The response total is the same as the row total for single select matrix questions,
  1616.                                             'while the response total for multiselect questions is the number of responses by
  1617.                                             'unique individuals, which was tracked in the section above.
  1618.                                             If lngItemTypeID = SUR_ITEM_MATRIX_SINGLE_SELECT_OPTIONS Then
  1619.                                                 Response.Write lngRowTotal
  1620.                                             Else 'SUR_ITEM_MATRIX_MULTISELECT_CHECKBOXES
  1621.                                                 Response.Write GetValueFromCollectionPipe(strUniqueRespondentsPerAnswerCollection, rsSubItems("subitem_id"))
  1622.                                             End If
  1623. %>
  1624.                                         </span>
  1625.                                     </td>
  1626.                                 </tr>
  1627. <%
  1628.                                 rsSubItems.MoveNext
  1629.                             Loop
  1630.                         ElseIf lngItemTypeID = SUR_ITEM_MATRIX_RATING_SCALE Then
  1631.                             'This section displays the results for matrix rating scale questions
  1632.  
  1633.                             'Get the total number of skipped items
  1634.                             lngSkippedTotal = CLng(GetValueFromCollectionPipe(strAnswersCollection, SUR_ANSWER_TEXT_NULL))
  1635.  
  1636.                             'Create an array of all the name value pairs for the answers
  1637.                             vaAnswers = Split(strAnswerIDsCollection, "|")
  1638.  
  1639.                             'Loop through the subitems collection, outputting the responses for each
  1640.                             rsSubItems.MoveFirst
  1641.                             Do While Not rsSubItems.EOF
  1642.                                 lngRowTotal = 0
  1643.                                 lngRowAverage = 0
  1644. %>
  1645.                                 <tr>
  1646.                                     <td align="left" valign="center" class="WhiteBackgroundColor">
  1647.                                         <span class="Normal"><%=rsSubItems("subitem_text")%></span>
  1648.                                     </td>
  1649. <%
  1650.                                     'Loop through the answers array.  Do a Step 2 because every other item in the array
  1651.                                     'is the value for the item.
  1652.                                     For i = 0 To UBound(vaAnswers) Step 2
  1653.                                         'Calculate the response total and the response average for this row
  1654.                                         lngRowTotal = lngRowTotal + CLng(GetValueFromCollectionPipe(strAnswersCollection, "SID" & rsSubItems("subitem_id") & "AID" & vaAnswers(i)))
  1655.                                         lngRowAverage = lngRowAverage + (CLng(CLng(GetValueFromCollectionPipe(strAnswersCollection, "SID" & rsSubItems("subitem_id") & "AID" & vaAnswers(i)))) * CLng(GetValueFromCollectionPipe(strAnswerIDsCollection, vaAnswers(i))))
  1656. %>
  1657.                                         <td align="center" valign="center" class="WhiteBackgroundColor">
  1658.                                             <span class="Normal">
  1659. <%
  1660.                                                 If GetValueFromCollectionPipe(strUniqueRespondentsPerAnswerCollection, rsSubItems("subitem_id")) = "0" Then
  1661.                                                     Response.Write "0% (0)"
  1662.                                                 Else
  1663. %>
  1664.                                                     <%=CLng((CLng(GetValueFromCollectionPipe(strAnswersCollection, "SID" & rsSubItems("subitem_id") & "AID" & vaAnswers(i)))/(GetValueFromCollectionPipe(strUniqueRespondentsPerAnswerCollection, rsSubItems("subitem_id")))) * 100) & "%"%> (<%=GetValueFromCollectionPipe(strAnswersCollection, "SID" & rsSubItems("subitem_id") & "AID" & vaAnswers(i))%>)
  1665. <%
  1666.                                                 End If
  1667.  
  1668.                                                 'Display an image if the user selected this response
  1669.                                                 If flgHighlightResponses = True And InStr(strHighlightResponses, "AnswerID" & vaAnswers(i) & "SubItemID" & rsSubItems("subitem_id")) > 0 Then
  1670. %>
  1671.                                                     <img alt="You submitted this response" border="0" src="<%=SUR_HIGHLIGHT_RESPONSES_IMAGE_PATH%>">
  1672. <%
  1673.                                                 End If
  1674. %>
  1675.                                             </span>
  1676.                                         </td>
  1677. <%
  1678.                                     Next
  1679. %>
  1680.                                     <td align="center" valign="center" class="WhiteBackgroundColor">
  1681.                                         <span class="NormalBold">
  1682. <%
  1683.                                             Response.Write lngRowTotal
  1684. %>
  1685.                                         </span>
  1686.                                     </td>
  1687.                                     <td align="center" valign="center" class="WhiteBackgroundColor">
  1688.                                         <span class="NormalBold">
  1689. <%
  1690.                                             If lngRowTotal = 0 Then
  1691.                                                 Response.Write "0"
  1692.                                             Else
  1693.                                                 Response.Write FormatNumber(lngRowAverage/lngRowTotal, 1)
  1694.                                             End If
  1695. %>
  1696.                                         </span>
  1697.                                     </td>
  1698.                                 </tr>
  1699. <%
  1700.                                 rsSubItems.MoveNext
  1701.                             Loop
  1702.                         ElseIf lngItemTypeID = SUR_ITEM_CONSTANT_SUM Or lngItemTypeID = SUR_ITEM_RANKING Then
  1703.                             'This section displays the results for questions that have multiple pre-canned answer
  1704.                             'possibilities (checkboxes, dropdown, or radio buttons)
  1705.  
  1706.                             'Create an array of all the name value pairs for the answers
  1707.                             vaAnswers = Split(strAnswersCollection, "|")
  1708.  
  1709.                             'Loop through the answers array and determine what the highest average is
  1710.                             lngHighestAverage = 0
  1711.                             For i = 0 To UBound(vaAnswers) Step 2
  1712.                                 'Get the denominator, and make sure it's not zero
  1713.                                 lngTemp = CLng(GetValueFromCollectionPipe(strUniqueRespondentsPerAnswerCollection, vaAnswers(i)))
  1714.                                 If lngTemp > 0 Then
  1715.                                     'Get the average for this row, and check to see if it's the highest so far
  1716.                                     lngTemp = FormatNumber(CLng(GetValueFromCollectionPipe(strAnswersCollection, vaAnswers(i)))/CLng(GetValueFromCollectionPipe(strUniqueRespondentsPerAnswerCollection, vaAnswers(i))), 1)
  1717.                                     If CLng(lngTemp) > CLng(lngHighestAverage) Then
  1718.                                         lngHighestAverage = lngTemp
  1719.                                     End If
  1720.                                 End If
  1721.                             Next
  1722.  
  1723.                             'Loop through the answers array.  Do a Step 2 because every other item in the array is the value
  1724.                             'for the item.
  1725.                             For i = 0 To UBound(vaAnswers) Step 2
  1726.                                 'Skip if at the NULL value
  1727.                                 If vaAnswers(i) = SUR_ANSWER_TEXT_NULL Then
  1728.                                     'If this entry is a null answer, it's a skipped answer, so record the total
  1729.                                     'number of skipped answers for display below
  1730.                                     lngSkippedTotal = CLng(GetValueFromCollectionPipe(strAnswersCollection, vaAnswers(i)))
  1731.                                 Else
  1732. %>
  1733.                                     <tr>
  1734.                                         <td class="WhiteBackgroundColor">
  1735.                                             <span class="Normal">
  1736.                                                 <%=GetValueFromCollectionPipe(strAnswerIDsCollection, vaAnswers(i))%>
  1737. <%
  1738.                                                 'Only display the star if the user gave a response in this row
  1739.                                                 If flgHighlightResponses = True And InStr(strHighlightResponses, "SubItemID" & Mid(vaAnswers(i), 4)) > 0 Then
  1740. %>
  1741.                                                     <img alt="You submitted this response" border="0" src="<%=SUR_HIGHLIGHT_RESPONSES_IMAGE_PATH%>">
  1742. <%
  1743.                                                 End If
  1744. %>
  1745.                                             </span>
  1746.                                         </td>
  1747.                                         <td class="WhiteBackgroundColor">
  1748. <%
  1749.                                             'Display a line bar based on relative response average
  1750.                                             If CLng(GetValueFromCollectionPipe(strUniqueRespondentsPerAnswerCollection, vaAnswers(i))) = 0 Then
  1751. %>
  1752.                                                 <img width="10" border="0" src="Resources/Images/InvisibleBar.gif" height="12" alt="Visual spacer">
  1753. <%
  1754.                                             Else
  1755.                                                 If lngItemTypeID = SUR_ITEM_CONSTANT_SUM Then
  1756.                                                     If lngHighestAverage = 0 Then
  1757. %>
  1758.                                                         <img alt="Bar graph result" width="<%=FormatNumber(466 * (CLng(GetValueFromCollectionPipe(strAnswersCollection, vaAnswers(i)))/CLng(GetValueFromCollectionPipe(strUniqueRespondentsPerAnswerCollection, vaAnswers(i)))), 0)%>" border="0" src="Resources/Images/Bar.gif" height="12">
  1759. <%
  1760.                                                     Else
  1761. %>
  1762.                                                         <img alt="Bar graph result" width="<%=FormatNumber(466 * (CLng(GetValueFromCollectionPipe(strAnswersCollection, vaAnswers(i)))/CLng(GetValueFromCollectionPipe(strUniqueRespondentsPerAnswerCollection, vaAnswers(i)))), 0)%>" border="0" src="Resources/Images/Bar.gif" height="12">
  1763. <%
  1764.                                                     End If
  1765.                                                 Else 'SUR_ITEM_RANKING
  1766.                                                     If lngHighestAverage = 0 Then
  1767. %>
  1768.                                                         <img alt="Bar graph result" width="<%=FormatNumber(466 * (CLng(GetValueFromCollectionPipe(strAnswersCollection, vaAnswers(i)))/CLng(GetValueFromCollectionPipe(strUniqueRespondentsPerAnswerCollection, vaAnswers(i))))/20, 0)%>" border="0" src="Resources/Images/Bar.gif" height="12">
  1769. <%
  1770.                                                     Else
  1771. %>
  1772.                                                         <img alt="Bar graph result" width="<%=FormatNumber(466 * (CLng(GetValueFromCollectionPipe(strAnswersCollection, vaAnswers(i)))/CLng(GetValueFromCollectionPipe(strUniqueRespondentsPerAnswerCollection, vaAnswers(i))))/20, 0)%>" border="0" src="Resources/Images/Bar.gif" height="12">
  1773. <%
  1774.                                                     End If
  1775.                                                 End If
  1776.                                             End If
  1777. %>
  1778.                                         </td>
  1779.                                         <td align="center" class="WhiteBackgroundColor">
  1780.                                             <span class="NormalBold">
  1781. <%
  1782.                                                 'Display the response average
  1783.                                                 If CLng(GetValueFromCollectionPipe(strUniqueRespondentsPerAnswerCollection, vaAnswers(i))) = 0 Then
  1784.                                                     Response.Write "0"
  1785.                                                 Else
  1786.                                                     Response.Write FormatNumber(CLng(GetValueFromCollectionPipe(strAnswersCollection, vaAnswers(i)))/CLng(GetValueFromCollectionPipe(strUniqueRespondentsPerAnswerCollection, vaAnswers(i))), 1)
  1787.                                                 End If
  1788. %>
  1789.                                             </span>
  1790.                                         </td>
  1791.                                     </tr>
  1792. <%
  1793.                                 End If
  1794.                             Next 'Loop through values
  1795.                         End If 'Check to see whether it's a text answer
  1796. %>
  1797.                         <tr>
  1798.                             <td height="22" colspan="<%=lngColspanCount - 1%>" align="right" class="WhiteBackgroundColor">
  1799.                                 <span class="NormalBold">Total Respondents</span> 
  1800.                             </td>
  1801.                             <td align="center" class="WhiteBackgroundColor">
  1802.                                 <span class="NormalBold">
  1803.                                 <%
  1804.                                 If (lngUniqueRespondentCount - lngSkippedTotal) < 0 then
  1805.                                 Response.Write "0"
  1806.                                 Else
  1807.                                 Response.Write (lngUniqueRespondentCount - lngSkippedTotal)
  1808.                                 End If
  1809.                                 '4/18/2006
  1810.                                 %>
  1811.                                 <%'=lngUniqueRespondentCount - lngSkippedTotal%></span>
  1812.                             </td>
  1813.                         </tr>
  1814. <%
  1815.  
  1816.                         If lngTotalPoints > 0 Then
  1817. %>
  1818.                             <tr>
  1819.                                 <td height="22" colspan="<%=lngColspanCount - 1%>" align="right" class="WhiteBackgroundColor">
  1820.                                     <span class="NormalBold">Average</span> 
  1821.                                 </td>
  1822.                                 <td align="center" class="WhiteBackgroundColor">
  1823.                                     <span class="NormalBold"><%=FormatNumber(lngTotalPoints/(lngUniqueRespondentCount - lngSkippedTotal), 1)%></span>
  1824.                                 </td>
  1825.                             </tr>
  1826.                             <tr>
  1827.                                 <td height="22" colspan="<%=lngColspanCount - 1%>" align="right" class="WhiteBackgroundColor">
  1828.                                     <span class="NormalBold">Weighted Average</span> 
  1829.                                 </td>
  1830.                                 <td align="center" class="WhiteBackgroundColor">
  1831.                                     <span class="NormalBold"><%=FormatNumber(lngTotalPoints/lngResponseCount, 1)%></span>
  1832.                                 </td>
  1833.                             </tr>
  1834. <%
  1835.                         End If
  1836. 'Response.Write " lngFilteredRespondents=" & lngFilteredRespondents  & " lngSkippedTotal = " & lngSkippedTotal & " lngUniqueRespondentCount = " & lngUniqueRespondentCount
  1837.  
  1838.                         'If any of the users skipped this question, display the number of users beneath the
  1839.                         'rest of the question
  1840.                         If (lngFilteredRespondents - lngUniqueRespondentCount + lngSkippedTotal) > 0 Then
  1841. %>
  1842.                             <tr>
  1843.                                 <td colspan="<%=lngColspanCount - 1%>" align="right" class="WhiteBackgroundColor">
  1844.                                     <span class="Normal">(skipped this question)</span> 
  1845.                                 </td>
  1846.                                 <td align="center" class="WhiteBackgroundColor">
  1847.                                     <span class="Normal">
  1848.                                     <%'4/18/2006%>
  1849.                                     <%
  1850.                                     If (lngFilteredRespondents - lngUniqueRespondentCount + lngSkippedTotal) > lngFilteredRespondents Then
  1851.                                         Response.Write lngSkippedTotal
  1852.                                     Else
  1853.                                         Response.Write lngFilteredRespondents - lngUniqueRespondentCount + lngSkippedTotal
  1854.                                     End If
  1855.                                     %>
  1856.                                     <%'=lngFilteredRespondents - lngUniqueRespondentCount + lngSkippedTotal%>
  1857.                                     </span>
  1858.                                 </td>
  1859.                             </tr>
  1860. <%
  1861.                         End If
  1862. 'Response.Write " lngFilteredRespondents=" & lngFilteredRespondents  & " lngSkippedTotal = " & lngSkippedTotal & " lngUniqueRespondentCount = " & lngUniqueRespondentCount
  1863.  
  1864. %>
  1865.                     </table>
  1866.                 </td>
  1867.             </tr>
  1868.         </table>
  1869. <%
  1870.         'Only add a line break if there's another question
  1871.         If Not rsQuestions.EOF = True Then
  1872. %>
  1873.             <br>
  1874. <%
  1875.         End If
  1876.  
  1877.         'If the subitems recordset is open, close it for the next iteration
  1878.         If lngItemTypeID = SUR_ITEM_CONSTANT_SUM Or lngItemTypeID = SUR_ITEM_RANKING Or lngItemTypeID = SUR_ITEM_MATRIX_SINGLE_SELECT_OPTIONS Or lngItemTypeID = SUR_ITEM_MATRIX_RATING_SCALE Or lngItemTypeID = SUR_ITEM_MATRIX_MULTISELECT_CHECKBOXES Or lngItemTypeID = SUR_ITEM_MATRIX_TEXT_BOXES Or lngItemTypeID = SUR_ITEM_OPEN_ENDED_ONE_OR_MORE_LINES Then
  1879.             rsSubItems.Close
  1880.         End If
  1881.  
  1882.         'Increment the item (question) number
  1883.         lngQuestionNumber = lngQuestionNumber + 1
  1884.  
  1885.     Loop
  1886. %>
  1887.     <!--#Include File="Include/FrameworkBottom_inc.asp"-->
  1888.  
  1889. </body>
  1890. </html>
  1891.  
  1892. <%
  1893.  
  1894.     'Clean up
  1895.     rsAnswers.Close
  1896.     Set rsAnswers = Nothing
  1897.     rsQuestions.Close
  1898.     Set rsQuestions = Nothing
  1899.     Set rsSubItems = Nothing
  1900.  
  1901.     'Ensure that the web server returns the page
  1902.     Response.Flush
  1903. %>
  1904.