diff --git a/app/controllers/colleges_controller.rb b/app/controllers/colleges_controller.rb index fff508a8..418015fd 100644 --- a/app/controllers/colleges_controller.rb +++ b/app/controllers/colleges_controller.rb @@ -50,7 +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 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:对于量比较大的尽量不使用笛卡尔积 @@ -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 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/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) diff --git a/app/controllers/managements_controller.rb b/app/controllers/managements_controller.rb index 54b7ffe6..eb3c37c9 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 diff --git a/app/controllers/myshixuns_controller.rb b/app/controllers/myshixuns_controller.rb index f6854c7a..add6511c 100644 --- a/app/controllers/myshixuns_controller.rb +++ b/app/controllers/myshixuns_controller.rb @@ -1,8 +1,8 @@ # encoding: utf-8 class MyshixunsController < ApplicationController layout 'base_myshixun' - skip_before_filter :verify_authenticity_token, :only => [:training_task_status, :close_webssh, :code_runinng_message] - before_filter :require_login, :except => [: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, :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] 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/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 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图形化: 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