/** * Update a gradebook. * * @param publishedAssessment the published assessment * @param g the Gradebook Service * @return false: cannot update the gradebook * @throws java.lang.Exception */ public boolean updateGradebook(PublishedAssessmentIfc publishedAssessment, GradebookService g) throws Exception { log.debug("updateGradebook start"); String gradebookUId = GradebookFacade.getGradebookUId(); if (gradebookUId == null) { return false; } log.debug("before g.isAssignmentDefined()"); g.updateExternalAssessment( gradebookUId, publishedAssessment.getPublishedAssessmentId().toString(), null, publishedAssessment.getTitle(), publishedAssessment.getTotalScore().doubleValue(), publishedAssessment.getAssessmentAccessControl().getDueDate()); return true; }
/** * Add a published assessment to gradebook. * * @param publishedAssessment the published assessment * @param g the Gradebook Service * @return false: cannot add to gradebook * @throws java.lang.Exception */ public boolean addToGradebook(PublishedAssessmentData publishedAssessment, GradebookService g) throws Exception { // log.info("total point(s) is/are =" + // publishedAssessment.getTotalScore().longValue()); // log.info("gradebookId =" + GradebookFacade.getGradebookUId()); boolean added = false; // log.info("GradebookService instance=" + g); String gradebookUId = GradebookFacade.getGradebookUId(); if (gradebookUId == null) { return false; } // log.info("inside addToGradebook, gradebook exists? " + // g.isGradebookDefined(gradebookUId)); if (g.isGradebookDefined(gradebookUId)) { // Tool name code added by Josh Holtzman Tool tool = ToolManager.getTool("sakai.samigo"); String appName = null; if (tool == null) { log.warn( "could not get tool named sakai.samigo, " + "so we're going to assume we're called 'Tests & Quizzes'"); appName = "Tests & Quizzes"; } else { appName = tool.getTitle(); } String title = StringEscapeUtils.unescapeHtml(publishedAssessment.getTitle()); if (!g.isAssignmentDefined(gradebookUId, title)) { g.addExternalAssessment( gradebookUId, publishedAssessment.getPublishedAssessmentId().toString(), null, title, publishedAssessment.getTotalScore().doubleValue(), publishedAssessment.getAssessmentAccessControl().getDueDate(), appName); // Use the app name from sakai added = true; } } return added; }
public boolean isAssignmentDefined(String assessmentTitle, GradebookService g) throws Exception { String gradebookUId = GradebookFacade.getGradebookUId(); return g.isAssignmentDefined(gradebookUId, assessmentTitle); }