Skip to content

Commit

Permalink
Expose assignment.is_gradable in the dashboard API
Browse files Browse the repository at this point in the history
This will allow  the FE to base the decision to show the "sync grades"
button both on the feature flag (part of the JSConfig dictionary) and
the current assignment's `is_gradable` value.
  • Loading branch information
marcospri committed Nov 25, 2024
1 parent 4d6059c commit ad56a63
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
2 changes: 2 additions & 0 deletions lms/js_config_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ class APIAssignment(TypedDict):
id: int
title: str
created: str
is_gradable: bool

course: NotRequired[APICourse]

sections: NotRequired[list[APISegment]]
Expand Down
3 changes: 3 additions & 0 deletions lms/views/dashboard/api/assignment.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ def assignments(self) -> APIAssignments:
id=assignment.id,
title=assignment.title,
created=assignment.created,
is_gradable=assignment.is_gradable,
)
for assignment in assignments
],
Expand All @@ -106,6 +107,7 @@ def assignment(self) -> APIAssignment:
id=assignment.id,
title=assignment.title,
created=assignment.created,
is_gradable=assignment.is_gradable,
course=APICourse(
id=assignment.course.id,
title=assignment.course.lms_name,
Expand Down Expand Up @@ -189,6 +191,7 @@ def course_assignments_metrics(self) -> APIAssignments:
APIAssignment(
id=assignment.id,
title=assignment.title,
is_gradable=assignment.is_gradable,
created=assignment.created,
course=api_course,
annotation_metrics=metrics,
Expand Down
13 changes: 12 additions & 1 deletion tests/unit/lms/views/dashboard/api/assignment_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,12 @@ def test_get_assignments(
)
assert response == {
"assignments": [
{"id": a.id, "title": a.title, "created": a.created}
{
"id": a.id,
"title": a.title,
"is_gradable": a.is_gradable,
"created": a.created,
}
for a in assignments
],
"pagination": sentinel.pagination,
Expand Down Expand Up @@ -70,6 +75,7 @@ def test_assignment(
assert response == {
"id": assignment.id,
"title": assignment.title,
"is_gradable": assignment.is_gradable,
"created": assignment.created,
"course": {"id": assignment.course.id, "title": assignment.course.lms_name},
}
Expand Down Expand Up @@ -98,6 +104,7 @@ def test_assignment_with_auto_grading(
"id": assignment.id,
"title": assignment.title,
"created": assignment.created,
"is_gradable": assignment.is_gradable,
"course": {"id": assignment.course.id, "title": assignment.course.lms_name},
"groups": [],
"auto_grading_config": {
Expand Down Expand Up @@ -127,6 +134,7 @@ def test_assignment_with_groups(
"id": assignment.id,
"title": assignment.title,
"created": assignment.created,
"is_gradable": assignment.is_gradable,
"course": {"id": assignment.course.id, "title": assignment.course.lms_name},
"groups": [
{"h_authority_provided_id": g.authority_provided_id, "name": g.lms_name}
Expand Down Expand Up @@ -154,6 +162,7 @@ def test_assignment_with_sections(
"id": assignment.id,
"title": assignment.title,
"created": assignment.created,
"is_gradable": assignment.is_gradable,
"course": {"id": assignment.course.id, "title": assignment.course.lms_name},
"sections": [
{"h_authority_provided_id": g.authority_provided_id, "name": g.lms_name}
Expand Down Expand Up @@ -211,6 +220,7 @@ def test_course_assignments(
{
"id": assignment.id,
"title": assignment.title,
"is_gradable": assignment.is_gradable,
"created": assignment.created,
"course": {
"id": course.id,
Expand All @@ -225,6 +235,7 @@ def test_course_assignments(
{
"id": assignment_with_no_annos.id,
"title": assignment_with_no_annos.title,
"is_gradable": assignment.is_gradable,
"created": assignment_with_no_annos.created,
"course": {
"id": course.id,
Expand Down

0 comments on commit ad56a63

Please sign in to comment.