From 65c3bb5eb151e922be882931cd30457061a11657 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Thu, 22 May 2014 16:37:39 +0800 Subject: [PATCH] =?UTF-8?q?1.=E4=BD=9C=E4=B8=9A=E5=88=97=E8=A1=A8=E8=AF=84?= =?UTF-8?q?=E5=88=86=E7=BB=93=E6=9E=9C=E6=98=BE=E7=A4=BA=E4=BF=9D=E7=95=99?= =?UTF-8?q?2=E4=BD=8D=E6=9C=89=E6=95=88=E6=95=B0=E5=AD=97=202.=E4=BA=92?= =?UTF-8?q?=E8=AF=84=E7=95=8C=E9=9D=A2=E6=98=BE=E7=A4=BA=E6=9C=80=E7=BB=88?= =?UTF-8?q?=E8=AF=84=E5=88=86=E6=95=B0=E5=80=BC=203.=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E4=BA=92=E8=AF=84=E6=8C=89=E9=92=AE=EF=BC=8C=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E6=9F=A5=E7=9C=8B=E5=AD=A6=E5=8F=B7=E3=80=81=E6=8C=89=E5=AD=A6?= =?UTF-8?q?=E5=8F=B7=E6=8E=92=E5=BA=8F=E7=AD=89=E5=8A=9F=E8=83=BD=E7=9A=84?= =?UTF-8?q?=E6=9D=A1=E4=BB=B6=204.=E4=BF=AE=E6=94=B9=E4=BA=92=E8=AF=84?= =?UTF-8?q?=E7=95=8C=E9=9D=A2=E4=BD=9C=E4=B8=9A=E4=B8=8B=E8=BD=BD=E4=BF=A1?= =?UTF-8?q?=E6=81=AF=E6=98=BE=E7=A4=BA=EF=BC=8C=E5=8F=96=E6=B6=88=E6=8F=8F?= =?UTF-8?q?=E8=BF=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/helpers/courses_helper.rb | 11 ++++ app/models/homework_user.rb | 2 +- app/models/user.rb | 2 +- app/views/bids/_homework_list.html.erb | 56 ++++++++++++-------- app/views/homework_attach/_app_link.html.erb | 12 +++++ app/views/homework_attach/show.html.erb | 41 ++++++++++---- 6 files changed, 91 insertions(+), 33 deletions(-) create mode 100644 app/views/homework_attach/_app_link.html.erb 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 %>
<%= l(:label_task_plural)%>(<%= @homework_list.count%>) |
- <%= text_field_tag 'student_id', params[:student_id], :size => 30 %>
- <%= submit_tag l(:label_search_by_student_id), :class => "small", :name => nil %>
+ <% if is_teacher %>
+ <%= text_field_tag 'student_id', params[:student_id], :size => 30 %>
+ <%= submit_tag l(:label_search_by_student_id), :class => "small", :name => nil %>
+ <% end %>
|
+ 作业 :
+ <% 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 %> |
作业描述: |
+ 作业描述: |