November Happy Hour will be moved to Thursday December 5th.
November Happy Hour will be moved to Thursday December 5th.
..and to make anonymous ratings the following code was used
IUser user = CommunitySystem.CurrentContext.DefaultSecurity.GetUserByUserName(
PageReference.StartPage.SiteSettings().GetProperty<string>("AnonymousUserName"));
IAuthor theAuthor = AuthorHandler.GetAnonymousAuthor(user, PageReference.StartPage.SiteSettings().GetProperty<string>("AnonymousUser"));
Sounds like you need a GuestAuthor. How to stop users from posting multiple ratings is a different problem, perhaps just use a cookie to store what entities the guest has already rated.
What do you mean by GuestAuthor?
We already have a cookie to prevent users from rating several times. The problem is that when not logged in it is supposed to be possible to rate once per anynymous "computer". However it is only possible to add one rating per user in Relate+ and since anonymous author is a based on a user only the first anonymous user can rate. When rating a second time for the same user in Relate the previous rating is over written. What we want is to be able to vote several times anonymously, once per computer. The once per computer part is already solved by our cookie.
How can I solve this?
There are several implementations of the IAuthor interface, UserAuthor is only one. Another is GuestAuthor, which sounds perfect for your situation. You have declared your "theAuthor" as an IAuthor, so I assume you can use the GuestAuthor instead, like so: IAuthor theAuthor = new GuestAuthor([any string you like here]);
Thanx, that worked like a charm! However the code is ugly.. I would appreciate an empty constructor for better usability since the key probably is the email or the email in conjunction with the name.
string uniqueVisitor = DateTime.Now.Ticks.ToString();
guestAuthor = new GuestAuthor(uniqueVisitor,String.Format("{0}@bar.com",uniqueVisitor));
Hi
I have a question about anonymous ratings. It seems it is not possible to rate more than once per user which is understandable. In order to rate anonymously one has to rate with the user Anynymous which means that this can only be done once. Is there any way around this? I have tried using null instead of author when creating a ratings object but this is not allowed. See the code below.
if (userId != "") CommunitySystem.CurrentContext.DefaultSecurity.GetUser(Convert.ToInt32(userId));
IRating rater = new Rating(answer, Convert.ToDouble(vote), userId == "" ? null : user.GetAuthor());
RatingHandler.Rate(rater);
ExpertHandler.UpdateAnswer(answer);
We are running EPiServer Community 3.2.5 with episerver CMS 5.2