l-min-components 1.7.1575 → 1.7.1577

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.1575",
3
+ "version": "1.7.1577",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "src/assets",
@@ -54,14 +54,6 @@ const quizResponses = ({ responses = [], type = "scripted" }) => {
54
54
  recording: response,
55
55
  };
56
56
  }
57
-
58
- if (type === "written") {
59
- return {
60
- key: index + 1,
61
- index,
62
- text: response,
63
- };
64
- }
65
57
  return {
66
58
  key: index + 1,
67
59
  text: response?.text,
@@ -433,23 +425,6 @@ const setupAnalysis = (data, audioData, score) => {
433
425
  };
434
426
  };
435
427
 
436
- const quizWrittenSelectedModel = (response, aiData) => {
437
- if (!response || !aiData) return null;
438
-
439
- const index = response?.index ?? 0;
440
- const objectData = {};
441
-
442
- if (aiData?.grammar?.[index]) {
443
- objectData.grammar = [aiData.grammar[index]];
444
- }
445
-
446
- if (index === 0 && aiData?.comprehension?.length) {
447
- objectData.comprehension = aiData.comprehension;
448
- }
449
-
450
- return Object.keys(objectData).length ? objectData : null;
451
- };
452
-
453
428
  const quixSelectedModel = (response, aiData) => {
454
429
  if (!response || !aiData) return null;
455
430
 
@@ -472,13 +447,6 @@ const quixSelectedModel = (response, aiData) => {
472
447
  );
473
448
  objectData["grammar"] = [findData];
474
449
  }
475
- if (aiData?.comprehension?.length && aiData?.comprehension) {
476
- const attemptResp = aiData?.comprehension?.[0]?.attempt_data_batch?.[0];
477
-
478
- if (attemptResp?.recording?.id === audioId || attemptResp?.id === audioId) {
479
- objectData["comprehension"] = aiData?.comprehension;
480
- }
481
- }
482
450
 
483
451
  return objectData;
484
452
  };
@@ -710,75 +678,41 @@ function toRGBA(rgbaString, alpha = 1) {
710
678
  }
711
679
 
712
680
  const getQuestionInfo = (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 };
681
+ let type = "";
682
+ if (question?.type === "SOUND_PLAY") type = "sound-play";
683
+ else if (question?.question_data?.type === "DIALOGUE") {
684
+ if (
685
+ Object.values(question?.question_data?.dialogues_data || {})?.[0]
686
+ ?.type === "Scripted"
687
+ )
688
+ type = "dialogue-scripted";
689
+ else type = "dialogue-unscripted";
690
+ } else if (question?.question_data?.type === "WORD_PLAY") {
691
+ if (question?.question_data?.answer_format_data?.type === "Multiple Choice")
692
+ type = "word-play-multiple-choice";
693
+ else type = "word-play-text";
694
+ } else if (question?.type === "QUIZ") {
695
+ if (
696
+ question?.question_data?.question_data?.type === "MultipleChoice" ||
697
+ question?.question_data?.question_data?.type === "Multiple Choice"
698
+ )
699
+ type = "quiz-multiple-choice";
700
+ else if (question?.question_data?.question_data?.type === "UnScripted")
701
+ type = "quiz-unscripted";
702
+ else if (question?.question_data?.question_data?.type === "Written")
703
+ type = "quiz-written";
704
+ else type = "quiz-scripted";
705
+ } else if (question?.type === "ESSAY") {
706
+ if (question?.question_data?.config?.type === "Scripted")
707
+ type = "essay-scripted";
708
+ else if (question?.question_data?.config?.type === "Written")
709
+ type = "essay-written";
710
+ else type = "essay-unscripted";
711
+ } else if (question?.question_data?.type === "READING") type = "reading";
712
+ else if (question?.type === "MATCH_PAIR") type = "match-pair";
713
+ else type = "";
714
+
715
+ return { type, data: question };
782
716
  };
783
717
 
