touchstudy-core 0.1.151 → 0.1.152

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.
@@ -1,10 +1,8 @@
1
1
  import { FC } from "react";
2
- import { CategoryResponse } from "../../../../utils/types/examResults";
3
2
  import { TextbookResult } from "../../configs/types";
4
3
  interface Props {
5
4
  data: TextbookResult;
6
5
  questionIdContextMenu?: number;
7
- categories: CategoryResponse[];
8
6
  itemProps?: any;
9
7
  isStudent: boolean;
10
8
  }
@@ -14,7 +14,7 @@ export interface TextbookAnswerItemProps extends TextbookAnswerItemBaseProps {
14
14
  nextData?: StudentQuestionResult;
15
15
  isLast?: boolean;
16
16
  isFirst?: boolean;
17
- categoryId: number;
17
+ questionGroupId: number;
18
18
  }
19
19
  export interface TextbookAnswerItemBaseProps {
20
20
  menuContextActions?: Action<StudentQuestionResult>[];
@@ -55,6 +55,7 @@ export declare type TextbookResult = {
55
55
  };
56
56
  export declare type StudentQuestionResult = {
57
57
  id: number;
58
+ questionGroupId: number;
58
59
  selectedAnswers?: number[] | string;
59
60
  correctAnswers?: number[] | string;
60
61
  textualAnswers?: string[];
package/dist/index.js CHANGED
@@ -6516,26 +6516,23 @@ var formatDataMyAnswer = function formatDataMyAnswer(inputData, categories) {
6516
6516
  });
6517
6517
  return questionsByCategory;
6518
6518
  };
