Skip to content

Commit

Permalink
Submission problem score (makeopensource#43)
Browse files Browse the repository at this point in the history
Add the submission problem score entity

Add documentation

rename filenames to be consistently singular

Co-authored-by: Emil Kovacev <[email protected]>
Co-authored-by: Emil Kovacev <[email protected]>
Co-authored-by: John Abramo <[email protected]>
Co-authored-by: Alex M <[email protected]>
Co-authored-by: dylanzinsley <[email protected]>
Co-authored-by: Adrian Carter <[email protected]>
Co-authored-by: alan soto <[email protected]>
Co-authored-by: Alan Soto <[email protected]>
Co-authored-by: --global <--global>
Co-authored-by: Adrian Carter <[email protected]>
Co-authored-by: zhikangxie107 <[email protected]>
Co-authored-by: Dylanz5 <[email protected]>
Co-authored-by: ToNewAutumn <[email protected]>
  • Loading branch information
13 people authored Nov 3, 2022
1 parent 6d7c15a commit 0ca1c2d
Show file tree
Hide file tree
Showing 69 changed files with 3,076 additions and 10,402 deletions.
Binary file removed .DS_Store
Binary file not shown.
21 changes: 10 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Typescript Example Project
# devU API

This is an API for the v4 autograder. The main purpose of this project is to act as an in-between for the containers doing the autograding, and the users submitting assignments.

Expand All @@ -9,7 +9,7 @@ This is an API for the v4 autograder. The main purpose of this project is to act

For now the only reason we're including docker is to more easily control the development database. In the future we may very well dockerize the api itself for ease of development and deployment, but for now this writeup is expecting it to be running directly on your machine via node.

## Running the project locally
## Running the Project Locally

### Getting Everything Started

Expand All @@ -25,7 +25,7 @@ docker run \
-d postgres
```

Install all node dependancies. All of the database environment variables can change, and can be set as environment variables on your machine if you want to overwrite the defaults
Install all node dependencies. All of the database environment variables can change, and can be set as environment variables on your machine if you want to overwrite the defaults

```
npm install
Expand All @@ -37,7 +37,6 @@ Run the setup script to create local development auth keys. These are used in lo
npm run generate-config
```


Run the initial migrations to setup our DB schema

```
Expand Down Expand Up @@ -76,13 +75,13 @@ Use [Azure Data Studio](https://docs.microsoft.com/en-us/sql/azure-data-studio/d

### Local Auth Providers

If you're looking for more information on how to setup auth for your developement environment, check out more info [here](./docs/localAuth.md)
If you're looking for more information on how to setup auth for your development environment, check out more info [here](./docs/localAuth.md)

## Working in the Project

This project is built using

- [Typescript](https://www.typescriptlang.org/) - A superset of JavaScript. The language of the applciation
- [Typescript](https://www.typescriptlang.org/) - A superset of JavaScript. The language of the application
- [Express](https://expressjs.com/) - A Node REST framework.
- [TypeORM](https://typeorm.io/#/) - A Typescript ORM (manages the DB and all DB calls)

Expand All @@ -101,7 +100,7 @@ In express, all of the functions added after the route's path are considered mid
Express's middleware is always a function with three arguments

```typescript
function middlwareName(req: Reques, res: Response, next: NextFunction)
function middlewareName(req: Request, res: Response, next: NextFunction)
```

Here's what you need to know:
Expand Down Expand Up @@ -130,7 +129,7 @@ Let's take this from the top
- Controllers: deals with setting status codes, and directing to services. For the most part, controllers should be the last piece of middleware in the chain.
- Services: Workhorse of the application. Deals with all major application logic and database calls

The database models live outside of this control flow as they don't deal with any buisness logic. However services will use them to access the database. You can largely think of the models as a 1:1 map to database tables.
The database models live outside of this control flow as they don't deal with any business logic. However services will use them to access the database. You can largely think of the models as a 1:1 map to database tables.

### Shared Modules

Expand Down Expand Up @@ -168,7 +167,7 @@ npm test

Keep in mind that when testing, jest is looking for `*.test.ts` files, so be sure to include the `.test` portion in those filenames.

If durring development, you want to only run a single test file (via command line), you can do so by adding a string to the end of the test command. That string will be used as a regex against the filename(s). So as an example, if we wanted to run all of the controller tests, you could do so by:
If during development, you want to only run a single test file (via command line), you can do so by adding a string to the end of the test command. That string will be used as a regex against the filename(s). So as an example, if we wanted to run all of the controller tests, you could do so by:

```
npm test "controller"
Expand Down Expand Up @@ -210,7 +209,7 @@ npm run typeorm -- migration:revert

### Configuration Options

Most of the API's configuraiton options live in a file called `environment.ts`. That file is bootstrapped at startup using the [config library]https://www.npmjs.com/package/config), as well as some environment variables.
Most of the API's configuration options live in a file called `environment.ts`. That file is bootstrapped at startup using the [config library](https://www.npmjs.com/package/config), as well as some environment variables.

What this means for you (the developer) is that you can control certain api options via environment variables at runtime, or by using your `config/default.yml`. To see which `environment.ts` options support using environment variables directly, open that file and see which are using `process.env.*`; everything else should be configurable via your `default.yml`

Expand All @@ -236,7 +235,7 @@ import Routers
import Utils
```

The important thing here is once you get into the modules (models/ controllers/ routers/ etc), import them alphebetically with a single empty line inbetween them.
The important thing here is once you get into the modules (models/ controllers/ routers/ etc), import them alphabetically with a single empty line in between them.

## Production Builds

Expand Down
121 changes: 121 additions & 0 deletions docs/SCHEMA.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
# Entities

- [x] [User](#user)
- [x] [Course](#course)
- [x] [UserCourse](#usercourse)
- [x] [Assignment](#assignment)
- [x] [Submission](#submission)
- [x] [AssignmentProblem](#assignmentproblem)
- [ ] [SubmissionProblemScore](#submissionproblemscore)
- [ ] [SubmissionScore](#submissionscore)
- [ ] [AssignmentScore](#assignmentscore)
- [ ] [CategoryScore](#categoryscore)
- [ ] [Category](#category)
- [ ] [CourseScore](#coursescore)



# Entity Details

### Generic Entity Attributes
* id
* createdAt
* updatedAt
* deletedAt


### User
*Student user for devu*
* email: string
* externalId: foreign_key
* preferredName: string


### Course
* name: string
* semester: string
* number: string *ex: cse220*
* startDate: ?
* endDate: ?


### UserCourse
*Links a user to a course*
* userId: foreign_key
* courseId: foreign_key
* level: ?
* dropped: boolean


### Assignment
* courseId: foreign_key
* name: string
* startDate: ?
* dueDate: ?
* endDate: ?
* gradingType: ?
* categoryName: ?
* description: string
* maxFileSize: ?
* maxSubmissions: ?
* disableHandins: boolean


### Submission
* courseId: foreign_key
* assignmentId: foreign_key
* userId: foreign_key
* content: ?
* type: ?
* submitterIp: ?
* submittedBy: ?
* orignalSubmissionId: ?


### AssignmentProblem
* assignmentId: foreign_key
* problemName: ?
* maxScore: ?


**------ Everything above this line exists in the code. Everything below needs to be built ------**


### SubmissionProblemScore
* submissionId: foreign_key
* assignmentProblemId: foreign_key
* score: ?
* feedback: ?
* released: ?


### SubmissionScore
* submissionId: foreign_key
* score: ?
* feedback: ?
* released: ?


### AssignmentScore
* assignmentId: foreign_key
* userId: foreign_key
* score: ?


### CategoryScore
* categoryId: foreign_key
* userId: foreign_key
* *missing attributes*


### Category
* courseId: foreign_key
* *missing attributes*


### CourseScore
* courseId: foreign_key
* userId: foreign_key
* *missing attributes*


42 changes: 42 additions & 0 deletions docs/localAuth.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,50 @@ If you wish to better understand how this works, here's a bit more information.
When developer auth is enabled, users can provide the email & externalId of the user they wish to login as (or create) and recieve a valid refresh/ access token.
### Fetching the bearer token
Request: `POST /login/developer`

Sample Request body:
```
{
"email": "[email protected]",
"externalId": "101"
}
```

Sample Response:

```
{
"message": "Login successful"
}
```

Sample Response Headers:
```
{
"Set-Cookie": "refreshToken=<token>;<cookie settings>"
}
```

### Using the Bearer token

Request: `GET /users`

Request headers (notice the space between `Bearer` and `<token>`!):

```
{
"Authorization": "Bearer <token>"
}
```

With this flag on, it enabled the `/login/developer` route (see `./router/login.router.ts` for more details).



## Testing SAML Authentication Locally

To test SAML authentication, you will need to configure an Identity Provider (IDP) for the API to authenticate against. As we don't expect anyone to just have a configured IDP laying around ready to go, this will walk through using [SamlTest.id](https://samltest.id/).
Expand Down
20 changes: 20 additions & 0 deletions docs/postman-setup.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Postman Setup

[JSON configuration file for Postman](https://www.getpostman.com/collections/b817928ddd3489a9f8a4)

Postman is a great tool for testing API endpoints. The link above is a configuration file that
will help setup the basic configuration for working with most of the basic endpoints.

### Get Started
1. Install/Open Postman
2. Copy JSON configuration file link
3. Select `Import > Link`
4. Paste the link, click continue, and then click `Import`

### Setup Auth
See `docs/localAuth.md` for examples

1. Using the auth folder, run `retrieve auth token`
2. Copy the **content** of the refresh token
3. Under the devU collection, set a variable called `authorization` to the content of the previous step
4. Run all the requests you want!
Loading

0 comments on commit 0ca1c2d

Please sign in to comment.