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

yslnewtiku
杨树明 5 years ago
commit 80ea35df88

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

@ -1,14 +1,58 @@
class LibrariesController < ApplicationController
class ItemBanksController < ApplicationController
include PaginateHelper
before_action :require_login
before_action :find_item, except: [:index, :create]
before_action :edit_auth, only: [:update, :destroy, :set_public]
def index
default_sort('updated_at', 'desc')
@items = ItemBankQuery.call(params)
@items = paginate courses.includes(:school, :students, :attachments, :homework_commons, teacher: :user_extension)
items = ItemBankQuery.call(params)
@items_count = items.size
@items = paginate items.includes(:item_analysis, :user)
@item_basket_ids = current_user.item_baskets.pluck(:item_bank_id)
end
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
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

@ -0,0 +1,49 @@
class ItemBasketsController < ApplicationController
before_action :require_login
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
private
def create_params
params.permit(item_ids: [])
end
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

@ -1,11 +1,18 @@
class ItemBank < ApplicationRecord
# 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 }
# item_type: 0 单选 1 多选 2 判断 3 填空 4 简答 5 实训 6 编程
belongs_to :user
belongs_to :sub_discipline
has_one :item_analysis, dependent: :destroy
has_many :item_choices, 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

@ -1,4 +1,14 @@
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 :user
def all_score
User.current.item_baskets.map(&:score).sum
end
def question_count
User.current.item_baskets.size
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 :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
scope :active, lambda { where(status: STATUS_ACTIVE) }

@ -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,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].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 %>
</li>
<li><%= sidebar_item(admins_disciplines_path, '课程体系', icon: 'sitemap', controller: 'admins-disciplines') %></li>
<li>
<%= sidebar_item_group('#course-submenu', '课堂管理', icon: 'book') do %>
<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,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,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

