diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index 10332752..a850d16c 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -1176,7 +1176,7 @@ class CoursesController < ApplicationController def export_course_member_excel q = params[:name] ? "#{params[:name].strip}" : "" - filename="#{@course.teacher.show_real_name.to_s }_#{@course.name}_#{l(:excel_member_list)}"; + filename="#{@course.teacher.show_real_name.to_s }_#{@course.name}_#{l(:excel_member_list)}" if params[:group_id] && params[:group_id] != "0" && params[:group_id] != "-1" group = CourseGroup.find params[:group_id] unless group.nil? @@ -2437,48 +2437,48 @@ class CoursesController < ApplicationController sheet1[count_row,column+=1] = member.course_group_id == 0 ? "暂无" : member.course_group.name # current_col = 5 shixun_score = 0 - homeworks.where(:homework_type => 4).includes(:student_works).each do |homework| - student_works = homework.student_works.where("user_id = #{member.user.id}") - if student_works.empty? + homeworks.where(:homework_type => 4).each do |homework| + student_works = homework.score_student_works.find_by_user_id(member.user.id) + if student_works.nil? sheet1[count_row,column+=1] = 0 else - work_score = student_works.first.work_score.nil? ? 0 : student_works.first.work_score + work_score = student_works.work_score.nil? ? 0 : student_works.work_score sheet1[count_row,column+=1] = work_score < 0 ? 0 : work_score.round(1) shixun_score += work_score < 0 ? 0 : work_score.round(1) end # current_col += 1 end common_score = 0 - homeworks.where(:homework_type => 1).includes(:student_works).each do |homework| - student_works = homework.student_works.where("user_id = #{member.user.id}") - if student_works.empty? + homeworks.where(:homework_type => 1).each do |homework| + student_works = homework.score_student_works.find_by_user_id(member.user.id) + if student_works.nil? sheet1[count_row,column+=1] = 0 else - work_score = student_works.first.work_score.nil? ? 0 : student_works.first.work_score + work_score = student_works.work_score.nil? ? 0 : student_works.work_score sheet1[count_row,column+=1] = work_score < 0 ? 0 : work_score.round(1) common_score += work_score < 0 ? 0 : work_score.round(1) end # current_col += 1 end group_score = 0 - homeworks.where(:homework_type => 3).includes(:student_works).each do |homework| - student_works = homework.student_works.where("user_id = #{member.user.id}") - if student_works.empty? + homeworks.where(:homework_type => 3).each do |homework| + student_works = homework.score_student_works.find_by_user_id(member.user.id) + if student_works.nil? sheet1[count_row,column+=1] = 0 else - work_score = student_works.first.work_score.nil? ? 0 : student_works.first.work_score + work_score = student_works.work_score.nil? ? 0 : student_works.work_score sheet1[count_row,column+=1] = work_score < 0 ? 0 : work_score.round(1) group_score += work_score < 0 ? 0 : work_score.round(1) end # current_col += 1 end exercise_score = 0 - exercises.includes(:exercise_users).each do |exercise| - exercise_user = exercise.exercise_users.where("user_id = #{member.user.id}") - if exercise_user.empty? + exercises.each do |exercise| + exercise_user = exercise.score_exercise_users.find_by_user_id(member.user.id) + if exercise_user.nil? sheet1[count_row,column+=1] = 0 else - work_score = exercise_user.first.score.nil? ? 0 : exercise_user.first.score + work_score = exercise_user.score.nil? ? 0 : exercise_user.score sheet1[count_row,column+=1] = work_score < 0 ? 0 : work_score.round(1) exercise_score += work_score < 0 ? 0 : work_score.round(1) end @@ -2486,7 +2486,7 @@ class CoursesController < ApplicationController end graduation_score = 0 - tasks.includes(:graduation_works).each do |task| + tasks.each do |task| graduation_works = task.graduation_works.where("user_id = #{member.user.id}") if graduation_works.empty? sheet1[count_row,column+=1] = 0 @@ -2576,7 +2576,7 @@ class CoursesController < ApplicationController sheet[3,1] = "第#{i+1}次" sheet[3,0] = "作业名称" sheet[3,1] = home.name - sheet.row(4).concat([l(:excel_rank),l(:excel_user_name),l(:excel_nickname),l(:excel_student_id),l(:excel_homework_des),l(:excel_l_penalty),l(:excel_f_score),l(:excel_commit_time)]) + sheet.row(4).concat([l(:excel_rank),l(:excel_user_name),l(:excel_nickname),l(:excel_student_id),"分班",l(:excel_homework_des),l(:excel_l_penalty),l(:excel_f_score),l(:excel_commit_time)]) count_row = 5 items = home.score_student_works # if items.count == 0 && home.publish_time < Time.now && !course.is_end @@ -2588,10 +2588,11 @@ class CoursesController < ApplicationController sheet[count_row,1] = stu.user.show_real_name sheet[count_row,2] = stu.user.login sheet[count_row,3] = stu.user.user_extensions.student_id - sheet[count_row,4] = strip_html stu.description - sheet[count_row,5] = stu.late_penalty - sheet[count_row,6] = stu.work_score.nil? ? l(:label_without_score) : stu.work_score.round(1) - sheet[count_row,7] = format_time(stu.commit_time) + sheet[count_row,4] = member_group_name course.members, stu.user_id + sheet[count_row,5] = strip_html stu.description + sheet[count_row,6] = stu.late_penalty + sheet[count_row,7] = stu.work_score.nil? ? l(:label_without_score) : stu.work_score.round(1) + sheet[count_row,8] = format_time(stu.commit_time) count_row += 1 end end diff --git a/app/models/exercise.rb b/app/models/exercise.rb index f82b6047..cb65c5ce 100644 --- a/app/models/exercise.rb +++ b/app/models/exercise.rb @@ -7,7 +7,7 @@ class Exercise < ActiveRecord::Base has_many :exercise_group_settings, :dependent => :destroy has_many :exercise_questions, :dependent => :destroy,:order => "#{ExerciseQuestion.table_name}.question_number" has_many :exercise_users, :dependent => :destroy, :conditions => "exercise_users.is_delete = 0" - has_many :score_exercise_users, :conditions => "exercise_users.is_delete = 0 and commit_status != 0", :order => "exercise_users.score desc" + has_many :score_exercise_users, :class_name => "ExerciseUser", :conditions => "exercise_users.is_delete = 0 and commit_status != 0", :order => "exercise_users.score desc" has_many :users, :through => :exercise_users #该测试被哪些用户提交答案过 has_many :course_acts, :class_name => 'CourseActivity',:as =>:course_act ,:dependent => :destroy # 课程消息 diff --git a/app/views/courses/settings/_student_table.html.erb b/app/views/courses/settings/_student_table.html.erb index 49c59421..f3b0c254 100644 --- a/app/views/courses/settings/_student_table.html.erb +++ b/app/views/courses/settings/_student_table.html.erb @@ -5,7 +5,9 @@ 用户ID 姓名 - 学号 + <% if User.current.admin || User.current.member_of_course?(@course) %> + 学号 + <% end %> 分班 @@ -22,9 +24,11 @@ <% end %> <%= user.login %> <%= link_to user.show_real_name, user_path(user), :class => 'edu-txt-w140 task-hide mt5 color-grey-3', :target => '_blank' %> - - <%= user.user_extensions ? user.user_extensions.student_id : '' %> - + <% if User.current.admin || User.current.member_of_course?(@course) %> + + <%= user.user_extensions ? user.user_extensions.student_id : '' %> + + <% end %> <%= member.course_group_id == 0 || member.course_group_id.nil? ? '未分班' : member.course_group.name %> <% if false %> <%= format("%.1f", member.course_score) %> diff --git a/app/views/exercise/_student_exercise.html.erb b/app/views/exercise/_student_exercise.html.erb index 68a92d3f..bb83e49d 100644 --- a/app/views/exercise/_student_exercise.html.erb +++ b/app/views/exercise/_student_exercise.html.erb @@ -12,7 +12,9 @@ 序号 姓名 分班 - 学号 + <% if User.current.admin || User.current.member_of_course?(@course) %> + 学号 + <% end %> 提交状态 提交时间 客观题得分 @@ -35,9 +37,11 @@ <%= member.try(:course_group_id).to_i == 0 ? '未分班' : member.course_group.name %> - "> - <%= exercise.user.user_extensions.nil? ? "--" : exercise.user.user_extensions.student_id %> - + <% if User.current.admin || User.current.member_of_course?(@course) %> + "> + <%= exercise.user.user_extensions.nil? ? "--" : exercise.user.user_extensions.student_id %> + + <% end %> <%= (ex_poll_work_status exercise.commit_status).html_safe %> diff --git a/app/views/graduation_tasks/_student_work_list.html.erb b/app/views/graduation_tasks/_student_work_list.html.erb index 84187cf4..3f3e2661 100644 --- a/app/views/graduation_tasks/_student_work_list.html.erb +++ b/app/views/graduation_tasks/_student_work_list.html.erb @@ -16,27 +16,29 @@
- +
- + - - + <% if User.current.admin || User.current.member_of_course?(@course) %> + + <% end %> + <% if @task.task_type == 2 %> - + <% if @task.base_on_project %> - + <% end %> <% end %> - - - + + + <% if @task.cross_comment %> - + <% end %> - - + + @@ -44,16 +46,20 @@ <% @works.each_with_index do |work, i| %> <% score_open = task_score_open || work.user == User.current %> - - - <% student_id = work.user.user_extensions.nil? ? "--" : work.user.user_extensions.student_id %> - + + + <% if User.current.admin || User.current.member_of_course?(@course) %> + <% student_id = work.user.user_extensions.nil? ? "--" : work.user.user_extensions.student_id %> + + <% end %> <% group_name = member_group_name @course.members, work.user_id %> - + <% if @task.task_type == 2 %> - + <% if @task.base_on_project %> - <% end %> <% end %> - - - + + <% if @task.cross_comment %> - <% end %> <% score = work.work_score %> - - - + <% if User.current.admin || User.current.member_of_course?(@course) %> + + <% end %> <% if @poll.un_anonymous && @is_teacher %> @@ -29,9 +31,11 @@ - + <% if User.current.admin || User.current.member_of_course?(@course) %> + + <% end %> diff --git a/app/views/student_work/_evaluation_un_common_title.html.erb b/app/views/student_work/_evaluation_un_common_title.html.erb index 20c85456..da53c12d 100644 --- a/app/views/student_work/_evaluation_un_common_title.html.erb +++ b/app/views/student_work/_evaluation_un_common_title.html.erb @@ -3,7 +3,9 @@ - + <% if User.current.admin || User.current.member_of_course?(@course) %> + + <% end %> @@ -33,10 +35,12 @@ - <% student_id = student_work.user.user_extensions.nil? ? "--" : student_work.user.user_extensions.student_id %> - + <% if User.current.admin || User.current.member_of_course?(@course) %> + <% student_id = student_work.user.user_extensions.nil? ? "--" : student_work.user.user_extensions.student_id %> + + <% end %> diff --git a/app/views/student_work/_evaluation_un_group_title.html.erb b/app/views/student_work/_evaluation_un_group_title.html.erb index 9bc44e9b..d782fe7f 100644 --- a/app/views/student_work/_evaluation_un_group_title.html.erb +++ b/app/views/student_work/_evaluation_un_group_title.html.erb @@ -3,7 +3,9 @@ - + <% if User.current.admin || User.current.member_of_course?(@course) %> + + <% end %> <% if @homework.homework_detail_group.base_on_project == 1 %> @@ -38,10 +40,12 @@ - <% student_id = student_work.user.user_extensions.nil? ? "--" : student_work.user.user_extensions.student_id %> - + <% if User.current.admin || User.current.member_of_course?(@course) %> + <% student_id = student_work.user.user_extensions.nil? ? "--" : student_work.user.user_extensions.student_id %> + + <% end %> diff --git a/app/views/student_work/_evaluation_un_shixun_title.html.erb b/app/views/student_work/_evaluation_un_shixun_title.html.erb index d732fcf7..f8380cdc 100644 --- a/app/views/student_work/_evaluation_un_shixun_title.html.erb +++ b/app/views/student_work/_evaluation_un_shixun_title.html.erb @@ -3,7 +3,9 @@ - + <% if User.current.admin || User.current.member_of_course?(@course) %> + + <% end %> @@ -30,10 +32,12 @@ - <% student_id = student_work.user.user_extensions.nil? ? "--" : student_work.user.user_extensions.student_id %> - + <% if User.current.admin || User.current.member_of_course?(@course) %> + <% student_id = student_work.user.user_extensions.nil? ? "--" : student_work.user.user_extensions.student_id %> + + <% end %>
序号序号 姓名学号分班学号分班分组分组关联项目关联项目提交状态更新时间教师评分提交状态更新时间教师评分交叉评分交叉评分最终成绩操作最终成绩操作
<%= (@page - 1) * @limit + i + 1 %><%= link_to work.user.show_real_name, user_path(work.user), :target => "_blank" %><%= student_id %><%= (@page - 1) * @limit + i + 1 %><%= link_to work.user.show_real_name, user_path(work.user), :target => "_blank" %><%= student_id %><%= group_name %> + <%= group_name %> + <%= work.group_id == 0 ? '--' : '分组'+work.group_id.to_s %><%= work.group_id == 0 ? '--' : '分组'+work.group_id.to_s %> + <% if work.project %> <% project = work.project %> <% if project.status != 9 && (project.is_public || User.current.member_of?(project) || @is_teacher) %> @@ -85,18 +91,18 @@ <%= (ex_poll_work_status work.work_status).html_safe %><%= work.work_status == 0 ? '--' : format_time(work.update_time) %> + <%= (ex_poll_work_status work.work_status).html_safe %><%= work.work_status == 0 ? '--' : format_time(work.update_time) %> <%= work.work_status == 0 ? '--' : (work.teacher_score.nil? ? "未批阅" : (!score_open ? "**" : format("%.1f", work.teacher_score.round(1)))) %> + <%= work.work_status == 0 ? '--' : (work.cross_score.nil? ? "未批阅" : (!score_open ? "**" : (format("%.1f", work.cross_score.round(1)) + "(#{work.graduation_work_scores.where(:reviewer_role => 2).group_by(&:user_id).count})"))) %> + <%= score.nil? ? "--" : (!score_open ? "**" : format("%.1f",score<0 ? 0 : score.round(1)))%> <% if score.present? %> <% end %> + <% if @is_teacher && @task.cross_comment && @task.comment_status == 2 %> 分配 <% end %> diff --git a/app/views/graduation_topics/_student_topic_list.html.erb b/app/views/graduation_topics/_student_topic_list.html.erb index cbe40195..80fdf4aa 100644 --- a/app/views/graduation_topics/_student_topic_list.html.erb +++ b/app/views/graduation_topics/_student_topic_list.html.erb @@ -3,7 +3,9 @@

