Search in sources :

Example 1 with Submission

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

the class AssignmentUtils2Test method getAssignmentState_unknownStateNullAssignment.

@Test
public void getAssignmentState_unknownStateNullAssignment() throws Exception {
    Assignment assignment = null;
    Submission submission = new Submission();
    int testValue = AssignmentUtils2.getAssignmentState(assignment, submission);
    assertEquals("", testValue, AssignmentUtils2.ASSIGNMENT_STATE_UNKNOWN);
}
Also used : Assignment(com.instructure.canvasapi2.models.Assignment) Submission(com.instructure.canvasapi2.models.Submission) Test(org.junit.Test)

Example 2 with Submission

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

the class AssignmentUtils2Test method getAssignmentState_stateInClass.

@Test
public void getAssignmentState_stateInClass() throws Exception {
    Assignment assignment = new Assignment();
    Submission submission = null;
    long time = Calendar.getInstance().getTimeInMillis() + 100000;
    Date date = new Date(time);
    ArrayList<String> submissionTypes = new ArrayList<>();
    submissionTypes.add(Assignment.submissionTypeToAPIString(Assignment.SUBMISSION_TYPE.ON_PAPER));
    assignment.setSubmission(submission);
    assignment.setDueAt(APIHelper.dateToString(date));
    assignment.setSubmissionTypes(submissionTypes);
    int testValue = AssignmentUtils2.getAssignmentState(assignment, submission);
    assertEquals("", testValue, AssignmentUtils2.ASSIGNMENT_STATE_IN_CLASS);
}
Also used : Assignment(com.instructure.canvasapi2.models.Assignment) Submission(com.instructure.canvasapi2.models.Submission) ArrayList(java.util.ArrayList) Date(java.util.Date) Test(org.junit.Test)

Example 3 with Submission

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

the class AssignmentUtils2Test method getAssignmentState_stateGraded.

@Test
public void getAssignmentState_stateGraded() 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");
    assignment.setSubmission(submission);
    assignment.setDueAt(APIHelper.dateToString(date));
    int testValue = AssignmentUtils2.getAssignmentState(assignment, submission);
    assertEquals("", testValue, AssignmentUtils2.ASSIGNMENT_STATE_GRADED);
}
Also used : Assignment(com.instructure.canvasapi2.models.Assignment) Submission(com.instructure.canvasapi2.models.Submission) Date(java.util.Date) Test(org.junit.Test)

Example 4 with Submission

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

the class AssignmentUtils2Test method getAssignmentState_stateMissingNullDueDate.

@Test
public void getAssignmentState_stateMissingNullDueDate() throws Exception {
    Assignment assignment = new Assignment();
    Submission submission = null;
    assignment.setSubmission(submission);
    assignment.setDueAt(null);
    int testValue = AssignmentUtils2.getAssignmentState(assignment, submission);
    assertEquals("", testValue, AssignmentUtils2.ASSIGNMENT_STATE_MISSING);
}
Also used : Assignment(com.instructure.canvasapi2.models.Assignment) Submission(com.instructure.canvasapi2.models.Submission) Test(org.junit.Test)

Example 5 with Submission

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

the class GradesListRecyclerAdapter method compareAssignments.

private boolean compareAssignments(Assignment oldItem, Assignment newItem) {
    boolean isSameName = oldItem.getName().equals(newItem.getName());
    boolean isSameScore = oldItem.getPointsPossible() == newItem.getPointsPossible();
    boolean isSameSubmission = true;
    boolean isSameGrade = true;
    Submission oldSubmission = oldItem.getSubmission();
    Submission newSubmission = newItem.getSubmission();
    if (oldSubmission != null && newSubmission != null) {
        if (oldSubmission.getGrade() != null && newSubmission.getGrade() != null) {
            isSameGrade = oldSubmission.getGrade().equals(newSubmission.getGrade());
        } else if (isNullableChanged(oldSubmission.getGrade(), newSubmission.getGrade())) {
            isSameGrade = false;
        }
    } else if (isNullableChanged(oldSubmission, newSubmission)) {
        isSameSubmission = false;
    }
    return isSameName && isSameGrade && isSameScore && isSameSubmission;
}
Also used : Submission(com.instructure.canvasapi2.models.Submission)

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