From b48e6a3f8462d56bdc1e2dec4abfbfb0a4bdfbe7 Mon Sep 17 00:00:00 2001 From: Kristof Deak <92309696+kdeakinstructure@users.noreply.github.com> Date: Thu, 25 Jan 2024 10:58:58 +0100 Subject: [PATCH] [MBL-16500][Student][Teacher] - Refactor MockCanvas addAssignment method to handle multiple submission types (as a list) (#2311) --- .../AssignmentDetailsInteractionTest.kt | 42 +++++++++- .../AssignmentListInteractionTest.kt | 4 +- .../ui/interaction/BookmarkInteractionTest.kt | 2 +- .../CourseGradesInteractionTest.kt | 2 +- .../interaction/DiscussionsInteractionTest.kt | 6 +- .../ui/interaction/HomeroomInteractionTest.kt | 8 +- .../ImportantDatesInteractionTest.kt | 8 +- .../ui/interaction/ModuleInteractionTest.kt | 14 ++-- .../NotificationInteractionTest.kt | 2 +- .../ui/interaction/PdfInteractionTest.kt | 2 +- .../PickerSubmissionUploadInteractionTest.kt | 2 +- .../ui/interaction/ScheduleInteractionTest.kt | 14 ++-- .../ShareExtensionInteractionTest.kt | 8 +- .../SubmissionDetailsInteractionTest.kt | 8 +- .../ui/interaction/SyllabusInteractionTest.kt | 10 +-- .../ui/interaction/TodoInteractionTest.kt | 10 +-- .../student/ui/pages/AssignmentDetailsPage.kt | 18 +++++ .../teacher/ui/AssigneeListPageTest.kt | 2 +- .../teacher/ui/AssignmentDetailsPageTest.kt | 12 ++- .../teacher/ui/AssignmentDueDatesPageTest.kt | 2 +- .../teacher/ui/AssignmentListPageTest.kt | 2 +- .../ui/AssignmentSubmissionListPageTest.kt | 8 +- .../teacher/ui/CommentLibraryPageTest.kt | 2 +- .../ui/EditAssignmentDetailsPageTest.kt | 4 +- .../teacher/ui/EditSyllabusPageTest.kt | 2 +- .../teacher/ui/SpeedGraderCommentsPageTest.kt | 65 +++++++++------- .../teacher/ui/SpeedGraderFilesPageTest.kt | 8 +- .../teacher/ui/SpeedGraderGradePageTest.kt | 2 +- .../teacher/ui/SpeedGraderPageTest.kt | 67 ++++++++-------- .../teacher/ui/SyllabusPageTest.kt | 9 ++- .../dataseeding/model/SubmissionType.kt | 3 +- .../canvas/espresso/TestMetaData.kt | 2 +- .../canvas/espresso/mockCanvas/MockCanvas.kt | 76 ++++++++++++++----- 33 files changed, 276 insertions(+), 150 deletions(-) diff --git a/apps/student/src/androidTest/java/com/instructure/student/ui/interaction/AssignmentDetailsInteractionTest.kt b/apps/student/src/androidTest/java/com/instructure/student/ui/interaction/AssignmentDetailsInteractionTest.kt index 6854424b64..38edfa87c9 100644 --- a/apps/student/src/androidTest/java/com/instructure/student/ui/interaction/AssignmentDetailsInteractionTest.kt +++ b/apps/student/src/androidTest/java/com/instructure/student/ui/interaction/AssignmentDetailsInteractionTest.kt @@ -28,6 +28,7 @@ import com.instructure.canvas.espresso.mockCanvas.init import com.instructure.canvasapi2.models.Assignment import com.instructure.canvasapi2.models.CourseSettings import com.instructure.canvasapi2.utils.toApiString +import com.instructure.dataseeding.model.SubmissionType import com.instructure.student.ui.utils.StudentTest import com.instructure.student.ui.utils.routeTo import com.instructure.student.ui.utils.tokenLogin @@ -53,7 +54,7 @@ class AssignmentDetailsInteractionTest : StudentTest() { val course = data.courses.values.first() val student = data.students[0] val token = data.tokenFor(student)!! - val assignment = data.addAssignment(courseId = course.id, submissionType = Assignment.SubmissionType.ONLINE_URL) + val assignment = data.addAssignment(courseId = course.id, submissionTypeList = listOf(Assignment.SubmissionType.ONLINE_URL)) data.addSubmissionForAssignment( assignmentId = assignment.id, userId = data.users.values.first().id, @@ -118,7 +119,7 @@ class AssignmentDetailsInteractionTest : StudentTest() { @Test @TestMetaData(Priority.COMMON, FeatureCategory.ASSIGNMENTS, TestCategory.INTERACTION) - fun testDisplayBookmarMenu() { + fun testDisplayBookmarkMenu() { val data = setUpData() goToAssignmentList() val assignmentList = data.assignments @@ -349,6 +350,41 @@ class AssignmentDetailsInteractionTest : StudentTest() { assignmentDetailsPage.assertScoreNotDisplayed() } + @Test + @TestMetaData(Priority.IMPORTANT, FeatureCategory.SUBMISSIONS, TestCategory.INTERACTION, SecondaryFeatureCategory.SUBMISSIONS_MULTIPLE_TYPE) + fun testSubmission_multipleSubmissionType() { + val data = MockCanvas.init( + studentCount = 1, + courseCount = 1 + ) + + val course = data.courses.values.first() + val student = data.students[0] + val token = data.tokenFor(student)!! + val assignment = data.addAssignment(courseId = course.id, submissionTypeList = listOf(Assignment.SubmissionType.ONLINE_TEXT_ENTRY, Assignment.SubmissionType.ONLINE_UPLOAD, Assignment.SubmissionType.MEDIA_RECORDING, Assignment.SubmissionType.DISCUSSION_TOPIC, Assignment.SubmissionType.ONLINE_URL)) + data.addSubmissionForAssignment( + assignmentId = assignment.id, + userId = data.users.values.first().id, + type = Assignment.SubmissionType.ONLINE_URL.apiString + ) + tokenLogin(data.domain, token, student) + routeTo("courses/${course.id}/assignments", data.domain) + assignmentListPage.waitForPage() + + assignmentListPage.clickAssignment(assignment) + assignmentDetailsPage.clickSubmit() + + assignmentDetailsPage.assertSubmissionTypeDisplayed("Text Entry") + assignmentDetailsPage.assertSubmissionTypeDisplayed("Website URL") + assignmentDetailsPage.assertSubmissionTypeDisplayed("File Upload") + assignmentDetailsPage.assertSubmissionTypeDisplayed("Media Recording") + + //Try 1 submission to check if it's possible to submit even when there are multiple submission types available. + assignmentDetailsPage.selectSubmissionType(SubmissionType.ONLINE_URL) + urlSubmissionUploadPage.submitText("https://google.com") + assignmentDetailsPage.assertStatusSubmitted() + } + private fun setUpData(restrictQuantitativeData: Boolean = false): MockCanvas { // Test clicking on the Submission and Rubric button to load the Submission Details Page val data = MockCanvas.init( @@ -401,7 +437,7 @@ class AssignmentDetailsInteractionTest : StudentTest() { val assignment = data.addAssignment( courseId = course.id, - submissionType = Assignment.SubmissionType.ONLINE_TEXT_ENTRY, + submissionTypeList = listOf(Assignment.SubmissionType.ONLINE_TEXT_ENTRY), gradingType = Assignment.gradingTypeToAPIString(gradingType) ?: "", pointsPossible = maxScore, ) diff --git a/apps/student/src/androidTest/java/com/instructure/student/ui/interaction/AssignmentListInteractionTest.kt b/apps/student/src/androidTest/java/com/instructure/student/ui/interaction/AssignmentListInteractionTest.kt index 38fd1537a7..fab2876a38 100644 --- a/apps/student/src/androidTest/java/com/instructure/student/ui/interaction/AssignmentListInteractionTest.kt +++ b/apps/student/src/androidTest/java/com/instructure/student/ui/interaction/AssignmentListInteractionTest.kt @@ -226,7 +226,7 @@ class AssignmentListInteractionTest : StudentTest() { repeat(assignmentCount) { val assignment = data.addAssignment( courseId = course.id, - submissionType = Assignment.SubmissionType.ONLINE_TEXT_ENTRY + submissionTypeList = listOf(Assignment.SubmissionType.ONLINE_TEXT_ENTRY) ) assignmentList.add(assignment) } @@ -254,7 +254,7 @@ class AssignmentListInteractionTest : StudentTest() { val assignment = data.addAssignment( courseId = course.id, - submissionType = Assignment.SubmissionType.ONLINE_TEXT_ENTRY, + submissionTypeList = listOf(Assignment.SubmissionType.ONLINE_TEXT_ENTRY), gradingType = Assignment.gradingTypeToAPIString(gradingType) ?: "", pointsPossible = maxScore, ) diff --git a/apps/student/src/androidTest/java/com/instructure/student/ui/interaction/BookmarkInteractionTest.kt b/apps/student/src/androidTest/java/com/instructure/student/ui/interaction/BookmarkInteractionTest.kt index 78c0a552c3..ec8cac9747 100644 --- a/apps/student/src/androidTest/java/com/instructure/student/ui/interaction/BookmarkInteractionTest.kt +++ b/apps/student/src/androidTest/java/com/instructure/student/ui/interaction/BookmarkInteractionTest.kt @@ -115,7 +115,7 @@ class BookmarkInteractionTest : StudentTest() { val course = data.courses.values.first() val assignment = data.addAssignment( courseId = course.id, - submissionType = Assignment.SubmissionType.ONLINE_TEXT_ENTRY + submissionTypeList = listOf(Assignment.SubmissionType.ONLINE_TEXT_ENTRY) ) val token = data.tokenFor(student)!! diff --git a/apps/student/src/androidTest/java/com/instructure/student/ui/interaction/CourseGradesInteractionTest.kt b/apps/student/src/androidTest/java/com/instructure/student/ui/interaction/CourseGradesInteractionTest.kt index a305f58b66..f989450db0 100644 --- a/apps/student/src/androidTest/java/com/instructure/student/ui/interaction/CourseGradesInteractionTest.kt +++ b/apps/student/src/androidTest/java/com/instructure/student/ui/interaction/CourseGradesInteractionTest.kt @@ -248,7 +248,7 @@ class CourseGradesInteractionTest : StudentTest() { val assignment = data.addAssignment( courseId = course.id, - submissionType = Assignment.SubmissionType.ONLINE_TEXT_ENTRY, + submissionTypeList = listOf(Assignment.SubmissionType.ONLINE_TEXT_ENTRY), gradingType = Assignment.gradingTypeToAPIString(gradingType) ?: "", pointsPossible = maxScore, ) diff --git a/apps/student/src/androidTest/java/com/instructure/student/ui/interaction/DiscussionsInteractionTest.kt b/apps/student/src/androidTest/java/com/instructure/student/ui/interaction/DiscussionsInteractionTest.kt index dcdf27fe50..25310d5be8 100644 --- a/apps/student/src/androidTest/java/com/instructure/student/ui/interaction/DiscussionsInteractionTest.kt +++ b/apps/student/src/androidTest/java/com/instructure/student/ui/interaction/DiscussionsInteractionTest.kt @@ -608,7 +608,7 @@ class DiscussionsInteractionTest : StudentTest() { // Add an assignment val assignment = data.addAssignment( courseId = course.id, - submissionType = Assignment.SubmissionType.ONLINE_TEXT_ENTRY, + submissionTypeList = listOf(Assignment.SubmissionType.ONLINE_TEXT_ENTRY), name = assignmentName, pointsPossible = 12 ) @@ -649,7 +649,7 @@ class DiscussionsInteractionTest : StudentTest() { // Add an assignment val assignment = data.addAssignment( courseId = course.id, - submissionType = Assignment.SubmissionType.ONLINE_TEXT_ENTRY, + submissionTypeList = listOf(Assignment.SubmissionType.ONLINE_TEXT_ENTRY), name = assignmentName, pointsPossible = 12 ) @@ -694,7 +694,7 @@ class DiscussionsInteractionTest : StudentTest() { // Add an assignment val assignment = data.addAssignment( courseId = course.id, - submissionType = Assignment.SubmissionType.ONLINE_TEXT_ENTRY, + submissionTypeList = listOf(Assignment.SubmissionType.ONLINE_TEXT_ENTRY), name = assignmentName, pointsPossible = 12 ) diff --git a/apps/student/src/androidTest/java/com/instructure/student/ui/interaction/HomeroomInteractionTest.kt b/apps/student/src/androidTest/java/com/instructure/student/ui/interaction/HomeroomInteractionTest.kt index a139f5d4c9..fa08c724fc 100644 --- a/apps/student/src/androidTest/java/com/instructure/student/ui/interaction/HomeroomInteractionTest.kt +++ b/apps/student/src/androidTest/java/com/instructure/student/ui/interaction/HomeroomInteractionTest.kt @@ -234,8 +234,8 @@ class HomeroomInteractionTest : StudentTest() { val courses = data.courses.values.filter { !it.homeroomCourse } - data.addAssignment(courses[0].id, submissionType = Assignment.SubmissionType.ONLINE_TEXT_ENTRY) - data.addAssignment(courses[0].id, submissionType = Assignment.SubmissionType.ONLINE_TEXT_ENTRY) + data.addAssignment(courses[0].id, submissionTypeList = listOf(Assignment.SubmissionType.ONLINE_TEXT_ENTRY)) + data.addAssignment(courses[0].id, submissionTypeList = listOf(Assignment.SubmissionType.ONLINE_TEXT_ENTRY)) goToHomeroomTab(data) @@ -259,8 +259,8 @@ class HomeroomInteractionTest : StudentTest() { val courses = data.courses.values.filter { !it.homeroomCourse } - val assignment1 = data.addAssignment(courses[0].id, submissionType = Assignment.SubmissionType.ONLINE_TEXT_ENTRY) - data.addAssignment(courses[0].id, submissionType = Assignment.SubmissionType.ONLINE_TEXT_ENTRY) + val assignment1 = data.addAssignment(courses[0].id, submissionTypeList = listOf(Assignment.SubmissionType.ONLINE_TEXT_ENTRY)) + data.addAssignment(courses[0].id, submissionTypeList = listOf(Assignment.SubmissionType.ONLINE_TEXT_ENTRY)) goToHomeroomTab(data) diff --git a/apps/student/src/androidTest/java/com/instructure/student/ui/interaction/ImportantDatesInteractionTest.kt b/apps/student/src/androidTest/java/com/instructure/student/ui/interaction/ImportantDatesInteractionTest.kt index 28a43cb393..53b95676a4 100644 --- a/apps/student/src/androidTest/java/com/instructure/student/ui/interaction/ImportantDatesInteractionTest.kt +++ b/apps/student/src/androidTest/java/com/instructure/student/ui/interaction/ImportantDatesInteractionTest.kt @@ -64,7 +64,7 @@ class ImportantDatesInteractionTest : StudentTest() { val data = createMockData(courseCount = 1) val course = data.courses.values.toList()[0] - val assignment = data.addAssignment(courseId = course.id, submissionType = Assignment.SubmissionType.ONLINE_TEXT_ENTRY) + val assignment = data.addAssignment(courseId = course.id, submissionTypeList = listOf(Assignment.SubmissionType.ONLINE_TEXT_ENTRY)) val assignmentScheduleItem = data.addAssignmentCalendarEvent(course.id, 2.days.fromNow.iso8601, assignment.name!!, assignment.description!!, true, assignment) goToImportantDatesTab(data) @@ -132,7 +132,7 @@ class ImportantDatesInteractionTest : StudentTest() { val data = createMockData(courseCount = 1) val course = data.courses.values.toList()[0] - val assignment = data.addAssignment(courseId = course.id, submissionType = Assignment.SubmissionType.ONLINE_TEXT_ENTRY) + val assignment = data.addAssignment(courseId = course.id, submissionTypeList = listOf(Assignment.SubmissionType.ONLINE_TEXT_ENTRY)) val assignmentScheduleItem = data.addAssignmentCalendarEvent(course.id, 2.days.fromNow.iso8601, assignment.name!!, assignment.description!!, true, assignment) goToImportantDatesTab(data) @@ -152,7 +152,7 @@ class ImportantDatesInteractionTest : StudentTest() { val data = createMockData(courseCount = 1) val course = data.courses.values.toList()[0] - val assignment = data.addAssignment(courseId = course.id, submissionType = Assignment.SubmissionType.ONLINE_TEXT_ENTRY) + val assignment = data.addAssignment(courseId = course.id, submissionTypeList = listOf(Assignment.SubmissionType.ONLINE_TEXT_ENTRY)) data.addAssignmentCalendarEvent(course.id, 2.days.fromNow.iso8601, assignment.name!!, assignment.description!!, true, assignment) val calendarEvent = data.addCourseCalendarEvent(course.id, 2.days.fromNow.iso8601, "Important event", "Important event description", true) @@ -176,7 +176,7 @@ class ImportantDatesInteractionTest : StudentTest() { val data = createMockData(courseCount = 1) val course = data.courses.values.toList()[0] - val assignment = data.addAssignment(courseId = course.id, submissionType = Assignment.SubmissionType.ONLINE_TEXT_ENTRY) + val assignment = data.addAssignment(courseId = course.id, submissionTypeList = listOf(Assignment.SubmissionType.ONLINE_TEXT_ENTRY)) val twoDaysFromNowEvent = data.addAssignmentCalendarEvent(course.id, 2.days.fromNow.iso8601, "Important event two days later", "Important event two days later description", true, assignment) val threeDaysFromNowEvent = data.addCourseCalendarEvent(course.id, diff --git a/apps/student/src/androidTest/java/com/instructure/student/ui/interaction/ModuleInteractionTest.kt b/apps/student/src/androidTest/java/com/instructure/student/ui/interaction/ModuleInteractionTest.kt index 2114a83fdc..a4af822a17 100644 --- a/apps/student/src/androidTest/java/com/instructure/student/ui/interaction/ModuleInteractionTest.kt +++ b/apps/student/src/androidTest/java/com/instructure/student/ui/interaction/ModuleInteractionTest.kt @@ -81,7 +81,7 @@ class ModuleInteractionTest : StudentTest() { // Create an assignment and add it as a module item assignment = data.addAssignment( courseId = course1.id, - submissionType = Assignment.SubmissionType.ONLINE_TEXT_ENTRY + submissionTypeList = listOf(Assignment.SubmissionType.ONLINE_TEXT_ENTRY) ) data.addItemToModule( course = course1, @@ -324,7 +324,7 @@ class ModuleInteractionTest : StudentTest() { // Create an assignment and add it as a module item assignment = data.addAssignment( courseId = course1.id, - submissionType = Assignment.SubmissionType.ONLINE_TEXT_ENTRY + submissionTypeList = listOf(Assignment.SubmissionType.ONLINE_TEXT_ENTRY) ) data.addItemToModule( course = course1, @@ -385,7 +385,7 @@ class ModuleInteractionTest : StudentTest() { // Create an assignment and add it as a module item assignment = data.addAssignment( courseId = course1.id, - submissionType = Assignment.SubmissionType.ONLINE_TEXT_ENTRY + submissionTypeList = listOf(Assignment.SubmissionType.ONLINE_TEXT_ENTRY) ) data.addItemToModule( course = course1, @@ -501,7 +501,7 @@ class ModuleInteractionTest : StudentTest() { // And let's add an assignment to the new module var unavailableAssignment = data.addAssignment( courseId = course1.id, - submissionType = Assignment.SubmissionType.ONLINE_TEXT_ENTRY, + submissionTypeList = listOf(Assignment.SubmissionType.ONLINE_TEXT_ENTRY), // Man, this is a bit hokey, but it's what I had to do to get the assignment to show // up as unavailable in the assignment details page lockInfo = LockInfo( @@ -541,7 +541,7 @@ class ModuleInteractionTest : StudentTest() { // And let's create an assignment and add it to the "locked" module. val lockedAssignment = data.addAssignment( courseId = course1.id, - submissionType = Assignment.SubmissionType.ONLINE_TEXT_ENTRY + submissionTypeList = listOf(Assignment.SubmissionType.ONLINE_TEXT_ENTRY) ) data.addItemToModule( course = course1, @@ -568,7 +568,7 @@ class ModuleInteractionTest : StudentTest() { val assignment = data.addAssignment( courseId = course.id, - submissionType = Assignment.SubmissionType.ONLINE_TEXT_ENTRY, + submissionTypeList = listOf(Assignment.SubmissionType.ONLINE_TEXT_ENTRY), pointsPossible = 10 ) @@ -595,7 +595,7 @@ class ModuleInteractionTest : StudentTest() { val assignment = data.addAssignment( courseId = course.id, - submissionType = Assignment.SubmissionType.ONLINE_TEXT_ENTRY, + submissionTypeList = listOf(Assignment.SubmissionType.ONLINE_TEXT_ENTRY), pointsPossible = 10 ) diff --git a/apps/student/src/androidTest/java/com/instructure/student/ui/interaction/NotificationInteractionTest.kt b/apps/student/src/androidTest/java/com/instructure/student/ui/interaction/NotificationInteractionTest.kt index f11a079a02..adde4b4802 100644 --- a/apps/student/src/androidTest/java/com/instructure/student/ui/interaction/NotificationInteractionTest.kt +++ b/apps/student/src/androidTest/java/com/instructure/student/ui/interaction/NotificationInteractionTest.kt @@ -255,7 +255,7 @@ class NotificationInteractionTest : StudentTest() { repeat(numSubmissions) { val assignment = data.addAssignment( courseId = course.id, - submissionType = Assignment.SubmissionType.ONLINE_TEXT_ENTRY, + submissionTypeList = listOf(Assignment.SubmissionType.ONLINE_TEXT_ENTRY), gradingType = Assignment.gradingTypeToAPIString(gradingType).orEmpty(), pointsPossible = 20 ) diff --git a/apps/student/src/androidTest/java/com/instructure/student/ui/interaction/PdfInteractionTest.kt b/apps/student/src/androidTest/java/com/instructure/student/ui/interaction/PdfInteractionTest.kt index 083442ccdd..8c61146e4e 100644 --- a/apps/student/src/androidTest/java/com/instructure/student/ui/interaction/PdfInteractionTest.kt +++ b/apps/student/src/androidTest/java/com/instructure/student/ui/interaction/PdfInteractionTest.kt @@ -153,7 +153,7 @@ class PdfInteractionTest : StudentTest() { val pdfUrlElementId = "testLinkElement" val assignmentDescriptionHtml = """pdf baby!!!""" - val assignment = data.addAssignment(courseId = course.id, submissionType = Assignment.SubmissionType.ONLINE_UPLOAD, description = assignmentDescriptionHtml) + val assignment = data.addAssignment(courseId = course.id, submissionTypeList = listOf(Assignment.SubmissionType.ONLINE_UPLOAD), description = assignmentDescriptionHtml) assignmentListPage.waitForPage() assignmentListPage.refresh() diff --git a/apps/student/src/androidTest/java/com/instructure/student/ui/interaction/PickerSubmissionUploadInteractionTest.kt b/apps/student/src/androidTest/java/com/instructure/student/ui/interaction/PickerSubmissionUploadInteractionTest.kt index 05d7ca62d1..333abfc1da 100644 --- a/apps/student/src/androidTest/java/com/instructure/student/ui/interaction/PickerSubmissionUploadInteractionTest.kt +++ b/apps/student/src/androidTest/java/com/instructure/student/ui/interaction/PickerSubmissionUploadInteractionTest.kt @@ -155,7 +155,7 @@ class PickerSubmissionUploadInteractionTest : StudentTest() { // Let's set up an assignment that requires an online upload val assignment = data.addAssignment( courseId = course.id, - submissionType = Assignment.SubmissionType.ONLINE_UPLOAD + submissionTypeList = listOf(Assignment.SubmissionType.ONLINE_UPLOAD) ) // Sign in diff --git a/apps/student/src/androidTest/java/com/instructure/student/ui/interaction/ScheduleInteractionTest.kt b/apps/student/src/androidTest/java/com/instructure/student/ui/interaction/ScheduleInteractionTest.kt index 58abd6a093..2cfe7c7cbb 100644 --- a/apps/student/src/androidTest/java/com/instructure/student/ui/interaction/ScheduleInteractionTest.kt +++ b/apps/student/src/androidTest/java/com/instructure/student/ui/interaction/ScheduleInteractionTest.kt @@ -83,7 +83,7 @@ class ScheduleInteractionTest : StudentTest() { courses[0].name = "Course 1" val currentDate = dateTimeProvider.getCalendar().time.toApiString() - val assignment1 = data.addAssignment(courses[0].id, submissionType = Assignment.SubmissionType.ONLINE_TEXT_ENTRY, dueAt = currentDate, name = "Assignment 1") + val assignment1 = data.addAssignment(courses[0].id, submissionTypeList = listOf(Assignment.SubmissionType.ONLINE_TEXT_ENTRY), dueAt = currentDate, name = "Assignment 1") goToScheduleTab(data) schedulePage.scrollToPosition(10) @@ -101,7 +101,7 @@ class ScheduleInteractionTest : StudentTest() { val courses = data.courses.values.filter { !it.homeroomCourse } val currentDate = dateTimeProvider.getCalendar().time.toApiString() - val assignment1 = data.addAssignment(courses[0].id, submissionType = Assignment.SubmissionType.ONLINE_TEXT_ENTRY, dueAt = currentDate) + val assignment1 = data.addAssignment(courses[0].id, submissionTypeList = listOf(Assignment.SubmissionType.ONLINE_TEXT_ENTRY), dueAt = currentDate) goToScheduleTab(data) schedulePage.scrollToPosition(12) @@ -140,8 +140,8 @@ class ScheduleInteractionTest : StudentTest() { schedulePage.assertNoScheduleItemDisplayed() val currentDate = dateTimeProvider.getCalendar().time.toApiString() - val assignment1 = data.addAssignment(courses[0].id, submissionType = Assignment.SubmissionType.ONLINE_TEXT_ENTRY, dueAt = currentDate) - val assignment2 = data.addAssignment(courses[0].id, submissionType = Assignment.SubmissionType.ONLINE_TEXT_ENTRY, dueAt = currentDate) + val assignment1 = data.addAssignment(courses[0].id, submissionTypeList = listOf(Assignment.SubmissionType.ONLINE_TEXT_ENTRY), dueAt = currentDate) + val assignment2 = data.addAssignment(courses[0].id, submissionTypeList = listOf(Assignment.SubmissionType.ONLINE_TEXT_ENTRY), dueAt = currentDate) schedulePage.scrollToPosition(0) schedulePage.refresh() @@ -209,7 +209,7 @@ class ScheduleInteractionTest : StudentTest() { courses[0].name = "Course 1" val currentDate = dateTimeProvider.getCalendar().time.toApiString() - val assignment = data.addAssignment(courses[0].id, submissionType = Assignment.SubmissionType.ONLINE_TEXT_ENTRY, dueAt = currentDate, name = "Assignment 1") + val assignment = data.addAssignment(courses[0].id, submissionTypeList = listOf(Assignment.SubmissionType.ONLINE_TEXT_ENTRY), dueAt = currentDate, name = "Assignment 1") goToScheduleTab(data) schedulePage.scrollToPosition(9) @@ -228,7 +228,7 @@ class ScheduleInteractionTest : StudentTest() { val courses = data.courses.values.filter { !it.homeroomCourse } val currentDate = dateTimeProvider.getCalendar().time.toApiString() - data.addAssignment(courses[0].id, submissionType = Assignment.SubmissionType.ONLINE_TEXT_ENTRY, dueAt = currentDate) + data.addAssignment(courses[0].id, submissionTypeList = listOf(Assignment.SubmissionType.ONLINE_TEXT_ENTRY), dueAt = currentDate) goToScheduleTab(data) schedulePage.scrollToPosition(8) @@ -265,7 +265,7 @@ class ScheduleInteractionTest : StudentTest() { courses[0].name = "Course 1" val currentDate = dateTimeProvider.getCalendar().time.toApiString() - val assignment1 = data.addAssignment(courses[0].id, submissionType = Assignment.SubmissionType.ONLINE_TEXT_ENTRY, dueAt = currentDate, name = "Assignment 1") + val assignment1 = data.addAssignment(courses[0].id, submissionTypeList = listOf(Assignment.SubmissionType.ONLINE_TEXT_ENTRY), dueAt = currentDate, name = "Assignment 1") goToScheduleTab(data) diff --git a/apps/student/src/androidTest/java/com/instructure/student/ui/interaction/ShareExtensionInteractionTest.kt b/apps/student/src/androidTest/java/com/instructure/student/ui/interaction/ShareExtensionInteractionTest.kt index f19c657307..13ab1f1da3 100644 --- a/apps/student/src/androidTest/java/com/instructure/student/ui/interaction/ShareExtensionInteractionTest.kt +++ b/apps/student/src/androidTest/java/com/instructure/student/ui/interaction/ShareExtensionInteractionTest.kt @@ -131,7 +131,7 @@ class ShareExtensionInteractionTest : StudentTest() { val uri = setupFileOnDevice("sample.jpg") val device = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation()) - val assignment = data.addAssignment(data.courses.values.first().id, submissionType = Assignment.SubmissionType.ONLINE_UPLOAD) + val assignment = data.addAssignment(data.courses.values.first().id, submissionTypeList = listOf(Assignment.SubmissionType.ONLINE_UPLOAD)) login(student) device.pressHome() @@ -182,8 +182,8 @@ class ShareExtensionInteractionTest : StudentTest() { val uri = setupFileOnDevice("sample.jpg") val device = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation()) - data.addAssignment(data.courses.values.first().id, submissionType = Assignment.SubmissionType.ONLINE_UPLOAD) - val assignment2 = data.addAssignment(data.courses.values.first().id, submissionType = Assignment.SubmissionType.ONLINE_UPLOAD) + data.addAssignment(data.courses.values.first().id, submissionTypeList = listOf(Assignment.SubmissionType.ONLINE_UPLOAD)) + val assignment2 = data.addAssignment(data.courses.values.first().id, submissionTypeList = listOf(Assignment.SubmissionType.ONLINE_UPLOAD)) login(student) device.pressHome() @@ -239,7 +239,7 @@ class ShareExtensionInteractionTest : StudentTest() { val uri = setupFileOnDevice("sample.jpg") val device = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation()) - data.addAssignment(data.courses.values.first().id, submissionType = Assignment.SubmissionType.ONLINE_UPLOAD) + data.addAssignment(data.courses.values.first().id, submissionTypeList = listOf(Assignment.SubmissionType.ONLINE_UPLOAD)) login(student) device.pressHome() diff --git a/apps/student/src/androidTest/java/com/instructure/student/ui/interaction/SubmissionDetailsInteractionTest.kt b/apps/student/src/androidTest/java/com/instructure/student/ui/interaction/SubmissionDetailsInteractionTest.kt index afedd20532..30203de91a 100644 --- a/apps/student/src/androidTest/java/com/instructure/student/ui/interaction/SubmissionDetailsInteractionTest.kt +++ b/apps/student/src/androidTest/java/com/instructure/student/ui/interaction/SubmissionDetailsInteractionTest.kt @@ -57,7 +57,7 @@ class SubmissionDetailsInteractionTest : StudentTest() { val data = getToCourse() val assignment = data.addAssignment( courseId = course.id, - submissionType = Assignment.SubmissionType.ONLINE_TEXT_ENTRY, + submissionTypeList = listOf(Assignment.SubmissionType.ONLINE_TEXT_ENTRY), pointsPossible = 10 ) @@ -102,7 +102,7 @@ class SubmissionDetailsInteractionTest : StudentTest() { val data = getToCourse() val assignment = data.addAssignment( courseId = course.id, - submissionType = Assignment.SubmissionType.ONLINE_URL + submissionTypeList = listOf(Assignment.SubmissionType.ONLINE_URL) ) courseBrowserPage.selectAssignments() @@ -124,7 +124,7 @@ class SubmissionDetailsInteractionTest : StudentTest() { val data = getToCourse() val assignment = data.addAssignment( courseId = course.id, - submissionType = Assignment.SubmissionType.ONLINE_URL, + submissionTypeList = listOf(Assignment.SubmissionType.ONLINE_URL), userSubmitted = true ) @@ -169,7 +169,7 @@ class SubmissionDetailsInteractionTest : StudentTest() { val user = data.users.values.first() val assignment = data.addAssignment( courseId = course.id, - submissionType = Assignment.SubmissionType.ONLINE_TEXT_ENTRY + submissionTypeList = listOf(Assignment.SubmissionType.ONLINE_TEXT_ENTRY) ) // Some html for an attachment diff --git a/apps/student/src/androidTest/java/com/instructure/student/ui/interaction/SyllabusInteractionTest.kt b/apps/student/src/androidTest/java/com/instructure/student/ui/interaction/SyllabusInteractionTest.kt index 7e8f5e321a..8b9b613563 100644 --- a/apps/student/src/androidTest/java/com/instructure/student/ui/interaction/SyllabusInteractionTest.kt +++ b/apps/student/src/androidTest/java/com/instructure/student/ui/interaction/SyllabusInteractionTest.kt @@ -15,6 +15,10 @@ */ package com.instructure.student.ui.interaction +import com.instructure.canvas.espresso.FeatureCategory +import com.instructure.canvas.espresso.Priority +import com.instructure.canvas.espresso.TestCategory +import com.instructure.canvas.espresso.TestMetaData import com.instructure.canvas.espresso.mockCanvas.MockCanvas import com.instructure.canvas.espresso.mockCanvas.addAssignment import com.instructure.canvas.espresso.mockCanvas.addCourseCalendarEvent @@ -26,10 +30,6 @@ import com.instructure.canvasapi2.models.Tab import com.instructure.dataseeding.util.days import com.instructure.dataseeding.util.fromNow import com.instructure.dataseeding.util.iso8601 -import com.instructure.canvas.espresso.FeatureCategory -import com.instructure.canvas.espresso.Priority -import com.instructure.canvas.espresso.TestCategory -import com.instructure.canvas.espresso.TestMetaData import com.instructure.student.ui.utils.StudentTest import com.instructure.student.ui.utils.tokenLogin import dagger.hilt.android.testing.HiltAndroidTest @@ -87,7 +87,7 @@ class SyllabusInteractionTest : StudentTest() { repeat(assignmentCount) { data.addAssignment( courseId = course.id, - submissionType = Assignment.SubmissionType.ONLINE_TEXT_ENTRY, + submissionTypeList = listOf(Assignment.SubmissionType.ONLINE_TEXT_ENTRY), dueAt = 2.days.fromNow.iso8601 ) } diff --git a/apps/student/src/androidTest/java/com/instructure/student/ui/interaction/TodoInteractionTest.kt b/apps/student/src/androidTest/java/com/instructure/student/ui/interaction/TodoInteractionTest.kt index 5b48a14d07..4e0d5abc4a 100644 --- a/apps/student/src/androidTest/java/com/instructure/student/ui/interaction/TodoInteractionTest.kt +++ b/apps/student/src/androidTest/java/com/instructure/student/ui/interaction/TodoInteractionTest.kt @@ -16,8 +16,12 @@ package com.instructure.student.ui.interaction import androidx.test.espresso.Espresso +import com.instructure.canvas.espresso.FeatureCategory +import com.instructure.canvas.espresso.Priority import com.instructure.canvas.espresso.StubLandscape import com.instructure.canvas.espresso.StubMultiAPILevel +import com.instructure.canvas.espresso.TestCategory +import com.instructure.canvas.espresso.TestMetaData import com.instructure.canvas.espresso.mockCanvas.MockCanvas import com.instructure.canvas.espresso.mockCanvas.addAssignment import com.instructure.canvas.espresso.mockCanvas.addQuizToCourse @@ -28,10 +32,6 @@ import com.instructure.canvasapi2.models.Quiz import com.instructure.dataseeding.util.days import com.instructure.dataseeding.util.fromNow import com.instructure.dataseeding.util.iso8601 -import com.instructure.canvas.espresso.FeatureCategory -import com.instructure.canvas.espresso.Priority -import com.instructure.canvas.espresso.TestCategory -import com.instructure.canvas.espresso.TestMetaData import com.instructure.student.ui.utils.StudentTest import com.instructure.student.ui.utils.tokenLogin import dagger.hilt.android.testing.HiltAndroidTest @@ -104,7 +104,7 @@ class TodoInteractionTest : StudentTest() { for(course in data.courses.values) { assignment = data.addAssignment( courseId = course.id, - submissionType = Assignment.SubmissionType.ONLINE_TEXT_ENTRY, + submissionTypeList = listOf(Assignment.SubmissionType.ONLINE_TEXT_ENTRY), dueAt = 1.days.fromNow.iso8601 ) diff --git a/apps/student/src/androidTest/java/com/instructure/student/ui/pages/AssignmentDetailsPage.kt b/apps/student/src/androidTest/java/com/instructure/student/ui/pages/AssignmentDetailsPage.kt index 5164267d7f..5ac189a0f8 100644 --- a/apps/student/src/androidTest/java/com/instructure/student/ui/pages/AssignmentDetailsPage.kt +++ b/apps/student/src/androidTest/java/com/instructure/student/ui/pages/AssignmentDetailsPage.kt @@ -32,6 +32,7 @@ import com.instructure.canvas.espresso.containsTextCaseInsensitive import com.instructure.canvas.espresso.stringContainsTextCaseInsensitive import com.instructure.canvas.espresso.waitForMatcherWithSleeps import com.instructure.canvasapi2.models.Assignment +import com.instructure.dataseeding.model.SubmissionType import com.instructure.espresso.OnViewWithId import com.instructure.espresso.assertContainsText import com.instructure.espresso.assertDisplayed @@ -221,6 +222,23 @@ open class AssignmentDetailsPage : BasePage(R.id.assignmentDetailsPage) { waitForView(allOf(withId(R.id.attemptTitle), withAncestor(withId(R.id.attemptSpinner)))).assertDisplayed() waitForView(allOf(withId(R.id.attemptDate), withAncestor(withId(R.id.attemptSpinner)))).assertDisplayed() } + + fun selectSubmissionType(submissionType: SubmissionType) { + val viewMatcher = when (submissionType) { + SubmissionType.ONLINE_TEXT_ENTRY -> withId(R.id.submissionEntryText) + SubmissionType.ONLINE_UPLOAD -> withId(R.id.submissionEntryFile) + SubmissionType.ONLINE_URL -> withId(R.id.submissionEntryWebsite) + SubmissionType.MEDIA_RECORDING -> withId(R.id.submissionEntryMedia) + + else -> {withId(R.id.submissionEntryText)} + } + + onView(viewMatcher).click() + } + + fun assertSubmissionTypeDisplayed(submissionType: String) { + onView(withText(submissionType) + withAncestor(R.id.customPanel)).assertDisplayed() + } } /** diff --git a/apps/teacher/src/androidTest/java/com/instructure/teacher/ui/AssigneeListPageTest.kt b/apps/teacher/src/androidTest/java/com/instructure/teacher/ui/AssigneeListPageTest.kt index 2c84903a1b..925dede26e 100644 --- a/apps/teacher/src/androidTest/java/com/instructure/teacher/ui/AssigneeListPageTest.kt +++ b/apps/teacher/src/androidTest/java/com/instructure/teacher/ui/AssigneeListPageTest.kt @@ -87,7 +87,7 @@ class AssigneeListPageTest : TeacherTest() { val assignment = data.addAssignment( courseId = course.id, - submissionType = Assignment.SubmissionType.ONLINE_TEXT_ENTRY) + submissionTypeList = listOf(Assignment.SubmissionType.ONLINE_TEXT_ENTRY)) val token = data.tokenFor(teacher)!! tokenLogin(data.domain, token, teacher) diff --git a/apps/teacher/src/androidTest/java/com/instructure/teacher/ui/AssignmentDetailsPageTest.kt b/apps/teacher/src/androidTest/java/com/instructure/teacher/ui/AssignmentDetailsPageTest.kt index fa1f934da9..935ec1fd2b 100644 --- a/apps/teacher/src/androidTest/java/com/instructure/teacher/ui/AssignmentDetailsPageTest.kt +++ b/apps/teacher/src/androidTest/java/com/instructure/teacher/ui/AssignmentDetailsPageTest.kt @@ -15,7 +15,11 @@ */ package com.instructure.teacher.ui -import com.instructure.canvas.espresso.mockCanvas.* +import com.instructure.canvas.espresso.mockCanvas.MockCanvas +import com.instructure.canvas.espresso.mockCanvas.addAssignment +import com.instructure.canvas.espresso.mockCanvas.addCoursePermissions +import com.instructure.canvas.espresso.mockCanvas.addSubmissionForAssignment +import com.instructure.canvas.espresso.mockCanvas.init import com.instructure.canvas.espresso.mockCanvas.utils.Randomizer import com.instructure.canvasapi2.models.Assignment import com.instructure.canvasapi2.models.Assignment.SubmissionType @@ -41,7 +45,7 @@ class AssignmentDetailsPageTest : TeacherTest() { @TestRail(ID = "C3109579") override fun displaysPageObjects() { getToAssignmentDetailsPage( - submissionTypes = listOf(SubmissionType.ONLINE_TEXT_ENTRY), + submissionTypes = listOf(ONLINE_TEXT_ENTRY), students = 1, withSubmission = true) assignmentDetailsPage.assertPageObjects() @@ -76,7 +80,7 @@ class AssignmentDetailsPageTest : TeacherTest() { } @Test - @TestRail(ID = "C3134482") + @TestRail(ID = "C313448 2") fun displaysNoFromDate() { val lockAt = 7.days.fromNow.iso8601 getToAssignmentDetailsPage(lockAt = lockAt) @@ -155,7 +159,7 @@ class AssignmentDetailsPageTest : TeacherTest() { val assignment = data.addAssignment( courseId = course.id, - submissionType = if(submissionTypes.isEmpty()) SubmissionType.ONLINE_TEXT_ENTRY else submissionTypes.first(), + submissionTypeList = submissionTypes.ifEmpty { listOf(ONLINE_TEXT_ENTRY) }, lockAt = lockAt, unlockAt = unlockAt, description = if(withDescription) Randomizer.randomCourseDescription() else "", diff --git a/apps/teacher/src/androidTest/java/com/instructure/teacher/ui/AssignmentDueDatesPageTest.kt b/apps/teacher/src/androidTest/java/com/instructure/teacher/ui/AssignmentDueDatesPageTest.kt index 857ed54e7e..ca15ef0125 100644 --- a/apps/teacher/src/androidTest/java/com/instructure/teacher/ui/AssignmentDueDatesPageTest.kt +++ b/apps/teacher/src/androidTest/java/com/instructure/teacher/ui/AssignmentDueDatesPageTest.kt @@ -77,7 +77,7 @@ class AssignmentDueDatesPageTest : TeacherTest() { dueAt = dueAt, lockAt = lockAt, unlockAt = unlockAt, - submissionType = Assignment.SubmissionType.ONLINE_TEXT_ENTRY + submissionTypeList = listOf(Assignment.SubmissionType.ONLINE_TEXT_ENTRY) ) val token = data.tokenFor(teacher)!! diff --git a/apps/teacher/src/androidTest/java/com/instructure/teacher/ui/AssignmentListPageTest.kt b/apps/teacher/src/androidTest/java/com/instructure/teacher/ui/AssignmentListPageTest.kt index e65087514b..545c030706 100644 --- a/apps/teacher/src/androidTest/java/com/instructure/teacher/ui/AssignmentListPageTest.kt +++ b/apps/teacher/src/androidTest/java/com/instructure/teacher/ui/AssignmentListPageTest.kt @@ -89,7 +89,7 @@ class AssignmentListPageTest : TeacherTest() { repeat(assignments) { data.addAssignment( courseId = course.id, - submissionType = Assignment.SubmissionType.ONLINE_TEXT_ENTRY, + submissionTypeList = listOf(Assignment.SubmissionType.ONLINE_TEXT_ENTRY), assignmentGroupId = assignmentGroup.id) } diff --git a/apps/teacher/src/androidTest/java/com/instructure/teacher/ui/AssignmentSubmissionListPageTest.kt b/apps/teacher/src/androidTest/java/com/instructure/teacher/ui/AssignmentSubmissionListPageTest.kt index 271ce63154..09f2b53493 100644 --- a/apps/teacher/src/androidTest/java/com/instructure/teacher/ui/AssignmentSubmissionListPageTest.kt +++ b/apps/teacher/src/androidTest/java/com/instructure/teacher/ui/AssignmentSubmissionListPageTest.kt @@ -15,7 +15,11 @@ */ package com.instructure.teacher.ui -import com.instructure.canvas.espresso.mockCanvas.* +import com.instructure.canvas.espresso.mockCanvas.MockCanvas +import com.instructure.canvas.espresso.mockCanvas.addAssignment +import com.instructure.canvas.espresso.mockCanvas.addCoursePermissions +import com.instructure.canvas.espresso.mockCanvas.addSubmissionForAssignment +import com.instructure.canvas.espresso.mockCanvas.init import com.instructure.canvasapi2.models.Assignment import com.instructure.canvasapi2.models.CanvasContextPermission import com.instructure.dataseeding.util.ago @@ -132,7 +136,7 @@ class AssignmentSubmissionListPageTest : TeacherTest() { val assignment = data.addAssignment( courseId = course.id, - submissionType = Assignment.SubmissionType.ONLINE_TEXT_ENTRY, + submissionTypeList = listOf(Assignment.SubmissionType.ONLINE_TEXT_ENTRY), dueAt = dueAt ) diff --git a/apps/teacher/src/androidTest/java/com/instructure/teacher/ui/CommentLibraryPageTest.kt b/apps/teacher/src/androidTest/java/com/instructure/teacher/ui/CommentLibraryPageTest.kt index 7832106162..3daf68f585 100644 --- a/apps/teacher/src/androidTest/java/com/instructure/teacher/ui/CommentLibraryPageTest.kt +++ b/apps/teacher/src/androidTest/java/com/instructure/teacher/ui/CommentLibraryPageTest.kt @@ -255,7 +255,7 @@ class CommentLibraryPageTest : TeacherTest() { val assignment = data.addAssignment( courseId = course.id, - submissionType = Assignment.SubmissionType.ONLINE_TEXT_ENTRY + submissionTypeList = listOf(Assignment.SubmissionType.ONLINE_TEXT_ENTRY) ) data.addSubmissionForAssignment( diff --git a/apps/teacher/src/androidTest/java/com/instructure/teacher/ui/EditAssignmentDetailsPageTest.kt b/apps/teacher/src/androidTest/java/com/instructure/teacher/ui/EditAssignmentDetailsPageTest.kt index dd07dd63c1..4713c578b8 100644 --- a/apps/teacher/src/androidTest/java/com/instructure/teacher/ui/EditAssignmentDetailsPageTest.kt +++ b/apps/teacher/src/androidTest/java/com/instructure/teacher/ui/EditAssignmentDetailsPageTest.kt @@ -201,14 +201,12 @@ class EditAssignmentDetailsPageTest : TeacherTest() { CanvasContextPermission() // Just need to have some sort of permissions object registered ) - val assignment = data.addAssignment( courseId = course.id, withDescription = withDescription, lockAt = lockAt, unlockAt = unlockAt, - submissionType = submissionTypes.firstOrNull() - ?: Assignment.SubmissionType.ONLINE_TEXT_ENTRY + submissionTypeList = submissionTypes.ifEmpty { listOf(Assignment.SubmissionType.ONLINE_TEXT_ENTRY) } ) val token = data.tokenFor(teacher)!! diff --git a/apps/teacher/src/androidTest/java/com/instructure/teacher/ui/EditSyllabusPageTest.kt b/apps/teacher/src/androidTest/java/com/instructure/teacher/ui/EditSyllabusPageTest.kt index ba7f29a88c..06aa6ac6d1 100644 --- a/apps/teacher/src/androidTest/java/com/instructure/teacher/ui/EditSyllabusPageTest.kt +++ b/apps/teacher/src/androidTest/java/com/instructure/teacher/ui/EditSyllabusPageTest.kt @@ -90,7 +90,7 @@ class EditSyllabusPageTest : TeacherTest() { data.addAssignment( courseId = course.id, - submissionType = Assignment.SubmissionType.ONLINE_TEXT_ENTRY, + submissionTypeList = listOf(Assignment.SubmissionType.ONLINE_TEXT_ENTRY), dueAt = 2.days.fromNow.iso8601, name = "Assignment: 1" ) diff --git a/apps/teacher/src/androidTest/java/com/instructure/teacher/ui/SpeedGraderCommentsPageTest.kt b/apps/teacher/src/androidTest/java/com/instructure/teacher/ui/SpeedGraderCommentsPageTest.kt index f479a552ab..cfaefe31a2 100644 --- a/apps/teacher/src/androidTest/java/com/instructure/teacher/ui/SpeedGraderCommentsPageTest.kt +++ b/apps/teacher/src/androidTest/java/com/instructure/teacher/ui/SpeedGraderCommentsPageTest.kt @@ -15,8 +15,16 @@ */ package com.instructure.teacher.ui -import com.instructure.canvas.espresso.mockCanvas.* -import com.instructure.canvasapi2.models.* +import com.instructure.canvas.espresso.mockCanvas.MockCanvas +import com.instructure.canvas.espresso.mockCanvas.addAssignment +import com.instructure.canvas.espresso.mockCanvas.addCoursePermissions +import com.instructure.canvas.espresso.mockCanvas.addSubmissionsForAssignment +import com.instructure.canvas.espresso.mockCanvas.init +import com.instructure.canvasapi2.models.Assignment +import com.instructure.canvasapi2.models.Attachment +import com.instructure.canvasapi2.models.CanvasContextPermission +import com.instructure.canvasapi2.models.Submission +import com.instructure.canvasapi2.models.SubmissionComment import com.instructure.espresso.randomString import com.instructure.teacher.ui.utils.TeacherTest import com.instructure.teacher.ui.utils.tokenLogin @@ -38,7 +46,7 @@ class SpeedGraderCommentsPageTest : TeacherTest() { @Test override fun displaysPageObjects() { goToSpeedGraderCommentsPage( - submissionType = Assignment.SubmissionType.ONLINE_TEXT_ENTRY + submissionTypeList = listOf(Assignment.SubmissionType.ONLINE_TEXT_ENTRY) ) speedGraderCommentsPage.assertPageObjects() @@ -46,42 +54,42 @@ class SpeedGraderCommentsPageTest : TeacherTest() { @Test fun displaysAuthorName() { - val submission = goToSpeedGraderCommentsPage( - submissionType = Assignment.SubmissionType.ONLINE_TEXT_ENTRY, + val submissionList = goToSpeedGraderCommentsPage( + submissionTypeList = listOf(Assignment.SubmissionType.ONLINE_TEXT_ENTRY), withComment = true ) - val authorName = submission!!.submissionComments[0].authorName!! + val authorName = submissionList?.get(0)!!.submissionComments[0].authorName!! speedGraderCommentsPage.assertDisplaysAuthorName(authorName) } @Test fun displaysCommentText() { - val submission = goToSpeedGraderCommentsPage( - submissionType = Assignment.SubmissionType.ONLINE_TEXT_ENTRY, + val submissionList = goToSpeedGraderCommentsPage( + submissionTypeList = listOf(Assignment.SubmissionType.ONLINE_TEXT_ENTRY), withComment = true ) - val commentText = submission!!.submissionComments[0].comment!! + val commentText = submissionList?.get(0)!!.submissionComments[0].comment!! speedGraderCommentsPage.assertDisplaysCommentText(commentText) } @Test fun displaysCommentAttachment() { - val submission = goToSpeedGraderCommentsPage( - submissionType = Assignment.SubmissionType.ONLINE_TEXT_ENTRY, + val submissionList = goToSpeedGraderCommentsPage( + submissionTypeList = listOf(Assignment.SubmissionType.ONLINE_TEXT_ENTRY), withComment = true, attachment = attachment ) - val attachment = submission!!.submissionComments[0].attachments.get(0) + val attachment = submissionList?.get(0)!!.submissionComments[0].attachments.get(0) speedGraderCommentsPage.assertDisplaysCommentAttachment(attachment) } @Test fun displaysSubmissionHistory() { goToSpeedGraderCommentsPage( - submissionType = Assignment.SubmissionType.ONLINE_TEXT_ENTRY + submissionTypeList = listOf(Assignment.SubmissionType.ONLINE_TEXT_ENTRY) ) speedGraderCommentsPage.assertDisplaysSubmission() @@ -89,19 +97,19 @@ class SpeedGraderCommentsPageTest : TeacherTest() { @Test fun displaysSubmissionFile() { - val submission = goToSpeedGraderCommentsPage( - submissionType = Assignment.SubmissionType.ONLINE_UPLOAD, + val submissionList = goToSpeedGraderCommentsPage( + submissionTypeList = listOf(Assignment.SubmissionType.ONLINE_UPLOAD), attachment = attachment ) - val fileAttachments = submission!!.attachments.get(0) + val fileAttachments = submissionList?.get(0)!!.attachments[0] speedGraderCommentsPage.assertDisplaysSubmissionFile(fileAttachments) } @Test fun addsNewTextComment() { goToSpeedGraderCommentsPage( - submissionType = Assignment.SubmissionType.ONLINE_TEXT_ENTRY + submissionTypeList = listOf(Assignment.SubmissionType.ONLINE_TEXT_ENTRY) ) val newComment = randomString(32) @@ -113,7 +121,7 @@ class SpeedGraderCommentsPageTest : TeacherTest() { fun showsNoCommentsMessage() { goToSpeedGraderCommentsPage( submissionCount = 0, - submissionType = Assignment.SubmissionType.ON_PAPER + submissionTypeList = listOf(Assignment.SubmissionType.ON_PAPER) ) speedGraderCommentsPage.assertDisplaysEmptyState() @@ -123,17 +131,17 @@ class SpeedGraderCommentsPageTest : TeacherTest() { * Common setup routine * * [submissionCount] is the number of submissions for the created assignment. Typically 0 or 1. - * [submissionType] is the submission type for the assignment. + * [submissionTypeList] is the submission type for the assignment. * [withComment] if true, include a (student) comment with the submission. * [attachment] if non-null, is either a comment attachment (if withComment is true) or a submission * attachment (if withComment is false). * */ private fun goToSpeedGraderCommentsPage( - submissionCount: Int = 1, - submissionType: Assignment.SubmissionType = Assignment.SubmissionType.ONLINE_TEXT_ENTRY, - withComment: Boolean = false, - attachment: Attachment? = null): Submission? { + submissionCount: Int = 1, + submissionTypeList: List = listOf(Assignment.SubmissionType.ONLINE_TEXT_ENTRY), + withComment: Boolean = false, + attachment: Attachment? = null): MutableList? { val data = MockCanvas.init(teacherCount = 1, studentCount = 1, courseCount = 1, favoriteCourseCount = 1) val teacher = data.teachers[0] @@ -147,7 +155,7 @@ class SpeedGraderCommentsPageTest : TeacherTest() { val assignment = data.addAssignment( courseId = course.id, - submissionType = submissionType + submissionTypeList = submissionTypeList ) var submissionComment : SubmissionComment? = null @@ -163,12 +171,13 @@ class SpeedGraderCommentsPageTest : TeacherTest() { ) } - var submission: Submission? = null + var submissionList = mutableListOf() repeat(submissionCount) { - submission = data.addSubmissionForAssignment( + val submissionTypesRaw = submissionTypeList.map { it.apiString } + submissionList = data.addSubmissionsForAssignment( assignmentId = assignment.id, userId = student.id, - type = submissionType.apiString, + types = submissionTypesRaw, comment = submissionComment, attachment = if (withComment) null else attachment ) @@ -185,6 +194,6 @@ class SpeedGraderCommentsPageTest : TeacherTest() { speedGraderPage.selectCommentsTab() speedGraderPage.swipeUpCommentsTab() - return submission + return submissionList } } diff --git a/apps/teacher/src/androidTest/java/com/instructure/teacher/ui/SpeedGraderFilesPageTest.kt b/apps/teacher/src/androidTest/java/com/instructure/teacher/ui/SpeedGraderFilesPageTest.kt index 929c21223e..f53301a282 100644 --- a/apps/teacher/src/androidTest/java/com/instructure/teacher/ui/SpeedGraderFilesPageTest.kt +++ b/apps/teacher/src/androidTest/java/com/instructure/teacher/ui/SpeedGraderFilesPageTest.kt @@ -15,7 +15,11 @@ */ package com.instructure.teacher.ui -import com.instructure.canvas.espresso.mockCanvas.* +import com.instructure.canvas.espresso.mockCanvas.MockCanvas +import com.instructure.canvas.espresso.mockCanvas.addAssignment +import com.instructure.canvas.espresso.mockCanvas.addCoursePermissions +import com.instructure.canvas.espresso.mockCanvas.addSubmissionForAssignment +import com.instructure.canvas.espresso.mockCanvas.init import com.instructure.canvasapi2.models.Assignment import com.instructure.canvasapi2.models.Attachment import com.instructure.canvasapi2.models.CanvasContextPermission @@ -76,7 +80,7 @@ class SpeedGraderFilesPageTest : TeacherTest() { val assignment = data.addAssignment( courseId = course.id, - submissionType = Assignment.SubmissionType.ONLINE_UPLOAD + submissionTypeList = listOf(Assignment.SubmissionType.ONLINE_UPLOAD) ) repeat(submissionCount) { diff --git a/apps/teacher/src/androidTest/java/com/instructure/teacher/ui/SpeedGraderGradePageTest.kt b/apps/teacher/src/androidTest/java/com/instructure/teacher/ui/SpeedGraderGradePageTest.kt index 5aa322958a..f743f88297 100644 --- a/apps/teacher/src/androidTest/java/com/instructure/teacher/ui/SpeedGraderGradePageTest.kt +++ b/apps/teacher/src/androidTest/java/com/instructure/teacher/ui/SpeedGraderGradePageTest.kt @@ -187,7 +187,7 @@ class SpeedGraderGradePageTest : TeacherTest() { val assignment = data.addAssignment( courseId = course.id, - submissionType = Assignment.SubmissionType.ONLINE_TEXT_ENTRY, + submissionTypeList = listOf(Assignment.SubmissionType.ONLINE_TEXT_ENTRY), pointsPossible = pointsPossible, gradingType = gradingType ) diff --git a/apps/teacher/src/androidTest/java/com/instructure/teacher/ui/SpeedGraderPageTest.kt b/apps/teacher/src/androidTest/java/com/instructure/teacher/ui/SpeedGraderPageTest.kt index 35e39d13f7..81a03fd8b6 100644 --- a/apps/teacher/src/androidTest/java/com/instructure/teacher/ui/SpeedGraderPageTest.kt +++ b/apps/teacher/src/androidTest/java/com/instructure/teacher/ui/SpeedGraderPageTest.kt @@ -15,9 +15,16 @@ */ package com.instructure.teacher.ui -import com.instructure.canvas.espresso.mockCanvas.* +import com.instructure.canvas.espresso.mockCanvas.MockCanvas +import com.instructure.canvas.espresso.mockCanvas.addAssignment +import com.instructure.canvas.espresso.mockCanvas.addCoursePermissions +import com.instructure.canvas.espresso.mockCanvas.addSubmissionsForAssignment +import com.instructure.canvas.espresso.mockCanvas.init import com.instructure.canvasapi2.models.Assignment -import com.instructure.canvasapi2.models.Assignment.SubmissionType.* +import com.instructure.canvasapi2.models.Assignment.SubmissionType.EXTERNAL_TOOL +import com.instructure.canvasapi2.models.Assignment.SubmissionType.ONLINE_TEXT_ENTRY +import com.instructure.canvasapi2.models.Assignment.SubmissionType.ONLINE_URL +import com.instructure.canvasapi2.models.Assignment.SubmissionType.ON_PAPER import com.instructure.canvasapi2.models.CanvasContextPermission import com.instructure.teacher.R import com.instructure.teacher.ui.utils.TeacherTest @@ -36,13 +43,13 @@ class SpeedGraderPageTest : TeacherTest() { @Test fun displaysSubmissionDropDown() { - goToSpeedGraderPage(submissionType = ONLINE_TEXT_ENTRY, students = 1, submissions = listOf(2)) + goToSpeedGraderPage(submissionTypeList = listOf(ONLINE_TEXT_ENTRY), students = 1, submissions = listOf(2)) speedGraderPage.assertHasSubmissionDropDown() } @Test fun opensToCorrectSubmission() { - val data = goToSpeedGraderPage(students = 4, submissionType = ONLINE_TEXT_ENTRY) + val data = goToSpeedGraderPage(students = 4, submissionTypeList = listOf(ONLINE_TEXT_ENTRY)) speedGraderPage.clickBackButton() val students = data.students for (i in 0 until students.size) { @@ -73,37 +80,37 @@ class SpeedGraderPageTest : TeacherTest() { @Test fun displaysTextSubmission() { - goToSpeedGraderPage(submissionType = ONLINE_TEXT_ENTRY, submissions = listOf(1)) + goToSpeedGraderPage(submissionTypeList = listOf(ONLINE_TEXT_ENTRY), submissions = listOf(1)) speedGraderPage.assertDisplaysTextSubmissionView() } @Test fun displaysUnsubmittedEmptyState() { - goToSpeedGraderPage(submissionType = ONLINE_TEXT_ENTRY) + goToSpeedGraderPage(submissionTypeList = listOf(ONLINE_TEXT_ENTRY)) speedGraderPage.assertDisplaysEmptyState(R.string.noSubmissionTeacher) } @Test fun displaysNoSubmissionsAllowedEmptyState() { - goToSpeedGraderPage(submissionType = Assignment.SubmissionType.NONE) + goToSpeedGraderPage(submissionTypeList = listOf(Assignment.SubmissionType.NONE)) speedGraderPage.assertDisplaysEmptyState(R.string.speedGraderNoneMessage) } @Test fun displaysOnPaperEmptyState() { - goToSpeedGraderPage(submissionType = ON_PAPER) + goToSpeedGraderPage(submissionTypeList = listOf(ON_PAPER)) speedGraderPage.assertDisplaysEmptyState(R.string.speedGraderOnPaperMessage) } @Test fun displaysExternalToolEmptyState() { - goToSpeedGraderPage(submissionType = EXTERNAL_TOOL) + goToSpeedGraderPage(submissionTypeList = listOf(EXTERNAL_TOOL)) speedGraderPage.assertDisplaysEmptyState(R.string.noSubmissionTeacher) } @Test fun displaysUrlSubmission() { - val data = goToSpeedGraderPage(submissionType = ONLINE_URL, submissions = listOf(1)) + val data = goToSpeedGraderPage(submissionTypeList = listOf(ONLINE_URL), submissions = listOf(1)) val assignment = data.assignments.values.first() val submission = data.submissions[assignment.id]!!.first() speedGraderPage.assertDisplaysUrlSubmissionLink(submission) @@ -111,10 +118,10 @@ class SpeedGraderPageTest : TeacherTest() { } private fun goToSpeedGraderPage( - students: Int = 1, - submissionType: Assignment.SubmissionType = Assignment.SubmissionType.NONE, - submissions: List = listOf(0), - selectStudent: Int = 0 + students: Int = 1, + submissionTypeList: List = listOf(Assignment.SubmissionType.NONE), + submissions: List = listOf(0), + selectStudent: Int = 0 ): MockCanvas { val data = MockCanvas.init(teacherCount = 1, studentCount = students, courseCount = 1, favoriteCourseCount = 1) val teacher = data.teachers[0] @@ -127,24 +134,24 @@ class SpeedGraderPageTest : TeacherTest() { val assignment = data.addAssignment( courseId = course.id, - submissionType = submissionType + submissionTypeList = submissionTypeList ) - val assignmentSubmissions = - (0 until submissions.size).map { - if(students < it + 1) throw Exception("student count does not agree with submissions") - val student = data.students[it] - val submissionCount = submissions[it] - repeat(submissionCount) { index -> - data.addSubmissionForAssignment( - assignmentId = assignment.id, - userId = student.id, - type = submissionType.apiString, - body = if(submissionType == Assignment.SubmissionType.ONLINE_URL) null else "AssignmentBody $index", - url = if(submissionType == Assignment.SubmissionType.ONLINE_URL) "www.google.com" else null - ) - } - } + (0 until submissions.size).map { + if(students < it + 1) throw Exception("student count does not agree with submissions") + val student = data.students[it] + val submissionCount = submissions[it] + val submissionTypesRaw = submissionTypeList.map { it.apiString } + repeat(submissionCount) { index -> + data.addSubmissionsForAssignment( + assignmentId = assignment.id, + userId = student.id, + types = submissionTypesRaw, + body = if(submissionTypesRaw.contains(Assignment.SubmissionType.ONLINE_URL.apiString)) null else "AssignmentBody $index", + url = if(submissionTypesRaw.contains(Assignment.SubmissionType.ONLINE_URL.apiString)) "www.google.com" else null + ) + } + } val token = data.tokenFor(teacher)!! tokenLogin(data.domain, token, teacher) diff --git a/apps/teacher/src/androidTest/java/com/instructure/teacher/ui/SyllabusPageTest.kt b/apps/teacher/src/androidTest/java/com/instructure/teacher/ui/SyllabusPageTest.kt index 50dc6a2d82..5cf04e871d 100644 --- a/apps/teacher/src/androidTest/java/com/instructure/teacher/ui/SyllabusPageTest.kt +++ b/apps/teacher/src/androidTest/java/com/instructure/teacher/ui/SyllabusPageTest.kt @@ -16,7 +16,12 @@ */ package com.instructure.teacher.ui -import com.instructure.canvas.espresso.mockCanvas.* +import com.instructure.canvas.espresso.mockCanvas.MockCanvas +import com.instructure.canvas.espresso.mockCanvas.addAssignment +import com.instructure.canvas.espresso.mockCanvas.addCourseCalendarEvent +import com.instructure.canvas.espresso.mockCanvas.addCoursePermissions +import com.instructure.canvas.espresso.mockCanvas.addCourseSettings +import com.instructure.canvas.espresso.mockCanvas.init import com.instructure.canvasapi2.models.Assignment import com.instructure.canvasapi2.models.CanvasContextPermission import com.instructure.canvasapi2.models.CourseSettings @@ -101,7 +106,7 @@ class SyllabusPageTest : TeacherTest() { repeat(assignmentCount) { data.addAssignment( courseId = course.id, - submissionType = Assignment.SubmissionType.ONLINE_TEXT_ENTRY, + submissionTypeList = listOf(Assignment.SubmissionType.ONLINE_TEXT_ENTRY), dueAt = 2.days.fromNow.iso8601, name = "Assignment: $it" ) diff --git a/automation/dataseedingapi/src/main/kotlin/com/instructure/dataseeding/model/SubmissionType.kt b/automation/dataseedingapi/src/main/kotlin/com/instructure/dataseeding/model/SubmissionType.kt index ed428d9257..dd640e2ece 100644 --- a/automation/dataseedingapi/src/main/kotlin/com/instructure/dataseeding/model/SubmissionType.kt +++ b/automation/dataseedingapi/src/main/kotlin/com/instructure/dataseeding/model/SubmissionType.kt @@ -23,5 +23,6 @@ enum class SubmissionType { ONLINE_TEXT_ENTRY, ONLINE_URL, EXTERNAL_TOOL, - DISCUSSION_TOPIC + DISCUSSION_TOPIC, + MEDIA_RECORDING } diff --git a/automation/espresso/src/main/kotlin/com/instructure/canvas/espresso/TestMetaData.kt b/automation/espresso/src/main/kotlin/com/instructure/canvas/espresso/TestMetaData.kt index 975a98505f..3fb7dce239 100644 --- a/automation/espresso/src/main/kotlin/com/instructure/canvas/espresso/TestMetaData.kt +++ b/automation/espresso/src/main/kotlin/com/instructure/canvas/espresso/TestMetaData.kt @@ -38,7 +38,7 @@ enum class FeatureCategory { enum class SecondaryFeatureCategory { NONE, LOGIN_K5, - SUBMISSIONS_TEXT_ENTRY, SUBMISSIONS_ANNOTATIONS, SUBMISSIONS_ONLINE_URL, + SUBMISSIONS_TEXT_ENTRY, SUBMISSIONS_ANNOTATIONS, SUBMISSIONS_ONLINE_URL, SUBMISSIONS_MULTIPLE_TYPE, ASSIGNMENT_COMMENTS, ASSIGNMENT_QUIZZES, ASSIGNMENT_DISCUSSIONS, GROUPS_DASHBOARD, GROUPS_FILES, GROUPS_ANNOUNCEMENTS, GROUPS_DISCUSSIONS, GROUPS_PAGES, GROUPS_PEOPLE, EVENTS_DISCUSSIONS, EVENTS_QUIZZES, EVENTS_ASSIGNMENTS, EVENTS_NOTIFICATIONS, diff --git a/automation/espresso/src/main/kotlin/com/instructure/canvas/espresso/mockCanvas/MockCanvas.kt b/automation/espresso/src/main/kotlin/com/instructure/canvas/espresso/mockCanvas/MockCanvas.kt index 9b559020bb..2c81f9e357 100644 --- a/automation/espresso/src/main/kotlin/com/instructure/canvas/espresso/mockCanvas/MockCanvas.kt +++ b/automation/espresso/src/main/kotlin/com/instructure/canvas/espresso/mockCanvas/MockCanvas.kt @@ -375,7 +375,7 @@ fun MockCanvas.Companion.init( totalStudents = studentUsers.count() ) } - val course = data.addCourse( + data.addCourse( isFavorite = it < favoriteCourseCount, id = courseId, section = section, @@ -827,24 +827,24 @@ fun MockCanvas.addAssignmentsToGroups(course: Course, assignmentCountPerGroup: I for (i in 0 until assignmentCountPerGroup) { - val overdueAssignment = addAssignment( + addAssignment( courseId = course.id, - submissionType = Assignment.SubmissionType.ONLINE_URL, + submissionTypeList = listOf(Assignment.SubmissionType.ONLINE_URL), name = Randomizer.randomAssignmentName(), dueAt = pastDueDate, assignmentGroupId = overdueAssignmentGroup.id ) - val upcomingAssignment = addAssignment( + addAssignment( courseId = course.id, - submissionType = Assignment.SubmissionType.ONLINE_URL, + submissionTypeList = listOf(Assignment.SubmissionType.ONLINE_URL), name = Randomizer.randomAssignmentName(), dueAt = futureDueDate, assignmentGroupId = upcomingAssignmentGroup.id ) - val undatedAssignment = addAssignment( + addAssignment( courseId = course.id, - submissionType = Assignment.SubmissionType.ONLINE_URL, + submissionTypeList = listOf(Assignment.SubmissionType.ONLINE_URL), name = Randomizer.randomAssignmentName(), dueAt = null, assignmentGroupId = undatedAssignmentGroup.id @@ -852,12 +852,12 @@ fun MockCanvas.addAssignmentsToGroups(course: Course, assignmentCountPerGroup: I val pastAssignment = addAssignment( courseId = course.id, - submissionType = Assignment.SubmissionType.ONLINE_URL, + submissionTypeList = listOf(Assignment.SubmissionType.ONLINE_URL), name = Randomizer.randomAssignmentName(), dueAt = pastDueDate, assignmentGroupId = pastAssignmentGroup.id ) - val pastSubmission = addSubmissionForAssignment( + addSubmissionForAssignment( assignmentId = pastAssignment.id, userId = users.values.first().id, type = Assignment.SubmissionType.ONLINE_URL.apiString, @@ -874,7 +874,7 @@ fun MockCanvas.addAssignmentsToGroups(course: Course, assignmentCountPerGroup: I */ fun MockCanvas.addAssignment( courseId: Long, - submissionType: Assignment.SubmissionType = Assignment.SubmissionType.ONLINE_TEXT_ENTRY, + submissionTypeList: List = listOf(Assignment.SubmissionType.ONLINE_TEXT_ENTRY), assignmentGroupId: Long = newItemId(), isQuizzesNext: Boolean = false, lockInfo : LockInfo? = null, @@ -889,12 +889,13 @@ fun MockCanvas.addAssignment( gradingType: String = "percent" ) : Assignment { val assignmentId = newItemId() + val submissionTypeListRawStrings = submissionTypeList.map { it.apiString } var assignment = Assignment( id = assignmentId, assignmentGroupId = assignmentGroupId, courseId = courseId, name = name, - submissionTypesRaw = listOf(submissionType.apiString), + submissionTypesRaw = submissionTypeListRawStrings, lockInfo = lockInfo, lockedForUser = lockInfo != null, userSubmitted = userSubmitted, @@ -921,7 +922,7 @@ fun MockCanvas.addAssignment( assignmentGroups[courseId] = assignmentGroupList } - var group = assignmentGroupList.find { it.id == assignmentGroupId } + val group = assignmentGroupList.find { it.id == assignmentGroupId } if (group == null) { assignmentGroupList.add(AssignmentGroup(id = assignmentGroupId, assignments = listOf(assignment))) } else { @@ -941,6 +942,45 @@ fun MockCanvas.addAssignment( return assignment } +/** + * Adds multiple (type) submissions to the assignment submission map. + */ +fun MockCanvas.addSubmissionsForAssignment( + assignmentId: Long, + userId: Long, + types: List, + body: String? = null, + url: String? = null, + attachment: Attachment? = null, + comment: SubmissionComment? = null, + state: String = "submitted", + grade: String? = null, + attempt: Long = 1, + score: Double? = null, + excused: Boolean = false): MutableList { + + val submissionList = mutableListOf() + types.forEach { type -> + val submission = addSubmissionForAssignment( + assignmentId, + userId, + type, + body, + url, + attachment, + comment, + state, + grade, + attempt, + score, + excused + ) + submissionList.add(submission) + } + + return submissionList + +} /** * Adds a submission to the assignment submission map. */ @@ -1253,7 +1293,7 @@ fun MockCanvas.addFolderToCourse( groupId: Long? = null ) : Long { // Find your root folder - var rootFolder = getRootFolder(courseId = courseId, groupId = groupId) + val rootFolder = getRootFolder(courseId = courseId, groupId = groupId) // Now create our folder metadata val newFolderId = newItemId() @@ -1303,7 +1343,7 @@ fun MockCanvas.addFileToFolder( if(courseId == null && folderId == null) { throw Exception("Either courseId or folderId must be non-null") } - var rootFolder = getRootFolder(courseId = courseId, folderId = folderId) + val rootFolder = getRootFolder(courseId = courseId, folderId = folderId) // Now create our file metadata val fileMetadataItem = FileFolder( @@ -1345,7 +1385,7 @@ fun MockCanvas.addFileToCourse( url: String = "", fileId: Long = newItemId() ): Long { - var rootFolder = getRootFolder(courseId = courseId, groupId = groupId) + val rootFolder = getRootFolder(courseId = courseId, groupId = groupId) return addFileToFolder( folderId = rootFolder.id, displayName = displayName, @@ -1563,7 +1603,7 @@ fun MockCanvas.addItemToModule( ) // Copy/update/replace the module - var newItemList = module.items.toMutableList() + val newItemList = module.items.toMutableList() newItemList.add(result) val changedModule = module.copy( items = newItemList @@ -1697,7 +1737,7 @@ fun MockCanvas.addQuestionToQuiz( fun MockCanvas.addQuizSubmission(quiz: Quiz, user: User, state: String = "untaken", grade: String? = null) : QuizSubmission { val now = Calendar.getInstance().time.time // ms - var quizSubmission = QuizSubmission( + val quizSubmission = QuizSubmission( id = newItemId(), quizId = quiz.id, userId = user.id, @@ -1710,7 +1750,7 @@ fun MockCanvas.addQuizSubmission(quiz: Quiz, user: User, state: String = "untake // Don't forget to add some sort of submission to the related assignment if(quiz.assignmentId != 0L) { - val assignment = assignments[quiz.assignmentId] + assignments[quiz.assignmentId] this.addSubmissionForAssignment(assignmentId = quiz.assignmentId, userId = user.id, type = "online_quiz", state = state, grade = grade) }