diff --git a/tool/src/java/org/sakaiproject/evaluation/tool/evolvers/NewFieldDateInputEvolver.java b/tool/src/java/org/sakaiproject/evaluation/tool/evolvers/NewFieldDateInputEvolver.java new file mode 100644 index 0000000..a2d21a2 --- /dev/null +++ b/tool/src/java/org/sakaiproject/evaluation/tool/evolvers/NewFieldDateInputEvolver.java @@ -0,0 +1,87 @@ +package org.sakaiproject.evaluation.tool.evolvers; + +import org.sakaiproject.evaluation.tool.utils.ISO8601FieldDateTransit; +import uk.org.ponder.beanutil.BeanGetter; +import uk.org.ponder.rsf.components.*; +import uk.org.ponder.rsf.evolvers.FormatAwareDateInputEvolver; +import uk.org.ponder.rsf.util.RSFUtil; + +import java.util.Date; + +/** + * Unlike the original date formatter we no longer do the parsing on the client side as we just + * expect a ISO8601 formatted date from all languages. + */ +public class NewFieldDateInputEvolver implements FormatAwareDateInputEvolver { + + // This is the RSF ID that will be looked up in the templates to decide which one to use. + public static final String COMPONENT_ID = "new-date-field-input:"; + + private String style = DATE_INPUT; + // The transit base is the bean looked up to convert data between the request and model. + // In this case we need to translate between a string and date. + private String transitBase = "iso8601DateTransit"; + + private BeanGetter rbg; + + public void setInvalidDateKey(String s) { + + } + public void setRequestBeanGetter(BeanGetter rbg) { + this.rbg = rbg; + } + + + public UIJointContainer evolveDateInput(UIInput toEvolve, Date value) { + // Pull in the template + UIJointContainer togo = new UIJointContainer(toEvolve.parent, toEvolve.ID, COMPONENT_ID); + // Remove the existing component from the tree + toEvolve.parent.remove(toEvolve); + String transitBean = transitBase + "." + togo.getFullID(); + + // Need ISO9601 support. + ISO8601FieldDateTransit transit = (ISO8601FieldDateTransit) rbg.getBean(transitBean); + if (value == null) { + // The UIInput we're evolving must have a OTP bean for this to work. + value = (Date) rbg.getBean(toEvolve.valuebinding.value); + } + if (value != null) { + transit.setDate(value); + } + + String ttb = transitBean + "."; + + UIOutput display = UIOutput.make(togo, "display"); + + + UIInput field = UIInput.make(togo, "iso8601", ttb + "ISO8601", transit.getISO8601()); + field.mustapply = true; + + // Bind the value back through to the transitBase. + // This generates a custom hidden HTML + UIForm form = RSFUtil.findBasicForm(togo); + form.parameters.add(new UIELBinding(toEvolve.valuebinding.value, + new ELReference(ttb + "date"))); + + UIInitBlock.make(togo, "init-date", "rsfDatePicker", new Object[] { + display.getFullID(), field.getFullID(), + // If we just supply a boolean it is output as a string which doesn't work. + (style.equals(DATE_TIME_INPUT) || style.equals(TIME_INPUT))?1:0 + }); + + return togo; + } + + public UIJointContainer evolveDateInput(UIInput toEvolve) { + return evolveDateInput(toEvolve, null); + } + + public void setInvalidTimeKey(String s) { + + } + + public void setStyle(String s) { + this.style = s; + } + +} diff --git a/tool/src/java/org/sakaiproject/evaluation/tool/producers/EvaluationSettingsProducer.java b/tool/src/java/org/sakaiproject/evaluation/tool/producers/EvaluationSettingsProducer.java index c1bb4f0..4a9f271 100644 --- a/tool/src/java/org/sakaiproject/evaluation/tool/producers/EvaluationSettingsProducer.java +++ b/tool/src/java/org/sakaiproject/evaluation/tool/producers/EvaluationSettingsProducer.java @@ -15,6 +15,7 @@ package org.sakaiproject.evaluation.tool.producers; import java.text.DateFormat; +import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; import java.util.GregorianCalendar; @@ -31,6 +32,7 @@ import org.sakaiproject.evaluation.logic.model.EvalUser; import org.sakaiproject.evaluation.model.EvalEvaluation; import org.sakaiproject.evaluation.model.EvalTemplate; import org.sakaiproject.evaluation.tool.EvalToolConstants; +import org.sakaiproject.evaluation.tool.evolvers.NewFieldDateInputEvolver; import org.sakaiproject.evaluation.tool.renderers.NavBarRenderer; import org.sakaiproject.evaluation.tool.utils.RSFUtils; import org.sakaiproject.evaluation.tool.viewparams.AdminSearchViewParameters; @@ -58,17 +60,17 @@ import uk.org.ponder.rsf.components.UISelect; import uk.org.ponder.rsf.components.UISelectChoice; import uk.org.ponder.rsf.components.UISelectLabel; import uk.org.ponder.rsf.components.UIVerbatim; -import uk.org.ponder.rsf.components.decorators.DecoratorList; -import uk.org.ponder.rsf.components.decorators.UILabelTargetDecorator; -import uk.org.ponder.rsf.components.decorators.UITextDimensionsDecorator; -import uk.org.ponder.rsf.components.decorators.UITooltipDecorator; +import uk.org.ponder.rsf.components.decorators.*; +import uk.org.ponder.rsf.evolvers.DateInputEvolver; import uk.org.ponder.rsf.evolvers.FormatAwareDateInputEvolver; import uk.org.ponder.rsf.evolvers.TextInputEvolver; import uk.org.ponder.rsf.flow.ARIResult; import uk.org.ponder.rsf.flow.ActionResultInterceptor; import uk.org.ponder.rsf.util.RSFUtil; +import uk.org.ponder.rsf.util.html.RSFHTMLUtil; import uk.org.ponder.rsf.view.ComponentChecker; import uk.org.ponder.rsf.view.ViewComponentProducer; +import uk.org.ponder.rsf.view.ViewRoot; import uk.org.ponder.rsf.viewstate.SimpleViewParameters; import uk.org.ponder.rsf.viewstate.ViewParameters; import uk.org.ponder.rsf.viewstate.ViewParamsReporter; @@ -107,11 +109,6 @@ public class EvaluationSettingsProducer implements ViewComponentProducer, ViewPa this.authoringService = authoringService; } - private FormatAwareDateInputEvolver dateevolver; - public void setDateEvolver(FormatAwareDateInputEvolver dateevolver) { - this.dateevolver = dateevolver; - } - private TextInputEvolver richTextEvolver; public void setRichTextEvolver(TextInputEvolver richTextEvolver) { this.richTextEvolver = richTextEvolver; @@ -127,11 +124,20 @@ public class EvaluationSettingsProducer implements ViewComponentProducer, ViewPa this.navBarRenderer = navBarRenderer; } + private FormatAwareDateInputEvolver dateEvolver; + public void setDateEvolver(FormatAwareDateInputEvolver dateEvolver) { + this.dateEvolver = dateEvolver; + } + /* (non-Javadoc) * @see uk.org.ponder.rsf.view.ComponentProducer#fillComponents(uk.org.ponder.rsf.components.UIContainer, uk.org.ponder.rsf.viewstate.ViewParameters, uk.org.ponder.rsf.view.ComponentChecker) */ public void fillComponents(UIContainer tofill, ViewParameters viewparams, ComponentChecker checker) { +// if (tofill instanceof ViewRoot) { +// ((ViewRoot)tofill).debug = true; +// } + EvalViewParameters evalViewParams = (EvalViewParameters) viewparams; if (evalViewParams.evaluationId == null) { throw new IllegalArgumentException("Cannot access this view unless the evaluationId is set"); @@ -294,19 +300,19 @@ public class EvaluationSettingsProducer implements ViewComponentProducer, ViewPa // Start Date UIBranchContainer showStartDate = UIBranchContainer.make(form, "showStartDate:"); - generateDateSelector(showStartDate, "startDate", evaluationOTP + "startDate", + generateDateSelector(showStartDate, "startDate", evaluationOTP + "startDate", null, currentEvalState, EvalConstants.EVALUATION_STATE_ACTIVE, useDateTime); // Due Date UIBranchContainer showDueDate = UIBranchContainer.make(form, "showDueDate:"); - generateDateSelector(showDueDate, "dueDate", evaluationOTP + "dueDate", + generateDateSelector(showDueDate, "dueDate", evaluationOTP + "dueDate", reOpenDueDate, currentEvalState, EvalConstants.EVALUATION_STATE_GRACEPERIOD, useDateTime); // Stop Date - Show the "Stop date" text box only if allowed in the System settings Boolean useStopDate = (Boolean) settings.get(EvalSettings.EVAL_USE_STOP_DATE); if (useStopDate) { UIBranchContainer showStopDate = UIBranchContainer.make(form, "showStopDate:"); - generateDateSelector(showStopDate, "stopDate", evaluationOTP + "stopDate", + generateDateSelector(showStopDate, "stopDate", evaluationOTP + "stopDate", reOpenStopDate, currentEvalState, EvalConstants.EVALUATION_STATE_CLOSED, useDateTime); } @@ -620,11 +626,11 @@ public class EvaluationSettingsProducer implements ViewComponentProducer, ViewPa } else { UIInput datePicker = UIInput.make(parent, rsfId + ":", binding); if (useDateTime) { - dateevolver.setStyle(FormatAwareDateInputEvolver.DATE_TIME_INPUT); + dateEvolver.setStyle(FormatAwareDateInputEvolver.DATE_TIME_INPUT); } else { - dateevolver.setStyle(FormatAwareDateInputEvolver.DATE_INPUT); + dateEvolver.setStyle(FormatAwareDateInputEvolver.DATE_INPUT); } - dateevolver.evolveDateInput(datePicker, initValue); + dateEvolver.evolveDateInput(datePicker, initValue); } } @@ -650,13 +656,7 @@ public class EvaluationSettingsProducer implements ViewComponentProducer, ViewPa UIMessage.make(parent, rsfId + "_label", "evalsettings.view.results.date.label"); } else { // allow them to choose the date using a date picker - UIInput dateInput = UIInput.make(parent, rsfId + ":", binding); - if (useDateTime) { - dateevolver.setStyle(FormatAwareDateInputEvolver.DATE_TIME_INPUT); - } else { - dateevolver.setStyle(FormatAwareDateInputEvolver.DATE_INPUT); - } - dateevolver.evolveDateInput(dateInput); + UIInput dateInput = UIInput.make(parent, rsfId + "-iso8601", binding); } } } diff --git a/tool/src/java/org/sakaiproject/evaluation/tool/utils/ISO8601FieldDateTransit.java b/tool/src/java/org/sakaiproject/evaluation/tool/utils/ISO8601FieldDateTransit.java new file mode 100644 index 0000000..6c8c983 --- /dev/null +++ b/tool/src/java/org/sakaiproject/evaluation/tool/utils/ISO8601FieldDateTransit.java @@ -0,0 +1,37 @@ +package org.sakaiproject.evaluation.tool.utils; + +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.Date; + +/** + * The new date widget always sends back a ISO8601 formatted string. If the user + * doesn't have JavaScript they can't enter a date so we don't need to worry about + * falling back to doing locale based parsing of dates. + */ +public class ISO8601FieldDateTransit { + + public static final String ISO_FORMAT = "yyyy-MM-dd'T'HH:mm:ssX"; + private Date date; + + public Date getDate() { + return date; + } + + public void setDate(Date date) { + this.date = date; + } + + public String getISO8601() { + return (date == null)?null:new SimpleDateFormat(ISO_FORMAT).format(date); + } + + public void setISO8601(String source) { + try { + // This shouldn't ever fail as we should be getting it from the widget. + date = new SimpleDateFormat(ISO_FORMAT).parse(source); + } catch (ParseException pe) { + throw new RuntimeException(pe); + } + } +} diff --git a/tool/src/webapp/WEB-INF/applicationContext.xml b/tool/src/webapp/WEB-INF/applicationContext.xml index b229436..bc9864e 100644 --- a/tool/src/webapp/WEB-INF/applicationContext.xml +++ b/tool/src/webapp/WEB-INF/applicationContext.xml @@ -32,11 +32,12 @@ + setupEvalBean, reportsBean, templateBBean, importBean, itemsBean, expertItemsBean, + templateBeanLocator, templateItemWBL, answersBeanLocator, responseAnswersBeanLocator, responseBeanLocator, + evaluationBeanLocator, takeEvalBean, settingsBean, scaleBean, scaleBeanLocator, itemWBL, + hierNodeLocator, hierNodeLocatorInvoker, hierNodeGroupsLocator, hierNodeGroupsLocatorInvoker, + emailTemplateWBL, administrateSearchBean, selectedEvaluationUsersLocator, assignGroupSelectionSettings, + iso8601DateTransit" /> + + + + + + + diff --git a/tool/src/webapp/component-templates/new_date_field_input.html b/tool/src/webapp/component-templates/new_date_field_input.html new file mode 100644 index 0000000..c3d9a13 --- /dev/null +++ b/tool/src/webapp/component-templates/new_date_field_input.html @@ -0,0 +1,47 @@ + + + + + + + + + + + + + + + +
+ + + +
+ + + diff --git a/tool/src/webapp/content/templates/evaluation_settings.html b/tool/src/webapp/content/templates/evaluation_settings.html index efca6d5..5926dc4 100644 --- a/tool/src/webapp/content/templates/evaluation_settings.html +++ b/tool/src/webapp/content/templates/evaluation_settings.html @@ -7,11 +7,12 @@ - - - + + + -
@@ -79,40 +80,37 @@
Evaluation Dates: -
- - Today is Oct 29, 1975 - -
-
- - - - +
+ + Today is Oct 29, 1975 - - - Users may begin submitting evaluation responses on this date +
+
+ + + + + Evaluation ends on this date, no more responses after this date
- - - - - - + + + Evaluation ends on this date, no more responses after this date
- - - - - - + + + Users may still submit responses up until this date (defines a grace period) @@ -142,18 +140,17 @@ Note that admins above in the hierarchy can view the results UNLESS results sharing is set to private

-
-
- - - - - - - - Results are not viewable until this date - -
+
+
+ + + + + Results are not viewable until this date + +