Skip to content

Commit

Permalink
Merge pull request sakaiproject#910 from steveswinsburg/feature/SAK-2…
Browse files Browse the repository at this point in the history
…9734_set_cat_id

SAK-29734 allow setting category when adding/updating assignment
  • Loading branch information
steveswinsburg committed Jul 22, 2015
2 parents 3144e06 + 3d1fbf4 commit 4d1ddcd
Showing 1 changed file with 13 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -610,6 +610,12 @@ public Long addAssignment(String gradebookUid, org.sakaiproject.service.gradeboo
}

Gradebook gradebook = getGradebook(gradebookUid);

//if attaching to category
if(assignmentDefinition.getCategoryId() != null) {
return createAssignmentForCategory(gradebook.getId(), assignmentDefinition.getCategoryId(), assignmentDefinition.getName(), points, assignmentDefinition.getDueDate(), !assignmentDefinition.isCounted(), assignmentDefinition.isReleased(), assignmentDefinition.isExtraCredit());
}

return createAssignment(gradebook.getId(), assignmentDefinition.getName(), points, assignmentDefinition.getDueDate(), !assignmentDefinition.isCounted(), assignmentDefinition.isReleased(), assignmentDefinition.isExtraCredit());
}

Expand Down Expand Up @@ -643,6 +649,13 @@ public Object doInHibernate(Session session) throws HibernateException {
assignment.setPointsPossible(assignmentDefinition.getPoints());
assignment.setReleased(assignmentDefinition.isReleased());
assignment.setExtraCredit(assignmentDefinition.isExtraCredit());

//if we have a category, get it and set it
if (assignmentDefinition.getCategoryId() != null) {
Category cat = (Category) session.load(Category.class, assignmentDefinition.getCategoryId());
assignment.setCategory(cat);
}

updateAssignment(assignment, session);
return null;
}
Expand Down

0 comments on commit 4d1ddcd

Please sign in to comment.