From eb7a0b833540a882fef98b4563a12a8c1eee535c Mon Sep 17 00:00:00 2001 From: Jordan Marshall Date: Wed, 11 Dec 2019 14:02:14 -0700 Subject: [PATCH] [Student][R-6.6.4] Don't show grade if submission is graded, unsubmitted, and muted/hidden (#432) --- .../ui/gradeCell/GradeCellViewState.kt | 6 ++--- .../assignment/details/GradeCellStateTest.kt | 26 +++++++++++++++++++ 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/apps/student/src/main/java/com/instructure/student/mobius/assignmentDetails/ui/gradeCell/GradeCellViewState.kt b/apps/student/src/main/java/com/instructure/student/mobius/assignmentDetails/ui/gradeCell/GradeCellViewState.kt index 076741c75c..37df043887 100644 --- a/apps/student/src/main/java/com/instructure/student/mobius/assignmentDetails/ui/gradeCell/GradeCellViewState.kt +++ b/apps/student/src/main/java/com/instructure/student/mobius/assignmentDetails/ui/gradeCell/GradeCellViewState.kt @@ -57,10 +57,8 @@ sealed class GradeCellViewState { assignment: Assignment, submission: Submission? ): GradeCellViewState { - // Return empty state for missing/null submission, unsubmitted workflow state, or "Not Graded" grading type - if (submission?.workflowState == null - || submission.workflowState == "unsubmitted" - || assignment.gradingType == Assignment.NOT_GRADED_TYPE) { + // Return empty state if unsubmitted and ungraded, or "Not Graded" grading type + if ((submission?.submittedAt == null && submission?.isGraded != true) || assignment.gradingType == Assignment.NOT_GRADED_TYPE) { return Empty } diff --git a/apps/student/src/test/java/com/instructure/student/test/assignment/details/GradeCellStateTest.kt b/apps/student/src/test/java/com/instructure/student/test/assignment/details/GradeCellStateTest.kt index 54bc127c64..9d207aaff6 100644 --- a/apps/student/src/test/java/com/instructure/student/test/assignment/details/GradeCellStateTest.kt +++ b/apps/student/src/test/java/com/instructure/student/test/assignment/details/GradeCellStateTest.kt @@ -81,6 +81,32 @@ class GradeCellStateTest : Assert() { assertEquals(expected, actual) } + @Test + fun `Returns Graded state if graded but not submitted`() { + val submission = baseSubmission.copy(submittedAt = null) + val expected = baseGradedState.copy( + graphPercent = 0.85f, + score = "85", + showPointsLabel = true + ) + val actual = GradeCellViewState.fromSubmission(context, baseAssignment, submission) + assertEquals(expected, actual) + } + + @Test + fun `Returns Empty state if graded, not submitted, and grade is hidden`() { + val submission = baseSubmission.copy( + submittedAt = null, + enteredGrade = null, + enteredScore = 0.0, + grade = null, + score = 0.0 + ) + val expected = GradeCellViewState.Empty + val actual = GradeCellViewState.fromSubmission(context, baseAssignment, submission) + assertEquals(expected, actual) + } + @Test fun `Returns Submitted state if submitted but not graded`() { val submission = Submission(