Commit 88fb8ab9 by Tim Krones

Allow authors to edit broken problems in Studio.

parent 134952b0
...@@ -686,13 +686,16 @@ function VectorDrawXBlockEdit(runtime, element, init_args) { ...@@ -686,13 +686,16 @@ function VectorDrawXBlockEdit(runtime, element, init_args) {
var fieldEditor = StudioEditableXBlockMixin(runtime, element); var fieldEditor = StudioEditableXBlockMixin(runtime, element);
// Initialize WYSIWYG editor // Initialize WYSIWYG editor
var vectordraw = new VectorDraw('vectordraw', init_args.settings); var vectordraw;
if (init_args.settings) {
vectordraw = new VectorDraw('vectordraw', init_args.settings);
}
// Set up click handlers // Set up click handlers
$('.save-button', element).on('click', function(e) { $('.save-button', element).on('click', function(e) {
e.preventDefault(); e.preventDefault();
var data = {}; var data = {};
if (vectordraw.wasUsed) { if (vectordraw && vectordraw.wasUsed) {
// If author edited both initial state and result, // If author edited both initial state and result,
// vectordraw.settings.vectors corresponds to state vectors were in // vectordraw.settings.vectors corresponds to state vectors were in
// when author switched to result mode // when author switched to result mode
......
...@@ -61,6 +61,15 @@ ...@@ -61,6 +61,15 @@
{% endif %} {% endif %}
</li> </li>
{% endfor %} {% endfor %}
{% if error %}
<div class="error-report">
<p>{% trans "Not displaying WYSIWYG editor: Problem contains invalid settings. Please fix them using the fields above." %}</p>
</div>
{% else %}
<li> <li>
<!-- WYSIWYG editor --> <!-- WYSIWYG editor -->
<div class="vectordraw_block vectordraw_edit_block"> <div class="vectordraw_block vectordraw_edit_block">
...@@ -358,6 +367,9 @@ ...@@ -358,6 +367,9 @@
</div> </div>
</div> </div>
</li> </li>
{% endif %}
</ul> </ul>
</div> </div>
......
...@@ -446,6 +446,13 @@ class VectorDrawXBlock(StudioEditableXBlockMixin, XBlock): ...@@ -446,6 +446,13 @@ class VectorDrawXBlock(StudioEditableXBlockMixin, XBlock):
field_info = self._make_field_info(field_name, field) field_info = self._make_field_info(field_name, field)
if field_info is not None: if field_info is not None:
context["fields"].append(field_info) context["fields"].append(field_info)
try:
settings = self.settings
except Exception:
error_type, error, tb = sys.exc_info()
context['error'] = error
context['traceback'] = traceback.format_tb(tb)
settings = None
fragment.add_content(loader.render_template("templates/html/vectordraw_edit.html", context)) fragment.add_content(loader.render_template("templates/html/vectordraw_edit.html", context))
# Add resources to studio_view fragment # Add resources to studio_view fragment
fragment.add_css_url( fragment.add_css_url(
...@@ -464,7 +471,7 @@ class VectorDrawXBlock(StudioEditableXBlockMixin, XBlock): ...@@ -464,7 +471,7 @@ class VectorDrawXBlock(StudioEditableXBlockMixin, XBlock):
self.runtime.local_resource_url(self, 'public/js/vectordraw_edit.js') self.runtime.local_resource_url(self, 'public/js/vectordraw_edit.js')
) )
fragment.initialize_js( fragment.initialize_js(
'VectorDrawXBlockEdit', {"settings": self.settings} 'VectorDrawXBlockEdit', {"settings": settings}
) )
return fragment return fragment
......
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