diff --git a/cms/templates/widgets/open-ended-edit.html b/cms/templates/widgets/open-ended-edit.html new file mode 100644 index 0000000000..b59e6f7068 --- /dev/null +++ b/cms/templates/widgets/open-ended-edit.html @@ -0,0 +1,67 @@ +<%include file="metadata-edit.html" /> +
+
+ %if enable_markdown: +
+
    +
  • +
  • +
  • +
+ +
+ + %endif + +
+
+ + diff --git a/common/lib/xmodule/xmodule/combined_open_ended_module.py b/common/lib/xmodule/xmodule/combined_open_ended_module.py index bffd4d4c78..008cf5acb0 100644 --- a/common/lib/xmodule/xmodule/combined_open_ended_module.py +++ b/common/lib/xmodule/xmodule/combined_open_ended_module.py @@ -69,6 +69,7 @@ class CombinedOpenEndedFields(object): version = VersionInteger(help="Current version number", default=DEFAULT_VERSION, scope=Scope.settings) data = String(help="XML data for the problem", scope=Scope.content) weight = StringyFloat(help="How much to weight this problem by", scope=Scope.settings) + markdown = String(help="Markdown source of this module", scope=Scope.settings) class CombinedOpenEndedModule(CombinedOpenEndedFields, XModule): @@ -213,9 +214,8 @@ class CombinedOpenEndedDescriptor(CombinedOpenEndedFields, RawDescriptor): """ Module for adding combined open ended questions """ - mako_template = "widgets/raw-edit.html" + mako_template = "widgets/open-ended-edit.html" module_class = CombinedOpenEndedModule - filename_extension = "xml" stores_state = True has_score = True @@ -227,3 +227,23 @@ class CombinedOpenEndedDescriptor(CombinedOpenEndedFields, RawDescriptor): #Specify whether or not to pass in open ended interface needs_open_ended_interface = True + + metadata_attributes = RawDescriptor.metadata_attributes + + js = {'coffee': [resource_string(__name__, 'js/src/combinedopenended/edit.coffee')]} + js_module_name = "OpenEndedMarkdownEditingDescriptor" + css = {'scss': [resource_string(__name__, 'css/editor/edit.scss'), resource_string(__name__, 'css/combinedopenended/edit.scss')]} + + def get_context(self): + _context = RawDescriptor.get_context(self) + _context.update({'markdown': self.markdown, + 'enable_markdown': self.markdown is not None}) + return _context + + @property + def non_editable_metadata_fields(self): + non_editable_fields = super(CombinedOpenEndedDescriptor, self).non_editable_metadata_fields + non_editable_fields.extend([CombinedOpenEndedDescriptor.due, CombinedOpenEndedDescriptor.graceperiod, + CombinedOpenEndedDescriptor.markdown]) + return non_editable_fields + diff --git a/common/lib/xmodule/xmodule/css/combinedopenended/edit.scss b/common/lib/xmodule/xmodule/css/combinedopenended/edit.scss new file mode 100644 index 0000000000..1e4b300c28 --- /dev/null +++ b/common/lib/xmodule/xmodule/css/combinedopenended/edit.scss @@ -0,0 +1,122 @@ +.editor-bar { + + .editor-tabs { + + .advanced-toggle { + @include white-button; + height: auto; + margin-top: -1px; + padding: 3px 9px; + font-size: 12px; + + &.current { + border: 1px solid $lightGrey !important; + border-radius: 3px !important; + background: $lightGrey !important; + color: $darkGrey !important; + pointer-events: none; + cursor: none; + + &:hover { + box-shadow: 0 0 0 0 !important; + } + } + } + + .cheatsheet-toggle { + width: 21px; + height: 21px; + padding: 0; + margin: 0 5px 0 15px; + border-radius: 22px; + border: 1px solid #a5aaaf; + background: #e5ecf3; + font-size: 13px; + font-weight: 700; + color: #565d64; + text-align: center; + } + } +} + +.simple-editor-cheatsheet { + position: absolute; + top: 0; + left: 100%; + width: 0; + border-radius: 0 3px 3px 0; + @include linear-gradient(left, rgba(0, 0, 0, .1), rgba(0, 0, 0, 0) 4px); + background-color: #fff; + overflow: hidden; + @include transition(width .3s); + + &.shown { + width: 300px; + height: 100%; + overflow-y: scroll; + } + + .cheatsheet-wrapper { + width: 240px; + padding: 20px 30px; + } + + h6 { + margin-bottom: 7px; + font-size: 15px; + font-weight: 700; + } + + .row { + @include clearfix; + padding-bottom: 5px !important; + margin-bottom: 10px !important; + border-bottom: 1px solid #ddd !important; + + &:last-child { + border-bottom: none !important; + margin-bottom: 0 !important; + } + } + + .col { + float: left; + + &.sample { + width: 60px; + margin-right: 30px; + } + } + + pre { + font-size: 12px; + line-height: 18px; + } + + code { + padding: 0; + background: none; + } +} + +.combinedopenended-editor-icon { + display: inline-block; + width: 26px; + height: 21px; + vertical-align: middle; + background: url(../img/problem-editor-icons.png) no-repeat; +} + +.combinedopenended-editor-icon.multiple-choice { + background-position: 0 0; +} + +.combinedopenended-editor-icon.explanation { + width: 28px; + background-position: -111px 0; +} + +.combinedopenended-editor-icon.dropdown { + width: 28px; + background-position: -111px 0; +} \ No newline at end of file diff --git a/common/lib/xmodule/xmodule/js/src/combinedopenended/edit.coffee b/common/lib/xmodule/xmodule/js/src/combinedopenended/edit.coffee index b723f230e9..58697aff07 100644 --- a/common/lib/xmodule/xmodule/js/src/combinedopenended/edit.coffee +++ b/common/lib/xmodule/xmodule/js/src/combinedopenended/edit.coffee @@ -1,4 +1,4 @@ -class @MarkdownEditingDescriptor extends XModule.Descriptor +class @OpenEndedMarkdownEditingDescriptor extends XModule.Descriptor # TODO really, these templates should come from or also feed the cheatsheet @multipleChoiceTemplate : "( ) incorrect\n( ) incorrect\n(x) correct\n" @checkboxChoiceTemplate: "[x] correct\n[ ] incorrect\n[x] correct\n" diff --git a/common/lib/xmodule/xmodule/templates/combinedopenended/default.yaml b/common/lib/xmodule/xmodule/templates/combinedopenended/default.yaml index a11367b46f..cfbb5b7334 100644 --- a/common/lib/xmodule/xmodule/templates/combinedopenended/default.yaml +++ b/common/lib/xmodule/xmodule/templates/combinedopenended/default.yaml @@ -7,6 +7,7 @@ metadata: skip_spelling_checks: False accept_file_upload: False weight: "" + markdown: "" data: |