Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor #30

Draft
wants to merge 10 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 16 additions & 12 deletions .github/ISSUE_TEMPLATE/bug-report.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
---
______________________________________________________________________

name: Bug Report
about: What is the bug about?
title: Priority
labels: bug
assignees: ''

---
______________________________________________________________________

**Describe the bug**
A clear and concise description of what the bug is.

**To Reproduce**
Steps to reproduce the behavior:

1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error
1. Click on '....'
1. Scroll down to '....'
1. See error

**Expected behavior**
A clear and concise description of what you expected to happen.
Expand All @@ -24,15 +26,17 @@ A clear and concise description of what you expected to happen.
If applicable, add screenshots to help explain your problem.

**Desktop (please complete the following information):**
- OS: [e.g. iOS]
- Browser [e.g. chrome, safari]
- Version [e.g. 22]

- OS: \[e.g. iOS\]
- Browser \[e.g. chrome, safari\]
- Version \[e.g. 22\]

**Smartphone (please complete the following information):**
- Device: [e.g. iPhone6]
- OS: [e.g. iOS8.1]
- Browser [e.g. stock browser, safari]
- Version [e.g. 22]

- Device: \[e.g. iPhone6\]
- OS: \[e.g. iOS8.1\]
- Browser \[e.g. stock browser, safari\]
- Version \[e.g. 22\]

**Additional context**
Add any other context about the problem here....
7 changes: 4 additions & 3 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
---
______________________________________________________________________

name: Feature request
about: Suggest an idea for this project
title: ''
labels: enhancement
assignees: ''

---
______________________________________________________________________

**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
A clear and concise description of what the problem is. Ex. I'm always frustrated when \[...\]

**Describe the solution you'd like**
A clear and concise description of what you want to happen.
Expand Down
9 changes: 7 additions & 2 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
### Summary

_Provide an overview..._

### Details

_Add more context to describe the changes..._

### Checks
- [ ] Tested changes
- [ ] Attached Logs

- \[ \] Tested changes
- \[ \] Attached Logs

### Team to Review

_Mention the name of the team to review the PR_

### Reference to the issue

_Mention the issue ID or resources_
24 changes: 5 additions & 19 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
@@ -1,49 +1,35 @@
---
name: Deploy API and Automate Tests

on:
push:
branches:
- main
branches: [main]
pull_request:
branches:
- main

branches: [main]
jobs:
deploy-and-test:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Python 3.12
uses: actions/setup-python@v5
with:
python-version: 3.12

- name: Setup PDM
uses: pdm-project/setup-pdm@v4

- name: Install PDM dependencies and initialize project repository
run: pdm install

- name: Activate Virtual Environment
run: pdm venv activate

- name: Install pip and other dependencies
run: |
python -m pip install --upgrade pip
python -m pip install types-beautifulsoup4 types-requests
pip install -r requirements.txt

- name: Format code
run: pdm format

# - name: Lint code
# run: pdm lint

- name: Start project
run: pdm run start

- name: Lint code
run: pdm lint
- name: Run Tests
run: pdm test
env:
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
wip/

# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
Expand Down
31 changes: 16 additions & 15 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
---
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.2.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: check-added-large-files
# export python requirements
- repo: https://github.com/pdm-project/pdm
rev: 2.15.1 # a PDM release exposing the hook
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: check-added-large-files
# export python requirements
- repo: https://github.com/pdm-project/pdm
rev: 2.15.1 # a PDM release exposing the hook
hooks:
- id: pdm-export
- id: pdm-export
# command arguments, e.g.:
args: ['-o', 'requirements.txt', '--without-hashes']
args: [-o, requirements.txt, --without-hashes]
files: ^pdm.lock$
# format pyproject.toml file
- repo: https://github.com/kieran-ryan/pyprojectsort
rev: v0.3.0
hooks:
- id: pyprojectsort
# format pyproject.toml file
- repo: https://github.com/kieran-ryan/pyprojectsort
rev: v0.3.0
hooks:
- id: pyprojectsort
16 changes: 16 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"configurations": [
{
"name": "Python Debugger: FastAPI",
"type": "debugpy",
"request": "launch",
"module": "uvicorn",
"args": [
"app:app",
"--reload"
],
"jinja": true,
"cwd": "${workspaceFolder}/src/gradescopeapi/api"
}
]
}
48 changes: 24 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,32 +1,33 @@
# Gradescope API

