Skip to content

Commit

Permalink
[Student][MBL-13026][R-6.6.0] Fix missing label for LTI assignments (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
CalvinKern authored Aug 7, 2019
1 parent 2bea932 commit 5462a8f
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,12 @@ object AssignmentDetailsPresenter : Presenter<AssignmentDetailsModel, Assignment
R.drawable.vd_submitted
)
} else {
if (assignment.submission?.missing == true ||
(assignment.dueAt != null && assignmentState == AssignmentUtils2.ASSIGNMENT_STATE_MISSING)) {
// Don't mark LTI assignments as missing when overdue as they usually won't have a real submission for it
val isMissingFromDueDate = assignment.turnInType != Assignment.TurnInType.EXTERNAL_TOOL
&& assignment.dueAt != null
&& assignmentState == AssignmentUtils2.ASSIGNMENT_STATE_MISSING

if (assignment.submission?.missing == true || isMissingFromDueDate) {
// Mark it missing if the teacher marked it missing or if it's past due
Triple(R.string.missingSubmissionLabel, R.color.submissionStatusColorMissing, R.drawable.vd_unsubmitted)
} else {
Expand Down Expand Up @@ -165,8 +169,7 @@ object AssignmentDetailsPresenter : Presenter<AssignmentDetailsModel, Assignment
.map { Assignment.submissionTypeToPrettyPrintString(it, context) }
.joinToString(", ")

val isExternalToolSubmission = assignment.getSubmissionTypes()
.any { it == Assignment.SubmissionType.EXTERNAL_TOOL || it == Assignment.SubmissionType.BASIC_LTI_LAUNCH }
val isExternalToolSubmission = assignment.turnInType == Assignment.TurnInType.EXTERNAL_TOOL

// File types
visibilities.fileTypes = assignment.allowedExtensions.isNotEmpty() && assignment.getSubmissionTypes().contains(Assignment.SubmissionType.ONLINE_UPLOAD)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,28 @@ class AssignmentDetailsPresenterTest : Assert() {
assertEquals("Missing", state.submittedStateLabel)
}

@Test
fun `Uses correct label text for submitted status when submission is past due for an LTI assignment`() {
val calendar = Calendar.getInstance().apply { set(2000, 0, 31, 23, 59, 0) }

val submission = baseSubmission.copy(attempt = 0, workflowState = "unsubmitted")
val assignment = baseAssignment.copy(submission = submission, dueAt = calendar.time.toApiString(), submissionTypesRaw = listOf("basic_lti_launch"))
val model = baseModel.copy(assignmentResult = DataResult.Success(assignment))
val state = AssignmentDetailsPresenter.present(model, context) as AssignmentDetailsViewState.Loaded
assertEquals("Not Submitted", state.submittedStateLabel)
}

@Test
fun `Uses correct label text for submitted status when submission is past due for an external assignment`() {
val calendar = Calendar.getInstance().apply { set(2000, 0, 31, 23, 59, 0) }

val submission = baseSubmission.copy(attempt = 0, workflowState = "unsubmitted")
val assignment = baseAssignment.copy(submission = submission, dueAt = calendar.time.toApiString(), submissionTypesRaw = listOf("external_tool"))
val model = baseModel.copy(assignmentResult = DataResult.Success(assignment))
val state = AssignmentDetailsPresenter.present(model, context) as AssignmentDetailsViewState.Loaded
assertEquals("Not Submitted", state.submittedStateLabel)
}

@Test
fun `Uses correct label text for submitted status when submission is null`() {
val assignment = baseAssignment.copy(submission = null, dueAt = null)
Expand Down

0 comments on commit 5462a8f

Please sign in to comment.