001: package org.sakaiproject.tool.assessment.ui.bean.samlite;
002:
003: import java.io.Serializable;
004: import java.util.ArrayList;
005: import java.util.List;
006:
007: import org.sakaiproject.component.cover.ServerConfigurationService;
008: import org.sakaiproject.tool.assessment.facade.AssessmentFacade;
009: import org.sakaiproject.tool.assessment.facade.AssessmentFacadeQueries;
010: import org.sakaiproject.tool.assessment.facade.AssessmentTemplateFacade;
011: import org.sakaiproject.tool.assessment.samlite.api.QuestionGroup;
012: import org.sakaiproject.tool.assessment.samlite.api.SamLiteService;
013: import org.sakaiproject.tool.assessment.services.assessment.AssessmentService;
014: import org.sakaiproject.tool.assessment.ui.bean.author.AuthorBean;
015: import org.w3c.dom.Document;
016:
017: public class SamLiteBean implements Serializable {
018: private static final long serialVersionUID = -3122436861866172596L;
019: public static final String DEFAULT_CHARSET = "ascii-us";
020:
021: private String name;
022: private String description;
023: private String data;
024: private String assessmentTemplateId;
025:
026: private boolean isVisible = false;
027:
028: private AuthorBean authorBean;
029:
030: public void setAuthorBean(AuthorBean authorBean) {
031: this .authorBean = authorBean;
032: }
033:
034: private QuestionGroup questionGroup;
035: private SamLiteService samLiteService;
036:
037: public void setSamLiteService(SamLiteService samLiteService) {
038: this .samLiteService = samLiteService;
039: }
040:
041: public SamLiteBean() {
042: String samliteProperty = ServerConfigurationService
043: .getString("samigo.samliteEnabled");
044: if (null != samliteProperty && !"".equals(samliteProperty))
045: isVisible = "true".equalsIgnoreCase(samliteProperty);
046: }
047:
048: public void parse() {
049: questionGroup = samLiteService.parse(name, description, data);
050: }
051:
052: public Document createDocument() {
053: return samLiteService.createDocument(questionGroup);
054: }
055:
056: public void createAssessment(AssessmentFacade assessment) {
057: authorBean.setAssessTitle("");
058: authorBean.setAssessmentDescription("");
059: authorBean.setAssessmentTypeId("");
060: authorBean
061: .setAssessmentTemplateId(AssessmentTemplateFacade.DEFAULTTEMPLATE
062: .toString());
063:
064: AssessmentService assessmentService = new AssessmentService();
065: ArrayList list = assessmentService
066: .getBasicInfoOfAllActiveAssessments(
067: AssessmentFacadeQueries.TITLE, true);
068:
069: authorBean.setAssessments(list);
070: }
071:
072: public List getQuestions() {
073: return questionGroup.getQuestions();
074: }
075:
076: public QuestionGroup getQuestionGroup() {
077: return questionGroup;
078: }
079:
080: public void setQuestionGroup(QuestionGroup questionGroup) {
081: this .questionGroup = questionGroup;
082: }
083:
084: public String getData() {
085: return data;
086: }
087:
088: public void setData(String data) {
089: this .data = data;
090: }
091:
092: public String getDescription() {
093: return description;
094: }
095:
096: public void setDescription(String description) {
097: this .description = description;
098: }
099:
100: public String getName() {
101: return name;
102: }
103:
104: public void setName(String name) {
105: this .name = name;
106: }
107:
108: public void setAssessmentTemplateId(String assessmentTemplateId) {
109: this .assessmentTemplateId = assessmentTemplateId;
110: }
111:
112: public String getAssessmentTemplateId() {
113: return assessmentTemplateId;
114: }
115:
116: public boolean isVisible() {
117: return isVisible;
118: }
119:
120: public void setVisible(boolean isVisible) {
121: this.isVisible = isVisible;
122: }
123: }
|