试题和试卷的后台审批

dev_jupyter
cxt 5 years ago
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

@ -9,41 +9,26 @@ class Admins::ItemAuthenticationsController < Admins::BaseController
end
def show
apply = ApplyAction.find params[:id]
@item = ItemBank.find apply.container_id
@item = ItemBank.find current_apply.container_id
end
def agree
Admins::ProfessionalAuths::AgreeApplyService.call(current_apply)
ActiveRecord::Base.transaction do
item = ItemBank.find current_apply.container_id
current_apply.update!(status: 1)
item.update!(public: 0)
end
render_success_js
end
def refuse
Admins::ProfessionalAuths::RefuseApplyService.call(current_apply, params)
render_success_js
end
def batch_agree
ApplyUserAuthentication.professional_auth.where(id: params[:ids]).each do |apply|
begin
Admins::ProfessionalAuths::AgreeApplyService.call(apply)
rescue => e
Util.logger_error(e)
end
end
render_ok
end
def revoke
Admins::ProfessionalAuths::RevokeApplyService.call(current_apply)
current_apply.update!(status: 2)
render_success_js
end
private
def current_apply
@_current_apply ||= ApplyUserAuthentication.professional_auth.find(params[:id])
@_current_apply ||= ApplyAction.find(params[:id])
end
end

@ -4,7 +4,7 @@ class ItemBank < ApplicationRecord
# item_type: 0 单选 1 多选 2 判断 3 填空 4 简答 5 实训 6 编程
belongs_to :user
belongs_to :sub_discipline
belongs_to :sub_discipline, optional: true
has_one :item_analysis, dependent: :destroy
has_many :item_choices, dependent: :destroy
@ -37,4 +37,16 @@ class ItemBank < ApplicationRecord
end
result
end
def difficulty_string
result = case difficulty
when 1
"简单"
when 2
"适中"
when 3
"困难"
end
result
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">&times;</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">&times;</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>

@ -11,6 +11,8 @@
<th width="16%">提交时间</th>
<% if !is_processed %>
<th width="16%">操作</th>
<% else %>
<th width="16%">审批结果</th>
<% end %>
</tr>
</thead>
@ -30,7 +32,7 @@
<td><%= raw [user.school_name.presence, user.department_name.presence].compact.join('<br/>') %></td>
<td>
<% if item.item_type == "PROGRAM" %>
<%= link_to item.name, "/questions/#{item.identifier}", target: "_blank" %>
<%= link_to item.name, "/problems/#{item.container&.identifier}/edit", target: "_blank" %>
<% else %>
<%= link_to item.name, admins_item_authentication_path(apply), remote: true %>
<% end %>
@ -40,12 +42,12 @@
<td><%= apply.updated_at.strftime('%Y-%m-%d %H:%M') %></td>
<td class="action-container">
<%= agree_link '同意', agree_admins_item_authentication_path(apply, element: ".item-authentication-#{apply.id}"), 'data-confirm': '确认审核通过?', 'data-disable-with': "提交中..." %>
<%= javascript_void_link('拒绝', class: 'action refuse-action',
data: {
toggle: 'modal', target: '.admin-common-refuse-modal', id: apply.id,
url: refuse_admins_item_authentication_path(apply, element: ".item-authentication-#{apply.id}")
}, 'data-disable-with': "拒绝中...") %>
<% if !is_processed %>
<%= agree_link '同意', agree_admins_item_authentication_path(apply, element: ".item-authentication-#{apply.id}"), 'data-confirm': '确认同意该审批?', 'data-disable-with': "提交中..." %>
<%= agree_link '拒绝', refuse_admins_item_authentication_path(apply, element: ".item-authentication-#{apply.id}"), 'data-confirm': '确认拒绝该审批?', 'data-disable-with': "拒绝中..." %>
<% else %>
<%= apply.status_text %>
<% end %>
</td>
</tr>
<% end %>

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

@ -75,8 +75,9 @@
<li><%= sidebar_item(admins_library_applies_path, '教学案例发布', icon: 'language', controller: 'admins-library_applies') %></li>
<li><%= sidebar_item(admins_project_package_applies_path, '众包需求发布', icon: 'joomla', controller: 'admins-project_package_applies') %></li>
<li><%= sidebar_item(admins_video_applies_path, '视频发布', icon: 'film', controller: 'admins-video_applies') %></li>
<li><%= sidebar_item(admins_item_authentications_path, '试题发布', icon: 'question', controller: 'admins-item_authentications') %></li>
<% end %>
<li><%= sidebar_item(admins_item_authentications_path, '试题发布', icon: 'question', controller: 'admins-item_authentications') %></li>
<li><%= sidebar_item(admins_examination_authentications_path, '试卷发布', icon: 'file-text-o', controller: 'admins-examination_authentications') %></li>
<% end %>
</li>
<li>

@ -1158,6 +1158,12 @@ Rails.application.routes.draw do
post :refuse
end
end
resources :examination_authentications, only: [:index] do
member do
post :agree
post :refuse
end
end
resources :shixuns, only: [:index,:destroy]
resources :shixun_settings, only: [:index,:update]
resources :shixun_feedback_messages, only: [:index]

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long
Loading…
Cancel
Save