移植新版实训关卡按测试集给分同步到旧版

dev_local
杨树明 6 years ago
parent dada8cfeba
commit 0bbcacd48c

@ -2,8 +2,15 @@
<script id="t:test-setting-list" type="text/html">
<div class="test_array_item mt30">
<p class="clearfix pr mb20">
<span class="fl mt5 mr10 color-orange">*</span><span class="color-blue font-16 fl" name="sample_inputs_label">组1</span>
<span class="fl ml20 color-grey-6">
<span class="fl mt5 mr10 color-orange">*</span><span class="color-blue font-16 fl mr20" name="sample_inputs_label">组1</span>
<span class="fl color-grey-6 width90px mt3 none" name="percentagenumbox">
<input class="fl martopf4 width44pxinline" name="percentagenum">
<span class="mr15 wid10px">%</span>
</span>
<span class="fl color-grey-6">
<input type="checkbox" name="test_set[lock][]" class="magic-checkbox" id="hide-1"/>
<label for="hide-1" style="top:2px">隐藏</label>
<input type="hidden" name="test_set[hidden][]"/>
@ -153,15 +160,67 @@
</div>
<div class="edu-back-white mb10 clearfix">
<div class="padding40-20">
<p class="color-grey-6 font-16">测试集设置</p>
<p class="color-grey-6 font-16">测试集和系统评分规则</p>
<li class="clearfix">
<label class="panel-form-label fl">得分规范:</label>
<div class="radioStyle ml10">
<input type="radio" name="specification" value="All_tests" id="All_tests" class="ml-3 mr5 magic-radio" onchange="hideSystem_score_percentage()"/>
<label class="mt3" for="All_tests">通过全部测试集
<span class="color979797">(学员评测,仅当所有测试集都正确时,才获得一次性奖励)</span>
</label>
</div>
</li>
<li class="clearfix">
<label class="panel-form-label fl transparent">得分规范:</label>
<div class="fl ml10">
<input type="radio" name="specification" value="Partial_test" id="Partial_test" class="ml5 mr5 magic-radio" onchange="showSystem_score_percentage()"/>
<label class="mt3" for="Partial_test">通过部分测试集
<span class="color979797">(学员评测,当至少有一组测试集正确时,即可获得其对应比例的奖励)</span>
</label>
</div>
</li>
<li class="clearfix none" id="System_score_percentage">
<label class="panel-form-label fl">系统评分占比:</label>
<span class="fl mr20 ml10">
<input type="radio" name="Proportion" value="Equal_proportion" id="Equal_proportion" class="ml5 mr5 magic-radio"/>
<label class="mt3" for="Equal_proportion">均分比例</label>
</span>
<span class="fl mr20">
<input type="radio" name="Proportion" value="Custom_ratio" id="Custom_ratio" class="ml5 mr5 magic-radio"/>
<label class="mt3" for="Custom_ratio">自定义比例</label>
</span>
</li>
<div class="df">
<div class="flex1 mr20">
<div id="test_array_set">
<% if @test_sets.count == 0 %>
<div class="test_array_item mt30">
<p class="clearfix pr mb20">
<span class="fl mt5 mr10 color-orange">*</span><span class="color-blue font-16 fl" name="sample_inputs_label">组1</span>
<span class="fl ml20 color-grey-6">
<span class="fl mt5 mr10 color-orange">*</span><span class="color-blue font-16 fl mr20" name="sample_inputs_label">组1</span>
<!---------填写百分比----------->
<span class="fl color-grey-6 width90px mt3 none" name="percentagenumbox">
<input class="fl martopf4 width44pxinline" name="percentagenum">
<span class="mr15 wid10px">%</span>
</span>
<!--//----------------//-->
<span class="fl color-grey-6">
<input type="checkbox" name="test_set[lock][]" class="magic-checkbox" id="hide-1"/>
<label for="hide-1" style="top:2px">隐藏</label>
<input type="hidden" name="test_set[hidden][]"/>
@ -177,8 +236,17 @@
<% if index == 0 %>
<span class="fl mt5 mr10 color-orange">*</span>
<% end %>
<span class="color-blue font-16 fl" name="sample_inputs_label">组<%= index + 1 %></span>
<span class="fl ml20 color-grey-6">
<span class="color-blue font-16 fl mr20" name="sample_inputs_label">组<%= index + 1 %></span>
<!---------填写百分比----------->
<span class="fl color-grey-6 width90px mt3 none" name="percentagenumbox">
<input class="fl martopf4 width44pxinline" name="percentagenum">
<span class="mr15 wid10px">%</span>
</span>
<!-------------------->
<span class="fl color-grey-6">
<input type="checkbox" name="test_set[lock][]" <%= test.is_public? ? "" : "checked" %> class="magic-checkbox" id="hide-<%= index + 1 %>"/>
<label for="hide-<%= index + 1 %>" style="top:2px">隐藏</label>
<input type="hidden" name="test_set[hidden][]" />
@ -208,7 +276,55 @@
</div>
<% end %>
<script>
//百分比
function getpercentage(){
var percentagelist = document.getElementsByName("percentagenum");
var percentagenumbox = document.getElementsByName("percentagenumbox");
if($("#Partial_test").is(":checked")&&$("#Equal_proportion").is(":checked")){
var sum=parseInt(100/percentagelist.length);
for(var i=0; i<percentagelist.length;i++){
if(i+1!=percentagelist.length){
$(percentagelist[i]).val(sum);
$(percentagenumbox[i]).show();
}else{
$(percentagelist[i]).val(sum+100%percentagelist.length)
$(percentagenumbox[i]).show();
}
}
}
}
function showSystem_score_percentage(){
if($("#Partial_test").is(":checked")){
$("#System_score_percentage").show()
$("#Equal_proportion").attr('checked', 'checked');
}
var percentagenumbox = document.getElementsByName("percentagenumbox");
for(var i=0; i<percentagenumbox.length;i++){
$(percentagenumbox[i]).show();
}
getpercentage()
}
function hideSystem_score_percentage(){
if($("#All_tests").is(":checked")){
$("#System_score_percentage").hide()
$("#Equal_proportion").attr('disabled', 'disabled');
}
var percentagenumbox = document.getElementsByName("percentagenumbox");
for(var i=0; i<percentagenumbox.length;i++){
$(percentagenumbox[i]).hide();
$(percentagenumbox[i]).val("");
}
}
$(function(){
//填写百分比初始化
$("#All_tests").attr('checked', 'checked');
if($("#All_tests").is(":checked")){
$("#System_score_percentage").hide()
}
// 设置textarea的宽度到140以后出现滚动条
var test_set_inputs = document.getElementsByName("test_set[input][]");
var test_set_outputs = document.getElementsByName("test_set[output][]");
@ -229,6 +345,8 @@
var outputs = document.getElementsByName("test_set[output][]");
var inputs_labels = document.getElementsByName("sample_inputs_label");
var inputs_set = document.getElementsByName("test_set[lock][]");
//百分比
getpercentage()
for (var j = 0; j < inputs_labels.length; j++) {
$(inputs_labels[j]).html("组" + (j + 1));
}
@ -247,6 +365,8 @@
});
$("#test_array_set").on('click', 'a.sample_icon_remove', function () {
$(this).parents('.test_array_item').remove();
//百分比
getpercentage()
var inputs_labels = document.getElementsByName("sample_inputs_label");
for (var j = 0; j < inputs_labels.length; j++) {
$(inputs_labels[j]).html("组" + (j + 1));

@ -1041,3 +1041,29 @@ html>body #ajax-indicator { position: fixed; }
width: 80px;
text-align: center;
}
.radioStyle{
display: inline-block;
height: 37px;
}
.transparent{
color: transparent !important;
}
.width90px{
width: 90px;
}
.width44pxinline{
display: inline-block;
width: 44px;
}
.inline-block{
display: inline-block;
}
.wid10px{
display: inline-block;
margin-left: 10px;
}
Loading…
Cancel
Save