From 8036c6eb85b3bdb3d9253c707d02c5edc622455f Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Wed, 17 Jul 2019 15:34:07 +0800 Subject: [PATCH 01/12] =?UTF-8?q?=E8=AF=95=E5=8D=B7=E7=BB=9F=E8=AE=A1?= =?UTF-8?q?=E7=BB=93=E6=9E=9C=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/helpers/exercises_helper.rb | 55 +++++++++++++-------------------- 1 file changed, 21 insertions(+), 34 deletions(-) diff --git a/app/helpers/exercises_helper.rb b/app/helpers/exercises_helper.rb index 4a0c5509d..5ec9bcad4 100644 --- a/app/helpers/exercises_helper.rb +++ b/app/helpers/exercises_helper.rb @@ -88,8 +88,8 @@ module ExercisesHelper question_infos = [] percent = 0.0 questions.includes(:exercise_choices).each do |ex| - ex_total_score = user_ids.count * ex&.question_score #该试卷的已回答的总分 - ex_answers = ex.exercise_answers + ex_total_score = user_ids.count * ex&.question_score.to_f #该试卷的已回答的总分 + # ex_answers = ex.exercise_answers if ex.question_type != Exercise::PRACTICAL ques_title = ex.question_title ques_less_title = nil @@ -98,23 +98,23 @@ module ExercisesHelper else ques_title = ex.shixun.name ques_less_title = ex.question_title - effictive_users = ex.exercise_shixun_answers.search_shixun_answers("user_id",user_ids) + ex_answers = ex.exercise_shixun_answers + effictive_users = ex_answers.search_shixun_answers("user_id",user_ids) end effictive_users_count = effictive_users.size #有效回答数,可能有重复的用户id,这里仅统计是否回答这个问题的全部人数 ex_answered_scores = effictive_users.score_reviewed.pluck(:score).sum #该问题的全部得分 if ex.question_type > Exercise::COMPLETION #当为主观题和实训题时, - if ex_total_score != 0.0 - percent = (ex_answered_scores / ex_total_score.to_f).round(3) * 100 #正确率 - end + percent = (ex_total_score == 0.0 ? 0.0 : (ex_answered_scores / ex_total_score.to_f).round(3) * 100) #正确率 end question_answer_infos = [] if ex.question_type <= Exercise::JUDGMENT #选择题和判断题 ex_choices = ex.exercise_choices standard_answer = ex.exercise_standard_answers.pluck(:exercise_choice_id).sort #标准答案的位置 - right_users_count = 0 #该问题的回答正确的人数 + right_users_count = 0 + #该问题的正确率 if ex.question_type == Exercise::MULTIPLE #多选题 user_ids.each do |user_id| ex_choice_ids = effictive_users.map{|e| e.exercise_choice_id if e.user_id == user_id}.reject(&:blank?).uniq @@ -129,15 +129,14 @@ module ExercisesHelper end percent = effictive_users_count > 0 ? (right_users_count / effictive_users_count.to_f).round(3)*100 : 0.0 + + #每个选项的正确率 ex_choices.each do |c| right_answer = standard_answer.include?(c.choice_position) #选项的标准答案为选项的位置 - answer_this_choice = effictive_users.search_exercise_answer("exercise_choice_id",c.id) - answer_users_count = answer_this_choice.size - if effictive_users_count == 0 - answer_percent = 0.0 - else - answer_percent = (answer_users_count / effictive_users_count.to_f ).round(3) - end + answer_users_count = effictive_users.select{|answer| answer.exercise_choice_id == c.id}.size + + answer_percent = (effictive_users_count == 0 ? 0.0 : (answer_users_count / effictive_users_count.to_f ).round(3)) + answer_option = { :choice_position => c.choice_position, :choice_text => c.choice_text, @@ -150,7 +149,7 @@ module ExercisesHelper elsif ex.question_type == Exercise::COMPLETION #填空题 ex_ordered = ex.is_ordered null_standard_answer = ex.exercise_standard_answers - null_stand_choice = null_standard_answer.pluck(:exercise_choice_id) + null_stand_choice = null_standard_answer.pluck(:exercise_choice_id) #一个exercise_choice_id可能对应多个answer_text null_stand_text = null_standard_answer.pluck(:answer_text) standard_answer_count = 0 all_user_count = 0 @@ -159,20 +158,17 @@ module ExercisesHelper s_choice_text = null_stand_text[index] if ex_ordered #有序排列 user_ids.each do |u| - user_answers = ex_answers.search_answer_users("user_id",u).search_answer_users("exercise_choice_id",s) - user_answers_choice = user_answers.present? ? user_answers.first.answer_text : "" + user_answers = ex_answers.where(user_id:u,exercise_choice_id:s).select(:answer_text) + user_answers_choice = user_answers.exists? ? user_answers&.first&.answer_text.to_s : "" if s_choice_text == user_answers_choice user_count += 1 end end else - user_count = user_count + effictive_users.search_exercise_answer("answer_text",s_choice_text).count #回答了标准答案的用户 - end - if effictive_users_count == 0 - answer_percent = 0.0 - else - answer_percent = (user_count / effictive_users_count.to_f ).round(3) + user_count = user_count + effictive_users.select{|answer| answer.answer_text == s_choice_text }.size #回答了标准答案的用户 end + + answer_percent = ((effictive_users_count == 0) ? 0.0 : (user_count / effictive_users_count.to_f ).round(3)) answer_option = { :choice_position => index+1, :choice_text => s_choice_text, @@ -237,22 +233,13 @@ module ExercisesHelper all_zero_scores = cha_shixun_answer.search_shixun_keys("score",0.0).size #零分人数 shixun_scores = user_ids.count * cha_score shixun_answered_scores = cha_shixun_answer.score_reviewed.pluck(:score).sum #该问题的全部得分 - - if shixun_answered_scores == 0.0 - game_percent = 0.0 - else - game_percent = (shixun_answered_scores / shixun_scores.to_f).round(3) * 100 #正确率 - end + game_percent = (shixun_answered_scores == 0.0 ? 0.0 : (shixun_answered_scores / shixun_scores.to_f).round(3) * 100) #正确率 shixun_score_array = [full_scores,no_full_scores,all_zero_scores] shixun_chas = [] shixun_score_array.each_with_index do |s,index| right_answer = (index == 0) - if effictive_users_count == 0 - score_percent = 0.0 - else - score_percent = (s.to_i / effictive_users_count.to_f ).round(3) - end + score_percent = (effictive_users_count == 0 ? 0.0 : (s.to_i / effictive_users_count.to_f ).round(3)) answer_option = { :choice_position => index+1, :choice_text => index+1, From 874c2fea2c09c952a6194c93214ce5af81a148aa Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Wed, 17 Jul 2019 16:22:24 +0800 Subject: [PATCH 02/12] =?UTF-8?q?=E5=88=A0=E9=99=A4=E7=89=88=E6=9C=AC?= =?UTF-8?q?=E5=BA=93=E5=BC=82=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/games_controller.rb | 1 + app/controllers/myshixuns_controller.rb | 1 + 2 files changed, 2 insertions(+) diff --git a/app/controllers/games_controller.rb b/app/controllers/games_controller.rb index 107839b31..8dc0719f3 100644 --- a/app/controllers/games_controller.rb +++ b/app/controllers/games_controller.rb @@ -511,6 +511,7 @@ class GamesController < ApplicationController GitService.delete_repository(repo_path: @myshixun.repo_path) rescue Exception => e uid_logger_error("#{e.message}") + tip_exception(-3, "#{e.message}") end # fork一个新的仓库 # project_fork(@myshixun, @shixun.repo_path, current_user.login) diff --git a/app/controllers/myshixuns_controller.rb b/app/controllers/myshixuns_controller.rb index a7c1e227c..811b9146a 100644 --- a/app/controllers/myshixuns_controller.rb +++ b/app/controllers/myshixuns_controller.rb @@ -97,6 +97,7 @@ class MyshixunsController < ApplicationController game_id = jsonTestDetails['buildID'] sec_key = jsonTestDetails['sec_key'] + # 资源消耗 res_usage = jsonTestDetails['resUsage'] # 关卡测试集的总耗时 ts_time = 0 From d991c52d103888d8aef1ea71ede2a65754f1e6b3 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Wed, 17 Jul 2019 16:39:41 +0800 Subject: [PATCH 03/12] =?UTF-8?q?=E7=BB=88=E7=AB=AF=E5=BE=AA=E7=8E=AF?= 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 8dc0719f3..83678ca7f 100644 --- a/app/controllers/games_controller.rb +++ b/app/controllers/games_controller.rb @@ -511,7 +511,8 @@ class GamesController < ApplicationController GitService.delete_repository(repo_path: @myshixun.repo_path) rescue Exception => e uid_logger_error("#{e.message}") - tip_exception(-3, "#{e.message}") + # 终端循环 + tip_exception("#{e.message}") end # fork一个新的仓库 # project_fork(@myshixun, @shixun.repo_path, current_user.login) From b3dadf5a8459671b30ddd218cd813d5ef989f081 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Wed, 17 Jul 2019 16:50:27 +0800 Subject: [PATCH 04/12] =?UTF-8?q?=E8=AF=BE=E5=A0=82=E7=9A=84=E6=88=90?= =?UTF-8?q?=E7=BB=A9=E5=AF=BC=E5=87=BA=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 | 38 +++++++++++++++++---------- app/models/course.rb | 2 +- 2 files changed, 25 insertions(+), 15 deletions(-) diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index b661c06b4..c46f9323a 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -1180,15 +1180,27 @@ class CoursesController < ApplicationController course_main_info = [course_1,course_2,course_3,course_4,course_5,course_6,course_7] course_group_info_head = %w(序号 分班名称 邀请码 学生数量) course_group_info_body = [] - if course.course_groups.present? + none_group_counts = course.none_group_count + + #当有未分班时,应该也做个统计 + if none_group_counts > 0 + none_group_index = 2 + no_group_array = [1,"未分班",course.invite_code,none_group_counts] + course_group_info_body.push(no_group_array) + else + none_group_index = 1 + end + + if course.course_groups.exists? course.course_groups.each_with_index do |group, index| - group_index = (index+1) + group_index = (index+none_group_index) group_name = group.name group_code = group.invite_code group_count = group.course_members_count group_array = [group_index,group_name,group_code,group_count] course_group_info_body.push(group_array) end + end course_group_info = [course_group_info_head,course_group_info_body] @course_info += [course_info_title,course_main_info,course_group_info] @@ -1256,7 +1268,7 @@ class CoursesController < ApplicationController #实训作业 if shixun_homeworks.size > 0 - shixun_homeworks.each do |s| + shixun_homeworks&.includes(:score_student_works).each do |s| 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 @@ -1272,7 +1284,7 @@ class CoursesController < ApplicationController #普通作业 if common_homeworks.size > 0 - common_homeworks.each do |c| + common_homeworks&.includes(:score_student_works).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? h_score_1 = 0.0 #该作业的得分为0 @@ -1288,7 +1300,7 @@ class CoursesController < ApplicationController #分组作业 if group_homeworks.size > 0 - group_homeworks.each do |g| + group_homeworks&.includes(:score_student_works).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? h_score_3 = 0.0 #该作业的得分为0 @@ -1304,7 +1316,7 @@ class CoursesController < ApplicationController #毕设作业 if tasks.size > 0 - tasks.each do |task| + tasks&.includes(:score_graduation_works).each do |task| graduation_work = task.score_graduation_works.select{|work| work.user_id == user.id}.first if graduation_work.nil? t_score = 0.0 @@ -1320,7 +1332,7 @@ class CoursesController < ApplicationController #试卷 if exercises.size > 0 - exercises.each do |ex| + exercises&.includes(:score_exercise_users).each do |ex| exercise_work = ex.score_exercise_users.select{|work| work.user_id == user.id}.first if exercise_work.nil? e_score = 0.0 @@ -1363,7 +1375,7 @@ class CoursesController < ApplicationController count_4 = tasks.size count_5 = exercises.size #实训作业 - shixun_homeworks.each_with_index do |s,index| + shixun_homeworks&.includes(:score_student_works).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) @@ -1373,7 +1385,7 @@ class CoursesController < ApplicationController end #普通作业 - common_homeworks.each_with_index do |c,index| + common_homeworks&.includes(:score_student_works).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) @@ -1385,7 +1397,7 @@ class CoursesController < ApplicationController end #分组作业 - group_homeworks.each_with_index do |c,index| + group_homeworks&.includes(:score_student_works).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) @@ -1395,23 +1407,21 @@ class CoursesController < ApplicationController end #毕设任务 - tasks.each_with_index do |c,index| + tasks&.includes(:score_graduation_works).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 #试卷的导出 - exercises.each_with_index do |c,index| + exercises&.includes(:score_exercise_users).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 diff --git a/app/models/course.rb b/app/models/course.rb index 3794a8b2b..1f38827ae 100644 --- a/app/models/course.rb +++ b/app/models/course.rb @@ -103,7 +103,7 @@ class Course < ApplicationRecord # 未分班的学生数 def none_group_count - course_members.where(role: 4, course_group_id: 0).count + course_members.where(role: 4, course_group_id: 0).size end def course_member(user_id) From 2eef513383649bfd7dbb053552ea1f9d67293f71 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Wed, 17 Jul 2019 16:50:58 +0800 Subject: [PATCH 05/12] =?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/games_controller.rb | 8 ++++---- app/controllers/myshixuns_controller.rb | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/controllers/games_controller.rb b/app/controllers/games_controller.rb index 83678ca7f..977ddefa0 100644 --- a/app/controllers/games_controller.rb +++ b/app/controllers/games_controller.rb @@ -707,10 +707,10 @@ class GamesController < ApplicationController resubmit_identifier = @game.resubmit_identifier # 如果没有超时并且正在评测中 # 判断评测中的状态有两种:1、如果之前没有通关的,只需判断status为1即可;如果通过关,则判断game的resubmit_identifier是否更新 - # uid_logger("################game_status: #{@game.status}") - # uid_logger("################params[:resubmit]: #{params[:resubmit]}") - # uid_logger("################resubmit_identifier: #{resubmit_identifier}") - # uid_logger("################time_out: #{params[:time_out]}") + uid_logger("################game_status: #{@game.status}") + uid_logger("################params[:resubmit]: #{params[:resubmit]}") + uid_logger("################resubmit_identifier: #{resubmit_identifier}") + uid_logger("################time_out: #{params[:time_out]}") if (params[:time_out] == "false") && ((params[:resubmit].blank? && @game.status == 1) || (params[:resubmit].present? && (params[:resubmit] != resubmit_identifier))) # 代码评测的信息 diff --git a/app/controllers/myshixuns_controller.rb b/app/controllers/myshixuns_controller.rb index 811b9146a..79429a30d 100644 --- a/app/controllers/myshixuns_controller.rb +++ b/app/controllers/myshixuns_controller.rb @@ -139,7 +139,6 @@ class MyshixunsController < ApplicationController end end uid_logger("#############status: #{status}") - uid_logger("#############resubmit: #{resubmit}") record = EvaluateRecord.where(:game_id => game_id).first logger.info("training_task_status start#3**#{game_id}**** #{Time.now.strftime("%Y-%m-%d %H:%M:%S.%L")}") answer_deduction_percentage = (100 - game.answer_deduction) / 100.to_f # 查看答案后剩余分数的百分比. @@ -147,6 +146,7 @@ class MyshixunsController < ApplicationController # status:0表示评测成功 if status == "0" if resubmit.present? + uid_logger("#############resubmit: #{resubmit}") game.update_attributes!(:retry_status => 2, :resubmit_identifier => resubmit) challenge.path.split(";").each do |path| game_passed_code(path.try(:strip), myshixun, game_id) From d21f863c17cbef3ebe320e90f070de508f9b87b0 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Wed, 17 Jul 2019 17:11:19 +0800 Subject: [PATCH 06/12] 1 --- app/controllers/myshixuns_controller.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/controllers/myshixuns_controller.rb b/app/controllers/myshixuns_controller.rb index 79429a30d..dc6faee13 100644 --- a/app/controllers/myshixuns_controller.rb +++ b/app/controllers/myshixuns_controller.rb @@ -146,8 +146,9 @@ class MyshixunsController < ApplicationController # status:0表示评测成功 if status == "0" if resubmit.present? - uid_logger("#############resubmit: #{resubmit}") + uid_logger("#############resubmitdaiao: #{resubmit}") game.update_attributes!(:retry_status => 2, :resubmit_identifier => resubmit) + uid_logger("#############resubmit_identifier_resubmitdaiao: #{game.resubmit_identifier}") challenge.path.split(";").each do |path| game_passed_code(path.try(:strip), myshixun, game_id) end From 44774e9c5872c793e48468b83d6d8c2477dfea6a Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Wed, 17 Jul 2019 17:14:21 +0800 Subject: [PATCH 07/12] =?UTF-8?q?=E8=AF=84=E6=B5=8B=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/myshixuns_controller.rb | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/app/controllers/myshixuns_controller.rb b/app/controllers/myshixuns_controller.rb index dc6faee13..c36be6284 100644 --- a/app/controllers/myshixuns_controller.rb +++ b/app/controllers/myshixuns_controller.rb @@ -99,8 +99,6 @@ class MyshixunsController < ApplicationController # 资源消耗 res_usage = jsonTestDetails['resUsage'] - # 关卡测试集的总耗时 - ts_time = 0 logger.info("training_task_status start#1**#{game_id}**** #{Time.now.strftime("%Y-%m-%d %H:%M:%S.%L")}") resubmit = jsonTestDetails['resubmit'] @@ -148,7 +146,6 @@ class MyshixunsController < ApplicationController if resubmit.present? uid_logger("#############resubmitdaiao: #{resubmit}") game.update_attributes!(:retry_status => 2, :resubmit_identifier => resubmit) - uid_logger("#############resubmit_identifier_resubmitdaiao: #{game.resubmit_identifier}") challenge.path.split(";").each do |path| game_passed_code(path.try(:strip), myshixun, game_id) end @@ -201,7 +198,7 @@ class MyshixunsController < ApplicationController if record.present? consume_time = format("%.3f", (Time.now - record.created_at)).to_f record.update_attributes!(:consume_time => consume_time, :git_pull => timeCost['pull'] , :create_pod => timeCost['createPod'], - :pod_execute => timeCost['execute'], :test_cases => test_cases_time, :ts_time => ts_time, + :pod_execute => timeCost['execute'], :test_cases => test_cases_time, :brige => timeCost['evaluateAllTime'], :return_back => return_back_time) end uid_logger("training_task_status start#4**#{game_id}**** #{Time.now.strftime("%Y-%m-%d %H:%M:%S.%L")}") From 264e56d80506b104a1a115bd8183ef415bcfedf9 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Wed, 17 Jul 2019 17:15:16 +0800 Subject: [PATCH 08/12] fixbug --- app/controllers/courses_controller.rb | 4 ++-- app/helpers/export_helper.rb | 33 +++++++++++++++------------ 2 files changed, 20 insertions(+), 17 deletions(-) diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index c46f9323a..7ff94c16a 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -1163,8 +1163,8 @@ class CoursesController < ApplicationController course_id = course.id course_name = course.name course_list_name = course.course_list.present? ? course.course_list.name : "--" - course_assistants = course.course_members.course_user_role(%i[PROFESSOR ASSISTANT_PROFESSOR]) - course_assistants_count = course_assistants&.count + course_assistants = course.teachers + course_assistants_count = course_assistants&.size course_assistants_name = course_assistants_count > 0 ? course_assistants.map{|m| m.user.real_name}.join('、') : "--" course_teacher_member = course.course_members.course_user_role(%i[CREATOR]) course_teacher = course_teacher_member.present? ? course_teacher_member.first.user.real_name : "--" diff --git a/app/helpers/export_helper.rb b/app/helpers/export_helper.rb index 76f51e498..b08cbb549 100644 --- a/app/helpers/export_helper.rb +++ b/app/helpers/export_helper.rb @@ -41,9 +41,9 @@ module ExportHelper w_user = w.user w_1 = (index + 1) if w_user.present? - w_2 = w_user&.login - w_3 = w_user&.real_name - w_3_1 = w_user&.mail + w_2 = w_user&.login.present? ? w_user&.login : "--" + w_3 = w_user&.real_name.present? ? w_user&.real_name : "--" + w_3_1 = w_user&.mail.present? ? w_user.mail : "--" w_4 = w_user.student_id.present? ? w_user.student_id : "--" else w_2 = "--" @@ -129,9 +129,9 @@ module ExportHelper myshixun = w.try(:myshixun) 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_2 = w_user&.login.present? ? w_user&.login : "--" + w_3 = w_user&.real_name.present? ? w_user&.real_name : "--" + w_3_1 = w_user&.mail.present? ? w_user.mail : "--" w_4 = w_user.student_id.present? ? w_user.student_id : "--" course_name = course.students.find_by(user_id: w.user_id).try(:course_group_name) w_5 = course_name.present? ? course_name : "--" @@ -214,9 +214,9 @@ module ExportHelper items.includes(user: :user_extension).each_with_index do |work,index| w_1 = (index+1) w_user = work.user - w_2 = w_user.login - w_3 = w_user.real_name - w_3_1 = w_user.mail + w_2 = w_user&.login.present? ? w_user&.login : "--" + w_3 = w_user&.real_name.present? ? w_user&.real_name : "--" + w_3_1 = w_user&.mail.present? ? w_user.mail : "--" w_4 = w_user.student_id.present? ? w_user.student_id : "--" w_5 = work.class_grouping_name if task_type_boolean #是否分组 @@ -305,8 +305,11 @@ module ExportHelper user_start_time = e_user.start_at.present? ? e_user.start_at.strftime('%Y-%m-%d %H:%M') : "--" user_end_time = e_user.end_at.present? ? e_user.end_at.strftime('%Y-%m-%d %H:%M') : "--" user_student_id = user_info.student_id.present? ? user_info.student_id : "--" + user_login = user_info&.login.present? ? user_info.login : "--" + user_real_name = user_info.real_name.present? ? user_info.real_name : "--" + user_mail = user_info&.mail.present? ? user_info.mail : "--" - user_option = [index+1,user_info.login,user_info.real_name, user_info.mail || '--', + user_option = [index+1,user_login,user_real_name, user_mail, user_student_id,user_course,user_commit_stu] if ques_type_boolean other_user_option = [user_obj_score,user_suj_score,user_score,user_start_time,user_end_time] @@ -335,11 +338,11 @@ module ExportHelper topic = nil end w_1 = (index+1) - w_2 = user.login - w_3 = user.real_name - w_3_1 = user.mail - w_4 = user.student_id - w_5 = student.course_group_name + w_2 = user&.login.present? ? user&.login : "--" + w_3 = user&.real_name.present? ? user&.real_name : "--" + w_3_1 = user&.mail.present? ? user.mail : "--" + w_4 = user.student_id.present? ? user.student_id : "--" + w_5 = student&.course_group_name.present? ? student.course_group_name : "--" w_6 = topic.present? ? topic.name : "--" w_7 = topic.present? ? topic.teacher.full_name : "--" w_8 = topic.present? ? topic.teacher.identity : "--" From b56ed404d8bb3a1633f151fb2500c8644dcc4f6d Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Wed, 17 Jul 2019 17:16:28 +0800 Subject: [PATCH 09/12] =?UTF-8?q?=E8=AF=84=E6=B5=8B=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/myshixuns_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/myshixuns_controller.rb b/app/controllers/myshixuns_controller.rb index c36be6284..ca527e47d 100644 --- a/app/controllers/myshixuns_controller.rb +++ b/app/controllers/myshixuns_controller.rb @@ -123,7 +123,7 @@ class MyshixunsController < ApplicationController jenkins_testsets.each_with_index do |j_test_set, i| logger.info("j_test_set: ############## #{j_test_set}") actual_output = tran_base64_decode64(j_test_set['output']) - ts_time += j_test_set['testSetTime'].to_i + #ts_time += j_test_set['testSetTime'].to_i # is_public = test_sets.where(:position => j_test_set['caseId']).first.try(:is_public) logger.info "actual_output:################################################# #{actual_output}" From 1675c21c2119ae56663099bd57e80dc29f7dfca2 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Wed, 17 Jul 2019 17:20:18 +0800 Subject: [PATCH 10/12] =?UTF-8?q?=E8=BF=81=E7=A7=BB=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- db/migrate/20190716062401_add_ts_time_to_outputs.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/migrate/20190716062401_add_ts_time_to_outputs.rb b/db/migrate/20190716062401_add_ts_time_to_outputs.rb index 8e0c55a78..7f09ea818 100644 --- a/db/migrate/20190716062401_add_ts_time_to_outputs.rb +++ b/db/migrate/20190716062401_add_ts_time_to_outputs.rb @@ -1,5 +1,5 @@ class AddTsTimeToOutputs < ActiveRecord::Migration[5.2] def change - add_column :outputs, :ts_time, :float + #add_column :outputs, :ts_time, :float end end From 5bfd875ffa5b886ba482a36a18ab58ca66aa3c64 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Wed, 17 Jul 2019 17:21:07 +0800 Subject: [PATCH 11/12] =?UTF-8?q?=E8=BF=81=E7=A7=BB=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- db/migrate/20190716062401_add_ts_time_to_outputs.rb | 2 +- lib/educoder/tip_exception.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/db/migrate/20190716062401_add_ts_time_to_outputs.rb b/db/migrate/20190716062401_add_ts_time_to_outputs.rb index 7f09ea818..8e0c55a78 100644 --- a/db/migrate/20190716062401_add_ts_time_to_outputs.rb +++ b/db/migrate/20190716062401_add_ts_time_to_outputs.rb @@ -1,5 +1,5 @@ class AddTsTimeToOutputs < ActiveRecord::Migration[5.2] def change - #add_column :outputs, :ts_time, :float + add_column :outputs, :ts_time, :float end end diff --git a/lib/educoder/tip_exception.rb b/lib/educoder/tip_exception.rb index 09f0228ac..08fd53ed6 100644 --- a/lib/educoder/tip_exception.rb +++ b/lib/educoder/tip_exception.rb @@ -13,7 +13,7 @@ module Educoder @status = status @message = message - Rails.logger.info("############# #{@status}, #{@message}") + Rails.logger.error("############# #{@status}, #{@message}") end def tip_json From 1f6f1dadecca81f20bc3aac3555d11be73d3247c Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Wed, 17 Jul 2019 17:27:51 +0800 Subject: [PATCH 12/12] =?UTF-8?q?=E5=AE=9E=E8=AE=AD=E9=A2=98=E7=9A=84?= =?UTF-8?q?=E6=8F=90=E4=BA=A4=E8=80=97=E6=97=B6=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/helpers/export_helper.rb | 3 +-- app/views/student_works/shixun_work.json.jbuilder | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/app/helpers/export_helper.rb b/app/helpers/export_helper.rb index b08cbb549..742deb85b 100644 --- a/app/helpers/export_helper.rb +++ b/app/helpers/export_helper.rb @@ -163,7 +163,7 @@ module ExportHelper end 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 + w_17 = (game_spend_time w.cost_time) teacher_comments = w.student_works_scores if teacher_comments.present? w_18 = "" @@ -173,7 +173,6 @@ module ExportHelper user_score = t&.score user_comment = t.comment.present? ? t.comment : "--" comment_title = "#{user_name}: #{user_time.to_s} #{user_score.to_s}分\n#{user_comment}\n\n" - # ("教师:" + user_name + "\n" + "时间:" + user_time.to_s + "\n" + "分数:" + user_score.to_s + "分" + "\n" + "评语:" + user_comment + "\n\n") w_18 = w_18 + comment_title end else diff --git a/app/views/student_works/shixun_work.json.jbuilder b/app/views/student_works/shixun_work.json.jbuilder index 74c33420e..39e7eb1b3 100644 --- a/app/views/student_works/shixun_work.json.jbuilder +++ b/app/views/student_works/shixun_work.json.jbuilder @@ -22,7 +22,7 @@ index = 1 json.game_list @myshixun.games do |game| json.position index json.end_time game.end_time ? game.end_time : '--' - json.cost_time game.cost_time + json.cost_time (game_spend_time game.cost_time) json.score game.final_score json.complete_status game_status(game, @homework) index += 1