/**
   * Update the grading of the assessment.
   *
   * @param ag the assessment grading.
   * @param g the Gradebook Service
   * @throws java.lang.Exception
   */
  public void updateExternalAssessmentScore(AssessmentGradingIfc ag, GradebookService g)
      throws Exception {
    boolean testErrorHandling = false;
    // log.info("GradebookService instance=" + g);
    PublishedAssessmentService pubService = new PublishedAssessmentService();
    GradingService gradingService = new GradingService();
    PublishedAssessmentIfc pub =
        (PublishedAssessmentIfc)
            gradingService.getPublishedAssessmentByAssessmentGradingId(
                ag.getAssessmentGradingId().toString());

    String gradebookUId = pubService.getPublishedAssessmentOwner(pub.getPublishedAssessmentId());
    if (gradebookUId == null) {
      return;
    }

    // SAM-1562 We need to round the float score and covert to a double -DH
    float fScore = MathUtils.round(ag.getFinalScore(), 2);
    Double score = Float.valueOf(fScore).doubleValue();
    log.info("rounded:  " + ag.getFinalScore() + " to: " + score.toString());
    g.updateExternalAssessmentScore(
        gradebookUId, ag.getPublishedAssessmentId().toString(), ag.getAgentId(), score);
    if (testErrorHandling) {
      throw new Exception("Encountered an error in update ExternalAssessmentScore.");
    }
  }