784
718
  const useReportUtils = () => {
@@ -800,7 +734,6 @@ const useReportUtils = () => {
800
734
  grammarFindOperation,
801
735
  toRGBA,
802
736
  getQuestionInfo,
803
- quizWrittenSelectedModel,
804
737
  };
805
738
  };
806
739
 
@@ -62,7 +62,6 @@ import { NavBack, NavForword } from "../fullAnalysis/icons/navArrow";
62
62
  */
63
63
  import useTranslation from "../../../hooks/useTranslation.jsx";
64
64
  import wordStore from "../../../mc/wordStore.json";
65
- import QuizWritten from "./questions/quizWritten";
66
65
  const ReportQuestions = ({
67
66
  accountType,
68
67
  AiData,
@@ -386,17 +385,6 @@ const ReportQuestions = ({
386
385
  defaultSelected={defaultSelected}
387
386
  />
388
387
  )}
389
-
390
- {questionType === "quiz-written" && (
391
- <QuizWritten
392
- data={findedQuestion}
393
- answerData={answerData}
394
- aiData={AiData}
395
- setToggle={setToggle}
396
- isPersonal={isPersonal}
397
- defaultSelected={defaultSelected}
398
- />
399
- )}
400
388
  {questionType === "quiz-multiple-choice" && (
401
389
  <QuizMultipleChoice
402
390
  data={findedQuestion}
@@ -66,7 +66,7 @@ const QuizScripted = ({
66
66
  <QuizQuestion data={data} />
67
67
  </li>
68
68
  <li>
69
- <h3>{findText("Question")}</h3>
69
+ <h3>{findText("Qyestion")}</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
- } 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
-
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";
14
16
  import useTranslation from "../../../../hooks/useTranslation.jsx";
15
17
  import wordStore from "../../../../mc/wordStore.json";
16
-
17
- const QuizWritten = ({
18
+ const QuizUnscripted = ({
18
19
  data,
19
20
  aiData,
20
21
  setToggle,
21
22
  answerData,
22
23
  isPersonal,
24
+
23
25
  defaultSelected = 1,
24
26
  }) => {
25
27
  const { findText } = useTranslation(wordStore);
26
28
  const [selected, setSelected] = useState(defaultSelected);
27
- const [analysis, setAnalysis] = useState(null);
28
-
29
- const { quizResponses, setupAnalysis, quizWrittenSelectedModel } =
29
+ const { quizResponses, quixSelectedModel, setupAnalysis, getTrabScriptData } =
30
30
  useReportUtils();
31
-
31
+ const [analysis, setAnalysis] = useState(null);
32
32
  const quizList = quizResponses({
33
33
  responses: answerData?.answer?.data?.data?.responses,
34
- type: "written",
34
+ type: "unscripted",
35
35
  });
36
-
37
36
  const selectionList = quizList?.map((item) => ({
38
37
  value: item?.key,
39
- label: `Response ${item?.key}`, // fixed spacing
38
+ label: `Reponses ${item?.key}`,
40
39
  }));
41
-
42
40
  const selectedResponse =
43
41
  quizList?.find((item) => item?.key === selected) || {};
44
-
45
- const selectedModel = quizWrittenSelectedModel(selectedResponse, aiData);
46
-
42
+ const selectedModel = quixSelectedModel(selectedResponse, aiData);
47
43
  useEffect(() => {
48
44
  if (selectedResponse) {
49
- const models = setupAnalysis(selectedModel, null, data?.ai_score);
45
+ const models = setupAnalysis(
46
+ selectedModel,
47
+ selectedResponse?.recording,
48
+ data?.ai_score
49
+ );
50
50
  setAnalysis(models);
51
51
  }
52
- }, [selected]); // changed from selectedResponse?.key
53
-
52
+ }, [selectedResponse?.key]);
53
+ const transcript = getTrabScriptData(analysis?.models);
54
54
  return (
55
55
  <QuestionSection>
56
56
  <Tabs
@@ -58,28 +58,50 @@ const QuizWritten = ({
58
58
  selected={selected}
59
59
  onChange={setSelected}
60
60
  />
61
-
62
61
  <QuestionDropdown>
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>
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
+ </>
74
75
  </QuestionDropdown>
75
76
 
76
- <Response response={selectedResponse?.text} isPersonal={isPersonal} />
77
-
78
77
  <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
+ />
79
90
  <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
+
80
100
  {analysis?.models?.length > 0 && (
81
101
  <AnalysisButton
82
- disabled={!analysis?.models?.length}
102
+ disabled={
103
+ !(analysis?.models?.length > 0 && selectedResponse?.recording)
104
+ }
83
105
  onClick={() => {
84
106
  setToggle({
85
107
  ...analysis,
@@ -93,5 +115,4 @@ const QuizWritten = ({
93
115
  </QuestionSection>
94
116
  );
95
117
  };
96
-
97
- export default QuizWritten;
118
+ export default QuizUnscripted;
@@ -1,92 +0,0 @@
1
- import React, { useEffect, useState } from "react";
2
- import {
3
- QuestionSection,
4
- QuestionSectionAction,
5
- QuestionSectionWithAnalysis,
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
-
14
- import useTranslation from "../../../../hooks/useTranslation.jsx";
15
- import wordStore from "../../../../mc/wordStore.json";
16
- const QuizWritten = ({
17
- data,
18
- aiData,
19
- setToggle,
20
- answerData,
21
- isPersonal,
22
- defaultSelected = 1,
23
- }) => {
24
- const { findText } = useTranslation(wordStore);
25
- const [selected, setSelected] = useState(defaultSelected);
26
- const [analysis, setAnalysis] = useState(null);
27
- const { quizResponses, setupAnalysis, quizWrittenSelectedModel } =
28
- useReportUtils();
29
- const quizList = quizResponses({
30
- responses: answerData?.answer?.data?.data?.responses,
31
- type: "written",
32
- });
33
-
34
- const selectionList = quizList?.map((item) => ({
35
- value: item?.key,
36
- label: `Reponses ${item?.key}`,
37
- }));
38
- const selectedResponse =
39
- quizList?.find((item) => item?.key === selected) || {};
40
-
41
- const selectedModel = quizWrittenSelectedModel(selectedResponse, aiData);
42
-
43
- useEffect(() => {
44
- if (selectedResponse) {
45
- const models = setupAnalysis(selectedModel, null, data?.ai_score);
46
- setAnalysis(models);
47
- }
48
- }, [selectedResponse?.key]);
49
- return (
50
- <QuestionSection>
51
- <Tabs
52
- options={selectionList}
53
- selected={selected}
54
- onChange={setSelected}
55
- />
56
- <QuestionDropdown>
57
- <>
58
- <li>
59
- <h3>{findText("Instruction")}</h3>
60
- <p>{data?.question_data?.instruction}</p>
61
- </li>
62
- <li>
63
- <QuizQuestion data={data} />
64
- </li>
65
- <li>
66
- <h3>{findText("Question")}</h3>
67
- <p>{data?.question_data?.question_data?.question}</p>
68
- </li>
69
- </>
70
- </QuestionDropdown>
71
-
72
- <Response response={selectedResponse?.text} isPersonal={isPersonal} />
73
-
74
- <QuestionSectionWithAnalysis>
75
- <QuestionSectionAction>
76
- {analysis?.models?.length > 0 && (
77
- <AnalysisButton
78
- disabled={!(analysis?.models?.length > 0)}
79
- onClick={() => {
80
- setToggle({
81
- ...analysis,
82
- defaultSelected: selected,
83
- });
84
- }}
85
- />
86
- )}
87
- </QuestionSectionAction>
88
- </QuestionSectionWithAnalysis>
89
- </QuestionSection>
90
- );
91
- };
92
- export default QuizWritten;