home *** CD-ROM | disk | FTP | other *** search
/ bombers.k12.ar.us / bombers.k12.ar.us.tar / bombers.k12.ar.us / survey_unconfigured / TakeSurveyActionComplete.asp < prev    next >
Text File  |  2005-11-03  |  16KB  |  392 lines

  1. <!--#Include File="Include/Top_inc.asp"-->
  2. <%
  3. '***********************************************************************
  4. '   Application: SelectSurveyASP Advanced v8.1.5
  5. '   Author: Aaron Baril for ClassApps.com
  6. '   Page Description: This page works with TakeSurveyAction.asp, and is the final
  7. '                      page displayed after a survey is taken.  This page is only
  8. '                       displayed for surveys where a message is to be displayed at
  9. '                      the end of the survey.
  10. '
  11. '   COPYRIGHT NOTICE                                
  12. '
  13. '   See attached Software License Agreement
  14. '
  15. '   (c) Copyright 2002 - 2006 by ClassApps.com.  All rights reserved.
  16. '***********************************************************************
  17. %>
  18. <!--#Include File="Include/Config_inc.asp"-->
  19. <!--#Include File="Include/adovbs_inc.asp"-->
  20. <!--#Include File="Include/ID_inc.asp"-->
  21. <!--#Include File="Include/CurrentUser_inc.asp"-->
  22. <!--#Include File="Include/SurveySecurity_inc.asp"-->
  23. <!--#Include File="Include/SurveyEmail_inc.asp"-->
  24. <!--#Include File="Include/Encryption_inc.asp"-->
  25. <!--#Include File="Include/Constants_inc.asp"-->
  26. <!--#Include File="Include/SurveyUtility_inc.asp"-->
  27. <!--#Include File="Include/Utility_inc.asp"-->
  28. <!--#Include File="Include/Email_inc.asp"-->
  29. <%
  30.     Dim strSQL
  31.     Dim rsSurvey
  32.     Dim lngSurveyID
  33.     Dim strTitle
  34.     Dim strLogoPath
  35.     Dim strLogoAlignment
  36.     Dim strSurveyAlignment
  37.     Dim strSurveyLanguage
  38.     Dim strHTMLTop
  39.     Dim strHTMLBottom
  40.     Dim strCompletionAction
  41.     Dim strSurveyCompleteMessage
  42.     Dim strSurveyCompleteURL
  43.     Dim flgCanUserViewOverviewReport
  44.     Dim strDisplayBorderYN
  45.     Dim strBorderColor
  46.     Dim lngBorderWidth
  47.     Dim strSurveyBackgroundColor
  48.     Dim strPageBackgroundColor
  49.     Dim strResponseEmailAddresses
  50.     Dim strAdminEmailAddress
  51.     Dim lngResponseID
  52.     Dim flgManualResponseEntryMode
  53.     Dim strCloseButton
  54.     Dim strContinueButton
  55.     Dim strReportsButton
  56.     
  57.     'Initialization
  58.     lngSurveyID = DecryptSurveyID(Request.QueryString("SurveyID"))
  59.     flgManualResponseEntryMode = IsManualResponseEntryMode(lngSurveyID)
  60.     lngResponseID = Request.QueryString("ResponseID")
  61.     Set rsSurvey = Server.CreateObject("ADODB.Recordset")
  62.         
  63.     'Clear out the session variable for tracking this survey
  64.     Session(SUR_SESSION_TAKING_SURVEY & lngSurveyID) = ""
  65.     
  66.     'Select information about the survey and the template
  67.     strSQL = "SELECT title, logo_path, logo_alignment, survey_alignment, survey_language, completion_action, survey_complete_redirect_url, " & _
  68.                 "survey_complete_display_close, survey_complete_display_continue, survey_complete_display_reports, " & _
  69.                 "display_border_yn, border_color, border_width, matrix_header_color, " & _
  70.                 "survey_background_color, page_background_color, matrix_first_color, matrix_second_color, " & _
  71.                 "survey_name_font_color, survey_name_font_size, survey_name_font_weight, " & _
  72.                 "admin_email_address, survey_name_font_family, page_title_font_color, page_title_font_size, " & _
  73.                 "page_title_font_weight, page_title_font_family, page_number_font_color, page_number_font_size, " & _
  74.                 "page_number_font_weight, page_number_font_family, question_text_font_color, question_text_font_size, " & _
  75.                 "question_text_font_weight, question_text_font_family, question_subtext_font_color, question_subtext_font_size, " & _
  76.                 "question_subtext_font_weight, question_subtext_font_family, survey_complete_message, " & _
  77.                 "html_top, html_bottom, response_email_addresses " & _
  78.              "FROM sur_survey s, sur_template t " & _
  79.              "WHERE s.template_id = t.template_id " & _
  80.              "AND survey_id = " & lngSurveyID
  81.     rsSurvey.Open ConvertSQL(strSQL), SURVEY_APP_CONNECTION, adOpenForwardOnly, adLockReadOnly, adCmdText
  82.     rsSurvey.MoveFirst
  83.     strHTMLTop = rsSurvey("html_top")
  84.     strHTMLBottom = rsSurvey("html_bottom")
  85.     strTitle = rsSurvey("title")
  86.     strLogoPath = rsSurvey("logo_path")
  87.     strLogoAlignment = rsSurvey("logo_alignment")
  88.     strSurveyAlignment = rsSurvey("survey_alignment")
  89.     strSurveyLanguage = rsSurvey("survey_language")
  90.     strCompletionAction = rsSurvey("completion_action")
  91.     strSurveyCompleteMessage = rsSurvey("survey_complete_message")
  92.     strSurveyCompleteURL = rsSurvey("survey_complete_redirect_url")
  93.     strCloseButton = rsSurvey("survey_complete_display_close")
  94.     strContinueButton = rsSurvey("survey_complete_display_continue")
  95.     strReportsButton = rsSurvey("survey_complete_display_reports")
  96.     strResponseEmailAddresses = rsSurvey("response_email_addresses")
  97.     strAdminEmailAddress = rsSurvey("admin_email_address")
  98.     strDisplayBorderYN = rsSurvey("display_border_yn")
  99.     strBorderColor = rsSurvey("border_color")
  100.     lngBorderWidth = rsSurvey("border_width")
  101.     strSurveyBackgroundColor = rsSurvey("survey_background_color")
  102.     strPageBackgroundColor = rsSurvey("page_background_color")
  103.  
  104.     'The redirect, below, adds the response ID to the URL.  Because we don't know if the URL entered contains 
  105.     'a querystring, check for a question mark, and add one if it does not already exist.
  106.     If InStr(strSurveyCompleteURL, "?") = 0 Then
  107.         strSurveyCompleteURL = strSurveyCompleteURL & "?"
  108.     End If
  109.     
  110.     'If the redirect URL does not start with http or https, add it
  111.     If Left(strSurveyCompleteURL, 7) <> "http://" And Left(strSurveyCompleteURL, 8) <> "https://" Then
  112.         strSurveyCompleteURL = "http://" & strSurveyCompleteURL
  113.     End If
  114.     
  115.     'Render the styles required for the survey    
  116. %>
  117. <html lang="<%=strSurveyLanguage%>">
  118. <head>
  119.     <title>'<%=strTitle%>' Survey Completed</title>
  120. <style>
  121.     .SurveyBodyStyle
  122.     {
  123.         FONT-FAMILY: <%=rsSurvey("question_text_font_family")%>;
  124.         BACKGROUND-COLOR: <%=strPageBackgroundColor%>;
  125.         COLOR: <%=rsSurvey("question_text_font_color")%>;
  126. <%
  127.         If Len(Trim(strHTMLTop)) > 0 Or Len(Trim(strHTMLBottom)) > 0 Then
  128. %>
  129.             MARGIN-LEFT: 0;
  130. <%
  131.         ElseIf strDisplayBorderYN = SUR_BOOLEAN_POSITIVE Then
  132. %>
  133.             MARGIN-LEFT: 10;
  134. <%
  135.         Else
  136. %>
  137.             MARGIN-LEFT: 3;
  138. <%
  139.         End If
  140. %>
  141.         MARGIN-RIGHT: 0;
  142.         MARGIN-BOTTOM: 0;
  143. <%
  144.         'If not top HTML was provided, leave a 15-pixel margin at the top; otherwise, flush the survey with the top, 
  145.         'and let the top HTML establish the look and feel.
  146.         If Len(Trim(strHTMLTop)) = 0 Then
  147. %>        
  148.             MARGIN-TOP: 15;
  149. <%
  150.         Else
  151. %>
  152.             MARGIN-TOP: 0;
  153. <%
  154.         End If
  155. %>
  156.     }
  157.  
  158.     .Normal
  159.     {
  160.         COLOR: <% If Len(rsSurvey("question_text_font_color")) > 0 Then Response.Write rsSurvey("question_text_font_color") Else Response.Write SUR_DEFAULT_FONT_COLOR End If %>;
  161.         FONT-FAMILY: <%=rsSurvey("question_text_font_family")%>;
  162.         FONT-SIZE: <% If Len(rsSurvey("question_text_font_size")) > 0 Then Response.Write rsSurvey("question_text_font_size") Else Response.Write "12" End If %>px;
  163.         FONT-WEIGHT: <%=rsSurvey("question_text_font_weight")%>;
  164.     }
  165.  
  166.     .H1HeadingStyle
  167.     {
  168.         COLOR: <% If Len(rsSurvey("survey_name_font_color")) > 0 Then Response.Write rsSurvey("survey_name_font_color") Else Response.Write SUR_DEFAULT_FONT_COLOR End If %>;
  169.         FONT-FAMILY: <%=rsSurvey("survey_name_font_family")%>;
  170.         FONT-WEIGHT: <%=rsSurvey("survey_name_font_weight")%>;
  171.         FONT-SIZE: <% If Len(rsSurvey("survey_name_font_size")) > 0 Then Response.Write rsSurvey("survey_name_font_size") Else Response.Write "18" End If %>px;
  172.     }
  173.  
  174.     .H2HeadingStyle
  175.     {
  176.         COLOR: <% If Len(rsSurvey("page_number_font_color")) > 0 Then Response.Write rsSurvey("page_number_font_color") Else Response.Write SUR_DEFAULT_FONT_COLOR End If %>;
  177.         FONT-FAMILY: <%=rsSurvey("page_number_font_family")%>;
  178.         FONT-WEIGHT: <%=rsSurvey("page_number_font_weight")%>;
  179.         FONT-SIZE: <% If Len(rsSurvey("page_number_font_size")) > 0 Then Response.Write rsSurvey("page_number_font_size") Else Response.Write "16" End If %>px;
  180.     }
  181.  
  182.     .InlineHelpSpanStyle
  183.     {
  184.         COLOR: <% If Len(rsSurvey("question_subtext_font_color")) > 0 Then Response.Write rsSurvey("question_subtext_font_color") Else Response.Write SUR_DEFAULT_FONT_COLOR End If %>;
  185.         FONT-FAMILY: <%=rsSurvey("question_subtext_font_family")%>;
  186.         FONT-SIZE: <% If Len(rsSurvey("question_subtext_font_size")) > 0 Then Response.Write rsSurvey("question_subtext_font_size") Else Response.Write "10" End If %>px;
  187.         FONT-WEIGHT: <%=rsSurvey("question_subtext_font_weight")%>;
  188.     }
  189.  
  190.     .SurveyPageTitle
  191.     {
  192.         COLOR: <% If Len(rsSurvey("page_title_font_color")) > 0 Then Response.Write rsSurvey("page_title_font_color") Else Response.Write SUR_DEFAULT_FONT_COLOR End If %>;
  193.         FONT-FAMILY: <%=rsSurvey("page_title_font_family")%>;
  194.         FONT-SIZE: <% If Len(rsSurvey("page_title_font_size")) > 0 Then Response.Write rsSurvey("page_title_font_size") Else Response.Write "16" End If %>px;
  195.         FONT-WEIGHT: <%=rsSurvey("page_title_font_weight")%>;
  196.     }
  197. </style>
  198. </head>
  199. <%
  200.     'Clean up
  201.     rsSurvey.Close
  202.     Set rsSurvey = Nothing
  203.  
  204.     'Send the response to the designated email addresses, if there are any, unless the survey is in manual response entry mode
  205.     If Len(strResponseEmailAddresses) > 0 And flgManualResponseEntryMode = False And Len(lngResponseID) > 0 Then
  206.         SendSurveyResponse lngResponseID, strResponseEmailAddresses, strAdminEmailAddress
  207.     End If
  208.  
  209.     'If this was not manual response entry mode, do the specified action on the survey
  210.     If flgManualResponseEntryMode = False Then    
  211.         'If the user is an admin or owner and just finsihed editing a survey, redirect the user back to the individual
  212.         'results for that survey.  Otherwise, redirect to the appropriate page or display the appropriate information
  213.         'based on the completion action specified
  214.         If Request.QueryString("Edit") = SUR_BOOLEAN_POSITIVE_DISPLAY Then
  215.             Response.Redirect "ResultsIndividual.asp?DisplayHeader=Yes&SurveyID=" & lngSurveyID
  216.         ElseIf strCompletionAction = SUR_COMPLETION_ACTION_DISPLAY_RESULTS Then
  217.             'Redirect to the survey results page.
  218.             Response.Redirect "ResultsOverview.asp?SurveyID=" & lngSurveyID
  219.         ElseIf strCompletionAction = SUR_COMPLETION_ACTION_CLOSE Then
  220.             'Render client-side code to close the browser
  221.     %>
  222.             <html><body onLoad="javascript:window.close();"></body></html>
  223.     <%        
  224.             Response.End 
  225.         ElseIf strCompletionAction = SUR_COMPLETION_ACTION_REDIRECT Then
  226.             'Redirect to the custom URL specified for the survey
  227.             Response.Redirect strSurveyCompleteURL & "&ResponseID=" & lngResponseID
  228.         End If
  229.     End If
  230. %>                        
  231.     <body class="SurveyBodyStyle">
  232. <%
  233.     'If an HTML header was provided, display it
  234.     If Len(strHTMLTop) > 0 Then
  235.         Response.Write strHTMLTop
  236.     End If
  237. %>
  238.     <table border="0" cellspacing="0" cellpadding="5" width="760" align="<% If strSurveyAlignment = SUR_SURVEY_ALIGNMENT_CENTER Then Response.Write "center" End If %>">
  239. <%
  240.         'Optionally display a logo at the top of the survey
  241.         If IsNull(strLogoPath) Or Len(strLogoPath) = 0 Then
  242. %>
  243.             <tr>
  244.                 <td height="44" valign="bottom">
  245.                     <% If strDisplayBorderYN = SUR_BOOLEAN_NEGATIVE Then Response.Write " " End If %><span class="H1HeadingStyle"><a name="skipnav" tabindex="1"><%=strTitle%></a></span>
  246.                 </td>
  247.             </tr>
  248. <%    
  249.         Else
  250.             'Whether the image alignment is left or right determines how the image and title are rendered
  251.             If strLogoAlignment = SUR_LOGO_ALIGNMENT_LEFT Then
  252. %>
  253.                 <tr>
  254.                     <td align="left">
  255.                         <img border="0" src="<%=strLogoPath%>" alt="Survey logo">
  256.                     </td>
  257.                     <td align="right">
  258.                         <span class="H1HeadingStyle"><a name="skipnav" tabindex="1"><%=strTitle%></a></span>
  259.                     </td>
  260.                 </tr>
  261. <%    
  262.             ElseIf strLogoAlignment = SUR_LOGO_ALIGNMENT_RIGHT Then
  263. %>
  264.                 <tr>
  265.                     <td align="left">
  266.                         <span class="H1HeadingStyle"><a name="skipnav" tabindex="1"><%=strTitle%></a></span>
  267.                     </td>
  268.                     <td align="right">
  269.                         <img border="0" src="<%=strLogoPath%>" alt="Survey logo">
  270.                     </td>
  271.                 </tr>
  272. <%    
  273.             Else
  274. %>
  275.                 <tr>
  276.                     <td align="left">
  277.                         <img border="0" src="<%=strLogoPath%>" alt="Survey logo">
  278.                     </td>
  279.                 </tr>
  280.                 <tr>
  281.                     <td align="left">
  282.                         <span class="H1HeadingStyle"><a name="skipnav" tabindex="1"><%=strTitle%></a></span>
  283.                     </td>
  284.                 </tr>
  285. <%    
  286.             End If
  287.         End If
  288. %>    
  289.     </table>
  290. <%
  291.     'Optionally display the border
  292.     If strDisplayBorderYN = SUR_BOOLEAN_POSITIVE Then
  293. %>
  294.         <table style="background-color:<%=strBorderColor%>" cellspacing="0" cellpadding="<%=lngBorderWidth%>" width="760" align="<% If strSurveyAlignment = SUR_SURVEY_ALIGNMENT_CENTER Then Response.Write "center" End If %>"><tr><td>
  295.         <table cellpadding="0" border="0" style="background-color:<%=strSurveyBackgroundColor%>" width="100%"><tr><td>
  296. <%
  297.     Else
  298. %>
  299.         <table style="background-color:<%=strSurveyBackgroundColor%>" cellspacing="0" cellpadding="0" width="760" align="<% If strSurveyAlignment = SUR_SURVEY_ALIGNMENT_CENTER Then Response.Write "center" End If %>"><tr><td>
  300. <%
  301.     End If
  302. %>
  303.     <table border="0" cellpadding="8" cellspacing="0" width="100%">
  304.         <tr>
  305.             <td>
  306.                 <span class="SurveyPageTitle">Survey Completed</span>
  307.             </td>
  308.         </tr>
  309.     </table>
  310.     <br>
  311.     <table border="0" cellpadding="3" cellspacing="3" height="225" width="95%" align="center">
  312.         <tr>
  313.             <td align="left" valign="top" class="Normal">
  314. <%
  315.                 'Display a different message for admin's in manual response entry mode
  316.                 If flgManualResponseEntryMode = True Then
  317. %>
  318.                     To enter another response, click the button below.
  319. <%
  320.                 Else
  321.                     Response.Write strSurveyCompleteMessage
  322.                 End If
  323. %>
  324.                 <br>
  325.             </td>
  326.         </tr>
  327. <%
  328.         'Check to see if the user can view the overview results report.
  329.         flgCanUserViewOverviewReport = CanUserViewOverviewReport(lngSurveyID)
  330.                 
  331. %>                        
  332.         <tr>
  333.             <td align="right" valign="bottom">
  334. <%
  335.                 'Optionally display the Close button
  336.                 If strCloseButton = SUR_BOOLEAN_POSITIVE Then
  337. %>
  338.                     <img style="cursor:hand" onClick="javascript:window.close();" border="0" alt="Close this window" name="btnClose" src="Resources/SurveyButtons/Close.gif">
  339. <%
  340.                 End If
  341.                     
  342.                 'If the survey was in manual data entry mode, display a button to allow the user to submit again
  343.                 If flgManualResponseEntryMode = True Then
  344. %>                        
  345.                         <a href="TakeSurvey.asp?DisplayHeader=Yes&SurveyID=<%=EncryptSurveyID(lngSurveyID)%>"><img border="0" alt="Enter another survey response" name="btnEnterNextResponse" src="Resources/SurveyButtons/EnterNextResponse.gif"></a>
  346. <%
  347.                 Else
  348.                     'If the user can view the overview reports and the survey option was set to display a button to view report, 
  349.                     'display a button linking to it.
  350.                     If flgCanUserViewOverviewReport = True And strReportsButton = SUR_BOOLEAN_POSITIVE Then
  351. %>                        
  352.                         <a href="ResultsOverview.asp?DisplayHeader=<%=Request.QueryString("DisplayHeader")%>&SurveyID=<%=lngSurveyID%>"><img border="0" alt="View reports for this survey" name="btnViewReports" src="Resources/SurveyButtons/ViewReports.gif"></a>
  353. <%
  354.                     End If
  355.  
  356.                     'Optionally display the continue button
  357.                     If strContinueButton = SUR_BOOLEAN_POSITIVE Then
  358. %>                        
  359.                         <a href="<%=strSurveyCompleteURL%>ResponseID=<%=lngResponseID%>"><img border="0" alt="Continue" name="btnContinue" src="Resources/SurveyButtons/Continue.gif"></a>
  360. <%
  361.                     End If
  362.                 End If
  363. %>                            
  364.                 <br><br>
  365.             </td>
  366.         </tr>
  367.     </table>
  368. <%
  369.     'If the border was displayed, close out an extra table
  370.     If strDisplayBorderYN = SUR_BOOLEAN_POSITIVE Then
  371. %>
  372.         </td></tr></table>
  373. <%
  374.     End If
  375. %>    
  376.     </td></tr></table>
  377. <%
  378.     'If an HTML footer was provided, display it
  379.     If Len(strHTMLBottom) > 0 Then
  380.         Response.Write strHTMLBottom
  381.     Else
  382.         Response.Write "<br>"
  383.     End If
  384. %>
  385.     </body>
  386.     </html>
  387. <%
  388.  
  389.     'Ensure that the web server returns the page
  390.     Response.Flush
  391. %>
  392.