diff --git a/app/controllers/challenges_controller.rb b/app/controllers/challenges_controller.rb index d1281338..0c37a3ab 100644 --- a/app/controllers/challenges_controller.rb +++ b/app/controllers/challenges_controller.rb @@ -1,7 +1,7 @@ # encoding: utf-8 class ChallengesController < ApplicationController layout "base_shixun" - before_filter :check_authentication + before_filter :check_authentication, :except => [:index] before_filter :find_shixun, :only => [:index, :new, :create, :destroy, :challenge_build, :update_evaluation, :add_choose_question, :new_choose_question, :choose_type_show, :edit_choose_question, :update_choose_question, :destroy_challenge_choose] before_filter :find_challenge, :only => [:show, :edit, :update, :challenge_build, :index_up, :index_down, :destroy, :update_evaluation, :add_choose_question, @@ -316,9 +316,12 @@ class ChallengesController < ApplicationController script = modify_shixun_script @shixun, @shixun.evaluate_script @shixun.update_column(:evaluate_script, script) end - if path != params[:challenge][:path] - shixun_modify_status_without_publish(@shixun, 1) - end + + # 学员任务文件路径更新不需要重置 + # if path != params[:challenge][:path] + # shixun_modify_status_without_publish(@shixun, 1) + # end + Attachment.attach_files(@challenge, params[:attachments]) elsif params[:tab].to_i == 5 @challenge_tags.delete_all unless @challenge_tags.blank? diff --git a/app/controllers/managements_controller.rb b/app/controllers/managements_controller.rb index fe5aa922..5e465ece 100644 --- a/app/controllers/managements_controller.rb +++ b/app/controllers/managements_controller.rb @@ -828,31 +828,30 @@ class ManagementsController < ApplicationController @pod_num = res['sum'] @pod_dis = JSON.parse(res['distr']) if res['distr'].present? end - @search = params[:search] # 搜索字 - @keyword = params[:keyword].blank? ? "u_name" : params[:keyword] # 根据姓名/课程名搜索 - if "u_name" == @keyword - if @search.blank? - @evaluate_recods = EvaluateRecord.where("0=0") - else - user_id = User.where("concat(lastname, firstname) like '%#{@search}%'") + + page = (params['page'] || 1).to_i + search = params[:search] + keyword = params[:keyword] + limit = 20 + + if search + if "u_name" == keyword @evaluate_recods = EvaluateRecord.joins("join users u on evaluate_records.user_id = u.id").where("concat(u.lastname, u.firstname) like '%#{@search}%'") + # @evaluate_recods = EvaluateRecord.where(user_id: User.where("concat(lastname, firstname) like '%#{search}%'").pluck(:id)) + else + @evaluate_recods = EvaluateRecord.joins("join user_extensions ue on evaluate_records.user_id = ue.user_id").where("ue.school_id in (select id from schools where name like '%#{@search}%')") + # @evaluate_recods = EvaluateRecord.where(user_id: UserExtensions.where(school_id: School.where("name like '%#{search}%'").pluck(:id)).pluck(:user_id)) end else - school_id = School.where("name like '%#{@search}%'").map(&:id) - user_id = UserExtensions.where(:school_id => school_id).map(&:user_id) - @evaluate_recods = EvaluateRecord.where(:user_id => user_id) + @evaluate_recods = EvaluateRecord.all end + @evaluate_recods_count = @evaluate_recods.count - @page = (params['page'] || 1).to_i - @limit = 20 - @is_remote = true - @evaluate_recods_pages = Paginator.new @evaluate_recods_count, @limit, @page - @offset ||= @evaluate_recods_pages.offset - @evaluate_recods = paginateHelper @evaluate_recods, @limit + @evaluate_recods_pages = Paginator.new @evaluate_recods_count, limit, page + @evaluate_recods = @evaluate_recods.includes(:shixun, :user).page(page).per(limit) respond_to do |format| format.js format.html - end end @@ -4098,7 +4097,7 @@ end book = Spreadsheet::Workbook.new sheet1 = book.create_worksheet :name => "已发布实训课程" count_row = 2 - sheet1.row(1).concat(["", "地址", "实训课程名称","章节名称", "实训组成", "关卡数", "状态", "更新时间"]) + sheet1.row(1).concat(["", "地址", "实训课程名称","章节名称", "实训组成", "关卡数", "状态", "课程等级", "更新时间", "发布时间", ]) Rails.logger.warn("##########subjects:#{subjects.count}") subjects.each do |subject| sheet1[count_row,1] = "paths/"+subject.id.to_s @@ -4112,19 +4111,25 @@ end sheet1[count_row,5] = shixun.challenges.count sheet1[count_row,6] = shixun.shixun_status if s_index == 0 && index == 0 - sheet1[count_row,7] = format_time subject.updated_at + sheet1[count_row,7] = subject.subject_level_system.try(:name) || "--" + sheet1[count_row,8] = format_time subject.updated_at + sheet1[count_row,9] = format_time subject.publish_time end count_row += 1 end else if s_index == 0 - sheet1[count_row,7] = format_time subject.updated_at + sheet1[count_row,7] = subject.subject_level_system.try(:name) || "--" + sheet1[count_row,8] = format_time subject.updated_at + sheet1[count_row,9] = format_time subject.publish_time end count_row += 1 end end else - sheet1[count_row,7] = format_time subject.updated_at + sheet1[count_row,7] = subject.subject_level_system.try(:name) || "--" + sheet1[count_row,8] = format_time subject.updated_at + sheet1[count_row,9] = format_time subject.publish_time count_row += 1 end end diff --git a/app/controllers/shixuns_controller.rb b/app/controllers/shixuns_controller.rb index f147b9b2..e50827e3 100644 --- a/app/controllers/shixuns_controller.rb +++ b/app/controllers/shixuns_controller.rb @@ -384,7 +384,7 @@ class ShixunsController < ApplicationController shixun_id = shixun_id & my_shixun_ids end - @shixuns = Shixun.select([:id, :name, :user_id, :challenges_count, :visits, :status, :myshixuns_count, :trainee, :use_scope, :identifier, :image_text]).where(:id => shixun_id, :hidden => 0, :trainee => diff, :status => status).includes(:challenges, :schools, :shixun_members, :users) + @shixuns = Shixun.select([:id, :name, :user_id, :challenges_count, :visits, :status, :myshixuns_count, :trainee, :use_scope, :identifier, :image_text, :averge_star]).where(:id => shixun_id, :hidden => 0, :trainee => diff, :status => status).includes(:challenges, :schools, :shixun_members, :users) if search.present? search_users_id = User.select([:id]).where("concat(lastname, firstname) like '%#{search}%'") diff --git a/app/models/subject.rb b/app/models/subject.rb index bd92c39c..59e84ee3 100644 --- a/app/models/subject.rb +++ b/app/models/subject.rb @@ -18,7 +18,7 @@ class Subject < ActiveRecord::Base has_many :tidings, :as => :container, :dependent => :destroy belongs_to :repertoire belongs_to :user - has_one :subject_level_system + belongs_to :subject_level_system scope :visible, lambda{where(status: 2)} diff --git a/app/views/shixuns/_shixun_item.html.erb b/app/views/shixuns/_shixun_item.html.erb index 40420a8b..f3677a27 100644 --- a/app/views/shixuns/_shixun_item.html.erb +++ b/app/views/shixuns/_shixun_item.html.erb @@ -1,21 +1,21 @@ -<% result = User.current.is_certification_teacher || User.current.admin? %> +<%# result = User.current.is_certification_teacher || User.current.admin? %> <% shixuns.each do |shixun| %>
暂未公开
-暂未公开
+- " class="justify color-grey-name" title="<%= shixun.name %>" target="_blank"><%= shixun.name %> + <%= shixun.name %>
diff --git a/app/views/subjects/_subject_item.html.erb b/app/views/subjects/_subject_item.html.erb index abcf0f11..3dbc3605 100644 --- a/app/views/subjects/_subject_item.html.erb +++ b/app/views/subjects/_subject_item.html.erb @@ -1,19 +1,18 @@ -<% result = User.current.is_certification_teacher || User.current.admin? %> <% subjects.each do |subject| %>暂未开发
- <%= link_to subject.name, "#{result ? subject_path(subject) : "javascript:void(0);"}", :class => "justify color-grey-name", :target => "_blank" %> + <%= link_to subject.name, subject_path(subject), :class => "justify color-grey-name", :target => "_blank" %>
<% if subject.stages_count > 0 %> diff --git a/app/views/users/_course_homework.html.erb b/app/views/users/_course_homework.html.erb index 03507d8c..5f521117 100644 --- a/app/views/users/_course_homework.html.erb +++ b/app/views/users/_course_homework.html.erb @@ -83,7 +83,10 @@ <% elsif work.present? %> <% myshixun = Myshixun.where(:id => work.myshixun_id).first %> <%# is_modify = ShixunModify.where(:myshixun_id => myshixun.try(:id), :shixun_id => myshixun.shixun.try(:id), :status => 1).first %> - <%= link_to "继续实战", shixun_path(myshixun.shixun), :class => "edu-filter-btn edu-activity-blue ml15 fl mt5", :target => "_blank" %> + <% if myshixun.present? %> + <%= link_to "继续实战", shixun_path(myshixun.shixun), :class => "edu-filter-btn edu-activity-blue ml15 fl mt5", :target => "_blank" %> + <% end %> + <%# if myshixun && is_modify.blank? %> <%#= link_to "继续实战", shixun_exec_shixun_path(myshixun.shixun), :class => "edu-filter-btn edu-activity-blue ml15 fl mt5", :target => "_blank" %> <%# elsif myshixun %> diff --git a/db/migrate/20190309061759_add_index_on_evaluate_records.rb b/db/migrate/20190309061759_add_index_on_evaluate_records.rb new file mode 100644 index 00000000..126d6cfa --- /dev/null +++ b/db/migrate/20190309061759_add_index_on_evaluate_records.rb @@ -0,0 +1,8 @@ +class AddIndexOnEvaluateRecords < ActiveRecord::Migration + def up + add_index :evaluate_records, :user_id + end + + def down + end +end diff --git a/lib/tasks/delete_error_myshixun.rake b/lib/tasks/delete_error_myshixun.rake new file mode 100644 index 00000000..b9165a73 --- /dev/null +++ b/lib/tasks/delete_error_myshixun.rake @@ -0,0 +1,14 @@ +namespace :myshixun do + desc "delete gpid is no" + task :delete_error_myshixuns => :environment do + begin + myshixuns = Myshixun.where("gpid is null and created_at > '#{Time.now.beginning_of_day}'") + myshixuns.find_each do |m| + m.destroy + puts("#myshixun_id: #{m.id}") + end + rescue Exception => e + puts e + end + end +end