Commit ba3410c0 by yuananting

fix:bug修复

parent 5cafb6c1
......@@ -15,7 +15,6 @@ import NewQuestionTab from "./components/NewQuestionTab";
import { defineJudgeOptionInfo, defineOptionInfo, defineQuestionInfo } from "./components/model";
import QuestionBankService from "@/domains/question-bank-domain/QuestionBankService";
import User from "@/common/js/user";
import UploadOss from "@/core/upload";
const { TabPane } = Tabs;
class AddNewQuestion extends Component {
......@@ -49,6 +48,13 @@ class AddNewQuestion extends Component {
}
}
transferStemDocument = (txt) => {
const template = `<p class='content'>${txt}</p>`;
let doc = new DOMParser().parseFromString(template, "text/html");
let p = doc.querySelector(".content");
return p;
};
queryQuestionDetails = () => {
let query = {
id: getParameterByName("id"),
......@@ -58,6 +64,10 @@ class AddNewQuestion extends Component {
};
QuestionBankService.queryQuestionDetails(query).then((res) => {
const { result = [] } = res;
let stemContent = _.find(
result.questionStemList,
(contentItem) => contentItem.type === "RICH_TEXT"
);
const { questionTypeEnum } = result;
switch (questionTypeEnum) {
case "SINGLE_CHOICE":
......@@ -70,6 +80,12 @@ class AddNewQuestion extends Component {
this.setState({ judgeContent: result });
break;
case "GAP_FILLING":
stemContent.content = stemContent.content.split('').map((item) => {
if (item === '_') {
return `<input class="add-fill-line" disabled correctAnswerList="" id=${window.random_string(16)} value="填空"/>`
}
return item;
}).join('');
this.setState({ gapFillingContent: result });
break;
case "INDEFINITE_CHOICE":
......@@ -99,7 +115,7 @@ class AddNewQuestion extends Component {
case "JUDGE":
let judgeContent = defineQuestionInfo("JUDGE");
var judgeOptions = ["正确", "错误"];
judgeOptions.forEach(item=>{
judgeOptions.forEach(item => {
judgeContent.optionList.push(defineJudgeOptionInfo(item));
})
this.setState({ judgeContent });
......@@ -155,9 +171,6 @@ class AddNewQuestion extends Component {
message.success("保存成功");
if (next === "add") {
this.handleRest(type);
// window.RCHistory.push({
// pathname: `/create-new-question?categoryId=${params.categoryId}&key=${type}`,
// });
}
if (next === "close") {
window.RCHistory.push({
......@@ -231,9 +244,9 @@ class AddNewQuestion extends Component {
}
break;
case "GAP_FILLING":
// if (this.gapRef.checkInput() === 0) {
if (this.gapRef.checkInput() === 0) {
this.saveCurrentQuestion(gapFillingContent, "GAP_FILLING", next);
// }
}
break;
case "INDEFINITE_CHOICE":
if (this.indefiniteRef.checkInput() === 0) {
......@@ -261,10 +274,11 @@ class AddNewQuestion extends Component {
gapFillingContent,
indefiniteChoiceContent,
} = this.state;
const categoryId = getParameterByName("categoryId");
return (
<div className="page add-new-question">
<Breadcrumbs
navList={getParameterByName("id") && this.state.currentOperate==="edit" ? "编辑题目" : "新增题目"}
navList={getParameterByName("id") && this.state.currentOperate === "edit" ? "编辑题目" : "新增题目"}
goBack={() => this.handleGoBack()}
/>
<div className="box">
......@@ -336,7 +350,6 @@ class AddNewQuestion extends Component {
}}
questionInfo={gapFillingContent}
onSetState={(newContent) => {
console.log("gapFillingContent:" ,newContent)
Object.assign(gapFillingContent, newContent);
}}
/>
......@@ -374,13 +387,13 @@ class AddNewQuestion extends Component {
>
取消
</Button>
<Button
{(categoryId && categoryId!=="null") && <Button
onClick={() => {
this.confirmSaveQuestion("add");
}}
>
保存并继续添加
</Button>
</Button>}
<Button
type="primary"
onClick={() => {
......
......@@ -19,9 +19,6 @@ class QuestionBankIndex extends Component {
super(props);
this.state = {
selectedCategoryId: "",
loading: true,
dataSource: [], // 题库列表数据
totalCount: 1, // 题库数据总条数
};
}
......@@ -33,8 +30,8 @@ class QuestionBankIndex extends Component {
}
};
updatedSiderTreeFromList = (updatedCategoryId) => {
this.setState({updatedCategoryId});
updatedSiderTreeFromList = (currentTotal) => {
this.setState({currentTotal});
};
render() {
......@@ -45,7 +42,7 @@ class QuestionBankIndex extends Component {
<div className="sider">
<QuestionBankSider
getSelectedCategoryId={this.getCategoryIdFromSider.bind(this)}
updatedCategoryId={this.state.updatedCategoryId}
currentTotal={this.state.currentTotal}
/>
</div>
<div className="content">
......
......@@ -2,7 +2,7 @@
* @Author: yuananting
* @Date: 2021-02-23 18:28:50
* @LastEditors: yuananting
* @LastEditTime: 2021-03-19 14:15:00
* @LastEditTime: 2021-03-22 09:42:28
* @Description: 助学工具-题库-主页面分类管理
* @Copyrigh: © 2020 杭州杰竞科技有限公司 版权所有
*/
......@@ -44,6 +44,7 @@ class QuestionCategoryManage extends Component {
// 查询分类树
queryCategoryTree = (categoryName) => {
this.setState({categoryName})
let query = {
source: 0,
categoryName,
......@@ -202,6 +203,9 @@ class QuestionCategoryManage extends Component {
};
onDrop = (info) => {
if (this.state.categoryName) {
return
}
// 未分类不可以拖拽
if (
info.dragNode.categoryName === "未分类" ||
......@@ -215,10 +219,15 @@ class QuestionCategoryManage extends Component {
info.dropPosition === -1
)
return;
let targetParentId = info.dropToGap ? info.node.parentId : info.node.id;
if (this.state.treeMap[targetParentId].categoryLevel === 4) {
return message.info("最多支持5级分类")
}
let relatedNodes = this.getRelatedNodes(targetParentId);
if (relatedNodes && relatedNodes.length === 30) {
return message.info("最多只能添加30个子分类")
}
const dropKey = info.node.key;
const dragKey = info.dragNode.key;
const dropPos = info.node.pos.split("-");
......@@ -458,7 +467,19 @@ class QuestionCategoryManage extends Component {
});
let map = {};
this.setState({ treeMap: this.getTreeMap(data, map) });
let topItem = []
data.forEach((item) => {
topItem.push(item);
});
this.setState({
treeMap: Object.assign(this.getTreeMap(data, map), {
"0": {
sonCategoryList: topItem
},
})
});
return newTreeData;
};
......@@ -469,6 +490,7 @@ class QuestionCategoryManage extends Component {
this.getTreeMap(item.sonCategoryList, map);
}
});
return map;
};
......@@ -484,17 +506,17 @@ class QuestionCategoryManage extends Component {
selectedKeys,
autoExpandParent,
} = this.state;
console.log("autoExpandParent:", autoExpandParent);
return (
<div className="page question-category-manage">
<Breadcrumbs
{getParameterByName('from') === "aid" ? <Breadcrumbs
navList="课程分类"
goBack={() =>
window.RCHistory.push({
pathname: "/question-bank-index",
})
}
/>
/> :
<div className="content-header">课程分类</div>}
<div className="box">
<div className="search-condition">
<span className="search-label">搜索名称:</span>
......
......@@ -337,16 +337,17 @@
position: relative;
display: inline-block;
width: 208px;
// height: calc(208px * 9 / 16);
height: calc(208px * 9 / 16);
position: relative;
overflow: hidden;
// background-color: #000;
padding-top: 12px;
background-color: #000;
margin: 0px 12px 12px 0;
&_content {
max-width: 200px;
max-height: 200px;
border-radius: 4px;
max-width: 100%;
max-height: 100%;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
&_btn {
width: 32px;
......@@ -354,13 +355,13 @@
position: absolute;
top: 50%;
left: 50%;
margin-top: -8px;
margin-top: -16px;
margin-left: -16px;
}
.icon_arrow {
position: absolute;
top: 0px;
right: 0px;
top: -12px;
right: -8px;
color: #bfbfbf;
cursor: pointer;
font-size: 16px;
......@@ -380,19 +381,28 @@
width: 50px;
}
.gap-answer-content {
display: flex;
// display: flex;
background: #ffffff;
border-radius: 4px;
border: 1px solid #e8e8e8;
padding: 6px 12px;
padding: 8px 12px 0;
width: calc(100% - 50px);
word-wrap: break-word;
word-break: break-all;
overflow: hidden;
.ant-tag {
margin-bottom: 8px !important;
}
.gap-tag-input {
margin-right: 5px;
border: 1px solid rgb(165, 165, 165);
}
::-webkit-input-placeholder { /* WebKit browsers */
color: #FF4F4F;
}
::-moz-placeholder { /* Mozilla Firefox 19+ */
color: #FF4F4F;
}
:-ms-input-placeholder { /* Internet Explorer 10+ */
......
......@@ -2,7 +2,7 @@
* @Author: yuananting
* @Date: 2021-02-22 10:59:43
* @LastEditors: yuananting
* @LastEditTime: 2021-03-19 14:18:59
* @LastEditTime: 2021-03-22 09:47:50
* @Description: 助学工具-题库-题库主页面侧边栏
* @Copyrigh: © 2020 杭州杰竞科技有限公司 版权所有
*/
......@@ -26,7 +26,7 @@ class QuestionBankSider extends Component {
NewEditQuestionBankCategory: null, //新增或编辑分类模态框
ImportCourseCategory: null, // 引用课程分类模态框
treeData: this.props.treeData || [],
autoExpandParent: false
autoExpandParent: false,
};
}
......@@ -40,11 +40,9 @@ class QuestionBankSider extends Component {
}
shouldComponentUpdate(nextProps, nextState) {
const { updatedCategoryId } = nextProps;
if (this.props.updatedCategoryId !== updatedCategoryId) {
this.setState({ selectedKeys: [updatedCategoryId] }, () =>
this.queryCategoryTree()
);
const { currentTotal } = nextProps;
if (this.props.currentTotal !== currentTotal) {
this.queryCategoryTree();
}
return true;
}
......@@ -170,7 +168,12 @@ class QuestionBankSider extends Component {
};
render() {
const { treeData, expandedKeys, selectedKeys, autoExpandParent } = this.state;
const {
treeData,
expandedKeys,
selectedKeys,
autoExpandParent,
} = this.state;
return (
<div className="question-bank-sider">
<div className="sider-title">题目分类</div>
......@@ -186,7 +189,7 @@ class QuestionBankSider extends Component {
<Button
onClick={() => {
window.RCHistory.push({
pathname: "/question-category-manage",
pathname: "/question-category-manage?from=aid",
});
}}
>
......
......@@ -138,16 +138,32 @@ class QuestionEditor extends Component {
};
let prevList = []
let counter = 0;
const isEdit = getParameterByName('id');
if (isEdit) {
const stemDom = document.getElementsByClassName("add-fill-line");
prevList = [...stemDom].map(item => item.id)
localStorage.setItem('gap_ques_prevList', JSON.stringify(prevList));
setTimeout(function () {
const divHeight = document.getElementById(`editor${editorId}_content`)
.firstChild.offsetHeight;
if (divHeight > 30) {
this.setState({ isShowSingleInput: false });
} else {
this.setState({ isShowSingleInput: true });
}
}.bind(this))
if (counter === 0) {
this.props.changeBlankCount(stemDom)
}
}
let counter = 0
editorRoot.customConfig.onchange = (html) => {
counter ++;
const conLen = html.replace(/<(?!img|input).*?>/g, "").length;
counter++;
const { focusFlag } = this.state;
const textLength = editorRoot.txt.text().replace(/\&nbsp\;/gi, " ")
.length;
......@@ -172,7 +188,7 @@ class QuestionEditor extends Component {
const prev = localStorage.getItem('gap_ques_prevList');
prevList = prev && JSON.parse(prev);
}
let idx = 0;
if (prevList && ids) {
idx = this.getNewArr(prevList, ids);
......@@ -186,7 +202,7 @@ class QuestionEditor extends Component {
this.setState({ blanksList: _blanksList }, () => this.props.changeBlankCount(_blanksList, idx))
}
this.setState(
{ contentLength, visiblePlacehold: contentLength === 0 && !focusFlag },
{ contentLength, visiblePlacehold: conLen === 0 && !focusFlag },
() => {
onChange && onChange(html, this.state.contentLength);
}
......@@ -194,11 +210,12 @@ class QuestionEditor extends Component {
};
editorRoot.customConfig.onblur = (html) => {
const conLen = html.replace(/<(?!img|input).*?>/g, "").length;
editorRoot.change && editorRoot.change();
this.setState({
focusFlag: false,
visibleMediaBox: false,
visiblePlacehold: _.isEmpty(html.replace(/\<\/?[\w]+\>/g, "")),
visiblePlacehold: conLen === 0,
zIndex: 9,
});
};
......@@ -262,10 +279,7 @@ class QuestionEditor extends Component {
var _blanksList = [];
_blanksList = document.getElementsByClassName("add-fill-line");
this.setState({ blanksList: _blanksList });
this.setState({
visiblePlacehold: false,
});
// this.props.changeBlankCount(_blanksList);
this.props.changeBlankCount(_blanksList);
};
render() {
......
......@@ -2,7 +2,7 @@
* @Author: yuananting
* @Date: 2021-02-25 11:23:47
* @LastEditors: yuananting
* @LastEditTime: 2021-03-18 14:21:22
* @LastEditTime: 2021-03-22 09:44:27
* @Description: 助学工具-题库-题目管理主页面列表数据
* @Copyrigh: © 2020 杭州杰竞科技有限公司 版权所有
*/
......@@ -105,7 +105,7 @@ class QuestionManageContent extends Component {
QuestionBankService.queryQuestionPageList(_query).then((res) => {
const { records = [], total = 0 } = res.result;
this.setState({ dataSource: records });
this.setState({ total });
this.setState({ total }, () => this.props.updatedSiderTree(total));
});
};
......@@ -141,7 +141,6 @@ class QuestionManageContent extends Component {
if (res.success) {
message.success("删除成功");
this.queryQuestionPageList();
this.props.updatedSiderTree(this.props.selectedCategoryId);
}
});
};
......@@ -163,7 +162,7 @@ class QuestionManageContent extends Component {
sort = "UPDATED_DESC";
}
const _query = this.state.query;
_query.order = sort;
_query.order = sort || "UPDATED_DESC";
_query.current = 1;
this.setState({ query: _query }, () => this.queryQuestionPageList());
};
......@@ -243,7 +242,6 @@ class QuestionManageContent extends Component {
key: "accuracy",
dataIndex: "accuracy",
sorter: true,
sortDirections: ["ascend", "descend", "ascend"],
showSorterTooltip: false,
render: (val) => {
return val + "%";
......@@ -254,7 +252,6 @@ class QuestionManageContent extends Component {
key: "updateTime",
dataIndex: "updateTime",
sorter: true,
sortDirections: ["ascend", "descend", "ascend"],
showSorterTooltip: false,
render: (val) => {
return formatDate("YYYY-MM-DD H:i:s", val);
......@@ -300,6 +297,7 @@ class QuestionManageContent extends Component {
// 自定义表格空状态
customizeRenderEmpty = () => {
const { categoryId } = this.state.query;
return (
<Empty
image="https://image.xiaomaiketang.com/xm/emptyTable.png"
......@@ -308,16 +306,16 @@ class QuestionManageContent extends Component {
}}
description={
<div>
还没有题目,快去
<span
className="empty-list-tip"
onClick={() => {
this.handleCreateQuestionBank()
}}
>
新建一个
<span>还没有题目</span>{(["CloudManager", "StoreManager"].includes(User.getUserRole()) && !["0", null].includes(categoryId)) && (<span>,快去
<span
className="empty-list-tip"
onClick={() => {
this.handleCreateQuestionBank()
}}
>
新建一个
</span>
吧!
吧!</span>)}
</div>
}
></Empty>
......
......@@ -2,7 +2,7 @@
* @Author: 吴文洁
* @Date: 2020-03-18 10:01:28
* @LastEditors: yuananting
* @LastEditTime: 2021-03-02 10:59:09
* @LastEditTime: 2021-03-22 09:46:07
* @Description: 录音组件
*/
......@@ -35,7 +35,7 @@ class XMRecord extends Component {
this.getAudioRecorderDevice();
}
componentWillUnmount() {}
componentWillUnmount() { }
getAudioRecorderDevice = () => {
//仅用来进行录音
......@@ -117,13 +117,14 @@ class XMRecord extends Component {
const blob = this.mMediaRecorder.upload();
UploadOss.uploadBlobToOSS(blob, window.random_string(16) + '.wav').then((mp3URL) => {
const { recordTime } = this.state;
this.props.onFinish(mp3URL, recordTime * 1000);
this.setState({
recordTime: 0,
isFinished: true,
});
window.clearInterval(this.timer);
this.mMediaRecorder.stop();
});
};
......@@ -147,6 +148,7 @@ class XMRecord extends Component {
},
() => {
this.props.onCancel();
this.mMediaRecorder.stop();
},
);
};
......
......@@ -108,6 +108,9 @@ export default function AudioRecorder(stream, config) {
//停止
this.stop = function () {
stream.getTracks().forEach(function(track) {
track.stop();
});
recorder.disconnect();
}
......
......@@ -244,7 +244,7 @@ class BatchImportQuestionModal extends Component {
</Modal>
<SelectPrepareFileModal
operateType="select"
accept="xls/xlsx"
accept="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/vnd.ms-excel"
selectTypeList={[
"vnd.openxmlformats-officedocument.spreadsheetml.sheet",
"vnd.ms-excel",
......
......@@ -2,7 +2,7 @@
* @Author: yuananting
* @Date: 2021-02-22 17:51:28
* @LastEditors: yuananting
* @LastEditTime: 2021-03-18 09:32:59
* @LastEditTime: 2021-03-22 09:43:18
* @Description: 助学工具-题库-题库新建或编辑题库分类模态框
* @Copyrigh: © 2020 杭州杰竞科技有限公司 版权所有
*/
......@@ -126,6 +126,11 @@ class NewEditQuestionBankCategory extends Component {
// 查询是否重名
checkExist = (sameLevelNodes, categoryName) => {
if ((sameLevelNodes.length > 0 && sameLevelNodes[0].parentId === "0")) {
if (categoryName === "未分类") {
return true;
}
}
var result = null;
sameLevelNodes.forEach((item) => {
if (result != null) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment