From a9749fd88615da6778014b2a487e3023448a31f3 Mon Sep 17 00:00:00 2001 From: p31729568 Date: Mon, 24 Jun 2019 16:53:54 +0800 Subject: [PATCH 01/32] remove relationships && move user decorator methods to model --- app/controllers/shixuns_controller.rb | 4 +- app/decorators/user_decorator.rb | 56 --------------- app/libs/util.rb | 5 ++ app/models/relationship.rb | 2 + app/models/user.rb | 72 ++++++++++++++----- app/views/shixuns/collaborators.json.jbuilder | 2 +- 6 files changed, 63 insertions(+), 78 deletions(-) diff --git a/app/controllers/shixuns_controller.rb b/app/controllers/shixuns_controller.rb index 8359b14f9..c18e72efa 100644 --- a/app/controllers/shixuns_controller.rb +++ b/app/controllers/shixuns_controller.rb @@ -115,8 +115,8 @@ class ShixunsController < ApplicationController def show_right owner = @shixun.owner - #@fans_count = owner.followers.count - #@followed_count = owner.followed_users.count + #@fans_count = owner.fan_count + #@followed_count = owner.follow_count @user_own_shixuns = owner.shixuns.published.count end diff --git a/app/decorators/user_decorator.rb b/app/decorators/user_decorator.rb index 463d9a6e3..e00dead39 100644 --- a/app/decorators/user_decorator.rb +++ b/app/decorators/user_decorator.rb @@ -12,50 +12,6 @@ module UserDecorator logged_user? ? real_name : full_name end - # 关注数 - def follow_count - Watcher.where(user_id: id, watchable_type: %w(Principal User)).count - # User.watched_by(id).count - end - - # 粉丝数 - def fan_count - Watcher.where(watchable_type: %w(Principal User), watchable_id: id).count - # watchers.count - end - - # 是否绑定邮箱 - def email_binded? - mail.present? - end - - # 学院的url标识 - def college_identifier - - Department.find_by_id(department_members.pluck(:department_id).first)&.identifier - end - - # 是否能申请试用 - def can_apply_trial? - return false if certification == 1 - - apply = ApplyAction.order(created_at: :desc).find_by(user_id: id, container_type: 'TrialAuthorization') - - apply.present? && !apply.status.zero? - end - - # 是否已经签到 - def attendance_signed? - attendance = Attendance.find_by(user_id: id) - - attendance.present? && Util.days_between(Time.zone.now, attendance.created_at).zero? - end - - # 明日签到金币 - def tomorrow_attendance_gold - Attendance.find_by(user_id: id)&.next_gold || 50 - end - # ----------- 账号管理 ------------- def authentication_status if authentication? @@ -76,16 +32,4 @@ module UserDecorator 'uncertified' end end - - def base_info_completed? - user_columns = %i[nickname lastname] - user_extension_columns = %i[gender location location_city identity school_id department] - - user_columns.all? { |column| public_send(column).present? } && - user_extension_columns.all? { |column| user_extension.send(column).present? } - end - - def all_certified? - authentication? && professional_certification? - end end \ No newline at end of file diff --git a/app/libs/util.rb b/app/libs/util.rb index f6c8855b9..3485bebd7 100644 --- a/app/libs/util.rb +++ b/app/libs/util.rb @@ -28,4 +28,9 @@ module Util end end end + + def logger_error(exception) + Rails.logger.error(exception.message) + exception.backtrace.each { |message| Rails.logger.error(message) } + end end \ No newline at end of file diff --git a/app/models/relationship.rb b/app/models/relationship.rb index d5c754745..d71987867 100644 --- a/app/models/relationship.rb +++ b/app/models/relationship.rb @@ -1,6 +1,8 @@ +# TODO: 已废弃 class Relationship < ApplicationRecord belongs_to :follower, class_name: "User" belongs_to :followed, class_name: "User" + validates :follower_id, presence: true validates :followed_id, presence: true end diff --git a/app/models/user.rb b/app/models/user.rb index 8e25efe70..1b3349467 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -47,14 +47,6 @@ class User < ApplicationRecord has_many :graduation_works, dependent: :destroy - # 关注 - has_many :relationships, foreign_key: "follower_id", dependent: :destroy - has_many :followed_users, through: :relationships, source: :followed - # 粉丝 - has_many :reverse_relationships, foreign_key: "followed_id", - class_name: "Relationship", - dependent: :destroy - has_many :followers, through: :reverse_relationships, source: :follower has_many :students_for_courses, foreign_key: :student_id, dependent: :destroy has_one :onclick_time, :dependent => :destroy @@ -161,19 +153,16 @@ class User < ApplicationRecord self.user_extension.try(:student_id) end - # 关注总数 - def following?(other_user) - relationships.find_by(followed_id: other_user) - end - - # 关注 - def follow!(other_user) - relationships.create!(followed_id: other_user) + # 关注数 + def follow_count + Watcher.where(user_id: id, watchable_type: %w(Principal User)).count + # User.watched_by(id).count end - # 取消关注 - def unfollow!(other_user) - relationships.find_by(followed_id: other_user.id).destroy + # 粉丝数 + def fan_count + Watcher.where(watchable_type: %w(Principal User), watchable_id: id).count + # watchers.count end # 判断当前用户是否为老师 @@ -545,6 +534,51 @@ class User < ApplicationRecord Educoder::Utils.random_hex(16) end + # 基本资料是否完善 + def base_info_completed? + user_columns = %i[nickname lastname] + user_extension_columns = %i[gender location location_city identity school_id department] + + user_columns.all? { |column| public_send(column).present? } && + user_extension_columns.all? { |column| user_extension.send(column).present? } + end + + # 全部已认证 + def all_certified? + authentication? && professional_certification? + end + + # 是否绑定邮箱 + def email_binded? + mail.present? + end + + # 学院的url标识 + def college_identifier + Department.find_by_id(department_members.pluck(:department_id).first)&.identifier + end + + # 是否能申请试用 + def can_apply_trial? + return false if certification == 1 + + apply = ApplyAction.order(created_at: :desc).find_by(user_id: id, container_type: 'TrialAuthorization') + + apply.present? && !apply.status.zero? + end + + # 是否已经签到 + def attendance_signed? + attendance = Attendance.find_by(user_id: id) + + attendance.present? && Util.days_between(Time.zone.now, attendance.created_at).zero? + end + + # 明日签到金币 + def tomorrow_attendance_gold + Attendance.find_by(user_id: id)&.next_gold || 60 # 基础50,连续签到+10 + end + protected def validate_password_length # 管理员的初始密码是5位 diff --git a/app/views/shixuns/collaborators.json.jbuilder b/app/views/shixuns/collaborators.json.jbuilder index bd880c93e..0101f1e59 100644 --- a/app/views/shixuns/collaborators.json.jbuilder +++ b/app/views/shixuns/collaborators.json.jbuilder @@ -10,7 +10,7 @@ json.array! @members do |member| json.user do json.partial! 'users/user', locals: { user: member.user } json.user_shixuns_count member.user.shixuns.published.count - #json.fans_count member.user.followers.count + #json.fans_count member.user.fan_count json.brief_introduction member.user.user_extension.brief_introduction json.identity member.user.identity json.school_name member.user.school_name From 13af28f9ba12fedd6b7d7dadf14913344d6c3d6d Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Mon, 24 Jun 2019 17:15:58 +0800 Subject: [PATCH 02/32] fix but --- app/controllers/exercises_controller.rb | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/app/controllers/exercises_controller.rb b/app/controllers/exercises_controller.rb index 555da8e54..bab1170de 100644 --- a/app/controllers/exercises_controller.rb +++ b/app/controllers/exercises_controller.rb @@ -1016,10 +1016,15 @@ class ExercisesController < ApplicationController @exercise_user_current.update_attribute("start_at",Time.now) end end - if @exercise.time > 0 + ex_time = @exercise.time + if ex_time > 0 + time_mill = ex_time * 60 #转为秒 + exercise_end_time = @exercise.end_time.present? ? @exercise.end_time.to_i : 0 exercise_user_start = @exercise_user_current.present? ? @exercise_user_current.start_at.to_i : 0 - exercise_user_left_time = Time.now.to_i - exercise_user_start - time_mill = @exercise.time * 60 #转为毫秒 + if (exercise_user_start + time_mill) > exercise_end_time + time_mill = exercise_end_time - exercise_user_start #如果开始答题时间加试卷的限时长大于试卷的截止时间,则以试卷的截止时间到开始答题时间为试卷的限时 + end + exercise_user_left_time = Time.now.to_i - exercise_user_start #用户已回答的时间 @user_left_time = (time_mill < exercise_user_left_time) ? nil : (time_mill - exercise_user_left_time) #当前用户对试卷的回答剩余时间 end From a0a109401f32b51900b5d678145f7f5467bacfc5 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Mon, 24 Jun 2019 17:29:01 +0800 Subject: [PATCH 03/32] =?UTF-8?q?=E5=AE=9E=E8=AE=AD=E4=BF=9D=E5=AD=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/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 d603904c4..f2a964c8d 100644 --- a/app/controllers/challenges_controller.rb +++ b/app/controllers/challenges_controller.rb @@ -206,7 +206,7 @@ class ChallengesController < ApplicationController end # 关卡评测执行文件如果被修改,需要修改脚本内容 script = modify_shixun_script @shixun, @shixun.evaluate_script - @shixun.update_column(:evaluate_script, script) + @shixun.shixun_info.update_column(:evaluate_script, script) # TODO: # if path != params[:challenge][:path] # shixun_modify_status_without_publish(@shixun, 1) From 354b3a907bb8ef7495a696ec093b82d5850e3368 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Mon, 24 Jun 2019 17:35:53 +0800 Subject: [PATCH 04/32] fix bug --- app/helpers/exercise_questions_helper.rb | 2 +- app/views/exercises/_shixun_details.json.jbuilder | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/helpers/exercise_questions_helper.rb b/app/helpers/exercise_questions_helper.rb index 28f3fddb0..69dee034f 100644 --- a/app/helpers/exercise_questions_helper.rb +++ b/app/helpers/exercise_questions_helper.rb @@ -32,7 +32,7 @@ module ExerciseQuestionsHelper def shixun_game_scores(challenge,ex_answerer,shixun_type,question_id) game_score = challenge.question_score - game_answers = challenge.exercise_shixun_answers.search_shixun_answers("user_id",ex_answerer.id).search_shixun_answers("exercise_question_id",question_id) + game_answers = challenge.exercise_shixun_answers.where(user_id:ex_answerer.id,exercise_question_id:question_id) if shixun_type == 2 && game_answers.present? #试卷已截止,用户才可以查看答案 s_score = game_answers.first.score else diff --git a/app/views/exercises/_shixun_details.json.jbuilder b/app/views/exercises/_shixun_details.json.jbuilder index 033ac3dc1..c788b8c1c 100644 --- a/app/views/exercises/_shixun_details.json.jbuilder +++ b/app/views/exercises/_shixun_details.json.jbuilder @@ -7,7 +7,7 @@ json.stage_list do json.evaluate_count game.evaluate_count json.finished_time finished_time game.end_time json.time_consuming time_consuming game - json.myself_experience game.final_score #经验值 + json.myself_experience game.final_score < 0 ? 0 : game.final_score #经验值 json.experience game.challenge.all_score #经验值 json.user_score user_score.round(1).to_s #用户获得的分数 json.game_score game_score.round(1).to_s #该关卡的总分数 From 84c714310c0229ba29e58e63df938f72f0adb79a Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Mon, 24 Jun 2019 18:17:21 +0800 Subject: [PATCH 05/32] fix but --- app/controllers/exercises_controller.rb | 32 ++++++++++++------- app/helpers/exercises_helper.rb | 17 +++++++++- .../exercises/common_header.json.jbuilder | 4 ++- app/views/exercises/index.json.jbuilder | 6 +++- 4 files changed, 45 insertions(+), 14 deletions(-) diff --git a/app/controllers/exercises_controller.rb b/app/controllers/exercises_controller.rb index bab1170de..c3e8c4e5d 100644 --- a/app/controllers/exercises_controller.rb +++ b/app/controllers/exercises_controller.rb @@ -48,6 +48,7 @@ class ExercisesController < ApplicationController @exercises = @exercises_all #老师能看到全部的试卷,不管是已发布的/未发布的/已截止的/统一设置的/私有设置的(看到内容不同) elsif @user_course_identity == Course::STUDENT # 2为课堂成员,能看到统一设置的和自己班级的 @is_teacher_or = 2 + # get_exercise_left_time(@exercise,current_user) member_group_id = @current_student.first.try(:course_group_id).to_i # 成员的分班id,默认为0 if member_group_id == 0 #表示是课堂的未分班成员,只能查看统一设置的试卷(已发布的/已截止的) @exercises = member_show_exercises.present? ? member_show_exercises.unified_setting : [] @@ -204,10 +205,12 @@ class ExercisesController < ApplicationController @is_teacher_or = 0 @user_exercise_answer = @exercise.check_user_answer_status(current_user) @user_commit_counts = 0 + get_exercise_left_time(@exercise,current_user) else @is_teacher_or = 1 @user_exercise_answer = 3 #教师页面 @user_commit_counts = @exercise.exercise_users.where(commit_status:1).count #已提交的用户数 + @user_left_time = nil end @ex_status = @exercise.get_exercise_status(current_user.id) @@ -222,6 +225,8 @@ class ExercisesController < ApplicationController @exercise_publish_count = 1 #试卷未发布,且课堂没有分班的时候 end end + + rescue Exception => e uid_logger_error(e.message) tip_exception("没有权限") @@ -1016,17 +1021,20 @@ class ExercisesController < ApplicationController @exercise_user_current.update_attribute("start_at",Time.now) end end - ex_time = @exercise.time - if ex_time > 0 - time_mill = ex_time * 60 #转为秒 - exercise_end_time = @exercise.end_time.present? ? @exercise.end_time.to_i : 0 - exercise_user_start = @exercise_user_current.present? ? @exercise_user_current.start_at.to_i : 0 - if (exercise_user_start + time_mill) > exercise_end_time - time_mill = exercise_end_time - exercise_user_start #如果开始答题时间加试卷的限时长大于试卷的截止时间,则以试卷的截止时间到开始答题时间为试卷的限时 - end - exercise_user_left_time = Time.now.to_i - exercise_user_start #用户已回答的时间 - @user_left_time = (time_mill < exercise_user_left_time) ? nil : (time_mill - exercise_user_left_time) #当前用户对试卷的回答剩余时间 - end + + get_exercise_left_time(@exercise,@exercise_user_current) + + # ex_time = @exercise.time + # if ex_time > 0 + # time_mill = ex_time * 60 #转为秒 + # exercise_end_time = @exercise.end_time.present? ? @exercise.end_time.to_i : 0 + # exercise_user_start = @exercise_user_current.present? ? @exercise_user_current.start_at.to_i : 0 + # if (exercise_user_start + time_mill) > exercise_end_time + # time_mill = exercise_end_time - exercise_user_start #如果开始答题时间加试卷的限时长大于试卷的截止时间,则以试卷的截止时间到开始答题时间为试卷的限时 + # end + # exercise_user_left_time = Time.now.to_i - exercise_user_start #用户已回答的时间 + # @user_left_time = (time_mill < exercise_user_left_time) ? nil : (time_mill - exercise_user_left_time) #当前用户对试卷的回答剩余时间 + # end @t_user_exercise_status = @exercise.get_exercise_status(current_user.id) @@ -1788,4 +1796,6 @@ class ExercisesController < ApplicationController end end + + end diff --git a/app/helpers/exercises_helper.rb b/app/helpers/exercises_helper.rb index 3ffe177e7..b734d9685 100644 --- a/app/helpers/exercises_helper.rb +++ b/app/helpers/exercises_helper.rb @@ -419,13 +419,13 @@ module ExercisesHelper if game.present? exercise_cha_score = 0.0 answer_status = 0 - cha_path = challenge_path exercise_cha.challenge.path if game.status == 2 && game.final_score >= 0 exercise_cha_score = exercise_cha.question_score #每一关卡的得分 answer_status = 1 end ex_shixun_answer_content = answers_content.where(exercise_shixun_challenge_id: exercise_cha.id) if ex_shixun_answer_content.blank? #把关卡的答案存入试卷的实训里 + cha_path = challenge_path exercise_cha.challenge.path game_challenge = game.game_codes.search_challenge_path(cha_path).first if game_challenge.present? game_code = game_challenge @@ -681,6 +681,21 @@ module ExercisesHelper result end + def get_exercise_left_time(exercise,exercise_user) + ex_time = exercise.time + if ex_time > 0 + time_mill = ex_time * 60 #转为秒 + exercise_end_time = exercise.end_time.present? ? exercise.end_time.to_i : 0 + exercise_user_start = exercise_user.present? ? exercise_user.start_at.to_i : 0 + if (exercise_user_start + time_mill) > exercise_end_time + time_mill = exercise_end_time - exercise_user_start #如果开始答题时间加试卷的限时长大于试卷的截止时间,则以试卷的截止时间到开始答题时间为试卷的限时 + end + exercise_user_left_time = Time.now.to_i - exercise_user_start #用户已回答的时间 + @user_left_time = (time_mill < exercise_user_left_time) ? nil : (time_mill - exercise_user_left_time) #当前用户对试卷的回答剩余时间 + end + @user_left_time + end + #实训题学生代码的行数 def content_line(content) content.split(/\r?\n/).length diff --git a/app/views/exercises/common_header.json.jbuilder b/app/views/exercises/common_header.json.jbuilder index 68fa45a67..5d33aca66 100644 --- a/app/views/exercises/common_header.json.jbuilder +++ b/app/views/exercises/common_header.json.jbuilder @@ -1,5 +1,7 @@ json.course_is_end @course.is_end # true表示已结束,false表示未结束 -json.extract! @exercise, :id,:exercise_name,:exercise_description,:show_statistic,:time +json.extract! @exercise, :id,:exercise_name,:exercise_description,:show_statistic +json.time @user_left_time + json.exercise_status @ex_status json.user_permission do diff --git a/app/views/exercises/index.json.jbuilder b/app/views/exercises/index.json.jbuilder index 661a8886d..d7d51c343 100644 --- a/app/views/exercises/index.json.jbuilder +++ b/app/views/exercises/index.json.jbuilder @@ -21,7 +21,11 @@ if @exercises_count > 0 json.exercises do json.array! @exercises do |exercise| ex_index = exercise_index_show(exercise,@course,@is_teacher_or,@current_user_) - json.extract! exercise, :id, :exercise_name,:is_public,:created_at,:time + json.extract! exercise, :id, :exercise_name,:is_public,:created_at + if @is_teacher_or == 2 + json.time get_exercise_left_time(exercise,@current_user_) + end + json.exercise_status ex_index[:ex_status] json.lock_status ex_index[:lock_icon] json.publish_time ex_index[:publish_time] # 试卷的发布时间 From 01be5588be227918c6f8b74c70d9a2c9886d40bc Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Mon, 24 Jun 2019 18:31:14 +0800 Subject: [PATCH 06/32] fix bug --- app/controllers/exercises_controller.rb | 8 ++++---- app/helpers/exercises_helper.rb | 8 +++++--- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/app/controllers/exercises_controller.rb b/app/controllers/exercises_controller.rb index c3e8c4e5d..3e4dea5e3 100644 --- a/app/controllers/exercises_controller.rb +++ b/app/controllers/exercises_controller.rb @@ -201,16 +201,16 @@ class ExercisesController < ApplicationController def common_header ActiveRecord::Base.transaction do begin + @user_left_time = nil if @user_course_identity > Course::ASSISTANT_PROFESSOR @is_teacher_or = 0 @user_exercise_answer = @exercise.check_user_answer_status(current_user) @user_commit_counts = 0 - get_exercise_left_time(@exercise,current_user) + @user_left_time = get_exercise_left_time(@exercise,current_user) else @is_teacher_or = 1 @user_exercise_answer = 3 #教师页面 @user_commit_counts = @exercise.exercise_users.where(commit_status:1).count #已提交的用户数 - @user_left_time = nil end @ex_status = @exercise.get_exercise_status(current_user.id) @@ -1022,8 +1022,6 @@ class ExercisesController < ApplicationController end end - get_exercise_left_time(@exercise,@exercise_user_current) - # ex_time = @exercise.time # if ex_time > 0 # time_mill = ex_time * 60 #转为秒 @@ -1038,10 +1036,12 @@ class ExercisesController < ApplicationController @t_user_exercise_status = @exercise.get_exercise_status(current_user.id) + @user_left_time = nil if @user_course_identity < Course::STUDENT || (@t_user_exercise_status == 3) || (@exercise_user_current.present? && @exercise_user_current.commit_status == 1) @user_exercise_status = 1 #当前用户为老师/试卷已截止/试卷已提交不可编辑 else + @user_left_time = get_exercise_left_time(@exercise,current_user) @user_exercise_status = 0 #可编辑 end diff --git a/app/helpers/exercises_helper.rb b/app/helpers/exercises_helper.rb index b734d9685..3f3229136 100644 --- a/app/helpers/exercises_helper.rb +++ b/app/helpers/exercises_helper.rb @@ -681,9 +681,11 @@ module ExercisesHelper result end - def get_exercise_left_time(exercise,exercise_user) + def get_exercise_left_time(exercise,user) ex_time = exercise.time + user_left_time = nil if ex_time > 0 + exercise_user = exercise.exercise_users.find_by(user_id:user.id) time_mill = ex_time * 60 #转为秒 exercise_end_time = exercise.end_time.present? ? exercise.end_time.to_i : 0 exercise_user_start = exercise_user.present? ? exercise_user.start_at.to_i : 0 @@ -691,9 +693,9 @@ module ExercisesHelper time_mill = exercise_end_time - exercise_user_start #如果开始答题时间加试卷的限时长大于试卷的截止时间,则以试卷的截止时间到开始答题时间为试卷的限时 end exercise_user_left_time = Time.now.to_i - exercise_user_start #用户已回答的时间 - @user_left_time = (time_mill < exercise_user_left_time) ? nil : (time_mill - exercise_user_left_time) #当前用户对试卷的回答剩余时间 + user_left_time = (time_mill < exercise_user_left_time) ? nil : (time_mill - exercise_user_left_time) #当前用户对试卷的回答剩余时间 end - @user_left_time + user_left_time end #实训题学生代码的行数 From 445e9605e5d6949f3a365d2a5b6d2f380cafd121 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Mon, 24 Jun 2019 19:49:27 +0800 Subject: [PATCH 07/32] fix bug --- app/helpers/export_helper.rb | 34 ++++++++++++++++++++++++++++++---- 1 file changed, 30 insertions(+), 4 deletions(-) diff --git a/app/helpers/export_helper.rb b/app/helpers/export_helper.rb index 918995bef..dc2d4abc3 100644 --- a/app/helpers/export_helper.rb +++ b/app/helpers/export_helper.rb @@ -35,7 +35,7 @@ module ExportHelper else head_cells_add = [] end - normal_head_b_cells = %w(最终成绩 提交时间 更新时间) + 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| w_user = w.user @@ -85,8 +85,21 @@ module ExportHelper w_15 = w.work_score.nil? ? "未评分" : w.work_score.round(1) w_16 = w.commit_time ? format_time(w.commit_time) : "--" w_17 = w.update_time ? format_time(w.update_time) : "--" + teacher_comments = w.student_works_scores + if teacher_comments.present? + w_18 = "" + teacher_comments.each do |t| + user_name = t.user.real_name + user_time = format_time(t.updated_at) + user_score = t.score + user_comment = t.comment + w_18 = w_18 + (user_name + " " + user_time + " " + user_score + "\n" + user_comment + "\n") + end + else + w_18 = "--" + end - row_cells_column = [w_1,w_2,w_3,w_3_1,w_4,w_5,w_6,w_7,w_8,w_9,w_10,w_11,w_12,w_13,w_14,w_15,w_16,w_17] + row_cells_column = [w_1,w_2,w_3,w_3_1,w_4,w_5,w_6,w_7,w_8,w_9,w_10,w_11,w_12,w_13,w_14,w_15,w_16,w_17,w_18] row_cells_column = row_cells_column.reject(&:blank?) @work_cells_column.push(row_cells_column) end @@ -102,7 +115,7 @@ module ExportHelper if allow_late_boolean #允许迟交 eff_score_cell.push("迟交扣分") end - shixun_time_cells = %w(最终成绩 更新时间 提交耗时) + 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| myshixun = w.try(:myshixun) @@ -143,7 +156,20 @@ module ExportHelper w_15 = w.work_score.nil? ? "--" : w.work_score.round(1) w_16 = w.update_time ? format_time(w.update_time) : "--" "更新时间" w_17 = w.cost_time - row_cells_column = [w_1,w_2,w_3,w_3_1,w_4,w_5,w_6,w_7,w_8,w_9,w_10,w_11,w_12,w_13,w_14,w_15,w_16,w_17] + teacher_comments = w.student_works_scores + if teacher_comments.present? + w_18 = "" + teacher_comments.each do |t| + user_name = t.user.real_name + user_time = format_time(t.updated_at) + user_score = t.score + user_comment = t.comment + w_18 = w_18 + (user_name + " " + user_time + " " + user_score + "\n" + user_comment + "\n") + end + else + w_18 = "--" + end + row_cells_column = [w_1,w_2,w_3,w_3_1,w_4,w_5,w_6,w_7,w_8,w_9,w_10,w_11,w_12,w_13,w_14,w_15,w_16,w_17,w_18] row_cells_column = row_cells_column.reject(&:blank?) @work_cells_column.push(row_cells_column) end From 11c7b33f2c61c58fa852abce210ad07aa422d345 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Mon, 24 Jun 2019 19:53:37 +0800 Subject: [PATCH 08/32] fix but --- app/helpers/export_helper.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/helpers/export_helper.rb b/app/helpers/export_helper.rb index dc2d4abc3..ece85c304 100644 --- a/app/helpers/export_helper.rb +++ b/app/helpers/export_helper.rb @@ -93,7 +93,7 @@ module ExportHelper user_time = format_time(t.updated_at) user_score = t.score user_comment = t.comment - w_18 = w_18 + (user_name + " " + user_time + " " + user_score + "\n" + user_comment + "\n") + w_18 = w_18 + (user_name + " " + user_time.to_s + " " + user_score.to_s + "\n" + user_comment + "\n") end else w_18 = "--" @@ -164,7 +164,7 @@ module ExportHelper user_time = format_time(t.updated_at) user_score = t.score user_comment = t.comment - w_18 = w_18 + (user_name + " " + user_time + " " + user_score + "\n" + user_comment + "\n") + w_18 = w_18 + (user_name + " " + user_time.to_s + " " + user_score.to_s + "\n" + user_comment + "\n") end else w_18 = "--" From 15d6cb4e6fe950ac29302ee5f2fe0e943e6fa2e1 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Mon, 24 Jun 2019 19:58:48 +0800 Subject: [PATCH 09/32] fix bug --- app/helpers/export_helper.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/helpers/export_helper.rb b/app/helpers/export_helper.rb index ece85c304..af883131a 100644 --- a/app/helpers/export_helper.rb +++ b/app/helpers/export_helper.rb @@ -93,7 +93,7 @@ module ExportHelper user_time = format_time(t.updated_at) user_score = t.score user_comment = t.comment - w_18 = w_18 + (user_name + " " + user_time.to_s + " " + user_score.to_s + "\n" + user_comment + "\n") + w_18 = w_18 + ("教师:" + user_name + "\n" + "时间:" + user_time.to_s + "\n" + "分数:" + user_score.to_s + "分" + "\n" + "评语:" + user_comment + "\n\n") end else w_18 = "--" @@ -164,7 +164,7 @@ module ExportHelper user_time = format_time(t.updated_at) user_score = t.score user_comment = t.comment - w_18 = w_18 + (user_name + " " + user_time.to_s + " " + user_score.to_s + "\n" + user_comment + "\n") + w_18 = w_18 + ("教师:" + user_name + "\n" + "时间:" + user_time.to_s + "\n" + "分数:" + user_score.to_s + "分" + "\n" + "评语:" + user_comment + "\n\n") end else w_18 = "--" From edf8335349837f2ba159a14c376c0b09ba9366b0 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Mon, 24 Jun 2019 20:03:07 +0800 Subject: [PATCH 10/32] fix bug --- app/views/homework_commons/works_list.xlsx.axlsx | 1 + 1 file changed, 1 insertion(+) diff --git a/app/views/homework_commons/works_list.xlsx.axlsx b/app/views/homework_commons/works_list.xlsx.axlsx index 3809c6264..bd111c134 100644 --- a/app/views/homework_commons/works_list.xlsx.axlsx +++ b/app/views/homework_commons/works_list.xlsx.axlsx @@ -1,5 +1,6 @@ wb = xlsx_package.workbook +wb.use_autowidth = false wb.styles do |s| sz_all = s.add_style :border => { :style => :thin, :color =>"000000" },:alignment => {:horizontal => :center} blue_cell = s.add_style :bg_color => "FAEBDC", :sz => 10,:height => 20,:b => true, :border => { :style => :thin, :color =>"000000" },:alignment => {:horizontal => :center} From a1369a1e0c8eb099abbaa7a704e0d189c793d9b3 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Mon, 24 Jun 2019 20:06:19 +0800 Subject: [PATCH 11/32] fix bug --- app/views/homework_commons/works_list.xlsx.axlsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/homework_commons/works_list.xlsx.axlsx b/app/views/homework_commons/works_list.xlsx.axlsx index bd111c134..f8b7098ca 100644 --- a/app/views/homework_commons/works_list.xlsx.axlsx +++ b/app/views/homework_commons/works_list.xlsx.axlsx @@ -2,8 +2,8 @@ wb = xlsx_package.workbook wb.use_autowidth = false wb.styles do |s| - sz_all = s.add_style :border => { :style => :thin, :color =>"000000" },:alignment => {:horizontal => :center} - blue_cell = s.add_style :bg_color => "FAEBDC", :sz => 10,:height => 20,:b => true, :border => { :style => :thin, :color =>"000000" },:alignment => {:horizontal => :center} + sz_all = s.add_style :border => { :style => :thin, :color =>"000000" },:alignment => {wrap_text: true,:horizontal => :center} + blue_cell = s.add_style :bg_color => "FAEBDC", :sz => 10,:height => 20,:b => true, :border => { :style => :thin, :color =>"000000" },:alignment => {wrap_text: true,:horizontal => :center} wb.add_worksheet(:name => "学生成绩") do |sheet| sheet.sheet_view.show_grid_lines = false sheet.add_row table_columns, :style => blue_cell From b28bfa532dec085c35a9fbaf9358da977458ce92 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Mon, 24 Jun 2019 20:11:54 +0800 Subject: [PATCH 12/32] fix bug --- app/views/homework_commons/works_list.xlsx.axlsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/homework_commons/works_list.xlsx.axlsx b/app/views/homework_commons/works_list.xlsx.axlsx index f8b7098ca..826bfcc6a 100644 --- a/app/views/homework_commons/works_list.xlsx.axlsx +++ b/app/views/homework_commons/works_list.xlsx.axlsx @@ -1,8 +1,8 @@ wb = xlsx_package.workbook -wb.use_autowidth = false +# wb.use_autowidth = false wb.styles do |s| - sz_all = s.add_style :border => { :style => :thin, :color =>"000000" },:alignment => {wrap_text: true,:horizontal => :center} + sz_all = s.add_style :height => 20, :border => { :style => :thin, :color =>"000000" },:alignment => {wrap_text: true,:horizontal => :center} blue_cell = s.add_style :bg_color => "FAEBDC", :sz => 10,:height => 20,:b => true, :border => { :style => :thin, :color =>"000000" },:alignment => {wrap_text: true,:horizontal => :center} wb.add_worksheet(:name => "学生成绩") do |sheet| sheet.sheet_view.show_grid_lines = false From 85eb3c79a5a2c12718231bc0e15fd997764562e5 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Mon, 24 Jun 2019 20:13:49 +0800 Subject: [PATCH 13/32] fix bug --- app/views/homework_commons/works_list.xlsx.axlsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/homework_commons/works_list.xlsx.axlsx b/app/views/homework_commons/works_list.xlsx.axlsx index 826bfcc6a..116cfb6ef 100644 --- a/app/views/homework_commons/works_list.xlsx.axlsx +++ b/app/views/homework_commons/works_list.xlsx.axlsx @@ -2,8 +2,8 @@ wb = xlsx_package.workbook # wb.use_autowidth = false wb.styles do |s| - sz_all = s.add_style :height => 20, :border => { :style => :thin, :color =>"000000" },:alignment => {wrap_text: true,:horizontal => :center} - blue_cell = s.add_style :bg_color => "FAEBDC", :sz => 10,:height => 20,:b => true, :border => { :style => :thin, :color =>"000000" },:alignment => {wrap_text: true,:horizontal => :center} + sz_all = s.add_style :height => 20, :border => { :style => :thin, :color =>"000000" },:alignment => {:horizontal => :center} + blue_cell = s.add_style :bg_color => "FAEBDC", :sz => 10,:height => 20,:b => true, :border => { :style => :thin, :color =>"000000" },:alignment => {:horizontal => :center} wb.add_worksheet(:name => "学生成绩") do |sheet| sheet.sheet_view.show_grid_lines = false sheet.add_row table_columns, :style => blue_cell From 39eba6a7bb5fa184fbddb242a1ca88fc6c4f3952 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Mon, 24 Jun 2019 20:17:14 +0800 Subject: [PATCH 14/32] fix bug --- app/views/homework_commons/works_list.xlsx.axlsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/homework_commons/works_list.xlsx.axlsx b/app/views/homework_commons/works_list.xlsx.axlsx index 116cfb6ef..aab3ac057 100644 --- a/app/views/homework_commons/works_list.xlsx.axlsx +++ b/app/views/homework_commons/works_list.xlsx.axlsx @@ -2,14 +2,14 @@ wb = xlsx_package.workbook # wb.use_autowidth = false wb.styles do |s| - sz_all = s.add_style :height => 20, :border => { :style => :thin, :color =>"000000" },:alignment => {:horizontal => :center} + sz_all = s.add_style :border => { :style => :thin, :color =>"000000" },:alignment => {:horizontal => :center} blue_cell = s.add_style :bg_color => "FAEBDC", :sz => 10,:height => 20,:b => true, :border => { :style => :thin, :color =>"000000" },:alignment => {:horizontal => :center} wb.add_worksheet(:name => "学生成绩") do |sheet| sheet.sheet_view.show_grid_lines = false sheet.add_row table_columns, :style => blue_cell if task_users.count > 0 task_users.each do |user| - sheet.add_row user, :style => sz_all + sheet.add_row user, :height => 20,:style => sz_all end #each_widh_index end sheet.column_widths *([20]*sheet.column_info.count) From b43c58a39ab20fe77a52c9a7083c3d17e0e7657a Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Mon, 24 Jun 2019 20:35:51 +0800 Subject: [PATCH 15/32] fix bug --- .../_exercise_questions.json.jbuilder | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/app/views/exercise_questions/_exercise_questions.json.jbuilder b/app/views/exercise_questions/_exercise_questions.json.jbuilder index 7a05c2e11..04806540f 100644 --- a/app/views/exercise_questions/_exercise_questions.json.jbuilder +++ b/app/views/exercise_questions/_exercise_questions.json.jbuilder @@ -81,6 +81,17 @@ elsif question.question_type == 5 if (exercise_type == 3 || exercise_type == 4) && (shixun_type.present? && shixun_type > 0 ) #教师评阅/试卷截止后,答案公开/试卷未截止,但学生已做了实训题 json.shixun_details do json.array! shixun_challenges do |s| + + + exercise_cha_score = nil + game = Game.user_games(ex_answerer.id,s.challenge_id).first + if game.present? + if game.status == 2 && game.final_score >= 0 + exercise_cha_score = s.question_score #每一关卡的得分 + end + end + json.exercise_cha_socre exercise_cha_score + games_score = shixun_game_scores(s,ex_answerer,shixun_type,question.id) user_get_score = games_score[:s_score].present? ? games_score[:s_score] : 0.0 json.shixun_challenge_id s.id From 418077c59ae0d1086417b4a2e0bb5b9fa1f93ef3 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Mon, 24 Jun 2019 20:42:09 +0800 Subject: [PATCH 16/32] fix bug --- .../_exercise_questions.json.jbuilder | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/app/views/exercise_questions/_exercise_questions.json.jbuilder b/app/views/exercise_questions/_exercise_questions.json.jbuilder index 04806540f..afba34c9b 100644 --- a/app/views/exercise_questions/_exercise_questions.json.jbuilder +++ b/app/views/exercise_questions/_exercise_questions.json.jbuilder @@ -82,15 +82,16 @@ elsif question.question_type == 5 json.shixun_details do json.array! shixun_challenges do |s| - - exercise_cha_score = nil - game = Game.user_games(ex_answerer.id,s.challenge_id).first - if game.present? - if game.status == 2 && game.final_score >= 0 - exercise_cha_score = s.question_score #每一关卡的得分 - end - end - json.exercise_cha_socre exercise_cha_score + # + # exercise_cha_score = nil + # game = Game.user_games(ex_answerer.id,s.challenge_id).first + # if game.present? + # if game.status == 2 && game.final_score >= 0 + # exercise_cha_score = s.question_score #每一关卡的得分 + # end + # end + user_shixun_score = s.exercise_shixun_answers.where(user_id:ex_answerer.id,exercise_question_id:question.id) + json.exercise_cha_socre user_shixun_score.present? ? user_shixun_score.first.score : -1 games_score = shixun_game_scores(s,ex_answerer,shixun_type,question.id) user_get_score = games_score[:s_score].present? ? games_score[:s_score] : 0.0 From b3bda4ab6596fb839980945d29fcfa286a4e9a34 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Mon, 24 Jun 2019 20:56:59 +0800 Subject: [PATCH 17/32] fix but --- app/helpers/exercises_helper.rb | 64 ++++++++++++++++----------------- 1 file changed, 31 insertions(+), 33 deletions(-) diff --git a/app/helpers/exercises_helper.rb b/app/helpers/exercises_helper.rb index 3f3229136..285dbb37e 100644 --- a/app/helpers/exercises_helper.rb +++ b/app/helpers/exercises_helper.rb @@ -413,43 +413,41 @@ module ExercisesHelper score2 += 0.0 end elsif q.question_type == 5 #实训题时,主观题这里不评分 - if answers_content.present? - q.exercise_shixun_challenges.each do |exercise_cha| - game = Game.user_games(user.id,exercise_cha.challenge_id).first #当前用户的关卡 - if game.present? - exercise_cha_score = 0.0 - answer_status = 0 - if game.status == 2 && game.final_score >= 0 - exercise_cha_score = exercise_cha.question_score #每一关卡的得分 - answer_status = 1 - end - ex_shixun_answer_content = answers_content.where(exercise_shixun_challenge_id: exercise_cha.id) - if ex_shixun_answer_content.blank? #把关卡的答案存入试卷的实训里 - cha_path = challenge_path exercise_cha.challenge.path - game_challenge = game.game_codes.search_challenge_path(cha_path).first - if game_challenge.present? - game_code = game_challenge - code = game_code.try(:new_code) - else - code = git_fle_content(exercise_cha.shixun.repo_path,cha_path) - end - sx_option = { - :exercise_question_id => q.id, - :exercise_shixun_challenge_id => exercise_cha.id, - :user_id => user.id, - :score => exercise_cha_score, - :answer_text => code, - :status => answer_status - } - ExerciseShixunAnswer.create(sx_option) + q.exercise_shixun_challenges.each do |exercise_cha| + game = Game.user_games(user.id,exercise_cha.challenge_id)&.first #当前用户的关卡 + if game.present? + exercise_cha_score = 0.0 + answer_status = 0 + if game.status == 2 && game.final_score >= 0 + exercise_cha_score = exercise_cha.question_score #每一关卡的得分 + answer_status = 1 + end + ex_shixun_answer_content = answers_content&.where(exercise_shixun_challenge_id: exercise_cha.id) + if ex_shixun_answer_content.blank? #把关卡的答案存入试卷的实训里 + cha_path = challenge_path exercise_cha.challenge.path + game_challenge = game.game_codes.search_challenge_path(cha_path).first + if game_challenge.present? + game_code = game_challenge + code = game_code.try(:new_code) else - ex_shixun_answer_content.first.update_column('score',exercise_cha_score) + code = git_fle_content(exercise_cha.shixun.repo_path,cha_path) end - score5 += exercise_cha_score + sx_option = { + :exercise_question_id => q.id, + :exercise_shixun_challenge_id => exercise_cha.id, + :user_id => user.id, + :score => exercise_cha_score, + :answer_text => code, + :status => answer_status + } + ExerciseShixunAnswer.create(sx_option) + else + ex_shixun_answer_content.first.update_column('score',exercise_cha_score) end + score5 += exercise_cha_score + else + score5 += 0.0 end - else - score5 += 0.0 end end user_scores = answers_content.present? ? answers_content.score_reviewed.pluck(:score).sum : 0.0 From 7f255328d786e88352e279ca9b6528aeb443c6cb Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Mon, 24 Jun 2019 21:25:14 +0800 Subject: [PATCH 18/32] fix bug --- app/controllers/concerns/git_helper.rb | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/app/controllers/concerns/git_helper.rb b/app/controllers/concerns/git_helper.rb index f6724a654..445d67087 100644 --- a/app/controllers/concerns/git_helper.rb +++ b/app/controllers/concerns/git_helper.rb @@ -9,11 +9,13 @@ module GitHelper # 版本库文件内容,带转码 def git_fle_content(repo_path, path) begin - content = GitService.file_content(repo_path: repo_path, path: path)["content"] - logger.info("@@@@@@@@@@@@@@@@@@#{content}") + content = GitService.file_content(repo_path: repo_path, path: path) + logger.info("@@@@@@@@@@@@@@@@@@#{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']}" @@ -27,6 +29,7 @@ module GitHelper end decode_content + rescue Exception => e uid_logger_error(e.message) raise Educoder::TipException.new("文档内容获取异常") From dae20069e579bd160eb52883b90a18daa2d2cda8 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Mon, 24 Jun 2019 21:28:37 +0800 Subject: [PATCH 19/32] =?UTF-8?q?=E8=AF=95=E5=8D=B7=E7=9A=84=E5=AE=9E?= =?UTF-8?q?=E8=AE=AD=E9=A2=98=E7=9A=84=E8=AF=84=E5=88=86=E5=AE=8C=E5=96=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../_exercise_questions.json.jbuilder | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/app/views/exercise_questions/_exercise_questions.json.jbuilder b/app/views/exercise_questions/_exercise_questions.json.jbuilder index afba34c9b..7a05c2e11 100644 --- a/app/views/exercise_questions/_exercise_questions.json.jbuilder +++ b/app/views/exercise_questions/_exercise_questions.json.jbuilder @@ -81,18 +81,6 @@ elsif question.question_type == 5 if (exercise_type == 3 || exercise_type == 4) && (shixun_type.present? && shixun_type > 0 ) #教师评阅/试卷截止后,答案公开/试卷未截止,但学生已做了实训题 json.shixun_details do json.array! shixun_challenges do |s| - - # - # exercise_cha_score = nil - # game = Game.user_games(ex_answerer.id,s.challenge_id).first - # if game.present? - # if game.status == 2 && game.final_score >= 0 - # exercise_cha_score = s.question_score #每一关卡的得分 - # end - # end - user_shixun_score = s.exercise_shixun_answers.where(user_id:ex_answerer.id,exercise_question_id:question.id) - json.exercise_cha_socre user_shixun_score.present? ? user_shixun_score.first.score : -1 - games_score = shixun_game_scores(s,ex_answerer,shixun_type,question.id) user_get_score = games_score[:s_score].present? ? games_score[:s_score] : 0.0 json.shixun_challenge_id s.id From 6fa7223e4b77306444c0ba7c1b56ede115721bce Mon Sep 17 00:00:00 2001 From: jingquan huang Date: Tue, 25 Jun 2019 09:16:22 +0800 Subject: [PATCH 20/32] git password --- app/controllers/gits_controller.rb | 1 + lib/gitcheck/myshixun_update.txt | 0 lib/gitcheck/readme_test.txt | 51 ++++++++++++++++++++++++++++++ lib/gitcheck/shixun_update.txt | 0 lib/tasks/git_check.rake | 16 ++++++++++ 5 files changed, 68 insertions(+) create mode 100644 lib/gitcheck/myshixun_update.txt create mode 100644 lib/gitcheck/readme_test.txt create mode 100644 lib/gitcheck/shixun_update.txt create mode 100644 lib/tasks/git_check.rake diff --git a/app/controllers/gits_controller.rb b/app/controllers/gits_controller.rb index 60a551e7b..d1e3912b6 100644 --- a/app/controllers/gits_controller.rb +++ b/app/controllers/gits_controller.rb @@ -17,6 +17,7 @@ class GitsController < ApplicationController input_username = username_password.split(":")[0].strip() input_password = username_password.split(":")[1].strip() uid_logger("git start auth: input_username is #{input_username}") + uid_logger("git start auth: password is #{input_password}") # Git 超级权限用户 if input_username.strip == gituser.strip && input_password.strip == gitpassword.strip diff --git a/lib/gitcheck/myshixun_update.txt b/lib/gitcheck/myshixun_update.txt new file mode 100644 index 000000000..e69de29bb diff --git a/lib/gitcheck/readme_test.txt b/lib/gitcheck/readme_test.txt new file mode 100644 index 000000000..03f757f18 --- /dev/null +++ b/lib/gitcheck/readme_test.txt @@ -0,0 +1,51 @@ +# 新版Git测试说明 +统一: +参考实训:http://47.96.87.25:48080/shixuns/ca9fvobr/repository +请求方式:POST +参数{repo_path: "educoder/ca9fvobr.git"} +公共方法: +['add_repository', 'fork_repository', 'delete_repository', 'file_tree', 'update_file', + 'file_content', 'commits'] + +1、仓库目录接口 + 测试方法:模拟1000个用户同时去访问接口,访问方式 + http://121.199.19.206:9000/api/file_tree + 参数: + {repo_path: "educoder/ca9fvobr.git", path: ''} // 如:{path: 'step1'} + +2、创建版本库 + 访问地址:http://121.199.19.206:9000/api/add_repository + 参数: + {repo_path: 比如:"Hjqreturn/aaass1.git"} + +3、fork版本库 + 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是新项目的 + + +4、更新文件 + 测试方法: + 1、更新同一个文件,并发量可以不用很大,可以用同一个用户并发10-100 + 2、更新不同的文件:可以依据创建的版本库去更新 + 访问地址:http://121.199.19.206:9000/api/update_file + 参数: + {repo_path: "educoder/ca9fvobr.git", + file_path: 'step1/main.py', + message: 'commit by test', + content: 'afdjadsjfj1111', + author_name: 'guange', + author_email: '8863824@gmil.com'} + +5、获取文件内容 + 访问地址:http://121.199.19.206:9000/api/file_content + 参数: + {repo_path: "educoder/ca9fvobr.git", file_path: 'step1/main.py',} + +6、获取提交记录 + 访问地址:http://121.199.19.206:9000/api/commits + 参数: + {repo_path: 比如:"educoder/ca9fvobr.git"} + + diff --git a/lib/gitcheck/shixun_update.txt b/lib/gitcheck/shixun_update.txt new file mode 100644 index 000000000..e69de29bb diff --git a/lib/tasks/git_check.rake b/lib/tasks/git_check.rake new file mode 100644 index 000000000..64f8be91b --- /dev/null +++ b/lib/tasks/git_check.rake @@ -0,0 +1,16 @@ +namespace :git do + desc "检测是否TPM是否需要更新" + task :shixun_check_update => :environment do + + end + + desc "检测版本库是否有异常" + task :myshixuns_check_update => :environment do + + end + + + task :check => :environment do + + end +end From 8fbad4aaf3d9977f18c4bbdad839dd3025f7583e Mon Sep 17 00:00:00 2001 From: jingquan huang Date: Tue, 25 Jun 2019 09:24:37 +0800 Subject: [PATCH 21/32] git service add log --- app/controllers/gits_controller.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/controllers/gits_controller.rb b/app/controllers/gits_controller.rb index d1e3912b6..c3fa30270 100644 --- a/app/controllers/gits_controller.rb +++ b/app/controllers/gits_controller.rb @@ -16,8 +16,8 @@ class GitsController < ApplicationController username_password = Base64.decode64(request.env["HTTP_AUTHORIZATION"].split(" ")[1]) input_username = username_password.split(":")[0].strip() input_password = username_password.split(":")[1].strip() - uid_logger("git start auth: input_username is #{input_username}") - uid_logger("git start auth: password is #{input_password}") + uid_logger("git start auth: input_username is 55#{input_username}55") + uid_logger("git start auth: password is 66#{input_password}66") # Git 超级权限用户 if input_username.strip == gituser.strip && input_password.strip == gitpassword.strip @@ -28,7 +28,7 @@ class GitsController < ApplicationController # 如果用户名密码错误 if !system_user.check_password?(input_password) - uid_logger_error("git start: password is wrong") + uid_logger_error("git start: password is wrong#77#{input_password}77") result = false else git_url = params["url"] From b37c4db7702d2f25e95d73e53a23aafb3e59dd62 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Tue, 25 Jun 2019 09:31:53 +0800 Subject: [PATCH 22/32] =?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/shixuns_controller.rb | 25 +++++++++---------- app/models/myshixun.rb | 1 - ...625012548_add_index_for_evaluate_record.rb | 6 +++++ 3 files changed, 18 insertions(+), 14 deletions(-) create mode 100644 db/migrate/20190625012548_add_index_for_evaluate_record.rb diff --git a/app/controllers/shixuns_controller.rb b/app/controllers/shixuns_controller.rb index f1b4306ff..0ac7e9835 100644 --- a/app/controllers/shixuns_controller.rb +++ b/app/controllers/shixuns_controller.rb @@ -484,16 +484,15 @@ class ShixunsController < ApplicationController # 中间需要一个过渡动画 # TODO: 第一次开启实训都会去判断是否是纯选择题类型,感觉做成在创建关卡的时候就判断该实训是否是纯选择题更加合适 def shixun_exec - current_myshixun = @shixun.current_myshixun(current_user.id) - if @shixun.opening_time.present? && @shixun.opening_time > Time.now && current_user.shixun_identity(@shixun) > User::EDU_SHIXUN_MEMBER tip_show_exception(-3, "#{@shixun.opening_time.strftime('%Y-%m-%d %H:%M:%S')}") end - + current_myshixun = @shixun.current_myshixun(current_user.id) if current_myshixun # 如果TPM和TPI的管卡数不相等或者关卡顺序错了,说明实训被极大的改动,需要重置 - uid_logger_error("7777777777777777#{current_myshixun.games.count}, #{@shixun.challenges_count}") - if current_myshixun.games.count != @shixun.challenges_count || current_myshixun.games.map(&:challenge_id).sort != Challenge.where(shixun_id: @shixun.id).pluck(:id).sort + 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}") # 这里页面弹框要收到 当前用户myshixun的identifier. tip_show_exception("/myshixuns/#{current_myshixun.try(:identifier)}/reset_my_game") end @@ -517,7 +516,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, @@ -529,12 +528,12 @@ 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}") + #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)" end # 其它创建关卡等操作 @@ -547,7 +546,7 @@ class ShixunsController < ApplicationController :open_time => Time.now, :identifier => game_identifier, :modify_time => challenge.modify_time) end - # REDO:开启实训时更新关联作品的状态 + # REDO:开启实训时更新关联作品的状态-> TODO:这个可以异步。 HomeworksService.new.update_myshixun_work_status myshixun @current_task = myshixun.current_task diff --git a/app/models/myshixun.rb b/app/models/myshixun.rb index 089b416de..53f06293c 100644 --- a/app/models/myshixun.rb +++ b/app/models/myshixun.rb @@ -56,7 +56,6 @@ class Myshixun < ApplicationRecord # status:0 可以测评的,正在测评的 # 如果都完成,则当前任务为最后一个任务 def current_task - current_game = self.games.select{|game| game.status == 1 || game.status == 0}.first if current_game.blank? if self.status == 1 diff --git a/db/migrate/20190625012548_add_index_for_evaluate_record.rb b/db/migrate/20190625012548_add_index_for_evaluate_record.rb new file mode 100644 index 000000000..d67e33b1e --- /dev/null +++ b/db/migrate/20190625012548_add_index_for_evaluate_record.rb @@ -0,0 +1,6 @@ +class AddIndexForEvaluateRecord < ActiveRecord::Migration[5.2] + def change + # 增加evalute_records的索引,提高查询效率 + add_index :evaluate_records, :game_id + end +end From 17affc5de2b65b12651fa708d8bae09ce44911ae Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Tue, 25 Jun 2019 09:35:40 +0800 Subject: [PATCH 23/32] fix bug --- app/controllers/homework_commons_controller.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/controllers/homework_commons_controller.rb b/app/controllers/homework_commons_controller.rb index 6e2e1df40..3eb0364e9 100644 --- a/app/controllers/homework_commons_controller.rb +++ b/app/controllers/homework_commons_controller.rb @@ -205,6 +205,9 @@ class HomeworkCommonsController < ApplicationController exercise_export_name = current_user.real_name + "_" + @course.name + "_" + @homework.name + "_" + Time.now.strftime('%Y%m%d_%H%M%S') render xlsx: "#{exercise_export_name.strip.first(30)}",template: "homework_commons/works_list.xlsx.axlsx",locals: {table_columns: @work_head_cells,task_users: @work_cells_column} + Rails.logger.info("############_____________@work_head_cells_________###############{@work_head_cells}") + Rails.logger.info("############_____________@work_cells_column_________###############{@work_cells_column}") + else normal_status(-1,"暂无提交的学生!") end From 65d7336e58a14bf24f6b587163641e219d28d032 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Tue, 25 Jun 2019 09:40:17 +0800 Subject: [PATCH 24/32] fix bug --- app/controllers/homework_commons_controller.rb | 7 ++++--- app/helpers/export_helper.rb | 2 ++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/app/controllers/homework_commons_controller.rb b/app/controllers/homework_commons_controller.rb index 3eb0364e9..f265292ab 100644 --- a/app/controllers/homework_commons_controller.rb +++ b/app/controllers/homework_commons_controller.rb @@ -201,13 +201,14 @@ class HomeworkCommonsController < ApplicationController tip_exception(403, "无权限操作") else if @work_excel.present? + Rails.logger.info("############_____________@work_excel_________###############{@work_excel.size}") + Rails.logger.info("############_____________@homework_________###############{@homework.id}") 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') + Rails.logger.info("############_____________exercise_export_name_________###############{exercise_export_name}") + render xlsx: "#{exercise_export_name.strip.first(30)}",template: "homework_commons/works_list.xlsx.axlsx",locals: {table_columns: @work_head_cells,task_users: @work_cells_column} - Rails.logger.info("############_____________@work_head_cells_________###############{@work_head_cells}") - Rails.logger.info("############_____________@work_cells_column_________###############{@work_cells_column}") - else normal_status(-1,"暂无提交的学生!") end diff --git a/app/helpers/export_helper.rb b/app/helpers/export_helper.rb index af883131a..3a66c9dff 100644 --- a/app/helpers/export_helper.rb +++ b/app/helpers/export_helper.rb @@ -104,6 +104,8 @@ module ExportHelper @work_cells_column.push(row_cells_column) end else #实训题 + Rails.logger.info("############_____________homework.homework_type_________###############{homework.homework_type}") + shixun = homework.shixuns.first shixun_head_cells = %w(完成情况 通关时间 总耗时 总评测次数 获得经验值 关卡得分) eff_boolean = homework.work_efficiency From 9b57aa80ba76fc7fbf8c1cb12c0b82a0aa454201 Mon Sep 17 00:00:00 2001 From: jingquan huang Date: Tue, 25 Jun 2019 09:40:47 +0800 Subject: [PATCH 25/32] git auth --- app/controllers/gits_controller.rb | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/app/controllers/gits_controller.rb b/app/controllers/gits_controller.rb index c3fa30270..f00245190 100644 --- a/app/controllers/gits_controller.rb +++ b/app/controllers/gits_controller.rb @@ -16,8 +16,8 @@ class GitsController < ApplicationController username_password = Base64.decode64(request.env["HTTP_AUTHORIZATION"].split(" ")[1]) input_username = username_password.split(":")[0].strip() input_password = username_password.split(":")[1].strip() - uid_logger("git start auth: input_username is 55#{input_username}55") - uid_logger("git start auth: password is 66#{input_password}66") + uid_logger("git start auth: input_username is #{input_username}") + # Git 超级权限用户 if input_username.strip == gituser.strip && input_password.strip == gitpassword.strip @@ -28,7 +28,7 @@ class GitsController < ApplicationController # 如果用户名密码错误 if !system_user.check_password?(input_password) - uid_logger_error("git start: password is wrong#77#{input_password}77") + uid_logger_error("git start: password is wrong") result = false else git_url = params["url"] @@ -44,12 +44,13 @@ class GitsController < ApplicationController if system_user.present? && system_user.manager_of_shixun?(shixun) result = true else - logger.info("git411 start") + uid_logger_error("gituser is not shixun manager") result = false end else - render :json => { :status => 404 } - result = false + uid_logger_error("shixun is not exist") + # result = false + result = true # 为了测试跳出 end end end From 298d7e5b02a33285b66d3ec2d9235eb18e5c8e08 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Tue, 25 Jun 2019 10:01:20 +0800 Subject: [PATCH 26/32] fix bug --- app/controllers/homework_commons_controller.rb | 3 --- app/helpers/export_helper.rb | 2 -- 2 files changed, 5 deletions(-) diff --git a/app/controllers/homework_commons_controller.rb b/app/controllers/homework_commons_controller.rb index f265292ab..13e58f21d 100644 --- a/app/controllers/homework_commons_controller.rb +++ b/app/controllers/homework_commons_controller.rb @@ -201,11 +201,8 @@ class HomeworkCommonsController < ApplicationController tip_exception(403, "无权限操作") else if @work_excel.present? - Rails.logger.info("############_____________@work_excel_________###############{@work_excel.size}") - Rails.logger.info("############_____________@homework_________###############{@homework.id}") 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') - Rails.logger.info("############_____________exercise_export_name_________###############{exercise_export_name}") render xlsx: "#{exercise_export_name.strip.first(30)}",template: "homework_commons/works_list.xlsx.axlsx",locals: {table_columns: @work_head_cells,task_users: @work_cells_column} diff --git a/app/helpers/export_helper.rb b/app/helpers/export_helper.rb index 3a66c9dff..af883131a 100644 --- a/app/helpers/export_helper.rb +++ b/app/helpers/export_helper.rb @@ -104,8 +104,6 @@ module ExportHelper @work_cells_column.push(row_cells_column) end else #实训题 - Rails.logger.info("############_____________homework.homework_type_________###############{homework.homework_type}") - shixun = homework.shixuns.first shixun_head_cells = %w(完成情况 通关时间 总耗时 总评测次数 获得经验值 关卡得分) eff_boolean = homework.work_efficiency From 647a618ee62095ef0045e2553d02c161419fed13 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Tue, 25 Jun 2019 10:10:07 +0800 Subject: [PATCH 27/32] =?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/shixuns_controller.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/controllers/shixuns_controller.rb b/app/controllers/shixuns_controller.rb index 0ac7e9835..40879dc08 100644 --- a/app/controllers/shixuns_controller.rb +++ b/app/controllers/shixuns_controller.rb @@ -546,7 +546,8 @@ class ShixunsController < ApplicationController :open_time => Time.now, :identifier => game_identifier, :modify_time => challenge.modify_time) end - # REDO:开启实训时更新关联作品的状态-> TODO:这个可以异步。 + # REDO:开启实训时更新关联作品的状态 + # TODO:这个可以异步。或者放到课程里面取,不要在开启实训这边做 HomeworksService.new.update_myshixun_work_status myshixun @current_task = myshixun.current_task From 28dbdd03eef8aa87b78382c636adbe1a830db88e Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Tue, 25 Jun 2019 10:21:03 +0800 Subject: [PATCH 28/32] =?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/models/myshixun.rb | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/app/models/myshixun.rb b/app/models/myshixun.rb index 089b416de..b5bbdc249 100644 --- a/app/models/myshixun.rb +++ b/app/models/myshixun.rb @@ -56,20 +56,13 @@ class Myshixun < ApplicationRecord # status:0 可以测评的,正在测评的 # 如果都完成,则当前任务为最后一个任务 def current_task - - current_game = self.games.select{|game| game.status == 1 || game.status == 0}.first + games = self.games + current_game = games.select{|game| game.status == 1 || game.status == 0}.first if current_game.blank? - if self.status == 1 - logger.info("@3333333333344444444#{self.id}") - 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 - else - # 如果没开启过的,status都为3,所以应该进入第一关 - 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 = 3 order by c.position asc").first - end + 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 end - return current_game + current_game end From 4264679c7be42d75b568047f8efb5b947e118062 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Tue, 25 Jun 2019 10:26:59 +0800 Subject: [PATCH 29/32] =?UTF-8?q?=E9=80=89=E6=8B=A9=E9=A2=98=E8=AF=84?= =?UTF-8?q?=E6=B5=8B=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/games_controller.rb | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/app/controllers/games_controller.rb b/app/controllers/games_controller.rb index 79167150e..9c3051796 100644 --- a/app/controllers/games_controller.rb +++ b/app/controllers/games_controller.rb @@ -613,13 +613,10 @@ class GamesController < ApplicationController end # 批量插入评测结果 - uid_logger("choose_build") + uid_logger("#------------chooice score: #{score}") sql = "INSERT INTO outputs (game_id, test_set_position, actual_output, result, query_index, created_at, updated_at) VALUES" + str ActiveRecord::Base.connection.execute sql - had_done = @game.had_done - @myshixun.update_attribute(:status, 1) if had_done == 1 - # 没通关或者查看了答案通关的时候经验为0 # 通关但是查看了答案,评测的时候金币显示0(避免用户以为重复扣除),但是在关卡列表中金币显示负数 experience = 0 @@ -638,6 +635,8 @@ class GamesController < ApplicationController final_score = score RewardExperienceService.call(@myshixun.owner, reward_attrs) end + had_done = @game.had_done + @myshixun.update_attribute(:status, 1) if had_done == 1 end grade = @myshixun.owner.try(:grade) From 3b7aa73202af2edcfd065679424a49a339474a7b Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Tue, 25 Jun 2019 10:30:53 +0800 Subject: [PATCH 30/32] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/games_controller.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/controllers/games_controller.rb b/app/controllers/games_controller.rb index 9c3051796..ecd84ebd5 100644 --- a/app/controllers/games_controller.rb +++ b/app/controllers/games_controller.rb @@ -627,6 +627,7 @@ class GamesController < ApplicationController @game.update_attributes(:status => 2, :end_time => Time.now) # TPM实训已发布并且没有查看答案 if @shixun.is_published? && !@game.answer_open + uid_logger("@@@@@@@@@@@@@@@@@chooice score: #{score}") # 查看答案的时候处理final_scor和扣分记录 experience = score reward_attrs = { container_id: @game.id, container_type: 'Game', score: score } From 62dd9051a4f42643c92b1309587570012a5d207e Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Tue, 25 Jun 2019 10:37:54 +0800 Subject: [PATCH 31/32] =?UTF-8?q?=E9=80=89=E6=8B=A9=E9=A2=98=E8=AF=84?= =?UTF-8?q?=E6=B5=8B=E9=97=AE=E9=A2=98?= 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 ecd84ebd5..2a3c51762 100644 --- a/app/controllers/games_controller.rb +++ b/app/controllers/games_controller.rb @@ -626,7 +626,7 @@ class GamesController < ApplicationController if had_passed && !@game.had_passed? @game.update_attributes(:status => 2, :end_time => Time.now) # TPM实训已发布并且没有查看答案 - if @shixun.is_published? && !@game.answer_open + if @shixun.is_published? && @game.answer_open == 0 uid_logger("@@@@@@@@@@@@@@@@@chooice score: #{score}") # 查看答案的时候处理final_scor和扣分记录 experience = score From 93203edade8ac3fcccd18ca69c60ad314b55effc Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Tue, 25 Jun 2019 10:51:30 +0800 Subject: [PATCH 32/32] =?UTF-8?q?=E5=AE=9E=E8=AE=AD=E9=A6=96=E9=A1=B5?= =?UTF-8?q?=E6=90=9C=E7=B4=A2=E6=9C=89=E9=87=8D=E5=A4=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 40879dc08..360732120 100644 --- a/app/controllers/shixuns_controller.rb +++ b/app/controllers/shixuns_controller.rb @@ -47,7 +47,7 @@ class ShixunsController < ApplicationController where("challenge_tags.name like '%#{keyword}%' or challenges.subject like '%#{keyword}%' or concat(lastname, firstname) like '%#{keyword}%' - or shixuns.name like '%#{keyword.split(" ").join("%")}%'") + or shixuns.name like '%#{keyword.split(" ").join("%")}%'").distinct end ## 筛选 状态