Survey Forums

HomeHomeSurvey Project ...Survey Project ...DevelopmentDevelopmentExport based on answersExport based on answers
Previous
 
Next
New Post
9/12/2012 12:01 PM
 

I am trying to modify the ExportData.aspx in order to select the data to extract based on the reply of the voters in certain questions. One idea is to have it through the use of the existing filters. Thing is I want to be able to have various combinations between them. By using the filters, this mean I will have to make a filter for each situation, right?

 For example, these are the options I want to run the export on:

 

Export from :

To :

Gender :
[Drop down list of Genders]

Seed :
[Yes/No Checkbox]

Any feedback/advice on this? How should I proceed? Should I just copy paste the filter code into the export? And how should I proceed from there?

 Thank you in advance

 

EDIT: Also something that might seem irrelevant but I really need to understand:

When I check the vts_tbVoterAnswers table I notice that the AnswerText field of radio button answers is NULL. Where do the replies of this are stored ? In which table?

Again, thank you in advance

 
New Post
9/17/2012 9:59 AM
 
Any reply? At least for the question where are the radio button and checkbox answers are stored in the database?
 
New Post
9/17/2012 8:19 PM
 
Hello,

We dont mean to discourage you with any attempts to adjust the SP tool but unfortunately we have to make choices to support the development of the official releases and new issues/ features first. Any visitor or project member is of course free to answer your questions or assist you thought this forum however the questions are not easy to answer and would take as much time for us to research as it would for yourself probably. We hope you do understand our postition and we do appreciate your reports on you investigations through these forums.

Meanwhile you can check the documents section of at http://survey.codeplex.com and find the database model including relations to help answer you question concerning the vts_tbVoterAnswer table.



 

 

 


 
New Post
9/18/2012 10:36 AM
 

I did manage to understand how the checkbox and radio buttons work.. Yes I understand your position, but you must understand also mine.

A tool which has such potential, yet simple stuff are missing. I understand that they are to be built in time and I respect that. Besides its not like I asked anyone to research for me or code for me, simply an off-the-hand opinion, if not, then its ok I managed to get this far on my own, why not a little further. Its why I dont submit new issues/features anymore as well. I am doing this for myself and If I believe one can gain from it, I will post my idea here. Besides this is how one discovers new features to add, research.

For those interested, apparently the answers which are selected in radio button of checkbox simply just exist with the NULL value in the VoterAnswers table and the corresponding VoterID. If an answer is not selected, then it doesn't exist at all.

 

 

EDIT:

For those interested:

 I managed to get close to finding a solution where a user can filter the data exported into CSV file through a drop down menu.

What I did was this:

 USE [SurveyDB20652]
GO
/****** Object:  StoredProcedure [dbo].[vts_spVoterExportCSVData]    Script Date: 18/9/2012 2:41:47 μμ ******/
SET ANSI_NULLS OFF
GO
SET QUOTED_IDENTIFIER ON
GO
/*
    Survey changes: copyright (c) 2010, Fryslan Webservices TM (http://survey.codeplex.com)    

    NSurvey - The web survey and form engine
    Copyright (c) 2004, 2005 Thomas Zumbrunn. (http://www.nsurvey.org)

    This program is free software; you can redistribute it and/or
    modify it under the terms of the GNU General Public License
    as published by the Free Software Foundation; either version 2
    of the License, or (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.

/// <summary>
/// Return the data needed to export a CSV  file
/// </summary>
*/
ALTER PROCEDURE [dbo].[vts_spVoterExportCSVData]
                @SurveyID int,
                @StartDate datetime,
                @EndDate datetime
AS

SELECT  SUBSTRING(Q.QuestionText,1,20) as QuestionText,Q.QuestionId,
 AnswerID,SelectionModeId,AnswerTypeId,
SUBSTRING(Q.QuestionText,1,20)+'...'+' | '+ AnswerText   as ColumnHeader ,
AnswerText,
Q.DisplayOrder QuestionDisplayOrder,
Q.QuestionId,
Q.Alias QuestionAlias,
Q.QuestionIdText QuestionIdText,
A.DisplayOrder AnswerDisplayOrder,
A.AnswerId ,
A.AnswerAlias,Q.ParentQuestionid,
    case when q.parentQuestionId is null then null
    else (select count(*)+1 from vts_tbquestion q1
             where q1.parentquestionid=q.parentquestionid
             and   q1.questionid<q.questionid
             )
    end as roworder,
    case when q.parentQuestionId is null then null
    else (select QuestionText from vts_tbquestion q1
             where q1.questionid=q.parentquestionid
             )
    end as ParentQuestiontext,
    case when q.parentQuestionId is null then null
    else (select QuestionIdText from vts_tbquestion q1
             where q1.questionid=q.parentquestionid
             )
    end as ParentQuestionIdtext,
    case when q.parentQuestionId is null then null
    else (select ALIAS from vts_tbquestion q1
             where q1.questionid=q.parentquestionid
             )
    end as ParentQuestionAliastext,
