Merge branches 'dev_aliyun' and 'dev_item_bank' of https://bdgit.educoder.net/Hjqreturn/educoder into dev_item_bank

dev_jupyter
杨树明 5 years ago
commit 088406d1f1

@ -0,0 +1,65 @@
$(document).on('turbolinks:load', function() {
if ($('body.admins-disciplines-index-page').length > 0) {
// ============== 新建 ===============
var $modal = $('.modal.admin-create-discipline-modal');
var $form = $modal.find('form.admin-create-discipline-form');
var $nameInput = $form.find('input[name="name"]');
$form.validate({
errorElement: 'span',
errorClass: 'danger text-danger',
rules: {
name: {
required: true
}
}
});
// modal ready fire
$modal.on('show.bs.modal', function () {
$nameInput.val('');
});
$modal.on('click', '.submit-btn', function(){
$form.find('.error').html('');
if ($form.valid()) {
var url = $form.data('url');
$.ajax({
method: 'POST',
dataType: 'json',
url: url,
data: $form.serialize(),
success: function(){
$.notify({ message: '创建成功' });
$modal.modal('hide');
setTimeout(function(){
window.location.reload();
}, 500);
},
error: function(res){
var data = res.responseJSON;
$form.find('.error').html(data.message);
}
});
}
});
$(".discipline-list-container").on("change", '.discipline-source-form', function () {
var s_id = $(this).attr("data-id");
var s_value = $(this).val();
var s_name = $(this).attr("name");
var json = {};
json[s_name] = s_value;
$.ajax({
url: "/admins/disciplines/" + s_id,
type: "PUT",
dataType:'script',
data: json
});
});
}
});

@ -0,0 +1,31 @@
$(document).on('turbolinks:load', function() {
$('.admin-modal-container').on('show.bs.modal', '.modal.admin-edit-discipline-modal', function(){
var $modal = $('.modal.admin-edit-discipline-modal');
var $form = $modal.find('form.admin-edit-discipline-form');
$form.validate({
errorElement: 'span',
errorClass: 'danger text-danger',
rules: {
'discipline[name]': {
required: true,
maxlength: 20
}
}
});
$modal.on('click', '.submit-btn', function(){
$form.find('.error').html('');
var url = $form.attr('action');
if ($form.valid()) {
$.ajax({
method: 'PATCH',
dataType: 'script',
url: url,
data: $form.serialize()
});
}
});
});
});

@ -0,0 +1,31 @@
$(document).on('turbolinks:load', function() {
$('.admin-modal-container').on('show.bs.modal', '.modal.admin-edit-sub-discipline-modal', function(){
var $modal = $('.modal.admin-edit-sub-discipline-modal');
var $form = $modal.find('form.admin-edit-sub-discipline-form');
$form.validate({
errorElement: 'span',
errorClass: 'danger text-danger',
rules: {
'sub_discipline[name]': {
required: true,
maxlength: 20
}
}
});
$modal.on('click', '.submit-btn', function(){
$form.find('.error').html('');
var url = $form.attr('action');
if ($form.valid()) {
$.ajax({
method: 'PATCH',
dataType: 'script',
url: url,
data: $form.serialize()
});
}
});
});
});

@ -0,0 +1,31 @@
$(document).on('turbolinks:load', function() {
$('.admin-modal-container').on('show.bs.modal', '.modal.admin-edit-tag-discipline-modal', function(){
var $modal = $('.modal.admin-edit-tag-discipline-modal');
var $form = $modal.find('form.admin-edit-tag-discipline-form');
$form.validate({
errorElement: 'span',
errorClass: 'danger text-danger',
rules: {
'tag_discipline[name]': {
required: true,
maxlength: 20
}
}
});
$modal.on('click', '.submit-btn', function(){
$form.find('.error').html('');
var url = $form.attr('action');
if ($form.valid()) {
$.ajax({
method: 'PATCH',
dataType: 'script',
url: url,
data: $form.serialize()
});
}
});
});
});

@ -0,0 +1,65 @@
$(document).on('turbolinks:load', function() {
if ($('body.admins-sub-disciplines-index-page').length > 0) {
// ============== 新建 ===============
var $modal = $('.modal.admin-create-sub-discipline-modal');
var $form = $modal.find('form.admin-create-sub-discipline-form');
var $nameInput = $form.find('input[name="name"]');
$form.validate({
errorElement: 'span',
errorClass: 'danger text-danger',
rules: {
name: {
required: true
}
}
});
// modal ready fire
$modal.on('show.bs.modal', function () {
$nameInput.val('');
});
$modal.on('click', '.submit-btn', function(){
$form.find('.error').html('');
if ($form.valid()) {
var url = $form.data('url');
$.ajax({
method: 'POST',
dataType: 'json',
url: url,
data: $form.serialize(),
success: function(){
$.notify({ message: '创建成功' });
$modal.modal('hide');
setTimeout(function(){
window.location.reload();
}, 500);
},
error: function(res){
var data = res.responseJSON;
$form.find('.error').html(data.message);
}
});
}
});
$(".sub-discipline-list-container").on("change", '.sub-discipline-source-form', function () {
var s_id = $(this).attr("data-id");
var s_value = $(this).val();
var s_name = $(this).attr("name");
var json = {};
json[s_name] = s_value;
$.ajax({
url: "/admins/sub_disciplines/" + s_id,
type: "PUT",
dataType:'script',
data: json
});
});
}
});

@ -0,0 +1,65 @@
$(document).on('turbolinks:load', function() {
if ($('body.admins-tag-disciplines-index-page').length > 0) {
// ============== 新建 ===============
var $modal = $('.modal.admin-create-tag-discipline-modal');
var $form = $modal.find('form.admin-create-tag-discipline-form');
var $nameInput = $form.find('input[name="name"]');
$form.validate({
errorElement: 'span',
errorClass: 'danger text-danger',
rules: {
name: {
required: true
}
}
});
// modal ready fire
$modal.on('show.bs.modal', function () {
$nameInput.val('');
});
$modal.on('click', '.submit-btn', function(){
$form.find('.error').html('');
if ($form.valid()) {
var url = $form.data('url');
$.ajax({
method: 'POST',
dataType: 'json',
url: url,
data: $form.serialize(),
success: function(){
$.notify({ message: '创建成功' });
$modal.modal('hide');
setTimeout(function(){
window.location.reload();
}, 500);
},
error: function(res){
var data = res.responseJSON;
$form.find('.error').html(data.message);
}
});
}
});
$(".tag-discipline-list-container").on("change", '.tag-discipline-source-form', function () {
var s_id = $(this).attr("data-id");
var s_value = $(this).val();
var s_name = $(this).attr("name");
var json = {};
json[s_name] = s_value;
$.ajax({
url: "/admins/tag_disciplines/" + s_id,
type: "PUT",
dataType:'script',
data: json
});
});
}
});

@ -0,0 +1,49 @@
class Admins::DisciplinesController < Admins::BaseController
def index
@disciplines = Discipline.all
end
def create
name = params[:name].to_s.strip
return render_error('名称重复') if Discipline.where(name: name).exists?
Discipline.create!(name: name)
render_ok
end
def edit
@discipline = current_discipline
end
def update
if params[:discipline] && params[:discipline][:name].present?
name = params[:discipline][:name].to_s.strip
current_discipline.update_attributes!(name: name)
else
ActiveRecord::Base.transaction do
current_discipline.update_attributes!(setting_params)
current_discipline.sub_disciplines.each do |sub|
sub.tag_disciplines.each do |tag|
tag.update_attributes!(setting_params)
end
sub.update_attributes!(setting_params)
end
end
end
@disciplines = Discipline.all
end
def destroy
@discipline_id = params[:id]
current_discipline.destroy!
end
private
def current_discipline
@_current_discipline = Discipline.find params[:id]
end
def setting_params
params.permit(:shixun, :subject, :question)
end
end

@ -0,0 +1,52 @@
class Admins::SubDisciplinesController < Admins::BaseController
def index
@discipline = current_discipline
@sub_disciplines = current_discipline.sub_disciplines
end
def create
name = params[:name].to_s.strip
return render_error('名称重复') if current_discipline.sub_disciplines.where(name: name).exists?
SubDiscipline.create!(name: name, discipline_id: current_discipline.id)
render_ok
end
def edit
@sub_discipline = current_sub_discipline
end
def update
if params[:sub_discipline] && params[:sub_discipline][:name].present?
name = params[:sub_discipline][:name].to_s.strip
current_sub_discipline.update_attributes!(name: name)
else
ActiveRecord::Base.transaction do
current_sub_discipline.update_attributes!(setting_params)
current_sub_discipline.tag_disciplines.each do |tag|
tag.update_attributes!(setting_params)
end
end
end
@sub_disciplines = current_sub_discipline.discipline&.sub_disciplines
end
def destroy
@sub_discipline_id = params[:id]
current_sub_discipline.destroy!
end
private
def current_sub_discipline
@_current_sub_discipline = SubDiscipline.find params[:id]
end
def current_discipline
@_current_discipline = Discipline.find params[:discipline_id]
end
def setting_params
params.permit(:shixun, :subject, :question)
end
end

@ -0,0 +1,47 @@
class Admins::TagDisciplinesController < Admins::BaseController
def index
@sub_discipline = current_sub_discipline
@tag_disciplines = current_sub_discipline.tag_disciplines
end
def create
name = params[:name].to_s.strip
return render_error('名称重复') if current_sub_discipline.tag_disciplines.where(name: name).exists?
TagDiscipline.create!(name: name, sub_discipline_id: current_sub_discipline.id)
render_ok
end
def edit
@tag_discipline = current_tag_discipline
end
def update
if params[:tag_discipline] && params[:tag_discipline][:name].present?
name = params[:tag_discipline][:name].to_s.strip
current_tag_discipline.update_attributes!(name: name)
else
current_tag_discipline.update_attributes!(setting_params)
end
@tag_disciplines = current_tag_discipline.sub_discipline&.tag_disciplines
end
def destroy
@tag_discipline_id = params[:id]
current_tag_discipline.destroy!
end
private
def current_sub_discipline
@_current_sub_discipline = SubDiscipline.find params[:sub_discipline_id]
end
def current_tag_discipline
@_current_tag_discipline = TagDiscipline.find params[:id]
end
def setting_params
params.permit(:shixun, :subject, :question)
end
end

@ -0,0 +1,6 @@
class DisciplinesController < ApplicationController
def index
end
end

@ -0,0 +1,51 @@
class ExaminationBanksController < ApplicationController
before_action :require_login
def index
exams = ExaminationBankQuery.call(params)
@exams_count = exams.size
@exams = paginate exams.includes(:user, :examination_items)
end
def show
end
def create
ActiveRecord::Base.transaction do
exam = ExaminationBank.new(user: current_user)
# 保存试卷基础信息
exam = ExaminationBanks::SaveExaminationBankService.call(exam, form_params)
# 将试题篮中的试题发送到试卷,试卷的题目与试题独立
current_user.item_baskets.includes(:item_bank).each do |basket|
item = basket.item_bank
if item.present?
new_item = ExaminationItem.new(examination_bank: exam, item_bank: item, name: item.name, item_type: item.item_type,
difficulty: item.difficulty, score: basket.score, position: basket.position)
if new_item.save!
item.increment!(:quotes)
if item.item_choices.present?
item.item_choices.each do |choice|
new_item.examination_item_choices << ExaminationItemChoice.new(choice_text: choice.choice_text, is_answer: choice.is_answer)
end
end
end
end
end
current_user.item_baskets.destroy_all
end
render_ok
end
def edit
end
private
def form_params
params.permit(:discipline_id, :sub_discipline_id, :difficulty, :name, :duration, tag_discipline_id: [])
end
end

@ -5,6 +5,7 @@ class HackUserLastestCodesController < ApplicationController
before_action :update_user_hack_status, only: [:code_debug, :code_submit] before_action :update_user_hack_status, only: [:code_debug, :code_submit]
before_action :require_auth_identity, only: [:add_notes] before_action :require_auth_identity, only: [:add_notes]
before_action :require_manager_identity, only: [:show, :update_code, :restore_initial_code, :sync_code] before_action :require_manager_identity, only: [:show, :update_code, :restore_initial_code, :sync_code]
skip_before_action :check_sign, only: [:listen_result]
def show def show
@my_hack.update_attribute(:submit_status, 0) if @my_hack.submit_status == 1 @my_hack.update_attribute(:submit_status, 0) if @my_hack.submit_status == 1

@ -1,14 +1,58 @@
class LibrariesController < ApplicationController class ItemBanksController < ApplicationController
include PaginateHelper include PaginateHelper
before_action :require_login
before_action :find_item, except: [:index, :create]
before_action :edit_auth, only: [:update, :destroy, :set_public]
def index def index
default_sort('updated_at', 'desc') items = ItemBankQuery.call(params)
@items_count = items.size
@items = ItemBankQuery.call(params) @items = paginate items.includes(:item_analysis, :user)
@items = paginate courses.includes(:school, :students, :attachments, :homework_commons, teacher: :user_extension) @item_basket_ids = current_user.item_baskets.pluck(:item_bank_id)
end end
def create def create
item = ItemBank.new(user: current_user)
ItemBanks::SaveItemService.call(item, form_params)
render_ok
rescue ApplicationService::Error => ex
render_error(ex.message)
end
def edit
end
def update
ItemBanks::SaveItemService.call(@item, form_params)
render_ok
rescue ApplicationService::Error => ex
render_error(ex.message)
end
def destroy
@item.destroy!
render_ok
end
def set_public
tip_exception(-1, "该试题已公开") if @item.public?
@item.update_attributes!(public: 1)
render_ok
end end
private
def find_item
@item = ItemBank.find_by!(id: params[:id])
end
def edit_auth
current_user.admin_or_business? || @item.user == current_user
end
def form_params
params.permit(:discipline_id, :sub_discipline_id, :item_type, :difficulty, :name, :analysis, tag_discipline_id: [], choices: %i[choice_text is_answer])
end
end end

