Skip to content

noise-controller-bw/Back-End

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

BACK END FOR THE NOISE CONTROLLER PROJECT

API: https://noise-controller-buildweek.herokuapp.com/

Table of Contents

DESCRIPTION

Pitch: As a teacher, it can be hard to control the noise level in your classroom! You need an app that holds kids attention, and is sensitive to the noise level in the room to motivate them to stay quiet. While some exist, they seem to encourage kids to yell (like balls that bounce higher if you yell louder). This app will reveal unique animals (choose a theme for this app) only if it's quiet enough, keeping the kids quiet.

MVP

  • Onboarding process for new teacher to sign up, including their class name.
  • Main page: Every 'x' number of seconds a new creature comes out if it's quiet enough. If the noise level in the room reaches a certain point, the animals are all scared away. This will involve a listener to detect sound.
  • Ability for the user to set how sensitive they want the microphone to be. Ability for user to set how many seconds they want between a new animal coming out (could also be random).
  • Show a live score on the page, and final score page at the end of each day. (ie start at 100 and -10 every time they scare the animals. You choose how to score)
  • Page for the class to view their daily score records over time

Stretch

  • Show a 'streak counter' to track how many days the class goes without scaring off the fish.
  • Create additional visual effects/themes for the class to choose from. (forest, ocean, desert, spiders, dinos, etc.)
  • Ability for a teacher to have multiple classes, and a page to view a list of their classes.

Resources

Restricted routes

All routes exept /register and /login are restricted, user must be logged in. GET for /users, DELETE /users/:id and /classes/:id are accessible only for users with admin permissions.

Authentication

Register

[POST]

URL: /register

Payload:

{
    "firstname": "Alan",
    "lastname": "Turing",
    "username": "Enigma",
    "password": "super%password",
    "email": "[email protected]",
    "role": "teacher" // optional, default to teacher
}

Returns: a user object and the authentication token.

Example:

{
    "user": {
        "id": "774a744d-6cb3-4a41-b45d-0ef94b9d2af7", // string, for routing
        "ref_id": 4, // integer, for referencing user in sessions
        "firstname": "Alan",
        "lastname": "Turing",
        "username": "Enigma",
        "email": "[email protected]",
        "role": "teacher"
    },
    "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWJqZWN0IjoiNzc0YTc0NGQtNmNiMy00YTQxLWI0NWQtMGVmOTRiOWQyYWY3IiwidXNlcm5hbWUiOiJNdGgiLCJyb2xlcyI6InRlYWNoZXIiLCJpYXQiOjE1NjMzMTQ4NzQsImV4cCI6MTU2MzQwMTI3NH0.UFGfIRyHym3sVwi9xkfOmQ9QdjJ9OQehFr00Hl9ZwYw"
}

Login

[POST]

URL: /login

Payload:

{
    "username": "Enigma",
    "password": "super%password"
}

Returns: Example:

{
    "message": "Welcome Enigma!",
    "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWJqZWN0IjoiNGRhYTFhMmYtMDdhNi00NWQ0LTkxMWQtYzQyNjJlNmM1NmZmIiwidXNlcm5hbWUiOiJFbmlnbWEiLCJyb2xlcyI6InRlYWNoZXIiLCJpYXQiOjE1NjMzMjI2MDksImV4cCI6MTU2MzQwOTAwOX0.hqB2hZ9HJjEiwbZpZXYfPTgDmjAfzE2MpJFLJlVKeJM",
    "user": {
        "id": "4daa1a2f-07a6-45d4-911d-c4262e6c56ff", // string, for routing
        "ref_id": 4, //integer, for referencing user in sessions
        "firstname": "Alan",
        "lastname": "Turing",
        "username": "Enigma",
        "email": "[email protected]",
        "role": "teacher"
    }
}

Users

[GET] all users

URL: /users

Returns: an array of user objects

Example:

{
    "id": "1", // string, for routing
    "ref_id": 1, // integer, for referencing user in sessions
    "firstname": "Kasia",
    "lastname": "Bondarava",
    "username": "kbondarava",
    "email": "[email protected]",
    "role": "teacher"
}

