1、老师新建作业界面,数据i初始化

2、部分help方法添加
This commit is contained in:
sw 2015-05-20 15:05:35 +08:00
parent 3b3ca0024d
commit a7fd5b950d
8 changed files with 181 additions and 146 deletions

View File

@ -13,7 +13,18 @@ class HomeworkCommonController < ApplicationController
end
def new
@homework = HomeworkCommon.new
@homework.safe_attributes = params[:homework_common]
@homework.late_penalty = 2
@homework.end_time = (Time.now + 3600 * 24).strftime('%Y-%m-%d')
@homework.publish_time = Time.now.strftime('%Y-%m-%d')
@homework_detail_manual = HomeworkDetailManual.new
@homework_detail_manual.ta_proportion = 0.6
@homework_detail_manual.absence_penalty = 2
@homework_detail_manual.evaluation_num = 3
@homework_detail_manual.evaluation_start = Time.now.strftime('%Y-%m-%d')
@homework_detail_manual.evaluation_end = (Time.now + 3600 * 24).strftime('%Y-%m-%d')
@homework.homework_detail_manual = @homework_detail_manual
respond_to do |format|
format.html
end

View File

@ -55,4 +55,44 @@ module HomeworkCommonHelper
def cur_user_works_for_homework homework
homework.student_works.where("user_id = ?",User.current).first
end
#迟交扣分下拉框
def late_penalty_option
type = []
for i in (1..5)
option = []
option << i
option << i
type << option
end
type
end
#教辅评分比例下拉框
def ta_proportion_option
type = []
i = 10
while i <= 100
option = []
option << i.to_s + "%"
option << i.to_f / 100
type << option
i += 10
end
type
end
#缺评扣分
def absence_penalty_option
type = []
i = 1
while i <= 5
option = []
option << i
option << i
type << option
i += 1
end
type
end
end

View File

@ -1,7 +1,8 @@
#老师布置的作业表
#homework_type: 1:普通作业;2:匿评作业;3:编程作业
class HomeworkCommon < ActiveRecord::Base
attr_accessible :name, :user_id, :description, :publish_time, :end_time, :homework_type, :late_penalty, :course_id
# attr_accessible :name, :user_id, :description, :publish_time, :end_time, :homework_type, :late_penalty, :course_id
include Redmine::SafeAttributes
belongs_to :course
belongs_to :user

View File

@ -0,0 +1,110 @@
<ul class="hwork_new_basic mb10">
<li >
<label class="label02">
<span class="c_red">*</span>
&nbsp;<%= l(:field_name)%>&nbsp;
</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%>" >
<p id="homework_name_span" class="c_red" style="padding-left: 55px;"></p>
</li>
<div class="cl"></div>
<li >
<label class="label02 ">&nbsp;&nbsp;&nbsp;<%= l(:field_quote)%>&nbsp;</label>
<!--<textarea name="" placeholder="请在此填入作业的要求及评分依据" class=" w548 h150 mb10 fl" ></textarea>-->
<% if edit_mode %>
<%= f.kindeditor :description,:width=>'83%',:editor_id => 'homework_description_editor',:owner_id => homework.id,:owner_type =>OwnerTypeHelper::BID %>
<% else %>
<%= hidden_field_tag :asset_id,params[:asset_id],:required => false,:style => 'display:none' %>
<%= f.kindeditor :description,:width=>'83%',:editor_id => 'homework_description_editor' %>
<% end %>
</li>
<div class="cl"></div>
<li class="mt10">
<label class="label02">&nbsp;&nbsp;附件:&nbsp;</label>
<%= render :partial => 'attachments/new_form', :locals => {:container => homework} %>
</li>
<div class="cl"></div>
<li class="fl">
<label class="label02">
<span class="c_red">*</span>
&nbsp;<%= l(:label_limit_time)%>&nbsp;
</label>
<input type="text" name="homework_common[end_time]" id="homework_end_time" class="hwork_input02 fl" readonly="readonly" value="<%= homework.end_time%>" >
<%= calendar_for('homework_end_time')%>
<div class="cl"></div>
</li>
<li class="fl ml100">
<label class="label02">&nbsp;发布日期:&nbsp;</label>
<input type="text" name="homework_common[publish_time]" id="homework_publish_time" class="hwork_input02 fl" readonly="readonly" value="<%= homework.publish_time%>" >
<%= calendar_for('homework_publish_time')%>
<div class="cl"></div>
</li>
<div class="cl"></div>
</ul><!--hwork_new_basic end--->
<div class="hwork_new_set" >
<p class="fl ml20 f14 mb10 c_orange">基本规则设置总分为100分</p>
<div class="cl"></div>
<form name="frm">
<ul class="ml10">
<li>
<label class="label02">迟交扣分:&nbsp;</label>
<%= select_tag :late_penalty,options_for_select(late_penalty_option,homework.late_penalty), {:class => "fl mb10 h26 w70"} %>
<span class="fl mt5">&nbsp;分</span>
<div class="cl"></div>
</li>
<li >
<label class="label02" >是否匿评:&nbsp;</label>
<%= f.check_box :homework_type, :class => "mb10 mt5 fl" %>
<div class="cl"></div>
</li>
<li >
<label class="label02">评分比例:&nbsp;</label>
<%= 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;&nbsp;+&nbsp;&nbsp;</span>
<input type="text" 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>
<div class="cl"></div>
</li>
<li >
<label class="label02" >&nbsp;&nbsp;</label>
<span class=" fl c_red">如果教师对学生作品进行了评分,则教师评分为学生最终得分。</span>
<div class="cl"></div>
</li>
</ul>
</form>
</div><!--hwork_new_set end-->
<div class="hwork_new_set" id="evaluation_setting" >
<p class="fl ml20 f14 mb10 c_orange">学生互评设置</p>
<div class="cl"></div>
<ul class="ml10">
<li >
<label class="label02">互评启动时间:&nbsp;</label>
<input type="text" name="evaluation_start" id="evaluation_start_time" class="hwork_input02 fl" readonly="readonly" value="<%= homework.homework_detail_manual.evaluation_start%>" >
<%= calendar_for('evaluation_start_time')%>
<div class="cl"></div>
</li>
<li >
<label class="label02">互评结束时间:&nbsp;</label>
<input type="text" name="evaluation_end" id="evaluation_end_time" class="hwork_input02 fl" readonly="readonly" value="<%= homework.homework_detail_manual.evaluation_end%>" >
<%= calendar_for('evaluation_end_time')%>
<div class="cl"></div>
</li>
<li >
<label class="label02">匿评分配数:&nbsp;</label>
<input type="text" name="evaluation_num" class=" hwork_input02 fl" value="<%= homework.homework_detail_manual.evaluation_num%>" maxlength="2" >
<p class="ml5 fl mt5">每个学生将收到<span class="c_red">&nbsp;3&nbsp;</span>份待匿评作品</p>
<div class="cl"></div>
</li>
<li >
<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"} %>
<span class="fl mt5">&nbsp;分</span>
<p class="ml5 fl mt5">学生漏评1个作品将扣<span class="c_red">&nbsp;2&nbsp;</span>分</p>
<div class="cl"></div>
</li>
</ul> <!-- h1 end--->
</div><!--hwork_new_set end-->