@ -0,0 +1,90 @@
class ItemBasketsController < ApplicationController
before_action :require_login
before_action :validate_score, only: [:set_score, :batch_set_score]
helper_method :current_basket
def index
@item_baskets = current_user.item_baskets
@single_questions = @item_baskets.where(item_type: "SINGLE")
@multiple_questions = @item_baskets.where(item_type: "MULTIPLE")
@judgement_questions = @item_baskets.where(item_type: "JUDGMENT")
@program_questions = @item_baskets.where(item_type: "PROGRAM")
end
def basket_list
@single_questions_count = current_user.item_baskets.where(item_type: "SINGLE").count
@multiple_questions_count = current_user.item_baskets.where(item_type: "MULTIPLE").count
@judgement_questions_count = current_user.item_baskets.where(item_type: "JUDGMENT").count
@completion_questions_count = current_user.item_baskets.where(item_type: "COMPLETION").count
@subjective_questions_count = current_user.item_baskets.where(item_type: "SUBJECTIVE").count
@practical_questions_count = current_user.item_baskets.where(item_type: "PRACTICAL").count
@program_questions_count = current_user.item_baskets.where(item_type: "PROGRAM").count
end
def create
ItemBaskets::SaveItemBasketService.call(current_user, create_params)
render_ok
rescue ApplicationService::Error => ex
render_error(ex.message)
end
def destroy
item = current_user.item_baskets.find_by!(item_bank_id: params[:id])
ActiveRecord::Base.transaction do
current_user.item_baskets.where(item_type: item.item_type).where("position > #{item.position}").update_all("position = position -1")
item.destroy!
end
render_ok
end
def delete_item_type
baskets = ItemBasket.where(item_type: params[:item_type])
baskets.destroy_all
render_ok
end
def set_score
current_basket.update_attributes!(score: params[:score])
@questions_score = current_user.item_baskets.where(item_type: current_basket.item_type).pluck(:score).sum
@all_score = current_user.item_baskets.pluck(:score).sum
end
def batch_set_score
current_user.item_baskets.where(item_type: params[:item_type]).update_all(score: params[:score])
@questions_score = current_user.item_baskets.where(item_type: params[:item_type]).pluck(:score).sum
@all_score = current_user.item_baskets.pluck(:score).sum
end
def adjust_position
same_items = current_user.item_baskets.where(item_type: current_basket.item_type)
max_position = same_items.size
tip_exception("position超出范围") unless params[:position].present? && params[:position].to_i <= max_position && params[:position].to_i >= 1
ActiveRecord::Base.transaction do
if params[:position].to_i > current_basket.position
same_items.where("position > #{current_basket.position} and position <= #{params[:position].to_i}").update_all("position=position-1")
current_basket.update_attributes!(position: params[:position])
elsif params[:position].to_i < current_basket.position
same_items.where("position < #{current_basket.position} and position >= #{params[:position].to_i}").update_all("position=position+1")
current_basket.update_attributes!(position: params[:position])
else
return normal_status(-1, "排序无变化")
end
end
render_ok
end
private
def create_params
params.permit(item_ids: [])
end
def current_basket
@_current_basket = current_user.item_baskets.find_by!(id: params[:id])
end
def validate_score
tip_exception("分值不能为空") unless params[:score].present?
tip_exception("分值需大于0") unless params[:score].to_f > 0
end
end

@ -0,0 +1,12 @@
class ExaminationBanks::SaveExamForm
include ActiveModel::Model
attr_accessor :discipline_id, :sub_discipline_id, :difficulty, :name, :duration, :tag_discipline_id
validates :discipline_id, presence: true
validates :sub_discipline_id, presence: true
validates :difficulty, presence: true, inclusion: {in: 1..3}, numericality: { only_integer: true }
validates :name, presence: true, length: { maximum: 60 }
validates :duration, numericality: { only_integer: true, greater_than: 0 }
end

@ -0,0 +1,33 @@
class ItemBanks::SaveItemForm
include ActiveModel::Model
attr_accessor :discipline_id, :sub_discipline_id, :item_type, :difficulty, :name, :analysis, :tag_discipline_id, :choices
validates :discipline_id, presence: true
validates :sub_discipline_id, presence: true
validates :item_type, presence: true, inclusion: {in: %W(SINGLE MULTIPLE JUDGMENT COMPLETION SUBJECTIVE PRACTICAL PROGRAM)}
validates :difficulty, presence: true, inclusion: {in: 1..3}, numericality: { only_integer: true }
validates :name, presence: true, length: { maximum: 1000 }
validates :analysis, length: { maximum: 1000 }
def validate!
super
return unless errors.blank?
choices.each { |item| SubForm.new(item).validate! } if %W(SINGLE MULTIPLE JUDGMENT).include?(item_type)
return unless errors.blank?
if [0, 2].include?(item_type) && choices.pluck(:is_answer).select{|item| item == 1}.length > 1
raise("正确答案只能有一个")
elsif item_type == 1 && choices.pluck(:is_answer).select{|item| item == 1}.length <= 1
raise("多选题至少有两个正确答案")
end
end
class SubForm
include ActiveModel::Model
attr_accessor :choice_text, :is_answer
validates :choice_text, presence: true, length: { maximum: 100 }
validates :is_answer, presence: true, inclusion: {in: 0..1}, numericality: { only_integer: true }
end
end

@ -0,0 +1,7 @@
class Discipline < ApplicationRecord
has_many :sub_disciplines, dependent: :destroy
has_many :shixun_sub_disciplines, -> { where("shixun = 1") }, class_name: "SubDiscipline"
has_many :subject_sub_disciplines, -> { where("subject = 1") }, class_name: "SubDiscipline"
has_many :question_sub_disciplines, -> { where("question = 1") }, class_name: "SubDiscipline"
end

@ -0,0 +1,17 @@
class ExaminationBank < ApplicationRecord
belongs_to :user
belongs_to :sub_discipline
has_many :tag_discipline_containers, as: :container, dependent: :destroy
has_many :tag_disciplines, through: :tag_discipline_containers
has_many :examination_items, dependent: :destroy
def question_count
examination_items.size
end
def total_score
examination_items.pluck(:score).sum
end
end

@ -0,0 +1,6 @@
class ExaminationItem < ApplicationRecord
belongs_to :examination_bank, touch: true
belongs_to :item_bank, optional: true
has_many :examination_item_choices, dependent: :destroy
end

@ -0,0 +1,3 @@
class ExaminationItemChoice < ApplicationRecord
belongs_to :examination_item
end

@ -1,11 +1,18 @@
class ItemBank < ApplicationRecord class ItemBank < ApplicationRecord
# difficulty: 1 简单 2 适中 3 困难 # difficulty: 1 简单 2 适中 3 困难
# item_type: 0 单选 1 多选 2 判断 3 填空 4 简答 5 实训 6 编程
enum item_type: { SINGLE: 0, MULTIPLE: 1, JUDGMENT: 2, COMPLETION: 3, SUBJECTIVE: 4, PRACTICAL: 5, PROGRAM: 6 } enum item_type: { SINGLE: 0, MULTIPLE: 1, JUDGMENT: 2, COMPLETION: 3, SUBJECTIVE: 4, PRACTICAL: 5, PROGRAM: 6 }
# item_type: 0 单选 1 多选 2 判断 3 填空 4 简答 5 实训 6 编程
belongs_to :user belongs_to :user
belongs_to :sub_discipline
has_one :item_analysis, dependent: :destroy has_one :item_analysis, dependent: :destroy
has_many :item_choices, dependent: :destroy has_many :item_choices, dependent: :destroy
has_many :item_baskets, dependent: :destroy has_many :item_baskets, dependent: :destroy
has_many :tag_discipline_containers, as: :container, dependent: :destroy
has_many :tag_disciplines, through: :tag_discipline_containers
def analysis
item_analysis&.analysis
end
end end

@ -1,4 +1,14 @@
class ItemBasket < ApplicationRecord class ItemBasket < ApplicationRecord
enum item_type: { SINGLE: 0, MULTIPLE: 1, JUDGMENT: 2, COMPLETION: 3, SUBJECTIVE: 4, PRACTICAL: 5, PROGRAM: 6 }
belongs_to :item_bank belongs_to :item_bank
belongs_to :user belongs_to :user
def all_score
User.current.item_baskets.map(&:score).sum
end
def question_count
User.current.item_baskets.size
end
end end

@ -0,0 +1,8 @@
class SubDiscipline < ApplicationRecord
belongs_to :discipline
has_many :tag_disciplines, dependent: :destroy
has_many :shixun_tag_disciplines, -> { where("shixun = 1") }, class_name: "TagDiscipline"
has_many :subject_tag_disciplines, -> { where("subject = 1") }, class_name: "TagDiscipline"
has_many :question_tag_disciplines, -> { where("question = 1") }, class_name: "TagDiscipline"
end

@ -0,0 +1,7 @@
class TagDiscipline < ApplicationRecord
belongs_to :sub_discipline
def discipline
sub_discipline&.discipline
end
end

@ -0,0 +1,5 @@
class TagDisciplineContainer < ApplicationRecord
belongs_to :tag_discipline
belongs_to :container, polymorphic: true, optional: true
end

@ -153,6 +153,10 @@ class User < ApplicationRecord
has_many :hacks, dependent: :destroy has_many :hacks, dependent: :destroy
has_many :hack_user_lastest_codes, dependent: :destroy has_many :hack_user_lastest_codes, dependent: :destroy
# 题库
has_many :item_banks, dependent: :destroy
has_many :item_baskets, -> { order("item_baskets.position ASC") }, dependent: :destroy
# Groups and active users # Groups and active users
scope :active, lambda { where(status: STATUS_ACTIVE) } scope :active, lambda { where(status: STATUS_ACTIVE) }

@ -0,0 +1,32 @@
class ExaminationBankQuery < ApplicationQuery
include CustomSortable
attr_reader :params
sort_columns :updated_at, default_by: :updated_at, default_direction: :desc, default_table: 'examination_banks'
def initialize(params)
@params = params
end
def call
if params[:public].to_i == 1
exams = ExaminationBank.where(public: 1)
elsif params[:public].to_i == 0
exams = ExaminationBank.where(user_id: User.current.id)
end
if params[:tag_discipline_id].present?
exams = exams.joins(:tag_discipline_containers).where(tag_discipline_containers: {tag_discipline_id: params[:tag_discipline_id]})
elsif params[:sub_discipline_id].present?
exams = exams.where(sub_discipline_id: params[:sub_discipline_id])
elsif params[:discipline_id].present?
exams = exams.joins(:sub_discipline).where(sub_disciplines: {discipline_id: params[:discipline_id]})
end
exams = exams.where(difficulty: params[:difficulty].to_i) if params[:difficulty].present?
exams = exams.where("name like ?", "%#{params[:keyword].strip}%") if params[:keyword].present?
custom_sort(exams, params[:sort_by], params[:sort_direction])
end
end

@ -0,0 +1,33 @@
class ItemBankQuery < ApplicationQuery
include CustomSortable
attr_reader :params
sort_columns :updated_at, default_by: :updated_at, default_direction: :desc, default_table: 'item_banks'
def initialize(params)
@params = params
end
def call
if params[:public].to_i == 1
items = ItemBank.where(public: 1)
elsif params[:public].to_i == 0
items = ItemBank.where(user_id: User.current.id)
end
if params[:tag_discipline_id].present?
items = items.joins(:tag_discipline_containers).where(tag_discipline_containers: {tag_discipline_id: params[:tag_discipline_id]})
elsif params[:sub_discipline_id].present?
items = items.where(sub_discipline_id: params[:sub_discipline_id])
elsif params[:discipline_id].present?
items = items.joins(:sub_discipline).where(sub_disciplines: {discipline_id: params[:discipline_id]})
end
items = items.where(item_type: params[:item_type].to_i) if params[:item_type].present?
items = items.where(difficulty: params[:difficulty].to_i) if params[:difficulty].present?
items = items.where("name like ?", "%#{params[:keyword].strip}%") if params[:keyword].present?
custom_sort(items, params[:sort_by], params[:sort_direction])
end
end

@ -0,0 +1,30 @@
class ExaminationBanks::SaveExaminationBankService < ApplicationService
attr_reader :exam, :params
def initialize(exam, params)
@exam = exam
@params = params
end
def call
ExaminationBanks::SaveExamForm.new(params).validate!
exam.name = params[:name].to_s.strip
exam.difficulty = params[:difficulty]
exam.duration = params[:duration]
exam.sub_discipline_id = params[:sub_discipline_id]
exam.save!
# 知识点的创建
new_tag_discipline_ids = params[:tag_discipline_id] || []
old_tag_discipline_ids = exam.tag_discipline_containers.pluck(:tag_discipline_id)
delete_tag_discipline_ids = old_tag_discipline_ids - new_tag_discipline_ids
create_tag_discipline_ids = new_tag_discipline_ids - old_tag_discipline_ids
exam.tag_discipline_containers.where(tag_discipline_id: delete_tag_discipline_ids).destroy_all
create_tag_discipline_ids.each do |tag_id|
exam.tag_discipline_containers << TagDisciplineContainer.new(tag_discipline_id: tag_id)
end
exam
end
end

@ -0,0 +1,58 @@
class ItemBanks::SaveItemService < ApplicationService
attr_reader :item, :params
def initialize(item, params)
@item = item
@params = params
end
def call
new_record = item.new_record?
raise("不能更改题型") if !new_record && item.item_type != params[:item_type]
ItemBanks::SaveItemForm.new(params).validate!
ActiveRecord::Base.transaction do
item.item_type = params[:item_type] if new_record
item.difficulty = params[:difficulty]
item.sub_discipline_id = params[:sub_discipline_id]
item.name = params[:name].to_s.strip
item.save!
analysis = item.item_analysis || ItemAnalysis.new(item_bank_id: item.id)
analysis.analysis = params[:analysis].blank? ? nil : params[:analysis].strip
analysis.save
# 知识点的创建
new_tag_discipline_ids = params[:tag_discipline_id]
old_tag_discipline_ids = item.tag_discipline_containers.pluck(:tag_discipline_id)
delete_tag_discipline_ids = old_tag_discipline_ids - new_tag_discipline_ids
create_tag_discipline_ids = new_tag_discipline_ids - old_tag_discipline_ids
item.tag_discipline_containers.where(tag_discipline_id: delete_tag_discipline_ids).destroy_all
create_tag_discipline_ids.each do |tag_id|
item.tag_discipline_containers << TagDisciplineContainer.new(tag_discipline_id: tag_id)
end
# 选项的创建
if %W(SINGLE MULTIPLE JUDGMENT).include?(item.item_type)
old_choices = item.item_choices
new_choices = params[:choices]
new_choices.each_with_index do |choice, index|
choice_item = old_choices[index] || ItemChoice.new(item_bank_id: item.id)
choice_item.choice_text = choice[:choice_text]
choice_item.is_answer = choice[:is_answer]
choice_item.save!
end
if old_choices.length > new_choices.length
old_choices[new_choices.length..(old_choices.length-1)].each do |old_choice|
old_choice.destroy
end
end
end
end
item
end
end

@ -0,0 +1,47 @@
class ItemBaskets::SaveItemBasketService < ApplicationService
attr_reader :user, :params
def initialize(user, params)
@user = user
@params = params
end
def call
raise("请选择试题") if params[:item_ids].blank?
# 只能选用公共题库或是自己的题库
items = ItemBank.where(public: 1).or(ItemBank.where(user_id: user.id))
# 已选到过试题篮的不重复选用
item_ids = params[:item_ids] - user.item_baskets.pluck(:item_bank_id)
items.where(id: item_ids).each do |item|
new_item = ItemBasket.new(user_id: user.id, item_bank_id: item.id, item_type: item.item_type)
new_item.score = item_score item.item_type
new_item.position = item_position item.item_type
new_item.save!
end
end
private
def item_score item_type
if user.item_baskets.where(item_type: item_type).last.present?
score = user.item_baskets.where(item_type: item_type).last.score
else
score =
case item_type
when 0, 1, 2
5
when 6
10
else
5
end
end
score
end
def item_position item_type
user.item_baskets.where(item_type: item_type).last&.position.to_i + 1
end
end

@ -0,0 +1,2 @@
$.notify({ message: '删除成功' });
$(".discipline-item-<%= @discipline_id %>").remove();

@ -0,0 +1,2 @@
$('.admin-modal-container').html("<%= j( render partial: 'admins/disciplines/shared/edit_discipline_modal', locals: { discipline: @discipline } ) %>");
$('.modal.admin-edit-discipline-modal').modal('show');

@ -0,0 +1,13 @@
<% define_admin_breadcrumbs do %>
<% add_admin_breadcrumb('课程方向', admins_disciplines_path) %>
<% end %>
<div class="box search-form-container discipline-list-form">
<%= javascript_void_link '新增', class: 'btn btn-primary', data: { toggle: 'modal', target: '.admin-create-discipline-modal' } %>
</div>
<div class="box admin-list-container discipline-list-container">
<%= render(partial: 'admins/disciplines/shared/list') %>
</div>
<%= render 'admins/disciplines/shared/create_discipline_modal' %>

