Search in sources :

Example 6 with QuizSubmissionResponse

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

the class QuizManager method startQuiz.

public static void startQuiz(CanvasContext canvasContext, long quizId, boolean forceNetwork, final StatusCallback<QuizSubmissionResponse> callback) {
    final RestBuilder adapter = new RestBuilder(callback);
    final RestParams params = new RestParams.Builder().withPerPageQueryParam(true).withShouldIgnoreToken(false).withForceReadFromNetwork(forceNetwork).build();
    QuizAPI.startQuiz(canvasContext, quizId, adapter, params, callback);
}
Also used : RestParams(com.instructure.canvasapi2.builders.RestParams) RestBuilder(com.instructure.canvasapi2.builders.RestBuilder) RestBuilder(com.instructure.canvasapi2.builders.RestBuilder)

Example 7 with QuizSubmissionResponse

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

the class QuizManager method getAllQuizSubmissions.

public static void getAllQuizSubmissions(final CanvasContext canvasContext, final long quizId, final boolean forceNetwork, final StatusCallback<List<QuizSubmission>> callback) {
    if (isTesting() || mTesting) {
        QuizManager_Test.getAllQuizSubmissions(callback);
    } else {
        final RestBuilder adapter = new RestBuilder(callback);
        final RestParams params = new RestParams.Builder().withPerPageQueryParam(true).withShouldIgnoreToken(false).withForceReadFromNetwork(forceNetwork).build();
        final ExhaustiveCallback<QuizSubmissionResponse, QuizSubmission> paginatedCallback = new ExhaustiveCallback<QuizSubmissionResponse, QuizSubmission>(callback) {

            @Override
            public void getNextPage(@NotNull StatusCallback<QuizSubmissionResponse> callback, @NotNull String nextUrl, boolean isCached) {
                QuizAPI.getQuizSubmissions(canvasContext, quizId, adapter, callback, params);
            }

            @NotNull
            @Override
            public List<QuizSubmission> extractItems(QuizSubmissionResponse response) {
                return response.getQuizSubmissions();
            }
        };
        adapter.setStatusCallback(paginatedCallback);
        QuizAPI.getQuizSubmissions(canvasContext, quizId, adapter, paginatedCallback, params);
    }
}
Also used : QuizSubmission(com.instructure.canvasapi2.models.QuizSubmission) RestParams(com.instructure.canvasapi2.builders.RestParams) RestBuilder(com.instructure.canvasapi2.builders.RestBuilder) RestBuilder(com.instructure.canvasapi2.builders.RestBuilder) StatusCallback(com.instructure.canvasapi2.StatusCallback) NotNull(org.jetbrains.annotations.NotNull) ExhaustiveCallback(com.instructure.canvasapi2.utils.ExhaustiveCallback) QuizSubmissionResponse(com.instructure.canvasapi2.models.QuizSubmissionResponse)

Example 8 with QuizSubmissionResponse

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

the class QuizManager method postQuizSubmit.

public static void postQuizSubmit(CanvasContext canvasContext, QuizSubmission quizSubmission, boolean forceNetwork, final StatusCallback<QuizSubmissionResponse> callback) {
    final RestBuilder adapter = new RestBuilder(callback);
    final RestParams params = new RestParams.Builder().withPerPageQueryParam(true).withShouldIgnoreToken(false).withForceReadFromNetwork(forceNetwork).build();
    QuizAPI.postQuizSubmit(canvasContext, quizSubmission, adapter, params, callback);
}
Also used : RestParams(com.instructure.canvasapi2.builders.RestParams) RestBuilder(com.instructure.canvasapi2.builders.RestBuilder) RestBuilder(com.instructure.canvasapi2.builders.RestBuilder)

Example 9 with QuizSubmissionResponse

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

the class QuizManager method getQuizSubmissions.

public static void getQuizSubmissions(CanvasContext canvasContext, long quizId, final boolean forceNetwork, StatusCallback<QuizSubmissionResponse> callback) {
    if (isTesting() || mTesting) {
        QuizManager_Test.getQuizSubmissions(callback);
    } else {
        RestBuilder adapter = new RestBuilder(callback);
        RestParams params = new RestParams.Builder().withPerPageQueryParam(true).withShouldIgnoreToken(false).withForceReadFromNetwork(forceNetwork).build();
        QuizAPI.getQuizSubmissions(canvasContext, quizId, adapter, callback, params);
    }
}
Also used : RestParams(com.instructure.canvasapi2.builders.RestParams) RestBuilder(com.instructure.canvasapi2.builders.RestBuilder) RestBuilder(com.instructure.canvasapi2.builders.RestBuilder)

Example 10 with QuizSubmissionResponse

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

the class QuizManager method startQuizPreview.

public static void startQuizPreview(long courseId, long quizId, boolean forceNetwork, StatusCallback<QuizSubmissionResponse> callback) {
    if (isTesting() || mTesting) {
        QuizManager_Test.startQuizPreview(courseId, quizId, callback);
    } else {
        RestBuilder adapter = new RestBuilder(callback);
        RestParams params = new RestParams.Builder().withPerPageQueryParam(true).withShouldIgnoreToken(false).withForceReadFromNetwork(forceNetwork).build();
        QuizAPI.startQuizPreview(courseId, quizId, adapter, callback, params);
    }
}
Also used : RestParams(com.instructure.canvasapi2.builders.RestParams) RestBuilder(com.instructure.canvasapi2.builders.RestBuilder) RestBuilder(com.instructure.canvasapi2.builders.RestBuilder)

Aggregations

RestBuilder (com.instructure.canvasapi2.builders.RestBuilder)7 RestParams (com.instructure.canvasapi2.builders.RestParams)7 QuizSubmissionResponse (com.instructure.canvasapi2.models.QuizSubmissionResponse)6 LinkHeaders (com.instructure.canvasapi2.utils.LinkHeaders)5 QuizSubmission (com.instructure.canvasapi2.models.QuizSubmission)4 QuizSubmissionQuestionResponse (com.instructure.canvasapi2.models.QuizSubmissionQuestionResponse)4 ArrayList (java.util.ArrayList)4 StatusCallback (com.instructure.canvasapi2.StatusCallback)3 ApiType (com.instructure.canvasapi2.utils.ApiType)3 NonNull (android.support.annotation.NonNull)2 QuizSubmissionTime (com.instructure.canvasapi2.models.QuizSubmissionTime)2 Response (okhttp3.Response)2 Response (retrofit2.Response)2 Activity (android.app.Activity)1 Bundle (android.os.Bundle)1 Nullable (android.support.annotation.Nullable)1 Fragment (android.support.v4.app.Fragment)1 FragmentActivity (android.support.v4.app.FragmentActivity)1 WebView (android.webkit.WebView)1 NavigationActivity (com.instructure.candroid.activity.NavigationActivity)1