diff --git a/app/helpers/courses_helper.rb b/app/helpers/courses_helper.rb index 97cca617e..45ebaf247 100644 --- a/app/helpers/courses_helper.rb +++ b/app/helpers/courses_helper.rb @@ -136,4 +136,15 @@ module CoursesHelper def find_by_extra_from_project extra Course.find_by_extra(try(extra)) end + #判断制定用户是不是当前课程的老师 + def is_course_teacher user,project + is_teacher = false + searchTeacherAndAssistant(project).each do |teacher| + if user == teacher + is_teacher = true + break + end + end + is_teacher + end end diff --git a/app/models/homework_user.rb b/app/models/homework_user.rb index da7e65afb..0adef62c4 100644 --- a/app/models/homework_user.rb +++ b/app/models/homework_user.rb @@ -2,5 +2,5 @@ class HomeworkUser < ActiveRecord::Base attr_accessible :homework_attach_id, :user_id belongs_to :homework_attach - has_one :user + belongs_to :user end diff --git a/app/models/user.rb b/app/models/user.rb index 8017ed5f8..c96e38595 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -73,7 +73,7 @@ class User < Principal ['none', :label_user_mail_option_none] ] - has_one :homework_user + belongs_to :homework_user has_and_belongs_to_many :groups, :after_add => Proc.new {|user, group| group.user_added(user)}, :after_remove => Proc.new {|user, group| group.user_removed(user)} diff --git a/app/views/bids/_homework_list.html.erb b/app/views/bids/_homework_list.html.erb index 35c414699..d720429fb 100644 --- a/app/views/bids/_homework_list.html.erb +++ b/app/views/bids/_homework_list.html.erb @@ -1,4 +1,5 @@ +<% is_teacher = is_course_teacher User.current,@bid.courses.first.project %> <%= form_tag(:controller => 'bids', :action => "show_project", :method => :get) do %>
@@ -6,8 +7,10 @@
<%= l(:label_task_plural)%>(<%= @homework_list.count%>)
@@ -25,16 +28,25 @@ <%= image_tag(url_to_avatar(homework.user), :class => "avatar")%> -    作业   :  - <% filename = "" %> - <% homework.attachments.map do |attachment| %> - <% filename = attachment.filename %> - <% if homework.attachments.count > 1%> - <% filename += "等#{homework.attachments.count}个文件" %> + + +
+   作业   :  + <% attachments = homework.attachments.map %> + <% for attachment in attachments %> + <% if attachments.count > 1 && attachment != attachments.first %> +
+ <% for item in 1..7 %> +   + <% end %> + <% end %> + <%= link_to_attachment attachment , :download => true -%> <% end %> - <% break %> - <% end %> - <%= link_to filename , homework_attach_path(homework)%> +
+ <% if display_id %> + <%= link_to "互评>>" , homework_attach_path(homework)%> + <% end %> +
  @@ -48,7 +60,7 @@ <% sum = sum + star_reates.stars %> <% end %> <% stars_reates_count = stars_reates.count == 0 ? 1 : stars_reates.count %> - <%= sum * 1.0 / stars_reates_count %> + <%= format("%.2f", sum * 1.0 / stars_reates_count) %> <% if Time.parse(@bid.deadline.to_s) < Time.parse(homework.attachments[0].created_on.to_s) %> @@ -58,20 +70,20 @@
  - <% if display_id %> - <%= l(:label_bidding_user_studentcode) %>  : <%= homework.user.user_extensions.student_id%> - <% end %> + <% if display_id %> + <%= l(:label_bidding_user_studentcode) %>  : <%= homework.user.user_extensions.student_id%> + <% end %>
- <% if (User.current == homework.user) || (!Member.where('user_id = ? and project_id = ?', User.current.id, @bid.courses.first.id).first.nil? && (Member.where('user_id = ? and project_id = ?', User.current.id, @bid.courses.first.id).first.roles&Role.where('id = ? or id = ? or id =?',3,7, 9)).size >0) %> -

- <% options = {:author => true, :deletable => attach_delete(homework)} %> - <%= render :partial => 'attachments/links', - :locals => {:attachments => homework.attachments, :options => options} %> -

- <% end %> + <% if (User.current == homework.user) || (!Member.where('user_id = ? and project_id = ?', User.current.id, @bid.courses.first.id).first.nil? && (Member.where('user_id = ? and project_id = ?', User.current.id, @bid.courses.first.id).first.roles&Role.where('id = ? or id = ? or id =?',3,7, 9)).size >0) %> +

+ <% options = {:author => true, :deletable => attach_delete(homework)} %> + <%= render :partial => 'attachments/links', + :locals => {:attachments => homework.attachments, :options => options} %> +

+ <% end %>
diff --git a/app/views/homework_attach/_app_link.html.erb b/app/views/homework_attach/_app_link.html.erb new file mode 100644 index 000000000..8adf5220e --- /dev/null +++ b/app/views/homework_attach/_app_link.html.erb @@ -0,0 +1,12 @@ + +<% for attachment in attachments %> + <% if attachments.count > 1 && attachment != attachments.first%> +
                 + <% end %> + <%= 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 -%> diff --git a/app/views/homework_attach/show.html.erb b/app/views/homework_attach/show.html.erb index 1400176c2..d7c1e8eb0 100644 --- a/app/views/homework_attach/show.html.erb +++ b/app/views/homework_attach/show.html.erb @@ -18,7 +18,9 @@ 作业基础信息<%=@count %> - 发布人员:<%= link_to @homework.user, user_path(@homework.user)%> + + 发布人员:<%= link_to @homework.user, user_path(@homework.user)%> + 发布时间:<%=format_time @homework.created_at %> @@ -26,9 +28,11 @@ 作业下载: <% options = {:author => true } %> - <%= render :partial => 'attachments/app_link', :locals => {:attachments => @homework.attachments, :options => options} %> + <%= render :partial => 'app_link', :locals => {:attachments => @homework.attachments, :options => options} %> + + + 所属任务:<%= link_to(@homework.bid.name, project_for_bid_path(@homework.bid))%> - 所属任务:<%= link_to(@homework.bid.name, project_for_bid_path(@homework.bid))%> @@ -49,7 +53,7 @@ - + <% @homework.attachments.map do |attachment| %> <% if attachment.description != nil && attachment.description != "" %> @@ -67,16 +71,20 @@
-
作业得分:
+
+ 作业得分: +
得分比例
<% 100.step(20,-20) do |star| %> -
+
-
+
<%= @stars_status_map["star#{(star/20).to_s}".to_sym] %> @@ -85,7 +93,11 @@
-
最终得分
+
最终得分
+
+ <%= @homework.average(:quality).try(:avg).try(:round, 2).to_s %> + 分 +
<%= rating_for @homework, :static => true, dimension: :quality, class: 'rateable div_inline' %>
@@ -102,6 +114,18 @@
+ +
作业评论:
评分: @@ -121,5 +145,4 @@ <%= render :partial => 'showjour', :locals => {:jour => @jours} %>
-<%#= link_to '返回竞赛页面', show_softapplication_contest_path(@softapplication.contest) %>
作业描述:
作业描述: