2014-08-28 14:05:48 +08:00
|
|
|
<script type="text/javascript">
|
|
|
|
function regexName()
|
|
|
|
{
|
2014-11-05 10:06:20 +08:00
|
|
|
var name = $.trim($("#bid_name").val());
|
2014-08-28 14:05:48 +08:00
|
|
|
|
|
|
|
if(name=="")
|
|
|
|
{
|
|
|
|
$("#bid_name_span").text("名称不能为空");
|
|
|
|
$("#bid_name_span").css('color','#ff0000');
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$("#bid_name_span").text("填写正确");
|
|
|
|
$("#bid_name_span").css('color','#008000');
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
function regexDeadLine()
|
|
|
|
{
|
2014-11-05 10:06:20 +08:00
|
|
|
var deadline = $.trim($("#bid_deadline").val());
|
2014-08-28 14:05:48 +08:00
|
|
|
var regex = /^\d{4}-\d{2}-\d{2}$/;
|
|
|
|
if(deadline=="")
|
|
|
|
{
|
|
|
|
$("#bid_deadline_span").text("截止日期不能为空");
|
|
|
|
$("#bid_deadline_span").css('color','#ff0000');
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
else if(regex.test(deadline))
|
|
|
|
{
|
|
|
|
$("#bid_deadline_span").text("填写正确");
|
|
|
|
$("#bid_deadline_span").css('color','#008000');
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$("#bid_deadline_span").text("截止日期格式错误");
|
|
|
|
$("#bid_deadline_span").css('color','#ff0000');
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
2014-11-05 10:06:20 +08:00
|
|
|
function regexEvaluationNum()
|
|
|
|
{
|
|
|
|
var evaluation_num = $.trim($("#bid_evaluation_num").val());
|
|
|
|
var regex = /^\d+$/;
|
2014-11-19 10:34:36 +08:00
|
|
|
if($("#bid_open_anonymous_evaluation").attr("checked") == "checked")
|
2014-11-05 10:06:20 +08:00
|
|
|
{
|
2014-11-19 10:34:36 +08:00
|
|
|
if(evaluation_num=="")
|
|
|
|
{
|
|
|
|
$("#bid_evaluation_num_span").text("匿评分配数量不能为空");
|
|
|
|
$("#bid_evaluation_num_span").css('color','#ff0000');
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
else if(regex.test(evaluation_num))
|
2014-11-05 10:14:02 +08:00
|
|
|
{
|
2014-11-19 10:34:36 +08:00
|
|
|
if(evaluation_num > 0)
|
|
|
|
{
|
|
|
|
$("#bid_evaluation_num_span").text("填写正确");
|
|
|
|
$("#bid_evaluation_num_span").css('color','#008000');
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$("#bid_evaluation_num_span").text("匿评分配数量必须为大于0");
|
|
|
|
$("#bid_evaluation_num_span").css('color','#ff0000');
|
|
|
|
return false;
|
|
|
|
}
|
2014-11-05 10:14:02 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2014-11-19 10:34:36 +08:00
|
|
|
$("#bid_evaluation_num_span").text("匿评分配数量只能为数字");
|
2014-11-05 10:14:02 +08:00
|
|
|
$("#bid_evaluation_num_span").css('color','#ff0000');
|
|
|
|
return false;
|
|
|
|
}
|
2014-11-05 10:06:20 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2014-11-19 10:34:36 +08:00
|
|
|
return true;
|
2014-11-05 10:06:20 +08:00
|
|
|
}
|
|
|
|
}
|
2014-08-28 14:05:48 +08:00
|
|
|
|
2014-11-19 10:34:36 +08:00
|
|
|
$(function(){
|
|
|
|
$("#bid_open_anonymous_evaluation").click(function(){
|
|
|
|
if($("#bid_open_anonymous_evaluation").attr("checked") == "checked")
|
|
|
|
{
|
|
|
|
$("#evaluation_num_p").slideDown();
|
2014-12-10 10:54:21 +08:00
|
|
|
$("#open_anonymous_evaluation_span").slideUp();
|
2014-11-19 10:34:36 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$("#evaluation_num_p").slideUp();
|
2014-12-10 10:54:21 +08:00
|
|
|
$("#open_anonymous_evaluation_span").slideDown();
|
2014-11-19 10:34:36 +08:00
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2014-08-28 14:05:48 +08:00
|
|
|
function submitHomework()
|
|
|
|
{
|
2014-11-05 10:06:20 +08:00
|
|
|
if(regexDeadLine()&®exName()&®exEvaluationNum())
|
2014-08-28 14:05:48 +08:00
|
|
|
{
|
|
|
|
$("#new_bid").submit();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
2013-08-30 09:34:21 +08:00
|
|
|
<h3><%=l(:label_course_new_homework)%></h3>
|
|
|
|
|
2014-06-30 11:15:52 +08:00
|
|
|
<%= labelled_form_for @homework, :url => {:controller => 'bids', :action => 'create_homework',:course_id => "#{params[:id] || params[:course_id]}"} do |f| %>
|
2013-08-30 09:34:21 +08:00
|
|
|
<div class="box tabular">
|
2013-09-12 10:41:15 +08:00
|
|
|
<%= render :partial => 'homework_form', :locals => { :f => f } %>
|
2014-11-27 17:34:27 +08:00
|
|
|
<!--<input type="button" onclick="submitHomework();" value="<%#= l(:button_create)%>" class="enterprise">-->
|
|
|
|
<a href="#" onclick="submitHomework();"class="ButtonColor m3p10"><%= l(:button_create)%></a>
|
2013-08-30 09:34:21 +08:00
|
|
|
<%= javascript_tag "$('#bid_name').focus();" %>
|
|
|
|
<% end %>
|
|
|
|
</div>
|