Search in sources :

Example 1 with GradeableStudent

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

the class AssignmentAPI method getFirstPageGradeableStudentsForAssignment.

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

Example 2 with GradeableStudent

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

the class AssignmentAPI method getNextPageGradeableStudents.

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

Example 3 with GradeableStudent

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

the class AssignmentManager method getAllGradeableStudentsForAssignment.

public static void getAllGradeableStudentsForAssignment(long courseId, long assignmentId, final boolean forceNetwork, StatusCallback<List<GradeableStudent>> callback) {
    if (isTesting() || mTesting) {
        AssignmentManager_Test.getAllGradeableStudentsForAssignment(courseId, assignmentId, callback);
    } else {
        final RestBuilder adapter = new RestBuilder(callback);
        StatusCallback<List<GradeableStudent>> depaginatedCallback = new ExhaustiveListCallback<GradeableStudent>(callback) {

            @Override
            public void getNextPage(@NotNull StatusCallback<List<GradeableStudent>> callback, @NotNull String nextUrl, boolean isCached) {
                AssignmentAPI.getNextPageGradeableStudents(forceNetwork, nextUrl, adapter, callback);
            }
        };
        adapter.setStatusCallback(depaginatedCallback);
        AssignmentAPI.getFirstPageGradeableStudentsForAssignment(courseId, assignmentId, adapter, depaginatedCallback);
    }
}
Also used : GradeableStudent(com.instructure.canvasapi2.models.GradeableStudent) RestBuilder(com.instructure.canvasapi2.builders.RestBuilder) List(java.util.List) StatusCallback(com.instructure.canvasapi2.StatusCallback) ExhaustiveListCallback(com.instructure.canvasapi2.utils.ExhaustiveListCallback) NotNull(org.jetbrains.annotations.NotNull)

Example 4 with GradeableStudent

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

the class AssignmentManager_Test method getAllGradeableStudentsForAssignment.

public static void getAllGradeableStudentsForAssignment(long courseId, long assignmentId, StatusCallback<List<GradeableStudent>> callback) {
    // TODO:
    Response httpResponse = new Response.Builder().request(new Request.Builder().url("https://test.com").build()).code(200).message("todo").protocol(Protocol.HTTP_1_0).body(ResponseBody.create(MediaType.parse("application/json"), "todo".getBytes())).addHeader("content-type", "application/json").build();
    List<GradeableStudent> students = new ArrayList<>();
    retrofit2.Response<List<GradeableStudent>> response = retrofit2.Response.success(students, httpResponse);
    callback.onResponse(response, new LinkHeaders(), ApiType.CACHE);
}
Also used : Response(okhttp3.Response) GradeableStudent(com.instructure.canvasapi2.models.GradeableStudent) LinkHeaders(com.instructure.canvasapi2.utils.LinkHeaders) Request(okhttp3.Request) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List)

Aggregations

RestBuilder (com.instructure.canvasapi2.builders.RestBuilder)2 RestParams (com.instructure.canvasapi2.builders.RestParams)2 GradeableStudent (com.instructure.canvasapi2.models.GradeableStudent)2 List (java.util.List)2 StatusCallback (com.instructure.canvasapi2.StatusCallback)1 ExhaustiveListCallback (com.instructure.canvasapi2.utils.ExhaustiveListCallback)1 LinkHeaders (com.instructure.canvasapi2.utils.LinkHeaders)1 ArrayList (java.util.ArrayList)1 Request (okhttp3.Request)1 Response (okhttp3.Response)1 NotNull (org.jetbrains.annotations.NotNull)1