Index: assignment-api/api/src/java/org/sakaiproject/assignment/api/model/AssignmentSupplementItemService.java =================================================================== --- assignment-api/api/src/java/org/sakaiproject/assignment/api/model/AssignmentSupplementItemService.java (revision 123299) +++ assignment-api/api/src/java/org/sakaiproject/assignment/api/model/AssignmentSupplementItemService.java (working copy) @@ -50,6 +50,20 @@ */ public List getAttachmentListForSupplementItem(AssignmentSupplementItemWithAttachment item); + /** + * reset the attachment list + * @param item + * @return + */ + public boolean cleanAttachment(AssignmentSupplementItemWithAttachment item); + + /** + * remove the AssignmentSupplementItemAttachment object + * @param attachment + * @return + */ + public boolean removeAttachment(AssignmentSupplementItemAttachment attachment); + /*************** model answer ******************/ /** Index: assignment-impl/impl/src/java/org/sakaiproject/assignment/impl/AssignmentSupplementItemServiceImpl.java =================================================================== --- assignment-impl/impl/src/java/org/sakaiproject/assignment/impl/AssignmentSupplementItemServiceImpl.java (revision 123299) +++ assignment-impl/impl/src/java/org/sakaiproject/assignment/impl/AssignmentSupplementItemServiceImpl.java (working copy) @@ -174,6 +174,42 @@ return (List) getHibernateTemplate().execute(hcb); } + /** + * {@inheritDoc} + */ + public boolean cleanAttachment(AssignmentSupplementItemWithAttachment item) + { + boolean rv = true; + Set attachmentSet = item.getAttachmentSet(); + if (attachmentSet != null) + { + for (Iterator iAttachmentSet = attachmentSet.iterator(); iAttachmentSet.hasNext();) + { + AssignmentSupplementItemAttachment attachment = iAttachmentSet.next(); + rv &= removeAttachment(attachment); + } + } + return rv; + } + + /** + * {@inheritDoc} + */ + public boolean removeAttachment(AssignmentSupplementItemAttachment attachment) + { + try + { + getHibernateTemplate().delete(attachment); + return true; + } + catch (DataAccessException e) + { + e.printStackTrace(); + Log.warn(this + ".removeAttachment() Hibernate could not delete attachment " + attachment.getId()); + return false; + } + } + /*********************** model answer ************************/ /** * {@inheritDoc}} Index: assignment-tool/tool/src/java/org/sakaiproject/assignment/tool/AssignmentAction.java =================================================================== --- assignment-tool/tool/src/java/org/sakaiproject/assignment/tool/AssignmentAction.java (revision 123299) +++ assignment-tool/tool/src/java/org/sakaiproject/assignment/tool/AssignmentAction.java (working copy) @@ -6452,7 +6452,10 @@ // to delete the model answer AssignmentModelAnswerItem mAnswer = m_assignmentSupplementItemService.getModelAnswer(aId); if (mAnswer != null) + { + m_assignmentSupplementItemService.cleanAttachment(mAnswer); m_assignmentSupplementItemService.removeModelAnswer(mAnswer); + } } else if (state.getAttribute(MODELANSWER_TEXT) != null) { @@ -6495,7 +6498,11 @@ // to remove allPurpose item AssignmentAllPurposeItem nAllPurpose = m_assignmentSupplementItemService.getAllPurposeItem(aId); if (nAllPurpose != null) + { + m_assignmentSupplementItemService.cleanAttachment(nAllPurpose); + m_assignmentSupplementItemService.cleanAllPurposeItemAccess(nAllPurpose); m_assignmentSupplementItemService.removeAllPurposeItem(nAllPurpose); + } } else if (state.getAttribute(ALLPURPOSE_TITLE) != null) { Index: assignment-tool/tool/src/webapp/js/assignments.js =================================================================== --- assignment-tool/tool/src/webapp/js/assignments.js (revision 123299) +++ assignment-tool/tool/src/webapp/js/assignments.js (working copy) @@ -40,9 +40,9 @@ $('#' + nodeType + '_title').val(''); $('#' + nodeType + '_title_holder').val(''); // uncheck all checkboxes - $('#allPurposeGroupLists input[@type=checkbox]').attr('checked', ''); + $('#allPurposeGroupLists input[type=checkbox]').attr('checked', ''); $('#allPurposeGroupLists label').removeClass('selectedItem'); - $('#allPurposeAttachShowWhen input[@type=checkbox]').attr('checked', ''); + $('#allPurposeAttachShowWhen input[type=checkbox]').attr('checked', ''); $('#allPurposeAttachShowWhen #allPurposeHide1').attr('checked', 'checked'); $('#allPurposeAttachShowWhen #allPurposeHide2').attr('checked', ''); $('#allPurposeAttachShowWhen select').val('1');