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) {
var fieldEditor = StudioEditableXBlockMixin(runtime, element);
// 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
$('.save-button', element).on('click', function(e) {
e.preventDefault();
var data = {};
if (vectordraw.wasUsed) {
if (vectordraw && vectordraw.wasUsed) {
// If author edited both initial state and result,
// vectordraw.settings.vectors corresponds to state vectors were in
// when author switched to result mode
......
......@@ -61,6 +61,15 @@
{% endif %}
</li>
{% 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>
<!-- WYSIWYG editor -->
<div class="vectordraw_block vectordraw_edit_block">
......@@ -358,6 +367,9 @@
</div>
</div>
</li>
{% endif %}
</ul>
</div>
......
......@@ -446,6 +446,13 @@ class VectorDrawXBlock(StudioEditableXBlockMixin, XBlock):
field_info = self._make_field_info(field_name, field)
if field_info is not None:
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))
# Add resources to studio_view fragment
fragment.add_css_url(
......@@ -464,7 +471,7 @@ class VectorDrawXBlock(StudioEditableXBlockMixin, XBlock):
self.runtime.local_resource_url(self, 'public/js/vectordraw_edit.js')
)
fragment.initialize_js(
'VectorDrawXBlockEdit', {"settings": self.settings}
'VectorDrawXBlockEdit', {"settings": settings}
)
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