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 +1 -1
- package/src/components/reportsComponents/hooks/useRreportUtils.jsx +78 -46
- package/src/components/reportsComponents/reportQuestions/questions/quizScripted.jsx +1 -1
- package/src/components/reportsComponents/reportQuestions/questions/quizUnsripted.jsx +41 -62
- package/src/components/reportsComponents/reportQuestions/questions/quizWritten.jsx +1 -1
package/package.json
CHANGED
|
@@ -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
|
-
|
|
438
|
+
|
|
439
|
+
const index = response?.index ?? 0;
|
|
439
440
|
const objectData = {};
|
|
440
441
|
|
|
441
|
-
if (aiData?.grammar?.[index]
|
|
442
|
-
|
|
443
|
-
objectData["grammar"] = [findData];
|
|
442
|
+
if (aiData?.grammar?.[index]) {
|
|
443
|
+
objectData.grammar = [aiData.grammar[index]];
|
|
444
444
|
}
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
aiData
|
|
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
|
-
|
|
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
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
type
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
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 = () => {
|
|
@@ -3,54 +3,54 @@ import {
|
|
|
3
3
|
QuestionSection,
|
|
4
4
|
QuestionSectionAction,
|
|
5
5
|
QuestionSectionWithAnalysis,
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
|
|
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
|
-
|
|
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: "
|
|
34
|
+
type: "written",
|
|
35
35
|
});
|
|
36
|
+
|
|
36
37
|
const selectionList = quizList?.map((item) => ({
|
|
37
38
|
value: item?.key,
|
|
38
|
-
label: `
|
|
39
|
+
label: `Response ${item?.key}`, // fixed spacing
|
|
39
40
|
}));
|
|
41
|
+
|
|
40
42
|
const selectedResponse =
|
|
41
43
|
quizList?.find((item) => item?.key === selected) || {};
|
|
42
|
-
|
|
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
|
-
|
|
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
|
-
<
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
<
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
<
|
|
71
|
-
|
|
72
|
-
|
|
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
|
-
|
|
96
|
+
|
|
97
|
+
export default QuizWritten;
|