From b241fb4dbe85f82517a3ce0abdd51ae1b0e4bdd4 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Mon, 8 Jul 2019 17:24:50 +0800 Subject: [PATCH 01/26] fixbug --- app/models/exercise.rb | 1 - app/models/poll.rb | 19 ++++++++++--------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/app/models/exercise.rb b/app/models/exercise.rb index 606132c27..2a6a8f84b 100644 --- a/app/models/exercise.rb +++ b/app/models/exercise.rb @@ -79,7 +79,6 @@ class Exercise < ApplicationRecord published_group_ids end - #判断用户是否属于试卷分班的学生中 def check_user_in_course(user_id,user_identity) ex_group_settings = exercise_group_settings.pluck(:course_group_id) diff --git a/app/models/poll.rb b/app/models/poll.rb index a055fd656..69b717493 100644 --- a/app/models/poll.rb +++ b/app/models/poll.rb @@ -44,8 +44,8 @@ class Poll < ApplicationRecord if unified_setting #试卷统一设置 poll_users else - ex_group_setting_ids = poll_group_settings.poll_group_published.pluck(:course_group_id) - poll_users.where(user_id: course.students.where(course_group_id:ex_group_setting_ids).pluck(:user_id).uniq) + ex_group_setting_ids = poll_group_settings.poll_group_published.select(:course_group_id).pluck(:course_group_id) + poll_users.where(user_id: course.students.where(course_group_id:ex_group_setting_ids).select(:user_id).pluck(:user_id).uniq) end end @@ -63,15 +63,16 @@ class Poll < ApplicationRecord def poll_published_ids(user_id) current_user_groups = course.teacher_course_ids(user_id) if unified_setting - if course.none_group_count > 0 #有未分班的,则发布到未发布 - un_group_ids = [0] - else - un_group_ids = [] - end - (current_user_groups + un_group_ids).uniq #统一设置时,为当前用户的分班id + current_user_groups.uniq + # if course.none_group_count > 0 #有未分班的,则发布到未发布 + # un_group_ids = [0] + # else + # un_group_ids = [] + # end + # (current_user_groups + un_group_ids).uniq #统一设置时,为当前用户的分班id else ex_group_setting = poll_group_settings.select(:course_group_id).pluck("course_group_id").uniq - ex_group_setting & current_user_groups #当前用户有权限的已发布的分班id #非统一设置时,为当前用户有权限的且已发布分班的id + (ex_group_setting & current_user_groups).uniq #当前用户有权限的已发布的分班id #非统一设置时,为当前用户有权限的且已发布分班的id end end From 3f6049df398585e94fbf7dd64dc52bff3a56affd Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Tue, 9 Jul 2019 15:58:15 +0800 Subject: [PATCH 02/26] =?UTF-8?q?=E8=B0=83=E6=95=B4=E5=AE=9E=E8=AE=AD?= =?UTF-8?q?=E4=BD=9C=E5=93=81=E7=9A=84=E5=85=B3=E5=8D=A1=E5=88=86=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/student_works_controller.rb | 35 ++++++++++++++----- app/models/challenge_work_score.rb | 8 +++++ .../adjust_review_score.json.jbuilder | 3 ++ .../shixun_work_report.json.jbuilder | 1 + 4 files changed, 39 insertions(+), 8 deletions(-) diff --git a/app/controllers/student_works_controller.rb b/app/controllers/student_works_controller.rb index 92d146c82..62d96c424 100644 --- a/app/controllers/student_works_controller.rb +++ b/app/controllers/student_works_controller.rb @@ -631,16 +631,35 @@ class StudentWorksController < ApplicationController # 查重作品调分 def adjust_review_score - if params[:score].nil? || params[:challenge_id].nil? || params[:code_rate].nil? || params[:copy_user_id].nil? + tip_exception("缺少type参数") if params[:type].blank? || ["review", "report"].include?(params[:type]) + if params[:type] == "review" && (params[:score].nil? || params[:challenge_id].nil? || params[:code_rate].nil? || params[:copy_user_id].nil?) tip_exception("参数错误,score和challenge_id和code_rate和copy_user_id不能为空") + elsif params[:type] == "report" && (params[:score].nil? || params[:challenge_id].nil?) + tip_exception("参数错误,score和challenge_id") + end + challenge_setting = @homework.homework_challenge_settings.find_by(challenge_id: params[:challenge_id]) + challenge = challenge_setting&.challenge + tip_exception("不能小于零") if params[:score] < 0 + tip_exception("不能大于关卡分值:#{challenge_setting.score}分") if challenge_setting.score < params[:score] + + ActiveRecord::Base.transaction do + begin + if params[:type] == "review" + copy_user = User.find params[:copy_user_id] + comment = "代码查重结果显示与#{copy_user.try(:show_real_name)}的代码相似度#{params[:code_rate]}%" + else + comment = "根据实训报告中最终提交的代码调整第#{challenge.position}关分数" + end + challenge_score = @work.challenge_work_scores.create(challenge_id: params[:challenge_id], user_id: current_user.id, score: params[:score], + comment: comment) + challenge_score.create_tiding current_user.id + HomeworksService.new.update_myshixun_work_score @work, @work&.myshixun, @work&.myshixun&.games, @homework, @homework.homework_challenge_settings + rescue Exception => e + uid_logger(e.message) + tip_exception(e.message) + raise ActiveRecord::Rollback + end end - copy_user = User.find params[:copy_user_id] - comment = "代码查重结果显示与#{copy_user.try(:show_real_name)}的代码相似度#{params[:code_rate]}%" - @work.challenge_work_scores.create(challenge_id: params[:challenge_id], user_id: current_user.id, score: params[:score], - comment: comment) - HomeworksService.new.set_shixun_final_score(@work) - @work_score = @homework.student_works.find_by(id: @work.id).try(:work_score) - end diff --git a/app/models/challenge_work_score.rb b/app/models/challenge_work_score.rb index 8316e228b..1e7c9f7fe 100644 --- a/app/models/challenge_work_score.rb +++ b/app/models/challenge_work_score.rb @@ -2,4 +2,12 @@ class ChallengeWorkScore < ApplicationRecord belongs_to :user belongs_to :student_work belongs_to :challenge + has_many :tidings, as: :container, dependent: :destroy + + def create_tiding trigger_user_id + tidings << Tiding.new(user_id: student_work.user_id, trigger_user_id: trigger_user_id, container_id: id, + container_type: "ChallengeWorkScore", parent_container_id: student_work_id, + parent_container_type: "StudentWork", belong_container_id: student_work&.homework_common&.course_id, + belong_container_type: "Course", viewed: 0, tiding_type: "HomeworkCommon") + end end diff --git a/app/views/student_works/adjust_review_score.json.jbuilder b/app/views/student_works/adjust_review_score.json.jbuilder index e69de29bb..399b52c13 100644 --- a/app/views/student_works/adjust_review_score.json.jbuilder +++ b/app/views/student_works/adjust_review_score.json.jbuilder @@ -0,0 +1,3 @@ +json.status 0 +json.message "调分成功" +json.work_score @work.work_score \ No newline at end of file diff --git a/app/views/student_works/shixun_work_report.json.jbuilder b/app/views/student_works/shixun_work_report.json.jbuilder index 1c6ed5899..f0aa8119e 100644 --- a/app/views/student_works/shixun_work_report.json.jbuilder +++ b/app/views/student_works/shixun_work_report.json.jbuilder @@ -24,6 +24,7 @@ if @shixun json.myself_experience game.final_score json.experience game.challenge.all_score json.complete_status game_status(game, @homework) + json.challenge_id game.challenge_id end end From 8bee375b67a224e583b9cfe56507ee1fea7684f8 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Tue, 9 Jul 2019 17:20:11 +0800 Subject: [PATCH 03/26] =?UTF-8?q?=E6=AF=95=E8=AE=BE=E6=8F=90=E4=BA=A4?= =?UTF-8?q?=E4=BD=9C=E5=93=81=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/graduation_works/edit.json.jbuilder | 2 ++ app/views/graduation_works/new.json.jbuilder | 2 ++ 2 files changed, 4 insertions(+) diff --git a/app/views/graduation_works/edit.json.jbuilder b/app/views/graduation_works/edit.json.jbuilder index 7fc3a9621..254579473 100644 --- a/app/views/graduation_works/edit.json.jbuilder +++ b/app/views/graduation_works/edit.json.jbuilder @@ -3,6 +3,8 @@ json.task_type @task.task_type json.work_id @work.id json.description @work.description json.user_name @task_user.real_name +json.max_num @task.max_num +json.min_num @task.min_num json.attachments @work.attachments do |atta| json.partial! "attachments/attachment_simple", locals: {attachment: atta, delete: @work.delete_atta(atta)} diff --git a/app/views/graduation_works/new.json.jbuilder b/app/views/graduation_works/new.json.jbuilder index 601ba02d3..26c046ab6 100644 --- a/app/views/graduation_works/new.json.jbuilder +++ b/app/views/graduation_works/new.json.jbuilder @@ -6,4 +6,6 @@ if @task.task_type == 2 json.user_id @user.id json.user_student_id @user.student_id json.group_name @course.course_member(@user.id).try(:course_group_name) + json.max_num @task.max_num + json.min_num @task.min_num end From 9b285f19c05329d3de367867f1f4a46971a042d1 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Tue, 9 Jul 2019 20:22:30 +0800 Subject: [PATCH 04/26] fixbug --- app/models/poll.rb | 5 ----- 1 file changed, 5 deletions(-) diff --git a/app/models/poll.rb b/app/models/poll.rb index 1c88c4c5a..e6a363f1d 100644 --- a/app/models/poll.rb +++ b/app/models/poll.rb @@ -45,14 +45,9 @@ class Poll < ApplicationRecord if unified_setting #试卷统一设置 poll_users else -<<<<<<< HEAD - ex_group_setting_ids = poll_group_settings.poll_group_published.select(:course_group_id).pluck(:course_group_id) - poll_users.where(user_id: course.students.where(course_group_id:ex_group_setting_ids).select(:user_id).pluck(:user_id).uniq) -======= ex_group_setting_ids = published_settings.pluck(:course_group_id) poll_users.joins("join course_members on poll_users.user_id=course_members.user_id"). where(course_members: {course_group_id: ex_group_setting_ids}) ->>>>>>> 8bee375b67a224e583b9cfe56507ee1fea7684f8 end end From b023702f093b93a602b069676b6505c5c78f4e5c Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Tue, 9 Jul 2019 20:47:32 +0800 Subject: [PATCH 05/26] =?UTF-8?q?=E6=AF=95=E8=AE=BE=E4=BB=BB=E5=8A=A1?= =?UTF-8?q?=E7=9A=84=E8=AF=84=E8=AF=AD=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/helpers/export_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/helpers/export_helper.rb b/app/helpers/export_helper.rb index 1732e1d10..898233ff4 100644 --- a/app/helpers/export_helper.rb +++ b/app/helpers/export_helper.rb @@ -257,7 +257,7 @@ module ExportHelper w_13 = work.work_score.nil? ? "未评分" : work.work_score.round(1) w_14 = work.commit_time.present? ? format_time(work.commit_time) : "--" w_15 = work.update_time.present? ? format_time(work.update_time) : "--" - teacher_comments = work.student_works_scores + teacher_comments = work.graduation_work_scores if teacher_comments.present? w_16 = "" teacher_comments.each do |t| From 0b529f7d39f332877c35d8871c19d5b058ee210f Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Tue, 9 Jul 2019 20:51:53 +0800 Subject: [PATCH 06/26] fixbug --- app/views/graduation_tasks/tasks_list.xlsx.axlsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/views/graduation_tasks/tasks_list.xlsx.axlsx b/app/views/graduation_tasks/tasks_list.xlsx.axlsx index 1f4f76292..8aa08122c 100644 --- a/app/views/graduation_tasks/tasks_list.xlsx.axlsx +++ b/app/views/graduation_tasks/tasks_list.xlsx.axlsx @@ -5,10 +5,12 @@ wb.styles do |s| blue_cell = s.add_style :bg_color => "FAEBDC", :sz => 10,:height => 20,:b => true, :border => { :style => :thin, :color =>"000000" },:alignment => {:horizontal => :center} wb.add_worksheet(:name =>"学生成绩") do |sheet| - sheet.add_row table_columns, :style => blue_cell + sheet.add_row table_columns,:height =>20, :style => blue_cell sheet.column_info.first.width = 12 task_users.each do |user| sheet.add_row user, :style => sz_all end #each_widh_index + sheet.column_widths *([25]*sheet.column_info.count) + sheet.column_info.first.width = 12 end #add_worksheet end \ No newline at end of file From fa86d4477e712fdb5106f983cb39a3bbb0ccc65e Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Tue, 9 Jul 2019 20:58:28 +0800 Subject: [PATCH 07/26] =?UTF-8?q?=E4=BF=AE=E6=94=B9xlsx=E7=9A=84=E6=A0=B7?= =?UTF-8?q?=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../export_member_scores_excel.xlsx.axlsx | 18 +++++++++--------- .../graduation_tasks/tasks_list.xlsx.axlsx | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/app/views/courses/export_member_scores_excel.xlsx.axlsx b/app/views/courses/export_member_scores_excel.xlsx.axlsx index da8c05f7a..4a70ea30a 100644 --- a/app/views/courses/export_member_scores_excel.xlsx.axlsx +++ b/app/views/courses/export_member_scores_excel.xlsx.axlsx @@ -14,7 +14,7 @@ wb.styles do |s| group_info_d = course_group_info[0] group_info_detail = course_group_info[1] course_main_info.each do |c| - sheet.add_row c, :style => sz_all #用户id + sheet.add_row c, :height => 20, :style => sz_all #用户id end sheet["A1:A7"].each { |c| c.style = row_cell } sheet.add_row [],:style => sz_all @@ -32,12 +32,12 @@ wb.styles do |s| sheet.sheet_view.show_grid_lines = false sheet_title = activity_level[1] sheet_content = activity_level[2] - sheet.add_row sheet_title, :style => blue_cell + sheet.add_row sheet_title, :height => 20,:style => blue_cell if sheet_content.count > 0 sheet_content.each_with_index do |c,index| c_1 = (index+1) c_2 = [c_1] + c.values - sheet.add_row c_2, :style => sz_all #用户id + sheet.add_row c_2, :height => 20, :style => sz_all #用户id end sheet.column_widths *([20]*sheet.column_info.count) sheet.column_info.first.width = 8 @@ -82,7 +82,7 @@ wb.styles do |s| sheet_content.each_with_index do |c,index| c_1 = (index+1) c_2 = [c_1] + c - sheet.add_row c_2, :style => sz_all #用户id + sheet.add_row c_2, :height => 20,:style => sz_all #用户id end end sheet.column_widths *([15]*sheet.column_info.count) @@ -100,7 +100,7 @@ wb.styles do |s| sheet.add_row head_title, :style => blue_cell if content_shixun.count > 0 content_shixun.each do |user| - sheet.add_row user, :style => sz_all + sheet.add_row user, :height => 20,:style => sz_all end #each_widh_index end sheet.column_widths *([20]*sheet.column_info.count) @@ -119,7 +119,7 @@ wb.styles do |s| sheet.add_row head_title, :style => blue_cell if content_.count > 0 content_.each do |user| - sheet.add_row user, :style => no_wrap_sz + sheet.add_row user, :height => 20,:style => no_wrap_sz end #each_widh_index end sheet.column_widths *([20]*sheet.column_info.count) @@ -138,7 +138,7 @@ wb.styles do |s| sheet.add_row head_title, :style => blue_cell if content_.count > 0 content_.each do |user| - sheet.add_row user, :style => sz_all + sheet.add_row user, :height => 20,:style => sz_all end #each_widh_index end sheet.column_widths *([20]*sheet.column_info.count) @@ -155,7 +155,7 @@ wb.styles do |s| content_ = task[2] sheet.add_row task[1], :style => blue_cell content_.each do |user| - sheet.add_row user, :style => sz_all + sheet.add_row user, :height => 20,:style => sz_all end #each_widh_index sheet.column_widths *([20]*sheet.column_info.count) sheet.column_info.first.width = 12 @@ -171,7 +171,7 @@ wb.styles do |s| content_ = ex[2] sheet.add_row ex[1], :style => blue_cell content_.each do |user| - sheet.add_row user, :style => sz_all #用户id + sheet.add_row user, :height => 20,:style => sz_all #用户id end #each_widh_index sheet.column_widths *([20]*sheet.column_info.count) sheet.column_info.first.width = 12 diff --git a/app/views/graduation_tasks/tasks_list.xlsx.axlsx b/app/views/graduation_tasks/tasks_list.xlsx.axlsx index 8aa08122c..e34290498 100644 --- a/app/views/graduation_tasks/tasks_list.xlsx.axlsx +++ b/app/views/graduation_tasks/tasks_list.xlsx.axlsx @@ -8,7 +8,7 @@ wb.styles do |s| sheet.add_row table_columns,:height =>20, :style => blue_cell sheet.column_info.first.width = 12 task_users.each do |user| - sheet.add_row user, :style => sz_all + sheet.add_row user, :height =>20, :style => sz_all end #each_widh_index sheet.column_widths *([25]*sheet.column_info.count) sheet.column_info.first.width = 12 From a102e6a22b830bbcaf1e40fe21a79dc0486776e0 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Tue, 9 Jul 2019 21:05:52 +0800 Subject: [PATCH 08/26] fixbug --- .../export_member_scores_excel.xlsx.axlsx | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/app/views/courses/export_member_scores_excel.xlsx.axlsx b/app/views/courses/export_member_scores_excel.xlsx.axlsx index 4a70ea30a..5b226a09c 100644 --- a/app/views/courses/export_member_scores_excel.xlsx.axlsx +++ b/app/views/courses/export_member_scores_excel.xlsx.axlsx @@ -4,7 +4,7 @@ wb.styles do |s| no_wrap_sz = s.add_style :border => { :style => :thin, :color =>"000000" },:alignment => {wrap_text: false,:horizontal => :center,:vertical => :center } sz_all = s.add_style :border => { :style => :thin, :color =>"000000" },:alignment => {wrap_text: true,:horizontal => :center,:vertical => :center } row_cell = s.add_style :bg_color=> "FAEBDC",:border => { :style => :thin, :color =>"000000" },alignment: {wrap_text: true,:horizontal => :center,:vertical => :center } - blue_cell = s.add_style :bg_color => "FAEBDC", :sz => 10,:height => 20,:b => true, :border => { :style => :thin, :color =>"000000" },:alignment => {wrap_text: true,:horizontal => :center,:vertical => :center} + blue_cell = s.add_style :bg_color => "FAEBDC", :sz => 10,:height => 25,:b => true, :border => { :style => :thin, :color =>"000000" },:alignment => {wrap_text: true,:horizontal => :center,:vertical => :center} #课堂信息摘要 wb.add_worksheet(name:course_info[0]) do |sheet| @@ -14,7 +14,7 @@ wb.styles do |s| group_info_d = course_group_info[0] group_info_detail = course_group_info[1] course_main_info.each do |c| - sheet.add_row c, :height => 20, :style => sz_all #用户id + sheet.add_row c, :style => sz_all #用户id end sheet["A1:A7"].each { |c| c.style = row_cell } sheet.add_row [],:style => sz_all @@ -32,12 +32,12 @@ wb.styles do |s| sheet.sheet_view.show_grid_lines = false sheet_title = activity_level[1] sheet_content = activity_level[2] - sheet.add_row sheet_title, :height => 20,:style => blue_cell + sheet.add_row sheet_title, :height => 25,:style => blue_cell if sheet_content.count > 0 sheet_content.each_with_index do |c,index| c_1 = (index+1) c_2 = [c_1] + c.values - sheet.add_row c_2, :height => 20, :style => sz_all #用户id + sheet.add_row c_2, :height => 25, :style => sz_all #用户id end sheet.column_widths *([20]*sheet.column_info.count) sheet.column_info.first.width = 8 @@ -82,7 +82,7 @@ wb.styles do |s| sheet_content.each_with_index do |c,index| c_1 = (index+1) c_2 = [c_1] + c - sheet.add_row c_2, :height => 20,:style => sz_all #用户id + sheet.add_row c_2, :height => 25,:style => sz_all #用户id end end sheet.column_widths *([15]*sheet.column_info.count) @@ -100,7 +100,7 @@ wb.styles do |s| sheet.add_row head_title, :style => blue_cell if content_shixun.count > 0 content_shixun.each do |user| - sheet.add_row user, :height => 20,:style => sz_all + sheet.add_row user, :height => 25,:style => sz_all end #each_widh_index end sheet.column_widths *([20]*sheet.column_info.count) @@ -119,7 +119,7 @@ wb.styles do |s| sheet.add_row head_title, :style => blue_cell if content_.count > 0 content_.each do |user| - sheet.add_row user, :height => 20,:style => no_wrap_sz + sheet.add_row user, :height => 25,:style => no_wrap_sz end #each_widh_index end sheet.column_widths *([20]*sheet.column_info.count) @@ -138,7 +138,7 @@ wb.styles do |s| sheet.add_row head_title, :style => blue_cell if content_.count > 0 content_.each do |user| - sheet.add_row user, :height => 20,:style => sz_all + sheet.add_row user, :height => 25,:style => sz_all end #each_widh_index end sheet.column_widths *([20]*sheet.column_info.count) @@ -155,7 +155,7 @@ wb.styles do |s| content_ = task[2] sheet.add_row task[1], :style => blue_cell content_.each do |user| - sheet.add_row user, :height => 20,:style => sz_all + sheet.add_row user, :height => 25,:style => sz_all end #each_widh_index sheet.column_widths *([20]*sheet.column_info.count) sheet.column_info.first.width = 12 @@ -171,7 +171,7 @@ wb.styles do |s| content_ = ex[2] sheet.add_row ex[1], :style => blue_cell content_.each do |user| - sheet.add_row user, :height => 20,:style => sz_all #用户id + sheet.add_row user, :height => 25,:style => sz_all #用户id end #each_widh_index sheet.column_widths *([20]*sheet.column_info.count) sheet.column_info.first.width = 12 From 274437554269290ec6872662fc887e0d9840de1d Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Tue, 9 Jul 2019 21:11:52 +0800 Subject: [PATCH 09/26] fixbug --- app/helpers/export_helper.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/helpers/export_helper.rb b/app/helpers/export_helper.rb index 898233ff4..57fe9c17c 100644 --- a/app/helpers/export_helper.rb +++ b/app/helpers/export_helper.rb @@ -100,7 +100,7 @@ module ExportHelper user_time = format_time(t.updated_at) user_score = t&.score user_comment = t.comment.present? ? t.comment : "--" - comment_title = "教师:#{user_name}\n时间:#{user_time.to_s}\n分数:#{user_score.to_s}分\n评语:#{user_comment}\n\n" + comment_title = "#{user_name}: #{user_time.to_s} #{user_score.to_s}分\n#{user_comment}\n\n" w_18 = w_18 + comment_title end else @@ -172,7 +172,7 @@ module ExportHelper user_time = format_time(t.updated_at) user_score = t&.score user_comment = t.comment.present? ? t.comment : "--" - comment_title = "教师:#{user_name}\n时间:#{user_time.to_s}\n分数:#{user_score.to_s}分\n评语:#{user_comment}\n\n" + comment_title = "#{user_name}: #{user_time.to_s} #{user_score.to_s}分\n#{user_comment}\n\n" # ("教师:" + user_name + "\n" + "时间:" + user_time.to_s + "\n" + "分数:" + user_score.to_s + "分" + "\n" + "评语:" + user_comment + "\n\n") w_18 = w_18 + comment_title end @@ -265,7 +265,7 @@ module ExportHelper user_time = format_time(t.updated_at) user_score = t&.score user_comment = t.comment.present? ? t.comment : "--" - comment_title = "教师:#{user_name}\n时间:#{user_time.to_s}\n分数:#{user_score.to_s}分\n评语:#{user_comment}\n\n" + comment_title = "#{user_name}: #{user_time.to_s} #{user_score.to_s}分\n#{user_comment}\n\n" # ("教师:" + user_name + "\n" + "时间:" + user_time.to_s + "\n" + "分数:" + user_score.to_s + "分" + "\n" + "评语:" + user_comment + "\n\n") w_16 = w_16 + comment_title end From f286d837639b86f1378b76a7b5f38fd0a542c812 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Tue, 9 Jul 2019 21:16:08 +0800 Subject: [PATCH 10/26] fixbug --- app/helpers/export_helper.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/helpers/export_helper.rb b/app/helpers/export_helper.rb index 57fe9c17c..76f51e498 100644 --- a/app/helpers/export_helper.rb +++ b/app/helpers/export_helper.rb @@ -100,7 +100,7 @@ module ExportHelper user_time = format_time(t.updated_at) user_score = t&.score user_comment = t.comment.present? ? t.comment : "--" - comment_title = "#{user_name}: #{user_time.to_s} #{user_score.to_s}分\n#{user_comment}\n\n" + comment_title = "#{user_name}: #{user_time.to_s} #{user_score.to_s}分\n#{user_comment}\n\n" w_18 = w_18 + comment_title end else @@ -172,7 +172,7 @@ module ExportHelper user_time = format_time(t.updated_at) user_score = t&.score user_comment = t.comment.present? ? t.comment : "--" - comment_title = "#{user_name}: #{user_time.to_s} #{user_score.to_s}分\n#{user_comment}\n\n" + comment_title = "#{user_name}: #{user_time.to_s} #{user_score.to_s}分\n#{user_comment}\n\n" # ("教师:" + user_name + "\n" + "时间:" + user_time.to_s + "\n" + "分数:" + user_score.to_s + "分" + "\n" + "评语:" + user_comment + "\n\n") w_18 = w_18 + comment_title end @@ -265,7 +265,7 @@ module ExportHelper user_time = format_time(t.updated_at) user_score = t&.score user_comment = t.comment.present? ? t.comment : "--" - comment_title = "#{user_name}: #{user_time.to_s} #{user_score.to_s}分\n#{user_comment}\n\n" + comment_title = "#{user_name}: #{user_time.to_s} #{user_score.to_s}分\n#{user_comment}\n\n" # ("教师:" + user_name + "\n" + "时间:" + user_time.to_s + "\n" + "分数:" + user_score.to_s + "分" + "\n" + "评语:" + user_comment + "\n\n") w_16 = w_16 + comment_title end From 4f3a696ea7896ca9de46ada4bf0b4b7786c48131 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Wed, 10 Jul 2019 09:48:26 +0800 Subject: [PATCH 11/26] =?UTF-8?q?=E6=89=93=E6=98=9F=E6=98=9F=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/shixun.rb | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/app/models/shixun.rb b/app/models/shixun.rb index c4345f90a..4a4aea355 100644 --- a/app/models/shixun.rb +++ b/app/models/shixun.rb @@ -158,13 +158,12 @@ class Shixun < ApplicationRecord # 实训评分信息 # return [实训评分, 5星评分比例, 4星评分比例, 3星评分比例, 2星评分比例, 1星评分比例] def shixun_preference_info - game_star_info = Game.find_by_sql("select g.star from - (games g left join (myshixuns m join shixuns s on s.id = m.shixun_id) on m.id = g.myshixun_id) - where g.star != 0 and s.id = #{self.id}") + game_star_info = Game.joins(challenge: :shixun).where(shixuns: {id: id}).where.not(games: {star: 0}).pluck(:star) + star_info = [] if game_star_info.present? 5.downto(1) do |i| - star_info << ((game_star_info.select{|s| s.star == i}.count / game_star_info.count.to_f) * 100).round + star_info << ((game_star_info.select{|s| s == i}.count / game_star_info.count.to_f) * 100).round end sum = star_info.sum max = star_info.max @@ -175,7 +174,7 @@ class Shixun < ApplicationRecord star_info = star_info.map{|s| s == max ? s + 1 : s} end cnt = game_star_info.count - sum = game_star_info.sum(&:star) + sum = game_star_info.sum star_info.unshift((sum / cnt.to_f).round(1)) else star_info = [5.0, 100, 0, 0, 0, 0] From e1864ea2f5fb92b75f35410afb2bb84deadbed25 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Wed, 10 Jul 2019 10:45:56 +0800 Subject: [PATCH 12/26] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=A0=87=E7=AD=BE?= =?UTF-8?q?=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/shixun.rb | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/app/models/shixun.rb b/app/models/shixun.rb index 4a4aea355..cb305efaf 100644 --- a/app/models/shixun.rb +++ b/app/models/shixun.rb @@ -73,9 +73,8 @@ class Shixun < ApplicationRecord # 实训用户tag def user_tags_name(user = User.current) - challenge_ids = challenges.pluck(:id) - user_challenge_ids = user.games.where(challenge_id: challenge_ids, status: 2).pluck(:challenge_id) - ChallengeTag.where(challenge_id: user_challenge_ids).pluck(:name).uniq + Shixun.joins(challenges: [:challenge_tags, :games]).where(games: {status: 2, user_id: user.id}, shixuns: {id:id}) + .pluck("challenge_tags.name").uniq end # 实训关卡tag @@ -159,7 +158,6 @@ class Shixun < ApplicationRecord # return [实训评分, 5星评分比例, 4星评分比例, 3星评分比例, 2星评分比例, 1星评分比例] def shixun_preference_info game_star_info = Game.joins(challenge: :shixun).where(shixuns: {id: id}).where.not(games: {star: 0}).pluck(:star) - star_info = [] if game_star_info.present? 5.downto(1) do |i| From cade029fc14df0157e91ffc20c53f84d8fec29e6 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Wed, 10 Jul 2019 11:06:28 +0800 Subject: [PATCH 13/26] =?UTF-8?q?=E5=AE=9E=E8=AE=AD=E6=8A=A5=E5=91=8A?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2=E7=9A=84=E8=B0=83=E5=88=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/helpers/homework_commons_helper.rb | 16 ++++++++++++++++ app/models/homework_common.rb | 4 ++++ .../shixun_work_report.json.jbuilder | 11 ++++++++++- 3 files changed, 30 insertions(+), 1 deletion(-) diff --git a/app/helpers/homework_commons_helper.rb b/app/helpers/homework_commons_helper.rb index c77ae5937..10e20ec0c 100644 --- a/app/helpers/homework_commons_helper.rb +++ b/app/helpers/homework_commons_helper.rb @@ -1,5 +1,21 @@ module HomeworkCommonsHelper + # 实训作品的单个关卡得分 + def work_challenge_score student_work, game, score, homework + result = 0 + adjust_score = student_work.challenge_work_scores.where(challenge_id: game.challenge_id).last + if adjust_score.present? + result = adjust_score.score + else + setting = homework.homework_group_setting student_work.user_id + if game.status == 2 && ((game.end_time && game.end_time < setting.end_time) || (homework.allow_late && game.end_time && game.end_time < homework.late_time)) + answer_open_evaluation = homework.homework_detail_manual.answer_open_evaluation + result = answer_open_evaluation ? score : (game.final_score > 0 ? game.real_score(score) : 0) + end + end + result + end + # 未发布时非老师角色不能访问,发布后非课堂成员不能访问未公开的作业,学生需要考虑分班设置的作业是否已发布 def homework_publish if (@user_course_identity >= Course::STUDENT && (@homework.publish_time.nil? || @homework.publish_time > Time.now)) || diff --git a/app/models/homework_common.rb b/app/models/homework_common.rb index 335b898fb..ac64b92c1 100644 --- a/app/models/homework_common.rb +++ b/app/models/homework_common.rb @@ -260,4 +260,8 @@ class HomeworkCommon < ApplicationRecord self.homework_group_settings.where("end_time is not null").pluck(:end_time).max end + + def challenge_score challenge_id + homework_challenge_settings.find_by(challenge_id: challenge_id)&.score.to_f + end end diff --git a/app/views/student_works/shixun_work_report.json.jbuilder b/app/views/student_works/shixun_work_report.json.jbuilder index f0aa8119e..103ead73f 100644 --- a/app/views/student_works/shixun_work_report.json.jbuilder +++ b/app/views/student_works/shixun_work_report.json.jbuilder @@ -8,9 +8,15 @@ if @shixun json.myself_experience @work.myshixun.try(:total_score) json.total_experience @shixun.all_score json.work_score number_with_precision @work.work_score, precision: 1 - json.all_work_score 100 + json.all_work_score number_with_precision 100, precision: 1 json.time_consuming @work.myshixun_consume json.evaluate_count @user_evaluate_count.to_i + if @homework.work_efficiency + json.eff_score_full number_with_precision @homework.eff_score, precision: 1 + json.eff_score @work.eff_score + json.challenge_score_full number_with_precision (100 - @homework.eff_score), precision: 1 + json.challenge_score @work.final_score + end # 阶段成绩 json.stage_list do @@ -25,6 +31,9 @@ if @shixun json.experience game.challenge.all_score json.complete_status game_status(game, @homework) json.challenge_id game.challenge_id + challenge_score = @homework.challenge_score game.challenge_id + json.game_score_full challenge_score + json.game_score work_challenge_score @work, game, challenge_score, @homework end end From ddf679dd3671af9367eee4d31abe170a3b685241 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Wed, 10 Jul 2019 11:31:43 +0800 Subject: [PATCH 14/26] =?UTF-8?q?=E6=9F=A5=E9=87=8D=E8=AF=A6=E6=83=85?= =?UTF-8?q?=E9=A1=B5=E7=9A=84=E6=8E=A5=E5=8F=A3=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../homework_commons_controller.rb | 22 +++---------------- app/helpers/homework_commons_helper.rb | 16 -------------- app/models/student_work.rb | 15 +++++++++++++ .../code_review_detail.json.jbuilder | 7 ++++++ .../shixun_work_report.json.jbuilder | 6 ++--- 5 files changed, 28 insertions(+), 38 deletions(-) diff --git a/app/controllers/homework_commons_controller.rb b/app/controllers/homework_commons_controller.rb index 232250e4c..b7291b647 100644 --- a/app/controllers/homework_commons_controller.rb +++ b/app/controllers/homework_commons_controller.rb @@ -1354,7 +1354,7 @@ class HomeworkCommonsController < ApplicationController if results.status == 0 code_info = results.code_info homework_challenge_settings = @homework.homework_challenge_settings - @challenges = @shixun.challenges.where(id: homework_challenge_settings.pluck(:challenge_id), st: 0).includes(:games) + @challenges = @shixun.challenges.where(id: homework_challenge_settings.pluck(:challenge_id), st: 0) @challenges = @challenges.map do |challenge| code_rate = 0 @@ -1368,24 +1368,8 @@ class HomeworkCommonsController < ApplicationController game = challenge.games.find_by(user_id: @user.id) end_time = game.end_time # 用户关卡的得分 - all_score = homework_challenge_settings.find_by(challenge_id: challenge.id).try(:score) - final_score = - if @student_work.challenge_work_scores.where(challenge_id: challenge.id).last.present? - @student_work.challenge_work_scores.where(:challenge_id => game.challenge_id).last.score - else - if game.status == 2 && ((game.end_time && game.end_time < @homework.end_time) || - (@homework.allow_late && (@course.end_date.nil? || - (game.end_time && game.end_time < @course.end_date.end_of_day)))) - answer_open_evaluation = @homework.homework_detail_manual.answer_open_evaluation - # 设置了查看答案也获得满分的话就取总分。否则取关卡的百分比分支 - if answer_open_evaluation.present? - all_score - else - # 关卡的百分比 * 作业设置的分数 = 总得分 - ((game.final_score) / challenge.score) * all_score - end - end - end + all_score = homework_challenge_settings.find_by(challenge_id: challenge.id).try(:score).to_f + final_score = @student_work.work_challenge_score game, all_score # 抄袭用户 copy_user = User.find_by_id(game_codes[0].target_user_id) copy_end_time = copy_user.games.find_by(challenge_id: challenge.id).try(:end_time) if copy_user.present? diff --git a/app/helpers/homework_commons_helper.rb b/app/helpers/homework_commons_helper.rb index 10e20ec0c..c77ae5937 100644 --- a/app/helpers/homework_commons_helper.rb +++ b/app/helpers/homework_commons_helper.rb @@ -1,21 +1,5 @@ module HomeworkCommonsHelper - # 实训作品的单个关卡得分 - def work_challenge_score student_work, game, score, homework - result = 0 - adjust_score = student_work.challenge_work_scores.where(challenge_id: game.challenge_id).last - if adjust_score.present? - result = adjust_score.score - else - setting = homework.homework_group_setting student_work.user_id - if game.status == 2 && ((game.end_time && game.end_time < setting.end_time) || (homework.allow_late && game.end_time && game.end_time < homework.late_time)) - answer_open_evaluation = homework.homework_detail_manual.answer_open_evaluation - result = answer_open_evaluation ? score : (game.final_score > 0 ? game.real_score(score) : 0) - end - end - result - end - # 未发布时非老师角色不能访问,发布后非课堂成员不能访问未公开的作业,学生需要考虑分班设置的作业是否已发布 def homework_publish if (@user_course_identity >= Course::STUDENT && (@homework.publish_time.nil? || @homework.publish_time > Time.now)) || diff --git a/app/models/student_work.rb b/app/models/student_work.rb index d5b746ebd..0e41ce1ae 100644 --- a/app/models/student_work.rb +++ b/app/models/student_work.rb @@ -193,4 +193,19 @@ class StudentWork < ApplicationRecord def scored? student_works_scores.where.not(reviewer_role: 3).exists? end + + def work_challenge_score game, score + game_score = 0 + adjust_score = challenge_work_scores.where(challenge_id: game.challenge_id).last + if adjust_score.present? + game_score = adjust_score.score + else + setting = homework.homework_group_setting user_id + if game.status == 2 && ((game.end_time && game.end_time < setting.end_time) || (homework.allow_late && game.end_time && game.end_time < homework.late_time)) + answer_open_evaluation = homework.homework_detail_manual.answer_open_evaluation + game_score = answer_open_evaluation ? score : (game.final_score > 0 ? game.real_score(score) : 0) + end + end + game_score + end end diff --git a/app/views/homework_commons/code_review_detail.json.jbuilder b/app/views/homework_commons/code_review_detail.json.jbuilder index 4ebabf20a..f2cad7f3e 100644 --- a/app/views/homework_commons/code_review_detail.json.jbuilder +++ b/app/views/homework_commons/code_review_detail.json.jbuilder @@ -8,12 +8,19 @@ json.user_id @user.id json.user_login @user.login json.work_score @student_work.work_score + if @student_work.ultimate_score json.adjust_score @student_work.work_score < 0 ? 0 : number_with_precision(@student_work.work_score, precision: 1) else json.final_score @student_work.final_score json.late_penalty @student_work.late_penalty json.score @student_work.work_score < 0 ? 0 : number_with_precision(@student_work.work_score, precision: 1) + if @homework.work_efficiency + json.eff_score_full number_with_precision @homework.eff_score, precision: 1 + json.eff_score number_with_precision @work.eff_score, precision: 1 + json.challenge_score_full number_with_precision (100 - @homework.eff_score), precision: 1 + json.challenge_score number_with_precision @work.final_score, precision: 1 + end end json.challenge_list do diff --git a/app/views/student_works/shixun_work_report.json.jbuilder b/app/views/student_works/shixun_work_report.json.jbuilder index 103ead73f..05387125d 100644 --- a/app/views/student_works/shixun_work_report.json.jbuilder +++ b/app/views/student_works/shixun_work_report.json.jbuilder @@ -13,9 +13,9 @@ if @shixun json.evaluate_count @user_evaluate_count.to_i if @homework.work_efficiency json.eff_score_full number_with_precision @homework.eff_score, precision: 1 - json.eff_score @work.eff_score + json.eff_score number_with_precision @work.eff_score, precision: 1 json.challenge_score_full number_with_precision (100 - @homework.eff_score), precision: 1 - json.challenge_score @work.final_score + json.challenge_score number_with_precision @work.final_score, precision: 1 end # 阶段成绩 @@ -33,7 +33,7 @@ if @shixun json.challenge_id game.challenge_id challenge_score = @homework.challenge_score game.challenge_id json.game_score_full challenge_score - json.game_score work_challenge_score @work, game, challenge_score, @homework + json.game_score @work.work_challenge_score game, challenge_score end end From e9db5afd54fcd8e765c933a4aef454d9b32a0ea8 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Wed, 10 Jul 2019 11:33:21 +0800 Subject: [PATCH 15/26] =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/student_work.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/models/student_work.rb b/app/models/student_work.rb index 0e41ce1ae..9151ca501 100644 --- a/app/models/student_work.rb +++ b/app/models/student_work.rb @@ -200,9 +200,9 @@ class StudentWork < ApplicationRecord if adjust_score.present? game_score = adjust_score.score else - setting = homework.homework_group_setting user_id - if game.status == 2 && ((game.end_time && game.end_time < setting.end_time) || (homework.allow_late && game.end_time && game.end_time < homework.late_time)) - answer_open_evaluation = homework.homework_detail_manual.answer_open_evaluation + setting = homework_common.homework_group_setting user_id + if game.status == 2 && ((game.end_time && game.end_time < setting.end_time) || (homework_common.allow_late && game.end_time && game.end_time < homework_common.late_time)) + answer_open_evaluation = homework_common.homework_detail_manual.answer_open_evaluation game_score = answer_open_evaluation ? score : (game.final_score > 0 ? game.real_score(score) : 0) end end From a1d11910fe2932f11cf4d17ae4b9886396495527 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Wed, 10 Jul 2019 13:52:11 +0800 Subject: [PATCH 16/26] =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/homework_commons/code_review_detail.json.jbuilder | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/homework_commons/code_review_detail.json.jbuilder b/app/views/homework_commons/code_review_detail.json.jbuilder index f2cad7f3e..90d2c4a54 100644 --- a/app/views/homework_commons/code_review_detail.json.jbuilder +++ b/app/views/homework_commons/code_review_detail.json.jbuilder @@ -17,9 +17,9 @@ else json.score @student_work.work_score < 0 ? 0 : number_with_precision(@student_work.work_score, precision: 1) if @homework.work_efficiency json.eff_score_full number_with_precision @homework.eff_score, precision: 1 - json.eff_score number_with_precision @work.eff_score, precision: 1 + json.eff_score number_with_precision @student_work.eff_score, precision: 1 json.challenge_score_full number_with_precision (100 - @homework.eff_score), precision: 1 - json.challenge_score number_with_precision @work.final_score, precision: 1 + json.challenge_score number_with_precision @student_work.final_score, precision: 1 end end From bd099f2e1b4cce1edc309d107cc72b974e267c3e Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Wed, 10 Jul 2019 14:18:42 +0800 Subject: [PATCH 17/26] =?UTF-8?q?=E5=AE=9E=E8=AE=AD=E6=8A=A5=E5=91=8A?= =?UTF-8?q?=E5=92=8C=E4=BB=A3=E7=A0=81=E6=9F=A5=E9=87=8D=E8=AF=A6=E6=83=85?= =?UTF-8?q?=E9=A1=B5=E7=9A=84=E6=8E=A5=E5=8F=A3=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/student_works_controller.rb | 2 +- app/views/homework_commons/code_review_detail.json.jbuilder | 2 ++ app/views/student_works/adjust_review_score.json.jbuilder | 3 ++- app/views/student_works/shixun_work_report.json.jbuilder | 1 + 4 files changed, 6 insertions(+), 2 deletions(-) diff --git a/app/controllers/student_works_controller.rb b/app/controllers/student_works_controller.rb index 62d96c424..1c98db56c 100644 --- a/app/controllers/student_works_controller.rb +++ b/app/controllers/student_works_controller.rb @@ -631,7 +631,7 @@ class StudentWorksController < ApplicationController # 查重作品调分 def adjust_review_score - tip_exception("缺少type参数") if params[:type].blank? || ["review", "report"].include?(params[:type]) + tip_exception("缺少type参数") if params[:type].blank? || !["review", "report"].include?(params[:type]) if params[:type] == "review" && (params[:score].nil? || params[:challenge_id].nil? || params[:code_rate].nil? || params[:copy_user_id].nil?) tip_exception("参数错误,score和challenge_id和code_rate和copy_user_id不能为空") elsif params[:type] == "report" && (params[:score].nil? || params[:challenge_id].nil?) diff --git a/app/views/homework_commons/code_review_detail.json.jbuilder b/app/views/homework_commons/code_review_detail.json.jbuilder index 90d2c4a54..c33a906ec 100644 --- a/app/views/homework_commons/code_review_detail.json.jbuilder +++ b/app/views/homework_commons/code_review_detail.json.jbuilder @@ -2,6 +2,7 @@ json.course_id @course.id json.course_name @course.name json.homework_common_id @homework.id json.homework_common_name @homework.name +json.work_id @student_work.id json.work_name @student_work.name json.username @user.full_name json.user_id @user.id @@ -32,6 +33,7 @@ json.challenge_list do json.final_score challenge[:final_score] json.username challenge[:username] json.all_score challenge[:all_score] + json.copy_user_id challenge[:copy_user_id] json.copy_username challenge[:copy_username] json.copy_end_time challenge[:copy_end_time] json.code_rate challenge[:code_rate] diff --git a/app/views/student_works/adjust_review_score.json.jbuilder b/app/views/student_works/adjust_review_score.json.jbuilder index 399b52c13..928806bd6 100644 --- a/app/views/student_works/adjust_review_score.json.jbuilder +++ b/app/views/student_works/adjust_review_score.json.jbuilder @@ -1,3 +1,4 @@ json.status 0 json.message "调分成功" -json.work_score @work.work_score \ No newline at end of file +json.work_score number_with_precision @work.work_score, 1 +json.challenge_score number_with_precision @work.final_score, 1 \ No newline at end of file diff --git a/app/views/student_works/shixun_work_report.json.jbuilder b/app/views/student_works/shixun_work_report.json.jbuilder index 05387125d..e24092f05 100644 --- a/app/views/student_works/shixun_work_report.json.jbuilder +++ b/app/views/student_works/shixun_work_report.json.jbuilder @@ -1,6 +1,7 @@ json.homework_common_id @homework.id json.category @homework.category_info json.course_name @course.name +json.work_id @work.id if @shixun json.shixun_name @shixun.name # 总体评价 From a299eabdaf347fb6d71be65864864a0dd3912f9f Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Wed, 10 Jul 2019 14:55:57 +0800 Subject: [PATCH 18/26] =?UTF-8?q?=E5=AD=A6=E7=94=9F=E6=9F=A5=E7=9C=8B?= =?UTF-8?q?=E4=BD=9C=E5=93=81=E5=88=97=E8=A1=A8=E6=97=B6=E6=B3=A8=E6=84=8F?= =?UTF-8?q?=E5=8C=BF=E8=AF=84=E6=88=AA=E6=AD=A2=E4=B8=8E=E8=A1=A5=E4=BA=A4?= =?UTF-8?q?=E6=88=AA=E6=AD=A2=E7=9A=84=E6=97=B6=E9=97=B4=E5=B7=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/homework_commons_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/homework_commons_controller.rb b/app/controllers/homework_commons_controller.rb index b7291b647..767884d68 100644 --- a/app/controllers/homework_commons_controller.rb +++ b/app/controllers/homework_commons_controller.rb @@ -118,7 +118,7 @@ class HomeworkCommonsController < ApplicationController # 学生已提交作品且补交(提交)已截止、作品公开、非匿评阶段 if @work&.work_status.to_i > 0 && (@homework.work_public || @homework.score_open) && - ((!@homework.anonymous_comment && @homework.end_or_late) || @homework_detail_manual.comment_status > 4) + ((!@homework.anonymous_comment && @homework.end_or_late) || (@homework_detail_manual.comment_status > 4 && @homework.end_or_late)) @student_works = student_works.where("user_id != #{@work.user_id}") # 匿评、申诉阶段只能看到分配给自己的匿评作品 From 24799503e415a0c9c64bb4d9675fc087a46d775a Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Wed, 10 Jul 2019 14:57:40 +0800 Subject: [PATCH 19/26] =?UTF-8?q?=E8=AF=84=E9=98=85=E9=98=B6=E6=AE=B5?= =?UTF-8?q?=E4=B8=8D=E8=83=BD=E7=9C=8B=E5=8C=BF=E8=AF=84=E4=BD=9C=E5=93=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/homework_commons_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/homework_commons_controller.rb b/app/controllers/homework_commons_controller.rb index 767884d68..09d225496 100644 --- a/app/controllers/homework_commons_controller.rb +++ b/app/controllers/homework_commons_controller.rb @@ -122,7 +122,7 @@ class HomeworkCommonsController < ApplicationController @student_works = student_works.where("user_id != #{@work.user_id}") # 匿评、申诉阶段只能看到分配给自己的匿评作品 - elsif @work&.work_status.to_i > 0 && @homework.anonymous_comment && @homework_detail_manual.comment_status > 2 + elsif @work&.work_status.to_i > 0 && @homework.anonymous_comment && @homework_detail_manual.comment_status > 2 && @homework_detail_manual.comment_status <= 4 @is_evaluation = true @student_works = student_works.joins(:student_works_evaluation_distributions).where( "student_works_evaluation_distributions.user_id = #{@current_user.id}") From 1bfc279905387e0caf29cefe66472761d0ce8fc8 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Wed, 10 Jul 2019 15:36:52 +0800 Subject: [PATCH 20/26] =?UTF-8?q?=E8=AE=A1=E7=AE=97=E6=88=90=E7=BB=A9?= =?UTF-8?q?=E7=9A=84=E5=88=A4=E6=96=AD=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/homework_commons_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/homework_commons_controller.rb b/app/controllers/homework_commons_controller.rb index 09d225496..6f0f10f4d 100644 --- a/app/controllers/homework_commons_controller.rb +++ b/app/controllers/homework_commons_controller.rb @@ -240,7 +240,7 @@ class HomeworkCommonsController < ApplicationController end def update_score - tip_exception("作业还未发布,暂不能计算成绩") if @homework.end_or_late_none_group + tip_exception("作业还未发布,暂不能计算成绩") if @homework.publish_time.nil? || @homework.publish_time > Time.now begin if @homework.unified_setting student_works = @homework.student_works From e7cec7b8a34125769e8ada3ad35a7c6b2cc289f3 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Wed, 10 Jul 2019 15:51:30 +0800 Subject: [PATCH 21/26] =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/exercises_controller.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/exercises_controller.rb b/app/controllers/exercises_controller.rb index 9a7838a96..0b8e12094 100644 --- a/app/controllers/exercises_controller.rb +++ b/app/controllers/exercises_controller.rb @@ -1188,7 +1188,7 @@ class ExercisesController < ApplicationController elsif @user_course_identity > Course::ASSISTANT_PROFESSOR #当前为学生或者有过答题的(提交/未提交) @ex_user_end_time = @exercise.get_exercise_end_time(current_user.id) #当前用户所看到的剩余时间 @exercise_all_users = @exercise.get_stu_exercise_users - get_exercise_answers(@exercise_users_list, @exercise_status) # 未答和已答的 + get_exercise_answers(@exercise_all_users, @exercise_status) # 未答和已答的 exercise_current_user = @exercise_all_users.exercise_commit_users(current_user.id) #当前用户是否开始做试卷(提交/未提交/没做) if exercise_current_user.present? @exercise_current_user_status = 1 #当前用户的状态,为学生 @@ -1202,7 +1202,7 @@ class ExercisesController < ApplicationController end else @exercise_all_users = @exercise.get_stu_exercise_users - get_exercise_answers(@exercise_users_list, @exercise_status) # 未答和已答的 + get_exercise_answers(@exercise_all_users, @exercise_status) # 未答和已答的 @exercise_current_user_status = 2 #当前用户非课堂成员 @exercise_users_list = [] end From ef0953f86752a635e216eeef62ad5f2e80f163e7 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Wed, 10 Jul 2019 17:08:43 +0800 Subject: [PATCH 22/26] =?UTF-8?q?=E8=AF=95=E5=8D=B7=E8=AF=84=E9=98=85?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2=E7=9A=84=E5=88=86=E6=95=B0=E8=AF=84=E5=88=A4?= =?UTF-8?q?=E6=A0=87=E5=87=86=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/exercises_controller.rb | 1 + app/helpers/exercises_helper.rb | 28 ++++++++++++++++++++++--- 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/app/controllers/exercises_controller.rb b/app/controllers/exercises_controller.rb index 9a7838a96..68be45660 100644 --- a/app/controllers/exercises_controller.rb +++ b/app/controllers/exercises_controller.rb @@ -1040,6 +1040,7 @@ class ExercisesController < ApplicationController @exercise_questions = @exercise_questions.order("question_number ASC") end # 判断问题是否已回答还是未回答 + @exercise_questions = @exercise_questions.includes(:exercise_stand_answers,:exercise_answers,:exercise_shixun_answers) if @t_user_exercise_status == 3 get_each_student_exercise(@exercise.id,@exercise_questions,@exercise_current_user_id) diff --git a/app/helpers/exercises_helper.rb b/app/helpers/exercises_helper.rb index 0b64cb916..25255de85 100644 --- a/app/helpers/exercises_helper.rb +++ b/app/helpers/exercises_helper.rb @@ -9,11 +9,32 @@ module ExercisesHelper @ex_obj_array = [] exercise_obj_status.each do |q| if q.question_type == 5 - ques_score = q.exercise_shixun_answers.search_shixun_answers("user_id",user_id).pluck(:score).sum + answers_content = q.exercise_shixun_answers.search_shixun_answers("user_id",user_id) else - ques_score = q.exercise_answers.search_answer_users("user_id",user_id).score_reviewed.pluck(:score).sum + answers_content = q.exercise_answers.includes(:exercise_choices).search_answer_users("user_id",user_id) end + if q.question_type <= 2 + if answers_content.present? #学生有回答时 + answer_choice_array = [] + answers_content.each do |a| + answer_choice_array.push(a.exercise_choice.choice_position) #学生答案的位置 + end + user_answer_content = answer_choice_array.sort + standard_answer = q.exercise_standard_answers.pluck(:exercise_choice_id).sort #该问题的标准答案,可能有多个 + if user_answer_content == standard_answer #答案一致,多选或单选才给分,答案不对不给分 + ques_score = q.question_score + else + ques_score = 0.0 + end + else + ques_score = 0.0 + end + else + ques_score = answers_content.select(:score).pluck(:score).sum + end + + if ques_score >= q.question_score #满分作答为正确 ques_score = q.question_score stand_answer = 1 @@ -370,7 +391,8 @@ module ExercisesHelper standard_answer = q.exercise_standard_answers.pluck(:exercise_choice_id).sort #该问题的标准答案,可能有多个 if user_answer_content == standard_answer #答案一致,多选或单选才给分,答案不对不给分 if standard_answer.count > 0 - q_score_1 = (q.question_score.to_f / standard_answer.count) #当多选答案正确时,每个answer的分数均摊。 + q_score_1 = q.question_score + # q_score_1 = (q.question_score.to_f / standard_answer.count) #当多选答案正确时,每个answer的分数均摊。 else q_score_1 = 0.0 end From 88a85bff7db9c71a0ace287606a1f9515102e25d Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Wed, 10 Jul 2019 17:12:17 +0800 Subject: [PATCH 23/26] fixbug --- app/helpers/exercises_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/helpers/exercises_helper.rb b/app/helpers/exercises_helper.rb index 25255de85..018bc2c39 100644 --- a/app/helpers/exercises_helper.rb +++ b/app/helpers/exercises_helper.rb @@ -11,7 +11,7 @@ module ExercisesHelper if q.question_type == 5 answers_content = q.exercise_shixun_answers.search_shixun_answers("user_id",user_id) else - answers_content = q.exercise_answers.includes(:exercise_choices).search_answer_users("user_id",user_id) + answers_content = q.exercise_answers.search_answer_users("user_id",user_id) end if q.question_type <= 2 From e7da0d9be83609256420292bd2822a03e8ad20dd Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Wed, 10 Jul 2019 17:39:59 +0800 Subject: [PATCH 24/26] fixbug --- app/controllers/exercises_controller.rb | 2 +- app/helpers/exercises_helper.rb | 30 +++++++++++++++++++------ 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/app/controllers/exercises_controller.rb b/app/controllers/exercises_controller.rb index 4be76fc59..6af48dbd1 100644 --- a/app/controllers/exercises_controller.rb +++ b/app/controllers/exercises_controller.rb @@ -1130,7 +1130,7 @@ class ExercisesController < ApplicationController @is_teacher_or = @user_course_identity < Course::STUDENT ? 1 : 0 @student_status = 2 # @exercise_answerer = User.find_by(id:@exercise_current_user_id) #试卷回答者 - @exercise_questions = @exercise.exercise_questions.order("question_number ASC") + @exercise_questions = @exercise.exercise_questions.includes(:exercise_shixun_challenges,:exercise_standard_answers,:exercise_answers,:exercise_shixun_answers).order("question_number ASC") @question_status = [] get_exercise_status = @exercise.get_exercise_status(current_user) if @ex_user.present? && @is_teacher_or == 0 diff --git a/app/helpers/exercises_helper.rb b/app/helpers/exercises_helper.rb index 018bc2c39..314a90403 100644 --- a/app/helpers/exercises_helper.rb +++ b/app/helpers/exercises_helper.rb @@ -34,7 +34,6 @@ module ExercisesHelper ques_score = answers_content.select(:score).pluck(:score).sum end - if ques_score >= q.question_score #满分作答为正确 ques_score = q.question_score stand_answer = 1 @@ -663,6 +662,7 @@ module ExercisesHelper user_score = nil shixun_type = 0 question_comment = [] + # user_score_pre = nil if ques_type == 5 exercise_answers = q.exercise_shixun_answers.search_shixun_answers("user_id",ex_answerer_id) else @@ -670,10 +670,26 @@ module ExercisesHelper end if student_status == 2 #当前为老师,或为学生且已提交 user_score_pre = exercise_answers.score_reviewed - if ques_type == 4 && user_score_pre.blank? #主观题时,且没有大于0的分数时,为空 - user_score = nil - else + if ques_type == 4 #主观题时,且没有大于0的分数时,为空 + user_score = user_score_pre.present? ? user_score_pre.pluck(:score).sum : nil + elsif ques_type == 5 || ques_type == 3 user_score = user_score_pre.present? ? user_score_pre.pluck(:score).sum : 0.0 + else + if exercise_answers.present? #判断题和选择题时, + answer_choice_array = [] + exercise_answers.each do |a| + answer_choice_array.push(a.exercise_choice.choice_position) #学生答案的位置 + end + user_answer_content = answer_choice_array.sort + standard_answer = q.exercise_standard_answers.pluck(:exercise_choice_id).sort #该问题的标准答案,可能有多个 + if user_answer_content == standard_answer #答案一致,多选或单选才给分,答案不对不给分 + user_score = q.question_score + else + user_score = 0.0 + end + else + user_score = 0.0 + end end end @@ -681,9 +697,9 @@ module ExercisesHelper user_score = q.question_score end if ques_type <= 2 - answered_content = exercise_answers.pluck(:exercise_choice_id) + answered_content = exercise_answers&.pluck(:exercise_choice_id) elsif ques_type == 3 - exercise_answers.each do |a| + exercise_answers&.each do |a| u_answer = { "choice_id":a.exercise_choice_id, "answer_text": a.answer_text @@ -691,7 +707,7 @@ module ExercisesHelper answered_content.push(u_answer) end elsif ques_type == 4 - answered_content = exercise_answers.pluck(:answer_text) + answered_content = exercise_answers&.pluck(:answer_text) end if ques_type == 5 #存在实训题,及已经做了实训题的 if ex_status == 3 || is_teacher_or == 1 #如果试卷已截止,则可以看到分数,否则不能查看分数 From 092ececc96b12f491b1c9f5d1025a7bf2d63e8e5 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Thu, 11 Jul 2019 09:26:26 +0800 Subject: [PATCH 25/26] =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=AF=95=E8=AE=BE?= =?UTF-8?q?=E9=80=89=E9=A2=98=E6=9D=83=E9=99=90=E4=B8=8D=E5=A4=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/commons_controller.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/commons_controller.rb b/app/controllers/commons_controller.rb index 1f6dce053..fa5e14dc1 100644 --- a/app/controllers/commons_controller.rb +++ b/app/controllers/commons_controller.rb @@ -44,8 +44,8 @@ class CommonsController < ApplicationController def validate_power code = case params[:object_type].strip - when 'message' - if current_user.course_identity(@object.board.course) >= 5 && @object.author != current_user + when 'message', 'journals_for_message' + if current_user.course_identity(@object.board.course) >= Course::STUDENT && @object.author != current_user 403 else 200 From 036037df2246bff68671d2efb6400bdccad6f1d2 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Thu, 11 Jul 2019 09:31:49 +0800 Subject: [PATCH 26/26] =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E5=88=A0=E9=99=A4?= =?UTF-8?q?=E5=B8=96=E5=AD=90=E6=9D=83=E9=99=90=E6=8E=A7=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/commons_controller.rb | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/app/controllers/commons_controller.rb b/app/controllers/commons_controller.rb index fa5e14dc1..a23d4dba7 100644 --- a/app/controllers/commons_controller.rb +++ b/app/controllers/commons_controller.rb @@ -44,12 +44,18 @@ class CommonsController < ApplicationController def validate_power code = case params[:object_type].strip - when 'message', 'journals_for_message' + when 'message' if current_user.course_identity(@object.board.course) >= Course::STUDENT && @object.author != current_user 403 else 200 end + when 'journals_for_message' + if current_user.course_identity(@object.jour.course) >= Course::STUDENT && @object.user != current_user + 403 + else + 200 + end else current_user.admin? ? 200 : 403 end