dev_new_shixunsrepository
杨树林 5 years ago
commit 841be62cd0

@ -0,0 +1,89 @@
class ExaminationIntelligentSettingsController < ApplicationController
before_action :require_login
before_action :find_exam, only: [:exchange_one_item, :exchange_items]
def optinal_items
sub_discipline_id = params[:sub_discipline_id]
tag_discipline_id = params[:tag_discipline_id]
difficulty = params[:difficulty]
source = params[:source]
items = OptionalItemQuery.call(sub_discipline_id, tag_discipline_id, difficulty, source)
@single_question_count = items.select{ |item| item.item_type == "SINGLE" }.size
@multiple_question_count = items.select{ |item| item.item_type == "MULTIPLE" }.size
@judgement_question_count = items.select{ |item| item.item_type == "JUDGMENT" }.size
@program_question_count = items.select{ |item| item.item_type == "PROGRAM" }.size
end
def create
ActiveRecord::Base.transaction do
exam = ExaminationIntelligentSetting.new(user: current_user)
# 保存试卷基础信息
exam = ExaminationIntelligentSettings::SaveSettingService.call(exam, form_params)
render_ok({exam_setting_id: exam.id})
end
rescue ApplicationService::Error => ex
render_error(ex.message)
end
def exchange_one_item
item = @exam.item_baskets.find_by!(id: params[:item_id])
exam_type_setting = @exam.examination_type_settings.find_by!(item_type: item.item_type)
# 获取可选的题
items = OptionalItemQuery.call(@exam.sub_discipline_id, @exam.tag_discipline_containers.pluck(:tag_discipline_id), @exam.difficulty, @exam.public)
type_items = items.select{ |t_item| t_item.item_type == item.item_type }
# 如果可选的题数小于等于设置的题数则提示无可换的题
tip_exception("无可换的题") if type_items.size <= exam_type_setting.count
# 可选题中去掉已组卷的同题型试题
optional_item_ids = type_items.pluck(:id) - @exam.item_baskets.where(item_type: item.item_type).pluck(:item_bank_id)
new_item = ItemBank.find optional_item_ids.sample(1).first
ActiveRecord::Base.transaction do
@exam.item_baskets << ItemBasket.new(item_bank_id: new_item.id, position: item.position, score: item.score, item_type: new_item.item_type)
item.destroy!
end
render_ok
end
def exchange_items
exam_type_setting = @exam.examination_type_settings.find_by!(item_type: params[:item_type])
choosed_items = @exam.item_baskets.where(item_type: params[:item_type])
# 获取可选的题
items = OptionalItemQuery.call(@exam.sub_discipline_id, @exam.tag_discipline_containers.pluck(:tag_discipline_id), @exam.difficulty, @exam.public)
type_items = items.select{ |t_item| t_item.item_type == params[:item_type] }
# 如果可选的题数小于等于设置的题数则提示无可换的题
tip_exception("无可换的题") if type_items.size <= exam_type_setting.count
# 可选题中去掉已组卷的同题型试题
choosed_item_ids = choosed_items.pluck(:item_bank_id)
optional_item_ids = type_items.pluck(:id) - choosed_item_ids
# 如果可选题数小于设置的题数n则在原来的选题中随机选n个确保换题时能选到新的题
if optional_item_ids.size < exam_type_setting.count
absence_count = exam_type_setting.count - optional_item_ids.size
optional_item_ids = optional_item_ids + choosed_item_ids.sample(absence_count)
end
ActiveRecord::Base.transaction do
# 取试题分数
score = choosed_items.first&.score || (params[:item_type] == "PROGRAM" ? 10 : 5)
choosed_items.destroy_all
optional_item_ids.sample(exam_type_setting.count).each_with_index do |item_id, index|
new_item = ItemBank.find item_id
@exam.item_baskets << ItemBasket.new(item_bank_id: new_item.id, position: index+1, score: score, item_type: new_item.item_type)
end
end
render_ok
end
private
def find_exam
@exam = ExaminationIntelligentSetting.find_by!(id: params[:id])
tip_exception(403,"无权限编辑") unless current_user.admin_or_business? || @exam.user_id == current_user.id
end
def form_params
params.permit(:discipline_id, :sub_discipline_id, :difficulty, :source, tag_discipline_id: [], question_settings: %i[item_type count])
end
end

@ -9,7 +9,14 @@ class ItemBanksController < ApplicationController
@items_count = items.size
@items = paginate items.includes(:item_analysis, :user, :container)
exam = ExaminationBank.find_by(id: params[:exam_id]) if params[:exam_id].present?
@item_basket_ids = exam ? exam.examination_items.pluck(:item_bank_id) : current_user.item_baskets.pluck(:item_bank_id)
exam_setting = ExaminationIntelligentSetting.find_by(id: params[:exam_setting_id]) if params[:exam_setting_id].present?
@item_basket_ids = if exam
exam.examination_items.pluck(:item_bank_id)
elsif exam_setting
exam_setting.item_baskets.pluck(:item_bank_id)
else
current_user.item_baskets.pluck(:item_bank_id)
end
end
def create

