Usually we use the follow SPQuery to make sure whether a user  has given a answer to our surveys:

Here we suppose you run these code in the administrator's role:

 

;
 SPSecurity.RunWithElevatedPrivileges(delegate()
    {

     
using(SPSite site =new SPSite(siteUrl))
     {

          
using (SPWeb web=site.RootWeb)
          { 
             SPUser imitationUser 
= web.EnsureUser(userForCheck);
             
using(SPSite siteWithUser = new SPSite(siteUrl, user.UserToken))
             {
                 
using ( SPWeb webWithUser = siteWithUser.RootWeb)
                 {
                    SPQuery q 
= new SPQuery();
                    q.Query
=@"<Where>
                                  <Eq>
                               <FieldRef Name=\
"Author\"/>
                               <Value Type=\"User\">"+SPUser.Name+@"</Value>"
                                  </Eq>
                              
</Where>"
                    SPList list=webWithUser.Lists["your survey's name"];
                    SPListItemCollection items
=list.GetItems(query);       
  
                    
if(items.Count>0)
                    {
                          result
=true;
                          isRespondComplete
=items[0]["Completed"].ToString()=="1";
                    }
                 }
             }  
          }
     }
     });

 

相关文章:

  • 2021-07-15
  • 2021-06-08
  • 2022-02-16
  • 2021-07-18
  • 2022-01-07
  • 2022-12-23
  • 2021-12-04
猜你喜欢
  • 2022-02-11
  • 2021-09-25
  • 2021-10-02
  • 2022-01-18
  • 2021-10-17
  • 2021-07-06
  • 2022-12-23
相关资源
相似解决方案