View File

@ -1,143 +1,16 @@
<%= javascript_include_tag "/assets/kindeditor/kindeditor" %>
<%= error_messages_for 'homework_common' %>
<div class="project_r_h">
<h2 class="project_h2">发布作业</h2>
<h2 class="project_h2">
<%= l(:label_course_homework_new)%>
</h2>
</div>
<div class="hwork_new">
<ul class="hwork_new_basic mb10">
<li >
<label class="label02"><span class="c_red">*</span>&nbsp;名称:&nbsp;</label>
<input type="text" name="" class="w548 h26 mb10 fl" >
</li>
<div class="cl"></div>
<li >
<label class="label02 ">&nbsp;&nbsp;作业描述及&nbsp;&nbsp;&nbsp;&nbsp;<br />评分依据:&nbsp;</label>
<textarea name="" placeholder="请在此填入作业的要求及评分依据" class=" w548 h150 mb10 fl" ></textarea>
</li>
<div class="cl"></div>
<li >
<label class="label02">&nbsp;&nbsp;附件:&nbsp;</label>
<input type="submit" name="" value="文件浏览" class="sub_btn">&nbsp;&nbsp;&nbsp;&nbsp;<span class=" c_grey ">-文件不超过200MB</span>
</li>
<div class="cl"></div>
<li class="fl">
<label class="label02"><span class="c_red">*</span>&nbsp;截止日期:&nbsp;</label>
<input type="text" name="" class="hwork_input02 fl" value="2015-04-03 12:00" >
<a href="javascript:void(0);" class="pic_date mt5 ml5"></a>
<div class="cl"></div>
</li>
<li class="fl ml100">
<label class="label02">&nbsp;发布日期:&nbsp;</label>
<input type="text" name="" class="hwork_input02 fl" value="2015-04-03 12:00" >
<a href="javascript:void(0);" class="pic_date mt5 ml5"></a>
<div class="cl"></div>
</li>
<div class="cl"></div>
</ul><!--hwork_new_basic end--->
<div class="hwork_new_set" >
<p class="fl ml20 f14 mb10 c_orange">基本规则设置总分为100分</p>
<div class="cl"></div>
<form name="frm">
<ul class="ml10">
<li>
<label class="label02">迟交扣分:&nbsp;</label>
<select class="fl mb10 h26 w70" name="s2" >
<option >1</option>
<option selected="selected">2</option>
<option >3</option>
<option >4</option>
<option >5</option>
</select>
<span class="fl mt5">&nbsp;分</span>
<div class="cl"></div>
</li>
<li >
<label class="label02" >是否匿评:&nbsp;</label>
<input type="checkbox" name="" checked="" class="mb10 mt5 fl" id="cb" onclick="chg()">
<div class="cl"></div>
</li>
<li >
<label class="label02">评分比例:&nbsp;</label>
<select class="fl mb10 h26 w70" >
<option>0% </option>
<option>10% </option>
<option>20%</option>
<option>30%</option>
<option >40%</option>
<option>50%</option>
<option selected="selected">60%</option>
<option>70%</option>
<option>80%</option>
<option>90%</option>
<option >100%</option>
</select>
<span class="ml5 fl mt5">×&nbsp;教辅评分</span>
<span class="ml5 fl mt5">&nbsp;&nbsp;+&nbsp;&nbsp;</span>
<select class="fl mb10 h26 w70" >
<option>0% </option>
<option>10% </option>
<option>20%</option>
<option>30%</option>
<option selected="selected">40%</option>
<option>50%</option>
<option >60%</option>
<option>70%</option>
<option>80%</option>
<option>90%</option>
<option >100%</option>
</select>
<span class="ml5 fl mt5">×&nbsp;匿评得分</span>
<span class="ml5 fl mt5">=&nbsp;学生得分</span>
<div class="cl"></div>
</li>
<li >
<label class="label02" >&nbsp;&nbsp;</label>
<span class=" fl c_red">如果教师对学生作品进行了评分,则教师评分为学生最终得分。</span>
<div class="cl"></div>
</li>
</ul>
</form>
</div><!--hwork_new_set end-->
<div class="hwork_new_set" id="h1" >
<p class="fl ml20 f14 mb10 c_orange">学生互评设置</p>
<div class="cl"></div>
<ul class="ml10">
<li >
<label class="label02">互评启动时间:&nbsp;</label>
<input type="text" name="" class="hwork_input02 fl" value="2015-04-03 12:00" >
<a href="javascript:void(0);" class="pic_date mt5 ml5"></a>
<div class="cl"></div>
</li>
<li >
<label class="label02">互评结束时间:&nbsp;</label>
<input type="text" name="" class="hwork_input02 fl" value="2015-04-23 12:00" >
<a href="javascript:void(0);" class="pic_date mt5 ml5"></a>
<p class="ml5 fl mt5">互评将持续<span class="c_red">&nbsp;20&nbsp;</span>天</p>
<div class="cl"></div>
</li>
<li >
<label class="label02">匿评分配数:&nbsp;</label>
<input type="text" name="" class=" hwork_input02 fl" value="3" >
<p class="ml5 fl mt5">每个学生将收到<span class="c_red">&nbsp;3&nbsp;</span>份待匿评作品</p>
<div class="cl"></div>
</li>
<li >
<label class="label02">缺评扣分:&nbsp;</label>
<select class="fl mb10 h26 w70" >
<option >1</option>
<option selected="selected">2</option>
<option >3</option>
<option >4</option>
<option >5</option>
</select>
<span class="fl mt5">&nbsp;分</span>
<p class="ml5 fl mt5">学生漏评1个作品将扣<span class="c_red">&nbsp;2&nbsp;</span>分</p>
<div class="cl"></div>
</li>
</ul> <!-- h1 end--->
</div><!--hwork_new_set end-->
<a class="blue_btn fl mr10 " onClick="show_window();" >提交</a><a href="#" target="_blank" class="grey_btn fl ">取消</a>
<%= 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 } %>
<a class="blue_btn fl mr10 " onClick="show_window();" >提交</a>
<a href="#" target="_blank" class="grey_btn fl ">取消</a>
<% end%>
</div><!--hwork_new end-->
<div class="cl"></div>

