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 >
Wrap
Text File
|
2006-10-25
|
5KB
|
99 lines
<!--#Include File="Include/Top_inc.asp"-->
<%
'***********************************************************************
' Application: SelectSurveyASP Advanced v8.1.11
' Author: Aaron Baril for ClassApps.com
' Page Description: This page deletes a survey, and then redirects the
' user back to the user's survey list.
'
' COPYRIGHT NOTICE
'
' See attached Software License Agreement
'
' (c) Copyright 2002 - 2006 by ClassApps.com. All rights reserved.
'***********************************************************************
%>
<!--#Include File="Include/Config_inc.asp"-->
<!--#Include File="Include/Utility_inc.asp"-->
<!--#Include File="Include/adovbs_inc.asp"-->
<!--#Include File="Include/ID_inc.asp"-->
<!--#Include File="Include/CurrentUser_inc.asp"-->
<!--#Include File="Include/SurveySecurity_inc.asp"-->
<!--#Include File="Include/Constants_inc.asp"-->
<%
'In order to delete the survey, the user must be the survey owner or an admin.
If IsUserOwnerOrAdmin(Request.QueryString("SurveyID")) = False Then
Response.Redirect "AccessDenied.asp?SurveyID=" & Request.QueryString("SurveyID") & "&Reason=" & SUR_ACCESS_DENIED_NOT_OWNER
End If
Dim strSQL
Dim conDelete
Dim lngOrderNumber
Dim lngSurveyID
'Initialization
Set conDelete = Server.CreateObject("ADODB.Connection")
conDelete.Open SURVEY_APP_CONNECTION
lngSurveyID = Request.QueryString("SurveyID")
'Delete all the answers from the answer table (SUR_RESPONSE_ANSWER)
strSQL = "DELETE FROM sur_response_answer where response_id IN (" & _
ConvertSQLInClause("SELECT response_id FROM sur_response WHERE survey_id = " & lngSurveyID, "response_id") & _
")"
conDelete.Execute ConvertSQL(strSQL), , adCmdText
'Delete any hidden field responses from the hidden field table (SUR_RESPONSE_HIDDEN_FIELD)
strSQL = "DELETE FROM sur_response_hidden_field WHERE response_id IN (" & _
ConvertSQLInClause("SELECT response_id FROM sur_response WHERE survey_id = " & lngSurveyID, "response_id") & _
")"
conDelete.Execute ConvertSQL(strSQL), , adCmdText
'Delete any hidden fields from the hidden field table (SUR_HIDDEN_FIELD)
strSQL = "DELETE FROM sur_hidden_field WHERE survey_id = " & lngSurveyID
conDelete.Execute ConvertSQL(strSQL), , adCmdText
'Delete all the response entries for this survey from the response table (SUR_RESPONSE)
strSQL = "DELETE FROM sur_response WHERE survey_id = " & lngSurveyID
conDelete.Execute ConvertSQL(strSQL), , adCmdText
'Delete all the answers for this survey from the item answer table (SUR_ITEM_ANSWER)
strSQL = "DELETE FROM sur_item_answer WHERE item_id IN (" & _
ConvertSQLInClause("SELECT item_id FROM sur_survey_to_item_mapping WHERE survey_id = " & lngSurveyID, "item_id") & _
")"
conDelete.Execute ConvertSQL(strSQL), , adCmdText
'Delete all of the row names for the item from the subitem table (SUR_SUBITEM)
strSQL = "DELETE FROM sur_subitem WHERE item_id IN (" & _
ConvertSQLInClause("SELECT item_id FROM sur_survey_to_item_mapping WHERE survey_id = " & lngSurveyID, "item_id") & _
")"
conDelete.Execute ConvertSQL(strSQL), , adCmdText
'Delete all the items for this survey from the item table (SUR_ITEM)
strSQL = "DELETE FROM sur_item WHERE item_id IN (" & _
ConvertSQLInClause("SELECT item_id FROM sur_survey_to_item_mapping WHERE survey_id = " & lngSurveyID, "item_id") & _
")"
conDelete.Execute ConvertSQL(strSQL), , adCmdText
'Delete all the items for this survey from the page table (SUR_PAGE)
strSQL = "DELETE FROM sur_page WHERE survey_id = " & lngSurveyID
conDelete.Execute ConvertSQL(strSQL), , adCmdText
'Delete all the entries for this survey from the mapping table (SUR_SURVEY_TO_ITEM_MAPPING)
strSQL = "DELETE FROM sur_survey_to_item_mapping WHERE survey_id = " & lngSurveyID
conDelete.Execute ConvertSQL(strSQL), , adCmdText
'Delete all page conditions associated with this survey from the page condition table (SUR_PAGE_CONDITION)
strSQL = "DELETE FROM sur_page_condition WHERE survey_id = " & lngSurveyID
conDelete.Execute ConvertSQL(strSQL), , adCmdText
'Delete the entry for this survey from the survey table (SUR_SURVEY)
strSQL = "DELETE FROM sur_survey WHERE survey_id = " & lngSurveyID
conDelete.Execute ConvertSQL(strSQL), , adCmdText
'Clean up
conDelete.Close
Set conDelete = Nothing
'Redirect to the main list of surveys for the current user
Response.Redirect "SurveyList.asp?SurveyID=" & lngSurveyID
%>