Skip to content

Commit

Permalink
SAK-29418: In an assignment resubmission, removing all attachments sh…
Browse files Browse the repository at this point in the history
…ould be considered a modification
  • Loading branch information
bbailla2 committed May 25, 2015
1 parent e190751 commit 548ad32
Showing 1 changed file with 11 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1520,12 +1520,12 @@ protected String build_student_view_submission_context(VelocityPortlet portlet,

// the attachments from the previous submission
List submittedAttachments = s.getSubmittedAttachments();
newAttachments = areAttachmentsNew(submittedAttachments, currentAttachments);
newAttachments = areAttachmentsModified(submittedAttachments, currentAttachments);
}
else
{
// There is no previous submission, attachments are modified if anything has been uploaded
newAttachments = currentAttachments != null && !currentAttachments.isEmpty();
newAttachments = CollectionUtils.isNotEmpty(currentAttachments);
}

// put the resubmit information into context
Expand Down Expand Up @@ -1615,17 +1615,20 @@ protected String build_student_view_submission_context(VelocityPortlet portlet,
} // build_student_view_submission_context

/**
* Determines if there are new attachments
* @return true if currentAttachments is not empty and isn't equal to oldAttachments
* Determines if the attachments have been modified
* @return true if currentAttachments isn't equal to oldAttachments
*/
private boolean areAttachmentsNew(List oldAttachments, List currentAttachments)
private boolean areAttachmentsModified(List oldAttachments, List currentAttachments)
{
if (currentAttachments == null || currentAttachments.isEmpty())
boolean hasCurrent = CollectionUtils.isNotEmpty(currentAttachments);
boolean hasOld = CollectionUtils.isNotEmpty(oldAttachments);

if (!hasCurrent)
{
//there are no current attachments
return false;
return hasOld;
}
if (oldAttachments == null || oldAttachments.isEmpty())
if (!hasOld)
{
//there are no old attachments (and there are new ones)
return true;
Expand Down

0 comments on commit 548ad32

Please sign in to comment.