From 04bbbc7319175eb83c609454d226d54dd7358535 Mon Sep 17 00:00:00 2001 From: jingquan huang Date: Mon, 1 Jul 2019 09:49:48 +0800 Subject: [PATCH 01/19] =?UTF-8?q?challenges=20=E6=97=A0=E6=B3=95=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/challenges_controller.rb | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/app/controllers/challenges_controller.rb b/app/controllers/challenges_controller.rb index afe0e14b6..bad438fdf 100644 --- a/app/controllers/challenges_controller.rb +++ b/app/controllers/challenges_controller.rb @@ -150,9 +150,8 @@ class ChallengesController < ApplicationController def index uid_logger("identifier: #{params}") - # 通过调试发现 这里includes(:games)性能会慢10倍 - current_myshixun = @shixun.current_myshixun(current_user.id) - @challenges = @shixun.challenges.includes(:games).where("games.user_id" => (current_myshixun ? current_user.id : nil)) + + @challenges = Challenge.fields_for_list.where(shixun_id: @shixun.id) @editable = current_user.manager_of_shixun?(@shixun) && @shixun.status == 0 @user = current_user From 4a257c29603b67ab17d2d59f66b6ba2ce580e172 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Mon, 1 Jul 2019 12:24:00 +0800 Subject: [PATCH 02/19] fix bug --- .../exercise_export/blank_exercise.html.erb | 34 +++++++++---------- 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/app/templates/exercise_export/blank_exercise.html.erb b/app/templates/exercise_export/blank_exercise.html.erb index 9ee1d40f7..f281a55a0 100644 --- a/app/templates/exercise_export/blank_exercise.html.erb +++ b/app/templates/exercise_export/blank_exercise.html.erb @@ -83,30 +83,28 @@
<% if q.question_type == 0 %> - <% q.exercise_choices.each_with_index do |s,index| %> -

- - <%= convert_to_char((index+1).to_s)%> - <%= to_markdown(s.choice_text) %> -

+ <% q.exercise_choices.each do |s| %> +
+ + <%= to_markdown(s.choice_text) %> +
<% end %> <% elsif q.question_type == 1 %> - <% q.exercise_choices.each_with_index do |s,index| %> -

- - <%= convert_to_char((index+1).to_s)%> - <%= to_markdown(s.choice_text) %> -

+ <% q.exercise_choices.each do |s| %> +
+ + <%= to_markdown(s.choice_text) %> +
<% end %> <% elsif q.question_type == 2 %> -

- <% q.exercise_choices.each_with_index do |s,index| %> - - - <%= to_markdown(s.choice_text) %> +

+ <% q.exercise_choices.each do |s| %> + + + <%= to_markdown(s.choice_text) %> <% end %> -

