From 04bbbc7319175eb83c609454d226d54dd7358535 Mon Sep 17 00:00:00 2001 From: jingquan huang Date: Mon, 1 Jul 2019 09:49:48 +0800 Subject: [PATCH 01/20] =?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 6110df20bd10d12b72ad2c125c6377b12cb0f810 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Mon, 1 Jul 2019 10:38:47 +0800 Subject: [PATCH 02/20] fix bug --- app/helpers/application_helper.rb | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index cb2f487cb..df024264e 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -336,6 +336,8 @@ module ApplicationHelper def to_markdown(text) Rails.logger.info("#########################text______________tedxt_________________###{text}") + Rails.logger.info("#########################text______________request_base_url________________###{request.base_url}") + return nil if text.blank? options = { :autolink => true, @@ -347,10 +349,10 @@ module ApplicationHelper :tables => true } markdown = Redcarpet::Markdown.new(Redcarpet::Render::HTML,options) - ss = markdown.render(text) - Rails.logger.info("#########################text______________markdown.render(text)________________###{ss}") - ss - + m_t = markdown.render(text) + q_title = m_t &.include?("src=\"") ? m_t&.gsub("src=\"","src=\"#{@request_url}")&.html_safe : m_t + Rails.logger.info("#########################text______________markdown.render(text)________________###{q_title }") + q_title end end From b320715e6e9ff22b45cf5e742337b309a2f02ea7 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Mon, 1 Jul 2019 10:45:45 +0800 Subject: [PATCH 03/20] fix bug --- app/helpers/application_helper.rb | 9 ++++----- .../exercise_export/blank_exercise.html.erb | 14 ++++++-------- 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index df024264e..67e899820 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -335,8 +335,7 @@ module ApplicationHelper end def to_markdown(text) - Rails.logger.info("#########################text______________tedxt_________________###{text}") - Rails.logger.info("#########################text______________request_base_url________________###{request.base_url}") + request_url = request.base_url return nil if text.blank? options = { @@ -350,9 +349,9 @@ module ApplicationHelper } markdown = Redcarpet::Markdown.new(Redcarpet::Render::HTML,options) m_t = markdown.render(text) - q_title = m_t &.include?("src=\"") ? m_t&.gsub("src=\"","src=\"#{@request_url}")&.html_safe : m_t - Rails.logger.info("#########################text______________markdown.render(text)________________###{q_title }") - q_title + ss = m_t&.include?("src=\"") ? m_t&.gsub("src=\"","src=\"#{request_url}")&.html_safe : m_t + Rails.logger.info("############_____________ss________________##################{ss}") + ss end end diff --git a/app/templates/exercise_export/blank_exercise.html.erb b/app/templates/exercise_export/blank_exercise.html.erb index 63b7fb8bc..d562224da 100644 --- a/app/templates/exercise_export/blank_exercise.html.erb +++ b/app/templates/exercise_export/blank_exercise.html.erb @@ -69,16 +69,14 @@
<% q_markdown = to_markdown(q.question_title) %> - <% q_title = q_markdown&.include?("src=\"") ? q_markdown&.gsub("src=\"","src=\"#{@request_url}")&.html_safe : q_markdown %> <% if q.question_type == 5 %> <% q_markdown_name = to_markdown(q.shixun_name) %> - <% q_name = q_markdown_name&.include?("src=\"") ? q_markdown_name&.gsub("src=\"","src=\"#{@request_url}")&.html_safe : q_markdown_name %> - <%= q_name %> + <%= q_markdown_name %>
- <%= q_markdown %> + <%= q_markdown %>
<% else %> - <%= q_markdown %> + <%= q_markdown %> <% end %>
@@ -86,14 +84,14 @@ <% q.exercise_choices.each_with_index do |s,index| %>

- <%= convert_to_char((index+1).to_s)%><%= s.choice_text%> + <%= convert_to_char((index+1).to_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)%><%= s.choice_text%> + <%= convert_to_char((index+1).to_s)%><%= to_markdown(s.choice_text) %>

<% end %> <% elsif q.question_type == 2 %> @@ -101,7 +99,7 @@ <% q.exercise_choices.each_with_index do |s,index| %> - <%= s.choice_text %> + <%= to_markdown(s.choice_text) %> <% end %>

