Search in sources :

Example 31 with Submission

use of com.instructure.canvasapi2.models.Submission in project instructure-android by instructure.

the class AssignmentUtils2Test method getAssignmentState_stateSubmittedLate.

@Test
public void getAssignmentState_stateSubmittedLate() throws Exception {
    Assignment assignment = new Assignment();
    Submission submission = new Submission();
    long time = Calendar.getInstance().getTimeInMillis() + 100000;
    Date date = new Date(time);
    submission.setAttempt(1);
    submission.setLate(true);
    assignment.setSubmission(submission);
    assignment.setDueAt(APIHelper.dateToString(date));
    int testValue = AssignmentUtils2.getAssignmentState(assignment, submission);
    assertEquals("", testValue, AssignmentUtils2.ASSIGNMENT_STATE_SUBMITTED_LATE);
}
Also used : Assignment(com.instructure.canvasapi2.models.Assignment) Submission(com.instructure.canvasapi2.models.Submission) Date(java.util.Date) Test(org.junit.Test)

Example 32 with Submission

use of com.instructure.canvasapi2.models.Submission in project instructure-android by instructure.

the class AssignmentUtils2Test method getAssignmentState_stateDue.

@Test
public void getAssignmentState_stateDue() throws Exception {
    Assignment assignment = new Assignment();
    Submission submission = null;
    long time = Calendar.getInstance().getTimeInMillis() + 100000;
    Date date = new Date(time);
    assignment.setSubmission(submission);
    assignment.setDueAt(APIHelper.dateToString(date));
    int testValue = AssignmentUtils2.getAssignmentState(assignment, submission);
    assertEquals("", testValue, AssignmentUtils2.ASSIGNMENT_STATE_DUE);
}
Also used : Assignment(com.instructure.canvasapi2.models.Assignment) Submission(com.instructure.canvasapi2.models.Submission) Date(java.util.Date) Test(org.junit.Test)

Example 33 with Submission

use of com.instructure.canvasapi2.models.Submission in project instructure-android by instructure.

the class AssignmentUtils2Test method getAssignmentState_stateGradedLate.

@Test
public void getAssignmentState_stateGradedLate() throws Exception {
    Assignment assignment = new Assignment();
    Submission submission = new Submission();
    long time = Calendar.getInstance().getTimeInMillis() + 100000;
    Date date = new Date(time);
    submission.setAttempt(1);
    submission.setGrade("A");
    submission.setLate(true);
    assignment.setSubmission(submission);
    assignment.setDueAt(APIHelper.dateToString(date));
    int testValue = AssignmentUtils2.getAssignmentState(assignment, submission);
    assertEquals("", testValue, AssignmentUtils2.ASSIGNMENT_STATE_GRADED_LATE);
}
Also used : Assignment(com.instructure.canvasapi2.models.Assignment) Submission(com.instructure.canvasapi2.models.Submission) Date(java.util.Date) Test(org.junit.Test)

Example 34 with Submission

use of com.instructure.canvasapi2.models.Submission in project instructure-android by instructure.

the class AssignmentUtils2Test method getAssignmentState_stateSubmitted.

@Test
public void getAssignmentState_stateSubmitted() throws Exception {
    Assignment assignment = new Assignment();
    Submission submission = new Submission();
    long time = Calendar.getInstance().getTimeInMillis() + 100000;
    Date date = new Date(time);
    submission.setAttempt(1);
    assignment.setSubmission(submission);
    assignment.setDueAt(APIHelper.dateToString(date));
    int testValue = AssignmentUtils2.getAssignmentState(assignment, submission);
    assertEquals("", testValue, AssignmentUtils2.ASSIGNMENT_STATE_SUBMITTED);
}
Also used : Assignment(com.instructure.canvasapi2.models.Assignment) Submission(com.instructure.canvasapi2.models.Submission) Date(java.util.Date) Test(org.junit.Test)

Example 35 with Submission

