l-min-components 1.7.1514 → 1.7.1515

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "l-min-components",
3
- "version": "1.7.1514",
3
+ "version": "1.7.1515",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "src/assets",
@@ -655,6 +655,39 @@ function toRGBA(rgbaString, alpha = 1) {
655
655
  const [r, g, b] = rgbaString.match(/\d+/g).map(Number);
656
656
  return `rgba(${r}, ${g}, ${b}, ${alpha})`;
657
657
  }
658
+
659
+ const getQuestionInfo = (question) => {
660
+ let type = "";
661
+ if (question?.type === "SOUND_PLAY") type = "sound-play";
662
+ else if (question?.question_data?.type === "DIALOGUE") {
663
+ if (
664
+ Object.values(question?.question_data?.dialogues_data || {})?.[0]
665
+ ?.type === "Scripted"
666
+ )
667
+ type = "dialogue-scripted";
668
+ else type = "dialogue-unscripted";
669
+ } else if (question?.question_data?.type === "WORD_PLAY") {
670
+ if (question?.question_data?.answer_format_data?.type === "Multiple Choice")
671
+ type = "word-play-multiple-choice";
672
+ else type = "word-play-text";
673
+ } else if (question?.type === "QUIZ") {
674
+ if (question?.question_data?.question_data?.type === "MultipleChoice")
675
+ type = "quiz-multiple-choice";
676
+ else if (question?.question_data?.question_data?.type === "UnScripted")
677
+ type = "quiz-unscripted";
678
+ else type = "quiz-scripted";
679
+ } else if (question?.type === "ESSAY") {
680
+ if (question?.question_data?.config?.type === "Scripted")
681
+ type = "essay-scripted";
682
+ else if (question?.question_data?.config?.type === "Written")
683
+ type = "essay-written";
684
+ else type = "essay-unscripted";
685
+ } else if (question?.question_data?.type === "READING") type = "reading";
686
+ else type = "match-pair";
687
+
688
+ return { type, data: question };
689
+ };
690
+
658
691
  const useReportUtils = () => {
659
692
  return {
660
693
  renderCorrectedSentence,
@@ -673,6 +706,7 @@ const useReportUtils = () => {
673
706
  getColor,
674
707
  grammarFindOperation,
675
708
  toRGBA,
709
+ getQuestionInfo,
676
710
  };
677
711
  };
678
712
 
@@ -44,38 +44,6 @@ import { InfoIcon } from "lucide-react";
44
44
  import InfoIcon2 from "../fullAnalysis/icons/info";
45
45
  import { NavBack, NavForword } from "../fullAnalysis/icons/navArrow";
46
46
 
47
- const getQuestionInfo = (question) => {
48
- let type = "";
49
- if (question?.type === "SOUND_PLAY") type = "sound-play";
50
- else if (question?.question_data?.type === "DIALOGUE") {
51
- if (
52
- Object.values(question?.question_data?.dialogues_data || {})?.[0]
53
- ?.type === "Scripted"
54
- )
55
- type = "dialogue-scripted";
56
- else type = "dialogue-unscripted";
57
- } else if (question?.question_data?.type === "WORD_PLAY") {
58
- if (question?.question_data?.answer_format_data?.type === "Multiple Choice")
59
- type = "word-play-multiple-choice";
60
- else type = "word-play-text";
61
- } else if (question?.type === "QUIZ") {
62
- if (question?.question_data?.question_data?.type === "MultipleChoice")
63
- type = "quiz-multiple-choice";
64
- else if (question?.question_data?.question_data?.type === "UnScripted")
65
- type = "quiz-unscripted";
66
- else type = "quiz-scripted";
67
- } else if (question?.type === "ESSAY") {
68
- if (question?.question_data?.config?.type === "Scripted")
69
- type = "essay-scripted";
70
- else if (question?.question_data?.config?.type === "Written")
71
- type = "essay-written";
72
- else type = "essay-unscripted";
73
- } else if (question?.question_data?.type === "READING") type = "reading";
74
- else type = "match-pair";
75
-
76
- return { type, data: question };
77
- };
78
-
79
47
  /**
80
48
  * @param {Object} props
81
49
 
@@ -100,10 +68,18 @@ const ReportQuestions = ({
100
68
  answerData,
101
69
  onSwitchQuestion,
102
70
  }) => {
103
- const findedQuestion = questions?.find(
71
+ const [questionList, setQuestionList] = useState([]);
72
+
73
+ useEffect(() => {
74
+ if (questions?.length) {
75
+ setQuestionList(questions);
76
+ }
77
+ }, [questions]);
78
+
79
+ const findedQuestion = questionList?.find(
104
80
  (question) => question?.question_activity_id === questionActivityID
105
81
  );
106
-
82
+ const { getQuestionInfo } = useReportUtils();
107
83
  const questionType = getQuestionInfo(findedQuestion)?.type;
108
84
 
109
85
  const [comment, setComment] = useState(null);
@@ -178,11 +154,11 @@ const ReportQuestions = ({
178
154
  const nextId = questions?.[currentQuestionIndex + 1]?.question_activity_id;
179
155
 
180
156
  const handleNext = () => {
181
- if (nextId) onSwitchQuestion(nextId);
157
+ if (nextId) onSwitchQuestion?.(nextId);
182
158
  };
183
159
 
184
160
  const handlePrev = () => {
185
- if (prevId) onSwitchQuestion(prevId);
161
+ if (prevId) onSwitchQuestion?.(prevId);
186
162
  };
187
163
 
188
164
  return (