修改老师新建作业界面

This commit is contained in:
sw 2015-03-23 17:18:58 +08:00
parent 36bd04cc7a
commit 5139ac30dc
6 changed files with 132 additions and 121 deletions

View File

@ -789,6 +789,7 @@ class CoursesController < ApplicationController
@homework = Bid.new
@homework.safe_attributes = params[:bid]
@homework.open_anonymous_evaluation = 1
@homework.deadline = (Time.now + 3600 * 24).strftime('%Y-%m-%d')
if (User.current.logged? && User.current.member_of_course?(Course.find params[:id] ))
render :layout => 'base_courses'
else

View File

@ -31,7 +31,7 @@
<span class="add_attachment" style="font-weight:normal;">
<%#= button_tag "浏览", :type=>"button", :onclick=>"CompatibleSend();" %>
<!--%= link_to image_tag(),"javascript:void(0)", :onclick => "_file.click()"%-->
<%= button_tag "浏览", :type=>"button", :onclick=>"_file.click()",:onmouseover => 'this.focus()' %>
<%= button_tag "文件浏览", :type=>"button", :onclick=>"_file.click()",:onmouseover => 'this.focus()',:class => 'sb' %>
<%= file_field_tag 'attachments[dummy][file]',
:id => '_file',
:class => 'file_selector',

View File

@ -0,0 +1,41 @@
<%= stylesheet_link_tag 'jquery/jquery-ui-1.9.2', :media => 'all' %>
<%= error_messages_for 'bid' %>
<%= hidden_field_tag 'course_id', @course.id %>
<div class="project_r_h">
<h2 class="project_h2"><%= l(:label_course_homework_new)%></h2>
</div>
<div class="hwork_new">
<ul>
<li class="ml45">
<label><span class="c_red">*</span>&nbsp;<%= l(:field_name)%>&nbsp;&nbsp;</label>
<input type="text" name="bid[name]" id="bid_name" class="hwork_input" maxlength="<%= Bid::NAME_LENGTH_LIMIT%>" onkeyup="regex_bid_name();" value="<%= @homework.name%>" >
<p id="bid_name_span" class="c_red" style="padding-left: 55px;"></p>
</li>
<li class="ml45">
<label class="fl" >&nbsp;&nbsp;<%= l(:field_quote)%>&nbsp;&nbsp;</label>
<textarea name="bid[description]" placeholder="最多3000个汉字(或6000个英文字符)" class="hwork_text fl" ></textarea>
</li>
<div class="cl"></div>
<li class="ml21">
<label><span class="c_red">*</span>&nbsp;<%= l(:label_limit_time)%>&nbsp;&nbsp;</label>
<input type="text" name="bid[deadline]" id="bid_deadline" class="hwork_input02" onchange="regexDeadLine();" readonly="readonly" >
<%= calendar_for('bid_deadline')%>
</li>
<li class=" mb5 ml30">
<label ><%= l(:label_open_anonymous_evaluation)%>&nbsp;&nbsp;</label>
<input type="checkbox" name="bid[open_anonymous_evaluation]" id="bid_open_anonymous_evaluation" checked="checked" >
<div class="cl"></div>
</li>
<li class="ml9">
<label><span class="c_red">*</span>&nbsp;<%= l(:field_evaluation_num)%>&nbsp;&nbsp;</label>
<input type="text" name="bid[evaluation_num]" id="bid_evaluation_num" class="hwork_input02" onkeyup="regex_evaluation_num();">
<span><%= l(:label_evaluation_description)%></span>
<p id="bid_evaluation_num_span" class="c_red" style="padding-left: 90px;"></p>
</li>
<li class="ml45">
<label>&nbsp;&nbsp;<%= l(:label_attachment_plural) %>&nbsp;&nbsp;</label>
<%= render :partial => 'attachments/form', :locals => {:container => @homework} %>
</li>
</ul>
</div>
<div class="cl"></div>

View File