@ -54,8 +54,19 @@ Rails.application.routes.draw do
end
end
resources :disciplines, only: [:index]
resources :item_banks do
member do
post :set_public
end
end
resources :item_baskets do
collection do
get :basket_list
delete :delete_item_type
end
end
@ -1250,6 +1261,10 @@ Rails.application.routes.draw do
resources :courses, only: [:index, :destroy, :update]
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
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

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 = {
// 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
devtool: "cheap-module-eval-source-map",
//devtool: "cheap-module-eval-source-map",
// 开启调试
//devtool: "source-map", // 开启调试
// These are the "entry points" to our application.

@ -397,9 +397,9 @@ label.infolabel{display: block;float: left;width: 56px;text-align: right;margin-
.task-colspan{min-width:25%;text-align: left;display: block;float: left;color: #999; }
.colspan-grey{border-radius: 12px;background-color: #E6E6E6;padding: 3px 10px;color: #747A7F}
/*新建任务*/
.challenge_nav{padding: 40px 20px 0px 20px;border-bottom: 1px solid #eee;}
.challenge_nav li{width: auto;float: left;margin-right: 40px;position: relative}
.challenge_nav li.active:after{position: absolute;content: '';width: 50%;background-color: #4CACFF;height: 3px;border-radius: 2px;left: 25%;bottom: 0px;}
.challenge_nav{padding: 20px 20px 0px 20px;border-bottom: 1px solid #eee;}
.challenge_nav li{width: auto;float: left;margin-right: 20px;position: relative}
.challenge_nav li.active:after{position: absolute;content: '';width: 76%;background-color: #4CACFF;height: 3px;border-radius: 2px;left: 25%;bottom: 0px;}
.challenge_nav li a{display: block;width: 100%;padding-bottom: 20px;}
.add_choose_type{width: 60px;height: 20px;line-height: 19px;border-radius: 2px;background-color: #eaeaea;color: #999!important;display: block;float: left;text-align: center;margin-top: 4px;}

@ -301,6 +301,22 @@ const Developer = Loadable({
loader: () => import('./modules/developer'),
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 College = Loadable({
loader: () => import('./college/College'),
@ -727,6 +743,19 @@ class App extends Component {
(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"
render={
(props) => (<StudentStudy {...this.props} {...props} {...this.state} />)
@ -736,7 +765,10 @@ class App extends Component {
render={
(props) => (<Developer {...this.props} {...props} {...this.state} />)
}/>
<Route path="/question"
render={
(props) => (<Headplugselection {...this.props} {...props} {...this.state} />)
}/>
<Route exact path="/"
// component={ShixunsHome}
render={

@ -285,10 +285,10 @@ class Bullsubdirectory extends Component{
const {getFieldDecorator} = this.props.form;
// console.log("Bullsubdirectory");
// console.log(this.props.isAdmin());
console.log(this.props);
console.log(whethertoeditysl);
console.log(this.state.eduintits);
console.log(this.state.description);
// console.log(this.props);
// console.log(whethertoeditysl);
// console.log(this.state.eduintits);
// console.log(this.state.description);
return(
<React.Fragment key={this.props.index} id={this.props.id}>

@ -0,0 +1,846 @@
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);
});
}
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">
<Input placeholder="未命名试卷"/>
</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">
试卷预览
</div>
</div>
</div>
:
<div className="drawernonedatadiv intermediatecenter">
<NoneData></NoneData>
</div>
}
</Drawer>
</div>
)
}
}
export default SnackbarHOC()(TPMIndexHOC(Question));

@ -0,0 +1,584 @@
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={{}}
>
<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 ;

@ -0,0 +1,604 @@
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';
const InputGroup = Input.Group;
const {Option} = Select;
const options = [
{
value: '方向',
label: '方向',
children: [
{
value: '课程',
label: '课程',
},
],
},
{
value: 'jiangsu',
label: 'Jiangsu',
children: [
{
value: 'nanjing',
label: 'Nanjing',
},
],
},
];
class Itembankstop extends Component {
constructor(props) {
super(props);
this.contentMdRef = React.createRef()
this.state = {
page: 1,
Knowpoints: [],
rbtx: undefined,
rbkc: undefined,
knowledgepoints: [],
options: [],
}
}
//初始化
componentDidMount() {
try {
this.props.getcontentMdRef(this);
} catch (e) {
}
this.setState({
options: this.props.disciplmy
})
// knowledgepoints:this.props.knowledgepoints,
////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)
// });()
// 题型
}
componentDidUpdate(prevProps) {
if (prevProps.item_banksedit !== this.props.item_banksedit) {
if (this.props.item_banksedit.item_type) {
this.handleFormtixing(this.props.item_banksedit.item_type);
}
if (this.props.item_banksedit.difficulty) {
this.handleFormLayoutChange(this.props.item_banksedit.difficulty);
}
if (this.props.item_banksedit.tag_disciplines) {
this.handletag_disciplinesChange(this.props.item_banksedit.tag_disciplines);
}
if (this.props.item_banksedit.discipline &&this.props.item_banksedit.sub_discipline) {
this.handdisciplinesChange(this.props.item_banksedit.discipline,this.props.item_banksedit.sub_discipline);
}
}
if (prevProps.disciplmy !== this.props.disciplmy) {
this.setState({
options: this.props.disciplmy
})
}
}
handdisciplinesChange =(name,title)=>{
this.setState({
rbkc:[name.id,title.id]
})
this.props.form.setFieldsValue({
rbkc: [name.id,title.id],
});
if(this.props.item_banksedit.tag_disciplines.length===0){
const didata = this.props.disciplinesdata;
const knowledgepointsdata = [];
for (var i = 0; i < didata.length; i++) {
//方向
if (name.id === didata[i].id) {
const fxdidata = didata[i].sub_disciplines;
for (var j = 0; j < fxdidata.length; j++) {
//课程
if (title.id === fxdidata[j].id) {
const zsddata = fxdidata[j].tag_disciplines;
for (var k = 0; k < zsddata.length; k++) {
//知识点
knowledgepointsdata.push(zsddata[k]);
}
}
}
}
}
this.setState({
Knowpoints: [],
knowledgepoints: knowledgepointsdata,
})
}
}
handletag_disciplinesChange = (data) => {
try {
var sju=data[data.length-1].name;
this.setState({
rbzsd:sju,
Knowpoints:data,
})
this.props.form.setFieldsValue({
rbzsd: sju,
});
}catch (e) {
}
}
onChange = (e) => {
}
Getdatas = () => {
return this.handleSubmits();
}
handleSubmits = () => {
var data = [];
this.props.form.validateFields((err, values) => {
data = []
if (!err) {
// ////console.log("获取的form 数据");
// ////console.log(values);
data.push({
rbnd: parseInt(values.rbnd)
})
data.push({
rbtx: values.rbtx
})
data.push({
rbzsd: this.state.Knowpoints
})
data.push({
rbkc: values.rbkc
})
}
});
return data;
}
handleSubmit = (e) => {
e.preventDefault();
this.props.form.validateFields((err, values) => {
if (!err) {
////console.log("获取的form 数据");
////console.log(values);
}
});
}
handleFormLayoutChange = (value) => {
//难度塞选
////console.log("难度塞选");
////console.log(value);
this.props.form.setFieldsValue({
rbnd: value + "",
});
this.setState({
rbnd: value + "",
})
}
handleFormkechen = (value) => {
//课程
////console.log("课程");
////console.log(value);
var valuename = undefined;
this.props.form.setFieldsValue({
rbzsd: value,
});
var arr = this.state.knowledgepoints;
for (let data of arr) {
if (data.id === value) {
this.state.Knowpoints.push(data);
valuename = data.name;
}
}
var tmp = JSON.parse(JSON.stringify(this.state.knowledgepoints));
for (var i = 0; i < tmp.length; i++) {
if (tmp[i].id === value) {
this.state.knowledgepoints.splice(i, 1);
}
}
this.setState({
rbzsd: valuename,
Knowpoints: this.state.Knowpoints,
knowledgepoints: this.state.knowledgepoints,
})
}
handleFormzhishidian = (value) => {
console.log("handleFormzhishidian 课程");
console.log(value);
//课程
this.props.form.setFieldsValue({
rbkc: value,
});
this.setState({
rbkc:value,
})
// console.log("handleFormzhishidian");
// console.log(this.props.disciplinesdata);
const didata = this.props.disciplinesdata;
const knowledgepointsdata = [];
for (var i = 0; i < didata.length; i++) {
//方向
if (value[0] === didata[i].id) {
const fxdidata = didata[i].sub_disciplines;
for (var j = 0; j < fxdidata.length; j++) {
//课程
if (value[1] === fxdidata[j].id) {
const zsddata = fxdidata[j].tag_disciplines;
for (var k = 0; k < zsddata.length; k++) {
//知识点
knowledgepointsdata.push(zsddata[k]);
}
}
}
}
}
this.setState({
Knowpoints: [],
knowledgepoints: knowledgepointsdata,
})
this.props.form.setFieldsValue({
rbzsd: undefined,
});
this.setState({
rbzsd: undefined,
})
}
handleFormtixing = (value) => {
//题型
//console.log("题型");
//console.log(value);
this.setState({
rbtx: value + "",
})
this.props.form.setFieldsValue({
rbtx: value + "",
});
this.props.setitem_type(value);
}
preventDefault = (e) => {
e.preventDefault();
////console.log('Clicked! But prevent default.');
}
deletesobject = (item, index) => {
var arr = this.state.Knowpoints;
for (let data of arr) {
if (data.id === item.id) {
this.state.knowledgepoints.push(data);
}
}
var tmp = JSON.parse(JSON.stringify(this.state.Knowpoints));
for (var i = 0; i < tmp.length; i++) {
if (i >= index) {
var pos = this.state.Knowpoints.indexOf(tmp[i]);
this.state.Knowpoints.splice(pos, 1);
}
}
this.props.form.setFieldsValue({
rbzsd: this.state.Knowpoints,
});
this.setState({
Knowpoints: this.state.Knowpoints,
})
if (this.state.Knowpoints.length === 0) {
this.setState({
rbzsd: undefined,
})
} else if (this.state.Knowpoints.length > 0) {
try {
const myknowda = this.state.Knowpoints;
this.setState({
rbzsd: myknowda[this.state.Knowpoints.length - 1].name,
})
} catch (e) {
}
}
}
render() {
let {page, options} = this.state;
const {getFieldDecorator} = this.props.form;
//console.log("renderrenderrender");
//console.log(this.props.item_banksedit);
//console.log("renderrenderrendersssss");
//console.log(this.state.rbtx);
return (
<div className=" clearfix educontent Contentquestionbankstyle w100s w1200fpx mt19">
<style>
{
`
.ant-form-item{
margin-bottom: 0px !important;
}
.ant-form-explain{
padding-left:0px !important;
margin-top: 3px !important;
}
.ant-select-selection{
height: 33px !important;
}
.ant-input-group{
width:258px !important;
}
.ant-input {
height: 33px !important;
}
.ant-radio-button-wrapper-checked:not(.ant-radio-button-wrapper-disabled):focus-within {
outline: 0px solid rgba(24, 144, 255, 0.06) !important;
}
`
}
</style>
<div className="h12"></div>
<Form.Item
label="课程"
>
{getFieldDecorator("rbkc",
{
rules: [{required: true, message: '请选择课程'}],
}
)(
<div className="sortinxdirection">
<InputGroup compact>
<Cascader style={{width: '258px'}} value={this.state.rbkc} options={options} onChange={this.handleFormzhishidian}
placeholder="请选择..."/>
</InputGroup>
{/*<div className="sortinxdirection" style={{*/}
{/* height: "33px",*/}
{/* lineHeight: "28px",*/}
{/*}}>*/}
{/* {this.state.Knowpoints === undefined ? "" : this.state.Knowpoints.map((object, index) => {*/}
{/* return (*/}
{/* <div className="mytags" style={{*/}
{/* position: "relative",*/}
{/* }}>*/}
{/* <p className="w100s stestcen lh32">{object}</p>*/}
{/* <i className="iconfont icon-roundclose font-25 lg ml7 icondowncolorss" onClick={()=>this.deletesobject(object,index)}></i>*/}
{/* </div>*/}
{/* )*/}
{/* })}*/}
{/*</div>*/}
</div>
)}
</Form.Item>
<Form onSubmit={this.handleSubmit}>
<Form.Item
label="知识点"
>
{getFieldDecorator("rbzsd"
)(
<div className="sortinxdirection">
<InputGroup compact>
<Select style={{width: '258px'}} value={this.state.rbzsd} onChange={this.handleFormkechen}
placeholder="请选择...">
{this.state.knowledgepoints && this.state.knowledgepoints.map((object, index) => {
return (
<Option value={object.id}>{object.name}</Option>
)
})}
</Select>
</InputGroup>
<div className="sortinxdirection" style={{
height: "33px",
lineHeight: "28px",
}}>
{this.state.Knowpoints === undefined ? "" : this.state.Knowpoints.map((object, index) => {
return (
<div className="mytags" style={{
position: "relative",
}}>
<p className="w100s stestcen lh32">{object.name}</p>
<i className="iconfont icon-roundclose font-25 lg ml7 icondowncolorss"
onClick={() => this.deletesobject(object, index)}></i>
</div>
)
})}
</div>
</div>
)}
</Form.Item>
<Form.Item
label="题型"
>
{getFieldDecorator("rbtx",
{
rules: [{required: true, message: '请选择题型'}],
}
)(
<InputGroup compact>
<Select style={{width: '258px'}} value={this.state.rbtx} onChange={this.handleFormtixing}
placeholder="请选择...">
<Option value="SINGLE">单选题</Option>
<Option value="MULTIPLE">多选题</Option>
<Option value="JUDGMENT">判断题</Option>
<Option value="PROGRAM">编程题</Option>
</Select>
</InputGroup>
)}
</Form.Item>
<style>
{
`
.rbndclass .ant-radio-button-wrapper{
width:106px !important;
height:33px !important;
background:#EEEEEE;
border-radius:17px !important;
color:#333333;
text-align: center !important;
border:0px !important;
margin-right: 27px !important;
margin-top: 6px !important;
}
.rbndclass .ant-radio-button-wrapper-checked {
width: 106px !important;
height: 33px !important;
background: #4CACFF !important;
border-radius: 17px !important;
text-align: center !important;
border:0px !important;
color: #ffffff !important;
margin-right: 27px !important;
margin-top: 6px!important;
}
.rbndclass .ant-radio-button-wrapper:not(:first-child)::before{
border:0px !important;
width:0px !important;
}
.rbndclass .ant-radio-button-wrapper{
border:0px !important;
}
.rbndclass .ant-radio-group{
border:0px !important;
}
.rbndclass .ant-radio-group label{
border:0px !important;
}
.rbndclass .ant-radio-group span{
border:0px !important;
}
ant-radio-button-wrapper:focus-within {
outline: 0px solid #ffffff;
}
`
}
</style>
<div className="rbndclass">
<Form.Item label="难度">
{getFieldDecorator('rbnd',
{
rules: [{required: true, message: '请选择难度'}],
}
)(
<Radio.Group value={this.state.rbnd} onChange={this.handleFormLayoutChange}>
<Radio.Button value="1">简单</Radio.Button>
<Radio.Button value="2">适中</Radio.Button>
<Radio.Button value="3">困难</Radio.Button>
</Radio.Group>,
)}
</Form.Item>
</div>
{/*<Form.Item>*/}
{/* <Button type="primary" htmlType="submit" className="login-form-button">*/}
{/* 提交*/}
{/* </Button>*/}
{/*</Form.Item>*/}
</Form>
<div className="h20"></div>
</div>
)
}
}
const Itembankstops = Form.create({name: 'Itembankstops'})(Itembankstop);
export default Itembankstops;

@ -0,0 +1,402 @@
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 JudquestionEditor 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)
})
}
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||'',
zqda:null,
item_banksedit:[],
mychoicess:[],
}
}
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, zqda,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(zqda===null) {
this.props.showNotification('请先点击选择本选择题的正确选项');
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,zqda,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,
})
if(this.props.item_banksedit){
if(this.props.item_banksedit.choices){
for(var ik=0;ik<this.props.item_banksedit.choices.length;ik++ ){
if( this.props.item_banksedit.choices[ik].choice_text==="正确"){
if( this.props.item_banksedit.choices[ik].is_answer===true){
this.setState({
zqda:"0"
})
}
}else{
if( this.props.item_banksedit.choices[ik].is_answer===true){
this.setState({
zqda:"1"
})
}
}
}
}
}
}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,
})
if(this.props.item_banksedit){
if(this.props.item_banksedit.choices){
for(var ik=0;ik<this.props.item_banksedit.choices.length;ik++ ){
if( this.props.item_banksedit.choices[ik].choice_text==="正确"){
if( this.props.item_banksedit.choices[ik].is_answer===true){
this.setState({
zqda:"0"
})
}
}else{
if( this.props.item_banksedit.choices[ik].is_answer===true){
this.setState({
zqda:"1"
})
}
}
}
}
}
}
}
onOptionClick = (index) => {
let standard_answers = this.state.standard_answers.slice(0);
// //////console.log("onOptionClick");
// //////console.log(standard_answers);
// //////console.log(standard_answers[index]);
// //////console.log(!standard_answers[index]);
for (var i=0;i<standard_answers.length;i++){
if(index===i){
standard_answers[index] = true;
}else{
standard_answers[i] = false;
}
}
// 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 = () => {
}
handleFormLayoutChange=(e)=>{
//////console.log("难度塞选");
//////console.log(value);
this.setState({
zqda:e.target.value,
})
}
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);
const params= this.props&&this.props.match&&this.props.match.params;
return(
<div className="padding20-30 signleEditor danxuano" 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>
<style>
{
`
.choice_textcsss {
border-radius:2px !important;
}
.choice_textcss {
margin-left: 40px !important;
border-radius:2px !important;
}
`
}
</style>
<div className="mb15 sortinxdirection ">
<Radio.Group buttonStyle="solid" value={this.state.zqda} onChange={this.handleFormLayoutChange}>
<Radio.Button value="0" className={"choice_textcsss"}>正确</Radio.Button>
<Radio.Button value="1" className={"choice_textcss"}>错误</Radio.Button>
</Radio.Group>
</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 (JudquestionEditor);

@ -0,0 +1,179 @@
import React, {Component} from "react";
import {Link, NavLink} from 'react-router-dom';
import {WordsBtn, ActionBtn,SnackbarHOC,getImageUrl,markdownToHTML} from 'educoder';
import axios from 'axios';
import {
notification,
Spin,
Table,
Pagination,
Radio
} from "antd";
import './../questioncss/questioncom.css';
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 Listjihe extends Component {
constructor(props) {
super(props);
this.state = {
page:1,
name:"单选题",
nd:"简单",
chakanjiexibool:false,
}
}
//初始化
componentDidMount(){
}
chakanjiexibool=()=>{
if(this.state.chakanjiexibool===true){
this.setState({
chakanjiexibool:false
})
}else{
this.setState({
chakanjiexibool:true
})
}
}
//选用
Selectingpracticaltraining=(id)=>{
let data={
item_ids:[id]
}
this.props.getitem_baskets(data);
}
//撤销
Selectingpracticaltrainings=(id)=>{
this.props.getitem_basketss(id);
}
render() {
let {page,name,nd,chakanjiexibool}=this.state;
let {defaultActiveKey,items}=this.props;
////console.log("Listjihe");
////console.log(this.props);
return (
<div className={chakanjiexibool===true?"w100s borderwds283 pd20 mb20":"w100s borderwds pd20 mb20"}>
{/*顶部*/}
<div className="w100s sortinxdirection">
<div className="w70s listjihetixingstit markdown-body" style={{wordBreak: "break-word"}} dangerouslySetInnerHTML={{__html: markdownToHTML(items&&items.name).replace(/▁/g, "▁▁▁")}}>
</div>
<div className="w30s xaxisreverseorder">
<p className="listjihetixing">难度<span className="listjihetixings">{items.difficulty===1?"简单":items.difficulty===2?"适中":items.difficulty===3?"困难":""}</span></p>
<p className="mr30 listjihetixing">题型<span className="listjihetixings">{items.item_type==="SINGLE"?"单选题":items.item_type==="MULTIPLE"?"多选题":items.item_type==="JUDGMENT"?"判断题":items.item_type==="PROGRAM"?"编程题":""}</span></p>
</div>
</div>
{/*内容*/}
<div className="w100s sortinxdirection">
<p className="w100s listjihetixingstits sortinxdirection ">
{
items.item_type==="JUDGMENT"?
items === undefined ||items === null? "" : items.choices.map((object, index) => {
return (
<p className={index===1? "sortinxdirection ml10":"sortinxdirection " } >
<Radio checked={object.is_answer}>
{object.choice_text}
</Radio>
</p>
)
})
:
items === undefined ||items === null? "" : items.choices.map((object, index) => {
return (
<p className="sortinxdirection ml10" >
{tagArray[index]}
<p style={{wordBreak: "break-word"}} dangerouslySetInnerHTML={{__html: markdownToHTML(object.choice_text).replace(/▁/g, "▁▁▁")}}></p>
</p>
)
})
}
</p>
</div>
{/*更新时间*/}
<div className="w100s sortinxdirection mt22">
<div className="w50s listjihetixingstit sortinxdirection">
<p className="updatetimes lh30">更新时间{items.update_time}</p>
{
this.props.defaultActiveKey==="0"||this.props.defaultActiveKey===0?
""
:
<p className="updatetimes lh30 ml45">创建者{items.author.name}</p>
}
</div>
<div className="w50s xaxisreverseorder">
{
items.choosed===true?
<p className="selectionss xiaoshou" onClick={()=>this.Selectingpracticaltrainings(items.id)}>
<i className="iconfont icon-jianhao font-12 lg ml7 lh30 icontianjiadaohangcolor mr10"></i>
<span>撤销</span></p>
:
<p className="selection xiaoshou" onClick={()=>this.Selectingpracticaltraining(items.id)}>
<i className="iconfont icon-tianjiadaohang font-12 lg ml7 lh30 icontianjiadaohangcolor mr10"></i>
<span>选用</span></p>
}
{
defaultActiveKey===0||defaultActiveKey==="0"?
<div className="xaxisreverseorder">
<p className="viewparsings xiaoshou mr25" onClick={()=>this.props.showmodelysl(items.id)}>
<i className="iconfont icon-shanchu1 font-17 lg ml7 lh30 icontianjiadaohangcolors mr5"></i>
<span>删除</span>
</p>
<a href={`/question/edit/${items.id}`}>
<p className="viewparsings xiaoshou mr25" >
<i className="iconfont icon-bianji2 font-17 lg ml7 lh30 icontianjiadaohangcolors mr5"></i>
<span>编辑</span>
</p>
</a>
<p className="viewparsings xiaoshou mr25" onClick={()=>this.props.showmodels(items.id)}>
<i className="iconfont icon-gongkai font-17 lg ml7 lh30 icontianjiadaohangcolors mr5"></i>
<span>公开</span>
</p>
</div>
:""
}
<p className="viewparsings xiaoshou mr25" onClick={()=>this.chakanjiexibool()}>
<i className="iconfont icon-jiexi font-17 lg ml7 lh30 icontianjiadaohangcolors mr5"></i>
查看解析</p>
</div>
</div>
{
chakanjiexibool===true?<div>
<div className="w100s questiontypeheng mt23">
</div>
<p className="analysis mt22">解析</p>
<p className="mt15 testfondex"
style={{wordBreak: "break-word"}} dangerouslySetInnerHTML={{__html: markdownToHTML(items.analysis).replace(/▁/g, "▁▁▁")}}
>
</p>
</div>:""
}
</div>
)
}
}
export default Listjihe;

@ -0,0 +1,37 @@
import React, { Component } from 'react';
import { getImageUrl , getUrl } from 'educoder';
class NoneData extends Component{
constructor(props) {
super(props)
}
render(){
const { style } = this.props;
return(
<div className="edu-tab-con-box clearfix edu-txt-center intermediatecenter" style={ style || { width:"100%",height:"100%"}}>
<style>
{`
.edu-tab-con-box{
padding:100px 0px;
}
.ant-modal-body .edu-tab-con-box{
padding:0px!important;
}
img.edu-nodata-img{
margin: 40px auto 20px;
}
.zenwuxgsj{
font-size:17px;
font-family:MicrosoftYaHei;
color:rgba(136,136,136,1);
}
`}
</style>
<img className="edu-nodata-img mb20" src={getUrl("/images/educoder/nodata.png")}/>
<p className="edu-nodata-p mb10 zenwuxgsj">暂无相关数据</p>
<p className="edu-nodata-p mb20 mt4 zenwuxgsj">请选择试题进行组卷</p>
</div>
)
}
}
export default NoneData;

@ -0,0 +1,36 @@
import React, { Component } from 'react';
import { getImageUrl , getUrl } from 'educoder';
class NoneDatas extends Component{
constructor(props) {
super(props)
}
render(){
const { style } = this.props;
return(
<div className="edu-tab-con-box clearfix edu-txt-center intermediatecenter" style={ style || { width:"100%",height:"100%"}}>
<style>
{`
.edu-tab-con-box{
padding:100px 0px;
}
.ant-modal-body .edu-tab-con-box{
padding:0px!important;
}
img.edu-nodata-img{
margin: 40px auto 20px;
}
.zenwuxgsj{
font-size:17px;
font-family:MicrosoftYaHei;
color:rgba(136,136,136,1);
}
`}
</style>
<img className="edu-nodata-img mb20" src={getUrl("/images/educoder/nodata.png")}/>
<p className="edu-nodata-p mb10 zenwuxgsj">暂无相关数据</p>
</div>
)
}
}
export default NoneDatas;

@ -0,0 +1,43 @@
import React, { Component } from 'react';
import {getImageUrl} from 'educoder';
import { Modal} from 'antd';
import axios from 'axios';
import './../questioncss/questioncom.css'
//立即申请试用
class QuestionModal extends Component {
constructor(props) {
super(props);
this.state={
}
}
render() {
return(
<Modal
keyboard={false}
closable={false}
footer={null}
destroyOnClose={true}
title="提示"
centered={true}
visible={this.props.modalsType===undefined?false:this.props.modalsType}
width="442px"
>
<div className="educouddiv">
<div className={"tabeltext-alignleft mt10"}><p className="titiles">{this.props.titilesm}</p></div>
<div className={"tabeltext-alignleft mt10"}><p className="titiles">{this.props.titiless}</p></div>
<div className="clearfix mt30 edu-txt-center">
<a className="task-btn mr30 w80" onClick={()=>this.props.modalCancel()}>取消</a>
<a className="task-btn task-btn-orange w80" onClick={()=>this.props.setDownload()}>确定</a>
</div>
</div>
</Modal>
)
}
}
export default QuestionModal;

@ -0,0 +1,66 @@
import React, { Component } from 'react';
import {getImageUrl} from 'educoder';
import { Modal} from 'antd';
import axios from 'axios';
import './../questioncss/questioncom.css'
//立即申请试用
class QuestionModals extends Component {
constructor(props) {
super(props);
this.state={
}
}
render() {
return(
<Modal
keyboard={false}
closable={false}
footer={null}
destroyOnClose={true}
title="提示"
centered={true}
visible={this.props.modalsTypes===undefined?false:this.props.modalsTypes}
width="442px"
>
<div className="educouddiv">
<div className={"tabeltext-alignleft mt10"}><p className="titiles">是否删除试题栏中{
this.props.titilesms&&this.props.titilesms==="SINGLE"?
"单选题"
:
this.props.titilesms&&this.props.titilesms==="MULTIPLE"?
"多选题"
:
this.props.titilesms&&this.props.titilesms==="JUDGMENT"?
"判断题"
:
this.props.titilesms&&this.props.titilesms==="COMPLETION"?
"填空题"
:
this.props.titilesms&&this.props.titilesms==="SUBJECTIVE"?
"简答题"
:
this.props.titilesms&&this.props.titilesms==="PROGRAM"?
"编程题"
:
this.props.titilesms&&this.props.titilesms==="PRACTICAL"?
"实训题"
:""
}</p></div>
<div className="clearfix mt30 edu-txt-center">
<a className="task-btn mr30 w80" onClick={()=>this.props.modalCancels()}>取消</a>
<a className="task-btn task-btn-orange w80" onClick={()=>this.props.setDownloads(this.props.titilesms)}>确定</a>
</div>
</div>
</Modal>
)
}
}
export default QuestionModals;

@ -0,0 +1,395 @@
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 SingleEditor 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) => {
//console.log("SingleEditor");
//console.log(item);
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||'',
item_banksedit:[],
}
}
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.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;
}
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);
// ////console.log("onOptionClick");
// ////console.log(standard_answers);
// ////console.log(standard_answers[index]);
// ////console.log(!standard_answers[index]);
for (var i=0;i<standard_answers.length;i++){
if(index===i){
standard_answers[index] = true;
}else{
standard_answers[i] = false;
}
}
// 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 danxuano" 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<=1?
<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 (SingleEditor);

