Random Question Paper Generation

Download as pdf or txt
Download as pdf or txt
You are on page 1of 39

RANDOM QUESTION GENERATION

PAPER

The Mini Project Report submitted in partial fulfillment of the requirements for the BACHELOR OF TECHNOLOGY IN COMPUTER SCIENCE ENGINEERING By Ayesha Nishath Madhuri Karukonda Nandini Polavarapu Sneha kankani 09241A0560 09241A0573 09241A0579 09241A05A4

Under the Esteemd Guidance of Ch.MALLIKARJUNA RAO

CERTIFICATE
This is to Certify that it is a bonafide record of the Mini project work entitled Random question paper generation done by Ayesha Nishath(09241A0560),Madhuri Karukonda(09241A0573) Nandini Polavarapu(09241A0579),Sneha Kankani(09241A05A4) students of BTech(CSE) in the Gokaraju Rangaraju Institute of Engineering and Technology during the Year 2012-2013 in the partial fulfillment of the requirements for the award of Degree in the Bachelor of Compute Science Engineering . This Work is not submitted to any other University for the award of any Degree/Diploma.

Ch.Mallikarjuna Rao Professor of CSE GRIET,HYDERABAD

Anuradha HOD GRIET,HYDERABAD

ACKNOWLEDGEMENT We wish to express our deep gratitude to Ch. Mallikarjuna Rao for all the encouragement and constant support throughout our miniproject. This would not have been possible for his valuable suggestions and support. We are grateful to G Anuradha (HOD of CSE),Members of Project Review Committee for their valuable suggestions. We are also grateful to Dr.Jandhyala N Murthy(Principal), Professor P.S.Raju(Director) for giving us all the necessary facilities to carry out our mini project successfully. We would like to thank our friends for their constructive criticism and help during our miniproject.

Ayesha Nishath

09241A0560

Nandini Polavarapu 09241A0579 Madhuri Karukonda 09241A0573 Sneha Kankani 09241A0584

INDEX Table of Contents: 1. Introduction 1.1 Project Overview 2.Software Description 2.1 Working with NetbeansIDE 2.2 Using JDBC 3.Programming Code. 4.Screen Shots 5.Purpose 5.1 Scope 6.Results 6.1 Results 6.2 Conclusion 7.References

PROJECT OVERVIEW
This project performs all tasks related to paper setting, starting from preparing question paper to printing paper. This project is mainly designed to be used by our college administration for generating a Question paper. The question paper can be used for the semester examinations. It selects questions randomly from a question bank available in the database. The database contains the subjects and their respective questions of all semesters, for the various branches of Engineering. The faculty can also edit the question papers, if they have any desired question to be included in the question paper. There are very rare chances for the disclosure of Question paper as it provides good security, due to the unpredictable questions generated.

The Platform used in this project is Net Beans-IDE and Java Database connectivity (JDBC) is used as the interface. The JDBC & ODBC drivers are configured to interact with the NET BEANS-IDE, to facilitate flawless integration of backend and front end of the project. JDBC is used for accessing databases in the Java applications. The databases are entered by creating tables using the MYSQL commands on Oracle server embedded in the Net Beans-IDE.

