01: /**********************************************************************************
02: *
03: * $Id: AddAssignmentBean.java 22020 2007-03-01 01:01:23Z louis@media.berkeley.edu $
04: *
05: ***********************************************************************************
06: *
07: * Copyright (c) 2005 The Regents of the University of California, The MIT Corporation
08: *
09: * Licensed under the Educational Community License, Version 1.0 (the "License");
10: * you may not use this file except in compliance with the License.
11: * You may obtain a copy of the License at
12: *
13: * http://www.opensource.org/licenses/ecl1.php
14: *
15: * Unless required by applicable law or agreed to in writing, software
16: * distributed under the License is distributed on an "AS IS" BASIS,
17: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18: * See the License for the specific language governing permissions and
19: * limitations under the License.
20: *
21: **********************************************************************************/package org.sakaiproject.tool.gradebook.ui;
22:
23: import java.io.Serializable;
24:
25: import org.apache.commons.logging.Log;
26: import org.apache.commons.logging.LogFactory;
27: import org.sakaiproject.service.gradebook.shared.ConflictingAssignmentNameException;
28: import org.sakaiproject.tool.gradebook.Assignment;
29: import org.sakaiproject.tool.gradebook.jsf.FacesUtil;
30:
31: public class AddAssignmentBean extends GradebookDependentBean implements
32: Serializable {
33: private static final Log logger = LogFactory
34: .getLog(AddAssignmentBean.class);
35:
36: private Assignment assignment;
37:
38: protected void init() {
39: if (assignment == null) {
40: assignment = new Assignment();
41: assignment.setReleased(true);
42: }
43: }
44:
45: public String saveNewAssignment() {
46: try {
47: getGradebookManager().createAssignment(getGradebookId(),
48: assignment.getName(),
49: assignment.getPointsPossible(),
50: assignment.getDueDate(),
51: new Boolean(assignment.isNotCounted()),
52: new Boolean(assignment.isReleased()));
53: getGradebookBean().getEventTrackingService().postEvent(
54: "gradebook.newItem",
55: "/gradebook/" + getGradebookId() + "/"
56: + assignment.getName());
57: FacesUtil.addRedirectSafeMessage(getLocalizedString(
58: "add_assignment_save", new String[] { assignment
59: .getName() }));
60: } catch (ConflictingAssignmentNameException e) {
61: logger.error(e);
62: FacesUtil
63: .addErrorMessage(getLocalizedString("add_assignment_name_conflict_failure"));
64: return "failure";
65: }
66: return "overview";
67: }
68:
69: public Assignment getAssignment() {
70: return assignment;
71: }
72: }
|