l-min-components 1.7.1571 → 1.7.1573

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.1571",
3
+ "version": "1.7.1573",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "src/assets",
@@ -54,6 +54,14 @@ 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
+ }
57
65
  return {
58
66
  key: index + 1,
59
67
  text: response?.text,
@@ -425,6 +433,25 @@ const setupAnalysis = (data, audioData, score) => {
425
433
  };
426
434
  };
427
435
 
436
+ const quizWrittenSelectedModel = (response, aiData) => {
437
+ if (!response || !aiData) return null;
438
+ const index = response?.index || 0;
439
+ const objectData = {};
440
+
441
+ if (aiData?.grammar?.[index] && aiData?.grammar?.length) {
442
+ const findData = aiData?.grammar?.[index];
443
+ objectData["grammar"] = [findData];
444
+ }
445
+ if (
446
+ aiData?.comprehension?.length &&
447
+ aiData?.comprehension?.[0] &&
448
+ index === 0
449
+ ) {
450
+ objectData["comprehension"] = aiData?.comprehension;
451
+ }
452
+ return objectData;
453
+ };
454
+
428
455
  const quixSelectedModel = (response, aiData) => {
429
456
  if (!response || !aiData) return null;
430
457
 
@@ -447,6 +474,13 @@ const quixSelectedModel = (response, aiData) => {
447
474
  );
448
475
  objectData["grammar"] = [findData];
449
476
  }
477
+ if (aiData?.comprehension?.length && aiData?.comprehension) {
478
+ const attemptResp = aiData?.comprehension?.[0]?.attempt_data_batch?.[0];
479
+
480
+ if (attemptResp?.recording?.id === audioId || attemptResp?.id === audioId) {
481
+ objectData["comprehension"] = aiData?.comprehension;
482
+ }
483
+ }
450
484
 
451
485
  return objectData;
452
486
  };
@@ -692,10 +726,15 @@ const getQuestionInfo = (question) => {
692
726
  type = "word-play-multiple-choice";
693
727
  else type = "word-play-text";
694
728
  } else if (question?.type === "QUIZ") {
695
- if (question?.question_data?.question_data?.type === "MultipleChoice")
729
+ if (
730
+ question?.question_data?.question_data?.type === "MultipleChoice" ||
731
+ question?.question_data?.question_data?.type === "Multiple Choice"
732
+ )
696
733
  type = "quiz-multiple-choice";
697
734
  else if (question?.question_data?.question_data?.type === "UnScripted")
698
735
  type = "quiz-unscripted";
736
+ else if (question?.question_data?.question_data?.type === "Written")
737
+ type = "quiz-written";
699
738
  else type = "quiz-scripted";
700
739
  } else if (question?.type === "ESSAY") {
701
740
  if (question?.question_data?.config?.type === "Scripted")
@@ -729,6 +768,7 @@ const useReportUtils = () => {
729
768
  grammarFindOperation,
730
769
  toRGBA,
731
770
  getQuestionInfo,
771
+ quizWrittenSelectedModel,
732
772
  };
733
773
  };
734
774
 
@@ -62,6 +62,7 @@ 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.jsx";
65
66
  const ReportQuestions = ({
66
67
  accountType,
67
68
  AiData,
@@ -385,6 +386,17 @@ const ReportQuestions = ({
385
386
  defaultSelected={defaultSelected}
386
387
  />
387
388
  )}
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
+ )}
388
400
  {questionType === "quiz-multiple-choice" && (
389
401
  <QuizMultipleChoice
390
402
  data={findedQuestion}
@@ -0,0 +1,92 @@
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("Qyestion")}</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;