Search in sources :

Example 26 with Assignment

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

the class AssignmentAPI method getFirstPageAssignments.

public static void getFirstPageAssignments(long courseId, boolean forceNetwork, @NonNull RestBuilder adapter, @NonNull StatusCallback<List<Assignment>> callback) {
    RestParams params = new RestParams.Builder().withShouldIgnoreToken(false).withPerPageQueryParam(true).withForceReadFromNetwork(forceNetwork).build();
    callback.addCall(adapter.build(AssignmentInterface.class, params).getAssignments(courseId)).enqueue(callback);
}
Also used : RestParams(com.instructure.canvasapi2.builders.RestParams) RestBuilder(com.instructure.canvasapi2.builders.RestBuilder)

Example 27 with Assignment

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

the class AssignmentTest method getLastActualSubmission_TestWorkFlowSubmitted.

@Test
public void getLastActualSubmission_TestWorkFlowSubmitted() {
    Assignment assignment = new Assignment();
    Submission submission = new Submission();
    submission.setWorkflowState("submitted");
    assignment.setSubmission(submission);
    assertEquals(submission, assignment.getLastActualSubmission());
}
Also used : Assignment(com.instructure.canvasapi2.models.Assignment) Submission(com.instructure.canvasapi2.models.Submission) Test(org.junit.Test)

Example 28 with Assignment

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

the class AssignmentTest method getLastActualSubmission_TestNullWorkFlow.

@Test
public void getLastActualSubmission_TestNullWorkFlow() {
    Assignment assignment = new Assignment();
    Submission submission = new Submission();
    submission.setWorkflowState(null);
    assignment.setSubmission(submission);
    assertEquals(null, assignment.getLastActualSubmission());
}
Also used : Assignment(com.instructure.canvasapi2.models.Assignment) Submission(com.instructure.canvasapi2.models.Submission) Test(org.junit.Test)

Example 29 with Assignment

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

the class AssignmentTest method isAllowedToSubmit_TestFalse.

@Test
public void isAllowedToSubmit_TestFalse() {
    Assignment assignment = new Assignment();
    List<String> submissionTypeList = new ArrayList<>();
    submissionTypeList.add(Assignment.submissionTypeToAPIString(Assignment.SUBMISSION_TYPE.ATTENDANCE));
    submissionTypeList.add(Assignment.submissionTypeToAPIString(Assignment.SUBMISSION_TYPE.ONLINE_QUIZ));
    assignment.setSubmissionTypes(submissionTypeList);
    assignment.setLockedForUser(true);
    assertEquals(false, assignment.isAllowedToSubmit());
}
Also used : Assignment(com.instructure.canvasapi2.models.Assignment) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 30 with Assignment

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

the class AssignmentTest method isAllowedToSubmit_TestTrue.

@Test
public void isAllowedToSubmit_TestTrue() {
    Assignment assignment = new Assignment();
    List<String> submissionTypeList = new ArrayList<>();
    submissionTypeList.add(Assignment.submissionTypeToAPIString(Assignment.SUBMISSION_TYPE.DISCUSSION_TOPIC));
    submissionTypeList.add(Assignment.submissionTypeToAPIString(Assignment.SUBMISSION_TYPE.ONLINE_URL));
    assignment.setSubmissionTypes(submissionTypeList);
    assignment.setLockedForUser(false);
    assertEquals(true, assignment.isAllowedToSubmit());
}
Also used : Assignment(com.instructure.canvasapi2.models.Assignment) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Aggregations

Assignment (com.instructure.canvasapi2.models.Assignment)62 Test (org.junit.Test)46 Submission (com.instructure.canvasapi2.models.Submission)25 Date (java.util.Date)18 ArrayList (java.util.ArrayList)15 View (android.view.View)10 RestBuilder (com.instructure.canvasapi2.builders.RestBuilder)10 Course (com.instructure.canvasapi2.models.Course)9 RestParams (com.instructure.canvasapi2.builders.RestParams)7 Bundle (android.os.Bundle)6 ScheduleItem (com.instructure.canvasapi2.models.ScheduleItem)6 LinkHeaders (com.instructure.canvasapi2.utils.LinkHeaders)6 Navigation (com.instructure.interactions.Navigation)5 DrawableRes (android.support.annotation.DrawableRes)4 AdapterView (android.widget.AdapterView)4 TextView (android.widget.TextView)4 Request (okhttp3.Request)4 Response (okhttp3.Response)4 Paint (android.graphics.Paint)3 Drawable (android.graphics.drawable.Drawable)3