fylein / fyle-interview-intern-backend

44 stars 1.14k forks source link

Complete-Assignment-vyomrana02@gmail.com #58

Open Vyomrana02 opened 2 months ago

Vyomrana02 commented 2 months ago

This Pull request covers the tasks mentioned in application.md:

  1. Add missing APIs mentioned here and get the automated tests to pass

    GET /principal/assignments 

image

    GET /principal/teachers 

image

    POST /principal/assignments/grade 

image

  1. Add tests for grading API Added Decorator and Sever test cases.

  2. Please be aware that intentional bugs have been incorporated into the application, leading to test failures. Kindly address and rectify these issues as part of the assignment. Rectify bugs and make code running.

  3. All tests should pass

Screenshot 2024-04-29 124731

  1. Get the test coverage to 94% or above

Screenshot 2024-04-29 125120

  1. There are certain SQL tests present inside tests/SQL/. You have to write SQL in following files: count_grade_A_assignments_by_teacher_with_max_grading.sql
    -- Write query to find the number of grade A's given by the teacher who has graded the most assignments
    SELECT COUNT(*) AS count_grade_a  
    FROM assignments AS assg
    JOIN teachers AS t ON assg.teacher_id = t.id 
    WHERE assg.grade = 'A'  
    GROUP BY t.id  
    ORDER BY count_grade_a DESC
    LIMIT 1; 

number_of_graded_assignments_for_each_student.sql

-- Write query to get number of graded assignments for each student:
SELECT student_id, COUNT(*) AS num_graded_assignments
FROM assignments
WHERE state = 'GRADED'
GROUP BY student_id;
  1. Optionally, Dockerize your application by creating a Dockerfile and a docker-compose.yml file, providing clear documentation on building and running the application with Docker, to stand out in your submission
FROM python:3.10
## Set the FLASK_APP environment variable
ENV FLASK_APP=core/server.py
ENV FLASK_RUN_HOST=0.0.0.0
WORKDIR /app
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt

## Remove the core/store.sqlite3 file
RUN rm -f core/store.sqlite3

## Run the Flask db upgrade command
RUN flask db upgrade -d core/migrations/

COPY . .
EXPOSE 5000
CMD ["bash", "run.sh"]
# docker-compose.yml
version: '3'

services:
  web:
    build: .
    ports:
      - "5000:5000"  
    volumes:
      - .:/app

Run following command to build

docker-compose build

Once the build is complete, start the Docker container using the following command

docker-compose up 

Go to localhost:5000 for seeing running app.