Merge branch 'dev_aliyun' of https://bdgit.educoder.net/Hjqreturn/educoder into dev_aliyun
commit
7b5f790bbb
@ -0,0 +1,14 @@
|
||||
class Admins::MyshixunsController < Admins::BaseController
|
||||
def index
|
||||
params[:sort_by] = params[:sort_by].presence || 'created_at'
|
||||
params[:sort_direction] = params[:sort_direction].presence || 'desc'
|
||||
|
||||
myshixuns = Admins::MyshixunQuery.call(params)
|
||||
|
||||
@myshixuns = paginate myshixuns.includes(:last_executable_task, :last_task, shixun: :user, user: { user_extension: :school })
|
||||
|
||||
myshixun_ids = @myshixuns.map(&:id)
|
||||
@finish_game_count = Game.where(myshixun_id: myshixun_ids, status: 2).group(:myshixun_id).count
|
||||
@total_score = Game.where(myshixun_id: myshixun_ids, status: 2).where('final_score > 0').group(:myshixun_id).sum(:final_score)
|
||||
end
|
||||
end
|
@ -0,0 +1,26 @@
|
||||
class Admins::MyshixunQuery < ApplicationQuery
|
||||
include CustomSortable
|
||||
|
||||
attr_reader :params
|
||||
|
||||
sort_columns :created_at, default_by: :created_at, default_direction: :desc
|
||||
|
||||
def initialize(params)
|
||||
@params = params
|
||||
end
|
||||
|
||||
def call
|
||||
objs = Myshixun.all
|
||||
|
||||
keyword = params[:keyword].to_s.strip
|
||||
if keyword.present?
|
||||
like_sql = 'users.login LIKE :keyword OR CONCAT(users.lastname, users.firstname) LIKE :keyword OR '\
|
||||
'schools.name LIKE :keyword OR shixuns.name LIKE :keyword OR CONCAT(teacher.lastname, teacher.firstname) Like :keyword'
|
||||
objs = objs.joins(:shixun, user: { user_extension: :school })
|
||||
.joins('JOIN users teacher ON teacher.id = shixuns.user_id')
|
||||
.where(like_sql, keyword: "%#{keyword}%")
|
||||
end
|
||||
|
||||
custom_sort(objs, params[:sort_by], params[:sort_direction])
|
||||
end
|
||||
end
|
@ -0,0 +1,14 @@
|
||||
<% define_admin_breadcrumbs do %>
|
||||
<% add_admin_breadcrumb('学员实训列表') %>
|
||||
<% end %>
|
||||
|
||||
<div class="box search-form-container myshixun-list-form">
|
||||
<%= form_tag(admins_myshixuns_path, method: :get, class: 'form-inline search-form', remote: true) do %>
|
||||
<%= text_field_tag(:keyword, params[:keyword], class: 'form-control col-md-4 ml-3', placeholder: '学员UID/姓名/学校/实训名称/老师姓名检索') %>
|
||||
<%= submit_tag('搜索', class: 'btn btn-primary ml-3', 'data-disable-with': '搜索中...') %>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
<div class="box myshixun-list-container">
|
||||
<%= render(partial: 'admins/myshixuns/shared/list', locals: { myshixuns: @myshixuns, finish_game_count: @finish_game_count, total_score: @total_score }) %>
|
||||
</div>
|
@ -0,0 +1 @@
|
||||
$('.myshixun-list-container').html("<%= j( render(partial: 'admins/myshixuns/shared/list', locals: { myshixuns: @myshixuns, finish_game_count: @finish_game_count, total_score: @total_score }) ) %>");
|
@ -0,0 +1,49 @@
|
||||
<table class="table table-hover text-center myshixun-list-table">
|
||||
<thead class="thead-light">
|
||||
<tr>
|
||||
<th width="6%">ID</th>
|
||||
<th width="10%">标识</th>
|
||||
<th width="22%" class="text-left">实训名称</th>
|
||||
<th width="10%">实训老师</th>
|
||||
<th width="6%">完成</th>
|
||||
<th width="6%">经验值</th>
|
||||
<th width="10%">学员姓名</th>
|
||||
<th width="16%" class="text-left">学员单位</th>
|
||||
<th width="14%"><%= sort_tag('开启时间', name: 'created_at', path: admins_myshixuns_path) %></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<% if myshixuns.present? %>
|
||||
<% myshixuns.each do |myshixun| %>
|
||||
<tr class="myshixun-item-<%= myshixun.id %>">
|
||||
<td><%= myshixun.id %></td>
|
||||
<td>
|
||||
<% current_task = myshixun.last_executable_task || myshixun.last_task %>
|
||||
<%= link_to "/myshixuns/#{myshixun.identifier}/stages/#{current_task.identifier}", target: '_blank' do %>
|
||||
<%= myshixun.identifier %>
|
||||
<% end %>
|
||||
</td>
|
||||
<td class="text-left">
|
||||
<%= link_to "/shixuns/#{myshixun.shixun.identifier}", target: '_blank' do %>
|
||||
<%= overflow_hidden_span myshixun.shixun.name, width: 280 %>
|
||||
<% end %>
|
||||
</td>
|
||||
<td><%= myshixun.shixun.user.real_name %></td>
|
||||
<td><%= finish_game_count.fetch(myshixun.id, 0) %>/<%= myshixun.shixun.challenges_count %></td>
|
||||
<td><%= total_score.fetch(myshixun.id, 0) %></td>
|
||||
<td>
|
||||
<%= link_to "/users/#{myshixun.user.login}", target: '_blank' do %>
|
||||
<%= overflow_hidden_span myshixun.user.real_name, width: 80 %>
|
||||
<% end %>
|
||||
</td>
|
||||
<td class="text-left"><%= overflow_hidden_span myshixun.user&.school_name, width: 150 %></td>
|
||||
<td><%= myshixun.created_at&.strftime('%Y-%m-%d %H:%M') %></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
<% else %>
|
||||
<%= render 'admins/shared/no_data_for_table' %>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<%= render partial: 'admins/shared/paginate', locals: { objects: myshixuns } %>
|
@ -1,10 +1,17 @@
|
||||
json.shixun_counts @shixuns_count
|
||||
json.shixun_list @shixuns do |shixun|
|
||||
json.shixun_id shixun.id
|
||||
json.identifier shixun.identifier
|
||||
json.shixun_name shixun.name
|
||||
json.myshixuns_count shixun.myshixuns_count
|
||||
json.school shixun.user&.school_name
|
||||
json.creator shixun.user&.full_name
|
||||
json.level level_to_s(shixun.trainee)
|
||||
end
|
||||
|
||||
json.shixuns do
|
||||
json.array! @shixuns do |s|
|
||||
json.shixun_id s.id
|
||||
json.shixun_name s.name
|
||||
json.shixun_user s.user.real_name
|
||||
json.shixun_user_count s.myshixuns_count
|
||||
end
|
||||
end
|
||||
json.tags @tags do |tag|
|
||||
json.tag_id tag.id
|
||||
json.tag_name tag.name
|
||||
end
|
||||
|
||||
json.shixuns_count @total_count
|
||||
json.search_tags @search_tags
|
@ -1,4 +1,4 @@
|
||||
json.status 0
|
||||
json.message "调分成功"
|
||||
json.work_score number_with_precision @work.work_score, 1
|
||||
json.challenge_score number_with_precision @work.final_score, 1
|
||||
json.work_score number_with_precision(@work.work_score, precision: 1)
|
||||
json.challenge_score number_with_precision(@work.final_score, precision: 1)
|
@ -0,0 +1,6 @@
|
||||
class MigratePollBankQuestion < ActiveRecord::Migration[5.2]
|
||||
def change
|
||||
ExerciseBankQuestion.where(question_type: 0, exercise_bank_id: ExerciseBank.where(container_type: 'Poll').pluck(:id)).update_all(question_type: 1)
|
||||
ExerciseBankQuestion.where(question_type: 1, exercise_bank_id: ExerciseBank.where(container_type: 'Poll').pluck(:id)).update_all(question_type: 2)
|
||||
end
|
||||
end
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Binary file not shown.
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Loading…
Reference in new issue