Search in sources :

Example 11 with Submission

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

the class FileUtils method showPdfDocument.

public static void showPdfDocument(Uri uri, OpenMediaAsyncTaskLoader.LoadedMedia loadedMedia, final Context context) {
    if (!PSPDFKitPreferences.get(context).isAnnotationCreatorSet()) {
        User cachedUser = ApiPrefs.getUser();
        String userName = "";
        if (cachedUser != null) {
            userName = ApiPrefs.getUser().getShortName();
        }
        PSPDFKitPreferences.get(context).setAnnotationCreator(userName);
    }
    final PdfActivityConfiguration pspdfActivityConfiguration;
    if (loadedMedia.isSubmission()) {
        // We don't want to allow users to edit for submission viewing
        pspdfActivityConfiguration = new PdfActivityConfiguration.Builder(context).scrollDirection(PageScrollDirection.HORIZONTAL).showThumbnailGrid().setThumbnailBarMode(ThumbnailBarMode.THUMBNAIL_BAR_MODE_DEFAULT).disableAnnotationEditing().disableAnnotationList().disableDocumentEditor().fitMode(PageFitMode.FIT_TO_WIDTH).build();
    } else {
        // Standard behavior
        pspdfActivityConfiguration = new PdfActivityConfiguration.Builder(context).scrollDirection(PageScrollDirection.HORIZONTAL).showThumbnailGrid().setThumbnailBarMode(ThumbnailBarMode.THUMBNAIL_BAR_MODE_DEFAULT).enableDocumentEditor().enabledAnnotationTools(setupAnnotationCreationList()).editableAnnotationTypes(setupAnnotationEditList()).fitMode(PageFitMode.FIT_TO_WIDTH).build();
    }
    if (PSPDFKit.isOpenableUri(context, uri)) {
        Intent intent = PdfActivityIntentBuilder.fromUri(context, uri).configuration(pspdfActivityConfiguration).activityClass(CandroidPSPDFActivity.class).build();
        context.startActivity(intent);
    } else {
        // If we still can't open this PDF, we will then attempt to pass it off to the user's pdfviewer
        context.startActivity(loadedMedia.getIntent());
    }
}
Also used : CandroidPSPDFActivity(com.instructure.candroid.activity.CandroidPSPDFActivity) User(com.instructure.canvasapi2.models.User) Intent(android.content.Intent) PdfActivityConfiguration(com.pspdfkit.configuration.activity.PdfActivityConfiguration)

Example 12 with Submission

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

the class GradesListRecyclerAdapterTest method testAreContentsTheSame_SameWithSubmissionNullGrade.

@Test
public void testAreContentsTheSame_SameWithSubmissionNullGrade() {
    Assignment assignment1 = new Assignment();
    assignment1.setName("assignment");
    assignment1.setPointsPossible(0.0);
    Submission submission1 = new Submission();
    submission1.setGrade("A");
    assignment1.setSubmission(submission1);
    Assignment assignment2 = new Assignment();
    assignment2.setName("assignment1");
    assignment2.setPointsPossible(0.0);
    Submission submission2 = new Submission();
    submission1.setGrade(null);
    assignment1.setSubmission(submission2);
    assertFalse(mAdapter.createItemCallback().areContentsTheSame(assignment1, assignment2));
}
Also used : Assignment(com.instructure.canvasapi2.models.Assignment) Submission(com.instructure.canvasapi2.models.Submission) Test(org.junit.Test)

Example 13 with Submission

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

the class GradesListRecyclerAdapterTest method testAreContentsTheSame_SameWithSubmissionNullChange.

@Test
public void testAreContentsTheSame_SameWithSubmissionNullChange() {
    Assignment assignment1 = new Assignment();
    assignment1.setName("assignment");
    assignment1.setPointsPossible(0.0);
    Submission submission1 = new Submission();
    submission1.setGrade("A");
    assignment1.setSubmission(submission1);
    Assignment assignment2 = new Assignment();
    assignment2.setName("assignment1");
    assignment2.setPointsPossible(0.0);
    assignment2.setSubmission(null);
    assertFalse(mAdapter.createItemCallback().areContentsTheSame(assignment1, assignment2));
}
Also used : Assignment(com.instructure.canvasapi2.models.Assignment) Submission(com.instructure.canvasapi2.models.Submission) Test(org.junit.Test)

Example 14 with Submission

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

the class AssignmentAPI method getFirstPageSubmissionsForAssignment.

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

Example 15 with Submission

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

the class SubmissionManager_Test method updateRubricAssessment.

public static void updateRubricAssessment(long courseId, long assignmentId, long studentId, Map<String, RubricCriterionAssessment> assessmentMap, StatusCallback<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();
    Submission submission = new Submission();
    retrofit2.Response<Submission> response1 = retrofit2.Response.success(submission, 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)

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