From 71bb76ff916a29cf839e2c6277a32c83cd725c18 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Thu, 19 Jun 2014 13:51:39 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E4=BD=9C=E4=B8=9A=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=E7=95=8C=E9=9D=A2=E9=A1=B5=E9=9D=A2=E6=94=B9=E9=80=A0=EF=BC=8C?= =?UTF-8?q?=E5=AE=9E=E7=8E=B0=E6=96=B0=E7=9A=84=E9=A1=B5=E9=9D=A2=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=E6=95=88=E6=9E=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/bids/_homework_list.html.erb | 138 +++++++++++++++---------- 1 file changed, 84 insertions(+), 54 deletions(-) diff --git a/app/views/bids/_homework_list.html.erb b/app/views/bids/_homework_list.html.erb index c49013cb..14d18216 100644 --- a/app/views/bids/_homework_list.html.erb +++ b/app/views/bids/_homework_list.html.erb @@ -28,75 +28,105 @@ <% @homework_list.each do |homework|%> - - @@ -110,17 +110,12 @@
- <% score = @homework.average(:quality).try(:avg).try(:round, 2).to_s %>
最终得分
- <% if score == "" %> - 0分 - <% else %> - <%= score %>分 - <% end %> + <%= @totle_score %>分
- <%= rating_for @homework, :static => true, dimension: :quality, class: 'rateable div_inline' %> + <%= render :partial => 'show_score', :locals => {:stars => @totle_score} %>
@@ -137,7 +132,7 @@
- <%= 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} %>
From 4d06d263035c0528e0eb23c85960f1f268a0ec69 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Thu, 19 Jun 2014 15:58:49 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=96=B0=E5=BB=BA?= =?UTF-8?q?=E4=BD=9C=E4=B8=9A=E9=A1=B5=E9=9D=A2=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/homework_attach/new.html.erb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/homework_attach/new.html.erb b/app/views/homework_attach/new.html.erb index c74d17bd..46ab0ce8 100644 --- a/app/views/homework_attach/new.html.erb +++ b/app/views/homework_attach/new.html.erb @@ -23,7 +23,7 @@ :bid_id => @bid }) do |f|%>

- 标 题: + 标      题: <%= f.text_field "name", :required => true, :size => 60, :style => "width:490px;" %>

@@ -33,7 +33,7 @@

提交项目可以为空

- 描 述: + 描      述: <%= f.text_area "description", :rows => 8, :class => 'wiki-edit', :style => "font-size:small;width:490px;margin-left:10px;" %>

<%= image_tag(url_to_avatar(homework.user), :class => "avatar")%> - + + @@ -125,7 +128,7 @@ From ef234d8c50d3813971b7a291e5268c846853f425 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Thu, 19 Jun 2014 15:55:42 +0800 Subject: [PATCH 3/4] =?UTF-8?q?1.=E6=8C=89=E7=85=A7=E6=96=B0=E7=9A=84?= =?UTF-8?q?=E8=AF=84=E5=88=86=E8=A7=84=E5=88=99=E4=BF=AE=E6=94=B9=E4=BD=9C?= =?UTF-8?q?=E4=B8=9A=E5=BE=97=E5=88=86=202.=E4=BF=AE=E6=94=B9=E4=BD=9C?= =?UTF-8?q?=E4=B8=9A=E5=88=97=E8=A1=A8=E6=98=BE=E7=A4=BA=E7=95=8C=E9=9D=A2?= =?UTF-8?q?=203.=E5=A2=9E=E5=8A=A0=E8=8E=B7=E5=8F=96=E4=BD=9C=E4=B8=9A?= =?UTF-8?q?=E7=9A=84=E4=BA=92=E8=AF=84=E5=BE=97=E5=88=86=E3=80=81=E6=95=99?= =?UTF-8?q?=E5=B8=88=E8=AF=84=E5=88=86=E3=80=81=E6=9C=80=E7=BB=88=E8=AF=84?= =?UTF-8?q?=E5=88=86=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/homework_attach_controller.rb | 4 ++ app/helpers/courses_helper.rb | 24 +++++++++++ app/views/bids/_app_link.html.erb | 8 ++++ app/views/bids/_homework_list.html.erb | 40 +++++++++++++------ .../_comprehensive_evaluation.html.erb | 16 +------- .../homework_attach/_show_score.html.erb | 14 +++++++ app/views/homework_attach/show.html.erb | 13 ++---- 7 files changed, 82 insertions(+), 37 deletions(-) create mode 100644 app/views/bids/_app_link.html.erb create mode 100644 app/views/homework_attach/_show_score.html.erb diff --git a/app/controllers/homework_attach_controller.rb b/app/controllers/homework_attach_controller.rb index 652025fc..20ae4c54 100644 --- a/app/controllers/homework_attach_controller.rb +++ b/app/controllers/homework_attach_controller.rb @@ -1,4 +1,5 @@ class HomeworkAttachController < ApplicationController + include CoursesHelper ############################### #判断当前角色权限时需先找到当前操作的project before_filter :find_project_by_bid_id, :only => [:new] @@ -241,6 +242,9 @@ class HomeworkAttachController < ApplicationController @offset ||= @feedback_pages.offset @jour = @jours[@offset, @limit] @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 render_403 :message => :notice_not_authorized end diff --git a/app/helpers/courses_helper.rb b/app/helpers/courses_helper.rb index 0602e52d..96ea4e28 100644 --- a/app/helpers/courses_helper.rb +++ b/app/helpers/courses_helper.rb @@ -182,4 +182,28 @@ module CoursesHelper def users_for_homework homework homework.nil? ? [] : (homework.users + [homework.user]) 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 diff --git a/app/views/bids/_app_link.html.erb b/app/views/bids/_app_link.html.erb new file mode 100644 index 00000000..645fe94f --- /dev/null +++ b/app/views/bids/_app_link.html.erb @@ -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 -%> \ No newline at end of file diff --git a/app/views/bids/_homework_list.html.erb b/app/views/bids/_homework_list.html.erb index 42d6460a..e1ca9e0f 100644 --- a/app/views/bids/_homework_list.html.erb +++ b/app/views/bids/_homework_list.html.erb @@ -72,7 +72,7 @@ 参与人员:  <% homework_users = "" %> <% homework.users.each do |user| %> - <% homework_users = homework_users + user.name %> + <% homework_users = homework_users + (is_teacher ? user.realname : user.name) %> <% if user != homework.users.last %> <% homework_users = homework_users + "、" %> <% end %> @@ -101,35 +101,49 @@ -
+ + + + + + + + + + +
<%= image_tag(url_to_avatar(homework.user), :class => "avatar")%>
+

