Skip to content

Commit

Permalink
Changes to send comments to Gradebook automatically. SAM-1597
Browse files Browse the repository at this point in the history
  • Loading branch information
mateullas committed Sep 24, 2015
1 parent 90624ce commit 3459223
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ public void updateExternalAssessmentScore(AssessmentGradingData ag,
public void updateExternalAssessmentScores(Long publishedAssessmentId, final Map<String, Double> studentUidsToScores,
GradebookExternalAssessmentService g) throws Exception;

public void updateExternalAssessmentComment(Long publishedAssessmentId, String studentUid, String comment,
GradebookExternalAssessmentService g) throws Exception;

public Long getExternalAssessmentCategoryId(String gradebookUId,
String publishedAssessmentId, GradebookExternalAssessmentService g);
}
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,22 @@ public void updateExternalAssessmentScores(Long publishedAssessmentId, final Map
throw new Exception("Encountered an error in update ExternalAssessmentScore.");
}
}

public void updateExternalAssessmentComment(Long publishedAssessmentId, String studentUid, String comment,
GradebookExternalAssessmentService g) throws Exception {
boolean testErrorHandling=false;
PublishedAssessmentService pubService = new PublishedAssessmentService();
String gradebookUId = pubService.getPublishedAssessmentOwner(publishedAssessmentId);
if (gradebookUId == null) {
return;
}
g.updateExternalAssessmentComment(gradebookUId, publishedAssessmentId.toString(), studentUid, comment);

if (testErrorHandling){
throw new Exception("Encountered an error in update ExternalAssessmentComment.");
}
}


public Long getExternalAssessmentCategoryId(String gradebookUId,
String publishedAssessmentId, GradebookExternalAssessmentService g) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -297,8 +297,22 @@ private ArrayList getListForGradebookNotification(
else{ // if new is different from old, include it for update
AssessmentGradingData b = (AssessmentGradingData) o;
if ((a.getFinalScore()!=null && b.getFinalScore()!=null)
&& !a.getFinalScore().equals(b.getFinalScore()))
l.add(a);
&& !a.getFinalScore().equals(b.getFinalScore())) {
l.add(a);
}
// if scores are not modified but comments are added, include it for update
else if (a.getComments()!=null)
{
if (b.getComments()!=null)
{
if (!a.getComments().equals(b.getComments())) {
l.add(a);
}
}
else {
l.add(a);
}
}
}
}
return l;
Expand Down Expand Up @@ -1395,6 +1409,16 @@ public void notifyGradebook(AssessmentGradingData data, PublishedAssessmentIfc p
if(!(MathUtils.equalsIncludingNaN(data.getFinalScore(), originalFinalScore, 0.0001))) {
data.setFinalScore(originalFinalScore);
}

try {
Long publishedAssessmentId = data.getPublishedAssessmentId();
String agent = data.getAgentId();
String comment = data.getComments();
gbsHelper.updateExternalAssessmentComment(publishedAssessmentId, agent, comment, g);
}
catch (Exception ex) {
log.warn("Error sending comments to gradebook: " + ex.getMessage());
}
} else {
if(log.isDebugEnabled()) log.debug("Not updating the gradebook. toGradebook = " + toGradebook);
}
Expand Down

0 comments on commit 3459223

Please sign in to comment.