Commit f0f2a6a2 by E. Kolpakov

Datetime field to demonstrate StudioEditableXBlockMixin datetime field supprot

parent 472a3130
...@@ -21,8 +21,9 @@ ...@@ -21,8 +21,9 @@
# Imports ########################################################### # Imports ###########################################################
import logging import logging
import datetime as datetime
from xblock.fields import List, Scope, Boolean from xblock.fields import List, Scope, Boolean, DateTime
from xblock.validation import ValidationMessage from xblock.validation import ValidationMessage
from .questionnaire import QuestionnaireAbstractBlock from .questionnaire import QuestionnaireAbstractBlock
from xblockutils.resources import ResourceLoader from xblockutils.resources import ResourceLoader
...@@ -69,9 +70,16 @@ class MRQBlock(QuestionnaireAbstractBlock): ...@@ -69,9 +70,16 @@ class MRQBlock(QuestionnaireAbstractBlock):
default=[], default=[],
) )
hide_results = Boolean(display_name="Hide results", scope=Scope.content, default=False) hide_results = Boolean(display_name="Hide results", scope=Scope.content, default=False)
datetime = DateTime(
display_name="DateTime",
help="This field does not do anything - just renders in template",
default=datetime.datetime(2015, 01, 01)
)
editable_fields = ( editable_fields = (
'question', 'required_choices', 'ignored_choices', 'message', 'display_name', 'question', 'required_choices', 'ignored_choices', 'message', 'display_name',
'show_title', 'weight', 'hide_results', 'show_title', 'weight', 'hide_results', 'datetime'
) )
def describe_choice_correctness(self, choice_value): def describe_choice_correctness(self, choice_value):
......
{% load tz %}
<fieldset class="choices questionnaire" data-hide_results="{{self.hide_results}}"> <fieldset class="choices questionnaire" data-hide_results="{{self.hide_results}}">
<!-- Avoid django timezone conversion to not confuse reviewers -->
{% localtime off %}
<p>{{ self.datetime|date }}</p>
{% endlocaltime %}
<legend class="question"> <legend class="question">
{% if not hide_header %}<h3 class="question-title">{{ self.display_name_with_default }}</h3>{% endif %} {% if not hide_header %}<h3 class="question-title">{{ self.display_name_with_default }}</h3>{% endif %}
<p>{{ self.question|safe }}</p> <p>{{ self.question|safe }}</p>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment