touchstudy-core 0.1.34 → 0.1.35

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.
@@ -9,7 +9,7 @@ import { useDispatch, useSelector } from 'react-redux';
9
9
  import axios from 'axios';
10
10
  import { useTranslation, initReactI18next } from 'react-i18next';
11
11
  export { I18nextProvider, useTranslation } from 'react-i18next';
12
- import { Grid, Dialog, DialogTitle, IconButton, DialogContent, TextField, DialogActions, Button, Box, Typography, Pagination, styled, Tooltip, tooltipClasses, Stack, ClickAwayListener, useMediaQuery, CircularProgress, FormControl, RadioGroup, FormControlLabel, Radio, useTheme, FormGroup, FormLabel, InputLabel, Container, Table, TableBody, TableRow, TableCell, TableHead, Paper, InputBase } from '@mui/material';
12
+ import { Grid, Dialog, DialogTitle, IconButton, DialogContent, TextField, DialogActions, Button, Box, Typography, Pagination, styled, Tooltip, tooltipClasses, Stack, ClickAwayListener, useTheme, useMediaQuery, CircularProgress, FormControl, RadioGroup, FormControlLabel, Radio, FormGroup, FormLabel, Checkbox, InputLabel, Container, Table, TableBody, TableRow, TableCell, TableHead, Paper, InputBase } from '@mui/material';
13
13
  import { gapi } from 'gapi-script';
14
14
  import Pusher from 'pusher-js';
15
15
  import { IoClose, IoCloseOutline, IoSearch } from 'react-icons/io5';
@@ -24,7 +24,7 @@ import { GoArrowSwitch } from 'react-icons/go';
24
24
  import { toast } from 'react-toastify';
25
25
  export { ToastContainer, toast } from 'react-toastify';
26
26
  import Select, { components } from 'react-select';
27
- import { FaCaretDown, FaTrash, FaPlus, FaSave, FaPencilAlt, FaSortUp, FaSortDown, FaEye, FaPlusCircle } from 'react-icons/fa';
27
+ import { FaCaretDown, FaTrash, FaPlus, FaSave, FaPencilAlt, FaPlusCircle, FaTimes, FaSortUp, FaSortDown, FaEye } from 'react-icons/fa';
28
28
  import { PiDotsNineLight } from 'react-icons/pi';
29
29
  import { IoMdArrowBack, IoIosLogOut } from 'react-icons/io';
30
30
  import _ from 'lodash';
@@ -137,7 +137,7 @@ function _objectWithoutPropertiesLoose(source, excluded) {
137
137
  return target;
138
138
  }
139
139
 
140
- var styles = {"btn-login-google":"_2HqmH","block-login":"_wWIyO","box-login":"_38Lo1","dropdown-menu":"_1krbH","header-avatar":"_RQaHE","dropdown-menu-flag":"_XK8oS","dropdown-content":"_3ys4W","dropdown-change":"_ToOW_","item-address":"_3sQlR","item-logout":"_3bqSM","title-address":"_1jgSI","img-avatar":"_35Ttz","item-contact":"_1wc7o","content-text":"_3S4f2","dropdown-content-language":"_3ajui","dropdown-item-language":"_3Y_y4","dropdown-item-language-active":"_CzNMi","dropdown-academy":"_3CMVp","image-academy":"_2ibYC","image-academy--item":"_3RDWF","academy-btn":"_1JMRU","switch-icon":"_N4FNf","dropdown-content-academy":"_31Dr0","dropdown-academy-item":"_3bjcz","noGutters":"_31ZQk","custom-col-2":"_3yXyK","custom-col-3":"_1RsJQ","custom-col-5":"_L42CP","custom-col-10":"_2u6eL","custom-row":"_8x7OP","custom-col":"_1JmTh","custom-col-4":"_3HO1e","custom-col-8":"_Oy31M","custom-col-12":"_3aUKo","custom-container":"_39LRs","form-label":"__Ut-u","form-control":"_2k4dX","btn-outline-primary":"_2PWdX","sort-icons":"_mQvLF","active":"_3oAH-","form-select":"_3W3aw","truncate":"_3NJzN","headers":"_3xnI5","logo-container":"_3YG70","tabBox":"_1CQPn","routerBox":"_3hx2T","tabText":"_3UyhW","router-link-active":"_1TGKA","router-link":"_1AqMh","userImg":"_2RI6G","disabled-link":"_3aVHg"};
140
+ var styles = {"btn-login-google":"_2HqmH","block-login":"_wWIyO","box-login":"_38Lo1","btn-primary":"_rd4Uy","dropdown-menu":"_1krbH","header-avatar":"_RQaHE","dropdown-menu-flag":"_XK8oS","dropdown-content":"_3ys4W","dropdown-change":"_ToOW_","item-address":"_3sQlR","item-logout":"_3bqSM","title-address":"_1jgSI","img-avatar":"_35Ttz","item-contact":"_1wc7o","content-text":"_3S4f2","dropdown-content-language":"_3ajui","dropdown-item-language":"_3Y_y4","dropdown-item-language-active":"_CzNMi","dropdown-academy":"_3CMVp","image-academy":"_2ibYC","image-academy--item":"_3RDWF","academy-btn":"_1JMRU","switch-icon":"_N4FNf","dropdown-content-academy":"_31Dr0","dropdown-academy-item":"_3bjcz","noGutters":"_31ZQk","custom-col-2":"_3yXyK","custom-col-3":"_1RsJQ","custom-col-5":"_L42CP","custom-col-10":"_2u6eL","custom-row":"_8x7OP","custom-col":"_1JmTh","custom-col-4":"_3HO1e","custom-col-8":"_Oy31M","custom-col-12":"_3aUKo","custom-container":"_39LRs","form-label":"__Ut-u","form-control":"_2k4dX","btn-outline-primary":"_2PWdX","sort-icons":"_mQvLF","active":"_3oAH-","form-select":"_3W3aw","truncate":"_3NJzN","headers":"_3xnI5","logo-container":"_3YG70","tabBox":"_1CQPn","routerBox":"_3hx2T","tabText":"_3UyhW","router-link-active":"_1TGKA","router-link":"_1AqMh","userImg":"_2RI6G","disabled-link":"_3aVHg"};
141
141
 
142
142
  var AuthenticationMessage;
