当标准代码内容改变时,自动还原所有的测试信息

This commit is contained in:
sw 2015-08-01 10:45:32 +08:00
parent 504d5a6b32
commit cbbc93acbd
3 changed files with 13 additions and 5 deletions

View File

@ -78,7 +78,7 @@
<li >
<label class="label02">&nbsp;标准代码:&nbsp;</label>
<textarea name="standard_code" class=" w547 h150 mb10 fl"><%= homework.homework_detail_programing.standard_code%></textarea>
<textarea name="standard_code" class=" w547 h150 mb10 fl" oninput="init_programing_test();" onpropertychange="init_programing_test()"><%= homework.homework_detail_programing.standard_code%></textarea>
<div class="cl"></div>
</li>
@ -96,7 +96,7 @@
<li>
<a class="icon_add ml10 " href="javascript:void(0);" title="添加测试" onclick="add_programing_test($(this).parent().parent())"></a>
<a class="icon_remove" href="javascript:void(0);" title="删除测试" onclick="remove_programing_test($(this).parent().parent())"></a>
<a class="blue_btn fl ml5 mt1" onclick="programing_test('<%= homework_test.id%>')" id="test_send_<%= homework_test.id%>">测试</a>
<a class="blue_btn fl ml5 mt1 programing_test" onclick="programing_test('<%= homework_test.id%>')" id="test_send_<%= homework_test.id%>">测试</a>
<input type="hidden" id="test_result_<%= homework_test.id%>" name="result[<%= homework_test.id%>]" />
</li>
<div class="cl"></div>
@ -115,7 +115,7 @@
<li>
<a class="icon_add ml10 " href="javascript:void(0);" title="添加测试" onclick="add_programing_test($(this).parent().parent())"></a>
<a class="icon_remove" href="javascript:void(0);" title="删除测试" onclick="remove_programing_test($(this).parent().parent())"></a>
<a class="blue_btn fl ml5 mt1" onclick="programing_test('0')" id="test_send_0">测试</a>
<a class="blue_btn fl ml5 mt programing_test" onclick="programing_test('0')" id="test_send_0">测试</a>
<input type="hidden" id="test_result_0" name="result[0]" />
</li>
<div class="cl"></div>
@ -142,4 +142,12 @@
}
);
}
function init_programing_test()
{
$(".programing_test").each(function(){
$(this).removeClass("green_btn red_btn").addClass("blue_btn").text("测试");
$(this).next("input").val("");
});
}
</script>

View File

@ -1,2 +1,2 @@
$("#test_send_<%= @index%>").replaceWith("<a class='<%= @result == 0 ? 'green_btn' : 'red_btn'%> fl ml5 mt1' onclick='programing_test(<%= @index%>)' id='test_send_<%= @index%>'><%= @result == 0 ? '正确' : '错误'%></a>");
$("#test_send_<%= @index%>").replaceWith("<a class='<%= @result == 0 ? 'green_btn' : 'red_btn'%> fl ml5 mt1 programing_test' onclick='programing_test(<%= @index%>)' id='test_send_<%= @index%>'><%= @result == 0 ? '正确' : '错误'%></a>");
$("#test_result_<%= @index%>").val("<%= @result%>");

View File

@ -550,7 +550,7 @@ function add_programing_test(obj) {
"</li><li ><label class='fl f14 ml10'>&nbsp;输出:&nbsp;</label><input type='text' class='fl h26 w190 mb10' name='output[" + now +"]' />" +
"</li><li><a class='icon_add ml10' href='javascript:void(0);' title='添加测试' onclick='add_programing_test($(this).parent().parent())'></a>" +
"<a class='icon_remove' href='javascript:void(0);' title='删除测试' onclick='remove_programing_test($(this).parent().parent())'></a>" +
"<a class='blue_btn fl ml5 mt1' onclick='programing_test("+ now +")' id='test_send_" + now + "'>测试</a>" +
"<a class='blue_btn fl ml5 mt1 programing_test' onclick='programing_test("+ now +")' id='test_send_" + now + "'>测试</a>" +
"<input type='hidden' id='test_result_" + now +"' name='result[" + now +"]'/>" +
"</li><div class='cl'></div></div>");
}