home *** CD-ROM | disk | FTP | other *** search
/ bombers.k12.ar.us / bombers.k12.ar.us.tar / bombers.k12.ar.us / survey / ResultsText.asp < prev    next >
Text File  |  2006-11-29  |  11KB  |  304 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 displays all of the values for a text
  7. '                      question, which can be either an "other" type
  8. '                      question or a straight text question.
  9. '
  10. '   COPYRIGHT NOTICE                                
  11. '
  12. '   See attached Software License Agreement
  13. '
  14. '   (c) Copyright 2002 - 2006 by ClassApps.com.  All rights reserved.
  15. '***********************************************************************
  16. %>
  17. <!--#Include File="Include/Config_inc.asp"-->
  18. <!--#Include File="Include/SurveyUtility_inc.asp"-->
  19. <!--#Include File="Include/Utility_inc.asp"-->
  20. <!--#Include File="Include/Collection_inc.asp"-->
  21. <!--#Include File="Include/adovbs_inc.asp"-->
  22. <!--#Include File="Include/CurrentUser_inc.asp"-->
  23. <!--#Include File="Include/Constants_inc.asp"-->
  24. <!--#Include File="Include/ReportShare_inc.asp"-->
  25. <!--#Include File="Include/SurveySecurity_inc.asp"-->
  26. <!--#Include File="Include/SurveyReportFilter_inc.asp"-->
  27. <%
  28.     Dim strSQL
  29.     Dim rsAnswers
  30.     Dim strSurveyName
  31.     Dim lngResponseCount
  32.     Dim strDateLaunched
  33.     Dim strStatus
  34.     Dim lngAnswerNumber
  35.     Dim strMessage
  36.     Dim flgCanUserViewIndividualReport
  37.     Dim lngSurveyID
  38.     Dim strDisplayText
  39.     Dim lngCurrentResponseID
  40.     Dim strItemText
  41.     Dim strItemAlias
  42.     Dim lngFilteredRespondents
  43.     Dim strReportFilters
  44.     Dim lngItemTypeID
  45.         
  46.     'Initialization
  47.     Set rsAnswers = Server.CreateObject("ADODB.Recordset")
  48.     lngSurveyID = Request.QueryString("SurveyID")
  49.     lngAnswerNumber = 1
  50.     flgCanUserViewIndividualReport = CanUserViewIndividualReport(lngSurveyID)
  51.     lngFilteredRespondents = GetFilteredRespondentCount(lngSurveyID)
  52.  
  53.     'Get all the items for this survey
  54.     If Request.QueryString("Type") = "Other" Then
  55.         strMessage = "The answers listed below are all those inputted for the 'Other' selection for the specified question.  The rest of the results are visible on the Results Overview screen."
  56.         strSQL = "SELECT title, launched_date, closed_date, status, item_type_id, " & _
  57.                     "r.response_id As ResponseID, ra.other_text As DisplayText, item_text, item_alias " & _
  58.                     "FROM sur_survey s, sur_item i, sur_survey_to_item_mapping m, sur_response r, sur_response_answer ra " & _
  59.                     "WHERE i.item_id = m.item_id " & _
  60.                     "AND s.survey_id = m.survey_id " & _
  61.                     "AND ra.item_id = i.item_id " & _
  62.                     "AND r.response_id = ra.response_id " & _
  63.                     "AND i.item_id = " & Request.QueryString("ItemID") & _
  64.                     " AND ra.answer_text " &  SQLEncodeLongTextEquality(SUR_ANSWER_TEXT_OTHER_SELECTED)
  65.         'If there are report filters, display only the data from questions that match the filter criteria
  66.         strReportFilters = GetFilteredResponseList(lngSurveyID)
  67.         If CStr(strReportFilters) <> SUR_REPORT_FILTER_NO_ACTIVE_FILTERS Then
  68.             strSQL = strSQL & " AND ra.response_id IN(" & strReportFilters & ")"
  69.         End If
  70.         strSQL = strSQL & " ORDER BY r.response_start_date, r.response_id, m.order_number"
  71.     Else 'Type = Text
  72.         strMessage = "The answers listed below are all those inputted for the specified question.  Because this type of question is not quantitative, only a listing of answers is provided."
  73.         strSQL = "SELECT title, username, launched_date, closed_date, status, item_type_id, " & _
  74.                     "r.response_id As ResponseID, item_alias, item_text, answer_text As DisplayText " & _
  75.                     "FROM sur_survey s, sur_item i, sur_survey_to_item_mapping m, sur_response r, sur_response_answer ra " & _
  76.                     "WHERE i.item_id = m.item_id " & _
  77.                     "AND s.survey_id = m.survey_id " & _
  78.                     "AND ra.item_id = i.item_id " & _
  79.                     "AND r.response_id = ra.response_id " & _
  80.                     "AND ra.item_id = " & Request.QueryString("ItemID")
  81.         'If a subitem ID was passed to this page, filter for only the answers for that subitem
  82.         If Len(Request.QueryString("SubItemID")) > 0 Then                    
  83.             strSQL = strSQL & " AND ra.subitem_id = " & Request.QueryString("SubItemID")
  84.         End If
  85.         'If there are report filters, display only the data from questions that match the filter criteria
  86.         strReportFilters = GetFilteredResponseList(lngSurveyID)
  87.         If CStr(strReportFilters) <> SUR_REPORT_FILTER_NO_ACTIVE_FILTERS Then
  88.             strSQL = strSQL & " AND ra.response_id IN(" & strReportFilters & ")"
  89.         End If
  90.         strSQL = strSQL & " ORDER BY r.response_start_date, r.response_id, m.order_number"
  91.     End If
  92.  
  93.     'Open the recordset, and store some of the values in local variables    
  94.     rsAnswers.Open ConvertSQL(strSQL), SURVEY_APP_CONNECTION, adOpenDynamic, , adCmdText
  95.     strSurveyName = rsAnswers("title")
  96.     strDateLaunched = CustomDateFormatDisplay(DateValue(rsAnswers("launched_date")))
  97.     strStatus = rsAnswers("status")
  98. %>
  99. <html>
  100. <head>
  101.     <title>Survey Results -- Details</title>
  102.     <link rel="stylesheet" href="Resources/StyleSheet/SurveyStyle.css">
  103. </head>
  104. <body class="MainBodyStyle">
  105.  
  106. <!--#Include File="Include/FrameworkTop_inc.asp"-->
  107.  
  108. <table border="0" cellspacing="0" cellpadding="0" width="754" class="MediumBlueBackgroundColor">
  109.     <tr>
  110.         <td height="36" valign="center">
  111.               <span class="H1HeadingStyle"><a name="skipnav" tabindex="1">Survey Results -- Details</a></span>
  112.         </td>
  113.         <td valign="middle" align="right">
  114.             <a href="ResultsOverview.asp?DisplayHeader=<%=Request.QueryString("DisplayHeader")%>&SurveyID=<%=lngSurveyID%>"><img border="0" alt="View summary results for this survey" name="btnResultsOverview" src="Resources/Buttons/ResultsOverview.gif"></a>
  115.         </td>
  116.         <td width="7"></td>
  117.     </tr>
  118. </table>
  119.  
  120. <!--#Include File="Include/FrameworkTop2_inc.asp"-->
  121.  
  122. <table border="0" cellpadding="0" cellspacing="0" width="740" class="WhiteBackgroundColor">
  123.     <tr>
  124.         <td width="740">
  125.             <table border="0" width="740" cellpadding="4" cellspacing="0" class="WhiteBackgroundColor">
  126.                 <tr class="LightGrayBackgroundColor">
  127.                     <td width="1"></td>
  128.                     <td colspan="5" align="left" height="36">
  129.                         <span class="H2HeadingStyle"><%=strSurveyName%></span>
  130.                     </td>
  131.                     <td width="1"></td>
  132.                 </tr>
  133.                 <tr>
  134.                     <td width="1" rowspan="30"></td>
  135.                     <td width="110">
  136.                         <span class="NormalBold">Respondents:</span>
  137.                     </td>
  138.                     <td width="258">
  139.                         <span class="Normal"><%=lngFilteredRespondents%></span>
  140.                     </td>
  141.                     <td width="110">
  142.                         <span class="NormalBold">Status:</span>
  143.                     </td>
  144.                     <td colspan="2" width="258">
  145.                         <span class="Normal"><%=rsAnswers("status")%></span>
  146.                     </td>
  147.                     <td width="1" rowspan="30"></td>
  148.                 </tr>
  149.                 <tr>
  150.                     <td>
  151.                         <span class="NormalBold">Launched Date:</span>
  152.                     </td>
  153.                     <td>
  154.                         <span class="Normal"><%=CustomDateFormatDisplay(DateValue(rsAnswers("launched_date")))%></span>
  155.                     </td>
  156.                     <td>
  157.                         <span class="NormalBold">Closed Date:</span>
  158.                     </td>
  159.                     <td colspan="2">
  160.                         <span class="Normal">
  161. <%
  162.                             If Len(rsAnswers("closed_date")) > 0 Then
  163.                                 Response.Write CustomDateFormatDisplay(DateValue(rsAnswers("closed_date")))
  164.                             Else
  165.                                 Response.Write "N/A"
  166.                             End If
  167. %>
  168.                         </span>
  169.                     </td>
  170.                 </tr>
  171.             </table>
  172.         </td>
  173.     </tr>
  174. </table>
  175. <br>
  176.  
  177. <table border="0" cellpadding="0" cellspacing="0" width="740" class="LightGrayBackgroundColor"><tr><td>
  178. <table border="0" cellpadding="4" cellspacing="1" width="722">
  179.     <tr>
  180.         <td colspan="2">
  181.             <table border="0" width="658" cellpadding="3" cellspacing="0">
  182.                 <tr>
  183.                     <td valign="top" width="35">
  184.                         <span class="ReportAnswerNumberSpanStyle"><%=Request.QueryString("ItemNumber")%>.</span>
  185.                     </td>
  186.                     <td valign="center" width="623">
  187. <%
  188.                         'If a question alias was supplied, use that instead of the question.  
  189.                         'Otherwise, use the actual question text.
  190.                         strItemText = Trim(rsAnswers("item_text"))
  191.                         strItemAlias = RemoveLineFeeds(Trim(rsAnswers("item_alias")))
  192.                         If Len(strItemAlias) > 0 Then
  193.                             strItemText = strItemAlias
  194.                         End If
  195.                         strItemText = RemovePipeTokens(strItemText)
  196. %>                                            
  197.                         <span class="Normal"><%=strItemText%><br></span>
  198. <%
  199.                         If CLng(Request.QueryString("ItemTypeID")) = SUR_ITEM_MATRIX_TEXT_BOXES Then
  200. %>
  201.                             <span class="InlineHelpSpanStyle">Prompt: <%=Request.QueryString("SubItemText")%></span>
  202. <%
  203.                         End If
  204. %>
  205.                     </td>
  206.                 </tr>
  207.             </table>
  208.         </td>
  209.         <td width="60" align="center">
  210.             <span class="NormalBold">Full Response</span>
  211.         </td>
  212.     </tr>
  213.  
  214. <%
  215.     Do While Not rsAnswers.EOF
  216.         If Request.Querystring("Type") = "Other" Or (Request.Querystring("Type") = "Text" And rsAnswers("DisplayText") <> SUR_ANSWER_TEXT_NULL) Then
  217.             'Initialize variables used for displaying each response
  218.             strDisplayText = ""
  219.             lngCurrentResponseID = rsAnswers("ResponseID")
  220.             lngItemTypeID = rsAnswers("item_type_id")
  221.                                     
  222.             'Some question types can contain multiple rows in the recordset.  Loop for each 
  223.             'response and combine all answers from the same response onto the same line in the display.
  224.             Do While Not rsAnswers.EOF And CLng(lngCurrentResponseID) = CLng(rsAnswers("ResponseID"))
  225.                 strDisplayText = strDisplayText & Trim(rsAnswers("DisplayText")) & "; "
  226.                 rsAnswers.MoveNext
  227.                 If rsAnswers.EOF = True Then
  228.                     Exit Do
  229.                 End If
  230.             Loop
  231.                                     
  232.             'Strip off the trailing semi-colon
  233.             strDisplayText = Left(strDisplayText, Len(Trim(strDisplayText)) - 1)
  234.             If lngItemTypeID = SUR_ITEM_DATE Then
  235.                 strDisplayText = CustomDateFormatDisplay(strDisplayText)
  236.             End If
  237. %>
  238.             <tr>
  239.                 <td width="30" class="WhiteBackgroundColor">
  240.                     <span class="Normal"><%=lngAnswerNumber%>.</span>
  241.                 </td>
  242.                 <td width="620" class="WhiteBackgroundColor">
  243. <%
  244.                     'If a value was actually entered, display it; otherwise, display a "No Response" message.
  245.                     If Len(strDisplayText) > 0 And strDisplayText <> SUR_ANSWER_TEXT_NULL Then
  246. %>                                
  247.                         <span class="Normal"><%=Replace(Server.HTMLEncode(strDisplayText), vbCrLf, "<br>")%></span>
  248. <%
  249.                     Else
  250. %>                                                                        
  251.                         <span class="NormalItalic"><%=SUR_ANSWER_NULL_DISPLAY%></span>
  252. <%
  253.                     End If
  254. %>                                                                        
  255.                 </td>
  256.                 <td align="center" class="WhiteBackgroundColor">
  257. <%
  258.                     'If the user has permissions to view the individual reports, display a button
  259.                     'linking to it.
  260.                     If flgCanUserViewIndividualReport = True Then
  261. %>                                        
  262.                         <span class="Normal"><a href="ResultsIndividual.asp?DisplayHeader=<%=Request.QueryString("DisplayHeader")%>&SurveyID=<%=lngSurveyID%>&ResponseID=<%=lngCurrentResponseID%>"><img alt="View complete survey for this response" border="0" src="Resources/Buttons/ViewSmall.gif" onMouseOver="this.style.cursor='hand'"></a></span>
  263. <%
  264.                     Else
  265. %>
  266.                         <span class="NormalItalic"><%=SUR_VIEW_DISABLED%></span>
  267. <%
  268.                     End If
  269. %>                                                
  270.                 </td>
  271.             </tr>
  272. <%            
  273.             lngAnswerNumber = lngAnswerNumber + 1
  274.         Else
  275.             rsAnswers.MoveNext
  276.         End If
  277.     Loop
  278.  
  279.     If lngAnswerNumber = 1 Then 'This means that there were no responses to this question
  280. %>
  281.         <tr>
  282.             <td colspan="4" width="740" class="WhiteBackgroundColor">
  283.                 <span class="NormalItalic"><%=SUR_ANSWER_NULL_DISPLAY%></span>
  284.             </td>
  285.         </tr>
  286. <%
  287.     End If        
  288. %>    
  289. </table>
  290. </td></tr></table>
  291.  
  292. <!--#Include File="Include/FrameworkBottom_inc.asp"-->
  293.  
  294. </body>
  295. </html>
  296. <%
  297.     'Clean up
  298.     rsAnswers.Close
  299.     Set rsAnswers = Nothing
  300.  
  301.     'Ensure that the web server returns the page
  302.     Response.Flush
  303. %>
  304.