@ -4,7 +4,7 @@ class ItemBasketsController < ApplicationController
helper_method :current_basket
def index
@item_baskets = current_user.item_baskets
@item_baskets = basket_items
@single_questions = @item_baskets.where(item_type: "SINGLE")
@multiple_questions = @item_baskets.where(item_type: "MULTIPLE")
@judgement_questions = @item_baskets.where(item_type: "JUDGMENT")
@ -22,41 +22,41 @@ class ItemBasketsController < ApplicationController
end
def create
ItemBaskets::SaveItemBasketService.call(current_user, create_params)
ItemBaskets::SaveItemBasketService.call(current_user, create_params, exam_setting)
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])
item = basket_items.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")
basket_items.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 = basket_items.where(item_type: params[:item_type])
baskets.destroy_all
render_ok
end
def set_score
current_basket.update_attributes!(score: params[:score])
@questions_score = current_user.item_baskets.where(item_type: current_basket.item_type).pluck(:score).sum
@all_score = current_user.item_baskets.pluck(:score).sum
@questions_score = basket_items.where(item_type: current_basket.item_type).pluck(:score).sum
@all_score = basket_items.pluck(:score).sum
end
def batch_set_score
current_user.item_baskets.where(item_type: params[:item_type]).update_all(score: params[:score])
@questions_score = current_user.item_baskets.where(item_type: params[:item_type]).pluck(:score).sum
@all_score = current_user.item_baskets.pluck(:score).sum
basket_items.where(item_type: params[:item_type]).update_all(score: params[:score])
@questions_score = basket_items.where(item_type: params[:item_type]).pluck(:score).sum
@all_score = basket_items.pluck(:score).sum
end
def adjust_position
same_items = current_user.item_baskets.where(item_type: current_basket.item_type)
same_items = basket_items.where(item_type: current_basket.item_type)
max_position = same_items.size
tip_exception("position超出范围") unless params[:position].present? && params[:position].to_i <= max_position && params[:position].to_i >= 1
ActiveRecord::Base.transaction do
@ -79,8 +79,19 @@ class ItemBasketsController < ApplicationController
params.permit(item_ids: [])
end
def exam_setting
@_exam_setting = ExaminationIntelligentSetting.find_by(id: params[:exam_setting_id])
end
def basket_items
@_items = params[:exam_setting_id] ? exam_setting.item_baskets : current_user.item_baskets
end
def current_basket
@_current_basket = current_user.item_baskets.find_by!(id: params[:id])
@_current_basket = ItemBasket.find_by!(id: params[:id])
tip_exception(403, "无权限编辑") unless current_user.admin_or_business? || @_current_basket.user_id.to_i == current_user.id ||
@_current_basket.examination_intelligent_setting&.user_id.to_i == current_user.id
@_current_basket
end
def validate_score

@ -0,0 +1,11 @@
class ExaminationIntelligentSettings::SaveExamSettingForm
include ActiveModel::Model
attr_accessor :discipline_id, :sub_discipline_id, :source, :difficulty, :tag_discipline_id, :question_settings
validates :discipline_id, presence: true
validates :sub_discipline_id, presence: true
validates :source, presence: true
validates :difficulty, presence: true, inclusion: {in: 1..3}, numericality: { only_integer: true }
validates :question_settings, presence: true
end

@ -15,9 +15,9 @@ class ItemBanks::SaveItemForm
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
if ["SINGLE", "JUDGMENT"].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
elsif item_type == "MULTIPLE" && choices.pluck(:is_answer).select{|item| item == 1}.length <= 1
raise("多选题至少有两个正确答案")
end
end

@ -0,0 +1,7 @@
class ExaminationIntelligentSetting < ApplicationRecord
belongs_to :sub_discipline
belongs_to :user
has_many :examination_type_settings, dependent: :destroy
has_many :tag_discipline_containers, as: :container, dependent: :destroy
has_many :item_baskets, dependent: :destroy
end

@ -0,0 +1,4 @@
class ExaminationTypeSetting < ApplicationRecord
enum item_type: { SINGLE: 0, MULTIPLE: 1, JUDGMENT: 2, COMPLETION: 3, SUBJECTIVE: 4, PRACTICAL: 5, PROGRAM: 6 }
belongs_to :examination_intelligent_setting
end

@ -2,13 +2,6 @@ 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
belongs_to :user, optional: true
belongs_to :examination_intelligent_setting, optional: true
end

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

