From cd3147dc970a41c91ef569fffe241a8da8dc69bc Mon Sep 17 00:00:00 2001 From: jasder Date: Sat, 29 Jun 2019 15:17:03 +0800 Subject: [PATCH 01/15] FIX bug --- app/controllers/files_controller.rb | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/app/controllers/files_controller.rb b/app/controllers/files_controller.rb index c303c7e78..c8fd042ea 100644 --- a/app/controllers/files_controller.rb +++ b/app/controllers/files_controller.rb @@ -16,12 +16,17 @@ class FilesController < ApplicationController sort = params[:sort] || 0 # 0: 降序;1: 升序 sort_type = params[:sort_type] || 'created_on' # created_on:时间排序, downloads:下载次数排序; quotes: 引用次数排序 course_second_category_id = params[:course_second_category_id] || 0 # 0: 为主目录, 其他为次目录id - @user = current_user || nil + @user = current_user @attachments = @course.attachments.by_course_second_category_id(course_second_category_id) .includes(attachment_group_settings: :course_group, author: [:user_extension, :course_members]) .ordered(sort: sort.to_i, sort_type: sort_type.strip) + get_category(@course, course_second_category_id) + @total_count = @attachments.size + @public_count = @attachments.publiced.size + @private_count = @total_count - @public_count + @attachments = @attachments.by_keywords(params[:search]) @attachments = case @user.course_identity(@course) when 5 @@ -32,12 +37,6 @@ class FilesController < ApplicationController @attachments end - @total_count = @attachments.size - @public_count = @attachments.publiced.size - @private_count = @total_count - @public_count - - @attachments = @attachments.by_keywords(params[:search]) - @attachments = @attachments.page(@page).per(@page_size) end From 069571bec2ad5de05dca27ac29a7a8c539007582 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Sat, 29 Jun 2019 15:17:46 +0800 Subject: [PATCH 02/15] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/challenges_controller.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/challenges_controller.rb b/app/controllers/challenges_controller.rb index afe0e14b6..41ba59be8 100644 --- a/app/controllers/challenges_controller.rb +++ b/app/controllers/challenges_controller.rb @@ -160,8 +160,8 @@ class ChallengesController < ApplicationController def show @tab = params[:tab].nil? ? 1 : params[:tab].to_i - challenge_num = Challenge.where(shixun_id: @shixun).count - @power = current_user.manager_of_shixun?(@shixun) && @shixun.status == 0 + challenge_num = @shixun.challenges_count + @power = @shixun.status == 0 # 之前验证走过了是不是管理员,因此这里只用判断是否发布 @position = @challenge.position if @position < challenge_num @next_challenge = Challenge.where(:shixun_id => @shixun, :position => @position + 1).first From 6cf53047c35635351ec2f495cc3262b1858d044e Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Sat, 29 Jun 2019 15:25:24 +0800 Subject: [PATCH 03/15] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/challenges_controller.rb | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/app/controllers/challenges_controller.rb b/app/controllers/challenges_controller.rb index 41ba59be8..d56c3ecbd 100644 --- a/app/controllers/challenges_controller.rb +++ b/app/controllers/challenges_controller.rb @@ -138,7 +138,7 @@ class ChallengesController < ApplicationController # tab 0,nil 过关任务, 1 评测设置, 2 参考答案 def edit @tab = params[:tab].to_i - @power = current_user.manager_of_shixun?(@shixun) && @shixun.status == 0 + @power = @shixun.status == 0 challenge_num = Challenge.where(:shixun_id => @shixun).count @position = @challenge.position @chooses = @challenge.challenge_chooses @@ -279,9 +279,6 @@ class ChallengesController < ApplicationController def find_shixun @shixun = Shixun.find_by_identifier(params[:shixun_identifier]) - if !current_user.shixun_permission(@shixun) - tip_exception(403, "..") - end end # 通用接口 From 3c1710eefc7218f1ad82d4c2e3f75c4b8eb15a06 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Sat, 29 Jun 2019 15:36:03 +0800 Subject: [PATCH 04/15] fix bug --- app/controllers/exercises_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/exercises_controller.rb b/app/controllers/exercises_controller.rb index 421c5177a..2fcd7275b 100644 --- a/app/controllers/exercises_controller.rb +++ b/app/controllers/exercises_controller.rb @@ -1418,7 +1418,7 @@ class ExercisesController < ApplicationController :best_counts => best_counts, } - @exercise_questions = @exercise.exercise_questions + @exercise_questions = @exercise.exercise_questions&.includes(:exercise_choices,:exercise_answers,:exercise_standard_answers,:exercise_shixun_challenges,:exercise_shixun_answers) @paging_type = "percent" # 按题型排序 From 133eaf42cb390f68070119668b92e3719d9fe20f Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Sat, 29 Jun 2019 15:53:04 +0800 Subject: [PATCH 05/15] =?UTF-8?q?=E9=97=AE=E5=8D=B7/=E8=AF=95=E5=8D=B7?= =?UTF-8?q?=E7=9A=84=E5=88=97=E8=A1=A8=E9=A1=B5=EF=BC=8C=E9=A2=84=E8=A7=88?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2=E5=8F=8A=E7=BB=9F=E8=AE=A1=E7=BB=93=E6=9E=9C?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2=E7=9A=84=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/exercises_controller.rb | 4 ++-- app/controllers/polls_controller.rb | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/controllers/exercises_controller.rb b/app/controllers/exercises_controller.rb index 2fcd7275b..8b65d7c70 100644 --- a/app/controllers/exercises_controller.rb +++ b/app/controllers/exercises_controller.rb @@ -101,7 +101,7 @@ class ExercisesController < ApplicationController @page = params[:page] || 1 @limit = params[:limit] || 15 @exercises = @exercises.page(@page).per(@limit) - @exercises = @exercises.includes(:exercise_users,:exercise_questions,:exercise_group_settings) + @exercises = @exercises&.includes(:exercise_users,:exercise_questions,:exercise_group_settings) else @exercises = [] end @@ -188,7 +188,7 @@ class ExercisesController < ApplicationController else @is_teacher_or = 0 #为学生 end - @exercise_questions = @exercise.exercise_questions.order("question_number ASC") + @exercise_questions = @exercise.exercise_questions&.includes(:exercise_choices,:exercise_shixun_challenges,:exercise_standard_answers).order("question_number ASC") rescue Exception => e uid_logger_error(e.message) tip_exception("试卷创建失败!") diff --git a/app/controllers/polls_controller.rb b/app/controllers/polls_controller.rb index 6fbba1c3d..cd9679972 100644 --- a/app/controllers/polls_controller.rb +++ b/app/controllers/polls_controller.rb @@ -90,7 +90,7 @@ class PollsController < ApplicationController @limit = params[:limit] || 15 @polls = @polls.page(@page).per(@limit) - @polls = @polls.includes(:poll_users,:poll_questions,:poll_group_settings) + @polls = @polls&.includes(:poll_users,:poll_questions,:poll_group_settings) else @polls = [] @@ -183,7 +183,7 @@ class PollsController < ApplicationController else @is_teacher_or = 0 end - @poll_questions = @poll.poll_questions.order("question_number ASC") + @poll_questions = @poll.poll_questions&.includes(:poll_answers).order("question_number ASC") rescue Exception => e uid_logger_error(e.message) tip_exception("没有权限") @@ -1148,7 +1148,7 @@ class PollsController < ApplicationController end def get_questions_count - @poll_questions = @poll.poll_questions.order("question_number ASC") + @poll_questions = @poll.poll_questions&.includes(:poll_answers,:poll_votes).order("question_number ASC") @poll_questions_count = @poll_questions.count # 全部的题目数 @poll_question_singles = @poll_questions.ques_count(1).all.count # 单选题 @poll_question_doubles = @poll_questions.ques_count(2).all.count # 多选题 From 783e2e1727cd0e29dc529c9eaf78df33dfe3602d Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Sat, 29 Jun 2019 16:23:37 +0800 Subject: [PATCH 06/15] fix bug --- app/helpers/polls_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/helpers/polls_helper.rb b/app/helpers/polls_helper.rb index b5ba79dcc..d9b6ccee7 100644 --- a/app/helpers/polls_helper.rb +++ b/app/helpers/polls_helper.rb @@ -110,7 +110,7 @@ module PollsHelper poll_user_name = user.nickname end course_member = course_members.find_by(user_id:user.id) - course_group_id = course_members.present? ? course_member.course_group_id : nil + course_group_id = course_member.present? ? course_member.course_group_id : nil if course_group_id == 0 course_group_name = "未分班" else From ad9e7a58f70e584f7254f5049643e546779969e4 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Sat, 29 Jun 2019 17:21:38 +0800 Subject: [PATCH 07/15] =?UTF-8?q?=E5=88=A0=E9=99=A4=E5=A4=9A=E4=BD=99?= =?UTF-8?q?=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/games_controller.rb | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/app/controllers/games_controller.rb b/app/controllers/games_controller.rb index 2a2439226..76e15f9e2 100644 --- a/app/controllers/games_controller.rb +++ b/app/controllers/games_controller.rb @@ -426,12 +426,12 @@ class GamesController < ApplicationController game_code = GameCode.where(:game_id => @game.try(:id), :path => path).first if game_code.present? content = game_code.try(:new_code) - @content = if @myshixun.mirror_name.select{|a| a.include?("MachineLearning") || a.include?("Python")}.present? && content.present? - content.gsub(/\t/, ' ') - else - content - end - update_file_content(@content, @myshixun.repo_path, path, current_user.mail, current_user.full_name, "game passed reset") + # @content = if @myshixun.mirror_name.select{|a| a.include?("MachineLearning") || a.include?("Python")}.present? && content.present? + # content.gsub(/\t/, ' ') + # else + # content + # end + update_file_content(content, @myshixun.repo_path, path, current_user.mail, current_user.full_name, "game passed reset") else tip_exception("代码重置失败,代码为空") end From 07e7f0d206b7058438b06bb6f94c80a41c483961 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Sat, 29 Jun 2019 17:23:40 +0800 Subject: [PATCH 08/15] fix bug --- app/controllers/zips_controller.rb | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/app/controllers/zips_controller.rb b/app/controllers/zips_controller.rb index a8750fc3d..710846f64 100644 --- a/app/controllers/zips_controller.rb +++ b/app/controllers/zips_controller.rb @@ -52,15 +52,16 @@ class ZipsController < ApplicationController @ex_users = default_ex_users #仅导出已提交的,截止后则是全部为提交的。 #可以分班选择 if group_id.present? - exercise_students = @course.students.course_find_by_ids("course_group_id",group_id) # 试卷所分班的全部人数 - user_ids = exercise_students.pluck(:user_id).reject(&:blank?) - @ex_users = @ex_users.exercise_commit_users(user_ids) + exercise_students = @course.students.where(course_group_id: group_id) # 试卷所分班的全部人数 + user_ids = exercise_students.pluck(:user_id).reject(&:blank?).uniq + logger.info("+++++++##################_________________user_ids_____________#########{user_ids}") + @ex_users = @ex_users.where(user_id: user_ids) end # @ex_users = @ex_users.first(200) if default_ex_users_size == 0 normal_status(-1,"导出失败,暂时没有已提交的学生") - elsif default_ex_users_size > 200 - normal_status(-1,"导出数量超过200,请分班导出或联系网站管理员导出") + elsif default_ex_users_size > 100 + normal_status(-1,"导出数量超过100,请分班导出或联系网站管理员导出") end end rescue Exception => e From c6e1fd3f8d0cb2ffd2078582e1eb00a19f1af684 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Sat, 29 Jun 2019 17:26:36 +0800 Subject: [PATCH 09/15] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E8=AF=95=E5=8D=B7?= =?UTF-8?q?=E7=9A=84=E7=AD=94=E9=A2=98=E8=AF=95=E5=8D=B7=E5=AF=BC=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/zips_controller.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/controllers/zips_controller.rb b/app/controllers/zips_controller.rb index 710846f64..4de85ec64 100644 --- a/app/controllers/zips_controller.rb +++ b/app/controllers/zips_controller.rb @@ -48,16 +48,16 @@ class ZipsController < ApplicationController @course = @exercise.course default_ex_users = @exercise.all_exercise_users(current_user.id).exercise_user_committed - default_ex_users_size = default_ex_users.size @ex_users = default_ex_users #仅导出已提交的,截止后则是全部为提交的。 #可以分班选择 if group_id.present? exercise_students = @course.students.where(course_group_id: group_id) # 试卷所分班的全部人数 user_ids = exercise_students.pluck(:user_id).reject(&:blank?).uniq - logger.info("+++++++##################_________________user_ids_____________#########{user_ids}") @ex_users = @ex_users.where(user_id: user_ids) end - # @ex_users = @ex_users.first(200) + + default_ex_users_size = @ex_users.size + if default_ex_users_size == 0 normal_status(-1,"导出失败,暂时没有已提交的学生") elsif default_ex_users_size > 100 From 15668d41986e7851c9d29ac2719ad4cb986995aa Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Sat, 29 Jun 2019 17:49:18 +0800 Subject: [PATCH 10/15] fix bug --- app/templates/exercise_export/exercise_user.html.erb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/templates/exercise_export/exercise_user.html.erb b/app/templates/exercise_export/exercise_user.html.erb index c81f45d68..0c1c1bbab 100644 --- a/app/templates/exercise_export/exercise_user.html.erb +++ b/app/templates/exercise_export/exercise_user.html.erb @@ -9,6 +9,7 @@
+
<%= request.url %>

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

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

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

