l-min-components 1.7.1585 → 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.1585",
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
 
@@ -1,54 +1,92 @@
1
- import React, { useState } from "react";
2
- import { QuestionSection } from "../style";
3
- import Tabs from "../components/tabs";
4
- import useReportUtils from "../../hooks/useRreportUtils";
5
- import Response from "../components/response";
6
- import QuestionDropdown from "../components/questionDropdown";
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";
7
13
 
8
- const QuizNewWritten = ({
14
+ import useTranslation from "../../../../hooks/useTranslation.jsx";
15
+ import wordStore from "../../../../mc/wordStore.json";
16
+ const QuizWritten = ({
9
17
  data,
10
18
  aiData,
19
+ setToggle,
11
20
  answerData,
12
21
  isPersonal,
13
22
  defaultSelected = 1,
14
23
  }) => {
24
+ const { findText } = useTranslation(wordStore);
15
25
  const [selected, setSelected] = useState(defaultSelected);
16
- const { quizResponses } = useReportUtils();
26
+ const [analysis, setAnalysis] = useState(null);
27
+ const { quizResponses, setupAnalysis, quizWrittenSelectedModel } =
28
+ useReportUtils();
17
29
  const quizList = quizResponses({
18
30
  responses: answerData?.answer?.data?.data?.responses,
19
31
  type: "written",
20
32
  });
33
+
21
34
  const selectionList = quizList?.map((item) => ({
22
35
  value: item?.key,
23
36
  label: `Reponses ${item?.key}`,
24
37
  }));
25
38
  const selectedResponse =
26
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]);
27
49
  return (
28
- <>
29
- <QuestionSection>
30
- <Tabs
31
- options={selectionList}
32
- selected={selected}
33
- onChange={setSelected}
34
- />
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>
35
71
 
36
- <QuestionDropdown>
37
- <>
38
- <li>
39
- <h3>{"Instruction"}</h3>
40
- <p>{data?.question_data?.instruction}</p>
41
- </li>
42
- <li>
43
- <h3>{"Essay topic"}</h3>
44
- <p>{data?.question_data?.question_title}</p>
45
- </li>
46
- </>
47
- </QuestionDropdown>
48
- <Response response={selectedResponse?.text} isPersonal={isPersonal} />
49
- </QuestionSection>
50
- </>
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>
51
90
  );
52
91
  };
53
-
54
- export default QuizNewWritten;
92
+ export default QuizWritten;