diff --git a/common/lib/xmodule/xmodule/js/spec/problem/edit_spec.coffee b/common/lib/xmodule/xmodule/js/spec/problem/edit_spec.coffee
index 9b8062d60d..5161e658e7 100644
--- a/common/lib/xmodule/xmodule/js/spec/problem/edit_spec.coffee
+++ b/common/lib/xmodule/xmodule/js/spec/problem/edit_spec.coffee
@@ -119,13 +119,13 @@ describe 'MarkdownEditingDescriptor', ->
The answer is correct if it is within a specified numerical tolerance of the expected answer.
Enter the numerical value of Pi:
-
+
Enter the approximate value of 502*9:
-
+
@@ -147,6 +147,20 @@ describe 'MarkdownEditingDescriptor', ->
+ """)
+ it 'will convert 0 as a numerical response (instead of string response)', ->
+ data = MarkdownEditingDescriptor.markdownToXml("""
+ Enter 0 with a tolerance:
+ = 0 +- .02
+ """)
+ expect(data).toEqual("""
+ Enter 0 with a tolerance:
+
+
+
+
+
+
""")
it 'converts multiple choice to xml', ->
data = MarkdownEditingDescriptor.markdownToXml("""A multiple choice problem presents radio buttons for student input. Students can only select a single option presented. Multiple Choice questions have been the subject of many areas of research due to the early invention and adoption of bubble sheets.
diff --git a/common/lib/xmodule/xmodule/js/src/problem/edit.coffee b/common/lib/xmodule/xmodule/js/src/problem/edit.coffee
index 2bfe483a7f..b723f230e9 100644
--- a/common/lib/xmodule/xmodule/js/src/problem/edit.coffee
+++ b/common/lib/xmodule/xmodule/js/src/problem/edit.coffee
@@ -231,13 +231,14 @@ class @MarkdownEditingDescriptor extends XModule.Descriptor
// replace string and numerical
xml = xml.replace(/^\=\s*(.*?$)/gm, function(match, p) {
var string;
- var params = /(.*?)\+\-\s*(.*?$)/.exec(p);
- if(parseFloat(p)) {
+ var floatValue = parseFloat(p);
+ if(!isNaN(floatValue)) {
+ var params = /(.*?)\+\-\s*(.*?$)/.exec(p);
if(params) {
- string = '\n';
+ string = '\n';
string += ' \n';
} else {
- string = '\n';
+ string = '\n';
}
string += ' \n';
string += '\n\n';