From a8fb8c32f3688efe360d748d3af6769aef7971c0 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Wed, 26 Jun 2019 16:43:06 +0800 Subject: [PATCH 001/256] fix bug --- app/views/polls/commit_result.xlsx.axlsx | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/app/views/polls/commit_result.xlsx.axlsx b/app/views/polls/commit_result.xlsx.axlsx index be27d73c5..f949af10a 100644 --- a/app/views/polls/commit_result.xlsx.axlsx +++ b/app/views/polls/commit_result.xlsx.axlsx @@ -30,19 +30,19 @@ wb.styles do |s| sheet_answer_row.push(answer_users_count) sheet_answer_percent.push(answer_percent.to_s) end - sheet.add_row sheet_row, :style => blue_cell - sheet.add_row sheet_answer_row, :style => sz_all - sheet.add_row sheet_answer_percent, :style => sz_all - sheet.add_row sheet_answer_useful, :style => sz_all + sheet.add_row sheet_row, :height =>20,:style => blue_cell + sheet.add_row sheet_answer_row, :height =>20, :style => sz_all + sheet.add_row sheet_answer_percent, :height =>20, :style => sz_all + sheet.add_row sheet_answer_useful, :height =>20, :style => sz_all #合并单元格,但无法填充style # sheet.merge_cells (Axlsx::cell_r(1,sheet.rows.last.row_index) + ':' + Axlsx::cell_r(sheet_row.count-1,sheet.rows.last.row_index)) # sheet.rows[sheet.rows.last.row_index].style = sz_all sheet.add_row [] else #主观题答案 main_show_row = ["第#{q.question_number}题",q.question_title] - sheet.add_row main_show_row, :style => blue_cell + sheet.add_row main_show_row,:height =>20, :style => blue_cell q.poll_votes.each do |v| #主观题的答案 - sheet.add_row ["",v.vote_text.present? ? v.vote_text : "--"], :style => sz_all + sheet.add_row ["",v.vote_text.present? ? v.vote_text : "--"],:height =>20, :style => sz_all end sheet.add_row [], :style => sz_all end @@ -86,7 +86,7 @@ wb.styles do |s| user_cell += [user_login,user_name, u_user.mail, user_student_id] end all_user_cell = user_cell + user_answer_array - sheet.add_row all_user_cell, :style => sz_all + sheet.add_row all_user_cell, :height =>20,:style => sz_all end sheet.column_widths *([25]*sheet.column_info.count) sheet.column_info.first.width = 10 From 7b51084c374cc83188ee4de02cfa9f496f72df22 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Wed, 26 Jun 2019 16:49:00 +0800 Subject: [PATCH 002/256] fix bug --- app/views/polls/commit_result.xlsx.axlsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/polls/commit_result.xlsx.axlsx b/app/views/polls/commit_result.xlsx.axlsx index f949af10a..9c91b63a0 100644 --- a/app/views/polls/commit_result.xlsx.axlsx +++ b/app/views/polls/commit_result.xlsx.axlsx @@ -2,8 +2,8 @@ wb = xlsx_package.workbook # wb.use_autowidth = false wb.styles do |s| - sz_all = s.add_style :sz => 10,:border => { :style => :thin, :color =>"000000"},:alignment => {:horizontal => :left} - blue_cell = s.add_style :bg_color => "FAEBDC", :sz => 10,:height => 20,:b => true, :border => { :style => :thin, :color =>"000000" },:alignment => {:horizontal => :left} + sz_all = s.add_style :sz => 10,:border => { :style => :thin, :color =>"000000"},:alignment => {wrap_text: true,:horizontal => :left} + blue_cell = s.add_style :bg_color => "FAEBDC", :sz => 10,:height => 20,:b => true, :border => { :style => :thin, :color =>"000000" },:alignment => {wrap_text: true,:horizontal => :left} wb.add_worksheet(:name => "统计结果") do |sheet| sheet.sheet_view.show_grid_lines = false From 6b66be9e60b26ff522dd79307060f40bc2649ffd Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Wed, 26 Jun 2019 16:52:05 +0800 Subject: [PATCH 003/256] fix bug --- app/views/polls/commit_result.xlsx.axlsx | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/app/views/polls/commit_result.xlsx.axlsx b/app/views/polls/commit_result.xlsx.axlsx index 9c91b63a0..3ea0571cb 100644 --- a/app/views/polls/commit_result.xlsx.axlsx +++ b/app/views/polls/commit_result.xlsx.axlsx @@ -30,25 +30,25 @@ wb.styles do |s| sheet_answer_row.push(answer_users_count) sheet_answer_percent.push(answer_percent.to_s) end - sheet.add_row sheet_row, :height =>20,:style => blue_cell - sheet.add_row sheet_answer_row, :height =>20, :style => sz_all - sheet.add_row sheet_answer_percent, :height =>20, :style => sz_all - sheet.add_row sheet_answer_useful, :height =>20, :style => sz_all + sheet.add_row sheet_row, :height =>15,:style => blue_cell + sheet.add_row sheet_answer_row, :height =>15, :style => sz_all + sheet.add_row sheet_answer_percent, :height =>15, :style => sz_all + sheet.add_row sheet_answer_useful, :height =>15, :style => sz_all #合并单元格,但无法填充style # sheet.merge_cells (Axlsx::cell_r(1,sheet.rows.last.row_index) + ':' + Axlsx::cell_r(sheet_row.count-1,sheet.rows.last.row_index)) # sheet.rows[sheet.rows.last.row_index].style = sz_all sheet.add_row [] else #主观题答案 main_show_row = ["第#{q.question_number}题",q.question_title] - sheet.add_row main_show_row,:height =>20, :style => blue_cell + sheet.add_row main_show_row,:height =>15, :style => blue_cell q.poll_votes.each do |v| #主观题的答案 - sheet.add_row ["",v.vote_text.present? ? v.vote_text : "--"],:height =>20, :style => sz_all + sheet.add_row ["",v.vote_text.present? ? v.vote_text : "--"],:height =>15, :style => sz_all end sheet.add_row [], :style => sz_all end end #each_with_index - sheet.add_row poll_users_info, :style => blue_cell + sheet.add_row poll_users_info, :height =>15, :style => blue_cell @poll.poll_users.each_with_index do |u,index| u_user = u.user user_answer_array = [] @@ -86,7 +86,7 @@ wb.styles do |s| user_cell += [user_login,user_name, u_user.mail, user_student_id] end all_user_cell = user_cell + user_answer_array - sheet.add_row all_user_cell, :height =>20,:style => sz_all + sheet.add_row all_user_cell, :height =>15,:style => sz_all end sheet.column_widths *([25]*sheet.column_info.count) sheet.column_info.first.width = 10 From aa8b8accc11ffcab96a4c92979da0984e8ab07c2 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Wed, 26 Jun 2019 17:08:12 +0800 Subject: [PATCH 004/256] =?UTF-8?q?=E5=8C=BF=E8=AF=84=E4=BD=9C=E5=93=81?= =?UTF-8?q?=E5=88=97=E8=A1=A8=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 | 10 ++++++++++ .../homework_commons/works_list.json.jbuilder | 18 ++++++++++++------ 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/app/models/student_work.rb b/app/models/student_work.rb index 0e674dd4c..8acc2e098 100644 --- a/app/models/student_work.rb +++ b/app/models/student_work.rb @@ -59,6 +59,16 @@ class StudentWork < ApplicationRecord group_by(&:user_id).count : 0 end + # 当前用户该作品的匿评申诉总条数 + def my_appeal_all_count user_id + student_works_scores.where("reviewer_role = 3 and appeal_status != 0 and user_id = #{user_id}").size + end + + # 当前用户该作品的匿评申诉总条数 + def my_appeal_deal_count user_id + student_works_scores.where("reviewer_role = 3 and appeal_status = 1 and user_id = #{user_id}").size + end + # 分组名 def work_group_name self.group_id == 0 ? "--" : "分组#{self.group_id}" diff --git a/app/views/homework_commons/works_list.json.jbuilder b/app/views/homework_commons/works_list.json.jbuilder index 42d4abf48..716b12190 100644 --- a/app/views/homework_commons/works_list.json.jbuilder +++ b/app/views/homework_commons/works_list.json.jbuilder @@ -106,6 +106,12 @@ elsif @homework.homework_type == "group" || @homework.homework_type == "normal" json.student_score work_score_format(anon_comments(@current_user, work.id).last.try(:score), false, true) # json.student_comment_count anon_comments(@current_user, work.id).count + + # 申诉条数 + if @homework.anonymous_appeal + json.appeal_all_count work.my_appeal_all_count @current_user.id + json.appeal_deal_count work.my_appeal_deal_count @current_user.id + end else json.(work, :id, :work_status, :update_time, :work_score, :final_score, :teacher_score, :student_score, :teaching_asistant_score, :ultimate_score) @@ -134,13 +140,13 @@ elsif @homework.homework_type == "group" || @homework.homework_type == "normal" end json.work_group work.work_group_name end - end - # 申诉条数 - if @homework.anonymous_appeal - json.appeal_all_count work.appeal_all_count - json.appeal_deal_count work.appeal_deal_count - json.appeal_penalty work.appeal_penalty + # 申诉条数 + if @homework.anonymous_appeal + json.appeal_all_count work.appeal_all_count + json.appeal_deal_count work.appeal_deal_count + json.appeal_penalty work.appeal_penalty + end end json.user_login @is_evaluation ? "--" : work.user.try(:login) From 665791f4720cf24050ccc4bef4159652856ca266 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Wed, 26 Jun 2019 17:12:20 +0800 Subject: [PATCH 005/256] =?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/myshixun.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/models/myshixun.rb b/app/models/myshixun.rb index e4573f3dd..a1aca3253 100644 --- a/app/models/myshixun.rb +++ b/app/models/myshixun.rb @@ -74,12 +74,12 @@ class Myshixun < ApplicationRecord # 个人实训得分 def total_score - self.games.select{|game| game.status = 2 && game.final_score > 0}.pluck(:final_score).sum.to_i + self.games.select{|game| game.status == 2 && game.final_score > 0}.pluck(:final_score).sum.to_i end # 个人通关数 def passed_count - self.games.select{|game| game.status = 2}.size + self.games.select{|game| game.status == 2}.size end # 通关时间 @@ -94,7 +94,7 @@ class Myshixun < ApplicationRecord # 通关总耗时 def total_cost_time - self.games.select{|game| game.status = 2}.map(&:cost_time).sum.to_i + self.games.select{|game| game.status == 2}.map(&:cost_time).sum.to_i end end From d44ada37510e85bb0b00cc857e85f4d17ed71358 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Wed, 26 Jun 2019 17:24:38 +0800 Subject: [PATCH 006/256] check poll_user create --- app/controllers/polls_controller.rb | 3 ++- app/views/polls/poll_lists.json.jbuilder | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/app/controllers/polls_controller.rb b/app/controllers/polls_controller.rb index 675e3283c..be3316df6 100644 --- a/app/controllers/polls_controller.rb +++ b/app/controllers/polls_controller.rb @@ -951,6 +951,7 @@ class PollsController < ApplicationController def poll_lists ActiveRecord::Base.transaction do begin + @poll_new_users = @poll.poll_users.find_by(user_id:current_user.id) poll_ids = [@poll.id] @poll_list_status = @poll.get_poll_status(current_user.id) @poll_publish_count = get_user_permission_course(poll_ids,2).count @@ -1184,7 +1185,7 @@ class PollsController < ApplicationController def check_poll_commit_result poll_status = @poll.get_poll_status(current_user.id) commit_poll_user = @poll.poll_users.find_by_group_ids(current_user.id).commit_by_status(1) #当前用户已提交问卷的 - unless @user_course_identity < Course::STUDENT || (@poll.show_result && poll_status == 3 && commit_poll_user.present?) + unless (@user_course_identity < Course::STUDENT) || (@poll.show_result && poll_status == 3 && commit_poll_user.present?) normal_status(-1,"没有权限!") #当前为老师/问卷公开统计,且问卷已截止,且用户有过回答的 end end diff --git a/app/views/polls/poll_lists.json.jbuilder b/app/views/polls/poll_lists.json.jbuilder index f134967c9..b83e767a1 100644 --- a/app/views/polls/poll_lists.json.jbuilder +++ b/app/views/polls/poll_lists.json.jbuilder @@ -1,7 +1,7 @@ json.course do json.partial! "polls/course_name",locals:{course:@course} end - +json.current_poll_user @poll_new_users.present? ? @poll_new_users.id : "---" json.poll_types do if @poll_current_user_status == 0 json.published_count @poll_publish_count From 939a536d3a916de320fd53141ea38526e547f000 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Wed, 26 Jun 2019 18:29:45 +0800 Subject: [PATCH 007/256] fix bug --- app/controllers/exercises_controller.rb | 2 +- app/controllers/polls_controller.rb | 3 +-- app/views/polls/poll_lists.json.jbuilder | 1 - 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/app/controllers/exercises_controller.rb b/app/controllers/exercises_controller.rb index f10bc81ff..5fa5296d5 100644 --- a/app/controllers/exercises_controller.rb +++ b/app/controllers/exercises_controller.rb @@ -402,7 +402,7 @@ class ExercisesController < ApplicationController :position => c.position, :challenge_id => c.challenge_id, :shixun_id => q.shixun_id, - :question_score => q.question_score + :question_score => c.question_score } shixun_challenge_bank = exercise_bank_question.exercise_bank_shixun_challenges.new challenge_option shixun_challenge_bank.save diff --git a/app/controllers/polls_controller.rb b/app/controllers/polls_controller.rb index be3316df6..119226c87 100644 --- a/app/controllers/polls_controller.rb +++ b/app/controllers/polls_controller.rb @@ -951,7 +951,6 @@ class PollsController < ApplicationController def poll_lists ActiveRecord::Base.transaction do begin - @poll_new_users = @poll.poll_users.find_by(user_id:current_user.id) poll_ids = [@poll.id] @poll_list_status = @poll.get_poll_status(current_user.id) @poll_publish_count = get_user_permission_course(poll_ids,2).count @@ -1185,7 +1184,7 @@ class PollsController < ApplicationController def check_poll_commit_result poll_status = @poll.get_poll_status(current_user.id) commit_poll_user = @poll.poll_users.find_by_group_ids(current_user.id).commit_by_status(1) #当前用户已提交问卷的 - unless (@user_course_identity < Course::STUDENT) || (@poll.show_result && poll_status == 3 && commit_poll_user.present?) + unless (@user_course_identity < Course::STUDENT) || ((@poll.show_result == 1) && (poll_status == 3) && commit_poll_user.present?) normal_status(-1,"没有权限!") #当前为老师/问卷公开统计,且问卷已截止,且用户有过回答的 end end diff --git a/app/views/polls/poll_lists.json.jbuilder b/app/views/polls/poll_lists.json.jbuilder index b83e767a1..1ebccffeb 100644 --- a/app/views/polls/poll_lists.json.jbuilder +++ b/app/views/polls/poll_lists.json.jbuilder @@ -1,7 +1,6 @@ json.course do json.partial! "polls/course_name",locals:{course:@course} end -json.current_poll_user @poll_new_users.present? ? @poll_new_users.id : "---" json.poll_types do if @poll_current_user_status == 0 json.published_count @poll_publish_count From 3587b33a81a7640f15a40d89ef8fce98199541d5 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Wed, 26 Jun 2019 18:52:11 +0800 Subject: [PATCH 008/256] fixbug --- app/helpers/exercises_helper.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/helpers/exercises_helper.rb b/app/helpers/exercises_helper.rb index 9ea7578f2..e0db9c2bf 100644 --- a/app/helpers/exercises_helper.rb +++ b/app/helpers/exercises_helper.rb @@ -13,7 +13,8 @@ module ExercisesHelper ques_score = q.exercise_answers.search_answer_users("user_id",user_id).score_reviewed.pluck(:score).sum end - if ques_score == q.question_score #满分作答为正确 + if ques_score >= q.question_score #满分作答为正确 + ques_score = q.question_score stand_answer = 1 elsif ques_score > 0.0 #部分作答 stand_answer = 2 @@ -35,7 +36,8 @@ module ExercisesHelper exercise_sub_status.each do |s| sub_answer = s.exercise_answers.search_answer_users("user_id",user_id) #主观题只有一个回答 if sub_answer.present? && sub_answer.first.score >= 0.0 - if s.question_score == sub_answer.first.score + + if s.question_score <= sub_answer.first.score stand_status = 1 else stand_status = 2 From 82f63e712ffe89a2f909362d704af0c916f536d4 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Thu, 27 Jun 2019 09:02:41 +0800 Subject: [PATCH 009/256] fix bug --- app/models/poll.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/models/poll.rb b/app/models/poll.rb index b498eda4e..ce5da17dd 100644 --- a/app/models/poll.rb +++ b/app/models/poll.rb @@ -145,7 +145,8 @@ class Poll < ApplicationRecord end if poll_answer_user.present? && poll_answer_user.start_at.blank? && user_poll_status == 3 - user_status = 4 + # user_status = 4 + user_status = 5 #问卷用户存在,且未开始答题,且问卷已截止时,返回未提交标示 end user_status From 17527970fc1f1fb37fe0672fb343f9ff03f322fc Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Thu, 27 Jun 2019 09:16:22 +0800 Subject: [PATCH 010/256] =?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/homework_common.rb | 5 ++--- app/models/student_work.rb | 16 ++++++++-------- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/app/models/homework_common.rb b/app/models/homework_common.rb index 9ed80e746..d55973ed8 100644 --- a/app/models/homework_common.rb +++ b/app/models/homework_common.rb @@ -78,8 +78,7 @@ class HomeworkCommon < ApplicationRecord # 根据是否统一发布获取作业的作品列表 def all_works student_works = self.unified_setting ? self.student_works : - self.student_works.joins("join course_members on student_works.user_id=course_members.user_id"). - where(course_members: {course_group_id: self.published_settings.pluck(:course_group_id)}) + self.student_works.joins("join course_members on student_works.user_id=course_members.user_id").where(course_members: {course_group_id: self.published_settings.pluck(:course_group_id)}) end # 分班权限的老师可见的作品列表 @@ -90,7 +89,7 @@ class HomeworkCommon < ApplicationRecord # 有分班权限的统计管理的分班且已发布的学生情况 if member.present? && teacher_course_groups.size > 0 group_ids = teacher_course_groups.pluck(:course_group_id) - all_student_works = all_student_works.joins("join course_members course_members on student_works.user_id=course_members.user_id"). + all_student_works = all_student_works.joins("join course_members on student_works.user_id=course_members.user_id"). where(course_members: {course_group_id: group_ids}) end all_student_works diff --git a/app/models/student_work.rb b/app/models/student_work.rb index 8acc2e098..a2379f1a8 100644 --- a/app/models/student_work.rb +++ b/app/models/student_work.rb @@ -39,34 +39,34 @@ class StudentWork < ApplicationRecord # 助教评分次数 def ta_comment_count - self.student_works_scores.where(reviewer_role: 2).group_by(&:user_id).count + self.student_works_scores.select{|score| score.reviewer_role == 2}.group_by(&:user_id).count end # 匿评次数 def student_comment_num - homework_common.homework_detail_manual.comment_status > 2 ? self.student_works_scores.where(reviewer_role: 3).group_by(&:user_id).count : 0 + homework_common.homework_detail_manual.comment_status > 2 ? self.student_works_scores.select{|score| score.reviewer_role == 3}.group_by(&:user_id).count : 0 end # 匿评申诉总条数 def appeal_all_count - homework_common.homework_detail_manual.comment_status >= 3 ? self.student_works_scores.where("reviewer_role = 3 and appeal_status != 0"). - group_by(&:user_id).count : 0 + homework_common.homework_detail_manual.comment_status >= 3 ? self.student_works_scores. + select{|score| score.reviewer_role == 3 && score.appeal_status != 0}.group_by(&:user_id).count : 0 end # 匿评申诉待处理条数 def appeal_deal_count - homework_common.homework_detail_manual.comment_status >= 3 ? self.student_works_scores.where("reviewer_role = 3 and appeal_status = 1"). - group_by(&:user_id).count : 0 + homework_common.homework_detail_manual.comment_status >= 3 ? self.student_works_scores. + select{|score| score.reviewer_role == 3 && score.appeal_status == 1}.group_by(&:user_id).count : 0 end # 当前用户该作品的匿评申诉总条数 def my_appeal_all_count user_id - student_works_scores.where("reviewer_role = 3 and appeal_status != 0 and user_id = #{user_id}").size + student_works_scores.select{|score| score.reviewer_role == 3 && score.appeal_status != 0 && score.user_id = user_id}.size end # 当前用户该作品的匿评申诉总条数 def my_appeal_deal_count user_id - student_works_scores.where("reviewer_role = 3 and appeal_status = 1 and user_id = #{user_id}").size + student_works_scores.select{|score| score.reviewer_role == 3 && score.appeal_status == 1 && score.user_id = user_id}.size end # 分组名 From bc3291d00bef43ef32645de2f85ffcdf2cad59e7 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Thu, 27 Jun 2019 09:23:04 +0800 Subject: [PATCH 011/256] =?UTF-8?q?=E8=BF=81=E7=A7=BB=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/graduation_topics_controller.rb | 4 ++-- app/controllers/question_banks_controller.rb | 2 +- db/migrate/20190627012117_modify_quotes_for_gtopic_banks.rb | 5 +++++ 3 files changed, 8 insertions(+), 3 deletions(-) create mode 100644 db/migrate/20190627012117_modify_quotes_for_gtopic_banks.rb diff --git a/app/controllers/graduation_topics_controller.rb b/app/controllers/graduation_topics_controller.rb index ce4488ffd..7a61613da 100644 --- a/app/controllers/graduation_topics_controller.rb +++ b/app/controllers/graduation_topics_controller.rb @@ -173,7 +173,7 @@ class GraduationTopicsController < ApplicationController member = @course.course_members.where(:user_id => @graduation_topic.tea_id).first tip_exception("分班名称不能为空") if params[:course_group_name].blank? course_group = CourseGroup.create(:name => params[:course_group_name], :course_id => @course.id) - teacher_group = TeacherCourseGroup.create(:course_id => @course.id, :member_id => member.try(:id), + teacher_group = TeacherCourseGroup.create(:course_id => @course.id, :course_member_id => member.try(:id), :user_id => @graduation_topic.tea_id, :course_group_id => course_group.try(:id)) end @@ -195,7 +195,7 @@ class GraduationTopicsController < ApplicationController user_unaccept_topics = @course.student_graduation_topics.where(user_id: current_user.id, status: [0, 1]) if user_unaccept_topics.size == 0 member_id = @course.course_members.find_by_user_id(current_user.id) - StudentGraduationTopic.create(course_id: @course.id, user_id: current_user.id, member_id: member_id, + StudentGraduationTopic.create(course_id: @course.id, user_id: current_user.id, course_member_id: member_id, graduation_topic_id: @graduation_topic.id) @graduation_topic.update_attribute(:status, 1) normal_status("选题成功") diff --git a/app/controllers/question_banks_controller.rb b/app/controllers/question_banks_controller.rb index 740e3a993..4df392257 100644 --- a/app/controllers/question_banks_controller.rb +++ b/app/controllers/question_banks_controller.rb @@ -266,7 +266,7 @@ class QuestionBanksController < ApplicationController def quote_gtopic_bank topic, course ActiveRecord::Base.transaction do new_topic = GraduationTopic.new - new_topic.attributes = topic.attributes.dup.except("id", "course_id", "user_id", "graduation_topic_id", + new_topic.attributes = topic.attributes.dup.except("id", "course_id", "user_id", "graduation_topic_id", "quotes", "course_list_id", "gtopic_bank_id", "created_at", "updated_at") new_topic.course_id = course.id new_topic.gtopic_bank_id = topic.id diff --git a/db/migrate/20190627012117_modify_quotes_for_gtopic_banks.rb b/db/migrate/20190627012117_modify_quotes_for_gtopic_banks.rb new file mode 100644 index 000000000..4c475fd8f --- /dev/null +++ b/db/migrate/20190627012117_modify_quotes_for_gtopic_banks.rb @@ -0,0 +1,5 @@ +class ModifyQuotesForGtopicBanks < ActiveRecord::Migration[5.2] + def change + change_column :gtopic_banks, :quotes, :integer, :default => 0 + end +end From 0b1049e319f1eb78c3f2b1b741c82f234e45a8d7 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Thu, 27 Jun 2019 09:26:42 +0800 Subject: [PATCH 012/256] =?UTF-8?q?=E8=BF=81=E7=A7=BB=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...banks.rb => 20190627012118_modify_quotes_for_gtopic_banks.rb} | 1 + 1 file changed, 1 insertion(+) rename db/migrate/{20190627012117_modify_quotes_for_gtopic_banks.rb => 20190627012118_modify_quotes_for_gtopic_banks.rb} (70%) diff --git a/db/migrate/20190627012117_modify_quotes_for_gtopic_banks.rb b/db/migrate/20190627012118_modify_quotes_for_gtopic_banks.rb similarity index 70% rename from db/migrate/20190627012117_modify_quotes_for_gtopic_banks.rb rename to db/migrate/20190627012118_modify_quotes_for_gtopic_banks.rb index 4c475fd8f..a47157414 100644 --- a/db/migrate/20190627012117_modify_quotes_for_gtopic_banks.rb +++ b/db/migrate/20190627012118_modify_quotes_for_gtopic_banks.rb @@ -1,5 +1,6 @@ class ModifyQuotesForGtopicBanks < ActiveRecord::Migration[5.2] def change + GtopicBank.where("quotes is null").update_all(:quotes => 0) change_column :gtopic_banks, :quotes, :integer, :default => 0 end end From 26919424e09a72f7c24fd377494eb7759f1838bc Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Thu, 27 Jun 2019 09:33:53 +0800 Subject: [PATCH 013/256] fix bug --- app/controllers/exercises_controller.rb | 12 ++++++------ app/helpers/polls_helper.rb | 4 ++-- app/models/poll.rb | 12 ++++++------ 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/app/controllers/exercises_controller.rb b/app/controllers/exercises_controller.rb index 5fa5296d5..44b694239 100644 --- a/app/controllers/exercises_controller.rb +++ b/app/controllers/exercises_controller.rb @@ -32,13 +32,13 @@ class ExercisesController < ApplicationController @exercises_all = @course.exercises member_show_exercises = @exercises_all.is_exercise_published #已发布的或已截止的试卷 @current_user_ = current_user - @exercises_count = @exercises_all.count # 全部页面,需返回 - @exercises_unpublish_counts = @exercises_all.exercise_by_status(1).count #未发布的试卷数 - @exercises_published_counts = @exercises_all.exercise_by_status([2,3]).count # 已发布的试卷数,包含已截止的 - @exercises_ended_counts = @exercises_all.exercise_by_status(3).count #已截止的试卷数 + @exercises_count = @exercises_all.size # 全部页面,需返回 + @exercises_unpublish_counts = @exercises_all.exercise_by_status(1).size #未发布的试卷数 + @exercises_published_counts = @exercises_all.exercise_by_status([2,3]).size # 已发布的试卷数,包含已截止的 + @exercises_ended_counts = @exercises_all.exercise_by_status(3).size #已截止的试卷数 # 课堂的学生人数 @course_all_members = @course.students #当前课堂的全部学生 - @course_all_members_count = @course_all_members.count #当前课堂的学生数 + @course_all_members_count = @course_all_members.size #当前课堂的学生数 @current_student = @course_all_members.course_find_by_ids("user_id",current_user.id) #当前用户是否为课堂的学生 # exercises的不同用户群体的显示 @@ -64,7 +64,7 @@ class ExercisesController < ApplicationController @is_teacher_or = 0 @exercises = member_show_exercises.present? ? member_show_exercises.unified_setting : [] end - if @exercises.count > 0 + if @exercises.size > 0 if params[:type].present? choose_type = params[:type].to_i member_group_id = @current_student.first.try(:course_group_id).to_i diff --git a/app/helpers/polls_helper.rb b/app/helpers/polls_helper.rb index 56bbb9b77..b5ba79dcc 100644 --- a/app/helpers/polls_helper.rb +++ b/app/helpers/polls_helper.rb @@ -3,8 +3,8 @@ module PollsHelper #获取试卷的已答/未答人数 def get_poll_answers(poll_users) @commit_poll_users = poll_users.commit_by_status(1) #当前老师的全部学生中已提交的 - @poll_answers = @commit_poll_users.present? ? @commit_poll_users.count : 0 #表示已经提交了的用户 - course_all_members_count = poll_users.present? ? poll_users.count : 0 + @poll_answers = @commit_poll_users.present? ? @commit_poll_users.size : 0 #表示已经提交了的用户 + course_all_members_count = poll_users.present? ? poll_users.size : 0 @poll_unanswers = (course_all_members_count - @poll_answers) end diff --git a/app/models/poll.rb b/app/models/poll.rb index ce5da17dd..1cead3291 100644 --- a/app/models/poll.rb +++ b/app/models/poll.rb @@ -137,17 +137,17 @@ class Poll < ApplicationRecord #判断当前用户的答题状态 def check_user_votes_status(user) poll_answer_user = poll_users.find_by(user_id: user.id) - user_poll_status = get_poll_status(user.id) + # user_poll_status = get_poll_status(user.id) user_status = 2 if poll_answer_user.present? && (poll_answer_user.start_at.present? || poll_answer_user.end_at.present?) #学生有过答题的,或者立即截止,但学生未做试卷的 user_status = poll_answer_user.commit_status end - - if poll_answer_user.present? && poll_answer_user.start_at.blank? && user_poll_status == 3 - # user_status = 4 - user_status = 5 #问卷用户存在,且未开始答题,且问卷已截止时,返回未提交标示 - end + # + # if poll_answer_user.present? && poll_answer_user.start_at.blank? && user_poll_status == 3 + # # user_status = 4 + # user_status = 2 #问卷用户存在,且未开始答题,且问卷已截止时,返回未提交标示 + # end user_status end From 0e32e63b7b836c3792b1f340af584327d39c9314 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Thu, 27 Jun 2019 09:34:33 +0800 Subject: [PATCH 014/256] =?UTF-8?q?=E6=AF=95=E8=AE=BE=E9=80=89=E9=A2=98?= =?UTF-8?q?=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/graduation_topics_controller.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app/controllers/graduation_topics_controller.rb b/app/controllers/graduation_topics_controller.rb index 7a61613da..521aaffc6 100644 --- a/app/controllers/graduation_topics_controller.rb +++ b/app/controllers/graduation_topics_controller.rb @@ -24,8 +24,7 @@ class GraduationTopicsController < ApplicationController end # 当前用户是否已经选过题 - user_graduation_topics = @course.student_graduation_topics.where(user_id: current_user.id, status: [0, 1]) #6.12 -hs - @user_selected = user_graduation_topics.size > 0 + @user_selected = @course.student_graduation_topics.where(user_id: current_user.id, status: [0, 1]).count > 0 #6.12 -hs ## 分页参数 page = params[:page] || 1 limit = params[:limit] || 15 From da719e500fa9a6330674911bcce6eb6ff6ceb694 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Thu, 27 Jun 2019 09:59:56 +0800 Subject: [PATCH 015/256] =?UTF-8?q?=E8=80=81=E5=B8=88=E6=89=BE=E4=B8=8D?= =?UTF-8?q?=E4=BA=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/question_banks_controller.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/controllers/question_banks_controller.rb b/app/controllers/question_banks_controller.rb index 4df392257..22650f2d3 100644 --- a/app/controllers/question_banks_controller.rb +++ b/app/controllers/question_banks_controller.rb @@ -271,6 +271,7 @@ class QuestionBanksController < ApplicationController new_topic.course_id = course.id new_topic.gtopic_bank_id = topic.id new_topic.user_id = current_user.id + new_topic.tea_id = current_user.id new_topic.save topic.attachments.each.try(:each) do |attachment| From a58bd2552a405d20c1e08e4bca06f1af2107a7b7 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Thu, 27 Jun 2019 11:26:27 +0800 Subject: [PATCH 016/256] =?UTF-8?q?=E6=89=A3=E5=88=86=E6=83=85=E5=86=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/games_controller.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/controllers/games_controller.rb b/app/controllers/games_controller.rb index 5fe230d32..32175ec2f 100644 --- a/app/controllers/games_controller.rb +++ b/app/controllers/games_controller.rb @@ -270,7 +270,8 @@ class GamesController < ApplicationController if @game.status == 2 @game.update_attributes!(:answer_open => @answer.level) else - @game.update_attributes!(:answer_open => @answer.level, :answer_deduction => deduct_score) + answer_deduction = challenge.challenge_answers.where("level <= #{@answer.level}").sum(:score) + @game.update_attributes!(:answer_open => @answer.level, :answer_deduction => answer_deduction) end rescue Exception => e From b7023c4c8e10c1cc4cad5b7a2d1ca541eb1b7aa6 Mon Sep 17 00:00:00 2001 From: jingquan huang Date: Thu, 27 Jun 2019 11:27:47 +0800 Subject: [PATCH 017/256] new git check --- lib/gitcheck/myshixun_update_error.txt | 0 lib/gitcheck/readme_test.txt | 4 +- lib/gitcheck/shixun_update.txt | 563 +++++++++++++++++++++++++ lib/gitcheck/shixun_update_error.txt | 72 ++++ lib/tasks/git_check.rake | 43 +- 5 files changed, 677 insertions(+), 5 deletions(-) create mode 100644 lib/gitcheck/myshixun_update_error.txt create mode 100644 lib/gitcheck/shixun_update_error.txt diff --git a/lib/gitcheck/myshixun_update_error.txt b/lib/gitcheck/myshixun_update_error.txt new file mode 100644 index 000000000..e69de29bb diff --git a/lib/gitcheck/readme_test.txt b/lib/gitcheck/readme_test.txt index 03f757f18..317af632c 100644 --- a/lib/gitcheck/readme_test.txt +++ b/lib/gitcheck/readme_test.txt @@ -22,7 +22,7 @@ http://121.199.19.206:9000/api/fork_repository 参数: {repo_path: 'Hjqreturn/aaass1.git', fork_repository_path: 'educoder/ca9fvobr.git'} - 说明:fork_repository_path是源项目的repo_path, repo_path是新项目的 + 说明:fork_repository_path是新项目的repo_path, repo_path是源项目的 4、更新文件 @@ -41,7 +41,7 @@ 5、获取文件内容 访问地址:http://121.199.19.206:9000/api/file_content 参数: - {repo_path: "educoder/ca9fvobr.git", file_path: 'step1/main.py',} + {repo_path: "educoder/ca9fvobr.git", path: 'step1/main.py',} 6、获取提交记录 访问地址:http://121.199.19.206:9000/api/commits diff --git a/lib/gitcheck/shixun_update.txt b/lib/gitcheck/shixun_update.txt index e69de29bb..ff5e54236 100644 --- a/lib/gitcheck/shixun_update.txt +++ b/lib/gitcheck/shixun_update.txt @@ -0,0 +1,563 @@ +http://testbdgit2.educoder.net/educoder/mqex9s82.git +http://testbdgit2.educoder.net/educoder/nf9ja46l.git +http://testbdgit2.educoder.net/educoder/qmeb65oa.git +http://testbdgit2.educoder.net/educoder/748fkcya.git +http://testbdgit2.educoder.net/educoder/o7pr4f6v.git +http://testbdgit2.educoder.net/educoder/tjxnyuv6.git +http://testbdgit2.educoder.net/educoder/fp6cmstz.git +http://testbdgit2.educoder.net/educoder/eh5oxkm9.git +http://testbdgit2.educoder.net/educoder/uznmbg54.git +http://testbdgit2.educoder.net/educoder/i8utopmc.git +http://testbdgit2.educoder.net/educoder/f9ly35vz.git +http://testbdgit2.educoder.net/educoder/vnw2fg5r.git +http://testbdgit2.educoder.net/educoder/pcfhzue5.git +http://testbdgit2.educoder.net/educoder/zlg2nmcf.git +http://testbdgit2.educoder.net/educoder/klp26sqc.git +http://testbdgit2.educoder.net/educoder/y68uqmoe.git +http://testbdgit2.educoder.net/educoder/7zg5mi2r.git +http://testbdgit2.educoder.net/educoder/8g93nfvc.git +http://testbdgit2.educoder.net/educoder/mnj3srpe.git +http://testbdgit2.educoder.net/educoder/lrwsyhzc.git +http://testbdgit2.educoder.net/educoder/a2ct98o7.git +http://testbdgit2.educoder.net/educoder/hawxspqm.git +http://testbdgit2.educoder.net/educoder/pobfl4g8.git +http://testbdgit2.educoder.net/educoder/zg7e9o2y.git +http://testbdgit2.educoder.net/educoder/fsu7tkaw.git +http://testbdgit2.educoder.net/educoder/cmklt4f8.git +http://testbdgit2.educoder.net/educoder/2gt3yuen.git +http://testbdgit2.educoder.net/educoder/v3bksozu.git +http://testbdgit2.educoder.net/educoder/ku6lva8t.git +http://testbdgit2.educoder.net/educoder/g8w3nj6r.git +http://testbdgit2.educoder.net/educoder/pxlsuotc.git +http://testbdgit2.educoder.net/educoder/opv8xkjw.git +http://testbdgit2.educoder.net/educoder/stewl573.git +http://testbdgit2.educoder.net/educoder/nuj9lbwv.git +http://testbdgit2.educoder.net/educoder/r4vlju5x.git +http://testbdgit2.educoder.net/educoder/85fat9w3.git +http://testbdgit2.educoder.net/educoder/guzqi4nm.git +http://testbdgit2.educoder.net/educoder/obtfwj3e.git +http://testbdgit2.educoder.net/educoder/3ozvy5f8.git +http://testbdgit2.educoder.net/educoder/8bu9zmjy.git +http://testbdgit2.educoder.net/educoder/n489y7qt.git +http://testbdgit2.educoder.net/educoder/f3pwvrtk.git +http://testbdgit2.educoder.net/educoder/b6ljcet3.git +http://testbdgit2.educoder.net/educoder/uie9snqp.git +http://testbdgit2.educoder.net/educoder/xti6ueyf.git +http://testbdgit2.educoder.net/educoder/gwkc395l.git +http://testbdgit2.educoder.net/educoder/6a2qy98p.git +http://testbdgit2.educoder.net/educoder/2qffg3pu.git +http://testbdgit2.educoder.net/educoder/nfypjxhl.git +http://testbdgit2.educoder.net/educoder/9p4neovc.git +http://testbdgit2.educoder.net/educoder/k4wg9b32.git +http://testbdgit2.educoder.net/educoder/pw53ln4m.git +http://testbdgit2.educoder.net/educoder/cylj7vgb.git +http://testbdgit2.educoder.net/educoder/ftfzbw72.git +http://testbdgit2.educoder.net/educoder/qt78x4a5.git +http://testbdgit2.educoder.net/educoder/qsza57pj.git +http://testbdgit2.educoder.net/educoder/afvk9r35.git +http://testbdgit2.educoder.net/educoder/68rqajhy.git +http://testbdgit2.educoder.net/educoder/q4ixftoz.git +http://testbdgit2.educoder.net/educoder/pbmkl5vt.git +http://testbdgit2.educoder.net/educoder/ral8fjw9.git +http://testbdgit2.educoder.net/educoder/89zfsjbp.git +http://testbdgit2.educoder.net/educoder/no9uv3g2.git +http://testbdgit2.educoder.net/educoder/cztux23y.git +http://testbdgit2.educoder.net/educoder/4bflgcs8.git +http://testbdgit2.educoder.net/educoder/6w2xmtls.git +http://testbdgit2.educoder.net/educoder/o4xa93mc.git +http://testbdgit2.educoder.net/educoder/uctzevfx.git +http://testbdgit2.educoder.net/educoder/wokspmut.git +http://testbdgit2.educoder.net/educoder/ba56rk8v.git +http://testbdgit2.educoder.net/educoder/6w49utr2.git +http://testbdgit2.educoder.net/educoder/qnubm248.git +http://testbdgit2.educoder.net/educoder/itzexlbn.git +http://testbdgit2.educoder.net/educoder/e6o9pmz4.git +http://testbdgit2.educoder.net/educoder/qr9fhylp.git +http://testbdgit2.educoder.net/educoder/q2nya3cj.git +http://testbdgit2.educoder.net/educoder/58drwg63.git +http://testbdgit2.educoder.net/educoder/oiwsvgpf.git +http://testbdgit2.educoder.net/educoder/4uyn5ebp.git +http://testbdgit2.educoder.net/educoder/pebvjtk9.git +http://testbdgit2.educoder.net/educoder/uywljq4v.git +http://testbdgit2.educoder.net/educoder/zawfjtnm.git +http://testbdgit2.educoder.net/educoder/z5w3gbhk.git +http://testbdgit2.educoder.net/educoder/cz7yw3en.git +http://testbdgit2.educoder.net/educoder/p87sflg2.git +http://testbdgit2.educoder.net/educoder/w3vcokrg.git +http://testbdgit2.educoder.net/educoder/uc64f2qs.git +http://testbdgit2.educoder.net/educoder/vtnag4op.git +http://testbdgit2.educoder.net/educoder/mbgfitn6.git +http://testbdgit2.educoder.net/educoder/nwj4ua2k.git +http://testbdgit2.educoder.net/educoder/y8kfhtu6.git +http://testbdgit2.educoder.net/educoder/tmivlph2.git +http://testbdgit2.educoder.net/educoder/ziyft572.git +http://testbdgit2.educoder.net/educoder/k8u4nrj6.git +http://testbdgit2.educoder.net/educoder/wgfyrzhe.git +http://testbdgit2.educoder.net/educoder/a4ts237c.git +http://testbdgit2.educoder.net/educoder/cvw63y9e.git +http://testbdgit2.educoder.net/educoder/bxltfpa5.git +http://testbdgit2.educoder.net/educoder/x2anczf5.git +http://testbdgit2.educoder.net/educoder/m57iyhan.git +http://testbdgit2.educoder.net/educoder/iqrakwl2.git +http://testbdgit2.educoder.net/educoder/fagcx7yl.git +http://testbdgit2.educoder.net/educoder/oxlpy9uq.git +http://testbdgit2.educoder.net/educoder/6spm2y7k.git +http://testbdgit2.educoder.net/educoder/6fxzts5b.git +http://testbdgit2.educoder.net/eduforge/fhc7p56a.git +http://testbdgit2.educoder.net/eduforge/3aexl5my.git +http://testbdgit2.educoder.net/educoder/9mz7qn5t.git +http://testbdgit2.educoder.net/educoder/b9r8pon3.git +http://testbdgit2.educoder.net/educoder/ciz68os9.git +http://testbdgit2.educoder.net/educoder/2e4fuw87.git +http://testbdgit2.educoder.net/educoder/hwm9s64y.git +http://testbdgit2.educoder.net/educoder/owsik483.git +http://testbdgit2.educoder.net/educoder/pbt9cyfo.git +http://testbdgit2.educoder.net/educoder/8u4fvn9w.git +http://testbdgit2.educoder.net/educoder/5bpkg3e6.git +http://testbdgit2.educoder.net/educoder/ohkunqe2.git +http://testbdgit2.educoder.net/educoder/u3j28qe6.git +http://testbdgit2.educoder.net/educoder/yjo3t72c.git +http://testbdgit2.educoder.net/educoder/oy7prsxe.git +http://testbdgit2.educoder.net/educoder/q3ljmkn2.git +http://testbdgit2.educoder.net/educoder/gk6lhtrf.git +http://testbdgit2.educoder.net/eduforge/v6pa2kiz.git +http://testbdgit2.educoder.net/educoder/qpuobn24.git +http://testbdgit2.educoder.net/educoder/mkxfysza.git +http://testbdgit2.educoder.net/eduforge/hpr7ojgc.git +http://testbdgit2.educoder.net/educoder/2aef9wni.git +http://testbdgit2.educoder.net/eduforge/8texrqwj.git +http://testbdgit2.educoder.net/educoder/wle7zmxu.git +http://testbdgit2.educoder.net/eduforge/j7cx68b9.git +http://testbdgit2.educoder.net/educoder/ywrcjki2.git +http://testbdgit2.educoder.net/educoder/sauvl9px.git +http://testbdgit2.educoder.net/educoder/3pl6j2me.git +http://testbdgit2.educoder.net/eduforge/o53rjgsh.git +http://testbdgit2.educoder.net/educoder/g8znf6cy.git +http://testbdgit2.educoder.net/educoder/itk4hy6l.git +http://testbdgit2.educoder.net/eduforge/igbc4rtw.git +http://testbdgit2.educoder.net/educoder/mnkfuyvx.git +http://testbdgit2.educoder.net/educoder/oatsh64e.git +http://testbdgit2.educoder.net/educoder/2mgsyrnu.git +http://testbdgit2.educoder.net/educoder/69ulmat5.git +http://testbdgit2.educoder.net/eduforge/9z3k5i4f.git +http://testbdgit2.educoder.net/educoder/7bysthvr.git +http://testbdgit2.educoder.net/eduforge/z3wh7uex.git +http://testbdgit2.educoder.net/educoder/9o5h2rsf.git +http://testbdgit2.educoder.net/educoder/uf3gl2vq.git +http://testbdgit2.educoder.net/eduforge/jef9xvzb.git +http://testbdgit2.educoder.net/educoder/g94qce7p.git +http://testbdgit2.educoder.net/educoder/2a54vk8x.git +http://testbdgit2.educoder.net/educoder/sx5eukfq.git +http://testbdgit2.educoder.net/educoder/ivzjw793.git +http://testbdgit2.educoder.net/eduforge/aekgf6pz.git +http://testbdgit2.educoder.net/educoder/tzqbu6c4.git +http://testbdgit2.educoder.net/educoder/ovz3e6a7.git +http://testbdgit2.educoder.net/educoder/ujavffi2.git +http://testbdgit2.educoder.net/educoder/8jsxcfm5.git +http://testbdgit2.educoder.net/educoder/qgpycjvn.git +http://testbdgit2.educoder.net/educoder/rhasift3.git +http://testbdgit2.educoder.net/educoder/nfpla5jg.git +http://testbdgit2.educoder.net/educoder/bjo2x4c9.git +http://testbdgit2.educoder.net/educoder/3jawxy9g.git +http://testbdgit2.educoder.net/eduforge/h6gs8t7q.git +http://testbdgit2.educoder.net/educoder/ntexhzrl.git +http://testbdgit2.educoder.net/educoder/jft327sa.git +http://testbdgit2.educoder.net/educoder/7bvs54gw.git +http://testbdgit2.educoder.net/educoder/grunzcs3.git +http://testbdgit2.educoder.net/educoder/q4fowkfa.git +http://testbdgit2.educoder.net/educoder/fkmtrpsn.git +http://testbdgit2.educoder.net/educoder/2iubzxfh.git +http://testbdgit2.educoder.net/educoder/gbhwvrki.git +http://testbdgit2.educoder.net/educoder/kpxfs4b5.git +http://testbdgit2.educoder.net/educoder/h5f6wi7x.git +http://testbdgit2.educoder.net/educoder/c3lr2xjz.git +http://testbdgit2.educoder.net/educoder/q8bcyxz3.git +http://testbdgit2.educoder.net/educoder/qha5emif.git +http://testbdgit2.educoder.net/educoder/5jr4gzs7.git +http://testbdgit2.educoder.net/educoder/9ksg4up7.git +http://testbdgit2.educoder.net/educoder/4rcxvftu.git +http://testbdgit2.educoder.net/educoder/hvaf5txj.git +http://testbdgit2.educoder.net/educoder/b4vqe8uz.git +http://testbdgit2.educoder.net/educoder/pg6c2i5y.git +http://testbdgit2.educoder.net/educoder/fbtlw8ro.git +http://testbdgit2.educoder.net/educoder/86f92lri.git +http://testbdgit2.educoder.net/educoder/zvaup9yo.git +http://testbdgit2.educoder.net/educoder/exm3ffap.git +http://testbdgit2.educoder.net/educoder/owg63ezu.git +http://testbdgit2.educoder.net/educoder/c36opqaj.git +http://testbdgit2.educoder.net/educoder/xuyrc6qs.git +http://testbdgit2.educoder.net/educoder/xc9tj82p.git +http://testbdgit2.educoder.net/educoder/nmougtya.git +http://testbdgit2.educoder.net/educoder/8arufxzl.git +http://testbdgit2.educoder.net/educoder/m7nrf6zf.git +http://testbdgit2.educoder.net/educoder/zffu9j6v.git +http://testbdgit2.educoder.net/educoder/epmtoh6b.git +http://testbdgit2.educoder.net/educoder/ejab7vxn.git +http://testbdgit2.educoder.net/educoder/83lyhsen.git +http://testbdgit2.educoder.net/educoder/m4e6x573.git +http://testbdgit2.educoder.net/educoder/unfihtsv.git +http://testbdgit2.educoder.net/educoder/74ftapwb.git +http://testbdgit2.educoder.net/educoder/iu47m9qx.git +http://testbdgit2.educoder.net/educoder/8bh6mfu3.git +http://testbdgit2.educoder.net/educoder/sb26oath.git +http://testbdgit2.educoder.net/educoder/igvm3fsb.git +http://testbdgit2.educoder.net/educoder/gancv2yo.git +http://testbdgit2.educoder.net/educoder/kyp65jwu.git +http://testbdgit2.educoder.net/educoder/6ru2nbpj.git +http://testbdgit2.educoder.net/educoder/rfpwhsu5.git +http://testbdgit2.educoder.net/educoder/orem2wgc.git +http://testbdgit2.educoder.net/educoder/yuhmfliq.git +http://testbdgit2.educoder.net/educoder/m4c7jo6y.git +http://testbdgit2.educoder.net/educoder/5l6oufzc.git +http://testbdgit2.educoder.net/educoder/my7vcffx.git +http://testbdgit2.educoder.net/educoder/uvka63xs.git +http://testbdgit2.educoder.net/educoder/c9thq3li.git +http://testbdgit2.educoder.net/educoder/o45rn2sl.git +http://testbdgit2.educoder.net/educoder/sae3fyjc.git +http://testbdgit2.educoder.net/educoder/56orxtg3.git +http://testbdgit2.educoder.net/educoder/cqpzx47f.git +http://testbdgit2.educoder.net/educoder/2in3vcf7.git +http://testbdgit2.educoder.net/educoder/6isfgtun.git +http://testbdgit2.educoder.net/educoder/46woubzq.git +http://testbdgit2.educoder.net/educoder/6xwmi29f.git +http://testbdgit2.educoder.net/educoder/hk968fua.git +http://testbdgit2.educoder.net/educoder/ogb6ixjz.git +http://testbdgit2.educoder.net/educoder/va7cru64.git +http://testbdgit2.educoder.net/educoder/vqnk5tjo.git +http://testbdgit2.educoder.net/educoder/oqfsci8u.git +http://testbdgit2.educoder.net/educoder/qcosi4f8.git +http://testbdgit2.educoder.net/educoder/bsnk7wit.git +http://testbdgit2.educoder.net/educoder/ksvmtwql.git +http://testbdgit2.educoder.net/educoder/eigqpfua.git +http://testbdgit2.educoder.net/educoder/hqmwxztb.git +http://testbdgit2.educoder.net/educoder/jlgt9wfk.git +http://testbdgit2.educoder.net/educoder/hcuzqkgv.git +http://testbdgit2.educoder.net/educoder/hzw89pof.git +http://testbdgit2.educoder.net/educoder/xnft4fsm.git +http://testbdgit2.educoder.net/educoder/guj4ml8q.git +http://testbdgit2.educoder.net/educoder/l56jkwfn.git +http://testbdgit2.educoder.net/educoder/4jqry5gl.git +http://testbdgit2.educoder.net/educoder/65kiwb72.git +http://testbdgit2.educoder.net/educoder/xb39mzfr.git +http://testbdgit2.educoder.net/educoder/hyb5m38x.git +http://testbdgit2.educoder.net/educoder/p4f2jtkq.git +http://testbdgit2.educoder.net/educoder/4n3stcol.git +http://testbdgit2.educoder.net/educoder/6kjqar5e.git +http://testbdgit2.educoder.net/educoder/qhc2prk4.git +http://testbdgit2.educoder.net/educoder/ltw8b29i.git +http://testbdgit2.educoder.net/educoder/g5y8zcvl.git +http://testbdgit2.educoder.net/educoder/5et7zpra.git +http://testbdgit2.educoder.net/educoder/au97mpbr.git +http://testbdgit2.educoder.net/educoder/oxmt2zvc.git +http://testbdgit2.educoder.net/educoder/26chou4y.git +http://testbdgit2.educoder.net/educoder/lfmus7o2.git +http://testbdgit2.educoder.net/educoder/efbp7luz.git +http://testbdgit2.educoder.net/educoder/7lr8agws.git +http://testbdgit2.educoder.net/educoder/ak8tbjuv.git +http://testbdgit2.educoder.net/educoder/qu8a93ew.git +http://testbdgit2.educoder.net/educoder/zlgfiowe.git +http://testbdgit2.educoder.net/educoder/qmt4nfai.git +http://testbdgit2.educoder.net/educoder/u2s4v9ba.git +http://testbdgit2.educoder.net/educoder/2icxsunf.git +http://testbdgit2.educoder.net/educoder/fzmqjp6g.git +http://testbdgit2.educoder.net/educoder/7ir3vmzw.git +http://testbdgit2.educoder.net/educoder/xkfzg96o.git +http://testbdgit2.educoder.net/educoder/xvfl5sjz.git +http://testbdgit2.educoder.net/educoder/qnwuy7h3.git +http://testbdgit2.educoder.net/educoder/bhnspvmg.git +http://testbdgit2.educoder.net/educoder/ns7vh6ro.git +http://testbdgit2.educoder.net/eduforge/un3xoal7.git +http://testbdgit2.educoder.net/educoder/29am7wv4.git +http://testbdgit2.educoder.net/educoder/qlfn5hiu.git +http://testbdgit2.educoder.net/educoder/e4pvkhtj.git +http://testbdgit2.educoder.net/educoder/hfesmtuz.git +http://testbdgit2.educoder.net/educoder/6kjhil3m.git +http://testbdgit2.educoder.net/educoder/2igrh8c4.git +http://testbdgit2.educoder.net/educoder/e7yt3kmw.git +http://testbdgit2.educoder.net/educoder/a8zybrkt.git +http://testbdgit2.educoder.net/educoder/v2uzrasj.git +http://testbdgit2.educoder.net/educoder/rb83htif.git +http://testbdgit2.educoder.net/eduforge/jc3p2wto.git +http://testbdgit2.educoder.net/educoder/jtnlfgw2.git +http://testbdgit2.educoder.net/educoder/fa96xrti.git +http://testbdgit2.educoder.net/educoder/r6bjga3u.git +http://testbdgit2.educoder.net/educoder/fpmwzxqn.git +http://testbdgit2.educoder.net/educoder/rbpsw8ct.git +http://testbdgit2.educoder.net/educoder/4zuxembp.git +http://testbdgit2.educoder.net/educoder/3gxwrzaf.git +http://testbdgit2.educoder.net/educoder/wz6j5lpn.git +http://testbdgit2.educoder.net/educoder/izu9tf3j.git +http://testbdgit2.educoder.net/educoder/vhux4pa7.git +http://testbdgit2.educoder.net/educoder/s9wvroqn.git +http://testbdgit2.educoder.net/educoder/ruofj2xl.git +http://testbdgit2.educoder.net/educoder/qj4mlxoi.git +http://testbdgit2.educoder.net/educoder/34gzbolc.git +http://testbdgit2.educoder.net/educoder/at86wfsn.git +http://testbdgit2.educoder.net/educoder/j7fnwsrh.git +http://testbdgit2.educoder.net/educoder/zgsuk364.git +http://testbdgit2.educoder.net/educoder/nf3gv54x.git +http://testbdgit2.educoder.net/educoder/fnbuq957.git +http://testbdgit2.educoder.net/educoder/z4fp9o3e.git +http://testbdgit2.educoder.net/educoder/c3qh4p6f.git +http://testbdgit2.educoder.net/educoder/fszntcbw.git +http://testbdgit2.educoder.net/educoder/af968lnf.git +http://testbdgit2.educoder.net/educoder/kpc36fhn.git +http://testbdgit2.educoder.net/educoder/6c4wp5bu.git +http://testbdgit2.educoder.net/educoder/hzmikncs.git +http://testbdgit2.educoder.net/educoder/6ogr4bhj.git +http://testbdgit2.educoder.net/educoder/fu59rezf.git +http://testbdgit2.educoder.net/educoder/zef9gswv.git +http://testbdgit2.educoder.net/educoder/p9z4fxv8.git +http://testbdgit2.educoder.net/eduforge/hcxeuyfl.git +http://testbdgit2.educoder.net/educoder/4u2ebx89.git +http://testbdgit2.educoder.net/educoder/cikojzsb.git +http://testbdgit2.educoder.net/educoder/2rzomtx5.git +http://testbdgit2.educoder.net/educoder/wfvbhr2s.git +http://testbdgit2.educoder.net/educoder/q8mxg4zv.git +http://testbdgit2.educoder.net/educoder/q8fezi37.git +http://testbdgit2.educoder.net/educoder/nb7ha8te.git +http://testbdgit2.educoder.net/educoder/qxgfbyn9.git +http://testbdgit2.educoder.net/educoder/k8so9wa2.git +http://testbdgit2.educoder.net/educoder/zwc9ja5y.git +http://testbdgit2.educoder.net/educoder/89lwscfy.git +http://testbdgit2.educoder.net/educoder/ga26fy4f.git +http://testbdgit2.educoder.net/educoder/rgy4769i.git +http://testbdgit2.educoder.net/educoder/q3rnovik.git +http://testbdgit2.educoder.net/educoder/r5xsukn4.git +http://testbdgit2.educoder.net/educoder/yu6za47j.git +http://testbdgit2.educoder.net/educoder/fqvr56nm.git +http://testbdgit2.educoder.net/educoder/tq26m73o.git +http://testbdgit2.educoder.net/educoder/k2rmpuf6.git +http://testbdgit2.educoder.net/educoder/fzg87ip6.git +http://testbdgit2.educoder.net/educoder/qk3l64zi.git +http://testbdgit2.educoder.net/educoder/bcjpk93f.git +http://testbdgit2.educoder.net/educoder/rnjak48l.git +http://testbdgit2.educoder.net/educoder/hyzkq5vr.git +http://testbdgit2.educoder.net/educoder/tqnvbisr.git +http://testbdgit2.educoder.net/educoder/nfszy26f.git +http://testbdgit2.educoder.net/educoder/rfnhkvgo.git +http://testbdgit2.educoder.net/educoder/6omf2gbl.git +http://testbdgit2.educoder.net/educoder/x4qhb5k7.git +http://testbdgit2.educoder.net/educoder/jyz63ge5.git +http://testbdgit2.educoder.net/educoder/hfqwilp3.git +http://testbdgit2.educoder.net/educoder/aq9c4fy5.git +http://testbdgit2.educoder.net/educoder/tzshnbl8.git +http://testbdgit2.educoder.net/educoder/zm8qffrj.git +http://testbdgit2.educoder.net/educoder/szctor3e.git +http://testbdgit2.educoder.net/educoder/amcyzpvk.git +http://testbdgit2.educoder.net/educoder/fpy467o9.git +http://testbdgit2.educoder.net/educoder/w5nytxec.git +http://testbdgit2.educoder.net/educoder/icreqzu4.git +http://testbdgit2.educoder.net/educoder/2jf76xr5.git +http://testbdgit2.educoder.net/educoder/yl4a2qf5.git +http://testbdgit2.educoder.net/educoder/jgmcieqk.git +http://testbdgit2.educoder.net/educoder/hjtxy657.git +http://testbdgit2.educoder.net/educoder/47w6uyeh.git +http://testbdgit2.educoder.net/educoder/pr4vg7j5.git +http://testbdgit2.educoder.net/educoder/m6xn7z93.git +http://testbdgit2.educoder.net/educoder/f23fge9h.git +http://testbdgit2.educoder.net/educoder/cfo7lqhs.git +http://testbdgit2.educoder.net/educoder/4gnkqf3y.git +http://testbdgit2.educoder.net/educoder/k89bgonj.git +http://testbdgit2.educoder.net/educoder/k98qr7iw.git +http://testbdgit2.educoder.net/educoder/jel85v62.git +http://testbdgit2.educoder.net/educoder/zt2aqnb6.git +http://testbdgit2.educoder.net/educoder/7icqubfj.git +http://testbdgit2.educoder.net/educoder/2x59s3by.git +http://testbdgit2.educoder.net/educoder/mrvwxekj.git +http://testbdgit2.educoder.net/educoder/k5cruoyp.git +http://testbdgit2.educoder.net/educoder/rc6hw58u.git +http://testbdgit2.educoder.net/educoder/ygzf7v3k.git +http://testbdgit2.educoder.net/educoder/8ty6fgln.git +http://testbdgit2.educoder.net/educoder/wp5mbjg8.git +http://testbdgit2.educoder.net/educoder/oniuafxz.git +http://testbdgit2.educoder.net/educoder/aviljpmn.git +http://testbdgit2.educoder.net/educoder/iufg8573.git +http://testbdgit2.educoder.net/educoder/gc8xl2v9.git +http://testbdgit2.educoder.net/educoder/2wgmhvuk.git +http://testbdgit2.educoder.net/educoder/clx7ha6j.git +http://testbdgit2.educoder.net/educoder/bz9wxpvr.git +http://testbdgit2.educoder.net/educoder/uw95cg28.git +http://testbdgit2.educoder.net/educoder/4frpc7ix.git +http://testbdgit2.educoder.net/educoder/nas3v78t.git +http://testbdgit2.educoder.net/educoder/cbrys8f3.git +http://testbdgit2.educoder.net/educoder/ofj29enq.git +http://testbdgit2.educoder.net/educoder/btvk2w5h.git +http://testbdgit2.educoder.net/educoder/cztbjan5.git +http://testbdgit2.educoder.net/educoder/7atfm9vu.git +http://testbdgit2.educoder.net/educoder/cpxs3kfu.git +http://testbdgit2.educoder.net/educoder/5pfalzkh.git +http://testbdgit2.educoder.net/educoder/yf6covh2.git +http://testbdgit2.educoder.net/educoder/ocevha8x.git +http://testbdgit2.educoder.net/educoder/qtxkogfi.git +http://testbdgit2.educoder.net/educoder/pa8fh4m2.git +http://testbdgit2.educoder.net/educoder/n3ps8i4m.git +http://testbdgit2.educoder.net/educoder/5x9alvmc.git +http://testbdgit2.educoder.net/educoder/yl732ofk.git +http://testbdgit2.educoder.net/educoder/hvlgfjb7.git +http://testbdgit2.educoder.net/educoder/i9sfum58.git +http://testbdgit2.educoder.net/educoder/my9jcvio.git +http://testbdgit2.educoder.net/educoder/2myqxbce.git +http://testbdgit2.educoder.net/educoder/p4x9qmka.git +http://testbdgit2.educoder.net/educoder/aslcogwk.git +http://testbdgit2.educoder.net/educoder/eryg8fot.git +http://testbdgit2.educoder.net/educoder/ust5hgjm.git +http://testbdgit2.educoder.net/educoder/ypve8gbo.git +http://testbdgit2.educoder.net/educoder/ir768pfq.git +http://testbdgit2.educoder.net/educoder/ki98yelu.git +http://testbdgit2.educoder.net/educoder/i4nzvb7x.git +http://testbdgit2.educoder.net/educoder/58l7vb9f.git +http://testbdgit2.educoder.net/educoder/l859pqs3.git +http://testbdgit2.educoder.net/educoder/6rvpzn7x.git +http://testbdgit2.educoder.net/educoder/c5msxfe8.git +http://testbdgit2.educoder.net/educoder/cwa6igze.git +http://testbdgit2.educoder.net/educoder/vbnqglcw.git +http://testbdgit2.educoder.net/educoder/8bysvmcf.git +http://testbdgit2.educoder.net/educoder/u3ceh2xw.git +http://testbdgit2.educoder.net/educoder/heqtnza3.git +http://testbdgit2.educoder.net/educoder/uzoltjva.git +http://testbdgit2.educoder.net/educoder/mefykafs.git +http://testbdgit2.educoder.net/educoder/6jvypwgq.git +http://testbdgit2.educoder.net/educoder/h5wisac9.git +http://testbdgit2.educoder.net/educoder/52ufjw9m.git +http://testbdgit2.educoder.net/educoder/v2uxoifl.git +http://testbdgit2.educoder.net/educoder/an2ofy6k.git +http://testbdgit2.educoder.net/educoder/kao2rlf5.git +http://testbdgit2.educoder.net/educoder/uihap3wr.git +http://testbdgit2.educoder.net/educoder/wliam3nq.git +http://testbdgit2.educoder.net/educoder/7cpo6hel.git +http://testbdgit2.educoder.net/educoder/bmtlph7e.git +http://testbdgit2.educoder.net/educoder/b8n9twpf.git +http://testbdgit2.educoder.net/educoder/3cur5wz6.git +http://testbdgit2.educoder.net/educoder/h6ga29wv.git +http://testbdgit2.educoder.net/educoder/67kv4zmg.git +http://testbdgit2.educoder.net/educoder/buf6h8jf.git +http://testbdgit2.educoder.net/educoder/gce9ojqv.git +http://testbdgit2.educoder.net/educoder/jm2l6rwf.git +http://testbdgit2.educoder.net/educoder/4lwfjfrt.git +http://testbdgit2.educoder.net/educoder/5qsw32oj.git +http://testbdgit2.educoder.net/educoder/9yw36vxq.git +http://testbdgit2.educoder.net/educoder/93fivo6k.git +http://testbdgit2.educoder.net/educoder/nwy3x4t2.git +http://testbdgit2.educoder.net/educoder/ku9o2fcf.git +http://testbdgit2.educoder.net/educoder/s68uqlic.git +http://testbdgit2.educoder.net/educoder/4bajyohg.git +http://testbdgit2.educoder.net/educoder/qtfpscz8.git +http://testbdgit2.educoder.net/educoder/j5u7y6wn.git +http://testbdgit2.educoder.net/educoder/btku8vcx.git +http://testbdgit2.educoder.net/educoder/a9n8w2eu.git +http://testbdgit2.educoder.net/educoder/vze7ny25.git +http://testbdgit2.educoder.net/educoder/yz5aofe2.git +http://testbdgit2.educoder.net/educoder/r9nibvz4.git +http://testbdgit2.educoder.net/educoder/6cvxk3q8.git +http://testbdgit2.educoder.net/educoder/rmtuvk6z.git +http://testbdgit2.educoder.net/educoder/sbitr936.git +http://testbdgit2.educoder.net/educoder/sb6j4raf.git +http://testbdgit2.educoder.net/educoder/a7gfvh5s.git +http://testbdgit2.educoder.net/educoder/zsj6ao3c.git +http://testbdgit2.educoder.net/educoder/8x2epwk6.git +http://testbdgit2.educoder.net/educoder/cbnfxeiw.git +http://testbdgit2.educoder.net/educoder/ul47bqcn.git +http://testbdgit2.educoder.net/educoder/ltsnfy4x.git +http://testbdgit2.educoder.net/educoder/t53nvo8e.git +http://testbdgit2.educoder.net/educoder/yojwp2mb.git +http://testbdgit2.educoder.net/educoder/67nayvtg.git +http://testbdgit2.educoder.net/educoder/42fq3yx7.git +http://testbdgit2.educoder.net/educoder/f39hiscw.git +http://testbdgit2.educoder.net/educoder/jey9avks.git +http://testbdgit2.educoder.net/educoder/ascbpy86.git +http://testbdgit2.educoder.net/educoder/vagzfryl.git +http://testbdgit2.educoder.net/educoder/c6k5i82o.git +http://testbdgit2.educoder.net/educoder/utr8bp9a.git +http://testbdgit2.educoder.net/educoder/ul65ap4o.git +http://testbdgit2.educoder.net/educoder/bmulap4n.git +http://testbdgit2.educoder.net/educoder/nxj2sfvr.git +http://testbdgit2.educoder.net/educoder/vq5t9hea.git +http://testbdgit2.educoder.net/educoder/7g5l6kzr.git +http://testbdgit2.educoder.net/educoder/2y8t594n.git +http://testbdgit2.educoder.net/educoder/mlnpqx9r.git +http://testbdgit2.educoder.net/educoder/apgxmqs7.git +http://testbdgit2.educoder.net/educoder/vur567ha.git +http://testbdgit2.educoder.net/educoder/qwctfpjl.git +http://testbdgit2.educoder.net/educoder/5w6gh9m8.git +http://testbdgit2.educoder.net/educoder/fzhe4mpv.git +http://testbdgit2.educoder.net/educoder/vmygstfb.git +http://testbdgit2.educoder.net/educoder/uryh3e4i.git +http://testbdgit2.educoder.net/educoder/nbixuzkf.git +http://testbdgit2.educoder.net/educoder/zpkyj7bs.git +http://testbdgit2.educoder.net/educoder/79tpk5oy.git +http://testbdgit2.educoder.net/educoder/s93x58at.git +http://testbdgit2.educoder.net/educoder/6ymec92a.git +http://testbdgit2.educoder.net/educoder/7vqgbsfc.git +http://testbdgit2.educoder.net/educoder/fr5fom8n.git +http://testbdgit2.educoder.net/educoder/7uzyskn9.git +http://testbdgit2.educoder.net/educoder/g4fvywf6.git +http://testbdgit2.educoder.net/educoder/wa98h2ly.git +http://testbdgit2.educoder.net/educoder/u6i2o3qz.git +http://testbdgit2.educoder.net/educoder/enxbyiok.git +http://testbdgit2.educoder.net/educoder/2fuweqf8.git +http://testbdgit2.educoder.net/educoder/48flws5g.git +http://testbdgit2.educoder.net/educoder/yugrij4n.git +http://testbdgit2.educoder.net/educoder/gtbkvm58.git +http://testbdgit2.educoder.net/educoder/nes73wfv.git +http://testbdgit2.educoder.net/educoder/oztyjl4h.git +http://testbdgit2.educoder.net/educoder/f398leqr.git +http://testbdgit2.educoder.net/educoder/i3xutoze.git +http://testbdgit2.educoder.net/educoder/mfv6zrj7.git +http://testbdgit2.educoder.net/educoder/6ujfeqbh.git +http://testbdgit2.educoder.net/educoder/8x93tfqn.git +http://testbdgit2.educoder.net/educoder/fxv9bpcw.git +http://testbdgit2.educoder.net/eduforge/64xb9k2q.git +http://testbdgit2.educoder.net/educoder/5e4vcr7t.git +http://testbdgit2.educoder.net/educoder/qwaffs2p.git +http://testbdgit2.educoder.net/educoder/ose7482b.git +http://testbdgit2.educoder.net/educoder/wt2xfzny.git +http://testbdgit2.educoder.net/educoder/cuqnpzjv.git +http://testbdgit2.educoder.net/educoder/n3a8q9b2.git +http://testbdgit2.educoder.net/educoder/f9o4hpix.git +http://testbdgit2.educoder.net/educoder/bm9qr7ue.git +http://testbdgit2.educoder.net/educoder/nhlygi7p.git +http://testbdgit2.educoder.net/educoder/mf2vfngu.git +http://testbdgit2.educoder.net/educoder/x6tsevzy.git +http://testbdgit2.educoder.net/educoder/rjfbm74o.git +http://testbdgit2.educoder.net/educoder/ztbukf7e.git +http://testbdgit2.educoder.net/educoder/pf8yze9h.git +http://testbdgit2.educoder.net/educoder/nrug2mfz.git +http://testbdgit2.educoder.net/educoder/jswmzaxr.git +http://testbdgit2.educoder.net/educoder/wpxjzo3c.git +http://testbdgit2.educoder.net/educoder/zaohblre.git +http://testbdgit2.educoder.net/educoder/psx2h9kf.git +http://testbdgit2.educoder.net/educoder/ayju6fie.git +http://testbdgit2.educoder.net/educoder/5kp9guol.git +http://testbdgit2.educoder.net/educoder/c4ztkfb2.git +http://testbdgit2.educoder.net/educoder/kboupjtl.git +http://testbdgit2.educoder.net/educoder/bcvhs9u7.git +http://testbdgit2.educoder.net/educoder/26vljnb3.git +http://testbdgit2.educoder.net/educoder/zesqa3wi.git +http://testbdgit2.educoder.net/educoder/43phxgsf.git +http://testbdgit2.educoder.net/educoder/fbx6awcm.git +http://testbdgit2.educoder.net/educoder/i2s7jof5.git +http://testbdgit2.educoder.net/educoder/n2w4jrax.git +http://testbdgit2.educoder.net/educoder/4pou5tey.git +http://testbdgit2.educoder.net/eduforge/e9qr7cxi.git +http://testbdgit2.educoder.net/educoder/y6bg739q.git +http://testbdgit2.educoder.net/educoder/h32r58s7.git +http://testbdgit2.educoder.net/eduforge/hpr7ojgc-1.git +http://testbdgit2.educoder.net/educoder/c3j4hufp.git +http://testbdgit2.educoder.net/eduforge/o72clmi4.git +http://testbdgit2.educoder.net/educoder/qfz8o2r6.git +http://testbdgit2.educoder.net/educoder/rw3i8vf2.git +http://testbdgit2.educoder.net/educoder/shpwf3xf.git +http://testbdgit2.educoder.net/eduforge/vnw2fg5r.git +http://testbdgit2.educoder.net/innov/f2izon59.git +http://testbdgit2.educoder.net/innov/qlkpiusm.git +http://testbdgit2.educoder.net/innov/edu1547017399.git +http://testbdgit2.educoder.net/forge01/cermyt39.git +http://testbdgit2.educoder.net/innov/em3z8yn6.git +http://testbdgit2.educoder.net/innov/c8ynf526.git +http://testbdgit2.educoder.net/Hjqreturn/sx36oveq.git +http://testbdgit2.educoder.net/innov/t7sxkfab20190115135957.git +http://testbdgit2.educoder.net/innov/etlb3pn620190115140004.git +http://testbdgit2.educoder.net/innov/5jbomfrg20190115140011.git +http://testbdgit2.educoder.net/innov/6ecmbf7g20190115140015.git +http://testbdgit2.educoder.net/innov/f7jn8kex20190115140330.git diff --git a/lib/gitcheck/shixun_update_error.txt b/lib/gitcheck/shixun_update_error.txt new file mode 100644 index 000000000..ef9663c46 --- /dev/null +++ b/lib/gitcheck/shixun_update_error.txt @@ -0,0 +1,72 @@ +mbtclufr +9op3hs4j +96ctv7yr +rtmzxfke +ofqxthrf +czu9w4gj +9fpzj6et +pwhc865b +maozpx4l +y5wh2ofx +b5rzhpf3 +bs243nrl +47fn2yfb +kwotfxey +w5468sbp +fyekprio +q6ze5fih +b5hjq9zm +ky8pbqux +53phc7nq +b9j2yuix +9t3uphwk +iokm8ah2 +qlsy6xb4 +345bqhfi +v728fqia +4euftvf2 +f23sef5m +nhqis8m9 +qp72tb5x +gt3anszw +tng6heyf +nb9keawo +elgnbkp9 +4neslomg +lh35s6ma +xmc4rpay +qrpaxi6b +9fla2zry +efuibzrm +fzp3iu4w +pligsyn8 +glbksr29 +kfm7ghyc +p6hk3svf +p539gjhm +am5o73er +4x3qwrbe +fqosyl8g +of5z3fci +tb7hw62n +ie6zxg7r +4q2bmy9h +fpm3u5yb +nikx3ojt +vt82s9bq +ma59fefo +lxa39tfq +4gnockxf +nxwg84ey +fmie8nzb +w5nsr24v +4hn3efwc +h9ljfbq7 +nuv54t8b +2te9fmfq +vihnsayz +qhlyn82s +vw74kmfr +vcta36bz +henz425l +g529v38z diff --git a/lib/tasks/git_check.rake b/lib/tasks/git_check.rake index 64f8be91b..a5e95eedc 100644 --- a/lib/tasks/git_check.rake +++ b/lib/tasks/git_check.rake @@ -1,15 +1,52 @@ +# 需要做的几件事: +# 1、检测两边(TPM\TPI)同步后有更新的仓库 +# + namespace :git do desc "检测是否TPM是否需要更新" task :shixun_check_update => :environment do - + g = Gitlab.client + file_txt = File.new("lib/gitcheck/shixun_update.txt", "r+") + file_error_txt = File.new("lib/gitcheck/shixun_update_error.txt", "r+") + host = EduSetting.find_by_name("git_address_domain").try(:value) + Shixun.find_each do |shixun| + begin + gitlab_commit = g.commits(shixun.gpid, :ref_name => 'master').first.try(:id) + repo_name = shixun.repo_name + git_commit = GitService.commits(repo_path: "#{repo_name}.git").first["id"] + git_url = host + "/" + repo_name + ".git\n" + if git_commit != gitlab_commit + file_txt.syswrite(git_url) + end + rescue + file_error_txt.syswrite("#{shixun.identifier}\n") + end + end end - desc "检测版本库是否有异常" + desc "检测版本库是否有更新" task :myshixuns_check_update => :environment do - + g = Gitlab.client + file_txt = File.new("lib/gitcheck/myshixun_update.txt", "r+") + file_error_txt = File.new("lib/gitcheck/myshixun_update_error.txt", "r+") + host = EduSetting.find_by_name("git_address_domain").try(:value) + Myshixun.find_each do |myshixun| + begin + gitlab_commit = g.commits(myshixun.gpid, :ref_name => 'master').first.try(:id) + repo_name = myshixun.repo_name + git_commit = GitService.commits(repo_path: "#{repo_name}.git").first["id"] + git_url = host + "/" + repo_name + ".git\n" + if git_commit != gitlab_commit + file_txt.syswrite(git_url) + end + rescue + file_error_txt.syswrite("#{myshixun.identifier}\n") + end + end end + # 检测TPI没有迁移过来的 task :check => :environment do end From bab042a7a5e80ec2f1739b13e68fd09f5ca61743 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Thu, 27 Jun 2019 11:35:10 +0800 Subject: [PATCH 018/256] =?UTF-8?q?=E6=B5=8B=E8=AF=95=E9=9B=86=E8=A7=A3?= =?UTF-8?q?=E9=94=81=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/games_controller.rb | 1 + config/routes.rb | 1 + 2 files changed, 2 insertions(+) diff --git a/app/controllers/games_controller.rb b/app/controllers/games_controller.rb index 32175ec2f..4e7afa516 100644 --- a/app/controllers/games_controller.rb +++ b/app/controllers/games_controller.rb @@ -270,6 +270,7 @@ class GamesController < ApplicationController if @game.status == 2 @game.update_attributes!(:answer_open => @answer.level) else + # 扣除总分计算 answer_deduction = challenge.challenge_answers.where("level <= #{@answer.level}").sum(:score) @game.update_attributes!(:answer_open => @answer.level, :answer_deduction => answer_deduction) end diff --git a/config/routes.rb b/config/routes.rb index ecd54c8c0..f81d90267 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -117,6 +117,7 @@ Rails.application.routes.draw do get :close_webssh get :get_answer_info get :unlock_answer + get :check_test_sets end collection do From f755a2dca8aacaba6d1b5f74d502c9f3d7776a93 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Thu, 27 Jun 2019 14:07:24 +0800 Subject: [PATCH 019/256] fix export exercise pdf --- app/controllers/accounts_controller.rb | 1 - app/services/exercise_user_pdf_service.rb | 6 +++--- app/templates/exercise_export/exercise_export.css | 2 +- app/templates/exercise_export/exercise_user.html.erb | 7 ++++--- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/app/controllers/accounts_controller.rb b/app/controllers/accounts_controller.rb index c3333c912..0d32926e4 100644 --- a/app/controllers/accounts_controller.rb +++ b/app/controllers/accounts_controller.rb @@ -83,7 +83,6 @@ class AccountsController < ApplicationController email = params[:login] verifi_code = VerificationCode.where(email: email, code: code, code_type: 3).last user = User.find_by_mail(email) #这里有问题,应该是为email,而不是mail 6.13-hs - end check_code = (verifi_code.try(:code) == code.strip && (Time.now.to_i - verifi_code.created_at.to_i) <= 10*60) unless check_code diff --git a/app/services/exercise_user_pdf_service.rb b/app/services/exercise_user_pdf_service.rb index d74e66d31..663d8b042 100644 --- a/app/services/exercise_user_pdf_service.rb +++ b/app/services/exercise_user_pdf_service.rb @@ -47,7 +47,7 @@ class ExerciseUserPdfService end def load_data - @exercise_questions = exercise.exercise_questions + @exercise_questions = exercise.exercise_questions.joins(:exercise_choices,:exercise_shixun_challenges,:exercise_answers,:exercise_shixun_answers,:exercise_answer_comments) @exercise_ques_count = @exercise_questions.count # 全部的题目数 @exercise_ques_scores = @exercise_questions.pluck(:question_score).sum @@ -81,9 +81,9 @@ class ExerciseUserPdfService @exercise_ques_shixun_count = exercise_ques_shixun.all.count @exercise_ques_shixun_scores = exercise_ques_shixun.pluck(:question_score).sum - challenge_ids = @exercise_questions.joins(:exercise_shixun_challenges).pluck("exercise_shixun_challenges.challenge_id") + challenge_ids = @exercise_questions.pluck("exercise_shixun_challenges.challenge_id") get_each_student_exercise(exercise.id,@exercise_questions,@ex_user_user.id) - @games = @exercise_user.user.games.ch_games(challenge_ids) + # @games = @exercise_user.user.games.ch_games(challenge_ids) end end \ No newline at end of file diff --git a/app/templates/exercise_export/exercise_export.css b/app/templates/exercise_export/exercise_export.css index 59be4f1bd..e04f77035 100644 --- a/app/templates/exercise_export/exercise_export.css +++ b/app/templates/exercise_export/exercise_export.css @@ -231,7 +231,7 @@ p{ position: absolute; display: inline-block; bottom: 9px; - left: 1px; + left: 2px; } .circle-right:after{ color:#fff; diff --git a/app/templates/exercise_export/exercise_user.html.erb b/app/templates/exercise_export/exercise_user.html.erb index 193a25301..c81f45d68 100644 --- a/app/templates/exercise_export/exercise_user.html.erb +++ b/app/templates/exercise_export/exercise_user.html.erb @@ -112,6 +112,7 @@
<% @exercise_questions.each do |q| %> <% q_type = q.question_type %> + <% games =( q_type == 5 ? @ex_user_user.games.ch_games(q.exercise_shixun_challenges.pluck(:challenge_id)) : nil) %> <% user_answer = (q_type == 5 ? q.exercise_shixun_answers.where(user_id: @ex_user_user.id) : q.exercise_answers.where(user_id: @ex_user_user.id)) %> <% this_ques_status = @ex_obj_array.detect{|f| f[:q_id] == q.id} %> <% main_ques_status = @ex_sub_array.detect{|f| f[:q_id] == q.id} %> @@ -247,8 +248,8 @@ 得分/满分 - <% if @games.size > 0 %> - <% @games.each_with_index do |game, index| %> + <% if games.present? %> + <% games&.each_with_index do |game, index| %> <% game_score = q.exercise_shixun_challenges.where(challenge_id:game.challenge.id) %> <% user_score = q.exercise_shixun_answers.where(exercise_shixun_challenge_id: game_score&.first&.id,user_id: @ex_user_user.id) %> @@ -286,7 +287,7 @@

实训详情

- <% @games.each_with_index do |game, index| %> + <% games&.each_with_index do |game, index| %>

第<%= index+1 %>关<%= game.challenge.subject %> From 3eadedc9ad3ec611e67016d761870fe42f312f78 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Thu, 27 Jun 2019 14:11:38 +0800 Subject: [PATCH 020/256] fix bug --- app/services/exercise_user_pdf_service.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/services/exercise_user_pdf_service.rb b/app/services/exercise_user_pdf_service.rb index 663d8b042..d76e792c4 100644 --- a/app/services/exercise_user_pdf_service.rb +++ b/app/services/exercise_user_pdf_service.rb @@ -47,7 +47,7 @@ class ExerciseUserPdfService end def load_data - @exercise_questions = exercise.exercise_questions.joins(:exercise_choices,:exercise_shixun_challenges,:exercise_answers,:exercise_shixun_answers,:exercise_answer_comments) + @exercise_questions = exercise.exercise_questions @exercise_ques_count = @exercise_questions.count # 全部的题目数 @exercise_ques_scores = @exercise_questions.pluck(:question_score).sum @@ -80,8 +80,9 @@ class ExerciseUserPdfService exercise_ques_shixun = @exercise_questions.find_by_custom("question_type",5) @exercise_ques_shixun_count = exercise_ques_shixun.all.count @exercise_ques_shixun_scores = exercise_ques_shixun.pluck(:question_score).sum + @exercise_questions = @exercise_questions.joins(:exercise_choices,:exercise_shixun_challenges,:exercise_answers,:exercise_shixun_answers,:exercise_answer_comments,:exercise_standard_answers) - challenge_ids = @exercise_questions.pluck("exercise_shixun_challenges.challenge_id") + # challenge_ids = @exercise_questions.pluck("exercise_shixun_challenges.challenge_id") get_each_student_exercise(exercise.id,@exercise_questions,@ex_user_user.id) # @games = @exercise_user.user.games.ch_games(challenge_ids) From d89a9138d15975ecafc33c0b6adf234c934e8a03 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Thu, 27 Jun 2019 14:13:27 +0800 Subject: [PATCH 021/256] fix bug --- app/services/exercise_user_pdf_service.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/services/exercise_user_pdf_service.rb b/app/services/exercise_user_pdf_service.rb index d76e792c4..ae90f60bf 100644 --- a/app/services/exercise_user_pdf_service.rb +++ b/app/services/exercise_user_pdf_service.rb @@ -80,7 +80,7 @@ class ExerciseUserPdfService exercise_ques_shixun = @exercise_questions.find_by_custom("question_type",5) @exercise_ques_shixun_count = exercise_ques_shixun.all.count @exercise_ques_shixun_scores = exercise_ques_shixun.pluck(:question_score).sum - @exercise_questions = @exercise_questions.joins(:exercise_choices,:exercise_shixun_challenges,:exercise_answers,:exercise_shixun_answers,:exercise_answer_comments,:exercise_standard_answers) + # @exercise_questions = @exercise_questions.joins(:exercise_choices,:exercise_shixun_challenges,:exercise_answers,:exercise_shixun_answers,:exercise_answer_comments,:exercise_standard_answers) # challenge_ids = @exercise_questions.pluck("exercise_shixun_challenges.challenge_id") From ca172d57e796a813a65d581fcebe1fcd47fb09e1 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Thu, 27 Jun 2019 14:19:15 +0800 Subject: [PATCH 022/256] fix exprot exercise bugs 2 --- app/services/exercise_user_pdf_service.rb | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/app/services/exercise_user_pdf_service.rb b/app/services/exercise_user_pdf_service.rb index ae90f60bf..422c3ad5f 100644 --- a/app/services/exercise_user_pdf_service.rb +++ b/app/services/exercise_user_pdf_service.rb @@ -47,7 +47,7 @@ class ExerciseUserPdfService end def load_data - @exercise_questions = exercise.exercise_questions + @exercise_questions = exercise.exercise_questions.includes(:exercise_choices,:exercise_shixun_challenges,:exercise_answers,:exercise_shixun_answers,:exercise_answer_comments,:exercise_standard_answers) @exercise_ques_count = @exercise_questions.count # 全部的题目数 @exercise_ques_scores = @exercise_questions.pluck(:question_score).sum @@ -80,11 +80,7 @@ class ExerciseUserPdfService exercise_ques_shixun = @exercise_questions.find_by_custom("question_type",5) @exercise_ques_shixun_count = exercise_ques_shixun.all.count @exercise_ques_shixun_scores = exercise_ques_shixun.pluck(:question_score).sum - # @exercise_questions = @exercise_questions.joins(:exercise_choices,:exercise_shixun_challenges,:exercise_answers,:exercise_shixun_answers,:exercise_answer_comments,:exercise_standard_answers) - - # challenge_ids = @exercise_questions.pluck("exercise_shixun_challenges.challenge_id") get_each_student_exercise(exercise.id,@exercise_questions,@ex_user_user.id) - # @games = @exercise_user.user.games.ch_games(challenge_ids) end end \ No newline at end of file From 6e36cc24ab8b803028f99cad4d90ce6198b8c859 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Thu, 27 Jun 2019 14:22:04 +0800 Subject: [PATCH 023/256] fix bug --- app/services/exercise_user_pdf_service.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/services/exercise_user_pdf_service.rb b/app/services/exercise_user_pdf_service.rb index 422c3ad5f..28857dff9 100644 --- a/app/services/exercise_user_pdf_service.rb +++ b/app/services/exercise_user_pdf_service.rb @@ -47,7 +47,7 @@ class ExerciseUserPdfService end def load_data - @exercise_questions = exercise.exercise_questions.includes(:exercise_choices,:exercise_shixun_challenges,:exercise_answers,:exercise_shixun_answers,:exercise_answer_comments,:exercise_standard_answers) + @exercise_questions = exercise.exercise_questions @exercise_ques_count = @exercise_questions.count # 全部的题目数 @exercise_ques_scores = @exercise_questions.pluck(:question_score).sum @@ -81,6 +81,8 @@ class ExerciseUserPdfService @exercise_ques_shixun_count = exercise_ques_shixun.all.count @exercise_ques_shixun_scores = exercise_ques_shixun.pluck(:question_score).sum + @exercise_questions = @exercise_questions.includes(:exercise_choices,:exercise_shixun_challenges,:exercise_answers,:exercise_shixun_answers,:exercise_answer_comments,:exercise_standard_answers) get_each_student_exercise(exercise.id,@exercise_questions,@ex_user_user.id) + end end \ No newline at end of file From 28c641510c13cd7a6477df4c8176ac6dbec0292d Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Thu, 27 Jun 2019 14:32:05 +0800 Subject: [PATCH 024/256] fix bug --- app/controllers/exercises_controller.rb | 2 +- app/templates/exercise_export/exercise_export.css | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/exercises_controller.rb b/app/controllers/exercises_controller.rb index 44b694239..e1e8e226b 100644 --- a/app/controllers/exercises_controller.rb +++ b/app/controllers/exercises_controller.rb @@ -1334,7 +1334,7 @@ class ExercisesController < ApplicationController #导出空白试卷 def export_exercise - @exercise_questions = @exercise.exercise_questions.order("question_number ASC") + @exercise_questions = @exercise.exercise_questions.includes(:exercise_choices).order("question_number ASC") filename = "#{current_user.real_name}_#{@course.name}_#{@exercise.exercise_name}_#{Time.current.strftime('%Y%m%d%H%M%S')}.pdf" stylesheets = "#{Rails.root}/app/templates/exercise_export/exercise_export.css" render pdf: 'exercise_export/blank_exercise', filename: filename, stylesheets: stylesheets diff --git a/app/templates/exercise_export/exercise_export.css b/app/templates/exercise_export/exercise_export.css index e04f77035..9190e9251 100644 --- a/app/templates/exercise_export/exercise_export.css +++ b/app/templates/exercise_export/exercise_export.css @@ -156,7 +156,7 @@ p{ position: absolute; display: inline-block; bottom: 6px; - /*left: 1px;*/ + left: 1px; } .line-line { From aab9b3e56d9c098e648923486dff33ce53efd1b4 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Thu, 27 Jun 2019 14:40:15 +0800 Subject: [PATCH 025/256] =?UTF-8?q?=E5=AE=9A=E6=97=B6=E4=BB=BB=E5=8A=A1?= =?UTF-8?q?=E7=9A=84=E5=BC=82=E6=AD=A5=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...omework_absence_penalty_calculation_job.rb | 33 +++++ ...ework_anonymous_appeal_start_notify_job.rb | 27 ++++ app/jobs/homework_common_push_notify_job.rb | 2 +- .../homework_evaluation_comment_assgin_job.rb | 48 +++++++ .../homework_evaluation_start_notify_job.rb | 30 +++++ ...homework_publish_update_work_status_job.rb | 2 +- config/sidekiq.yml | 2 + lib/tasks/homework_evaluation.rake | 122 +----------------- lib/tasks/homework_publishtime.rake | 56 +++----- ...rk_absence_penalty_calculation_job_spec.rb | 5 + ..._anonymous_appeal_start_notify_job_spec.rb | 5 + ...work_evaluation_comment_assgin_job_spec.rb | 5 + ...mework_evaluation_start_notify_job_spec.rb | 5 + 13 files changed, 184 insertions(+), 158 deletions(-) create mode 100644 app/jobs/homework_absence_penalty_calculation_job.rb create mode 100644 app/jobs/homework_anonymous_appeal_start_notify_job.rb create mode 100644 app/jobs/homework_evaluation_comment_assgin_job.rb create mode 100644 app/jobs/homework_evaluation_start_notify_job.rb create mode 100644 spec/jobs/homework_absence_penalty_calculation_job_spec.rb create mode 100644 spec/jobs/homework_anonymous_appeal_start_notify_job_spec.rb create mode 100644 spec/jobs/homework_evaluation_comment_assgin_job_spec.rb create mode 100644 spec/jobs/homework_evaluation_start_notify_job_spec.rb diff --git a/app/jobs/homework_absence_penalty_calculation_job.rb b/app/jobs/homework_absence_penalty_calculation_job.rb new file mode 100644 index 000000000..87f78f311 --- /dev/null +++ b/app/jobs/homework_absence_penalty_calculation_job.rb @@ -0,0 +1,33 @@ +class HomeworkAbsencePenaltyCalculationJob < ApplicationJob + queue_as :score + + def perform(homework_common_id) + homework_common = HomeworkCommon.find_by(id: homework_common_id) + return if homework_common.blank? + + #计算缺评扣分 参与匿评 + work_ids = homework_common.student_works.has_committed.pluck(:id) + homework_detail_manual = homework_common.homework_detail_manual + + homework_common.student_works.where("work_status != 0").each do |student_work| + absence_penalty_count = student_work.user.student_works_evaluation_distributions.where(student_work_id: work_ids).count - + student_work.user.student_works_scores.where(student_work_id: work_ids, reviewer_role: 3).group_by(:student_work_id).count + + student_work.absence_penalty = absence_penalty_count > 0 ? absence_penalty_count * homework_detail_manual.absence_penalty : 0 + student_work.save + end + + # 未参与匿评 + if homework_detail_manual.no_anon_penalty == 0 + all_dis_eva = StudentWorksEvaluationDistribution.where(student_work_id: work_ids) + has_sw_count = all_dis_eva.select("distinct user_id").count + anon_count = all_dis_eva.count / has_sw_count + homework_common.student_works.where("work_status != 0").each do |student_work| + if student_work.user.student_works_evaluation_distributions.where(student_work_id: work_ids).count == 0 + student_work.absence_penalty = homework_detail_manual.absence_penalty * anon_count + student_work.save + end + end + end + end +end diff --git a/app/jobs/homework_anonymous_appeal_start_notify_job.rb b/app/jobs/homework_anonymous_appeal_start_notify_job.rb new file mode 100644 index 000000000..97c369846 --- /dev/null +++ b/app/jobs/homework_anonymous_appeal_start_notify_job.rb @@ -0,0 +1,27 @@ +class HomeworkAnonymousAppealStartNotifyJob < ApplicationJob + queue_as :notify + + def perform(homework_common_id) + homework = HomeworkCommon.find_by(id: homework_common_id) + return if homework.blank? + eva_distribution = StudentWorksEvaluationDistribution.where(student_work_id: homework.student_works.pluck(:id)) + + attrs = %i[ + user_id trigger_user_id container_id container_type parent_container_id parent_container_type + belong_container_id belong_container_type viewed tiding_type created_at updated_at + ] + + same_attrs = { + trigger_user_id: homework.user_id, container_id: homework.id, container_type: 'HomeworkCommon', + parent_container_id: homework.id, parent_container_type: 'AnonymousAppeal', + belong_container_id: homework.course_id, belong_container_type: 'Course', + viewed: 0, tiding_type: 'HomeworkCommon' + } + Tiding.bulk_insert(*attrs) do |worker| + + eva_distribution.pluck(:user_id).uniq.each do |user_id| + worker.add same_attrs.merge(user_id: user_id) + end + end + end +end diff --git a/app/jobs/homework_common_push_notify_job.rb b/app/jobs/homework_common_push_notify_job.rb index 961face58..47956a14c 100644 --- a/app/jobs/homework_common_push_notify_job.rb +++ b/app/jobs/homework_common_push_notify_job.rb @@ -24,7 +24,7 @@ class HomeworkCommonPushNotifyJob < ApplicationJob same_attrs = { trigger_user_id: homework.user_id, container_id: homework.id, container_type: 'HomeworkCommon', parent_container_id: homework.id, parent_container_type: 'HomeworkPublish', - belong_container_id: task.course_id, belong_container_type: 'Course', + belong_container_id: homework.course_id, belong_container_type: 'Course', viewed: 0, tiding_type: 'HomeworkCommon' } Tiding.bulk_insert(*attrs) do |worker| diff --git a/app/jobs/homework_evaluation_comment_assgin_job.rb b/app/jobs/homework_evaluation_comment_assgin_job.rb new file mode 100644 index 000000000..2579ea18b --- /dev/null +++ b/app/jobs/homework_evaluation_comment_assgin_job.rb @@ -0,0 +1,48 @@ +class HomeworkEvaluationCommentAssginJob < ApplicationJob + queue_as :evaluation_comment + + def get_assigned_homeworks(student_works, n, index) + student_works += student_works + student_works[index + 1..index + n] + end + + def perform(homework_common_id) + homework_common = HomeworkCommon.find_by(id: homework_common_id) + return if homework_common.blank? + homework_detail_manual = homework_common.homework_detail_manual + + if homework_common.homework_type == "group" + student_works = homework_common.student_works.where("work_status != 0").group(:group_id) + student_work_projects = homework_common.student_works.where("work_status != 0").shuffle + student_work_projects.each do |pro_work| + n = homework_detail_manual.evaluation_num + n = (n < student_works.size && n != -1) ? n : student_works.size - 1 + work_index = -1 + student_works.each_with_index do |stu_work, stu_index| + if stu_work.group_id.to_i == pro_work.group_id.to_i + work_index = stu_index + end + end + assigned_homeworks = get_assigned_homeworks(student_works, n, work_index) + assigned_homeworks.each do |h| + student_works_evaluation_distributions = StudentWorksEvaluationDistribution.new(user_id: pro_work.user_id, student_work_id: h.id) + student_works_evaluation_distributions.save + end + end + + else + student_works = homework_common.student_works.has_committed + student_works = student_works.shuffle + student_works.each_with_index do |work, index| + user = work.user + n = homework_detail_manual.evaluation_num + n = (n < student_works.size && n != -1) ? n : student_works.size - 1 + assigned_homeworks = get_assigned_homeworks(student_works, n, index) + assigned_homeworks.each do |h| + student_works_evaluation_distributions = StudentWorksEvaluationDistribution.new(user_id: user.id, student_work_id: h.id) + student_works_evaluation_distributions.save + end + end + end + end +end diff --git a/app/jobs/homework_evaluation_start_notify_job.rb b/app/jobs/homework_evaluation_start_notify_job.rb new file mode 100644 index 000000000..709c37b32 --- /dev/null +++ b/app/jobs/homework_evaluation_start_notify_job.rb @@ -0,0 +1,30 @@ +class HomeworkEvaluationStartNotifyJob < ApplicationJob + queue_as :notify + + def perform(homework_common_id, content) + homework = HomeworkCommon.find_by(id: homework_common_id) + return if homework.blank? + course = homework.course + members = content.blank? ? course.course_members : course.teachers + tiding_type = content.blank? ? "HomeworkCommon" : "System" + + attrs = %i[ + user_id trigger_user_id container_id container_type parent_container_id parent_container_type + belong_container_id belong_container_type viewed tiding_type extra created_at updated_at + ] + + same_attrs = { + trigger_user_id: homework.user_id, container_id: homework.id, container_type: 'HomeworkCommon', + parent_container_id: homework.id, parent_container_type: 'AnonymousComment', + belong_container_id: homework.course_id, belong_container_type: 'Course', + viewed: 0, tiding_type: tiding_type, extra: content + } + Tiding.bulk_insert(*attrs) do |worker| + member_ids = members.pluck(:user_id).uniq + + member_ids.each do |user_id| + worker.add same_attrs.merge(user_id: user_id) + end + end + end +end diff --git a/app/jobs/homework_publish_update_work_status_job.rb b/app/jobs/homework_publish_update_work_status_job.rb index 0060ab270..fe03a3ac5 100644 --- a/app/jobs/homework_publish_update_work_status_job.rb +++ b/app/jobs/homework_publish_update_work_status_job.rb @@ -1,6 +1,6 @@ class HomeworkPublishUpdateWorkStatusJob < ApplicationJob # 作业发布时更新学生(发布前已开启过实训)的作业状态和成绩 - queue_as :default + queue_as :score def perform(group_ids, homework_id) # Do something later diff --git a/config/sidekiq.yml b/config/sidekiq.yml index a2b3fc0be..5bd9dad23 100644 --- a/config/sidekiq.yml +++ b/config/sidekiq.yml @@ -3,4 +3,6 @@ :logfile: log/sidekiq.log :queues: - [default, 3] + - [score, 4] + - [evaluation_comment, 5] - [notify, 100] \ No newline at end of file diff --git a/lib/tasks/homework_evaluation.rake b/lib/tasks/homework_evaluation.rake index cb7b51fae..d1fad8f14 100644 --- a/lib/tasks/homework_evaluation.rake +++ b/lib/tasks/homework_evaluation.rake @@ -23,59 +23,11 @@ namespace :homework_evaluation do else student_works = homework_common.student_works.has_committed end - if student_works.present? && student_works.length >= 2 - if homework_common.homework_type == "group" - student_work_projects = homework_common.student_works.where("work_status != 0").shuffle - student_work_projects.each_with_index do |pro_work, pro_index| - n = homework_detail_manual.evaluation_num - n = (n < student_works.size && n != -1) ? n : student_works.size - 1 - work_index = -1 - student_works.each_with_index do |stu_work, stu_index| - if stu_work.group_id.to_i == pro_work.group_id.to_i - work_index = stu_index - end - end - assigned_homeworks = get_assigned_homeworks(student_works, n, work_index) - assigned_homeworks.each do |h| - student_works_evaluation_distributions = StudentWorksEvaluationDistribution.new(user_id: pro_work.user_id, student_work_id: h.id) - student_works_evaluation_distributions.save - end - #更新CourseHomeworkStatistics中该学生的待匿评数 - # course_statistics = CourseHomeworkStatistics.find_by_course_id_and_user_id(homework_common.course_id, pro_work.user_id) - # course_statistics.update_attribute('un_evaluation_work_num', course_statistics.un_evaluation_work_num + n) if course_statistics - end - else - student_works = student_works.shuffle - student_works.each_with_index do |work, index| - user = work.user - n = homework_detail_manual.evaluation_num - n = (n < student_works.size && n != -1) ? n : student_works.size - 1 - assigned_homeworks = get_assigned_homeworks(student_works, n, index) - assigned_homeworks.each do |h| - student_works_evaluation_distributions = StudentWorksEvaluationDistribution.new(user_id: user.id, student_work_id: h.id) - student_works_evaluation_distributions.save - end + if student_works.size >= 2 + HomeworkEvaluationCommentAssginJob.perform_later(homework_common.id) - #更新CourseHomeworkStatistics中该学生的待匿评数 - # course_statistics = CourseHomeworkStatistics.find_by_course_id_and_user_id(homework_common.course_id, user.id) - # course_statistics.update_attribute('un_evaluation_work_num', course_statistics.un_evaluation_work_num + n) if course_statistics - end - end homework_detail_manual.update_column('comment_status', 3) - # 匿评开启消息邮件通知,# 所有人 - str = "" - homework_common.course.course_members.pluck(:user_id).uniq.each do |user_id| - str += "," if str != "" - str += "('#{user_id}', '#{homework_common.user_id}', '#{homework_common.id}','HomeworkCommon','#{homework_common.id}', - 'AnonymousComment',#{homework_common.course_id},'Course',0,'HomeworkCommon', - '#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}', '#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}')" - end - if str != "" - sql = "insert into tidings (user_id,trigger_user_id,container_id, container_type, parent_container_id, - parent_container_type, belong_container_id, belong_container_type, viewed, tiding_type, created_at, updated_at) values" + str - ActiveRecord::Base.connection.execute sql - end else #作业数小于2,启动失败, 只给老师和助教发 extra = "作品数量低于两个,无法开启匿评" @@ -83,20 +35,8 @@ namespace :homework_evaluation do else extra = "存在尚未截止的分班,无法开启匿评" end + HomeworkEvaluationStartNotifyJob.perform_later(homework_common.id, extra) if extra.present? - str = '' - homework_common.course.teachers.each do |mem| - str += "," if str != "" - str += "('#{mem.user.id}', '#{homework_common.user_id}', '#{homework_common.id}','HomeworkCommon','#{homework_common.id}', - 'AnonymousCommentFail',#{homework_common.course_id},'Course',0,'System','#{extra}', - '#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}', '#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}')" - end - if str != "" - sql = "insert into tidings (user_id,trigger_user_id,container_id, container_type,parent_container_id, - parent_container_type, belong_container_id, belong_container_type, viewed, tiding_type, extra, created_at, - updated_at) values" + str - ActiveRecord::Base.connection.execute sql - end homework_detail_manual.update_attributes(:evaluation_start => nil, :evaluation_end => nil, :absence_penalty => 0, :evaluation_num => 0, :appeal_time => nil, :appeal_penalty => 0) homework_common.update_attributes(:anonymous_comment => 0, :anonymous_appeal => 0) @@ -114,63 +54,15 @@ namespace :homework_evaluation do homework_detail_manuals.each do |homework_detail_manual| homework_common = homework_detail_manual.homework_common if homework_common.anonymous_comment #开启匿评状态才可关闭匿评 - #计算缺评扣分 参与匿评 - work_ids = "(" + homework_common.student_works.has_committed.map(&:id).join(",") + ")" - - homework_common.student_works.where("work_status != 0").each do |student_work| - absence_penalty_count = student_work.user.student_works_evaluation_distributions.where("student_work_id IN #{work_ids}").count - - student_work.user.student_works_scores.where("student_work_id IN #{work_ids} and reviewer_role = 3").count - - student_work.absence_penalty = absence_penalty_count > 0 ? absence_penalty_count * homework_detail_manual.absence_penalty : 0 - student_work.save - - #更新CourseHomeworkStatistics中该学生的待匿评数和缺评数 - # absence_penalty_count = absence_penalty_count > 0 ? absence_penalty_count : 0 - # course_statistics = CourseHomeworkStatistics.find_by_course_id_and_user_id(homework_common.course_id, student_work.user_id) - # course_statistics.update_attribute('un_evaluation_work_num', (course_statistics.un_evaluation_work_num - absence_penalty_count) < 0 ? 0 : - # (course_statistics.un_evaluation_work_num - absence_penalty_count)) if course_statistics - # course_statistics.update_attribute('absence_evaluation_work_num', course_statistics.absence_evaluation_work_num + absence_penalty_count) if course_statistics - end - - # 未参与匿评 - if homework_common.homework_detail_manual.no_anon_penalty == 0 - all_dis_eva = StudentWorksEvaluationDistribution.where("student_work_id IN #{work_ids}") - has_sw_count = all_dis_eva.select("distinct user_id").count - anon_count = all_dis_eva.count / has_sw_count - homework_common.student_works.where("work_status != 0").each do |student_work| - if student_work.user.student_works_evaluation_distributions.where("student_work_id IN #{work_ids}").count == 0 - student_work.absence_penalty = homework_detail_manual.absence_penalty * anon_count - student_work.save - end - end - end - if homework_common.anonymous_appeal homework_detail_manual.update_column('comment_status', 4) - # 申诉开启 - eva_distribution = StudentWorksEvaluationDistribution.where(:student_work_id => homework_common.student_works.pluck(:id)) - str = "" - eva_distribution.pluck(:user_id).uniq.each do |user_id| - str += "," if str != "" - str += "(#{user_id}, #{homework_common.user_id}, #{homework_common.id}, 'HomeworkCommon', #{homework_common.id}, - 'AnonymousAppeal', #{homework_common.course_id}, 'Course', 0, 'HomeworkCommon', - '#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}', '#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}')" - end - if str != "" - sql = "insert into tidings (user_id,trigger_user_id,container_id, container_type, parent_container_id, - parent_container_type, belong_container_id, belong_container_type, viewed, tiding_type, created_at, updated_at) values" + str - ActiveRecord::Base.connection.execute sql - end + # 申诉开启发送消息 + HomeworkAnonymousAppealStartNotifyJob.perform_later(homework_common.id) else homework_detail_manual.update_column('comment_status', 5) end - # 匿评关闭消息通知 给所有人发 - # course = homework_common.course - # course.members.each do |m| - # homework_common.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => course.id, :viewed => false, :status => 3) - # end - # 邮件通知 - # Mailer.send_mail_anonymous_comment_close(homework_common).deliver + + HomeworkAbsencePenaltyCalculationJob.perform_later(homework_common.id) end end end diff --git a/lib/tasks/homework_publishtime.rake b/lib/tasks/homework_publishtime.rake index 0e45b0224..cbfd4413a 100644 --- a/lib/tasks/homework_publishtime.rake +++ b/lib/tasks/homework_publishtime.rake @@ -21,34 +21,29 @@ namespace :homework_publishtime do homework_commons.each do |homework| homework_detail_manual = homework.homework_detail_manual homework_detail_manual.update_column('comment_status', 1) - course = homework.course - students = course.students - if !course.nil? && !students.empty? + # 统一设置的作业在这发消息,非统一设置的只给有全部分班权限的老师发 + if homework.unified_setting + HomeworkPublishUpdateWorkStatusJob.perform_later(nil, homework.id) + HomeworkCommonPushNotifyJob.perform_later(homework.id, nil) + else + course = homework.course + teachers = course.teachers.where.not(id: course.teacher_course_groups.select(:course_member_id)) + tid_str = "" - course.teachers.find_each do |member| + teachers.find_each do |member| tid_str += "," if tid_str != "" tid_str += "(#{member.user_id}, #{homework.user_id}, #{homework.id}, 'HomeworkCommon', #{homework.id}, 'HomeworkPublish', #{course.id}, 'Course', 0, 'HomeworkCommon', '#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}', '#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}')" end - if homework.unified_setting - students.each do |student| - tid_str += "," if tid_str != "" - tid_str += "(#{student.user_id}, #{homework.user_id}, #{homework.id}, 'HomeworkCommon', #{homework.id}, - 'HomeworkPublish', #{course.id}, 'Course', 0, 'HomeworkCommon', - '#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}', '#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}')" - end - HomeworkPublishUpdateWorkStatusJob.perform_now(nil, homework.id) - end if tid_str != "" tid_sql = "insert into tidings (user_id, trigger_user_id, container_id, container_type, parent_container_id, parent_container_type, belong_container_id, belong_container_type, viewed, tiding_type, created_at, updated_at) values" + tid_str ActiveRecord::Base.connection.execute tid_sql end - end - + end if homework.course_acts.size == 0 homework.course_acts << CourseActivity.new(:user_id => homework.user_id,:course_id => homework.course_id) end @@ -59,27 +54,8 @@ namespace :homework_publishtime do homework_group_settings.each do |homework_group| homework = homework_group.homework_common if homework.present? - course = homework.course - homework_detail_manual = homework.homework_detail_manual - homework_detail_manual.update_column('comment_status', 1) if homework_detail_manual.comment_status == 0 - - tid_str = "" - members = course.students.where(:course_group_id => homework_group.course_group_id) - members.find_each do |member| - tid_str += "," if tid_str != "" - tid_str += "(#{member.user_id}, #{homework.user_id}, #{homework.id}, 'HomeworkCommon', #{homework.id}, 'HomeworkPublish', - #{course.id}, 'Course', 0, 'HomeworkCommon', '#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}', - '#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}')" - end - if tid_str != "" - tid_sql = "insert into tidings (user_id, trigger_user_id, container_id, container_type, parent_container_id, - parent_container_type, belong_container_id, belong_container_type, viewed, tiding_type, created_at, - updated_at) values" + tid_str - ActiveRecord::Base.connection.execute tid_sql - end - HomeworkPublishUpdateWorkStatusJob.perform_now([homework_group.id], homework.id) - + HomeworkCommonPushNotifyJob.perform_later(homework.id, [homework_group.id]) end end Rails.logger.info("log--------------------------------homework_publish end") @@ -98,11 +74,10 @@ namespace :homework_publishtime do student_works = homework.student_works.where("work_status != 0") # none_student_works = homework.student_works.where("work_status = 0") else - setting = homework.homework_group_settings.where(:end_time => homework.end_time) + setting = homework.homework_group_settings.where(end_time: homework.end_time) unless setting.blank? - users = homework.course.students.where(:course_group_id => setting.map(&:course_group_id)) - user_ids = users.blank? ? "(-1)" : "(" + users.map(&:user_id).join(",") + ")" - student_works = homework.student_works.where("work_status != 0 and user_id in #{user_ids}") + users = homework.course.students.where(course_group_id: setting.pluck(:course_group_id)) + student_works = homework.student_works.where("work_status != 0").where(user_id: users.pluck(:user_id)) # none_student_works = homework.student_works.where("work_status = 0 and user_id in #{user_ids}") end end @@ -172,8 +147,7 @@ namespace :homework_publishtime do # homework_challenge_settings = homework.homework_challenge_settings users = homework.course.students.where(:course_group_id => homework_setting.course_group_id) - user_ids = users.blank? ? "(-1)" : "(" + users.map(&:user_id).join(",") + ")" - student_works = homework.student_works.where("work_status != 0 and user_id in #{user_ids}") + student_works = homework.student_works.where("work_status != 0").where(user_id: users.pluck(:user_id)) student_works.joins(:myshixun).where("myshixuns.status != 1").update_all(late_penalty: homework.late_penalty) if student_works.present? else # HomeworksService.new.update_student_eff_score homework # 分班设置的不需要另外算效率分 diff --git a/spec/jobs/homework_absence_penalty_calculation_job_spec.rb b/spec/jobs/homework_absence_penalty_calculation_job_spec.rb new file mode 100644 index 000000000..b347086ce --- /dev/null +++ b/spec/jobs/homework_absence_penalty_calculation_job_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe HomeworkAbsencePenaltyCalculationJob, type: :job do + pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/spec/jobs/homework_anonymous_appeal_start_notify_job_spec.rb b/spec/jobs/homework_anonymous_appeal_start_notify_job_spec.rb new file mode 100644 index 000000000..bd5db1e69 --- /dev/null +++ b/spec/jobs/homework_anonymous_appeal_start_notify_job_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe HomeworkAnonymousAppealStartNotifyJob, type: :job do + pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/spec/jobs/homework_evaluation_comment_assgin_job_spec.rb b/spec/jobs/homework_evaluation_comment_assgin_job_spec.rb new file mode 100644 index 000000000..7a31a825f --- /dev/null +++ b/spec/jobs/homework_evaluation_comment_assgin_job_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe HomeworkEvaluationCommentAssginJob, type: :job do + pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/spec/jobs/homework_evaluation_start_notify_job_spec.rb b/spec/jobs/homework_evaluation_start_notify_job_spec.rb new file mode 100644 index 000000000..b347ea1f5 --- /dev/null +++ b/spec/jobs/homework_evaluation_start_notify_job_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe HomeworkEvaluationStartNotifyJob, type: :job do + pending "add some examples to (or delete) #{__FILE__}" +end From 118cf21fdecd9106aaa3280c83ceb870f697fc1c Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Thu, 27 Jun 2019 14:41:36 +0800 Subject: [PATCH 026/256] =?UTF-8?q?=E9=80=89=E9=A2=98=E6=B2=A1=E4=BF=9D?= =?UTF-8?q?=E5=AD=98=E7=8F=AD=E7=BA=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/graduation_topics_controller.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/graduation_topics_controller.rb b/app/controllers/graduation_topics_controller.rb index 521aaffc6..c611069a8 100644 --- a/app/controllers/graduation_topics_controller.rb +++ b/app/controllers/graduation_topics_controller.rb @@ -193,8 +193,8 @@ class GraduationTopicsController < ApplicationController def student_select_topic user_unaccept_topics = @course.student_graduation_topics.where(user_id: current_user.id, status: [0, 1]) if user_unaccept_topics.size == 0 - member_id = @course.course_members.find_by_user_id(current_user.id) - StudentGraduationTopic.create(course_id: @course.id, user_id: current_user.id, course_member_id: member_id, + member = @course.course_members.find_by_user_id(current_user.id) + StudentGraduationTopic.create(course_id: @course.id, user_id: current_user.id, course_member_id: member.try(:id), graduation_topic_id: @graduation_topic.id) @graduation_topic.update_attribute(:status, 1) normal_status("选题成功") From b6216e29972241f3a5d9adaa748328b0abfe271f Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Thu, 27 Jun 2019 14:46:07 +0800 Subject: [PATCH 027/256] =?UTF-8?q?=E4=BD=9C=E5=93=81=E5=88=97=E8=A1=A8?= =?UTF-8?q?=E7=9A=84=E5=88=86=E6=95=B0=E6=9F=A5=E7=9C=8B=E6=9D=83=E9=99=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../homework_commons_controller.rb | 7 ++-- .../homework_commons/works_list.json.jbuilder | 36 +++++++++---------- 2 files changed, 23 insertions(+), 20 deletions(-) diff --git a/app/controllers/homework_commons_controller.rb b/app/controllers/homework_commons_controller.rb index 4abada488..59f745fb0 100644 --- a/app/controllers/homework_commons_controller.rb +++ b/app/controllers/homework_commons_controller.rb @@ -121,23 +121,26 @@ class HomeworkCommonsController < ApplicationController @work = @homework.user_work(current_user.id) # 学生已提交作品且补交(提交)已截止、作品公开、非匿评阶段 - if @work.work_status > 0 && @homework.work_public && + if @work&.work_status.to_i > 0 && @homework.work_public && ((!@homework.anonymous_comment && @homework.end_or_late) || @homework_detail_manual.comment_status > 4) @student_works = student_works.where("user_id != #{@work.id}") # 匿评、申诉阶段只能看到分配给自己的匿评作品 - elsif @work.work_status > 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 @is_evaluation = true @student_works = student_works.joins(:student_works_evaluation_distributions).where( "student_works_evaluation_distributions.user_id = #{@current_user.id}") else @student_works = [] end + @score_open = @homework.score_open && @work&.work_status.to_i > 0 elsif @user_course_identity < Course::STUDENT @student_works = @homework.teacher_works(@member) @all_member_count = @student_works.size + @score_open = true elsif @user_course_identity > Course::STUDENT && @homework.work_public @student_works = student_works + @score_open = false else @student_works = [] end diff --git a/app/views/homework_commons/works_list.json.jbuilder b/app/views/homework_commons/works_list.json.jbuilder index 716b12190..60441909b 100644 --- a/app/views/homework_commons/works_list.json.jbuilder +++ b/app/views/homework_commons/works_list.json.jbuilder @@ -33,19 +33,19 @@ elsif @user_course_identity == Course::STUDENT json.late_penalty @work.late_penalty if @homework.allow_late json.cost_time @work.myshixun.try(:total_cost_time) - json.work_score work_score_format(@work.work_score, true, @homework.score_open) - json.final_score work_score_format(@work.final_score, true, @homework.score_open) - json.efficiency work_score_format(@work.efficiency, true, @homework.score_open) - json.eff_score work_score_format(@work.eff_score, true, @homework.score_open) + json.work_score work_score_format(@work.work_score, true, @score_open) + json.final_score work_score_format(@work.final_score, true, @score_open) + json.efficiency work_score_format(@work.efficiency, true, @score_open) + json.eff_score work_score_format(@work.eff_score, true, @score_open) json.complete_count @work.myshixun.try(:passed_count) else json.(@work, :id, :work_status, :update_time, :ultimate_score) - json.work_score work_score_format(@work.work_score, true, @homework.score_open) - json.final_score work_score_format(@work.final_score, true, @homework.score_open) - json.teacher_score work_score_format(@work.teacher_score, true, @homework.score_open) - json.student_score work_score_format(@work.student_score, true, @homework.score_open) - json.teaching_asistant_score work_score_format(@work.teaching_asistant_score, true, @homework.score_open) + json.work_score work_score_format(@work.work_score, true, @score_open) + json.final_score work_score_format(@work.final_score, true, @score_open) + json.teacher_score work_score_format(@work.teacher_score, true, @score_open) + json.student_score work_score_format(@work.student_score, true, @score_open) + json.teaching_asistant_score work_score_format(@work.teaching_asistant_score, true, @score_open) json.ta_comment_count @work.ta_comment_count @@ -84,10 +84,10 @@ if @homework.homework_type == "practice" json.(work, :id, :work_status, :update_time, :ultimate_score) json.late_penalty work.late_penalty if @homework.allow_late - json.work_score work_score_format(work.work_score, @current_user == work.user, @homework.score_open) - json.final_score work_score_format(work.final_score, @current_user == work.user, @homework.score_open) - json.efficiency work_score_format(work.efficiency, @current_user == work.user, @homework.score_open) - json.eff_score work_score_format(work.eff_score, @current_user == work.user, @homework.score_open) + json.work_score work_score_format(work.work_score, @current_user == work.user, @score_open) + json.final_score work_score_format(work.final_score, @current_user == work.user, @score_open) + json.efficiency work_score_format(work.efficiency, @current_user == work.user, @score_open) + json.eff_score work_score_format(work.eff_score, @current_user == work.user, @score_open) json.cost_time work.myshixun.try(:total_cost_time) json.complete_count work.myshixun.try(:passed_count) @@ -117,11 +117,11 @@ elsif @homework.homework_type == "group" || @homework.homework_type == "normal" :teaching_asistant_score, :ultimate_score) json.late_penalty work.late_penalty if @homework.allow_late - json.work_score work_score_format(work.work_score, @current_user == work.user, @homework.score_open) - json.final_score work_score_format(work.final_score, @current_user == work.user, @homework.score_open) - json.teacher_score work_score_format(work.teacher_score, @current_user == work.user, @homework.score_open) - json.student_score work_score_format(work.student_score, @current_user == work.user, @homework.score_open) - json.teaching_asistant_score work_score_format(work.teaching_asistant_score, @current_user == work.user, @homework.score_open) + json.work_score work_score_format(work.work_score, @current_user == work.user, @score_open) + json.final_score work_score_format(work.final_score, @current_user == work.user, @score_open) + json.teacher_score work_score_format(work.teacher_score, @current_user == work.user, @score_open) + json.student_score work_score_format(work.student_score, @current_user == work.user, @score_open) + json.teaching_asistant_score work_score_format(work.teaching_asistant_score, @current_user == work.user, @score_open) # 助教评分次数 json.ta_comment_count work.ta_comment_count From c68bbfc937aa668e0f9ec524f4bdfceaa2eab422 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Thu, 27 Jun 2019 14:49:48 +0800 Subject: [PATCH 028/256] =?UTF-8?q?=E4=BD=9C=E5=93=81=E5=88=97=E8=A1=A8?= =?UTF-8?q?=E7=9A=84=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 59f745fb0..83bfd29fc 100644 --- a/app/controllers/homework_commons_controller.rb +++ b/app/controllers/homework_commons_controller.rb @@ -123,7 +123,7 @@ class HomeworkCommonsController < ApplicationController # 学生已提交作品且补交(提交)已截止、作品公开、非匿评阶段 if @work&.work_status.to_i > 0 && @homework.work_public && ((!@homework.anonymous_comment && @homework.end_or_late) || @homework_detail_manual.comment_status > 4) - @student_works = student_works.where("user_id != #{@work.id}") + @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 From 94daf8d429922fae5c761eaf86e1b431e556497e Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Thu, 27 Jun 2019 14:56:28 +0800 Subject: [PATCH 029/256] =?UTF-8?q?=E8=AF=84=E8=AE=BA=E9=9A=90=E8=97=8F?= =?UTF-8?q?=E5=90=8C=E6=AD=A5=E5=88=B0=E6=96=B0=E7=89=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/discusses_controller.rb | 15 ++++++++++++--- app/models/discuss.rb | 2 +- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/app/controllers/discusses_controller.rb b/app/controllers/discusses_controller.rb index 6e9c1427e..abedca8ba 100644 --- a/app/controllers/discusses_controller.rb +++ b/app/controllers/discusses_controller.rb @@ -7,9 +7,18 @@ class DiscussesController < ApplicationController page = params[:page].to_i offset = page * LIMIT # 总数,分页使用 - @disscuss_count = Discuss.where(:dis_id => @container.id, :dis_type => @container.class.to_s, :root_id => nil).count - @discusses = Discuss.limit(LIMIT).where(:dis_id => @container.id, :dis_type => @container.class.to_s, :root_id => nil). - includes(:user, :praise_tread).offset(offset) + if current_user.admin? + @disscuss_count = Discuss.where(:dis_id => @container.id, :dis_type => @container.class.to_s, :root_id => nil).count + @discusses = Discuss.limit(LIMIT).where(:dis_id => dis_id, :dis_type => dis_type, + :root_id => nil).includes(:user, :praise_tread).offset(offset) + else + disscusses = Discuss.where("dis_id = :dis_id and dis_type = :dis_type and root_id is null and + (hidden = :hidden or user_id = :user_id)", + {dis_id: dis_id, dis_type: dis_type, hidden: false, user_id: current_user.id}) + @disscuss_count = disscusses.count + @discusses = disscusses.limit(LIMIT).includes(:user, :praise_tread).offset(offset) + end + @current_user = current_user end diff --git a/app/models/discuss.rb b/app/models/discuss.rb index 602813e66..c1b08718c 100644 --- a/app/models/discuss.rb +++ b/app/models/discuss.rb @@ -36,7 +36,7 @@ class Discuss < ApplicationRecord def contents(shixun, user) return content unless hidden? - shixun.has_manager?(user) ? content : '违规评论已被屏蔽!' + shixun.has_manager?(user) ? content : '' end private From cea5187439158c5452463cc840e93d3e17505fad Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Thu, 27 Jun 2019 14:59:19 +0800 Subject: [PATCH 030/256] =?UTF-8?q?=E5=AE=9E=E8=AE=AD=E8=AF=84=E8=AE=BA?= =?UTF-8?q?=E6=94=B9=E7=89=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/discusses_controller.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/controllers/discusses_controller.rb b/app/controllers/discusses_controller.rb index abedca8ba..93cf90780 100644 --- a/app/controllers/discusses_controller.rb +++ b/app/controllers/discusses_controller.rb @@ -32,8 +32,10 @@ class DiscussesController < ApplicationController def create begin - @discuss = Discuss.create!(:dis_id => params[:container_id], :dis_type => params[:container_type], :content => params[:content].gsub(" \;", "").strip, - :user_id => current_user.id, :praise_count => 0, :position => params[:position], :challenge_id => params[:challenge_id]) + @discuss = Discuss.create!(:dis_id => params[:container_id], :dis_type => params[:container_type], + :content => params[:content].gsub(" \;", "").strip, :user_id => current_user.id, + :praise_count => 0, :position => params[:position], :challenge_id => params[:challenge_id], + :hidden => current_user.admin?) rescue Exception => e uid_logger_error("create discuss failed : #{e.message}") raise Educoder::TipException.new("评论异常") From 48b1d7ca159f58de7e24fe5afd511bd0b1654439 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Thu, 27 Jun 2019 14:59:56 +0800 Subject: [PATCH 031/256] =?UTF-8?q?=E5=88=A0=E9=99=A4=E4=BD=9C=E4=B8=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/homework_common.rb | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/app/models/homework_common.rb b/app/models/homework_common.rb index d55973ed8..c0882ec6f 100644 --- a/app/models/homework_common.rb +++ b/app/models/homework_common.rb @@ -169,12 +169,8 @@ class HomeworkCommon < ApplicationRecord #删除时更新题库中的引用数 def update_homework_bank_quotes - old_banks = self.homework_bank - unless old_banks.blank? - old_banks.each do |bank| - bank.update_attributes(quotes: (bank.quotes - 1) > 0 ? (bank.quotes - 1) : 0, homework_common_id: nil) - end - end + old_bank = self.homework_bank + old_bank.update_attributes(quotes: (old_bank.quotes - 1) > 0 ? (old_bank.quotes - 1) : 0, homework_common_id: nil) end # 查重是否有新结果 From f61490ab738d9499e50890524537f99a2ae6ab7b Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Thu, 27 Jun 2019 15:03:34 +0800 Subject: [PATCH 032/256] =?UTF-8?q?=E8=AF=84=E8=AE=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/discusses_controller.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/controllers/discusses_controller.rb b/app/controllers/discusses_controller.rb index 93cf90780..1d3b524f4 100644 --- a/app/controllers/discusses_controller.rb +++ b/app/controllers/discusses_controller.rb @@ -9,12 +9,12 @@ class DiscussesController < ApplicationController # 总数,分页使用 if current_user.admin? @disscuss_count = Discuss.where(:dis_id => @container.id, :dis_type => @container.class.to_s, :root_id => nil).count - @discusses = Discuss.limit(LIMIT).where(:dis_id => dis_id, :dis_type => dis_type, + @discusses = Discuss.limit(LIMIT).where(:dis_id => @container.id, :dis_type => @container.class.to_s, :root_id => nil).includes(:user, :praise_tread).offset(offset) else disscusses = Discuss.where("dis_id = :dis_id and dis_type = :dis_type and root_id is null and (hidden = :hidden or user_id = :user_id)", - {dis_id: dis_id, dis_type: dis_type, hidden: false, user_id: current_user.id}) + {dis_id: @container.id, dis_type: @container.class.to_s, hidden: false, user_id: current_user.id}) @disscuss_count = disscusses.count @discusses = disscusses.limit(LIMIT).includes(:user, :praise_tread).offset(offset) end @@ -35,7 +35,7 @@ class DiscussesController < ApplicationController @discuss = Discuss.create!(:dis_id => params[:container_id], :dis_type => params[:container_type], :content => params[:content].gsub(" \;", "").strip, :user_id => current_user.id, :praise_count => 0, :position => params[:position], :challenge_id => params[:challenge_id], - :hidden => current_user.admin?) + :hidden => !current_user.admin?) # 管理员回复的能够显示 rescue Exception => e uid_logger_error("create discuss failed : #{e.message}") raise Educoder::TipException.new("评论异常") From 39b87564feb04ee5f7f9d6e2f78f5814043d8ce0 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Thu, 27 Jun 2019 15:41:14 +0800 Subject: [PATCH 033/256] =?UTF-8?q?=E6=AF=95=E8=AE=BE=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../graduation_works_controller.rb | 6 +-- app/jobs/graduation_task_cross_comment_job.rb | 39 ++++++++++++++ .../graduation_task_publish_notify_job.rb | 4 +- ...ework_anonymous_appeal_start_notify_job.rb | 1 + lib/tasks/graduation_task.rake | 54 ++----------------- lib/tasks/homework_publishtime.rake | 5 +- .../graduation_task_cross_comment_job_spec.rb | 5 ++ ...graduation_task_publish_notify_job_spec.rb | 5 ++ 8 files changed, 62 insertions(+), 57 deletions(-) create mode 100644 app/jobs/graduation_task_cross_comment_job.rb create mode 100644 spec/jobs/graduation_task_cross_comment_job_spec.rb create mode 100644 spec/jobs/graduation_task_publish_notify_job_spec.rb diff --git a/app/controllers/graduation_works_controller.rb b/app/controllers/graduation_works_controller.rb index 9117112d3..09b9146e8 100644 --- a/app/controllers/graduation_works_controller.rb +++ b/app/controllers/graduation_works_controller.rb @@ -432,11 +432,11 @@ class GraduationWorksController < ApplicationController # 交叉评阅分配老师 def assign_teacher tip_exception(-1, "user_id不能为空") if params[:user_id].nil? - @work_assign_teacher = @work.graduation_work_comment_assignations.first + @work_assign_teacher = @work.graduation_work_comment_assignations.find_by(user_id: params[:user_id]) - if @work_assign_teacher + if @work_assign_teacher.present? # graduation_group_id: 已经是答辩组的需要 将答辩组清空 - @work_assign_teacher.update_attributes(user_id: params[:user_id], graduation_group_id: 0) + @work_assign_teacher.update_attributes(graduation_group_id: 0) else @work.graduation_work_comment_assignations << GraduationWorkCommentAssignation.new(graduation_task_id: @task.id, user_id: params[:user_id], diff --git a/app/jobs/graduation_task_cross_comment_job.rb b/app/jobs/graduation_task_cross_comment_job.rb new file mode 100644 index 000000000..64973a3e9 --- /dev/null +++ b/app/jobs/graduation_task_cross_comment_job.rb @@ -0,0 +1,39 @@ +# 毕设任务的交叉评阅分配 +class GraduationTaskCrossCommentJob < ApplicationJob + queue_as :evaluation_comment + + def perform(graduation_task_id) + task = GraduationTask.find_by(id: graduation_task_id) + return if task.blank? + + course = task.course + task.graduation_task_group_assignations.each do |assignation| + graduation_group = assignation.graduation_group + assign_group = assignation.assign_group + if graduation_group.present? && assign_group.present? + course_group_ids = course.teacher_course_groups.where(course_member_id: graduation_group.course_members.pluck(:id)).pluck(:course_group_id) + graduation_works = task.graduation_works.where(user_id: course.course_members.where(:course_group_id => course_group_ids).map(&:user_id), + work_status: [1, 2]) + if assign_group.course_members.count <= task.comment_num + graduation_works.each do |work| + assign_group.course_members.each do |member| + work.graduation_work_comment_assignations << GraduationWorkCommentAssignation.new( + graduation_group_id: assign_group.id, user_id: member.user_id, graduation_task_id: task.id) + end + end + else + member_user_ids = assign_group.course_members.pluck(:user_id) + count = 0 + graduation_works.each do |work| + for i in 1 .. task.comment_num + assign_user_id = member_user_ids[count % member_user_ids.size] + work.graduation_work_comment_assignations << GraduationWorkCommentAssignation.new( + graduation_group_id: assign_group.id, user_id: assign_user_id, graduation_task_id: task.id) + count += 1 + end + end + end + end + end + end +end diff --git a/app/jobs/graduation_task_publish_notify_job.rb b/app/jobs/graduation_task_publish_notify_job.rb index 3489aa711..92346ab27 100644 --- a/app/jobs/graduation_task_publish_notify_job.rb +++ b/app/jobs/graduation_task_publish_notify_job.rb @@ -18,8 +18,8 @@ class GraduationTaskPublishNotifyJob < ApplicationJob viewed: 0, tiding_type: 'GraduationTask' } Tiding.bulk_insert(*attrs) do |worker| - task.course.students.find_each do |student| - worker.add same_attrs.merge(user_id: student.user_id) + task.course.course_members.pluck(:user_id).uniq.find_each do |user_id| + worker.add same_attrs.merge(user_id: user_id) end end end diff --git a/app/jobs/homework_anonymous_appeal_start_notify_job.rb b/app/jobs/homework_anonymous_appeal_start_notify_job.rb index 97c369846..1c3098690 100644 --- a/app/jobs/homework_anonymous_appeal_start_notify_job.rb +++ b/app/jobs/homework_anonymous_appeal_start_notify_job.rb @@ -1,3 +1,4 @@ +# 匿评申诉开启时给分配了匿评的学生发消息 class HomeworkAnonymousAppealStartNotifyJob < ApplicationJob queue_as :notify diff --git a/lib/tasks/graduation_task.rake b/lib/tasks/graduation_task.rake index aad84491f..0d4dff237 100644 --- a/lib/tasks/graduation_task.rake +++ b/lib/tasks/graduation_task.rake @@ -5,27 +5,9 @@ namespace :graduation_task do tasks = GraduationTask.where("publish_time is not null and publish_time <= '#{Time.now}' and status = 0") tasks.each do |task| task.update_attributes(status: 1) - course = task.course - members = course.course_members - if !course.nil? && !members.empty? - tid_str = "" - members.find_each do |member| - tid_str += "," if tid_str != "" - tid_str += "(#{member.user_id}, #{task.user_id}, #{task.id}, 'GraduationTask', #{task.id}, 'TaskPublish', - #{course.id}, 'Course', 0, 'GraduationTask', '#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}', - '#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}')" - end - if tid_str != "" - tid_sql = "insert into tidings (user_id, trigger_user_id, container_id, container_type, parent_container_id, - parent_container_type, belong_container_id, belong_container_type, viewed, tiding_type, created_at, - updated_at) values" + tid_str - ActiveRecord::Base.connection.execute tid_sql - end - end + GraduationTaskPublishNotifyJob.perform_later(task.id) - if task.course_acts.size == 0 - task.course_acts << CourseActivity.new(user_id: task.user_id, course_id: task.course_id) - end + task.course_acts << CourseActivity.new(user_id: task.user_id, course_id: task.course_id) if task.course_acts.exists? end end @@ -62,37 +44,11 @@ namespace :graduation_task do tasks = GraduationTask.where("cross_comment = 1 and comment_time is not null and comment_time <= '#{Time.now}' and status = 2") tasks.each do |task| if task.comment_status == 4 - course = task.course - task.graduation_task_group_assignations.each do |assignation| - graduation_group = assignation.graduation_group - assign_group = assignation.assign_group - if graduation_group.present? && assign_group.present? - course_group_ids = course.teacher_course_groups.where(course_member_id: graduation_group.course_members.pluck(:id)).pluck(:course_group_id) - graduation_works = task.graduation_works.where(user_id: course.course_members.where(:course_group_id => course_group_ids).map(&:user_id), - work_status: [1, 2]) - if assign_group.course_members.count <= task.comment_num - graduation_works.each do |work| - assign_group.course_members.each do |member| - work.graduation_work_comment_assignations << GraduationWorkCommentAssignation.new( - graduation_group_id: assign_group.id, user_id: member.user_id, graduation_task_id: task.id) - end - end - else - member_user_ids = assign_group.course_members.pluck(:user_id) - count = 0 - graduation_works.each do |work| - for i in 1 .. task.comment_num - assign_user_id = member_user_ids[count % member_user_ids.size] - work.graduation_work_comment_assignations << GraduationWorkCommentAssignation.new( - graduation_group_id: assign_group.id, user_id: assign_user_id, graduation_task_id: task.id) - count += 1 - end - end - end - end - end + GraduationTaskCrossCommentJob.perform_later(task.id) end task.update_attributes(status: 3) + + # 给老师发消息 tid_str = "" task.course.teachers.find_each do |member| tid_str += "," if tid_str != "" diff --git a/lib/tasks/homework_publishtime.rake b/lib/tasks/homework_publishtime.rake index cbfd4413a..4c27f0317 100644 --- a/lib/tasks/homework_publishtime.rake +++ b/lib/tasks/homework_publishtime.rake @@ -44,9 +44,8 @@ namespace :homework_publishtime do ActiveRecord::Base.connection.execute tid_sql end end - if homework.course_acts.size == 0 - homework.course_acts << CourseActivity.new(:user_id => homework.user_id,:course_id => homework.course_id) - end + + homework.course_acts << CourseActivity.new(user_id: homework.user_id, course_id: homework.course_id) if homework.course_acts.exists? end # 分组设置发布时间的作业 diff --git a/spec/jobs/graduation_task_cross_comment_job_spec.rb b/spec/jobs/graduation_task_cross_comment_job_spec.rb new file mode 100644 index 000000000..d517d939b --- /dev/null +++ b/spec/jobs/graduation_task_cross_comment_job_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe GraduationTaskCrossCommentJob, type: :job do + pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/spec/jobs/graduation_task_publish_notify_job_spec.rb b/spec/jobs/graduation_task_publish_notify_job_spec.rb new file mode 100644 index 000000000..39f6046af --- /dev/null +++ b/spec/jobs/graduation_task_publish_notify_job_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe GraduationTaskPublishNotifyJob, type: :job do + pending "add some examples to (or delete) #{__FILE__}" +end From 67b6b735cd23a697ee0ff0aec7cecbcd77272aed Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Thu, 27 Jun 2019 15:58:34 +0800 Subject: [PATCH 034/256] =?UTF-8?q?=E5=AE=9E=E8=AE=AD=E8=AF=84=E8=AE=BA?= =?UTF-8?q?=E5=9B=9E=E5=A4=8D=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/discuss.rb | 6 ++++++ app/views/discusses/_discuss.json.jbuilder | 2 +- app/views/discusses/index.json.jbuilder | 3 +-- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/app/models/discuss.rb b/app/models/discuss.rb index c1b08718c..8d8dc0163 100644 --- a/app/models/discuss.rb +++ b/app/models/discuss.rb @@ -39,6 +39,12 @@ class Discuss < ApplicationRecord shixun.has_manager?(user) ? content : '' end + def child_discuss(user) + user.admin? ? + Discuss.where(parent_id: self.id).includes(:user).reorder(created_at: :asc) : + Discuss.where(parent_id: self.id, :hidden => false).includes(:user).reorder(created_at: :asc) + end + private def send_tiding diff --git a/app/views/discusses/_discuss.json.jbuilder b/app/views/discusses/_discuss.json.jbuilder index 1fcf150bc..da1ca5a6c 100644 --- a/app/views/discusses/_discuss.json.jbuilder +++ b/app/views/discusses/_discuss.json.jbuilder @@ -2,7 +2,7 @@ json.author do json.partial! 'users/user', user: discuss.user end json.id discuss.id -json.content discuss.contents(container, current_user) +json.content discuss.contents json.time time_from_now(discuss.created_at) json.position discuss.position json.shixun_id discuss.dis_id diff --git a/app/views/discusses/index.json.jbuilder b/app/views/discusses/index.json.jbuilder index 3d0ee9fc9..1b7a95eb3 100644 --- a/app/views/discusses/index.json.jbuilder +++ b/app/views/discusses/index.json.jbuilder @@ -2,8 +2,7 @@ json.disscuss_count @disscuss_count json.all @current_user.admin? json.comments @discusses do |discuss| json.partial! 'discusses/discuss', locals: { discuss: discuss, container: @container, current_user: @current_user } - child_discuss = Discuss.children(discuss.id) - json.children child_discuss do |c_d| + json.children discuss.child_discuss(current_user) do |c_d| json.partial! 'discusses/discuss', locals: { discuss: c_d, container: @container, current_user: @current_user } end end From 3286d175a2ccbe037df7a3f4305aa6af9ac99d74 Mon Sep 17 00:00:00 2001 From: jingquan huang Date: Thu, 27 Jun 2019 16:28:50 +0800 Subject: [PATCH 035/256] =?UTF-8?q?=E5=BC=80=E5=90=AF=E5=AE=9E=E8=AE=AD?= =?UTF-8?q?=E7=9A=84=E4=B8=80=E4=BA=9B=E6=94=B9=E9=80=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/shixuns_controller.rb | 29 +++++++++++++++------------ app/models/myshixun.rb | 8 +++----- app/services/git_service.rb | 5 +++++ 3 files changed, 24 insertions(+), 18 deletions(-) diff --git a/app/controllers/shixuns_controller.rb b/app/controllers/shixuns_controller.rb index 3b14eea84..a319dc58a 100644 --- a/app/controllers/shixuns_controller.rb +++ b/app/controllers/shixuns_controller.rb @@ -488,17 +488,19 @@ class ShixunsController < ApplicationController tip_show_exception(-3, "#{@shixun.opening_time.strftime('%Y-%m-%d %H:%M:%S')}") end current_myshixun = @shixun.current_myshixun(current_user.id) + + min_challenges = @shixun.challenges.pluck(:id , :st) + if current_myshixun + games = current_myshixun.games # 如果TPM和TPI的管卡数不相等或者关卡顺序错了,说明实训被极大的改动,需要重置 - if current_myshixun.games.count != @shixun.challenges_count || - current_myshixun.games.reorder(:challenge_id).pluck(:challenge_id) != @shixun.challenges.reorder(:id).pluck(:id) - uid_logger_error("7777777777777777#{current_myshixun.games.count}, #{@shixun.challenges_count}") + if games.size != min_challenges.size || games.map(&:challenge_id) != min_challenges.map{|challenge| challenge.first} # 这里页面弹框要收到 当前用户myshixun的identifier. tip_show_exception("/myshixuns/#{current_myshixun.try(:identifier)}/reset_my_game") end # 如果存在实训,则直接进入实训 - @current_task = current_myshixun.current_task + @current_task = current_myshixun.current_task(games) else # 如果未创建关卡一定不能开启实训,否则TPI没法找到当前的关卡 if @shixun.challenges_count == 0 @@ -506,10 +508,10 @@ class ShixunsController < ApplicationController end # 判断实训是否全为选择题 - is_choice_type = @shixun.is_choice_type? + is_choice_type = (min_challenges.size == min_challenges.select{|challenge| challenge.last == 1}.count) if !is_choice_type commit = GitService.commits(repo_path: @repo_path).try(:first) - Rails.logger.info("First comit########{commit}") + uid_logger("First comit########{commit}") tip_exception("开启实战前请先在版本库中提交代码") if commit.blank? commit_id = commit["id"] end @@ -528,13 +530,13 @@ class ShixunsController < ApplicationController # fork仓库 project_fork(myshixun, @repo_path, current_user.login) - #rep_url = Base64.urlsafe_encode64(repo_ip_url @repo_path ) - #uid_logger("start openGameInstance") - #uri = "#{cloud_bridge}/bridge/game/openGameInstance" - #logger.info("end openGameInstance") - #params = {tpiID: "#{myshixun.id}", tpmGitURL:rep_url, tpiRepoName: myshixun.repo_name.split("/").last} - #uid_logger("openGameInstance params is #{params}") - # res = interface_post uri, params, 83, "实训云平台繁忙(繁忙等级:83)" + rep_url = Base64.urlsafe_encode64(repo_ip_url @repo_path ) + uid_logger("start openGameInstance") + uri = "#{cloud_bridge}/bridge/game/openGameInstance" + logger.info("end openGameInstance") + params = {tpiID: "#{myshixun.id}", tpmGitURL:rep_url, tpiRepoName: myshixun.repo_name.split("/").last} + uid_logger("openGameInstance params is #{params}") + interface_post uri, params, 83, "实训云平台繁忙(繁忙等级:83)" end # 其它创建关卡等操作 challenges = @shixun.challenges @@ -565,6 +567,7 @@ class ShixunsController < ApplicationController end end end + # gameID 及实训ID # status: 0 , 1 申请过, 2,实训关卡路径未填, 3 实训标签未填, 4 实训未创建关卡 def publish diff --git a/app/models/myshixun.rb b/app/models/myshixun.rb index a1aca3253..d8f294a39 100644 --- a/app/models/myshixun.rb +++ b/app/models/myshixun.rb @@ -53,14 +53,12 @@ class Myshixun < ApplicationRecord end # 当前任务:一个实训中只可能一个未完成任务(status 0或1只会存在一条记录) - # status:0 可以测评的,正在测评的 + # status:0 可以测评的; 1 正在测评的; 2评测通过的; 3未开启的 # 如果都完成,则当前任务为最后一个任务 - def current_task - games = self.games + def current_task games current_game = games.select{|game| game.status == 1 || game.status == 0}.first if current_game.blank? - current_game = Game.find_by_sql("SELECT g.* FROM games g, challenges c where g.myshixun_id=#{self.id} - and g.challenge_id = c.id and g.status = 2 order by c.position desc").first + current_game = games.last end current_game end diff --git a/app/services/git_service.rb b/app/services/git_service.rb index 3298185bf..076f62920 100644 --- a/app/services/git_service.rb +++ b/app/services/git_service.rb @@ -33,7 +33,12 @@ class GitService res = https.request(req) body = res.body logger.info("--uri_exec: .....res is #{body}") + content = JSON.parse(body) + if content["code"] != 0 + raise("版本库异常") + logger.error("repository error: #{content['msg']}") + end #raise content["msg"] if content["code"] != 0 content["data"] From 86e8ab96973ba71dbd4792773e13e5324465e8f8 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Thu, 27 Jun 2019 16:33:22 +0800 Subject: [PATCH 036/256] =?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/controllers/polls_controller.rb | 7 ++-- app/helpers/student_works_helper.rb | 2 +- app/jobs/poll_publish_notify_job.rb | 16 +++++++-- lib/tasks/graduation_task.rake | 2 +- lib/tasks/homework_publishtime.rake | 4 +-- lib/tasks/poll_publish.rake | 52 +++++++---------------------- 6 files changed, 31 insertions(+), 52 deletions(-) diff --git a/app/controllers/polls_controller.rb b/app/controllers/polls_controller.rb index 119226c87..6fbba1c3d 100644 --- a/app/controllers/polls_controller.rb +++ b/app/controllers/polls_controller.rb @@ -263,7 +263,6 @@ class PollsController < ApplicationController if g_course.map(&:to_i).sort == user_course_groups.sort # 如果是设置为全部班级,则问卷不用分组,且问卷设定为统一设置,否则则分组设置 poll.poll_group_settings.destroy_all poll_unified = true - notify_student_ids = @course.students.pluck(:user_id) else poll_unified = false g_course.each do |i| @@ -282,13 +281,11 @@ class PollsController < ApplicationController new_poll_group.save end end - - notify_student_ids = @course.students.where(course_group_id: params[:group_ids]).pluck(:user_id) + group_ids = params[:group_ids] end else poll.poll_group_settings.destroy_all poll_unified = true - notify_student_ids = @course.students.pluck(:user_id) end if poll.end_time.blank? e_time = ex_end_time @@ -309,7 +306,7 @@ class PollsController < ApplicationController if poll.course_acts.size == 0 poll.course_acts << CourseActivity.new(:user_id => poll.user_id,:course_id => poll.course_id) end - PollPublishNotifyJob.perform_later(poll.id, notify_student_ids) + PollPublishNotifyJob.perform_later(poll.id, group_ids) end end normal_status(0, "问卷发布成功!") diff --git a/app/helpers/student_works_helper.rb b/app/helpers/student_works_helper.rb index 17cdd41a7..a7103b4bf 100644 --- a/app/helpers/student_works_helper.rb +++ b/app/helpers/student_works_helper.rb @@ -145,7 +145,7 @@ module StudentWorksHelper else user_name = message_user.real_name user_login = message_user.login - image_url = url_to_avatar(score.user) + image_url = url_to_avatar(message_user) end {user_name: user_name, user_login: user_login, user_image_url: image_url} end diff --git a/app/jobs/poll_publish_notify_job.rb b/app/jobs/poll_publish_notify_job.rb index bc31957e0..d7ed1ae02 100644 --- a/app/jobs/poll_publish_notify_job.rb +++ b/app/jobs/poll_publish_notify_job.rb @@ -2,10 +2,20 @@ class PollPublishNotifyJob < ApplicationJob queue_as :notify - def perform(poll_id, receiver_ids) + def perform(poll_id, group_ids) poll = Poll.find_by(id: poll_id) return if poll.blank? user = poll.user + course = poll.course + + if group_ids.present? + students = course.students.where(course_group_id: group_ids) + subquery = course.teacher_course_groups.where(course_group_id: group_ids).select(:course_member_id) + teachers = course.teachers.where(id: subquery) + else + students = course.students + teachers = course.teachers + end attrs = %i[ user_id trigger_user_id container_id container_type parent_container_id parent_container_type @@ -19,14 +29,14 @@ class PollPublishNotifyJob < ApplicationJob viewed: 0, tiding_type: 'Poll' } Tiding.bulk_insert(*attrs) do |worker| - teacher_ids = poll.course.teachers.pluck(:user_id) + teacher_ids = teachers.pluck(:user_id) unless poll.tidings.exists?(parent_container_type: 'PollPublish', user_id: teacher_ids) poll.course.teachers.find_each do |teacher| worker.add same_attrs.merge(user_id: teacher.user_id) end end - receiver_ids.each do |user_id| + students.pluck(:user_id).each do |user_id| worker.add same_attrs.merge(user_id: user_id) end end diff --git a/lib/tasks/graduation_task.rake b/lib/tasks/graduation_task.rake index 0d4dff237..58f7764d0 100644 --- a/lib/tasks/graduation_task.rake +++ b/lib/tasks/graduation_task.rake @@ -7,7 +7,7 @@ namespace :graduation_task do task.update_attributes(status: 1) GraduationTaskPublishNotifyJob.perform_later(task.id) - task.course_acts << CourseActivity.new(user_id: task.user_id, course_id: task.course_id) if task.course_acts.exists? + task.course_acts << CourseActivity.new(user_id: task.user_id, course_id: task.course_id) if !task.course_acts.exists? end end diff --git a/lib/tasks/homework_publishtime.rake b/lib/tasks/homework_publishtime.rake index 4c27f0317..7ee2a4a07 100644 --- a/lib/tasks/homework_publishtime.rake +++ b/lib/tasks/homework_publishtime.rake @@ -45,7 +45,7 @@ namespace :homework_publishtime do end end - homework.course_acts << CourseActivity.new(user_id: homework.user_id, course_id: homework.course_id) if homework.course_acts.exists? + homework.course_acts << CourseActivity.new(user_id: homework.user_id, course_id: homework.course_id) if !homework.course_acts.exists? end # 分组设置发布时间的作业 @@ -54,7 +54,7 @@ namespace :homework_publishtime do homework = homework_group.homework_common if homework.present? HomeworkPublishUpdateWorkStatusJob.perform_now([homework_group.id], homework.id) - HomeworkCommonPushNotifyJob.perform_later(homework.id, [homework_group.id]) + HomeworkCommonPushNotifyJob.perform_later(homework.id, [homework_group.course_group_id]) end end Rails.logger.info("log--------------------------------homework_publish end") diff --git a/lib/tasks/poll_publish.rake b/lib/tasks/poll_publish.rake index 6ced88908..8cec43565 100644 --- a/lib/tasks/poll_publish.rake +++ b/lib/tasks/poll_publish.rake @@ -9,39 +9,22 @@ namespace :poll_publish do polls = Poll.includes(:poll_users).where("publish_time is not null and polls_status = 1 and publish_time <=?",Time.now) polls.each do |poll| poll.update_attributes(:polls_status => 2) - course = poll.course - tid_str = "" - course.teachers.find_each do |member| - tid_str += "," if tid_str != "" - tid_str += "(#{member.user_id}, #{poll.user_id}, #{poll.id}, 'Poll', #{poll.id}, 'PollPublish', #{course.id}, 'Course', 0, 'Poll', '#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}', '#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}')" - end if poll.unified_setting - course.students.find_each do |student| + PollPublishNotifyJob.perform_later(poll.id, nil) + else + course = poll.course + teachers = course.teachers.where.not(id: course.teacher_course_groups.select(:course_member_id)) + tid_str = "" + teachers.find_each do |member| tid_str += "," if tid_str != "" - tid_str += "(#{student.user_id}, #{poll.user_id}, #{poll.id}, 'Poll', #{poll.id}, 'PollPublish', #{course.id}, 'Course', 0, 'Poll', '#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}', '#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}')" - end - end - if tid_str != "" - tid_sql = "insert into tidings (user_id, trigger_user_id, container_id, container_type, parent_container_id, parent_container_type, belong_container_id, belong_container_type, viewed, tiding_type, created_at, updated_at) values" + tid_str - ActiveRecord::Base.connection.execute tid_sql - end - - if poll.poll_users.count == 0 - str = "" - course.students.find_each do |student| - str += "," if str != "" - str += "(#{student.user_id},#{poll.id}, 0, '#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}', '#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}')" + tid_str += "(#{member.user_id}, #{poll.user_id}, #{poll.id}, 'Poll', #{poll.id}, 'PollPublish', #{course.id}, 'Course', 0, 'Poll', '#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}', '#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}')" end - - if str != "" - sql = "insert into poll_users (user_id, poll_id, commit_status, created_at, updated_at) values" + str - ActiveRecord::Base.connection.execute sql + if tid_str != "" + tid_sql = "insert into tidings (user_id, trigger_user_id, container_id, container_type, parent_container_id, parent_container_type, belong_container_id, belong_container_type, viewed, tiding_type, created_at, updated_at) values" + tid_str + ActiveRecord::Base.connection.execute tid_sql end end - - if poll.course_acts.size == 0 - poll.course_acts << CourseActivity.new(:user_id => poll.user_id,:course_id => poll.course_id) - end + poll.course_acts << CourseActivity.new(user_id: poll.user_id, course_id: poll.course_id) if !poll.course_acts.exists? end # 分组设置发布时间的问卷 @@ -49,19 +32,8 @@ namespace :poll_publish do poll_group_settings.each do |poll_group| poll = poll_group.poll if poll.present? - course = poll.course poll.update_attributes(:polls_status => 2) if poll.polls_status == 1 - - tid_str = "" - members = course.course_members.where(:course_group_id => poll_group.course_group_id) - members.find_each do |member| - tid_str += "," if tid_str != "" - tid_str += "(#{member.user_id},#{poll.user_id}, #{poll.id}, 'Poll', #{poll.id}, 'PollPublish', #{course.id}, 'Course', 0, 'Poll', '#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}', '#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}')" - end - if tid_str != "" - tid_sql = "insert into tidings (user_id, trigger_user_id, container_id, container_type, parent_container_id, parent_container_type, belong_container_id, belong_container_type, viewed, tiding_type, created_at, updated_at) values" + tid_str - ActiveRecord::Base.connection.execute tid_sql - end + PollPublishNotifyJob.perform_later(poll.id, [poll_group.course_group_id]) end end From fd3f85aa93123c7e02a4cc3c8824a6c0eb24d4f2 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Thu, 27 Jun 2019 16:50:35 +0800 Subject: [PATCH 037/256] =?UTF-8?q?=E5=AE=9E=E8=AE=AD=E8=AF=84=E8=AE=BA?= =?UTF-8?q?=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/discuss.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/app/models/discuss.rb b/app/models/discuss.rb index 8d8dc0163..93f0d62cd 100644 --- a/app/models/discuss.rb +++ b/app/models/discuss.rb @@ -33,11 +33,11 @@ class Discuss < ApplicationRecord "/tasks/#{game&.identifier}" end - def contents(shixun, user) - return content unless hidden? - - shixun.has_manager?(user) ? content : '' - end + # def contents(shixun, user) + # return content unless hidden? + # + # shixun.has_manager?(user) ? content : '' + # end def child_discuss(user) user.admin? ? From 4e7098a3397586c464c2bc52468ff51c8d35f25e Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Thu, 27 Jun 2019 16:50:44 +0800 Subject: [PATCH 038/256] fix bug --- app/controllers/exercises_controller.rb | 2 +- app/services/exercise_user_pdf_service.rb | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/app/controllers/exercises_controller.rb b/app/controllers/exercises_controller.rb index e1e8e226b..720f8f593 100644 --- a/app/controllers/exercises_controller.rb +++ b/app/controllers/exercises_controller.rb @@ -1512,7 +1512,7 @@ class ExercisesController < ApplicationController end def get_exercise_question_counts #获取试卷的问题数及总分数 - exercise_questions = @exercise.exercise_questions.all + exercise_questions = @exercise.exercise_questions.includes(:exercise_choices,:exercise_shixun_challenges,:exercise_answers,:exercise_shixun_answers,:exercise_answer_comments,:exercise_standard_answers) @exercise_ques_count = exercise_questions.count # 全部的题目数 @exercise_ques_scores = exercise_questions.pluck(:question_score).sum diff --git a/app/services/exercise_user_pdf_service.rb b/app/services/exercise_user_pdf_service.rb index 28857dff9..8ee1d0cd4 100644 --- a/app/services/exercise_user_pdf_service.rb +++ b/app/services/exercise_user_pdf_service.rb @@ -47,7 +47,7 @@ class ExerciseUserPdfService end def load_data - @exercise_questions = exercise.exercise_questions + @exercise_questions = exercise.exercise_questions.includes(:exercise_choices,:exercise_shixun_challenges,:exercise_answers,:exercise_shixun_answers,:exercise_answer_comments,:exercise_standard_answers) @exercise_ques_count = @exercise_questions.count # 全部的题目数 @exercise_ques_scores = @exercise_questions.pluck(:question_score).sum @@ -81,7 +81,6 @@ class ExerciseUserPdfService @exercise_ques_shixun_count = exercise_ques_shixun.all.count @exercise_ques_shixun_scores = exercise_ques_shixun.pluck(:question_score).sum - @exercise_questions = @exercise_questions.includes(:exercise_choices,:exercise_shixun_challenges,:exercise_answers,:exercise_shixun_answers,:exercise_answer_comments,:exercise_standard_answers) get_each_student_exercise(exercise.id,@exercise_questions,@ex_user_user.id) end From b65f8bc0a532a391094f5f0ddbfc39f0b0085009 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Thu, 27 Jun 2019 16:51:59 +0800 Subject: [PATCH 039/256] =?UTF-8?q?=E5=AE=9E=E8=AE=AD=E8=AF=84=E8=AE=BA?= =?UTF-8?q?=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/discusses/_discuss.json.jbuilder | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/discusses/_discuss.json.jbuilder b/app/views/discusses/_discuss.json.jbuilder index da1ca5a6c..e7e6e425f 100644 --- a/app/views/discusses/_discuss.json.jbuilder +++ b/app/views/discusses/_discuss.json.jbuilder @@ -2,7 +2,7 @@ json.author do json.partial! 'users/user', user: discuss.user end json.id discuss.id -json.content discuss.contents +json.content discuss.content json.time time_from_now(discuss.created_at) json.position discuss.position json.shixun_id discuss.dis_id From a43f0b64e935980ba7b1833e3f045653563da0c6 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Thu, 27 Jun 2019 16:53:44 +0800 Subject: [PATCH 040/256] fix bug --- app/controllers/exercises_controller.rb | 19 +++++++++++-------- app/services/exercise_user_pdf_service.rb | 17 +++++++++-------- 2 files changed, 20 insertions(+), 16 deletions(-) diff --git a/app/controllers/exercises_controller.rb b/app/controllers/exercises_controller.rb index 720f8f593..9a46aa09b 100644 --- a/app/controllers/exercises_controller.rb +++ b/app/controllers/exercises_controller.rb @@ -1512,39 +1512,42 @@ class ExercisesController < ApplicationController end def get_exercise_question_counts #获取试卷的问题数及总分数 - exercise_questions = @exercise.exercise_questions.includes(:exercise_choices,:exercise_shixun_challenges,:exercise_answers,:exercise_shixun_answers,:exercise_answer_comments,:exercise_standard_answers) - @exercise_ques_count = exercise_questions.count # 全部的题目数 + exercise_questions = @exercise.exercise_questions + @exercise_ques_count = exercise_questions.size # 全部的题目数 @exercise_ques_scores = exercise_questions.pluck(:question_score).sum #单选题的数量及分数 exercise_single_ques = exercise_questions.find_by_custom("question_type",0) - @exercise_single_ques_count = exercise_single_ques.all.count + @exercise_single_ques_count = exercise_single_ques.size @exercise_single_ques_scores = exercise_single_ques.pluck(:question_score).sum #多选题的数量及分数 exercise_double_ques = exercise_questions.find_by_custom("question_type",1) - @exercise_double_ques_count = exercise_double_ques.all.count + @exercise_double_ques_count = exercise_double_ques.size @exercise_double_ques_scores = exercise_double_ques.pluck(:question_score).sum # 判断题数量及分数 exercise_ques_judge = exercise_questions.find_by_custom("question_type",2) - @exercise_ques_judge_count = exercise_ques_judge.all.count + @exercise_ques_judge_count = exercise_ques_judge.size @exercise_ques_judge_scores = exercise_ques_judge.pluck(:question_score).sum #填空题数量及分数 exercise_ques_null = exercise_questions.find_by_custom("question_type",3) - @exercise_ques_null_count = exercise_ques_null.all.count + @exercise_ques_null_count = exercise_ques_null.size @exercise_ques_null_scores = exercise_ques_null.pluck(:question_score).sum #简答题数量及分数 exercise_ques_main = exercise_questions.find_by_custom("question_type",4) - @exercise_ques_main_count = exercise_ques_main.all.count + @exercise_ques_main_count = exercise_ques_main.size @exercise_ques_main_scores = exercise_ques_main.pluck(:question_score).sum #实训题数量及分数 exercise_ques_shixun = exercise_questions.find_by_custom("question_type",5) - @exercise_ques_shixun_count = exercise_ques_shixun.all.count + @exercise_ques_shixun_count = exercise_ques_shixun.size @exercise_ques_shixun_scores = exercise_ques_shixun.pluck(:question_score).sum + + @exercise_questions = @exercise_questions.includes(:exercise_choices,:exercise_shixun_challenges,:exercise_answers,:exercise_shixun_answers,:exercise_answer_comments,:exercise_standard_answers) + end #获取用户有权限的分班 diff --git a/app/services/exercise_user_pdf_service.rb b/app/services/exercise_user_pdf_service.rb index 8ee1d0cd4..63fbb5a1d 100644 --- a/app/services/exercise_user_pdf_service.rb +++ b/app/services/exercise_user_pdf_service.rb @@ -47,40 +47,41 @@ class ExerciseUserPdfService end def load_data - @exercise_questions = exercise.exercise_questions.includes(:exercise_choices,:exercise_shixun_challenges,:exercise_answers,:exercise_shixun_answers,:exercise_answer_comments,:exercise_standard_answers) - @exercise_ques_count = @exercise_questions.count # 全部的题目数 + @exercise_questions = exercise.exercise_questions + @exercise_ques_count = @exercise_questions.size # 全部的题目数 @exercise_ques_scores = @exercise_questions.pluck(:question_score).sum #单选题的数量及分数 exercise_single_ques = @exercise_questions.find_by_custom("question_type",0) - @exercise_single_ques_count = exercise_single_ques.all.count + @exercise_single_ques_count = exercise_single_ques.size @exercise_single_ques_scores = exercise_single_ques.pluck(:question_score).sum #多选题的数量及分数 exercise_double_ques = @exercise_questions.find_by_custom("question_type",1) - @exercise_double_ques_count = exercise_double_ques.all.count + @exercise_double_ques_count = exercise_double_ques.size @exercise_double_ques_scores = exercise_double_ques.pluck(:question_score).sum # 判断题数量及分数 exercise_ques_judge = @exercise_questions.find_by_custom("question_type",2) - @exercise_ques_judge_count = exercise_ques_judge.all.count + @exercise_ques_judge_count = exercise_ques_judge.size @exercise_ques_judge_scores = exercise_ques_judge.pluck(:question_score).sum #填空题数量及分数 exercise_ques_null = @exercise_questions.find_by_custom("question_type",3) - @exercise_ques_null_count = exercise_ques_null.all.count + @exercise_ques_null_count = exercise_ques_null.size @exercise_ques_null_scores = exercise_ques_null.pluck(:question_score).sum #简答题数量及分数 exercise_ques_main = @exercise_questions.find_by_custom("question_type",4) - @exercise_ques_main_count = exercise_ques_main.all.count + @exercise_ques_main_count = exercise_ques_main.size @exercise_ques_main_scores = exercise_ques_main.pluck(:question_score).sum #实训题数量及分数 exercise_ques_shixun = @exercise_questions.find_by_custom("question_type",5) - @exercise_ques_shixun_count = exercise_ques_shixun.all.count + @exercise_ques_shixun_count = exercise_ques_shixun.size @exercise_ques_shixun_scores = exercise_ques_shixun.pluck(:question_score).sum + @exercise_questions = @exercise_questions.includes(:exercise_choices,:exercise_shixun_challenges,:exercise_answers,:exercise_shixun_answers,:exercise_answer_comments,:exercise_standard_answers) get_each_student_exercise(exercise.id,@exercise_questions,@ex_user_user.id) end From 28b39b94f4cae61a7bf9deb8e932434e25d484ed Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Thu, 27 Jun 2019 16:58:12 +0800 Subject: [PATCH 041/256] fix bug --- app/controllers/exercises_controller.rb | 2 +- app/services/exercise_user_pdf_service.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/exercises_controller.rb b/app/controllers/exercises_controller.rb index 9a46aa09b..4b96afc85 100644 --- a/app/controllers/exercises_controller.rb +++ b/app/controllers/exercises_controller.rb @@ -1546,7 +1546,7 @@ class ExercisesController < ApplicationController @exercise_ques_shixun_count = exercise_ques_shixun.size @exercise_ques_shixun_scores = exercise_ques_shixun.pluck(:question_score).sum - @exercise_questions = @exercise_questions.includes(:exercise_choices,:exercise_shixun_challenges,:exercise_answers,:exercise_shixun_answers,:exercise_answer_comments,:exercise_standard_answers) + @exercise_questions = @exercise_questions&.includes(:exercise_choices,:exercise_shixun_challenges,:exercise_answers,:exercise_shixun_answers,:exercise_answer_comments,:exercise_standard_answers) end diff --git a/app/services/exercise_user_pdf_service.rb b/app/services/exercise_user_pdf_service.rb index 63fbb5a1d..22804092e 100644 --- a/app/services/exercise_user_pdf_service.rb +++ b/app/services/exercise_user_pdf_service.rb @@ -81,7 +81,7 @@ class ExerciseUserPdfService @exercise_ques_shixun_count = exercise_ques_shixun.size @exercise_ques_shixun_scores = exercise_ques_shixun.pluck(:question_score).sum - @exercise_questions = @exercise_questions.includes(:exercise_choices,:exercise_shixun_challenges,:exercise_answers,:exercise_shixun_answers,:exercise_answer_comments,:exercise_standard_answers) + @exercise_questions = @exercise_questions&.includes(:exercise_choices,:exercise_shixun_challenges,:exercise_answers,:exercise_shixun_answers,:exercise_answer_comments,:exercise_standard_answers) get_each_student_exercise(exercise.id,@exercise_questions,@ex_user_user.id) end From 7c1635f157fbb73172de7b5e91e9580df4993db9 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Thu, 27 Jun 2019 17:02:47 +0800 Subject: [PATCH 042/256] 1 --- 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 83bfd29fc..2f63f3ab9 100644 --- a/app/controllers/homework_commons_controller.rb +++ b/app/controllers/homework_commons_controller.rb @@ -1233,7 +1233,7 @@ class HomeworkCommonsController < ApplicationController # 代码查重届结果 def code_review_results # 如果有未获取结果的查重操作 则先读取结果 - get_new_code_reviews_result @homework + #get_new_code_reviews_result @homework @current_user = current_user # 列表数据 From a04bdef1eb3655de4c45677172210039e4fd95bd Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Thu, 27 Jun 2019 17:05:59 +0800 Subject: [PATCH 043/256] =?UTF-8?q?=E8=AF=95=E5=8D=B7=E7=9A=84=E5=AE=9A?= =?UTF-8?q?=E6=97=B6=E4=BB=BB=E5=8A=A1=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 | 6 +-- app/jobs/exercise_publish_notify_job.rb | 19 ++++++--- app/jobs/poll_publish_notify_job.rb | 4 +- app/tasks/exercise_publish_task.rb | 51 +++++++------------------ 4 files changed, 31 insertions(+), 49 deletions(-) diff --git a/app/controllers/exercises_controller.rb b/app/controllers/exercises_controller.rb index e1e8e226b..2103a8614 100644 --- a/app/controllers/exercises_controller.rb +++ b/app/controllers/exercises_controller.rb @@ -729,7 +729,6 @@ class ExercisesController < ApplicationController if g_course.map(&:to_i).sort == user_course_groups.sort # 如果是设置为全部班级,则试卷不用分组,且试卷设定为统一设置,否则则分组设置 exercise.exercise_group_settings.destroy_all ex_unified = true - notify_receiver_ids = @course.students.pluck(:user_id) else ex_unified = false g_course.each do |i| @@ -749,12 +748,11 @@ class ExercisesController < ApplicationController end end - notify_receiver_ids = @course.students.where(course_group_id: params[:group_ids]).pluck(:user_id) + group_ids = params[:group_ids] end else exercise.exercise_group_settings.destroy_all ex_unified = true - notify_receiver_ids = @course.students.pluck(:user_id) end if exercise.end_time.blank? e_time = ex_end_time @@ -775,7 +773,7 @@ class ExercisesController < ApplicationController if exercise.course_acts.size == 0 exercise.course_acts << CourseActivity.new(:user_id => exercise.user_id,:course_id => exercise.course_id) end - ExercisePublishNotifyJob.perform_later(exercise.id, notify_receiver_ids) + ExercisePublishNotifyJob.perform_later(exercise.id, group_ids) end end end diff --git a/app/jobs/exercise_publish_notify_job.rb b/app/jobs/exercise_publish_notify_job.rb index c66fa5660..563f6ceb0 100644 --- a/app/jobs/exercise_publish_notify_job.rb +++ b/app/jobs/exercise_publish_notify_job.rb @@ -2,11 +2,20 @@ class ExercisePublishNotifyJob < ApplicationJob queue_as :notify - def perform(exercise_id, receiver_ids) + def perform(exercise_id, group_ids) exercise = Exercise.find_by(id: exercise_id) return if exercise.blank? user = exercise.user + if group_ids.present? + students = course.students.where(course_group_id: group_ids) + subquery = course.teacher_course_groups.where(course_group_id: group_ids).select(:course_member_id) + teachers = course.teachers.where(id: subquery) + else + students = course.students + teachers = course.teachers + end + attrs = %i[ user_id trigger_user_id container_id container_type parent_container_id parent_container_type belong_container_id belong_container_type viewed tiding_type created_at updated_at @@ -19,14 +28,14 @@ class ExercisePublishNotifyJob < ApplicationJob viewed: 0, tiding_type: 'Exercise' } Tiding.bulk_insert(*attrs) do |worker| - teacher_ids = exercise.course.teachers.pluck(:user_id) + teacher_ids = teachers.pluck(:user_id) unless exercise.tidings.exists?(parent_container_type: 'ExercisePublish', user_id: teacher_ids) - exercise.course.teachers.find_each do |teacher| - worker.add same_attrs.merge(user_id: teacher.user_id) + teacher_ids.find_each do |user_id| + worker.add same_attrs.merge(user_id: user_id) end end - receiver_ids.each do |user_id| + students.pluck(:user_id).each do |user_id| worker.add same_attrs.merge(user_id: user_id) end end diff --git a/app/jobs/poll_publish_notify_job.rb b/app/jobs/poll_publish_notify_job.rb index d7ed1ae02..89fb45ea5 100644 --- a/app/jobs/poll_publish_notify_job.rb +++ b/app/jobs/poll_publish_notify_job.rb @@ -31,8 +31,8 @@ class PollPublishNotifyJob < ApplicationJob Tiding.bulk_insert(*attrs) do |worker| teacher_ids = teachers.pluck(:user_id) unless poll.tidings.exists?(parent_container_type: 'PollPublish', user_id: teacher_ids) - poll.course.teachers.find_each do |teacher| - worker.add same_attrs.merge(user_id: teacher.user_id) + teacher_ids.find_each do |user_id| + worker.add same_attrs.merge(user_id: user_id) end end diff --git a/app/tasks/exercise_publish_task.rb b/app/tasks/exercise_publish_task.rb index 3df5f84ae..220512664 100644 --- a/app/tasks/exercise_publish_task.rb +++ b/app/tasks/exercise_publish_task.rb @@ -8,39 +8,24 @@ class ExercisePublishTask exercises = Exercise.includes(:exercise_users).where("publish_time is not null and exercise_status = 1 and publish_time <=?",Time.now) exercises&.each do |exercise| exercise.update_column('exercise_status', 2) - course = exercise.course - tid_str = "" - course.teachers.find_each do |member| - tid_str += "," if tid_str != "" - tid_str += "(#{member.user_id}, #{exercise.user_id}, #{exercise.id}, 'Exercise', #{exercise.id}, 'ExercisePublish', #{course.id}, 'Course', 0, 'Exercise', '#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}', '#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}')" - end + if exercise.unified_setting - course.students.find_each do |student| + ExercisePublishNotifyJob.perform_later(exercise.id, nil) + else + course = exercise.course + teachers = course.teachers.where.not(id: course.teacher_course_groups.select(:course_member_id)) + tid_str = "" + teachers.find_each do |member| tid_str += "," if tid_str != "" - tid_str += "(#{student.user_id}, #{exercise.user_id}, #{exercise.id}, 'Exercise', #{exercise.id}, 'ExercisePublish', #{course.id}, 'Course', 0, 'Exercise', '#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}', '#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}')" + tid_str += "(#{member.user_id}, #{exercise.user_id}, #{exercise.id}, 'Exercise', #{exercise.id}, 'ExercisePublish', #{course.id}, 'Course', 0, 'Exercise', '#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}', '#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}')" end - end - if tid_str != "" - tid_sql = "insert into tidings (user_id, trigger_user_id, container_id, container_type, parent_container_id, parent_container_type, belong_container_id, belong_container_type, viewed, tiding_type, created_at, updated_at) values" + tid_str - ActiveRecord::Base.connection.execute tid_sql - end - - if exercise.exercise_users.size == 0 - str = "" - course.students.find_each do |student| - str += "," if str != "" - str += "(#{student.user_id}, #{exercise.id}, 0, '#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}', '#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}')" - end - - if str != "" - sql = "insert into exercise_users (user_id, exercise_id, commit_status, created_at, updated_at) values" + str - ActiveRecord::Base.connection.execute sql + if tid_str != "" + tid_sql = "insert into tidings (user_id, trigger_user_id, container_id, container_type, parent_container_id, parent_container_type, belong_container_id, belong_container_type, viewed, tiding_type, created_at, updated_at) values" + tid_str + ActiveRecord::Base.connection.execute tid_sql end end - if exercise.course_acts.size == 0 - exercise.course_acts << CourseActivity.new(:user_id => exercise.user_id,:course_id => exercise.course_id) - end + exercise.course_acts << CourseActivity.new(user_id: exercise.user_id, course_id: exercise.course_id) if !exercise.course_acts.exists? end # 分组设置发布时间的测验 @@ -48,18 +33,8 @@ class ExercisePublishTask exercise_group_settings&.each do |exercise_group| exercise = exercise_group.exercise if exercise.present? - course = exercise.course exercise.update_attributes(:exercise_status => 2) if exercise.exercise_status == 1 - tid_str = "" - members = course.students.where(:course_group_id => exercise_group.course_group_id) - members.find_each do |member| - tid_str += "," if tid_str != "" - tid_str += "(#{member.user_id},#{exercise.user_id}, #{exercise.id}, 'Exercise', #{exercise.id}, 'ExercisePublish', #{course.id}, 'Course', 0, 'Exercise', '#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}', '#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}')" - end - if tid_str != "" - tid_sql = "insert into tidings (user_id, trigger_user_id, container_id, container_type, parent_container_id, parent_container_type, belong_container_id, belong_container_type, viewed, tiding_type, created_at, updated_at) values" + tid_str - ActiveRecord::Base.connection.execute tid_sql - end + ExercisePublishNotifyJob.perform_later(exercise.id, [exercise_group.course_group_id]) end end Rails.logger.info("log--------------------------------exercise_publish end") From 442ff88d39c7097baca78a7a476f2cc64a9237aa Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Thu, 27 Jun 2019 17:06:27 +0800 Subject: [PATCH 044/256] =?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/helpers/homework_commons_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/helpers/homework_commons_helper.rb b/app/helpers/homework_commons_helper.rb index 261fc85e9..c77ae5937 100644 --- a/app/helpers/homework_commons_helper.rb +++ b/app/helpers/homework_commons_helper.rb @@ -65,7 +65,7 @@ module HomeworkCommonsHelper # 作业统一设置、游客身份、超级管理员、分班权限不限的老师身份 if homework_common.unified_setting || identity > Course::STUDENT || identity == Course::ADMIN || - (identity < Course::STUDENT && teacher_course_groups.size == 0) + (identity < Course::STUDENT && teacher_course_groups.blank?) case ho_detail_manual.comment_status when 0 status << "未发布" From 3c92d07cf343a09b4a84d9f8fc470d1171601f79 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Thu, 27 Jun 2019 17:21:12 +0800 Subject: [PATCH 045/256] fix bug --- .../exercise_questions_controller.rb | 36 +++++++++++-------- app/controllers/poll_questions_controller.rb | 20 ++++++----- 2 files changed, 33 insertions(+), 23 deletions(-) diff --git a/app/controllers/exercise_questions_controller.rb b/app/controllers/exercise_questions_controller.rb index 490791918..8c4eb0a89 100644 --- a/app/controllers/exercise_questions_controller.rb +++ b/app/controllers/exercise_questions_controller.rb @@ -424,14 +424,18 @@ class ExerciseQuestionsController < ApplicationController begin choice_d_id = params[:choice_no].to_i # 选项的当前位置 question_choices = @exercise_question.exercise_choices - delete_answer = question_choices.find_choice_custom("choice_position",choice_d_id).first - left_choice = question_choices.left_choice_choose("choice_position",choice_d_id) - if left_choice.present? - left_choice.each do |p| - p.choice_position -= 1 - p.save - end - end + delete_answer = question_choices.find_by(choice_position: choice_d_id) + left_choices = question_choices.where("choice_position > ? ",choice_d_id) + left_choices.update_all("choice_position = choice_position - 1") if left_choices + # delete_answer = question_choices.find_choice_custom("choice_position",choice_d_id).first + # + # left_choice = question_choices.left_choice_choose("choice_position",choice_d_id) + # if left_choice.present? + # left_choice.each do |p| + # p.choice_position -= 1 + # p.save + # end + # end if delete_answer.destroy normal_status(0, "答案删除成功!") else @@ -450,13 +454,15 @@ class ExerciseQuestionsController < ApplicationController begin question_d_id = @exercise_question.question_number.to_i #问题的当前位置 exercise_questions = @exercise.exercise_questions - left_question = exercise_questions.left_question_choose("question_number",question_d_id) - if left_question.present? - left_question.each do |q| - q.question_number -= 1 - q.save - end - end + left_questions = exercise_questions.where("question_number > ?", question_d_id) + left_questions.update_all("question_number = question_number - 1") if left_questions + # left_question = exercise_questions.left_question_choose("question_number",question_d_id) + # if left_question.present? + # left_question.each do |q| + # q.question_number -= 1 + # q.save + # end + # end if @exercise_question.destroy normal_status(0, "问题删除成功!") else diff --git a/app/controllers/poll_questions_controller.rb b/app/controllers/poll_questions_controller.rb index 47cd236a9..c7407c129 100644 --- a/app/controllers/poll_questions_controller.rb +++ b/app/controllers/poll_questions_controller.rb @@ -156,14 +156,18 @@ class PollQuestionsController < ApplicationController begin answer_d_id = params[:answer_no].to_i # 答案的当前位置 poll_answers = @poll_question.poll_answers - delete_answer = poll_answers.find_answer_by_custom("answer_position",answer_d_id).first - left_answer = poll_answers.left_answer_choose("answer_position",answer_d_id) - if left_answer.present? - left_answer.each do |p| - p.answer_position -= 1 - p.save - end - end + delete_answer = poll_answers.find_by(answer_position: answer_d_id) + left_answers = poll_answers.where("answer_position > ?",answer_d_id) + left_answers.update_all("answer_position = answer_position - 1") if left_answers + + # delete_answer = poll_answers.find_answer_by_custom("answer_position",answer_d_id).first + # left_answer = poll_answers.left_answer_choose("answer_position",answer_d_id) + # if left_answer.present? + # left_answer.each do |p| + # p.answer_position -= 1 + # p.save + # end + # end if delete_answer.destroy normal_status(0, "答案删除成功!") else From 1f224b681296eaeb517373f76d22eb4305d9520a Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Thu, 27 Jun 2019 17:32:44 +0800 Subject: [PATCH 046/256] =?UTF-8?q?=E8=A7=A3=E9=94=81=E6=B5=8B=E8=AF=95?= =?UTF-8?q?=E9=9B=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/games_controller.rb | 19 ++++++++++++++----- .../homework_commons_controller.rb | 2 +- app/views/games/check_test_sets.json.jbuilder | 3 +-- 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/app/controllers/games_controller.rb b/app/controllers/games_controller.rb index 4e7afa516..00760209e 100644 --- a/app/controllers/games_controller.rb +++ b/app/controllers/games_controller.rb @@ -344,11 +344,20 @@ class GamesController < ApplicationController @game.update_attribute(:test_sets_view, true) # 扣分记录 Grade.create(:user_id => current_user.id, :container_id => @game.id, :score => -@minus_grade, :container_type => "testSet") - @status = 0 - @message = "解锁成功!" + max_query_index = game.query_index.to_i + # 区分评测过未评测过,未评测过按需求取数据 + if max_query_index > 0 + qurey_test_sets = TestSet.find_by_sql("SELECT o.code, o.actual_output, o.out_put, o.result, o.compile_success, o.test_set_position, o.query_index,t.is_public,t.input, t.output, g.id as game_id, c.id as challenge_id FROM outputs o,games g ,challenges c,test_sets t where + g.id=#{game.id} and o.query_index=#{max_query_index} and g.id = o.game_id and c.id= g.challenge_id and t.challenge_id = c.id and t.position =o.test_set_position order by o.query_index + ") + else + qurey_test_sets = TestSet.find_by_sql("SELECT t.is_public,t.input, t.output,t.position FROM games g ,challenges c,test_sets t where + g.id=#{game.id} and c.id= g.challenge_id and t.challenge_id = c.id + ") + end + testset_detail max_query_index, challenge else - @status = -1 - @message = "本操作需要扣除#{ @minus_grade }金币,您的金币不够了" + tip_exception(-1, "本操作需要扣除#{ @minus_grade }金币,您的金币不够了") end end @@ -813,7 +822,7 @@ class GamesController < ApplicationController # 评测测试机封装 def testset_detail max_query_index, challenge # 是否允许查看隐藏的测试集,以前的power - @allowed_hidden_testset = @identity < User::EDU_GAME_MANAGER + @allowed_hidden_testset = @identity < User::EDU_GAME_MANAGER || @game.test_sets_view #解锁的用户 if max_query_index > 0 uid_logger("max_query_index is #{max_query_index} game id is #{@game.id}, challenge_id is #{challenge.id}") diff --git a/app/controllers/homework_commons_controller.rb b/app/controllers/homework_commons_controller.rb index 2f63f3ab9..83bfd29fc 100644 --- a/app/controllers/homework_commons_controller.rb +++ b/app/controllers/homework_commons_controller.rb @@ -1233,7 +1233,7 @@ class HomeworkCommonsController < ApplicationController # 代码查重届结果 def code_review_results # 如果有未获取结果的查重操作 则先读取结果 - #get_new_code_reviews_result @homework + get_new_code_reviews_result @homework @current_user = current_user # 列表数据 diff --git a/app/views/games/check_test_sets.json.jbuilder b/app/views/games/check_test_sets.json.jbuilder index 017a75aea..ae44b54e9 100644 --- a/app/views/games/check_test_sets.json.jbuilder +++ b/app/views/games/check_test_sets.json.jbuilder @@ -1,2 +1 @@ -json.status @status -json.message @message \ No newline at end of file +json.partial! 'games/testset_list' \ No newline at end of file From 0800574303ca924e4592362f530ca651869fac13 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Thu, 27 Jun 2019 17:42:10 +0800 Subject: [PATCH 047/256] =?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/controllers/graduation_tasks_controller.rb | 5 ++++- app/models/graduation_work.rb | 2 +- app/views/graduation_tasks/tasks_list.json.jbuilder | 1 + 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/app/controllers/graduation_tasks_controller.rb b/app/controllers/graduation_tasks_controller.rb index 2e72c57d3..93d3cba3d 100644 --- a/app/controllers/graduation_tasks_controller.rb +++ b/app/controllers/graduation_tasks_controller.rb @@ -59,7 +59,8 @@ class GraduationTasksController < ApplicationController # 任务发布的情况下: 是老师身份或者任务已截止的情况下公开任务了作品设置的学生也能查看其他人的作品 if @task.published? && (@user_course_identity < Course::STUDENT || (@user_course_identity == Course::STUDENT && @work.present? && @work.take.work_status > 0 && - @task.status > 1 && @task.open_work)) + ((!@task.allow_late && @task.status > 1) || (@task.allow_late && @task.late_time && @task.late_time < Time.now)) && + (@task.open_work || @task.open_score))) # 如有有分班则看分班内的学生,否则看所有学生的作品 user_ids = if @user_course_identity < Course::STUDENT @@ -117,6 +118,7 @@ class GraduationTasksController < ApplicationController @work_list = @work_list.joins(user: :user_extension).order("user_extensions.#{rorder} #{b_order}") end + @view_work = @task.open_work || @user_course_identity < Course::STUDENT @work_count = @work_list.count @work_excel = @work_list @@ -150,6 +152,7 @@ class GraduationTasksController < ApplicationController end else @work_list = @work + @view_work = false @work_count = @work_list.count @all_work_count = @work_list.count respond_to do |format| diff --git a/app/models/graduation_work.rb b/app/models/graduation_work.rb index 49cab19ee..e9be0a43e 100644 --- a/app/models/graduation_work.rb +++ b/app/models/graduation_work.rb @@ -63,7 +63,7 @@ class GraduationWork < ApplicationRecord #用户是否有查看分数的权限 def check_score_power? current_user, course_identity - self.work_score.present? || course_identity < Course::STUDENT || self.user_id = current_user.id + self.work_score.present? && (course_identity < Course::STUDENT || self.user_id = current_user.id || graduation_task.open_score) end # 作品是否能够分配指导老师 diff --git a/app/views/graduation_tasks/tasks_list.json.jbuilder b/app/views/graduation_tasks/tasks_list.json.jbuilder index 62c95901f..7588b6b6e 100644 --- a/app/views/graduation_tasks/tasks_list.json.jbuilder +++ b/app/views/graduation_tasks/tasks_list.json.jbuilder @@ -59,6 +59,7 @@ if @task.published? || @user_course_identity < Course::STUDENT json.late_penalty work.late_penalty if @task.allow_late json.final_score work_final_score work, @current_user, @user_course_identity json.assign work.assign_power?(@user_course_identity) + json.view_work @view_work || @current_user.id == work.user_id end end end \ No newline at end of file From 2a559db5806d151f37f7329f7cb61741bfea2d1d Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Thu, 27 Jun 2019 17:57:35 +0800 Subject: [PATCH 048/256] =?UTF-8?q?=E6=AF=95=E8=AE=BE=E4=BD=9C=E5=93=81?= =?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/controllers/graduation_works_controller.rb | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app/controllers/graduation_works_controller.rb b/app/controllers/graduation_works_controller.rb index 09b9146e8..7cf1a3393 100644 --- a/app/controllers/graduation_works_controller.rb +++ b/app/controllers/graduation_works_controller.rb @@ -13,6 +13,7 @@ class GraduationWorksController < ApplicationController before_action :published_task, only: [:new, :create, :edit, :update, :search_member_list, :relate_project, :cancel_relate_project, :revise_attachment] before_action :edit_duration, only: [:edit, :update] + before_action :open_work, only: [:show, :supply_attachments, :comment_list] def new if @task.task_type == 2 && @task.base_on_project @@ -489,6 +490,11 @@ class GraduationWorksController < ApplicationController tip_exception("已过了修改时间") if @task.end_time && @task.end_time < Time.now end + # 作品是否公开 + def open_work + tip_exception(403,"没有操作权限") unless (@user_course_identity < Course::STUDENT || current_user == @work.user || @task.open_work) + end + def update_check work tip_exception("作品描述不能为空") if params[:description].blank? if @task.task_type == 2 From 2c48a24f485a98a329b7b69138841f3dbf2bbf90 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Thu, 27 Jun 2019 18:12:04 +0800 Subject: [PATCH 049/256] 1 --- app/controllers/games_controller.rb | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/app/controllers/games_controller.rb b/app/controllers/games_controller.rb index 00760209e..ac0b6baa8 100644 --- a/app/controllers/games_controller.rb +++ b/app/controllers/games_controller.rb @@ -344,17 +344,7 @@ class GamesController < ApplicationController @game.update_attribute(:test_sets_view, true) # 扣分记录 Grade.create(:user_id => current_user.id, :container_id => @game.id, :score => -@minus_grade, :container_type => "testSet") - max_query_index = game.query_index.to_i - # 区分评测过未评测过,未评测过按需求取数据 - if max_query_index > 0 - qurey_test_sets = TestSet.find_by_sql("SELECT o.code, o.actual_output, o.out_put, o.result, o.compile_success, o.test_set_position, o.query_index,t.is_public,t.input, t.output, g.id as game_id, c.id as challenge_id FROM outputs o,games g ,challenges c,test_sets t where - g.id=#{game.id} and o.query_index=#{max_query_index} and g.id = o.game_id and c.id= g.challenge_id and t.challenge_id = c.id and t.position =o.test_set_position order by o.query_index - ") - else - qurey_test_sets = TestSet.find_by_sql("SELECT t.is_public,t.input, t.output,t.position FROM games g ,challenges c,test_sets t where - g.id=#{game.id} and c.id= g.challenge_id and t.challenge_id = c.id - ") - end + max_query_index = @game.query_index.to_i testset_detail max_query_index, challenge else tip_exception(-1, "本操作需要扣除#{ @minus_grade }金币,您的金币不够了") From 248ff8a43464dcc0da7dad304144994456f9a918 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Thu, 27 Jun 2019 18:14:52 +0800 Subject: [PATCH 050/256] =?UTF-8?q?=E6=B5=8B=E8=AF=95=E9=9B=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/games/check_test_sets.json.jbuilder | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/app/views/games/check_test_sets.json.jbuilder b/app/views/games/check_test_sets.json.jbuilder index ae44b54e9..ba1ed64a6 100644 --- a/app/views/games/check_test_sets.json.jbuilder +++ b/app/views/games/check_test_sets.json.jbuilder @@ -1 +1,10 @@ -json.partial! 'games/testset_list' \ No newline at end of file +json.test_sets @qurey_test_sets do |test_set| + json.is_public test_set.is_public + json.result test_set.try(:result) + if test_set.is_public || @allowed_hidden_testset + json.input test_set.input + json.output test_set.output + json.actual_output evaluate_actual_output(test_set) + end + json.compile_success test_set.try(:compile_success) +end \ No newline at end of file From 5bc7ef8da5b9985cf9281dec5b821456c1683ee4 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Thu, 27 Jun 2019 18:15:06 +0800 Subject: [PATCH 051/256] =?UTF-8?q?=E4=BD=9C=E4=B8=9A=E7=9A=84=E6=9D=83?= =?UTF-8?q?=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/homework_commons_controller.rb | 2 +- app/controllers/student_works_controller.rb | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/app/controllers/homework_commons_controller.rb b/app/controllers/homework_commons_controller.rb index 83bfd29fc..b89fd6b67 100644 --- a/app/controllers/homework_commons_controller.rb +++ b/app/controllers/homework_commons_controller.rb @@ -121,7 +121,7 @@ class HomeworkCommonsController < ApplicationController @work = @homework.user_work(current_user.id) # 学生已提交作品且补交(提交)已截止、作品公开、非匿评阶段 - if @work&.work_status.to_i > 0 && @homework.work_public && + 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) @student_works = student_works.where("user_id != #{@work.user_id}") diff --git a/app/controllers/student_works_controller.rb b/app/controllers/student_works_controller.rb index 31c198fd8..ab026cf05 100644 --- a/app/controllers/student_works_controller.rb +++ b/app/controllers/student_works_controller.rb @@ -25,7 +25,7 @@ class StudentWorksController < ApplicationController before_action :require_score_id, only: [:destroy_score, :add_score_reply, :appeal_anonymous_score, :deal_appeal_score, :cancel_appeal] - before_action :is_evaluation, only: [:show, :supply_attachments] + before_action :is_evaluation, :open_work, only: [:show, :supply_attachments] def new uid_logger("#######new current_user : 1111") @@ -704,6 +704,11 @@ class StudentWorksController < ApplicationController [3, 4].include?(@homework.homework_detail_manual.comment_status) end + # 作品是否公开 + def open_work + tip_exception(403,"没有操作权限") unless (@user_course_identity < Course::STUDENT || current_user == @work.user || @homework.work_public || @is_evaluation) + end + def allow_add_score # 老师始终有评阅权限,匿评阶段内,学生对分配给该学生的作品有评阅权限 tip_exception(403, "没有权限") unless allow_score(@homework, @user_course_identity, current_user.id, @work) From 4f88d88bed4ff9a6195b4ca501eb0cbf9edec3e1 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Thu, 27 Jun 2019 18:22:56 +0800 Subject: [PATCH 052/256] =?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 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/models/student_work.rb b/app/models/student_work.rb index a2379f1a8..d5b746ebd 100644 --- a/app/models/student_work.rb +++ b/app/models/student_work.rb @@ -61,12 +61,12 @@ class StudentWork < ApplicationRecord # 当前用户该作品的匿评申诉总条数 def my_appeal_all_count user_id - student_works_scores.select{|score| score.reviewer_role == 3 && score.appeal_status != 0 && score.user_id = user_id}.size + student_works_scores.select{|score| score.reviewer_role == 3 && score.appeal_status != 0 && score.user_id == user_id}.size end # 当前用户该作品的匿评申诉总条数 def my_appeal_deal_count user_id - student_works_scores.select{|score| score.reviewer_role == 3 && score.appeal_status == 1 && score.user_id = user_id}.size + student_works_scores.select{|score| score.reviewer_role == 3 && score.appeal_status == 1 && score.user_id == user_id}.size end # 分组名 From 4d1ff1f0e8521b04587775ecfa91065de47b31fb Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Thu, 27 Jun 2019 18:32:21 +0800 Subject: [PATCH 053/256] fix bug --- app/controllers/exercise_questions_controller.rb | 16 ---------------- app/controllers/poll_questions_controller.rb | 8 -------- 2 files changed, 24 deletions(-) diff --git a/app/controllers/exercise_questions_controller.rb b/app/controllers/exercise_questions_controller.rb index 8c4eb0a89..dd0247f70 100644 --- a/app/controllers/exercise_questions_controller.rb +++ b/app/controllers/exercise_questions_controller.rb @@ -427,15 +427,6 @@ class ExerciseQuestionsController < ApplicationController delete_answer = question_choices.find_by(choice_position: choice_d_id) left_choices = question_choices.where("choice_position > ? ",choice_d_id) left_choices.update_all("choice_position = choice_position - 1") if left_choices - # delete_answer = question_choices.find_choice_custom("choice_position",choice_d_id).first - # - # left_choice = question_choices.left_choice_choose("choice_position",choice_d_id) - # if left_choice.present? - # left_choice.each do |p| - # p.choice_position -= 1 - # p.save - # end - # end if delete_answer.destroy normal_status(0, "答案删除成功!") else @@ -456,13 +447,6 @@ class ExerciseQuestionsController < ApplicationController exercise_questions = @exercise.exercise_questions left_questions = exercise_questions.where("question_number > ?", question_d_id) left_questions.update_all("question_number = question_number - 1") if left_questions - # left_question = exercise_questions.left_question_choose("question_number",question_d_id) - # if left_question.present? - # left_question.each do |q| - # q.question_number -= 1 - # q.save - # end - # end if @exercise_question.destroy normal_status(0, "问题删除成功!") else diff --git a/app/controllers/poll_questions_controller.rb b/app/controllers/poll_questions_controller.rb index c7407c129..84e21c4e8 100644 --- a/app/controllers/poll_questions_controller.rb +++ b/app/controllers/poll_questions_controller.rb @@ -160,14 +160,6 @@ class PollQuestionsController < ApplicationController left_answers = poll_answers.where("answer_position > ?",answer_d_id) left_answers.update_all("answer_position = answer_position - 1") if left_answers - # delete_answer = poll_answers.find_answer_by_custom("answer_position",answer_d_id).first - # left_answer = poll_answers.left_answer_choose("answer_position",answer_d_id) - # if left_answer.present? - # left_answer.each do |p| - # p.answer_position -= 1 - # p.save - # end - # end if delete_answer.destroy normal_status(0, "答案删除成功!") else From 0946b44fadf3db54e62b5f3458ebe5c3b0b3cca6 Mon Sep 17 00:00:00 2001 From: jingquan huang Date: Fri, 28 Jun 2019 08:42:50 +0800 Subject: [PATCH 054/256] =?UTF-8?q?=E5=BC=80=E5=90=AF=E6=8C=91=E6=88=98?= =?UTF-8?q?=E5=BD=93=E5=89=8D=E5=85=B3=E5=8D=A1=E5=90=8C=E6=AD=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/shixuns_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/shixuns_controller.rb b/app/controllers/shixuns_controller.rb index a319dc58a..d9588cb5b 100644 --- a/app/controllers/shixuns_controller.rb +++ b/app/controllers/shixuns_controller.rb @@ -557,7 +557,7 @@ class ShixunsController < ApplicationController # HomeworksService.new.update_myshixun_work_status myshixun UpdateMyshixunWorkStatusJob.perform_later(myshixun.id) - @current_task = myshixun.current_task + @current_task = myshixun.current_task(myshixun.games) uid_logger("## shixun exec: myshixun id is #{myshixun.id}") rescue Exception => e uid_logger_error(e.message) From 6f97f3e6c94891c72bb8e813f410f9427c114478 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Fri, 28 Jun 2019 09:01:05 +0800 Subject: [PATCH 055/256] =?UTF-8?q?=E5=85=B3=E5=8D=A1=E7=9A=84=E6=9D=83?= =?UTF-8?q?=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/challenges_controller.rb | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/app/controllers/challenges_controller.rb b/app/controllers/challenges_controller.rb index f2a964c8d..e315ab596 100644 --- a/app/controllers/challenges_controller.rb +++ b/app/controllers/challenges_controller.rb @@ -5,8 +5,8 @@ class ChallengesController < ApplicationController before_action :find_challenge, only: [:edit, :show, :update, :create_choose_question, :index_down, :index_up, :edit_choose_question, :show_choose_question, :destroy_challenge_choose, :update_choose_question, :destroy, :crud_answer, :answer] - # before_action :allowed, except: [:index, :show, :edit_choose_question, :edit] - + # 权限控制 + before_action :allowed, except: [:index] include ShixunsHelper include ChallengesHelper @@ -296,8 +296,7 @@ class ChallengesController < ApplicationController end def allowed - # 实训为发布前,除实训的管理者外,其他人都不人都不允许访问 - if !current_user.manager_of_shixun?(@shixun) && (@shixun.status < 1 || @shixun.hidden == 1) + unless current_user.manager_of_shixun?(@shixun) raise Educoder::TipException.new(403, "..") end end From 0773f7fc48004fb9a7e604dfedf5d662bffeb17a Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Fri, 28 Jun 2019 09:36:56 +0800 Subject: [PATCH 056/256] =?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/controllers/courses_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index 253bafa48..93eba89d8 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -11,7 +11,7 @@ class CoursesController < ApplicationController render_error(ex.model.errors.full_messages.join(',')) end - before_action :require_login, except: [:index, :show, :students, :teachers, :board_list, :mine, :all_course_groups] + before_action :require_login, except: [:index, :show, :students, :teachers, :board_list, :mine, :all_course_groups, :left_banner, :top_banner] before_action :set_course, :user_course_identity, only: [:show, :update, :destroy, :settings, :set_invite_code_halt, :set_public_or_private, :search_teacher_candidate, :teachers, :top_banner, :left_banner, :add_teacher_popup, :add_teacher, From 6e18d221112013a4d783dea3828ce224d3be623d Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Fri, 28 Jun 2019 09:42:59 +0800 Subject: [PATCH 057/256] =?UTF-8?q?=E6=89=93=E5=BC=80=E6=B3=A8=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/shixuns_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/shixuns_controller.rb b/app/controllers/shixuns_controller.rb index d9588cb5b..290b4387d 100644 --- a/app/controllers/shixuns_controller.rb +++ b/app/controllers/shixuns_controller.rb @@ -518,7 +518,7 @@ class ShixunsController < ApplicationController ActiveRecord::Base.transaction do begin - #cloud_bridge = edu_setting('cloud_bridge') + cloud_bridge = edu_setting('cloud_bridge') myshixun_identifier = generate_identifier Myshixun, 10 myshixun = @shixun.myshixuns.create!(user_id: current_user.id, identifier: myshixun_identifier, modify_time: @shixun.modify_time, reset_time: @shixun.reset_time, From 11c7e95a4606c25f27f6a1ba081534a5cdeff73b Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Fri, 28 Jun 2019 09:44:00 +0800 Subject: [PATCH 058/256] =?UTF-8?q?=E4=BC=98=E5=8C=96=E8=AF=95=E5=8D=B7?= =?UTF-8?q?=E7=9A=84=E5=88=A0=E9=99=A4=E6=85=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/exercise_question.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/models/exercise_question.rb b/app/models/exercise_question.rb index 5f456e21f..607ad1a29 100644 --- a/app/models/exercise_question.rb +++ b/app/models/exercise_question.rb @@ -5,11 +5,11 @@ class ExerciseQuestion < ApplicationRecord belongs_to :shixun, optional: true has_many :exercise_choices, :dependent => :destroy - has_many :exercise_answers, :dependent => :destroy + has_many :exercise_answers has_many :exercise_shixun_challenges,:dependent => :destroy - has_many :exercise_shixun_answers, :dependent => :destroy - has_many :exercise_answer_comments, :dependent => :destroy - has_many :exercise_standard_answers, :dependent => :destroy + has_many :exercise_shixun_answers + has_many :exercise_answer_comments + has_many :exercise_standard_answers scope :insert_question_ex, lambda {|k| where("question_number > ?",k)} scope :find_by_custom, lambda {|k,v| where("#{k} = ?",v)} #根据传入的参数查找问题 From fc2685a9d8433f36a1f2775ba5c4ed8acd607053 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Fri, 28 Jun 2019 10:07:55 +0800 Subject: [PATCH 059/256] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=90=88=E4=BD=9C?= =?UTF-8?q?=E8=80=85=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/shixuns_controller.rb | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/app/controllers/shixuns_controller.rb b/app/controllers/shixuns_controller.rb index 290b4387d..743594749 100644 --- a/app/controllers/shixuns_controller.rb +++ b/app/controllers/shixuns_controller.rb @@ -624,8 +624,11 @@ class ShixunsController < ApplicationController def add_collaborators raise("搜索内容不能为空") unless params[:search] member_ids = "(" + @shixun.shixun_members.map(&:user_id).join(',') + ")" - condition = "%#{params[:search].strip}%".gsub(" ","") - @users = User.where("id not in #{member_ids} and status = 1 and LOWER(concat(lastname, firstname, login, mail, nickname)) LIKE '#{condition}'") + user_name = "%#{params[:user_name].strip}%" + school_name = "%#{params[:school_name].strip}%" + @users = User.joins(user_extension: :school).where("users.id not in #{member_ids} AND users.status = 1 AND + LOWER(users.lastname) LIKE '#{user_name}' AND LOWER(schools.name) LIKE + '#{school_name}' ") end def shixun_members_added From e1c40cd30d9288e6a0b3e5cb03f44c5c8f0f9d3d Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Fri, 28 Jun 2019 10:11:27 +0800 Subject: [PATCH 060/256] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=90=88=E4=BD=9C?= =?UTF-8?q?=E8=80=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/shixuns_controller.rb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/controllers/shixuns_controller.rb b/app/controllers/shixuns_controller.rb index 743594749..ecbcbf872 100644 --- a/app/controllers/shixuns_controller.rb +++ b/app/controllers/shixuns_controller.rb @@ -626,9 +626,13 @@ class ShixunsController < ApplicationController member_ids = "(" + @shixun.shixun_members.map(&:user_id).join(',') + ")" user_name = "%#{params[:user_name].strip}%" school_name = "%#{params[:school_name].strip}%" - @users = User.joins(user_extension: :school).where("users.id not in #{member_ids} AND users.status = 1 AND + if user_name.present? || school_name.present? + @users = User.joins(user_extension: :school).where("users.id not in #{member_ids} AND users.status = 1 AND LOWER(users.lastname) LIKE '#{user_name}' AND LOWER(schools.name) LIKE - '#{school_name}' ") + '#{school_name}'") + else + @users = User.none + end end def shixun_members_added From 72c304faa5707b76035221cf2812e21fd88664ec Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Fri, 28 Jun 2019 10:22:03 +0800 Subject: [PATCH 061/256] =?UTF-8?q?=E8=AF=95=E5=8D=B7=E7=9A=84=E9=80=89?= =?UTF-8?q?=E9=A1=B9=E9=9A=8F=E6=9C=BA=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../exercise_questions/_exercise_questions.json.jbuilder | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/views/exercise_questions/_exercise_questions.json.jbuilder b/app/views/exercise_questions/_exercise_questions.json.jbuilder index 7a05c2e11..9445862ba 100644 --- a/app/views/exercise_questions/_exercise_questions.json.jbuilder +++ b/app/views/exercise_questions/_exercise_questions.json.jbuilder @@ -6,10 +6,11 @@ json.question_type question.question_type json.question_score question.question_score.round(1).to_s if question.question_type <= 2 #当为选择题或判断题时,只显示选项的位置 standard_answers_array = question.get_standard_answer_ids - exercise_choices = choices.order("choice_position ASC") ex_choice_random_boolean = (exercise_type.present? && exercise_type == 3 && (question.exercise.choice_random)) ? true : false #问题的选项随机打乱 if ex_choice_random_boolean - exercise_choices = exercise_choices.order("RAND()") + exercise_choices = choices.order("RAND()") + else + exercise_choices = choices.order("choice_position ASC") end json.question_choices do json.array! exercise_choices.each_with_index.to_a do |a,index| From 21c0d774e4d9e717b747dceb2de164bd6aa37210 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Fri, 28 Jun 2019 10:26:11 +0800 Subject: [PATCH 062/256] =?UTF-8?q?=E5=8F=91=E9=80=81=E8=87=B3=E6=90=9C?= =?UTF-8?q?=E7=B4=A2=E8=AF=BE=E7=A8=8B=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/shixuns_controller.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/controllers/shixuns_controller.rb b/app/controllers/shixuns_controller.rb index ecbcbf872..f8c2fce68 100644 --- a/app/controllers/shixuns_controller.rb +++ b/app/controllers/shixuns_controller.rb @@ -674,14 +674,14 @@ class ShixunsController < ApplicationController limit = params[:limit] || 20 if params[:search] search = "%#{params[:search].to_s.strip.downcase}%" - course_ids = Course.find_by_sql("SELECT c.id FROM courses c, members m, member_roles mr - WHERE m.course_id = c.id AND m.id=mr.member_id AND mr.role_id in (3,7,9) + course_ids = Course.find_by_sql("SELECT c.id FROM courses c, course_members m + WHERE m.course_id = c.id AND m.role in (1,2,3) AND m.user_id=#{current_user.id} AND c.is_delete = 0 AND c.is_end = 0 AND c.name like '#{search}' ").map(&:id) else - course_ids = Course.find_by_sql("SELECT c.id, c.name FROM courses c, members m, member_roles mr - WHERE m.course_id = c.id AND m.id=mr.member_id AND mr.role_id in (3,7,9) + course_ids = Course.find_by_sql("SELECT c.id, c.name FROM courses c, course_members m + WHERE m.course_id = c.id AND m.role in (1,2,3) AND m.user_id=#{current_user.id} AND c.is_delete = 0 AND c.is_end = 0").map(&:id) end From fa9448967bc96d6b679ae28c5a6718dd2fc789b2 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Fri, 28 Jun 2019 10:32:56 +0800 Subject: [PATCH 063/256] =?UTF-8?q?=E5=AE=9E=E8=AE=AD=E5=8F=91=E9=80=81?= =?UTF-8?q?=E8=87=B3=E8=AF=BE=E7=A8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/shixuns_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/shixuns_controller.rb b/app/controllers/shixuns_controller.rb index f8c2fce68..e3a658d7c 100644 --- a/app/controllers/shixuns_controller.rb +++ b/app/controllers/shixuns_controller.rb @@ -693,7 +693,7 @@ class ShixunsController < ApplicationController # 将实训发送到课程 def send_to_course @course = Course.find(params[:course_id]) - homework = HomeworksService.new.create_homework shixun, @course, nil, current_user + homework = HomeworksService.new.create_homework @shixun, @course, nil, current_user end # 二维码扫描下载 From d4bdc7e8e2145f730875937b70917d89082c9d25 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Fri, 28 Jun 2019 10:34:50 +0800 Subject: [PATCH 064/256] =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E5=8F=91=E9=80=81?= =?UTF-8?q?=E8=87=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/shixuns/send_to_course.json.jbuilder | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app/views/shixuns/send_to_course.json.jbuilder b/app/views/shixuns/send_to_course.json.jbuilder index dd087d3e2..b2e30f985 100644 --- a/app/views/shixuns/send_to_course.json.jbuilder +++ b/app/views/shixuns/send_to_course.json.jbuilder @@ -1,4 +1,3 @@ json.status 1 json.message "发送成功" -json.url course_homework_commons_path(@course.id, type: 4) -# json.url "#{Rails::configuration.educoder['old_edu_host']}/homework_common?course=#{@course.id}&homework_type=4" \ No newline at end of file +json.course_id @course.id \ No newline at end of file From 863dad51b1ab2d80da23070c020c20da2df13d53 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Fri, 28 Jun 2019 10:37:41 +0800 Subject: [PATCH 065/256] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=AF=95=E5=8D=B7?= =?UTF-8?q?=E7=AD=94=E9=A2=98=E5=88=97=E8=A1=A8=E7=9A=84=E5=AD=A6=E7=94=9F?= =?UTF-8?q?=E5=92=8C=E8=80=81=E5=B8=88=E8=A7=86=E8=A7=92=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/helpers/exercises_helper.rb | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/app/helpers/exercises_helper.rb b/app/helpers/exercises_helper.rb index 7e7e1070d..fd2877cc8 100644 --- a/app/helpers/exercises_helper.rb +++ b/app/helpers/exercises_helper.rb @@ -508,15 +508,14 @@ module ExercisesHelper current_user_group_name = course_group.first.name if course_group.present? end teacher_review = ex_user.subjective_score < 0.0 ? false : true - if ex_user_exercise_status != 3 || commit_status != 1 #试卷未截止或用户未提交 - # if (user_status != 0 && ex_user_exercise_status != 3)|| commit_status == 0 #不为教师,且试卷未截止;当前用户未提交 不显示分数 - ex_object_score = nil - ex_subject_score = nil - score = nil - else + if (user_status == 0 && commit_status == 1) || (user_status == 1 && ex_user_exercise_status == 3 && commit_status == 1) #老师都可以看,学生,需在试卷已提交,且已截止的情况下看 ex_object_score = ex_user.objective_score < 0.0 ? 0.0 : ex_user.objective_score.round(1).to_s ex_subject_score = ex_user.subjective_score < 0.0 ? nil : ex_user.subjective_score.round(1).to_s score = ex_user.score.present? ? ex_user.score.round(1).to_s : 0.0.to_s + else + ex_object_score = nil + ex_subject_score = nil + score = nil end { From 4122ccf438accbacf156baf67012c98f2041e37a Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Fri, 28 Jun 2019 10:48:23 +0800 Subject: [PATCH 066/256] fix bug --- app/helpers/exercises_helper.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/helpers/exercises_helper.rb b/app/helpers/exercises_helper.rb index fd2877cc8..8db7e8bfa 100644 --- a/app/helpers/exercises_helper.rb +++ b/app/helpers/exercises_helper.rb @@ -638,6 +638,9 @@ module ExercisesHelper if student_status == 2 #当前为老师,或为学生且已提交 user_score = exercise_answers.score_reviewed.pluck(:score).sum end + if user_score > q.question_score + user_score = q.question_score + end if ques_type <= 2 answered_content = exercise_answers.pluck(:exercise_choice_id) elsif ques_type == 3 From 76028ceca5e290dd7a620176189d6c673bd1a7cb Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Fri, 28 Jun 2019 10:59:31 +0800 Subject: [PATCH 067/256] =?UTF-8?q?=E5=AE=9E=E8=AE=AD=E8=AF=BE=E7=A8=8B?= =?UTF-8?q?=E5=8F=91=E9=80=81=E8=87=B3=E5=8A=9F=E8=83=BD=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/subjects_controller.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/subjects_controller.rb b/app/controllers/subjects_controller.rb index 4b954584b..c73fec500 100644 --- a/app/controllers/subjects_controller.rb +++ b/app/controllers/subjects_controller.rb @@ -164,8 +164,8 @@ class SubjectsController < ApplicationController end def choose_course - course_ids = Course.find_by_sql("SELECT c.id FROM courses c, members m, member_roles mr - WHERE m.course_id = c.id AND m.id=mr.member_id AND mr.role_id in (3,7,9) + course_ids = Course.find_by_sql("SELECT c.id FROM courses c, course_members m + WHERE m.course_id = c.id AND m.role in (1,2,3) AND m.user_id=#{current_user.id} AND c.is_delete = 0 AND c.is_end = 0").map(&:id) @courses = Course.where(id: course_ids) @none_shixun_ids = ShixunSchool.where("school_id != #{current_user.user_extension.try(:school_id)}").pluck(:shixun_id) From 6f900946d79d9cf912431b02fcc66d4eeaf89680 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Fri, 28 Jun 2019 11:08:15 +0800 Subject: [PATCH 068/256] =?UTF-8?q?=E6=90=9C=E7=B4=A2=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/shixuns_controller.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/app/controllers/shixuns_controller.rb b/app/controllers/shixuns_controller.rb index e3a658d7c..5f7c13964 100644 --- a/app/controllers/shixuns_controller.rb +++ b/app/controllers/shixuns_controller.rb @@ -622,7 +622,6 @@ class ShixunsController < ApplicationController end def add_collaborators - raise("搜索内容不能为空") unless params[:search] member_ids = "(" + @shixun.shixun_members.map(&:user_id).join(',') + ")" user_name = "%#{params[:user_name].strip}%" school_name = "%#{params[:school_name].strip}%" From 2a010194578c773162e856a6812ea74adb83b667 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Fri, 28 Jun 2019 12:23:10 +0800 Subject: [PATCH 069/256] =?UTF-8?q?=E8=AF=95=E5=8D=B7=E5=88=A0=E9=99=A4?= =?UTF-8?q?=E7=9A=84=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/exercise.rb | 13 ++++++++++--- app/models/exercise_answer.rb | 8 +++++++- app/models/exercise_choice.rb | 11 +++++++++-- app/models/exercise_question.rb | 10 ++++++++-- app/models/exercise_shixun_answer.rb | 7 ++++++- 5 files changed, 40 insertions(+), 9 deletions(-) diff --git a/app/models/exercise.rb b/app/models/exercise.rb index 0c8b97ca7..af84a5c49 100644 --- a/app/models/exercise.rb +++ b/app/models/exercise.rb @@ -3,9 +3,9 @@ class Exercise < ApplicationRecord belongs_to :exercise_bank, optional: true belongs_to :user - has_many :exercise_users,:dependent => :destroy - has_many :exercise_questions,:dependent => :destroy - has_many :exercise_group_settings,:dependent => :destroy + has_many :exercise_users + has_many :exercise_questions + has_many :exercise_group_settings has_many :tidings, as: :container has_many :course_acts, class_name: 'CourseActivity', as: :course_act, dependent: :destroy @@ -19,6 +19,13 @@ class Exercise < ApplicationRecord validates :exercise_name, length: { maximum: 60, too_long: "60 characters is the maximum allowed" } after_create :create_exercise_list + after_destroy :destroy_other_relations + + def destroy_other_relations + exercise_users.destroy_all + exercise_questions.destroy_all + exercise_group_settings.destroy_all + end def create_exercise_list str = "" diff --git a/app/models/exercise_answer.rb b/app/models/exercise_answer.rb index 465fa036b..96fbe17bb 100644 --- a/app/models/exercise_answer.rb +++ b/app/models/exercise_answer.rb @@ -3,7 +3,7 @@ class ExerciseAnswer < ApplicationRecord belongs_to :user belongs_to :exercise_question belongs_to :exercise_choice, optional: true - has_many :exercise_answer_comments, :dependent => :destroy + has_many :exercise_answer_comments scope :search_exercise_answer, lambda { |name,key| where("#{name} = ?",key)} scope :search_answer_users, lambda {|name,ids| where("#{name}":ids)} @@ -11,4 +11,10 @@ class ExerciseAnswer < ApplicationRecord scope :exercise_answer_is_right, -> {where("score > ?",0.0)} #判断答案是否正确,根据分数总和大于0 scope :score_reviewed, lambda {where("score >= ?",0.0)} #是否评分,用于判断主观题的 + after_destroy :destroy_answers_relations + + def destroy_answers_relations + exercise_answer_comments.destroy_all + end + end \ No newline at end of file diff --git a/app/models/exercise_choice.rb b/app/models/exercise_choice.rb index 525251ce6..f4f5c5a16 100644 --- a/app/models/exercise_choice.rb +++ b/app/models/exercise_choice.rb @@ -1,9 +1,16 @@ class ExerciseChoice < ApplicationRecord belongs_to :exercise_question - has_many :exercise_answers, :dependent => :destroy - has_many :exercise_standard_answers, :dependent => :destroy + has_many :exercise_answers + has_many :exercise_standard_answers scope :find_choice_custom, lambda {|k,v| where("#{k} = ?",v)} #根据传入的参数查找问题 scope :left_choice_choose, lambda {|k,v| where("#{k} > ?",v)} #根据传入的参数查找问题 + + after_destroy :destroy_choices_relations + + def destroy_choices_relations + exercise_answers.destroy_all + exercise_standard_answers.destroy_all + end end \ No newline at end of file diff --git a/app/models/exercise_question.rb b/app/models/exercise_question.rb index 607ad1a29..c236b657c 100644 --- a/app/models/exercise_question.rb +++ b/app/models/exercise_question.rb @@ -4,9 +4,9 @@ class ExerciseQuestion < ApplicationRecord belongs_to :exercise belongs_to :shixun, optional: true - has_many :exercise_choices, :dependent => :destroy + has_many :exercise_choices has_many :exercise_answers - has_many :exercise_shixun_challenges,:dependent => :destroy + has_many :exercise_shixun_challenges has_many :exercise_shixun_answers has_many :exercise_answer_comments has_many :exercise_standard_answers @@ -17,6 +17,12 @@ class ExerciseQuestion < ApplicationRecord scope :find_objective_questions, -> {where("question_type != ?",4)} #查找全部客观题 # scope :next_exercise, lambda {|k| where("question_number > ?",k).first} # scope :last_exercise, lambda {|k| where("question_number < ?",k).last} + after_destroy :destroy_questions_relations + + def destroy_questions_relations + exercise_choices.destroy_all + exercise_shixun_challenges.destroy_all + end def question_type_name case self.question_type diff --git a/app/models/exercise_shixun_answer.rb b/app/models/exercise_shixun_answer.rb index 8548e497d..72a6999d6 100644 --- a/app/models/exercise_shixun_answer.rb +++ b/app/models/exercise_shixun_answer.rb @@ -2,7 +2,7 @@ class ExerciseShixunAnswer < ApplicationRecord belongs_to :exercise_question belongs_to :user belongs_to :exercise_shixun_challenge - has_many :exercise_answer_comments, :dependent => :destroy + has_many :exercise_answer_comments # status 0: 未通过, 1:通过 # attr_accessible :answer_text, :score, :status scope :search_shixun_answers, lambda {|name,ids| where("#{name}":ids)} @@ -10,4 +10,9 @@ class ExerciseShixunAnswer < ApplicationRecord scope :shixun_no_full_scores, lambda { |score| where("score > 0.0 AND score < ?",score)} scope :score_reviewed, lambda {where("score is not NULL AND score >= ?",0.0)} #是否评分 + after_destroy :destroy_shixun_relations + + def destroy_shixun_relations + exercise_answer_comments.destroy_all + end end From 7a007dbd44315ea14fe384b50dedb1f6212f6404 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Fri, 28 Jun 2019 12:38:32 +0800 Subject: [PATCH 070/256] fix bug --- app/models/exercise.rb | 15 ++++----------- app/models/exercise_answer.rb | 8 +------- app/models/exercise_choice.rb | 10 ++-------- app/models/exercise_question.rb | 11 ++--------- app/models/exercise_shixun_answer.rb | 7 +------ 5 files changed, 10 insertions(+), 41 deletions(-) diff --git a/app/models/exercise.rb b/app/models/exercise.rb index af84a5c49..60409e51d 100644 --- a/app/models/exercise.rb +++ b/app/models/exercise.rb @@ -3,11 +3,11 @@ class Exercise < ApplicationRecord belongs_to :exercise_bank, optional: true belongs_to :user - has_many :exercise_users - has_many :exercise_questions - has_many :exercise_group_settings + has_many :exercise_users, :dependent => :delete_all + has_many :exercise_questions, :dependent => :delete_all + has_many :exercise_group_settings, :dependent => :delete_all has_many :tidings, as: :container - has_many :course_acts, class_name: 'CourseActivity', as: :course_act, dependent: :destroy + has_many :course_acts, class_name: 'CourseActivity', as: :course_act, :dependent => :delete_all scope :is_exercise_published, -> { where("exercise_status > ? ",1)} scope :unified_setting, -> { where("unified_setting = ?",true) } @@ -19,13 +19,6 @@ class Exercise < ApplicationRecord validates :exercise_name, length: { maximum: 60, too_long: "60 characters is the maximum allowed" } after_create :create_exercise_list - after_destroy :destroy_other_relations - - def destroy_other_relations - exercise_users.destroy_all - exercise_questions.destroy_all - exercise_group_settings.destroy_all - end def create_exercise_list str = "" diff --git a/app/models/exercise_answer.rb b/app/models/exercise_answer.rb index 96fbe17bb..11558f937 100644 --- a/app/models/exercise_answer.rb +++ b/app/models/exercise_answer.rb @@ -3,7 +3,7 @@ class ExerciseAnswer < ApplicationRecord belongs_to :user belongs_to :exercise_question belongs_to :exercise_choice, optional: true - has_many :exercise_answer_comments + has_many :exercise_answer_comments, :dependent => :delete_all scope :search_exercise_answer, lambda { |name,key| where("#{name} = ?",key)} scope :search_answer_users, lambda {|name,ids| where("#{name}":ids)} @@ -11,10 +11,4 @@ class ExerciseAnswer < ApplicationRecord scope :exercise_answer_is_right, -> {where("score > ?",0.0)} #判断答案是否正确,根据分数总和大于0 scope :score_reviewed, lambda {where("score >= ?",0.0)} #是否评分,用于判断主观题的 - after_destroy :destroy_answers_relations - - def destroy_answers_relations - exercise_answer_comments.destroy_all - end - end \ No newline at end of file diff --git a/app/models/exercise_choice.rb b/app/models/exercise_choice.rb index f4f5c5a16..72dc30c9d 100644 --- a/app/models/exercise_choice.rb +++ b/app/models/exercise_choice.rb @@ -1,16 +1,10 @@ class ExerciseChoice < ApplicationRecord belongs_to :exercise_question - has_many :exercise_answers - has_many :exercise_standard_answers + has_many :exercise_answers, :dependent => :delete_all + has_many :exercise_standard_answers, :dependent => :delete_all scope :find_choice_custom, lambda {|k,v| where("#{k} = ?",v)} #根据传入的参数查找问题 scope :left_choice_choose, lambda {|k,v| where("#{k} > ?",v)} #根据传入的参数查找问题 - after_destroy :destroy_choices_relations - - def destroy_choices_relations - exercise_answers.destroy_all - exercise_standard_answers.destroy_all - end end \ No newline at end of file diff --git a/app/models/exercise_question.rb b/app/models/exercise_question.rb index c236b657c..2c9b281c3 100644 --- a/app/models/exercise_question.rb +++ b/app/models/exercise_question.rb @@ -4,9 +4,9 @@ class ExerciseQuestion < ApplicationRecord belongs_to :exercise belongs_to :shixun, optional: true - has_many :exercise_choices + has_many :exercise_choices, :dependent => :delete_all has_many :exercise_answers - has_many :exercise_shixun_challenges + has_many :exercise_shixun_challenges, :dependent => :delete_all has_many :exercise_shixun_answers has_many :exercise_answer_comments has_many :exercise_standard_answers @@ -15,14 +15,7 @@ class ExerciseQuestion < ApplicationRecord scope :find_by_custom, lambda {|k,v| where("#{k} = ?",v)} #根据传入的参数查找问题 scope :left_question_choose, lambda {|k,v| where("#{k} > ?",v)} #根据传入的参数查找问题 scope :find_objective_questions, -> {where("question_type != ?",4)} #查找全部客观题 - # scope :next_exercise, lambda {|k| where("question_number > ?",k).first} - # scope :last_exercise, lambda {|k| where("question_number < ?",k).last} - after_destroy :destroy_questions_relations - def destroy_questions_relations - exercise_choices.destroy_all - exercise_shixun_challenges.destroy_all - end def question_type_name case self.question_type diff --git a/app/models/exercise_shixun_answer.rb b/app/models/exercise_shixun_answer.rb index 72a6999d6..a9550c024 100644 --- a/app/models/exercise_shixun_answer.rb +++ b/app/models/exercise_shixun_answer.rb @@ -2,7 +2,7 @@ class ExerciseShixunAnswer < ApplicationRecord belongs_to :exercise_question belongs_to :user belongs_to :exercise_shixun_challenge - has_many :exercise_answer_comments + has_many :exercise_answer_comments, :dependent => :delete_all # status 0: 未通过, 1:通过 # attr_accessible :answer_text, :score, :status scope :search_shixun_answers, lambda {|name,ids| where("#{name}":ids)} @@ -10,9 +10,4 @@ class ExerciseShixunAnswer < ApplicationRecord scope :shixun_no_full_scores, lambda { |score| where("score > 0.0 AND score < ?",score)} scope :score_reviewed, lambda {where("score is not NULL AND score >= ?",0.0)} #是否评分 - after_destroy :destroy_shixun_relations - - def destroy_shixun_relations - exercise_answer_comments.destroy_all - end end From e233d90197bc70ef7775c364f3bdb13e2c6673a1 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Fri, 28 Jun 2019 12:48:41 +0800 Subject: [PATCH 071/256] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=AF=95=E5=8D=B7?= =?UTF-8?q?=E5=92=8C=E9=97=AE=E5=8D=B7=E5=88=A0=E9=99=A4=E5=85=B3=E8=81=94?= =?UTF-8?q?=E4=B8=BAdelete=5Fall?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/poll.rb | 10 +++++----- app/models/poll_answer.rb | 2 +- app/models/poll_question.rb | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/app/models/poll.rb b/app/models/poll.rb index 1cead3291..f72239ba7 100644 --- a/app/models/poll.rb +++ b/app/models/poll.rb @@ -4,13 +4,13 @@ class Poll < ApplicationRecord belongs_to :exercise_bank, optional: true # belongs_to :exercise_bank - has_many :poll_questions,dependent: :destroy - has_many :poll_users, :dependent => :destroy + has_many :poll_questions,dependent: :delete_all + has_many :poll_users, :dependent => :delete_all has_many :users, :through => :poll_users #该文件被哪些用户提交答案过 - has_many :poll_group_settings, :dependent => :destroy - has_many :course_acts, class_name: 'CourseActivity', as: :course_act, dependent: :destroy + has_many :poll_group_settings, :dependent => :delete_all + has_many :course_acts, class_name: 'CourseActivity', as: :course_act, dependent: :delete_all - has_many :tidings, as: :container, dependent: :destroy + has_many :tidings, as: :container, dependent: :delete_all scope :publish_or_not, -> { where("polls_status > ? ",1)} scope :only_public, -> {where("is_public = ?",true)} diff --git a/app/models/poll_answer.rb b/app/models/poll_answer.rb index 423198bbf..8e2421328 100644 --- a/app/models/poll_answer.rb +++ b/app/models/poll_answer.rb @@ -3,7 +3,7 @@ class PollAnswer < ApplicationRecord # include Redmine::SafeAttributes belongs_to :poll_question - has_many :poll_votes, :dependent => :destroy + has_many :poll_votes, :dependent => :delete_all scope :find_answer_by_custom, lambda {|k,v| where("#{k}":v)} #根据传入的参数查找问题 scope :left_answer_choose, lambda {|k,v| where("#{k} > ?",v)} #根据传入的参数查找问题 diff --git a/app/models/poll_question.rb b/app/models/poll_question.rb index 1fc8e0c16..a0854aa48 100644 --- a/app/models/poll_question.rb +++ b/app/models/poll_question.rb @@ -1,9 +1,9 @@ class PollQuestion < ApplicationRecord belongs_to :poll - has_many :poll_answers, :dependent => :destroy + has_many :poll_answers, :dependent => :delete_all attr_accessor :question_answers, :question_other_anser - has_many :poll_votes, :dependent => :destroy + has_many :poll_votes scope :ques_count, lambda {|k| where("question_type = ?",k)} scope :ques_necessary, -> {where("is_necessary = ?",1)} From d183334d919a1b5e6188041d7271c59b240e7e47 Mon Sep 17 00:00:00 2001 From: jingquan huang Date: Fri, 28 Jun 2019 13:57:09 +0800 Subject: [PATCH 072/256] =?UTF-8?q?=E5=AE=9E=E8=AE=AD=E8=AF=A6=E6=83=85?= =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/challenges_controller.rb | 7 +++-- app/models/challenge.rb | 40 +++++++++++++++--------- app/views/challenges/index.json.jbuilder | 2 +- 3 files changed, 32 insertions(+), 17 deletions(-) diff --git a/app/controllers/challenges_controller.rb b/app/controllers/challenges_controller.rb index f2a964c8d..bce0ae3c2 100644 --- a/app/controllers/challenges_controller.rb +++ b/app/controllers/challenges_controller.rb @@ -149,7 +149,11 @@ class ChallengesController < ApplicationController def index uid_logger("identifier: #{params}") # 通过调试发现 这里includes(:games)性能会慢10倍 - @challenges = @shixun.challenges.fields_for_list + # @challenges = @shixun.challenges.fields_for_list + @challenges = Challenge.fields_for_list.includes(:games).where("challenges.shixun_id" => @shixun.id) + + # @challenges = Challenge.includes(:games).where("games.user_id" => 12).where(shixun_id: @shixun.id) + @editable = current_user.manager_of_shixun?(@shixun) && @shixun.status == 0 @user = current_user end @@ -247,7 +251,6 @@ class ChallengesController < ApplicationController # 关卡位置被修改,需要修改脚本 script = modify_shixun_script @shixun, @shixun.evaluate_script @shixun.update_column(:evaluate_script, script) - end def index_up diff --git a/app/models/challenge.rb b/app/models/challenge.rb index 5495dd7a3..f25ce330a 100644 --- a/app/models/challenge.rb +++ b/app/models/challenge.rb @@ -51,9 +51,8 @@ class Challenge < ApplicationRecord end # 开启挑战 - def open_game(user_id) - game = self.games.select([:status, :identifier]).where(user_id: user_id).first - shixun = self.shixun + def open_game user_id, challenge_id, shixun + game = games.select{|game| game.challenge_id = challenge_id && game.user_id == user_id}.first if game.present? shixun.task_pass || game.status != 3 ? "/tasks/#{game.identifier}" : "" else @@ -61,18 +60,31 @@ class Challenge < ApplicationRecord end end + # # 开启挑战 + # def open_game(user_id, shixun) + # + # + # game = self.games.select([:status, :identifier]).where(user_id: user_id).first + # game = self.games.select{|game| game.user_id == user_id} + # if game.present? + # shixun.task_pass || game.status != 3 ? "/tasks/#{game.identifier}" : "" + # else + # "/api/shixuns/#{shixun.identifier}/shixun_exec" + # end + # end + ## 用户关卡状态 0: 不能开启实训; 1:直接开启; 2表示已完成 def user_tpi_status user_id # todo: 以前没加索引导致相同关卡,同一用户有多个games - game = self.games.where(user_id: user_id).last - status = - if game.blank? - self.position == 1 ? 1 : 0 - elsif game.status == 2 - 2 - else - 1 - end + game = games.select{|game| game.user_id == user_id }.last + + if game.blank? + self.position == 1 ? 1 : 0 + elsif game.status == 2 + 2 + else + 1 + end end ## 选择题答案 @@ -85,12 +97,12 @@ class Challenge < ApplicationRecord # 关卡用户通关数 def user_passed_count - games.where(status: 2).count + games.select{|game| game.status == 2}.size end # 关卡用户正在挑战的人数 def playing_count - games.where(status: [0, 1]).count + games.select{|game| game.status == 0 || game.status == 1}.size end def last_challenge diff --git a/app/views/challenges/index.json.jbuilder b/app/views/challenges/index.json.jbuilder index 0b90b5ca5..dc122b8c4 100644 --- a/app/views/challenges/index.json.jbuilder +++ b/app/views/challenges/index.json.jbuilder @@ -17,7 +17,7 @@ if @challenges.present? json.passed_count challenge.user_passed_count json.playing_count challenge.playing_count json.name_url shixun_challenge_path(challenge, shixun_identifier: @shixun.identifier) - json.open_game challenge.open_game(@user.id) + json.open_game challenge.open_game(@user.id, challenge.id, @shixun) if @editable json.edit_url edit_shixun_challenge_path(challenge, shixun_identifier: @shixun.identifier) json.delete_url shixun_challenge_path(challenge, shixun_identifier: @shixun.identifier) From aa4dfd6190599fdfdbd21d50b37e1e3a6839eb97 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Fri, 28 Jun 2019 14:10:09 +0800 Subject: [PATCH 073/256] fix bug --- app/helpers/exercises_helper.rb | 10 +++++----- app/views/exercises/start_answer.json.jbuilder | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/app/helpers/exercises_helper.rb b/app/helpers/exercises_helper.rb index 8db7e8bfa..cec6dd0ff 100644 --- a/app/helpers/exercises_helper.rb +++ b/app/helpers/exercises_helper.rb @@ -46,7 +46,7 @@ module ExercisesHelper sub_answer_score = sub_answer.first.score else stand_status = 0 - sub_answer_score = 0.0 + sub_answer_score = nil end sub_score = { @@ -54,7 +54,7 @@ module ExercisesHelper "q_type":s.question_type, "q_position":s.question_number, "stand_status":stand_status, - "user_score":sub_answer_score.round(1).to_s + "user_score":sub_answer_score.present? ? sub_answer_score.round(1).to_s : nil } @ex_sub_array.push(sub_score) end @@ -627,7 +627,7 @@ module ExercisesHelper #学生的分数状态及回答的内容 def user_question_answers(q,ex_answerer_id,student_status,is_teacher_or,ex_status,ques_type,ex_type) answered_content = [] - user_score = 0.0 + user_score = nil shixun_type = 0 question_comment = [] if q.question_type == 5 @@ -638,7 +638,7 @@ module ExercisesHelper if student_status == 2 #当前为老师,或为学生且已提交 user_score = exercise_answers.score_reviewed.pluck(:score).sum end - if user_score > q.question_score + if user_score.present? && (user_score > q.question_score) user_score = q.question_score end if ques_type <= 2 @@ -667,7 +667,7 @@ module ExercisesHelper question_comment = q.exercise_answer_comments.search_answer_comments("exercise_answer_id",q_answer_id) end { - "user_score": user_score.round(1), + "user_score": user_score.present? ? user_score.round(1) : nil, "answered_content":answered_content, "shixun_type":shixun_type, "question_comment":question_comment diff --git a/app/views/exercises/start_answer.json.jbuilder b/app/views/exercises/start_answer.json.jbuilder index 4cc461d56..42d611712 100644 --- a/app/views/exercises/start_answer.json.jbuilder +++ b/app/views/exercises/start_answer.json.jbuilder @@ -40,8 +40,8 @@ json.exercise_questions do question_info = get_exercise_question_info(question,@exercise,@exercise_user_current,@ex_answerer.id) # json.q_position q[:ques_number] #问题的序号,当问题为随机时,重新更新后的问题序号 if @t_user_exercise_status == 3 - this_answer_status = "0.0" - user_score = "0.0" + this_answer_status = 0 + user_score = nil if all_question_status.size > 0 this_ques_status = all_question_status.detect {|f| f[:q_id] == question.id} this_answer_status = this_ques_status[:stand_status] From d1f721b249d86400226c2f91a89390407e01cc62 Mon Sep 17 00:00:00 2001 From: jingquan huang Date: Fri, 28 Jun 2019 14:12:04 +0800 Subject: [PATCH 074/256] left out join --- app/controllers/challenges_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/challenges_controller.rb b/app/controllers/challenges_controller.rb index 3782468d4..5503dfe63 100644 --- a/app/controllers/challenges_controller.rb +++ b/app/controllers/challenges_controller.rb @@ -150,7 +150,7 @@ class ChallengesController < ApplicationController uid_logger("identifier: #{params}") # 通过调试发现 这里includes(:games)性能会慢10倍 # @challenges = @shixun.challenges.fields_for_list - @challenges = Challenge.fields_for_list.includes(:games).where("challenges.shixun_id" => @shixun.id) + @challenges = Challenge.fields_for_list.left_outer_joins(:games).where("challenges.shixun_id" => @shixun.id) # @challenges = Challenge.includes(:games).where("games.user_id" => 12).where(shixun_id: @shixun.id) From c8bfb0b4c1a92f572b601eb68ee2c10001a954e8 Mon Sep 17 00:00:00 2001 From: jingquan huang Date: Fri, 28 Jun 2019 14:14:23 +0800 Subject: [PATCH 075/256] .. --- app/controllers/challenges_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/challenges_controller.rb b/app/controllers/challenges_controller.rb index 5503dfe63..b821929d6 100644 --- a/app/controllers/challenges_controller.rb +++ b/app/controllers/challenges_controller.rb @@ -150,7 +150,7 @@ class ChallengesController < ApplicationController uid_logger("identifier: #{params}") # 通过调试发现 这里includes(:games)性能会慢10倍 # @challenges = @shixun.challenges.fields_for_list - @challenges = Challenge.fields_for_list.left_outer_joins(:games).where("challenges.shixun_id" => @shixun.id) + @challenges = Challenge.fields_for_list.where(shixun_id: @shixun.id) # @challenges = Challenge.includes(:games).where("games.user_id" => 12).where(shixun_id: @shixun.id) From 20fe2ba75c6ef5213f70fdfbd6f3805f721a4b20 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Fri, 28 Jun 2019 14:15:39 +0800 Subject: [PATCH 076/256] =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/tasks/homework_evaluation.rake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/tasks/homework_evaluation.rake b/lib/tasks/homework_evaluation.rake index d1fad8f14..35d075398 100644 --- a/lib/tasks/homework_evaluation.rake +++ b/lib/tasks/homework_evaluation.rake @@ -24,7 +24,7 @@ namespace :homework_evaluation do student_works = homework_common.student_works.has_committed end - if student_works.size >= 2 + if student_works.count >= 2 HomeworkEvaluationCommentAssginJob.perform_later(homework_common.id) homework_detail_manual.update_column('comment_status', 3) From 732fcaa466a379c39abde30e1195dbdb604c9006 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Fri, 28 Jun 2019 14:20:48 +0800 Subject: [PATCH 077/256] =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/tasks/homework_evaluation.rake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/tasks/homework_evaluation.rake b/lib/tasks/homework_evaluation.rake index 35d075398..56c46179c 100644 --- a/lib/tasks/homework_evaluation.rake +++ b/lib/tasks/homework_evaluation.rake @@ -24,7 +24,7 @@ namespace :homework_evaluation do student_works = homework_common.student_works.has_committed end - if student_works.count >= 2 + if student_works.present? && student_works.length >= 2 HomeworkEvaluationCommentAssginJob.perform_later(homework_common.id) homework_detail_manual.update_column('comment_status', 3) From b51c899cb558e79d13721b0e1771a1b1267d2922 Mon Sep 17 00:00:00 2001 From: jingquan huang Date: Fri, 28 Jun 2019 14:22:30 +0800 Subject: [PATCH 078/256] =?UTF-8?q?challenge=20index=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/challenge.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/models/challenge.rb b/app/models/challenge.rb index f25ce330a..9bfb89b4b 100644 --- a/app/models/challenge.rb +++ b/app/models/challenge.rb @@ -97,12 +97,12 @@ class Challenge < ApplicationRecord # 关卡用户通关数 def user_passed_count - games.select{|game| game.status == 2}.size + games.where(status: 2).count end # 关卡用户正在挑战的人数 def playing_count - games.select{|game| game.status == 0 || game.status == 1}.size + games.where(status: [0, 1]).count end def last_challenge From bc61bbbe05ef0101ae4a7bea8c5bbc1633b18d7e Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Fri, 28 Jun 2019 14:26:39 +0800 Subject: [PATCH 079/256] =?UTF-8?q?=E5=AE=9E=E8=AE=AD=E7=9A=84=E5=85=B3?= =?UTF-8?q?=E5=8D=A1=E6=8E=A7=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/application_controller.rb | 7 +++++++ app/controllers/challenges_controller.rb | 11 ++++++++--- app/controllers/shixuns_controller.rb | 9 +++------ 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 4a9220939..afe2129a9 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -23,6 +23,13 @@ class ApplicationController < ActionController::Base EduSetting.get(name) end + # 实训的访问权限 + def shixun_access_allowed + if !current_user.shixun_permission(@shixun) + tip_exception(403, "..") + end + end + def user_course_identity @user_course_identity = current_user.course_identity(@course) if @user_course_identity > Course::STUDENT && @course.is_public == 0 diff --git a/app/controllers/challenges_controller.rb b/app/controllers/challenges_controller.rb index b821929d6..8550c20ce 100644 --- a/app/controllers/challenges_controller.rb +++ b/app/controllers/challenges_controller.rb @@ -5,8 +5,10 @@ class ChallengesController < ApplicationController before_action :find_challenge, only: [:edit, :show, :update, :create_choose_question, :index_down, :index_up, :edit_choose_question, :show_choose_question, :destroy_challenge_choose, :update_choose_question, :destroy, :crud_answer, :answer] - # 权限控制 - before_action :allowed, except: [:index] + # 关卡更新和操作的权限控制 + before_action :update_allowed, except: [:index] + # 关卡访问的权限控制 + before_action :shixun_access_allowed include ShixunsHelper include ChallengesHelper @@ -279,6 +281,9 @@ class ChallengesController < ApplicationController def find_shixun @shixun = Shixun.find_by_identifier(params[:shixun_identifier]) + if !current_user.shixun_permission(@shixun) + tip_exception(403, "..") + end end # 通用接口 @@ -298,7 +303,7 @@ class ChallengesController < ApplicationController :standard_answer, :score, :difficult) end - def allowed + def update_allowed unless current_user.manager_of_shixun?(@shixun) raise Educoder::TipException.new(403, "..") end diff --git a/app/controllers/shixuns_controller.rb b/app/controllers/shixuns_controller.rb index 5f7c13964..0cf4fc77e 100644 --- a/app/controllers/shixuns_controller.rb +++ b/app/controllers/shixuns_controller.rb @@ -2,8 +2,9 @@ class ShixunsController < ApplicationController before_action :require_login, except: [:download_file, :index, :menus] before_action :check_auth, except: [:download_file, :index] - before_action :find_shixun, except: [:index, :new, :create, :menus, :get_recommend_shixuns, :propaedeutics, - :departments, :apply_shixun_mirror, :get_mirror_script, :download_file] + before_action :find_shixun, :shixun_access_allowed, except: [:index, :new, :create, :menus, :get_recommend_shixuns, + :propaedeutics, :departments, :apply_shixun_mirror, + :get_mirror_script, :download_file] before_action :find_repo_name, only: [:repository, :commits, :file_content, :update_file, :shixun_exec, :copy] before_action :allowed, only: [:update, :close, :update_propaedeutics, :settings, :publish, @@ -726,10 +727,6 @@ private normal_status(404, "...") return end - - if !current_user.shixun_permission(@shixun) - tip_exception(403, "..") - end end def find_repo_name From 79eb49c7506e85cb73e4b253c370cfb158dc6ed0 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Fri, 28 Jun 2019 14:26:46 +0800 Subject: [PATCH 080/256] fix bug --- app/views/exercises/_user_exercise_info.json.jbuilder | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/exercises/_user_exercise_info.json.jbuilder b/app/views/exercises/_user_exercise_info.json.jbuilder index 5b5d0c725..cc10f5bb7 100644 --- a/app/views/exercises/_user_exercise_info.json.jbuilder +++ b/app/views/exercises/_user_exercise_info.json.jbuilder @@ -54,7 +54,7 @@ json.exercise_questions do this_ques_status = all_question_status.detect {|f| f[:q_id] == q.id} json.answer_status this_ques_status[:stand_status] end - json.user_score user_ques_answers[:user_score].to_s + json.user_score user_ques_answers[:user_score].present? ? user_ques_answers[:user_score].to_s : nil json.partial! "exercise_questions/exercise_questions", question: q, ex_answerer: ex_answerer, From cc3687df2f895705fc6d19c027ec3f4b0d294aa8 Mon Sep 17 00:00:00 2001 From: jingquan huang Date: Fri, 28 Jun 2019 14:28:17 +0800 Subject: [PATCH 081/256] =?UTF-8?q?=E5=AE=9E=E8=AE=AD=E5=BC=80=E5=90=AF?= =?UTF-8?q?=E7=8A=B6=E6=80=81=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/challenge.rb | 4 ++-- app/views/challenges/index.json.jbuilder | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/models/challenge.rb b/app/models/challenge.rb index 9bfb89b4b..434812234 100644 --- a/app/models/challenge.rb +++ b/app/models/challenge.rb @@ -51,8 +51,8 @@ class Challenge < ApplicationRecord end # 开启挑战 - def open_game user_id, challenge_id, shixun - game = games.select{|game| game.challenge_id = challenge_id && game.user_id == user_id}.first + def open_game user_id, shixun + game = self.games.select([:status, :identifier]).where(user_id: user_id).first if game.present? shixun.task_pass || game.status != 3 ? "/tasks/#{game.identifier}" : "" else diff --git a/app/views/challenges/index.json.jbuilder b/app/views/challenges/index.json.jbuilder index dc122b8c4..6b92be411 100644 --- a/app/views/challenges/index.json.jbuilder +++ b/app/views/challenges/index.json.jbuilder @@ -17,7 +17,7 @@ if @challenges.present? json.passed_count challenge.user_passed_count json.playing_count challenge.playing_count json.name_url shixun_challenge_path(challenge, shixun_identifier: @shixun.identifier) - json.open_game challenge.open_game(@user.id, challenge.id, @shixun) + json.open_game challenge.open_game(@user.id, @shixun) if @editable json.edit_url edit_shixun_challenge_path(challenge, shixun_identifier: @shixun.identifier) json.delete_url shixun_challenge_path(challenge, shixun_identifier: @shixun.identifier) From c7c39f46311e31782798411b3a10a1319ce64587 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Fri, 28 Jun 2019 14:31:50 +0800 Subject: [PATCH 082/256] =?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/jobs/homework_evaluation_comment_assgin_job.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/jobs/homework_evaluation_comment_assgin_job.rb b/app/jobs/homework_evaluation_comment_assgin_job.rb index 2579ea18b..5921386f2 100644 --- a/app/jobs/homework_evaluation_comment_assgin_job.rb +++ b/app/jobs/homework_evaluation_comment_assgin_job.rb @@ -16,7 +16,7 @@ class HomeworkEvaluationCommentAssginJob < ApplicationJob student_work_projects = homework_common.student_works.where("work_status != 0").shuffle student_work_projects.each do |pro_work| n = homework_detail_manual.evaluation_num - n = (n < student_works.size && n != -1) ? n : student_works.size - 1 + n = (n < student_works.length && n != -1) ? n : student_works.length - 1 work_index = -1 student_works.each_with_index do |stu_work, stu_index| if stu_work.group_id.to_i == pro_work.group_id.to_i From 58259feb483d04a03a979f467ce6c3ee81b1068e Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Fri, 28 Jun 2019 14:36:18 +0800 Subject: [PATCH 083/256] =?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/homework_common.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/homework_common.rb b/app/models/homework_common.rb index c0882ec6f..6512c3f1d 100644 --- a/app/models/homework_common.rb +++ b/app/models/homework_common.rb @@ -170,7 +170,7 @@ class HomeworkCommon < ApplicationRecord #删除时更新题库中的引用数 def update_homework_bank_quotes old_bank = self.homework_bank - old_bank.update_attributes(quotes: (old_bank.quotes - 1) > 0 ? (old_bank.quotes - 1) : 0, homework_common_id: nil) + old_bank.update_attributes(quotes: (old_bank.quotes - 1) > 0 ? (old_bank.quotes - 1) : 0, homework_common_id: nil) if old_bank.present? end # 查重是否有新结果 From 68637a2464764546f8f3136a45c3f799fecd5723 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Fri, 28 Jun 2019 14:48:08 +0800 Subject: [PATCH 084/256] fix bug --- app/helpers/exercises_helper.rb | 8 +++++--- app/views/exercises/_user_exercise_info.json.jbuilder | 3 +-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/app/helpers/exercises_helper.rb b/app/helpers/exercises_helper.rb index cec6dd0ff..3595b5866 100644 --- a/app/helpers/exercises_helper.rb +++ b/app/helpers/exercises_helper.rb @@ -630,14 +630,16 @@ module ExercisesHelper user_score = nil shixun_type = 0 question_comment = [] - if q.question_type == 5 + if ques_type == 5 exercise_answers = q.exercise_shixun_answers.search_shixun_answers("user_id",ex_answerer_id) else exercise_answers = q.exercise_answers.search_exercise_answer("user_id",ex_answerer_id) #试卷用户的回答 end if student_status == 2 #当前为老师,或为学生且已提交 - user_score = exercise_answers.score_reviewed.pluck(:score).sum + user_score_pre = exercise_answers.score_reviewed.pluck(:score).sum + user_score = user_score_pre.present? ? user_score_pre.pluck(:score).sum : nil end + if user_score.present? && (user_score > q.question_score) user_score = q.question_score end @@ -667,7 +669,7 @@ module ExercisesHelper question_comment = q.exercise_answer_comments.search_answer_comments("exercise_answer_id",q_answer_id) end { - "user_score": user_score.present? ? user_score.round(1) : nil, + "user_score": (user_score.present? ? user_score.round(1).to_s : nil), "answered_content":answered_content, "shixun_type":shixun_type, "question_comment":question_comment diff --git a/app/views/exercises/_user_exercise_info.json.jbuilder b/app/views/exercises/_user_exercise_info.json.jbuilder index cc10f5bb7..1ff929897 100644 --- a/app/views/exercises/_user_exercise_info.json.jbuilder +++ b/app/views/exercises/_user_exercise_info.json.jbuilder @@ -47,14 +47,13 @@ end json.exercise_questions do json.array! exercise_questions do |q| - user_ques_answers = user_question_answers(q,ex_answerer.id,student_status,is_teacher_or,exercise_status,q.question_type,ex_type) user_ques_comments = user_ques_answers[:question_comment] if all_question_status.size > 0 this_ques_status = all_question_status.detect {|f| f[:q_id] == q.id} json.answer_status this_ques_status[:stand_status] end - json.user_score user_ques_answers[:user_score].present? ? user_ques_answers[:user_score].to_s : nil + json.user_score user_ques_answers[:user_score] json.partial! "exercise_questions/exercise_questions", question: q, ex_answerer: ex_answerer, From 584d9bd53ab208c2e6afae0451b789e6b7da70c2 Mon Sep 17 00:00:00 2001 From: jingquan huang Date: Fri, 28 Jun 2019 14:49:00 +0800 Subject: [PATCH 085/256] =?UTF-8?q?=E5=85=B3=E5=8D=A1=E9=80=9A=E5=85=B3?= =?UTF-8?q?=E6=83=85=E5=86=B5=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/challenges_controller.rb | 4 +--- app/models/challenge.rb | 4 ++-- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/app/controllers/challenges_controller.rb b/app/controllers/challenges_controller.rb index 8550c20ce..565545713 100644 --- a/app/controllers/challenges_controller.rb +++ b/app/controllers/challenges_controller.rb @@ -151,10 +151,8 @@ class ChallengesController < ApplicationController def index uid_logger("identifier: #{params}") # 通过调试发现 这里includes(:games)性能会慢10倍 - # @challenges = @shixun.challenges.fields_for_list - @challenges = Challenge.fields_for_list.where(shixun_id: @shixun.id) - # @challenges = Challenge.includes(:games).where("games.user_id" => 12).where(shixun_id: @shixun.id) + @challenges = @shixun.challenges.fields_for_list.includes(:games).where("games.user_id" => current_user.id) @editable = current_user.manager_of_shixun?(@shixun) && @shixun.status == 0 @user = current_user diff --git a/app/models/challenge.rb b/app/models/challenge.rb index 434812234..07a49196d 100644 --- a/app/models/challenge.rb +++ b/app/models/challenge.rb @@ -52,7 +52,7 @@ class Challenge < ApplicationRecord # 开启挑战 def open_game user_id, shixun - game = self.games.select([:status, :identifier]).where(user_id: user_id).first + game = self.games.first if game.present? shixun.task_pass || game.status != 3 ? "/tasks/#{game.identifier}" : "" else @@ -76,7 +76,7 @@ class Challenge < ApplicationRecord ## 用户关卡状态 0: 不能开启实训; 1:直接开启; 2表示已完成 def user_tpi_status user_id # todo: 以前没加索引导致相同关卡,同一用户有多个games - game = games.select{|game| game.user_id == user_id }.last + game = games.last if game.blank? self.position == 1 ? 1 : 0 From 0576924ab636945a1047e6ecfc2f0d8bd393495b Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Fri, 28 Jun 2019 14:49:42 +0800 Subject: [PATCH 086/256] fix bug --- 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 3595b5866..a2a80c311 100644 --- a/app/helpers/exercises_helper.rb +++ b/app/helpers/exercises_helper.rb @@ -636,7 +636,7 @@ module ExercisesHelper exercise_answers = q.exercise_answers.search_exercise_answer("user_id",ex_answerer_id) #试卷用户的回答 end if student_status == 2 #当前为老师,或为学生且已提交 - user_score_pre = exercise_answers.score_reviewed.pluck(:score).sum + user_score_pre = exercise_answers.score_reviewed user_score = user_score_pre.present? ? user_score_pre.pluck(:score).sum : nil end From 54196a44c5d36fb22b40023a1b6e04f47ebfaa62 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Fri, 28 Jun 2019 15:07:36 +0800 Subject: [PATCH 087/256] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=90=88=E4=BD=9C?= =?UTF-8?q?=E8=80=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/challenges_controller.rb | 2 +- app/controllers/shixuns_controller.rb | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/controllers/challenges_controller.rb b/app/controllers/challenges_controller.rb index 565545713..2ba76c60a 100644 --- a/app/controllers/challenges_controller.rb +++ b/app/controllers/challenges_controller.rb @@ -8,7 +8,7 @@ class ChallengesController < ApplicationController # 关卡更新和操作的权限控制 before_action :update_allowed, except: [:index] # 关卡访问的权限控制 - before_action :shixun_access_allowed + before_action :shixun_access_allowed, only: [:index] include ShixunsHelper include ChallengesHelper diff --git a/app/controllers/shixuns_controller.rb b/app/controllers/shixuns_controller.rb index 0cf4fc77e..52e05e57d 100644 --- a/app/controllers/shixuns_controller.rb +++ b/app/controllers/shixuns_controller.rb @@ -624,12 +624,12 @@ class ShixunsController < ApplicationController def add_collaborators member_ids = "(" + @shixun.shixun_members.map(&:user_id).join(',') + ")" - user_name = "%#{params[:user_name].strip}%" - school_name = "%#{params[:school_name].strip}%" + user_name = "%#{params[:user_name].to_s.strip}%" + school_name = "%#{params[:school_name].to_s.strip}%" if user_name.present? || school_name.present? @users = User.joins(user_extension: :school).where("users.id not in #{member_ids} AND users.status = 1 AND LOWER(users.lastname) LIKE '#{user_name}' AND LOWER(schools.name) LIKE - '#{school_name}'") + '#{school_name}'").limit(20) else @users = User.none end From 4efa98153fe89cf82c46cde024a0d83585c01490 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Fri, 28 Jun 2019 15:09:40 +0800 Subject: [PATCH 088/256] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=90=88=E4=BD=9C?= =?UTF-8?q?=E8=80=85=E5=88=86=E9=A1=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/shixuns_controller.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/controllers/shixuns_controller.rb b/app/controllers/shixuns_controller.rb index 52e05e57d..234983932 100644 --- a/app/controllers/shixuns_controller.rb +++ b/app/controllers/shixuns_controller.rb @@ -627,9 +627,11 @@ class ShixunsController < ApplicationController user_name = "%#{params[:user_name].to_s.strip}%" school_name = "%#{params[:school_name].to_s.strip}%" if user_name.present? || school_name.present? + page = params[:page] || 1 + limit = params[:limit] || 20 @users = User.joins(user_extension: :school).where("users.id not in #{member_ids} AND users.status = 1 AND LOWER(users.lastname) LIKE '#{user_name}' AND LOWER(schools.name) LIKE - '#{school_name}'").limit(20) + '#{school_name}'").page(page).per(limit) else @users = User.none end From cd87ea9b5a95c085e8cbdea5b72fefd6d4aa7f66 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Fri, 28 Jun 2019 15:11:45 +0800 Subject: [PATCH 089/256] =?UTF-8?q?=E5=8E=BB=E9=87=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/shixuns_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/shixuns_controller.rb b/app/controllers/shixuns_controller.rb index 234983932..df6de775a 100644 --- a/app/controllers/shixuns_controller.rb +++ b/app/controllers/shixuns_controller.rb @@ -631,7 +631,7 @@ class ShixunsController < ApplicationController limit = params[:limit] || 20 @users = User.joins(user_extension: :school).where("users.id not in #{member_ids} AND users.status = 1 AND LOWER(users.lastname) LIKE '#{user_name}' AND LOWER(schools.name) LIKE - '#{school_name}'").page(page).per(limit) + '#{school_name}'").distinct.page(page).per(limit) else @users = User.none end From 250888abc58fcf60f0c66fe9f7097d13523ee419 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Fri, 28 Jun 2019 15:15:58 +0800 Subject: [PATCH 090/256] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=90=88=E4=BD=9C?= =?UTF-8?q?=E8=80=85=E7=BF=BB=E9=A1=B5=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/shixuns_controller.rb | 27 ++++++++++--------- .../shixuns/add_collaborators.json.jbuilder | 5 ++-- 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/app/controllers/shixuns_controller.rb b/app/controllers/shixuns_controller.rb index df6de775a..32a2c6ef9 100644 --- a/app/controllers/shixuns_controller.rb +++ b/app/controllers/shixuns_controller.rb @@ -623,19 +623,22 @@ class ShixunsController < ApplicationController end def add_collaborators - member_ids = "(" + @shixun.shixun_members.map(&:user_id).join(',') + ")" - user_name = "%#{params[:user_name].to_s.strip}%" - school_name = "%#{params[:school_name].to_s.strip}%" - if user_name.present? || school_name.present? - page = params[:page] || 1 - limit = params[:limit] || 20 - @users = User.joins(user_extension: :school).where("users.id not in #{member_ids} AND users.status = 1 AND + member_ids = "(" + @shixun.shixun_members.map(&:user_id).join(',') + ")" + user_name = "%#{params[:user_name].to_s.strip}%" + school_name = "%#{params[:school_name].to_s.strip}%" + if user_name.present? || school_name.present? + @users = User.joins(user_extension: :school).where("users.id not in #{member_ids} AND users.status = 1 AND LOWER(users.lastname) LIKE '#{user_name}' AND LOWER(schools.name) LIKE - '#{school_name}'").distinct.page(page).per(limit) - else - @users = User.none - end - end + '#{school_name}'") + else + @users = User.none + end + page = params[:page] || 1 + limit = params[:limit] || 20 + @users_count = @users.count + @users = @users.page(page).per(limit) + + end def shixun_members_added raise("user_ids 不能为空!") if params[:user_ids].blank? diff --git a/app/views/shixuns/add_collaborators.json.jbuilder b/app/views/shixuns/add_collaborators.json.jbuilder index ab4716681..e77fd41a0 100644 --- a/app/views/shixuns/add_collaborators.json.jbuilder +++ b/app/views/shixuns/add_collaborators.json.jbuilder @@ -2,6 +2,7 @@ json.array! @users do |user| json.user_id user.id json.identify user.identity - json.nickname user.nickname + json.nickname user.real_name json.school_name user.school_name -end \ No newline at end of file +end +json.user_count @users_count \ No newline at end of file From 796f9a97f0a07c834a63c525a195906cbd090fb2 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Fri, 28 Jun 2019 15:18:28 +0800 Subject: [PATCH 091/256] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=90=88=E4=BD=9C?= =?UTF-8?q?=E8=80=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/shixuns/add_collaborators.json.jbuilder | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/shixuns/add_collaborators.json.jbuilder b/app/views/shixuns/add_collaborators.json.jbuilder index e77fd41a0..3fc341b69 100644 --- a/app/views/shixuns/add_collaborators.json.jbuilder +++ b/app/views/shixuns/add_collaborators.json.jbuilder @@ -1,8 +1,8 @@ #json.partial! "users/users_list", users: @users +json.user_count @users_count json.array! @users do |user| json.user_id user.id json.identify user.identity json.nickname user.real_name json.school_name user.school_name end -json.user_count @users_count \ No newline at end of file From c145345c4dca841462a136175369a429030ecf86 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Fri, 28 Jun 2019 15:22:01 +0800 Subject: [PATCH 092/256] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=90=88=E4=BD=9C?= =?UTF-8?q?=E8=80=85=E7=9C=9F=E5=AE=9E=E5=A7=93=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/shixuns/add_collaborators.json.jbuilder | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/shixuns/add_collaborators.json.jbuilder b/app/views/shixuns/add_collaborators.json.jbuilder index 3fc341b69..1264caafa 100644 --- a/app/views/shixuns/add_collaborators.json.jbuilder +++ b/app/views/shixuns/add_collaborators.json.jbuilder @@ -3,6 +3,6 @@ json.user_count @users_count json.array! @users do |user| json.user_id user.id json.identify user.identity - json.nickname user.real_name + json.nickname user.lastname json.school_name user.school_name end From 7487bc1c0c3b951ab94d2dfb806f92ab91b4d790 Mon Sep 17 00:00:00 2001 From: jasder Date: Fri, 28 Jun 2019 15:22:03 +0800 Subject: [PATCH 093/256] =?UTF-8?q?ADD=20=E9=80=89=E7=94=A8=E7=9A=84?= =?UTF-8?q?=E8=B5=84=E6=BA=90=E9=87=8C=E7=AB=8B=E9=A9=AC=E5=8F=91=E5=B8=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/files_controller.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/controllers/files_controller.rb b/app/controllers/files_controller.rb index 0e00dcc66..7e150c44c 100644 --- a/app/controllers/files_controller.rb +++ b/app/controllers/files_controller.rb @@ -180,6 +180,8 @@ class FilesController < ApplicationController attach_copied_obj.created_on = Time.now attach_copied_obj.author = current_user attach_copied_obj.is_public = 0 + attach_copied_obj.is_publish = 1 + attach_copied_obj.publish_time = Time.now attach_copied_obj.course_second_category_id = course_second_category_id attach_copied_obj.copy_from = ori.copy_from.nil? ? ori.id : ori.copy_from if attach_copied_obj.attachtype == nil From 7e02210ab8807634dbac5d08816e1291a50f7503 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Fri, 28 Jun 2019 15:26:11 +0800 Subject: [PATCH 094/256] =?UTF-8?q?=E8=B0=83=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/shixuns/add_collaborators.json.jbuilder | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/shixuns/add_collaborators.json.jbuilder b/app/views/shixuns/add_collaborators.json.jbuilder index 1264caafa..7bac0c24c 100644 --- a/app/views/shixuns/add_collaborators.json.jbuilder +++ b/app/views/shixuns/add_collaborators.json.jbuilder @@ -1,5 +1,5 @@ #json.partial! "users/users_list", users: @users -json.user_count @users_count +#json.users_count @users_count json.array! @users do |user| json.user_id user.id json.identify user.identity From 9bc8453ba3b14c11cc2956d7658d6e08efa7e68b Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Fri, 28 Jun 2019 15:32:25 +0800 Subject: [PATCH 095/256] =?UTF-8?q?=E5=88=86=E9=A1=B5=E6=8A=A5500?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/shixuns_controller.rb | 2 +- app/views/shixuns/add_collaborators.json.jbuilder | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/shixuns_controller.rb b/app/controllers/shixuns_controller.rb index 32a2c6ef9..89a0d524f 100644 --- a/app/controllers/shixuns_controller.rb +++ b/app/controllers/shixuns_controller.rb @@ -635,7 +635,7 @@ class ShixunsController < ApplicationController end page = params[:page] || 1 limit = params[:limit] || 20 - @users_count = @users.count + @total_count = @users.count @users = @users.page(page).per(limit) end diff --git a/app/views/shixuns/add_collaborators.json.jbuilder b/app/views/shixuns/add_collaborators.json.jbuilder index 7bac0c24c..963389933 100644 --- a/app/views/shixuns/add_collaborators.json.jbuilder +++ b/app/views/shixuns/add_collaborators.json.jbuilder @@ -1,5 +1,5 @@ #json.partial! "users/users_list", users: @users -#json.users_count @users_count +json.total_count @total_count json.array! @users do |user| json.user_id user.id json.identify user.identity From d8dab33c211df583815601263e3d581e2a2d220f Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Fri, 28 Jun 2019 15:34:24 +0800 Subject: [PATCH 096/256] =?UTF-8?q?=E8=AF=95=E5=8D=B7=E7=9A=84=E7=AD=94?= =?UTF-8?q?=E9=A2=98=E5=88=97=E8=A1=A8=E6=98=AF=E5=90=A6=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=E5=AE=A2=E8=A7=82=E9=A2=98=E5=92=8C=E4=B8=BB=E8=A7=82=E9=A2=98?= =?UTF-8?q?=E7=9A=84=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 | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/controllers/exercises_controller.rb b/app/controllers/exercises_controller.rb index 01a2d540a..421c5177a 100644 --- a/app/controllers/exercises_controller.rb +++ b/app/controllers/exercises_controller.rb @@ -1177,15 +1177,16 @@ class ExercisesController < ApplicationController @exercise_status = @exercise.get_exercise_status(current_user.id) @course_all_members = @course.students @c_group_counts = @course.course_groups_count - question_types = @exercise.exercise_questions.pluck(:question_type) + question_types = @exercise.exercise_questions.pluck(:question_type).uniq @exercise_publish_count = get_user_permission_course(exercise_ids,2).count #判断是否有已发布的分班 @exercise_unpublish_count = get_user_permission_course(exercise_ids,1).count #判断是否有未发布的分班 - if question_types.include?(4) #是否包含主观题 + if (question_types.size > 1) && question_types.include?(4) #是否包含主观题,或者是否大于1 @subjective_type = 1 else @subjective_type = 0 end + if @user_course_identity < Course::STUDENT #当前为老师,而且老师只能查看自己班级的/课堂的试卷 @exercise_current_user_status = 0 if @exercise_status == 1 From ce07bf7e3497bc5aa8348705d6b5968a92760bbc Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Fri, 28 Jun 2019 15:37:45 +0800 Subject: [PATCH 097/256] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=90=88=E4=BD=9C?= =?UTF-8?q?=E8=80=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/shixuns/add_collaborators.json.jbuilder | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/app/views/shixuns/add_collaborators.json.jbuilder b/app/views/shixuns/add_collaborators.json.jbuilder index 963389933..79b325fcd 100644 --- a/app/views/shixuns/add_collaborators.json.jbuilder +++ b/app/views/shixuns/add_collaborators.json.jbuilder @@ -1,8 +1,11 @@ #json.partial! "users/users_list", users: @users json.total_count @total_count -json.array! @users do |user| - json.user_id user.id - json.identify user.identity - json.nickname user.lastname - json.school_name user.school_name +json.users do + json.array! @users do |user| + json.user_id user.id + json.identify user.identity + json.nickname user.lastname + json.school_name user.school_name + end + end From bf5489ca5b692087eededfc4b9794234d4eba1b3 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Fri, 28 Jun 2019 15:38:16 +0800 Subject: [PATCH 098/256] =?UTF-8?q?=E5=AF=BC=E5=85=A5=E5=88=86=E7=8F=AD?= =?UTF-8?q?=E7=9A=84=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/courses_controller.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index 93eba89d8..e0844ab4c 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -799,6 +799,8 @@ class CoursesController < ApplicationController uid_logger_error(e.message) normal_status(-1, "无法完成导入,原因:文件内容无法读取") end + else + normal_status(-1, "只支持xls文件的导入") end end end From c211548a13326945c5795b74ee1ad64e41c29383 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Fri, 28 Jun 2019 15:38:22 +0800 Subject: [PATCH 099/256] =?UTF-8?q?=E5=90=88=E4=BD=9C=E8=80=85=E5=88=86?= =?UTF-8?q?=E9=A1=B5=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/shixuns_controller.rb | 2 +- app/views/shixuns/add_collaborators.json.jbuilder | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/shixuns_controller.rb b/app/controllers/shixuns_controller.rb index 89a0d524f..73029706f 100644 --- a/app/controllers/shixuns_controller.rb +++ b/app/controllers/shixuns_controller.rb @@ -635,7 +635,7 @@ class ShixunsController < ApplicationController end page = params[:page] || 1 limit = params[:limit] || 20 - @total_count = @users.count + @user_count = @users.count @users = @users.page(page).per(limit) end diff --git a/app/views/shixuns/add_collaborators.json.jbuilder b/app/views/shixuns/add_collaborators.json.jbuilder index 79b325fcd..d73a5b9bc 100644 --- a/app/views/shixuns/add_collaborators.json.jbuilder +++ b/app/views/shixuns/add_collaborators.json.jbuilder @@ -1,5 +1,5 @@ #json.partial! "users/users_list", users: @users -json.total_count @total_count +json.user_count @user_count json.users do json.array! @users do |user| json.user_id user.id From 4fefe12d16da4987ea91037813207ba5d73321d1 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Fri, 28 Jun 2019 16:29:13 +0800 Subject: [PATCH 100/256] =?UTF-8?q?=E6=9D=83=E9=99=90=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/games_controller.rb | 5 ++--- app/views/shixuns/add_collaborators.json.jbuilder | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/app/controllers/games_controller.rb b/app/controllers/games_controller.rb index ac0b6baa8..9e645c35a 100644 --- a/app/controllers/games_controller.rb +++ b/app/controllers/games_controller.rb @@ -51,9 +51,8 @@ class GamesController < ApplicationController # 统计评测时间 record_onsume_time = EvaluateRecord.where(game_id: @game.id).first.try(:consume_time) - # power判断用户是否有权限查看隐藏测试集(TPM管理员;平台认证的老师;花费金币查看者) - # myshixun_manager - myshixun_manager = current_user.manager_of_shixun?(@shixun) || (current_user.is_teacher? && current_user.pro_certification?) + # myshixun_manager判断用户是否有权限查看隐藏测试集(TPM管理员;平台认证的老师;花费金币查看者) + myshixun_manager = @identity < USER::EDU_GAME_MANAGER # 选择题和编程题公共部分 @base_date = {st: @st, discusses_count: discusses_count, game_count: game_count, myshixun: @myshixun, diff --git a/app/views/shixuns/add_collaborators.json.jbuilder b/app/views/shixuns/add_collaborators.json.jbuilder index d73a5b9bc..d20f0b318 100644 --- a/app/views/shixuns/add_collaborators.json.jbuilder +++ b/app/views/shixuns/add_collaborators.json.jbuilder @@ -4,7 +4,7 @@ json.users do json.array! @users do |user| json.user_id user.id json.identify user.identity - json.nickname user.lastname + json.nickname user.real_name json.school_name user.school_name end From 2a50253d39d3691fa49105346e7d9448c9ee3645 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Fri, 28 Jun 2019 16:52:26 +0800 Subject: [PATCH 101/256] =?UTF-8?q?=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 | 92 ++++++++++++++++++- app/models/homework_common.rb | 10 +- 2 files changed, 98 insertions(+), 4 deletions(-) diff --git a/app/controllers/homework_commons_controller.rb b/app/controllers/homework_commons_controller.rb index b89fd6b67..bd18f102a 100644 --- a/app/controllers/homework_commons_controller.rb +++ b/app/controllers/homework_commons_controller.rb @@ -235,6 +235,96 @@ class HomeworkCommonsController < ApplicationController end end + def update_score + student_works = @homework.student_works + myshixuns = Myshixun.where(shixun_id: @homework.homework_commons_shixun&.shixun_id, user_id: @course.students.pluck(:user_id)) + myshixuns = Myshixun.where(shixun_id: @homework.homework_commons_shixun&.shixun_id). + joins("join course_members on myshixuns.user_id=course_members.user_id").where(course_members: {course_id: @course.id, role: 4}).includes(:games) + myshixuns.find_each(batch_size: 100) do |myshixun| + work = student_works.select{|work| work.user_id == myshixun.user_id}.first + setting_time = @homework.homework_group_setting work.user_id + + if setting_time.end_time.present? && (setting_time.end_time > Time.now || (@homework.allow_late && @homework.late_time && @homework.late_time > Time.now)) + #logger.info("#############setting_time: #{setting_time.end_time}") + + user_total_score = 0 + pass_consume_time = 0 + final_score = 0 + homework.homework_challenge_settings.each do |setting| + game = myshixun.games.where(:challenge_id => setting.challenge_id, :status => 2).first + unless game.nil? + pass_consume_time += (game.cost_time / 60.0).to_f + user_total_score += game.final_score.to_i < 0 ? 0 : game.challenge.score.to_i + adjust_score = work.challenge_work_scores.where(:challenge_id => setting.challenge_id).last + final_score += adjust_score.present? ? adjust_score.score : (homework.homework_detail_manual.answer_open_evaluation ? setting.score : (game.final_score > 0 ? game.real_score(setting.score) : 0)) + end + end + if work.work_status == 0 + is_complete = myshixun.is_complete? && (myshixun.done_time < setting_time.end_time) + work.work_status = setting_time.end_time > Time.now ? 1 : (is_complete ? 1 : 2) + work.late_penalty = setting_time.end_time > Time.now ? 0 : (is_complete ? 0 : homework.late_penalty) + work.commit_time = myshixun.created_at > setting_time.publish_time ? setting_time.publish_time : myshixun.created_at + work.myshixun_id = myshixun.id + end + + games = myshixun.games.where(:challenge_id => homework.homework_challenge_settings.map(&:challenge_id)) + myshixun_endtime = games.select{|game| game.status == 2}.size == games.size ? games.map(&:end_time).max : nil + if myshixun_endtime.present? + min_efficiency_changed = min_efficiency_changed.present? ? min_efficiency_changed : false + work.compelete_status = 1 + work.cost_time = myshixun_endtime.to_i - setting_time.publish_time.to_i + + efficiency = (pass_consume_time == 0 ? 0 : Math.log((user_total_score / pass_consume_time.to_f) + 1.0)) + work.efficiency = format("%.2f", efficiency) + + # 如果作业的最大效率值有变更则更新所有作品的效率分 + if homework.work_efficiency && homework.max_efficiency < work.efficiency + homework.update_column("max_efficiency", work.efficiency) + end + end + + work.update_time = Time.now + + work.final_score = final_score + score = work.final_score + work.eff_score - work.late_penalty + work.work_score = format("%.2f",(score < 0 ? 0 : score).to_f) unless work.ultimate_score + #logger.info("#############work_score: #{score}") + work.save! + end + end + @homework.student_works.each do || + + end + end + + def update_student_score + work = @homework.students_works.find_by(user_id: current_user.id) + myshixun = Myshixun.find_by(shixun_id: params[:shixun_id], user_id: current_user.id) + if work && myshixun + # 判断作品是否关联过myshixun + if work.myshixun_id.nil? + work.myshixun_id = myshixun.id + work.update_time = myshixun.updated_at + setting_time = @homework.homework_group_setting myshixun.user_id + games = myshixun.games.where(:challenge_id => @homework.homework_challenge_settings.pluck(:challenge_id)) + myshixun_endtime = games.select{|game| game.status == 2}.size == games.size ? games.map(&:end_time).max : nil + compelete_status = 0 + if myshixun_endtime.present? && myshixun_endtime < setting_time.end_time + if myshixun_endtime < setting_time.publish_time + compelete_status = 2 + else + compelete_status = 1 + end + end + if setting_time.end_time > Time.now + work.update_attributes(:work_status => 1, :late_penalty => 0, :commit_time => myshixun.updated_at, :update_time => myshixun.updated_at, :myshixun_id => myshixun.id, :compelete_status => compelete_status) + else + work.update_attributes(:work_status => ((myshixun.is_complete? && (myshixun.done_time < setting_time.end_time)) ? 1 : 2), :late_penalty => (myshixun.is_complete? && (myshixun.done_time < setting_time.end_time) ? 0 : homework.late_penalty), :commit_time => myshixun.updated_at, :update_time => myshixun.updated_at, :myshixun_id => myshixun.id, :compelete_status => compelete_status) + end + end + end + end + def alter_name tip_exception("作业名称不能为空") if params[:name].blank? @homework.update_attributes(name: params[:name].strip) @@ -620,7 +710,7 @@ class HomeworkCommonsController < ApplicationController if @homework_detail_manual.comment_status < 4 tip_exception("匿评结束时间不能为空") if @homework.anonymous_comment && params[:evaluation_end].blank? tip_exception("匿评截止时间必须晚于匿评开启时间") if @homework.anonymous_comment && - params[:evaluation_end] <= params[:evaluation_start] + params[:evaluation_end] <= strf_time(@homework_detail_manual.evaluation_start) tip_exception("匿评截止时间不能晚于课堂结束时间") if @homework.anonymous_comment && @course.end_date.present? && params[:evaluation_end] > strf_time(@course.end_date.end_of_day) diff --git a/app/models/homework_common.rb b/app/models/homework_common.rb index 6512c3f1d..8f24820e7 100644 --- a/app/models/homework_common.rb +++ b/app/models/homework_common.rb @@ -231,9 +231,13 @@ class HomeworkCommon < ApplicationRecord # 作业的分班设置时间 def homework_group_setting user_id - member = course.course_member(user_id) - group_setting = self.homework_group_settings.find_by_course_group_id(member.try(:course_group_id)) - homework_setting = group_setting.present? ? group_setting : self + if unified_setting + homework_setting = self + else + member = course.course_member(user_id) + group_setting = self.homework_group_settings.find_by_course_group_id(member.try(:course_group_id)) + homework_setting = group_setting.present? ? group_setting : self + end homework_setting end From 5d9c142b3524fa727e885cc3348b8651b4fd205f Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Sat, 29 Jun 2019 08:49:31 +0800 Subject: [PATCH 102/256] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E6=9F=A5=E9=87=8D?= 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 b89fd6b67..1ebb1cf93 100644 --- a/app/controllers/homework_commons_controller.rb +++ b/app/controllers/homework_commons_controller.rb @@ -1233,7 +1233,7 @@ class HomeworkCommonsController < ApplicationController # 代码查重届结果 def code_review_results # 如果有未获取结果的查重操作 则先读取结果 - get_new_code_reviews_result @homework + #get_new_code_reviews_result @homework @current_user = current_user # 列表数据 From 41da5389dee3d1c5c19d86de98b8178889f3242a Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Sat, 29 Jun 2019 09:07:41 +0800 Subject: [PATCH 103/256] =?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/controllers/graduation_tasks_controller.rb | 2 +- app/controllers/homework_commons_controller.rb | 11 +++++++---- app/controllers/student_works_controller.rb | 2 +- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/app/controllers/graduation_tasks_controller.rb b/app/controllers/graduation_tasks_controller.rb index 93d3cba3d..454f23c81 100644 --- a/app/controllers/graduation_tasks_controller.rb +++ b/app/controllers/graduation_tasks_controller.rb @@ -122,7 +122,7 @@ class GraduationTasksController < ApplicationController @work_count = @work_list.count @work_excel = @work_list - @work_list = @work_list.page(page).limit(limit) + @work_list = @work_list.page(page).per(limit) respond_to do |format| format.json format.xlsx{ diff --git a/app/controllers/homework_commons_controller.rb b/app/controllers/homework_commons_controller.rb index bd18f102a..c3bd777ae 100644 --- a/app/controllers/homework_commons_controller.rb +++ b/app/controllers/homework_commons_controller.rb @@ -316,10 +316,13 @@ class HomeworkCommonsController < ApplicationController compelete_status = 1 end end - if setting_time.end_time > Time.now - work.update_attributes(:work_status => 1, :late_penalty => 0, :commit_time => myshixun.updated_at, :update_time => myshixun.updated_at, :myshixun_id => myshixun.id, :compelete_status => compelete_status) - else - work.update_attributes(:work_status => ((myshixun.is_complete? && (myshixun.done_time < setting_time.end_time)) ? 1 : 2), :late_penalty => (myshixun.is_complete? && (myshixun.done_time < setting_time.end_time) ? 0 : homework.late_penalty), :commit_time => myshixun.updated_at, :update_time => myshixun.updated_at, :myshixun_id => myshixun.id, :compelete_status => compelete_status) + games.each do |game| + unless game.nil? + pass_consume_time += (game.cost_time / 60.0).to_f + user_total_score += game.final_score.to_i < 0 ? 0 : game.challenge.score.to_i + adjust_score = work.challenge_work_scores.where(:challenge_id => setting.challenge_id).last + final_score += adjust_score.present? ? adjust_score.score : (homework.homework_detail_manual.answer_open_evaluation ? setting.score : (game.final_score > 0 ? game.real_score(setting.score) : 0)) + end end end end diff --git a/app/controllers/student_works_controller.rb b/app/controllers/student_works_controller.rb index ab026cf05..5d14a43ea 100644 --- a/app/controllers/student_works_controller.rb +++ b/app/controllers/student_works_controller.rb @@ -43,7 +43,7 @@ class StudentWorksController < ApplicationController def search_member_list # 统一设置的作业取所有学生,否则取已发布的分班学生 students = @homework.unified_setting? ? @course.students : @course.students.where(course_group_id: @homework.published_settings.pluck(:course_group_id)) - unless params[:search].blank? + if !params[:search].blank? @members = students.joins(user: :user_extension).where("course_members.user_id != #{current_user.id} and (concat(users.lastname, users.firstname) like ? or user_extensions.student_id like ?)", "%#{params[:search]}%", "%#{params[:search]}%") else From 48bf9693d87b9f21a819bc210cb752a010c40376 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Sat, 29 Jun 2019 09:19:35 +0800 Subject: [PATCH 104/256] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=AE=9E=E8=AE=AD?= =?UTF-8?q?=E9=A2=98=E6=9C=AA=E9=80=9A=E5=85=B3=E6=98=BE=E7=A4=BA=E5=85=B3?= =?UTF-8?q?=E5=8D=A1=E5=86=85=E5=AE=B9=E4=B8=BA=E7=A9=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/exercise_questions_controller.rb | 2 +- .../exercise_questions/_exercise_questions.json.jbuilder | 2 +- app/views/exercises/_shixun_details.json.jbuilder | 9 ++++++++- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/app/controllers/exercise_questions_controller.rb b/app/controllers/exercise_questions_controller.rb index dd0247f70..79d671605 100644 --- a/app/controllers/exercise_questions_controller.rb +++ b/app/controllers/exercise_questions_controller.rb @@ -640,7 +640,7 @@ class ExerciseQuestionsController < ApplicationController if @exercise.exercise_status != 1 question_score = @exercise_question.question_score #原来的分数 update_question_score = params[:question_score].to_f.round(1) #传入的分数 - choices_count = @exercise_question.exercise_choices.count #原来的选项个数 + choices_count = @exercise_question.exercise_choices.size #原来的选项个数 exercise_choice_ids = @exercise_question.exercise_standard_answers.pluck(:exercise_choice_id).uniq standard_answers_text = @exercise_question.exercise_standard_answers.pluck(:answer_text).uniq update_choices_count = params[:question_choices].present? ? params[:question_choices].count : choices_count #传入的选项个数 diff --git a/app/views/exercise_questions/_exercise_questions.json.jbuilder b/app/views/exercise_questions/_exercise_questions.json.jbuilder index 9445862ba..4e05ffb7a 100644 --- a/app/views/exercise_questions/_exercise_questions.json.jbuilder +++ b/app/views/exercise_questions/_exercise_questions.json.jbuilder @@ -86,7 +86,7 @@ elsif question.question_type == 5 user_get_score = games_score[:s_score].present? ? games_score[:s_score] : 0.0 json.shixun_challenge_id s.id if games_score[:games].count > 0 - json.partial! "exercises/shixun_details",games: games_score[:games], user_score: user_get_score,game_score: games_score[:game_score] + json.partial! "exercises/shixun_details",games: games_score[:games], user_score: user_get_score,game_score: games_score[:game_score],shixun_challenge:s else json.partial! "exercises/shixun_undo",games: [s], user_score: user_get_score ,game_score: s.question_score end diff --git a/app/views/exercises/_shixun_details.json.jbuilder b/app/views/exercises/_shixun_details.json.jbuilder index c788b8c1c..a28bf4145 100644 --- a/app/views/exercises/_shixun_details.json.jbuilder +++ b/app/views/exercises/_shixun_details.json.jbuilder @@ -26,6 +26,13 @@ json.shixun_detail do json.position output.query_index json.output_detail output_detail game, output end - json.passed_code game.try(:lastest_code) + + if game.try(:lastest_code).blank? + cha_path = challenge_path(shixun_challenge.challenge&.path) + latest_code = git_fle_content(shixun_challenge.shixun&.repo_path,cha_path) + else + latest_code = game.try(:lastest_code) + end + json.passed_code latest_code end end \ No newline at end of file From f2fed6a237d740b3f1c3825bdb6dfe4013a4464b Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Sat, 29 Jun 2019 09:32:59 +0800 Subject: [PATCH 105/256] fix bug --- app/controllers/concerns/git_helper.rb | 5 ----- app/helpers/application_helper.rb | 6 ++++++ 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/app/controllers/concerns/git_helper.rb b/app/controllers/concerns/git_helper.rb index 445d67087..f40e18e1c 100644 --- a/app/controllers/concerns/git_helper.rb +++ b/app/controllers/concerns/git_helper.rb @@ -53,9 +53,4 @@ module GitHelper container.update_attributes!(:repo_name => new_repo_name) end - #实训题的关卡url初始化 - def challenge_path(path) - cha_path = path.present? ? path.split(";") : [] - cha_path.reject(&:blank?)[0].try(:strip) - end end \ No newline at end of file diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 32c4438a6..0cdfeba06 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -332,6 +332,12 @@ module ApplicationHelper raw arr.join('') end + + #实训题的关卡url初始化 + def challenge_path(path) + cha_path = path.present? ? path.split(";") : [] + cha_path.reject(&:blank?)[0].try(:strip) + end end From 71ea32797d5193d8c891575dbc443fd5b5b27c65 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Sat, 29 Jun 2019 09:39:05 +0800 Subject: [PATCH 106/256] fix bug --- app/controllers/concerns/git_helper.rb | 5 +++++ app/helpers/application_helper.rb | 6 +----- app/helpers/exercises_helper.rb | 1 + 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/app/controllers/concerns/git_helper.rb b/app/controllers/concerns/git_helper.rb index f40e18e1c..445d67087 100644 --- a/app/controllers/concerns/git_helper.rb +++ b/app/controllers/concerns/git_helper.rb @@ -53,4 +53,9 @@ module GitHelper container.update_attributes!(:repo_name => new_repo_name) end + #实训题的关卡url初始化 + def challenge_path(path) + cha_path = path.present? ? path.split(";") : [] + cha_path.reject(&:blank?)[0].try(:strip) + end end \ No newline at end of file diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 0cdfeba06..d8ea8cd60 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -1,6 +1,7 @@ # 所有的方法请按首字母的顺序依次列出 module ApplicationHelper include Educoder::I18n + include GitHelper ONE_MINUTE = 60 * 1000 ONE_HOUR = 60 * ONE_MINUTE @@ -333,11 +334,6 @@ module ApplicationHelper raw arr.join('') end - #实训题的关卡url初始化 - def challenge_path(path) - cha_path = path.present? ? path.split(";") : [] - cha_path.reject(&:blank?)[0].try(:strip) - end end diff --git a/app/helpers/exercises_helper.rb b/app/helpers/exercises_helper.rb index a2a80c311..45666d296 100644 --- a/app/helpers/exercises_helper.rb +++ b/app/helpers/exercises_helper.rb @@ -1,5 +1,6 @@ module ExercisesHelper + # include GitHelper #获取每个学生对每个题的答案状态 def get_each_student_exercise(exercise_id,exercise_questions,user_id) From 226afa2d96beb9aea284303b1589220b9f377955 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Sat, 29 Jun 2019 09:42:54 +0800 Subject: [PATCH 107/256] fix bug --- app/views/exercises/_shixun_details.json.jbuilder | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/app/views/exercises/_shixun_details.json.jbuilder b/app/views/exercises/_shixun_details.json.jbuilder index a28bf4145..de847ebed 100644 --- a/app/views/exercises/_shixun_details.json.jbuilder +++ b/app/views/exercises/_shixun_details.json.jbuilder @@ -27,12 +27,17 @@ json.shixun_detail do json.output_detail output_detail game, output end - if game.try(:lastest_code).blank? - cha_path = challenge_path(shixun_challenge.challenge&.path) - latest_code = git_fle_content(shixun_challenge.shixun&.repo_path,cha_path) + if game.evaluate_count > 0 + if game.try(:lastest_code).blank? + cha_path = challenge_path(shixun_challenge.challenge&.path) + latest_code = git_fle_content(shixun_challenge.shixun&.repo_path,cha_path) + else + latest_code = game.try(:lastest_code) + end else - latest_code = game.try(:lastest_code) + latest_code = nil end + json.passed_code latest_code end end \ No newline at end of file From a8b0f950c71eacef61154a822821c96978db7194 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Sat, 29 Jun 2019 09:52:17 +0800 Subject: [PATCH 108/256] fix bug --- app/views/exercises/_shixun_details.json.jbuilder | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/app/views/exercises/_shixun_details.json.jbuilder b/app/views/exercises/_shixun_details.json.jbuilder index de847ebed..ac3884336 100644 --- a/app/views/exercises/_shixun_details.json.jbuilder +++ b/app/views/exercises/_shixun_details.json.jbuilder @@ -27,15 +27,11 @@ json.shixun_detail do json.output_detail output_detail game, output end - if game.evaluate_count > 0 - if game.try(:lastest_code).blank? - cha_path = challenge_path(shixun_challenge.challenge&.path) - latest_code = git_fle_content(shixun_challenge.shixun&.repo_path,cha_path) - else - latest_code = game.try(:lastest_code) - end + if game.try(:lastest_code).blank? + cha_path = challenge_path(shixun_challenge.challenge&.path) + latest_code = git_fle_content(shixun_challenge.shixun&.repo_path,cha_path) else - latest_code = nil + latest_code = game.try(:lastest_code) end json.passed_code latest_code From 4b71fc157677ad9ca15eeb9f856cd4dc30370c3f Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Sat, 29 Jun 2019 09:59:06 +0800 Subject: [PATCH 109/256] fix bug --- app/controllers/concerns/git_helper.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/controllers/concerns/git_helper.rb b/app/controllers/concerns/git_helper.rb index 445d67087..8e7288df2 100644 --- a/app/controllers/concerns/git_helper.rb +++ b/app/controllers/concerns/git_helper.rb @@ -31,7 +31,8 @@ module GitHelper decode_content rescue Exception => e - uid_logger_error(e.message) + Rails.logger.error(e.message) + # uid_logger_error(e.message) raise Educoder::TipException.new("文档内容获取异常") end end From 5c74d71c947720f37b94e7e2dec7d6f630daf021 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Sat, 29 Jun 2019 10:14:46 +0800 Subject: [PATCH 110/256] fix bug --- app/helpers/exercises_helper.rb | 2 +- app/views/exercises/_shixun_details.json.jbuilder | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/helpers/exercises_helper.rb b/app/helpers/exercises_helper.rb index 45666d296..5f8683fd0 100644 --- a/app/helpers/exercises_helper.rb +++ b/app/helpers/exercises_helper.rb @@ -436,7 +436,7 @@ module ExercisesHelper game_code = game_challenge code = game_code.try(:new_code) else - code = git_fle_content(exercise_cha.shixun&.repo_path,cha_path) + code = git_fle_content(game.myshixun.repo_path,cha_path) end sx_option = { :exercise_question_id => q.id, diff --git a/app/views/exercises/_shixun_details.json.jbuilder b/app/views/exercises/_shixun_details.json.jbuilder index ac3884336..96e5c6281 100644 --- a/app/views/exercises/_shixun_details.json.jbuilder +++ b/app/views/exercises/_shixun_details.json.jbuilder @@ -29,7 +29,7 @@ json.shixun_detail do if game.try(:lastest_code).blank? cha_path = challenge_path(shixun_challenge.challenge&.path) - latest_code = git_fle_content(shixun_challenge.shixun&.repo_path,cha_path) + latest_code = git_fle_content(game&.myshixun.repo_path,cha_path) else latest_code = game.try(:lastest_code) end From a78759f8af49cc8c20d2d2b523256fe7875b7e6e Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Sat, 29 Jun 2019 10:19:10 +0800 Subject: [PATCH 111/256] =?UTF-8?q?=E5=BC=80=E5=90=AF=E5=AE=9E=E8=AE=AD?= =?UTF-8?q?=E6=8A=A5500?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/games_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/games_controller.rb b/app/controllers/games_controller.rb index 9e645c35a..8c364308f 100644 --- a/app/controllers/games_controller.rb +++ b/app/controllers/games_controller.rb @@ -52,7 +52,7 @@ class GamesController < ApplicationController record_onsume_time = EvaluateRecord.where(game_id: @game.id).first.try(:consume_time) # myshixun_manager判断用户是否有权限查看隐藏测试集(TPM管理员;平台认证的老师;花费金币查看者) - myshixun_manager = @identity < USER::EDU_GAME_MANAGER + myshixun_manager = @identity < User::EDU_GAME_MANAGER # 选择题和编程题公共部分 @base_date = {st: @st, discusses_count: discusses_count, game_count: game_count, myshixun: @myshixun, From 8cfb86d76c9857493bc5f926408fe80ad49cd91d Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Sat, 29 Jun 2019 10:28:30 +0800 Subject: [PATCH 112/256] fix bug --- app/views/exercises/_shixun_details.json.jbuilder | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/exercises/_shixun_details.json.jbuilder b/app/views/exercises/_shixun_details.json.jbuilder index 96e5c6281..85bf532e1 100644 --- a/app/views/exercises/_shixun_details.json.jbuilder +++ b/app/views/exercises/_shixun_details.json.jbuilder @@ -29,7 +29,7 @@ json.shixun_detail do if game.try(:lastest_code).blank? cha_path = challenge_path(shixun_challenge.challenge&.path) - latest_code = git_fle_content(game&.myshixun.repo_path,cha_path) + latest_code = git_fle_content(game.myshixun.repo_path,cha_path) else latest_code = game.try(:lastest_code) end From 067c516561d1fc70ae7152cf2893d0d16673fec8 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Sat, 29 Jun 2019 10:43:50 +0800 Subject: [PATCH 113/256] =?UTF-8?q?=E7=89=88=E6=9C=AC=E5=BA=93=E6=89=93?= =?UTF-8?q?=E5=8D=B0=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/concerns/git_helper.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/controllers/concerns/git_helper.rb b/app/controllers/concerns/git_helper.rb index 8e7288df2..78eae769c 100644 --- a/app/controllers/concerns/git_helper.rb +++ b/app/controllers/concerns/git_helper.rb @@ -9,6 +9,8 @@ module GitHelper # 版本库文件内容,带转码 def git_fle_content(repo_path, path) begin + logger.info("##########repo_path: #{repo_path}") + logger.info("##########path: #{path}") content = GitService.file_content(repo_path: repo_path, path: path) logger.info("@@@@@@@@@@@@@@@@@@#{content}") From 76d16698a1d83e3ac5753d6f8c3c56b3fd0bb72c Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Sat, 29 Jun 2019 10:49:05 +0800 Subject: [PATCH 114/256] fix bug --- app/helpers/exercises_helper.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/helpers/exercises_helper.rb b/app/helpers/exercises_helper.rb index 5f8683fd0..6ec6cd601 100644 --- a/app/helpers/exercises_helper.rb +++ b/app/helpers/exercises_helper.rb @@ -430,7 +430,10 @@ module ExercisesHelper end ex_shixun_answer_content = answers_content&.where(exercise_shixun_challenge_id: exercise_cha.id) if ex_shixun_answer_content.blank? #把关卡的答案存入试卷的实训里 + logger.info("############_________exercise_cha.challenge&.path___________###############{exercise_cha.challenge&.path}") cha_path = challenge_path(exercise_cha.challenge&.path) + logger.info("############_________cha_path___________###############{cha_path}") + game_challenge = game.game_codes.search_challenge_path(cha_path)&.first if game_challenge.present? game_code = game_challenge From 831b1937f98eeb529283db11bae76f7cc8dff4c7 Mon Sep 17 00:00:00 2001 From: jingquan huang Date: Sat, 29 Jun 2019 10:57:24 +0800 Subject: [PATCH 115/256] =?UTF-8?q?challenge=E6=98=BE=E7=A4=BA=E9=94=99?= =?UTF-8?q?=E8=AF=AF=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/challenges_controller.rb | 4 ++-- app/controllers/shixuns_controller.rb | 5 ----- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/app/controllers/challenges_controller.rb b/app/controllers/challenges_controller.rb index 2ba76c60a..afe0e14b6 100644 --- a/app/controllers/challenges_controller.rb +++ b/app/controllers/challenges_controller.rb @@ -151,8 +151,8 @@ class ChallengesController < ApplicationController def index uid_logger("identifier: #{params}") # 通过调试发现 这里includes(:games)性能会慢10倍 - - @challenges = @shixun.challenges.fields_for_list.includes(:games).where("games.user_id" => current_user.id) + current_myshixun = @shixun.current_myshixun(current_user.id) + @challenges = @shixun.challenges.includes(:games).where("games.user_id" => (current_myshixun ? current_user.id : nil)) @editable = current_user.manager_of_shixun?(@shixun) && @shixun.status == 0 @user = current_user diff --git a/app/controllers/shixuns_controller.rb b/app/controllers/shixuns_controller.rb index 73029706f..b3069bc5d 100644 --- a/app/controllers/shixuns_controller.rb +++ b/app/controllers/shixuns_controller.rb @@ -553,11 +553,6 @@ class ShixunsController < ApplicationController end end - # REDO:开启实训时更新关联作品的状态 - # TODO:这个可以异步。或者放到课程里面取,不要在开启实训这边做 - # HomeworksService.new.update_myshixun_work_status myshixun - UpdateMyshixunWorkStatusJob.perform_later(myshixun.id) - @current_task = myshixun.current_task(myshixun.games) uid_logger("## shixun exec: myshixun id is #{myshixun.id}") rescue Exception => e From 538efef33aa40d3483da58d57bd933c569e1a48d Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Sat, 29 Jun 2019 11:18:59 +0800 Subject: [PATCH 116/256] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E6=9F=A5=E9=87=8D?= =?UTF-8?q?=E7=BB=93=E6=9E=9C?= 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 2a1dfb14a..c3bd777ae 100644 --- a/app/controllers/homework_commons_controller.rb +++ b/app/controllers/homework_commons_controller.rb @@ -1326,7 +1326,7 @@ class HomeworkCommonsController < ApplicationController # 代码查重届结果 def code_review_results # 如果有未获取结果的查重操作 则先读取结果 - #get_new_code_reviews_result @homework + get_new_code_reviews_result @homework @current_user = current_user # 列表数据 From 9d7d609bb5ebfa4d573dc6be55582653f445a0d3 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Sat, 29 Jun 2019 11:28:36 +0800 Subject: [PATCH 117/256] fix bug --- app/helpers/exercises_helper.rb | 11 ++++++----- .../_exercise_questions.json.jbuilder | 6 +++++- app/views/exercises/_shixun_details.json.jbuilder | 13 ++++++++----- .../exercises/_user_exercise_info.json.jbuilder | 2 +- 4 files changed, 20 insertions(+), 12 deletions(-) diff --git a/app/helpers/exercises_helper.rb b/app/helpers/exercises_helper.rb index 6ec6cd601..68f6574ee 100644 --- a/app/helpers/exercises_helper.rb +++ b/app/helpers/exercises_helper.rb @@ -429,11 +429,9 @@ module ExercisesHelper answer_status = 1 end ex_shixun_answer_content = answers_content&.where(exercise_shixun_challenge_id: exercise_cha.id) - if ex_shixun_answer_content.blank? #把关卡的答案存入试卷的实训里 - logger.info("############_________exercise_cha.challenge&.path___________###############{exercise_cha.challenge&.path}") + code = nil + if exercise_cha.challenge&.path.present? cha_path = challenge_path(exercise_cha.challenge&.path) - logger.info("############_________cha_path___________###############{cha_path}") - game_challenge = game.game_codes.search_challenge_path(cha_path)&.first if game_challenge.present? game_code = game_challenge @@ -441,6 +439,9 @@ module ExercisesHelper else code = git_fle_content(game.myshixun.repo_path,cha_path) end + end + if ex_shixun_answer_content.blank? #把关卡的答案存入试卷的实训里 + ### Todo 实训题的_shixun_details里的代码是不是直接从这里取出就可以了?涉及到code的多个版本库的修改 sx_option = { :exercise_question_id => q.id, :exercise_shixun_challenge_id => exercise_cha.id, @@ -451,7 +452,7 @@ module ExercisesHelper } ExerciseShixunAnswer.create(sx_option) else - ex_shixun_answer_content.first.update_column('score',exercise_cha_score) + ex_shixun_answer_content.first.update_attributes(score:exercise_cha_score.round(1),answer_text:code) end score5 += exercise_cha_score else diff --git a/app/views/exercise_questions/_exercise_questions.json.jbuilder b/app/views/exercise_questions/_exercise_questions.json.jbuilder index 4e05ffb7a..4cdd97f3c 100644 --- a/app/views/exercise_questions/_exercise_questions.json.jbuilder +++ b/app/views/exercise_questions/_exercise_questions.json.jbuilder @@ -1,6 +1,10 @@ json.question_id question.id # json.question_number question.question_number -json.q_position ques_position.present? ? ques_position : question.question_number +q_positon = question.question_number +if ques_position.present? + q_positon = ques_position +end +json.q_position q_positon json.question_title question.question_title json.question_type question.question_type json.question_score question.question_score.round(1).to_s diff --git a/app/views/exercises/_shixun_details.json.jbuilder b/app/views/exercises/_shixun_details.json.jbuilder index 85bf532e1..4a73a9bbb 100644 --- a/app/views/exercises/_shixun_details.json.jbuilder +++ b/app/views/exercises/_shixun_details.json.jbuilder @@ -27,11 +27,14 @@ json.shixun_detail do json.output_detail output_detail game, output end - if game.try(:lastest_code).blank? - cha_path = challenge_path(shixun_challenge.challenge&.path) - latest_code = git_fle_content(game.myshixun.repo_path,cha_path) - else - latest_code = game.try(:lastest_code) + latest_code = nil + if shixun_challenge.challenge&.path.present? + if game.try(:lastest_code).blank? + cha_path = challenge_path(shixun_challenge.challenge&.path) + latest_code = git_fle_content(game.myshixun.repo_path,cha_path) + else + latest_code = game.try(:lastest_code) + end end json.passed_code latest_code diff --git a/app/views/exercises/_user_exercise_info.json.jbuilder b/app/views/exercises/_user_exercise_info.json.jbuilder index 1ff929897..cba07fb3f 100644 --- a/app/views/exercises/_user_exercise_info.json.jbuilder +++ b/app/views/exercises/_user_exercise_info.json.jbuilder @@ -62,7 +62,7 @@ json.exercise_questions do exercise_type: ex_type, user_answer: user_ques_answers[:answered_content], shixun_type: user_ques_answers[:shixun_type], - ques_position:nil + ques_position: nil if user_ques_comments.count > 0 json.question_comments do json.partial! "exercises/exercise_comments", question_comment:user_ques_answers[:question_comment].first From 16dba624008e84859976f2223f4b094faea942a9 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Sat, 29 Jun 2019 11:31:54 +0800 Subject: [PATCH 118/256] fix bug --- app/views/exercise_questions/_exercise_questions.json.jbuilder | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/exercise_questions/_exercise_questions.json.jbuilder b/app/views/exercise_questions/_exercise_questions.json.jbuilder index 4cdd97f3c..ce8d0f1f2 100644 --- a/app/views/exercise_questions/_exercise_questions.json.jbuilder +++ b/app/views/exercise_questions/_exercise_questions.json.jbuilder @@ -4,7 +4,7 @@ q_positon = question.question_number if ques_position.present? q_positon = ques_position end -json.q_position q_positon +json.q_position question.question_number json.question_title question.question_title json.question_type question.question_type json.question_score question.question_score.round(1).to_s From 0ec0e612fa4d568db685c4c5b4df884ddff5d6dd Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Sat, 29 Jun 2019 11:41:10 +0800 Subject: [PATCH 119/256] fix bug --- app/views/exercise_questions/_exercise_questions.json.jbuilder | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/exercise_questions/_exercise_questions.json.jbuilder b/app/views/exercise_questions/_exercise_questions.json.jbuilder index ce8d0f1f2..4cdd97f3c 100644 --- a/app/views/exercise_questions/_exercise_questions.json.jbuilder +++ b/app/views/exercise_questions/_exercise_questions.json.jbuilder @@ -4,7 +4,7 @@ q_positon = question.question_number if ques_position.present? q_positon = ques_position end -json.q_position question.question_number +json.q_position q_positon json.question_title question.question_title json.question_type question.question_type json.question_score question.question_score.round(1).to_s From da2c9c97c263743af8c3a6238ff63f9cede3a36b Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Sat, 29 Jun 2019 12:29:14 +0800 Subject: [PATCH 120/256] fix bug --- 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 68f6574ee..72fbc9486 100644 --- a/app/helpers/exercises_helper.rb +++ b/app/helpers/exercises_helper.rb @@ -642,7 +642,7 @@ module ExercisesHelper end if student_status == 2 #当前为老师,或为学生且已提交 user_score_pre = exercise_answers.score_reviewed - user_score = user_score_pre.present? ? user_score_pre.pluck(:score).sum : nil + user_score = user_score_pre.present? ? user_score_pre.pluck(:score).sum : "0.0" end if user_score.present? && (user_score > q.question_score) From 8dd42b59a7237468f4c0c72487032e9293f82b2c Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Sat, 29 Jun 2019 12:30:32 +0800 Subject: [PATCH 121/256] fix bug --- 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 72fbc9486..04890954b 100644 --- a/app/helpers/exercises_helper.rb +++ b/app/helpers/exercises_helper.rb @@ -642,7 +642,7 @@ module ExercisesHelper end if student_status == 2 #当前为老师,或为学生且已提交 user_score_pre = exercise_answers.score_reviewed - user_score = user_score_pre.present? ? user_score_pre.pluck(:score).sum : "0.0" + user_score = user_score_pre.present? ? user_score_pre.pluck(:score).sum : 0.0 end if user_score.present? && (user_score > q.question_score) From 079d757021b4678302f9e34832117f6222baf709 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Sat, 29 Jun 2019 14:17:43 +0800 Subject: [PATCH 122/256] =?UTF-8?q?=E8=B0=83=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/myshixuns_controller.rb | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/app/controllers/myshixuns_controller.rb b/app/controllers/myshixuns_controller.rb index 035b43955..8629083dd 100644 --- a/app/controllers/myshixuns_controller.rb +++ b/app/controllers/myshixuns_controller.rb @@ -260,12 +260,12 @@ class MyshixunsController < ApplicationController unless @hide_code # 远程版本库文件内容 last_content = GitService.file_content(repo_path: @repo_path, path: path)["content"] - - content = if @myshixun.mirror_name.select{|a| a.include?("MachineLearning") || a.include?("Python")}.present? && params[:content].present? - params[:content].gsub(/\t/, ' ') - else - params[:content] - end + content = params[:content] + # content = if @myshixun.mirror_name.select{|a| a.include?("MachineLearning") || a.include?("Python")}.present? && params[:content].present? + # params[:content].gsub(/\t/, ' ') + # else + # params[:content] + # end if content != last_content @content_modified = 1 From 0d5361b59cd9c45c10c585610ba1df83ef22a0dd Mon Sep 17 00:00:00 2001 From: jingquan huang Date: Sat, 29 Jun 2019 14:38:12 +0800 Subject: [PATCH 123/256] shixun file update --- app/controllers/myshixuns_controller.rb | 85 ++++++++++--------- app/views/myshixuns/update_file.json.jbuilder | 1 + 2 files changed, 44 insertions(+), 42 deletions(-) diff --git a/app/controllers/myshixuns_controller.rb b/app/controllers/myshixuns_controller.rb index 035b43955..24c5066e5 100644 --- a/app/controllers/myshixuns_controller.rb +++ b/app/controllers/myshixuns_controller.rb @@ -243,55 +243,56 @@ class MyshixunsController < ApplicationController # -----Repository # TODO: 之类需要一个resubmit参数,但是是关于games. def update_file - @hide_code = Shixun.where(id: @myshixun.shixun_id).pluck(:hide_code).first - tip_exception("技术平台为空!") if @myshixun.mirror_name.blank? - path = params[:path].strip unless params[:path].blank? - game_id = params[:game_id] - game = Game.find(game_id) - @content_modified = 0 - # params[:evaluate] 实训评测时更新必须给的参数,需要依据该参数做性能统计,其它类型的更新可以跳过 - # 自动保存的时候evaluate为0;点评测的时候为1 - if params[:evaluate] == 1 - record = EvaluateRecord.create!(:user_id => current_user.id, :shixun_id => @myshixun.shixun_id, :game_id => game_id) - uid_logger("-- game is #{game_id}, record id is #{record.id}, time is **** #{Time.now.strftime("%Y-%m-%d %H:%M:%S.%L")}") - student_work_time = format("%.3f", (Time.now.to_f - record.created_at.to_f)).to_f - record.update_attributes!(:student_work => student_work_time) - end - unless @hide_code - # 远程版本库文件内容 - last_content = GitService.file_content(repo_path: @repo_path, path: path)["content"] + begin + @hide_code = Shixun.where(id: @myshixun.shixun_id).pluck(:hide_code).first + tip_exception("技术平台为空!") if @myshixun.mirror_name.blank? + path = params[:path].strip unless params[:path].blank? + game_id = params[:game_id] + game = Game.find(game_id) + @content_modified = 0 + + # params[:evaluate] 实训评测时更新必须给的参数,需要依据该参数做性能统计,其它类型的更新可以跳过 + # 自动保存的时候evaluate为0;点评测的时候为1 + if params[:evaluate] == 1 + @sec_key = generate_identifier(EvaluateRecord, 12) + record = EvaluateRecord.create!(:user_id => current_user.id, :shixun_id => @myshixun.shixun_id, :game_id => game_id, + :identifier => @sec_key) + uid_logger("-- game build: file update #{@sec_key}, record id is #{record.id}, time is **** #{Time.now.strftime("%Y-%m-%d %H:%M:%S.%L")}") + end + unless @hide_code + # 远程版本库文件内容 + last_content = GitService.file_content(repo_path: @repo_path, path: path)["content"] - content = if @myshixun.mirror_name.select{|a| a.include?("MachineLearning") || a.include?("Python")}.present? && params[:content].present? - params[:content].gsub(/\t/, ' ') - else - params[:content] - end - if content != last_content - @content_modified = 1 + content = params[:content] - author_name = current_user.full_name - author_email = current_user.mail - message = params[:evaluate] == 0 ? "auto commit" : "task commit" - @content = GitService.update_file(repo_path: @repo_path, - file_path: path, - message: message, - content: content, - author_name: author_name, - author_email: author_email) + if content != last_content + @content_modified = 1 - uid_logger("-- file update #{@content}") + author_name = current_user.full_name + author_email = current_user.mail + message = params[:evaluate] == 0 ? "System automatically submitted" : "User submitted" + @content = GitService.update_file(repo_path: @repo_path, + file_path: path, + message: message, + content: content, + author_name: author_name, + author_email: author_email) + end end - end - if game.status == 2 - @resubmit = Time.now.to_i - end + if game.status == 2 + @resubmit = Time.now.to_i + end - # 评测时间记录 - if record.present? - consume_time = format("%.3f", (Time.now.to_f - record.created_at.to_f)).to_f - record.update_attributes!(:file_update => consume_time) + # 评测时间记录 + if record.present? + consume_time = format("%.3f", (Time.now.to_f - record.created_at.to_f)).to_f + record.update_attributes!(:file_update => consume_time) + end + rescue Exception => e + uid_logger_error(e.message) + tip_exception("文件内容更新异常,请稍后重试") end end diff --git a/app/views/myshixuns/update_file.json.jbuilder b/app/views/myshixuns/update_file.json.jbuilder index c647927c4..ce8426715 100644 --- a/app/views/myshixuns/update_file.json.jbuilder +++ b/app/views/myshixuns/update_file.json.jbuilder @@ -1,3 +1,4 @@ json.content @content json.resubmit "#{@resubmit}" +json.sec_key "#{@sec_key}" json.content_modified @hide_code ? false : @content_modified From 84b6110c56e58c409628273315ad252bb82b9172 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Sat, 29 Jun 2019 14:44:18 +0800 Subject: [PATCH 124/256] fix bug --- .../exercise_questions_controller.rb | 2 +- app/helpers/exercises_helper.rb | 17 ++++++++++++----- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/app/controllers/exercise_questions_controller.rb b/app/controllers/exercise_questions_controller.rb index 79d671605..b231d6af7 100644 --- a/app/controllers/exercise_questions_controller.rb +++ b/app/controllers/exercise_questions_controller.rb @@ -616,7 +616,7 @@ class ExerciseQuestionsController < ApplicationController elsif params[:question_type].to_i == 2 && (params[:standard_answers].count > 1 || params[:question_choices].blank? || params[:question_choices].include?("")) #判断题的标准答案不能大于1个,选项不能为空 normal_status(-1,"判断题选项不能为空/标准答案不能大于1个!") elsif params[:question_type].to_i <= 1 && (params[:question_choices].blank? || params[:question_choices].include?("") || params[:question_choices].count < 2) #选择题选项不能为空,且不能小于2 - normal_status(-1,"选择题选项内容不能为空,且不能少于3个!") + normal_status(-1,"选择题选项内容不能为空,且不能少于2个!") elsif params[:question_type].to_i == 3 && (params[:standard_answers].blank? || params[:standard_answers].count > 5 ) #填空题选项最多为5个,且如果为1个的话,不允许修改is_ordered normal_status(-1,"填空题标准答案不能为空/不能超过5个!") elsif params[:question_type].to_i == 4 && params[:standard_answers].count > 2 #简单题参考答案最多为1个 diff --git a/app/helpers/exercises_helper.rb b/app/helpers/exercises_helper.rb index 04890954b..1442e1da3 100644 --- a/app/helpers/exercises_helper.rb +++ b/app/helpers/exercises_helper.rb @@ -167,10 +167,13 @@ module ExercisesHelper ex_score = ex&.question_score full_scores = effictive_users.search_exercise_answer("score",ex_score).count #满分人数 no_full_scores = effictive_users.exercise_no_full_scores(ex_score).count #部分分数人数 - all_zero_scores = effictive_users.search_exercise_answer("score",0.0).count #包含为0分的,及未评阅的 - review_scores = ex.exercise_answer_comments.count #主观题的评阅数量 - un_review_scores = effictive_users_count - review_scores #未评阅数 - zero_scores = all_zero_scores - un_review_scores #已评阅,且答案未0分的人数 + zero_scores = effictive_users.search_exercise_answer("score",0.0).count #包含为0分的,及未评阅的 + # review_scores = ex.exercise_answer_comments.count #主观题的评阅数量 + un_review_scores = effictive_users_count - full_scores - no_full_scores - zero_scores #未评阅数 + if un_review_scores < 0 + un_review_scores = 0 + end + # zero_scores = all_zero_scores - un_review_scores #已评阅,且答案未0分的人数 main_scores_array = [full_scores,no_full_scores,zero_scores,un_review_scores] main_scores_array.each_with_index do |s,index| if index == 0 @@ -642,7 +645,11 @@ module ExercisesHelper end if student_status == 2 #当前为老师,或为学生且已提交 user_score_pre = exercise_answers.score_reviewed - user_score = user_score_pre.present? ? user_score_pre.pluck(:score).sum : 0.0 + if ques_type == 4 && user_score_pre.blank? #主观题时,且没有大于0的分数时,为空 + user_score = nil + else + user_score = user_score_pre.present? ? user_score_pre.pluck(:score).sum : 0.0 + end end if user_score.present? && (user_score > q.question_score) From ab098a3e24d305b9069ee2c7419d0d3331b7f28a Mon Sep 17 00:00:00 2001 From: jasder Date: Sat, 29 Jun 2019 15:04:25 +0800 Subject: [PATCH 125/256] =?UTF-8?q?FIX=20=E8=B5=84=E6=BA=90=E5=88=97?= =?UTF-8?q?=E8=A1=A8=E9=A1=B6=E9=83=A8=E6=95=B0=E9=87=8F=E7=BB=9F=E8=AE=A1?= =?UTF-8?q?=E6=9B=B4=E6=94=B9=E7=AE=97=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/files_controller.rb | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/app/controllers/files_controller.rb b/app/controllers/files_controller.rb index 7e150c44c..c303c7e78 100644 --- a/app/controllers/files_controller.rb +++ b/app/controllers/files_controller.rb @@ -17,25 +17,27 @@ class FilesController < ApplicationController sort_type = params[:sort_type] || 'created_on' # created_on:时间排序, downloads:下载次数排序; quotes: 引用次数排序 course_second_category_id = params[:course_second_category_id] || 0 # 0: 为主目录, 其他为次目录id @user = current_user || nil - @attachments = @course.attachments.by_keywords(params[:search]) + @attachments = @course.attachments.by_course_second_category_id(course_second_category_id) .includes(attachment_group_settings: :course_group, author: [:user_extension, :course_members]) - .by_course_second_category_id(course_second_category_id) .ordered(sort: sort.to_i, sort_type: sort_type.strip) get_category(@course, course_second_category_id) - case @user.course_identity(@course) - when 5 - # 课程学生 - @attachments = @attachments.published - when 6 || 7 - # 非课堂成员 - @attachments = @attachments.publiced.published - end + @attachments = + case @user.course_identity(@course) + when 5 + @attachments.published + when 6, 7 + @attachments.publiced.published + else + @attachments + end @total_count = @attachments.size @public_count = @attachments.publiced.size @private_count = @total_count - @public_count + @attachments = @attachments.by_keywords(params[:search]) + @attachments = @attachments.page(@page).per(@page_size) end From d8ecd6e7728977f463a0975eaaef51640c5e7c9e Mon Sep 17 00:00:00 2001 From: jingquan huang Date: Sat, 29 Jun 2019 15:09:44 +0800 Subject: [PATCH 126/256] =?UTF-8?q?tpi=20=E7=89=88=E6=9C=AC=E5=BA=93?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E6=9B=B4=E6=96=B0=E5=92=8C=E8=8E=B7=E5=8F=96?= =?UTF-8?q?=E7=9A=84=E4=B8=80=E4=BA=9B=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/concerns/git_common.rb | 1 - app/controllers/concerns/git_helper.rb | 6 ++---- app/controllers/games_controller.rb | 1 + 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/app/controllers/concerns/git_common.rb b/app/controllers/concerns/git_common.rb index 2f977245c..452204419 100644 --- a/app/controllers/concerns/git_common.rb +++ b/app/controllers/concerns/git_common.rb @@ -28,7 +28,6 @@ module GitCommon end def file_content - logger.info("#################{@repo_path}, #{@path}") @content = git_fle_content @repo_path, @path end diff --git a/app/controllers/concerns/git_helper.rb b/app/controllers/concerns/git_helper.rb index 78eae769c..8d769a244 100644 --- a/app/controllers/concerns/git_helper.rb +++ b/app/controllers/concerns/git_helper.rb @@ -9,11 +9,10 @@ module GitHelper # 版本库文件内容,带转码 def git_fle_content(repo_path, path) begin - logger.info("##########repo_path: #{repo_path}") - logger.info("##########path: #{path}") + logger.info("git file content: repo_path is #{repo_path}, path is #{path}") content = GitService.file_content(repo_path: repo_path, path: path) - logger.info("@@@@@@@@@@@@@@@@@@#{content}") + logger.info("git file content: content is #{content}") decode_content = nil if content.present? content = content["content"] #6.24 -hs 这个为新增,因为当实训题里含有选择题时,这里会报错,undefined method `[]' for nil:NilClass @@ -34,7 +33,6 @@ module GitHelper rescue Exception => e Rails.logger.error(e.message) - # uid_logger_error(e.message) raise Educoder::TipException.new("文档内容获取异常") end end diff --git a/app/controllers/games_controller.rb b/app/controllers/games_controller.rb index 8c364308f..2a2439226 100644 --- a/app/controllers/games_controller.rb +++ b/app/controllers/games_controller.rb @@ -461,6 +461,7 @@ class GamesController < ApplicationController git_fle_content(@myshixun.shixun.repo_path, path) rescue Exception => e uid_logger_error("#{e.message}") + # 如果已发布的TPM实训也不能获取到内容,那么肯定是版本库异常了 if @myshixun.shixun.try(:status) < 2 tip_exception("代码获取异常,请检查实训模板的评测设置是否正确") else From cd3147dc970a41c91ef569fffe241a8da8dc69bc Mon Sep 17 00:00:00 2001 From: jasder Date: Sat, 29 Jun 2019 15:17:03 +0800 Subject: [PATCH 127/256] FIX bug --- app/controllers/files_controller.rb | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/app/controllers/files_controller.rb b/app/controllers/files_controller.rb index c303c7e78..c8fd042ea 100644 --- a/app/controllers/files_controller.rb +++ b/app/controllers/files_controller.rb @@ -16,12 +16,17 @@ class FilesController < ApplicationController sort = params[:sort] || 0 # 0: 降序;1: 升序 sort_type = params[:sort_type] || 'created_on' # created_on:时间排序, downloads:下载次数排序; quotes: 引用次数排序 course_second_category_id = params[:course_second_category_id] || 0 # 0: 为主目录, 其他为次目录id - @user = current_user || nil + @user = current_user @attachments = @course.attachments.by_course_second_category_id(course_second_category_id) .includes(attachment_group_settings: :course_group, author: [:user_extension, :course_members]) .ordered(sort: sort.to_i, sort_type: sort_type.strip) + get_category(@course, course_second_category_id) + @total_count = @attachments.size + @public_count = @attachments.publiced.size + @private_count = @total_count - @public_count + @attachments = @attachments.by_keywords(params[:search]) @attachments = case @user.course_identity(@course) when 5 @@ -32,12 +37,6 @@ class FilesController < ApplicationController @attachments end - @total_count = @attachments.size - @public_count = @attachments.publiced.size - @private_count = @total_count - @public_count - - @attachments = @attachments.by_keywords(params[:search]) - @attachments = @attachments.page(@page).per(@page_size) end From 069571bec2ad5de05dca27ac29a7a8c539007582 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Sat, 29 Jun 2019 15:17:46 +0800 Subject: [PATCH 128/256] =?UTF-8?q?=E4=BB=A3=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/controllers/challenges_controller.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/challenges_controller.rb b/app/controllers/challenges_controller.rb index afe0e14b6..41ba59be8 100644 --- a/app/controllers/challenges_controller.rb +++ b/app/controllers/challenges_controller.rb @@ -160,8 +160,8 @@ class ChallengesController < ApplicationController def show @tab = params[:tab].nil? ? 1 : params[:tab].to_i - challenge_num = Challenge.where(shixun_id: @shixun).count - @power = current_user.manager_of_shixun?(@shixun) && @shixun.status == 0 + challenge_num = @shixun.challenges_count + @power = @shixun.status == 0 # 之前验证走过了是不是管理员,因此这里只用判断是否发布 @position = @challenge.position if @position < challenge_num @next_challenge = Challenge.where(:shixun_id => @shixun, :position => @position + 1).first From 6cf53047c35635351ec2f495cc3262b1858d044e Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Sat, 29 Jun 2019 15:25:24 +0800 Subject: [PATCH 129/256] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/challenges_controller.rb | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/app/controllers/challenges_controller.rb b/app/controllers/challenges_controller.rb index 41ba59be8..d56c3ecbd 100644 --- a/app/controllers/challenges_controller.rb +++ b/app/controllers/challenges_controller.rb @@ -138,7 +138,7 @@ class ChallengesController < ApplicationController # tab 0,nil 过关任务, 1 评测设置, 2 参考答案 def edit @tab = params[:tab].to_i - @power = current_user.manager_of_shixun?(@shixun) && @shixun.status == 0 + @power = @shixun.status == 0 challenge_num = Challenge.where(:shixun_id => @shixun).count @position = @challenge.position @chooses = @challenge.challenge_chooses @@ -279,9 +279,6 @@ class ChallengesController < ApplicationController def find_shixun @shixun = Shixun.find_by_identifier(params[:shixun_identifier]) - if !current_user.shixun_permission(@shixun) - tip_exception(403, "..") - end end # 通用接口 From 3c1710eefc7218f1ad82d4c2e3f75c4b8eb15a06 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Sat, 29 Jun 2019 15:36:03 +0800 Subject: [PATCH 130/256] fix bug --- app/controllers/exercises_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/exercises_controller.rb b/app/controllers/exercises_controller.rb index 421c5177a..2fcd7275b 100644 --- a/app/controllers/exercises_controller.rb +++ b/app/controllers/exercises_controller.rb @@ -1418,7 +1418,7 @@ class ExercisesController < ApplicationController :best_counts => best_counts, } - @exercise_questions = @exercise.exercise_questions + @exercise_questions = @exercise.exercise_questions&.includes(:exercise_choices,:exercise_answers,:exercise_standard_answers,:exercise_shixun_challenges,:exercise_shixun_answers) @paging_type = "percent" # 按题型排序 From 133eaf42cb390f68070119668b92e3719d9fe20f Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Sat, 29 Jun 2019 15:53:04 +0800 Subject: [PATCH 131/256] =?UTF-8?q?=E9=97=AE=E5=8D=B7/=E8=AF=95=E5=8D=B7?= =?UTF-8?q?=E7=9A=84=E5=88=97=E8=A1=A8=E9=A1=B5=EF=BC=8C=E9=A2=84=E8=A7=88?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2=E5=8F=8A=E7=BB=9F=E8=AE=A1=E7=BB=93=E6=9E=9C?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2=E7=9A=84=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/exercises_controller.rb | 4 ++-- app/controllers/polls_controller.rb | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/controllers/exercises_controller.rb b/app/controllers/exercises_controller.rb index 2fcd7275b..8b65d7c70 100644 --- a/app/controllers/exercises_controller.rb +++ b/app/controllers/exercises_controller.rb @@ -101,7 +101,7 @@ class ExercisesController < ApplicationController @page = params[:page] || 1 @limit = params[:limit] || 15 @exercises = @exercises.page(@page).per(@limit) - @exercises = @exercises.includes(:exercise_users,:exercise_questions,:exercise_group_settings) + @exercises = @exercises&.includes(:exercise_users,:exercise_questions,:exercise_group_settings) else @exercises = [] end @@ -188,7 +188,7 @@ class ExercisesController < ApplicationController else @is_teacher_or = 0 #为学生 end - @exercise_questions = @exercise.exercise_questions.order("question_number ASC") + @exercise_questions = @exercise.exercise_questions&.includes(:exercise_choices,:exercise_shixun_challenges,:exercise_standard_answers).order("question_number ASC") rescue Exception => e uid_logger_error(e.message) tip_exception("试卷创建失败!") diff --git a/app/controllers/polls_controller.rb b/app/controllers/polls_controller.rb index 6fbba1c3d..cd9679972 100644 --- a/app/controllers/polls_controller.rb +++ b/app/controllers/polls_controller.rb @@ -90,7 +90,7 @@ class PollsController < ApplicationController @limit = params[:limit] || 15 @polls = @polls.page(@page).per(@limit) - @polls = @polls.includes(:poll_users,:poll_questions,:poll_group_settings) + @polls = @polls&.includes(:poll_users,:poll_questions,:poll_group_settings) else @polls = [] @@ -183,7 +183,7 @@ class PollsController < ApplicationController else @is_teacher_or = 0 end - @poll_questions = @poll.poll_questions.order("question_number ASC") + @poll_questions = @poll.poll_questions&.includes(:poll_answers).order("question_number ASC") rescue Exception => e uid_logger_error(e.message) tip_exception("没有权限") @@ -1148,7 +1148,7 @@ class PollsController < ApplicationController end def get_questions_count - @poll_questions = @poll.poll_questions.order("question_number ASC") + @poll_questions = @poll.poll_questions&.includes(:poll_answers,:poll_votes).order("question_number ASC") @poll_questions_count = @poll_questions.count # 全部的题目数 @poll_question_singles = @poll_questions.ques_count(1).all.count # 单选题 @poll_question_doubles = @poll_questions.ques_count(2).all.count # 多选题 From 783e2e1727cd0e29dc529c9eaf78df33dfe3602d Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Sat, 29 Jun 2019 16:23:37 +0800 Subject: [PATCH 132/256] fix bug --- app/helpers/polls_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/helpers/polls_helper.rb b/app/helpers/polls_helper.rb index b5ba79dcc..d9b6ccee7 100644 --- a/app/helpers/polls_helper.rb +++ b/app/helpers/polls_helper.rb @@ -110,7 +110,7 @@ module PollsHelper poll_user_name = user.nickname end course_member = course_members.find_by(user_id:user.id) - course_group_id = course_members.present? ? course_member.course_group_id : nil + course_group_id = course_member.present? ? course_member.course_group_id : nil if course_group_id == 0 course_group_name = "未分班" else From ad9e7a58f70e584f7254f5049643e546779969e4 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Sat, 29 Jun 2019 17:21:38 +0800 Subject: [PATCH 133/256] =?UTF-8?q?=E5=88=A0=E9=99=A4=E5=A4=9A=E4=BD=99?= =?UTF-8?q?=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/games_controller.rb | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/app/controllers/games_controller.rb b/app/controllers/games_controller.rb index 2a2439226..76e15f9e2 100644 --- a/app/controllers/games_controller.rb +++ b/app/controllers/games_controller.rb @@ -426,12 +426,12 @@ class GamesController < ApplicationController game_code = GameCode.where(:game_id => @game.try(:id), :path => path).first if game_code.present? content = game_code.try(:new_code) - @content = if @myshixun.mirror_name.select{|a| a.include?("MachineLearning") || a.include?("Python")}.present? && content.present? - content.gsub(/\t/, ' ') - else - content - end - update_file_content(@content, @myshixun.repo_path, path, current_user.mail, current_user.full_name, "game passed reset") + # @content = if @myshixun.mirror_name.select{|a| a.include?("MachineLearning") || a.include?("Python")}.present? && content.present? + # content.gsub(/\t/, ' ') + # else + # content + # end + update_file_content(content, @myshixun.repo_path, path, current_user.mail, current_user.full_name, "game passed reset") else tip_exception("代码重置失败,代码为空") end From 07e7f0d206b7058438b06bb6f94c80a41c483961 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Sat, 29 Jun 2019 17:23:40 +0800 Subject: [PATCH 134/256] fix bug --- app/controllers/zips_controller.rb | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/app/controllers/zips_controller.rb b/app/controllers/zips_controller.rb index a8750fc3d..710846f64 100644 --- a/app/controllers/zips_controller.rb +++ b/app/controllers/zips_controller.rb @@ -52,15 +52,16 @@ class ZipsController < ApplicationController @ex_users = default_ex_users #仅导出已提交的,截止后则是全部为提交的。 #可以分班选择 if group_id.present? - exercise_students = @course.students.course_find_by_ids("course_group_id",group_id) # 试卷所分班的全部人数 - user_ids = exercise_students.pluck(:user_id).reject(&:blank?) - @ex_users = @ex_users.exercise_commit_users(user_ids) + exercise_students = @course.students.where(course_group_id: group_id) # 试卷所分班的全部人数 + user_ids = exercise_students.pluck(:user_id).reject(&:blank?).uniq + logger.info("+++++++##################_________________user_ids_____________#########{user_ids}") + @ex_users = @ex_users.where(user_id: user_ids) end # @ex_users = @ex_users.first(200) if default_ex_users_size == 0 normal_status(-1,"导出失败,暂时没有已提交的学生") - elsif default_ex_users_size > 200 - normal_status(-1,"导出数量超过200,请分班导出或联系网站管理员导出") + elsif default_ex_users_size > 100 + normal_status(-1,"导出数量超过100,请分班导出或联系网站管理员导出") end end rescue Exception => e From c6e1fd3f8d0cb2ffd2078582e1eb00a19f1af684 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Sat, 29 Jun 2019 17:26:36 +0800 Subject: [PATCH 135/256] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E8=AF=95=E5=8D=B7?= =?UTF-8?q?=E7=9A=84=E7=AD=94=E9=A2=98=E8=AF=95=E5=8D=B7=E5=AF=BC=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/zips_controller.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/controllers/zips_controller.rb b/app/controllers/zips_controller.rb index 710846f64..4de85ec64 100644 --- a/app/controllers/zips_controller.rb +++ b/app/controllers/zips_controller.rb @@ -48,16 +48,16 @@ class ZipsController < ApplicationController @course = @exercise.course default_ex_users = @exercise.all_exercise_users(current_user.id).exercise_user_committed - default_ex_users_size = default_ex_users.size @ex_users = default_ex_users #仅导出已提交的,截止后则是全部为提交的。 #可以分班选择 if group_id.present? exercise_students = @course.students.where(course_group_id: group_id) # 试卷所分班的全部人数 user_ids = exercise_students.pluck(:user_id).reject(&:blank?).uniq - logger.info("+++++++##################_________________user_ids_____________#########{user_ids}") @ex_users = @ex_users.where(user_id: user_ids) end - # @ex_users = @ex_users.first(200) + + default_ex_users_size = @ex_users.size + if default_ex_users_size == 0 normal_status(-1,"导出失败,暂时没有已提交的学生") elsif default_ex_users_size > 100 From 15668d41986e7851c9d29ac2719ad4cb986995aa Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Sat, 29 Jun 2019 17:49:18 +0800 Subject: [PATCH 136/256] fix bug --- app/templates/exercise_export/exercise_user.html.erb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/templates/exercise_export/exercise_user.html.erb b/app/templates/exercise_export/exercise_user.html.erb index c81f45d68..0c1c1bbab 100644 --- a/app/templates/exercise_export/exercise_user.html.erb +++ b/app/templates/exercise_export/exercise_user.html.erb @@ -9,6 +9,7 @@

+
<%= request.url %>

<%= @exercise.try(:exercise_name) %>

From 9ce0af33704eb849e2f5006f7aef686e7d3f973a Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Sat, 29 Jun 2019 18:06:25 +0800 Subject: [PATCH 137/256] fix bug --- app/controllers/zips_controller.rb | 4 +++- app/services/exercise_user_pdf_service.rb | 3 ++- app/services/export_exercises_service.rb | 5 +++-- app/templates/exercise_export/exercise_user.html.erb | 11 ++++++----- 4 files changed, 14 insertions(+), 9 deletions(-) diff --git a/app/controllers/zips_controller.rb b/app/controllers/zips_controller.rb index 4de85ec64..c1ff95abd 100644 --- a/app/controllers/zips_controller.rb +++ b/app/controllers/zips_controller.rb @@ -17,7 +17,7 @@ class ZipsController < ApplicationController end def export_exercises - exercises = ExportExercisesService.new(@exercise,@ex_users) + exercises = ExportExercisesService.new(@exercise,@ex_users,@request_url) file_name = filename_for_content_disposition(exercises.filename) send_file exercises.ex_zip, filename: file_name, type: 'application/zip' @@ -41,6 +41,8 @@ class ZipsController < ApplicationController ActiveRecord::Base.transaction do begin @exercise = Exercise.includes(:exercise_users,:exercise_questions).find_by(id:params[:exercise_id]) + @request_url = request.base_url + logger.info("######################____________@request_url____________##########################{@request_url}") group_id = params[:exercise_group_id] if @exercise.blank? normal_status(-1,"试卷不存在") diff --git a/app/services/exercise_user_pdf_service.rb b/app/services/exercise_user_pdf_service.rb index 22804092e..913d0cfbc 100644 --- a/app/services/exercise_user_pdf_service.rb +++ b/app/services/exercise_user_pdf_service.rb @@ -5,9 +5,10 @@ class ExerciseUserPdfService attr_reader :exercise, :ex_user - def initialize(exercise, ex_user) + def initialize(exercise, ex_user,request_url) @exercise = exercise @ex_user = ex_user + @request_url = request_url @ex_user_user = @ex_user.user @course = @exercise.course end diff --git a/app/services/export_exercises_service.rb b/app/services/export_exercises_service.rb index 12b5501f9..48bfc9519 100644 --- a/app/services/export_exercises_service.rb +++ b/app/services/export_exercises_service.rb @@ -3,9 +3,10 @@ class ExportExercisesService include StudentWorksHelper attr_reader :exercise, :ex_users - def initialize(exercise, ex_users) + def initialize(exercise, ex_users,request_url) @exercise = exercise @ex_users = ex_users + @request_url = request_url end def filename @@ -18,7 +19,7 @@ class ExportExercisesService pdfs = [] Zip::File.open(zip_file.path, Zip::File::CREATE) do |zip| ex_users.each do |ex_user| - export = ExerciseUserPdfService.new(exercise, ex_user) + export = ExerciseUserPdfService.new(exercise, ex_user,@request_url) pdf = export.ex_pdf pdfs << pdf begin diff --git a/app/templates/exercise_export/exercise_user.html.erb b/app/templates/exercise_export/exercise_user.html.erb index 0c1c1bbab..269237520 100644 --- a/app/templates/exercise_export/exercise_user.html.erb +++ b/app/templates/exercise_export/exercise_user.html.erb @@ -168,15 +168,16 @@ <% end %>
+ <% q_title = q.question_title&.gsub("src='","src='/#{@request_url}") %> + <% if q_type == 5 %> - <%= q.shixun_name&.html_safe %> + <% q_name = q.shixun_name&.gsub("src='","src='/#{@request_url}") %> + <%= q_name&.html_safe %>
- <%= q.question_title&.html_safe %> + <%= q_title&.html_safe %>
- <% elsif q_type == 4 %> - <%= q.question_title&.html_safe %> <% else %> - <%= q.question_title&.html_safe %> + <%= q_title&.html_safe %> <% end %>
From 7dd8189f17368b01d1e9647512364692a5b6259a Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Sat, 29 Jun 2019 18:08:03 +0800 Subject: [PATCH 138/256] fix bug --- app/templates/exercise_export/exercise_user.html.erb | 1 - 1 file changed, 1 deletion(-) diff --git a/app/templates/exercise_export/exercise_user.html.erb b/app/templates/exercise_export/exercise_user.html.erb index 269237520..df9c4c6ab 100644 --- a/app/templates/exercise_export/exercise_user.html.erb +++ b/app/templates/exercise_export/exercise_user.html.erb @@ -9,7 +9,6 @@
-
<%= request.url %>

<%= @exercise.try(:exercise_name) %>

From 51dc8ae124d3e5eca4921d5f0134782de39bb94e Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Sat, 29 Jun 2019 19:31:45 +0800 Subject: [PATCH 139/256] =?UTF-8?q?=E5=AF=BC=E5=87=BApdf=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E6=A0=87=E9=A2=98=E5=9B=BE=E7=89=87=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/exercises_controller.rb | 1 + app/controllers/zips_controller.rb | 5 ++--- app/services/exercise_user_pdf_service.rb | 4 ++-- app/templates/exercise_export/blank_exercise.html.erb | 8 +++++--- app/templates/exercise_export/exercise_user.html.erb | 5 ++--- 5 files changed, 12 insertions(+), 11 deletions(-) diff --git a/app/controllers/exercises_controller.rb b/app/controllers/exercises_controller.rb index 8b65d7c70..2377f411b 100644 --- a/app/controllers/exercises_controller.rb +++ b/app/controllers/exercises_controller.rb @@ -1334,6 +1334,7 @@ class ExercisesController < ApplicationController #导出空白试卷 def export_exercise @exercise_questions = @exercise.exercise_questions.includes(:exercise_choices).order("question_number ASC") + @request_url = request.base_url filename = "#{current_user.real_name}_#{@course.name}_#{@exercise.exercise_name}_#{Time.current.strftime('%Y%m%d%H%M%S')}.pdf" stylesheets = "#{Rails.root}/app/templates/exercise_export/exercise_export.css" render pdf: 'exercise_export/blank_exercise', filename: filename, stylesheets: stylesheets diff --git a/app/controllers/zips_controller.rb b/app/controllers/zips_controller.rb index c1ff95abd..b23a3e033 100644 --- a/app/controllers/zips_controller.rb +++ b/app/controllers/zips_controller.rb @@ -42,7 +42,6 @@ class ZipsController < ApplicationController begin @exercise = Exercise.includes(:exercise_users,:exercise_questions).find_by(id:params[:exercise_id]) @request_url = request.base_url - logger.info("######################____________@request_url____________##########################{@request_url}") group_id = params[:exercise_group_id] if @exercise.blank? normal_status(-1,"试卷不存在") @@ -50,12 +49,12 @@ class ZipsController < ApplicationController @course = @exercise.course default_ex_users = @exercise.all_exercise_users(current_user.id).exercise_user_committed - @ex_users = default_ex_users #仅导出已提交的,截止后则是全部为提交的。 + @ex_users = default_ex_users.limit 1 #仅导出已提交的,截止后则是全部为提交的。 #可以分班选择 if group_id.present? exercise_students = @course.students.where(course_group_id: group_id) # 试卷所分班的全部人数 user_ids = exercise_students.pluck(:user_id).reject(&:blank?).uniq - @ex_users = @ex_users.where(user_id: user_ids) + @ex_users = @ex_users.where(user_id: user_ids).limit 1 end default_ex_users_size = @ex_users.size diff --git a/app/services/exercise_user_pdf_service.rb b/app/services/exercise_user_pdf_service.rb index 913d0cfbc..9b96cd70c 100644 --- a/app/services/exercise_user_pdf_service.rb +++ b/app/services/exercise_user_pdf_service.rb @@ -38,10 +38,10 @@ class ExerciseUserPdfService kit = PDFKit.new(html) base_css = %w(app/templates/exercise_export/exercise_export.css) base_css.each { |css| kit.stylesheets << Rails.root.join(css) } - #-----正式需删掉 + # #-----正式需删掉 # aa = File.open(Rails.root.join("public/123.html"),"w+") # aa.syswrite(kit.source) - #正式需删掉------- + # #正式需删掉------- file = Tempfile.new(filename) kit.to_pdf(file.path) file diff --git a/app/templates/exercise_export/blank_exercise.html.erb b/app/templates/exercise_export/blank_exercise.html.erb index 2745f8cbe..95a92358f 100644 --- a/app/templates/exercise_export/blank_exercise.html.erb +++ b/app/templates/exercise_export/blank_exercise.html.erb @@ -68,13 +68,15 @@ (<%= q&.question_score %>分)
+ <% q_title = q.question_title&.include?("src=\"") ? q.question_title&.gsub("src=\"","src=\"#{@request_url}") : q.question_title %> <% if q.question_type == 5 %> - <%= q.shixun_name.present? ? q.shixun_name&.html_safe : "" %> + <% q_name = q.shixun_name&.include?("src=\"") ? q.shixun_name&.gsub("src=\"","src=\"#{@request_url}") : q.shixun_name %> + <%= q_name&.html_safe %>
- <%= q.question_title.present? ? q.question_title&.html_safe : "" %> + <%= q_title&.html_safe %>
<% else %> - <%= q.question_title.present? ? q.question_title&.html_safe : "" %> + <%= q_title&.html_safe %> <% end %>
diff --git a/app/templates/exercise_export/exercise_user.html.erb b/app/templates/exercise_export/exercise_user.html.erb index df9c4c6ab..42758af77 100644 --- a/app/templates/exercise_export/exercise_user.html.erb +++ b/app/templates/exercise_export/exercise_user.html.erb @@ -167,10 +167,9 @@ <% end %>
- <% q_title = q.question_title&.gsub("src='","src='/#{@request_url}") %> - + <% q_title = q.question_title&.include?("src=\"") ? q.question_title&.gsub("src=\"","src=\"#{@request_url}") : q.question_title %> <% if q_type == 5 %> - <% q_name = q.shixun_name&.gsub("src='","src='/#{@request_url}") %> + <% q_name = q.shixun_name&.include?("src=\"") ? q.shixun_name&.gsub("src=\"","src=\"#{@request_url}") : q.shixun_name %> <%= q_name&.html_safe %>
<%= q_title&.html_safe %> From fba4bf318488bcd1df5eeea72e55048062625e91 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Sat, 29 Jun 2019 19:33:33 +0800 Subject: [PATCH 140/256] fix bug --- app/controllers/zips_controller.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/zips_controller.rb b/app/controllers/zips_controller.rb index b23a3e033..77a41d065 100644 --- a/app/controllers/zips_controller.rb +++ b/app/controllers/zips_controller.rb @@ -49,12 +49,12 @@ class ZipsController < ApplicationController @course = @exercise.course default_ex_users = @exercise.all_exercise_users(current_user.id).exercise_user_committed - @ex_users = default_ex_users.limit 1 #仅导出已提交的,截止后则是全部为提交的。 + @ex_users = default_ex_users #仅导出已提交的,截止后则是全部为提交的。 #可以分班选择 if group_id.present? exercise_students = @course.students.where(course_group_id: group_id) # 试卷所分班的全部人数 user_ids = exercise_students.pluck(:user_id).reject(&:blank?).uniq - @ex_users = @ex_users.where(user_id: user_ids).limit 1 + @ex_users = @ex_users.where(user_id: user_ids) end default_ex_users_size = @ex_users.size From e3dbe6c5734fe337a48fe6df350b5704bbf38e98 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Mon, 1 Jul 2019 09:11:08 +0800 Subject: [PATCH 141/256] fix bug --- app/templates/exercise_export/blank_exercise.html.erb | 10 +++++----- app/templates/exercise_export/exercise_user.html.erb | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/app/templates/exercise_export/blank_exercise.html.erb b/app/templates/exercise_export/blank_exercise.html.erb index 95a92358f..74cea75f1 100644 --- a/app/templates/exercise_export/blank_exercise.html.erb +++ b/app/templates/exercise_export/blank_exercise.html.erb @@ -68,15 +68,15 @@ (<%= q&.question_score %>分)
- <% q_title = q.question_title&.include?("src=\"") ? q.question_title&.gsub("src=\"","src=\"#{@request_url}") : q.question_title %> + <% q_title = q.question_title&.html_safe %> <% if q.question_type == 5 %> - <% q_name = q.shixun_name&.include?("src=\"") ? q.shixun_name&.gsub("src=\"","src=\"#{@request_url}") : q.shixun_name %> - <%= q_name&.html_safe %> + <% q_name = q.shixun_name&.html_safe %> + <%= q_name&.include?("src=\"") ? q_name&.gsub("src=\"","src=\"#{@request_url}") : q_name %>
- <%= q_title&.html_safe %> + <%= q_title&.include?("src=\"") ? q_title&.gsub("src=\"","src=\"#{@request_url}") : q_title %>
<% else %> - <%= q_title&.html_safe %> + <%= q_title&.include?("src=\"") ? q_title&.gsub("src=\"","src=\"#{@request_url}") : q_title %> <% end %>
diff --git a/app/templates/exercise_export/exercise_user.html.erb b/app/templates/exercise_export/exercise_user.html.erb index 42758af77..5770c5921 100644 --- a/app/templates/exercise_export/exercise_user.html.erb +++ b/app/templates/exercise_export/exercise_user.html.erb @@ -167,15 +167,15 @@ <% end %>
- <% q_title = q.question_title&.include?("src=\"") ? q.question_title&.gsub("src=\"","src=\"#{@request_url}") : q.question_title %> + <% q_title = q.question_title&.html_safe %> <% if q_type == 5 %> - <% q_name = q.shixun_name&.include?("src=\"") ? q.shixun_name&.gsub("src=\"","src=\"#{@request_url}") : q.shixun_name %> - <%= q_name&.html_safe %> + <% q_name = q.shixun_name&.html_safe %> + <%= q_name&.include?("src=\"") ? q_name&.gsub("src=\"","src=\"#{@request_url}") : q_name %>
- <%= q_title&.html_safe %> + <%= q_title&.include?("src=\"") ? q_title&.gsub("src=\"","src=\"#{@request_url}") : q_title %>
<% else %> - <%= q_title&.html_safe %> + <%= q_title&.include?("src=\"") ? q_title&.gsub("src=\"","src=\"#{@request_url}") : q_title %> <% end %>
From 04bbbc7319175eb83c609454d226d54dd7358535 Mon Sep 17 00:00:00 2001 From: jingquan huang Date: Mon, 1 Jul 2019 09:49:48 +0800 Subject: [PATCH 142/256] =?UTF-8?q?challenges=20=E6=97=A0=E6=B3=95?= =?UTF-8?q?=E6=98=BE=E7=A4=BA=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/challenges_controller.rb | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/app/controllers/challenges_controller.rb b/app/controllers/challenges_controller.rb index afe0e14b6..bad438fdf 100644 --- a/app/controllers/challenges_controller.rb +++ b/app/controllers/challenges_controller.rb @@ -150,9 +150,8 @@ class ChallengesController < ApplicationController def index uid_logger("identifier: #{params}") - # 通过调试发现 这里includes(:games)性能会慢10倍 - current_myshixun = @shixun.current_myshixun(current_user.id) - @challenges = @shixun.challenges.includes(:games).where("games.user_id" => (current_myshixun ? current_user.id : nil)) + + @challenges = Challenge.fields_for_list.where(shixun_id: @shixun.id) @editable = current_user.manager_of_shixun?(@shixun) && @shixun.status == 0 @user = current_user From b29d4063a87c1fcbc09c7c46bfcc8c2639b3cdcd Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Mon, 1 Jul 2019 09:53:58 +0800 Subject: [PATCH 143/256] fix bug --- .../exercise_export/blank_exercise.html.erb | 26 ++++++++++++++----- 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/app/templates/exercise_export/blank_exercise.html.erb b/app/templates/exercise_export/blank_exercise.html.erb index 74cea75f1..995d04995 100644 --- a/app/templates/exercise_export/blank_exercise.html.erb +++ b/app/templates/exercise_export/blank_exercise.html.erb @@ -57,7 +57,7 @@
- <% @exercise_questions.each do |q| %> + <% @exercise_questions.each_with_index do |q,index| %>
@@ -68,15 +68,27 @@ (<%= q&.question_score %>分)
- <% q_title = q.question_title&.html_safe %> + <% q_title = q.question_title&.include?("src=\"") ? q.question_title&.gsub("src=\"","src=\"#{@request_url}")&.html_safe : q.question_title&.html_safe %> <% if q.question_type == 5 %> - <% q_name = q.shixun_name&.html_safe %> - <%= q_name&.include?("src=\"") ? q_name&.gsub("src=\"","src=\"#{@request_url}") : q_name %> + <% q_name = q.shixun_name&.include?("src=\"") ? q.shixun_name&.gsub("src=\"","src=\"#{@request_url}")&.html_safe : q.shixun_name&.html_safe %> + <%= q_name %>
- <%= q_title&.include?("src=\"") ? q_title&.gsub("src=\"","src=\"#{@request_url}") : q_title %> + <%= q_title %>
+ <% else %> - <%= q_title&.include?("src=\"") ? q_title&.gsub("src=\"","src=\"#{@request_url}") : q_title %> + <%= q_title %> + <% end %>
@@ -134,4 +146,6 @@
+<%= ApplicationController.helpers.pdf_load_sources(*%w(react/public/js/jquery-1.8.3.min.js react/public/js/editormd/marked.min.js))%> + \ No newline at end of file From 93d18fac5dbba3bd15d925dcc958c42b681b06dd Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Mon, 1 Jul 2019 10:12:26 +0800 Subject: [PATCH 144/256] fix bug --- Gemfile | 2 ++ Gemfile.lock | 2 ++ app/helpers/application_helper.rb | 12 +++++++++++ .../exercise_export/blank_exercise.html.erb | 21 +++++-------------- 4 files changed, 21 insertions(+), 16 deletions(-) diff --git a/Gemfile b/Gemfile index 31af87f14..b8b174a6f 100644 --- a/Gemfile +++ b/Gemfile @@ -39,6 +39,8 @@ gem 'pdfkit' gem 'wkhtmltopdf-binary' #gem 'iconv' +# markdown 转html +gem 'redcarpet', '~> 3.4' gem 'rqrcode', '~> 0.10.1' gem 'rqrcode_png' diff --git a/Gemfile.lock b/Gemfile.lock index 83bd79628..86f524bc2 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -193,6 +193,7 @@ GEM rb-inotify (0.9.10) ffi (>= 0.5.0, < 2) rchardet (1.8.0) + redcarpet (3.4.0) redis (4.1.0) redis-actionpack (5.0.2) actionpack (>= 4.0, < 6) @@ -328,6 +329,7 @@ DEPENDENCIES rails (~> 5.2.0) rails-i18n (~> 5.1) rchardet (~> 1.8) + redcarpet (~> 3.4) redis-rails roo-xls rqrcode (~> 0.10.1) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index d8ea8cd60..8d92362cc 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -334,6 +334,18 @@ module ApplicationHelper raw arr.join('') end + def to_markdown(text) + nil if text.blank? + html_render_options = { + fenced_code_blocks: true, + tables: true, + autolink: true + } + + markdown = Redcarpet::Markdown.new(html_render_options) + raw markdown.render(h(text)).html_safe + end + end diff --git a/app/templates/exercise_export/blank_exercise.html.erb b/app/templates/exercise_export/blank_exercise.html.erb index 995d04995..bdb86d9d9 100644 --- a/app/templates/exercise_export/blank_exercise.html.erb +++ b/app/templates/exercise_export/blank_exercise.html.erb @@ -57,7 +57,7 @@
- <% @exercise_questions.each_with_index do |q,index| %> + <% @exercise_questions.each do |q| %>
@@ -68,27 +68,17 @@ (<%= q&.question_score %>分)
- <% q_title = q.question_title&.include?("src=\"") ? q.question_title&.gsub("src=\"","src=\"#{@request_url}")&.html_safe : q.question_title&.html_safe %> + <% q_markdown = to_markdown(q.question_title) %> + <% q_title = q_markdown&.include?("src=\"") ? q_markdown&.gsub("src=\"","src=\"#{@request_url}")&.html_safe : q_markdown %> <% if q.question_type == 5 %> - <% q_name = q.shixun_name&.include?("src=\"") ? q.shixun_name&.gsub("src=\"","src=\"#{@request_url}")&.html_safe : q.shixun_name&.html_safe %> + <% q_markdown_name = to_markdown(q.shixun_name) %> + <% q_name = q_markdown_name&.include?("src=\"") ? q_markdown_name&.gsub("src=\"","src=\"#{@request_url}")&.html_safe : q_markdown_name %> <%= q_name %>
<%= q_title %>
- <% else %> <%= q_title %> - <% end %>
@@ -146,6 +136,5 @@
-<%= ApplicationController.helpers.pdf_load_sources(*%w(react/public/js/jquery-1.8.3.min.js react/public/js/editormd/marked.min.js))%> \ No newline at end of file From 4f21bcb3bb479f43b08ba755dbcd3e5e947a2255 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Mon, 1 Jul 2019 10:17:09 +0800 Subject: [PATCH 145/256] fix bug --- app/helpers/application_helper.rb | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 8d92362cc..34848fd51 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -335,15 +335,19 @@ module ApplicationHelper end def to_markdown(text) - nil if text.blank? - html_render_options = { - fenced_code_blocks: true, - tables: true, - autolink: true + return nil if text.blank? + options = { + :autolink => true, + :no_intra_emphasis => true, + :fenced_code_blocks => true, + :lax_html_blocks => true, + :strikethrough => true, + :superscript => true, + :tables => true } - markdown = Redcarpet::Markdown.new(html_render_options) - raw markdown.render(h(text)).html_safe + markdown = Redcarpet::Markdown.new(options) + markdown.render(h(text)).html_safe end end From 5bfd514211a3ab67621230684ef04c3990373bb4 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Mon, 1 Jul 2019 10:22:03 +0800 Subject: [PATCH 146/256] fix bug --- app/helpers/application_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 34848fd51..acb1089ec 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -346,7 +346,7 @@ module ApplicationHelper :tables => true } - markdown = Redcarpet::Markdown.new(options) + markdown = Redcarpet::Markdown.new(Redcarpet::Render::HTML,options) markdown.render(h(text)).html_safe end From a6ea8d139a1c9861701d28bfbfa498f76e46d3f9 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Mon, 1 Jul 2019 10:23:02 +0800 Subject: [PATCH 147/256] fix bug --- app/helpers/application_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index acb1089ec..055731168 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -347,7 +347,7 @@ module ApplicationHelper } markdown = Redcarpet::Markdown.new(Redcarpet::Render::HTML,options) - markdown.render(h(text)).html_safe + markdown.render(text).html_safe end end From 1044209d4f995b3c6bee369b183986d53e9f1160 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Mon, 1 Jul 2019 10:25:14 +0800 Subject: [PATCH 148/256] =?UTF-8?q?=E5=AE=9E=E8=AE=AD=E6=9C=8D=E5=8A=A1?= =?UTF-8?q?=E5=99=A8=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/application_controller.rb | 18 ++++++++++++++++++ app/controllers/challenges_controller.rb | 4 ++-- app/controllers/games_controller.rb | 6 +++--- app/controllers/myshixuns_controller.rb | 2 +- app/controllers/shixuns_controller.rb | 16 ++++++++++++++++ app/models/challenge.rb | 2 +- app/models/shixun.rb | 2 ++ app/models/shixun_service_config.rb | 4 ++++ app/views/challenges/edit.json.jbuilder | 2 +- spec/models/shixun_service_config_spec.rb | 5 +++++ 10 files changed, 53 insertions(+), 8 deletions(-) create mode 100644 app/models/shixun_service_config.rb create mode 100644 spec/models/shixun_service_config_spec.rb diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index afe2129a9..cbd2962b6 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -427,6 +427,24 @@ class ApplicationController < ActionController::Base container.to_json end + # 实训中间层pod配置 + def shixun_container_limit shixun + container = [] + shixun.shixun_service_configs.each do |config| + mirror = config.mirror_repository + if mirror.name.present? + container << {:image => mirror.name, + :cpuLimit => config.cpu_limit, + :cpuRequest => config.lower_cpu_limit, + :memoryLimit => "#{config.memory_limit}M", + :memoryRequest => "#{config.request_limit}M", + :resourceLimit => "#{config.resource_limit}K", + :type => mirror.try(:main_type) == "1" ? "main" : "sub"} + end + end + container.to_json + end + # 毕设任务列表的赛选 def course_work(task, **option) logger.info("#############{option}") diff --git a/app/controllers/challenges_controller.rb b/app/controllers/challenges_controller.rb index d56c3ecbd..856afeb01 100644 --- a/app/controllers/challenges_controller.rb +++ b/app/controllers/challenges_controller.rb @@ -154,7 +154,7 @@ class ChallengesController < ApplicationController current_myshixun = @shixun.current_myshixun(current_user.id) @challenges = @shixun.challenges.includes(:games).where("games.user_id" => (current_myshixun ? current_user.id : nil)) - @editable = current_user.manager_of_shixun?(@shixun) && @shixun.status == 0 + @editable = @shixun.status == 0 # before_action:有判断权限,如果没发布,则肯定是管理人员 @user = current_user end @@ -290,7 +290,7 @@ class ChallengesController < ApplicationController def challenge_params params.require(:challenge).permit(:subject, :task_pass, :difficulty, :score, :st, :modify_time, :test_set_average, :path, :exec_path, :show_type, :original_picture_path, :test_set_score, - :expect_picture_path, :picture_path, :web_route, :answer) + :expect_picture_path, :picture_path, :web_route, :answer, :exec_time) end def chooce_params diff --git a/app/controllers/games_controller.rb b/app/controllers/games_controller.rb index 76e15f9e2..7e7b6e082 100644 --- a/app/controllers/games_controller.rb +++ b/app/controllers/games_controller.rb @@ -33,7 +33,7 @@ class GamesController < ApplicationController is_teacher = @user.is_teacher? # 实训超时设置 - time_limit = @shixun.exec_time + time_limit = game_challenge.exec_time # 上一关、下一关 prev_game = @game.prev_of_current_game(@shixun.id, @game.myshixun_id, game_challenge.position) @@ -66,7 +66,7 @@ class GamesController < ApplicationController shixun_tomcat = edu_setting('cloud_bridge') service_host = edu_setting('vnc_url') uri = "#{shixun_tomcat}/bridge/vnc/getvnc" - params = {tpiID: @myshixun.id, :containers => "#{Base64.urlsafe_encode64(container_limit(@shixun.mirror_repositories))}"} + params = {tpiID: @myshixun.id, :containers => "#{Base64.urlsafe_encode64(shixun_container_limit(@shixun))}"} res = uri_post uri, params if res && res['code'].to_i != 0 raise("实训云平台繁忙(繁忙等级:99)") @@ -547,7 +547,7 @@ class GamesController < ApplicationController br_params = {:tpiID => "#{@myshixun.id}", :tpiGitURL => "#{gitUrl}", :buildID => "#{@game.id}", :instanceChallenge => "#{step}", :testCases => "#{testCases}", :resubmit => "#{resubmit}", :times => params[:first].to_i, :podType => @shixun.webssh, :content_modified => content_modified, - :containers => "#{Base64.urlsafe_encode64(container_limit(@shixun.mirror_repositories))}", + :containers => "#{Base64.urlsafe_encode64(shixun_container_limit(@shixun))}", :persistenceName => @shixun.identifier, :tpmScript => "#{tpmScript}", :timeLimit => "#{@shixun.exec_time}", :isPublished => (@shixun.status < 2 ? 0 : 1) } diff --git a/app/controllers/myshixuns_controller.rb b/app/controllers/myshixuns_controller.rb index a4a3b7222..909533301 100644 --- a/app/controllers/myshixuns_controller.rb +++ b/app/controllers/myshixuns_controller.rb @@ -217,7 +217,7 @@ class MyshixunsController < ApplicationController shixun_tomcat = edu_setting('tomcat_webssh') uri = "#{shixun_tomcat}/bridge/webssh/getConnectInfo" params = {tpiID:@myshixun.id, podType:@myshixun.shixun.try(:webssh), - containers:(Base64.urlsafe_encode64(container_limit @myshixun.shixun.mirror_repositories))} + containers:(Base64.urlsafe_encode64(shixun_container_limit @myshixun.shixun))} res = uri_post uri, params if res && res['code'].to_i != 0 tip_exception("实训云平台繁忙(繁忙等级:92)") diff --git a/app/controllers/shixuns_controller.rb b/app/controllers/shixuns_controller.rb index b3069bc5d..f079aed1e 100644 --- a/app/controllers/shixuns_controller.rb +++ b/app/controllers/shixuns_controller.rb @@ -315,9 +315,13 @@ class ShixunsController < ApplicationController # 镜像-实训关联表 ShixunMirrorRepository.create!(:shixun_id => @shixun.id, :mirror_repository_id => main_type.to_i) if main_type.present? + # 实训主镜像服务配置 + ShixunServiceConfig.create!(:shixun_id => @shixun.id, :mirror_repository_id => main_type.to_i) if sub_type.present? sub_type.each do |mirror| ShixunMirrorRepository.create!(:shixun_id => @shixun.id, :mirror_repository_id => mirror) + # 实训子镜像服务配置 + ShixunServiceConfig.create!(:shixun_id => @shixun.id, :mirror_repository_id => mirror) end end @@ -395,6 +399,18 @@ class ShixunsController < ApplicationController use_scope = 0 end @shixun.update_attributes!(:use_scope => use_scope) + # 超级管理员和运营人员才能保存 中间层服务器pod信息的配置 + if current_user.admin? || current_user.business? + @shixun.shixun_service_configs.destroy_all + params[:mirror_id].each_with_index do |mirror_id, index| + ShixunServiceConfig.create!(:shixun_id => @shixun.id, + :cpu_limit => params[:cpu_limit][index], + :lower_cpu_limit => params[:lower_cpu_limit][index], + :memory_limit => params[:memory_limit][index], + :request_limit => params[:request_limit][index], + :mirror_repository_id => mirror_id) + end + end rescue Exception => e uid_logger_error(e.message) tip_exception("实训保存失败") diff --git a/app/models/challenge.rb b/app/models/challenge.rb index 07a49196d..18b177e1c 100644 --- a/app/models/challenge.rb +++ b/app/models/challenge.rb @@ -20,7 +20,7 @@ class Challenge < ApplicationRecord # acts_as_attachable scope :base_attrs, -> { select([:id, :subject, :position, :shixun_id, :st, :score, :path, :task_pass, :modify_time, - :web_route, :answer]) } + :web_route, :answer, :exec_time]) } scope :choose_type, -> { where(st: 1) } scope :practice_type, -> { where(st: 0) } diff --git a/app/models/shixun.rb b/app/models/shixun.rb index 556a4400f..18d5c5fae 100644 --- a/app/models/shixun.rb +++ b/app/models/shixun.rb @@ -30,6 +30,8 @@ class Shixun < ApplicationRecord has_one :shixun_info, dependent: :destroy belongs_to :user + # 实训服务配置 + has_many :shixun_service_configs, :dependent => :destroy scope :search_by_name, ->(keyword) { where("name like ? or description like ? ", diff --git a/app/models/shixun_service_config.rb b/app/models/shixun_service_config.rb new file mode 100644 index 000000000..6d106fc07 --- /dev/null +++ b/app/models/shixun_service_config.rb @@ -0,0 +1,4 @@ +class ShixunServiceConfig < ApplicationRecord + belongs_to :shixun + belongs_to :mirror_repository +end diff --git a/app/views/challenges/edit.json.jbuilder b/app/views/challenges/edit.json.jbuilder index 64848a4e6..2774b5a05 100644 --- a/app/views/challenges/edit.json.jbuilder +++ b/app/views/challenges/edit.json.jbuilder @@ -7,7 +7,7 @@ json.chooses do end if @tab == 0 # 本关任务tab的编辑模式 - json.(@challenge, :id, :subject, :task_pass, :difficulty, :score) + json.(@challenge, :id, :subject, :task_pass, :difficulty, :score, :exec_time) json.tags @challenge.challenge_tags.map(&:name) elsif @tab == 1 # 评测设置的编辑模式 diff --git a/spec/models/shixun_service_config_spec.rb b/spec/models/shixun_service_config_spec.rb new file mode 100644 index 000000000..d79cd19f7 --- /dev/null +++ b/spec/models/shixun_service_config_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe ShixunServiceConfig, type: :model do + pending "add some examples to (or delete) #{__FILE__}" +end From 3533f2e7b6204fc033dacd9c3106648e52b9200e Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Mon, 1 Jul 2019 10:30:19 +0800 Subject: [PATCH 149/256] =?UTF-8?q?=E5=AE=9E=E8=AE=AD=E4=BD=9C=E4=B8=9A?= =?UTF-8?q?=E7=9A=84=E8=AE=A1=E7=AE=97=E6=88=90=E7=BB=A9=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../homework_commons_controller.rb | 119 ++++++------------ app/services/homeworks_service.rb | 63 ++++++++++ .../_homework_public_navigation.json.jbuilder | 1 + .../homework_commons/works_list.json.jbuilder | 7 +- config/routes.rb | 2 + ...013243_add_calculation_time_to_homework.rb | 6 + 6 files changed, 115 insertions(+), 83 deletions(-) create mode 100644 db/migrate/20190701013243_add_calculation_time_to_homework.rb diff --git a/app/controllers/homework_commons_controller.rb b/app/controllers/homework_commons_controller.rb index 2a1dfb14a..8ce99cb79 100644 --- a/app/controllers/homework_commons_controller.rb +++ b/app/controllers/homework_commons_controller.rb @@ -186,6 +186,7 @@ class HomeworkCommonsController < ApplicationController @work_count = @student_works.size @work_excel = @student_works + @students = @course.students # 分页参数 page = params[:page] || 1 @@ -236,94 +237,51 @@ class HomeworkCommonsController < ApplicationController end def update_score - student_works = @homework.student_works - myshixuns = Myshixun.where(shixun_id: @homework.homework_commons_shixun&.shixun_id, user_id: @course.students.pluck(:user_id)) - myshixuns = Myshixun.where(shixun_id: @homework.homework_commons_shixun&.shixun_id). - joins("join course_members on myshixuns.user_id=course_members.user_id").where(course_members: {course_id: @course.id, role: 4}).includes(:games) - myshixuns.find_each(batch_size: 100) do |myshixun| - work = student_works.select{|work| work.user_id == myshixun.user_id}.first - setting_time = @homework.homework_group_setting work.user_id - - if setting_time.end_time.present? && (setting_time.end_time > Time.now || (@homework.allow_late && @homework.late_time && @homework.late_time > Time.now)) - #logger.info("#############setting_time: #{setting_time.end_time}") - - user_total_score = 0 - pass_consume_time = 0 - final_score = 0 - homework.homework_challenge_settings.each do |setting| - game = myshixun.games.where(:challenge_id => setting.challenge_id, :status => 2).first - unless game.nil? - pass_consume_time += (game.cost_time / 60.0).to_f - user_total_score += game.final_score.to_i < 0 ? 0 : game.challenge.score.to_i - adjust_score = work.challenge_work_scores.where(:challenge_id => setting.challenge_id).last - final_score += adjust_score.present? ? adjust_score.score : (homework.homework_detail_manual.answer_open_evaluation ? setting.score : (game.final_score > 0 ? game.real_score(setting.score) : 0)) - end - end - if work.work_status == 0 - is_complete = myshixun.is_complete? && (myshixun.done_time < setting_time.end_time) - work.work_status = setting_time.end_time > Time.now ? 1 : (is_complete ? 1 : 2) - work.late_penalty = setting_time.end_time > Time.now ? 0 : (is_complete ? 0 : homework.late_penalty) - work.commit_time = myshixun.created_at > setting_time.publish_time ? setting_time.publish_time : myshixun.created_at - work.myshixun_id = myshixun.id - end - - games = myshixun.games.where(:challenge_id => homework.homework_challenge_settings.map(&:challenge_id)) - myshixun_endtime = games.select{|game| game.status == 2}.size == games.size ? games.map(&:end_time).max : nil - if myshixun_endtime.present? - min_efficiency_changed = min_efficiency_changed.present? ? min_efficiency_changed : false - work.compelete_status = 1 - work.cost_time = myshixun_endtime.to_i - setting_time.publish_time.to_i - - efficiency = (pass_consume_time == 0 ? 0 : Math.log((user_total_score / pass_consume_time.to_f) + 1.0)) - work.efficiency = format("%.2f", efficiency) + begin + if @homework.unified_setting + student_works = @homework.student_works + user_ids = @course.students.pluck(:user_id) + else + user_ids = @course.students.where(course_group_id: @homework.published_settings.pluck(:course_group_id)).pluck(:user_id) + student_works = @homework.student_works.where(user_id: user_ids) + end - # 如果作业的最大效率值有变更则更新所有作品的效率分 - if homework.work_efficiency && homework.max_efficiency < work.efficiency - homework.update_column("max_efficiency", work.efficiency) - end + myshixuns = Myshixun.where(shixun_id: params[:shixun_id], user_id: user_ids). + includes(:games).where(games: {challenge_id: @homework.homework_challenge_settings.pluck(:challenge_id)}) + challenge_settings = @homework.homework_challenge_settings + myshixuns.find_each(batch_size: 100) do |myshixun| + work = student_works.select{|work| work.user_id == myshixun.user_id}.first + if work && myshixun && (work.update_time.nil? || work.update_time < myshixun.updated_at) + games = myshixun.games.where(challenge_id: challenge_settings.pluck(:challenge_id)) + HomeworksService.new.update_myshixun_work_score work, myshixun, games, @homework, challenge_settings end - - work.update_time = Time.now - - work.final_score = final_score - score = work.final_score + work.eff_score - work.late_penalty - work.work_score = format("%.2f",(score < 0 ? 0 : score).to_f) unless work.ultimate_score - #logger.info("#############work_score: #{score}") - work.save! end - end - @homework.student_works.each do || - + @homework.update_attribute('calculation_time', Time.now) + normal_status("更新成功") + rescue Exception => e + uid_logger(e.message) + tip_exception(e.message) + raise ActiveRecord::Rollback end end def update_student_score - work = @homework.students_works.find_by(user_id: current_user.id) + work = @homework.student_works.find_by(user_id: current_user.id) myshixun = Myshixun.find_by(shixun_id: params[:shixun_id], user_id: current_user.id) - if work && myshixun - # 判断作品是否关联过myshixun - if work.myshixun_id.nil? - work.myshixun_id = myshixun.id - work.update_time = myshixun.updated_at - setting_time = @homework.homework_group_setting myshixun.user_id - games = myshixun.games.where(:challenge_id => @homework.homework_challenge_settings.pluck(:challenge_id)) - myshixun_endtime = games.select{|game| game.status == 2}.size == games.size ? games.map(&:end_time).max : nil - compelete_status = 0 - if myshixun_endtime.present? && myshixun_endtime < setting_time.end_time - if myshixun_endtime < setting_time.publish_time - compelete_status = 2 - else - compelete_status = 1 - end - end - games.each do |game| - unless game.nil? - pass_consume_time += (game.cost_time / 60.0).to_f - user_total_score += game.final_score.to_i < 0 ? 0 : game.challenge.score.to_i - adjust_score = work.challenge_work_scores.where(:challenge_id => setting.challenge_id).last - final_score += adjust_score.present? ? adjust_score.score : (homework.homework_detail_manual.answer_open_evaluation ? setting.score : (game.final_score > 0 ? game.real_score(setting.score) : 0)) - end + ActiveRecord::Base.transaction do + begin + if work && myshixun && (work.update_time.nil? || work.update_time < myshixun.updated_at) + challenge_settings = @homework.homework_challenge_settings + games = myshixun.games.where(challenge_id: challenge_settings.pluck(:challenge_id)) + HomeworksService.new.update_myshixun_work_score work, myshixun, games, @homework, challenge_settings + normal_status("更新成功") + else + normal_status("已是最新成绩") end + rescue Exception => e + uid_logger(e.message) + tip_exception(e.message) + raise ActiveRecord::Rollback end end end @@ -1036,7 +994,7 @@ class HomeworkCommonsController < ApplicationController if homework.course_acts.size == 0 homework.course_acts << CourseActivity.new(user_id: homework.user_id, course_id: homework.course_id) end - + # 发消息 HomeworkCommonPushNotifyJob.perform_later(homework.id, tiding_group_ids) else create_homework_group_settings(homework) @@ -1057,6 +1015,7 @@ class HomeworkCommonsController < ApplicationController homework.save! + # 更新学生状态及成绩 HomeworkPublishUpdateWorkStatusJob.perform_later(tiding_group_ids, homework.id) end normal_status(0, "发布成功") diff --git a/app/services/homeworks_service.rb b/app/services/homeworks_service.rb index 1e155dde0..48db76295 100644 --- a/app/services/homeworks_service.rb +++ b/app/services/homeworks_service.rb @@ -272,4 +272,67 @@ class HomeworksService end end end + + # 计算实训作品成绩 + def update_myshixun_work_score work, myshixun, games, homework, challenge_settings + user_total_score = 0 + pass_consume_time = 0 + final_score = 0 + setting_time = homework.homework_group_setting myshixun.user_id + homework_end_or_late_time = homework.allow_late ? homework.late_time : setting_time.end_time + games.each do |game| + # 在截止时间前通关的关卡才考虑得分 + if game.status == 2 && game.end_time <= homework_end_or_late_time + challenge_setting = challenge_settings.select{|setting| setting.challenge_id == game.challenge_id}.first + pass_consume_time += (game.cost_time / 60.0).to_f + user_total_score += game.final_score.to_i < 0 ? 0 : game.challenge.score.to_i + adjust_score = work.challenge_work_scores.where(:challenge_id => game.challenge_id).last + final_score += if adjust_score.present? + adjust_score.score + elsif homework.homework_detail_manual.answer_open_evaluation + challenge_setting.score + elsif game.final_score > 0 + game.real_score(challenge_setting.score) + else + 0 + end + end + end + + myshixun_endtime = games.select{|game| game.status == 2}.size == games.size ? games.map(&:end_time).max : nil + if myshixun_endtime.present? + work.cost_time = myshixun_endtime.to_i - setting_time.publish_time.to_i + + efficiency = (pass_consume_time == 0 ? 0 : Math.log((user_total_score / pass_consume_time.to_f) + 1.0)) + work.efficiency = format("%.2f", efficiency) + + if myshixun_endtime <= homework_end_or_late_time + work.compelete_status = myshixun_endtime < setting_time.publish_time ? 2 : 1 + + # 如果作业的最大效率值有变更则更新所有作品的效率分 + homework.update_column("max_efficiency", work.efficiency) if homework.work_efficiency && homework.max_efficiency < work.efficiency + end + end + + if work.work_status == 0 + is_complete = myshixun_endtime && (myshixun_endtime < setting_time.end_time) + if is_complete || (!homework.allow_late && myshixun.created_at < setting_time.end_time) + work.work_status = 1 + elsif homework.allow_late && myshixun.created_at < homework.late_time + work.work_status = 2 + end + work.late_penalty = work.work_status == 2 ? homework.late_penalty : 0 + work.commit_time = myshixun.created_at > setting_time.publish_time ? setting_time.publish_time : myshixun.created_at + work.myshixun_id = myshixun.id + end + + work.update_time = myshixun.updated_at + + work.final_score = final_score + score = work.final_score + work.eff_score - work.late_penalty + work.work_score = format("%.2f",(score < 0 ? 0 : score).to_f) unless work.ultimate_score + #logger.info("#############work_score: #{score}") + work.calculation_time = Time.now + work.save! + end end \ No newline at end of file diff --git a/app/views/homework_commons/_homework_public_navigation.json.jbuilder b/app/views/homework_commons/_homework_public_navigation.json.jbuilder index 2c548074c..243c6aecd 100644 --- a/app/views/homework_commons/_homework_public_navigation.json.jbuilder +++ b/app/views/homework_commons/_homework_public_navigation.json.jbuilder @@ -11,4 +11,5 @@ json.homework_id homework.id json.homework_type homework.homework_type if homework.homework_type == "practice" json.shixun_identifier homework.shixuns.take.try(:identifier) + json.shixun_id homework.shixuns.take.try(:id) end diff --git a/app/views/homework_commons/works_list.json.jbuilder b/app/views/homework_commons/works_list.json.jbuilder index 60441909b..f740959d0 100644 --- a/app/views/homework_commons/works_list.json.jbuilder +++ b/app/views/homework_commons/works_list.json.jbuilder @@ -13,6 +13,7 @@ json.ta_mode @homework_detail_manual.ta_mode json.is_evaluation @is_evaluation ? @is_evaluation : false json.work_public @homework.work_public +json.calculation_time @homework.calculation_time if @homework.homework_type == "practice" if @user_course_identity < Course::STUDENT @@ -30,7 +31,7 @@ elsif @user_course_identity == Course::STUDENT if @homework.homework_type == "practice" json.(@work, :id, :work_status, :update_time, :ultimate_score) - + json.calculation_time @work.calculation_time json.late_penalty @work.late_penalty if @homework.allow_late json.cost_time @work.myshixun.try(:total_cost_time) json.work_score work_score_format(@work.work_score, true, @score_open) @@ -94,7 +95,7 @@ if @homework.homework_type == "practice" json.user_login work.user.try(:login) json.user_name work.user.try(:real_name) json.student_id work.user.try(:student_id) - json.group_name @course.course_student(work.user_id).try(:course_group_name) + json.group_name @students.select{|student| student.user_id == work.user_id}.first.try(:course_group_name) end elsif @homework.homework_type == "group" || @homework.homework_type == "normal" json.anonymous_comment @homework.anonymous_comment @@ -133,7 +134,7 @@ elsif @homework.homework_type == "group" || @homework.homework_type == "normal" end json.student_id work.user.try(:student_id) - json.group_name @course.course_student(work.user_id).try(:course_group_name) + json.group_name @students.select{|student| student.user_id == work.user_id}.first.try(:course_group_name) if @homework.homework_type == "group" if @homework.homework_detail_group.base_on_project json.project_info project_info work, @current_user, @user_course_identity diff --git a/config/routes.rb b/config/routes.rb index f81d90267..0f47cda76 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -338,6 +338,8 @@ Rails.application.routes.draw do get :publish_groups get :end_groups post :alter_name + get :update_score + get :update_student_score end collection do diff --git a/db/migrate/20190701013243_add_calculation_time_to_homework.rb b/db/migrate/20190701013243_add_calculation_time_to_homework.rb new file mode 100644 index 000000000..4a622ee92 --- /dev/null +++ b/db/migrate/20190701013243_add_calculation_time_to_homework.rb @@ -0,0 +1,6 @@ +class AddCalculationTimeToHomework < ActiveRecord::Migration[5.2] + def change + add_column :homework_commons, :calculation_time, :datetime + add_column :student_works, :calculation_time, :datetime + end +end From 9c7523a8527679f1711f63ebb4de3d9b4da29e4c Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Mon, 1 Jul 2019 10:31:00 +0800 Subject: [PATCH 150/256] fix bug --- app/helpers/application_helper.rb | 3 +-- app/templates/exercise_export/blank_exercise.html.erb | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 055731168..f77e9a313 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -345,9 +345,8 @@ module ApplicationHelper :superscript => true, :tables => true } - markdown = Redcarpet::Markdown.new(Redcarpet::Render::HTML,options) - markdown.render(text).html_safe + markdown.render(text) end end diff --git a/app/templates/exercise_export/blank_exercise.html.erb b/app/templates/exercise_export/blank_exercise.html.erb index bdb86d9d9..63b7fb8bc 100644 --- a/app/templates/exercise_export/blank_exercise.html.erb +++ b/app/templates/exercise_export/blank_exercise.html.erb @@ -75,10 +75,10 @@ <% q_name = q_markdown_name&.include?("src=\"") ? q_markdown_name&.gsub("src=\"","src=\"#{@request_url}")&.html_safe : q_markdown_name %> <%= q_name %>
- <%= q_title %> + <%= q_markdown %>
<% else %> - <%= q_title %> + <%= q_markdown %> <% end %>
From 5db1bbd18a8fcd73d28c414a044fc77533582ca2 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Mon, 1 Jul 2019 10:33:57 +0800 Subject: [PATCH 151/256] fix bug --- app/helpers/application_helper.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index f77e9a313..cb2f487cb 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -335,6 +335,7 @@ module ApplicationHelper end def to_markdown(text) + Rails.logger.info("#########################text______________tedxt_________________###{text}") return nil if text.blank? options = { :autolink => true, @@ -346,7 +347,10 @@ module ApplicationHelper :tables => true } markdown = Redcarpet::Markdown.new(Redcarpet::Render::HTML,options) - markdown.render(text) + ss = markdown.render(text) + Rails.logger.info("#########################text______________markdown.render(text)________________###{ss}") + ss + end end From 53b0f2efcd8b6810278ffe8d5ccb1558b3a299ec Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Mon, 1 Jul 2019 10:37:05 +0800 Subject: [PATCH 152/256] =?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/works_list.json.jbuilder | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/homework_commons/works_list.json.jbuilder b/app/views/homework_commons/works_list.json.jbuilder index f740959d0..a7dc292b8 100644 --- a/app/views/homework_commons/works_list.json.jbuilder +++ b/app/views/homework_commons/works_list.json.jbuilder @@ -13,10 +13,10 @@ json.ta_mode @homework_detail_manual.ta_mode json.is_evaluation @is_evaluation ? @is_evaluation : false json.work_public @homework.work_public -json.calculation_time @homework.calculation_time if @homework.homework_type == "practice" if @user_course_identity < Course::STUDENT + json.calculation_time @homework.calculation_time if @homework.homework_type == "practice" # 教师身份的评阅、提交状态、分班过滤 if @homework.homework_type != "practice" json.teacher_comment teacher_comment @homework, @current_user.id From 6110df20bd10d12b72ad2c125c6377b12cb0f810 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Mon, 1 Jul 2019 10:38:47 +0800 Subject: [PATCH 153/256] fix bug --- app/helpers/application_helper.rb | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index cb2f487cb..df024264e 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -336,6 +336,8 @@ module ApplicationHelper def to_markdown(text) Rails.logger.info("#########################text______________tedxt_________________###{text}") + Rails.logger.info("#########################text______________request_base_url________________###{request.base_url}") + return nil if text.blank? options = { :autolink => true, @@ -347,10 +349,10 @@ module ApplicationHelper :tables => true } markdown = Redcarpet::Markdown.new(Redcarpet::Render::HTML,options) - ss = markdown.render(text) - Rails.logger.info("#########################text______________markdown.render(text)________________###{ss}") - ss - + m_t = markdown.render(text) + q_title = m_t &.include?("src=\"") ? m_t&.gsub("src=\"","src=\"#{@request_url}")&.html_safe : m_t + Rails.logger.info("#########################text______________markdown.render(text)________________###{q_title }") + q_title end end From b320715e6e9ff22b45cf5e742337b309a2f02ea7 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Mon, 1 Jul 2019 10:45:45 +0800 Subject: [PATCH 154/256] fix bug --- app/helpers/application_helper.rb | 9 ++++----- .../exercise_export/blank_exercise.html.erb | 14 ++++++-------- 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index df024264e..67e899820 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -335,8 +335,7 @@ module ApplicationHelper end def to_markdown(text) - Rails.logger.info("#########################text______________tedxt_________________###{text}") - Rails.logger.info("#########################text______________request_base_url________________###{request.base_url}") + request_url = request.base_url return nil if text.blank? options = { @@ -350,9 +349,9 @@ module ApplicationHelper } markdown = Redcarpet::Markdown.new(Redcarpet::Render::HTML,options) m_t = markdown.render(text) - q_title = m_t &.include?("src=\"") ? m_t&.gsub("src=\"","src=\"#{@request_url}")&.html_safe : m_t - Rails.logger.info("#########################text______________markdown.render(text)________________###{q_title }") - q_title + ss = m_t&.include?("src=\"") ? m_t&.gsub("src=\"","src=\"#{request_url}")&.html_safe : m_t + Rails.logger.info("############_____________ss________________##################{ss}") + ss end end diff --git a/app/templates/exercise_export/blank_exercise.html.erb b/app/templates/exercise_export/blank_exercise.html.erb index 63b7fb8bc..d562224da 100644 --- a/app/templates/exercise_export/blank_exercise.html.erb +++ b/app/templates/exercise_export/blank_exercise.html.erb @@ -69,16 +69,14 @@
<% q_markdown = to_markdown(q.question_title) %> - <% q_title = q_markdown&.include?("src=\"") ? q_markdown&.gsub("src=\"","src=\"#{@request_url}")&.html_safe : q_markdown %> <% if q.question_type == 5 %> <% q_markdown_name = to_markdown(q.shixun_name) %> - <% q_name = q_markdown_name&.include?("src=\"") ? q_markdown_name&.gsub("src=\"","src=\"#{@request_url}")&.html_safe : q_markdown_name %> - <%= q_name %> + <%= q_markdown_name %>
- <%= q_markdown %> + <%= q_markdown %>
<% else %> - <%= q_markdown %> + <%= q_markdown %> <% end %>
@@ -86,14 +84,14 @@ <% q.exercise_choices.each_with_index do |s,index| %>

- <%= convert_to_char((index+1).to_s)%><%= s.choice_text%> + <%= convert_to_char((index+1).to_s)%><%= to_markdown(s.choice_text) %>

<% end %> <% elsif q.question_type == 1 %> <% q.exercise_choices.each_with_index do |s,index| %>

- <%= convert_to_char((index+1).to_s)%><%= s.choice_text%> + <%= convert_to_char((index+1).to_s)%><%= to_markdown(s.choice_text) %>

<% end %> <% elsif q.question_type == 2 %> @@ -101,7 +99,7 @@ <% q.exercise_choices.each_with_index do |s,index| %> - <%= s.choice_text %> + <%= to_markdown(s.choice_text) %> <% end %>

From fec939b098c167812f7b7f7bd55c11e13cf92115 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Mon, 1 Jul 2019 10:58:26 +0800 Subject: [PATCH 155/256] fix bug --- app/helpers/application_helper.rb | 2 +- app/templates/exercise_export/blank_exercise.html.erb | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 67e899820..fd5a8b233 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -349,7 +349,7 @@ module ApplicationHelper } markdown = Redcarpet::Markdown.new(Redcarpet::Render::HTML,options) m_t = markdown.render(text) - ss = m_t&.include?("src=\"") ? m_t&.gsub("src=\"","src=\"#{request_url}")&.html_safe : m_t + ss = m_t&.include?("src=\"") ? m_t&.gsub("src=\"","src=\"#{request_url}") : m_t Rails.logger.info("############_____________ss________________##################{ss}") ss end diff --git a/app/templates/exercise_export/blank_exercise.html.erb b/app/templates/exercise_export/blank_exercise.html.erb index d562224da..b43dc1923 100644 --- a/app/templates/exercise_export/blank_exercise.html.erb +++ b/app/templates/exercise_export/blank_exercise.html.erb @@ -68,6 +68,7 @@ (<%= q&.question_score %>分)
+ 电脑的电路图 <% q_markdown = to_markdown(q.question_title) %> <% if q.question_type == 5 %> <% q_markdown_name = to_markdown(q.shixun_name) %> @@ -84,14 +85,14 @@ <% q.exercise_choices.each_with_index do |s,index| %>

- <%= convert_to_char((index+1).to_s)%><%= to_markdown(s.choice_text) %> + <%= convert_to_char((index+1).to_s)%><%= to_markdown(s.choice_text) %>

<% end %> <% elsif q.question_type == 1 %> <% q.exercise_choices.each_with_index do |s,index| %>

- <%= convert_to_char((index+1).to_s)%><%= to_markdown(s.choice_text) %> + <%= convert_to_char((index+1).to_s)%><%= to_markdown(s.choice_text) %>

<% end %> <% elsif q.question_type == 2 %> @@ -99,7 +100,7 @@ <% q.exercise_choices.each_with_index do |s,index| %> - <%= to_markdown(s.choice_text) %> + <%= to_markdown(s.choice_text) %> <% end %>

From decedbe354ac222e9a90a9e3884cc3e6971b19ad Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Mon, 1 Jul 2019 11:28:42 +0800 Subject: [PATCH 156/256] fix bug --- app/templates/exercise_export/blank_exercise.html.erb | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/app/templates/exercise_export/blank_exercise.html.erb b/app/templates/exercise_export/blank_exercise.html.erb index b43dc1923..9ee1d40f7 100644 --- a/app/templates/exercise_export/blank_exercise.html.erb +++ b/app/templates/exercise_export/blank_exercise.html.erb @@ -69,6 +69,7 @@
电脑的电路图 + udasker_picture <% q_markdown = to_markdown(q.question_title) %> <% if q.question_type == 5 %> <% q_markdown_name = to_markdown(q.shixun_name) %> @@ -85,14 +86,16 @@ <% q.exercise_choices.each_with_index do |s,index| %>

- <%= convert_to_char((index+1).to_s)%><%= to_markdown(s.choice_text) %> + <%= convert_to_char((index+1).to_s)%> + <%= to_markdown(s.choice_text) %>

<% end %> <% elsif q.question_type == 1 %> <% q.exercise_choices.each_with_index do |s,index| %>

- <%= convert_to_char((index+1).to_s)%><%= to_markdown(s.choice_text) %> + <%= convert_to_char((index+1).to_s)%> + <%= to_markdown(s.choice_text) %>

<% end %> <% elsif q.question_type == 2 %> From 4d2943973fc156ee5c51352e72b3b2222e3c2252 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Mon, 1 Jul 2019 11:31:17 +0800 Subject: [PATCH 157/256] =?UTF-8?q?=E5=AE=9E=E8=AE=AD=E6=9C=8D=E5=8A=A1?= =?UTF-8?q?=E5=99=A8=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/shixuns_controller.rb | 27 +++++++++++------------- app/models/shixun.rb | 2 ++ app/views/shixuns/settings.json.jbuilder | 8 +++++++ 3 files changed, 22 insertions(+), 15 deletions(-) diff --git a/app/controllers/shixuns_controller.rb b/app/controllers/shixuns_controller.rb index f079aed1e..5631d03a7 100644 --- a/app/controllers/shixuns_controller.rb +++ b/app/controllers/shixuns_controller.rb @@ -367,11 +367,6 @@ class ShixunsController < ApplicationController end def update - h = {test_set_permission: params[:test_set_permission], code_hidden: params[:code_hidden], - task_pass: params[:task_pass], hide_code: params[:hide_code], forbid_copy: params[:forbid_copy]} - - s_params = shixun_params.merge(h) - ActiveRecord::Base.transaction do begin @shixun.shixun_mirror_repositories.destroy_all @@ -384,8 +379,8 @@ class ShixunsController < ApplicationController end end - @shixun.update_attributes(s_params) - @shixun.shixun_info.update_attributes(description: params[:description], evaluate_script: params[:evaluate_script]) + @shixun.update_attributes(shixun_params) + @shixun.shixun_info.update_attributes(shixun_info_params) @shixun.shixun_schools.delete_all if params[:scope_partment].present? && params[:user_scope].to_i == 1 arr = [] @@ -402,13 +397,8 @@ class ShixunsController < ApplicationController # 超级管理员和运营人员才能保存 中间层服务器pod信息的配置 if current_user.admin? || current_user.business? @shixun.shixun_service_configs.destroy_all - params[:mirror_id].each_with_index do |mirror_id, index| - ShixunServiceConfig.create!(:shixun_id => @shixun.id, - :cpu_limit => params[:cpu_limit][index], - :lower_cpu_limit => params[:lower_cpu_limit][index], - :memory_limit => params[:memory_limit][index], - :request_limit => params[:request_limit][index], - :mirror_repository_id => mirror_id) + params[:shixun_service_configs].each do |config| + @shixun.shixun_service_configs.create!(config) end end rescue Exception => e @@ -446,6 +436,7 @@ class ShixunsController < ApplicationController @choice_small_type = @shixun.small_mirror_id @main_type = shixun_main_type @small_type = shixun_small_type + @configs = @shixun.shixun_service_configs #@mirror_script = MirrorScript.select([:id, :script_type]).find(@shixun.mirror_script_id).attributes if @shixun.mirror_script_id && @shixun.mirror_script_id != 0 # @shixun_main_mirror = @shixun.show_shixun_mirror # @script_type = @shixun.script_tag.try(:script_type) || "无" @@ -734,7 +725,13 @@ private def shixun_params raise("实训名称不能为空") if params[:name].blank? params.require(:shixun).permit(:name, :trainee, :webssh, :can_copy, :use_scope, :vnc, :test_set_permission, - :task_pass, :repo_name, :multi_webssh, :opening_time, :mirror_script_id) + :task_pass, :repo_name, :multi_webssh, :opening_time, :mirror_script_id, :code_hidden, + :hide_code, :forbid_copy) + end + def shixun_info_params + raise("实训描述不能为空") if params[:description].blank? + raise("评测脚本不能为空") if params[:evaluate_script].blank? + params.require(:shixun_info).permit(:description, :evaluate_script) end def find_shixun diff --git a/app/models/shixun.rb b/app/models/shixun.rb index 18d5c5fae..c4345f90a 100644 --- a/app/models/shixun.rb +++ b/app/models/shixun.rb @@ -1,5 +1,7 @@ class Shixun < ApplicationRecord # status: 0:编辑 1:申请发布 2:正式发布 3:关闭 -1:软删除 + # hide_code: 隐藏代码窗口 + # code_hidden: 隐藏代码目录 has_many :challenges, dependent: :destroy has_many :myshixuns, :dependent => :destroy has_many :shixun_members, dependent: :destroy diff --git a/app/views/shixuns/settings.json.jbuilder b/app/views/shixuns/settings.json.jbuilder index e97331388..ed7d93039 100644 --- a/app/views/shixuns/settings.json.jbuilder +++ b/app/views/shixuns/settings.json.jbuilder @@ -29,6 +29,14 @@ json.shixun do json.scope_partment @shixun.schools.map(&:name) # 公开范围 json.opening_time @shixun.opening_time json.forbid_copy @shixun.forbid_copy + + # 实训服务配置 + json.shixun_service_configs do + json.array! @configs do |config| + json.name config.mirror_repository&.name + json.(config, :cpu_limit, :lower_cpu_limit, :memory_limit, :request_limit, :mirror_repository_id) + end + end end From 029aac355491a4ee5a44823ea0cc55875719dab4 Mon Sep 17 00:00:00 2001 From: jasder Date: Mon, 1 Jul 2019 11:35:27 +0800 Subject: [PATCH 158/256] FIX delete message permission --- app/controllers/messages_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/messages_controller.rb b/app/controllers/messages_controller.rb index bad54b88e..f684b27f3 100644 --- a/app/controllers/messages_controller.rb +++ b/app/controllers/messages_controller.rb @@ -128,7 +128,7 @@ class MessagesController < ApplicationController def destroy begin - return normal_status(403, "您没有权限进行该操作") unless @message.author == current_user || current_user.teacher_of_course?(@message.board.course) + return normal_status(403, "您没有权限进行该操作") if current_user.course_identity(@message.board.course) >= 5 || @message.author != current_user @message.destroy! rescue Exception => e uid_logger_error(e.message) From 4a257c29603b67ab17d2d59f66b6ba2ce580e172 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Mon, 1 Jul 2019 12:24:00 +0800 Subject: [PATCH 159/256] fix bug --- .../exercise_export/blank_exercise.html.erb | 34 +++++++++---------- 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/app/templates/exercise_export/blank_exercise.html.erb b/app/templates/exercise_export/blank_exercise.html.erb index 9ee1d40f7..f281a55a0 100644 --- a/app/templates/exercise_export/blank_exercise.html.erb +++ b/app/templates/exercise_export/blank_exercise.html.erb @@ -83,30 +83,28 @@
<% if q.question_type == 0 %> - <% q.exercise_choices.each_with_index do |s,index| %> -

- - <%= convert_to_char((index+1).to_s)%> - <%= to_markdown(s.choice_text) %> -

+ <% q.exercise_choices.each do |s| %> +
+ + <%= to_markdown(s.choice_text) %> +
<% end %> <% elsif q.question_type == 1 %> - <% q.exercise_choices.each_with_index do |s,index| %> -

- - <%= convert_to_char((index+1).to_s)%> - <%= to_markdown(s.choice_text) %> -

+ <% q.exercise_choices.each do |s| %> +
+ + <%= to_markdown(s.choice_text) %> +
<% end %> <% elsif q.question_type == 2 %> -

- <% q.exercise_choices.each_with_index do |s,index| %> - - - <%= to_markdown(s.choice_text) %> +

+ <% q.exercise_choices.each do |s| %> + + + <%= to_markdown(s.choice_text) %> <% end %> -

+
<% elsif q.question_type == 3 %> <% st_counts = q.exercise_standard_answers.pluck(:exercise_choice_id).uniq %> <% st_counts.each_with_index do |s,index| %> From 8f3be9a7f6e42c8e3678df80eb6b0f660b748d4c Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Mon, 1 Jul 2019 12:37:13 +0800 Subject: [PATCH 160/256] fix bug --- .../exercise_export/blank_exercise.html.erb | 16 ++++++---------- .../exercise_export/exercise_export.css | 6 ++++++ 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/app/templates/exercise_export/blank_exercise.html.erb b/app/templates/exercise_export/blank_exercise.html.erb index f281a55a0..b253d86b9 100644 --- a/app/templates/exercise_export/blank_exercise.html.erb +++ b/app/templates/exercise_export/blank_exercise.html.erb @@ -68,17 +68,13 @@ (<%= q&.question_score %>分)
- 电脑的电路图 - udasker_picture - <% q_markdown = to_markdown(q.question_title) %> <% if q.question_type == 5 %> - <% q_markdown_name = to_markdown(q.shixun_name) %> - <%= q_markdown_name %> + <%= to_markdown(q.shixun_name) %>
- <%= q_markdown %> + <%= to_markdown(q.question_title) %>
<% else %> - <%= q_markdown %> + <%= to_markdown(q.question_title) %> <% end %>
@@ -86,14 +82,14 @@ <% q.exercise_choices.each do |s| %>
- <%= to_markdown(s.choice_text) %> + <%= to_markdown(s.choice_text) %>
<% end %> <% elsif q.question_type == 1 %> <% q.exercise_choices.each do |s| %>
- <%= to_markdown(s.choice_text) %> + <%= to_markdown(s.choice_text) %>
<% end %> <% elsif q.question_type == 2 %> @@ -101,7 +97,7 @@ <% q.exercise_choices.each do |s| %> - <%= to_markdown(s.choice_text) %> + <%= to_markdown(s.choice_text) %> <% end %>
diff --git a/app/templates/exercise_export/exercise_export.css b/app/templates/exercise_export/exercise_export.css index 9190e9251..bbe523972 100644 --- a/app/templates/exercise_export/exercise_export.css +++ b/app/templates/exercise_export/exercise_export.css @@ -309,6 +309,12 @@ textarea{ clear:both; zoom:1; } +.line-20{ + line-height: 20px; +} +.line-20 P{ + margin-bottom:0; +} From 0922155a1cdd9a603bd59b193506b2537c165896 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Mon, 1 Jul 2019 12:50:01 +0800 Subject: [PATCH 161/256] fix bug --- app/helpers/application_helper.rb | 4 +--- .../exercise_export/blank_exercise.html.erb | 15 +++++++-------- app/templates/exercise_export/exercise_export.css | 4 +++- 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index fd5a8b233..c49e5e775 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -349,9 +349,7 @@ module ApplicationHelper } markdown = Redcarpet::Markdown.new(Redcarpet::Render::HTML,options) m_t = markdown.render(text) - ss = m_t&.include?("src=\"") ? m_t&.gsub("src=\"","src=\"#{request_url}") : m_t - Rails.logger.info("############_____________ss________________##################{ss}") - ss + m_t&.include?("src=\"") ? m_t&.gsub("src=\"","src=\"#{request_url}") : m_t end end diff --git a/app/templates/exercise_export/blank_exercise.html.erb b/app/templates/exercise_export/blank_exercise.html.erb index b253d86b9..5727d0f62 100644 --- a/app/templates/exercise_export/blank_exercise.html.erb +++ b/app/templates/exercise_export/blank_exercise.html.erb @@ -44,7 +44,6 @@ 实训题<%= @exercise_ques_shixun_count %>题, 共<%= @exercise_ques_shixun_scores %> <% end %> - <% if @exercise_ques_count > 0 %> <%= @exercise_ques_scores %>分 @@ -59,7 +58,7 @@
<% @exercise_questions.each do |q| %>
-
+
<%= q.question_number %>、 @@ -80,15 +79,15 @@
<% if q.question_type == 0 %> <% q.exercise_choices.each do |s| %> -
- +
+ <%= to_markdown(s.choice_text) %>
<% end %> <% elsif q.question_type == 1 %> <% q.exercise_choices.each do |s| %> -
- +
+ <%= to_markdown(s.choice_text) %>
<% end %> @@ -96,8 +95,8 @@
<% q.exercise_choices.each do |s| %> - - <%= to_markdown(s.choice_text) %> + + <%= s.choice_text %> <% end %>
diff --git a/app/templates/exercise_export/exercise_export.css b/app/templates/exercise_export/exercise_export.css index bbe523972..140db58ef 100644 --- a/app/templates/exercise_export/exercise_export.css +++ b/app/templates/exercise_export/exercise_export.css @@ -315,6 +315,8 @@ textarea{ .line-20 P{ margin-bottom:0; } - +.v-middle{ + vertical-align: middle; +} From b69d705ed77f4f81f78b32d323a03f05d5ca5aef Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Mon, 1 Jul 2019 12:52:42 +0800 Subject: [PATCH 162/256] Fix bug --- app/templates/exercise_export/blank_exercise.html.erb | 8 ++++---- app/templates/exercise_export/exercise_export.css | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/templates/exercise_export/blank_exercise.html.erb b/app/templates/exercise_export/blank_exercise.html.erb index 5727d0f62..aed7acdcd 100644 --- a/app/templates/exercise_export/blank_exercise.html.erb +++ b/app/templates/exercise_export/blank_exercise.html.erb @@ -80,15 +80,15 @@ <% if q.question_type == 0 %> <% q.exercise_choices.each do |s| %>
- - <%= to_markdown(s.choice_text) %> + + <%= to_markdown(s.choice_text) %>
<% end %> <% elsif q.question_type == 1 %> <% q.exercise_choices.each do |s| %>
- - <%= to_markdown(s.choice_text) %> + + <%= to_markdown(s.choice_text) %>
<% end %> <% elsif q.question_type == 2 %> diff --git a/app/templates/exercise_export/exercise_export.css b/app/templates/exercise_export/exercise_export.css index 140db58ef..3efda43bb 100644 --- a/app/templates/exercise_export/exercise_export.css +++ b/app/templates/exercise_export/exercise_export.css @@ -309,8 +309,8 @@ textarea{ clear:both; zoom:1; } -.line-20{ - line-height: 20px; +.line-24{ + line-height: 24px; } .line-20 P{ margin-bottom:0; From e365005af14682e96f3bc080ac32ab1c733f1438 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Mon, 1 Jul 2019 12:55:04 +0800 Subject: [PATCH 163/256] fix bug --- app/templates/exercise_export/blank_exercise.html.erb | 4 ++-- app/templates/exercise_export/exercise_export.css | 6 ++---- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/app/templates/exercise_export/blank_exercise.html.erb b/app/templates/exercise_export/blank_exercise.html.erb index aed7acdcd..99b8e6683 100644 --- a/app/templates/exercise_export/blank_exercise.html.erb +++ b/app/templates/exercise_export/blank_exercise.html.erb @@ -79,14 +79,14 @@
<% if q.question_type == 0 %> <% q.exercise_choices.each do |s| %> -
+
<%= to_markdown(s.choice_text) %>
<% end %> <% elsif q.question_type == 1 %> <% q.exercise_choices.each do |s| %> -
+
<%= to_markdown(s.choice_text) %>
diff --git a/app/templates/exercise_export/exercise_export.css b/app/templates/exercise_export/exercise_export.css index 3efda43bb..53dc5b3c8 100644 --- a/app/templates/exercise_export/exercise_export.css +++ b/app/templates/exercise_export/exercise_export.css @@ -312,11 +312,9 @@ textarea{ .line-24{ line-height: 24px; } -.line-20 P{ +.line-24 p{ margin-bottom:0; } -.v-middle{ - vertical-align: middle; -} + From 81950469b4c33cdd8e139a8ac26a4717c7c87f6b Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Mon, 1 Jul 2019 13:15:13 +0800 Subject: [PATCH 164/256] fix bug --- .../exercise_export/blank_exercise.html.erb | 8 ++-- .../exercise_export/exercise_export.css | 10 +++++ .../exercise_export/exercise_user.html.erb | 40 +++++++++---------- 3 files changed, 33 insertions(+), 25 deletions(-) diff --git a/app/templates/exercise_export/blank_exercise.html.erb b/app/templates/exercise_export/blank_exercise.html.erb index 99b8e6683..7e7c14977 100644 --- a/app/templates/exercise_export/blank_exercise.html.erb +++ b/app/templates/exercise_export/blank_exercise.html.erb @@ -80,15 +80,15 @@ <% if q.question_type == 0 %> <% q.exercise_choices.each do |s| %>
- - <%= to_markdown(s.choice_text) %> + + <%= to_markdown(s.choice_text) %>
<% end %> <% elsif q.question_type == 1 %> <% q.exercise_choices.each do |s| %>
- - <%= to_markdown(s.choice_text) %> + + <%= to_markdown(s.choice_text) %>
<% end %> <% elsif q.question_type == 2 %> diff --git a/app/templates/exercise_export/exercise_export.css b/app/templates/exercise_export/exercise_export.css index 53dc5b3c8..a72b26782 100644 --- a/app/templates/exercise_export/exercise_export.css +++ b/app/templates/exercise_export/exercise_export.css @@ -44,6 +44,9 @@ p{ .mbt10{ margin: 10px 0; } +.mt5{ + margin-top:5px; +} .pull-right{ float:right; } @@ -82,9 +85,15 @@ p{ .ml20{ margin-left:20px; } +.ml10{ + margin-left:10px; +} .mr3{ margin-right:3px; } +.mr8{ + margin-right:8px; +} .mr15{ margin-right:15px; } @@ -318,3 +327,4 @@ textarea{ + diff --git a/app/templates/exercise_export/exercise_user.html.erb b/app/templates/exercise_export/exercise_user.html.erb index 5770c5921..1679692b3 100644 --- a/app/templates/exercise_export/exercise_user.html.erb +++ b/app/templates/exercise_export/exercise_user.html.erb @@ -167,41 +167,39 @@ <% end %>
- <% q_title = q.question_title&.html_safe %> - <% if q_type == 5 %> - <% q_name = q.shixun_name&.html_safe %> - <%= q_name&.include?("src=\"") ? q_name&.gsub("src=\"","src=\"#{@request_url}") : q_name %> + <% if q.question_type == 5 %> + <%= to_markdown(q.shixun_name) %>
- <%= q_title&.include?("src=\"") ? q_title&.gsub("src=\"","src=\"#{@request_url}") : q_title %> + <%= to_markdown(q.question_title) %>
<% else %> - <%= q_title&.include?("src=\"") ? q_title&.gsub("src=\"","src=\"#{@request_url}") : q_title %> + <%= to_markdown(q.question_title) %> <% end %>
<% if q_type == 0 %> - <% q.exercise_choices.each_with_index do |s,index| %> + <% q.exercise_choices.each do |s| %> <% check_answer = (user_answer.present? && (s.id == user_answer.first.exercise_choice_id)) ? "choose-answer" : '' %> -

- - <%= convert_to_char((index+1).to_s)%><%= s.choice_text%> -

+
+ + <%= to_markdown(s.choice_text) %> +
<% end %> <% elsif q_type == 1 %> - <% q.exercise_choices.each_with_index do |s,index| %> + <% q.exercise_choices.each do |s| %> <% check_answer = (user_answer.present? && (user_answer.pluck(:exercise_choice_id).include?(s.id))) ? true : false %> -

+

<% if check_answer %> - + <% else %> - + <% end %> - <%= convert_to_char((index+1).to_s)%><%= s.choice_text%> -

+ <%= to_markdown(s.choice_text) %> +
<% end %> <% elsif q_type == 2 %> -

+

<% q.exercise_choices.each do |s| %> <% if user_answer.present? && (s.id == user_answer.first.exercise_choice_id) %> <% check_answer = 'choose-answer' %> @@ -213,7 +211,7 @@ <%= s.choice_text %> <% end %> -

+
<% elsif q_type == 3 %> <% st_counts = q.exercise_standard_answers.pluck(:exercise_choice_id).uniq %> <% st_counts.each_with_index do |s,index| %> @@ -224,13 +222,13 @@ <% end %>

答案(填空<%= index+1 %>): - <%= check_answer&.html_safe %> + <%= to_markdown(check_answer) %>

<% end %> <% elsif q_type == 4 %> <% check_answer = (user_answer.present? ? user_answer.first.answer_text : '--') %>

- <%= check_answer&.html_safe %> + <%= to_markdown(check_answer) %>

<% else %>
From 065669bc2b2a0c7dcdadbdfa450a61b0d559df7d Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Mon, 1 Jul 2019 13:38:18 +0800 Subject: [PATCH 165/256] =?UTF-8?q?fork=E5=AE=9E=E8=AE=AD=E5=B8=A6?= =?UTF-8?q?=E7=9D=80=E9=85=8D=E7=BD=AE=E4=BF=A1=E6=81=AF"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/shixuns_controller.rb | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/app/controllers/shixuns_controller.rb b/app/controllers/shixuns_controller.rb index 5631d03a7..f7172021c 100644 --- a/app/controllers/shixuns_controller.rb +++ b/app/controllers/shixuns_controller.rb @@ -179,6 +179,16 @@ class ShixunsController < ApplicationController ShixunTagRepertoire.create!(:tag_repertoire_id => str.tag_repertoire_id, :shixun_id => @new_shixun.id) end + # 同步配置 + @shixun.shixun_service_configs.each do |config| + ShixunServiceConfig.create!(:shixun_id => @new_shixun.id, + :cpu_limit => config.cpu_limit, + :lower_cpu_limit => config.lower_cpu_limit, + :memory_limit => config.memory_limit, + :request_limit => config.request_limit, + :mirror_repository_id => config.mirror_repository_id) + end + # fork版本库 logger.info("###########fork_repo_path: ######{@repo_path}") project_fork(@new_shixun, @repo_path, current_user.login) From db4d45d00e4f5c31842dc9b94fa6e6ec3de4cef9 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Mon, 1 Jul 2019 13:56:36 +0800 Subject: [PATCH 166/256] =?UTF-8?q?=E5=85=B3=E5=8D=A1=E8=AF=A6=E6=83=85?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2=E5=8F=82=E6=95=B0=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/challenges/show.json.jbuilder | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/challenges/show.json.jbuilder b/app/views/challenges/show.json.jbuilder index 332879eac..cffe77ebb 100644 --- a/app/views/challenges/show.json.jbuilder +++ b/app/views/challenges/show.json.jbuilder @@ -1,6 +1,6 @@ # 导航栏公共数据 json.partial! "challenges/top_common_data", shixun_identifier: @shixun.identifier -json.(@challenge, :id, :subject, :task_pass, :difficulty, :score) +json.(@challenge, :id, :subject, :task_pass, :difficulty, :score, :exec_time) json.tags @challenge.challenge_tags.map(&:name) From c3087d7b4e95003a7b1139362f810653884fe90a Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Mon, 1 Jul 2019 13:59:33 +0800 Subject: [PATCH 167/256] fix bug --- app/helpers/application_helper.rb | 1 + .../exercise_export/blank_exercise.html.erb | 12 ++++++------ app/templates/exercise_export/exercise_export.css | 8 +++----- .../exercise_export/exercise_user.html.erb | 14 +++++++------- 4 files changed, 17 insertions(+), 18 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index c49e5e775..e6bc84f20 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -350,6 +350,7 @@ module ApplicationHelper markdown = Redcarpet::Markdown.new(Redcarpet::Render::HTML,options) m_t = markdown.render(text) m_t&.include?("src=\"") ? m_t&.gsub("src=\"","src=\"#{request_url}") : m_t + Rails.logger.info("###########__________request_url_________###################{request_url}") end end diff --git a/app/templates/exercise_export/blank_exercise.html.erb b/app/templates/exercise_export/blank_exercise.html.erb index 7e7c14977..1dde00e56 100644 --- a/app/templates/exercise_export/blank_exercise.html.erb +++ b/app/templates/exercise_export/blank_exercise.html.erb @@ -79,16 +79,16 @@
<% if q.question_type == 0 %> <% q.exercise_choices.each do |s| %> -
- - <%= to_markdown(s.choice_text) %> +
+ + <%= to_markdown(s.choice_text) %>
<% end %> <% elsif q.question_type == 1 %> <% q.exercise_choices.each do |s| %> -
- - <%= to_markdown(s.choice_text) %> +
+ + <%= to_markdown(s.choice_text) %>
<% end %> <% elsif q.question_type == 2 %> diff --git a/app/templates/exercise_export/exercise_export.css b/app/templates/exercise_export/exercise_export.css index a72b26782..f0eeb0f4c 100644 --- a/app/templates/exercise_export/exercise_export.css +++ b/app/templates/exercise_export/exercise_export.css @@ -257,7 +257,7 @@ table{ text-align:center; } -table, tr, td, th, tbody, thead, tfoot,textarea{ +table, tr, td, th, tbody, thead, tfoot,textarea,.main-choice{ page-break-inside: avoid; } table th{ @@ -318,10 +318,8 @@ textarea{ clear:both; zoom:1; } -.line-24{ - line-height: 24px; -} -.line-24 p{ + +.choice-text p{ margin-bottom:0; } diff --git a/app/templates/exercise_export/exercise_user.html.erb b/app/templates/exercise_export/exercise_user.html.erb index 1679692b3..3e92c5864 100644 --- a/app/templates/exercise_export/exercise_user.html.erb +++ b/app/templates/exercise_export/exercise_user.html.erb @@ -181,21 +181,21 @@ <% if q_type == 0 %> <% q.exercise_choices.each do |s| %> <% check_answer = (user_answer.present? && (s.id == user_answer.first.exercise_choice_id)) ? "choose-answer" : '' %> -
- - <%= to_markdown(s.choice_text) %> +
+ + <%= to_markdown(s.choice_text) %>
<% end %> <% elsif q_type == 1 %> <% q.exercise_choices.each do |s| %> <% check_answer = (user_answer.present? && (user_answer.pluck(:exercise_choice_id).include?(s.id))) ? true : false %> -
+
<% if check_answer %> - + <% else %> - + <% end %> - <%= to_markdown(s.choice_text) %> + <%= to_markdown(s.choice_text) %>
<% end %> <% elsif q_type == 2 %> From 733e7827234ddf4055f9932d20f3db6115597dc4 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Mon, 1 Jul 2019 14:03:03 +0800 Subject: [PATCH 168/256] fix bug --- app/controllers/zips_controller.rb | 3 +-- app/helpers/application_helper.rb | 1 + app/services/exercise_user_pdf_service.rb | 3 +-- app/services/export_exercises_service.rb | 5 ++--- 4 files changed, 5 insertions(+), 7 deletions(-) diff --git a/app/controllers/zips_controller.rb b/app/controllers/zips_controller.rb index 77a41d065..4de85ec64 100644 --- a/app/controllers/zips_controller.rb +++ b/app/controllers/zips_controller.rb @@ -17,7 +17,7 @@ class ZipsController < ApplicationController end def export_exercises - exercises = ExportExercisesService.new(@exercise,@ex_users,@request_url) + exercises = ExportExercisesService.new(@exercise,@ex_users) file_name = filename_for_content_disposition(exercises.filename) send_file exercises.ex_zip, filename: file_name, type: 'application/zip' @@ -41,7 +41,6 @@ class ZipsController < ApplicationController ActiveRecord::Base.transaction do begin @exercise = Exercise.includes(:exercise_users,:exercise_questions).find_by(id:params[:exercise_id]) - @request_url = request.base_url group_id = params[:exercise_group_id] if @exercise.blank? normal_status(-1,"试卷不存在") diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index e6bc84f20..f0cac79b9 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -334,6 +334,7 @@ module ApplicationHelper raw arr.join('') end + # 导出pdf时,转化markdown为html def to_markdown(text) request_url = request.base_url diff --git a/app/services/exercise_user_pdf_service.rb b/app/services/exercise_user_pdf_service.rb index 9b96cd70c..be048c4c2 100644 --- a/app/services/exercise_user_pdf_service.rb +++ b/app/services/exercise_user_pdf_service.rb @@ -5,10 +5,9 @@ class ExerciseUserPdfService attr_reader :exercise, :ex_user - def initialize(exercise, ex_user,request_url) + def initialize(exercise, ex_user) @exercise = exercise @ex_user = ex_user - @request_url = request_url @ex_user_user = @ex_user.user @course = @exercise.course end diff --git a/app/services/export_exercises_service.rb b/app/services/export_exercises_service.rb index 48bfc9519..12b5501f9 100644 --- a/app/services/export_exercises_service.rb +++ b/app/services/export_exercises_service.rb @@ -3,10 +3,9 @@ class ExportExercisesService include StudentWorksHelper attr_reader :exercise, :ex_users - def initialize(exercise, ex_users,request_url) + def initialize(exercise, ex_users) @exercise = exercise @ex_users = ex_users - @request_url = request_url end def filename @@ -19,7 +18,7 @@ class ExportExercisesService pdfs = [] Zip::File.open(zip_file.path, Zip::File::CREATE) do |zip| ex_users.each do |ex_user| - export = ExerciseUserPdfService.new(exercise, ex_user,@request_url) + export = ExerciseUserPdfService.new(exercise, ex_user) pdf = export.ex_pdf pdfs << pdf begin From b8592a99433ac4af3eeb508d1d456fd3b53c623e Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Mon, 1 Jul 2019 14:10:48 +0800 Subject: [PATCH 169/256] fix bug --- app/controllers/exercises_controller.rb | 1 - app/helpers/application_helper.rb | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/app/controllers/exercises_controller.rb b/app/controllers/exercises_controller.rb index 2377f411b..8b65d7c70 100644 --- a/app/controllers/exercises_controller.rb +++ b/app/controllers/exercises_controller.rb @@ -1334,7 +1334,6 @@ class ExercisesController < ApplicationController #导出空白试卷 def export_exercise @exercise_questions = @exercise.exercise_questions.includes(:exercise_choices).order("question_number ASC") - @request_url = request.base_url filename = "#{current_user.real_name}_#{@course.name}_#{@exercise.exercise_name}_#{Time.current.strftime('%Y%m%d%H%M%S')}.pdf" stylesheets = "#{Rails.root}/app/templates/exercise_export/exercise_export.css" render pdf: 'exercise_export/blank_exercise', filename: filename, stylesheets: stylesheets diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index f0cac79b9..65b6c0634 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -336,9 +336,9 @@ module ApplicationHelper # 导出pdf时,转化markdown为html def to_markdown(text) + return nil if text.blank? request_url = request.base_url - return nil if text.blank? options = { :autolink => true, :no_intra_emphasis => true, @@ -350,7 +350,7 @@ module ApplicationHelper } markdown = Redcarpet::Markdown.new(Redcarpet::Render::HTML,options) m_t = markdown.render(text) - m_t&.include?("src=\"") ? m_t&.gsub("src=\"","src=\"#{request_url}") : m_t + m_t&.include?("src=\"") ? m_t&.gsub("src=\"","src=\"#{request.base_url}") : m_t Rails.logger.info("###########__________request_url_________###################{request_url}") end From dade42727badc705a19a0e37f3f0a80a53389b86 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Mon, 1 Jul 2019 14:19:39 +0800 Subject: [PATCH 170/256] =?UTF-8?q?=E5=8E=BB=E9=99=A4=E5=AE=9E=E8=AE=AD?= =?UTF-8?q?=E7=9A=84=E5=85=B3=E5=8D=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/shixuns/settings.json.jbuilder | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/shixuns/settings.json.jbuilder b/app/views/shixuns/settings.json.jbuilder index ed7d93039..e81498058 100644 --- a/app/views/shixuns/settings.json.jbuilder +++ b/app/views/shixuns/settings.json.jbuilder @@ -22,7 +22,7 @@ json.shixun do json.hide_code @shixun.hide_code # 隐藏代码窗口 json.code_hidden @shixun.code_hidden # 代码目录隐藏 json.vnc @shixun.vnc - json.exec_time @shixun.exec_time + #json.exec_time @shixun.exec_time json.webssh @shixun.webssh json.multi_webssh @shixun.multi_webssh json.use_scope @shixun.use_scope From c543779cb1aaac41615d0093b5907e14c4f6d6ae Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Mon, 1 Jul 2019 14:20:48 +0800 Subject: [PATCH 171/256] fix bug --- app/helpers/application_helper.rb | 4 ++-- app/templates/exercise_export/exercise_user.html.erb | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 65b6c0634..6ddbdce0c 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -337,7 +337,7 @@ module ApplicationHelper # 导出pdf时,转化markdown为html def to_markdown(text) return nil if text.blank? - request_url = request.base_url + request_url = "http://47.96.87.25:48080" options = { :autolink => true, @@ -350,7 +350,7 @@ module ApplicationHelper } markdown = Redcarpet::Markdown.new(Redcarpet::Render::HTML,options) m_t = markdown.render(text) - m_t&.include?("src=\"") ? m_t&.gsub("src=\"","src=\"#{request.base_url}") : m_t + m_t&.include?("src=\"") ? m_t&.gsub("src=\"","src=\"#{request_url}") : m_t Rails.logger.info("###########__________request_url_________###################{request_url}") end diff --git a/app/templates/exercise_export/exercise_user.html.erb b/app/templates/exercise_export/exercise_user.html.erb index 3e92c5864..f523246a0 100644 --- a/app/templates/exercise_export/exercise_user.html.erb +++ b/app/templates/exercise_export/exercise_user.html.erb @@ -121,7 +121,7 @@
- <%= q.question_number %>、  + <%= q.question_number %>、 <%= request.base_url %> <%= q.question_type_name %> From 90fadb2869971dd7fc8a6b11cc3cd8b52024f92b Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Mon, 1 Jul 2019 14:22:56 +0800 Subject: [PATCH 172/256] =?UTF-8?q?=E5=AF=BC=E5=85=A5=E5=88=86=E7=8F=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/courses_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index e0844ab4c..cef2a1785 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -776,7 +776,7 @@ class CoursesController < ApplicationController name = attachment.disk_filename if name.split(".").last == "xls" begin - attachment_folder = Rails.configuration.educoder['attachment_folder'] + attachment_folder = edu_setting('attachment_folder') full_path = "#{attachment_folder}/#{path}/#{name}" xls = Roo::Spreadsheet.open(full_path, extension: :xls) worksheet = xls.sheet(0) From 0387dbaf9142376a5397438d7c4526d6c1baddd0 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Mon, 1 Jul 2019 14:23:59 +0800 Subject: [PATCH 173/256] fix bug --- app/templates/exercise_export/exercise_user.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/templates/exercise_export/exercise_user.html.erb b/app/templates/exercise_export/exercise_user.html.erb index f523246a0..3e92c5864 100644 --- a/app/templates/exercise_export/exercise_user.html.erb +++ b/app/templates/exercise_export/exercise_user.html.erb @@ -121,7 +121,7 @@
- <%= q.question_number %>、 <%= request.base_url %> + <%= q.question_number %>、  <%= q.question_type_name %> From cc20b5459fc3574baa79218b9ddb126a6093edae Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Mon, 1 Jul 2019 14:36:21 +0800 Subject: [PATCH 174/256] fix bug --- app/controllers/exercises_controller.rb | 1 + app/controllers/zips_controller.rb | 3 ++- app/helpers/application_helper.rb | 7 ++----- app/services/exercise_user_pdf_service.rb | 3 ++- app/services/export_exercises_service.rb | 5 +++-- .../exercise_export/blank_exercise.html.erb | 10 +++++----- app/templates/exercise_export/exercise_user.html.erb | 12 ++++++------ 7 files changed, 21 insertions(+), 20 deletions(-) diff --git a/app/controllers/exercises_controller.rb b/app/controllers/exercises_controller.rb index 8b65d7c70..3c364b979 100644 --- a/app/controllers/exercises_controller.rb +++ b/app/controllers/exercises_controller.rb @@ -1333,6 +1333,7 @@ class ExercisesController < ApplicationController #导出空白试卷 def export_exercise + @request_url = request.base_url @exercise_questions = @exercise.exercise_questions.includes(:exercise_choices).order("question_number ASC") filename = "#{current_user.real_name}_#{@course.name}_#{@exercise.exercise_name}_#{Time.current.strftime('%Y%m%d%H%M%S')}.pdf" stylesheets = "#{Rails.root}/app/templates/exercise_export/exercise_export.css" diff --git a/app/controllers/zips_controller.rb b/app/controllers/zips_controller.rb index 4de85ec64..c20546701 100644 --- a/app/controllers/zips_controller.rb +++ b/app/controllers/zips_controller.rb @@ -17,7 +17,8 @@ class ZipsController < ApplicationController end def export_exercises - exercises = ExportExercisesService.new(@exercise,@ex_users) + @request_url = request.base_url + exercises = ExportExercisesService.new(@exercise,@ex_users,@request_url) file_name = filename_for_content_disposition(exercises.filename) send_file exercises.ex_zip, filename: file_name, type: 'application/zip' diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 6ddbdce0c..fd72b5651 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -335,10 +335,8 @@ module ApplicationHelper end # 导出pdf时,转化markdown为html - def to_markdown(text) + def to_markdown(text,origin_url) return nil if text.blank? - request_url = "http://47.96.87.25:48080" - options = { :autolink => true, :no_intra_emphasis => true, @@ -350,8 +348,7 @@ module ApplicationHelper } markdown = Redcarpet::Markdown.new(Redcarpet::Render::HTML,options) m_t = markdown.render(text) - m_t&.include?("src=\"") ? m_t&.gsub("src=\"","src=\"#{request_url}") : m_t - Rails.logger.info("###########__________request_url_________###################{request_url}") + m_t&.include?("src=\"") ? m_t&.gsub("src=\"","src=\"#{origin_url}") : m_t end end diff --git a/app/services/exercise_user_pdf_service.rb b/app/services/exercise_user_pdf_service.rb index be048c4c2..9b96cd70c 100644 --- a/app/services/exercise_user_pdf_service.rb +++ b/app/services/exercise_user_pdf_service.rb @@ -5,9 +5,10 @@ class ExerciseUserPdfService attr_reader :exercise, :ex_user - def initialize(exercise, ex_user) + def initialize(exercise, ex_user,request_url) @exercise = exercise @ex_user = ex_user + @request_url = request_url @ex_user_user = @ex_user.user @course = @exercise.course end diff --git a/app/services/export_exercises_service.rb b/app/services/export_exercises_service.rb index 12b5501f9..0d2d8f3ce 100644 --- a/app/services/export_exercises_service.rb +++ b/app/services/export_exercises_service.rb @@ -3,9 +3,10 @@ class ExportExercisesService include StudentWorksHelper attr_reader :exercise, :ex_users - def initialize(exercise, ex_users) + def initialize(exercise, ex_users,request_url) @exercise = exercise @ex_users = ex_users + @request_url = request_url end def filename @@ -18,7 +19,7 @@ class ExportExercisesService pdfs = [] Zip::File.open(zip_file.path, Zip::File::CREATE) do |zip| ex_users.each do |ex_user| - export = ExerciseUserPdfService.new(exercise, ex_user) + export = ExerciseUserPdfService.new(exercise, ex_user,request_url) pdf = export.ex_pdf pdfs << pdf begin diff --git a/app/templates/exercise_export/blank_exercise.html.erb b/app/templates/exercise_export/blank_exercise.html.erb index 1dde00e56..153ba1514 100644 --- a/app/templates/exercise_export/blank_exercise.html.erb +++ b/app/templates/exercise_export/blank_exercise.html.erb @@ -68,12 +68,12 @@
<% if q.question_type == 5 %> - <%= to_markdown(q.shixun_name) %> + <%= to_markdown(q.shixun_name,@request_url) %>
- <%= to_markdown(q.question_title) %> + <%= to_markdown(q.question_title,@request_url) %>
<% else %> - <%= to_markdown(q.question_title) %> + <%= to_markdown(q.question_title,@request_url) %> <% end %>
@@ -81,14 +81,14 @@ <% q.exercise_choices.each do |s| %>
- <%= to_markdown(s.choice_text) %> + <%= to_markdown(s.choice_text,@request_url) %>
<% end %> <% elsif q.question_type == 1 %> <% q.exercise_choices.each do |s| %>
- <%= to_markdown(s.choice_text) %> + <%= to_markdown(s.choice_text,@request_url) %>
<% end %> <% elsif q.question_type == 2 %> diff --git a/app/templates/exercise_export/exercise_user.html.erb b/app/templates/exercise_export/exercise_user.html.erb index 3e92c5864..bb3723373 100644 --- a/app/templates/exercise_export/exercise_user.html.erb +++ b/app/templates/exercise_export/exercise_user.html.erb @@ -168,12 +168,12 @@
<% if q.question_type == 5 %> - <%= to_markdown(q.shixun_name) %> + <%= to_markdown(q.shixun_name,@request_url) %>
- <%= to_markdown(q.question_title) %> + <%= to_markdown(q.question_title,@request_url) %>
<% else %> - <%= to_markdown(q.question_title) %> + <%= to_markdown(q.question_title,@request_url) %> <% end %>
@@ -183,7 +183,7 @@ <% check_answer = (user_answer.present? && (s.id == user_answer.first.exercise_choice_id)) ? "choose-answer" : '' %>
- <%= to_markdown(s.choice_text) %> + <%= to_markdown(s.choice_text,@request_url) %>
<% end %> <% elsif q_type == 1 %> @@ -195,7 +195,7 @@ <% else %> <% end %> - <%= to_markdown(s.choice_text) %> + <%= to_markdown(s.choice_text,@request_url) %>
<% end %> <% elsif q_type == 2 %> @@ -335,7 +335,7 @@
- +

<%= ques_user.real_name %><%= ques_comment.first.updated_at.strftime('%Y-%m-%d %H:%M') %>

From 1e5db588192fe5b130c99589e3ae78719c83fce4 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Mon, 1 Jul 2019 14:38:24 +0800 Subject: [PATCH 175/256] fix bug --- app/services/exercise_user_pdf_service.rb | 2 +- app/services/export_exercises_service.rb | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/services/exercise_user_pdf_service.rb b/app/services/exercise_user_pdf_service.rb index 9b96cd70c..44ee1e769 100644 --- a/app/services/exercise_user_pdf_service.rb +++ b/app/services/exercise_user_pdf_service.rb @@ -3,7 +3,7 @@ class ExerciseUserPdfService include ApplicationHelper include StudentWorksHelper - attr_reader :exercise, :ex_user + attr_reader :exercise, :ex_user, :request_url def initialize(exercise, ex_user,request_url) @exercise = exercise diff --git a/app/services/export_exercises_service.rb b/app/services/export_exercises_service.rb index 0d2d8f3ce..f83323d7e 100644 --- a/app/services/export_exercises_service.rb +++ b/app/services/export_exercises_service.rb @@ -1,9 +1,9 @@ class ExportExercisesService include ExercisesHelper include StudentWorksHelper - attr_reader :exercise, :ex_users + attr_reader :exercise, :ex_users, :request_url - def initialize(exercise, ex_users,request_url) + def initialize(exercise, ex_users, request_url) @exercise = exercise @ex_users = ex_users @request_url = request_url @@ -19,7 +19,7 @@ class ExportExercisesService pdfs = [] Zip::File.open(zip_file.path, Zip::File::CREATE) do |zip| ex_users.each do |ex_user| - export = ExerciseUserPdfService.new(exercise, ex_user,request_url) + export = ExerciseUserPdfService.new(exercise, ex_user,@request_url) pdf = export.ex_pdf pdfs << pdf begin From e5cd38ed9007b5fe2338ef3da7cfa9ecaa100486 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Mon, 1 Jul 2019 14:39:46 +0800 Subject: [PATCH 176/256] =?UTF-8?q?=E8=AE=A1=E7=AE=97=E6=88=90=E7=BB=A9?= =?UTF-8?q?=E7=9A=84=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/homework_commons_controller.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/controllers/homework_commons_controller.rb b/app/controllers/homework_commons_controller.rb index f242f3438..545fbce85 100644 --- a/app/controllers/homework_commons_controller.rb +++ b/app/controllers/homework_commons_controller.rb @@ -12,7 +12,7 @@ class HomeworkCommonsController < ApplicationController :code_review_detail, :show_comment, :settings, :works_list, :update_settings, :reference_answer, :publish_groups, :end_groups, :alter_name, :update_explanation] before_action :user_course_identity - before_action :homework_publish, only: [:show, :works_list, :code_review_results, :show_comment, :settings, :reference_answer] + before_action :homework_publish, only: [:show, :works_list, :code_review_results, :show_comment, :settings, :reference_answer, :update_student_score] before_action :teacher_allowed, only: [:new, :edit, :create, :update, :shixuns, :subjects, :create_shixun_homework, :publish_homework, :end_homework, :set_public, :choose_category, :move_to_category, :choose_category, :create_subject_homework, :multi_destroy, :group_list, :homework_code_repeat, @@ -237,6 +237,7 @@ class HomeworkCommonsController < ApplicationController end def update_score + tip_exception("作业还未发布,暂不能计算成绩") if @homework.publish_time.nil? || @homework.publish_time > Time.now begin if @homework.unified_setting student_works = @homework.student_works From 99d94df66117f9939ed3141e9e98d7ba9d653595 Mon Sep 17 00:00:00 2001 From: jasder Date: Mon, 1 Jul 2019 14:44:49 +0800 Subject: [PATCH 177/256] =?UTF-8?q?FIX=20=E2=80=98=E5=88=A0=E9=99=A4?= =?UTF-8?q?=E2=80=99=E5=85=AC=E5=85=B1api=E6=9B=B4=E6=94=B9=E5=88=A0?= =?UTF-8?q?=E9=99=A4=E6=9D=83=E9=99=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/commons_controller.rb | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/app/controllers/commons_controller.rb b/app/controllers/commons_controller.rb index ca68c65d3..105cbefbe 100644 --- a/app/controllers/commons_controller.rb +++ b/app/controllers/commons_controller.rb @@ -42,7 +42,18 @@ class CommonsController < ApplicationController end def validate_power - tip_exception(403, "无操作权限") unless current_user.admin? + code = + case params[:object_type].strip + when 'message' + if current_user.course_identity(@object.board.course) >= 5 || @object.author != current_user + 403 + else + 200 + end + else + current_user.admin? ? 200 : 403 + end + return normal_status(403, "你没有权限操作!") if code == 403 end def action(flag) From bfd6b60f66ed0fd2a7751d85e34fd057678c9861 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Mon, 1 Jul 2019 14:45:47 +0800 Subject: [PATCH 178/256] =?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/controllers/homework_commons_controller.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/controllers/homework_commons_controller.rb b/app/controllers/homework_commons_controller.rb index 545fbce85..3562be4f3 100644 --- a/app/controllers/homework_commons_controller.rb +++ b/app/controllers/homework_commons_controller.rb @@ -10,7 +10,8 @@ class HomeworkCommonsController < ApplicationController :create_subject_homework, :multi_destroy, :add_to_homework_bank] before_action :find_homework, only: [:edit, :show, :update, :group_list, :homework_code_repeat, :code_review_results, :code_review_detail, :show_comment, :settings, :works_list, :update_settings, - :reference_answer, :publish_groups, :end_groups, :alter_name, :update_explanation] + :reference_answer, :publish_groups, :end_groups, :alter_name, :update_explanation, + :update_score, :update_student_score] before_action :user_course_identity before_action :homework_publish, only: [:show, :works_list, :code_review_results, :show_comment, :settings, :reference_answer, :update_student_score] before_action :teacher_allowed, only: [:new, :edit, :create, :update, :shixuns, :subjects, :create_shixun_homework, From 2d2ab5e8bb24bd564e9e8ba552e9ba94e55dd9aa Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Mon, 1 Jul 2019 14:46:34 +0800 Subject: [PATCH 179/256] fix bug --- app/templates/exercise_export/exercise_user.html.erb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/templates/exercise_export/exercise_user.html.erb b/app/templates/exercise_export/exercise_user.html.erb index bb3723373..41f8d5726 100644 --- a/app/templates/exercise_export/exercise_user.html.erb +++ b/app/templates/exercise_export/exercise_user.html.erb @@ -222,13 +222,13 @@ <% end %>

答案(填空<%= index+1 %>): - <%= to_markdown(check_answer) %> + <%= to_markdown(check_answer,@request_url) %>

<% end %> <% elsif q_type == 4 %> <% check_answer = (user_answer.present? ? user_answer.first.answer_text : '--') %>

- <%= to_markdown(check_answer) %> + <%= to_markdown(check_answer,@request_url) %>

<% else %>
From cf714a85ea0b317b7059805f9fe7d1d865bd926a Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Mon, 1 Jul 2019 14:48:47 +0800 Subject: [PATCH 180/256] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E5=AE=9E=E8=AE=AD?= =?UTF-8?q?=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/shixuns_controller.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/shixuns_controller.rb b/app/controllers/shixuns_controller.rb index f7172021c..0eaeae7de 100644 --- a/app/controllers/shixuns_controller.rb +++ b/app/controllers/shixuns_controller.rb @@ -739,8 +739,8 @@ private :hide_code, :forbid_copy) end def shixun_info_params - raise("实训描述不能为空") if params[:description].blank? - raise("评测脚本不能为空") if params[:evaluate_script].blank? + raise("实训描述不能为空") if params[:shixun_info][:description].blank? + raise("评测脚本不能为空") if params[:shixun_info][:evaluate_script].blank? params.require(:shixun_info).permit(:description, :evaluate_script) end From 783f73796007f6e1f39aeeae9b6fbcaadbb4ebd7 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Mon, 1 Jul 2019 14:49:19 +0800 Subject: [PATCH 181/256] =?UTF-8?q?=E5=AE=9E=E8=AE=AD=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/shixuns_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/shixuns_controller.rb b/app/controllers/shixuns_controller.rb index 0eaeae7de..0d913a0a1 100644 --- a/app/controllers/shixuns_controller.rb +++ b/app/controllers/shixuns_controller.rb @@ -733,7 +733,7 @@ class ShixunsController < ApplicationController private def shixun_params - raise("实训名称不能为空") if params[:name].blank? + raise("实训名称不能为空") if params[:shixun][:name].blank? params.require(:shixun).permit(:name, :trainee, :webssh, :can_copy, :use_scope, :vnc, :test_set_permission, :task_pass, :repo_name, :multi_webssh, :opening_time, :mirror_script_id, :code_hidden, :hide_code, :forbid_copy) From 191c2a25fa9f989694eb1cfb495f533cfc73f987 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Mon, 1 Jul 2019 15:03:50 +0800 Subject: [PATCH 182/256] fix bug --- app/templates/exercise_export/exercise_export.css | 3 +++ app/templates/exercise_export/exercise_user.html.erb | 6 +++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/app/templates/exercise_export/exercise_export.css b/app/templates/exercise_export/exercise_export.css index f0eeb0f4c..ef76479c5 100644 --- a/app/templates/exercise_export/exercise_export.css +++ b/app/templates/exercise_export/exercise_export.css @@ -109,6 +109,9 @@ p{ white-space: normal; min-height:12px; } +.null-answer p{ + display: inline-block; +} .choose-radio{ display: inline-block; width: 12px; diff --git a/app/templates/exercise_export/exercise_user.html.erb b/app/templates/exercise_export/exercise_user.html.erb index 41f8d5726..8731df439 100644 --- a/app/templates/exercise_export/exercise_user.html.erb +++ b/app/templates/exercise_export/exercise_user.html.erb @@ -181,7 +181,7 @@ <% if q_type == 0 %> <% q.exercise_choices.each do |s| %> <% check_answer = (user_answer.present? && (s.id == user_answer.first.exercise_choice_id)) ? "choose-answer" : '' %> -
+
<%= to_markdown(s.choice_text,@request_url) %>
@@ -189,9 +189,9 @@ <% elsif q_type == 1 %> <% q.exercise_choices.each do |s| %> <% check_answer = (user_answer.present? && (user_answer.pluck(:exercise_choice_id).include?(s.id))) ? true : false %> -
+
<% if check_answer %> - + <% else %> <% end %> From 275bc3bd0d39aab0f6ff7a0de19fef148a6eebed Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Mon, 1 Jul 2019 15:08:11 +0800 Subject: [PATCH 183/256] =?UTF-8?q?=E5=AE=9E=E8=AE=AD=E5=85=B3=E5=8D=A1?= =?UTF-8?q?=E5=88=97=E8=A1=A8=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/challenge.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/challenge.rb b/app/models/challenge.rb index 18b177e1c..e7a382a51 100644 --- a/app/models/challenge.rb +++ b/app/models/challenge.rb @@ -52,7 +52,7 @@ class Challenge < ApplicationRecord # 开启挑战 def open_game user_id, shixun - game = self.games.first + game = self.games.where(user_id: user_id).first if game.present? shixun.task_pass || game.status != 3 ? "/tasks/#{game.identifier}" : "" else From fcbd308d05c1406263450a3c9b7c5dd4b07d3cfb Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Mon, 1 Jul 2019 15:09:31 +0800 Subject: [PATCH 184/256] fix bug --- app/templates/exercise_export/exercise_export.css | 3 +++ .../exercise_export/exercise_user.html.erb | 14 ++++++++------ 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/app/templates/exercise_export/exercise_export.css b/app/templates/exercise_export/exercise_export.css index ef76479c5..2745382f7 100644 --- a/app/templates/exercise_export/exercise_export.css +++ b/app/templates/exercise_export/exercise_export.css @@ -41,6 +41,9 @@ p{ .mt8{ margin-top:8px; } +.mt10{ + margin-top:10px; +} .mbt10{ margin: 10px 0; } diff --git a/app/templates/exercise_export/exercise_user.html.erb b/app/templates/exercise_export/exercise_user.html.erb index 8731df439..1e3d88a44 100644 --- a/app/templates/exercise_export/exercise_user.html.erb +++ b/app/templates/exercise_export/exercise_user.html.erb @@ -182,7 +182,7 @@ <% q.exercise_choices.each do |s| %> <% check_answer = (user_answer.present? && (s.id == user_answer.first.exercise_choice_id)) ? "choose-answer" : '' %>
- + <%= to_markdown(s.choice_text,@request_url) %>
<% end %> @@ -191,9 +191,9 @@ <% check_answer = (user_answer.present? && (user_answer.pluck(:exercise_choice_id).include?(s.id))) ? true : false %>
<% if check_answer %> - + <% else %> - + <% end %> <%= to_markdown(s.choice_text,@request_url) %>
@@ -227,9 +227,11 @@ <% end %> <% elsif q_type == 4 %> <% check_answer = (user_answer.present? ? user_answer.first.answer_text : '--') %> -

- <%= to_markdown(check_answer,@request_url) %> -

+
+
+ <%= to_markdown(check_answer,@request_url) %> +
+
<% else %>

From a820dd0a67da819a28441f2ffd451d3b654fecbe Mon Sep 17 00:00:00 2001 From: jasder Date: Mon, 1 Jul 2019 15:10:24 +0800 Subject: [PATCH 185/256] FIX bug --- 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 105cbefbe..1f6dce053 100644 --- a/app/controllers/commons_controller.rb +++ b/app/controllers/commons_controller.rb @@ -45,7 +45,7 @@ class CommonsController < ApplicationController code = case params[:object_type].strip when 'message' - if current_user.course_identity(@object.board.course) >= 5 || @object.author != current_user + if current_user.course_identity(@object.board.course) >= 5 && @object.author != current_user 403 else 200 @@ -53,7 +53,7 @@ class CommonsController < ApplicationController else current_user.admin? ? 200 : 403 end - return normal_status(403, "你没有权限操作!") if code == 403 + return normal_status(code, "你没有权限操作!") if code == 403 end def action(flag) From 08a4a0d89ba71bf0ebbf045fd7bf695466470036 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Mon, 1 Jul 2019 15:22:59 +0800 Subject: [PATCH 186/256] =?UTF-8?q?=E8=AF=95=E5=8D=B7=E7=9A=84=E6=89=B9?= =?UTF-8?q?=E9=87=8F=E5=AF=BC=E5=87=BAhtml=E5=92=8Ccss=E7=9A=84=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/zips_controller.rb | 4 ++-- app/templates/exercise_export/exercise_user.html.erb | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/controllers/zips_controller.rb b/app/controllers/zips_controller.rb index c20546701..51761d023 100644 --- a/app/controllers/zips_controller.rb +++ b/app/controllers/zips_controller.rb @@ -49,12 +49,12 @@ class ZipsController < ApplicationController @course = @exercise.course default_ex_users = @exercise.all_exercise_users(current_user.id).exercise_user_committed - @ex_users = default_ex_users #仅导出已提交的,截止后则是全部为提交的。 + @ex_users = default_ex_users.limit 2 #仅导出已提交的,截止后则是全部为提交的。 #可以分班选择 if group_id.present? exercise_students = @course.students.where(course_group_id: group_id) # 试卷所分班的全部人数 user_ids = exercise_students.pluck(:user_id).reject(&:blank?).uniq - @ex_users = @ex_users.where(user_id: user_ids) + @ex_users = @ex_users.where(user_id: user_ids).limit 2 end default_ex_users_size = @ex_users.size diff --git a/app/templates/exercise_export/exercise_user.html.erb b/app/templates/exercise_export/exercise_user.html.erb index 1e3d88a44..62d2132ce 100644 --- a/app/templates/exercise_export/exercise_user.html.erb +++ b/app/templates/exercise_export/exercise_user.html.erb @@ -220,10 +220,10 @@ <% else %> <% check_answer = "--" %> <% end %> -

- 答案(填空<%= index+1 %>): - <%= to_markdown(check_answer,@request_url) %> -

+
+
答案(填空<%= index+1 %>):
+
<%= to_markdown(check_answer,@request_url) %>
+
<% end %> <% elsif q_type == 4 %> <% check_answer = (user_answer.present? ? user_answer.first.answer_text : '--') %> From f613331443ec493aec0dd9e5b96b6af67e08e4e8 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Mon, 1 Jul 2019 15:38:12 +0800 Subject: [PATCH 187/256] fix bug --- app/templates/exercise_export/exercise_export.css | 3 +++ .../exercise_export/exercise_user.html.erb | 13 ++++++------- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/app/templates/exercise_export/exercise_export.css b/app/templates/exercise_export/exercise_export.css index 2745382f7..0c4bf54e5 100644 --- a/app/templates/exercise_export/exercise_export.css +++ b/app/templates/exercise_export/exercise_export.css @@ -328,6 +328,9 @@ textarea{ .choice-text p{ margin-bottom:0; } +.mt-2{ + margin-top:-2px; +} diff --git a/app/templates/exercise_export/exercise_user.html.erb b/app/templates/exercise_export/exercise_user.html.erb index 62d2132ce..7e40047b0 100644 --- a/app/templates/exercise_export/exercise_user.html.erb +++ b/app/templates/exercise_export/exercise_user.html.erb @@ -21,8 +21,8 @@

<% if @exercise_single_ques_count > 0 %> - 单选题<%= @exercise_single_ques_count %>题, - 共<%= @exercise_single_ques_scores %> + 单选题<%= @exercise_single_ques_count %>题, + 共<%= @exercise_single_ques_scores %> <% end %> <% if @exercise_double_ques_count > 0 %> 多选题<%= @exercise_double_ques_count %>题, @@ -44,7 +44,6 @@ 实训题<%= @exercise_ques_shixun_count %>题, 共<%= @exercise_ques_shixun_scores %> <% end %> - <% if @exercise_ques_count > 0 %> <%= @exercise_ques_scores %>分 @@ -183,7 +182,7 @@ <% check_answer = (user_answer.present? && (s.id == user_answer.first.exercise_choice_id)) ? "choose-answer" : '' %>

- <%= to_markdown(s.choice_text,@request_url) %> + <%= to_markdown(s.choice_text,@request_url) %>
<% end %> <% elsif q_type == 1 %> @@ -195,7 +194,7 @@ <% else %> <% end %> - <%= to_markdown(s.choice_text,@request_url) %> + <%= to_markdown(s.choice_text,@request_url) %>
<% end %> <% elsif q_type == 2 %> @@ -221,13 +220,13 @@ <% check_answer = "--" %> <% end %>
-
答案(填空<%= index+1 %>):
+
答案(填空<%= index+1 %>):
<%= to_markdown(check_answer,@request_url) %>
<% end %> <% elsif q_type == 4 %> <% check_answer = (user_answer.present? ? user_answer.first.answer_text : '--') %> -
+
<%= to_markdown(check_answer,@request_url) %>
From b679e1f0bfe60ad22605960eda6f00431af459fc Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Mon, 1 Jul 2019 15:48:57 +0800 Subject: [PATCH 188/256] fix bug --- app/templates/exercise_export/blank_exercise.html.erb | 2 +- app/templates/exercise_export/exercise_export.css | 5 +++++ app/templates/exercise_export/exercise_user.html.erb | 4 ++-- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/app/templates/exercise_export/blank_exercise.html.erb b/app/templates/exercise_export/blank_exercise.html.erb index 153ba1514..759a2d2b0 100644 --- a/app/templates/exercise_export/blank_exercise.html.erb +++ b/app/templates/exercise_export/blank_exercise.html.erb @@ -94,7 +94,7 @@ <% elsif q.question_type == 2 %>
<% q.exercise_choices.each do |s| %> - + <%= s.choice_text %> diff --git a/app/templates/exercise_export/exercise_export.css b/app/templates/exercise_export/exercise_export.css index 0c4bf54e5..d2a4fe0de 100644 --- a/app/templates/exercise_export/exercise_export.css +++ b/app/templates/exercise_export/exercise_export.css @@ -331,6 +331,11 @@ textarea{ .mt-2{ margin-top:-2px; } +.ex-scores{ + min-height: 100%; + height: auto !important; + position: relative; +} diff --git a/app/templates/exercise_export/exercise_user.html.erb b/app/templates/exercise_export/exercise_user.html.erb index 7e40047b0..d79379596 100644 --- a/app/templates/exercise_export/exercise_user.html.erb +++ b/app/templates/exercise_export/exercise_user.html.erb @@ -220,8 +220,8 @@ <% check_answer = "--" %> <% end %>
-
答案(填空<%= index+1 %>):
-
<%= to_markdown(check_answer,@request_url) %>
+ 答案(填空<%= index+1 %>): + <%= to_markdown(check_answer,@request_url) %>
<% end %> <% elsif q_type == 4 %> From 90a6f4d7378dd04f8e9839d8c7343ee42ba2ab5b Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Mon, 1 Jul 2019 15:59:19 +0800 Subject: [PATCH 189/256] fix bug --- .../exercise_export/exercise_user.html.erb | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/app/templates/exercise_export/exercise_user.html.erb b/app/templates/exercise_export/exercise_user.html.erb index d79379596..e43af2fb9 100644 --- a/app/templates/exercise_export/exercise_user.html.erb +++ b/app/templates/exercise_export/exercise_user.html.erb @@ -21,8 +21,8 @@

<% if @exercise_single_ques_count > 0 %> - 单选题<%= @exercise_single_ques_count %>题, - 共<%= @exercise_single_ques_scores %> + 单选题<%= @exercise_single_ques_count %>题, + 共<%= @exercise_single_ques_scores %> <% end %> <% if @exercise_double_ques_count > 0 %> 多选题<%= @exercise_double_ques_count %>题, @@ -55,6 +55,7 @@

+
<% if @ex_obj_array.size > 0 %>
@@ -176,15 +177,17 @@ <% end %>
+
<% if q_type == 0 %> <% q.exercise_choices.each do |s| %> <% check_answer = (user_answer.present? && (s.id == user_answer.first.exercise_choice_id)) ? "choose-answer" : '' %> -
+
<%= to_markdown(s.choice_text,@request_url) %>
<% end %> +
<% elsif q_type == 1 %> <% q.exercise_choices.each do |s| %> <% check_answer = (user_answer.present? && (user_answer.pluck(:exercise_choice_id).include?(s.id))) ? true : false %> @@ -197,6 +200,7 @@ <%= to_markdown(s.choice_text,@request_url) %>
<% end %> +
<% elsif q_type == 2 %>
<% q.exercise_choices.each do |s| %> @@ -211,6 +215,7 @@ <% end %>
+
<% elsif q_type == 3 %> <% st_counts = q.exercise_standard_answers.pluck(:exercise_choice_id).uniq %> <% st_counts.each_with_index do |s,index| %> @@ -223,14 +228,16 @@ 答案(填空<%= index+1 %>): <%= to_markdown(check_answer,@request_url) %>
+
<% end %> <% elsif q_type == 4 %> <% check_answer = (user_answer.present? ? user_answer.first.answer_text : '--') %> -
+
<%= to_markdown(check_answer,@request_url) %>
+
<% else %>

@@ -327,6 +334,7 @@

<% end %>
+
<% end %>
From 5e87e88f560ab315caf514975c36ce06cea7be8d Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Mon, 1 Jul 2019 16:17:31 +0800 Subject: [PATCH 190/256] fix bug --- app/controllers/zips_controller.rb | 4 ++-- app/services/exercise_user_pdf_service.rb | 2 +- app/templates/exercise_export/exercise_export.css | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/controllers/zips_controller.rb b/app/controllers/zips_controller.rb index 51761d023..c20546701 100644 --- a/app/controllers/zips_controller.rb +++ b/app/controllers/zips_controller.rb @@ -49,12 +49,12 @@ class ZipsController < ApplicationController @course = @exercise.course default_ex_users = @exercise.all_exercise_users(current_user.id).exercise_user_committed - @ex_users = default_ex_users.limit 2 #仅导出已提交的,截止后则是全部为提交的。 + @ex_users = default_ex_users #仅导出已提交的,截止后则是全部为提交的。 #可以分班选择 if group_id.present? exercise_students = @course.students.where(course_group_id: group_id) # 试卷所分班的全部人数 user_ids = exercise_students.pluck(:user_id).reject(&:blank?).uniq - @ex_users = @ex_users.where(user_id: user_ids).limit 2 + @ex_users = @ex_users.where(user_id: user_ids) end default_ex_users_size = @ex_users.size diff --git a/app/services/exercise_user_pdf_service.rb b/app/services/exercise_user_pdf_service.rb index 44ee1e769..ee055ac66 100644 --- a/app/services/exercise_user_pdf_service.rb +++ b/app/services/exercise_user_pdf_service.rb @@ -41,7 +41,7 @@ class ExerciseUserPdfService # #-----正式需删掉 # aa = File.open(Rails.root.join("public/123.html"),"w+") # aa.syswrite(kit.source) - # #正式需删掉------- + # #正式需删掉-------s file = Tempfile.new(filename) kit.to_pdf(file.path) file diff --git a/app/templates/exercise_export/exercise_export.css b/app/templates/exercise_export/exercise_export.css index d2a4fe0de..bc06800a9 100644 --- a/app/templates/exercise_export/exercise_export.css +++ b/app/templates/exercise_export/exercise_export.css @@ -39,7 +39,7 @@ p{ margin-bottom: 10px; } .mt8{ - margin-top:8px; + margin-top:7px; } .mt10{ margin-top:10px; From bf2f8743aa0ac8ffcaa3a69f3695d4196c2cc20b Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Mon, 1 Jul 2019 16:27:32 +0800 Subject: [PATCH 191/256] fix bug --- app/templates/exercise_export/exercise_export.css | 3 +-- app/templates/exercise_export/exercise_user.html.erb | 8 ++++---- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/app/templates/exercise_export/exercise_export.css b/app/templates/exercise_export/exercise_export.css index bc06800a9..97b070dc3 100644 --- a/app/templates/exercise_export/exercise_export.css +++ b/app/templates/exercise_export/exercise_export.css @@ -333,8 +333,7 @@ textarea{ } .ex-scores{ min-height: 100%; - height: auto !important; - position: relative; + height: auto ; } diff --git a/app/templates/exercise_export/exercise_user.html.erb b/app/templates/exercise_export/exercise_user.html.erb index e43af2fb9..2d41f93fa 100644 --- a/app/templates/exercise_export/exercise_user.html.erb +++ b/app/templates/exercise_export/exercise_user.html.erb @@ -37,12 +37,12 @@ 共<%= @exercise_ques_null_scores %>分 <% end %> <% if @exercise_ques_main_count > 0 %> - 主观题<%= @exercise_ques_main_count %>题, - 共<%= @exercise_ques_main_scores %> + 主观题<%= @exercise_ques_main_count %>题, + 共<%= @exercise_ques_main_scores %> <% end %> <% if @exercise_ques_shixun_count > 0 %> - 实训题<%= @exercise_ques_shixun_count %>题, - 共<%= @exercise_ques_shixun_scores %> + 实训题<%= @exercise_ques_shixun_count %>题, + 共<%= @exercise_ques_shixun_scores %> <% end %> <% if @exercise_ques_count > 0 %> From f4602d1d5cbfa59d3a97ffc720a2e3d2a8f6dae0 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Mon, 1 Jul 2019 16:38:58 +0800 Subject: [PATCH 192/256] fixu bug --- app/templates/exercise_export/exercise_export.css | 1 - app/templates/exercise_export/exercise_user.html.erb | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/app/templates/exercise_export/exercise_export.css b/app/templates/exercise_export/exercise_export.css index 97b070dc3..1cfa57c80 100644 --- a/app/templates/exercise_export/exercise_export.css +++ b/app/templates/exercise_export/exercise_export.css @@ -332,7 +332,6 @@ textarea{ margin-top:-2px; } .ex-scores{ - min-height: 100%; height: auto ; } diff --git a/app/templates/exercise_export/exercise_user.html.erb b/app/templates/exercise_export/exercise_user.html.erb index 2d41f93fa..bb50f7edf 100644 --- a/app/templates/exercise_export/exercise_user.html.erb +++ b/app/templates/exercise_export/exercise_user.html.erb @@ -182,7 +182,7 @@ <% if q_type == 0 %> <% q.exercise_choices.each do |s| %> <% check_answer = (user_answer.present? && (s.id == user_answer.first.exercise_choice_id)) ? "choose-answer" : '' %> -
+
<%= to_markdown(s.choice_text,@request_url) %>
From 0aa403ff757e39fdf3eaffb0c7f9f691a3ccff6b Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Mon, 1 Jul 2019 17:18:25 +0800 Subject: [PATCH 193/256] =?UTF-8?q?=E5=AE=9E=E8=AE=AD=E4=BD=9C=E4=B8=9A?= =?UTF-8?q?=E7=AE=97=E5=88=86=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 | 20 ++++++++++--------- app/controllers/myshixuns_controller.rb | 2 +- app/models/homework_common.rb | 5 +++++ app/services/homeworks_service.rb | 2 +- lib/tasks/homework_publishtime.rake | 4 ++-- 5 files changed, 20 insertions(+), 13 deletions(-) diff --git a/app/controllers/homework_commons_controller.rb b/app/controllers/homework_commons_controller.rb index 3562be4f3..aaffc34a6 100644 --- a/app/controllers/homework_commons_controller.rb +++ b/app/controllers/homework_commons_controller.rb @@ -238,7 +238,7 @@ class HomeworkCommonsController < ApplicationController end def update_score - tip_exception("作业还未发布,暂不能计算成绩") if @homework.publish_time.nil? || @homework.publish_time > Time.now + tip_exception("作业还未发布,暂不能计算成绩") if @homework.end_or_late_none_group begin if @homework.unified_setting student_works = @homework.student_works @@ -258,6 +258,8 @@ class HomeworkCommonsController < ApplicationController HomeworksService.new.update_myshixun_work_score work, myshixun, games, @homework, challenge_settings end end + HomeworksService.new.update_student_eff_score @homework if (@homework.allow_late && @homework.late_time < Time.now) || + (!@homework.allow_late && @homework.end_time < Time.now) @homework.update_attribute('calculation_time', Time.now) normal_status("更新成功") rescue Exception => e @@ -606,14 +608,14 @@ class HomeworkCommonsController < ApplicationController @homework.score_open = params[:score_open] @homework.save! - if score_change - @homework.student_works.has_committed.each do |student_work| - HomeworksService.new.set_shixun_final_score student_work - end - end + # if score_change + # @homework.student_works.has_committed.each do |student_work| + # HomeworksService.new.set_shixun_final_score student_work + # end + # end # 更新所有学生的效率分(作业允许补交且补交已截止 或者 作业不允许补交且提交已截止) - if (score_change || update_eff_score) && @homework.end_or_late + if update_eff_score && @homework.end_or_late_none_group HomeworksService.new.update_student_eff_score HomeworkCommon.find_by(id: @homework.id) end @@ -1017,8 +1019,8 @@ class HomeworkCommonsController < ApplicationController homework.save! - # 更新学生状态及成绩 - HomeworkPublishUpdateWorkStatusJob.perform_later(tiding_group_ids, homework.id) + # 更新学生状态及成绩(手动点击计算) + # HomeworkPublishUpdateWorkStatusJob.perform_later(tiding_group_ids, homework.id) end normal_status(0, "发布成功") rescue Exception => e diff --git a/app/controllers/myshixuns_controller.rb b/app/controllers/myshixuns_controller.rb index 909533301..9c3847b3c 100644 --- a/app/controllers/myshixuns_controller.rb +++ b/app/controllers/myshixuns_controller.rb @@ -167,7 +167,7 @@ class MyshixunsController < ApplicationController end # 更新实训关联的作品分数 TODO: 更新作品分数 - HomeworksService.new.update_myshixun_work_score myshixun + # HomeworksService.new.update_myshixun_work_score myshixun end # 如果过关了,下一关的状态是3(为开启),则需要把状态改成1(已开启) # next_game = game.next_game diff --git a/app/models/homework_common.rb b/app/models/homework_common.rb index 8f24820e7..3e0bec5fe 100644 --- a/app/models/homework_common.rb +++ b/app/models/homework_common.rb @@ -118,6 +118,11 @@ class HomeworkCommon < ApplicationRecord status end + # 作业是否补交截止或者不允许补交且提交截止(不考虑分班) + def end_or_late_none_group + course.is_end || (allow_late && late_time < Time.now) || (!allow_late && end_time < Time.now) + end + # 作业是否可以查重 def code_review self.homework_type == 'practice' && self.publish_time.present? && self.publish_time < Time.now && self.homework_group_reviews.count == 0 diff --git a/app/services/homeworks_service.rb b/app/services/homeworks_service.rb index 48db76295..306a48d3c 100644 --- a/app/services/homeworks_service.rb +++ b/app/services/homeworks_service.rb @@ -156,7 +156,7 @@ class HomeworksService end # 用户评测时更新实训作业成绩 - def update_myshixun_work_score myshixun + def update_myshixun_work_score_old myshixun ActiveRecord::Base.transaction do student_works = myshixun.student_works.where(user_id: myshixun.user_id) #logger.info("#############student_works_count: #{student_works.count}") diff --git a/lib/tasks/homework_publishtime.rake b/lib/tasks/homework_publishtime.rake index 7ee2a4a07..4127a9339 100644 --- a/lib/tasks/homework_publishtime.rake +++ b/lib/tasks/homework_publishtime.rake @@ -23,7 +23,7 @@ namespace :homework_publishtime do homework_detail_manual.update_column('comment_status', 1) # 统一设置的作业在这发消息,非统一设置的只给有全部分班权限的老师发 if homework.unified_setting - HomeworkPublishUpdateWorkStatusJob.perform_later(nil, homework.id) + # HomeworkPublishUpdateWorkStatusJob.perform_later(nil, homework.id) HomeworkCommonPushNotifyJob.perform_later(homework.id, nil) else course = homework.course @@ -53,7 +53,7 @@ namespace :homework_publishtime do homework_group_settings.each do |homework_group| homework = homework_group.homework_common if homework.present? - HomeworkPublishUpdateWorkStatusJob.perform_now([homework_group.id], homework.id) + # HomeworkPublishUpdateWorkStatusJob.perform_now([homework_group.id], homework.id) HomeworkCommonPushNotifyJob.perform_later(homework.id, [homework_group.course_group_id]) end end From 148ac868e772afe6b1058388f0e5ad9802dbcc22 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Mon, 1 Jul 2019 17:18:58 +0800 Subject: [PATCH 194/256] fix bug --- app/services/exercise_user_pdf_service.rb | 1 + .../exercise_export/exercise_export.css | 1 + .../exercise_export/exercise_user.html.erb | 23 +++++++++++-------- 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/app/services/exercise_user_pdf_service.rb b/app/services/exercise_user_pdf_service.rb index ee055ac66..f0f7c1ac1 100644 --- a/app/services/exercise_user_pdf_service.rb +++ b/app/services/exercise_user_pdf_service.rb @@ -2,6 +2,7 @@ class ExerciseUserPdfService include ExercisesHelper include ApplicationHelper include StudentWorksHelper + include GitHelper attr_reader :exercise, :ex_user, :request_url diff --git a/app/templates/exercise_export/exercise_export.css b/app/templates/exercise_export/exercise_export.css index 1cfa57c80..c2b054666 100644 --- a/app/templates/exercise_export/exercise_export.css +++ b/app/templates/exercise_export/exercise_export.css @@ -333,6 +333,7 @@ textarea{ } .ex-scores{ height: auto ; + word-break: break-all; } diff --git a/app/templates/exercise_export/exercise_user.html.erb b/app/templates/exercise_export/exercise_user.html.erb index bb50f7edf..ea782e23b 100644 --- a/app/templates/exercise_export/exercise_user.html.erb +++ b/app/templates/exercise_export/exercise_user.html.erb @@ -316,20 +316,23 @@ <% end %> - <% if game.try(:lastest_code).present? && game.challenge.st == 0 %> - <% con_rows = content_line(game.lastest_code) %> -
-

+ <% if game.try(:lastest_code).blank? %> + <% cha_path = challenge_path(game.challenge&.path) %> + <% latest_code = git_fle_content(game.myshixun.repo_path,cha_path) %> + <% else %> + <% latest_code = game.try(:lastest_code) %> + <% end %> +

+

最近通过的代码 - <%= game.challenge.path %> + <%= game.challenge&.path %> -

-
- -
+

+
+
- <% end %> +
<% end %> From 4e435cca0f7c96f03222a252bb935b729b0d6131 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Mon, 1 Jul 2019 17:21:42 +0800 Subject: [PATCH 195/256] fix bug --- app/controllers/concerns/git_helper.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/controllers/concerns/git_helper.rb b/app/controllers/concerns/git_helper.rb index 8d769a244..65ebd4074 100644 --- a/app/controllers/concerns/git_helper.rb +++ b/app/controllers/concerns/git_helper.rb @@ -9,17 +9,17 @@ module GitHelper # 版本库文件内容,带转码 def git_fle_content(repo_path, path) begin - logger.info("git file content: repo_path is #{repo_path}, path is #{path}") + Rails.logger.info("git file content: repo_path is #{repo_path}, path is #{path}") content = GitService.file_content(repo_path: repo_path, path: path) - logger.info("git file content: content is #{content}") + Rails.logger.info("git file content: content is #{content}") decode_content = nil if content.present? content = content["content"] #6.24 -hs 这个为新增,因为当实训题里含有选择题时,这里会报错,undefined method `[]' for nil:NilClass content = Base64.decode64(content) cd = CharDet.detect(content) - logger.info "encoding: #{cd['encoding']} confidence: #{cd['confidence']}" + Rails.logger.info "encoding: #{cd['encoding']} confidence: #{cd['confidence']}" decode_content = if cd["encoding"] == 'GB18030' && cd['confidence'] > 0.8 From ee04d36e978b1afba99a21464385001e40a13a6c Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Mon, 1 Jul 2019 17:23:59 +0800 Subject: [PATCH 196/256] fix bug --- app/templates/exercise_export/exercise_export.css | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/templates/exercise_export/exercise_export.css b/app/templates/exercise_export/exercise_export.css index c2b054666..b7f4892c1 100644 --- a/app/templates/exercise_export/exercise_export.css +++ b/app/templates/exercise_export/exercise_export.css @@ -315,10 +315,12 @@ table td{ /*}*/ textarea{ width:100%; + height:100%; resize:none; border:none; background-color:#eee; line-height:2; + } .clearfix{ clear:both; @@ -339,3 +341,4 @@ textarea{ + From 8a88b57a321d21ce050d40c3898f18ded89c0af7 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Mon, 1 Jul 2019 17:27:10 +0800 Subject: [PATCH 197/256] fix bug --- app/helpers/exercises_helper.rb | 2 +- app/templates/exercise_export/exercise_export.css | 1 - app/templates/exercise_export/exercise_user.html.erb | 3 ++- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/helpers/exercises_helper.rb b/app/helpers/exercises_helper.rb index 1442e1da3..437965ca6 100644 --- a/app/helpers/exercises_helper.rb +++ b/app/helpers/exercises_helper.rb @@ -734,6 +734,6 @@ module ExercisesHelper #实训题学生代码的行数 def content_line(content) - content.split(/\r?\n/).length + content.split(/\r?\n/).length + 1 end end diff --git a/app/templates/exercise_export/exercise_export.css b/app/templates/exercise_export/exercise_export.css index b7f4892c1..407a39b1f 100644 --- a/app/templates/exercise_export/exercise_export.css +++ b/app/templates/exercise_export/exercise_export.css @@ -315,7 +315,6 @@ table td{ /*}*/ textarea{ width:100%; - height:100%; resize:none; border:none; background-color:#eee; diff --git a/app/templates/exercise_export/exercise_user.html.erb b/app/templates/exercise_export/exercise_user.html.erb index ea782e23b..52a083eab 100644 --- a/app/templates/exercise_export/exercise_user.html.erb +++ b/app/templates/exercise_export/exercise_user.html.erb @@ -322,6 +322,7 @@ <% else %> <% latest_code = game.try(:lastest_code) %> <% end %> + <% con_rows = content_line(latest_code) %>

@@ -330,7 +331,7 @@

- +
From fa692a25353d18b5737218f67a334c9e00bd1de2 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Mon, 1 Jul 2019 17:37:22 +0800 Subject: [PATCH 198/256] fix bug --- app/templates/exercise_export/exercise_user.html.erb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/templates/exercise_export/exercise_user.html.erb b/app/templates/exercise_export/exercise_user.html.erb index 52a083eab..fa5060a1e 100644 --- a/app/templates/exercise_export/exercise_user.html.erb +++ b/app/templates/exercise_export/exercise_user.html.erb @@ -17,8 +17,8 @@

-
-
+
+

<% if @exercise_single_ques_count > 0 %> 单选题<%= @exercise_single_ques_count %>题, From 4904e536a262eebd6713e1ca5a3b3a5dba676272 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Mon, 1 Jul 2019 17:38:32 +0800 Subject: [PATCH 199/256] fix bug --- app/templates/exercise_export/exercise_export.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/templates/exercise_export/exercise_export.css b/app/templates/exercise_export/exercise_export.css index 407a39b1f..09d8f0268 100644 --- a/app/templates/exercise_export/exercise_export.css +++ b/app/templates/exercise_export/exercise_export.css @@ -333,7 +333,7 @@ textarea{ margin-top:-2px; } .ex-scores{ - height: auto ; + height: 100% ; word-break: break-all; } From feca48a4574c4b21acb7307bdeaddc7d1bbd9f63 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Mon, 1 Jul 2019 17:40:56 +0800 Subject: [PATCH 200/256] fix bug --- app/templates/exercise_export/exercise_export.css | 4 +++- app/templates/exercise_export/exercise_user.html.erb | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/app/templates/exercise_export/exercise_export.css b/app/templates/exercise_export/exercise_export.css index 09d8f0268..828987bb7 100644 --- a/app/templates/exercise_export/exercise_export.css +++ b/app/templates/exercise_export/exercise_export.css @@ -333,7 +333,8 @@ textarea{ margin-top:-2px; } .ex-scores{ - height: 100% ; + width:100%; + display:inline-block; word-break: break-all; } @@ -341,3 +342,4 @@ textarea{ + diff --git a/app/templates/exercise_export/exercise_user.html.erb b/app/templates/exercise_export/exercise_user.html.erb index fa5060a1e..52a083eab 100644 --- a/app/templates/exercise_export/exercise_user.html.erb +++ b/app/templates/exercise_export/exercise_user.html.erb @@ -17,8 +17,8 @@

-
-
+
+

<% if @exercise_single_ques_count > 0 %> 单选题<%= @exercise_single_ques_count %>题, From 68ad44129febc0310a9ae316c92142d6f267c456 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Mon, 1 Jul 2019 17:42:34 +0800 Subject: [PATCH 201/256] fix bug --- app/templates/exercise_export/exercise_export.css | 3 +++ app/templates/exercise_export/exercise_user.html.erb | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/app/templates/exercise_export/exercise_export.css b/app/templates/exercise_export/exercise_export.css index 828987bb7..8e950f7ed 100644 --- a/app/templates/exercise_export/exercise_export.css +++ b/app/templates/exercise_export/exercise_export.css @@ -332,6 +332,9 @@ textarea{ .mt-2{ margin-top:-2px; } +.width100{ + width:100%; +} .ex-scores{ width:100%; display:inline-block; diff --git a/app/templates/exercise_export/exercise_user.html.erb b/app/templates/exercise_export/exercise_user.html.erb index 52a083eab..7e3a5a64f 100644 --- a/app/templates/exercise_export/exercise_user.html.erb +++ b/app/templates/exercise_export/exercise_user.html.erb @@ -17,7 +17,7 @@

-
+

<% if @exercise_single_ques_count > 0 %> From 479df01b7a28c0c1d999b2d71112a5ef0d30fd06 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Mon, 1 Jul 2019 17:44:17 +0800 Subject: [PATCH 202/256] fix bug --- app/templates/exercise_export/exercise_export.css | 8 ++++---- app/templates/exercise_export/exercise_user.html.erb | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/templates/exercise_export/exercise_export.css b/app/templates/exercise_export/exercise_export.css index 8e950f7ed..66bd565b1 100644 --- a/app/templates/exercise_export/exercise_export.css +++ b/app/templates/exercise_export/exercise_export.css @@ -332,11 +332,11 @@ textarea{ .mt-2{ margin-top:-2px; } -.width100{ - width:100%; -} +/*.width100{*/ + /*width:100%;*/ +/*}*/ .ex-scores{ - width:100%; + /*width:100%;*/ display:inline-block; word-break: break-all; } diff --git a/app/templates/exercise_export/exercise_user.html.erb b/app/templates/exercise_export/exercise_user.html.erb index 7e3a5a64f..52a083eab 100644 --- a/app/templates/exercise_export/exercise_user.html.erb +++ b/app/templates/exercise_export/exercise_user.html.erb @@ -17,7 +17,7 @@

-
+

<% if @exercise_single_ques_count > 0 %> From 65c7dafb8208a7b1f4a8211702eb4a4b0d168ff5 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Tue, 2 Jul 2019 08:41:22 +0800 Subject: [PATCH 203/256] fix bug --- .../exercise_export/blank_exercise.html.erb | 28 +++++++++------ .../exercise_export/exercise_user.html.erb | 34 +++++++++++-------- 2 files changed, 36 insertions(+), 26 deletions(-) diff --git a/app/templates/exercise_export/blank_exercise.html.erb b/app/templates/exercise_export/blank_exercise.html.erb index 759a2d2b0..45a086e6e 100644 --- a/app/templates/exercise_export/blank_exercise.html.erb +++ b/app/templates/exercise_export/blank_exercise.html.erb @@ -20,41 +20,47 @@

- <% if @exercise_single_ques_count > 0 %> + + <% if @exercise_single_ques_count > 0 %> 单选题<%= @exercise_single_ques_count %>题, 共<%= @exercise_single_ques_scores %> <% end %> - <% if @exercise_double_ques_count > 0 %> + <% if @exercise_double_ques_count > 0 %> 多选题<%= @exercise_double_ques_count %>题, 共<%= @exercise_double_ques_scores %> <% end %> - <% if @exercise_ques_judge_count > 0 %> + <% if @exercise_ques_judge_count > 0 %> 判断题<%= @exercise_ques_judge_count %>题, 共<%= @exercise_ques_judge_scores %> <% end %> - <% if @exercise_ques_null_count > 0 %> + <% if @exercise_ques_null_count > 0 %> 填空题<%= @exercise_ques_null_count %>题, 共<%= @exercise_ques_null_scores %> <% end %> - <% if @exercise_ques_main_count > 0 %> + <% if @exercise_ques_main_count > 0 %> 主观题<%= @exercise_ques_main_count %>题, 共<%= @exercise_ques_main_scores %> <% end %> - <% if @exercise_ques_shixun_count > 0 %> + <% if @exercise_ques_shixun_count > 0 %> 实训题<%= @exercise_ques_shixun_count %>题, 共<%= @exercise_ques_shixun_scores %> <% end %> - <% if @exercise_ques_count > 0 %> - - 共<%= @exercise_ques_scores %>分 - - + + + + <% if @exercise_ques_count > 0 %> + 合计<%= @exercise_ques_count %> + + 共<%= @exercise_ques_scores %>分 + <% end %> +

+
<% @exercise_questions.each do |q| %>
diff --git a/app/templates/exercise_export/exercise_user.html.erb b/app/templates/exercise_export/exercise_user.html.erb index 52a083eab..ba47d6b02 100644 --- a/app/templates/exercise_export/exercise_user.html.erb +++ b/app/templates/exercise_export/exercise_user.html.erb @@ -20,38 +20,42 @@

- <% if @exercise_single_ques_count > 0 %> + + <% if @exercise_single_ques_count > 0 %> 单选题<%= @exercise_single_ques_count %>题, 共<%= @exercise_single_ques_scores %> <% end %> - <% if @exercise_double_ques_count > 0 %> + <% if @exercise_double_ques_count > 0 %> 多选题<%= @exercise_double_ques_count %>题, 共<%= @exercise_double_ques_scores %> <% end %> - <% if @exercise_ques_judge_count > 0 %> + <% if @exercise_ques_judge_count > 0 %> 判断题<%= @exercise_ques_judge_count %>题, 共<%= @exercise_ques_judge_scores %> <% end %> - <% if @exercise_ques_null_count > 0 %> + <% if @exercise_ques_null_count > 0 %> 填空题<%= @exercise_ques_null_count %>题, 共<%= @exercise_ques_null_scores %> <% end %> - <% if @exercise_ques_main_count > 0 %> - 主观题<%= @exercise_ques_main_count %>题, - 共<%= @exercise_ques_main_scores %> + <% if @exercise_ques_main_count > 0 %> + 主观题<%= @exercise_ques_main_count %>题, + 共<%= @exercise_ques_main_scores %> <% end %> - <% if @exercise_ques_shixun_count > 0 %> - 实训题<%= @exercise_ques_shixun_count %>题, - 共<%= @exercise_ques_shixun_scores %> + <% if @exercise_ques_shixun_count > 0 %> + 实训题<%= @exercise_ques_shixun_count %>题, + 共<%= @exercise_ques_shixun_scores %> <% end %> - <% if @exercise_ques_count > 0 %> - - 共<%= @exercise_ques_scores %>分 - - + + + <% if @exercise_ques_count > 0 %> + 合计<%= @exercise_ques_count %> + + 共<%= @exercise_ques_scores %>分 + <% end %> +

From 4267b8d32cf5eea0876e83fa833fedeb266813ca Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Tue, 2 Jul 2019 08:46:36 +0800 Subject: [PATCH 204/256] fix bug --- app/templates/exercise_export/exercise_export.css | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/templates/exercise_export/exercise_export.css b/app/templates/exercise_export/exercise_export.css index 66bd565b1..cdb4adc32 100644 --- a/app/templates/exercise_export/exercise_export.css +++ b/app/templates/exercise_export/exercise_export.css @@ -2,6 +2,9 @@ body{ font-size:14px; font-family: "微软雅黑","宋体"; } +.container{ + width:1200px; +} p{ margin:0; } From b6cd30946ae494b6ecbbe7411c0c91698296acab Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Tue, 2 Jul 2019 08:49:48 +0800 Subject: [PATCH 205/256] fix bug --- app/templates/exercise_export/blank_exercise.html.erb | 2 +- app/templates/exercise_export/exercise_export.css | 10 ++++------ app/templates/exercise_export/exercise_user.html.erb | 2 +- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/app/templates/exercise_export/blank_exercise.html.erb b/app/templates/exercise_export/blank_exercise.html.erb index 45a086e6e..37900d983 100644 --- a/app/templates/exercise_export/blank_exercise.html.erb +++ b/app/templates/exercise_export/blank_exercise.html.erb @@ -19,7 +19,7 @@
-

+

<% if @exercise_single_ques_count > 0 %> 单选题<%= @exercise_single_ques_count %>题, diff --git a/app/templates/exercise_export/exercise_export.css b/app/templates/exercise_export/exercise_export.css index cdb4adc32..6e2ecd8b3 100644 --- a/app/templates/exercise_export/exercise_export.css +++ b/app/templates/exercise_export/exercise_export.css @@ -2,9 +2,7 @@ body{ font-size:14px; font-family: "微软雅黑","宋体"; } -.container{ - width:1200px; -} + p{ margin:0; } @@ -335,9 +333,9 @@ textarea{ .mt-2{ margin-top:-2px; } -/*.width100{*/ - /*width:100%;*/ -/*}*/ +.width100{ + width:100%; +} .ex-scores{ /*width:100%;*/ display:inline-block; diff --git a/app/templates/exercise_export/exercise_user.html.erb b/app/templates/exercise_export/exercise_user.html.erb index ba47d6b02..9b2fef1e0 100644 --- a/app/templates/exercise_export/exercise_user.html.erb +++ b/app/templates/exercise_export/exercise_user.html.erb @@ -19,7 +19,7 @@

-

+

<% if @exercise_single_ques_count > 0 %> 单选题<%= @exercise_single_ques_count %>题, From 402562144dbb0978aa60452443af9c7656138c35 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Tue, 2 Jul 2019 08:53:17 +0800 Subject: [PATCH 206/256] fix bug --- app/templates/exercise_export/exercise_export.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/templates/exercise_export/exercise_export.css b/app/templates/exercise_export/exercise_export.css index 6e2ecd8b3..e34eefedc 100644 --- a/app/templates/exercise_export/exercise_export.css +++ b/app/templates/exercise_export/exercise_export.css @@ -338,7 +338,7 @@ textarea{ } .ex-scores{ /*width:100%;*/ - display:inline-block; + /*display:inline-block;*/ word-break: break-all; } From 7be1a7901cfd806612e59758181c1f5a6d6b3170 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Tue, 2 Jul 2019 08:56:16 +0800 Subject: [PATCH 207/256] fix bug --- app/templates/exercise_export/exercise_export.css | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/templates/exercise_export/exercise_export.css b/app/templates/exercise_export/exercise_export.css index e34eefedc..2e5f77a11 100644 --- a/app/templates/exercise_export/exercise_export.css +++ b/app/templates/exercise_export/exercise_export.css @@ -337,8 +337,8 @@ textarea{ width:100%; } .ex-scores{ - /*width:100%;*/ - /*display:inline-block;*/ + width:100%; + display:inline-block; word-break: break-all; } From 684084cc6387dc56e2b9195bd7dbd8c69cf8572a Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Tue, 2 Jul 2019 09:02:43 +0800 Subject: [PATCH 208/256] fix bug --- app/controllers/exercises_controller.rb | 2 +- app/templates/exercise_export/blank_exercise.html.erb | 2 +- app/templates/exercise_export/exercise_user.html.erb | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/controllers/exercises_controller.rb b/app/controllers/exercises_controller.rb index 3c364b979..aee99fbab 100644 --- a/app/controllers/exercises_controller.rb +++ b/app/controllers/exercises_controller.rb @@ -1335,7 +1335,7 @@ class ExercisesController < ApplicationController def export_exercise @request_url = request.base_url @exercise_questions = @exercise.exercise_questions.includes(:exercise_choices).order("question_number ASC") - filename = "#{current_user.real_name}_#{@course.name}_#{@exercise.exercise_name}_#{Time.current.strftime('%Y%m%d%H%M%S')}.pdf" + filename = "#{@exercise.user.real_name}_#{@exercise.exercise_name}_#{Time.current.strftime('%Y%m%d%H%M%S')}.pdf" stylesheets = "#{Rails.root}/app/templates/exercise_export/exercise_export.css" render pdf: 'exercise_export/blank_exercise', filename: filename, stylesheets: stylesheets end diff --git a/app/templates/exercise_export/blank_exercise.html.erb b/app/templates/exercise_export/blank_exercise.html.erb index 37900d983..48bb1567f 100644 --- a/app/templates/exercise_export/blank_exercise.html.erb +++ b/app/templates/exercise_export/blank_exercise.html.erb @@ -19,7 +19,7 @@

-

+

<% if @exercise_single_ques_count > 0 %> 单选题<%= @exercise_single_ques_count %>题, diff --git a/app/templates/exercise_export/exercise_user.html.erb b/app/templates/exercise_export/exercise_user.html.erb index 9b2fef1e0..42d25dd1b 100644 --- a/app/templates/exercise_export/exercise_user.html.erb +++ b/app/templates/exercise_export/exercise_user.html.erb @@ -19,7 +19,7 @@

-

+

<% if @exercise_single_ques_count > 0 %> 单选题<%= @exercise_single_ques_count %>题, From 5d3cb93b35f6b1319423f7d017d178d9d721bb96 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Tue, 2 Jul 2019 09:10:22 +0800 Subject: [PATCH 209/256] fi xbug --- app/templates/exercise_export/exercise_user.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/templates/exercise_export/exercise_user.html.erb b/app/templates/exercise_export/exercise_user.html.erb index 42d25dd1b..934ca6586 100644 --- a/app/templates/exercise_export/exercise_user.html.erb +++ b/app/templates/exercise_export/exercise_user.html.erb @@ -17,7 +17,7 @@

-
+

From e178f32db50613624c0fbaba460ccd6245133b03 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Tue, 2 Jul 2019 09:32:22 +0800 Subject: [PATCH 210/256] fix bug --- app/controllers/exercises_controller.rb | 2 +- app/controllers/zips_controller.rb | 4 ++-- app/services/exercise_user_pdf_service.rb | 4 ++-- app/services/export_exercises_service.rb | 2 +- .../exercise_export/blank_exercise.html.erb | 19 ++++++++----------- .../exercise_export/exercise_export.css | 4 ++-- .../exercise_export/exercise_user.html.erb | 16 +++++++--------- 7 files changed, 23 insertions(+), 28 deletions(-) diff --git a/app/controllers/exercises_controller.rb b/app/controllers/exercises_controller.rb index aee99fbab..ff4dc6be9 100644 --- a/app/controllers/exercises_controller.rb +++ b/app/controllers/exercises_controller.rb @@ -1335,7 +1335,7 @@ class ExercisesController < ApplicationController def export_exercise @request_url = request.base_url @exercise_questions = @exercise.exercise_questions.includes(:exercise_choices).order("question_number ASC") - filename = "#{@exercise.user.real_name}_#{@exercise.exercise_name}_#{Time.current.strftime('%Y%m%d%H%M%S')}.pdf" + filename = "#{@exercise.user.real_name}_#{@exercise.exercise_name}_#{Time.current.strftime('%Y%m%d_%H%M')}.pdf" stylesheets = "#{Rails.root}/app/templates/exercise_export/exercise_export.css" render pdf: 'exercise_export/blank_exercise', filename: filename, stylesheets: stylesheets end diff --git a/app/controllers/zips_controller.rb b/app/controllers/zips_controller.rb index c20546701..51761d023 100644 --- a/app/controllers/zips_controller.rb +++ b/app/controllers/zips_controller.rb @@ -49,12 +49,12 @@ class ZipsController < ApplicationController @course = @exercise.course default_ex_users = @exercise.all_exercise_users(current_user.id).exercise_user_committed - @ex_users = default_ex_users #仅导出已提交的,截止后则是全部为提交的。 + @ex_users = default_ex_users.limit 2 #仅导出已提交的,截止后则是全部为提交的。 #可以分班选择 if group_id.present? exercise_students = @course.students.where(course_group_id: group_id) # 试卷所分班的全部人数 user_ids = exercise_students.pluck(:user_id).reject(&:blank?).uniq - @ex_users = @ex_users.where(user_id: user_ids) + @ex_users = @ex_users.where(user_id: user_ids).limit 2 end default_ex_users_size = @ex_users.size diff --git a/app/services/exercise_user_pdf_service.rb b/app/services/exercise_user_pdf_service.rb index f0f7c1ac1..73711192f 100644 --- a/app/services/exercise_user_pdf_service.rb +++ b/app/services/exercise_user_pdf_service.rb @@ -15,8 +15,8 @@ class ExerciseUserPdfService end def filename - user_course = @course.course_members.find_by(user_id:@ex_user_user.id).course_group_name - exercise_user_name = user_course + "_" + exercise.exercise_name + "_" + @ex_user_user.real_name + user_course = @course.course_members.find_by(user_id:@ex_user_user.id)&.course_group_name + exercise_user_name = "#{@ex_user_user.real_name}_#{user_course.present? ? user_course : "未分班"}_#{exercise.exercise_name}_#{Time.now.strftime('%Y%m%d_%H%M')}" "#{exercise_user_name.strip}.pdf" end diff --git a/app/services/export_exercises_service.rb b/app/services/export_exercises_service.rb index f83323d7e..3aac67713 100644 --- a/app/services/export_exercises_service.rb +++ b/app/services/export_exercises_service.rb @@ -10,7 +10,7 @@ class ExportExercisesService end def filename - exercise_export_name = exercise.user.real_name + "_" + exercise.exercise_name + "_" + Time.now.strftime('%Y%m%d_%H%M%S') + exercise_export_name = "#{exercise.user.real_name}_#{exercise.exercise_name}_#{Time.now.strftime('%Y%m%d_%H%M')}" "#{exercise_export_name.strip}.zip" end diff --git a/app/templates/exercise_export/blank_exercise.html.erb b/app/templates/exercise_export/blank_exercise.html.erb index 48bb1567f..bb7b28f22 100644 --- a/app/templates/exercise_export/blank_exercise.html.erb +++ b/app/templates/exercise_export/blank_exercise.html.erb @@ -17,37 +17,34 @@

-
+
-

- - <% if @exercise_single_ques_count > 0 %> +

+ <% if @exercise_single_ques_count > 0 %> 单选题<%= @exercise_single_ques_count %>题, 共<%= @exercise_single_ques_scores %> <% end %> - <% if @exercise_double_ques_count > 0 %> + <% if @exercise_double_ques_count > 0 %> 多选题<%= @exercise_double_ques_count %>题, 共<%= @exercise_double_ques_scores %> <% end %> - <% if @exercise_ques_judge_count > 0 %> + <% if @exercise_ques_judge_count > 0 %> 判断题<%= @exercise_ques_judge_count %>题, 共<%= @exercise_ques_judge_scores %> <% end %> - <% if @exercise_ques_null_count > 0 %> + <% if @exercise_ques_null_count > 0 %> 填空题<%= @exercise_ques_null_count %>题, 共<%= @exercise_ques_null_scores %> <% end %> - <% if @exercise_ques_main_count > 0 %> + <% if @exercise_ques_main_count > 0 %> 主观题<%= @exercise_ques_main_count %>题, 共<%= @exercise_ques_main_scores %> <% end %> - <% if @exercise_ques_shixun_count > 0 %> + <% if @exercise_ques_shixun_count > 0 %> 实训题<%= @exercise_ques_shixun_count %>题, 共<%= @exercise_ques_shixun_scores %> <% end %> - - <% if @exercise_ques_count > 0 %> 合计<%= @exercise_ques_count %>题 diff --git a/app/templates/exercise_export/exercise_export.css b/app/templates/exercise_export/exercise_export.css index 2e5f77a11..e34eefedc 100644 --- a/app/templates/exercise_export/exercise_export.css +++ b/app/templates/exercise_export/exercise_export.css @@ -337,8 +337,8 @@ textarea{ width:100%; } .ex-scores{ - width:100%; - display:inline-block; + /*width:100%;*/ + /*display:inline-block;*/ word-break: break-all; } diff --git a/app/templates/exercise_export/exercise_user.html.erb b/app/templates/exercise_export/exercise_user.html.erb index 934ca6586..847820d57 100644 --- a/app/templates/exercise_export/exercise_user.html.erb +++ b/app/templates/exercise_export/exercise_user.html.erb @@ -19,33 +19,31 @@

-

- - <% if @exercise_single_ques_count > 0 %> +

+ <% if @exercise_single_ques_count > 0 %> 单选题<%= @exercise_single_ques_count %>题, 共<%= @exercise_single_ques_scores %> <% end %> - <% if @exercise_double_ques_count > 0 %> + <% if @exercise_double_ques_count > 0 %> 多选题<%= @exercise_double_ques_count %>题, 共<%= @exercise_double_ques_scores %> <% end %> - <% if @exercise_ques_judge_count > 0 %> + <% if @exercise_ques_judge_count > 0 %> 判断题<%= @exercise_ques_judge_count %>题, 共<%= @exercise_ques_judge_scores %> <% end %> - <% if @exercise_ques_null_count > 0 %> + <% if @exercise_ques_null_count > 0 %> 填空题<%= @exercise_ques_null_count %>题, 共<%= @exercise_ques_null_scores %> <% end %> - <% if @exercise_ques_main_count > 0 %> + <% if @exercise_ques_main_count > 0 %> 主观题<%= @exercise_ques_main_count %>题, 共<%= @exercise_ques_main_scores %> <% end %> - <% if @exercise_ques_shixun_count > 0 %> + <% if @exercise_ques_shixun_count > 0 %> 实训题<%= @exercise_ques_shixun_count %>题, 共<%= @exercise_ques_shixun_scores %> <% end %> - <% if @exercise_ques_count > 0 %> From ce2344eecd1ebc4bc703ded6434655e8ec31970a Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Tue, 2 Jul 2019 09:44:14 +0800 Subject: [PATCH 211/256] fix bug --- app/controllers/zips_controller.rb | 4 ++-- app/templates/exercise_export/blank_exercise.html.erb | 2 +- app/templates/exercise_export/exercise_export.css | 1 + app/templates/exercise_export/exercise_user.html.erb | 2 +- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/app/controllers/zips_controller.rb b/app/controllers/zips_controller.rb index 51761d023..c20546701 100644 --- a/app/controllers/zips_controller.rb +++ b/app/controllers/zips_controller.rb @@ -49,12 +49,12 @@ class ZipsController < ApplicationController @course = @exercise.course default_ex_users = @exercise.all_exercise_users(current_user.id).exercise_user_committed - @ex_users = default_ex_users.limit 2 #仅导出已提交的,截止后则是全部为提交的。 + @ex_users = default_ex_users #仅导出已提交的,截止后则是全部为提交的。 #可以分班选择 if group_id.present? exercise_students = @course.students.where(course_group_id: group_id) # 试卷所分班的全部人数 user_ids = exercise_students.pluck(:user_id).reject(&:blank?).uniq - @ex_users = @ex_users.where(user_id: user_ids).limit 2 + @ex_users = @ex_users.where(user_id: user_ids) end default_ex_users_size = @ex_users.size diff --git a/app/templates/exercise_export/blank_exercise.html.erb b/app/templates/exercise_export/blank_exercise.html.erb index bb7b28f22..5e763d1cc 100644 --- a/app/templates/exercise_export/blank_exercise.html.erb +++ b/app/templates/exercise_export/blank_exercise.html.erb @@ -19,7 +19,7 @@

-

+

<% if @exercise_single_ques_count > 0 %> 单选题<%= @exercise_single_ques_count %>题, 共<%= @exercise_single_ques_scores %> diff --git a/app/templates/exercise_export/exercise_export.css b/app/templates/exercise_export/exercise_export.css index e34eefedc..119d92a05 100644 --- a/app/templates/exercise_export/exercise_export.css +++ b/app/templates/exercise_export/exercise_export.css @@ -340,6 +340,7 @@ textarea{ /*width:100%;*/ /*display:inline-block;*/ word-break: break-all; + line-height:2; } diff --git a/app/templates/exercise_export/exercise_user.html.erb b/app/templates/exercise_export/exercise_user.html.erb index 847820d57..1c91baec2 100644 --- a/app/templates/exercise_export/exercise_user.html.erb +++ b/app/templates/exercise_export/exercise_user.html.erb @@ -19,7 +19,7 @@

-

+

<% if @exercise_single_ques_count > 0 %> 单选题<%= @exercise_single_ques_count %>题, 共<%= @exercise_single_ques_scores %> From 95255749bd4f98eb2c3ddcd55e5df52b67546052 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Tue, 2 Jul 2019 11:23:49 +0800 Subject: [PATCH 212/256] =?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/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 aaffc34a6..af1dffe71 100644 --- a/app/controllers/homework_commons_controller.rb +++ b/app/controllers/homework_commons_controller.rb @@ -272,7 +272,7 @@ class HomeworkCommonsController < ApplicationController def update_student_score work = @homework.student_works.find_by(user_id: current_user.id) myshixun = Myshixun.find_by(shixun_id: params[:shixun_id], user_id: current_user.id) - ActiveRecord::Base.transaction do + ActiveRecord::Base.transaction do begin if work && myshixun && (work.update_time.nil? || work.update_time < myshixun.updated_at) challenge_settings = @homework.homework_challenge_settings From c3885ec64c6f9982452c8b1ca0deba763135a889 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Tue, 2 Jul 2019 11:43:02 +0800 Subject: [PATCH 213/256] =?UTF-8?q?=E6=89=93=E5=8D=B0=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/shixuns_controller.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/controllers/shixuns_controller.rb b/app/controllers/shixuns_controller.rb index 0d913a0a1..767129026 100644 --- a/app/controllers/shixuns_controller.rb +++ b/app/controllers/shixuns_controller.rb @@ -280,7 +280,6 @@ class ShixunsController < ApplicationController @small_type = shixun_small_type end - # 注意这里传参都应该使用params[:shixun]['name']这种格式 def create # 评测脚本的一些操作 main_type, sub_type = params[:main_type], params[:small_type] @@ -388,7 +387,8 @@ class ShixunsController < ApplicationController ShixunMirrorRepository.create(:shixun_id => @shixun.id, :mirror_repository_id => mirror) end end - + logger.info("#######shixun_params: ##{shixun_params}") + logger.info("#######shixun_info_params: ##{shixun_info_params}") @shixun.update_attributes(shixun_params) @shixun.shixun_info.update_attributes(shixun_info_params) @shixun.shixun_schools.delete_all @@ -735,7 +735,7 @@ private def shixun_params raise("实训名称不能为空") if params[:shixun][:name].blank? params.require(:shixun).permit(:name, :trainee, :webssh, :can_copy, :use_scope, :vnc, :test_set_permission, - :task_pass, :repo_name, :multi_webssh, :opening_time, :mirror_script_id, :code_hidden, + :task_pass, :multi_webssh, :opening_time, :mirror_script_id, :code_hidden, :hide_code, :forbid_copy) end def shixun_info_params From 61747f8e840675f796de679fcf99b48cef8807a7 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Tue, 2 Jul 2019 12:25:44 +0800 Subject: [PATCH 214/256] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=AF=95=E5=8D=B7?= =?UTF-8?q?=E5=92=8C=E9=97=AE=E5=8D=B7=E7=AD=94=E9=A2=98=E5=88=97=E8=A1=A8?= =?UTF-8?q?=E7=9A=84=E6=90=9C=E7=B4=A2=E6=9D=A1=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/exercises_controller.rb | 10 ++-------- app/controllers/polls_controller.rb | 10 +++------- 2 files changed, 5 insertions(+), 15 deletions(-) diff --git a/app/controllers/exercises_controller.rb b/app/controllers/exercises_controller.rb index ff4dc6be9..2761523a6 100644 --- a/app/controllers/exercises_controller.rb +++ b/app/controllers/exercises_controller.rb @@ -1278,14 +1278,8 @@ class ExercisesController < ApplicationController #搜索 if params[:search].present? - search_content = params[:search] - #搜索用户的nickname,如果存在则返回,否则继续查询用户的真实姓名或学生号 - nick_name_search = @exercise_users_list.where(user_id: User.where('CONCAT(users.lastname, users.firstname) like ?',"%#{search_content}%")) - if nick_name_search.present? - @exercise_users_list = nick_name_search - else - @exercise_users_list = @exercise_users_list.joins(user: [:user_extension]).where('user_extensions.student_id like ? OR user_extensions.student_realname like ?',"%#{search_content}%","%#{search_content}%") - end + + @exercise_users_list = @exercise_users_list.joins(user: :user_extension).where("CONCAT(lastname, firstname) like ? OR student_id like ?", "%#{params[:search]}%", "%#{params[:search]}%") end @export_ex_users = @exercise_users_list diff --git a/app/controllers/polls_controller.rb b/app/controllers/polls_controller.rb index cd9679972..90ca1778e 100644 --- a/app/controllers/polls_controller.rb +++ b/app/controllers/polls_controller.rb @@ -1026,13 +1026,9 @@ class PollsController < ApplicationController #搜索 if search_content.present? - #搜索用户的nickname,如果存在则返回,否则继续查询用户的真实姓名或学生号 - nick_name_search = @poll_users_list.where(user_id: User.where('CONCAT(users.lastname, users.firstname) like ?',"%#{search_content}%")) - if nick_name_search.present? - @poll_users_list = nick_name_search - else - @poll_users_list = @poll_users_list.joins(user: [:user_extension]).where('user_extensions.student_id like ? OR user_extensions.student_realname like ?',"%#{search_content}%","%#{search_content}%") - end + + @poll_users_list = @poll_users_list.joins(user: :user_extension).where("CONCAT(lastname, firstname) like ? OR student_id like ?", "%#{search_content}%", "%#{search_content}%") + end @poll_users_size = @poll_users_list.count From 50c7e9815e7d71ab46e641c07ad94b72968c0c9c Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Tue, 2 Jul 2019 13:43:19 +0800 Subject: [PATCH 215/256] fix bug --- app/controllers/polls_controller.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/controllers/polls_controller.rb b/app/controllers/polls_controller.rb index 90ca1778e..24aa54309 100644 --- a/app/controllers/polls_controller.rb +++ b/app/controllers/polls_controller.rb @@ -953,12 +953,14 @@ class PollsController < ApplicationController @poll_publish_count = get_user_permission_course(poll_ids,2).count @poll_unpublish_count = get_user_permission_course(poll_ids,1).count @course_all_members = @course.students + logger.info("#######F___________poll_user_ids________________####{@poll.poll_users.pluck(:id)}") @poll_group_counts = @course.course_groups_count if @user_course_identity < Course::STUDENT #当前为老师,而且老师只能查看自己班级的/课堂的问卷 @poll_current_user_status = 0 - @poll_users_list = @poll.all_poll_users(current_user.id).distinct #该老师分班的全部学生 + @poll_users_list = @poll.all_poll_users(current_user.id) #该老师分班的全部学生 get_poll_answers(@poll_users_list) + logger.info("#######F__________@poll_users_list________________####{@poll_users_list.pluck(:id)}") if @poll_list_status == 1 @poll_course_groups =[] @@ -1026,9 +1028,7 @@ class PollsController < ApplicationController #搜索 if search_content.present? - @poll_users_list = @poll_users_list.joins(user: :user_extension).where("CONCAT(lastname, firstname) like ? OR student_id like ?", "%#{search_content}%", "%#{search_content}%") - end @poll_users_size = @poll_users_list.count From b1e13758d3d1c127b4153460b1ec04e70d1ebcd1 Mon Sep 17 00:00:00 2001 From: p31729568 Date: Tue, 2 Jul 2019 13:53:00 +0800 Subject: [PATCH 216/256] add school and department api for option --- app/controllers/departments_controller.rb | 11 +++++++++++ app/controllers/schools_controller.rb | 4 ++++ app/models/department.rb | 22 +++++++++++++++++++++ app/models/school.rb | 24 +++++++++++++++++++++++ config/routes.rb | 6 +++++- 5 files changed, 66 insertions(+), 1 deletion(-) create mode 100644 app/controllers/departments_controller.rb diff --git a/app/controllers/departments_controller.rb b/app/controllers/departments_controller.rb new file mode 100644 index 000000000..f0fa8fe2c --- /dev/null +++ b/app/controllers/departments_controller.rb @@ -0,0 +1,11 @@ +class DepartmentsController < ApplicationController + def for_option + render_ok(departments: Department.cached_names_data(current_school)) + end + + private + + def current_school + @_current_school ||= School.find(params[:id]) + end +end \ No newline at end of file diff --git a/app/controllers/schools_controller.rb b/app/controllers/schools_controller.rb index 11932be42..ea94f4c69 100644 --- a/app/controllers/schools_controller.rb +++ b/app/controllers/schools_controller.rb @@ -9,4 +9,8 @@ class SchoolsController < ApplicationController render_ok(school_names: schools.pluck(:name)) end + + def for_option + render_ok(schools: School.cached_names_data) + end end diff --git a/app/models/department.rb b/app/models/department.rb index 15a8a7c1b..bf5c3a90e 100644 --- a/app/models/department.rb +++ b/app/models/department.rb @@ -2,4 +2,26 @@ class Department < ApplicationRecord belongs_to :school has_many :department_members, dependent: :destroy + + after_create_commit :reset_data_cache + after_update_commit :reset_data_cache + + def self.cached_names_data(school) + Rails.cache.fetch(names_data_cache_key(school.id), expires_in: 7.days) do + school.departments.select(:id, :name).as_json + end + end + + private + + def reset_data_cache + # 清除部门名称缓存 + if new_record? || name_previously_changed? + Rails.cache.delete(self.class.names_data_cache_key(school_id)) + end + end + + def self.names_data_cache_key(school_id) + "schools/#{school_id}/department_names_data" + end end diff --git a/app/models/school.rb b/app/models/school.rb index af04ed0c7..983a93735 100644 --- a/app/models/school.rb +++ b/app/models/school.rb @@ -1,4 +1,6 @@ class School < ApplicationRecord + has_many :departments, dependent: :destroy + has_many :shixun_schools, :dependent => :destroy has_many :shixuns, :through => :shixun_schools @@ -8,6 +10,9 @@ class School < ApplicationRecord has_many :ec_major_schools, :dependent => :destroy has_many :ec_majors, :through => :ec_major_schools + after_create_commit :reset_data_cache + after_update_commit :reset_data_cache + # 学校管理员 def manager?(user) ec_school_users.exists?(user_id: user.id) @@ -28,4 +33,23 @@ class School < ApplicationRecord def manage_permission?(user) manager?(user) || major_manager?(user) || course_manager?(user) end + + def self.cached_names_data + Rails.cache.fetch(names_data_cache_key, expires_in: 7.days) do + School.select(:id, :name).as_json + end + end + + private + + def reset_data_cache + # 清除学校名称缓存 + if new_record? || name_previously_changed? + Rails.cache.delete(self.class.names_data_cache_key) + end + end + + def self.names_data_cache_key + 'schools/names_data' + end end diff --git a/config/routes.rb b/config/routes.rb index 0f47cda76..a27dde1f3 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -576,9 +576,13 @@ Rails.application.routes.draw do resources :schools do member do + resources :departments, only: [] do + get :for_option, on: :collection + end end collection do - get "school_list" + get :school_list + get :for_option end scope module: :ecs do From 1cbd20b57add58f719a7cefbf7f07af8320378d1 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Tue, 2 Jul 2019 13:58:43 +0800 Subject: [PATCH 217/256] fix bug --- app/controllers/polls_controller.rb | 2 ++ app/models/poll.rb | 6 +++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/app/controllers/polls_controller.rb b/app/controllers/polls_controller.rb index 24aa54309..e1ea02016 100644 --- a/app/controllers/polls_controller.rb +++ b/app/controllers/polls_controller.rb @@ -961,6 +961,8 @@ class PollsController < ApplicationController @poll_users_list = @poll.all_poll_users(current_user.id) #该老师分班的全部学生 get_poll_answers(@poll_users_list) logger.info("#######F__________@poll_users_list________________####{@poll_users_list.pluck(:id)}") + logger.info("#######F__________@users_ids________________####{PollUser.where(id:@poll_users_list.pluck(:id)).pluck(:user_id)}") + if @poll_list_status == 1 @poll_course_groups =[] diff --git a/app/models/poll.rb b/app/models/poll.rb index f72239ba7..7e71505ba 100644 --- a/app/models/poll.rb +++ b/app/models/poll.rb @@ -52,12 +52,12 @@ class Poll < ApplicationRecord # 统一设置,为当前老师有权限的分班学生,分班设置,也为当前老师有权限的分班的学生 def all_poll_users(user_id) - poll_users = self.poll_users + poll_all_users = poll_users group_ids = poll_published_ids(user_id) if group_ids.present? - poll_users = poll_users.where(user_id: course.students.where(course_group_id: group_ids).pluck(:user_id)) + poll_all_users = poll_all_users.where(user_id: course.students.where(course_group_id: group_ids).pluck(:user_id).uniq) end - poll_users + poll_all_users end #当前用户已发布的班级id和试卷分组已发布的班级id的交集 From 3d6ab9da88fe236d4aff0d344789e15b4c65efec Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Tue, 2 Jul 2019 14:02:58 +0800 Subject: [PATCH 218/256] fix bug --- app/controllers/polls_controller.rb | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/app/controllers/polls_controller.rb b/app/controllers/polls_controller.rb index e1ea02016..810bf55c1 100644 --- a/app/controllers/polls_controller.rb +++ b/app/controllers/polls_controller.rb @@ -1029,15 +1029,20 @@ class PollsController < ApplicationController end #搜索 - if search_content.present? - @poll_users_list = @poll_users_list.joins(user: :user_extension).where("CONCAT(lastname, firstname) like ? OR student_id like ?", "%#{search_content}%", "%#{search_content}%") - end + # if search_content.present? + # @poll_users_list = @poll_users_list.joins(user: :user_extension).where("CONCAT(lastname, firstname) like ? OR student_id like ?", "%#{search_content}%", "%#{search_content}%") + # end + + logger.info("#######F_______@poll_users_list_last___@users_ids________________####{@poll_users_list.pluck(:id)}") + @poll_users_size = @poll_users_list.count # 分页 @page = params[:page] || 1 @limit = params[:limit] || 20 @poll_users_list = @poll_users_list.page(@page).per(@limit) + logger.info("#######F_______@poll_users_list_after_page___@users_ids________________####{@poll_users_list.pluck(:id)}") + else @poll_users_list = [] @poll_users_size = 0 From 8269367f4737ef49753bfebcb81e4680718cacc6 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Tue, 2 Jul 2019 14:21:16 +0800 Subject: [PATCH 219/256] fix bug --- app/controllers/polls_controller.rb | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/app/controllers/polls_controller.rb b/app/controllers/polls_controller.rb index 810bf55c1..7ac288d7d 100644 --- a/app/controllers/polls_controller.rb +++ b/app/controllers/polls_controller.rb @@ -1029,20 +1029,19 @@ class PollsController < ApplicationController end #搜索 - # if search_content.present? - # @poll_users_list = @poll_users_list.joins(user: :user_extension).where("CONCAT(lastname, firstname) like ? OR student_id like ?", "%#{search_content}%", "%#{search_content}%") - # end + if search_content.present? + @poll_users_list = @poll_users_list.joins(user: :user_extension).where("CONCAT(lastname, firstname) like ? OR student_id like ?", "%#{search_content}%", "%#{search_content}%") + end logger.info("#######F_______@poll_users_list_last___@users_ids________________####{@poll_users_list.pluck(:id)}") @poll_users_size = @poll_users_list.count # 分页 - @page = params[:page] || 1 - @limit = params[:limit] || 20 - @poll_users_list = @poll_users_list.page(@page).per(@limit) + page = params[:page] || 1 + limit = params[:limit] || 20 + @poll_users_list = @poll_users_list.page(page).per(limit) logger.info("#######F_______@poll_users_list_after_page___@users_ids________________####{@poll_users_list.pluck(:id)}") - else @poll_users_list = [] @poll_users_size = 0 From 910c0b13b3fe2e0fae05258c94426b4229a91671 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Tue, 2 Jul 2019 14:23:20 +0800 Subject: [PATCH 220/256] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E5=AE=9E=E8=AE=AD?= =?UTF-8?q?=E5=8F=82=E6=95=B0=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/shixuns_controller.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/controllers/shixuns_controller.rb b/app/controllers/shixuns_controller.rb index 767129026..65d671856 100644 --- a/app/controllers/shixuns_controller.rb +++ b/app/controllers/shixuns_controller.rb @@ -387,8 +387,6 @@ class ShixunsController < ApplicationController ShixunMirrorRepository.create(:shixun_id => @shixun.id, :mirror_repository_id => mirror) end end - logger.info("#######shixun_params: ##{shixun_params}") - logger.info("#######shixun_info_params: ##{shixun_info_params}") @shixun.update_attributes(shixun_params) @shixun.shixun_info.update_attributes(shixun_info_params) @shixun.shixun_schools.delete_all @@ -407,6 +405,8 @@ class ShixunsController < ApplicationController # 超级管理员和运营人员才能保存 中间层服务器pod信息的配置 if current_user.admin? || current_user.business? @shixun.shixun_service_configs.destroy_all + ActionController::Parameters.permit_all_parameters = true + logger.info("##--;;;;---#{params[:shixun_service_configs]}") params[:shixun_service_configs].each do |config| @shixun.shixun_service_configs.create!(config) end @@ -738,6 +738,7 @@ private :task_pass, :multi_webssh, :opening_time, :mirror_script_id, :code_hidden, :hide_code, :forbid_copy) end + def shixun_info_params raise("实训描述不能为空") if params[:shixun_info][:description].blank? raise("评测脚本不能为空") if params[:shixun_info][:evaluate_script].blank? From 857f2dcb3e169d27fcf804e919b0f3ac66d2ee55 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Tue, 2 Jul 2019 14:43:56 +0800 Subject: [PATCH 221/256] fix bug --- app/controllers/exercises_controller.rb | 2 +- app/controllers/polls_controller.rb | 11 +++-------- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/app/controllers/exercises_controller.rb b/app/controllers/exercises_controller.rb index 2761523a6..a793c673c 100644 --- a/app/controllers/exercises_controller.rb +++ b/app/controllers/exercises_controller.rb @@ -1238,7 +1238,7 @@ class ExercisesController < ApplicationController @teacher_unreview_count = 0 #筛选/分类,排序 order = params[:order] - if @exercise_users_list.present? && @exercise_users_list.count > 0 + if @exercise_users_list.present? && @exercise_users_list.size > 0 teacher_reviews = @exercise_users_list.exercise_review teacher_unreviews = @exercise_users_list.exercise_unreview @teacher_review_count = teacher_reviews.count #已评阅 diff --git a/app/controllers/polls_controller.rb b/app/controllers/polls_controller.rb index 7ac288d7d..6a8edee71 100644 --- a/app/controllers/polls_controller.rb +++ b/app/controllers/polls_controller.rb @@ -953,17 +953,12 @@ class PollsController < ApplicationController @poll_publish_count = get_user_permission_course(poll_ids,2).count @poll_unpublish_count = get_user_permission_course(poll_ids,1).count @course_all_members = @course.students - logger.info("#######F___________poll_user_ids________________####{@poll.poll_users.pluck(:id)}") @poll_group_counts = @course.course_groups_count if @user_course_identity < Course::STUDENT #当前为老师,而且老师只能查看自己班级的/课堂的问卷 @poll_current_user_status = 0 @poll_users_list = @poll.all_poll_users(current_user.id) #该老师分班的全部学生 get_poll_answers(@poll_users_list) - logger.info("#######F__________@poll_users_list________________####{@poll_users_list.pluck(:id)}") - logger.info("#######F__________@users_ids________________####{PollUser.where(id:@poll_users_list.pluck(:id)).pluck(:user_id)}") - - if @poll_list_status == 1 @poll_course_groups =[] else @@ -1033,15 +1028,15 @@ class PollsController < ApplicationController @poll_users_list = @poll_users_list.joins(user: :user_extension).where("CONCAT(lastname, firstname) like ? OR student_id like ?", "%#{search_content}%", "%#{search_content}%") end - logger.info("#######F_______@poll_users_list_last___@users_ids________________####{@poll_users_list.pluck(:id)}") - + logger.info("#######F_______@poll_users_list_last___@users_ids________________####{@poll_users_list.pluck(:user_id)}") @poll_users_size = @poll_users_list.count + # 分页 page = params[:page] || 1 limit = params[:limit] || 20 @poll_users_list = @poll_users_list.page(page).per(limit) - logger.info("#######F_______@poll_users_list_after_page___@users_ids________________####{@poll_users_list.pluck(:id)}") + logger.info("#######F_______@poll_users_list_after_page___@users_ids________________####{@poll_users_list.pluck(:user_id)}") else @poll_users_list = [] @poll_users_size = 0 From 23333a8186e50f1ab51d0fc17fd8de027f5cdd80 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Tue, 2 Jul 2019 14:55:59 +0800 Subject: [PATCH 222/256] =?UTF-8?q?=E6=89=93=E5=8D=B0=E6=97=A5=E5=BF=97?= =?UTF-8?q?=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/polls_controller.rb | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/app/controllers/polls_controller.rb b/app/controllers/polls_controller.rb index 6a8edee71..d928d1df5 100644 --- a/app/controllers/polls_controller.rb +++ b/app/controllers/polls_controller.rb @@ -1005,12 +1005,6 @@ class PollsController < ApplicationController if @poll_users_list.present? && @poll_users_list.count > 0 - if order == "student_id" - @poll_users_list = @poll_users_list.joins(user: [:user_extension]).order("user_extensions.student_id DESC") - else - @poll_users_list = @poll_users_list.order("end_at DESC") - end - #答题状态的选择 if choose_type.present? @poll_users_list = @poll_users_list.commit_by_status(choose_type) @@ -1027,8 +1021,12 @@ class PollsController < ApplicationController if search_content.present? @poll_users_list = @poll_users_list.joins(user: :user_extension).where("CONCAT(lastname, firstname) like ? OR student_id like ?", "%#{search_content}%", "%#{search_content}%") end - - logger.info("#######F_______@poll_users_list_last___@users_ids________________####{@poll_users_list.pluck(:user_id)}") + if order == "student_id" + @poll_users_list = @poll_users_list.joins(user: :user_extension).order("user_extensions.student_id DESC") + else + @poll_users_list = @poll_users_list.order("end_at DESC") + end + logger.info("#######user_id: ####{@poll_users_list.pluck(:user_id).sort}") @poll_users_size = @poll_users_list.count @@ -1036,7 +1034,7 @@ class PollsController < ApplicationController page = params[:page] || 1 limit = params[:limit] || 20 @poll_users_list = @poll_users_list.page(page).per(limit) - logger.info("#######F_______@poll_users_list_after_page___@users_ids________________####{@poll_users_list.pluck(:user_id)}") + logger.info("#####page_user: #{@poll_users_list.pluck(:user_id).sort}") else @poll_users_list = [] @poll_users_size = 0 From 91d875c36b9bbab0a02b12cbd900b297f2cb861d Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Tue, 2 Jul 2019 15:01:20 +0800 Subject: [PATCH 223/256] =?UTF-8?q?=E6=89=93=E5=8D=B0=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/polls_controller.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/controllers/polls_controller.rb b/app/controllers/polls_controller.rb index d928d1df5..50784ee74 100644 --- a/app/controllers/polls_controller.rb +++ b/app/controllers/polls_controller.rb @@ -1024,9 +1024,9 @@ class PollsController < ApplicationController if order == "student_id" @poll_users_list = @poll_users_list.joins(user: :user_extension).order("user_extensions.student_id DESC") else - @poll_users_list = @poll_users_list.order("end_at DESC") + @poll_users_list = @poll_users_list.joins(user: :user_extension).order("end_at DESC") end - logger.info("#######user_id: ####{@poll_users_list.pluck(:user_id).sort}") + logger.info("#######user_id: ####{@poll_users_list.pluck(:id, :user_id)}") @poll_users_size = @poll_users_list.count @@ -1034,7 +1034,7 @@ class PollsController < ApplicationController page = params[:page] || 1 limit = params[:limit] || 20 @poll_users_list = @poll_users_list.page(page).per(limit) - logger.info("#####page_user: #{@poll_users_list.pluck(:user_id).sort}") + logger.info("#####page_user: #{@poll_users_list.pluck(:id, :user_id)}") else @poll_users_list = [] @poll_users_size = 0 From 2b2257b181dc5dd2ce7e92547565f91da74b1112 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Tue, 2 Jul 2019 15:16:24 +0800 Subject: [PATCH 224/256] fix bug --- app/controllers/homework_commons_controller.rb | 3 ++- app/controllers/polls_controller.rb | 11 ++++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/app/controllers/homework_commons_controller.rb b/app/controllers/homework_commons_controller.rb index af1dffe71..2478633a1 100644 --- a/app/controllers/homework_commons_controller.rb +++ b/app/controllers/homework_commons_controller.rb @@ -186,7 +186,7 @@ class HomeworkCommonsController < ApplicationController end @work_count = @student_works.size - @work_excel = @student_works + @work_excel = @student_works.includes(:student_works_scores) @students = @course.students # 分页参数 @@ -207,6 +207,7 @@ class HomeworkCommonsController < ApplicationController tip_exception(403, "无权限操作") else if @work_excel.present? + @homework = @homework.includes() student_work_to_xlsx(@work_excel,@homework) exercise_export_name = current_user.real_name + "_" + @course.name + "_" + @homework.name + "_" + Time.now.strftime('%Y%m%d_%H%M%S') diff --git a/app/controllers/polls_controller.rb b/app/controllers/polls_controller.rb index 6a8edee71..81e6cedaa 100644 --- a/app/controllers/polls_controller.rb +++ b/app/controllers/polls_controller.rb @@ -1005,11 +1005,6 @@ class PollsController < ApplicationController if @poll_users_list.present? && @poll_users_list.count > 0 - if order == "student_id" - @poll_users_list = @poll_users_list.joins(user: [:user_extension]).order("user_extensions.student_id DESC") - else - @poll_users_list = @poll_users_list.order("end_at DESC") - end #答题状态的选择 if choose_type.present? @@ -1028,6 +1023,12 @@ class PollsController < ApplicationController @poll_users_list = @poll_users_list.joins(user: :user_extension).where("CONCAT(lastname, firstname) like ? OR student_id like ?", "%#{search_content}%", "%#{search_content}%") end + if order == "student_id" + @poll_users_list = @poll_users_list.joins(user: :user_extension).order("user_extensions.student_id DESC") + else + @poll_users_list = @poll_users_list.order("end_at DESC") + end + logger.info("#######F_______@poll_users_list_last___@users_ids________________####{@poll_users_list.pluck(:user_id)}") @poll_users_size = @poll_users_list.count From 925ff7fd09d2319b8d71032e2879e852c218467a Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Tue, 2 Jul 2019 15:21:10 +0800 Subject: [PATCH 225/256] fix bug --- app/controllers/polls_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/polls_controller.rb b/app/controllers/polls_controller.rb index a7e039944..84af9b584 100644 --- a/app/controllers/polls_controller.rb +++ b/app/controllers/polls_controller.rb @@ -1025,7 +1025,7 @@ class PollsController < ApplicationController if order == "student_id" @poll_users_list = @poll_users_list.joins(user: :user_extension).order("user_extensions.student_id DESC") else - @poll_users_list = @poll_users_list.order("end_at DESC") + @poll_users_list = @poll_users_list.joins(user: :user_extension).order("end_at DESC") end logger.info("#######F_______@poll_users_list_last___@users_ids________________####{@poll_users_list.pluck(:user_id)}") From bf8e88c39396931b0c2cc9cfc012403ecde67ea6 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Tue, 2 Jul 2019 15:28:57 +0800 Subject: [PATCH 226/256] =?UTF-8?q?=E5=8F=82=E6=95=B0=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/shixuns_controller.rb | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/app/controllers/shixuns_controller.rb b/app/controllers/shixuns_controller.rb index 65d671856..3a4592b2f 100644 --- a/app/controllers/shixuns_controller.rb +++ b/app/controllers/shixuns_controller.rb @@ -405,11 +405,7 @@ class ShixunsController < ApplicationController # 超级管理员和运营人员才能保存 中间层服务器pod信息的配置 if current_user.admin? || current_user.business? @shixun.shixun_service_configs.destroy_all - ActionController::Parameters.permit_all_parameters = true - logger.info("##--;;;;---#{params[:shixun_service_configs]}") - params[:shixun_service_configs].each do |config| - @shixun.shixun_service_configs.create!(config) - end + @shixun.shixun_service_configs.create!(service_config_params[:shixun_service_configs]) end rescue Exception => e uid_logger_error(e.message) @@ -745,6 +741,11 @@ private params.require(:shixun_info).permit(:description, :evaluate_script) end + + def service_config_params + params.permit(shixun_service_configs: [:cpu_limit, :lower_cpu_limit, :memory_limit, :request_limit, :mirror_repository_id]) + end + def find_shixun @shixun = Shixun.find_by_identifier(params[:identifier]) if @shixun.blank? From c22ec7dff21c85adf3d6f11fcbbeb35213f5b851 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Tue, 2 Jul 2019 16:10:38 +0800 Subject: [PATCH 227/256] =?UTF-8?q?=E9=A6=96=E9=A1=B5=E7=AD=9B=E9=80=89?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/repertoire.rb | 4 ++-- app/models/sub_repertoire.rb | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/app/models/repertoire.rb b/app/models/repertoire.rb index 400cef494..5c6ffebff 100644 --- a/app/models/repertoire.rb +++ b/app/models/repertoire.rb @@ -1,6 +1,6 @@ class Repertoire < ApplicationRecord - - has_many :sub_repertoires + default_scope :order => 'updated_at desc' + has_many :sub_repertoires, :dependent => :destroy, :order => "sub_repertoires.updated_at desc" has_many :tag_repertoires, through: :sub_repertoires end diff --git a/app/models/sub_repertoire.rb b/app/models/sub_repertoire.rb index d94db66c7..aa99494b1 100644 --- a/app/models/sub_repertoire.rb +++ b/app/models/sub_repertoire.rb @@ -1,3 +1,5 @@ class SubRepertoire < ApplicationRecord - has_many :tag_repertoires + belongs_to :repertoire + has_many :tag_repertoires, :dependent => :destroy, :order => "tag_repertoires.updated_at desc" + end From a53c20e02892d01ae72ffd514024ce879ed9a7f3 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Tue, 2 Jul 2019 16:13:35 +0800 Subject: [PATCH 228/256] fix bug --- app/controllers/exercises_controller.rb | 31 +++++++++++-------- .../homework_commons_controller.rb | 4 +-- app/controllers/polls_controller.rb | 30 ++++++++++++------ app/helpers/export_helper.rb | 4 +-- app/views/polls/commit_result.xlsx.axlsx | 8 ++--- 5 files changed, 46 insertions(+), 31 deletions(-) diff --git a/app/controllers/exercises_controller.rb b/app/controllers/exercises_controller.rb index a793c673c..18b8fbb2f 100644 --- a/app/controllers/exercises_controller.rb +++ b/app/controllers/exercises_controller.rb @@ -1173,6 +1173,7 @@ class ExercisesController < ApplicationController ActiveRecord::Base.transaction do begin @current_user_id = current_user.id + @exercise = @exercise.includes(:exercise_questions) exercise_ids = [@exercise.id] @exercise_status = @exercise.get_exercise_status(current_user.id) @course_all_members = @course.students @@ -1254,14 +1255,6 @@ class ExercisesController < ApplicationController end end - if order == "student_id" - @exercise_users_list = @exercise_users_list.joins(user: [:user_extension]).order("user_extensions.student_id DESC") - elsif order == "score" - @exercise_users_list = @exercise_users_list.order("#{order} DESC") - else - @exercise_users_list = @exercise_users_list.order("end_at DESC, start_at DESC") - end - #答题状态的选择 if params[:commit_status].present? choose_type = params[:commit_status] @@ -1282,9 +1275,17 @@ class ExercisesController < ApplicationController @exercise_users_list = @exercise_users_list.joins(user: :user_extension).where("CONCAT(lastname, firstname) like ? OR student_id like ?", "%#{params[:search]}%", "%#{params[:search]}%") end + if order == "student_id" + @exercise_users_list = @exercise_users_list.joins(user: :user_extension).order("user_extensions.student_id DESC") + elsif order == "score" + @exercise_users_list = @exercise_users_list.joins(user: :user_extension).order("#{order} DESC") + else + @exercise_users_list = @exercise_users_list.order("end_at DESC, start_at DESC") + end + @export_ex_users = @exercise_users_list - @exercise_users_size = @exercise_users_list.count + @exercise_users_size = @exercise_users_list.size # 分页 @page = params[:page] || 1 @@ -1296,10 +1297,14 @@ class ExercisesController < ApplicationController if @user_course_identity > Course::ASSISTANT_PROFESSOR tip_exception(403,"无权限操作") else - get_export_users(@exercise,@course,@export_ex_users) - exercise_export_name = - "#{current_user.real_name}_#{@course.name}_#{@exercise.exercise_name}_#{Time.now.strftime('%Y%m%d_%H%M%S')}" - render xlsx: "#{exercise_export_name.strip.first(30)}",template: "exercises/exercise_lists.xlsx.axlsx",locals: {table_columns:@table_columns,exercise_users:@user_columns} + if @exercise_users_size.size > 0 + normal_status(-1,"暂无用户提交") + else + get_export_users(@exercise,@course,@export_ex_users) + exercise_export_name = + "#{current_user.real_name}_#{@course.name}_#{@exercise.exercise_name}_#{Time.now.strftime('%Y%m%d_%H%M%S')}" + render xlsx: "#{exercise_export_name.strip.first(30)}",template: "exercises/exercise_lists.xlsx.axlsx",locals: {table_columns:@table_columns,exercise_users:@user_columns} + end end } end diff --git a/app/controllers/homework_commons_controller.rb b/app/controllers/homework_commons_controller.rb index 2478633a1..dc4d6b117 100644 --- a/app/controllers/homework_commons_controller.rb +++ b/app/controllers/homework_commons_controller.rb @@ -186,7 +186,7 @@ class HomeworkCommonsController < ApplicationController end @work_count = @student_works.size - @work_excel = @student_works.includes(:student_works_scores) + @work_excel = @student_works.includes(:student_works_scores, user: :user_extension, myshixun: :games) @students = @course.students # 分页参数 @@ -207,7 +207,7 @@ class HomeworkCommonsController < ApplicationController tip_exception(403, "无权限操作") else if @work_excel.present? - @homework = @homework.includes() + @homework = @homework.includes(:shixuns,:homework_detail_manual) student_work_to_xlsx(@work_excel,@homework) exercise_export_name = current_user.real_name + "_" + @course.name + "_" + @homework.name + "_" + Time.now.strftime('%Y%m%d_%H%M%S') diff --git a/app/controllers/polls_controller.rb b/app/controllers/polls_controller.rb index 84af9b584..151a2a098 100644 --- a/app/controllers/polls_controller.rb +++ b/app/controllers/polls_controller.rb @@ -18,7 +18,7 @@ class PollsController < ApplicationController before_action :check_user_id_start_answer,only: [:start_answer] before_action :check_poll_question_complete,only: [:commit_poll] #问卷提交前来判断问题是否完成 before_action :check_poll_commit_result,only: [:commit_result] - before_action :get_all_polls_commit, only: [:commit_result] #该问卷全部的用户 + # before_action :get_all_polls_commit, only: [:commit_result] #该问卷全部的用户 before_action :get_left_banner_id, only:[:common_header,:start_answer,:new,:edit,:index] include PollsHelper @@ -920,19 +920,32 @@ class PollsController < ApplicationController def commit_result ActiveRecord::Base.transaction do begin + # @poll_questions = @poll.poll_questions.order("question_number ASC") + # 全部页面,需返回 + # @poll_questions_count = @poll_questions.size # 分页 + @poll = @poll.includes(:poll_users,user: :user_extension,) + @poll_users = @poll.poll_users + @poll_commit_ids = @poll_users.commit_by_status(1).pluck(:user_id) #问卷提交用户的id @page = params[:page] || 1 @limit = params[:limit] || 10 @poll_export_questions = @poll_questions.order("question_number ASC") + @poll_questions = @poll_questions.page(@page).per(@limit) respond_to do |format| format.json format.xlsx{ if @user_course_identity > Course::ASSISTANT_PROFESSOR tip_exception(403,"无权限操作") + elsif @poll_export_questions.size == 0 || (@poll_users.where("commit_status = ?",1).size == 0) + normal_status(-1,"暂时没有提交的用户") else - polls_export_name = current_user.real_name + "_" + @course.name + "_" + @poll.polls_name + "_" + Time.now.strftime('%Y%m%d_%H%M%S') - render xlsx: "#{polls_export_name.strip.first(30)}",template: "polls/commit_result.xlsx.axlsx",locals: {poll_questions:@poll_export_questions} + polls_export_name = "#{current_user.real_name}_#{@course.name}_#{@poll.polls_name}_#{Time.now.strftime('%Y%m%d_%H%M%S')}" + render xlsx: "#{polls_export_name.strip.first(30)}",template: "polls/commit_result.xlsx.axlsx",locals: { + poll_questions:@poll_export_questions, + poll:@poll, + poll_users: @poll_users, + poll_commit_ids:@poll_commit_ids} end } end @@ -1028,15 +1041,12 @@ class PollsController < ApplicationController @poll_users_list = @poll_users_list.joins(user: :user_extension).order("end_at DESC") end - logger.info("#######F_______@poll_users_list_last___@users_ids________________####{@poll_users_list.pluck(:user_id)}") - @poll_users_size = @poll_users_list.count # 分页 page = params[:page] || 1 limit = params[:limit] || 20 @poll_users_list = @poll_users_list.page(page).per(limit) - logger.info("#####page_user: #{@poll_users_list.pluck(:id, :user_id)}") else @poll_users_list = [] @poll_users_size = 0 @@ -1146,10 +1156,10 @@ class PollsController < ApplicationController def get_questions_count @poll_questions = @poll.poll_questions&.includes(:poll_answers,:poll_votes).order("question_number ASC") - @poll_questions_count = @poll_questions.count # 全部的题目数 - @poll_question_singles = @poll_questions.ques_count(1).all.count # 单选题 - @poll_question_doubles = @poll_questions.ques_count(2).all.count # 多选题 - @poll_question_mains = @poll_questions.ques_count(3).all.count #主观题 + @poll_questions_count = @poll_questions.size # 全部的题目数 + @poll_question_singles = @poll_questions.ques_count(1).all.size # 单选题 + @poll_question_doubles = @poll_questions.ques_count(2).all.size # 多选题 + @poll_question_mains = @poll_questions.ques_count(3).all.size #主观题 end def check_poll_question_complete #commit_poll 的权限 diff --git a/app/helpers/export_helper.rb b/app/helpers/export_helper.rb index b6720c66c..211b31660 100644 --- a/app/helpers/export_helper.rb +++ b/app/helpers/export_helper.rb @@ -262,14 +262,14 @@ module ExportHelper end export_ex_users.each_with_index do |e_user,index| user_info = e_user.user - user_course_id = user_info.course_members.course_find_by_ids("course_id",course.id).first + user_course_id = user_info.course_members.course_find_by_ids("course_id",course.id)&.first if user_course_id.present? get_course_group_id = user_course_id.course_group_id if get_course_group_id.present? && get_course_group_id != 0 user_course_info = CourseGroup.by_group_ids(get_course_group_id) user_course = user_course_info.first.name else - user_course = "--" + user_course = "未分班" end else user_course = "--" diff --git a/app/views/polls/commit_result.xlsx.axlsx b/app/views/polls/commit_result.xlsx.axlsx index 3ea0571cb..6ce00388c 100644 --- a/app/views/polls/commit_result.xlsx.axlsx +++ b/app/views/polls/commit_result.xlsx.axlsx @@ -9,7 +9,7 @@ wb.styles do |s| sheet.sheet_view.show_grid_lines = false poll_users_info = %w(序号) poll_ques_titles = poll_questions.pluck(:question_title).map {|k| strip_export_title(k) if k.present?} - poll_un_anony = @poll.un_anonymous + poll_un_anony = poll.un_anonymous if poll_un_anony #是否匿名,默认为false user_info = %w(登陆名 真实姓名 邮箱 学号) else @@ -18,13 +18,13 @@ wb.styles do |s| poll_users_info = poll_users_info + user_info + poll_ques_titles poll_questions.each do |q| if q.question_type != 3 #问题不为主观题 - question_vote_user = q.poll_votes.find_current_vote("user_id",@poll_commit_ids).count #该问题的有效填写量 + question_vote_user = q.poll_votes.find_current_vote("user_id",poll_commit_ids).count #该问题的有效填写量 sheet_row = ["第#{q.question_number}题"] #选择题答案选项的数组 sheet_answer_row = ["小计"] #选择题回答的答案人数,数组 sheet_answer_percent = ["比例"] sheet_answer_useful = ["有效填写人次",question_vote_user] q.poll_answers.each do |a| #问卷的答案选项 - answer_users_count = a.poll_votes.find_current_vote("user_id",@poll_commit_ids).count + answer_users_count = a.poll_votes.find_current_vote("user_id",poll_commit_ids).count answer_percent = number_to_percentage((answer_users_count.to_f / question_vote_user.to_f)*100,precision:1) sheet_row.push(a.answer_text) sheet_answer_row.push(answer_users_count) @@ -49,7 +49,7 @@ wb.styles do |s| end #each_with_index sheet.add_row poll_users_info, :height =>15, :style => blue_cell - @poll.poll_users.each_with_index do |u,index| + poll_users.each_with_index do |u,index| u_user = u.user user_answer_array = [] poll_questions.each do |q| From ad092d91e1b1ad5feb9d7256f0b988b07958775b Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Tue, 2 Jul 2019 16:14:17 +0800 Subject: [PATCH 229/256] =?UTF-8?q?=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/repertoire.rb | 2 +- app/models/sub_repertoire.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/models/repertoire.rb b/app/models/repertoire.rb index 5c6ffebff..995d52d0b 100644 --- a/app/models/repertoire.rb +++ b/app/models/repertoire.rb @@ -1,6 +1,6 @@ class Repertoire < ApplicationRecord default_scope :order => 'updated_at desc' - has_many :sub_repertoires, :dependent => :destroy, :order => "sub_repertoires.updated_at desc" + has_many :sub_repertoires, ->{order("sub_repertoires.updated_at desc")}, :dependent => :destroy has_many :tag_repertoires, through: :sub_repertoires end diff --git a/app/models/sub_repertoire.rb b/app/models/sub_repertoire.rb index aa99494b1..9f7079cfc 100644 --- a/app/models/sub_repertoire.rb +++ b/app/models/sub_repertoire.rb @@ -1,5 +1,5 @@ class SubRepertoire < ApplicationRecord belongs_to :repertoire - has_many :tag_repertoires, :dependent => :destroy, :order => "tag_repertoires.updated_at desc" + has_many :tag_repertoires, ->{order("tag_repertoires.updated_at desc")} ,:dependent => :destroy end From 2ab15ddf5c4eaa2c3e0c8c3ccb29080b563d51eb Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Tue, 2 Jul 2019 16:16:16 +0800 Subject: [PATCH 230/256] =?UTF-8?q?=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/repertoire.rb | 2 +- app/models/sub_repertoire.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/models/repertoire.rb b/app/models/repertoire.rb index 995d52d0b..5c37eb3b6 100644 --- a/app/models/repertoire.rb +++ b/app/models/repertoire.rb @@ -1,6 +1,6 @@ class Repertoire < ApplicationRecord default_scope :order => 'updated_at desc' - has_many :sub_repertoires, ->{order("sub_repertoires.updated_at desc")}, :dependent => :destroy + has_many :sub_repertoires, ->{order(updated_at: :desc)}, :dependent => :destroy has_many :tag_repertoires, through: :sub_repertoires end diff --git a/app/models/sub_repertoire.rb b/app/models/sub_repertoire.rb index 9f7079cfc..d6a6c1b3d 100644 --- a/app/models/sub_repertoire.rb +++ b/app/models/sub_repertoire.rb @@ -1,5 +1,5 @@ class SubRepertoire < ApplicationRecord belongs_to :repertoire - has_many :tag_repertoires, ->{order("tag_repertoires.updated_at desc")} ,:dependent => :destroy + has_many :tag_repertoires, ->{order(updated_at: :desc)} ,:dependent => :destroy end From 91661cbee857109803c17d6a917a64c1f10d1f35 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Tue, 2 Jul 2019 16:18:08 +0800 Subject: [PATCH 231/256] =?UTF-8?q?=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/repertoire.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/app/models/repertoire.rb b/app/models/repertoire.rb index 5c37eb3b6..d76a022c5 100644 --- a/app/models/repertoire.rb +++ b/app/models/repertoire.rb @@ -1,5 +1,4 @@ class Repertoire < ApplicationRecord - default_scope :order => 'updated_at desc' has_many :sub_repertoires, ->{order(updated_at: :desc)}, :dependent => :destroy has_many :tag_repertoires, through: :sub_repertoires From 03797ce1fa82333ab085c58d0a0327425c6c973a Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Tue, 2 Jul 2019 16:51:27 +0800 Subject: [PATCH 232/256] ifx bug --- app/controllers/exercises_controller.rb | 4 ++-- app/controllers/polls_controller.rb | 2 +- app/controllers/zips_controller.rb | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/controllers/exercises_controller.rb b/app/controllers/exercises_controller.rb index 18b8fbb2f..b3cf1f0be 100644 --- a/app/controllers/exercises_controller.rb +++ b/app/controllers/exercises_controller.rb @@ -1173,7 +1173,7 @@ class ExercisesController < ApplicationController ActiveRecord::Base.transaction do begin @current_user_id = current_user.id - @exercise = @exercise.includes(:exercise_questions) + @exercise = @exercise exercise_ids = [@exercise.id] @exercise_status = @exercise.get_exercise_status(current_user.id) @course_all_members = @course.students @@ -1297,7 +1297,7 @@ class ExercisesController < ApplicationController if @user_course_identity > Course::ASSISTANT_PROFESSOR tip_exception(403,"无权限操作") else - if @exercise_users_size.size > 0 + if @exercise_users_size == 0 normal_status(-1,"暂无用户提交") else get_export_users(@exercise,@course,@export_ex_users) diff --git a/app/controllers/polls_controller.rb b/app/controllers/polls_controller.rb index 151a2a098..eb03345e7 100644 --- a/app/controllers/polls_controller.rb +++ b/app/controllers/polls_controller.rb @@ -924,7 +924,7 @@ class PollsController < ApplicationController # 全部页面,需返回 # @poll_questions_count = @poll_questions.size # 分页 - @poll = @poll.includes(:poll_users,user: :user_extension,) + # @poll = @poll.includes(:poll_users,user: :user_extension) @poll_users = @poll.poll_users @poll_commit_ids = @poll_users.commit_by_status(1).pluck(:user_id) #问卷提交用户的id @page = params[:page] || 1 diff --git a/app/controllers/zips_controller.rb b/app/controllers/zips_controller.rb index c20546701..a70d4c332 100644 --- a/app/controllers/zips_controller.rb +++ b/app/controllers/zips_controller.rb @@ -62,7 +62,7 @@ class ZipsController < ApplicationController if default_ex_users_size == 0 normal_status(-1,"导出失败,暂时没有已提交的学生") elsif default_ex_users_size > 100 - normal_status(-1,"导出数量超过100,请分班导出或联系网站管理员导出") + normal_status(-2,"100") end end rescue Exception => e From df714555fcf1aead83378154a8d66031fef3cd6c Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Tue, 2 Jul 2019 17:07:23 +0800 Subject: [PATCH 233/256] =?UTF-8?q?=E5=AE=9E=E8=AE=AD=E5=85=B3=E5=8D=A1?= =?UTF-8?q?=E6=A0=87=E7=AD=BE=E7=9A=84model=E5=85=B3=E7=B3=BB=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/challenge_tag.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/challenge_tag.rb b/app/models/challenge_tag.rb index 6f176cc67..83b743adc 100644 --- a/app/models/challenge_tag.rb +++ b/app/models/challenge_tag.rb @@ -1,5 +1,5 @@ class ChallengeTag < ApplicationRecord belongs_to :challenge, counter_cache: true - belongs_to :challenge_choose + belongs_to :challenge_choose, optional: true end From 178a448f54d0bacd20f7cff301bcea605231985d Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Tue, 2 Jul 2019 17:08:38 +0800 Subject: [PATCH 234/256] =?UTF-8?q?=E5=AD=A6=E7=94=9F=E5=88=97=E8=A1=A8?= =?UTF-8?q?=E5=AF=BC=E5=87=BA=E6=88=90=E7=BB=A9=E7=9A=84=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/courses_controller.rb | 72 +++++++++---------- .../graduation_tasks_controller.rb | 2 +- .../homework_commons_controller.rb | 2 +- app/helpers/export_helper.rb | 22 ++---- app/models/exercise.rb | 3 +- app/models/graduation_task.rb | 3 +- app/models/graduation_work.rb | 2 +- app/models/homework_common.rb | 3 +- app/models/poll.rb | 2 +- 9 files changed, 48 insertions(+), 63 deletions(-) diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index cef2a1785..bae37d92a 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -969,22 +969,17 @@ class CoursesController < ApplicationController @all_members = @course.students end if name.present? - nick_name_search = @all_members.joins(:user).where("nickname like ?","%#{name}%") - if nick_name_search.present? - @all_members = nick_name_search - else - @all_members = @all_members.joins(user: [:user_extension]).where('user_extensions.student_id like ? OR user_extensions.student_realname like ?',"%#{name}%","%#{name}%") - end + @all_members = @all_members.joins(user: [:user_extension]).where('concat(users.lastname, users.firstname) like ? or user_extensions.student_id like ?',"%#{name}%","%#{name}%") end - @c_homeworks = @course.homework_commons.homework_published.order("publish_time asc, created_at asc") - @c_exercises = @course.exercises.is_exercise_published.order("publish_time asc, created_at asc") - @c_polls = @course.polls.publish_or_not.order("publish_time asc, created_at asc") - @c_tasks = @course.graduation_tasks.task_published.order("publish_time asc, created_at asc") + @c_homeworks = @course.homework_commons.homework_published.order("homework_commons.publish_time asc, homework_commons.created_at asc") + @c_exercises = @course.exercises.is_exercise_published.order("exercises.publish_time asc, exercises.created_at asc") + @c_polls = @course.polls.publish_or_not.order("polls.publish_time asc, polls.created_at asc") + @c_tasks = @course.graduation_tasks.task_published.order("graduation_tasks.publish_time asc, graduation_tasks.created_at asc") if @user_course_identity > Course::ASSISTANT_PROFESSOR tip_exception(403,"无权限操作") else - member_to_xlsx(@course,@all_members,@c_homeworks,@c_exercises,@c_tasks,@c_polls) + member_to_xlsx(@course, @all_members, @c_homeworks, @c_exercises, @c_tasks, @c_polls) filename = current_user.real_name + "_" + @course.name + "_全部成绩" + Time.now.strftime('%Y%m%d_%H%M%S') render xlsx: "#{filename.strip.first(30)}",template: "courses/export_member_scores_excel.xlsx.axlsx", locals: {course_info:@course_info, activity_level:@user_activity_level, @@ -1058,14 +1053,14 @@ class CoursesController < ApplicationController def member_to_xlsx(course,all_members,homeworks,exercises,tasks,polls) #课堂的作业信息 - shixun_homeworks = homeworks.search_homework_type(4) #全部实训作业 + shixun_homeworks = homeworks.search_homework_type(4).includes(:score_student_works) #全部实训作业 shixun_titles = shixun_homeworks.pluck(:name) + ["总得分"] - common_homeworks = homeworks.search_homework_type(1) #全部普通作业 + common_homeworks = homeworks.search_homework_type(1).includes(:score_student_works) #全部普通作业 common_titles = common_homeworks.pluck(:name)+ ["总得分"] - group_homeworks = homeworks.search_homework_type(3) #全部分组作业 + group_homeworks = homeworks.search_homework_type(3).includes(:score_student_works) #全部分组作业 group_titles = group_homeworks.pluck(:name)+ ["总得分"] - task_titles = tasks.pluck(:name)+ ["总得分"] - exercise_titles = exercises.pluck(:exercise_name)+ ["总得分"] + task_titles = tasks.includes(:score_graduation_works).pluck(:name) + ["总得分"] + exercise_titles = exercises.includes(:score_exercise_users).pluck(:exercise_name) + ["总得分"] total_user_score_array = [] #学生总成绩集合 #课堂信息 @@ -1114,7 +1109,7 @@ class CoursesController < ApplicationController course_user_level = [] course_activity_title = "课堂活跃度统计" user_cell_head = %w(排名 真实姓名 登录名 邮箱 学号 分班 作业完成数(*10) 试卷完成数(*10) 问卷完成数(*7) 资源发布数(*5) 帖子发布数(*2) 帖子回复数(*1) 作业回复数(*1) 活跃度) - all_members.each do |u| + all_members.includes(user: :user_extension).each do |u| #用户的基本信息 user = u.user user_login = user.login @@ -1174,12 +1169,11 @@ class CoursesController < ApplicationController #实训作业 if shixun_homeworks.count > 0 shixun_homeworks.each do |s| - user_student_work = s.student_works.homework_by_user(user.id) #当前用户的对该作业的回答 - if user_student_work.blank? + user_student_work = s.score_student_works.find_by_user_id(user.id) #当前用户的对该作业的回答 + if user_student_work.nil? h_score = 0.0 #该作业的得分为0 else - user_stu_work = user_student_work.first - h_score = user_stu_work.work_score.nil? ? 0.0 : user_stu_work.work_score #用户对该作业的分数 + h_score = user_student_work.work_score.nil? ? 0.0 : user_student_work.work_score #用户对该作业的分数 end shixun_score_array.push(h_score) end @@ -1191,12 +1185,11 @@ class CoursesController < ApplicationController #普通作业 if common_homeworks.count > 0 common_homeworks.each do |c| - user_student_work_1 = c.student_works.homework_by_user(user.id) #当前用户的对该作业的回答 - if user_student_work_1.blank? + user_student_work_1 = c.score_student_works.find_by_user_id(user.id) #当前用户的对该作业的回答 + if user_student_work_1.nil? h_score_1 = 0.0 #该作业的得分为0 else - user_stu_work_1 = user_student_work_1.first - h_score_1 = user_stu_work_1.work_score.nil? ? 0.0 : user_stu_work_1.work_score #用户对该作业的分数 + h_score_1 = user_student_work_1.work_score.nil? ? 0.0 : user_student_work_1.work_score #用户对该作业的分数 end common_score_array.push(h_score_1) end @@ -1208,12 +1201,11 @@ class CoursesController < ApplicationController #分组作业 if group_homeworks.count > 0 group_homeworks.each do |g| - user_student_work_3 = g.student_works.homework_by_user(user.id) #当前用户的对该作业的回答 - if user_student_work_3.blank? + user_student_work_3 = g.score_student_works.find_by_user_id(user.id) #当前用户的对该作业的回答 + if user_student_work_3.nil? h_score_3 = 0.0 #该作业的得分为0 else - user_stu_work_3 = user_student_work_3.first - h_score_3 = user_stu_work_3.work_score.nil? ? 0.0 : user_stu_work_3.work_score #用户对该作业的分数 + h_score_3 = user_student_work_3.work_score.nil? ? 0.0 : user_student_work_3.work_score #用户对该作业的分数 end group_score_array.push(h_score_3) end @@ -1225,11 +1217,11 @@ class CoursesController < ApplicationController #毕设作业 if tasks.count > 0 tasks.each do |task| - graduation_works = task.graduation_works.find_by_task_user(user.id) - if graduation_works.empty? + graduation_work = task.score_graduation_works.find_by_user_id(user.id) + if graduation_work.nil? t_score = 0.0 else - t_score = graduation_works.first.work_score.nil? ? 0.0 : graduation_works.first.work_score + t_score = graduation_work.work_score.nil? ? 0.0 : graduation_work.work_score end task_score_array.push(t_score) end @@ -1241,11 +1233,11 @@ class CoursesController < ApplicationController #试卷 if exercises.count > 0 exercises.each do |ex| - exercise_works = ex.exercise_users.exercise_commit_users(user.id) - if exercise_works.empty? + exercise_work = ex.score_exercise_users.find_by_user_id(user.id) + if exercise_work.nil? e_score = 0.0 else - e_score = exercise_works.first.score.nil? ? 0.0 : exercise_works.first.score + e_score = exercise_work.score.nil? ? 0.0 : exercise_work.score end exercise_score_array.push(e_score) end @@ -1285,7 +1277,7 @@ class CoursesController < ApplicationController #实训作业 if count_1 > 0 shixun_homeworks.each_with_index do |s,index| - all_student_works = s.student_works.has_committed.order("work_score desc") #该实训题的全部用户回答 + all_student_works = s.score_student_works #该实训题的全部用户回答 title_no = index.to_i + 1 student_work_to_xlsx(all_student_works,s) shixun_work_display_name = (title_no.to_s + "." + s.name).strip.first(30) @@ -1297,7 +1289,7 @@ class CoursesController < ApplicationController #普通作业 if count_2 > 0 common_homeworks.each_with_index do |c,index| - all_student_works = c.student_works.has_committed.order("work_score desc") #当前用户的对该作业的回答 + all_student_works = c.score_student_works #当前用户的对该作业的回答 title_no = count_1 + index.to_i + 1 student_work_to_xlsx(all_student_works,c) @@ -1311,7 +1303,7 @@ class CoursesController < ApplicationController #分组作业 if count_3 > 0 group_homeworks.each_with_index do |c,index| - all_student_works = c.student_works.has_committed.order("work_score desc") #当前用户的对该作业的回答 + all_student_works = c.score_student_works #当前用户的对该作业的回答 title_no = count_1 + count_2 + index.to_i + 1 student_work_to_xlsx(all_student_works,c) work_name = (title_no.to_s + "." + c.name).strip.first(30) @@ -1323,7 +1315,7 @@ class CoursesController < ApplicationController #毕设任务 if count_4 > 0 tasks.each_with_index do |c,index| - all_student_works = c.graduation_works.has_committed.order("work_score desc") #当前用户的对该作业的回答 + all_student_works = c.score_graduation_works #当前用户的对该作业的回答 title_no = count_1 + count_2 + count_3 + index.to_i + 1 graduation_work_to_xlsx(all_student_works,c,current_user) work_name = (title_no.to_s + "." + c.name).strip.first(30) @@ -1336,7 +1328,7 @@ class CoursesController < ApplicationController #试卷的导出 if count_5 > 0 exercises.each_with_index do |c,index| - all_student_works = c.exercise_users.exercise_user_committed #当前用户的对该作业的回答 + all_student_works = c.score_exercise_users #当前用户的对该作业的回答 title_no = count_1 + count_2 + count_3 + count_4 + index.to_i + 1 get_export_users(c,course,all_student_works) work_name = (title_no.to_s + "." + c.exercise_name).strip.first(30) diff --git a/app/controllers/graduation_tasks_controller.rb b/app/controllers/graduation_tasks_controller.rb index 454f23c81..41ddb7659 100644 --- a/app/controllers/graduation_tasks_controller.rb +++ b/app/controllers/graduation_tasks_controller.rb @@ -145,7 +145,7 @@ class GraduationTasksController < ApplicationController file = decode64(zipfile[0][:base64file]) send_file "#{OUTPUT_FOLDER}/#{file}", filename: filename_for_content_disposition(file), type: 'application/zip' else - tip_exception(status == -1 ? "文件大小超过500M,请通过微信或者QQ联系管理员辅助您打包下载" : "无附件可下载") + tip_exception(status == -2 ? "500" : "无附件可下载") end end } diff --git a/app/controllers/homework_commons_controller.rb b/app/controllers/homework_commons_controller.rb index af1dffe71..ca8d6364d 100644 --- a/app/controllers/homework_commons_controller.rb +++ b/app/controllers/homework_commons_controller.rb @@ -229,7 +229,7 @@ class HomeworkCommonsController < ApplicationController file = decode64(zipfile[0][:base64file]) send_file "#{OUTPUT_FOLDER}/#{file}", filename: filename_for_content_disposition(file), type: 'application/zip' else - tip_exception(status == -1 ? "文件大小超过500M,请通过微信或者QQ联系管理员辅助您打包下载" : "无附件可下载") + tip_exception(status == -2 ? "500M" : "无附件可下载") end end } diff --git a/app/helpers/export_helper.rb b/app/helpers/export_helper.rb index b6720c66c..31fadc265 100644 --- a/app/helpers/export_helper.rb +++ b/app/helpers/export_helper.rb @@ -37,7 +37,7 @@ module ExportHelper end normal_head_b_cells = %w(最终成绩 提交时间 更新时间 评语) @work_head_cells = (head_cells_format + group_cells + normal_head_cells + head_cells_add + allow_late_cell + normal_head_b_cells).reject(&:blank?) - works.each_with_index do |w, index| + works.includes(student_works_scores: :user).each_with_index do |w, index| w_user = w.user w_1 = (index + 1) w_2 = w_user.login @@ -118,7 +118,7 @@ module ExportHelper end shixun_time_cells = %w(最终成绩 更新时间 提交耗时 评语) @work_head_cells = (head_cells_format + shixun_head_cells + eff_score_cell + shixun_time_cells).reject(&:blank?) - works.each_with_index do |w, index| + works.includes(:myshixun).each_with_index do |w, index| myshixun = w.try(:myshixun) w_user = w.user w_1 = (index + 1) @@ -262,18 +262,8 @@ module ExportHelper end export_ex_users.each_with_index do |e_user,index| user_info = e_user.user - user_course_id = user_info.course_members.course_find_by_ids("course_id",course.id).first - if user_course_id.present? - get_course_group_id = user_course_id.course_group_id - if get_course_group_id.present? && get_course_group_id != 0 - user_course_info = CourseGroup.by_group_ids(get_course_group_id) - user_course = user_course_info.first.name - else - user_course = "--" - end - else - user_course = "--" - end + member = course.students.find_by_user_id(e_user.user_id) + user_course = member.try(:course_group_name) user_obj_score = e_user.objective_score < 0.0 ? 0.0 : e_user.objective_score.round(1).to_s user_suj_score = e_user.subjective_score < 0.0 ? 0.0 : e_user.subjective_score.round(1).to_s user_score = e_user.score.present? ? e_user.score.round(1).to_s : 0.0 @@ -375,11 +365,11 @@ module ExportHelper end if file_size > MAX_DOWN_SIZE - status = -1 + status = -2 elsif file_count > 0 status = 0 else - status = -2 + status = -1 end status end diff --git a/app/models/exercise.rb b/app/models/exercise.rb index 60409e51d..ed003286b 100644 --- a/app/models/exercise.rb +++ b/app/models/exercise.rb @@ -3,7 +3,8 @@ class Exercise < ApplicationRecord belongs_to :exercise_bank, optional: true belongs_to :user - has_many :exercise_users, :dependent => :delete_all + has_many :exercise_users, -> { where("is_delete = 0") }, :dependent => :delete_all + has_many :score_exercise_users, -> { where("is_delete = 0 and commit_status != 0").order("score desc") }, class_name: "ExerciseUser" has_many :exercise_questions, :dependent => :delete_all has_many :exercise_group_settings, :dependent => :delete_all has_many :tidings, as: :container diff --git a/app/models/graduation_task.rb b/app/models/graduation_task.rb index d85f9782d..030978817 100644 --- a/app/models/graduation_task.rb +++ b/app/models/graduation_task.rb @@ -16,7 +16,8 @@ class GraduationTask < ApplicationRecord has_many :graduation_task_group_assignations, dependent: :destroy has_many :graduation_work_comment_assignations, dependent: :destroy - has_many :graduation_works, -> { where("is_delete != 1") } + has_many :graduation_works, -> { where("is_delete = 0") } + has_many :score_graduation_works, -> { where("is_delete = 0 and work_status != 0").order("work_score desc") }, class_name: "GraduationWork" has_many :graduation_work_scores belongs_to :gtask_bank, optional: true diff --git a/app/models/graduation_work.rb b/app/models/graduation_work.rb index e9be0a43e..093e409a9 100644 --- a/app/models/graduation_work.rb +++ b/app/models/graduation_work.rb @@ -53,7 +53,7 @@ class GraduationWork < ApplicationRecord # 分班名 def class_grouping_name - CourseMember.find_by(user_id: self.user_id, course_id: self.course_id, role: 4).try(:course_group).try(:name) || '未分班' + CourseMember.find_by(course_id: self.course_id, user_id: self.user_id, role: 4).try(:course_group).try(:name) || '未分班' end # 分组名 diff --git a/app/models/homework_common.rb b/app/models/homework_common.rb index 3e0bec5fe..193d9aa6c 100644 --- a/app/models/homework_common.rb +++ b/app/models/homework_common.rb @@ -3,7 +3,8 @@ class HomeworkCommon < ApplicationRecord enum homework_type: { normal: 1, program: 2, group: 3, practice: 4 }, _suffix: true has_many :homework_group_settings, dependent: :destroy has_many :published_settings, -> { group_published }, class_name: "HomeworkGroupSetting" - has_many :student_works, -> { where("is_delete != 1") } + has_many :student_works, -> { where("is_delete = 0") } + has_many :score_student_works, -> { where("is_delete = 0 and work_status != 0").order("work_score desc") }, class_name: "StudentWork" has_one :homework_detail_manual, dependent: :destroy # 分组作业的设置 diff --git a/app/models/poll.rb b/app/models/poll.rb index f72239ba7..1920dd939 100644 --- a/app/models/poll.rb +++ b/app/models/poll.rb @@ -5,7 +5,7 @@ class Poll < ApplicationRecord # belongs_to :exercise_bank has_many :poll_questions,dependent: :delete_all - has_many :poll_users, :dependent => :delete_all + has_many :poll_users, -> { where("is_delete != 1") }, :dependent => :delete_all has_many :users, :through => :poll_users #该文件被哪些用户提交答案过 has_many :poll_group_settings, :dependent => :delete_all has_many :course_acts, class_name: 'CourseActivity', as: :course_act, dependent: :delete_all From 8f2be183f6885306961d41ff118198f6286458c6 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Tue, 2 Jul 2019 17:11:46 +0800 Subject: [PATCH 235/256] fix bug --- app/controllers/exercises_controller.rb | 15 +++++++++------ app/controllers/polls_controller.rb | 13 +++++-------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/app/controllers/exercises_controller.rb b/app/controllers/exercises_controller.rb index b3cf1f0be..1d81ed4c2 100644 --- a/app/controllers/exercises_controller.rb +++ b/app/controllers/exercises_controller.rb @@ -1173,7 +1173,7 @@ class ExercisesController < ApplicationController ActiveRecord::Base.transaction do begin @current_user_id = current_user.id - @exercise = @exercise + @exercise = @exercise.joins(:exercise_questions,:exercise_users) exercise_ids = [@exercise.id] @exercise_status = @exercise.get_exercise_status(current_user.id) @course_all_members = @course.students @@ -1271,16 +1271,17 @@ class ExercisesController < ApplicationController #搜索 if params[:search].present? - @exercise_users_list = @exercise_users_list.joins(user: :user_extension).where("CONCAT(lastname, firstname) like ? OR student_id like ?", "%#{params[:search]}%", "%#{params[:search]}%") end + exercise_user_joins = @exercise_users_list.joins(user: :user_extension) + if order == "student_id" - @exercise_users_list = @exercise_users_list.joins(user: :user_extension).order("user_extensions.student_id DESC") + @exercise_users_list = exercise_user_joins.order("user_extensions.student_id DESC") elsif order == "score" - @exercise_users_list = @exercise_users_list.joins(user: :user_extension).order("#{order} DESC") + @exercise_users_list = exercise_user_joins.order("#{order} DESC") else - @exercise_users_list = @exercise_users_list.order("end_at DESC, start_at DESC") + @exercise_users_list = exercise_user_joins.order("end_at DESC, start_at DESC") end @export_ex_users = @exercise_users_list @@ -1297,9 +1298,11 @@ class ExercisesController < ApplicationController if @user_course_identity > Course::ASSISTANT_PROFESSOR tip_exception(403,"无权限操作") else - if @exercise_users_size == 0 + if @export_ex_users.exercise_user_committed.size == 0 normal_status(-1,"暂无用户提交") else + @exercise = @exercise.includes(:exercise_questions) + @export_ex_users = @export_ex_users.joins(user: :user_extension) get_export_users(@exercise,@course,@export_ex_users) exercise_export_name = "#{current_user.real_name}_#{@course.name}_#{@exercise.exercise_name}_#{Time.now.strftime('%Y%m%d_%H%M%S')}" diff --git a/app/controllers/polls_controller.rb b/app/controllers/polls_controller.rb index eb03345e7..44cdc6512 100644 --- a/app/controllers/polls_controller.rb +++ b/app/controllers/polls_controller.rb @@ -920,11 +920,6 @@ class PollsController < ApplicationController def commit_result ActiveRecord::Base.transaction do begin - # @poll_questions = @poll.poll_questions.order("question_number ASC") - # 全部页面,需返回 - # @poll_questions_count = @poll_questions.size - # 分页 - # @poll = @poll.includes(:poll_users,user: :user_extension) @poll_users = @poll.poll_users @poll_commit_ids = @poll_users.commit_by_status(1).pluck(:user_id) #问卷提交用户的id @page = params[:page] || 1 @@ -937,7 +932,7 @@ class PollsController < ApplicationController format.xlsx{ if @user_course_identity > Course::ASSISTANT_PROFESSOR tip_exception(403,"无权限操作") - elsif @poll_export_questions.size == 0 || (@poll_users.where("commit_status = ?",1).size == 0) + elsif (@poll.polls_status == 1) || (@poll_export_questions.size == 0) || (@poll_commit_ids.size == 0) normal_status(-1,"暂时没有提交的用户") else polls_export_name = "#{current_user.real_name}_#{@course.name}_#{@poll.polls_name}_#{Time.now.strftime('%Y%m%d_%H%M%S')}" @@ -1035,10 +1030,12 @@ class PollsController < ApplicationController @poll_users_list = @poll_users_list.joins(user: :user_extension).where("CONCAT(lastname, firstname) like ? OR student_id like ?", "%#{search_content}%", "%#{search_content}%") end + poll_users_joins = @poll_users_list.joins(user: :user_extension) + if order == "student_id" - @poll_users_list = @poll_users_list.joins(user: :user_extension).order("user_extensions.student_id DESC") + @poll_users_list = poll_users_joins.order("user_extensions.student_id DESC") else - @poll_users_list = @poll_users_list.joins(user: :user_extension).order("end_at DESC") + @poll_users_list = poll_users_joins.order("end_at DESC") end @poll_users_size = @poll_users_list.count From 35b91d96d896e57ee9d07e598fbefc8e1cdbf5f7 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Tue, 2 Jul 2019 17:15:44 +0800 Subject: [PATCH 236/256] fix bug --- app/controllers/exercises_controller.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app/controllers/exercises_controller.rb b/app/controllers/exercises_controller.rb index 1d81ed4c2..d19de52c4 100644 --- a/app/controllers/exercises_controller.rb +++ b/app/controllers/exercises_controller.rb @@ -1173,7 +1173,6 @@ class ExercisesController < ApplicationController ActiveRecord::Base.transaction do begin @current_user_id = current_user.id - @exercise = @exercise.joins(:exercise_questions,:exercise_users) exercise_ids = [@exercise.id] @exercise_status = @exercise.get_exercise_status(current_user.id) @course_all_members = @course.students @@ -1302,7 +1301,7 @@ class ExercisesController < ApplicationController normal_status(-1,"暂无用户提交") else @exercise = @exercise.includes(:exercise_questions) - @export_ex_users = @export_ex_users.joins(user: :user_extension) + @export_ex_users = @export_ex_users.includes(user: :user_extension) get_export_users(@exercise,@course,@export_ex_users) exercise_export_name = "#{current_user.real_name}_#{@course.name}_#{@exercise.exercise_name}_#{Time.now.strftime('%Y%m%d_%H%M%S')}" From 7a9a78d918390aa84854347ecca19ec296fd70dc Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Tue, 2 Jul 2019 17:34:21 +0800 Subject: [PATCH 237/256] =?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/controllers/courses_controller.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index bae37d92a..2d379b555 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -1169,7 +1169,7 @@ class CoursesController < ApplicationController #实训作业 if shixun_homeworks.count > 0 shixun_homeworks.each do |s| - user_student_work = s.score_student_works.find_by_user_id(user.id) #当前用户的对该作业的回答 + user_student_work = s.score_student_works.select{|work| work.user_id == user.id}.first #当前用户的对该作业的回答 if user_student_work.nil? h_score = 0.0 #该作业的得分为0 else @@ -1185,7 +1185,7 @@ class CoursesController < ApplicationController #普通作业 if common_homeworks.count > 0 common_homeworks.each do |c| - user_student_work_1 = c.score_student_works.find_by_user_id(user.id) #当前用户的对该作业的回答 + user_student_work_1 = c.score_student_works.select{|work| work.user_id == user.id}.first #当前用户的对该作业的回答 if user_student_work_1.nil? h_score_1 = 0.0 #该作业的得分为0 else @@ -1201,7 +1201,7 @@ class CoursesController < ApplicationController #分组作业 if group_homeworks.count > 0 group_homeworks.each do |g| - user_student_work_3 = g.score_student_works.find_by_user_id(user.id) #当前用户的对该作业的回答 + user_student_work_3 = g.score_student_works.select{|work| work.user_id == user.id}.first #当前用户的对该作业的回答 if user_student_work_3.nil? h_score_3 = 0.0 #该作业的得分为0 else @@ -1217,7 +1217,7 @@ class CoursesController < ApplicationController #毕设作业 if tasks.count > 0 tasks.each do |task| - graduation_work = task.score_graduation_works.find_by_user_id(user.id) + graduation_work = task.score_graduation_works.select{|work| work.user_id == user.id}.first if graduation_work.nil? t_score = 0.0 else @@ -1233,7 +1233,7 @@ class CoursesController < ApplicationController #试卷 if exercises.count > 0 exercises.each do |ex| - exercise_work = ex.score_exercise_users.find_by_user_id(user.id) + exercise_work = ex.score_exercise_users.select{|work| work.user_id == user.id}.first if exercise_work.nil? e_score = 0.0 else From 254a643b4f8ab7eb2145726813c01bfdb4fbcd7b Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Tue, 2 Jul 2019 18:10:08 +0800 Subject: [PATCH 238/256] fix bug --- app/controllers/exercises_controller.rb | 2 -- .../graduation_tasks_controller.rb | 10 ++++-- .../homework_commons_controller.rb | 3 +- app/controllers/zips_controller.rb | 19 +++++++--- .../batch_export_shixun_report_service.rb | 36 ++++++++++--------- 5 files changed, 43 insertions(+), 27 deletions(-) diff --git a/app/controllers/exercises_controller.rb b/app/controllers/exercises_controller.rb index d19de52c4..79bed2d25 100644 --- a/app/controllers/exercises_controller.rb +++ b/app/controllers/exercises_controller.rb @@ -1300,8 +1300,6 @@ class ExercisesController < ApplicationController if @export_ex_users.exercise_user_committed.size == 0 normal_status(-1,"暂无用户提交") else - @exercise = @exercise.includes(:exercise_questions) - @export_ex_users = @export_ex_users.includes(user: :user_extension) get_export_users(@exercise,@course,@export_ex_users) exercise_export_name = "#{current_user.real_name}_#{@course.name}_#{@exercise.exercise_name}_#{Time.now.strftime('%Y%m%d_%H%M%S')}" diff --git a/app/controllers/graduation_tasks_controller.rb b/app/controllers/graduation_tasks_controller.rb index 41ddb7659..1931c26a0 100644 --- a/app/controllers/graduation_tasks_controller.rb +++ b/app/controllers/graduation_tasks_controller.rb @@ -129,9 +129,13 @@ class GraduationTasksController < ApplicationController if @user_course_identity >= Course::STUDENT tip_exception(403, "无权限操作") else - graduation_work_to_xlsx(@work_excel,@task,current_user) - exercise_export_name = current_user.real_name + "_" + @course.name + "_" + @task.name + "_" + Time.now.strftime('%Y%m%d_%H%M%S') - render xlsx: "#{exercise_export_name.strip.first(30)}",template: "graduation_tasks/tasks_list.xlsx.axlsx",locals: {table_columns:@head_cells_column, task_users:@task_cells_column} + if @work_count > 1 + graduation_work_to_xlsx(@work_excel,@task,current_user) + exercise_export_name = "#{current_user.real_name}_#{@course.name}_#{@task.name}_#{Time.now.strftime('%Y%m%d_%H%M%S')}" + render xlsx: "#{exercise_export_name.strip.first(30)}",template: "graduation_tasks/tasks_list.xlsx.axlsx",locals: {table_columns:@head_cells_column, task_users:@task_cells_column} + else + normal_status(-1,"暂无提交的学生!") + end end } format.zip{ diff --git a/app/controllers/homework_commons_controller.rb b/app/controllers/homework_commons_controller.rb index b3953c7dd..89e301f93 100644 --- a/app/controllers/homework_commons_controller.rb +++ b/app/controllers/homework_commons_controller.rb @@ -206,8 +206,7 @@ class HomeworkCommonsController < ApplicationController if @user_course_identity >= Course::STUDENT tip_exception(403, "无权限操作") else - if @work_excel.present? - @homework = @homework.includes(:shixuns,:homework_detail_manual) + if @work_count > 1 student_work_to_xlsx(@work_excel,@homework) exercise_export_name = current_user.real_name + "_" + @course.name + "_" + @homework.name + "_" + Time.now.strftime('%Y%m%d_%H%M%S') diff --git a/app/controllers/zips_controller.rb b/app/controllers/zips_controller.rb index a70d4c332..e88f4d552 100644 --- a/app/controllers/zips_controller.rb +++ b/app/controllers/zips_controller.rb @@ -6,9 +6,11 @@ class ZipsController < ApplicationController before_action :require_admin_or_teacher def shixun_report - student_work_ids = Array.wrap(params[:student_work_ids]) + # student_work_ids = Array.wrap(params[:student_work_ids]) + + # service = BatchExportShixunReportService.new(@homework, @student_work_ids) + service = BatchExportShixunReportService.new(@homework, @all_student_works) - service = BatchExportShixunReportService.new(@homework, student_work_ids) filename = filename_for_content_disposition(service.filename) send_file service.zip, filename: filename, type: 'application/zip' @@ -57,9 +59,9 @@ class ZipsController < ApplicationController @ex_users = @ex_users.where(user_id: user_ids) end - default_ex_users_size = @ex_users.size + default_ex_users_size = @ex_users&.size - if default_ex_users_size == 0 + if default_ex_users_size.blank? || default_ex_users_size == 0 normal_status(-1,"导出失败,暂时没有已提交的学生") elsif default_ex_users_size > 100 normal_status(-2,"100") @@ -75,5 +77,14 @@ class ZipsController < ApplicationController def load_homework @homework = HomeworkCommon.find(params[:homework_common_id]) @course = @homework.course + ##7。2 -hs新增 + @member = @course.course_member(current_user.id) + @all_student_works = @homework.teacher_works(@member) + student_work_sizes = @all_student_works&.size + if student_work_sizes.blank? || student_work_sizes == 0 + normal_status(-1,"导出失败,暂时没有已提交的学生") + elsif student_work_sizes > 100 + normal_status(-2,"100") + end end end diff --git a/app/services/batch_export_shixun_report_service.rb b/app/services/batch_export_shixun_report_service.rb index 6ea38b23f..ebb273a87 100644 --- a/app/services/batch_export_shixun_report_service.rb +++ b/app/services/batch_export_shixun_report_service.rb @@ -3,11 +3,15 @@ class BatchExportShixunReportService MAX_BATCH_LIMIT = 20 - attr_reader :homework, :student_work_ids + # attr_reader :homework, :student_work_ids + attr_reader :homework, :all_student_works - def initialize(homework, student_work_ids) + + def initialize(homework, all_student_works) @homework = homework - @student_work_ids = student_work_ids + # @student_work_ids = student_work_ids + @all_student_works = all_student_works + end def filename @@ -15,8 +19,8 @@ class BatchExportShixunReportService end def zip - validate! - student_works = homework.student_works.where(id: student_work_ids).includes(:myshixun, user: :user_extension) + # validate! + student_works = all_student_works.includes(:myshixun, user: :user_extension) if student_works.count.zero? raise Error, '请选择要导出的学生实训报告' @@ -41,15 +45,15 @@ class BatchExportShixunReportService end end - private - - def validate! - if student_work_ids.size.zero? - raise Error, '请选择学生实训作业' - end - - if student_work_ids.size > MAX_BATCH_LIMIT - raise Error, '导出实训报告太多,请分批导出' - end - end + # private + # + # def validate! + # if student_work_ids.size.zero? + # raise Error, '请选择学生实训作业' + # end + # + # if student_work_ids.size > MAX_BATCH_LIMIT + # raise Error, '导出实训报告太多,请分批导出' + # end + # end end From 74e613e8045c063c235220e936b9a239c160ee2a Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Wed, 3 Jul 2019 09:21:08 +0800 Subject: [PATCH 239/256] =?UTF-8?q?pdf=E6=89=B9=E9=87=8F=E5=AF=BC=E5=87=BA?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E7=AD=9B=E9=80=89=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/zips_controller.rb | 43 +++++++++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) diff --git a/app/controllers/zips_controller.rb b/app/controllers/zips_controller.rb index e88f4d552..984bef6d2 100644 --- a/app/controllers/zips_controller.rb +++ b/app/controllers/zips_controller.rb @@ -49,9 +49,26 @@ class ZipsController < ApplicationController normal_status(-1,"试卷不存在") else @course = @exercise.course - default_ex_users = @exercise.all_exercise_users(current_user.id).exercise_user_committed @ex_users = default_ex_users #仅导出已提交的,截止后则是全部为提交的。 + + #是否评阅 + if params[:review].present? + review_type = params[:review].first.to_i #已评,则数据为1,未评,则数据为0,前端传过来的为数组 + if review_type == 1 + @ex_users = @ex_users.where("subjective_score >= ?",0.0) + else + @ex_users = @ex_users.where("subjective_score < ?",0.0) + end + end + + #答题状态的选择 + if params[:commit_status].present? && (params[:commit_status].to_i == 1) + @exercise_users_list = @exercise_users_list.where(commit_status:params[:commit_status]) + elsif params[:commit_status].present? && (params[:commit_status].to_i == 0) + normal_status(-1,"仅支持导出已提交的学生!") + end + #可以分班选择 if group_id.present? exercise_students = @course.students.where(course_group_id: group_id) # 试卷所分班的全部人数 @@ -59,6 +76,11 @@ class ZipsController < ApplicationController @ex_users = @ex_users.where(user_id: user_ids) end + #搜索 + if params[:search].present? + @ex_users = @ex_users.joins(user: :user_extension).where("CONCAT(lastname, firstname) like ? OR student_id like ?", "%#{params[:search]}%", "%#{params[:search]}%") + end + default_ex_users_size = @ex_users&.size if default_ex_users_size.blank? || default_ex_users_size == 0 @@ -80,6 +102,25 @@ class ZipsController < ApplicationController ##7。2 -hs新增 @member = @course.course_member(current_user.id) @all_student_works = @homework.teacher_works(@member) + work_status = params[:work_status] + group_id = params[:course_group] + + if work_status.present? && !work_status.include?(0) + @all_student_works = @all_student_works.where(work_status:work_status) + elsif work_status.present? && work_status.include?(0) + normal_status(-1,"仅支持导出已提交的学生!") + end + + if group_id.present? + group_user_ids = @course.students.where(course_group_id: params[:course_group]).pluck(:user_id) + @all_student_works = @all_student_works.where(user_id: group_user_ids) + end + + unless params[:search].blank? + @all_student_works = @all_student_works.joins(user: :user_extension).where("concat(lastname, firstname) like ? + or student_id like ?", "%#{params[:search]}%", "%#{params[:search]}%") + end + student_work_sizes = @all_student_works&.size if student_work_sizes.blank? || student_work_sizes == 0 normal_status(-1,"导出失败,暂时没有已提交的学生") From dfe784a051c14398029a9aaae96ecfbd51471cae Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Wed, 3 Jul 2019 09:38:22 +0800 Subject: [PATCH 240/256] fix bug --- app/controllers/exercises_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/exercises_controller.rb b/app/controllers/exercises_controller.rb index 79bed2d25..d8278faff 100644 --- a/app/controllers/exercises_controller.rb +++ b/app/controllers/exercises_controller.rb @@ -1297,7 +1297,7 @@ class ExercisesController < ApplicationController if @user_course_identity > Course::ASSISTANT_PROFESSOR tip_exception(403,"无权限操作") else - if @export_ex_users.exercise_user_committed.size == 0 + if (@exercise_users_size == 0) ||( @export_ex_users&.exercise_user_committed.size == 0) normal_status(-1,"暂无用户提交") else get_export_users(@exercise,@course,@export_ex_users) From 8768f4cb237abde1eda6f9e9221d8049f8e8e2ab Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Wed, 3 Jul 2019 09:43:04 +0800 Subject: [PATCH 241/256] fix bug --- app/controllers/exercises_controller.rb | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/app/controllers/exercises_controller.rb b/app/controllers/exercises_controller.rb index d8278faff..72e075d31 100644 --- a/app/controllers/exercises_controller.rb +++ b/app/controllers/exercises_controller.rb @@ -1291,13 +1291,15 @@ class ExercisesController < ApplicationController @page = params[:page] || 1 @limit = params[:limit] || 20 @exercise_users_list = @exercise_users_list.page(@page).per(@limit) + logger.info("#######___________@exercise_users_size_________##################{@exercise_users_size}") + logger.info("#######__________@export_ex_users&.exercise_user_committed.size_________##################{@export_ex_users&.exercise_user_committed.size}") respond_to do |format| format.json format.xlsx{ if @user_course_identity > Course::ASSISTANT_PROFESSOR tip_exception(403,"无权限操作") else - if (@exercise_users_size == 0) ||( @export_ex_users&.exercise_user_committed.size == 0) + if (@exercise_users_size == 0) || ( @export_ex_users&.exercise_user_committed.size == 0) normal_status(-1,"暂无用户提交") else get_export_users(@exercise,@course,@export_ex_users) @@ -1316,9 +1318,6 @@ class ExercisesController < ApplicationController format.xlsx{ normal_status(-1,"暂无用户提交") } - format.zip{ - normal_status(-1,"暂无用户提交") - } end end From 09a2eca61846b1ef58154a3352a08d2d756557fb Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Wed, 3 Jul 2019 09:58:59 +0800 Subject: [PATCH 242/256] =?UTF-8?q?fork=E5=AE=9E=E8=AE=AD=E5=90=8C?= =?UTF-8?q?=E6=AD=A5=E5=A4=8D=E5=88=B6=E5=8F=82=E8=80=83=E7=AD=94=E6=A1=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/shixuns_controller.rb | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/app/controllers/shixuns_controller.rb b/app/controllers/shixuns_controller.rb index 3a4592b2f..b91ce9580 100644 --- a/app/controllers/shixuns_controller.rb +++ b/app/controllers/shixuns_controller.rb @@ -203,6 +203,13 @@ class ShixunsController < ApplicationController new_challenge.user_id = User.current.id new_challenge.shixun_id = @new_shixun.id new_challenge.save! + # 同步参考答案 + challenge.challenge_answers.each do |answer| + new_answer = Challenge.new + new_answer = answer.attributes.dup.except("id","challenge_id") + new_answer.challenge_id = new_challenge.id + new_answer.save! + end if challenge.st == 0 # 评测题 # 同步测试集 if challenge.test_sets.present? From 14dc08892ce247719bbc6e3a200b93690b9f0740 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Wed, 3 Jul 2019 10:14:16 +0800 Subject: [PATCH 243/256] =?UTF-8?q?=E9=AA=8C=E8=AF=81=20format.xlsx?= =?UTF-8?q?=E4=B8=8B=E7=9A=84render=20json=E6=98=AF=E5=90=A6=E6=9C=89?= =?UTF-8?q?=E6=95=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/exercises_controller.rb | 45 +++++++++++++++++-------- 1 file changed, 31 insertions(+), 14 deletions(-) diff --git a/app/controllers/exercises_controller.rb b/app/controllers/exercises_controller.rb index 72e075d31..a1db41d79 100644 --- a/app/controllers/exercises_controller.rb +++ b/app/controllers/exercises_controller.rb @@ -1291,23 +1291,40 @@ class ExercisesController < ApplicationController @page = params[:page] || 1 @limit = params[:limit] || 20 @exercise_users_list = @exercise_users_list.page(@page).per(@limit) - logger.info("#######___________@exercise_users_size_________##################{@exercise_users_size}") - logger.info("#######__________@export_ex_users&.exercise_user_committed.size_________##################{@export_ex_users&.exercise_user_committed.size}") respond_to do |format| format.json + if @user_course_identity > Course::ASSISTANT_PROFESSOR + tip_exception(403,"无权限操作") + elsif (@exercise_users_size == 0) || ( @export_ex_users&.exercise_user_committed.size == 0) + logger.info("#######___________@exercise_users_size_________##################{@exercise_users_size}") + logger.info("#######__________@export_ex_users&.exercise_user_committed.size_________##################{@export_ex_users&.exercise_user_committed.size}") + + + normal_status(-1,"暂无用户提交") + else + format.xlsx{ + get_export_users(@exercise,@course,@export_ex_users) + exercise_export_name = + "#{current_user.real_name}_#{@course.name}_#{@exercise.exercise_name}_#{Time.now.strftime('%Y%m%d_%H%M%S')}" + render xlsx: "#{exercise_export_name.strip.first(30)}",template: "exercises/exercise_lists.xlsx.axlsx",locals: {table_columns:@table_columns,exercise_users:@user_columns} + } + end format.xlsx{ - if @user_course_identity > Course::ASSISTANT_PROFESSOR - tip_exception(403,"无权限操作") - else - if (@exercise_users_size == 0) || ( @export_ex_users&.exercise_user_committed.size == 0) - normal_status(-1,"暂无用户提交") - else - get_export_users(@exercise,@course,@export_ex_users) - exercise_export_name = - "#{current_user.real_name}_#{@course.name}_#{@exercise.exercise_name}_#{Time.now.strftime('%Y%m%d_%H%M%S')}" - render xlsx: "#{exercise_export_name.strip.first(30)}",template: "exercises/exercise_lists.xlsx.axlsx",locals: {table_columns:@table_columns,exercise_users:@user_columns} - end - end + # if @user_course_identity > Course::ASSISTANT_PROFESSOR + # tip_exception(403,"无权限操作") + # else + # if (@exercise_users_size == 0) || ( @export_ex_users&.exercise_user_committed.size == 0) + # logger.info("#######__________@export_ex_users&.exercise_user_committed.size_________##################{@export_ex_users&.exercise_user_committed.size}") + # logger.info("#######___________@exercise_users_size_________##################{@exercise_users_size}") + # + # normal_status(-1,"暂无用户提交") + # else + # get_export_users(@exercise,@course,@export_ex_users) + # exercise_export_name = + # "#{current_user.real_name}_#{@course.name}_#{@exercise.exercise_name}_#{Time.now.strftime('%Y%m%d_%H%M%S')}" + # render xlsx: "#{exercise_export_name.strip.first(30)}",template: "exercises/exercise_lists.xlsx.axlsx",locals: {table_columns:@table_columns,exercise_users:@user_columns} + # end + # end } end else From d7649d04421ab02105d40d987072a75a2d46f254 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Wed, 3 Jul 2019 10:16:18 +0800 Subject: [PATCH 244/256] fix bug --- app/controllers/exercises_controller.rb | 46 ++++++++----------------- 1 file changed, 15 insertions(+), 31 deletions(-) diff --git a/app/controllers/exercises_controller.rb b/app/controllers/exercises_controller.rb index a1db41d79..038d9a87c 100644 --- a/app/controllers/exercises_controller.rb +++ b/app/controllers/exercises_controller.rb @@ -1293,38 +1293,22 @@ class ExercisesController < ApplicationController @exercise_users_list = @exercise_users_list.page(@page).per(@limit) respond_to do |format| format.json - if @user_course_identity > Course::ASSISTANT_PROFESSOR - tip_exception(403,"无权限操作") - elsif (@exercise_users_size == 0) || ( @export_ex_users&.exercise_user_committed.size == 0) - logger.info("#######___________@exercise_users_size_________##################{@exercise_users_size}") - logger.info("#######__________@export_ex_users&.exercise_user_committed.size_________##################{@export_ex_users&.exercise_user_committed.size}") - - - normal_status(-1,"暂无用户提交") - else - format.xlsx{ - get_export_users(@exercise,@course,@export_ex_users) - exercise_export_name = - "#{current_user.real_name}_#{@course.name}_#{@exercise.exercise_name}_#{Time.now.strftime('%Y%m%d_%H%M%S')}" - render xlsx: "#{exercise_export_name.strip.first(30)}",template: "exercises/exercise_lists.xlsx.axlsx",locals: {table_columns:@table_columns,exercise_users:@user_columns} - } - end format.xlsx{ - # if @user_course_identity > Course::ASSISTANT_PROFESSOR - # tip_exception(403,"无权限操作") - # else - # if (@exercise_users_size == 0) || ( @export_ex_users&.exercise_user_committed.size == 0) - # logger.info("#######__________@export_ex_users&.exercise_user_committed.size_________##################{@export_ex_users&.exercise_user_committed.size}") - # logger.info("#######___________@exercise_users_size_________##################{@exercise_users_size}") - # - # normal_status(-1,"暂无用户提交") - # else - # get_export_users(@exercise,@course,@export_ex_users) - # exercise_export_name = - # "#{current_user.real_name}_#{@course.name}_#{@exercise.exercise_name}_#{Time.now.strftime('%Y%m%d_%H%M%S')}" - # render xlsx: "#{exercise_export_name.strip.first(30)}",template: "exercises/exercise_lists.xlsx.axlsx",locals: {table_columns:@table_columns,exercise_users:@user_columns} - # end - # end + if @user_course_identity > Course::ASSISTANT_PROFESSOR + tip_exception(403,"无权限操作") + else + if (@exercise_users_size == 0) || ( @export_ex_users&.exercise_user_committed.size == 0) + logger.info("#######__________@export_ex_users&.exercise_user_committed.size_________##################{@export_ex_users&.exercise_user_committed.size}") + logger.info("#######___________@exercise_users_size_________##################{@exercise_users_size}") + + normal_status(-1,"暂无用户提交") + else + get_export_users(@exercise,@course,@export_ex_users) + exercise_export_name = + "#{current_user.real_name}_#{@course.name}_#{@exercise.exercise_name}_#{Time.now.strftime('%Y%m%d_%H%M%S')}" + render xlsx: "#{exercise_export_name.strip.first(30)}",template: "exercises/exercise_lists.xlsx.axlsx",locals: {table_columns:@table_columns,exercise_users:@user_columns} + end + end } end else From 9fc9bf97e56bbbaf6d2fc4bda6e089c90c4fae44 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Wed, 3 Jul 2019 10:23:43 +0800 Subject: [PATCH 245/256] fix bug --- app/controllers/exercises_controller.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/controllers/exercises_controller.rb b/app/controllers/exercises_controller.rb index 038d9a87c..a10e5ad1b 100644 --- a/app/controllers/exercises_controller.rb +++ b/app/controllers/exercises_controller.rb @@ -1291,6 +1291,7 @@ class ExercisesController < ApplicationController @page = params[:page] || 1 @limit = params[:limit] || 20 @exercise_users_list = @exercise_users_list.page(@page).per(@limit) + tip_exception(403,"无权限操作") respond_to do |format| format.json format.xlsx{ From 39f75a0dc75de9401453b8da6ab3b332ba8d92a4 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Wed, 3 Jul 2019 10:30:46 +0800 Subject: [PATCH 246/256] fix bug --- app/controllers/exercises_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/exercises_controller.rb b/app/controllers/exercises_controller.rb index a10e5ad1b..090386361 100644 --- a/app/controllers/exercises_controller.rb +++ b/app/controllers/exercises_controller.rb @@ -1291,7 +1291,7 @@ class ExercisesController < ApplicationController @page = params[:page] || 1 @limit = params[:limit] || 20 @exercise_users_list = @exercise_users_list.page(@page).per(@limit) - tip_exception(403,"无权限操作") + logger.info("###########______________format.xlsx_______#######{format.xlsx}") respond_to do |format| format.json format.xlsx{ From ca4c84d6c2f6f6b425bf0e59f2cd2eb33133f5c9 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Wed, 3 Jul 2019 10:35:09 +0800 Subject: [PATCH 247/256] fix bug --- app/controllers/exercises_controller.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/controllers/exercises_controller.rb b/app/controllers/exercises_controller.rb index 090386361..a050e7eaa 100644 --- a/app/controllers/exercises_controller.rb +++ b/app/controllers/exercises_controller.rb @@ -1291,7 +1291,10 @@ class ExercisesController < ApplicationController @page = params[:page] || 1 @limit = params[:limit] || 20 @exercise_users_list = @exercise_users_list.page(@page).per(@limit) - logger.info("###########______________format.xlsx_______#######{format.xlsx}") + if params[:format] == "xlsx" + logger.info("###########______________format.xlsx______111111111_#######") + + end respond_to do |format| format.json format.xlsx{ From 92006341b66a9a21e878982206b30a0108238eea Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Wed, 3 Jul 2019 10:48:12 +0800 Subject: [PATCH 248/256] fix bug --- app/controllers/exercises_controller.rb | 56 ++++++++++++------------- app/controllers/polls_controller.rb | 42 ++++++++++++------- 2 files changed, 54 insertions(+), 44 deletions(-) diff --git a/app/controllers/exercises_controller.rb b/app/controllers/exercises_controller.rb index a050e7eaa..2fcf45cda 100644 --- a/app/controllers/exercises_controller.rb +++ b/app/controllers/exercises_controller.rb @@ -1291,39 +1291,37 @@ class ExercisesController < ApplicationController @page = params[:page] || 1 @limit = params[:limit] || 20 @exercise_users_list = @exercise_users_list.page(@page).per(@limit) - if params[:format] == "xlsx" - logger.info("###########______________format.xlsx______111111111_#######") - - end - respond_to do |format| - format.json - format.xlsx{ - if @user_course_identity > Course::ASSISTANT_PROFESSOR - tip_exception(403,"无权限操作") - else - if (@exercise_users_size == 0) || ( @export_ex_users&.exercise_user_committed.size == 0) - logger.info("#######__________@export_ex_users&.exercise_user_committed.size_________##################{@export_ex_users&.exercise_user_committed.size}") - logger.info("#######___________@exercise_users_size_________##################{@exercise_users_size}") - - normal_status(-1,"暂无用户提交") - else - get_export_users(@exercise,@course,@export_ex_users) - exercise_export_name = - "#{current_user.real_name}_#{@course.name}_#{@exercise.exercise_name}_#{Time.now.strftime('%Y%m%d_%H%M%S')}" - render xlsx: "#{exercise_export_name.strip.first(30)}",template: "exercises/exercise_lists.xlsx.axlsx",locals: {table_columns:@table_columns,exercise_users:@user_columns} - end - end - } - end else @exercise_users_list = [] + @export_ex_users = @exercise_users_list @exercise_users_size = 0 - respond_to do |format| - format.json - format.xlsx{ - normal_status(-1,"暂无用户提交") - } + end + + if params[:format] == "xlsx" + if @user_course_identity > Course::ASSISTANT_PROFESSOR + tip_exception(403,"无权限操作") + elsif (@exercise_users_size == 0) || ( @export_ex_users&.exercise_user_committed.size == 0) + normal_status(-1,"暂无用户提交") + else + respond_to do |format| + format.xlsx{ + get_export_users(@exercise,@course,@export_ex_users) + exercise_export_name = + "#{current_user.real_name}_#{@course.name}_#{@exercise.exercise_name}_#{Time.now.strftime('%Y%m%d_%H%M%S')}" + render xlsx: "#{exercise_export_name.strip.first(30)}",template: "exercises/exercise_lists.xlsx.axlsx",locals: {table_columns:@table_columns,exercise_users:@user_columns} + } + end end + # else + # respond_to do |format| + # format.json + # format.xlsx{ + # get_export_users(@exercise,@course,@export_ex_users) + # exercise_export_name = + # "#{current_user.real_name}_#{@course.name}_#{@exercise.exercise_name}_#{Time.now.strftime('%Y%m%d_%H%M%S')}" + # render xlsx: "#{exercise_export_name.strip.first(30)}",template: "exercises/exercise_lists.xlsx.axlsx",locals: {table_columns:@table_columns,exercise_users:@user_columns} + # } + # end end rescue Exception => e diff --git a/app/controllers/polls_controller.rb b/app/controllers/polls_controller.rb index 44cdc6512..7075ac0ef 100644 --- a/app/controllers/polls_controller.rb +++ b/app/controllers/polls_controller.rb @@ -927,23 +927,35 @@ class PollsController < ApplicationController @poll_export_questions = @poll_questions.order("question_number ASC") @poll_questions = @poll_questions.page(@page).per(@limit) - respond_to do |format| - format.json - format.xlsx{ - if @user_course_identity > Course::ASSISTANT_PROFESSOR - tip_exception(403,"无权限操作") - elsif (@poll.polls_status == 1) || (@poll_export_questions.size == 0) || (@poll_commit_ids.size == 0) - normal_status(-1,"暂时没有提交的用户") - else - polls_export_name = "#{current_user.real_name}_#{@course.name}_#{@poll.polls_name}_#{Time.now.strftime('%Y%m%d_%H%M%S')}" - render xlsx: "#{polls_export_name.strip.first(30)}",template: "polls/commit_result.xlsx.axlsx",locals: { - poll_questions:@poll_export_questions, - poll:@poll, - poll_users: @poll_users, - poll_commit_ids:@poll_commit_ids} + if params[:format] == "xlsx" + if @user_course_identity > Course::ASSISTANT_PROFESSOR + tip_exception(403,"无权限操作") + elsif (@poll.polls_status == 1) || (@poll_export_questions.size == 0) || (@poll_commit_ids.size == 0) + normal_status(-1,"暂无用户提交") + else + respond_to do |format| + format.xlsx{ + polls_export_name = "#{current_user.real_name}_#{@course.name}_#{@poll.polls_name}_#{Time.now.strftime('%Y%m%d_%H%M%S')}" + render xlsx: "#{polls_export_name.strip.first(30)}",template: "polls/commit_result.xlsx.axlsx",locals: { + poll_questions:@poll_export_questions, + poll:@poll, + poll_users: @poll_users, + poll_commit_ids:@poll_commit_ids} + } end - } + end end + # respond_to do |format| + # format.json + # format.xlsx{ + # polls_export_name = "#{current_user.real_name}_#{@course.name}_#{@poll.polls_name}_#{Time.now.strftime('%Y%m%d_%H%M%S')}" + # render xlsx: "#{polls_export_name.strip.first(30)}",template: "polls/commit_result.xlsx.axlsx",locals: { + # poll_questions:@poll_export_questions, + # poll:@poll, + # poll_users: @poll_users, + # poll_commit_ids:@poll_commit_ids} + # } + # end rescue Exception => e uid_logger_error(e.message) tip_exception("页面调用失败!") From e6f5a2b13a314ab4ec6625cd7ea19f545a0b38b8 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Wed, 3 Jul 2019 10:58:24 +0800 Subject: [PATCH 249/256] =?UTF-8?q?=E8=AF=95=E5=8D=B7=E7=9A=84xlsx?= =?UTF-8?q?=E9=94=99=E8=AF=AF=E6=8F=90=E7=A4=BA=E7=9A=84=E6=B7=BB=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/exercises_controller.rb | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/app/controllers/exercises_controller.rb b/app/controllers/exercises_controller.rb index 2fcf45cda..c5cf7390f 100644 --- a/app/controllers/exercises_controller.rb +++ b/app/controllers/exercises_controller.rb @@ -1298,9 +1298,16 @@ class ExercisesController < ApplicationController end if params[:format] == "xlsx" + logger.info("#######___________params_xlsx____________##########") + logger.info("#######___________@exercise_users_size____________##########{@exercise_users_size}") + logger.info("#######___________@export_ex_users&.exercise_user_committed.size____________##########{@export_ex_users&.exercise_user_committed.size}") + + if @user_course_identity > Course::ASSISTANT_PROFESSOR tip_exception(403,"无权限操作") elsif (@exercise_users_size == 0) || ( @export_ex_users&.exercise_user_committed.size == 0) + logger.info("#######___________@exercise_users_size == 0____________##########") + normal_status(-1,"暂无用户提交") else respond_to do |format| @@ -1312,18 +1319,7 @@ class ExercisesController < ApplicationController } end end - # else - # respond_to do |format| - # format.json - # format.xlsx{ - # get_export_users(@exercise,@course,@export_ex_users) - # exercise_export_name = - # "#{current_user.real_name}_#{@course.name}_#{@exercise.exercise_name}_#{Time.now.strftime('%Y%m%d_%H%M%S')}" - # render xlsx: "#{exercise_export_name.strip.first(30)}",template: "exercises/exercise_lists.xlsx.axlsx",locals: {table_columns:@table_columns,exercise_users:@user_columns} - # } - # end end - rescue Exception => e uid_logger_error(e.message) tip_exception("页面调用失败!") From 1b4103a54b1377da8dbd17d661b33681fff65f07 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Wed, 3 Jul 2019 11:00:29 +0800 Subject: [PATCH 250/256] =?UTF-8?q?copy=E5=8F=82=E8=80=83=E7=AD=94?= =?UTF-8?q?=E6=A1=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/shixuns_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/shixuns_controller.rb b/app/controllers/shixuns_controller.rb index b91ce9580..265398833 100644 --- a/app/controllers/shixuns_controller.rb +++ b/app/controllers/shixuns_controller.rb @@ -205,7 +205,7 @@ class ShixunsController < ApplicationController new_challenge.save! # 同步参考答案 challenge.challenge_answers.each do |answer| - new_answer = Challenge.new + new_answer = ChallengeAnswer.new new_answer = answer.attributes.dup.except("id","challenge_id") new_answer.challenge_id = new_challenge.id new_answer.save! From 04dc476b8854cd3f03178017f030e4c099c37296 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Wed, 3 Jul 2019 11:02:45 +0800 Subject: [PATCH 251/256] =?UTF-8?q?copy=E5=8F=82=E8=80=83=E7=AD=94?= =?UTF-8?q?=E6=A1=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/shixuns_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/shixuns_controller.rb b/app/controllers/shixuns_controller.rb index 265398833..fdd55e6cf 100644 --- a/app/controllers/shixuns_controller.rb +++ b/app/controllers/shixuns_controller.rb @@ -206,7 +206,7 @@ class ShixunsController < ApplicationController # 同步参考答案 challenge.challenge_answers.each do |answer| new_answer = ChallengeAnswer.new - new_answer = answer.attributes.dup.except("id","challenge_id") + new_answer = new_answer.attributes.dup.except("id","challenge_id") new_answer.challenge_id = new_challenge.id new_answer.save! end From af4922ea72ac791332f2fea62e96bc243b25049c Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Wed, 3 Jul 2019 11:05:31 +0800 Subject: [PATCH 252/256] 1 --- app/controllers/shixuns_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/shixuns_controller.rb b/app/controllers/shixuns_controller.rb index fdd55e6cf..265398833 100644 --- a/app/controllers/shixuns_controller.rb +++ b/app/controllers/shixuns_controller.rb @@ -206,7 +206,7 @@ class ShixunsController < ApplicationController # 同步参考答案 challenge.challenge_answers.each do |answer| new_answer = ChallengeAnswer.new - new_answer = new_answer.attributes.dup.except("id","challenge_id") + new_answer = answer.attributes.dup.except("id","challenge_id") new_answer.challenge_id = new_challenge.id new_answer.save! end From 35c3cc1e2937ac9d86e6653601676f8ecbac82b2 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Wed, 3 Jul 2019 11:07:29 +0800 Subject: [PATCH 253/256] =?UTF-8?q?copy=E5=AE=9E=E8=AE=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/shixuns_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/shixuns_controller.rb b/app/controllers/shixuns_controller.rb index 265398833..5a1773a10 100644 --- a/app/controllers/shixuns_controller.rb +++ b/app/controllers/shixuns_controller.rb @@ -206,7 +206,7 @@ class ShixunsController < ApplicationController # 同步参考答案 challenge.challenge_answers.each do |answer| new_answer = ChallengeAnswer.new - new_answer = answer.attributes.dup.except("id","challenge_id") + new_answer.attributes = answer.attributes.dup.except("id","challenge_id") new_answer.challenge_id = new_challenge.id new_answer.save! end From 275030bb6a3221f7eaa91bb14231d1928713438a Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Wed, 3 Jul 2019 11:07:31 +0800 Subject: [PATCH 254/256] fix bug --- app/controllers/exercises_controller.rb | 27 ++++++++++--------------- 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/app/controllers/exercises_controller.rb b/app/controllers/exercises_controller.rb index c5cf7390f..dd19c36d1 100644 --- a/app/controllers/exercises_controller.rb +++ b/app/controllers/exercises_controller.rb @@ -1298,28 +1298,23 @@ class ExercisesController < ApplicationController end if params[:format] == "xlsx" - logger.info("#######___________params_xlsx____________##########") - logger.info("#######___________@exercise_users_size____________##########{@exercise_users_size}") - logger.info("#######___________@export_ex_users&.exercise_user_committed.size____________##########{@export_ex_users&.exercise_user_committed.size}") - - if @user_course_identity > Course::ASSISTANT_PROFESSOR tip_exception(403,"无权限操作") elsif (@exercise_users_size == 0) || ( @export_ex_users&.exercise_user_committed.size == 0) - logger.info("#######___________@exercise_users_size == 0____________##########") - normal_status(-1,"暂无用户提交") - else - respond_to do |format| - format.xlsx{ - get_export_users(@exercise,@course,@export_ex_users) - exercise_export_name = - "#{current_user.real_name}_#{@course.name}_#{@exercise.exercise_name}_#{Time.now.strftime('%Y%m%d_%H%M%S')}" - render xlsx: "#{exercise_export_name.strip.first(30)}",template: "exercises/exercise_lists.xlsx.axlsx",locals: {table_columns:@table_columns,exercise_users:@user_columns} - } - end + end end + + respond_to do |format| + format.json + format.xlsx{ + get_export_users(@exercise,@course,@export_ex_users) + exercise_export_name = + "#{current_user.real_name}_#{@course.name}_#{@exercise.exercise_name}_#{Time.now.strftime('%Y%m%d_%H%M%S')}" + render xlsx: "#{exercise_export_name.strip.first(30)}",template: "exercises/exercise_lists.xlsx.axlsx",locals: {table_columns:@table_columns,exercise_users:@user_columns} + } + end rescue Exception => e uid_logger_error(e.message) tip_exception("页面调用失败!") From cece1eee5f0b48a1964c4f1049c773d87a08037e Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Wed, 3 Jul 2019 11:08:36 +0800 Subject: [PATCH 255/256] =?UTF-8?q?=E5=AF=BC=E5=87=BA=E6=88=90=E7=BB=A9?= =?UTF-8?q?=E7=9A=84=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/courses_controller.rb | 222 +++++++++++++++----------- app/helpers/export_helper.rb | 21 +-- app/models/myshixun.rb | 2 +- 3 files changed, 143 insertions(+), 102 deletions(-) diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index 2d379b555..26e70f471 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -959,18 +959,20 @@ class CoursesController < ApplicationController def export_member_scores_excel ActiveRecord::Base.transaction do begin - name = params[:name] ? "#{params[:name].strip}" : "" #用户名或学生学号id搜索 + search = params[:search] ? "#{params[:search].strip}" : "" #用户名或学生学号id搜索 group_id = params[:group_id] #分班的班级id - if group_id && group_id != "0" && group_id != "-1" - @all_members = @course.students.course_find_by_ids("course_group_id",group_id) - elsif group_id && group_id == "0" # 未分班 - @all_members = @course.course_members.ungroup_students - else - @all_members = @course.students - end - if name.present? - @all_members = @all_members.joins(user: [:user_extension]).where('concat(users.lastname, users.firstname) like ? or user_extensions.student_id like ?',"%#{name}%","%#{name}%") - end + # if group_id && group_id != "0" && group_id != "-1" + # @all_members = @course.students.course_find_by_ids("course_group_id",group_id) + # elsif group_id && group_id == "0" # 未分班 + # @all_members = @course.course_members.ungroup_students + # else + # @all_members = @course.students + # end + # if name.present? + # @all_members = @all_members.joins(user: [:user_extension]).where('concat(users.lastname, users.firstname) like ? or user_extensions.student_id like ?',"%#{name}%","%#{name}%") + # end + + @all_members = student_act_score group_id, search @c_homeworks = @course.homework_commons.homework_published.order("homework_commons.publish_time asc, homework_commons.created_at asc") @c_exercises = @course.exercises.is_exercise_published.order("exercises.publish_time asc, exercises.created_at asc") @@ -981,7 +983,7 @@ class CoursesController < ApplicationController else member_to_xlsx(@course, @all_members, @c_homeworks, @c_exercises, @c_tasks, @c_polls) filename = current_user.real_name + "_" + @course.name + "_全部成绩" + Time.now.strftime('%Y%m%d_%H%M%S') - render xlsx: "#{filename.strip.first(30)}",template: "courses/export_member_scores_excel.xlsx.axlsx", + render xlsx: "#{format_sheet_name filename.strip.first(30)}",template: "courses/export_member_scores_excel.xlsx.axlsx", locals: {course_info:@course_info, activity_level:@user_activity_level, course_scores:@course_user_scores,shixun_works:@shixun_work_arrays, common_works:@common_work_arrays,group_works:@group_work_arrays,task_works:@task_work_arrays, @@ -1051,16 +1053,68 @@ class CoursesController < ApplicationController end end - def member_to_xlsx(course,all_members,homeworks,exercises,tasks,polls) + def student_act_score group_id, search + sql_select = %Q{SELECT cm.*,( + SELECT SUM(student_works.work_score) + FROM student_works,homework_commons + WHERE student_works.homework_common_id = homework_commons.id + AND homework_commons.course_id = #{@course.id} + AND student_works.user_id = cm.user_id + ) AS score, + (SELECT SUM(gw.work_score) FROM graduation_works gw,graduation_tasks gt WHERE gw.graduation_task_id = gt.id + AND gt.course_id = #{@course.id} AND gw.user_id = cm.user_id) AS graduation_score, + (SELECT SUM(exercise_users.score) FROM exercise_users,exercises WHERE exercise_users.exercise_id = exercises.id + AND exercises.course_id = #{@course.id} AND exercise_users.user_id = cm.user_id) AS ex_score, + (SELECT max(student_id) FROM user_extensions WHERE user_extensions.user_id = cm.user_id) AS student_id, + (SELECT max(message_num) FROM course_contributor_scores AS ccs WHERE ccs.course_id = #{@course.id} AND ccs.user_id = cm.user_id) AS message_num, + (SELECT max(message_reply_num) FROM course_contributor_scores AS ccs WHERE ccs.course_id = #{@course.id} AND ccs.user_id = cm.user_id) AS message_reply_num, + (SELECT max(resource_num) FROM course_contributor_scores AS ccs WHERE ccs.course_id = #{@course.id} AND ccs.user_id = cm.user_id) AS resource_num, + (SELECT max(homework_journal_num) FROM course_contributor_scores AS ccs WHERE ccs.course_id = #{@course.id} AND ccs.user_id = cm.user_id) AS homework_journal_num, + (SELECT COUNT(gw.id) FROM graduation_works AS gw, graduation_tasks AS gt WHERE gw.graduation_task_id = gt.id AND gt.course_id = #{@course.id} AND gw.work_status != 0 AND gw.user_id = cm.user_id) AS graduation_num, + (SELECT COUNT(ss.id) FROM student_works AS ss ,homework_commons AS hc WHERE ss.homework_common_id = hc.id AND hc.course_id = #{@course.id} AND ss.work_status != 0 AND ss.user_id = cm.user_id) AS homework_num, + (SELECT COUNT(eu.id) FROM exercise_users AS eu,exercises WHERE eu.exercise_id = exercises.id AND exercises.course_id = #{@course.id} AND eu.commit_status = 1 AND eu.user_id = cm.user_id) AS exercise_num, + (SELECT COUNT(pu.id) FROM poll_users AS pu, polls WHERE pu.poll_id = polls.id AND polls.course_id = #{@course.id} AND pu.commit_status = 1 AND pu.user_id = cm.user_id) AS poll_num + FROM course_members cm} + if search.present? && group_id.present? + sql_select += %Q{ join users on cm.user_id = users.id + joins user_extensions ue on ue.user_id = users.id + WHERE cm.role = 4 and cm.course_id = #{@course.id} and cm.course_group_id = #{group_id} and + (concat(users.lastname, users.firstname) like '%#{search}%' or ue.student_id like '%#{search}%') ORDER BY score desc} + + elsif search.present? + ql_select += %Q{ join users on cm.user_id = users.id + joins user_extensions ue on ue.user_id = users.id + WHERE cm.role = 4 and + (concat(users.lastname, users.firstname) like '%#{search}%' or ue.student_id like '%#{search}%') ORDER BY score desc} + elsif group_id.present? + sql_select += %Q{ WHERE cm.role = 4 and cm.course_id = #{@course.id} and cm.course_group_id = #{group_id} ORDER BY score desc} + else + sql_select += %Q{ WHERE cm.role = 4 and cm.course_id = #{@course.id} ORDER BY score desc} + end + act_scores = CourseMember.find_by_sql(sql_select) + act_scores + end + + def member_to_xlsx(course,all_members,homeworks,exercises,tasks) #课堂的作业信息 - shixun_homeworks = homeworks.search_homework_type(4).includes(:score_student_works) #全部实训作业 + shixun_homeworks = homeworks.search_homework_type(4) #全部实训作业 shixun_titles = shixun_homeworks.pluck(:name) + ["总得分"] - common_homeworks = homeworks.search_homework_type(1).includes(:score_student_works) #全部普通作业 + shixun_homeworks = shixun_homeworks.includes(:score_student_works) + + common_homeworks = homeworks.search_homework_type(1) #全部普通作业 common_titles = common_homeworks.pluck(:name)+ ["总得分"] + common_homeworks = common_homeworks.includes(:score_student_works) + group_homeworks = homeworks.search_homework_type(3).includes(:score_student_works) #全部分组作业 group_titles = group_homeworks.pluck(:name)+ ["总得分"] - task_titles = tasks.includes(:score_graduation_works).pluck(:name) + ["总得分"] - exercise_titles = exercises.includes(:score_exercise_users).pluck(:exercise_name) + ["总得分"] + group_homeworks = group_homeworks.includes(:score_student_works) + + task_titles = tasks.pluck(:name) + ["总得分"] + tasks = tasks.includes(:score_graduation_works) + + exercise_titles = exercises.pluck(:exercise_name) + ["总得分"] + exercises = exercises.includes(:score_exercise_users) + total_user_score_array = [] #学生总成绩集合 #课堂信息 @@ -1075,7 +1129,7 @@ class CoursesController < ApplicationController course_teacher_member = course.course_members.course_user_role(%i[CREATOR]) course_teacher = course_teacher_member.present? ? course_teacher_member.first.user.real_name : "--" course_class_counts = course.course_groups_count - course_students_count = course.students.count + course_students_count = course.students.size course_1 = ["课堂编号",course_id] course_2 = ["课程名称",course_list_name] course_3 = ["课堂名称",course_name] @@ -1100,16 +1154,11 @@ class CoursesController < ApplicationController @course_info += [course_info_title,course_main_info,course_group_info] #课堂活跃度 - course_homework_ids = homeworks.pluck(:id) #该课堂的全部作业id - course_graduate_task_ids = tasks.pluck(:id) #该课堂的全部毕业任务id - course_exercise_ids = exercises.pluck(:id) #课堂的全部试卷数 - course_poll_ids = polls.pluck(:id) #课堂的全部问卷数 - course_board_ids = course.boards.pluck(:id) #课堂的全部讨论区 @user_activity_level = [] course_user_level = [] course_activity_title = "课堂活跃度统计" user_cell_head = %w(排名 真实姓名 登录名 邮箱 学号 分班 作业完成数(*10) 试卷完成数(*10) 问卷完成数(*7) 资源发布数(*5) 帖子发布数(*2) 帖子回复数(*1) 作业回复数(*1) 活跃度) - all_members.includes(user: :user_extension).each do |u| + all_members.each do |u| #用户的基本信息 user = u.user user_login = user.login @@ -1121,15 +1170,14 @@ class CoursesController < ApplicationController user_work_scores = [] #课堂活跃度统计 - user_homeworks_num = user.student_works.find_by_homework(course_homework_ids).has_committed.count #完成的作业数 - user_graduate_num = user.graduation_works.find_by_task(course_graduate_task_ids).has_committed.count #毕业任务完成数 - user_exercise_num = user.exercise_users.search_by_exercise(course_exercise_ids).commit_exercise_by_status(1).count #根据试卷的id来查找 - user_poll_num = user.poll_users.search_by_poll(course_poll_ids).commit_by_status(1).count #已完成问卷 - user_file_num = user.attachments.search_by_container(course.id).count - user_messages = user.messages - user_messages_num = user_messages.root_nodes.find_by_boards(course_board_ids).count #帖子发布数 - user_reply_num = user_messages.reply_nodes.find_by_boards(course_board_ids).count #帖子回复数 - user_work_reply_num = user.journals_for_messages.search_by_jour_type("HomeworkCommon",course_homework_ids).count #作业回复数的数量 + user_homeworks_num = u.homework_num.to_i #完成的作业数 + user_graduate_num = u.graduation_num.to_i #毕业任务完成数 + user_exercise_num = u.exercise_num.to_i #根据试卷的id来查找 + user_poll_num = u.poll_num.to_i #已完成问卷 + user_file_num = u.resource_num.to_i + user_messages_num = u.message_num.to_i #帖子发布数 + user_reply_num = u.message_reply_num.to_i #帖子回复数 + user_work_reply_num = u.homework_journal_num.to_i #作业回复数的数量 c_works_num = (user_homeworks_num + user_graduate_num)*10 c_exercise_num = user_exercise_num*10 c_poll_num = user_poll_num*7 @@ -1167,7 +1215,7 @@ class CoursesController < ApplicationController exercise_score_array = [] #实训作业 - if shixun_homeworks.count > 0 + if shixun_homeworks.size > 0 shixun_homeworks.each do |s| user_student_work = s.score_student_works.select{|work| work.user_id == user.id}.first #当前用户的对该作业的回答 if user_student_work.nil? @@ -1183,7 +1231,7 @@ class CoursesController < ApplicationController user_work_scores += user_info_array + shixun_score_array #单个用户的实训作业得分信息 #普通作业 - if common_homeworks.count > 0 + if common_homeworks.size > 0 common_homeworks.each do |c| user_student_work_1 = c.score_student_works.select{|work| work.user_id == user.id}.first #当前用户的对该作业的回答 if user_student_work_1.nil? @@ -1199,7 +1247,7 @@ class CoursesController < ApplicationController user_work_scores += common_score_array #单个用户的普通作业得分信息 #分组作业 - if group_homeworks.count > 0 + if group_homeworks.size > 0 group_homeworks.each do |g| user_student_work_3 = g.score_student_works.select{|work| work.user_id == user.id}.first #当前用户的对该作业的回答 if user_student_work_3.nil? @@ -1215,7 +1263,7 @@ class CoursesController < ApplicationController user_work_scores += group_score_array #单个用户的分组作业得分信息 #毕设作业 - if tasks.count > 0 + if tasks.size > 0 tasks.each do |task| graduation_work = task.score_graduation_works.select{|work| work.user_id == user.id}.first if graduation_work.nil? @@ -1231,7 +1279,7 @@ class CoursesController < ApplicationController user_work_scores += task_score_array #单个用户的分组作业得分信息 #试卷 - if exercises.count > 0 + if exercises.size > 0 exercises.each do |ex| exercise_work = ex.score_exercise_users.select{|work| work.user_id == user.id}.first if exercise_work.nil? @@ -1269,73 +1317,63 @@ class CoursesController < ApplicationController @common_work_arrays = [] @task_work_arrays = [] @exercise_work_arrays = [] - count_1 = shixun_homeworks.count - count_2 = common_homeworks.count - count_3 = group_homeworks.count - count_4 = tasks.count - count_5 = exercises.count + count_1 = shixun_homeworks.size + count_2 = common_homeworks.size + count_3 = group_homeworks.size + count_4 = tasks.size + count_5 = exercises.size #实训作业 - if count_1 > 0 - shixun_homeworks.each_with_index do |s,index| - all_student_works = s.score_student_works #该实训题的全部用户回答 - title_no = index.to_i + 1 - student_work_to_xlsx(all_student_works,s) - shixun_work_display_name = (title_no.to_s + "." + s.name).strip.first(30) - shixun_work_content = [shixun_work_display_name,@work_head_cells,@work_cells_column] - @shixun_work_arrays.push(shixun_work_content) - end + shixun_homeworks.each_with_index do |s,index| + all_student_works = s.score_student_works #该实训题的全部用户回答 + title_no = index.to_i + 1 + student_work_to_xlsx(all_student_works,s) + shixun_work_display_name = format_sheet_name (title_no.to_s + "." + s.name).strip.first(30) + shixun_work_content = [shixun_work_display_name,@work_head_cells,@work_cells_column] + @shixun_work_arrays.push(shixun_work_content) end #普通作业 - if count_2 > 0 - common_homeworks.each_with_index do |c,index| - all_student_works = c.score_student_works #当前用户的对该作业的回答 - title_no = count_1 + index.to_i + 1 - student_work_to_xlsx(all_student_works,c) - - work_name = (title_no.to_s + "." + c.name).strip.first(30) - work_content = [work_name,@work_head_cells,@work_cells_column] - @common_work_arrays.push(work_content) - title_no - end + common_homeworks.each_with_index do |c,index| + all_student_works = c.score_student_works #当前用户的对该作业的回答 + title_no = count_1 + index.to_i + 1 + student_work_to_xlsx(all_student_works,c) + + work_name = format_sheet_name (title_no.to_s + "." + c.name).strip.first(30) + work_content = [work_name,@work_head_cells,@work_cells_column] + @common_work_arrays.push(work_content) + title_no end #分组作业 - if count_3 > 0 - group_homeworks.each_with_index do |c,index| - all_student_works = c.score_student_works #当前用户的对该作业的回答 - title_no = count_1 + count_2 + index.to_i + 1 - student_work_to_xlsx(all_student_works,c) - work_name = (title_no.to_s + "." + c.name).strip.first(30) - work_content = [work_name,@work_head_cells,@work_cells_column] - @group_work_arrays.push(work_content) - end + group_homeworks.each_with_index do |c,index| + all_student_works = c.score_student_works #当前用户的对该作业的回答 + title_no = count_1 + count_2 + index.to_i + 1 + student_work_to_xlsx(all_student_works,c) + work_name = format_sheet_name (title_no.to_s + "." + c.name).strip.first(30) + work_content = [work_name,@work_head_cells,@work_cells_column] + @group_work_arrays.push(work_content) end #毕设任务 - if count_4 > 0 - tasks.each_with_index do |c,index| - all_student_works = c.score_graduation_works #当前用户的对该作业的回答 - title_no = count_1 + count_2 + count_3 + index.to_i + 1 - graduation_work_to_xlsx(all_student_works,c,current_user) - work_name = (title_no.to_s + "." + c.name).strip.first(30) - # work_content = [work_name,@work_head_cells,@work_cells_column] - work_content = [work_name,@head_cells_column,@task_cells_column] - @task_work_arrays.push(work_content) - end + tasks.each_with_index do |c,index| + all_student_works = c.score_graduation_works #当前用户的对该作业的回答 + title_no = count_1 + count_2 + count_3 + index.to_i + 1 + graduation_work_to_xlsx(all_student_works,c,current_user) + work_name = format_sheet_name (title_no.to_s + "." + c.name).strip.first(30) + # work_content = [work_name,@work_head_cells,@work_cells_column] + work_content = [work_name,@head_cells_column,@task_cells_column] + @task_work_arrays.push(work_content) end #试卷的导出 - if count_5 > 0 - exercises.each_with_index do |c,index| - all_student_works = c.score_exercise_users #当前用户的对该作业的回答 - title_no = count_1 + count_2 + count_3 + count_4 + index.to_i + 1 - get_export_users(c,course,all_student_works) - work_name = (title_no.to_s + "." + c.exercise_name).strip.first(30) - # work_content = [work_name,@work_head_cells,@work_cells_column] - work_content = [work_name,@table_columns,@user_columns] - @exercise_work_arrays.push(work_content) - end + exercises.each_with_index do |c,index| + all_student_works = c.score_exercise_users #当前用户的对该作业的回答 + title_no = count_1 + count_2 + count_3 + count_4 + index.to_i + 1 + get_export_users(c,course,all_student_works) + work_name = format_sheet_name (title_no.to_s + "." + c.exercise_name).strip.first(30) + # work_content = [work_name,@work_head_cells,@work_cells_column] + work_content = [work_name,@table_columns,@user_columns] + @exercise_work_arrays.push(work_content) end end end diff --git a/app/helpers/export_helper.rb b/app/helpers/export_helper.rb index 31fadc265..edb2b7e74 100644 --- a/app/helpers/export_helper.rb +++ b/app/helpers/export_helper.rb @@ -37,14 +37,14 @@ module ExportHelper end normal_head_b_cells = %w(最终成绩 提交时间 更新时间 评语) @work_head_cells = (head_cells_format + group_cells + normal_head_cells + head_cells_add + allow_late_cell + normal_head_b_cells).reject(&:blank?) - works.includes(student_works_scores: :user).each_with_index do |w, index| + works.includes(user: :user_extension, student_works_scores: :user).each_with_index do |w, index| w_user = w.user w_1 = (index + 1) w_2 = w_user.login w_3 = w_user.real_name w_3_1 = w_user.mail w_4 = w_user.student_id.present? ? w_user.student_id : "--" - course_name = course.course_member(w.user_id).try(:course_group_name) + course_name = course.students.find_by(user_id: w.user_id).try(:course_group_name) w_5 = course_name.present? ? course_name : "--" #0: 未提交, 1 按时提交, 2 延迟提交 if w.work_status == 0 @@ -118,7 +118,7 @@ module ExportHelper end shixun_time_cells = %w(最终成绩 更新时间 提交耗时 评语) @work_head_cells = (head_cells_format + shixun_head_cells + eff_score_cell + shixun_time_cells).reject(&:blank?) - works.includes(:myshixun).each_with_index do |w, index| + works.includes(:student_works_scores, user: :user_extension, myshixun: :games).each_with_index do |w, index| myshixun = w.try(:myshixun) w_user = w.user w_1 = (index + 1) @@ -126,7 +126,7 @@ module ExportHelper w_3 = w_user.real_name w_3_1 = w_user.mail w_4 = w_user.student_id.present? ? w_user.student_id : "--" - course_name = course.course_member(w.user_id).try(:course_group_name) + course_name = course.students.find_by(user_id: w.user_id).try(:course_group_name) w_5 = course_name.present? ? course_name : "--" #0: 未提交, 1 按时提交, 2 延迟提交 if w.work_status == 0 @@ -138,7 +138,7 @@ module ExportHelper else w_6 = "--" end - w_7 = w.work_status == 0 ? '--' : myshixun.try(:passed_count).to_s+"/"+shixun.challenges.count.to_s + w_7 = w.work_status == 0 ? '--' : myshixun.try(:passed_count).to_s+"/"+shixun.challenges_count.to_s w_8 = myshixun ? myshixun.try(:passed_time) == "--" ? "--" : format_time(myshixun.try(:passed_time)) : "--" # 通关时间 w_9 = myshixun ? (myshixun.try(:passed_count) > 0 ? myshixun.total_spend_time : '--') : "--" #总耗时 w_10 = myshixun ? myshixun.output_times : 0 #评测次数 @@ -204,7 +204,7 @@ module ExportHelper @head_cells_column = head_cells_format @task_cells_column = [] - items.each_with_index do |work,index| + items.includes(user: :user_extension).each_with_index do |work,index| w_1 = (index+1) w_user = work.user w_2 = w_user.login @@ -260,7 +260,7 @@ module ExportHelper else @table_columns = @table_columns + %w(最终成绩 开始答题时间 提交时间) end - export_ex_users.each_with_index do |e_user,index| + export_ex_users.includes(user: :user_extension).each_with_index do |e_user,index| user_info = e_user.user member = course.students.find_by_user_id(e_user.user_id) user_course = member.try(:course_group_name) @@ -295,7 +295,7 @@ module ExportHelper @topic_body_cells = [] if students.count > 0 - students.each_with_index do |student, index| + students.includes(user: :user_extension).each_with_index do |student, index| user = student.user student_topic = course.student_graduation_topics.user_topics_accept(user.id).first if student_topic.present? @@ -308,7 +308,7 @@ module ExportHelper w_2 = user.login w_3 = user.real_name w_3_1 = user.mail - w_4 = user.user_extension.student_id + w_4 = user.student_id w_5 = student.course_group_name w_6 = topic.present? ? topic.name : "--" w_7 = topic.present? ? topic.teacher.full_name : "--" @@ -504,4 +504,7 @@ module ExportHelper attach.filename end + def format_sheet_name name + name = name.gsub(":", "-") + end end diff --git a/app/models/myshixun.rb b/app/models/myshixun.rb index d8f294a39..31cc53200 100644 --- a/app/models/myshixun.rb +++ b/app/models/myshixun.rb @@ -18,7 +18,7 @@ class Myshixun < ApplicationRecord end def output_times - games.sum(:evaluate_count) + games.pluck(:evaluate_count).sum.to_i end def repo_path From ad7f287faccca9b38b35e7e2a2375b99feed5686 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Wed, 3 Jul 2019 11:10:14 +0800 Subject: [PATCH 256/256] =?UTF-8?q?=E5=AF=BC=E5=87=BA=E6=88=90=E7=BB=A9?= =?UTF-8?q?=E7=9A=84=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/courses_controller.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index 26e70f471..4e4d0284a 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -976,12 +976,12 @@ class CoursesController < ApplicationController @c_homeworks = @course.homework_commons.homework_published.order("homework_commons.publish_time asc, homework_commons.created_at asc") @c_exercises = @course.exercises.is_exercise_published.order("exercises.publish_time asc, exercises.created_at asc") - @c_polls = @course.polls.publish_or_not.order("polls.publish_time asc, polls.created_at asc") + # @c_polls = @course.polls.publish_or_not.order("polls.publish_time asc, polls.created_at asc") @c_tasks = @course.graduation_tasks.task_published.order("graduation_tasks.publish_time asc, graduation_tasks.created_at asc") if @user_course_identity > Course::ASSISTANT_PROFESSOR tip_exception(403,"无权限操作") else - member_to_xlsx(@course, @all_members, @c_homeworks, @c_exercises, @c_tasks, @c_polls) + member_to_xlsx(@course, @all_members, @c_homeworks, @c_exercises, @c_tasks) filename = current_user.real_name + "_" + @course.name + "_全部成绩" + Time.now.strftime('%Y%m%d_%H%M%S') render xlsx: "#{format_sheet_name filename.strip.first(30)}",template: "courses/export_member_scores_excel.xlsx.axlsx", locals: {course_info:@course_info, activity_level:@user_activity_level,