A.AnswerIDText AnswerIdText
 FROM vts_tbQuestion Q
INNER JOIN vts_tbAnswer A
    ON A.QuestionID = Q.QuestionID
WHERE
    SurveyID = @SurveyID  
ORDER BY Q.DisplayOrder, Q.QuestionID, A.DisplayOrder

SELECT
    V.VoterID,
    V.VoteDate,
    V.StartDate,
    V.IPSource,
    V.ContextUserName as username,
    (SELECT sum(ScorePoint) FROM vts_tbVoter
        INNER JOIN vts_tbVoterAnswers
            ON vts_tbVoterAnswers.VoterID = vts_tbVoter.VoterID
        INNER JOIN vts_tbAnswer
            ON vts_tbAnswer.AnswerID = vts_tbVoterAnswers.AnswerID
        WHERE vts_tbVoter.VoterID = V.VoterID) AS Score
    FROM vts_tbVoter V
    WHERE
        V.SurveyID = @SurveyID AND
        V.Validated <> 0 AND
        DATEDIFF (d,@startDate,V.VoteDate) >= 0 AND DATEDIFF (d,@endDate,V.VoteDate) <= 0 AND
        V.VoterID IN (SELECT VoterID FROM vts_tbVoterAnswers WHERE AnswerID='32')

    ORDER BY V.VoterID DESC
 
SELECT
    V.VoterID,
    VA.AnswerID,
    SectionNumber,
    VA.AnswerText,
    AnswerTypeId,
    SelectionModeId,
    Q.QuestionId,
    A.AnswerText AnswerAnswerText,
    A.DisplayOrder AnswerDisplayOrder,
A.AnswerAlias,
A.AnswerIDText AnswerIdAlias
FROM vts_tbVoterAnswers VA
INNER JOIN vts_tbVoter V
    ON V.VoterID = VA.VoterID
INNER JOIN vts_tbAnswer A
    ON VA.AnswerId=A.AnswerId
INNER JOIN vts_tbQuestion Q
     ON A.QuestionId=Q.QuestionId
WHERE
    V.SurveyID = @SurveyID AND
    V.Validated <> 0 AND
    DATEDIFF (d,@startDate,V.VoteDate) >= 0 AND DATEDIFF (d,@endDate,V.VoteDate) <= 0 AND
    V.VoterID IN (SELECT VoterID FROM vts_tbVoterAnswers WHERE AnswerID='32')

    
ORDER BY V.VoterID DESC

I simply added the bold red code in and it simply filters entries that have the AnswerID='32', meaning that they have given a specific answer to a specific question. I tested this thoroughly and it works.

 Now what remains is to connect the stored procedure with the respective form field value in the file "ExportData.aspx":

<asp:DropDownList ID="ddlSeed" runat="server">
                                <asp:ListItem Value=""> All </asp:ListItem>
                                <asp:ListItem Value="32"> Yes </asp:ListItem>
                                <asp:ListItem Value="31"> No </asp:ListItem>
                                </asp:DropDownList> 

To do that I imagine I have to add a variable in the stored procedure (for example: @Seed int)  which will be assigned the value of the drop down list.

This is where Im stuck. Im trying to figure out how to do it. So far I've found several ways to do it for MSAccess, but not for SQL directly. If anyone knows Id appreciate an input.

 

Thanks :)

 
New Post
9/18/2012 10:57 PM
 
You're certainly most welcome to share your thoughts and research experiences (much appreciated).

Have you considered creating a fork of your own at the Codeplex site (http://survey.codeplex.com)
Just check: http://survey.codeplex.com/discussions/352296 on how to get started.

That would certainly benefit the project (and other users) greatly and would give you the option to share, test and research your code also!

Hope you will give it a try.





 
Previous
 
Next
HomeHomeSurvey Project ...Survey Project ...DevelopmentDevelopmentExport based on answersExport based on answers