avantifellows / quiz-frontend

A generic player for playing different types of content (questions, etc.) in a mobile-friendly webapp
GNU General Public License v3.0
4 stars 25 forks source link

Quiz Frontend

License: GPL v3 codecov Cypress Discord

A generic quiz engine for serving different types of questions (mcq, subjective, images, audio etc.) in a mobile-friendly webapp. The backend can be found here.

Table of Contents

Project Setup

Pre-requisites

Backend

Ensure that the backend is up and running by following the setup instructions here.

Pre-commit

The project uses pre-commit for identifying and fixing simple issues before you even make a commit.

  1. Install pre-commit Use pip to install pre-commit

    pip install pre-commit

    Or using homebrew on macOS

    brew install pre-commit

    For more installation alternatives, check out Pre-commit official documentation.

  2. Verify pre-commit installation

    pre-commit --version

Installation

npm install
pre-commit install

Compile and setup hot-reloading for development

npm run serve

You can access the web app at http://localhost:8080/quiz/{quizId}?userId={userId}&apiKey={apikey}. Here, {quizId} should be replaced by a valid ID corresponding to an actual quiz created using the backend and {userId} can be any valid user identifier. For now, there are no explicit checks in place for userId. So, you can use any valid string (eg: 20). Please contact the repository developers for {apiKey}.

Build for deployment

Staging

npm run build -- --mode staging

Production

npm run build

Deployment

The actual deployment happens through Github Actions. Look at .github/workflows/deploy_to_s3_staging.yml for understanding the deployment to Staging and .github/workflows/deploy_to_s3_prod.yml for Production. Make sure to set all the environment variables mentioned in docs/ENV.md in the Production and Staging environments in your Github repository.

Run the unit tests

npm run test:unit

To run unit tests for individual spec files (say, for Header component), use:

npm run test:unit -- Header.spec.ts

Run the end-to-end tests

npx cypress run