Sitemap

Towards Dev

A publication for sharing projects, ideas, codes, and new theories.

Question Paper Setter Using CHAT-GPT using React JS

2 min readFeb 19, 2023

--

The question “Can we use CHAT GPT to help teachers?” crossed my head a few days ago.
I made the decision to create a website that is accessible to everyone, regardless of device.

The only information you need to enter is the number of questions to be framed, together with the block of text from which you wish to phrase the questions.
CHAT-GPT will pose questions based on how well the paragraph is written.
When a paragraph is informative, CHAT-GPT creates multiple-choice questions (MCQs) with answers; but, when a paragraph is neutral, it frames When, What, and Where inquiries.

Depending on your requirements, you can modify the query that is used as an input by the CHAT-GPT. You’ll get more comparable results if your query is better.

What actually occurs in the background is that a JavaScript file called openai.js makes an API call to the CHAT-GPT, which then returns a series of questions as the result.

(Note :- The maximum number of questions you can receive in the output is 10, which is a CHAT-GPT restriction.)

Get Deepankar Varma’s stories in your inbox

Join Medium for free to get updates from this writer.

The working source code is available at :-

QuickStart

  1. Clone this repository.
  2. Add your OpenAI API key to .env file (sign up at https://beta.openai.com for account / key)
  3. Install node_modules by running npm install or yarn install in terminal
  4. In pages/api/openai.js you construct your request to OpenAI API
  5. In pages/index.js you tweak your UI/UX
  6. Start the dev server with yarn dev or npm run dev command
  7. Run setx command in cmd for setting the API Key in the environment variables
  8. Incase you get browser outdated error, run npm install browserslist
  9. For any other major errors try removing the node modues , package.json and run the npm install again.

For help related to API connection visit OpenAI

How to use

Simply paste a paragraph in the first textarea and then enter the number of MCQ questions you need in the second textarea.Finally use the Frame Questions button to generate questions. The maximum questions generated at a time is 10 (Limitation from CHAT GPT).

Working Screenshot

Press enter or click to view image in full size
Image
Demonstration

Tips

If you don’t have a setup on your computer that allow to run code locally, then use https://replit.com/

--

--

Published in Towards Dev

A publication for sharing projects, ideas, codes, and new theories.

Written by Deepankar Varma

Final year student majoring in computer science from TIET with an emphasis on machine learning and data science and a solid background in programming.

No responses yet