l-min-components 1.7.1428 → 1.7.1430
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 +2 -1
- package/src/components/reportsComponents/fullAnalysis/components/Grammar.jsx +11 -33
- package/src/components/reportsComponents/hooks/useRreportUtils.jsx +6 -4
- package/src/components/reportsComponents/reportQuestions/components/style/comment.style.jsx +1 -1
- package/src/components/reportsComponents/reportQuestions/index.jsx +5 -9
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "l-min-components",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.1430",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"files": [
|
|
6
6
|
"src/assets",
|
|
@@ -22,6 +22,7 @@
|
|
|
22
22
|
"classnames": "^2.3.2",
|
|
23
23
|
"dexie": "^4.0.8",
|
|
24
24
|
"dexie-react-hooks": "^1.1.7",
|
|
25
|
+
"dompurify": "^3.2.6",
|
|
25
26
|
"draft-convert": "^2.1.13",
|
|
26
27
|
"draft-js": "^0.11.7",
|
|
27
28
|
"draftjs-to-html": "^0.9.1",
|
|
@@ -15,18 +15,23 @@ import { useState } from "react";
|
|
|
15
15
|
import GoodCheck from "../../../../assets/svg/goodCheck";
|
|
16
16
|
import RedX from "../../../../assets/svg/redX";
|
|
17
17
|
import useReportUtils from "../../hooks/useRreportUtils";
|
|
18
|
-
import WarningGrey from "../../../../assets/svg/warningGrey";
|
|
18
|
+
// import WarningGrey from "../../../../assets/svg/warningGrey";
|
|
19
|
+
|
|
20
|
+
// import DOMPurify from "dompurify";
|
|
19
21
|
|
|
20
22
|
const Grammar = ({ Aidata }) => {
|
|
21
23
|
const [selectedSection, setSelectedSection] = useState(1);
|
|
22
24
|
const [selectedWord, setSelectedWord] = useState(null);
|
|
23
25
|
|
|
24
26
|
const data = Aidata?.data;
|
|
25
|
-
const feedbackCorrection =
|
|
27
|
+
const feedbackCorrection = (
|
|
28
|
+
data?.["Correction Operations (Optional)"] || []
|
|
29
|
+
)?.filter((item) => ["substituted", "formatting"].includes(item?.operation));
|
|
26
30
|
const originalText = data?.["Original Speech"] || "";
|
|
27
31
|
const correctText = data?.["Grammatical Correct Version"] || "";
|
|
28
32
|
const feedbacks = data?.["Feedback"];
|
|
29
|
-
|
|
33
|
+
|
|
34
|
+
const { grammarFeekbackResult } = useReportUtils();
|
|
30
35
|
|
|
31
36
|
const wordsFeedback = grammarFeekbackResult(
|
|
32
37
|
originalText,
|
|
@@ -34,10 +39,6 @@ const Grammar = ({ Aidata }) => {
|
|
|
34
39
|
feedbacks
|
|
35
40
|
);
|
|
36
41
|
|
|
37
|
-
console.log(JSON.stringify(wordsFeedback));
|
|
38
|
-
|
|
39
|
-
const sentenceParts = renderCorrectedSentence(wordsFeedback);
|
|
40
|
-
|
|
41
42
|
useEffect(() => {
|
|
42
43
|
if (wordsFeedback?.length) {
|
|
43
44
|
const findWord = wordsFeedback?.find((word) => word?.operation);
|
|
@@ -114,39 +115,16 @@ const Grammar = ({ Aidata }) => {
|
|
|
114
115
|
<GoodCheck />
|
|
115
116
|
<span>{selectedWord?.correct}</span>
|
|
116
117
|
</div>
|
|
117
|
-
<p>{selectedWord?.feedback}</p>
|
|
118
118
|
</div>
|
|
119
119
|
)}
|
|
120
120
|
{selectedSection === 2 && originalText && <p>{originalText}</p>}
|
|
121
121
|
{selectedSection === 3 && (
|
|
122
122
|
<div className="correct_section">
|
|
123
|
-
<div className="warning">
|
|
123
|
+
{/* <div className="warning">
|
|
124
124
|
<WarningGrey />
|
|
125
125
|
<p>Introduced words are highlighted in green</p>
|
|
126
|
-
</div>
|
|
127
|
-
<p>
|
|
128
|
-
{sentenceParts.map((part, index) => {
|
|
129
|
-
const nextPart = sentenceParts[index + 1];
|
|
130
|
-
const needsSpace =
|
|
131
|
-
nextPart && !/^[.,!?;:]/.test(nextPart.text);
|
|
132
|
-
|
|
133
|
-
if (part.highlight) {
|
|
134
|
-
return (
|
|
135
|
-
<span key={index}>
|
|
136
|
-
{part.text}
|
|
137
|
-
{needsSpace ? " " : ""}
|
|
138
|
-
</span>
|
|
139
|
-
);
|
|
140
|
-
} else {
|
|
141
|
-
return (
|
|
142
|
-
<React.Fragment key={index}>
|
|
143
|
-
{part.text}
|
|
144
|
-
{needsSpace ? " " : ""}
|
|
145
|
-
</React.Fragment>
|
|
146
|
-
);
|
|
147
|
-
}
|
|
148
|
-
})}
|
|
149
|
-
</p>
|
|
126
|
+
</div> */}
|
|
127
|
+
<p>{correctText}</p>
|
|
150
128
|
</div>
|
|
151
129
|
)}
|
|
152
130
|
</GrammarContent>
|
|
@@ -465,7 +465,7 @@ const grammarFeekbackResult = (originalText, feedbackCorrection, feedbacks) => {
|
|
|
465
465
|
correction.original_word?.match(/\w+|[^\s\w]+/g) || [];
|
|
466
466
|
const slice = originalTokens
|
|
467
467
|
.slice(tokenIndex, tokenIndex + originalWordsFromCorrection.length)
|
|
468
|
-
.join("
|
|
468
|
+
.join(""); // 🔥 Key fix: no space between tokens
|
|
469
469
|
|
|
470
470
|
if (slice === correction.original_word) {
|
|
471
471
|
result.push({
|
|
@@ -476,6 +476,7 @@ const grammarFeekbackResult = (originalText, feedbackCorrection, feedbacks) => {
|
|
|
476
476
|
feedback: correction.feedback,
|
|
477
477
|
feedbackPosition: correction.feedbackPosition,
|
|
478
478
|
});
|
|
479
|
+
|
|
479
480
|
tokenIndex += originalWordsFromCorrection.length;
|
|
480
481
|
correctionIndex++;
|
|
481
482
|
continue;
|
|
@@ -485,18 +486,19 @@ const grammarFeekbackResult = (originalText, feedbackCorrection, feedbacks) => {
|
|
|
485
486
|
// Handle inserted correction
|
|
486
487
|
if (correction && correction.operation === "inserted") {
|
|
487
488
|
result.push({
|
|
488
|
-
text: correction.word,
|
|
489
|
-
correct: correction.word,
|
|
489
|
+
text: correction.word.trim(),
|
|
490
|
+
correct: correction.word.trim(),
|
|
490
491
|
position: result.length + 1,
|
|
491
492
|
operation: correction.operation,
|
|
492
493
|
feedback: correction.feedback,
|
|
493
494
|
feedbackPosition: correction.feedbackPosition,
|
|
494
495
|
});
|
|
496
|
+
|
|
495
497
|
correctionIndex++;
|
|
496
498
|
continue;
|
|
497
499
|
}
|
|
498
500
|
|
|
499
|
-
// Default: original token
|
|
501
|
+
// Default: push original token as-is
|
|
500
502
|
if (tokenIndex < originalTokens.length) {
|
|
501
503
|
result.push({
|
|
502
504
|
text: token,
|
|
@@ -1,9 +1,5 @@
|
|
|
1
1
|
import React, { useContext, useEffect, useState } from "react";
|
|
2
|
-
import constants
|
|
3
|
-
aiWordSample,
|
|
4
|
-
sampleResponse,
|
|
5
|
-
sampleResponseAudio,
|
|
6
|
-
} from "./contants";
|
|
2
|
+
import constants from "./contants";
|
|
7
3
|
|
|
8
4
|
import ArrowLeft from "../../../assets/svg/arrowLeft";
|
|
9
5
|
import YellowPen from "../../../assets/svg/yellow-pen";
|
|
@@ -16,10 +12,10 @@ import {
|
|
|
16
12
|
ScoreRight,
|
|
17
13
|
QuestionContent,
|
|
18
14
|
QuestionTitle,
|
|
19
|
-
QuestionFooter,
|
|
15
|
+
// QuestionFooter,
|
|
20
16
|
} from "./style";
|
|
21
17
|
import Comment from "./components/comment";
|
|
22
|
-
import ButtonComponent from "../../button";
|
|
18
|
+
// import ButtonComponent from "../../button";
|
|
23
19
|
import EssayWritten from "./questions/essayWritten";
|
|
24
20
|
import EssayScripted from "./questions/essayScripted";
|
|
25
21
|
import EssayUnscripted from "./questions/essayUnscripted";
|
|
@@ -296,12 +292,12 @@ const ReportQuestions = ({
|
|
|
296
292
|
accountType === "instructor-affiliate"
|
|
297
293
|
}
|
|
298
294
|
/>
|
|
299
|
-
{(accountType === "instructor-personal" ||
|
|
295
|
+
{/* {(accountType === "instructor-personal" ||
|
|
300
296
|
accountType === "instructor-affiliate") && (
|
|
301
297
|
<QuestionFooter>
|
|
302
298
|
<ButtonComponent text="Save" onClick={onClose} />
|
|
303
299
|
</QuestionFooter>
|
|
304
|
-
)}
|
|
300
|
+
)} */}
|
|
305
301
|
</Content>
|
|
306
302
|
</Container>
|
|
307
303
|
);
|