Merge branch 'szzh' of http://repository.trustie.net/xianbo/trustie2 into szzh
This commit is contained in:
commit
a764888055
|
@ -1,4 +1,5 @@
|
||||||
class HomeworkAttachController < ApplicationController
|
class HomeworkAttachController < ApplicationController
|
||||||
|
include CoursesHelper
|
||||||
###############################
|
###############################
|
||||||
#判断当前角色权限时需先找到当前操作的project
|
#判断当前角色权限时需先找到当前操作的project
|
||||||
before_filter :find_project_by_bid_id, :only => [:new]
|
before_filter :find_project_by_bid_id, :only => [:new]
|
||||||
|
@ -241,6 +242,9 @@ class HomeworkAttachController < ApplicationController
|
||||||
@offset ||= @feedback_pages.offset
|
@offset ||= @feedback_pages.offset
|
||||||
@jour = @jours[@offset, @limit]
|
@jour = @jours[@offset, @limit]
|
||||||
@comprehensive_evaluation = @homework.journals_for_messages.where("is_comprehensive_evaluation is not null").order("created_on DESC")
|
@comprehensive_evaluation = @homework.journals_for_messages.where("is_comprehensive_evaluation is not null").order("created_on DESC")
|
||||||
|
|
||||||
|
@totle_score = score_for_homework @homework
|
||||||
|
@teaher_score = teacher_score_for_homework @homework
|
||||||
else
|
else
|
||||||
render_403 :message => :notice_not_authorized
|
render_403 :message => :notice_not_authorized
|
||||||
end
|
end
|
||||||
|
|
|
@ -182,4 +182,28 @@ module CoursesHelper
|
||||||
def users_for_homework homework
|
def users_for_homework homework
|
||||||
homework.nil? ? [] : (homework.users + [homework.user])
|
homework.nil? ? [] : (homework.users + [homework.user])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
#获取指定作业的最终评分
|
||||||
|
#最终评分 = 学生评分的平均分 * 0.4 +教师评分 * 0.6
|
||||||
|
def score_for_homework homework
|
||||||
|
return format("%.2f",(teacher_score_for_homework(homework).to_f * 0.6 + student_score_for_homework(homework).to_f * 0.4))
|
||||||
|
end
|
||||||
|
|
||||||
|
#获取作业的互评得分
|
||||||
|
def student_score_for_homework homework
|
||||||
|
member = searchPeopleByRoles(homework.bid.courses.first,TeacherRoles).first
|
||||||
|
student_stars = homework.rates(:quality).where("rater_id <> #{member.user_id}").select("stars")
|
||||||
|
student_stars_count = 0
|
||||||
|
student_stars.each do |star|
|
||||||
|
student_stars_count = student_stars_count + star.stars
|
||||||
|
end
|
||||||
|
return format("%.2f",student_stars_count / (student_stars.count == 0 ? 1 : student_stars.count))
|
||||||
|
end
|
||||||
|
|
||||||
|
#获取作业的教师评分
|
||||||
|
def teacher_score_for_homework homework
|
||||||
|
member = searchPeopleByRoles(homework.bid.courses.first,TeacherRoles).first
|
||||||
|
teacher_stars = homework.rates(:quality).where("rater_id = #{member.user_id}").select("stars").first
|
||||||
|
return format("%.2f",teacher_stars == nil ? 0 : teacher_stars.stars)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -0,0 +1,8 @@
|
||||||
|
<% for attachment in attachments %>
|
||||||
|
<%= link_to_attachment attachment, :class => 'icon icon-attachment', :download => true -%>
|
||||||
|
<% if attachment.is_text? %>
|
||||||
|
<%= link_to image_tag('magnifier.png'),
|
||||||
|
:controller => 'attachments', :action => 'show',
|
||||||
|
:id => attachment, :filename => attachment.filename %>
|
||||||
|
<% end %>
|
||||||
|
<% end -%>
|
|
@ -28,75 +28,122 @@
|
||||||
<% @homework_list.each do |homework|%>
|
<% @homework_list.each do |homework|%>
|
||||||
<table width="660px" border="0" align="center" id="homework_attach_<%= homework.id %>" >
|
<table width="660px" border="0" align="center" id="homework_attach_<%= homework.id %>" >
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="2" valign="top" width="50" ><%= image_tag(url_to_avatar(homework.user), :class => "avatar")%></td>
|
<td style="vertical-align: top;width: 70px" >
|
||||||
<td>
|
<table style="text-align: center;width: 100%;table-layout: fixed">
|
||||||
<table width="580px" border="0">
|
<tr>
|
||||||
|
<td title="<%= homework.user.name %>"><%= image_tag(url_to_avatar(homework.user), :class => "avatar")%></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td title="<%= homework.user.name %>">
|
||||||
|
<p style="width: 100%;white-space: nowrap;overflow: hidden;text-overflow: ellipsis;"><strong>
|
||||||
|
<%= link_to (is_teacher ? homework.user.realname : homework.user ), user_path(homework.user)%>
|
||||||
|
</strong></p>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<% if (users_for_homework(homework).include?(User.current) || is_teacher) %>
|
||||||
|
<%= link_to l(:button_edit), edit_homework_attach_path(homework) %>
|
||||||
|
<% if homework.user == User.current || is_teacher %>
|
||||||
|
<%= link_to(l(:label_bid_respond_delete), homework,
|
||||||
|
method: :delete, :confirm => l(:text_are_you_sure)) %>
|
||||||
|
<% end %>
|
||||||
|
<% end %>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
<span></span>
|
||||||
|
</td>
|
||||||
|
<td colspan="2">
|
||||||
|
<table width="580px" border="0" style="table-layout: fixed">
|
||||||
<tr>
|
<tr>
|
||||||
<td style="width: 300px;">
|
<td style="width: 300px;">
|
||||||
<strong>作业 :</strong>
|
<strong>作业名称:</strong>
|
||||||
<% if homework.name == nil || homework.name == "" %>
|
<% if homework.name == nil || homework.name == "" %>
|
||||||
<% attachments = homework.attachments.map %>
|
<% homework_filename = homework.user.name + "提交的作业" %>
|
||||||
<% for attachment in attachments %>
|
|
||||||
<% if attachments.count > 1 %>
|
|
||||||
<% homework_filename = attachment.filename + "等" + attachments.count.to_s + "个文件" %>
|
|
||||||
<% else %>
|
|
||||||
<% homework_filename = attachment.filename %>
|
|
||||||
<% end %>
|
|
||||||
<% end %>
|
|
||||||
<% else %>
|
<% else %>
|
||||||
<% homework_filename = homework.name %>
|
<% homework_filename = homework.name %>
|
||||||
<% end %>
|
<% end %>
|
||||||
<strong>
|
<strong>
|
||||||
<% if is_evaluation || is_teacher%>
|
<%= link_to homework_filename , homework_attach_path(homework)%>
|
||||||
<%= link_to homework_filename, :controller => "zipdown", :action => "download_user_homework",:homework => homework%>
|
|
||||||
<% else %>
|
|
||||||
<%= homework_filename %>
|
|
||||||
<% end %>
|
|
||||||
</strong>
|
</strong>
|
||||||
</td>
|
</td>
|
||||||
<td style="vertical-align: top">
|
<td style="vertical-align: top;width: 200px;white-space: nowrap;overflow: hidden;text-overflow: ellipsis;">
|
||||||
<% if is_student %>
|
<strong>参与人员: </strong>
|
||||||
<% if is_evaluation %>
|
<% homework_users = "" %>
|
||||||
<%= link_to "互评>>" , homework_attach_path(homework)%>
|
<% homework.users.each do |user| %>
|
||||||
<% else %>
|
<% homework_users = homework_users + (is_teacher ? user.realname : user.name) %>
|
||||||
<%= link_to "查看详细" , homework_attach_path(homework)%>
|
<% if user != homework.users.last %>
|
||||||
<% end %>
|
<% homework_users = homework_users + "、" %>
|
||||||
<% else %>
|
<% end %>
|
||||||
<% if is_teacher %>
|
<% end %>
|
||||||
<%= link_to "综评>>" , homework_attach_path(homework)%>
|
<% if homework.users.count == 0 %>
|
||||||
<% end %>
|
无
|
||||||
|
<% else %>
|
||||||
|
<span title="<%= homework_users%>"><%= homework_users %></span>
|
||||||
|
<% end %>
|
||||||
|
</td>
|
||||||
|
<td rowspan="4" style="text-align: center;vertical-align: middle;width: 30px">
|
||||||
|
<% if Time.parse(@bid.deadline.to_s) < Time.parse(homework.created_at.to_s) %>
|
||||||
|
<span class="required">迟交</span>
|
||||||
<% end %>
|
<% end %>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
|
||||||
<td colspan="1" valign="top" style="width: 300px">
|
|
||||||
<strong>发布人: <%= link_to ( is_teacher ? homework.user.realname : homework.user ), user_path(homework.user)%></strong>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<strong>作业评分:</strong>
|
|
||||||
|
|
||||||
<%= format("%.2f", homework.rate_averages.first.try(:avg).to_f ) %>
|
<tr>
|
||||||
</td>
|
<td>
|
||||||
<td valign="top" align="right">
|
<strong>开发项目:</strong>
|
||||||
<% if Time.parse(@bid.deadline.to_s) < Time.parse(homework.created_at.to_s) %>
|
<% if homework.project != nil %>
|
||||||
<span class="required">迟交</span>
|
<%= link_to homework.project.name,project_path(homework.project.id)%>
|
||||||
<% end %>
|
<% else %>
|
||||||
</td>
|
该作业暂无项目
|
||||||
</tr>
|
<% end %>
|
||||||
<tr>
|
</td>
|
||||||
<td valign="top">
|
<td>
|
||||||
<% if User.current.member_of?(@bid.courses.first) %>
|
<strong>项目得分:</strong>
|
||||||
<strong><%= l(:label_bidding_user_studentcode) %> : <%= homework.user.student_id%></strong>
|
<span class="required">
|
||||||
|
<% if homework.project != nil %>
|
||||||
|
0分
|
||||||
|
<% else %>
|
||||||
|
0分
|
||||||
<% end %>
|
<% end %>
|
||||||
</td>
|
</span>
|
||||||
<td>
|
</td>
|
||||||
<% if (users_for_homework(homework).include?(User.current) || is_teacher) %>
|
</tr>
|
||||||
<%= link_to l(:button_edit), edit_homework_attach_path(homework) %>
|
|
||||||
<% if homework.user == User.current || is_teacher %>
|
<tr>
|
||||||
<%= link_to(l(:label_bid_respond_delete), homework,
|
<td>
|
||||||
method: :delete, :confirm => l(:text_are_you_sure)) %>
|
<strong>提交文件:
|
||||||
<% end %>
|
<% if is_evaluation %>
|
||||||
|
<%= link_to "打包下载", :controller => "zipdown", :action => "download_user_homework",:homework => homework%>
|
||||||
|
<% else %>
|
||||||
|
<span class="required">未开启互评功能作业不允许下载</span>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
</strong>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<strong>互评得分:
|
||||||
|
<span class="required"><%= student_score_for_homework(homework) %>分</span>
|
||||||
|
<% if is_evaluation && is_student && (!users_for_homework(homework).include? User.current)%>
|
||||||
|
<%= link_to "学生互评>>",homework_attach_path(homework) %>
|
||||||
|
<% end %>
|
||||||
|
</strong>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td style="vertical-align: top;width: 200px;white-space: nowrap;overflow: hidden;text-overflow: ellipsis;">
|
||||||
|
<% if is_evaluation %>
|
||||||
|
<%= render :partial => 'app_link', :locals => {:attachments => homework.attachments} %>
|
||||||
|
<% end %>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<strong>综评得分:
|
||||||
|
<span class="required"><%= score_for_homework homework %>分</span>
|
||||||
|
<% if is_teacher %>
|
||||||
|
<%= link_to "教师评分>>",homework_attach_path(homework) %>
|
||||||
|
<% end %>
|
||||||
|
</strong>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
|
|
@ -1,23 +1,9 @@
|
||||||
<% is_teacher = is_course_teacher User.current,homework.bid.courses.first %>
|
<% is_teacher = is_course_teacher User.current,homework.bid.courses.first %>
|
||||||
<% if comprehensive_evaluation != nil && comprehensive_evaluation.count > 0 %>
|
<% if comprehensive_evaluation != nil && comprehensive_evaluation.count > 0 %>
|
||||||
<% stars = homework.rates(:quality).where("rater_id = #{comprehensive_evaluation.first.user.id}").select("stars").first %>
|
|
||||||
<div style="height: 100px; padding-bottom: 10px">
|
<div style="height: 100px; padding-bottom: 10px">
|
||||||
<div style="font-size: 15px">
|
<div style="font-size: 15px">
|
||||||
<strong>作业综评:</strong>
|
<strong>作业综评:</strong>
|
||||||
<span class="user" style="font-size: 15px">
|
<%= render :partial => 'show_score', locals: {:stars => teaher_score} %>
|
||||||
<div data-kls="HomeworkAttach" data-id="2" data-dimension="quality" data-average="3.25" class="rateable div_inline jDisabled"
|
|
||||||
style="height: 15px; width: 100px; overflow: hidden; z-index: 1; position: relative;">
|
|
||||||
<% if stars != nil %>
|
|
||||||
<div class="jRatingColor" style="width: <%=stars.stars * 2 * 10 %>%;"></div>
|
|
||||||
<% else %>
|
|
||||||
<div class="jRatingColor" style="width: 0px;"></div>
|
|
||||||
<% end %>
|
|
||||||
<div class="jRatingAverage" style="width: 0px; top: -20px;"></div>
|
|
||||||
<div class="jStar" style="width: 115px; height: 20px; top: -40px;
|
|
||||||
background: url('/images/seems_rateable/stars.png') repeat-x scroll 0% 0% transparent;">
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</span>
|
|
||||||
</div>
|
</div>
|
||||||
<div style="font-size: 14px;">
|
<div style="font-size: 14px;">
|
||||||
<div style="margin-left: 20px;margin-bottom: 10px;margin-top: 10px;"> <%= comprehensive_evaluation.first.notes%> </div>
|
<div style="margin-left: 20px;margin-bottom: 10px;margin-top: 10px;"> <%= comprehensive_evaluation.first.notes%> </div>
|
||||||
|
|
|
@ -0,0 +1,14 @@
|
||||||
|
<span class="user" style="font-size: 15px">
|
||||||
|
<div data-kls="HomeworkAttach" data-id="2" data-dimension="quality" data-average="3.25" class="rateable div_inline jDisabled"
|
||||||
|
style="height: 15px; width: 100px; overflow: hidden; z-index: 1; position: relative;">
|
||||||
|
<% if stars != nil %>
|
||||||
|
<div class="jRatingColor" style="width: <%=stars.to_f * 20 %>%;"></div>
|
||||||
|
<% else %>
|
||||||
|
<div class="jRatingColor" style="width: 0px;"></div>
|
||||||
|
<% end %>
|
||||||
|
<div class="jRatingAverage" style="width: 0px; top: -20px;"></div>
|
||||||
|
<div class="jStar" style="width: 115px; height: 20px; top: -40px;
|
||||||
|
background: url('/images/seems_rateable/stars.png') repeat-x scroll 0% 0% transparent;">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</span>
|
|
@ -23,7 +23,7 @@
|
||||||
:bid_id => @bid
|
:bid_id => @bid
|
||||||
}) do |f|%>
|
}) do |f|%>
|
||||||
<p style=" padding: 3px 0 3px 0;padding-left: 50px; clear:left;">
|
<p style=" padding: 3px 0 3px 0;padding-left: 50px; clear:left;">
|
||||||
<strong>标 题:</strong>
|
<strong>标 题:</strong>
|
||||||
<%= f.text_field "name", :required => true, :size => 60, :style => "width:490px;" %>
|
<%= f.text_field "name", :required => true, :size => 60, :style => "width:490px;" %>
|
||||||
</p>
|
</p>
|
||||||
<p style=" padding: 3px 0 3px 0;padding-left: 50px; clear:left;">
|
<p style=" padding: 3px 0 3px 0;padding-left: 50px; clear:left;">
|
||||||
|
@ -33,7 +33,7 @@
|
||||||
<p class="font_lighter" style="padding-left:120px;clear:left;">提交项目可以为空</p>
|
<p class="font_lighter" style="padding-left:120px;clear:left;">提交项目可以为空</p>
|
||||||
</p>
|
</p>
|
||||||
<p style=" padding: 3px 0 3px 0;padding-left: 50px; clear:left;">
|
<p style=" padding: 3px 0 3px 0;padding-left: 50px; clear:left;">
|
||||||
<strong style="vertical-align: top">描 述:</strong>
|
<strong style="vertical-align: top">描 述:</strong>
|
||||||
<span style="margin-left:-10px;padding-right: 20px;">
|
<span style="margin-left:-10px;padding-right: 20px;">
|
||||||
<%= f.text_area "description", :rows => 8, :class => 'wiki-edit', :style => "font-size:small;width:490px;margin-left:10px;" %>
|
<%= f.text_area "description", :rows => 8, :class => 'wiki-edit', :style => "font-size:small;width:490px;margin-left:10px;" %>
|
||||||
</span>
|
</span>
|
||||||
|
|
|
@ -49,7 +49,7 @@
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td style=" padding-left: 40px">平均评分:
|
<td style=" padding-left: 40px">平均评分:
|
||||||
<%= rating_for @homework, :static => true, dimension: :quality, class: 'rateable div_inline' %>
|
<%= render :partial => 'show_score', :locals => {:stars => @totle_score} %>
|
||||||
</td>
|
</td>
|
||||||
<td style="width: 240px; word-wrap: break-word; word-break: break-all">发布时间:<%=format_time @homework.created_at %></td>
|
<td style="width: 240px; word-wrap: break-word; word-break: break-all">发布时间:<%=format_time @homework.created_at %></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
@ -110,17 +110,12 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div style="float: left; padding-left: 100px; padding-top:35px ">
|
<div style="float: left; padding-left: 100px; padding-top:35px ">
|
||||||
<% score = @homework.average(:quality).try(:avg).try(:round, 2).to_s %>
|
|
||||||
<div style="text-align: center">最终得分</div>
|
<div style="text-align: center">最终得分</div>
|
||||||
<div style="padding-top: 1px; font-size: 15px; color: blue;text-align: center">
|
<div style="padding-top: 1px; font-size: 15px; color: blue;text-align: center">
|
||||||
<% if score == "" %>
|
<%= @totle_score %>分
|
||||||
0分
|
|
||||||
<% else %>
|
|
||||||
<%= score %>分
|
|
||||||
<% end %>
|
|
||||||
</div>
|
</div>
|
||||||
<div style="padding-top: 3px">
|
<div style="padding-top: 3px">
|
||||||
<%= rating_for @homework, :static => true, dimension: :quality, class: 'rateable div_inline' %>
|
<%= render :partial => 'show_score', :locals => {:stars => @totle_score} %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div style="float: left; padding-left: 100px; padding-top:35px ">
|
<div style="float: left; padding-left: 100px; padding-top:35px ">
|
||||||
|
@ -137,7 +132,7 @@
|
||||||
|
|
||||||
<!-- 作业综评 -->
|
<!-- 作业综评 -->
|
||||||
<div id="comprehensive_evaluation">
|
<div id="comprehensive_evaluation">
|
||||||
<%= render :partial => 'comprehensive_evaluation', :locals => {:comprehensive_evaluation => @comprehensive_evaluation,:homework => @homework} %>
|
<%= render :partial => 'comprehensive_evaluation', :locals => {:comprehensive_evaluation => @comprehensive_evaluation,:homework => @homework, :teaher_score => @teaher_score} %>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="underline-contests_one"></div>
|
<div class="underline-contests_one"></div>
|
||||||
|
|
Loading…
Reference in New Issue