序号 姓名 - 学号 + <% if User.current.admin || User.current.member_of_course?(@course) %> + 学号 + <% end %> 分班 选题时间 确认结果 @@ -15,8 +17,10 @@

<%= index + 1 %> <%= student_topic.user.show_real_name %> - <% student_id = student_topic.user.user_extensions.try(:student_id).present? ? student_topic.user.user_extensions.student_id : "--" %> - <%= student_id %> + <% if User.current.admin || User.current.member_of_course?(@course) %> + <% student_id = student_topic.user.user_extensions.try(:student_id).present? ? student_topic.user.user_extensions.student_id : "--" %> + <%= student_id %> + <% end %> <%= student_topic.member.course_group.try(:name) %> <%= format_time student_topic.created_at %> <%= (student_topic_status student_topic.status).html_safe %> diff --git a/app/views/poll/_student_poll.html.erb b/app/views/poll/_student_poll.html.erb index edf97bd4..80589a4c 100644 --- a/app/views/poll/_student_poll.html.erb +++ b/app/views/poll/_student_poll.html.erb @@ -10,7 +10,9 @@

序号 姓名 分班学号学号提交状态 提交时间 <%= member.try(:course_group_id).to_i == 0 ? '未分班' : member.course_group.name %> "> - <%= poll.user.user_extensions.nil? ? "--" : poll.user.user_extensions.student_id %> - "> + <%= poll.user.user_extensions.nil? ? "--" : poll.user.user_extensions.student_id %> + <%= (ex_poll_work_status poll.commit_status).html_safe %> 序号 姓名 分班学号学号提交状态 更新时间 教师评分 <%= group_name %> - <%= student_id %> - + <%= student_id %> + <%= (ex_poll_work_status student_work.work_status).html_safe %> 序号 姓名 分班学号学号分组关联项目 <%= group_name %> - <%= student_id %> - + <%= student_id %> + <%= student_work.group_id == 0 ? '--' : '分组'+student_work.group_id.to_s %> 序号 姓名 分班学号学号提交状态 提交耗时 更新时间 <%= group_name %> - <%= student_id %> - + <%= student_id %> + <% status = list_work_status student_work, @homework, group_id %> <%= status %>