Search in sources :

Example 11 with Assignment

use of com.instructure.canvasapi.model.Assignment in project instructure-android by instructure.

the class ScheduleItemUnitTest method testScheduleItemAssignment.

@Test
public void testScheduleItemAssignment() {
    Gson gson = CanvasRestAdapter.getGSONParser();
    Assignment[] assignments = gson.fromJson(scheduleItemAssignmentJSON, Assignment[].class);
    assertNotNull(assignments);
    for (Assignment assignment : assignments) {
        ScheduleItem scheduleItem = assignment.toScheduleItem();
        assertNotNull(scheduleItem);
        assertTrue(scheduleItem.getId() > 0);
        assertNotNull(scheduleItem.getTitle());
        assertNotNull(scheduleItem.getType());
    }
}
Also used : Assignment(com.instructure.canvasapi.model.Assignment) ScheduleItem(com.instructure.canvasapi.model.ScheduleItem) Gson(com.google.gson.Gson) Test(org.junit.Test)

Example 12 with Assignment

use of com.instructure.canvasapi.model.Assignment in project instructure-android by instructure.

the class RubricFragment method getBundleDataWithCache.

public void getBundleDataWithCache(Bundle bundle) {
    super.getBundleData(bundle);
    // Since the markGrades method will alter the rubric on an mAssignment. We need to copy the mAssignment, so that grading a mSubmission will not affect others
    Assignment newAssignment = bundle.getParcelable(Const.assignment);
    mOriginalAssignment = SerializationUtils.clone(newAssignment);
    ;
    mAssignment = SerializationUtils.clone(newAssignment);
    mSubmission = bundle.getParcelable(Const.submission);
    mAssignment.setLastSubmission(mSubmission);
    originalRubricAssessment = SerializationUtils.clone(mSubmission.getRubricAssessment());
}
Also used : Assignment(com.instructure.canvasapi.model.Assignment)

Example 13 with Assignment

use of com.instructure.canvasapi.model.Assignment in project instructure-android by instructure.

the class AssignmentGroupListRecyclerAdapter method populateAdapter.

private void populateAdapter(List<Assignment> assignments, List<AssignmentGroup> assignmentGroups) {
    // wait for all api calls to return
    if (assignmentGroups.size() == 0 || assignments.size() == 0) {
        return;
    }
    for (Assignment assignment : assignments) {
        // put the mAssignments into assignment groups
        AssignmentGroup assignmentGroup = mAssignmentGroupsHash.get(assignment.getAssignmentGroupId());
        if (assignmentGroup != null) {
            addOrUpdateItem(assignmentGroup, assignment);
        }
    }
    if (isAssignmentsLoaded && isGroupsLoaded) {
        mAdapterToFragmentCallback.onRefreshFinished();
        setAllPagesLoaded(true);
    }
}
Also used : Assignment(com.instructure.canvasapi.model.Assignment) AssignmentGroup(com.instructure.canvasapi.model.AssignmentGroup)

Example 14 with Assignment

use of com.instructure.canvasapi.model.Assignment in project instructure-android by instructure.

the class EditAssignmentDialog method saveData.

public void saveData() {
    // disable save, show our progress
    disableSave();
    String editedAssignmentTitle = assignmentTitleET.getText().toString();
    Date editedDueAt = dueDateDT.getDate();
    boolean shouldNotifyUsers = notifyUsers.isChecked();
    Double editedPointsPossible = Double.parseDouble(pointsPossibleET.getText().toString());
    String editedAssignmentGroupString = (String) assignmentGroupSpinner.getSelectedItem();
    Long editedAssignmentGroup = null;
    for (AssignmentGroup group : assignmentGroups) {
        if (editedAssignmentGroupString.equals(group.getName())) {
            editedAssignmentGroup = group.getId();
            break;
        }
    }
    Assignment.GRADING_TYPE editedGradingType = Assignment.getGradingTypeFromString((String) gradingTypeSpinner.getSelectedItem(), getActivity());
    Assignment.SUBMISSION_TYPE[] editedSubmissionTypes;
    Assignment.TURN_IN_TYPE editedTurnInType = Assignment.stringToTurnInType((String) turnInTypeSpinner.getSelectedItem(), getActivity());
    if (editedTurnInType == Assignment.TURN_IN_TYPE.ONLINE) {
        ArrayList<Assignment.SUBMISSION_TYPE> newSubmissionTypes = new ArrayList<Assignment.SUBMISSION_TYPE>();
        for (CheckBox checkbox : submissionTypesArrayList) {
            if (checkbox.isChecked()) {
                newSubmissionTypes.add((Assignment.SUBMISSION_TYPE) checkbox.getTag());
            }
        }
        editedSubmissionTypes = newSubmissionTypes.toArray(new Assignment.SUBMISSION_TYPE[newSubmissionTypes.size()]);
    } else if (editedTurnInType == Assignment.TURN_IN_TYPE.ON_PAPER) {
        editedSubmissionTypes = new Assignment.SUBMISSION_TYPE[1];
        editedSubmissionTypes[0] = Assignment.SUBMISSION_TYPE.ON_PAPER;
    } else if (editedTurnInType == Assignment.TURN_IN_TYPE.NONE) {
        editedSubmissionTypes = new Assignment.SUBMISSION_TYPE[1];
        editedSubmissionTypes[0] = Assignment.SUBMISSION_TYPE.NONE;
    } else {
        editedSubmissionTypes = null;
    }
    assignment.setName(editedAssignmentTitle);
    assignment.setAssignmentGroupId(editedAssignmentGroup);
    if (editedSubmissionTypes != null) {
        assignment.setSubmissionTypes(editedSubmissionTypes);
    }
    assignment.setPointsPossible(editedPointsPossible);
    assignment.setGradingType(editedGradingType);
    assignment.setDueDate(editedDueAt);
    assignment.setMuted(mutedCheckBox.isChecked());
    AssignmentAPI.editAssignment(assignment, shouldNotifyUsers, assignmentCanvasCallback);
}
Also used : AssignmentGroup(com.instructure.canvasapi.model.AssignmentGroup) ArrayList(java.util.ArrayList) Date(java.util.Date) Assignment(com.instructure.canvasapi.model.Assignment) CheckBox(android.widget.CheckBox)

Example 15 with Assignment

use of com.instructure.canvasapi.model.Assignment in project instructure-android by instructure.

the class GradingDrawerFragment method getBundleData.

// /////////////////////////////////////////////////////////////////////////
// Intent Stuff
// /////////////////////////////////////////////////////////////////////////
@Override
public void getBundleData(Bundle bundle) {
    super.getBundleData(bundle);
    course = bundle.getParcelable(Const.canvasContext);
    // Copy the assignment
    Assignment newAssignment = bundle.getParcelable(Const.assignment);
    this.assignment = SerializationUtils.clone(newAssignment);
    this.submission = bundle.getParcelable(Const.submission);
    this.assignment.setLastSubmission(this.submission);
    this.rubricFragmentTag = bundle.getString(Const.RUBRIC_FRAGMENT_TAG);
    this.commentsFragmentTag = bundle.getString(Const.COMMENTS_FRAGMENT_TAG);
}
Also used : Assignment(com.instructure.canvasapi.model.Assignment)

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