{"id":24896927,"url":"https://github.com/alpha951/reelo","last_synced_at":"2025-03-27T16:41:35.265Z","repository":{"id":209151168,"uuid":"723341811","full_name":"alpha951/reelo","owner":"alpha951","description":null,"archived":false,"fork":false,"pushed_at":"2023-11-26T09:05:30.000Z","size":38,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-01T20:15:50.000Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/alpha951.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2023-11-25T11:10:08.000Z","updated_at":"2023-11-25T12:15:10.000Z","dependencies_parsed_at":"2023-11-25T13:28:18.515Z","dependency_job_id":"70386bdf-ad92-4bf3-aee8-822fcc77fd7c","html_url":"https://github.com/alpha951/reelo","commit_stats":null,"previous_names":["alpha951/reelo"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alpha951%2Freelo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alpha951%2Freelo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alpha951%2Freelo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alpha951%2Freelo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/alpha951","download_url":"https://codeload.github.com/alpha951/reelo/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245885823,"owners_count":20688535,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-02-01T20:15:51.338Z","updated_at":"2025-03-27T16:41:35.240Z","avatar_url":"https://github.com/alpha951.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Quiz App API\n\nThis is a simple Node.js Express application for a quiz app, providing an API to retrieve questions based on specified criteria.\n\n## Table of Contents\n\n- [Introduction](#introduction)\n- [Installation](#installation)\n- [Usage](#usage)\n- [API Endpoint](#api-endpoint)\n- [Request Body](#request-body)\n- [Questions Service](#questions-service)\n- [Error Handling](#error-handling)\n\n## Introduction\n\nThis application serves as the backend for a quiz app, allowing users to retrieve questions based on their desired difficulty levels and total marks. The API is designed to be straightforward, with a single endpoint to request questions.\n\n## Installation\n\n1. Clone the repository:\n\n   ```bash\n   git clone https://github.com/alpha951/reelo\n   ```\n\n2. Navigate to the project directory:\n\n   ```bash\n   cd reelo\n   ```\n\n3. Install dependencies:\n\n   ```bash\n   npm install\n   ```\n\n4. Start the application:\n\n   ```bash\n   node index.js\n   ```\n\n## Usage\n\nThe application provides a RESTful API to fetch questions for a quiz. Refer to the [API Endpoint](#api-endpoint) and [Request Body](#request-body) sections for details on making requests.\n\n## API Endpoint\n\n- **Endpoint:** `/v1/questions`\n- **Method:** `POST`\n\n## Request Body\n\nThe endpoint expects the following JSON structure in the request body:\n\n```json\n{\n  \"totalMarks\": 100,\n  \"easyPercentage\": 30,\n  \"mediumPercentage\": 40,\n  \"hardPercentage\": 30\n}\n```\n\n- `totalMarks`: Total marks for the quiz.\n- `easyPercentage`: Percentage of easy questions.\n- `mediumPercentage`: Percentage of medium questions.\n- `hardPercentage`: Percentage of hard questions.\n\n## Questions Service\n\nThe core functionality is implemented in the `question.service.js` file. This service handles the loading and selection of questions based on the provided criteria.\n\n### Functions\n\n#### `loadQuestions(filePath: string): Promise`\n\nLoads questions from the specified JSON file.\n\n#### `getQuestions(data: object): Promise`\n\nSelects questions based on the provided criteria (total marks and difficulty percentages).\n\n### Usage\n\n\n#### Example - 1\n\n\u003cb\u003ereq.body\u003c/b\u003e\n\n````json\n    {\n    \"totalMarks\": 100,\n    \"easyPercentage\": 20,\n    \"mediumPercentage\": 50,\n    \"hardPercentage\": 30\n    }\n````\n\u003cb\u003eresponse\u003c/b\u003e\n\n```json\n{\n    \"success\": true,\n    \"message\": \"Successfully completed the request\",\n    \"data\": {\n        \"easy\": [\n            {\n                \"id\": 1,\n                \"question\": \"What is the speed of light\",\n                \"subject\": \"Physics\",\n                \"topic\": \"Motion\",\n                \"difficulty\": \"Easy\",\n                \"marks\": 5\n            },\n            {\n                \"id\": 3,\n                \"question\": \"If an object is moving with constant speed, what can you say about its acceleration?\",\n                \"subject\": \"Physics\",\n                \"topic\": \"Motion\",\n                \"difficulty\": \"Easy\",\n                \"marks\": 5\n            },\n            {\n                \"id\": 6,\n                \"question\": \"What is the molecular structure of water?\",\n                \"subject\": \"Chemistry\",\n                \"topic\": \"Chemical Bonding\",\n                \"difficulty\": \"Easy\",\n                \"marks\": 5\n            },\n            {\n                \"id\": 10,\n                \"question\": \"What are isotopes in the context of atomic structure?\",\n                \"subject\": \"Chemistry\",\n                \"topic\": \"Atomic Structure\",\n                \"difficulty\": \"Easy\",\n                \"marks\": 5\n            }\n        ],\n        \"medium\": [\n            {\n                \"id\": 2,\n                \"question\": \"State the first law of thermodynamics.\",\n                \"subject\": \"Physics\",\n                \"topic\": \"Thermodynamics\",\n                \"difficulty\": \"Medium\",\n                \"marks\": 10\n            },\n            {\n                \"id\": 4,\n                \"question\": \"Solve the quadratic equation: (2x^2 - 5x + 2 = 0).\",\n                \"subject\": \"Mathematics\",\n                \"topic\": \"Quadratic Equations\",\n                \"difficulty\": \"Medium\",\n                \"marks\": 10\n            },\n            {\n                \"id\": 7,\n                \"question\": \"Balance the following chemical equation: (C_4H_{10} + O_2 rightarrow CO_2 + H_2O).\",\n                \"subject\": \"Chemistry\",\n                \"topic\": \"Chemical Equations\",\n                \"difficulty\": \"Medium\",\n                \"marks\": 10\n            },\n            {\n                \"id\": 9,\n                \"question\": \"Evaluate the integral: (int (3x^2 + 2x - 5) ,dx).\",\n                \"subject\": \"Mathematics\",\n                \"topic\": \"Integration\",\n                \"difficulty\": \"Medium\",\n                \"marks\": 10\n            },\n            {\n                \"id\": 12,\n                \"question\": \"Explain the concept of oxidation and reduction in chemical reactions.\",\n                \"subject\": \"Chemistry\",\n                \"topic\": \"Redox Reactions\",\n                \"difficulty\": \"Medium\",\n                \"marks\": 10\n            }\n        ],\n        \"hard\": [\n            {\n                \"id\": 5,\n                \"question\": \"Define the concept of limit in calculus.\",\n                \"subject\": \"Mathematics\",\n                \"topic\": \"Calculus\",\n                \"difficulty\": \"Hard\",\n                \"marks\": 15\n            },\n            {\n                \"id\": 8,\n                \"question\": \"Explain the concept of wave-particle duality in quantum mechanics.\",\n                \"subject\": \"Physics\",\n                \"topic\": \"Quantum Mechanics\",\n                \"difficulty\": \"Hard\",\n                \"marks\": 15\n            }\n        ]\n    },\n    \"error\": {}\n}\n```\n\n#### Example - 2\n\n\u003cb\u003e req.body\u003c/b\u003e\n\n````json\n    {\n    \"totalMarks\": 20,\n    \"easyPercentage\": 100,\n    \"mediumPercentage\": 0,\n    \"hardPercentage\": 0\n    }\n````\n\n\u003cb\u003eresponse \u003c/b\u003e\n\n```json\n{\n    \"success\": true,\n    \"message\": \"Successfully completed the request\",\n    \"data\": {\n        \"easy\": [\n            {\n                \"id\": 1,\n                \"question\": \"What is the speed of light\",\n                \"subject\": \"Physics\",\n                \"topic\": \"Motion\",\n                \"difficulty\": \"Easy\",\n                \"marks\": 5\n            },\n            {\n                \"id\": 3,\n                \"question\": \"If an object is moving with constant speed, what can you say about its acceleration?\",\n                \"subject\": \"Physics\",\n                \"topic\": \"Motion\",\n                \"difficulty\": \"Easy\",\n                \"marks\": 5\n            },\n            {\n                \"id\": 6,\n                \"question\": \"What is the molecular structure of water?\",\n                \"subject\": \"Chemistry\",\n                \"topic\": \"Chemical Bonding\",\n                \"difficulty\": \"Easy\",\n                \"marks\": 5\n            },\n            {\n                \"id\": 10,\n                \"question\": \"What are isotopes in the context of atomic structure?\",\n                \"subject\": \"Chemistry\",\n                \"topic\": \"Atomic Structure\",\n                \"difficulty\": \"Easy\",\n                \"marks\": 5\n            }\n        ],\n        \"medium\": [],\n        \"hard\": []\n    },\n    \"error\": {}\n}\n\n```\n\n## Error Handling\n\nThe application uses the `AppError` class for error handling. Specific error messages and HTTP status codes are provided for different scenarios, ensuring clear communication with the client.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falpha951%2Freelo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falpha951%2Freelo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falpha951%2Freelo/lists"}