diff --git a/ccm-cms-types-survey/pdl/com/arsdigita/content-types/Survey.pdl b/ccm-cms-types-survey/pdl/com/arsdigita/content-types/Survey.pdl
index 8a6104d5b..1280aaa44 100755
--- a/ccm-cms-types-survey/pdl/com/arsdigita/content-types/Survey.pdl
+++ b/ccm-cms-types-survey/pdl/com/arsdigita/content-types/Survey.pdl
@@ -7,7 +7,7 @@ object type Survey extends ContentPage {
to bebop_form_sections.form_section_id;
// Date[0..1] startDate = ct_surveys.start_date DATE;
// Date[0..1] endDate = ct_surveys.end_date DATE;
- Boolean[0..1] responsesPublic = ct_surveys.responses_public CHAR(1);
+ Boolean[0..1] responsesPublic = ct_surveys.responses_public BOOLEAN;
reference key ( ct_surveys.survey_id );
}
diff --git a/ccm-cms-types-survey/src/com/arsdigita/cms/contenttypes/Survey.java b/ccm-cms-types-survey/src/com/arsdigita/cms/contenttypes/Survey.java
index e66735cb3..dcc9c5c86 100755
--- a/ccm-cms-types-survey/src/com/arsdigita/cms/contenttypes/Survey.java
+++ b/ccm-cms-types-survey/src/com/arsdigita/cms/contenttypes/Survey.java
@@ -11,7 +11,6 @@ import com.arsdigita.domain.DataObjectNotFoundException;
import com.arsdigita.formbuilder.PersistentForm;
-
import com.arsdigita.util.Assert;
/**
@@ -31,7 +30,6 @@ public class Survey extends ContentPage {
// public static final String END_DATE = "endDate";
/** PDL property name for responsesPublic */
public static final String RESPONSES_PUBLIC = "responsesPublic";
-
/** Data object type for this domain object */
public static final String BASE_DATA_OBJECT_TYPE = "com.arsdigita.simplesurvey.Survey";
@@ -55,7 +53,7 @@ public class Survey extends ContentPage {
this(new OID(BASE_DATA_OBJECT_TYPE, id));
}
- /**
+ /**
* Constructor. The contained DataObject is retrieved
* from the persistent storage mechanism with an OID
* specified by id.
@@ -111,24 +109,23 @@ public class Survey extends ContentPage {
/*
public void setStartDate(Date startDate) {
- set(START_DATE, startDate);
+ set(START_DATE, startDate);
}
public Date getStartDate() {
- return (Date)get(START_DATE);
+ return (Date)get(START_DATE);
}
public void setEndDate(Date endDate) {
- set(END_DATE, endDate);
+ set(END_DATE, endDate);
}
public Date getEndDate() {
- return (Date)get(END_DATE);
+ return (Date)get(END_DATE);
}
- */
-
- public boolean responsesArePublic() {
- return ((Boolean) get(RESPONSES_PUBLIC)).booleanValue();
+ */
+ public boolean getResponsesPublic() {
+ return ((Boolean) get(RESPONSES_PUBLIC));
}
public void setResponsesPublic(Boolean responsesPublic) {
@@ -136,7 +133,6 @@ public class Survey extends ContentPage {
}
/* Class methods *********************************************************/
-
public static Survey retrieve(BigDecimal id)
throws DataObjectNotFoundException {
@@ -150,25 +146,25 @@ public class Survey extends ContentPage {
return survey;
}
-/*
+ /*
public SurveyResponseCollection getResponses() {
- return SurveyResponse.retrieveBySurvey(this);
+ return SurveyResponse.retrieveBySurvey(this);
}
public SurveyResponseCollection getUserResponses(User user) {
- return SurveyResponse.retrieveBySurvey(this, user);
+ return SurveyResponse.retrieveBySurvey(this, user);
}
public boolean hasUserResponded(User user) {
- SurveyResponseCollection responses = getUserResponses(user);
+ SurveyResponseCollection responses = getUserResponses(user);
- if (responses.next()) {
- responses.close();
- return true;
- }
- return false;
+ if (responses.next()) {
+ responses.close();
+ return true;
}
-*/
+ return false;
+ }
+ */
/*
public DataQuery getLabelDataQuery() {
diff --git a/ccm-cms-types-survey/src/com/arsdigita/cms/contenttypes/SurveyAnswer.java b/ccm-cms-types-survey/src/com/arsdigita/cms/contenttypes/SurveyAnswer.java
index 8f3af9c8b..24e620ba1 100755
--- a/ccm-cms-types-survey/src/com/arsdigita/cms/contenttypes/SurveyAnswer.java
+++ b/ccm-cms-types-survey/src/com/arsdigita/cms/contenttypes/SurveyAnswer.java
@@ -1,14 +1,12 @@
package com.arsdigita.cms.contenttypes;
import com.arsdigita.cms.ContentItem;
-import com.arsdigita.cms.ContentType;
import com.arsdigita.db.Sequences;
import com.arsdigita.domain.DataObjectNotFoundException;
import com.arsdigita.formbuilder.PersistentLabel;
import com.arsdigita.formbuilder.PersistentWidget;
import com.arsdigita.persistence.DataObject;
import com.arsdigita.persistence.OID;
-import com.arsdigita.util.Assert;
import java.math.BigDecimal;
/**
@@ -22,8 +20,6 @@ import java.math.BigDecimal;
*/
public class SurveyAnswer extends ContentItem {
- /** PDL property name for id */
- public static final String ID = "id";
/** PDL property name for label */
public static final String LABEL = "label";
/** PDL property name for widget */
@@ -90,11 +86,8 @@ public class SurveyAnswer extends ContentItem {
}
/* accessors *****************************************************/
- public BigDecimal getID() {
- return (BigDecimal) get(ID);
- }
-/* Class methods ********/
+ /* Class methods ********/
public static SurveyAnswer create(PersistentLabel label,
PersistentWidget widget,
String value) {
@@ -115,5 +108,4 @@ public class SurveyAnswer extends ContentItem {
set(WIDGET, widget);
set(VALUE, value);
}
-
}
diff --git a/ccm-cms-types-survey/src/com/arsdigita/cms/contenttypes/SurveyResponse.java b/ccm-cms-types-survey/src/com/arsdigita/cms/contenttypes/SurveyResponse.java
index a58a2f363..f1b25b7ef 100755
--- a/ccm-cms-types-survey/src/com/arsdigita/cms/contenttypes/SurveyResponse.java
+++ b/ccm-cms-types-survey/src/com/arsdigita/cms/contenttypes/SurveyResponse.java
@@ -7,7 +7,6 @@ import com.arsdigita.formbuilder.PersistentWidget;
import com.arsdigita.kernel.User;
import com.arsdigita.persistence.DataObject;
import com.arsdigita.persistence.OID;
-import com.arsdigita.simplesurvey.Survey;
import java.math.BigDecimal;
import java.util.Date;
diff --git a/ccm-cms-types-survey/src/com/arsdigita/cms/contenttypes/ui/SurveyProcessListener.java b/ccm-cms-types-survey/src/com/arsdigita/cms/contenttypes/ui/SurveyProcessListener.java
index a1dc8cdf0..208b77402 100755
--- a/ccm-cms-types-survey/src/com/arsdigita/cms/contenttypes/ui/SurveyProcessListener.java
+++ b/ccm-cms-types-survey/src/com/arsdigita/cms/contenttypes/ui/SurveyProcessListener.java
@@ -16,8 +16,7 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
-package com.arsdigita.simplesurvey.ui;
-
+package com.arsdigita.cms.contenttypes.ui;
import com.arsdigita.bebop.event.FormProcessListener;
import com.arsdigita.bebop.event.FormSectionEvent;
@@ -35,13 +34,11 @@ import java.util.Map;
import java.util.HashMap;
import com.arsdigita.bebop.FormData;
import com.arsdigita.bebop.PageState;
-import com.arsdigita.bebop.RequestLocal;
-import com.arsdigita.simplesurvey.Survey;
-import com.arsdigita.simplesurvey.Response;
import com.arsdigita.bebop.RequestLocal;
-import com.arsdigita.simplesurvey.ui.Question;
import com.arsdigita.bebop.parameters.ParameterData;
+import com.arsdigita.cms.contenttypes.Survey;
+import com.arsdigita.cms.contenttypes.SurveyResponse;
import com.arsdigita.persistence.DataAssociationCursor;
import com.arsdigita.persistence.DataOperation;
import com.arsdigita.persistence.SessionManager;
@@ -58,135 +55,136 @@ import org.apache.log4j.Logger;
/**
* The process lister that processes a survey response entered by a user.
*
- * @author Peter Marklund
- * @version $Id: SurveyProcessListener.java 759 2005-09-02 15:25:32Z sskracic $
*/
-public class SurveyProcessListener
- implements FormProcessListener {
+public class SurveyProcessListener
+ implements FormProcessListener {
public static final String SURVEY_ID_NAME = "__ss_survey_id__";
public static final String RESPONSE_ID = "__ss_response_id__";
-
public static final BigDecimal THE_PUBLIC_USER = new BigDecimal(-200);
private static final String KNOWLEDGE_TEST = "knowledge_test";
protected RequestLocal m_persistentForm = new RequestLocal();
private RequestLocal m_nameQuestionMap = new RequestLocal();
- private RequestLocal m_response;
-
- private static org.apache.log4j.Logger s_log =
- Logger.getLogger(SurveyProcessListener.class.getName());
+ private RequestLocal m_response;
+ private static org.apache.log4j.Logger s_log =
+ Logger.getLogger(SurveyProcessListener.class.getName());
public SurveyProcessListener(RequestLocal response) {
- m_response = response;
+ m_response = response;
}
+
public SurveyProcessListener() {
- m_response = null;
+ m_response = null;
}
-
+
public void process(FormSectionEvent event) {
FormData formData = event.getFormData();
PageState ps = event.getPageState();
- BigDecimal surveyID = (BigDecimal)formData.get(SURVEY_ID_NAME);
- BigDecimal responseID = (BigDecimal)formData.get(RESPONSE_ID);
- m_response.set(ps, responseID);
+ BigDecimal surveyID = (BigDecimal) formData.get(SURVEY_ID_NAME);
+ BigDecimal responseID = (BigDecimal) formData.get(RESPONSE_ID);
+ m_response.set(ps, responseID);
Survey survey = (Survey) FormBuilderUtil.instantiateObjectOneArg(Survey.class.getName(), surveyID);
- Response response = null;
- try {
- response = (Response) DomainObjectFactory.newInstance( new OID(Response.class.getName(), responseID));
- } catch (DataObjectNotFoundException ex) {
- // s_log.warn("Can't create this object" + responseID);
- }
-
- //Let's not save the data twice in the case of a double-click
- if ( response.questionsAnswered() ) {
- return;
- }
-
+ SurveyResponse response = null;
+ try {
+ response = (SurveyResponse) DomainObjectFactory.newInstance(new OID(SurveyResponse.class.getName(), responseID));
+ } catch (DataObjectNotFoundException ex) {
+ // s_log.warn("Can't create this object" + responseID);
+ }
+
+ //Let's not save the data twice in the case of a double-click
+ if (response.questionsAnswered()) {
+ return;
+ }
+
m_persistentForm.set(ps, survey.getForm());
// Get the responding user
User user = KernelHelper.getCurrentUser(ps.getRequest());
- // Use the generic user "The Public" if the user is not registered
- if ( user == null) {
- try {
- user = User.retrieve(THE_PUBLIC_USER);
- } catch ( DataObjectNotFoundException e ) {
- s_log.error("Public User does not exist.");
- }
- }
+ // Use the generic user "The Public" if the user is not registered
+ if (user == null) {
+ try {
+ user = User.retrieve(THE_PUBLIC_USER);
+ } catch (DataObjectNotFoundException e) {
+ s_log.error("Public User does not exist.");
+ }
+ }
// Iterate over the widget parameters and insert the answers to the survey response
Iterator parameterIter = formData.getParameters().iterator();
while (parameterIter.hasNext()) {
- s_log.warn("Found some formData");
- ParameterData parameterData = (ParameterData)parameterIter.next();
+ s_log.warn("Found some formData");
+ ParameterData parameterData = (ParameterData) parameterIter.next();
- String parameterName = (String)parameterData.getName();
+ String parameterName = (String) parameterData.getName();
- Object parameterValue = parameterData.getValue();
- if (parameterValue instanceof java.lang.String[]) {
- // This is a multi-answer question - iterate over the
- // answer values and add them one by one
- String[] valueArray = (String[])parameterValue;
- for (int i = 0; i < valueArray.length; ++i) {
- addAnswer(response, ps, valueArray[i], parameterName);
-
- }
- } else {
- // Single answer question
-
- addAnswer(response, ps, parameterValue, parameterName);
- }
+ Object parameterValue = parameterData.getValue();
+ if (parameterValue instanceof java.lang.String[]) {
+ // This is a multi-answer question - iterate over the
+ // answer values and add them one by one
+ String[] valueArray = (String[]) parameterValue;
+ for (int i = 0; i < valueArray.length; ++i) {
+// addAnswer(response, ps, valueArray[i], parameterName);
+
+ }
+ } else {
+ // Single answer question
+
+// addAnswer(response, ps, parameterValue, parameterName);
+ }
}
// Save the survey response to the database
- response.save();
- saveScore(survey, response);
+ response.save();
+// saveScore(survey, response);
}
- private void saveScore(Survey survey, Response response) {
+/*
+ private void saveScore(Survey survey, SurveyResponse response) {
- String query;
- if ( survey.getQuizType().equals(KNOWLEDGE_TEST) ) {
- query = "com.arsdigita.simplesurvey.saveScore";
- } else {
- query = "com.arsdigita.simplesurvey.saveAssessmentScore";
- }
- DataOperation dao = SessionManager.getSession().retrieveDataOperation(query);
+ String query;
+ if (survey.getQuizType().equals(KNOWLEDGE_TEST)) {
+ query = "com.arsdigita.simplesurvey.saveScore";
+ } else {
+ query = "com.arsdigita.simplesurvey.saveAssessmentScore";
+ }
+ DataOperation dao = SessionManager.getSession().retrieveDataOperation(query);
dao.setParameter("responseID", response.getID());
dao.execute();
}
+*/
+/*
+ private void addAnswer(SurveyResponse surveyResponse,
+ PageState ps,
+ Object parameterValue,
+ String parameterName) {
- private void addAnswer(Response surveyResponse,
- PageState ps,
- Object parameterValue,
- String parameterName) {
+ s_log.debug("formData name " + parameterName + " value " + parameterValue);
- s_log.debug("formData name " + parameterName + " value " + parameterValue);
-
- Question question = getQuestion(ps, parameterName);
+ Question question = getQuestion(ps, parameterName);
- if (question != null ) {
+ if (question != null) {
- PersistentLabel persistentLabel = question.getLabel();
- PersistentWidget persistentWidget = question.getWidget();
+ PersistentLabel persistentLabel = question.getLabel();
+ PersistentWidget persistentWidget = question.getWidget();
- surveyResponse.addAnswer(persistentLabel, persistentWidget, getStringValue(parameterValue));
- }
+ surveyResponse.addAnswer(persistentLabel, persistentWidget, getStringValue(parameterValue));
+ }
}
-
+*/
+/*
private String getStringValue(Object parameterValue) {
- return parameterValue == null ? "" : parameterValue.toString();
+ return parameterValue == null ? "" : parameterValue.toString();
}
-
+*/
+/*
protected Question getQuestion(PageState ps, String parameterName) {
if (m_nameQuestionMap.get(ps) == null) {
-
+
// Populate the parameter name label id map
synchronized (this) {
@@ -194,7 +192,7 @@ public class SurveyProcessListener
s_log.debug("initializing the parameter name persistent label map");
- PersistentForm persistentForm = (PersistentForm)m_persistentForm.get(ps);
+ PersistentForm persistentForm = (PersistentForm) m_persistentForm.get(ps);
DataAssociationCursor componentCursor = persistentForm.getComponents();
PersistentLabel lastPersistentLabel = null;
while (componentCursor.next()) {
@@ -205,20 +203,20 @@ public class SurveyProcessListener
// If this is a PersistentLabel save its id
if (factory instanceof com.arsdigita.formbuilder.PersistentLabel) {
-
- lastPersistentLabel = (PersistentLabel)factory;
+
+ lastPersistentLabel = (PersistentLabel) factory;
}
// Add the previous label id if this is a PersistentWidget
if (factory instanceof com.arsdigita.formbuilder.PersistentWidget) {
- s_log.debug("adding to map " + ((PersistentWidget)factory).getParameterName() +
- " mapped to " + lastPersistentLabel);
+ s_log.debug("adding to map " + ((PersistentWidget) factory).getParameterName() +
+ " mapped to " + lastPersistentLabel);
- Question question = new Question(lastPersistentLabel,
- (PersistentWidget)factory);
-
- nameQuestionMap.put(((PersistentWidget)factory).getParameterName(), question);
+ Question question = new Question(lastPersistentLabel,
+ (PersistentWidget) factory);
+
+ nameQuestionMap.put(((PersistentWidget) factory).getParameterName(), question);
}
}
@@ -228,10 +226,12 @@ public class SurveyProcessListener
s_log.debug("fetching label for parameter name " + parameterName);
- Question question = (Question)((Map)m_nameQuestionMap.get(ps)).get(parameterName);
+ Question question = (Question) ((Map) m_nameQuestionMap.get(ps)).get(parameterName);
s_log.debug("returning " + question);
return question;
}
+ */
+
}
diff --git a/ccm-cms-types-survey/src/com/arsdigita/cms/contenttypes/ui/SurveyPropertiesForm.java b/ccm-cms-types-survey/src/com/arsdigita/cms/contenttypes/ui/SurveyPropertiesForm.java
index 468665b65..2bd66ed97 100755
--- a/ccm-cms-types-survey/src/com/arsdigita/cms/contenttypes/ui/SurveyPropertiesForm.java
+++ b/ccm-cms-types-survey/src/com/arsdigita/cms/contenttypes/ui/SurveyPropertiesForm.java
@@ -18,178 +18,124 @@
*/
package com.arsdigita.cms.contenttypes.ui;
-
-import com.arsdigita.cms.contenttypes.util.SurveyGlobalizationUtil ;
+import com.arsdigita.cms.contenttypes.util.SurveyGlobalizationUtil;
import com.arsdigita.bebop.event.FormSectionEvent;
import com.arsdigita.bebop.event.FormProcessListener;
import com.arsdigita.bebop.event.FormInitListener;
-import com.arsdigita.bebop.parameters.NotWhiteSpaceValidationListener;
-import com.arsdigita.bebop.Form;
import com.arsdigita.bebop.FormProcessException;
-import com.arsdigita.bebop.PageState;
import com.arsdigita.bebop.Label;
-import com.arsdigita.bebop.BlockStylable;
-import com.arsdigita.bebop.form.TextField;
+import com.arsdigita.bebop.FormData;
+import com.arsdigita.bebop.event.FormSubmissionListener;
import com.arsdigita.bebop.form.TextArea;
-import com.arsdigita.bebop.form.Date;
-import com.arsdigita.bebop.form.Submit;
import com.arsdigita.bebop.form.RadioGroup;
import com.arsdigita.bebop.form.Option;
-import com.arsdigita.formbuilder.PersistentForm;
+import com.arsdigita.bebop.parameters.ParameterModel;
+import com.arsdigita.bebop.parameters.StringInRangeValidationListener;
+import com.arsdigita.bebop.parameters.StringParameter;
+import com.arsdigita.cms.ItemSelectionModel;
import com.arsdigita.cms.contenttypes.Survey;
-import java.util.Calendar;
-import java.util.GregorianCalendar;
-import java.lang.Boolean;
+import com.arsdigita.cms.ui.authoring.BasicPageForm;
-public class SurveyPropertiesForm extends Form {
-
- private SurveySelectionModel m_survey;
- private Class m_type;
+public class SurveyPropertiesForm extends BasicPageForm implements FormProcessListener, FormInitListener, FormSubmissionListener {
+ private SurveyPropertiesStep m_step;
+ public static final String DESCRIPTION = Survey.DESCRIPTION;
+// public static final String START_DATE = Survey.START_DATE;
+// public static final String END_DATE = Survey.END_DATE;
+ public static final String RESPONSES_PUBLIC = Survey.RESPONSES_PUBLIC;
+ /**
+ * ID of the form
+ */
+ public static final String ID = "Survey_edit";
- private TextField m_surveyName;
- private TextArea m_description;
- private Date m_startDate;
- private Date m_endDate;
- private RadioGroup m_responsesPublic;
- private RadioGroup m_quizType;
-
- public PropertiesForm(SurveySelectionModel survey,
- Class type) {
-
- super("properties" + type.getName());
-
- m_survey = survey;
- m_type = type;
-
- m_surveyName = new TextField("surveyName");
- m_surveyName.addValidationListener(new NotWhiteSpaceValidationListener());
- m_description = new TextArea("description");
-
-
- m_startDate = new Date("startDate");
- m_endDate = new Date("endDate");
-
- add(new Label(GlobalizationUtil.globalize("simplesurvey.ui.admin.name")));
- add(m_surveyName);
-
- add(new Label(GlobalizationUtil.globalize("simplesurvey.ui.admin.description")));
- m_description.setRows(20);
- m_description.setCols(60);
- add(m_description);
-
- add(new Label(GlobalizationUtil.globalize("simplesurvey.ui.admin.start_date")));
- add(m_startDate);
-
- add(new Label(GlobalizationUtil.globalize("simplesurvey.ui.admin.end_date")));
- add(m_endDate);
-
-
-
- add(new Label(GlobalizationUtil.globalize("simplesurvey.ui.admin.should_quiz_responses_be_public")));
- m_responsesPublic = new RadioGroup("responsesPublic");
- Option o1 = new Option("true", new Label(GlobalizationUtil.globalize("simplesurvey.ui.admin.Yes")));
- Option o2 = new Option("false", new Label(GlobalizationUtil.globalize("simplesurvey.ui.admin.No")));
- m_responsesPublic.addOption(o1);
- m_responsesPublic.addOption(o2);
- add(m_responsesPublic);
-
- // There can be 2 kinds of quizzes: the knowledge test kind of quiz and the personality assessment kind
- add(new Label(GlobalizationUtil.globalize("simplesurvey.ui.admin.what_type_of_quiz_is_this")));
- m_quizType = new RadioGroup("quizType");
- Option o3 = new Option("knowledge_test", new Label(GlobalizationUtil.globalize("simplesurvey.ui.admin.knowledge_test_quiz")));
- Option o4 = new Option("personal_assessment", new Label(GlobalizationUtil.globalize("simplesurvey.ui.admin.personal_assessment_quiz")));
- m_quizType.addOption(o3);
- m_quizType.addOption(o4);
- add(m_quizType);
-
- add(new Submit("submit"), BlockStylable.CENTER);
- addInitListener(new SurveyInitListener());
- addProcessListener(new PropertiesFormProcessListener());
-
- }
-
- private class SurveyInitListener implements FormInitListener {
- public void init(FormSectionEvent e)
- throws FormProcessException {
- PageState state = e.getPageState();
-
- if (m_survey.isSelected(state)) {
- Survey survey = m_survey.getSelectedSurvey(state);
- PersistentForm form = survey.getForm();
-
- m_surveyName.setValue(state, form.getAdminName());
- m_description.setValue(state, form.getDescription());
- m_startDate.setValue(state, survey.getStartDate());
- m_endDate.setValue(state, survey.getEndDate());
- m_quizType.setValue(state, survey.getQuizType());
- if ( survey.responsesArePublic() ) {
- m_responsesPublic.setValue(state, "true");
- } else {
- m_responsesPublic.setValue(state,"false");
- }
- } else {
- m_surveyName.setValue(state, "");
- m_description.setValue(state, "");
-
- Calendar startCalendar = new GregorianCalendar();
- startCalendar.add(Calendar.DATE, 0);
- java.util.Date startDate = startCalendar.getTime();
- Calendar endCalendar = new GregorianCalendar();
- endCalendar.add(Calendar.DATE, 15);
- java.util.Date endDate = endCalendar.getTime();
-
- m_startDate.setValue(state, startDate);
- m_endDate.setValue(state, endDate);
- m_responsesPublic.setValue(state, "true");
- m_quizType.setValue(state, "knowledge_test");
- }
- }
+ /**
+ * Constrctor taking an ItemSelectionModel
+ *
+ * @param itemModel
+ */
+ public SurveyPropertiesForm(ItemSelectionModel itemModel) {
+ this(itemModel, null);
}
- private class PropertiesFormProcessListener implements FormProcessListener {
- public void process(FormSectionEvent e)
- throws FormProcessException {
- PageState state = e.getPageState();
-
- Survey survey;
- PersistentForm form;
-
- if (m_survey.isSelected(state)) {
- survey = m_survey.getSelectedSurvey(state);
- form = survey.getForm();
- } else {
- survey = m_type.equals(Survey.class) ? new Survey() : new Poll();
- survey.setPackageInstance(SimpleSurveyUtil.getPackageInstance(state));
- form = new PersistentForm();
- survey.setForm(form);
- }
-
- form.setAdminName((String)m_surveyName.getValue(state));
- form.setHTMLName(getHTMLName((String)m_surveyName.getValue(state)));
- form.setDescription((String)m_description.getValue(state));
- form.save();
-
- survey.setStartDate((java.util.Date)m_startDate.getValue(state));
- survey.setEndDate((java.util.Date)m_endDate.getValue(state));
- survey.setResponsesPublic(new Boolean((String) m_responsesPublic.getValue(state)));
- survey.setQuizType((String) m_quizType.getValue(state));
- survey.save();
- }
+ /**
+ * Constrctor taking an ItemSelectionModel and an instance of BaseContactPropertiesStep.
+ *
+ * @param itemModel
+ * @param step
+ */
+ public SurveyPropertiesForm(ItemSelectionModel itemModel, SurveyPropertiesStep step) {
+ super(ID, itemModel);
+ m_step = step;
+ addSubmissionListener(this);
+ }
- private String getHTMLName(String surveyName) {
-
- String htmlName = surveyName.trim().toLowerCase();
-
- htmlName = htmlName.replace(' ', '_');
-
- return htmlName;
- }
+ @Override
+ public void addWidgets() {
+ super.addWidgets();
+ add(new Label((String) SurveyGlobalizationUtil.globalize("cms.contenttypes.survey.ui.admin.description").localize()));
+ ParameterModel descriptionParam = new StringParameter(DESCRIPTION);
+ descriptionParam.addParameterListener(new StringInRangeValidationListener(0, 4000));
+ TextArea description = new TextArea(descriptionParam);
+ description.setRows(20);
+ description.setCols(60);
+ add(description);
+
+// add(new Label(SurveyGlobalizationUtil.globalize("simplesurvey.ui.admin.start_date")));
+// add(m_startDate);
+//
+// add(new Label(SurveyGlobalizationUtil.globalize("simplesurvey.ui.admin.end_date")));
+// add(m_endDate);
+
+ add(new Label((String) SurveyGlobalizationUtil.globalize("cms.contenttypes.survey.ui.admin.should_quiz_responses_be_public").localize()));
+ RadioGroup responsesPublic = new RadioGroup("responsesPublic");
+ Option rp1 = new Option("true", new Label((String) SurveyGlobalizationUtil.globalize("cms.contenttypes.survey.ui.Yes").localize()));
+ Option rp2 = new Option("false", new Label((String) SurveyGlobalizationUtil.globalize("cms.contenttypes.survey.ui.No").localize()));
+ responsesPublic.addOption(rp1);
+ responsesPublic.addOption(rp2);
+ add(responsesPublic);
+
+ }
+
+ @Override
+ public void init(FormSectionEvent e) throws FormProcessException {
+ FormData data = e.getFormData();
+ Survey survey = (Survey) super.initBasicWidgets(e);
+
+ data.put(DESCRIPTION, survey.getDescription());
+// data.put(START_DATE, survey.getStartDate());
+// data.put(END_DATE, survey.getEndDate());
+ data.put(RESPONSES_PUBLIC, survey.getResponsesPublic());
+ }
+
+ @Override
+ public void process(FormSectionEvent e) throws FormProcessException {
+ FormData data = e.getFormData();
+
+ Survey survey = (Survey) super.processBasicWidgets(e);
+
+ if ((survey != null) && (getSaveCancelSection().getSaveButton().isSelected(e.getPageState()))) {
+ survey.setDescription((String) data.get(DESCRIPTION));
+// survey.setStartDate((String)data.get(START_DATE));
+// survey.setEndDate((String)data.get(END_DATE));
+ survey.setResponsesPublic((Boolean) data.get(RESPONSES_PUBLIC));
+
+ survey.save();
+ }
+
+ if (m_step != null) {
+ m_step.maybeForwardToNextStep(e.getPageState());
+ }
+ }
+
+ public void submitted(FormSectionEvent e) throws FormProcessException {
+ if ((m_step != null) && (getSaveCancelSection().getCancelButton().isSelected(e.getPageState()))) {
+ m_step.cancelStreamlinedCreation(e.getPageState());
+ }
}
}
diff --git a/ccm-cms-types-survey/src/com/arsdigita/cms/contenttypes/ui/SurveyPropertiesStep.java b/ccm-cms-types-survey/src/com/arsdigita/cms/contenttypes/ui/SurveyPropertiesStep.java
index 057e97a17..36ab21894 100644
--- a/ccm-cms-types-survey/src/com/arsdigita/cms/contenttypes/ui/SurveyPropertiesStep.java
+++ b/ccm-cms-types-survey/src/com/arsdigita/cms/contenttypes/ui/SurveyPropertiesStep.java
@@ -14,7 +14,6 @@ import com.arsdigita.cms.util.GlobalizationUtil;
import com.arsdigita.bebop.Component;
import com.arsdigita.bebop.Label;
import com.arsdigita.bebop.SegmentedPanel;
-import com.arsdigita.cms.contenttypes.Survey;
import com.arsdigita.cms.contenttypes.util.SurveyGlobalizationUtil;
import java.text.DateFormat;
@@ -26,7 +25,6 @@ import org.apache.log4j.Logger;
public class SurveyPropertiesStep extends SimpleEditStep {
private static final Logger logger = Logger.getLogger(SurveyPropertiesStep.class);
-
/**
* Name of the this edit sheet (Don't know if this this really needed.
* It has the same value in almost all PropertiesStep classes)
@@ -44,70 +42,58 @@ public class SurveyPropertiesStep extends SimpleEditStep {
/* Use a Segmented Panel for the multiple parts of data */
SegmentedPanel segmentedPanel = new SegmentedPanel();
-
+
setDefaultEditKey(EDIT_BASIC_SHEET_NAME);
/* The different parts of information are displayed in seperated segments each containing a SimpleEditStep */
/* Well, not so simple anymore... */
-
+
/* A new SimpleEditStep */
SimpleEditStep basicProperties = new SimpleEditStep(itemModel, parent, EDIT_BASIC_SHEET_NAME);
-
+
/* Create the edit component for this SimpleEditStep and the corresponding link */
- BasicPageForm editBasicSheet = new SurveyPropertyForm(itemModel, this);
- basicProperties.add(EDIT_BASIC_SHEET_NAME, (String)SurveyGlobalizationUtil.globalize("cms.contenttypes.ui.survey.edit_basic_properties").localize(), new WorkflowLockedComponentAccess(editBasicSheet, itemModel), editBasicSheet.getSaveCancelSection().getCancelButton());
-
+ BasicPageForm editBasicSheet = new SurveyPropertiesForm(itemModel, this);
+ basicProperties.add(EDIT_BASIC_SHEET_NAME, (String) SurveyGlobalizationUtil.globalize("cms.contenttypes.ui.survey.edit_basic_properties").localize(), new WorkflowLockedComponentAccess(editBasicSheet, itemModel), editBasicSheet.getSaveCancelSection().getCancelButton());
+
/* Set the displayComponent for this step */
- basicProperties.setDisplayComponent(getSurveyPropertySheet(itemModel));
+ basicProperties.setDisplayComponent(getSurveyPropertiesSheet(itemModel));
/* Add the SimpleEditStep to the segmented panel */
- segmentedPanel.addSegment(new Label((String)SurveyGlobalizationUtil.globalize("cms.contenttypes.ui.survey.basic_properties").localize()), basicProperties);
+ segmentedPanel.addSegment(new Label((String) SurveyGlobalizationUtil.globalize("cms.contenttypes.ui.survey.basic_properties").localize()), basicProperties);
- // If not disabled via registry, add the ui for attaching a person
- if(!Survey.getConfig().getHidePerson()) {
- SurveyPersonPropertiesStep personProperties = new SurveyPersonPropertiesStep(itemModel, parent);
- segmentedPanel.addSegment(new Label((String)SurveyGlobalizationUtil.globalize("cms.contenttypes.ui.survey.person").localize()), personProperties);
- }
-
- // If not disabled via registry, add the ui for attaching a baseAddress
- if(!Survey.getConfig().getHideAddress()) {
- SurveyAddressPropertiesStep addressProperties = new SurveyAddressPropertiesStep(itemModel, parent);
- segmentedPanel.addSegment(new Label((String)SurveyGlobalizationUtil.globalize("cms.contenttypes.ui.survey.address").localize()), addressProperties);
- }
+ // Add the ui for attaching a FormSection
+// SurveyPersonPropertiesStep personProperties = new SurveyPersonPropertiesStep(itemModel, parent);
+// segmentedPanel.addSegment(new Label((String) SurveyGlobalizationUtil.globalize("cms.contenttypes.ui.survey.person").localize()), personProperties);
- SurveyEntriesPropertiesStep surveyEntries = new SurveyEntriesPropertiesStep(itemModel, parent);
- segmentedPanel.addSegment(new Label((String)SurveyGlobalizationUtil.globalize("cms.contenttypes.ui.survey.contactEntry").localize()), surveyEntries);
-
/* Sets the composed segmentedPanel as display component */
setDisplayComponent(segmentedPanel);
}
/**
* Creates and returns the sheet for editing the basic properties
- * of an organization. (@see SurveyPropertyForm).
+ * of a survey. (@see SurveyPropertiesForm).
*
* @param itemModel
* @return The sheet for editing the properties of the organization.
*/
- public static Component getSurveyPropertySheet(ItemSelectionModel itemModel) {
-
+ public static Component getSurveyPropertiesSheet(ItemSelectionModel itemModel) {
+
/* The DisplayComponent for the Basic Properties */
DomainObjectPropertySheet sheet = new DomainObjectPropertySheet(itemModel);
- sheet.add(GlobalizationUtil.globalize("cms.contenttypes.ui.name"),"name");
- sheet.add(GlobalizationUtil.globalize("cms.contenttypes.ui.title"),"title");
-
- if(!ContentSection.getConfig().getHideLaunchDate()) {
+ sheet.add(GlobalizationUtil.globalize("cms.contenttypes.ui.name"), "name");
+ sheet.add(GlobalizationUtil.globalize("cms.contenttypes.ui.title"), "title");
+
+ if (!ContentSection.getConfig().getHideLaunchDate()) {
sheet.add(GlobalizationUtil.globalize("cms.ui.authoring.page_launch_date"), ContentPage.LAUNCH_DATE, new DomainObjectPropertySheet.AttributeFormatter() {
public String format(DomainObject obj, String attribute, PageState state) {
- ContentPage page = (ContentPage)obj;
- if(page.getLaunchDate() != null) {
+ ContentPage page = (ContentPage) obj;
+ if (page.getLaunchDate() != null) {
return DateFormat.getDateInstance(DateFormat.LONG).format(page.getLaunchDate());
- }
- else {
- return (String)GlobalizationUtil.globalize("cms.ui.unknown").localize();
+ } else {
+ return (String) GlobalizationUtil.globalize("cms.ui.unknown").localize();
}
}
});
@@ -115,5 +101,4 @@ public class SurveyPropertiesStep extends SimpleEditStep {
return sheet;
}
-
}
diff --git a/ccm-cms-types-survey/src/com/arsdigita/cms/contenttypes/ui/SurveySelectionModel.java b/ccm-cms-types-survey/src/com/arsdigita/cms/contenttypes/ui/SurveySelectionModel.java
index 3aaa1eaec..25ee278a7 100755
--- a/ccm-cms-types-survey/src/com/arsdigita/cms/contenttypes/ui/SurveySelectionModel.java
+++ b/ccm-cms-types-survey/src/com/arsdigita/cms/contenttypes/ui/SurveySelectionModel.java
@@ -16,14 +16,14 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
-package com.arsdigita.simplesurvey.ui;
+package com.arsdigita.cms.contenttypes.ui;
import com.arsdigita.bebop.PageState;
import com.arsdigita.bebop.parameters.BigDecimalParameter;
-import com.arsdigita.simplesurvey.Survey;
+import com.arsdigita.cms.contenttypes.Survey;
import com.arsdigita.toolbox.ui.ACSObjectSelectionModel;