Merge branch 'educoder' into develop

pre_develop
jingquan huang 6 years ago
commit a5c3034a3b

@ -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

@ -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)

@ -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

@ -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]) }

@ -156,7 +156,7 @@
<label style="top:6px" class="color-grey-6" for="can_copy">勾选则允许认证教师复制该实训</label>
</li>
</div>
<% if Redmine::Configuration['gitlab_address'].include?("test") %>
<% if User.current.admin? %>
<div class="mb10 edu-back-white padding30-20">
<p class="color-grey-6 font-16 mb10">VNC图形化</p>
<li class="mb20">

@ -211,7 +211,7 @@
</span>
</div>
<% if Redmine::Configuration['gitlab_address'].include?("test") %>
<% if User.current.admin? %>
<div class="clearfix mt20">
<span class="color-grey-6 mt5 fl" style="min-width: 95px;">VNC图形化:</span>
<span class="fl">

@ -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
Loading…
Cancel
Save