Commit 6471e275 by Ehtesham

getting inputtypes from registry

parent 9eb4253f
......@@ -2,22 +2,27 @@
var summaryMessage = validation.get("summary");
var aggregateMessageType = summaryMessage.type;
var aggregateValidationClass = aggregateMessageType === "error" ? "has-errors" : "has-warnings";
var actionLink = (summaryMessage.action_class === 'external-link' && summaryMessage.action_link) ?
summaryMessage.action_link : '#';
%>
<div class="xblock-message validation <%= aggregateValidationClass %> <%= additionalClasses %>">
<p class="<%= aggregateMessageType %>"><i class="icon fa <%= getIcon(aggregateMessageType) %>"></i>
<%- summaryMessage.text %>
<% if (summaryMessage.action_class) { %>
<a href="<%= summaryMessage.action_link ? summaryMessage.action_link : '#' %>" class="button action-button <%- summaryMessage.action_class %>">
<span class="action-button-text"><%- summaryMessage.action_label %></span>
<% if (summaryMessage.action_class === 'external-link') { %>
<i class="fa fa-external-link-square" aria-hidden="true"></i>
<% } %>
<% if (summaryMessage.action_class && actionLink === '#') { %>
<a href="#" class="button action-button <%- summaryMessage.action_class %>">
<span class="action-button-text"><%- summaryMessage.action_label %></span>
</a>
<% } else if (summaryMessage.action_runtime_event) {%>
<a href="#" class="button action-button notification-action-button" data-notification-action="<%- summaryMessage.action_runtime_event %>">
<span class="action-button-text"><%- summaryMessage.action_label %></span>
<% } else if (actionLink !== '#') { %>
<a href="<%= actionLink %>" target="_blank" class="button action-button <%- summaryMessage.action_class %>">
<span class="action-button-text"><%- summaryMessage.action_label %></span>
<i class="fa fa-external-link-square" aria-hidden="true"></i>
</a>
<% } %>
<% } else if (summaryMessage.action_runtime_event) { %>
<a href="#" class="button action-button notification-action-button"
data-notification-action="<%- summaryMessage.action_runtime_event %>">
<span class="action-button-text"><%- summaryMessage.action_label %></span>
</a>
<% } %>
</p>
<% var detailedMessages = validation.get("messages"); %>
<% if (detailedMessages.length > 0) { %>
......
......@@ -11,7 +11,7 @@ import dogstats_wrapper as dog_stats_api
from xmodule.validation import StudioValidation, StudioValidationMessage
from .capa_base import CapaMixin, CapaFields, ComplexEncoder
from capa import responsetypes
from capa import responsetypes, inputtypes
from .progress import Progress
from xmodule.util.misc import escape_html_characters
from xmodule.x_module import XModule, module_attr, DEPRECATION_VSCOMPAT_EVENT
......@@ -277,9 +277,9 @@ class CapaDescriptor(CapaFields, RawDescriptor):
validation = StudioValidation.copy(validation)
# validate xml to check questions are correctly separated
is_valid = self.validate_xml()
is_valid_xml = self.validate_xml_for_inputtypes()
if not is_valid:
if not is_valid_xml:
validation.set_summary(
StudioValidationMessage(
StudioValidationMessage.WARNING,
......@@ -292,18 +292,21 @@ class CapaDescriptor(CapaFields, RawDescriptor):
return validation
def validate_xml(self):
input_tags = ['choiceresponse', 'optionresponse', 'multiplechoiceresponse', 'stringresponse',
'numericalresponse', 'schematicresponse', 'imageresponse', 'formularesponse']
def validate_xml_for_inputtypes(self):
"""
Looks for more than one occurrences of inputtypes inside each <question>
if found returns False
"""
input_types = inputtypes.registry.registered_tags()
from nose.tools import set_trace; set_trace()
xmltree = etree.fromstring(self.data)
questions = xmltree.findall(".//question")
for question in questions:
for tag in input_tags:
for tag in input_types:
tag_elements = question.findall(".//" + tag)
if len(tag_elements) > 1:
print("more choices")
return False
return True
......
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