@ -1,115 +1,8 @@
<script type="text/javascript">
function regexName()
{
var name = $.trim($("#bid_name").val());
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()
{
var deadline = $.trim($("#bid_deadline").val());
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;
}
}
function regexEvaluationNum()
{
var evaluation_num = $.trim($("#bid_evaluation_num").val());
var regex = /^\d+$/;
if($("#bid_open_anonymous_evaluation").attr("checked") == "checked")
{
if(evaluation_num=="")
{
$("#bid_evaluation_num_span").text("匿评分配数量不能为空");
$("#bid_evaluation_num_span").css('color','#ff0000');
return false;
}
else if(regex.test(evaluation_num))
{
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;
}
}
else
{
$("#bid_evaluation_num_span").text("匿评分配数量只能为数字");
$("#bid_evaluation_num_span").css('color','#ff0000');
return false;
}
}
else
{
return true;
}
}
$(function(){
$("#bid_open_anonymous_evaluation").click(function(){
if($("#bid_open_anonymous_evaluation").attr("checked") == "checked")
{
$("#evaluation_num_p").slideDown();
$("#open_anonymous_evaluation_span").slideUp();
}
else
{
$("#evaluation_num_p").slideUp();
$("#open_anonymous_evaluation_span").slideDown();
}
});
});
function submitHomework()
{
if(regexDeadLine()&&regexName()&&regexEvaluationNum())
{
$("#new_bid").submit();
}
}
</script>
<h3><%=l(:label_course_new_homework)%></h3>
<%= labelled_form_for @homework, :url => {:controller => 'bids', :action => 'create_homework',:course_id => "#{params[:id] || params[:course_id]}"} do |f| %>
<div class="box tabular">
<%= render :partial => 'homework_form', :locals => { :f => f } %>
<!--<input type="button" onclick="submitHomework();" value="<%#= l(:button_create)%>" class="enterprise">-->
<a href="#" onclick="submitHomework();"class="ButtonColor m3p10"><%= l(:button_create)%></a>
<%= javascript_tag "$('#bid_name').focus();" %>
<% end %>
</div>
<%= render :partial => 'bids/new_homework_form', :locals => { :f => f } %>
<li class=" ml90" >
<a class="blue_btn fl c_white" onclick="submit_new_bid();" href="#"><%= l(:button_create)%></a>
<%= link_to l(:button_cancel), homework_course_path(@course), :class => "blue_btn grey_btn fl c_white"%>
<div class="cl"></div>
</li>
<% end %>

View File

@ -2016,7 +2016,7 @@ zh:
label_anonymous_comments: 匿评
label_submit_comments: 提交评论
field_evaluation_num: 匿评分配数
field_evaluation_num: 匿评分配数
label_my_score: 我的评分
field_open_anonymous_evaluation: 是否使用匿评
label_course_empty_select: 尚未选择课程!
@ -2084,6 +2084,9 @@ zh:
label_totle: 共有
label_homework_count: 个作业
lebel_homework_commit: 已提交的作业
label_open_anonymous_evaluation: 是否匿评
label_evaluation_description: 即每份作业被允许匿评的人数
label_name_not_null: 名称不能为空

View File

@ -1,3 +1,4 @@
//验证搜索时输入名字
function regexName(content)
{
var name = $.trim($("#name").val());
@ -14,26 +15,26 @@ function regexName(content)
return true;
}
}
//提交搜索
function submitSerch(content)
{
if(regexName(content)){$("#course_search_form").submit();}
}
//课程描述显示更多信息
function show_more_msg()
{
$("#course_description").toggleClass("course_description_none");
}
//作业描述显示更多信息
function bid_show_more_des(id)
{
$("#bid_description_" + id).toggleClass("news_description_none");
}
//将右侧的最小高度设置成左侧高度,美化界面
$(document).ready(function () {
$("#RSide").css("min-height",$("#LSide").height()-30);
});
//课程作业结束时间倒计时
function ShowCountDown(year,month,day,divname)
{
var now = new Date();
@ -49,4 +50,76 @@ function ShowCountDown(year,month,day,divname)
+hour+"&nbsp;</span><span style='color: #acaeb1;'>时</span><span style='color: red;'>&nbsp;"
+minute+"&nbsp;</span><span style='color: #acaeb1;'>分</span><span style='color: red;'>&nbsp;"
+second+"&nbsp;</span><span style='color: #acaeb1;'>秒</span>");
}
//验证新建作业的名字
function regex_bid_name()
{
var name = $.trim($("#bid_name").val());
if(name=="")
{
$("#bid_name_span").text("名称不能为空");
return false;
}
else
{
$("#bid_name_span").text("");
return true;
}
}
function regex_evaluation_num()
{
var evaluation_num = $.trim($("#bid_evaluation_num").val());
var regex = /^\d+$/;
if($("#bid_open_anonymous_evaluation").attr("checked") == "checked")
{
if(evaluation_num=="")
{
$("#bid_evaluation_num_span").text("匿评分配数量不能为空");
return false;
}
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
{
$("#bid_evaluation_num_span").text("匿评分配数量只能为数字");
return false;
}
}
else
{
return true;
}
}
$(function(){
$("#bid_open_anonymous_evaluation").click(function(){
if($("#bid_open_anonymous_evaluation").attr("checked") == "checked")
{
$("#bid_evaluation_num").slideDown();
}
else
{
$("#bid_evaluation_num").slideUp();
}
});
});
function submit_new_bid()
{
if(regex_bid_name()&&regex_evaluation_num())
{
$("#new_bid").submit();
}
}