Search in sources :

Example 41 with Submission

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

the class SubmissionManager method getAllStudentSubmissionsForCourse.

public static void getAllStudentSubmissionsForCourse(final long studentId, final long courseId, @NonNull StatusCallback<List<Submission>> callback, boolean forceNetwork) {
    if (isTesting() | mTesting) {
        SubmissionManager_Test.getStudentSubmissionsForCourse(studentId, courseId, callback);
    } else {
        final RestBuilder adapter = new RestBuilder(callback);
        final RestParams params = new RestParams.Builder().withForceReadFromNetwork(forceNetwork).withPerPageQueryParam(true).withShouldIgnoreToken(false).build();
        StatusCallback<List<Submission>> depaginatedCallback = new ExhaustiveListCallback<Submission>(callback) {

            @Override
            public void getNextPage(@NonNull StatusCallback<List<Submission>> callback, @NonNull String nextUrl, boolean isCached) {
                SubmissionAPI.getStudentSubmissionsForCourse(courseId, studentId, adapter, callback, params);
            }
        };
        adapter.setStatusCallback(depaginatedCallback);
        SubmissionAPI.getStudentSubmissionsForCourse(courseId, studentId, adapter, callback, params);
    }
}
Also used : Submission(com.instructure.canvasapi2.models.Submission) RestParams(com.instructure.canvasapi2.builders.RestParams) RestBuilder(com.instructure.canvasapi2.builders.RestBuilder) NonNull(android.support.annotation.NonNull) RestBuilder(com.instructure.canvasapi2.builders.RestBuilder) List(java.util.List) StatusCallback(com.instructure.canvasapi2.StatusCallback) ExhaustiveListCallback(com.instructure.canvasapi2.utils.ExhaustiveListCallback)

Example 42 with Submission

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

the class SubmissionManager method postSubmissionExcusedStatus.

public static void postSubmissionExcusedStatus(long courseId, long assignmentId, long userId, boolean isExcused, boolean forceNetwork, @NonNull StatusCallback<Submission> callback) {
    if (isTesting() | mTesting) {
    // SubmissionManager_Test.postSubmissionGrade(courseId, assignmentId, userId, score, callback);
    } else {
        RestBuilder adapter = new RestBuilder(callback);
        RestParams params = new RestParams.Builder().withForceReadFromNetwork(forceNetwork).withPerPageQueryParam(false).withShouldIgnoreToken(false).build();
        SubmissionAPI.postSubmissionExcusedStatus(courseId, assignmentId, userId, isExcused, adapter, callback, params);
    }
}
Also used : RestParams(com.instructure.canvasapi2.builders.RestParams) RestBuilder(com.instructure.canvasapi2.builders.RestBuilder) RestBuilder(com.instructure.canvasapi2.builders.RestBuilder)

Example 43 with Submission

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

the class SubmissionManager method postMediaSubmission.

public static void postMediaSubmission(CanvasContext canvasContext, long assignmentId, String submissionType, String mediaId, String mediaType, StatusCallback<Submission> callback) {
    if (isTesting() || mTesting) {
    // TODO
    } else {
        RestBuilder adapter = new RestBuilder(callback);
        RestParams params = new RestParams.Builder().withCanvasContext(canvasContext).build();
        SubmissionAPI.postMediaSubmission(canvasContext.getId(), assignmentId, submissionType, mediaId, mediaType, adapter, params, callback);
    }
}
Also used : RestParams(com.instructure.canvasapi2.builders.RestParams) RestBuilder(com.instructure.canvasapi2.builders.RestBuilder) RestBuilder(com.instructure.canvasapi2.builders.RestBuilder)

Example 44 with Submission

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

the class SubmissionManager method postSubmissionComment.

public static void postSubmissionComment(long courseId, long assignmentId, long userId, String commentText, boolean isGroupMessage, List<Long> attachments, @NonNull StatusCallback<Submission> callback) {
    if (isTesting() || mTesting) {
        SubmissionManager_Test.postSubmissionComment(courseId, assignmentId, userId, commentText, isGroupMessage, callback);
    } else {
        RestBuilder adapter = new RestBuilder(callback);
        RestParams params = new RestParams.Builder().build();
        SubmissionAPI.postSubmissionComment(courseId, assignmentId, userId, commentText, isGroupMessage, attachments, adapter, callback, params);
    }
}
Also used : RestParams(com.instructure.canvasapi2.builders.RestParams) RestBuilder(com.instructure.canvasapi2.builders.RestBuilder)

Example 45 with Submission

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

the class SubmissionManager method getSingleSubmission.

public static void getSingleSubmission(long courseId, long assignmentId, long studentId, @NonNull StatusCallback<Submission> callback, boolean forceNetwork) {
    if (isTesting() | mTesting) {
    // TODO
    } else {
        RestBuilder adapter = new RestBuilder(callback);
        RestParams params = new RestParams.Builder().withForceReadFromNetwork(forceNetwork).withPerPageQueryParam(false).build();
        SubmissionAPI.getSingleSubmission(courseId, assignmentId, studentId, adapter, callback, params);
    }
}
Also used : RestParams(com.instructure.canvasapi2.builders.RestParams) RestBuilder(com.instructure.canvasapi2.builders.RestBuilder)

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