home *** CD-ROM | disk | FTP | other *** search
/ bombers.k12.ar.us / bombers.k12.ar.us.tar / bombers.k12.ar.us / survey_unconfigured / SurveyAction.asp < prev    next >
Text File  |  2006-10-25  |  7KB  |  181 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 works with ManageSurvey.asp, and processes
  7. '                     the form for managing general information about a survey
  8. '                     by writing to the database.
  9. '
  10. '   COPYRIGHT NOTICE                                
  11. '
  12. '   See attached Software License Agreement
  13. '
  14. '   (c) Copyright 2002 - 2006 by ClassApps.com.  All rights reserved.
  15. '***********************************************************************
  16. %>
  17. <!--#Include File="Include/Config_inc.asp"-->
  18. <!--#Include File="Include/Utility_inc.asp"-->
  19. <!--#Include File="Include/adovbs_inc.asp"-->
  20. <!--#Include File="Include/CurrentUser_inc.asp"-->
  21. <!--#Include File="Include/ID_inc.asp"-->
  22. <!--#Include File="Include/SurveySecurity_inc.asp"-->
  23. <!--#Include File="Include/Constants_inc.asp"-->
  24. <%
  25.     Dim strSQL
  26.     Dim conSurvey
  27.     Dim strOwners
  28.     Dim lngSurveyID
  29.     Dim strPageNumbering
  30.     Dim strSecureSurvey
  31.     Dim strPreviousStatus
  32.     Dim rsSurvey
  33.     Dim strStartDate
  34.     Dim strEndDate
  35.     Dim strBorderColor
  36.     Dim strBackgroundColor
  37.     Dim lngMaximumResponses
  38.     Dim lngMaximumResponsesPerUser
  39.     Dim lngModifySurveyWithinDays
  40.     Dim strCloseButton
  41.     Dim strContinueButton
  42.     Dim strReportsButton
  43.     
  44.     'Initialization
  45.     Set conSurvey = Server.CreateObject("ADODB.Connection")
  46.     Set rsSurvey = Server.CreateObject("ADODB.Recordset")
  47.     conSurvey.Open SURVEY_APP_CONNECTION
  48.     strOwners = Replace(Request.Form("txtOwners"), " ", "")
  49.     
  50.     'Get the previous status of the survey.  If the status was previously New, and 
  51.     'it is now being changed to Live, update the launch_date
  52.     strSQL = "SELECT status FROM sur_survey WHERE survey_id = " & Request.Form("SurveyID")
  53.     rsSurvey.Open ConvertSQL(strSQL), SURVEY_APP_CONNECTION, adOpenForwardOnly, adLockReadOnly, adCmdText
  54.     rsSurvey.MoveFirst
  55.     strPreviousStatus = rsSurvey("status")
  56.     rsSurvey.Close
  57.     Set rsSurvey = Nothing
  58.             
  59.     If Request.Form("chkPageNumbering") = "on" Then
  60.         strPageNumbering = SUR_BOOLEAN_POSITIVE
  61.     Else    
  62.         strPageNumbering = SUR_BOOLEAN_NEGATIVE
  63.     End If
  64.  
  65.     If Request.Form("chkSecureSurvey") = "on" Then
  66.         strSecureSurvey = SUR_BOOLEAN_POSITIVE
  67.     Else    
  68.         strSecureSurvey = SUR_BOOLEAN_NEGATIVE
  69.     End If
  70.  
  71.     If Len(Request.Form("txtStartDate")) > 0 Then
  72.         strStartDate = Request.Form("txtStartDate")
  73.     Else
  74.         strStartDate = "Null"
  75.     End If
  76.  
  77.     If Len(Request.Form("txtEndDate")) > 0 Then
  78.         strEndDate = Request.Form("txtEndDate")
  79.     Else
  80.         strEndDate = "Null"
  81.     End If
  82.  
  83.     If Len(Request.Form("cboBorderColor")) > 0 Then
  84.         strBorderColor = Request.Form("cboBorderColor")
  85.     Else
  86.         strBorderColor = Request.Form("txtBorderColor")
  87.     End If
  88.  
  89.     If Len(Request.Form("cboBackgroundColor")) > 0 Then
  90.         strBackgroundColor = Request.Form("cboBackgroundColor")
  91.     Else
  92.         strBackgroundColor = Request.Form("txtBackgroundColor")
  93.     End If
  94.  
  95.     If Len(Trim(Request.Form("txtMaximumResponses"))) = 0 Then
  96.         lngMaximumResponses = SUR_UNLIMITED_RESPONSES
  97.     Else
  98.         lngMaximumResponses = Request.Form("txtMaximumResponses")
  99.     End If
  100.  
  101.     If Len(Trim(Request.Form("txtMaximumResponsesPerUser"))) = 0 Then
  102.         lngMaximumResponsesPerUser = SUR_UNLIMITED_RESPONSES
  103.     Else
  104.         lngMaximumResponsesPerUser = Request.Form("txtMaximumResponsesPerUser")
  105.     End If
  106.     
  107.     If Len(Trim(Request.Form("txtModifySurveyWithinDays"))) = 0 Then
  108.         lngModifySurveyWithinDays = SUR_UNLIMITED_NUMBER_OF_DAYS
  109.     Else
  110.         lngModifySurveyWithinDays = Request.Form("txtModifySurveyWithinDays")
  111.     End If
  112.  
  113.     'Completion buttons
  114.     If Request.Form("chkCloseButton") = "on" Then
  115.         strCloseButton = SUR_BOOLEAN_POSITIVE
  116.     Else
  117.         strCloseButton = SUR_BOOLEAN_NEGATIVE
  118.     End If
  119.     If Request.Form("chkContinueButton") = "on" Then
  120.         strContinueButton = SUR_BOOLEAN_POSITIVE
  121.     Else
  122.         strContinueButton = SUR_BOOLEAN_NEGATIVE
  123.     End If
  124.     If Request.Form("chkReportsButton") = "on" Then
  125.         strReportsButton = SUR_BOOLEAN_POSITIVE
  126.     Else
  127.         strReportsButton = SUR_BOOLEAN_NEGATIVE
  128.     End If
  129.     
  130.     'Create the SQL statement to update the SUR_SURVEY table
  131.     strSQL = "UPDATE sur_survey SET "
  132.                 'If the previous status was New and the status is now being updated to Live, set the launched date.
  133.                 If strPreviousStatus = SUR_STATUS_DESIGN And Request.Form("cboStatus") = SUR_STATUS_OPEN Then
  134.                     strSQL = strSQL & "launched_date = GETDATE(), "
  135.                 End If
  136.                     
  137.                 'If the previous status was not Closed and it is now being updated to Closed, set the closed date.
  138.                 If strPreviousStatus <> SUR_STATUS_CLOSED And Request.Form("cboStatus") = SUR_STATUS_CLOSED Then
  139.                     strSQL = strSQL & "closed_date = GETDATE(), "
  140.                 End If
  141.                     
  142.                 strSQL = strSQL & "title = " & SQLEncode(Request.Form("txtTitle")) & ", " & _
  143.                 "template_id = " & Request.Form("cboTemplateID") & ", " & _
  144.                 "report_security = " & SQLEncode(Request.Form("cboReportSecurity")) & ", " & _
  145.                 "page_numbering_format = " & SQLEncode(Request.Form("cboPageNumbering")) & ", " & _
  146.                 "question_numbering_format = " & SQLEncode(Request.Form("cboQuestionNumbering")) & ", " & _
  147.                 "survey_language = " & SQLEncode(Request.Form("cboSurveyLanguage")) & ", " & _
  148.                 "status = " & SQLEncode(Request.Form("cboStatus")) & ", " & _
  149.                 "start_date = " & SQLEncodeDate(CustomDateFormatInsert(strStartDate)) & ", " & _
  150.                 "end_date = " & SQLEncodeDate(CustomDateFormatInsert(strEndDate)) & ", " & _
  151.                 "maximum_responses_for_survey = " & lngMaximumResponses & ", " & _
  152.                 "respondent_access_level = " & Request.Form("optRespondentAccessLevel") & ", " & _
  153.                 "survey_complete_message = " & SQLEncode(Request.Form("txtSurveyCompleteMessage")) & ", " & _
  154.                 "owners = " & SQLEncode(strOwners) & ", " & _
  155.                 "completion_action = " & SQLEncode(Request.Form("cboCompletionAction")) & ", " & _
  156.                 "survey_complete_display_close = " & SQLEncode(strCloseButton) & ", " & _
  157.                 "survey_complete_display_continue = " & SQLEncode(strContinueButton) & ", " & _
  158.                 "survey_complete_display_reports = " & SQLEncode(strReportsButton) & ", " & _
  159.                 "survey_complete_redirect_url = " & SQLEncode(Request.Form("txtSurveyCompleteRedirectURL")) & ", " & _
  160.                 "response_email_addresses = " & SQLEncode(Request.Form("txtResponseEmailAddresses")) & ", " & _
  161.                 "admin_email_address = " & SQLEncode(Request.Form("txtAdminEmailAddress")) & ", " & _
  162.                 "highlight_responses_yn= " & SQLEncode(Request.Form("cboHighlightResponses")) & ", " & _
  163.                 "back_button_display = " & SQLEncode(Request.Form("cboBackButtonDisplay")) & ", " & _
  164.                 "cancel_button_display = " & SQLEncode(Request.Form("cboCancelButtonDisplay")) & ", " & _
  165.                 "cancel_button_redirect_url = " & SQLEncode(Request.Form("txtCancelButtonRedirectURL")) & ", " & _
  166.                 "maximum_responses_per_user = " & lngMaximumResponsesPerUser & ", " & _
  167.                 "modify_survey_within_days = " & lngModifySurveyWithinDays & _
  168.                 " WHERE survey_id = " & Request.Form("SurveyID")
  169.     conSurvey.Execute ConvertSQL(strSQL), , adCmdText
  170.  
  171.     'Clean up
  172.     conSurvey.Close
  173.     Set conSurvey = Nothing
  174.  
  175.     'Redirect to the main list of surveys for the current user
  176.     If Request.Form("Nav") = "Survey" Then
  177.         Response.Redirect "Survey.asp?SurveyID=" & Request.Form("SurveyID")
  178.     Else
  179.         Response.Redirect "SurveyList.asp"
  180.     End If
  181. %>