新建作业js验证以及页面操作js效果添加

This commit is contained in:
sw 2015-05-20 15:43:55 +08:00
parent a7fd5b950d
commit 296d4a678c
3 changed files with 46 additions and 38 deletions

View File

@ -1,11 +1,11 @@
<ul class="hwork_new_basic mb10"> <ul class="hwork_new_basic mb10">
<li > <li>
<label class="label02"> <label class="label02 mb20">
<span class="c_red">*</span> <span class="c_red">*</span>
&nbsp;<%= l(:field_name)%>&nbsp; &nbsp;<%= l(:field_name)%>&nbsp;
</label> </label>
<input type="text" name="homework_common[name]" id="homework_name" class="w548 h26 mb10 fl" maxlength="<%= Bid::NAME_LENGTH_LIMIT%>" onkeyup="regex_homework_name();" value="<%= homework.name%>" > <input type="text" name="homework_common[name]" id="homework_name" class="w548 h26 fl" maxlength="<%= Bid::NAME_LENGTH_LIMIT%>" onkeyup="regex_homework_name();" value="<%= homework.name%>" >
<p id="homework_name_span" class="c_red" style="padding-left: 55px;"></p> <p id="homework_name_span" class="c_red ml110"></p>
</li> </li>
<div class="cl"></div> <div class="cl"></div>
<li > <li >
@ -62,7 +62,7 @@
<%= select_tag :ta_proportion,options_for_select(ta_proportion_option,homework.homework_detail_manual.ta_proportion), {:class => "fl mb10 h26 w70"} %> <%= select_tag :ta_proportion,options_for_select(ta_proportion_option,homework.homework_detail_manual.ta_proportion), {:class => "fl mb10 h26 w70"} %>
<span class="ml5 fl mt5">×&nbsp;教辅评分</span> <span class="ml5 fl mt5">×&nbsp;教辅评分</span>
<span class="ml5 fl mt5">&nbsp;&nbsp;+&nbsp;&nbsp;</span> <span class="ml5 fl mt5">&nbsp;&nbsp;+&nbsp;&nbsp;</span>
<input type="text" value="<%= ((1 - homework.homework_detail_manual.ta_proportion) * 100).to_i%>%" class="fl mb10 h26 w70" readonly> <input type="text" id="student_proportion" value="<%= ((1 - homework.homework_detail_manual.ta_proportion) * 100).to_i%>%" class="fl mb10 h26 w70" readonly>
<span class="ml5 fl mt5">×&nbsp;匿评得分</span> <span class="ml5 fl mt5">×&nbsp;匿评得分</span>
<span class="ml5 fl mt5">=&nbsp;学生得分</span> <span class="ml5 fl mt5">=&nbsp;学生得分</span>
<div class="cl"></div> <div class="cl"></div>
@ -94,8 +94,8 @@
</li> </li>
<li > <li >
<label class="label02">匿评分配数:&nbsp;</label> <label class="label02">匿评分配数:&nbsp;</label>
<input type="text" name="evaluation_num" class=" hwork_input02 fl" value="<%= homework.homework_detail_manual.evaluation_num%>" maxlength="2" > <input type="text" name="evaluation_num" id="evaluation_num" class=" hwork_input02 fl" value="<%= homework.homework_detail_manual.evaluation_num%>" maxlength="2" onkeyup="regex_evaluation_num()">
<p class="ml5 fl mt5">每个学生将收到<span class="c_red">&nbsp;3&nbsp;</span>份待匿评作品</p> <p class="ml5 fl mt5" id="evaluation_num_notice">每个学生将收到<span class="c_red">&nbsp;3&nbsp;</span>份待匿评作品</p>
<div class="cl"></div> <div class="cl"></div>
</li> </li>
@ -103,7 +103,7 @@
<label class="label02">缺评扣分:&nbsp;</label> <label class="label02">缺评扣分:&nbsp;</label>
<%= select_tag :absence_penalty,options_for_select(absence_penalty_option,homework.homework_detail_manual.absence_penalty), {:class => "fl mb10 h26 w70"} %> <%= select_tag :absence_penalty,options_for_select(absence_penalty_option,homework.homework_detail_manual.absence_penalty), {:class => "fl mb10 h26 w70"} %>
<span class="fl mt5">&nbsp;分</span> <span class="fl mt5">&nbsp;分</span>
<p class="ml5 fl mt5">学生漏评1个作品将扣<span class="c_red">&nbsp;2&nbsp;</span>分</p> <p class="ml5 fl mt5">学生漏评1个作品将扣<span class="c_red" id="absence_penalty_notice">&nbsp;2&nbsp;</span>分</p>
<div class="cl"></div> <div class="cl"></div>
</li> </li>
</ul> <!-- h1 end---> </ul> <!-- h1 end--->

