Search in sources :

Example 16 with Submission

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

the class SubmissionManager_Test method postSubmissionComment.

public static void postSubmissionComment(long courseId, long assignmentId, long userId, String commentText, boolean isGroupMessage, 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)

Example 17 with Submission

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

the class AssignmentTest method getLastActualSubmission_TestWorkFlowSubmitted.

@Test
public void getLastActualSubmission_TestWorkFlowSubmitted() {
    Assignment assignment = new Assignment();
    Submission submission = new Submission();
    submission.setWorkflowState("submitted");
    assignment.setSubmission(submission);
    assertEquals(submission, assignment.getLastActualSubmission());
}
Also used : Assignment(com.instructure.canvasapi2.models.Assignment) Submission(com.instructure.canvasapi2.models.Submission) Test(org.junit.Test)

Example 18 with Submission

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

the class AssignmentTest method getLastActualSubmission_TestNullWorkFlow.

@Test
public void getLastActualSubmission_TestNullWorkFlow() {
    Assignment assignment = new Assignment();
    Submission submission = new Submission();
    submission.setWorkflowState(null);
    assignment.setSubmission(submission);
    assertEquals(null, assignment.getLastActualSubmission());
}
Also used : Assignment(com.instructure.canvasapi2.models.Assignment) Submission(com.instructure.canvasapi2.models.Submission) Test(org.junit.Test)

Example 19 with Submission

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

the class GradesListFragment method configureViews.

public void configureViews(View rootView) {
    // Not handled automatically as we cast from canvasContext;
    if (course == null) {
        return;
    }
    termSpinner = rootView.findViewById(R.id.termSpinner);
    AppBarLayout appBarLayout = rootView.findViewById(R.id.appbar);
    totalGradeView = rootView.findViewById(R.id.txtOverallGrade);
    showBasedOnGradedAssignmentsCB = rootView.findViewById(R.id.showTotalCheckBox);
    showWhatIfCheckbox = rootView.findViewById(R.id.showWhatIfCheckBox);
    toggleGradeView = rootView.findViewById(R.id.grade_toggle_view);
    toggleWhatIfScores = rootView.findViewById(R.id.what_if_view);
    Drawable lockDrawable = ColorKeeper.getColoredDrawable(getContext(), R.drawable.vd_lock, getResources().getColor(R.color.canvasTextDark));
    lockedGradeImage = rootView.findViewById(R.id.lockedGradeImage);
    lockedGradeImage.setImageDrawable(lockDrawable);
    setupListeners();
    lockGrade(course.isHideFinalGrades());
    dialogStyled = new WhatIfDialogStyled.WhatIfDialogCallback() {

        @Override
        public void onOkayClick(String whatIf, double total, Assignment assignment, int position) {
            // Create dummy submission for what if grade
            Submission s = new Submission();
            // check to see if grade is empty for reset
            if (TextUtils.isEmpty(whatIf)) {
                assignment.setSubmission(null);
                recyclerAdapter.getAssignmentsHash().get(assignment.getId()).setSubmission(null);
            } else {
                s.setScore(Double.parseDouble(whatIf));
                s.setGrade(whatIf);
                recyclerAdapter.getAssignmentsHash().get(assignment.getId()).setSubmission(s);
            }
            recyclerAdapter.notifyItemChanged(position);
            // Compute new overall grade
            new ComputeGradesTask(showBasedOnGradedAssignmentsCB.isChecked()).execute();
        }
    };
    appBarLayout.addOnOffsetChangedListener(new AppBarLayout.OnOffsetChangedListener() {

        @Override
        public void onOffsetChanged(AppBarLayout appBarLayout, int i) {
            // workaround for Toolbar not showing with swipe to refresh
            if (i == 0) {
                setRefreshingEnabled(true);
            } else {
                setRefreshingEnabled(false);
            }
        }
    });
}
Also used : WhatIfDialogStyled(com.instructure.candroid.dialog.WhatIfDialogStyled) Assignment(com.instructure.canvasapi2.models.Assignment) Submission(com.instructure.canvasapi2.models.Submission) Drawable(android.graphics.drawable.Drawable) AppBarLayout(android.support.design.widget.AppBarLayout)

Example 20 with Submission

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

the class NotificationListFragment method addFragmentForStreamItem.

