Skip to content

Commit

Permalink
SAK-29103 Associate multiple assignments with the same item gradebook
Browse files Browse the repository at this point in the history
don't delete grades from the old association
  • Loading branch information
annuelo committed Feb 24, 2015
1 parent 63c200b commit 789029a
Showing 1 changed file with 18 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4723,16 +4723,18 @@ else if ("remove".equals(updateRemoveSubmission))
while (submissions.hasNext())
{
AssignmentSubmission aSubmission = (AssignmentSubmission) submissions.next();
User[] submitters = aSubmission.getSubmitters();
for (int i=0; submitters != null && i < submitters.length; i++) {
if (isExternalAssociateAssignmentDefined)
{
// if the old associated assignment is an external maintained one
gExternal.updateExternalAssessmentScore(gradebookUid, associateGradebookAssignment, submitters[i].getId(), null);
}
else if (isAssignmentDefined)
{
g.setAssignmentScoreString(gradebookUid, associateGradebookAssignment, submitters[i].getId(), "0", assignmentToolTitle);
if (aSubmission.getGrade(false) != null) {
User[] submitters = aSubmission.getSubmitters();
for (int i=0; submitters != null && i < submitters.length; i++) {
if (isExternalAssociateAssignmentDefined)
{
// if the old associated assignment is an external maintained one
gExternal.updateExternalAssessmentScore(gradebookUid, associateGradebookAssignment, submitters[i].getId(), null);
}
else if (isAssignmentDefined)
{
g.setAssignmentScoreString(gradebookUid, associateGradebookAssignment, submitters[i].getId(), "0", assignmentToolTitle);
}
}
}
}
Expand Down Expand Up @@ -8268,6 +8270,9 @@ else if (addtoGradebook.equals(AssignmentService.GRADEBOOK_INTEGRATION_ASSOCIATE
// if the assignment has been assoicated with a different entry in gradebook before, remove those grades from the entry in Gradebook
if (StringUtils.trimToNull(oAssociateGradebookAssignment) != null && !oAssociateGradebookAssignment.equals(associateGradebookAssignment))
{
// remove all previously associated grades, if any, into Gradebook
integrateGradebook(state, aReference, oAssociateGradebookAssignment, null, null, null, -1, null, null, "remove", category);

// if the old assoicated assignment entry in GB is an external one, but doesn't have anything assoicated with it in Assignment tool, remove it
removeNonAssociatedExternalGradebookEntry(context, a.getReference(), oAssociateGradebookAssignment,gExternal, gradebookUid);
}
Expand All @@ -8286,6 +8291,9 @@ else if (addtoGradebook.equals(AssignmentService.GRADEBOOK_INTEGRATION_ASSOCIATE
}
else
{
// remove all previously associated grades, if any, into Gradebook
integrateGradebook(state, aReference, oAssociateGradebookAssignment, null, null, null, -1, null, null, "remove", category);

// need to remove the associated gradebook entry if 1) it is external and 2) no other assignment are associated with it
removeNonAssociatedExternalGradebookEntry(context, a.getReference(), oAssociateGradebookAssignment,gExternal, gradebookUid);
}
Expand Down

0 comments on commit 789029a

Please sign in to comment.