mario-education 2.4.460-release → 2.4.462-release

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -44,5 +44,8 @@ declare const useQuestionDetail: (id?: number | undefined, type?: number | undef
44
44
  listLanguage: any;
45
45
  activeLanguage: string;
46
46
  onChangeLanguage: (code: string) => void;
47
+ modelQuestionLang: QuestionDetail[];
48
+ setModelQuestionLang: import("react").Dispatch<import("react").SetStateAction<QuestionDetail[]>>;
49
+ handleValidateForm: (onValidate: Function, setErrors: Function) => Promise<boolean>;
47
50
  };
48
51
  export default useQuestionDetail;
package/dist/index.js CHANGED
@@ -183,6 +183,65 @@ function _forTo(array, body, check) {
183
183
 
184
184
  const _iteratorSymbol = /*#__PURE__*/ typeof Symbol !== "undefined" ? (Symbol.iterator || (Symbol.iterator = Symbol("Symbol.iterator"))) : "@@iterator";
185
185
 
186
+ // Asynchronously iterate through an object's values
187
+ // Uses for...of if the runtime supports it, otherwise iterates until length on a copy
188
+ function _forOf(target, body, check) {
189
+ if (typeof target[_iteratorSymbol] === "function") {
190
+ var iterator = target[_iteratorSymbol](), step, pact, reject;
191
+ function _cycle(result) {
192
+ try {
193
+ while (!(step = iterator.next()).done && (!check || !check())) {
194
+ result = body(step.value);
195
+ if (result && result.then) {
196
+ if (_isSettledPact(result)) {
197
+ result = result.v;
198
+ } else {
199
+ result.then(_cycle, reject || (reject = _settle.bind(null, pact = new _Pact(), 2)));
200
+ return;
201
+ }
202
+ }
203
+ }
204
+ if (pact) {
205
+ _settle(pact, 1, result);
206
+ } else {
207
+ pact = result;
208
+ }
209
+ } catch (e) {
210
+ _settle(pact || (pact = new _Pact()), 2, e);
211
+ }
212
+ }
213
+ _cycle();
214
+ if (iterator.return) {
215
+ var _fixup = function(value) {
216
+ try {
217
+ if (!step.done) {
218
+ iterator.return();
219
+ }
220
+ } catch(e) {
221
+ }
222
+ return value;
223
+ };
224
+ if (pact && pact.then) {
225
+ return pact.then(_fixup, function(e) {
226
+ throw _fixup(e);
227
+ });
228
+ }
229
+ _fixup();
230
+ }
231
+ return pact;
232
+ }
233
+ // No support for Symbol.iterator
234
+ if (!("length" in target)) {
235
+ throw new TypeError("Object is not iterable");
236
+ }
237
+ // Handle live collections properly
238
+ var values = [];
239
+ for (var i = 0; i < target.length; i++) {
240
+ values.push(target[i]);
241
+ }
242
+ return _forTo(values, function(i) { return body(values[i]); }, check);
243
+ }
244
+
186
245
  const _asyncIteratorSymbol = /*#__PURE__*/ typeof Symbol !== "undefined" ? (Symbol.asyncIterator || (Symbol.asyncIterator = Symbol("Symbol.asyncIterator"))) : "@@asyncIterator";
187
246
 
188
247
  // Asynchronously implement a generic for loop
@@ -15975,6 +16034,10 @@ var useQuestionDetail$1 = function useQuestionDetail(id, type) {
15975
16034
  activeLanguage = _useState4[0],
15976
16035
  setActiveLanguage = _useState4[1];
15977
16036
 
16037
+ var _useState5 = React.useState([]),
16038
+ modelQuestionLang = _useState5[0],
16039
+ setModelQuestionLang = _useState5[1];
16040
+
15978
16041
  var setEditedTrue = function setEditedTrue() {
15979
16042
  try {
15980
16043
  localStorage.setItem(window.location.href, "true");
@@ -15985,13 +16048,13 @@ var useQuestionDetail$1 = function useQuestionDetail(id, type) {
15985
16048
  }
15986
16049
  };
15987
16050
 
15988
- var _useState5 = React.useState(initialLabelQuestions),
15989
- labelQuestions = _useState5[0],
15990
- setLabelQuestions = _useState5[1];
16051
+ var _useState6 = React.useState(initialLabelQuestions),
16052
+ labelQuestions = _useState6[0],
16053
+ setLabelQuestions = _useState6[1];
15991
16054
 
15992
- var _useState6 = React.useState(""),
15993
- tinyMCEKey = _useState6[0],
15994
- setTinyMCEKey = _useState6[1];
16055
+ var _useState7 = React.useState(""),
16056
+ tinyMCEKey = _useState7[0],
16057
+ setTinyMCEKey = _useState7[1];
15995
16058
 
15996
16059
  var getMinIdCategory = function getMinIdCategory(categories) {
15997
16060
  var sortedCategory = categories.sort(function (c1, c2) {
@@ -16001,15 +16064,49 @@ var useQuestionDetail$1 = function useQuestionDetail(id, type) {
16001
16064
  return (firstCategory === null || firstCategory === void 0 ? void 0 : firstCategory.id) || 1;
16002
16065
  };
16003
16066
 
16067
+ var handleValidateForm = function handleValidateForm(onValidate, setErrors) {
16068
+ try {
16069
+ var _exit2 = false;
16070
+ var formLanguageModelCreate = modelQuestionLang.filter(function (r) {
16071
+ var _listLanguage$;
16072
+
16073
+ return r.text || r.lang == ((_listLanguage$ = listLanguage[0]) === null || _listLanguage$ === void 0 ? void 0 : _listLanguage$.code);
16074
+ }) || [];
16075
+
16076
+ var _temp2 = _forOf(formLanguageModelCreate, function (form) {
16077
+ return Promise.resolve(onValidate(form)).then(function (errors) {
16078
+ console.log({
16079
+ errors: errors
16080
+ });
16081
+
16082
+ if (Object.keys(errors).length > 0) {
16083
+ setActiveLanguage(form.lang);
16084
+ setErrors(_extends({}, errors));
16085
+ _exit2 = true;
16086
+ return false;
16087
+ }
16088
+ });
16089
+ }, function () {
16090
+ return _exit2;
16091
+ });
16092
+
16093
+ return Promise.resolve(_temp2 && _temp2.then ? _temp2.then(function (_result) {
16094
+ return _exit2 ? _result : true;
16095
+ }) : _exit2 ? _temp2 : true);
16096
+ } catch (e) {
16097
+ return Promise.reject(e);
16098
+ }
16099
+ };
16100
+
16004
16101
  var getTinyMCEKey = function getTinyMCEKey() {
16005
16102
  try {
16006
- var _temp3 = function _temp3() {
16103
+ var _temp5 = function _temp5() {
16007
16104
  dispatch(marioCore.setLoading(false));
16008
16105
  };
16009
16106
 
16010
16107
  dispatch(marioCore.setLoading(true));
16011
16108
 
16012
- var _temp4 = _catch(function () {
16109
+ var _temp6 = _catch(function () {
16013
16110
  return Promise.resolve(getTinyMCEKeyApi()).then(function (res) {
16014
16111
  var data = res.data;
16015
16112
 
@@ -16026,7 +16123,7 @@ var useQuestionDetail$1 = function useQuestionDetail(id, type) {
16026
16123
  }));
16027
16124
  });
16028
16125
 
16029
- return Promise.resolve(_temp4 && _temp4.then ? _temp4.then(_temp3) : _temp3(_temp4));
16126
+ return Promise.resolve(_temp6 && _temp6.then ? _temp6.then(_temp5) : _temp5(_temp6));
16030
16127
  } catch (e) {
16031
16128
  return Promise.reject(e);
16032
16129
  }
@@ -16034,13 +16131,13 @@ var useQuestionDetail$1 = function useQuestionDetail(id, type) {
16034
16131
 
16035
16132
  var getQuestionCategories = function getQuestionCategories() {
16036
16133
  try {
16037
- var _temp7 = function _temp7() {
16134
+ var _temp9 = function _temp9() {
16038
16135
  dispatch(marioCore.setLoading(false));
16039
16136
  };
16040
16137
 
16041
16138
  dispatch(marioCore.setLoading(true));
16042
16139
 
16043
- var _temp8 = _catch(function () {
16140
+ var _temp10 = _catch(function () {
16044
16141
  return Promise.resolve(get$i()).then(function (res) {
16045
16142
  var items = res.data.items;
16046
16143
  var categoryId = getMinIdCategory(items);
@@ -16057,7 +16154,7 @@ var useQuestionDetail$1 = function useQuestionDetail(id, type) {
16057
16154
  }));
16058
16155
  });
16059
16156
 
16060
- return Promise.resolve(_temp8 && _temp8.then ? _temp8.then(_temp7) : _temp7(_temp8));
16157
+ return Promise.resolve(_temp10 && _temp10.then ? _temp10.then(_temp9) : _temp9(_temp10));
16061
16158
  } catch (e) {
16062
16159
  return Promise.reject(e);
16063
16160
  }
@@ -16065,15 +16162,24 @@ var useQuestionDetail$1 = function useQuestionDetail(id, type) {
16065
16162
 
16066
16163
  var getLanguageSystems = function getLanguageSystems() {
16067
16164
  try {
16068
- var _temp11 = function _temp11() {
16165
+ var _temp13 = function _temp13() {
16069
16166
  dispatch(marioCore.setLoading(false));
16070
16167
  };
16071
16168
 
16072
16169
  dispatch(marioCore.setLoading(true));
16073
16170
 
16074
- var _temp12 = _catch(function () {
16171
+ var _temp14 = _catch(function () {
16075
16172
  return Promise.resolve(getLanguages()).then(function (res) {
16076
16173
  setListLanguage(res.data);
16174
+ var modelQuestion = res.data.map(function (r) {
16175
+ var _r$code;
16176
+
16177
+ return _extends({}, initValue$f, {
16178
+ lang: (_r$code = r.code) != null ? _r$code : "",
16179
+ isSurvey: type === TYPE_QUESTION.Default
16180
+ });
16181
+ });
16182
+ setModelQuestionLang(modelQuestion != null ? modelQuestion : []);
16077
16183
  });
16078
16184
  }, function (err) {
16079
16185
  var _err$response3, _err$response3$data;
@@ -16084,7 +16190,7 @@ var useQuestionDetail$1 = function useQuestionDetail(id, type) {
16084
16190
  }));
16085
16191
  });
16086
16192
 
16087
- return Promise.resolve(_temp12 && _temp12.then ? _temp12.then(_temp11) : _temp11(_temp12));
16193
+ return Promise.resolve(_temp14 && _temp14.then ? _temp14.then(_temp13) : _temp13(_temp14));
16088
16194
  } catch (e) {
16089
16195
  return Promise.reject(e);
16090
16196
  }
@@ -16109,13 +16215,13 @@ var useQuestionDetail$1 = function useQuestionDetail(id, type) {
16109
16215
 
16110
16216
  var getData = function getData(lang) {
16111
16217
  try {
16112
- var _temp15 = function _temp15() {
16218
+ var _temp17 = function _temp17() {
16113
16219
  dispatch(marioCore.setLoading(false));
16114
16220
  };
16115
16221
 
16116
16222
  dispatch(marioCore.setLoading(true));
16117
16223
 
16118
- var _temp16 = _catch(function () {
16224
+ var _temp18 = _catch(function () {
16119
16225
  var objLang = {
16120
16226
  lang: lang
16121
16227
  };
@@ -16146,7 +16252,7 @@ var useQuestionDetail$1 = function useQuestionDetail(id, type) {
16146
16252
  }));
16147
16253
  });
16148
16254
 
16149
- return Promise.resolve(_temp16 && _temp16.then ? _temp16.then(_temp15) : _temp15(_temp16));
16255
+ return Promise.resolve(_temp18 && _temp18.then ? _temp18.then(_temp17) : _temp17(_temp18));
16150
16256
  } catch (e) {
16151
16257
  return Promise.reject(e);
16152
16258
  }
@@ -16159,19 +16265,85 @@ var useQuestionDetail$1 = function useQuestionDetail(id, type) {
16159
16265
  var backToList = React.useCallback(function () {
16160
16266
  history.goBack();
16161
16267
  }, [questionDetail]);
16268
+ var handleCreateQuestion = React.useCallback(function (_data, _type) {
16269
+ try {
16270
+ var _exit4 = false;
16271
+
16272
+ var _temp22 = function _temp22(_result2) {
16273
+ if (_exit4) return _result2;
16274
+ dispatch(marioCore.setLoading(false));
16275
+ };
16276
+
16277
+ dispatch(marioCore.setLoading(true));
16278
+
16279
+ var _temp23 = _catch(function () {
16280
+ var formLanguageModelCreate = modelQuestionLang.filter(function (r) {
16281
+ var _listLanguage$2;
16282
+
16283
+ return r.text || r.lang == ((_listLanguage$2 = listLanguage[0]) === null || _listLanguage$2 === void 0 ? void 0 : _listLanguage$2.code);
16284
+ }) || [];
16285
+ console.log({
16286
+ formLanguageModelCreate: formLanguageModelCreate
16287
+ });
16288
+ console.log({
16289
+ modelQuestionLang: modelQuestionLang
16290
+ });
16291
+
16292
+ for (var _iterator = _createForOfIteratorHelperLoose(formLanguageModelCreate), _step; !(_step = _iterator()).done;) {
16293
+ var form = _step.value;
16294
+ var validator = validationChoices(form);
16295
+ if (validator.isError) throw new Error(validator.message);
16296
+ }
16297
+
16298
+ var questionCreateEng = modelQuestionLang.find(function (r) {
16299
+ var _listLanguage$3;
16300
+
16301
+ return r.lang == ((_listLanguage$3 = listLanguage[0]) === null || _listLanguage$3 === void 0 ? void 0 : _listLanguage$3.code);
16302
+ });
16303
+ if (!questionCreateEng) throw new Error("Create question fail");
16304
+ questionCreateEng = validationAnswerId(questionCreateEng);
16305
+ return Promise.resolve(create$2(questionCreateEng, type || 0)).then(function (res) {
16306
+ if (!res.data) throw new Error("Create question fail");
16307
+
16308
+ var _temp19 = _forOf(formLanguageModelCreate.filter(function (r) {
16309
+ var _listLanguage$4;
16310
+
16311
+ return r.lang != ((_listLanguage$4 = listLanguage[0]) === null || _listLanguage$4 === void 0 ? void 0 : _listLanguage$4.code);
16312
+ }), function (form) {
16313
+ form.id = res.data.id;
16314
+ form = validationAnswerId(form);
16315
+ return Promise.resolve(update$2(form, type || 0)).then(function () {});
16316
+ });
16317
+
16318
+ if (_temp19 && _temp19.then) return _temp19.then(function () {});
16319
+ });
16320
+ }, function (err) {
16321
+ var _err$response5, _err$response5$data;
16322
+
16323
+ dispatch(marioCore.setAlert({
16324
+ type: "danger",
16325
+ message: ((_err$response5 = err.response) === null || _err$response5 === void 0 ? void 0 : (_err$response5$data = _err$response5.data) === null || _err$response5$data === void 0 ? void 0 : _err$response5$data.title) || err.message
16326
+ }));
16327
+ });
16328
+
16329
+ return Promise.resolve(_temp23 && _temp23.then ? _temp23.then(_temp22) : _temp22(_temp23));
16330
+ } catch (e) {
16331
+ return Promise.reject(e);
16332
+ }
16333
+ }, [modelQuestionLang]);
16162
16334
  var confirmData = React.useCallback(function (data) {
16163
16335
  try {
16164
- var _exit2 = false;
16336
+ var _exit6 = false;
16165
16337
 
16166
- var _temp19 = function _temp19(_result) {
16167
- if (_exit2) return _result;
16338
+ var _temp26 = function _temp26(_result3) {
16339
+ if (_exit6) return _result3;
16168
16340
  dispatch(marioCore.setLoading(false));
16169
16341
  };
16170
16342
 
16171
16343
  dispatch(marioCore.setLoading(true));
16172
16344
 
16173
- var _temp20 = _catch(function () {
16174
- var next = !!id ? update$2 : create$2;
16345
+ var _temp27 = _catch(function () {
16346
+ var next = !!id ? update$2 : handleCreateQuestion;
16175
16347
  var validator = validationChoices(data);
16176
16348
  if (validator.isError) throw new Error(validator.message);
16177
16349
  data.lang = activeLanguage;
@@ -16184,28 +16356,28 @@ var useQuestionDetail$1 = function useQuestionDetail(id, type) {
16184
16356
  !id && backToList();
16185
16357
  });
16186
16358
  }, function (err) {
16187
- var _err$response5, _err$response5$data;
16359
+ var _err$response6, _err$response6$data;
16188
16360
 
16189
16361
  dispatch(marioCore.setAlert({
16190
16362
  type: "danger",
16191
- message: ((_err$response5 = err.response) === null || _err$response5 === void 0 ? void 0 : (_err$response5$data = _err$response5.data) === null || _err$response5$data === void 0 ? void 0 : _err$response5$data.title) || err.message
16363
+ message: ((_err$response6 = err.response) === null || _err$response6 === void 0 ? void 0 : (_err$response6$data = _err$response6.data) === null || _err$response6$data === void 0 ? void 0 : _err$response6$data.title) || err.message
16192
16364
  }));
16193
16365
  });
16194
16366
 
16195
- return Promise.resolve(_temp20 && _temp20.then ? _temp20.then(_temp19) : _temp19(_temp20));
16367
+ return Promise.resolve(_temp27 && _temp27.then ? _temp27.then(_temp26) : _temp26(_temp27));
16196
16368
  } catch (e) {
16197
16369
  return Promise.reject(e);
16198
16370
  }
16199
- }, [id, activeLanguage]);
16371
+ }, [id, activeLanguage, modelQuestionLang]);
16200
16372
  var handleGetLabelQuestions = React.useCallback(function (questionType) {
16201
16373
  try {
16202
- var _temp23 = function _temp23() {
16374
+ var _temp30 = function _temp30() {
16203
16375
  dispatch(marioCore.setLoading(false));
16204
16376
  };
16205
16377
 
16206
16378
  dispatch(marioCore.setLoading(true));
16207
16379
 
16208
- var _temp24 = _catch(function () {
16380
+ var _temp31 = _catch(function () {
16209
16381
  return Promise.resolve(getLabelQuestions({
16210
16382
  isDefaultSurvey: true,
16211
16383
  questionType: questionType
@@ -16213,15 +16385,15 @@ var useQuestionDetail$1 = function useQuestionDetail(id, type) {
16213
16385
  setLabelQuestions(res.data);
16214
16386
  });
16215
16387
  }, function (err) {
16216
- var _err$response6, _err$response6$data;
16388
+ var _err$response7, _err$response7$data;
16217
16389
 
16218
16390
  dispatch(marioCore.setAlert({
16219
16391
  type: "danger",
16220
- message: ((_err$response6 = err.response) === null || _err$response6 === void 0 ? void 0 : (_err$response6$data = _err$response6.data) === null || _err$response6$data === void 0 ? void 0 : _err$response6$data.title) || err.message
16392
+ message: ((_err$response7 = err.response) === null || _err$response7 === void 0 ? void 0 : (_err$response7$data = _err$response7.data) === null || _err$response7$data === void 0 ? void 0 : _err$response7$data.title) || err.message
16221
16393
  }));
16222
16394
  });
16223
16395
 
16224
- return Promise.resolve(_temp24 && _temp24.then ? _temp24.then(_temp23) : _temp23(_temp24));
16396
+ return Promise.resolve(_temp31 && _temp31.then ? _temp31.then(_temp30) : _temp30(_temp31));
16225
16397
  } catch (e) {
16226
16398
  return Promise.reject(e);
16227
16399
  }
@@ -16242,7 +16414,10 @@ var useQuestionDetail$1 = function useQuestionDetail(id, type) {
16242
16414
  tinyMCEKey: tinyMCEKey,
16243
16415
  listLanguage: listLanguage,
16244
16416
  activeLanguage: activeLanguage,
16245
- onChangeLanguage: onChangeLanguage
16417
+ onChangeLanguage: onChangeLanguage,
16418
+ modelQuestionLang: modelQuestionLang,
16419
+ setModelQuestionLang: setModelQuestionLang,
16420
+ handleValidateForm: handleValidateForm
16246
16421
  };
16247
16422
  };
16248
16423
 
@@ -16323,16 +16498,19 @@ var QuestionDetail = function QuestionDetail() {
16323
16498
  tinyMCEKey = _useQuestionDetail.tinyMCEKey,
16324
16499
  listLanguage = _useQuestionDetail.listLanguage,
16325
16500
  activeLanguage = _useQuestionDetail.activeLanguage,
16326
- onChangeLanguage = _useQuestionDetail.onChangeLanguage;
16501
+ onChangeLanguage = _useQuestionDetail.onChangeLanguage,
16502
+ modelQuestionLang = _useQuestionDetail.modelQuestionLang,
16503
+ setModelQuestionLang = _useQuestionDetail.setModelQuestionLang,
16504
+ handleValidateForm = _useQuestionDetail.handleValidateForm;
16327
16505
 
16328
16506
  var TINY_MCE_API_KEY = "ebwt07xgrus9j0kd8gq1k89muft26xih8aivb0ridjv7c216";
16329
16507
  var header = !!id ? t(EDIT_QUESTION_HEADER) : t(CREATE_QUESTION_HEADER);
16330
16508
  var confirmText = !!id ? t("update") : t("create");
16331
16509
  var additionalFields = ["fromLabel", "toLabel", "numberOfStars"];
16332
- console.log({
16333
- tinyMCEKey: tinyMCEKey
16510
+ var activeModelLanguage = modelQuestionLang.find(function (r) {
16511
+ return r.lang == activeLanguage;
16334
16512
  });
16335
- return React__default.createElement(React__default.Fragment, null, !!id && React__default.createElement(reactstrap.Nav, {
16513
+ return React__default.createElement(React__default.Fragment, null, React__default.createElement(reactstrap.Nav, {
16336
16514
  tabs: true,
16337
16515
  className: "mb-3"
16338
16516
  }, listLanguage && listLanguage.length > 0 && listLanguage.map(function (item) {
@@ -16343,7 +16521,8 @@ var QuestionDetail = function QuestionDetail() {
16343
16521
  }
16344
16522
  }, item.name));
16345
16523
  })), React__default.createElement(formik.Formik, {
16346
- initialValues: questionDetail,
16524
+ key: activeLanguage,
16525
+ initialValues: !id && !!activeModelLanguage ? activeModelLanguage : questionDetail,
16347
16526
  enableReinitialize: true,
16348
16527
  validationSchema: schema$a,
16349
16528
  onSubmit: function onSubmit(values) {
@@ -16362,7 +16541,9 @@ var QuestionDetail = function QuestionDetail() {
16362
16541
  touched = formikProps.touched,
16363
16542
  errors = formikProps.errors,
16364
16543
  setFieldValue = formikProps.setFieldValue,
16365
- handleSubmit = formikProps.handleSubmit;
16544
+ handleSubmit = formikProps.handleSubmit,
16545
+ validateForm = formikProps.validateForm,
16546
+ setErrors = formikProps.setErrors;
16366
16547
 
16367
16548
  var onChangeQuestionType = function onChangeQuestionType(e) {
16368
16549
  if (![marioCore.QUESTION_TYPES.EMOTIONAL, marioCore.QUESTION_TYPES.LEARNING_STRATEGY, marioCore.QUESTION_TYPES.RATING, marioCore.QUESTION_TYPES.SUMMARIZE, marioCore.QUESTION_TYPES.TEXT_INPUT, marioCore.QUESTION_TYPES.DROPDOWN].includes(e.value)) {
@@ -16394,6 +16575,24 @@ var QuestionDetail = function QuestionDetail() {
16394
16575
  setEditedTrue();
16395
16576
  };
16396
16577
 
16578
+ React.useEffect(function () {
16579
+ if (!id && !!activeModelLanguage && activeModelLanguage.lang == activeLanguage && (activeModelLanguage.answers != values.answers || activeModelLanguage.text != values.text || activeModelLanguage.type != values.type || activeModelLanguage.fromLabel != values.fromLabel || activeModelLanguage.toLabel != values.toLabel)) {
16580
+ var categoryId = values.categoryId != 0 ? values.categoryId : questionDetail.categoryId;
16581
+ var updatedModelQuestionLang = modelQuestionLang.map(function (item) {
16582
+ return item.lang === activeLanguage ? _extends({}, item, values, {
16583
+ categoryId: categoryId
16584
+ }) : _extends({}, item, {
16585
+ type: values.type,
16586
+ categoryId: categoryId,
16587
+ isMandatory: values.isMandatory,
16588
+ isQuestionIntervention: values.isQuestionIntervention,
16589
+ isBeforeSession: values.isBeforeSession,
16590
+ userForQuestion: values.userForQuestion
16591
+ });
16592
+ });
16593
+ setModelQuestionLang(updatedModelQuestionLang);
16594
+ }
16595
+ }, [values, id, activeModelLanguage, modelQuestionLang, activeLanguage]);
16397
16596
  return React__default.createElement("div", {
16398
16597
  className: "animated fadeIn detail-buttons-padding"
16399
16598
  }, React__default.createElement(marioCore.QuitPrompt, {
@@ -16442,9 +16641,9 @@ var QuestionDetail = function QuestionDetail() {
16442
16641
  className: styles["form-question-text"] + " mb-2"
16443
16642
  }, React__default.createElement(marioCore.RequiredLabel, {
16444
16643
  text: t("question_text")
16445
- }), (questionDetail.text || !id) && !!tinyMCEKey && React__default.createElement(tinymceReact.Editor, {
16644
+ }), (values.text || !id) && !!tinyMCEKey && React__default.createElement(tinymceReact.Editor, {
16446
16645
  apiKey: tinyMCEKey || TINY_MCE_API_KEY,
16447
- value: questionDetail.text,
16646
+ value: values.text,
16448
16647
  init: _extends({}, marioCore.editorConfig.question, {
16449
16648
  paste_preprocess: function paste_preprocess(_plugin, args) {
16450
16649
  args.content = args.content.replace(/<\/?(?!b\b|p\b)[^>]+>/g, "");
@@ -16507,7 +16706,29 @@ var QuestionDetail = function QuestionDetail() {
16507
16706
  }) : null;
16508
16707
  }), React__default.createElement(marioCore.DetailActionButtons, {
16509
16708
  confirmText: confirmText,
16510
- onConfirm: handleSubmit,
16709
+ onConfirm: function () {
16710
+ try {
16711
+ var _exit2 = false;
16712
+
16713
+ var _temp3 = function _temp3(_result) {
16714
+ if (_exit2) return _result;
16715
+ handleSubmit();
16716
+ };
16717
+
16718
+ var _temp4 = function () {
16719
+ if (!id) {
16720
+ return Promise.resolve(handleValidateForm(validateForm, setErrors)).then(function (isPass) {
16721
+ if (isPass) handleSubmit();
16722
+ _exit2 = true;
16723
+ });
16724
+ }
16725
+ }();
16726
+
16727
+ return Promise.resolve(_temp4 && _temp4.then ? _temp4.then(_temp3) : _temp3(_temp4));
16728
+ } catch (e) {
16729
+ return Promise.reject(e);
16730
+ }
16731
+ },
16511
16732
  onCancel: backToList
16512
16733
  }));
16513
16734
  }));
@@ -34054,7 +34275,7 @@ var StudentPressureChart = function StudentPressureChart(_ref) {
34054
34275
  var tooltipHeight = ((_data3 = data[i - 1]) === null || _data3 === void 0 ? void 0 : _data3.value.length) * lineHeight;
34055
34276
  var widthLabel = 69;
34056
34277
  var isScrollStudents = tooltipHeight + 30 > chartHeight - 100 - (isMobileScreen ? widthLabel : 0);
34057
- if (isScrollStudents) circle.addEventListener("click", handleDotLeave);else circle.addEventListener("mouseleave", handleDotLeave);
34278
+ if (isScrollStudents) circle.addEventListener("click", handleDotLeave);
34058
34279
  svg.appendChild(circle);
34059
34280
  var text = document.createElementNS("http://www.w3.org/2000/svg", "text");
34060
34281
  text.setAttribute("x", "" + circleX);
@@ -34071,7 +34292,7 @@ var StudentPressureChart = function StudentPressureChart(_ref) {
34071
34292
 
34072
34293
  handleDotHover((_data5 = data[i - 1]) === null || _data5 === void 0 ? void 0 : _data5.value, circleX, circleY, (_data6 = data[i - 1]) === null || _data6 === void 0 ? void 0 : _data6.label, colors[i - 1]);
34073
34294
  });
34074
- if (isScrollStudents) text.addEventListener("click", handleDotLeave);else text.addEventListener("mouseleave", handleDotLeave);
34295
+ if (isScrollStudents) text.addEventListener("click", handleDotLeave);
34075
34296
  svg.appendChild(text);
34076
34297
  var label = t((_data7 = data[i - 1]) === null || _data7 === void 0 ? void 0 : _data7.label).toUpperCase();
34077
34298
  var tooltip = t((_data8 = data[i - 1]) === null || _data8 === void 0 ? void 0 : _data8.tooltip);
@@ -34146,11 +34367,27 @@ var StudentPressureChart = function StudentPressureChart(_ref) {
34146
34367
  var isScrollStudents = tooltipHeight + 30 > chartHeight - 100 - (isMobileScreen ? widthLabel : 0);
34147
34368
  var maxHeightTooltip = isScrollStudents ? chartHeight - 100 - (isMobileScreen ? widthLabel : 0) : tooltipHeight + 30;
34148
34369
  var heightInfoTooltip = 64;
34370
+ var tooltipRef = React.useRef(null);
34371
+ React.useEffect(function () {
34372
+ var handleClickOutside = function handleClickOutside(event) {
34373
+ var _tooltipRef$current;
34374
+
34375
+ if (tooltipRef.current && !((_tooltipRef$current = tooltipRef.current) !== null && _tooltipRef$current !== void 0 && _tooltipRef$current.contains(event.target))) {
34376
+ handleDotLeave();
34377
+ }
34378
+ };
34379
+
34380
+ document.addEventListener("mousedown", handleClickOutside);
34381
+ return function () {
34382
+ document.removeEventListener("mousedown", handleClickOutside);
34383
+ };
34384
+ }, []);
34149
34385
  return React__default.createElement("svg", {
34150
34386
  ref: svgRef,
34151
34387
  width: chartWidth,
34152
34388
  height: chartHeight + 50
34153
34389
  }, !!tooltipVisible && React__default.createElement("g", {
34390
+ ref: tooltipRef,
34154
34391
  transform: "translate(" + (infoTooltip ? tooltipX - 81 : tooltipX - 100) + "," + Math.max(0, infoTooltip ? tooltipY - heightInfoTooltip - 30 : isMobileScreen ? tooltipY - tooltipHeight - 100 - widthLabel : tooltipY - tooltipHeight - 100) + ")"
34155
34392
  }, React__default.createElement("rect", {
34156
34393
  width: infoTooltip ? 162 : 200,