143
143
  (function (AuthenticationMessage) {
@@ -881,6 +881,7 @@ var switchAcademy = function switchAcademy(academyId) {
881
881
  };
882
882
 
883
883
  var LayoutContext = function LayoutContext(_ref) {
884
+ var _currentPusher$connec, _currentPusher$connec3;
884
885
  var children = _ref.children,
885
886
  role = _ref.role,
886
887
  _ref$pusherRegisterUr = _ref.pusherRegisterUrls,
@@ -905,6 +906,7 @@ var LayoutContext = function LayoutContext(_ref) {
905
906
  var _state$common3;
906
907
  return state === null || state === void 0 ? void 0 : (_state$common3 = state.common) === null || _state$common3 === void 0 ? void 0 : _state$common3.concurrentConnectionPusher;
907
908
  });
909
+ var currentPusher = concurrentConnectionPusher === null || concurrentConnectionPusher === void 0 ? void 0 : concurrentConnectionPusher.pusher;
908
910
  var roles = (user === null || user === void 0 ? void 0 : user.roles) || [];
909
911
  var academyDomain = user === null || user === void 0 ? void 0 : user.academyDomain;
910
912
  var pathname = window.location.pathname;
@@ -971,31 +973,41 @@ var LayoutContext = function LayoutContext(_ref) {
971
973
  return Promise.reject(e);
972
974
  }
973
975
  };
976
+ console.log({
977
+ connection: currentPusher === null || currentPusher === void 0 ? void 0 : (_currentPusher$connec = currentPusher.connection) === null || _currentPusher$connec === void 0 ? void 0 : _currentPusher$connec.state,
978
+ pusherRegisterUrls: pusherRegisterUrls,
979
+ pathname: pathname
980
+ });
974
981
  var registerPusher = useCallback(function () {
975
- if (pusherRegisterUrls.includes(pathname.toLocaleLowerCase()) && academyDomain && academyDomain !== (concurrentConnectionPusher === null || concurrentConnectionPusher === void 0 ? void 0 : concurrentConnectionPusher.academyDomain) && isReadyRegisterPusher) {
976
- var _headers;
977
- if (concurrentConnectionPusher.pusher) {
978
- concurrentConnectionPusher.pusher.disconnect();
979
- }
980
- var token = getAccessToken();
981
- var pusher = new Pusher(PUSHER_CONFIG.key, {
982
- cluster: PUSHER_CONFIG.cluster,
983
- authEndpoint: BASE_URL + "/api/auth/pusher",
984
- auth: {
985
- params: {},
986
- headers: (_headers = {
987
- Authorization: "Bearer " + token
988
- }, _headers[AcademyHeaders] = academyDomain, _headers)
982
+ if (pusherRegisterUrls.includes(pathname.toLocaleLowerCase())) {
983
+ var _currentPusher$connec2;
984
+ if (academyDomain && academyDomain !== (concurrentConnectionPusher === null || concurrentConnectionPusher === void 0 ? void 0 : concurrentConnectionPusher.academyDomain) && isReadyRegisterPusher) {
985
+ var _headers;
986
+ if (currentPusher) {
987
+ currentPusher.disconnect();
989
988
  }
990
- });
991
- dispatch(setConcurrentConnectionPusher({
992
- pusher: pusher,
993
- academyDomain: academyDomain
994
- }));
989
+ var token = getAccessToken();
990
+ var pusher = new Pusher(PUSHER_CONFIG.key, {
991
+ cluster: PUSHER_CONFIG.cluster,
992
+ authEndpoint: BASE_URL + "/api/auth/pusher",
993
+ auth: {
994
+ params: {},
995
+ headers: (_headers = {
996
+ Authorization: "Bearer " + token
997
+ }, _headers[AcademyHeaders] = academyDomain, _headers)
998
+ }
999
+ });
1000
+ dispatch(setConcurrentConnectionPusher({
1001
+ pusher: pusher,
1002
+ academyDomain: academyDomain
1003
+ }));
1004
+ } else if ((currentPusher === null || currentPusher === void 0 ? void 0 : (_currentPusher$connec2 = currentPusher.connection) === null || _currentPusher$connec2 === void 0 ? void 0 : _currentPusher$connec2.state) === "disconnected") {
1005
+ currentPusher.connect();
1006
+ }
995
1007
  }
996
- if ((!pusherRegisterUrls.includes(pathname.toLocaleLowerCase()) || !isReadyRegisterPusher) && !!(concurrentConnectionPusher !== null && concurrentConnectionPusher !== void 0 && concurrentConnectionPusher.pusher)) {
997
- if (concurrentConnectionPusher.pusher) {
998
- concurrentConnectionPusher.pusher.disconnect();
1008
+ if (!pusherRegisterUrls.includes(pathname.toLocaleLowerCase()) && !!currentPusher) {
1009
+ if (currentPusher) {
1010
+ currentPusher.disconnect();
999
1011
  }
1000
1012
  dispatch(setConcurrentConnectionPusher({
1001
1013
  pusher: null,
@@ -1005,7 +1017,7 @@ var LayoutContext = function LayoutContext(_ref) {
1005
1017
  if (!pusherRegisterUrls.includes(pathname.toLocaleLowerCase()) && isReadyRegisterPusher) {
1006
1018
  dispatch(setReadyRegisterPusher(false));
1007
1019
  }
1008
- }, [pusherRegisterUrls.join(","), academyDomain, pathname, isReadyRegisterPusher]);
1020
+ }, [pusherRegisterUrls.join(","), academyDomain, pathname, isReadyRegisterPusher, currentPusher === null || currentPusher === void 0 ? void 0 : (_currentPusher$connec3 = currentPusher.connection) === null || _currentPusher$connec3 === void 0 ? void 0 : _currentPusher$connec3.state]);
1009
1021
  useEffect(function () {
1010
1022
  !user && loadInfo();
1011
1023
  !!user && checkRoleUser();
@@ -1016,8 +1028,8 @@ var LayoutContext = function LayoutContext(_ref) {
1016
1028
  useEffect(function () {
1017
1029
  registerPusher();
1018
1030
  return function () {
1019
- if (concurrentConnectionPusher.pusher) {
1020
- concurrentConnectionPusher.pusher.disconnect();
1031
+ if (currentPusher) {
1032
+ currentPusher.disconnect();
1021
1033
  }
1022
1034
  };
1023
1035
  }, [registerPusher]);
@@ -1306,6 +1318,7 @@ var recent_exam_results = "최근 시험 결과";
1306
1318
  var instructor_name = "강사이름";
1307
1319
  var academy_name = "학원 이름";
1308
1320
  var total_students = "총 학생수";
1321
+ var total_class = "반 수";
1309
1322
  var total_number_students = "총 학생수";
1310
1323
  var student = "학생";
1311
1324
  var students = "재학생";
@@ -1322,8 +1335,9 @@ var mins_mins_seconds_seconds = "{{mins}}분 {{seconds}}초";
1322
1335
  var mins_mins = "{{mins}}분";
1323
1336
  var class_name = "반 이름";
1324
1337
  var create_new_exam = "새 시험 생성";
1338
+ var live_exam = "시험 생성";
1325
1339
  var there_are_no_recent_exams = "최근 시험이 없습니다";
1326
- var you_have_created_a_exam_with_code_code_do_you_want_to_continue = "코드가 {{code}} 시험을 생성했습니다. 계속하시겠습니까?";
1340
+ var you_have_started_an_exam_with_code_code_do_you_want_to_continue = "{{code}} 코드로 시험을 시작했습니다. 계속하시겠습니까?";
1327
1341
  var here = "여기";
1328
1342
  var do_you_want_to_complete_the_exam = "시험을 완료처리 하시겠습니까?";
1329
1343
  var are_you_sure_you_want_to_delete_the_exam = "시험을 삭제하시겠습니까?";
@@ -1562,6 +1576,7 @@ var course = "진로";
1562
1576
  var etc = "그 외";
1563
1577
  var consultation_category = "상담 카테고리";
1564
1578
  var points = "{{number}} 점";
1579
+ var noun_number_of_people = "인원 수";
1565
1580
  var number_of_people = "{{ number }} 명";
1566
1581
  var total_classes = "반수";
1567
1582
  var number_of_classes = "{{ number }} 개";
@@ -1581,6 +1596,29 @@ var my_answers = "내 해답";
1581
1596
  var request_for_consultation = "상담요청";
1582
1597
  var ask_a_question_with_a_problem = "문제로 질문하기";
1583
1598
  var live = "살다";
1599
+ var user_email = "사용자 이메일";
1600
+ var user_academy = {
1601
+ add: "사용자 추가",
1602
+ update_user_roles: "사용자 역할 업데이트",
1603
+ add_failed: "아카데미에 사용자 추가 실패",
1604
+ add_successfully: "사용자를 아카데미에 추가했습니다",
1605
+ remove_failed: "아카데미에서 사용자를 제거하지 못했습니다",
1606
+ remove_successfully: "아카데미에서 사용자를 성공적으로 제거했습니다",
1607
+ update_user_roles_failed: "아카데미 사용자 역할 업데이트에 실패했습니다",
1608
+ update_user_roles__successfully: "아카데미 사용자 역할을 성공적으로 제거했습니다",
1609
+ get_failed: "아카데미 사용자 가져오기 실패"
1610
+ };
1611
+ var get_users_failed = "사용자 가져오기 실패";
1612
+ var status_of_each_class = "각 반별 현황";
1613
+ var attendance_rate = "출석률";
1614
+ var select_article_create_exam = "시험을 만들 기사를 선택하세요.";
1615
+ var comprehensive_analysis = "내 해답";
1616
+ var solution_order = "풀이 순서";
1617
+ var compare_solution = "풀이 비교";
1618
+ var problem_analysis = "문제 분석";
1619
+ var class_information = "수업정보";
1620
+ var teachers = "교사";
1621
+ var lessons = "수업";
1584
1622
  var lang_ko = {
1585
1623
  problem_solving: problem_solving,
1586
1624
  my_story: my_story,
@@ -1598,6 +1636,7 @@ var lang_ko = {
1598
1636
  instructor_name: instructor_name,
1599
1637
  academy_name: academy_name,
1600
1638
  total_students: total_students,
1639
+ total_class: total_class,
1601
1640
  total_number_students: total_number_students,
1602
1641
  student: student,
1603
1642
  students: students,
@@ -1616,8 +1655,9 @@ var lang_ko = {
1616
1655
  mins_mins: mins_mins,
1617
1656
  class_name: class_name,
1618
1657
  create_new_exam: create_new_exam,
1658
+ live_exam: live_exam,
1619
1659
  there_are_no_recent_exams: there_are_no_recent_exams,
1620
- you_have_created_a_exam_with_code_code_do_you_want_to_continue: you_have_created_a_exam_with_code_code_do_you_want_to_continue,
1660
+ you_have_started_an_exam_with_code_code_do_you_want_to_continue: you_have_started_an_exam_with_code_code_do_you_want_to_continue,
1621
1661
  here: here,
1622
1662
  do_you_want_to_complete_the_exam: do_you_want_to_complete_the_exam,
1623
1663
  are_you_sure_you_want_to_delete_the_exam: are_you_sure_you_want_to_delete_the_exam,
@@ -1853,6 +1893,7 @@ var lang_ko = {
1853
1893
  etc: etc,
1854
1894
  consultation_category: consultation_category,
1855
1895
  points: points,
1896
+ noun_number_of_people: noun_number_of_people,
1856
1897
  number_of_people: number_of_people,
1857
1898
  total_classes: total_classes,
1858
1899
  number_of_classes: number_of_classes,
@@ -1871,7 +1912,20 @@ var lang_ko = {
1871
1912
  my_answers: my_answers,
1872
1913
  request_for_consultation: request_for_consultation,
1873
1914
  ask_a_question_with_a_problem: ask_a_question_with_a_problem,
1874
- live: live
1915
+ live: live,
1916
+ user_email: user_email,
1917
+ user_academy: user_academy,
1918
+ get_users_failed: get_users_failed,
1919
+ status_of_each_class: status_of_each_class,
1920
+ attendance_rate: attendance_rate,
1921
+ select_article_create_exam: select_article_create_exam,
1922
+ comprehensive_analysis: comprehensive_analysis,
1923
+ solution_order: solution_order,
1924
+ compare_solution: compare_solution,
1925
+ problem_analysis: problem_analysis,
1926
+ class_information: class_information,
1927
+ teachers: teachers,
1928
+ lessons: lessons
1875
1929
  };
1876
1930
 
1877
1931
  var problem_solving$1 = "Problem Solving";
@@ -1890,6 +1944,7 @@ var recent_exam_results$1 = "Recent exam";
1890
1944
  var instructor_name$1 = "Instructor name";
1891
1945
  var academy_name$1 = "Academy name";
1892
1946
  var total_students$1 = "Total students";
1947
+ var total_class$1 = "Total Class";
1893
1948
  var total_number_students$1 = "Total number of students";
1894
1949
  var students$1 = "Students";
1895
1950
  var student$1 = "Student";
@@ -1906,8 +1961,9 @@ var mins_mins_seconds_seconds$1 = "{{mins}}m {{seconds}}s";
1906
1961
  var mins_mins$1 = "{{mins}}m";
1907
1962
  var class_name$1 = "Class name";
1908
1963
  var create_new_exam$1 = "Create exam";
1964
+ var live_exam$1 = "Live exam";
1909
1965
  var there_are_no_recent_exams$1 = "There are no recent exams";
1910
- var you_have_created_a_exam_with_code_code_do_you_want_to_continue$1 = "You have created a exam with code {{code}}, do you want to continue?";
1966
+ var you_have_started_an_exam_with_code_code_do_you_want_to_continue$1 = "You have started an exam with code {{code}}, do you want to continue?";
1911
1967
  var here$1 = "here";
1912
1968
  var do_you_want_to_complete_the_exam$1 = "Do you want to complete the exam?";
1913
1969
  var are_you_sure_you_want_to_delete_the_exam$1 = "Are you sure you want to delete the exam?";
@@ -2181,6 +2237,7 @@ var course$1 = "Course";
2181
2237
  var etc$1 = "Etc";
2182
2238
  var consultation_category$1 = "Consultation Category";
2183
2239
  var points$1 = "{{number}} points";
2240
+ var noun_number_of_people$1 = "Number of people";
2184
2241
  var number_of_people$1 = "{{ number }} students";
2185
2242
  var total_classes$1 = "Total classes";
2186
2243
  var number_of_classes$1 = "{{ number }} classes";
@@ -2200,6 +2257,29 @@ var my_answers$1 = "My answers";
2200
2257
  var request_for_consultation$1 = "Request for consultation";
2201
2258
  var ask_a_question_with_a_problem$1 = "Ask a question with a problem";
2202
2259
  var live$1 = "live";
2260
+ var user_email$1 = "User email";
2261
+ var user_academy$1 = {
2262
+ add: "Add user",
2263
+ update_user_roles: "Update user roles",
2264
+ add_failed: "Add user to academy failed",
2265
+ add_successfully: "Add user to academy successfully",
2266
+ remove_failed: "Remove user from academy failed",
2267
+ remove_successfully: "Remove user from academy successfully",
2268
+ update_user_roles_failed: "Update academy user roles failed",
2269
+ update_user_roles_successfully: "Update academy user roles successfully",
2270
+ get_failed: "Get academy users failed"
2271
+ };
2272
+ var get_users_failed$1 = "Get users failed";
2273
+ var status_of_each_class$1 = "Status of each class";
2274
+ var attendance_rate$1 = "Attendance Rate";
2275
+ var select_article_create_exam$1 = "Select article to create exam";
2276
+ var comprehensive_analysis$1 = "Comprehensive analysis";
2277
+ var solution_order$1 = "Solution order";
2278
+ var compare_solution$1 = "Compare solution";
2279
+ var problem_analysis$1 = "Problem analysis";
2280
+ var class_information$1 = "Class Information";
2281
+ var teachers$1 = "Teachers";
2282
+ var lessons$1 = "Lessons";
2203
2283
  var lang_en = {
2204
2284
  problem_solving: problem_solving$1,
2205
2285
  my_story: my_story$1,
@@ -2217,6 +2297,7 @@ var lang_en = {
2217
2297
  instructor_name: instructor_name$1,
2218
2298
  academy_name: academy_name$1,
2219
2299
  total_students: total_students$1,
2300
+ total_class: total_class$1,
2220
2301
  total_number_students: total_number_students$1,
2221
2302
  students: students$1,
2222
2303
  student: student$1,
@@ -2235,8 +2316,9 @@ var lang_en = {
2235
2316
  mins_mins: mins_mins$1,
2236
2317
  class_name: class_name$1,
2237
2318
  create_new_exam: create_new_exam$1,
2319
+ live_exam: live_exam$1,
2238
2320
  there_are_no_recent_exams: there_are_no_recent_exams$1,
2239
- you_have_created_a_exam_with_code_code_do_you_want_to_continue: you_have_created_a_exam_with_code_code_do_you_want_to_continue$1,
2321
+ you_have_started_an_exam_with_code_code_do_you_want_to_continue: you_have_started_an_exam_with_code_code_do_you_want_to_continue$1,
2240
2322
  here: here$1,
2241
2323
  do_you_want_to_complete_the_exam: do_you_want_to_complete_the_exam$1,
2242
2324
  are_you_sure_you_want_to_delete_the_exam: are_you_sure_you_want_to_delete_the_exam$1,
@@ -2507,6 +2589,7 @@ var lang_en = {
2507
2589
  etc: etc$1,
2508
2590
  consultation_category: consultation_category$1,
2509
2591
  points: points$1,
2592
+ noun_number_of_people: noun_number_of_people$1,
2510
2593
  number_of_people: number_of_people$1,
2511
2594
  total_classes: total_classes$1,
2512
2595
  number_of_classes: number_of_classes$1,
@@ -2525,7 +2608,20 @@ var lang_en = {
2525
2608
  my_answers: my_answers$1,
2526
2609
  request_for_consultation: request_for_consultation$1,
2527
2610
  ask_a_question_with_a_problem: ask_a_question_with_a_problem$1,
2528
- live: live$1
2611
+ live: live$1,
2612
+ user_email: user_email$1,
2613
+ user_academy: user_academy$1,
2614
+ get_users_failed: get_users_failed$1,
2615
+ status_of_each_class: status_of_each_class$1,
2616
+ attendance_rate: attendance_rate$1,
2617
+ select_article_create_exam: select_article_create_exam$1,
2618
+ comprehensive_analysis: comprehensive_analysis$1,
2619
+ solution_order: solution_order$1,
2620
+ compare_solution: compare_solution$1,
2621
+ problem_analysis: problem_analysis$1,
2622
+ class_information: class_information$1,
2623
+ teachers: teachers$1,
2624
+ lessons: lessons$1
2529
2625
  };
2530
2626
 
2531
2627
  i18n.use(initReactI18next).init({
@@ -3998,7 +4094,8 @@ var ChatHeader = function ChatHeader(_ref) {
3998
4094
  handleConfirm = _useDialog.handleConfirm;
3999
4095
  var _useTranslation = useTranslation(),
4000
4096
  t = _useTranslation.t;
4001
- var isTabletUp = useMediaQuery('(min-width:900px)');
4097
+ var theme = useTheme();
4098
+ var isTabletUp = useMediaQuery(theme.breakpoints.up('lg'));
4002
4099
  var isStudent = roles === null || roles === void 0 ? void 0 : roles.includes(Roles$1.Student);
4003
4100
  var filterDurationExam = useMemo(function () {
4004
4101
  if (!durationExam) return;
@@ -5222,6 +5319,7 @@ var ChapterBox = function ChapterBox(_ref) {
5222
5319
  onChangePageTo = _ref.onChangePageTo,
5223
5320
  onAddArticle = _ref.onAddArticle,
5224
5321
  onRemoveArticle = _ref.onRemoveArticle,
5322
+ handleCheckArticle = _ref.handleCheckArticle,
5225
5323
  onUpdateArticleQuestionCount = _ref.onUpdateArticleQuestionCount,
5226
5324
  onUpdateArticleCategory = _ref.onUpdateArticleCategory,
5227
5325
  onUpdateArticleQuestionAnswerCount = _ref.onUpdateArticleQuestionAnswerCount,
@@ -5443,6 +5541,7 @@ var ChapterBox = function ChapterBox(_ref) {
5443
5541
  onChangeName: onChangeName,
5444
5542
  onChangePageFrom: onChangePageFrom,
5445
5543
  onChangePageTo: onChangePageTo,
5544
+ handleCheckArticle: handleCheckArticle,
5446
5545
  onAddArticle: onAddArticle,
5447
5546
  onRemoveArticle: onRemoveArticle,
5448
5547
  onUpdateArticleQuestionCount: onUpdateArticleQuestionCount,
@@ -5453,7 +5552,24 @@ var ChapterBox = function ChapterBox(_ref) {
5453
5552
  });
5454
5553
  }), data.subChapters.length === 0 && data.articles.map(function (article) {
5455
5554
  var _article$category;
5456
- return React.createElement(ArticleGroupView, {
5555
+ return React.createElement(Stack, null, React.createElement(Stack, {
5556
+ display: "flex",
5557
+ flexDirection: "row",
5558
+ gap: "8px",
5559
+ alignItems: "center"
5560
+ }, React.createElement(Checkbox, {
5561
+ id: "textbook",
5562
+ sx: {
5563
+ display: "flex",
5564
+ justifyContent: "start",
5565
+ width: "fit-content"
5566
+ },
5567
+ onChange: function onChange(e) {
5568
+ return handleCheckArticle(e, article);
5569
+ }
5570
+ }), React.createElement("label", {
5571
+ htmlFor: "textbook"
5572
+ }, t("select_article_create_exam"))), React.createElement(ArticleGroupView, {
5457
5573
  key: article.id,
5458
5574
  categoryOptions: categoryOptions,
5459
5575
  article: article.articleNumber,
@@ -5470,7 +5586,7 @@ var ChapterBox = function ChapterBox(_ref) {
5470
5586
  onChangeScoreAnswer: handleUpdateArticleQuestionScore,
5471
5587
  onDelete: handleRemoveArticle,
5472
5588
  isDeletable: true
5473
- });
5589
+ }));
5474
5590
  }))));
5475
5591
  };
5476
5592
 
@@ -5530,6 +5646,25 @@ var TextbookSortBy;
5530
5646
  TextbookSortBy["Title"] = "Name";
5531
5647
  TextbookSortBy["SubjectName"] = "Subject.Name";
5532
5648
  })(TextbookSortBy || (TextbookSortBy = {}));
5649
+ var ExamType;
5650
+ (function (ExamType) {
5651
+ ExamType["Normal"] = "Normal";
5652
+ ExamType["Standard"] = "Standard";
5653
+ })(ExamType || (ExamType = {}));
5654
+ var ExamStatus$1;
5655
+ (function (ExamStatus) {
5656
+ ExamStatus["Default"] = "Default";
5657
+ ExamStatus["Pending"] = "Pending";
5658
+ ExamStatus["InProgress"] = "InProgress";
5659
+ ExamStatus["Completed"] = "Completed";
5660
+ })(ExamStatus$1 || (ExamStatus$1 = {}));
5661
+ var ExamStatusNumber;
5662
+ (function (ExamStatusNumber) {
5663
+ ExamStatusNumber[ExamStatusNumber["Default"] = 0] = "Default";
5664
+ ExamStatusNumber[ExamStatusNumber["Pending"] = 1] = "Pending";
5665
+ ExamStatusNumber[ExamStatusNumber["InProgress"] = 2] = "InProgress";
5666
+ ExamStatusNumber[ExamStatusNumber["Completed"] = 3] = "Completed";
5667
+ })(ExamStatusNumber || (ExamStatusNumber = {}));
5533
5668
 
5534
5669
  var TEXTBOOK_HEADERS = [{
5535
5670
  title: "#"
@@ -5547,6 +5682,19 @@ var TEXTBOOK_HEADERS = [{
5547
5682
  }, {
5548
5683
  title: "actions"
5549
5684
  }];
5685
+ var DEFAULT_ANSWER_COUNT = 5;
5686
+ var DEFAULT_EXAM_REQUEST = {
5687
+ questions: [{
5688
+ article: 1,
5689
+ correctAnswers: [1],
5690
+ numberOfAnswers: DEFAULT_ANSWER_COUNT,
5691
+ score: 2,
5692
+ questionOrder: 0
5693
+ }],
5694
+ title: "",
5695
+ duration: 10,
5696
+ subjectId: 0
5697
+ };
5550
5698
  var TEXTBOOK_PAGE_TITLE = "textbooks";
5551
5699
  var TEXT_BOOK_SEARCH_PLACEHOLDER = "enter_student_name_to_search";
5552
5700
  var TextbookDefaultQuery = {
@@ -5613,6 +5761,133 @@ var deleteArticleApi = function deleteArticleApi(articleId, role) {
5613
5761
  });
5614
5762
  };
5615
5763
 
5764
+ var EXAM_URL = BASE_URL + "/api/exam";
5765
+ var createExam = function createExam(data) {
5766
+ return api.post("" + EXAM_URL, data, {
5767
+ params: {
5768
+ roles: [Role.Teacher]
5769
+ }
5770
+ });
5771
+ };
5772
+ var apiCreateExamSession = function apiCreateExamSession(examId) {
5773
+ return api.post(EXAM_URL + "/" + examId);
5774
+ };
5775
+
5776
+ var useExam = function useExam(props) {
5777
+ var callback = props.callback,
5778
+ navigate = props.navigate;
5779
+ var dispatch = useDispatch();
5780
+ var _useState = useState(false),
5781
+ isOpenDialog = _useState[0],
5782
+ setOpenDialog = _useState[1];
5783
+ var _useState2 = useState(DEFAULT_EXAM_REQUEST),
5784
+ examRequest = _useState2[0],
5785
+ setExamRequest = _useState2[1];
5786
+ var isTeacher = useSelector(function (state) {
5787
+ var _state$common, _state$common$user;
5788
+ return state === null || state === void 0 ? void 0 : (_state$common = state.common) === null || _state$common === void 0 ? void 0 : (_state$common$user = _state$common.user) === null || _state$common$user === void 0 ? void 0 : _state$common$user.roles.includes(Roles.Teacher);
5789
+ });
5790
+ var _useTranslation = useTranslation(),
5791
+ t = _useTranslation.t;
5792
+ var handleChangeExamRequest = function handleChangeExamRequest(value) {
5793
+ setExamRequest(value);
5794
+ };
5795
+ var handleOpenCreateExamDialog = function handleOpenCreateExamDialog() {
5796
+ setOpenDialog(true);
5797
+ };
5798
+ var handleCloseDialog = function handleCloseDialog() {
5799
+ setExamRequest(DEFAULT_EXAM_REQUEST);
5800
+ setOpenDialog(false);
5801
+ callback === null || callback === void 0 ? void 0 : callback();
5802
+ };
5803
+ var validateExam = function validateExam(exam) {
5804
+ if (!exam.subjectId) return t("Please select an exam subject");
5805
+ if (!exam.title.trim().length) return t("Please enter exam title");
5806
+ if (!exam.questions.length) return t("Exam required at least one question");
5807
+ for (var i = 0; i < exam.questions.length; i++) {
5808
+ var question = exam.questions[i];
5809
+ if (!question.categoryId) return t("Please select category for article " + question.article);
5810
+ }
5811
+ return false;
5812
+ };
5813
+ var handleCreateExam = function handleCreateExam() {
5814
+ try {
5815
+ var _temp3 = function _temp3() {
5816
+ dispatch(setLoading(false));
5817
+ };
5818
+ if (!examRequest) return Promise.resolve();
5819
+ var errorMessage = validateExam(examRequest);
5820
+ if (errorMessage) {
5821
+ toast.error(errorMessage);
5822
+ return Promise.resolve();
5823
+ }
5824
+ dispatch(setLoading(true));
5825
+ var _temp2 = _catch(function () {
5826
+ return Promise.resolve(createExam(_extends({}, examRequest, {
5827
+ duration: minutesToTimeSpan(examRequest.duration || 0)
5828
+ }))).then(function (res) {
5829
+ var _temp = function (_res$data, _res$data$data) {
5830
+ if (!((_res$data = res.data) !== null && _res$data !== void 0 && (_res$data$data = _res$data.data) !== null && _res$data$data !== void 0 && _res$data$data.id)) {
5831
+ toast.error("Create exam failed");
5832
+ } else {
5833
+ var _res$data2, _res$data2$data;
5834
+ return Promise.resolve(apiCreateExamSession((_res$data2 = res.data) === null || _res$data2 === void 0 ? void 0 : (_res$data2$data = _res$data2.data) === null || _res$data2$data === void 0 ? void 0 : _res$data2$data.id)).then(function () {
5835
+ setExamRequest(DEFAULT_EXAM_REQUEST);
5836
+ toast.success("Create exam successfully");
5837
+ });
5838
+ }
5839
+ }();
5840
+ if (_temp && _temp.then) return _temp.then(function () {});
5841
+ });
5842
+ }, function (error) {
5843
+ var _error$response;
5844
+ toast.error((error === null || error === void 0 ? void 0 : (_error$response = error.response) === null || _error$response === void 0 ? void 0 : _error$response.data) || "Create exam failed");
5845
+ });
5846
+ return Promise.resolve(_temp2 && _temp2.then ? _temp2.then(_temp3) : _temp3(_temp2));
5847
+ } catch (e) {
5848
+ return Promise.reject(e);
5849
+ }
5850
+ };
5851
+ var handleSaveExam = function handleSaveExam() {
5852
+ try {
5853
+ var _temp5 = function _temp5() {
5854
+ dispatch(setLoading(false));
5855
+ };
5856
+ if (!examRequest) return Promise.resolve();
5857
+ var errorMessage = validateExam(examRequest);
5858
+ if (errorMessage) {
5859
+ toast.error(errorMessage);
5860
+ return Promise.resolve();
5861
+ }
5862
+ dispatch(setLoading(true));
5863
+ var _temp4 = _catch(function () {
5864
+ return Promise.resolve(createExam(_extends({}, examRequest, {
5865
+ duration: minutesToTimeSpan(examRequest.duration || 0)
5866
+ }))).then(function () {
5867
+ handleCloseDialog();
5868
+ toast.success("Save exam successfully");
5869
+ isTeacher ? navigate('/teacher/exam-list') : navigate('/exams');
5870
+ });
5871
+ }, function (error) {
5872
+ var _error$response2;
5873
+ toast.error((error === null || error === void 0 ? void 0 : (_error$response2 = error.response) === null || _error$response2 === void 0 ? void 0 : _error$response2.data) || "Save exam failed");
5874
+ });
5875
+ return Promise.resolve(_temp4 && _temp4.then ? _temp4.then(_temp5) : _temp5(_temp4));
5876
+ } catch (e) {
5877
+ return Promise.reject(e);
5878
+ }
5879
+ };
5880
+ return {
5881
+ isOpenDialog: isOpenDialog,
5882
+ examRequest: examRequest,
5883
+ handleChangeExamRequest: handleChangeExamRequest,
5884
+ handleOpenCreateExamDialog: handleOpenCreateExamDialog,
5885
+ handleSaveExam: handleSaveExam,
5886
+ handleCloseDialog: handleCloseDialog,
5887
+ handleCreateExam: handleCreateExam
5888
+ };
5889
+ };
5890
+
5616
5891
  var useTextbookDetail = function useTextbookDetail(props) {
5617
5892
  var role = props.role,
5618
5893
  isReadonlyParam = props.isReadonlyParam,
@@ -5636,18 +5911,31 @@ var useTextbookDetail = function useTextbookDetail(props) {
5636
5911
  var _useState5 = useState(),
5637
5912
  parentChapter = _useState5[0],
5638
5913
  setParentChapter = _useState5[1];
5639
- var _useState6 = useState(),
5640
- selectedChapter = _useState6[0],
5641
- setSelectedChapter = _useState6[1];
5914
+ var _useState6 = useState([]),
5915
+ articlesSelected = _useState6[0],
5916
+ setArticlesSelected = _useState6[1];
5642
5917
  var _useState7 = useState(),
5643
- selectedDeleteItem = _useState7[0],
5644
- setSelectedDeleteItem = _useState7[1];
5918
+ selectedChapter = _useState7[0],
5919
+ setSelectedChapter = _useState7[1];
5920
+ var _useState8 = useState(),
5921
+ selectedDeleteItem = _useState8[0],
5922
+ setSelectedDeleteItem = _useState8[1];
5645
5923
  var updateChapterRef = useRef();
5646
5924
  var updateArticleRef = useRef();
5647
- var _useState8 = useState(false),
5648
- isEditedTitle = _useState8[0],
5649
- setEditedTitle = _useState8[1];
5925
+ var _useState9 = useState(false),
5926
+ isEditedTitle = _useState9[0],
5927
+ setEditedTitle = _useState9[1];
5650
5928
  var textbookUrl = role === Role.Teacher ? TEXTBOOK_URL$1 : ADMIN_TEXTBOOK_URL;
5929
+ var _useExam = useExam({
5930
+ navigate: navigate
5931
+ }),
5932
+ isOpenDialog = _useExam.isOpenDialog,
5933
+ examRequest = _useExam.examRequest,
5934
+ handleChangeExamRequest = _useExam.handleChangeExamRequest,
5935
+ handleOpenCreateExamDialog = _useExam.handleOpenCreateExamDialog,
5936
+ handleSaveExam = _useExam.handleSaveExam,
5937
+ handleCloseDialog = _useExam.handleCloseDialog,
5938
+ handleCreateExam = _useExam.handleCreateExam;
5651
5939
  var handleOpenAddArticleDialog = function handleOpenAddArticleDialog(chapter) {
5652
5940
  setSelectedChapter(chapter);
5653
5941
  };
@@ -5898,7 +6186,6 @@ var useTextbookDetail = function useTextbookDetail(props) {
5898
6186
  }
5899
6187
  };
5900
6188
  return Promise.resolve(handleCreateArticle(newArticle, function (article) {
5901
- console.log("created article: ", article);
5902
6189
  handleUpdateChapterValue([].concat(articles, [article]), "articles", selectedChapter.id, selectedChapter.parentChapterId);
5903
6190
  setSelectedChapter(undefined);
5904
6191
  })).then(function () {});
@@ -5988,12 +6275,14 @@ var useTextbookDetail = function useTextbookDetail(props) {
5988
6275
  };
5989
6276
  });
5990
6277
  newArticle = _extends({}, thisArticles, {
6278
+ chapterId: chapterId,
5991
6279
  questions: [].concat(thisQuestions, additionalQuestionArticles)
5992
6280
  });
5993
6281
  newArticles = [].concat(articles.slice(0, articleNumber - 1), [newArticle], articles.slice(articleNumber));
5994
6282
  }
5995
6283
  if (questionCount < thisQuestions.length) {
5996
6284
  newArticle = _extends({}, thisArticles, {
6285
+ chapterId: chapterId,
5997
6286
  questions: [].concat(thisQuestions.slice(0, questionCount))
5998
6287
  });
5999
6288
  newArticles = [].concat(articles.slice(0, articleNumber - 1), [newArticle], articles.slice(articleNumber));
@@ -6005,6 +6294,7 @@ var useTextbookDetail = function useTextbookDetail(props) {
6005
6294
  };
6006
6295
  var handleUpdateArticleCategory = function handleUpdateArticleCategory(articleNumber, categoryId, articles, chapterId, parentChapterId) {
6007
6296
  var newArticle = _extends({}, articles[articleNumber - 1], {
6297
+ chapterId: chapterId,
6008
6298
  category: {
6009
6299
  id: categoryId
6010
6300
  }
@@ -6021,6 +6311,7 @@ var useTextbookDetail = function useTextbookDetail(props) {
6021
6311
  if (newAnswerCount > answerCount) {
6022
6312
  newArticle = _extends({}, articles[articleNumber - 1], {
6023
6313
  answerCount: newAnswerCount,
6314
+ chapterId: chapterId,
6024
6315
  questions: articles[articleNumber - 1].questions.map(function (i) {
6025
6316
  return _extends({}, i, {
6026
6317
  numberOfAnswers: newAnswerCount
@@ -6030,6 +6321,7 @@ var useTextbookDetail = function useTextbookDetail(props) {
6030
6321
  } else if (newAnswerCount < answerCount) {
6031
6322
  newArticle = _extends({}, articles[articleNumber - 1], {
6032
6323
  answerCount: newAnswerCount,
6324
+ chapterId: chapterId,
6033
6325
  questions: articles[articleNumber - 1].questions.map(function (i) {
6034
6326
  return _extends({}, i, {
6035
6327
  numberOfAnswers: newAnswerCount,
@@ -6049,6 +6341,7 @@ var useTextbookDetail = function useTextbookDetail(props) {
6049
6341
  var _extends4;
6050
6342
  var thisQuestions = articles[articleNumber - 1].questions;
6051
6343
  var newArticle = _extends({}, articles[articleNumber - 1], {
6344
+ chapterId: chapterId,
6052
6345
  questions: [].concat(thisQuestions.slice(0, index), [_extends({}, thisQuestions[index], (_extends4 = {}, _extends4[key] = value, _extends4))], thisQuestions.slice(index + 1))
6053
6346
  });
6054
6347
  var newArticles = [].concat(articles.slice(0, articleNumber - 1), [newArticle], articles.slice(articleNumber));
@@ -6209,6 +6502,19 @@ var useTextbookDetail = function useTextbookDetail(props) {
6209
6502
  replace: true
6210
6503
  });
6211
6504
  };
6505
+ var handleCheckArticle = function handleCheckArticle(e, article) {
6506
+ var checked = e.target.checked;
6507
+ if (!(article !== null && article !== void 0 && article.id)) return;
6508
+ if (!checked) {
6509
+ var _newArticles = articlesSelected.filter(function (item) {
6510
+ return item !== article.id;
6511
+ });
6512
+ setArticlesSelected(_newArticles);
6513
+ return;
6514
+ }
6515
+ var newArticles = [].concat(articlesSelected, [article.id]);
6516
+ setArticlesSelected(newArticles);
6517
+ };
6212
6518
  useEffect(function () {
6213
6519
  var getTextbookDetail = function getTextbookDetail() {
6214
6520
  try {
@@ -6233,6 +6539,53 @@ var useTextbookDetail = function useTextbookDetail(props) {
6233
6539
  };
6234
6540
  if (id) getTextbookDetail();
6235
6541
  }, [dispatch, id]);
6542
+ var handleChangeExamRequestBeforeOpenDialog = function handleChangeExamRequestBeforeOpenDialog() {
6543
+ var _textbookSubject$valu;
6544
+ handleOpenCreateExamDialog();
6545
+ var articles = textbook.chapters.map(function (chapter) {
6546
+ var isSubChapters = !!chapter.subChapters.length;
6547
+ if (isSubChapters) {
6548
+ var _articles = chapter.subChapters.map(function (chapter) {
6549
+ return chapter.articles;
6550
+ });
6551
+ return _articles.filter(Boolean).flat();
6552
+ }
6553
+ return chapter.articles;
6554
+ });
6555
+ var articlesAfterFlat = articles.flat();
6556
+ var questionCount = 0;
6557
+ var articleCount = 1;
6558
+ var questions = articlesAfterFlat.map(function (article) {
6559
+ if (articlesSelected.findIndex(function (item) {
6560
+ return item === article.id;
6561
+ }) !== -1) {
6562
+ var _questions = article.questions.map(function (question) {
6563
+ var _article$category3;
6564
+ var newQuestion = {
6565
+ article: articleCount,
6566
+ id: question === null || question === void 0 ? void 0 : question.id,
6567
+ correctAnswers: question.correctAnswers,
6568
+ numberOfAnswers: question.numberOfAnswers,
6569
+ score: question.score,
6570
+ questionOrder: questionCount,
6571
+ categoryId: (_article$category3 = article.category) === null || _article$category3 === void 0 ? void 0 : _article$category3.id
6572
+ };
6573
+ questionCount++;
6574
+ return newQuestion;
6575
+ });
6576
+ articleCount++;
6577
+ return _questions;
6578
+ }
6579
+ return [];
6580
+ });
6581
+ var exam = {
6582
+ title: "",
6583
+ duration: 10,
6584
+ subjectId: (_textbookSubject$valu = textbookSubject === null || textbookSubject === void 0 ? void 0 : textbookSubject.value) != null ? _textbookSubject$valu : 0,
6585
+ questions: questions.flat().filter(Boolean)
6586
+ };
6587
+ handleChangeExamRequest(exam);
6588
+ };
6236
6589
  useEffect(function () {
6237
6590
  document.title = t("textbooks") + " | " + t(id ? "textbook_detail" : "create_textbook");
6238
6591
  }, [id, t]);
@@ -6252,6 +6605,15 @@ var useTextbookDetail = function useTextbookDetail(props) {
6252
6605
  selectedDeleteItem: selectedDeleteItem,
6253
6606
  isEditedTitle: isEditedTitle,
6254
6607
  isReadonlyParam: isReadonlyParam,
6608
+ articlesSelected: articlesSelected,
6609
+ isOpenDialog: isOpenDialog,
6610
+ examRequest: examRequest,
6611
+ handleChangeExamRequest: handleChangeExamRequest,
6612
+ handleCheckArticle: handleCheckArticle,
6613
+ handleOpenCreateExamDialog: handleChangeExamRequestBeforeOpenDialog,
6614
+ handleSaveExam: handleSaveExam,
6615
+ handleCloseDialog: handleCloseDialog,
6616
+ handleCreateExam: handleCreateExam,
6255
6617
  handleChangeTextbookTitle: handleChangeTextbookTitle,
6256
6618
  handleCreateOrUpdateTextbook: handleCreateOrUpdateTextbook,
6257
6619
  handleChangeTextbookSubject: handleChangeTextbookSubject,
@@ -6709,1036 +7071,1115 @@ var SubjectSelector = function SubjectSelector(_ref) {
6709
7071
  }));
6710
7072
  };
6711
7073
 
6712
- var TextbookViewDetail = function TextbookViewDetail(props) {
6713
- var _textbook$chapters;
6714
- var _useTextbookDetail = useTextbookDetail(props),
6715
- id = _useTextbookDetail.id,
6716
- t = _useTextbookDetail.t,
6717
- textbook = _useTextbookDetail.textbook,
6718
- textbookSubject = _useTextbookDetail.textbookSubject,
6719
- isReadonly = _useTextbookDetail.isReadonly,
6720
- isNotFound = _useTextbookDetail.isNotFound,
6721
- parentChapter = _useTextbookDetail.parentChapter,
6722
- textbookId = _useTextbookDetail.textbookId,
6723
- selectedChapter = _useTextbookDetail.selectedChapter,
6724
- selectedDeleteItem = _useTextbookDetail.selectedDeleteItem,
6725
- isEditedTitle = _useTextbookDetail.isEditedTitle,
6726
- handleChangeTextbookTitle = _useTextbookDetail.handleChangeTextbookTitle,
6727
- handleChangeTextbookSubject = _useTextbookDetail.handleChangeTextbookSubject,
6728
- handleGoToTextbookList = _useTextbookDetail.handleGoToTextbookList,
6729
- handleCreateOrUpdateTextbook = _useTextbookDetail.handleCreateOrUpdateTextbook,
6730
- handleCloseChapterNameDialog = _useTextbookDetail.handleCloseChapterNameDialog,
6731
- handleCreateChapter = _useTextbookDetail.handleCreateChapter,
6732
- handleAddChapterToTextbook = _useTextbookDetail.handleAddChapterToTextbook,
6733
- handleAddChapterToParentSubchapter = _useTextbookDetail.handleAddChapterToParentSubchapter,
6734
- handleChangeChapterName = _useTextbookDetail.handleChangeChapterName,
6735
- handleChangeChapterPageFrom = _useTextbookDetail.handleChangeChapterPageFrom,
6736
- handleChangeChapterPageTo = _useTextbookDetail.handleChangeChapterPageTo,
6737
- handleAddArticleToChapter = _useTextbookDetail.handleAddArticleToChapter,
6738
- handleUpdateArticleQuestionCountFromChapter = _useTextbookDetail.handleUpdateArticleQuestionCountFromChapter,
6739
- handleUpdateArticleCategory = _useTextbookDetail.handleUpdateArticleCategory,
6740
- handleUpdateArticleAnswerCount = _useTextbookDetail.handleUpdateArticleAnswerCount,
6741
- handleUpdateArticleQuestion = _useTextbookDetail.handleUpdateArticleQuestion,
6742
- handleCloseArticleDialog = _useTextbookDetail.handleCloseArticleDialog,
6743
- handleOpenAddArticleDialog = _useTextbookDetail.handleOpenAddArticleDialog,
6744
- handleOpenRemoveArticleConfirmDialog = _useTextbookDetail.handleOpenRemoveArticleConfirmDialog,
6745
- handleCloseConfirmDeleteDialog = _useTextbookDetail.handleCloseConfirmDeleteDialog,
6746
- handleRemoveSelectedItem = _useTextbookDetail.handleRemoveSelectedItem,
6747
- handleOpenRemoveChapterConfirmDialog = _useTextbookDetail.handleOpenRemoveChapterConfirmDialog;
6748
- var _useCategorySelect = useCategorySelect({
6749
- subjectId: id ? textbookSubject === null || textbookSubject === void 0 ? void 0 : textbookSubject.value : undefined
6750
- }),
6751
- categoryOptions = _useCategorySelect.categoryOptions;
6752
- if (isNotFound) return React.createElement(NotFound, null);
6753
- return React.createElement(Container, {
6754
- maxWidth: "xl",
6755
- className: "bg-white py-5 p-4 rounded-4 h-100 d-flex flex-column"
6756
- }, React.createElement(Stack, {
6757
- direction: "row",
6758
- alignItems: "center",
6759
- justifyContent: "space-between",
6760
- mb: 2
6761
- }, React.createElement(Typography, {
6762
- variant: "h3"
6763
- }, t(id ? isReadonly ? "view_textbook" : "update_textbook" : "create_textbook"))), React.createElement(Grid, {
6764
- container: true,
6765
- spacing: 3
6766
- }, React.createElement(Grid, {
6767
- item: true,
6768
- xs: 4,
6769
- className: "d-flex align-items-center"
6770
- }, React.createElement(Table, null, React.createElement(TableBody, null, React.createElement(TableRow, {
6771
- sx: {
6772
- "& td": {
6773
- border: 0
6774
- }
6775
- }
6776
- }, React.createElement(TableCell, {
6777
- className: "p-2 pe-0",
6778
- sx: {
6779
- width: "15%"
6780
- }
6781
- }, React.createElement(InputLabel, null, React.createElement("span", {
6782
- className: "fw-bold"
6783
- }, t("name")), React.createElement("span", {
6784
- className: "text-danger"
6785
- }, "*"))), React.createElement(TableCell, {
6786
- sx: {
6787
- width: 0,
6788
- px: 1
6789
- }
6790
- }, ":"), React.createElement(TableCell, {
6791
- className: "p-2"
6792
- }, React.createElement(InputText, {
6793
- className: "w-100",
6794
- value: textbook === null || textbook === void 0 ? void 0 : textbook.name,
6795
- placeholder: t("enter_textbook_title"),
6796
- onChange: handleChangeTextbookTitle,
6797
- disabled: isReadonly
6798
- }))), React.createElement(TableRow, {
6799
- sx: {
6800
- "& td": {
6801
- border: 0
6802
- }
6803
- }
6804
- }, React.createElement(TableCell, {
6805
- className: "p-2 pe-0"
6806
- }, React.createElement(InputLabel, null, React.createElement("span", {
6807
- className: "fw-bold"
6808
- }, t("subject")), React.createElement("span", {
6809
- className: "text-danger"
6810
- }, "*"))), React.createElement(TableCell, {
6811
- sx: {
6812
- width: 0,
6813
- px: 1
6814
- }
6815
- }, ":"), React.createElement(TableCell, {
6816
- className: "p-2"
6817
- }, React.createElement(SubjectSelector, {
6818
- value: textbookSubject,
6819
- onChange: handleChangeTextbookSubject,
6820
- isDisabled: isReadonly || !!id
6821
- })))))), React.createElement(Grid, {
6822
- item: true,
6823
- xs: 8,
6824
- className: "d-flex justify-content-end"
6825
- }, React.createElement("div", null, React.createElement(TextbookActionButtons, {
6826
- isReadonly: isReadonly,
6827
- textbook: textbook,
6828
- onBack: handleGoToTextbookList,
6829
- onSave: handleCreateOrUpdateTextbook,
6830
- hideSave: !isEditedTitle && !!id && !isReadonly || textbook.isCreatedByAdmin
6831
- }))), React.createElement(Grid, {
6832
- item: true,
6833
- xs: 12,
6834
- className: "d-flex justify-content-end"
6835
- }, !!id && React.createElement(Button, {
6836
- className: "mx-1",
6837
- variant: "contained",
6838
- color: "primary",
6839
- startIcon: React.createElement(FaPlus, {
6840
- size: 12
6841
- }),
6842
- onClick: handleAddChapterToTextbook,
6843
- disabled: isReadonly
6844
- }, t("add_chapter"))), React.createElement(Grid, {
6845
- item: true,
6846
- xs: 12
6847
- }, React.createElement(Stack, {
6848
- spacing: 3
6849
- }, !!(textbook !== null && textbook !== void 0 && textbook.subject) && (textbook === null || textbook === void 0 ? void 0 : (_textbook$chapters = textbook.chapters) === null || _textbook$chapters === void 0 ? void 0 : _textbook$chapters.map(function (chapter) {
6850
- return React.createElement(ChapterBox, {
6851
- key: chapter.id,
6852
- subject: textbook.subject,
6853
- data: chapter,
6854
- categoryOptions: categoryOptions || [],
6855
- onClickAddSubchapter: handleAddChapterToParentSubchapter,
6856
- onChangeName: handleChangeChapterName,
6857
- onChangePageFrom: handleChangeChapterPageFrom,
6858
- onChangePageTo: handleChangeChapterPageTo,
6859
- onAddArticle: handleOpenAddArticleDialog,
6860
- onRemoveArticle: handleOpenRemoveArticleConfirmDialog,
6861
- onUpdateArticleQuestionCount: handleUpdateArticleQuestionCountFromChapter,
6862
- onUpdateArticleCategory: handleUpdateArticleCategory,
6863
- onUpdateArticleQuestionAnswerCount: handleUpdateArticleAnswerCount,
6864
- onUpdateArticleQuestion: handleUpdateArticleQuestion,
6865
- onRemoveChapter: handleOpenRemoveChapterConfirmDialog,
6866
- isReadonly: isReadonly
6867
- });
6868
- }))))), React.createElement(ChapterNameDialog, {
6869
- open: !!(parentChapter !== null && parentChapter !== void 0 && parentChapter.id) || !!textbookId,
6870
- chapter: parentChapter,
6871
- onClose: handleCloseChapterNameDialog,
6872
- onSubmitForm: handleCreateChapter
6873
- }), React.createElement(ArticleDialog, {
6874
- open: !!selectedChapter,
6875
- chapter: selectedChapter,
6876
- categoryOptions: categoryOptions || [],
6877
- onClose: handleCloseArticleDialog,
6878
- onSubmitForm: handleAddArticleToChapter
6879
- }), selectedDeleteItem && React.createElement(ConfirmDialog, {
6880
- open: true,
6881
- toggle: handleCloseConfirmDeleteDialog,
6882
- text: selectedDeleteItem.confirmText,
6883
- confirmText: selectedDeleteItem.name,
6884
- onConfirm: handleRemoveSelectedItem,
6885
- isDelete: true
6886
- }));
6887
- };
6888
-
6889
- var useAutoAcademyDomain = function useAutoAcademyDomain(logout, history, superUrls, homeUrl, homeAcademyUrl) {
6890
- var searchParams = new URLSearchParams(window.location.search);
6891
- var user = useSelector(function (state) {
6892
- var _state$common;
6893
- return state === null || state === void 0 ? void 0 : (_state$common = state.common) === null || _state$common === void 0 ? void 0 : _state$common.user;
6894
- });
6895
- var initialAcademySearchParam = function initialAcademySearchParam() {
6896
- var paramAcademyDomain = searchParams.get("domain");
6897
- var domain = getAcademyDomain();
6898
- var pathname = window.location.pathname.toLowerCase();
6899
- if (!user) return;
6900
- var academyDomain = user.academyDomain;
6901
- if (!academyDomain) {
6902
- if (!superUrls.some(function (i) {
6903
- return pathname.startsWith(i);
6904
- })) {
6905
- pushTo({
6906
- pathname: homeUrl,
6907
- search: ""
6908
- });
6909
- }
6910
- if (domain) {
6911
- searchParams.append("domain", domain);
6912
- pushTo({
6913
- pathname: homeUrl,
6914
- search: ""
6915
- });
6916
- }
6917
- } else {
6918
- if (superUrls.some(function (i) {
6919
- return pathname.startsWith(i);
6920
- })) {
6921
- pushTo({
6922
- pathname: homeAcademyUrl,
6923
- search: ""
6924
- });
6925
- }
6926
- if (paramAcademyDomain && academyDomain.trim().toLocaleLowerCase() != (paramAcademyDomain === null || paramAcademyDomain === void 0 ? void 0 : paramAcademyDomain.trim().toLocaleLowerCase())) {
6927
- logout();
6928
- }
6929
- if (!paramAcademyDomain && academyDomain) {
6930
- searchParams.append("domain", academyDomain);
6931
- pushTo(_extends({}, window.location, {
6932
- search: searchParams.toString()
6933
- }));
6934
- }
7074
+ var styles$3 = {"drawer":"_11aYm","open":"_3Ydwm","drawer-overlay":"_3SQDf","drawer-header":"_2BwOx","drawer-form":"_2Zo7R","dropdown-content-academy":"_1lzjD","dropdown-change":"_1y7K9","dropdown-academy-item":"_1Y-55","dropdown-content-language":"_1fBXY","dropdown-item-language":"_3Szun","dropdown-item-language-active":"_2HhLb","item-address":"_3WYHC","item-logout":"_2-9ix","title-address":"_1r4pn","image-academy":"_2ZozT"};
7075
+
7076
+ var DURATION_OPTIONS = Array.from({
7077
+ length: 120
7078
+ }, function (_, i) {
7079
+ return i + 1;
7080
+ });
7081
+ var DEFAULT_ANSWER_COUNT$1 = 5;
7082
+
7083
+ var useExamDetailView = function useExamDetailView(props) {
7084
+ var exam = props.exam,
7085
+ selectedSubject = props.selectedSubject,
7086
+ onChangeExam = props.onChangeExam;
7087
+ var _useTranslation = useTranslation(),
7088
+ t = _useTranslation.t;
7089
+ var handleChangeQuestionCount = function handleChangeQuestionCount(article, questionCount, answerCount) {
7090
+ if (!exam) return;
7091
+ var examQuestions = exam.questions;
7092
+ var questions = examQuestions.filter(function (i) {
7093
+ return i.article === +article;
7094
+ });
7095
+ var prevQuestions = examQuestions.filter(function (i) {
7096
+ return i.article < +article;
7097
+ });
7098
+ var nextQuestions = examQuestions.filter(function (i) {
7099
+ return i.article > +article;
7100
+ });
7101
+ var lastOrder = questions[questions.length - 1].questionOrder;
7102
+ if (questions.length === questionCount) return;
7103
+ if (questions.length < questionCount) {
7104
+ var additionalQuestions = Array.from({
7105
+ length: questionCount - questions.length
7106
+ }).map(function (_, index) {
7107
+ var _questions$;
7108
+ return {
7109
+ article: +article,
7110
+ correctAnswers: [1],
7111
+ numberOfAnswers: answerCount,
7112
+ categoryId: (_questions$ = questions[0]) === null || _questions$ === void 0 ? void 0 : _questions$.categoryId,
7113
+ score: DEFAULT_SCORE,
7114
+ questionOrder: lastOrder + index + 1
7115
+ };
7116
+ });
7117
+ var newQuestions = [].concat(prevQuestions, questions, additionalQuestions, nextQuestions.map(function (i) {
7118
+ return _extends({}, i, {
7119
+ questionOrder: i.questionOrder + questionCount - questions.length
7120
+ });
7121
+ }));
7122
+ onChangeExam(_extends({}, exam, {
7123
+ questions: [].concat(newQuestions)
7124
+ }));
7125
+ } else {
7126
+ var remainQuestions = questions.slice(0, questionCount);
7127
+ var _newQuestions = [].concat(prevQuestions, remainQuestions, nextQuestions.map(function (i) {
7128
+ return _extends({}, i, {
7129
+ questionOrder: i.questionOrder - questions.length + questionCount
7130
+ });
7131
+ }));
7132
+ onChangeExam(_extends({}, exam, {
7133
+ questions: [].concat(_newQuestions)
7134
+ }));
6935
7135
  }
6936
7136
  };
6937
- var pushTo = function pushTo(data) {
6938
- if (history.push) history.push(data);else history(data);
6939
- };
6940
- useEffect(function () {
6941
- initialAcademySearchParam();
6942
- }, [window.location.pathname, user === null || user === void 0 ? void 0 : user.academyDomain]);
6943
- };
6944
-
6945
- var useList = function useList(fetchData, defaultQuery) {
6946
- var dispatch = useDispatch();
6947
- var _useState = useState(defaultQuery),
6948
- filter = _useState[0],
6949
- setFilter = _useState[1];
6950
- var _useState2 = useState(0),
6951
- totalPages = _useState2[0],
6952
- setTotalPages = _useState2[1];
6953
- var _useState3 = useState([]),
6954
- data = _useState3[0],
6955
- setData = _useState3[1];
6956
- var _useState4 = useState(),
6957
- selectedItem = _useState4[0],
6958
- setSelectedItem = _useState4[1];
6959
- var textSearchRef = useRef(null);
6960
- var isFirstLoadRef = useRef(true);
6961
- var handleChangeSelectedItem = function handleChangeSelectedItem(item) {
6962
- setSelectedItem(item);
6963
- };
6964
- var getData = function getData(isLoading) {
6965
- if (isLoading === void 0) {
6966
- isLoading = false;
6967
- }
6968
- try {
6969
- var _temp2 = function _temp2() {
6970
- isLoading && dispatch(setLoading(false));
6971
- };
6972
- if (isFirstLoadRef.current) isFirstLoadRef.current = false;
6973
- isLoading && dispatch(setLoading(true));
6974
- var _temp = _catch(function () {
6975
- return Promise.resolve(fetchData(filter)).then(function (res) {
6976
- var _res$data = res.data,
6977
- _res$data$items = _res$data.items,
6978
- items = _res$data$items === void 0 ? [] : _res$data$items,
6979
- _res$data$totalPages = _res$data.totalPages,
6980
- totalPages = _res$data$totalPages === void 0 ? 0 : _res$data$totalPages;
6981
- setTotalPages(totalPages);
6982
- setData(items);
6983
- });
6984
- }, function (error) {
6985
- var _error$response, _error$response$data;
6986
- setTotalPages(0);
6987
- setData([]);
6988
- toast.error((error === null || error === void 0 ? void 0 : (_error$response = error.response) === null || _error$response === void 0 ? void 0 : (_error$response$data = _error$response.data) === null || _error$response$data === void 0 ? void 0 : _error$response$data.title) || "Get data failed");
6989
- });
6990
- return Promise.resolve(_temp && _temp.then ? _temp.then(_temp2) : _temp2(_temp));
6991
- } catch (e) {
6992
- return Promise.reject(e);
6993
- }
6994
- };
6995
- var handleSort = function handleSort(sortColumnName) {
6996
- var sortColumnDirection = OrderType.ASC;
6997
- console.log({
6998
- sortColumnName: typeof sortColumnName,
6999
- filter: typeof filter.sortColumnName
7137
+ var handleChangeCategory = function handleChangeCategory(article, categoryId) {
7138
+ if (!exam) return;
7139
+ var examQuestions = exam.questions;
7140
+ var questions = examQuestions.filter(function (i) {
7141
+ return i.article === +article;
7000
7142
  });
7001
- if (filter.sortColumnName == sortColumnName && filter.sortColumnDirection === OrderType.ASC) sortColumnDirection = OrderType.DESC;
7002
- setFilter(_extends({}, filter, {
7003
- sortColumnName: sortColumnName,
7004
- sortColumnDirection: sortColumnDirection,
7005
- currentPage: 1
7006
- }));
7007
- };
7008
- var handleChangeSearchText = function handleChangeSearchText(e) {
7009
- if (!textSearchRef.current) return;
7010
- textSearchRef.current.value = e.target.value.trim();
7011
- debounceSearch();
7012
- };
7013
- var handleChangePage = function handleChangePage(_, page) {
7014
- setFilter(_extends({}, filter, {
7015
- currentPage: page
7016
- }));
7017
- };
7018
- var calcOrderNumber = function calcOrderNumber(index) {
7019
- var _filter$currentPage, _filter$pageSize;
7020
- return (((_filter$currentPage = filter.currentPage) != null ? _filter$currentPage : 0) - 1) * ((_filter$pageSize = filter.pageSize) != null ? _filter$pageSize : 0) + index + 1;
7021
- };
7022
- var debounceSearch = _.debounce(function () {
7023
- var _textSearchRef$curren;
7024
- setFilter(_extends({}, filter, {
7025
- currentPage: 1,
7026
- textSearch: (_textSearchRef$curren = textSearchRef.current) === null || _textSearchRef$curren === void 0 ? void 0 : _textSearchRef$curren.value
7143
+ var otherQuestions = examQuestions.filter(function (i) {
7144
+ return i.article !== +article;
7145
+ });
7146
+ onChangeExam(_extends({}, exam, {
7147
+ questions: [].concat(otherQuestions, questions.map(function (q) {
7148
+ return _extends({}, q, {
7149
+ categoryId: categoryId
7150
+ });
7151
+ }))
7027
7152
  }));
7028
- }, 500);
7029
- useEffect(function () {
7030
- getData(isFirstLoadRef.current);
7031
- }, [JSON.stringify(filter)]);
7032
- return {
7033
- filter: filter,
7034
- textSearchRef: textSearchRef,
7035
- totalPages: totalPages,
7036
- data: data,
7037
- selectedItem: selectedItem,
7038
- handleSort: handleSort,
7039
- handleChangeSearchText: handleChangeSearchText,
7040
- handleChangePage: handleChangePage,
7041
- calcOrderNumber: calcOrderNumber,
7042
- handleChangeSelectedItem: handleChangeSelectedItem,
7043
- getData: getData
7044
7153
  };
7045
- };
7046
-
7047
-
7048
-
7049
- var index$1 = {
7050
- __proto__: null,
7051
- useLogin: useLogin,
7052
- useAutoAcademyDomain: useAutoAcademyDomain,
7053
- useList: useList
7054
- };
7055
-
7056
- var useTextbookList = function useTextbookList(props) {
7057
- var role = props.role,
7058
- navigate = props.navigate;
7059
- var _useList = useList(function (search) {
7060
- return getTextbookListApi(search, role);
7061
- }, TextbookDefaultQuery),
7062
- filter = _useList.filter,
7063
- textSearchRef = _useList.textSearchRef,
7064
- totalPages = _useList.totalPages,
7065
- textbooks = _useList.data,
7066
- selectedTextbook = _useList.selectedItem,
7067
- handleSort = _useList.handleSort,
7068
- handleChangeSearchText = _useList.handleChangeSearchText,
7069
- handleChangePage = _useList.handleChangePage,
7070
- calcOrderNumber = _useList.calcOrderNumber,
7071
- handleChangeSelectedItem = _useList.handleChangeSelectedItem,
7072
- getData = _useList.getData;
7073
- var textbookUrl = role === Role.Teacher ? TEXTBOOK_URL$1 : ADMIN_TEXTBOOK_URL;
7074
- var dispatch = useDispatch();
7075
- var handleViewTextbook = function handleViewTextbook(id) {
7076
- navigate(textbookUrl + "/" + id + "?readonly=true", {
7077
- replace: true
7154
+ var handleDeleteArticle = function handleDeleteArticle(article) {
7155
+ if (!exam) return;
7156
+ var removedQuestions = exam.questions.filter(function (i) {
7157
+ return i.article === +article;
7158
+ }).map(function (i) {
7159
+ return i.questionOrder;
7160
+ });
7161
+ var max = Math.max.apply(Math, removedQuestions);
7162
+ var examQuestions = exam.questions.filter(function (i) {
7163
+ return i.article !== +article;
7164
+ }).map(function (i) {
7165
+ return _extends({}, i, {
7166
+ article: i.article > article ? i.article - 1 : i.article,
7167
+ questionOrder: i.questionOrder > max ? i.questionOrder - removedQuestions.length : i.questionOrder
7168
+ });
7078
7169
  });
7170
+ onChangeExam(_extends({}, exam, {
7171
+ questions: [].concat(examQuestions)
7172
+ }));
7079
7173
  };
7080
- var handleUpdateTextbook = function handleUpdateTextbook(id) {
7081
- navigate(textbookUrl + "/" + id, {
7082
- replace: true
7174
+ var handleChangeAnswerCount = function handleChangeAnswerCount(article, newAnswerCount, answerCount) {
7175
+ if (!exam) return;
7176
+ if (newAnswerCount === answerCount) return;
7177
+ var examQuestions = exam.questions;
7178
+ var questions = examQuestions.filter(function (i) {
7179
+ return i.article === +article;
7083
7180
  });
7181
+ var otherQuestions = examQuestions.filter(function (i) {
7182
+ return i.article !== +article;
7183
+ });
7184
+ if (answerCount < newAnswerCount) {
7185
+ onChangeExam(_extends({}, exam, {
7186
+ questions: [].concat(otherQuestions, questions.map(function (q) {
7187
+ return _extends({}, q, {
7188
+ numberOfAnswers: newAnswerCount
7189
+ });
7190
+ }))
7191
+ }));
7192
+ } else {
7193
+ onChangeExam(_extends({}, exam, {
7194
+ questions: [].concat(otherQuestions, questions.map(function (q) {
7195
+ var _q$correctAnswers;
7196
+ return _extends({}, q, {
7197
+ numberOfAnswers: newAnswerCount,
7198
+ correctAnswers: (_q$correctAnswers = q.correctAnswers) === null || _q$correctAnswers === void 0 ? void 0 : _q$correctAnswers.filter(function (i) {
7199
+ return i <= newAnswerCount;
7200
+ })
7201
+ });
7202
+ }))
7203
+ }));
7204
+ }
7084
7205
  };
7085
- var handleCreateTextbook = function handleCreateTextbook() {
7086
- navigate(textbookUrl + "/create", {
7087
- replace: true
7206
+ var handleChangeCorrectAnswers = function handleChangeCorrectAnswers(article, index, answer) {
7207
+ if (!exam) return;
7208
+ var examQuestions = exam.questions;
7209
+ var questions = examQuestions.filter(function (i) {
7210
+ return i.article === +article;
7088
7211
  });
7212
+ var otherQuestions = examQuestions.filter(function (i) {
7213
+ return i.article !== +article;
7214
+ });
7215
+ var selectedQuestion = questions[index];
7216
+ onChangeExam(_extends({}, exam, {
7217
+ questions: [].concat(otherQuestions, questions.slice(0, index), [_extends({}, selectedQuestion, {
7218
+ correctAnswers: [answer]
7219
+ })], questions.slice(index + 1))
7220
+ }));
7089
7221
  };
7090
- var toggleConfirmDialog = function toggleConfirmDialog() {
7091
- handleChangeSelectedItem(undefined);
7222
+ var handleChangeScoreAnswer = function handleChangeScoreAnswer(article, index, score) {
7223
+ if (!exam) return;
7224
+ var examQuestions = exam.questions;
7225
+ var questions = examQuestions.filter(function (i) {
7226
+ return i.article === +article;
7227
+ });
7228
+ var otherQuestions = examQuestions.filter(function (i) {
7229
+ return i.article !== +article;
7230
+ });
7231
+ var selectedQuestion = questions[index];
7232
+ if (score === selectedQuestion.score) return;
7233
+ onChangeExam(_extends({}, exam, {
7234
+ questions: [].concat(otherQuestions, questions.slice(0, index), [_extends({}, selectedQuestion, {
7235
+ score: score
7236
+ })], questions.slice(index + 1))
7237
+ }));
7092
7238
  };
7093
- var handleSelectDeleteTextbook = function handleSelectDeleteTextbook(textbook) {
7094
- return [handleChangeSelectedItem(textbook)];
7239
+ var handleChangeDuration = function handleChangeDuration(value) {
7240
+ if (!exam) return;
7241
+ onChangeExam(_extends({}, exam, {
7242
+ duration: value === null || value === void 0 ? void 0 : value.value
7243
+ }));
7095
7244
  };
7096
- var handleDeleteTextbook = function handleDeleteTextbook() {
7097
- try {
7098
- var _temp2 = function _temp2() {
7099
- dispatch(setLoading(false));
7100
- };
7101
- if (!(selectedTextbook !== null && selectedTextbook !== void 0 && selectedTextbook.id)) return Promise.resolve();
7102
- dispatch(setLoading(true));
7103
- var _temp = _catch(function () {
7104
- return Promise.resolve(deleteTextbookApi(selectedTextbook.id, role)).then(function () {
7105
- return Promise.resolve(getData(false)).then(function () {
7106
- toggleConfirmDialog();
7107
- });
7245
+ var handleChangeTitle = function handleChangeTitle(e) {
7246
+ if (!exam) return;
7247
+ onChangeExam(_extends({}, exam, {
7248
+ title: e.target.value
7249
+ }));
7250
+ };
7251
+ var handleAddArticle = function handleAddArticle() {
7252
+ var _$maxBy, _$maxBy2;
7253
+ if (!exam) return;
7254
+ var maxArticle = ((_$maxBy = _.maxBy(exam.questions, "article")) === null || _$maxBy === void 0 ? void 0 : _$maxBy.article) || 0;
7255
+ var maxOrder = ((_$maxBy2 = _.maxBy(exam.questions, "questionOrder")) === null || _$maxBy2 === void 0 ? void 0 : _$maxBy2.questionOrder) || 0;
7256
+ onChangeExam(_extends({}, exam, {
7257
+ questions: [].concat(exam.questions, [{
7258
+ article: maxArticle + 1,
7259
+ correctAnswers: [1],
7260
+ numberOfAnswers: DEFAULT_ANSWER_COUNT$1,
7261
+ score: DEFAULT_SCORE,
7262
+ questionOrder: maxOrder + 1
7263
+ }])
7264
+ }));
7265
+ };
7266
+ var examGroupByArticle = useMemo(function () {
7267
+ if (!exam) return [];
7268
+ var articles = [];
7269
+ var groupedArticle = _.groupBy(exam.questions, "article");
7270
+ for (var key in groupedArticle) {
7271
+ if (Object.prototype.hasOwnProperty.call(groupedArticle, key)) {
7272
+ var _questions$find, _$maxBy3;
7273
+ var questions = groupedArticle[key];
7274
+ articles.push({
7275
+ article: +key,
7276
+ categoryId: (_questions$find = questions.find(function (i) {
7277
+ return !!i.categoryId;
7278
+ })) === null || _questions$find === void 0 ? void 0 : _questions$find.categoryId,
7279
+ answerCount: ((_$maxBy3 = _.maxBy(questions, "numberOfAnswers")) === null || _$maxBy3 === void 0 ? void 0 : _$maxBy3.numberOfAnswers) || DEFAULT_ANSWER_COUNT$1,
7280
+ questionCount: questions.length,
7281
+ questions: questions
7108
7282
  });
7109
- }, function (error) {
7110
- var _error$response, _error$response$data;
7111
- toast.error((error === null || error === void 0 ? void 0 : (_error$response = error.response) === null || _error$response === void 0 ? void 0 : (_error$response$data = _error$response.data) === null || _error$response$data === void 0 ? void 0 : _error$response$data.title) || "Textbook deleted failed");
7112
- });
7113
- return Promise.resolve(_temp && _temp.then ? _temp.then(_temp2) : _temp2(_temp));
7114
- } catch (e) {
7115
- return Promise.reject(e);
7283
+ }
7116
7284
  }
7117
- };
7285
+ return _.sortBy(articles, "article");
7286
+ }, [JSON.stringify(exam)]);
7287
+ var durationOptions = useMemo(function () {
7288
+ var options = DURATION_OPTIONS.map(function (i) {
7289
+ return {
7290
+ label: i + "\uBD84",
7291
+ value: i
7292
+ };
7293
+ });
7294
+ if (!!exam.duration && exam.duration > DURATION_OPTIONS[DURATION_OPTIONS.length - 1]) return [].concat(options, [{
7295
+ label: exam.duration + "\uBD84",
7296
+ value: exam.duration
7297
+ }]);
7298
+ return options;
7299
+ }, [exam.duration]);
7300
+ useEffect(function () {
7301
+ if ((selectedSubject === null || selectedSubject === void 0 ? void 0 : selectedSubject.id) !== exam.subjectId) onChangeExam(_extends({}, exam, {
7302
+ subjectId: (selectedSubject === null || selectedSubject === void 0 ? void 0 : selectedSubject.id) || 0
7303
+ }));
7304
+ }, [selectedSubject === null || selectedSubject === void 0 ? void 0 : selectedSubject.id, exam.subjectId]);
7118
7305
  return {
7119
- filter: filter,
7120
- textSearchRef: textSearchRef,
7121
- totalPages: totalPages,
7122
- textbooks: textbooks,
7123
- selectedTextbook: selectedTextbook,
7124
- handleSort: handleSort,
7125
- handleChangeSearchText: handleChangeSearchText,
7126
- handleChangePage: handleChangePage,
7127
- calcOrderNumber: calcOrderNumber,
7128
- handleViewTextbook: handleViewTextbook,
7129
- handleUpdateTextbook: handleUpdateTextbook,
7130
- handleCreateTextbook: handleCreateTextbook,
7131
- toggleConfirmDialog: toggleConfirmDialog,
7132
- handleDeleteTextbook: handleDeleteTextbook,
7133
- handleSelectDeleteTextbook: handleSelectDeleteTextbook
7306
+ t: t,
7307
+ durationOptions: durationOptions,
7308
+ examGroupByArticle: examGroupByArticle,
7309
+ handleAddArticle: handleAddArticle,
7310
+ handleChangeScoreAnswer: handleChangeScoreAnswer,
7311
+ handleChangeTitle: handleChangeTitle,
7312
+ handleChangeDuration: handleChangeDuration,
7313
+ handleChangeCorrectAnswers: handleChangeCorrectAnswers,
7314
+ handleChangeAnswerCount: handleChangeAnswerCount,
7315
+ handleChangeQuestionCount: handleChangeQuestionCount,
7316
+ handleChangeCategory: handleChangeCategory,
7317
+ handleDeleteArticle: handleDeleteArticle
7134
7318
  };
7135
7319
  };
7136
7320
 
7137
- var EmptyRow = function EmptyRow() {
7321
+ var ExamDetailView = function ExamDetailView(_ref) {
7322
+ var _ref$className = _ref.className,
7323
+ className = _ref$className === void 0 ? "" : _ref$className,
7324
+ exam = _ref.exam,
7325
+ isDisabled = _ref.isDisabled,
7326
+ isEdit = _ref.isEdit,
7327
+ onChangeExam = _ref.onChangeExam;
7328
+ var _useSubjectSelect = useSubjectSelect(),
7329
+ subjectOptions = _useSubjectSelect.subjectOptions,
7330
+ selectedSubject = _useSubjectSelect.selectedSubject,
7331
+ handleChangeSubject = _useSubjectSelect.handleChangeSubject;
7332
+ var _useExamDetailView = useExamDetailView({
7333
+ exam: exam,
7334
+ onChangeExam: onChangeExam,
7335
+ selectedSubject: selectedSubject
7336
+ }),
7337
+ t = _useExamDetailView.t,
7338
+ durationOptions = _useExamDetailView.durationOptions,
7339
+ examGroupByArticle = _useExamDetailView.examGroupByArticle,
7340
+ handleAddArticle = _useExamDetailView.handleAddArticle,
7341
+ handleChangeScoreAnswer = _useExamDetailView.handleChangeScoreAnswer,
7342
+ handleChangeTitle = _useExamDetailView.handleChangeTitle,
7343
+ handleChangeDuration = _useExamDetailView.handleChangeDuration,
7344
+ handleChangeCorrectAnswers = _useExamDetailView.handleChangeCorrectAnswers,
7345
+ handleChangeAnswerCount = _useExamDetailView.handleChangeAnswerCount,
7346
+ handleChangeQuestionCount = _useExamDetailView.handleChangeQuestionCount,
7347
+ handleChangeCategory = _useExamDetailView.handleChangeCategory,
7348
+ handleDeleteArticle = _useExamDetailView.handleDeleteArticle;
7349
+ return React.createElement(Grid, {
7350
+ container: true,
7351
+ spacing: 3,
7352
+ className: className + " " + styles["custom-row"]
7353
+ }, React.createElement(Grid, {
7354
+ item: true,
7355
+ xs: 5,
7356
+ className: 'mb-2'
7357
+ }, React.createElement("label", {
7358
+ className: styles["form-label"] + " " + styles$2["question-label"],
7359
+ htmlFor: "title"
7360
+ }, t("title")), React.createElement("input", {
7361
+ disabled: isDisabled,
7362
+ className: "" + styles["form-control"],
7363
+ value: exam.title,
7364
+ id: "title",
7365
+ placeholder: t("enter_title"),
7366
+ onChange: handleChangeTitle
7367
+ })), React.createElement(Grid, {
7368
+ item: true,
7369
+ xs: 3,
7370
+ className: 'mb-2'
7371
+ }, React.createElement("label", {
7372
+ className: styles["form-label"] + " " + styles$2["question-label"],
7373
+ htmlFor: "duration"
7374
+ }, t("duration")), React.createElement(CustomSelect, {
7375
+ inputId: "duration",
7376
+ value: exam.duration,
7377
+ options: durationOptions,
7378
+ onChange: handleChangeDuration,
7379
+ isDisabled: isDisabled
7380
+ })), React.createElement(Grid, {
7381
+ item: true,
7382
+ xs: 3,
7383
+ className: 'mb-2'
7384
+ }, React.createElement("label", {
7385
+ className: styles["form-label"] + " " + styles$2["question-label"],
7386
+ htmlFor: "duration"
7387
+ }, t("subject"), " ", selectedSubject === null || selectedSubject === void 0 ? void 0 : selectedSubject.name), React.createElement(CustomSelect, {
7388
+ inputId: "subject",
7389
+ value: selectedSubject === null || selectedSubject === void 0 ? void 0 : selectedSubject.id,
7390
+ options: subjectOptions,
7391
+ onChange: handleChangeSubject,
7392
+ isDisabled: isDisabled || isEdit
7393
+ })), examGroupByArticle.map(function (i, index) {
7394
+ return React.createElement(Grid, {
7395
+ item: true,
7396
+ key: i.article,
7397
+ xs: 12,
7398
+ className: index === examGroupByArticle.length - 1 ? "mb-2" : ''
7399
+ }, React.createElement(ArticleGroupView, Object.assign({}, i, {
7400
+ isActive: index === examGroupByArticle.length - 1,
7401
+ onChangeQuestionCount: handleChangeQuestionCount,
7402
+ onChangeCategory: handleChangeCategory,
7403
+ onChangeAnswerCount: handleChangeAnswerCount,
7404
+ onChangeCorrectAnswers: handleChangeCorrectAnswers,
7405
+ onChangeScoreAnswer: handleChangeScoreAnswer,
7406
+ onDelete: handleDeleteArticle,
7407
+ isDisabled: isDisabled,
7408
+ selectedSubject: selectedSubject,
7409
+ isDeletable: examGroupByArticle.length > 1
7410
+ })));
7411
+ }), React.createElement(Grid, {
7412
+ item: true,
7413
+ xs: 12
7414
+ }, React.createElement("button", {
7415
+ disabled: isDisabled,
7416
+ className: styles["btn-outline-primary"] + " w-100 d-flex justify-content-center align-items-center " + styles$2["question-btn"] + " mt-3",
7417
+ onClick: handleAddArticle
7418
+ }, React.createElement(FaPlusCircle, {
7419
+ className: "me-2"
7420
+ }), "\uBB38\uD56D \uCD94\uAC00\uD558\uAE30")));
7421
+ };
7422
+
7423
+ var _excluded$4 = ["isOpen", "onClose", "handleSaveExam"];
7424
+ var CreateExamDrawer = function CreateExamDrawer(props) {
7425
+ var isOpen = props.isOpen,
7426
+ onClose = props.onClose,
7427
+ handleSaveExam = props.handleSaveExam,
7428
+ examDetailViewProps = _objectWithoutPropertiesLoose(props, _excluded$4);
7138
7429
  var _useTranslation = useTranslation(),
7139
7430
  t = _useTranslation.t;
7140
- return React.createElement(TableRow, null, React.createElement(TableCell, {
7141
- colSpan: 12,
7142
- className: "text-center text-muted"
7143
- }, t("no_data")));
7431
+ var theme = useTheme();
7432
+ var isTabletUp = useMediaQuery(theme.breakpoints.up('lg'));
7433
+ return React.createElement("div", null, React.createElement("div", {
7434
+ className: styles$3["drawer-overlay"] + " " + (isOpen && styles$3["open"]),
7435
+ onClick: function onClick() {
7436
+ return onClose();
7437
+ }
7438
+ }), React.createElement("div", {
7439
+ className: styles$3["drawer"] + " bg-white " + (isOpen && styles$3["open"]),
7440
+ style: {
7441
+ width: "" + (isTabletUp ? "70vw" : "100vw")
7442
+ }
7443
+ }, React.createElement("div", {
7444
+ className: styles$3["drawer-header"] + " d-flex justify-content-between align-items-center"
7445
+ }, React.createElement("div", {
7446
+ style: {
7447
+ color: "#5458D5",
7448
+ cursor: "pointer",
7449
+ padding: "0.5rem 1rem",
7450
+ border: "1px solid #5458D5",
7451
+ backgroundColor: "white",
7452
+ justifyContent: "center",
7453
+ alignItems: "center",
7454
+ borderRadius: "6px"
7455
+ },
7456
+ onClick: handleSaveExam
7457
+ }, t("live_exam")), React.createElement("span", {
7458
+ className: "p-1 pointer",
7459
+ onClick: function onClick() {
7460
+ return onClose();
7461
+ }
7462
+ }, React.createElement(FaTimes, {
7463
+ size: 18
7464
+ }))), React.createElement("div", {
7465
+ className: "" + styles$3["drawer-form"]
7466
+ }, React.createElement(ExamDetailView, Object.assign({}, examDetailViewProps)))));
7144
7467
  };
7145
7468
 
7146
- var LayoutList = function LayoutList(_ref) {
7147
- var children = _ref.children,
7148
- title = _ref.title;
7149
- return React.createElement(Box, {
7150
- className: 'bg-white p-3'
7469
+ var TextbookViewDetail = function TextbookViewDetail(props) {
7470
+ var _textbook$chapters;
7471
+ var _useTextbookDetail = useTextbookDetail(props),
7472
+ id = _useTextbookDetail.id,
7473
+ t = _useTextbookDetail.t,
7474
+ textbook = _useTextbookDetail.textbook,
7475
+ textbookSubject = _useTextbookDetail.textbookSubject,
7476
+ isReadonly = _useTextbookDetail.isReadonly,
7477
+ isNotFound = _useTextbookDetail.isNotFound,
7478
+ parentChapter = _useTextbookDetail.parentChapter,
7479
+ textbookId = _useTextbookDetail.textbookId,
7480
+ selectedChapter = _useTextbookDetail.selectedChapter,
7481
+ articlesSelected = _useTextbookDetail.articlesSelected,
7482
+ selectedDeleteItem = _useTextbookDetail.selectedDeleteItem,
7483
+ isEditedTitle = _useTextbookDetail.isEditedTitle,
7484
+ isOpenDialog = _useTextbookDetail.isOpenDialog,
7485
+ examRequest = _useTextbookDetail.examRequest,
7486
+ handleChangeExamRequest = _useTextbookDetail.handleChangeExamRequest,
7487
+ handleSaveExam = _useTextbookDetail.handleSaveExam,
7488
+ handleCloseDialog = _useTextbookDetail.handleCloseDialog,
7489
+ handleCreateExam = _useTextbookDetail.handleCreateExam,
7490
+ handleCheckArticle = _useTextbookDetail.handleCheckArticle,
7491
+ handleChangeTextbookTitle = _useTextbookDetail.handleChangeTextbookTitle,
7492
+ handleOpenCreateExamDialog = _useTextbookDetail.handleOpenCreateExamDialog,
7493
+ handleChangeTextbookSubject = _useTextbookDetail.handleChangeTextbookSubject,
7494
+ handleGoToTextbookList = _useTextbookDetail.handleGoToTextbookList,
7495
+ handleCreateOrUpdateTextbook = _useTextbookDetail.handleCreateOrUpdateTextbook,
7496
+ handleCloseChapterNameDialog = _useTextbookDetail.handleCloseChapterNameDialog,
7497
+ handleCreateChapter = _useTextbookDetail.handleCreateChapter,
7498
+ handleAddChapterToTextbook = _useTextbookDetail.handleAddChapterToTextbook,
7499
+ handleAddChapterToParentSubchapter = _useTextbookDetail.handleAddChapterToParentSubchapter,
7500
+ handleChangeChapterName = _useTextbookDetail.handleChangeChapterName,
7501
+ handleChangeChapterPageFrom = _useTextbookDetail.handleChangeChapterPageFrom,
7502
+ handleChangeChapterPageTo = _useTextbookDetail.handleChangeChapterPageTo,
7503
+ handleAddArticleToChapter = _useTextbookDetail.handleAddArticleToChapter,
7504
+ handleUpdateArticleQuestionCountFromChapter = _useTextbookDetail.handleUpdateArticleQuestionCountFromChapter,
7505
+ handleUpdateArticleCategory = _useTextbookDetail.handleUpdateArticleCategory,
7506
+ handleUpdateArticleAnswerCount = _useTextbookDetail.handleUpdateArticleAnswerCount,
7507
+ handleUpdateArticleQuestion = _useTextbookDetail.handleUpdateArticleQuestion,
7508
+ handleCloseArticleDialog = _useTextbookDetail.handleCloseArticleDialog,
7509
+ handleOpenAddArticleDialog = _useTextbookDetail.handleOpenAddArticleDialog,
7510
+ handleOpenRemoveArticleConfirmDialog = _useTextbookDetail.handleOpenRemoveArticleConfirmDialog,
7511
+ handleCloseConfirmDeleteDialog = _useTextbookDetail.handleCloseConfirmDeleteDialog,
7512
+ handleRemoveSelectedItem = _useTextbookDetail.handleRemoveSelectedItem,
7513
+ handleOpenRemoveChapterConfirmDialog = _useTextbookDetail.handleOpenRemoveChapterConfirmDialog;
7514
+ var _useCategorySelect = useCategorySelect({
7515
+ subjectId: id ? textbookSubject === null || textbookSubject === void 0 ? void 0 : textbookSubject.value : undefined
7516
+ }),
7517
+ categoryOptions = _useCategorySelect.categoryOptions;
7518
+ if (isNotFound) return React.createElement(NotFound, null);
7519
+ return React.createElement(Container, {
7520
+ maxWidth: "xl",
7521
+ className: "bg-white py-5 p-4 rounded-4 h-100 d-flex flex-column"
7151
7522
  }, React.createElement(Stack, {
7152
7523
  direction: "row",
7153
7524
  alignItems: "center",
7154
7525
  justifyContent: "space-between",
7155
7526
  mb: 2
7156
7527
  }, React.createElement(Typography, {
7157
- variant: 'h4'
7158
- }, title)), React.createElement(Box, null, children));
7159
- };
7160
-
7161
- var SortIcon = function SortIcon(_ref) {
7162
- var isAscending = _ref.isAscending,
7163
- onClick = _ref.onClick;
7164
- return React.createElement("div", {
7165
- className: "d-flex flex-column " + styles["sort-icons"],
7166
- onClick: onClick
7167
- }, React.createElement(FaSortUp, {
7168
- className: isAscending === true ? styles["active"] : ""
7169
- }), React.createElement(FaSortDown, {
7170
- className: isAscending === false ? styles["active"] : ""
7171
- }));
7172
- };
7173
-
7174
- var TableHeader = function TableHeader(_ref) {
7175
- var headerTemplates = _ref.headerTemplates,
7176
- filter = _ref.filter,
7177
- onSort = _ref.onSort;
7178
- var _useTranslation = useTranslation(),
7179
- t = _useTranslation.t;
7180
- return React.createElement(TableHead, null, React.createElement(TableRow, null, headerTemplates.map(function (i, index$1) {
7181
- return React.createElement(TableCell, {
7182
- key: index$1,
7183
- className: "" + (!!i.sortKey && "pointer"),
7184
- onClick: !!i.sortKey ? function () {
7185
- return onSort === null || onSort === void 0 ? void 0 : onSort(i.sortKey);
7186
- } : undefined
7187
- }, React.createElement("div", {
7188
- className: "d-flex justify-content-between align-items-center text-nowrap"
7189
- }, t(i.title), !!i.sortKey && React.createElement(SortIcon, {
7190
- isAscending: filter.sortColumnName !== i.sortKey ? undefined : filter.sortColumnDirection === OrderType.ASC
7191
- })));
7192
- })));
7193
- };
7194
-
7195
- var SearchInput = function SearchInput(_ref) {
7196
- var textSearchRef = _ref.textSearchRef,
7197
- _ref$placeholder = _ref.placeholder,
7198
- placeholder = _ref$placeholder === void 0 ? "Search for..." : _ref$placeholder,
7199
- onChange = _ref.onChange,
7200
- _ref$fit = _ref.fit,
7201
- fit = _ref$fit === void 0 ? true : _ref$fit;
7202
- return React.createElement(Paper, {
7203
- component: "div",
7204
- className: "bg-light w-100 " + (fit && "h-100"),
7528
+ variant: "h3"
7529
+ }, t(id ? isReadonly ? "view_textbook" : "update_textbook" : "create_textbook"))), React.createElement(Grid, {
7530
+ container: true,
7531
+ spacing: 3
7532
+ }, React.createElement(Grid, {
7533
+ item: true,
7534
+ xs: 4,
7535
+ className: "d-flex align-items-center"
7536
+ }, React.createElement(Table, null, React.createElement(TableBody, null, React.createElement(TableRow, {
7205
7537
  sx: {
7206
- p: "2px 4px",
7207
- display: "flex",
7208
- alignItems: "center",
7209
- width: 400,
7210
- transition: "border 0.2s ease",
7211
- outline: "1px solid transparent",
7212
- ":focus-within": {
7213
- outlineColor: function outlineColor(theme) {
7214
- return theme.palette.primary.main;
7215
- }
7538
+ "& td": {
7539
+ border: 0
7216
7540
  }
7217
7541
  }
7218
- }, React.createElement(Box, {
7542
+ }, React.createElement(TableCell, {
7543
+ className: "p-2 pe-0",
7219
7544
  sx: {
7220
- p: "10px"
7221
- },
7222
- "aria-label": "search"
7223
- }, React.createElement(IoSearch, {
7224
- size: 24,
7225
- className: "pb-1"
7226
- })), React.createElement(InputBase, {
7227
- id: "searchText",
7228
- className: "" + (fit && "h-100"),
7545
+ width: "15%"
7546
+ }
7547
+ }, React.createElement(InputLabel, null, React.createElement("span", {
7548
+ className: "fw-bold"
7549
+ }, t("name")), React.createElement("span", {
7550
+ className: "text-danger"
7551
+ }, "*"))), React.createElement(TableCell, {
7229
7552
  sx: {
7230
- ml: 1,
7231
- flex: 1,
7232
- lineHeight: 1
7233
- },
7234
- placeholder: placeholder,
7235
- ref: textSearchRef,
7236
- onChange: onChange
7237
- }));
7238
- };
7239
-
7240
- var TextbookList = function TextbookList(props) {
7241
- var _useTranslation = useTranslation(),
7242
- t = _useTranslation.t;
7243
- var _useTextbookList = useTextbookList(props),
7244
- filter = _useTextbookList.filter,
7245
- textbooks = _useTextbookList.textbooks,
7246
- totalPages = _useTextbookList.totalPages,
7247
- textSearchRef = _useTextbookList.textSearchRef,
7248
- selectedTextbook = _useTextbookList.selectedTextbook,
7249
- handleChangeSearchText = _useTextbookList.handleChangeSearchText,
7250
- handleSort = _useTextbookList.handleSort,
7251
- handleChangePage = _useTextbookList.handleChangePage,
7252
- calcOrderNumber = _useTextbookList.calcOrderNumber,
7253
- handleViewTextbook = _useTextbookList.handleViewTextbook,
7254
- handleUpdateTextbook = _useTextbookList.handleUpdateTextbook,
7255
- handleCreateTextbook = _useTextbookList.handleCreateTextbook,
7256
- toggleConfirmDialog = _useTextbookList.toggleConfirmDialog,
7257
- handleDeleteTextbook = _useTextbookList.handleDeleteTextbook,
7258
- handleSelectDeleteTextbook = _useTextbookList.handleSelectDeleteTextbook;
7259
- return React.createElement(LayoutList, {
7260
- title: t(TEXTBOOK_PAGE_TITLE)
7261
- }, React.createElement(Grid, {
7262
- container: true
7263
- }, React.createElement(Grid, {
7553
+ width: 0,
7554
+ px: 1
7555
+ }
7556
+ }, ":"), React.createElement(TableCell, {
7557
+ className: "p-2"
7558
+ }, React.createElement(InputText, {
7559
+ className: "w-100",
7560
+ value: textbook === null || textbook === void 0 ? void 0 : textbook.name,
7561
+ placeholder: t("enter_textbook_title"),
7562
+ onChange: handleChangeTextbookTitle,
7563
+ disabled: isReadonly
7564
+ }))), React.createElement(TableRow, {
7565
+ sx: {
7566
+ "& td": {
7567
+ border: 0
7568
+ }
7569
+ }
7570
+ }, React.createElement(TableCell, {
7571
+ className: "p-2 pe-0"
7572
+ }, React.createElement(InputLabel, null, React.createElement("span", {
7573
+ className: "fw-bold"
7574
+ }, t("subject")), React.createElement("span", {
7575
+ className: "text-danger"
7576
+ }, "*"))), React.createElement(TableCell, {
7577
+ sx: {
7578
+ width: 0,
7579
+ px: 1
7580
+ }
7581
+ }, ":"), React.createElement(TableCell, {
7582
+ className: "p-2"
7583
+ }, React.createElement(SubjectSelector, {
7584
+ value: textbookSubject,
7585
+ onChange: handleChangeTextbookSubject,
7586
+ isDisabled: isReadonly || !!id
7587
+ })))))), React.createElement(Grid, {
7264
7588
  item: true,
7265
- xs: 6
7266
- }, React.createElement(SearchInput, {
7267
- textSearchRef: textSearchRef,
7268
- onChange: handleChangeSearchText,
7269
- placeholder: t(TEXT_BOOK_SEARCH_PLACEHOLDER)
7270
- })), React.createElement(Grid, {
7589
+ xs: 8,
7590
+ className: "d-flex justify-content-end"
7591
+ }, React.createElement("div", null, React.createElement(TextbookActionButtons, {
7592
+ isReadonly: isReadonly,
7593
+ textbook: textbook,
7594
+ onBack: handleGoToTextbookList,
7595
+ onSave: handleCreateOrUpdateTextbook,
7596
+ hideSave: !isEditedTitle && !!id && !isReadonly || textbook.isCreatedByAdmin
7597
+ }))), React.createElement(Grid, {
7271
7598
  item: true,
7272
- xs: 6
7273
- }, React.createElement(Stack, {
7274
- alignItems: "end"
7599
+ xs: 12,
7600
+ gap: "8px",
7601
+ className: "d-flex justify-content-end"
7275
7602
  }, React.createElement(Button, {
7603
+ variant: "outlined",
7604
+ sx: {
7605
+ borderColor: "#5458D5",
7606
+ color: "#5458D5"
7607
+ },
7608
+ onClick: function onClick() {
7609
+ return handleOpenCreateExamDialog();
7610
+ },
7611
+ disabled: isReadonly || !articlesSelected.length,
7276
7612
  startIcon: React.createElement(FaPlus, {
7277
7613
  size: 12
7278
- }),
7614
+ })
7615
+ }, React.createElement(Typography, null, t("create_new_exam"))), !!id && React.createElement(Button, {
7616
+ className: "mx-1",
7279
7617
  variant: "contained",
7280
7618
  color: "primary",
7281
- onClick: handleCreateTextbook
7282
- }, t("create_textbook")))), React.createElement(Grid, {
7283
- item: true,
7284
- xs: 12,
7285
- className: "mt-3"
7286
- }, React.createElement(Table, null, React.createElement(TableHeader, {
7287
- headerTemplates: TEXTBOOK_HEADERS,
7288
- filter: filter,
7289
- onSort: handleSort
7290
- }), React.createElement(TableBody, null, textbooks.map(function (i, index) {
7291
- return React.createElement(TableRow, {
7292
- key: i.id
7293
- }, React.createElement(TableCell, null, calcOrderNumber(index)), React.createElement(TableCell, null, i.name), React.createElement(TableCell, null, i.subject.name), React.createElement(TableCell, null, utcToLocalTime(i.createdAt, t("date_format"))), React.createElement(TableCell, null, i.totalChapters), React.createElement(TableCell, null, React.createElement(Stack, {
7294
- direction: "row",
7295
- spacing: 1,
7296
- alignItems: "center"
7297
- }, !i.isCreatedByAdmin && React.createElement(IconButton, {
7298
- color: "default",
7299
- className: "bg-warning text-white",
7300
- onClick: function onClick() {
7301
- return handleUpdateTextbook(i.id);
7302
- }
7303
- }, React.createElement(FaPencil, {
7304
- size: 12
7305
- })), React.createElement(IconButton, {
7306
- color: "default",
7307
- className: "bg-primary text-white",
7308
- onClick: function onClick() {
7309
- return handleViewTextbook(i.id);
7310
- }
7311
- }, React.createElement(FaEye, {
7312
- size: 12
7313
- })), !i.isCreatedByAdmin && React.createElement(IconButton, {
7314
- color: "default",
7315
- className: "bg-danger text-white",
7316
- onClick: function onClick() {
7317
- return handleSelectDeleteTextbook(i);
7318
- }
7319
- }, React.createElement(FaTrash, {
7619
+ startIcon: React.createElement(FaPlus, {
7320
7620
  size: 12
7321
- })))));
7322
- }), !textbooks.length && React.createElement(EmptyRow, null))), React.createElement("div", {
7323
- className: "d-flex justify-content-end mt-3"
7324
- }, !!totalPages && React.createElement(Pagination, {
7325
- count: totalPages,
7326
- page: filter.currentPage,
7327
- onChange: handleChangePage
7328
- })))), React.createElement(ConfirmDialog, {
7329
- open: !!(selectedTextbook !== null && selectedTextbook !== void 0 && selectedTextbook.id),
7330
- toggle: toggleConfirmDialog,
7331
- text: "" + t("are_you_sure_you_want_to_delete_the_textbook"),
7332
- onConfirm: handleDeleteTextbook,
7333
- confirmText: selectedTextbook === null || selectedTextbook === void 0 ? void 0 : selectedTextbook.name,
7621
+ }),
7622
+ onClick: handleAddChapterToTextbook,
7623
+ disabled: isReadonly
7624
+ }, t("add_chapter"))), React.createElement(Grid, {
7625
+ item: true,
7626
+ xs: 12
7627
+ }, React.createElement(Stack, {
7628
+ spacing: 3
7629
+ }, !!(textbook !== null && textbook !== void 0 && textbook.subject) && (textbook === null || textbook === void 0 ? void 0 : (_textbook$chapters = textbook.chapters) === null || _textbook$chapters === void 0 ? void 0 : _textbook$chapters.map(function (chapter) {
7630
+ return React.createElement(ChapterBox, {
7631
+ key: chapter.id,
7632
+ subject: textbook.subject,
7633
+ data: chapter,
7634
+ categoryOptions: categoryOptions || [],
7635
+ onClickAddSubchapter: handleAddChapterToParentSubchapter,
7636
+ onChangeName: handleChangeChapterName,
7637
+ onChangePageFrom: handleChangeChapterPageFrom,
7638
+ onChangePageTo: handleChangeChapterPageTo,
7639
+ handleCheckArticle: handleCheckArticle,
7640
+ onAddArticle: handleOpenAddArticleDialog,
7641
+ onRemoveArticle: handleOpenRemoveArticleConfirmDialog,
7642
+ onUpdateArticleQuestionCount: handleUpdateArticleQuestionCountFromChapter,
7643
+ onUpdateArticleCategory: handleUpdateArticleCategory,
7644
+ onUpdateArticleQuestionAnswerCount: handleUpdateArticleAnswerCount,
7645
+ onUpdateArticleQuestion: handleUpdateArticleQuestion,
7646
+ onRemoveChapter: handleOpenRemoveChapterConfirmDialog,
7647
+ isReadonly: isReadonly
7648
+ });
7649
+ }))))), React.createElement(ChapterNameDialog, {
7650
+ open: !!(parentChapter !== null && parentChapter !== void 0 && parentChapter.id) || !!textbookId,
7651
+ chapter: parentChapter,
7652
+ onClose: handleCloseChapterNameDialog,
7653
+ onSubmitForm: handleCreateChapter
7654
+ }), React.createElement(CreateExamDrawer, {
7655
+ isOpen: isOpenDialog,
7656
+ onClose: handleCloseDialog,
7657
+ onSubmit: handleCreateExam,
7658
+ handleSaveExam: handleSaveExam,
7659
+ exam: examRequest,
7660
+ onChangeExam: handleChangeExamRequest
7661
+ }), React.createElement(ArticleDialog, {
7662
+ open: !!selectedChapter,
7663
+ chapter: selectedChapter,
7664
+ categoryOptions: categoryOptions || [],
7665
+ onClose: handleCloseArticleDialog,
7666
+ onSubmitForm: handleAddArticleToChapter
7667
+ }), selectedDeleteItem && React.createElement(ConfirmDialog, {
7668
+ open: true,
7669
+ toggle: handleCloseConfirmDeleteDialog,
7670
+ text: selectedDeleteItem.confirmText,
7671
+ confirmText: selectedDeleteItem.name,
7672
+ onConfirm: handleRemoveSelectedItem,
7334
7673
  isDelete: true
7335
7674
  }));
7336
7675
  };
7337
7676
 
7338
-
7339
-
7340
- var index$2 = {
7341
- __proto__: null,
7342
- TextbookList: TextbookList,
7343
- TextbookDetail: TextbookViewDetail
7344
- };
7345
-
7346
- var _excluded$4 = ["defaultValue", "options", "isDisabled", "scrollBottom", "value", "isMulti"];
7347
- var CustomCreatable = function CustomCreatable(_ref) {
7348
- var options = _ref.options,
7349
- isDisabled = _ref.isDisabled,
7350
- scrollBottom = _ref.scrollBottom,
7351
- value = _ref.value,
7352
- isMulti = _ref.isMulti,
7353
- rest = _objectWithoutPropertiesLoose(_ref, _excluded$4);
7354
- var initialValues = Array.isArray(value) ? options.filter(function (i) {
7355
- return value.includes(i.value);
7356
- }) : isMulti ? options.filter(function (i) {
7357
- return i.value == value;
7358
- }) : options.find(function (i) {
7359
- return i.value == value;
7360
- });
7361
- return React.createElement(CreatableSelect, Object.assign({
7362
- isClearable: true,
7363
- isDisabled: isDisabled,
7364
- options: options,
7365
- value: initialValues,
7366
- menuPlacement: scrollBottom ? "top" : "auto",
7367
- isMulti: isMulti
7368
- }, rest));
7369
- };
7370
-
7371
- var _excluded$5 = ["isDefault", "defaultValue", "options", "isDisabled", "scrollBottom", "value", "isMulti"];
7372
- var CustomAsyncSelect = function CustomAsyncSelect(_ref) {
7373
- var isDefault = _ref.isDefault,
7374
- options = _ref.options,
7375
- isDisabled = _ref.isDisabled,
7376
- scrollBottom = _ref.scrollBottom,
7377
- value = _ref.value,
7378
- isMulti = _ref.isMulti,
7379
- rest = _objectWithoutPropertiesLoose(_ref, _excluded$5);
7380
- var initialValues = Array.isArray(value) ? options.filter(function (i) {
7381
- return value.includes(i.value);
7382
- }) : isMulti ? options.filter(function (i) {
7383
- return i.value == value;
7384
- }) : options.find(function (i) {
7385
- return i.value == value;
7677
+ var useAutoAcademyDomain = function useAutoAcademyDomain(logout, history, superUrls, homeUrl, homeAcademyUrl) {
7678
+ var searchParams = new URLSearchParams(window.location.search);
7679
+ var user = useSelector(function (state) {
7680
+ var _state$common;
7681
+ return state === null || state === void 0 ? void 0 : (_state$common = state.common) === null || _state$common === void 0 ? void 0 : _state$common.user;
7386
7682
  });
7387
- return React.createElement(Select, Object.assign({
7388
- isDisabled: isDisabled,
7389
- options: options,
7390
- value: !isDefault ? initialValues : undefined,
7391
- defaultValue: isDefault ? initialValues : undefined,
7392
- menuPlacement: scrollBottom ? "top" : "auto",
7393
- isMulti: isMulti
7394
- }, rest));
7395
- };
7396
-
7397
- var DURATION_OPTIONS = Array.from({
7398
- length: 120
7399
- }, function (_, i) {
7400
- return i + 1;
7401
- });
7402
- var DEFAULT_ANSWER_COUNT = 5;
7403
-
7404
- var useExamDetailView = function useExamDetailView(props) {
7405
- var exam = props.exam,
7406
- selectedSubject = props.selectedSubject,
7407
- onChangeExam = props.onChangeExam;
7408
- var _useTranslation = useTranslation(),
7409
- t = _useTranslation.t;
7410
- var handleChangeQuestionCount = function handleChangeQuestionCount(article, questionCount, answerCount) {
7411
- if (!exam) return;
7412
- var examQuestions = exam.questions;
7413
- var questions = examQuestions.filter(function (i) {
7414
- return i.article === +article;
7415
- });
7416
- var prevQuestions = examQuestions.filter(function (i) {
7417
- return i.article < +article;
7418
- });
7419
- var nextQuestions = examQuestions.filter(function (i) {
7420
- return i.article > +article;
7421
- });
7422
- var lastOrder = questions[questions.length - 1].questionOrder;
7423
- if (questions.length === questionCount) return;
7424
- if (questions.length < questionCount) {
7425
- var additionalQuestions = Array.from({
7426
- length: questionCount - questions.length
7427
- }).map(function (_, index) {
7428
- var _questions$;
7429
- return {
7430
- article: +article,
7431
- correctAnswers: [1],
7432
- numberOfAnswers: answerCount,
7433
- categoryId: (_questions$ = questions[0]) === null || _questions$ === void 0 ? void 0 : _questions$.categoryId,
7434
- score: DEFAULT_SCORE,
7435
- questionOrder: lastOrder + index + 1
7436
- };
7437
- });
7438
- var newQuestions = [].concat(prevQuestions, questions, additionalQuestions, nextQuestions.map(function (i) {
7439
- return _extends({}, i, {
7440
- questionOrder: i.questionOrder + questionCount - questions.length
7683
+ var initialAcademySearchParam = function initialAcademySearchParam() {
7684
+ var paramAcademyDomain = searchParams.get("domain");
7685
+ var domain = getAcademyDomain();
7686
+ var pathname = window.location.pathname.toLowerCase();
7687
+ if (!user) return;
7688
+ var academyDomain = user.academyDomain;
7689
+ if (!academyDomain) {
7690
+ if (!superUrls.some(function (i) {
7691
+ return pathname.startsWith(i);
7692
+ })) {
7693
+ pushTo({
7694
+ pathname: homeUrl,
7695
+ search: ""
7696
+ });
7697
+ }
7698
+ if (domain) {
7699
+ searchParams.append("domain", domain);
7700
+ pushTo({
7701
+ pathname: homeUrl,
7702
+ search: ""
7441
7703
  });
7442
- }));
7443
- onChangeExam(_extends({}, exam, {
7444
- questions: [].concat(newQuestions)
7445
- }));
7704
+ }
7446
7705
  } else {
7447
- var remainQuestions = questions.slice(0, questionCount);
7448
- var _newQuestions = [].concat(prevQuestions, remainQuestions, nextQuestions.map(function (i) {
7449
- return _extends({}, i, {
7450
- questionOrder: i.questionOrder - questions.length + questionCount
7706
+ if (superUrls.some(function (i) {
7707
+ return pathname.startsWith(i);
7708
+ })) {
7709
+ pushTo({
7710
+ pathname: homeAcademyUrl,
7711
+ search: ""
7451
7712
  });
7452
- }));
7453
- onChangeExam(_extends({}, exam, {
7454
- questions: [].concat(_newQuestions)
7455
- }));
7713
+ }
7714
+ if (paramAcademyDomain && academyDomain.trim().toLocaleLowerCase() != (paramAcademyDomain === null || paramAcademyDomain === void 0 ? void 0 : paramAcademyDomain.trim().toLocaleLowerCase())) {
7715
+ logout();
7716
+ }
7717
+ if (!paramAcademyDomain && academyDomain) {
7718
+ searchParams.append("domain", academyDomain);
7719
+ pushTo(_extends({}, window.location, {
7720
+ search: searchParams.toString()
7721
+ }));
7722
+ }
7456
7723
  }
7457
7724
  };
7458
- var handleChangeCategory = function handleChangeCategory(article, categoryId) {
7459
- if (!exam) return;
7460
- var examQuestions = exam.questions;
7461
- var questions = examQuestions.filter(function (i) {
7462
- return i.article === +article;
7463
- });
7464
- var otherQuestions = examQuestions.filter(function (i) {
7465
- return i.article !== +article;
7466
- });
7467
- onChangeExam(_extends({}, exam, {
7468
- questions: [].concat(otherQuestions, questions.map(function (q) {
7469
- return _extends({}, q, {
7470
- categoryId: categoryId
7471
- });
7472
- }))
7473
- }));
7725
+ var pushTo = function pushTo(data) {
7726
+ if (history.push) history.push(data);else history(data);
7474
7727
  };
7475
- var handleDeleteArticle = function handleDeleteArticle(article) {
7476
- if (!exam) return;
7477
- var removedQuestions = exam.questions.filter(function (i) {
7478
- return i.article === +article;
7479
- }).map(function (i) {
7480
- return i.questionOrder;
7481
- });
7482
- var max = Math.max.apply(Math, removedQuestions);
7483
- var examQuestions = exam.questions.filter(function (i) {
7484
- return i.article !== +article;
7485
- }).map(function (i) {
7486
- return _extends({}, i, {
7487
- article: i.article > article ? i.article - 1 : i.article,
7488
- questionOrder: i.questionOrder > max ? i.questionOrder - removedQuestions.length : i.questionOrder
7728
+ useEffect(function () {
7729
+ initialAcademySearchParam();
7730
+ }, [window.location.pathname, user === null || user === void 0 ? void 0 : user.academyDomain]);
7731
+ };
7732
+
7733
+ var useList = function useList(fetchData, defaultQuery) {
7734
+ var dispatch = useDispatch();
7735
+ var _useState = useState(defaultQuery),
7736
+ filter = _useState[0],
7737
+ setFilter = _useState[1];
7738
+ var _useState2 = useState(0),
7739
+ totalPages = _useState2[0],
7740
+ setTotalPages = _useState2[1];
7741
+ var _useState3 = useState([]),
7742
+ data = _useState3[0],
7743
+ setData = _useState3[1];
7744
+ var _useState4 = useState(),
7745
+ selectedItem = _useState4[0],
7746
+ setSelectedItem = _useState4[1];
7747
+ var textSearchRef = useRef(null);
7748
+ var isFirstLoadRef = useRef(true);
7749
+ var handleChangeSelectedItem = function handleChangeSelectedItem(item) {
7750
+ setSelectedItem(item);
7751
+ };
7752
+ var getData = function getData(isLoading) {
7753
+ if (isLoading === void 0) {
7754
+ isLoading = false;
7755
+ }
7756
+ try {
7757
+ var _temp2 = function _temp2() {
7758
+ isLoading && dispatch(setLoading(false));
7759
+ };
7760
+ if (isFirstLoadRef.current) isFirstLoadRef.current = false;
7761
+ isLoading && dispatch(setLoading(true));
7762
+ var _temp = _catch(function () {
7763
+ return Promise.resolve(fetchData(filter)).then(function (res) {
7764
+ var _res$data = res.data,
7765
+ _res$data$items = _res$data.items,
7766
+ items = _res$data$items === void 0 ? [] : _res$data$items,
7767
+ _res$data$totalPages = _res$data.totalPages,
7768
+ totalPages = _res$data$totalPages === void 0 ? 0 : _res$data$totalPages;
7769
+ setTotalPages(totalPages);
7770
+ setData(items);
7771
+ });
7772
+ }, function (error) {
7773
+ var _error$response, _error$response$data;
7774
+ setTotalPages(0);
7775
+ setData([]);
7776
+ toast.error((error === null || error === void 0 ? void 0 : (_error$response = error.response) === null || _error$response === void 0 ? void 0 : (_error$response$data = _error$response.data) === null || _error$response$data === void 0 ? void 0 : _error$response$data.title) || "Get data failed");
7489
7777
  });
7778
+ return Promise.resolve(_temp && _temp.then ? _temp.then(_temp2) : _temp2(_temp));
7779
+ } catch (e) {
7780
+ return Promise.reject(e);
7781
+ }
7782
+ };
7783
+ var handleSort = function handleSort(sortColumnName) {
7784
+ var sortColumnDirection = OrderType.ASC;
7785
+ console.log({
7786
+ sortColumnName: typeof sortColumnName,
7787
+ filter: typeof filter.sortColumnName
7490
7788
  });
7491
- onChangeExam(_extends({}, exam, {
7492
- questions: [].concat(examQuestions)
7789
+ if (filter.sortColumnName == sortColumnName && filter.sortColumnDirection === OrderType.ASC) sortColumnDirection = OrderType.DESC;
7790
+ setFilter(_extends({}, filter, {
7791
+ sortColumnName: sortColumnName,
7792
+ sortColumnDirection: sortColumnDirection,
7793
+ currentPage: 1
7493
7794
  }));
7494
7795
  };
7495
- var handleChangeAnswerCount = function handleChangeAnswerCount(article, newAnswerCount, answerCount) {
7496
- if (!exam) return;
7497
- if (newAnswerCount === answerCount) return;
7498
- var examQuestions = exam.questions;
7499
- var questions = examQuestions.filter(function (i) {
7500
- return i.article === +article;
7501
- });
7502
- var otherQuestions = examQuestions.filter(function (i) {
7503
- return i.article !== +article;
7504
- });
7505
- if (answerCount < newAnswerCount) {
7506
- onChangeExam(_extends({}, exam, {
7507
- questions: [].concat(otherQuestions, questions.map(function (q) {
7508
- return _extends({}, q, {
7509
- numberOfAnswers: newAnswerCount
7510
- });
7511
- }))
7512
- }));
7513
- } else {
7514
- onChangeExam(_extends({}, exam, {
7515
- questions: [].concat(otherQuestions, questions.map(function (q) {
7516
- var _q$correctAnswers;
7517
- return _extends({}, q, {
7518
- numberOfAnswers: newAnswerCount,
7519
- correctAnswers: (_q$correctAnswers = q.correctAnswers) === null || _q$correctAnswers === void 0 ? void 0 : _q$correctAnswers.filter(function (i) {
7520
- return i <= newAnswerCount;
7521
- })
7522
- });
7523
- }))
7524
- }));
7525
- }
7796
+ var handleChangeSearchText = function handleChangeSearchText(e) {
7797
+ if (!textSearchRef.current) return;
7798
+ textSearchRef.current.value = e.target.value.trim();
7799
+ debounceSearch();
7526
7800
  };
7527
- var handleChangeCorrectAnswers = function handleChangeCorrectAnswers(article, index, answer) {
7528
- if (!exam) return;
7529
- var examQuestions = exam.questions;
7530
- var questions = examQuestions.filter(function (i) {
7531
- return i.article === +article;
7532
- });
7533
- var otherQuestions = examQuestions.filter(function (i) {
7534
- return i.article !== +article;
7535
- });
7536
- var selectedQuestion = questions[index];
7537
- onChangeExam(_extends({}, exam, {
7538
- questions: [].concat(otherQuestions, questions.slice(0, index), [_extends({}, selectedQuestion, {
7539
- correctAnswers: [answer]
7540
- })], questions.slice(index + 1))
7801
+ var handleChangePage = function handleChangePage(_, page) {
7802
+ setFilter(_extends({}, filter, {
7803
+ currentPage: page
7541
7804
  }));
7542
7805
  };
7543
- var handleChangeScoreAnswer = function handleChangeScoreAnswer(article, index, score) {
7544
- if (!exam) return;
7545
- var examQuestions = exam.questions;
7546
- var questions = examQuestions.filter(function (i) {
7547
- return i.article === +article;
7548
- });
7549
- var otherQuestions = examQuestions.filter(function (i) {
7550
- return i.article !== +article;
7551
- });
7552
- var selectedQuestion = questions[index];
7553
- if (score === selectedQuestion.score) return;
7554
- onChangeExam(_extends({}, exam, {
7555
- questions: [].concat(otherQuestions, questions.slice(0, index), [_extends({}, selectedQuestion, {
7556
- score: score
7557
- })], questions.slice(index + 1))
7806
+ var calcOrderNumber = function calcOrderNumber(index) {
7807
+ var _filter$currentPage, _filter$pageSize;
7808
+ return (((_filter$currentPage = filter.currentPage) != null ? _filter$currentPage : 0) - 1) * ((_filter$pageSize = filter.pageSize) != null ? _filter$pageSize : 0) + index + 1;
7809
+ };
7810
+ var debounceSearch = _.debounce(function () {
7811
+ var _textSearchRef$curren;
7812
+ setFilter(_extends({}, filter, {
7813
+ currentPage: 1,
7814
+ textSearch: (_textSearchRef$curren = textSearchRef.current) === null || _textSearchRef$curren === void 0 ? void 0 : _textSearchRef$curren.value
7558
7815
  }));
7816
+ }, 500);
7817
+ useEffect(function () {
7818
+ getData(isFirstLoadRef.current);
7819
+ }, [JSON.stringify(filter)]);
7820
+ return {
7821
+ filter: filter,
7822
+ textSearchRef: textSearchRef,
7823
+ totalPages: totalPages,
7824
+ data: data,
7825
+ selectedItem: selectedItem,
7826
+ handleSort: handleSort,
7827
+ handleChangeSearchText: handleChangeSearchText,
7828
+ handleChangePage: handleChangePage,
7829
+ calcOrderNumber: calcOrderNumber,
7830
+ handleChangeSelectedItem: handleChangeSelectedItem,
7831
+ getData: getData
7832
+ };
7833
+ };
7834
+
7835
+
7836
+
7837
+ var index$1 = {
7838
+ __proto__: null,
7839
+ useLogin: useLogin,
7840
+ useAutoAcademyDomain: useAutoAcademyDomain,
7841
+ useList: useList
7842
+ };
7843
+
7844
+ var useTextbookList = function useTextbookList(props) {
7845
+ var role = props.role,
7846
+ navigate = props.navigate;
7847
+ var _useList = useList(function (search) {
7848
+ return getTextbookListApi(search, role);
7849
+ }, TextbookDefaultQuery),
7850
+ filter = _useList.filter,
7851
+ textSearchRef = _useList.textSearchRef,
7852
+ totalPages = _useList.totalPages,
7853
+ textbooks = _useList.data,
7854
+ selectedTextbook = _useList.selectedItem,
7855
+ handleSort = _useList.handleSort,
7856
+ handleChangeSearchText = _useList.handleChangeSearchText,
7857
+ handleChangePage = _useList.handleChangePage,
7858
+ calcOrderNumber = _useList.calcOrderNumber,
7859
+ handleChangeSelectedItem = _useList.handleChangeSelectedItem,
7860
+ getData = _useList.getData;
7861
+ var textbookUrl = role === Role.Teacher ? TEXTBOOK_URL$1 : ADMIN_TEXTBOOK_URL;
7862
+ var dispatch = useDispatch();
7863
+ var handleViewTextbook = function handleViewTextbook(id) {
7864
+ navigate(textbookUrl + "/" + id + "?readonly=true", {
7865
+ replace: true
7866
+ });
7867
+ };
7868
+ var handleUpdateTextbook = function handleUpdateTextbook(id) {
7869
+ navigate(textbookUrl + "/" + id, {
7870
+ replace: true
7871
+ });
7559
7872
  };
7560
- var handleChangeDuration = function handleChangeDuration(value) {
7561
- if (!exam) return;
7562
- onChangeExam(_extends({}, exam, {
7563
- duration: value === null || value === void 0 ? void 0 : value.value
7564
- }));
7873
+ var handleCreateTextbook = function handleCreateTextbook() {
7874
+ navigate(textbookUrl + "/create", {
7875
+ replace: true
7876
+ });
7565
7877
  };
7566
- var handleChangeTitle = function handleChangeTitle(e) {
7567
- if (!exam) return;
7568
- onChangeExam(_extends({}, exam, {
7569
- title: e.target.value
7570
- }));
7878
+ var toggleConfirmDialog = function toggleConfirmDialog() {
7879
+ handleChangeSelectedItem(undefined);
7571
7880
  };
7572
- var handleAddArticle = function handleAddArticle() {
7573
- var _$maxBy, _$maxBy2;
7574
- if (!exam) return;
7575
- var maxArticle = ((_$maxBy = _.maxBy(exam.questions, "article")) === null || _$maxBy === void 0 ? void 0 : _$maxBy.article) || 0;
7576
- var maxOrder = ((_$maxBy2 = _.maxBy(exam.questions, "questionOrder")) === null || _$maxBy2 === void 0 ? void 0 : _$maxBy2.questionOrder) || 0;
7577
- onChangeExam(_extends({}, exam, {
7578
- questions: [].concat(exam.questions, [{
7579
- article: maxArticle + 1,
7580
- correctAnswers: [1],
7581
- numberOfAnswers: DEFAULT_ANSWER_COUNT,
7582
- score: DEFAULT_SCORE,
7583
- questionOrder: maxOrder + 1
7584
- }])
7585
- }));
7881
+ var handleSelectDeleteTextbook = function handleSelectDeleteTextbook(textbook) {
7882
+ return [handleChangeSelectedItem(textbook)];
7586
7883
  };
7587
- var examGroupByArticle = useMemo(function () {
7588
- if (!exam) return [];
7589
- var articles = [];
7590
- var groupedArticle = _.groupBy(exam.questions, "article");
7591
- for (var key in groupedArticle) {
7592
- if (Object.prototype.hasOwnProperty.call(groupedArticle, key)) {
7593
- var _questions$find, _$maxBy3;
7594
- var questions = groupedArticle[key];
7595
- articles.push({
7596
- article: +key,
7597
- categoryId: (_questions$find = questions.find(function (i) {
7598
- return !!i.categoryId;
7599
- })) === null || _questions$find === void 0 ? void 0 : _questions$find.categoryId,
7600
- answerCount: ((_$maxBy3 = _.maxBy(questions, "numberOfAnswers")) === null || _$maxBy3 === void 0 ? void 0 : _$maxBy3.numberOfAnswers) || DEFAULT_ANSWER_COUNT,
7601
- questionCount: questions.length,
7602
- questions: questions
7884
+ var handleDeleteTextbook = function handleDeleteTextbook() {
7885
+ try {
7886
+ var _temp2 = function _temp2() {
7887
+ dispatch(setLoading(false));
7888
+ };
7889
+ if (!(selectedTextbook !== null && selectedTextbook !== void 0 && selectedTextbook.id)) return Promise.resolve();
7890
+ dispatch(setLoading(true));
7891
+ var _temp = _catch(function () {
7892
+ return Promise.resolve(deleteTextbookApi(selectedTextbook.id, role)).then(function () {
7893
+ return Promise.resolve(getData(false)).then(function () {
7894
+ toggleConfirmDialog();
7895
+ });
7603
7896
  });
7604
- }
7897
+ }, function (error) {
7898
+ var _error$response, _error$response$data;
7899
+ toast.error((error === null || error === void 0 ? void 0 : (_error$response = error.response) === null || _error$response === void 0 ? void 0 : (_error$response$data = _error$response.data) === null || _error$response$data === void 0 ? void 0 : _error$response$data.title) || "Textbook deleted failed");
7900
+ });
7901
+ return Promise.resolve(_temp && _temp.then ? _temp.then(_temp2) : _temp2(_temp));
7902
+ } catch (e) {
7903
+ return Promise.reject(e);
7605
7904
  }
7606
- return _.sortBy(articles, "article");
7607
- }, [JSON.stringify(exam)]);
7608
- var durationOptions = useMemo(function () {
7609
- var options = DURATION_OPTIONS.map(function (i) {
7610
- return {
7611
- label: i + "\uBD84",
7612
- value: i
7613
- };
7614
- });
7615
- if (!!exam.duration && exam.duration > DURATION_OPTIONS[DURATION_OPTIONS.length - 1]) return [].concat(options, [{
7616
- label: exam.duration + "\uBD84",
7617
- value: exam.duration
7618
- }]);
7619
- return options;
7620
- }, [exam.duration]);
7621
- useEffect(function () {
7622
- if ((selectedSubject === null || selectedSubject === void 0 ? void 0 : selectedSubject.id) !== exam.subjectId) onChangeExam(_extends({}, exam, {
7623
- subjectId: (selectedSubject === null || selectedSubject === void 0 ? void 0 : selectedSubject.id) || 0
7624
- }));
7625
- }, [selectedSubject === null || selectedSubject === void 0 ? void 0 : selectedSubject.id, exam.subjectId]);
7905
+ };
7626
7906
  return {
7627
- t: t,
7628
- durationOptions: durationOptions,
7629
- examGroupByArticle: examGroupByArticle,
7630
- handleAddArticle: handleAddArticle,
7631
- handleChangeScoreAnswer: handleChangeScoreAnswer,
7632
- handleChangeTitle: handleChangeTitle,
7633
- handleChangeDuration: handleChangeDuration,
7634
- handleChangeCorrectAnswers: handleChangeCorrectAnswers,
7635
- handleChangeAnswerCount: handleChangeAnswerCount,
7636
- handleChangeQuestionCount: handleChangeQuestionCount,
7637
- handleChangeCategory: handleChangeCategory,
7638
- handleDeleteArticle: handleDeleteArticle
7907
+ filter: filter,
7908
+ textSearchRef: textSearchRef,
7909
+ totalPages: totalPages,
7910
+ textbooks: textbooks,
7911
+ selectedTextbook: selectedTextbook,
7912
+ handleSort: handleSort,
7913
+ handleChangeSearchText: handleChangeSearchText,
7914
+ handleChangePage: handleChangePage,
7915
+ calcOrderNumber: calcOrderNumber,
7916
+ handleViewTextbook: handleViewTextbook,
7917
+ handleUpdateTextbook: handleUpdateTextbook,
7918
+ handleCreateTextbook: handleCreateTextbook,
7919
+ toggleConfirmDialog: toggleConfirmDialog,
7920
+ handleDeleteTextbook: handleDeleteTextbook,
7921
+ handleSelectDeleteTextbook: handleSelectDeleteTextbook
7639
7922
  };
7640
7923
  };
7641
7924
 
7642
- var ExamDetailView = function ExamDetailView(_ref) {
7643
- var _ref$className = _ref.className,
7644
- className = _ref$className === void 0 ? "" : _ref$className,
7645
- exam = _ref.exam,
7646
- isDisabled = _ref.isDisabled,
7647
- isEdit = _ref.isEdit,
7648
- onChangeExam = _ref.onChangeExam;
7649
- var _useSubjectSelect = useSubjectSelect(),
7650
- subjectOptions = _useSubjectSelect.subjectOptions,
7651
- selectedSubject = _useSubjectSelect.selectedSubject,
7652
- handleChangeSubject = _useSubjectSelect.handleChangeSubject;
7653
- var _useExamDetailView = useExamDetailView({
7654
- exam: exam,
7655
- onChangeExam: onChangeExam,
7656
- selectedSubject: selectedSubject
7657
- }),
7658
- t = _useExamDetailView.t,
7659
- durationOptions = _useExamDetailView.durationOptions,
7660
- examGroupByArticle = _useExamDetailView.examGroupByArticle,
7661
- handleAddArticle = _useExamDetailView.handleAddArticle,
7662
- handleChangeScoreAnswer = _useExamDetailView.handleChangeScoreAnswer,
7663
- handleChangeTitle = _useExamDetailView.handleChangeTitle,
7664
- handleChangeDuration = _useExamDetailView.handleChangeDuration,
7665
- handleChangeCorrectAnswers = _useExamDetailView.handleChangeCorrectAnswers,
7666
- handleChangeAnswerCount = _useExamDetailView.handleChangeAnswerCount,
7667
- handleChangeQuestionCount = _useExamDetailView.handleChangeQuestionCount,
7668
- handleChangeCategory = _useExamDetailView.handleChangeCategory,
7669
- handleDeleteArticle = _useExamDetailView.handleDeleteArticle;
7670
- return React.createElement(Grid, {
7671
- container: true,
7672
- spacing: 3,
7673
- className: className + " " + styles["custom-row"]
7925
+ var EmptyRow = function EmptyRow() {
7926
+ var _useTranslation = useTranslation(),
7927
+ t = _useTranslation.t;
7928
+ return React.createElement(TableRow, null, React.createElement(TableCell, {
7929
+ colSpan: 12,
7930
+ className: "text-center text-muted"
7931
+ }, t("no_data")));
7932
+ };
7933
+
7934
+ var LayoutList = function LayoutList(_ref) {
7935
+ var children = _ref.children,
7936
+ title = _ref.title;
7937
+ return React.createElement(Box, {
7938
+ className: 'bg-white p-3'
7939
+ }, React.createElement(Stack, {
7940
+ direction: "row",
7941
+ alignItems: "center",
7942
+ justifyContent: "space-between",
7943
+ mb: 2
7944
+ }, React.createElement(Typography, {
7945
+ variant: 'h4'
7946
+ }, title)), React.createElement(Box, null, children));
7947
+ };
7948
+
7949
+ var SortIcon = function SortIcon(_ref) {
7950
+ var isAscending = _ref.isAscending,
7951
+ onClick = _ref.onClick;
7952
+ return React.createElement("div", {
7953
+ className: "d-flex flex-column " + styles["sort-icons"],
7954
+ onClick: onClick
7955
+ }, React.createElement(FaSortUp, {
7956
+ className: isAscending === true ? styles["active"] : ""
7957
+ }), React.createElement(FaSortDown, {
7958
+ className: isAscending === false ? styles["active"] : ""
7959
+ }));
7960
+ };
7961
+
7962
+ var TableHeader = function TableHeader(_ref) {
7963
+ var headerTemplates = _ref.headerTemplates,
7964
+ filter = _ref.filter,
7965
+ onSort = _ref.onSort;
7966
+ var _useTranslation = useTranslation(),
7967
+ t = _useTranslation.t;
7968
+ return React.createElement(TableHead, null, React.createElement(TableRow, null, headerTemplates.map(function (i, index$1) {
7969
+ return React.createElement(TableCell, {
7970
+ key: index$1,
7971
+ className: "" + (!!i.sortKey && "pointer"),
7972
+ onClick: !!i.sortKey ? function () {
7973
+ return onSort === null || onSort === void 0 ? void 0 : onSort(i.sortKey);
7974
+ } : undefined
7975
+ }, React.createElement("div", {
7976
+ className: "d-flex justify-content-between align-items-center text-nowrap"
7977
+ }, t(i.title), !!i.sortKey && React.createElement(SortIcon, {
7978
+ isAscending: filter.sortColumnName !== i.sortKey ? undefined : filter.sortColumnDirection === OrderType.ASC
7979
+ })));
7980
+ })));
7981
+ };
7982
+
7983
+ var SearchInput = function SearchInput(_ref) {
7984
+ var textSearchRef = _ref.textSearchRef,
7985
+ _ref$placeholder = _ref.placeholder,
7986
+ placeholder = _ref$placeholder === void 0 ? "Search for..." : _ref$placeholder,
7987
+ onChange = _ref.onChange,
7988
+ _ref$fit = _ref.fit,
7989
+ fit = _ref$fit === void 0 ? true : _ref$fit;
7990
+ return React.createElement(Paper, {
7991
+ component: "div",
7992
+ className: "bg-light w-100 " + (fit && "h-100"),
7993
+ sx: {
7994
+ p: "2px 4px",
7995
+ display: "flex",
7996
+ alignItems: "center",
7997
+ width: 400,
7998
+ transition: "border 0.2s ease",
7999
+ outline: "1px solid transparent",
8000
+ ":focus-within": {
8001
+ outlineColor: function outlineColor(theme) {
8002
+ return theme.palette.primary.main;
8003
+ }
8004
+ }
8005
+ }
8006
+ }, React.createElement(Box, {
8007
+ sx: {
8008
+ p: "10px"
8009
+ },
8010
+ "aria-label": "search"
8011
+ }, React.createElement(IoSearch, {
8012
+ size: 24,
8013
+ className: "pb-1"
8014
+ })), React.createElement(InputBase, {
8015
+ id: "searchText",
8016
+ className: "" + (fit && "h-100"),
8017
+ sx: {
8018
+ ml: 1,
8019
+ flex: 1,
8020
+ lineHeight: 1
8021
+ },
8022
+ placeholder: placeholder,
8023
+ ref: textSearchRef,
8024
+ onChange: onChange
8025
+ }));
8026
+ };
8027
+
8028
+ var TextbookList = function TextbookList(props) {
8029
+ var _useTranslation = useTranslation(),
8030
+ t = _useTranslation.t;
8031
+ var _useTextbookList = useTextbookList(props),
8032
+ filter = _useTextbookList.filter,
8033
+ textbooks = _useTextbookList.textbooks,
8034
+ totalPages = _useTextbookList.totalPages,
8035
+ textSearchRef = _useTextbookList.textSearchRef,
8036
+ selectedTextbook = _useTextbookList.selectedTextbook,
8037
+ handleChangeSearchText = _useTextbookList.handleChangeSearchText,
8038
+ handleSort = _useTextbookList.handleSort,
8039
+ handleChangePage = _useTextbookList.handleChangePage,
8040
+ calcOrderNumber = _useTextbookList.calcOrderNumber,
8041
+ handleViewTextbook = _useTextbookList.handleViewTextbook,
8042
+ handleUpdateTextbook = _useTextbookList.handleUpdateTextbook,
8043
+ handleCreateTextbook = _useTextbookList.handleCreateTextbook,
8044
+ toggleConfirmDialog = _useTextbookList.toggleConfirmDialog,
8045
+ handleDeleteTextbook = _useTextbookList.handleDeleteTextbook,
8046
+ handleSelectDeleteTextbook = _useTextbookList.handleSelectDeleteTextbook;
8047
+ return React.createElement(LayoutList, {
8048
+ title: t(TEXTBOOK_PAGE_TITLE)
8049
+ }, React.createElement(Grid, {
8050
+ container: true
7674
8051
  }, React.createElement(Grid, {
7675
8052
  item: true,
7676
- xs: 5,
7677
- className: 'mb-2'
7678
- }, React.createElement("label", {
7679
- className: styles["form-label"] + " " + styles$2["question-label"],
7680
- htmlFor: "title"
7681
- }, t("title")), React.createElement("input", {
7682
- disabled: isDisabled,
7683
- className: "" + styles["form-control"],
7684
- value: exam.title,
7685
- id: "title",
7686
- placeholder: t("enter_title"),
7687
- onChange: handleChangeTitle
7688
- })), React.createElement(Grid, {
7689
- item: true,
7690
- xs: 3,
7691
- className: 'mb-2'
7692
- }, React.createElement("label", {
7693
- className: styles["form-label"] + " " + styles$2["question-label"],
7694
- htmlFor: "duration"
7695
- }, t("duration")), React.createElement(CustomSelect, {
7696
- inputId: "duration",
7697
- value: exam.duration,
7698
- options: durationOptions,
7699
- onChange: handleChangeDuration,
7700
- isDisabled: isDisabled
8053
+ xs: 6
8054
+ }, React.createElement(SearchInput, {
8055
+ textSearchRef: textSearchRef,
8056
+ onChange: handleChangeSearchText,
8057
+ placeholder: t(TEXT_BOOK_SEARCH_PLACEHOLDER)
7701
8058
  })), React.createElement(Grid, {
7702
8059
  item: true,
7703
- xs: 3,
7704
- className: 'mb-2'
7705
- }, React.createElement("label", {
7706
- className: styles["form-label"] + " " + styles$2["question-label"],
7707
- htmlFor: "duration"
7708
- }, t("subject"), " ", selectedSubject === null || selectedSubject === void 0 ? void 0 : selectedSubject.name), React.createElement(CustomSelect, {
7709
- inputId: "subject",
7710
- value: selectedSubject === null || selectedSubject === void 0 ? void 0 : selectedSubject.id,
7711
- options: subjectOptions,
7712
- onChange: handleChangeSubject,
7713
- isDisabled: isDisabled || isEdit
7714
- })), examGroupByArticle.map(function (i, index) {
7715
- return React.createElement(Grid, {
7716
- item: true,
7717
- key: i.article,
7718
- xs: 12,
7719
- className: index === examGroupByArticle.length - 1 ? "mb-2" : ''
7720
- }, React.createElement(ArticleGroupView, Object.assign({}, i, {
7721
- isActive: index === examGroupByArticle.length - 1,
7722
- onChangeQuestionCount: handleChangeQuestionCount,
7723
- onChangeCategory: handleChangeCategory,
7724
- onChangeAnswerCount: handleChangeAnswerCount,
7725
- onChangeCorrectAnswers: handleChangeCorrectAnswers,
7726
- onChangeScoreAnswer: handleChangeScoreAnswer,
7727
- onDelete: handleDeleteArticle,
7728
- isDisabled: isDisabled,
7729
- selectedSubject: selectedSubject,
7730
- isDeletable: examGroupByArticle.length > 1
7731
- })));
7732
- }), React.createElement(Grid, {
8060
+ xs: 6
8061
+ }, React.createElement(Stack, {
8062
+ alignItems: "end"
8063
+ }, React.createElement(Button, {
8064
+ startIcon: React.createElement(FaPlus, {
8065
+ size: 12
8066
+ }),
8067
+ variant: "contained",
8068
+ color: "primary",
8069
+ onClick: handleCreateTextbook
8070
+ }, t("create_textbook")))), React.createElement(Grid, {
7733
8071
  item: true,
7734
- xs: 12
7735
- }, React.createElement("button", {
7736
- disabled: isDisabled,
7737
- className: styles["btn-outline-primary"] + " w-100 d-flex justify-content-center align-items-center " + styles$2["question-btn"] + " mt-3",
7738
- onClick: handleAddArticle
7739
- }, React.createElement(FaPlusCircle, {
7740
- className: "me-2"
7741
- }), "\uBB38\uD56D \uCD94\uAC00\uD558\uAE30")));
8072
+ xs: 12,
8073
+ className: "mt-3"
8074
+ }, React.createElement(Table, null, React.createElement(TableHeader, {
8075
+ headerTemplates: TEXTBOOK_HEADERS,
8076
+ filter: filter,
8077
+ onSort: handleSort
8078
+ }), React.createElement(TableBody, null, textbooks.map(function (i, index) {
8079
+ return React.createElement(TableRow, {
8080
+ key: i.id
8081
+ }, React.createElement(TableCell, null, calcOrderNumber(index)), React.createElement(TableCell, null, i.name), React.createElement(TableCell, null, i.subject.name), React.createElement(TableCell, null, utcToLocalTime(i.createdAt, t("date_format"))), React.createElement(TableCell, null, i.totalChapters), React.createElement(TableCell, null, React.createElement(Stack, {
8082
+ direction: "row",
8083
+ spacing: 1,
8084
+ alignItems: "center"
8085
+ }, !i.isCreatedByAdmin && React.createElement(IconButton, {
8086
+ color: "default",
8087
+ className: "bg-warning text-white",
8088
+ onClick: function onClick() {
8089
+ return handleUpdateTextbook(i.id);
8090
+ }
8091
+ }, React.createElement(FaPencil, {
8092
+ size: 12
8093
+ })), React.createElement(IconButton, {
8094
+ color: "default",
8095
+ className: "bg-primary text-white",
8096
+ onClick: function onClick() {
8097
+ return handleViewTextbook(i.id);
8098
+ }
8099
+ }, React.createElement(FaEye, {
8100
+ size: 12
8101
+ })), !i.isCreatedByAdmin && React.createElement(IconButton, {
8102
+ color: "default",
8103
+ className: "bg-danger text-white",
8104
+ onClick: function onClick() {
8105
+ return handleSelectDeleteTextbook(i);
8106
+ }
8107
+ }, React.createElement(FaTrash, {
8108
+ size: 12
8109
+ })))));
8110
+ }), !textbooks.length && React.createElement(EmptyRow, null))), React.createElement("div", {
8111
+ className: "d-flex justify-content-end mt-3"
8112
+ }, !!totalPages && React.createElement(Pagination, {
8113
+ count: totalPages,
8114
+ page: filter.currentPage,
8115
+ onChange: handleChangePage
8116
+ })))), React.createElement(ConfirmDialog, {
8117
+ open: !!(selectedTextbook !== null && selectedTextbook !== void 0 && selectedTextbook.id),
8118
+ toggle: toggleConfirmDialog,
8119
+ text: "" + t("are_you_sure_you_want_to_delete_the_textbook"),
8120
+ onConfirm: handleDeleteTextbook,
8121
+ confirmText: selectedTextbook === null || selectedTextbook === void 0 ? void 0 : selectedTextbook.name,
8122
+ isDelete: true
8123
+ }));
8124
+ };
8125
+
8126
+
8127
+
8128
+ var index$2 = {
8129
+ __proto__: null,
8130
+ TextbookList: TextbookList,
8131
+ TextbookDetail: TextbookViewDetail
8132
+ };
8133
+
8134
+ var _excluded$5 = ["defaultValue", "options", "isDisabled", "scrollBottom", "value", "isMulti"];
8135
+ var CustomCreatable = function CustomCreatable(_ref) {
8136
+ var options = _ref.options,
8137
+ isDisabled = _ref.isDisabled,
8138
+ scrollBottom = _ref.scrollBottom,
8139
+ value = _ref.value,
8140
+ isMulti = _ref.isMulti,
8141
+ rest = _objectWithoutPropertiesLoose(_ref, _excluded$5);
8142
+ var initialValues = Array.isArray(value) ? options.filter(function (i) {
8143
+ return value.includes(i.value);
8144
+ }) : isMulti ? options.filter(function (i) {
8145
+ return i.value == value;
8146
+ }) : options.find(function (i) {
8147
+ return i.value == value;
8148
+ });
8149
+ return React.createElement(CreatableSelect, Object.assign({
8150
+ isClearable: true,
8151
+ isDisabled: isDisabled,
8152
+ options: options,
8153
+ value: initialValues,
8154
+ menuPlacement: scrollBottom ? "top" : "auto",
8155
+ isMulti: isMulti
8156
+ }, rest));
8157
+ };
8158
+
8159
+ var _excluded$6 = ["isDefault", "defaultValue", "options", "isDisabled", "scrollBottom", "value", "isMulti"];
8160
+ var CustomAsyncSelect = function CustomAsyncSelect(_ref) {
8161
+ var isDefault = _ref.isDefault,
8162
+ options = _ref.options,
8163
+ isDisabled = _ref.isDisabled,
8164
+ scrollBottom = _ref.scrollBottom,
8165
+ value = _ref.value,
8166
+ isMulti = _ref.isMulti,
8167
+ rest = _objectWithoutPropertiesLoose(_ref, _excluded$6);
8168
+ var initialValues = Array.isArray(value) ? options.filter(function (i) {
8169
+ return value.includes(i.value);
8170
+ }) : isMulti ? options.filter(function (i) {
8171
+ return i.value == value;
8172
+ }) : options.find(function (i) {
8173
+ return i.value == value;
8174
+ });
8175
+ return React.createElement(Select, Object.assign({
8176
+ isDisabled: isDisabled,
8177
+ options: options,
8178
+ value: !isDefault ? initialValues : undefined,
8179
+ defaultValue: isDefault ? initialValues : undefined,
8180
+ menuPlacement: scrollBottom ? "top" : "auto",
8181
+ isMulti: isMulti
8182
+ }, rest));
7742
8183
  };
7743
8184
 
7744
8185
  var EXAM_SESSION_URL = BASE_URL + "/api/examSession";
@@ -7796,16 +8237,16 @@ var ORDER_NUMBERS = {
7796
8237
  10: "the_tenth"
7797
8238
  };
7798
8239
  var TabList = [{
7799
- label: "종합 분석",
8240
+ label: "comprehensive_analysis",
7800
8241
  value: 0
7801
8242
  }, {
7802
- label: "풀이 순서",
8243
+ label: "solution_order",
7803
8244
  value: 1
7804
8245
  }, {
7805
- label: "풀이 비교",
8246
+ label: "compare_solution",
7806
8247
  value: 2
7807
8248
  }, {
7808
- label: "문제 분석",
8249
+ label: "problem_analysis",
7809
8250
  value: 3
7810
8251
  }];
7811
8252
  var Roles$2;
@@ -8667,7 +9108,7 @@ var useExamResult = function useExamResult(searchParam, navigate, examSessionId,
8667
9108
  var questions = ((_timelyOrderQuestion$ = timelyOrderQuestion[dataChartIndex]) === null || _timelyOrderQuestion$ === void 0 ? void 0 : _timelyOrderQuestion$.questions) || null;
8668
9109
  var questionLength = (_questions$length = questions === null || questions === void 0 ? void 0 : questions.length) != null ? _questions$length : 0;
8669
9110
  return val != null ? t("problem_number_question", {
8670
- number: questions !== null ? ((_questions = questions[questionLength - val]) === null || _questions === void 0 ? void 0 : _questions.questionOrder) + 1 : val
9111
+ number: questions !== null ? (((_questions = questions[questionLength - val]) === null || _questions === void 0 ? void 0 : _questions.questionOrder) || 0) + 1 : val
8671
9112
  }) : t("no_data");
8672
9113
  }
8673
9114
  return null;
@@ -8734,7 +9175,7 @@ var useExamResult = function useExamResult(searchParam, navigate, examSessionId,
8734
9175
  var questions = ((_timelyOrderQuestion$2 = timelyOrderQuestion[dataChartIndex]) === null || _timelyOrderQuestion$2 === void 0 ? void 0 : _timelyOrderQuestion$2.questions) || null;
8735
9176
  var questionLength = (_questions$length2 = questions === null || questions === void 0 ? void 0 : questions.length) != null ? _questions$length2 : 0;
8736
9177
  return val != null ? t("problem_number_question", {
8737
- number: questions !== null ? ((_questions2 = questions[questionLength - val]) === null || _questions2 === void 0 ? void 0 : _questions2.questionOrder) + 1 : val
9178
+ number: questions !== null ? (((_questions2 = questions[questionLength - val]) === null || _questions2 === void 0 ? void 0 : _questions2.questionOrder) || 0) + 1 : val
8738
9179
  }) : t("no_data");
8739
9180
  },
8740
9181
  style: {
@@ -8762,15 +9203,23 @@ var useExamResult = function useExamResult(searchParam, navigate, examSessionId,
8762
9203
  topAnswerOrder: i.topAnswerOrder == null ? 0 : i.topAnswerOrder
8763
9204
  });
8764
9205
  });
8765
- var mySeriesData = [null].concat(questionsData.sort(function (a, b) {
8766
- return b.answerOrder === 0 ? -1 : a.answerOrder > b.answerOrder ? 1 : b.answerOrder > a.answerOrder ? -1 : 0;
8767
- }).map(function (item) {
8768
- return item.answerOrder === 0 ? null : data.questions.length - item.questionOrder;
9206
+ var mySeriesData = [null].concat(_.sortBy(questionsData.filter(function (i) {
9207
+ return i.answerOrder !== 0;
9208
+ }), ["answerOrder", "questionOrder"]).map(function (item) {
9209
+ return data.questions.length - item.questionOrder;
9210
+ }), questionsData.filter(function (i) {
9211
+ return i.answerOrder === 0;
9212
+ }).map(function () {
9213
+ return null;
8769
9214
  }), [null]);
8770
- var topSeriesData = [null].concat(questionsData.sort(function (a, b) {
8771
- return b.topAnswerOrder === 0 ? -1 : a.topAnswerOrder > b.topAnswerOrder ? 1 : b.topAnswerOrder > a.topAnswerOrder ? -1 : 0;
8772
- }).map(function (item) {
8773
- return item.topAnswerOrder === 0 ? null : data.questions.length - item.questionOrder;
9215
+ var topSeriesData = [null].concat(_.sortBy(questionsData.filter(function (i) {
9216
+ return i.topAnswerOrder !== 0;
9217
+ }), ["topAnswerOrder", "questionOrder"]).map(function (item) {
9218
+ return data.questions.length - item.questionOrder;
9219
+ }), questionsData.filter(function (i) {
9220
+ return i.topAnswerOrder === 0;
9221
+ }).map(function () {
9222
+ return null;
8774
9223
  }), [null]);
8775
9224
  return [{
8776
9225
  name: t("my_problem_solving_order"),
@@ -9936,7 +10385,7 @@ Object.defineProperty(exports,"__esModule",{value:!0});var _typeof="function"==t
9936
10385
 
9937
10386
  var ReactApexChart = unwrapExports(reactApexcharts_min);
9938
10387
 
9939
- var styles$3 = {"titleBox":"_1dveO","title":"_mxRxf","point":"_2fD-F","buttonGroup":"_2DGl3","btnFeedback":"_xGW1x","btnTerminate":"_3mLu2","myanswer":"_eDBpS","titleMyAnswer1":"_2fMq3","titleMyAnswer2":"_3gEYh","contentMyAnswer":"_2K_sx","myAnswerItem":"_2qiLh","time":"_6TCOK","timeCol":"_hmseC","answer-response":"_3GfJt","answer-response-0":"_3ut64","answer-response-1":"_2VtpD","answer-response-2":"_58lQU","answer-response-3":"_1ucMY","answer-response-4":"_1qkxy","answerCorrect":"_2jIeT","answerIncorrect":"_to2v0","answerNograss":"_1JSte","answerEasy":"_2_uTU","answerDiscrimination":"_1DBoA","answerTrap":"_1q3tD","answerNoTime":"_3iItu","questionOrder":"_1fNkS","myTimeLabel":"_1Z_F3","myPoolTime":"_4KwG0","topTimeLabel":"_245H-","topTime":"_3tZqw","meanTimeLabel":"_PlPLY","meanTime":"_12a7R","compareChart":"_3MW16","prevChart":"_1fNkb","chart":"_3K4oY","nextChart":"_3YKBp","titleChart":"_13BVP","compareGrass":"_1_fJu","titleCompareGrass":"_o1txm","tableCompareGrass":"_bT5nf","thcolumn1":"_3Umg0","tdcolumn1":"_3dRMF","tdcolumn3":"_2tcBP","classification":"_1AFeb","wrapperProblem":"_oTqG7","titleProblem":"_35eIx","titleProblemClose":"_3t4HO","titleTrickyProblem":"_1-oxK","wrongQuestions":"_2dpMR","question":"_1lSOX","assignedQuestions":"_1ONUt","wrapperContent":"_nPoR0","content":"_2zmZn","contentColumn1":"_334SY","span1":"_3Lf-U","span2":"_ZpMot","contentColumn2":"_16P3l","duration":"_1kT28","topDuration":"_1fVRi","overallCorrectRate":"_3jLGe","answer":"_VsZ0K","contentVulnerable":"_QxKMy","wrappContentProblem":"_nnqpW","contentProblem":"_3Z1nV","labelProblem":"_36Xpx","name":"_3ZJQW","percent":"_2J3MK","slider":"_1MPdO","track":"_3CV_y","noData":"__g-ff","loading":"_3j485","table-responsive":"_2O6RX","form-label":"_1RYOQ","form-control":"_3VRVT","form-label-dialog":"_3oCSh","btn-cancel":"_3USKq","btn-register":"_3y_iD","pdfBtnBox":"_3xZHo","pdfBtn":"_1DtWq","form-select":"_1a_vw"};
10388
+ var styles$4 = {"titleBox":"_1dveO","title":"_mxRxf","point":"_2fD-F","buttonGroup":"_2DGl3","btnFeedback":"_xGW1x","btnTerminate":"_3mLu2","myanswer":"_eDBpS","titleMyAnswer1":"_2fMq3","titleMyAnswer2":"_3gEYh","contentMyAnswer":"_2K_sx","myAnswerItem":"_2qiLh","time":"_6TCOK","timeCol":"_hmseC","answer-response":"_3GfJt","answer-response-0":"_3ut64","answer-response-1":"_2VtpD","answer-response-2":"_58lQU","answer-response-3":"_1ucMY","answer-response-4":"_1qkxy","answerCorrect":"_2jIeT","answerIncorrect":"_to2v0","answerNograss":"_1JSte","answerEasy":"_2_uTU","answerDiscrimination":"_1DBoA","answerTrap":"_1q3tD","answerNoTime":"_3iItu","questionOrder":"_1fNkS","myTimeLabel":"_1Z_F3","myPoolTime":"_4KwG0","topTimeLabel":"_245H-","topTime":"_3tZqw","meanTimeLabel":"_PlPLY","meanTime":"_12a7R","compareChart":"_3MW16","prevChart":"_1fNkb","chart":"_3K4oY","nextChart":"_3YKBp","titleChart":"_13BVP","compareGrass":"_1_fJu","titleCompareGrass":"_o1txm","tableCompareGrass":"_bT5nf","thcolumn1":"_3Umg0","tdcolumn1":"_3dRMF","tdcolumn3":"_2tcBP","classification":"_1AFeb","wrapperProblem":"_oTqG7","titleProblem":"_35eIx","titleProblemClose":"_3t4HO","titleTrickyProblem":"_1-oxK","wrongQuestions":"_2dpMR","question":"_1lSOX","assignedQuestions":"_1ONUt","wrapperContent":"_nPoR0","content":"_2zmZn","contentColumn1":"_334SY","span1":"_3Lf-U","span2":"_ZpMot","contentColumn2":"_16P3l","duration":"_1kT28","topDuration":"_1fVRi","overallCorrectRate":"_3jLGe","answer":"_VsZ0K","contentVulnerable":"_QxKMy","wrappContentProblem":"_nnqpW","contentProblem":"_3Z1nV","labelProblem":"_36Xpx","name":"_3ZJQW","percent":"_2J3MK","slider":"_1MPdO","track":"_3CV_y","noData":"__g-ff","loading":"_3j485","table-responsive":"_2O6RX","form-label":"_1RYOQ","form-control":"_3VRVT","form-label-dialog":"_3oCSh","btn-cancel":"_3USKq","btn-register":"_3y_iD","pdfBtnBox":"_3xZHo","pdfBtn":"_1DtWq","form-select":"_1a_vw"};
9940
10389
 
9941
10390
  var iconStarQuestion = function iconStarQuestion(_ref) {
9942
10391
  var _ref$width = _ref.width,
@@ -10227,7 +10676,7 @@ function CreateNewQuestionDialog(_ref) {
10227
10676
  padding: "24px 24px 40px 24px"
10228
10677
  }, React.createElement(Stack, null, React.createElement("label", {
10229
10678
  htmlFor: "questions",
10230
- className: styles['form-label'] + " " + styles$3['form-label-dialog']
10679
+ className: styles['form-label'] + " " + styles$4['form-label-dialog']
10231
10680
  }, "\uC9C8\uBB38\uD560 \uBB38\uC81C"), React.createElement(Field, {
10232
10681
  as: "select",
10233
10682
  id: "questions",
@@ -10244,7 +10693,7 @@ function CreateNewQuestionDialog(_ref) {
10244
10693
  }));
10245
10694
  }))), React.createElement(Stack, null, React.createElement("label", {
10246
10695
  htmlFor: "content-question",
10247
- className: styles['form-label'] + " " + styles$3['form-label-dialog']
10696
+ className: styles['form-label'] + " " + styles$4['form-label-dialog']
10248
10697
  }, "\uC9C8\uBB38 \uB0B4\uC6A9"), React.createElement(Box, {
10249
10698
  position: 'relative',
10250
10699
  display: 'flex',
@@ -10280,14 +10729,14 @@ function CreateNewQuestionDialog(_ref) {
10280
10729
  borderTop: "1px solid #CED2DA"
10281
10730
  }
10282
10731
  }, React.createElement(Button$1, {
10283
- className: styles$3['btn-cancel'],
10732
+ className: styles$4['btn-cancel'],
10284
10733
  onClick: toggleCreateQuestion
10285
10734
  }, React.createElement(Typography$1, {
10286
10735
  fontWeight: 700,
10287
10736
  fontSize: '14px',
10288
10737
  lineHeight: '16.71px'
10289
10738
  }, "\uCDE8\uC18C")), React.createElement(Button$1, {
10290
- className: styles$3['btn-register'],
10739
+ className: styles$4['btn-register'],
10291
10740
  type: "submit"
10292
10741
  }, React.createElement(Typography$1, {
10293
10742
  fontWeight: 700,
@@ -10319,7 +10768,7 @@ function MyAnswer(_ref) {
10319
10768
  toggleCreateQuestion();
10320
10769
  };
10321
10770
  return React.createElement("div", {
10322
- className: styles$3["myanswer"]
10771
+ className: styles$4["myanswer"]
10323
10772
  }, formattedData && formattedData.length > 0 && formattedData.map(function (item) {
10324
10773
  return React.createElement("div", {
10325
10774
  key: item.category.id
@@ -10327,7 +10776,7 @@ function MyAnswer(_ref) {
10327
10776
  bgcolor: "#F9FAFB",
10328
10777
  flexDirection: "row",
10329
10778
  padding: "12px",
10330
- className: styles$3["myAnswerItem"] + " " + styles["noGutters"]
10779
+ className: styles$4["myAnswerItem"] + " " + styles["noGutters"]
10331
10780
  }, React.createElement("div", {
10332
10781
  className: styles["custom-col-2"],
10333
10782
  style: {
@@ -10391,7 +10840,7 @@ function MyAnswer(_ref) {
10391
10840
  color: "#97A1AF"
10392
10841
  }
10393
10842
  }, "\uC804\uCCB4 \uC815\uB2F5\uB960"))), React.createElement("div", {
10394
- className: styles$3["titleMyAnswer2"]
10843
+ className: styles$4["titleMyAnswer2"]
10395
10844
  }, React.createElement(Typography, {
10396
10845
  sx: {
10397
10846
  color: "#97A1AF",
@@ -10404,7 +10853,7 @@ function MyAnswer(_ref) {
10404
10853
  fontWeight: 700
10405
10854
  }
10406
10855
  }, item.category.name)), React.createElement("div", {
10407
- className: styles$3["contentMyAnswer"]
10856
+ className: styles$4["contentMyAnswer"]
10408
10857
  }, item.questions.map(function (question, index) {
10409
10858
  return React.createElement("div", {
10410
10859
  style: isOpenTime[question.id] ? {
@@ -10413,7 +10862,7 @@ function MyAnswer(_ref) {
10413
10862
  } : {},
10414
10863
  key: question.id
10415
10864
  }, React.createElement("div", {
10416
- className: styles$3["myAnswerItem"] + " " + styles["noGutters"]
10865
+ className: styles$4["myAnswerItem"] + " " + styles["noGutters"]
10417
10866
  }, React.createElement("div", {
10418
10867
  className: styles["custom-col-2"],
10419
10868
  style: {
@@ -10423,7 +10872,7 @@ function MyAnswer(_ref) {
10423
10872
  padding: "4px 8px"
10424
10873
  }
10425
10874
  }, question.isStar ? React.createElement(iconStarQuestion, null) : React.createElement(iconNoStarQuestion, null), React.createElement("span", {
10426
- className: styles$3["questionOrder"]
10875
+ className: styles$4["questionOrder"]
10427
10876
  }, question.questionOrder + 1, "\uBC88")), React.createElement("div", {
10428
10877
  className: styles["custom-col-2"],
10429
10878
  style: {
@@ -10432,11 +10881,11 @@ function MyAnswer(_ref) {
10432
10881
  gap: "4px"
10433
10882
  }
10434
10883
  }, question.isCorrect && question.selectedAnswers !== "" && React.createElement(Fragment$1, null, React.createElement(iconCorrectAnswer, null), React.createElement("span", {
10435
- className: styles$3["answerCorrect"]
10884
+ className: styles$4["answerCorrect"]
10436
10885
  }, "\uC815\uB2F5")), !question.isCorrect && question.selectedAnswers !== "" && React.createElement(Fragment$1, null, React.createElement(iconCorrectAnswer$1, null), React.createElement("span", {
10437
- className: styles$3["answerIncorrect"]
10886
+ className: styles$4["answerIncorrect"]
10438
10887
  }, "\uC624\uB2F5")), question.selectedAnswers === "" && React.createElement(Fragment$1, null, React.createElement(iconNoGrass, null), React.createElement("span", {
10439
- className: styles$3["answerNograss"]
10888
+ className: styles$4["answerNograss"]
10440
10889
  }, "\uD480\uC774 \uC5C6\uC74C"))), React.createElement("div", {
10441
10890
  className: styles["custom-col-2"],
10442
10891
  style: {
@@ -10447,12 +10896,12 @@ function MyAnswer(_ref) {
10447
10896
  style: {
10448
10897
  margin: 0
10449
10898
  },
10450
- className: styles$3["answer-response"] + " " + styles$3["answer-response-" + question.answerResponseSignal]
10899
+ className: styles$4["answer-response"] + " " + styles$4["answer-response-" + question.answerResponseSignal]
10451
10900
  }, formatTimeSecond(Math.round(question.duration), t)) : React.createElement("p", {
10452
10901
  style: {
10453
10902
  margin: 0
10454
10903
  },
10455
- className: styles$3["answerNoTime"]
10904
+ className: styles$4["answerNoTime"]
10456
10905
  }, "\uC2DC\uAC04 \uC5C6\uC74C")), React.createElement("div", {
10457
10906
  className: styles["custom-col-2"],
10458
10907
  style: {
@@ -10463,13 +10912,13 @@ function MyAnswer(_ref) {
10463
10912
  style: {
10464
10913
  margin: 0
10465
10914
  },
10466
- className: styles$3["answer-response"] + " " + styles$3["answer-response-" + question.answerResponseSignal]
10915
+ className: styles$4["answer-response"] + " " + styles$4["answer-response-" + question.answerResponseSignal]
10467
10916
  }, formatTimeSecond(Math.round(question.topDuration - question.duration), t)) : React.createElement("p", {
10468
10917
  style: {
10469
10918
  margin: 0,
10470
10919
  textAlign: "center"
10471
10920
  },
10472
- className: styles$3["answerNoTime"]
10921
+ className: styles$4["answerNoTime"]
10473
10922
  }, "-")), React.createElement("div", {
10474
10923
  className: styles["custom-col-2"],
10475
10924
  style: {
@@ -10480,12 +10929,12 @@ function MyAnswer(_ref) {
10480
10929
  style: {
10481
10930
  margin: 0
10482
10931
  },
10483
- className: styles$3["answer-response"] + " " + styles$3["answer-response-" + question.answerResponseSignal]
10484
- }, question.overallCorrectRate + "%") : React.createElement("p", {
10932
+ className: styles$4["answer-response"] + " " + styles$4["answer-response-" + question.answerResponseSignal]
10933
+ }, question.overallCorrectRate.toFixed(2) + "%") : React.createElement("p", {
10485
10934
  style: {
10486
10935
  margin: 0
10487
10936
  },
10488
- className: styles$3["answerNoTime"]
10937
+ className: styles$4["answerNoTime"]
10489
10938
  }, "\uC2DC\uAC04 \uC5C6\uC74C")), isStudent && React.createElement("div", {
10490
10939
  className: styles["custom-col-2"],
10491
10940
  style: {
@@ -10556,11 +11005,11 @@ var iconBtnNextChart = function iconBtnNextChart(_ref) {
10556
11005
  function CompareGrass(_ref) {
10557
11006
  var effectSize = _ref.effectSize;
10558
11007
  return React.createElement("div", {
10559
- className: styles$3["compareGrass"]
11008
+ className: styles$4["compareGrass"]
10560
11009
  }, React.createElement("div", {
10561
- className: styles$3["tableCompareGrass"]
11010
+ className: styles$4["tableCompareGrass"]
10562
11011
  }, React.createElement("div", {
10563
- className: styles$3["table-responsive"]
11012
+ className: styles$4["table-responsive"]
10564
11013
  }, React.createElement(Table, {
10565
11014
  style: {
10566
11015
  width: "100%"
@@ -10570,7 +11019,7 @@ function CompareGrass(_ref) {
10570
11019
  borderBottom: "1px solid #E4E7EC"
10571
11020
  }
10572
11021
  }, React.createElement("tr", null, React.createElement("th", {
10573
- className: styles$3["thcolumn1"]
11022
+ className: styles$4["thcolumn1"]
10574
11023
  }, "\uBB38\uC81C \uBC88\uD638"), React.createElement("th", {
10575
11024
  style: {
10576
11025
  textAlign: "center"
@@ -10594,14 +11043,14 @@ function CompareGrass(_ref) {
10594
11043
  borderBottom: "1px solid #e4e7ec"
10595
11044
  } : {}
10596
11045
  }, React.createElement("td", {
10597
- className: styles$3["tdcolumn1"]
11046
+ className: styles$4["tdcolumn1"]
10598
11047
  }, "\uBB38\uC81C ", item.questionOrder + 1), React.createElement("td", {
10599
11048
  style: {
10600
11049
  textAlign: "center",
10601
11050
  color: "#202B37"
10602
11051
  }
10603
11052
  }, item.correctAnswers, "\uBC88"), React.createElement("td", {
10604
- className: styles$3["tdcolumn3"],
11053
+ className: styles$4["tdcolumn3"],
10605
11054
  style: {
10606
11055
  color: item.isCorrect ? "#1EE288" : "#F34B4B"
10607
11056
  }
@@ -10611,7 +11060,7 @@ function CompareGrass(_ref) {
10611
11060
  color: "#414E62"
10612
11061
  }
10613
11062
  }, item.mostSelectedAnswers ? item.mostSelectedAnswers + "\uBC88" : ""), React.createElement("td", null, React.createElement("div", {
10614
- className: styles$3["classification"]
11063
+ className: styles$4["classification"]
10615
11064
  }, item.problemCategories.map(function (problem, index) {
10616
11065
  return React.createElement("div", {
10617
11066
  key: index
@@ -10738,9 +11187,9 @@ function TrickyProblem(_ref) {
10738
11187
  return i.isStar && i.isCorrect;
10739
11188
  });
10740
11189
  return React.createElement("div", {
10741
- className: styles$3["wrapperProblem"]
11190
+ className: styles$4["wrapperProblem"]
10742
11191
  }, React.createElement("div", {
10743
- className: !openProblem.problem1 ? styles$3["titleProblemClose"] : styles$3["titleProblem"],
11192
+ className: !openProblem.problem1 ? styles$4["titleProblemClose"] : styles$4["titleProblem"],
10744
11193
  onClick: function onClick() {
10745
11194
  return changeOpen(_extends({}, openProblem, {
10746
11195
  problem1: !openProblem.problem1
@@ -10753,27 +11202,27 @@ function TrickyProblem(_ref) {
10753
11202
  fontWeight: 700
10754
11203
  }
10755
11204
  }, "\uAE4C\uB2E4\uB85C\uC6E0\uB358 \uBB38\uC81C"), openProblem.problem1 ? React.createElement(iconUpArrow, null) : React.createElement(iconDownArrow, null)), openProblem.problem1 && React.createElement(Fragment$1, null, React.createElement("div", {
10756
- className: styles$3["titleTrickyProblem"]
11205
+ className: styles$4["titleTrickyProblem"]
10757
11206
  }, React.createElement(iconX, null), React.createElement("span", null, "\uBCC4\uD45C \uCE5C \uBB38\uC81C \uC911 \uD2C0\uB9B0 \uBB38\uC81C")), React.createElement("div", {
10758
- className: styles$3["wrongQuestions"]
11207
+ className: styles$4["wrongQuestions"]
10759
11208
  }, !!inCorrectQuestions.length && inCorrectQuestions.map(function (question) {
10760
11209
  return React.createElement("span", {
10761
11210
  key: question.id,
10762
- className: styles$3["question"]
11211
+ className: styles$4["question"]
10763
11212
  }, question.questionOrder + 1, "\uBC88");
10764
11213
  }), !data.questions.length && React.createElement("div", {
10765
- className: styles$3["noData"]
11214
+ className: styles$4["noData"]
10766
11215
  }, "\uB370\uC774\uD130 \uC5C6\uC74C")), React.createElement("div", {
10767
- className: styles$3["titleTrickyProblem"]
11216
+ className: styles$4["titleTrickyProblem"]
10768
11217
  }, React.createElement(iconAssignedQuestions, null), React.createElement("span", null, "\uBCC4\uD45C \uCE5C \uBB38\uC81C \uC911 \uB9DE\uCD98 \uBB38\uC81C")), React.createElement("div", {
10769
- className: styles$3["assignedQuestions"]
11218
+ className: styles$4["assignedQuestions"]
10770
11219
  }, !!correctQuestions.length && correctQuestions.map(function (question) {
10771
11220
  return React.createElement("div", {
10772
11221
  key: question.id,
10773
- className: styles$3["question"]
11222
+ className: styles$4["question"]
10774
11223
  }, question.questionOrder + 1, "\uBC88");
10775
11224
  }), !data.questions.length && React.createElement("div", {
10776
- className: styles$3["noData"]
11225
+ className: styles$4["noData"]
10777
11226
  }, "\uB370\uC774\uD130 \uC5C6\uC74C"))));
10778
11227
  }
10779
11228
 
@@ -10784,9 +11233,9 @@ function ProtractedProblem(_ref) {
10784
11233
  var _useTranslation = useTranslation(),
10785
11234
  t = _useTranslation.t;
10786
11235
  return React.createElement("div", {
10787
- className: styles$3["wrapperProblem"]
11236
+ className: styles$4["wrapperProblem"]
10788
11237
  }, React.createElement("div", {
10789
- className: !openProblem.problem2 ? styles$3["titleProblemClose"] : styles$3["titleProblem"],
11238
+ className: !openProblem.problem2 ? styles$4["titleProblemClose"] : styles$4["titleProblem"],
10790
11239
  onClick: function onClick() {
10791
11240
  return changeOpen(_extends({}, openProblem, {
10792
11241
  problem2: !openProblem.problem2
@@ -10799,30 +11248,30 @@ function ProtractedProblem(_ref) {
10799
11248
  fontWeight: 700
10800
11249
  }
10801
11250
  }, "\uC2DC\uAC04\uC774 \uC624\uB798 \uAC78\uB9B0 \uBB38\uC81C"), openProblem.problem2 ? React.createElement(iconUpArrow, null) : React.createElement(iconDownArrow, null)), openProblem.problem2 && React.createElement(Fragment$1, null, React.createElement("div", {
10802
- className: styles$3["wrapperContent"]
11251
+ className: styles$4["wrapperContent"]
10803
11252
  }, data.length ? data.map(function (item) {
10804
11253
  return React.createElement("div", {
10805
- className: styles$3["content"],
11254
+ className: styles$4["content"],
10806
11255
  key: item.id
10807
11256
  }, React.createElement("div", {
10808
- className: styles$3["contentColumn1"]
11257
+ className: styles$4["contentColumn1"]
10809
11258
  }, React.createElement("div", null, React.createElement("span", {
10810
- className: styles$3["span1"]
11259
+ className: styles$4["span1"]
10811
11260
  }, "\uBB38\uC81C"), React.createElement("span", {
10812
- className: styles$3["span2"]
11261
+ className: styles$4["span2"]
10813
11262
  }, item.questionOrder + 1, "\uBC88"))), React.createElement("div", {
10814
- className: styles$3["contentColumn2"]
11263
+ className: styles$4["contentColumn2"]
10815
11264
  }, React.createElement("div", null, React.createElement("span", {
10816
- className: styles$3["span1"]
11265
+ className: styles$4["span1"]
10817
11266
  }, "\uB098\uC758 \uC2DC\uAC04"), React.createElement("span", {
10818
- className: styles$3["span2"]
11267
+ className: styles$4["span2"]
10819
11268
  }, "\uC0C1\uC704\uAD8C \uC2DC\uAC04")), React.createElement("div", null, React.createElement("span", {
10820
- className: styles$3["duration"]
11269
+ className: styles$4["duration"]
10821
11270
  }, formatTimeSecond(item.duration, t)), React.createElement("span", {
10822
- className: styles$3["topDuration"]
11271
+ className: styles$4["topDuration"]
10823
11272
  }, formatTimeSecond(item.topDuration, t)))));
10824
11273
  }) : React.createElement("div", {
10825
- className: styles$3["noData"]
11274
+ className: styles$4["noData"]
10826
11275
  }, "\uB370\uC774\uD130 \uC5C6\uC74C"))));
10827
11276
  }
10828
11277
 
@@ -10836,9 +11285,9 @@ function Vulnerable(_ref) {
10836
11285
  return q2.overallCorrectRate === q1.overallCorrectRate ? q1.questionOrder - q2.questionOrder : q2.overallCorrectRate - q1.overallCorrectRate;
10837
11286
  });
10838
11287
  return React.createElement("div", {
10839
- className: styles$3["wrapperProblem"]
11288
+ className: styles$4["wrapperProblem"]
10840
11289
  }, React.createElement("div", {
10841
- className: !openProblem.problem3 ? styles$3["titleProblemClose"] : styles$3["titleProblem"],
11290
+ className: !openProblem.problem3 ? styles$4["titleProblemClose"] : styles$4["titleProblem"],
10842
11291
  onClick: function onClick() {
10843
11292
  return changeOpen(_extends({}, openProblem, {
10844
11293
  problem3: !openProblem.problem3
@@ -10851,30 +11300,30 @@ function Vulnerable(_ref) {
10851
11300
  fontWeight: 700
10852
11301
  }
10853
11302
  }, "\uB0B4\uAC00 \uCDE8\uC57D\uD55C \uBB38\uC81C"), openProblem.problem3 ? React.createElement(iconUpArrow, null) : React.createElement(iconDownArrow, null)), openProblem.problem3 && React.createElement(Fragment$1, null, React.createElement("div", {
10854
- className: styles$3["wrapperContent"]
11303
+ className: styles$4["wrapperContent"]
10855
11304
  }, incorrectQuestions.length ? React.createElement(Fragment$1, null, incorrectQuestions.map(function (question) {
10856
11305
  return React.createElement("div", {
10857
- className: styles$3["content"],
11306
+ className: styles$4["content"],
10858
11307
  key: question.id
10859
11308
  }, React.createElement("div", {
10860
- className: styles$3["contentColumn1"]
11309
+ className: styles$4["contentColumn1"]
10861
11310
  }, React.createElement("div", null, React.createElement("span", {
10862
- className: styles$3["span1"]
11311
+ className: styles$4["span1"]
10863
11312
  }, "\uBB38\uC81C"), React.createElement("span", {
10864
- className: styles$3["span2"]
11313
+ className: styles$4["span2"]
10865
11314
  }, question.questionOrder + 1, "\uBC88"))), React.createElement("div", {
10866
- className: styles$3["contentColumn2"]
11315
+ className: styles$4["contentColumn2"]
10867
11316
  }, React.createElement("div", null, React.createElement("span", {
10868
- className: styles$3["span1"]
11317
+ className: styles$4["span1"]
10869
11318
  }, "\uC804\uCCB4 \uC815\uB2F5\uB960"), React.createElement("span", {
10870
- className: styles$3["span2"]
11319
+ className: styles$4["span2"]
10871
11320
  }, "\uB098\uC758 \uC624\uB2F5")), React.createElement("div", null, React.createElement("span", {
10872
- className: styles$3["overallCorrectRate"]
11321
+ className: styles$4["overallCorrectRate"]
10873
11322
  }, question.overallCorrectRate.toFixed(2), "%"), React.createElement("span", {
10874
- className: styles$3["answer"]
11323
+ className: styles$4["answer"]
10875
11324
  }, question.selectedAnswers, "\uBC88 (\uC815\uB2F5", " ", question.correctAnswers, "\uBC88)"))));
10876
11325
  })) : React.createElement("div", {
10877
- className: styles$3["noData"]
11326
+ className: styles$4["noData"]
10878
11327
  }, "\uB370\uC774\uD130 \uC5C6\uC74C"))));
10879
11328
  }
10880
11329
 
@@ -10883,9 +11332,9 @@ function GradesByTerritory(_ref) {
10883
11332
  openProblem = _ref.openProblem,
10884
11333
  changeOpen = _ref.changeOpen;
10885
11334
  return React.createElement("div", {
10886
- className: styles$3["wrapperProblem"]
11335
+ className: styles$4["wrapperProblem"]
10887
11336
  }, React.createElement("div", {
10888
- className: !openProblem.problem4 ? styles$3["titleProblemClose"] : styles$3["titleProblem"],
11337
+ className: !openProblem.problem4 ? styles$4["titleProblemClose"] : styles$4["titleProblem"],
10889
11338
  onClick: function onClick() {
10890
11339
  return changeOpen(_extends({}, openProblem, {
10891
11340
  problem4: !openProblem.problem4
@@ -10898,27 +11347,27 @@ function GradesByTerritory(_ref) {
10898
11347
  fontWeight: 700
10899
11348
  }
10900
11349
  }, "\uC601\uC5ED\uBCC4 \uC131\uC801"), openProblem.problem4 ? React.createElement(iconUpArrow, null) : React.createElement(iconDownArrow, null)), openProblem.problem4 && React.createElement("div", {
10901
- className: styles$3["wrappContentProblem"]
11350
+ className: styles$4["wrappContentProblem"]
10902
11351
  }, data.length && data.map(function (item) {
10903
11352
  return React.createElement("div", {
10904
- className: styles$3["contentProblem"],
11353
+ className: styles$4["contentProblem"],
10905
11354
  key: item.id
10906
11355
  }, React.createElement("div", {
10907
- className: styles$3["labelProblem"]
11356
+ className: styles$4["labelProblem"]
10908
11357
  }, React.createElement("span", {
10909
- className: styles$3["name"]
11358
+ className: styles$4["name"]
10910
11359
  }, item.name), React.createElement("div", {
10911
- className: styles$3["percent"]
11360
+ className: styles$4["percent"]
10912
11361
  }, React.createElement("span", null, item.percentageAmongStudents.toFixed(2), "%"), React.createElement("span", null, item.totalCorrectQuestions, "/", item.totalQuestions, "\uBB38\uC81C"))), React.createElement("div", {
10913
- className: styles$3["slider"]
11362
+ className: styles$4["slider"]
10914
11363
  }, React.createElement("span", {
10915
- className: styles$3["track"],
11364
+ className: styles$4["track"],
10916
11365
  style: {
10917
11366
  left: item.percentageAmongStudents + "%"
10918
11367
  }
10919
11368
  })));
10920
11369
  }), openProblem.problem4 && !data.length && React.createElement("div", {
10921
- className: styles$3["noData"]
11370
+ className: styles$4["noData"]
10922
11371
  }, "\uB370\uC774\uD130 \uC5C6\uC74C")));
10923
11372
  }
10924
11373
 
@@ -11011,7 +11460,7 @@ function CreateNewQuestionDialog$1(_ref) {
11011
11460
  var errors = _ref2.errors;
11012
11461
  return React.createElement(Form, null, React.createElement("label", {
11013
11462
  htmlFor: "content-question",
11014
- className: styles['form-label'] + " " + styles$3['form-label-dialog']
11463
+ className: styles['form-label'] + " " + styles$4['form-label-dialog']
11015
11464
  }, "\uC9C8\uBB38 \uB0B4\uC6A9"), React.createElement(Box, {
11016
11465
  position: 'relative',
11017
11466
  display: 'flex',
@@ -11046,14 +11495,14 @@ function CreateNewQuestionDialog$1(_ref) {
11046
11495
  padding: '12px'
11047
11496
  }
11048
11497
  }, React.createElement(Button$1, {
11049
- className: styles$3['btn-cancel'],
11498
+ className: styles$4['btn-cancel'],
11050
11499
  onClick: toggleCreateQuestion
11051
11500
  }, React.createElement(Typography$1, {
11052
11501
  fontWeight: 700,
11053
11502
  fontSize: '14px',
11054
11503
  lineHeight: '16.71px'
11055
11504
  }, "\uCDE8\uC18C")), React.createElement(Button$1, {
11056
- className: styles$3['btn-register'],
11505
+ className: styles$4['btn-register'],
11057
11506
  type: "submit"
11058
11507
  }, React.createElement(Typography$1, {
11059
11508
  fontWeight: 700,
@@ -11064,12 +11513,12 @@ function CreateNewQuestionDialog$1(_ref) {
11064
11513
  })));
11065
11514
  }
11066
11515
 
11067
- var _excluded$6 = ["children", "value", "index"];
11516
+ var _excluded$7 = ["children", "value", "index"];
11068
11517
  var CustomTabPanel = function CustomTabPanel(props) {
11069
11518
  var children = props.children,
11070
11519
  value = props.value,
11071
11520
  index = props.index,
11072
- other = _objectWithoutPropertiesLoose(props, _excluded$6);
11521
+ other = _objectWithoutPropertiesLoose(props, _excluded$7);
11073
11522
  return React.createElement("div", Object.assign({
11074
11523
  role: "tabpanel",
11075
11524
  hidden: value !== index,
@@ -11257,9 +11706,9 @@ var ExamResultV2 = function ExamResultV2(_ref) {
11257
11706
  alignItems: "end",
11258
11707
  bgcolor: "#F9FAFB"
11259
11708
  }, React.createElement("div", {
11260
- className: styles$3["pdfBtnBox"]
11709
+ className: styles$4["pdfBtnBox"]
11261
11710
  }, React.createElement("button", {
11262
- className: styles$3["pdfBtn"] + " " + styles["truncate"],
11711
+ className: styles$4["pdfBtn"] + " " + styles["truncate"],
11263
11712
  onClick: handleExportPdf
11264
11713
  }, React.createElement(iconPrintFill, null), React.createElement("p", null, t("print"))))))), React.createElement(Grid, {
11265
11714
  item: true,
@@ -11299,9 +11748,9 @@ var ExamResultV2 = function ExamResultV2(_ref) {
11299
11748
  alignItems: "end",
11300
11749
  bgcolor: "#F9FAFB"
11301
11750
  }, React.createElement("div", {
11302
- className: styles$3["pdfBtnBox"]
11751
+ className: styles$4["pdfBtnBox"]
11303
11752
  }, React.createElement("button", {
11304
- className: styles$3["pdfBtn"] + " " + styles["truncate"],
11753
+ className: styles$4["pdfBtn"] + " " + styles["truncate"],
11305
11754
  onClick: handleExportPdf
11306
11755
  }, React.createElement(iconPrintFill, null), React.createElement("p", null, t("print"))))))), React.createElement(Grid, {
11307
11756
  item: true,
@@ -11317,18 +11766,18 @@ var ExamResultV2 = function ExamResultV2(_ref) {
11317
11766
  value: selected,
11318
11767
  index: 1
11319
11768
  }, React.createElement("div", {
11320
- className: styles$3["compareChart"]
11769
+ className: styles$4["compareChart"]
11321
11770
  }, React.createElement("div", {
11322
- className: styles$3["prevChart"] + " " + (dataChartIndex > 0 && "pointer"),
11771
+ className: styles$4["prevChart"] + " " + (dataChartIndex > 0 && "pointer"),
11323
11772
  onClick: handlePrevChart
11324
11773
  }, React.createElement(iconBtnPrevChart, null)), React.createElement("div", {
11325
- className: styles$3["chart"] + " sr-line-chart"
11774
+ className: styles$4["chart"] + " sr-line-chart"
11326
11775
  }, React.createElement("div", null, React.createElement(ReactApexChart, {
11327
11776
  height: 389,
11328
11777
  options: chartOptions,
11329
11778
  series: series
11330
11779
  }))), React.createElement("div", {
11331
- className: styles$3["nextChart"] + " " + (dataChartIndex < timelyOrderQuestion.length - 1 && "pointer"),
11780
+ className: styles$4["nextChart"] + " " + (dataChartIndex < timelyOrderQuestion.length - 1 && "pointer"),
11332
11781
  onClick: handleNextChart
11333
11782
  }, React.createElement(iconBtnNextChart, null)))), React.createElement(CustomTabPanel, {
11334
11783
  value: selected,
@@ -11363,39 +11812,70 @@ var ExamResultV2 = function ExamResultV2(_ref) {
11363
11812
  width: "100%"
11364
11813
  },
11365
11814
  id: "canvas"
11366
- }, React.createElement(CustomTabPanel, {
11367
- value: selected,
11368
- index: 0
11369
- }, React.createElement(MyAnswer, {
11815
+ }, React.createElement(Stack, {
11816
+ display: "flex",
11817
+ flexDirection: "column",
11818
+ gap: "12px"
11819
+ }, React.createElement(Typography, {
11820
+ sx: {
11821
+ fontSize: "16px",
11822
+ fontWeight: 700,
11823
+ color: "#414E62"
11824
+ }
11825
+ }, t(TabList[0].label)), React.createElement(MyAnswer, {
11370
11826
  data: resultDatas,
11371
11827
  categories: categoryResponses,
11372
11828
  isStudent: isStudent
11373
- })), React.createElement(CustomTabPanel, {
11374
- value: selected,
11375
- index: 1
11376
- }, React.createElement("div", {
11377
- className: styles$3["compareChart"]
11829
+ })), React.createElement(Stack, {
11830
+ display: "flex",
11831
+ flexDirection: "column",
11832
+ gap: "12px",
11833
+ marginTop: "24px"
11834
+ }, React.createElement(Typography, {
11835
+ sx: {
11836
+ fontSize: "16px",
11837
+ fontWeight: 700,
11838
+ color: "#414E62"
11839
+ }
11840
+ }, t(TabList[1].label)), React.createElement("div", {
11841
+ className: styles$4["compareChart"]
11378
11842
  }, React.createElement("div", {
11379
- className: styles$3["prevChart"] + " " + (dataChartIndex > 0 && "pointer"),
11843
+ className: styles$4["prevChart"] + " " + (dataChartIndex > 0 && "pointer"),
11380
11844
  onClick: handlePrevChart
11381
11845
  }, React.createElement(iconBtnPrevChart, null)), React.createElement("div", {
11382
- className: styles$3["chart"] + " sr-line-chart"
11846
+ className: styles$4["chart"] + " sr-line-chart"
11383
11847
  }, React.createElement("div", null, React.createElement(ReactApexChart, {
11384
11848
  height: 389,
11385
11849
  options: chartOptions,
11386
11850
  series: series
11387
11851
  }))), React.createElement("div", {
11388
- className: styles$3["nextChart"] + " " + (dataChartIndex < timelyOrderQuestion.length - 1 && "pointer"),
11852
+ className: styles$4["nextChart"] + " " + (dataChartIndex < timelyOrderQuestion.length - 1 && "pointer"),
11389
11853
  onClick: handleNextChart
11390
- }, React.createElement(iconBtnNextChart, null)))), React.createElement(CustomTabPanel, {
11391
- value: selected,
11392
- index: 2
11393
- }, React.createElement(CompareGrass, {
11854
+ }, React.createElement(iconBtnNextChart, null)))), React.createElement(Stack, {
11855
+ display: "flex",
11856
+ flexDirection: "column",
11857
+ gap: "12px",
11858
+ marginTop: "24px"
11859
+ }, React.createElement(Typography, {
11860
+ sx: {
11861
+ fontSize: "16px",
11862
+ fontWeight: 700,
11863
+ color: "#414E62"
11864
+ }
11865
+ }, t(TabList[2].label)), React.createElement(CompareGrass, {
11394
11866
  effectSize: effectSize
11395
- })), React.createElement(CustomTabPanel, {
11396
- value: selected,
11397
- index: 3
11398
- }, React.createElement(TrickyProblem, {
11867
+ })), React.createElement(Stack, {
11868
+ display: "flex",
11869
+ flexDirection: "column",
11870
+ gap: "12px",
11871
+ marginTop: "24px"
11872
+ }, React.createElement(Typography, {
11873
+ sx: {
11874
+ fontSize: "16px",
11875
+ fontWeight: 700,
11876
+ color: "#414E62"
11877
+ }
11878
+ }, t(TabList[3].label)), React.createElement(TrickyProblem, {
11399
11879
  data: resultDatas,
11400
11880
  openProblem: _extends({}, openProblem, {
11401
11881
  problem1: true