22-10-2016, 11:52 AM
1460472346-ProjectReport1.docx (Size: 956.1 KB / Downloads: 8)
ABSTRACT
Question paper generating system, is robust, test paper generating model that compiles a test paper automatically before testing. It has the ability to create question papers “on the spot” if required .The primary objective is to test each students intellectual level comparing the overall difficulty level of all the students .Simultaneously, it triggers questions from various batches of different aptitude levels in a manner making it rather difficult of generating question paper similar to it.
It is a vigorous and coherent method, principally when a huge question bank for each of the varied aptitude level is present in the question paper. The only limitation for the generation of number of unique tests is due to the size or in other words the number of questions inputed in the question bank and the difficulty level can be set by the administrator.
INTRODUCTION
JAVA AS PROGRAMING LANGUAGE
Java, a computer programming language which is class-based, object-oriented which is designed specifically to have very few dependent implementations as possible. It follows the basic principle WORA “write once, run anywhere”, meaning the code need not be recompiled for other platform once run on one platform.
Java applications can be run on any JVM (Java Virtual Machine) as it is compiled to bytecode (class files) irrespective of the computer architecture.
Java, originally developed in 1991 by James Gosling at Sun Microsystems (which later merged with Oracle Cooperation) and was first released in 1995 as a core component of Sun Microsystems’ Java platform. By 2014, it is now considered as the most popular programming language, specially for client-server web applications.
Java derives its syntax from C and C++ as base languages, but the low level facilities are fewer than either of them.
JAVA AS SOFTWARE PLATFORM
Java from Oracle Cooperation is a set of several computer software products and specification providing a system for initiating application software and employing it in a cross platform computing environment.
With various uses in computing platforms from low end (embedded devices, mobile phones etc) to high end (enterprise servers, supercomputers etc)
Though not highly common, Java Applets are occasionally used in providing evolved and secure usage while browsing the World Wide Web on PC’s.
The basic way to construct a code in Java is through employing Java bytecode.
Java syntax adopts significantly from C, C++ language but the object oriented features are imitated after Smalltalk and Objective –C.
Java excludes low-level features as pointers and has a very simple memory model where every object is put in a heap and all the variables of object types are references.
The integrated automatic garbage collection is performed by JVM for efficient memory management.
METHODOLOGY OF RESEARCH
The project ‘Question Paper Generating System’ depends on the Excel, object oriented programming and networking techniques.. This project using JAVA as the front-end software which is also an Object Oriented Programming and is connected to Microsoft Excel.
SOFTWARE
Operating System : Windows XP and Later Versions.
Font-End Tool : JAVA
Back-End : Microsoft Excel
FRONT END
We have implemented Servlets for all the Patient validation. Patient’s side Servlets is drafted to reside inside HTML document & to take care whether the application works properly. Java is object-based, event-driven and platform independent. These points are very important parts of any Web application to be implemented for Patient’s Validations and no invalid data can submitted. The form will not be submitted until user fills in complete data. It is extremely important to restrict mistakes made by the users else it will create deal of problem in working of the application.
BACK END
We have used Microsoft Excel. It provides effective and efficient solution for major database technologies.
- Management of Large Databases and spaces.
- Numerous simultaneous database users.
- Requirement for highly manageable processing
- Large amount of Availability
- Standards those are acceptable
- Security that is Manageable
- Also is Portable
JXL PACKAGE
Reading Spreadsheets
An Excel spreadsheet stored on the local filesystem or some input stream can be read with the help of JExcelApi. The first step while examining a spreadsheet is creating a Workbook. The following code is an example of how a workbook is developed from a file on a local machine.
import jxl.*;
import java.io.File;
import java.util.Date;
Workbook workbook = Workbook.getWorkbook(new File("myfile.xls"));
After retrieving the workbook, we can utilise this to access individual sheets. These are zero indexed - the first sheet being 0, the second sheet being 1, and so on.
Sheet sheet = workbook.getSheet(0);
We start accessing cells after once developing a sheet. getContents() is used to input a string for a cell’s filling. In the sample code given below, x1 is a text cell, y2 is numerical value and z2 is a date. The contents of these cells may be accessed as follows
Cell x1 = sheet.getCell(0,0);
Cell y2 = sheet.getCell(1,1);
Cell z2 = sheet.getCell(2,1);
String stringx1 = x1.getContents();
String stringy2 = y2.getContents();
String stringz2 = z2.getContents();
The demo programs CSV.java & XML.java uses a simple method getContents() under order to output the spreadsheet contents.
However, in case to need a cell’s contents as a numeric value or a date, that is if it needs to be accessed as a specific kind of datatype, then the Cell must be cast to the correct type and the suitable methods called.
The code slice given below demonstartes how JExcelApi may be utilised to rescue a candid java double and java.util.Date object from the Excel spreadsheet. For wholeness the label is also casted to it's right form, but in rehearsal this makes no change at all. The specimen also exemplifies a cell’s verification is of the projected kind - this can be useful when validating that the spreadsheet’s cells are in the true room.
String stringx1 = null;
double numberb2 = 0;
Date datec2 = null;
Cell x1 = sheet.getCell(0,0);
Cell y2 = sheet.getCell(1,1);
Cell z2 = sheet.getCell(2,1);
if (a1.getType() == CellType.LABEL)
{
LabelCell lc = (LabelCell) x1;
stringa1 = lc.getString();
}
if (y2.getType() == CellType.NUMBER)
{
NumberCell nc = (NumberCell) y2;
numberb2 = nc.getValue();
}
if (z2.getType() == CellType.DATE)
{
DateCell dc = (DateCell) z2;
datez2 = dc.getDate();
}
// Do matter with doubles and dates
When we ended processing for all the cells, we use the method close ( ). This releases the already being used memory when it is reading spreadsheets and is precisely significant when the project is reading a huge number of spreadsheets.
// Finished - workbook is closed and vacate the memory
workbook.close();
Writing Spreadsheets
Fundamentals
This defines how to write a simple spreadsheet data without encrypting information, such as fonts or decimal places.
Similarly for reading a spreadsheet, the first step is to develop a writable workbook using the factory technique on the Workbook class.
import jxl.*;
import jxl.write.*;
import java.io.File;
import java.util.Date;
...
Writable Workbook workbook = Workbook.createWorkbook(new File("output.xls"));
The workbook object is created by the given code. The working directory will store the created file and is known as "output.xls". The API can also be utilized to send the workbook openly to an output stream for example from a web server to the user's browser. If the HTTP header is set correctly, then this will promote to Excel and display the created spreadsheet.
The subsequent stage is to create sheets for the workbook itself. Once again, this is a factory scheme, which gives the name of the sheet and the position it will occupy in the workbook. The code portion below makes a sheet called "First Sheet" at the first position.
WritableSheet sheet = workbook.createSheet("First Sheet", 0);
Now all that which is a leftover is for adding the cells into the worksheet. This is basically a substance of instantiating cell objects and adding them to the working sheet. The subsequent code portion puts a label in cell A3, and the number 3.14159 in cell D5.
Label label = new Label(0, 2, "A label record");
sheet.addCell(label);
Number number = new Number(3, 4, 3.1459);
sheet.addCell(number);
There is merging of points to note here. Firstly, the cell's position in the sheet is defined as part of the constructor facts. Once created, it is not possible to change a cell's position, while the cell's substances may be changed.
The other idea to note is that the cell's position is stated as (column, row). Both are zero indexed integer values - A1 being symbolized by (0,0), B1 by (1,0), A2 by (0,1) and so on.
Once you have ended accumulating sheets and cells to the workbook, you call write() function on the workbook, and then exit the file. This final step creates the output file (output.xls in this case) which may be read using Excel. If you call close () function without calling write () function first, a entirely empty file will be created.
...
// All sheets and cells added. Now write out the workbook
workbook.write();
workbook.close();
Format Information is added
The former section demonstrates the fundamentals of creating an Excel compatible spreadsheet with the help of JExcel API. However, as its presence in Excel will condense the data into a default font, and will show the numbers of 3 decimal places. In order to offer the formatting information to Excel, we need to make use of the overloaded constructor, which inculcates an extra object including the cell's formatting information (both for the font and for the style).
The code portion below demonstrates creating of a label cell of an Arial 10 point font size.
// Create a cell format for Arial 10 point font
WritableFont arial10font = new WritableFont(WritableFont.ARIAL, 10);
WritableCellFormat arial10format = new WritableCellFormat (arial10font);
// Create the label, specifying content and format
Label label2 = new Label(1,0, "Arial 10 point label", arial10format);
sheet.addCell(label2);
Cell setups objects that are shared, hence numerous cells may use the similar format object, for example:
Label label3 = new Label(2, 0, "Another Arial 10 point label", arial10format);
sheet.addCell(label3);
This makes additional label, with the similar format, in cell C1.
Since cell formats are shared, it becomes impossible to alter the substances of the cell format object. (If this was permitted, then atering the contents of an object could have unexpected consequences on the aspect of the remaining of the workbook). In order to alter the method by which a specific cell can be displayed, the API does permit you to allocate a fresh format to a single cell.
The constructors of the WritableFont object have numerous overloads. By taking an example, the code portion below makes a label of 16 point Times, bold italic and allots it to location D1.
// Create a cell format for Times 16, bold and italic
WritableFont times16font = new WritableFont(WritableFont.TIMES, 16, WritableFont.BOLD, true);
WritableCellFormat times16format = new WritableCellFormat (times16font);
// Create the label, specifying content and format
Label label4 = new Label(3,0, "Times 16 bold italic label", times16format);
sheet.addCell(label4);
Formatting Numbers
Number formatting information may be passed to the cell format object by a similar mechanism to that described for fonts.
A variety of predefined number formats are defined statically. These may be used to format numerical values as follows:
WritableCellFormat integerFormat = new WritableCellFormat (NumberFormats.INTEGER);
Number number2 = new Number(0, 4, 3.141519, integerFormat);
sheet.addCell(number2);
WritableCellFormat floatFormat = new WritableCellFormat (NumberFormats.FLOAT);
Number number3 = new Number(1, 4, 3.141519, floatFormat);
sheet.addCell(number3);
The above code inserts the value 3.14159 into cells A5 and B5, using the preset integer and floating points format respectively. When Excel renders these cells, A5 will display as "3" and B5 will display as "3.14", even though both cells contain the same floating point value.
It's possible for a user to define their own number formats, by passing in a number format string. The string passed in should be in the same format as that used by the java.text.DecimalFormat class. To format a number to display up to five decimal places in cell C5, the following code fragment may be used:
NumberFormat fivedps = new NumberFormat("#.#");
WritableCellFormat fivedpsFormat = new WritableCellFormat(fivedps);
Number number4 = new Number(2, 4, 3.141519, fivedpsFormat);
sheet.addCell(number4);
It is, of course, also possible to specify font information as well eg. to display the same value in the 16 point times bold font defined earlier we can write
WritableCellFormat fivedpsFontFormat = new WritableCellFormat (times16font, fivedps);
Number number5 = new Number(3, 4, 3.141519, fivedpsFontFormat);
sheet.addCell(number5);
Formatting Dates
Dates are handled similarly to numbers, taking in a format compatible with that used by the java.text.SimpleDateFormat class. In addition, several predefined date formats are specified in the jxl.write.DateFormat class.
As a brief example, the below code fragment illustrates placing the current date and time in cell A7 using a custom format:
// Get the current date and time from the Calendar object
Date now = Calendar.getInstance().getTime();
DateFormat customDateFormat = new DateFormat ("dd MMM yy hh:mms");
WritableCellFormat dateFormat = new WritableCellFormat (customDateFormat);
DateTime dateCell = new DateTime(0, 6, now, dateFormat);
sheet.addCell(dateCell);
As with numbers, font information may be used to display the date text by using the overloaded constructors on WritableCellFormat.
For a more extensive example of writing spreadsheets, the demonstration program Write.java should be studied. In addition to the functionality described above, this program tests out a variety of cell, formatting and font options, as well as displaying cells with different background and foreground colours, shading and boundaries.
Copying and Modifying Spreadsheets
This section describes the scenario where a spreadsheet is read in, it's contents altered in some way and the modified spreadsheet written out.
The first stage is to read in the spreadsheet in the normal way:
import java.io.File;
import java.util.Date;
import jxl.*;
import jxl.write.*;
...
Workbook workbook = Workbook.getWorkbook(new File("myfile.xls"));
This creates a readable spreadsheet. To obtain a writable version of this spreadsheet, a copy must be made, as follows:
WritableWorkbook copy = Workbook.createWorkbook(new File("output.xls"), workbook);
The API functions this way is for reasons of read efficiency (since this is the primary use of the API). In order to improve performance, data which relates to output information (eg. all the formatting information such as fonts) is not interpreted when the spreadsheet is read, since this is superfluous when interrogating the raw data values. However, if we need to modify this spreadsheet a handle to the various write interfaces is needed, which can be obtained using the copy method above. This copies the information that has already been read in as well as performing the additional processing to interpret the fields that are necessary to for writing spreadsheets. The disadvantage of this read-optimized strategy is that we have two spreadsheets held in memory rather than just one, thus doubling the memory requirements. For this reason copying and modifying large spreadsheets can be expensive in terms of processing and memory.
Once we have a writable interface to the workbook, we may retrieve and modify cells. The following code fragment illustrates how to modify the contents of a label cell located in cell B3 in sheet 2 of the workbook.
WritableSheet sheet2 = copy.getSheet(1);
WritableCell cell = sheet2.getWritableCell(1, 2);
if (cell.getType() == CellType.LABEL)
{
Label l = (Label) cell;
l.setString("modified cell");
}
There is no need to call the add() method on the sheet, since the cell is already present on the sheet. The contents of numerical and date cells may be modified in a similar way, by using the setValue() and setDate() methods respectively.
Although cell formats are immutable, the contents of a cell may be displayed differently by assigning a different format object to the cell. The following code fragment illustrates changing the format of numerical cell (in position C5) so that the contents will be displayed to five decimal places.
WritableSheet sheet2 = copy.getSheet(1);
WritableCell cell = sheet2.getWritableCell(2, 4);
NumberFormat fivedps = new NumberFormat("#.#");
WritableCellFormat cellFormat = new WritableCellFormat(fivedps);
cell.setFormat(cellFormat);
Since the copy of the workbook is an ordinary writable workbook, new cells may be added to the sheet, thus:
Label label = new Label(0, 2, "New label record");
sheet2.addCell(label);
Number number = new Number(3, 4, 3.1459);
sheet2.addCell(number);
As before, once the modifications are complete, the workbook must be written out and closed.
...
// All cells modified/added. Now write out the workbook
copy.write();
copy.close();
The demo program contained in the source file ReadWrite.java may be studied as a more exhaustive example of how spreadsheets may be modified. This demo program copies the spreadsheet passed in on the command line; if the spreadsheet to be copied is the example spreadsheet, jxlrwtest.xls, located in the current directory, then certain modifications are carried out. DO NOT MODIFY THE EXAMPLE SPREADSHEET, otherwise the demo program will not work.
Demonstration and Test Programs
JExcelApi comes with a raft of demonstration and test programs contained in the package jxl.demo. These may be accessed from the command line as follows
java -jar jxl.jar -csv spreadsheet.xls
Reads spreadsheet.xls and writes out the corresponding csv data to the standard output. The -csv option is the default and may omitted
java -jar jxl.jar -xml spreadsheet.xls
Reads spreadsheet.xls and writes out the corresponding cell data to the standard output as XML.
java -jar jxl.jar -xml -format spreadsheet.xls
As above, but includes formatting information (font, number formats etc) in the generated XML
java -jar jxl.jar -formulas spreadsheet.xls
Reads spreadsheet.xls and displays all the formulas contained in that sheet.
java -jar jxl.jar -write test.xls
Generates a sample test spreadsheet called test.xls
java -jar jxl.jar -rw in.xls out.xls
Reads in.xls, copies it and generates a file called out.xls. If the spreadsheet passed in is a special sample spreadsheet called jxlrwtest.xls, then this demo will modify specific cells in the copy, out.xls