l-min-components 1.7.1574 → 1.7.1575

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.1574",
3
+ "version": "1.7.1575",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "src/assets",
@@ -435,21 +435,19 @@ const setupAnalysis = (data, audioData, score) => {
435
435
 
436
436
  const quizWrittenSelectedModel = (response, aiData) => {
437
437
  if (!response || !aiData) return null;
438
- const index = response?.index || 0;
438
+
439
+ const index = response?.index ?? 0;
439
440
  const objectData = {};
440
441
 
441
- if (aiData?.grammar?.[index] && aiData?.grammar?.length) {
442
- const findData = aiData?.grammar?.[index];
443
- objectData["grammar"] = [findData];
442
+ if (aiData?.grammar?.[index]) {
443
+ objectData.grammar = [aiData.grammar[index]];
444
444
  }
445
- if (
446
- aiData?.comprehension?.length &&
447
- aiData?.comprehension?.[0] &&
448
- index === 0
449
- ) {
450
- objectData["comprehension"] = aiData?.comprehension;
445
+
446
+ if (index === 0 && aiData?.comprehension?.length) {
447
+ objectData.comprehension = aiData.comprehension;
451
448
  }
452
- return objectData;
449
+
450
+ return Object.keys(objectData).length ? objectData : null;
453
451
  };
454
452
 
455
453
  const quixSelectedModel = (response, aiData) => {
@@ -712,41 +710,75 @@ function toRGBA(rgbaString, alpha = 1) {
712
710
  }
713
711
 
714
712
  const getQuestionInfo = (question) => {
715
- let type = "";
716
- if (question?.type === "SOUND_PLAY") type = "sound-play";
717
- else if (question?.question_data?.type === "DIALOGUE") {
718
- if (
719
- Object.values(question?.question_data?.dialogues_data || {})?.[0]
720
- ?.type === "Scripted"
721
- )
722
- type = "dialogue-scripted";
723
- else type = "dialogue-unscripted";
724
- } else if (question?.question_data?.type === "WORD_PLAY") {
725
- if (question?.question_data?.answer_format_data?.type === "Multiple Choice")
726
- type = "word-play-multiple-choice";
727
- else type = "word-play-text";
728
- } else if (question?.type === "QUIZ") {
729
- if (
730
- question?.question_data?.question_data?.type === "MultipleChoice" ||
731
- question?.question_data?.question_data?.type === "Multiple Choice"
732
- )
733
- type = "quiz-multiple-choice";
734
- else if (question?.question_data?.question_data?.type === "UnScripted")
735
- type = "quiz-unscripted";
736
- else if (question?.question_data?.question_data?.type === "Written")
737
- type = "quiz-written";
738
- else type = "quiz-scripted";
739
- } else if (question?.type === "ESSAY") {
740
- if (question?.question_data?.config?.type === "Scripted")
741
- type = "essay-scripted";
742
- else if (question?.question_data?.config?.type === "Written")
743
- type = "essay-written";
744
- else type = "essay-unscripted";
745
- } else if (question?.question_data?.type === "READING") type = "reading";
746
- else if (question?.type === "MATCH_PAIR") type = "match-pair";
747
- else type = "";
748
-
749
- return { type, data: question };
713
+ if (!question) return { type: "", data: question };
714
+
715
+ const qType = question.type;
716
+ const qData = question.question_data || {};
717
+ const innerType = qData?.question_data?.type;
718
+ const dialoguesData = Object.values(qData?.dialogues_data || {})[0];
719
+ const answerFormatType = qData?.answer_format_data?.type;
720
+ const essayType = qData?.config?.type;
721
+
722
+ // SOUND PLAY
723
+ if (qType === "SOUND_PLAY") return { type: "sound-play", data: question };
724
+
725
+ // DIALOGUE
726
+ if (qData.type === "DIALOGUE") {
727
+ return {
728
+ type:
729
+ dialoguesData?.type === "Scripted"
730
+ ? "dialogue-scripted"
731
+ : "dialogue-unscripted",
732
+ data: question,
733
+ };
734
+ }
735
+
736
+ // WORD PLAY
737
+ if (qData.type === "WORD_PLAY") {
738
+ return {
739
+ type:
740
+ answerFormatType === "Multiple Choice"
741
+ ? "word-play-multiple-choice"
742
+ : "word-play-text",
743
+ data: question,
744
+ };
745
+ }
746
+
747
+ // QUIZ
748
+ if (qType === "QUIZ") {
749
+ switch (innerType) {
750
+ case "MultipleChoice":
751
+ case "Multiple Choice":
752
+ return { type: "quiz-multiple-choice", data: question };
753
+ case "UnScripted":
754
+ return { type: "quiz-unscripted", data: question };
755
+ case "Written":
756
+ return { type: "quiz-written", data: question };
757
+ default:
758
+ return { type: "quiz-scripted", data: question };
759
+ }
760
+ }
761
+
762
+ // ESSAY
763
+ if (qType === "ESSAY") {
764
+ switch (essayType) {
765
+ case "Scripted":
766
+ return { type: "essay-scripted", data: question };
767
+ case "Written":
768
+ return { type: "essay-written", data: question };
769
+ default:
770
+ return { type: "essay-unscripted", data: question };
771
+ }
772
+ }
773
+
774
+ // READING
775
+ if (qData.type === "READING") return { type: "reading", data: question };
776
+
777
+ // MATCH PAIR
778
+ if (qType === "MATCH_PAIR") return { type: "match-pair", data: question };
779
+
780
+ // DEFAULT
781
+ return { type: "", data: question };
750
782
  };
751
783
 
752
784
  const useReportUtils = () => {
@@ -66,7 +66,7 @@ const QuizScripted = ({
66
66
  <QuizQuestion data={data} />
67
67
  </li>
68
68
  <li>
69
- <h3>{findText("Qyestion")}</h3>
69
+ <h3>{findText("Question")}</h3>
70
70
  <p>{data?.question_data?.question_data?.question}</p>
71
71
  </li>
72
72
  </>
@@ -3,54 +3,54 @@ import {
3
3
  QuestionSection,
4
4
  QuestionSectionAction,
5
5
  QuestionSectionWithAnalysis,
6
- TitleAndSubtitle,
7
- } from "../style";
8
- import Tabs from "../components/tabs";
9
- import useReportUtils from "../../hooks/useRreportUtils";
10
- import Response from "../components/response";
11
- import AnalysisButton from "../components/analysisButton";
12
- import ResponseAudio from "../components/responseAudio";
13
- import QuestionDropdown from "../components/questionDropdown";
14
- import QuizQuestion from "../components/quizQuestion";
15
- import ResponseAudioV2 from "../components/responseAudio.v2";
6
+ } from "../style.jsx";
7
+ import Tabs from "../components/tabs.jsx";
8
+ import useReportUtils from "../../hooks/useRreportUtils.jsx";
9
+ import Response from "../components/response.jsx";
10
+ import AnalysisButton from "../components/analysisButton.jsx";
11
+ import QuestionDropdown from "../components/questionDropdown.jsx";
12
+ import QuizQuestion from "../components/quizQuestion.jsx";
13
+
16
14
  import useTranslation from "../../../../hooks/useTranslation.jsx";
17
15
  import wordStore from "../../../../mc/wordStore.json";
18
- const QuizUnscripted = ({
16
+
17
+ const QuizWritten = ({
19
18
  data,
20
19
  aiData,
21
20
  setToggle,
22
21
  answerData,
23
22
  isPersonal,
24
-
25
23
  defaultSelected = 1,
26
24
  }) => {
27
25
  const { findText } = useTranslation(wordStore);
28
26
  const [selected, setSelected] = useState(defaultSelected);
29
- const { quizResponses, quixSelectedModel, setupAnalysis, getTrabScriptData } =
30
- useReportUtils();
31
27
  const [analysis, setAnalysis] = useState(null);
28
+
29
+ const { quizResponses, setupAnalysis, quizWrittenSelectedModel } =
30
+ useReportUtils();
31
+
32
32
  const quizList = quizResponses({
33
33
  responses: answerData?.answer?.data?.data?.responses,
34
- type: "unscripted",
34
+ type: "written",
35
35
  });
36
+
36
37
  const selectionList = quizList?.map((item) => ({
37
38
  value: item?.key,
38
- label: `Reponses ${item?.key}`,
39
+ label: `Response ${item?.key}`, // fixed spacing
39
40
  }));
41
+
40
42
  const selectedResponse =
41
43
  quizList?.find((item) => item?.key === selected) || {};
42
- const selectedModel = quixSelectedModel(selectedResponse, aiData);
44
+
45
+ const selectedModel = quizWrittenSelectedModel(selectedResponse, aiData);
46
+
43
47
  useEffect(() => {
44
48
  if (selectedResponse) {
45
- const models = setupAnalysis(
46
- selectedModel,
47
- selectedResponse?.recording,
48
- data?.ai_score
49
- );
49
+ const models = setupAnalysis(selectedModel, null, data?.ai_score);
50
50
  setAnalysis(models);
51
51
  }
52
- }, [selectedResponse?.key]);
53
- const transcript = getTrabScriptData(analysis?.models);
52
+ }, [selected]); // changed from selectedResponse?.key
53
+
54
54
  return (
55
55
  <QuestionSection>
56
56
  <Tabs
@@ -58,50 +58,28 @@ const QuizUnscripted = ({
58
58
  selected={selected}
59
59
  onChange={setSelected}
60
60
  />
61
+
61
62
  <QuestionDropdown>
62
- <>
63
- <li>
64
- <h3>{findText("Instruction")}</h3>
65
- <p>{data?.question_data?.instruction}</p>
66
- </li>
67
- <li>
68
- <QuizQuestion data={data} />
69
- </li>
70
- <li>
71
- <h3>{findText("Qyestion")}</h3>
72
- <p>{data?.question_data?.question_data?.question}</p>
73
- </li>
74
- </>
63
+ <li>
64
+ <h3>{findText("Instruction")}</h3>
65
+ <p>{data?.question_data?.instruction}</p>
66
+ </li>
67
+ <li>
68
+ <QuizQuestion data={data} />
69
+ </li>
70
+ <li>
71
+ <h3>{findText("Question")}</h3>
72
+ <p>{data?.question_data?.question_data?.question}</p>
73
+ </li>
75
74
  </QuestionDropdown>
76
75
 
76
+ <Response response={selectedResponse?.text} isPersonal={isPersonal} />
77
+
77
78
  <QuestionSectionWithAnalysis>
78
- <Response
79
- response={
80
- analysis?.models?.length > 0 &&
81
- transcript?.length > 0 &&
82
- selectedResponse?.recording
83
- ? transcript
84
- : undefined
85
- }
86
- isAiWordFlow
87
- defaultError={!selectedResponse?.recording}
88
- isPersonal={isPersonal}
89
- />
90
79
  <QuestionSectionAction>
91
- {selectedResponse?.recording && (
92
- <ResponseAudioV2
93
- streamUrl={selectedResponse?.recording?.url}
94
- url={selectedResponse?.recording?.uploaded_media_url}
95
- audioData={selectedResponse?.recording}
96
- key={selected}
97
- />
98
- )}
99
-
100
80
  {analysis?.models?.length > 0 && (
101
81
  <AnalysisButton
102
- disabled={
103
- !(analysis?.models?.length > 0 && selectedResponse?.recording)
104
- }
82
+ disabled={!analysis?.models?.length}
105
83
  onClick={() => {
106
84
  setToggle({
107
85
  ...analysis,
@@ -115,4 +93,5 @@ const QuizUnscripted = ({
115
93
  </QuestionSection>
116
94
  );
117
95
  };
118
- export default QuizUnscripted;
96
+
97
+ export default QuizWritten;
@@ -63,7 +63,7 @@ const QuizWritten = ({
63
63
  <QuizQuestion data={data} />
64
64
  </li>
65
65
  <li>
66
- <h3>{findText("Qyestion")}</h3>
66
+ <h3>{findText("Question")}</h3>
67
67
  <p>{data?.question_data?.question_data?.question}</p>
68
68
  </li>
69
69
  </>