[![PyPI version](https://img.shields.io/pypi/v/gradescopeapi)](https://pypi.org/project/gradescopeapi/) ![Test and lint workflow](https://github.com/nyuoss/gradescope-api/actions/workflows/main.yaml/badge.svg)

## Description

This *unofficial* project serves as a library for programmatically interacting with [Gradescope](https://www.gradescope.com/). The primary purpose of this project is to provide students and instructors tools for interacting with Gradescope without having to use the web interface.

For example:

* Students using this project could automatically query information about their courses and assignments to notify them of upcoming deadlines or new assignments.
* Instructors could use this project bulk edit assignment due dates or sync student extensions with an external system.
- Students using this project could automatically query information about their courses and assignments to notify them of upcoming deadlines or new assignments.
- Instructors could use this project bulk edit assignment due dates or sync student extensions with an external system.

## Features

Implemented Features Include:

* Get all courses for a user
* Get a list of all assignments for a course
* Get all extensions for an assignment in a course
* Add/remove/modify extensions for an assignment in a course
* Add/remove/modify dates for an assignment in a course
* Upload submissions to assignments
* API server to interact with library without Python
- Get all courses for a user
- Get a list of all assignments for a course
- Get all extensions for an assignment in a course
- Add/remove/modify extensions for an assignment in a course
- Add/remove/modify dates for an assignment in a course
- Upload submissions to assignments
- API server to interact with library without Python

## Demo

## Demo
To get a feel for how the API works, we have provided a demo video of the features in-use: [link](https://youtu.be/eK9m4nVjU1A?si=6GTevv23Vym0Mu8V)

Note that we only demo interacting with the API server, you can alternatively use the Python library directly.

Note that we only demo interacting with the API server, you can alternatively use the Python library directly.

## Setup

Expand All @@ -39,6 +40,7 @@ pip install gradescopeapi
For additional methods of installation, refer to the [install guide](docs/INSTALL.md)

## Usage

The project is designed to be simple and easy to use. As such, we have provided users with two different options for using this project.

### Option 1: FastAPI
Expand All @@ -50,24 +52,22 @@ If you do not want to use Python, you can host the API using the integrated Fast
To run the API server locally on your machine, open the project repository on your machine that you have cloned/forked, and:

1. Navigate to the `src.gradescopeapi.api` directory
2. Run the command: `uvicorn api:app --reload` to run the server locally
3. In a web browser, navigate to `localhost:8000/docs`, to see the auto-generated FastAPI docs

1. Run the command: `uvicorn api:app --reload` to run the server locally
1. In a web browser, navigate to `localhost:8000/docs`, to see the auto-generated FastAPI docs

### Option 2: Python

Alternatively, you can use Python to use the library directly. We have provided some sample scripts of common tasks one might do:

```python
from gradescopeapi.classes.connection import GSConnection
from gradescopeapi.classes.connection import login
from gradescopeapi.classes.courses import get_all_courses

# create connection and login
connection = GSConnection()
connection.login("[email protected]", "password")
# Login to Gradescope
session = login("email", "password")

"""
Fetching all courses for user
"""
courses = connection.account.get_courses()
# Fetch all courses for the user
courses = get_courses(session)
for course in courses["instructor"]:
print(course)
for course in courses["student"]:
Expand All @@ -93,7 +93,7 @@ For more examples of features not covered here such as changing extensions, uplo

## Testing

For information on how to run your own tests using ```gradescopeapi```, refer to [TESTING.md](docs/TESTING.md)
For information on how to run your own tests using `gradescopeapi` refer to [TESTING.md](docs/TESTING.md)

## Contributing Guidelines

Expand Down
42 changes: 17 additions & 25 deletions docs/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,26 +1,24 @@
# Contributing Guidelines

We welcome any potential contributions to the gradescopeapi project! Please
use this page as a reference if you want to help improve the project by submitting feedback, changes, etc.
use this page as a reference if you want to help improve the project by submitting feedback, changes, etc.


## Bug Reports/Enhancements Requests
## Bug Reports/Enhancements Requests

We use [GitHub Issues](https://github.com/nyuoss/gradescope-api/issues) to track any potential bugs along with requests for features to be implemented. Please follow the provided guide for creating your bug report/feature request
and we will respond to it as soon as possible.

and we will respond to it as soon as possible.

## Making Your Own Changes

If you want to make your own changes to the gradescopeapi, please follow the following instructions:

1. Clone/Fork the ```gradescopeapi``` repository
2. Create a ```feature``` branch
3. Make your desired changes
4. Push the changes
5. Submit a Pull Request
1. Clone/Fork the `gradescopeapi` repository
1. Create a `feature` branch
1. Make your desired changes
1. Push the changes
1. Submit a Pull Request

Ensure that your changes adhere to the **coding style**. This can be done using ```pdm``` to run the ```ruff``` linter:
Ensure that your changes adhere to the **coding style**. This can be done using `pdm` to run the `ruff` linter:

```bash
pdm format
Expand All @@ -29,21 +27,15 @@ pdm lint
```

## Pull Requests
If you have existing chnages that you want added to gradescopeapi, please create a pull request using [GitHub](https://github.com/nyuoss/gradescope-api/pulls).

Include in your pull request:
1. Summary of the changes you made
2. Detailed description of the exact changes
3. Checks made
4. Members of the team to review the request
5. A reference to the issue (optional)

Once you have submitted your pull requests, a team member will review the changes and provide feedback as necessary. If your changes are approved, they will be merged with the ```main``` branch.





If you have existing chnages that you want added to gradescopeapi, please create a pull request using [GitHub](https://github.com/nyuoss/gradescope-api/pulls).

Include in your pull request:

1. Summary of the changes you made
1. Detailed description of the exact changes
1. Checks made
1. Members of the team to review the request
1. A reference to the issue (optional)

Once you have submitted your pull requests, a team member will review the changes and provide feedback as necessary. If your changes are approved, they will be merged with the `main` branch.
Loading