@ -0,0 +1,28 @@
<div class="modal fade admin-create-discipline-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">
<form class="admin-create-discipline-form" data-url="<%= admins_disciplines_path %>">
<div class="form-group d-flex">
<label for="new_mirror_id" class="col-form-label">名称:</label>
<div class="w-75 d-flex flex-column">
<%= text_field_tag(:name, nil, class: 'form-control', placeholder: '请输入名称') %>
</div>
</div>
<div class="error text-danger"></div>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">取消</button>
<button type="button" class="btn btn-primary submit-btn">确认</button>
</div>
</div>
</div>
</div>

@ -0,0 +1,23 @@
<div class="modal fade admin-edit-discipline-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">
<%= simple_form_for([:admins, discipline], html: { class: 'admin-edit-discipline-form' }, defaults: { wrapper_html: { class: 'offset-md-1 col-md-10' } }) do |f| %>
<%= f.input :name, as: :string, label: '名称' %>
<div class="error text-danger"></div>
<% end %>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">取消</button>
<button type="button" class="btn btn-primary submit-btn">确认</button>
</div>
</div>
</div>
</div>

@ -0,0 +1,33 @@
<table class="table table-hover text-center discipline-list-table">
<thead class="thead-light">
<tr>
<th width="6%">序号</th>
<th width="54%" class="text-left">课程方向</th>
<th width="8%">实践课程</th>
<th width="8%">实训</th>
<th width="8%">题库</th>
<th width="16%">操作</th>
</tr>
</thead>
<tbody>
<% if @disciplines.present? %>
<% @disciplines.each_with_index do |discipline, index| %>
<tr class="discipline-item discipline-item-<%= discipline.id %>">
<td><%= index + 1 %></td>
<td class="text-left">
<span><%= link_to discipline.name, admins_sub_disciplines_path(discipline_id: discipline), :title => discipline.name %></span>
</td>
<td><%= check_box_tag :subject,!discipline.subject,discipline.subject,remote:true,data:{id:discipline.id},class:"discipline-source-form" %></td>
<td><%= check_box_tag :shixun,!discipline.shixun,discipline.shixun,remote:true,data:{id:discipline.id},class:"discipline-source-form" %></td>
<td><%= check_box_tag :question,!discipline.question,discipline.question,remote:true,data:{id:discipline.id},class:"discipline-source-form" %></td>
<td>
<%= link_to '编辑', edit_admins_discipline_path(discipline), remote: true, class: 'action' %>
<%= delete_link '删除', admins_discipline_path(discipline, element: ".discipline-item-#{discipline.id}"), class: 'delete-discipline-action' %>
</td>
</tr>
<% end %>
<% else %>
<%= render 'admins/shared/no_data_for_table' %>
<% end %>
</tbody>
</table>

@ -0,0 +1,2 @@
$('.modal.admin-edit-discipline-modal').modal("hide");
$(".discipline-list-container").html("<%= j(render :partial => 'admins/disciplines/shared/list') %>");

@ -38,6 +38,8 @@
<% end %> <% end %>
</li> </li>
<li><%= sidebar_item(admins_disciplines_path, '课程体系', icon: 'sitemap', controller: 'admins-disciplines') %></li>
<li> <li>
<%= sidebar_item_group('#course-submenu', '课堂管理', icon: 'book') do %> <%= sidebar_item_group('#course-submenu', '课堂管理', icon: 'book') do %>
<li><%= sidebar_item(admins_course_lists_path, '课程列表', icon: 'list', controller: 'admins-course_lists') %></li> <li><%= sidebar_item(admins_course_lists_path, '课程列表', icon: 'list', controller: 'admins-course_lists') %></li>

@ -0,0 +1,2 @@
$.notify({ message: '删除成功' });
$(".sub-discipline-item-<%= @sub_discipline_id %>").remove();

@ -0,0 +1,2 @@
$('.admin-modal-container').html("<%= j( render partial: 'admins/sub_disciplines/shared/edit_sub_discipline_modal', locals: { sub_discipline: @sub_discipline } ) %>");
$('.modal.admin-edit-sub-discipline-modal').modal('show');

@ -0,0 +1,14 @@
<% define_admin_breadcrumbs do %>
<% add_admin_breadcrumb('课程方向', admins_disciplines_path) %>
<% add_admin_breadcrumb(@discipline.name) %>
<% end %>
<div class="box search-form-container sub-discipline-list-form">
<%= javascript_void_link '新增', class: 'btn btn-primary', data: { toggle: 'modal', target: '.admin-create-sub-discipline-modal' } %>
</div>
<div class="box admin-list-container sub-discipline-list-container">
<%= render(partial: 'admins/sub_disciplines/shared/list') %>
</div>
<%= render 'admins/sub_disciplines/shared/create_sub_discipline_modal' %>

@ -0,0 +1,28 @@
<div class="modal fade admin-create-sub-discipline-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">
<form class="admin-create-sub-discipline-form" data-url="<%= admins_sub_disciplines_path(discipline_id: @discipline) %>">
<div class="form-group d-flex">
<label for="new_mirror_id" class="col-form-label">名称:</label>
<div class="w-75 d-flex flex-column">
<%= text_field_tag(:name, nil, class: 'form-control', placeholder: '请输入名称') %>
</div>
</div>
<div class="error text-danger"></div>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">取消</button>
<button type="button" class="btn btn-primary submit-btn">确认</button>
</div>
</div>
</div>
</div>

@ -0,0 +1,23 @@
<div class="modal fade admin-edit-sub-discipline-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">
<%= simple_form_for([:admins, sub_discipline], html: { class: 'admin-edit-sub-discipline-form' }, defaults: { wrapper_html: { class: 'offset-md-1 col-md-10' } }) do |f| %>
<%= f.input :name, as: :string, label: '名称' %>
<div class="error text-danger"></div>
<% end %>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">取消</button>
<button type="button" class="btn btn-primary submit-btn">确认</button>
</div>
</div>
</div>
</div>

@ -0,0 +1,33 @@
<table class="table table-hover text-center sub-discipline-list-table">
<thead class="thead-light">
<tr>
<th width="6%">序号</th>
<th width="54%" class="text-left">课程</th>
<th width="8%">实践课程</th>
<th width="8%">实训</th>
<th width="8%">题库</th>
<th width="16%">操作</th>
</tr>
</thead>
<tbody>
<% if @sub_disciplines.present? %>
<% @sub_disciplines.each_with_index do |sub, index| %>
<tr class="sub-discipline-item sub-discipline-item-<%= sub.id %>">
<td><%= index + 1 %></td>
<td class="text-left">
<span><%= link_to sub.name, admins_tag_disciplines_path(sub_discipline_id: sub), :title => sub.name %></span>
</td>
<td><%= check_box_tag :subject,!sub.subject,sub.subject,disabled:!sub.discipline&.subject,remote:true,data:{id:sub.id},class:"sub-discipline-source-form" %></td>
<td><%= check_box_tag :shixun,!sub.shixun,sub.shixun,disabled:!sub.discipline&.shixun,remote:true,data:{id:sub.id},class:"sub-discipline-source-form" %></td>
<td><%= check_box_tag :question,!sub.question,sub.question,disabled:!sub.discipline&.question,remote:true,data:{id:sub.id},class:"sub-discipline-source-form" %></td>
<td>
<%= link_to '编辑', edit_admins_sub_discipline_path(sub), remote: true, class: 'action' %>
<%= delete_link '删除', admins_sub_discipline_path(sub, element: ".sub-discipline-item-#{sub.id}"), class: 'delete-sub-discipline-action' %>
</td>
</tr>
<% end %>
<% else %>
<%= render 'admins/shared/no_data_for_table' %>
<% end %>
</tbody>
</table>

@ -0,0 +1,2 @@
$('.modal.admin-edit-sub-discipline-modal').modal("hide");
$(".sub-discipline-list-container").html("<%= j(render :partial => 'admins/sub_disciplines/shared/list') %>");

@ -0,0 +1,2 @@
$.notify({ message: '删除成功' });
$(".tag-discipline-item-<%= @tag_discipline_id %>").remove();

@ -0,0 +1,2 @@
$('.admin-modal-container').html("<%= j( render partial: 'admins/tag_disciplines/shared/edit_tag_discipline_modal', locals: { tag_discipline: @tag_discipline } ) %>");
$('.modal.admin-edit-tag-discipline-modal').modal('show');

@ -0,0 +1,15 @@
<% define_admin_breadcrumbs do %>
<% add_admin_breadcrumb('课程方向', admins_disciplines_path) %>
<% add_admin_breadcrumb(@sub_discipline&.discipline&.name, admins_sub_disciplines_path(discipline_id: @sub_discipline&.discipline_id)) %>
<% add_admin_breadcrumb(@sub_discipline.name) %>
<% end %>
<div class="box search-form-container tag-discipline-list-form">
<%= javascript_void_link '新增', class: 'btn btn-primary', data: { toggle: 'modal', target: '.admin-create-tag-discipline-modal' } %>
</div>
<div class="box admin-list-container tag-discipline-list-container">
<%= render(partial: 'admins/tag_disciplines/shared/list') %>
</div>
<%= render 'admins/tag_disciplines/shared/create_tag_discipline_modal' %>

@ -0,0 +1,28 @@
<div class="modal fade admin-create-tag-discipline-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">
<form class="admin-create-tag-discipline-form" data-url="<%= admins_tag_disciplines_path(sub_discipline_id: @sub_discipline) %>">
<div class="form-group d-flex">
<label for="new_mirror_id" class="col-form-label">名称:</label>
<div class="w-75 d-flex flex-column">
<%= text_field_tag(:name, nil, class: 'form-control', placeholder: '请输入名称') %>
</div>
</div>
<div class="error text-danger"></div>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">取消</button>
<button type="button" class="btn btn-primary submit-btn">确认</button>
</div>
</div>
</div>
</div>

@ -0,0 +1,23 @@
<div class="modal fade admin-edit-tag-discipline-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">
<%= simple_form_for([:admins, tag_discipline], html: { class: 'admin-edit-tag-discipline-form' }, defaults: { wrapper_html: { class: 'offset-md-1 col-md-10' } }) do |f| %>
<%= f.input :name, as: :string, label: '名称' %>
<div class="error text-danger"></div>
<% end %>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">取消</button>
<button type="button" class="btn btn-primary submit-btn">确认</button>
</div>
</div>
</div>
</div>

@ -0,0 +1,40 @@
<table class="table table-hover text-center tag-discipline-list-table">
<thead class="thead-light">
<tr>
<th width="6%">序号</th>
<th width="54%" class="text-left">知识点</th>
<th width="8%">实践课程</th>
<th width="8%">实训</th>
<th width="8%">题库</th>
<th width="16%">操作</th>
</tr>
</thead>
<tbody>
<% if @tag_disciplines.present? %>
<% @tag_disciplines.each_with_index do |tag, index| %>
<tr class="tag-discipline-item tag-discipline-item-<%= tag.id %>">
<td><%= index + 1 %></td>
<td class="text-left"><%= tag.name %></td>
<td>
<% disabled = !(tag.sub_discipline&.subject && tag.discipline&.subject) %>
<%= check_box_tag :subject,!tag.subject,tag.subject,disabled:disabled,remote:true,data:{id:tag.id},class:"tag-discipline-source-form" %>
</td>
<td>
<% disabled = !(tag.sub_discipline&.shixun && tag.discipline&.shixun) %>
<%= check_box_tag :shixun,!tag.shixun,tag.shixun,disabled:disabled,remote:true,data:{id:tag.id},class:"tag-discipline-source-form" %>
</td>
<td>
<% disabled = !(tag.sub_discipline&.question && tag.discipline&.question) %>
<%= check_box_tag :question,!tag.question,tag.question,disabled:disabled,remote:true,data:{id:tag.id},class:"tag-discipline-source-form" %>
</td>
<td>
<%= link_to '编辑', edit_admins_tag_discipline_path(tag), remote: true, class: 'action' %>
<%= delete_link '删除', admins_tag_discipline_path(tag, element: ".tag-discipline-item-#{tag.id}"), class: 'delete-tag-discipline-action' %>
</td>
</tr>
<% end %>
<% else %>
<%= render 'admins/shared/no_data_for_table' %>
<% end %>
</tbody>
</table>

@ -0,0 +1,2 @@
$('.modal.admin-edit-tag-discipline-modal').modal("hide");
$(".tag-discipline-list-container").html("<%= j(render :partial => 'admins/tag_disciplines/shared/list') %>");

@ -0,0 +1,35 @@
case params[:source]
when 'subject'
disciplines = Discipline.where(subject: 1).includes(subject_sub_disciplines: :subject_tag_disciplines)
json.disciplines disciplines do |dis|
json.(dis, :id, :name)
json.sub_disciplines dis.subject_sub_disciplines do |sub|
json.(sub, :id, :name)
json.tag_disciplines sub.subject_tag_disciplines do |tag|
json.(tag, :id, :name)
end
end
end
when 'shixun'
disciplines = Discipline.where(shixun: 1).includes(shixun_sub_disciplines: :shixun_tag_disciplines)
json.disciplines disciplines do |dis|
json.(dis, :id, :name)
json.sub_disciplines dis.shixun_sub_disciplines do |sub|
json.(sub, :id, :name)
json.tag_disciplines sub.shixun_tag_disciplines do |tag|
json.(tag, :id, :name)
end
end
end
when 'question'
disciplines = Discipline.where(question: 1).includes(question_sub_disciplines: :question_tag_disciplines)
json.disciplines disciplines do |dis|
json.(dis, :id, :name)
json.sub_disciplines dis.question_sub_disciplines do |sub|
json.(sub, :id, :name)
json.tag_disciplines sub.question_tag_disciplines do |tag|
json.(tag, :id, :name)
end
end
end
end

@ -0,0 +1,11 @@
json.exams @exams.each do |exam|
json.(exam, :id, :name, :difficulty, :quotes)
json.question_count exam.question_count
json.total_score exam.total_score
json.update_time exam.updated_at&.strftime("%Y-%m-%d %H:%M")
json.author do
json.login exam.user&.login
json.name exam.user&.full_name
end
end
json.exam_count @exams_count

@ -0,0 +1,6 @@
json.(item, :id, :name, :item_type, :difficulty, :public, :quotes)
json.analysis item.analysis
json.choices item.item_choices do |choice|
json.choice_text choice.choice_text
json.is_answer choice.is_answer
end

@ -0,0 +1,15 @@
json.discipline do
json.(@item.sub_discipline&.discipline, :id, :name)
end
json.sub_discipline do
json.(@item.sub_discipline, :id, :name)
end
json.tag_disciplines @item.tag_disciplines do |tag|
json.(tag, :id, :name)
end
json.(@item, :id, :name, :item_type, :difficulty)
json.analysis @item.analysis
json.choices @item.item_choices do |choice|
json.choice_text choice.choice_text
json.is_answer choice.is_answer
end

@ -0,0 +1,10 @@
json.items @items.each do |item|
json.partial! "item_banks/item", locals: {item: item}
json.update_time item.updated_at&.strftime("%Y-%m-%d %H:%M")
json.choosed @item_basket_ids.include?(item.id)
json.author do
json.login item.user&.login
json.name item.user&.full_name
end
end
json.items_count @items_count

