From 6db6d8cd8d9cd18e64c3ca771a1e2816ad6aa4f7 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Mon, 27 May 2019 17:19:11 +0800 Subject: [PATCH 1/9] =?UTF-8?q?=E8=AF=84=E6=B5=8B=E6=97=B6=E9=97=B4?= =?UTF-8?q?=E5=8F=96=E6=97=B6=E5=9C=A8=E4=B8=80=E5=A4=A9=E4=B9=8B=E5=86=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/managements_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/managements_controller.rb b/app/controllers/managements_controller.rb index 851c50e6..202f90b3 100644 --- a/app/controllers/managements_controller.rb +++ b/app/controllers/managements_controller.rb @@ -853,7 +853,7 @@ class ManagementsController < ApplicationController def evaluate_simple page = params[:page] - @recodes = EvaluateRecord.where("created_at > ?", Time.now - 10000.days).reorder("consume_time desc") + @recodes = EvaluateRecord.where("created_at > ?", Time.now - 1.days).reorder("consume_time desc") @recodes_count = @recodes.size @record_pages = Paginator.new @recodes_count, 20, page || 1 @offset ||= @record_pages.offset From d48ec8974e2267d2e09c12028df046bcf59e9465 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Tue, 28 May 2019 08:58:43 +0800 Subject: [PATCH 2/9] =?UTF-8?q?=E5=AD=A6=E9=99=A2=E7=BB=9F=E8=AE=A1?= =?UTF-8?q?=E7=9A=84=E8=AF=BE=E5=A0=82=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/colleges_controller.rb | 2 +- app/controllers/courses_controller.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/colleges_controller.rb b/app/controllers/colleges_controller.rb index fff508a8..1ffcdb46 100644 --- a/app/controllers/colleges_controller.rb +++ b/app/controllers/colleges_controller.rb @@ -131,7 +131,7 @@ class CollegesController < ApplicationController (select count(m.id) from messages m inner join boards b on b.id=m.board_id and b.parent_id=0 where b.course_id=c.id group by c.id) as messages_count, c.tea_id, c.name, c.is_end, (SELECT MAX(created_at) FROM `course_activities` ca WHERE ca.course_id = c.id) AS update_time - FROM `courses` c WHERE (c.school_id = #{@school.id} and c.is_delete = 0)") + FROM `courses` c join user_extensions ue on ue.user_id = c.tea_id WHERE (ue.school_id = #{@school.id} and c.is_delete = 0)") @courses.each do |course| course[:evaluating_count] = Output.find_by_sql("select sum(g.evaluate_count) as evaluating_count from games g inner join diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index e87c7297..669cc58f 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -577,7 +577,7 @@ class CoursesController < ApplicationController cha_member.member_roles.where("role_id = 10").first.destroy StudentsForCourse.where(:course_id => @course.id, :student_id => cha_member.user_id).destroy_all end - @course.update_attributes(:tea_id => cha_member.user_id) + @course.update_attributes(:tea_id => cha_member.user_id, :school_id => cha_member.user.try(:user_extensions).try(:school_id)) man_member.member_roles.first.update_attributes(:role_id => 9) course_act = CourseActivity.where(:course_id => @course.id, :course_act_id => @course.id, :course_act_type => 'Course').first course_act.update_column('user_id', cha_member.user_id) From f14bf75b307fb7f3ae90ea8d9c16f75f2789fb36 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Tue, 28 May 2019 09:15:13 +0800 Subject: [PATCH 3/9] =?UTF-8?q?=E7=BB=9F=E8=AE=A1=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/colleges_controller.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/controllers/colleges_controller.rb b/app/controllers/colleges_controller.rb index 1ffcdb46..ad831e78 100644 --- a/app/controllers/colleges_controller.rb +++ b/app/controllers/colleges_controller.rb @@ -50,7 +50,8 @@ class CollegesController < ApplicationController # Redo:这样做内存会卡死的 # user_ids = User.find_by_sql("SELECT users.id FROM users LEFT JOIN user_extensions ON users.id=user_extensions.user_id WHERE user_extensions.`school_id` = #{@school.id}").map(&:id) # Redo:是否直接使用count会更好 - all_course_ids = Course.joins("join users u on courses.tea_id = u.id").joins("join user_extensions ue on u.id = ue.user_id").where("courses.id != 1309 and ue.school_id = #{@school.id}") + all_course_ids = Course.joins("join users u on courses.tea_id = u.id").joins("join user_extensions ue on u.id = ue.user_id"). + where("courses.id != 1309 and courses.is_delete = 0 and ue.school_id = #{@school.id}") @courses_count = all_course_ids.size # Redo:对于量比较大的尽量不使用笛卡尔积 From 00e4170593e53843aeed2f91dfa49fd2aa4fd6d4 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Tue, 28 May 2019 09:46:58 +0800 Subject: [PATCH 4/9] =?UTF-8?q?=E8=AF=BE=E5=A0=82=E7=9A=84school=5Fid?= =?UTF-8?q?=E8=BF=81=E7=A7=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/colleges_controller.rb | 5 ++--- db/migrate/20190528013018_migrate_course_school_id.rb | 11 +++++++++++ 2 files changed, 13 insertions(+), 3 deletions(-) create mode 100644 db/migrate/20190528013018_migrate_course_school_id.rb diff --git a/app/controllers/colleges_controller.rb b/app/controllers/colleges_controller.rb index ad831e78..418015fd 100644 --- a/app/controllers/colleges_controller.rb +++ b/app/controllers/colleges_controller.rb @@ -50,8 +50,7 @@ class CollegesController < ApplicationController # Redo:这样做内存会卡死的 # user_ids = User.find_by_sql("SELECT users.id FROM users LEFT JOIN user_extensions ON users.id=user_extensions.user_id WHERE user_extensions.`school_id` = #{@school.id}").map(&:id) # Redo:是否直接使用count会更好 - all_course_ids = Course.joins("join users u on courses.tea_id = u.id").joins("join user_extensions ue on u.id = ue.user_id"). - where("courses.id != 1309 and courses.is_delete = 0 and ue.school_id = #{@school.id}") + all_course_ids = Course.where("id != 1309 and is_delete = 0 and school_id = #{@school.id}") @courses_count = all_course_ids.size # Redo:对于量比较大的尽量不使用笛卡尔积 @@ -132,7 +131,7 @@ class CollegesController < ApplicationController (select count(m.id) from messages m inner join boards b on b.id=m.board_id and b.parent_id=0 where b.course_id=c.id group by c.id) as messages_count, c.tea_id, c.name, c.is_end, (SELECT MAX(created_at) FROM `course_activities` ca WHERE ca.course_id = c.id) AS update_time - FROM `courses` c join user_extensions ue on ue.user_id = c.tea_id WHERE (ue.school_id = #{@school.id} and c.is_delete = 0)") + FROM `courses` c WHERE c.school_id = #{@school.id} and c.is_delete = 0") @courses.each do |course| course[:evaluating_count] = Output.find_by_sql("select sum(g.evaluate_count) as evaluating_count from games g inner join diff --git a/db/migrate/20190528013018_migrate_course_school_id.rb b/db/migrate/20190528013018_migrate_course_school_id.rb new file mode 100644 index 00000000..b0669591 --- /dev/null +++ b/db/migrate/20190528013018_migrate_course_school_id.rb @@ -0,0 +1,11 @@ +class MigrateCourseSchoolId < ActiveRecord::Migration + def up + courses = Course.includes(teacher: :user_extensions).where("courses.school_id != user_extensions.school_id or courses.school_id is null") + courses.each do |course| + course.update_column('school_id', course.teacher.try(:user_extensions).try(:school_id)) + end + end + + def down + end +end From 2f9fb67479a4537a2e861a6b67426e60e4bdb200 Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Tue, 28 May 2019 15:10:51 +0800 Subject: [PATCH 5/9] =?UTF-8?q?sonar=E8=AF=84=E6=B5=8B=E5=8F=96=E6=9C=80?= =?UTF-8?q?=E5=90=8E=E4=B8=80=E4=B8=AA=E9=99=84=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/student_work_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/student_work_controller.rb b/app/controllers/student_work_controller.rb index 1afaefc3..89fddb36 100644 --- a/app/controllers/student_work_controller.rb +++ b/app/controllers/student_work_controller.rb @@ -647,7 +647,7 @@ class StudentWorkController < ApplicationController uid: "#{work.user.user_extensions.student_id}", downloadUrl: '' } - attachment = work.attachments.first + attachment = work.attachments.last if attachment o[:downloadUrl] = "https://#{Setting.host_name}/"+download_named_attachment_path(attachment.id, attachment.filename) end From 7e87cd2f822f0f8bfb1b6704f18146c24a764896 Mon Sep 17 00:00:00 2001 From: jingquan huang Date: Wed, 29 May 2019 20:34:07 +0800 Subject: [PATCH 6/9] vnc --- app/models/shixun.rb | 2 +- app/views/shixuns/_form.html.erb | 2 +- app/views/shixuns/_settings_edit.html.erb | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/models/shixun.rb b/app/models/shixun.rb index 439c0e44..bf06b583 100644 --- a/app/models/shixun.rb +++ b/app/models/shixun.rb @@ -57,7 +57,7 @@ class Shixun < ActiveRecord::Base scope :visible, lambda{where(status: [2,3])} scope :min, lambda { select([:id, :name, :gpid, :modify_time, :reset_time, :language, :propaedeutics, :status, :identifier, :test_set_permission, :hide_code, :forbid_copy, :hidden, :webssh, :user_id, :code_hidden, - :task_pass, :exec_time, :multi_webssh]) } + :task_pass, :exec_time, :multi_webssh, :vnc]) } scope :published, lambda{where(status: 2)} scope :field_for_recommend, lambda{ select([:id, :name, :identifier, :myshixuns_count]) } diff --git a/app/views/shixuns/_form.html.erb b/app/views/shixuns/_form.html.erb index 53d38a63..337ecee2 100644 --- a/app/views/shixuns/_form.html.erb +++ b/app/views/shixuns/_form.html.erb @@ -156,7 +156,7 @@ - <% if Redmine::Configuration['gitlab_address'].include?("test") %> + <% if User.current.admin? %>

VNC图形化

  • diff --git a/app/views/shixuns/_settings_edit.html.erb b/app/views/shixuns/_settings_edit.html.erb index 6ebbf633..6ebd6138 100644 --- a/app/views/shixuns/_settings_edit.html.erb +++ b/app/views/shixuns/_settings_edit.html.erb @@ -211,7 +211,7 @@
  • - <% if Redmine::Configuration['gitlab_address'].include?("test") %> + <% if User.current.admin? %>
    VNC图形化: From 9c01b6ff77b0ab90ea54b62a4060db548226509e Mon Sep 17 00:00:00 2001 From: jingquan huang Date: Thu, 30 May 2019 08:46:30 +0800 Subject: [PATCH 7/9] =?UTF-8?q?vnc=E5=9C=A8gameshow=E4=B8=AD=E8=BF=94?= =?UTF-8?q?=E5=9B=9E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/services/games_service.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/services/games_service.rb b/app/services/games_service.rb index 9e1ea356..a53ee086 100644 --- a/app/services/games_service.rb +++ b/app/services/games_service.rb @@ -75,7 +75,8 @@ class GamesService :challenge => game_challenge.try(:attributes), :game => game.try(:attributes), :shixun => shixun.try(:attributes), :record => record, :grade => grade, :prev_game => prev_game, :next_game => next_game, :username => username, :image_url => image_url, :user_url => user_url, :praise_count => praise_count, :user_praise => user_praise, :time_limit => time_limit, - :tomcat_url => Redmine::Configuration['tomcat_php'], :is_teacher => is_teacher, :power => power, :myshixun_manager => myshixun_manager} + :tomcat_url => Redmine::Configuration['tomcat_php'], :is_teacher => is_teacher, :power => power, :myshixun_manager => myshixun_manager, + :vnc => shixun.vnc} # 区分选择题和编程题,st:0编程题; if st == 0 From 048c8571bcdae20221a5fac7c7e003f35c4166ca Mon Sep 17 00:00:00 2001 From: jingquan huang Date: Thu, 30 May 2019 08:57:33 +0800 Subject: [PATCH 8/9] vnc.. --- app/controllers/myshixuns_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/myshixuns_controller.rb b/app/controllers/myshixuns_controller.rb index f6854c7a..d95cdc96 100644 --- a/app/controllers/myshixuns_controller.rb +++ b/app/controllers/myshixuns_controller.rb @@ -1,7 +1,7 @@ # encoding: utf-8 class MyshixunsController < ApplicationController layout 'base_myshixun' - skip_before_filter :verify_authenticity_token, :only => [:training_task_status, :close_webssh, :code_runinng_message] + skip_before_filter :verify_authenticity_token, :only => [:training_task_status, :close_webssh, :code_runinng_message, :vnc] before_filter :require_login, :except => [:training_task_status, :close_webssh, :code_runinng_message] before_filter :check_authentication, :except => [:training_task_status, :close_webssh, :mul_test_home, :mul_test_user, :mul_test_myshixun, :mul_test_shixun, :mul_test_start, :code_runinng_message] From 8a45a61ef89cbc78e8b59ff6d1b31e3836db0d80 Mon Sep 17 00:00:00 2001 From: jingquan huang Date: Thu, 30 May 2019 08:59:35 +0800 Subject: [PATCH 9/9] =?UTF-8?q?vnc=E5=85=8D=E7=99=BB=E9=99=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/myshixuns_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/myshixuns_controller.rb b/app/controllers/myshixuns_controller.rb index d95cdc96..add6511c 100644 --- a/app/controllers/myshixuns_controller.rb +++ b/app/controllers/myshixuns_controller.rb @@ -2,7 +2,7 @@ class MyshixunsController < ApplicationController layout 'base_myshixun' skip_before_filter :verify_authenticity_token, :only => [:training_task_status, :close_webssh, :code_runinng_message, :vnc] - before_filter :require_login, :except => [:training_task_status, :close_webssh, :code_runinng_message] + before_filter :require_login, :except => [:training_task_status, :close_webssh, :code_runinng_message, :vnc] before_filter :check_authentication, :except => [:training_task_status, :close_webssh, :mul_test_home, :mul_test_user, :mul_test_myshixun, :mul_test_shixun, :mul_test_start, :code_runinng_message] before_filter :find_myshixun, :only => [:show, :myshixun_reset, :open_webssh, :sync_reset_time, :destroy, :search_file_list, :vnc]