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);
}
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());
}
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());
}
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);
}
}
});
}
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;
}
Aggregations