Search in sources :

Example 36 with Submission

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

the class SubmissionManager_Test method getStudentSubmissionsForCourse.

public static void getStudentSubmissionsForCourse(long studentId, long courseId, StatusCallback<List<Submission>> callback) {
    // TODO:
    Response response = 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<Submission> submissions = new ArrayList<>();
    retrofit2.Response<List<Submission>> response1 = retrofit2.Response.success(submissions, response);
    callback.onResponse(response1, new LinkHeaders(), ApiType.CACHE);
}
Also used : Response(okhttp3.Response) Submission(com.instructure.canvasapi2.models.Submission) LinkHeaders(com.instructure.canvasapi2.utils.LinkHeaders) Request(okhttp3.Request) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List)

Example 37 with Submission

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

the class AssignmentTest method isWithoutGradedSubmission_TestTrueNotNull.

@Test
public void isWithoutGradedSubmission_TestTrueNotNull() {
    Assignment assignment = new Assignment();
    Submission submission = new Submission();
    submission.setWorkflowState("submitted");
    submission.setGrade(null);
    submission.setSubmissionType(null);
    assignment.setSubmission(submission);
    assertEquals(true, assignment.isWithoutGradedSubmission());
}
Also used : Assignment(com.instructure.canvasapi2.models.Assignment) Submission(com.instructure.canvasapi2.models.Submission) Test(org.junit.Test)

Example 38 with Submission

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

the class AssignmentTest method isWithoutGradedSubmission_TestFalse.

@Test
public void isWithoutGradedSubmission_TestFalse() {
    Assignment assignment = new Assignment();
    Submission submission = new Submission();
    submission.setWorkflowState("submitted");
    submission.setGrade("A");
    submission.setSubmissionType("Online_Quiz");
    assignment.setSubmission(submission);
    assertEquals(false, assignment.isWithoutGradedSubmission());
}
Also used : Assignment(com.instructure.canvasapi2.models.Assignment) Submission(com.instructure.canvasapi2.models.Submission) Test(org.junit.Test)

Example 39 with Submission

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

the class SubmissionManager method postTextSubmission.

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

Example 40 with Submission

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

the class SubmissionManager method postUrlSubmission.

public static void postUrlSubmission(CanvasContext canvasContext, long assignmentId, String url, boolean isLti, StatusCallback<Submission> callback) {
    if (isTesting() || mTesting) {
    // TODO
    } else {
        RestBuilder adapter = new RestBuilder(callback);
        RestParams params = new RestParams.Builder().withCanvasContext(canvasContext).build();
        String type = isLti ? "basic_lti_launch" : "online_url";
        SubmissionAPI.postUrlSubmission(canvasContext.getId(), assignmentId, type, url, adapter, params, callback);
    }
}
Also used : RestParams(com.instructure.canvasapi2.builders.RestParams) RestBuilder(com.instructure.canvasapi2.builders.RestBuilder) 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