This commit is contained in:
yutao 2015-07-18 15:13:13 +08:00
commit 5eb07311b7
9 changed files with 58 additions and 53 deletions

View File

@ -151,7 +151,7 @@ class HomeworkCommonController < ApplicationController
@homework.description = params[:homework_common][:description]
@homework.end_time = params[:homework_common][:end_time]
@homework.publish_time = params[:homework_common][:publish_time]
@homework.homework_type = params[:homework_common][:homework_type]
@homework.homework_type = params[:homework_common][:homework_type] if params[:homework_common][:homework_type]
unless @homework.late_penalty == params[:late_penalty]
@homework.student_works.where("created_at > '#{@homework.end_time} 23:59:59'").each do |student_work|
student_work.late_penalty = params[:late_penalty]

View File

@ -13,8 +13,9 @@ class StudentWorkController < ApplicationController
def index
@order,@b_sort,@name,@group = params[:order] || "score",params[:sort] || "desc",params[:name] || "",params[:group]
@is_teacher = User.current.allowed_to?(:as_teacher,@course)
unless @group == "0" || @group.nil?
group_students = CourseGroup.find_by_id(@group).users
course_group = CourseGroup.find_by_id(@group) if @group
if course_group
group_students = course_group.users
if group_students.empty?
student_in_group = '(0)'
else

View File

@ -2345,6 +2345,34 @@ module ApplicationHelper
#将文本内的/n转换为<br>
def text_format text
text.gsub("\n","<br/>").html_safe
text.gsub("&","&amp;").gsub("<","&lt;").gsub(">","&gt;").gsub("\n","<br/>").html_safe
end
#评分规则显示
def scoring_rules late_penalty,homework_id,is_teacher,absence_penalty=nil
if absence_penalty
if late_penalty.to_i == 0 && absence_penalty.to_i == 0
notice = "尚未设置评分规则"
if is_teacher
notice += ",请&nbsp" + link_to("设置",edit_homework_common_path(homework_id),:class => "c_green")
end
elsif late_penalty.to_i != 0 && absence_penalty.to_i == 0
notice = "迟交扣#{late_penalty}分,缺评扣分未设置"
elsif late_penalty.to_i == 0 && absence_penalty.to_i != 0
notice = "迟交扣分未设置,缺评一个作品扣#{absence_penalty}"
elsif late_penalty.to_i != 0 && absence_penalty.to_i != 0
notice = "迟交扣#{late_penalty}分,缺评一个作品扣#{absence_penalty}"
end
else
if late_penalty.to_i == 0
notice = "尚未设置评分规则"
if is_teacher
notice += ",请&nbsp" + link_to("设置",edit_homework_common_path(homework_id),:class => "c_green")
end
else
notice = "迟交扣#{late_penalty}"
end
end
notice.html_safe
end
end

View File

@ -53,31 +53,4 @@ module HomeworkCommonHelper
link
end
#评分规则显示
def scoring_rules late_penalty,homework_id,is_teacher,absence_penalty=nil
if absence_penalty
if late_penalty.to_i == 0 && absence_penalty.to_i == 0
notice = "尚未设置评分规则"
if is_teacher
notice += ",请&nbsp" + link_to("设置",edit_homework_common_path(homework_id),:class => "c_green")
end
elsif late_penalty.to_i != 0 && absence_penalty.to_i == 0
notice = "迟交扣#{late_penalty}分,缺评扣分未设置"
elsif late_penalty.to_i == 0 && absence_penalty.to_i != 0
notice = "迟交扣分未设置,缺评一个作品扣#{absence_penalty}"
elsif late_penalty.to_i != 0 && absence_penalty.to_i != 0
notice = "迟交扣#{late_penalty}分,缺评一个作品扣#{absence_penalty}"
end
else
if late_penalty.to_i == 0
notice = "尚未设置评分规则"
if is_teacher
notice += ",请&nbsp" + link_to("设置",edit_homework_common_path(homework_id),:class => "c_green")
end
else
notice = "迟交扣#{late_penalty}"
end
end
notice.html_safe
end
end

View File

@ -2,26 +2,29 @@
<% if file.is_public? || User.current.member_of_course?(course) %>
<div class="re_con_box" id="container_files_<%= file.id %>">
<div class="">
<%= link_to_attachment file, :download => true,:text => truncate(file.filename,length: 35, omission: '...'), :title => file.filename+"\n"+file.description.to_s,:class => "c_dblue f_14 f_b f_l hiddent" %>
<%= link_to truncate(file.filename,length: 35, omission: '...'),
download_named_attachment_path(file.id, file.filename),
:title => file.filename+"\n"+file.description.to_s, :style => "overflow: hidden; white-space: nowrap;text-overflow: ellipsis;",:class => "c_dblue f_14 f_b f_l" %>
<% if User.current.logged? %>
<% if (is_course_teacher(User.current,@course) || file.author_id == User.current.id) && course_contains_attachment?(@course,file) %>
<%= link_to("选入我的其他课程",quote_resource_show_course_file_path(@course,file),:class => "f_l re_select c_lorange",:remote => true) if has_course?(User.current,file) %>
<% if delete_allowed && file.container_id == @course.id && file.container_type == "Course" %>
<span id="is_public_<%= file.id %>">
<%= link_to (file.is_public? ? "公开":"私有"), update_file_dense_attachments_path(:attachmentid=>file.id,:newtype=>(file.is_public? ? 0:1)),:remote=>true,:class=>"f_l re_open c_blue",:method => :post %>
</span>
<span id="is_public_<%= file.id %>">
<%= link_to (file.is_public? ? "公开":"私有"), update_file_dense_attachments_path(:attachmentid=>file.id,:newtype=>(file.is_public? ? 0:1)),:remote=>true,:class=>"f_l re_open c_blue",:method => :post %>
</span>
<% else %>
<!-- <#%= link_to (file.is_public? ? "公开":"私有"),"javascript:void(0)",:class=>"f_l re_open" %> -->
<% end %>
<% else %>
<%= link_to("选入我的课程",quote_resource_show_course_file_path(@course,file),:class => "f_l re_select c_lorange",:remote => true) if has_course?(User.current,file) %>
<% end %>
<%= file_preview_tag(file, class: 'f_l re_open') %>
<% else %>
<% end %>
</div>
<div class="cl"></div>
<div class="">
<div class="mt5">
<p class="f_l mb5 c_grey02">文件大小:<%= number_to_human_size(file.filesize) %></p>
<%= link_to( l(:button_delete), attachment_path(file),
:data => {:confirm => l(:text_are_you_sure)}, :method => :delete,:class => "f_r re_de") if delete_allowed && file.container_id == @course.id && file.container_type == "Course"%>

