home *** CD-ROM | disk | FTP | other *** search
/ bombers.k12.ar.us / bombers.k12.ar.us.tar / bombers.k12.ar.us / survey_unconfigured / CreateSurvey.asp < prev    next >
Text File  |  2006-10-25  |  8KB  |  217 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 the user to create a new survey either
  7. '                      from scratch or from an existing survey.
  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/Config_inc.asp"-->
  17. <!--#Include File="Include/Utility_inc.asp"-->
  18. <!--#Include File="Include/SurveyUtility_inc.asp"-->
  19. <!--#Include File="Include/adovbs_inc.asp"-->
  20. <!--#Include File="Include/CurrentUser_inc.asp"-->
  21. <!--#Include File="Include/Constants_inc.asp"-->
  22. <!--#Include File="Include/SurveySecurity_inc.asp"-->
  23. <%
  24.     'If the user does not have "Create" or "Admin" permission, redirect them to the access denied page.
  25.     If lngUserSecurityLevel <> SUR_SECURITY_LEVEL_CREATE And lngUserSecurityLevel <> SUR_SECURITY_LEVEL_ADMIN Then
  26.         Response.Redirect "AccessDenied.asp?Reason=" & SUR_ACCESS_DENIED_NOT_ADMIN_SECURITY_LEVEL
  27.     End If
  28.  
  29.     Dim rsSurveys
  30.     Dim strSQL
  31.  
  32.     'Initialization 
  33.     Set rsSurveys = Server.CreateObject("ADODB.Recordset")
  34. %>
  35. <html>
  36. <head>
  37.     <title>Survey Administration -- Create Survey</title>
  38.     <link rel="stylesheet" href="Resources/StyleSheet/SurveyStyle.css">
  39. </head>
  40.  
  41. <script language ="JavaScript" src="ClientInclude/Utility.js"></script>
  42. <script language="JavaScript">
  43. function submitCheck() 
  44. {
  45.     // Make sure that a title has been entered
  46.     if (trim(document.forms['frmSurvey'].txtTitle.value) == "")
  47.     {    
  48.         alert("Please enter a value for the Title.");
  49.         document.forms['frmSurvey'].txtTitle.focus();
  50.         return false;
  51.     }
  52.  
  53.     // Only validate the form if the user is creating a survey from an existing survey.
  54.     if (document.forms['frmSurvey'].optType[1].checked == true)
  55.     {
  56.         // Make sure that the user selected a survey 
  57.         if (document.forms['frmSurvey'].cboSurvey.value == '<%=SUR_COMBO_PLEASE_SELECT%>')
  58.         {    
  59.             alert("Please select an existing survey.");
  60.             document.forms['frmSurvey'].cboSurvey.focus();
  61.             return false;
  62.         }
  63.  
  64.         // If the survey has a 'No surveys available' choice, there are no existing surveys, which means
  65.         // the user must create a new survey from scratch.
  66.         if (document.forms['frmSurvey'].cboSurvey.value == '<%=SUR_COMBO_NO_AVAILABLE_SURVEYS%>')
  67.         {    
  68.             alert("There are no existing surveys.  Please create a new survey from scratch.");
  69.             document.forms['frmSurvey'].optType[0].checked = true;
  70.             document.forms['frmSurvey'].optType[0].focus();
  71.             return false;
  72.         }
  73.     }
  74.  
  75.     return true;
  76. }
  77. </script>
  78.  
  79. <body class="MainBodyStyle" onLoad="javascript:document.forms['frmSurvey'].txtTitle.focus();">
  80.  
  81. <!--#Include File="Include/FrameworkTop_inc.asp"-->
  82.  
  83. <table border="0" cellspacing="0" cellpadding="0" width="754" class="MediumBlueBackgroundColor">
  84.     <tr>
  85.         <td height="36" valign="center">
  86.               <span class="H1HeadingStyle"><a name="skipnav" tabindex="1">Create Survey</a></span> <img style="cursor:hand" alt="Help" onClick="javascript:window.open('Help/Help.htm#CreateSurveys', 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">
  87.         </td>
  88.     </tr>
  89. </table>
  90.  
  91. <!--#Include File="Include/FrameworkTop2_inc.asp"-->
  92.  
  93. <table width="740" border="0" cellpadding="0" cellspacing="6" class="LightGrayBackgroundColor">
  94.     <form name="frmSurvey" method="post" action="CreateSurveyAction.asp" onSubmit="return submitCheck();">
  95.         <tr>
  96.             <td width="1" rowspan="2"></td>
  97.             <td valign="center" height="40">
  98.                 <span class="H2HeadingStyle">New Survey Options</span>
  99.             </td>
  100.             <td width="1" rowspan="2"> </td>
  101.         </tr>
  102.         <tr>
  103.             <td valign="top" class="Normal" height="18">
  104.                 Create a new survey either by starting from scratch or by copying an existing survey.
  105.             </td>
  106.         </tr>
  107.     </table>
  108.     <table border="0" cellpadding="0" cellspacing="0" width="100%"><tr><td height="1" background="Resources/Images/ThinDivider.gif"></td></tr>
  109.     <table border="0" cellpadding="0" cellspacing="6" width="740" class="WhiteBackgroundColor">
  110.         <tr>
  111.             <td colspan="4" height="8"></td>
  112.         </tr>
  113.         <tr>
  114.             <td width="1" rowspan="10"></td>
  115.             <td valign="top" width="30">
  116.                 <span class="NormalBold"><label for="txtTitle">Title:</label></span><span class="Required">*</span>
  117.             </td>
  118.             <td align="left" valign="top" colspan="3">
  119.                 <input type="text" name="txtTitle" id="txtTitle" maxlength="50" style="width:410">
  120.             </td>
  121.             <td width="1" rowspan="10"> </td>
  122.         </tr>
  123.         <tr>
  124.             <td valign="top">
  125.                 <label for="optType"> </label>
  126.             </td>
  127.             <td valign="top">
  128.                 <input checked type="radio" name="optType" id="optType" value="<%=SUR_CREATE_SURVEY_FROM_SCRATCH%>">
  129.             </td>
  130.             <td valign="top" colspan="2">
  131.                 <span class="NormalBold">From Scratch </span><span class="Normal">-- Create a new survey from scratch</span>
  132.             </td>
  133.         </tr>
  134.         <tr>
  135.             <td valign="top">
  136.                  
  137.             </td>
  138.             <td valign="top">
  139.                 <input type="radio" name="optType" id="optType" value="<%=SUR_CREATE_SURVEY_FROM_EXISTING%>">
  140.             </td>
  141.             <td valign="top" colspan="2">
  142.                 <span class="NormalBold">From Existing </span><span class="Normal">-- Copy questions, options, and page conditions from an existing survey</span>
  143.             </td>
  144.         </tr>
  145.         <tr>
  146.             <td valign="top">
  147.                  
  148.             </td>
  149.             <td valign="top">
  150.                  
  151.             </td>
  152.             <td valign="top" width="40">
  153.                 <span class="NormalBold"><label for="cboSurvey">Survey:</label></span>
  154.             </td>
  155.             <td align="left" valign="top">
  156.                 <select name="cboSurvey" id="cboSurvey" style="width:480">
  157. <%
  158.                     'Create the SQL for creating the list of surveys.  If the user has "Create" permission, limit the list
  159.                     'to surveys the s/he owns.
  160.                     strSQL = "SELECT survey_id, title, created_date " & _
  161.                                 "FROM sur_survey "
  162.                     'If the user has "Create" permission (as opposed to "Admin" permission), limit the list to only surveys that the
  163.                     'user is an owner of.
  164.                     If CLng(lngUserSecurityLevel) = SUR_SECURITY_LEVEL_CREATE Then
  165.                         strSQL = strSQL & " WHERE owners LIKE '%" & GetUsername() & "%'"
  166.                     End If                    
  167.  
  168.                     strSQL = strSQL & " ORDER BY created_date DESC"
  169.                     rsSurveys.Open ConvertSQL(strSQL), SURVEY_APP_CONNECTION, adOpenForwardOnly, adLockReadOnly, adCmdText
  170.  
  171.                     'If there are not surveys, display an option indicating that there are no available surveys.  Otherwise, 
  172.                     'display the list of surveys                    
  173.                     If rsSurveys.EOF Then
  174. %>
  175.                         <option value="<%=SUR_COMBO_NO_AVAILABLE_SURVEYS%>"><%=SUR_COMBO_NO_AVAILABLE_SURVEYS%></option>
  176. <%                    
  177.                     Else
  178. %>
  179.                         <option value="<%=SUR_COMBO_PLEASE_SELECT%>"><%=SUR_COMBO_PLEASE_SELECT%></option>
  180. <%                    
  181.                         rsSurveys.MoveFirst
  182.                         Do While Not rsSurveys.EOF
  183. %>
  184.                             <option value="<%=rsSurveys("survey_id")%>"><%=rsSurveys("title")%> (<%=CustomDateFormatDisplay(DateValue(rsSurveys("created_date")))%>)</option>
  185. <%                            
  186.                             rsSurveys.MoveNext
  187.                         Loop
  188.                     End If
  189.                             
  190.                     'Clean up 
  191.                     rsSurveys.Close
  192.                     Set rsSurveys = Nothing
  193. %>
  194.                 </select>
  195.             </td>
  196.         </tr>
  197.         <tr>
  198.             <td valign="top" align="right" colspan="4">
  199.                 <br>
  200.                 <a href="SurveyList.asp"><img style="cursor:hand" border="0" alt="Cancel" src="Resources/Buttons/Cancel.gif" name="btnCancel"></a>
  201.                 <input type="image" border="0" alt="Save" src="Resources/Buttons/Save.gif" name="btnSave">
  202.                 <br>
  203.             </td>
  204.         </tr>
  205.     </form>
  206. </table>
  207.  
  208. <!--#Include File="Include/FrameworkBottom_inc.asp"-->
  209.  
  210. </body>
  211. </html>
  212.  
  213. <%        
  214.     'Ensure that the web server returns the page
  215.     Response.Flush
  216. %>
  217.