From fec939b098c167812f7b7f7bd55c11e13cf92115 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Mon, 1 Jul 2019 10:58:26 +0800 Subject: [PATCH 04/20] fix bug --- app/helpers/application_helper.rb | 2 +- app/templates/exercise_export/blank_exercise.html.erb | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 67e899820..fd5a8b233 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -349,7 +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}")&.html_safe : m_t + ss = m_t&.include?("src=\"") ? m_t&.gsub("src=\"","src=\"#{request_url}") : m_t Rails.logger.info("############_____________ss________________##################{ss}") ss end diff --git a/app/templates/exercise_export/blank_exercise.html.erb b/app/templates/exercise_export/blank_exercise.html.erb index d562224da..b43dc1923 100644 --- a/app/templates/exercise_export/blank_exercise.html.erb +++ b/app/templates/exercise_export/blank_exercise.html.erb @@ -68,6 +68,7 @@ (<%= q&.question_score %>分)
+ 电脑的电路图 <% q_markdown = to_markdown(q.question_title) %> <% if q.question_type == 5 %> <% q_markdown_name = to_markdown(q.shixun_name) %> @@ -84,14 +85,14 @@ <% q.exercise_choices.each_with_index do |s,index| %>

- <%= convert_to_char((index+1).to_s)%><%= to_markdown(s.choice_text) %> + <%= convert_to_char((index+1).to_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) %> + <%= convert_to_char((index+1).to_s)%><%= to_markdown(s.choice_text) %>

<% end %> <% elsif q.question_type == 2 %> @@ -99,7 +100,7 @@ <% q.exercise_choices.each_with_index do |s,index| %> - <%= to_markdown(s.choice_text) %> + <%= to_markdown(s.choice_text) %> <% end %>

From decedbe354ac222e9a90a9e3884cc3e6971b19ad Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Mon, 1 Jul 2019 11:28:42 +0800 Subject: [PATCH 05/20] fix bug --- app/templates/exercise_export/blank_exercise.html.erb | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/app/templates/exercise_export/blank_exercise.html.erb b/app/templates/exercise_export/blank_exercise.html.erb index b43dc1923..9ee1d40f7 100644 --- a/app/templates/exercise_export/blank_exercise.html.erb +++ b/app/templates/exercise_export/blank_exercise.html.erb @@ -69,6 +69,7 @@
电脑的电路图 + udasker_picture <% q_markdown = to_markdown(q.question_title) %> <% if q.question_type == 5 %> <% q_markdown_name = to_markdown(q.shixun_name) %> @@ -85,14 +86,16 @@ <% q.exercise_choices.each_with_index do |s,index| %>

- <%= convert_to_char((index+1).to_s)%><%= to_markdown(s.choice_text) %> + <%= convert_to_char((index+1).to_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) %> + <%= convert_to_char((index+1).to_s)%> + <%= to_markdown(s.choice_text) %>

