appId: com.toughra.ustadmobile
tags:
  - assignments
env:
  TESTRESULTSDIR: "build/reports/maestro/004_001_assignment_creation_submission_grading/Screenshots"
onFlowStart:
  - startRecording: 004_001_assignment_creation_submission_grading
  - runScript:
      file: "common/startserver.js"
      env:
        TESTCONTROLLER_URL: ${TESTCONTROLLER_URL}
  - clearState: com.toughra.ustadmobile
onFlowComplete:
  - stopRecording
  - runScript:
      file: "common/stopserver.js"
      env:
        TESTCONTROLLER_URL: ${TESTCONTROLLER_URL}
---
- runScript:
    file: "common/import_users_via_http.js"
    env:
      TESTCONTROLLER_URL: ${TESTCONTROLLER_URL}
      IMPORT_FROM_CSV_FILE: "Ustad_Teacher_and_Students.csv"
# download the assignment file
- runFlow:
    file:  "common/download_file_via_browser.yaml"
    env:
      TESTFILENAME: "Assignment_File.pdf"
- runFlow: "common/clear_state_and_learning_space_existing_userflow.yaml"
- runFlow: "common/select_site.yaml"
- runFlow:
    file: "common/user_login.yaml"
    env:
      USERNAME: "teach1"
      PASSWORD: "testt1"
- tapOn: "Courses"
- tapOn: "Test Course Block"
# edit the course to add blocks
- tapOn:
    id: "floating_action_button"
# add assignment block ------ 1
- scrollUntilVisible:
    element:
      text: "Add block"
    direction: DOWN
- tapOn: "Add block"
- runFlow:
    when:
      notVisible:
        text: "Assignment"
    commands:
      - swipe:
          from:
            text: "Drag handle"
          direction: UP
- tapOn: "Assignment"
- tapOn: "Title*"
- hideKeyboard
- tapOn: "Done"
#Assertion to make sure the page is not saved because title is blank
- assertNotVisible:
    text: "Add block"
- tapOn: "Title*"
- inputText: "Assignment 1"
- hideKeyboard
- tapOn: "Description"
- tapOn:
    id: "com.toughra.ustadmobile:id/editor"
- inputText: "test block"
- tapOn: "Done"
- scrollUntilVisible:
    element:
      text: "Submission policy"
    direction: DOWN
- assertVisible: "Must submit all at once"
- assertVisible: "Done"
- takeScreenshot: "${TESTRESULTSDIR}/added_assignment"
- tapOn:
    text: "Done"
- assertNotVisible: "Done"
- tapOn: "Save"
# student submit assignment
- runFlow: "common/clear_state_and_learning_space_existing_userflow.yaml"
- runFlow: "common/select_site.yaml"
- runFlow:
    file: "common/user_login.yaml"
    env:
      USERNAME: "stud1"
      PASSWORD: "tests1"
- tapOn: "Courses"
- tapOn: "Test Course Block"
- scrollUntilVisible:
    element:
      text: "Assignment"
    direction: DOWN
- tapOn: "Assignment"
- tapOn: "Text"
- tapOn:
     id: "com.toughra.ustadmobile:id/editor"
- inputText: "Assignment done by student 1"
- tapOn: "Done"
- runFlow:
    file: "common/add_assignment_file.yaml"
    env:
      TESTFILENAME: "Assignment_File.pdf"
- scrollUntilVisible:
    element:
      text: "Submit"
    direction: DOWN
- tapOn: "Submit"
- assertVisible: "Submitted"
# teacher view and mark the assignment submitted by student
- runFlow: "common/clear_state_and_learning_space_existing_userflow.yaml"
- runFlow: "common/select_site.yaml"
- runFlow:
    file: "common/user_login.yaml"
    env:
      USERNAME: "teach1"
      PASSWORD: "testt1"
- tapOn: "Courses"
- tapOn: "Test Course Block"
- scrollUntilVisible:
    element:
      text: "Assignment"
    direction: DOWN
- tapOn: "Assignment"
- tapOn: "Submissions"
- assertVisible: "Student 1"
- tapOn: "Student 1"
# assert that teacher able to view text submitted by student
- assertVisible: "Assignment done by student 1"
# assert that teacher able to open and view file submitted by student
- assertVisible: "Assignment_File.pdf"
- tapOn: "Assignment_File.pdf"
- assertVisible: "Assignment test Pdf\r\n"
- back
- assertVisible: "Mark comment"
- tapOn: "Mark comment"
- inputText: "Good job"
- hideKeyboard
- scrollUntilVisible:
    element:
      text: "Mark*"
    direction: DOWN
- tapOn: "Mark*"
- inputText: "9"
- tapOn: "Submit grade"
- hideKeyboard
- scrollUntilVisible:
    element:
      text: "Result"
    direction: UP
- assertVisible: "9.0/10.0 Points"
# student able to view his grade
- runFlow: "common/clear_state_and_learning_space_existing_userflow.yaml"
- runFlow: "common/select_site.yaml"
- runFlow:
    file: "common/user_login.yaml"
    env:
      USERNAME: "stud1"
      PASSWORD: "tests1"
- tapOn: "Courses"
- tapOn: "Test Course Block"
- scrollUntilVisible:
    element:
      text: "Assignment"
    direction: DOWN
- tapOn: "Assignment"
- assertVisible: "Marked"
- scrollUntilVisible:
    element:
      text: "Grades"
    direction: DOWN
- assertVisible: "9.0/10.0 Points"
#  Submission policy - Must submit all at once , so make sure Submit button is not visible
- assertNotVisible: "Submit"
# teacher can delete the course
- runFlow: "common/clear_state_and_learning_space_existing_userflow.yaml"
- runFlow: "common/select_site.yaml"
- runFlow:
    file: "common/user_login.yaml"
    env:
      USERNAME: "teach1"
      PASSWORD: "testt1"
- tapOn: "Courses"
- tapOn: "Test Course Block"
# verify teacher able to see student score in gradebook
- tapOn: "Gradebook"
- assertVisible: "9"
- tapOn: "Course"
- tapOn:
    id: "floating_action_button"
- scrollUntilVisible:
    element:
      text: "Assignment 1"
    direction: DOWN
- tapOn: "More options"
- tapOn: "Delete"
- tapOn: "Save"
- assertNotVisible: "Assignment 1"