1

Title says whole question...

How is possible that survey knows wheather user already responded without author info?

2
  • What do you mean under "without author info"? Jan 30, 2012 at 12:40
  • It means that in columns Author and Editor are three stars ("***"). And there is no other value in the other hidden and system columns that could hold this info...
    – jumbo
    Jan 30, 2012 at 14:16

1 Answer 1

4

The data is still stored in those author and editor columns, it's just that when it presents it through the API, it changes them to stars. If you are wanting to view it through the UI, in the list settings you can always change the setting to show user names in the survey results to see the users real quick and then switch it back.

Through code here's how I determined if someone could respond to a survey a long time ago (SP 2003/2007 days).

private bool CurrentUserCanVote(SPWeb web, SPList list)
{
    string strPost = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
        //"<ows:HttpVDir/>/_vti_bin/owssvr.dll?Cmd=DisplayPost&PostBody=<ows:Batch>" + 
        "<Method>" +
        "<SetList Scope=\"Request\" name=\"u_" + list.Title + "\"/>" +
        //"<SetVar name=\"Cmd\">DisplayPost</SetVar>" + 
        "<SetVar Name=\"Cmd\">Display</SetVar>" +
        "<SetVar Name=\"XMLDATA\">TRUE</SetVar>" + 
        "<OkToVote></OkToVote>" +
        "</Method>" + 
        //"</ows:Batch>" +
        "";

    string result = web.ProcessBatchData(strPost);
    web.AllowUnsafeUpdates = false;
    switch(result)
    {
        //It is OK for the currently authenticated user to vote in the survey
        case "0":
            return true;
        //The user cannot vote because the survey has no questions.
        case "1":
            return true;
        //The user cannot vote because he or she has already voted in this survey.
        case "2":
            return false;
        default:
            return true;
    }
}

I want to say with SP 2010, i just decided to pull back the dataset as the currently logged in user and see if it was empty. My code then changed to this:

private bool CurrentUserCanVote(DataSet ds, SPList myList)
{
    return (myList.AllowMultiResponses || ds.IsEmpty());
}

I'm not sure if the SP 2010 code will work in all cases...

1
  • That's it. I just looked into SQL and the Author and Editor values are still there. It just can't be viewed through API. Thanks
    – jumbo
    Jan 30, 2012 at 14:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.