<% end %> <% elsif q.question_type == 2 %> From 4d2943973fc156ee5c51352e72b3b2222e3c2252 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Mon, 1 Jul 2019 11:31:17 +0800 Subject: [PATCH 06/20] =?UTF-8?q?=E5=AE=9E=E8=AE=AD=E6=9C=8D=E5=8A=A1?= =?UTF-8?q?=E5=99=A8=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/shixuns_controller.rb | 27 +++++++++++------------- app/models/shixun.rb | 2 ++ app/views/shixuns/settings.json.jbuilder | 8 +++++++ 3 files changed, 22 insertions(+), 15 deletions(-) diff --git a/app/controllers/shixuns_controller.rb b/app/controllers/shixuns_controller.rb index f079aed1e..5631d03a7 100644 --- a/app/controllers/shixuns_controller.rb +++ b/app/controllers/shixuns_controller.rb @@ -367,11 +367,6 @@ class ShixunsController < ApplicationController end def update - h = {test_set_permission: params[:test_set_permission], code_hidden: params[:code_hidden], - task_pass: params[:task_pass], hide_code: params[:hide_code], forbid_copy: params[:forbid_copy]} - - s_params = shixun_params.merge(h) - ActiveRecord::Base.transaction do begin @shixun.shixun_mirror_repositories.destroy_all @@ -384,8 +379,8 @@ class ShixunsController < ApplicationController end end - @shixun.update_attributes(s_params) - @shixun.shixun_info.update_attributes(description: params[:description], evaluate_script: params[:evaluate_script]) + @shixun.update_attributes(shixun_params) + @shixun.shixun_info.update_attributes(shixun_info_params) @shixun.shixun_schools.delete_all if params[:scope_partment].present? && params[:user_scope].to_i == 1 arr = [] @@ -402,13 +397,8 @@ class ShixunsController < ApplicationController # 超级管理员和运营人员才能保存 中间层服务器pod信息的配置 if current_user.admin? || current_user.business? @shixun.shixun_service_configs.destroy_all - params[:mirror_id].each_with_index do |mirror_id, index| - ShixunServiceConfig.create!(:shixun_id => @shixun.id, - :cpu_limit => params[:cpu_limit][index], - :lower_cpu_limit => params[:lower_cpu_limit][index], - :memory_limit => params[:memory_limit][index], - :request_limit => params[:request_limit][index], - :mirror_repository_id => mirror_id) + params[:shixun_service_configs].each do |config| + @shixun.shixun_service_configs.create!(config) end end rescue Exception => e @@ -446,6 +436,7 @@ class ShixunsController < ApplicationController @choice_small_type = @shixun.small_mirror_id @main_type = shixun_main_type @small_type = shixun_small_type + @configs = @shixun.shixun_service_configs #@mirror_script = MirrorScript.select([:id, :script_type]).find(@shixun.mirror_script_id).attributes if @shixun.mirror_script_id && @shixun.mirror_script_id != 0 # @shixun_main_mirror = @shixun.show_shixun_mirror # @script_type = @shixun.script_tag.try(:script_type) || "无" @@ -734,7 +725,13 @@ private def shixun_params raise("实训名称不能为空") if params[:name].blank? params.require(:shixun).permit(:name, :trainee, :webssh, :can_copy, :use_scope, :vnc, :test_set_permission, - :task_pass, :repo_name, :multi_webssh, :opening_time, :mirror_script_id) + :task_pass, :repo_name, :multi_webssh, :opening_time, :mirror_script_id, :code_hidden, + :hide_code, :forbid_copy) + end + def shixun_info_params + raise("实训描述不能为空") if params[:description].blank? + raise("评测脚本不能为空") if params[:evaluate_script].blank? + params.require(:shixun_info).permit(:description, :evaluate_script) end def find_shixun diff --git a/app/models/shixun.rb b/app/models/shixun.rb index 18d5c5fae..c4345f90a 100644 --- a/app/models/shixun.rb +++ b/app/models/shixun.rb @@ -1,5 +1,7 @@ class Shixun < ApplicationRecord # status: 0:编辑 1:申请发布 2:正式发布 3:关闭 -1:软删除 + # hide_code: 隐藏代码窗口 + # code_hidden: 隐藏代码目录 has_many :challenges, dependent: :destroy has_many :myshixuns, :dependent => :destroy has_many :shixun_members, dependent: :destroy diff --git a/app/views/shixuns/settings.json.jbuilder b/app/views/shixuns/settings.json.jbuilder index e97331388..ed7d93039 100644 --- a/app/views/shixuns/settings.json.jbuilder +++ b/app/views/shixuns/settings.json.jbuilder @@ -29,6 +29,14 @@ json.shixun do json.scope_partment @shixun.schools.map(&:name) # 公开范围 json.opening_time @shixun.opening_time json.forbid_copy @shixun.forbid_copy + + # 实训服务配置 + json.shixun_service_configs do + json.array! @configs do |config| + json.name config.mirror_repository&.name + json.(config, :cpu_limit, :lower_cpu_limit, :memory_limit, :request_limit, :mirror_repository_id) + end + end end From 029aac355491a4ee5a44823ea0cc55875719dab4 Mon Sep 17 00:00:00 2001 From: jasder Date: Mon, 1 Jul 2019 11:35:27 +0800 Subject: [PATCH 07/20] FIX delete message permission --- app/controllers/messages_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/messages_controller.rb b/app/controllers/messages_controller.rb index bad54b88e..f684b27f3 100644 --- a/app/controllers/messages_controller.rb +++ b/app/controllers/messages_controller.rb @@ -128,7 +128,7 @@ class MessagesController < ApplicationController def destroy begin - return normal_status(403, "您没有权限进行该操作") unless @message.author == current_user || current_user.teacher_of_course?(@message.board.course) + return normal_status(403, "您没有权限进行该操作") if current_user.course_identity(@message.board.course) >= 5 || @message.author != current_user @message.destroy! rescue Exception => e uid_logger_error(e.message) From 4a257c29603b67ab17d2d59f66b6ba2ce580e172 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Mon, 1 Jul 2019 12:24:00 +0800 Subject: [PATCH 08/20] 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 09/20] 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 10/20] 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 11/20] 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 12/20] 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 13/20] 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 14/20] =?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 15/20] =?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 16/20] 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 17/20] 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 18/20] 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 19/20] =?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 20/20] 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 %>