Merge branch 'educoder' into develop

dev_SaaS
cxt 6 years ago
commit 0e56ce2ae4

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

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

@ -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}%'")

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

@ -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| %>
<div class="square-Item">
<% if shixun.tag_repertoires.first.present? %>
<div class="tag-green"><span class="tag-name"><%= shixun.tag_repertoires.first.try(:name) %></span><img src="/images/educoder/tag2.png"></div>
<% end %>
<% unless result %>
<div class="closeSquare">
<img src="/images/educoder/icon/lockclose.svg" class="mt80 mb25">
<p class="font-14 color-white">暂未公开</p>
</div>
<% if params[:controller] != "welcome" && shixun_view_allow(shixun, true) %>
<div class="closeSquare">
<img src="/images/educoder/icon/lockclose.svg" class="mt80 mb25">
<p class="font-14 color-white">暂未公开</p>
</div>
<% end %>
<a href="<%= result ? shixun_path(shixun) : "javascript:void(0);" %>" class="square-img" target="_blank">
<a href="<%= shixun_path(shixun) %>" class="square-img" target="_blank">
<%= image_tag(url_to_avatar(shixun)) %>
</a>
<div class="square-main">
<p class="task-hide">
<a href="<%= result ? shixun_path(shixun) : "javascript:void(0);" %>" class="justify color-grey-name" title="<%= shixun.name %>" target="_blank"><%= shixun.name %></a>
<a href="<%= shixun_path(shixun) %>" class="justify color-grey-name" title="<%= shixun.name %>" target="_blank"><%= shixun.name %></a>
</p>
<!--五星评分-->

@ -1,19 +1,18 @@
<% result = User.current.is_certification_teacher || User.current.admin? %>
<% subjects.each do |subject| %>
<div class="square-Item">
<% if subject.repertoire.present? %>
<div class="tag-green"><span class="tag-name"><%= subject.repertoire.name %></span><img src="/images/educoder/tag2.png"></div>
<% end %>
<% unless result %>
<% if params[:controller] != "welcome" && subject.status < 2 && !User.current.member_of_subject?(subject) %>
<div class="closeSquare">
<img src="/images/educoder/icon/lockclose.svg" class="mt80 mb25"/>
<p class="font-14 color-white">暂未开发</p>
</div>
<% end %>
<a href="<%= result ? subject_path(subject) : "javascript:void(0);" %>" class="square-img" target="_blank"><%= image_tag(url_to_avatar(subject)) %></a>
<a href="<%= subject_path(subject) %>" class="square-img" target="_blank"><%= image_tag(url_to_avatar(subject)) %></a>
<div class="square-main">
<p class="task-hide">
<%= 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" %>
</p>
<p class="clearfix mt8 font-12 color-grey-B4">
<% if subject.stages_count > 0 %>

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

@ -0,0 +1,8 @@
class AddIndexOnEvaluateRecords < ActiveRecord::Migration
def up
add_index :evaluate_records, :user_id
end
def down
end
end

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