parent
a4b485c542
commit
78354cb70e
@ -0,0 +1,22 @@
|
||||
$(document).on('turbolinks:load', function() {
|
||||
if ($('body.admins-examination-authentications-index-page').length > 0) {
|
||||
var $searchFrom = $('.examination-authentication-list-form');
|
||||
$searchFrom.find('select[name="status"]').val('pending');
|
||||
|
||||
$searchFrom.on('click', '.search-form-tab', function(){
|
||||
var $link = $(this);
|
||||
|
||||
$searchFrom.find('input[name="keyword"]').val('');
|
||||
$searchFrom.find('select[name="status"]').val('processed');
|
||||
|
||||
if($link.data('value') === 'processed'){
|
||||
$('.batch-action-container').hide();
|
||||
$searchFrom.find('.status-filter').show();
|
||||
} else {
|
||||
$('.batch-action-container').show();
|
||||
$searchFrom.find('.status-filter').hide();
|
||||
$searchFrom.find('select[name="status"]').val('pending');
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
@ -0,0 +1,30 @@
|
||||
class Admins::ExaminationAuthenticationsController < Admins::BaseController
|
||||
def index
|
||||
params[:status] ||= 'pending'
|
||||
params[:sort_direction] = params[:status] == 'pending' ? 'asc' : 'desc'
|
||||
|
||||
applies = Admins::ApplyItemBankQuery.call(params.merge(type: "ExaminationBank"))
|
||||
|
||||
@applies = paginate applies.preload(user: { user_extension: [:school, :department] })
|
||||
end
|
||||
|
||||
def agree
|
||||
ActiveRecord::Base.transaction do
|
||||
exam = ExaminationBank.find current_apply.container_id
|
||||
current_apply.update!(status: 1)
|
||||
exam.update!(public: 0)
|
||||
end
|
||||
render_success_js
|
||||
end
|
||||
|
||||
def refuse
|
||||
current_apply.update!(status: 2)
|
||||
render_success_js
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def current_apply
|
||||
@_current_apply ||= ApplyAction.find(params[:id])
|
||||
end
|
||||
end
|
@ -0,0 +1,30 @@
|
||||
<% define_admin_breadcrumbs do %>
|
||||
<% add_admin_breadcrumb('试卷审批') %>
|
||||
<% end %>
|
||||
|
||||
<div class="box search-form-container flex-column mb-0 pb-0 examination-authentication-list-form">
|
||||
<ul class="nav nav-tabs w-100 search-form-tabs">
|
||||
<li class="nav-item">
|
||||
<%= link_to '待审批', admins_examination_authentications_path(status: :pending), remote: true, 'data-value': 'pending',
|
||||
class: "nav-link search-form-tab #{params[:status] == 'pending' ? 'active' : ''}" %>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<%= link_to '已审批', admins_examination_authentications_path(status: :processed), remote: true, 'data-value': 'processed',
|
||||
class: "nav-link search-form-tab #{params[:status] != 'pending' ? 'active' : ''}" %>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<%= form_tag(admins_examination_authentications_path(unsafe_params), method: :get, class: 'form-inline search-form justify-content-end mt-3', remote: true) do %>
|
||||
<div class="form-group status-filter" style="<%= params[:status] != 'pending' ? '' : 'display: none;' %>">
|
||||
<label for="status">审核状态:</label>
|
||||
<% status_options = [['全部', 'processed'], ['已同意', 'agreed'], ['已拒绝', 'refused']] %>
|
||||
<%= select_tag(:status, options_for_select(status_options), class: 'form-control') %>
|
||||
</div>
|
||||
<%= text_field_tag(:keyword, params[:keyword], class: 'form-control col-sm-2 ml-3', placeholder: '姓名/学校/单位检索') %>
|
||||
<%= submit_tag('搜索', class: 'btn btn-primary ml-3', 'data-disable-with': '搜索中...') %>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
<div class="box admin-list-container examination-authentication-list-container">
|
||||
<%= render(partial: 'admins/examination_authentications/shared/list', locals: { applies: @applies }) %>
|
||||
</div>
|
@ -0,0 +1 @@
|
||||
$('.examination-authentication-list-container').html("<%= j( render partial: 'admins/examination_authentications/shared/list', locals: { applies: @applies } ) %>");
|
@ -0,0 +1,35 @@
|
||||
<div class="modal fade admin-item-show-modal" tabindex="-1" role="dialog" aria-hidden="true">
|
||||
<div class="modal-dialog modal-dialog-centered" role="document">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title">试题信息</h5>
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div class="mt-2">
|
||||
<p>题型:<%= item.type_string %></p>
|
||||
<p>难度:<%= item.difficulty_string %></p>
|
||||
</div>
|
||||
|
||||
<div class="mt-2">
|
||||
<p><%= item.name %></p>
|
||||
<% item.item_choices.each do |choice| %>
|
||||
<div class="form-check ml-3">
|
||||
<% if item.item_type == "MULTIPLE" %>
|
||||
<%= check_box_tag(:choice, true, choice.is_answer, class: 'form-check-input') %>
|
||||
<label class="form-check-label" for="choice"><%= choice.choice_text %></label>
|
||||
<% elsif item.item_type == "SINGLE" || item.item_type == "JUDGMENT" %>
|
||||
<%= radio_button_tag(:choice, true, choice.is_answer, class: 'form-check-input') %>
|
||||
<label class="form-check-label" for="choice"><%= choice.choice_text %></label>
|
||||
<% else %>
|
||||
答案:<%= choice.choice_text %>
|
||||
<% end %>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
@ -0,0 +1,54 @@
|
||||
<% is_processed = params[:status].to_s != 'pending' %>
|
||||
<table class="table table-hover text-center professional-authentication-list-table">
|
||||
<thead class="thead-light">
|
||||
<tr>
|
||||
<th width="4%">序号</th>
|
||||
<th width="8%">头像</th>
|
||||
<th width="18%">创建者</th>
|
||||
<th width="14%">学校</th>
|
||||
<th width="24%">试卷</th>
|
||||
<th width="16%">提交时间</th>
|
||||
<% if !is_processed %>
|
||||
<th width="16%">操作</th>
|
||||
<% else %>
|
||||
<th width="16%">审批结果</th>
|
||||
<% end %>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<% if applies.present? %>
|
||||
<% applies.each_with_index do |apply, index| %>
|
||||
<% user = apply.user %>
|
||||
<% exam = ExaminationBank.find apply.container_id %>
|
||||
<tr class="examination-authentication-item examination-authentication-<%= apply.id %>">
|
||||
<td><%= list_index_no((params[:page] || 1).to_i, index) %></td>
|
||||
<td>
|
||||
<%= link_to "/users/#{user.login}", class: 'examination-authentication-avatar', target: '_blank', data: { toggle: 'tooltip', title: '个人主页' } do %>
|
||||
<img src="/images/<%= url_to_avatar(user) %>" class="rounded-circle" width="40" height="40" />
|
||||
<% end %>
|
||||
</td>
|
||||
<td><%= user.real_name %></td>
|
||||
<td><%= raw [user.school_name.presence, user.department_name.presence].compact.join('<br/>') %></td>
|
||||
<td>
|
||||
<%= link_to exam.name, "/paperlibrary/see/#{exam.id}", target: "_blank" %>
|
||||
</td>
|
||||
|
||||
<td><%= apply.updated_at.strftime('%Y-%m-%d %H:%M') %></td>
|
||||
|
||||
<td class="action-container">
|
||||
<% if !is_processed %>
|
||||
<%= agree_link '同意', agree_admins_examination_authentication_path(apply, element: ".examination-authentication-#{apply.id}"), 'data-confirm': '确认同意该审批?', 'data-disable-with': "提交中..." %>
|
||||
<%= agree_link '拒绝', refuse_admins_examination_authentication_path(apply, element: ".examination-authentication-#{apply.id}"), 'data-confirm': '确认拒绝该审批?', 'data-disable-with': "拒绝中..." %>
|
||||
<% else %>
|
||||
<%= apply.status_text %>
|
||||
<% end %>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
<% else %>
|
||||
<%= render 'admins/shared/no_data_for_table' %>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<%= render partial: 'admins/shared/paginate', locals: { objects: applies } %>
|
@ -0,0 +1,2 @@
|
||||
$('.admin-modal-container').html("<%= j( render partial: 'admins/item_authentications/shared/item_show_modal', locals: { item: @item } ) %>");
|
||||
$('.modal.admin-item-show-modal').modal('show');
|
@ -0,0 +1,35 @@
|
||||
<div class="modal fade admin-item-show-modal" tabindex="-1" role="dialog" aria-hidden="true">
|
||||
<div class="modal-dialog modal-dialog-centered" role="document">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title">试题信息</h5>
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div class="mt-2">
|
||||
<p>题型:<%= item.type_string %></p>
|
||||
<p>难度:<%= item.difficulty_string %></p>
|
||||
</div>
|
||||
|
||||
<div class="mt-2">
|
||||
<p><%= item.name %></p>
|
||||
<% item.item_choices.each do |choice| %>
|
||||
<div class="form-check ml-3">
|
||||
<% if item.item_type == "MULTIPLE" %>
|
||||
<%= check_box_tag(:choice, true, choice.is_answer, class: 'form-check-input') %>
|
||||
<label class="form-check-label" for="choice"><%= choice.choice_text %></label>
|
||||
<% elsif item.item_type == "SINGLE" || item.item_type == "JUDGMENT" %>
|
||||
<%= radio_button_tag(:choice, true, choice.is_answer, class: 'form-check-input') %>
|
||||
<label class="form-check-label" for="choice"><%= choice.choice_text %></label>
|
||||
<% else %>
|
||||
答案:<%= choice.choice_text %>
|
||||
<% end %>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
@ -0,0 +1,2 @@
|
||||
$('.admin-modal-container').html("<%= j( render partial: 'admins/item_authentications/shared/item_show_modal', locals: { item: @item } ) %>");
|
||||
$('.modal.admin-item-show-modal').modal('show');
|
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.
Loading…
Reference in new issue