use of com.instructure.canvasapi2.models.Assignment in project instructure-android by instructure.
the class AssignmentManager method getAssignmentAirwolf.
public static void getAssignmentAirwolf(@NonNull String airwolfDomain, @NonNull String parentId, @NonNull String studentId, @NonNull String courseId, @NonNull String assignmentId, @NonNull StatusCallback<Assignment> callback) {
RestBuilder adapter = new RestBuilder(callback);
RestParams params = new RestParams.Builder().withShouldIgnoreToken(false).withPerPageQueryParam(false).withDomain(airwolfDomain).withAPIVersion("").build();
AssignmentAPI.getAssignmentAirwolf(parentId, studentId, courseId, assignmentId, adapter, callback, params);
}
use of com.instructure.canvasapi2.models.Assignment 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.Assignment 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;
}
use of com.instructure.canvasapi2.models.Assignment in project instructure-android by instructure.
the class AssignmentManager_Test method getAllAssignments.
public static void getAllAssignments(long courseId, StatusCallback<List<Assignment>> callback) {
// TODO:
Response httpResponse = 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<Assignment> assignments = new ArrayList<>();
retrofit2.Response<List<Assignment>> response = retrofit2.Response.success(assignments, httpResponse);
callback.onResponse(response, new LinkHeaders(), ApiType.CACHE);
}
use of com.instructure.canvasapi2.models.Assignment in project instructure-android by instructure.
the class AssignmentManager_Test method getAssignment.
public static void getAssignment(long assignmentId, long courseId, StatusCallback<Assignment> callback) {
// TODO:
Response httpResponse = 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();
Assignment assignment = new Assignment();
retrofit2.Response<Assignment> response = retrofit2.Response.success(assignment, httpResponse);
callback.onResponse(response, new LinkHeaders(), ApiType.CACHE);
}
Aggregations