I am developing a web-based training management system that provides the employees with weekly short quizzes. In profile section in the webiste, the employee should be able to see a list of the quizzes that he did not participate in them. I could be able to let the system to show them but not after improving the system, it doesn’t show.
First of all, I have the following database design:
Quiz Table: QuizID, Title, Description, IsSent
UserQuiz Table: ID, QuizID, Score, DateTimeComplete, Username
IsSent is a flag that refers to the quizzes that have been sent or not
I put IsSent in the Quiz table because I want the Admin to be able to insert around 50 quizzes in a day. Then, the system will deal with sending them on a weekly basis. Now, when the user wants to see his profile and see the quizzes that he did not participate in them, he should see the the list of quizzes that have been sent and he did not participate in them.
The problem that I am facing it right now is that the system shows the quizzes that have not been sent as a list of quizzes that the employee did not participate in them and this is wrong. So how I can fix this problem?
My Query:
SELECT Title, Description
FROM dbo.Quiz
WHERE (NOT EXISTS
(SELECT QuizID
FROM dbo.UserQuiz
WHERE (dbo.Quiz.QuizID = QuizID) AND (Username = @Username)))
Add folllowing line in the end of the query
P.S. i’m assuming ur
isSentcolumn is tinyint and 1 = true