use of com.instructure.canvasapi2.models.Submission in project instructure-android by instructure.

the class ViewUtilsTest method getAssignmentIconOrder.

@Test
public void getAssignmentIconOrder() throws Exception {
    /**
     * Tests the order that the icons are retrieved.
     * Quizzes, Discussion Topics, Assignment icons in that order
     *
     * To properly test the order we need to test the method 3 times for each icon type
     */
    Assignment assignment = new Assignment();
    List<String> types = new ArrayList<>();
    @DrawableRes int iconRes = 0;
    // Add all other submission types
    types.add(submissionTypeToAPIString(Assignment.SUBMISSION_TYPE.NONE));
    types.add(submissionTypeToAPIString(Assignment.SUBMISSION_TYPE.ON_PAPER));
    types.add(submissionTypeToAPIString(Assignment.SUBMISSION_TYPE.EXTERNAL_TOOL));
    types.add(submissionTypeToAPIString(Assignment.SUBMISSION_TYPE.ONLINE_UPLOAD));
    types.add(submissionTypeToAPIString(Assignment.SUBMISSION_TYPE.ONLINE_TEXT_ENTRY));
    types.add(submissionTypeToAPIString(Assignment.SUBMISSION_TYPE.ONLINE_URL));
    types.add(submissionTypeToAPIString(Assignment.SUBMISSION_TYPE.MEDIA_RECORDING));
    types.add(submissionTypeToAPIString(Assignment.SUBMISSION_TYPE.ATTENDANCE));
    types.add(submissionTypeToAPIString(Assignment.SUBMISSION_TYPE.NOT_GRADED));
    assignment.setSubmissionTypes(types);
    iconRes = ViewUtils.getAssignmentIcon(assignment);
    assertTrue(iconRes == R.drawable.ic_cv_assignments_fill);
    // Add the one we want to test
    types.add(submissionTypeToAPIString(Assignment.SUBMISSION_TYPE.DISCUSSION_TOPIC));
    assignment.setSubmissionTypes(types);
    iconRes = ViewUtils.getAssignmentIcon(assignment);
    assertTrue(iconRes == R.drawable.ic_cv_discussions_fill);
    // Add the next one we want to test
    types.add(submissionTypeToAPIString(Assignment.SUBMISSION_TYPE.ONLINE_QUIZ));
    assignment.setSubmissionTypes(types);
    iconRes = ViewUtils.getAssignmentIcon(assignment);
    assertTrue(iconRes == R.drawable.ic_cv_quizzes_fill);
}
Also used : Assignment(com.instructure.canvasapi2.models.Assignment) DrawableRes(android.support.annotation.DrawableRes) ArrayList(java.util.ArrayList) Assignment.submissionTypeToAPIString(com.instructure.canvasapi2.models.Assignment.submissionTypeToAPIString) Test(org.junit.Test)

Aggregations

Submission (com.instructure.canvasapi2.models.Submission)33 Assignment (com.instructure.canvasapi2.models.Assignment)20 Test (org.junit.Test)17 RestBuilder (com.instructure.canvasapi2.builders.RestBuilder)14 RestParams (com.instructure.canvasapi2.builders.RestParams)13 ArrayList (java.util.ArrayList)8 LinkHeaders (com.instructure.canvasapi2.utils.LinkHeaders)7 Date (java.util.Date)7 List (java.util.List)5 Request (okhttp3.Request)4 Response (okhttp3.Response)4 NonNull (android.support.annotation.NonNull)3 View (android.view.View)3 StatusCallback (com.instructure.canvasapi2.StatusCallback)3 GradeableStudentSubmission (com.instructure.canvasapi2.models.GradeableStudentSubmission)3 ApiType (com.instructure.canvasapi2.utils.ApiType)3 Navigation (com.instructure.interactions.Navigation)3 Response (retrofit2.Response)3 Intent (android.content.Intent)2 Paint (android.graphics.Paint)2