public static DialogFragment addFragmentForStreamItem(StreamItem streamItem, FragmentActivity activity, boolean fromWidget) {
    ParentFragment fragment = null;
    if (streamItem == null || activity == null) {
        return null;
    }
    String unsupportedLabel = null;
    switch(streamItem.getType()) {
        case SUBMISSION:
            if (streamItem.getAssignment() == null && streamItem.getCanvasContext() instanceof Course) {
                fragment = FragUtils.getFrag(AssignmentFragment.class, AssignmentFragment.Companion.createBundle(streamItem.getCanvasContext(), streamItem.getAssignmentId()));
            } else if (streamItem.getAssignment() != null && streamItem.getCanvasContext() instanceof Course) {
                // add an empty submission with the grade to the assignment so that we can see the score.
                Submission emptySubmission = new Submission();
                emptySubmission.setGrade(streamItem.getGrade());
                streamItem.getAssignment().setSubmission(emptySubmission);
                fragment = FragUtils.getFrag(AssignmentFragment.class, AssignmentFragment.Companion.createBundle((Course) streamItem.getCanvasContext(), streamItem.getAssignment()));
            }
            break;
        case ANNOUNCEMENT:
            if (streamItem.getCanvasContext() != null) {
                fragment = FragUtils.getFrag(DiscussionDetailsFragment.class, DiscussionDetailsFragment.makeBundle(streamItem.getCanvasContext(), streamItem.getDiscussionTopicId(), true));
            }
            break;
        case CONVERSATION:
            Conversation conversation = streamItem.getConversation();
            if (conversation != null) {
                // Check to see if the conversation has been deleted.
                if (conversation.isDeleted()) {
                    Toast.makeText(activity, R.string.deleteConversation, Toast.LENGTH_SHORT).show();
                    return null;
                }
                Bundle extras = InboxConversationFragment.createBundle(conversation, 0, null);
                fragment = FragUtils.getFrag(InboxConversationFragment.class, extras);
            }
            break;
        case DISCUSSION_TOPIC:
            if (streamItem.getCanvasContext() != null) {
                fragment = FragUtils.getFrag(DiscussionDetailsFragment.class, DiscussionDetailsFragment.makeBundle(streamItem.getCanvasContext(), streamItem.getDiscussionTopicId(), false));
            }
            break;
        case MESSAGE:
            if (streamItem.getAssignmentId() > 0) {
                if (streamItem.getCanvasContext() != null) {
                    fragment = FragUtils.getFrag(AssignmentFragment.class, AssignmentFragment.Companion.createBundle(activity, streamItem.getCanvasContext(), streamItem.getAssignmentId(), streamItem));
                }
            } else {
                fragment = FragUtils.getFrag(UnknownItemFragment.class, UnknownItemFragment.createBundle(streamItem.getCanvasContext(), streamItem));
            }
            break;
        case COLLABORATION:
            if (streamItem.getCanvasContext() != null) {
                unsupportedLabel = activity.getString(R.string.collaborations);
                fragment = UnSupportedTabFragment.createFragment(UnSupportedTabFragment.class, UnSupportedTabFragment.createBundle(streamItem.getCanvasContext(), Tab.COLLABORATIONS_ID, R.string.collaborations));
            }
            break;
        case CONFERENCE:
            if (streamItem.getCanvasContext() != null) {
                unsupportedLabel = activity.getString(R.string.conferences);
                fragment = UnSupportedTabFragment.createFragment(UnSupportedTabFragment.class, UnSupportedTabFragment.createBundle(streamItem.getCanvasContext(), Tab.CONFERENCES_ID, R.string.conferences));
            }
            break;
        default:
            if (streamItem.getCanvasContext() != null) {
                unsupportedLabel = streamItem.getType().toString();
                fragment = FragUtils.getFrag(UnSupportedFeatureFragment.class, UnSupportedFeatureFragment.createBundle(streamItem.getCanvasContext(), unsupportedLabel, streamItem.getUrl()));
            }
            break;
    }
    if (unsupportedLabel != null) {
        if (activity instanceof Navigation) {
            ((Navigation) activity).addFragment(fragment);
        }
    } else {
        if (activity instanceof Navigation && fragment != null) {
            ((Navigation) activity).addFragment(fragment);
        }
        if (fromWidget) {
            if (streamItem.getUrl() != null) {
                RouterUtils.routeUrl(activity, streamItem.getUrl(), false);
            } else {
                RouterUtils.routeUrl(activity, streamItem.getHtmlUrl(), false);
            }
        }
    }
    return null;
}
Also used : Navigation(com.instructure.interactions.Navigation) Submission(com.instructure.canvasapi2.models.Submission) Bundle(android.os.Bundle) Conversation(com.instructure.canvasapi2.models.Conversation) Course(com.instructure.canvasapi2.models.Course)

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