Giter Site home page Giter Site logo

reelo's Introduction

Reelo Assignment - Question Paper Generator

Overview

This Node.js application is designed to generate question papers based on a question bank provided in a JSON file. The application exposes three REST APIs for different functionalities related to question paper generation.

Prerequisites

  • Node.js installed on your machine.

Installation

  1. Clone the repository:

    git clone https://github.com/your-username/reelo.git
  2. Navigate to the project directory:

    cd reelo
  3. Install dependencies:

    npm install

Usage

1. Generate Basic Question Paper

Endpoint: /generate_paper

  • Method: POST
  • Request Body:
    {
      "total_marks": 50,
      "difficulty": {
        "Easy": "28%",
        "Medium": "40%",
        "Hard": "32%"
      }
    }
  • Example:

    Steps to Use Postman

  1. Open Postman on your machine.

  2. Set the request type GET .

  3. Enter the API endpoint URL: https://127.0.0.1:3000/generate_paper

  4. Set the request headers:

  • Content-Type: application/json
  1. Set the request body:

    • For POST requests, select the "Body" tab, choose "raw," and paste the JSON body given above.
  2. Click the "Send" button to make the API call.

  3. View the response in the "Body" section of the Postman interface.

dfs Function

The dfs function is a critical component of the first API in this application. Its primary role is to generate a question paper based on the specified parameters, including total marks, a pool of all available questions, the number of required questions, and the maximum limit for each difficulty level.

Function Signature:

function dfs(marks, allquestions, required_questions, max) {
  // Function implementation
}

Parameters:

  • marks: Total marks for the question paper.
  • allquestions: A pool of all available questions.
  • required_questions: The number of questions required for the paper.
  • max: Maximum limit for each difficulty level.

Functionality:

  1. Depth-First Search (DFS) Algorithm:

    • The function employs a depth-first search algorithm to traverse the available questions and select the optimal combination that meets the specified requirements.
  2. Difficulty Level Weightage:

    • The function ensures that the selected questions maintain the desired weightage for each difficulty level, as defined by the max parameter. This ensures a balanced distribution of easy, medium, and hard questions.
  3. Total Marks Calculation:

    • The function calculates the total marks of the generated question paper, providing users with a clear understanding of the paper's overall difficulty level.

Example Usage:

const generatedPaper = dfs(50, allQuestionsPool, [], { "Easy": 14, "Medium": 20, "Hard": 16 });

Important Note:

Feel free to enhance the function based on specific use cases and requirements.

2. Get Questions Topicwise

Endpoint: /get_questions_topicwise

  • Method: POST
  • Request Body:
    {
      "total_marks": 50,
      "difficulty": {
        "Easy": "28%",
        "Medium": "40%",
        "Hard": "32%"
      },
      "weightage": {
        "Democracy": "8%"
      }
    }
  • Example:

    Steps to Use Postman

  1. Open Postman on your machine.

  2. Set the request type GET .

  3. Enter the API endpoint URL: https://127.0.0.1:3000/get_questions_topicwise

  4. Set the request headers:

  • Content-Type: application/json
  1. Set the request body:

    • For POST requests, select the "Body" tab, choose "raw," and paste the JSON body given above.
  2. Click the "Send" button to make the API call.

  3. View the response in the "Body" section of the Postman interface.

topicwise_dfs Function

The topicwise_dfs function is a core component of the second API in this application. Its primary responsibility is to generate a question paper based on the specified parameters, including total marks, marks distribution across difficulty levels, topic-wise weightage, and a pool of all available questions.

Function Signature:

function topicwise_dfs(marks, marks_obj, topics_weightage, allquestions) {
  // Function implementation
}

Parameters:

  • marks: Total marks for the question paper.
  • marks_obj: Marks distribution across difficulty levels.
  • topics_weightage: Weightage of each topic in terms of marks percentage.
  • allquestions: A pool of all available questions.

Functionality:

  1. Topic-wise Question Selection:

    • The function utilizes a depth-first search (DFS) approach to select questions for each topic based on their weightage in the total marks. It ensures that each topic contributes its designated percentage of marks to the total marks.
  2. Difficulty Level Distribution:

    • Within each topic, the function further distributes marks across difficulty levels according to the provided marks_obj. This ensures a balanced representation of easy, medium, and hard questions within each topic.
  3. Marks Percentage Calculation:

    • The function calculates the marks percentage of each topic from the total marks. This information can be useful for users to understand the distribution of marks across different topics.

Example Usage:

const generatedPaper = topicwise_dfs(
  50,
  { "Easy": 14, "Medium":20, "Hard": 16 },
  { "Democracy": "8%" },
  allQuestionsPool
);

Important Note:

  • Adjust the function as needed to accommodate any specific business rules, error handling, or additional features required by your application.

Feel free to enhance the function based on specific use cases and requirements.

3. Paper Generator Topicwise

Endpoint: /paper_generator_topicwise

  • Method: POST
  • Request Body:
    {
      "total_marks": 50,
      "difficulty": {
        "Easy": "28%",
        "Medium": "40%",
        "Hard": "32%"
      },
      "total_questions": 13,
      "weightage": {
        "Democracy": "7.69%"
      }
    }
  • Example:

    Steps to Use Postman

  1. Open Postman on your machine.

  2. Set the request type GET .

  3. Enter the API endpoint URL: https://127.0.0.1:3000/paper_generator_topicwise

  4. Set the request headers:

  • Content-Type: application/json
  1. Set the request body:

    • For POST requests, select the "Body" tab, choose "raw," and paste the JSON body given above.
  2. Click the "Send" button to make the API call.

  3. View the response in the "Body" section of the Postman interface.

paper_generator_topicwise Function

The paper_generator_topicwise function is a key component of the third API in this application. It is responsible for generating a question paper based on various parameters, including total marks, the number of total questions, marks distribution across difficulty levels, topic-wise weightage, a pool of all available questions, and an index to keep track of the current question set.

Function Signature:

function paper_generator_topicwise(
  marks,
  total_questions,
  marks_obj,
  topics_weightage,
  allquestions,
  index
) {
  // Function implementation
}

Parameters:

  • marks: Total marks for the question paper.
  • total_questions: Total number of questions to be included in the paper.
  • marks_obj: Marks distribution across difficulty levels.
  • topics_weightage: Weightage of each topic in terms of marks percentage.
  • allquestions: A pool of all available questions.
  • index: Index to keep track of the current topic.

Functionality:

  1. Topic-wise Question Selection:

    • The function begins by selecting questions for each topic based on their weightage in the total number of questions. It ensures that each topic contributes its designated percentage of marks to the total marks.
  2. Random Question Selection:

    • After selecting questions for each topic, the function fills in the remaining questions randomly from the pool of all available questions.
  3. Difficulty Level Distribution:

    • The function takes into account the marks distribution across difficulty levels (marks_obj) and assigns marks to questions accordingly.

Example Usage:

const generatedPaper = paper_generator_topicwise(
  50,
  13,
  { "Easy": 14, "Medium": 20, "Hard": 16 },
  { "Democracy": "7.69%" },
  allQuestionsPool,
  0
);

Important Note:

Feel free to adjust the function or provide additional error handling based on specific use cases and requirements.

Contributing

Feel free to contribute by opening issues, suggesting improvements, or submitting pull requests.

License

This project is licensed under the MIT License - see the LICENSE file for details.

reelo's People

Contributors

sar-thak-3 avatar

Stargazers

Anuj Kumar Mishra avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.