View File

@ -98,7 +98,7 @@
<li>
<a class="icon_add ml10 " href="javascript:void(0);" title="添加测试" onclick="add_programing_test($(this).parent().parent())"></a>
<a class="icon_remove" href="javascript:void(0);" title="删除测试" onclick="remove_programing_test($(this).parent().parent())"></a>
<span class="green_btn fl ml5 mt1">测试</span>
<!--span class="green_btn fl ml5 mt1">测试</span-->
</li>
<div class="cl"></div>
</div>
@ -116,7 +116,7 @@
<li>
<a class="icon_add ml10 " href="javascript:void(0);" title="添加测试" onclick="add_programing_test($(this).parent().parent())"></a>
<a class="icon_remove" href="javascript:void(0);" title="删除测试" onclick="remove_programing_test($(this).parent().parent())"></a>
<span class="green_btn fl ml5 mt1">测试</span>
<!--span class="green_btn fl ml5 mt1">测试</span-->
</li>
<div class="cl"></div>
</div>

View File

@ -48,9 +48,9 @@
<%= link_to "所有作品(<span class='c_red'>#{@stundet_works.count}</span>)".html_safe,student_work_index_path(:homework => @homework.id), :class => "fl"%>
</span>
<% if @show_all%>
<input type="text" value="<%= @name%>" placeholder="昵称、学号、姓名搜索" class="min_search ml10 fl" onkeypress="SearchByName($(this).val(),$(this).next().val(),'<%= student_work_index_path(:homework => @homework.id)%>',event);">
<%= select_tag(:late_penalty,options_for_select(course_group_list(@course),@group), {:class => "fl h22 w100 ml10"}) if @is_teacher %>
<a class="student_work_search fl" onclick="SearchByName_1($(this).prev().prev().val(),$(this).prev().val(),'<%= student_work_index_path(:homework => @homework.id)%>');" href="javascript:void(0)">搜索</a>
<input type="text" id="course_student_name" value="<%= @name%>" placeholder="昵称、学号、姓名搜索" class="min_search ml10 fl" onkeypress="SearchByName('<%= student_work_index_path(:homework => @homework.id)%>',event);">
<%= select_tag(:late_penalty,options_for_select(course_group_list(@course),@group), {:class => "fl h22 w100 ml10"}) if(@is_teacher && course_group_list(@course).count > 0) %>
<a class="student_work_search fl" onclick="SearchByName_1('<%= student_work_index_path(:homework => @homework.id)%>');" href="javascript:void(0)">搜索</a>
<%= link_to("缺评情况",student_work_absence_penalty_student_work_index_path(:homework => @homework.id), :class => "student_work_search fl", :target => "_blank") if((@is_teacher || User.current.admin?) && @homework.homework_type == 1) %>
<% end%>
<% if @is_teacher%>
@ -165,15 +165,10 @@
<div class="mt5">
<span class="tit_fb" style="width: auto;"> 扣分标准:</span>
<div class="fl mb5 c_red">
迟交扣
<%= @homework.late_penalty%>
<% if @homework.homework_type == 1%>
,缺评一个作品扣
<%= @homework.homework_detail_manual.absence_penalty%>
<%= scoring_rules @homework.late_penalty,@homework.id,@is_teacher,@homework.homework_detail_manual.absence_penalty%>
<% else%>
<%= scoring_rules @homework.late_penalty,@homework.id,@is_teacher%>
<% end%>
</div>
</div>

View File

@ -6,7 +6,7 @@
<div class="recall" id='word_li_<%=reply.id.to_s%>' onmouseover="$('#<%= ids_r %>').show()" onmouseout="$('#<%= ids_r %>').hide()">
<div class="recall_head">
<% if show_name %>
<%= image_tag url_to_avatar(journal.user),:width => '30',:height => '30' %>
<%= image_tag url_to_avatar(reply.user),:width => '30',:height => '30' %>
<% else %>
<%= image_tag url_to_avatar(nil),:width => '30',:height => '30' %>
<% end %>

View File

@ -861,14 +861,19 @@ function clickOK(path)
});
}
//查询
function SearchByName(name,group,url,event)
function SearchByName(url,event)
{
var keycode = (event.keyCode ? event.keyCode : event.which);
if(keycode == '13'){
location.href = url + "&name=" + name + "&group=" + group;
location.href = url + "&name=" + $("#course_student_name").val() + "&group=" + $("#late_penalty").val();
}
}
function SearchByName_1(name,group,url)
function SearchByName_1(url)
{
location.href = url + "&name=" + name + "&group=" + group;
if($("#late_penalty").val() == null){
location.href = url + "&name=" + $("#course_student_name").val()
}
else{
location.href = url + "&name=" + $("#course_student_name").val() + "&group=" + $("#late_penalty").val();
}
}