@ -0,0 +1,35 @@
class OptionalItemQuery < ApplicationQuery
attr_reader :sub_discipline_id, :tag_discipline_id, :difficulty, :source
def initialize(sub_discipline_id, tag_discipline_id, difficulty, source)
@sub_discipline_id = sub_discipline_id
@tag_discipline_id = tag_discipline_id
@difficulty = difficulty
@source = source
end
def call
items = ItemBank.all
if tag_discipline_id.present? && sub_discipline_id.present?
items = items.joins(:tag_discipline_containers).where(tag_discipline_containers: {tag_discipline_id: tag_discipline_id})
hacks = Hack.joins(:tag_discipline_containers).where(tag_discipline_containers: {tag_discipline_id: tag_discipline_id})
elsif sub_discipline_id.present?
items = items.where(sub_discipline_id: sub_discipline_id)
hacks = Hack.where(sub_discipline_id: sub_discipline_id)
end
if hacks.present?
items = ItemBank.where(container_id: hacks.pluck(:id), container_type: "Hack").or(ItemBank.where(id: items.pluck(:id)))
end
# 来源
public = source.present? ? source.to_i : 1
public = public == 2 ? [0, 1] : public
items = items.where(public: public)
# 难度
difficulty = difficulty ? difficulty.to_i : 1
items = items.where(difficulty: difficulty)
items
end
end

@ -0,0 +1,63 @@
class ExaminationIntelligentSettings::SaveSettingService < ApplicationService
attr_reader :exam, :params
def initialize(exam, params)
@exam = exam
@params = params
end
def call
ExaminationIntelligentSettings::SaveExamSettingForm.new(params).validate!
items = OptionalItemQuery.call(params[:sub_discipline_id], params[:tag_discipline_id], params[:difficulty], params[:source])
params[:question_settings].each do |setting|
raise "超出可选题数范围" if items.select{ |item| item.item_type == setting[:item_type] }.size.to_i < setting[:count].to_i
end
exam.difficulty = params[:difficulty]
exam.sub_discipline_id = params[:sub_discipline_id]
exam.public = params[:source].present? ? params[:source].to_i : 1
exam.save!
# 知识点的创建
params[:tag_discipline_id].each do |tag_id|
exam.tag_discipline_containers << TagDisciplineContainer.new(tag_discipline_id: tag_id)
end
# 智能选题的设置
params[:question_settings].each do |setting|
if setting[:count].to_i > 0
exam.examination_type_settings << ExaminationTypeSetting.new(item_type: setting[:item_type], count: setting[:count].to_i)
end
end
# 选题
choose_question items
exam
end
private
def choose_question items
exam.examination_type_settings.each do |setting|
questions = items.select{ |item| item.item_type == setting.item_type }
questions.pluck(:id).sample(setting.count).each_with_index do |item_id, index|
item = ItemBank.find item_id
exam.item_baskets << ItemBasket.new(item_bank_id: item.id, position: index+1, score: item_score(item.item_type), item_type: item.item_type)
end
end
end
def item_score item_type
score =
case item_type
when "SINGLE", "MULTIPLE", "JUDGMENT"
5
when "PROGRAM"
10
else
5
end
score
end
end

@ -1,9 +1,10 @@
class ItemBaskets::SaveItemBasketService < ApplicationService
attr_reader :user, :params
attr_reader :user, :params, :exam_setting
def initialize(user, params)
def initialize(user, params, exam_setting)
@user = user
@params = params
@exam_setting = exam_setting
end
def call
@ -13,9 +14,14 @@ class ItemBaskets::SaveItemBasketService < ApplicationService
items = ItemBank.where(public: 1).or(ItemBank.where(user_id: user.id))
# 已选到过试题篮的不重复选用
item_ids = params[:item_ids] - user.item_baskets.pluck(:item_bank_id)
item_ids = params[:item_ids] - basket_items.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 = ItemBasket.new(item_bank_id: item.id, item_type: item.item_type)
if exam_setting.present?
new_item.examination_intelligent_setting_id = exam_setting.id
else
new_item.user_id = user.id
end
new_item.score = item_score item.item_type
new_item.position = item_position item.item_type
new_item.save!
@ -25,8 +31,8 @@ class ItemBaskets::SaveItemBasketService < ApplicationService
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
if basket_items.where(item_type: item_type).last.present?
score = basket_items.where(item_type: item_type).last.score
else
score =
case item_type
@ -42,6 +48,10 @@ class ItemBaskets::SaveItemBasketService < ApplicationService
end
def item_position item_type
user.item_baskets.where(item_type: item_type).last&.position.to_i + 1
basket_items.where(item_type: item_type).last&.position.to_i + 1
end
def basket_items
exam_setting.present? ? exam_setting.item_baskets : user.item_baskets
end
end

@ -0,0 +1,4 @@
json.single_question_count @single_question_count
json.multiple_question_count @multiple_question_count
json.judgement_question_count @judgement_question_count
json.program_question_count @program_question_count

