diff --git a/common/lib/xmodule/xmodule/js/fixtures/jsinput_problem.html b/common/lib/xmodule/xmodule/js/fixtures/jsinput_problem.html new file mode 100644 index 0000000000000000000000000000000000000000..0e133de9ffd8d1ca1b97ec27933a71f39f055411 --- /dev/null +++ b/common/lib/xmodule/xmodule/js/fixtures/jsinput_problem.html @@ -0,0 +1,53 @@ +<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> diff --git a/common/lib/xmodule/xmodule/js/spec/capa/display_spec.coffee b/common/lib/xmodule/xmodule/js/spec/capa/display_spec.coffee index 203a70d9d1908a6056d562e974287d0414d7ed09..cbc05b03026e8580ffd32343748926cea26c3272 100644 --- a/common/lib/xmodule/xmodule/js/spec/capa/display_spec.coffee +++ b/common/lib/xmodule/xmodule/js/spec/capa/display_spec.coffee @@ -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) diff --git a/common/lib/xmodule/xmodule/js/src/capa/display.coffee b/common/lib/xmodule/xmodule/js/src/capa/display.coffee index 592c9b3a0cb45c4db3f7abbdfa14355f9652496e..5fa03e381e68f37404b3868b445c24f1fb8ae643 100644 --- a/common/lib/xmodule/xmodule/js/src/capa/display.coffee +++ b/common/lib/xmodule/xmodule/js/src/capa/display.coffee @@ -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 ###