touchstudy-core 0.1.10 → 0.1.11
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.
- package/dist/components/Chats/ChatHeader.d.ts +1 -0
- package/dist/components/Chats/hooks/useChatContainer.d.ts +1 -0
- package/dist/components/Dialogs/ConfirmDialog.d.ts +1 -0
- package/dist/components/Selects/CustomAsyncSelect.d.ts +3 -0
- package/dist/components/Selects/CustomCreatable.d.ts +3 -0
- package/dist/components/Selects/CustomSelect.d.ts +1 -1
- package/dist/containers/Exams/components/ArticleGroupView.d.ts +19 -0
- package/dist/containers/Exams/components/QuestionView.d.ts +11 -0
- package/dist/containers/Exams/configs/constants.d.ts +8 -0
- package/dist/containers/Exams/configs/interfaces.d.ts +9 -0
- package/dist/containers/Exams/configs/types.d.ts +21 -0
- package/dist/containers/Exams/hooks/useExamDetailView.d.ts +23 -0
- package/dist/containers/Exams/views/ExamDetailView.d.ts +4 -0
- package/dist/containers/Login/configs/constants.d.ts +5 -0
- package/dist/containers/Login/views/Login.d.ts +2 -1
- package/dist/containers/Login/views/block/BlockLogin.d.ts +2 -1
- package/dist/index.css +38 -0
- package/dist/index.d.ts +11 -1
- package/dist/index.js +825 -41
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +810 -42
- package/dist/index.modern.js.map +1 -1
- package/dist/utils/useLanguage.d.ts +10 -0
- package/package.json +3 -1
- package/dist/services/api.d.ts +0 -3
package/dist/index.modern.js
CHANGED
@@ -1,8 +1,9 @@
|
|
1
1
|
import { createBrowserHistory } from 'history';
|
2
2
|
import { createAction, createReducer, configureStore } from '@reduxjs/toolkit';
|
3
3
|
import moment from 'moment';
|
4
|
+
export { default as moment } from 'moment';
|
4
5
|
import React, { useState, useCallback, useEffect, Fragment, useRef, useMemo } from 'react';
|
5
|
-
import { Row, Col, Form, Modal, ModalHeader, ModalBody, ModalFooter, Button, Alert, Pagination, PaginationItem, PaginationLink, Dropdown, DropdownToggle, DropdownMenu, DropdownItem, Collapse, InputGroup,
|
6
|
+
import { Row, Col, Form, Modal, ModalHeader, ModalBody, Input, ModalFooter, Button, Alert, Pagination, PaginationItem, PaginationLink, Dropdown, DropdownToggle, DropdownMenu, DropdownItem, Collapse, InputGroup, Spinner, FormGroup, Label } from 'reactstrap';
|
6
7
|
import { Formik } from 'formik';
|
7
8
|
import { object, string, boolean } from 'yup';
|
8
9
|
import GoogleLogin, { useGoogleLogout } from '@leecheuk/react-google-login';
|
@@ -13,11 +14,16 @@ import i18n from 'i18next';
|
|
13
14
|
import { initReactI18next, useTranslation } from 'react-i18next';
|
14
15
|
export { I18nextProvider, useTranslation } from 'react-i18next';
|
15
16
|
import { IoChevronDown } from 'react-icons/io5';
|
16
|
-
import Select from 'react-select';
|
17
|
+
import Select, { components } from 'react-select';
|
18
|
+
import { FaCaretDown, FaPlusCircle } from 'react-icons/fa';
|
17
19
|
import { Link } from 'react-router-dom';
|
18
20
|
import { IoIosCloseCircle, IoMdSend } from 'react-icons/io';
|
19
|
-
import { ToastContainer, toast } from 'react-toastify';
|
20
21
|
import Pusher from 'pusher-js';
|
22
|
+
import { toast } from 'react-toastify';
|
23
|
+
export { ToastContainer, toast } from 'react-toastify';
|
24
|
+
import CreatableSelect from 'react-select/creatable';
|
25
|
+
import { PiDotsNineLight } from 'react-icons/pi';
|
26
|
+
import _ from 'lodash';
|
21
27
|
|
22
28
|
var setLoading = createAction("common/setLoading");
|
23
29
|
var setAlert = createAction("common/setAlert");
|
@@ -147,6 +153,12 @@ var AuthenticationMessage;
|
|
147
153
|
AuthenticationMessage["NotAllowedToRegister"] = "NotAllowedToRegister";
|
148
154
|
AuthenticationMessage["InvalidGoogleToken"] = "InvalidGoogleToken";
|
149
155
|
})(AuthenticationMessage || (AuthenticationMessage = {}));
|
156
|
+
var Role;
|
157
|
+
(function (Role) {
|
158
|
+
Role["Student"] = "Student";
|
159
|
+
Role["Teacher"] = "Teacher";
|
160
|
+
Role["Admin"] = "Admin";
|
161
|
+
})(Role || (Role = {}));
|
150
162
|
|
151
163
|
var useGoogleSignOut = function useGoogleSignOut(props) {
|
152
164
|
var dispatch = useDispatch();
|
@@ -193,7 +205,8 @@ var schema = object({
|
|
193
205
|
var BlockLogin = function BlockLogin(_ref) {
|
194
206
|
var defaultInfo = _ref.defaultInfo,
|
195
207
|
onNavigate = _ref.onNavigate,
|
196
|
-
|
208
|
+
_ref$role = _ref.role,
|
209
|
+
role = _ref$role === void 0 ? Role.Student : _ref$role;
|
197
210
|
var dispatch = useDispatch();
|
198
211
|
var _useGoogleSignOut = useGoogleSignOut({
|
199
212
|
onNavigate: onNavigate
|
@@ -219,7 +232,6 @@ var BlockLogin = function BlockLogin(_ref) {
|
|
219
232
|
token: accessToken,
|
220
233
|
googleId: googleId
|
221
234
|
};
|
222
|
-
var role = isTeacher ? "Teacher" : "Student";
|
223
235
|
dispatch(setLoading(true));
|
224
236
|
var _temp = _catch(function () {
|
225
237
|
return Promise.resolve(apiLoginGoogle(infoLogin, role)).then(function (res1) {
|
@@ -227,7 +239,7 @@ var BlockLogin = function BlockLogin(_ref) {
|
|
227
239
|
var tokenJWT = res1.data.token;
|
228
240
|
localStorage.setItem("USER_INFORMATION", JSON.stringify(infoLogin));
|
229
241
|
localStorage.setItem(ACCESS_TOKEN, tokenJWT);
|
230
|
-
if (
|
242
|
+
if (role === Role.Student && isFirstLogin) {
|
231
243
|
onNavigate("/register/info");
|
232
244
|
} else {
|
233
245
|
onNavigate("/");
|
@@ -346,7 +358,7 @@ var useLogin = function useLogin(onNavigate) {
|
|
346
358
|
|
347
359
|
var Login = function Login(_ref) {
|
348
360
|
var onNavigate = _ref.onNavigate,
|
349
|
-
|
361
|
+
role = _ref.role;
|
350
362
|
var _useLogin = useLogin(onNavigate),
|
351
363
|
defaultInfo = _useLogin.defaultInfo;
|
352
364
|
return React.createElement("div", {
|
@@ -361,7 +373,7 @@ var Login = function Login(_ref) {
|
|
361
373
|
}, React.createElement(BlockLogin, {
|
362
374
|
defaultInfo: defaultInfo,
|
363
375
|
onNavigate: onNavigate,
|
364
|
-
|
376
|
+
role: role
|
365
377
|
}))));
|
366
378
|
};
|
367
379
|
|
@@ -602,11 +614,11 @@ var NotFound = function NotFound() {
|
|
602
614
|
document.title = TITLE;
|
603
615
|
});
|
604
616
|
return React.createElement("div", {
|
605
|
-
className: "not-found"
|
617
|
+
className: "not-found d-flex justify-content-center"
|
606
618
|
}, React.createElement("div", {
|
607
|
-
className: "clearfix"
|
619
|
+
className: "clearfix pt-5"
|
608
620
|
}, React.createElement("h1", {
|
609
|
-
className: "float-left display-3 mr-4"
|
621
|
+
className: "float-left display-3 fw-bold mr-4 text-center"
|
610
622
|
}, "404"), React.createElement("div", {
|
611
623
|
className: "float-left"
|
612
624
|
}, React.createElement("h4", {
|
@@ -661,16 +673,13 @@ var LayoutContext = function LayoutContext(_ref) {
|
|
661
673
|
var _state$common;
|
662
674
|
return state === null || state === void 0 ? void 0 : (_state$common = state.common) === null || _state$common === void 0 ? void 0 : _state$common.user;
|
663
675
|
});
|
676
|
+
var roles = (user === null || user === void 0 ? void 0 : user.roles) || [];
|
664
677
|
var resetAuth = function resetAuth() {
|
665
678
|
handleSignOut();
|
666
679
|
};
|
667
680
|
var checkRoleUser = useCallback(function () {
|
668
|
-
var _user$roles, _user$roles2;
|
669
681
|
if (!user) return;
|
670
|
-
|
671
|
-
if (isAdmin && role !== "Teacher") alert(user.email + " not allow to register " + role);
|
672
|
-
if (isAdmin) return;
|
673
|
-
if (!((_user$roles2 = user.roles) !== null && _user$roles2 !== void 0 && _user$roles2.includes(role))) {
|
682
|
+
if (!roles.includes(role)) {
|
674
683
|
alert(user.email + " not allow to register " + role);
|
675
684
|
resetAuth();
|
676
685
|
}
|
@@ -723,19 +732,47 @@ var ConfirmDialog = function ConfirmDialog(_ref) {
|
|
723
732
|
_ref$title = _ref.title,
|
724
733
|
title = _ref$title === void 0 ? "Confirmation" : _ref$title,
|
725
734
|
toggle = _ref.toggle,
|
726
|
-
onConfirm = _ref.onConfirm
|
735
|
+
onConfirm = _ref.onConfirm,
|
736
|
+
confirmText = _ref.confirmText;
|
737
|
+
var _useState = useState(),
|
738
|
+
confirmTextValue = _useState[0],
|
739
|
+
setConfirmTextValue = _useState[1];
|
740
|
+
var handleConfirm = function handleConfirm() {
|
741
|
+
onConfirm();
|
742
|
+
};
|
743
|
+
var handleChangeConfirmText = function handleChangeConfirmText(e) {
|
744
|
+
setConfirmTextValue(e.target.value);
|
745
|
+
};
|
746
|
+
var handlePaste = function handlePaste(e) {
|
747
|
+
e.preventDefault();
|
748
|
+
};
|
749
|
+
useEffect(function () {
|
750
|
+
!open && setConfirmTextValue(undefined);
|
751
|
+
}, [open]);
|
752
|
+
var isValid = !!confirmText && !!confirmTextValue && confirmTextValue.trim() === confirmText.trim();
|
727
753
|
return React.createElement(Modal, {
|
728
754
|
isOpen: open,
|
729
755
|
toggle: toggle,
|
730
|
-
centered: true
|
756
|
+
centered: true,
|
757
|
+
zIndex: 1102
|
731
758
|
}, React.createElement(ModalHeader, {
|
732
759
|
toggle: toggle
|
733
|
-
}, title), React.createElement(ModalBody, null, text), React.createElement(
|
760
|
+
}, title), React.createElement(ModalBody, null, React.createElement("p", null, React.createElement("strong", null, text)), !!confirmText && React.createElement("div", null, React.createElement("p", null, "Enter \"", React.createElement("strong", null, confirmText), "\" to confirm delete"), React.createElement(Input, {
|
761
|
+
value: confirmTextValue,
|
762
|
+
onChange: handleChangeConfirmText,
|
763
|
+
placeholder: "Please enter...",
|
764
|
+
onPaste: handlePaste,
|
765
|
+
invalid: !isValid && confirmTextValue !== undefined,
|
766
|
+
valid: isValid
|
767
|
+
}))), React.createElement(ModalFooter, null, React.createElement(Button, {
|
734
768
|
color: "secondary",
|
769
|
+
className: "px-3",
|
735
770
|
onClick: toggle
|
736
771
|
}, cancelText), React.createElement(Button, {
|
737
772
|
color: isDelete ? "danger" : "primary",
|
738
|
-
|
773
|
+
className: "px-3",
|
774
|
+
disabled: !!confirmText && (confirmTextValue === null || confirmTextValue === void 0 ? void 0 : confirmTextValue.trim()) !== confirmText.trim(),
|
775
|
+
onClick: handleConfirm
|
739
776
|
}, okText)));
|
740
777
|
};
|
741
778
|
|
@@ -753,7 +790,8 @@ var CommonDialog = function CommonDialog(_ref) {
|
|
753
790
|
isOpen: open,
|
754
791
|
toggle: onClose,
|
755
792
|
centered: centered,
|
756
|
-
size: size
|
793
|
+
size: size,
|
794
|
+
zIndex: 1102
|
757
795
|
}, React.createElement(ModalHeader, {
|
758
796
|
toggle: onClose
|
759
797
|
}, title), children);
|
@@ -970,6 +1008,18 @@ var problem = "문제";
|
|
970
1008
|
var problem_solving_time = "문제풀이 시간";
|
971
1009
|
var minutes = "분";
|
972
1010
|
var correct_rate = "정확한 비율";
|
1011
|
+
var title = "시험명";
|
1012
|
+
var duration = "시험 시간";
|
1013
|
+
var answer_count = "답변 수";
|
1014
|
+
var question_count = "문제 갯수";
|
1015
|
+
var category = "문항 카테고리";
|
1016
|
+
var save_and_exit = "저장 및 종료";
|
1017
|
+
var update_exam = "시험 업데이트";
|
1018
|
+
var create_exam = "새 시험 만들기";
|
1019
|
+
var enter_title = "시험 제목을 입력하세요";
|
1020
|
+
var select_placeholder = "선택하다...";
|
1021
|
+
var view_exam = "시험 보기";
|
1022
|
+
var back = "뒤쪽에";
|
973
1023
|
var lang_ko = {
|
974
1024
|
problem_solving: problem_solving,
|
975
1025
|
my_story: my_story,
|
@@ -1027,7 +1077,19 @@ var lang_ko = {
|
|
1027
1077
|
problem: problem,
|
1028
1078
|
problem_solving_time: problem_solving_time,
|
1029
1079
|
minutes: minutes,
|
1030
|
-
correct_rate: correct_rate
|
1080
|
+
correct_rate: correct_rate,
|
1081
|
+
title: title,
|
1082
|
+
duration: duration,
|
1083
|
+
answer_count: answer_count,
|
1084
|
+
question_count: question_count,
|
1085
|
+
category: category,
|
1086
|
+
save_and_exit: save_and_exit,
|
1087
|
+
update_exam: update_exam,
|
1088
|
+
create_exam: create_exam,
|
1089
|
+
enter_title: enter_title,
|
1090
|
+
select_placeholder: select_placeholder,
|
1091
|
+
view_exam: view_exam,
|
1092
|
+
back: back
|
1031
1093
|
};
|
1032
1094
|
|
1033
1095
|
var problem_solving$1 = "Problem Solving";
|
@@ -1087,6 +1149,58 @@ var problem$1 = "Problem ";
|
|
1087
1149
|
var problem_solving_time$1 = "Problem solving time";
|
1088
1150
|
var minutes$1 = "m";
|
1089
1151
|
var correct_rate$1 = "Correct rate";
|
1152
|
+
var difficult_level = "Difficult level";
|
1153
|
+
var difficulty_explain = "(The Difficulty Level provides an indication of the difficulty level of each test question)";
|
1154
|
+
var explain_your_answer = "Explain your answer";
|
1155
|
+
var hint = "Hint";
|
1156
|
+
var save_and_add_next_question = "Save and add next question";
|
1157
|
+
var save_and_exit$1 = "Save and exit";
|
1158
|
+
var question_text = "Question text";
|
1159
|
+
var title$1 = "Title";
|
1160
|
+
var create_question = "Create question";
|
1161
|
+
var parent_question = "Parent question";
|
1162
|
+
var edit_question = "Edit question";
|
1163
|
+
var easy = "Easy";
|
1164
|
+
var intermediate = "Intermediate";
|
1165
|
+
var difficult = "Difficult";
|
1166
|
+
var article = "Article";
|
1167
|
+
var correct_answer = "Correct answer";
|
1168
|
+
var mark = "Mark";
|
1169
|
+
var answer = "Answer";
|
1170
|
+
var add_new_row = "Add new row";
|
1171
|
+
var question_text_required = "Question text is required";
|
1172
|
+
var create_question_success = "Question is created successfully";
|
1173
|
+
var update_question_success = "Question is updated successfully";
|
1174
|
+
var number_of_answers = "Number of answers";
|
1175
|
+
var correct_answers = "Correct answers";
|
1176
|
+
var category$1 = "Category";
|
1177
|
+
var score = "Score";
|
1178
|
+
var enter_title$1 = "Enter title";
|
1179
|
+
var enter_score = "Enter score";
|
1180
|
+
var exam_title_required = "Exam title is required";
|
1181
|
+
var question_category_required = "Question category is required";
|
1182
|
+
var start_time = "Start time";
|
1183
|
+
var end_time = "End time";
|
1184
|
+
var enter_class_name = "Enter class name";
|
1185
|
+
var class_required = "Class name is required";
|
1186
|
+
var total_teachers = "Total teachers";
|
1187
|
+
var start_time_required = "Start time is required";
|
1188
|
+
var end_time_required = "End time is required";
|
1189
|
+
var full_name = "Full name";
|
1190
|
+
var email = "Email";
|
1191
|
+
var is_paid = "Is paid";
|
1192
|
+
var payment_time = "Payment time";
|
1193
|
+
var create_and_continue = "Create and continue";
|
1194
|
+
var payments = "Payments";
|
1195
|
+
var duration$1 = "Duration";
|
1196
|
+
var answer_count$1 = "Answer count";
|
1197
|
+
var question_count$1 = "Question count";
|
1198
|
+
var multi_choice = "Is multiple";
|
1199
|
+
var select_placeholder$1 = "Select...";
|
1200
|
+
var view_exam$1 = "View exam";
|
1201
|
+
var update_exam$1 = "Update exam";
|
1202
|
+
var create_exam$1 = "Create exam";
|
1203
|
+
var back$1 = "Back";
|
1090
1204
|
var lang_en = {
|
1091
1205
|
problem_solving: problem_solving$1,
|
1092
1206
|
my_story: my_story$1,
|
@@ -1144,7 +1258,59 @@ var lang_en = {
|
|
1144
1258
|
problem: problem$1,
|
1145
1259
|
problem_solving_time: problem_solving_time$1,
|
1146
1260
|
minutes: minutes$1,
|
1147
|
-
correct_rate: correct_rate$1
|
1261
|
+
correct_rate: correct_rate$1,
|
1262
|
+
difficult_level: difficult_level,
|
1263
|
+
difficulty_explain: difficulty_explain,
|
1264
|
+
explain_your_answer: explain_your_answer,
|
1265
|
+
hint: hint,
|
1266
|
+
save_and_add_next_question: save_and_add_next_question,
|
1267
|
+
save_and_exit: save_and_exit$1,
|
1268
|
+
question_text: question_text,
|
1269
|
+
title: title$1,
|
1270
|
+
create_question: create_question,
|
1271
|
+
parent_question: parent_question,
|
1272
|
+
edit_question: edit_question,
|
1273
|
+
easy: easy,
|
1274
|
+
intermediate: intermediate,
|
1275
|
+
difficult: difficult,
|
1276
|
+
article: article,
|
1277
|
+
correct_answer: correct_answer,
|
1278
|
+
mark: mark,
|
1279
|
+
answer: answer,
|
1280
|
+
add_new_row: add_new_row,
|
1281
|
+
question_text_required: question_text_required,
|
1282
|
+
create_question_success: create_question_success,
|
1283
|
+
update_question_success: update_question_success,
|
1284
|
+
number_of_answers: number_of_answers,
|
1285
|
+
correct_answers: correct_answers,
|
1286
|
+
category: category$1,
|
1287
|
+
score: score,
|
1288
|
+
enter_title: enter_title$1,
|
1289
|
+
enter_score: enter_score,
|
1290
|
+
exam_title_required: exam_title_required,
|
1291
|
+
question_category_required: question_category_required,
|
1292
|
+
start_time: start_time,
|
1293
|
+
end_time: end_time,
|
1294
|
+
enter_class_name: enter_class_name,
|
1295
|
+
class_required: class_required,
|
1296
|
+
total_teachers: total_teachers,
|
1297
|
+
start_time_required: start_time_required,
|
1298
|
+
end_time_required: end_time_required,
|
1299
|
+
full_name: full_name,
|
1300
|
+
email: email,
|
1301
|
+
is_paid: is_paid,
|
1302
|
+
payment_time: payment_time,
|
1303
|
+
create_and_continue: create_and_continue,
|
1304
|
+
payments: payments,
|
1305
|
+
duration: duration$1,
|
1306
|
+
answer_count: answer_count$1,
|
1307
|
+
question_count: question_count$1,
|
1308
|
+
multi_choice: multi_choice,
|
1309
|
+
select_placeholder: select_placeholder$1,
|
1310
|
+
view_exam: view_exam$1,
|
1311
|
+
update_exam: update_exam$1,
|
1312
|
+
create_exam: create_exam$1,
|
1313
|
+
back: back$1
|
1148
1314
|
};
|
1149
1315
|
|
1150
1316
|
i18n.use(initReactI18next).init({
|
@@ -1183,7 +1349,7 @@ var SUPPORTED_LANGUAGES_CODE = LANGUAGES.map(function (i) {
|
|
1183
1349
|
return i.code;
|
1184
1350
|
});
|
1185
1351
|
|
1186
|
-
var
|
1352
|
+
var useLanguage = function useLanguage() {
|
1187
1353
|
var defaultLanguage = !!localStorage.getItem("language") ? localStorage.getItem("language") : navigator.language || DEFAULT_LANGUAGE_CODE;
|
1188
1354
|
var dispatch = useDispatch();
|
1189
1355
|
var _useTranslation = useTranslation(),
|
@@ -1206,19 +1372,32 @@ var TheLanguageDropdown = function TheLanguageDropdown() {
|
|
1206
1372
|
setItemLanguage(lang);
|
1207
1373
|
dispatch(setLanguage(lang));
|
1208
1374
|
};
|
1375
|
+
useEffect(function () {
|
1376
|
+
changeLanguageApp(language);
|
1377
|
+
}, [language]);
|
1209
1378
|
var currentLanguage = useMemo(function () {
|
1210
1379
|
var currentLang = LANGUAGES.find(function (i) {
|
1211
1380
|
return i.code === language;
|
1212
1381
|
});
|
1213
1382
|
if (!currentLang) return null;
|
1214
|
-
return
|
1215
|
-
className: "mr-2 " + styles['dropdown-menu-flag'],
|
1216
|
-
src: currentLang.image
|
1217
|
-
}), " ", currentLang.shortName);
|
1218
|
-
}, [language]);
|
1219
|
-
useEffect(function () {
|
1220
|
-
changeLanguageApp(language);
|
1383
|
+
return currentLang;
|
1221
1384
|
}, [language]);
|
1385
|
+
return {
|
1386
|
+
language: language,
|
1387
|
+
dropdownOpen: dropdownOpen,
|
1388
|
+
currentLanguage: currentLanguage,
|
1389
|
+
toggle: toggle,
|
1390
|
+
setItemLanguage: setItemLanguage
|
1391
|
+
};
|
1392
|
+
};
|
1393
|
+
|
1394
|
+
var TheLanguageDropdown = function TheLanguageDropdown() {
|
1395
|
+
var _useLanguage = useLanguage(),
|
1396
|
+
currentLanguage = _useLanguage.currentLanguage,
|
1397
|
+
language = _useLanguage.language,
|
1398
|
+
dropdownOpen = _useLanguage.dropdownOpen,
|
1399
|
+
toggle = _useLanguage.toggle,
|
1400
|
+
setItemLanguage = _useLanguage.setItemLanguage;
|
1222
1401
|
return React.createElement(Dropdown, {
|
1223
1402
|
isOpen: dropdownOpen,
|
1224
1403
|
toggle: toggle,
|
@@ -1232,7 +1411,10 @@ var TheLanguageDropdown = function TheLanguageDropdown() {
|
|
1232
1411
|
display: 'flex',
|
1233
1412
|
alignItems: 'center'
|
1234
1413
|
}
|
1235
|
-
}, currentLanguage
|
1414
|
+
}, !!currentLanguage && React.createElement("img", {
|
1415
|
+
className: "mr-2 " + styles['dropdown-menu-flag'],
|
1416
|
+
src: currentLanguage.image
|
1417
|
+
}), !!currentLanguage && currentLanguage.shortName, React.createElement(IoChevronDown, {
|
1236
1418
|
className: "ml-2",
|
1237
1419
|
style: {
|
1238
1420
|
fontSize: '15px',
|
@@ -1316,14 +1498,54 @@ function _objectWithoutPropertiesLoose(source, excluded) {
|
|
1316
1498
|
return target;
|
1317
1499
|
}
|
1318
1500
|
|
1319
|
-
var _excluded = ["defaultValue", "options", "isDisabled", "scrollBottom", "value", "isMulti"];
|
1501
|
+
var _excluded = ["isDefault", "defaultValue", "options", "isDisabled", "scrollBottom", "value", "isMulti"];
|
1502
|
+
var DropdownIndicator = function DropdownIndicator(props) {
|
1503
|
+
return React.createElement(components.DropdownIndicator, Object.assign({}, props), React.createElement(FaCaretDown, {
|
1504
|
+
color: "#5458D5"
|
1505
|
+
}));
|
1506
|
+
};
|
1507
|
+
var CustomOption = function CustomOption(props) {
|
1508
|
+
return React.createElement(components.Option, Object.assign({}, props), React.createElement("div", {
|
1509
|
+
style: {
|
1510
|
+
fontSize: "14px",
|
1511
|
+
fontWeight: 500
|
1512
|
+
}
|
1513
|
+
}, props.data.label));
|
1514
|
+
};
|
1515
|
+
var customStyles = {
|
1516
|
+
control: function control(baseStyles, state) {
|
1517
|
+
return _extends({}, baseStyles, {
|
1518
|
+
fontSize: "14px",
|
1519
|
+
fontWeight: 700,
|
1520
|
+
color: "#5458D5",
|
1521
|
+
borderColor: state.isFocused ? '#5458D5' : '#C3C5FE'
|
1522
|
+
});
|
1523
|
+
},
|
1524
|
+
input: function input(baseStyles, _) {
|
1525
|
+
return _extends({}, baseStyles, {
|
1526
|
+
fontSize: "14px",
|
1527
|
+
fontWeight: 700,
|
1528
|
+
color: "#5458D5"
|
1529
|
+
});
|
1530
|
+
},
|
1531
|
+
singleValue: function singleValue(baseStyles) {
|
1532
|
+
return _extends({}, baseStyles, {
|
1533
|
+
fontSize: "14px",
|
1534
|
+
fontWeight: 700,
|
1535
|
+
color: "#5458D5"
|
1536
|
+
});
|
1537
|
+
}
|
1538
|
+
};
|
1320
1539
|
var CustomSelect = function CustomSelect(_ref) {
|
1321
|
-
var
|
1540
|
+
var isDefault = _ref.isDefault,
|
1541
|
+
options = _ref.options,
|
1322
1542
|
isDisabled = _ref.isDisabled,
|
1323
1543
|
scrollBottom = _ref.scrollBottom,
|
1324
1544
|
value = _ref.value,
|
1325
1545
|
isMulti = _ref.isMulti,
|
1326
1546
|
rest = _objectWithoutPropertiesLoose(_ref, _excluded);
|
1547
|
+
var _useTranslation = useTranslation(),
|
1548
|
+
t = _useTranslation.t;
|
1327
1549
|
var initialValues = Array.isArray(value) ? options.filter(function (i) {
|
1328
1550
|
return value.includes(i.value);
|
1329
1551
|
}) : isMulti ? options.filter(function (i) {
|
@@ -1334,9 +1556,19 @@ var CustomSelect = function CustomSelect(_ref) {
|
|
1334
1556
|
return React.createElement(Select, Object.assign({
|
1335
1557
|
isDisabled: isDisabled,
|
1336
1558
|
options: options,
|
1337
|
-
value: initialValues,
|
1559
|
+
value: !isDefault ? initialValues != null ? initialValues : null : undefined,
|
1560
|
+
defaultValue: isDefault ? initialValues : undefined,
|
1338
1561
|
menuPlacement: scrollBottom ? "top" : "auto",
|
1339
|
-
isMulti: isMulti
|
1562
|
+
isMulti: isMulti,
|
1563
|
+
components: {
|
1564
|
+
IndicatorSeparator: function IndicatorSeparator() {
|
1565
|
+
return null;
|
1566
|
+
},
|
1567
|
+
DropdownIndicator: DropdownIndicator,
|
1568
|
+
Option: CustomOption
|
1569
|
+
},
|
1570
|
+
styles: customStyles,
|
1571
|
+
placeholder: t("select_placeholder")
|
1340
1572
|
}, rest));
|
1341
1573
|
};
|
1342
1574
|
|
@@ -1688,6 +1920,7 @@ var ChatHeader = function ChatHeader(_ref) {
|
|
1688
1920
|
var name = _ref.name,
|
1689
1921
|
avatar = _ref.avatar,
|
1690
1922
|
options = _ref.options,
|
1923
|
+
selectedOption = _ref.selectedOption,
|
1691
1924
|
onChangeOption = _ref.onChangeOption;
|
1692
1925
|
var wrapperRef = useRef(null);
|
1693
1926
|
var actionRef = useRef(null);
|
@@ -1726,6 +1959,7 @@ var ChatHeader = function ChatHeader(_ref) {
|
|
1726
1959
|
}, selectOptions !== undefined && React.createElement("div", {
|
1727
1960
|
className: styles$1["header__select"] + " mx-3"
|
1728
1961
|
}, React.createElement(CustomSelect, {
|
1962
|
+
value: selectedOption,
|
1729
1963
|
options: selectOptions,
|
1730
1964
|
onChange: handleChangeOption,
|
1731
1965
|
isClearable: true
|
@@ -1843,7 +2077,7 @@ var ChatContainer = function ChatContainer(_ref) {
|
|
1843
2077
|
onAddExamMessage: handleAddExamMessage
|
1844
2078
|
}))), React.createElement("div", null, React.createElement(InputChat, Object.assign({}, inputProps, {
|
1845
2079
|
inputRef: inputRef
|
1846
|
-
})))
|
2080
|
+
}))));
|
1847
2081
|
};
|
1848
2082
|
|
1849
2083
|
var CONVERSATION_URL = BASE_URL + "/api/conversation";
|
@@ -1960,13 +2194,14 @@ var useMessageList = function useMessageList(userId, getListExamOptions) {
|
|
1960
2194
|
examId: !examId ? messageFilter.examId : examId
|
1961
2195
|
});
|
1962
2196
|
return Promise.resolve(getMessagesByConversation(conversationId, filter)).then(function (res) {
|
2197
|
+
var _res$data$items2;
|
1963
2198
|
function _temp(_getListExamOptions) {
|
1964
2199
|
_getListExamOptions;
|
1965
2200
|
}
|
1966
|
-
setMessages(function (state) {
|
2201
|
+
if (messageFilter.beforeDate) setMessages(function (state) {
|
1967
2202
|
var _res$data$items;
|
1968
2203
|
return [].concat(((_res$data$items = res.data.items) === null || _res$data$items === void 0 ? void 0 : _res$data$items.reverse()) || [], state);
|
1969
|
-
});
|
2204
|
+
});else setMessages((_res$data$items2 = res.data.items) === null || _res$data$items2 === void 0 ? void 0 : _res$data$items2.reverse());
|
1970
2205
|
return getListExamOptions ? Promise.resolve(!!getListExamOptions && getListExamOptions(userId)).then(_temp) : _temp(!!getListExamOptions && getListExamOptions(userId));
|
1971
2206
|
});
|
1972
2207
|
}, function (error) {
|
@@ -2398,6 +2633,7 @@ var useChatContainer = function useChatContainer(props) {
|
|
2398
2633
|
name: userName,
|
2399
2634
|
avatar: userAvatar,
|
2400
2635
|
options: exams,
|
2636
|
+
selectedOption: messageFilter.examId,
|
2401
2637
|
onChangeOption: handleFilterExam
|
2402
2638
|
},
|
2403
2639
|
chatListProps: {
|
@@ -2563,9 +2799,12 @@ var useConversationList = function useConversationList() {
|
|
2563
2799
|
return i.id === lastMessage.conversationId;
|
2564
2800
|
});
|
2565
2801
|
if (updateIndex < 0) return state;
|
2566
|
-
|
2802
|
+
console.log({
|
2567
2803
|
lastMessage: lastMessage
|
2568
|
-
})
|
2804
|
+
});
|
2805
|
+
return [_extends({}, state[updateIndex], {
|
2806
|
+
lastMessage: lastMessage
|
2807
|
+
})].concat(state.slice(0, updateIndex), state.slice(updateIndex + 1));
|
2569
2808
|
});
|
2570
2809
|
};
|
2571
2810
|
var handleCreateConversationSuccess = function handleCreateConversationSuccess(id) {
|
@@ -2654,7 +2893,536 @@ var usePusherConversation = function usePusherConversation(onNewMessageConversat
|
|
2654
2893
|
return {};
|
2655
2894
|
};
|
2656
2895
|
|
2896
|
+
var _excluded$1 = ["defaultValue", "options", "isDisabled", "scrollBottom", "value", "isMulti"];
|
2897
|
+
var CustomCreatable = function CustomCreatable(_ref) {
|
2898
|
+
var options = _ref.options,
|
2899
|
+
isDisabled = _ref.isDisabled,
|
2900
|
+
scrollBottom = _ref.scrollBottom,
|
2901
|
+
value = _ref.value,
|
2902
|
+
isMulti = _ref.isMulti,
|
2903
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded$1);
|
2904
|
+
var initialValues = Array.isArray(value) ? options.filter(function (i) {
|
2905
|
+
return value.includes(i.value);
|
2906
|
+
}) : isMulti ? options.filter(function (i) {
|
2907
|
+
return i.value == value;
|
2908
|
+
}) : options.find(function (i) {
|
2909
|
+
return i.value == value;
|
2910
|
+
});
|
2911
|
+
return React.createElement(CreatableSelect, Object.assign({
|
2912
|
+
isClearable: true,
|
2913
|
+
isDisabled: isDisabled,
|
2914
|
+
options: options,
|
2915
|
+
value: initialValues,
|
2916
|
+
menuPlacement: scrollBottom ? "top" : "auto",
|
2917
|
+
isMulti: isMulti
|
2918
|
+
}, rest));
|
2919
|
+
};
|
2920
|
+
|
2921
|
+
var _excluded$2 = ["isDefault", "defaultValue", "options", "isDisabled", "scrollBottom", "value", "isMulti"];
|
2922
|
+
var CustomAsyncSelect = function CustomAsyncSelect(_ref) {
|
2923
|
+
var isDefault = _ref.isDefault,
|
2924
|
+
options = _ref.options,
|
2925
|
+
isDisabled = _ref.isDisabled,
|
2926
|
+
scrollBottom = _ref.scrollBottom,
|
2927
|
+
value = _ref.value,
|
2928
|
+
isMulti = _ref.isMulti,
|
2929
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded$2);
|
2930
|
+
var initialValues = Array.isArray(value) ? options.filter(function (i) {
|
2931
|
+
return value.includes(i.value);
|
2932
|
+
}) : isMulti ? options.filter(function (i) {
|
2933
|
+
return i.value == value;
|
2934
|
+
}) : options.find(function (i) {
|
2935
|
+
return i.value == value;
|
2936
|
+
});
|
2937
|
+
return React.createElement(Select, Object.assign({
|
2938
|
+
isDisabled: isDisabled,
|
2939
|
+
options: options,
|
2940
|
+
value: !isDefault ? initialValues : undefined,
|
2941
|
+
defaultValue: isDefault ? initialValues : undefined,
|
2942
|
+
menuPlacement: scrollBottom ? "top" : "auto",
|
2943
|
+
isMulti: isMulti
|
2944
|
+
}, rest));
|
2945
|
+
};
|
2946
|
+
|
2947
|
+
var styles$2 = {"question":"_2uc_W","question-article":"_2p7kY","question-title":"_2tHmc","question--active":"_3IHYm","question-label":"_26ATj","question-input":"_3R8PR","question-btn":"_1VZac"};
|
2948
|
+
|
2949
|
+
var DURATION_OPTIONS = Array.from({
|
2950
|
+
length: 120
|
2951
|
+
}, function (_, i) {
|
2952
|
+
return i + 1;
|
2953
|
+
});
|
2954
|
+
var SCORE_OPTIONS = Array.from({
|
2955
|
+
length: 10
|
2956
|
+
}, function (_, i) {
|
2957
|
+
return i + 1;
|
2958
|
+
});
|
2959
|
+
var QUESTION_OPTIONS = Array.from({
|
2960
|
+
length: 40
|
2961
|
+
}, function (_, i) {
|
2962
|
+
return i + 1;
|
2963
|
+
});
|
2964
|
+
var ANSWER_OPTIONS = Array.from({
|
2965
|
+
length: 9
|
2966
|
+
}, function (_, i) {
|
2967
|
+
return i + 2;
|
2968
|
+
});
|
2969
|
+
var DEFAULT_SCORE = 2;
|
2970
|
+
var DEFAULT_ANSWER_COUNT = 5;
|
2971
|
+
|
2972
|
+
var QuestionView = function QuestionView(_ref) {
|
2973
|
+
var index = _ref.index,
|
2974
|
+
question = _ref.question,
|
2975
|
+
answerCount = _ref.answerCount,
|
2976
|
+
isDisabled = _ref.isDisabled,
|
2977
|
+
onChangeCorrectAnswers = _ref.onChangeCorrectAnswers,
|
2978
|
+
onChangeScoreAnswer = _ref.onChangeScoreAnswer;
|
2979
|
+
var scoreOptions = SCORE_OPTIONS.map(function (i) {
|
2980
|
+
return {
|
2981
|
+
label: DEFAULT_SCORE === i ? i + "\uC810 (\uAE30\uBCF8\uAC12)" : i + "\uC810",
|
2982
|
+
value: i
|
2983
|
+
};
|
2984
|
+
});
|
2985
|
+
return React.createElement("div", {
|
2986
|
+
className: "d-flex justify-content-between"
|
2987
|
+
}, React.createElement("div", {
|
2988
|
+
className: "d-flex flex-grow-1"
|
2989
|
+
}, React.createElement("div", {
|
2990
|
+
className: styles$2["question-title"] + " me-2"
|
2991
|
+
}, "\uBB38\uC81C ", question.questionOrder + 1, "\uBC88"), React.createElement("div", {
|
2992
|
+
className: "d-flex flex-grow-1"
|
2993
|
+
}, Array.from({
|
2994
|
+
length: answerCount
|
2995
|
+
}, function (_, i) {
|
2996
|
+
return i + 1;
|
2997
|
+
}).map(function (i) {
|
2998
|
+
return React.createElement(FormGroup, {
|
2999
|
+
className: "d-flex flex-column px-4"
|
3000
|
+
}, React.createElement(Label, {
|
3001
|
+
htmlFor: "answer-" + i,
|
3002
|
+
className: "" + styles$2["question-label"]
|
3003
|
+
}, i, "\uBC88"), React.createElement(Input, {
|
3004
|
+
id: "answer-" + i,
|
3005
|
+
type: "radio",
|
3006
|
+
checked: question.correctAnswers.includes(i),
|
3007
|
+
onClick: function onClick() {
|
3008
|
+
return onChangeCorrectAnswers(i, index);
|
3009
|
+
},
|
3010
|
+
disabled: isDisabled
|
3011
|
+
}));
|
3012
|
+
}))), React.createElement("div", {
|
3013
|
+
className: "d-flex align-items-center"
|
3014
|
+
}, React.createElement(FormGroup, {
|
3015
|
+
className: "mx-3",
|
3016
|
+
style: {
|
3017
|
+
width: "140px"
|
3018
|
+
}
|
3019
|
+
}, React.createElement(CustomSelect, {
|
3020
|
+
value: question.score,
|
3021
|
+
options: scoreOptions,
|
3022
|
+
onChange: function onChange(value) {
|
3023
|
+
return onChangeScoreAnswer(value.value, index);
|
3024
|
+
},
|
3025
|
+
isDisabled: isDisabled
|
3026
|
+
}))));
|
3027
|
+
};
|
3028
|
+
|
3029
|
+
var ArticleGroupView = function ArticleGroupView(_ref) {
|
3030
|
+
var categoryOptions = _ref.categoryOptions,
|
3031
|
+
article = _ref.article,
|
3032
|
+
questions = _ref.questions,
|
3033
|
+
answerCount = _ref.answerCount,
|
3034
|
+
questionCount = _ref.questionCount,
|
3035
|
+
categoryId = _ref.categoryId,
|
3036
|
+
isActive = _ref.isActive,
|
3037
|
+
isDisabled = _ref.isDisabled,
|
3038
|
+
onChangeQuestionCount = _ref.onChangeQuestionCount,
|
3039
|
+
onChangeCategory = _ref.onChangeCategory,
|
3040
|
+
onChangeAnswerCount = _ref.onChangeAnswerCount,
|
3041
|
+
onChangeCorrectAnswers = _ref.onChangeCorrectAnswers,
|
3042
|
+
onChangeScoreAnswer = _ref.onChangeScoreAnswer;
|
3043
|
+
var _useTranslation = useTranslation(),
|
3044
|
+
t = _useTranslation.t;
|
3045
|
+
var handleChangeQuestionCount = function handleChangeQuestionCount(value) {
|
3046
|
+
onChangeQuestionCount(article, value === null || value === void 0 ? void 0 : value.value, answerCount);
|
3047
|
+
};
|
3048
|
+
var handleChangeCategory = function handleChangeCategory(value) {
|
3049
|
+
onChangeCategory(article, value === null || value === void 0 ? void 0 : value.value);
|
3050
|
+
};
|
3051
|
+
var handleChangeAnswerCount = function handleChangeAnswerCount(value) {
|
3052
|
+
onChangeAnswerCount(article, value === null || value === void 0 ? void 0 : value.value, answerCount);
|
3053
|
+
};
|
3054
|
+
var handleChangeCorrectAnswers = function handleChangeCorrectAnswers(value, index) {
|
3055
|
+
onChangeCorrectAnswers(article, index, value);
|
3056
|
+
};
|
3057
|
+
var handleChangeScoreAnswer = function handleChangeScoreAnswer(value, index) {
|
3058
|
+
onChangeScoreAnswer(article, index, value);
|
3059
|
+
};
|
3060
|
+
var questionOptions = QUESTION_OPTIONS.map(function (i) {
|
3061
|
+
return {
|
3062
|
+
label: i + "\uAC1C",
|
3063
|
+
value: i
|
3064
|
+
};
|
3065
|
+
});
|
3066
|
+
var answerOptions = ANSWER_OPTIONS.map(function (i) {
|
3067
|
+
return {
|
3068
|
+
label: i + "\uBC88",
|
3069
|
+
value: i
|
3070
|
+
};
|
3071
|
+
});
|
3072
|
+
return React.createElement("div", {
|
3073
|
+
className: "d-flex " + styles$2["question"] + " " + (isActive ? styles$2["question--active"] : "")
|
3074
|
+
}, React.createElement("div", {
|
3075
|
+
className: "py-1"
|
3076
|
+
}, React.createElement(PiDotsNineLight, {
|
3077
|
+
size: 18
|
3078
|
+
})), React.createElement("div", {
|
3079
|
+
className: "px-4"
|
3080
|
+
}, React.createElement(Row, null, React.createElement(Col, {
|
3081
|
+
xs: 12
|
3082
|
+
}, React.createElement("p", {
|
3083
|
+
className: "mb-0 " + styles$2["question-article"]
|
3084
|
+
}, "\uBB38\uD56D"), React.createElement("p", {
|
3085
|
+
className: "text-center " + styles$2["question-article"]
|
3086
|
+
}, article)))), React.createElement("div", {
|
3087
|
+
className: "flex-grow-1"
|
3088
|
+
}, React.createElement(Row, null, React.createElement(Col, {
|
3089
|
+
xs: 3
|
3090
|
+
}, React.createElement(FormGroup, null, React.createElement(Label, {
|
3091
|
+
htmlFor: "question_count",
|
3092
|
+
className: "" + styles$2["question-label"]
|
3093
|
+
}, t("question_count")), React.createElement(CustomSelect, {
|
3094
|
+
inputId: "question_count",
|
3095
|
+
value: questionCount,
|
3096
|
+
options: questionOptions,
|
3097
|
+
onChange: handleChangeQuestionCount,
|
3098
|
+
isDisabled: isDisabled
|
3099
|
+
}))), React.createElement(Col, {
|
3100
|
+
xs: 3
|
3101
|
+
}, React.createElement(FormGroup, null, React.createElement(Label, {
|
3102
|
+
htmlFor: "category",
|
3103
|
+
className: "" + styles$2["question-label"]
|
3104
|
+
}, t("category")), React.createElement(CustomSelect, {
|
3105
|
+
inputId: "category",
|
3106
|
+
value: categoryId,
|
3107
|
+
options: categoryOptions,
|
3108
|
+
onChange: handleChangeCategory,
|
3109
|
+
isDisabled: isDisabled
|
3110
|
+
}))), React.createElement(Col, {
|
3111
|
+
xs: 3
|
3112
|
+
}, React.createElement(FormGroup, null, React.createElement(Label, {
|
3113
|
+
htmlFor: "answer_count",
|
3114
|
+
className: "" + styles$2["question-label"]
|
3115
|
+
}, t("answer_count")), React.createElement(CustomSelect, {
|
3116
|
+
inputId: "answer_count",
|
3117
|
+
value: answerCount,
|
3118
|
+
options: answerOptions,
|
3119
|
+
onChange: handleChangeAnswerCount,
|
3120
|
+
isDisabled: isDisabled
|
3121
|
+
}))), React.createElement(Col, {
|
3122
|
+
xs: 3
|
3123
|
+
})), React.createElement("div", null, questions.map(function (q, index) {
|
3124
|
+
return React.createElement(QuestionView, {
|
3125
|
+
key: index,
|
3126
|
+
question: q,
|
3127
|
+
answerCount: answerCount,
|
3128
|
+
index: index,
|
3129
|
+
onChangeCorrectAnswers: handleChangeCorrectAnswers,
|
3130
|
+
onChangeScoreAnswer: handleChangeScoreAnswer,
|
3131
|
+
isDisabled: isDisabled
|
3132
|
+
});
|
3133
|
+
}))));
|
3134
|
+
};
|
3135
|
+
|
3136
|
+
var useExamDetailView = function useExamDetailView(props) {
|
3137
|
+
var exam = props.exam,
|
3138
|
+
onChangeExam = props.onChangeExam;
|
3139
|
+
var _useTranslation = useTranslation(),
|
3140
|
+
t = _useTranslation.t;
|
3141
|
+
var handleChangeQuestionCount = function handleChangeQuestionCount(article, questionCount, answerCount) {
|
3142
|
+
if (!exam) return;
|
3143
|
+
var examQuestions = exam.questions;
|
3144
|
+
var questions = examQuestions.filter(function (i) {
|
3145
|
+
return i.article === +article;
|
3146
|
+
});
|
3147
|
+
var prevQuestions = examQuestions.filter(function (i) {
|
3148
|
+
return i.article < +article;
|
3149
|
+
});
|
3150
|
+
var nextQuestions = examQuestions.filter(function (i) {
|
3151
|
+
return i.article > +article;
|
3152
|
+
});
|
3153
|
+
var lastOrder = questions[questions.length - 1].questionOrder;
|
3154
|
+
if (questions.length === questionCount) return;
|
3155
|
+
if (questions.length < questionCount) {
|
3156
|
+
var additionalQuestions = Array.from({
|
3157
|
+
length: questionCount - questions.length
|
3158
|
+
}).map(function (_, index) {
|
3159
|
+
var _questions$;
|
3160
|
+
return {
|
3161
|
+
article: +article,
|
3162
|
+
correctAnswers: [1],
|
3163
|
+
numberOfAnswers: answerCount,
|
3164
|
+
categoryId: (_questions$ = questions[0]) === null || _questions$ === void 0 ? void 0 : _questions$.categoryId,
|
3165
|
+
score: DEFAULT_SCORE,
|
3166
|
+
questionOrder: lastOrder + index + 1
|
3167
|
+
};
|
3168
|
+
});
|
3169
|
+
var newQuestions = [].concat(prevQuestions, questions, additionalQuestions, nextQuestions.map(function (i) {
|
3170
|
+
return _extends({}, i, {
|
3171
|
+
questionOrder: i.questionOrder + questionCount - questions.length
|
3172
|
+
});
|
3173
|
+
}));
|
3174
|
+
onChangeExam(_extends({}, exam, {
|
3175
|
+
questions: [].concat(newQuestions)
|
3176
|
+
}));
|
3177
|
+
} else {
|
3178
|
+
var remainQuestions = questions.slice(0, questionCount);
|
3179
|
+
var _newQuestions = [].concat(prevQuestions, remainQuestions, nextQuestions.map(function (i) {
|
3180
|
+
return _extends({}, i, {
|
3181
|
+
questionOrder: i.questionOrder - questions.length + questionCount
|
3182
|
+
});
|
3183
|
+
}));
|
3184
|
+
onChangeExam(_extends({}, exam, {
|
3185
|
+
questions: [].concat(_newQuestions)
|
3186
|
+
}));
|
3187
|
+
}
|
3188
|
+
};
|
3189
|
+
var handleChangeCategory = function handleChangeCategory(article, categoryId) {
|
3190
|
+
if (!exam) return;
|
3191
|
+
var examQuestions = exam.questions;
|
3192
|
+
var questions = examQuestions.filter(function (i) {
|
3193
|
+
return i.article === +article;
|
3194
|
+
});
|
3195
|
+
var otherQuestions = examQuestions.filter(function (i) {
|
3196
|
+
return i.article !== +article;
|
3197
|
+
});
|
3198
|
+
onChangeExam(_extends({}, exam, {
|
3199
|
+
questions: [].concat(otherQuestions, questions.map(function (q) {
|
3200
|
+
return _extends({}, q, {
|
3201
|
+
categoryId: categoryId
|
3202
|
+
});
|
3203
|
+
}))
|
3204
|
+
}));
|
3205
|
+
};
|
3206
|
+
var handleChangeAnswerCount = function handleChangeAnswerCount(article, newAnswerCount, answerCount) {
|
3207
|
+
if (!exam) return;
|
3208
|
+
if (newAnswerCount === answerCount) return;
|
3209
|
+
var examQuestions = exam.questions;
|
3210
|
+
var questions = examQuestions.filter(function (i) {
|
3211
|
+
return i.article === +article;
|
3212
|
+
});
|
3213
|
+
var otherQuestions = examQuestions.filter(function (i) {
|
3214
|
+
return i.article !== +article;
|
3215
|
+
});
|
3216
|
+
if (answerCount < newAnswerCount) {
|
3217
|
+
onChangeExam(_extends({}, exam, {
|
3218
|
+
questions: [].concat(otherQuestions, questions.map(function (q) {
|
3219
|
+
return _extends({}, q, {
|
3220
|
+
numberOfAnswers: newAnswerCount
|
3221
|
+
});
|
3222
|
+
}))
|
3223
|
+
}));
|
3224
|
+
} else {
|
3225
|
+
onChangeExam(_extends({}, exam, {
|
3226
|
+
questions: [].concat(otherQuestions, questions.map(function (q) {
|
3227
|
+
return _extends({}, q, {
|
3228
|
+
numberOfAnswers: newAnswerCount,
|
3229
|
+
correctAnswers: q.correctAnswers.filter(function (i) {
|
3230
|
+
return i <= newAnswerCount;
|
3231
|
+
})
|
3232
|
+
});
|
3233
|
+
}))
|
3234
|
+
}));
|
3235
|
+
}
|
3236
|
+
};
|
3237
|
+
var handleChangeCorrectAnswers = function handleChangeCorrectAnswers(article, index, answer) {
|
3238
|
+
if (!exam) return;
|
3239
|
+
var examQuestions = exam.questions;
|
3240
|
+
var questions = examQuestions.filter(function (i) {
|
3241
|
+
return i.article === +article;
|
3242
|
+
});
|
3243
|
+
var otherQuestions = examQuestions.filter(function (i) {
|
3244
|
+
return i.article !== +article;
|
3245
|
+
});
|
3246
|
+
var selectedQuestion = questions[index];
|
3247
|
+
onChangeExam(_extends({}, exam, {
|
3248
|
+
questions: [].concat(otherQuestions, questions.slice(0, index), [_extends({}, selectedQuestion, {
|
3249
|
+
correctAnswers: [answer]
|
3250
|
+
})], questions.slice(index + 1))
|
3251
|
+
}));
|
3252
|
+
};
|
3253
|
+
var handleChangeScoreAnswer = function handleChangeScoreAnswer(article, index, score) {
|
3254
|
+
if (!exam) return;
|
3255
|
+
var examQuestions = exam.questions;
|
3256
|
+
var questions = examQuestions.filter(function (i) {
|
3257
|
+
return i.article === +article;
|
3258
|
+
});
|
3259
|
+
var otherQuestions = examQuestions.filter(function (i) {
|
3260
|
+
return i.article !== +article;
|
3261
|
+
});
|
3262
|
+
var selectedQuestion = questions[index];
|
3263
|
+
if (score === selectedQuestion.score) return;
|
3264
|
+
onChangeExam(_extends({}, exam, {
|
3265
|
+
questions: [].concat(otherQuestions, questions.slice(0, index), [_extends({}, selectedQuestion, {
|
3266
|
+
score: score
|
3267
|
+
})], questions.slice(index + 1))
|
3268
|
+
}));
|
3269
|
+
};
|
3270
|
+
var handleChangeDuration = function handleChangeDuration(value) {
|
3271
|
+
if (!exam) return;
|
3272
|
+
onChangeExam(_extends({}, exam, {
|
3273
|
+
duration: value === null || value === void 0 ? void 0 : value.value
|
3274
|
+
}));
|
3275
|
+
};
|
3276
|
+
var handleChangeTitle = function handleChangeTitle(e) {
|
3277
|
+
if (!exam) return;
|
3278
|
+
onChangeExam(_extends({}, exam, {
|
3279
|
+
title: e.target.value
|
3280
|
+
}));
|
3281
|
+
};
|
3282
|
+
var handleAddArticle = function handleAddArticle() {
|
3283
|
+
var _$maxBy, _$maxBy2;
|
3284
|
+
if (!exam) return;
|
3285
|
+
var maxArticle = ((_$maxBy = _.maxBy(exam.questions, "article")) === null || _$maxBy === void 0 ? void 0 : _$maxBy.article) || 0;
|
3286
|
+
var maxOrder = ((_$maxBy2 = _.maxBy(exam.questions, "questionOrder")) === null || _$maxBy2 === void 0 ? void 0 : _$maxBy2.questionOrder) || 0;
|
3287
|
+
onChangeExam(_extends({}, exam, {
|
3288
|
+
questions: [].concat(exam.questions, [{
|
3289
|
+
article: maxArticle + 1,
|
3290
|
+
correctAnswers: [1],
|
3291
|
+
numberOfAnswers: DEFAULT_ANSWER_COUNT,
|
3292
|
+
score: DEFAULT_SCORE,
|
3293
|
+
questionOrder: maxOrder + 1
|
3294
|
+
}])
|
3295
|
+
}));
|
3296
|
+
};
|
3297
|
+
var examGroupByArticle = useMemo(function () {
|
3298
|
+
if (!exam) return [];
|
3299
|
+
var articles = [];
|
3300
|
+
var groupedArticle = _.groupBy(exam.questions, "article");
|
3301
|
+
for (var key in groupedArticle) {
|
3302
|
+
if (Object.prototype.hasOwnProperty.call(groupedArticle, key)) {
|
3303
|
+
var _questions$find, _$maxBy3;
|
3304
|
+
var questions = groupedArticle[key];
|
3305
|
+
articles.push({
|
3306
|
+
article: +key,
|
3307
|
+
categoryId: (_questions$find = questions.find(function (i) {
|
3308
|
+
return !!i.categoryId;
|
3309
|
+
})) === null || _questions$find === void 0 ? void 0 : _questions$find.categoryId,
|
3310
|
+
answerCount: ((_$maxBy3 = _.maxBy(questions, "numberOfAnswers")) === null || _$maxBy3 === void 0 ? void 0 : _$maxBy3.numberOfAnswers) || DEFAULT_ANSWER_COUNT,
|
3311
|
+
questionCount: questions.length,
|
3312
|
+
questions: questions
|
3313
|
+
});
|
3314
|
+
}
|
3315
|
+
}
|
3316
|
+
return _.sortBy(articles, "article");
|
3317
|
+
}, [JSON.stringify(exam)]);
|
3318
|
+
var durationOptions = useMemo(function () {
|
3319
|
+
var options = DURATION_OPTIONS.map(function (i) {
|
3320
|
+
return {
|
3321
|
+
label: i + "\uBD84",
|
3322
|
+
value: i
|
3323
|
+
};
|
3324
|
+
});
|
3325
|
+
if (!!exam.duration && exam.duration > DURATION_OPTIONS[DURATION_OPTIONS.length - 1]) return [].concat(options, [{
|
3326
|
+
label: exam.duration + "\uBD84",
|
3327
|
+
value: exam.duration
|
3328
|
+
}]);
|
3329
|
+
return options;
|
3330
|
+
}, [exam.duration]);
|
3331
|
+
return {
|
3332
|
+
t: t,
|
3333
|
+
durationOptions: durationOptions,
|
3334
|
+
examGroupByArticle: examGroupByArticle,
|
3335
|
+
handleAddArticle: handleAddArticle,
|
3336
|
+
handleChangeScoreAnswer: handleChangeScoreAnswer,
|
3337
|
+
handleChangeTitle: handleChangeTitle,
|
3338
|
+
handleChangeDuration: handleChangeDuration,
|
3339
|
+
handleChangeCorrectAnswers: handleChangeCorrectAnswers,
|
3340
|
+
handleChangeAnswerCount: handleChangeAnswerCount,
|
3341
|
+
handleChangeQuestionCount: handleChangeQuestionCount,
|
3342
|
+
handleChangeCategory: handleChangeCategory
|
3343
|
+
};
|
3344
|
+
};
|
3345
|
+
|
3346
|
+
var ExamDetailView = function ExamDetailView(_ref) {
|
3347
|
+
var _ref$className = _ref.className,
|
3348
|
+
className = _ref$className === void 0 ? "" : _ref$className,
|
3349
|
+
categoryOptions = _ref.categoryOptions,
|
3350
|
+
exam = _ref.exam,
|
3351
|
+
_ref$isUsingMui = _ref.isUsingMui,
|
3352
|
+
isUsingMui = _ref$isUsingMui === void 0 ? true : _ref$isUsingMui,
|
3353
|
+
isDisabled = _ref.isDisabled,
|
3354
|
+
onChangeExam = _ref.onChangeExam;
|
3355
|
+
var _useExamDetailView = useExamDetailView({
|
3356
|
+
exam: exam,
|
3357
|
+
onChangeExam: onChangeExam
|
3358
|
+
}),
|
3359
|
+
t = _useExamDetailView.t,
|
3360
|
+
durationOptions = _useExamDetailView.durationOptions,
|
3361
|
+
examGroupByArticle = _useExamDetailView.examGroupByArticle,
|
3362
|
+
handleAddArticle = _useExamDetailView.handleAddArticle,
|
3363
|
+
handleChangeScoreAnswer = _useExamDetailView.handleChangeScoreAnswer,
|
3364
|
+
handleChangeTitle = _useExamDetailView.handleChangeTitle,
|
3365
|
+
handleChangeDuration = _useExamDetailView.handleChangeDuration,
|
3366
|
+
handleChangeCorrectAnswers = _useExamDetailView.handleChangeCorrectAnswers,
|
3367
|
+
handleChangeAnswerCount = _useExamDetailView.handleChangeAnswerCount,
|
3368
|
+
handleChangeQuestionCount = _useExamDetailView.handleChangeQuestionCount,
|
3369
|
+
handleChangeCategory = _useExamDetailView.handleChangeCategory;
|
3370
|
+
return React.createElement(Row, {
|
3371
|
+
className: "" + className
|
3372
|
+
}, React.createElement(Col, {
|
3373
|
+
xs: 5
|
3374
|
+
}, React.createElement(FormGroup, null, React.createElement(Label, {
|
3375
|
+
className: "" + styles$2["question-label"],
|
3376
|
+
htmlFor: "title"
|
3377
|
+
}, t("title")), React.createElement(Input, {
|
3378
|
+
disabled: isDisabled,
|
3379
|
+
className: "w-100 rounded-2 " + styles$2["question-input"],
|
3380
|
+
value: exam.title,
|
3381
|
+
id: "title",
|
3382
|
+
placeholder: t("enter_title"),
|
3383
|
+
onChange: handleChangeTitle
|
3384
|
+
}))), React.createElement(Col, {
|
3385
|
+
xs: 3
|
3386
|
+
}, React.createElement(FormGroup, null, React.createElement(Label, {
|
3387
|
+
className: "" + styles$2["question-label"],
|
3388
|
+
htmlFor: "duration"
|
3389
|
+
}, t("duration")), React.createElement(CustomSelect, {
|
3390
|
+
inputId: "duration",
|
3391
|
+
value: exam.duration,
|
3392
|
+
options: durationOptions,
|
3393
|
+
onChange: handleChangeDuration,
|
3394
|
+
isDisabled: isDisabled
|
3395
|
+
}))), React.createElement(Col, {
|
3396
|
+
xs: 4
|
3397
|
+
}), examGroupByArticle.map(function (i, index) {
|
3398
|
+
return React.createElement(Col, {
|
3399
|
+
xs: 12,
|
3400
|
+
key: i.article,
|
3401
|
+
className: (index === 0 && !isUsingMui ? "mt-3" : "") + " " + (!isUsingMui ? "mb-4" : "")
|
3402
|
+
}, React.createElement(ArticleGroupView, Object.assign({}, i, {
|
3403
|
+
categoryOptions: categoryOptions,
|
3404
|
+
isActive: index === examGroupByArticle.length - 1,
|
3405
|
+
onChangeQuestionCount: handleChangeQuestionCount,
|
3406
|
+
onChangeCategory: handleChangeCategory,
|
3407
|
+
onChangeAnswerCount: handleChangeAnswerCount,
|
3408
|
+
onChangeCorrectAnswers: handleChangeCorrectAnswers,
|
3409
|
+
onChangeScoreAnswer: handleChangeScoreAnswer,
|
3410
|
+
isDisabled: isDisabled
|
3411
|
+
})));
|
3412
|
+
}), React.createElement(Col, {
|
3413
|
+
xs: 12
|
3414
|
+
}, React.createElement(Button, {
|
3415
|
+
disabled: isDisabled,
|
3416
|
+
className: "w-100 d-flex justify-content-center align-items-center " + styles$2["question-btn"],
|
3417
|
+
color: "primary",
|
3418
|
+
outline: true,
|
3419
|
+
onClick: handleAddArticle
|
3420
|
+
}, React.createElement(FaPlusCircle, {
|
3421
|
+
className: "me-2"
|
3422
|
+
}), "\uBB38\uD56D \uCD94\uAC00\uD558\uAE30")));
|
3423
|
+
};
|
3424
|
+
|
2657
3425
|
var historyCore = createBrowserHistory();
|
2658
3426
|
|
2659
|
-
export { ACCESS_TOKEN, BASE_URL, ChatContainer, ChatItemType, CommonAlert, CommonDialog, ConfirmDialog, CustomPagination, CustomSelect, DATE_MIN_VALUE, EXAM_CHANNEL, EXAM_STUDENT_CHANNEL, ExamEvent, LayoutContext, Loading, Login, NotFound, PUSHER_CONFIG, TheLanguageDropdown, api, canAccess as canAccessRoute, diffFromNow, formatTime, getAccessToken$1 as getAccessToken, historyCore, i18n, minutesToTimeSpan, setAlert, setLanguage, setLoading, setUser, store, toISOString, useChatContainer, useConversationList, useGoogleSignOut, usePusherConversation, utcToLocalTime };
|
3427
|
+
export { ACCESS_TOKEN, BASE_URL, ChatContainer, ChatItemType, CommonAlert, CommonDialog, ConfirmDialog, CustomAsyncSelect, CustomCreatable, CustomPagination, CustomSelect, DATE_MIN_VALUE, EXAM_CHANNEL, EXAM_STUDENT_CHANNEL, ExamDetailView, ExamEvent, LANGUAGES, LayoutContext, Loading, Login, NotFound, PUSHER_CONFIG, Role, TheLanguageDropdown, api, canAccess as canAccessRoute, diffFromNow, formatTime, getAccessToken$1 as getAccessToken, historyCore, i18n, minutesToTimeSpan, setAlert, setLanguage, setLoading, setUser, store, toISOString, useChatContainer, useConversationList, useGoogleSignOut, useLanguage, usePusherConversation, utcToLocalTime };
|
2660
3428
|
//# sourceMappingURL=index.modern.js.map
|