About Netbeans:
NetBeans refers to both a platform framework for Java desktop applications and an integrated development environment (IDE) for developing with Java, JavaScript, PHP, Python (no longer supported after NetBeans , Groovy, C, C++, Scala , Clojure and others The NetBeans IDE is written in Java and can run on Windows, OS X, Linux, Solaris and other platforms supporting a compatible JVM. A preexisting JVM or a JDK is not required. The NetBeans platform allows applications to be developed from a set of modular software components called modules. Applications based on the NetBeans platform (including the NetBeans IDE) can be extended by third party developers.

NetBeans Platform

The NetBeans Platform is a reusable framework for simplifying the development of Java Swing desktop applications. The NetBeans IDE bundle for Java SE contains what is needed to start developing NetBeans plugins and NetBeans Platform based applications; no additional SDK is required. Applications can install modules dynamically. Any application can include the Update Center module to allow users of the application to

download digitally signed upgrades and new features directly into the running application. Reinstalling an upgrade or a new release does not force users to download the entire application again. The platform offers reusable services common to desktop applications, allowing developers to focus on the logic specific to their application. Among the features of the platform are: User interface management (e.g. menus and toolbars) User settings management Storage management (saving and loading any kind of data) Window management Wizard framework (supports step-by-step dialogs) NetBeans Visual Library Integrated development tools NetBeans IDE is a free, open-source, cross-platform IDE with built-in-support for Java Programming Language.

NetBeans IDE is an open-source integrated development environment. NetBeans IDE supports development of all Java application types (Java SE (including JavaFX), Java ME, web, EJB and mobile applications) out of the box. Among other features are an Ant-based project system, Maven support, refactorings, version control (supporting CVS, Subversion, Mercurial and Clearcase). Modularity: All the functions of the IDE are provided by modules. Each module provides a well defined function, such as support for the Java language, editing, or support for the CVS versioning system, and SVN. NetBeans contains all the modules needed for Java development in a single download, allowing the user to start working immediately.

Using JDBC in General


1. Load the JDBC driver. To load a driver, you specify the classname of the database driver in the Class.forName method. By doing so, you automatically create a driver instance and register it with the JDBC driver manager. 2. Define the connection URL. In JDBC, a connection URL specifies the server host, port, and database name with which to establish a connection. 3. Establish the connection. With the connection URL, username, and password, a network connection to the database can be established. Once the connection is established, database queries can be performed until the connection is closed. 4. Create a Statement object. Creating a Statement object enables you to send queries and commands to the database. 5. Execute a query or update. Given a Statement object, you can send SQL statements to the database by using the execute, executeQuery, executeUpdate, or executeBatch methods. 6. Process the results. When a database query is executed, a ResultSet is returned. The ResultSet represents a set of rows and columns that you can process by calls to next and various getXxx methods. 7. Close the connection. When you are finished performing queries and processing results, you should close the connection, releasing resources to the database.

Once you have a Statement object, you can use it to send SQL queries by using the executeQuery method, which returns an object of type ResultSet. Here is an example. String query = "SELECT col1, col2, col3 FROM sometable"; ResultSet resultSet = statement.executeQuery(query); The following list summarizes commonly used methods in the Statement class. executeQuery. Executes an SQL query and returns the data in a ResultSet. The ResultSet may be empty, but never null. executeUpdate. Used for UPDATE, INSERT, or DELETE commands. Returns the number of rows affected, which could be zero. Also provides support for Data Definition Language (DDL) commands, for example, CREATE TABLE, DROP TABLE, and ALTER TABLE.

Authenticate:
<%@page import="java.io.*,java.sql.*;"%> <% try { String nm=request.getParameter("name"); String pwd=request.getParameter("password"); Class.forName("org.apache.derby.jdbc.ClientDriver"); Connection co=DriverManager.getConnection("jdbc:derby://localhost:1527/login","login","login");

Statement st=co.createStatement(); ResultSet rs=st.executeQuery("select name,password from login where name='"+nm+"' and password='"+pwd+"'"); int c=0; if(rs.next()){ //out.println("<center><br><h1>Login successfull</h1></center></body>"); response.sendRedirect("select.jsp"); } else{ //out.println("<center><br><h1>Login Failed</h1></center></body>"); response.sendRedirect("login.jsp?yes=User name or Password is invalid"); // out.println("Login Failed"); }

out.println("</body>");

} catch(Exception e){out.println(e);} %>

Change: <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>JSP Page</title> </head> <body> <h1>Hello World!</h1> </body> </html> <%@page import="java.io.*,java.sql.*;"%> <% try { String user=request.getParameter("user"); String op=request.getParameter("oldpwd"); String np=request.getParameter("newpwd"); String cp=request.getParameter("conpwd");String pwd; Class.forName("org.apache.derby.jdbc.ClientDriver"); Connection co=DriverManager.getConnection("jdbc:derby://localhost:1527/login","login","login"); PreparedStatement up; Statement st=co.createStatement(); ResultSet rs=st.executeQuery("select password from login where name='"+user+"'"); if(rs.next())

if(op.equals(rs.getString("password"))) { out.println("np="+np+"cp="+cp); if(np.equals(cp)) { up=co.prepareStatement("update name='"+user+"'"); up.executeUpdate(); response.sendRedirect("login.jsp?yes=Password updated sucessfully"); } else { response.sendRedirect("password.jsp?yes=Entered password in invalid"); } } else { response.sendRedirect("password.jsp?yes=Entered old password in invalid"); } login set password='"+np+"' where

} catch(Exception e) { out.println("Exception"+e); }%>

Edit:
<html> <head> <style type="text/css"> <!-input { vertical-align:middle; font-size:15px; font-family: Arial, Geneva, Helvetica, sans-serif; font-weight: bold; } --> </style> </head> </html> <form action="final.jsp" name="form"> <%@page import="java.io.*,java.sql.*;"%> <% try { String q[][]=(String [][])session.getAttribute("q"); session.setAttribute("q",q); //out.println("<h2>LENGTH="+q.length+"n="+reqt.getParameter("n")); int n=Integer.parseInt(request.getParameter("n")); int x=97,count=0,f=-1;

for(int i=0;i<8;i++) { if(q[i][1]==null) count=1; out.println("<h4>"+(i+1)+"."); for(int j=0;j<n&&q[i][j]!=null;j++) { if(count==1); else { out.println("("+(char)(x+j)+")"); } f++; count=0; %>

<input type="text" align="left"><br> <% } } %>

name=<%=f+""%>

size="120"

value="<%=q[i][j]%>"

<center><input type="submit" value="ok" > <input type="hidden" name="set" value=<%=request.getParameter("set")%>> <input type="hidden" name="f" value=<%=f%>>

<input type="hidden" name="n" value=<%=n%>></center></form> <% } catch(Exception e) { out.println("Exception"+e); } %>

Final:
<%@page import="java.io.*,java.sql.*;"%>

<% try { int n=Integer.parseInt(request.getParameter("n")); String q[][]=(String [][])session.getAttribute("q"); session.setAttribute("q",q); int f=-1; for(int i=0;i<8;i++) { for(int j=0;(j<n)&&(q[i][j]!=null);j++) { f++; //out.println("q["+i+"]["+j+"] = "+request.getParameter(f+"")); String question=request.getParameter(f+""); // out.println("<h2>"+question+"<br>"); if(question=="") q[i][j]=null; else q[i][j]=question; } }%> <input type="hidden" name="set" value=<%=request.getParameter("set")%>>

<input type="hidden" name="n" value=<%=n%>> <% pageContext.forward("print.jsp"); } catch(Exception e) { out.println(e); } %>

Edit:
<html> <frameset rows="25%,*" frameborder="no"> <frame src="griet.jsp" name="image"> <frame src="login.jsp" name="log"/> </frameset>

</html>

Login
<%@page import="java.io.*,java.sql.*;"%> <html> <title>Gokaraju rangaraju institue of engineering and technology</title> <body> <font color="brown" size="50"> <center><b>Login</b><br></center> </font> <% String p=request.getParameter("yes"); if(p!=null) {%> <center><font color="red" size="5px"><%out.println("<br>"+p);%></font></center> <% }%> <font color="Black" size="5px"> <center> <form name="forms" action="authenticate.jsp"> <table> <tr><td><b>Name:</b></td><td><input type="text" name="name"></td></tr> <tr><td><b>Password:</b></td><td><input name="password"></td></tr> <br> <tr> <td><a href="forgot.jsp" target=log>forgot password?</a></td> <td><a href="password.jsp" target=log>change password?</a></td> </tr><br> type="password"

</table> <input type="Submit" value="submit" style="height: 25px; width: 100px"> <input type="reset" value="Reset" style="height: 25px; width: 100px"> </form> </center> </font>

</body>

</html>

Password:
<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>JSP Page</title> </head> <body> <% String p=request.getParameter("yes"); if(p!=null) {%> <center> <font color="red" size="5px" blink"><%out.println("<br>"+p);%></font></center> <% }%> <form action="change.jsp"> <center> <table> <tr><td><b>User Name:</b></td><td><input type="text" name="user"></td></tr> <tr><td><b>Old name="oldpwd"></td></tr> <tr><td><b>New name="newpwd"></td></tr> <tr><td><b>Confirm name="conpwd"></td></tr> <br> <tr> </table> password:</b></td><td><input type="password" style="text-decoration:

Password:</b></td><td><input

type="password"

Password:</b></td><td><input

type="password"

<input type="Submit" value="submit" style="height: 25px; width: 100px"> <input type="reset" value="reset" style="height: 25px; width: 100px"> </center> </form>

</body> </html>

Print:
<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>JSP Page</title> </head> <body> <img alt="logo" src="Images/logo2.jpg" align="left" height="80px" width="150px"> <center><h1>Gokaraju </h1></center> Rangaraju Institute of Engineering And Technology

<div align="center"><%String set=request.getParameter("set");%></div><h3><div align=right>Time:3:00hrs<br>MaxMarks:75</div></h3> <center><h2>Set-<%out.print(set);%></h2></center> </body> </html> <%@page import="java.io.*,java.sql.*;"%> <% try { String q[][]=(String [][])session.getAttribute("q"); //out.println("<h2>LENGTH="+q.length+"n="+request.getParameter("n")); int n=Integer.parseInt(request.getParameter("n")); int x=97,count=0,f=0,l; out.println("<h3><u><center>Each queston carries 16 Marks</center></u></h3>"); for(int i=0;i<8;i++) {

l=0;

out.println("<h3>"+(i+1)+"."); for(int k=0;k<n;k++) { if(q[i][k]==null); else l++;//out.println("l="+l); } if(q[i][1]==null||l==1) count=1;//out.println("c="+count); for(int j=0;j<n;j++) { if(q[i][j]==null) f++; else if(q[i][j]!=null&&count==1) out.println(q[i][j]+"<br>"); else { out.println("("+((char)(x+(j-f)))+")."+q[i][j]+"<br>"); out.println("\t\t"); } } count=f=0; }

} catch(Exception e) { out.println("Exception"+e); } %>

Question paper:
<%-Document : question_paper Created on : 1 Aug, 2012, 9:36:38 PM Author --%> : Nandini

<%@page contentType="text/html" pageEncoding="UTF-8"%> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<%@page import="java.io.*,java.sql.*;"%> <html> <head> </head> <body> <img alt="logo" src="Images/logo2.jpg" align="left" height="80px" width="150px"> <center><h1>Gokaraju </h1></center> Rangaraju Institute of Engineering And Technology

<div align="center"><%String set=request.getParameter("set");%></div><h3><div align=right>Time:3:00hrs<br>MaxMarks:75</div></h3> <center><h2>Set-<%out.print(set);%></h2></center> </body> </html> <% String url=request.getParameter("url");

String user=request.getParameter("user"); String pwd=request.getParameter("pwd"); String sub=request.getParameter("sub"); try { int i,x=97; String unit=null; int u[]=new int[20]; char c;int n=0; Connection co=DriverManager.getConnection(url,user,pwd); Statement st=co.createStatement(); ResultSet rs,result; String query="select ques from "+sub+" where unit="; for(i=0;i<8;i++) { unit=request.getParameter((i+1)+""); if(unit!=null) u[i]=Integer.parseInt(unit); //out.println(u[i]); if(u[i]>n) n=u[i]; } String q[][]=new String[8][n]; session.setAttribute("q",q); result=st.executeQuery("Select * from "+sub);

out.println("<h3><u><center>Each queston carries 16 Marks</center></u></h3>"); for(i=0;i<8;i++) { rs=st.executeQuery(query+(i+1)+"ORDER BY RANDOM()"); //out.println("<h4>Unit "+(i+1)); if(u[i]==1&&rs.next()) { //out.println("u[i]==1<br>"); String question=rs.getString("ques"); out.println("<h4>"+(i+1)+"."+question); q[i][0]=question; } else { int j=0; c=(char)x; //out.println("u[i]!=1"); out.println("<h4>"+(i+1)+"."); while(rs.next()&&j<u[i]) { String question=rs.getString("ques"); out.println("("+(char)(x+j)+")."+question+"<br>"); q[i][j]=question; j++; }

} } %> <form action="" > <input type="hidden" name="set" value=<%=request.getParameter("set")%>><br> <input type="hidden" name="n" value=<%=n%>><br> <center><input type="Submit" value="ok" style="height: 25px; width: 100px" onClick="this.form.action='print.jsp';"> <input type="Submit" value="edit" onClick="this.form.action='edit.jsp';"></center> </form> <% } catch(Exception e) { out.println("Exception"+e); } %> style="height: 25px; width: 100px"

Select:
<html> <title> selection </title> <body> <center> <table> <form name="select" action="subject.jsp"> <tr><td>Select the year :</td> <td><select name="y"> <option value="firstyr">1st</option> <option value="twoone">2-1</option> <option value="twotwo">2-2</option> <option value="threeone">3-1</option> <option value="threetwo">3-2</option> <option value="fourone">4-1</option> <option value="fourtwo">4-2</option> </select> </td> </tr> <tr><td><input type="image" src="Images/examination-papers.jpg" style="position:absolute; left:306px; top:127px;

width:200px;height: alt="Submit" name="submit" value="Submit"> </form> </table> </center> </body> </html> Subject: <%@page language="java" import="java.io.*,java.sql.*;"%> <% String url=null,user=null,pwd=null; try { Class.forName("org.apache.derby.jdbc.ClientDriver"); String year=request.getParameter("y"); if(year.equals("firstyr")) { url="jdbc:derby://localhost:1527/firstyr"; user="firstyr"; pwd="firstyr"; } else { url="jdbc:derby://localhost:1527/cse"; user="cse";

200px;"

pwd="cse"; } Connection co=DriverManager.getConnection(url,user,pwd); Statement st=co.createStatement(); ResultSet rs=st.executeQuery("select * from "+year); int i=0; %> <html> <head> <link rel='stylesheet' type="text/css" href="css_sheets/links.css"/> </head> <body> <% while(rs.next()) { String sub=rs.getString("short"); out.println("\n<center>"); out.println("<a href=units.jsp?value="+sub+"&url="+url+"&pwd="+pwd+"&user="+user+">"+rs.getString("su b")+"</a>"); out.println("</center>"); } %> </body> </html> <%

} catch(Exception e) { out.println("EXCEPTION:"+e); } %> Units: <html> <head> <title>units</title> </head> <body> <center> <%out.println("<h1>"+request.getParameter("value")+"</h1><br>");%> <form name="units" action="question_paper.jsp"> <table> <tr><td><b>Unit-I value=""></td></tr> :</b></td><td><input type="text" name="1" size="4"

<tr><td><b>Unit-II:</b></td><td><input value=""></td></tr> <tr><td><b>Unit-III:</b></td><td><input value=""></td></tr> <tr><td><b>Unit-IV:</b></td><td><input value=""></td></tr> <tr><td><b>Unit-V:</b></td><td><input value=""></td></tr>

type="text"

name="2"

size="4"

type="text"

name="3"

size="4"

type="text"

name="4"

size="4"

type="text"

name="5"

size="4"

<tr><td><b>Unit-VI:</b></td><td><input value=""></td></tr> <tr><td><b>Unit-VII:</b></td><td><input value=""></td></tr> <tr><td><b>Unit-VIII:</b></td><td><input value=""></td></tr><br> <tr><td>Set-<select name="set"> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> <option value="4">4</option> </select> </tr> </table>

type="text"

name="6"

size="4"

type="text"

name="7"

size="4"

type="text"

name="8"

size="4"

<input type="hidden" name="url" value=<%=request.getParameter("url")%>> <input type="hidden" name="user" value=<%=request.getParameter("user")%>> <input type="hidden" name="pwd" value=<%=request.getParameter("pwd")%>> <input type="hidden" name="sub" value=<%=request.getParameter("value")%>><br>

<input type="Submit" value="submit" onclick="this.form.target='_blank';return true">

style="height:

25px;

width:

100px"

<input type="reset" value="reset" style="height: 25px; width: 100px"> </form> </center> </body> </html>

You might also like