View File

@ -17,7 +17,7 @@
<%= javascript_heads %>
<%= heads_for_theme %>
<%= call_hook :view_layouts_base_html_head %>
<%= stylesheet_link_tag 'public', 'leftside', 'courses'%>
<%= stylesheet_link_tag 'public', 'leftside', 'courses', 'jquery/jquery-ui-1.9.2'%>
<%= javascript_include_tag "course","header" %>
<!-- page specific tags -->
<%= yield :header_tags -%>

View File

@ -1218,7 +1218,7 @@ zh:
no_attachmens_allowed: 提交作业不能为空
button_bidding_homework: 参加竞标 #huang
field_homework_type: 提交形式 #bai
field_homework_type: "" #bai
label_homework_respond: 作业情况
label_bid_me: 我要应标

View File

@ -379,18 +379,18 @@ function show_bid_dead_line(year,month,day,divname)
+ "<p class='fr'>作品提交还剩:</p>");
}
//验证新建作业的名字
function regex_bid_name()
function regex_homework_name()
{
var name = $.trim($("#bid_name").val());
var name = $.trim($("#homework_name").val());
if(name=="")
{
$("#bid_name_span").text("名称不能为空");
$("#homework_name_span").text("名称不能为空");
return false;
}
else
{
$("#bid_name_span").text("");
$("#homework_name_span").text("");
return true;
}
}