This Node.js application is a question paper generator which generates a question paper containing 3 levels of difficulty namely Easy
, Medium
and Hard
based on the following queries provided by the user:
- Subject name
- Total marks
- What proportion of marks distributed among the 3 difficulty levels
- What proportion of marks a particular topic should contain
- Download, install and setup postgres v13.11 and pgAdmin4 in your local system.
- Make sure to note down the passwords you enter during the setup.
- After setting up postgres, open command prompt and enter the following command
psql -U postgres -d postgres
. - Now create a new database and a new table for storing all questions and other related info. Enter the queries and commands in the
database.sql
file in database directory as it is.
- Fork this repository and clone it into your local system.
- Create a
.env
file to store all your database config details- PORT=4000
- DB_USER=postgres (default)
- DB_HOST=localhost (default)
- DB_PORT=5432 (default)
- DB_DATABASE=userposts
- DB_PASSWORD=(whatever password you provided while setting up the database in pgAdmin)
- Open the terminal and run
npm install
to install all the necessary packages. - Run
npm run dev
to start the application.
-
This application contains APIs for 2
GET
requests. -
For the first
GET
request, users can provide subject, total marks, and what proportion of marks each difficulty level should contain.Eg:
http://localhost:4000/generatepaper?subject=Mathematics&totalMarks=70&easy=0.4&medium=0.4&hard=0.2
. -
For the second
GET
request, users can provide subject, total marks, what proportion of total marks each difficulty level should contain and what proportion of total marks particular topic should contain. At the current moment, users can add ONLY 1 topic for the last condition mentioned.Eg:
http://localhost:4000/generatepaper/topic?subject=Mathematics&topic=Geometry&topicPercentage=0.2
. -
Users can provide proportions for either 1 or 2 or all 3 difficulty levels. If proportion for only 1 difficulty level is provided, the application will calculate the remaining proportion and divide it equally into the other 2 levels.
-
If the proportions for any 2 difficulty levels are provided, the remaining proportion is calculated and assigned to the 3rd level.
- This application currently supports only 2 subjects namely Physics and Mathematics.
- The default subject is set as
Physics
, i.e. if no subject is provided as query parameter, the application will generate a Physics question paper. - The default total marks is set as
100
, i.e. if total marks is not provided as query parameter, the application will generate a question paper of full marks 100. - The default proportions for each difficulty are set as 0.2 for Easy, 0.5 for Medium and 0.3 for Hard. If proportions for all 3 difficulty levels do not add up to 100%, then the default proportions are assigned to each difficulty level.
- The second api can be tested for topics Waves in Physics and Geometry in Mathematics. It may provide undesired results for other topics.
- Since the question bank doesn't have enough questions on every topic present in the data, it may produce undesired results sometimes.
- Please try to stick to the conventions and notes mentioned to get the desired results.
- Finally, feel free to add to the application.