Search in sources :

Example 1 with Assignment

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);
        }
    }
}
Also used : Assignment(com.instructure.canvasapi.model.Assignment) ToDo(com.instructure.canvasapi.model.ToDo) Gson(com.google.gson.Gson) Test(org.junit.Test)

Example 2 with Assignment

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);
    }
}
Also used : Assignment(com.instructure.canvasapi.model.Assignment) RubricCriterion(com.instructure.canvasapi.model.RubricCriterion) Gson(com.google.gson.Gson) Test(org.junit.Test)

Example 3 with Assignment

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());
}
Also used : Assignment(com.instructure.canvasapi.model.Assignment) MasteryPathAssignment(com.instructure.canvasapi.model.MasteryPathAssignment) Gson(com.google.gson.Gson) MasteryPathAssignment(com.instructure.canvasapi.model.MasteryPathAssignment) Test(org.junit.Test)

Example 4 with Assignment

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;
}
Also used : Assignment(com.instructure.canvasapi.model.Assignment) HomeActivity(com.instructure.speedgrader.activities.HomeActivity) AssignmentGroupListRecyclerAdapter(com.instructure.speedgrader.adapters.AssignmentGroupListRecyclerAdapter) AssignmentAdapterToFragmentCallback(com.instructure.speedgrader.interfaces.AssignmentAdapterToFragmentCallback) Section(com.instructure.canvasapi.model.Section)

Example 5 with Assignment

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);
}
Also used : Assignment(com.instructure.canvasapi.model.Assignment) HashMap(java.util.HashMap)

Aggregations

Assignment (com.instructure.canvasapi.model.Assignment)15 Gson (com.google.gson.Gson)7 Test (org.junit.Test)7 AssignmentGroup (com.instructure.canvasapi.model.AssignmentGroup)2 ToDo (com.instructure.canvasapi.model.ToDo)2 ArrayList (java.util.ArrayList)2 Date (java.util.Date)2 HashMap (java.util.HashMap)2 CheckBox (android.widget.CheckBox)1 AssignmentDueDate (com.instructure.canvasapi.model.AssignmentDueDate)1 LockInfo (com.instructure.canvasapi.model.LockInfo)1 LockedModule (com.instructure.canvasapi.model.LockedModule)1 MasteryPathAssignment (com.instructure.canvasapi.model.MasteryPathAssignment)1 ModuleCompletionRequirement (com.instructure.canvasapi.model.ModuleCompletionRequirement)1 RubricCriterion (com.instructure.canvasapi.model.RubricCriterion)1 ScheduleItem (com.instructure.canvasapi.model.ScheduleItem)1 Section (com.instructure.canvasapi.model.Section)1 HomeActivity (com.instructure.speedgrader.activities.HomeActivity)1 AssignmentGroupListRecyclerAdapter (com.instructure.speedgrader.adapters.AssignmentGroupListRecyclerAdapter)1 AssignmentAdapterToFragmentCallback (com.instructure.speedgrader.interfaces.AssignmentAdapterToFragmentCallback)1