Skip to content

Commit

Permalink
[Student][R-6.6.4] Don't show grade if submission is graded, unsubmit…
Browse files Browse the repository at this point in the history
…ted, and muted/hidden (#432)
  • Loading branch information
JordanMarshall authored Dec 11, 2019
1 parent bac6efe commit eb7a0b8
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit eb7a0b8

Please sign in to comment.