Skip to content

Commit bb54282

Browse files
authored
Chore: update openapi schema (#74)
* chore: Regenerate the API models * chore[FE]: Use enums for submission statuses in the code * fix: Improve the error message when restoring a submission
1 parent f4ed5b1 commit bb54282

File tree

16 files changed

+305
-120
lines changed

16 files changed

+305
-120
lines changed
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
from datetime import date, datetime # noqa: F401
2+
3+
from typing import List, Dict # noqa: F401
4+
5+
from grader_labextension.api.models.base_model import Model
6+
from grader_labextension.api import util
7+
8+
9+
class AutoStatus(Model):
10+
"""NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
11+
12+
Do not edit the class manually.
13+
"""
14+
15+
"""
16+
allowed enum values
17+
"""
18+
NOT_GRADED = 'not_graded'
19+
PENDING = 'pending'
20+
AUTOMATICALLY_GRADED = 'automatically_graded'
21+
GRADING_FAILED = 'grading_failed'
22+
def __init__(self): # noqa: E501
23+
"""AutoStatus - a model defined in OpenAPI
24+
25+
"""
26+
self.openapi_types = {
27+
}
28+
29+
self.attribute_map = {
30+
}
31+
32+
@classmethod
33+
def from_dict(cls, dikt) -> 'AutoStatus':
34+
"""Returns the dict as a model
35+
36+
:param dikt: A dict.
37+
:type: dict
38+
:return: The AutoStatus of this AutoStatus. # noqa: E501
39+
:rtype: AutoStatus
40+
"""
41+
return util.deserialize_model(dikt, cls)
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
from datetime import date, datetime # noqa: F401
2+
3+
from typing import List, Dict # noqa: F401
4+
5+
from grader_labextension.api.models.base_model import Model
6+
from grader_labextension.api import util
7+
8+
9+
class FeedbackStatus(Model):
10+
"""NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
11+
12+
Do not edit the class manually.
13+
"""
14+
15+
"""
16+
allowed enum values
17+
"""
18+
NOT_GENERATED = 'not_generated'
19+
GENERATING = 'generating'
20+
GENERATED = 'generated'
21+
GENERATION_FAILED = 'generation_failed'
22+
FEEDBACK_OUTDATED = 'feedback_outdated'
23+
def __init__(self): # noqa: E501
24+
"""FeedbackStatus - a model defined in OpenAPI
25+
26+
"""
27+
self.openapi_types = {
28+
}
29+
30+
self.attribute_map = {
31+
}
32+
33+
@classmethod
34+
def from_dict(cls, dikt) -> 'FeedbackStatus':
35+
"""Returns the dict as a model
36+
37+
:param dikt: A dict.
38+
:type: dict
39+
:return: The FeedbackStatus of this FeedbackStatus. # noqa: E501
40+
:rtype: FeedbackStatus
41+
"""
42+
return util.deserialize_model(dikt, cls)
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
from datetime import date, datetime # noqa: F401
2+
3+
from typing import List, Dict # noqa: F401
4+
5+
from grader_labextension.api.models.base_model import Model
6+
from grader_labextension.api import util
7+
8+
9+
class ManualStatus(Model):
10+
"""NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
11+
12+
Do not edit the class manually.
13+
"""
14+
15+
"""
16+
allowed enum values
17+
"""
18+
NOT_GRADED = 'not_graded'
19+
MANUALLY_GRADED = 'manually_graded'
20+
BEING_EDITED = 'being_edited'
21+
def __init__(self): # noqa: E501
22+
"""ManualStatus - a model defined in OpenAPI
23+
24+
"""
25+
self.openapi_types = {
26+
}
27+
28+
self.attribute_map = {
29+
}
30+
31+
@classmethod
32+
def from_dict(cls, dikt) -> 'ManualStatus':
33+
"""Returns the dict as a model
34+
35+
:param dikt: A dict.
36+
:type: dict
37+
:return: The ManualStatus of this ManualStatus. # noqa: E501
38+
:rtype: ManualStatus
39+
"""
40+
return util.deserialize_model(dikt, cls)

grader_labextension/api/models/submission.py

Lines changed: 68 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,43 @@
55
from grader_labextension.api.models.base_model import Model
66
from grader_labextension.api import util
77

8+
from grader_labextension.api.models.auto_status import AutoStatus # noqa: E501
9+
from grader_labextension.api.models.feedback_status import FeedbackStatus # noqa: E501
10+
from grader_labextension.api.models.manual_status import ManualStatus # noqa: E501
11+
812

913
class Submission(Model):
1014
"""NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
1115
1216
Do not edit the class manually.
1317
"""
1418

15-
def __init__(self, id=None, submitted_at=None, auto_status=None, manual_status=None, username=None, user_display_name=None, grading_score=None, score_scaling=None, score=None, assignid=None, commit_hash=None, feedback_status=None, edited=None): # noqa: E501
19+
def __init__(
20+
self,
21+
id=None,
22+
submitted_at=None,
23+
auto_status=None,
24+
manual_status=None,
25+
username=None,
26+
user_display_name=None,
27+
grading_score=None,
28+
score_scaling=None,
29+
score=None,
30+
assignid=None,
31+
commit_hash=None,
32+
feedback_status=None,
33+
edited=None,
34+
): # noqa: E501
1635
"""Submission - a model defined in OpenAPI
1736
1837
:param id: The id of this Submission. # noqa: E501
1938
:type id: int
2039
:param submitted_at: The submitted_at of this Submission. # noqa: E501
2140
:type submitted_at: datetime
2241
:param auto_status: The auto_status of this Submission. # noqa: E501
23-
:type auto_status: str
42+
:type auto_status: AutoStatus
2443
:param manual_status: The manual_status of this Submission. # noqa: E501
25-
:type manual_status: str
44+
:type manual_status: ManualStatus
2645
:param username: The username of this Submission. # noqa: E501
2746
:type username: str
2847
:param user_display_name: The user_display_name of this Submission. # noqa: E501
@@ -38,40 +57,40 @@ def __init__(self, id=None, submitted_at=None, auto_status=None, manual_status=N
3857
:param commit_hash: The commit_hash of this Submission. # noqa: E501
3958
:type commit_hash: str
4059
:param feedback_status: The feedback_status of this Submission. # noqa: E501
41-
:type feedback_status: str
60+
:type feedback_status: FeedbackStatus
4261
:param edited: The edited of this Submission. # noqa: E501
4362
:type edited: bool
4463
"""
4564
self.openapi_types = {
46-
'id': int,
47-
'submitted_at': datetime,
48-
'auto_status': str,
49-
'manual_status': str,
50-
'username': str,
51-
'user_display_name': str,
52-
'grading_score': float,
53-
'score_scaling': float,
54-
'score': float,
55-
'assignid': int,
56-
'commit_hash': str,
57-
'feedback_status': str,
58-
'edited': bool
65+
"id": int,
66+
"submitted_at": datetime,
67+
"auto_status": AutoStatus,
68+
"manual_status": ManualStatus,
69+
"username": str,
70+
"user_display_name": str,
71+
"grading_score": float,
72+
"score_scaling": float,
73+
"score": float,
74+
"assignid": int,
75+
"commit_hash": str,
76+
"feedback_status": FeedbackStatus,
77+
"edited": bool,
5978
}
6079

6180
self.attribute_map = {
62-
'id': 'id',
63-
'submitted_at': 'submitted_at',
64-
'auto_status': 'auto_status',
65-
'manual_status': 'manual_status',
66-
'username': 'username',
67-
'user_display_name': 'user_display_name',
68-
'grading_score': 'grading_score',
69-
'score_scaling': 'score_scaling',
70-
'score': 'score',
71-
'assignid': 'assignid',
72-
'commit_hash': 'commit_hash',
73-
'feedback_status': 'feedback_status',
74-
'edited': 'edited'
81+
"id": "id",
82+
"submitted_at": "submitted_at",
83+
"auto_status": "auto_status",
84+
"manual_status": "manual_status",
85+
"username": "username",
86+
"user_display_name": "user_display_name",
87+
"grading_score": "grading_score",
88+
"score_scaling": "score_scaling",
89+
"score": "score",
90+
"assignid": "assignid",
91+
"commit_hash": "commit_hash",
92+
"feedback_status": "feedback_status",
93+
"edited": "edited",
7594
}
7695

7796
self._id = id
@@ -89,7 +108,7 @@ def __init__(self, id=None, submitted_at=None, auto_status=None, manual_status=N
89108
self._edited = edited
90109

91110
@classmethod
92-
def from_dict(cls, dikt) -> 'Submission':
111+
def from_dict(cls, dikt) -> "Submission":
93112
"""Returns the dict as a model
94113
95114
:param dikt: A dict.
@@ -142,56 +161,44 @@ def submitted_at(self, submitted_at: datetime):
142161
self._submitted_at = submitted_at
143162

144163
@property
145-
def auto_status(self) -> str:
164+
def auto_status(self) -> AutoStatus:
146165
"""Gets the auto_status of this Submission.
147166
148167
149168
:return: The auto_status of this Submission.
150-
:rtype: str
169+
:rtype: AutoStatus
151170
"""
152171
return self._auto_status
153172

154173
@auto_status.setter
155-
def auto_status(self, auto_status: str):
174+
def auto_status(self, auto_status: AutoStatus):
156175
"""Sets the auto_status of this Submission.
157176
158177
159178
:param auto_status: The auto_status of this Submission.
160-
:type auto_status: str
179+
:type auto_status: AutoStatus
161180
"""
162-
allowed_values = ["not_graded", "pending", "automatically_graded", "grading_failed"] # noqa: E501
163-
if auto_status not in allowed_values:
164-
raise ValueError(
165-
"Invalid value for `auto_status` ({0}), must be one of {1}"
166-
.format(auto_status, allowed_values)
167-
)
168181

169182
self._auto_status = auto_status
170183

171184
@property
172-
def manual_status(self) -> str:
185+
def manual_status(self) -> ManualStatus:
173186
"""Gets the manual_status of this Submission.
174187
175188
176189
:return: The manual_status of this Submission.
177-
:rtype: str
190+
:rtype: ManualStatus
178191
"""
179192
return self._manual_status
180193

181194
@manual_status.setter
182-
def manual_status(self, manual_status: str):
195+
def manual_status(self, manual_status: ManualStatus):
183196
"""Sets the manual_status of this Submission.
184197
185198
186199
:param manual_status: The manual_status of this Submission.
187-
:type manual_status: str
200+
:type manual_status: ManualStatus
188201
"""
189-
allowed_values = ["not_graded", "manually_graded", "being_edited", "grading_failed"] # noqa: E501
190-
if manual_status not in allowed_values:
191-
raise ValueError(
192-
"Invalid value for `manual_status` ({0}), must be one of {1}"
193-
.format(manual_status, allowed_values)
194-
)
195202

196203
self._manual_status = manual_status
197204

@@ -277,9 +284,13 @@ def score_scaling(self, score_scaling: float):
277284
:type score_scaling: float
278285
"""
279286
if score_scaling is not None and score_scaling > 1.0: # noqa: E501
280-
raise ValueError("Invalid value for `score_scaling`, must be a value less than or equal to `1.0`") # noqa: E501
287+
raise ValueError(
288+
"Invalid value for `score_scaling`, must be a value less than or equal to `1.0`"
289+
) # noqa: E501
281290
if score_scaling is not None and score_scaling < 0.0: # noqa: E501
282-
raise ValueError("Invalid value for `score_scaling`, must be a value greater than or equal to `0.0`") # noqa: E501
291+
raise ValueError(
292+
"Invalid value for `score_scaling`, must be a value greater than or equal to `0.0`"
293+
) # noqa: E501
283294

284295
self._score_scaling = score_scaling
285296

@@ -347,29 +358,23 @@ def commit_hash(self, commit_hash: str):
347358
self._commit_hash = commit_hash
348359

349360
@property
350-
def feedback_status(self) -> str:
361+
def feedback_status(self) -> FeedbackStatus:
351362
"""Gets the feedback_status of this Submission.
352363
353364
354365
:return: The feedback_status of this Submission.
355-
:rtype: str
366+
:rtype: FeedbackStatus
356367
"""
357368
return self._feedback_status
358369

359370
@feedback_status.setter
360-
def feedback_status(self, feedback_status: str):
371+
def feedback_status(self, feedback_status: FeedbackStatus):
361372
"""Sets the feedback_status of this Submission.
362373
363374
364375
:param feedback_status: The feedback_status of this Submission.
365-
:type feedback_status: str
376+
:type feedback_status: FeedbackStatus
366377
"""
367-
allowed_values = ["not_generated", "generating", "generated", "generation_failed", "feedback_outdated"] # noqa: E501
368-
if feedback_status not in allowed_values:
369-
raise ValueError(
370-
"Invalid value for `feedback_status` ({0}), must be one of {1}"
371-
.format(feedback_status, allowed_values)
372-
)
373378

374379
self._feedback_status = feedback_status
375380

src/components/assignment/assignment.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,14 @@ import { FilesList } from '../util/file-list';
5555
import { Contents } from '@jupyterlab/services';
5656
import { GlobalObjects } from '../..';
5757
import { RepoType } from '../util/repo-type';
58+
import { FeedbackStatus } from '../../model/feedbackStatus';
5859

5960
const calculateActiveStep = (submissions: Submission[]) => {
6061
const hasFeedback = submissions.reduce(
6162
(accum: boolean, curr: Submission) =>
6263
accum ||
63-
curr.feedback_status === 'generated' ||
64-
curr.feedback_status === 'feedback_outdated',
64+
curr.feedback_status === FeedbackStatus.Generated ||
65+
curr.feedback_status === FeedbackStatus.FeedbackOutdated,
6566
false
6667
);
6768
if (hasFeedback) {

0 commit comments

Comments
 (0)