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 java.util.ArrayList;
023: import java.util.List;
024: import java.util.Map;
025: import java.util.HashMap;
026:
027: import org.apache.commons.logging.Log;
028: import org.apache.commons.logging.LogFactory;
029:
030: import org.sakaiproject.tool.assessment.data.dao.grading.ItemGradingData;
031: import org.sakaiproject.tool.assessment.data.ifc.assessment.PublishedAssessmentIfc;
032: import org.sakaiproject.tool.assessment.data.ifc.grading.AssessmentGradingIfc;
033: import org.sakaiproject.tool.assessment.data.ifc.grading.ItemGradingIfc;
034: import org.sakaiproject.tool.assessment.data.ifc.grading.MediaIfc;
035: import org.sakaiproject.tool.assessment.services.GradingService;
036: import org.sakaiproject.tool.assessment.shared.api.grading.GradingServiceAPI;
037: import org.sakaiproject.tool.assessment.services.GradingServiceException;
038:
039: /**
040: *
041: * The GradingServiceAPI implements the shared interface to get grading information.
042: * @author Ed Smiley <esmiley@stanford.edu>
043: */
044:
045: public class GradingServiceImpl implements GradingServiceAPI {
046: private static Log log = LogFactory
047: .getLog(GradingServiceImpl.class);
048:
049: /**
050: * Get all scores for a published assessment from the back end.
051: * @return List of AssessmentGradingIfcIfs
052: */
053: public List getTotalScores(String publishedId, String which) {
054: try {
055: GradingService service = new GradingService();
056: return service.getTotalScores(publishedId, which);
057: } catch (Exception ex) {
058: throw new GradingServiceException(ex);
059: }
060: }
061:
062: /**
063: * Get all submissions for a published assessment from the back end.
064: * @return List of AssessmentGradingIfcIfs
065: */
066: public List getAllSubmissions(String publishedId) {
067: try {
068: GradingService service = new GradingService();
069: return service.getAllSubmissions(publishedId);
070: } catch (Exception ex) {
071: throw new GradingServiceException(ex);
072: }
073: }
074:
075: /**
076: * Save the total scores.
077: * @param data List of AssessmentGradingDataIfcs
078: */
079: public void saveTotalScores(List data, PublishedAssessmentIfc pub) {
080: try {
081: GradingService service = new GradingService();
082: ArrayList list = new ArrayList(data);
083: service.saveTotalScores(list, pub);
084: } catch (Exception ex) {
085: throw new GradingServiceException(ex);
086: }
087: }
088:
089: /**
090: * Save the item scores.
091: * @param data List of itemGradingDataIfcs
092: */
093:
094: /*
095: public void saveItemScores(List data, HashMap map, PublishedAssessmentIfc pub)
096: {
097: try
098: {
099: GradingService service = new GradingService();
100: ArrayList list = new ArrayList(data);
101: service.saveItemScores(list, map, pub);
102: }
103: catch (Exception ex)
104: {
105: throw new GradingServiceException(ex);
106: }
107: }
108: */
109: /**
110: * Get the score information for each item from the assessment score.
111: */
112: public Map getItemScores(Long publishedId, Long itemId, String which) {
113: try {
114: GradingService service = new GradingService();
115: return service.getItemScores(publishedId, itemId, which);
116: } catch (Exception ex) {
117: throw new GradingServiceException(ex);
118: }
119: }
120:
121: /**
122: * Get the last set of ItemGradingIfc for a student per assessment
123: */
124: public Map getLastItemGrading(String publishedId, String agentId) {
125: try {
126: GradingService service = new GradingService();
127: // note name change
128: return service.getLastItemGradingData(publishedId, agentId);
129: } catch (Exception ex) {
130: throw new GradingServiceException(ex);
131: }
132: }
133:
134: /**
135: * Get the grading data for a given submission
136: */
137: public Map getStudentGradingData(String assessmentGradingId) {
138: try {
139: GradingService service = new GradingService();
140: return service.getStudentGradingData(assessmentGradingId);
141: } catch (Exception ex) {
142: throw new GradingServiceException(ex);
143: }
144: }
145:
146: /**
147: * Get the last submission for a student per assessment
148: */
149: public Map getSubmitData(String publishedId, String agentId,
150: Integer scoringoption) {
151: try {
152: GradingService service = new GradingService();
153: return service.getSubmitData(publishedId, agentId,
154: scoringoption);
155: } catch (Exception ex) {
156: throw new GradingServiceException(ex);
157: }
158: }
159:
160: /**
161: * Get the text for the type.
162: * @param typeId
163: * @return
164: */
165: public String getTextForId(Long typeId) {
166: try {
167: GradingService service = new GradingService();
168: return service.getTextForId(typeId);
169: } catch (Exception ex) {
170: throw new GradingServiceException(ex);
171: }
172: }
173:
174: /**
175: * Store the grading data.
176: * @param data
177: */
178: /*
179: public void storeGrades(AssessmentGradingIfc data)
180: {
181: try
182: {
183: GradingService service = new GradingService();
184: service.storeGrades(data);
185: }
186: catch (Exception ex)
187: {
188: throw new GradingServiceException(ex);
189: }
190: }
191: */
192: /**
193: * Get the count of published assessments.
194: * @param publishedAssessmentId
195: * @return
196: */
197: public int getSubmissionSizeOfPublishedAssessment(
198: String publishedAssessmentId) {
199: try {
200: GradingService service = new GradingService();
201: return service
202: .getSubmissionSizeOfPublishedAssessment(publishedAssessmentId);
203: } catch (Exception ex) {
204: throw new GradingServiceException(ex);
205: }
206: }
207:
208: /**
209: *
210: * @return
211: */
212: public Map getSubmissionSizeOfAllPublishedAssessments() {
213: try {
214: GradingService service = new GradingService();
215: return service.getSubmissionSizeOfAllPublishedAssessments();
216: } catch (Exception ex) {
217: throw new GradingServiceException(ex);
218: }
219: }
220:
221: /**
222: *
223: * @param media
224: * @param mimeType
225: * @return
226: */
227: public Long saveMedia(byte[] media, String mimeType) {
228: try {
229: GradingService service = new GradingService();
230: return service.saveMedia(media, mimeType);
231: } catch (Exception ex) {
232: throw new GradingServiceException(ex);
233: }
234: }
235:
236: /**
237: * Save media.
238: * @param mediaData
239: * @return
240: */
241: public Long saveMedia(MediaIfc mediaData) {
242: try {
243: GradingService service = new GradingService();
244: return service.saveMedia(service.getMedia(mediaData
245: .getMediaId().toString()));
246: } catch (Exception ex) {
247: throw new GradingServiceException(ex);
248: }
249: }
250:
251: /**
252: *
253: * @param mediaId
254: * @return
255: */
256: public MediaIfc getMedia(String mediaId) {
257: try {
258: GradingService service = new GradingService();
259: return service.getMedia(mediaId);
260: } catch (Exception ex) {
261: throw new GradingServiceException(ex);
262: }
263: }
264:
265: /**
266: *
267: * @param itemGradingId
268: * @return
269: */
270: public List getMediaArray(String itemGradingId) {
271: try {
272: GradingService service = new GradingService();
273: return service.getMediaArray(itemGradingId);
274: } catch (Exception ex) {
275: throw new GradingServiceException(ex);
276: }
277: }
278:
279: /**
280: *
281: * @param i
282: * @return
283: */
284: public List getMediaArray(ItemGradingIfc itemGrading) {
285: try {
286: GradingService service = new GradingService();
287: String publishedItemId = itemGrading.getPublishedItemId()
288: .toString();
289: String assessmentGradingId = itemGrading
290: .getAssessmentGradingId().toString();
291: ItemGradingData gradingData = service.getItemGradingData(
292: assessmentGradingId, publishedItemId);
293: return service.getMediaArray(gradingData);
294: } catch (Exception ex) {
295: throw new GradingServiceException(ex);
296: }
297: }
298:
299: /**
300: *
301: * @param publishedItemId
302: * @param agentId
303: * @return
304: */
305: public ItemGradingIfc getLastItemGradingByAgent(
306: String publishedItemId, String agentId) {
307: try {
308: GradingService service = new GradingService();
309: return service.getLastItemGradingDataByAgent(
310: publishedItemId, agentId);
311: } catch (Exception ex) {
312: throw new GradingServiceException(ex);
313: }
314: }
315:
316: /**
317: *
318: * @param assessmentGradingId
319: * @param publishedItemId
320: * @return
321: */
322: public ItemGradingIfc getItemGrading(String assessmentGradingId,
323: String publishedItemId) {
324: try {
325: GradingService service = new GradingService();
326: // note name change
327: return service.getItemGradingData(assessmentGradingId,
328: publishedItemId);
329: } catch (Exception ex) {
330: throw new GradingServiceException(ex);
331: }
332: }
333:
334: /**
335: * Load assessment grading information.
336: * @param assessmentGradingId
337: * @return
338: */
339: public AssessmentGradingIfc load(String assessmentGradingId) {
340: try {
341: GradingService service = new GradingService();
342: return service.load(assessmentGradingId);
343: } catch (Exception ex) {
344: throw new GradingServiceException(ex);
345: }
346: }
347:
348: /**
349: * Get the grading data for the last submission of this agent.
350: * @param publishedAssessmentId
351: * @param agentIdString
352: * @return
353: */
354: public AssessmentGradingIfc getLastAssessmentGradingByAgentId(
355: String publishedAssessmentId, String agentIdString) {
356: try {
357: GradingService service = new GradingService();
358: return service.getLastAssessmentGradingByAgentId(
359: publishedAssessmentId, agentIdString);
360: } catch (Exception ex) {
361: throw new GradingServiceException(ex);
362: }
363: }
364:
365: /**
366: * Save item grading information.
367: * @param item
368: */
369: public void saveItemGrading(ItemGradingIfc item) {
370: try {
371: GradingService service = new GradingService();
372: service.saveItemGrading(item);
373: } catch (Exception ex) {
374: throw new GradingServiceException(ex);
375: }
376: }
377:
378: /**
379: * Save assesment grading.
380: * @param assessment
381: */
382: public void saveOrUpdateAssessmentGrading(
383: AssessmentGradingIfc assessment) {
384: try {
385: GradingService service = new GradingService();
386: service.saveOrUpdateAssessmentGrading(assessment);
387: } catch (Exception ex) {
388: throw new GradingServiceException(ex);
389: }
390: }
391: }
|