0001: /**********************************************************************************
0002: * $URL: https://source.sakaiproject.org/svn/sam/tags/sakai_2-4-1/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/bean/author/PublishedAssessmentSettingsBean.java $
0003: * $Id: PublishedAssessmentSettingsBean.java 28709 2007-04-12 00:08:46Z ajpoland@iupui.edu $
0004: ***********************************************************************************
0005: *
0006: * Copyright (c) 2004, 2005, 2006 The Sakai Foundation.
0007: *
0008: * Licensed under the Educational Community License, Version 1.0 (the"License");
0009: * you may not use this file except in compliance with the License.
0010: * You may obtain a copy of the License at
0011: *
0012: * http://www.opensource.org/licenses/ecl1.php
0013: *
0014: * Unless required by applicable law or agreed to in writing, software
0015: * distributed under the License is distributed on an "AS IS" BASIS,
0016: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
0017: * See the License for the specific language governing permissions and
0018: * limitations under the License.
0019: *
0020: **********************************************************************************/package org.sakaiproject.tool.assessment.ui.bean.author;
0021:
0022: import java.io.Serializable;
0023: import java.text.SimpleDateFormat;
0024: import java.util.ArrayList;
0025: import java.util.Arrays;
0026: import java.util.Calendar;
0027: import java.util.Date;
0028: import java.util.HashMap;
0029: import java.util.Iterator;
0030: import java.util.List;
0031: import java.util.Set;
0032: import javax.faces.context.ExternalContext;
0033: import javax.faces.context.FacesContext;
0034: import javax.faces.model.SelectItem;
0035:
0036: import org.apache.commons.logging.Log;
0037: import org.apache.commons.logging.LogFactory;
0038:
0039: import org.sakaiproject.service.gradebook.shared.GradebookService;
0040: import org.sakaiproject.spring.SpringBeanLocator;
0041: import org.sakaiproject.tool.assessment.data.ifc.assessment.AssessmentAccessControlIfc;
0042: import org.sakaiproject.tool.assessment.data.ifc.assessment.AssessmentFeedbackIfc;
0043: import org.sakaiproject.tool.assessment.data.ifc.assessment.AssessmentMetaDataIfc;
0044: import org.sakaiproject.tool.assessment.data.ifc.assessment.EvaluationModelIfc;
0045: import org.sakaiproject.tool.assessment.data.ifc.assessment.SecuredIPAddressIfc;
0046: import org.sakaiproject.tool.assessment.facade.AgentFacade;
0047: import org.sakaiproject.tool.assessment.facade.GradebookFacade;
0048: import org.sakaiproject.tool.assessment.facade.PublishedAssessmentFacade;
0049: import org.sakaiproject.tool.assessment.integration.context.IntegrationContextFactory;
0050: import org.sakaiproject.tool.assessment.integration.helper.ifc.GradebookServiceHelper;
0051: import org.sakaiproject.tool.assessment.integration.helper.ifc.PublishingTargetHelper;
0052: import org.sakaiproject.tool.assessment.ui.listener.util.ContextUtil;
0053: import org.sakaiproject.tool.assessment.ui.listener.util.TimeUtil;
0054:
0055: public class PublishedAssessmentSettingsBean implements Serializable {
0056: private static Log log = LogFactory
0057: .getLog(PublishedAssessmentSettingsBean.class);
0058:
0059: private static final IntegrationContextFactory integrationContextFactory = IntegrationContextFactory
0060: .getInstance();
0061: private static final PublishingTargetHelper ptHelper = integrationContextFactory
0062: .getPublishingTargetHelper();
0063: private static final GradebookServiceHelper gbsHelper = integrationContextFactory
0064: .getGradebookServiceHelper();
0065: private static final boolean integrated = integrationContextFactory
0066: .isIntegrated();
0067: /**
0068: * we use the calendar widget which uses 'MM/dd/yyyy hh:mm:ss a'
0069: * used to take the internal format from calendar picker and move it
0070: * transparently in and out of the date properties
0071: *
0072: */
0073: // private static final String DISPLAY_DATEFORMAT = "MM/dd/yyyy hh:mm:ss a";
0074: private String display_dateFormat = ContextUtil.getLocalizedString(
0075: "org.sakaiproject.tool.assessment.bundle.GeneralMessages",
0076: "output_data_picker_w_sec");
0077:
0078: private SimpleDateFormat displayFormat = new SimpleDateFormat(
0079: display_dateFormat);
0080:
0081: /** Use serialVersionUID for interoperability. */
0082: private final static long serialVersionUID = -630950053380808339L;
0083: private PublishedAssessmentFacade assessment;
0084: private Long assessmentId;
0085: private String title;
0086: private String creator;
0087: private String description;
0088: private boolean hasQuestions;
0089:
0090: // meta data
0091: private String objectives;
0092: private String keywords;
0093: private String rubrics;
0094: private String authors;
0095:
0096: // these are properties in PublishedAccessControl
0097: private Date startDate;
0098: private Date dueDate;
0099: private Date retractDate;
0100: private Date feedbackDate;
0101: private Integer timeLimit; // in seconds, calculated from timedHours & timedMinutes
0102: private Integer timedHours;
0103: private Integer timedMinutes;
0104: private Integer timedSeconds;
0105: private boolean timedAssessment = false;
0106: private boolean autoSubmit = false;
0107: private String assessmentFormat; // question (1)/part(2)/assessment(3) on separate page
0108: private String itemNavigation; // linear (1)or random (2)
0109: private String itemNumbering; // continuous between parts(1), restart between parts(2)
0110: private String unlimitedSubmissions;
0111: private String submissionsAllowed;
0112: private String submissionsSaved; // bad name, this is autoSaved
0113: private String lateHandling;
0114: private String submissionMessage;
0115: private SelectItem[] publishingTargets;
0116: private String[] targetSelected;
0117: private String firstTargetSelected;
0118: private String releaseTo;
0119: private String username;
0120: private String password;
0121: private String finalPageUrl;
0122: private String ipAddresses;
0123:
0124: // properties of PublishedFeedback
0125: private String feedbackDelivery; // immediate, on specific date , no feedback
0126: private String feedbackAuthoring;
0127: private String editComponents; // 0 = cannot
0128: private boolean showQuestionText = false;
0129: private boolean showStudentResponse = false;
0130: private boolean showCorrectResponse = false;
0131: private boolean showStudentScore = false;
0132: private boolean showStudentQuestionScore = false;
0133: private boolean showQuestionLevelFeedback = false;
0134: private boolean showSelectionLevelFeedback = false; // must be MC
0135: private boolean showGraderComments = false;
0136: private boolean showStatistics = false;
0137:
0138: // properties of PublishedEvaluationModel
0139: private String anonymousGrading;
0140: private boolean gradebookExists;
0141: private String toDefaultGradebook;
0142: private String scoringType;
0143: private String bgColor;
0144: private String bgImage;
0145: private HashMap values = new HashMap();
0146:
0147: // extra properties
0148: private String publishedUrl;
0149: private String alias;
0150:
0151: private String outcome;
0152:
0153: /*
0154: * Creates a new AssessmentBean object.
0155: */
0156: public PublishedAssessmentSettingsBean() {
0157: }
0158:
0159: public PublishedAssessmentFacade getAssessment() {
0160: return assessment;
0161: }
0162:
0163: public void setAssessment(PublishedAssessmentFacade assessment) {
0164: try {
0165: this .assessment = assessment;
0166: // set the valueMap
0167: setValueMap(assessment.getAssessmentMetaDataMap());
0168: this .assessmentId = assessment.getPublishedAssessmentId();
0169: this .title = assessment.getTitle();
0170: this .creator = AgentFacade.getDisplayName(assessment
0171: .getCreatedBy());
0172: this .description = assessment.getDescription();
0173: // assessment meta data
0174: this .authors = assessment
0175: .getAssessmentMetaDataByLabel(AssessmentMetaDataIfc.AUTHORS);
0176: this .objectives = assessment
0177: .getAssessmentMetaDataByLabel(AssessmentMetaDataIfc.OBJECTIVES);
0178: this .keywords = assessment
0179: .getAssessmentMetaDataByLabel(AssessmentMetaDataIfc.KEYWORDS);
0180: this .rubrics = assessment
0181: .getAssessmentMetaDataByLabel(AssessmentMetaDataIfc.RUBRICS);
0182: this .bgColor = assessment
0183: .getAssessmentMetaDataByLabel(AssessmentMetaDataIfc.BGCOLOR);
0184: this .bgImage = assessment
0185: .getAssessmentMetaDataByLabel(AssessmentMetaDataIfc.BGIMAGE);
0186:
0187: // these are properties in AssessmentAccessControl
0188: AssessmentAccessControlIfc accessControl = null;
0189: accessControl = assessment.getAssessmentAccessControl();
0190: if (accessControl != null) {
0191: this .startDate = accessControl.getStartDate();
0192: this .dueDate = accessControl.getDueDate();
0193: this .retractDate = accessControl.getRetractDate();
0194: this .feedbackDate = accessControl.getFeedbackDate();
0195:
0196: // deal with releaseTo
0197: this .releaseTo = accessControl.getReleaseTo(); // list of String
0198: this .publishingTargets = getPublishingTargets();
0199: this .targetSelected = getTargetSelected(releaseTo);
0200: this .firstTargetSelected = getFirstTargetSelected(releaseTo);
0201:
0202: this .timeLimit = accessControl.getTimeLimit(); // in seconds
0203: if (timeLimit != null && timeLimit.intValue() > 0)
0204: setTimeLimitDisplay(timeLimit.intValue());
0205: if ((new Integer(1)).equals(assessment
0206: .getAssessmentAccessControl()
0207: .getTimedAssessment()))
0208: this .timedAssessment = true;
0209: if ((new Integer(1)).equals(assessment
0210: .getAssessmentAccessControl().getAutoSubmit()))
0211: this .autoSubmit = true;
0212: if (accessControl.getAssessmentFormat() != null)
0213: this .assessmentFormat = accessControl
0214: .getAssessmentFormat().toString(); // question/part/assessment on separate page
0215: if (accessControl.getItemNavigation() != null)
0216: this .itemNavigation = accessControl
0217: .getItemNavigation().toString(); // linear or random
0218: if (accessControl.getItemNumbering() != null)
0219: this .itemNumbering = accessControl
0220: .getItemNumbering().toString();
0221: if (accessControl.getSubmissionsSaved() != null)
0222: this .submissionsSaved = accessControl
0223: .getSubmissionsSaved().toString();
0224:
0225: // default to unlimited if control value is null
0226: if (accessControl.getUnlimitedSubmissions() != null
0227: && !accessControl.getUnlimitedSubmissions()
0228: .booleanValue()) {
0229: this .unlimitedSubmissions = AssessmentAccessControlIfc.LIMITED_SUBMISSIONS
0230: .toString();
0231: this .submissionsAllowed = accessControl
0232: .getSubmissionsAllowed().toString();
0233: } else {
0234: this .unlimitedSubmissions = AssessmentAccessControlIfc.UNLIMITED_SUBMISSIONS
0235: .toString();
0236: this .submissionsAllowed = "";
0237: }
0238:
0239: if (accessControl.getLateHandling() != null)
0240: this .lateHandling = accessControl.getLateHandling()
0241: .toString();
0242: if (accessControl.getSubmissionsSaved() != null)
0243: this .submissionsSaved = accessControl
0244: .getSubmissionsSaved().toString();
0245: this .submissionMessage = accessControl
0246: .getSubmissionMessage();
0247: this .username = accessControl.getUsername();
0248: this .password = accessControl.getPassword();
0249: this .finalPageUrl = accessControl.getFinalPageUrl();
0250: }
0251:
0252: // properties of AssesmentFeedback
0253: AssessmentFeedbackIfc feedback = assessment
0254: .getAssessmentFeedback();
0255: if (feedback != null) {
0256: if (feedback.getFeedbackDelivery() != null)
0257: this .feedbackDelivery = feedback
0258: .getFeedbackDelivery().toString();
0259: if (feedback.getFeedbackAuthoring() != null)
0260: this .feedbackAuthoring = feedback
0261: .getFeedbackAuthoring().toString();
0262: if ((Boolean.TRUE).equals(feedback
0263: .getShowQuestionText()))
0264: this .showQuestionText = true;
0265: if ((Boolean.TRUE).equals(feedback
0266: .getShowStudentResponse()))
0267: this .showStudentResponse = true;
0268: if ((Boolean.TRUE).equals(feedback
0269: .getShowCorrectResponse()))
0270: this .showCorrectResponse = true;
0271: if ((Boolean.TRUE).equals(feedback
0272: .getShowStudentScore()))
0273: this .showStudentScore = true;
0274: if ((Boolean.TRUE).equals(feedback
0275: .getShowStudentQuestionScore()))
0276: this .showStudentQuestionScore = true;
0277: if ((Boolean.TRUE).equals(feedback
0278: .getShowQuestionLevelFeedback()))
0279: this .showQuestionLevelFeedback = true;
0280: if ((Boolean.TRUE).equals(feedback
0281: .getShowSelectionLevelFeedback()))
0282: this .showSelectionLevelFeedback = true;// must be MC
0283: if ((Boolean.TRUE).equals(feedback
0284: .getShowGraderComments()))
0285: this .showGraderComments = true;
0286: if ((Boolean.TRUE).equals(feedback.getShowStatistics()))
0287: this .showStatistics = true;
0288: }
0289:
0290: // properties of EvaluationModel
0291: EvaluationModelIfc evaluation = assessment
0292: .getEvaluationModel();
0293: if (evaluation != null) {
0294: if (evaluation.getAnonymousGrading() != null)
0295: this .anonymousGrading = evaluation
0296: .getAnonymousGrading().toString();
0297: if (evaluation.getToGradeBook() != null)
0298: this .toDefaultGradebook = evaluation
0299: .getToGradeBook();
0300: if (evaluation.getScoringType() != null)
0301: this .scoringType = evaluation.getScoringType()
0302: .toString();
0303:
0304: String currentSiteId = AgentFacade.getCurrentSiteId();
0305: this .gradebookExists = gbsHelper
0306: .isGradebookExist(currentSiteId);
0307: /*
0308: GradebookService g = null;
0309: if (integrated)
0310: {
0311: g = (GradebookService) SpringBeanLocator.getInstance().
0312: getBean("org.sakaiproject.service.gradebook.GradebookService");
0313: }
0314:
0315: this.gradebookExists = gbsHelper.gradebookExists(
0316: GradebookFacade.getGradebookUId(), g);
0317: */
0318: }
0319:
0320: //set IPAddresses
0321: setIpAddresses(assessment);
0322:
0323: // publishedUrl
0324: FacesContext context = FacesContext.getCurrentInstance();
0325: ExternalContext extContext = context.getExternalContext();
0326: // get the alias to the pub assessment
0327: this .alias = assessment
0328: .getAssessmentMetaDataByLabel(AssessmentMetaDataIfc.ALIAS);
0329: String server = ((javax.servlet.http.HttpServletRequest) extContext
0330: .getRequest()).getRequestURL().toString();
0331: int index = server.indexOf(extContext
0332: .getRequestContextPath()
0333: + "/"); // "/samigo/"
0334: server = server.substring(0, index);
0335: String url = server + extContext.getRequestContextPath();
0336: this .publishedUrl = url + "/servlet/Login?id=" + this .alias;
0337: } catch (RuntimeException ex) {
0338: log.warn(ex.getMessage());
0339: }
0340: }
0341:
0342: // properties from Assessment
0343: public Long getAssessmentId() {
0344: return this .assessmentId;
0345: }
0346:
0347: public void setAssessmentId(Long assessmentId) {
0348: this .assessmentId = assessmentId;
0349: }
0350:
0351: public String getTitle() {
0352: return this .title;
0353: }
0354:
0355: public void setTitle(String title) {
0356: this .title = title;
0357: }
0358:
0359: public String getCreator() {
0360: return this .creator;
0361: }
0362:
0363: public void setCreator(String creator) {
0364: this .creator = creator;
0365: }
0366:
0367: public String getDescription() {
0368: return this .description;
0369: }
0370:
0371: public void setDescription(String description) {
0372: this .description = description;
0373: }
0374:
0375: // properties form AssessmentMetaData
0376: public String getObjectives() {
0377: return this .objectives;
0378: }
0379:
0380: public void setObjectives(String objectives) {
0381: this .objectives = objectives;
0382: }
0383:
0384: public String getKeywords() {
0385: return this .keywords;
0386: }
0387:
0388: public void setKeywords(String keywords) {
0389: this .keywords = keywords;
0390: }
0391:
0392: public String getRubrics() {
0393: return this .rubrics;
0394: }
0395:
0396: public void setRubrics(String rubrics) {
0397: this .rubrics = rubrics;
0398: }
0399:
0400: public String getAuthors() {
0401: return this .authors;
0402: }
0403:
0404: public void setAuthors(String authors) {
0405: this .authors = authors;
0406: }
0407:
0408: public String getBgColor() {
0409: return this .bgColor;
0410: }
0411:
0412: public void setBgColor(String bgColor) {
0413: this .bgColor = bgColor;
0414: }
0415:
0416: public String getBgImage() {
0417: return this .bgImage;
0418: }
0419:
0420: public void setBgImage(String bgImage) {
0421: this .bgImage = bgImage;
0422: }
0423:
0424: public boolean getHasQuestions() {
0425: return this .hasQuestions;
0426: }
0427:
0428: public void setHasQuestions(boolean hasQuestions) {
0429: this .hasQuestions = hasQuestions;
0430: }
0431:
0432: // copied from AssessmentAccessControl ;-)
0433: public Date getStartDate() {
0434: return this .startDate;
0435: }
0436:
0437: public void setStartDate(Date startDate) {
0438: this .startDate = startDate;
0439: }
0440:
0441: public Date getDueDate() {
0442: return this .dueDate;
0443: }
0444:
0445: public void setDueDate(Date dueDate) {
0446: this .dueDate = dueDate;
0447: }
0448:
0449: public Date getFeedbackDate() {
0450: return this .feedbackDate;
0451: }
0452:
0453: public void setFeedbackDate(Date feedbackDate) {
0454: this .feedbackDate = feedbackDate;
0455: }
0456:
0457: public Date getRetractDate() {
0458: return this .retractDate;
0459: }
0460:
0461: public void setRetractDate(Date retractDate) {
0462: this .retractDate = retractDate;
0463: }
0464:
0465: public String getReleaseTo() {
0466: String anonymousString = "";
0467: String authenticatedString = "";
0468: if (values.get("hasAnonymousRelease") != null)
0469: anonymousString = values.get("hasAnonymousRelease")
0470: .toString();
0471: if (values.get("hasAuthenticatedRelease") != null)
0472: authenticatedString = values.get("hasAuthenticatedRelease")
0473: .toString();
0474: if (("true").equals(anonymousString)
0475: && ("true").equals(authenticatedString))
0476: this .releaseTo = "anonymous; authenticated users";
0477: else if (("true").equals(anonymousString))
0478: this .releaseTo = "anonymous";
0479: else if (("true").equals(authenticatedString))
0480: this .releaseTo = "authenticated users";
0481: return this .releaseTo;
0482: }
0483:
0484: public void setReleaseTo(String releaseTo) {
0485: this .releaseTo = releaseTo;
0486: }
0487:
0488: public Integer getTimeLimit() {
0489: return new Integer(timedHours.intValue() * 3600
0490: + timedMinutes.intValue() * 60
0491: + timedSeconds.intValue());
0492: }
0493:
0494: public void setTimeLimit(Integer timeLimit) {
0495: this .timeLimit = timeLimit;
0496: }
0497:
0498: public void setTimedHours(Integer timedHours) {
0499: this .timedHours = timedHours;
0500: }
0501:
0502: public Integer getTimedHours() {
0503: return timedHours;
0504: }
0505:
0506: public void setTimedMinutes(Integer timedMinutes) {
0507: this .timedMinutes = timedMinutes;
0508: }
0509:
0510: public Integer getTimedMinutes() {
0511: return timedMinutes;
0512: }
0513:
0514: public void setTimedSeconds(Integer timedSeconds) {
0515: this .timedSeconds = timedSeconds;
0516: }
0517:
0518: public Integer getTimedSeconds() {
0519: return timedSeconds;
0520: }
0521:
0522: public boolean getTimedAssessment() {
0523: return timedAssessment;
0524: }
0525:
0526: public void setTimedAssessment(boolean timedAssessment) {
0527: this .timedAssessment = timedAssessment;
0528: }
0529:
0530: public boolean getAutoSubmit() {
0531: return autoSubmit;
0532: }
0533:
0534: public void setAutoSubmit(boolean autoSubmit) {
0535: this .autoSubmit = autoSubmit;
0536: }
0537:
0538: public String getAssessmentFormat() {
0539: return assessmentFormat;
0540: }
0541:
0542: public void setAssessmentFormat(String assessmentFormat) {
0543: this .assessmentFormat = assessmentFormat;
0544: }
0545:
0546: public String getItemNavigation() {
0547: return itemNavigation;
0548: }
0549:
0550: public void setItemNavigation(String itemNavigation) {
0551: this .itemNavigation = itemNavigation;
0552: }
0553:
0554: public String getItemNumbering() {
0555: return itemNumbering;
0556: }
0557:
0558: public void setItemNumbering(String itemNumbering) {
0559: this .itemNumbering = itemNumbering;
0560: }
0561:
0562: public String getUnlimitedSubmissions() {
0563: return unlimitedSubmissions;
0564: }
0565:
0566: public void setUnlimitedSubmissions(String unlimitedSubmissions) {
0567: this .unlimitedSubmissions = unlimitedSubmissions;
0568: }
0569:
0570: public String getSubmissionsAllowed() {
0571: return submissionsAllowed;
0572: }
0573:
0574: public void setSubmissionsAllowed(String submissionsAllowed) {
0575: this .submissionsAllowed = submissionsAllowed;
0576: }
0577:
0578: public void setLateHandling(String lateHandling) {
0579: this .lateHandling = lateHandling;
0580: }
0581:
0582: public String getLateHandling() {
0583: return lateHandling;
0584: }
0585:
0586: // bad name - this is autoSaved
0587: public void setSubmissionsSaved(String submissionSaved) {
0588: this .submissionsSaved = submissionSaved;
0589: }
0590:
0591: public String getSubmissionsSaved() {
0592: return submissionsSaved;
0593: }
0594:
0595: public void setSubmissionMessage(String submissionMessage) {
0596: this .submissionMessage = submissionMessage;
0597: }
0598:
0599: public String getSubmissionMessage() {
0600: return submissionMessage;
0601: }
0602:
0603: public String getUsername() {
0604: return this .username;
0605: }
0606:
0607: public void setUsername(String username) {
0608: this .username = username;
0609: }
0610:
0611: public String getPassword() {
0612: return this .password;
0613: }
0614:
0615: public void setPassword(String password) {
0616: this .password = password;
0617: }
0618:
0619: public void setFinalPageUrl(String finalPageUrl) {
0620: this .finalPageUrl = finalPageUrl;
0621: }
0622:
0623: public String getFinalPageUrl() {
0624: return finalPageUrl;
0625: }
0626:
0627: public String getFeedbackDelivery() {
0628: return feedbackDelivery;
0629: }
0630:
0631: public void setFeedbackDelivery(String feedbackDelivery) {
0632: this .feedbackDelivery = feedbackDelivery;
0633: }
0634:
0635: public String getFeedbackAuthoring() {
0636: return feedbackAuthoring;
0637: }
0638:
0639: public void setFeedbackAuthoring(String feedbackAuthoring) {
0640: this .feedbackAuthoring = feedbackAuthoring;
0641: }
0642:
0643: public boolean getShowQuestionText() {
0644: return showQuestionText;
0645: }
0646:
0647: public void setShowQuestionText(boolean showQuestionText) {
0648: this .showQuestionText = showQuestionText;
0649: }
0650:
0651: public boolean getShowStudentResponse() {
0652: return showStudentResponse;
0653: }
0654:
0655: public void setShowStudentResponse(boolean showStudentResponse) {
0656: this .showStudentResponse = showStudentResponse;
0657: }
0658:
0659: public boolean getShowCorrectResponse() {
0660: return showCorrectResponse;
0661: }
0662:
0663: public void setShowCorrectResponse(boolean showCorrectResponse) {
0664: this .showCorrectResponse = showCorrectResponse;
0665: }
0666:
0667: public boolean getShowStudentScore() {
0668: return showStudentScore;
0669: }
0670:
0671: public void setShowStudentScore(boolean showStudentScore) {
0672: this .showStudentScore = showStudentScore;
0673: }
0674:
0675: public boolean getShowStudentQuestionScore() {
0676: return showStudentQuestionScore;
0677: }
0678:
0679: public void setShowStudentQuestionScore(
0680: boolean showStudentQuestionScore) {
0681: this .showStudentQuestionScore = showStudentQuestionScore;
0682: }
0683:
0684: public boolean getShowQuestionLevelFeedback() {
0685: return showQuestionLevelFeedback;
0686: }
0687:
0688: public void setShowQuestionLevelFeedback(
0689: boolean showQuestionLevelFeedback) {
0690: this .showQuestionLevelFeedback = showQuestionLevelFeedback;
0691: }
0692:
0693: public boolean getShowSelectionLevelFeedback() {
0694: return showSelectionLevelFeedback;
0695: }
0696:
0697: public void setShowSelectionLevelFeedback(
0698: boolean showSelectionLevelFeedback) {
0699: this .showSelectionLevelFeedback = showSelectionLevelFeedback;
0700: }
0701:
0702: public boolean getShowGraderComments() {
0703: return showGraderComments;
0704: }
0705:
0706: public void setShowGraderComments(boolean showGraderComments) {
0707: this .showGraderComments = showGraderComments;
0708: }
0709:
0710: public boolean getShowStatistics() {
0711: return showStatistics;
0712: }
0713:
0714: public void setShowStatistics(boolean showStatistics) {
0715: this .showStatistics = showStatistics;
0716: }
0717:
0718: public String getAnonymousGrading() {
0719: return this .anonymousGrading;
0720: }
0721:
0722: public void setAnonymousGrading(String anonymousGrading) {
0723: this .anonymousGrading = anonymousGrading;
0724: }
0725:
0726: public String getToDefaultGradebook() {
0727: return this .toDefaultGradebook;
0728: }
0729:
0730: public void setToDefaultGradebook(String toDefaultGradebook) {
0731: this .toDefaultGradebook = toDefaultGradebook;
0732: }
0733:
0734: public boolean getGradebookExists() {
0735: return this .gradebookExists;
0736: }
0737:
0738: public void setGradebookExists(boolean gradebookExists) {
0739: this .gradebookExists = gradebookExists;
0740: }
0741:
0742: public String getScoringType() {
0743: return this .scoringType;
0744: }
0745:
0746: public void setScoringType(String scoringType) {
0747: this .scoringType = scoringType;
0748: }
0749:
0750: public void setValue(String key, Object value) {
0751: this .values.put(key, value);
0752: }
0753:
0754: public Object getValue(String key) {
0755: if (this .values.get(key) == null) {
0756: return Boolean.FALSE;
0757: }
0758:
0759: return values.get(key);
0760: }
0761:
0762: public void setValueMap(HashMap newMap) {
0763: this .values = newMap;
0764: }
0765:
0766: public HashMap getValueMap() {
0767: return values;
0768: }
0769:
0770: public String getDateString(Date date) {
0771: if (date != null) {
0772: Calendar c = Calendar.getInstance();
0773: c.setTime(date);
0774: int mon = c.get(Calendar.MONTH);
0775: int day = c.get(Calendar.DAY_OF_MONTH);
0776: int year = c.get(Calendar.YEAR);
0777: String dateString = mon + "/" + day + "/" + year;
0778: return dateString;
0779: } else
0780: return "";
0781: }
0782:
0783: public void setTimeLimitDisplay(int time) {
0784: this .timedHours = new Integer(time / 60 / 60);
0785: this .timedMinutes = new Integer((time / 60) % 60);
0786: this .timedSeconds = new Integer(time % 60);
0787: }
0788:
0789: // followings are set of SelectItem[] used in authorSettings.jsp
0790: public SelectItem[] getHours() {
0791: return hours;
0792: }
0793:
0794: public static void setHours(SelectItem[] hours) {
0795: PublishedAssessmentSettingsBean.hours = hours;
0796: }
0797:
0798: public SelectItem[] getMins() {
0799: return mins;
0800: }
0801:
0802: public static void setMins(SelectItem[] mins) {
0803: PublishedAssessmentSettingsBean.mins = mins;
0804: }
0805:
0806: private static List months;
0807: private static List days;
0808: private static SelectItem[] mins;
0809: private static SelectItem[] hours;
0810: static {
0811: months = new ArrayList();
0812: for (int i = 1; i <= 12; i++) {
0813: months.add(new SelectItem(new Integer(i)));
0814: }
0815: days = new ArrayList();
0816: for (int i = 1; i < 32; i++) {
0817: days.add(new SelectItem(new Integer(i)));
0818: }
0819: hours = new SelectItem[24];
0820: for (int i = 0; i < 24; i++) {
0821: if (i < 10)
0822: hours[i] = new SelectItem(new Integer(i), "0" + i);
0823: else
0824: hours[i] = new SelectItem(new Integer(i), i + "");
0825: }
0826: mins = new SelectItem[60];
0827: for (int i = 0; i < 60; i++) {
0828: if (i < 10)
0829: mins[i] = new SelectItem(new Integer(i), "0" + i);
0830: else
0831: mins[i] = new SelectItem(new Integer(i), i + "");
0832: }
0833: }
0834:
0835: public String getIpAddresses() {
0836: return ipAddresses;
0837: }
0838:
0839: public void setIpAddresses(PublishedAssessmentFacade assessment) {
0840: // ip addresses
0841: this .ipAddresses = "";
0842: Set ipAddressSet = assessment.getSecuredIPAddressSet();
0843: if (ipAddressSet != null) {
0844: Iterator iter = ipAddressSet.iterator();
0845: while (iter.hasNext()) {
0846: SecuredIPAddressIfc ip = (SecuredIPAddressIfc) iter
0847: .next();
0848: this .ipAddresses = ip.getIpAddress() + "\n"
0849: + this .ipAddresses;
0850: }
0851: }
0852: }
0853:
0854: // the following methods are used to take the internal format from
0855: // calendar picker and move it transparently in and out of the date
0856: // properties
0857:
0858: /**
0859: * date from internal string of calendar widget
0860: * @param date Date object
0861: * @return date String "MM-dd-yyyy hh:mm:ss a"
0862: */
0863: private String getDisplayFormatFromDate(Date date) {
0864: String dateString = "";
0865: if (date == null) {
0866: return dateString;
0867: }
0868:
0869: try {
0870: //dateString = displayFormat.format(date);
0871: TimeUtil tu = new TimeUtil();
0872: dateString = tu.getDisplayDateTime(displayFormat, date);
0873:
0874: } catch (Exception ex) {
0875: // we will leave it as an empty string
0876: log.warn("Unable to format date.");
0877: ex.printStackTrace();
0878: }
0879: return dateString;
0880: }
0881:
0882: /**
0883: * format according to internal requirements of calendar widget
0884: * @param dateString "MM-dd-yyyy hh:mm:ss a"
0885: * @return Date object
0886: */
0887: private Date getDateFromDisplayFormat(String dateString) {
0888: Date date = null;
0889: if (dateString == null || dateString.trim().equals("")) {
0890: return date;
0891: }
0892:
0893: try {
0894: //date = (Date) displayFormat.parse(dateString);
0895: TimeUtil tu = new TimeUtil();
0896: date = tu.getServerDateTime(displayFormat, dateString);
0897:
0898: } catch (Exception ex) {
0899: // we will leave it as a null date
0900: log.warn("Unable to format date.");
0901: ex.printStackTrace();
0902: }
0903:
0904: return date;
0905: }
0906:
0907: public String getStartDateString() {
0908: return getDisplayFormatFromDate(startDate);
0909: }
0910:
0911: public void setStartDateString(String startDateString) {
0912: this .startDate = getDateFromDisplayFormat(startDateString);
0913: }
0914:
0915: public String getDueDateString() {
0916: return getDisplayFormatFromDate(dueDate);
0917: }
0918:
0919: public void setDueDateString(String dueDateString) {
0920: this .dueDate = getDateFromDisplayFormat(dueDateString);
0921: }
0922:
0923: public String getRetractDateString() {
0924: return getDisplayFormatFromDate(retractDate);
0925: }
0926:
0927: public void setRetractDateString(String retractDateString) {
0928: this .retractDate = getDateFromDisplayFormat(retractDateString);
0929: }
0930:
0931: public String getFeedbackDateString() {
0932: return getDisplayFormatFromDate(feedbackDate);
0933: }
0934:
0935: public void setFeedbackDateString(String feedbackDateString) {
0936: this .feedbackDate = getDateFromDisplayFormat(feedbackDateString);
0937: }
0938:
0939: public String getPublishedUrl() {
0940: return this .publishedUrl;
0941: }
0942:
0943: public void setPublishedUrl(String publishedUrl) {
0944: this .publishedUrl = publishedUrl;
0945: }
0946:
0947: public String getAlias() {
0948: return this .alias;
0949: }
0950:
0951: public void setAlias(String alias) {
0952: this .alias = alias;
0953: }
0954:
0955: public SelectItem[] getPublishingTargets() {
0956: HashMap targets = ptHelper.getTargets();
0957: Set e = targets.keySet();
0958: Iterator iter = e.iterator();
0959: // sort the targets
0960: String[] titles = new String[targets.size()];
0961: while (iter.hasNext()) {
0962: for (int m = 0; m < e.size(); m++) {
0963: String t = (String) iter.next();
0964: //log.info("target "+m+"="+t);
0965: titles[m] = t;
0966: }
0967: }
0968: Arrays.sort(titles);
0969: SelectItem[] target = new SelectItem[targets.size()];
0970: for (int i = 0; i < titles.length; i++) {
0971: target[i] = new SelectItem(titles[i]);
0972: }
0973: /**
0974: SelectItem[] target = new SelectItem[targets.size()];
0975: while (iter.hasNext()) {
0976: for (int i = 0; i < e.size(); i++) {
0977: target[i] = new SelectItem( (String) iter.next());
0978: }
0979: }
0980: */
0981: return target;
0982: }
0983:
0984: public void setTargetSelected(String[] targetSelected) {
0985: this .targetSelected = targetSelected;
0986: }
0987:
0988: public String[] getTargetSelected() {
0989: return targetSelected;
0990: }
0991:
0992: public String[] getTargetSelected(String releaseTo) {
0993: if (releaseTo != null) {
0994: this .targetSelected = releaseTo.split(",");
0995: for (int i = 0; i < targetSelected.length; i++) {
0996: targetSelected[i] = targetSelected[i].trim();
0997: }
0998: }
0999: return this .targetSelected;
1000: }
1001:
1002: public void setFirstTargetSelected(String firstTargetSelected) {
1003: this .firstTargetSelected = firstTargetSelected.trim();
1004: this .targetSelected[0] = firstTargetSelected.trim();
1005: }
1006:
1007: public String getFirstTargetSelected() {
1008: return firstTargetSelected;
1009: }
1010:
1011: public String getFirstTargetSelected(String releaseTo) {
1012: if (releaseTo != null) {
1013: this .targetSelected = releaseTo.split(",");
1014: this .firstTargetSelected = targetSelected[0].trim();
1015: }
1016: return this .firstTargetSelected;
1017: }
1018:
1019: /**
1020: * @return Returns the outcome.
1021: */
1022: public String getOutcome() {
1023: return outcome;
1024: }
1025:
1026: /**
1027: * @param outcome The outcome to set.
1028: */
1029: public void setOutcome(String outcome) {
1030: this .outcome = outcome;
1031: }
1032:
1033: public boolean getActive() {
1034: Date currentDate = new Date();
1035: if ((this .dueDate != null && currentDate.after(this .dueDate))
1036: || (this .retractDate != null && currentDate
1037: .after(this .retractDate))) {
1038: return false;
1039: }
1040: return true;
1041: }
1042:
1043: }
|