01: /**********************************************************************************
02: * $URL: https://source.sakaiproject.org/svn/sam/trunk/component/src/java/org/sakaiproject/tool/assessment/integration/helper/integrated/GradebookHelperImpl.java $
03: * $Id: GradebookHelperImpl.java 9273 2006-05-10 22:34:28Z daisyf@stanford.edu $
04: ***********************************************************************************
05: *
06: * Copyright (c) 2004, 2005, 2006 The Sakai Foundation.
07: *
08: * Licensed under the Educational Community License, Version 1.0 (the"License");
09: * you may not use this file except in compliance with the License.
10: * You may obtain a copy of the License at
11: *
12: * http://www.opensource.org/licenses/ecl1.php
13: *
14: * Unless required by applicable law or agreed to in writing, software
15: * distributed under the License is distributed on an "AS IS" BASIS,
16: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17: * See the License for the specific language governing permissions and
18: * limitations under the License.
19: *
20: **********************************************************************************/package org.sakaiproject.tool.assessment.integration.helper.integrated;
21:
22: import org.apache.commons.logging.Log;
23: import org.apache.commons.logging.LogFactory;
24:
25: import org.sakaiproject.tool.api.Placement;
26: import org.sakaiproject.tool.cover.ToolManager;
27: import org.sakaiproject.tool.assessment.integration.helper.ifc.GradebookHelper;
28:
29: /**
30: *
31: * <p>Description:
32: * This is an integrated context implementation helper delegate class for
33: * the GradebookFacade class.
34: * "Integrated" means that Samigo (Tests and Quizzes)
35: * is running within the context of the Sakai portal and authentication
36: * mechanisms, and therefore makes calls on Sakai for things it needs.</p>
37: * <p>Note: To customize behavior you can add your own helper class to the
38: * Spring injection via the integrationContext.xml for your context.
39: * The particular integrationContext.xml to be used is selected by the
40: * build process.
41: * </p>
42: * <p>Sakai Project Copyright (c) 2005</p>
43: * <p> </p>
44: * @author Ed Smiley <esmiley@stanford.edu>
45: * based on code originally in GradebookFacade
46: */
47:
48: public class GradebookHelperImpl implements GradebookHelper {
49: private static Log log = LogFactory
50: .getLog(GradebookHelperImpl.class);
51:
52: /**
53: * Get current gradebook uid.
54: * This will *fail* unless called from an integrated Sakai context!
55: * @return the current gradebook uid.
56: */
57: public String getGradebookUId() {
58: String context;
59:
60: Placement placement = null;
61: try {
62: placement = ToolManager.getInstance().getCurrentPlacement();
63: } catch (Exception ex) {
64: log.warn(ex);
65: placement = null;
66: }
67: if (placement == null) {
68: log
69: .warn("getGradebookUId() - no tool placement found, probably taking an "
70: + "assessment via URL. Gradebook not updated.");
71: return null;
72: }
73: context = placement.getContext();
74:
75: return context;
76: }
77:
78: /**
79: * Get the default gradebook uid.
80: * @return "Test Gradebook #1" (always)
81: */
82:
83: public String getDefaultGradebookUId() {
84: return "Test Gradebook #1";
85: }
86:
87: }
|