Title says whole question...
How is possible that survey knows wheather user already responded without author info?
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It only takes a minute to sign up.
Sign up to join this communityTitle says whole question...
How is possible that survey knows wheather user already responded without author info?
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...