@ -96,6 +96,17 @@ Rails.application.routes.draw do
end
end
resources :examination_intelligent_settings do
collection do
get :optinal_items
end
member do
post :exchange_one_item
post :exchange_items
end
end
resources :hacks, path: :problems, param: :identifier do
collection do
get :unpulished_list

@ -0,0 +1,13 @@
class CreateExaminationIntelligentSettings < ActiveRecord::Migration[5.2]
def change
create_table :examination_intelligent_settings do |t|
t.references :sub_discipline
t.integer :public, default: 1
t.integer :difficulty, default: 1
t.timestamps
end
add_index :examination_intelligent_settings, :sub_discipline_id, name: "index_on_sub_discipline_id"
end
end

@ -0,0 +1,13 @@
class CreateExaminationTypeSettings < ActiveRecord::Migration[5.2]
def change
create_table :examination_type_settings do |t|
t.references :examination_intelligent_setting, index: false
t.integer :item_type
t.integer :count
t.timestamps
end
add_index :examination_type_settings, :examination_intelligent_setting_id, name: "index_on_examination_intelligent_setting"
end
end

@ -0,0 +1,5 @@
class AddUserIdToIntelligentSettings < ActiveRecord::Migration[5.2]
def change
add_column :examination_intelligent_settings, :user_id, :integer, index: true
end
end

@ -0,0 +1,5 @@
class AddIntelligentSettingIdToItemBaskets < ActiveRecord::Migration[5.2]
def change
add_column :item_baskets, :examination_intelligent_setting_id, :integer, index: true
end
end

