Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-platform
Commits
6471e275
Commit
6471e275
authored
Jun 02, 2016
by
Ehtesham
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
getting inputtypes from registry
parent
9eb4253f
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
18 deletions
+26
-18
cms/templates/js/xblock-validation-messages.underscore
+15
-10
common/lib/xmodule/xmodule/capa_module.py
+11
-8
No files found.
cms/templates/js/xblock-validation-messages.underscore
View file @
6471e275
...
@@ -2,22 +2,27 @@
...
@@ -2,22 +2,27 @@
var summaryMessage = validation.get("summary");
var summaryMessage = validation.get("summary");
var aggregateMessageType = summaryMessage.type;
var aggregateMessageType = summaryMessage.type;
var aggregateValidationClass = aggregateMessageType === "error" ? "has-errors" : "has-warnings";
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 %>">
<div class="xblock-message validation <%= aggregateValidationClass %> <%= additionalClasses %>">
<p class="<%= aggregateMessageType %>"><i class="icon fa <%= getIcon(aggregateMessageType) %>"></i>
<p class="<%= aggregateMessageType %>"><i class="icon fa <%= getIcon(aggregateMessageType) %>"></i>
<%- summaryMessage.text %>
<%- summaryMessage.text %>
<% if (summaryMessage.action_class) { %>
<% if (summaryMessage.action_class && actionLink === '#') { %>
<a href="<%= summaryMessage.action_link ? summaryMessage.action_link : '#' %>" class="button action-button <%- summaryMessage.action_class %>">
<a href="#" class="button action-button <%- summaryMessage.action_class %>">
<span class="action-button-text"><%- summaryMessage.action_label %></span>
<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>
<% } %>
</a>
</a>
<% } else if (summaryMessage.action_runtime_event) {%>
<% } else if (actionLink !== '#') { %>
<a href="#" class="button action-button notification-action-button" data-notification-action="<%- summaryMessage.action_runtime_event %>">
<a href="<%= actionLink %>" target="_blank" class="button action-button <%- summaryMessage.action_class %>">
<span class="action-button-text"><%- summaryMessage.action_label %></span>
<span class="action-button-text"><%- summaryMessage.action_label %></span>
<i class="fa fa-external-link-square" aria-hidden="true"></i>
</a>
</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>
</p>
<% var detailedMessages = validation.get("messages"); %>
<% var detailedMessages = validation.get("messages"); %>
<% if (detailedMessages.length > 0) { %>
<% if (detailedMessages.length > 0) { %>
...
...
common/lib/xmodule/xmodule/capa_module.py
View file @
6471e275
...
@@ -11,7 +11,7 @@ import dogstats_wrapper as dog_stats_api
...
@@ -11,7 +11,7 @@ import dogstats_wrapper as dog_stats_api
from
xmodule.validation
import
StudioValidation
,
StudioValidationMessage
from
xmodule.validation
import
StudioValidation
,
StudioValidationMessage
from
.capa_base
import
CapaMixin
,
CapaFields
,
ComplexEncoder
from
.capa_base
import
CapaMixin
,
CapaFields
,
ComplexEncoder
from
capa
import
responsetypes
from
capa
import
responsetypes
,
inputtypes
from
.progress
import
Progress
from
.progress
import
Progress
from
xmodule.util.misc
import
escape_html_characters
from
xmodule.util.misc
import
escape_html_characters
from
xmodule.x_module
import
XModule
,
module_attr
,
DEPRECATION_VSCOMPAT_EVENT
from
xmodule.x_module
import
XModule
,
module_attr
,
DEPRECATION_VSCOMPAT_EVENT
...
@@ -277,9 +277,9 @@ class CapaDescriptor(CapaFields, RawDescriptor):
...
@@ -277,9 +277,9 @@ class CapaDescriptor(CapaFields, RawDescriptor):
validation
=
StudioValidation
.
copy
(
validation
)
validation
=
StudioValidation
.
copy
(
validation
)
# validate xml to check questions are correctly separated
# 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
(
validation
.
set_summary
(
StudioValidationMessage
(
StudioValidationMessage
(
StudioValidationMessage
.
WARNING
,
StudioValidationMessage
.
WARNING
,
...
@@ -292,18 +292,21 @@ class CapaDescriptor(CapaFields, RawDescriptor):
...
@@ -292,18 +292,21 @@ class CapaDescriptor(CapaFields, RawDescriptor):
return
validation
return
validation
def
validate_xml
(
self
):
def
validate_xml_for_inputtypes
(
self
):
input_tags
=
[
'choiceresponse'
,
'optionresponse'
,
'multiplechoiceresponse'
,
'stringresponse'
,
"""
'numericalresponse'
,
'schematicresponse'
,
'imageresponse'
,
'formularesponse'
]
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
)
xmltree
=
etree
.
fromstring
(
self
.
data
)
questions
=
xmltree
.
findall
(
".//question"
)
questions
=
xmltree
.
findall
(
".//question"
)
for
question
in
questions
:
for
question
in
questions
:
for
tag
in
input_t
ag
s
:
for
tag
in
input_t
ype
s
:
tag_elements
=
question
.
findall
(
".//"
+
tag
)
tag_elements
=
question
.
findall
(
".//"
+
tag
)
if
len
(
tag_elements
)
>
1
:
if
len
(
tag_elements
)
>
1
:
print
(
"more choices"
)
return
False
return
False
return
True
return
True
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment