Transcript
1DEMOS ONLINE QUIZ
DEMOS ONLINE QUIZ
Project ReportSubmitted in partial fulfillment of the requirements for the award of degree of
Bachelor of Technology
In
Computer Science and Engineering
Of
MAHATMA GANDHI UNIVERSITY
Submitted by
Anand M.N
Tinku Soman Jacob
Tom Joseph
Department of Computer Science and Engineering
Mar Athanasius College of Engineering Kothamangalam
MAR ATHANASIUS COLLEGE OF ENGINEERING
KOTHAMANGALAM
2DEMOS ONLINE QUIZ
DEMOS Online Quiz
Bonafide record of project done by
Anand M.N
Tinku Soman Jacob
Tom Joseph
Dissertation submitted in partial fulfillment of the requirements for the degree of
BACHELOR OF TECHNOLOGY
Branch: COMPUTER SCIENCE
Of MG University
JUNE 2008
...……………………… …………..………………………………….
Mr. Eldho P Elias Mrs. Surekha Mariam Varghese
Faculty guide Head of the Department
Certified that the candidate was examined in the viva-voce examination held on
…………………….. …………………………..
(Internal Examiner) (External Examiner)
3DEMOS ONLINE QUIZ
ACKNOWLEDGEMENT
First and foremost, we sincerely thank the ‘Almighty’ for his grace for the successful and timely completion of the project.
We express my sincere gratitude and thanks to Dr. George Isaac, our Principal and Mrs.Surekha M Varghese, the Head of the Department, Computer Science and Engineering for their guidance, constant encouragement and valuable and countless suggestions.
I owe special thanks to the staff-in-charge Mr. Eldho P. Elias for his corrections, suggestions and sincere efforts to co-ordinate the project.
I express my sincere thanks to all staff members in the department of Computer Science and Engineering who have taken sincere efforts in helping me develop this project.
Last , but not the least I would like to acknowledge the heartfelt efforts, comments, criticisms , co-operation and tremendous support given to me by my dear friends during the development and also during the presentation without whose support this work would have been all the more difficult to accomplish.
4DEMOS ONLINE QUIZ
ABSTRACT
INTRODUCTION
DEMOS ONLINE QUIZ is Windows based web application for facilitating quizzes on any subject based on the data provided to the application. This will be a data driven application whose behavior is mostly controlled by the data provided to this application which makes the application very flexible and powerful.The features are:
1. The application will list, the available subjects of quizzes to the end user where the user can select and execute the Quiz.
2. The selected Quiz will have its own characteristics such as total number of questions, marks for each correct answer.
3. A new quiz can be added to the system by proving the Quiz data.
Types Of Users
Administrator: Person who is granted access to database. The functions of administrator are:
Add or edit Subjects Add or edit Questions Check the status of the on-going quiz Adds new participants and keep their details Controls registration of participants Add new News about the site Keeps the Login History
Participants : These are the users who participate in the quiz competition .Each user has a unique user name and password with which they can log on to the system. User selects the category of quiz to participate in.
5DEMOS ONLINE QUIZ
Modules
DEMOS is mainly divided into four modules, namely
User Management Module Question management module Quiz Execution Module Mark calculation module
User Management Module The functions of this module are:
o Add new users to the user table.
o Authenticating users in the system.
We use user table for user authentication purpose and for storing user data.
Question Management ModuleThe functions of this module are:
o To add new subjects
o To delete the subject
o Add questions to each category of subject.
o Update questions
Here we use a single table for each subject. Each subject has 10 questions and each question has 4 choices.
Quiz Execution ModuleThe functions of this module are:o Quiz Selection
o Listing a single question and its choices at a timeo Verifying selected answero Displaying the marko Navigating to the next question
Mark calculation module The functions of this module are:o Calculation of marks for each of the participants.
o Toppers of each Subject are found
The marks are stored in Marks detail table.The Toppers are stored in Subject Table
6DEMOS ONLINE QUIZ
7DEMOS ONLINE QUIZ
CONTENTS
1. Introduction.
2. SRS.
3. System Study.
4. System Requirements.
5. Project Implementation.
6. System Design.
7. Source Code.
8. Screenshots.
9. List of Figures.
10. Conclusion.
11. Bibliography.
8DEMOS ONLINE QUIZ
1. INTRODUCTION
9DEMOS ONLINE QUIZ
2. SOFTWARE REQUIREMENT SPECIFICATION
Real RequirementThis document details the requirements of Interactive Quiz application.
1) Quiz Execution:
Quiz selection and Execution.
This feature enables the user to select a quiz from the available list and execute it . After the user selects the subject, questions with the four answer choices will be listed one question at a time. Question need to be evaluated at each attempt. If the choice is correct, the mark is incremented, otherwise correct answer is displayed and a next button is provided to navigate through questions. At one attempt a user is provided to attempt only 10 questions. After the 10 t h one, questions need to be evaluated and total mark has to be displayed. The button to return to the home page is then displayed.
2) Adding Quiz to the system:
The Administrator has the provision to add new subjects and questions
3) User Login
New users can create an account by providing a unique username and password.
Existing users can login directly from the login page
Need for the product
Users can participate in various quizzes as a pass- time activity. It can also improve their knowledge in various subjects.
Users will be ranked according to their marks .The topper in each subject is listed in the subject table.
10DEMOS ONLINE QUIZ
Input Requirements
Administrator Inputs:-
Create the database
Enter the quiz databases.
Enter the administrator accounts. Verify and manage user accounts.
User inputs:-
To participate in the quiz, the user must create an account. Then he must login to his account and choose a topic from the available list. Then he is allowed to answer the questions.
Upon completion of the quiz he can view his status.
Business Logic (to be completed)
1. Top performers are listed in the home page.2. Interesting topics and questions are included.3. User friendly interface and navigation.
Operations Performed
1. Accessing the site.First the user is required to create an account. If unique user name and other details are provided properly, account is successfully created. Then the user can login to his account. User can view his status in his home page.
2. Starting the quiz.User can select the topic from the available list. Once the topic is selected the question index corresponding to the user is retrieved from the database and questions are asked from the index.
11DEMOS ONLINE QUIZ
3. Mark calculation.When the user chooses an answer the correct answer is highlighted and marks for the current quiz are updated accordingly. Upon completing the quiz the quiz status is shown and user status is updated.
12DEMOS ONLINE QUIZ
3. .SYSTEM STUDY
Existing System
http://www.triviapark.com
In the home page, a list of available topics and updated news are present. User is allowed to select the topic. A brief description about the selected topic and a link to start the quiz are given.
User is allowed to answer 10 questions in one instance of the quiz. After answering the given question, the correct answer is highlighted and a brief description will be shown. Navigation to the previous and next questions are possible. Upon completing the quiz the final score is shown. Then we can start a new quiz or choose a different topic.
Proposed SystemWe are planning to create an online quiz named DEMOS ONLINE QUIZ
which is a windows based web application for facilitating quizzes on any subject based on the data provided to the application. This will be a data driven application whose behavior is mostly controlled by the data provided to this application which makes the application very flexible and powerful.The features are:
1) The application will list a number of available categories of quizzes to the end user where the user can select and execute the Quiz.
2) The selected Quiz will have its own characteristics such as total number of questions, marks for each correct answer etc.
3) The users will get random selection of questions from the selected quiz during each attempt.
4) A new quiz can be added to the system by proving the Quiz data.
13DEMOS ONLINE QUIZ
4. SYSTEM REQUIREMENTS
<HARDWARE AND SOFTWARE REQUIRMENTS>
<TO BE COMPLETED>
14DEMOS ONLINE QUIZ
5. PROJECT IMPLEMENTATION
FAMILIARISATION WITH ASP.NET
What is ASP.NET?
ASP.NET is a server side scripting technology that enables scripts (embedded in web pages) to be executed by an Internet server.
ASP+ is the same as ASP.NET.
ASP+ is just an early name used by Microsoft when they developed ASP.NET.
The Microsoft .NET Framework
The .NET Framework is the infrastructure for the Microsoft .NET platform.
The .NET Framework is an environment for building, deploying, and running Web applications and Web Services.
Microsoft's first server technology ASP (Active Server Pages), was a powerful and flexible "programming language". But it was to much code oriented. It was not an application framework and not an enterprise development tool.
The Microsoft .NET Framework was developed to solve this problem.
The .NET Framework consists of 3 main parts:
Programming languages:
* C# (Pronounced C sharp)
* Visual Basic (VB .NET)
* J# (Pronounced J sharp)
Server technologies and client technologies:
15DEMOS ONLINE QUIZ
* ASP .NET (Active Server Pages)
* Windows Forms (Windows desktop solutions)
* Compact Framework (PDA / Mobile solutions)
Development environments:
* Visual Studio .NET (VS .NET)
Visual Web Developer
What is an ASP.NET File?
* An ASP.NET file is just the same as an HTML file
* An ASP.NET file can contain HTML, XML, and scripts
* Scripts in an ASP.NET file are executed on the server
* An ASP.NET file has the file extension ".aspx"
How Does ASP.NET Work?
* When a browser requests an HTML file, the server returns the file
* When a browser requests an ASP.NET file, IIS passes the request to the ASP.NET engine on the server
* The ASP.NET engine reads the file, line by line, and executes the scripts in the file
* Finally, the ASP.NET file is returned to the browser as plain HTML
ASP.NET 2.0 & ASP.NET 3.0
ASP.NET 2.0 improves upon ASP.NET by adding support for several new features.
16DEMOS ONLINE QUIZ
ASP.NET 3.0 is not a new version of ASP.NET. It's just the name for a new ASP.NET 2.0 framework library with support for Windows Presentation Foundation, Windows Communication Foundation, Windows Workflow Foundation; and Windows CardSpace.
New in ASP.NET
* Better language support
* Programmable controls
* Event-driven programming
* XML-based components
* User authentication, with accounts and roles
* Higher scalability
* Increased performance - Compiled code
* Easier configuration and deployment
* Not fully ASP compatible
Language Support
ASP.NET uses the new ADO.NET.
ASP.NET supports full Visual Basic, not VBScript.
ASP.NET supports C# (C sharp) and C++.
ASP.NET supports JScript as before.
ASP.NET Pages
The simplest way to convert an HTML page into an ASP.NET page is to copy the HTML file to a new file with an .aspx extension.
This code displays our example as an ASP.NET page:
17DEMOS ONLINE QUIZ
<html>
<body bgcolor="yellow">
<center>
<h2>Hello W3Schools!</h2>
</center>
</body>
</html>
Fundamentally an ASP.NET page is just the same as an HTML page.
An HTML page has the extension .htm. If a browser requests an HTML page from the server, the server sends the page to the browser without any modifications.
An ASP.NET page has the extension .aspx. If a browser requests an ASP.NET page, the server processes any executable code in the page, before the result is sent back to the browser. Active Server Pages (ASP) has been around for several years. With ASP, executable code can be placed inside HTML pages.
ASP.NET - Server Controls
Server controls are tags that are understood by the server.
There are three kinds of server controls:
* HTML Server Controls - Traditional HTML tags
* Web Server Controls - New ASP.NET tags
Validation Server Controls - For input validation
18DEMOS ONLINE QUIZ
ASP.NET - HTML Server Controls
HTML server controls are HTML tags understood by the server.
HTML elements in ASP.NET files are, by default, treated as text. To make these elements programmable, add a runat="server" attribute to the HTML element. This attribute indicates that the element should be treated as a server control. The id attribute is added to identify the server control. The id reference can be used to manipulate the server control at run time.
Note: All HTML server controls must be within a <form> tag with the runat="server" attribute. The runat="server" attribute indicates that the form should be processed on the server. It also indicates that the enclosed controls can be accessed by server scripts.
ASP.NET - Web Server Controls
Web server controls are special ASP.NET tags understood by the server.
Like HTML server controls, Web server controls are also created on the server and they require a runat="server" attribute to work. However, Web server controls do not necessarily map to any existing HTML elements and they may represent more complex elements.
The syntax for creating a Web server control is:
<asp:control_name id="some_id" runat="server" />
ASP.NET - Validation Server Controls
Validation server controls is used to validate user-input. If the user-input does not pass validation, it will display an error message to the user.
Each validation control performs a specific type of validation (like validating against a specific value or a range of values).By default, page validation is performed when a Button,
19DEMOS ONLINE QUIZ
ImageButton, or LinkButton control is clicked. You can prevent validation when a button control is clicked by setting the CausesValidation property to false.
The syntax for creating a Validation server control is:
<asp:control_name id="some_id" runat="server" />
ASP.NET Web Forms
All server controls must appear within a <form> tag, and the <form> tag must contain the runat="server" attribute. The runat="server" attribute indicates that the form should be processed on the server. It also indicates that the enclosed controls can be accessed by server scripts:
<form runat="server">
...HTML + server controls
</form>
Note: The form is always submitted to the page itself. If you specify an action attribute, it is ignored. If you omit the method attribute, it will be set to method="post" by default. Also, if you do not specify the name and id attributes, they are automatically assigned by ASP.NET.
Note: An .aspx page can only contain ONE <form runat="server"> control!
If you select view source in an .aspx page containing a form with no name, method, action, or id attribute specified, you will see that ASP.NET has added these attributes to the form. It looks something like this:
<form name="_ctl0" method="post" action="page.aspx" id="_ctl0">
...some code
</form>
Submitting a Form
A form is most often submitted by clicking on a button. The Button server control in ASP.NET has the following format:
20DEMOS ONLINE QUIZ
<asp:Button id="id" text="label" OnClick="sub" runat="server" />
The id attribute defines a unique name for the button and the text attribute assigns a label to the button. The onClick event handler specifies a named subroutine to execute.
In the following example we declare a Button control in an .aspx file. A button click runs a subroutine which changes the text on the button:
The Page_Load Event
The Page_Load event is one of many events that ASP.NET understands. The Page_Load event is triggered when a page loads, and ASP.NET will automatically call the subroutine Page_Load, and execute the code inside it:
<script runat="server">
Sub Page_Load
lbl1.Text="The date and time is " & now()
End Sub
</script>
<html>
<body>
<form runat="server">
<h3><asp:label id="lbl1" runat="server" /></h3>
</form>
</body>
</html>
21DEMOS ONLINE QUIZ
The Page.IsPostBack Property
The Page_Load subroutine runs EVERY time the page is loaded. If you want to execute the code in the Page_Load subroutine only the FIRST time the page is loaded, you can use the Page.IsPostBack property. If the Page.IsPostBack property is false, the page is loaded for the first time, if it is true, the page is posted back to the server (i.e. from a button click on a form):
<script runat="server">
Sub Page_Load
if Not Page.IsPostBack then
lbl1.Text="The date and time is " & now()
end if
End Sub
<html>
<body>
<form runat="server">
<h3><asp:label id="lbl1" runat="server" /></h3>
<h3><asp:label id="lbl2" runat="server" /></h3>
<asp:button text="Submit" onclick="submit" runat="server" />
</form>
</body>
</html>
The example above will write the "The date and time is...." message only the first time the page is loaded. When a user clicks on the Submit button, the submit subroutine will write "Hello World!" to the second label, but the date and time in the first label will not change.
22DEMOS ONLINE QUIZ
The TextBox Control
The TextBox control is used to create a text box where the user can input text.
The TextBox control's attributes and properties are listed in our web controls reference page.
The example below demonstrates some of the attributes you may use with the TextBox control:
A basic TextBox:
<asp:TextBox id="tb1" runat="server" />
<br /><br />
A password TextBox:
<asp:TextBox id="tb2" TextMode="password" runat="server" />
<br /><br />
A TextBox with text:
<asp:TextBox id="tb4" Text="Hello World!" runat="server" />
<br /><br />
A multiline TextBox:
<asp:TextBox id="tb3" TextMode="multiline" runat="server" />
<br /><br />
23DEMOS ONLINE QUIZ
The Button Control
The Button control is used to display a push button. The push button may be a submit button or a command button. By default, this control is a submit button.
A submit button does not have a command name and it posts the page back to the server when it is clicked. It is possible to write an event handler to control the actions performed when the submit button is clicked.A command button has a command name and allows you to create multiple Button controls on a page. It is possible to write an event handler to control the actions performed when the command button is clicked.
The example below demonstrates a simple Button control:
<html>
<body>
<form runat="server">
<asp:Button id="b1" Text="Submit" runat="server" />
</form>
</body>
</html>
Data Binding
The following controls are list controls which support data binding:
* asp:RadioButtonList
* asp:CheckBoxList
* asp:DropDownList
* asp:Listbox
The selectable items in each of the above controls are usually defined by one or more asp:ListItem controls, like this:
<html>
<body>
24DEMOS ONLINE QUIZ
<form runat="server">
<asp:RadioButtonList id="countrylist" runat="server">
<asp:ListItem value="N" text="Norway" />
<asp:ListItem value="S" text="Sweden" />
<asp:ListItem value="F" text="France" />
<asp:ListItem value="I" text="Italy" />
</asp:RadioButtonList>
</form></body></html>
However, with data binding we may use a separate source, like a database, an XML file, or a script to fill the list with selectable items.
By using an imported source, the data is separated from the HTML, and any changes to the items are made in the separate data source.
In the next three chapters, we will describe how to bind data from a scripted data source.
Create an ArrayList
The ArrayList object is a collection of items containing a single data value.
Items are added to the ArrayList with the Add() method.The following code creates a new ArrayList object named mycountries and four items are added:
<script runat="server">
Sub Page_Load
if Not Page.IsPostBack then
dim mycountries=New ArrayList
mycountries.Add("Norway")
mycountries.Add("Sweden")
25DEMOS ONLINE QUIZ
mycountries.Add("France")
mycountries.Add("Italy")
end if
end sub
</script>
By default, an ArrayList object contains 16 entries. An ArrayList can be sized to its final size with the TrimToSize() method:
HTML Server Controls
HTML elements in ASP.NET files are, by default, treated as text. To make these elements programmable, add a runat="server" attribute to the HTML element. This attribute indicates that the element should be treated as a server control.
HTML Server Control Description
HtmlAnchor Controls an <a> HTML element
HtmlButton Controls a <button> HTML element
HtmlForm Controls a <form> HTML element
HtmlGeneric Controls other HTML element not specified by
HtmlImage Controls an <image> HTML element
HtmlInputButton Controls <input type="button">,
HtmlInputCheckBox Controls an <input type="checkbox"> HTML
HtmlInputFile Controls an <input type="file"> HTML element
HtmlInputHidden Controls an <input type="hidden"> HTML element
HtmlInputImage Controls an <input type="image"> HTML element
HtmlInputRadioButton Controls an <input type="radio"> HTML element
HtmlInputText Controls <input type="text"> and <inptype="password">
HtmlSelect Controls a <select> HTML element
HtmlTable Controls a <table> HTML element
26DEMOS ONLINE QUIZ
HtmlTableCell Controls <td>and <th> HTML elements
HtmlTableRow Controls a <tr> HTML element
HtmlTextArea Controls a <textarea> HTML element
Web Server Controls
Like HTML server controls, Web server controls are also created on the server and they require a runat="server" attribute to work. However, Web server controls do not necessarily map to any existing HTML elements and they may represent more complex elements.
The syntax for creating a Web server control is:
<asp:control_name id="some_id" runat="server" />
Web Server Control Description
AdRotator Displays a sequence of images
Button Displays a push button
Calendar Displays a calendar
CheckBox Displays a check box
CheckBoxList Creates a multi-selection check box group
DataGrid Displays fields of a data source in a grid
DataList Displays items from a data source by using templates
DropDownList Creates a drop-down list
HyperLink Creates a hyperlink
Image Displays an image
ImageButton Displays a clickable image
Label Displays static content which is programmable
LinkButton Creates a hyperlink button
ListBox Creates a single- or multi-selection drop-down list
27DEMOS ONLINE QUIZ
ListItem Creates an item in a list
Panel Provides a container for other controls
PlaceHolder Reserves space for controls added by code
RadioButton Creates a radio button
RadioButtonList Creates a group of radio buttons
Repeater Displays a repeated list of items bound to the control
Table Creates a table
TableCell Creates a table cell
TableRow Creates a table row
TextBox Creates a text box
Xml Displays an XML file or the results of an XSL
Validation Server Controls
A Validation server control is used to validate the data of an input control. If the data does not pass validation, it will display an error message to the user.
The syntax for creating a Validation server control is:
<asp:control_name id="some_id" runat="server" />
Validation Server Control Description
CompareValidator Compares the value of one input control to the value of another input control or to a
fixed value
CustomValidator Allows you to write a method to handle the validation of the value entered
28DEMOS ONLINE QUIZ
RangeValidator Checks that the user enters a value that falls between two values
RegularExpressionValidator Ensures that the value of an input control matches a specified pattern
RequiredFieldValidator Makes an input control a required field
ValidationSummary Displays a report of all validation errors occurred in a Web page
29DEMOS ONLINE QUIZ
6. SYSTEM DESIGN
Modules
DEMOS is mainly divided into four modules, namely
User Management Module Question management module Quiz Execution Module Mark calculation module
User Management Module The primary function of this module is to add new users to the user table. User management module is mainly concerned with authenticating users in the system.
We use user table for user authentication purpose and for storing user data.
Question Management ModuleThis module has the function to add new subjects and questions to each category of
subject. Here we use a single table for each subject. Each subject has 10 questions and eachquestion has 4 choice.
Quiz Execution Module The major operations in this module areo Quiz selectiono Listing a single question and its choices at a timeo Verifying selected answero Displaying the marko Navigating to the next question
Mark calculation moduleThis module carries out the calculation of marks for each of the participants. The marks are stored in Marks_detail table.The toppers of each Subject are found and are kept in the subject table.
30DEMOS ONLINE QUIZ
7. SOURCE CODE
LOGIN PAGE
protected void cmdSignIn_Click(object sender, EventArgs e) { Stringcomm="select*fromUserDetwhereUserName=@unameandPassword=@pass"; clsGlobal temp1 = new clsGlobal(); temp1.con.Open(); SqlCommand cmd = new SqlCommand(comm, temp1.con ); cmd.Parameters.Add(new SqlParameter("@uname",SqlDbType.NVarChar,20)); cmd.Parameters.Add(new SqlParameter("@pass", SqlDbType.NVarChar,20)); cmd.Parameters["@uname"].Value = txtUserNm.Text; cmd.Parameters["@pass"].Value = txtPass.Text; SqlDataReader rdr; rdr = cmd.ExecuteReader(); if (rdr.HasRows == false) { Label1.Text= "User name or password Incorrect"; } else { Response.Write("u exist"); if (txtUserNm.Text == "admin") { Response.Redirect("~/Admin_Files/AdminDefault.aspx"); } Session.Add("UserNm", txtUserNm.Text.ToString());
FormsAuthentication.RedirectFromLoginPage(txtUserNm.Text, false); Session["QuizStatus"] = "false"; Session["Qindex"] = "0"; Session["Qmarks"] = "0"; } temp1.con.Close(); }
31DEMOS ONLINE QUIZ
SIGNUP PAGE
public partial class SignUp : System.Web.UI.Page{ clsGlobal temp = new clsGlobal(); protected void Page_Load(object sender, EventArgs e) { FormView1.ChangeMode(FormViewMode.Insert); }
protected void FormView1_ItemInserted(object sender, FormViewInsertedEventArgs e) {
Response.Redirect("Login.aspx"); }
protected void FormView1_ModeChanged(object sender, EventArgs e) { if (FormView1.CurrentMode == FormViewMode.ReadOnly) { Response.Redirect("Default.aspx"); } } protected void InsertCancelButton_Click(object sender, EventArgs e) { Response.Redirect("Login.aspx"); } protected void FormView1_ItemInserting(object sender, FormViewInsertEventArgs e) { TextBox txt = (TextBox)this.FormView1.Row.FindControl("UserNameTextBox");
temp.con.Open(); SqlCommand com = new SqlCommand("select * from UserDet where UserName='" + txt.Text + "'", temp.con); SqlDataReader rdr; rdr = com.ExecuteReader(); Response.Write("emgp=" + rdr.FieldCount); if (rdr.HasRows == true)
32DEMOS ONLINE QUIZ
{ Label lb1 = (Label)this.FormView1.Row.FindControl("Label1"); lb1.Text = "User name alredy exists"; e.Cancel = true; } temp.con.Close(); }
QUIZ EXECUTION PAGE
public partial class quizexecute : System.Web.UI.Page{ static clsGlobal temp = new clsGlobal(); string cans = null; static int j = 0; protected void Page_Load(object sender, EventArgs e) { if (Session["QuizStatus"] == "false") { temp.InitiateQuiz(Session["CurrSubject"].ToString()); Session["QuizStatus"] = "true"; } if (Session["QuizStatus"] == "true") { Lblmrk.Text = Session["Qmarks"].ToString(); ShowQuestion(); } } protected void Button2_Click(object sender, EventArgs e) { Lblstatus.Visible = false; if (Button2.Text != "NEXT") { Button2.Text = "NEXT"; Response.Redirect("Default.aspx"); } else {
33DEMOS ONLINE QUIZ
Button1.Enabled = true; Session["Qindex"] = Convert.ToString(Convert.ToInt32(Session["Qindex"]) + 1);
ShowQuestion();
} } protected void Button1_Click(object sender, EventArgs e) {
if (Convert.ToInt32(Session["Qindex"]) > 9) { QuizComplete(); }
Lblstatus.Visible = true; Button1.Enabled = false; if (RadioButtonList1.SelectedValue.ToString() == cans) { Session["Qmarks"] = Convert.ToString(Convert.ToInt32(Session["Qmarks"]) + 1); Lblmrk.Text = Session["Qmarks"].ToString(); Lblstatus.Text = "CORRECT ANSWER";
} else { Lblstatus.Text = "WRONG ANSWER,CORRECT ANSWER IS : " + cans;
}
Button2.Enabled = true;
}
private void ShowQuestion() { if (Convert.ToInt32(Session["Qindex"]) > 9) { QuizComplete(); } else
34DEMOS ONLINE QUIZ
{ Button2.Enabled = false;
DataRow dr; dr = temp.ds.Tables[0].Rows[Convert.ToInt32(Session["Qindex"])];
Lblqno.Text = Convert.ToString(Convert.ToUInt32(Session["Qindex"]) + 1); LblQn.Text = dr[2].ToString(); RadioButtonList1.Items[0].Text = dr[3].ToString(); RadioButtonList1.Items[1].Text = dr[4].ToString(); RadioButtonList1.Items[2].Text = dr[5].ToString(); RadioButtonList1.Items[3].Text = dr[6].ToString(); cans = dr[7].ToString();
}
} private void QuizComplete() { int maxmarks; temp.con.Open();
SqlCommand com1 = new SqlCommand("select TopMarks from SubjectDet where SubName='" + Session["CurrSubject"].ToString() + "'", temp.con); SqlDataReader rdr; rdr = com1.ExecuteReader(); rdr.Read(); if (Convert.ToInt32(rdr[0])==0) { maxmarks = 0; }
else { maxmarks = Convert.ToInt32(rdr[0]); }
rdr.Close(); if (maxmarks < Convert.ToInt32(Session["Qmarks"])) { SqlCommand com3 = new SqlCommand("update SubjectDet set TopMarks='" + Session["Qmarks"] + "',UserName='" + Session["UserNm"].ToString() + "' where SubName='" + Session["CurrSubject"].ToString() + "'", temp.con);
35DEMOS ONLINE QUIZ
com3.ExecuteNonQuery(); } Response.Write("now marks is "+Convert.ToInt32(Session["Qmarks"])); SqlCommand com4 = new SqlCommand("insert into MarksDet values('" + Session["UserNm"].ToString() + "','" + Session["CurrSubject"].ToString() + "','"+Convert.ToInt32(Session["Qmarks"])+"','"+System.DateTime.Now+"')", temp.con); com4.ExecuteNonQuery(); Button1.Enabled = false; Button2.Enabled = true; Button2.Text = "Go to Home Page"; lblComplete.Visible = true;
Session["Qindex"] = "0"; Session["Qmarks"] = "0"; Session["QuizStatus"]="false"; temp.con.Close(); }
}
CLASS GLOBAL
public class clsGlobal{
public SqlConnection con = new SqlConnection(@"Data Source=.\SQLEXPRESS;AttachDbFilename=C:\Documents and Settings\tomtat\Desktop\Mini Project\App_Data\Deemos.mdf;Integrated Security=True;User Instance=True"); public DataSet ds = new DataSet();
public string InitiateQuiz(string CurSubject) { ds.Clear(); con.Open(); SqlDataAdapter ad = new SqlDataAdapter("select TOP 10 * from QuestDet where SubName='" + CurSubject + "' order by NEWID()", con); ad.Fill(ds); con.Close(); return (ds.Tables.Count.ToString());
36DEMOS ONLINE QUIZ
}
}
INSERT SUBJECT PAGE
protected void Button1_Click(object sender, EventArgs e) { Label Lbl1 = (Label)this.FormView1.Row.FindControl("SubNameLabel"); Response.Write(Lbl1.Text); clsGlobal temp1 = new clsGlobal(); temp1.con.Open(); SqlCommand comm = new SqlCommand("delete from QuestDet where SubName=@SubName", temp1.con); comm.Parameters.Add(new SqlParameter("SubName", SqlDbType.NVarChar, 20)); comm.Parameters["SubName"].Value = Lbl1.Text; comm.ExecuteNonQuery(); SqlCommand comm1 = new SqlCommand("delete from SubjectDet where SubName=@SubName" , temp1.con); comm1.Parameters.Add(new SqlParameter("SubName", SqlDbType.NVarChar, 20)); comm1.Parameters["SubName"].Value = Lbl1.Text; comm1.ExecuteNonQuery(); temp1.con.Close(); Label1.Visible = false; Button1.Visible = false; FormView1.DataBind(); GridView1.DataBind(); } protected void Button2_Click(object sender, EventArgs e) { Label1.Visible = true; Button1.Visible = true; Button3.Visible = true; }
protected void FormView1_ItemInserted(object sender, FormViewInsertedEventArgs e) { GridView1.DataBind(); } protected void Button3_Click(object sender, EventArgs e) {
37DEMOS ONLINE QUIZ
Label1.Visible = Button1.Visible =Button3.Visible= false; } protected void Page_Load(object sender, EventArgs e) { Button3.Visible = false; }}
INSERT QUESTION PAGE
private void showQid() { int tempval; clsGlobal temp3 = new clsGlobal(); temp3.con.Open(); SqlDataReader rdr1; SqlCommand comm2 = new SqlCommand("select max(Qid) from QuestDet ", temp3.con); rdr1 = comm2.ExecuteReader(); rdr1.Read(); tempval = Convert.ToInt32(rdr1[0]) + 1; TextBox Txt2 = (TextBox)this.FormView1.Row.FindControl("QidTextBox"); Txt2.Text = tempval.ToString(); Response.Write(tempval.ToString()); showSub(); temp3.con.Close();
} private void showSub() { DropDownList drp = (DropDownList)this.FormView1.Row.FindControl("DropDownList1");
TextBox Txt1 = (TextBox)this.FormView1.Row.FindControl("SubNameTextBox"); Txt1.Text = drp.SelectedValue; } protected void InsertButton_Click(object sender, EventArgs e) { showQid(); showSub(); }}
38DEMOS ONLINE QUIZ
8.SCREEN SHOTS
LOGIN PAGE
39DEMOS ONLINE QUIZ
SIGNUP PAGE
40DEMOS ONLINE QUIZ
HOME PAGE
41DEMOS ONLINE QUIZ
My History Page
42DEMOS ONLINE QUIZ
My Account Page
43DEMOS ONLINE QUIZ
Topper Page
44DEMOS ONLINE QUIZ
Quiz Execution Page
45DEMOS ONLINE QUIZ
Administrator Page
46DEMOS ONLINE QUIZ
Login History Page
47DEMOS ONLINE QUIZ
User Page
48DEMOS ONLINE QUIZ
Subject Page
49DEMOS ONLINE QUIZ
Question Page
50DEMOS ONLINE QUIZ
News Page
51DEMOS ONLINE QUIZ
Administrator Account Page
52DEMOS ONLINE QUIZ
9.CONCLUSION
top related