home | products | customer | support | forums | contact
Sign in | Join |
in
Page 1 of 1 (11 items)
Sort Posts: Previous Next
  • 04-22-2010 12:16

    Create a new Voter

    Hi, I need to save the data from a "custom form", generated by an xml. example: Simon White so I wrote the following code: Surveys FSForm surveyForm = new (). GetFormForExport (surveyID, false, false); DataTable dt = surveyForm.Answer; foreach (XmlNode xField in xDoc.SelectNodes (/ FORM / FIELDS / FIELD ")) ( DataRow [] dr = dt.Select (AnswerText = '"xField.Attributes [" NAME "]. "'"); Value if (dr.Length> 0) ( ansID string = dr [0] ["RefAnswerId"]. ToString (); VoterAnswersData.VotersAnswersRow respondentAnswer answerRespondent.VotersAnswers.NewVotersAnswersRow = (); respondentAnswer.AnswerId = int.Parse (ansID); respondentAnswer.VoterId = ?????? respondentAnswer.SectionNumber = ???????; respondentAnswer.AnswerText = xField.FirstChild.InnerText; answerRespondent.VotersAnswers.AddVotersAnswersRow (respondentAnswer); ) ) The problem is that I do not know how to create a new voter and so save the data entered in form. I hope in your help Thanks a lot Simone
  • 04-23-2010 4:00 In reply to

    • Tom
    • Top 10 Contributor
    • Joined on 05-19-2007
    • Switzerland
    • Data Illusion

    Re: Create a new Voter

    Hi Simone,

    do you want to add new respondent entries to an existing form in the db is that correct ?

  • 04-23-2010 4:09 In reply to

    Re: Create a new Voter

    Hi Tom, Yes, I want to add new entries of a survey present in the db. I create the FSxml of the survey, I transform the FSxml into a customXML to be played by Flash. So I need to recreate the Submit button to save the data entered. Thanks a lot Simone
  • 04-23-2010 4:41 In reply to

    • Tom
    • Top 10 Contributor
    • Joined on 05-19-2007
    • Switzerland
    • Data Illusion

    Re: Create a new Voter

    Hi,

    you can't go through xml since there isnt a way in FS that would allow you to reimport an xml just to store respondent answers.

    What you will need to do is a web service that will get the values from your flash application and then use following code to create a new entry :

    // Creates a new voter identity
    VoterAnswersData.VotersRow voter = voterAnswers.Voters.NewVotersRow();
    voter.SurveyId = yoursurveyid;
    voter.StartDate = datesurveystarted;
    voter.VoteDate = dateofresponses;
    voter.IPSource = ipofrespondent;
    voter.LanguageCode = languageofrespondentl;
    voter.Validated = true;
    voterAnswers.Voters.AddVotersRow(voter);
     

    and then for each of the answer you want to store for that respondent

    VoterAnswersData.VotersAnswersRow voterAnswer = voterAnswers.VotersAnswers.NewVotersAnswersRow();
    voterAnswer.VoterId = voter.VoterId;
    voterAnswer.QuestionId = -1;
    voterAnswer.SectionNumber = 0;
    voterAnswer.AnswerId = answeridthathasbeenanswered;
    voterAnswer.AnswerText = iftextfromatextboxotherwiseleavenull;
    voterAnswers.VotersAnswers.AddVotersAnswersRow(voterAnswer);


    and finally store everything in the db :
    new Voter().AddVoter(voterAnswers);

    While I am not proficient with flash I believe that you could get the VoterAnswersData xml / xsd definition through the WSDL once you have setup your web service using .net and then setup everything directly from your flash code and have a simple web service method like this on the .net side :

    [WebMethod]
    public void AddVoter(VoterAnswersData voterAnswers)
    {
    new Voter().AddVoter(voterAnswers);
    }

    if you want to do it through REST you will need to download the REST toolkit of Microsoft to generate REST compatible code.

  • 04-26-2010 5:59 In reply to

    Re: Create a new Voter

    Hi Tom, This works perfectly! thanks a lot! I noticed that saving data in this way, the server-side validation does not work. I can recall the validation through the code? Thanks a lot I hope in your help Simone
  • 04-26-2010 9:18 In reply to

    • Tom
    • Top 10 Contributor
    • Joined on 05-19-2007
    • Switzerland
    • Data Illusion

    Re: Create a new Voter

    Hi Simone,

    its not possible to recall validation through the code at the moment since its managed directly by the answer item instances web control when there are displayed, the next version of the framework should support "external" validation but at the moment its unfortunately not possible to reuse the answer items validations based on a current set of answers.

  • 06-07-2010 4:32 In reply to

    • spotvice29
    • Not Ranked
      Male
    • Joined on 05-21-2010
    • Mountain View California

    Just want to ask

     hi can I just join a little bit if you dont mind. . .

     Is this code is tested?? can it mix with PHP script with out error??

     Thanks

    Advice 

  • 06-07-2010 14:06 In reply to

    • Tom
    • Top 10 Contributor
    • Joined on 05-19-2007
    • Switzerland
    • Data Illusion

    Re: Just want to ask

    Hi,

    FeedbackServer only support .net based application integration PHP is not supported.

  • 09-09-2010 8:25 In reply to

    • Marco
    • Not Ranked
    • Joined on 03-08-2010

    Re: Create a new Voter

    Hi Tom,

    i'm actually working in the same project of Simone. With the new version 5.0 published, I would like to re-submit Simone's question regarding the "external" validation in order to know if it is now supported by this new version of Feedback Server.

    Thanks a lot,

    Marco

  • 09-09-2010 16:16 In reply to

    • Tom
    • Top 10 Contributor
    • Joined on 05-19-2007
    • Switzerland
    • Data Illusion

    Re: Create a new Voter

     Hi,

    while there is no direct way to do external validation you can since V5  use a method that will check if a respondent answer set has invalid answers in it or not.

    Its in the SurveyAnswer class and is called 

            public List<InvalidSurveyQuestion> ValidateRespondentAnswers(int surveyId, int pageNumber,
                bool enableAnswerDefaults, VoterAnswersData respondentAnswers, bool applyQuestionSkipLogic,
    string languageCode, string userId, string[] userGroups, bool breakOnFirstError)

    eg:

    it will check the VoterAnswersData that you pass in and see if all conditions (mandatory, regex etc..) have been met and return all invalid questions (if any).  You can set applyQuestionSkipLogic, breakOnFirstError and enableAnswerDefaults to false and leave language code, user id, user groups to null. Set Page to -1 if you want to check all pages in the survey and pass as respondentanswers the respondent answer dataset that you whish to check

  • 10-26-2010 14:49 In reply to

    • d3100
    • Not Ranked
      Male
    • Joined on 10-26-2010
    • New Mexico

    Re: Create a new Voter

    Tom you really are a life saver. Thanks

Page 1 of 1 (11 items)
(c) 2008 Data Illusion. All Rights Reserved.