This lab involved developing a role-based Online Quiz System using ASP.NET Web Forms and VB.NET, supporting three roles: Teacher, Student, and Administrator each with a distinct interface with session-based authorization. Teachers add questions with multiple choice options, students attempt randomized quizzes, and results are stored and displayed on submission.
| Table | Key Columns | Purpose |
|---|---|---|
| USER_t | User_Id, Username, Password, Role | All users with their assigned role. |
| QUESTION_t | Question_Id, Question_Text, Created_By | Quiz questions entered by teachers. |
| OPTION_t | Option_Id, Question_Id, Option_Text, Is_Correct | Answer options Is_Correct flags the right answer. |
| RESULT_t | Result_Id, Student_Id, Score, Attempt_Date | Student scores per attempt. |
| ANSWER_t | Answer_Id, Result_Id, Question_Id, Selected_Option_Id | Each student's selected option per question. |
Fetch questions + options (randomized):
SELECT Q.Question_Id, Q.Question_Text, O.Option_Id, O.Option_Text FROM QUESTION_t Q JOIN OPTION_t O ON Q.Question_Id = O.Question_Id ORDER BY NEWID();
Insert question & option:
INSERT INTO QUESTION_t (Question_Text, Created_By) VALUES (@QuestionText, @TeacherId); INSERT INTO OPTION_t (Question_Id, Option_Text, Is_Correct) VALUES (@QuestionId, @OptionText, @IsCorrect);
Save result & calculate score:
INSERT INTO RESULT_t (Student_Id, Score, Attempt_Date) VALUES (@StudentId, @Score, GETDATE()); SELECT COUNT(*) AS CorrectAnswers FROM ANSWER_t A JOIN OPTION_t O ON A.Selected_Option_Id = O.Option_Id WHERE A.Result_Id = @ResultId AND O.Is_Correct = 1;
| # | Test Case | Expected Output |
|---|---|---|
| 1 | Valid Teacher login | Redirected to Teacher dashboard |
| 2 | Valid Student login | Redirected to Attempt Quiz page |
| 3 | Invalid credentials | Error message, it stays on Login page |
| 4 | Student accesses Teacher URL directly | will be Redirected to Login page |
| 5 | Teacher adds complete question | Saved to DB, confirmation is shown |
| 6 | Teacher submits empty question | Validation error, no record inserted |
| 7 | No questions in DB | "No questions available. Please try later." |
| 8 | Student submits quiz | Score is calculated, stored, and displayed |
| 9 | Student skips a question | Skipped question is counted as incorrect |
| 10 | Same student attempts twice | Different question/option order is shown each time |
Built with ASP.NET Web Forms (VB.NET) and ADO.NET
(SqlConnection, SqlCommand, SqlDataAdapter).
Session("Role") and Session("User_Id") are set on login and
validated on every protected page's Page_Load. The quiz dynamically generates
one RadioButtonList per question, since dynamic controls don't survive
postbacks, student selections are re-read from Request.Form at submission.