And his answers will be stored in DataBase.
For being able to store the answers
we need user's 'id' to be stored along with each of his answers.
This code can get us that we need:
string strUserID = Membership.GetUser(User.Identity.Name).ProviderUserKey.ToString();
Getting Relevant Survey Id
Same user cannot do the same survey twice, therefore we need to display him one of the surveys he didnt answer yet.
Here is stored procedure i wrote for this task:
ALTER PROCEDURE dbo.getRelevantSurveys
@user_id nvarchar(256)
AS
SELECT [survey_id]
FROM [surveys]
WHERE [IsPublished]=1 AND
(survey_id NOT IN
(SELECT surveys_1.survey_id
FROM users_answers INNER JOIN questions ON
[users_answers].[question_id] = [questions].[questionID]
INNER JOIN
INNER JOIN
surveys AS surveys_1 ON
surveys_1.[survey_id]= questions.surv_id
surveys_1.[survey_id]= questions.surv_id
WHERE (users_answers.user_id = @user_id)
GROUP BY surveys_1.survey_id))
RETURN
No comments:
Post a Comment