From 51dc8ae124d3e5eca4921d5f0134782de39bb94e Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Sat, 29 Jun 2019 19:31:45 +0800 Subject: [PATCH 13/15] =?UTF-8?q?=E5=AF=BC=E5=87=BApdf=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E6=A0=87=E9=A2=98=E5=9B=BE=E7=89=87=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/exercises_controller.rb | 1 + app/controllers/zips_controller.rb | 5 ++--- app/services/exercise_user_pdf_service.rb | 4 ++-- app/templates/exercise_export/blank_exercise.html.erb | 8 +++++--- app/templates/exercise_export/exercise_user.html.erb | 5 ++--- 5 files changed, 12 insertions(+), 11 deletions(-) diff --git a/app/controllers/exercises_controller.rb b/app/controllers/exercises_controller.rb index 8b65d7c70..2377f411b 100644 --- a/app/controllers/exercises_controller.rb +++ b/app/controllers/exercises_controller.rb @@ -1334,6 +1334,7 @@ class ExercisesController < ApplicationController #导出空白试卷 def export_exercise @exercise_questions = @exercise.exercise_questions.includes(:exercise_choices).order("question_number ASC") + @request_url = request.base_url filename = "#{current_user.real_name}_#{@course.name}_#{@exercise.exercise_name}_#{Time.current.strftime('%Y%m%d%H%M%S')}.pdf" stylesheets = "#{Rails.root}/app/templates/exercise_export/exercise_export.css" render pdf: 'exercise_export/blank_exercise', filename: filename, stylesheets: stylesheets diff --git a/app/controllers/zips_controller.rb b/app/controllers/zips_controller.rb index c1ff95abd..b23a3e033 100644 --- a/app/controllers/zips_controller.rb +++ b/app/controllers/zips_controller.rb @@ -42,7 +42,6 @@ class ZipsController < ApplicationController begin @exercise = Exercise.includes(:exercise_users,:exercise_questions).find_by(id:params[:exercise_id]) @request_url = request.base_url - logger.info("######################____________@request_url____________##########################{@request_url}") group_id = params[:exercise_group_id] if @exercise.blank? normal_status(-1,"试卷不存在") @@ -50,12 +49,12 @@ class ZipsController < ApplicationController @course = @exercise.course default_ex_users = @exercise.all_exercise_users(current_user.id).exercise_user_committed - @ex_users = default_ex_users #仅导出已提交的,截止后则是全部为提交的。 + @ex_users = default_ex_users.limit 1 #仅导出已提交的,截止后则是全部为提交的。 #可以分班选择 if group_id.present? exercise_students = @course.students.where(course_group_id: group_id) # 试卷所分班的全部人数 user_ids = exercise_students.pluck(:user_id).reject(&:blank?).uniq - @ex_users = @ex_users.where(user_id: user_ids) + @ex_users = @ex_users.where(user_id: user_ids).limit 1 end default_ex_users_size = @ex_users.size diff --git a/app/services/exercise_user_pdf_service.rb b/app/services/exercise_user_pdf_service.rb index 913d0cfbc..9b96cd70c 100644 --- a/app/services/exercise_user_pdf_service.rb +++ b/app/services/exercise_user_pdf_service.rb @@ -38,10 +38,10 @@ class ExerciseUserPdfService kit = PDFKit.new(html) base_css = %w(app/templates/exercise_export/exercise_export.css) base_css.each { |css| kit.stylesheets << Rails.root.join(css) } - #-----正式需删掉 + # #-----正式需删掉 # aa = File.open(Rails.root.join("public/123.html"),"w+") # aa.syswrite(kit.source) - #正式需删掉------- + # #正式需删掉------- file = Tempfile.new(filename) kit.to_pdf(file.path) file diff --git a/app/templates/exercise_export/blank_exercise.html.erb b/app/templates/exercise_export/blank_exercise.html.erb index 2745f8cbe..95a92358f 100644 --- a/app/templates/exercise_export/blank_exercise.html.erb +++ b/app/templates/exercise_export/blank_exercise.html.erb @@ -68,13 +68,15 @@ (<%= q&.question_score %>分)
+ <% q_title = q.question_title&.include?("src=\"") ? q.question_title&.gsub("src=\"","src=\"#{@request_url}") : q.question_title %> <% if q.question_type == 5 %> - <%= q.shixun_name.present? ? q.shixun_name&.html_safe : "" %> + <% q_name = q.shixun_name&.include?("src=\"") ? q.shixun_name&.gsub("src=\"","src=\"#{@request_url}") : q.shixun_name %> + <%= q_name&.html_safe %>
- <%= q.question_title.present? ? q.question_title&.html_safe : "" %> + <%= q_title&.html_safe %>
<% else %> - <%= q.question_title.present? ? q.question_title&.html_safe : "" %> + <%= q_title&.html_safe %> <% end %>
diff --git a/app/templates/exercise_export/exercise_user.html.erb b/app/templates/exercise_export/exercise_user.html.erb index df9c4c6ab..42758af77 100644 --- a/app/templates/exercise_export/exercise_user.html.erb +++ b/app/templates/exercise_export/exercise_user.html.erb @@ -167,10 +167,9 @@ <% end %>
- <% q_title = q.question_title&.gsub("src='","src='/#{@request_url}") %> - + <% q_title = q.question_title&.include?("src=\"") ? q.question_title&.gsub("src=\"","src=\"#{@request_url}") : q.question_title %> <% if q_type == 5 %> - <% q_name = q.shixun_name&.gsub("src='","src='/#{@request_url}") %> + <% q_name = q.shixun_name&.include?("src=\"") ? q.shixun_name&.gsub("src=\"","src=\"#{@request_url}") : q.shixun_name %> <%= q_name&.html_safe %>
<%= q_title&.html_safe %> From fba4bf318488bcd1df5eeea72e55048062625e91 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Sat, 29 Jun 2019 19:33:33 +0800 Subject: [PATCH 14/15] fix bug --- app/controllers/zips_controller.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/zips_controller.rb b/app/controllers/zips_controller.rb index b23a3e033..77a41d065 100644 --- a/app/controllers/zips_controller.rb +++ b/app/controllers/zips_controller.rb @@ -49,12 +49,12 @@ class ZipsController < ApplicationController @course = @exercise.course default_ex_users = @exercise.all_exercise_users(current_user.id).exercise_user_committed - @ex_users = default_ex_users.limit 1 #仅导出已提交的,截止后则是全部为提交的。 + @ex_users = default_ex_users #仅导出已提交的,截止后则是全部为提交的。 #可以分班选择 if group_id.present? exercise_students = @course.students.where(course_group_id: group_id) # 试卷所分班的全部人数 user_ids = exercise_students.pluck(:user_id).reject(&:blank?).uniq - @ex_users = @ex_users.where(user_id: user_ids).limit 1 + @ex_users = @ex_users.where(user_id: user_ids) end default_ex_users_size = @ex_users.size From e3dbe6c5734fe337a48fe6df350b5704bbf38e98 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Mon, 1 Jul 2019 09:11:08 +0800 Subject: [PATCH 15/15] fix bug --- app/templates/exercise_export/blank_exercise.html.erb | 10 +++++----- app/templates/exercise_export/exercise_user.html.erb | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/app/templates/exercise_export/blank_exercise.html.erb b/app/templates/exercise_export/blank_exercise.html.erb index 95a92358f..74cea75f1 100644 --- a/app/templates/exercise_export/blank_exercise.html.erb +++ b/app/templates/exercise_export/blank_exercise.html.erb @@ -68,15 +68,15 @@ (<%= q&.question_score %>分)
- <% q_title = q.question_title&.include?("src=\"") ? q.question_title&.gsub("src=\"","src=\"#{@request_url}") : q.question_title %> + <% q_title = q.question_title&.html_safe %> <% if q.question_type == 5 %> - <% q_name = q.shixun_name&.include?("src=\"") ? q.shixun_name&.gsub("src=\"","src=\"#{@request_url}") : q.shixun_name %> - <%= q_name&.html_safe %> + <% q_name = q.shixun_name&.html_safe %> + <%= q_name&.include?("src=\"") ? q_name&.gsub("src=\"","src=\"#{@request_url}") : q_name %>
- <%= q_title&.html_safe %> + <%= q_title&.include?("src=\"") ? q_title&.gsub("src=\"","src=\"#{@request_url}") : q_title %>
<% else %> - <%= q_title&.html_safe %> + <%= q_title&.include?("src=\"") ? q_title&.gsub("src=\"","src=\"#{@request_url}") : q_title %> <% end %>
diff --git a/app/templates/exercise_export/exercise_user.html.erb b/app/templates/exercise_export/exercise_user.html.erb index 42758af77..5770c5921 100644 --- a/app/templates/exercise_export/exercise_user.html.erb +++ b/app/templates/exercise_export/exercise_user.html.erb @@ -167,15 +167,15 @@ <% end %>
- <% q_title = q.question_title&.include?("src=\"") ? q.question_title&.gsub("src=\"","src=\"#{@request_url}") : q.question_title %> + <% q_title = q.question_title&.html_safe %> <% if q_type == 5 %> - <% q_name = q.shixun_name&.include?("src=\"") ? q.shixun_name&.gsub("src=\"","src=\"#{@request_url}") : q.shixun_name %> - <%= q_name&.html_safe %> + <% q_name = q.shixun_name&.html_safe %> + <%= q_name&.include?("src=\"") ? q_name&.gsub("src=\"","src=\"#{@request_url}") : q_name %>
- <%= q_title&.html_safe %> + <%= q_title&.include?("src=\"") ? q_title&.gsub("src=\"","src=\"#{@request_url}") : q_title %>
<% else %> - <%= q_title&.html_safe %> + <%= q_title&.include?("src=\"") ? q_title&.gsub("src=\"","src=\"#{@request_url}") : q_title %> <% end %>