home *** CD-ROM | disk | FTP | other *** search
/ bombers.k12.ar.us / bombers.k12.ar.us.tar / bombers.k12.ar.us / survey / EmailSurvey.asp < prev    next >
Text File  |  2006-11-29  |  25KB  |  625 lines

  1. <!--#Include File="Include/Top_inc.asp"-->
  2. <!--#Include File="Include/Config_inc.asp"-->
  3. <%
  4. '***********************************************************************
  5. '   Application: SelectSurveyASP Advanced v8.1.11
  6. '   Author: Aaron Baril for ClassApps.com
  7. '   Page Description: This page is used to generate HTML that can be used to
  8. '                      send out a survey via email.
  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. %>
  18. <!--#Include File="Include/SurveyUtility_inc.asp"-->
  19. <!--#Include File="Include/Utility_inc.asp"-->
  20. <!--#Include File="Include/adovbs_inc.asp"-->
  21. <!--#Include File="Include/CurrentUser_inc.asp"-->
  22. <!--#Include File="Include/Constants_inc.asp"-->
  23. <!--#Include File="Include/SurveySecurity_inc.asp"-->
  24. <!--#Include File="Include/Collection_inc.asp"-->
  25. <!--#Include File="Include/Encryption_inc.asp"-->
  26. <!--#Include File="Include/SurveyPageCondition_inc.asp"-->
  27. <!--#Include File="Include/SurveyRendering_inc.asp"-->
  28.  
  29. <%
  30.     Dim strSQL
  31.     Dim lngSurveyID
  32.     Dim rsSurvey
  33.     Dim rsResponseID
  34.     Dim rsTemplate
  35.     Dim rsPage
  36.     Dim rsLastActualPage
  37.     Dim lngQuestionNumber
  38.     Dim flgUpdatingSurvey
  39.     Dim flgUpdateableSurvey
  40.     Dim flgHasStartedSurvey
  41.     Dim flgHasCompletedSurvey
  42.     Dim lngResponseID
  43.     Dim lngActualPageNumber
  44.     Dim lngDisplayPageNumber
  45.     Dim lngPageCount
  46.     Dim strQuestionNumberingFormat
  47.     Dim flgResponseIDFound
  48.     Dim lngItemID
  49.     Dim lngTemplateID
  50.     Dim strEditValue
  51.     Dim strTitle
  52.     Dim strLogoPath
  53.     Dim strLogoAlignment
  54.     Dim strSurveyAlignment
  55.     Dim strDisplayBorderYN
  56.     Dim strBorderColor
  57.     Dim lngBorderWidth
  58.     Dim strProgressFirstColor
  59.     Dim strProgressSecondColor
  60.     Dim strSurveyBackgroundColor
  61.     Dim strPageBackgroundColor
  62.     Dim strHTMLTop
  63.     Dim strHTMLBottom
  64.     Dim strNavigationBackButtonPath
  65.     Dim strNavigationBackLinkText
  66.     Dim strNavigationNextButtonPath
  67.     Dim strNavigationNextLinkText
  68.     Dim strNavigationDoneButtonPath
  69.     Dim strNavigationDoneLinkText
  70.     Dim strNavigationCancelButtonPath
  71.     Dim strNavigationCancelLinkText
  72.     Dim strPageTitle
  73.     Dim strPageIntroduction
  74.     Dim strBackButtonDisplay
  75.     Dim strCancelButtonDisplay
  76.     Dim strCancelButtonRedirectURL
  77.     Dim strButtonPath
  78.     Dim strRedirectURL
  79.     Dim strEncryptedIDs
  80.     Dim lngEmailAddressID
  81.     Dim lngEmailMessageID
  82.     Dim strResponseType
  83.     Dim strTempDate
  84.     Dim strTempValue
  85.     Dim strItemIDValues
  86.         
  87.     'Initialization
  88.     lngSurveyID = DecryptSurveyID(Request.QueryString("SurveyID"))
  89.     lngPageCount = GetPageCount(lngSurveyID)
  90.     lngItemID = -1
  91.     lngDisplayPageNumber = 1
  92.     lngActualPageNumber = 1
  93.     lngQuestionNumber = 1
  94.     Set rsSurvey = Server.CreateObject("ADODB.Recordset")
  95.     Set rsResponseID = Server.CreateObject("ADODB.Recordset")
  96.     Set rsTemplate = Server.CreateObject("ADODB.Recordset")
  97.     Set rsPage = Server.CreateObject("ADODB.Recordset")
  98.     Set rsLastActualPage = Server.CreateObject("ADODB.Recordset")
  99.  
  100.     'Make sure that the survey ID is a valid survey. This is an important check because it's possible that 
  101.     'the survey was deleted since the time it was deployed.
  102.     If IsValidSurveyID(lngSurveyID) = False Then
  103.         Response.Redirect "AccessDenied.asp?Reason=" & SUR_ACCESS_DENIED_INVALID_SURVEY_ID
  104.     End If
  105.     
  106.     'Make sure the survey is "LIVE" based on both its status and its start and end dates, if specified, before a 
  107.     'user takes it.  If it's not "LIVE", redirect.
  108.     If IsSurveyLive(lngSurveyID) = False Then
  109.         Response.Redirect "TakeSurveyError.asp?SurveyID=" & EncryptSurveyID(lngSurveyID) & "&Reason=" & SUR_ACCESS_DENIED_NOT_LIVE
  110.     End If
  111.  
  112.     'If this is the first page of the survey, check to make sure that the IP address is in a valid range
  113.     If IsIPAddressInRange(lngSurveyID) = False Then
  114.         Response.Redirect "TakeSurveyError.asp?SurveyID=" & EncryptSurveyID(lngSurveyID) & "&Reason=" & SUR_ACCESS_DENIED_IP_ADDRESS_OUT_OF_RANGE
  115.     End If
  116.     
  117.     'The user is not updating the survey.  This means either it's the first time the user has taken the survey, or the 
  118.     'user started the survey, and is now completing it.
  119.     strSQL = "SELECT title, survey_language, template_id, i.item_type_id As item_type_id, " & _
  120.                 "required_yn, email_address_yn, it.item_type_name As ItemType, random_answer_order_yn, " & _
  121.                 "other_yn, m.order_number As order_number, i.item_id As item_id, database_dsn, " & _
  122.                 "display_format, maximum_length, image_path, image_height, image_width, image_alignment, " & _
  123.                 "minimum_value, maximum_value, answer_total, minimum_number_responses, maximum_number_responses, " & _
  124.                 "row_text_width, subitem_count, page_numbering_format, question_numbering_format, back_button_display, " & _
  125.                 "cancel_button_display, cancel_button_redirect_url, default_value, item_text, " & _
  126.                 "other_text As OtherTextQuestion, database_sql, item_sub_text, other_display_type " & _
  127.                 "FROM sur_survey s, sur_item i, sur_survey_to_item_mapping m, sur_item_type it " & _
  128.                 "WHERE i.item_id = m.item_id " & _
  129.                 "AND m.page_number = " & lngActualPageNumber & _
  130.                 " AND s.survey_id = m.survey_id " & _
  131.                 "AND it.item_type_id = i.item_type_id " & _
  132.                 "AND m.survey_id = " & lngSurveyID & _
  133.                 " ORDER BY m.order_number"
  134.     rsSurvey.Open ConvertSQL(strSQL), SURVEY_APP_CONNECTION, adOpenDynamic, , adCmdText
  135.  
  136.     'Get the survey title and template ID for reuse later
  137.     rsSurvey.MoveFirst
  138.     strTitle = rsSurvey("title")
  139.     strBackButtonDisplay = rsSurvey("back_button_display")
  140.     strCancelButtonDisplay = rsSurvey("cancel_button_display")
  141.     strCancelButtonRedirectURL = rsSurvey("cancel_button_redirect_url")
  142.     lngTemplateID = rsSurvey("template_id")
  143. %>
  144. <html lang="<%=rsSurvey("survey_language")%>">
  145. <head>
  146.     <title><%=strTitle%> Survey</title>
  147. </head>
  148.  
  149. <% 
  150.     'Initialize the question number before generating the JavaScript.
  151.     If Len(Request.QueryString("QuestionNumber")) = 0 Then
  152.         lngQuestionNumber = 1
  153.     Else
  154.         lngQuestionNumber = Request.QueryString("QuestionNumber")
  155.     End If
  156.  
  157.     'Select all of the attributes for the specified template to create the look and feel
  158.     strSQL = "SELECT logo_path, logo_alignment, survey_alignment, display_border_yn, border_color, border_width, survey_background_color, " & _
  159.                 "page_background_color, progress_first_color, progress_second_color, survey_name_font_color, " & _
  160.                 "survey_name_font_size, survey_name_font_weight, survey_name_font_family, page_title_font_color, " & _
  161.                 "page_title_font_size, page_title_font_weight, " & _
  162.                 "page_title_font_family, page_number_font_color, page_number_font_size, page_number_font_weight, " & _
  163.                 "page_number_font_family, question_text_font_color, question_text_font_size, question_text_font_weight, " & _
  164.                 "question_text_font_family, question_subtext_font_color, question_subtext_font_size, " & _
  165.                 "question_subtext_font_weight, question_subtext_font_family, navigation_link_font_color, " & _
  166.                 "navigation_link_font_size, navigation_link_font_weight, navigation_link_font_family, html_top, html_bottom, " & _
  167.                 "navigation_back_button_path, navigation_back_link_text, navigation_next_button_path, navigation_next_link_text, " & _
  168.                 "navigation_cancel_button_path, navigation_cancel_link_text, navigation_done_button_path, navigation_done_link_text " & _
  169.               "FROM sur_template " & _
  170.               "WHERE template_id = " & lngTemplateID
  171.     rsTemplate.Open ConvertSQL(strSQL), SURVEY_APP_CONNECTION, adOpenForwardOnly, adLockReadOnly, adCmdText
  172.     rsTemplate.MoveFirst
  173.  
  174.     'Capture all of the fields in local variables
  175.     strLogoPath = rsTemplate("logo_path")
  176.     strLogoAlignment = rsTemplate("logo_alignment")
  177.     strSurveyAlignment = rsTemplate("survey_alignment")
  178.     strDisplayBorderYN = rsTemplate("display_border_yn")
  179.     strBorderColor = rsTemplate("border_color")
  180.     lngBorderWidth = rsTemplate("border_width")
  181.     strSurveyBackgroundColor = rsTemplate("survey_background_color")
  182.     strPageBackgroundColor = rsTemplate("page_background_color")
  183.     strProgressFirstColor = rsTemplate("progress_first_color")
  184.     If Len(strProgressFirstColor) = 0 Or IsNull(strProgressFirstColor) = True Then
  185.         strProgressFirstColor = SUR_DEFAULT_PROGRESS_FIRST_COLOR 
  186.     End If
  187.     strProgressSecondColor = rsTemplate("progress_second_color")
  188.     If Len(strProgressSecondColor) = 0 Or IsNull(strProgressSecondColor) = True Then
  189.         strProgressSecondColor = SUR_DEFAULT_PROGRESS_SECOND_COLOR
  190.     End If
  191.     strHTMLTop = rsTemplate("html_top")
  192.     strHTMLBottom = rsTemplate("html_bottom")
  193.     strNavigationBackButtonPath = rsTemplate("navigation_back_button_path")
  194.     strNavigationBackLinkText = rsTemplate("navigation_back_link_text")
  195.     strNavigationNextButtonPath = rsTemplate("navigation_next_button_path")
  196.     strNavigationNextLinkText = rsTemplate("navigation_next_link_text")
  197.     strNavigationCancelButtonPath = rsTemplate("navigation_cancel_button_path")
  198.     strNavigationCancelLinkText = rsTemplate("navigation_cancel_link_text")
  199.     strNavigationDoneButtonPath = rsTemplate("navigation_done_button_path")
  200.     strNavigationDoneLinkText = rsTemplate("navigation_done_link_text")
  201.  
  202.     'Render the styles required for the survey    
  203. %>
  204. <style>
  205.     .SurveyBodyStyle
  206.     {
  207.         FONT-FAMILY: <%=rsTemplate("question_text_font_family")%>;
  208.         BACKGROUND-COLOR: <%=strPageBackgroundColor%>;
  209.         COLOR: <%=rsTemplate("question_text_font_color")%>;
  210. <%
  211.         If Len(Trim(strHTMLTop)) > 0 Or Len(Trim(strHTMLBottom)) > 0 Then
  212. %>
  213.             MARGIN-LEFT: 0;
  214. <%
  215.         ElseIf strDisplayBorderYN = SUR_BOOLEAN_POSITIVE Then
  216. %>
  217.             MARGIN-LEFT: 10;
  218. <%
  219.         Else
  220. %>
  221.             MARGIN-LEFT: 3;
  222. <%
  223.         End If
  224. %>
  225.         MARGIN-RIGHT: 0;
  226.         MARGIN-BOTTOM: 0;
  227. <%
  228.         'If not top HTML was provided, leave a 15-pixel margin at the top; otherwise, flush the survey with the top, 
  229.         'and let the top HTML establish the look and feel.
  230.         If Len(Trim(strHTMLTop)) = 0 Then
  231. %>        
  232.             MARGIN-TOP: 15;
  233. <%
  234.         Else
  235. %>
  236.             MARGIN-TOP: 0;
  237. <%
  238.         End If
  239. %>
  240.     }
  241.  
  242.     .Normal
  243.     {
  244.         COLOR: <% If Len(rsTemplate("question_text_font_color")) > 0 Then Response.Write rsTemplate("question_text_font_color") Else Response.Write SUR_DEFAULT_FONT_COLOR End If %>;
  245.         FONT-FAMILY: <%=rsTemplate("question_text_font_family")%>;
  246.         FONT-SIZE: <% If Len(rsTemplate("question_text_font_size")) > 0 Then Response.Write rsTemplate("question_text_font_size") Else Response.Write "12" End If %>px;
  247.         FONT-WEIGHT: <%=rsTemplate("question_text_font_weight")%>;
  248.     }
  249.  
  250.     .Required
  251.     {
  252.         COLOR: red;
  253.         FONT-FAMILY: <%=rsTemplate("question_text_font_family")%>;
  254.         FONT-SIZE: 10px;
  255.     }
  256.  
  257.     .H1HeadingStyle
  258.     {
  259.         COLOR: <% If Len(rsTemplate("survey_name_font_color")) > 0 Then Response.Write rsTemplate("survey_name_font_color") Else Response.Write SUR_DEFAULT_FONT_COLOR End If %>;
  260.         FONT-FAMILY: <%=rsTemplate("survey_name_font_family")%>;
  261.         FONT-WEIGHT: <%=rsTemplate("survey_name_font_weight")%>;
  262.         FONT-SIZE: <% If Len(rsTemplate("survey_name_font_size")) > 0 Then Response.Write rsTemplate("survey_name_font_size") Else Response.Write "18" End If %>px;
  263.     }
  264.  
  265.     .PageNumberFontStyle
  266.     {
  267.         COLOR: <% If Len(rsTemplate("page_number_font_color")) > 0 Then Response.Write rsTemplate("page_number_font_color") Else Response.Write SUR_DEFAULT_FONT_COLOR End If %>;
  268.         FONT-FAMILY: <%=rsTemplate("page_number_font_family")%>;
  269.         FONT-WEIGHT: <%=rsTemplate("page_number_font_weight")%>;
  270.         FONT-SIZE: <% If Len(rsTemplate("page_number_font_size")) > 0 Then Response.Write rsTemplate("page_number_font_size") Else Response.Write "16" End If %>px;
  271.     }
  272.  
  273.     .InlineHelpSpanStyle
  274.     {
  275.         COLOR: <% If Len(rsTemplate("question_subtext_font_color")) > 0 Then Response.Write rsTemplate("question_subtext_font_color") Else Response.Write SUR_DEFAULT_FONT_COLOR End If %>;
  276.         FONT-FAMILY: <%=rsTemplate("question_subtext_font_family")%>;
  277.         FONT-SIZE: <% If Len(rsTemplate("question_subtext_font_size")) > 0 Then Response.Write rsTemplate("question_subtext_font_size") Else Response.Write "10" End If %>px;
  278.         FONT-WEIGHT: <%=rsTemplate("question_subtext_font_weight")%>;
  279.     }
  280.  
  281.     .SurveyPageTitle
  282.     {
  283.         COLOR: <% If Len(rsTemplate("page_title_font_color")) > 0 Then Response.Write rsTemplate("page_title_font_color") Else Response.Write SUR_DEFAULT_FONT_COLOR End If %>;
  284.         FONT-FAMILY: <%=rsTemplate("page_title_font_family")%>;
  285.         FONT-SIZE: <% If Len(rsTemplate("page_title_font_size")) > 0 Then Response.Write rsTemplate("page_title_font_size") Else Response.Write "16" End If %>px;
  286.         FONT-WEIGHT: <%=rsTemplate("page_title_font_weight")%>;
  287.     }
  288.  
  289.     .QuestionHeadingStyle
  290.     {
  291.         COLOR: <% If Len(rsTemplate("page_title_font_color")) > 0 Then Response.Write rsTemplate("page_title_font_color") Else Response.Write SUR_DEFAULT_FONT_COLOR End If %>;
  292.         FONT-FAMILY: <%=rsTemplate("page_title_font_family")%>;
  293.         FONT-SIZE: <% If Len(rsTemplate("page_title_font_size")) > 0 Then Response.Write rsTemplate("page_title_font_size") Else Response.Write "16" End If %>px;
  294.         FONT-WEIGHT: <%=rsTemplate("page_title_font_weight")%>;
  295.     }
  296.  
  297.     .SurveyNavigationLink A
  298.     {
  299.         COLOR: <% If Len(rsTemplate("navigation_link_font_color")) > 0 Then Response.Write rsTemplate("navigation_link_font_color") Else Response.Write SUR_DEFAULT_FONT_COLOR End If %>;
  300.         FONT-FAMILY: <%=rsTemplate("navigation_link_font_family")%>;
  301.         FONT-SIZE: <% If Len(rsTemplate("navigation_link_font_size")) > 0 Then Response.Write rsTemplate("navigation_link_font_size") Else Response.Write "14" End If %>px;
  302.         FONT-WEIGHT: <%=rsTemplate("navigation_link_font_weight")%>;
  303.     }
  304. </style>
  305. <%
  306.     'Clean up
  307.     rsTemplate.Close
  308.     Set rsTemplate = Nothing
  309.     
  310.     'Get the page title and page introduction for this page
  311.     strSQL = "SELECT page_title, page_introduction " & _
  312.              "FROM sur_page " & _
  313.              "WHERE survey_id = " & lngSurveyID & _
  314.              " AND page_number = " & lngActualPageNumber
  315.     rsPage.Open ConvertSQL(strSQL), SURVEY_APP_CONNECTION, adOpenForwardOnly, adLockReadOnly, adCmdText
  316.     If rsPage.EOF Then
  317.         strPageTitle = ""    
  318.         strPageIntroduction = ""    
  319.     Else
  320.         rsPage.MoveFirst
  321.         strPageTitle = rsPage("page_title")
  322.         strPageIntroduction = rsPage("page_introduction")
  323.     End If
  324.     rsPage.Close
  325.     Set rsPage = Nothing
  326.  
  327. %>
  328.  
  329. <body class="SurveyBodyStyle">
  330. <%
  331.     'If an HTML header was provided, display it
  332.     If Len(strHTMLTop) > 0 Then
  333.         Response.Write strHTMLTop
  334.     End If
  335. %>
  336. <table border="0" cellspacing="0" cellpadding="5" width="760" align="<% If strSurveyAlignment = SUR_SURVEY_ALIGNMENT_CENTER Then Response.Write "center" End If %>">
  337. <%
  338.     'Optionally display a logo at the top of the survey
  339.     If IsNull(strLogoPath) Or Len(strLogoPath) = 0 Then
  340. %>
  341.         <tr>
  342.             <td height="44" valign="bottom">
  343.                 <% If strDisplayBorderYN = SUR_BOOLEAN_NEGATIVE Then Response.Write "      " End If %><span class="H1HeadingStyle"><a name="skipnav" tabindex="1"><%=strTitle%></a></span>
  344.             </td>
  345.         </tr>
  346. <%    
  347.     Else
  348.         'Whether the image alignment is left or right determines how the image and title are rendered
  349.         If strLogoAlignment = SUR_LOGO_ALIGNMENT_LEFT Then
  350. %>
  351.             <tr>
  352.                 <td align="left">
  353.                     <img border="0" src="<%=strLogoPath%>" alt="Survey logo">
  354.                 </td>
  355.                 <td align="right">
  356.                     <span class="H1HeadingStyle"><a name="skipnav" tabindex="1"><%=strTitle%></a></span>
  357.                 </td>
  358.             </tr>
  359. <%    
  360.         ElseIf strLogoAlignment = SUR_LOGO_ALIGNMENT_RIGHT Then
  361. %>
  362.             <tr>
  363.                 <td align="left">
  364.                     <span class="H1HeadingStyle"><a name="skipnav" tabindex="1"><%=strTitle%></a></span>
  365.                 </td>
  366.                 <td align="right">
  367.                     <img border="0" src="<%=strLogoPath%>" alt="Survey logo">
  368.                 </td>
  369.             </tr>
  370. <%    
  371.         Else
  372. %>
  373.             <tr>
  374.                 <td align="left">
  375.                     <img border="0" src="<%=strLogoPath%>" alt="Survey logo">
  376.                 </td>
  377.             </tr>
  378.             <tr>
  379.                 <td align="left">
  380.                     <span class="H1HeadingStyle"><a name="skipnav" tabindex="1"><%=strTitle%></a></span>
  381.                 </td>
  382.             </tr>
  383. <%    
  384.         End If
  385.     End If
  386. %>    
  387. </table>
  388. <%
  389.     'Optionally display the border
  390.     If strDisplayBorderYN = SUR_BOOLEAN_POSITIVE Then
  391. %>
  392.         <table border="0" 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>
  393.         <table cellpadding="0" border="0" style="background-color:<%=strSurveyBackgroundColor%>" width="100%"><tr><td>
  394. <%
  395.     Else
  396. %>
  397.         <table border="0" 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>
  398. <%
  399.     End If
  400. %>
  401.     <table cellpadding="3" cellspacing="2" border="0" width="100%">
  402. <%
  403.         'Only display the page number if a page numbering format was selected
  404.         If rsSurvey("page_numbering_format") <> SUR_PAGE_NUMBERING_DO_NOT_DISPLAY Then
  405. %>
  406.             <tr>
  407.                 <td width="28"> </td>
  408.                 <td align="right" valign="top">
  409. <%        
  410.                     'Display the page numbers in the appropriate format
  411.                     If rsSurvey("page_numbering_format") = SUR_PAGE_NUMBERING_DISPLAY_PROGRESS Then
  412. %>                    
  413.                         <span class="PageNumberFontStyle">
  414.                             Page <%=lngActualPageNumber%> of <%=lngPageCount%>
  415.                         </span>
  416. <%
  417.                     ElseIf rsSurvey("page_numbering_format") = SUR_PAGE_NUMBERING_DISPLAY_PROGRESS_BAR Then
  418. %>                    
  419.                         <table width="100" border="0" cellspacing="0" cellpadding="2" height="12">
  420.                             <tr>
  421.                                 <td align="center">
  422.                                     <span class="Normal">
  423.                                         Page <%=lngActualPageNumber%> of <%=lngPageCount%>
  424.                                     </span>
  425.                                 </td>
  426.                             </tr>
  427.                         </table>
  428.                         <table width="100" border="0" cellspacing="0" cellpadding="1" height="12">
  429.                             <tr>
  430.                                 <td bgcolor="black">
  431.                                     <table width="100" border="0" cellspacing="0" cellpadding="0" height="12">
  432.                                         <tr> 
  433.                                             <td width="<%=CInt((lngActualPageNumber / lngPageCount ) * 100)%>" bgcolor="<%=strProgressFirstColor%>"></td>
  434.                                             <td width="<%=CInt((100 - ((lngActualPageNumber / lngPageCount ) * 100)))%>" bgcolor="<%=strProgressSecondColor%>"></td>
  435.                                         </tr>
  436.                                     </table>
  437.                                 </td>
  438.                             </tr>
  439.                         </table>
  440.                         
  441. <%
  442.                     Else 'SUR_PAGE_NUMBERING_DISPLAY_PAGE_NUMBER_ONLY
  443. %>                    
  444.                         <span class="PageNumberFontStyle">
  445.                             Page <%=lngActualPageNumber%>
  446.                         </span>
  447. <%
  448.                     End If
  449. %>                    
  450.                 </td>
  451.                 <td width="14"> </td>
  452.             </tr>
  453. <%
  454.         Else
  455. %>
  456.             <tr><td colspan="3"><br></td></tr>
  457. <%
  458.         End If
  459.         
  460.         'Only display the page title if there is one
  461.         If Len(strPageTitle) > 0 Then
  462. %>
  463.             <tr>
  464.                 <td width="28" rowspan="5"> </td>
  465.                 <td>
  466.                     <span class="SurveyPageTitle">
  467.                         <%=strPageTitle%>
  468.                     </span>
  469.                 </td>
  470.                 <td width="14" rowspan="5"> </td>
  471.             </tr>
  472. <%
  473.         End If
  474.         
  475.         'Only display the page introduction if there is one
  476.         If Len(strPageIntroduction) > 0 Then
  477. %>
  478.             <tr>
  479.                 <td align="left" valign="top">
  480.                     <span class="Normal"><%=strPageIntroduction%></span>
  481.                 </td>
  482.             </tr>
  483. <%
  484.         End If
  485. %>
  486.     </table>
  487.     <br>
  488. <%
  489.     If Request.Form("AdminOrOwnerEditResponse") = SUR_BOOLEAN_POSITIVE_DISPLAY Or Request.QueryString("Edit") = SUR_BOOLEAN_POSITIVE_DISPLAY Then
  490.         strEditValue = SUR_BOOLEAN_POSITIVE_DISPLAY
  491.     Else
  492.         strEditValue = SUR_BOOLEAN_NEGATIVE_DISPLAY
  493.     End If
  494. %>    
  495.     <form action="<%=SUR_APPLICATION_ROOT_URL%>/TakeSurveyAction.asp?DisplayHeader=<%=Request.QueryString("DisplayHeader")%>" method="post" name="frmSurvey" ID="Form1">
  496.     <table cellpadding="2" cellspacing="0" border="0" width="100%" height="200">
  497.             <input type="hidden" value="<%=strEditValue%>" name="AdminOrOwnerEditResponse">
  498.             <input type="hidden" value="<%=lngResponseID%>" name="AdminOrOwnerResponseID">
  499.             <input type="hidden" value="<%=EncryptSurveyID(lngSurveyID)%>" name="SurveyID">
  500.             <input type="hidden" value="<%=lngEmailAddressID%>" name="EmailAddressID">
  501.             <input type="hidden" value="<%=lngEmailMessageID%>" name="EmailMessageID">
  502.             <input type="hidden" value="<%=Request.QueryString("EID")%>" name="EID">
  503.             <input type="hidden" value="<%=strResponseType%>" name="ResponseType">
  504. <%
  505.             If InStr(Request.ServerVariables("QUERY_STRING"), "ItemID") > 0 Then
  506.                 For Each strTempValue In Request.Querystring
  507.                     If Left(strTempValue, 6) = "ItemID" Then
  508.                         strItemIDValues = strItemIDValues & strTempValue & "=" & Request.Querystring(strTempValue) & "&"
  509.                     End If
  510.                 Next
  511.             Else
  512.                 strItemIDValues = ""
  513.             End If
  514. %>
  515.             <input type="hidden" value="<%=strItemIDValues%>" name="ItemIDValues">
  516.             <input type="hidden" value="<%=Request.ServerVariables("QUERY_STRING")%>" name="PostedQueryString">
  517.             <input type="hidden" value="<%=lngDisplayPageNumber%>" name="DisplayPageNumber">
  518. <%
  519.             If SUR_DATABASE_TYPE = "SQLServer" Or SUR_DATABASE_TYPE = "MySQL" Then
  520.                 strTempDate = Year(Now()) & SUR_DATE_DELIMITER & Month(Now()) & SUR_DATE_DELIMITER & Day(Now())
  521.             Else
  522.                 If SUR_DATE_FORMAT = SUR_DATE_FORMAT_AMERICAN Then
  523.                     strTempDate = Month(Now()) & SUR_DATE_DELIMITER & Day(Now()) & SUR_DATE_DELIMITER & Year(Now())
  524.                 Else 'SUR_DATE_FORMAT_EUROPEAN
  525.                     strTempDate = Day(Now()) & SUR_DATE_DELIMITER & Month(Now()) & SUR_DATE_DELIMITER & Year(Now())
  526.                 End If
  527.             End If
  528. %>
  529.             <input type="hidden" value="<%=strTempDate & " " & DisplayCurrentTime()%>" name="ResponseStartDate">
  530.             <input type="hidden" value="<%=lngActualPageNumber%>" name="ActualPageNumber">
  531.             <input type="hidden" value="<% If flgUpdatingSurvey = True Then Response.Write("True") Else Response.Write("False") End If %>" name="hdnUpdatingSurvey">
  532. <%
  533.             'Add a value to SESSION indicating the survey and page number the user is about to take.  On the "action"
  534.             'page for this survey, check this value again to make sure that the same page is not submitted twice.
  535.             Session(SUR_UNIQUE_RESPONSE_IDENTIFIER) = CStr(lngSurveyID) & CStr(lngActualPageNumber)
  536.             
  537.             strQuestionNumberingFormat = rsSurvey("question_numbering_format")    
  538.             Do While Not rsSurvey.EOF
  539. %>
  540.                 <tr>
  541.                     <td width="5"> </td>
  542.                     <td valign="top">
  543.                     <%DisplayFormattedItem rsSurvey, flgUpdatingSurvey, True%>
  544.                     </td>
  545.                     <td width="5"> </td>
  546.                 </tr>
  547.                 <tr>
  548.                     <td colspan="3"> </td>
  549.                 </tr>
  550. <%    
  551.                 rsSurvey.MoveNext
  552.             Loop
  553.  
  554.             'If the question numbering format is within each page, update the next question number to 1, since that is
  555.             'the number each page will always start with.  Otherwise, leave the variable lngQuestionNumber as is, which 
  556.             'will cause the next page to be started with the subsequent number in the sequence.
  557.             If strQuestionNumberingFormat = SUR_QUESTION_NUMBERING_EACH_PAGE Then
  558.                 lngQuestionNumber = 1
  559.             End If
  560. %>            
  561.             <input type="hidden" value="<%=lngResponseID%>" name="ResponseID">
  562.             <input type="hidden" value="<%=lngQuestionNumber%>" name="QuestionNumber">
  563.     </table>
  564.  
  565.     <table border="0" cellpadding="10" cellspacing="3" width="100%">
  566.         <tr>
  567.             <td width="25"> </td>
  568.             <td align="center">
  569. <%
  570.                 'If this is the last page, display a "Done" button; otherwise, display a "Next" button.
  571.                 If CLng(lngPageCount) = CLng(lngActualPageNumber) Then
  572.                     'Use the button for the Next button, if provided
  573.                     If Len(strNavigationDoneButtonPath) > 0 Then
  574.                         'Use the button path provided, if there is one; otherwise, use the default button
  575.                         If Len(strNavigationDoneButtonPath) > 0 Then
  576. %>
  577.                             <input type="image" border="0" alt="Done" name="btnDone" src="<%=SUR_APPLICATION_ROOT_URL & "/" & strNavigationDoneButtonPath%>">  
  578. <%
  579.                         Else
  580. %>
  581.                             <input type="image" border="0" alt="Done" name="btnDone" src="<%=SUR_APPLICATION_ROOT_URL%>/Resources/SurveyButtons/Done.gif">  
  582. <%
  583.                         End If                    
  584.                     Else
  585. %>
  586.                         <span class="SurveyNavigationLink">
  587.                             <%=strNavigationDoneLinkText%>  
  588.                         </span>
  589. <%
  590.                     End If
  591.                 End If
  592. %>                    
  593.             </td>
  594.             <td width="5"> </td>
  595.         </tr>
  596.     </table>
  597.     </form>
  598. <%
  599.     'If the border was displayed, close out an extra table
  600.     If strDisplayBorderYN = SUR_BOOLEAN_POSITIVE Then
  601. %>
  602.         </td></tr></table>
  603. <%
  604.     End If
  605. %>    
  606. </td></tr></table>
  607. <%
  608.     'If an HTML footer was provided, display it
  609.     If Len(strHTMLBottom) > 0 Then
  610.         Response.Write strHTMLBottom
  611.     Else
  612.         Response.Write "<br>"
  613.     End If
  614. %>
  615. </body>
  616. </html>
  617. <%
  618.     'Clean up
  619.     rsSurvey.Close
  620.     Set rsSurvey = Nothing
  621.  
  622.     'Ensure that the web server returns the page
  623.     Response.Flush
  624. %>
  625.