@ -0,0 +1,611 @@
.w1200{
width:1062px;
height:177px;
background:rgba(255,255,255,1);
box-shadow:0px 6px 8px 0px rgba(0,0,0,0.03);
border-radius:2px;
}
.w1200dbl{
width:1062px;
min-height:60px;
background:rgba(255,255,255,1);
box-shadow:0px 6px 8px 0px rgba(0,0,0,0.03);
border-radius:2px;
}
.w1200fpx{
width:1200px;
background:rgba(255,255,255,1);
box-shadow:0px 6px 8px 0px rgba(0,0,0,0.03);
border-radius:2px;
}
.w1200mss{
width:1200px;
}
.w1200ms{
width:1062px;
}
.w1200s{
width:1062px;
background:rgba(255,255,255,1);
box-shadow:0px 6px 8px 0px rgba(0,0,0,0.03);
border-radius:2px;
}
.h177{
height: 177px;
}
/* 中间居中 */
.intermediatecenter{
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
/* 简单居中 */
.intermediatecenterysls{
display: flex;
align-items: center;
}
.spacearound{
display: flex;
justify-content: space-around;
}
.spacebetween{
display: flex;
justify-content: space-between;
}
/* 头顶部居中 */
.topcenter{
display: -webkit-flex;
flex-direction: column;
align-items: center;
}
/* x轴正方向排序 */
/* 一 二 三 四 五 六 七 八 */
.sortinxdirection{
display: flex;
flex-direction:row;
}
/* x轴反方向排序 */
/* 八 七 六 五 四 三 二 一 */
.xaxisreverseorder{
display: flex;
flex-direction:row-reverse;
}
/* 垂直布局 正方向*/
/*
*/
.verticallayout{
display: flex;
flex-direction:column;
}
/* 垂直布局 反方向*/
.reversedirection{
display: flex;
flex-direction:column-reverse;
}
.w100{
width: 100px;
}
.mt21{
margin-top: 21px;
}
.mt23{
margin-top: 23px;
}
.mt19{
margin-top: 19px;
}
.mt15{
margin-top: 10px;
}
.h40{
height: 40px;
}
.tophom{
padding-top: 33px;
padding-bottom: 40px;
padding-left: 26px;
padding-right: 26px;
}
.tophoms{
padding-top: 15px;
padding-left: 26px;
padding-right: 26px;
}
.borderwd{
border: 1px solid #000000;
}
.borderwds{
width: 1020px !important;
background: #FFFFFF;
border: 1px solid #DDDDDD;
margin-left: 20px;
min-height:150px;
}
.borderwds283{
width: 1020px !important;
min-height:283px;
background:#F9F9F9;
border:1px solid #DDDDDD;
margin-left: 20px;
}
.w64{
width: 64px;
}
.w70{
width: 70px !important;
}
.tophomsembold{
height:21px;
font-size:16px;
color:#333333;
line-height:21px;
}
.tophomsembolds{
width:42px;
height:19px;
font-size:14px;
font-family:MicrosoftYaHeiSemibold;
color:rgba(51,51,51,1);
line-height:31px;
}
/*Contentpart*/
.contentparttit{
padding-top: 10px;
padding-left: 20px;
padding-right: 20px;
}
.subjecttit{
width:28px;
height:19px;
font-size:14px;
color:rgba(51,51,51,1);
line-height: 42px;
cursor:pointer;
}
.ml55{
margin-right: 55px;
}
.lg{
line-height: 42px;
}
.ml7{
margin-left: 7px;
}
.icondowncolor{
color:#9E9E9E;
}
.icondowncolorss{
color: #9E9E9E;
position: absolute;
top: -20px;
right: -16px;
}
.questiontype{
width: 100%;
font-size: 12px;
color: #333333;
line-height: 17px;
text-align: center;
padding: 11px;
cursor:pointer;
}
.questiontypes{
width:37px;
height:17px;
font-size:12px;
color:rgba(51,51,51,1);
line-height:17px;
cursor:pointer;
}
.questiontypeheng{
width:100%;
height:1px;
background: #EEEEEE;
}
.questiontype:hover{
color: #4CACFF;
}
.questiontype:active{
color: #4CACFF;
}
.w100s{
width:100%;
}
.stestcen{
text-align: center;
}
.w70s{
width:70%;
}
.w30s{
width:70%;
}
.w50s{
width: 50%;
}
.testpaper{
font-size:12px;
color:#888888;
line-height:28px;
text-align: center;
}
.setequesbank{
font-size:14px;
color:#333333;
line-height:28px;
}
.Contentquestionbankstyle{
padding-left: 20px;
padding-right: 20px;
}
.pd20{
padding-top: 20px;
padding-bottom: 20px;
padding-left: 30px;
padding-right: 30px;
}
/*listjihe*/
.listjihetixing{
color: #888888;
font-size: 12px;
line-height: 17px;
}
.listjihetixings{
color: #333333;
font-size: 12px;
line-height: 17px;
}
.listjihetixingstit{
color: #333333;
font-size: 14px;
line-height: 17px;
}
.listjihetixingstits{
color: #333333;
font-size: 14px;
line-height:19px;
margin-top: 19px;
}
.updatetimes{
color: #BBBBBB;
font-size: 12px;
}
.mt22{
margin-top: 22px;
}
.viewparsings{
color:#4CACFF;
font-size:12px;
line-height: 30px;
}
.selection{
width:88px;
height:30px;
background:#33BD8C;
border-radius:4px;
text-align: center;
line-height: 30px;
color: #FFFFFF;
}
.selectionss{
width:88px;
height:30px;
background:#eeeeee;
border-radius:4px;
text-align: center;
line-height: 30px;
color: #FFFFFF;
}
.lh30{
line-height: 30px;
}
.analysis{
height:19px;
font-size:14px;
color:#333333;
line-height:19px;
}
.testfondex{
color: #808080;
font-size: 14px;
}
.pb20{
padding-bottom: 20px;
}
.icontianjiadaohangcolor{
color: #FFFFFF;
}
.icontianjiadaohangcolors{
color: #4CACFF;
}
.xiaoshou{
cursor:pointer
}
.mt40{
margin-top: 40px;
}
.mt42{
margin-top: 42px;
}
.drawerbutton{
width:88px;
height:30px;
background:#4CACFF;
border-radius:4px;
font-size:14px;
color:#ffffff;
line-height:30px;
text-align: center;
}
.icondrawercolor{
color: #979797;
}
.mt25{
margin-top: 25px;
}
.mb26{
margin-bottom: 26px;
}
.drawernonedatadiv{
height: 100%;
}
.font-17{
font-size: 17px;
}
.ml30{
margin-right: 30px;
}
.mr25{
margin-right: 25px;
}
.newbutoon{
width:88px;
height:42px;
background:#33BD8C;
line-height: 42px;
border-radius:4px;
}
.newbutoontes{
width:100%;
height:42px;
font-size:14px;
color:#ffffff;
line-height:42px;
text-align: center;
}
.educouddiv {
display: flex;
flex-direction: column;
}
.tabeltext-alignleftysl{
font-size:14px;
color:#000000;
line-height:19px;
}
.tabeltext-alignleftysltwo{
font-size:14px;
color:#848282;
line-height:19px;
}
.publictask-btn{
width:80px;
height:34px;
background:#CCCCCC;
border-radius:4px;
color: #ffffff;
}
.publictask-btns{
width:80px;
height:34px;
background:#4CACFF;
border-radius:4px;
color: #ffffff;
}
.w80{
width: 80px;
}
.titiles{
color: #333333;
font-size: 16px;
}
.h12{
height: 12px;
min-height: 12px;
}
.mt19{
margin-top: 19px;
}
.mytags{
width:106px;
height:32px;
border-radius:2px;
border:1px solid #DDDDDD;
margin-left: 20px;
}
.lh32{
line-height: 32px;
}
.h20{
height: 20px;
min-height: 20px;
line-height: 20px;
}
.xingcolor{
color: rgba(224, 64, 64, 1);
}
.xingtigan{
font-size:14px;
color:rgba(51, 51, 51, 1);
}
.mr4{
margin-right: 4px;
}
.xingtigans{
width:100%;
font-size:14px;
color:rgba(136,136,136,1);
}
.bottomdivs{
width:100%;
height:55px;
background:rgba(255,255,255,1);
box-shadow:0px -2px 7px 0px rgba(1,6,22,0.04);
}
.mt50{
margin-top: 50px;
}
.divquxiao{
width:88px;
height:32px;
background:rgba(255,255,255,1);
border-radius:4px;
border:1px solid rgba(204,204,204,1);
}
.divquxiaotest{
width:100%;
height:32px;
font-size:12px;
color:rgba(136,136,136,1);
line-height:32px;
text-align: center;
}
.divbaocuntests{
width:100%;
height:32px;
font-size:12px;
color:#ffffff;
line-height:32px;
text-align: center;
}
.divbaocun{
width:88px;
height:32px;
background:rgba(76,172,255,1);
border-radius:4px;
}
.sortzhenque{
width:49px;
height:33px;
border-radius:2px;
border:1px solid rgba(221,221,221,1);
}
.sortzhenquetest{
width:100%;
height:33px;
font-size:14px;
color:rgba(51,51,51,1);
line-height:33px;
}
.sortquxiao{
width:49px;
height:33px;
border-radius:2px;
border:1px solid rgba(221,221,221,1);
}
.sortquxiaotest{
width:100%;
height:33px;
font-size:14px;
color:rgba(51,51,51,1);
line-height:33px;
}
.ml45{
margin-left: 45px;
}
.programcss{
height: 251px;
min-height: 100%;
}
.titlesttingcss{
min-width: 100px;
height:32px;
line-height: 32px;
background:rgba(76,172,255,1);
border-radius:16px;
text-align: center;
color: #fff;
}
.titlesttingcssmy{
min-width: 100px;
height:32px;
line-height: 32px;
font-size:14px;
color:rgba(51,51,51,1);
text-align: center;
}
.minleng40{
min-height: 40px;
}
.w60{
width: 60px !important;
}
.h30{
min-height: 30px !important;
}
.minheight{
min-height: 500px !important;
}

@ -13,7 +13,7 @@ import { getImageUrl, toPath ,trigger,broadcastChannelPostMessage} from 'educode
import axios from 'axios';
import { Modal,Checkbox ,Radio,Input,message,notification } from 'antd';
import { Modal,Checkbox ,Radio,Input,message,notification,Popover} from 'antd';
import Addcourses from '../courses/coursesPublic/Addcourses';
@ -69,6 +69,7 @@ class NewHeader extends Component {
headtypesonClickbool:false,
headtypess:"/",
mygetHelmetapi2: null,
visiblemyss:false,
}
console.log("176")
// console.log(props);
@ -705,6 +706,15 @@ submittojoinclass=(value)=>{
document.head.appendChild(link);
}
handleVisibleChanges = (boll) => {
this.setState({
visiblemyss: boll,
})
}
getAppdata=()=>{
let url = "/setting.json";
axios.get(url).then((response) => {
@ -874,7 +884,17 @@ submittojoinclass=(value)=>{
})
}
const contents = (
<div className="questiontypes" style={{
width:'93px',
height:'80px',
}}>
<a href={'/question'} ><p className="questiontype">试题库</p></a>
<p className="questiontypeheng"></p>
<a href={'/question'} ><p className="questiontype">试卷库</p></a>
<p className="questiontypeheng"></p>
</div>
);
return (
<div className="newHeaders" id="nHeader" >
@ -948,10 +968,38 @@ submittojoinclass=(value)=>{
)
})
}
{/*<li className={`${activePaths === true ? 'pr active' : 'pr'}`}>*/}
{/* <Link to={this.props.Headertop===undefined?"":'/paths'}>实践课程</Link>*/}
{/*<style>*/}
{/* {*/}
{/* `*/}
{/* .queyppors {*/}
{/* top: 63px !important;*/}
{/* }*/}
{/* .ant-popover-inner-content {*/}
{/* padding:0px !important;*/}
{/* }*/}
{/* `*/}
{/* }*/}
{/*</style>*/}
{/*<li className={`pr `}>*/}
{/* <Popover placement="bottom" content={contents} trigger="click" >*/}
{/* <div className=" sortinxdirection mr10">*/}
{/* <div style={{*/}
{/* color:"#fff"*/}
{/* }}>*/}
{/* 题库*/}
{/* </div>*/}
{/* </div>*/}
{/* </Popover>*/}
{/*</li>*/}
<li className={`pr `}>
<Link to={'/question'}>题库</Link>
</li>
{/*<li><a href={this.props.Headertop===undefined?"":'/courses'}>课堂</a></li>*/}
{/*<li className={`${coursestype === true ? 'pr active' : 'pr'}`}>*/}
{/* /!*<a href={this.props.Headertop===undefined?"":this.props.Headertop.course_url}>课堂</a>*!/*/}

