Commit e2ce9777 by Waheed Ahmed

Fixed multiple JsInput's in problem.

TNL-269
parent e895e101
<h2 class="problem-header">Custom Javascript Display and Grading</h2>
<div role="application" class="problem">
<div>
<span>
<section data-processed="true" data-sop="false" data-setstate="WebGLDemo.setState"
data-getstate="WebGLDemo.getState"
data-stored=""
data="WebGLDemo.getGrade" class="jsinput"
id="inputtype_1_">
<div id="status_1_" class="correct">
<iframe width="400" height="400" frameborder="0" src="https://studio.edx.org/c4x/edX/DemoX/asset/webGLDemo.html"
seamless="seamless"
sandbox="allow-scripts allow-popups allow-same-origin allow-forms allow-pointer-lock"
id="iframe_1_"
name="iframe_1_">
</iframe>
<input type="hidden"
value=""
waitfor="" id="input_1_1"
name="input_1_1">
</div>
</section>
</span>
<span>
<section data-processed="true" data-sop="false" data-setstate="WebGLDemo.setState"
data-getstate="WebGLDemo.getState"
data-stored=""
data="WebGLDemo.getGrade" class="jsinput"
id="inputtype_1_">
<div id="status_1_" class="incorrect">
<iframe width="400" height="400" frameborder="0"
src="https://studio.edx.org/c4x/edX/DemoX/asset/webGLDemo.html" seamless="seamless"
sandbox="allow-scripts allow-popups allow-same-origin allow-forms allow-pointer-lock"
id="iframe_1_"
name="iframe_1_">
</iframe>
<input type="hidden"
value=""
id="input_1_2"
name="input_1_2">
</div>
</section>
</span>
</div>
<div class="action">
<input type="hidden" value="Custom Javascript Display and Grading" name="problem_id">
<input type="button" value="Reset" class="reset">
<button class="show"><span aria-hidden="true" class="show-label">Show Answer</span> <span class="sr">Reveal Answer</span></button>
</div>
</div>
......@@ -604,3 +604,14 @@ describe 'Problem', ->
xit 'serialize all answers', ->
@problem.refreshAnswers()
expect(@problem.answers).toEqual "input_1_1=one&input_1_2=two"
describe 'multiple JsInput in single problem', ->
jsinput_html = readFixtures('jsinput_problem.html')
beforeEach ->
@problem = new Problem($('.xblock-student_view'))
@problem.render(jsinput_html)
it 'check_save_waitfor should return false', ->
$(@problem.inputs[0]).data('waitfor', ->)
expect(@problem.check_save_waitfor()).toEqual(false)
......@@ -180,6 +180,7 @@ class @Problem
# and specify the function to be called by the check button before sending
# off @answers
check_save_waitfor: (callback) =>
flag = false
for inp in @inputs
if ($(inp).is("input[waitfor]"))
try
......@@ -193,9 +194,10 @@ class @Problem
else
alert "Could not grade your answer. The submission was aborted."
throw e
return true
flag = true
else
return false
flag = false
return flag
###
......
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