home *** CD-ROM | disk | FTP | other *** search
/ bombers.k12.ar.us / bombers.k12.ar.us.tar / bombers.k12.ar.us / survey / PageCondition.asp < prev    next >
Text File  |  2006-11-29  |  32KB  |  719 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 allows a user to insert, delete, and modify 
  7. '                      page conditions.
  8. '
  9. '   COPYRIGHT NOTICE                                
  10. '
  11. '   See attached Software License Agreement
  12. '
  13. '   (c) Copyright 2002 - 2006 by ClassApps.com.  All rights reserved.
  14. '***********************************************************************
  15. %>
  16. <!--#Include File="Include/SurveyUtility_inc.asp"-->
  17. <!--#Include File="Include/Utility_inc.asp"-->
  18. <!--#Include File="Include/Constants_inc.asp"-->
  19. <!--#Include File="Include/Config_inc.asp"-->
  20. <!--#Include File="Include/ID_inc.asp"-->
  21. <!--#Include File="Include/adovbs_inc.asp"-->
  22. <!--#Include File="Include/CurrentUser_inc.asp"-->
  23. <!--#Include File="Include/SurveySecurity_inc.asp"-->
  24.  
  25. <html>
  26. <head>
  27.     <title>Page Conditions</title>
  28.     <link rel="stylesheet" href="Resources/StyleSheet/SurveyStyle.css">
  29. </head>
  30.  
  31. <%
  32.     'If the user is not the survey owner and does not have "Admin" permission, redirect to the access denied page.
  33.     If IsUserOwnerOrAdmin(Request.QueryString("SurveyID")) = False Then
  34.         Response.Redirect "AccessDenied.asp?Reason=" & SUR_ACCESS_DENIED_NOT_ADMIN_SECURITY_LEVEL
  35.     End If
  36.  
  37.     Dim lngSurveyID
  38.     Dim strSurveyName
  39.     Dim lngPageNumber
  40.     Dim rsPageConditions
  41.     Dim rsQuestions
  42.     Dim strSQL
  43.     Dim lngDisplayItemID
  44.     Dim lngItemTypeID
  45.     Dim rsAnswers
  46.     Dim strPageTitle
  47.     Dim strState
  48.     Dim lngPageConditionID
  49.     Dim rsPageCondition
  50.     Dim lngSelectedItemID
  51.     Dim lngSelectedOperatorID
  52.     Dim lngSelectedAnswerID
  53.     Dim strSelectedAnswerText
  54.     Dim strValue
  55.     Dim lngSelectedGroupNumber
  56.     Dim lngPageConditionCount
  57.     Dim flgRequired
  58.     Dim rsItemDetails
  59.     Dim conItemDetails
  60.     Dim strDatabaseSQL
  61.     Dim strDatabaseDSN
  62.     Dim conPageConditions
  63.     Dim flgAnswersExist
  64.     Dim strTableRowColor
  65.             
  66.     'Initialization
  67.     lngSurveyID = Request.QueryString("SurveyID")
  68.     strSurveyName = Request.QueryString("SurveyName")
  69.     lngPageNumber = Request.QueryString("PageNumber")
  70.     lngPageConditionCount = 0
  71.     Set rsPageConditions = Server.CreateObject("ADODB.Recordset")
  72.     Set rsQuestions = Server.CreateObject("ADODB.Recordset")
  73.     Set rsAnswers = Server.CreateObject("ADODB.Recordset")
  74.     Set conPageConditions = Server.CreateObject("ADODB.Connection")
  75.     Set conItemDetails = Server.CreateObject("ADODB.Connection")
  76.     conPageConditions.Open SURVEY_APP_CONNECTION
  77.     
  78.     'If a question was selected and the page was resubmitted, initialize the variable that will be used to determine
  79.     'which page's items to display.  Otherwise, initialize the variable to 0, and the first question will be selected
  80.     'and its items displayed.
  81.     If Len(Request.Form("cboQuestion")) > 0 Then
  82.         lngDisplayItemID = Request.Form("cboQuestion")
  83.     Else
  84.         lngDisplayItemID = 0
  85.     End If
  86.  
  87.     'Initialize state-dependent variables    
  88.     If Request.QueryString("State") = SUR_STATE_EDIT Then
  89.         strState = SUR_STATE_EDIT
  90.         strPageTitle = "Edit Existing Page Condition"
  91.         lngPageConditionID = Request.QueryString("PageConditionID")
  92.         
  93.         'In EDIT mode, query and save data about the page condition
  94.         Set rsPageCondition = Server.CreateObject("ADODB.Recordset")
  95.         strSQL = "SELECT dependent_item_id, operator_id, answer_id, group_number, answer_text " & _
  96.                     "FROM sur_page_condition " & _
  97.                     "WHERE page_condition_id = " & lngPageConditionID
  98.         rsPageCondition.Open ConvertSQL(strSQL), SURVEY_APP_CONNECTION, adOpenDynamic, , adCmdText
  99.         rsPageCondition.MoveFirst
  100.         lngSelectedItemID = rsPageCondition("dependent_item_id")
  101.         lngDisplayItemID = lngSelectedItemID
  102.         lngSelectedOperatorID = rsPageCondition("operator_id")
  103.         lngSelectedAnswerID = rsPageCondition("answer_id")
  104.         If rsPageCondition("answer_text") <> SUR_ANSWER_TEXT_NULL Then
  105.             strSelectedAnswerText = rsPageCondition("answer_text")
  106.         End If
  107.         lngSelectedGroupNumber = rsPageCondition("group_number")
  108.         rsPageCondition.Close
  109.         Set rsPageCondition = Nothing
  110.     Else
  111.         strState = SUR_STATE_INSERT
  112.         strPageTitle = "Manage Page Conditions"
  113.     End If
  114. %>
  115.  
  116. <script language ="JavaScript" src="ClientInclude/Utility.js"></script>
  117. <script language="JavaScript">
  118. function submitCheck()
  119. {
  120.     if (trim(document.forms['frmPageCondition'].cboQuestion.value) == '<%=SUR_COMBO_NO_AVAILABLE_QUESTIONS%>')
  121.     {    
  122.         alert("A page condition cannot be created because there are no questions on any prior pages.  To add a page condition to this page, go back and add a question to a previous page.");
  123.         document.forms['frmPageCondition'].cboQuestion.focus();
  124.         return false;
  125.     }
  126.     else if (trim(document.forms['frmPageCondition'].cboOperator.value) == '<%=SUR_COMBO_NO_AVAILABLE_OPERATORS%>')
  127.     {    
  128.         alert("No page conditions are available for this operator.  Please select a different question that has operators available.");
  129.         document.forms['frmPageCondition'].cboOperator.focus();
  130.         return false;
  131.     }
  132.     else
  133.     {
  134.         document.forms['frmPageCondition'].cboQuestion.disabled = false;
  135.         document.forms['frmPageCondition'].action = 'PageConditionAction.asp';
  136.     }
  137. }
  138.  
  139. function deletePageCondition(strPageConditionID)
  140. {
  141.     if (confirm("Are you sure you want to delete this page condition?") == true) //OK
  142.     {
  143.         window.location.href = 'DeletePageCondition.asp?SurveyID=<%=lngSurveyID%>&SurveyName=<%=JavaScriptEncode(strSurveyName)%>&PageNumber=<%=lngPageNumber%>&PageConditionID=' + strPageConditionID;
  144.     }
  145. }
  146.  
  147. <%
  148.     'Only display these client-side JavaScript functions in INSERT mode
  149.     If strState = SUR_STATE_INSERT Then
  150. %>
  151.         function questionSelected()
  152.         {
  153.             document.forms['frmPageCondition'].action = 'PageCondition.asp?SurveyID=<%=lngSurveyID%>&SurveyName=<%=JavaScriptEncode(strSurveyName)%>&PageNumber=<%=lngPageNumber%>&State=<%=strState%>&PageConditionID=<%=lngPageConditionID%>';
  154.             document.forms['frmPageCondition'].submit();
  155.         }
  156.  
  157.         function editPageCondition(strPageConditionID)
  158.         {
  159.             window.location.href = 'PageCondition.asp?SurveyID=<%=lngSurveyID%>&SurveyName=<%=JavaScriptEncode(strSurveyName)%>&PageNumber=<%=lngPageNumber%>&PageConditionID=' + strPageConditionID + '&State=<%=SUR_STATE_EDIT%>';
  160.         }
  161. <%
  162.     End If
  163. %>
  164. </script>
  165.  
  166. <body class="MainBodyStyle">
  167.  
  168. <!--#Include File="Include/FrameworkTop_inc.asp"-->
  169.  
  170. <table border="0" cellspacing="0" cellpadding="0" width="754" class="MediumBlueBackgroundColor">
  171.     <tr>
  172.         <td height="36" valign="center">
  173.               <span class="H1HeadingStyle"><a name="skipnav" tabindex="1">Page Conditions</a></span> <img style="cursor:hand" alt="Help" onClick="javascript:window.open('Help/Help.htm#PageConditions', null, 'menubar=no,toolbar=no,titlebar=no,status=no,left=10,top=10,scrollbars=yes,resizable=yes,height=550,width=770');" border="0" src="Resources/Images/Help.gif">
  174.         </td>
  175.     </tr>
  176. </table>
  177.  
  178. <!--#Include File="Include/FrameworkTop2_inc.asp"-->
  179.  
  180. <form method="post" name="frmPageCondition" onSubmit="return submitCheck();">
  181.     <input type="hidden" name="SurveyID" value="<%=lngSurveyID%>">
  182.     <input type="hidden" name="PageNumber" value="<%=lngPageNumber%>">
  183.     <input type="hidden" name="SurveyName" value="<%=Request.QueryString("SurveyName")%>">
  184.     <input type="hidden" name="State" value="<%=strState%>">
  185. <%
  186.     'The page condition ID only exists in EDIT mode
  187.     If strState = SUR_STATE_EDIT Then
  188. %>    
  189.         <input type="hidden" name="PageConditionID" value="<%=lngPageConditionID%>">
  190. <%
  191.     End If
  192. %>        
  193.     <table width="740" border="0" cellpadding="0" cellspacing="0" class="LightGrayBackgroundColor">
  194.         <tr>
  195.             <td width="1" rowspan="10"></td>
  196.             <td>
  197.                 <table cellspacing="6" cellpadding="0" border="0" width="100%">
  198.                     <tr>
  199.                         <td width="65%" align="left">
  200.                             <span class="H2HeadingStyle"> <%=strPageTitle%></span>
  201.                         </td>
  202.                         <td width="35%" align="right">
  203.                             <span class="Required">*</span><span class="InlineHelpSpanStyle"> = Required</span>
  204.                         </td>
  205.                     </tr>
  206.                     <tr>
  207.                         <td colspan="2">
  208. <%
  209.                             If strState = SUR_STATE_INSERT Then
  210. %>                        
  211.                                  <span class="Normal">Page <span class="NormalBold"><%=lngPageNumber%></span> of '<span class="NormalBold"><%=strSurveyName%></span>' survey.</span>
  212. <%
  213.                             Else 'EDIT mode
  214. %>                        
  215.                                  <span class="Normal">Page condition located on page <span class="NormalBold"><%=lngPageNumber%></span> of '<span class="NormalBold"><%=strSurveyName%></span>' survey.</span>
  216. <%
  217.                             End If
  218. %>                        
  219.                         </td>
  220.                     </tr>
  221.                 </table>
  222.             </td>
  223.             <td width="1" rowspan="10"> </td>
  224.         </tr>
  225.     </table>
  226.     <table border="0" cellpadding="0" cellspacing="0" width="100%"><tr><td height="1" background="Resources/Images/ThinDivider.gif"></td></tr>
  227.     <table border="0" cellpadding="0" cellspacing="6" width="740" class="WhiteBackgroundColor">
  228. <%
  229.         'Only display the existing conditions in INSERT mode (manage page conditions mode).
  230.         If strState = SUR_STATE_INSERT Then
  231. %>        
  232.             <tr>
  233.                 <td width="1" rowspan="10"></td>
  234.                 <td colspan="2" valign="bottom" height="24">
  235.                     <span class="QuestionSectionHeadingSpanStyle">Existing Page Conditions</span><br>
  236.                 </td>
  237.                 <td width="1" rowspan="10"></td>
  238.             </tr>
  239.             <tr>
  240.                 <td colspan="2" valign="top" height="30">
  241.                     <span class="Normal">
  242.                         Page conditions in the same group are evaluated together with an AND operator.  Each group is 
  243.                         evaluated with other groups using an OR operator.  To evaluate all page conditions, use a single group number.
  244.                     </span>
  245.                 </td>
  246.             </tr>
  247.             <tr>
  248.                 <td colspan="2">
  249.  
  250. <%
  251.                     'Get the existing page conditions for this page
  252.                     strSQL = "SELECT sur_page_condition.answer_id, sur_page_condition.group_number, " & _
  253.                                 "sur_page_condition.operator_id, page_condition_id, sur_item.item_text, " & _
  254.                                 "sur_item_answer.answer_text As ItemAnswerText, sur_page_condition.answer_text As ConditionAnswerText " & _
  255.                                 "FROM (sur_item INNER JOIN sur_page_condition ON " & _
  256.                                 "sur_item.item_id = sur_page_condition.dependent_item_id) " & _
  257.                                 "LEFT JOIN sur_item_answer ON sur_page_condition.answer_id = sur_item_answer.answer_id " & _
  258.                                 "WHERE survey_id = " & lngSurveyID & _
  259.                                 " AND page_number = " & lngPageNumber & _
  260.                                 " ORDER BY group_number"
  261.                     rsPageConditions.Open ConvertSQL(strSQL), SURVEY_APP_CONNECTION, adOpenDynamic, , adCmdText
  262. %>
  263.                     <table cellpadding="3" cellspacing="0" border="0" width="714">
  264.                         <tr class="TableHeadingColor" height="40">
  265.                             <td width="44" valign="center">
  266.                                 <span class="NormalBold">Group</span>
  267.                             </td>
  268.                             <td width="300" valign="center">
  269.                                 <span class="NormalBold">Question</span>
  270.                             </td>
  271.                             <td width="110" valign="center">
  272.                                 <span class="NormalBold">Operator</span>
  273.                             </td>
  274.                             <td width="160" valign="center">
  275.                                 <span class="NormalBold">Answer</span>
  276.                             </td>
  277.                             <td width="100" align="center" valign="center">
  278.                                 <span class="NormalBold">Actions</span>
  279.                             </td>
  280.                         </tr>
  281. <%                    
  282.                     'If there are no existing page conditions, display a message to that effect
  283.                     If rsPageConditions.EOF = True Then
  284. %>
  285.                         <tr>
  286.                             <td colspan="5" class="<%=strTableRowColor%>">
  287.                                 <span class="Normal">There are no conditions for this page.</span>
  288.                             </td>
  289.                         </tr>
  290. <%                
  291.                     Else 'There are existing page conditions
  292. %>
  293. <%                    
  294.                             rsPageConditions.MoveFirst
  295.                             Do While Not rsPageConditions.EOF
  296.                                 flgAnswersExist = True
  297.                                 lngPageConditionCount = lngPageConditionCount + 1
  298. %>
  299.                                 <tr class="<%=strTableRowColor%>">
  300.                                     <td>
  301.                                         <span class="Normal"><%=rsPageConditions("group_number")%><br></span>
  302.                                     </td>
  303.                                     <td>
  304.                                         <span class="Normal"><%=rsPageConditions("item_text")%><br></span>
  305.                                     </td>
  306.                                     <td>
  307.                                         <span class="Normal">
  308. <%
  309.                                             Select Case CLng(rsPageConditions("operator_id"))
  310.                                                 Case SUR_OPERATOR_EQUALS
  311.                                                     Response.Write SUR_OPERATOR_EQUALS_SHORT_TEXT
  312.                                                 Case SUR_OPERATOR_NOT_EQUALS
  313.                                                     Response.Write SUR_OPERATOR_NOT_EQUALS_SHORT_TEXT
  314.                                                 Case SUR_OPERATOR_GREATER_THAN
  315.                                                     Response.Write SUR_OPERATOR_GREATER_THAN_SHORT_TEXT
  316.                                                 Case SUR_OPERATOR_GREATER_THAN_OR_EQUAL_TO
  317.                                                     Response.Write SUR_OPERATOR_GREATER_THAN_OR_EQUAL_TO_SHORT_TEXT
  318.                                                 Case SUR_OPERATOR_LESS_THAN
  319.                                                     Response.Write SUR_OPERATOR_LESS_THAN_SHORT_TEXT
  320.                                                 Case SUR_OPERATOR_LESS_THAN_OR_EQUAL_TO
  321.                                                     Response.Write SUR_OPERATOR_LESS_THAN_OR_EQUAL_TO_SHORT_TEXT
  322.                                                 Case SUR_OPERATOR_CONTAINS
  323.                                                     Response.Write SUR_OPERATOR_CONTAINS_SHORT_TEXT
  324.                                                 Case SUR_OPERATOR_DOES_NOT_CONTAIN
  325.                                                     Response.Write SUR_OPERATOR_DOES_NOT_CONTAIN_SHORT_TEXT
  326.                                                 Case SUR_OPERATOR_ANSWERED
  327.                                                     Response.Write SUR_OPERATOR_ANSWERED_SHORT_TEXT
  328.                                                 Case SUR_OPERATOR_DID_NOT_ANSWER
  329.                                                     Response.Write SUR_OPERATOR_DID_NOT_ANSWER_SHORT_TEXT
  330.                                             End Select
  331. %>                                        
  332.                                         </span>
  333.                                     </td>
  334.                                     <td>
  335.                                         <span class="Normal">
  336. <%
  337.                                             'If the operator is Answered or Did Not Answer, the Answer column does not apply
  338.                                             If CLng(rsPageConditions("operator_id")) = SUR_OPERATOR_ANSWERED Or CLng(rsPageConditions("operator_id")) = SUR_OPERATOR_DID_NOT_ANSWER Then
  339.                                                 Response.Write "N/A"
  340.                                             'If the answer ID column is Null, display the text inputted for the page condition.  Otherwise,
  341.                                             'the answer ID column contains a valid answer ID, so display the answer from the sur_item_answer 
  342.                                             'table.
  343.                                             ElseIf CLng(rsPageConditions("answer_id")) = CLng(SUR_ANSWER_ID_NULL) Then
  344.                                                 'If the question type was Yes/No or True/False, and the user selected --None--,
  345.                                                 'it was stored as null text, so convert back to --None--
  346.                                                 If rsPageConditions("ConditionAnswerText") = SUR_ANSWER_TEXT_NULL Then
  347.                                                     Response.Write SUR_COMBO_NONE
  348.                                                 Else
  349.                                                     Response.Write rsPageConditions("ConditionAnswerText")
  350.                                                 End If
  351.                                             Else
  352.                                                 Response.Write rsPageConditions("ItemAnswerText")
  353.                                             End If
  354. %>                                        
  355.                                         </span>
  356.                                     </td>
  357.                                     <td align="center">
  358.                                         <a href="javascript:editPageCondition('<%=rsPageConditions("page_condition_id")%>');"><img alt="Edit this page condition" border="0" src="Resources/Buttons/EditSmall.gif" onMouseOver="this.style.cursor='hand'"></a>
  359.                                         <a href="javascript:deletePageCondition('<%=rsPageConditions("page_condition_id")%>');"><img alt="Delete this page condition" border="0" src="Resources/Buttons/DeleteSmall.gif" onMouseOver="this.style.cursor='hand'"></a>
  360.                                     </td>
  361.                                 </tr>
  362. <%                        
  363.                                 'Alternate the colors for the rows in the table
  364.                                 If strTableRowColor = "TableRowDarkColor" Then
  365.                                     strTableRowColor = "TableRowLightColor"
  366.                                 Else
  367.                                     strTableRowColor = "TableRowDarkColor"
  368.                                 End If
  369.  
  370.                                 rsPageConditions.MoveNext
  371.                             Loop                
  372.                         End If
  373. %>
  374.                     </table>
  375. <%
  376.                     'Clean up
  377.                     rsPageConditions.Close
  378.                     Set rsPageConditions = Nothing
  379. %>        
  380.                 </td>
  381.             </tr>
  382.             <tr>
  383.                 <td colspan="2" height="3">
  384.                 </td>
  385.             </tr>
  386. <%
  387.         End If 'strState = SUR_STATE_INSERT
  388. %>        
  389.     </table>
  390.     <table border="0" cellpadding="0" cellspacing="0" width="100%"><tr><td height="1" background="Resources/Images/ThinDivider.gif"></td></tr>
  391.     <table border="0" cellpadding="0" cellspacing="6" width="740" class="LightGrayBackgroundColor">
  392.         <tr>
  393.             <td width="1" rowspan="15"></td>
  394.             <td valign="bottom" colspan="2" height="24">
  395. <%
  396.                 If strState = SUR_STATE_INSERT Then
  397. %>
  398.                     <span class="QuestionSectionHeadingSpanStyle">
  399.                         Insert a Page Condition
  400.                     </span>
  401. <%
  402.                 Else
  403. %>                                    
  404.                     <span class="QuestionSectionHeadingSpanStyle">
  405.                         Edit Page Condition
  406.                     </span>
  407. <%
  408.                 End If
  409. %>                                    
  410.             </td>
  411.             <td width="1" rowspan="15"> </td>
  412.         </tr>
  413.         <tr>
  414.             <td valign="top" colspan="2" height="24">
  415. <%
  416.                 If strState = SUR_STATE_INSERT Then
  417. %>
  418.                     <span class="Normal">
  419.                         Create a page condition by selecting a question from a prior page, and then specifying the 
  420.                         operator and answer in the form below.  Note that the Provided and Did Not Provide operators do not 
  421.                         require an answer.
  422.                     </span>
  423. <%
  424.                 Else
  425. %>                                    
  426.                     <span class="Normal">
  427.                         Edit the existing page condition by selecting a question from a prior page, and then specifying the 
  428.                         operator and answer in the form below.
  429.                     </span>
  430. <%
  431.                 End If
  432. %>                                    
  433.             </td>
  434.         </tr>
  435.         <tr>
  436.             <td width="110">
  437.                 <span class="NormalBold"><label for="cboQuestion">Question:</label></span><span class="Required">*</span>
  438.             </td>
  439.             <td valign="top" width="620">
  440. <%
  441.                 'Disable the combo box in edit mode.  The question cannot be changed in edit mode.
  442. %>            
  443.                 <select style="width:560px" name="cboQuestion" id="cboQuestion" onChange="questionSelected();" <% If strState = SUR_STATE_EDIT Then Response.Write("DISABLED") End If %>>
  444. <%
  445.                     'Select all of the questions on the prior pages.
  446.                     strSQL = "SELECT i.item_id, i.item_type_id, i.required_yn, page_number, item_text " & _
  447.                                 "FROM sur_item i, sur_survey_to_item_mapping m, sur_item_type it " & _
  448.                                 "WHERE i.item_id = m.item_id " & _
  449.                                 "AND i.item_type_id = it.item_type_id " & _
  450.                                 "AND m.survey_id = " & lngSurveyID & _
  451.                                 " AND page_number < " & lngPageNumber & _
  452.                                 " AND question_yn = " & SQLEncode(SUR_BOOLEAN_POSITIVE) & _
  453.                                 " ORDER BY m.order_number DESC"
  454.                     rsQuestions.Open ConvertSQL(strSQL), SURVEY_APP_CONNECTION, adOpenDynamic, , adCmdText
  455.  
  456.                     'If there are no questions, display an option indicating that no questions are available
  457.                     If rsQuestions.EOF = True Then
  458. %>
  459.                         <option value="<%=SUR_COMBO_NO_AVAILABLE_QUESTIONS%>"><%=SUR_COMBO_NO_AVAILABLE_QUESTIONS%></option>
  460. <%                    
  461.                     Else 'There are questions on prior pages
  462.                         rsQuestions.MoveFirst
  463.                         
  464.                         'If this is the first time on the page, select the first question
  465.                         If lngDisplayItemID = 0 Then
  466.                             lngDisplayItemID = rsQuestions("item_id")
  467.                         End If
  468.                         
  469.                         Do While Not rsQuestions.EOF
  470.                             'Save the item type so that when the answer(s) for the question are rendered (below), we know
  471.                             'in what format to render them.
  472.                             If CLng(lngDisplayItemID) = CLng(rsQuestions("item_id")) Then
  473.                                 lngItemTypeID = rsQuestions("item_type_id")
  474.                                 flgRequired = rsQuestions("required_yn")
  475.                             End If
  476.                             'Determine value to use for comparisons to select the correct question
  477.                             If strState = SUR_STATE_INSERT Then
  478.                                 strValue = lngDisplayItemID
  479.                             Else 'EDIT mode
  480.                                 strValue = lngSelectedItemID
  481.                             End If
  482. %>
  483.                             <option <% If CLng(strValue) = CLng(rsQuestions("item_id")) Then Response.Write "SELECTED" End If %> value="<%=rsQuestions("item_id")%>"><%=rsQuestions("item_text")%> (Page <%=rsQuestions("page_number")%>)</option>
  484. <%                        
  485.                             rsQuestions.MoveNext
  486.                         Loop
  487.                     End If
  488.                     
  489.                     'Clean up
  490.                     rsQuestions.Close
  491.                     Set rsQuestions = Nothing
  492. %>        
  493.                 </select>
  494.             </td>
  495.         </tr>
  496.         <tr>
  497.             <td>
  498.                 <span class="NormalBold"><label for="cboOperator">Operator:</label></span><span class="Required">*</span>
  499.             </td>
  500.             <td valign="top">
  501.                 <select style="width:280px" name="cboOperator" id="cboOperator">
  502. <%
  503.                     'Determine value to use for comparisons to select the correct operator
  504.                     If strState = SUR_STATE_INSERT Then
  505.                         If Request.Form("cboOperator") <> SUR_COMBO_NO_AVAILABLE_OPERATORS Then
  506.                             strValue = Request.Form("cboOperator")
  507.                         End If
  508.                     Else 'EDIT mode
  509.                         strValue = lngSelectedOperatorID
  510.                     End If
  511.  
  512.                     'The equals and not equals operators are not available for the following question types
  513.                     If lngItemTypeID <> SUR_ITEM_RANKING And lngItemTypeID <> SUR_ITEM_MATRIX_SINGLE_SELECT_OPTIONS And lngItemTypeID <> SUR_ITEM_MATRIX_RATING_SCALE And lngItemTypeID <> SUR_ITEM_MATRIX_MULTISELECT_CHECKBOXES And lngItemTypeID <> SUR_ITEM_MATRIX_TEXT_BOXES And lngItemTypeID <> SUR_ITEM_OPEN_ENDED_ONE_OR_MORE_LINES Then
  514. %>
  515.                         <option <% If CLng(SUR_OPERATOR_EQUALS) = CLng(strValue) Then Response.Write "SELECTED" End If %> value="<%=SUR_OPERATOR_EQUALS%>"><%=SUR_OPERATOR_EQUALS_LONG_TEXT%></option>
  516.                         <option <% If CLng(SUR_OPERATOR_NOT_EQUALS) = CLng(strValue) Then Response.Write "SELECTED" End If %> value="<%=SUR_OPERATOR_NOT_EQUALS%>"><%=SUR_OPERATOR_NOT_EQUALS_LONG_TEXT%></option>
  517. <%
  518.                     Else
  519.                         'For these three question types, if the question is required, there are no operators to display
  520.                         If 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 Then
  521.                             If flgRequired = SUR_BOOLEAN_POSITIVE Then
  522. %>
  523.                                 <option value="<%=SUR_COMBO_NO_AVAILABLE_OPERATORS%>"><%=SUR_COMBO_NO_AVAILABLE_OPERATORS%></option>
  524. <%                                
  525.                             End If
  526.                         End If
  527.                     End If
  528.                     
  529.                     'Display inequality operators only for number and date question types.
  530.                     If lngItemTypeID = SUR_ITEM_DATE Or lngItemTypeID = SUR_ITEM_NUMBER Or lngItemTypeID = SUR_ITEM_CONSTANT_SUM Then
  531. %>                    
  532.                         <option <% If CLng(SUR_OPERATOR_GREATER_THAN) = CLng(strValue) Then Response.Write "SELECTED" End If %> value="<%=SUR_OPERATOR_GREATER_THAN%>"><%=SUR_OPERATOR_GREATER_THAN_LONG_TEXT%></option>
  533.                         <option <% If CLng(SUR_OPERATOR_GREATER_THAN_OR_EQUAL_TO) = CLng(strValue) Then Response.Write "SELECTED" End If %> value="<%=SUR_OPERATOR_GREATER_THAN_OR_EQUAL_TO%>"><%=SUR_OPERATOR_GREATER_THAN_OR_EQUAL_TO_LONG_TEXT%></option>
  534.                         <option <% If CLng(SUR_OPERATOR_LESS_THAN) = CLng(strValue) Then Response.Write "SELECTED" End If %> value="<%=SUR_OPERATOR_LESS_THAN%>"><%=SUR_OPERATOR_LESS_THAN_LONG_TEXT%></option>
  535.                         <option <% If CLng(SUR_OPERATOR_LESS_THAN_OR_EQUAL_TO) = CLng(strValue) Then Response.Write "SELECTED" End If %> value="<%=SUR_OPERATOR_LESS_THAN_OR_EQUAL_TO%>"><%=SUR_OPERATOR_LESS_THAN_OR_EQUAL_TO_LONG_TEXT%></option>
  536. <%
  537.                     End If
  538.  
  539.                     'Display "Contains" and "Doesn't Contain" for text question types, as well as checkboxes and radio buttons (because 
  540.                     'the latter two item types can have an "Other" choice
  541.                     If lngItemTypeID = SUR_ITEM_OPEN_ENDED_ONE_LINE Or lngItemTypeID = SUR_ITEM_OPEN_ENDED_COMMENTS_BOX  Or lngItemTypeID = SUR_ITEM_SINGLE_SELECT_OPTIONS  Or lngItemTypeID = SUR_ITEM_MULTISELECT_CHECKBOXES Or lngItemTypeID = SUR_ITEM_OPEN_ENDED_ONE_OR_MORE_LINES Or lngItemTypeID = SUR_ITEM_MATRIX_TEXT_BOXES Then
  542. %>                    
  543.                         <option <% If CLng(SUR_OPERATOR_CONTAINS) = CLng(strValue) Then Response.Write "SELECTED" End If %> value="<%=SUR_OPERATOR_CONTAINS%>"><%=SUR_OPERATOR_CONTAINS_LONG_TEXT%></option>
  544.                         <option <% If CLng(SUR_OPERATOR_DOES_NOT_CONTAIN) = CLng(strValue) Then Response.Write "SELECTED" End If %> value="<%=SUR_OPERATOR_DOES_NOT_CONTAIN%>"><%=SUR_OPERATOR_DOES_NOT_CONTAIN_LONG_TEXT%></option>
  545. <%
  546.                     End If
  547.  
  548.                     'Only display the "Answered" and "Didn't Answer" operators for questions that were not required.  For required
  549.                     'questions, the user must have answered the question.                    
  550.                     If flgRequired = SUR_BOOLEAN_NEGATIVE Then
  551. %>
  552.                         <option <% If CLng(SUR_OPERATOR_ANSWERED) = CLng(strValue) Then Response.Write "SELECTED" End If %> value="<%=SUR_OPERATOR_ANSWERED%>"><%=SUR_OPERATOR_ANSWERED_LONG_TEXT%></option>
  553.                         <option <% If CLng(SUR_OPERATOR_DID_NOT_ANSWER) = CLng(strValue) Then Response.Write "SELECTED" End If %> value="<%=SUR_OPERATOR_DID_NOT_ANSWER%>"><%=SUR_OPERATOR_DID_NOT_ANSWER_LONG_TEXT%></option>
  554. <%
  555.                     End If
  556. %>
  557.                 </select>
  558.             </td>
  559.         </tr>
  560.         <tr>
  561.             <td>
  562.                 <span class="NormalBold"><label for="cboAnswer">Answer:</label></span>
  563.             </td>
  564.             <td valign="top">
  565. <%
  566.                 'For checkboxes, dropdowns, and option buttons, display a combo box with all of the values
  567.                 If CLng(lngItemTypeID) = SUR_ITEM_SINGLE_SELECT_DROPDOWN Or CLng(lngItemTypeID) = SUR_ITEM_SINGLE_SELECT_OPTIONS Or CLng(lngItemTypeID) = SUR_ITEM_MULTISELECT_CHECKBOXES Then
  568.                     'Select all of the answers for the question. 
  569.                     strSQL = "SELECT answer_id, answer_text " & _
  570.                                 "FROM sur_item_answer " & _
  571.                                 "WHERE item_id = " & lngDisplayItemID & _
  572.                                 " ORDER BY order_number"
  573.                     rsAnswers.Open ConvertSQL(strSQL), SURVEY_APP_CONNECTION, adOpenDynamic, , adCmdText
  574.                     rsAnswers.MoveFirst
  575. %>
  576.                     <select style="width:280px" name="cboAnswer" id="cboAnswer">
  577. <%                    
  578.                     'For dropdowns and checkboxes, display a "None" option because the user may opt to enter text, instead.  Text can be
  579.                     'entered because of the "Other" choice
  580.                     If CLng(lngItemTypeID) = SUR_ITEM_SINGLE_SELECT_OPTIONS Or CLng(lngItemTypeID) = SUR_ITEM_MULTISELECT_CHECKBOXES Then
  581. %>
  582.                         <option value="<%=SUR_COMBO_NONE%>"><%=SUR_COMBO_NONE%></option>
  583. <%                    
  584.                     End If
  585.                         Do While Not rsAnswers.EOF
  586. %>
  587.                             <option <% If CLng(rsAnswers("answer_id")) = CLng(lngSelectedAnswerID) Then Response.Write "SELECTED" End If %> value="<%=rsAnswers("answer_id")%>"><%=rsAnswers("answer_text")%></option>
  588. <%                
  589.                             rsAnswers.MoveNext
  590.                         Loop
  591. %>
  592.                     </select>
  593. <%                    
  594.                     'For dropdowns and checkboxes, display a text box, too, for the answer type because the "Other" option is text-based
  595.                     If CLng(lngItemTypeID) = SUR_ITEM_SINGLE_SELECT_OPTIONS Or CLng(lngItemTypeID) = SUR_ITEM_MULTISELECT_CHECKBOXES Then
  596. %>                    
  597.                         <span class="Normal">or</span> <input value="<% If strState = SUR_STATE_EDIT Then Response.Write strSelectedAnswerText End If %>" type="text" style="width:255px" name="txtAnswer" id="txtAnswer" maxlength="50">
  598. <%                    
  599.                     End If
  600.                 ElseIf CLng(lngItemTypeID) = SUR_ITEM_DATABASE_DROPDOWN Then
  601.                     'Select the SQL and database connection for this question
  602.                     strSQL = "SELECT database_sql, database_dsn " & _
  603.                              "FROM sur_item " & _
  604.                              "WHERE item_id = " & lngDisplayItemID
  605.                     Set rsItemDetails = conPageConditions.Execute(ConvertSQL(strSQL), , adCmdText)
  606.                     rsItemDetails.MoveFirst
  607.                     strDatabaseSQL = rsItemDetails("database_sql")
  608.                     strDatabaseDSN = rsItemDetails("database_dsn")
  609.                     rsItemDetails.Close
  610.                     Set rsItemDetails = Nothing
  611.  
  612.                     'Select all of the answers for the question
  613.                     On Error Resume Next
  614.                     conItemDetails.Open strDatabaseDSN
  615.                     If Err.number = 0 Then
  616.                         Set rsAnswers = conItemDetails.Execute(ConvertSQL(strDatabaseSQL), , adCmdText)
  617.                         If Err.number <> 0 Then
  618.                             flgAnswersExist = False
  619.                         End If
  620.                     Else
  621.                         flgAnswersExist = False
  622.                     End If
  623.                     On Error GoTo 0
  624. %>
  625.                     <select style="width:280px" name="cboAnswer" id="cboAnswer">
  626. <%                    
  627.                         'If there are answers to this item, render them
  628.                         If flgAnswersExist = True Then
  629.                             rsAnswers.MoveFirst
  630.                             Do While Not rsAnswers.EOF
  631. %>
  632.                                 <option <% If CStr(rsAnswers("ItemValue")) = CStr(strSelectedAnswerText) Then Response.Write "selected" End If %> value="<%=rsAnswers("ItemValue")%>"><%=rsAnswers("ItemDisplay")%></option>
  633. <%                
  634.                                 rsAnswers.MoveNext
  635.                             Loop
  636.                         End If
  637. %>
  638.                     </select>
  639. <%
  640.                     'Clean up
  641.                     If flgAnswersExist = True Then
  642.                         rsAnswers.Close
  643.                     End If
  644.                     Set conItemDetails = Nothing
  645.                 ElseIf CLng(lngItemTypeID) = SUR_ITEM_YES_NO Then
  646. %>
  647.                     <select style="width:280px" name="cboAnswer" id="cboAnswer">
  648.                         <option <% If strSelectedAnswerText = SUR_COMBO_NONE Then Response.Write "SELECTED" End If %> value="<%=SUR_COMBO_NONE%>"><%=SUR_COMBO_NONE%></option>
  649.                         <option <% If strSelectedAnswerText = SUR_YES_NO_QUESTION_VALUE_YES Then Response.Write "SELECTED" End If %> value="<%=SUR_YES_NO_QUESTION_VALUE_YES%>"><%=SUR_YES_NO_QUESTION_VALUE_YES%></option>
  650.                         <option <% If strSelectedAnswerText = SUR_YES_NO_QUESTION_VALUE_NO Then Response.Write "SELECTED" End If %> value="<%=SUR_YES_NO_QUESTION_VALUE_NO%>"><%=SUR_YES_NO_QUESTION_VALUE_NO%></option>
  651.                     </select>
  652. <%                    
  653.                 ElseIf CLng(lngItemTypeID) = SUR_ITEM_TRUE_FALSE Then
  654. %>
  655.                     <select style="width:280px" name="cboAnswer" id="cboAnswer">
  656.                         <option <% If strSelectedAnswerText = SUR_COMBO_NONE Then Response.Write "SELECTED" End If %> value="<%=SUR_COMBO_NONE%>"><%=SUR_COMBO_NONE%></option>
  657.                         <option <% If strSelectedAnswerText = SUR_TRUE_FALSE_QUESTION_VALUE_TRUE Then Response.Write "SELECTED" End If %> value="<%=SUR_TRUE_FALSE_QUESTION_VALUE_TRUE%>"><%=SUR_TRUE_FALSE_QUESTION_VALUE_TRUE%></option>
  658.                         <option <% If strSelectedAnswerText = SUR_TRUE_FALSE_QUESTION_VALUE_FALSE Then Response.Write "SELECTED" End If %> value="<%=SUR_TRUE_FALSE_QUESTION_VALUE_FALSE%>"><%=SUR_TRUE_FALSE_QUESTION_VALUE_FALSE%></option>
  659.                     </select>
  660. <%                    
  661.                 Else 'Simply display a text box
  662. %>
  663.                     <input value="<% If strState = SUR_STATE_EDIT Then Response.Write strSelectedAnswerText End If %>" type="text" style="width:280px" name="txtAnswer" id="txtAnswer" maxlength="50">                
  664. <%                
  665.                 End If
  666. %>            
  667.             </td>
  668.         </tr>
  669.         <tr>
  670.             <td>
  671.                 <span class="NormalBold">Group:</span><span class="Required">*</span>
  672.             </td>
  673.             <td valign="top">
  674.                 <select style="width:280px" name="cboGroupNumber" id="cboGroupNumber">
  675.                     <option <% If CLng(lngSelectedGroupNumber) = 1 Then Response.Write "SELECTED" End If %> value="1">Group 1</option>
  676.                     <option <% If CLng(lngSelectedGroupNumber) = 2 Then Response.Write "SELECTED" End If %> value="2">Group 2</option>
  677.                     <option <% If CLng(lngSelectedGroupNumber) = 3 Then Response.Write "SELECTED" End If %> value="3">Group 3</option>
  678.                     <option <% If CLng(lngSelectedGroupNumber) = 4 Then Response.Write "SELECTED" End If %> value="4">Group 4</option>
  679.                     <option <% If CLng(lngSelectedGroupNumber) = 5 Then Response.Write "SELECTED" End If %> value="5">Group 5</option>
  680.                 </select>
  681.             </td>
  682.         </tr>
  683.         <tr>
  684.             <td valign="top" align="right" colspan="2">
  685. <%
  686.                 'Display a "Done" button in INSERT mode, and "Cancel" and "Delete" buttons in EDIT mode
  687.                 If strState = SUR_STATE_INSERT Then
  688. %>            
  689.                     <a href="ModifySurvey.asp?SurveyID=<%=lngSurveyID%>"><img border="0" border="0" alt="Finish editing page conditions for this page" name="btnDone" src="Resources/Buttons/Done.gif"></a>
  690. <%
  691.                 Else
  692. %>            
  693.                     <a href="PageCondition.asp?SurveyID=<%=lngSurveyID%>&PageNumber=<%=lngPageNumber%>&SurveyName=<%=strSurveyName%>"><img border="0" border="0" alt="Cancel" name="btnCancel" src="Resources/Buttons/Cancel.gif"></a>
  694.                     <a href="javascript:deletePageCondition('<%=Request.QueryString("PageConditionID")%>');"><img border="0" border="0" alt="Delete this page condition" name="btnDelete" src="Resources/Buttons/Delete.gif"></a>
  695. <%
  696.                 End If
  697. %>            
  698.                 <input type="image" border="0" border="0" alt="Save the current page condition" name="btnSave" src="Resources/Buttons/Save.gif">
  699.             </td>
  700.         </tr>
  701.         <input type="hidden" name="ItemTypeID" value="<%=lngItemTypeID%>">
  702.     </form>
  703. </table>
  704. <%
  705.     'Clean up 
  706.     conPageConditions.Close
  707.     Set conPageConditions = Nothing
  708. %>
  709.  
  710. <!--#Include File="Include/FrameworkBottom_inc.asp"-->
  711.  
  712. </body>
  713. </html>
  714.  
  715. <%        
  716.     'Ensure that the web server returns the page
  717.     Response.Flush
  718. %>
  719.