@ -89,10 +89,13 @@ class SiderBar extends Component {
render() {
// console.log(this.props)
// console.log("SiderBar");
// console.log(this.props);
var mypath= this.props&&this.props.match&&this.props.match.path;
return (
<div className="-task-sidebar" >
<div className={mypath&&mypath==="/question"?"-task-sidebar myrigthsiderbar":"-task-sidebar"} >
{this.props.mygetHelmetapi&&this.props.mygetHelmetapi.main_site===true?<div>
<Tooltip placement="right" title={"返回顶部"}>
@ -103,6 +106,21 @@ class SiderBar extends Component {
</div>
</Tooltip>
{
mypath&&mypath==="/question"?
<Tooltip placement="right" title={"试题库"}>
<div className="feedback feedbackdivcolor xiaoshou" onClick={()=>this.props.showDrawer()} >
<a target="_blank" className="color_white xiaoshou" >
<i className="iconfont icon-shitilan color-white xiaoshou"></i>
</a>
<p className="color-white font-12 xiaoshou">试题库</p>
</div>
</Tooltip>
:""
}
<Tooltip placement="right" title={"意见反馈"}>
<div className="feedback">
<a target="_blank" className="color_white" href="/help/feedback">

@ -130,16 +130,19 @@ class TPMBanner extends Component {
if(this.props.status===0&&this.props.openknows===false){
if(this.props.shixunsDetails&&this.props.shixunsDetails.shixun_status === 0 && this.props.identity < 5){
if(shixunopenprocess===undefined||shixunopenprocess===false||shixunopenprocess===null){
this.setState({
openknow:true
})
}else{
this.setState({
openknow:false
})
if(this.props.user&&this.props.user.user_id){
if(shixunopenprocess===undefined||shixunopenprocess===false||shixunopenprocess===null){
this.setState({
openknow:true
})
}else{
this.setState({
openknow:false
})
}
}
}
}
}else{
this.setState({
openknow:false
@ -150,14 +153,16 @@ class TPMBanner extends Component {
if(this.props.public===0&&this.props.status>1&&this.props.openknows===false){
if(this.props.shixunsDetails&&this.props.shixunsDetails.shixun_status === 2 && this.props.shixunsDetails&&this.props.shixunsDetails.public===0 && this.props.identity < 5){
if(openopenpublictype===undefined||openopenpublictype===false||openopenpublictype===null){
this.setState({
openshowpublictype:true
})
}else{
this.setState({
openshowpublictype:false
})
if(this.props.user&&this.props.user.user_id) {
if (openopenpublictype === undefined || openopenpublictype === false || openopenpublictype === null) {
this.setState({
openshowpublictype: true
})
} else {
this.setState({
openshowpublictype: false
})
}
}
}
}else{

@ -229,4 +229,41 @@ body>.-task-title {
}
.wechatcenter{
text-align: center;
}
}
.myrigthsiderbar{
right: 15% !important;
}
.feedbackdivcolor{
background: #33BD8C !important;
height: 49px !important;
line-height: 24px !important;
}
.xiaoshou{
cursor:pointer
}
.questiontypes{
width:37px;
height:17px;
font-size:12px;
color:rgba(51,51,51,1);
line-height:17px;
cursor:pointer;
}
.questiontype{
width: 100%;
font-size: 12px;
color: #333333;
line-height: 17px;
text-align: center;
padding: 11px;
cursor:pointer;
}
.questiontypeheng{
width:100%;
height:1px;
background: #EEEEEE;
}

@ -87,6 +87,11 @@ const TPMchallengesnew = Loadable({
loader: () => import('./challengesnew/TPMchallengesnew'),
loading: Loading,
})
//新建实训
// const TPMchallengesnew = Loadable({
// loader: () => import('./challengesnew/TpmTask/TpmTaskIndex'),
// loading: Loading,
// })
//新建tab2
const TPMevaluation = Loadable({

@ -35,14 +35,14 @@ if (!window['indexHOCLoaded']) {
// $('head').append($('<link rel="stylesheet" type="text/css" />')
// .attr('href', `${_url_origin}/stylesheets/educoder/antd.min.css?1525440977`));
$('head').append($('<link rel="stylesheet" type="text/css" />')
.attr('href', `${_url_origin}/stylesheets/css/edu-common.css?8`));
.attr('href', `${_url_origin}/stylesheets/css/edu-common.css?2020`));
$('head').append($('<link rel="stylesheet" type="text/css" />')
.attr('href', `${_url_origin}/stylesheets/educoder/edu-main.css?8`));
.attr('href', `${_url_origin}/stylesheets/educoder/edu-main.css?2020`));
// index.html有加载
$('head').append($('<link rel="stylesheet" type="text/css" />')
.attr('href', `${_url_origin}/stylesheets/educoder/edu-all.css?8`));
.attr('href', `${_url_origin}/stylesheets/educoder/edu-all.css?2020`));
// $('head').append($('<link rel="stylesheet" type="text/css" />')
@ -635,6 +635,18 @@ export function TPMIndexHOC(WrappedComponent) {
}
}
//跳转道描点的地方
scrollToAnchor = (anchorName) => {
if (anchorName) {
// 找到锚点
let anchorElement = document.getElementById(anchorName);
// 如果对应id的锚点存在就跳转到锚点
if (anchorElement) {
anchorElement.scrollIntoView();
}
}
}
render() {
let{Headertop,Footerdown, isRender, AccountProfiletype,AccountPhoneemailtype}=this.state;
const common = {
@ -670,11 +682,16 @@ export function TPMIndexHOC(WrappedComponent) {
hideGlobalLoading: this.hideGlobalLoading,
yslslowCheckresults:this.yslslowCheckresults,
yslslowCheckresultsNo:this.yslslowCheckresultsNo,
MdifHasAnchorJustScorll:this.MdifHasAnchorJustScorll
MdifHasAnchorJustScorll:this.MdifHasAnchorJustScorll,
scrollToAnchor:this.scrollToAnchor
};
// console.log("this.props.mygetHelmetapi");
// console.log(this.props.mygetHelmetapi);
// console.log("WrappedComponent");
// console.log(this.props);
// console.log(this.props.match.path);
var mypath= this.props&&this.props.match&&this.props.match.path;
return (
<div className="indexHOC">
{isRender===true ? <LoginDialog
@ -696,10 +713,17 @@ export function TPMIndexHOC(WrappedComponent) {
{...this.state}
{...this.dialogObj}
/>:""}
<SiderBar
{...this.props}
{...this.state}
Headertop={Headertop}/>
{
mypath&&mypath==="/question"?
""
:
<SiderBar
{...this.props}
{...this.state}
Headertop={Headertop}/>
}
{/* 注释掉了1440 影响到了手机屏幕的展示 */}
<style>{
`

@ -1,48 +1,21 @@
import React, {Component} from 'react';
import {Input, InputNumber, Select, Radio, Checkbox, Popconfirm, message, Modal, Tooltip} from 'antd';
import {Input, InputNumber, Button, Tooltip} from 'antd';
import {BrowserRouter as Router, Route, Link, Switch} from "react-router-dom";
// import "antd/dist/antd.css";
import { getImageUrl, toPath, getUrl } from 'educoder';
import axios from 'axios';
import './css/TPMchallengesnew.css';
import TPMMDEditor from './TPMMDEditor';
import Bottomsubmit from "../../modals/Bottomsubmit";
let origin = getUrl();
let path = getUrl("/editormd/lib/")
import './css/TPMchallengesnew.css';
const $ = window.$;
let timeout;
let currentValue;
const Option = Select.Option;
const RadioGroup = Radio.Group;
// const testAnswers = [{
// "id": 4337,
// "name": "解题思路1",
// "contents": "答案的解题思路1",
// "level": 1,
// "score": 25
// },
// {
// "id": 4338,
// "name": "解题思路2",
// "contents": "答案的解题思路2",
// "level": 2,
// "score": 25
// }]
export default class TPManswer extends Component {
constructor(props) {
super(props)
@ -94,7 +67,7 @@ export default class TPManswer extends Component {
}
}
this.setState({
answer:response.data.answer,
answer:response.data.answer,
power: response.data.power,
choice_url: newchoice_url, // 导航中的新建选择题url
practice_url: newpractice_url, //string 导航中新建实践题url
@ -102,10 +75,11 @@ export default class TPManswer extends Component {
position: response.data.position, //int 关卡位置,导航栏中的第几关
prev_challenge: newprev_challenge,
next_challenge: next_challenge,
responsedata:response.data,
})
if(response.data.power===false){
this.props.showSnackbar("没有权限修改");
this.props.showNotification("没有权限修改");
}
// if(response.data.answer===undefined||response.data.answer===null){
// this.answerMD("", "answerMD");
@ -133,7 +107,7 @@ export default class TPManswer extends Component {
// this.refs.md0
const { answers } = this.state;
const answersParams = answers.slice(0)
console.log(answersParams)
// console.log(answersParams)
let isValidate = true;
let totalScore = 0;
answersParams.forEach( (item, index) => {
@ -147,10 +121,10 @@ export default class TPManswer extends Component {
totalScore += item.score;
delete item.id;
if (!item.name) {
this.props.showSnackbar("请先填写参考答案名称");
this.props.showNotification("请先填写参考答案名称");
isValidate = false;
} else if (!mdContnet) {
this.props.showSnackbar("请先填写参考答案内容");
this.props.showNotification("请先填写参考答案内容");
isValidate = false;
}
if (!isValidate) {
@ -161,7 +135,7 @@ export default class TPManswer extends Component {
return;
}
if (answersParams.length != 0 && totalScore != 100) {
this.props.showSnackbar("请先保证占比和为100%");
this.props.showNotification("请先保证占比和为100%");
return;
}
let id = this.props.match.params.shixunId;
@ -174,7 +148,7 @@ export default class TPManswer extends Component {
).then((response) => {
if (response.data) {
if (response.data.message) {
this.props.showSnackbar(response.data.message);
this.props.showNotification(response.data.message);
}
if (response.data.status == 1) {
window.location.href=`/shixuns/${id}/challenges`;
@ -233,12 +207,16 @@ export default class TPManswer extends Component {
}
})
}
gotocheckpoint=(url)=>{
this.props.history.replace(url);
}
render() {
let {
choice_url,
practice_url,
go_back_url,
responsedata,
position,
task_pass_default,
submit_url,
@ -256,60 +234,51 @@ export default class TPManswer extends Component {
return (
<React.Fragment>
<div className="educontent mt30 mb30 tpmAnswer">
<div className="padding10-20 mb10 edu-back-white clearfix">
<span className="fl ring-blue mr10 mt7">
<img src={getImageUrl("images/educoder/icon/code.svg")} data-tip-down="实训任务" className="fl mt2 ml2"/>
</span>
<span className="font-16 task-hide fl TPMtaskName">{position}</span>
<Link to={go_back_url === undefined ? "" : go_back_url}
className="color-grey-6 fr font-15 mt3">返回</Link>
{prev_challenge === undefined ? "" :
<a href={prev_challenge} className="fr color-blue mr15 mt4">上一关</a>
}
{next_challenge === undefined ? "" :
<a href={next_challenge} className="fr color-blue mr15 mt4">下一关</a>
}
<a href={practice_url === undefined ? "" : practice_url}
className="fr color-blue mr15 mt4"
style={{display:this.props.status===2||this.props.status===1?'none':'block'}}
data-tip-down="新增代码编辑类型的任务">+&nbsp;实践类型</a>
<a href={choice_url === undefined ? "" : choice_url}
className="fr color-blue mr15 mt4"
style={{display:this.props.status===2||this.props.status===1?'none':'block'}}
data-tip-down="新增选择题类型的任务">+&nbsp;选择题类型</a>
<div className="TPMchallengesnewtitles edu-back-white clearfix borderbottomf4">
<span className="font-16 task-hide fl TPMtaskName">{position}{responsedata&&responsedata.st === 0 ?"实践题":responsedata&&responsedata.st === 1?"选择题":""}</span>
{this.props.identity>4||this.props.identity===undefined||this.props.status===2||this.props.status===1?"":<a href={practice_url === undefined ? "" : practice_url} className="fr ml15 mt13">
<Button type="primary" className="edu-default-btn edu-greenback-btn "
>新增实践任务</Button></a>}
{this.props.identity>4||this.props.identity===undefined||this.props.status===2||this.props.status===1?"":<Link to={choice_url === undefined ? "" : choice_url}
className="fr ml15 mt13">
<Button type="primary"
className="edu-default-btn edu-greenback-btn mr5"
>新增选择题任务</Button></Link>}
{next_challenge===undefined?"":
<Button type="primary" ghost onClick={()=>this.gotocheckpoint(next_challenge)}
className="edu-default-btn edu-greenback-btn mr5 fr ml15 mt13"
>下一关</Button> }
{prev_challenge===undefined?"":
<Button type="primary" ghost onClick={()=>this.gotocheckpoint(prev_challenge)}
className="edu-default-btn edu-greenback-btn mr5 fr ml15 mt13"
>上一关</Button>}
</div>
<div className="challenge_nav clearfix edu-back-white">
<li>
<Link to={tab1url}>本关任务</Link>
<Link to={tab1url}>1本关任务 </Link>
</li>
{tab2url === "" ? "":<li> > </li>}
<li >
<Link to={tab2url}>评测设置</Link>
<Link to={tab2url} >2评测设置</Link>
</li>
{tab3url === "" ? "":<li> > </li>}
<li className="active">
<Link to={tab3url}>参考答案</Link>
<Link to={tab3url} className={"color-blue"}> 3参考答案</Link>
</li>
</div>
<div className="edu-back-white mb10 clearfix">
<div className="padding30-20">
<p className=" font-12" style={{ paddingBottom: '5px'
, color: '#666666'}}>
可以将参考答案分级设置让学员自行选择级别每级查看后按照比例扣分值学员已完成任务再查看则不影响原因已获得的成绩
<p className=" font-14" style={{ paddingBottom: '5px'
, color: '#333'}}>
可以将参考答案分级设置让学员自行选择级别每级查看后按照比例扣分值学员已完成任务再查看则不影响学员已获得的成绩
</p>
<p className=" font-12 "
style={{ maxWidth: "782px"
, color: '#999999'}}>
示例级别1扣减分值占比25%级别2扣减分值占比35%级别3扣减分值占比40%则学员选择查看级别1的答案将被扣减25%的分值
选择查看级别2的答案将被扣减60%的分值选择查看级别3的答案将被扣减100%的分值
<p className=" font-14 mt15 "
style={{ color: '#888'}}>
<div>示例级别1扣减分值占比25%级别2扣减分值占比35%级别3扣减分值占比40%</div>
<div className={"mt5 ml41"}>若学员选择查看级别1的答案将被扣减25%的分值选择查看级别2的答案将被扣减60%的分值选择查看级别3的答案将被扣减100%的分值</div>
</p>
<style>{`
@ -320,25 +289,31 @@ export default class TPManswer extends Component {
{
answers.map((answer, index) => {
return <div className="levelSection" id={`levelSection${index}`} style={{ clear: 'both' }}>
return <div className="levelSection mt30" id={`levelSection${index}`} style={{ clear: 'both' }}>
<span className="mr4 color-orange pt10">*</span>
<p className="color-grey-6 font-16 mb30 mt10" style={{ display: "inline" }}>级别{index + 1}</p>
<p className="color-grey-6 font-16 mb30 mt10" style={{ display: "inline" }}>级别{index + 1}</p>
<Tooltip title="删除">
<a className="fr sample_icon_remove mr30 mt8" onClick={()=>this.delanswers(index)}>
<i className="fa fa-times-circle color-grey-c font-16 fl" ></i>
<a className="fr sample_icon_remove mr10 mt8" onClick={()=>this.delanswers(index)}>
<i className={"iconfont icon-shanchu_Hover font-16 fl"}></i>
</a>
</Tooltip>
<div className=" color-grey-6 font-16" style={{ marginLeft: "9px", margin: '8px 9px'}}>
<div className=" color-grey-6 font-16 bortopeeetpm pt20 mt20" style={{ marginLeft: "9px", margin: '8px 9px'}}>
<div className=" ">
<span>名称</span>
<Input value={answer.name} onChange={(e) => this.onNameChange(e, index)}></Input>
<span style={{ marginLeft: "20px"}} >扣减分值占比</span>
<InputNumber className="score" step={1} min={1} max={100} defaultValue={answer.score}
onChange={(e) => this.onScoreChange(e, index)} ></InputNumber>%
<div className={"wind500height45"}>
<div className={"fl"} style={{'width':'240px'}}>名称</div>
<div className={"fl"} style={{ marginLeft: "20px"}} >扣减分值占比</div>
</div>
<div className={"wind500height45"}>
<Input value={answer.name} onChange={(e) => this.onNameChange(e, index)}></Input>
<InputNumber className="score" step={1} min={1} max={100} defaultValue={answer.score}
style={{ marginLeft: "32px"}}
onChange={(e) => this.onScoreChange(e, index)} ></InputNumber> %
</div>
</div>
<div className="mt10">
<span>参考答案</span>
<span>内容</span>
<TPMMDEditor ref={`md${index}`} mdID={index} initValue={answer.contents}
onChange={(val) => this.answerOnChange(val, index)}></TPMMDEditor>
</div>
@ -348,19 +323,28 @@ export default class TPManswer extends Component {
}
<div className="clearfix mt20" style={{display:this.props.identity>4||this.props.identity===undefined||power===false?"none":"block"}}>
<a href={"javascript:void(0)"} className="defalutCancelbtn fl" onClick={this.addAnswer}>新增</a>
{/*<a href={"javascript:void(0)"} className="defalutCancelbtn fl" >新增参考答案</a>*/}
<Button type="primary" ghost className="edu-default-btn edu-greenback-btn mt20 mb20 newaddswermargin" onClick={this.addAnswer}>新增参考答案</Button>
</div>
</div>
</div>
<div className="clearfix mt20" style={{display:this.props.identity>4||this.props.identity===undefined||power===false?"none":"block"}}>
<a className="defalutSubmitbtn fl mr20"
onClick={this.challenge_answer_submit}>提交</a>
<a href={"/shixuns/" + shixunId + "/challenges"} className="defalutCancelbtn fl">取消</a>
</div>
</div>
{this.props.identity>4||this.props.identity===undefined||power===false?"":<div className="clearfix mt20" >
{/*<a className="defalutSubmitbtn fl mr20" onClick={this.challenge_answer_submit}>提交</a>*/}
{/*/!*<a href={"/shixuns/" + shixunId + "/challenges"} className="defalutCancelbtn fl">取消</a>*!/*/}
{/*<Link to={"/shixuns/" + shixunId + "/challenges"} className={"defalutCancelbtn fl"}>取消</Link>*/}
<Bottomsubmit url={"/shixuns/" + shixunId + "/challenges"}
bottomvalue={"提交"}
onSubmits={this.challenge_answer_submit}
{...this.props}
{...this.state}
loadings={false}
/>
</div>}
</React.Fragment>
)
}

@ -1,31 +1,19 @@
import React, {Component} from 'react';
import {Input, Select, Radio, Checkbox, Popconfirm, message, Modal} from 'antd';
import {Input, Select, Radio, Badge, message, Button} from 'antd';
import {BrowserRouter as Router, Route, Link, Switch} from "react-router-dom";
// import "antd/dist/antd.css";
import {Link} from "react-router-dom";
import TPMMDEditor from '../../tpm/challengesnew/TPMMDEditor';
import Bottomsubmit from "../../modals/Bottomsubmit";
import axios from 'axios';
import './css/TPMchallengesnew.css';
import { getImageUrl, toPath } from 'educoder';
import {getUrl} from 'educoder';
let origin = getUrl();
let path = getUrl("/editormd/lib/")
const $ = window.$;
let timeout;
let currentValue;
const Option = Select.Option;
const RadioGroup = Radio.Group;
@ -40,12 +28,12 @@ export default class TPMchallengesnew extends Component {
go_back_url: undefined,
task_pass_default: undefined,
submit_url: undefined,
shixunCreatePracticeGroup: 1,
shixunCreatePracticeGroup: undefined,
optionsums:[100,200],
activetype:0,
setopen: false,
shixunCreatePractice: undefined,
onshixunsmarkvalue: 100,
onshixunsmarkvalue: undefined,
shixunsskillvalue: undefined,
shixunsskillvaluelist: [],
tab2url: "",
@ -59,12 +47,13 @@ export default class TPMchallengesnew extends Component {
editPracticesendtype:false,
CreatePracticesendtype:false,
exec_time:20,
shixunExec_timeType:false
shixunExec_timeType:false,
onshixunsmarkvaluetype:false,
shixunCreatePracticeGrouptype:false
}
}
componentDidMount() {
getdatas=()=>{
let id = this.props.match.params.shixunId;
let checkpointId=this.props.match.params.checkpointId;
@ -83,10 +72,11 @@ export default class TPMchallengesnew extends Component {
task_pass_default: response.data.task_pass_default,
submit_url: response.data.submit_url,
checkpointId:checkpointId,
exercisememoMDRefval:response.data.task_pass_default
exercisememoMDRefval:response.data.task_pass_default,
responsedata:response.data
})
this.exercisememoMDRef.current.setValue(response.data.task_pass_default||'')
this.exercisememoMDRef.current.setValue(response.data.task_pass_default||'')
}).catch((error) => {
console.log(error)
});
@ -133,16 +123,18 @@ export default class TPMchallengesnew extends Component {
onshixunsmarkvalue:response.data.score,
shixunsskillvaluelist:response.data.tags,
checkpointId:checkpointId,
exec_time:response.data.exec_time,
tab2url: "/shixuns/" + id + "/challenges/"+checkpointId+"/tab=2",
tab3url: "/shixuns/" + id + "/challenges/"+checkpointId+"/tab=3",
exercisememoMDRefval:response.data.task_pass
exercisememoMDRefval:response.data.task_pass,
responsedata:response.data
})
// exec_time:response.data.exec_time,
if(response.data.power===false){
this.props.showSnackbar("你没有权限修改");
this.props.showNotification("你没有权限修改");
}
this.exercisememoMDRef.current.setValue(response.data.task_pass||'')
this.exercisememoMDRef.current.setValue(response.data.task_pass||'')
}).catch((error) => {
console.log(error)
});
@ -150,8 +142,24 @@ export default class TPMchallengesnew extends Component {
}
}
componentDidUpdate=(prevProps, prevState)=>{
if(prevProps!=this.props){
this.getdatas()
}
}
componentDidMount() {
this.getdatas()
}
onshixunCreatePracticeChange = (e) => {
if(e.target.value===undefined||e.target.value=== ""||e.target.value=== null){
}else{
this.setState({
shixunCreatePracticeGrouptype:false,
onshixunsmarkvaluetype:false
})
}
let optionsum;
let onshixunsmark;
if(e.target.value===1){
@ -172,9 +180,18 @@ export default class TPMchallengesnew extends Component {
}
shixunCreatePractice = (e) => {
if (e.target.value === undefined|| e.target.value== ""){
}else{
this.setState({
shixunCreatePracticetype:false
})
}
this.setState({
shixunCreatePractice: e.target.value
})
}
CreatePracticesend = () => {
@ -185,49 +202,92 @@ export default class TPMchallengesnew extends Component {
})
if(this.props.status===2){
this.props.showSnackbar("该实训已经发布不能新建")
this.props.showNotification("该实训已经发布不能新建")
this.setState({
CreatePracticesendtype:false
})
return
}
let {shixunCreatePractice, shixunCreatePracticeGroup, onshixunsmarkvalue, shixunsskillvaluelist,exec_time} = this.state;
if (shixunCreatePractice === undefined||shixunCreatePractice=="") {
this.setState({
shixunCreatePracticetype: true
shixunCreatePracticetype: true,
CreatePracticesendtype:false
})
this.props.showSnackbar("任务名称为空")
$('html').animate({
$('html').animate({
scrollTop: 10
}, 1000);
this.setState({
CreatePracticesendtype:false
})
return
}
if (shixunCreatePractice.match(/^[ ]*$/)) {
this.props.showNotification("任务名称为空,请勿输入空格");
this.setState({
shixunCreatePracticetype: true,
CreatePracticesendtype:false
})
$('html').animate({
scrollTop: 10
}, 1000);
return
}
if(shixunCreatePracticeGroup===undefined){
this.setState({
shixunCreatePracticeGrouptype:true,
CreatePracticesendtype:false
})
this.props.scrollToAnchor("shixunCreatePracticeGroupid");
return
}
if(onshixunsmarkvalue===undefined){
this.setState({
onshixunsmarkvaluetype:true,
CreatePracticesendtype:false
})
this.props.scrollToAnchor("input_task_tag");
return
}
if (shixunsskillvaluelist.length === 0) {
this.setState({
shixunsskillvaluelisttype: true,
CreatePracticesendtype:false
CreatePracticesendtype:false
})
this.props.showSnackbar("技能标签为空")
// this.props.showNotification("技能标签为空")
this.props.scrollToAnchor("input_task_tag");
return
}
if(exec_time===null||exec_time===undefined||exec_time===""){
this.setState({
shixunExec_timeType:false
})
return
}
// if(exec_time===null||exec_time===undefined||exec_time === ""){
// this.setState({
// shixunExec_timeType:true,
// CreatePracticesendtype:false
// })
// this.props.scrollToAnchor("exec_time");
// return
// }
// if (exec_time.match(/^[ ]*$/)) {
// this.props.showNotification("评测时限,请勿输入空格");
// this.setState({
// shixunExec_timeType:true,
// CreatePracticesendtype:false
// })
// this.props.scrollToAnchor("exec_time");
// return
// }
const exercise_editormdvalue = this.exercisememoMDRef.current.getValue().trim();
let id = this.props.match.params.shixunId;
let url = "/shixuns/" + id + "/challenges.json";
// exec_time:exec_time
axios.post(url, {
identifier:id,
subject: shixunCreatePractice,
@ -236,12 +296,12 @@ export default class TPMchallengesnew extends Component {
score: onshixunsmarkvalue,
challenge_tag: shixunsskillvaluelist,
st: 0,
exec_time:exec_time
}).then((response) => {
if (response.data.status === 1) {
// $("html").animate({ scrollTop: 0 })
//window.location.href=`/shixuns/${id}/challenges/${response.data.challenge_id}/editcheckpoint?tab=2`;
window.location.href=`/shixuns/${id}/challenges/${response.data.challenge_id}/tab=2`;
// window.location.href=`/shixuns/${id}/challenges/${response.data.challenge_id}/tab=2`;
this.props.history.replace(`/shixuns/${id}/challenges/${response.data.challenge_id}/tab=2`);
// this.setState({
// setopen: true,
// CreatePracticesendtype:false,
@ -250,7 +310,7 @@ export default class TPMchallengesnew extends Component {
// })
}
// this.props.showSnackbar(response.data.messages);
// this.props.showNotification(response.data.messages);
}).catch((error) => {
console.log(error)
});
@ -287,6 +347,12 @@ export default class TPMchallengesnew extends Component {
let list = shixunsskillvaluelist;
list.push(shixunsskillvalue);
if (list.length> 0) {
this.setState({
shixunsskillvaluelisttype: false,
})
}
this.setState({
shixunsskillvaluelist: list,
shixunsskillvalue: ""
@ -316,38 +382,77 @@ export default class TPMchallengesnew extends Component {
let url = "/shixuns/"+id+"/challenges/"+checkpointId+".json";
if (shixunCreatePractice === undefined||shixunCreatePractice=="") {
// this.setState({
// shixunCreatePracticetype: true
// })
this.props.showSnackbar("任务名称为空")
this.setState({
shixunCreatePracticetype: true,
editPracticesendtype:false
})
// this.props.showNotification("任务名称为空")
$('html').animate({
scrollTop: 10
}, 1000);
return
}
if (shixunCreatePractice.match(/^[ ]*$/)) {
this.props.showNotification("任务名称为空,请勿输入空格");
this.setState({
editPracticesendtype:false
shixunCreatePracticetype: true,
editPracticesendtype:false
})
$('html').animate({
scrollTop: 10
}, 1000);
return
}
if (shixunsskillvaluelist.length === 0) {
// this.setState({
// shixunsskillvaluelisttype: true
// })
this.props.showSnackbar("技能标签为空")
if(shixunCreatePracticeGroup===undefined){
this.setState({
editPracticesendtype:false
shixunCreatePracticeGrouptype:true,
editPracticesendtype:false
})
this.props.scrollToAnchor("shixunCreatePracticeGroupid");
return
}
if(onshixunsmarkvalue===undefined){
this.setState({
onshixunsmarkvaluetype:true,
editPracticesendtype:false
})
this.props.scrollToAnchor("input_task_tag");
return
}
if(exec_time===null||exec_time===undefined||exec_time===""){
if (shixunsskillvaluelist.length === 0) {
this.setState({
shixunsskillvaluelisttype: true,
editPracticesendtype:false,
})
this.props.scrollToAnchor("input_task_tag");
return
}
this.setState({
shixunExec_timeType:false
})
return
}
// if(exec_time===null||exec_time===undefined||exec_time === ""){
// this.setState({
// shixunExec_timeType:true,
// editPracticesendtype:false
// })
// this.props.scrollToAnchor("exec_time");
// return
// }
// if (exec_time.match(/^[ ]*$/)) {
// this.props.showNotification("评测时限,请勿输入空格");
// this.setState({
// shixunExec_timeType:true,
// editPracticesendtype:false
// })
// this.props.scrollToAnchor("exec_time");
// return
// }
// exec_time:exec_time
axios.put(url, {
tab:0,
identifier:id,
@ -357,19 +462,19 @@ export default class TPMchallengesnew extends Component {
task_pass: exercise_editormdvalue,
difficulty: shixunCreatePracticeGroup,
score: onshixunsmarkvalue,
exec_time:exec_time
},
challenge_tag:shixunsskillvaluelist
}).then((response) => {
this.props.showSnackbar(response.data.messages);
this.props.showNotification(response.data.messages);
if (response.data.status === 1) {
window.location.href=`/shixuns/${id}/challenges/${checkpointId}/tab=2`;
// window.location.href=`/shixuns/${id}/challenges/${checkpointId}/tab=2`;
this.setState({
setopen: true,
editPracticesendtype:false,
tab2url: "/shixuns/" + id + "/challenges/"+checkpointId+"/tab=2",
tab3url: "/shixuns/" + id + "/challenges/"+checkpointId+"/tab=3",
})
this.props.history.replace(`/shixuns/${id}/challenges/${checkpointId}/tab=2`);
// window.location.href = "/shixuns/" + id + "/challenges/"+response.data.challenge_id+"/tab=2"
}
}).catch((error) => {
@ -396,12 +501,16 @@ export default class TPMchallengesnew extends Component {
exec_time:e.target.value
})
}
gotocheckpoint=(url)=>{
this.props.history.replace(url);
}
render() {
let shixuntype = this.props.match.params.type;
let {marktype,
let {responsedata,
shixunCreatePracticetype, shixunsskillvaluelisttype,
choice_url, practice_url, go_back_url, position, task_pass_default, submit_url, setopen,checkpointId,prev_challenge,next_challenge,power,
shixunCreatePractice, shixunCreatePracticeGroup, onshixunsmarkvalue, shixunsskillvalue, shixunsskillvaluelist, tab2url, tab3url,optionsums,
@ -417,142 +526,143 @@ export default class TPMchallengesnew extends Component {
})
}
// console.log(this.props)
// console.log(this.state)
//a console.log(shixunCreatePractice)
return (
<React.Fragment>
<div className="educontent mt30 mb30">
<div className="padding10-20 mb10 edu-back-white clearfix">
<span className="fl ring-blue mr10 mt7">
<img src={getImageUrl("images/educoder/icon/code.svg")} data-tip-down="实训任务" className="fl mt2 ml2"/>
</span>
<span className="font-16 task-hide fl TPMtaskName">{position}</span>
<Link to={go_back_url === undefined ? "" : go_back_url}
className="color-grey-6 fr font-15 mt3">返回</Link>
{ next_challenge===undefined?"":
<a href={next_challenge}className="fr color-blue mr15 mt4">下一关</a>
}
{ prev_challenge===undefined?"":
<a href={prev_challenge} className="fr color-blue mr15 mt4">上一关</a>
}
<a href={practice_url === undefined ? "" : practice_url}
className="fr color-blue mr15 mt4"
style={{display:this.props.identity>4||this.props.identity===undefined||this.props.status===2||this.props.status===1?"none":'block'}}
data-tip-down="新增代码编辑类型的任务">+&nbsp;实践类型</a>
<a href={choice_url === undefined ? "" : choice_url}
className="fr color-blue mr15 mt4"
style={{display:this.props.identity>4||this.props.identity===undefined||this.props.status===2||this.props.status===1?"none":'block'}}
data-tip-down="新增选择题类型的任务">+&nbsp;选择题类型</a>
<div className="TPMchallengesnewtitles edu-back-white clearfix borderbottomf4">
<span className="font-16 task-hide fl TPMtaskName">{position}{responsedata&&responsedata.st === 0 ?"实践题":responsedata&&responsedata.st === 1?"选择题":""}</span>
{this.props.identity>4||this.props.identity===undefined||this.props.status===2||this.props.status===1?"":<a href={practice_url === undefined ? "" : practice_url} className="fr ml15 mt13">
<Button type="primary" className="edu-default-btn edu-greenback-btn "
>新增实践任务</Button></a>}
{this.props.identity>4||this.props.identity===undefined||this.props.status===2||this.props.status===1?"":<Link to={choice_url === undefined ? "" : choice_url}
className="fr ml15 mt13">
<Button type="primary"
className="edu-default-btn edu-greenback-btn mr5"
>新增选择题任务</Button></Link>}
{next_challenge===undefined?"":
<Button type="primary" ghost onClick={()=>this.gotocheckpoint(next_challenge)}
className="edu-default-btn edu-greenback-btn mr5 fr ml15 mt13"
>下一关</Button> }
{prev_challenge===undefined?"":
<Button type="primary" ghost onClick={()=>this.gotocheckpoint(prev_challenge)}
className="edu-default-btn edu-greenback-btn mr5 fr ml15 mt13"
>上一关</Button>}
</div>
<div className="challenge_nav clearfix edu-back-white">
<li className="active">
<a>本关任务</a>
<a className={"color-blue"}>1本关任务 </a>
</li>
{tab2url === "" ? "":<li> > </li>}
<li className="">
{tab2url === "" ? <span>评测设置</span> : <Link to={tab2url}></Link>}
{tab2url === "" ? <span></span> : <Link to={tab2url}>2</Link>}
</li>
{tab3url === "" ? "":<li> > </li>}
<li className="">
{tab3url === "" ? <span>参考答案</span> : <Link to={tab3url}></Link>}
{tab3url === "" ? <span></span> : <Link to={tab3url}> 3</Link>}
</li>
</div>
<div className="edu-back-white mb10 clearfix">
<div className="padding40-20">
<p className="color-grey-6 font-16 mb30">任务名称</p>
<div className="df">
<span className="mr30 color-orange pt10">*</span>
<div className="flex1 mr20">
<input type="text"
// className="input-100-45 greyInput"
className={shixunCreatePracticetype===true?"input-100-45 greyInpus wind100":"input-100-45 greyInput "}
maxLength="50"
name="challenge[subject]"
value={shixunCreatePractice}
<div className="edu-back-white clearfix">
<div className="newpadding1020">
<p className="color-grey-6 font-16 mb10"> <span className="mr5 color-red">*</span></p>
<div>
<div className="flex1">
<Input placeholder="请输入任务名称最大限制60个字符此信息将在实训发布后展示给学员计算学生的课程成绩绩点"
maxLength="60"
className={shixunCreatePracticetype === true ? "bor-red":"newViewAfter"}
onInput={this.shixunCreatePractice}
placeholder="请输入任务名称(此信息将提前展示给学员),例:计算学生的课程成绩绩点"/>
value={shixunCreatePractice}
addonAfter={`${String(!shixunCreatePractice? 0 : shixunCreatePractice.length)}/${60}`}
/>
</div>
<div style={{width: '57px'}}>
<span
className={shixunCreatePracticetype === true ? "color-orange mt8 fl block" : "color-orange mt8 fl none"}
id="new_shixun_name"><i
className="fa fa-exclamation-circle mr3"></i></span>
<div>
<span className={shixunCreatePracticetype === true ? "color-red mt8 fl block" : "color-red mt8 fl none"} id="new_shixun_name">必填项不能为空</span>
</div>
</div>
</div>
</div>
<div className="edu-back-white padding40-20 mb20">
<p className="color-grey-6 font-16 mb30">过关任务</p>
<TPMMDEditor ref={this.exercisememoMDRef} placeholder="请输入选择题的题干内容" mdID={'exercisememoMD'} refreshTimeout={1500}
watch={true} className="courseMessageMD" initValue={this.state.exercisememoMDRefval} height={700}></TPMMDEditor>
<div className="edu-back-white newpadding02020">
<p className="color-grey-6 font-16 mb10"><span className="mr5 color-red">*</span></p>
<style>
{
`
.markdown-body img {
max-width: 80%;
margin: 0 auto;
display: block;
width: auto;
height: auto;
max-height: 80%;
}
`
}
</style>
<TPMMDEditor ref={this.exercisememoMDRef} placeholder="请输入选择题的题干内容" mdID={'exercisememoMD'} refreshTimeout={1500}
watch={true} className="courseMessageMD" initValue={this.state.exercisememoMDRefval} height={800}></TPMMDEditor>
<p id="e_tip_Memochallengesnew" className="edu-txt-right color-grey-cd font-12"></p>
<p id="e_tips_Memochallengesnew" className="edu-txt-right color-grey-cd font-12"></p>
</div>
<div className="edu-back-white padding40-20 mb20">
<p className="color-grey-6 font-16 mb30">难度系数</p>
<div className="clearfix mb40">
<RadioGroup value={shixunCreatePracticeGroup} className="fl mr40"
disabled={this.props.status===2?true:false}
onChange={this.props.status===2?"":this.onshixunCreatePracticeChange}>
<div className="edu-back-white newpadding02020">
<p className="color-grey-6 font-16 mb20">
<span className="fl color-red mr5">*</span>
难度系数
<RadioGroup value={shixunCreatePracticeGroup}
className={"ml10"}
id={"shixunCreatePracticeGroupid"}
disabled={this.props.status===2?true:false}
onChange={this.props.status===2?"":this.onshixunCreatePracticeChange}>
<Radio value={1}>简单</Radio>
<Radio value={2}>中等</Radio>
<Radio value={3}>困难</Radio>
</RadioGroup>
</div>
<p className="color-grey-6 font-16 mb30">奖励经验值</p>
<div className="clearfix"
// onMouseLeave={this.props.status===2?"":this.onshixunsmarkss}
>
<span className="fl mr30 color-orange pt10">*</span>
<Select style={{width: 120}} className="winput-240-40 fl"
{this.state.shixunCreatePracticeGrouptype===true?<div className="color-red mt7 ml5 font-14" id="ex_value_notice">
必选项不能为空</div>:""}
</p>
<p className="color-grey-6 font-16 mb10"> <span className="fl mr5 color-red">*</span> <span className={"color-grey-8 font-14"}> (+100+100)</span></p>
<div className="clearfix">
{this.state.onshixunsmarkvaluetype===true?<style>
{
`
.ant-select-selection{
border:1px solid red;
}
`
}
</style>:""}
<Select style={{width: 252}}
className={"winput-240-40 ml3"}
id="challenge_score"
onChange={this.props.status===2?"":this.onshixunsmark}
// onMouseEnter={this.props.status===2?"":this.onshixunsmarks}
disabled={this.props.status===2?true:false}
// open={marktype}
value={onshixunsmarkvalue}
getPopupContainer={triggerNode => triggerNode.parentNode}
>
{options}
</Select>
<p className="fl color-grey-9 font-12 ml20">
如果学员答题错误则不能得到相应的经验值<br/>
如果学员成功得到经验值那么将同时获得等值的金币奖励+10经验值+10金币
</p>
<span className="color-orange mt7 fl ml20 none" id="ex_value_notice"><i
className="fa fa-exclamation-circle mr3"></i></span>
{this.state.onshixunsmarkvaluetype===true?<div className="color-red mt7 ml5" id="ex_value_notice">
必选项不能为空</div>:""}
</div>
</div>
<div className="edu-back-white padding40-20 mb20">
<p className="color-grey-6 font-16 mb30">技能标签</p>
<div className="clearfix df">
<span className="mr30 color-orange pt10">*</span>
<div className="edu-back-white newpadding02020">
<p className="color-grey-6 font-16 mb10"><span className="mr5 color-red">*</span><span className={"color-grey-8 font-14"}> ()</span></p>
<div className="clearfix">
<div className="flex1">
<Input type="text"
className="winput-240-40 fl mr20 winput-240-40s"
className={shixunsskillvaluelisttype === true ?"winput-240-40 fl mr20 winput-240-40s ml10 bor-red":"winput-240-40 fl mr20 winput-240-40s ml10"}
id="input_task_tag"
placeholder="添加标签"
onInput={this.shixunsskill}
@ -560,54 +670,59 @@ export default class TPMchallengesnew extends Component {
onPressEnter={this.clickshixunsskill}
onBlur={this.clickshixunsskill}
/>
{/*<a className="white-btn orange-btn fl mt1 use_scope-btn ml20 mt5 mr20"*/}
{/*onClick={this.clickshixunsskill}>+ 添加</a>*/}
<div className="ml15 color-grey-9 mt5">学员答题正确将获得技能否则不能获得技能</div>
<div className="ml15 color-grey-9 pt5 font-14">(回车添加标签)</div>
<div className="mt20 clearfix" id="task_tag_content">
{
shixunsskillvaluelist===undefined?"":shixunsskillvaluelist.length === 0 ? "" : shixunsskillvaluelist.map((itme, key) => {
return (
<li className="task_tag_span" key={key}><span>{itme}</span>
<a onClick={() => this.delshixunsskilllist(key)}>×</a>
</li>
<li key={key} className={"fl ml10 mr10"}>
<Badge className={"tpmpointer"} count={"x"} onClick={(key) => this.delshixunsskilllist(key)}>
<Button type="primary" ghost className={"Permanentban "}>
{itme}
</Button>
</Badge>
</li>
)
})
}
</div>
</div>
<span
className={shixunsskillvaluelisttype === true ? "color-orange mt7 fl ml20 block" : " color-orange mt7 fl ml20 none"}
id="stage_name_notice">
<i className="fa fa-exclamation-circle mr3"></i></span>
<div className={shixunsskillvaluelisttype === true ? "color-red ml10 mt5 block" : "none"}
id="stage_name_notice">必选项不能为空</div>
</div>
</div>
<div className="edu-back-white padding40-20 mb20">
<p className="color-grey-6 font-16 mb30">服务配置</p>
<div className="clearfix mb5">
<span className="color-orange pt10 fl">*</span>
<label className="panel-form-label fl">评测时限(S)</label>
<div className="pr fl with80 status_con">
<input value={this.state.exec_time} className="panel-box-sizing task-form-100 task-height-40" placeholder="请输入类别名称" onInput={this.setexec_time}/>
</div>
<span
className={this.state.shixunExec_timeType === true ? "color-orange mt8 fl block ml20" : "color-orange mt8 fl none"}
id="new_shixun_name"><i className="fa fa-exclamation-circle mr3"></i></span>
<div className="cl"></div>
</div>
</div>
<div className="clearfix mt30"
style={{display:this.props.identity>4||this.props.identity===undefined?"none":'block'}}
>
{checkpointId===undefined?<a className="defalutSubmitbtn fl mr20" onClick={CreatePracticesendtype===true?"":this.CreatePracticesend}>提交</a>:
<a className="defalutSubmitbtn fl mr20" onClick={editPracticesendtype===true?"":this.editPracticesend}>提交</a>}
<a href={go_back_url === undefined ? "" : go_back_url} className="defalutCancelbtn fl">取消</a>
</div>
{/*<div className="edu-back-white newpadding02020">*/}
{/* <p className="color-grey-6 font-16 mb20"> <span className="color-orange mr5 fl">*</span> 服务配置:评测时限(S)</p>*/}
{/* <div className="clearfix mb5 ml10">*/}
{/* <div className="pr status_con" id={"exec_timeid"}>*/}
{/* /!*<label className="panel-form-label fl"></label>*!/*/}
{/* <input value={this.state.exec_time}*/}
{/* className={this.state.shixunExec_timeType === true ?"panel-box-sizing task-form-100 task-height-40 bor-red":"panel-box-sizing task-form-100 task-height-40" }*/}
{/* placeholder="请输入类别名称" onInput={this.setexec_time}/>*/}
{/* </div>*/}
{/* <div*/}
{/* className={this.state.shixunExec_timeType === true ? "color-red mt8 block ml5" : " none"}*/}
{/* id="new_shixun_name">必填项:不能为空</div>*/}
{/* </div>*/}
{/*</div>*/}
</div>
{this.props.identity>4||this.props.identity===undefined?"":<div className="clearfix mt30"
// style={{display:this.props.identity>4||this.props.identity===undefined?"none":'block'}}
>
{/*{checkpointId===undefined?<a className="defalutSubmitbtn fl mr20" onClick={CreatePracticesendtype===true?"":this.CreatePracticesend}>提交</a>:*/}
{/*<a className="defalutSubmitbtn fl mr20" onClick={editPracticesendtype===true?"":this.editPracticesend}>提交</a>}*/}
{/*<a href={go_back_url === undefined ? "" : go_back_url} className="defalutCancelbtn fl">取消</a>*/}
{/*<Link to={go_back_url === undefined ? "" : go_back_url} className={"defalutCancelbtn fl"}>取消</Link>*/}
<Bottomsubmit url={go_back_url === undefined ? "" : go_back_url}
{...this.props}
{...this.state}
bottomvalue={"提交"}
onSubmits={checkpointId===undefined?()=>this.CreatePracticesend():()=>this.editPracticesend()}
loadings={CreatePracticesendtype===true?true:editPracticesendtype===true?true:false}/>
</div>}
</React.Fragment>
)
}

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

Loading…
Cancel
Save