+
<% elsif q.question_type == 3 %> <% st_counts = q.exercise_standard_answers.pluck(:exercise_choice_id).uniq %> <% st_counts.each_with_index do |s,index| %> From 8f3be9a7f6e42c8e3678df80eb6b0f660b748d4c Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Mon, 1 Jul 2019 12:37:13 +0800 Subject: [PATCH 03/19] fix bug --- .../exercise_export/blank_exercise.html.erb | 16 ++++++---------- .../exercise_export/exercise_export.css | 6 ++++++ 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/app/templates/exercise_export/blank_exercise.html.erb b/app/templates/exercise_export/blank_exercise.html.erb index f281a55a0..b253d86b9 100644 --- a/app/templates/exercise_export/blank_exercise.html.erb +++ b/app/templates/exercise_export/blank_exercise.html.erb @@ -68,17 +68,13 @@ (<%= q&.question_score %>分)
- 电脑的电路图 - udasker_picture - <% q_markdown = to_markdown(q.question_title) %> <% if q.question_type == 5 %> - <% q_markdown_name = to_markdown(q.shixun_name) %> - <%= q_markdown_name %> + <%= to_markdown(q.shixun_name) %>
- <%= q_markdown %> + <%= to_markdown(q.question_title) %>
<% else %> - <%= q_markdown %> + <%= to_markdown(q.question_title) %> <% end %>
@@ -86,14 +82,14 @@ <% q.exercise_choices.each do |s| %>
- <%= to_markdown(s.choice_text) %> + <%= to_markdown(s.choice_text) %>
<% end %> <% elsif q.question_type == 1 %> <% q.exercise_choices.each do |s| %>
- <%= to_markdown(s.choice_text) %> + <%= to_markdown(s.choice_text) %>
<% end %> <% elsif q.question_type == 2 %> @@ -101,7 +97,7 @@ <% q.exercise_choices.each do |s| %> - <%= to_markdown(s.choice_text) %> + <%= to_markdown(s.choice_text) %> <% end %>
diff --git a/app/templates/exercise_export/exercise_export.css b/app/templates/exercise_export/exercise_export.css index 9190e9251..bbe523972 100644 --- a/app/templates/exercise_export/exercise_export.css +++ b/app/templates/exercise_export/exercise_export.css @@ -309,6 +309,12 @@ textarea{ clear:both; zoom:1; } +.line-20{ + line-height: 20px; +} +.line-20 P{ + margin-bottom:0; +} From 0922155a1cdd9a603bd59b193506b2537c165896 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Mon, 1 Jul 2019 12:50:01 +0800 Subject: [PATCH 04/19] fix bug --- app/helpers/application_helper.rb | 4 +--- .../exercise_export/blank_exercise.html.erb | 15 +++++++-------- app/templates/exercise_export/exercise_export.css | 4 +++- 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index fd5a8b233..c49e5e775 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -349,9 +349,7 @@ module ApplicationHelper } markdown = Redcarpet::Markdown.new(Redcarpet::Render::HTML,options) m_t = markdown.render(text) - ss = m_t&.include?("src=\"") ? m_t&.gsub("src=\"","src=\"#{request_url}") : m_t - Rails.logger.info("############_____________ss________________##################{ss}") - ss + m_t&.include?("src=\"") ? m_t&.gsub("src=\"","src=\"#{request_url}") : m_t end end diff --git a/app/templates/exercise_export/blank_exercise.html.erb b/app/templates/exercise_export/blank_exercise.html.erb index b253d86b9..5727d0f62 100644 --- a/app/templates/exercise_export/blank_exercise.html.erb +++ b/app/templates/exercise_export/blank_exercise.html.erb @@ -44,7 +44,6 @@ 实训题<%= @exercise_ques_shixun_count %>题, 共<%= @exercise_ques_shixun_scores %> <% end %> - <% if @exercise_ques_count > 0 %> <%= @exercise_ques_scores %>分 @@ -59,7 +58,7 @@
<% @exercise_questions.each do |q| %>
-
+
<%= q.question_number %>、 @@ -80,15 +79,15 @@
<% if q.question_type == 0 %> <% q.exercise_choices.each do |s| %> -
- +
+ <%= to_markdown(s.choice_text) %>
<% end %> <% elsif q.question_type == 1 %> <% q.exercise_choices.each do |s| %> -
- +
+ <%= to_markdown(s.choice_text) %>
<% end %> @@ -96,8 +95,8 @@
<% q.exercise_choices.each do |s| %> - - <%= to_markdown(s.choice_text) %> + + <%= s.choice_text %> <% end %>
diff --git a/app/templates/exercise_export/exercise_export.css b/app/templates/exercise_export/exercise_export.css index bbe523972..140db58ef 100644 --- a/app/templates/exercise_export/exercise_export.css +++ b/app/templates/exercise_export/exercise_export.css @@ -315,6 +315,8 @@ textarea{ .line-20 P{ margin-bottom:0; } - +.v-middle{ + vertical-align: middle; +} From b69d705ed77f4f81f78b32d323a03f05d5ca5aef Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Mon, 1 Jul 2019 12:52:42 +0800 Subject: [PATCH 05/19] Fix bug --- app/templates/exercise_export/blank_exercise.html.erb | 8 ++++---- app/templates/exercise_export/exercise_export.css | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/templates/exercise_export/blank_exercise.html.erb b/app/templates/exercise_export/blank_exercise.html.erb index 5727d0f62..aed7acdcd 100644 --- a/app/templates/exercise_export/blank_exercise.html.erb +++ b/app/templates/exercise_export/blank_exercise.html.erb @@ -80,15 +80,15 @@ <% if q.question_type == 0 %> <% q.exercise_choices.each do |s| %>
- - <%= to_markdown(s.choice_text) %> + + <%= to_markdown(s.choice_text) %>
<% end %> <% elsif q.question_type == 1 %> <% q.exercise_choices.each do |s| %>
- - <%= to_markdown(s.choice_text) %> + + <%= to_markdown(s.choice_text) %>
<% end %> <% elsif q.question_type == 2 %> diff --git a/app/templates/exercise_export/exercise_export.css b/app/templates/exercise_export/exercise_export.css index 140db58ef..3efda43bb 100644 --- a/app/templates/exercise_export/exercise_export.css +++ b/app/templates/exercise_export/exercise_export.css @@ -309,8 +309,8 @@ textarea{ clear:both; zoom:1; } -.line-20{ - line-height: 20px; +.line-24{ + line-height: 24px; } .line-20 P{ margin-bottom:0; From e365005af14682e96f3bc080ac32ab1c733f1438 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Mon, 1 Jul 2019 12:55:04 +0800 Subject: [PATCH 06/19] fix bug --- app/templates/exercise_export/blank_exercise.html.erb | 4 ++-- app/templates/exercise_export/exercise_export.css | 6 ++---- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/app/templates/exercise_export/blank_exercise.html.erb b/app/templates/exercise_export/blank_exercise.html.erb index aed7acdcd..99b8e6683 100644 --- a/app/templates/exercise_export/blank_exercise.html.erb +++ b/app/templates/exercise_export/blank_exercise.html.erb @@ -79,14 +79,14 @@
<% if q.question_type == 0 %> <% q.exercise_choices.each do |s| %> -
+
<%= to_markdown(s.choice_text) %>
<% end %> <% elsif q.question_type == 1 %> <% q.exercise_choices.each do |s| %> -
+
<%= to_markdown(s.choice_text) %>
diff --git a/app/templates/exercise_export/exercise_export.css b/app/templates/exercise_export/exercise_export.css index 3efda43bb..53dc5b3c8 100644 --- a/app/templates/exercise_export/exercise_export.css +++ b/app/templates/exercise_export/exercise_export.css @@ -312,11 +312,9 @@ textarea{ .line-24{ line-height: 24px; } -.line-20 P{ +.line-24 p{ margin-bottom:0; } -.v-middle{ - vertical-align: middle; -} + From 81950469b4c33cdd8e139a8ac26a4717c7c87f6b Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Mon, 1 Jul 2019 13:15:13 +0800 Subject: [PATCH 07/19] fix bug --- .../exercise_export/blank_exercise.html.erb | 8 ++-- .../exercise_export/exercise_export.css | 10 +++++ .../exercise_export/exercise_user.html.erb | 40 +++++++++---------- 3 files changed, 33 insertions(+), 25 deletions(-) diff --git a/app/templates/exercise_export/blank_exercise.html.erb b/app/templates/exercise_export/blank_exercise.html.erb index 99b8e6683..7e7c14977 100644 --- a/app/templates/exercise_export/blank_exercise.html.erb +++ b/app/templates/exercise_export/blank_exercise.html.erb @@ -80,15 +80,15 @@ <% if q.question_type == 0 %> <% q.exercise_choices.each do |s| %>
- - <%= to_markdown(s.choice_text) %> + + <%= to_markdown(s.choice_text) %>
<% end %> <% elsif q.question_type == 1 %> <% q.exercise_choices.each do |s| %>
- - <%= to_markdown(s.choice_text) %> + + <%= to_markdown(s.choice_text) %>
<% end %> <% elsif q.question_type == 2 %> diff --git a/app/templates/exercise_export/exercise_export.css b/app/templates/exercise_export/exercise_export.css index 53dc5b3c8..a72b26782 100644 --- a/app/templates/exercise_export/exercise_export.css +++ b/app/templates/exercise_export/exercise_export.css @@ -44,6 +44,9 @@ p{ .mbt10{ margin: 10px 0; } +.mt5{ + margin-top:5px; +} .pull-right{ float:right; } @@ -82,9 +85,15 @@ p{ .ml20{ margin-left:20px; } +.ml10{ + margin-left:10px; +} .mr3{ margin-right:3px; } +.mr8{ + margin-right:8px; +} .mr15{ margin-right:15px; } @@ -318,3 +327,4 @@ textarea{ + diff --git a/app/templates/exercise_export/exercise_user.html.erb b/app/templates/exercise_export/exercise_user.html.erb index 5770c5921..1679692b3 100644 --- a/app/templates/exercise_export/exercise_user.html.erb +++ b/app/templates/exercise_export/exercise_user.html.erb @@ -167,41 +167,39 @@ <% end %>
- <% q_title = q.question_title&.html_safe %> - <% if q_type == 5 %> - <% q_name = q.shixun_name&.html_safe %> - <%= q_name&.include?("src=\"") ? q_name&.gsub("src=\"","src=\"#{@request_url}") : q_name %> + <% if q.question_type == 5 %> + <%= to_markdown(q.shixun_name) %>
- <%= q_title&.include?("src=\"") ? q_title&.gsub("src=\"","src=\"#{@request_url}") : q_title %> + <%= to_markdown(q.question_title) %>
<% else %> - <%= q_title&.include?("src=\"") ? q_title&.gsub("src=\"","src=\"#{@request_url}") : q_title %> + <%= to_markdown(q.question_title) %> <% end %>
<% if q_type == 0 %> - <% q.exercise_choices.each_with_index do |s,index| %> + <% q.exercise_choices.each do |s| %> <% check_answer = (user_answer.present? && (s.id == user_answer.first.exercise_choice_id)) ? "choose-answer" : '' %> -

- - <%= convert_to_char((index+1).to_s)%><%= s.choice_text%> -

+
+ + <%= to_markdown(s.choice_text) %> +
<% end %> <% elsif q_type == 1 %> - <% q.exercise_choices.each_with_index do |s,index| %> + <% q.exercise_choices.each do |s| %> <% check_answer = (user_answer.present? && (user_answer.pluck(:exercise_choice_id).include?(s.id))) ? true : false %> -

+

<% if check_answer %> - + <% else %> - + <% end %> - <%= convert_to_char((index+1).to_s)%><%= s.choice_text%> -

+ <%= to_markdown(s.choice_text) %> +
<% end %> <% elsif q_type == 2 %> -

+

<% q.exercise_choices.each do |s| %> <% if user_answer.present? && (s.id == user_answer.first.exercise_choice_id) %> <% check_answer = 'choose-answer' %> @@ -213,7 +211,7 @@ <%= s.choice_text %> <% end %> -

+
<% elsif q_type == 3 %> <% st_counts = q.exercise_standard_answers.pluck(:exercise_choice_id).uniq %> <% st_counts.each_with_index do |s,index| %> @@ -224,13 +222,13 @@ <% end %>

答案(填空<%= index+1 %>): - <%= check_answer&.html_safe %> + <%= to_markdown(check_answer) %>

<% end %> <% elsif q_type == 4 %> <% check_answer = (user_answer.present? ? user_answer.first.answer_text : '--') %>

- <%= check_answer&.html_safe %> + <%= to_markdown(check_answer) %>

<% else %>
From 065669bc2b2a0c7dcdadbdfa450a61b0d559df7d Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Mon, 1 Jul 2019 13:38:18 +0800 Subject: [PATCH 08/19] =?UTF-8?q?fork=E5=AE=9E=E8=AE=AD=E5=B8=A6=E7=9D=80?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=E4=BF=A1=E6=81=AF"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/shixuns_controller.rb | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/app/controllers/shixuns_controller.rb b/app/controllers/shixuns_controller.rb index 5631d03a7..f7172021c 100644 --- a/app/controllers/shixuns_controller.rb +++ b/app/controllers/shixuns_controller.rb @@ -179,6 +179,16 @@ class ShixunsController < ApplicationController ShixunTagRepertoire.create!(:tag_repertoire_id => str.tag_repertoire_id, :shixun_id => @new_shixun.id) end + # 同步配置 + @shixun.shixun_service_configs.each do |config| + ShixunServiceConfig.create!(:shixun_id => @new_shixun.id, + :cpu_limit => config.cpu_limit, + :lower_cpu_limit => config.lower_cpu_limit, + :memory_limit => config.memory_limit, + :request_limit => config.request_limit, + :mirror_repository_id => config.mirror_repository_id) + end + # fork版本库 logger.info("###########fork_repo_path: ######{@repo_path}") project_fork(@new_shixun, @repo_path, current_user.login) From db4d45d00e4f5c31842dc9b94fa6e6ec3de4cef9 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Mon, 1 Jul 2019 13:56:36 +0800 Subject: [PATCH 09/19] =?UTF-8?q?=E5=85=B3=E5=8D=A1=E8=AF=A6=E6=83=85?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2=E5=8F=82=E6=95=B0=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/challenges/show.json.jbuilder | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/challenges/show.json.jbuilder b/app/views/challenges/show.json.jbuilder index 332879eac..cffe77ebb 100644 --- a/app/views/challenges/show.json.jbuilder +++ b/app/views/challenges/show.json.jbuilder @@ -1,6 +1,6 @@ # 导航栏公共数据 json.partial! "challenges/top_common_data", shixun_identifier: @shixun.identifier -json.(@challenge, :id, :subject, :task_pass, :difficulty, :score) +json.(@challenge, :id, :subject, :task_pass, :difficulty, :score, :exec_time) json.tags @challenge.challenge_tags.map(&:name) From c3087d7b4e95003a7b1139362f810653884fe90a Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Mon, 1 Jul 2019 13:59:33 +0800 Subject: [PATCH 10/19] fix bug --- app/helpers/application_helper.rb | 1 + .../exercise_export/blank_exercise.html.erb | 12 ++++++------ app/templates/exercise_export/exercise_export.css | 8 +++----- .../exercise_export/exercise_user.html.erb | 14 +++++++------- 4 files changed, 17 insertions(+), 18 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index c49e5e775..e6bc84f20 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -350,6 +350,7 @@ module ApplicationHelper markdown = Redcarpet::Markdown.new(Redcarpet::Render::HTML,options) m_t = markdown.render(text) m_t&.include?("src=\"") ? m_t&.gsub("src=\"","src=\"#{request_url}") : m_t + Rails.logger.info("###########__________request_url_________###################{request_url}") end end diff --git a/app/templates/exercise_export/blank_exercise.html.erb b/app/templates/exercise_export/blank_exercise.html.erb index 7e7c14977..1dde00e56 100644 --- a/app/templates/exercise_export/blank_exercise.html.erb +++ b/app/templates/exercise_export/blank_exercise.html.erb @@ -79,16 +79,16 @@
<% if q.question_type == 0 %> <% q.exercise_choices.each do |s| %> -
- - <%= to_markdown(s.choice_text) %> +
+ + <%= to_markdown(s.choice_text) %>
<% end %> <% elsif q.question_type == 1 %> <% q.exercise_choices.each do |s| %> -
- - <%= to_markdown(s.choice_text) %> +
+ + <%= to_markdown(s.choice_text) %>
<% end %> <% elsif q.question_type == 2 %> diff --git a/app/templates/exercise_export/exercise_export.css b/app/templates/exercise_export/exercise_export.css index a72b26782..f0eeb0f4c 100644 --- a/app/templates/exercise_export/exercise_export.css +++ b/app/templates/exercise_export/exercise_export.css @@ -257,7 +257,7 @@ table{ text-align:center; } -table, tr, td, th, tbody, thead, tfoot,textarea{ +table, tr, td, th, tbody, thead, tfoot,textarea,.main-choice{ page-break-inside: avoid; } table th{ @@ -318,10 +318,8 @@ textarea{ clear:both; zoom:1; } -.line-24{ - line-height: 24px; -} -.line-24 p{ + +.choice-text p{ margin-bottom:0; } diff --git a/app/templates/exercise_export/exercise_user.html.erb b/app/templates/exercise_export/exercise_user.html.erb index 1679692b3..3e92c5864 100644 --- a/app/templates/exercise_export/exercise_user.html.erb +++ b/app/templates/exercise_export/exercise_user.html.erb @@ -181,21 +181,21 @@ <% if q_type == 0 %> <% q.exercise_choices.each do |s| %> <% check_answer = (user_answer.present? && (s.id == user_answer.first.exercise_choice_id)) ? "choose-answer" : '' %> -
- - <%= to_markdown(s.choice_text) %> +
+ + <%= to_markdown(s.choice_text) %>
<% end %> <% elsif q_type == 1 %> <% q.exercise_choices.each do |s| %> <% check_answer = (user_answer.present? && (user_answer.pluck(:exercise_choice_id).include?(s.id))) ? true : false %> -
+
<% if check_answer %> - + <% else %> - + <% end %> - <%= to_markdown(s.choice_text) %> + <%= to_markdown(s.choice_text) %>
<% end %> <% elsif q_type == 2 %> From 733e7827234ddf4055f9932d20f3db6115597dc4 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Mon, 1 Jul 2019 14:03:03 +0800 Subject: [PATCH 11/19] fix bug --- app/controllers/zips_controller.rb | 3 +-- app/helpers/application_helper.rb | 1 + app/services/exercise_user_pdf_service.rb | 3 +-- app/services/export_exercises_service.rb | 5 ++--- 4 files changed, 5 insertions(+), 7 deletions(-) diff --git a/app/controllers/zips_controller.rb b/app/controllers/zips_controller.rb index 77a41d065..4de85ec64 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,@request_url) + exercises = ExportExercisesService.new(@exercise,@ex_users) file_name = filename_for_content_disposition(exercises.filename) send_file exercises.ex_zip, filename: file_name, type: 'application/zip' @@ -41,7 +41,6 @@ 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 group_id = params[:exercise_group_id] if @exercise.blank? normal_status(-1,"试卷不存在") diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index e6bc84f20..f0cac79b9 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -334,6 +334,7 @@ module ApplicationHelper raw arr.join('') end + # 导出pdf时,转化markdown为html def to_markdown(text) request_url = request.base_url diff --git a/app/services/exercise_user_pdf_service.rb b/app/services/exercise_user_pdf_service.rb index 9b96cd70c..be048c4c2 100644 --- a/app/services/exercise_user_pdf_service.rb +++ b/app/services/exercise_user_pdf_service.rb @@ -5,10 +5,9 @@ class ExerciseUserPdfService attr_reader :exercise, :ex_user - def initialize(exercise, ex_user,request_url) + def initialize(exercise, ex_user) @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 48bfc9519..12b5501f9 100644 --- a/app/services/export_exercises_service.rb +++ b/app/services/export_exercises_service.rb @@ -3,10 +3,9 @@ class ExportExercisesService include StudentWorksHelper attr_reader :exercise, :ex_users - def initialize(exercise, ex_users,request_url) + def initialize(exercise, ex_users) @exercise = exercise @ex_users = ex_users - @request_url = request_url end def filename @@ -19,7 +18,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,@request_url) + export = ExerciseUserPdfService.new(exercise, ex_user) pdf = export.ex_pdf pdfs << pdf begin From b8592a99433ac4af3eeb508d1d456fd3b53c623e Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Mon, 1 Jul 2019 14:10:48 +0800 Subject: [PATCH 12/19] fix bug --- app/controllers/exercises_controller.rb | 1 - app/helpers/application_helper.rb | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/app/controllers/exercises_controller.rb b/app/controllers/exercises_controller.rb index 2377f411b..8b65d7c70 100644 --- a/app/controllers/exercises_controller.rb +++ b/app/controllers/exercises_controller.rb @@ -1334,7 +1334,6 @@ 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/helpers/application_helper.rb b/app/helpers/application_helper.rb index f0cac79b9..65b6c0634 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -336,9 +336,9 @@ module ApplicationHelper # 导出pdf时,转化markdown为html def to_markdown(text) + return nil if text.blank? request_url = request.base_url - return nil if text.blank? options = { :autolink => true, :no_intra_emphasis => true, @@ -350,7 +350,7 @@ module ApplicationHelper } markdown = Redcarpet::Markdown.new(Redcarpet::Render::HTML,options) m_t = markdown.render(text) - m_t&.include?("src=\"") ? m_t&.gsub("src=\"","src=\"#{request_url}") : m_t + m_t&.include?("src=\"") ? m_t&.gsub("src=\"","src=\"#{request.base_url}") : m_t Rails.logger.info("###########__________request_url_________###################{request_url}") end From dade42727badc705a19a0e37f3f0a80a53389b86 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Mon, 1 Jul 2019 14:19:39 +0800 Subject: [PATCH 13/19] =?UTF-8?q?=E5=8E=BB=E9=99=A4=E5=AE=9E=E8=AE=AD?= =?UTF-8?q?=E7=9A=84=E5=85=B3=E5=8D=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/shixuns/settings.json.jbuilder | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/shixuns/settings.json.jbuilder b/app/views/shixuns/settings.json.jbuilder index ed7d93039..e81498058 100644 --- a/app/views/shixuns/settings.json.jbuilder +++ b/app/views/shixuns/settings.json.jbuilder @@ -22,7 +22,7 @@ json.shixun do json.hide_code @shixun.hide_code # 隐藏代码窗口 json.code_hidden @shixun.code_hidden # 代码目录隐藏 json.vnc @shixun.vnc - json.exec_time @shixun.exec_time + #json.exec_time @shixun.exec_time json.webssh @shixun.webssh json.multi_webssh @shixun.multi_webssh json.use_scope @shixun.use_scope From c543779cb1aaac41615d0093b5907e14c4f6d6ae Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Mon, 1 Jul 2019 14:20:48 +0800 Subject: [PATCH 14/19] fix bug --- app/helpers/application_helper.rb | 4 ++-- app/templates/exercise_export/exercise_user.html.erb | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 65b6c0634..6ddbdce0c 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -337,7 +337,7 @@ module ApplicationHelper # 导出pdf时,转化markdown为html def to_markdown(text) return nil if text.blank? - request_url = request.base_url + request_url = "http://47.96.87.25:48080" options = { :autolink => true, @@ -350,7 +350,7 @@ module ApplicationHelper } markdown = Redcarpet::Markdown.new(Redcarpet::Render::HTML,options) m_t = markdown.render(text) - m_t&.include?("src=\"") ? m_t&.gsub("src=\"","src=\"#{request.base_url}") : m_t + m_t&.include?("src=\"") ? m_t&.gsub("src=\"","src=\"#{request_url}") : m_t Rails.logger.info("###########__________request_url_________###################{request_url}") end diff --git a/app/templates/exercise_export/exercise_user.html.erb b/app/templates/exercise_export/exercise_user.html.erb index 3e92c5864..f523246a0 100644 --- a/app/templates/exercise_export/exercise_user.html.erb +++ b/app/templates/exercise_export/exercise_user.html.erb @@ -121,7 +121,7 @@
- <%= q.question_number %>、  + <%= q.question_number %>、 <%= request.base_url %> <%= q.question_type_name %> From 90fadb2869971dd7fc8a6b11cc3cd8b52024f92b Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Mon, 1 Jul 2019 14:22:56 +0800 Subject: [PATCH 15/19] =?UTF-8?q?=E5=AF=BC=E5=85=A5=E5=88=86=E7=8F=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/courses_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index e0844ab4c..cef2a1785 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -776,7 +776,7 @@ class CoursesController < ApplicationController name = attachment.disk_filename if name.split(".").last == "xls" begin - attachment_folder = Rails.configuration.educoder['attachment_folder'] + attachment_folder = edu_setting('attachment_folder') full_path = "#{attachment_folder}/#{path}/#{name}" xls = Roo::Spreadsheet.open(full_path, extension: :xls) worksheet = xls.sheet(0) From 0387dbaf9142376a5397438d7c4526d6c1baddd0 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Mon, 1 Jul 2019 14:23:59 +0800 Subject: [PATCH 16/19] fix bug --- app/templates/exercise_export/exercise_user.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/templates/exercise_export/exercise_user.html.erb b/app/templates/exercise_export/exercise_user.html.erb index f523246a0..3e92c5864 100644 --- a/app/templates/exercise_export/exercise_user.html.erb +++ b/app/templates/exercise_export/exercise_user.html.erb @@ -121,7 +121,7 @@
- <%= q.question_number %>、 <%= request.base_url %> + <%= q.question_number %>、  <%= q.question_type_name %> From cc20b5459fc3574baa79218b9ddb126a6093edae Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Mon, 1 Jul 2019 14:36:21 +0800 Subject: [PATCH 17/19] fix bug --- app/controllers/exercises_controller.rb | 1 + app/controllers/zips_controller.rb | 3 ++- app/helpers/application_helper.rb | 7 ++----- app/services/exercise_user_pdf_service.rb | 3 ++- app/services/export_exercises_service.rb | 5 +++-- .../exercise_export/blank_exercise.html.erb | 10 +++++----- app/templates/exercise_export/exercise_user.html.erb | 12 ++++++------ 7 files changed, 21 insertions(+), 20 deletions(-) diff --git a/app/controllers/exercises_controller.rb b/app/controllers/exercises_controller.rb index 8b65d7c70..3c364b979 100644 --- a/app/controllers/exercises_controller.rb +++ b/app/controllers/exercises_controller.rb @@ -1333,6 +1333,7 @@ class ExercisesController < ApplicationController #导出空白试卷 def export_exercise + @request_url = request.base_url @exercise_questions = @exercise.exercise_questions.includes(:exercise_choices).order("question_number ASC") 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" diff --git a/app/controllers/zips_controller.rb b/app/controllers/zips_controller.rb index 4de85ec64..c20546701 100644 --- a/app/controllers/zips_controller.rb +++ b/app/controllers/zips_controller.rb @@ -17,7 +17,8 @@ class ZipsController < ApplicationController end def export_exercises - exercises = ExportExercisesService.new(@exercise,@ex_users) + @request_url = request.base_url + 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' diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 6ddbdce0c..fd72b5651 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -335,10 +335,8 @@ module ApplicationHelper end # 导出pdf时,转化markdown为html - def to_markdown(text) + def to_markdown(text,origin_url) return nil if text.blank? - request_url = "http://47.96.87.25:48080" - options = { :autolink => true, :no_intra_emphasis => true, @@ -350,8 +348,7 @@ module ApplicationHelper } markdown = Redcarpet::Markdown.new(Redcarpet::Render::HTML,options) m_t = markdown.render(text) - m_t&.include?("src=\"") ? m_t&.gsub("src=\"","src=\"#{request_url}") : m_t - Rails.logger.info("###########__________request_url_________###################{request_url}") + m_t&.include?("src=\"") ? m_t&.gsub("src=\"","src=\"#{origin_url}") : m_t end end diff --git a/app/services/exercise_user_pdf_service.rb b/app/services/exercise_user_pdf_service.rb index be048c4c2..9b96cd70c 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..0d2d8f3ce 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/blank_exercise.html.erb b/app/templates/exercise_export/blank_exercise.html.erb index 1dde00e56..153ba1514 100644 --- a/app/templates/exercise_export/blank_exercise.html.erb +++ b/app/templates/exercise_export/blank_exercise.html.erb @@ -68,12 +68,12 @@
<% if q.question_type == 5 %> - <%= to_markdown(q.shixun_name) %> + <%= to_markdown(q.shixun_name,@request_url) %>
- <%= to_markdown(q.question_title) %> + <%= to_markdown(q.question_title,@request_url) %>
<% else %> - <%= to_markdown(q.question_title) %> + <%= to_markdown(q.question_title,@request_url) %> <% end %>
@@ -81,14 +81,14 @@ <% q.exercise_choices.each do |s| %>
- <%= to_markdown(s.choice_text) %> + <%= to_markdown(s.choice_text,@request_url) %>
<% end %> <% elsif q.question_type == 1 %> <% q.exercise_choices.each do |s| %>
- <%= to_markdown(s.choice_text) %> + <%= to_markdown(s.choice_text,@request_url) %>
<% end %> <% elsif q.question_type == 2 %> diff --git a/app/templates/exercise_export/exercise_user.html.erb b/app/templates/exercise_export/exercise_user.html.erb index 3e92c5864..bb3723373 100644 --- a/app/templates/exercise_export/exercise_user.html.erb +++ b/app/templates/exercise_export/exercise_user.html.erb @@ -168,12 +168,12 @@
<% if q.question_type == 5 %> - <%= to_markdown(q.shixun_name) %> + <%= to_markdown(q.shixun_name,@request_url) %>
- <%= to_markdown(q.question_title) %> + <%= to_markdown(q.question_title,@request_url) %>
<% else %> - <%= to_markdown(q.question_title) %> + <%= to_markdown(q.question_title,@request_url) %> <% end %>
@@ -183,7 +183,7 @@ <% check_answer = (user_answer.present? && (s.id == user_answer.first.exercise_choice_id)) ? "choose-answer" : '' %>
- <%= to_markdown(s.choice_text) %> + <%= to_markdown(s.choice_text,@request_url) %>
<% end %> <% elsif q_type == 1 %> @@ -195,7 +195,7 @@ <% else %> <% end %> - <%= to_markdown(s.choice_text) %> + <%= to_markdown(s.choice_text,@request_url) %>
<% end %> <% elsif q_type == 2 %> @@ -335,7 +335,7 @@
- +

<%= ques_user.real_name %><%= ques_comment.first.updated_at.strftime('%Y-%m-%d %H:%M') %>

From 1e5db588192fe5b130c99589e3ae78719c83fce4 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Mon, 1 Jul 2019 14:38:24 +0800 Subject: [PATCH 18/19] fix bug --- app/services/exercise_user_pdf_service.rb | 2 +- app/services/export_exercises_service.rb | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/services/exercise_user_pdf_service.rb b/app/services/exercise_user_pdf_service.rb index 9b96cd70c..44ee1e769 100644 --- a/app/services/exercise_user_pdf_service.rb +++ b/app/services/exercise_user_pdf_service.rb @@ -3,7 +3,7 @@ class ExerciseUserPdfService include ApplicationHelper include StudentWorksHelper - attr_reader :exercise, :ex_user + attr_reader :exercise, :ex_user, :request_url def initialize(exercise, ex_user,request_url) @exercise = exercise diff --git a/app/services/export_exercises_service.rb b/app/services/export_exercises_service.rb index 0d2d8f3ce..f83323d7e 100644 --- a/app/services/export_exercises_service.rb +++ b/app/services/export_exercises_service.rb @@ -1,9 +1,9 @@ class ExportExercisesService include ExercisesHelper include StudentWorksHelper - attr_reader :exercise, :ex_users + attr_reader :exercise, :ex_users, :request_url - def initialize(exercise, ex_users,request_url) + def initialize(exercise, ex_users, request_url) @exercise = exercise @ex_users = ex_users @request_url = request_url @@ -19,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,request_url) + export = ExerciseUserPdfService.new(exercise, ex_user,@request_url) pdf = export.ex_pdf pdfs << pdf begin From e5cd38ed9007b5fe2338ef3da7cfa9ecaa100486 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Mon, 1 Jul 2019 14:39:46 +0800 Subject: [PATCH 19/19] =?UTF-8?q?=E8=AE=A1=E7=AE=97=E6=88=90=E7=BB=A9?= =?UTF-8?q?=E7=9A=84=E6=9D=83=E9=99=90=E6=8E=A7=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/homework_commons_controller.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/controllers/homework_commons_controller.rb b/app/controllers/homework_commons_controller.rb index f242f3438..545fbce85 100644 --- a/app/controllers/homework_commons_controller.rb +++ b/app/controllers/homework_commons_controller.rb @@ -12,7 +12,7 @@ class HomeworkCommonsController < ApplicationController :code_review_detail, :show_comment, :settings, :works_list, :update_settings, :reference_answer, :publish_groups, :end_groups, :alter_name, :update_explanation] before_action :user_course_identity - before_action :homework_publish, only: [:show, :works_list, :code_review_results, :show_comment, :settings, :reference_answer] + before_action :homework_publish, only: [:show, :works_list, :code_review_results, :show_comment, :settings, :reference_answer, :update_student_score] before_action :teacher_allowed, only: [:new, :edit, :create, :update, :shixuns, :subjects, :create_shixun_homework, :publish_homework, :end_homework, :set_public, :choose_category, :move_to_category, :choose_category, :create_subject_homework, :multi_destroy, :group_list, :homework_code_repeat, @@ -237,6 +237,7 @@ class HomeworkCommonsController < ApplicationController end def update_score + tip_exception("作业还未发布,暂不能计算成绩") if @homework.publish_time.nil? || @homework.publish_time > Time.now begin if @homework.unified_setting student_works = @homework.student_works