001: /**********************************************************************************
002: * $URL$
003: * $Id$
004: ***********************************************************************************
005: *
006: * Copyright (c) 2005, 2006 The Sakai Foundation.
007: *
008: * Licensed under the Educational Community License, Version 1.0 (the"License");
009: * you may not use this file except in compliance with the License.
010: * You may obtain a copy of the License at
011: *
012: * http://www.opensource.org/licenses/ecl1.php
013: *
014: * Unless required by applicable law or agreed to in writing, software
015: * distributed under the License is distributed on an "AS IS" BASIS,
016: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
017: * See the License for the specific language governing permissions and
018: * limitations under the License.
019: *
020: **********************************************************************************/package org.sakaiproject.tool.assessment.shared.impl.grading;
021:
022: import org.sakaiproject.tool.assessment.data.dao.assessment.PublishedAssessmentData;
023: import org.sakaiproject.tool.assessment.data.ifc.assessment.PublishedAssessmentIfc;
024: import org.sakaiproject.tool.assessment.data.ifc.grading.AssessmentGradingIfc;
025: import org.sakaiproject.tool.assessment.facade.PublishedAssessmentFacade;
026: import org.sakaiproject.tool.assessment.services.assessment.PublishedAssessmentService;
027: import org.sakaiproject.tool.assessment.services.gradebook.GradebookServiceHelper;
028: import org.sakaiproject.tool.assessment.shared.api.grading.GradebookServiceAPI;
029: import org.sakaiproject.tool.assessment.services.GradingServiceException;
030:
031: /**
032: * The GradebookServiceAPI describes an interface for gradebook information
033: * for published assessments. Implemented by wrapping GradebookServiceHelper().
034: * Right that is a stub implementation, but this is designed to continue to work
035: * if it isn't.
036: *
037: * @author Ed Smiley <esmiley@stanford.edu>
038: */
039: public class GradebookServiceImpl implements GradebookServiceAPI {
040: //private static Log log = LogFactory.getLog(GradebookServiceImpl.class);
041:
042: public boolean isAssignmentDefined(String assessmentTitle) {
043: try {
044: return GradebookServiceHelper
045: .isAssignmentDefined(assessmentTitle);
046: } catch (Exception ex) {
047: throw new GradingServiceException(ex);
048: }
049: }
050:
051: /**
052: * Add this published assessment to the site.
053: * @param publishedAssessment, must be castable to PublishedAssessmentData
054: * @return true if added
055: */
056: public boolean addToGradebook(
057: PublishedAssessmentIfc publishedAssessment) {
058: try {
059: // this a little convoluted
060: // our internal data representation uses OSIDs which declare an
061: // 'any type' data property, but our OOB standard has data that is
062: // a PublishedAssessmentData which is the implementation of
063: // PublishedAssessmentIfc
064: Long id = publishedAssessment.getPublishedAssessmentId();
065: PublishedAssessmentService pubService = new PublishedAssessmentService();
066: PublishedAssessmentFacade pubFacade = pubService
067: .getPublishedAssessment(id.toString());
068: PublishedAssessmentIfc data = pubFacade.getData();
069: return GradebookServiceHelper
070: .addToGradebook((PublishedAssessmentData) data);
071: } catch (Exception ex) {
072: throw new GradingServiceException(ex);
073: }
074: }
075:
076: /**
077: * Remove published assessment.
078: * @param siteId the site id
079: * @param publishedAssessmentId teh published assessment id
080: */
081: public void removeExternalAssessment(String siteId,
082: String publishedAssessmentId) {
083: try {
084: GradebookServiceHelper.removeExternalAssessment(siteId,
085: publishedAssessmentId);
086: } catch (Exception ex) {
087: throw new GradingServiceException(ex);
088: }
089: }
090:
091: /**
092: * @todo fix
093: * Update the assessment for the agent's grade.
094: * @param ag the assessment grading data
095: * @param agentIdString agent id
096: */
097: public void updateExternalAssessment(AssessmentGradingIfc ag,
098: String agentIdString) {
099: try {
100: // GradingService service = new GradingService();
101: // AssessmentGradingData data = service.load(ag.getAssessmentGradingId().toString());
102: // helper.updateExternalAssessment(data, agentIdString);
103: } catch (Exception ex) {
104: throw new GradingServiceException(ex);
105: }
106: }
107:
108: /**
109: * Determine if a gradebook exists for the site.
110: * @param siteId the site id
111: * @return
112: */
113: public boolean gradebookExists(String siteId) {
114: try {
115: return GradebookServiceHelper.gradebookExists(siteId);
116: } catch (Exception ex) {
117: throw new GradingServiceException(ex);
118: }
119: }
120:
121: /**
122: * Update the score in the gradebook.
123: * @param ag the assessment grading interface
124: */
125: public void updateExternalAssessmentScore(AssessmentGradingIfc ag) {
126: try {
127: GradebookServiceHelper.updateExternalAssessmentScore(ag);
128: } catch (Exception ex) {
129: throw new GradingServiceException(ex);
130: }
131: }
132:
133: }
|