6519
- var formatTextbookDataMyAnswer = function formatTextbookDataMyAnswer(inputData, categories) {
6520
- var uniqueCategories = new Set();
6521
- var filterCategories = categories.filter(function (category) {
6522
- if (!uniqueCategories.has(category.name)) {
6523
- uniqueCategories.add(category.name);
6524
- return true;
6525
- }
6526
- return false;
6527
- });
6528
- var questionsByCategory = filterCategories.map(function (category) {
6519
+ var formatTextbookDataMyAnswer = function formatTextbookDataMyAnswer(inputData, questionGroupIds) {
6520
+ var questionsByCategories = questionGroupIds.map(function (questionGroupId) {
6521
+ var _questions$, _questions$$categorie, _questions$2, _questions$2$categori;
6522
+ var questions = inputData.studentQuestionResults.filter(function (question) {
6523
+ return question.questionGroupId === questionGroupId;
6524
+ });
6525
+ var category = questions === null || questions === void 0 ? void 0 : (_questions$ = questions[0]) === null || _questions$ === void 0 ? void 0 : (_questions$$categorie = _questions$.categories) === null || _questions$$categorie === void 0 ? void 0 : _questions$$categorie[0];
6526
+ var subcategory = !category ? null : questions === null || questions === void 0 ? void 0 : (_questions$2 = questions[0]) === null || _questions$2 === void 0 ? void 0 : (_questions$2$categori = _questions$2.categories) === null || _questions$2$categori === void 0 ? void 0 : _questions$2$categori.find(function (c) {
6527
+ return !!c.parentCategoryId && c.parentCategoryId === (category === null || category === void 0 ? void 0 : category.id);
6528
+ });
6529
6529
  return {
6530
- category: category,
6531
- questions: inputData.studentQuestionResults.filter(function (question) {
6532
- return !!question.categories.find(function (i) {
6533
- return i.name === category.name;
6534
- });
6535
- })
6530
+ categories: category && subcategory ? [category, subcategory] : category ? [category] : [],
6531
+ questions: questions,
6532
+ questionGroupId: questionGroupId
6536
6533
  };
6537
6534
  });
6538
- return questionsByCategory;
6535
+ return questionsByCategories;
6539
6536
  };
6540
6537
  var totalSolveTimeCategories = function totalSolveTimeCategories(inputData, categories) {
6541
6538
  var uniqueCategories = new Set();
@@ -18498,7 +18495,7 @@ var TextbookAnswerItem = function TextbookAnswerItem(_ref) {
18498
18495
  nextData = _ref.nextData,
18499
18496
  isFirst = _ref.isFirst,
18500
18497
  isLast = _ref.isLast,
18501
- categoryId = _ref.categoryId,
18498
+ questionGroupId = _ref.questionGroupId,
18502
18499
  _ref$menuContextActio = _ref.menuContextActions,
18503
18500
  menuContextActions = _ref$menuContextActio === void 0 ? [] : _ref$menuContextActio,
18504
18501
  openContextMenu = _ref.openContextMenu,
@@ -18510,14 +18507,14 @@ var TextbookAnswerItem = function TextbookAnswerItem(_ref) {
18510
18507
  var isLearningSpace = getLearningSpace();
18511
18508
  var handleCloseContextMenu = function handleCloseContextMenu() {
18512
18509
  onCloseContextMenu === null || onCloseContextMenu === void 0 ? void 0 : onCloseContextMenu(_extends({}, data, {
18513
- id: ((data === null || data === void 0 ? void 0 : data.id) || 0) + categoryId
18510
+ id: ((data === null || data === void 0 ? void 0 : data.id) || 0) + questionGroupId
18514
18511
  }));
18515
18512
  };
18516
18513
  var handleMoreClick = function handleMoreClick(e) {
18517
18514
  e.preventDefault();
18518
18515
  e.stopPropagation();
18519
18516
  onOpenContextMenu === null || onOpenContextMenu === void 0 ? void 0 : onOpenContextMenu(_extends({}, data, {
18520
- id: ((data === null || data === void 0 ? void 0 : data.id) || 0) + categoryId
18517
+ id: ((data === null || data === void 0 ? void 0 : data.id) || 0) + questionGroupId
18521
18518
  }));
18522
18519
  };
18523
18520
  return React__default.createElement("div", {
@@ -18644,24 +18641,28 @@ var TextbookAnswerItem = function TextbookAnswerItem(_ref) {
18644
18641
 
18645
18642
  var TextbookMyAnswer = function TextbookMyAnswer(_ref) {
18646
18643
  var data = _ref.data,
18647
- categories = _ref.categories,
18648
18644
  itemProps = _ref.itemProps,
18649
18645
  questionIdContextMenu = _ref.questionIdContextMenu,
18650
18646
  isStudent = _ref.isStudent;
18651
- var formattedData = formatTextbookDataMyAnswer(data, categories);
18647
+ var questionGroupIds = Array.from(new Set(data.studentQuestionResults.map(function (i) {
18648
+ return i.questionGroupId;
18649
+ }))).sort(function (a, b) {
18650
+ return a - b;
18651
+ });
18652
+ var formattedData = formatTextbookDataMyAnswer(data, questionGroupIds);
18652
18653
  var _useTranslation = reactI18next.useTranslation(),
18653
18654
  t = _useTranslation.t;
18654
- var renderAnswer = function renderAnswer(item, index, questions, categoryId) {
18655
+ var renderAnswer = function renderAnswer(item, index, questions, questionGroupId) {
18655
18656
  var nextItem = index < questions.length - 1 ? questions[index + 1] : undefined;
18656
18657
  var isLast = index === questions.length - 1;
18657
18658
  var isFirst = index === 0;
18658
- var isSelected = (item === null || item === void 0 ? void 0 : item.id) + categoryId === questionIdContextMenu;
18659
+ var isSelected = (item === null || item === void 0 ? void 0 : item.id) + questionGroupId === questionIdContextMenu;
18659
18660
  return React__default.createElement(TextbookAnswerItem, Object.assign({
18660
18661
  key: index
18661
18662
  }, itemProps, {
18662
18663
  openContextMenu: isSelected,
18663
18664
  data: item,
18664
- categoryId: categoryId,
18665
+ questionGroupId: questionGroupId,
18665
18666
  nextData: nextItem,
18666
18667
  isLast: isLast,
18667
18668
  isFirst: isFirst,
@@ -18671,8 +18672,9 @@ var TextbookMyAnswer = function TextbookMyAnswer(_ref) {
18671
18672
  return React__default.createElement("div", {
18672
18673
  className: "" + styles$4["myanswer"]
18673
18674
  }, formattedData && formattedData.length > 0 && formattedData.map(function (item) {
18675
+ var _item$categories;
18674
18676
  return React__default.createElement("div", {
18675
- key: item.category.id
18677
+ key: item.questionGroupId
18676
18678
  }, React__default.createElement("div", {
18677
18679
  className: "" + printStyles["avoid-break-inside"]
18678
18680
  }, React__default.createElement(material.Stack, {
@@ -18770,12 +18772,14 @@ var TextbookMyAnswer = function TextbookMyAnswer(_ref) {
18770
18772
  fontSize: "12px",
18771
18773
  fontWeight: 700
18772
18774
  }
18773
- }, item.category.name))), React__default.createElement("div", {
18775
+ }, (_item$categories = item.categories) === null || _item$categories === void 0 ? void 0 : _item$categories.map(function (i) {
18776
+ return i.name;
18777
+ }).join(" / ")))), React__default.createElement("div", {
18774
18778
  className: styles$4["contentMyAnswer"]
18775
18779
  }, React__default.createElement(ListView, {
18776
18780
  data: item.questions,
18777
18781
  render: function render(question, index) {
18778
- return renderAnswer(question, index, item.questions, item.category.id);
18782
+ return renderAnswer(question, index, item.questions, item.questionGroupId);
18779
18783
  }
18780
18784
  })));
18781
18785
  }));
@@ -20887,7 +20891,6 @@ var ExamResultV2 = function ExamResultV2(props) {
20887
20891
  index: 0
20888
20892
  }, chapterId ? textbookResult && React__default.createElement(TextbookMyAnswer, {
20889
20893
  data: textbookResult,
20890
- categories: categoryResponses,
20891
20894
  isStudent: isStudent,
20892
20895
  questionIdContextMenu: questionIdContextMenu,
20893
20896
  itemProps: questionItemProp