@ -0,0 +1,7 @@
json.single_questions_count @single_questions_count
json.multiple_questions_count @multiple_questions_count
json.judgement_questions_count @judgement_questions_count
json.completion_questions_count @completion_questions_count
json.subjective_questions_count @subjective_questions_count
json.practical_questions_count @practical_questions_count
json.program_questions_count @program_questions_count

@ -0,0 +1,3 @@
json.status 0
json.questions_score @questions_score
json.all_score @all_score

@ -0,0 +1,38 @@
json.single_questions do
json.questions @single_questions.each do |question|
json.(question, :id, :position, :score, :item_type)
json.partial! "item_banks/item", locals: {item: question.item_bank}
end
json.questions_score @single_questions.map(&:score).sum
json.questions_count @single_questions.size
end
json.multiple_questions do
json.questions @multiple_questions.each do |question|
json.(question, :id, :position, :score, :item_type)
json.partial! "item_banks/item", locals: {item: question.item_bank}
end
json.questions_score @multiple_questions.map(&:score).sum
json.questions_count @multiple_questions.size
end
json.judgement_questions do
json.questions @judgement_questions.each do |question|
json.(question, :id, :position, :score, :item_type)
json.partial! "item_banks/item", locals: {item: question.item_bank}
end
json.questions_score @judgement_questions.map(&:score).sum
json.questions_count @judgement_questions.size
end
json.program_questions do
json.questions @program_questions.each do |question|
json.(question, :id, :position, :score, :item_type)
json.partial! "item_banks/item", locals: {item: question.item_bank}
end
json.questions_score @program_questions.map(&:score).sum
json.questions_count @program_questions.size
end
json.all_score @item_baskets.map(&:score).sum
json.all_questions_count @item_baskets.size

@ -0,0 +1,3 @@
json.status 0
json.questions_score @questions_score
json.all_score @all_score

@ -54,10 +54,30 @@ Rails.application.routes.draw do
end end
end end
resources :disciplines, only: [:index]
resources :item_banks do resources :item_banks do
member do
post :set_public
end
end
resources :item_baskets do
collection do
get :basket_list
delete :delete_item_type
post :batch_set_score
end
member do
post :set_score
post :adjust_position
end
end
resources :examination_banks do
end end
resources :hacks, path: :problems, param: :identifier do resources :hacks, path: :problems, param: :identifier do
collection do collection do
@ -1250,6 +1270,10 @@ Rails.application.routes.draw do
resources :courses, only: [:index, :destroy, :update] resources :courses, only: [:index, :destroy, :update]
resources :projects, only: [:index, :destroy] resources :projects, only: [:index, :destroy]
resources :disciplines, only: [:index, :create, :edit, :update, :destroy]
resources :sub_disciplines, only: [:index, :create, :edit, :update, :destroy]
resources :tag_disciplines, only: [:index, :create, :edit, :update, :destroy]
end end
namespace :cooperative do namespace :cooperative do

@ -0,0 +1,7 @@
class MigrateItemBankColumn < ActiveRecord::Migration[5.2]
def change
remove_column :item_banks, :curriculum_id
remove_column :item_banks, :curriculum_direction_id
add_column :item_banks, :sub_repertoire_id, :integer, index: true
end
end

@ -0,0 +1,7 @@
class ChangeItemBankPublicDefault < ActiveRecord::Migration[5.2]
def change
change_column_default :item_banks, :public, 0
change_column_default :item_banks, :quotes, 0
change_column_default :item_banks, :difficulty, 1
end
end

@ -0,0 +1,7 @@
class AddPositionScoreToBasket < ActiveRecord::Migration[5.2]
def change
add_column :item_baskets, :position, :integer, default: 0
add_column :item_baskets, :score, :float, default: 0
add_column :item_baskets, :item_type, :integer, default: 0
end
end

@ -0,0 +1,12 @@
class CreateDisciplines < ActiveRecord::Migration[5.2]
def change
create_table :disciplines do |t|
t.string :name
t.boolean :subject
t.boolean :shixun
t.boolean :question
t.timestamps
end
end
end

@ -0,0 +1,13 @@
class CreateSubDisciplines < ActiveRecord::Migration[5.2]
def change
create_table :sub_disciplines do |t|
t.references :discipline, index: true
t.string :name
t.boolean :subject
t.boolean :shixun
t.boolean :question
t.timestamps
end
end
end

@ -0,0 +1,13 @@
class CreateTagDisciplines < ActiveRecord::Migration[5.2]
def change
create_table :tag_disciplines do |t|
t.references :sub_discipline, index: true
t.string :name
t.boolean :subject
t.boolean :shixun
t.boolean :question
t.timestamps
end
end
end

@ -0,0 +1,6 @@
class MigrateItemBankTagColumn < ActiveRecord::Migration[5.2]
def change
remove_column :item_banks, :sub_repertoire_id
add_column :item_banks, :sub_discipline_id, :integer, index: true
end
end

@ -0,0 +1,13 @@
class CreateTagDisciplineContainers < ActiveRecord::Migration[5.2]
def change
create_table :tag_discipline_containers do |t|
t.references :tag_discipline, index: true
t.integer :container_id
t.string :container_type
t.timestamps
end
add_index :tag_discipline_containers, [:container_type, :container_id], name: "index_on_container"
end
end

@ -0,0 +1,15 @@
class MigrateDisciplinesDefault < ActiveRecord::Migration[5.2]
def change
change_column_default :disciplines, :subject, from: nil, to: 1
change_column_default :disciplines, :shixun, from: nil, to: 1
change_column_default :disciplines, :question, from: nil, to: 1
change_column_default :sub_disciplines, :subject, from: nil, to: 1
change_column_default :sub_disciplines, :shixun, from: nil, to: 1
change_column_default :sub_disciplines, :question, from: nil, to: 1
change_column_default :tag_disciplines, :subject, from: nil, to: 1
change_column_default :tag_disciplines, :shixun, from: nil, to: 1
change_column_default :tag_disciplines, :question, from: nil, to: 1
end
end

@ -0,0 +1,15 @@
class CreateExaminationBanks < ActiveRecord::Migration[5.2]
def change
create_table :examination_banks do |t|
t.string :name
t.integer :difficulty, default: 1
t.references :user, index: true
t.boolean :public, default: 0
t.integer :quotes, default: 0
t.references :sub_discipline, index: true
t.integer :duration
t.timestamps
end
end
end

@ -0,0 +1,15 @@
class CreateExaminationItems < ActiveRecord::Migration[5.2]
def change
create_table :examination_items do |t|
t.references :examination_bank, index: true
t.references :item_bank, index: true
t.string :name
t.integer :item_type, default: 0
t.integer :difficulty, default: 1
t.float :score, default: 0
t.integer :position, default: 0
t.timestamps
end
end
end

@ -0,0 +1,11 @@
class CreateExaminationItemChoices < ActiveRecord::Migration[5.2]
def change
create_table :examination_item_choices do |t|
t.references :examination_item, index: true
t.text :choice_text
t.boolean :is_answer, default: 0
t.timestamps
end
end
end

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

@ -30,7 +30,7 @@ const env = getClientEnvironment(publicUrl);
module.exports = { module.exports = {
// You may want 'eval' instead if you prefer to see the compiled output in DevTools. // You may want 'eval' instead if you prefer to see the compiled output in DevTools.
// See the discussion in https://github.com/facebookincubator/create-react-app/issues/343.s // See the discussion in https://github.com/facebookincubator/create-react-app/issues/343.s
//devtool: "cheap-module-eval-source-map", devtool: "cheap-module-eval-source-map",
// 开启调试 // 开启调试
//devtool: "source-map", // 开启调试 //devtool: "source-map", // 开启调试
// These are the "entry points" to our application. // These are the "entry points" to our application.

@ -326,8 +326,8 @@ module.exports = {
comments: false comments: false
}, },
compress: { compress: {
drop_debugger: true, drop_debugger: false,
drop_console: true drop_console: false
} }
} }
}), }),

@ -49,6 +49,7 @@
"lodash": "^4.17.5", "lodash": "^4.17.5",
"loglevel": "^1.6.1", "loglevel": "^1.6.1",
"material-ui": "^1.0.0-beta.40", "material-ui": "^1.0.0-beta.40",
"md5": "^2.2.1",
"moment": "^2.23.0", "moment": "^2.23.0",
"monaco-editor": "^0.15.6", "monaco-editor": "^0.15.6",
"monaco-editor-webpack-plugin": "^1.7.0", "monaco-editor-webpack-plugin": "^1.7.0",

