Merge branch 'dev_aliyun' of https://bdgit.educoder.net/Hjqreturn/educoder into topic_bank

dev_aliyun_beta
杨树林 6 years ago
commit 39aaaf96a9

@ -121,25 +121,20 @@ class ShixunsController < ApplicationController
@shixuns = status == "published" ? @shixuns.where(status: 2) : @shixuns.where(status: [0, 1])
end
## 搜索关键字创建者、实训名称、院校名称
unless params[:search].blank?
keyword = params[:search].strip
@shixuns = @shixuns.joins(user: [user_extension: :school]).
where("schools.name like '%#{keyword}%'
or concat(lastname, firstname) like '%#{keyword}%'
or shixuns.name like '%#{keyword.split(" ").join("%")}%'").distinct
end
## 筛选 难度
if params[:diff].present? && params[:diff].to_i != 0
@shixuns = @shixuns.where(trainee: params[:diff])
@shixuns = @shixuns.where(trainee: params[:diff])
end
@total_count = @shixuns.count
page = params[:page] || 1
limit = params[:limit] || 15
limit = params[:limit] || 10
offset = (page.to_i - 1) * limit
order = params[:order] || "desc"
## 搜索关键字创建者、实训名称、院校名称
keyword = params[:search]
@shixuns = Shixun.search keyword, where: {id: @shixuns.pluck(:id)}, order: {"myshixuns_count" => order}, limit: limit, offset: offset
@shixuns = @shixuns.order("myshixuns_count desc").page(page).per(limit).includes(:shixun_info, :subjects, user: [user_extension: :school])
@total_count = @shixuns.total_count
end
## 获取顶部菜单

@ -14,7 +14,9 @@ module Searchable::Shixun
def search_data
{
name: name,
description: Util.extract_content(description)[0..Searchable::MAXIMUM_LENGTH]
description: Util.extract_content(description)[0..Searchable::MAXIMUM_LENGTH],
status: status,
myshixuns_count: myshixuns_count
}.merge!(searchable_user_data)
.merge!(searchable_challenge_data)
end
@ -37,7 +39,7 @@ module Searchable::Shixun
end
def should_index?
status == 2 # published
[0, 1, 2].include?(status) # published
end
def to_searchable_json

@ -14,10 +14,12 @@ class SearchService < ApplicationService
private
def search_options
{
model_options = {
index_name: index_names,
model_includes: model_includes
}.merge(default_options)
}
model_options.merge(where: { status: 2 }) if index_names == [Shixun]
model_options.merge(default_options)
end
def index_names

@ -1,15 +1,17 @@
json.shixun_list @shixuns do |shixun|
json.shixun_id shixun.id
json.identifier shixun.identifier
json.shixun_name shixun.name
json.description shixun.description
json.myshixuns_count shixun.myshixuns_count
json.school shixun.user&.school_name
json.creator shixun.user&.full_name
json.level level_to_s(shixun.trainee)
json.subjects shixun.subjects do |subject|
json.(subject, :id, :name)
end
end
json.shixuns_count @total_count
json.shixun_list do
json.array! @shixuns.with_highlights(multiple: true) do |obj, highlights|
puts obj
json.merge! obj.to_searchable_json
json.challenge_names obj.challenges.pluck(:subject)
json.shixuns_count @total_count
json.title highlights.delete(:name)&.join('...') || obj.searchable_title
# json.description highlights.values[0,5].each { |arr| arr.is_a?(Array) ? arr.join('...') : arr }.join('<br/>')
json.content highlights
json.level level_to_s(obj.trainee)
json.subjects obj.subjects do |subject|
json.(subject, :id, :name)
end
end
end

Binary file not shown.

After

Width:  |  Height:  |  Size: 661 KiB

@ -70,6 +70,7 @@ class PollNew extends Component {
Newdisplay:false,
first_category_url:"",
left_banner_id:"",
publishtimeid_int:0,
}
// console.log("试卷新建和编辑");
// console.log(JSON.stringify(props));
@ -366,7 +367,12 @@ class PollNew extends Component {
}
//添加单选题目
addmysingles = () => {
if (this.state.q_countst > 0) {
this.scrollToAnchor("publishtimeid"+this.state.publishtimeid_int);
this.props.showNotification(`不能同时编辑两题`);
return;
}
if (this.state.newoption === true) {
this.setState({
newoption: false
@ -383,12 +389,18 @@ class PollNew extends Component {
}
}
this.addMytopic(1, this.state.pollid, Insertposition, false, 0);
// }
this.addMytopic(1, this.state.pollid, Insertposition, false, 0,0);
this.scrollToAnchor("publishtimeids");
}
//添加多选题目
addmydoubles = () => {
if (this.state.q_countst > 0) {
this.scrollToAnchor("publishtimeid"+this.state.publishtimeid_int);
this.props.showNotification(`不能同时编辑两题`);
return;
}
// console.log("addmymainsint 70")
if (this.state.newoption === true) {
this.setState({
@ -407,13 +419,17 @@ class PollNew extends Component {
}
this.addMytopic(2, this.state.pollid, Insertposition, false, 0);
// }
this.addMytopic(2, this.state.pollid, Insertposition, false, 0,0);
this.scrollToAnchor("publishtimeids");
}
//添加主观题目
addmymainsint = () => {
if (this.state.q_countst > 0) {
this.scrollToAnchor("publishtimeid"+this.state.publishtimeid_int);
this.props.showNotification(`不能同时编辑两题`);
return;
}
this.setState({
Newdisplay:true,
})
@ -427,22 +443,23 @@ class PollNew extends Component {
}
this.addMytopic(3, this.state.pollid, Insertposition, false, 0);
// }
this.addMytopic(3, this.state.pollid, Insertposition, false, 0,0);
this.scrollToAnchor("publishtimeids");
}
//编辑方法
adddomedit = (object) => {
adddomedit = (object,indexysl) => {
// console.log("adddomedit 76");
if (this.state.q_countst > 0) {
this.props.showNotification(`不能同时编辑两题`);
this.scrollToAnchor("publishtimeids");
return;
}
var anserbool = false;
this.setState({
q_countst: 1,
bindingid:object.question.id
bindingid:object.question.id,
publishtimeid_int:indexysl
})
// window.scrollTo(0, this.refs.targetElement.offsetTops)
let {adddom} = this.state;
@ -581,9 +598,19 @@ class PollNew extends Component {
})
}
//滚动
scrollToAnchor=(index)=>{
// let name="Anchor_"+index;
console.log("scrollToAnchor");
console.log(index);
if (index) {
let anchorElement = document.getElementById(index);
// if(anchorElement) { anchorElement.scrollIntoView(); }
$("html").animate({ scrollTop: $(anchorElement).offset().top - 150})
}
}
//新增添加题目 有new
addMytopic = (index, pollid, Insertposition, Whether, id) => {
addMytopic = (index, pollid, Insertposition, Whether, id,inty) => {
//Whether 是否插入
// console.log("addMytopic 90")
// console.log(index)
@ -593,10 +620,17 @@ class PollNew extends Component {
console.log("addMytopic");
console.log(id);
if (this.state.q_countst > 0) {
if(Whether===true){
this.scrollToAnchor("publishtimeids");
}
this.props.showNotification(`不能同时编辑两题`);
return;
}
if(Whether===true){
this.setState({
publishtimeid_int:inty,
})
}
this.state.Insertposition = Insertposition;
var Whethername = null;
if (Whether === true) {
@ -2081,32 +2115,67 @@ class PollNew extends Component {
axios.post(url, {
opr: "up",
}).then((result) => {
// try {
// if (result.data.status === 0) {
// this.props.showNotification(`上移成功`);
// thiss.thisinitializationdatanew();
// }
// // console.log(JSON.stringify(result))
// } catch (e) {
// // console.log("上移题目成功 错误")
// console.log(e)
// }
try {
if (result.data.status === 0) {
this.props.showNotification(`上移成功`);
thiss.thisinitializationdatanew();
if(result){
if(result.data){
if (result.data.status === 0) {
this.props.showNotification(`上移成功`);
thiss.thisinitializationdatanew();
}else{
this.props.showNotification(`上移失败`);
}
}
}else {
this.props.showNotification(`上移失败`);
}
// console.log(JSON.stringify(result))
} catch (e) {
// console.log("上移题目成功 错误")
console.log(e)
}
this.props.showNotification(`上移失败`);
}
})
} else {
var url = `/poll_questions/${poll_question_id}/up_down.json`;
axios.post(url, {
opr: "down",
}).then((result) => {
// try {
// if (result.data.status === 0) {
// // message.success("下移题目成功", 1)
// this.props.showNotification(`下移成功`);
// thiss.thisinitializationdatanew();
// }
// // console.log(JSON.stringify(result))
// } catch (e) {
// // console.log("下移题目成功 错误")
// console.log(e)
// }
try {
if (result.data.status === 0) {
// message.success("下移题目成功", 1)
this.props.showNotification(`下移成功`);
thiss.thisinitializationdatanew();
if(result){
if(result.data){
if (result.data.status === 0) {
this.props.showNotification(`下移成功`);
thiss.thisinitializationdatanew();
}else {
this.props.showNotification(`下移失败`);
}
}else {
this.props.showNotification(`上移失败`);
}
}
// console.log(JSON.stringify(result))
} catch (e) {
// console.log("下移题目成功 错误")
this.props.showNotification(`上移失败`);
console.log(e)
}
})
@ -2243,17 +2312,17 @@ class PollNew extends Component {
//点击向上排序按钮事件
handleClickBySortUp = (index, object) => {
// console.log("handleClickBySortUp 521")
let arr = this.state.poll_questions;
let newarr = [...arr];
// let arr = this.state.poll_questions;
// let newarr = [...arr];
// console.log(newarr)
if (index != 0) {
this.Upanddownmovementof(true, object.question.id);
let temp = newarr[index - 1];
newarr[index - 1] = newarr[index];
newarr[index] = temp;
this.setState({
poll_questions: newarr,
});
// let temp = newarr[index - 1];
// newarr[index - 1] = newarr[index];
// newarr[index] = temp;
// this.setState({
// poll_questions: newarr,
// });
}
}
@ -2265,12 +2334,12 @@ class PollNew extends Component {
//
if (index != newarr.length - 1) {
this.Upanddownmovementof(false, object.question.id);
let temp = newarr[index + 1];
newarr[index + 1] = newarr[index];
newarr[index] = temp;
this.setState({
poll_questions: newarr,
});
// let temp = newarr[index + 1];
// newarr[index + 1] = newarr[index];
// newarr[index] = temp;
// this.setState({
// poll_questions: newarr,
// });
} else {
// console.log("2222index==arr.length");
// console.log(this.state.poll_questions);
@ -2897,12 +2966,12 @@ class PollNew extends Component {
title="下移"><i
className="color-green font-18 iconfont icon-xiangxiayi"></i></Tooltip></a>}
<a className="mr30"
onClick={() => this.addMytopic(item.question.question_type, this.state.pollid, index + 1, true, item.question.id)}><Tooltip
onClick={() => this.addMytopic(item.question.question_type, this.state.pollid, index + 1, true, item.question.id,index)}><Tooltip
title={item.question.question_type === 1 ? "插入单选题" : item.question.question_type === 2 ? "插入多选题" : "插入主观题"}><i
className="color-green font-18 iconfont icon-roundaddfill"></i></Tooltip></a>
<a onClick={() => this.adddomedit(item)}><Tooltip title="编辑"><i
<a onClick={() => this.adddomedit(item,index)}><Tooltip title="编辑"><i
className="color-green font-18 iconfont icon-bianjidaibeijing"></i></Tooltip></a>
</span> : <span className="fr"> <a onClick={() => this.adddomedit(item)}><Tooltip title=""><i
</span> : <span className="fr"> <a onClick={() => this.adddomedit(item,index)}><Tooltip title=""><i
className="color-green font-18 iconfont icon-bianjidaibeijing"></i></Tooltip></a> </span>
}
@ -2959,7 +3028,7 @@ class PollNew extends Component {
let arrid = itemo.question.id;
let resultDomtwo;
resultDomtwo =
<div >
<div id={"publishtimeid"+index}>
<span
className="font-16 color-grey-6 mb20" id={"yslproblms3"}>{itemo.question.question_type === 1 ? "单选题" : itemo.question.question_type === 2 ? "多选题" : "主观题"}
<Checkbox value={itemo.question.is_necessary}
@ -3201,7 +3270,7 @@ class PollNew extends Component {
let arrid = itemo.question.id;
let resultDomtwo;
resultDomtwo =
<div >
<div id={"publishtimeid"+index}>
<span
className="font-16 color-grey-6 mb20" id={"yslproblms2"}>{itemo.question.question_type === 1 ? "单选题" : itemo.question.question_type === 2 ? "多选题" : "主观题"}
<Checkbox value={itemo.question.is_necessary}
@ -3452,7 +3521,7 @@ class PollNew extends Component {
let arrid = itemo.question.id;
let resultDomtwo;
resultDomtwo =
<div className="problemShow">
<div className="problemShow" id={"publishtimeids"}>
<span
className="font-16 color-grey-6 mb20" id={"yslproblms"}>{itemo.question.question_type === 1 ? "单选题" : itemo.question.question_type === 2 ? "多选题" : "主观题"}
<Checkbox value={itemo.question.is_necessary}

Loading…
Cancel
Save