@ -75,17 +75,21 @@ class BoardsListItem extends Component{
<i className="iconfont icon-guansuo color-grey-c ml10 font-16 fl mt4"></i>
</Tooltip>) : ""
}
{canNotLink?"":<WordsBtn style="blue" className="font-16 fr " onClick={canNotLink ? () => {} : () => this.onTitleClick(discussMessage)}>查看详情</WordsBtn>}
</h6>
<div className="fr">
{(isAdmin || discussMessage.author.login == current_user.login) &&
<WordsBtn style="blue" className="fl font-16 ml28"
<WordsBtn style="blue" className="fr font-16 ml28"
onClick={(e) => { this.props.toEditPage(this.props.match.params.coursesId, this.props.match.params.boardId, discussMessage.id )} }>编辑</WordsBtn> }
{ isAdmin && <WordsBtn style="blue" className="fl font-16 ml28"
{ isAdmin && <WordsBtn style="blue" className="fr font-16 ml28"
onClick={(e) => { debugger; onSticky(discussMessage); e.cancelBubble = true; e.stopPropagation();}}>
{ discussMessage.sticky ? '取消置顶' : '置顶' }</WordsBtn> }
{canNotLink?"":<WordsBtn style="blue" className="font-16 fr " onClick={canNotLink ? () => {} : () => this.onTitleClick(discussMessage)}>查看详情</WordsBtn>}
</div>
<div className="cl"></div>

@ -227,6 +227,10 @@ class CommonWorkItem extends Component{
//
isStudent &&
<li className="fr">
<WordsBtn style="blue" className={"fl font-16"}
onClick={ canNotLink ? () => {} : () => this.onItemClick(item)}
>查看详情</WordsBtn>
{ //
item.work_status && item.work_status.indexOf('关联项目') != -1 &&
<React.Fragment>
@ -277,9 +281,7 @@ class CommonWorkItem extends Component{
item.work_status && item.work_status.indexOf('查看作品') != -1 &&
<WordsBtn style="blue" className="fl font-16 ml28" onClick={() => this.props.toWorkDetailPage(this.props.match.params, item.homework_id, item.work_id)}>查看作品</WordsBtn> }
<WordsBtn style="blue" className={"fl font-16 ml28"}
onClick={ canNotLink ? () => {} : () => this.onItemClick(item)}
>查看详情</WordsBtn>
</li>
}
</p>

@ -531,7 +531,7 @@ class Coursesleftnav extends Component{
if(result!=undefined){
if(result.data.status===0){
// window.location.reload()
this.updasaveNavmoda()
// this.updasaveNavmoda()
//
notification.open({
message:"提示",

@ -257,9 +257,9 @@ class GraduationTaskssettinglist extends Component{
}
this.seacthdata(list.length===0?undefined:list[0], task_status, course_group, cross_comment, order, b_order, search,this.state.page);
this.props.getsonar(list.length===0?undefined:list[0], task_status, course_group, cross_comment, search)
let newvalue=list.length===0?undefined:parseInt(list[0])
this.seacthdata(newvalue, task_status, course_group, cross_comment, order, b_order, search,this.state.page);
this.props.getsonar(newvalue, task_status, course_group, cross_comment, search)
// if(list.length===key){
// this.seacthdata(undefined, task_status, course_group, cross_comment, order, b_order, search,this.state.page);
// this.props.getsonar(undefined, task_status, course_group, cross_comment, search)

@ -134,13 +134,13 @@ class GraduateTopicItem extends Component{
}
{
isStudent && data.user_selected == true && discussMessage.user_topic_status==0 &&
<WordsBtn onClick={()=>chooseTopic(`${discussMessage.id}`,index,true)} style="blue" className="font-16">
<WordsBtn onClick={()=>chooseTopic(`${discussMessage.id}`,index,true)} style="blue" className="font-16 mr20">
取消选题
</WordsBtn>
}
{
isStudent && data.user_selected==false && (discussMessage.user_topic_status == null || discussMessage.user_topic_status == 2) &&
<WordsBtn onClick={()=>chooseTopic(`${discussMessage.id}`,index,false)} style="blue" className="font-16">
<WordsBtn onClick={()=>chooseTopic(`${discussMessage.id}`,index,false)} style="blue" className="font-16 mr20">
选题
</WordsBtn>
}

@ -357,7 +357,7 @@ class ShixunhomeWorkItem extends Component{
color:#fff !important;
}
.newhomepagePostSettingname{
width: 274px !important;
width: 205px !important;
}
.newwidthSettin{
width:255px !important;
@ -365,16 +365,22 @@ class ShixunhomeWorkItem extends Component{
`
}
</style>
{this.props.isAdmin?<span onClick={(event)=>this.stopPro(event)} className={discussMessage&&discussMessage.shixun_status>1?this.props.isAdminOrCreator()?"homepagePostSetting newhomepagePostSettingname":"homepagePostSetting homepagePostSettingbox":"homepagePostSetting newwidthSettin"} style={{"right":"-2px","top":"6px","display":"block"}}>
{discussMessage&&discussMessage.shixun_status>1?<a onClick={()=>this.hrefjumpskip("/courses/"+this.props.match.params.coursesId+"/"+this.state.shixuntypes+"/"+discussMessage.homework_id+"/list?tab=0")} className="btn colorblue font-16 fontweight400 mr20">查看详情</a>:""}
{/*to={`/courses/${this.props.match.params.coursesId}/${discussMessage.homework_id}/jobsettings`}*/}
{this.props.isAdmin?<span onClick={(event)=>this.stopPro(event)} className={discussMessage&&discussMessage.shixun_status>1?this.props.isAdminOrCreator()?" newhomepagePostSettingname fr":" homepagePostSettingbox fr":" newwidthSettin fr"} style={{"right":"-2px","top":"6px","display":"block"}}>
{discussMessage&&discussMessage.shixun_status>1?<Link className="btn colorblue font-16 fontweight400 mr20" to={"/shixuns/"+discussMessage.shixun_identifier+"/challenges"} target={"_blank"}>实训详情</Link>:
<a className={"btn colorfff font-16 fontweight400"}>实训详情</a>
<a className={"btn colorfff font-16 fontweight400 "}>实训详情</a>
}
{discussMessage&&discussMessage.shixun_status>1?"":<a onClick={()=>this.hrefjumpskip("/courses/"+this.props.match.params.coursesId+"/"+this.state.shixuntypes+"/"+discussMessage.homework_id+"/list?tab=0")} className="btn colorblue font-16 fontweight400 mr20">查看详情</a>}
{this.props.isAdminOrCreator()?<a onClick={(event)=>this.editname(discussMessage.name,discussMessage.homework_id,event)} className={"btn colorblue font-16 fontweight400"}>重命名</a>:""}
{this.props.isAdminOrCreator()?<a onClick={(event)=>this.editname(discussMessage.name,discussMessage.homework_id,event)} className={"btn colorblue font-16 fontweight400 "}>重命名</a>:""}
{/*<WordsBtn className="btn colorblue ml20 font-16" to={`/courses/${this.props.match.params.coursesId}/${this.state.shixuntypes}/${discussMessage.homework_id}/settings?tab=3`} > 设置</WordsBtn>*/}
<WordsBtn className="btn colorblue font-16 ml15 fontweight400" to={`/courses/${this.props.match.params.coursesId}/${this.state.shixuntypes}/${discussMessage.homework_id}/settings?tab=3`} > 设置</WordsBtn>
<WordsBtn className="btn colorblue font-16 ml15 fontweight400 " to={`/courses/${this.props.match.params.coursesId}/${this.state.shixuntypes}/${discussMessage.homework_id}/settings?tab=3`} > 设置</WordsBtn>
</span>:""}
@ -393,13 +399,18 @@ class ShixunhomeWorkItem extends Component{
</WordsBtn>:"":"":"":""
}
{ this.props.isAdmin?<a onClick={()=>this.hrefjumpskip("/courses/"+this.props.match.params.coursesId+"/"+this.state.shixuntypes+"/"+discussMessage.homework_id+"/list?tab=0")} className="btn colorblue font-16 fontweight400 mr20 fr">查看详情</a>:""}
{
this.props.isStudent? <a onClick={()=>this.hrefjumpskip("/courses/"+this.props.match.params.coursesId+"/"+this.state.shixuntypes+"/"+discussMessage.homework_id+"/list?tab=0")} className="btn colorblue font-16 fontweight400 mr20 fr mt2">查看详情</a>:""
}
{this.props.isStudent===true?this.props.course_identity===5?
<a onClick={()=>this.hrefjumpskip("/courses/"+this.props.match.params.coursesId+"/"+this.state.shixuntypes+"/"+discussMessage.homework_id+"/list?tab=0")}
className="btn colorblue colorblue font-16 mr20 fr mt2">查看详情</a>
:"":""
{
this.props.isNotMember===true? this.props.discussMessage.private_icon===true?""
:<a onClick={()=>this.hrefjumpskip("/courses/"+this.props.match.params.coursesId+"/"+this.state.shixuntypes+"/"+discussMessage.homework_id+"/list?tab=0")} className="btn colorblue font-16 fontweight400 mr20 fr">查看详情</a>:""
}
</h6>
<div className="cl"></div>

@ -422,6 +422,7 @@ class Trainingjobsetting extends Component {
if (this.state.jobsettingsdata.data.unified_setting === true) {
if (this.state.unifiedsetting === true) {
//统一设置
if (this.state.releasetime === undefined || this.state.releasetime === null || this.state.releasetime === "") {
// this.props.showNotification(`请选择发布时间`);
@ -544,13 +545,28 @@ class Trainingjobsetting extends Component {
}
} else {
//分班设置
// console.log("分班设置");
// console.log(this.$pollDetailTabForthRules);
const result=this.$pollDetailTabForthRules.notUnifiedSettingCheck(this.state.rules);
this.setState({
rules: result.rules
})
if(result.validate==false){
this.scrollToAnchor("publishtimeid");
this.props.showNotification(`分班发布设置不能为空`);
return false;
}
let rulesdata = this.state.rulesdata;
if (
rulesdata.length === 0) {
if (rulesdata.length === 0) {
this.props.showNotification(`分班发布设置不能为空`);
return;
}
//
}
}
@ -2396,7 +2412,7 @@ class Trainingjobsetting extends Component {
modalSave={modalSave}
></Modals>
<div className={"educontent"}>
<div className={"educontent"} id={"publishtimeid"}>
{
!flagPageEdit && this.props.isAdmin() === true ?
""
@ -2454,7 +2470,7 @@ class Trainingjobsetting extends Component {
</style>
{
unifiedsetting === undefined ? "" : unifiedsetting === true ?
<div>
<div >
<div className="clearfix mb5 ml15">
<span className="font-16 fl mt3" style={{color: "#999999"}}>发布时间</span>
<Tooltip placement="bottom"
@ -2536,6 +2552,9 @@ class Trainingjobsetting extends Component {
<PollDetailTabForthRules
{...this.props}
{...this.state}
ref={dom => {
this.$pollDetailTabForthRules = dom;
}}
teacherdatapage={this.props.teacherdatapage}
rules={rules}
moduleName={"作业"}

@ -134,23 +134,21 @@ class ChoquesEditor extends Component{
this.props.showNotification('请您输入题干');
return editordata;
}
for(let i = 0; i < question_choices.length; i++) {
if (!question_choices[i]) {
this.props.showNotification(`请先输入 ${tagArray[i]} 选项的内容`);
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.props.showNotification(`请先输入 ${tagArray[i]} 选项的内容`);
return editordata;
}
}
if(!question_titlesysl) {
this.props.showNotification('请您输入题目解析');
return editordata;

@ -37,6 +37,48 @@ class Contentpart extends Component {
this.props.chakanjiexibool(index);
}
xinzenw=(e)=>{
var urls="?";
if(this.props.discipline_id){
if(urls==="?"){
urls=urls+`discipline_id=${this.props.discipline_id}`
}else {
urls=urls+`&discipline_id=${this.props.discipline_id}`
}
}
if(this.props.sub_discipline_id){
if(urls==="?"){
urls=urls+`sub_discipline_id=${this.props.sub_discipline_id}`
}else {
urls=urls+`&sub_discipline_id=${this.props.sub_discipline_id}`
}
}
if(this.props.tag_discipline_id){
if(urls==="?"){
urls=urls+`sub_discipline_id=${this.props.tag_discipline_id}`
}else {
urls=urls+`&sub_discipline_id=${this.props.tag_discipline_id}`
}
}
if(this.props.difficulty){
if(urls==="?"){
urls=urls+`difficulty=${this.props.difficulty}&`
}else {
urls=urls+`&difficulty=${this.props.difficulty}`
}
}
if(this.props.item_type){
if(urls==="?"){
urls=urls+`item_type=${this.props.item_type}`
}else {
urls=urls+`&item_type=${this.props.item_type}`
}
}
this.props.history.push("/question/newitem"+urls);
}
render() {
let {page}=this.state;
let {defaultActiveKey,item_type,booljupyterurls}=this.props;
@ -139,7 +181,7 @@ class Contentpart extends Component {
<div className="xaxisreverseorder">
{
defaultActiveKey===0||defaultActiveKey==="0"?
<a href={'/question/newitem'}>
<a onClick={(e)=>this.xinzenw(e)}>
<div className="newbutoon">
<p className="newbutoontes" >新增</p>
</div>

@ -153,7 +153,7 @@ class Headplugselections extends Component {
{
item&&item.map((list,k)=>{
return(
<Menu.Item >
<Menu.Item key={k}>
<div className="mt5 subshaicontent-part" key={k}>
<a style={{ height: '20px' }} className={ "mb15 shixun_repertoire color-dark intermediatecenterysls textcen "} name={list.id} id={list.id} onClick={()=>this.getshixunchildValue(list.id,id)}>{list.name}</a>
</div>

@ -19,6 +19,8 @@ import './../questioncss/questioncom.css';
import Newknledpots from './Newknledpots'
const InputGroup = Input.Group;
const {Option} = Select;
const queryString = require('query-string');
const options = [
{
value: '方向',
@ -59,6 +61,8 @@ class Itembankstop extends Component {
//初始化
componentDidMount() {
try {
this.props.getcontentMdRef(this);
} catch (e) {
@ -68,9 +72,55 @@ class Itembankstop extends Component {
options: this.props.disciplmy,
})
console.log("数据");
console.log(this.props);
const parsed = queryString.parse(this.props.location.search);
console.log(parsed);
try {
if(JSON.stringify(parsed)==={}||JSON.stringify(parsed)==="{}"){
}else {
if(parsed.discipline_id){
if(parsed.sub_discipline_id){
this.setState({
rbkc:[parseInt(parsed.discipline_id),parseInt(parsed.sub_discipline_id)]
})
this.props.form.setFieldsValue({
rbkc: [parseInt(parsed.discipline_id),parseInt(parsed.sub_discipline_id)],
});
this.getdatasmyss(parseInt(parsed.discipline_id),parseInt(parsed.sub_discipline_id));
}
}
if(parsed.item_type){
this.setState({
rbtx:parsed.item_type,
})
this.props.form.setFieldsValue({
rbtx:parsed.item_type,
});
this.props.setitem_type(parsed.item_type);
}
if(parsed.difficulty){
this.setState({
rbnd:parsed.difficulty,
})
this.props.form.setFieldsValue({
rbnd:parsed.difficulty,
});
}
}
}catch (e) {
}
}
componentDidUpdate(prevProps) {
// 把知识点放进塞选中 ,如果是编辑 已经选中就不放进去
if (prevProps.disciplmy !== this.props.disciplmy) {
@ -79,6 +129,7 @@ class Itembankstop extends Component {
})
}
if(prevProps.disciplinesdata!== this.props.disciplinesdata){
console.log("新增开始加载了")
try {
if(this.props.item_banksedit.discipline &&this.props.item_banksedit.sub_discipline){
const didata = this.props.disciplinesdata;
@ -110,6 +161,27 @@ class Itembankstop extends Component {
knowledgepoints2: _result,
})
}
try {
const parsed = queryString.parse(this.props.location.search);
if(JSON.stringify(parsed)==={}||JSON.stringify(parsed)==="{}"){
}else {
if(parsed.discipline_id){
if(parsed.sub_discipline_id){
this.setState({
rbkc:[parseInt(parsed.discipline_id),parseInt(parsed.sub_discipline_id)]
})
this.props.form.setFieldsValue({
rbkc: [parseInt(parsed.discipline_id),parseInt(parsed.sub_discipline_id)],
});
this.getdatasmyss(parseInt(parsed.discipline_id),parseInt(parsed.sub_discipline_id));
}
}
}
}catch (e) {
}
}catch (e) {
}
}
@ -125,6 +197,7 @@ class Itembankstop extends Component {
this.handletag_disciplinesChange(this.props.item_banksedit.tag_disciplines);
}
try {
//初始化课程
this.handdisciplinesChange(this.props.item_banksedit.discipline,this.props.item_banksedit.sub_discipline);
}catch (e) {
@ -175,7 +248,42 @@ class Itembankstop extends Component {
}
}
}
getdatasmyss=(id,ids)=>{
if(this.props.disciplinesdata){
try {
if(id &&ids){
var didata = this.props.disciplinesdata;
var knowledgepointsdata = [];
for (var i = 0; i < didata.length; i++) {
//方向
if (id === didata[i].id) {
const fxdidata = didata[i].sub_disciplines;
for (var j = 0; j < fxdidata.length; j++) {
//课程
if (ids === fxdidata[j].id) {
const zsddata = fxdidata[j].tag_disciplines;
for (var k = 0; k < zsddata.length; k++) {
//知识点
knowledgepointsdata.push(zsddata[k]);
}
}
}
}
}
this.setState({
knowledgepoints:knowledgepointsdata,
knowledgepoints2: knowledgepointsdata,
})
}else{
}
}catch (e) {
}
}
}
handdisciplinesChange =(name,title)=>{
this.setState({
rbkc:[name.id,title.id]
@ -476,6 +584,11 @@ class Itembankstop extends Component {
let {page, options,NewknTypedel,knowledgepoints,knowledgepoints2,Knowpoints} = this.state;
const {getFieldDecorator} = this.props.form;
console.log("this.state.rbkc");
console.log(this.state.rbkc);
console.log(options);
return (
<div className=" clearfix educontent Contentquestionbankstyle w100s w1200fpx mt19">
@ -555,15 +668,15 @@ class Itembankstop extends Component {
<img className=" ml22 zjzsdian xiaoshou" src={getImageUrl("images/educoder/zjzsd.png")} onClick={()=>this.NewknTypedeldel(true)}/>
<div className="sortinxdirection" style={{
height: "33px",
<div className="sortinxdirection huanhan" style={{
minHeight: "33px",
lineHeight: "28px",
}}>
{this.state.Knowpoints === undefined ? "" : this.state.Knowpoints.map((object, index) => {
return (
<div key={index} className="mytags" style={{
<div key={index} className={index===0?"mytags mb20":"mytags"} style={{
position: "relative",
}}>
<p className="w100s stestcen lh32">{object.name}</p>

@ -14,10 +14,27 @@ class PaperDeletModel extends Component {
}
handleChange=(e)=>{
// this.setState({
// newkntypeinput: e.target.value
// })
// console.log(e.target.value);
// console.log(e.target.value.length);
this.setState({
newkntypeinput: e.target.value
})
//
// debugger
// console.log(e);
//
// if(e.target.value.length>0){
// if(e.target.value.length>=16){
// var result = e.target.value.substring(0,15);
// this.setState({
// newkntypeinput: result
// })
// }
// }
}
render() {
@ -35,7 +52,7 @@ class PaperDeletModel extends Component {
>
<div className="educouddiv">
<div className={"tabeltext-alignleft mt10"}>
<Input onInput={this.handleChange} />
<Input onInput={this.handleChange} maxLength={16} />
</div>
<div className="clearfix mt30 edu-txt-center">
<a className="task-btn mr30 w80" onClick={()=>this.props.NewknTypedeldel(false)}>取消</a>

@ -141,13 +141,6 @@ class SingleEditor extends Component{
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()
@ -156,6 +149,14 @@ class SingleEditor extends Component{
}
}
if(!answerArray || answerArray.length == 0) {
this.props.showNotification('请先点击选择本选择题的正确选项');
return editordata;
}
if(!question_titlesysl) {
this.props.showNotification('请您输入题目解析');
return editordata;
@ -328,7 +329,7 @@ class SingleEditor extends Component{
texts=value;
}
this.setState({
question_titleysl:texts
question_titlesysl:texts
})
}
}
@ -410,7 +411,7 @@ class SingleEditor extends Component{
{/* <Tooltip title={standard_answers[index] ? '点击取消标准答案设置' : '点击设置为标准答案'}> */}
<span className={`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}>
<ConditionToolTip key={index} title={'点击设置为标准答案'} placement="left" condition={true}>
<div style={{width: '100%', height: '100%'}}>{tagArray[index]}</div>
</ConditionToolTip>
</span>

@ -524,7 +524,7 @@
margin-top: 19px;
}
.mytags{
width:106px;
min-width:106px;
height:32px;
border-radius:2px;
border:1px solid #DDDDDD;
@ -955,4 +955,9 @@
padding: 0px !important;
}
.huanhan{
flex-wrap: wrap;
}
.mb20{
margin-bottom: 20px;
}

@ -1043,7 +1043,6 @@ submittojoinclass=(value)=>{
.questionbanks .ant-popover-inner-content {
padding:0px !important;
}
`
}
</style>

@ -0,0 +1,5 @@
require 'rails_helper'
RSpec.describe ExaminationIntelligentSetting, type: :model do
pending "add some examples to (or delete) #{__FILE__}"
end

@ -0,0 +1,5 @@
require 'rails_helper'
RSpec.describe ExaminationTypeSetting, type: :model do
pending "add some examples to (or delete) #{__FILE__}"
end
Loading…
Cancel
Save