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