use of com.instructure.canvasapi.model.Assignment in project instructure-android by instructure.
the class TodoUnitTest method testToDo.
@Test
public void testToDo() {
Gson gson = CanvasRestAdapter.getGSONParser();
ToDo[] toDoList = gson.fromJson(todoJSON, ToDo[].class);
assertNotNull(toDoList);
for (ToDo toDo : toDoList) {
assertNotNull(toDo);
assertNotNull(toDo.getType());
assertNotNull(toDo.getTitle());
assertNotNull(toDo.getHtmlUrl());
assertNotNull(toDo.getIgnore());
assertNotNull(toDo.getIgnorePermanently());
if (toDo.getAssignment() != null) {
Assignment assignment = toDo.getAssignment();
assertTrue(assignment.getId() > 0);
}
}
}
use of com.instructure.canvasapi.model.Assignment in project instructure-android by instructure.
the class AssignmentUnitTest method testRubricAssignment.
@Test
public void testRubricAssignment() {
Gson gson = CanvasRestAdapter.getGSONParser();
Assignment rubricAssignment = gson.fromJson(rubricAssignmentJSON, Assignment.class);
assertNotNull(rubricAssignment.getRubric());
List<RubricCriterion> rubricCriterions = rubricAssignment.getRubric();
assertEquals(rubricCriterions.size(), 3);
for (RubricCriterion rubricCriterion : rubricCriterions) {
testRubricCriterion(rubricCriterion);
}
}
use of com.instructure.canvasapi.model.Assignment in project instructure-android by instructure.
the class MasteryPathAssignmentUnitTest method testMasteryPathAssignment.
@Test
public void testMasteryPathAssignment() {
Gson gson = CanvasRestAdapter.getGSONParser();
MasteryPathAssignment[] masteryPathAssignments = gson.fromJson(masteryPathAssignmentJSON, MasteryPathAssignment[].class);
assertNotNull(masteryPathAssignments);
assertTrue(masteryPathAssignments.length > 0);
assertNotNull(masteryPathAssignments[0].getAssignment());
// check the assignment
Assignment assignment = masteryPathAssignments[0].getAssignment();
assertTrue(assignment.getId() == 5);
assertTrue(assignment.getPointsPossible() == 0);
assertNotNull(assignment.getSubmissionTypes());
}
use of com.instructure.canvasapi.model.Assignment in project instructure-android by instructure.
the class AssignmentListFragment method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
super.onCreateView(inflater, container, savedInstanceState);
if (savedInstanceState != null) {
loadSavedInstanceState(savedInstanceState);
}
mAdapterToFragmentCallback = new AssignmentAdapterToFragmentCallback() {
@Override
public void onRowClicked(Assignment assignment) {
if (mSectionsSpinner.getSelectedItem() != null) {
startActivityForResult(DocumentActivity.createIntent(getContext(), getCanvasContext(), assignment, ((Section) mSectionsSpinner.getSelectedItem()).getId()), Const.UPDATED_ASSIGNMENT_FLAGS);
} else {
startActivityForResult(DocumentActivity.createIntent(getContext(), getCanvasContext(), assignment, getAllSectionsItem().getId()), Const.UPDATED_ASSIGNMENT_FLAGS);
}
}
@Override
public void onRefreshFinished() {
setRefreshing(false);
}
@Override
public Section getCurrentSection() {
if (mSectionsSpinner == null || mSectionsSpinner.getSelectedItem() == null) {
return getAllSectionsItem();
}
return (Section) mSectionsSpinner.getSelectedItem();
}
@Override
public void onSectionsLoaded(List<Section> sections) {
if (!isAdded()) {
return;
}
mSections = sections;
if (mSectionsSpinner != null) {
createSectionsSpinner();
}
}
};
if (mRecyclerAdapter == null) {
mRecyclerAdapter = new AssignmentGroupListRecyclerAdapter(getContext(), getCanvasContext(), mAdapterToFragmentCallback);
}
if (getActivity() instanceof HomeActivity) {
((HomeActivity) getActivity()).hideDrawer();
}
handleActionBarColor();
setTitle(getCanvasContext().getName());
configureRecyclerViewAsGrid(mRootView, mRecyclerAdapter, R.id.swipeRefreshLayout, R.id.emptyPandaView, R.id.listView);
if (isRouting) {
isRouting = false;
startActivityForResult(DocumentActivity.createIntent(getContext(), getCanvasContext(), mRoutedAssignment, getAllSectionsItem().getId()), Const.UPDATED_ASSIGNMENT_FLAGS);
getActivity().overridePendingTransition(R.anim.slide_in_right, R.anim.slide_out_left);
}
return mRootView;
}
use of com.instructure.canvasapi.model.Assignment in project instructure-android by instructure.
the class AssignmentListFragment method onActivityResult.
/**
* If changes are made to the assignment by the user inside the EditAssignmentFragment, we update that assignment to reflect new changes.
* @param requestCode
* @param resultCode
* @param data
*/
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == Const.UPDATED_ASSIGNMENT_FLAGS && data != null && mAssignments != null) {
HashMap<Long, Assignment> mUpdatedAssignments = (HashMap) data.getSerializableExtra(Const.UPDATED_ASSIGNMENTS);
final Set<Long> keys = mUpdatedAssignments.keySet();
for (Long assignmentId : keys) {
Assignment assignment = mUpdatedAssignments.get(assignmentId);
mRecyclerAdapter.addOrUpdateItem(mRecyclerAdapter.getGroup(assignment.getAssignmentGroupId()), assignment);
}
}
super.onActivityResult(requestCode, resultCode, data);
}
Aggregations