001: /**********************************************************************************
002: * $URL: https://source.sakaiproject.org/svn/sam/tags/sakai_2-4-1/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/bean/delivery/SettingsDeliveryBean.java $
003: * $Id: SettingsDeliveryBean.java 12885 2006-07-25 21:10:20Z lydial@stanford.edu $
004: ***********************************************************************************
005: *
006: * Copyright (c) 2004, 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.ui.bean.delivery;
021:
022: import org.sakaiproject.tool.assessment.data.ifc.assessment.AssessmentMetaDataIfc;
023: import org.sakaiproject.tool.assessment.data.ifc.assessment.AssessmentAccessControlIfc;
024: import org.sakaiproject.tool.assessment.data.ifc.assessment.PublishedAssessmentIfc;
025:
026: import java.io.Serializable;
027: import java.util.Set;
028: import java.util.Iterator;
029:
030: /**
031: * Assessment Settings used in Delivery
032: */
033: public class SettingsDeliveryBean implements Serializable {
034: /** Use serialVersionUID for interoperability. */
035: private final static long serialVersionUID = -1090852048737428722L;
036:
037: private String username;
038: private String password;
039: private Set ipAddresses;
040: private boolean unlimitedAttempts;
041: private java.util.Date dueDate;
042: private java.util.Date feedbackDate;
043: private boolean autoSave;
044: private boolean autoSubmit;
045: private boolean formatByPart;
046: private boolean formatByQuestion;
047: private boolean formatByAssessment;
048: private int maxAttempts;
049: private String submissionMessage;
050: private String bgcolor;
051: private String background;
052: private String itemNumbering;
053:
054: /**
055: * Maximum number of attemtps allowed.
056: * @return
057: */
058: public int getMaxAttempts() {
059: return maxAttempts;
060: }
061:
062: /**
063: * Maximum number of attemtps allowed.
064: * @param string
065: */
066: public void setMaxAttempts(int maxAttempts) {
067: this .maxAttempts = maxAttempts;
068: }
069:
070: /**
071: * Is this auto-submit? Is auto submit turned on?
072: * @return is this auto-submit?
073: */
074: public boolean getAutoSubmit() {
075: return autoSubmit;
076: }
077:
078: /**
079: * Is auto save turned on?
080: * @return
081: */
082: public boolean isAutoSave() {
083: return autoSave;
084: }
085:
086: /**
087: * Due date for assessment.
088: * @return Date
089: */
090: public java.util.Date getDueDate() {
091: return dueDate;
092: }
093:
094: /**
095: * Feedback date for assessment.
096: * @return
097: */
098: public java.util.Date getFeedbackDate() {
099: return feedbackDate;
100: }
101:
102: /**
103: * Is auto submit turned on?
104: * @param boolean autoSubmit
105: */
106: public void setAutoSubmit(boolean autoSubmit) {
107: this .autoSubmit = autoSubmit;
108: }
109:
110: /**
111: * Is auto save turned on?
112: * @param boolean autoSave
113: */
114: public void setAutoSave(boolean autoSave) {
115: this .autoSave = autoSave;
116: }
117:
118: /**
119: * Set assessment due date.
120: * @param due date
121: */
122: public void setDueDate(java.util.Date dueDate) {
123: this .dueDate = dueDate;
124: }
125:
126: /**
127: * the date at which to display feedback
128: * @param the date at which to display feedback
129: */
130: public void setFeedbackDate(java.util.Date feedbackDate) {
131: this .feedbackDate = feedbackDate;
132: }
133:
134: /**
135: * if required, assessment password
136: * @return password
137: */
138: public String getPassword() {
139: return password;
140: }
141:
142: /**
143: * if required, assessment user name
144: * @return user name
145: */
146: public String getUsername() {
147: if (username == null)
148: return "";
149: return username;
150: }
151:
152: /**
153: * if required, assessment password
154: * @param string assessment password
155: */
156: public void setPassword(String string) {
157: password = string;
158: }
159:
160: /**
161: * if required, assessment user name
162: * @param string assessment user name
163: */
164: public void setUsername(String string) {
165: username = string;
166: }
167:
168: /**
169: * Set of IP Addresses.
170: * @return list of IP Addresses.
171: */
172: public Set getIpAddresses() {
173: return ipAddresses;
174: }
175:
176: /**
177: * Set list of IP Addresses.
178: * @param string list of IP Addresses.
179: */
180: public void setIpAddresses(Set set) {
181: ipAddresses = set;
182: }
183:
184: /**
185: * No limit to number of attempts. True or false?
186: * @return
187: */
188: public boolean isUnlimitedAttempts() {
189: return unlimitedAttempts;
190: }
191:
192: /**
193: * Limit to number of attempts. Unlimited-- rue or false?
194: * @param unlimitedAttempts
195: */
196: public void setUnlimitedAttempts(boolean unlimitedAttempts) {
197: this .unlimitedAttempts = unlimitedAttempts;
198: }
199:
200: /**
201: * Is there one part per page?
202: * @return Is there one part per page?
203: */
204: public boolean isFormatByPart() {
205: return formatByPart;
206: }
207:
208: /**
209: * Is there one part per page?
210: * @param formatByPart Is there one part per page?
211: */
212: public void setFormatByPart(boolean formatByPart) {
213: this .formatByPart = formatByPart;
214: }
215:
216: /**
217: * Is there one question per page?
218: * @return Is there one question per page?
219: */
220: public boolean isFormatByQuestion() {
221: return formatByQuestion;
222: }
223:
224: /**
225: * Is there one question per page?
226: * @param formatByQuestion Is there one question per page?
227: */
228: public void setFormatByQuestion(boolean formatByQuestion) {
229: this .formatByQuestion = formatByQuestion;
230: }
231:
232: /**
233: * Is there the entire assessment on one page?
234: * @return Is there the entire assessment on one page?
235: */
236: public boolean isFormatByAssessment() {
237: return formatByAssessment;
238: }
239:
240: /**
241: * Is there the entire assessment on one page?
242: * @param formatByAssessment Is there the entire assessment on one page if true.
243: */
244: public void setFormatByAssessment(boolean formatByAssessment) {
245: this .formatByAssessment = formatByAssessment;
246: }
247:
248: /**
249: * Displayed on submission to grading.
250: * @return message on submission to grading.
251: */
252: public String getSubmissionMessage() {
253: return submissionMessage;
254: }
255:
256: /**
257: * Message on submission to grading.
258: * @param submissionMessage displayed on submission to grading.
259: */
260: public void setSubmissionMessage(String submissionMessage) {
261: this .submissionMessage = submissionMessage;
262: }
263:
264: public String getBgcolor() {
265: return checkColor(bgcolor, "bgcolor=transparent");
266: }
267:
268: public void setBgcolor(String color) {
269: bgcolor = "bgcolor=" + color;
270: }
271:
272: public String getBackground() {
273: return background;
274:
275: }
276:
277: public void setBackground(String bg) {
278: background = "background=" + bg;
279: }
280:
281: public String getDivBgcolor() {
282:
283: return "background:" + this .getBgcolor().substring(8);
284: }
285:
286: public String getDivBackground() {
287: if (getBackground() != null && !getBackground().equals("")) {
288: String divbg = "background-image:url("
289: + this .getBackground().substring(11) + ")";
290: return divbg;
291: } else
292:
293: return "";
294: }
295:
296: public String checkColor(String color, String defaultcolor) {
297: if (color == null || color.equals("")) {
298: return defaultcolor;
299: } else {
300: return color;
301: }
302: }
303:
304: public String getItemNumbering() {
305: return itemNumbering;
306: }
307:
308: public void setItemNumbering(String numbering) {
309: itemNumbering = numbering;
310: }
311:
312: public void setAssessmentAccessControl(
313: PublishedAssessmentIfc pubAssessment) {
314:
315: AssessmentAccessControlIfc control = pubAssessment
316: .getAssessmentAccessControl();
317: setAutoSubmit(control.AUTO_SUBMIT.equals(control
318: .getAutoSubmit()));
319: setAutoSave(control.AUTO_SAVE.equals(control
320: .getSubmissionsSaved()));
321: setDueDate(control.getDueDate());
322: if ((Boolean.TRUE).equals(control.getUnlimitedSubmissions())) {
323: setUnlimitedAttempts(true);
324: } else {
325: setUnlimitedAttempts(false);
326: if (control.getSubmissionsAllowed() != null) {
327: setMaxAttempts(control.getSubmissionsAllowed()
328: .intValue());
329: }
330: }
331: setSubmissionMessage(control.getSubmissionMessage());
332: setFeedbackDate(control.getFeedbackDate());
333: Integer format = control.getAssessmentFormat();
334: if (format == null)
335: format = new Integer(1);
336: setFormatByAssessment(control.BY_ASSESSMENT.equals(format));
337: setFormatByPart(control.BY_PART.equals(format));
338: setFormatByQuestion(control.BY_QUESTION.equals(format));
339: setUsername(control.getUsername());
340: setPassword(control.getPassword());
341: setItemNumbering(control.getItemNumbering().toString());
342:
343: setIpAddresses(pubAssessment.getSecuredIPAddressSet());
344:
345: Set set = pubAssessment.getAssessmentMetaDataSet();
346: Iterator iter = set.iterator();
347: while (iter.hasNext()) {
348: AssessmentMetaDataIfc data = (AssessmentMetaDataIfc) iter
349: .next();
350: if (data.getLabel().equals(AssessmentMetaDataIfc.BGCOLOR))
351: setBgcolor(data.getEntry());
352: else if (data.getLabel().equals(
353: AssessmentMetaDataIfc.BGIMAGE))
354: setBackground(data.getEntry());
355: }
356: }
357:
358: }
|