"use strict"; (self["webpackChunk"] = self["webpackChunk"] || []).push([[8286],{ /***/ 37863: /*!***********************************************!*\ !*** ./src/components/Editor/NullMDEditor.js ***! \***********************************************/ /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ "Z": function() { return /* binding */ NullMDEditor; } /* harmony export */ }); /* harmony import */ var _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_helpers_objectSpread2_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./node_modules/@babel/runtime/helpers/objectSpread2.js */ 42122); /* harmony import */ var _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_helpers_objectSpread2_js__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_helpers_objectSpread2_js__WEBPACK_IMPORTED_MODULE_0__); /* harmony import */ var _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_helpers_classCallCheck_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./node_modules/@babel/runtime/helpers/classCallCheck.js */ 56690); /* harmony import */ var _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_helpers_classCallCheck_js__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_helpers_classCallCheck_js__WEBPACK_IMPORTED_MODULE_1__); /* harmony import */ var _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_helpers_createClass_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./node_modules/@babel/runtime/helpers/createClass.js */ 89728); /* harmony import */ var _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_helpers_createClass_js__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_helpers_createClass_js__WEBPACK_IMPORTED_MODULE_2__); /* harmony import */ var _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_helpers_assertThisInitialized_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./node_modules/@babel/runtime/helpers/assertThisInitialized.js */ 66115); /* harmony import */ var _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_helpers_assertThisInitialized_js__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_helpers_assertThisInitialized_js__WEBPACK_IMPORTED_MODULE_3__); /* harmony import */ var _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_helpers_inherits_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./node_modules/@babel/runtime/helpers/inherits.js */ 61655); /* harmony import */ var _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_helpers_inherits_js__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(_root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_helpers_inherits_js__WEBPACK_IMPORTED_MODULE_4__); /* harmony import */ var _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_helpers_createSuper_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./node_modules/@babel/runtime/helpers/createSuper.js */ 26389); /* harmony import */ var _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_helpers_createSuper_js__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(_root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_helpers_createSuper_js__WEBPACK_IMPORTED_MODULE_5__); /* harmony import */ var _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_helpers_defineProperty_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./node_modules/@babel/runtime/helpers/defineProperty.js */ 38416); /* harmony import */ var _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_helpers_defineProperty_js__WEBPACK_IMPORTED_MODULE_6___default = /*#__PURE__*/__webpack_require__.n(_root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_helpers_defineProperty_js__WEBPACK_IMPORTED_MODULE_6__); /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! react */ 67294); /* harmony import */ var _markdown_editor__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../markdown-editor */ 55373); /* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! react/jsx-runtime */ 85893); var NULL_CH = '▁'; var NullMDEditor = /*#__PURE__*/function (_Component) { _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_helpers_inherits_js__WEBPACK_IMPORTED_MODULE_4___default()(NullMDEditor, _Component); var _super = _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_helpers_createSuper_js__WEBPACK_IMPORTED_MODULE_5___default()(NullMDEditor); function NullMDEditor() { var _this; _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_helpers_classCallCheck_js__WEBPACK_IMPORTED_MODULE_1___default()(this, NullMDEditor); for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } _this = _super.call.apply(_super, [this].concat(args)); _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_helpers_defineProperty_js__WEBPACK_IMPORTED_MODULE_6___default()(_root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_helpers_assertThisInitialized_js__WEBPACK_IMPORTED_MODULE_3___default()(_this), "getChCountBeforeCursor", function (cm, cursor) { var currentLine = cursor.line; var placeholderCountBefore = 0; for (var _line = 0; _line < currentLine; _line++) { placeholderCountBefore += cm.getLine(_line).split(NULL_CH).length - 1; } var currentLineStringBeforeCursor = cm.getLine(currentLine).substring(0, cursor.ch); placeholderCountBefore += currentLineStringBeforeCursor.split(NULL_CH).length - 1; return placeholderCountBefore; }); _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_helpers_defineProperty_js__WEBPACK_IMPORTED_MODULE_6___default()(_root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_helpers_assertThisInitialized_js__WEBPACK_IMPORTED_MODULE_3___default()(_this), "onCMBeforeChange", function (cm, change) { var rangeText = cm.getRange(change.from, change.to); var totalPlaceholderCount = 0; change.text.forEach(function (item) { totalPlaceholderCount += item.split(NULL_CH).length - 1; }); if (rangeText && rangeText.indexOf(NULL_CH) != -1) { var placeholderCountInRange = rangeText.split(NULL_CH).length - 1; var placeholderCountBefore = _this.getChCountBeforeCursor(cm, change.from); console.log("\u5220\u9664".concat(placeholderCountInRange, "\u4E2A\uFF0C \u4E4B\u524D\u6709").concat(placeholderCountBefore, "\u4E2A\uFF0C\u65B0\u589E").concat(totalPlaceholderCount, "\u4E2A")); if (_this.props.deleteEmptyDisabled) { // 删除空格不检测 change.cancel(); } else { // const ret = window.confirm( // `确认要删除第${ // placeholderCountInRange == 1 // ? placeholderCountBefore + 1 // : `${placeholderCountBefore + 1}-${placeholderCountBefore + // placeholderCountInRange}` // }个空吗?`, // ); // if (ret) { _this.props.onPlaceholderChange && _this.props.onPlaceholderChange(placeholderCountBefore, placeholderCountInRange, totalPlaceholderCount); // } else { // change.cancel(); // } } } else if (totalPlaceholderCount) { var _placeholderCountBefore = _this.getChCountBeforeCursor(cm, change.from); console.log("\u65B0\u589E".concat(totalPlaceholderCount, "\u4E2A\uFF0C\u4E4B\u524D\u6709").concat(_placeholderCountBefore, "\u4E2A")); _this.props.onPlaceholderChange && _this.props.onPlaceholderChange(_placeholderCountBefore, 0, totalPlaceholderCount); } }); return _this; } _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_helpers_createClass_js__WEBPACK_IMPORTED_MODULE_2___default()(NullMDEditor, [{ key: "render", value: function render() { return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_9__.jsx)(_markdown_editor__WEBPACK_IMPORTED_MODULE_8__/* ["default"] */ .Z, _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_helpers_objectSpread2_js__WEBPACK_IMPORTED_MODULE_0___default()(_root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_helpers_objectSpread2_js__WEBPACK_IMPORTED_MODULE_0___default()({}, this.props), {}, { onCMBeforeChange: this.onCMBeforeChange })); } }]); return NullMDEditor; }(react__WEBPACK_IMPORTED_MODULE_7__.Component); /***/ }), /***/ 8286: /*!***********************************************************!*\ !*** ./src/components/DragSubject/index.tsx + 19 modules ***! \***********************************************************/ /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { // EXPORTS __webpack_require__.d(__webpack_exports__, { "Z": function() { return /* binding */ components_DragSubject; } }); // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/regeneratorRuntime.js var regeneratorRuntime = __webpack_require__(17061); var regeneratorRuntime_default = /*#__PURE__*/__webpack_require__.n(regeneratorRuntime); // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/asyncToGenerator.js var asyncToGenerator = __webpack_require__(17156); var asyncToGenerator_default = /*#__PURE__*/__webpack_require__.n(asyncToGenerator); // EXTERNAL MODULE: ./node_modules/antd/es/input-number/style/index.js + 1 modules var style = __webpack_require__(25359); // EXTERNAL MODULE: ./node_modules/antd/es/input-number/index.js + 9 modules var input_number = __webpack_require__(87799); // EXTERNAL MODULE: ./node_modules/antd/es/modal/style/index.js + 1 modules var modal_style = __webpack_require__(35611); // EXTERNAL MODULE: ./node_modules/antd/es/modal/index.js + 7 modules var modal = __webpack_require__(85402); // EXTERNAL MODULE: ./node_modules/antd/es/divider/style/index.js + 1 modules var divider_style = __webpack_require__(98541); // EXTERNAL MODULE: ./node_modules/antd/es/divider/index.js var divider = __webpack_require__(27049); // EXTERNAL MODULE: ./node_modules/antd/es/row/style/index.js var row_style = __webpack_require__(13062); // EXTERNAL MODULE: ./node_modules/antd/es/row/index.js var row = __webpack_require__(71230); // EXTERNAL MODULE: ./node_modules/antd/es/button/style/index.js + 1 modules var button_style = __webpack_require__(29913); // EXTERNAL MODULE: ./node_modules/antd/es/button/index.js var es_button = __webpack_require__(71577); // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/objectSpread2.js var objectSpread2 = __webpack_require__(42122); var objectSpread2_default = /*#__PURE__*/__webpack_require__.n(objectSpread2); // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/slicedToArray.js var slicedToArray = __webpack_require__(27424); var slicedToArray_default = /*#__PURE__*/__webpack_require__.n(slicedToArray); // EXTERNAL MODULE: ./node_modules/react/index.js var react = __webpack_require__(67294); // EXTERNAL MODULE: ./node_modules/antd/es/tooltip/style/index.js + 1 modules var tooltip_style = __webpack_require__(38390); // EXTERNAL MODULE: ./node_modules/antd/es/tooltip/index.js + 3 modules var tooltip = __webpack_require__(84908); // EXTERNAL MODULE: ./node_modules/antd/es/input/style/index.js + 1 modules var input_style = __webpack_require__(69463); // EXTERNAL MODULE: ./node_modules/antd/es/input/index.js + 5 modules var input = __webpack_require__(75008); // EXTERNAL MODULE: ./node_modules/antd/es/col/style/index.js var col_style = __webpack_require__(89032); // EXTERNAL MODULE: ./node_modules/antd/es/col/index.js var col = __webpack_require__(15746); // EXTERNAL MODULE: ./node_modules/antd/es/switch/style/index.js + 1 modules var switch_style = __webpack_require__(5812); // EXTERNAL MODULE: ./node_modules/antd/es/switch/index.js + 1 modules var es_switch = __webpack_require__(94594); // EXTERNAL MODULE: ./node_modules/antd/es/radio/style/index.js + 1 modules var radio_style = __webpack_require__(83822); // EXTERNAL MODULE: ./node_modules/antd/es/radio/index.js + 4 modules var es_radio = __webpack_require__(29924); // EXTERNAL MODULE: ./node_modules/antd/es/checkbox/style/index.js + 1 modules var checkbox_style = __webpack_require__(82000); // EXTERNAL MODULE: ./node_modules/antd/es/checkbox/index.js + 2 modules var es_checkbox = __webpack_require__(32808); // EXTERNAL MODULE: ./node_modules/antd/es/message/style/index.js + 1 modules var message_style = __webpack_require__(14934); // EXTERNAL MODULE: ./node_modules/antd/es/message/index.js + 1 modules var message = __webpack_require__(12461); // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/toConsumableArray.js var toConsumableArray = __webpack_require__(861); var toConsumableArray_default = /*#__PURE__*/__webpack_require__.n(toConsumableArray); // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/objectWithoutProperties.js var objectWithoutProperties = __webpack_require__(70215); var objectWithoutProperties_default = /*#__PURE__*/__webpack_require__.n(objectWithoutProperties); // EXTERNAL MODULE: ./src/.umi-production/exports.ts + 8 modules var _umi_production_exports = __webpack_require__(89214); // EXTERNAL MODULE: ./src/service/exercise.ts var service_exercise = __webpack_require__(51412); // EXTERNAL MODULE: ./src/components/markdown-editor/index.tsx + 10 modules var markdown_editor = __webpack_require__(55373); // EXTERNAL MODULE: ./src/components/Editor/NullMDEditor.js var NullMDEditor = __webpack_require__(37863); // EXTERNAL MODULE: ./src/components/Editor/NullChildEditor/index.jsx + 1 modules var NullChildEditor = __webpack_require__(2977); // EXTERNAL MODULE: ./src/utils/util.tsx var util = __webpack_require__(29427); ;// CONCATENATED MODULE: ./src/pages/Classrooms/Lists/Exercise/Edit/components/editor.less?modules // extracted by mini-css-extract-plugin /* harmony default export */ var editormodules = ({"flex_box_center":"flex_box_center___epJYP","flex_space_between":"flex_space_between___SU6BD","flex_box_vertical_center":"flex_box_vertical_center___Qes2t","flex_box_center_end":"flex_box_center_end___hGppz","flex_box_column":"flex_box_column___uzhhO","wrap":"wrap___rEjJ0","modal":"modal___gRDV9","titleWrap":"titleWrap___MK_OO","required":"required___Hja3H","title":"title___vMFKz","colorGray":"colorGray___hNhIL","choiceWrap":"choiceWrap___Xx5du","answer":"answer___cbuNE","activeAnswer":"activeAnswer___LwFG7","deleteIcon":"deleteIcon____HG4s","addIcon":"addIcon___r_Vhy","editorWrap":"editorWrap___OYwur","htmlWrap":"htmlWrap___qXHYn","radio":"radio___urtyZ","color333":"color333___Lah7k","color999":"color999___TmkZt","questionType":"questionType___r_bKw","questionChoices":"questionChoices___LA7VM","action":"action___fTTDM","difficult":"difficult___Mg7lT","fold":"fold___oVjRI","head":"head___fpwmn"}); // EXTERNAL MODULE: ./src/components/RenderHtml/index.tsx + 1 modules var RenderHtml = __webpack_require__(12768); // EXTERNAL MODULE: ./src/components/Knowledge/index.tsx + 2 modules var Knowledge = __webpack_require__(90525); // EXTERNAL MODULE: ./node_modules/react/jsx-runtime.js var jsx_runtime = __webpack_require__(85893); ;// CONCATENATED MODULE: ./src/pages/Classrooms/Lists/Exercise/Edit/components/CompletionEditor/index.tsx var _excluded = ["problemset", "globalSetting", "exercise", "loading", "dispatch", "editData", "editKey", "setEditKey", "cancelAdd", "addCallback", "reload", "setIsClaer"]; var tagList = (/* unused pure expression or super */ null && (['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'])); var NULL_CH = '▁'; var CompletionEditor = function CompletionEditor(_ref, ref) { var problemset = _ref.problemset, globalSetting = _ref.globalSetting, exercise = _ref.exercise, loading = _ref.loading, dispatch = _ref.dispatch, editData = _ref.editData, editKey = _ref.editKey, _ref$setEditKey = _ref.setEditKey, setEditKey = _ref$setEditKey === void 0 ? function () {} : _ref$setEditKey, _ref$cancelAdd = _ref.cancelAdd, cancelAdd = _ref$cancelAdd === void 0 ? function () {} : _ref$cancelAdd, _ref$addCallback = _ref.addCallback, addCallback = _ref$addCallback === void 0 ? function () {} : _ref$addCallback, _ref$reload = _ref.reload, reload = _ref$reload === void 0 ? function () {} : _ref$reload, _ref$setIsClaer = _ref.setIsClaer, setIsClaer = _ref$setIsClaer === void 0 ? function () {} : _ref$setIsClaer, props = objectWithoutProperties_default()(_ref, _excluded); var _useState = (0,react.useState)(''), _useState2 = slicedToArray_default()(_useState, 2), title = _useState2[0], setTitle = _useState2[1]; var _useState3 = (0,react.useState)(''), _useState4 = slicedToArray_default()(_useState3, 2), analysis = _useState4[0], setAnalysis = _useState4[1]; var _useState5 = (0,react.useState)([]), _useState6 = slicedToArray_default()(_useState5, 2), answerList = _useState6[0], setAnswerList = _useState6[1]; var _useState7 = (0,react.useState)(''), _useState8 = slicedToArray_default()(_useState7, 2), activeOptionErrorIndex = _useState8[0], setActiveOptionErrorIndex = _useState8[1]; var _useState9 = (0,react.useState)(), _useState10 = slicedToArray_default()(_useState9, 2), checked = _useState10[0], setChecked = _useState10[1]; var _useState11 = (0,react.useState)(false), _useState12 = slicedToArray_default()(_useState11, 2), firstSetAnswerFlag = _useState12[0], setFirstSetAnswerFlag = _useState12[1]; var _useState13 = (0,react.useState)(), _useState14 = slicedToArray_default()(_useState13, 2), score = _useState14[0], setScore = _useState14[1]; var _useState15 = (0,react.useState)(0), _useState16 = slicedToArray_default()(_useState15, 2), totalBlanks = _useState16[0], setTotalBlanks = _useState16[1]; var _useState17 = (0,react.useState)(false), _useState18 = slicedToArray_default()(_useState17, 2), isEdit = _useState18[0], setIsEdit = _useState18[1]; var _useState19 = (0,react.useState)(false), _useState20 = slicedToArray_default()(_useState19, 2), btnSave = _useState20[0], setBtnSave = _useState20[1]; var _useState21 = (0,react.useState)([]), _useState22 = slicedToArray_default()(_useState21, 2), knowledge = _useState22[0], setKnowledge = _useState22[1]; var _useState23 = (0,react.useState)(1), _useState24 = slicedToArray_default()(_useState23, 2), difficulty = _useState24[0], setdifficult = _useState24[1]; var _useState25 = (0,react.useState)(false), _useState26 = slicedToArray_default()(_useState25, 2), repeat_answer = _useState26[0], setrepeat_answer = _useState26[1]; var freeze = (0,react.useRef)(false); var params = (0,_umi_production_exports.useParams)(); var _useState27 = (0,react.useState)([]), _useState28 = slicedToArray_default()(_useState27, 2), knowledgeOptions = _useState28[0], setKnowledgeOptions = _useState28[1]; var handleAddKnowledgeFinish = function handleAddKnowledgeFinish(item) { setKnowledgeOptions([].concat(toConsumableArray_default()(knowledgeOptions), [objectSpread2_default()({}, item)])); }; (0,react.useEffect)(function () { if (freeze.current) return; if (!(editData !== null && editData !== void 0 && editData.question_title)) { setIsEdit(true); setTitle(''); setChecked(false); setScore(2); setAnswerList([]); setActiveOptionErrorIndex(''); setFirstSetAnswerFlag(false); return; } setTitle(editData === null || editData === void 0 ? void 0 : editData.question_title); setChecked(editData === null || editData === void 0 ? void 0 : editData.is_ordered); setdifficult(editData === null || editData === void 0 ? void 0 : editData.difficulty); setrepeat_answer(!(editData !== null && editData !== void 0 && editData.repeat_answer)); setScore(editData === null || editData === void 0 ? void 0 : editData.question_score); var answer = editData === null || editData === void 0 ? void 0 : editData.standard_answer.map(function (item) { return item.answer_text; }); setAnswerList(toConsumableArray_default()(answer)); setKnowledge(editData.tag_discipline_ids); setAnalysis(editData === null || editData === void 0 ? void 0 : editData.analysis); }, [editData, isEdit]); (0,react.useEffect)(function () { setFirstSetAnswerFlag(false); if (isEdit) { init(); } function init() { return _init.apply(this, arguments); } function _init() { _init = asyncToGenerator_default()( /*#__PURE__*/regeneratorRuntime_default()().mark(function _callee() { var _exercise$editData, _exercise$editData$ex; var res; return regeneratorRuntime_default()().wrap(function _callee$(_context) { while (1) switch (_context.prev = _context.next) { case 0: _context.next = 2; return (0,service_exercise/* getTagDiscipline */.YY)({ sub_discipline_id: (_exercise$editData = exercise.editData) === null || _exercise$editData === void 0 ? void 0 : (_exercise$editData$ex = _exercise$editData.exercise) === null || _exercise$editData$ex === void 0 ? void 0 : _exercise$editData$ex.sub_discipline_id }); case 2: res = _context.sent; setKnowledgeOptions(res.tag_disciplines); case 4: case "end": return _context.stop(); } }, _callee); })); return _init.apply(this, arguments); } }, [isEdit]); (0,react.useImperativeHandle)(ref, function () { return { onSave: onSave, isEdit: isEdit }; }); (0,react.useEffect)(function () { var _exercise$tagDiscipli; var data = exercise !== null && exercise !== void 0 && (_exercise$tagDiscipli = exercise.tagDisciplineData) !== null && _exercise$tagDiscipli !== void 0 && _exercise$tagDiscipli.tag_disciplines && Array.isArray(exercise.tagDisciplineData.tag_disciplines) ? exercise.tagDisciplineData.tag_disciplines : []; setKnowledgeOptions(data); }, [exercise.tagDisciplineData]); var repeal = function repeal(res) { if ((res === null || res === void 0 ? void 0 : res.status) === 0) { message/* default.success */.ZP.success("保存成功"); setIsEdit(false); setEditKey(-1); freeze.current = false; reload(); } }; var onSave = /*#__PURE__*/function () { var _ref2 = asyncToGenerator_default()( /*#__PURE__*/regeneratorRuntime_default()().mark(function _callee4() { var answerArray, isEmpty, res, _exercise$editData4, _exercise$editData4$e, _exercise$editData5, _exercise$editData5$e; return regeneratorRuntime_default()().wrap(function _callee4$(_context4) { while (1) switch (_context4.prev = _context4.next) { case 0: answerArray = []; isEmpty = false; setBtnSave(true); //保存的时候不弹出删除框 answerList.forEach(function (answers, index) { answerArray.push({ choice_id: index + 1, answer_text: [] }); answers.forEach(function (item, itemIndex) { answerArray[index].answer_text.push(item); if (!item || !(0,util/* validateLength */.eR)(item, 10000)) { setActiveOptionErrorIndex("".concat(index, "-").concat(itemIndex)); message/* default.info */.ZP.info(!item ? "\u7B54\u6848\uFF1A\u4E0D\u80FD\u4E3A\u7A7A" : "答案不能超过10000字符"); isEmpty = true; } }); }); if (!isEmpty) { _context4.next = 7; break; } setBtnSave(false); return _context4.abrupt("return", false); case 7: // if (knowledge.length < 1) { // message.info("请选择知识点"); // return false; // } freeze.current = true; if (!editData.question_id) { _context4.next = 19; break; } if (!((editData === null || editData === void 0 ? void 0 : editData.is_my) === 1)) { _context4.next = 13; break; } modal/* default.confirm */.Z.confirm({ title: '提示', content: '此题目已存在于试题库,是否将修改后的题目覆盖试题库的原题?', okText: '覆盖原题', cancelText: '不覆盖', keyboard: false, onOk: function () { var _onOk = asyncToGenerator_default()( /*#__PURE__*/regeneratorRuntime_default()().mark(function _callee2() { var _exercise$editData2, _exercise$editData2$e; return regeneratorRuntime_default()().wrap(function _callee2$(_context2) { while (1) switch (_context2.prev = _context2.next) { case 0: _context2.next = 2; return dispatch({ type: "exercise/editExerciseQuestion", payload: { "id": editData.question_id, "question_title": title, "question_type": 3, "question_score": score, "is_ordered": checked, "standard_answers": answerArray, "tag_discipline_ids": knowledge, "sub_discipline_id": (_exercise$editData2 = exercise.editData) === null || _exercise$editData2 === void 0 ? void 0 : (_exercise$editData2$e = _exercise$editData2.exercise) === null || _exercise$editData2$e === void 0 ? void 0 : _exercise$editData2$e.sub_discipline_id, "difficulty": difficulty, 'is_cover': 1, "repeat_answer": !repeat_answer, analysis: analysis } }); case 2: res = _context2.sent; repeal(res); case 4: case "end": return _context2.stop(); } }, _callee2); })); function onOk() { return _onOk.apply(this, arguments); } return onOk; }(), onCancel: function () { var _onCancel = asyncToGenerator_default()( /*#__PURE__*/regeneratorRuntime_default()().mark(function _callee3() { var _exercise$editData3, _exercise$editData3$e; return regeneratorRuntime_default()().wrap(function _callee3$(_context3) { while (1) switch (_context3.prev = _context3.next) { case 0: _context3.next = 2; return dispatch({ type: "exercise/editExerciseQuestion", payload: { "id": editData.question_id, "question_title": title, "question_type": 3, "question_score": score, "is_ordered": checked, "standard_answers": answerArray, "tag_discipline_ids": knowledge, "sub_discipline_id": (_exercise$editData3 = exercise.editData) === null || _exercise$editData3 === void 0 ? void 0 : (_exercise$editData3$e = _exercise$editData3.exercise) === null || _exercise$editData3$e === void 0 ? void 0 : _exercise$editData3$e.sub_discipline_id, "difficulty": difficulty, "repeat_answer": !repeat_answer, analysis: analysis } }); case 2: res = _context3.sent; repeal(res); case 4: case "end": return _context3.stop(); } }, _callee3); })); function onCancel() { return _onCancel.apply(this, arguments); } return onCancel; }() }); _context4.next = 17; break; case 13: _context4.next = 15; return dispatch({ type: "exercise/editExerciseQuestion", payload: { "id": editData.question_id, "question_title": title, "question_type": 3, "question_score": score, "is_ordered": checked, "standard_answers": answerArray, "tag_discipline_ids": knowledge, "sub_discipline_id": (_exercise$editData4 = exercise.editData) === null || _exercise$editData4 === void 0 ? void 0 : (_exercise$editData4$e = _exercise$editData4.exercise) === null || _exercise$editData4$e === void 0 ? void 0 : _exercise$editData4$e.sub_discipline_id, "difficulty": difficulty, "repeat_answer": !repeat_answer, analysis: analysis } }); case 15: res = _context4.sent; repeal(res); case 17: _context4.next = 23; break; case 19: _context4.next = 21; return dispatch({ type: "exercise/addExerciseQuestion", payload: { insert_id: editData === null || editData === void 0 ? void 0 : editData.insert_id, "categoryId": params.categoryId, "question_title": title, "question_type": 3, "question_score": score, "is_ordered": checked, "standard_answers": answerArray, "tag_discipline_ids": knowledge, "sub_discipline_id": (_exercise$editData5 = exercise.editData) === null || _exercise$editData5 === void 0 ? void 0 : (_exercise$editData5$e = _exercise$editData5.exercise) === null || _exercise$editData5$e === void 0 ? void 0 : _exercise$editData5$e.sub_discipline_id, "difficulty": difficulty, "repeat_answer": !repeat_answer, analysis: analysis } }); case 21: res = _context4.sent; repeal(res); case 23: setBtnSave(false); return _context4.abrupt("return", { name: title, analysis: analysis, standard_answers: answerArray, is_ordered: checked }); case 25: case "end": return _context4.stop(); } }, _callee4); })); return function onSave() { return _ref2.apply(this, arguments); }; }(); var handlePlaceholderChange = function handlePlaceholderChange(placeholderCountBefore, placeholderCountInRange, totalPlaceholderCount) { var newStandardAnswers = answerList.slice(); if (placeholderCountInRange) { newStandardAnswers.splice(placeholderCountBefore, placeholderCountInRange); } if (totalPlaceholderCount && firstSetAnswerFlag || !editData.question_id) { for (var i = 0; i < totalPlaceholderCount; i++) { newStandardAnswers.splice(placeholderCountBefore + i, 0, [""]); } } setTotalBlanks(newStandardAnswers === null || newStandardAnswers === void 0 ? void 0 : newStandardAnswers.length); setFirstSetAnswerFlag(true); console.log(newStandardAnswers, 'newStandardAnswers'); setAnswerList(newStandardAnswers); }; var handleAnswerChange = function handleAnswerChange(index, itemIndex, val) { setActiveOptionErrorIndex(''); var newStandardAnswers = answerList.slice(); newStandardAnswers[index][itemIndex] = val; setAnswerList(newStandardAnswers); }; var handleAddChildAnswer = function handleAddChildAnswer(index) { var newStandardAnswers = answerList.slice(); newStandardAnswers[index] = [].concat(toConsumableArray_default()(newStandardAnswers[index]), ['']); setAnswerList(newStandardAnswers); }; var handleDeleteChildAnswer = function handleDeleteChildAnswer(index, childIndex) { var newStandardAnswers = answerList.slice(); if (!newStandardAnswers[index][childIndex]) { newStandardAnswers[index] = newStandardAnswers[index].filter(function (_, key) { return key !== childIndex; }); setAnswerList(newStandardAnswers); return; } modal/* default.confirm */.Z.confirm({ centered: true, okText: '确定', cancelText: '取消', title: '提示', content: '确认要删除这个参考答案吗?', className: editormodules.modal, onOk: function onOk() { newStandardAnswers[index] = newStandardAnswers[index].filter(function (_, key) { return key !== childIndex; }); setAnswerList(newStandardAnswers); } }); }; var handleDeleteChildAnswermain = function handleDeleteChildAnswermain(index) { modal/* default.confirm */.Z.confirm({ centered: true, okText: '确定', cancelText: '取消', title: '提示', content: '确认要删除这个参考答案吗?', className: editormodules.modal, onOk: function onOk() { var key = 0; setTitle(title.replace(/\▁/g, function (item) { key++; if (key - 1 === index) { return ""; } else { return item; } })); setTimeout(function () { var newStandardAnswers = answerList.slice(); newStandardAnswers = answerList.filter(function (_, key) { return index !== key; }); setAnswerList(newStandardAnswers); }, 500); } }); }; var onChange = function onChange() {}; var showEdit = function showEdit() { var _exercise$editData6, _exercise$editData6$e, _exercise$editData7, _exercise$editData7$e, _exercise$editData9, _exercise$editData9$e; console.log(answerList, 'answers'); return /*#__PURE__*/(0,jsx_runtime.jsxs)("aside", { children: [/*#__PURE__*/(0,jsx_runtime.jsx)("div", { className: editormodules.questionType, children: /*#__PURE__*/(0,jsx_runtime.jsxs)("div", { children: [/*#__PURE__*/(0,jsx_runtime.jsx)("span", { className: "font16 c-blue", children: "\u586B\u7A7A\u9898" }), "\uFF08\u5BA2\u89C2\u9898\uFF0C\u7531\u7CFB\u7EDF\u81EA\u52A8\u8BC4\u5206\uFF0C\u5141\u8BB8\u624B\u52A8\u8C03\u5206\uFF0C\u8BF7\u8BBE\u7F6E\u6807\u51C6\u7B54\u6848 \uFF1B\u652F\u6301\u6700\u591A5\u4E2A\u7A7A\uFF0C\u6BCF\u7A7A\u5F97\u5206\u6309\u7167\u672C\u9898\u7684\u603B\u5206\u5E73\u5747\u8BA1\u7B97\uFF09"] }) }), /*#__PURE__*/(0,jsx_runtime.jsx)("div", { children: /*#__PURE__*/(0,jsx_runtime.jsx)(NullMDEditor/* default */.Z, { id: "completion-question-tittle", placeholder: "\u8BF7\u60A8\u8F93\u5165\u9898\u76EE", height: 155, defaultValue: title, onChange: function onChange(value) { return setTitle(value); }, showNullButton: ((_exercise$editData6 = exercise.editData) === null || _exercise$editData6 === void 0 ? void 0 : (_exercise$editData6$e = _exercise$editData6.exercise) === null || _exercise$editData6$e === void 0 ? void 0 : _exercise$editData6$e.exercise_status) === 1 ? true : false, deleteEmptyDisabled: (((_exercise$editData7 = exercise.editData) === null || _exercise$editData7 === void 0 ? void 0 : (_exercise$editData7$e = _exercise$editData7.exercise) === null || _exercise$editData7$e === void 0 ? void 0 : _exercise$editData7$e.exercise_status) === 1 ? false : true) || btnSave, onPlaceholderChange: handlePlaceholderChange }) }), /*#__PURE__*/(0,jsx_runtime.jsx)("div", { className: "mt20", children: answerList.map(function (answers, index) { var _exercise$editData8, _exercise$editData8$e; return /*#__PURE__*/(0,jsx_runtime.jsx)(NullChildEditor/* default */.Z, { answers: answers, index: index, is_md: true, exerciseIsPublish: ((_exercise$editData8 = exercise.editData) === null || _exercise$editData8 === void 0 ? void 0 : (_exercise$editData8$e = _exercise$editData8.exercise) === null || _exercise$editData8$e === void 0 ? void 0 : _exercise$editData8$e.exercise_status) !== 1, activeOptionErrorIndex: activeOptionErrorIndex, onAnswerChange: handleAnswerChange, addChildAnswer: handleAddChildAnswer, deleteChildAnswer: handleDeleteChildAnswer, deleteChildAnswermain: handleDeleteChildAnswermain }, index); }) }), /*#__PURE__*/(0,jsx_runtime.jsx)("div", { className: "mt20", children: answerList.length > 1 && /*#__PURE__*/(0,jsx_runtime.jsxs)("span", { children: [/*#__PURE__*/(0,jsx_runtime.jsx)(es_checkbox/* default */.Z, { checked: checked, onChange: function onChange(e) { return setChecked(e.target.checked); }, className: "".concat(editormodules.color333, " font14"), children: "\u591A\u4E2A\u586B\u7A7A\u7684\u7B54\u6848\u6709\u987A\u5E8F\u8981\u6C42" }), /*#__PURE__*/(0,jsx_runtime.jsx)("span", { className: "".concat(editormodules.color999, " font12"), children: "\uFF08\u9009\u4E2D\uFF0C\u6BCF\u4E2A\u586B\u7A7A\u7684\u7B54\u6848\u987A\u5E8F\u5FC5\u987B\u4E0E\u53C2\u8003\u7B54\u6848\u4E00\u81F4\uFF09" })] }) }), /*#__PURE__*/(0,jsx_runtime.jsx)("p", { className: editormodules.titleWrap, children: /*#__PURE__*/(0,jsx_runtime.jsx)("span", { className: editormodules.title, children: "\u9898\u76EE\u89E3\u6790\uFF1A" }) }), /*#__PURE__*/(0,jsx_runtime.jsx)(markdown_editor/* default */.Z, { id: "single-question-title", watch: true, height: 155, placeholder: "\u8BF7\u60A8\u8F93\u5165\u9898\u76EE\u89E3\u6790", defaultValue: analysis, onChange: function onChange(value) { return setAnalysis(value); } }), /*#__PURE__*/(0,jsx_runtime.jsxs)("p", { className: "", children: [/*#__PURE__*/(0,jsx_runtime.jsx)("span", { style: { color: 'red' }, children: "*" }), "\u5206\u503C\uFF1A", /*#__PURE__*/(0,jsx_runtime.jsx)(input_number/* default */.Z, { value: score, max: 10000, min: 0, onChange: function onChange(value) { setScore(value); } }), " \u5206 \xA0 ", !!score && !!totalBlanks && /*#__PURE__*/(0,jsx_runtime.jsxs)("span", { style: { color: 'red' }, children: ["(\u6839\u636E\u5747\u5206\u89C4\u5219\uFF0C\u672C\u9898\u6BCF\u7A7A", (score / totalBlanks).toFixed(1), "\u5206)"] }), /*#__PURE__*/(0,jsx_runtime.jsxs)("span", { style: { marginLeft: '30px' }, className: editormodules.difficult, children: [/*#__PURE__*/(0,jsx_runtime.jsx)("label", { style: { color: 'red' }, children: "*" }), " \u96BE\u5EA6\uFF1A", /*#__PURE__*/(0,jsx_runtime.jsxs)(es_radio/* default.Group */.ZP.Group, { value: difficulty, onChange: function onChange(e) { setdifficult(e.target.value); }, children: [/*#__PURE__*/(0,jsx_runtime.jsx)(es_radio/* default.Button */.ZP.Button, { value: 1, children: "\u7B80\u5355" }), /*#__PURE__*/(0,jsx_runtime.jsx)(es_radio/* default.Button */.ZP.Button, { value: 2, children: "\u9002\u4E2D" }), /*#__PURE__*/(0,jsx_runtime.jsx)(es_radio/* default.Button */.ZP.Button, { value: 3, children: "\u56F0\u96BE" })] })] })] }), /*#__PURE__*/(0,jsx_runtime.jsxs)("p", { className: editormodules.titleWrap, children: [/*#__PURE__*/(0,jsx_runtime.jsxs)("span", { className: "".concat(editormodules.title), children: ["\u77E5\u8BC6\u70B9\uFF1A", /*#__PURE__*/(0,jsx_runtime.jsx)("span", { className: editormodules.colorGray, children: "\uFF08\u6240\u6709\u81EA\u5EFA\u77E5\u8BC6\u70B9\u4EC5\u672C\u4EBA\u53EF\u89C1\uFF0C\u88ABEduCoder\u5E73\u53F0\u5BA1\u6838\u901A\u8FC7\u4E3A\u5B98\u65B9\u77E5\u8BC6\u70B9\u540E\u6240\u6709\u7528\u6237\u53EF\u89C1\uFF09" })] }), /*#__PURE__*/(0,jsx_runtime.jsx)("div", { className: "mt5", children: /*#__PURE__*/(0,jsx_runtime.jsx)(Knowledge/* Knowledge */.N, { value: knowledge, selectvalues: editData === null || editData === void 0 ? void 0 : editData.tag_discipline_ids, onChange: setKnowledge, subId: (_exercise$editData9 = exercise.editData) === null || _exercise$editData9 === void 0 ? void 0 : (_exercise$editData9$e = _exercise$editData9.exercise) === null || _exercise$editData9$e === void 0 ? void 0 : _exercise$editData9$e.sub_discipline_id, knowledgeOptions: knowledgeOptions, onAddKnowledgeFinish: handleAddKnowledgeFinish }) }), /*#__PURE__*/(0,jsx_runtime.jsxs)("div", { style: { marginTop: 10 }, children: [/*#__PURE__*/(0,jsx_runtime.jsx)("span", { style: { marginRight: 10 }, children: "\u4E0D\u5141\u8BB8\u5B66\u751F\u91CD\u590D\u7B54\u9898" }), /*#__PURE__*/(0,jsx_runtime.jsx)(es_switch/* default */.Z, { checked: repeat_answer, onChange: function onChange(e) { setrepeat_answer(e); } })] })] }), /*#__PURE__*/(0,jsx_runtime.jsxs)("aside", { className: "tr", children: [(editKey !== -1 || editData.question_id) && /*#__PURE__*/(0,jsx_runtime.jsx)(es_button/* default */.Z, { type: "default", onClick: function onClick() { cancelAdd(); setIsEdit(false); }, children: "\u53D6\u6D88" }), /*#__PURE__*/(0,jsx_runtime.jsx)(es_button/* default */.Z, { className: "ml20", type: "primary", onClick: function onClick() { onSave(); }, children: "\u4FDD\u5B58" })] })] }); }; var actionArr = [{ name: "删除", icon: "iconfont c-light-black ml30 icon-shanchu current", id: "del" }, // { name: "上移", icon: "iconfont c-green ml30 icon-shangyi_Hover", id: "up" }, // { name: "下移", icon: "iconfont c-green ml30 icon-xiayi_moren", id: "down" }, { name: "(向下插入单选题)", icon: "iconfont c-light-primary ml30 icon-tianjia current", id: "add" }, { name: "编辑", icon: "iconfont c-light-primary ml30 icon-bianjishijuan3x current", id: "edit" }].filter(function (item) { var _exercise$editData10, _exercise$editData10$; if ((exercise === null || exercise === void 0 ? void 0 : (_exercise$editData10 = exercise.editData) === null || _exercise$editData10 === void 0 ? void 0 : (_exercise$editData10$ = _exercise$editData10.exercise) === null || _exercise$editData10$ === void 0 ? void 0 : _exercise$editData10$.exercise_status) === 1) { return item; } else { return item.id !== 'del' && item.id !== 'add'; } }); var actionClick = /*#__PURE__*/function () { var _ref3 = asyncToGenerator_default()( /*#__PURE__*/regeneratorRuntime_default()().mark(function _callee6(item) { return regeneratorRuntime_default()().wrap(function _callee6$(_context6) { while (1) switch (_context6.prev = _context6.next) { case 0: if (!(editKey !== -1)) { _context6.next = 3; break; } message/* default.error */.ZP.error("请先保存或取消当前正在编辑的问题。"); return _context6.abrupt("return"); case 3: _context6.t0 = item.id; _context6.next = _context6.t0 === "del" ? 6 : _context6.t0 === "up" ? 8 : _context6.t0 === "down" ? 8 : _context6.t0 === "edit" ? 12 : _context6.t0 === "add" ? 15 : 17; break; case 6: modal/* default.confirm */.Z.confirm({ centered: true, okText: '确定', cancelText: '取消', title: '确认要删除这个试题吗?', onOk: function onOk() { return asyncToGenerator_default()( /*#__PURE__*/regeneratorRuntime_default()().mark(function _callee5() { return regeneratorRuntime_default()().wrap(function _callee5$(_context5) { while (1) switch (_context5.prev = _context5.next) { case 0: _context5.next = 2; return (0,service_exercise/* exeriseQuestionDelete */.Fl)({ id: editData.question_id }); case 2: dispatch({ type: "exercise/editExercise", payload: objectSpread2_default()({}, params) }); case 3: case "end": return _context5.stop(); } }, _callee5); }))(); } }); return _context6.abrupt("break", 17); case 8: _context6.next = 10; return dispatch({ type: "exercise/exeriseMoveUpDown", payload: { id: editData.question_id, opr: item.id } }); case 10: dispatch({ type: "exercise/editExercise", payload: objectSpread2_default()({}, params) }); return _context6.abrupt("break", 17); case 12: setEditKey(editData.dragKey); setIsEdit(true); return _context6.abrupt("break", 17); case 15: addCallback({ key: editData.key, insert_id: editData === null || editData === void 0 ? void 0 : editData.question_id, question_type: 3 }); return _context6.abrupt("break", 17); case 17: case "end": return _context6.stop(); } }, _callee6); })); return function actionClick(_x) { return _ref3.apply(this, arguments); }; }(); var showList = function showList() { var _editData$standard_an; return /*#__PURE__*/(0,jsx_runtime.jsxs)("aside", { children: [/*#__PURE__*/(0,jsx_runtime.jsx)("div", { className: editormodules.questionType, children: !(editData !== null && editData !== void 0 && editData.isPreview) && /*#__PURE__*/(0,jsx_runtime.jsxs)("div", { children: [/*#__PURE__*/(0,jsx_runtime.jsxs)("span", { className: "font16 c-blue", children: [editData.key, "\u3001\u586B\u7A7A\u9898"] }), "\uFF08", editData.question_score, "\u5206\uFF09"] }) }), editData !== null && editData !== void 0 && editData.isPreview ? /*#__PURE__*/(0,jsx_runtime.jsxs)("div", { style: { display: 'flex' }, children: [/*#__PURE__*/(0,jsx_runtime.jsxs)("span", { style: { flexShrink: 0 }, className: "font18", children: [editData.key, "."] }), /*#__PURE__*/(0,jsx_runtime.jsx)(RenderHtml/* default */.Z, { value: editData.question_title }), /*#__PURE__*/(0,jsx_runtime.jsxs)("span", { style: { flexShrink: 0 }, className: "font16", children: ["\uFF08", editData.question_score, "\u5206\uFF09"] })] }) : /*#__PURE__*/(0,jsx_runtime.jsx)("div", { className: "mt5", children: /*#__PURE__*/(0,jsx_runtime.jsx)(RenderHtml/* default */.Z, { value: editData.question_title }) }), /*#__PURE__*/(0,jsx_runtime.jsx)("div", { className: editormodules.questionChoices, children: editData === null || editData === void 0 ? void 0 : (_editData$standard_an = editData.standard_answer) === null || _editData$standard_an === void 0 ? void 0 : _editData$standard_an.map(function (item, index) { return /*#__PURE__*/(0,jsx_runtime.jsxs)(row/* default */.Z, { align: "middle", children: [/*#__PURE__*/(0,jsx_runtime.jsxs)(col/* default */.Z, { children: ["\u7B54\u6848\uFF08\u586B\u7A7A", item.choice_id, "\uFF09\uFF1A"] }), /*#__PURE__*/(0,jsx_runtime.jsx)(col/* default */.Z, { flex: "1", children: /*#__PURE__*/(0,jsx_runtime.jsx)(row/* default */.Z, { align: "middle", gutter: [1, 1], children: item.answer_text.map(function (val, key) { return /*#__PURE__*/(0,jsx_runtime.jsx)(col/* default */.Z, { span: 24, children: /*#__PURE__*/(0,jsx_runtime.jsx)(input/* default */.Z, { checked: editData.standard_answer.includes(index), disabled: true, value: val }, index) }, key); }) }) })] }, index); }) }), /*#__PURE__*/(0,jsx_runtime.jsx)("div", { className: editormodules.action, children: !editData.hideAction && actionArr.map(function (item, index) { if (item.id === "up" && editData.key === 1) return null; if (item.id === "down" && editData.key === editData.len) return null; return /*#__PURE__*/(0,jsx_runtime.jsx)(tooltip/* default */.Z, { placement: "bottom", title: item.name, children: /*#__PURE__*/(0,jsx_runtime.jsx)("span", { onClick: function onClick() { return actionClick(item); }, className: item.icon }) }, index); }) })] }); }; return /*#__PURE__*/(0,jsx_runtime.jsxs)("section", { className: editormodules.wrap, children: [!isEdit && showList(), isEdit && showEdit()] }); }; /* harmony default export */ var components_CompletionEditor = ((0,_umi_production_exports.connect)(function (_ref4) { var problemset = _ref4.problemset, loading = _ref4.loading, exercise = _ref4.exercise, globalSetting = _ref4.globalSetting; return { problemset: problemset, globalSetting: globalSetting, exercise: exercise, loading: loading.effects }; }, null, null, { forwardRef: true })( /*#__PURE__*/(0,react.forwardRef)(CompletionEditor))); ;// CONCATENATED MODULE: ./src/pages/Classrooms/Lists/Exercise/Edit/components/JudgmentEditor/index.tsx var JudgmentEditor_excluded = ["problemset", "globalSetting", "exercise", "loading", "dispatch", "onRef", "editData", "editKey", "setEditKey", "cancelAdd", "reload", "addCallback", "setIsClaer"]; var JudgmentEditor_tagList = ['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']; var JudgmentEditor = function JudgmentEditor(_ref, ref) { var problemset = _ref.problemset, globalSetting = _ref.globalSetting, exercise = _ref.exercise, loading = _ref.loading, dispatch = _ref.dispatch, _ref$onRef = _ref.onRef, onRef = _ref$onRef === void 0 ? function () {} : _ref$onRef, editData = _ref.editData, editKey = _ref.editKey, _ref$setEditKey = _ref.setEditKey, setEditKey = _ref$setEditKey === void 0 ? function () {} : _ref$setEditKey, _ref$cancelAdd = _ref.cancelAdd, cancelAdd = _ref$cancelAdd === void 0 ? function () {} : _ref$cancelAdd, _ref$reload = _ref.reload, reload = _ref$reload === void 0 ? function () {} : _ref$reload, _ref$addCallback = _ref.addCallback, addCallback = _ref$addCallback === void 0 ? function () {} : _ref$addCallback, _ref$setIsClaer = _ref.setIsClaer, setIsClaer = _ref$setIsClaer === void 0 ? function () {} : _ref$setIsClaer, props = objectWithoutProperties_default()(_ref, JudgmentEditor_excluded); var _useState = (0,react.useState)(), _useState2 = slicedToArray_default()(_useState, 2), activeAnswer = _useState2[0], setActiveAnswer = _useState2[1]; var _useState3 = (0,react.useState)(''), _useState4 = slicedToArray_default()(_useState3, 2), title = _useState4[0], setTitle = _useState4[1]; var _useState5 = (0,react.useState)(false), _useState6 = slicedToArray_default()(_useState5, 2), isEdit = _useState6[0], setIsEdit = _useState6[1]; var _useState7 = (0,react.useState)(), _useState8 = slicedToArray_default()(_useState7, 2), score = _useState8[0], setScore = _useState8[1]; var _useState9 = (0,react.useState)([]), _useState10 = slicedToArray_default()(_useState9, 2), knowledge = _useState10[0], setKnowledge = _useState10[1]; var _useState11 = (0,react.useState)([]), _useState12 = slicedToArray_default()(_useState11, 2), knowledgeOptions = _useState12[0], setKnowledgeOptions = _useState12[1]; var _useState13 = (0,react.useState)(1), _useState14 = slicedToArray_default()(_useState13, 2), difficulty = _useState14[0], setdifficult = _useState14[1]; var _useState15 = (0,react.useState)(false), _useState16 = slicedToArray_default()(_useState15, 2), repeat_answer = _useState16[0], setrepeat_answer = _useState16[1]; var _useState17 = (0,react.useState)(''), _useState18 = slicedToArray_default()(_useState17, 2), analysis = _useState18[0], setAnalysis = _useState18[1]; var freeze = (0,react.useRef)(false); var handleAddKnowledgeFinish = function handleAddKnowledgeFinish(item) { setKnowledgeOptions([].concat(toConsumableArray_default()(knowledgeOptions), [objectSpread2_default()({}, item)])); }; var params = (0,_umi_production_exports.useParams)(); (0,react.useEffect)(function () { if (freeze.current) return; if (!(editData !== null && editData !== void 0 && editData.question_choices)) { setIsEdit(true); setTitle(''); setScore(2); setActiveAnswer(''); return; } setrepeat_answer(!(editData !== null && editData !== void 0 && editData.repeat_answer)); setTitle(editData === null || editData === void 0 ? void 0 : editData.question_title); setScore(editData === null || editData === void 0 ? void 0 : editData.question_score); setdifficult(editData === null || editData === void 0 ? void 0 : editData.difficulty); // const answer = editData?.question_choices.find(item => item.is_answer); setActiveAnswer(editData.standard_answer[0] + ''); setKnowledge(editData.tag_discipline_ids); setAnalysis(editData === null || editData === void 0 ? void 0 : editData.analysis); }, [editData, isEdit]); (0,react.useEffect)(function () { if (isEdit) { init(); } function init() { return _init.apply(this, arguments); } function _init() { _init = asyncToGenerator_default()( /*#__PURE__*/regeneratorRuntime_default()().mark(function _callee() { var _exercise$editData, _exercise$editData$ex; var res; return regeneratorRuntime_default()().wrap(function _callee$(_context) { while (1) switch (_context.prev = _context.next) { case 0: _context.next = 2; return (0,service_exercise/* getTagDiscipline */.YY)({ sub_discipline_id: (_exercise$editData = exercise.editData) === null || _exercise$editData === void 0 ? void 0 : (_exercise$editData$ex = _exercise$editData.exercise) === null || _exercise$editData$ex === void 0 ? void 0 : _exercise$editData$ex.sub_discipline_id }); case 2: res = _context.sent; setKnowledgeOptions(res.tag_disciplines); case 4: case "end": return _context.stop(); } }, _callee); })); return _init.apply(this, arguments); } }, [isEdit]); (0,react.useImperativeHandle)(ref, function () { return { onSave: onSave, isEdit: isEdit }; }); (0,react.useEffect)(function () { var _exercise$tagDiscipli; var data = exercise !== null && exercise !== void 0 && (_exercise$tagDiscipli = exercise.tagDisciplineData) !== null && _exercise$tagDiscipli !== void 0 && _exercise$tagDiscipli.tag_disciplines && Array.isArray(exercise.tagDisciplineData.tag_disciplines) ? exercise.tagDisciplineData.tag_disciplines : []; setKnowledgeOptions(data); }, [exercise.tagDisciplineData]); var repeal = function repeal(res) { if ((res === null || res === void 0 ? void 0 : res.status) === 0) { message/* default.success */.ZP.success("保存成功"); setIsEdit(false); setEditKey(-1); freeze.current = false; reload(); } }; var onSave = /*#__PURE__*/function () { var _ref2 = asyncToGenerator_default()( /*#__PURE__*/regeneratorRuntime_default()().mark(function _callee4() { var choices, res, _exercise$editData4, _exercise$editData4$e, _exercise$editData5, _exercise$editData5$e; return regeneratorRuntime_default()().wrap(function _callee4$(_context4) { while (1) switch (_context4.prev = _context4.next) { case 0: if (title) { _context4.next = 3; break; } message/* default.info */.ZP.info("请您输入题干"); return _context4.abrupt("return", false); case 3: if (activeAnswer) { _context4.next = 6; break; } message/* default.info */.ZP.info("请先点击选择本选择题的正确选项"); return _context4.abrupt("return", false); case 6: // if (knowledge.length < 1) { // message.info("请选择知识点"); // return false; // } choices = [{ choice_text: "正确", is_answer: activeAnswer === "1" ? 1 : 0 }, { choice_text: "错误", is_answer: activeAnswer === "2" ? 2 : 0 }]; freeze.current = true; if (!editData.question_id) { _context4.next = 19; break; } if (!((editData === null || editData === void 0 ? void 0 : editData.is_my) === 1)) { _context4.next = 13; break; } modal/* default.confirm */.Z.confirm({ title: '提示', content: '此题目已存在于试题库,是否将修改后的题目覆盖试题库的原题?', okText: '覆盖原题', cancelText: '不覆盖', keyboard: false, onOk: function () { var _onOk = asyncToGenerator_default()( /*#__PURE__*/regeneratorRuntime_default()().mark(function _callee2() { var _exercise$editData2, _exercise$editData2$e; return regeneratorRuntime_default()().wrap(function _callee2$(_context2) { while (1) switch (_context2.prev = _context2.next) { case 0: _context2.next = 2; return dispatch({ type: "exercise/editExerciseQuestion", payload: { "id": editData.question_id, "question_title": title, "question_type": 2, "question_score": score, "question_choices": choices.map(function (item) { return item.choice_text; }), "standard_answers": choices.filter(function (item) { return item.is_answer; }).map(function (item) { return item.is_answer; }), "tag_discipline_ids": knowledge, "sub_discipline_id": (_exercise$editData2 = exercise.editData) === null || _exercise$editData2 === void 0 ? void 0 : (_exercise$editData2$e = _exercise$editData2.exercise) === null || _exercise$editData2$e === void 0 ? void 0 : _exercise$editData2$e.sub_discipline_id, "difficulty": difficulty, 'is_cover': 1, "repeat_answer": !repeat_answer, analysis: analysis } }); case 2: res = _context2.sent; repeal(res); case 4: case "end": return _context2.stop(); } }, _callee2); })); function onOk() { return _onOk.apply(this, arguments); } return onOk; }(), onCancel: function () { var _onCancel = asyncToGenerator_default()( /*#__PURE__*/regeneratorRuntime_default()().mark(function _callee3() { var _exercise$editData3, _exercise$editData3$e; return regeneratorRuntime_default()().wrap(function _callee3$(_context3) { while (1) switch (_context3.prev = _context3.next) { case 0: _context3.next = 2; return dispatch({ type: "exercise/editExerciseQuestion", payload: { "id": editData.question_id, "question_title": title, "question_type": 2, "question_score": score, "question_choices": choices.map(function (item) { return item.choice_text; }), "standard_answers": choices.filter(function (item) { return item.is_answer; }).map(function (item) { return item.is_answer; }), "tag_discipline_ids": knowledge, "sub_discipline_id": (_exercise$editData3 = exercise.editData) === null || _exercise$editData3 === void 0 ? void 0 : (_exercise$editData3$e = _exercise$editData3.exercise) === null || _exercise$editData3$e === void 0 ? void 0 : _exercise$editData3$e.sub_discipline_id, "difficulty": difficulty, "repeat_answer": !repeat_answer, analysis: analysis } }); case 2: res = _context3.sent; repeal(res); case 4: case "end": return _context3.stop(); } }, _callee3); })); function onCancel() { return _onCancel.apply(this, arguments); } return onCancel; }() }); _context4.next = 17; break; case 13: _context4.next = 15; return dispatch({ type: "exercise/editExerciseQuestion", payload: { "id": editData.question_id, "question_title": title, "question_type": 2, "question_score": score, "question_choices": choices.map(function (item) { return item.choice_text; }), "standard_answers": choices.filter(function (item) { return item.is_answer; }).map(function (item) { return item.is_answer; }), "tag_discipline_ids": knowledge, "sub_discipline_id": (_exercise$editData4 = exercise.editData) === null || _exercise$editData4 === void 0 ? void 0 : (_exercise$editData4$e = _exercise$editData4.exercise) === null || _exercise$editData4$e === void 0 ? void 0 : _exercise$editData4$e.sub_discipline_id, "difficulty": difficulty, "repeat_answer": !repeat_answer, analysis: analysis } }); case 15: res = _context4.sent; repeal(res); case 17: _context4.next = 23; break; case 19: _context4.next = 21; return dispatch({ type: "exercise/addExerciseQuestion", payload: { insert_id: editData === null || editData === void 0 ? void 0 : editData.insert_id, "categoryId": params.categoryId, "question_title": title, "question_type": 2, "question_score": score, "question_choices": choices.map(function (item) { return item.choice_text; }), "standard_answers": choices.filter(function (item) { return item.is_answer; }).map(function (item) { return item.is_answer; }), "tag_discipline_ids": knowledge, "sub_discipline_id": (_exercise$editData5 = exercise.editData) === null || _exercise$editData5 === void 0 ? void 0 : (_exercise$editData5$e = _exercise$editData5.exercise) === null || _exercise$editData5$e === void 0 ? void 0 : _exercise$editData5$e.sub_discipline_id, "difficulty": difficulty, "repeat_answer": !repeat_answer, analysis: analysis } }); case 21: res = _context4.sent; repeal(res); case 23: return _context4.abrupt("return", { name: title, choices: choices }); case 24: case "end": return _context4.stop(); } }, _callee4); })); return function onSave() { return _ref2.apply(this, arguments); }; }(); var actionArr = [{ name: "删除", icon: "iconfont c-light-black ml30 icon-shanchu current", id: "del" }, // { name: "上移", icon: "iconfont c-green ml30 icon-shangyi_Hover", id: "up" }, // { name: "下移", icon: "iconfont c-green ml30 icon-xiayi_moren", id: "down" }, { name: "(向下插入单选题)", icon: "iconfont c-light-primary ml30 icon-tianjia current", id: "add" }, { name: "编辑", icon: "iconfont c-light-primary ml30 icon-bianjishijuan3x current", id: "edit" }].filter(function (item) { var _exercise$editData6, _exercise$editData6$e; if ((exercise === null || exercise === void 0 ? void 0 : (_exercise$editData6 = exercise.editData) === null || _exercise$editData6 === void 0 ? void 0 : (_exercise$editData6$e = _exercise$editData6.exercise) === null || _exercise$editData6$e === void 0 ? void 0 : _exercise$editData6$e.exercise_status) === 1) { return item; } else { return item.id !== 'del' && item.id !== 'add'; } }); var actionClick = /*#__PURE__*/function () { var _ref3 = asyncToGenerator_default()( /*#__PURE__*/regeneratorRuntime_default()().mark(function _callee6(item) { return regeneratorRuntime_default()().wrap(function _callee6$(_context6) { while (1) switch (_context6.prev = _context6.next) { case 0: if (!(editKey !== -1)) { _context6.next = 3; break; } message/* default.error */.ZP.error("请先保存或取消当前正在编辑的问题。"); return _context6.abrupt("return"); case 3: _context6.t0 = item.id; _context6.next = _context6.t0 === "del" ? 6 : _context6.t0 === "up" ? 8 : _context6.t0 === "down" ? 8 : _context6.t0 === "edit" ? 12 : _context6.t0 === "add" ? 15 : 17; break; case 6: modal/* default.confirm */.Z.confirm({ centered: true, okText: '确定', cancelText: '取消', title: '确认要删除这个试题吗?', onOk: function onOk() { return asyncToGenerator_default()( /*#__PURE__*/regeneratorRuntime_default()().mark(function _callee5() { return regeneratorRuntime_default()().wrap(function _callee5$(_context5) { while (1) switch (_context5.prev = _context5.next) { case 0: _context5.next = 2; return (0,service_exercise/* exeriseQuestionDelete */.Fl)({ id: editData.question_id }); case 2: dispatch({ type: "exercise/editExercise", payload: objectSpread2_default()({}, params) }); case 3: case "end": return _context5.stop(); } }, _callee5); }))(); } }); return _context6.abrupt("break", 17); case 8: _context6.next = 10; return dispatch({ type: "exercise/exeriseMoveUpDown", payload: { id: editData.question_id, opr: item.id } }); case 10: dispatch({ type: "exercise/editExercise", payload: objectSpread2_default()({}, params) }); return _context6.abrupt("break", 17); case 12: setEditKey(editData.dragKey); setIsEdit(true); return _context6.abrupt("break", 17); case 15: addCallback({ key: editData.key, insert_id: editData === null || editData === void 0 ? void 0 : editData.question_id, question_type: 2 }); return _context6.abrupt("break", 17); case 17: case "end": return _context6.stop(); } }, _callee6); })); return function actionClick(_x) { return _ref3.apply(this, arguments); }; }(); var showList = function showList() { var _editData$question_ch; return /*#__PURE__*/(0,jsx_runtime.jsxs)("aside", { children: [/*#__PURE__*/(0,jsx_runtime.jsx)("div", { className: editormodules.questionType, children: !(editData !== null && editData !== void 0 && editData.isPreview) && /*#__PURE__*/(0,jsx_runtime.jsxs)("div", { children: [/*#__PURE__*/(0,jsx_runtime.jsxs)("span", { className: "font16 c-blue", children: [editData.key, "\u3001\u5224\u65AD\u9898"] }), "\uFF08", editData.question_score, "\u5206\uFF09"] }) }), editData !== null && editData !== void 0 && editData.isPreview ? /*#__PURE__*/(0,jsx_runtime.jsxs)("div", { style: { display: 'flex' }, children: [/*#__PURE__*/(0,jsx_runtime.jsxs)("span", { style: { flexShrink: 0 }, className: "font18", children: [editData.key, "."] }), /*#__PURE__*/(0,jsx_runtime.jsx)(RenderHtml/* default */.Z, { value: editData.question_title }), /*#__PURE__*/(0,jsx_runtime.jsxs)("span", { style: { flexShrink: 0 }, className: "font16", children: ["\uFF08", editData.question_score, "\u5206\uFF09"] })] }) : /*#__PURE__*/(0,jsx_runtime.jsx)("div", { className: "mt5", children: /*#__PURE__*/(0,jsx_runtime.jsx)(RenderHtml/* default */.Z, { value: editData.question_title }) }), /*#__PURE__*/(0,jsx_runtime.jsx)("div", { className: editormodules.questionChoices, children: editData === null || editData === void 0 ? void 0 : (_editData$question_ch = editData.question_choices) === null || _editData$question_ch === void 0 ? void 0 : _editData$question_ch.map(function (item, index) { return /*#__PURE__*/(0,jsx_runtime.jsxs)(es_radio/* default */.ZP, { checked: editData.standard_answer.includes(index + 1), disabled: true, children: [JudgmentEditor_tagList[index], ". ", /*#__PURE__*/(0,jsx_runtime.jsx)("span", { className: "c-black font14", children: item.choice_text })] }, index); }) }), /*#__PURE__*/(0,jsx_runtime.jsx)("div", { className: editormodules.action, children: !editData.hideAction && actionArr.map(function (item, index) { if (item.id === "up" && editData.key === 1) return null; if (item.id === "down" && editData.key === editData.len) return null; return /*#__PURE__*/(0,jsx_runtime.jsx)(tooltip/* default */.Z, { placement: "bottom", title: item.name, children: /*#__PURE__*/(0,jsx_runtime.jsx)("span", { onClick: function onClick() { return actionClick(item); }, className: item.icon }) }, index); }) })] }); }; var showEdit = function showEdit() { var _exercise$editData7, _exercise$editData7$e; return /*#__PURE__*/(0,jsx_runtime.jsxs)("aside", { children: [/*#__PURE__*/(0,jsx_runtime.jsxs)("div", { children: [/*#__PURE__*/(0,jsx_runtime.jsx)("span", { className: "font16 c-blue", children: "\u5224\u65AD\u9898" }), "\uFF08\u5BA2\u89C2\u9898\uFF0C\u7531\u7CFB\u7EDF\u81EA\u52A8\u8BC4\u5206\uFF0C\u8BF7\u8BBE\u7F6E\u6807\u51C6\u7B54\u6848\uFF09"] }), /*#__PURE__*/(0,jsx_runtime.jsxs)("p", { className: editormodules.titleWrap, children: [/*#__PURE__*/(0,jsx_runtime.jsx)("span", { className: editormodules.required, children: "*" }), /*#__PURE__*/(0,jsx_runtime.jsx)("span", { className: editormodules.title, children: "\u9898\u5E72\uFF1A" })] }), /*#__PURE__*/(0,jsx_runtime.jsx)(markdown_editor/* default */.Z, { id: "single-question-title", watch: true, height: 155, placeholder: "\u8BF7\u60A8\u8F93\u5165\u9898\u5E72", defaultValue: title, onChange: function onChange(value) { return setTitle(value); } }), /*#__PURE__*/(0,jsx_runtime.jsxs)("p", { className: editormodules.titleWrap, children: [/*#__PURE__*/(0,jsx_runtime.jsx)("span", { className: editormodules.required, children: "*" }), /*#__PURE__*/(0,jsx_runtime.jsxs)("span", { className: editormodules.title, children: ["\u7B54\u6848\u9009\u9879\uFF1A", /*#__PURE__*/(0,jsx_runtime.jsx)("span", { className: editormodules.colorGray, children: "\u70B9\u51FB\u9009\u9879\u53EF\u8BBE\u7F6E\u6B63\u786E\u7B54\u6848" })] })] }), /*#__PURE__*/(0,jsx_runtime.jsxs)(es_radio/* default.Group */.ZP.Group, { buttonStyle: "solid", value: activeAnswer, onChange: function onChange(e) { return setActiveAnswer(e.target.value); }, children: [/*#__PURE__*/(0,jsx_runtime.jsx)(es_radio/* default.Button */.ZP.Button, { value: "1", className: "".concat(editormodules.radio, " mr40"), children: "\u6B63\u786E" }), /*#__PURE__*/(0,jsx_runtime.jsx)(es_radio/* default.Button */.ZP.Button, { value: "2", className: editormodules.radio, children: "\u9519\u8BEF" })] }), /*#__PURE__*/(0,jsx_runtime.jsx)("p", { className: "c-orange", children: "\u6E29\u99A8\u63D0\u793A\uFF1A\u70B9\u51FB\u9009\u9879\uFF0C\u53EF\u4EE5\u76F4\u63A5\u8BBE\u7F6E\u6807\u51C6\u7B54\u6848" }), /*#__PURE__*/(0,jsx_runtime.jsx)("p", { className: editormodules.titleWrap, children: /*#__PURE__*/(0,jsx_runtime.jsx)("span", { className: editormodules.title, children: "\u9898\u76EE\u89E3\u6790\uFF1A" }) }), /*#__PURE__*/(0,jsx_runtime.jsx)(markdown_editor/* default */.Z, { id: "single-question-title", watch: true, height: 155, placeholder: "\u8BF7\u60A8\u8F93\u5165\u9898\u76EE\u89E3\u6790", defaultValue: analysis, onChange: function onChange(value) { return setAnalysis(value); } }), /*#__PURE__*/(0,jsx_runtime.jsxs)("p", { className: "", children: ["\u5206\u503C\uFF1A", /*#__PURE__*/(0,jsx_runtime.jsx)(input_number/* default */.Z, { value: score, max: 10000, min: 0, onChange: function onChange(value) { setScore(value); } }), " \u5206", /*#__PURE__*/(0,jsx_runtime.jsxs)("span", { style: { marginLeft: '30px' }, className: editormodules.difficult, children: [/*#__PURE__*/(0,jsx_runtime.jsx)("label", { style: { color: 'red' }, children: "*" }), " \u96BE\u5EA6\uFF1A", /*#__PURE__*/(0,jsx_runtime.jsxs)(es_radio/* default.Group */.ZP.Group, { value: difficulty, onChange: function onChange(e) { setdifficult(e.target.value); }, children: [/*#__PURE__*/(0,jsx_runtime.jsx)(es_radio/* default.Button */.ZP.Button, { value: 1, children: "\u7B80\u5355" }), /*#__PURE__*/(0,jsx_runtime.jsx)(es_radio/* default.Button */.ZP.Button, { value: 2, children: "\u9002\u4E2D" }), /*#__PURE__*/(0,jsx_runtime.jsx)(es_radio/* default.Button */.ZP.Button, { value: 3, children: "\u56F0\u96BE" })] })] })] }), /*#__PURE__*/(0,jsx_runtime.jsxs)("p", { className: editormodules.titleWrap, children: [/*#__PURE__*/(0,jsx_runtime.jsxs)("span", { className: "".concat(editormodules.title), children: ["\u77E5\u8BC6\u70B9\uFF1A", /*#__PURE__*/(0,jsx_runtime.jsx)("span", { className: editormodules.colorGray, children: "\uFF08\u6240\u6709\u81EA\u5EFA\u77E5\u8BC6\u70B9\u4EC5\u672C\u4EBA\u53EF\u89C1\uFF0C\u88ABEduCoder\u5E73\u53F0\u5BA1\u6838\u901A\u8FC7\u4E3A\u5B98\u65B9\u77E5\u8BC6\u70B9\u540E\u6240\u6709\u7528\u6237\u53EF\u89C1\uFF09" })] }), /*#__PURE__*/(0,jsx_runtime.jsx)("div", { className: "mt5", children: /*#__PURE__*/(0,jsx_runtime.jsx)(Knowledge/* Knowledge */.N, { value: knowledge, selectvalues: editData === null || editData === void 0 ? void 0 : editData.tag_discipline_ids, onChange: setKnowledge, subId: (_exercise$editData7 = exercise.editData) === null || _exercise$editData7 === void 0 ? void 0 : (_exercise$editData7$e = _exercise$editData7.exercise) === null || _exercise$editData7$e === void 0 ? void 0 : _exercise$editData7$e.sub_discipline_id, knowledgeOptions: knowledgeOptions, onAddKnowledgeFinish: handleAddKnowledgeFinish }) }), /*#__PURE__*/(0,jsx_runtime.jsxs)("div", { style: { marginTop: 10 }, children: [/*#__PURE__*/(0,jsx_runtime.jsx)("span", { style: { marginRight: 10 }, children: "\u4E0D\u5141\u8BB8\u5B66\u751F\u91CD\u590D\u7B54\u9898" }), /*#__PURE__*/(0,jsx_runtime.jsx)(es_switch/* default */.Z, { checked: repeat_answer, onChange: function onChange(e) { setrepeat_answer(e); } })] })] }), /*#__PURE__*/(0,jsx_runtime.jsxs)("aside", { className: "tr", children: [(editKey !== -1 || editData.question_id) && /*#__PURE__*/(0,jsx_runtime.jsx)(es_button/* default */.Z, { type: "default", onClick: function onClick() { cancelAdd(); setIsEdit(false); }, children: "\u53D6\u6D88" }), /*#__PURE__*/(0,jsx_runtime.jsx)(es_button/* default */.Z, { className: "ml20", type: "primary", onClick: function onClick() { onSave(); }, children: "\u4FDD\u5B58" })] })] }); }; return /*#__PURE__*/(0,jsx_runtime.jsxs)("section", { className: editormodules.wrap, children: [!isEdit && showList(), isEdit && showEdit()] }); }; /* harmony default export */ var components_JudgmentEditor = ((0,_umi_production_exports.connect)(function (_ref4) { var problemset = _ref4.problemset, loading = _ref4.loading, exercise = _ref4.exercise, globalSetting = _ref4.globalSetting; return { problemset: problemset, globalSetting: globalSetting, exercise: exercise, loading: loading.effects }; }, null, null, { forwardRef: true })( /*#__PURE__*/(0,react.forwardRef)(JudgmentEditor))); ;// CONCATENATED MODULE: ./src/pages/Classrooms/Lists/Exercise/Edit/components/MultipleEditor/index.tsx var MultipleEditor_excluded = ["problemset", "globalSetting", "exercise", "loading", "dispatch", "onRef", "editData", "cancelAdd", "editKey", "setEditKey", "setIsClaer", "addCallback", "reload"]; var MultipleEditor_tagList = ['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']; var MultipleEditor = /*#__PURE__*/(0,react.forwardRef)(function (_ref, ref) { var problemset = _ref.problemset, globalSetting = _ref.globalSetting, exercise = _ref.exercise, loading = _ref.loading, dispatch = _ref.dispatch, _ref$onRef = _ref.onRef, onRef = _ref$onRef === void 0 ? function () {} : _ref$onRef, editData = _ref.editData, _ref$cancelAdd = _ref.cancelAdd, cancelAdd = _ref$cancelAdd === void 0 ? function () {} : _ref$cancelAdd, editKey = _ref.editKey, _ref$setEditKey = _ref.setEditKey, setEditKey = _ref$setEditKey === void 0 ? function () {} : _ref$setEditKey, _ref$setIsClaer = _ref.setIsClaer, setIsClaer = _ref$setIsClaer === void 0 ? function () {} : _ref$setIsClaer, _ref$addCallback = _ref.addCallback, addCallback = _ref$addCallback === void 0 ? function (value) {} : _ref$addCallback, _ref$reload = _ref.reload, reload = _ref$reload === void 0 ? function () {} : _ref$reload, props = objectWithoutProperties_default()(_ref, MultipleEditor_excluded); var _useState = (0,react.useState)([]), _useState2 = slicedToArray_default()(_useState, 2), questionChoiceList = _useState2[0], setQuestionChoiceList = _useState2[1]; var _useState3 = (0,react.useState)(), _useState4 = slicedToArray_default()(_useState3, 2), activeEditor = _useState4[0], setActiveEditor = _useState4[1]; var _useState5 = (0,react.useState)([]), _useState6 = slicedToArray_default()(_useState5, 2), activeAnswer = _useState6[0], setActiveAnswer = _useState6[1]; var _useState7 = (0,react.useState)(''), _useState8 = slicedToArray_default()(_useState7, 2), title = _useState8[0], setTitle = _useState8[1]; var _useState9 = (0,react.useState)(), _useState10 = slicedToArray_default()(_useState9, 2), score = _useState10[0], setScore = _useState10[1]; var _useState11 = (0,react.useState)(false), _useState12 = slicedToArray_default()(_useState11, 2), isEdit = _useState12[0], setIsEdit = _useState12[1]; var _useState13 = (0,react.useState)([]), _useState14 = slicedToArray_default()(_useState13, 2), knowledge = _useState14[0], setKnowledge = _useState14[1]; var _useState15 = (0,react.useState)(1), _useState16 = slicedToArray_default()(_useState15, 2), difficulty = _useState16[0], setdifficult = _useState16[1]; var _useState17 = (0,react.useState)(false), _useState18 = slicedToArray_default()(_useState17, 2), repeat_answer = _useState18[0], setrepeat_answer = _useState18[1]; var _useState19 = (0,react.useState)(''), _useState20 = slicedToArray_default()(_useState19, 2), analysis = _useState20[0], setAnalysis = _useState20[1]; var _useState21 = (0,react.useState)([]), _useState22 = slicedToArray_default()(_useState21, 2), knowledgeOptions = _useState22[0], setKnowledgeOptions = _useState22[1]; var freeze = (0,react.useRef)(false); var handleAddKnowledgeFinish = function handleAddKnowledgeFinish(item) { setKnowledgeOptions([].concat(toConsumableArray_default()(knowledgeOptions), [objectSpread2_default()({}, item)])); }; var params = (0,_umi_production_exports.useParams)(); (0,react.useEffect)(function () { setQuestionChoiceList(['', '', '', '']); }, []); (0,react.useEffect)(function () { if (freeze.current) return; if (!(editData !== null && editData !== void 0 && editData.question_choices)) { setIsEdit(true); setTitle(''); setScore(5); setQuestionChoiceList(['', '', '', '']); setActiveAnswer([]); return; } setTitle(editData === null || editData === void 0 ? void 0 : editData.question_title); setScore(editData === null || editData === void 0 ? void 0 : editData.question_score); setrepeat_answer(!(editData !== null && editData !== void 0 && editData.repeat_answer)); setdifficult(editData === null || editData === void 0 ? void 0 : editData.difficulty); setQuestionChoiceList(editData === null || editData === void 0 ? void 0 : editData.question_choices.map(function (item) { return item.choice_text; })); var answerIndexs = []; editData === null || editData === void 0 ? void 0 : editData.standard_answer.map(function (item, index) { answerIndexs.push(item - 1); }); setActiveAnswer(answerIndexs); setKnowledge(editData.tag_discipline_ids); setAnalysis(editData === null || editData === void 0 ? void 0 : editData.analysis); }, [editData, isEdit]); (0,react.useEffect)(function () { if (isEdit) { init(); } function init() { return _init.apply(this, arguments); } function _init() { _init = asyncToGenerator_default()( /*#__PURE__*/regeneratorRuntime_default()().mark(function _callee() { var _exercise$editData, _exercise$editData$ex; var res; return regeneratorRuntime_default()().wrap(function _callee$(_context) { while (1) switch (_context.prev = _context.next) { case 0: _context.next = 2; return (0,service_exercise/* getTagDiscipline */.YY)({ sub_discipline_id: (_exercise$editData = exercise.editData) === null || _exercise$editData === void 0 ? void 0 : (_exercise$editData$ex = _exercise$editData.exercise) === null || _exercise$editData$ex === void 0 ? void 0 : _exercise$editData$ex.sub_discipline_id }); case 2: res = _context.sent; setKnowledgeOptions(res.tag_disciplines); case 4: case "end": return _context.stop(); } }, _callee); })); return _init.apply(this, arguments); } }, [isEdit]); (0,react.useImperativeHandle)(ref, function () { return { onSave: onSave, isEdit: isEdit }; }); (0,react.useEffect)(function () { var _exercise$tagDiscipli; var data = exercise !== null && exercise !== void 0 && (_exercise$tagDiscipli = exercise.tagDisciplineData) !== null && _exercise$tagDiscipli !== void 0 && _exercise$tagDiscipli.tag_disciplines && Array.isArray(exercise.tagDisciplineData.tag_disciplines) ? exercise.tagDisciplineData.tag_disciplines : []; setKnowledgeOptions(data); }, [exercise.tagDisciplineData]); var repeal = function repeal(res) { if ((res === null || res === void 0 ? void 0 : res.status) === 0) { message/* default.success */.ZP.success("保存成功"); setIsEdit(false); setEditKey(-1); freeze.current = false; reload(); } }; var onSave = /*#__PURE__*/function () { var _ref2 = asyncToGenerator_default()( /*#__PURE__*/regeneratorRuntime_default()().mark(function _callee4() { var findNotAnswerIndex, choices, res, _exercise$editData4, _exercise$editData4$e, _exercise$editData5, _exercise$editData5$e; return regeneratorRuntime_default()().wrap(function _callee4$(_context4) { while (1) switch (_context4.prev = _context4.next) { case 0: if (title) { _context4.next = 3; break; } message/* default.info */.ZP.info('请您输入题目'); return _context4.abrupt("return", false); case 3: findNotAnswerIndex = questionChoiceList.findIndex(function (item) { return !item; }); if (!(findNotAnswerIndex > -1)) { _context4.next = 7; break; } message/* default.info */.ZP.info("\u8BF7\u5148\u8F93\u5165 ".concat(MultipleEditor_tagList[findNotAnswerIndex], " \u9009\u9879\u7684\u5185\u5BB9")); return _context4.abrupt("return", false); case 7: if (activeAnswer.length) { _context4.next = 10; break; } message/* default.info */.ZP.info('请设置本题的正确答案,点击选项A/B...即可完成设置'); return _context4.abrupt("return", false); case 10: if (!(activeAnswer.length < 1)) { _context4.next = 13; break; } message/* default.info */.ZP.info('请选择答案'); return _context4.abrupt("return", false); case 13: // if (knowledge.length < 1) { // message.info("请选择知识点"); // return false; // } choices = questionChoiceList.map(function (item, index) { return { choice_text: item, is_answer: activeAnswer.includes(index) ? index + 1 : 0 }; }); freeze.current = true; if (!editData.question_id) { _context4.next = 26; break; } if (!((editData === null || editData === void 0 ? void 0 : editData.is_my) === 1)) { _context4.next = 20; break; } modal/* default.confirm */.Z.confirm({ title: '提示', content: '此题目已存在于试题库,是否将修改后的题目覆盖试题库的原题?', okText: '覆盖原题', cancelText: '不覆盖', keyboard: false, onOk: function () { var _onOk = asyncToGenerator_default()( /*#__PURE__*/regeneratorRuntime_default()().mark(function _callee2() { var _exercise$editData2, _exercise$editData2$e; return regeneratorRuntime_default()().wrap(function _callee2$(_context2) { while (1) switch (_context2.prev = _context2.next) { case 0: _context2.next = 2; return dispatch({ type: 'exercise/editExerciseQuestion', payload: { id: editData.question_id, question_title: title, question_type: 1, question_score: score, question_choices: choices.map(function (item) { return item.choice_text; }), standard_answers: choices.filter(function (item) { return item.is_answer; }).map(function (item) { return item.is_answer; }), tag_discipline_ids: knowledge, sub_discipline_id: (_exercise$editData2 = exercise.editData) === null || _exercise$editData2 === void 0 ? void 0 : (_exercise$editData2$e = _exercise$editData2.exercise) === null || _exercise$editData2$e === void 0 ? void 0 : _exercise$editData2$e.sub_discipline_id, difficulty: difficulty, is_cover: 1, repeat_answer: !repeat_answer, analysis: analysis } }); case 2: res = _context2.sent; repeal(res); case 4: case "end": return _context2.stop(); } }, _callee2); })); function onOk() { return _onOk.apply(this, arguments); } return onOk; }(), onCancel: function () { var _onCancel = asyncToGenerator_default()( /*#__PURE__*/regeneratorRuntime_default()().mark(function _callee3() { var _exercise$editData3, _exercise$editData3$e; return regeneratorRuntime_default()().wrap(function _callee3$(_context3) { while (1) switch (_context3.prev = _context3.next) { case 0: _context3.next = 2; return dispatch({ type: 'exercise/editExerciseQuestion', payload: { id: editData.question_id, question_title: title, question_type: 1, question_score: score, question_choices: choices.map(function (item) { return item.choice_text; }), standard_answers: choices.filter(function (item) { return item.is_answer; }).map(function (item) { return item.is_answer; }), tag_discipline_ids: knowledge, sub_discipline_id: (_exercise$editData3 = exercise.editData) === null || _exercise$editData3 === void 0 ? void 0 : (_exercise$editData3$e = _exercise$editData3.exercise) === null || _exercise$editData3$e === void 0 ? void 0 : _exercise$editData3$e.sub_discipline_id, difficulty: difficulty, repeat_answer: !repeat_answer, analysis: analysis } }); case 2: res = _context3.sent; repeal(res); case 4: case "end": return _context3.stop(); } }, _callee3); })); function onCancel() { return _onCancel.apply(this, arguments); } return onCancel; }() }); _context4.next = 24; break; case 20: _context4.next = 22; return dispatch({ type: 'exercise/editExerciseQuestion', payload: { id: editData.question_id, question_title: title, question_type: 1, question_score: score, question_choices: choices.map(function (item) { return item.choice_text; }), standard_answers: choices.filter(function (item) { return item.is_answer; }).map(function (item) { return item.is_answer; }), tag_discipline_ids: knowledge, sub_discipline_id: (_exercise$editData4 = exercise.editData) === null || _exercise$editData4 === void 0 ? void 0 : (_exercise$editData4$e = _exercise$editData4.exercise) === null || _exercise$editData4$e === void 0 ? void 0 : _exercise$editData4$e.sub_discipline_id, difficulty: difficulty, repeat_answer: !repeat_answer, analysis: analysis } }); case 22: res = _context4.sent; repeal(res); case 24: _context4.next = 30; break; case 26: _context4.next = 28; return dispatch({ type: 'exercise/addExerciseQuestion', payload: { insert_id: editData === null || editData === void 0 ? void 0 : editData.insert_id, categoryId: params.categoryId, question_title: title, question_type: 1, question_score: score, question_choices: choices.map(function (item) { return item.choice_text; }), standard_answers: choices.filter(function (item) { return item.is_answer; }).map(function (item) { return item.is_answer; }), tag_discipline_ids: knowledge, sub_discipline_id: (_exercise$editData5 = exercise.editData) === null || _exercise$editData5 === void 0 ? void 0 : (_exercise$editData5$e = _exercise$editData5.exercise) === null || _exercise$editData5$e === void 0 ? void 0 : _exercise$editData5$e.sub_discipline_id, difficulty: difficulty, repeat_answer: !repeat_answer, analysis: analysis } }); case 28: res = _context4.sent; repeal(res); case 30: case "end": return _context4.stop(); } }, _callee4); })); return function onSave() { return _ref2.apply(this, arguments); }; }(); var actionArr = [{ name: '删除', icon: 'iconfont c-light-black ml30 icon-shanchu current', id: 'del' }, // { name: "上移", icon: "iconfont c-green ml30 icon-shangyi_Hover", id: "up" }, // { name: "下移", icon: "iconfont c-green ml30 icon-xiayi_moren", id: "down" }, { name: '(向下插入单选题)', icon: 'iconfont c-light-primary ml30 icon-tianjia current', id: 'add' }, { name: '编辑', icon: 'iconfont c-light-primary ml30 icon-bianjishijuan3x current', id: 'edit' }].filter(function (item) { var _exercise$editData6, _exercise$editData6$e; if ((exercise === null || exercise === void 0 ? void 0 : (_exercise$editData6 = exercise.editData) === null || _exercise$editData6 === void 0 ? void 0 : (_exercise$editData6$e = _exercise$editData6.exercise) === null || _exercise$editData6$e === void 0 ? void 0 : _exercise$editData6$e.exercise_status) === 1) { return item; } else { return item.id !== 'del' && item.id !== 'add'; } }); var actionClick = /*#__PURE__*/function () { var _ref3 = asyncToGenerator_default()( /*#__PURE__*/regeneratorRuntime_default()().mark(function _callee6(item) { return regeneratorRuntime_default()().wrap(function _callee6$(_context6) { while (1) switch (_context6.prev = _context6.next) { case 0: if (!(editKey !== -1)) { _context6.next = 3; break; } message/* default.error */.ZP.error('请先保存或取消当前正在编辑的问题。'); return _context6.abrupt("return"); case 3: _context6.t0 = item.id; _context6.next = _context6.t0 === 'del' ? 6 : _context6.t0 === 'up' ? 8 : _context6.t0 === 'down' ? 8 : _context6.t0 === 'edit' ? 12 : _context6.t0 === 'add' ? 15 : 17; break; case 6: modal/* default.confirm */.Z.confirm({ centered: true, okText: '确定', cancelText: '取消', title: '确认要删除这个试题吗?', onOk: function onOk() { return asyncToGenerator_default()( /*#__PURE__*/regeneratorRuntime_default()().mark(function _callee5() { return regeneratorRuntime_default()().wrap(function _callee5$(_context5) { while (1) switch (_context5.prev = _context5.next) { case 0: _context5.next = 2; return (0,service_exercise/* exeriseQuestionDelete */.Fl)({ id: editData.question_id }); case 2: dispatch({ type: 'exercise/editExercise', payload: objectSpread2_default()({}, params) }); case 3: case "end": return _context5.stop(); } }, _callee5); }))(); } }); return _context6.abrupt("break", 17); case 8: _context6.next = 10; return dispatch({ type: 'exercise/exeriseMoveUpDown', payload: { id: editData.question_id, opr: item.id } }); case 10: dispatch({ type: 'exercise/editExercise', payload: objectSpread2_default()({}, params) }); return _context6.abrupt("break", 17); case 12: setEditKey(editData.dragKey); setIsEdit(true); return _context6.abrupt("break", 17); case 15: addCallback({ key: editData.key, insert_id: editData === null || editData === void 0 ? void 0 : editData.question_id, question_type: 1 }); return _context6.abrupt("break", 17); case 17: case "end": return _context6.stop(); } }, _callee6); })); return function actionClick(_x) { return _ref3.apply(this, arguments); }; }(); var showList = function showList() { var _editData$question_ch; return /*#__PURE__*/(0,jsx_runtime.jsxs)("aside", { children: [/*#__PURE__*/(0,jsx_runtime.jsx)("div", { className: editormodules.questionType, children: !(editData !== null && editData !== void 0 && editData.isPreview) && /*#__PURE__*/(0,jsx_runtime.jsxs)("div", { children: [/*#__PURE__*/(0,jsx_runtime.jsxs)("span", { className: "font16 c-blue", children: [editData.key, "\u3001\u591A\u9009\u9898"] }), "\uFF08", editData.question_score, "\u5206\uFF09"] }) }), editData !== null && editData !== void 0 && editData.isPreview ? /*#__PURE__*/(0,jsx_runtime.jsxs)("div", { style: { display: 'flex' }, children: [/*#__PURE__*/(0,jsx_runtime.jsxs)("span", { style: { flexShrink: 0 }, className: "font18", children: [editData.key, "."] }), /*#__PURE__*/(0,jsx_runtime.jsx)(RenderHtml/* default */.Z, { value: editData.question_title }), /*#__PURE__*/(0,jsx_runtime.jsxs)("span", { style: { flexShrink: 0 }, className: "font16", children: ["\uFF08", editData.question_score, "\u5206\uFF09"] })] }) : /*#__PURE__*/(0,jsx_runtime.jsx)("div", { className: "mt5", children: /*#__PURE__*/(0,jsx_runtime.jsx)(RenderHtml/* default */.Z, { value: editData.question_title }) }), /*#__PURE__*/(0,jsx_runtime.jsx)("div", { className: editormodules.questionChoices, children: editData === null || editData === void 0 ? void 0 : (_editData$question_ch = editData.question_choices) === null || _editData$question_ch === void 0 ? void 0 : _editData$question_ch.map(function (item, index) { return /*#__PURE__*/(0,jsx_runtime.jsxs)(row/* default */.Z, { children: [/*#__PURE__*/(0,jsx_runtime.jsx)(col/* default */.Z, { children: /*#__PURE__*/(0,jsx_runtime.jsxs)(es_checkbox/* default */.Z, { checked: editData.standard_answer.includes(index + 1), disabled: true, children: [MultipleEditor_tagList[index], "."] }, index) }), /*#__PURE__*/(0,jsx_runtime.jsx)(col/* default */.Z, { flex: "1", children: /*#__PURE__*/(0,jsx_runtime.jsx)("span", { className: "c-black font14", children: /*#__PURE__*/(0,jsx_runtime.jsx)(RenderHtml/* default */.Z, { value: item.choice_text }) }) })] }, index); }) }), /*#__PURE__*/(0,jsx_runtime.jsx)("div", { className: editormodules.action, children: !editData.hideAction && actionArr.map(function (item, index) { if (item.id === 'up' && editData.key === 1) return null; if (item.id === 'down' && editData.key === editData.len) return null; return /*#__PURE__*/(0,jsx_runtime.jsx)(tooltip/* default */.Z, { placement: "bottom", title: item.name, children: /*#__PURE__*/(0,jsx_runtime.jsx)("span", { onClick: function onClick() { return actionClick(item); }, className: item.icon }) }, index); }) })] }); }; var showEdit = function showEdit() { var _exercise$editData8, _exercise$editData8$e; return /*#__PURE__*/(0,jsx_runtime.jsxs)("aside", { children: [/*#__PURE__*/(0,jsx_runtime.jsx)("div", { className: editormodules.questionType, children: /*#__PURE__*/(0,jsx_runtime.jsxs)("div", { children: [/*#__PURE__*/(0,jsx_runtime.jsx)("span", { className: "font16 c-blue", children: "\u9009\u62E9\u9898" }), "\uFF08\u5BA2\u89C2\u9898\uFF0C\u7531\u7CFB\u7EDF\u81EA\u52A8\u8BC4\u5206\uFF0C\u8BF7\u8BBE\u7F6E\u6807\u51C6\u7B54\u6848\uFF09"] }) }), /*#__PURE__*/(0,jsx_runtime.jsxs)("p", { className: editormodules.titleWrap, children: [/*#__PURE__*/(0,jsx_runtime.jsx)("span", { className: editormodules.required, children: "*" }), /*#__PURE__*/(0,jsx_runtime.jsx)("span", { className: editormodules.title, children: "\u9898\u5E72\uFF1A" })] }), /*#__PURE__*/(0,jsx_runtime.jsx)(markdown_editor/* default */.Z, { id: "single-question-title", watch: true, height: 155, placeholder: "\u8BF7\u60A8\u8F93\u5165\u9898\u5E72", defaultValue: title, onChange: function onChange(value) { return setTitle(value); } }), /*#__PURE__*/(0,jsx_runtime.jsxs)("p", { className: editormodules.titleWrap, children: [/*#__PURE__*/(0,jsx_runtime.jsx)("span", { className: editormodules.required, children: "*" }), /*#__PURE__*/(0,jsx_runtime.jsxs)("span", { className: editormodules.title, children: ["\u7B54\u6848\u9009\u9879\uFF1A", /*#__PURE__*/(0,jsx_runtime.jsx)("span", { className: editormodules.colorGray, children: "\u70B9\u51FB\u9009\u9879\u53EF\u8BBE\u7F6E\u6B63\u786E\u7B54\u6848" })] })] }), questionChoiceList.map(function (item, index) { var _exercise$editData7, _exercise$editData7$e; return /*#__PURE__*/(0,jsx_runtime.jsxs)("div", { className: editormodules.choiceWrap, children: [/*#__PURE__*/(0,jsx_runtime.jsx)(tooltip/* default */.Z, { title: "\u70B9\u51FB\u8BBE\u7F6E\u4E3A\u6807\u51C6\u7B54\u6848", placement: "left", children: /*#__PURE__*/(0,jsx_runtime.jsx)("div", { className: "".concat(editormodules.answer, " ").concat(activeAnswer.includes(index) ? editormodules.activeAnswer : ''), onClick: function onClick() { if (activeAnswer.includes(index)) { setActiveAnswer(activeAnswer.filter(function (item) { return item !== index; })); } else { setActiveAnswer([].concat(toConsumableArray_default()(activeAnswer), [index])); } }, children: MultipleEditor_tagList[index] }) }), /*#__PURE__*/(0,jsx_runtime.jsx)("div", { className: editormodules.editorWrap, children: activeEditor === index ? /*#__PURE__*/(0,jsx_runtime.jsx)(markdown_editor/* default */.Z, { id: "single-question-option-".concat(index), watch: true, isFocus: true, height: 155, placeholder: "\u8BF7\u60A8\u8F93\u5165\u9009\u9879", defaultValue: item, onChange: function onChange(value) { questionChoiceList[index] = value; setQuestionChoiceList(questionChoiceList); } }) : /*#__PURE__*/(0,jsx_runtime.jsx)("div", { className: editormodules.htmlWrap, onClick: function onClick() { return setActiveEditor(index); }, children: /*#__PURE__*/(0,jsx_runtime.jsx)(RenderHtml/* default */.Z, { value: item }) }) }), ((_exercise$editData7 = exercise.editData) === null || _exercise$editData7 === void 0 ? void 0 : (_exercise$editData7$e = _exercise$editData7.exercise) === null || _exercise$editData7$e === void 0 ? void 0 : _exercise$editData7$e.exercise_status) === 1 && /*#__PURE__*/(0,jsx_runtime.jsxs)(jsx_runtime.Fragment, { children: [index > 1 && /*#__PURE__*/(0,jsx_runtime.jsx)(tooltip/* default */.Z, { title: "\u5220\u9664", children: /*#__PURE__*/(0,jsx_runtime.jsx)("i", { className: "".concat(editormodules.deleteIcon, " iconfont icon-htmal5icon19"), onClick: function onClick() { return setQuestionChoiceList(questionChoiceList.filter(function (_, key) { return key !== index; })); } }) }), index < 7 && index === questionChoiceList.length - 1 && /*#__PURE__*/(0,jsx_runtime.jsx)(tooltip/* default */.Z, { title: "\u65B0\u589E\u53C2\u8003\u7B54\u6848", children: /*#__PURE__*/(0,jsx_runtime.jsx)("i", { className: "".concat(editormodules.addIcon, " iconfont icon-roundaddfill ml6"), onClick: function onClick() { return setQuestionChoiceList([].concat(toConsumableArray_default()(questionChoiceList), [''])); } }) })] })] }, index); }), /*#__PURE__*/(0,jsx_runtime.jsx)("p", { className: "c-orange", children: "\u6E29\u99A8\u63D0\u793A\uFF1A\u70B9\u51FB\u9009\u9879\u8F93\u5165\u6846\u53EF\u8BBE\u7F6E\u7B54\u6848\uFF1B\u9009\u4E2D\u7684\u9009\u9879\u5373\u4E3A\u6B63\u786E\u7B54\u6848\uFF0C\u9009\u62E9\u591A\u4E2A\u7B54\u6848\u5373\u4E3A\u591A\u9009\u9898" }), /*#__PURE__*/(0,jsx_runtime.jsx)("p", { className: editormodules.titleWrap, children: /*#__PURE__*/(0,jsx_runtime.jsx)("span", { className: editormodules.title, children: "\u9898\u76EE\u89E3\u6790\uFF1A" }) }), /*#__PURE__*/(0,jsx_runtime.jsx)(markdown_editor/* default */.Z, { id: "single-question-title", watch: true, height: 155, placeholder: "\u8BF7\u60A8\u8F93\u5165\u9898\u76EE\u89E3\u6790", defaultValue: analysis, onChange: function onChange(value) { return setAnalysis(value); } }), /*#__PURE__*/(0,jsx_runtime.jsxs)("p", { className: "", children: ["\u5206\u503C\uFF1A", /*#__PURE__*/(0,jsx_runtime.jsx)(input_number/* default */.Z, { value: score, max: 10000, min: 0, onChange: function onChange(value) { setScore(value); } }), ' ', "\u5206", /*#__PURE__*/(0,jsx_runtime.jsxs)("span", { style: { marginLeft: '30px' }, className: editormodules.difficult, children: [/*#__PURE__*/(0,jsx_runtime.jsx)("label", { style: { color: 'red' }, children: "*" }), " \u96BE\u5EA6\uFF1A", /*#__PURE__*/(0,jsx_runtime.jsxs)(es_radio/* default.Group */.ZP.Group, { value: difficulty, onChange: function onChange(e) { setdifficult(e.target.value); }, children: [/*#__PURE__*/(0,jsx_runtime.jsx)(es_radio/* default.Button */.ZP.Button, { value: 1, children: "\u7B80\u5355" }), /*#__PURE__*/(0,jsx_runtime.jsx)(es_radio/* default.Button */.ZP.Button, { value: 2, children: "\u9002\u4E2D" }), /*#__PURE__*/(0,jsx_runtime.jsx)(es_radio/* default.Button */.ZP.Button, { value: 3, children: "\u56F0\u96BE" })] })] })] }), /*#__PURE__*/(0,jsx_runtime.jsxs)("p", { className: editormodules.titleWrap, children: [/*#__PURE__*/(0,jsx_runtime.jsxs)("span", { className: "".concat(editormodules.title), children: ["\u77E5\u8BC6\u70B9\uFF1A", /*#__PURE__*/(0,jsx_runtime.jsx)("span", { className: editormodules.colorGray, children: "\uFF08\u6240\u6709\u81EA\u5EFA\u77E5\u8BC6\u70B9\u4EC5\u672C\u4EBA\u53EF\u89C1\uFF0C\u88ABEduCoder\u5E73\u53F0\u5BA1\u6838\u901A\u8FC7\u4E3A\u5B98\u65B9\u77E5\u8BC6\u70B9\u540E\u6240\u6709\u7528\u6237\u53EF\u89C1\uFF09" })] }), /*#__PURE__*/(0,jsx_runtime.jsx)("div", { className: "mt5", children: /*#__PURE__*/(0,jsx_runtime.jsx)(Knowledge/* Knowledge */.N, { value: knowledge, selectvalues: editData === null || editData === void 0 ? void 0 : editData.tag_discipline_ids, onChange: setKnowledge, subId: (_exercise$editData8 = exercise.editData) === null || _exercise$editData8 === void 0 ? void 0 : (_exercise$editData8$e = _exercise$editData8.exercise) === null || _exercise$editData8$e === void 0 ? void 0 : _exercise$editData8$e.sub_discipline_id, knowledgeOptions: knowledgeOptions, onAddKnowledgeFinish: handleAddKnowledgeFinish }) }), /*#__PURE__*/(0,jsx_runtime.jsxs)("div", { style: { marginTop: 10 }, children: [/*#__PURE__*/(0,jsx_runtime.jsx)("span", { style: { marginRight: 10 }, children: "\u4E0D\u5141\u8BB8\u5B66\u751F\u91CD\u590D\u7B54\u9898" }), /*#__PURE__*/(0,jsx_runtime.jsx)(es_switch/* default */.Z, { checked: repeat_answer, onChange: function onChange(e) { setrepeat_answer(e); } })] })] }), /*#__PURE__*/(0,jsx_runtime.jsxs)("aside", { className: "tr", children: [(editKey !== -1 || editData.question_id) && /*#__PURE__*/(0,jsx_runtime.jsx)(es_button/* default */.Z, { type: "default", onClick: function onClick() { cancelAdd(); setIsEdit(false); }, children: "\u53D6\u6D88" }), /*#__PURE__*/(0,jsx_runtime.jsx)(es_button/* default */.Z, { className: "ml20", type: "primary", onClick: function onClick() { onSave(); }, children: "\u4FDD\u5B58" })] })] }); }; return /*#__PURE__*/(0,jsx_runtime.jsxs)("section", { className: editormodules.wrap, children: [!isEdit && showList(), isEdit && showEdit()] }); }); /* harmony default export */ var components_MultipleEditor = ((0,_umi_production_exports.connect)(function (_ref4) { var problemset = _ref4.problemset, loading = _ref4.loading, exercise = _ref4.exercise, globalSetting = _ref4.globalSetting; return { problemset: problemset, globalSetting: globalSetting, exercise: exercise, loading: loading.effects }; }, null, null, { forwardRef: true })(MultipleEditor)); ;// CONCATENATED MODULE: ./src/pages/Classrooms/Lists/Exercise/Edit/components/ShixunEditor/index.tsx var ShixunEditor_excluded = ["problemset", "globalSetting", "exercise", "loading", "dispatch", "editData", "cancelAdd", "editKey", "setEditKey", "addCallback", "reload", "setIsClaer"]; var ShixunEditor_tagList = (/* unused pure expression or super */ null && (['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'])); var ShixunEditor = function ShixunEditor(_ref, ref) { var problemset = _ref.problemset, globalSetting = _ref.globalSetting, exercise = _ref.exercise, loading = _ref.loading, dispatch = _ref.dispatch, editData = _ref.editData, _ref$cancelAdd = _ref.cancelAdd, cancelAdd = _ref$cancelAdd === void 0 ? function () {} : _ref$cancelAdd, editKey = _ref.editKey, _ref$setEditKey = _ref.setEditKey, setEditKey = _ref$setEditKey === void 0 ? function () {} : _ref$setEditKey, _ref$addCallback = _ref.addCallback, addCallback = _ref$addCallback === void 0 ? function () {} : _ref$addCallback, _ref$reload = _ref.reload, reload = _ref$reload === void 0 ? function () {} : _ref$reload, _ref$setIsClaer = _ref.setIsClaer, setIsClaer = _ref$setIsClaer === void 0 ? function () {} : _ref$setIsClaer, props = objectWithoutProperties_default()(_ref, ShixunEditor_excluded); var _useState = (0,react.useState)(''), _useState2 = slicedToArray_default()(_useState, 2), name = _useState2[0], setName = _useState2[1]; var _useState3 = (0,react.useState)(''), _useState4 = slicedToArray_default()(_useState3, 2), title = _useState4[0], setTitle = _useState4[1]; var _useState5 = (0,react.useState)(''), _useState6 = slicedToArray_default()(_useState5, 2), analysis = _useState6[0], setAnalysis = _useState6[1]; var _useState7 = (0,react.useState)([]), _useState8 = slicedToArray_default()(_useState7, 2), answerList = _useState8[0], setAnswerList = _useState8[1]; var _useState9 = (0,react.useState)(''), _useState10 = slicedToArray_default()(_useState9, 2), activeOptionErrorIndex = _useState10[0], setActiveOptionErrorIndex = _useState10[1]; var _useState11 = (0,react.useState)(), _useState12 = slicedToArray_default()(_useState11, 2), checked = _useState12[0], setChecked = _useState12[1]; var _useState13 = (0,react.useState)(false), _useState14 = slicedToArray_default()(_useState13, 2), firstSetAnswerFlag = _useState14[0], setFirstSetAnswerFlag = _useState14[1]; var _useState15 = (0,react.useState)([]), _useState16 = slicedToArray_default()(_useState15, 2), score = _useState16[0], setScore = _useState16[1]; var _useState17 = (0,react.useState)(false), _useState18 = slicedToArray_default()(_useState17, 2), isEdit = _useState18[0], setIsEdit = _useState18[1]; var _useState19 = (0,react.useState)(false), _useState20 = slicedToArray_default()(_useState19, 2), btnLoading = _useState20[0], setBtnLoading = _useState20[1]; var params = (0,_umi_production_exports.useParams)(); var freeze = (0,react.useRef)(false); (0,react.useEffect)(function () { var _editData$shixun; if (freeze.current) return; if (editData.edit) { setIsEdit(true); setTitle(''); setName(''); setScore([]); } setName(editData.shixun_name); setTitle(editData.question_title); var arr = []; (_editData$shixun = editData.shixun) === null || _editData$shixun === void 0 ? void 0 : _editData$shixun.map(function (item) { arr.push(item.challenge_score); }); setScore(arr); }, [editData]); (0,react.useEffect)(function () { setFirstSetAnswerFlag(false); }, [isEdit]); (0,react.useImperativeHandle)(ref, function () { return { onSave: onSave, isEdit: isEdit }; }); var repeal = function repeal(res) { if ((res === null || res === void 0 ? void 0 : res.status) === 0) { message/* default.success */.ZP.success("保存成功"); setIsEdit(false); setEditKey(-1); freeze.current = false; reload(); } }; var onSave = /*#__PURE__*/function () { var _ref2 = asyncToGenerator_default()( /*#__PURE__*/regeneratorRuntime_default()().mark(function _callee() { var answerArray, isEmpty, res; return regeneratorRuntime_default()().wrap(function _callee$(_context) { while (1) switch (_context.prev = _context.next) { case 0: answerArray = []; isEmpty = false; if (!isEmpty) { _context.next = 4; break; } return _context.abrupt("return", false); case 4: freeze.current = true; setBtnLoading(true); if (!editData.question_id) { _context.next = 12; break; } _context.next = 9; return dispatch({ type: "exercise/editExerciseQuestion", payload: { "id": editData.question_id, "question_title": title, "shixun_name": name, "shixun_id": editData.shixun_id, "question_type": 5, "question_scores": score } }); case 9: res = _context.sent; _context.next = 15; break; case 12: _context.next = 14; return dispatch({ type: "exercise/addExerciseQuestion", payload: { insert_id: editData === null || editData === void 0 ? void 0 : editData.insert_id, "categoryId": params.categoryId, "question_title": title, "shixun_name": name, "shixun_id": editData.shixun_id, "question_type": 5, "question_scores": score, "is_copy": editData.is_copy } }); case 14: res = _context.sent; case 15: repeal(res); setBtnLoading(false); return _context.abrupt("return", { name: title, analysis: analysis, standard_answers: answerArray, is_ordered: checked }); case 18: case "end": return _context.stop(); } }, _callee); })); return function onSave() { return _ref2.apply(this, arguments); }; }(); var showEdit = function showEdit() { var _editData$shixun2; return /*#__PURE__*/(0,jsx_runtime.jsxs)("aside", { children: [/*#__PURE__*/(0,jsx_runtime.jsx)("div", { className: editormodules.questionType, children: /*#__PURE__*/(0,jsx_runtime.jsxs)("div", { children: [/*#__PURE__*/(0,jsx_runtime.jsx)("span", { className: "font16 c-blue", children: "\u5B9E\u8BAD\u9898" }), "\uFF08\u5BA2\u89C2\u9898\uFF0C\u7531\u7CFB\u7EDF\u81EA\u52A8\u8BC4\u5206\uFF0C\u5141\u8BB8\u624B\u52A8\u8C03\u5206\uFF09"] }) }), /*#__PURE__*/(0,jsx_runtime.jsx)("div", { className: "mt10", children: /*#__PURE__*/(0,jsx_runtime.jsx)(input/* default */.Z, { defaultValue: name, onChange: function onChange(e) { ; setName(e.target.value); } }) }), /*#__PURE__*/(0,jsx_runtime.jsx)("div", { className: "mt10", children: /*#__PURE__*/(0,jsx_runtime.jsx)(markdown_editor/* default */.Z, { id: "single-question-option-0", height: 155, placeholder: "\u8BF7\u8F93\u5165\u5B9E\u8BAD\u9898\u5B8C\u6210\u8981\u6C42", defaultValue: title, onChange: function onChange(value) { setTitle(value); } }) }), /*#__PURE__*/(0,jsx_runtime.jsx)("div", { className: "mt20", children: (_editData$shixun2 = editData.shixun) === null || _editData$shixun2 === void 0 ? void 0 : _editData$shixun2.map(function (item, index) { return /*#__PURE__*/(0,jsx_runtime.jsxs)(row/* default */.Z, { gutter: [20, 20], children: [/*#__PURE__*/(0,jsx_runtime.jsxs)(col/* default */.Z, { flex: "1", children: [index + 1, ".", item.challenge_name] }), /*#__PURE__*/(0,jsx_runtime.jsxs)(col/* default */.Z, { children: [/*#__PURE__*/(0,jsx_runtime.jsx)(input_number/* default */.Z, { defaultValue: score[index], onChange: function onChange(value) { score[index] = value; setScore(score); console.log("srore:L", score[index]); } }), " \u5206"] })] }); }) }), /*#__PURE__*/(0,jsx_runtime.jsx)("div", { className: "mt20", children: answerList.length > 1 && /*#__PURE__*/(0,jsx_runtime.jsxs)("span", { children: [/*#__PURE__*/(0,jsx_runtime.jsx)(es_checkbox/* default */.Z, { checked: checked, onChange: function onChange(e) { return setChecked(e.target.checked); }, className: "".concat(editormodules.color333, " font14"), children: "\u591A\u4E2A\u586B\u7A7A\u7684\u7B54\u6848\u6709\u987A\u5E8F\u8981\u6C42" }), /*#__PURE__*/(0,jsx_runtime.jsx)("span", { className: "".concat(editormodules.color999, " font12"), children: "\uFF08\u9009\u4E2D\uFF0C\u6BCF\u4E2A\u586B\u7A7A\u7684\u7B54\u6848\u987A\u5E8F\u5FC5\u987B\u4E0E\u53C2\u8003\u7B54\u6848\u4E00\u81F4\uFF09" })] }) }), /*#__PURE__*/(0,jsx_runtime.jsxs)("aside", { className: "tr", children: [(editKey !== -1 || !(editData !== null && editData !== void 0 && editData.edit)) && /*#__PURE__*/(0,jsx_runtime.jsx)(es_button/* default */.Z, { type: "default", onClick: function onClick() { cancelAdd(); setIsEdit(false); }, children: "\u53D6\u6D88" }), /*#__PURE__*/(0,jsx_runtime.jsx)(es_button/* default */.Z, { loading: btnLoading, className: "ml20", type: "primary", onClick: function onClick() { onSave(); }, children: "\u4FDD\u5B58" })] })] }); }; var actionArr = [{ name: "删除", icon: "iconfont c-light-black ml30 icon-shanchu current", id: "del" }, // { name: "上移", icon: "iconfont c-green ml30 icon-shangyi_Hover", id: "up" }, // { name: "下移", icon: "iconfont c-green ml30 icon-xiayi_moren", id: "down" }, { name: "(向下插入实训题)", icon: "iconfont c-light-primary ml30 icon-tianjia current", id: "add" }, { name: "编辑", icon: "iconfont c-light-primary ml30 icon-bianjishijuan3x current", id: "edit" }].filter(function (item) { var _exercise$editData, _exercise$editData$ex; if ((exercise === null || exercise === void 0 ? void 0 : (_exercise$editData = exercise.editData) === null || _exercise$editData === void 0 ? void 0 : (_exercise$editData$ex = _exercise$editData.exercise) === null || _exercise$editData$ex === void 0 ? void 0 : _exercise$editData$ex.exercise_status) === 1) { return item; } else { return item.id !== 'del' && item.id !== 'add'; } }); var actionClick = /*#__PURE__*/function () { var _ref3 = asyncToGenerator_default()( /*#__PURE__*/regeneratorRuntime_default()().mark(function _callee3(item) { return regeneratorRuntime_default()().wrap(function _callee3$(_context3) { while (1) switch (_context3.prev = _context3.next) { case 0: if (!(editKey !== -1)) { _context3.next = 3; break; } message/* default.error */.ZP.error("请先保存或取消当前正在编辑的问题。"); return _context3.abrupt("return"); case 3: _context3.t0 = item.id; _context3.next = _context3.t0 === "del" ? 6 : _context3.t0 === "up" ? 8 : _context3.t0 === "down" ? 8 : _context3.t0 === "edit" ? 12 : _context3.t0 === "add" ? 15 : 17; break; case 6: modal/* default.confirm */.Z.confirm({ centered: true, okText: '确定', cancelText: '取消', title: '确认要删除这个试题吗?', onOk: function onOk() { return asyncToGenerator_default()( /*#__PURE__*/regeneratorRuntime_default()().mark(function _callee2() { return regeneratorRuntime_default()().wrap(function _callee2$(_context2) { while (1) switch (_context2.prev = _context2.next) { case 0: _context2.next = 2; return (0,service_exercise/* exeriseQuestionDelete */.Fl)({ id: editData.question_id }); case 2: dispatch({ type: "exercise/editExercise", payload: objectSpread2_default()({}, params) }); case 3: case "end": return _context2.stop(); } }, _callee2); }))(); } }); return _context3.abrupt("break", 17); case 8: _context3.next = 10; return dispatch({ type: "exercise/exeriseMoveUpDown", payload: { id: editData.question_id, opr: item.id } }); case 10: dispatch({ type: "exercise/editExercise", payload: objectSpread2_default()({}, params) }); return _context3.abrupt("break", 17); case 12: setEditKey(editData.dragKey); setIsEdit(true); return _context3.abrupt("break", 17); case 15: dispatch({ type: "classroomList/setActionTabs", payload: { key: "选用实践项目", editData: { key: editData.key, insert_id: editData === null || editData === void 0 ? void 0 : editData.question_id, question_type: 5 } } }); return _context3.abrupt("break", 17); case 17: case "end": return _context3.stop(); } }, _callee3); })); return function actionClick(_x) { return _ref3.apply(this, arguments); }; }(); var showList = function showList() { var _editData$schools, _editData$shixun3; return /*#__PURE__*/(0,jsx_runtime.jsxs)("aside", { children: [/*#__PURE__*/(0,jsx_runtime.jsx)("div", { className: editormodules.questionType, children: !(editData !== null && editData !== void 0 && editData.isPreview) && /*#__PURE__*/(0,jsx_runtime.jsxs)("div", { children: [/*#__PURE__*/(0,jsx_runtime.jsxs)("span", { className: "font16 c-blue", children: [editData.key, "\u3001\u5B9E\u8BAD\u9898"] }), "\uFF08", editData.question_score, "\u5206\uFF09"] }) }), editData !== null && editData !== void 0 && editData.isPreview ? /*#__PURE__*/(0,jsx_runtime.jsxs)("div", { style: { display: 'flex' }, children: [/*#__PURE__*/(0,jsx_runtime.jsxs)("span", { style: { flexShrink: 0 }, className: "font18", children: [editData.key, "."] }), /*#__PURE__*/(0,jsx_runtime.jsx)(RenderHtml/* default */.Z, { value: editData.shixun_name }), /*#__PURE__*/(0,jsx_runtime.jsxs)("span", { style: { flexShrink: 0 }, className: "font16", children: ["\uFF08", editData.question_score, "\u5206\uFF09"] }), !!((_editData$schools = editData.schools) !== null && _editData$schools !== void 0 && _editData$schools.length) && /*#__PURE__*/(0,jsx_runtime.jsx)(tooltip/* default */.Z, { title: "\u8BE5\u5B9E\u8BAD\u9898\u9762\u5411\u6307\u5B9A\u5355\u4F4D\u5F00\u653E", children: /*#__PURE__*/(0,jsx_runtime.jsx)("i", { className: "iconfont icon-zhidinggongkai1 font18 line24 c-orange" }) })] }) : /*#__PURE__*/(0,jsx_runtime.jsx)("div", { className: "mt5", children: /*#__PURE__*/(0,jsx_runtime.jsx)(RenderHtml/* default */.Z, { value: editData.shixun_name }) }), /*#__PURE__*/(0,jsx_runtime.jsx)("div", { className: "mt30" }), (_editData$shixun3 = editData.shixun) === null || _editData$shixun3 === void 0 ? void 0 : _editData$shixun3.map(function (item, index) { return /*#__PURE__*/(0,jsx_runtime.jsxs)("div", { children: ["\u7B2C", index + 1, "\u5173 ", /*#__PURE__*/(0,jsx_runtime.jsx)("span", { className: "ml10", children: item.challenge_name }), " ", /*#__PURE__*/(0,jsx_runtime.jsxs)("span", { className: "ml10", children: [item.challenge_score, " \u5206"] })] }, index); }), /*#__PURE__*/(0,jsx_runtime.jsxs)("div", { className: editormodules.action, children: [/*#__PURE__*/(0,jsx_runtime.jsx)(_umi_production_exports.Link, { target: "_blank", to: "/shixuns/".concat(editData.shixun_identifier, "/challenges?exercise=true"), children: "\u5B9E\u8BAD\u8BE6\u60C5" }), !editData.hideAction && actionArr.map(function (item, index) { if (item.id === "up" && editData.key === 1) return null; if (item.id === "down" && editData.key === editData.len) return null; return /*#__PURE__*/(0,jsx_runtime.jsx)(tooltip/* default */.Z, { placement: "bottom", title: item.name, children: /*#__PURE__*/(0,jsx_runtime.jsx)("span", { onClick: function onClick() { return actionClick(item); }, className: item.icon }) }, index); })] })] }); }; return /*#__PURE__*/(0,jsx_runtime.jsxs)("section", { className: editormodules.wrap, children: [!isEdit && showList(), isEdit && showEdit()] }); }; // export default connect( // ({ // problemset, // loading, // globalSetting, // }: { // problemset: ProblemsetModelState; // loading: Loading; // globalSetting: GlobalSettingModelState; // }) => ({ // problemset, // globalSetting, // loading: loading.effects, // }), // )(ShixunEditor); /* harmony default export */ var components_ShixunEditor = ((0,_umi_production_exports.connect)(function (_ref4) { var problemset = _ref4.problemset, loading = _ref4.loading, globalSetting = _ref4.globalSetting, exercise = _ref4.exercise; return { problemset: problemset, globalSetting: globalSetting, exercise: exercise, loading: loading.effects }; }, null, null, { forwardRef: true })( /*#__PURE__*/(0,react.forwardRef)(ShixunEditor))); ;// CONCATENATED MODULE: ./src/pages/Classrooms/Lists/Exercise/Edit/components/SingleEditor/index.tsx var SingleEditor_excluded = ["problemset", "exercise", "globalSetting", "loading", "dispatch", "onRef", "editData", "cancelAdd", "editKey", "setEditKey", "setIsClaer", "reload", "addCallback"]; var SingleEditor_tagList = ['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']; var SingleEditor = function SingleEditor(_ref, ref) { var problemset = _ref.problemset, exercise = _ref.exercise, globalSetting = _ref.globalSetting, loading = _ref.loading, dispatch = _ref.dispatch, _ref$onRef = _ref.onRef, onRef = _ref$onRef === void 0 ? function () {} : _ref$onRef, editData = _ref.editData, _ref$cancelAdd = _ref.cancelAdd, cancelAdd = _ref$cancelAdd === void 0 ? function () {} : _ref$cancelAdd, editKey = _ref.editKey, _ref$setEditKey = _ref.setEditKey, setEditKey = _ref$setEditKey === void 0 ? function () {} : _ref$setEditKey, _ref$setIsClaer = _ref.setIsClaer, setIsClaer = _ref$setIsClaer === void 0 ? function () {} : _ref$setIsClaer, _ref$reload = _ref.reload, reload = _ref$reload === void 0 ? function () {} : _ref$reload, _ref$addCallback = _ref.addCallback, addCallback = _ref$addCallback === void 0 ? function (data) {} : _ref$addCallback, props = objectWithoutProperties_default()(_ref, SingleEditor_excluded); var _useState = (0,react.useState)([]), _useState2 = slicedToArray_default()(_useState, 2), questionChoiceList = _useState2[0], setQuestionChoiceList = _useState2[1]; var _useState3 = (0,react.useState)(), _useState4 = slicedToArray_default()(_useState3, 2), activeEditor = _useState4[0], setActiveEditor = _useState4[1]; var _useState5 = (0,react.useState)([]), _useState6 = slicedToArray_default()(_useState5, 2), activeAnswer = _useState6[0], setActiveAnswer = _useState6[1]; var _useState7 = (0,react.useState)(''), _useState8 = slicedToArray_default()(_useState7, 2), title = _useState8[0], setTitle = _useState8[1]; var _useState9 = (0,react.useState)(), _useState10 = slicedToArray_default()(_useState9, 2), score = _useState10[0], setScore = _useState10[1]; var _useState11 = (0,react.useState)([]), _useState12 = slicedToArray_default()(_useState11, 2), knowledge = _useState12[0], setKnowledge = _useState12[1]; var _useState13 = (0,react.useState)(false), _useState14 = slicedToArray_default()(_useState13, 2), isEdit = _useState14[0], setIsEdit = _useState14[1]; var _useState15 = (0,react.useState)(1), _useState16 = slicedToArray_default()(_useState15, 2), difficulty = _useState16[0], setdifficult = _useState16[1]; var _useState17 = (0,react.useState)(false), _useState18 = slicedToArray_default()(_useState17, 2), repeat_answer = _useState18[0], setrepeat_answer = _useState18[1]; var _useState19 = (0,react.useState)(''), _useState20 = slicedToArray_default()(_useState19, 2), analysis = _useState20[0], setAnalysis = _useState20[1]; var params = (0,_umi_production_exports.useParams)(); var dom = (0,react.useRef)(null); var freeze = (0,react.useRef)(false); var _useState21 = (0,react.useState)([]), _useState22 = slicedToArray_default()(_useState21, 2), knowledgeOptions = _useState22[0], setKnowledgeOptions = _useState22[1]; var handleAddKnowledgeFinish = function handleAddKnowledgeFinish(item) { setKnowledgeOptions([].concat(toConsumableArray_default()(knowledgeOptions), [objectSpread2_default()({}, item)])); }; (0,react.useEffect)(function () { setQuestionChoiceList(['', '', '', '']); }, []); (0,react.useEffect)(function () { if (freeze.current) return; if (!(editData !== null && editData !== void 0 && editData.question_choices)) { setIsEdit(true); setTitle(''); setScore(5); setQuestionChoiceList(['', '', '', '']); setActiveAnswer([]); // dom.current?.scrollIntoView() return; } setTitle(editData === null || editData === void 0 ? void 0 : editData.question_title); setScore(editData === null || editData === void 0 ? void 0 : editData.question_score); setrepeat_answer(!(editData !== null && editData !== void 0 && editData.repeat_answer)); setAnalysis(editData === null || editData === void 0 ? void 0 : editData.analysis); setdifficult(editData === null || editData === void 0 ? void 0 : editData.difficulty); setQuestionChoiceList(editData === null || editData === void 0 ? void 0 : editData.question_choices.map(function (item) { return item.choice_text; })); var answerIndexs = []; editData === null || editData === void 0 ? void 0 : editData.standard_answer.map(function (item, index) { answerIndexs.push(item - 1); }); setKnowledge(editData.tag_discipline_ids); setActiveAnswer(answerIndexs); }, [editData, isEdit]); (0,react.useEffect)(function () { if (isEdit) { init(); } function init() { return _init.apply(this, arguments); } function _init() { _init = asyncToGenerator_default()( /*#__PURE__*/regeneratorRuntime_default()().mark(function _callee() { var _exercise$editData, _exercise$editData$ex; var res; return regeneratorRuntime_default()().wrap(function _callee$(_context) { while (1) switch (_context.prev = _context.next) { case 0: _context.next = 2; return (0,service_exercise/* getTagDiscipline */.YY)({ sub_discipline_id: (_exercise$editData = exercise.editData) === null || _exercise$editData === void 0 ? void 0 : (_exercise$editData$ex = _exercise$editData.exercise) === null || _exercise$editData$ex === void 0 ? void 0 : _exercise$editData$ex.sub_discipline_id }); case 2: res = _context.sent; setKnowledgeOptions(res.tag_disciplines); case 4: case "end": return _context.stop(); } }, _callee); })); return _init.apply(this, arguments); } }, [isEdit]); (0,react.useEffect)(function () { var _exercise$tagDiscipli; var data = exercise !== null && exercise !== void 0 && (_exercise$tagDiscipli = exercise.tagDisciplineData) !== null && _exercise$tagDiscipli !== void 0 && _exercise$tagDiscipli.tag_disciplines && Array.isArray(exercise.tagDisciplineData.tag_disciplines) ? exercise.tagDisciplineData.tag_disciplines : []; setKnowledgeOptions(data); }, [exercise.tagDisciplineData]); (0,react.useImperativeHandle)(ref, function () { return { onSave: onSave, isEdit: isEdit }; }); var repeal = function repeal(res) { if ((res === null || res === void 0 ? void 0 : res.status) === 0) { message/* default.success */.ZP.success("保存成功"); setIsEdit(false); setEditKey(-1); freeze.current = false; reload(); } }; var onSave = /*#__PURE__*/function () { var _ref2 = asyncToGenerator_default()( /*#__PURE__*/regeneratorRuntime_default()().mark(function _callee4() { var findNotAnswerIndex, choices, res, _exercise$editData4, _exercise$editData4$e, _exercise$editData5, _exercise$editData5$e; return regeneratorRuntime_default()().wrap(function _callee4$(_context4) { while (1) switch (_context4.prev = _context4.next) { case 0: if (title) { _context4.next = 3; break; } message/* default.info */.ZP.info("请您输入题目"); return _context4.abrupt("return", false); case 3: findNotAnswerIndex = questionChoiceList.findIndex(function (item) { return !item; }); if (!(findNotAnswerIndex > -1)) { _context4.next = 7; break; } message/* default.info */.ZP.info("\u8BF7\u5148\u8F93\u5165 ".concat(SingleEditor_tagList[findNotAnswerIndex], " \u9009\u9879\u7684\u5185\u5BB9")); return _context4.abrupt("return", false); case 7: if (activeAnswer.length) { _context4.next = 10; break; } message/* default.info */.ZP.info("请设置本题的正确答案,点击选项A/B...即可完成设置"); return _context4.abrupt("return", false); case 10: if (!(activeAnswer.length < 1)) { _context4.next = 13; break; } message/* default.info */.ZP.info("请选择答案"); return _context4.abrupt("return", false); case 13: // if (knowledge.length < 1) { // message.info("请选择知识点"); // return false; // } choices = questionChoiceList.map(function (item, index) { return { choice_text: item, is_answer: activeAnswer.includes(index) ? index + 1 : 0 }; }); freeze.current = true; if (!editData.question_id) { _context4.next = 26; break; } if (!((editData === null || editData === void 0 ? void 0 : editData.is_my) === 1)) { _context4.next = 20; break; } modal/* default.confirm */.Z.confirm({ title: '提示', content: '此题目已存在于试题库,是否将修改后的题目覆盖试题库的原题?', okText: '覆盖原题', cancelText: '不覆盖', keyboard: false, onOk: function () { var _onOk = asyncToGenerator_default()( /*#__PURE__*/regeneratorRuntime_default()().mark(function _callee2() { var _exercise$editData2, _exercise$editData2$e; return regeneratorRuntime_default()().wrap(function _callee2$(_context2) { while (1) switch (_context2.prev = _context2.next) { case 0: _context2.next = 2; return dispatch({ type: "exercise/editExerciseQuestion", payload: { "id": editData.question_id, "question_title": title, "question_type": 1, "question_score": score, "question_choices": choices.map(function (item) { return item.choice_text; }), "standard_answers": choices.filter(function (item) { return item.is_answer; }).map(function (item) { return item.is_answer; }), "tag_discipline_ids": knowledge, "sub_discipline_id": (_exercise$editData2 = exercise.editData) === null || _exercise$editData2 === void 0 ? void 0 : (_exercise$editData2$e = _exercise$editData2.exercise) === null || _exercise$editData2$e === void 0 ? void 0 : _exercise$editData2$e.sub_discipline_id, "difficulty": difficulty, "is_cover": 1, "repeat_answer": !repeat_answer, analysis: analysis } }); case 2: res = _context2.sent; repeal(res); case 4: case "end": return _context2.stop(); } }, _callee2); })); function onOk() { return _onOk.apply(this, arguments); } return onOk; }(), onCancel: function () { var _onCancel = asyncToGenerator_default()( /*#__PURE__*/regeneratorRuntime_default()().mark(function _callee3() { var _exercise$editData3, _exercise$editData3$e; return regeneratorRuntime_default()().wrap(function _callee3$(_context3) { while (1) switch (_context3.prev = _context3.next) { case 0: _context3.next = 2; return dispatch({ type: "exercise/editExerciseQuestion", payload: { "id": editData.question_id, "question_title": title, "question_type": 1, "question_score": score, "question_choices": choices.map(function (item) { return item.choice_text; }), "standard_answers": choices.filter(function (item) { return item.is_answer; }).map(function (item) { return item.is_answer; }), "tag_discipline_ids": knowledge, "sub_discipline_id": (_exercise$editData3 = exercise.editData) === null || _exercise$editData3 === void 0 ? void 0 : (_exercise$editData3$e = _exercise$editData3.exercise) === null || _exercise$editData3$e === void 0 ? void 0 : _exercise$editData3$e.sub_discipline_id, "difficulty": difficulty, "repeat_answer": !repeat_answer, analysis: analysis } }); case 2: res = _context3.sent; repeal(res); case 4: case "end": return _context3.stop(); } }, _callee3); })); function onCancel() { return _onCancel.apply(this, arguments); } return onCancel; }() }); _context4.next = 24; break; case 20: _context4.next = 22; return dispatch({ type: "exercise/editExerciseQuestion", payload: { "id": editData.question_id, "question_title": title, "question_type": 1, "question_score": score, "question_choices": choices.map(function (item) { return item.choice_text; }), "standard_answers": choices.filter(function (item) { return item.is_answer; }).map(function (item) { return item.is_answer; }), "tag_discipline_ids": knowledge, "sub_discipline_id": (_exercise$editData4 = exercise.editData) === null || _exercise$editData4 === void 0 ? void 0 : (_exercise$editData4$e = _exercise$editData4.exercise) === null || _exercise$editData4$e === void 0 ? void 0 : _exercise$editData4$e.sub_discipline_id, "difficulty": difficulty, "repeat_answer": !repeat_answer, analysis: analysis } }); case 22: res = _context4.sent; repeal(res); case 24: _context4.next = 30; break; case 26: _context4.next = 28; return dispatch({ type: "exercise/addExerciseQuestion", payload: { insert_id: editData === null || editData === void 0 ? void 0 : editData.insert_id, "categoryId": params.categoryId, "question_title": title, "question_type": 1, "question_score": score, "question_choices": choices.map(function (item) { return item.choice_text; }), "standard_answers": choices.filter(function (item) { return item.is_answer; }).map(function (item) { return item.is_answer; }), "tag_discipline_ids": knowledge, "sub_discipline_id": (_exercise$editData5 = exercise.editData) === null || _exercise$editData5 === void 0 ? void 0 : (_exercise$editData5$e = _exercise$editData5.exercise) === null || _exercise$editData5$e === void 0 ? void 0 : _exercise$editData5$e.sub_discipline_id, "difficulty": difficulty, "repeat_answer": !repeat_answer, analysis: analysis } }); case 28: res = _context4.sent; repeal(res); case 30: case "end": return _context4.stop(); } }, _callee4); })); return function onSave() { return _ref2.apply(this, arguments); }; }(); var actionArr = [{ name: "删除", icon: "iconfont c-light-black ml30 icon-shanchu current", id: "del" }, // { name: "上移", icon: "iconfont c-green ml30 icon-shangyi_Hover", id: "up" }, // { name: "下移", icon: "iconfont c-green ml30 icon-xiayi_moren", id: "down" }, { name: "(向下插入单选题)", icon: "iconfont c-light-primary ml30 icon-tianjia current", id: "add" }, { name: "编辑", icon: "iconfont c-light-primary ml30 icon-bianjishijuan3x current", id: "edit" }].filter(function (item) { var _exercise$editData6, _exercise$editData6$e; if ((exercise === null || exercise === void 0 ? void 0 : (_exercise$editData6 = exercise.editData) === null || _exercise$editData6 === void 0 ? void 0 : (_exercise$editData6$e = _exercise$editData6.exercise) === null || _exercise$editData6$e === void 0 ? void 0 : _exercise$editData6$e.exercise_status) === 1) { return item; } else { return item.id !== 'del' && item.id !== 'add'; } }); var actionClick = /*#__PURE__*/function () { var _ref3 = asyncToGenerator_default()( /*#__PURE__*/regeneratorRuntime_default()().mark(function _callee6(item) { return regeneratorRuntime_default()().wrap(function _callee6$(_context6) { while (1) switch (_context6.prev = _context6.next) { case 0: if (!(editKey !== -1)) { _context6.next = 3; break; } message/* default.error */.ZP.error("请先保存或取消当前正在编辑的问题。"); return _context6.abrupt("return"); case 3: _context6.t0 = item.id; _context6.next = _context6.t0 === "del" ? 6 : _context6.t0 === "up" ? 8 : _context6.t0 === "down" ? 8 : _context6.t0 === "edit" ? 12 : _context6.t0 === "add" ? 15 : 17; break; case 6: modal/* default.confirm */.Z.confirm({ centered: true, okText: '确定', cancelText: '取消', title: '确认要删除这个试题吗?', onOk: function onOk() { return asyncToGenerator_default()( /*#__PURE__*/regeneratorRuntime_default()().mark(function _callee5() { return regeneratorRuntime_default()().wrap(function _callee5$(_context5) { while (1) switch (_context5.prev = _context5.next) { case 0: _context5.next = 2; return (0,service_exercise/* exeriseQuestionDelete */.Fl)({ id: editData.question_id }); case 2: dispatch({ type: "exercise/editExercise", payload: objectSpread2_default()({}, params) }); case 3: case "end": return _context5.stop(); } }, _callee5); }))(); } }); return _context6.abrupt("break", 17); case 8: _context6.next = 10; return dispatch({ type: "exercise/exeriseMoveUpDown", payload: { id: editData.question_id, opr: item.id } }); case 10: dispatch({ type: "exercise/editExercise", payload: objectSpread2_default()({}, params) }); return _context6.abrupt("break", 17); case 12: setEditKey(editData.dragKey); setIsEdit(true); return _context6.abrupt("break", 17); case 15: addCallback({ key: editData.key, insert_id: editData === null || editData === void 0 ? void 0 : editData.question_id, question_type: 0 }); return _context6.abrupt("break", 17); case 17: case "end": return _context6.stop(); } }, _callee6); })); return function actionClick(_x) { return _ref3.apply(this, arguments); }; }(); var showList = function showList() { var _editData$question_ch; return /*#__PURE__*/(0,jsx_runtime.jsxs)("aside", { ref: dom, children: [/*#__PURE__*/(0,jsx_runtime.jsx)("div", { className: editormodules.questionType, children: !(editData !== null && editData !== void 0 && editData.isPreview) && /*#__PURE__*/(0,jsx_runtime.jsxs)("div", { children: [/*#__PURE__*/(0,jsx_runtime.jsxs)("span", { className: "font16 c-blue", children: [editData.key, "\u3001\u5355\u9009\u9898"] }), "\uFF08", editData.question_score, "\u5206\uFF09"] }) }), editData !== null && editData !== void 0 && editData.isPreview ? /*#__PURE__*/(0,jsx_runtime.jsxs)("div", { style: { display: 'flex', alignItems: "flex-start" }, children: [/*#__PURE__*/(0,jsx_runtime.jsxs)("span", { style: { flexShrink: 0 }, className: "font18", children: [editData.key, "."] }), /*#__PURE__*/(0,jsx_runtime.jsx)(RenderHtml/* default */.Z, { value: editData.question_title }), /*#__PURE__*/(0,jsx_runtime.jsxs)("span", { style: { flexShrink: 0 }, className: "font16", children: ["\uFF08", editData.question_score, "\u5206\uFF09"] })] }) : /*#__PURE__*/(0,jsx_runtime.jsx)("div", { className: "mt5", children: /*#__PURE__*/(0,jsx_runtime.jsx)(RenderHtml/* default */.Z, { value: editData.question_title }) }), /*#__PURE__*/(0,jsx_runtime.jsx)("div", { className: editormodules.questionChoices, children: editData === null || editData === void 0 ? void 0 : (_editData$question_ch = editData.question_choices) === null || _editData$question_ch === void 0 ? void 0 : _editData$question_ch.map(function (item, index) { return /*#__PURE__*/(0,jsx_runtime.jsxs)(row/* default */.Z, { children: [/*#__PURE__*/(0,jsx_runtime.jsx)(col/* default */.Z, { children: /*#__PURE__*/(0,jsx_runtime.jsxs)(es_radio/* default */.ZP, { checked: editData.standard_answer.includes(index + 1), disabled: true, children: [SingleEditor_tagList[index], "."] }, index) }), /*#__PURE__*/(0,jsx_runtime.jsx)(col/* default */.Z, { flex: "1", children: /*#__PURE__*/(0,jsx_runtime.jsx)("span", { className: "c-black font14", children: /*#__PURE__*/(0,jsx_runtime.jsx)(RenderHtml/* default */.Z, { value: item.choice_text }) }) })] }, index); }) }), /*#__PURE__*/(0,jsx_runtime.jsx)("div", { className: editormodules.action, children: !editData.hideAction && actionArr.map(function (item, index) { if (item.id === "up" && editData.key === 1) return null; if (item.id === "down" && editData.key === editData.len) return null; return /*#__PURE__*/(0,jsx_runtime.jsx)(tooltip/* default */.Z, { placement: "bottom", title: item.name, children: /*#__PURE__*/(0,jsx_runtime.jsx)("span", { onClick: function onClick() { return actionClick(item); }, className: item.icon }) }, index); }) })] }); }; var showEdit = function showEdit() { var _exercise$editData8, _exercise$editData8$e; return /*#__PURE__*/(0,jsx_runtime.jsxs)("aside", { children: [/*#__PURE__*/(0,jsx_runtime.jsx)("div", { className: editormodules.questionType, children: /*#__PURE__*/(0,jsx_runtime.jsxs)("div", { children: [/*#__PURE__*/(0,jsx_runtime.jsx)("span", { className: "font16 c-blue", children: "\u9009\u62E9\u9898" }), "\uFF08\u5BA2\u89C2\u9898\uFF0C\u7531\u7CFB\u7EDF\u81EA\u52A8\u8BC4\u5206\uFF0C\u8BF7\u8BBE\u7F6E\u6807\u51C6\u7B54\u6848\uFF09"] }) }), /*#__PURE__*/(0,jsx_runtime.jsxs)("p", { className: editormodules.titleWrap, children: [/*#__PURE__*/(0,jsx_runtime.jsx)("span", { className: editormodules.required, children: "*" }), /*#__PURE__*/(0,jsx_runtime.jsx)("span", { className: editormodules.title, children: "\u9898\u5E72\uFF1A" })] }), /*#__PURE__*/(0,jsx_runtime.jsx)(markdown_editor/* default */.Z, { id: "single-question-title", watch: true, height: 155, placeholder: "\u8BF7\u60A8\u8F93\u5165\u9898\u5E72", defaultValue: title, onChange: function onChange(value) { return setTitle(value); } }), /*#__PURE__*/(0,jsx_runtime.jsxs)("p", { className: editormodules.titleWrap, children: [/*#__PURE__*/(0,jsx_runtime.jsx)("span", { className: editormodules.required, children: "*" }), /*#__PURE__*/(0,jsx_runtime.jsxs)("span", { className: editormodules.title, children: ["\u7B54\u6848\u9009\u9879\uFF1A", /*#__PURE__*/(0,jsx_runtime.jsx)("span", { className: editormodules.colorGray, children: "\u70B9\u51FB\u9009\u9879\u53EF\u8BBE\u7F6E\u6B63\u786E\u7B54\u6848" })] })] }), questionChoiceList.map(function (item, index) { var _exercise$editData7, _exercise$editData7$e; return /*#__PURE__*/(0,jsx_runtime.jsxs)("div", { className: editormodules.choiceWrap, children: [/*#__PURE__*/(0,jsx_runtime.jsx)(tooltip/* default */.Z, { title: "\u70B9\u51FB\u8BBE\u7F6E\u4E3A\u6807\u51C6\u7B54\u6848", placement: "left", children: /*#__PURE__*/(0,jsx_runtime.jsx)("div", { className: "".concat(editormodules.answer, " ").concat(activeAnswer.includes(index) ? editormodules.activeAnswer : ''), onClick: function onClick() { if (activeAnswer.includes(index)) { setActiveAnswer(activeAnswer.filter(function (item) { return item !== index; })); } else { setActiveAnswer([].concat(toConsumableArray_default()(activeAnswer), [index])); } }, children: SingleEditor_tagList[index] }) }), /*#__PURE__*/(0,jsx_runtime.jsx)("div", { className: editormodules.editorWrap, children: activeEditor === index ? /*#__PURE__*/(0,jsx_runtime.jsx)(markdown_editor/* default */.Z, { id: "single-question-option-".concat(index), watch: true, isFocus: true, height: 155, placeholder: "\u8BF7\u60A8\u8F93\u5165\u9009\u9879", defaultValue: item, onChange: function onChange(value) { questionChoiceList[index] = value; setQuestionChoiceList(questionChoiceList); } }) : /*#__PURE__*/(0,jsx_runtime.jsx)("div", { className: editormodules.htmlWrap, onClick: function onClick() { return setActiveEditor(index); }, children: /*#__PURE__*/(0,jsx_runtime.jsx)(RenderHtml/* default */.Z, { value: item }) }) }), ((_exercise$editData7 = exercise.editData) === null || _exercise$editData7 === void 0 ? void 0 : (_exercise$editData7$e = _exercise$editData7.exercise) === null || _exercise$editData7$e === void 0 ? void 0 : _exercise$editData7$e.exercise_status) === 1 && /*#__PURE__*/(0,jsx_runtime.jsxs)(jsx_runtime.Fragment, { children: [index > 1 && /*#__PURE__*/(0,jsx_runtime.jsx)(tooltip/* default */.Z, { title: "\u5220\u9664", children: /*#__PURE__*/(0,jsx_runtime.jsx)("i", { className: "".concat(editormodules.deleteIcon, " iconfont icon-htmal5icon19"), onClick: function onClick() { return setQuestionChoiceList(questionChoiceList.filter(function (_, key) { return key !== index; })); } }) }), index < 7 && index === questionChoiceList.length - 1 && /*#__PURE__*/(0,jsx_runtime.jsx)(tooltip/* default */.Z, { title: "\u65B0\u589E\u53C2\u8003\u7B54\u6848", children: /*#__PURE__*/(0,jsx_runtime.jsx)("i", { className: "".concat(editormodules.addIcon, " iconfont icon-roundaddfill ml6"), onClick: function onClick() { return setQuestionChoiceList([].concat(toConsumableArray_default()(questionChoiceList), [''])); } }) })] })] }, index); }), /*#__PURE__*/(0,jsx_runtime.jsx)("p", { className: "c-orange", children: "\u6E29\u99A8\u63D0\u793A\uFF1A\u70B9\u51FB\u9009\u9879\u8F93\u5165\u6846\u53EF\u8BBE\u7F6E\u7B54\u6848\uFF1B\u9009\u4E2D\u7684\u9009\u9879\u5373\u4E3A\u6B63\u786E\u7B54\u6848\uFF0C\u9009\u62E9\u591A\u4E2A\u7B54\u6848\u5373\u4E3A\u591A\u9009\u9898" }), /*#__PURE__*/(0,jsx_runtime.jsx)("p", { className: editormodules.titleWrap, children: /*#__PURE__*/(0,jsx_runtime.jsx)("span", { className: editormodules.title, children: "\u9898\u76EE\u89E3\u6790\uFF1A" }) }), /*#__PURE__*/(0,jsx_runtime.jsx)(markdown_editor/* default */.Z, { id: "single-question-title", watch: true, height: 155, placeholder: "\u8BF7\u60A8\u8F93\u5165\u9898\u76EE\u89E3\u6790", defaultValue: analysis, onChange: function onChange(value) { return setAnalysis(value); } }), /*#__PURE__*/(0,jsx_runtime.jsxs)("div", { style: { marginBottom: 14 }, children: ["\u5206\u503C\uFF1A", /*#__PURE__*/(0,jsx_runtime.jsx)(input_number/* default */.Z, { value: score, max: 10000, min: 0, onChange: function onChange(value) { setScore(value); } }), " \u5206", /*#__PURE__*/(0,jsx_runtime.jsxs)("span", { style: { marginLeft: '30px' }, className: editormodules.difficult, children: [/*#__PURE__*/(0,jsx_runtime.jsx)("label", { style: { color: 'red' }, children: "*" }), " \u96BE\u5EA6\uFF1A", /*#__PURE__*/(0,jsx_runtime.jsxs)(es_radio/* default.Group */.ZP.Group, { value: difficulty, onChange: function onChange(e) { setdifficult(e.target.value); }, children: [/*#__PURE__*/(0,jsx_runtime.jsx)(es_radio/* default.Button */.ZP.Button, { value: 1, children: "\u7B80\u5355" }), /*#__PURE__*/(0,jsx_runtime.jsx)(es_radio/* default.Button */.ZP.Button, { value: 2, children: "\u9002\u4E2D" }), /*#__PURE__*/(0,jsx_runtime.jsx)(es_radio/* default.Button */.ZP.Button, { value: 3, children: "\u56F0\u96BE" })] })] })] }), /*#__PURE__*/(0,jsx_runtime.jsxs)("div", { className: editormodules.titleWrap, children: [/*#__PURE__*/(0,jsx_runtime.jsxs)("span", { className: "".concat(editormodules.title), children: ["\u77E5\u8BC6\u70B9\uFF1A", /*#__PURE__*/(0,jsx_runtime.jsx)("span", { className: editormodules.colorGray, children: "\uFF08\u6240\u6709\u81EA\u5EFA\u77E5\u8BC6\u70B9\u4EC5\u672C\u4EBA\u53EF\u89C1\uFF0C\u88ABEduCoder\u5E73\u53F0\u5BA1\u6838\u901A\u8FC7\u4E3A\u5B98\u65B9\u77E5\u8BC6\u70B9\u540E\u6240\u6709\u7528\u6237\u53EF\u89C1\uFF09" })] }), /*#__PURE__*/(0,jsx_runtime.jsx)("div", { className: "mt5", children: /*#__PURE__*/(0,jsx_runtime.jsx)(Knowledge/* Knowledge */.N, { selectvalues: editData === null || editData === void 0 ? void 0 : editData.tag_discipline_ids, value: knowledge, onChange: setKnowledge, subId: (_exercise$editData8 = exercise.editData) === null || _exercise$editData8 === void 0 ? void 0 : (_exercise$editData8$e = _exercise$editData8.exercise) === null || _exercise$editData8$e === void 0 ? void 0 : _exercise$editData8$e.sub_discipline_id, knowledgeOptions: knowledgeOptions, onAddKnowledgeFinish: handleAddKnowledgeFinish }) }), /*#__PURE__*/(0,jsx_runtime.jsxs)("div", { style: { marginTop: 10 }, children: [/*#__PURE__*/(0,jsx_runtime.jsx)("span", { style: { marginRight: 10 }, children: "\u4E0D\u5141\u8BB8\u5B66\u751F\u91CD\u590D\u7B54\u9898" }), /*#__PURE__*/(0,jsx_runtime.jsx)(es_switch/* default */.Z, { checked: repeat_answer, onChange: function onChange(e) { setrepeat_answer(e); } })] })] }), /*#__PURE__*/(0,jsx_runtime.jsxs)("aside", { className: "tr", children: [(editKey !== -1 || editData.question_id) && /*#__PURE__*/(0,jsx_runtime.jsx)(es_button/* default */.Z, { type: "default", onClick: function onClick() { cancelAdd(); setIsEdit(false); }, children: "\u53D6\u6D88" }), /*#__PURE__*/(0,jsx_runtime.jsx)(es_button/* default */.Z, { className: "ml20", type: "primary", onClick: function onClick() { onSave(); }, children: "\u4FDD\u5B58" })] })] }); }; return /*#__PURE__*/(0,jsx_runtime.jsxs)("section", { className: editormodules.wrap, children: [!isEdit && showList(), isEdit && showEdit()] }); }; /* harmony default export */ var components_SingleEditor = ((0,_umi_production_exports.connect)(function (_ref4) { var problemset = _ref4.problemset, loading = _ref4.loading, globalSetting = _ref4.globalSetting, exercise = _ref4.exercise; return { problemset: problemset, globalSetting: globalSetting, exercise: exercise, loading: loading.effects }; }, null, null, { forwardRef: true })( /*#__PURE__*/(0,react.forwardRef)(SingleEditor))); // EXTERNAL MODULE: ./src/components/EditorKeyword/index.tsx var EditorKeyword = __webpack_require__(4207); ;// CONCATENATED MODULE: ./src/pages/Classrooms/Lists/Exercise/Edit/components/SubjectiveEditor/index.tsx var SubjectiveEditor_excluded = ["problemset", "exercise", "globalSetting", "loading", "dispatch", "onRef", "editData", "cancelAdd", "editKey", "setEditKey", "reload", "addCallback", "setIsClaer"]; var SubjectiveEditor_tagList = (/* unused pure expression or super */ null && (['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'])); var SubjectiveEditor = function SubjectiveEditor(_ref, ref) { var problemset = _ref.problemset, exercise = _ref.exercise, globalSetting = _ref.globalSetting, loading = _ref.loading, dispatch = _ref.dispatch, _ref$onRef = _ref.onRef, onRef = _ref$onRef === void 0 ? function () {} : _ref$onRef, editData = _ref.editData, _ref$cancelAdd = _ref.cancelAdd, cancelAdd = _ref$cancelAdd === void 0 ? function () {} : _ref$cancelAdd, editKey = _ref.editKey, _ref$setEditKey = _ref.setEditKey, setEditKey = _ref$setEditKey === void 0 ? function () {} : _ref$setEditKey, _ref$reload = _ref.reload, reload = _ref$reload === void 0 ? function () {} : _ref$reload, _ref$addCallback = _ref.addCallback, addCallback = _ref$addCallback === void 0 ? function () {} : _ref$addCallback, _ref$setIsClaer = _ref.setIsClaer, setIsClaer = _ref$setIsClaer === void 0 ? function () {} : _ref$setIsClaer, props = objectWithoutProperties_default()(_ref, SubjectiveEditor_excluded); var _useState = (0,react.useState)(''), _useState2 = slicedToArray_default()(_useState, 2), title = _useState2[0], setTitle = _useState2[1]; var _useState3 = (0,react.useState)(''), _useState4 = slicedToArray_default()(_useState3, 2), analysis = _useState4[0], setAnalysis = _useState4[1]; var _useState5 = (0,react.useState)(''), _useState6 = slicedToArray_default()(_useState5, 2), answer = _useState6[0], setAnswer = _useState6[1]; var _useState7 = (0,react.useState)(), _useState8 = slicedToArray_default()(_useState7, 2), score = _useState8[0], setScore = _useState8[1]; var _useState9 = (0,react.useState)(false), _useState10 = slicedToArray_default()(_useState9, 2), isEdit = _useState10[0], setIsEdit = _useState10[1]; var _useState11 = (0,react.useState)([]), _useState12 = slicedToArray_default()(_useState11, 2), knowledge = _useState12[0], setKnowledge = _useState12[1]; var _useState13 = (0,react.useState)(1), _useState14 = slicedToArray_default()(_useState13, 2), difficulty = _useState14[0], setdifficult = _useState14[1]; var _useState15 = (0,react.useState)(false), _useState16 = slicedToArray_default()(_useState15, 2), repeat_answer = _useState16[0], setrepeat_answer = _useState16[1]; var _useState17 = (0,react.useState)([[], []]), _useState18 = slicedToArray_default()(_useState17, 2), keyword = _useState18[0], setKeyword = _useState18[1]; var freeze = (0,react.useRef)(false); var params = (0,_umi_production_exports.useParams)(); var _useState19 = (0,react.useState)([]), _useState20 = slicedToArray_default()(_useState19, 2), knowledgeOptions = _useState20[0], setKnowledgeOptions = _useState20[1]; var handleAddKnowledgeFinish = function handleAddKnowledgeFinish(item) { setKnowledgeOptions([].concat(toConsumableArray_default()(knowledgeOptions), [objectSpread2_default()({}, item)])); }; (0,react.useEffect)(function () { var _editData$standard_an; if (freeze.current) return; if (!(editData !== null && editData !== void 0 && editData.question_title)) { setIsEdit(true); setTitle(''); setAnswer(''); setScore(10); return; } setrepeat_answer(!(editData !== null && editData !== void 0 && editData.repeat_answer)); setTitle(editData === null || editData === void 0 ? void 0 : editData.question_title); setAnswer(editData === null || editData === void 0 ? void 0 : (_editData$standard_an = editData.standard_answer) === null || _editData$standard_an === void 0 ? void 0 : _editData$standard_an[0]); setScore(editData === null || editData === void 0 ? void 0 : editData.question_score); setKnowledge(editData.tag_discipline_ids); setdifficult(editData === null || editData === void 0 ? void 0 : editData.difficulty); setAnalysis(editData === null || editData === void 0 ? void 0 : editData.analysis); setKeyword([editData === null || editData === void 0 ? void 0 : editData.normal_keywords, editData === null || editData === void 0 ? void 0 : editData.main_keywords]); }, [problemset.editData, isEdit]); (0,react.useEffect)(function () { var _exercise$tagDiscipli; var data = exercise !== null && exercise !== void 0 && (_exercise$tagDiscipli = exercise.tagDisciplineData) !== null && _exercise$tagDiscipli !== void 0 && _exercise$tagDiscipli.tag_disciplines && Array.isArray(exercise.tagDisciplineData.tag_disciplines) ? exercise.tagDisciplineData.tag_disciplines : []; setKnowledgeOptions(data); }, [exercise.tagDisciplineData]); (0,react.useEffect)(function () { if (isEdit) { init(); } function init() { return _init.apply(this, arguments); } function _init() { _init = asyncToGenerator_default()( /*#__PURE__*/regeneratorRuntime_default()().mark(function _callee() { var _exercise$editData, _exercise$editData$ex; var res; return regeneratorRuntime_default()().wrap(function _callee$(_context) { while (1) switch (_context.prev = _context.next) { case 0: _context.next = 2; return (0,service_exercise/* getTagDiscipline */.YY)({ sub_discipline_id: (_exercise$editData = exercise.editData) === null || _exercise$editData === void 0 ? void 0 : (_exercise$editData$ex = _exercise$editData.exercise) === null || _exercise$editData$ex === void 0 ? void 0 : _exercise$editData$ex.sub_discipline_id }); case 2: res = _context.sent; setKnowledgeOptions(res.tag_disciplines); case 4: case "end": return _context.stop(); } }, _callee); })); return _init.apply(this, arguments); } }, [isEdit]); (0,react.useImperativeHandle)(ref, function () { return { onSave: onSave, isEdit: isEdit }; }); var repeal = function repeal(res) { if ((res === null || res === void 0 ? void 0 : res.status) === 0) { message/* default.success */.ZP.success("保存成功"); setIsEdit(false); setEditKey(-1); freeze.current = false; reload(); } }; var onSave = /*#__PURE__*/function () { var _ref2 = asyncToGenerator_default()( /*#__PURE__*/regeneratorRuntime_default()().mark(function _callee4() { var normal_keywords, main_keywords, res, _exercise$editData4, _exercise$editData4$e, _exercise$editData5, _exercise$editData5$e; return regeneratorRuntime_default()().wrap(function _callee4$(_context4) { while (1) switch (_context4.prev = _context4.next) { case 0: if (title) { _context4.next = 3; break; } message/* default.info */.ZP.info("请您输入题干"); return _context4.abrupt("return", false); case 3: // if (knowledge.length < 1) { // message.info("请选择知识点"); // return false; // } normal_keywords = keyword[0]; main_keywords = keyword[1]; freeze.current = true; if (!editData.question_id) { _context4.next = 17; break; } if (!((editData === null || editData === void 0 ? void 0 : editData.is_my) === 1)) { _context4.next = 11; break; } modal/* default.confirm */.Z.confirm({ title: '提示', content: '此题目已存在于试题库,是否将修改后的题目覆盖试题库的原题?', okText: '覆盖原题', cancelText: '不覆盖', keyboard: false, onOk: function () { var _onOk = asyncToGenerator_default()( /*#__PURE__*/regeneratorRuntime_default()().mark(function _callee2() { var _exercise$editData2, _exercise$editData2$e; return regeneratorRuntime_default()().wrap(function _callee2$(_context2) { while (1) switch (_context2.prev = _context2.next) { case 0: _context2.next = 2; return dispatch({ type: "exercise/editExerciseQuestion", payload: { "id": editData.question_id, "question_title": title, "question_type": 4, "question_score": score, "standard_answers": [answer], "tag_discipline_ids": knowledge, "sub_discipline_id": (_exercise$editData2 = exercise.editData) === null || _exercise$editData2 === void 0 ? void 0 : (_exercise$editData2$e = _exercise$editData2.exercise) === null || _exercise$editData2$e === void 0 ? void 0 : _exercise$editData2$e.sub_discipline_id, "difficulty": difficulty, 'is_cover': 1, "repeat_answer": !repeat_answer, analysis: analysis, normal_keywords: normal_keywords, main_keywords: main_keywords } }); case 2: res = _context2.sent; repeal(res); case 4: case "end": return _context2.stop(); } }, _callee2); })); function onOk() { return _onOk.apply(this, arguments); } return onOk; }(), onCancel: function () { var _onCancel = asyncToGenerator_default()( /*#__PURE__*/regeneratorRuntime_default()().mark(function _callee3() { var _exercise$editData3, _exercise$editData3$e; return regeneratorRuntime_default()().wrap(function _callee3$(_context3) { while (1) switch (_context3.prev = _context3.next) { case 0: _context3.next = 2; return dispatch({ type: "exercise/editExerciseQuestion", payload: { "id": editData.question_id, "question_title": title, "question_type": 4, "question_score": score, "standard_answers": [answer], "tag_discipline_ids": knowledge, "sub_discipline_id": (_exercise$editData3 = exercise.editData) === null || _exercise$editData3 === void 0 ? void 0 : (_exercise$editData3$e = _exercise$editData3.exercise) === null || _exercise$editData3$e === void 0 ? void 0 : _exercise$editData3$e.sub_discipline_id, "difficulty": difficulty, "repeat_answer": !repeat_answer, analysis: analysis, normal_keywords: normal_keywords, main_keywords: main_keywords } }); case 2: res = _context3.sent; repeal(res); case 4: case "end": return _context3.stop(); } }, _callee3); })); function onCancel() { return _onCancel.apply(this, arguments); } return onCancel; }() }); _context4.next = 15; break; case 11: _context4.next = 13; return dispatch({ type: "exercise/editExerciseQuestion", payload: { "id": editData.question_id, "question_title": title, "question_type": 4, "question_score": score, "standard_answers": [answer], "tag_discipline_ids": knowledge, "sub_discipline_id": (_exercise$editData4 = exercise.editData) === null || _exercise$editData4 === void 0 ? void 0 : (_exercise$editData4$e = _exercise$editData4.exercise) === null || _exercise$editData4$e === void 0 ? void 0 : _exercise$editData4$e.sub_discipline_id, "difficulty": difficulty, "repeat_answer": !repeat_answer, analysis: analysis, normal_keywords: normal_keywords, main_keywords: main_keywords } }); case 13: res = _context4.sent; repeal(res); case 15: _context4.next = 21; break; case 17: _context4.next = 19; return dispatch({ type: "exercise/addExerciseQuestion", payload: { insert_id: editData === null || editData === void 0 ? void 0 : editData.insert_id, "categoryId": params.categoryId, "exercise_bank_id": params.categoryId, "question_title": title, "question_type": 4, "question_score": score, "standard_answers": [answer], "tag_discipline_ids": knowledge, "sub_discipline_id": (_exercise$editData5 = exercise.editData) === null || _exercise$editData5 === void 0 ? void 0 : (_exercise$editData5$e = _exercise$editData5.exercise) === null || _exercise$editData5$e === void 0 ? void 0 : _exercise$editData5$e.sub_discipline_id, "difficulty": difficulty, "repeat_answer": !repeat_answer, analysis: analysis, normal_keywords: normal_keywords, main_keywords: main_keywords } }); case 19: res = _context4.sent; repeal(res); case 21: return _context4.abrupt("return", { name: title, answer_texts: [answer], analysis: analysis, normal_keywords: normal_keywords, main_keywords: main_keywords }); case 22: case "end": return _context4.stop(); } }, _callee4); })); return function onSave() { return _ref2.apply(this, arguments); }; }(); var showEdit = function showEdit() { var _exercise$editData6, _exercise$editData6$e; return /*#__PURE__*/(0,jsx_runtime.jsxs)("aside", { children: [/*#__PURE__*/(0,jsx_runtime.jsx)("div", { className: editormodules.questionType, children: /*#__PURE__*/(0,jsx_runtime.jsxs)("div", { children: [/*#__PURE__*/(0,jsx_runtime.jsx)("span", { className: "font16 c-blue", children: "\u4E3B\u89C2\u9898" }), "\uFF08\u4E3B\u89C2\u9898\uFF0C\u672A\u4F5C\u7B54\u7684\u60C5\u51B5\u4E0B\u81EA\u52A8\u8BC4\u4E3A\u96F6\u5206\uFF09"] }) }), /*#__PURE__*/(0,jsx_runtime.jsx)(markdown_editor/* default */.Z, { id: "single-question-title", watch: true, height: 155, placeholder: "\u8BF7\u60A8\u8F93\u5165\u9898\u5E72", defaultValue: title, onChange: function onChange(value) { return setTitle(value); } }), /*#__PURE__*/(0,jsx_runtime.jsx)("p", { className: editormodules.titleWrap, children: /*#__PURE__*/(0,jsx_runtime.jsx)("span", { className: editormodules.title, children: "\u53C2\u8003\u7B54\u6848\uFF1A" }) }), /*#__PURE__*/(0,jsx_runtime.jsx)(markdown_editor/* default */.Z, { id: "single-question-reference-answer", watch: true, height: 155, placeholder: "\u8BF7\u60A8\u8F93\u5165\u53C2\u8003\u7B54\u6848", defaultValue: answer, onChange: function onChange(value) { return setAnswer(value); } }), /*#__PURE__*/(0,jsx_runtime.jsx)(EditorKeyword/* default */.Z, { value: keyword, onChange: setKeyword }), /*#__PURE__*/(0,jsx_runtime.jsx)("p", { className: editormodules.titleWrap, children: /*#__PURE__*/(0,jsx_runtime.jsx)("span", { className: editormodules.title, children: "\u9898\u76EE\u89E3\u6790\uFF1A" }) }), /*#__PURE__*/(0,jsx_runtime.jsx)(markdown_editor/* default */.Z, { id: "single-question-title", watch: true, height: 155, placeholder: "\u8BF7\u60A8\u8F93\u5165\u9898\u76EE\u89E3\u6790", defaultValue: analysis, onChange: function onChange(value) { return setAnalysis(value); } }), /*#__PURE__*/(0,jsx_runtime.jsxs)("p", { className: "", children: ["\u5206\u503C\uFF1A", /*#__PURE__*/(0,jsx_runtime.jsx)(input_number/* default */.Z, { value: score, max: 10000, min: 0, onChange: function onChange(value) { setScore(value); } }), " \u5206", /*#__PURE__*/(0,jsx_runtime.jsxs)("span", { style: { marginLeft: '30px' }, className: editormodules.difficult, children: [/*#__PURE__*/(0,jsx_runtime.jsx)("label", { style: { color: 'red' }, children: "*" }), " \u96BE\u5EA6\uFF1A", /*#__PURE__*/(0,jsx_runtime.jsxs)(es_radio/* default.Group */.ZP.Group, { value: difficulty, onChange: function onChange(e) { setdifficult(e.target.value); }, children: [/*#__PURE__*/(0,jsx_runtime.jsx)(es_radio/* default.Button */.ZP.Button, { value: 1, children: "\u7B80\u5355" }), /*#__PURE__*/(0,jsx_runtime.jsx)(es_radio/* default.Button */.ZP.Button, { value: 2, children: "\u9002\u4E2D" }), /*#__PURE__*/(0,jsx_runtime.jsx)(es_radio/* default.Button */.ZP.Button, { value: 3, children: "\u56F0\u96BE" })] })] })] }), /*#__PURE__*/(0,jsx_runtime.jsxs)("p", { className: editormodules.titleWrap, children: [/*#__PURE__*/(0,jsx_runtime.jsxs)("span", { className: "".concat(editormodules.title), children: ["\u77E5\u8BC6\u70B9\uFF1A", /*#__PURE__*/(0,jsx_runtime.jsx)("span", { className: editormodules.colorGray, children: "\uFF08\u6240\u6709\u81EA\u5EFA\u77E5\u8BC6\u70B9\u4EC5\u672C\u4EBA\u53EF\u89C1\uFF0C\u88ABEduCoder\u5E73\u53F0\u5BA1\u6838\u901A\u8FC7\u4E3A\u5B98\u65B9\u77E5\u8BC6\u70B9\u540E\u6240\u6709\u7528\u6237\u53EF\u89C1\uFF09" })] }), /*#__PURE__*/(0,jsx_runtime.jsx)("div", { className: "mt5", children: /*#__PURE__*/(0,jsx_runtime.jsx)(Knowledge/* Knowledge */.N, { value: knowledge, selectvalues: editData === null || editData === void 0 ? void 0 : editData.tag_discipline_ids, onChange: setKnowledge, subId: (_exercise$editData6 = exercise.editData) === null || _exercise$editData6 === void 0 ? void 0 : (_exercise$editData6$e = _exercise$editData6.exercise) === null || _exercise$editData6$e === void 0 ? void 0 : _exercise$editData6$e.sub_discipline_id, knowledgeOptions: knowledgeOptions, onAddKnowledgeFinish: handleAddKnowledgeFinish }) }), /*#__PURE__*/(0,jsx_runtime.jsxs)("div", { style: { marginTop: 10 }, children: [/*#__PURE__*/(0,jsx_runtime.jsx)("span", { style: { marginRight: 10 }, children: "\u4E0D\u5141\u8BB8\u5B66\u751F\u91CD\u590D\u7B54\u9898" }), /*#__PURE__*/(0,jsx_runtime.jsx)(es_switch/* default */.Z, { checked: repeat_answer, onChange: function onChange(e) { setrepeat_answer(e); } })] })] }), /*#__PURE__*/(0,jsx_runtime.jsxs)("aside", { className: "tr", children: [(editKey !== -1 || editData.question_id) && /*#__PURE__*/(0,jsx_runtime.jsx)(es_button/* default */.Z, { type: "default", onClick: function onClick() { cancelAdd(); setIsEdit(false); }, children: "\u53D6\u6D88" }), /*#__PURE__*/(0,jsx_runtime.jsx)(es_button/* default */.Z, { className: "ml20", type: "primary", onClick: function onClick() { onSave(); }, children: "\u4FDD\u5B58" })] })] }); }; var actionArr = [{ name: "删除", icon: "iconfont c-light-black ml30 icon-shanchu current", id: "del" }, // { name: "上移", icon: "iconfont c-green ml30 icon-shangyi_Hover", id: "up" }, // { name: "下移", icon: "iconfont c-green ml30 icon-xiayi_moren", id: "down" }, { name: "(向下插入单选题)", icon: "iconfont c-light-primary ml30 icon-tianjia current", id: "add" }, { name: "编辑", icon: "iconfont c-light-primary ml30 icon-bianjishijuan3x current", id: "edit" }].filter(function (item) { var _exercise$editData7, _exercise$editData7$e; if ((exercise === null || exercise === void 0 ? void 0 : (_exercise$editData7 = exercise.editData) === null || _exercise$editData7 === void 0 ? void 0 : (_exercise$editData7$e = _exercise$editData7.exercise) === null || _exercise$editData7$e === void 0 ? void 0 : _exercise$editData7$e.exercise_status) === 1) { return item; } else { return item.id !== 'del' && item.id !== 'add'; } }); var actionClick = /*#__PURE__*/function () { var _ref3 = asyncToGenerator_default()( /*#__PURE__*/regeneratorRuntime_default()().mark(function _callee6(item) { return regeneratorRuntime_default()().wrap(function _callee6$(_context6) { while (1) switch (_context6.prev = _context6.next) { case 0: if (!(editKey !== -1)) { _context6.next = 3; break; } message/* default.error */.ZP.error("请先保存或取消当前正在编辑的问题。"); return _context6.abrupt("return"); case 3: _context6.t0 = item.id; _context6.next = _context6.t0 === "del" ? 6 : _context6.t0 === "up" ? 8 : _context6.t0 === "down" ? 8 : _context6.t0 === "edit" ? 12 : _context6.t0 === "add" ? 15 : 17; break; case 6: modal/* default.confirm */.Z.confirm({ centered: true, okText: '确定', cancelText: '取消', title: '确认要删除这个试题吗?', onOk: function onOk() { return asyncToGenerator_default()( /*#__PURE__*/regeneratorRuntime_default()().mark(function _callee5() { return regeneratorRuntime_default()().wrap(function _callee5$(_context5) { while (1) switch (_context5.prev = _context5.next) { case 0: _context5.next = 2; return (0,service_exercise/* exeriseQuestionDelete */.Fl)({ id: editData.question_id }); case 2: dispatch({ type: "exercise/editExercise", payload: objectSpread2_default()({}, params) }); case 3: case "end": return _context5.stop(); } }, _callee5); }))(); } }); return _context6.abrupt("break", 17); case 8: _context6.next = 10; return dispatch({ type: "exercise/exeriseMoveUpDown", payload: { id: editData.question_id, opr: item.id } }); case 10: dispatch({ type: "exercise/editExercise", payload: objectSpread2_default()({}, params) }); return _context6.abrupt("break", 17); case 12: setEditKey(editData.dragKey); setIsEdit(true); return _context6.abrupt("break", 17); case 15: addCallback({ key: editData.key, insert_id: editData === null || editData === void 0 ? void 0 : editData.question_id, question_type: 4 }); return _context6.abrupt("break", 17); case 17: case "end": return _context6.stop(); } }, _callee6); })); return function actionClick(_x) { return _ref3.apply(this, arguments); }; }(); var showList = function showList() { return /*#__PURE__*/(0,jsx_runtime.jsxs)("aside", { children: [/*#__PURE__*/(0,jsx_runtime.jsx)("div", { className: editormodules.questionType, children: !(editData !== null && editData !== void 0 && editData.isPreview) && /*#__PURE__*/(0,jsx_runtime.jsxs)("div", { children: [/*#__PURE__*/(0,jsx_runtime.jsxs)("span", { className: "font16 c-blue", children: [editData.key, "\u3001\u7B80\u7B54\u9898"] }), "\uFF08", editData.question_score, "\u5206\uFF09"] }) }), editData !== null && editData !== void 0 && editData.isPreview ? /*#__PURE__*/(0,jsx_runtime.jsxs)("div", { style: { display: 'flex' }, children: [/*#__PURE__*/(0,jsx_runtime.jsxs)("span", { style: { flexShrink: 0 }, className: "font18", children: [editData.key, "."] }), /*#__PURE__*/(0,jsx_runtime.jsx)(RenderHtml/* default */.Z, { value: editData.question_title }), /*#__PURE__*/(0,jsx_runtime.jsxs)("span", { style: { flexShrink: 0 }, className: "font16", children: ["\uFF08", editData.question_score, "\u5206\uFF09"] })] }) : /*#__PURE__*/(0,jsx_runtime.jsx)("div", { className: "mt5", children: /*#__PURE__*/(0,jsx_runtime.jsx)(RenderHtml/* default */.Z, { value: editData.question_title }) }), /*#__PURE__*/(0,jsx_runtime.jsxs)("div", { className: editormodules.questionChoices, children: [/*#__PURE__*/(0,jsx_runtime.jsx)("p", { children: /*#__PURE__*/(0,jsx_runtime.jsx)("strong", { children: "\u53C2\u8003\u7B54\u6848\uFF1A" }) }), /*#__PURE__*/(0,jsx_runtime.jsx)(RenderHtml/* default */.Z, { value: answer || '' })] }), /*#__PURE__*/(0,jsx_runtime.jsx)("div", { className: editormodules.action, children: !editData.hideAction && actionArr.map(function (item, index) { if (item.id === "up" && editData.key === 1) return null; if (item.id === "down" && editData.key === editData.len) return null; return /*#__PURE__*/(0,jsx_runtime.jsx)(tooltip/* default */.Z, { placement: "bottom", title: item.name, children: /*#__PURE__*/(0,jsx_runtime.jsx)("span", { onClick: function onClick() { return actionClick(item); }, className: item.icon }) }, index); }) })] }); }; return /*#__PURE__*/(0,jsx_runtime.jsxs)("section", { className: editormodules.wrap, children: [!isEdit && showList(), isEdit && showEdit()] }); }; /* harmony default export */ var components_SubjectiveEditor = ((0,_umi_production_exports.connect)(function (_ref4) { var problemset = _ref4.problemset, loading = _ref4.loading, exercise = _ref4.exercise, globalSetting = _ref4.globalSetting; return { problemset: problemset, globalSetting: globalSetting, exercise: exercise, loading: loading.effects }; }, null, null, { forwardRef: true })( /*#__PURE__*/(0,react.forwardRef)(SubjectiveEditor))); ;// CONCATENATED MODULE: ./src/pages/Classrooms/Lists/Exercise/Edit/components/ProgrammingEditor/index.tsx var ProgrammingEditor_excluded = ["problemset", "exercise", "globalSetting", "loading", "dispatch", "onRef", "editData", "cancelAdd", "editKey", "setEditKey", "addCallback", "setIsClaer"]; var ProgrammingEditor_tagList = ['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']; var ProgrammingEditor_SingleEditor = function SingleEditor(_ref, ref) { var problemset = _ref.problemset, exercise = _ref.exercise, globalSetting = _ref.globalSetting, loading = _ref.loading, dispatch = _ref.dispatch, _ref$onRef = _ref.onRef, onRef = _ref$onRef === void 0 ? function () {} : _ref$onRef, editData = _ref.editData, _ref$cancelAdd = _ref.cancelAdd, cancelAdd = _ref$cancelAdd === void 0 ? function () {} : _ref$cancelAdd, editKey = _ref.editKey, _ref$setEditKey = _ref.setEditKey, setEditKey = _ref$setEditKey === void 0 ? function () {} : _ref$setEditKey, _ref$addCallback = _ref.addCallback, addCallback = _ref$addCallback === void 0 ? function () {} : _ref$addCallback, _ref$setIsClaer = _ref.setIsClaer, setIsClaer = _ref$setIsClaer === void 0 ? function () {} : _ref$setIsClaer, props = objectWithoutProperties_default()(_ref, ProgrammingEditor_excluded); var _useState = (0,react.useState)([]), _useState2 = slicedToArray_default()(_useState, 2), questionChoiceList = _useState2[0], setQuestionChoiceList = _useState2[1]; var _useState3 = (0,react.useState)(), _useState4 = slicedToArray_default()(_useState3, 2), activeEditor = _useState4[0], setActiveEditor = _useState4[1]; var _useState5 = (0,react.useState)([]), _useState6 = slicedToArray_default()(_useState5, 2), activeAnswer = _useState6[0], setActiveAnswer = _useState6[1]; var _useState7 = (0,react.useState)(''), _useState8 = slicedToArray_default()(_useState7, 2), title = _useState8[0], setTitle = _useState8[1]; var _useState9 = (0,react.useState)(5), _useState10 = slicedToArray_default()(_useState9, 2), score = _useState10[0], setScore = _useState10[1]; var _useState11 = (0,react.useState)(false), _useState12 = slicedToArray_default()(_useState11, 2), isEdit = _useState12[0], setIsEdit = _useState12[1]; var params = (0,_umi_production_exports.useParams)(); (0,react.useEffect)(function () { setQuestionChoiceList(['', '', '', '']); }, []); (0,react.useEffect)(function () { if (!(editData !== null && editData !== void 0 && editData.question_choices)) { setIsEdit(true); setTitle(''); setScore(5); setQuestionChoiceList(['', '', '', '']); setActiveAnswer([]); return; } setTitle(editData === null || editData === void 0 ? void 0 : editData.question_title); setScore(editData === null || editData === void 0 ? void 0 : editData.question_score); setQuestionChoiceList(editData === null || editData === void 0 ? void 0 : editData.question_choices.map(function (item) { return item.choice_text; })); var answerIndexs = []; editData === null || editData === void 0 ? void 0 : editData.standard_answer.map(function (item, index) { answerIndexs.push(item - 1); }); setActiveAnswer(answerIndexs); }, [editData]); (0,react.useImperativeHandle)(ref, function () { return { onSave: onSave, isEdit: isEdit }; }); var onSave = /*#__PURE__*/function () { var _ref2 = asyncToGenerator_default()( /*#__PURE__*/regeneratorRuntime_default()().mark(function _callee() { var findNotAnswerIndex, choices, res; return regeneratorRuntime_default()().wrap(function _callee$(_context) { while (1) switch (_context.prev = _context.next) { case 0: if (title) { _context.next = 3; break; } message/* default.info */.ZP.info("请您输入题目"); return _context.abrupt("return", false); case 3: findNotAnswerIndex = questionChoiceList.findIndex(function (item) { return !item; }); if (!(findNotAnswerIndex > -1)) { _context.next = 7; break; } message/* default.info */.ZP.info("\u8BF7\u5148\u8F93\u5165 ".concat(ProgrammingEditor_tagList[findNotAnswerIndex], " \u9009\u9879\u7684\u5185\u5BB9")); return _context.abrupt("return", false); case 7: if (activeAnswer.length) { _context.next = 10; break; } message/* default.info */.ZP.info("请设置本题的正确答案,点击选项A/B...即可完成设置"); return _context.abrupt("return", false); case 10: if (!(activeAnswer.length < 1)) { _context.next = 13; break; } message/* default.info */.ZP.info("请选择答案"); return _context.abrupt("return", false); case 13: choices = questionChoiceList.map(function (item, index) { return { choice_text: item, is_answer: activeAnswer.includes(index) ? index + 1 : 0 }; }); if (!editData.question_id) { _context.next = 20; break; } _context.next = 17; return dispatch({ type: "exercise/editExerciseQuestion", payload: { "id": editData.question_id, "question_title": title, "question_type": 1, "question_score": score, "question_choices": choices.map(function (item) { return item.choice_text; }), "standard_answers": choices.filter(function (item) { return item.is_answer; }).map(function (item) { return item.is_answer; }) } }); case 17: res = _context.sent; _context.next = 23; break; case 20: _context.next = 22; return dispatch({ type: "exercise/addExerciseQuestion", payload: { insert_id: editData === null || editData === void 0 ? void 0 : editData.insert_id, "categoryId": params.categoryId, "question_title": title, "question_type": 1, "question_score": "5.0", "question_choices": choices.map(function (item) { return item.choice_text; }), "standard_answers": choices.filter(function (item) { return item.is_answer; }).map(function (item) { return item.is_answer; }) } }); case 22: res = _context.sent; case 23: if (res.status === 0) { message/* default.success */.ZP.success("保存成功"); setIsEdit(false); dispatch({ type: "exercise/editExercise", payload: objectSpread2_default()({}, params) }); } case 24: case "end": return _context.stop(); } }, _callee); })); return function onSave() { return _ref2.apply(this, arguments); }; }(); var actionArr = [{ name: "删除", icon: "iconfont c-light-black ml30 icon-shanchu current", id: "del" }, // { name: "上移", icon: "iconfont c-green ml30 icon-shangyi_Hover", id: "up" }, // { name: "下移", icon: "iconfont c-green ml30 icon-xiayi_moren", id: "down" }, { name: "(向下插入单选题)", icon: "iconfont c-light-primary ml30 icon-tianjia current", id: "add" }, { name: "编辑", icon: "iconfont c-light-primary ml30 icon-bianjishijuan3x current", id: "edit" }].filter(function (item) { var _exercise$editData, _exercise$editData$ex; if ((exercise === null || exercise === void 0 ? void 0 : (_exercise$editData = exercise.editData) === null || _exercise$editData === void 0 ? void 0 : (_exercise$editData$ex = _exercise$editData.exercise) === null || _exercise$editData$ex === void 0 ? void 0 : _exercise$editData$ex.exercise_status) === 1) { return item; } else { return item.id !== 'del' && item.id !== 'add'; } }); var actionClick = /*#__PURE__*/function () { var _ref3 = asyncToGenerator_default()( /*#__PURE__*/regeneratorRuntime_default()().mark(function _callee3(item) { return regeneratorRuntime_default()().wrap(function _callee3$(_context3) { while (1) switch (_context3.prev = _context3.next) { case 0: if (!(editKey !== -1)) { _context3.next = 3; break; } message/* default.error */.ZP.error("请先保存或取消当前正在编辑的问题。"); return _context3.abrupt("return"); case 3: _context3.t0 = item.id; _context3.next = _context3.t0 === "del" ? 6 : _context3.t0 === "up" ? 8 : _context3.t0 === "down" ? 8 : _context3.t0 === "edit" ? 12 : _context3.t0 === "add" ? 14 : 16; break; case 6: modal/* default.confirm */.Z.confirm({ centered: true, okText: '确定', cancelText: '取消', title: '确认要删除这个试题吗?', onOk: function onOk() { return asyncToGenerator_default()( /*#__PURE__*/regeneratorRuntime_default()().mark(function _callee2() { return regeneratorRuntime_default()().wrap(function _callee2$(_context2) { while (1) switch (_context2.prev = _context2.next) { case 0: _context2.next = 2; return (0,service_exercise/* exeriseQuestionDelete */.Fl)({ id: editData.question_id }); case 2: dispatch({ type: "exercise/editExercise", payload: objectSpread2_default()({}, params) }); case 3: case "end": return _context2.stop(); } }, _callee2); }))(); } }); return _context3.abrupt("break", 16); case 8: _context3.next = 10; return dispatch({ type: "exercise/exeriseMoveUpDown", payload: { id: editData.question_id, opr: item.id } }); case 10: dispatch({ type: "exercise/editExercise", payload: objectSpread2_default()({}, params) }); return _context3.abrupt("break", 16); case 12: _umi_production_exports.history.push("/problems/".concat(editData === null || editData === void 0 ? void 0 : editData.hack_identifier, "/edit?type=exercises&express_id=").concat(params.categoryId, "&question_id=").concat(editData === null || editData === void 0 ? void 0 : editData.question_id, "&score=").concat(editData === null || editData === void 0 ? void 0 : editData.question_score, "&exercise=true&callback_url=").concat(location.pathname)); return _context3.abrupt("break", 16); case 14: addCallback({ key: editData.key, insert_id: editData === null || editData === void 0 ? void 0 : editData.question_id, question_type: 6 }); return _context3.abrupt("break", 16); case 16: case "end": return _context3.stop(); } }, _callee3); })); return function actionClick(_x) { return _ref3.apply(this, arguments); }; }(); var handleClick = /*#__PURE__*/function () { var _ref4 = asyncToGenerator_default()( /*#__PURE__*/regeneratorRuntime_default()().mark(function _callee4(e) { var res; return regeneratorRuntime_default()().wrap(function _callee4$(_context4) { while (1) switch (_context4.prev = _context4.next) { case 0: e.preventDefault(); _context4.next = 3; return (0,service_exercise/* startProgram */.nF)({ id: editData === null || editData === void 0 ? void 0 : editData.hack_identifier }); case 3: res = _context4.sent; res.status === 0 && (0,util/* openNewWindow */.xg)("/myproblems/".concat(res === null || res === void 0 ? void 0 : res.identifier)); case 5: case "end": return _context4.stop(); } }, _callee4); })); return function handleClick(_x2) { return _ref4.apply(this, arguments); }; }(); var showList = function showList() { return /*#__PURE__*/(0,jsx_runtime.jsxs)("aside", { children: [/*#__PURE__*/(0,jsx_runtime.jsx)("div", { className: editormodules.questionType, children: !(editData !== null && editData !== void 0 && editData.isPreview) && /*#__PURE__*/(0,jsx_runtime.jsxs)("div", { children: [/*#__PURE__*/(0,jsx_runtime.jsxs)("span", { className: "font16 c-blue", children: [editData.key, "\u3001\u7F16\u7A0B\u9898"] }), "\uFF08", editData.question_score, "\u5206\uFF09"] }) }), editData !== null && editData !== void 0 && editData.isPreview ? /*#__PURE__*/(0,jsx_runtime.jsxs)("div", { style: { display: 'flex' }, children: [/*#__PURE__*/(0,jsx_runtime.jsxs)("span", { style: { flexShrink: 0 }, className: "font18", children: [editData.key, "."] }), /*#__PURE__*/(0,jsx_runtime.jsx)(RenderHtml/* default */.Z, { value: editData.question_title }), /*#__PURE__*/(0,jsx_runtime.jsxs)("span", { style: { flexShrink: 0 }, className: "font16", children: ["\uFF08", editData.question_score, "\u5206\uFF09"] })] }) : /*#__PURE__*/(0,jsx_runtime.jsx)("div", { className: "mt5", children: /*#__PURE__*/(0,jsx_runtime.jsx)(RenderHtml/* default */.Z, { value: editData.question_title }) }), /*#__PURE__*/(0,jsx_runtime.jsx)("div", { className: editormodules.questionChoices, children: /*#__PURE__*/(0,jsx_runtime.jsx)(RenderHtml/* default */.Z, { value: editData.description || '' }) }), /*#__PURE__*/(0,jsx_runtime.jsx)("div", { className: editormodules.action, children: !editData.hideAction && actionArr.map(function (item, index) { if (item.id === "up" && editData.key === 1) return null; if (item.id === "down" && editData.key === editData.len) return null; return /*#__PURE__*/(0,jsx_runtime.jsx)(tooltip/* default */.Z, { placement: "bottom", title: item.name, children: /*#__PURE__*/(0,jsx_runtime.jsx)("span", { onClick: function onClick() { return actionClick(item); }, className: item.icon }) }, index); }) })] }); }; return /*#__PURE__*/(0,jsx_runtime.jsx)("section", { className: editormodules.wrap, children: showList() }); }; /* harmony default export */ var ProgrammingEditor = ((0,_umi_production_exports.connect)(function (_ref5) { var problemset = _ref5.problemset, loading = _ref5.loading, globalSetting = _ref5.globalSetting, exercise = _ref5.exercise; return { problemset: problemset, globalSetting: globalSetting, exercise: exercise, loading: loading.effects }; }, null, null, { forwardRef: true })( /*#__PURE__*/(0,react.forwardRef)(ProgrammingEditor_SingleEditor))); // EXTERNAL MODULE: ./node_modules/lodash/lodash.js var lodash = __webpack_require__(96486); ;// CONCATENATED MODULE: ./src/pages/Classrooms/Lists/Exercise/Edit/components/CombinationEditor/index.tsx var CombinationEditor_excluded = ["problemset", "exercise", "globalSetting", "loading", "dispatch", "onRef", "editData", "cancelAdd", "editKey", "setEditKey", "setIsClaer", "addCallback", "reload"]; var CombinationEditor_tagList = ['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']; var CombinationEditor = function CombinationEditor(_ref, ref) { var problemset = _ref.problemset, exercise = _ref.exercise, globalSetting = _ref.globalSetting, loading = _ref.loading, dispatch = _ref.dispatch, _ref$onRef = _ref.onRef, onRef = _ref$onRef === void 0 ? function () {} : _ref$onRef, editData = _ref.editData, _ref$cancelAdd = _ref.cancelAdd, cancelAdd = _ref$cancelAdd === void 0 ? function () {} : _ref$cancelAdd, editKey = _ref.editKey, _ref$setEditKey = _ref.setEditKey, setEditKey = _ref$setEditKey === void 0 ? function () {} : _ref$setEditKey, _ref$setIsClaer = _ref.setIsClaer, setIsClaer = _ref$setIsClaer === void 0 ? function () {} : _ref$setIsClaer, _ref$addCallback = _ref.addCallback, addCallback = _ref$addCallback === void 0 ? function (data) {} : _ref$addCallback, _ref$reload = _ref.reload, reload = _ref$reload === void 0 ? function () {} : _ref$reload, props = objectWithoutProperties_default()(_ref, CombinationEditor_excluded); var _useState = (0,react.useState)([]), _useState2 = slicedToArray_default()(_useState, 2), knowledge = _useState2[0], setKnowledge = _useState2[1]; var _useState3 = (0,react.useState)(false), _useState4 = slicedToArray_default()(_useState3, 2), isEdit = _useState4[0], setIsEdit = _useState4[1]; var _useState5 = (0,react.useState)(true), _useState6 = slicedToArray_default()(_useState5, 2), show = _useState6[0], setShow = _useState6[1]; var _useState7 = (0,react.useState)(1), _useState8 = slicedToArray_default()(_useState7, 2), difficulty = _useState8[0], setdifficult = _useState8[1]; var _useState9 = (0,react.useState)(false), _useState10 = slicedToArray_default()(_useState9, 2), repeat_answer = _useState10[0], setrepeat_answer = _useState10[1]; var _useState11 = (0,react.useState)([]), _useState12 = slicedToArray_default()(_useState11, 2), knowledgeOptions = _useState12[0], setKnowledgeOptions = _useState12[1]; var params = (0,_umi_production_exports.useParams)(); var dom = (0,react.useRef)(null); var _useState13 = (0,react.useState)(''), _useState14 = slicedToArray_default()(_useState13, 2), name = _useState14[0], setName = _useState14[1]; var _useState15 = (0,react.useState)([]), _useState16 = slicedToArray_default()(_useState15, 2), questionList = _useState16[0], setQuestionList = _useState16[1]; var freeze = (0,react.useRef)(false); var handleAddKnowledgeFinish = function handleAddKnowledgeFinish(item) { setKnowledgeOptions([].concat(toConsumableArray_default()(knowledgeOptions), [objectSpread2_default()({}, item)])); }; (0,react.useEffect)(function () { var _editData$sub_exercis; if (freeze.current) return; if (!(editData !== null && editData !== void 0 && editData.question_title)) { setIsEdit(true); setName(''); return; } setName(editData === null || editData === void 0 ? void 0 : editData.question_title); setrepeat_answer(!(editData !== null && editData !== void 0 && editData.repeat_answer)); setdifficult(editData === null || editData === void 0 ? void 0 : editData.difficulty); setKnowledge(editData.tag_discipline_ids); var list = editData === null || editData === void 0 ? void 0 : (_editData$sub_exercis = editData.sub_exercise_questions) === null || _editData$sub_exercis === void 0 ? void 0 : _editData$sub_exercis.map(function (k) { var _k$question_choices, _ref2, _k$question_choices2; return objectSpread2_default()(objectSpread2_default()({}, k), {}, { id: k.question_id, name: k.question_title, open: false, score: k.question_score, qusList: k === null || k === void 0 ? void 0 : (_k$question_choices = k.question_choices) === null || _k$question_choices === void 0 ? void 0 : _k$question_choices.map(function (e) { return e.choice_text; }), activeQusEditor: null, qusAnswer: (_ref2 = [k === null || k === void 0 ? void 0 : (_k$question_choices2 = k.question_choices) === null || _k$question_choices2 === void 0 ? void 0 : _k$question_choices2.findIndex(function (e) { return e.standard_boolean; })]) === null || _ref2 === void 0 ? void 0 : _ref2.filter(function (k) { return k !== -1; }) }); }); setQuestionList(list); }, [editData, isEdit]); (0,react.useEffect)(function () { if (isEdit) { init(); } function init() { return _init.apply(this, arguments); } function _init() { _init = asyncToGenerator_default()( /*#__PURE__*/regeneratorRuntime_default()().mark(function _callee() { var _exercise$editData, _exercise$editData$ex; var res; return regeneratorRuntime_default()().wrap(function _callee$(_context) { while (1) switch (_context.prev = _context.next) { case 0: _context.next = 2; return (0,service_exercise/* getTagDiscipline */.YY)({ sub_discipline_id: (_exercise$editData = exercise.editData) === null || _exercise$editData === void 0 ? void 0 : (_exercise$editData$ex = _exercise$editData.exercise) === null || _exercise$editData$ex === void 0 ? void 0 : _exercise$editData$ex.sub_discipline_id }); case 2: res = _context.sent; setKnowledgeOptions(res.tag_disciplines); case 4: case "end": return _context.stop(); } }, _callee); })); return _init.apply(this, arguments); } }, [isEdit]); (0,react.useEffect)(function () { var _exercise$tagDiscipli; var data = exercise !== null && exercise !== void 0 && (_exercise$tagDiscipli = exercise.tagDisciplineData) !== null && _exercise$tagDiscipli !== void 0 && _exercise$tagDiscipli.tag_disciplines && Array.isArray(exercise.tagDisciplineData.tag_disciplines) ? exercise.tagDisciplineData.tag_disciplines : []; setKnowledgeOptions(data); }, [exercise.tagDisciplineData]); (0,react.useImperativeHandle)(ref, function () { return { onSave: onSave, isEdit: isEdit }; }); var repeal = function repeal(res) { if ((res === null || res === void 0 ? void 0 : res.status) === 0) { message/* default.success */.ZP.success("保存成功"); setIsEdit(false); setEditKey(-1); freeze.current = false; reload(); } }; var onSave = /*#__PURE__*/function () { var _ref3 = asyncToGenerator_default()( /*#__PURE__*/regeneratorRuntime_default()().mark(function _callee4() { var i, _param$qusList, param, findNotAnswerIndex, sub_questions, res, _exercise$editData4, _exercise$editData4$e; return regeneratorRuntime_default()().wrap(function _callee4$(_context4) { while (1) switch (_context4.prev = _context4.next) { case 0: if (name) { _context4.next = 3; break; } message/* default.info */.ZP.info('请您输入题干'); return _context4.abrupt("return", false); case 3: if (!(questionList.length === 0)) { _context4.next = 6; break; } message/* default.info */.ZP.info('请您添加小题'); return _context4.abrupt("return", false); case 6: i = 0; case 7: if (!(i < questionList.length)) { _context4.next = 25; break; } param = questionList[i]; if (param !== null && param !== void 0 && param.name) { _context4.next = 12; break; } message/* default.info */.ZP.info("\u8BF7\u60A8\u8F93\u5165\u7B2C".concat(i + 1, "\u5C0F\u9898\u9898\u5E72")); return _context4.abrupt("return", false); case 12: if (param !== null && param !== void 0 && param.score) { _context4.next = 15; break; } message/* default.info */.ZP.info("\u7B2C".concat(i + 1, "\u5C0F\u9898\u5206\u6570\u4E0D\u80FD\u4E3A0\u6216\u7A7A")); return _context4.abrupt("return", false); case 15: findNotAnswerIndex = param === null || param === void 0 ? void 0 : (_param$qusList = param.qusList) === null || _param$qusList === void 0 ? void 0 : _param$qusList.findIndex(function (item) { return !item; }); if (!(findNotAnswerIndex > -1)) { _context4.next = 19; break; } message/* default.info */.ZP.info("\u8BF7\u5148\u8F93\u5165\u7B2C".concat(i + 1, "\u5C0F\u9898").concat(CombinationEditor_tagList[findNotAnswerIndex], "\u9009\u9879\u7684\u5185\u5BB9")); return _context4.abrupt("return", false); case 19: if (param !== null && param !== void 0 && param.qusAnswer.length) { _context4.next = 22; break; } message/* default.info */.ZP.info("\u8BF7\u8BBE\u7F6E\u7B2C".concat(i + 1, "\u5C0F\u9898\u7684\u6B63\u786E\u7B54\u6848\uFF0C\u70B9\u51FB\u9009\u9879A/B...\u5373\u53EF\u5B8C\u6210\u8BBE\u7F6E")); return _context4.abrupt("return", false); case 22: i++; _context4.next = 7; break; case 25: sub_questions = questionList.map(function (e) { var _e$qusAnswer; return { id: e.id > 1 ? e.id : null, question_title: e.name, question_type: 1, question_choices: e.qusList, question_score: e.score, standard_answers: [((_e$qusAnswer = e.qusAnswer) === null || _e$qusAnswer === void 0 ? void 0 : _e$qusAnswer[0]) + 1] }; }); freeze.current = true; if (!editData.question_id) { _context4.next = 36; break; } if (!((editData === null || editData === void 0 ? void 0 : editData.is_my) === 1)) { _context4.next = 32; break; } modal/* default.confirm */.Z.confirm({ title: '提示', content: '此题目已存在于试题库,是否将修改后的题目覆盖试题库的原题?', okText: '覆盖原题', cancelText: '不覆盖', keyboard: false, onOk: function () { var _onOk = asyncToGenerator_default()( /*#__PURE__*/regeneratorRuntime_default()().mark(function _callee2() { var _exercise$editData2, _exercise$editData2$e; return regeneratorRuntime_default()().wrap(function _callee2$(_context2) { while (1) switch (_context2.prev = _context2.next) { case 0: _context2.next = 2; return dispatch({ type: 'exercise/editExerciseQuestion', payload: { id: editData.question_id, question_title: name, question_type: 7, sub_questions: sub_questions, tag_discipline_ids: knowledge, sub_discipline_id: (_exercise$editData2 = exercise.editData) === null || _exercise$editData2 === void 0 ? void 0 : (_exercise$editData2$e = _exercise$editData2.exercise) === null || _exercise$editData2$e === void 0 ? void 0 : _exercise$editData2$e.sub_discipline_id, difficulty: difficulty, is_cover: 1, repeat_answer: !repeat_answer } }); case 2: res = _context2.sent; repeal(res); case 4: case "end": return _context2.stop(); } }, _callee2); })); function onOk() { return _onOk.apply(this, arguments); } return onOk; }(), onCancel: function () { var _onCancel = asyncToGenerator_default()( /*#__PURE__*/regeneratorRuntime_default()().mark(function _callee3() { var _exercise$editData3, _exercise$editData3$e; return regeneratorRuntime_default()().wrap(function _callee3$(_context3) { while (1) switch (_context3.prev = _context3.next) { case 0: _context3.next = 2; return dispatch({ type: 'exercise/editExerciseQuestion', payload: { id: editData.question_id, question_title: name, question_type: 7, sub_questions: sub_questions, tag_discipline_ids: knowledge, sub_discipline_id: (_exercise$editData3 = exercise.editData) === null || _exercise$editData3 === void 0 ? void 0 : (_exercise$editData3$e = _exercise$editData3.exercise) === null || _exercise$editData3$e === void 0 ? void 0 : _exercise$editData3$e.sub_discipline_id, difficulty: difficulty, repeat_answer: !repeat_answer } }); case 2: res = _context3.sent; repeal(res); case 4: case "end": return _context3.stop(); } }, _callee3); })); function onCancel() { return _onCancel.apply(this, arguments); } return onCancel; }() }); _context4.next = 36; break; case 32: _context4.next = 34; return dispatch({ type: 'exercise/editExerciseQuestion', payload: { id: editData.question_id, question_title: name, question_type: 7, sub_questions: sub_questions, tag_discipline_ids: knowledge, sub_discipline_id: (_exercise$editData4 = exercise.editData) === null || _exercise$editData4 === void 0 ? void 0 : (_exercise$editData4$e = _exercise$editData4.exercise) === null || _exercise$editData4$e === void 0 ? void 0 : _exercise$editData4$e.sub_discipline_id, difficulty: difficulty, repeat_answer: !repeat_answer } }); case 34: res = _context4.sent; repeal(res); case 36: case "end": return _context4.stop(); } }, _callee4); })); return function onSave() { return _ref3.apply(this, arguments); }; }(); var actionArr = [{ name: '删除', icon: 'iconfont c-light-black ml30 icon-shanchu current', id: 'del' }, // { name: "上移", icon: "iconfont c-green ml30 icon-shangyi_Hover", id: "up" }, // { name: "下移", icon: "iconfont c-green ml30 icon-xiayi_moren", id: "down" }, // { name: "(向下插入单选题)", icon: "iconfont c-light-primary ml30 icon-tianjia current", id: "add" }, { name: '编辑', icon: 'iconfont c-light-primary ml30 icon-bianjishijuan3x current', id: 'edit' }].filter(function (item) { var _exercise$editData5, _exercise$editData5$e; if ((exercise === null || exercise === void 0 ? void 0 : (_exercise$editData5 = exercise.editData) === null || _exercise$editData5 === void 0 ? void 0 : (_exercise$editData5$e = _exercise$editData5.exercise) === null || _exercise$editData5$e === void 0 ? void 0 : _exercise$editData5$e.exercise_status) === 1) { return item; } else { return item.id !== 'del' && item.id !== 'add'; } }); var actionClick = /*#__PURE__*/function () { var _ref4 = asyncToGenerator_default()( /*#__PURE__*/regeneratorRuntime_default()().mark(function _callee6(item) { return regeneratorRuntime_default()().wrap(function _callee6$(_context6) { while (1) switch (_context6.prev = _context6.next) { case 0: if (!(editKey !== -1)) { _context6.next = 3; break; } message/* default.error */.ZP.error('请先保存或取消当前正在编辑的问题。'); return _context6.abrupt("return"); case 3: _context6.t0 = item.id; _context6.next = _context6.t0 === 'del' ? 6 : _context6.t0 === 'up' ? 8 : _context6.t0 === 'down' ? 8 : _context6.t0 === 'edit' ? 12 : _context6.t0 === 'add' ? 15 : 17; break; case 6: modal/* default.confirm */.Z.confirm({ centered: true, okText: '确定', cancelText: '取消', title: '确认要删除这个试题吗?', onOk: function onOk() { return asyncToGenerator_default()( /*#__PURE__*/regeneratorRuntime_default()().mark(function _callee5() { return regeneratorRuntime_default()().wrap(function _callee5$(_context5) { while (1) switch (_context5.prev = _context5.next) { case 0: _context5.next = 2; return (0,service_exercise/* exeriseQuestionDelete */.Fl)({ id: editData.question_id }); case 2: dispatch({ type: 'exercise/editExercise', payload: objectSpread2_default()({}, params) }); case 3: case "end": return _context5.stop(); } }, _callee5); }))(); } }); return _context6.abrupt("break", 17); case 8: _context6.next = 10; return dispatch({ type: 'exercise/exeriseMoveUpDown', payload: { id: editData.question_id, opr: item.id } }); case 10: dispatch({ type: 'exercise/editExercise', payload: objectSpread2_default()({}, params) }); return _context6.abrupt("break", 17); case 12: setEditKey(editData.dragKey); setIsEdit(true); return _context6.abrupt("break", 17); case 15: addCallback({ key: editData.key, insert_id: editData === null || editData === void 0 ? void 0 : editData.question_id, question_type: 0 }); return _context6.abrupt("break", 17); case 17: case "end": return _context6.stop(); } }, _callee6); })); return function actionClick(_x) { return _ref4.apply(this, arguments); }; }(); var showList = function showList() { var _editData$sub_exercis2; return /*#__PURE__*/(0,jsx_runtime.jsxs)("aside", { ref: dom, children: [/*#__PURE__*/(0,jsx_runtime.jsx)("div", { className: editormodules.questionType, children: !(editData !== null && editData !== void 0 && editData.isPreview) && /*#__PURE__*/(0,jsx_runtime.jsxs)("div", { children: [/*#__PURE__*/(0,jsx_runtime.jsxs)("span", { className: "font16 c-blue", children: [editData.key, "\u3001\u7EC4\u5408\u9898"] }), "\uFF08", editData.question_score, "\u5206\uFF09"] }) }), editData !== null && editData !== void 0 && editData.isPreview ? /*#__PURE__*/(0,jsx_runtime.jsxs)("div", { style: { display: 'flex', alignItems: 'flex-start' }, children: [/*#__PURE__*/(0,jsx_runtime.jsxs)("span", { style: { flexShrink: 0 }, className: "font18", children: [editData.key, "."] }), /*#__PURE__*/(0,jsx_runtime.jsx)(RenderHtml/* default */.Z, { value: editData.question_title }), /*#__PURE__*/(0,jsx_runtime.jsxs)("span", { style: { flexShrink: 0 }, className: "font16", children: ["\uFF08\u5171", editData === null || editData === void 0 ? void 0 : editData.sub_q_count, "\u5C0F\u9898\uFF0C", editData.question_score, "\u5206\uFF09"] })] }) : /*#__PURE__*/(0,jsx_runtime.jsx)("div", { className: "mt5", children: /*#__PURE__*/(0,jsx_runtime.jsx)(RenderHtml/* default */.Z, { value: editData.question_title }) }), /*#__PURE__*/(0,jsx_runtime.jsx)("div", { style: { display: show ? 'block' : 'none' }, className: editormodules.questionChoices, children: editData === null || editData === void 0 ? void 0 : (_editData$sub_exercis2 = editData.sub_exercise_questions) === null || _editData$sub_exercis2 === void 0 ? void 0 : _editData$sub_exercis2.map(function (e, i) { var _e$question_choices; return /*#__PURE__*/(0,jsx_runtime.jsxs)("div", { children: [/*#__PURE__*/(0,jsx_runtime.jsxs)("div", { style: { display: 'flex', alignItems: 'flex-start' }, children: [/*#__PURE__*/(0,jsx_runtime.jsxs)("span", { style: { flexShrink: 0 }, className: "font18", children: [editData.key, ".", i + 1, '(单选题)'] }), /*#__PURE__*/(0,jsx_runtime.jsx)(RenderHtml/* default */.Z, { value: e.question_title }), /*#__PURE__*/(0,jsx_runtime.jsxs)("span", { style: { flexShrink: 0 }, className: "font16", children: ["\uFF08", e.question_score, "\u5206\uFF09"] })] }), e === null || e === void 0 ? void 0 : (_e$question_choices = e.question_choices) === null || _e$question_choices === void 0 ? void 0 : _e$question_choices.map(function (item, index) { return /*#__PURE__*/(0,jsx_runtime.jsxs)(row/* default */.Z, { children: [/*#__PURE__*/(0,jsx_runtime.jsx)(col/* default */.Z, { children: /*#__PURE__*/(0,jsx_runtime.jsxs)(es_radio/* default */.ZP, { checked: e.standard_answer.includes(index + 1), disabled: true, children: [CombinationEditor_tagList[index], "."] }, index) }), /*#__PURE__*/(0,jsx_runtime.jsx)(col/* default */.Z, { flex: "1", children: /*#__PURE__*/(0,jsx_runtime.jsx)("span", { className: "c-black font14", children: /*#__PURE__*/(0,jsx_runtime.jsx)(RenderHtml/* default */.Z, { value: item.choice_text }) }) })] }, index); })] }, i); }) }), /*#__PURE__*/(0,jsx_runtime.jsxs)("div", { className: editormodules.action, children: [/*#__PURE__*/(0,jsx_runtime.jsx)("span", { className: "c-light-primary current", onClick: function onClick() { return setShow(!show); }, style: {}, children: show ? '收起' : '展开' }), !editData.hideAction && actionArr.map(function (item, index) { if (item.id === 'up' && editData.key === 1) return null; if (item.id === 'down' && editData.key === editData.len) return null; return /*#__PURE__*/(0,jsx_runtime.jsx)(tooltip/* default */.Z, { placement: "bottom", title: item.name, children: /*#__PURE__*/(0,jsx_runtime.jsx)("span", { onClick: function onClick() { return actionClick(item); }, className: item.icon }) }, index); })] })] }); }; var showEdit = function showEdit() { var _exercise$editData6, _exercise$editData6$e; return /*#__PURE__*/(0,jsx_runtime.jsxs)("aside", { children: [/*#__PURE__*/(0,jsx_runtime.jsx)("div", { className: editormodules.questionType, children: /*#__PURE__*/(0,jsx_runtime.jsxs)("div", { children: [/*#__PURE__*/(0,jsx_runtime.jsx)("span", { className: "font16 c-blue", children: "\u9009\u62E9\u9898" }), "\uFF08\u5BA2\u89C2\u9898\uFF0C\u7531\u7CFB\u7EDF\u81EA\u52A8\u8BC4\u5206\uFF0C\u8BF7\u8BBE\u7F6E\u6807\u51C6\u7B54\u6848\uFF09"] }) }), /*#__PURE__*/(0,jsx_runtime.jsxs)("section", { className: editormodules.wrap, style: { padding: 0 }, children: [/*#__PURE__*/(0,jsx_runtime.jsxs)("p", { className: editormodules.titleWrap, children: [/*#__PURE__*/(0,jsx_runtime.jsx)("span", { className: editormodules.required, children: "*" }), /*#__PURE__*/(0,jsx_runtime.jsx)("span", { className: editormodules.title, children: "\u9898\u5E72\uFF1A" })] }), /*#__PURE__*/(0,jsx_runtime.jsx)(markdown_editor/* default */.Z, { id: "combination-question-title", watch: true, height: 155, placeholder: "\u8BF7\u60A8\u8F93\u5165\u9898\u5E72", defaultValue: name, onChange: function onChange(value) { return setName(value); } }), /*#__PURE__*/(0,jsx_runtime.jsxs)("p", { children: ["\u5C0F\u9898\u6570\uFF1A", questionList === null || questionList === void 0 ? void 0 : questionList.length] }), questionList === null || questionList === void 0 ? void 0 : questionList.map(function (e, j) { var _e$qusList; return /*#__PURE__*/(0,jsx_runtime.jsxs)("div", { className: editormodules.fold, children: [/*#__PURE__*/(0,jsx_runtime.jsxs)("div", { onClick: function onClick() { return handleQuestionList('open', j); }, className: editormodules.head, children: [/*#__PURE__*/(0,jsx_runtime.jsx)("i", { className: "iconfont icon-sanjiaoxing", style: { transform: e.open ? 'initial' : 'rotate(270deg) translate(2px, 4px)' } }), /*#__PURE__*/(0,jsx_runtime.jsxs)("span", { children: ["\u7B2C", j + 1, "\u5C0F\u9898\uFF08\u5355\u9009\u9898\uFF09"] }), /*#__PURE__*/(0,jsx_runtime.jsx)("b", { onClick: function onClick(e) { e.stopPropagation(); handleQuestionList('delete', j); }, className: "iconfont icon-shanchu8" })] }), /*#__PURE__*/(0,jsx_runtime.jsxs)("div", { className: "mb10", style: { display: e.open ? 'block' : 'none' }, children: [/*#__PURE__*/(0,jsx_runtime.jsx)(markdown_editor/* default */.Z, { watch: true, height: 155, placeholder: "\u8BF7\u60A8\u8F93\u5165\u9898\u5E72", defaultValue: e === null || e === void 0 ? void 0 : e.name, onChange: function onChange(value) { return handleQuestionList('value', j, value); } }), /*#__PURE__*/(0,jsx_runtime.jsxs)("p", { className: editormodules.titleWrap, children: [/*#__PURE__*/(0,jsx_runtime.jsx)("span", { className: editormodules.required, children: "*" }), /*#__PURE__*/(0,jsx_runtime.jsxs)("span", { className: editormodules.title, children: ["\u7B54\u6848\u9009\u9879\uFF1A", /*#__PURE__*/(0,jsx_runtime.jsx)("span", { className: editormodules.colorGray, children: "\u70B9\u51FB\u9009\u9879\u53EF\u8BBE\u7F6E\u6B63\u786E\u7B54\u6848" })] })] }), e === null || e === void 0 ? void 0 : (_e$qusList = e.qusList) === null || _e$qusList === void 0 ? void 0 : _e$qusList.map(function (item, index) { var _e$qusAnswer2, _e$qusList2; return /*#__PURE__*/(0,jsx_runtime.jsxs)("div", { className: editormodules.choiceWrap, children: [/*#__PURE__*/(0,jsx_runtime.jsx)(tooltip/* default */.Z, { title: "\u70B9\u51FB\u8BBE\u7F6E\u4E3A\u6807\u51C6\u7B54\u6848", placement: "left", children: /*#__PURE__*/(0,jsx_runtime.jsx)("div", { className: "".concat(editormodules.answer, " ").concat(e !== null && e !== void 0 && (_e$qusAnswer2 = e.qusAnswer) !== null && _e$qusAnswer2 !== void 0 && _e$qusAnswer2.includes(index) ? editormodules.activeAnswer : ''), onClick: function onClick() { return handleQuestionList('answer', j, index); }, children: CombinationEditor_tagList[index] }) }), /*#__PURE__*/(0,jsx_runtime.jsx)("div", { className: editormodules.editorWrap, children: (e === null || e === void 0 ? void 0 : e.activeQusEditor) === index ? /*#__PURE__*/(0,jsx_runtime.jsx)(markdown_editor/* default */.Z, { id: "single-question-option-".concat(index), watch: true, height: 155, isFocus: true, placeholder: "\u8BF7\u60A8\u8F93\u5165\u9009\u9879", defaultValue: item, onChange: function onChange(value) { return handleQuestionList('details', j, value); } }) : /*#__PURE__*/(0,jsx_runtime.jsx)("div", { className: editormodules.htmlWrap, onClick: function onClick() { return handleQuestionList('edit', j, index); }, children: /*#__PURE__*/(0,jsx_runtime.jsx)(RenderHtml/* default */.Z, { value: item }) }) }), index > 1 && /*#__PURE__*/(0,jsx_runtime.jsx)(tooltip/* default */.Z, { title: "\u5220\u9664", children: /*#__PURE__*/(0,jsx_runtime.jsx)("i", { className: "".concat(editormodules.deleteIcon, " iconfont icon-htmal5icon19"), onClick: function onClick() { return handleQuestionList('deleteQus', j, index); } }) }), index < 7 && index === (e === null || e === void 0 ? void 0 : (_e$qusList2 = e.qusList) === null || _e$qusList2 === void 0 ? void 0 : _e$qusList2.length) - 1 && /*#__PURE__*/(0,jsx_runtime.jsx)(tooltip/* default */.Z, { title: "\u65B0\u589E\u53C2\u8003\u7B54\u6848", children: /*#__PURE__*/(0,jsx_runtime.jsx)("i", { className: "".concat(editormodules.addIcon, " iconfont icon-roundaddfill ml6"), onClick: function onClick() { return handleQuestionList('addQus', j); } }) })] }, index); }), /*#__PURE__*/(0,jsx_runtime.jsxs)("p", { className: "mt10", children: ["\u5206\u503C\uFF1A", /*#__PURE__*/(0,jsx_runtime.jsx)(input_number/* default */.Z, { value: e.score, max: 10000, min: 0, onChange: function onChange(value) { return handleQuestionList('score', j, value); } }), ' ', "\u5206"] })] })] }, e.id); }), questionList.length < 20 && /*#__PURE__*/(0,jsx_runtime.jsxs)(es_button/* default */.Z, { type: "primary", onClick: handleAdd, children: [/*#__PURE__*/(0,jsx_runtime.jsx)("i", { className: "iconfont icon-tianjiatimu mr5 font14" }), "\u6DFB\u52A0\u5C0F\u9898"] })] }), /*#__PURE__*/(0,jsx_runtime.jsx)("p", { className: "mt10", children: /*#__PURE__*/(0,jsx_runtime.jsxs)("span", { className: editormodules.difficult, children: [/*#__PURE__*/(0,jsx_runtime.jsx)("label", { style: { color: 'red' }, children: "*" }), " \u96BE\u5EA6\uFF1A", /*#__PURE__*/(0,jsx_runtime.jsxs)(es_radio/* default.Group */.ZP.Group, { value: difficulty, onChange: function onChange(e) { setdifficult(e.target.value); }, children: [/*#__PURE__*/(0,jsx_runtime.jsx)(es_radio/* default.Button */.ZP.Button, { value: 1, children: "\u7B80\u5355" }), /*#__PURE__*/(0,jsx_runtime.jsx)(es_radio/* default.Button */.ZP.Button, { value: 2, children: "\u9002\u4E2D" }), /*#__PURE__*/(0,jsx_runtime.jsx)(es_radio/* default.Button */.ZP.Button, { value: 3, children: "\u56F0\u96BE" })] })] }) }), /*#__PURE__*/(0,jsx_runtime.jsxs)("p", { className: editormodules.titleWrap, children: [/*#__PURE__*/(0,jsx_runtime.jsxs)("span", { className: "".concat(editormodules.title), children: ["\u77E5\u8BC6\u70B9\uFF1A", /*#__PURE__*/(0,jsx_runtime.jsx)("span", { className: editormodules.colorGray, children: "\uFF08\u6240\u6709\u81EA\u5EFA\u77E5\u8BC6\u70B9\u4EC5\u672C\u4EBA\u53EF\u89C1\uFF0C\u88ABEduCoder\u5E73\u53F0\u5BA1\u6838\u901A\u8FC7\u4E3A\u5B98\u65B9\u77E5\u8BC6\u70B9\u540E\u6240\u6709\u7528\u6237\u53EF\u89C1\uFF09" })] }), /*#__PURE__*/(0,jsx_runtime.jsx)("div", { className: "mt5", children: /*#__PURE__*/(0,jsx_runtime.jsx)(Knowledge/* Knowledge */.N, { selectvalues: editData === null || editData === void 0 ? void 0 : editData.tag_discipline_ids, value: knowledge, onChange: setKnowledge, subId: (_exercise$editData6 = exercise.editData) === null || _exercise$editData6 === void 0 ? void 0 : (_exercise$editData6$e = _exercise$editData6.exercise) === null || _exercise$editData6$e === void 0 ? void 0 : _exercise$editData6$e.sub_discipline_id, knowledgeOptions: knowledgeOptions, onAddKnowledgeFinish: handleAddKnowledgeFinish }) })] }), /*#__PURE__*/(0,jsx_runtime.jsxs)("aside", { className: "tr", children: [(editKey !== -1 || editData.question_id) && /*#__PURE__*/(0,jsx_runtime.jsx)(es_button/* default */.Z, { type: "default", onClick: function onClick() { cancelAdd(); setIsEdit(false); }, children: "\u53D6\u6D88" }), /*#__PURE__*/(0,jsx_runtime.jsx)(es_button/* default */.Z, { className: "ml20", type: "primary", onClick: function onClick() { onSave(); }, children: "\u4FDD\u5B58" })] })] }); }; var handleAdd = function handleAdd() { var param = { id: Math.random(), item_type: 'SINGLE', open: false, name: '', qusList: ['', '', '', ''], activeQusEditor: null, qusAnswer: [], analysis: '' }; setQuestionList(questionList.concat(param)); }; var handleQuestionList = function handleQuestionList(type, i, value) { var cloneQuestionList = (0,lodash.cloneDeep)(questionList); if (type === 'open') { cloneQuestionList[i].open = !cloneQuestionList[i].open; } if (type === 'delete') { cloneQuestionList.splice(i, 1); } if (type === 'value') { cloneQuestionList[i].name = value; } if (type === 'answer') { cloneQuestionList[i].qusAnswer = [value]; } if (type === 'edit') { cloneQuestionList[i].activeQusEditor = value; } if (type === 'details') { cloneQuestionList[i].qusList[cloneQuestionList[i].activeQusEditor] = value; } if (type === 'addQus') { cloneQuestionList[i].qusList = cloneQuestionList[i].qusList.concat(''); } if (type === 'deleteQus') { var _cloneQuestionList$i$; cloneQuestionList[i].qusList = cloneQuestionList[i].qusList.filter(function (_, c) { return c !== value; }); cloneQuestionList[i].qusAnswer = (_cloneQuestionList$i$ = cloneQuestionList[i].qusAnswer) === null || _cloneQuestionList$i$ === void 0 ? void 0 : _cloneQuestionList$i$.filter(function (k) { return k !== value; }); } if (type === 'analysis') { cloneQuestionList[i].analysis = value; } if (type === 'score') { cloneQuestionList[i].score = value; } setQuestionList(cloneQuestionList); }; return /*#__PURE__*/(0,jsx_runtime.jsxs)("section", { className: editormodules.wrap, children: [!isEdit && showList(), isEdit && showEdit()] }); }; /* harmony default export */ var components_CombinationEditor = ((0,_umi_production_exports.connect)(function (_ref5) { var problemset = _ref5.problemset, loading = _ref5.loading, globalSetting = _ref5.globalSetting, exercise = _ref5.exercise; return { problemset: problemset, globalSetting: globalSetting, exercise: exercise, loading: loading.effects }; }, null, null, { forwardRef: true })( /*#__PURE__*/(0,react.forwardRef)(CombinationEditor))); // EXTERNAL MODULE: ./node_modules/react-beautiful-dnd/dist/react-beautiful-dnd.esm.js + 27 modules var react_beautiful_dnd_esm = __webpack_require__(66012); ;// CONCATENATED MODULE: ./src/components/DragSubject/index.less?modules // extracted by mini-css-extract-plugin /* harmony default export */ var DragSubjectmodules = ({"flex_box_center":"flex_box_center___dDNpp","flex_space_between":"flex_space_between___ovpjv","flex_box_vertical_center":"flex_box_vertical_center___oqAEt","flex_box_center_end":"flex_box_center_end___mHCIK","flex_box_column":"flex_box_column___GZMP2","posWarp":"posWarp___ZUxXl","pos":"pos___A7NKx","tips":"tips___ap6NV","markWrongBtnWrapper":"markWrongBtnWrapper___oAKlK"}); // EXTERNAL MODULE: ./src/utils/fetch.ts var fetch = __webpack_require__(84519); // EXTERNAL MODULE: ./src/service/paperlibrary.ts var paperlibrary = __webpack_require__(24410); ;// CONCATENATED MODULE: ./src/pages/Paperlibrary/EditPaper/Questions/editor.less?modules // extracted by mini-css-extract-plugin /* harmony default export */ var Questions_editormodules = ({"flex_box_center":"flex_box_center____wjva","flex_space_between":"flex_space_between___F2_sO","flex_box_vertical_center":"flex_box_vertical_center___pCTvi","flex_box_center_end":"flex_box_center_end___ChHrd","flex_box_column":"flex_box_column___HeDXp","wrap":"wrap____e4M2","modal":"modal___UjGgD","titleWrap":"titleWrap___PWC_1","required":"required___OmL0I","title":"title___iJ1Qg","colorGray":"colorGray___xdJix","choiceWrap":"choiceWrap___XT6nM","answer":"answer___pHl5v","activeAnswer":"activeAnswer___XjpeG","deleteIcon":"deleteIcon___O5cN4","addIcon":"addIcon___a2AM2","editorWrap":"editorWrap___FKOOz","htmlWrap":"htmlWrap___ogueB","radio":"radio___W1kjJ","color333":"color333____LRzT","color999":"color999___KrWiG","questionType":"questionType___natt6","questionChoices":"questionChoices___NluQh","action":"action___zhdyr","difficult":"difficult___gAQyf","fold":"fold___aZJDt","head":"head___WgTkC"}); // EXTERNAL MODULE: ./src/utils/enum.ts var utils_enum = __webpack_require__(70960); ;// CONCATENATED MODULE: ./src/pages/Paperlibrary/EditPaper/Questions/SingleEditor.tsx var Questions_SingleEditor_tagList = ['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']; var SingleEditor_SingleEditor = function SingleEditor(_ref, ref) { var newExercisePaper = _ref.newExercisePaper, dispatch = _ref.dispatch, editData = _ref.editData, _ref$cancelAdd = _ref.cancelAdd, cancelAdd = _ref$cancelAdd === void 0 ? function () {} : _ref$cancelAdd, editKey = _ref.editKey, _ref$setEditKey = _ref.setEditKey, setEditKey = _ref$setEditKey === void 0 ? function () {} : _ref$setEditKey, _ref$reload = _ref.reload, reload = _ref$reload === void 0 ? function () {} : _ref$reload, _ref$addCallback = _ref.addCallback, addCallback = _ref$addCallback === void 0 ? function (data) {} : _ref$addCallback; var _useState = (0,react.useState)([]), _useState2 = slicedToArray_default()(_useState, 2), questionChoiceList = _useState2[0], setQuestionChoiceList = _useState2[1]; var _useState3 = (0,react.useState)(), _useState4 = slicedToArray_default()(_useState3, 2), activeEditor = _useState4[0], setActiveEditor = _useState4[1]; var _useState5 = (0,react.useState)([]), _useState6 = slicedToArray_default()(_useState5, 2), activeAnswer = _useState6[0], setActiveAnswer = _useState6[1]; var _useState7 = (0,react.useState)(''), _useState8 = slicedToArray_default()(_useState7, 2), title = _useState8[0], setTitle = _useState8[1]; var _useState9 = (0,react.useState)(), _useState10 = slicedToArray_default()(_useState9, 2), score = _useState10[0], setScore = _useState10[1]; var _useState11 = (0,react.useState)([]), _useState12 = slicedToArray_default()(_useState11, 2), knowledge = _useState12[0], setKnowledge = _useState12[1]; var _useState13 = (0,react.useState)(false), _useState14 = slicedToArray_default()(_useState13, 2), isEdit = _useState14[0], setIsEdit = _useState14[1]; var _useState15 = (0,react.useState)(1), _useState16 = slicedToArray_default()(_useState15, 2), difficulty = _useState16[0], setdifficult = _useState16[1]; var _useState17 = (0,react.useState)(false), _useState18 = slicedToArray_default()(_useState17, 2), repeat_answer = _useState18[0], setrepeat_answer = _useState18[1]; var _useState19 = (0,react.useState)(''), _useState20 = slicedToArray_default()(_useState19, 2), analysis = _useState20[0], setAnalysis = _useState20[1]; var params = (0,_umi_production_exports.useParams)(); var dom = (0,react.useRef)(null); var freeze = (0,react.useRef)(false); var _useState21 = (0,react.useState)([]), _useState22 = slicedToArray_default()(_useState21, 2), knowledgeOptions = _useState22[0], setKnowledgeOptions = _useState22[1]; var handleAddKnowledgeFinish = function handleAddKnowledgeFinish(item) { setKnowledgeOptions([].concat(toConsumableArray_default()(knowledgeOptions), [objectSpread2_default()({}, item)])); }; (0,react.useEffect)(function () { setQuestionChoiceList(['', '', '', '']); }, []); (0,react.useEffect)(function () { if (freeze.current) return; if (!(editData !== null && editData !== void 0 && editData.question_choices)) { setIsEdit(true); setTitle(''); setScore(5); setQuestionChoiceList(['', '', '', '']); setActiveAnswer([]); // dom.current?.scrollIntoView() return; } setTitle(editData === null || editData === void 0 ? void 0 : editData.question_title); setScore(editData === null || editData === void 0 ? void 0 : editData.question_score); setrepeat_answer(!(editData !== null && editData !== void 0 && editData.repeat_answer)); setAnalysis(editData === null || editData === void 0 ? void 0 : editData.analysis); setdifficult(editData === null || editData === void 0 ? void 0 : editData.difficulty); setQuestionChoiceList(editData === null || editData === void 0 ? void 0 : editData.question_choices.map(function (item) { return item.choice_text; })); var answerIndexs = []; editData === null || editData === void 0 ? void 0 : editData.standard_answer.map(function (item, index) { answerIndexs.push(item - 1); }); setKnowledge(editData.tag_discipline_ids); setActiveAnswer(answerIndexs); }, [editData, isEdit]); (0,react.useEffect)(function () { if (isEdit) { init(); } function init() { return _init.apply(this, arguments); } function _init() { _init = asyncToGenerator_default()( /*#__PURE__*/regeneratorRuntime_default()().mark(function _callee() { var _newExercisePaper$edi, _newExercisePaper$edi2; var res; return regeneratorRuntime_default()().wrap(function _callee$(_context) { while (1) switch (_context.prev = _context.next) { case 0: _context.next = 2; return (0,service_exercise/* getTagDiscipline */.YY)({ sub_discipline_id: (_newExercisePaper$edi = newExercisePaper.editData) === null || _newExercisePaper$edi === void 0 ? void 0 : (_newExercisePaper$edi2 = _newExercisePaper$edi.exercise) === null || _newExercisePaper$edi2 === void 0 ? void 0 : _newExercisePaper$edi2.sub_discipline_id }); case 2: res = _context.sent; setKnowledgeOptions(res.tag_disciplines); case 4: case "end": return _context.stop(); } }, _callee); })); return _init.apply(this, arguments); } }, [isEdit]); (0,react.useEffect)(function () { var _newExercisePaper$tag; var data = newExercisePaper !== null && newExercisePaper !== void 0 && (_newExercisePaper$tag = newExercisePaper.tagDisciplineData) !== null && _newExercisePaper$tag !== void 0 && _newExercisePaper$tag.tag_disciplines && Array.isArray(newExercisePaper.tagDisciplineData.tag_disciplines) ? newExercisePaper.tagDisciplineData.tag_disciplines : []; setKnowledgeOptions(data); }, [newExercisePaper.tagDisciplineData]); (0,react.useImperativeHandle)(ref, function () { return { onSave: onSave, isEdit: isEdit }; }); var repeal = function repeal(res) { if ((res === null || res === void 0 ? void 0 : res.status) === 0) { message/* default.success */.ZP.success("保存成功"); setIsEdit(false); setEditKey(-1); freeze.current = false; reload(); } }; var onSave = /*#__PURE__*/function () { var _ref2 = asyncToGenerator_default()( /*#__PURE__*/regeneratorRuntime_default()().mark(function _callee2() { var findNotAnswerIndex, choices, res, _newExercisePaper$edi3, _newExercisePaper$edi4, _newExercisePaper$edi5, _newExercisePaper$edi6; return regeneratorRuntime_default()().wrap(function _callee2$(_context2) { while (1) switch (_context2.prev = _context2.next) { case 0: if (title) { _context2.next = 3; break; } message/* default.info */.ZP.info("请您输入题目"); return _context2.abrupt("return", false); case 3: findNotAnswerIndex = questionChoiceList.findIndex(function (item) { return !item; }); if (!(findNotAnswerIndex > -1)) { _context2.next = 7; break; } message/* default.info */.ZP.info("\u8BF7\u5148\u8F93\u5165 ".concat(Questions_SingleEditor_tagList[findNotAnswerIndex], " \u9009\u9879\u7684\u5185\u5BB9")); return _context2.abrupt("return", false); case 7: if (activeAnswer.length) { _context2.next = 10; break; } message/* default.info */.ZP.info("请设置本题的正确答案,点击选项A/B...即可完成设置"); return _context2.abrupt("return", false); case 10: if (!(activeAnswer.length < 1)) { _context2.next = 13; break; } message/* default.info */.ZP.info("请选择答案"); return _context2.abrupt("return", false); case 13: // if (knowledge.length < 1) { // message.info("请选择知识点"); // return false; // } choices = questionChoiceList.map(function (item, index) { return { choice_text: item, is_answer: activeAnswer.includes(index) ? 1 : 0 }; }); freeze.current = true; if (!editData.question_id) { _context2.next = 22; break; } _context2.next = 18; return dispatch({ type: "newExercisePaper/editExerciseQuestion", payload: { "id": params.id, "question_id": editData.question_id, "name": title, "item_type": activeAnswer.length > 1 ? utils_enum/* QuestionType.Multiple */.c.Multiple : utils_enum/* QuestionType.Single */.c.Single, "question_score": score, "choices": choices, "tag_discipline_ids": knowledge, "sub_discipline_id": (_newExercisePaper$edi3 = newExercisePaper.editData) === null || _newExercisePaper$edi3 === void 0 ? void 0 : (_newExercisePaper$edi4 = _newExercisePaper$edi3.exercise) === null || _newExercisePaper$edi4 === void 0 ? void 0 : _newExercisePaper$edi4.sub_discipline_id, "difficulty": difficulty, "repeat_answer": !repeat_answer, analysis: analysis } }); case 18: res = _context2.sent; repeal(res); _context2.next = 26; break; case 22: _context2.next = 24; return dispatch({ type: "newExercisePaper/addExerciseQuestion", payload: { insert_id: editData === null || editData === void 0 ? void 0 : editData.insert_id, "id": params.id, "name": title, "item_type": activeAnswer.length > 1 ? utils_enum/* QuestionType.Multiple */.c.Multiple : utils_enum/* QuestionType.Single */.c.Single, "question_score": score, "choices": choices, "tag_discipline_ids": knowledge, "sub_discipline_id": (_newExercisePaper$edi5 = newExercisePaper.editData) === null || _newExercisePaper$edi5 === void 0 ? void 0 : (_newExercisePaper$edi6 = _newExercisePaper$edi5.exercise) === null || _newExercisePaper$edi6 === void 0 ? void 0 : _newExercisePaper$edi6.sub_discipline_id, "difficulty": difficulty, "repeat_answer": !repeat_answer, analysis: analysis } }); case 24: res = _context2.sent; repeal(res); case 26: case "end": return _context2.stop(); } }, _callee2); })); return function onSave() { return _ref2.apply(this, arguments); }; }(); var actionArr = [{ name: "删除", icon: "iconfont c-light-black ml30 icon-shanchu current", id: "del" }, { name: "(向下插入单选题)", icon: "iconfont c-light-primary ml30 icon-tianjia current", id: "add" }, { name: "编辑", icon: "iconfont c-light-primary ml30 icon-bianjishijuan3x current", id: "edit" }]; var actionClick = /*#__PURE__*/function () { var _ref3 = asyncToGenerator_default()( /*#__PURE__*/regeneratorRuntime_default()().mark(function _callee4(item) { return regeneratorRuntime_default()().wrap(function _callee4$(_context4) { while (1) switch (_context4.prev = _context4.next) { case 0: if (!(editKey !== -1)) { _context4.next = 3; break; } message/* default.error */.ZP.error("请先保存或取消当前正在编辑的问题。"); return _context4.abrupt("return"); case 3: _context4.t0 = item.id; _context4.next = _context4.t0 === "del" ? 6 : _context4.t0 === "edit" ? 8 : _context4.t0 === "add" ? 11 : 13; break; case 6: modal/* default.confirm */.Z.confirm({ centered: true, okText: '确定', cancelText: '取消', title: '确认要删除这个试题吗?', onOk: function onOk() { return asyncToGenerator_default()( /*#__PURE__*/regeneratorRuntime_default()().mark(function _callee3() { return regeneratorRuntime_default()().wrap(function _callee3$(_context3) { while (1) switch (_context3.prev = _context3.next) { case 0: _context3.next = 2; return (0,paperlibrary/* deleteQuestion */.Km)({ exam_id: params.id, question_id: editData.question_id }); case 2: reload(); case 3: case "end": return _context3.stop(); } }, _callee3); }))(); } }); return _context4.abrupt("break", 13); case 8: setEditKey(editData.dragKey); setIsEdit(true); return _context4.abrupt("break", 13); case 11: addCallback({ key: editData.key, insert_id: editData === null || editData === void 0 ? void 0 : editData.question_id, question_type: 0 }); return _context4.abrupt("break", 13); case 13: case "end": return _context4.stop(); } }, _callee4); })); return function actionClick(_x) { return _ref3.apply(this, arguments); }; }(); var showList = function showList() { var _editData$question_ch; return /*#__PURE__*/(0,jsx_runtime.jsxs)("aside", { ref: dom, children: [/*#__PURE__*/(0,jsx_runtime.jsx)("div", { className: Questions_editormodules.questionType, children: !(editData !== null && editData !== void 0 && editData.isPreview) && /*#__PURE__*/(0,jsx_runtime.jsxs)("div", { children: [/*#__PURE__*/(0,jsx_runtime.jsxs)("span", { className: "font16 c-blue", children: [editData.key, "\u3001\u5355\u9009\u9898"] }), "\uFF08", editData.question_score, "\u5206\uFF09"] }) }), editData !== null && editData !== void 0 && editData.isPreview ? /*#__PURE__*/(0,jsx_runtime.jsxs)("div", { style: { display: 'flex', alignItems: "flex-start" }, children: [/*#__PURE__*/(0,jsx_runtime.jsxs)("span", { style: { flexShrink: 0 }, className: "font18", children: [editData.key, "."] }), /*#__PURE__*/(0,jsx_runtime.jsx)(RenderHtml/* default */.Z, { value: editData.question_title }), /*#__PURE__*/(0,jsx_runtime.jsxs)("span", { style: { flexShrink: 0 }, className: "font16", children: ["\uFF08", editData.question_score, "\u5206\uFF09"] })] }) : /*#__PURE__*/(0,jsx_runtime.jsx)("div", { className: "mt5", children: /*#__PURE__*/(0,jsx_runtime.jsx)(RenderHtml/* default */.Z, { value: editData.question_title }) }), /*#__PURE__*/(0,jsx_runtime.jsx)("div", { className: Questions_editormodules.questionChoices, children: editData === null || editData === void 0 ? void 0 : (_editData$question_ch = editData.question_choices) === null || _editData$question_ch === void 0 ? void 0 : _editData$question_ch.map(function (item, index) { return /*#__PURE__*/(0,jsx_runtime.jsxs)(row/* default */.Z, { children: [/*#__PURE__*/(0,jsx_runtime.jsx)(col/* default */.Z, { children: /*#__PURE__*/(0,jsx_runtime.jsxs)(es_radio/* default */.ZP, { checked: editData.standard_answer.includes(index + 1), disabled: true, children: [Questions_SingleEditor_tagList[index], "."] }, index) }), /*#__PURE__*/(0,jsx_runtime.jsx)(col/* default */.Z, { flex: "1", children: /*#__PURE__*/(0,jsx_runtime.jsx)("span", { className: "c-black font14", children: /*#__PURE__*/(0,jsx_runtime.jsx)(RenderHtml/* default */.Z, { value: item.choice_text }) }) })] }, index); }) }), /*#__PURE__*/(0,jsx_runtime.jsx)("div", { className: Questions_editormodules.action, children: !editData.hideAction && actionArr.map(function (item, index) { return /*#__PURE__*/(0,jsx_runtime.jsx)(tooltip/* default */.Z, { placement: "bottom", title: item.name, children: /*#__PURE__*/(0,jsx_runtime.jsx)("span", { onClick: function onClick() { return actionClick(item); }, className: item.icon }) }, index); }) })] }); }; var showEdit = function showEdit() { var _newExercisePaper$edi7, _newExercisePaper$edi8; return /*#__PURE__*/(0,jsx_runtime.jsxs)("aside", { children: [/*#__PURE__*/(0,jsx_runtime.jsx)("div", { className: Questions_editormodules.questionType, children: /*#__PURE__*/(0,jsx_runtime.jsxs)("div", { children: [/*#__PURE__*/(0,jsx_runtime.jsx)("span", { className: "font16 c-blue", children: "\u9009\u62E9\u9898" }), "\uFF08\u5BA2\u89C2\u9898\uFF0C\u7531\u7CFB\u7EDF\u81EA\u52A8\u8BC4\u5206\uFF0C\u8BF7\u8BBE\u7F6E\u6807\u51C6\u7B54\u6848\uFF09"] }) }), /*#__PURE__*/(0,jsx_runtime.jsxs)("p", { className: Questions_editormodules.titleWrap, children: [/*#__PURE__*/(0,jsx_runtime.jsx)("span", { className: Questions_editormodules.required, children: "*" }), /*#__PURE__*/(0,jsx_runtime.jsx)("span", { className: Questions_editormodules.title, children: "\u9898\u5E72\uFF1A" })] }), /*#__PURE__*/(0,jsx_runtime.jsx)(markdown_editor/* default */.Z, { id: "single-question-title", watch: true, height: 155, placeholder: "\u8BF7\u60A8\u8F93\u5165\u9898\u5E72", defaultValue: title, onChange: function onChange(value) { return setTitle(value); } }), /*#__PURE__*/(0,jsx_runtime.jsxs)("p", { className: Questions_editormodules.titleWrap, children: [/*#__PURE__*/(0,jsx_runtime.jsx)("span", { className: Questions_editormodules.required, children: "*" }), /*#__PURE__*/(0,jsx_runtime.jsxs)("span", { className: Questions_editormodules.title, children: ["\u7B54\u6848\u9009\u9879\uFF1A", /*#__PURE__*/(0,jsx_runtime.jsx)("span", { className: Questions_editormodules.colorGray, children: "\u70B9\u51FB\u9009\u9879\u53EF\u8BBE\u7F6E\u6B63\u786E\u7B54\u6848" })] })] }), questionChoiceList.map(function (item, index) { return /*#__PURE__*/(0,jsx_runtime.jsxs)("div", { className: Questions_editormodules.choiceWrap, children: [/*#__PURE__*/(0,jsx_runtime.jsx)(tooltip/* default */.Z, { title: "\u70B9\u51FB\u8BBE\u7F6E\u4E3A\u6807\u51C6\u7B54\u6848", placement: "left", children: /*#__PURE__*/(0,jsx_runtime.jsx)("div", { className: "".concat(Questions_editormodules.answer, " ").concat(activeAnswer.includes(index) ? Questions_editormodules.activeAnswer : ''), onClick: function onClick() { if (activeAnswer.includes(index)) { setActiveAnswer(function (originalActiveAnswer) { return originalActiveAnswer.filter(function (item) { return item !== index; }); }); } else { setActiveAnswer(function (originalActiveAnswer) { return [].concat(toConsumableArray_default()(originalActiveAnswer), [index]); }); } }, children: Questions_SingleEditor_tagList[index] }) }), /*#__PURE__*/(0,jsx_runtime.jsx)("div", { className: Questions_editormodules.editorWrap, children: activeEditor === index ? /*#__PURE__*/(0,jsx_runtime.jsx)(markdown_editor/* default */.Z, { id: "single-question-option-".concat(index), watch: true, isFocus: true, height: 155, placeholder: "\u8BF7\u60A8\u8F93\u5165\u9009\u9879", defaultValue: item, onChange: function onChange(value) { questionChoiceList[index] = value; setQuestionChoiceList(questionChoiceList); } }) : /*#__PURE__*/(0,jsx_runtime.jsx)("div", { className: Questions_editormodules.htmlWrap, onClick: function onClick() { return setActiveEditor(index); }, children: /*#__PURE__*/(0,jsx_runtime.jsx)(RenderHtml/* default */.Z, { value: item }) }) }), /*#__PURE__*/(0,jsx_runtime.jsxs)(jsx_runtime.Fragment, { children: [index > 1 && /*#__PURE__*/(0,jsx_runtime.jsx)(tooltip/* default */.Z, { title: "\u5220\u9664", children: /*#__PURE__*/(0,jsx_runtime.jsx)("i", { className: "".concat(Questions_editormodules.deleteIcon, " iconfont icon-htmal5icon19"), onClick: function onClick() { return setQuestionChoiceList(questionChoiceList.filter(function (_, key) { return key !== index; })); } }) }), index < 7 && index === questionChoiceList.length - 1 && /*#__PURE__*/(0,jsx_runtime.jsx)(tooltip/* default */.Z, { title: "\u65B0\u589E\u53C2\u8003\u7B54\u6848", children: /*#__PURE__*/(0,jsx_runtime.jsx)("i", { className: "".concat(Questions_editormodules.addIcon, " iconfont icon-roundaddfill ml6"), onClick: function onClick() { return setQuestionChoiceList([].concat(toConsumableArray_default()(questionChoiceList), [''])); } }) })] })] }, index); }), /*#__PURE__*/(0,jsx_runtime.jsx)("p", { className: "c-orange", children: "\u6E29\u99A8\u63D0\u793A\uFF1A\u70B9\u51FB\u9009\u9879\u8F93\u5165\u6846\u53EF\u8BBE\u7F6E\u7B54\u6848\uFF1B\u9009\u4E2D\u7684\u9009\u9879\u5373\u4E3A\u6B63\u786E\u7B54\u6848\uFF0C\u9009\u62E9\u591A\u4E2A\u7B54\u6848\u5373\u4E3A\u591A\u9009\u9898" }), /*#__PURE__*/(0,jsx_runtime.jsx)("p", { className: Questions_editormodules.titleWrap, children: /*#__PURE__*/(0,jsx_runtime.jsx)("span", { className: Questions_editormodules.title, children: "\u9898\u76EE\u89E3\u6790\uFF1A" }) }), /*#__PURE__*/(0,jsx_runtime.jsx)(markdown_editor/* default */.Z, { id: "single-question-title", watch: true, height: 155, placeholder: "\u8BF7\u60A8\u8F93\u5165\u9898\u76EE\u89E3\u6790", defaultValue: analysis, onChange: function onChange(value) { return setAnalysis(value); } }), /*#__PURE__*/(0,jsx_runtime.jsxs)("div", { style: { marginBottom: 14 }, children: ["\u5206\u503C\uFF1A", /*#__PURE__*/(0,jsx_runtime.jsx)(input_number/* default */.Z, { value: score, max: 10000, min: 0, onChange: function onChange(value) { setScore(value); } }), " \u5206", /*#__PURE__*/(0,jsx_runtime.jsxs)("span", { style: { marginLeft: '30px' }, className: Questions_editormodules.difficult, children: [/*#__PURE__*/(0,jsx_runtime.jsx)("label", { style: { color: 'red' }, children: "*" }), " \u96BE\u5EA6\uFF1A", /*#__PURE__*/(0,jsx_runtime.jsxs)(es_radio/* default.Group */.ZP.Group, { value: difficulty, onChange: function onChange(e) { setdifficult(e.target.value); }, children: [/*#__PURE__*/(0,jsx_runtime.jsx)(es_radio/* default.Button */.ZP.Button, { value: 1, children: "\u7B80\u5355" }), /*#__PURE__*/(0,jsx_runtime.jsx)(es_radio/* default.Button */.ZP.Button, { value: 2, children: "\u9002\u4E2D" }), /*#__PURE__*/(0,jsx_runtime.jsx)(es_radio/* default.Button */.ZP.Button, { value: 3, children: "\u56F0\u96BE" })] })] })] }), /*#__PURE__*/(0,jsx_runtime.jsxs)("div", { className: Questions_editormodules.titleWrap, children: [/*#__PURE__*/(0,jsx_runtime.jsxs)("span", { className: "".concat(Questions_editormodules.title), children: ["\u77E5\u8BC6\u70B9\uFF1A", /*#__PURE__*/(0,jsx_runtime.jsx)("span", { className: Questions_editormodules.colorGray, children: "\uFF08\u6240\u6709\u81EA\u5EFA\u77E5\u8BC6\u70B9\u4EC5\u672C\u4EBA\u53EF\u89C1\uFF0C\u88ABEduCoder\u5E73\u53F0\u5BA1\u6838\u901A\u8FC7\u4E3A\u5B98\u65B9\u77E5\u8BC6\u70B9\u540E\u6240\u6709\u7528\u6237\u53EF\u89C1\uFF09" })] }), /*#__PURE__*/(0,jsx_runtime.jsx)("div", { className: "mt5", children: /*#__PURE__*/(0,jsx_runtime.jsx)(Knowledge/* Knowledge */.N, { selectvalues: editData === null || editData === void 0 ? void 0 : editData.tag_discipline_ids, value: knowledge, onChange: setKnowledge, subId: (_newExercisePaper$edi7 = newExercisePaper.editData) === null || _newExercisePaper$edi7 === void 0 ? void 0 : (_newExercisePaper$edi8 = _newExercisePaper$edi7.exercise) === null || _newExercisePaper$edi8 === void 0 ? void 0 : _newExercisePaper$edi8.sub_discipline_id, knowledgeOptions: knowledgeOptions, onAddKnowledgeFinish: handleAddKnowledgeFinish }) }), /*#__PURE__*/(0,jsx_runtime.jsxs)("div", { style: { marginTop: 10 }, children: [/*#__PURE__*/(0,jsx_runtime.jsx)("span", { style: { marginRight: 10 }, children: "\u4E0D\u5141\u8BB8\u5B66\u751F\u91CD\u590D\u7B54\u9898" }), /*#__PURE__*/(0,jsx_runtime.jsx)(es_switch/* default */.Z, { checked: repeat_answer, onChange: function onChange(e) { setrepeat_answer(e); } })] })] }), /*#__PURE__*/(0,jsx_runtime.jsxs)("aside", { className: "tr", children: [(editKey !== -1 || editData.question_id) && /*#__PURE__*/(0,jsx_runtime.jsx)(es_button/* default */.Z, { type: "default", onClick: function onClick() { cancelAdd(); setIsEdit(false); }, children: "\u53D6\u6D88" }), /*#__PURE__*/(0,jsx_runtime.jsx)(es_button/* default */.Z, { className: "ml20", type: "primary", onClick: function onClick() { onSave(); }, children: "\u4FDD\u5B58" })] })] }); }; return /*#__PURE__*/(0,jsx_runtime.jsxs)("section", { className: Questions_editormodules.wrap, children: [!isEdit && showList(), isEdit && showEdit()] }); }; /* harmony default export */ var Questions_SingleEditor = ((0,_umi_production_exports.connect)(function (_ref4) { var newExercisePaper = _ref4.newExercisePaper; return { newExercisePaper: newExercisePaper }; }, null, null, { forwardRef: true })( /*#__PURE__*/(0,react.forwardRef)(SingleEditor_SingleEditor))); ;// CONCATENATED MODULE: ./src/pages/Paperlibrary/EditPaper/Questions/MultipleEditor.tsx var Questions_MultipleEditor_tagList = ['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']; var MultipleEditor_MultipleEditor = /*#__PURE__*/(0,react.forwardRef)(function (_ref, ref) { var newExercisePaper = _ref.newExercisePaper, dispatch = _ref.dispatch, editData = _ref.editData, _ref$cancelAdd = _ref.cancelAdd, cancelAdd = _ref$cancelAdd === void 0 ? function () {} : _ref$cancelAdd, editKey = _ref.editKey, _ref$setEditKey = _ref.setEditKey, setEditKey = _ref$setEditKey === void 0 ? function () {} : _ref$setEditKey, _ref$addCallback = _ref.addCallback, addCallback = _ref$addCallback === void 0 ? function (value) {} : _ref$addCallback, _ref$reload = _ref.reload, reload = _ref$reload === void 0 ? function () {} : _ref$reload; var _useState = (0,react.useState)([]), _useState2 = slicedToArray_default()(_useState, 2), questionChoiceList = _useState2[0], setQuestionChoiceList = _useState2[1]; var _useState3 = (0,react.useState)(), _useState4 = slicedToArray_default()(_useState3, 2), activeEditor = _useState4[0], setActiveEditor = _useState4[1]; var _useState5 = (0,react.useState)([]), _useState6 = slicedToArray_default()(_useState5, 2), activeAnswer = _useState6[0], setActiveAnswer = _useState6[1]; var _useState7 = (0,react.useState)(''), _useState8 = slicedToArray_default()(_useState7, 2), title = _useState8[0], setTitle = _useState8[1]; var _useState9 = (0,react.useState)(), _useState10 = slicedToArray_default()(_useState9, 2), score = _useState10[0], setScore = _useState10[1]; var _useState11 = (0,react.useState)(false), _useState12 = slicedToArray_default()(_useState11, 2), isEdit = _useState12[0], setIsEdit = _useState12[1]; var _useState13 = (0,react.useState)([]), _useState14 = slicedToArray_default()(_useState13, 2), knowledge = _useState14[0], setKnowledge = _useState14[1]; var _useState15 = (0,react.useState)(1), _useState16 = slicedToArray_default()(_useState15, 2), difficulty = _useState16[0], setdifficult = _useState16[1]; var _useState17 = (0,react.useState)(false), _useState18 = slicedToArray_default()(_useState17, 2), repeat_answer = _useState18[0], setrepeat_answer = _useState18[1]; var _useState19 = (0,react.useState)(''), _useState20 = slicedToArray_default()(_useState19, 2), analysis = _useState20[0], setAnalysis = _useState20[1]; var _useState21 = (0,react.useState)([]), _useState22 = slicedToArray_default()(_useState21, 2), knowledgeOptions = _useState22[0], setKnowledgeOptions = _useState22[1]; var freeze = (0,react.useRef)(false); var handleAddKnowledgeFinish = function handleAddKnowledgeFinish(item) { setKnowledgeOptions([].concat(toConsumableArray_default()(knowledgeOptions), [objectSpread2_default()({}, item)])); }; var params = (0,_umi_production_exports.useParams)(); (0,react.useEffect)(function () { setQuestionChoiceList(['', '', '', '']); }, []); (0,react.useEffect)(function () { if (freeze.current) return; if (!(editData !== null && editData !== void 0 && editData.question_choices)) { setIsEdit(true); setTitle(''); setScore(5); setQuestionChoiceList(['', '', '', '']); setActiveAnswer([]); return; } setTitle(editData === null || editData === void 0 ? void 0 : editData.question_title); setScore(editData === null || editData === void 0 ? void 0 : editData.question_score); setrepeat_answer(!(editData !== null && editData !== void 0 && editData.repeat_answer)); setdifficult(editData === null || editData === void 0 ? void 0 : editData.difficulty); setQuestionChoiceList(editData === null || editData === void 0 ? void 0 : editData.question_choices.map(function (item) { return item.choice_text; })); var answerIndexs = []; editData === null || editData === void 0 ? void 0 : editData.standard_answer.map(function (item, index) { answerIndexs.push(item - 1); }); setActiveAnswer(answerIndexs); setKnowledge(editData.tag_discipline_ids); setAnalysis(editData === null || editData === void 0 ? void 0 : editData.analysis); }, [editData, isEdit]); (0,react.useEffect)(function () { if (isEdit) { init(); } function init() { return _init.apply(this, arguments); } function _init() { _init = asyncToGenerator_default()( /*#__PURE__*/regeneratorRuntime_default()().mark(function _callee() { var _newExercisePaper$edi, _newExercisePaper$edi2; var res; return regeneratorRuntime_default()().wrap(function _callee$(_context) { while (1) switch (_context.prev = _context.next) { case 0: _context.next = 2; return (0,service_exercise/* getTagDiscipline */.YY)({ sub_discipline_id: (_newExercisePaper$edi = newExercisePaper.editData) === null || _newExercisePaper$edi === void 0 ? void 0 : (_newExercisePaper$edi2 = _newExercisePaper$edi.exercise) === null || _newExercisePaper$edi2 === void 0 ? void 0 : _newExercisePaper$edi2.sub_discipline_id }); case 2: res = _context.sent; setKnowledgeOptions(res.tag_disciplines); case 4: case "end": return _context.stop(); } }, _callee); })); return _init.apply(this, arguments); } }, [isEdit]); (0,react.useImperativeHandle)(ref, function () { return { onSave: onSave, isEdit: isEdit }; }); (0,react.useEffect)(function () { var _newExercisePaper$tag; var data = newExercisePaper !== null && newExercisePaper !== void 0 && (_newExercisePaper$tag = newExercisePaper.tagDisciplineData) !== null && _newExercisePaper$tag !== void 0 && _newExercisePaper$tag.tag_disciplines && Array.isArray(newExercisePaper.tagDisciplineData.tag_disciplines) ? newExercisePaper.tagDisciplineData.tag_disciplines : []; setKnowledgeOptions(data); }, [newExercisePaper.tagDisciplineData]); var repeal = function repeal(res) { if ((res === null || res === void 0 ? void 0 : res.status) === 0) { message/* default.success */.ZP.success("保存成功"); setIsEdit(false); setEditKey(-1); freeze.current = false; reload(); } }; var onSave = /*#__PURE__*/function () { var _ref2 = asyncToGenerator_default()( /*#__PURE__*/regeneratorRuntime_default()().mark(function _callee2() { var findNotAnswerIndex, choices, res, _newExercisePaper$edi3, _newExercisePaper$edi4, _newExercisePaper$edi5, _newExercisePaper$edi6; return regeneratorRuntime_default()().wrap(function _callee2$(_context2) { while (1) switch (_context2.prev = _context2.next) { case 0: if (title) { _context2.next = 3; break; } message/* default.info */.ZP.info('请您输入题目'); return _context2.abrupt("return", false); case 3: findNotAnswerIndex = questionChoiceList.findIndex(function (item) { return !item; }); if (!(findNotAnswerIndex > -1)) { _context2.next = 7; break; } message/* default.info */.ZP.info("\u8BF7\u5148\u8F93\u5165 ".concat(Questions_MultipleEditor_tagList[findNotAnswerIndex], " \u9009\u9879\u7684\u5185\u5BB9")); return _context2.abrupt("return", false); case 7: if (activeAnswer.length) { _context2.next = 10; break; } message/* default.info */.ZP.info('请设置本题的正确答案,点击选项A/B...即可完成设置'); return _context2.abrupt("return", false); case 10: if (!(activeAnswer.length < 1)) { _context2.next = 13; break; } message/* default.info */.ZP.info('请选择答案'); return _context2.abrupt("return", false); case 13: // if (knowledge.length < 1) { // message.info("请选择知识点"); // return false; // } choices = questionChoiceList.map(function (item, index) { return { choice_text: item, is_answer: activeAnswer.includes(index) ? 1 : 0 }; }); freeze.current = true; if (!editData.question_id) { _context2.next = 22; break; } _context2.next = 18; return dispatch({ type: 'newExercisePaper/editExerciseQuestion', payload: { id: params.id, question_id: editData.question_id, name: title, item_type: activeAnswer.length > 1 ? utils_enum/* QuestionType.Multiple */.c.Multiple : utils_enum/* QuestionType.Single */.c.Single, question_score: score, choices: choices, tag_discipline_ids: knowledge, sub_discipline_id: (_newExercisePaper$edi3 = newExercisePaper.editData) === null || _newExercisePaper$edi3 === void 0 ? void 0 : (_newExercisePaper$edi4 = _newExercisePaper$edi3.exercise) === null || _newExercisePaper$edi4 === void 0 ? void 0 : _newExercisePaper$edi4.sub_discipline_id, difficulty: difficulty, repeat_answer: !repeat_answer, analysis: analysis } }); case 18: res = _context2.sent; repeal(res); _context2.next = 26; break; case 22: _context2.next = 24; return dispatch({ type: 'newExercisePaper/addExerciseQuestion', payload: { insert_id: editData === null || editData === void 0 ? void 0 : editData.insert_id, id: params.id, name: title, item_type: activeAnswer.length > 1 ? utils_enum/* QuestionType.Multiple */.c.Multiple : utils_enum/* QuestionType.Single */.c.Single, question_score: score, choices: choices, tag_discipline_ids: knowledge, sub_discipline_id: (_newExercisePaper$edi5 = newExercisePaper.editData) === null || _newExercisePaper$edi5 === void 0 ? void 0 : (_newExercisePaper$edi6 = _newExercisePaper$edi5.exercise) === null || _newExercisePaper$edi6 === void 0 ? void 0 : _newExercisePaper$edi6.sub_discipline_id, difficulty: difficulty, repeat_answer: !repeat_answer, analysis: analysis } }); case 24: res = _context2.sent; repeal(res); case 26: case "end": return _context2.stop(); } }, _callee2); })); return function onSave() { return _ref2.apply(this, arguments); }; }(); var actionArr = [{ name: '删除', icon: 'iconfont c-light-black ml30 icon-shanchu current', id: 'del' }, { name: '(向下插入多选题)', icon: 'iconfont c-light-primary ml30 icon-tianjia current', id: 'add' }, { name: '编辑', icon: 'iconfont c-light-primary ml30 icon-bianjishijuan3x current', id: 'edit' }]; var actionClick = /*#__PURE__*/function () { var _ref3 = asyncToGenerator_default()( /*#__PURE__*/regeneratorRuntime_default()().mark(function _callee4(item) { return regeneratorRuntime_default()().wrap(function _callee4$(_context4) { while (1) switch (_context4.prev = _context4.next) { case 0: if (!(editKey !== -1)) { _context4.next = 3; break; } message/* default.error */.ZP.error('请先保存或取消当前正在编辑的问题。'); return _context4.abrupt("return"); case 3: _context4.t0 = item.id; _context4.next = _context4.t0 === 'del' ? 6 : _context4.t0 === 'edit' ? 8 : _context4.t0 === 'add' ? 11 : 13; break; case 6: modal/* default.confirm */.Z.confirm({ centered: true, okText: '确定', cancelText: '取消', title: '确认要删除这个试题吗?', onOk: function onOk() { return asyncToGenerator_default()( /*#__PURE__*/regeneratorRuntime_default()().mark(function _callee3() { return regeneratorRuntime_default()().wrap(function _callee3$(_context3) { while (1) switch (_context3.prev = _context3.next) { case 0: _context3.next = 2; return (0,paperlibrary/* deleteQuestion */.Km)({ question_id: editData.question_id, exam_id: params.id }); case 2: reload(); case 3: case "end": return _context3.stop(); } }, _callee3); }))(); } }); return _context4.abrupt("break", 13); case 8: setEditKey(editData.dragKey); setIsEdit(true); return _context4.abrupt("break", 13); case 11: addCallback({ key: editData.key, insert_id: editData === null || editData === void 0 ? void 0 : editData.question_id, question_type: 1 }); return _context4.abrupt("break", 13); case 13: case "end": return _context4.stop(); } }, _callee4); })); return function actionClick(_x) { return _ref3.apply(this, arguments); }; }(); var showList = function showList() { var _editData$question_ch; return /*#__PURE__*/(0,jsx_runtime.jsxs)("aside", { children: [/*#__PURE__*/(0,jsx_runtime.jsx)("div", { className: Questions_editormodules.questionType, children: !(editData !== null && editData !== void 0 && editData.isPreview) && /*#__PURE__*/(0,jsx_runtime.jsxs)("div", { children: [/*#__PURE__*/(0,jsx_runtime.jsxs)("span", { className: "font16 c-blue", children: [editData.key, "\u3001\u591A\u9009\u9898"] }), "\uFF08", editData.question_score, "\u5206\uFF09"] }) }), editData !== null && editData !== void 0 && editData.isPreview ? /*#__PURE__*/(0,jsx_runtime.jsxs)("div", { style: { display: 'flex' }, children: [/*#__PURE__*/(0,jsx_runtime.jsxs)("span", { style: { flexShrink: 0 }, className: "font18", children: [editData.key, "."] }), /*#__PURE__*/(0,jsx_runtime.jsx)(RenderHtml/* default */.Z, { value: editData.question_title }), /*#__PURE__*/(0,jsx_runtime.jsxs)("span", { style: { flexShrink: 0 }, className: "font16", children: ["\uFF08", editData.question_score, "\u5206\uFF09"] })] }) : /*#__PURE__*/(0,jsx_runtime.jsx)("div", { className: "mt5", children: /*#__PURE__*/(0,jsx_runtime.jsx)(RenderHtml/* default */.Z, { value: editData.question_title }) }), /*#__PURE__*/(0,jsx_runtime.jsx)("div", { className: Questions_editormodules.questionChoices, children: editData === null || editData === void 0 ? void 0 : (_editData$question_ch = editData.question_choices) === null || _editData$question_ch === void 0 ? void 0 : _editData$question_ch.map(function (item, index) { return /*#__PURE__*/(0,jsx_runtime.jsxs)(row/* default */.Z, { children: [/*#__PURE__*/(0,jsx_runtime.jsx)(col/* default */.Z, { children: /*#__PURE__*/(0,jsx_runtime.jsxs)(es_checkbox/* default */.Z, { checked: editData.standard_answer.includes(index + 1), disabled: true, children: [Questions_MultipleEditor_tagList[index], "."] }, index) }), /*#__PURE__*/(0,jsx_runtime.jsx)(col/* default */.Z, { flex: "1", children: /*#__PURE__*/(0,jsx_runtime.jsx)("span", { className: "c-black font14", children: /*#__PURE__*/(0,jsx_runtime.jsx)(RenderHtml/* default */.Z, { value: item.choice_text }) }) })] }, index); }) }), /*#__PURE__*/(0,jsx_runtime.jsx)("div", { className: Questions_editormodules.action, children: !editData.hideAction && actionArr.map(function (item, index) { return /*#__PURE__*/(0,jsx_runtime.jsx)(tooltip/* default */.Z, { placement: "bottom", title: item.name, children: /*#__PURE__*/(0,jsx_runtime.jsx)("span", { onClick: function onClick() { return actionClick(item); }, className: item.icon }) }, index); }) })] }); }; var showEdit = function showEdit() { var _newExercisePaper$edi9, _newExercisePaper$edi10; return /*#__PURE__*/(0,jsx_runtime.jsxs)("aside", { children: [/*#__PURE__*/(0,jsx_runtime.jsx)("div", { className: Questions_editormodules.questionType, children: /*#__PURE__*/(0,jsx_runtime.jsxs)("div", { children: [/*#__PURE__*/(0,jsx_runtime.jsx)("span", { className: "font16 c-blue", children: "\u9009\u62E9\u9898" }), "\uFF08\u5BA2\u89C2\u9898\uFF0C\u7531\u7CFB\u7EDF\u81EA\u52A8\u8BC4\u5206\uFF0C\u8BF7\u8BBE\u7F6E\u6807\u51C6\u7B54\u6848\uFF09"] }) }), /*#__PURE__*/(0,jsx_runtime.jsxs)("p", { className: Questions_editormodules.titleWrap, children: [/*#__PURE__*/(0,jsx_runtime.jsx)("span", { className: Questions_editormodules.required, children: "*" }), /*#__PURE__*/(0,jsx_runtime.jsx)("span", { className: Questions_editormodules.title, children: "\u9898\u5E72\uFF1A" })] }), /*#__PURE__*/(0,jsx_runtime.jsx)(markdown_editor/* default */.Z, { id: "single-question-title", watch: true, height: 155, placeholder: "\u8BF7\u60A8\u8F93\u5165\u9898\u5E72", defaultValue: title, onChange: function onChange(value) { return setTitle(value); } }), /*#__PURE__*/(0,jsx_runtime.jsxs)("p", { className: Questions_editormodules.titleWrap, children: [/*#__PURE__*/(0,jsx_runtime.jsx)("span", { className: Questions_editormodules.required, children: "*" }), /*#__PURE__*/(0,jsx_runtime.jsxs)("span", { className: Questions_editormodules.title, children: ["\u7B54\u6848\u9009\u9879\uFF1A", /*#__PURE__*/(0,jsx_runtime.jsx)("span", { className: Questions_editormodules.colorGray, children: "\u70B9\u51FB\u9009\u9879\u53EF\u8BBE\u7F6E\u6B63\u786E\u7B54\u6848" })] })] }), questionChoiceList.map(function (item, index) { var _newExercisePaper$edi7, _newExercisePaper$edi8; return /*#__PURE__*/(0,jsx_runtime.jsxs)("div", { className: Questions_editormodules.choiceWrap, children: [/*#__PURE__*/(0,jsx_runtime.jsx)(tooltip/* default */.Z, { title: "\u70B9\u51FB\u8BBE\u7F6E\u4E3A\u6807\u51C6\u7B54\u6848", placement: "left", children: /*#__PURE__*/(0,jsx_runtime.jsx)("div", { className: "".concat(Questions_editormodules.answer, " ").concat(activeAnswer.includes(index) ? Questions_editormodules.activeAnswer : ''), onClick: function onClick() { if (activeAnswer.includes(index)) { setActiveAnswer(activeAnswer.filter(function (item) { return item !== index; })); } else { setActiveAnswer([].concat(toConsumableArray_default()(activeAnswer), [index])); } }, children: Questions_MultipleEditor_tagList[index] }) }), /*#__PURE__*/(0,jsx_runtime.jsx)("div", { className: Questions_editormodules.editorWrap, children: activeEditor === index ? /*#__PURE__*/(0,jsx_runtime.jsx)(markdown_editor/* default */.Z, { id: "single-question-option-".concat(index), watch: true, isFocus: true, height: 155, placeholder: "\u8BF7\u60A8\u8F93\u5165\u9009\u9879", defaultValue: item, onChange: function onChange(value) { questionChoiceList[index] = value; setQuestionChoiceList(questionChoiceList); } }) : /*#__PURE__*/(0,jsx_runtime.jsx)("div", { className: Questions_editormodules.htmlWrap, onClick: function onClick() { return setActiveEditor(index); }, children: /*#__PURE__*/(0,jsx_runtime.jsx)(RenderHtml/* default */.Z, { value: item }) }) }), ((_newExercisePaper$edi7 = newExercisePaper.editData) === null || _newExercisePaper$edi7 === void 0 ? void 0 : (_newExercisePaper$edi8 = _newExercisePaper$edi7.exercise) === null || _newExercisePaper$edi8 === void 0 ? void 0 : _newExercisePaper$edi8.exercise_status) === 1 && /*#__PURE__*/(0,jsx_runtime.jsxs)(jsx_runtime.Fragment, { children: [index > 1 && /*#__PURE__*/(0,jsx_runtime.jsx)(tooltip/* default */.Z, { title: "\u5220\u9664", children: /*#__PURE__*/(0,jsx_runtime.jsx)("i", { className: "".concat(Questions_editormodules.deleteIcon, " iconfont icon-htmal5icon19"), onClick: function onClick() { return setQuestionChoiceList(questionChoiceList.filter(function (_, key) { return key !== index; })); } }) }), index < 7 && index === questionChoiceList.length - 1 && /*#__PURE__*/(0,jsx_runtime.jsx)(tooltip/* default */.Z, { title: "\u65B0\u589E\u53C2\u8003\u7B54\u6848", children: /*#__PURE__*/(0,jsx_runtime.jsx)("i", { className: "".concat(Questions_editormodules.addIcon, " iconfont icon-roundaddfill ml6"), onClick: function onClick() { return setQuestionChoiceList([].concat(toConsumableArray_default()(questionChoiceList), [''])); } }) })] })] }, index); }), /*#__PURE__*/(0,jsx_runtime.jsx)("p", { className: "c-orange", children: "\u6E29\u99A8\u63D0\u793A\uFF1A\u70B9\u51FB\u9009\u9879\u8F93\u5165\u6846\u53EF\u8BBE\u7F6E\u7B54\u6848\uFF1B\u9009\u4E2D\u7684\u9009\u9879\u5373\u4E3A\u6B63\u786E\u7B54\u6848\uFF0C\u9009\u62E9\u591A\u4E2A\u7B54\u6848\u5373\u4E3A\u591A\u9009\u9898" }), /*#__PURE__*/(0,jsx_runtime.jsx)("p", { className: Questions_editormodules.titleWrap, children: /*#__PURE__*/(0,jsx_runtime.jsx)("span", { className: Questions_editormodules.title, children: "\u9898\u76EE\u89E3\u6790\uFF1A" }) }), /*#__PURE__*/(0,jsx_runtime.jsx)(markdown_editor/* default */.Z, { id: "single-question-title", watch: true, height: 155, placeholder: "\u8BF7\u60A8\u8F93\u5165\u9898\u76EE\u89E3\u6790", defaultValue: analysis, onChange: function onChange(value) { return setAnalysis(value); } }), /*#__PURE__*/(0,jsx_runtime.jsxs)("p", { className: "", children: ["\u5206\u503C\uFF1A", /*#__PURE__*/(0,jsx_runtime.jsx)(input_number/* default */.Z, { value: score, max: 10000, min: 0, onChange: function onChange(value) { setScore(value); } }), "\u5206", /*#__PURE__*/(0,jsx_runtime.jsxs)("span", { style: { marginLeft: '30px' }, className: Questions_editormodules.difficult, children: [/*#__PURE__*/(0,jsx_runtime.jsx)("label", { style: { color: 'red' }, children: "*" }), " \u96BE\u5EA6\uFF1A", /*#__PURE__*/(0,jsx_runtime.jsxs)(es_radio/* default.Group */.ZP.Group, { value: difficulty, onChange: function onChange(e) { setdifficult(e.target.value); }, children: [/*#__PURE__*/(0,jsx_runtime.jsx)(es_radio/* default.Button */.ZP.Button, { value: 1, children: "\u7B80\u5355" }), /*#__PURE__*/(0,jsx_runtime.jsx)(es_radio/* default.Button */.ZP.Button, { value: 2, children: "\u9002\u4E2D" }), /*#__PURE__*/(0,jsx_runtime.jsx)(es_radio/* default.Button */.ZP.Button, { value: 3, children: "\u56F0\u96BE" })] })] })] }), /*#__PURE__*/(0,jsx_runtime.jsxs)("p", { className: Questions_editormodules.titleWrap, children: [/*#__PURE__*/(0,jsx_runtime.jsxs)("span", { className: "".concat(Questions_editormodules.title), children: ["\u77E5\u8BC6\u70B9\uFF1A", /*#__PURE__*/(0,jsx_runtime.jsx)("span", { className: Questions_editormodules.colorGray, children: "\uFF08\u6240\u6709\u81EA\u5EFA\u77E5\u8BC6\u70B9\u4EC5\u672C\u4EBA\u53EF\u89C1\uFF0C\u88ABEduCoder\u5E73\u53F0\u5BA1\u6838\u901A\u8FC7\u4E3A\u5B98\u65B9\u77E5\u8BC6\u70B9\u540E\u6240\u6709\u7528\u6237\u53EF\u89C1\uFF09" })] }), /*#__PURE__*/(0,jsx_runtime.jsx)("div", { className: "mt5", children: /*#__PURE__*/(0,jsx_runtime.jsx)(Knowledge/* Knowledge */.N, { value: knowledge, selectvalues: editData === null || editData === void 0 ? void 0 : editData.tag_discipline_ids, onChange: setKnowledge, subId: (_newExercisePaper$edi9 = newExercisePaper.editData) === null || _newExercisePaper$edi9 === void 0 ? void 0 : (_newExercisePaper$edi10 = _newExercisePaper$edi9.exercise) === null || _newExercisePaper$edi10 === void 0 ? void 0 : _newExercisePaper$edi10.sub_discipline_id, knowledgeOptions: knowledgeOptions, onAddKnowledgeFinish: handleAddKnowledgeFinish }) }), /*#__PURE__*/(0,jsx_runtime.jsxs)("div", { style: { marginTop: 10 }, children: [/*#__PURE__*/(0,jsx_runtime.jsx)("span", { style: { marginRight: 10 }, children: "\u4E0D\u5141\u8BB8\u5B66\u751F\u91CD\u590D\u7B54\u9898" }), /*#__PURE__*/(0,jsx_runtime.jsx)(es_switch/* default */.Z, { checked: repeat_answer, onChange: function onChange(e) { setrepeat_answer(e); } })] })] }), /*#__PURE__*/(0,jsx_runtime.jsxs)("aside", { className: "tr", children: [(editKey !== -1 || editData.question_id) && /*#__PURE__*/(0,jsx_runtime.jsx)(es_button/* default */.Z, { type: "default", onClick: function onClick() { cancelAdd(); setIsEdit(false); }, children: "\u53D6\u6D88" }), /*#__PURE__*/(0,jsx_runtime.jsx)(es_button/* default */.Z, { className: "ml20", type: "primary", onClick: function onClick() { onSave(); }, children: "\u4FDD\u5B58" })] })] }); }; return /*#__PURE__*/(0,jsx_runtime.jsxs)("section", { className: Questions_editormodules.wrap, children: [!isEdit && showList(), isEdit && showEdit()] }); }); /* harmony default export */ var Questions_MultipleEditor = ((0,_umi_production_exports.connect)(function (_ref4) { var newExercisePaper = _ref4.newExercisePaper; return { newExercisePaper: newExercisePaper }; }, null, null, { forwardRef: true })(MultipleEditor_MultipleEditor)); ;// CONCATENATED MODULE: ./src/pages/Paperlibrary/EditPaper/Questions/JudgmentEditor.tsx var Questions_JudgmentEditor_tagList = ['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']; var JudgmentEditor_JudgmentEditor = function JudgmentEditor(_ref, ref) { var newExercisePaper = _ref.newExercisePaper, dispatch = _ref.dispatch, editData = _ref.editData, editKey = _ref.editKey, _ref$setEditKey = _ref.setEditKey, setEditKey = _ref$setEditKey === void 0 ? function () {} : _ref$setEditKey, _ref$cancelAdd = _ref.cancelAdd, cancelAdd = _ref$cancelAdd === void 0 ? function () {} : _ref$cancelAdd, _ref$reload = _ref.reload, reload = _ref$reload === void 0 ? function () {} : _ref$reload, _ref$addCallback = _ref.addCallback, addCallback = _ref$addCallback === void 0 ? function () {} : _ref$addCallback; var _useState = (0,react.useState)(), _useState2 = slicedToArray_default()(_useState, 2), activeAnswer = _useState2[0], setActiveAnswer = _useState2[1]; var _useState3 = (0,react.useState)(''), _useState4 = slicedToArray_default()(_useState3, 2), title = _useState4[0], setTitle = _useState4[1]; var _useState5 = (0,react.useState)(false), _useState6 = slicedToArray_default()(_useState5, 2), isEdit = _useState6[0], setIsEdit = _useState6[1]; var _useState7 = (0,react.useState)(), _useState8 = slicedToArray_default()(_useState7, 2), score = _useState8[0], setScore = _useState8[1]; var _useState9 = (0,react.useState)([]), _useState10 = slicedToArray_default()(_useState9, 2), knowledge = _useState10[0], setKnowledge = _useState10[1]; var _useState11 = (0,react.useState)([]), _useState12 = slicedToArray_default()(_useState11, 2), knowledgeOptions = _useState12[0], setKnowledgeOptions = _useState12[1]; var _useState13 = (0,react.useState)(1), _useState14 = slicedToArray_default()(_useState13, 2), difficulty = _useState14[0], setdifficult = _useState14[1]; var _useState15 = (0,react.useState)(false), _useState16 = slicedToArray_default()(_useState15, 2), repeat_answer = _useState16[0], setrepeat_answer = _useState16[1]; var _useState17 = (0,react.useState)(''), _useState18 = slicedToArray_default()(_useState17, 2), analysis = _useState18[0], setAnalysis = _useState18[1]; var freeze = (0,react.useRef)(false); var handleAddKnowledgeFinish = function handleAddKnowledgeFinish(item) { setKnowledgeOptions([].concat(toConsumableArray_default()(knowledgeOptions), [objectSpread2_default()({}, item)])); }; var params = (0,_umi_production_exports.useParams)(); (0,react.useEffect)(function () { if (freeze.current) return; if (!(editData !== null && editData !== void 0 && editData.question_choices)) { setIsEdit(true); setTitle(''); setScore(2); setActiveAnswer(''); return; } setrepeat_answer(!(editData !== null && editData !== void 0 && editData.repeat_answer)); setTitle(editData === null || editData === void 0 ? void 0 : editData.question_title); setScore(editData === null || editData === void 0 ? void 0 : editData.question_score); setdifficult(editData === null || editData === void 0 ? void 0 : editData.difficulty); setActiveAnswer(editData.standard_answer[0] + ''); setKnowledge(editData.tag_discipline_ids); setAnalysis(editData === null || editData === void 0 ? void 0 : editData.analysis); }, [editData, isEdit]); (0,react.useEffect)(function () { if (isEdit) { init(); } function init() { return _init.apply(this, arguments); } function _init() { _init = asyncToGenerator_default()( /*#__PURE__*/regeneratorRuntime_default()().mark(function _callee() { var _newExercisePaper$edi, _newExercisePaper$edi2; var res; return regeneratorRuntime_default()().wrap(function _callee$(_context) { while (1) switch (_context.prev = _context.next) { case 0: _context.next = 2; return (0,service_exercise/* getTagDiscipline */.YY)({ sub_discipline_id: (_newExercisePaper$edi = newExercisePaper.editData) === null || _newExercisePaper$edi === void 0 ? void 0 : (_newExercisePaper$edi2 = _newExercisePaper$edi.exercise) === null || _newExercisePaper$edi2 === void 0 ? void 0 : _newExercisePaper$edi2.sub_discipline_id }); case 2: res = _context.sent; setKnowledgeOptions(res.tag_disciplines); case 4: case "end": return _context.stop(); } }, _callee); })); return _init.apply(this, arguments); } }, [isEdit]); (0,react.useImperativeHandle)(ref, function () { return { onSave: onSave, isEdit: isEdit }; }); (0,react.useEffect)(function () { var _newExercisePaper$tag; var data = newExercisePaper !== null && newExercisePaper !== void 0 && (_newExercisePaper$tag = newExercisePaper.tagDisciplineData) !== null && _newExercisePaper$tag !== void 0 && _newExercisePaper$tag.tag_disciplines && Array.isArray(newExercisePaper.tagDisciplineData.tag_disciplines) ? newExercisePaper.tagDisciplineData.tag_disciplines : []; setKnowledgeOptions(data); }, [newExercisePaper.tagDisciplineData]); var repeal = function repeal(res) { if ((res === null || res === void 0 ? void 0 : res.status) === 0) { message/* default.success */.ZP.success("保存成功"); setIsEdit(false); setEditKey(-1); freeze.current = false; reload(); } }; var onSave = /*#__PURE__*/function () { var _ref2 = asyncToGenerator_default()( /*#__PURE__*/regeneratorRuntime_default()().mark(function _callee2() { var choices, res, _newExercisePaper$edi3, _newExercisePaper$edi4, _newExercisePaper$edi5, _newExercisePaper$edi6; return regeneratorRuntime_default()().wrap(function _callee2$(_context2) { while (1) switch (_context2.prev = _context2.next) { case 0: if (title) { _context2.next = 3; break; } message/* default.info */.ZP.info("请您输入题干"); return _context2.abrupt("return", false); case 3: if (activeAnswer) { _context2.next = 6; break; } message/* default.info */.ZP.info("请先点击选择本选择题的正确选项"); return _context2.abrupt("return", false); case 6: // if (knowledge.length < 1) { // message.info("请选择知识点"); // return false; // } choices = [{ choice_text: "正确", is_answer: activeAnswer === "1" ? 1 : 0 }, { choice_text: "错误", is_answer: activeAnswer === "2" ? 1 : 0 }]; freeze.current = true; if (!editData.question_id) { _context2.next = 15; break; } _context2.next = 11; return dispatch({ type: "newExercisePaper/editExerciseQuestion", payload: { "id": params.id, "question_id": editData.question_id, "name": title, "item_type": utils_enum/* QuestionType.Judge */.c.Judge, "question_score": score, "choices": choices, "tag_discipline_ids": knowledge, "sub_discipline_id": (_newExercisePaper$edi3 = newExercisePaper.editData) === null || _newExercisePaper$edi3 === void 0 ? void 0 : (_newExercisePaper$edi4 = _newExercisePaper$edi3.exercise) === null || _newExercisePaper$edi4 === void 0 ? void 0 : _newExercisePaper$edi4.sub_discipline_id, "difficulty": difficulty, "repeat_answer": !repeat_answer, analysis: analysis } }); case 11: res = _context2.sent; repeal(res); _context2.next = 19; break; case 15: _context2.next = 17; return dispatch({ type: "newExercisePaper/addExerciseQuestion", payload: { "id": params.id, insert_id: editData === null || editData === void 0 ? void 0 : editData.insert_id, "name": title, "item_type": utils_enum/* QuestionType.Judge */.c.Judge, "question_score": score, "choices": choices, "tag_discipline_ids": knowledge, "sub_discipline_id": (_newExercisePaper$edi5 = newExercisePaper.editData) === null || _newExercisePaper$edi5 === void 0 ? void 0 : (_newExercisePaper$edi6 = _newExercisePaper$edi5.exercise) === null || _newExercisePaper$edi6 === void 0 ? void 0 : _newExercisePaper$edi6.sub_discipline_id, "difficulty": difficulty, "repeat_answer": !repeat_answer, analysis: analysis } }); case 17: res = _context2.sent; repeal(res); case 19: return _context2.abrupt("return", { name: title, choices: choices }); case 20: case "end": return _context2.stop(); } }, _callee2); })); return function onSave() { return _ref2.apply(this, arguments); }; }(); var actionArr = [{ name: "删除", icon: "iconfont c-light-black ml30 icon-shanchu current", id: "del" }, { name: "(向下插入判断题)", icon: "iconfont c-light-primary ml30 icon-tianjia current", id: "add" }, { name: "编辑", icon: "iconfont c-light-primary ml30 icon-bianjishijuan3x current", id: "edit" }]; var actionClick = /*#__PURE__*/function () { var _ref3 = asyncToGenerator_default()( /*#__PURE__*/regeneratorRuntime_default()().mark(function _callee4(item) { return regeneratorRuntime_default()().wrap(function _callee4$(_context4) { while (1) switch (_context4.prev = _context4.next) { case 0: if (!(editKey !== -1)) { _context4.next = 3; break; } message/* default.error */.ZP.error("请先保存或取消当前正在编辑的问题。"); return _context4.abrupt("return"); case 3: _context4.t0 = item.id; _context4.next = _context4.t0 === "del" ? 6 : _context4.t0 === "edit" ? 8 : _context4.t0 === "add" ? 11 : 13; break; case 6: modal/* default.confirm */.Z.confirm({ centered: true, okText: '确定', cancelText: '取消', title: '确认要删除这个试题吗?', onOk: function onOk() { return asyncToGenerator_default()( /*#__PURE__*/regeneratorRuntime_default()().mark(function _callee3() { return regeneratorRuntime_default()().wrap(function _callee3$(_context3) { while (1) switch (_context3.prev = _context3.next) { case 0: _context3.next = 2; return (0,paperlibrary/* deleteQuestion */.Km)({ question_id: editData.question_id, exam_id: params.id }); case 2: reload(); case 3: case "end": return _context3.stop(); } }, _callee3); }))(); } }); return _context4.abrupt("break", 13); case 8: setEditKey(editData.dragKey); setIsEdit(true); return _context4.abrupt("break", 13); case 11: addCallback({ key: editData.key, insert_id: editData === null || editData === void 0 ? void 0 : editData.question_id, question_type: 2 }); return _context4.abrupt("break", 13); case 13: case "end": return _context4.stop(); } }, _callee4); })); return function actionClick(_x) { return _ref3.apply(this, arguments); }; }(); var showList = function showList() { var _editData$question_ch; return /*#__PURE__*/(0,jsx_runtime.jsxs)("aside", { children: [/*#__PURE__*/(0,jsx_runtime.jsx)("div", { className: Questions_editormodules.questionType, children: !(editData !== null && editData !== void 0 && editData.isPreview) && /*#__PURE__*/(0,jsx_runtime.jsxs)("div", { children: [/*#__PURE__*/(0,jsx_runtime.jsxs)("span", { className: "font16 c-blue", children: [editData.key, "\u3001\u5224\u65AD\u9898"] }), "\uFF08", editData.question_score, "\u5206\uFF09"] }) }), editData !== null && editData !== void 0 && editData.isPreview ? /*#__PURE__*/(0,jsx_runtime.jsxs)("div", { style: { display: 'flex' }, children: [/*#__PURE__*/(0,jsx_runtime.jsxs)("span", { style: { flexShrink: 0 }, className: "font18", children: [editData.key, "."] }), /*#__PURE__*/(0,jsx_runtime.jsx)(RenderHtml/* default */.Z, { value: editData.question_title }), /*#__PURE__*/(0,jsx_runtime.jsxs)("span", { style: { flexShrink: 0 }, className: "font16", children: ["\uFF08", editData.question_score, "\u5206\uFF09"] })] }) : /*#__PURE__*/(0,jsx_runtime.jsx)("div", { className: "mt5", children: /*#__PURE__*/(0,jsx_runtime.jsx)(RenderHtml/* default */.Z, { value: editData.question_title }) }), /*#__PURE__*/(0,jsx_runtime.jsx)("div", { className: Questions_editormodules.questionChoices, children: editData === null || editData === void 0 ? void 0 : (_editData$question_ch = editData.question_choices) === null || _editData$question_ch === void 0 ? void 0 : _editData$question_ch.map(function (item, index) { return /*#__PURE__*/(0,jsx_runtime.jsxs)(es_radio/* default */.ZP, { checked: editData.standard_answer.includes(index + 1), disabled: true, children: [Questions_JudgmentEditor_tagList[index], ". ", /*#__PURE__*/(0,jsx_runtime.jsx)("span", { className: "c-black font14", children: item.choice_text })] }, index); }) }), /*#__PURE__*/(0,jsx_runtime.jsx)("div", { className: Questions_editormodules.action, children: !editData.hideAction && actionArr.map(function (item, index) { return /*#__PURE__*/(0,jsx_runtime.jsx)(tooltip/* default */.Z, { placement: "bottom", title: item.name, children: /*#__PURE__*/(0,jsx_runtime.jsx)("span", { onClick: function onClick() { return actionClick(item); }, className: item.icon }) }, index); }) })] }); }; var showEdit = function showEdit() { var _newExercisePaper$edi7, _newExercisePaper$edi8; return /*#__PURE__*/(0,jsx_runtime.jsxs)("aside", { children: [/*#__PURE__*/(0,jsx_runtime.jsxs)("div", { children: [/*#__PURE__*/(0,jsx_runtime.jsx)("span", { className: "font16 c-blue", children: "\u5224\u65AD\u9898" }), "\uFF08\u5BA2\u89C2\u9898\uFF0C\u7531\u7CFB\u7EDF\u81EA\u52A8\u8BC4\u5206\uFF0C\u8BF7\u8BBE\u7F6E\u6807\u51C6\u7B54\u6848\uFF09"] }), /*#__PURE__*/(0,jsx_runtime.jsxs)("p", { className: Questions_editormodules.titleWrap, children: [/*#__PURE__*/(0,jsx_runtime.jsx)("span", { className: Questions_editormodules.required, children: "*" }), /*#__PURE__*/(0,jsx_runtime.jsx)("span", { className: Questions_editormodules.title, children: "\u9898\u5E72\uFF1A" })] }), /*#__PURE__*/(0,jsx_runtime.jsx)(markdown_editor/* default */.Z, { id: "single-question-title", watch: true, height: 155, placeholder: "\u8BF7\u60A8\u8F93\u5165\u9898\u5E72", defaultValue: title, onChange: function onChange(value) { return setTitle(value); } }), /*#__PURE__*/(0,jsx_runtime.jsxs)("p", { className: Questions_editormodules.titleWrap, children: [/*#__PURE__*/(0,jsx_runtime.jsx)("span", { className: Questions_editormodules.required, children: "*" }), /*#__PURE__*/(0,jsx_runtime.jsxs)("span", { className: Questions_editormodules.title, children: ["\u7B54\u6848\u9009\u9879\uFF1A", /*#__PURE__*/(0,jsx_runtime.jsx)("span", { className: Questions_editormodules.colorGray, children: "\u70B9\u51FB\u9009\u9879\u53EF\u8BBE\u7F6E\u6B63\u786E\u7B54\u6848" })] })] }), /*#__PURE__*/(0,jsx_runtime.jsxs)(es_radio/* default.Group */.ZP.Group, { buttonStyle: "solid", value: activeAnswer, onChange: function onChange(e) { return setActiveAnswer(e.target.value); }, children: [/*#__PURE__*/(0,jsx_runtime.jsx)(es_radio/* default.Button */.ZP.Button, { value: "1", className: "".concat(Questions_editormodules.radio, " mr40"), children: "\u6B63\u786E" }), /*#__PURE__*/(0,jsx_runtime.jsx)(es_radio/* default.Button */.ZP.Button, { value: "2", className: Questions_editormodules.radio, children: "\u9519\u8BEF" })] }), /*#__PURE__*/(0,jsx_runtime.jsx)("p", { className: "c-orange", children: "\u6E29\u99A8\u63D0\u793A\uFF1A\u70B9\u51FB\u9009\u9879\uFF0C\u53EF\u4EE5\u76F4\u63A5\u8BBE\u7F6E\u6807\u51C6\u7B54\u6848" }), /*#__PURE__*/(0,jsx_runtime.jsx)("p", { className: Questions_editormodules.titleWrap, children: /*#__PURE__*/(0,jsx_runtime.jsx)("span", { className: Questions_editormodules.title, children: "\u9898\u76EE\u89E3\u6790\uFF1A" }) }), /*#__PURE__*/(0,jsx_runtime.jsx)(markdown_editor/* default */.Z, { id: "single-question-title", watch: true, height: 155, placeholder: "\u8BF7\u60A8\u8F93\u5165\u9898\u76EE\u89E3\u6790", defaultValue: analysis, onChange: function onChange(value) { return setAnalysis(value); } }), /*#__PURE__*/(0,jsx_runtime.jsxs)("p", { className: "", children: ["\u5206\u503C\uFF1A", /*#__PURE__*/(0,jsx_runtime.jsx)(input_number/* default */.Z, { value: score, max: 10000, min: 0, onChange: function onChange(value) { setScore(value); } }), " \u5206", /*#__PURE__*/(0,jsx_runtime.jsxs)("span", { style: { marginLeft: '30px' }, className: Questions_editormodules.difficult, children: [/*#__PURE__*/(0,jsx_runtime.jsx)("label", { style: { color: 'red' }, children: "*" }), " \u96BE\u5EA6\uFF1A", /*#__PURE__*/(0,jsx_runtime.jsxs)(es_radio/* default.Group */.ZP.Group, { value: difficulty, onChange: function onChange(e) { setdifficult(e.target.value); }, children: [/*#__PURE__*/(0,jsx_runtime.jsx)(es_radio/* default.Button */.ZP.Button, { value: 1, children: "\u7B80\u5355" }), /*#__PURE__*/(0,jsx_runtime.jsx)(es_radio/* default.Button */.ZP.Button, { value: 2, children: "\u9002\u4E2D" }), /*#__PURE__*/(0,jsx_runtime.jsx)(es_radio/* default.Button */.ZP.Button, { value: 3, children: "\u56F0\u96BE" })] })] })] }), /*#__PURE__*/(0,jsx_runtime.jsxs)("p", { className: Questions_editormodules.titleWrap, children: [/*#__PURE__*/(0,jsx_runtime.jsxs)("span", { className: "".concat(Questions_editormodules.title), children: ["\u77E5\u8BC6\u70B9\uFF1A", /*#__PURE__*/(0,jsx_runtime.jsx)("span", { className: Questions_editormodules.colorGray, children: "\uFF08\u6240\u6709\u81EA\u5EFA\u77E5\u8BC6\u70B9\u4EC5\u672C\u4EBA\u53EF\u89C1\uFF0C\u88ABEduCoder\u5E73\u53F0\u5BA1\u6838\u901A\u8FC7\u4E3A\u5B98\u65B9\u77E5\u8BC6\u70B9\u540E\u6240\u6709\u7528\u6237\u53EF\u89C1\uFF09" })] }), /*#__PURE__*/(0,jsx_runtime.jsx)("div", { className: "mt5", children: /*#__PURE__*/(0,jsx_runtime.jsx)(Knowledge/* Knowledge */.N, { value: knowledge, selectvalues: editData === null || editData === void 0 ? void 0 : editData.tag_discipline_ids, onChange: setKnowledge, subId: (_newExercisePaper$edi7 = newExercisePaper.editData) === null || _newExercisePaper$edi7 === void 0 ? void 0 : (_newExercisePaper$edi8 = _newExercisePaper$edi7.exercise) === null || _newExercisePaper$edi8 === void 0 ? void 0 : _newExercisePaper$edi8.sub_discipline_id, knowledgeOptions: knowledgeOptions, onAddKnowledgeFinish: handleAddKnowledgeFinish }) }), /*#__PURE__*/(0,jsx_runtime.jsxs)("div", { style: { marginTop: 10 }, children: [/*#__PURE__*/(0,jsx_runtime.jsx)("span", { style: { marginRight: 10 }, children: "\u4E0D\u5141\u8BB8\u5B66\u751F\u91CD\u590D\u7B54\u9898" }), /*#__PURE__*/(0,jsx_runtime.jsx)(es_switch/* default */.Z, { checked: repeat_answer, onChange: function onChange(e) { setrepeat_answer(e); } })] })] }), /*#__PURE__*/(0,jsx_runtime.jsxs)("aside", { className: "tr", children: [(editKey !== -1 || editData.question_id) && /*#__PURE__*/(0,jsx_runtime.jsx)(es_button/* default */.Z, { type: "default", onClick: function onClick() { cancelAdd(); setIsEdit(false); }, children: "\u53D6\u6D88" }), /*#__PURE__*/(0,jsx_runtime.jsx)(es_button/* default */.Z, { className: "ml20", type: "primary", onClick: function onClick() { onSave(); }, children: "\u4FDD\u5B58" })] })] }); }; return /*#__PURE__*/(0,jsx_runtime.jsxs)("section", { className: Questions_editormodules.wrap, children: [!isEdit && showList(), isEdit && showEdit()] }); }; /* harmony default export */ var Questions_JudgmentEditor = ((0,_umi_production_exports.connect)(function (_ref4) { var newExercisePaper = _ref4.newExercisePaper; return { newExercisePaper: newExercisePaper }; }, null, null, { forwardRef: true })( /*#__PURE__*/(0,react.forwardRef)(JudgmentEditor_JudgmentEditor))); ;// CONCATENATED MODULE: ./src/pages/Paperlibrary/EditPaper/Questions/CompletionEditor.tsx var CompletionEditor_CompletionEditor = function CompletionEditor(_ref, ref) { var newExercisePaper = _ref.newExercisePaper, dispatch = _ref.dispatch, editData = _ref.editData, editKey = _ref.editKey, _ref$setEditKey = _ref.setEditKey, setEditKey = _ref$setEditKey === void 0 ? function () {} : _ref$setEditKey, _ref$cancelAdd = _ref.cancelAdd, cancelAdd = _ref$cancelAdd === void 0 ? function () {} : _ref$cancelAdd, _ref$addCallback = _ref.addCallback, addCallback = _ref$addCallback === void 0 ? function () {} : _ref$addCallback, _ref$reload = _ref.reload, reload = _ref$reload === void 0 ? function () {} : _ref$reload; var _useState = (0,react.useState)(''), _useState2 = slicedToArray_default()(_useState, 2), title = _useState2[0], setTitle = _useState2[1]; var _useState3 = (0,react.useState)(''), _useState4 = slicedToArray_default()(_useState3, 2), analysis = _useState4[0], setAnalysis = _useState4[1]; var _useState5 = (0,react.useState)([]), _useState6 = slicedToArray_default()(_useState5, 2), answerList = _useState6[0], setAnswerList = _useState6[1]; var _useState7 = (0,react.useState)(''), _useState8 = slicedToArray_default()(_useState7, 2), activeOptionErrorIndex = _useState8[0], setActiveOptionErrorIndex = _useState8[1]; var _useState9 = (0,react.useState)(), _useState10 = slicedToArray_default()(_useState9, 2), checked = _useState10[0], setChecked = _useState10[1]; var _useState11 = (0,react.useState)(false), _useState12 = slicedToArray_default()(_useState11, 2), firstSetAnswerFlag = _useState12[0], setFirstSetAnswerFlag = _useState12[1]; var _useState13 = (0,react.useState)(), _useState14 = slicedToArray_default()(_useState13, 2), score = _useState14[0], setScore = _useState14[1]; var _useState15 = (0,react.useState)(0), _useState16 = slicedToArray_default()(_useState15, 2), totalBlanks = _useState16[0], setTotalBlanks = _useState16[1]; var _useState17 = (0,react.useState)(false), _useState18 = slicedToArray_default()(_useState17, 2), isEdit = _useState18[0], setIsEdit = _useState18[1]; var _useState19 = (0,react.useState)(false), _useState20 = slicedToArray_default()(_useState19, 2), btnSave = _useState20[0], setBtnSave = _useState20[1]; var _useState21 = (0,react.useState)([]), _useState22 = slicedToArray_default()(_useState21, 2), knowledge = _useState22[0], setKnowledge = _useState22[1]; var _useState23 = (0,react.useState)(1), _useState24 = slicedToArray_default()(_useState23, 2), difficulty = _useState24[0], setdifficult = _useState24[1]; var _useState25 = (0,react.useState)(false), _useState26 = slicedToArray_default()(_useState25, 2), repeat_answer = _useState26[0], setrepeat_answer = _useState26[1]; var freeze = (0,react.useRef)(false); var params = (0,_umi_production_exports.useParams)(); var _useState27 = (0,react.useState)([]), _useState28 = slicedToArray_default()(_useState27, 2), knowledgeOptions = _useState28[0], setKnowledgeOptions = _useState28[1]; var handleAddKnowledgeFinish = function handleAddKnowledgeFinish(item) { setKnowledgeOptions([].concat(toConsumableArray_default()(knowledgeOptions), [objectSpread2_default()({}, item)])); }; (0,react.useEffect)(function () { if (freeze.current) return; if (!(editData !== null && editData !== void 0 && editData.question_title)) { setIsEdit(true); setTitle(''); setChecked(false); setScore(2); setAnswerList([]); setActiveOptionErrorIndex(''); setFirstSetAnswerFlag(false); return; } setTitle(editData === null || editData === void 0 ? void 0 : editData.question_title); setChecked(editData === null || editData === void 0 ? void 0 : editData.is_ordered); setdifficult(editData === null || editData === void 0 ? void 0 : editData.difficulty); setrepeat_answer(!(editData !== null && editData !== void 0 && editData.repeat_answer)); setScore(editData === null || editData === void 0 ? void 0 : editData.question_score); var answer = editData === null || editData === void 0 ? void 0 : editData.standard_answer.map(function (item) { return item.answer_text; }); setAnswerList(toConsumableArray_default()(answer)); setKnowledge(editData.tag_discipline_ids); setAnalysis(editData === null || editData === void 0 ? void 0 : editData.analysis); }, [editData, isEdit]); (0,react.useEffect)(function () { setFirstSetAnswerFlag(false); if (isEdit) { init(); } function init() { return _init.apply(this, arguments); } function _init() { _init = asyncToGenerator_default()( /*#__PURE__*/regeneratorRuntime_default()().mark(function _callee() { var _newExercisePaper$edi, _newExercisePaper$edi2; var res; return regeneratorRuntime_default()().wrap(function _callee$(_context) { while (1) switch (_context.prev = _context.next) { case 0: _context.next = 2; return (0,service_exercise/* getTagDiscipline */.YY)({ sub_discipline_id: (_newExercisePaper$edi = newExercisePaper.editData) === null || _newExercisePaper$edi === void 0 ? void 0 : (_newExercisePaper$edi2 = _newExercisePaper$edi.exercise) === null || _newExercisePaper$edi2 === void 0 ? void 0 : _newExercisePaper$edi2.sub_discipline_id }); case 2: res = _context.sent; setKnowledgeOptions(res.tag_disciplines); case 4: case "end": return _context.stop(); } }, _callee); })); return _init.apply(this, arguments); } }, [isEdit]); (0,react.useImperativeHandle)(ref, function () { return { onSave: onSave, isEdit: isEdit }; }); (0,react.useEffect)(function () { var _newExercisePaper$tag; var data = newExercisePaper !== null && newExercisePaper !== void 0 && (_newExercisePaper$tag = newExercisePaper.tagDisciplineData) !== null && _newExercisePaper$tag !== void 0 && _newExercisePaper$tag.tag_disciplines && Array.isArray(newExercisePaper.tagDisciplineData.tag_disciplines) ? newExercisePaper.tagDisciplineData.tag_disciplines : []; setKnowledgeOptions(data); }, [newExercisePaper.tagDisciplineData]); var repeal = function repeal(res) { if ((res === null || res === void 0 ? void 0 : res.status) === 0) { message/* default.success */.ZP.success("保存成功"); setIsEdit(false); setEditKey(-1); freeze.current = false; reload(); } }; var onSave = /*#__PURE__*/function () { var _ref2 = asyncToGenerator_default()( /*#__PURE__*/regeneratorRuntime_default()().mark(function _callee2() { var answerArray, isEmpty, res, _newExercisePaper$edi3, _newExercisePaper$edi4, _newExercisePaper$edi5, _newExercisePaper$edi6; return regeneratorRuntime_default()().wrap(function _callee2$(_context2) { while (1) switch (_context2.prev = _context2.next) { case 0: answerArray = []; isEmpty = false; setBtnSave(true); //保存的时候不弹出删除框 answerList.forEach(function (answers, index) { answerArray.push({ position: index + 1, answer_text: [] }); answers.forEach(function (item, itemIndex) { answerArray[index].answer_text.push(item); if (!item || !(0,util/* validateLength */.eR)(item, 10000)) { setActiveOptionErrorIndex("".concat(index, "-").concat(itemIndex)); message/* default.info */.ZP.info(!item ? "\u7B54\u6848\uFF1A\u4E0D\u80FD\u4E3A\u7A7A" : "答案不能超过10000字符"); isEmpty = true; } }); }); if (!isEmpty) { _context2.next = 7; break; } setBtnSave(false); return _context2.abrupt("return", false); case 7: // if (knowledge.length < 1) { // message.info("请选择知识点"); // return false; // } freeze.current = true; if (!editData.question_id) { _context2.next = 15; break; } _context2.next = 11; return dispatch({ type: "newExercisePaper/editExerciseQuestion", payload: { "id": params.id, "question_id": editData.question_id, "name": title, "item_type": 3, "question_score": score, "is_ordered": checked, "standard_answers": answerArray, "tag_discipline_ids": knowledge, "sub_discipline_id": (_newExercisePaper$edi3 = newExercisePaper.editData) === null || _newExercisePaper$edi3 === void 0 ? void 0 : (_newExercisePaper$edi4 = _newExercisePaper$edi3.exercise) === null || _newExercisePaper$edi4 === void 0 ? void 0 : _newExercisePaper$edi4.sub_discipline_id, "difficulty": difficulty, "repeat_answer": !repeat_answer, analysis: analysis } }); case 11: res = _context2.sent; repeal(res); _context2.next = 19; break; case 15: _context2.next = 17; return dispatch({ type: "newExercisePaper/addExerciseQuestion", payload: { insert_id: editData === null || editData === void 0 ? void 0 : editData.insert_id, id: params.id, "name": title, "item_type": 3, "question_score": score, "is_ordered": checked, "standard_answers": answerArray, "tag_discipline_ids": knowledge, "sub_discipline_id": (_newExercisePaper$edi5 = newExercisePaper.editData) === null || _newExercisePaper$edi5 === void 0 ? void 0 : (_newExercisePaper$edi6 = _newExercisePaper$edi5.exercise) === null || _newExercisePaper$edi6 === void 0 ? void 0 : _newExercisePaper$edi6.sub_discipline_id, "difficulty": difficulty, "repeat_answer": !repeat_answer, analysis: analysis } }); case 17: res = _context2.sent; repeal(res); case 19: setBtnSave(false); return _context2.abrupt("return", { name: title, analysis: analysis, standard_answers: answerArray, is_ordered: checked }); case 21: case "end": return _context2.stop(); } }, _callee2); })); return function onSave() { return _ref2.apply(this, arguments); }; }(); var handlePlaceholderChange = function handlePlaceholderChange(placeholderCountBefore, placeholderCountInRange, totalPlaceholderCount) { var newStandardAnswers = answerList.slice(); if (placeholderCountInRange) { newStandardAnswers.splice(placeholderCountBefore, placeholderCountInRange); } if (totalPlaceholderCount && firstSetAnswerFlag || !editData.question_id) { for (var i = 0; i < totalPlaceholderCount; i++) { newStandardAnswers.splice(placeholderCountBefore + i, 0, [""]); } } setTotalBlanks(newStandardAnswers === null || newStandardAnswers === void 0 ? void 0 : newStandardAnswers.length); setFirstSetAnswerFlag(true); setAnswerList(newStandardAnswers); }; var handleAnswerChange = function handleAnswerChange(index, itemIndex, val) { setActiveOptionErrorIndex(''); var newStandardAnswers = answerList.slice(); newStandardAnswers[index][itemIndex] = val; setAnswerList(newStandardAnswers); }; var handleAddChildAnswer = function handleAddChildAnswer(index) { var newStandardAnswers = answerList.slice(); newStandardAnswers[index] = [].concat(toConsumableArray_default()(newStandardAnswers[index]), ['']); setAnswerList(newStandardAnswers); }; var handleDeleteChildAnswer = function handleDeleteChildAnswer(index, childIndex) { var newStandardAnswers = answerList.slice(); if (!newStandardAnswers[index][childIndex]) { newStandardAnswers[index] = newStandardAnswers[index].filter(function (_, key) { return key !== childIndex; }); setAnswerList(newStandardAnswers); return; } modal/* default.confirm */.Z.confirm({ centered: true, okText: '确定', cancelText: '取消', title: '提示', content: '确认要删除这个参考答案吗?', className: Questions_editormodules.modal, onOk: function onOk() { newStandardAnswers[index] = newStandardAnswers[index].filter(function (_, key) { return key !== childIndex; }); setAnswerList(newStandardAnswers); } }); }; var handleDeleteChildAnswermain = function handleDeleteChildAnswermain(index) { modal/* default.confirm */.Z.confirm({ centered: true, okText: '确定', cancelText: '取消', title: '提示', content: '确认要删除这个参考答案吗?', className: Questions_editormodules.modal, onOk: function onOk() { var key = 0; setTitle(title.replace(/\▁/g, function (item) { key++; if (key - 1 === index) { return ""; } else { return item; } })); setTimeout(function () { var newStandardAnswers = answerList.slice(); newStandardAnswers = answerList.filter(function (_, key) { return index !== key; }); setAnswerList(newStandardAnswers); }, 500); } }); }; var showEdit = function showEdit() { var _newExercisePaper$edi7, _newExercisePaper$edi8; return /*#__PURE__*/(0,jsx_runtime.jsxs)("aside", { children: [/*#__PURE__*/(0,jsx_runtime.jsx)("div", { className: Questions_editormodules.questionType, children: /*#__PURE__*/(0,jsx_runtime.jsxs)("div", { children: [/*#__PURE__*/(0,jsx_runtime.jsx)("span", { className: "font16 c-blue", children: "\u586B\u7A7A\u9898" }), "\uFF08\u5BA2\u89C2\u9898\uFF0C\u7531\u7CFB\u7EDF\u81EA\u52A8\u8BC4\u5206\uFF0C\u5141\u8BB8\u624B\u52A8\u8C03\u5206\uFF0C\u8BF7\u8BBE\u7F6E\u6807\u51C6\u7B54\u6848 \uFF1B\u652F\u6301\u6700\u591A5\u4E2A\u7A7A\uFF0C\u6BCF\u7A7A\u5F97\u5206\u6309\u7167\u672C\u9898\u7684\u603B\u5206\u5E73\u5747\u8BA1\u7B97\uFF09"] }) }), /*#__PURE__*/(0,jsx_runtime.jsx)("div", { children: /*#__PURE__*/(0,jsx_runtime.jsx)(NullMDEditor/* default */.Z, { id: "completion-question-tittle", placeholder: "\u8BF7\u60A8\u8F93\u5165\u9898\u76EE", height: 155, defaultValue: title, onChange: function onChange(value) { return setTitle(value); }, showNullButton: true, deleteEmptyDisabled: false || btnSave, onPlaceholderChange: handlePlaceholderChange }) }), /*#__PURE__*/(0,jsx_runtime.jsx)("div", { className: "mt20", children: answerList.map(function (answers, index) { return /*#__PURE__*/(0,jsx_runtime.jsx)(NullChildEditor/* default */.Z, { answers: answers, index: index, is_md: true, exerciseIsPublish: false, activeOptionErrorIndex: activeOptionErrorIndex, onAnswerChange: handleAnswerChange, addChildAnswer: handleAddChildAnswer, deleteChildAnswer: handleDeleteChildAnswer, deleteChildAnswermain: handleDeleteChildAnswermain }, index); }) }), /*#__PURE__*/(0,jsx_runtime.jsx)("div", { className: "mt20", children: answerList.length > 1 && /*#__PURE__*/(0,jsx_runtime.jsxs)("span", { children: [/*#__PURE__*/(0,jsx_runtime.jsx)(es_checkbox/* default */.Z, { checked: checked, onChange: function onChange(e) { return setChecked(e.target.checked); }, className: "".concat(Questions_editormodules.color333, " font14"), children: "\u591A\u4E2A\u586B\u7A7A\u7684\u7B54\u6848\u6709\u987A\u5E8F\u8981\u6C42" }), /*#__PURE__*/(0,jsx_runtime.jsx)("span", { className: "".concat(Questions_editormodules.color999, " font12"), children: "\uFF08\u9009\u4E2D\uFF0C\u6BCF\u4E2A\u586B\u7A7A\u7684\u7B54\u6848\u987A\u5E8F\u5FC5\u987B\u4E0E\u53C2\u8003\u7B54\u6848\u4E00\u81F4\uFF09" })] }) }), /*#__PURE__*/(0,jsx_runtime.jsx)("p", { className: Questions_editormodules.titleWrap, children: /*#__PURE__*/(0,jsx_runtime.jsx)("span", { className: Questions_editormodules.title, children: "\u9898\u76EE\u89E3\u6790\uFF1A" }) }), /*#__PURE__*/(0,jsx_runtime.jsx)(markdown_editor/* default */.Z, { id: "single-question-title", watch: true, height: 155, placeholder: "\u8BF7\u60A8\u8F93\u5165\u9898\u76EE\u89E3\u6790", defaultValue: analysis, onChange: function onChange(value) { return setAnalysis(value); } }), /*#__PURE__*/(0,jsx_runtime.jsxs)("p", { className: "", children: [/*#__PURE__*/(0,jsx_runtime.jsx)("span", { style: { color: 'red' }, children: "*" }), "\u5206\u503C\uFF1A", /*#__PURE__*/(0,jsx_runtime.jsx)(input_number/* default */.Z, { value: score, max: 10000, min: 0, onChange: function onChange(value) { setScore(value); } }), " \u5206 \xA0 ", !!score && !!totalBlanks && /*#__PURE__*/(0,jsx_runtime.jsxs)("span", { style: { color: 'red' }, children: ["(\u6839\u636E\u5747\u5206\u89C4\u5219\uFF0C\u672C\u9898\u6BCF\u7A7A", (score / totalBlanks).toFixed(1), "\u5206)"] }), /*#__PURE__*/(0,jsx_runtime.jsxs)("span", { style: { marginLeft: '30px' }, className: Questions_editormodules.difficult, children: [/*#__PURE__*/(0,jsx_runtime.jsx)("label", { style: { color: 'red' }, children: "*" }), " \u96BE\u5EA6\uFF1A", /*#__PURE__*/(0,jsx_runtime.jsxs)(es_radio/* default.Group */.ZP.Group, { value: difficulty, onChange: function onChange(e) { setdifficult(e.target.value); }, children: [/*#__PURE__*/(0,jsx_runtime.jsx)(es_radio/* default.Button */.ZP.Button, { value: 1, children: "\u7B80\u5355" }), /*#__PURE__*/(0,jsx_runtime.jsx)(es_radio/* default.Button */.ZP.Button, { value: 2, children: "\u9002\u4E2D" }), /*#__PURE__*/(0,jsx_runtime.jsx)(es_radio/* default.Button */.ZP.Button, { value: 3, children: "\u56F0\u96BE" })] })] })] }), /*#__PURE__*/(0,jsx_runtime.jsxs)("p", { className: Questions_editormodules.titleWrap, children: [/*#__PURE__*/(0,jsx_runtime.jsxs)("span", { className: "".concat(Questions_editormodules.title), children: ["\u77E5\u8BC6\u70B9\uFF1A", /*#__PURE__*/(0,jsx_runtime.jsx)("span", { className: Questions_editormodules.colorGray, children: "\uFF08\u6240\u6709\u81EA\u5EFA\u77E5\u8BC6\u70B9\u4EC5\u672C\u4EBA\u53EF\u89C1\uFF0C\u88ABEduCoder\u5E73\u53F0\u5BA1\u6838\u901A\u8FC7\u4E3A\u5B98\u65B9\u77E5\u8BC6\u70B9\u540E\u6240\u6709\u7528\u6237\u53EF\u89C1\uFF09" })] }), /*#__PURE__*/(0,jsx_runtime.jsx)("div", { className: "mt5", children: /*#__PURE__*/(0,jsx_runtime.jsx)(Knowledge/* Knowledge */.N, { value: knowledge, selectvalues: editData === null || editData === void 0 ? void 0 : editData.tag_discipline_ids, onChange: setKnowledge, subId: (_newExercisePaper$edi7 = newExercisePaper.editData) === null || _newExercisePaper$edi7 === void 0 ? void 0 : (_newExercisePaper$edi8 = _newExercisePaper$edi7.exercise) === null || _newExercisePaper$edi8 === void 0 ? void 0 : _newExercisePaper$edi8.sub_discipline_id, knowledgeOptions: knowledgeOptions, onAddKnowledgeFinish: handleAddKnowledgeFinish }) }), /*#__PURE__*/(0,jsx_runtime.jsxs)("div", { style: { marginTop: 10 }, children: [/*#__PURE__*/(0,jsx_runtime.jsx)("span", { style: { marginRight: 10 }, children: "\u4E0D\u5141\u8BB8\u5B66\u751F\u91CD\u590D\u7B54\u9898" }), /*#__PURE__*/(0,jsx_runtime.jsx)(es_switch/* default */.Z, { checked: repeat_answer, onChange: function onChange(e) { setrepeat_answer(e); } })] })] }), /*#__PURE__*/(0,jsx_runtime.jsxs)("aside", { className: "tr", children: [(editKey !== -1 || editData.question_id) && /*#__PURE__*/(0,jsx_runtime.jsx)(es_button/* default */.Z, { type: "default", onClick: function onClick() { cancelAdd(); setIsEdit(false); }, children: "\u53D6\u6D88" }), /*#__PURE__*/(0,jsx_runtime.jsx)(es_button/* default */.Z, { className: "ml20", type: "primary", onClick: function onClick() { onSave(); }, children: "\u4FDD\u5B58" })] })] }); }; var actionArr = [{ name: "删除", icon: "iconfont c-light-black ml30 icon-shanchu current", id: "del" }, { name: "(向下插入填空题)", icon: "iconfont c-light-primary ml30 icon-tianjia current", id: "add" }, { name: "编辑", icon: "iconfont c-light-primary ml30 icon-bianjishijuan3x current", id: "edit" }]; var actionClick = /*#__PURE__*/function () { var _ref3 = asyncToGenerator_default()( /*#__PURE__*/regeneratorRuntime_default()().mark(function _callee4(item) { return regeneratorRuntime_default()().wrap(function _callee4$(_context4) { while (1) switch (_context4.prev = _context4.next) { case 0: if (!(editKey !== -1)) { _context4.next = 3; break; } message/* default.error */.ZP.error("请先保存或取消当前正在编辑的问题。"); return _context4.abrupt("return"); case 3: _context4.t0 = item.id; _context4.next = _context4.t0 === "del" ? 6 : _context4.t0 === "edit" ? 8 : _context4.t0 === "add" ? 11 : 13; break; case 6: modal/* default.confirm */.Z.confirm({ centered: true, okText: '确定', cancelText: '取消', title: '确认要删除这个试题吗?', onOk: function onOk() { return asyncToGenerator_default()( /*#__PURE__*/regeneratorRuntime_default()().mark(function _callee3() { return regeneratorRuntime_default()().wrap(function _callee3$(_context3) { while (1) switch (_context3.prev = _context3.next) { case 0: _context3.next = 2; return (0,paperlibrary/* deleteQuestion */.Km)({ question_id: editData.question_id, exam_id: params.id }); case 2: reload(); case 3: case "end": return _context3.stop(); } }, _callee3); }))(); } }); return _context4.abrupt("break", 13); case 8: setEditKey(editData.dragKey); setIsEdit(true); return _context4.abrupt("break", 13); case 11: addCallback({ key: editData.key, insert_id: editData === null || editData === void 0 ? void 0 : editData.question_id, question_type: 3 }); return _context4.abrupt("break", 13); case 13: case "end": return _context4.stop(); } }, _callee4); })); return function actionClick(_x) { return _ref3.apply(this, arguments); }; }(); var showList = function showList() { var _editData$standard_an; return /*#__PURE__*/(0,jsx_runtime.jsxs)("aside", { children: [/*#__PURE__*/(0,jsx_runtime.jsx)("div", { className: Questions_editormodules.questionType, children: !(editData !== null && editData !== void 0 && editData.isPreview) && /*#__PURE__*/(0,jsx_runtime.jsxs)("div", { children: [/*#__PURE__*/(0,jsx_runtime.jsxs)("span", { className: "font16 c-blue", children: [editData.key, "\u3001\u586B\u7A7A\u9898"] }), "\uFF08", editData.question_score, "\u5206\uFF09"] }) }), editData !== null && editData !== void 0 && editData.isPreview ? /*#__PURE__*/(0,jsx_runtime.jsxs)("div", { style: { display: 'flex' }, children: [/*#__PURE__*/(0,jsx_runtime.jsxs)("span", { style: { flexShrink: 0 }, className: "font18", children: [editData.key, "."] }), /*#__PURE__*/(0,jsx_runtime.jsx)(RenderHtml/* default */.Z, { value: editData.question_title }), /*#__PURE__*/(0,jsx_runtime.jsxs)("span", { style: { flexShrink: 0 }, className: "font16", children: ["\uFF08", editData.question_score, "\u5206\uFF09"] })] }) : /*#__PURE__*/(0,jsx_runtime.jsx)("div", { className: "mt5", children: /*#__PURE__*/(0,jsx_runtime.jsx)(RenderHtml/* default */.Z, { value: editData.question_title }) }), /*#__PURE__*/(0,jsx_runtime.jsx)("div", { className: Questions_editormodules.questionChoices, children: editData === null || editData === void 0 ? void 0 : (_editData$standard_an = editData.standard_answer) === null || _editData$standard_an === void 0 ? void 0 : _editData$standard_an.map(function (item, index) { return /*#__PURE__*/(0,jsx_runtime.jsxs)(row/* default */.Z, { align: "middle", children: [/*#__PURE__*/(0,jsx_runtime.jsxs)(col/* default */.Z, { children: ["\u7B54\u6848\uFF08\u586B\u7A7A", item.choice_id, "\uFF09\uFF1A"] }), /*#__PURE__*/(0,jsx_runtime.jsx)(col/* default */.Z, { flex: "1", children: /*#__PURE__*/(0,jsx_runtime.jsx)(row/* default */.Z, { align: "middle", gutter: [1, 1], children: item.answer_text.map(function (val, key) { return /*#__PURE__*/(0,jsx_runtime.jsx)(col/* default */.Z, { span: 24, children: /*#__PURE__*/(0,jsx_runtime.jsx)(input/* default */.Z, { checked: editData.standard_answer.includes(index), disabled: true, value: val }, index) }, key); }) }) })] }, index); }) }), /*#__PURE__*/(0,jsx_runtime.jsx)("div", { className: Questions_editormodules.action, children: !editData.hideAction && actionArr.map(function (item, index) { if (item.id === "up" && editData.key === 1) return null; if (item.id === "down" && editData.key === editData.len) return null; return /*#__PURE__*/(0,jsx_runtime.jsx)(tooltip/* default */.Z, { placement: "bottom", title: item.name, children: /*#__PURE__*/(0,jsx_runtime.jsx)("span", { onClick: function onClick() { return actionClick(item); }, className: item.icon }) }, index); }) })] }); }; return /*#__PURE__*/(0,jsx_runtime.jsxs)("section", { className: Questions_editormodules.wrap, children: [!isEdit && showList(), isEdit && showEdit()] }); }; /* harmony default export */ var Questions_CompletionEditor = ((0,_umi_production_exports.connect)(function (_ref4) { var newExercisePaper = _ref4.newExercisePaper; return { newExercisePaper: newExercisePaper }; }, null, null, { forwardRef: true })( /*#__PURE__*/(0,react.forwardRef)(CompletionEditor_CompletionEditor))); ;// CONCATENATED MODULE: ./src/pages/Paperlibrary/EditPaper/Questions/SubjectiveEditor.tsx var SubjectiveEditor_SubjectiveEditor = function SubjectiveEditor(_ref, ref) { var newExercisePaper = _ref.newExercisePaper, dispatch = _ref.dispatch, editData = _ref.editData, _ref$cancelAdd = _ref.cancelAdd, cancelAdd = _ref$cancelAdd === void 0 ? function () {} : _ref$cancelAdd, editKey = _ref.editKey, _ref$setEditKey = _ref.setEditKey, setEditKey = _ref$setEditKey === void 0 ? function () {} : _ref$setEditKey, _ref$reload = _ref.reload, reload = _ref$reload === void 0 ? function () {} : _ref$reload, _ref$addCallback = _ref.addCallback, addCallback = _ref$addCallback === void 0 ? function () {} : _ref$addCallback; var _useState = (0,react.useState)(''), _useState2 = slicedToArray_default()(_useState, 2), title = _useState2[0], setTitle = _useState2[1]; var _useState3 = (0,react.useState)(''), _useState4 = slicedToArray_default()(_useState3, 2), analysis = _useState4[0], setAnalysis = _useState4[1]; var _useState5 = (0,react.useState)(''), _useState6 = slicedToArray_default()(_useState5, 2), answer = _useState6[0], setAnswer = _useState6[1]; var _useState7 = (0,react.useState)(), _useState8 = slicedToArray_default()(_useState7, 2), score = _useState8[0], setScore = _useState8[1]; var _useState9 = (0,react.useState)(false), _useState10 = slicedToArray_default()(_useState9, 2), isEdit = _useState10[0], setIsEdit = _useState10[1]; var _useState11 = (0,react.useState)([]), _useState12 = slicedToArray_default()(_useState11, 2), knowledge = _useState12[0], setKnowledge = _useState12[1]; var _useState13 = (0,react.useState)(1), _useState14 = slicedToArray_default()(_useState13, 2), difficulty = _useState14[0], setdifficult = _useState14[1]; var _useState15 = (0,react.useState)(false), _useState16 = slicedToArray_default()(_useState15, 2), repeat_answer = _useState16[0], setrepeat_answer = _useState16[1]; var _useState17 = (0,react.useState)([[], []]), _useState18 = slicedToArray_default()(_useState17, 2), keyword = _useState18[0], setKeyword = _useState18[1]; var freeze = (0,react.useRef)(false); var params = (0,_umi_production_exports.useParams)(); var _useState19 = (0,react.useState)([]), _useState20 = slicedToArray_default()(_useState19, 2), knowledgeOptions = _useState20[0], setKnowledgeOptions = _useState20[1]; var handleAddKnowledgeFinish = function handleAddKnowledgeFinish(item) { setKnowledgeOptions([].concat(toConsumableArray_default()(knowledgeOptions), [objectSpread2_default()({}, item)])); }; (0,react.useEffect)(function () { var _editData$standard_an; if (freeze.current) return; if (!(editData !== null && editData !== void 0 && editData.question_title)) { setIsEdit(true); setTitle(''); setAnswer(''); setScore(10); return; } setrepeat_answer(!(editData !== null && editData !== void 0 && editData.repeat_answer)); setTitle(editData === null || editData === void 0 ? void 0 : editData.question_title); setAnswer(editData === null || editData === void 0 ? void 0 : (_editData$standard_an = editData.standard_answer) === null || _editData$standard_an === void 0 ? void 0 : _editData$standard_an[0]); setScore(editData === null || editData === void 0 ? void 0 : editData.question_score); setKnowledge(editData.tag_discipline_ids); setdifficult(editData === null || editData === void 0 ? void 0 : editData.difficulty); setAnalysis(editData === null || editData === void 0 ? void 0 : editData.analysis); setKeyword([editData === null || editData === void 0 ? void 0 : editData.normal_keywords, editData === null || editData === void 0 ? void 0 : editData.main_keywords]); }, [newExercisePaper.editData, isEdit]); (0,react.useEffect)(function () { var _newExercisePaper$tag; var data = newExercisePaper !== null && newExercisePaper !== void 0 && (_newExercisePaper$tag = newExercisePaper.tagDisciplineData) !== null && _newExercisePaper$tag !== void 0 && _newExercisePaper$tag.tag_disciplines && Array.isArray(newExercisePaper.tagDisciplineData.tag_disciplines) ? newExercisePaper.tagDisciplineData.tag_disciplines : []; setKnowledgeOptions(data); }, [newExercisePaper.tagDisciplineData]); (0,react.useEffect)(function () { if (isEdit) { init(); } function init() { return _init.apply(this, arguments); } function _init() { _init = asyncToGenerator_default()( /*#__PURE__*/regeneratorRuntime_default()().mark(function _callee() { var _newExercisePaper$edi, _newExercisePaper$edi2; var res; return regeneratorRuntime_default()().wrap(function _callee$(_context) { while (1) switch (_context.prev = _context.next) { case 0: _context.next = 2; return (0,service_exercise/* getTagDiscipline */.YY)({ sub_discipline_id: (_newExercisePaper$edi = newExercisePaper.editData) === null || _newExercisePaper$edi === void 0 ? void 0 : (_newExercisePaper$edi2 = _newExercisePaper$edi.exercise) === null || _newExercisePaper$edi2 === void 0 ? void 0 : _newExercisePaper$edi2.sub_discipline_id }); case 2: res = _context.sent; setKnowledgeOptions(res.tag_disciplines); case 4: case "end": return _context.stop(); } }, _callee); })); return _init.apply(this, arguments); } }, [isEdit]); (0,react.useImperativeHandle)(ref, function () { return { onSave: onSave, isEdit: isEdit }; }); var repeal = function repeal(res) { if ((res === null || res === void 0 ? void 0 : res.status) === 0) { message/* default.success */.ZP.success("保存成功"); setIsEdit(false); setEditKey(-1); freeze.current = false; reload(); } }; var onSave = /*#__PURE__*/function () { var _ref2 = asyncToGenerator_default()( /*#__PURE__*/regeneratorRuntime_default()().mark(function _callee2() { var normal_keywords, main_keywords, res, _newExercisePaper$edi3, _newExercisePaper$edi4, _newExercisePaper$edi5, _newExercisePaper$edi6; return regeneratorRuntime_default()().wrap(function _callee2$(_context2) { while (1) switch (_context2.prev = _context2.next) { case 0: if (title) { _context2.next = 3; break; } message/* default.info */.ZP.info("请您输入题干"); return _context2.abrupt("return", false); case 3: // if (knowledge.length < 1) { // message.info("请选择知识点"); // return false; // } normal_keywords = keyword[0]; main_keywords = keyword[1]; freeze.current = true; if (!editData.question_id) { _context2.next = 13; break; } _context2.next = 9; return dispatch({ type: "newExercisePaper/editExerciseQuestion", payload: { "id": params.id, "question_id": editData.question_id, "name": title, "item_type": 4, "question_score": score, "answer_texts": [answer], "tag_discipline_ids": knowledge, "sub_discipline_id": (_newExercisePaper$edi3 = newExercisePaper.editData) === null || _newExercisePaper$edi3 === void 0 ? void 0 : (_newExercisePaper$edi4 = _newExercisePaper$edi3.exercise) === null || _newExercisePaper$edi4 === void 0 ? void 0 : _newExercisePaper$edi4.sub_discipline_id, "difficulty": difficulty, "repeat_answer": !repeat_answer, analysis: analysis, normal_keywords: normal_keywords, main_keywords: main_keywords } }); case 9: res = _context2.sent; repeal(res); _context2.next = 17; break; case 13: _context2.next = 15; return dispatch({ type: "newExercisePaper/addExerciseQuestion", payload: { insert_id: editData === null || editData === void 0 ? void 0 : editData.insert_id, "id": params.id, "name": title, "item_type": 4, "question_score": score, "answer_texts": [answer], "tag_discipline_ids": knowledge, "sub_discipline_id": (_newExercisePaper$edi5 = newExercisePaper.editData) === null || _newExercisePaper$edi5 === void 0 ? void 0 : (_newExercisePaper$edi6 = _newExercisePaper$edi5.exercise) === null || _newExercisePaper$edi6 === void 0 ? void 0 : _newExercisePaper$edi6.sub_discipline_id, "difficulty": difficulty, "repeat_answer": !repeat_answer, analysis: analysis, normal_keywords: normal_keywords, main_keywords: main_keywords } }); case 15: res = _context2.sent; repeal(res); case 17: return _context2.abrupt("return", { name: title, answer_texts: [answer], analysis: analysis, normal_keywords: normal_keywords, main_keywords: main_keywords }); case 18: case "end": return _context2.stop(); } }, _callee2); })); return function onSave() { return _ref2.apply(this, arguments); }; }(); var showEdit = function showEdit() { var _newExercisePaper$edi7, _newExercisePaper$edi8; return /*#__PURE__*/(0,jsx_runtime.jsxs)("aside", { children: [/*#__PURE__*/(0,jsx_runtime.jsx)("div", { className: Questions_editormodules.questionType, children: /*#__PURE__*/(0,jsx_runtime.jsxs)("div", { children: [/*#__PURE__*/(0,jsx_runtime.jsx)("span", { className: "font16 c-blue", children: "\u4E3B\u89C2\u9898" }), "\uFF08\u4E3B\u89C2\u9898\uFF0C\u672A\u4F5C\u7B54\u7684\u60C5\u51B5\u4E0B\u81EA\u52A8\u8BC4\u4E3A\u96F6\u5206\uFF09"] }) }), /*#__PURE__*/(0,jsx_runtime.jsx)(markdown_editor/* default */.Z, { id: "single-question-title", watch: true, height: 155, placeholder: "\u8BF7\u60A8\u8F93\u5165\u9898\u5E72", defaultValue: title, onChange: function onChange(value) { return setTitle(value); } }), /*#__PURE__*/(0,jsx_runtime.jsx)("p", { className: Questions_editormodules.titleWrap, children: /*#__PURE__*/(0,jsx_runtime.jsx)("span", { className: Questions_editormodules.title, children: "\u53C2\u8003\u7B54\u6848\uFF1A" }) }), /*#__PURE__*/(0,jsx_runtime.jsx)(markdown_editor/* default */.Z, { id: "single-question-reference-answer", watch: true, height: 155, placeholder: "\u8BF7\u60A8\u8F93\u5165\u53C2\u8003\u7B54\u6848", defaultValue: answer, onChange: function onChange(value) { return setAnswer(value); } }), /*#__PURE__*/(0,jsx_runtime.jsx)(EditorKeyword/* default */.Z, { value: keyword, onChange: setKeyword }), /*#__PURE__*/(0,jsx_runtime.jsx)("p", { className: Questions_editormodules.titleWrap, children: /*#__PURE__*/(0,jsx_runtime.jsx)("span", { className: Questions_editormodules.title, children: "\u9898\u76EE\u89E3\u6790\uFF1A" }) }), /*#__PURE__*/(0,jsx_runtime.jsx)(markdown_editor/* default */.Z, { id: "single-question-title", watch: true, height: 155, placeholder: "\u8BF7\u60A8\u8F93\u5165\u9898\u76EE\u89E3\u6790", defaultValue: analysis, onChange: function onChange(value) { return setAnalysis(value); } }), /*#__PURE__*/(0,jsx_runtime.jsxs)("p", { className: "", children: ["\u5206\u503C\uFF1A", /*#__PURE__*/(0,jsx_runtime.jsx)(input_number/* default */.Z, { value: score, max: 10000, min: 0, onChange: function onChange(value) { setScore(value); } }), " \u5206", /*#__PURE__*/(0,jsx_runtime.jsxs)("span", { style: { marginLeft: '30px' }, className: Questions_editormodules.difficult, children: [/*#__PURE__*/(0,jsx_runtime.jsx)("label", { style: { color: 'red' }, children: "*" }), " \u96BE\u5EA6\uFF1A", /*#__PURE__*/(0,jsx_runtime.jsxs)(es_radio/* default.Group */.ZP.Group, { value: difficulty, onChange: function onChange(e) { setdifficult(e.target.value); }, children: [/*#__PURE__*/(0,jsx_runtime.jsx)(es_radio/* default.Button */.ZP.Button, { value: 1, children: "\u7B80\u5355" }), /*#__PURE__*/(0,jsx_runtime.jsx)(es_radio/* default.Button */.ZP.Button, { value: 2, children: "\u9002\u4E2D" }), /*#__PURE__*/(0,jsx_runtime.jsx)(es_radio/* default.Button */.ZP.Button, { value: 3, children: "\u56F0\u96BE" })] })] })] }), /*#__PURE__*/(0,jsx_runtime.jsxs)("p", { className: Questions_editormodules.titleWrap, children: [/*#__PURE__*/(0,jsx_runtime.jsxs)("span", { className: "".concat(Questions_editormodules.title), children: ["\u77E5\u8BC6\u70B9\uFF1A", /*#__PURE__*/(0,jsx_runtime.jsx)("span", { className: Questions_editormodules.colorGray, children: "\uFF08\u6240\u6709\u81EA\u5EFA\u77E5\u8BC6\u70B9\u4EC5\u672C\u4EBA\u53EF\u89C1\uFF0C\u88ABEduCoder\u5E73\u53F0\u5BA1\u6838\u901A\u8FC7\u4E3A\u5B98\u65B9\u77E5\u8BC6\u70B9\u540E\u6240\u6709\u7528\u6237\u53EF\u89C1\uFF09" })] }), /*#__PURE__*/(0,jsx_runtime.jsx)("div", { className: "mt5", children: /*#__PURE__*/(0,jsx_runtime.jsx)(Knowledge/* Knowledge */.N, { value: knowledge, selectvalues: editData === null || editData === void 0 ? void 0 : editData.tag_discipline_ids, onChange: setKnowledge, subId: (_newExercisePaper$edi7 = newExercisePaper.editData) === null || _newExercisePaper$edi7 === void 0 ? void 0 : (_newExercisePaper$edi8 = _newExercisePaper$edi7.exercise) === null || _newExercisePaper$edi8 === void 0 ? void 0 : _newExercisePaper$edi8.sub_discipline_id, knowledgeOptions: knowledgeOptions, onAddKnowledgeFinish: handleAddKnowledgeFinish }) }), /*#__PURE__*/(0,jsx_runtime.jsxs)("div", { style: { marginTop: 10 }, children: [/*#__PURE__*/(0,jsx_runtime.jsx)("span", { style: { marginRight: 10 }, children: "\u4E0D\u5141\u8BB8\u5B66\u751F\u91CD\u590D\u7B54\u9898" }), /*#__PURE__*/(0,jsx_runtime.jsx)(es_switch/* default */.Z, { checked: repeat_answer, onChange: function onChange(e) { setrepeat_answer(e); } })] })] }), /*#__PURE__*/(0,jsx_runtime.jsxs)("aside", { className: "tr", children: [(editKey !== -1 || editData.question_id) && /*#__PURE__*/(0,jsx_runtime.jsx)(es_button/* default */.Z, { type: "default", onClick: function onClick() { cancelAdd(); setIsEdit(false); }, children: "\u53D6\u6D88" }), /*#__PURE__*/(0,jsx_runtime.jsx)(es_button/* default */.Z, { className: "ml20", type: "primary", onClick: function onClick() { onSave(); }, children: "\u4FDD\u5B58" })] })] }); }; var actionArr = [{ name: "删除", icon: "iconfont c-light-black ml30 icon-shanchu current", id: "del" }, { name: "(向下插入简答题)", icon: "iconfont c-light-primary ml30 icon-tianjia current", id: "add" }, { name: "编辑", icon: "iconfont c-light-primary ml30 icon-bianjishijuan3x current", id: "edit" }]; var actionClick = /*#__PURE__*/function () { var _ref3 = asyncToGenerator_default()( /*#__PURE__*/regeneratorRuntime_default()().mark(function _callee4(item) { return regeneratorRuntime_default()().wrap(function _callee4$(_context4) { while (1) switch (_context4.prev = _context4.next) { case 0: if (!(editKey !== -1)) { _context4.next = 3; break; } message/* default.error */.ZP.error("请先保存或取消当前正在编辑的问题。"); return _context4.abrupt("return"); case 3: _context4.t0 = item.id; _context4.next = _context4.t0 === "del" ? 6 : _context4.t0 === "edit" ? 8 : _context4.t0 === "add" ? 11 : 13; break; case 6: modal/* default.confirm */.Z.confirm({ centered: true, okText: '确定', cancelText: '取消', title: '确认要删除这个试题吗?', onOk: function onOk() { return asyncToGenerator_default()( /*#__PURE__*/regeneratorRuntime_default()().mark(function _callee3() { return regeneratorRuntime_default()().wrap(function _callee3$(_context3) { while (1) switch (_context3.prev = _context3.next) { case 0: _context3.next = 2; return (0,paperlibrary/* deleteQuestion */.Km)({ question_id: editData.question_id, exam_id: params.id }); case 2: reload(); case 3: case "end": return _context3.stop(); } }, _callee3); }))(); } }); return _context4.abrupt("break", 13); case 8: setEditKey(editData.dragKey); setIsEdit(true); return _context4.abrupt("break", 13); case 11: addCallback({ key: editData.key, insert_id: editData === null || editData === void 0 ? void 0 : editData.question_id, question_type: 4 }); return _context4.abrupt("break", 13); case 13: case "end": return _context4.stop(); } }, _callee4); })); return function actionClick(_x) { return _ref3.apply(this, arguments); }; }(); var showList = function showList() { return /*#__PURE__*/(0,jsx_runtime.jsxs)("aside", { children: [/*#__PURE__*/(0,jsx_runtime.jsx)("div", { className: Questions_editormodules.questionType, children: !(editData !== null && editData !== void 0 && editData.isPreview) && /*#__PURE__*/(0,jsx_runtime.jsxs)("div", { children: [/*#__PURE__*/(0,jsx_runtime.jsxs)("span", { className: "font16 c-blue", children: [editData.key, "\u3001\u7B80\u7B54\u9898"] }), "\uFF08", editData.question_score, "\u5206\uFF09"] }) }), editData !== null && editData !== void 0 && editData.isPreview ? /*#__PURE__*/(0,jsx_runtime.jsxs)("div", { style: { display: 'flex' }, children: [/*#__PURE__*/(0,jsx_runtime.jsxs)("span", { style: { flexShrink: 0 }, className: "font18", children: [editData.key, "."] }), /*#__PURE__*/(0,jsx_runtime.jsx)(RenderHtml/* default */.Z, { value: editData.question_title }), /*#__PURE__*/(0,jsx_runtime.jsxs)("span", { style: { flexShrink: 0 }, className: "font16", children: ["\uFF08", editData.question_score, "\u5206\uFF09"] })] }) : /*#__PURE__*/(0,jsx_runtime.jsx)("div", { className: "mt5", children: /*#__PURE__*/(0,jsx_runtime.jsx)(RenderHtml/* default */.Z, { value: editData.question_title }) }), /*#__PURE__*/(0,jsx_runtime.jsxs)("div", { className: Questions_editormodules.questionChoices, children: [/*#__PURE__*/(0,jsx_runtime.jsx)("p", { children: /*#__PURE__*/(0,jsx_runtime.jsx)("strong", { children: "\u53C2\u8003\u7B54\u6848\uFF1A" }) }), /*#__PURE__*/(0,jsx_runtime.jsx)(RenderHtml/* default */.Z, { value: answer || '' })] }), /*#__PURE__*/(0,jsx_runtime.jsx)("div", { className: Questions_editormodules.action, children: !editData.hideAction && actionArr.map(function (item, index) { return /*#__PURE__*/(0,jsx_runtime.jsx)(tooltip/* default */.Z, { placement: "bottom", title: item.name, children: /*#__PURE__*/(0,jsx_runtime.jsx)("span", { onClick: function onClick() { return actionClick(item); }, className: item.icon }) }, index); }) })] }); }; return /*#__PURE__*/(0,jsx_runtime.jsxs)("section", { className: Questions_editormodules.wrap, children: [!isEdit && showList(), isEdit && showEdit()] }); }; /* harmony default export */ var Questions_SubjectiveEditor = ((0,_umi_production_exports.connect)(function (_ref4) { var newExercisePaper = _ref4.newExercisePaper; return { newExercisePaper: newExercisePaper }; }, null, null, { forwardRef: true })( /*#__PURE__*/(0,react.forwardRef)(SubjectiveEditor_SubjectiveEditor))); ;// CONCATENATED MODULE: ./src/pages/Paperlibrary/EditPaper/Questions/ShixunEditor.tsx var ShixunEditor_ShixunEditor = function ShixunEditor(_ref, ref) { var dispatch = _ref.dispatch, editData = _ref.editData, _ref$cancelAdd = _ref.cancelAdd, cancelAdd = _ref$cancelAdd === void 0 ? function () {} : _ref$cancelAdd, editKey = _ref.editKey, _ref$setEditKey = _ref.setEditKey, setEditKey = _ref$setEditKey === void 0 ? function () {} : _ref$setEditKey, _ref$reload = _ref.reload, reload = _ref$reload === void 0 ? function () {} : _ref$reload; var _useState = (0,react.useState)(''), _useState2 = slicedToArray_default()(_useState, 2), name = _useState2[0], setName = _useState2[1]; var _useState3 = (0,react.useState)(''), _useState4 = slicedToArray_default()(_useState3, 2), title = _useState4[0], setTitle = _useState4[1]; var _useState5 = (0,react.useState)(''), _useState6 = slicedToArray_default()(_useState5, 2), analysis = _useState6[0], setAnalysis = _useState6[1]; var _useState7 = (0,react.useState)([]), _useState8 = slicedToArray_default()(_useState7, 2), answerList = _useState8[0], setAnswerList = _useState8[1]; var _useState9 = (0,react.useState)(), _useState10 = slicedToArray_default()(_useState9, 2), checked = _useState10[0], setChecked = _useState10[1]; var _useState11 = (0,react.useState)(false), _useState12 = slicedToArray_default()(_useState11, 2), firstSetAnswerFlag = _useState12[0], setFirstSetAnswerFlag = _useState12[1]; var _useState13 = (0,react.useState)([]), _useState14 = slicedToArray_default()(_useState13, 2), score = _useState14[0], setScore = _useState14[1]; var _useState15 = (0,react.useState)(false), _useState16 = slicedToArray_default()(_useState15, 2), isEdit = _useState16[0], setIsEdit = _useState16[1]; var _useState17 = (0,react.useState)(false), _useState18 = slicedToArray_default()(_useState17, 2), btnLoading = _useState18[0], setBtnLoading = _useState18[1]; var params = (0,_umi_production_exports.useParams)(); var freeze = (0,react.useRef)(false); (0,react.useEffect)(function () { var _editData$shixun; if (freeze.current) return; if (editData.edit) { setIsEdit(true); setTitle(''); setName(''); setScore([]); } setName(editData.shixun_name); setTitle(editData.question_title); var arr = []; (_editData$shixun = editData.shixun) === null || _editData$shixun === void 0 ? void 0 : _editData$shixun.map(function (item) { arr.push(parseFloat(item.challenge_score)); }); setScore(arr); }, [editData]); (0,react.useEffect)(function () { setFirstSetAnswerFlag(false); }, [isEdit]); (0,react.useImperativeHandle)(ref, function () { return { onSave: onSave, isEdit: isEdit }; }); var repeal = function repeal(res) { if ((res === null || res === void 0 ? void 0 : res.status) === 0) { message/* default.success */.ZP.success('保存成功'); setIsEdit(false); setEditKey(-1); freeze.current = false; reload(); } }; var onSave = /*#__PURE__*/function () { var _ref2 = asyncToGenerator_default()( /*#__PURE__*/regeneratorRuntime_default()().mark(function _callee() { var answerArray, isEmpty, res; return regeneratorRuntime_default()().wrap(function _callee$(_context) { while (1) switch (_context.prev = _context.next) { case 0: answerArray = []; isEmpty = false; if (!isEmpty) { _context.next = 4; break; } return _context.abrupt("return", false); case 4: freeze.current = true; setBtnLoading(true); if (!editData.question_id) { _context.next = 12; break; } _context.next = 9; return dispatch({ type: 'newExercisePaper/editExerciseQuestion', payload: { id: params.id, question_id: editData.question_id, name: title, shixun_name: name, shixun_id: editData.shixun_id, item_type: 5, question_scores: score } }); case 9: res = _context.sent; _context.next = 15; break; case 12: _context.next = 14; return dispatch({ type: 'newExercisePaper/addExerciseQuestion', payload: { id: params.id, insert_id: editData === null || editData === void 0 ? void 0 : editData.insert_id, name: title, shixun_name: name, shixun_id: editData.shixun_id, item_type: 5, question_scores: score, is_copy: editData.is_copy } }); case 14: res = _context.sent; case 15: repeal(res); setBtnLoading(false); return _context.abrupt("return", { name: title, analysis: analysis, standard_answers: answerArray, is_ordered: checked }); case 18: case "end": return _context.stop(); } }, _callee); })); return function onSave() { return _ref2.apply(this, arguments); }; }(); var showEdit = function showEdit() { var _editData$shixun2; return /*#__PURE__*/(0,jsx_runtime.jsxs)("aside", { children: [/*#__PURE__*/(0,jsx_runtime.jsx)("div", { className: Questions_editormodules.questionType, children: /*#__PURE__*/(0,jsx_runtime.jsxs)("div", { children: [/*#__PURE__*/(0,jsx_runtime.jsx)("span", { className: "font16 c-blue", children: "\u5B9E\u8BAD\u9898" }), "\uFF08\u5BA2\u89C2\u9898\uFF0C\u7531\u7CFB\u7EDF\u81EA\u52A8\u8BC4\u5206\uFF0C\u5141\u8BB8\u624B\u52A8\u8C03\u5206\uFF09"] }) }), /*#__PURE__*/(0,jsx_runtime.jsx)("div", { className: "mt10", children: /*#__PURE__*/(0,jsx_runtime.jsx)(input/* default */.Z, { defaultValue: name, onChange: function onChange(e) { setName(e.target.value); } }) }), /*#__PURE__*/(0,jsx_runtime.jsx)("div", { className: "mt10", children: /*#__PURE__*/(0,jsx_runtime.jsx)(markdown_editor/* default */.Z, { id: "single-question-option-0", height: 155, placeholder: "\u8BF7\u8F93\u5165\u5B9E\u8BAD\u9898\u5B8C\u6210\u8981\u6C42", defaultValue: title, onChange: function onChange(value) { setTitle(value); } }) }), /*#__PURE__*/(0,jsx_runtime.jsx)("div", { className: "mt20", children: (_editData$shixun2 = editData.shixun) === null || _editData$shixun2 === void 0 ? void 0 : _editData$shixun2.map(function (item, index) { return /*#__PURE__*/(0,jsx_runtime.jsxs)(row/* default */.Z, { gutter: [20, 20], children: [/*#__PURE__*/(0,jsx_runtime.jsxs)(col/* default */.Z, { flex: "1", children: [index + 1, ".", item.challenge_name] }), /*#__PURE__*/(0,jsx_runtime.jsxs)(col/* default */.Z, { children: [/*#__PURE__*/(0,jsx_runtime.jsx)(input_number/* default */.Z, { defaultValue: score[index], onChange: function onChange(value) { var newScoreArr = toConsumableArray_default()(score); newScoreArr[index] = value; setScore(newScoreArr); } }), "\u5206"] })] }); }) }), /*#__PURE__*/(0,jsx_runtime.jsx)("div", { className: "mt20", children: answerList.length > 1 && /*#__PURE__*/(0,jsx_runtime.jsxs)("span", { children: [/*#__PURE__*/(0,jsx_runtime.jsx)(es_checkbox/* default */.Z, { checked: checked, onChange: function onChange(e) { return setChecked(e.target.checked); }, className: "".concat(Questions_editormodules.color333, " font14"), children: "\u591A\u4E2A\u586B\u7A7A\u7684\u7B54\u6848\u6709\u987A\u5E8F\u8981\u6C42" }), /*#__PURE__*/(0,jsx_runtime.jsx)("span", { className: "".concat(Questions_editormodules.color999, " font12"), children: "\uFF08\u9009\u4E2D\uFF0C\u6BCF\u4E2A\u586B\u7A7A\u7684\u7B54\u6848\u987A\u5E8F\u5FC5\u987B\u4E0E\u53C2\u8003\u7B54\u6848\u4E00\u81F4\uFF09" })] }) }), /*#__PURE__*/(0,jsx_runtime.jsxs)("aside", { className: "tr", children: [(editKey !== -1 || !(editData !== null && editData !== void 0 && editData.edit)) && /*#__PURE__*/(0,jsx_runtime.jsx)(es_button/* default */.Z, { type: "default", onClick: function onClick() { cancelAdd(); setIsEdit(false); }, children: "\u53D6\u6D88" }), /*#__PURE__*/(0,jsx_runtime.jsx)(es_button/* default */.Z, { loading: btnLoading, className: "ml20", type: "primary", onClick: function onClick() { onSave(); }, children: "\u4FDD\u5B58" })] })] }); }; var actionArr = [{ name: '删除', icon: 'iconfont c-light-black ml30 icon-shanchu current', id: 'del' }, { name: '(向下插入实训题)', icon: 'iconfont c-light-primary ml30 icon-tianjia current', id: 'add' }, { name: '编辑', icon: 'iconfont c-light-primary ml30 icon-bianjishijuan3x current', id: 'edit' }]; var actionClick = /*#__PURE__*/function () { var _ref3 = asyncToGenerator_default()( /*#__PURE__*/regeneratorRuntime_default()().mark(function _callee3(item) { return regeneratorRuntime_default()().wrap(function _callee3$(_context3) { while (1) switch (_context3.prev = _context3.next) { case 0: if (!(editKey !== -1)) { _context3.next = 3; break; } message/* default.error */.ZP.error('请先保存或取消当前正在编辑的问题。'); return _context3.abrupt("return"); case 3: _context3.t0 = item.id; _context3.next = _context3.t0 === 'del' ? 6 : _context3.t0 === 'edit' ? 8 : _context3.t0 === 'add' ? 11 : 13; break; case 6: modal/* default.confirm */.Z.confirm({ centered: true, okText: '确定', cancelText: '取消', title: '确认要删除这个试题吗?', onOk: function onOk() { return asyncToGenerator_default()( /*#__PURE__*/regeneratorRuntime_default()().mark(function _callee2() { return regeneratorRuntime_default()().wrap(function _callee2$(_context2) { while (1) switch (_context2.prev = _context2.next) { case 0: _context2.next = 2; return (0,paperlibrary/* deleteQuestion */.Km)({ question_id: editData.question_id, exam_id: params.id }); case 2: reload(); case 3: case "end": return _context2.stop(); } }, _callee2); }))(); } }); return _context3.abrupt("break", 13); case 8: setEditKey(editData.dragKey); setIsEdit(true); return _context3.abrupt("break", 13); case 11: dispatch({ type: 'classroomList/setActionTabs', payload: { key: '选用实践项目', editData: { key: editData.key, insert_id: editData === null || editData === void 0 ? void 0 : editData.question_id, question_type: 5 } } }); return _context3.abrupt("break", 13); case 13: case "end": return _context3.stop(); } }, _callee3); })); return function actionClick(_x) { return _ref3.apply(this, arguments); }; }(); var showList = function showList() { var _editData$schools, _editData$shixun3; return /*#__PURE__*/(0,jsx_runtime.jsxs)("aside", { children: [/*#__PURE__*/(0,jsx_runtime.jsx)("div", { className: Questions_editormodules.questionType, children: !(editData !== null && editData !== void 0 && editData.isPreview) && /*#__PURE__*/(0,jsx_runtime.jsxs)("div", { children: [/*#__PURE__*/(0,jsx_runtime.jsxs)("span", { className: "font16 c-blue", children: [editData.key, "\u3001\u5B9E\u8BAD\u9898"] }), "\uFF08", editData.question_score, "\u5206\uFF09"] }) }), editData !== null && editData !== void 0 && editData.isPreview ? /*#__PURE__*/(0,jsx_runtime.jsxs)("div", { style: { display: 'flex' }, children: [/*#__PURE__*/(0,jsx_runtime.jsxs)("span", { style: { flexShrink: 0 }, className: "font18", children: [editData.key, "."] }), /*#__PURE__*/(0,jsx_runtime.jsx)(RenderHtml/* default */.Z, { value: editData.shixun_name }), /*#__PURE__*/(0,jsx_runtime.jsxs)("span", { style: { flexShrink: 0 }, className: "font16", children: ["\uFF08", editData.question_score, "\u5206\uFF09"] }), !!((_editData$schools = editData.schools) !== null && _editData$schools !== void 0 && _editData$schools.length) && /*#__PURE__*/(0,jsx_runtime.jsx)(tooltip/* default */.Z, { title: "\u8BE5\u5B9E\u8BAD\u9898\u9762\u5411\u6307\u5B9A\u5355\u4F4D\u5F00\u653E", children: /*#__PURE__*/(0,jsx_runtime.jsx)("i", { className: "iconfont icon-zhidinggongkai1 font18 line24 c-orange" }) })] }) : /*#__PURE__*/(0,jsx_runtime.jsx)("div", { className: "mt5", children: /*#__PURE__*/(0,jsx_runtime.jsx)(RenderHtml/* default */.Z, { value: editData.shixun_name }) }), /*#__PURE__*/(0,jsx_runtime.jsx)("div", { className: "mt30" }), (_editData$shixun3 = editData.shixun) === null || _editData$shixun3 === void 0 ? void 0 : _editData$shixun3.map(function (item, index) { return /*#__PURE__*/(0,jsx_runtime.jsxs)("div", { children: ["\u7B2C", index + 1, "\u5173", ' ', /*#__PURE__*/(0,jsx_runtime.jsx)("span", { className: "ml10", children: item.challenge_name }), ' ', /*#__PURE__*/(0,jsx_runtime.jsxs)("span", { className: "ml10", children: [item.challenge_score, " \u5206"] })] }, index); }), /*#__PURE__*/(0,jsx_runtime.jsxs)("div", { className: Questions_editormodules.action, children: [/*#__PURE__*/(0,jsx_runtime.jsx)(_umi_production_exports.Link, { target: "_blank", to: "/shixuns/".concat(editData.shixun_identifier, "/challenges?exercise=true"), children: "\u5B9E\u8BAD\u8BE6\u60C5" }), !editData.hideAction && actionArr.map(function (item, index) { return /*#__PURE__*/(0,jsx_runtime.jsx)(tooltip/* default */.Z, { placement: "bottom", title: item.name, children: /*#__PURE__*/(0,jsx_runtime.jsx)("span", { onClick: function onClick() { return actionClick(item); }, className: item.icon }) }, index); })] })] }); }; return /*#__PURE__*/(0,jsx_runtime.jsxs)("section", { className: Questions_editormodules.wrap, children: [!isEdit && showList(), isEdit && showEdit()] }); }; /* harmony default export */ var Questions_ShixunEditor = ((0,_umi_production_exports.connect)(function (_ref4) { var newExercisePaper = _ref4.newExercisePaper; return { newExercisePaper: newExercisePaper }; }, null, null, { forwardRef: true })( /*#__PURE__*/(0,react.forwardRef)(ShixunEditor_ShixunEditor))); ;// CONCATENATED MODULE: ./src/pages/Paperlibrary/EditPaper/Questions/ProgrammingEditor.tsx var Questions_ProgrammingEditor_tagList = ['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']; var ProgrammingEditor_ProgrammingEditor = function ProgrammingEditor(_ref, ref) { var newExercisePaper = _ref.newExercisePaper, dispatch = _ref.dispatch, editData = _ref.editData, editKey = _ref.editKey, _ref$addCallback = _ref.addCallback, addCallback = _ref$addCallback === void 0 ? function () {} : _ref$addCallback, _ref$reload = _ref.reload, reload = _ref$reload === void 0 ? function () {} : _ref$reload; var _useState = (0,react.useState)([]), _useState2 = slicedToArray_default()(_useState, 2), questionChoiceList = _useState2[0], setQuestionChoiceList = _useState2[1]; var _useState3 = (0,react.useState)(), _useState4 = slicedToArray_default()(_useState3, 2), activeEditor = _useState4[0], setActiveEditor = _useState4[1]; var _useState5 = (0,react.useState)([]), _useState6 = slicedToArray_default()(_useState5, 2), activeAnswer = _useState6[0], setActiveAnswer = _useState6[1]; var _useState7 = (0,react.useState)(''), _useState8 = slicedToArray_default()(_useState7, 2), title = _useState8[0], setTitle = _useState8[1]; var _useState9 = (0,react.useState)(5), _useState10 = slicedToArray_default()(_useState9, 2), score = _useState10[0], setScore = _useState10[1]; var _useState11 = (0,react.useState)(false), _useState12 = slicedToArray_default()(_useState11, 2), isEdit = _useState12[0], setIsEdit = _useState12[1]; var params = (0,_umi_production_exports.useParams)(); (0,react.useEffect)(function () { setQuestionChoiceList(['', '', '', '']); }, []); (0,react.useEffect)(function () { if (!(editData !== null && editData !== void 0 && editData.question_choices)) { setIsEdit(true); setTitle(''); setScore(5); setQuestionChoiceList(['', '', '', '']); setActiveAnswer([]); return; } setTitle(editData === null || editData === void 0 ? void 0 : editData.question_title); setScore(editData === null || editData === void 0 ? void 0 : editData.question_score); setQuestionChoiceList(editData === null || editData === void 0 ? void 0 : editData.question_choices.map(function (item) { return item.choice_text; })); var answerIndexs = []; editData === null || editData === void 0 ? void 0 : editData.standard_answer.map(function (item, index) { answerIndexs.push(item - 1); }); setActiveAnswer(answerIndexs); }, [editData]); (0,react.useImperativeHandle)(ref, function () { return { onSave: onSave, isEdit: isEdit }; }); var onSave = /*#__PURE__*/function () { var _ref2 = asyncToGenerator_default()( /*#__PURE__*/regeneratorRuntime_default()().mark(function _callee() { var findNotAnswerIndex, choices, res; return regeneratorRuntime_default()().wrap(function _callee$(_context) { while (1) switch (_context.prev = _context.next) { case 0: if (title) { _context.next = 3; break; } message/* default.info */.ZP.info("请您输入题目"); return _context.abrupt("return", false); case 3: findNotAnswerIndex = questionChoiceList.findIndex(function (item) { return !item; }); if (!(findNotAnswerIndex > -1)) { _context.next = 7; break; } message/* default.info */.ZP.info("\u8BF7\u5148\u8F93\u5165 ".concat(Questions_ProgrammingEditor_tagList[findNotAnswerIndex], " \u9009\u9879\u7684\u5185\u5BB9")); return _context.abrupt("return", false); case 7: if (activeAnswer.length) { _context.next = 10; break; } message/* default.info */.ZP.info("请设置本题的正确答案,点击选项A/B...即可完成设置"); return _context.abrupt("return", false); case 10: if (!(activeAnswer.length < 1)) { _context.next = 13; break; } message/* default.info */.ZP.info("请选择答案"); return _context.abrupt("return", false); case 13: choices = questionChoiceList.map(function (item, index) { return { choice_text: item, is_answer: activeAnswer.includes(index) ? index + 1 : 0 }; }); if (!editData.question_id) { _context.next = 20; break; } _context.next = 17; return dispatch({ type: "newExercisePaper/editExerciseQuestion", payload: { "id": editData.question_id, "question_title": title, "question_type": 1, "question_score": score, "question_choices": choices.map(function (item) { return item.choice_text; }), "standard_answers": choices.filter(function (item) { return item.is_answer; }).map(function (item) { return item.is_answer; }) } }); case 17: res = _context.sent; _context.next = 23; break; case 20: _context.next = 22; return dispatch({ type: "newExercisePaper/addExerciseQuestion", payload: { insert_id: editData === null || editData === void 0 ? void 0 : editData.insert_id, "categoryId": params.categoryId, "question_title": title, "question_type": 1, "question_score": "5.0", "question_choices": choices.map(function (item) { return item.choice_text; }), "standard_answers": choices.filter(function (item) { return item.is_answer; }).map(function (item) { return item.is_answer; }) } }); case 22: res = _context.sent; case 23: if (res.status === 0) { message/* default.success */.ZP.success("保存成功"); setIsEdit(false); dispatch({ type: "newExercisePaper/editExercise", payload: objectSpread2_default()({}, params) }); } case 24: case "end": return _context.stop(); } }, _callee); })); return function onSave() { return _ref2.apply(this, arguments); }; }(); var actionArr = [{ name: "删除", icon: "iconfont c-light-black ml30 icon-shanchu current", id: "del" }, { name: "(向下插入编程题)", icon: "iconfont c-light-primary ml30 icon-tianjia current", id: "add" }, { name: "编辑", icon: "iconfont c-light-primary ml30 icon-bianjishijuan3x current", id: "edit" }]; var actionClick = /*#__PURE__*/function () { var _ref3 = asyncToGenerator_default()( /*#__PURE__*/regeneratorRuntime_default()().mark(function _callee3(item) { return regeneratorRuntime_default()().wrap(function _callee3$(_context3) { while (1) switch (_context3.prev = _context3.next) { case 0: if (!(editKey !== -1)) { _context3.next = 3; break; } message/* default.error */.ZP.error("请先保存或取消当前正在编辑的问题。"); return _context3.abrupt("return"); case 3: _context3.t0 = item.id; _context3.next = _context3.t0 === "del" ? 6 : _context3.t0 === "edit" ? 8 : _context3.t0 === "add" ? 10 : 12; break; case 6: modal/* default.confirm */.Z.confirm({ centered: true, okText: '确定', cancelText: '取消', title: '确认要删除这个试题吗?', onOk: function onOk() { return asyncToGenerator_default()( /*#__PURE__*/regeneratorRuntime_default()().mark(function _callee2() { return regeneratorRuntime_default()().wrap(function _callee2$(_context2) { while (1) switch (_context2.prev = _context2.next) { case 0: _context2.next = 2; return (0,paperlibrary/* deleteQuestion */.Km)({ exam_id: params.id, question_id: editData.question_id }); case 2: reload(); case 3: case "end": return _context2.stop(); } }, _callee2); }))(); } }); return _context3.abrupt("break", 12); case 8: _umi_production_exports.history.push("/problems/".concat(editData === null || editData === void 0 ? void 0 : editData.hack_identifier, "/edit?type=exercises&express_id=").concat(params.id, "&question_id=").concat(editData === null || editData === void 0 ? void 0 : editData.question_id, "&score=").concat(editData === null || editData === void 0 ? void 0 : editData.question_score, "&exercise=true&callback_url=").concat(location.pathname)); return _context3.abrupt("break", 12); case 10: addCallback({ key: editData.key, insert_id: editData === null || editData === void 0 ? void 0 : editData.question_id, question_type: 6 }); return _context3.abrupt("break", 12); case 12: case "end": return _context3.stop(); } }, _callee3); })); return function actionClick(_x) { return _ref3.apply(this, arguments); }; }(); var handleClick = /*#__PURE__*/function () { var _ref4 = asyncToGenerator_default()( /*#__PURE__*/regeneratorRuntime_default()().mark(function _callee4(e) { var res; return regeneratorRuntime_default()().wrap(function _callee4$(_context4) { while (1) switch (_context4.prev = _context4.next) { case 0: e.preventDefault(); _context4.next = 3; return (0,service_exercise/* startProgram */.nF)({ id: editData === null || editData === void 0 ? void 0 : editData.hack_identifier }); case 3: res = _context4.sent; res.status === 0 && (0,util/* openNewWindow */.xg)("/myproblems/".concat(res === null || res === void 0 ? void 0 : res.identifier)); case 5: case "end": return _context4.stop(); } }, _callee4); })); return function handleClick(_x2) { return _ref4.apply(this, arguments); }; }(); var showList = function showList() { return /*#__PURE__*/(0,jsx_runtime.jsxs)("aside", { children: [/*#__PURE__*/(0,jsx_runtime.jsx)("div", { className: Questions_editormodules.questionType, children: !(editData !== null && editData !== void 0 && editData.isPreview) && /*#__PURE__*/(0,jsx_runtime.jsxs)("div", { children: [/*#__PURE__*/(0,jsx_runtime.jsxs)("span", { className: "font16 c-blue", children: [editData.key, "\u3001\u7F16\u7A0B\u9898"] }), "\uFF08", editData.question_score, "\u5206\uFF09"] }) }), editData !== null && editData !== void 0 && editData.isPreview ? /*#__PURE__*/(0,jsx_runtime.jsxs)("div", { style: { display: 'flex' }, children: [/*#__PURE__*/(0,jsx_runtime.jsxs)("span", { style: { flexShrink: 0 }, className: "font18", children: [editData.key, "."] }), /*#__PURE__*/(0,jsx_runtime.jsx)(RenderHtml/* default */.Z, { value: editData.question_title }), /*#__PURE__*/(0,jsx_runtime.jsxs)("span", { style: { flexShrink: 0 }, className: "font16", children: ["\uFF08", editData.question_score, "\u5206\uFF09"] })] }) : /*#__PURE__*/(0,jsx_runtime.jsx)("div", { className: "mt5", children: /*#__PURE__*/(0,jsx_runtime.jsx)(RenderHtml/* default */.Z, { value: editData.question_title }) }), /*#__PURE__*/(0,jsx_runtime.jsx)("div", { className: Questions_editormodules.questionChoices, children: /*#__PURE__*/(0,jsx_runtime.jsx)(RenderHtml/* default */.Z, { value: editData.description || '' }) }), /*#__PURE__*/(0,jsx_runtime.jsx)("div", { className: Questions_editormodules.action, children: !editData.hideAction && actionArr.map(function (item, index) { return /*#__PURE__*/(0,jsx_runtime.jsx)(tooltip/* default */.Z, { placement: "bottom", title: item.name, children: /*#__PURE__*/(0,jsx_runtime.jsx)("span", { onClick: function onClick() { return actionClick(item); }, className: item.icon }) }, index); }) })] }); }; return /*#__PURE__*/(0,jsx_runtime.jsx)("section", { className: Questions_editormodules.wrap, children: showList() }); }; /* harmony default export */ var Questions_ProgrammingEditor = ((0,_umi_production_exports.connect)(function (_ref5) { var newExercisePaper = _ref5.newExercisePaper; return { newExercisePaper: newExercisePaper }; }, null, null, { forwardRef: true })( /*#__PURE__*/(0,react.forwardRef)(ProgrammingEditor_ProgrammingEditor))); ;// CONCATENATED MODULE: ./src/pages/Paperlibrary/EditPaper/Questions/CombinationEditor.tsx var Questions_CombinationEditor_tagList = ['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']; var CombinationEditor_CombinationEditor = function CombinationEditor(_ref, ref) { var newExercisePaper = _ref.newExercisePaper, dispatch = _ref.dispatch, editData = _ref.editData, _ref$cancelAdd = _ref.cancelAdd, cancelAdd = _ref$cancelAdd === void 0 ? function () {} : _ref$cancelAdd, editKey = _ref.editKey, _ref$setEditKey = _ref.setEditKey, setEditKey = _ref$setEditKey === void 0 ? function () {} : _ref$setEditKey, _ref$addCallback = _ref.addCallback, addCallback = _ref$addCallback === void 0 ? function (data) {} : _ref$addCallback, _ref$reload = _ref.reload, reload = _ref$reload === void 0 ? function () {} : _ref$reload; var _useState = (0,react.useState)([]), _useState2 = slicedToArray_default()(_useState, 2), knowledge = _useState2[0], setKnowledge = _useState2[1]; var _useState3 = (0,react.useState)(false), _useState4 = slicedToArray_default()(_useState3, 2), isEdit = _useState4[0], setIsEdit = _useState4[1]; var _useState5 = (0,react.useState)(true), _useState6 = slicedToArray_default()(_useState5, 2), show = _useState6[0], setShow = _useState6[1]; var _useState7 = (0,react.useState)(1), _useState8 = slicedToArray_default()(_useState7, 2), difficulty = _useState8[0], setdifficult = _useState8[1]; var _useState9 = (0,react.useState)(false), _useState10 = slicedToArray_default()(_useState9, 2), repeat_answer = _useState10[0], setrepeat_answer = _useState10[1]; var _useState11 = (0,react.useState)([]), _useState12 = slicedToArray_default()(_useState11, 2), knowledgeOptions = _useState12[0], setKnowledgeOptions = _useState12[1]; var params = (0,_umi_production_exports.useParams)(); var dom = (0,react.useRef)(null); var _useState13 = (0,react.useState)(''), _useState14 = slicedToArray_default()(_useState13, 2), name = _useState14[0], setName = _useState14[1]; var _useState15 = (0,react.useState)([]), _useState16 = slicedToArray_default()(_useState15, 2), questionList = _useState16[0], setQuestionList = _useState16[1]; var freeze = (0,react.useRef)(false); var handleAddKnowledgeFinish = function handleAddKnowledgeFinish(item) { setKnowledgeOptions([].concat(toConsumableArray_default()(knowledgeOptions), [objectSpread2_default()({}, item)])); }; (0,react.useEffect)(function () { var _editData$sub_exercis; if (freeze.current) return; if (!(editData !== null && editData !== void 0 && editData.question_title)) { setIsEdit(true); setName(''); return; } setName(editData === null || editData === void 0 ? void 0 : editData.question_title); setrepeat_answer(!(editData !== null && editData !== void 0 && editData.repeat_answer)); setdifficult(editData === null || editData === void 0 ? void 0 : editData.difficulty); setKnowledge(editData.tag_discipline_ids); var list = editData === null || editData === void 0 ? void 0 : (_editData$sub_exercis = editData.sub_exercise_questions) === null || _editData$sub_exercis === void 0 ? void 0 : _editData$sub_exercis.map(function (k) { return objectSpread2_default()(objectSpread2_default()({}, k), {}, { id: k.question_id, name: k.question_title, open: false, question_score: k.question_score, choices: k === null || k === void 0 ? void 0 : k.question_choices.map(function (item) { return { choice_text: item.choice_text, is_answer: item.standard_boolean ? 1 : 0 }; }), activeQusEditor: null }); }); setQuestionList(list); }, [editData, isEdit]); (0,react.useEffect)(function () { if (isEdit) { init(); } function init() { return _init.apply(this, arguments); } function _init() { _init = asyncToGenerator_default()( /*#__PURE__*/regeneratorRuntime_default()().mark(function _callee() { var _newExercisePaper$edi, _newExercisePaper$edi2; var res; return regeneratorRuntime_default()().wrap(function _callee$(_context) { while (1) switch (_context.prev = _context.next) { case 0: _context.next = 2; return (0,service_exercise/* getTagDiscipline */.YY)({ sub_discipline_id: (_newExercisePaper$edi = newExercisePaper.editData) === null || _newExercisePaper$edi === void 0 ? void 0 : (_newExercisePaper$edi2 = _newExercisePaper$edi.exercise) === null || _newExercisePaper$edi2 === void 0 ? void 0 : _newExercisePaper$edi2.sub_discipline_id }); case 2: res = _context.sent; setKnowledgeOptions(res.tag_disciplines); case 4: case "end": return _context.stop(); } }, _callee); })); return _init.apply(this, arguments); } }, [isEdit]); (0,react.useEffect)(function () { var _newExercisePaper$tag; var data = newExercisePaper !== null && newExercisePaper !== void 0 && (_newExercisePaper$tag = newExercisePaper.tagDisciplineData) !== null && _newExercisePaper$tag !== void 0 && _newExercisePaper$tag.tag_disciplines && Array.isArray(newExercisePaper.tagDisciplineData.tag_disciplines) ? newExercisePaper.tagDisciplineData.tag_disciplines : []; setKnowledgeOptions(data); }, [newExercisePaper.tagDisciplineData]); (0,react.useImperativeHandle)(ref, function () { return { onSave: onSave, isEdit: isEdit }; }); var repeal = function repeal(res) { if ((res === null || res === void 0 ? void 0 : res.status) === 0) { message/* default.success */.ZP.success("保存成功"); setIsEdit(false); setEditKey(-1); freeze.current = false; reload(); } }; var onSave = /*#__PURE__*/function () { var _ref2 = asyncToGenerator_default()( /*#__PURE__*/regeneratorRuntime_default()().mark(function _callee2() { var i, _param$choices, param, findNotAnswerIndex, sub_item_banks, res, _newExercisePaper$edi3, _newExercisePaper$edi4, _newExercisePaper$edi5, _newExercisePaper$edi6; return regeneratorRuntime_default()().wrap(function _callee2$(_context2) { while (1) switch (_context2.prev = _context2.next) { case 0: if (name) { _context2.next = 3; break; } message/* default.info */.ZP.info('请您输入题干'); return _context2.abrupt("return", false); case 3: if (!(questionList.length === 0)) { _context2.next = 6; break; } message/* default.info */.ZP.info('请您添加小题'); return _context2.abrupt("return", false); case 6: i = 0; case 7: if (!(i < questionList.length)) { _context2.next = 25; break; } param = questionList[i]; if (param !== null && param !== void 0 && param.name) { _context2.next = 12; break; } message/* default.info */.ZP.info("\u8BF7\u60A8\u8F93\u5165\u7B2C".concat(i + 1, "\u5C0F\u9898\u9898\u5E72")); return _context2.abrupt("return", false); case 12: if (param !== null && param !== void 0 && param.question_score) { _context2.next = 15; break; } message/* default.info */.ZP.info("\u7B2C".concat(i + 1, "\u5C0F\u9898\u5206\u6570\u4E0D\u80FD\u4E3A0\u6216\u7A7A")); return _context2.abrupt("return", false); case 15: findNotAnswerIndex = param === null || param === void 0 ? void 0 : (_param$choices = param.choices) === null || _param$choices === void 0 ? void 0 : _param$choices.findIndex(function (item) { return !item; }); if (!(findNotAnswerIndex > -1)) { _context2.next = 19; break; } message/* default.info */.ZP.info("\u8BF7\u5148\u8F93\u5165\u7B2C".concat(i + 1, "\u5C0F\u9898").concat(Questions_CombinationEditor_tagList[findNotAnswerIndex], "\u9009\u9879\u7684\u5185\u5BB9")); return _context2.abrupt("return", false); case 19: if (!(param.choices.findIndex(function (item) { return item.is_answer === 1; }) === -1)) { _context2.next = 22; break; } message/* default.info */.ZP.info("\u8BF7\u8BBE\u7F6E\u7B2C".concat(i + 1, "\u5C0F\u9898\u7684\u6B63\u786E\u7B54\u6848\uFF0C\u70B9\u51FB\u9009\u9879A/B...\u5373\u53EF\u5B8C\u6210\u8BBE\u7F6E")); return _context2.abrupt("return", false); case 22: i++; _context2.next = 7; break; case 25: sub_item_banks = questionList.map(function (e) { return { id: e.id > 1 ? e.id : null, name: e.name, item_type: utils_enum/* QuestionType.Single */.c.Single, choices: e.choices, question_score: e.question_score }; }); freeze.current = true; if (!editData.question_id) { _context2.next = 34; break; } _context2.next = 30; return dispatch({ type: 'newExercisePaper/editExerciseQuestion', payload: { id: params.id, question_id: editData.question_id, name: name, item_type: utils_enum/* QuestionType.Combine */.c.Combine, sub_item_banks: sub_item_banks, tag_discipline_ids: knowledge, sub_discipline_id: (_newExercisePaper$edi3 = newExercisePaper.editData) === null || _newExercisePaper$edi3 === void 0 ? void 0 : (_newExercisePaper$edi4 = _newExercisePaper$edi3.exercise) === null || _newExercisePaper$edi4 === void 0 ? void 0 : _newExercisePaper$edi4.sub_discipline_id, difficulty: difficulty, repeat_answer: !repeat_answer } }); case 30: res = _context2.sent; repeal(res); _context2.next = 38; break; case 34: _context2.next = 36; return dispatch({ type: "newExercisePaper/addExerciseQuestion", payload: { id: params.id, insert_id: editData === null || editData === void 0 ? void 0 : editData.insert_id, "name": name, "item_type": utils_enum/* QuestionType.Combine */.c.Combine, "tag_discipline_ids": knowledge, "sub_discipline_id": (_newExercisePaper$edi5 = newExercisePaper.editData) === null || _newExercisePaper$edi5 === void 0 ? void 0 : (_newExercisePaper$edi6 = _newExercisePaper$edi5.exercise) === null || _newExercisePaper$edi6 === void 0 ? void 0 : _newExercisePaper$edi6.sub_discipline_id, "difficulty": difficulty, "repeat_answer": !repeat_answer, sub_item_banks: sub_item_banks } }); case 36: res = _context2.sent; repeal(res); case 38: case "end": return _context2.stop(); } }, _callee2); })); return function onSave() { return _ref2.apply(this, arguments); }; }(); var actionArr = [{ name: '删除', icon: 'iconfont c-light-black ml30 icon-shanchu current', id: 'del' }, { name: '编辑', icon: 'iconfont c-light-primary ml30 icon-bianjishijuan3x current', id: 'edit' }]; var actionClick = /*#__PURE__*/function () { var _ref3 = asyncToGenerator_default()( /*#__PURE__*/regeneratorRuntime_default()().mark(function _callee4(item) { return regeneratorRuntime_default()().wrap(function _callee4$(_context4) { while (1) switch (_context4.prev = _context4.next) { case 0: if (!(editKey !== -1)) { _context4.next = 3; break; } message/* default.error */.ZP.error('请先保存或取消当前正在编辑的问题。'); return _context4.abrupt("return"); case 3: _context4.t0 = item.id; _context4.next = _context4.t0 === 'del' ? 6 : _context4.t0 === 'edit' ? 8 : _context4.t0 === 'add' ? 11 : 13; break; case 6: modal/* default.confirm */.Z.confirm({ centered: true, okText: '确定', cancelText: '取消', title: '确认要删除这个试题吗?', onOk: function onOk() { return asyncToGenerator_default()( /*#__PURE__*/regeneratorRuntime_default()().mark(function _callee3() { return regeneratorRuntime_default()().wrap(function _callee3$(_context3) { while (1) switch (_context3.prev = _context3.next) { case 0: _context3.next = 2; return (0,paperlibrary/* deleteQuestion */.Km)({ question_id: editData.question_id, exam_id: params.id }); case 2: reload(); case 3: case "end": return _context3.stop(); } }, _callee3); }))(); } }); return _context4.abrupt("break", 13); case 8: setEditKey(editData.dragKey); setIsEdit(true); return _context4.abrupt("break", 13); case 11: addCallback({ key: editData.key, insert_id: editData === null || editData === void 0 ? void 0 : editData.question_id, item_type: utils_enum/* QuestionType.Single */.c.Single }); return _context4.abrupt("break", 13); case 13: case "end": return _context4.stop(); } }, _callee4); })); return function actionClick(_x) { return _ref3.apply(this, arguments); }; }(); var showList = function showList() { var _editData$sub_exercis2; return /*#__PURE__*/(0,jsx_runtime.jsxs)("aside", { ref: dom, children: [/*#__PURE__*/(0,jsx_runtime.jsx)("div", { className: Questions_editormodules.questionType, children: !(editData !== null && editData !== void 0 && editData.isPreview) && /*#__PURE__*/(0,jsx_runtime.jsxs)("div", { children: [/*#__PURE__*/(0,jsx_runtime.jsxs)("span", { className: "font16 c-blue", children: [editData.key, "\u3001\u7EC4\u5408\u9898"] }), "\uFF08", editData.question_score, "\u5206\uFF09"] }) }), editData !== null && editData !== void 0 && editData.isPreview ? /*#__PURE__*/(0,jsx_runtime.jsxs)("div", { style: { display: 'flex', alignItems: 'flex-start' }, children: [/*#__PURE__*/(0,jsx_runtime.jsxs)("span", { style: { flexShrink: 0 }, className: "font18", children: [editData.key, "."] }), /*#__PURE__*/(0,jsx_runtime.jsx)(RenderHtml/* default */.Z, { value: editData.question_title }), /*#__PURE__*/(0,jsx_runtime.jsxs)("span", { style: { flexShrink: 0 }, className: "font16", children: ["\uFF08\u5171", editData === null || editData === void 0 ? void 0 : editData.sub_q_count, "\u5C0F\u9898\uFF0C", editData.question_score, "\u5206\uFF09"] })] }) : /*#__PURE__*/(0,jsx_runtime.jsx)("div", { className: "mt5", children: /*#__PURE__*/(0,jsx_runtime.jsx)(RenderHtml/* default */.Z, { value: editData.question_title }) }), /*#__PURE__*/(0,jsx_runtime.jsx)("div", { style: { display: show ? 'block' : 'none' }, className: Questions_editormodules.questionChoices, children: editData === null || editData === void 0 ? void 0 : (_editData$sub_exercis2 = editData.sub_exercise_questions) === null || _editData$sub_exercis2 === void 0 ? void 0 : _editData$sub_exercis2.map(function (e, i) { var _e$question_choices; return /*#__PURE__*/(0,jsx_runtime.jsxs)("div", { children: [/*#__PURE__*/(0,jsx_runtime.jsxs)("div", { style: { display: 'flex', alignItems: 'flex-start' }, children: [/*#__PURE__*/(0,jsx_runtime.jsxs)("span", { style: { flexShrink: 0 }, className: "font18", children: [editData.key, ".", i + 1, '(单选题)'] }), /*#__PURE__*/(0,jsx_runtime.jsx)(RenderHtml/* default */.Z, { value: e.question_title }), /*#__PURE__*/(0,jsx_runtime.jsxs)("span", { style: { flexShrink: 0 }, className: "font16", children: ["\uFF08", e.question_score, "\u5206\uFF09"] })] }), e === null || e === void 0 ? void 0 : (_e$question_choices = e.question_choices) === null || _e$question_choices === void 0 ? void 0 : _e$question_choices.map(function (item, index) { return /*#__PURE__*/(0,jsx_runtime.jsxs)(row/* default */.Z, { children: [/*#__PURE__*/(0,jsx_runtime.jsx)(col/* default */.Z, { children: /*#__PURE__*/(0,jsx_runtime.jsxs)(es_radio/* default */.ZP, { checked: item.standard_boolean, disabled: true, children: [Questions_CombinationEditor_tagList[index], "."] }, index) }), /*#__PURE__*/(0,jsx_runtime.jsx)(col/* default */.Z, { flex: "1", children: /*#__PURE__*/(0,jsx_runtime.jsx)("span", { className: "c-black font14", children: /*#__PURE__*/(0,jsx_runtime.jsx)(RenderHtml/* default */.Z, { value: item.choice_text }) }) })] }, index); })] }, i); }) }), /*#__PURE__*/(0,jsx_runtime.jsxs)("div", { className: Questions_editormodules.action, children: [/*#__PURE__*/(0,jsx_runtime.jsx)("span", { className: "c-light-primary current", onClick: function onClick() { return setShow(!show); }, style: {}, children: show ? '收起' : '展开' }), !editData.hideAction && actionArr.map(function (item, index) { return /*#__PURE__*/(0,jsx_runtime.jsx)(tooltip/* default */.Z, { placement: "bottom", title: item.name, children: /*#__PURE__*/(0,jsx_runtime.jsx)("span", { onClick: function onClick() { return actionClick(item); }, className: item.icon }) }, index); })] })] }); }; var showEdit = function showEdit() { var _newExercisePaper$edi7, _newExercisePaper$edi8; return /*#__PURE__*/(0,jsx_runtime.jsxs)("aside", { children: [/*#__PURE__*/(0,jsx_runtime.jsx)("div", { className: Questions_editormodules.questionType, children: /*#__PURE__*/(0,jsx_runtime.jsxs)("div", { children: [/*#__PURE__*/(0,jsx_runtime.jsx)("span", { className: "font16 c-blue", children: "\u9009\u62E9\u9898" }), "\uFF08\u5BA2\u89C2\u9898\uFF0C\u7531\u7CFB\u7EDF\u81EA\u52A8\u8BC4\u5206\uFF0C\u8BF7\u8BBE\u7F6E\u6807\u51C6\u7B54\u6848\uFF09"] }) }), /*#__PURE__*/(0,jsx_runtime.jsxs)("section", { className: Questions_editormodules.wrap, style: { padding: 0 }, children: [/*#__PURE__*/(0,jsx_runtime.jsxs)("p", { className: Questions_editormodules.titleWrap, children: [/*#__PURE__*/(0,jsx_runtime.jsx)("span", { className: Questions_editormodules.required, children: "*" }), /*#__PURE__*/(0,jsx_runtime.jsx)("span", { className: Questions_editormodules.title, children: "\u9898\u5E72\uFF1A" })] }), /*#__PURE__*/(0,jsx_runtime.jsx)(markdown_editor/* default */.Z, { id: "combination-question-title", watch: true, height: 155, placeholder: "\u8BF7\u60A8\u8F93\u5165\u9898\u5E72", defaultValue: name, onChange: function onChange(value) { return setName(value); } }), /*#__PURE__*/(0,jsx_runtime.jsxs)("p", { children: ["\u5C0F\u9898\u6570\uFF1A", questionList === null || questionList === void 0 ? void 0 : questionList.length] }), questionList === null || questionList === void 0 ? void 0 : questionList.map(function (e, j) { var _e$choices; return /*#__PURE__*/(0,jsx_runtime.jsxs)("div", { className: Questions_editormodules.fold, children: [/*#__PURE__*/(0,jsx_runtime.jsxs)("div", { onClick: function onClick() { return handleQuestionList('open', j); }, className: Questions_editormodules.head, children: [/*#__PURE__*/(0,jsx_runtime.jsx)("i", { className: "iconfont icon-sanjiaoxing", style: { transform: e.open ? 'initial' : 'rotate(270deg) translate(2px, 4px)' } }), /*#__PURE__*/(0,jsx_runtime.jsxs)("span", { children: ["\u7B2C", j + 1, "\u5C0F\u9898\uFF08\u5355\u9009\u9898\uFF09"] }), /*#__PURE__*/(0,jsx_runtime.jsx)("b", { onClick: function onClick(e) { e.stopPropagation(); handleQuestionList('delete', j); }, className: "iconfont icon-shanchu8" })] }), /*#__PURE__*/(0,jsx_runtime.jsxs)("div", { className: "mb10", style: { display: e.open ? 'block' : 'none' }, children: [/*#__PURE__*/(0,jsx_runtime.jsx)(markdown_editor/* default */.Z, { watch: true, height: 155, placeholder: "\u8BF7\u60A8\u8F93\u5165\u9898\u5E72", defaultValue: e === null || e === void 0 ? void 0 : e.name, onChange: function onChange(value) { return handleQuestionList('value', j, value); } }), /*#__PURE__*/(0,jsx_runtime.jsxs)("p", { className: Questions_editormodules.titleWrap, children: [/*#__PURE__*/(0,jsx_runtime.jsx)("span", { className: Questions_editormodules.required, children: "*" }), /*#__PURE__*/(0,jsx_runtime.jsxs)("span", { className: Questions_editormodules.title, children: ["\u7B54\u6848\u9009\u9879\uFF1A", /*#__PURE__*/(0,jsx_runtime.jsx)("span", { className: Questions_editormodules.colorGray, children: "\u70B9\u51FB\u9009\u9879\u53EF\u8BBE\u7F6E\u6B63\u786E\u7B54\u6848" })] })] }), e === null || e === void 0 ? void 0 : (_e$choices = e.choices) === null || _e$choices === void 0 ? void 0 : _e$choices.map(function (item, index) { var _e$choices2; return /*#__PURE__*/(0,jsx_runtime.jsxs)("div", { className: Questions_editormodules.choiceWrap, children: [/*#__PURE__*/(0,jsx_runtime.jsx)(tooltip/* default */.Z, { title: "\u70B9\u51FB\u8BBE\u7F6E\u4E3A\u6807\u51C6\u7B54\u6848", placement: "left", children: /*#__PURE__*/(0,jsx_runtime.jsx)("div", { className: "".concat(Questions_editormodules.answer, " ").concat(item.is_answer === 1 ? Questions_editormodules.activeAnswer : ''), onClick: function onClick() { return handleQuestionList('answer', j, index); }, children: Questions_CombinationEditor_tagList[index] }) }), /*#__PURE__*/(0,jsx_runtime.jsx)("div", { className: Questions_editormodules.editorWrap, children: (e === null || e === void 0 ? void 0 : e.activeQusEditor) === index ? /*#__PURE__*/(0,jsx_runtime.jsx)(markdown_editor/* default */.Z, { id: "single-question-option-".concat(index), watch: true, height: 155, isFocus: true, placeholder: "\u8BF7\u60A8\u8F93\u5165\u9009\u9879", defaultValue: item.choice_text, onChange: function onChange(value) { return handleQuestionList('details', j, value); } }) : /*#__PURE__*/(0,jsx_runtime.jsx)("div", { className: Questions_editormodules.htmlWrap, onClick: function onClick() { return handleQuestionList('edit', j, index); }, children: /*#__PURE__*/(0,jsx_runtime.jsx)(RenderHtml/* default */.Z, { value: item.choice_text }) }) }), index > 1 && /*#__PURE__*/(0,jsx_runtime.jsx)(tooltip/* default */.Z, { title: "\u5220\u9664", children: /*#__PURE__*/(0,jsx_runtime.jsx)("i", { className: "".concat(Questions_editormodules.deleteIcon, " iconfont icon-htmal5icon19"), onClick: function onClick() { return handleQuestionList('deleteQus', j, index); } }) }), index < 7 && index === (e === null || e === void 0 ? void 0 : (_e$choices2 = e.choices) === null || _e$choices2 === void 0 ? void 0 : _e$choices2.length) - 1 && /*#__PURE__*/(0,jsx_runtime.jsx)(tooltip/* default */.Z, { title: "\u65B0\u589E\u53C2\u8003\u7B54\u6848", children: /*#__PURE__*/(0,jsx_runtime.jsx)("i", { className: "".concat(Questions_editormodules.addIcon, " iconfont icon-roundaddfill ml6"), onClick: function onClick() { return handleQuestionList('addQus', j); } }) })] }, index); }), /*#__PURE__*/(0,jsx_runtime.jsxs)("p", { className: "mt10", children: ["\u5206\u503C\uFF1A", /*#__PURE__*/(0,jsx_runtime.jsx)(input_number/* default */.Z, { value: e.question_score, max: 10000, min: 0, onChange: function onChange(value) { return handleQuestionList('score', j, value); } }), "\u5206"] })] })] }, e.id); }), questionList.length < 20 && /*#__PURE__*/(0,jsx_runtime.jsxs)(es_button/* default */.Z, { type: "primary", onClick: handleAdd, children: [/*#__PURE__*/(0,jsx_runtime.jsx)("i", { className: "iconfont icon-tianjiatimu mr5 font14" }), "\u6DFB\u52A0\u5C0F\u9898"] })] }), /*#__PURE__*/(0,jsx_runtime.jsx)("p", { className: "mt10", children: /*#__PURE__*/(0,jsx_runtime.jsxs)("span", { className: Questions_editormodules.difficult, children: [/*#__PURE__*/(0,jsx_runtime.jsx)("label", { style: { color: 'red' }, children: "*" }), " \u96BE\u5EA6\uFF1A", /*#__PURE__*/(0,jsx_runtime.jsxs)(es_radio/* default.Group */.ZP.Group, { value: difficulty, onChange: function onChange(e) { setdifficult(e.target.value); }, children: [/*#__PURE__*/(0,jsx_runtime.jsx)(es_radio/* default.Button */.ZP.Button, { value: 1, children: "\u7B80\u5355" }), /*#__PURE__*/(0,jsx_runtime.jsx)(es_radio/* default.Button */.ZP.Button, { value: 2, children: "\u9002\u4E2D" }), /*#__PURE__*/(0,jsx_runtime.jsx)(es_radio/* default.Button */.ZP.Button, { value: 3, children: "\u56F0\u96BE" })] })] }) }), /*#__PURE__*/(0,jsx_runtime.jsxs)("p", { className: Questions_editormodules.titleWrap, children: [/*#__PURE__*/(0,jsx_runtime.jsxs)("span", { className: "".concat(Questions_editormodules.title), children: ["\u77E5\u8BC6\u70B9\uFF1A", /*#__PURE__*/(0,jsx_runtime.jsx)("span", { className: Questions_editormodules.colorGray, children: "\uFF08\u6240\u6709\u81EA\u5EFA\u77E5\u8BC6\u70B9\u4EC5\u672C\u4EBA\u53EF\u89C1\uFF0C\u88ABEduCoder\u5E73\u53F0\u5BA1\u6838\u901A\u8FC7\u4E3A\u5B98\u65B9\u77E5\u8BC6\u70B9\u540E\u6240\u6709\u7528\u6237\u53EF\u89C1\uFF09" })] }), /*#__PURE__*/(0,jsx_runtime.jsx)("div", { className: "mt5", children: /*#__PURE__*/(0,jsx_runtime.jsx)(Knowledge/* Knowledge */.N, { selectvalues: editData === null || editData === void 0 ? void 0 : editData.tag_discipline_ids, value: knowledge, onChange: setKnowledge, subId: (_newExercisePaper$edi7 = newExercisePaper.editData) === null || _newExercisePaper$edi7 === void 0 ? void 0 : (_newExercisePaper$edi8 = _newExercisePaper$edi7.exercise) === null || _newExercisePaper$edi8 === void 0 ? void 0 : _newExercisePaper$edi8.sub_discipline_id, knowledgeOptions: knowledgeOptions, onAddKnowledgeFinish: handleAddKnowledgeFinish }) })] }), /*#__PURE__*/(0,jsx_runtime.jsxs)("aside", { className: "tr", children: [(editKey !== -1 || editData.question_id) && /*#__PURE__*/(0,jsx_runtime.jsx)(es_button/* default */.Z, { type: "default", onClick: function onClick() { cancelAdd(); setIsEdit(false); }, children: "\u53D6\u6D88" }), /*#__PURE__*/(0,jsx_runtime.jsx)(es_button/* default */.Z, { className: "ml20", type: "primary", onClick: function onClick() { onSave(); }, children: "\u4FDD\u5B58" })] })] }); }; var handleAdd = function handleAdd() { var param = { id: Math.random(), item_type: 'SINGLE', open: false, name: '', choices: Array.from({ length: 4 }, function () { return { choice_text: '', is_answer: 0 }; }), activeQusEditor: null, analysis: '' }; setQuestionList(questionList.concat(param)); }; var handleQuestionList = function handleQuestionList(type, i, value) { var cloneQuestionList = (0,lodash.cloneDeep)(questionList); if (type === 'open') { cloneQuestionList[i].open = !cloneQuestionList[i].open; } if (type === 'delete') { cloneQuestionList.splice(i, 1); } if (type === 'value') { cloneQuestionList[i].name = value; } if (type === 'answer') { cloneQuestionList[i].choices.forEach(function (item, index) { item.is_answer = value === index ? 1 : 0; }); } if (type === 'edit') { cloneQuestionList[i].activeQusEditor = value; } if (type === 'details') { cloneQuestionList[i].choices[cloneQuestionList[i].activeQusEditor].choice_text = value; } if (type === 'addQus') { cloneQuestionList[i].choices = cloneQuestionList[i].choices.concat({ choice_text: '', is_answer: 0 }); } if (type === 'deleteQus') { cloneQuestionList[i].choices = cloneQuestionList[i].choices.filter(function (_, c) { return c !== value; }); } if (type === 'analysis') { cloneQuestionList[i].analysis = value; } if (type === 'score') { cloneQuestionList[i].question_score = value; } setQuestionList(cloneQuestionList); }; return /*#__PURE__*/(0,jsx_runtime.jsxs)("section", { className: Questions_editormodules.wrap, children: [!isEdit && showList(), isEdit && showEdit()] }); }; /* harmony default export */ var Questions_CombinationEditor = ((0,_umi_production_exports.connect)(function (_ref4) { var newExercisePaper = _ref4.newExercisePaper; return { newExercisePaper: newExercisePaper }; }, null, null, { forwardRef: true })( /*#__PURE__*/(0,react.forwardRef)(CombinationEditor_CombinationEditor))); ;// CONCATENATED MODULE: ./src/components/DragSubject/index.tsx var DragSubject = function DragSubject(_ref) { var data = _ref.data, _ref$isDragDisabled = _ref.isDragDisabled, isDragDisabled = _ref$isDragDisabled === void 0 ? false : _ref$isDragDisabled, _ref$editorProps = _ref.editorProps, editorProps = _ref$editorProps === void 0 ? {} : _ref$editorProps, _ref$onDragEnd = _ref.onDragEnd, onDragEnd = _ref$onDragEnd === void 0 ? function () {} : _ref$onDragEnd, dispatch = _ref.dispatch, _ref$markBtnVisible = _ref.markBtnVisible, markBtnVisible = _ref$markBtnVisible === void 0 ? false : _ref$markBtnVisible, _ref$batchScore = _ref.batchScore, batchScore = _ref$batchScore === void 0 ? [] : _ref$batchScore, _ref$reload = _ref.reload, reload = _ref$reload === void 0 ? function () {} : _ref$reload, _ref$inNewPaperLibrar = _ref.inNewPaperLibrary, inNewPaperLibrary = _ref$inNewPaperLibrar === void 0 ? false : _ref$inNewPaperLibrar; var score = (0,react.useRef)(); var params = (0,_umi_production_exports.useParams)(); var classifyType = function classifyType() { var _data$exercise_types, _data$exercise_types2, _data$exercise_types3, _data$exercise_types4, _data$exercise_types5, _data$exercise_types6, _data$exercise_types7, _data$exercise_types8, _data$exercise_types9, _data$exercise_types10, _data$exercise_types11, _data$exercise_types12, _data$exercise_types13, _data$exercise_types14, _data$exercise_types15, _data$exercise_types16; var array = [{ name: '单选题', type: 0, count: data === null || data === void 0 ? void 0 : (_data$exercise_types = data.exercise_types) === null || _data$exercise_types === void 0 ? void 0 : _data$exercise_types['q_singles'], score: data === null || data === void 0 ? void 0 : (_data$exercise_types2 = data.exercise_types) === null || _data$exercise_types2 === void 0 ? void 0 : _data$exercise_types2['q_singles_scores'], items: [] }, { name: '多选题', type: 1, count: data === null || data === void 0 ? void 0 : (_data$exercise_types3 = data.exercise_types) === null || _data$exercise_types3 === void 0 ? void 0 : _data$exercise_types3['q_doubles'], score: data === null || data === void 0 ? void 0 : (_data$exercise_types4 = data.exercise_types) === null || _data$exercise_types4 === void 0 ? void 0 : _data$exercise_types4['q_doubles_scores'], items: [] }, { name: '判断题', type: 2, count: data === null || data === void 0 ? void 0 : (_data$exercise_types5 = data.exercise_types) === null || _data$exercise_types5 === void 0 ? void 0 : _data$exercise_types5['q_judges'], score: data === null || data === void 0 ? void 0 : (_data$exercise_types6 = data.exercise_types) === null || _data$exercise_types6 === void 0 ? void 0 : _data$exercise_types6['q_judges_scores'], items: [] }, { name: '填空题', type: 3, count: data === null || data === void 0 ? void 0 : (_data$exercise_types7 = data.exercise_types) === null || _data$exercise_types7 === void 0 ? void 0 : _data$exercise_types7['q_nulls'], score: data === null || data === void 0 ? void 0 : (_data$exercise_types8 = data.exercise_types) === null || _data$exercise_types8 === void 0 ? void 0 : _data$exercise_types8['q_nulls_scores'], items: [] }, { name: '简答题', type: 4, count: data === null || data === void 0 ? void 0 : (_data$exercise_types9 = data.exercise_types) === null || _data$exercise_types9 === void 0 ? void 0 : _data$exercise_types9['q_mains'], score: data === null || data === void 0 ? void 0 : (_data$exercise_types10 = data.exercise_types) === null || _data$exercise_types10 === void 0 ? void 0 : _data$exercise_types10['q_mains_scores'], items: [] }, { name: '实训题', type: 5, count: data === null || data === void 0 ? void 0 : (_data$exercise_types11 = data.exercise_types) === null || _data$exercise_types11 === void 0 ? void 0 : _data$exercise_types11['q_shixuns'], score: data === null || data === void 0 ? void 0 : (_data$exercise_types12 = data.exercise_types) === null || _data$exercise_types12 === void 0 ? void 0 : _data$exercise_types12['q_shixuns_scores'], items: [] }, { name: '编程题', type: 6, count: data === null || data === void 0 ? void 0 : (_data$exercise_types13 = data.exercise_types) === null || _data$exercise_types13 === void 0 ? void 0 : _data$exercise_types13['q_pros'], score: data === null || data === void 0 ? void 0 : (_data$exercise_types14 = data.exercise_types) === null || _data$exercise_types14 === void 0 ? void 0 : _data$exercise_types14['q_pros_scores'], items: [] }, { name: '组合题', type: 7, count: data === null || data === void 0 ? void 0 : (_data$exercise_types15 = data.exercise_types) === null || _data$exercise_types15 === void 0 ? void 0 : _data$exercise_types15['q_combinations'], score: data === null || data === void 0 ? void 0 : (_data$exercise_types16 = data.exercise_types) === null || _data$exercise_types16 === void 0 ? void 0 : _data$exercise_types16['q_combination_scores'], items: [] }]; return array; }; //过滤函数 var reorder = function reorder(list, startIndex, endIndex) { var result = Array.from(list); var _result$splice = result.splice(startIndex, 1), _result$splice2 = slicedToArray_default()(_result$splice, 1), removed = _result$splice2[0]; result.splice(endIndex, 0, removed); return result; }; var handleDragEnd = function handleDragEnd(result, list, type) { if (!result.destination) { return; } var items = reorder(list, result.source.index, result.destination.index); if (inNewPaperLibrary) { onDragEnd(result, items, type); } else { onDragEnd(items, type); } }; //打开标记错题弹窗 var handleMarkWrongQuestion = function handleMarkWrongQuestion(params) { dispatch({ type: 'exercise/setActionTabs', payload: { key: '标记错题', params: params } }); }; var renderSubject = function renderSubject(v, type) { if (type === 0) { return inNewPaperLibrary ? /*#__PURE__*/(0,jsx_runtime.jsx)(Questions_SingleEditor, objectSpread2_default()({ reload: reload, editData: v }, v)) : /*#__PURE__*/(0,jsx_runtime.jsx)(components_SingleEditor, objectSpread2_default()({ reload: reload, editData: v }, v)); } if (type === 1) { return inNewPaperLibrary ? /*#__PURE__*/(0,jsx_runtime.jsx)(Questions_MultipleEditor, objectSpread2_default()({ reload: reload, editData: v }, v)) : /*#__PURE__*/(0,jsx_runtime.jsx)(components_MultipleEditor, objectSpread2_default()({ reload: reload, editData: v }, v)); } if (type === 2) { return inNewPaperLibrary ? /*#__PURE__*/(0,jsx_runtime.jsx)(Questions_JudgmentEditor, objectSpread2_default()({ reload: reload, editData: v }, v)) : /*#__PURE__*/(0,jsx_runtime.jsx)(components_JudgmentEditor, objectSpread2_default()({ reload: reload, editData: v }, v)); } if (type === 3) { return inNewPaperLibrary ? /*#__PURE__*/(0,jsx_runtime.jsx)(Questions_CompletionEditor, objectSpread2_default()({ reload: reload, editData: v }, v)) : /*#__PURE__*/(0,jsx_runtime.jsx)(components_CompletionEditor, objectSpread2_default()({ reload: reload, editData: v }, v)); } if (type === 4) { return inNewPaperLibrary ? /*#__PURE__*/(0,jsx_runtime.jsx)(Questions_SubjectiveEditor, objectSpread2_default()({ reload: reload, editData: v }, v)) : /*#__PURE__*/(0,jsx_runtime.jsx)(components_SubjectiveEditor, objectSpread2_default()({ reload: reload, editData: v }, v)); } if (type === 5) { return inNewPaperLibrary ? /*#__PURE__*/(0,jsx_runtime.jsx)(Questions_ShixunEditor, objectSpread2_default()({ reload: reload, editData: v }, v)) : /*#__PURE__*/(0,jsx_runtime.jsx)(components_ShixunEditor, objectSpread2_default()({ reload: reload, editData: v }, v)); } if (type === 6) { return inNewPaperLibrary ? /*#__PURE__*/(0,jsx_runtime.jsx)(Questions_ProgrammingEditor, objectSpread2_default()({ reload: reload, editData: v }, v)) : /*#__PURE__*/(0,jsx_runtime.jsx)(ProgrammingEditor, objectSpread2_default()({ editData: v }, v)); } if (type === 7) { return inNewPaperLibrary ? /*#__PURE__*/(0,jsx_runtime.jsx)(Questions_CombinationEditor, objectSpread2_default()({ reload: reload, editData: v }, v)) : /*#__PURE__*/(0,jsx_runtime.jsx)(components_CombinationEditor, objectSpread2_default()({ reload: reload, editData: v }, v)); } }; var renderMapDom = function renderMapDom(list, type, name) { return /*#__PURE__*/(0,jsx_runtime.jsx)(react_beautiful_dnd_esm/* DragDropContext */.Z5, { onDragEnd: function onDragEnd(result) { return handleDragEnd(result, list, type); }, children: /*#__PURE__*/(0,jsx_runtime.jsx)(react_beautiful_dnd_esm/* Droppable */.bK, { droppableId: "droppable", children: function children(provided, snapshot) { return /*#__PURE__*/(0,jsx_runtime.jsxs)("div", objectSpread2_default()(objectSpread2_default()({ ref: provided.innerRef }, provided.droppableProps), {}, { style: { width: '100%' }, children: [list === null || list === void 0 ? void 0 : list.map(function (item, k) { var _v$question_id; var v = objectSpread2_default()(objectSpread2_default()({}, item), {}, { key: k + 1, hideAction: true, isPreview: true, dragKey: type + '-' + k }, editorProps); return /*#__PURE__*/(0,jsx_runtime.jsx)(react_beautiful_dnd_esm/* Draggable */._l, { draggableId: v === null || v === void 0 ? void 0 : (_v$question_id = v.question_id) === null || _v$question_id === void 0 ? void 0 : _v$question_id.toString(), index: k, isDragDisabled: isDragDisabled //是否允许拖拽 , children: function children(provided, snapshot) { return /*#__PURE__*/(0,jsx_runtime.jsx)("aside", objectSpread2_default()(objectSpread2_default()(objectSpread2_default()({ ref: provided.innerRef }, provided.draggableProps), provided.dragHandleProps), {}, { children: /*#__PURE__*/(0,jsx_runtime.jsxs)("div", { className: DragSubjectmodules.posWarp, id: v.dragKey, children: [renderSubject(v, type), markBtnVisible && /*#__PURE__*/(0,jsx_runtime.jsx)(row/* default */.Z, { className: DragSubjectmodules.markWrongBtnWrapper, children: /*#__PURE__*/(0,jsx_runtime.jsx)(es_button/* default */.Z, { onClick: function onClick() { return handleMarkWrongQuestion({ value: v, type: type }); }, children: v !== null && v !== void 0 && v.is_wrong ? '取消标记错题' : '标记错题' }) }), /*#__PURE__*/(0,jsx_runtime.jsx)(divider/* default */.Z, {}), !isDragDisabled && /*#__PURE__*/(0,jsx_runtime.jsx)("div", { className: DragSubjectmodules.pos, children: /*#__PURE__*/(0,jsx_runtime.jsx)("div", { className: DragSubjectmodules.tips, children: "\u62D6\u52A8\u53EF\u4EE5\u6539\u53D8\u8BD5\u9898\u663E\u793A\u987A\u5E8F" }) })] }) })); } }, v === null || v === void 0 ? void 0 : v.question_id); }), provided.placeholder] })); } }) }); }; //转换中文 var toChinesNum = function toChinesNum(num) { var changeNum = ['零', '一', '二', '三', '四', '五', '六', '七', '八', '九']; //changeNum[0] = "零" var unit = ['', '十', '百', '千', '万']; num = parseInt(num); var getWan = function getWan(temp) { var strArr = temp.toString().split('').reverse(); var newNum = ''; for (var i = 0; i < strArr.length; i++) { newNum = (i == 0 && strArr[i] == 0 ? '' : i > 0 && strArr[i] == 0 && strArr[i - 1] == 0 ? '' : changeNum[strArr[i]] + (strArr[i] == 0 ? unit[0] : unit[i])) + newNum; } return newNum; }; var overWan = Math.floor(num / 10000); var noWan = num % 10000; if (noWan.toString().length < 4) noWan = '0' + noWan; return overWan ? getWan(overWan) + '万' + getWan(noWan) : getWan(num); }; var formatTypeNameToDefaultScore = function formatTypeNameToDefaultScore(typeName) { var mapping = { '单选题': 2, '多选题': 5, '填空题': 2, '判断题': 2, '简答题': 10, '编程题': 10, '实训题': 5, '组合题': 10 }; return mapping[typeName] || 0; }; var handleBatchSetScore = function handleBatchSetScore(type, typeName) { score.current = formatTypeNameToDefaultScore(typeName); modal/* default.confirm */.Z.confirm({ centered: true, title: '批量设置分数', content: /*#__PURE__*/(0,jsx_runtime.jsxs)("div", { className: '', children: [/*#__PURE__*/(0,jsx_runtime.jsxs)("span", { children: [typeName === "组合题" ? '组合题中的每小题' : typeName, "\uFF1A"] }), /*#__PURE__*/(0,jsx_runtime.jsx)(input_number/* default */.Z, { min: 1, defaultValue: score.current, onChange: function onChange(value) { score.current = value; } }), /*#__PURE__*/(0,jsx_runtime.jsx)("span", { className: "ml5", children: "\u5206/\u9898" }), /*#__PURE__*/(0,jsx_runtime.jsx)("br", {}), typeName === "填空题" && /*#__PURE__*/(0,jsx_runtime.jsx)("div", { style: { color: 'rgb(255, 0, 0)' }, children: "\u6BCF\u7A7A\u5206\u503C\u6309\u6BCF\u9898\u5206\u503C\u53D6\u5E73\u5747\u5206\u8BA1\u7B97" })] }), okText: '确认', cancelText: '取消', onOk: function () { var _onOk = asyncToGenerator_default()( /*#__PURE__*/regeneratorRuntime_default()().mark(function _callee() { var _res, res; return regeneratorRuntime_default()().wrap(function _callee$(_context) { while (1) switch (_context.prev = _context.next) { case 0: if (!inNewPaperLibrary) { _context.next = 6; break; } _context.next = 3; return (0,paperlibrary/* newBatchSetScore */.vF)(params.id, { question_type: type, score: score.current }); case 3: _res = _context.sent; if (_res.status === 0) { reload(); } return _context.abrupt("return"); case 6: _context.next = 8; return (0,fetch/* default */.ZP)("/api/exercises/".concat(params.categoryId, "/batch_set_score.json"), { method: 'post', body: { question_type: type, score: score.current } }); case 8: res = _context.sent; if (res.status !== -1) { reload(); } case 10: case "end": return _context.stop(); } }, _callee); })); function onOk() { return _onOk.apply(this, arguments); } return onOk; }() }); }; var renderClassifyQuestion = function renderClassifyQuestion() { var _data$exercise_questi; var array = classifyType(); data === null || data === void 0 ? void 0 : (_data$exercise_questi = data.exercise_questions) === null || _data$exercise_questi === void 0 ? void 0 : _data$exercise_questi.forEach(function (v, k) { if (v.question_type === 0) { var _array$v$question_typ, _array$v$question_typ2; (_array$v$question_typ = array[v.question_type]) === null || _array$v$question_typ === void 0 ? void 0 : (_array$v$question_typ2 = _array$v$question_typ.items) === null || _array$v$question_typ2 === void 0 ? void 0 : _array$v$question_typ2.push(v); } if (v.question_type === 1) { var _array$v$question_typ3, _array$v$question_typ4; (_array$v$question_typ3 = array[v.question_type]) === null || _array$v$question_typ3 === void 0 ? void 0 : (_array$v$question_typ4 = _array$v$question_typ3.items) === null || _array$v$question_typ4 === void 0 ? void 0 : _array$v$question_typ4.push(v); } if (v.question_type === 2) { var _array$v$question_typ5, _array$v$question_typ6; (_array$v$question_typ5 = array[v.question_type]) === null || _array$v$question_typ5 === void 0 ? void 0 : (_array$v$question_typ6 = _array$v$question_typ5.items) === null || _array$v$question_typ6 === void 0 ? void 0 : _array$v$question_typ6.push(v); } if (v.question_type === 3) { var _array$v$question_typ7, _array$v$question_typ8; (_array$v$question_typ7 = array[v.question_type]) === null || _array$v$question_typ7 === void 0 ? void 0 : (_array$v$question_typ8 = _array$v$question_typ7.items) === null || _array$v$question_typ8 === void 0 ? void 0 : _array$v$question_typ8.push(v); } if (v.question_type === 4) { var _array$v$question_typ9, _array$v$question_typ10; (_array$v$question_typ9 = array[v.question_type]) === null || _array$v$question_typ9 === void 0 ? void 0 : (_array$v$question_typ10 = _array$v$question_typ9.items) === null || _array$v$question_typ10 === void 0 ? void 0 : _array$v$question_typ10.push(v); } if (v.question_type === 5) { var _array$v$question_typ11, _array$v$question_typ12; (_array$v$question_typ11 = array[v.question_type]) === null || _array$v$question_typ11 === void 0 ? void 0 : (_array$v$question_typ12 = _array$v$question_typ11.items) === null || _array$v$question_typ12 === void 0 ? void 0 : _array$v$question_typ12.push(v); } if (v.question_type === 6) { var _array$v$question_typ13, _array$v$question_typ14; (_array$v$question_typ13 = array[v.question_type]) === null || _array$v$question_typ13 === void 0 ? void 0 : (_array$v$question_typ14 = _array$v$question_typ13.items) === null || _array$v$question_typ14 === void 0 ? void 0 : _array$v$question_typ14.push(v); } if (v.question_type === 7) { var _array$v$question_typ15, _array$v$question_typ16; (_array$v$question_typ15 = array[v.question_type]) === null || _array$v$question_typ15 === void 0 ? void 0 : (_array$v$question_typ16 = _array$v$question_typ15.items) === null || _array$v$question_typ16 === void 0 ? void 0 : _array$v$question_typ16.push(v); } }); var dom = data === null || data === void 0 ? void 0 : data.map(function (er, index) { return /*#__PURE__*/(0,jsx_runtime.jsxs)(react.Fragment, { children: [/*#__PURE__*/(0,jsx_runtime.jsxs)("div", { className: "pl20", children: [/*#__PURE__*/(0,jsx_runtime.jsxs)("span", { className: "font16 c-light-primary", children: [toChinesNum(index + 1), "\u3001", er.name] }), /*#__PURE__*/(0,jsx_runtime.jsxs)("span", { className: "c-grey-999", children: ["\uFF08\u5171", er.count, "\u9898", (er === null || er === void 0 ? void 0 : er.question_type) === 7 ? "\uFF0C\u5305\u542B".concat(er.sub_count, "\u5C0F\u9898") : '', "\uFF1B\u5171", er.score, "\u5206\uFF09"] }), (batchScore === null || batchScore === void 0 ? void 0 : batchScore.includes(er === null || er === void 0 ? void 0 : er.name)) && /*#__PURE__*/(0,jsx_runtime.jsx)(es_button/* default */.Z, { onClick: function onClick() { return handleBatchSetScore(er === null || er === void 0 ? void 0 : er.question_type, er === null || er === void 0 ? void 0 : er.name); }, style: { "float": 'right' }, type: "primary", ghost: true, children: "\u6279\u91CF\u8BBE\u7F6E\u5F97\u5206" })] }), renderMapDom(er.items, er === null || er === void 0 ? void 0 : er.question_type, er === null || er === void 0 ? void 0 : er.name)] }, index); }); return dom; }; return /*#__PURE__*/(0,jsx_runtime.jsxs)("div", { children: [" ", renderClassifyQuestion(), " "] }); }; /* harmony default export */ var components_DragSubject = ((0,_umi_production_exports.connect)()(DragSubject)); /***/ }), /***/ 2977: /*!*********************************************************************!*\ !*** ./src/components/Editor/NullChildEditor/index.jsx + 1 modules ***! \*********************************************************************/ /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { // EXPORTS __webpack_require__.d(__webpack_exports__, { "Z": function() { return /* binding */ Editor_NullChildEditor; } }); // EXTERNAL MODULE: ./node_modules/antd/es/message/style/index.js + 1 modules var style = __webpack_require__(14934); // EXTERNAL MODULE: ./node_modules/antd/es/message/index.js + 1 modules var message = __webpack_require__(12461); // EXTERNAL MODULE: ./node_modules/antd/es/tag/style/index.js + 1 modules var tag_style = __webpack_require__(71114); // EXTERNAL MODULE: ./node_modules/antd/es/tag/index.js + 1 modules var es_tag = __webpack_require__(20550); // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/classCallCheck.js var classCallCheck = __webpack_require__(56690); var classCallCheck_default = /*#__PURE__*/__webpack_require__.n(classCallCheck); // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/createClass.js var createClass = __webpack_require__(89728); var createClass_default = /*#__PURE__*/__webpack_require__.n(createClass); // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/inherits.js var inherits = __webpack_require__(61655); var inherits_default = /*#__PURE__*/__webpack_require__.n(inherits); // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/createSuper.js var createSuper = __webpack_require__(26389); var createSuper_default = /*#__PURE__*/__webpack_require__.n(createSuper); // EXTERNAL MODULE: ./node_modules/antd/es/input/style/index.js + 1 modules var input_style = __webpack_require__(69463); // EXTERNAL MODULE: ./node_modules/antd/es/input/index.js + 5 modules var input = __webpack_require__(75008); // EXTERNAL MODULE: ./node_modules/react/index.js var react = __webpack_require__(67294); ;// CONCATENATED MODULE: ./src/components/Editor/NullChildEditor/index.less?modules // extracted by mini-css-extract-plugin /* harmony default export */ var NullChildEditormodules = ({"flex":"flex___eLcnP","flex1":"flex1___yUTT7","color666":"color666___TiUhG","error":"error___gTTtv","deleteIcon":"deleteIcon___mnZW1","addIcon":"addIcon___JC5NS"}); // EXTERNAL MODULE: ./node_modules/@ant-design/icons/es/icons/PlusOutlined.js var PlusOutlined = __webpack_require__(51042); // EXTERNAL MODULE: ./node_modules/react/jsx-runtime.js var jsx_runtime = __webpack_require__(85893); ;// CONCATENATED MODULE: ./src/components/Editor/NullChildEditor/index.jsx var TextArea = input/* default.TextArea */.Z.TextArea; var NullChildEditor = /*#__PURE__*/function (_Component) { inherits_default()(NullChildEditor, _Component); var _super = createSuper_default()(NullChildEditor); function NullChildEditor(props) { var _this; classCallCheck_default()(this, NullChildEditor); _this = _super.call(this, props); _this.state = { inputVisible: false, EditInputIndex: -1 }; return _this; } // componentDidMount() { // // console.log(`${this.props.index}----`,this.props,e); // if (this.props.answers[0].length <= 0) { // this.setState({ // EditInputIndex: 0, // }); // } // } createClass_default()(NullChildEditor, [{ key: "render", value: function render() { var _this2 = this; var _this$props = this.props, index = _this$props.index, onAnswerChange = _this$props.onAnswerChange, addChildAnswer = _this$props.addChildAnswer, exerciseIsPublish = _this$props.exerciseIsPublish, answers = _this$props.answers, activeOptionErrorIndex = _this$props.activeOptionErrorIndex, _this$props$flex = _this$props.flex, flex = _this$props$flex === void 0 ? '0 0 1000px' : _this$props$flex; console.log('----', answers); var _this$state = this.state, inputVisible = _this$state.inputVisible, EditInputIndex = _this$state.EditInputIndex; return /*#__PURE__*/(0,jsx_runtime.jsxs)("div", { className: NullChildEditormodules.flex, children: [/*#__PURE__*/(0,jsx_runtime.jsxs)("div", { className: "".concat(NullChildEditormodules.color666, " mb5 mt6"), style: { flex: '0 0 90px' }, children: ["\u7B54\u6848(\u586B\u7A7A", index + 1, "):"] }), /*#__PURE__*/(0,jsx_runtime.jsxs)("div", { style: { border: '1px solid #f6f6f6', flex: 1, padding: 10 }, children: [answers.map(function (tag, itemIndex) { return /*#__PURE__*/(0,jsx_runtime.jsx)(jsx_runtime.Fragment, { children: EditInputIndex !== itemIndex ? tag.length > 0 ? /*#__PURE__*/(0,jsx_runtime.jsx)(es_tag/* default */.Z, { className: "edit-tag", closable: true, onClose: function onClose(e) { e.preventDefault(); if ((answers === null || answers === void 0 ? void 0 : answers.length) === 1 && itemIndex === 0) { _this2.props.deleteChildAnswermain(index, itemIndex); } else { _this2.props.deleteChildAnswer(index, itemIndex); } }, children: /*#__PURE__*/(0,jsx_runtime.jsx)("span", { onDoubleClick: function onDoubleClick(e) { _this2.setState({ EditInputIndex: itemIndex }); e.preventDefault(); }, children: tag }) }, tag) : /*#__PURE__*/(0,jsx_runtime.jsx)(input/* default */.Z, { defaultValue: tag, style: { width: 78, marginRight: 8, height: 24, verticalAlign: 'top' }, onBlur: function onBlur(e) { if (e.target.value.replaceAll(' ', '').length <= 0) { message/* default.info */.ZP.info('内容不能为纯空格'); return; } onAnswerChange(index, itemIndex, e.target.value); _this2.setState({ EditInputIndex: -1, inputVisible: false }); } }) : /*#__PURE__*/(0,jsx_runtime.jsx)(input/* default */.Z, { defaultValue: tag, style: { width: 78, marginRight: 8, height: 24, verticalAlign: 'top' }, onBlur: function onBlur(e) { if (e.target.value.replaceAll(' ', '').length <= 0) { message/* default.info */.ZP.info('内容不能为纯空格'); return; } onAnswerChange(index, itemIndex, e.target.value); _this2.setState({ EditInputIndex: -1, inputVisible: false }); } }) }); }), !inputVisible && /*#__PURE__*/(0,jsx_runtime.jsxs)(es_tag/* default */.Z, { className: "site-tag-plus", onClick: function onClick() { addChildAnswer(index); // console.log(this.props.index); _this2.setState({ inputVisible: true }); }, children: [/*#__PURE__*/(0,jsx_runtime.jsx)(PlusOutlined/* default */.Z, {}), " \u65B0\u589E\u7B54\u6848"] })] })] }); } }]); return NullChildEditor; }(react.Component); /* harmony default export */ var Editor_NullChildEditor = (NullChildEditor); /***/ }), /***/ 4207: /*!************************************************!*\ !*** ./src/components/EditorKeyword/index.tsx ***! \************************************************/ /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { /* harmony import */ var antd_es_tag_style__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! antd/es/tag/style */ 71114); /* harmony import */ var antd_es_tag__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! antd/es/tag */ 20550); /* harmony import */ var antd_es_row_style__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! antd/es/row/style */ 13062); /* harmony import */ var antd_es_row__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! antd/es/row */ 71230); /* harmony import */ var antd_es_input_style__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! antd/es/input/style */ 69463); /* harmony import */ var antd_es_input__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! antd/es/input */ 75008); /* harmony import */ var _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_helpers_toConsumableArray_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./node_modules/@babel/runtime/helpers/toConsumableArray.js */ 861); /* harmony import */ var _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_helpers_toConsumableArray_js__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_helpers_toConsumableArray_js__WEBPACK_IMPORTED_MODULE_3__); /* harmony import */ var antd_es_tooltip_style__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! antd/es/tooltip/style */ 38390); /* harmony import */ var antd_es_tooltip__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! antd/es/tooltip */ 84908); /* harmony import */ var antd_es_message_style__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! antd/es/message/style */ 14934); /* harmony import */ var antd_es_message__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! antd/es/message */ 12461); /* harmony import */ var _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_helpers_slicedToArray_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./node_modules/@babel/runtime/helpers/slicedToArray.js */ 27424); /* harmony import */ var _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_helpers_slicedToArray_js__WEBPACK_IMPORTED_MODULE_6___default = /*#__PURE__*/__webpack_require__.n(_root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_helpers_slicedToArray_js__WEBPACK_IMPORTED_MODULE_6__); /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! react */ 67294); /* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! react/jsx-runtime */ 85893); var EditorKeyword = function EditorKeyword(_ref) { var _value$2, _value$5; var _ref$value = _ref.value, value = _ref$value === void 0 ? [[], []] : _ref$value, onChange = _ref.onChange; var _useState = (0,react__WEBPACK_IMPORTED_MODULE_7__.useState)(''), _useState2 = _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_helpers_slicedToArray_js__WEBPACK_IMPORTED_MODULE_6___default()(_useState, 2), valueOne = _useState2[0], setValueOne = _useState2[1]; var _useState3 = (0,react__WEBPACK_IMPORTED_MODULE_7__.useState)(''), _useState4 = _root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_helpers_slicedToArray_js__WEBPACK_IMPORTED_MODULE_6___default()(_useState3, 2), valueTwo = _useState4[0], setValueTwo = _useState4[1]; var test = function test(str) { if (!str) { return false; } // let containSpecial = RegExp(/[(\ )(\~)(\!)(\@)(\#)(\$)(\%)(\^)(\&)(\*)(\()(\))(\-)(\_)(\+)(\=)(\[)(\])(\{)(\})(\\)(\;)(\:)(\')(\")(\,)(\.)(\/)(\<)(\>)(\?)(\)]+/); var containSpecial = new RegExp("[ `~!@#$^&*()={}':;,\\[\\].<>/?~!@#¥……&*()—【】‘;:”“。,、?「」『』_\\+\\-·%《》]|[\\\\/]"); if (containSpecial.test(str)) { antd_es_message__WEBPACK_IMPORTED_MODULE_9__/* ["default"].warn */ .ZP.warn("关键词不能含有特殊字符!"); return false; } if (str === '|') { antd_es_message__WEBPACK_IMPORTED_MODULE_9__/* ["default"].warn */ .ZP.warn("关键词不能只输入一个“|”字符!"); return false; } return true; }; return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_8__.jsxs)("div", { children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_8__.jsxs)("p", { className: "font14", children: ["\u5173\u952E\u8BCD", /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_8__.jsx)("span", { className: "c-grey-999", children: "\uFF08\u5173\u952E\u8BCD\u53EF\u7528\u4E8E\u81EA\u52A8\u5224\u5206\uFF09" }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_8__.jsx)(antd_es_tooltip__WEBPACK_IMPORTED_MODULE_10__/* ["default"] */ .Z, { overlayStyle: { maxWidth: 350 }, title: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_8__.jsxs)("div", { children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_8__.jsx)("div", { children: "\u6BCF\u4E2A\u6838\u5FC3\u5173\u952E\u8BCD\u7684\u5206\u6570\u662F\u666E\u901A\u5173\u952E\u8BCD\u5206\u6570\u7684\u4E24\u500D" }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_8__.jsx)("div", { children: "\u4F8B\u5982\uFF1A" }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_8__.jsx)("div", { children: "\u672C\u989810\u5206\uFF0C\u666E\u901A\u5173\u952E\u8BCD1\u4E2A\uFF0C\u6838\u5FC3\u5173\u952E\u8BCD2\u4E2A\uFF0C\u5219\u6BCF\u4E2A" }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_8__.jsx)("div", { children: "\u666E\u901A\u5173\u952E\u8BCD2\u5206\uFF0C\u6BCF\u4E2A\u6838\u5FC3\u5173\u952E\u8BCD4\u5206" })] }), children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_8__.jsx)("span", { className: "iconfont icon-a-wenhaobeifen2 font14" }) })] }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_8__.jsxs)(antd_es_row__WEBPACK_IMPORTED_MODULE_11__/* ["default"] */ .Z, { align: "middle", className: "font14", children: ["\u666E\u901A\u5173\u952E\u8BCD\uFF1A", /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_8__.jsx)(antd_es_input__WEBPACK_IMPORTED_MODULE_12__/* ["default"] */ .Z, { value: valueOne, onChange: function onChange(e) { setValueOne(e.target.value); }, maxLength: 50, allowClear: true, onPressEnter: function onPressEnter(e) { var _e$target; var v = (_e$target = e.target) === null || _e$target === void 0 ? void 0 : _e$target.value; if (test(v)) { var _value$, _v$split; (_value$ = value[0]) === null || _value$ === void 0 ? void 0 : _value$.push(v === null || v === void 0 ? void 0 : (_v$split = v.split('|')) === null || _v$split === void 0 ? void 0 : _v$split.filter(function (k) { return !!k; })); onChange(_root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_helpers_toConsumableArray_js__WEBPACK_IMPORTED_MODULE_3___default()(value)); setValueOne(''); } }, style: { width: 800 }, className: "ml5 mr10", placeholder: "\u652F\u6301\u4FDD\u5B58\u591A\u4E2A\u5173\u952E\u8BCD\uFF1B\u5E76\u5217\u5173\u952E\u8BCD\uFF08\u6216\u7684\u5173\u7CFB\uFF09\u7528\u201D|\u201D\u5206\u5272\u3002" }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_8__.jsx)("span", { className: "c-grey-999", children: "\u201C\u56DE\u8F66\u952E\u201D\u4FDD\u5B58\u5173\u952E\u8BCD" })] }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_8__.jsx)("div", { style: { paddingLeft: 89 }, className: "mt10", children: value === null || value === void 0 ? void 0 : (_value$2 = value[0]) === null || _value$2 === void 0 ? void 0 : _value$2.map(function (tag, k) { return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_8__.jsx)(antd_es_tag__WEBPACK_IMPORTED_MODULE_13__/* ["default"] */ .Z, { className: "mb10", closable: true, onClose: function onClose(e) { var _value$3; e.preventDefault(); value[0] = (_value$3 = value[0]) === null || _value$3 === void 0 ? void 0 : _value$3.filter(function (e, i) { return i !== k; }); onChange(_root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_helpers_toConsumableArray_js__WEBPACK_IMPORTED_MODULE_3___default()(value)); }, children: tag === null || tag === void 0 ? void 0 : tag.join(' 或 ') }, k); }) }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_8__.jsxs)(antd_es_row__WEBPACK_IMPORTED_MODULE_11__/* ["default"] */ .Z, { align: "middle", className: "font14", children: ["\u6838\u5FC3\u5173\u952E\u8BCD\uFF1A", /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_8__.jsx)(antd_es_input__WEBPACK_IMPORTED_MODULE_12__/* ["default"] */ .Z, { value: valueTwo, onChange: function onChange(e) { setValueTwo(e.target.value); }, maxLength: 50, allowClear: true, onPressEnter: function onPressEnter(e) { var _e$target2; var v = (_e$target2 = e.target) === null || _e$target2 === void 0 ? void 0 : _e$target2.value; if (test(v)) { var _value$4, _v$split2; (_value$4 = value[1]) === null || _value$4 === void 0 ? void 0 : _value$4.push(v === null || v === void 0 ? void 0 : (_v$split2 = v.split('|')) === null || _v$split2 === void 0 ? void 0 : _v$split2.filter(function (k) { return !!k; })); onChange(_root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_helpers_toConsumableArray_js__WEBPACK_IMPORTED_MODULE_3___default()(value)); setValueTwo(''); } }, style: { width: 800 }, className: "ml5 mr10", placeholder: "\u652F\u6301\u4FDD\u5B58\u591A\u4E2A\u5173\u952E\u8BCD\uFF1B\u5E76\u5217\u5173\u952E\u8BCD\uFF08\u6216\u7684\u5173\u7CFB\uFF09\u7528\u201D|\u201D\u5206\u5272\u3002" }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_8__.jsx)("span", { className: "c-grey-999", children: "\u201C\u56DE\u8F66\u952E\u201D\u4FDD\u5B58\u5173\u952E\u8BCD" })] }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_8__.jsx)("div", { style: { paddingLeft: 89 }, className: "mt10", children: value === null || value === void 0 ? void 0 : (_value$5 = value[1]) === null || _value$5 === void 0 ? void 0 : _value$5.map(function (tag, k) { return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_8__.jsx)(antd_es_tag__WEBPACK_IMPORTED_MODULE_13__/* ["default"] */ .Z, { className: "mb10", closable: true, onClose: function onClose(e) { var _value$6; e.preventDefault(); value[1] = (_value$6 = value[1]) === null || _value$6 === void 0 ? void 0 : _value$6.filter(function (e, i) { return i !== k; }); onChange(_root_workspace_ppte5yg23_SJ5m_develop_node_modules_babel_runtime_helpers_toConsumableArray_js__WEBPACK_IMPORTED_MODULE_3___default()(value)); }, children: tag === null || tag === void 0 ? void 0 : tag.join(' 或 ') }, k); }) })] }); }; /* harmony default export */ __webpack_exports__["Z"] = (EditorKeyword); /***/ }), /***/ 90525: /*!********************************************************!*\ !*** ./src/components/Knowledge/index.tsx + 2 modules ***! \********************************************************/ /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { // EXPORTS __webpack_require__.d(__webpack_exports__, { "N": function() { return /* binding */ Knowledge; } }); // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/regeneratorRuntime.js var regeneratorRuntime = __webpack_require__(17061); var regeneratorRuntime_default = /*#__PURE__*/__webpack_require__.n(regeneratorRuntime); // EXTERNAL MODULE: ./node_modules/antd/es/message/style/index.js + 1 modules var style = __webpack_require__(14934); // EXTERNAL MODULE: ./node_modules/antd/es/message/index.js + 1 modules var message = __webpack_require__(12461); // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/asyncToGenerator.js var asyncToGenerator = __webpack_require__(17156); var asyncToGenerator_default = /*#__PURE__*/__webpack_require__.n(asyncToGenerator); // EXTERNAL MODULE: ./node_modules/antd/es/input/style/index.js + 1 modules var input_style = __webpack_require__(69463); // EXTERNAL MODULE: ./node_modules/antd/es/input/index.js + 5 modules var input = __webpack_require__(75008); // EXTERNAL MODULE: ./node_modules/antd/es/modal/style/index.js + 1 modules var modal_style = __webpack_require__(35611); // EXTERNAL MODULE: ./node_modules/antd/es/modal/index.js + 7 modules var modal = __webpack_require__(85402); // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/toConsumableArray.js var toConsumableArray = __webpack_require__(861); var toConsumableArray_default = /*#__PURE__*/__webpack_require__.n(toConsumableArray); // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/slicedToArray.js var slicedToArray = __webpack_require__(27424); var slicedToArray_default = /*#__PURE__*/__webpack_require__.n(slicedToArray); // EXTERNAL MODULE: ./node_modules/antd/es/select/style/index.js + 1 modules var select_style = __webpack_require__(95985); // EXTERNAL MODULE: ./node_modules/antd/es/select/index.js var es_select = __webpack_require__(34041); // EXTERNAL MODULE: ./node_modules/react/index.js var react = __webpack_require__(67294); // EXTERNAL MODULE: ./src/utils/fetch.ts var fetch = __webpack_require__(84519); ;// CONCATENATED MODULE: ./src/components/Knowledge/index.less?modules // extracted by mini-css-extract-plugin /* harmony default export */ var Knowledgemodules = ({"wrap":"wrap___F7E3F","addKnowledge":"addKnowledge___LyKCQ","disabled":"disabled___P1Ph9"}); ;// CONCATENATED MODULE: ./src/components/Knowledge/icon.png var icon_namespaceObject = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGwAAABsCAYAAACPZlfNAAALdklEQVR4Xu2dC2wc1RVAzx1nDXFiO4SEhqxtxS0JHzX94TS0FEKLALX8WkKbqrRVKQrh15Zfq0IqIaSGSOXb8ktANFJbKqUFWigEAUohfFRQDC1KxS8UR/7wDbZ3TRxix3urN951No7Xnt15M7Mbz0hRImXevffds/PmzXv33StU0KWqTlcfh6mwkCHmq8M8B5oUZosyS6EeOCD7x/Rsl/kjkFJhu8AHGWiXDNuoYqsoW5K1vCkimUpxg5SzoW+r1gylOUGErygci9IC1Fi2uR+hVeA5VZ6tquOpuSL9lnVYE1d2wNo+0jnVylLNcKYKx6EcaK23XgQJH4vyjDg8OCDc3zxd3vXSLKx7ygJYW5seOGUmZ6GcJ8IShaqwHDCeHoEhVTYh3LO7mweam+XjqO2KFNjWPp09VblUlQuAmVE7YwL93SKs2SncMr9WPojK1kiAdWzXpCa40oHlCtOi6nwpegV2ZOBuGeSGxlnSVYoMP21CBfZmnx5SneFagXPzZnJ+7I+y7S6FdQMO1xxWK++HZUgowNzpeIoVKqwCDgqrcyHp6RFlZbKetWF8HgQOrD2liwTuAHdKvj9frVVTuHDuNGkNspOBAWtt1cShC1ilcLlqecz6gnSkkS3CkMBN77zBypYWGQxCXyDAuvq1KTPIeuCYIIyuAJnPOwmWJWuk3bat1oF1pfWMjLKuAqbptn05Wl63I5ybrJOHbCqyCqw9ratEucqMDjaNrGBZqsLqpjpZaasPVhyrqlVdKe5Wcafr8TXKA6KsS9azXESG/DrHN7CODp0qdaxXON2vMftze4F/aJpljY2y008/fQFr69EZCYeH3ZX0+JrQA2ZHYDDDac0HSe+ENxe4oWRg2SfriRhWca53t3HSnFTqk1YSMPedleZv8TBYHKzc3WZ4TNbxrVLeaSUB6+zV38cTjNJgjUBT1jXMkB8XK6VoYNmp+9XFKorv39cDKlxX7JS/KGDZj+K/x99Z1n5+6gjfLObj2jOw7HLTv+MVDGuwcoK6nQSf97qM5QmYWcj9xHyensRrg9YpjRL4/HtbOd7LgrEnYF1p/U1G+XnQVk9m+Y5wfbJOfjGRDyYEZvazHOFfk2WLZCKHBfX/Zmsmo3ypqV42j6djXGBmp7gzzQuTYPMxKA7Fym1tqGPxeDvX4wLr7NULVdzd4vgKyQOiXNQwQ+4spK4gMBMwc0CG1/bDGIyQXF+ymp5dDkcUCuwpCKwzpXcqbrxgfIXsAYU1TfVy4VhqxwRm4gZJ8L/9IBQtZFdbU7eLQT41VtzjmMDaU3qzwKXW1MeCivaAwi1N9XLZ6Ib7AHPDpzO0hRmR+/L78Ict8J93IT1QdN+sN6irhs/NgR8uhM8eYl28J4EmwninQ/PosPB9gHWmdZUqoS3u/uUVuPEFKMcDWg5wxWL4zlGefGz9JhGuaxgVD7IXsOwpEhMvHsrBBPNknf9IecLKed9Au+vUyJ607t3dJPNPzewFrCOl3wPutf5TKSDwio3wdF7k3imfhMNnugGZkV2q8Ho3PPbWHhOOb4IbT4zMpHMa6+XPOe17A+vVjQhfC8u0E+/d884ysH69JCzNE+v51aY90Mw7beM5E7cJ5A7ln40zZOTnMgLMnHxMDNEZ5mG6RSbcNHv9tAV+sDCQLpck9I9b4Hd5UfKbIwrgM4cKB6toyJ0EHQHWkdJLgFtL6l2JjfKB/WwRfP/TJQoKoNmf/gu/zVuGjQqY6ZrjcEmyVm43/x4B1pnSxxVOCqDvBUXGwLx5W+CJhno5eQSYe1q/jw/DPgAeA/MGDOHjqloONtkN3CesI6XfAB7x2NzabV6B3fca3LoZ+ndbU+0KmpaAn7TA0iP2lVtOQ2LWulMb62WDC6wzrdfp8CGGUC+vwL56L3wU0ArI9Gp4cowZYLkBE2F1Q51cPfyEpXUTyvGh0gK8ArvgUXgxoGwZX5gDa79eAU+Y8HRjnSyR7K5yXwAZZibk7xXYjkHY2Abmb5uXGRJPnAfTqisAGPQ31FErnWldoMrrNh3hVZZXYF7l2byv3IZEd4YoHC4dfbqUDPfZ7KxXWTEwr57K3udwtnT06i8RVhfZ1MrtMbAi3ahcJe1pXSPKiiKbWrk9BlacG1VYa95hG1QZY55UnLBS7vYK7JXtwxuc/ZYnHTWJ4U3Ko2ZVxKTDvMMelY60bs7mISzF577aeAV25l/h7Y98qSrYeO50ePDblQHMzevYmVITDjAvGHeMLzUGVpzXBbZJR0p7gBnFNbVzt1dgr+aGRMtLUzVThofEI8cYEh9/C1ZuGu7n7BrYsMxOn31K6TXAdkTx0WwM9wrMZydLaj6UgTtegje64UefgaPnlCTGdqN+A8z8biPJAFrOwGx72pK8oRiYJU+GJMYFFg+JIXnbghp3SOyO6sCD1yFxxwBs3BbA4m91dvE3YcGV4YjoqYhp/YpH4aWAtlfMZGJNJMsGxRMentZXwIdzFBuYxbszhBbuh3MFLE25IQKtwSxNmRCBs8cIEQjB/UWrcJem4sXfvf32Qhdc8jjcdjIsThbt00AbuIu/8fZK5QDDbK/EG5gVBMxsYMYhApUDzA0RqIQgnEBfDKOEl/E7bDgIx9hb7mFuMTA3qH44zM04o9wDSWNgbsRUXiBpmYdq2wZmhr1C16sfwu0vwsVHw5EHF74vgin/nlDtcjgMEeb5sPw1zFJ/DKEePxp9GMIdFiM4bhTVCUyvT9gR4zxhx4T4Ub3PcSMDrKtPL85kuK3UX1wp7fyccTaHGE5uBhP5ZPMqx1nimAf6ojgy+/J7cP6G0rMILJ4Lt51iExeUG7CCR2bd6X3Ih9KNTj95OmZOhce+u38Do9ChdBdYyGkfcq4uJRPO9ARc9kU4Y8F+DgwKp30IO7GKXVfbkVZmQ+L4iVWyH9Ghpi6y42Z7UsoJ2ISpi0y3o0gOZs/d/iWVCzDPycFMl+P0e/7B+5XgOf2eO/mIE1z69bff9sUluMw+ZXdKnELWr+NLal90ClmjJU7SXJKvbTQqLUmzO2OM06DbAFCUjJLToBstcaGBonxt42Z/hQay77K4lIcNFBPIsFLKI6cjLpYTBjGub7RRLMeYGpejChyY3XJUxty44Ftg0OwXfMsbGs/IKHFJRXvsgiupmLMxLlpqkVbQRUtzpsZlgf1Dk7DKAme/z+LC2z6YhV54210g7tCpUkdc2r5IcJGUts/Z2NajMxIODyscW6Tdk/J2A2sww2nNB0lvqQ7wXTQj+6StVzi9VCMmQzszDGqaZY2NstNPf30DM8qfVJ0yP8VdKkRUP8GPC4JvayYYyXqWi8iQX21WgI2a8pvs3Fbl+u1khO1VhdVNo0pK+bHHumO70mo+rk1VlVBKWvnpfMBtux3h3GSdPGRTj3VgectY64FjbBpbQbKedxIsS9ZIXrEtO9YHAsyYZhaMD13AKoXLJ0uVdbNFInDTO2+wsqVFLOdPHQYeGLCR91pKFwlu8e4WO7+xspXSqnDRRKXp/VofODBjoNm57kqxQoVVUeW18uuocdr3iLIyWc/a8UrS29IfCrCcsSawpzrDtYI7/T/AVicikrNLYd2AwzWFqpoHYVeowHIdMHGPmuBKB5aHWX7YhgNNRG4G7pZBbhirMLYNHePJiARYziA3LFy5VJULKuAzoFuENTuFW0bXVg4aUr78SIHlDMmemjkL5TwRloRZh3OCX/OQKpsQ7tndzQP55XnDhFR2wPINMidBq5WlmuFMFY4Lu2qgqYYnyjPi8OCAcH+uWGhUgEbrLYsnrJAz3OwGaU5AOQ6HL2cLItRYdl6/m8AfnlPl2ao6njKlCy3rsCaurIGN7qX7edDHYSosZIj56jDPgSaF2aLM0uH8+6YaWG4GugsYEOhVYbvABxlolwzbqGKrKFuStbwZxnTcFrH/A8wNv8JI/KKJAAAAAElFTkSuQmCC"; // EXTERNAL MODULE: ./node_modules/react/jsx-runtime.js var jsx_runtime = __webpack_require__(85893); ;// CONCATENATED MODULE: ./src/components/Knowledge/index.tsx var Option = es_select/* default.Option */.Z.Option; var Knowledge = function Knowledge(_ref) { var subId = _ref.subId, value = _ref.value, selectvalues = _ref.selectvalues, disabled = _ref.disabled, _ref$knowledgeOptions = _ref.knowledgeOptions, knowledgeOptions = _ref$knowledgeOptions === void 0 ? [] : _ref$knowledgeOptions, _ref$onChange = _ref.onChange, onChange = _ref$onChange === void 0 ? function () {} : _ref$onChange, _ref$onAddKnowledgeFi = _ref.onAddKnowledgeFinish, onAddKnowledgeFinish = _ref$onAddKnowledgeFi === void 0 ? function () {} : _ref$onAddKnowledgeFi; var addValue = (0,react.useRef)(); var _useState = (0,react.useState)([]), _useState2 = slicedToArray_default()(_useState, 2), values = _useState2[0], setValues = _useState2[1]; value = value || []; var handleChange = function handleChange(e, valuesmap) { if (e) { //获取选中的数据 setValues([valuesmap.key]); onChange([valuesmap.key]); } else { //获取选中的数据 setValues([]); onChange([]); } }; (0,react.useEffect)(function () { if ((selectvalues === null || selectvalues === void 0 ? void 0 : selectvalues.length) > 0) { setValues(toConsumableArray_default()(selectvalues)); onChange(toConsumableArray_default()(selectvalues)); } }, [knowledgeOptions]); (0,react.useEffect)(function () { var _value; if (((_value = value) === null || _value === void 0 ? void 0 : _value.length) > 0) { onChange(toConsumableArray_default()(value)); } }, [knowledgeOptions]); var handleAdd = function handleAdd(e) { e.preventDefault(); addValue.current = ''; modal/* default.confirm */.Z.confirm({ centered: true, width: 700, okText: '确定', cancelText: '取消', icon: null, title: '新建知识点', className: 'custom-modal-divider', content: /*#__PURE__*/(0,jsx_runtime.jsxs)("div", { className: "font14", children: [/*#__PURE__*/(0,jsx_runtime.jsxs)("div", { style: { display: 'flex', marginTop: '48px', marginBottom: '36px' }, children: [/*#__PURE__*/(0,jsx_runtime.jsx)("img", { src: icon_namespaceObject, style: { width: '108px', height: "108px", marginRight: '29px' } }), "\u60A8\u586B\u5199\u7684\u77E5\u8BC6\u70B9\u6682\u65F6\u4EC5\u5BF9\u672C\u4EBA\u53EF\u89C1\uFF0C\u5E73\u53F0\u5BA1\u6838\u901A\u8FC7\u540E\u5C06\u5217\u5165\u516C\u5F00\u77E5\u8BC6\u70B9\uFF0C\u5BF9\u6240\u6709\u7528\u6237\u53EF\u89C1\uFF1B", /*#__PURE__*/(0,jsx_runtime.jsx)("br", {}), "\u5E73\u53F0\u5BA1\u6838\u8FC7\u7A0B\u4E2D\u6709\u6743\u5220\u9664\u4E0D\u5408\u9002\u7684\u77E5\u8BC6\u70B9\uFF08\u5305\u62EC\u4F46\u4E0D\u9650\u4E8E\u9519\u8BEF\u3001\u975E\u6CD5\u3001\u4E0D\u96C5\u3001\u4E0D\u5339\u914D\u5F53\u524D\u8BFE\u7A0B\u7B49\u60C5\u5F62\uFF09\uFF0C\u5220\u9664\u540E\u53EF\u80FD\u5F71\u54CD\u60A8\u7684\u8BD5\u9898\u7684\u6B63\u5E38\u4F7F\u7528\u3002", /*#__PURE__*/(0,jsx_runtime.jsx)("br", {}), "\u8BF7\u8BA4\u771F\u586B\u5199\u4E0E\u6559\u5B66\u5185\u5BB9\u76F8\u5173\u7684\u771F\u5B9E\u77E5\u8BC6\u70B9 ", /*#__PURE__*/(0,jsx_runtime.jsx)("br", {})] }), /*#__PURE__*/(0,jsx_runtime.jsx)(input/* default */.Z, { className: "mt5", maxLength: 20, style: { marginBottom: '42px' }, placeholder: "\u8BF7\u8F93\u5165\u4E0D\u8D85\u8FC720\u5B57\u7684\u77E5\u8BC6\u70B9\u540D\u79F0", defaultValue: addValue.current, onChange: function onChange(e) { addValue.current = e.target.value; } })] }), onOk: function onOk() { return new Promise( /*#__PURE__*/function () { var _ref2 = asyncToGenerator_default()( /*#__PURE__*/regeneratorRuntime_default()().mark(function _callee(resolve, reject) { var res, _value2; return regeneratorRuntime_default()().wrap(function _callee$(_context) { while (1) switch (_context.prev = _context.next) { case 0: if (addValue.current) { _context.next = 3; break; } message/* default.warn */.ZP.warn("请输入知识点名称"); return _context.abrupt("return", reject()); case 3: if (!(addValue.current.length > 20)) { _context.next = 6; break; } message/* default.warn */.ZP.warn("请输入不超过20字的知识点名称"); return _context.abrupt("return", reject()); case 6: _context.next = 8; return (0,fetch/* default */.ZP)("/api/tag_disciplines.json", { method: 'post', body: { name: addValue.current, sub_discipline_id: subId } }); case 8: res = _context.sent; if ((res === null || res === void 0 ? void 0 : res.status) === 0) { onAddKnowledgeFinish({ id: res.tag_discipline_id, name: addValue.current, type: 'personal' }); // values.push(res.tag_discipline_id) // value.push(res.tag_discipline_id) _value2 = []; _value2.push(res.tag_discipline_id); onChange([].concat(_value2)); setValues([res.tag_discipline_id]); onChange([].concat(_value2)); } return _context.abrupt("return", resolve()); case 11: case "end": return _context.stop(); } }, _callee); })); return function (_x, _x2) { return _ref2.apply(this, arguments); }; }()); } }); }; return /*#__PURE__*/(0,jsx_runtime.jsxs)("div", { className: Knowledgemodules.wrap, children: [/*#__PURE__*/(0,jsx_runtime.jsx)(es_select/* default */.Z, { disabled: !subId || disabled // mode="multiple" , className: "mr5", style: { width: '242px' }, onChange: handleChange, showSearch: true, allowClear: true // showSearch={true} , value: knowledgeOptions === null || knowledgeOptions === void 0 ? void 0 : knowledgeOptions.filter(function (item) { return (values === null || values === void 0 ? void 0 : values.includes(item === null || item === void 0 ? void 0 : item.id)) || (values === null || values === void 0 ? void 0 : values.includes((item === null || item === void 0 ? void 0 : item.id) + '')); }).map(function (item) { return item.name; }), children: knowledgeOptions === null || knowledgeOptions === void 0 ? void 0 : knowledgeOptions.map(function (item) { return /*#__PURE__*/(0,jsx_runtime.jsx)(Option, { value: item.name, children: /*#__PURE__*/(0,jsx_runtime.jsxs)("div", { style: { display: 'flex', justifyContent: 'space-between' }, children: [/*#__PURE__*/(0,jsx_runtime.jsx)("span", { style: { overflow: "hidden", whiteSpace: "nowrap", textOverflow: "ellipsis" }, children: item.name }), /*#__PURE__*/(0,jsx_runtime.jsx)("span", { children: item.type === 'personal' ? '(自用)' : '' })] }) }, item.id); }) }), /*#__PURE__*/(0,jsx_runtime.jsx)("button", { disabled: !subId, className: "".concat(Knowledgemodules.addKnowledge, " ").concat(subId ? '' : Knowledgemodules.disabled), onClick: handleAdd, children: "\u65B0\u5EFA\u77E5\u8BC6\u70B9" })] }); }; /***/ }), /***/ 70960: /*!***************************!*\ !*** ./src/utils/enum.ts ***! \***************************/ /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ "c": function() { return /* binding */ QuestionType; } /* harmony export */ }); /* unused harmony export PageType */ var PageType; (function (PageType) { PageType["FirstPage"] = "firstPage"; PageType["PrevPage"] = "prevPage"; PageType["NextPage"] = "nextPage"; })(PageType || (PageType = {})); var QuestionType; (function (QuestionType) { QuestionType[QuestionType["Single"] = 0] = "Single"; QuestionType[QuestionType["Multiple"] = 1] = "Multiple"; QuestionType[QuestionType["Judge"] = 2] = "Judge"; QuestionType[QuestionType["Fill"] = 3] = "Fill"; QuestionType[QuestionType["Subjective"] = 4] = "Subjective"; QuestionType[QuestionType["Shixun"] = 5] = "Shixun"; QuestionType[QuestionType["Program"] = 6] = "Program"; QuestionType[QuestionType["Combine"] = 7] = "Combine"; })(QuestionType || (QuestionType = {})); /***/ }) }]);