From a76088fe30a77e1883f634348c9979080838dc39 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Sat, 22 Jun 2019 14:04:45 +0800 Subject: [PATCH 01/37] fix bug --- app/controllers/exercise_questions_controller.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/controllers/exercise_questions_controller.rb b/app/controllers/exercise_questions_controller.rb index 9e3259e6e..a0b88a97e 100644 --- a/app/controllers/exercise_questions_controller.rb +++ b/app/controllers/exercise_questions_controller.rb @@ -480,7 +480,7 @@ class ExerciseQuestionsController < ApplicationController ex_answers = @exercise_question.exercise_answers.search_answer_users("user_id",@user_id) #当前用户答案的得分 if @exercise_question.question_type == 3 #当为填空题,更新问题的总分, ex_answer_old = ex_answers.score_reviewed.pluck(:score).sum #每一关的得分总和 - each_right_score = (@c_score / ex_answers.count.to_f).round(1) #调分后,平均每关的分数 + each_right_score = (@c_score / ex_answers.count.to_f) #调分后,平均每关的分数 new_obj_score = ex_obj_score - ex_answer_old + @c_score total_scores = new_obj_score + ex_subj_score ex_scores = { @@ -615,7 +615,7 @@ class ExerciseQuestionsController < ApplicationController normal_status(-1,"题目不允许为空!") if (params[:question_title].blank? && params[:question_type].to_i !=5 ) #除了实训题,其余题目必需有题干 normal_status(-1,"问题类型不允许为空!" ) if params[:question_type].blank? normal_status(-1,"分值不允许为空!" ) if params[:question_score].blank? && params[:question_scores].blank? #分值的数组或参数必需存在一个 - if params[:question_score].present? && params[:question_score].to_f.round(1) <= 0.0 #问题类型存在,则分值不能为空,且必需大于0 + if params[:question_score].present? && params[:question_score].to_f <= 0.0 #问题类型存在,则分值不能为空,且必需大于0 normal_status(-1,"分值必需大于0!") elsif (params[:question_score].present? && params[:question_score].to_f.round(1) > 100.0) || (params[:question_scores].present? && (params[:question_scores].map{|a| a.to_f.round(1)}.max > 100.0)) normal_status(-1,"分值不能超过100分!") @@ -677,7 +677,7 @@ class ExerciseQuestionsController < ApplicationController end def check_adjust_score - @c_score = params[:score].to_f.round(1) #调分后的分数 + @c_score = params[:score].to_f #调分后的分数 @user_id = params[:user_id] @exercise_current_user = @exercise.exercise_users.exercise_commit_users(@user_id).first #当前试卷用户的答案内容 if @exercise_current_user.blank? From 19617532734469ddd05feb48e1b152c8a350a818 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Sat, 22 Jun 2019 14:37:01 +0800 Subject: [PATCH 02/37] fix bug --- app/helpers/export_helper.rb | 2 +- .../exercise_export/blank_exercise.html.erb | 10 +++++----- .../exercise_export/exercise_export.css | 3 +++ .../exercise_export/exercise_user.html.erb | 16 ++++++++-------- 4 files changed, 17 insertions(+), 14 deletions(-) diff --git a/app/helpers/export_helper.rb b/app/helpers/export_helper.rb index a5e3c5d9d..918995bef 100644 --- a/app/helpers/export_helper.rb +++ b/app/helpers/export_helper.rb @@ -245,7 +245,7 @@ module ExportHelper else user_course = "--" end - user_obj_score = e_user.objective_score < 0.0 ? 0.0 : e_user.subjective_score.round(1).to_s + user_obj_score = e_user.objective_score < 0.0 ? 0.0 : e_user.objective_score.round(1).to_s user_suj_score = e_user.subjective_score < 0.0 ? 0.0 : e_user.subjective_score.round(1).to_s user_score = e_user.score.present? ? e_user.score.round(1).to_s : 0.0 if e_user.commit_status.present? && e_user.commit_status == 1 diff --git a/app/templates/exercise_export/blank_exercise.html.erb b/app/templates/exercise_export/blank_exercise.html.erb index 61bde0d27..123e114b1 100644 --- a/app/templates/exercise_export/blank_exercise.html.erb +++ b/app/templates/exercise_export/blank_exercise.html.erb @@ -13,13 +13,13 @@

- <%= @exercise.try(:exercise_description).nil? ? "" : @exercise.try(:exercise_description).html_safe %> + <%= @exercise.try(:exercise_description).nil? ? "" : @exercise.try(:exercise_description)&.html_safe %>

-
+
<% if @exercise_single_ques_count > 0 %> 单选题<%= @exercise_single_ques_count %>题, 共<%= @exercise_single_ques_scores %> @@ -63,12 +63,12 @@
<% if q.question_type == 5 %> - <%= q.shixun_name.present? ? q.shixun_name.html_safe : "" %> + <%= q.shixun_name.present? ? q.shixun_name&.html_safe : "" %>
- <%= q.question_title.present? ? q.question_title.html_safe : "" %> + <%= q.question_title.present? ? q.question_title&.html_safe : "" %>
<% else %> - <%= q.question_title.present? ? q.question_title.html_safe : "" %> + <%= q.question_title.present? ? q.question_title&.html_safe : "" %> <% end %>
diff --git a/app/templates/exercise_export/exercise_export.css b/app/templates/exercise_export/exercise_export.css index 91f25e45e..4747e9eed 100644 --- a/app/templates/exercise_export/exercise_export.css +++ b/app/templates/exercise_export/exercise_export.css @@ -303,6 +303,9 @@ textarea{ background-color:#eee; line-height:2; } +.max-100{ + max-width:100%; +} diff --git a/app/templates/exercise_export/exercise_user.html.erb b/app/templates/exercise_export/exercise_user.html.erb index 713f09ee4..67aaf493a 100644 --- a/app/templates/exercise_export/exercise_user.html.erb +++ b/app/templates/exercise_export/exercise_user.html.erb @@ -13,13 +13,13 @@

- <%= @exercise.try(:exercise_description).nil? ? "" : @exercise.try(:exercise_description).html_safe %> + <%= @exercise.try(:exercise_description).nil? ? "" : @exercise.try(:exercise_description)&.html_safe %>

-
+
<% if @exercise_single_ques_count > 0 %> 单选题<%= @exercise_single_ques_count %>题, 共<%= @exercise_single_ques_scores %> @@ -162,14 +162,14 @@
<% if q_type == 5 %> - <%= q.shixun_name.html_safe %> + <%= q.shixun_name&.html_safe %>
- <%= q.question_title.html_safe %> + <%= q.question_title&.html_safe %>
<% elsif q_type == 4 %> - <%= q.question_title.html_safe %> + <%= q.question_title&.html_safe %> <% else %> - <%= q.question_title.html_safe %> + <%= q.question_title&.html_safe %> <% end %>
@@ -218,13 +218,13 @@ <% end %>

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

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

- <%= check_answer.html_safe %> + <%= check_answer&.html_safe %>

<% else %>
From 152fcd9bc454d850ccd31e1dea392f9a5abd652c Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Sat, 22 Jun 2019 14:49:57 +0800 Subject: [PATCH 03/37] fix bug --- app/controllers/homework_commons_controller.rb | 13 +++++++++---- .../exercise_export/blank_exercise.html.erb | 2 +- app/templates/exercise_export/exercise_export.css | 4 ++++ 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/app/controllers/homework_commons_controller.rb b/app/controllers/homework_commons_controller.rb index ec3f0ab9a..5e8f7b67e 100644 --- a/app/controllers/homework_commons_controller.rb +++ b/app/controllers/homework_commons_controller.rb @@ -200,10 +200,15 @@ class HomeworkCommonsController < ApplicationController if @user_course_identity >= Course::STUDENT tip_exception(403, "无权限操作") else - student_work_to_xlsx(@work_excel,@homework) - exercise_export_name = current_user.real_name + "_" + @course.name + "_" + @homework.name + "_" + Time.now.strftime('%Y%m%d_%H%M%S') - render xlsx: "#{exercise_export_name.strip.first(30)}",template: "homework_commons/works_list.xlsx.axlsx",locals: - {table_columns: @work_head_cells,task_users: @work_cells_column} + if @work_excel.size > 0 + student_work_to_xlsx(@work_excel,@homework) + exercise_export_name = current_user.real_name + "_" + @course.name + "_" + @homework.name + "_" + Time.now.strftime('%Y%m%d_%H%M%S') + render xlsx: "#{exercise_export_name.strip.first(30)}",template: "homework_commons/works_list.xlsx.axlsx",locals: + {table_columns: @work_head_cells,task_users: @work_cells_column} + else + normal_status(-1,"暂无提交的学生!") + end + end } format.zip{ diff --git a/app/templates/exercise_export/blank_exercise.html.erb b/app/templates/exercise_export/blank_exercise.html.erb index 123e114b1..53466929d 100644 --- a/app/templates/exercise_export/blank_exercise.html.erb +++ b/app/templates/exercise_export/blank_exercise.html.erb @@ -18,7 +18,7 @@
-
+
<% if @exercise_single_ques_count > 0 %> 单选题<%= @exercise_single_ques_count %>题, diff --git a/app/templates/exercise_export/exercise_export.css b/app/templates/exercise_export/exercise_export.css index 4747e9eed..454bb1c26 100644 --- a/app/templates/exercise_export/exercise_export.css +++ b/app/templates/exercise_export/exercise_export.css @@ -306,6 +306,10 @@ textarea{ .max-100{ max-width:100%; } +.width100{ + width:100%; + word-break:normal; +} From 218020fdcadca69d8b2b238d39bd8b758c679f9d Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Sat, 22 Jun 2019 14:52:52 +0800 Subject: [PATCH 04/37] fix bug --- app/controllers/homework_commons_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/homework_commons_controller.rb b/app/controllers/homework_commons_controller.rb index 5e8f7b67e..a9843a5cc 100644 --- a/app/controllers/homework_commons_controller.rb +++ b/app/controllers/homework_commons_controller.rb @@ -200,7 +200,7 @@ class HomeworkCommonsController < ApplicationController if @user_course_identity >= Course::STUDENT tip_exception(403, "无权限操作") else - if @work_excel.size > 0 + if @work_excel.present? student_work_to_xlsx(@work_excel,@homework) exercise_export_name = current_user.real_name + "_" + @course.name + "_" + @homework.name + "_" + Time.now.strftime('%Y%m%d_%H%M%S') render xlsx: "#{exercise_export_name.strip.first(30)}",template: "homework_commons/works_list.xlsx.axlsx",locals: From 3b68ce2474a778cbc4458f1f25f6ee85245adc55 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Sat, 22 Jun 2019 15:07:06 +0800 Subject: [PATCH 05/37] fix bug --- config/initializers/pdfkit.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/config/initializers/pdfkit.rb b/config/initializers/pdfkit.rb index 168fc0c1e..bb562f473 100644 --- a/config/initializers/pdfkit.rb +++ b/config/initializers/pdfkit.rb @@ -6,8 +6,9 @@ PDFKit.configure do |config| dpi: 300, debug_javascript: true, javascript_delay: 500, - stop_slow_scripts:false, - no_stop_slow_scripts: true + quiet: false + # stop_slow_scripts:false, + # no_stop_slow_scripts: true } end From cf5e40b97f2d35c46ced9d3fec2a09667379a589 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Sat, 22 Jun 2019 15:29:11 +0800 Subject: [PATCH 06/37] fix but --- app/templates/exercise_export/blank_exercise.html.erb | 4 ++-- config/initializers/pdfkit.rb | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/templates/exercise_export/blank_exercise.html.erb b/app/templates/exercise_export/blank_exercise.html.erb index 53466929d..9028139cb 100644 --- a/app/templates/exercise_export/blank_exercise.html.erb +++ b/app/templates/exercise_export/blank_exercise.html.erb @@ -19,7 +19,7 @@
-
+
<% if @exercise_single_ques_count > 0 %> 单选题<%= @exercise_single_ques_count %>题, 共<%= @exercise_single_ques_scores %> @@ -45,7 +45,7 @@ 共<%= @exercise_ques_shixun_scores %>分 <% end %>
-
合计<%= @exercise_ques_count %>题, +
合计<%= @exercise_ques_count %>题, 共<%= @exercise_ques_scores %>
diff --git a/config/initializers/pdfkit.rb b/config/initializers/pdfkit.rb index bb562f473..36ff30963 100644 --- a/config/initializers/pdfkit.rb +++ b/config/initializers/pdfkit.rb @@ -6,9 +6,9 @@ PDFKit.configure do |config| dpi: 300, debug_javascript: true, javascript_delay: 500, - quiet: false - # stop_slow_scripts:false, - # no_stop_slow_scripts: true + # quiet: false + stop_slow_scripts:false, + no_stop_slow_scripts: true } end From 8f3584733e062c98da1074ac910a4bbc9b7bb976 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Sat, 22 Jun 2019 15:49:11 +0800 Subject: [PATCH 07/37] =?UTF-8?q?=E9=98=BF=E9=87=8C=E4=BA=91=E7=89=88?= =?UTF-8?q?=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/shixuns/_top.json.jbuilder | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/shixuns/_top.json.jbuilder b/app/views/shixuns/_top.json.jbuilder index ef15e2515..ebb77ec74 100644 --- a/app/views/shixuns/_top.json.jbuilder +++ b/app/views/shixuns/_top.json.jbuilder @@ -1,4 +1,4 @@ -json.status shixun.status +json.shixun_status shixun.status # REDO:前端需要通过status来判断发布 json.task_operation task_operation_url(current_myshixun, shixun) From 4e0f9b4842c4c7273563958341e1df5db3bea7b4 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Sat, 22 Jun 2019 16:00:38 +0800 Subject: [PATCH 08/37] fix bug --- .../exercise_export/blank_exercise.html.erb | 18 +- .../exercise_export/exercise_export.css | 9 +- .../exercise_export/exercise_user.html.erb | 17 +- public/123.html | 366 ++++++++++++++++++ 4 files changed, 392 insertions(+), 18 deletions(-) diff --git a/app/templates/exercise_export/blank_exercise.html.erb b/app/templates/exercise_export/blank_exercise.html.erb index 9028139cb..2745f8cbe 100644 --- a/app/templates/exercise_export/blank_exercise.html.erb +++ b/app/templates/exercise_export/blank_exercise.html.erb @@ -18,8 +18,8 @@
-
-
+
+

<% if @exercise_single_ques_count > 0 %> 单选题<%= @exercise_single_ques_count %>题, 共<%= @exercise_single_ques_scores %> @@ -44,10 +44,16 @@ 实训题<%= @exercise_ques_shixun_count %>题, 共<%= @exercise_ques_shixun_scores %> <% end %> -

-
合计<%= @exercise_ques_count %>题, - 共<%= @exercise_ques_scores %>分 -
+ + <% if @exercise_ques_count > 0 %> + + 共<%= @exercise_ques_scores %>分 + + + 合计<%= @exercise_ques_count %>题 + + <% end %> +

diff --git a/app/templates/exercise_export/exercise_export.css b/app/templates/exercise_export/exercise_export.css index 454bb1c26..884a49af0 100644 --- a/app/templates/exercise_export/exercise_export.css +++ b/app/templates/exercise_export/exercise_export.css @@ -303,12 +303,9 @@ textarea{ background-color:#eee; line-height:2; } -.max-100{ - max-width:100%; -} -.width100{ - width:100%; - word-break:normal; +.clearfix{ + clear:both; + zoom:1; } diff --git a/app/templates/exercise_export/exercise_user.html.erb b/app/templates/exercise_export/exercise_user.html.erb index 67aaf493a..088ff1fd4 100644 --- a/app/templates/exercise_export/exercise_user.html.erb +++ b/app/templates/exercise_export/exercise_user.html.erb @@ -19,7 +19,7 @@
-
+

<% if @exercise_single_ques_count > 0 %> 单选题<%= @exercise_single_ques_count %>题, 共<%= @exercise_single_ques_scores %> @@ -44,11 +44,16 @@ 实训题<%= @exercise_ques_shixun_count %>题, 共<%= @exercise_ques_shixun_scores %> <% end %> -

-
- 合计<%= @exercise_ques_count %>题, - 共<%= @exercise_ques_scores %>分 -
+ + <% if @exercise_ques_count > 0 %> + + 共<%= @exercise_ques_scores %>分 + + + 合计<%= @exercise_ques_count %>题 + + <% end %> +

diff --git a/public/123.html b/public/123.html index e69de29bb..8986880e5 100644 --- a/public/123.html +++ b/public/123.html @@ -0,0 +1,366 @@ + + + + + + + + + +
+
+

+ + 单选题5题,共10分 + + + 单选题5题,共10分 + + + 单选题5题,共10分 + + + 单选题5题,共10分 + + + 共10分 + + + 合计20题 + + + +

+ + + + + + + +
+
+ + + \ No newline at end of file From 8e3af838907ee42d74bd0809ca99f2f75a3ae43d Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Sat, 22 Jun 2019 16:06:47 +0800 Subject: [PATCH 09/37] =?UTF-8?q?=E9=85=8D=E7=BD=AE=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/environments/production.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/config/environments/production.rb b/config/environments/production.rb index c3950f345..be2bdf3d7 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -96,7 +96,8 @@ Rails.application.configure do config.active_record.belongs_to_required_by_default = false # config.cache_store = :file_store, "#{Rails.root }/files/cache_store/" - config.cache_store = :redis_store, 'redis://r-bp122bd1b710f274.redis.rds.aliyuncs.com:6379/0/cache', { expires_in: 90.minutes } + #config.cache_store = :redis_store, 'redis://r-bp122bd1b710f274.redis.rds.aliyuncs.com:6379/0/cache', { expires_in: 90.minutes } + config.cache_store = :redis_store, 'redis://10.9.72.102:6379/0/cache', { expires_in: 90.minutes } config.action_mailer.delivery_method = :smtp config.action_mailer.smtp_settings = { From 73d9a633e9d13ac2f2f782e19ee3b8f740beb7de Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Sat, 22 Jun 2019 16:17:44 +0800 Subject: [PATCH 10/37] fix bug --- app/controllers/zips_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/zips_controller.rb b/app/controllers/zips_controller.rb index 89f473499..f0ab50001 100644 --- a/app/controllers/zips_controller.rb +++ b/app/controllers/zips_controller.rb @@ -46,7 +46,7 @@ class ZipsController < ApplicationController else @course = @exercise.course - default_ex_users = @exercise.all_exercise_users(current_user.id).exercise_user_committed + default_ex_users = @exercise.all_exercise_users(current_user.id).exercise_user_committed.limit 2 default_ex_users_size = default_ex_users.size @ex_users = default_ex_users #仅导出已提交的,截止后则是全部为提交的。 #可以分班选择 From 2fa4e118feade84bf0a5a397db170f3ed2dc3431 Mon Sep 17 00:00:00 2001 From: jingquan huang Date: Sat, 22 Jun 2019 16:33:17 +0800 Subject: [PATCH 11/37] =?UTF-8?q?git=20=E6=8F=90=E4=BA=A4=E8=AE=B0?= =?UTF-8?q?=E5=BD=95=E6=B2=A1=E5=AE=9A=E4=BD=8D=E5=88=B0=E5=85=B7=E4=BD=93?= =?UTF-8?q?=E7=94=A8=E6=88=B7=E7=9A=84=E6=97=B6=E5=80=99=E5=A4=84=E7=90=86?= =?UTF-8?q?=E6=96=B9=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/shixuns/_commit.json.jbuilder | 1 + 1 file changed, 1 insertion(+) diff --git a/app/views/shixuns/_commit.json.jbuilder b/app/views/shixuns/_commit.json.jbuilder index cd934baea..b752affb6 100644 --- a/app/views/shixuns/_commit.json.jbuilder +++ b/app/views/shixuns/_commit.json.jbuilder @@ -14,6 +14,7 @@ json.commits commits do |commit| json.author do json.id nil json.login nil + json.image_url "avatars/User/b" json.name commit["author_name"] json.email commit["author_email"] end From 5f0f16e1d8400aefe3f986c5407d7c5729ea0466 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Sat, 22 Jun 2019 16:43:04 +0800 Subject: [PATCH 12/37] fix b ug --- config/initializers/pdfkit.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/config/initializers/pdfkit.rb b/config/initializers/pdfkit.rb index 36ff30963..556076f4b 100644 --- a/config/initializers/pdfkit.rb +++ b/config/initializers/pdfkit.rb @@ -1,5 +1,6 @@ PDFKit.configure do |config| - config.wkhtmltopdf = ENV["WKHTMLTOPDF_EXEC"] || 'wkhtmltopdf' + # config.wkhtmltopdf = ENV["WKHTMLTOPDF_EXEC"] || 'wkhtmltopdf' + config.wkhtmltopdf = ENV["WKHTMLTOPDF_EXEC"] || '/usr/bin/wkhtmltopdf' config.default_options = { page_size: 'A4', print_media_type: true, From e10a29306d7c78ef0c94d5e766ad1ae95219cb47 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Sat, 22 Jun 2019 16:44:57 +0800 Subject: [PATCH 13/37] =?UTF-8?q?=E6=B2=A1=E6=9C=89=E5=88=86=E7=8F=AD?= =?UTF-8?q?=E7=9A=84=E8=AF=BE=E5=A0=82=E4=B8=8D=E6=98=BE=E7=A4=BA=E6=9C=AA?= =?UTF-8?q?=E5=88=86=E7=8F=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/helpers/courses_helper.rb | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/app/helpers/courses_helper.rb b/app/helpers/courses_helper.rb index 8c88f02d0..a56eb27a6 100644 --- a/app/helpers/courses_helper.rb +++ b/app/helpers/courses_helper.rb @@ -246,15 +246,17 @@ module CoursesHelper def left_group_info course group_info = [] - course.course_groups.each do |course_group| - group_info << {category_id: course_group.id, category_name: course_group.name, position: course_group.position, - category_count: course_group.course_members_count, category_type: false, - second_category_url: "/courses/#{@course.id}/course_groups/#{course_group.id}"} + if course.course_groups_count > 0 + course.course_groups.each do |course_group| + group_info << {category_id: course_group.id, category_name: course_group.name, position: course_group.position, + category_count: course_group.course_members_count, category_type: false, + second_category_url: "/courses/#{@course.id}/course_groups/#{course_group.id}"} + end + none_group_count = course.students.where(course_group_id: 0).size + group_info << {category_id: 0, category_name: "未分班", position: course.course_groups.pluck(:position).max.to_i + 1, + category_count: none_group_count, category_type: false, + second_category_url: "/courses/#{@course.id}/course_groups/0"} end - none_group_count = course.students.where(course_group_id: 0).size - group_info << {category_id: 0, category_name: "未分班", position: course.course_groups.pluck(:position).max.to_i + 1, - category_count: none_group_count, category_type: false, - second_category_url: "/courses/#{@course.id}/course_groups/0"} end end From f4503cc467a43b2e1074bb060d613808466fb161 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Sat, 22 Jun 2019 16:47:53 +0800 Subject: [PATCH 14/37] =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/helpers/courses_helper.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/helpers/courses_helper.rb b/app/helpers/courses_helper.rb index a56eb27a6..226a45570 100644 --- a/app/helpers/courses_helper.rb +++ b/app/helpers/courses_helper.rb @@ -257,6 +257,7 @@ module CoursesHelper category_count: none_group_count, category_type: false, second_category_url: "/courses/#{@course.id}/course_groups/0"} end + group_info end end From 08861416f2f1c7fdad04bf4e00be6781d321d874 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Sat, 22 Jun 2019 16:52:28 +0800 Subject: [PATCH 15/37] =?UTF-8?q?TPI=E5=A4=B4=E5=83=8F=E7=82=B9=E5=87=BB?= =?UTF-8?q?=E8=B7=B3=E8=BD=AC=E6=9C=89=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/users/_user.json.jbuilder | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/users/_user.json.jbuilder b/app/views/users/_user.json.jbuilder index 1d26506f3..8c5f58265 100644 --- a/app/views/users/_user.json.jbuilder +++ b/app/views/users/_user.json.jbuilder @@ -4,5 +4,5 @@ json.name user.full_name json.grade user.grade # json.email user.mail # 邮箱原则上不暴露的,如果实在需要的话只能对某些具体的接口公开 json.image_url url_to_avatar(user) -json.user_url user_path(user) +json.user_url "/users/#{user.login}" json.school user.school_name \ No newline at end of file From db67ed37fadf7751851e41e54193fe974e8ed45c Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Sat, 22 Jun 2019 16:54:55 +0800 Subject: [PATCH 16/37] =?UTF-8?q?=E5=88=A0=E9=99=A4tpi=E7=9A=84user=5Furl?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/users/_user.json.jbuilder | 1 - 1 file changed, 1 deletion(-) diff --git a/app/views/users/_user.json.jbuilder b/app/views/users/_user.json.jbuilder index 8c5f58265..afec979a1 100644 --- a/app/views/users/_user.json.jbuilder +++ b/app/views/users/_user.json.jbuilder @@ -4,5 +4,4 @@ json.name user.full_name json.grade user.grade # json.email user.mail # 邮箱原则上不暴露的,如果实在需要的话只能对某些具体的接口公开 json.image_url url_to_avatar(user) -json.user_url "/users/#{user.login}" json.school user.school_name \ No newline at end of file From 66c2f52f4896491dee0e3985a005bc995003ab3f Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Sat, 22 Jun 2019 16:56:47 +0800 Subject: [PATCH 17/37] =?UTF-8?q?user.jbuider=E8=BF=98=E6=98=AF=E9=9C=80?= =?UTF-8?q?=E8=A6=81user=5Furl=E4=BA=86=EF=BC=8C=E5=A4=AA=E5=A4=9A?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E8=B0=83=E7=94=A8=E5=89=8D=E7=AB=AF=E6=94=B9?= =?UTF-8?q?=E7=9A=84=E5=A4=AA=E9=BA=BB=E7=83=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/users/_user.json.jbuilder | 1 + 1 file changed, 1 insertion(+) diff --git a/app/views/users/_user.json.jbuilder b/app/views/users/_user.json.jbuilder index afec979a1..8c5f58265 100644 --- a/app/views/users/_user.json.jbuilder +++ b/app/views/users/_user.json.jbuilder @@ -4,4 +4,5 @@ json.name user.full_name json.grade user.grade # json.email user.mail # 邮箱原则上不暴露的,如果实在需要的话只能对某些具体的接口公开 json.image_url url_to_avatar(user) +json.user_url "/users/#{user.login}" json.school user.school_name \ No newline at end of file From 8fce13d83aaacb289543344faf6b2167881c5d18 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Sat, 22 Jun 2019 16:58:01 +0800 Subject: [PATCH 18/37] fix bug --- app/controllers/zips_controller.rb | 7 ++++--- config/initializers/pdfkit.rb | 5 +++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/app/controllers/zips_controller.rb b/app/controllers/zips_controller.rb index f0ab50001..41407f876 100644 --- a/app/controllers/zips_controller.rb +++ b/app/controllers/zips_controller.rb @@ -20,6 +20,7 @@ class ZipsController < ApplicationController exercises = ExportExercisesService.new(@exercise,@ex_users) file_name = filename_for_content_disposition(exercises.filename) + logger.info("##################_______________________file_name_____________________############{file_name}") send_file exercises.ex_zip, filename: file_name, type: 'application/zip' rescue Exception => e normal_status(-1, e.message) @@ -39,14 +40,14 @@ class ZipsController < ApplicationController def get_exercise ActiveRecord::Base.transaction do begin - @exercise = Exercise.find_by(id:params[:exercise_id]) + @exercise = Exercise.find_by(id:params[:exercise_id]).includes(:exercise_users) group_id = params[:exercise_group_id] if @exercise.blank? normal_status(-1,"试卷不存在") else - @course = @exercise.course + @course = @exercise.course.includes(:course_members) - default_ex_users = @exercise.all_exercise_users(current_user.id).exercise_user_committed.limit 2 + 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 #仅导出已提交的,截止后则是全部为提交的。 #可以分班选择 diff --git a/config/initializers/pdfkit.rb b/config/initializers/pdfkit.rb index 556076f4b..0cd80c9c7 100644 --- a/config/initializers/pdfkit.rb +++ b/config/initializers/pdfkit.rb @@ -1,7 +1,8 @@ PDFKit.configure do |config| - # config.wkhtmltopdf = ENV["WKHTMLTOPDF_EXEC"] || 'wkhtmltopdf' - config.wkhtmltopdf = ENV["WKHTMLTOPDF_EXEC"] || '/usr/bin/wkhtmltopdf' + config.wkhtmltopdf = ENV["WKHTMLTOPDF_EXEC"] || 'wkhtmltopdf' + # config.wkhtmltopdf = ENV["WKHTMLTOPDF_EXEC"] || '/usr/bin/wkhtmltopdf' config.default_options = { + encoding: "UTF-8", page_size: 'A4', print_media_type: true, dpi: 300, From d335f9315e20b51910032d3ae160d8a41dc71907 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Sat, 22 Jun 2019 16:59:32 +0800 Subject: [PATCH 19/37] =?UTF-8?q?tpi=E6=8E=A5=E5=8F=A3=E5=8E=BB=E9=99=A4us?= =?UTF-8?q?er=5Furl?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/users/_user.json.jbuilder | 1 - 1 file changed, 1 deletion(-) diff --git a/app/views/users/_user.json.jbuilder b/app/views/users/_user.json.jbuilder index 8c5f58265..afec979a1 100644 --- a/app/views/users/_user.json.jbuilder +++ b/app/views/users/_user.json.jbuilder @@ -4,5 +4,4 @@ json.name user.full_name json.grade user.grade # json.email user.mail # 邮箱原则上不暴露的,如果实在需要的话只能对某些具体的接口公开 json.image_url url_to_avatar(user) -json.user_url "/users/#{user.login}" json.school user.school_name \ No newline at end of file From b0bee8bc75e2df5d4eff20ff0553c3d11fa55760 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Sat, 22 Jun 2019 16:59:51 +0800 Subject: [PATCH 20/37] 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 41407f876..35373730c 100644 --- a/app/controllers/zips_controller.rb +++ b/app/controllers/zips_controller.rb @@ -40,12 +40,12 @@ class ZipsController < ApplicationController def get_exercise ActiveRecord::Base.transaction do begin - @exercise = Exercise.find_by(id:params[:exercise_id]).includes(:exercise_users) + @exercise = Exercise.includes(:exercise_users).find_by(id:params[:exercise_id]) group_id = params[:exercise_group_id] if @exercise.blank? normal_status(-1,"试卷不存在") else - @course = @exercise.course.includes(:course_members) + @course = @exercise.course default_ex_users = @exercise.all_exercise_users(current_user.id).exercise_user_committed default_ex_users_size = default_ex_users.size From aa8c02a9a7c836579362abb72f2ef1c2eb5dc768 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Sat, 22 Jun 2019 17:02:04 +0800 Subject: [PATCH 21/37] =?UTF-8?q?=E6=95=99=E5=B8=88=E5=88=97=E8=A1=A8?= =?UTF-8?q?=E7=9A=84=E6=9D=83=E9=99=90=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/application_controller.rb | 7 +++++++ app/controllers/course_groups_controller.rb | 2 +- app/controllers/courses_controller.rb | 8 ++++---- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 1915281bf..36659ff4a 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -126,6 +126,13 @@ class ApplicationController < ActionController::Base end end + # 课堂教师、课堂管理员、超级管理员的权限(不包含助教) + def teacher_or_admin_allowed + unless current_user.course_identity(@course) < Course::ASSISTANT_PROFESSOR + normal_status(403, "") + end + end + def require_admin normal_status(403, "") unless User.current.admin? end diff --git a/app/controllers/course_groups_controller.rb b/app/controllers/course_groups_controller.rb index 8b6737e0f..bee3fa09d 100644 --- a/app/controllers/course_groups_controller.rb +++ b/app/controllers/course_groups_controller.rb @@ -2,7 +2,7 @@ class CourseGroupsController < ApplicationController before_action :require_login before_action :set_group, except: [:create] before_action :find_course, only: [:create] - before_action :teacher_allowed + before_action :teacher_or_admin_allowed def create tip_exception("分班名称不能为空") if params[:name].blank? diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index 3d0926994..b76673945 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -25,11 +25,11 @@ class CoursesController < ApplicationController before_action :teacher_allowed, only: [:update, :destroy, :settings, :search_teacher_candidate, :transfer_to_course_group, :delete_from_course, :search_users, :add_students_by_search, :get_historical_courses, :add_teacher_popup, :add_teacher] - before_action :admin_allowed, only: [:set_invite_code_halt, :set_public_or_private, :join_graduation_group, - :set_course_group, :change_course_admin, :change_course_teacher, - :delete_course_teacher, :teacher_application_review, :create_group_by_importing_file] + before_action :admin_allowed, only: [:set_invite_code_halt, :set_public_or_private, :change_course_admin, + :set_course_group, :delete_course_teacher, :teacher_application_review, + :create_group_by_importing_file] before_action :teacher_or_admin_allowed, only: [:graduation_group_list, :create_graduation_group, :join_graduation_group, - :export_member_scores_excel, :course_group_list] + :change_course_teacher, :export_member_scores_excel, :course_group_list] before_action :validate_course_name, only: [:create, :update] before_action :find_board, only: :board_list before_action :validate_page_size, only: :mine From fb279178ae8fe6c4ae27a71d688a0639f39e4279 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Sat, 22 Jun 2019 17:06:26 +0800 Subject: [PATCH 22/37] fix bug --- app/controllers/zips_controller.rb | 5 +++-- app/services/exercise_user_pdf_service.rb | 5 +++++ app/services/export_exercises_service.rb | 14 ++++++++++++++ 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/app/controllers/zips_controller.rb b/app/controllers/zips_controller.rb index 35373730c..3e3445e77 100644 --- a/app/controllers/zips_controller.rb +++ b/app/controllers/zips_controller.rb @@ -20,8 +20,9 @@ class ZipsController < ApplicationController exercises = ExportExercisesService.new(@exercise,@ex_users) file_name = filename_for_content_disposition(exercises.filename) - logger.info("##################_______________________file_name_____________________############{file_name}") send_file exercises.ex_zip, filename: file_name, type: 'application/zip' + logger.info("##################_______________________file_name___________1100101010010__________###########") + rescue Exception => e normal_status(-1, e.message) end @@ -40,7 +41,7 @@ class ZipsController < ApplicationController def get_exercise ActiveRecord::Base.transaction do begin - @exercise = Exercise.includes(:exercise_users).find_by(id:params[:exercise_id]) + @exercise = Exercise.includes(:exercise_users,:exercise_questions).find_by(id:params[:exercise_id]) 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 5f92aee9c..52f54163e 100644 --- a/app/services/exercise_user_pdf_service.rb +++ b/app/services/exercise_user_pdf_service.rb @@ -41,9 +41,14 @@ class ExerciseUserPdfService # aa = File.open(Rails.root.join("public/123.html"),"w+") # aa.syswrite(kit.source) #正式需删掉------- + logger.info("##################_______________________file_name___________5555555555__________###########") file = Tempfile.new(filename) + logger.info("##################_______________________file_name___________66666666__________###########") + kit.to_pdf(file.path) + logger.info("##################_______________________file_name___________7777777777__________###########") + file end diff --git a/app/services/export_exercises_service.rb b/app/services/export_exercises_service.rb index 12b5501f9..4b7b10b9b 100644 --- a/app/services/export_exercises_service.rb +++ b/app/services/export_exercises_service.rb @@ -14,15 +14,29 @@ class ExportExercisesService end def ex_zip + logger.info("##################_______________________file_name___________11111__________###########") + zip_file = Tempfile.new(filename) + logger.info("##################_______________________file_name___________2222222__________###########") + pdfs = [] Zip::File.open(zip_file.path, Zip::File::CREATE) do |zip| + logger.info("##################_______________________file_name___________3333333__________###########") + ex_users.each do |ex_user| export = ExerciseUserPdfService.new(exercise, ex_user) + logger.info("##################_______________________file_name___________444444__________###########") + pdf = export.ex_pdf + logger.info("##################_______________________file_name___________888888888__________###########") + pdfs << pdf + logger.info("##################_______________________file_name___________999999999__________###########") + begin zip.add(export.filename, pdf.path) + logger.info("##################_______________________file_name___________10000000000000__________###########") + rescue => ex Rails.logger.error(ex.message) zip.get_output_stream('FILE_NOTICE.txt'){|os| os.write("文件重复:#{export.filename}") } From 28ae66071901ab1b3ecdff6c971afd34f613d9c7 Mon Sep 17 00:00:00 2001 From: jingquan huang Date: Sat, 22 Jun 2019 17:07:08 +0800 Subject: [PATCH 23/37] =?UTF-8?q?=E8=AE=A4=E8=AF=81=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/application_controller.rb | 27 ++++++++++++----------- app/controllers/shixuns_controller.rb | 2 +- 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 1915281bf..1fffc0cb7 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -176,19 +176,20 @@ class ApplicationController < ActionController::Base # 系统全局认证 # def check_auth - old_edu_host = edu_setting('old_edu_host') - ue = current_user.user_extension - - if current_user.lastname.blank? || ue.school_id.blank? || ue.identity.blank? || current_user.mail.blank? - info_url = old_edu_host + '/account/user_info' - render :json => { status: 402, url: info_url } - elsif current_user.certification != 1 - day_cer = UserDayCertification.where(user_id: current_user.id).last - unless (Time.now.to_i - day_cer.try(:created_at).to_i) < 86400 - account_url = old_edu_host + "/my/account" - render :json => { status: 402, url: account_url } - end - end + # old_edu_host = edu_setting('old_edu_host') + # ue = current_user.user_extension + # + # if current_user.lastname.blank? || ue.school_id.blank? || ue.identity.blank? || current_user.mail.blank? + # info_url = old_edu_host + '/account/user_info' + # render :json => { status: 402, url: info_url } + # elsif current_user.certification != 1 + # day_cer = UserDayCertification.where(user_id: current_user.id).last + # unless (Time.now.to_i - day_cer.try(:created_at).to_i) < 86400 + # account_url = old_edu_host + "/my/account" + # render :json => { status: 402, url: account_url } + # end + # end + true end # 身份资料的认证: diff --git a/app/controllers/shixuns_controller.rb b/app/controllers/shixuns_controller.rb index 6dfa94252..5cc470d61 100644 --- a/app/controllers/shixuns_controller.rb +++ b/app/controllers/shixuns_controller.rb @@ -1,5 +1,5 @@ class ShixunsController < ApplicationController - # before_action :require_login, except: [:download_file, :index, :menus] + before_action :require_login, except: [:download_file, :index, :menus] before_action :check_auth, except: [:download_file, :index] before_action :find_shixun, except: [:index, :new, :create, :menus, :get_recommend_shixuns, :propaedeutics, From 05d0bb7c1af6d27fee5e7b99ca90c438880d234b Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Sat, 22 Jun 2019 17:09:21 +0800 Subject: [PATCH 24/37] fix bug --- app/controllers/zips_controller.rb | 2 +- app/services/exercise_user_pdf_service.rb | 6 +++--- app/services/export_exercises_service.rb | 14 +++++++------- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/app/controllers/zips_controller.rb b/app/controllers/zips_controller.rb index 3e3445e77..b04ee3cb1 100644 --- a/app/controllers/zips_controller.rb +++ b/app/controllers/zips_controller.rb @@ -21,7 +21,7 @@ class ZipsController < ApplicationController file_name = filename_for_content_disposition(exercises.filename) send_file exercises.ex_zip, filename: file_name, type: 'application/zip' - logger.info("##################_______________________file_name___________1100101010010__________###########") + Rails.logger.info("##################_______________________file_name___________1100101010010__________###########") rescue Exception => e normal_status(-1, e.message) diff --git a/app/services/exercise_user_pdf_service.rb b/app/services/exercise_user_pdf_service.rb index 52f54163e..1f2f84414 100644 --- a/app/services/exercise_user_pdf_service.rb +++ b/app/services/exercise_user_pdf_service.rb @@ -41,13 +41,13 @@ class ExerciseUserPdfService # aa = File.open(Rails.root.join("public/123.html"),"w+") # aa.syswrite(kit.source) #正式需删掉------- - logger.info("##################_______________________file_name___________5555555555__________###########") + Rails.logger.info("##################_______________________file_name___________5555555555__________###########") file = Tempfile.new(filename) - logger.info("##################_______________________file_name___________66666666__________###########") + Rails.logger.info("##################_______________________file_name___________66666666__________###########") kit.to_pdf(file.path) - logger.info("##################_______________________file_name___________7777777777__________###########") + Rails.logger.info("##################_______________________file_name___________7777777777__________###########") file end diff --git a/app/services/export_exercises_service.rb b/app/services/export_exercises_service.rb index 4b7b10b9b..c450f6247 100644 --- a/app/services/export_exercises_service.rb +++ b/app/services/export_exercises_service.rb @@ -14,28 +14,28 @@ class ExportExercisesService end def ex_zip - logger.info("##################_______________________file_name___________11111__________###########") + Rails.logger.info("##################_______________________file_name___________11111__________###########") zip_file = Tempfile.new(filename) - logger.info("##################_______________________file_name___________2222222__________###########") + Rails.logger.info("##################_______________________file_name___________2222222__________###########") pdfs = [] Zip::File.open(zip_file.path, Zip::File::CREATE) do |zip| - logger.info("##################_______________________file_name___________3333333__________###########") + Rails.logger.info("##################_______________________file_name___________3333333__________###########") ex_users.each do |ex_user| export = ExerciseUserPdfService.new(exercise, ex_user) - logger.info("##################_______________________file_name___________444444__________###########") + Rails.logger.info("##################_______________________file_name___________444444__________###########") pdf = export.ex_pdf - logger.info("##################_______________________file_name___________888888888__________###########") + Rails.logger.info("##################_______________________file_name___________888888888__________###########") pdfs << pdf - logger.info("##################_______________________file_name___________999999999__________###########") + Rails.logger.info("##################_______________________file_name___________999999999__________###########") begin zip.add(export.filename, pdf.path) - logger.info("##################_______________________file_name___________10000000000000__________###########") + Rails.logger.info("##################_______________________file_name___________10000000000000__________###########") rescue => ex Rails.logger.error(ex.message) From 92bd6ea4b5c31924e801806038b4c4737e0d9ccb Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Sat, 22 Jun 2019 17:16:53 +0800 Subject: [PATCH 25/37] =?UTF-8?q?=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/user.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/user.rb b/app/models/user.rb index 0d5517c50..8e25efe70 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -260,7 +260,7 @@ class User < ApplicationRecord # 实训管理员:实训合作者、admin def manager_of_shixun?(shixun) - shixun.shixun_members.exists?(role: [1,2], user_id: id) || admin? + shixun.shixun_members.exists?(role: [1,2], user_id: id) || admin? || business? end # 实训管理员 From 262c3bf78a0529dd0722ce89232ae9b7f975a763 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Sat, 22 Jun 2019 17:17:11 +0800 Subject: [PATCH 26/37] fixbug --- app/controllers/zips_controller.rb | 1 - config/initializers/pdfkit.rb | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/app/controllers/zips_controller.rb b/app/controllers/zips_controller.rb index b04ee3cb1..a8750fc3d 100644 --- a/app/controllers/zips_controller.rb +++ b/app/controllers/zips_controller.rb @@ -21,7 +21,6 @@ class ZipsController < ApplicationController file_name = filename_for_content_disposition(exercises.filename) send_file exercises.ex_zip, filename: file_name, type: 'application/zip' - Rails.logger.info("##################_______________________file_name___________1100101010010__________###########") rescue Exception => e normal_status(-1, e.message) diff --git a/config/initializers/pdfkit.rb b/config/initializers/pdfkit.rb index 0cd80c9c7..8bd9e5e38 100644 --- a/config/initializers/pdfkit.rb +++ b/config/initializers/pdfkit.rb @@ -1,6 +1,6 @@ PDFKit.configure do |config| - config.wkhtmltopdf = ENV["WKHTMLTOPDF_EXEC"] || 'wkhtmltopdf' - # config.wkhtmltopdf = ENV["WKHTMLTOPDF_EXEC"] || '/usr/bin/wkhtmltopdf' + # config.wkhtmltopdf = ENV["WKHTMLTOPDF_EXEC"] || 'wkhtmltopdf' + config.wkhtmltopdf = ENV["WKHTMLTOPDF_EXEC"] || '/usr/bin/wkhtmltopdf' config.default_options = { encoding: "UTF-8", page_size: 'A4', From 7055401525b818a1b457eea15a960e6eedfde93e Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Sat, 22 Jun 2019 17:20:46 +0800 Subject: [PATCH 27/37] fix but --- app/services/exercise_user_pdf_service.rb | 6 - app/services/export_exercises_service.rb | 14 - .../exercise_export/exercise_user.html.erb | 354 +----------------- 3 files changed, 1 insertion(+), 373 deletions(-) diff --git a/app/services/exercise_user_pdf_service.rb b/app/services/exercise_user_pdf_service.rb index 1f2f84414..d74e66d31 100644 --- a/app/services/exercise_user_pdf_service.rb +++ b/app/services/exercise_user_pdf_service.rb @@ -41,14 +41,8 @@ class ExerciseUserPdfService # aa = File.open(Rails.root.join("public/123.html"),"w+") # aa.syswrite(kit.source) #正式需删掉------- - Rails.logger.info("##################_______________________file_name___________5555555555__________###########") - file = Tempfile.new(filename) - Rails.logger.info("##################_______________________file_name___________66666666__________###########") - kit.to_pdf(file.path) - Rails.logger.info("##################_______________________file_name___________7777777777__________###########") - file end diff --git a/app/services/export_exercises_service.rb b/app/services/export_exercises_service.rb index c450f6247..12b5501f9 100644 --- a/app/services/export_exercises_service.rb +++ b/app/services/export_exercises_service.rb @@ -14,29 +14,15 @@ class ExportExercisesService end def ex_zip - Rails.logger.info("##################_______________________file_name___________11111__________###########") - zip_file = Tempfile.new(filename) - Rails.logger.info("##################_______________________file_name___________2222222__________###########") - pdfs = [] Zip::File.open(zip_file.path, Zip::File::CREATE) do |zip| - Rails.logger.info("##################_______________________file_name___________3333333__________###########") - ex_users.each do |ex_user| export = ExerciseUserPdfService.new(exercise, ex_user) - Rails.logger.info("##################_______________________file_name___________444444__________###########") - pdf = export.ex_pdf - Rails.logger.info("##################_______________________file_name___________888888888__________###########") - pdfs << pdf - Rails.logger.info("##################_______________________file_name___________999999999__________###########") - begin zip.add(export.filename, pdf.path) - Rails.logger.info("##################_______________________file_name___________10000000000000__________###########") - rescue => ex Rails.logger.error(ex.message) zip.get_output_stream('FILE_NOTICE.txt'){|os| os.write("文件重复:#{export.filename}") } diff --git a/app/templates/exercise_export/exercise_user.html.erb b/app/templates/exercise_export/exercise_user.html.erb index 088ff1fd4..d769ca0f0 100644 --- a/app/templates/exercise_export/exercise_user.html.erb +++ b/app/templates/exercise_export/exercise_user.html.erb @@ -1,353 +1 @@ - - - - - - - -
-
-
-
-

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

-
-
-

- <%= @exercise.try(:exercise_description).nil? ? "" : @exercise.try(:exercise_description)&.html_safe %> -

-
-
-
-
-

- <% if @exercise_single_ques_count > 0 %> - 单选题<%= @exercise_single_ques_count %>题, - 共<%= @exercise_single_ques_scores %> - <% end %> - <% if @exercise_double_ques_count > 0 %> - 多选题<%= @exercise_double_ques_count %>题, - 共<%= @exercise_double_ques_scores %> - <% end %> - <% if @exercise_ques_judge_count > 0 %> - 判断题<%= @exercise_ques_judge_count %>题, - 共<%= @exercise_ques_judge_scores %> - <% end %> - <% if @exercise_ques_null_count > 0 %> - 填空题<%= @exercise_ques_null_count %>题, - 共<%= @exercise_ques_null_scores %> - <% end %> - <% if @exercise_ques_main_count > 0 %> - 主观题<%= @exercise_ques_main_count %>题, - 共<%= @exercise_ques_main_scores %> - <% end %> - <% if @exercise_ques_shixun_count > 0 %> - 实训题<%= @exercise_ques_shixun_count %>题, - 共<%= @exercise_ques_shixun_scores %> - <% end %> - - <% if @exercise_ques_count > 0 %> - - 共<%= @exercise_ques_scores %>分 - - - 合计<%= @exercise_ques_count %>题 - - <% end %> -

-
-
-
- <% if @ex_obj_array.size > 0 %> -
-

- 客观题 - 正确 - 错误 - 部分得分 - 总分:<%= @exercise_user.score %>分 -

-
-
- <% @ex_obj_array.each do |s| %> - <% if s[:stand_status] == 1 %> -
- <%= s[:q_position] %> -
- <% elsif s[:stand_status] == 0 %> -
- <%= s[:q_position] %> -
- <% else %> -
- <%= s[:q_position] %> -
- <% end %> - <% end %> -
- <% end %> - <% if @ex_sub_array.size > 0 %> -
-

- 主观题 - 已评 - 未评 - 开始答题时间:<%= @exercise_user.start_at.present? ? @exercise_user.start_at.strftime("%Y-%m-%d %H:%M") : "--" %> -

-
-
- <% @ex_sub_array.each do |s| %> - <% if s[:stand_status] == 0 %> -
- <%= s[:q_position] %> -
- <% else %> -
- <%= s[:q_position] %> -
- <% end %> - <% end %> -
- <% end %> -
-
- <% @exercise_questions.each do |q| %> - <% q_type = q.question_type %> - <% user_answer = (q_type == 5 ? q.exercise_shixun_answers.where(user_id: @ex_user_user.id) : q.exercise_answers.where(user_id: @ex_user_user.id)) %> - <% this_ques_status = @ex_obj_array.detect{|f| f[:q_id] == q.id} %> - <% main_ques_status = @ex_sub_array.detect{|f| f[:q_id] == q.id} %> - <% ques_comment = q.exercise_answer_comments.where("exercise_answer_id",user_answer.first&.id) %> -
-
-
-
- <%= q.question_number %>、  - - <%= q.question_type_name %> - - (<%= q&.question_score %>分) - <% if q_type == 5 %> - - <% if this_ques_status.present? && this_ques_status[:stand_status] == 1 %> - - <%= this_ques_status[:user_score] %>分 - <% elsif this_ques_status.present? && this_ques_status[:stand_status] == 2 %> - - <%= this_ques_status[:user_score] %>分 - <% else %> - - 0.0分 - <% end %> - - <% elsif q_type == 4 %> - - <% if main_ques_status.present? && main_ques_status[:stand_status] == 1 %> - - <%= main_ques_status[:user_score] %>分 - <% elsif main_ques_status.present? && main_ques_status[:stand_status] == 2 %> - - <%= main_ques_status[:user_score] %>分 - <% else %> - 未批 - <% end %> - - <% else %> - - <% if this_ques_status.present? && this_ques_status[:stand_status] == 1 %> - - <%= this_ques_status[:user_score] %>分 - <% elsif this_ques_status.present? && this_ques_status[:stand_status] == 2 %> - - <%= this_ques_status[:user_score] %>分 - <% else %> - - 0.0分 - <% end %> - - <% end %> -
-
- <% if q_type == 5 %> - <%= q.shixun_name&.html_safe %> -
- <%= q.question_title&.html_safe %> -
- <% elsif q_type == 4 %> - <%= q.question_title&.html_safe %> - <% else %> - <%= q.question_title&.html_safe %> - <% end %> -
-
-
- <% if q_type == 0 %> - <% q.exercise_choices.each_with_index do |s,index| %> - <% 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%> -

- <% end %> - <% elsif q_type == 1 %> - <% q.exercise_choices.each_with_index do |s,index| %> - <% 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%> -

- <% 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' %> - <% else %> - <% check_answer = '' %> - <% end %> - - - <%= 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| %> - <% if user_answer.present? && user_answer.where(exercise_choice_id:s).present? %> - <% check_answer = user_answer.where(exercise_choice_id:s).first.answer_text %> - <% else %> - <% check_answer = "--" %> - <% end %> -

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

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

- <%= check_answer&.html_safe %> -

- <% else %> -
-

- 阶段成绩 -

- - - - - - - - - - - - <% if @games.size > 0 %> - <% @games.each_with_index do |game, index| %> - <% user_score = q.exercise_shixun_answers.where(exercise_shixun_challenge_id:game.challenge.id,user_id: @ex_user_user.id) %> - <% game_score = q.exercise_shixun_challenges.where(challenge_id:game.challenge.id) %> - - - - - - - - - - <% end %> - <% else %> - <% q.exercise_shixun_challenges.each_with_index do |game, index| %> - <% game_score = q.exercise_shixun_challenges.where(challenge_id:game.challenge.id) %> - - - - - - - - - - <% end %> - <% end %> - -
关卡任务名称评测次数完成时间耗时经验值得分/满分
<%= index + 1 %> - <%= game.challenge.subject %> - <%= game.evaluate_count %><%= game.end_time.present? ? game.end_time.strftime("%Y-%m-%d %H:%M") : "--" %><%= ApplicationController.helpers.time_consuming game %><%= game.final_score %> / <%= game.challenge.all_score %><%= user_score.present? ? user_score.first.score : 0.0 %> / <%= game_score.present? ? game_score.first.question_score : 0.0 %>
<%= index + 1 %> - <%= game.challenge.subject %> - 0----0.0 / <%= game.challenge.all_score %>0.0 / <%= game_score.present? ? game_score.first.question_score : 0.0 %>
-
-
-

- 实训详情 -

- <% @games.each_with_index do |game, index| %> -
-

- 第<%= index+1 %>关<%= game.challenge.subject %> -

-
- <% if game.outputs.present? %> - - - - - - - <% outputs = game.outputs.group("query_index") %> - <% outputs.reverse.try(:each) do |output| %> - - - - - <% end %> - -
评测次数评测信息
<%= "第#{output.query_index}次" %><%= output_detail(game, output) %>
- <% end %> - <% if game.try(:lastest_code).present? && game.challenge.st == 0 %> - <% con_rows = content_line(game.lastest_code) %> -
-

- - 最近通过的代码 - <%= game.challenge.path %> - -

-
- -
-
- <% end %> -
-
- <% end %> -
- <% end %> -
-
-
- <% if ques_comment.present? && ques_comment.first.comment.present? %> - <% ques_user = ques_comment.first.user %> -
-
-
- -
-
-

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

-

<%= ques_comment.first.comment %>

-
-
-
- <% end %> - <% end %> -
-
-
- - +11111111111111 \ No newline at end of file From df76135f8d44c67682bb732193cacb06319f3167 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Sat, 22 Jun 2019 17:27:59 +0800 Subject: [PATCH 28/37] fix bug --- app/services/exercise_user_pdf_service.rb | 1 + .../exercise_export/exercise_user.html.erb | 354 +++++++++++++++++- 2 files changed, 354 insertions(+), 1 deletion(-) diff --git a/app/services/exercise_user_pdf_service.rb b/app/services/exercise_user_pdf_service.rb index d74e66d31..6dbb11c83 100644 --- a/app/services/exercise_user_pdf_service.rb +++ b/app/services/exercise_user_pdf_service.rb @@ -42,6 +42,7 @@ class ExerciseUserPdfService # aa.syswrite(kit.source) #正式需删掉------- file = Tempfile.new(filename) + logger.info("###########__________________file.path_______________########################{file.path}") kit.to_pdf(file.path) file end diff --git a/app/templates/exercise_export/exercise_user.html.erb b/app/templates/exercise_export/exercise_user.html.erb index d769ca0f0..70c023d26 100644 --- a/app/templates/exercise_export/exercise_user.html.erb +++ b/app/templates/exercise_export/exercise_user.html.erb @@ -1 +1,353 @@ -11111111111111 \ No newline at end of file + + + + + + + +
+
+
+
+

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

+
+
+

+ <%= @exercise.try(:exercise_description).nil? ? "" : @exercise.try(:exercise_description)&.html_safe %> +

+
+
+
+
+

+ <% if @exercise_single_ques_count > 0 %> + 单选题<%= @exercise_single_ques_count %>题, + 共<%= @exercise_single_ques_scores %> + <% end %> + <% if @exercise_double_ques_count > 0 %> + 多选题<%= @exercise_double_ques_count %>题, + 共<%= @exercise_double_ques_scores %> + <% end %> + <% if @exercise_ques_judge_count > 0 %> + 判断题<%= @exercise_ques_judge_count %>题, + 共<%= @exercise_ques_judge_scores %> + <% end %> + <% if @exercise_ques_null_count > 0 %> + 填空题<%= @exercise_ques_null_count %>题, + 共<%= @exercise_ques_null_scores %> + <% end %> + <% if @exercise_ques_main_count > 0 %> + 主观题<%= @exercise_ques_main_count %>题, + 共<%= @exercise_ques_main_scores %> + <% end %> + <% if @exercise_ques_shixun_count > 0 %> + 实训题<%= @exercise_ques_shixun_count %>题, + 共<%= @exercise_ques_shixun_scores %> + <% end %> + + <% if @exercise_ques_count > 0 %> + + 共<%= @exercise_ques_scores %>分 + + + 合计<%= @exercise_ques_count %>题 + + <% end %> +

+
+
+
+ <% if @ex_obj_array.size > 0 %> +
+

+ 客观题 + 正确 + 错误 + 部分得分 + 总分:<%= @exercise_user&.score %>分 +

+
+
+ <% @ex_obj_array.each do |s| %> + <% if s[:stand_status] == 1 %> +
+ <%= s[:q_position] %> +
+ <% elsif s[:stand_status] == 0 %> +
+ <%= s[:q_position] %> +
+ <% else %> +
+ <%= s[:q_position] %> +
+ <% end %> + <% end %> +
+ <% end %> + <% if @ex_sub_array.size > 0 %> +
+

+ 主观题 + 已评 + 未评 + 开始答题时间:<%= @exercise_user.start_at.present? ? @exercise_user.start_at.strftime("%Y-%m-%d %H:%M") : "--" %> +

+
+
+ <% @ex_sub_array.each do |s| %> + <% if s[:stand_status] == 0 %> +
+ <%= s[:q_position] %> +
+ <% else %> +
+ <%= s[:q_position] %> +
+ <% end %> + <% end %> +
+ <% end %> +
+
+ <% @exercise_questions.each do |q| %> + <% q_type = q.question_type %> + <% user_answer = (q_type == 5 ? q.exercise_shixun_answers.where(user_id: @ex_user_user.id) : q.exercise_answers.where(user_id: @ex_user_user.id)) %> + <% this_ques_status = @ex_obj_array.detect{|f| f[:q_id] == q.id} %> + <% main_ques_status = @ex_sub_array.detect{|f| f[:q_id] == q.id} %> + <% ques_comment = q.exercise_answer_comments.where("exercise_answer_id",user_answer.first&.id) %> +
+
+
+
+ <%= q.question_number %>、  + + <%= q.question_type_name %> + + (<%= q&.question_score %>分) + <% if q_type == 5 %> + + <% if this_ques_status.present? && this_ques_status[:stand_status] == 1 %> + + <%= this_ques_status[:user_score] %>分 + <% elsif this_ques_status.present? && this_ques_status[:stand_status] == 2 %> + + <%= this_ques_status[:user_score] %>分 + <% else %> + + 0.0分 + <% end %> + + <% elsif q_type == 4 %> + + <% if main_ques_status.present? && main_ques_status[:stand_status] == 1 %> + + <%= main_ques_status[:user_score] %>分 + <% elsif main_ques_status.present? && main_ques_status[:stand_status] == 2 %> + + <%= main_ques_status[:user_score] %>分 + <% else %> + 未批 + <% end %> + + <% else %> + + <% if this_ques_status.present? && this_ques_status[:stand_status] == 1 %> + + <%= this_ques_status[:user_score] %>分 + <% elsif this_ques_status.present? && this_ques_status[:stand_status] == 2 %> + + <%= this_ques_status[:user_score] %>分 + <% else %> + + 0.0分 + <% end %> + + <% end %> +
+
+ <% if q_type == 5 %> + <%= q.shixun_name&.html_safe %> +
+ <%= q.question_title&.html_safe %> +
+ <% elsif q_type == 4 %> + <%= q.question_title&.html_safe %> + <% else %> + <%= q.question_title&.html_safe %> + <% end %> +
+
+
+ <% if q_type == 0 %> + <% q.exercise_choices.each_with_index do |s,index| %> + <% 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%> +

+ <% end %> + <% elsif q_type == 1 %> + <% q.exercise_choices.each_with_index do |s,index| %> + <% 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%> +

+ <% 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' %> + <% else %> + <% check_answer = '' %> + <% end %> + + + <%= 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| %> + <% if user_answer.present? && user_answer.where(exercise_choice_id:s).present? %> + <% check_answer = user_answer.where(exercise_choice_id:s).first.answer_text %> + <% else %> + <% check_answer = "--" %> + <% end %> +

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

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

+ <%= check_answer&.html_safe %> +

+ <% else %> +
+

+ 阶段成绩 +

+ + + + + + + + + + + + <% if @games.size > 0 %> + <% @games.each_with_index do |game, index| %> + <% user_score = q.exercise_shixun_answers.where(exercise_shixun_challenge_id:game.challenge.id,user_id: @ex_user_user.id) %> + <% game_score = q.exercise_shixun_challenges.where(challenge_id:game.challenge.id) %> + + + + + + + + + + <% end %> + <% else %> + <% q.exercise_shixun_challenges.each_with_index do |game, index| %> + <% game_score = q.exercise_shixun_challenges.where(challenge_id:game.challenge.id) %> + + + + + + + + + + <% end %> + <% end %> + +
关卡任务名称评测次数完成时间耗时经验值得分/满分
<%= index + 1 %> + <%= game.challenge.subject %> + <%= game.evaluate_count %><%= game.end_time.present? ? game.end_time.strftime("%Y-%m-%d %H:%M") : "--" %><%= ApplicationController.helpers.time_consuming game %><%= game.final_score %> / <%= game.challenge.all_score %><%= user_score.present? ? user_score.first.score : 0.0 %> / <%= game_score.present? ? game_score.first.question_score : 0.0 %>
<%= index + 1 %> + <%= game.challenge.subject %> + 0----0.0 / <%= game.challenge.all_score %>0.0 / <%= game_score.present? ? game_score.first.question_score : 0.0 %>
+
+
+

+ 实训详情 +

+ <% @games.each_with_index do |game, index| %> +
+

+ 第<%= index+1 %>关<%= game.challenge.subject %> +

+
+ <% if game.outputs.present? %> + + + + + + + <% outputs = game.outputs.group("query_index") %> + <% outputs.reverse.try(:each) do |output| %> + + + + + <% end %> + +
评测次数评测信息
<%= "第#{output.query_index}次" %><%= output_detail(game, output) %>
+ <% end %> + <% if game.try(:lastest_code).present? && game.challenge.st == 0 %> + <% con_rows = content_line(game.lastest_code) %> +
+

+ + 最近通过的代码 + <%= game.challenge.path %> + +

+
+ +
+
+ <% end %> +
+
+ <% end %> +
+ <% end %> +
+
+
+ <% if ques_comment.present? && ques_comment.first.comment.present? %> + <% ques_user = ques_comment.first.user %> +
+
+
+ +
+
+

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

+

<%= ques_comment.first.comment %>

+
+
+
+ <% end %> + <% end %> +
+
+
+ + From fc92232cdea1d4a8e6415355c525d6c14d7378b8 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Sat, 22 Jun 2019 17:50:11 +0800 Subject: [PATCH 29/37] =?UTF-8?q?vnc=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/games_controller.rb | 16 ++++++++++++++++ app/views/games/show.json.jbuilder | 3 +++ 2 files changed, 19 insertions(+) diff --git a/app/controllers/games_controller.rb b/app/controllers/games_controller.rb index 4aa0b13b8..79167150e 100644 --- a/app/controllers/games_controller.rb +++ b/app/controllers/games_controller.rb @@ -62,6 +62,22 @@ class GamesController < ApplicationController praise_count: praise_count, user_praise: user_praise, time_limit: time_limit, tomcat_url: edu_setting('cloud_tomcat_php'), is_teacher: is_teacher, myshixun_manager: myshixun_manager} + if @shixun.vnc + begin + shixun_tomcat = edu_setting('shixun_tomcat') + service_host = edu_setting('vnc_url') + uri = "#{shixun_tomcat}/bridge/vnc/getvnc" + params = {tpiID: @myshixun.id, :containers => "#{Base64.urlsafe_encode64(container_limit(@shixun.mirror_repositories))}"} + res = uri_post uri, params + if res && res['code'].to_i != 0 + raise("实训云平台繁忙(繁忙等级:99)") + end + @url = "http://#{service_host}:#{res['port']}}/vnc_lite.html?password=headless" + Rails.logger.info("66666666sssssss#{url}") + rescue Exception => e + Rails.logger.error(e.message) + end + end # 区分选择题和编程题,st:0编程题; if @st == 0 diff --git a/app/views/games/show.json.jbuilder b/app/views/games/show.json.jbuilder index acbc8c2ef..607a57a15 100644 --- a/app/views/games/show.json.jbuilder +++ b/app/views/games/show.json.jbuilder @@ -1,6 +1,9 @@ json.(@base_date, :st, :discusses_count, :game_count, :record_onsume_time, :prev_game, :next_game, :praise_count, :user_praise, :time_limit, :tomcat_url, :is_teacher, :myshixun_manager, :game, :challenge, :shixun, :myshixun) +if @shixun.vnc + json.vnc_url @vnc_url +end json.user do json.partial! 'users/user', user: @user json.identity @identity From fe133afc0993918973a5b0a822616d297027ba65 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Sat, 22 Jun 2019 18:00:04 +0800 Subject: [PATCH 30/37] fix but --- app/services/exercise_user_pdf_service.rb | 1 - .../exercise_export/exercise_export.css | 6 +- public/123.html | 366 ------------------ 3 files changed, 4 insertions(+), 369 deletions(-) diff --git a/app/services/exercise_user_pdf_service.rb b/app/services/exercise_user_pdf_service.rb index 6dbb11c83..d74e66d31 100644 --- a/app/services/exercise_user_pdf_service.rb +++ b/app/services/exercise_user_pdf_service.rb @@ -42,7 +42,6 @@ class ExerciseUserPdfService # aa.syswrite(kit.source) #正式需删掉------- file = Tempfile.new(filename) - logger.info("###########__________________file.path_______________########################{file.path}") kit.to_pdf(file.path) file end diff --git a/app/templates/exercise_export/exercise_export.css b/app/templates/exercise_export/exercise_export.css index 884a49af0..302097208 100644 --- a/app/templates/exercise_export/exercise_export.css +++ b/app/templates/exercise_export/exercise_export.css @@ -1,5 +1,7 @@ body{ - font-size:14px;} + font-size:14px; + font-family: "微软雅黑","宋体"; +} p{ margin:0; } @@ -229,7 +231,7 @@ p{ position: absolute; display: inline-block; bottom: 9px; - left: 3px; + left: 1px; } .circle-right:after{ color:#fff; diff --git a/public/123.html b/public/123.html index 8986880e5..e69de29bb 100644 --- a/public/123.html +++ b/public/123.html @@ -1,366 +0,0 @@ - - - - - - - - - -
-
-

- - 单选题5题,共10分 - - - 单选题5题,共10分 - - - 单选题5题,共10分 - - - 单选题5题,共10分 - - - 共10分 - - - 合计20题 - - - -

- - - - - - - -
-
- - - \ No newline at end of file From d45e8da5b9503553a40d8f5a15154346f0a7c40e Mon Sep 17 00:00:00 2001 From: p31729568 Date: Sat, 22 Jun 2019 18:08:02 +0800 Subject: [PATCH 31/37] fix --- app/decorators/user_decorator.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/decorators/user_decorator.rb b/app/decorators/user_decorator.rb index a0f9f7fdd..463d9a6e3 100644 --- a/app/decorators/user_decorator.rb +++ b/app/decorators/user_decorator.rb @@ -14,12 +14,14 @@ module UserDecorator # 关注数 def follow_count - User.watched_by(id).count + Watcher.where(user_id: id, watchable_type: %w(Principal User)).count + # User.watched_by(id).count end # 粉丝数 def fan_count - watchers.count + Watcher.where(watchable_type: %w(Principal User), watchable_id: id).count + # watchers.count end # 是否绑定邮箱 From 7b92517d3df36485e2fdfcbecfc679356e76a8ac Mon Sep 17 00:00:00 2001 From: jingquan huang Date: Sat, 22 Jun 2019 18:09:04 +0800 Subject: [PATCH 32/37] =?UTF-8?q?=E8=AF=84=E6=B5=8B=E8=BF=94=E5=9B=9E?= =?UTF-8?q?=E9=97=AE=E9=A2=98=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/myshixuns_controller.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/myshixuns_controller.rb b/app/controllers/myshixuns_controller.rb index 042945b6e..91cff3c19 100644 --- a/app/controllers/myshixuns_controller.rb +++ b/app/controllers/myshixuns_controller.rb @@ -1,7 +1,7 @@ class MyshixunsController < ApplicationController before_action :require_login, :except => [:training_task_status, :code_runinng_message] - before_action :find_myshixun, :except => [:training_task_status] - before_action :find_repo_name, :except => [:training_task_status] + before_action :find_myshixun, :except => [:training_task_status, :code_runinng_message] + before_action :find_repo_name, :except => [:training_task_status, :code_runinng_message] skip_before_action :verify_authenticity_token, :only => [:html_content] ## TPI关卡列表 From 73de92d405a5c3055a0c47b979e8848f5a752699 Mon Sep 17 00:00:00 2001 From: jingquan huang Date: Sat, 22 Jun 2019 18:13:49 +0800 Subject: [PATCH 33/37] production ignore --- .gitignore | 1 + Gemfile | 4 ++-- .../environments/{development.rb => development.rb.example} | 0 3 files changed, 3 insertions(+), 2 deletions(-) rename config/environments/{development.rb => development.rb.example} (100%) diff --git a/.gitignore b/.gitignore index 309e960d7..4f52644ff 100644 --- a/.gitignore +++ b/.gitignore @@ -47,6 +47,7 @@ public/upload.html /config/configuration.yml +/config/environments/production.rb /config/initializers/gitlab_config.rb /db/schema.rb .vscode/ diff --git a/Gemfile b/Gemfile index dfc9d41fd..f7c7e487a 100644 --- a/Gemfile +++ b/Gemfile @@ -45,12 +45,12 @@ gem 'rqrcode_png' gem 'acts-as-taggable-on', '~> 6.0' -group :development, :test do +group :'development.rb.example', :test do gem 'byebug', platforms: [:mri, :mingw, :x64_mingw] gem 'rspec-rails', '~> 3.8' end -group :development do +group :'development.rb.example' do gem 'awesome_print' gem 'web-console', '>= 3.3.0' gem 'listen', '>= 3.0.5', '< 3.2' diff --git a/config/environments/development.rb b/config/environments/development.rb.example similarity index 100% rename from config/environments/development.rb rename to config/environments/development.rb.example From 8ac11cace5a7f2a157b35e1249f7c781e7065d3e Mon Sep 17 00:00:00 2001 From: jingquan huang Date: Sat, 22 Jun 2019 18:15:36 +0800 Subject: [PATCH 34/37] .. --- config/environments/development.rb | 76 ++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 config/environments/development.rb diff --git a/config/environments/development.rb b/config/environments/development.rb new file mode 100644 index 000000000..0b31f5828 --- /dev/null +++ b/config/environments/development.rb @@ -0,0 +1,76 @@ +Rails.application.configure do + # Settings specified here will take precedence over those in config/application.rb. + + # In the development environment your application's code is reloaded on + # every request. This slows down response time but is perfect for development + # since you don't have to restart the web server when you make code changes. + config.cache_classes = false + + # Do not eager load code on boot. + config.eager_load = false + + # Show full error reports. + config.consider_all_requests_local = true + + # Enable/disable caching. By default caching is disabled. + # Run rails dev:cache to toggle caching. + + config.cache_store = :file_store, "#{Rails.root }/files/cache_store/" + + # if Rails.root.join('tmp', 'caching-dev.txt').exist? + # config.action_controller.perform_caching = true + # + # config.cache_store = :memory_store + # config.public_file_server.headers = { + # 'Cache-Control' => "public, max-age=#{2.days.to_i}" + # } + # else + # config.action_controller.perform_caching = false + # + # config.cache_store = :null_store + # end + + # Store uploaded files on the local file system (see config/storage.yml for options) + config.active_storage.service = :local + + # Don't care if the mailer can't send. + config.action_mailer.raise_delivery_errors = false + + config.action_mailer.perform_caching = false + + # Print deprecation notices to the Rails logger. + config.active_support.deprecation = :log + + # Raise an error on page load if there are pending migrations. + config.active_record.migration_error = :page_load + + # Highlight code that triggered database queries in logs. + config.active_record.verbose_query_logs = true + + # Debug mode disables concatenation and preprocessing of assets. + # This option may cause significant delays in view rendering with a large + # number of complex assets. + config.assets.debug = true + + # Suppress logger output for asset requests. + config.assets.quiet = true + + # Raises error for missing translations + # config.action_view.raise_on_missing_translations = true + + # Use an evented file watcher to asynchronously detect changes in source code, + # routes, locales, etc. This feature depends on the listen gem. + config.file_watcher = ActiveSupport::EventedFileUpdateChecker + + config.action_controller.perform_caching = true + + config.action_mailer.delivery_method = :smtp + config.action_mailer.smtp_settings = { + address: 'smtp.exmail.qq.com', + port: 25, + domain: 'smtp.qq.com', + user_name: 'educoder@trustie.org', + password: 'mAZc9EWbe2Kawaqo2', + authentication: 'login', + enable_starttls_auto: true } +end From 5ad7840fb4f6ee1b47cb23eede31b488168c96b7 Mon Sep 17 00:00:00 2001 From: jingquan huang Date: Sat, 22 Jun 2019 18:17:24 +0800 Subject: [PATCH 35/37] development ignore --- config/environments/{production.rb => production.rb.example} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename config/environments/{production.rb => production.rb.example} (100%) diff --git a/config/environments/production.rb b/config/environments/production.rb.example similarity index 100% rename from config/environments/production.rb rename to config/environments/production.rb.example From 26d0e0a917878ce7f4400d71d6a5746035b36591 Mon Sep 17 00:00:00 2001 From: jingquan huang Date: Sat, 22 Jun 2019 19:48:06 +0800 Subject: [PATCH 36/37] =?UTF-8?q?reset=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/shixuns_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/shixuns_controller.rb b/app/controllers/shixuns_controller.rb index 5cc470d61..b11444716 100644 --- a/app/controllers/shixuns_controller.rb +++ b/app/controllers/shixuns_controller.rb @@ -492,7 +492,7 @@ class ShixunsController < ApplicationController if current_myshixun # 如果TPM和TPI的管卡数不相等或者关卡顺序错了,说明实训被极大的改动,需要重置 - if current_myshixun.games.count != @shixun.challenges_count || current_myshixun.games.map(&:challenge_id).sort != Challenge.where(shixun_id: @shixun.id).pluck(:id).sort + if current_myshixun.games.count != @shixun.challenges_count # 这里页面弹框要收到 当前用户myshixun的identifier. tip_show_exception("/myshixuns/#{current_myshixun.try(:identifier)}/reset_my_game") end From 8fc26a69f36f856cc0ee4511228de40b50de75bf Mon Sep 17 00:00:00 2001 From: jingquan huang Date: Sat, 22 Jun 2019 19:50:04 +0800 Subject: [PATCH 37/37] log --- app/controllers/shixuns_controller.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/controllers/shixuns_controller.rb b/app/controllers/shixuns_controller.rb index b11444716..8359b14f9 100644 --- a/app/controllers/shixuns_controller.rb +++ b/app/controllers/shixuns_controller.rb @@ -492,7 +492,8 @@ class ShixunsController < ApplicationController if current_myshixun # 如果TPM和TPI的管卡数不相等或者关卡顺序错了,说明实训被极大的改动,需要重置 - if current_myshixun.games.count != @shixun.challenges_count + uid_logger_error("7777777777777777#{current_myshixun.games.count}, #{@shixun.challenges_count}") + if current_myshixun.games.count != @shixun.challenges_count || current_myshixun.games.map(&:challenge_id).sort != Challenge.where(shixun_id: @shixun.id).pluck(:id).sort # 这里页面弹框要收到 当前用户myshixun的identifier. tip_show_exception("/myshixuns/#{current_myshixun.try(:identifier)}/reset_my_game") end