+ <%= link_to (is_teacher ? homework.user.realname : homework.user ), user_path(homework.user)%> +

+
+ <% 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 %> +
+ +
+ - + - - - - - + + + + + + + + + + - +
-   作业   :  + 作业名称:  <% if homework.name == nil || homework.name == "" %> - <% attachments = homework.attachments.map %> - <% for attachment in attachments %> - <% if attachments.count > 1 %> - <% homework_filename = attachment.filename + "等" + attachments.count.to_s + "个文件" %> - <% else %> - <% homework_filename = attachment.filename %> - <% end %> - <% end %> + <% homework_filename = homework.user.name + "提交的作业" %> <% else %> <% homework_filename = homework.name %> <% end %> - <% if is_evaluation || is_teacher%> - <%= link_to homework_filename, :controller => "zipdown", :action => "download_user_homework",:homework => homework%> - <% else %> - <%= homework_filename %> - <% end %> + <%= link_to homework_filename , homework_attach_path(homework)%> - <% if is_student %> - <% if is_evaluation %> - <%= link_to "互评>>" , homework_attach_path(homework)%> - <% else %> - <%= link_to "查看详细" , homework_attach_path(homework)%> - <% end %> - <% else %> - <% if is_teacher %> - <%= link_to "综评>>" , homework_attach_path(homework)%> - <% end %> + + 参与人员:  + <% homework_users = "" %> + <% homework.users.each do |user| %> + <% homework_users = user.name %> + <% end %> + <% if homework.users.count == 0 %> + 无 + <% else %> + <%= homework_users %> + <% end %> + + <% if Time.parse(@bid.deadline.to_s) < Time.parse(homework.created_at.to_s) %> + 迟交 <% end %>
  - 发布人:  <%= link_to ( is_teacher ? homework.user.realname : homework.user ), user_path(homework.user)%> - - 作业评分: - <%= format("%.2f", homework.rate_averages.first.try(:avg).to_f ) %> - - <% if Time.parse(@bid.deadline.to_s) < Time.parse(homework.created_at.to_s) %> - 迟交 - <% end %> -
+ 开发项目:  + <% if homework.project != nil %> + <%= link_to homework.project.name,project_path(homework.project.id)%> + <% else %> + 该作业暂无项目 + <% end %> + + 项目得分:  + <% if homework.project != nil %> + 0分 + <% else %> + 0分 + <% end %> +
+ 提交文件:  + <%= link_to "打包下载", :controller => "zipdown", :action => "download_user_homework",:homework => homework%> + + + 互评得分:  + <%= format("%.2f", homework.rate_averages.first.try(:avg).to_f ) %>   + <%= link_to "学生互评>>",homework_attach_path(homework) %> +
  - <% if User.current.member_of?(@bid.courses.first) %> - <%= l(:label_bidding_user_studentcode) %>  : <%= homework.user.student_id%> - <% end %> - + + - <% 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 %> + 综评得分:  + <%= format("%.2f", homework.rate_averages.first.try(:avg).to_f ) %>   + <%= link_to "教师评分>>",homework_attach_path(homework) %>
