home *** CD-ROM | disk | FTP | other *** search
/ bombers.k12.ar.us / bombers.k12.ar.us.tar / bombers.k12.ar.us / survey_unconfigured / DeleteSurvey.asp < prev    next >
Text File  |  2006-10-25  |  5KB  |  99 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 deletes a survey, and then redirects the
  7. '                     user back to the user's survey list.
  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/adovbs_inc.asp"-->
  19. <!--#Include File="Include/ID_inc.asp"-->
  20. <!--#Include File="Include/CurrentUser_inc.asp"-->
  21. <!--#Include File="Include/SurveySecurity_inc.asp"-->
  22. <!--#Include File="Include/Constants_inc.asp"-->
  23. <%
  24.     'In order to delete the survey, the user must be the survey owner or an admin.
  25.     If IsUserOwnerOrAdmin(Request.QueryString("SurveyID")) = False Then
  26.         Response.Redirect "AccessDenied.asp?SurveyID=" & Request.QueryString("SurveyID") & "&Reason=" & SUR_ACCESS_DENIED_NOT_OWNER
  27.     End If
  28.  
  29.     Dim strSQL
  30.     Dim conDelete
  31.     Dim lngOrderNumber
  32.     Dim lngSurveyID
  33.  
  34.     'Initialization
  35.     Set conDelete = Server.CreateObject("ADODB.Connection")
  36.     conDelete.Open SURVEY_APP_CONNECTION
  37.     lngSurveyID = Request.QueryString("SurveyID")
  38.  
  39.     'Delete all the answers from the answer table (SUR_RESPONSE_ANSWER)
  40.     strSQL = "DELETE FROM sur_response_answer where response_id IN (" & _
  41.              ConvertSQLInClause("SELECT response_id FROM sur_response WHERE survey_id = " & lngSurveyID, "response_id") & _
  42.              ")"
  43.     conDelete.Execute ConvertSQL(strSQL), , adCmdText
  44.  
  45.     'Delete any hidden field responses from the hidden field table (SUR_RESPONSE_HIDDEN_FIELD)
  46.     strSQL = "DELETE FROM sur_response_hidden_field WHERE response_id IN (" & _
  47.              ConvertSQLInClause("SELECT response_id FROM sur_response WHERE survey_id = " & lngSurveyID, "response_id") & _
  48.              ")"
  49.     conDelete.Execute ConvertSQL(strSQL), , adCmdText
  50.  
  51.     'Delete any hidden fields from the hidden field table (SUR_HIDDEN_FIELD)
  52.     strSQL = "DELETE FROM sur_hidden_field WHERE survey_id = " & lngSurveyID
  53.     conDelete.Execute ConvertSQL(strSQL), , adCmdText
  54.  
  55.     'Delete all the response entries for this survey from the response table (SUR_RESPONSE)
  56.     strSQL = "DELETE FROM sur_response WHERE survey_id = " & lngSurveyID
  57.     conDelete.Execute ConvertSQL(strSQL), , adCmdText
  58.  
  59.     'Delete all the answers for this survey from the item answer table (SUR_ITEM_ANSWER)
  60.     strSQL = "DELETE FROM sur_item_answer WHERE item_id IN (" & _
  61.              ConvertSQLInClause("SELECT item_id FROM sur_survey_to_item_mapping WHERE survey_id = " & lngSurveyID, "item_id") & _
  62.              ")"
  63.     conDelete.Execute ConvertSQL(strSQL), , adCmdText
  64.  
  65.     'Delete all of the row names for the item from the subitem table (SUR_SUBITEM)
  66.     strSQL = "DELETE FROM sur_subitem WHERE item_id IN (" & _
  67.              ConvertSQLInClause("SELECT item_id FROM sur_survey_to_item_mapping WHERE survey_id = " & lngSurveyID, "item_id") & _
  68.              ")"
  69.     conDelete.Execute ConvertSQL(strSQL), , adCmdText
  70.  
  71.     'Delete all the items for this survey from the item table (SUR_ITEM)
  72.     strSQL = "DELETE FROM sur_item WHERE item_id IN (" & _
  73.              ConvertSQLInClause("SELECT item_id FROM sur_survey_to_item_mapping WHERE survey_id = " & lngSurveyID, "item_id") & _
  74.              ")"
  75.     conDelete.Execute ConvertSQL(strSQL), , adCmdText
  76.  
  77.     'Delete all the items for this survey from the page table (SUR_PAGE)
  78.     strSQL = "DELETE FROM sur_page WHERE survey_id = " & lngSurveyID
  79.     conDelete.Execute ConvertSQL(strSQL), , adCmdText
  80.  
  81.     'Delete all the entries for this survey from the mapping table (SUR_SURVEY_TO_ITEM_MAPPING)
  82.     strSQL = "DELETE FROM sur_survey_to_item_mapping WHERE survey_id = " & lngSurveyID
  83.     conDelete.Execute ConvertSQL(strSQL), , adCmdText
  84.  
  85.     'Delete all page conditions associated with this survey from the page condition table (SUR_PAGE_CONDITION)
  86.     strSQL = "DELETE FROM sur_page_condition WHERE survey_id = " & lngSurveyID
  87.     conDelete.Execute ConvertSQL(strSQL), , adCmdText
  88.  
  89.     'Delete the entry for this survey from the survey table (SUR_SURVEY)
  90.     strSQL = "DELETE FROM sur_survey WHERE survey_id = " & lngSurveyID
  91.     conDelete.Execute ConvertSQL(strSQL), , adCmdText
  92.  
  93.     'Clean up
  94.     conDelete.Close
  95.     Set conDelete = Nothing
  96.  
  97.     'Redirect to the main list of surveys for the current user
  98.     Response.Redirect "SurveyList.asp?SurveyID=" & lngSurveyID
  99. %>