From 01be5588be227918c6f8b74c70d9a2c9886d40bc Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Mon, 24 Jun 2019 18:31:14 +0800 Subject: [PATCH 01/16] 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 02/16] 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 03/16] 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 04/16] 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 05/16] 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 06/16] 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 07/16] 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 08/16] 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 09/16] 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 10/16] 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 11/16] 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 12/16] 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 13/16] 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 14/16] =?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 15/16] 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 16/16] 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"]