gradescopeapi 1.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- gradescopeapi-1.0.0/LICENSE.md +21 -0
- gradescopeapi-1.0.0/PKG-INFO +128 -0
- gradescopeapi-1.0.0/README.md +108 -0
- gradescopeapi-1.0.0/pyproject.toml +60 -0
- gradescopeapi-1.0.0/src/gradescopeapi/__init__.py +1 -0
- gradescopeapi-1.0.0/src/gradescopeapi/__main__.py +6 -0
- gradescopeapi-1.0.0/src/gradescopeapi/_config/__init__.py +0 -0
- gradescopeapi-1.0.0/src/gradescopeapi/_config/config.py +65 -0
- gradescopeapi-1.0.0/src/gradescopeapi/api/__init__.py +0 -0
- gradescopeapi-1.0.0/src/gradescopeapi/api/api.py +383 -0
- gradescopeapi-1.0.0/src/gradescopeapi/api/constants.py +5 -0
- gradescopeapi-1.0.0/src/gradescopeapi/classes/__init__.py +0 -0
- gradescopeapi-1.0.0/src/gradescopeapi/classes/_helpers/_assignment_helpers.py +178 -0
- gradescopeapi-1.0.0/src/gradescopeapi/classes/_helpers/_course_helpers.py +189 -0
- gradescopeapi-1.0.0/src/gradescopeapi/classes/_helpers/_login_helpers.py +56 -0
- gradescopeapi-1.0.0/src/gradescopeapi/classes/account.py +241 -0
- gradescopeapi-1.0.0/src/gradescopeapi/classes/assignments.py +85 -0
- gradescopeapi-1.0.0/src/gradescopeapi/classes/connection.py +29 -0
- gradescopeapi-1.0.0/src/gradescopeapi/classes/courses.py +11 -0
- gradescopeapi-1.0.0/src/gradescopeapi/classes/extensions.py +223 -0
- gradescopeapi-1.0.0/src/gradescopeapi/classes/member.py +15 -0
- gradescopeapi-1.0.0/src/gradescopeapi/classes/upload.py +78 -0
- gradescopeapi-1.0.0/tests/__init__.py +0 -0
- gradescopeapi-1.0.0/tests/conftest.py +36 -0
- gradescopeapi-1.0.0/tests/test_connection.py +73 -0
- gradescopeapi-1.0.0/tests/test_courses.py +90 -0
- gradescopeapi-1.0.0/tests/test_edit_assignment.py +43 -0
- gradescopeapi-1.0.0/tests/test_extension.py +114 -0
- gradescopeapi-1.0.0/tests/test_submission.py +70 -0
- gradescopeapi-1.0.0/tests/test_upload.py +92 -0
- gradescopeapi-1.0.0/tests/upload_files/markdown_file.md +1 -0
- gradescopeapi-1.0.0/tests/upload_files/python_file.py +1 -0
- gradescopeapi-1.0.0/tests/upload_files/text_file.txt +1 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 gradescope-api
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: gradescopeapi
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Library for programmatically interacting with Gradescope.
|
|
5
|
+
Author: Berry Liu, Calvin Tian, Kevin Zheng, Margaret Jagger, Susmitha Kusuma
|
|
6
|
+
Maintainer: Calvin Tian
|
|
7
|
+
License: MIT
|
|
8
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
9
|
+
Project-URL: Homepage, https://github.com/nyuoss/gradescope-api
|
|
10
|
+
Project-URL: Issues, https://github.com/nyuoss/gradescope-api/issues
|
|
11
|
+
Project-URL: Repository, https://github.com/nyuoss/gradescope-api
|
|
12
|
+
Requires-Python: >=3.12
|
|
13
|
+
Requires-Dist: beautifulsoup4>=4.12.3
|
|
14
|
+
Requires-Dist: fastapi>=0.111.0
|
|
15
|
+
Requires-Dist: pytest>=8.2.0
|
|
16
|
+
Requires-Dist: python-dotenv>=1.0.1
|
|
17
|
+
Requires-Dist: requests-toolbelt>=1.0.0
|
|
18
|
+
Requires-Dist: requests>=2.31.0
|
|
19
|
+
Description-Content-Type: text/markdown
|
|
20
|
+
|
|
21
|
+
# Gradescope API
|
|
22
|
+
|
|
23
|
+
## Description
|
|
24
|
+
|
|
25
|
+
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.
|
|
26
|
+
|
|
27
|
+
For example:
|
|
28
|
+
|
|
29
|
+
* Students using this project could automatically query information about their courses and assignments to notify them of upcoming deadlines or new assignments.
|
|
30
|
+
* Instructors could use this project bulk edit assignment due dates or sync student extensions with an external system.
|
|
31
|
+
|
|
32
|
+
## Features
|
|
33
|
+
|
|
34
|
+
Implemented Features Include:
|
|
35
|
+
|
|
36
|
+
* Get all courses for a user
|
|
37
|
+
* Get a list of all assignments for a course
|
|
38
|
+
* Get all extensions for an assignment in a course
|
|
39
|
+
* Add/remove/modify extensions for an assignment in a course
|
|
40
|
+
* Add/remove/modify dates for an assignment in a course
|
|
41
|
+
* Upload submissions to assignments
|
|
42
|
+
* API server to interact with library without Python
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
## Demo
|
|
46
|
+
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)
|
|
47
|
+
|
|
48
|
+
Note that we only demo interacting with the API server, you can alternatively use the Python library directly.
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
## Setup
|
|
52
|
+
|
|
53
|
+
To use the project you can install the package from PyPI using pip:
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
pip install gradescopeapi
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
For additional methods of installation, refer to the [install guide](docs/INSTALL.md)
|
|
60
|
+
|
|
61
|
+
## Usage
|
|
62
|
+
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.
|
|
63
|
+
|
|
64
|
+
### Option 1: FastAPI
|
|
65
|
+
|
|
66
|
+
If you do not want to use Python, you can host the API using the integrated FastAPI server. This way, you can interact with Gradescope using different languages by sending HTTP requests to the API server.
|
|
67
|
+
|
|
68
|
+
**Running the API Server Locally**
|
|
69
|
+
|
|
70
|
+
To run the API server locally on your machine, open the project repository on your machine that you have cloned/forked, and:
|
|
71
|
+
|
|
72
|
+
1. Navigate to the `src.gradescopeapi.api` directory
|
|
73
|
+
2. Run the command: `uvicorn api:app --reload` to run the server locally
|
|
74
|
+
3. In a web browser, navigate to `localhost:8000/docs`, to see the auto-generated FastAPI docs
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
### Option 2: Python
|
|
78
|
+
Alternatively, you can use Python to use the library directly. We have provided some sample scripts of common tasks one might do:
|
|
79
|
+
|
|
80
|
+
```python
|
|
81
|
+
from gradescopeapi.classes.connection import GSConnection
|
|
82
|
+
|
|
83
|
+
# create connection and login
|
|
84
|
+
connection = GSConnection()
|
|
85
|
+
connection.login("email@domain.com", "password")
|
|
86
|
+
|
|
87
|
+
"""
|
|
88
|
+
Fetching all courses for user
|
|
89
|
+
"""
|
|
90
|
+
courses = connection.account.get_courses()
|
|
91
|
+
for course in courses["instructor"]:
|
|
92
|
+
print(course)
|
|
93
|
+
for course in courses["student"]:
|
|
94
|
+
print(course)
|
|
95
|
+
|
|
96
|
+
"""
|
|
97
|
+
Getting roster for a course
|
|
98
|
+
"""
|
|
99
|
+
course_id = "123456"
|
|
100
|
+
members = connection.account.get_course_users(course_id)
|
|
101
|
+
for member in members:
|
|
102
|
+
print(member)
|
|
103
|
+
|
|
104
|
+
"""
|
|
105
|
+
Getting all assignments for course
|
|
106
|
+
"""
|
|
107
|
+
assignments = connection.account.get_assignments(course_id)
|
|
108
|
+
for assignment in assignments:
|
|
109
|
+
print(assignment)
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
For more examples of features not covered here such as changing extensions, uploading files, etc., please refer to the [tests](tests/) directory.
|
|
113
|
+
|
|
114
|
+
## Testing
|
|
115
|
+
|
|
116
|
+
For information on how to run your own tests using ```gradescopeapi```, refer to [TESTING.md](docs/TESTING.md)
|
|
117
|
+
|
|
118
|
+
## Contributing Guidelines
|
|
119
|
+
|
|
120
|
+
Please refer to the [CONTRIBUTING.md](docs/CONTRIBUTING.md) file for more information on how to contribute to the project.
|
|
121
|
+
|
|
122
|
+
## Authors
|
|
123
|
+
|
|
124
|
+
- Susmitha Kusuma
|
|
125
|
+
- Berry Liu
|
|
126
|
+
- Margaret Jagger
|
|
127
|
+
- Calvin Tian
|
|
128
|
+
- Kevin Zheng
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
# Gradescope API
|
|
2
|
+
|
|
3
|
+
## Description
|
|
4
|
+
|
|
5
|
+
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.
|
|
6
|
+
|
|
7
|
+
For example:
|
|
8
|
+
|
|
9
|
+
* Students using this project could automatically query information about their courses and assignments to notify them of upcoming deadlines or new assignments.
|
|
10
|
+
* Instructors could use this project bulk edit assignment due dates or sync student extensions with an external system.
|
|
11
|
+
|
|
12
|
+
## Features
|
|
13
|
+
|
|
14
|
+
Implemented Features Include:
|
|
15
|
+
|
|
16
|
+
* Get all courses for a user
|
|
17
|
+
* Get a list of all assignments for a course
|
|
18
|
+
* Get all extensions for an assignment in a course
|
|
19
|
+
* Add/remove/modify extensions for an assignment in a course
|
|
20
|
+
* Add/remove/modify dates for an assignment in a course
|
|
21
|
+
* Upload submissions to assignments
|
|
22
|
+
* API server to interact with library without Python
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
## Demo
|
|
26
|
+
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)
|
|
27
|
+
|
|
28
|
+
Note that we only demo interacting with the API server, you can alternatively use the Python library directly.
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
## Setup
|
|
32
|
+
|
|
33
|
+
To use the project you can install the package from PyPI using pip:
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
pip install gradescopeapi
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
For additional methods of installation, refer to the [install guide](docs/INSTALL.md)
|
|
40
|
+
|
|
41
|
+
## Usage
|
|
42
|
+
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.
|
|
43
|
+
|
|
44
|
+
### Option 1: FastAPI
|
|
45
|
+
|
|
46
|
+
If you do not want to use Python, you can host the API using the integrated FastAPI server. This way, you can interact with Gradescope using different languages by sending HTTP requests to the API server.
|
|
47
|
+
|
|
48
|
+
**Running the API Server Locally**
|
|
49
|
+
|
|
50
|
+
To run the API server locally on your machine, open the project repository on your machine that you have cloned/forked, and:
|
|
51
|
+
|
|
52
|
+
1. Navigate to the `src.gradescopeapi.api` directory
|
|
53
|
+
2. Run the command: `uvicorn api:app --reload` to run the server locally
|
|
54
|
+
3. In a web browser, navigate to `localhost:8000/docs`, to see the auto-generated FastAPI docs
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
### Option 2: Python
|
|
58
|
+
Alternatively, you can use Python to use the library directly. We have provided some sample scripts of common tasks one might do:
|
|
59
|
+
|
|
60
|
+
```python
|
|
61
|
+
from gradescopeapi.classes.connection import GSConnection
|
|
62
|
+
|
|
63
|
+
# create connection and login
|
|
64
|
+
connection = GSConnection()
|
|
65
|
+
connection.login("email@domain.com", "password")
|
|
66
|
+
|
|
67
|
+
"""
|
|
68
|
+
Fetching all courses for user
|
|
69
|
+
"""
|
|
70
|
+
courses = connection.account.get_courses()
|
|
71
|
+
for course in courses["instructor"]:
|
|
72
|
+
print(course)
|
|
73
|
+
for course in courses["student"]:
|
|
74
|
+
print(course)
|
|
75
|
+
|
|
76
|
+
"""
|
|
77
|
+
Getting roster for a course
|
|
78
|
+
"""
|
|
79
|
+
course_id = "123456"
|
|
80
|
+
members = connection.account.get_course_users(course_id)
|
|
81
|
+
for member in members:
|
|
82
|
+
print(member)
|
|
83
|
+
|
|
84
|
+
"""
|
|
85
|
+
Getting all assignments for course
|
|
86
|
+
"""
|
|
87
|
+
assignments = connection.account.get_assignments(course_id)
|
|
88
|
+
for assignment in assignments:
|
|
89
|
+
print(assignment)
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
For more examples of features not covered here such as changing extensions, uploading files, etc., please refer to the [tests](tests/) directory.
|
|
93
|
+
|
|
94
|
+
## Testing
|
|
95
|
+
|
|
96
|
+
For information on how to run your own tests using ```gradescopeapi```, refer to [TESTING.md](docs/TESTING.md)
|
|
97
|
+
|
|
98
|
+
## Contributing Guidelines
|
|
99
|
+
|
|
100
|
+
Please refer to the [CONTRIBUTING.md](docs/CONTRIBUTING.md) file for more information on how to contribute to the project.
|
|
101
|
+
|
|
102
|
+
## Authors
|
|
103
|
+
|
|
104
|
+
- Susmitha Kusuma
|
|
105
|
+
- Berry Liu
|
|
106
|
+
- Margaret Jagger
|
|
107
|
+
- Calvin Tian
|
|
108
|
+
- Kevin Zheng
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
build-backend = "pdm.backend"
|
|
3
|
+
requires = [
|
|
4
|
+
"pdm-backend",
|
|
5
|
+
]
|
|
6
|
+
|
|
7
|
+
[project]
|
|
8
|
+
authors = [
|
|
9
|
+
{ name = "Berry Liu" },
|
|
10
|
+
{ name = "Calvin Tian" },
|
|
11
|
+
{ name = "Kevin Zheng" },
|
|
12
|
+
{ name = "Margaret Jagger" },
|
|
13
|
+
{ name = "Susmitha Kusuma" },
|
|
14
|
+
]
|
|
15
|
+
classifiers = [
|
|
16
|
+
"Programming Language :: Python :: 3 :: Only",
|
|
17
|
+
]
|
|
18
|
+
dependencies = [
|
|
19
|
+
"beautifulsoup4>=4.12.3",
|
|
20
|
+
"fastapi>=0.111.0",
|
|
21
|
+
"pytest>=8.2.0",
|
|
22
|
+
"python-dotenv>=1.0.1",
|
|
23
|
+
"requests-toolbelt>=1.0.0",
|
|
24
|
+
"requests>=2.31.0",
|
|
25
|
+
]
|
|
26
|
+
description = "Library for programmatically interacting with Gradescope."
|
|
27
|
+
maintainers = [
|
|
28
|
+
{ name = "Calvin Tian" },
|
|
29
|
+
]
|
|
30
|
+
name = "gradescopeapi"
|
|
31
|
+
readme = "README.md"
|
|
32
|
+
requires-python = ">=3.12"
|
|
33
|
+
version = "1.0.0"
|
|
34
|
+
|
|
35
|
+
[project.license]
|
|
36
|
+
text = "MIT"
|
|
37
|
+
|
|
38
|
+
[project.urls]
|
|
39
|
+
Homepage = "https://github.com/nyuoss/gradescope-api"
|
|
40
|
+
Issues = "https://github.com/nyuoss/gradescope-api/issues"
|
|
41
|
+
Repository = "https://github.com/nyuoss/gradescope-api"
|
|
42
|
+
|
|
43
|
+
[tool.pdm]
|
|
44
|
+
distribution = true
|
|
45
|
+
|
|
46
|
+
[tool.pdm.dev-dependencies]
|
|
47
|
+
dev = [
|
|
48
|
+
"mypy>=1.8.0",
|
|
49
|
+
"pre-commit>=3.7.0",
|
|
50
|
+
"ruff>=0.4.3",
|
|
51
|
+
]
|
|
52
|
+
|
|
53
|
+
[tool.pdm.scripts]
|
|
54
|
+
export = "pdm export -f requirements -o requirements.txt --without-hashes"
|
|
55
|
+
format = "ruff format src tests"
|
|
56
|
+
format-test = "ruff format --check src tests"
|
|
57
|
+
lint = "ruff check src tests"
|
|
58
|
+
lint-fix = "ruff check --fix src tests"
|
|
59
|
+
start = "python -m gradescopeapi"
|
|
60
|
+
test = "pytest tests"
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# empty on purpose
|
|
File without changes
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"""config.py
|
|
2
|
+
Configuration file for FastAPI. Specifies the specific objects and data models used in our api
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
from datetime import datetime
|
|
6
|
+
import io
|
|
7
|
+
from typing import List, Dict, Optional
|
|
8
|
+
from pydantic import BaseModel
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class UserSession(BaseModel):
|
|
12
|
+
user_email: str
|
|
13
|
+
session_token: str
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class LoginRequestModel(BaseModel):
|
|
17
|
+
email: str
|
|
18
|
+
password: str
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
class CourseID(BaseModel):
|
|
22
|
+
course_id: str
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
class AssignmentID(BaseModel):
|
|
26
|
+
course_id: str
|
|
27
|
+
assignment_id: str
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
class StudentSubmission(BaseModel):
|
|
31
|
+
student_email: str
|
|
32
|
+
course_id: str
|
|
33
|
+
assignment_id: str
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
class ExtensionData(BaseModel):
|
|
37
|
+
course_id: str
|
|
38
|
+
assignment_id: str
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
class UpdateExtensionData(BaseModel):
|
|
42
|
+
course_id: str
|
|
43
|
+
assignment_id: str
|
|
44
|
+
user_id: str
|
|
45
|
+
release_date: Optional[datetime] = None
|
|
46
|
+
due_date: Optional[datetime] = None
|
|
47
|
+
late_due_date: Optional[datetime] = None
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
class AssignmentDates(BaseModel):
|
|
51
|
+
course_id: str
|
|
52
|
+
assignment_id: str
|
|
53
|
+
release_date: Optional[datetime] = None
|
|
54
|
+
due_date: Optional[datetime] = None
|
|
55
|
+
late_due_date: Optional[datetime] = None
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
class FileUploadModel(BaseModel, arbitrary_types_allowed=True):
|
|
59
|
+
file: io.TextIOWrapper
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
class AssignmentUpload(BaseModel):
|
|
63
|
+
course_id: str
|
|
64
|
+
assignment_id: str
|
|
65
|
+
leaderboard_name: Optional[str] = None
|
|
File without changes
|