@ -301,6 +301,31 @@ const Developer = Loadable({
loader: () => import('./modules/developer'), loader: () => import('./modules/developer'),
loading: Loading loading: Loading
}) })
// 试题库
const Headplugselection = Loadable({
loader: () => import('./modules/question/Question'),
loading: Loading
})
//试题库新建 //题库编辑
const Questionitem_banks = Loadable({
loader: () => import('./modules/question/Questionitem_banks'),
loading: Loading
})
//试卷库
const Testpaperlibrary= Loadable({
loader: () => import('./modules/testpaper/Testpaperlibrary'),
loading: Loading
})
//人工组卷
const Paperreview= Loadable({
loader: () => import('./modules/question/Paperreview'),
loading: Loading
})
// 学院统计 // 学院统计
const College = Loadable({ const College = Loadable({
loader: () => import('./college/College'), loader: () => import('./college/College'),
@ -730,6 +755,19 @@ class App extends Component {
(props) => (<RecordDetail {...this.props} {...props} {...this.state} />) (props) => (<RecordDetail {...this.props} {...props} {...this.state} />)
} }
/> />
<Route path="/question/edit/:id"
render={
(props) => (<Questionitem_banks {...this.props} {...props} {...this.state} />)
} />
<Route path="/question/newitem"
render={
(props) => (<Questionitem_banks {...this.props} {...props} {...this.state} />)
} />
<Route path="/question/:type"
render={
(props) => (<Headplugselection {...this.props} {...props} {...this.state} />)
} />
<Route path="/myproblems/:id/:tab?" <Route path="/myproblems/:id/:tab?"
render={ render={
(props) => (<StudentStudy {...this.props} {...props} {...this.state} />) (props) => (<StudentStudy {...this.props} {...props} {...this.state} />)
@ -740,6 +778,18 @@ class App extends Component {
(props) => (<Developer {...this.props} {...props} {...this.state} />) (props) => (<Developer {...this.props} {...props} {...this.state} />)
}/> }/>
<Route path="/paperreview"
render={
(props) => (<Paperreview {...this.props} {...props} {...this.state} />)
}/>
<Route path="/paperlibrary"
render={
(props) => (<Testpaperlibrary {...this.props} {...props} {...this.state} />)
}/>
<Route path="/question"
render={
(props) => (<Headplugselection {...this.props} {...props} {...this.state} />)
}/>
<Route exact path="/" <Route exact path="/"
// component={ShixunsHome} // component={ShixunsHome}
render={ render={

@ -126,7 +126,6 @@ class Sendresource extends Component{
this.props.Cancel() this.props.Cancel()
} }
Saves=()=>{ Saves=()=>{
let {fileList,description,is_public,datatime,Radiovalue} =this.state; let {fileList,description,is_public,datatime,Radiovalue} =this.state;
let newfileList=[]; let newfileList=[];
@ -445,4 +444,4 @@ class Sendresource extends Component{
) )
} }
} }
export default Sendresource; export default Sendresource;

@ -0,0 +1,159 @@
import React, {Component} from "react";
import {Link, NavLink} from 'react-router-dom';
import {WordsBtn, ActionBtn, SnackbarHOC, getImageUrl} from 'educoder';
import axios from 'axios';
import {
notification,
Spin,
Table,
Pagination,
Drawer,
Input,
Button,
Breadcrumb
} from "antd";
import {TPMIndexHOC} from "../tpm/TPMIndexHOC";
import Itembankstop from "./component/Itembankstop";
import NoneData from './component/NoneData';
import './questioncss/questioncom.css';
import '../tpm/newshixuns/css/Newshixuns.css';
import Choicequestion from './component/Choicequestion';
import SingleEditor from "./component/SingleEditor";
import ChoquesEditor from "./component/ChoquesEditor"
import JudquestionEditor from "./component/JudquestionEditor";
import Paperreview_item from "./Paperreview_item"
import Bottomsubmit from "../../modules/modals/Bottomsubmit";
class Paperreview extends Component {
constructor(props) {
super(props);
this.contentMdRef = React.createRef();
this.answerMdRef = React.createRef();
this.Choques = React.createRef();
this.Judquestio = React.createRef();
this.state = {
item_type: null,
item_banksedit: [],
myquestion_choicesco: [],
disciplinesdata: [],
knowledgepoints: [],
disciplmy:[]
}
}
//初始化
componentDidMount() {
}
getdata = (data) => {
}
getcontentMdRef = (Ref) => {
this.contentMdRef = Ref;
}
getanswerMdRef = (Ref) => {
this.answerMdRef = Ref;
}
getJudquestio = (Ref) => {
this.Judquestio = Ref;
}
getChoquesEditor = (Ref) => {
this.Choques = Ref;
}
//跳转道描点的地方
scrollToAnchor = (anchorName) => {
try {
if (anchorName) {
// 找到锚点
let anchorElement = document.getElementById(anchorName);
// 如果对应id的锚点存在就跳转到锚点
if (anchorElement) {
anchorElement.scrollIntoView();
}
}
} catch (e) {
}
}
preservation = () => {
//保存试卷
}
setitem_type = (item_type) => {
}
render() {
let {page, limit, count, Headertop, visible, placement, modalsType, item_type} = this.state;
const params = this.props && this.props.match && this.props.match.params;
// //console.log(params);
return (
<div>
<div id={"Itembankstopid"} className="newMain clearfix intermediatecenter "
>
<style>
{
`
.newFooter{
display: none;
}
`
}
</style>
<div className="w1200mss">
<div className="w100s mt30">
<Breadcrumb separator=">">
<Breadcrumb.Item href="/question">试题库</Breadcrumb.Item>
<Breadcrumb.Item className={"xiaoshou"} >人工组卷</Breadcrumb.Item>
<Breadcrumb.Item className={"xiaoshout"}>试卷预览</Breadcrumb.Item>
</Breadcrumb>
</div>
<Paperreview_item>
</Paperreview_item>
</div>
</div>
{
item_type === null ?
""
:
<Bottomsubmit {...this.props} {...this.state} bottomvalue={"保存组卷"}
onSubmits={() => this.preservation()} url={'/question'}></Bottomsubmit>
}
</div>
)
}
}
export default SnackbarHOC()(TPMIndexHOC(Paperreview));

@ -0,0 +1,85 @@
import React, {Component} from "react";
import {Link, NavLink} from 'react-router-dom';
import {WordsBtn, ActionBtn, getImageUrl} from 'educoder';
import axios from 'axios';
import {
notification,
Spin,
Table,
Pagination,
Drawer,
Input,
Button,
Breadcrumb
} from "antd";
import Itembankstop from "./component/Itembankstop";
import NoneData from './component/NoneData';
import './questioncss/questioncom.css';
import '../tpm/newshixuns/css/Newshixuns.css';
import Choicequestion from './component/Choicequestion';
import SingleEditor from "./component/SingleEditor";
import ChoquesEditor from "./component/ChoquesEditor"
import JudquestionEditor from "./component/JudquestionEditor";
import Bottomsubmit from "../../modules/modals/Bottomsubmit";
class Paperreview_item extends Component {
constructor(props) {
super(props);
this.state = {
questions:0,
totalscore:0,
}
}
//初始化
componentDidMount() {
}
getdata = (data) => {
}
preservation = () => {
}
setitem_type = (item_type) => {
}
render() {
let {questions,totalscore} = this.state;
// //console.log(params);
return (
<div className=" clearfix educontent Contentquestionbankstyle w100s w1200fpx mt19">
<div className="w100s mt20 mb20">
<div className="w100s sortinxdirection">
<p className="questionstishu">题数{questions}</p>
<p className="ml58 questionstotal">总分{totalscore}</p>
</div>
</div>
</div>
)
}
}
export default Paperreview_item

@ -0,0 +1,851 @@
import React, {Component} from "react";
import {Link, NavLink} from 'react-router-dom';
import {WordsBtn, ActionBtn, SnackbarHOC, getImageUrl} from 'educoder';
import axios from 'axios';
import {
notification,
Spin,
Table,
Pagination,
Drawer,
Input
} from "antd";
import Headplugselection from "./component/Headplugselection";
import QuestionModal from "./component/QuestionModal";
import QuestionModals from "./component/QuestionModals";
import Contentpart from "./component/Contentpart";
import {TPMIndexHOC} from "../tpm/TPMIndexHOC";
import NoneData from './component/NoneData';
import './questioncss/questioncom.css';
import SiderBar from "../tpm/SiderBar";
class Question extends Component {
constructor(props) {
super(props);
this.state = {
count: 50,
defaultActiveKey:"0",
Headertop: "",
Footerdown: "",
visible: false,
placement: 'right',
modalsType: false,
modalsTypes:false,
titilesm: "设为公开后,所有成员均可使用试题",
titiless: "是否设置为公开?",
titilesms:"单选题",
titbool: false,
Contentdata: [],
difficulty: null,
visiblemys: false,
visiblemyss: false,
item_type: null,
keyword: null,
timuid: null,
items_count: 0,
basket_list: [],
completion_questions_count: 0,
judgement_questions_count: 0,
multiple_questions_count: 0,
practical_questions_count: 0,
program_questions_count: 0,
single_questions_count: 0,
subjective_questions_count: 0,
page:1,
per_page:10,
disciplinesdata:[],
discipline_id:null,
sub_discipline_id:null,
tag_discipline_id:null,
booljupyterurls:false,
disciplinesdatakc:0,
disciplinesdatazsd:0,
}
}
setdiscipline_id=(discipline_id)=>{
this.setState({
discipline_id:discipline_id,
sub_discipline_id:null,
tag_discipline_id:null
})
var data = {
discipline_id:discipline_id,
sub_discipline_id:null,
tag_discipline_id:null,
public: this.state.defaultActiveKey,
difficulty: this.state.difficulty,
item_type: this.state.item_type,
keywords: this.state.keywords,
page: this.state.page,
per_page:10,
};
this.getdata(data);
}
setsub_discipline_id=(sub_discipline_id)=>{
this.setState({
sub_discipline_id:sub_discipline_id,
tag_discipline_id:null
})
var data = {
discipline_id:this.state.discipline_id,
sub_discipline_id:sub_discipline_id,
tag_discipline_id:null,
public: this.state.defaultActiveKey,
difficulty: this.state.difficulty,
item_type: this.state.item_type,
keywords: this.state.keywords,
page: this.state.page,
per_page:10,
};
this.getdata(data);
}
settag_discipline_id=(tag_discipline_id)=>{
this.setState({
tag_discipline_id:tag_discipline_id
})
var data = {
discipline_id:this.state.discipline_id,
sub_discipline_id:this.state.sub_discipline_id,
tag_discipline_id:tag_discipline_id,
public: this.state.defaultActiveKey,
difficulty: this.state.difficulty,
item_type: this.state.item_type,
keywords: this.state.keywords,
page: this.state.page,
per_page:10,
};
this.getdata(data);
}
//初始化
componentDidMount() {
let {defaultActiveKey} = this.state;
var data = {
discipline_id:this.state.discipline_id,
sub_discipline_id:this.state.sub_discipline_id,
tag_discipline_id:this.state.tag_discipline_id,
public: defaultActiveKey,
page:1,
per_page:10,
};
this.getdata(data);
let url = `/users/get_navigation_info.json`;
axios.get(url, {}).then((response) => {
// ////console.log("开始请求/get_navigation_info.json");
// ////console.log(response);
if (response != undefined) {
if (response.status === 200) {
this.setState({
Headertop: response.data.top,
Footerdown: response.data.down
})
}
}
});
this.getbasket_listdata();
//获取题库筛选资料
let urls = `/disciplines.json`;
axios.get(urls, {params: {
source:"question"
}}).then((response) => {
console.log("Questiondisciplines");
console.log(response.data);
if (response) {
this.setState({
disciplinesdata: response.data.disciplines,
})
}
});
}
callback = (key) => {
this.setState({
defaultActiveKey: key,
})
var data = {
discipline_id:this.state.discipline_id,
sub_discipline_id:this.state.sub_discipline_id,
tag_discipline_id:this.state.tag_discipline_id,
public: key,
item_type: this.state.item_type,
difficulty: this.state.difficulty,
page: this.state.page,
per_page:10,
};
this.getdata(data);
}
getdata = (data) => {
const url = `/item_banks.json`;
this.setState({
booljupyterurls:true,
})
axios.get((url), {params: data}).then((response) => {
setTimeout(()=>{
this.setState({
booljupyterurls:false,
})
},1000);
if (response === null || response === undefined) {
return
}
if (response.data.status === 403 || response.data.status === 401 || response.data.status === 500) {
} else {
}
////console.log("item_banks");
////console.log(response);
this.setState({
Contentdata: response.data,
items_count: response.data.items_count,
})
}).catch((error) => {
////console.log(error)
this.setState({
booljupyterurls:false,
})
});
}
paginationonChange = (pageNumber) => {
this.setState({
page: pageNumber,
})
var data = {
discipline_id:this.state.discipline_id,
sub_discipline_id:this.state.sub_discipline_id,
tag_discipline_id:this.state.tag_discipline_id,
public: this.state.defaultActiveKey,
difficulty: this.state.difficulty,
item_type: this.state.item_type,
keywords: this.state.keywords,
page: pageNumber,
per_page:10,
};
this.getdata(data);
}
showDrawer = () => {
this.setState({
visible: true,
});
this.getbasket_listdata();
};
onClose = () => {
this.setState({
visible: false,
});
};
onChange = e => {
this.setState({
placement: e.target.value,
});
};
getContainer = () => {
return this.container;
};
saveContainer = container => {
this.container = container;
};
showmodels = (id) => {
this.setState({
modalsType: true,
titilesm: "设为公开后,所有成员均可使用试题",
titiless: "是否设置为公开?",
titbool: true,
timuid: id
})
};
showmodelysl = (id) => {
this.setState({
modalsType: true,
titilesm: "确认删除后,无法撤销",
titiless: "是否确认删除?",
titbool: false,
timuid: id
})
};
modalCancel = () => {
this.setState({
modalsType: false
})
}
modalCancels=()=>{
this.setState({
modalsTypes: false
})
}
showQuestionModals =(item_type)=>{
this.setState({
modalsTypes: true,
titilesms:item_type,
})
}
setDownloads=(item_type)=>{
this.Deletebigquestiontype(item_type);
this.setState({
modalsTypes: false
})
}
setDownload = () => {
//确认
if (this.state.titbool === true) {
//公开
this.publicopentimu(this.state.timuid);
} else {
// 删除
this.deletetimu(this.state.timuid);
}
this.setState({
modalsType: false
})
}
setdifficulty = (difficulty) => {
this.setState({
difficulty: difficulty,
visiblemys: false,
})
var data = {
discipline_id:this.state.discipline_id,
sub_discipline_id:this.state.sub_discipline_id,
tag_discipline_id:this.state.tag_discipline_id,
public: this.state.defaultActiveKey,
difficulty: difficulty,
item_type: this.state.item_type,
page: this.state.page,
per_page:10,
};
this.getdata(data);
}
setitem_types = (item_type) => {
this.setState({
item_type: item_type,
visiblemyss: false,
})
var data = {
discipline_id:this.state.discipline_id,
sub_discipline_id:this.state.sub_discipline_id,
tag_discipline_id:this.state.tag_discipline_id,
public: this.state.defaultActiveKey,
difficulty: this.state.difficulty,
item_type: item_type,
page: this.state.page,
per_page:10,
};
this.getdata(data);
}
handleVisibleChange = (boll) => {
if (this.state.visiblemyss === true) {
this.setState({
visiblemys: boll,
visiblemyss: false,
})
} else {
this.setState({
visiblemys: boll,
})
}
}
handleVisibleChanges = (boll) => {
if (this.state.visiblemys === true) {
this.setState({
visiblemyss: boll,
visiblemys: false,
})
} else {
this.setState({
visiblemyss: boll,
})
}
}
setdatafunsval = (e) => {
this.setState({
keywords: e.target.value
})
var data = {
discipline_id:this.state.discipline_id,
sub_discipline_id:this.state.sub_discipline_id,
tag_discipline_id:this.state.tag_discipline_id,
public: this.state.defaultActiveKey,
difficulty: this.state.difficulty,
item_type: this.state.item_type,
keywords: e.target.value,
page: this.state.page,
per_page:10,
};
this.getdata(data);
}
setdatafuns = (value) => {
this.setState({
keywords: value,
})
var data = {
discipline_id:this.state.discipline_id,
sub_discipline_id:this.state.sub_discipline_id,
tag_discipline_id:this.state.tag_discipline_id,
public: this.state.defaultActiveKey,
difficulty: this.state.difficulty,
item_type: this.state.item_type,
keywords: value,
page: this.state.page,
per_page:10,
};
this.getdata(data);
}
deletetimu = (id) => {
const url = `/item_banks/${id}.json`;
axios.delete(url)
.then((response) => {
if (response.data.status == 0) {
this.props.showNotification('删除试题成功')
// props.history.push(response.data.right_url)
var data = {
discipline_id:this.state.discipline_id,
sub_discipline_id:this.state.sub_discipline_id,
tag_discipline_id:this.state.tag_discipline_id,
public: this.state.defaultActiveKey,
difficulty: this.state.difficulty,
item_type: this.state.item_type,
keywords: this.state.keywords,
page: this.state.page,
per_page:10,
};
this.getdata(data);
}
})
.catch(function (error) {
//console.log(error);
});
}
publicopentimu = (id) => {
const url = `/item_banks/${id}/set_public.json`;
axios.post(url)
.then((result) => {
if (result.data.status == 0) {
this.props.showNotification(`公开题目成功`);
var data = {
discipline_id:this.state.discipline_id,
sub_discipline_id:this.state.sub_discipline_id,
tag_discipline_id:this.state.tag_discipline_id,
public: this.state.defaultActiveKey,
difficulty: this.state.difficulty,
item_type: this.state.item_type,
keywords: this.state.keywords,
page: this.state.page,
per_page:10,
};
this.getdata(data);
}
}).catch((error) => {
//console.log(error);
})
}
getbasket_listdata = () => {
// 获取试题篮展开的数据
const url = "/item_baskets/basket_list.json";
axios.get(url)
.then((result) => {
// //console.log("getbasket_listdata");
// //console.log(result.data);
this.setState({
completion_questions_count: result.data.completion_questions_count,
judgement_questions_count: result.data.judgement_questions_count,
multiple_questions_count: result.data.multiple_questions_count,
practical_questions_count: result.data.practical_questions_count,
program_questions_count: result.data.program_questions_count,
single_questions_count: result.data.single_questions_count,
subjective_questions_count: result.data.subjective_questions_count,
})
}).catch((error) => {
// //console.log(error);
this.setState({
completion_questions_count: 0,
judgement_questions_count: 0,
multiple_questions_count: 0,
practical_questions_count: 0,
program_questions_count: 0,
single_questions_count: 0,
subjective_questions_count: 0,
})
})
}
//选用
getitem_baskets=(data)=>{
//选用题型可以上传单个 或者多个题型
let url="/item_baskets.json";
axios.post(url, data)
.then((result) => {
if (result.data.status == 0) {
this.props.showNotification(`选用成功`);
var data = {
discipline_id:this.state.discipline_id,
sub_discipline_id:this.state.sub_discipline_id,
tag_discipline_id:this.state.tag_discipline_id,
public: this.state.defaultActiveKey,
difficulty: this.state.difficulty,
item_type: this.state.item_type,
keywords: this.state.keywords,
page: this.state.page,
per_page:10,
};
this.getdata(data);
this.getbasket_listdata();
this.setState({
visible:true
})
}
}).catch((error) => {
//console.log(error);
})
}
// 撤销
getitem_basketss=(id)=>{
//选用题型可以上传单个 或者多个题型
let url=`/item_baskets/${id}.json`;
axios.delete(url)
.then((result) => {
if (result.data.status == 0) {
this.props.showNotification(`撤销成功`);
var data = {
discipline_id:this.state.discipline_id,
sub_discipline_id:this.state.sub_discipline_id,
tag_discipline_id:this.state.tag_discipline_id,
public: this.state.defaultActiveKey,
difficulty: this.state.difficulty,
item_type: this.state.item_type,
keywords: this.state.keywords,
page: this.state.page,
per_page:10,
};
this.getdata(data);
this.getbasket_listdata();
}
}).catch((error) => {
//console.log(error);
})
}
//全选试题库
selectallquestionsonthispage=()=>{
var item_idsdata=[];
var arr= this.state.Contentdata.items;
for(let data of arr) {
item_idsdata.push(data.id);
}
const data={
item_ids:item_idsdata
}
this.getitem_baskets(data);
}
//删除大题型
Deletebigquestiontype =(item_type)=>{
const url=`/item_baskets/delete_item_type.json`;
axios.delete((url), { data: {
item_type:item_type
}})
.then((response) => {
if (response.data.status == 0) {
this.props.showNotification('删除成功');
var data = {
discipline_id:this.state.discipline_id,
sub_discipline_id:this.state.sub_discipline_id,
tag_discipline_id:this.state.tag_discipline_id,
public: this.state.defaultActiveKey,
difficulty: this.state.difficulty,
item_type: this.state.item_type,
keywords: this.state.keywords,
page: this.state.page,
per_page:10,
};
this.getdata(data);
this.getbasket_listdata();
}
})
.catch(function (error) {
//console.log(error);
});
}
//跳转
gotopaperreview=()=>{
this.props.history.replace("/paperreview");
}
render() {
let {
page, per_page, items_count, Headertop, visible, placement, modalsType, modalsTypes,basket_list,
completion_questions_count, judgement_questions_count, multiple_questions_count, practical_questions_count,
program_questions_count, single_questions_count, subjective_questions_count
} = this.state;
const Datacount = completion_questions_count + judgement_questions_count
+ multiple_questions_count + practical_questions_count
+ program_questions_count
+ single_questions_count
+ subjective_questions_count;
return (
<div className="newMain clearfix" ref={this.saveContainer}>
{
visible===true?
<style>
{
`
.newHeaders{
position: fixed;
top: 0px;
z-index: 999 !important;
}
.ant-drawer {
z-index: 800 !important;
}
.ant-notification{
position: fixed;
z-index: 1500 !important;
}
.newFooter{
position: relative;
z-index: 9999999 ;
}
`
}
</style>
:""
}
{
visible===true?
<div
style={{
marginTop: "60px"
}}></div>
:""}
<QuestionModals {...this.props}{...this.state} modalsTypes={modalsTypes} modalCancels={() => this.modalCancels()}
setDownloads={(e) => this.setDownloads(e)}></QuestionModals>
<QuestionModal {...this.props}{...this.state} modalsType={modalsType} modalCancel={() => this.modalCancel()}
setDownload={() => this.setDownload()}></QuestionModal>
<SiderBar
{...this.props}
{...this.state}
showDrawer={() => this.showDrawer()}
Headertop={Headertop}/>
{/*顶部*/}
<Headplugselection {...this.props} {...this.state}
setdiscipline_id={(e)=>this.setdiscipline_id(e)}
setsub_discipline_id={(e)=>this.setsub_discipline_id(e)}
settag_discipline_id={(e)=>this.settag_discipline_id(e)}
></Headplugselection>
{/*头部*/}
<Contentpart {...this.state} {...this.props}
getitem_basketss={(id)=>this.getitem_basketss(id)}
selectallquestionsonthispage={()=>this.selectallquestionsonthispage()}
getitem_baskets={(e)=>this.getitem_baskets(e)}
setdatafuns={(e) => this.setdatafuns(e)}
setdatafunsval={(e) => this.setdatafunsval(e)}
handleVisibleChanges={(e) => this.handleVisibleChanges(e)}
setitem_types={(e) => this.setitem_types(e)}
handleVisibleChange={(e) => this.handleVisibleChange(e)}
setdifficulty={(e) => this.setdifficulty(e)}
showmodels={(e) => this.showmodels(e)}
showmodelysl={(e) => this.showmodelysl(e)}
callback={(e) => this.callback(e)}></Contentpart>
{/*分页*/}
{/*<div className="clearfix mt5">*/}
{/*<div className="educontent mt10 pb20 w1200s">*/}
{/* fenye*/}
{
items_count&&items_count>10?
<div className="mb30 clearfix educontent mt40 intermediatecenter">
<Pagination showQuickJumper current={page} onChange={this.paginationonChange}
pageSize={per_page}
total={items_count}></Pagination>
</div>
:<div className="h30 clearfix educontent mt40 intermediatecenter">
</div>
}
{/*抽屉效果*/}
<style>
{
`
.ant-drawer-content-wrapper{
width: 200px !important;
overflowhidden;
margin-top: 62px;
}
.ant-drawer-body{
height: 100%;
background:rgba(234,234,234,1);
}
`
}
</style>
<Drawer
className="drawercontainer"
placement={placement}
closable={false}
onClose={() => this.onClose()}
visible={visible}
mask={false}
closable={true}
>
{Datacount && Datacount > 0 ?
<div>
<div className="mt25 mb26">
</div>
{
single_questions_count === 0 ?
""
: <div className="sortinxdirection" onClick={()=>this.showQuestionModals("SINGLE")} >
<p
className="w50s intermediatecenterysls sortinxdirection font-14">单选题{'('}{single_questions_count}{')'}</p>
<p className="w50s intermediatecenterysls xaxisreverseorder"><i
className="iconfont icon-shanchu1 font-14 lg lh30 icondrawercolor "></i></p>
</div>
}
{
multiple_questions_count === 0 ?
""
:
<div className="sortinxdirection" onClick={()=>this.showQuestionModals("MULTIPLE")}>
<p
className="w50s intermediatecenterysls sortinxdirection font-14">多选题{'('}{multiple_questions_count}{')'}</p>
<p className="w50s intermediatecenterysls xaxisreverseorder"><i
className="iconfont icon-shanchu1 font-14 lg lh30 icondrawercolor "></i></p>
</div>
}
{
judgement_questions_count === 0 ?
""
:
<div className="sortinxdirection" onClick={()=>this.showQuestionModals("JUDGMENT")}>
<p
className="w50s intermediatecenterysls sortinxdirection font-14">判断题{'('}{judgement_questions_count}{')'}</p>
<p className="w50s intermediatecenterysls xaxisreverseorder"><i
className="iconfont icon-shanchu1 font-14 lg lh30 icondrawercolor "></i></p>
</div>
}
{
completion_questions_count === 0 ?
""
:
<div className="sortinxdirection" onClick={()=>this.showQuestionModals("COMPLETION")}>
<p
className="w50s intermediatecenterysls sortinxdirection font-14">填空题{'('}{completion_questions_count}{')'}</p>
<p className="w50s intermediatecenterysls xaxisreverseorder"><i
className="iconfont icon-shanchu1 font-14 lg lh30 icondrawercolor "></i></p>
</div>
}
{
subjective_questions_count === 0 ?
""
:
<div className="sortinxdirection" onClick={()=>this.showQuestionModals("SUBJECTIVE")}>
<p
className="w50s intermediatecenterysls sortinxdirection font-14">简答题{'('}{subjective_questions_count}{')'}</p>
<p className="w50s intermediatecenterysls xaxisreverseorder"><i
className="iconfont icon-shanchu1 font-14 lg lh30 icondrawercolor "></i></p>
</div>
}
{
practical_questions_count === 0 ?
""
:
<div className="sortinxdirection">
<p
className="w50s intermediatecenterysls sortinxdirection font-14">实训题{'('}{practical_questions_count}{')'}</p>
<p className="w50s intermediatecenterysls xaxisreverseorder"><i
className="iconfont icon-shanchu1 font-14 lg lh30 icondrawercolor "></i></p>
</div>
}
{
program_questions_count === 0 ?
""
:
<div className="sortinxdirection" onClick={()=>this.showQuestionModals("PROGRAM")}>
<p
className="w50s intermediatecenterysls sortinxdirection font-14">编程题{'('}{program_questions_count}{')'}</p>
<p className="w50s intermediatecenterysls xaxisreverseorder"><i
className="iconfont icon-shanchu1 font-14 lg lh30 icondrawercolor "></i></p>
</div>
}
<div className="intermediatecenter verticallayout mt42">
<div className="drawerbutton" onClick={()=>this.gotopaperreview()}>
试卷预览
</div>
</div>
</div>
:
<div className="drawernonedatadiv intermediatecenter">
<NoneData></NoneData>
</div>
}
</Drawer>
</div>
)
}
}
export default SnackbarHOC()(TPMIndexHOC(Question));

@ -0,0 +1,583 @@
import React, {Component} from "react";
import {Link, NavLink} from 'react-router-dom';
import {WordsBtn, ActionBtn, SnackbarHOC, getImageUrl} from 'educoder';
import axios from 'axios';
import {
notification,
Spin,
Table,
Pagination,
Drawer,
Input,
Button,
Breadcrumb
} from "antd";
import {TPMIndexHOC} from "../tpm/TPMIndexHOC";
import Itembankstop from "./component/Itembankstop";
import NoneData from './component/NoneData';
import './questioncss/questioncom.css';
import '../tpm/newshixuns/css/Newshixuns.css';
import Choicequestion from './component/Choicequestion';
import SingleEditor from "./component/SingleEditor";
import ChoquesEditor from "./component/ChoquesEditor"
import JudquestionEditor from "./component/JudquestionEditor";
import Bottomsubmit from "../../modules/modals/Bottomsubmit";
// var itembankstop=null;
// var singleEditor=null;
// var Judquestio=null;
// var Choques=null;
class Questionitem_banks extends Component {
constructor(props) {
super(props);
this.contentMdRef = React.createRef();
this.answerMdRef = React.createRef();
this.Choques = React.createRef();
this.Judquestio = React.createRef();
this.state = {
item_type: null,
item_banksedit: [],
myquestion_choicesco: [],
disciplinesdata: [],
knowledgepoints: [],
disciplmy:[]
}
}
//初始化
componentDidMount() {
// let {defaultActiveKey}= this.state;
// var data={
// public:defaultActiveKey
// };
// this.getdata(data);
//
// let url=`/users/get_navigation_info.json`;
// axios.get(url, {
//
// }).then((response) => {
// // //////console.log("开始请求/get_navigation_info.json");
// // //////console.log(response);
// if(response!=undefined){
// if(response.status===200){
// this.setState({
// Headertop:response.data.top,
// Footerdown:response.data.down
// })
// }
// }
// });
const params = this.props && this.props.match && this.props.match.params;
if (JSON.stringify(params) === "{}") {
//新增
} else {
//编辑
const url = `/item_banks/${this.props.match.params.id}/edit.json`;
axios.get((url)).then((response) => {
if (response === null || response === undefined) {
return
}
if (response.data.status === 403 || response.data.status === 401 || response.data.status === 500) {
} else {
}
//////console.log("item_banks");
//console.log("Questionitem_banks");
//console.log(response.data);
this.setState({
item_banksedit: response.data,
})
}).catch((error) => {
//////console.log(error)
});
}
let urls = `/disciplines.json`;
axios.get(urls, {
params: {
source: "question"
}
}).then((response) => {
if (response) {
this.setState({
disciplinesdata: response.data.disciplines,
})
if (response.data) {
if (response.data.disciplines) {
const didata = response.data.disciplines;
for (var i = 0; i < didata.length; i++) {
const childern=[];
//方向
const fxdidata = didata[i].sub_disciplines;
for (var j = 0; j < fxdidata.length; j++) {
//课程
const zsddata = fxdidata[j].tag_disciplines;
childern.push(
{
value: fxdidata[j].id,
label: fxdidata[j].name,
}
)
for (var k = 0; k < zsddata.length; k++) {
//知识点
this.state.knowledgepoints.push(zsddata[k]);
}
}
const datakec={
value: didata[i].id,
label: didata[i].name,
children: childern,
}
this.state.disciplmy.push(datakec);
}
this.setState({
knowledgepoints: this.state.knowledgepoints,
disciplmy:this.state.disciplmy,
})
}
}
}
});
}
getdata = (data) => {
// const url=`/item_banks.json`;
// axios.get((url),{params:data}).then((response) => {
// if(response===null||response===undefined){
//
// return
// }
// if (response.data.status === 403||response.data.status === 401||response.data.status === 500) {
//
// }else{
//
// }
// //////console.log("item_banks");
// //////console.log(response);
// }).catch((error) => {
// //////console.log(error)
//
// });
}
getcontentMdRef = (Ref) => {
this.contentMdRef = Ref;
}
getanswerMdRef = (Ref) => {
this.answerMdRef = Ref;
}
getJudquestio = (Ref) => {
this.Judquestio = Ref;
}
getChoquesEditor = (Ref) => {
this.Choques = Ref;
}
//跳转道描点的地方
scrollToAnchor = (anchorName) => {
try {
if (anchorName) {
// 找到锚点
let anchorElement = document.getElementById(anchorName);
// 如果对应id的锚点存在就跳转到锚点
if (anchorElement) {
anchorElement.scrollIntoView();
}
}
} catch (e) {
}
}
preservation = () => {
//////console.log("preservation");
// //////console.log(this.contentMdRef);
// //////console.log(this.answerMdRef);
//////console.log("preservation222");
//////console.log(this.contentMdRef.Getdatas());
//////console.log("preservation3333");
//////console.log(this.answerMdRef.onSave());
const params = this.props && this.props.match && this.props.match.params;
var url = "";
var boolnew = true;
if (JSON.stringify(params) === "{}") {
// "新增"
url = "/item_banks.json";
boolnew = true;
} else {
url = `/item_banks/${params.id}.json`;
boolnew = false;
// "编辑"
}
if (this.contentMdRef.Getdatas().length === 0) {
this.scrollToAnchor("Itembankstopid");
return;
}
console.log("preservation");
console.log(this.contentMdRef.Getdatas());
var Getdatasdata=this.contentMdRef.Getdatas();
if (this.state.item_type === null) {
return
}
if (this.state.item_type === "SINGLE") {
if (this.answerMdRef != null) {
//单选题
// //console.log(this.answerMdRef.onSave());
if (this.answerMdRef.onSave().length === 0) {
return;
}
var anserdata = this.answerMdRef.onSave();
const choices = [];
// 1: [3]
// 2: (4) ["1", "2", "3", "4"]
for (var k = 0; k < anserdata[2].length; k++) {
const choicesdata = {
choice_text: anserdata[2][k],
is_answer: anserdata[1][0] === (k + 1) ? 1 : 0,
}
choices.push(choicesdata);
}
// repertoire_id:1,
// sub_repertoire_id:1,
// tag_repertoire_id:[1,3],
var myrbkc=[];
var Getdatasdatas=Getdatasdata[2].rbzsd;
for(let myda of Getdatasdatas) {
myrbkc.push(myda.id);
}
var data = {
discipline_id: Getdatasdata[3].rbkc[0],
sub_discipline_id: Getdatasdata[3].rbkc[1],
tag_discipline_id: myrbkc,
name: anserdata[0],
item_type: Getdatasdata[1].rbtx,
difficulty:Getdatasdata[0].rbnd,
analysis: anserdata[3],
choices: choices,
};
if (boolnew === true) {
axios.post(url, data)
.then((result) => {
if (result.data.status == 0) {
this.props.showNotification(`新增单选题成功`);
this.props.history.replace('/question');
}
}).catch((error) => {
//console.log(error);
})
} else {
axios.put(url, data)
.then((result) => {
if (result.data.status == 0) {
this.props.showNotification(`编辑单选题成功`);
this.props.history.replace('/question');
}
}).catch((error) => {
//console.log(error);
})
}
}
}
if (this.state.item_type === "MULTIPLE") {
if (this.Choques != null) {
//多选题
// //console.log(this.Choques.onSave());
if (this.Choques.onSave().length === 0) {
return;
}
var anserdata = this.Choques.onSave();
const choices = [];
// 1: [3]
// 2: (4) ["1", "2", "3", "4"]
//console.log("MULTIPLE");
//console.log(anserdata);
for (var k = 0; k < anserdata[2].length; k++) {
var bool = false
for (var y = 0; y < anserdata[1].length; y++) {
if (anserdata[1][y] === (k + 1)) {
bool = true
}
}
const choicesdata = {
choice_text: anserdata[2][k],
is_answer: bool === true ? 1 : 0,
}
choices.push(choicesdata);
}
var myrbkc=[];
var Getdatasdatas=Getdatasdata[2].rbzsd;
for(let myda of Getdatasdatas) {
myrbkc.push(myda.id);
}
var data = {
discipline_id: Getdatasdata[3].rbkc[0],
sub_discipline_id: Getdatasdata[3].rbkc[1],
tag_discipline_id: myrbkc,
name: anserdata[0],
item_type: Getdatasdata[1].rbtx,
difficulty:Getdatasdata[0].rbnd,
analysis: anserdata[3],
choices: choices,
};
if (boolnew === true) {
axios.post(url, data)
.then((result) => {
if (result.data.status == 0) {
this.props.showNotification(`新增多选题成功`);
this.props.history.replace('/question');
}
}).catch((error) => {
//console.log(error);
})
} else {
axios.put(url, data)
.then((result) => {
if (result.data.status == 0) {
this.props.showNotification(`编辑多选题成功`);
this.props.history.replace('/question');
}
}).catch((error) => {
//console.log(error);
})
}
}
}
if (this.state.item_type === "JUDGMENT") {
if (this.Judquestio != null) {
//判断题
// //console.log(this.Judquestio.onSave());
if (this.Judquestio.onSave().length === 0) {
return;
}
var anserdata = this.Judquestio.onSave();
const choices = [];
const choicesdata = {
choice_text: "正确",
is_answer: anserdata[1] === "0" ? 1 : 0,
}
choices.push(choicesdata);
const choicesdatas = {
choice_text: "错误",
is_answer: anserdata[1] === "1" ? 1 : 0,
}
choices.push(choicesdatas);
var myrbkc=[];
var Getdatasdatas=Getdatasdata[2].rbzsd;
for(let myda of Getdatasdatas) {
myrbkc.push(myda.id);
}
var data = {
discipline_id: Getdatasdata[3].rbkc[0],
sub_discipline_id: Getdatasdata[3].rbkc[1],
tag_discipline_id: myrbkc,
name: anserdata[0],
item_type: Getdatasdata[1].rbtx,
difficulty:Getdatasdata[0].rbnd,
analysis: anserdata[2],
choices: choices,
};
if (boolnew === true) {
axios.post(url, data)
.then((result) => {
if (result.data.status == 0) {
this.props.showNotification(`新增判断题成功`);
this.props.history.replace('/question');
}
}).catch((error) => {
//console.log(error);
})
} else {
axios.put(url, data)
.then((result) => {
if (result.data.status == 0) {
this.props.showNotification(`编辑判断题成功`);
this.props.history.replace('/question');
}
}).catch((error) => {
//console.log(error);
})
}
}
}
if (this.state.item_type === "PROGRAM") {
//编程题 跳转到 oj 中创建
}
}
setitem_type = (item_type) => {
this.setState({
item_type: item_type
})
}
render() {
let {page, limit, count, Headertop, visible, placement, modalsType, item_type} = this.state;
const params = this.props && this.props.match && this.props.match.params;
// //console.log(params);
return (
<div>
<div id={"Itembankstopid"} className="newMain clearfix intermediatecenter "
>
<style>
{
`
.newFooter{
display: none;
}
`
}
</style>
<div className="w1200mss">
<div className="w100s mt30">
<Breadcrumb separator=">">
<Breadcrumb.Item href="/question">试题库</Breadcrumb.Item>
<Breadcrumb.Item>{JSON.stringify(params) === "{}" ? "新增" : "编辑"}试题</Breadcrumb.Item>
</Breadcrumb>
</div>
{/*题目头部操作*/}
<Itembankstop
{...this.state}
{...this.props}
getcontentMdRef={(ref) => this.getcontentMdRef(ref)}
setitem_type={(item) => this.setitem_type(item)}
>
</Itembankstop>
{
item_type && item_type === "SINGLE" ?
<div className=" clearfix educontent w100s w1200fpx mt19">
<SingleEditor
{...this.state}
{...this.props}
getanswerMdRef={(ref) => this.getanswerMdRef(ref)}
>
</SingleEditor>
</div>
: item_type && item_type === "MULTIPLE" ?
<div className=" clearfix educontent w100s w1200fpx mt19">
<ChoquesEditor
{...this.state}
{...this.props}
getanswerMdRef={(ref) => this.getChoquesEditor(ref)}
>
</ChoquesEditor>
</div>
: item_type && item_type === "JUDGMENT" ?
<div className=" clearfix educontent w100s w1200fpx mt19">
<JudquestionEditor
{...this.state}
{...this.props}
item_banksedit={this.state.item_banksedit}
getanswerMdRef={(ref) => this.getJudquestio(ref)}
>
</JudquestionEditor>
</div>
: item_type && item_type === "PROGRAM" ?
""
: ""
}
</div>
</div>
{
item_type === null ?
""
:
<Bottomsubmit {...this.props} {...this.state} bottomvalue={item_type === "PROGRAM" ? "创建" : "保存"}
onSubmits={() => this.preservation()} url={item_type === "PROGRAM" ?'/problems':'/question'}></Bottomsubmit>
}
</div>
)
}
}
export default SnackbarHOC()(TPMIndexHOC(Questionitem_banks));

@ -0,0 +1,51 @@
import React, {Component} from "react";
import {Link, NavLink} from 'react-router-dom';
import {WordsBtn, ActionBtn,SnackbarHOC,getImageUrl} from 'educoder';
import axios from 'axios';
import {
notification,
Spin,
Table,
Pagination,
Radio,
Checkbox,
Form,
Input,
Select,
Cascader,
Col, Row, InputNumber, DatePicker, AutoComplete,Button,Tag
} from "antd";
import './../questioncss/questioncom.css';
import SingleEditor from './../component/SingleEditor';
class Choicequestion extends Component {
constructor(props) {
super(props);
this.state = {
page:1,
Knowpoints:[]
}
}
//初始化
componentDidMount(){
}
render() {
let {page}=this.state;
const { getFieldDecorator } = this.props.form;
return (
<div className=" clearfix educontent Contentquestionbankstyle w100s w1200fpx mt19" >
<SingleEditor>
</SingleEditor>
</div>
)
}
}
const Choicequestions = Form.create({ name: 'Choicequestions' })(Choicequestion);
export default Choicequestions;

@ -0,0 +1,384 @@
import React,{ Component } from "react";
import {
Form, Input, InputNumber, Switch, Radio,
Slider, Button, Upload, Icon, Rate, Checkbox, message,
Row, Col, Select, Modal, Tooltip
} from 'antd';
import TPMMDEditor from '../../../modules/tpm/challengesnew/TPMMDEditor';
import axios from 'axios'
import update from 'immutability-helper'
import './../questioncss/questioncom.css';
import {getUrl, ActionBtn, DMDEditor, ConditionToolTip} from 'educoder';
const { TextArea } = Input;
const confirm = Modal.confirm;
const $ = window.$
const { Option } = Select;
const tagArray = [
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I',
'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R',
'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'
]
//题库的试卷 多选题 组件
class ChoquesEditor extends Component{
constructor(props){
super(props);
/**
choice_id: 32076
choice_position: 1
choice_text: "1"
standard_boolean: true
*/
const {question_choices} = this.props;
let _standard_answers = undefined;
let _question_choices = undefined;
if (question_choices) {
_standard_answers = []
_question_choices = []
question_choices.forEach((item, index) => {
_standard_answers.push(item.standard_boolean)
_question_choices.push(item.choice_text)
})
}
const choicescomy=[];
try {
if(this.props.item_banksedit){
if(this.props.item_banksedit.choices){
this.props.item_banksedit.choices.forEach((item, index) => {
choicescomy.push({
choice_text:item.choice_text,
standard_boolean:item.is_answer,
})
})
_standard_answers = []
_question_choices = []
choicescomy.forEach((item, index) => {
_standard_answers.push(item.standard_boolean)
_question_choices.push(item.choice_text)
})
}
}
}catch (e) {
}
this.state = {
question_choices: _question_choices || ['', '', '', ''],
standard_answers: _standard_answers || [false, false, false, false],
question_title: this.props.question_title || '',
question_type: this.props.question_type || 0,
question_score: this.props.question_score || this.props.init_question_score,
question_titles:this.props.question_titles||'',
}
}
addOption = () => {
const { question_choices, standard_answers } = this.state;
// ////console.log("addOption");
// ////console.log(question_choices);
// ////console.log(standard_answers);
question_choices.push('')
standard_answers.push(false)
this.setState({ question_choices, standard_answers })
}
deleteOption = (index) => {
let {question_choices}=this.state;
// ////console.log("deleteOption");
// ////console.log(question_choices);
if(question_choices[index]===""){
// repeat code
this.toMDMode(null)
this.setState(
(prevState) => ({
question_choices : update(prevState.question_choices, {$splice: [[index, 1]]}),
standard_answers : update(prevState.standard_answers, {$splice: [[index, 1]]})
})
)
}else{
// this.props.confirm({
// content: `确认要删除这个选项吗?`,
// onOk: () => {
this.toMDMode(null)
this.setState(
(prevState) => ({
question_choices : update(prevState.question_choices, {$splice: [[index, 1]]}),
standard_answers : update(prevState.standard_answers, {$splice: [[index, 1]]})
})
)
// }
// })
}
}
onSave = () => {
var editordata=[];
const {question_title, question_score, question_type,question_titles, question_choices, standard_answers } = this.state;
const { question_id_to_insert_after, question_id } = this.props
// TODO check
const answerArray = standard_answers.map((item, index) => { return item == true ? index+1 : -1 }).filter(item => item != -1);
if(!question_title) {
this.refs['titleEditor'].showError()
this.props.showNotification('请您输入题干');
return editordata;
}
if(!answerArray || answerArray.length == 0) {
this.props.showNotification('请先点击选择本选择题的正确选项');
return editordata;
}
if(!answerArray || answerArray.length < 2) {
this.props.showNotification('多选题最小正确选项为2个');
return editordata;
}
for(let i = 0; i < question_choices.length; i++) {
if (!question_choices[i]) {
this.refs[`optionEditor${i}`].showError()
this.props.showNotification(`请先输入 ${tagArray[i]} 选项的内容`);
return editordata;
}
}
if(!question_titles) {
this.refs['titleEditor2'].showError()
this.props.showNotification('请您输入题目解析');
return editordata;
}
/**
{
"question_title":"同学朋友间常用的沟通工具是什么?",
"question_type":1,
"question_score":5,
"question_choices":["a答案","b答案","c答案","d答案"],
"standard_answers":[1]
}*/
editordata=[question_title,answerArray,question_choices,question_titles];
// question_title,
// question_type: answerArray.length > 1 ? 1 : 0,
// question_score,
// question_choices,
// standard_answers: answerArray,
// insert_id: question_id_to_insert_after || undefined
return editordata;
}
onCancel = () => {
this.props.onEditorCancel()
}
componentDidMount = () => {
try {
this.props.getanswerMdRef(this);
}catch (e) {
}
try {
this.setState({
item_banksedit:this.props.item_banksedit,
question_title:this.props.item_banksedit.name,
question_titles:this.props.item_banksedit.analysis,
mychoicess:this.props.item_banksedit.choices,
})
}catch (e) {
}
}
componentDidUpdate(prevProps) {
//console.log("componentDidUpdate");
// //console.log(prevProps);
// //console.log(this.props.item_banksedit);
if(prevProps.item_banksedit !== this.props.item_banksedit) {
this.setState({
item_banksedit: this.props.item_banksedit,
question_title: this.props.item_banksedit.name,
question_titles: this.props.item_banksedit.analysis,
mychoicess: this.props.item_banksedit.choices,
})
}
}
onOptionClick = (index) => {
let standard_answers = this.state.standard_answers.slice(0)
standard_answers[index] = !standard_answers[index]
this.setState({ standard_answers })
}
onOptionContentChange = (value, index) => {
if (index >= this.state.question_choices.length) {
// TODO 新建然后删除CD选项再输入题干会调用到这里且index是3
return;
}
let question_choices = this.state.question_choices.slice(0);
question_choices[index] = value;
this.setState({ question_choices })
}
on_question_score_change = (e) => {
this.setState({ question_score: e })
}
toMDMode = (that) => {
if (this.mdReactObject) {
let mdReactObject = this.mdReactObject;
this.mdReactObject = null
mdReactObject.toShowMode()
}
this.mdReactObject = that;
}
toShowMode = () => {
}
render() {
let { question_title, question_score, question_type, question_choices, standard_answers,question_titles} = this.state;
let { question_id, index, exerciseIsPublish,
// question_title,
// question_type,
// question_score,
isNew } = this.props;
// const { getFieldDecorator } = this.props.form;
// const isAdmin = this.props.isAdmin()
// const courseId=this.props.match.params.coursesId;
// const isEdit = !!this.props.question_id
const qNumber = `question_`;
// TODO show模式 isNew为false isEdit为false
// [true, false, true] -> [0, 2]
const answerTagArray = standard_answers.map((item, index) => { return item == true ? tagArray[index] : -1 }).filter(item => item != -1);
// ////console.log("xuanzheshijuan");
// ////console.log(answerTagArray);
// ////console.log(!exerciseIsPublish);
return(
<div className="padding20-30 signleEditor duoxuano" id={qNumber}>
<style>{`
.optionMdEditor {
flex:1
}
.optionRow {
margin:0px!important;
/* margin-bottom: 20px!important; */
}
.signleEditor .content_editorMd_show{
display: flex;
margin-top:0px!important;
border-radius:2px;
max-width: 1056px;
word-break:break-all;
}
#e_tips_mdEditor_question_undefined4{
display: none;
}
`}</style>
<p className="mb10 clearfix">
{/* {!question_id ? '新建' : '编辑'} */}
<span className="xingcolor font-16 fl mr4">*</span>
<span className="xingtigan fl">题干</span>
</p>
<TPMMDEditor mdID={qNumber} placeholder="请您输入题干" height={155} className=" mt10"
initValue={question_title} onChange={(val) => this.setState({ question_title: val})}
ref="titleEditor"
></TPMMDEditor>
<div className="mb10 sortinxdirection">
{/* {!question_id ? '新建' : '编辑'} */}
<span className="xingcolor font-16 fl mr4">*</span>
<span className="xingtigans fl"><span className="xingtigan">答案选项</span></span>
</div>
{question_choices.map( (item, index) => {
const bg = standard_answers[index] ? 'check-option-bg' : ''
return <div className="df optionRow " >
{/* 点击设置答案 */}
{/* TODO 加了tooltip后会丢失掉span的class */}
{/* <Tooltip title={standard_answers[index] ? '点击取消标准答案设置' : '点击设置为标准答案'}> */}
<span class={`option-item fr mr10 color-grey select-choice ${bg} `}
name="option_span" onClick={() => this.onOptionClick(index)} style={{flex: '0 0 38px'}}>
<ConditionToolTip title={standard_answers[index] ? '点击取消标准答案设置' : '点击设置为标准答案'} placement="left" condition={true}>
<div style={{width: '100%', height: '100%'}}>{tagArray[index]}</div>
</ConditionToolTip>
</span>
{/* </Tooltip> */}
<div style={{ flex: '0 0 1038px'}}>
<DMDEditor
ref={`optionEditor${index}`}
toMDMode={this.toMDMode} toShowMode={this.toShowMode}
height={166} className={'optionMdEditor'} noStorage={true}
mdID={qNumber + index} placeholder="" onChange={(value) => this.onOptionContentChange(value, index)}
initValue={item}
></DMDEditor>
</div>
{exerciseIsPublish || index<=2?
<i className=" font-18 ml15 mr20"></i>
:<Tooltip title="删除">
<i className="iconfont icon-htmal5icon19 font-18 color-grey-c ml15" onClick={() => this.deleteOption(index)}></i>
</Tooltip> }
{ !exerciseIsPublish && index<7 && <Tooltip title={`新增参考答案`}>
<i className="color-green font-16 iconfont icon-roundaddfill ml6"
onClick={() => this.addOption()}
style={{float: 'right', visibility: index == question_choices.length - 1 ? '' : 'hidden', marginTop: '2px'}}
></i>
</Tooltip>}
</div>
}) }
<div>
<p className="mb10 clearfix">
{/* {!question_id ? '新建' : '编辑'} */}
<span className="xingcolor font-16 fl mr4">*</span>
<span className="xingtigan fl">题目解析</span>
</p>
<style>{`
.optionMdEditor {
flex:1
}
.optionRow {
margin:0px!important;
/* margin-bottom: 20px!important; */
}
.signleEditor .content_editorMd_show{
display: flex;
margin-top:0px!important;
border-radius:2px;
max-width: 1056px;
word-break:break-all;
}
`}</style>
<TPMMDEditor mdID={qNumber+question_choices.length} placeholder="请您输入题目解析" height={155} className=" mt10"
initValue={question_titles} onChange={(val) => this.setState({ question_titles: val})}
ref="titleEditor2"
></TPMMDEditor>
</div>
</div>
)
}
}
// RouteHOC()
export default (ChoquesEditor);

@ -0,0 +1,237 @@
import React, {Component} from "react";
import {Link, NavLink} from 'react-router-dom';
import {WordsBtn, ActionBtn,SnackbarHOC,getImageUrl} from 'educoder';
import axios from 'axios';
import {
notification,
Spin,
Table,
Pagination,
Tabs,
Input,
Popover
} from "antd";
import './../questioncss/questioncom.css';
import NoneDatas from '../component/NoneDatas';
import LoadingSpin from '../../../common/LoadingSpin';
import Contentquestionbank from "./Contentquestionbank";
import Listjihe from "./Listjihe";
const { TabPane } = Tabs;
const Search = Input.Search;
class Contentpart extends Component {
constructor(props) {
super(props);
this.state = {
page:1,
}
}
//初始化
componentDidMount(){
}
render() {
let {page}=this.state;
let {defaultActiveKey}=this.props;
const content = (
<div className="questiontypes" style={{
width:'93px',
height:'161px',
}}>
<p className="questiontype " onClick={()=>this.props.setitem_types("SINGLE")}>单选题</p>
<p className="questiontypeheng" ></p>
<p className="questiontype " onClick={()=>this.props.setitem_types("MULTIPLE")}>多选题</p>
<p className="questiontypeheng"></p>
<p className="questiontype " onClick={()=>this.props.setitem_types("JUDGMENT")}>判断题</p>
<p className="questiontypeheng"></p>
<p className="questiontype " onClick={()=>this.props.setitem_types("PROGRAM")}>编程题</p>
<p className="questiontypeheng"></p>
</div>
);
const contents = (
<div className="questiontypes" style={{
width:'93px',
height:'120px',
}}>
<p className="questiontype " onClick={()=>this.props.setdifficulty(1)}>简单</p>
<p className="questiontypeheng"></p>
<p className="questiontype " onClick={()=>this.props.setdifficulty(2)}>适中</p>
<p className="questiontypeheng"></p>
<p className="questiontype " onClick={()=>this.props.setdifficulty(3)}>困难</p>
<p className="questiontypeheng"></p>
</div>
);
const buttonWidth = 70;
//console.log("Contentpart");
//console.log(this.props);
return (
<div className=" clearfix mt40">
<div className="educontent mt10 pb20 w1200s">
<div className="w1200ms contentparttit" style={{
position: "relative",
}}>
<style>
{
`
.contentparttit .ant-tabs-nav .ant-tabs-tab{
margin: 10px 10px 10px 0 !important;
}
.contentparttit .ant-tabs-nav .ant-tabs-ink-bar{
width: 31px !important;
left: 14px;
}
`
}
</style>
<Tabs defaultActiveKey={defaultActiveKey} onChange={(e)=>this.props.callback(e)}>
<TabPane tab="公共" key="1">
</TabPane>
<TabPane tab="我的" key="0">
</TabPane>
</Tabs>
<div className=" mt19" style={{
position:"absolute",
top: "0px",
right:" 0px",
paddingRight: "20px",
}}>
<style>
{
`
.xaxisreverseorder .ant-input-group-addon{
width: 60px !important;
}
.xaxisreverseorder .ant-input-lg {
height: 41px;}
.xaxisreverseorder .ant-popover{
top: 348px !important;
}
.ant-popover-inner-content {
padding:0px !important;
}
`
}
</style>
<div className="xaxisreverseorder">
{
defaultActiveKey===0||defaultActiveKey==="0"?
<a href={'/question/newitem'}>
<div className="newbutoon">
<p className="newbutoontes" >新增</p>
</div>
</a>
:""
}
<Popover placement="bottom" content={contents} trigger="click" visible={this.props.visiblemys} onVisibleChange={()=>this.props.handleVisibleChange(true)}>
<div className=" sortinxdirection mr10">
<div className="subjecttit">
难度
</div>
<i className="iconfont icon-sanjiaoxing-down font-12 lg ml7 icondowncolor"></i>
</div>
</Popover>
<Popover placement="bottom" content={content} trigger="click" visible={this.props.visiblemyss} onVisibleChange={()=>this.props.handleVisibleChanges(true)}>
<div className="sortinxdirection mr40">
<div className="subjecttit">
题型
</div>
<i className="iconfont icon-sanjiaoxing-down font-12 lg ml7 icondowncolor"></i>
</div>
</Popover>
<Search
style={{ width: "347px",marginRight:"60px",}}
placeholder="请输入题目名称、内容"
enterButton
size="large"
onInput={(e)=>this.props.setdatafunsval(e)}
onSearch={ (value)=>this.props.setdatafuns(value)} />
</div>
</div>
</div>
{/*内容*/}
{
this.props.Contentdata.items === undefined ||this.props.Contentdata.items === null||this.props.Contentdata.items.length===0 ?
<div className=" w100s mb10"></div>
:
<div className=" w100s mb10">
{
defaultActiveKey===1||defaultActiveKey==="1"?
<Contentquestionbank {...this.props} {...this.state} selectallquestionsonthispage={()=>this.props.selectallquestionsonthispage()}></Contentquestionbank>
:""
}
{
defaultActiveKey===0||defaultActiveKey==="0"?
<Contentquestionbank {...this.props} {...this.state} selectallquestionsonthispage={()=>this.props.selectallquestionsonthispage()}></Contentquestionbank>
:""
}
</div>
}
<div className="minheight">
{/*列表集合*/}
<div className=" w100s">
{
this.props.booljupyterurls===true?
<LoadingSpin></LoadingSpin>
:
this.props.Contentdata.items === undefined ||this.props.Contentdata.items === null||this.props.Contentdata.items.length===0?
<NoneDatas></NoneDatas>
: this.props.Contentdata.items.map((object, index) => {
return (
<Listjihe {...this.state} {...this.props} items={object}
getitem_basketss={(id)=>this.props.getitem_basketss(id)}
getitem_baskets={(e)=>this.props.getitem_baskets(e)}
showmodels={(e)=>this.props.showmodels(e)}
showmodelysl={(e)=>this.props.showmodelysl(e)}>
</Listjihe>
)
})}
</div>
</div>
</div>
</div>
)
}
}
export default Contentpart

@ -0,0 +1,70 @@
import React, {Component} from "react";
import {Link, NavLink} from 'react-router-dom';
import {WordsBtn, ActionBtn,SnackbarHOC,getImageUrl} from 'educoder';
import axios from 'axios';
import {
notification,
Spin,
Table,
Pagination,
Radio,
Checkbox
} from "antd";
import './../questioncss/questioncom.css';
class Contentquestionbank extends Component {
constructor(props) {
super(props);
this.state = {
page:1,
}
}
//初始化
componentDidMount(){
////console.log("componentDidMount");
////console.log(this.state);
////console.log(this.props);
// let homeworkid = this.props.match.params.homeworkid;
// let url = "/homework_commons/" + homeworkid + "/end_groups.json";
// axios.get(url).then((response) => {
// if (response.status === 200) {
// this.setState({})
// }
// }).catch((error) => {
// ////console.log(error)
// });
}
onChange=(e)=> {
////console.log(`checked = ${e.target.checked}`);
}
render() {
let {page}=this.state;
return (
<div className=" clearfix mt5 Contentquestionbankstyle">
<div className="educontent mt10 w100s">
<div className="sortinxdirection w100s" >
<div className="sortinxdirection w50s">
<Checkbox onChange={()=>this.props.selectallquestionsonthispage()}></Checkbox>
<p className="setequesbank ml20">选用本页全部试题</p>
</div>
<div className="xaxisreverseorder testpaper w50s">
{this.props.items_count?this.props.items_count:0}个试题
</div>
</div>
</div>
</div>
)
}
}
export default Contentquestionbank ;

@ -0,0 +1,277 @@
import React, {Component} from "react";
import {Link, NavLink} from 'react-router-dom';
import {WordsBtn, ActionBtn,SnackbarHOC,getImageUrl} from 'educoder';
import axios from 'axios';
import {
notification,
Spin,
Table,
Pagination,
} from "antd";
import './../questioncss/questioncom.css';
class Headplugselection extends Component {
constructor(props) {
super(props);
this.state = {
page:1,
titlestting:"全部",
titlesttingid:null,
titlesttings:null,
titlesttingss:null,
}
}
//初始化
componentDidMount(){
}
//
// setdiscipline_id={(e)=>this.setdiscipline_id(e)}
// setsub_discipline_id={(e)=>this.setsub_discipline_id(e)}
// settag_discipline_id={(e)=>this.settag_discipline_id(e)}
settitlestting=(name,id)=>{
//如果全部其他的选项重置
this.setState({
titlestting:name,
titlesttingid:id,
titlesttings:null,
titlesttingsid:null,
titlesttingss:null,
titlesttingssid:null
})
if(name==="全部"){
this.props.setdiscipline_id(null);
}else{
this.props.setdiscipline_id(id);
}
}
settitlesttings=(name,id)=>{
//课程选项
this.setState({
titlesttings:name,
titlesttingsid:id,
titlesttingss:null,
})
this.props.setsub_discipline_id(id);
}
settitlesttingss=(name,id)=>{
//知识点
if(this.state.titlesttings===null){
this.props.showNotification('请先选择课程');
return
}
this.setState({
titlesttingss:name,
titlesttingssid:id
})
this.props.settag_discipline_id(id);
}
render() {
let {page,titlestting,titlesttings,titlesttingss}=this.state;
// console.log("Headplugselection");
// console.log(this.props.disciplinesdata);
// disciplinesdatakc:kc,
// disciplinesdatazsd:zsd,
var kc=0;
var zsd=0;
if(this.props.disciplinesdata){
const didata = this.props.disciplinesdata;
for (var i = 0; i < didata.length; i++) {
//方向
const fxdidata = didata[i].sub_disciplines;
if(titlestting===didata[i].name){
for (var j = 0; j < fxdidata.length; j++) {
kc=kc+1;
//课程
const zsddata = fxdidata[j].tag_disciplines;
for (var k = 0; k < zsddata.length; k++) {
//知识点
zsd=zsd+1;
}
}
}else if(titlestting==="全部"){
kc=kc+1;
zsd=zsd+1;
}else{
}
}
}
return (
<div className=" clearfix mt21 ">
<div className="educontent w1200dbl">
<div className="clearfix edu-back-white tophoms">
{/*课程*/}
<div className=" sortinxdirection">
<div className="w60 tophomsembolds">
方向
</div>
<div className="sortinxdirection minleng40">
<div className={titlestting==="全部"?" titlesttingcss xiaoshou":" titlesttingcssmy xiaoshou"} onClick={()=>this.settitlestting("全部",null)}>
全部
</div>
{this.props.disciplinesdata&&this.props.disciplinesdata.map((object, index) => {
return (
<div className={titlestting===object.name?" xiaoshou titlesttingcss":" titlesttingcssmy xiaoshou"} onClick={()=>this.settitlestting(object.name,object.id)}>
{object.name}
</div>
)
})}
</div>
</div>
{/*课程*/}
{
kc===0?
""
:
<div className="mt30 sortinxdirection">
<div className="w60 tophomsembolds">
课程
</div>
<div className="sortinxdirection minleng40">
{this.props.disciplinesdata&&this.props.disciplinesdata.map((objectn, index) => {
return (
titlestting==="全部"?
objectn.sub_disciplines&&objectn.sub_disciplines.map((object, indexs) => {
return (
<div className={index===0&&indexs===0&&titlesttings===object.name?"titlesttingcss xiaoshou":index===0&&indexs===0&&titlesttings!==object.name?"titlesttingcssmy xiaoshou"
:titlesttings===object.name?" titlesttingcss xiaoshou":"titlesttingcssmy xiaoshou"} onClick={()=>this.settitlesttings(object.name,object.id)}>
{object.name}
</div>
)
})
:
objectn.name===titlestting?
objectn.sub_disciplines&&objectn.sub_disciplines.map((object, indexs) => {
return (
<div className={index===0&&indexs===0&&titlesttings===object.name?"titlesttingcss xiaoshou":index===0&&indexs===0&&titlesttings!==object.name?"titlesttingcssmy xiaoshou"
:titlesttings===object.name?" titlesttingcss xiaoshou":"titlesttingcssmy xiaoshou"} onClick={()=>this.settitlesttings(object.name,object.id)}>
{object.name}
</div>
)
})
: ""
)
})}
</div>
</div>
}
{/*知识点*/}
{
zsd===0?
""
:<div className="mt30 sortinxdirection">
<div className="w60 tophomsembolds">
知识点
</div>
<div className="sortinxdirection minleng40">
{this.props.disciplinesdata&&this.props.disciplinesdata.map((objecta, index) => {
return (
titlestting==="全部"&&titlesttings===null?
objecta.sub_disciplines&&objecta.sub_disciplines.map((objectb, indexs) => {
return (
objectb.tag_disciplines&&objectb.tag_disciplines.map((object, indexss) => {
return (
<div className={index===0&&indexs===0&&indexss===0&&titlesttingss===object.name?"titlesttingcss xiaoshou":
index===0&&indexs===0&&indexss===0&&titlesttingss!==object.name?"titlesttingcssmy xiaoshou"
:titlesttingss===object.name?" titlesttingcss xiaoshou":" titlesttingcssmy xiaoshou"} onClick={()=>this.settitlesttingss(object.name)}>
{object.name}
</div>
)
})
)
})
:titlestting==="全部"&&titlesttings!==null?
objecta.sub_disciplines&&objecta.sub_disciplines.map((objectb, indexs) => {
return (
titlesttings===objectb.name?
objectb.tag_disciplines&&objectb.tag_disciplines.map((object, indexss) => {
return (
<div className={index===0&&indexs===0&&indexss===0&&titlesttingss===object.name?"titlesttingcss xiaoshou":
index===0&&indexs===0&&indexss===0&&titlesttingss!==object.name?"titlesttingcssmy xiaoshou"
:titlesttingss===object.name?" titlesttingcss xiaoshou":" titlesttingcssmy xiaoshou"} onClick={()=>this.settitlesttingss(object.name)}>
{object.name}
</div>
)
}):""
)
})
: titlestting!=="全部"&&titlesttings!==null?
titlestting===objecta.name?
objecta.sub_disciplines&&objecta.sub_disciplines.map((objectb, indexs) => {
return (
titlesttings===objectb.name?
objectb.tag_disciplines&&objectb.tag_disciplines.map((object, indexss) => {
return (
<div className={index===0&&indexs===0&&indexss===0&&titlesttingss===object.name?"titlesttingcss xiaoshou":
index===0&&indexs===0&&indexss===0&&titlesttingss!==object.name?"titlesttingcssmy xiaoshou"
:titlesttingss===object.name?" titlesttingcss xiaoshou":" titlesttingcssmy xiaoshou"} onClick={()=>this.settitlesttingss(object.name)}>
{object.name}
</div>
)
}):""
)
})
:""
: titlestting!=="全部"&&titlesttings===null?
titlestting===objecta.name?
objecta.sub_disciplines&&objecta.sub_disciplines.map((objectb, indexs) => {
return (
objectb.tag_disciplines&&objectb.tag_disciplines.map((object, indexss) => {
return (
<div className={index===0&&indexs===0&&indexss===0&&titlesttingss===object.name?"titlesttingcss xiaoshou":
index===0&&indexs===0&&indexss===0&&titlesttingss!==object.name?"titlesttingcssmy xiaoshou"
:titlesttingss===object.name?" titlesttingcss xiaoshou":" titlesttingcssmy xiaoshou"} onClick={()=>this.settitlesttingss(object.name)}>
{object.name}
</div>
)
})
)
})
:""
:""
)
})}
</div>
</div>
}
</div>
</div>
</div>
)
}
}
export default Headplugselection ;

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save