View File

@ -9,8 +9,8 @@
<div class="hwork_new"> <div class="hwork_new">
<%= labelled_form_for @homework,:url => {:controller => 'homework_common',:action => 'create'} do |f| %> <%= labelled_form_for @homework,:url => {:controller => 'homework_common',:action => 'create'} do |f| %>
<%= render :partial => 'homework_common/homework_common_form', :locals => { :homework => @homework,:f => f,:edit_mode => false } %> <%= render :partial => 'homework_common/homework_common_form', :locals => { :homework => @homework,:f => f,:edit_mode => false } %>
<a class="blue_btn fl mr10 " onClick="show_window();" >提交</a> <a class="blue_btn fl mr10 " onClick="submit_homework('new_homework_common');" >提交</a>
<a href="#" target="_blank" class="grey_btn fl ">取消</a> <%= link_to '取消',homework_common_index_path(:course => @course.id),:class => 'grey_btn fl'%>
<% end%> <% end%>
</div><!--hwork_new end--> </div><!--hwork_new end-->
<div class="cl"></div> <div class="cl"></div>

View File

@ -398,60 +398,68 @@ function regex_homework_name()
//验证匿评数量 //验证匿评数量
function regex_evaluation_num() function regex_evaluation_num()
{ {
var evaluation_num = $.trim($("#bid_evaluation_num").val()); var evaluation_num = $.trim($("#evaluation_num").val());
var regex = /^\d+$/; var regex = /^\d+$/;
if($("#bid_open_anonymous_evaluation").attr("checked") == "checked") if(evaluation_num=="")
{ {
if(evaluation_num=="") $("#evaluation_num_notice").html("匿评分配数量不能为空");
$("#evaluation_num_notice").removeClass("c_red").addClass("c_red");
return false;
}
else if(regex.test(evaluation_num))
{
if(evaluation_num > 0)
{ {
$("#bid_evaluation_num_span").text("匿评分配数量不能为空"); $("#evaluation_num_notice").html("每个学生将收到<span class='c_red'>&nbsp;"+ parseInt(evaluation_num) + "&nbsp;</span>份待匿评作品");
return false; $("#evaluation_num_notice").removeClass("c_red");
} return true;
else if(regex.test(evaluation_num))
{
if(evaluation_num > 0)
{
$("#bid_evaluation_num_span").text("");
return true;
}
else
{
$("#bid_evaluation_num_span").text("匿评分配数量必须为大于0");
return false;
}
} }
else else
{ {
$("#bid_evaluation_num_span").text("匿评分配数量只能为数字"); $("#evaluation_num_notice").html("匿评分配数量必须为大于0");
$("#evaluation_num_notice").removeClass("c_red").addClass("c_red");
return false; return false;
} }
} }
else else
{ {
return true; $("#evaluation_num_notice").html("匿评分配数量只能为数字");
$("#evaluation_num_notice").removeClass("c_red").addClass("c_red");
return false;
} }
} }
//点击是否开启匿评单选框效果 //点击是否开启匿评单选框效果
$(function(){ $(function(){
$("#bid_open_anonymous_evaluation").click(function(){ $("#homework_common_homework_type").click(function(){
if($("#bid_open_anonymous_evaluation").attr("checked") == "checked") if($("#homework_common_homework_type").attr("checked") == "checked")
{ {
$("#bid_evaluation_num_li").slideDown(); $("#evaluation_setting").slideDown();
$("#ta_proportion").removeAttr("disabled");
} }
else else
{ {
$("#bid_evaluation_num_li").slideUp(); $("#evaluation_setting").slideUp();
$("#ta_proportion").attr("disabled","disabled");
} }
}); });
$("#absence_penalty").change(function(){
$("#absence_penalty_notice").html("&nbsp;"+ $("#absence_penalty").val() +"&nbsp;");
});
$("#ta_proportion").change(function(){
var ta_proportion = $("#ta_proportion").val();
$("#student_proportion").val(parseInt((1-ta_proportion)*100) + "%");
});
}); });
//老师提交新建作业 //老师提交 新建/修改 作业
function submit_new_bid(id) function submit_homework(id)
{ {
if(regex_bid_name()&&regex_evaluation_num()) if(regex_homework_name()&&regex_evaluation_num())
{ {
bid_description_editor.sync(); homework_description_editor.sync();
$("#"+id).submit(); $("#"+id).submit();
} }
} }