l-min-components 1.7.1584 → 1.7.1586

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.1584",
3
+ "version": "1.7.1586",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "src/assets",
@@ -721,6 +721,24 @@ const getQuestionInfo = (question) => {
721
721
 
722
722
  return { type, data: question };
723
723
  };
724
+ const quizWrittenSelectedModel = (response, aiData) => {
725
+ if (!response || !aiData) return null;
726
+ const index = response?.index || 0;
727
+ const objectData = {};
728
+
729
+ if (aiData?.grammar?.[index] && aiData?.grammar?.length) {
730
+ const findData = aiData?.grammar?.[index];
731
+ objectData["grammar"] = [findData];
732
+ }
733
+ if (
734
+ aiData?.comprehension?.length &&
735
+ aiData?.comprehension?.[0] &&
736
+ index === 0
737
+ ) {
738
+ objectData["comprehension"] = aiData?.comprehension;
739
+ }
740
+ return objectData;
741
+ };
724
742
 
725
743
  const useReportUtils = () => {
726
744
  return {
@@ -741,6 +759,7 @@ const useReportUtils = () => {
741
759
  grammarFindOperation,
742
760
  toRGBA,
743
761
  getQuestionInfo,
762
+ quizWrittenSelectedModel,
744
763
  };
745
764
  };
746
765
 
@@ -40,10 +40,11 @@ import useApi from "./api";
40
40
  import FullPageLoader from "../../fullPageLoader";
41
41
  import { ButtonComponent, OutletContext } from "../..";
42
42
  import useReportUtils from "../hooks/useRreportUtils";
43
- import ErrorHeader from "./components/errorHeader";
44
- import { InfoIcon } from "lucide-react";
45
43
  import InfoIcon2 from "../fullAnalysis/icons/info";
46
44
  import { NavBack, NavForword } from "../fullAnalysis/icons/navArrow";
45
+ import useTranslation from "../../../hooks/useTranslation.jsx";
46
+ import wordStore from "../../../mc/wordStore.json";
47
+ import QuizNewWritten from "./questions/quizNewWritten.jsx";
47
48
 
48
49
  /**
49
50
  * @param {Object} props
@@ -60,9 +61,7 @@ import { NavBack, NavForword } from "../fullAnalysis/icons/navArrow";
60
61
  * @param {object} props.navControl
61
62
  * @returns {React.ReactNode}
62
63
  */
63
- import useTranslation from "../../../hooks/useTranslation.jsx";
64
- import wordStore from "../../../mc/wordStore.json";
65
- import QuizWritten from "./questions/quizWritten.jsx";
64
+
66
65
  const ReportQuestions = ({
67
66
  accountType,
68
67
  AiData,
@@ -387,7 +386,7 @@ const ReportQuestions = ({
387
386
  />
388
387
  )}
389
388
  {questionType === "quiz-written" && (
390
- <QuizWritten
389
+ <QuizNewWritten
391
390
  data={findedQuestion}
392
391
  answerData={answerData}
393
392
  aiData={AiData}
@@ -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("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;