From 1679cfc6b5030663a0340adf2981ce026da9031c Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Thu, 4 Jul 2019 11:12:41 +0800 Subject: [PATCH 1/9] =?UTF-8?q?=E6=92=A4=E9=94=80=E5=8F=91=E5=B8=83?= 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 b3b3023a8..ae75a9a0a 100644 --- a/app/controllers/shixuns_controller.rb +++ b/app/controllers/shixuns_controller.rb @@ -742,8 +742,8 @@ class ShixunsController < ApplicationController if apply && apply.status == 0 apply.update_attribute(:status, 3) apply.tidings.destroy_all - @shixun.update_column('status', 0) end + @shixun.update_column('status', 0) end private From 82c0318861cbcc40efda9b6abb0c797101a63b87 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Thu, 4 Jul 2019 11:14:29 +0800 Subject: [PATCH 2/9] =?UTF-8?q?=E6=92=A4=E9=94=80=E5=8F=91=E5=B8=83?= 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 ae75a9a0a..b8a5ec53c 100644 --- a/app/controllers/shixuns_controller.rb +++ b/app/controllers/shixuns_controller.rb @@ -743,7 +743,7 @@ class ShixunsController < ApplicationController apply.update_attribute(:status, 3) apply.tidings.destroy_all end - @shixun.update_column('status', 0) + @shixun.update_column(:status, 0) end private From 977a966706f1c32c0db263f0a632cecc03d85f70 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Thu, 4 Jul 2019 11:38:18 +0800 Subject: [PATCH 3/9] =?UTF-8?q?=E5=BC=80=E5=90=AF=E5=AE=9E=E8=AE=AD?= =?UTF-8?q?=E6=9C=89=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 +- app/models/challenge.rb | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/app/controllers/games_controller.rb b/app/controllers/games_controller.rb index 7e7b6e082..56c1d9347 100644 --- a/app/controllers/games_controller.rb +++ b/app/controllers/games_controller.rb @@ -454,7 +454,7 @@ class GamesController < ApplicationController begin @content = git_fle_content(@myshixun.repo_path, path) || "" rescue - if params[:retry].present? + if params[:retry].to_i == 1 begin begin # 检测TPM对应的路径代码是否正常 diff --git a/app/models/challenge.rb b/app/models/challenge.rb index ac031c31c..6dd93dcc0 100644 --- a/app/models/challenge.rb +++ b/app/models/challenge.rb @@ -77,14 +77,17 @@ class Challenge < ApplicationRecord def user_tpi_status user_id # todo: 以前没加索引导致相同关卡,同一用户有多个games # 允许跳关则直接开启 - return 1 if shixun.task_pass game = games.where(user_id: user_id).take if game.blank? self.position == 1 ? 1 : 0 elsif game.status == 2 2 else - 1 + if shixun.task_pass + 1 + else + 0 + end end end From 5321c98037f184bda9672f71b161d054f54f7c04 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Thu, 4 Jul 2019 11:38:34 +0800 Subject: [PATCH 4/9] poll export youhua --- app/controllers/polls_controller.rb | 123 +++++++++++++-- app/helpers/polls_helper.rb | 12 -- app/views/polls/commit_result.xlsx.axlsx | 191 ++++++++++++++--------- 3 files changed, 228 insertions(+), 98 deletions(-) diff --git a/app/controllers/polls_controller.rb b/app/controllers/polls_controller.rb index 0dfa4b1b8..1a6981d9f 100644 --- a/app/controllers/polls_controller.rb +++ b/app/controllers/polls_controller.rb @@ -924,7 +924,8 @@ class PollsController < ApplicationController @poll_commit_ids = @poll_users.commit_by_status(1).pluck(:user_id) #问卷提交用户的id @page = params[:page] || 1 @limit = params[:limit] || 10 - @poll_export_questions = @poll_questions.order("question_number ASC") + @poll_export_questions = @poll_questions + logger.info("################____________________#{@poll_questions.pluck(:id)}") @poll_questions = @poll_questions.page(@page).per(@limit) if params[:format] == "xlsx" @@ -936,11 +937,14 @@ class PollsController < ApplicationController respond_to do |format| format.xlsx{ polls_export_name = "#{current_user.real_name}_#{@course.name}_#{@poll.polls_name}_#{Time.now.strftime('%Y%m%d_%H%M%S')}" - render xlsx: "#{polls_export_name.strip.first(30)}",template: "polls/commit_result.xlsx.axlsx",locals: { - poll_questions:@poll_export_questions, - poll:@poll, - poll_users: @poll_users, - poll_commit_ids:@poll_commit_ids} + polls_user_commit = poll_commit_result(@poll,@poll_export_questions,@poll_users,@poll_commit_ids) + render xlsx: "#{polls_export_name.strip.first(30)}",template: "polls/commit_result.xlsx.axlsx",locals: {polls_user_commit:polls_user_commit} + + # render xlsx: "#{polls_export_name.strip.first(30)}",template: "polls/commit_result.xlsx.axlsx",locals: { + # poll_questions:@poll_export_questions, + # poll:@poll, + # poll_users: @poll_users, + # poll_commit_ids:@poll_commit_ids} } end end @@ -1153,11 +1157,12 @@ class PollsController < ApplicationController end def get_questions_count - @poll_questions = @poll.poll_questions&.includes(:poll_answers,:poll_votes).order("question_number ASC") + @poll_questions = @poll.poll_questions.order("question_number ASC") @poll_questions_count = @poll_questions.size # 全部的题目数 - @poll_question_singles = @poll_questions.ques_count(1).all.size # 单选题 - @poll_question_doubles = @poll_questions.ques_count(2).all.size # 多选题 - @poll_question_mains = @poll_questions.ques_count(3).all.size #主观题 + @poll_question_singles = @poll_questions.ques_count(1).size # 单选题 + @poll_question_doubles = @poll_questions.ques_count(2).size # 多选题 + @poll_question_mains = @poll_questions.ques_count(3).size #主观题 + @poll_questions = @poll_questions&.includes(:poll_answers,:poll_votes).distinct end def check_poll_question_complete #commit_poll 的权限 @@ -1301,4 +1306,102 @@ class PollsController < ApplicationController end end + #问卷的统计结果的导出 + def poll_commit_result(poll,poll_questions,poll_users,poll_commit_ids) + obj_commit = [] + sub_commit = [] + user_commit = [] + poll_users_info = %w(序号) + poll_ques_titles = poll_questions.pluck(:question_title).map {|k| k.strip if k.present?} + poll_un_anony = poll.un_anonymous + if poll_un_anony #是否匿名,默认为false + user_info = %w(登陆名 真实姓名 邮箱 学号) + else + user_info = [] + end + poll_users_info = poll_users_info + user_info + poll_ques_titles + poll_questions.each do |q| + if q.question_type != 3 #问题不为主观题 + question_vote_user = q.poll_votes.find_current_vote("user_id",poll_commit_ids).size #该问题的有效填写量 + sheet_row = ["第#{q.question_number}题"] #选择题答案选项的数组 + sheet_answer_row = ["小计"] #选择题回答的答案人数,数组 + sheet_answer_percent = ["比例"] + sheet_answer_useful = ["有效填写人次",question_vote_user] + q.poll_answers.each do |a| #问卷的答案选项 + answer_users_count = a.poll_votes.find_current_vote("user_id",poll_commit_ids).size + answer_percent = (question_vote_user == 0) ? "0.0%" : "#{((answer_users_count / question_vote_user.to_f)*100).round(1).to_s}%" + sheet_row.push(a.answer_text) + sheet_answer_row.push(answer_users_count) + sheet_answer_percent.push(answer_percent) + end + sheet_obj_commit = { + sheet_row:sheet_row, + sheet_answer_row:sheet_answer_row, + sheet_answer_percent:sheet_answer_percent, + sheet_answer_useful:sheet_answer_useful + } + obj_commit.push(sheet_obj_commit) + else #主观题答案 + user_votes= [] + main_show_row = ["第#{q.question_number}题", q.question_title] + q.poll_votes.each_with_index do |v,index| #主观题的答案 + q_poll_vote = [(index+1),v.vote_text.present? ? v.vote_text : "--"] + user_votes.push(q_poll_vote) + end + sheet_sub_commit = { + sub_title: main_show_row, + sub_user_votes:user_votes + } + sub_commit.push(sheet_sub_commit) + end + end #each_with_index + + poll_users.includes(user: :user_extension).each_with_index do |u,index| + u_user = u.user + user_answer_array = [] + poll_questions.each do |q| + user_poll_votes = u_user.poll_votes.find_current_vote("poll_question_id",q.id) + if user_poll_votes.present? + user_poll_answer_ids = user_poll_votes.pluck(:poll_answer_id).reject(&:blank?) + user_poll_vote_texts = user_poll_votes.pluck(:vote_text).reject(&:blank?) + if user_poll_answer_ids.count > 0 + answer_content = q.poll_answers.find_answer_by_custom("id",user_poll_answer_ids) + if user_poll_answer_ids.count >1 + u_answer = answer_content.pluck(:answer_text).join(";") + else + u_answer = answer_content.first.answer_text + end + elsif user_poll_vote_texts.count > 0 + if user_poll_vote_texts.count > 1 + u_answer = user_poll_vote_texts.join(";") + else + u_answer = user_poll_vote_texts.first + end + else + u_answer = "--" + end + else + u_answer = "--" + end + user_answer_array.push(u_answer) + end + user_cell = [index+1] + if poll_un_anony + user_login = u_user.login + user_name = u_user.real_name.present? ? u_user.real_name : "--" + user_student_id = u_user.student_id.present? ? u_user.student_id : "--" + user_cell += [user_login,user_name, u_user.mail, user_student_id] + end + all_user_cell = user_cell + user_answer_array + user_commit.push(all_user_cell) + end + + { + obj_commit:obj_commit, + poll_users_info:poll_users_info, + sub_commit:sub_commit, + user_commit:user_commit + } + end + end diff --git a/app/helpers/polls_helper.rb b/app/helpers/polls_helper.rb index 1892f3fa2..693149e8f 100644 --- a/app/helpers/polls_helper.rb +++ b/app/helpers/polls_helper.rb @@ -128,16 +128,4 @@ module PollsHelper } end - def poll_commit_result(poll,poll_questions,poll_users,poll_commit_ids) - poll_users_info = %w(序号) - poll_ques_titles = poll_questions.pluck(:question_title).map {|k| strip_export_title(k) if k.present?} - poll_un_anony = poll.un_anonymous - if poll_un_anony #是否匿名,默认为false - user_info = %w(登陆名 真实姓名 邮箱 学号) - else - user_info = [] - end - poll_users_info = poll_users_info + user_info + poll_ques_titles - - end end diff --git a/app/views/polls/commit_result.xlsx.axlsx b/app/views/polls/commit_result.xlsx.axlsx index 71585dae9..975668bfe 100644 --- a/app/views/polls/commit_result.xlsx.axlsx +++ b/app/views/polls/commit_result.xlsx.axlsx @@ -7,91 +7,130 @@ wb.styles do |s| wb.add_worksheet(:name => "统计结果") do |sheet| sheet.sheet_view.show_grid_lines = false - poll_users_info = %w(序号) - Rails.logger.info("#############_______________poll_questions.pluck(:question_title)_______####################{poll_questions.pluck(:question_title)}") + obj_commit = polls_user_commit[:obj_commit] + sub_commit = polls_user_commit[:sub_commit] + poll_user_info = polls_user_commit[:poll_users_info] + user_commit = polls_user_commit[:user_commit] - poll_ques_titles = poll_questions.pluck(:question_title).map {|k| strip_export_title(k) if k.present?} - Rails.logger.info("#############_______________poll_ques_titles_______####################{poll_ques_titles}") - poll_un_anony = poll.un_anonymous - if poll_un_anony #是否匿名,默认为false - user_info = %w(登陆名 真实姓名 邮箱 学号) - else - user_info = [] - end - poll_users_info = poll_users_info + user_info + poll_ques_titles - poll_questions.each do |q| - if q.question_type != 3 #问题不为主观题 - question_vote_user = q.poll_votes.find_current_vote("user_id",poll_commit_ids).size #该问题的有效填写量 - sheet_row = ["第#{q.question_number}题"] #选择题答案选项的数组 - sheet_answer_row = ["小计"] #选择题回答的答案人数,数组 - sheet_answer_percent = ["比例"] - sheet_answer_useful = ["有效填写人次",question_vote_user] - q.poll_answers.each do |a| #问卷的答案选项 - answer_users_count = a.poll_votes.find_current_vote("user_id",poll_commit_ids).size - answer_percent = number_to_percentage((answer_users_count.to_f / question_vote_user.to_f)*100,precision:1) - sheet_row.push(a.answer_text) - sheet_answer_row.push(answer_users_count) - sheet_answer_percent.push(answer_percent.to_s) - end - sheet.add_row sheet_row, :height =>15,:style => blue_cell - sheet.add_row sheet_answer_row, :height =>15, :style => sz_all - sheet.add_row sheet_answer_percent, :height =>15, :style => sz_all - sheet.add_row sheet_answer_useful, :height =>15, :style => sz_all - #合并单元格,但无法填充style - # sheet.merge_cells (Axlsx::cell_r(1,sheet.rows.last.row_index) + ':' + Axlsx::cell_r(sheet_row.count-1,sheet.rows.last.row_index)) - # sheet.rows[sheet.rows.last.row_index].style = sz_all + #客观题的导出 + if obj_commit.size > 0 + obj_commit.each do |obj| + sheet.add_row obj[:sheet_row], :height =>15,:style => blue_cell + sheet.add_row obj[:sheet_answer_row], :height =>15, :style => sz_all + sheet.add_row obj[:sheet_answer_percent], :height =>15, :style => sz_all + sheet.add_row obj[:sheet_answer_useful], :height =>15, :style => sz_all sheet.add_row [] - else #主观题答案 - main_show_row = ["第#{q.question_number}题",q.question_title] - sheet.add_row main_show_row,:height =>15, :style => blue_cell - q.poll_votes.each_with_index do |v,index| #主观题的答案 - sheet.add_row [(index+1),v.vote_text.present? ? v.vote_text : "--"],:height =>15, :style => sz_all - end - sheet.add_row [], :style => sz_all end - end #each_with_index + end - sheet.add_row poll_users_info, :height =>15, :style => blue_cell - poll_users.includes(user: :user_extension).each_with_index do |u,index| - u_user = u.user - user_answer_array = [] - poll_questions.each do |q| - user_poll_votes = u_user.poll_votes.find_current_vote("poll_question_id",q.id) - if user_poll_votes.present? - user_poll_answer_ids = user_poll_votes.pluck(:poll_answer_id).reject(&:blank?) - user_poll_vote_texts = user_poll_votes.pluck(:vote_text).reject(&:blank?) - if user_poll_answer_ids.count > 0 - answer_content = q.poll_answers.find_answer_by_custom("id",user_poll_answer_ids) - if user_poll_answer_ids.count >1 - u_answer = answer_content.pluck(:answer_text).join(";") - else - u_answer = answer_content.first.answer_text - end - elsif user_poll_vote_texts.count > 0 - if user_poll_vote_texts.count > 1 - u_answer = user_poll_vote_texts.join(";") - else - u_answer = user_poll_vote_texts.first - end - else - u_answer = "--" - end - else - u_answer = "--" + #主观题的导出 + if sub_commit.size > 0 + sub_commit.each do |sub| + main_sub_title = sub[:sub_tile] + main_sub_content = sub[:sub_user_votes] + sheet.add_row main_sub_title,:height =>15, :style => blue_cell + main_sub_content.each do |con| + sheet.add_row con,:height =>15, :style => sz_all end - user_answer_array.push(u_answer) + sheet.add_row [] end - user_cell = [index+1] - if poll_un_anony - user_login = u_user.login - user_name = u_user.real_name.present? ? u_user.real_name : "--" - user_student_id = u_user.student_id.present? ? u_user.student_id : "--" - user_cell += [user_login,user_name, u_user.mail, user_student_id] + end + + sheet.add_row poll_user_info, :height =>15, :style => blue_cell + + if user_commit.size > 0 + user_commit.each do |com| + sheet.add_row com, :height =>15,:style => sz_all end - all_user_cell = user_cell + user_answer_array - sheet.add_row all_user_cell, :height =>15,:style => sz_all end sheet.column_widths *([25]*sheet.column_info.count) sheet.column_info.first.width = 10 + + #答题用户的导出 + + # sheet.sheet_view.show_grid_lines = false + # poll_users_info = %w(序号) + # poll_ques_titles = poll_questions.pluck(:question_title).map {|k| strip_export_title(k) if k.present?} + # poll_un_anony = poll.un_anonymous + # if poll_un_anony #是否匿名,默认为false + # user_info = %w(登陆名 真实姓名 邮箱 学号) + # else + # user_info = [] + # end + # poll_users_info = poll_users_info + user_info + poll_ques_titles + # poll_questions.each do |q| + # if q.question_type != 3 #问题不为主观题 + # question_vote_user = q.poll_votes.find_current_vote("user_id",poll_commit_ids).size #该问题的有效填写量 + # sheet_row = ["第#{q.question_number}题"] #选择题答案选项的数组 + # sheet_answer_row = ["小计"] #选择题回答的答案人数,数组 + # sheet_answer_percent = ["比例"] + # sheet_answer_useful = ["有效填写人次",question_vote_user] + # q.poll_answers.each do |a| #问卷的答案选项 + # answer_users_count = a.poll_votes.find_current_vote("user_id",poll_commit_ids).size + # answer_percent = number_to_percentage((answer_users_count.to_f / question_vote_user.to_f)*100,precision:1) + # sheet_row.push(a.answer_text) + # sheet_answer_row.push(answer_users_count) + # sheet_answer_percent.push(answer_percent.to_s) + # end + # sheet.add_row sheet_row, :height =>15,:style => blue_cell + # sheet.add_row sheet_answer_row, :height =>15, :style => sz_all + # sheet.add_row sheet_answer_percent, :height =>15, :style => sz_all + # sheet.add_row sheet_answer_useful, :height =>15, :style => sz_all + # #合并单元格,但无法填充style + # # sheet.merge_cells (Axlsx::cell_r(1,sheet.rows.last.row_index) + ':' + Axlsx::cell_r(sheet_row.count-1,sheet.rows.last.row_index)) + # # sheet.rows[sheet.rows.last.row_index].style = sz_all + # sheet.add_row [] + # else #主观题答案 + # main_show_row = ["第#{q.question_number}题",q.question_title] + # sheet.add_row main_show_row,:height =>15, :style => blue_cell + # q.poll_votes.each_with_index do |v,index| #主观题的答案 + # sheet.add_row [(index+1),v.vote_text.present? ? v.vote_text : "--"],:height =>15, :style => sz_all + # end + # sheet.add_row [], :style => sz_all + # end + # end #each_with_index + # + # sheet.add_row poll_users_info, :height =>15, :style => blue_cell + # poll_users.includes(user: :user_extension).each_with_index do |u,index| + # u_user = u.user + # user_answer_array = [] + # poll_questions.each do |q| + # user_poll_votes = u_user.poll_votes.find_current_vote("poll_question_id",q.id) + # if user_poll_votes.present? + # user_poll_answer_ids = user_poll_votes.pluck(:poll_answer_id).reject(&:blank?) + # user_poll_vote_texts = user_poll_votes.pluck(:vote_text).reject(&:blank?) + # if user_poll_answer_ids.count > 0 + # answer_content = q.poll_answers.find_answer_by_custom("id",user_poll_answer_ids) + # if user_poll_answer_ids.count >1 + # u_answer = answer_content.pluck(:answer_text).join(";") + # else + # u_answer = answer_content.first.answer_text + # end + # elsif user_poll_vote_texts.count > 0 + # if user_poll_vote_texts.count > 1 + # u_answer = user_poll_vote_texts.join(";") + # else + # u_answer = user_poll_vote_texts.first + # end + # else + # u_answer = "--" + # end + # else + # u_answer = "--" + # end + # user_answer_array.push(u_answer) + # end + # user_cell = [index+1] + # if poll_un_anony + # user_login = u_user.login + # user_name = u_user.real_name.present? ? u_user.real_name : "--" + # user_student_id = u_user.student_id.present? ? u_user.student_id : "--" + # user_cell += [user_login,user_name, u_user.mail, user_student_id] + # end + # all_user_cell = user_cell + user_answer_array + # sheet.add_row all_user_cell, :height =>15,:style => sz_all + # end + # sheet.column_widths *([25]*sheet.column_info.count) + # sheet.column_info.first.width = 10 end #add_worksheet end \ No newline at end of file From 427a437e99e68fe5b76061d7ac9a9ee4a62d881e Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Thu, 4 Jul 2019 12:14:09 +0800 Subject: [PATCH 5/9] fix bug --- app/controllers/polls_controller.rb | 7 ------- app/views/polls/commit_result.xlsx.axlsx | 14 +++++++------- 2 files changed, 7 insertions(+), 14 deletions(-) diff --git a/app/controllers/polls_controller.rb b/app/controllers/polls_controller.rb index 1a6981d9f..e6ada3098 100644 --- a/app/controllers/polls_controller.rb +++ b/app/controllers/polls_controller.rb @@ -925,7 +925,6 @@ class PollsController < ApplicationController @page = params[:page] || 1 @limit = params[:limit] || 10 @poll_export_questions = @poll_questions - logger.info("################____________________#{@poll_questions.pluck(:id)}") @poll_questions = @poll_questions.page(@page).per(@limit) if params[:format] == "xlsx" @@ -939,12 +938,6 @@ class PollsController < ApplicationController polls_export_name = "#{current_user.real_name}_#{@course.name}_#{@poll.polls_name}_#{Time.now.strftime('%Y%m%d_%H%M%S')}" polls_user_commit = poll_commit_result(@poll,@poll_export_questions,@poll_users,@poll_commit_ids) render xlsx: "#{polls_export_name.strip.first(30)}",template: "polls/commit_result.xlsx.axlsx",locals: {polls_user_commit:polls_user_commit} - - # render xlsx: "#{polls_export_name.strip.first(30)}",template: "polls/commit_result.xlsx.axlsx",locals: { - # poll_questions:@poll_export_questions, - # poll:@poll, - # poll_users: @poll_users, - # poll_commit_ids:@poll_commit_ids} } end end diff --git a/app/views/polls/commit_result.xlsx.axlsx b/app/views/polls/commit_result.xlsx.axlsx index 975668bfe..016c6e34c 100644 --- a/app/views/polls/commit_result.xlsx.axlsx +++ b/app/views/polls/commit_result.xlsx.axlsx @@ -7,13 +7,13 @@ wb.styles do |s| wb.add_worksheet(:name => "统计结果") do |sheet| sheet.sheet_view.show_grid_lines = false - obj_commit = polls_user_commit[:obj_commit] - sub_commit = polls_user_commit[:sub_commit] - poll_user_info = polls_user_commit[:poll_users_info] - user_commit = polls_user_commit[:user_commit] + obj_commit = polls_user_commit[:obj_commit] || [] + sub_commit = polls_user_commit[:sub_commit] || [] + poll_user_info = polls_user_commit[:poll_users_info] || [] + user_commit = polls_user_commit[:user_commit] || [] #客观题的导出 - if obj_commit.size > 0 + if obj_commit&.size > 0 obj_commit.each do |obj| sheet.add_row obj[:sheet_row], :height =>15,:style => blue_cell sheet.add_row obj[:sheet_answer_row], :height =>15, :style => sz_all @@ -24,7 +24,7 @@ wb.styles do |s| end #主观题的导出 - if sub_commit.size > 0 + if sub_commit&.size > 0 sub_commit.each do |sub| main_sub_title = sub[:sub_tile] main_sub_content = sub[:sub_user_votes] @@ -38,7 +38,7 @@ wb.styles do |s| sheet.add_row poll_user_info, :height =>15, :style => blue_cell - if user_commit.size > 0 + if user_commit&.size > 0 user_commit.each do |com| sheet.add_row com, :height =>15,:style => sz_all end From bebbbe099d678e3486cc9084103b6355576a7139 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Thu, 4 Jul 2019 13:45:22 +0800 Subject: [PATCH 6/9] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E6=9F=A5=E9=87=8D?= =?UTF-8?q?=E7=BB=9F=E8=AE=A1=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/homework_commons/group_list.json.jbuilder | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/homework_commons/group_list.json.jbuilder b/app/views/homework_commons/group_list.json.jbuilder index 1be1cdab6..dcc04e761 100644 --- a/app/views/homework_commons/group_list.json.jbuilder +++ b/app/views/homework_commons/group_list.json.jbuilder @@ -7,7 +7,7 @@ json.group_list do end end # 未分班展示情况放在最后 -if @course_groups.count > 0 && @course_groups.count < @limit.to_i +if @course_groups.count < @limit.to_i json.ungroup_list do json.id 0 json.name "未分班" From 17eaebc75a5d34dc759f346a8376b3712768037f Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Thu, 4 Jul 2019 13:55:56 +0800 Subject: [PATCH 7/9] =?UTF-8?q?=E5=8D=A1=E5=85=B6=E5=AE=9E=E8=AE=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/challenge.rb | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/app/models/challenge.rb b/app/models/challenge.rb index 6dd93dcc0..a4fd71830 100644 --- a/app/models/challenge.rb +++ b/app/models/challenge.rb @@ -79,14 +79,14 @@ class Challenge < ApplicationRecord # 允许跳关则直接开启 game = games.where(user_id: user_id).take if game.blank? - self.position == 1 ? 1 : 0 - elsif game.status == 2 - 2 + position == 1 ? 1 : 0 else - if shixun.task_pass - 1 + if game.status == 3 + shixun.task_pass ? 1 : 0 + elsif game.status == 2 + 2 else - 0 + 1 end end end From 77ebf88fde7db138e3a709f2ae6e72f3448f6a42 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Thu, 4 Jul 2019 14:01:24 +0800 Subject: [PATCH 8/9] =?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/models/challenge.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/models/challenge.rb b/app/models/challenge.rb index a4fd71830..cc0f68efb 100644 --- a/app/models/challenge.rb +++ b/app/models/challenge.rb @@ -78,6 +78,8 @@ class Challenge < ApplicationRecord # todo: 以前没加索引导致相同关卡,同一用户有多个games # 允许跳关则直接开启 game = games.where(user_id: user_id).take + logger.info("########---game_status: #{game.status}") + logger.info("########---challenge_id: #{id}") if game.blank? position == 1 ? 1 : 0 else From aa76382c5e67bada312767e6cc3155df4f17308f Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Thu, 4 Jul 2019 14:05:13 +0800 Subject: [PATCH 9/9] =?UTF-8?q?=E5=85=81=E8=AE=B8=E8=B7=B3=E5=85=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/myshixun.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/myshixun.rb b/app/models/myshixun.rb index 31cc53200..a4f05f2ce 100644 --- a/app/models/myshixun.rb +++ b/app/models/myshixun.rb @@ -56,7 +56,7 @@ class Myshixun < ApplicationRecord # status:0 可以测评的; 1 正在测评的; 2评测通过的; 3未开启的 # 如果都完成,则当前任务为最后一个任务 def current_task games - current_game = games.select{|game| game.status == 1 || game.status == 0}.first + current_game = games.select{|game| game.status == 1 || game.status == 0}.last if current_game.blank? current_game = games.last end