From d38e0094693dba1a01bc8c4e637d35fc7522d972 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Thu, 19 Jun 2014 14:01:18 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E5=8F=96=E6=B6=88=E5=AD=A6=E5=8F=B7?= =?UTF-8?q?=E6=98=BE=E7=A4=BA=EF=BC=8C=E5=A2=9E=E5=8A=A0=E5=8F=82=E4=B8=8E?= =?UTF-8?q?=E4=BA=BA=E5=91=98=E5=9C=A8=E4=BD=9C=E4=B8=9A=E5=88=97=E8=A1=A8?= =?UTF-8?q?=E7=9A=84=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/bids/_homework_list.html.erb | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/app/views/bids/_homework_list.html.erb b/app/views/bids/_homework_list.html.erb index 14d18216..42d6460a 100644 --- a/app/views/bids/_homework_list.html.erb +++ b/app/views/bids/_homework_list.html.erb @@ -72,12 +72,15 @@ 参与人员:  <% homework_users = "" %> <% homework.users.each do |user| %> - <% homework_users = user.name %> + <% homework_users = homework_users + user.name %> + <% if user != homework.users.last %> + <% homework_users = homework_users + "、" %> + <% end %> <% end %> <% if homework.users.count == 0 %> 无 <% else %> - <%= homework_users %> + <%= homework_users %> <% end %>
@@ -114,7 +117,7 @@ 互评得分:  - <%= format("%.2f", homework.rate_averages.first.try(:avg).to_f ) %>   + <%= format("%.2f", homework.rate_averages.first.try(:avg).to_f ) %>分   <%= link_to "学生互评>>",homework_attach_path(homework) %>
综评得分:  - <%= format("%.2f", homework.rate_averages.first.try(:avg).to_f ) %>   + <%= format("%.2f", homework.rate_averages.first.try(:avg).to_f ) %>分   <%= link_to "教师评分>>",homework_attach_path(homework) %>
项目得分:  - <% if homework.project != nil %> - 0分 - <% else %> - 0分 - <% end %> + + <% if homework.project != nil %> + 0分 + <% else %> + 0分 + <% end %> +
提交文件:  - <%= link_to "打包下载", :controller => "zipdown", :action => "download_user_homework",:homework => homework%> + <% if is_evaluation %> + <%= link_to "打包下载", :controller => "zipdown", :action => "download_user_homework",:homework => homework%> + <% else %> + 未开启互评功能作业不允许下载 + <% end %> 互评得分:  - <%= format("%.2f", homework.rate_averages.first.try(:avg).to_f ) %>分   - <%= link_to "学生互评>>",homework_attach_path(homework) %> + <%= student_score_for_homework(homework) %>分   + <% if is_evaluation && is_student && (!users_for_homework(homework).include? User.current)%> + <%= link_to "学生互评>>",homework_attach_path(homework) %> + <% end %> +
- + + <% if is_evaluation %> + <%= render :partial => 'app_link', :locals => {:attachments => homework.attachments} %> + <% end %> 综评得分:  - <%= format("%.2f", homework.rate_averages.first.try(:avg).to_f ) %>分   - <%= link_to "教师评分>>",homework_attach_path(homework) %> + <%= score_for_homework homework %>分   + <% if is_teacher %> + <%= link_to "教师评分>>",homework_attach_path(homework) %> + <% end %> +
diff --git a/app/views/homework_attach/_comprehensive_evaluation.html.erb b/app/views/homework_attach/_comprehensive_evaluation.html.erb index 08db3054..786659d9 100644 --- a/app/views/homework_attach/_comprehensive_evaluation.html.erb +++ b/app/views/homework_attach/_comprehensive_evaluation.html.erb @@ -1,23 +1,9 @@ <% is_teacher = is_course_teacher User.current,homework.bid.courses.first %> <% if comprehensive_evaluation != nil && comprehensive_evaluation.count > 0 %> - <% stars = homework.rates(:quality).where("rater_id = #{comprehensive_evaluation.first.user.id}").select("stars").first %>
作业综评: - -
- <% if stars != nil %> -
- <% else %> -
- <% end %> -
-
-
-
-
+ <%= render :partial => 'show_score', locals: {:stars => teaher_score} %>
<%= comprehensive_evaluation.first.notes%>
diff --git a/app/views/homework_attach/_show_score.html.erb b/app/views/homework_attach/_show_score.html.erb new file mode 100644 index 00000000..7c2403e1 --- /dev/null +++ b/app/views/homework_attach/_show_score.html.erb @@ -0,0 +1,14 @@ + +
+ <% if stars != nil %> +
+ <% else %> +
+ <% end %> +
+
+
+
+
\ No newline at end of file diff --git a/app/views/homework_attach/show.html.erb b/app/views/homework_attach/show.html.erb index 4ab6141d..915485fe 100644 --- a/app/views/homework_attach/show.html.erb +++ b/app/views/homework_attach/show.html.erb @@ -49,7 +49,7 @@
平均评分: - <%= rating_for @homework, :static => true, dimension: :quality, class: 'rateable div_inline' %> + <%= render :partial => 'show_score', :locals => {:stars => @totle_score} %> 发布时间:<%=format_time @homework.created_at %>