[GET] user by id

URL: /users/:id

Returns: a user object

Example:

{
    "id": "2", // string, for routing
    "ref_id": 2, // integer, for referencing user in sessions
    "firstname": "Levi",
    "lastname": "Simpson",
    "username": "levisimpson",
    "email": "[email protected]",
    "role": "teacher"
}

[GET] sessions by user id

URL: /users/:id/sessions

Returns: an array of session objects for particular user

Example:

{
    "id": "1",
    "date": "",
    "score": 100,
    "lessonName": "Math",
    "name": "Ms. Angela's",
    "grade": "1st"
}

[GET] classes by user id

URL: /users/:id/classes

Returns: an array of session objects for particular user

Example:

{
    "id": "1",
    "name": "Ms. Angela's",
    "grade": "1st"
}

[POST] create user

URL: /users

Payload:

{
    "firstname": "Alan",
    "lastname": "Turing",
    "username": "Enigma",
    "password": "super%password",
    "email": "[email protected]",
    "role": "admin" // optional, default to "teacher"
}

Returns: a newely created user object with id

Example:

{
    "id": "350a9aeb-3545-42f4-892b-791d51fc9e0a", // string, for routing
    "ref_id": 4, // integer, for referencing user in sessions
    "firstname": "Alan",
    "lastname": "Turing",
    "username": "Enigma",
    "email": "[email protected]",
    "role": "admin"
}

[DELETE] user

URL: /users/:id

Authorisation: User must be an admin.

Returns: (if successful) message and count of the records has beed deleted.

Example:

{
    "message": "The user has been deleted",
    "count": 1 
}

[PUT] edit user

URL: /users/:id

Payload: an object with the same values as for register.

Returns: (if successful) message and updated user object.

{
    "message": "The user has been updated",
    "updatedUser": {
        "id": "2c872254-feee-48ff-bda3-10041b8b56eb", // string, for routing
        "ref_id": 4, // integer, for referencing user in sessions
        "firstname": "Alan",
        "lastname": "Turing",
        "username": "Enigma",
        "password": "Super%Password",
        "email": "[email protected]",
        "role": "admin"
}

Sessions

[GET] all sessions

URL: /sessions

Returns: an array of sessions objects

Example:

{
    "id": "1",
    "date": "03/07/2019",
    "score": 100,
    "lessonName": "Math" // subject
}

[GET] session by id

URL: /sessions/:id

Returns: a session object

Example:

{
    "id": "1",
    "firstname": "Kasia", // first name of the user which has created the session
    "lastname": "Bondarava", // last name of the user which has created the session
    "date": "03/07/2019",
    "lessonName": "Math", // subject
    "className": "Ms. Angela's",
    "grade": "1st",
    "score": 100
}

[POST] create session

URL: /sessions

Payload:

{
    "user_id": 1, // === integer, ref_id of the user
    "class_id": 1, // === integer, ref_id of the class
    "date": "03/07/2019",
    "score": 0,
    "lessonName": "Math" // optional
}

Returns: message and a newely created session object with id

Example:

{
    "message": "sessions was added succesfully",
    "inserted": [
        {
            "id": "a0a15399-523b-4fd8-b883-fb03f1cbc2bf",
            "firstname": "Alan", // first name of the user which has created the session
            "lastname": "Turing", // last name of the user which has created the session
            "date": "03/07/2019",
            "lessonName": "Math",
            "className": "Ms. Angela's",
            "grade": "1st",
            "score": 80
        }
    ]
}

[DELETE] session

URL: /sessions/:id

Returns: (if successful) message and count of the records has beed deleted.

Example:

{
    "message": "The session has been deleted",
    "count": 1
}

[PUT] edit session

URL: /sessions/:id

Payload: an object with the same values as for create session.

Returns: (if successful) message and updated user object.

{
    "message": "The session has been updated",
    "updatedSessions": {
        "id": "a0a15399-523b-4fd8-b883-fb03f1cbc2bf",
        "user_id": 9,
        "class_id": 1,
        "date": "03/07/2019",
        "score": 100,
        "lessonName": "Math"
}

Classes

Themes

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •