l-min-components 1.7.1433 → 1.7.1435

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.1433",
3
+ "version": "1.7.1435",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "src/assets",
@@ -1,6 +1,6 @@
1
1
  import React from "react";
2
2
 
3
- const YellowPen = () => {
3
+ const YellowPen = ({ color = "#FEBF10" }) => {
4
4
  return (
5
5
  <svg
6
6
  xmlns="http://www.w3.org/2000/svg"
@@ -11,8 +11,8 @@ const YellowPen = () => {
11
11
  >
12
12
  <path
13
13
  d="M13.4766 7.45508L5.62695 15.3047H3.44531V13.123L11.2949 5.27344L13.4766 7.45508ZM4.05469 13.375V14.6953H5.375L12.6152 7.45508L11.2949 6.13477L4.05469 13.375ZM13.9951 2.69531C14.082 2.69534 14.1527 2.72318 14.2119 2.78223L15.9678 4.53809C16.0857 4.65649 16.0859 4.84653 15.9678 4.96484L14.9102 6.02148L12.7275 3.83887L13.7852 2.78223C13.841 2.72652 13.9215 2.69531 13.9951 2.69531Z"
14
- fill="#FEBF10"
15
- stroke="#FEBF10"
14
+ fill={color}
15
+ stroke={color}
16
16
  strokeWidth="0.891406"
17
17
  />
18
18
  </svg>
@@ -1,4 +1,4 @@
1
- import React, { useEffect } from "react";
1
+ import React, { useCallback, useEffect } from "react";
2
2
  import {
3
3
  GrammarContent,
4
4
  GrammarHeader,
@@ -14,36 +14,89 @@ import { MarsIcon } from "lucide-react";
14
14
  import { useState } from "react";
15
15
  import GoodCheck from "../../../../assets/svg/goodCheck";
16
16
  import RedX from "../../../../assets/svg/redX";
17
- import useReportUtils from "../../hooks/useRreportUtils";
17
+ import DOMPurify from "dompurify";
18
+ // import useReportUtils from "../../hooks/useRreportUtils";
18
19
 
19
20
  const Grammar = ({ Aidata }) => {
20
21
  const [selectedSection, setSelectedSection] = useState(1);
21
- const [selectedWord, setSelectedWord] = useState(null);
22
+
23
+ const [formattedCopy, setFormattedCopy] = useState("");
24
+ const [operationIndex, setOperationIndex] = useState(null);
22
25
 
23
26
  const data = Aidata?.data;
27
+
28
+ const originalText = data?.["Original Speech"] || "";
29
+ const correctText = data?.["Grammatical Correct Version"] || "";
30
+
24
31
  const feedbackCorrection = (
25
32
  data?.["Correction Operations (Optional)"] || []
26
33
  )?.filter((item) => ["substituted", "formatting"].includes(item?.operation));
27
34
 
28
- const originalText = data?.["Original Speech"] || "";
29
- const correctText = data?.["Grammatical Correct Version"] || "";
30
- const feedbacks = data?.["Feedback"];
35
+ const findOperation = useCallback(() => {
36
+ const substitutedCorrections = feedbackCorrection.filter((correction) =>
37
+ ["substituted", "formatting"].includes(correction.operation)
38
+ );
39
+ return substitutedCorrections[operationIndex ?? -1] || null;
40
+ }, [feedbackCorrection, operationIndex]);
41
+
42
+ const processSubstitutedCorrections = useCallback(
43
+ (corrections, originalSpeech) => {
44
+ if (!corrections.length) return originalSpeech;
31
45
 
32
- const { grammarFeekbackResult } = useReportUtils();
46
+ let modifiedSpeech = originalSpeech;
47
+ let usedIndices = [];
33
48
 
34
- const wordsFeedback = grammarFeekbackResult(
35
- originalText,
36
- feedbackCorrection,
37
- feedbacks
49
+ corrections.forEach((correction, correctionIndex) => {
50
+ const escapedOriginalWord = correction.original_word.replace(
51
+ /[.*+?^${}()|[\]\\]/g,
52
+ "\\$&"
53
+ );
54
+ const regex = new RegExp(escapedOriginalWord, "g");
55
+ let match;
56
+
57
+ while ((match = regex.exec(modifiedSpeech)) !== null) {
58
+ const [start, end] = [match.index, match.index + match[0].length];
59
+
60
+ if (!usedIndices.some(([s, e]) => start < e && end > s)) {
61
+ usedIndices.push([start, end]);
62
+ modifiedSpeech =
63
+ modifiedSpeech.slice(0, start) +
64
+ `<span class="issue" data-index="${correctionIndex}"><span class="number" data-index="${correctionIndex}">${
65
+ correctionIndex + 1
66
+ }</span> ${match[0]}</span>` +
67
+ modifiedSpeech.slice(end);
68
+ break;
69
+ }
70
+ }
71
+ });
72
+
73
+ return DOMPurify.sanitize(modifiedSpeech);
74
+ },
75
+ []
38
76
  );
39
77
 
40
78
  useEffect(() => {
41
- if (wordsFeedback?.length) {
42
- const findWord = wordsFeedback?.find((word) => word?.operation);
79
+ const substitutedCorrections = feedbackCorrection?.filter((correction) =>
80
+ ["substituted", "formatting"].includes(correction.operation)
81
+ );
82
+
83
+ const processedSpeech = processSubstitutedCorrections(
84
+ substitutedCorrections,
85
+ originalText
86
+ );
87
+ setFormattedCopy(processedSpeech);
88
+ }, [feedbackCorrection, processSubstitutedCorrections]);
89
+
90
+ useEffect(() => {
91
+ const handleClick = (event) => {
92
+ const target = event.target;
93
+ const index = target.getAttribute("data-index");
94
+ if (index) setOperationIndex(Number(index));
95
+ };
43
96
 
44
- setSelectedWord(findWord);
45
- }
46
- }, [wordsFeedback?.length]);
97
+ document.addEventListener("click", handleClick);
98
+ return () => document.removeEventListener("click", handleClick);
99
+ }, []);
47
100
 
48
101
  const tabs = [
49
102
  { label: "Feedback", value: 1, icon: ChatIcon },
@@ -51,6 +104,8 @@ const Grammar = ({ Aidata }) => {
51
104
  { label: "Corrected version", value: 3, icon: MarsIcon },
52
105
  ].filter((item) => !(item?.value === 3 && Aidata?.score >= 100));
53
106
 
107
+ const operation = findOperation();
108
+
54
109
  return (
55
110
  <ModelComtainer>
56
111
  <ModelContent>
@@ -60,38 +115,10 @@ const Grammar = ({ Aidata }) => {
60
115
  <p>Click on the words to see detailed feedback</p>
61
116
  </div>
62
117
  <GrammarHeaderContent>
63
- {wordsFeedback?.map((word, idx) => {
64
- const isWord = /^\w+$/.test(word.text);
65
- const isSymbol = /^[^\w\s]+$/.test(word.text);
66
- const next = wordsFeedback[idx + 1];
67
- const nextIsWord = /^\w+$/.test(next?.text || "");
68
- const isCorrected = !!word.operation;
69
- const showFeedback = !!word.feedbackPosition;
70
-
71
- const shouldAddSpace =
72
- (isWord && nextIsWord) || // word → word
73
- (isSymbol && nextIsWord); // symbol → word
74
-
75
- return (
76
- <span
77
- className={classNames("inline", {
78
- "error-text": isCorrected,
79
- })}
80
- key={idx}
81
- style={{ whiteSpace: "pre" }}
82
- onClick={() => {
83
- if (!isCorrected) return;
84
- setSelectedWord(word);
85
- setSelectedSection(1);
86
- }}
87
- >
88
- {/* This will only be true for words with a correction (and a position) */}
89
- {showFeedback && <sup>{word.feedbackPosition}</sup>}
90
- {word.text}
91
- {shouldAddSpace && " "}
92
- </span>
93
- );
94
- })}
118
+ <div
119
+ className="grammar_analysis_container"
120
+ dangerouslySetInnerHTML={{ __html: formattedCopy }}
121
+ ></div>
95
122
  </GrammarHeaderContent>
96
123
  <ul className="no-border ul_tabs">
97
124
  {tabs.map((tab) => (
@@ -114,18 +141,17 @@ const Grammar = ({ Aidata }) => {
114
141
  </ul>
115
142
  </GrammarHeader>
116
143
  <GrammarContent>
117
- {selectedSection === 1 && selectedWord && selectedWord?.operation && (
144
+ {selectedSection === 1 && operation && (
118
145
  <div className="feedback_section">
119
146
  <div className="failed">
120
147
  <RedX />
121
148
  <span>
122
- <span>{selectedWord?.feedbackPosition}</span>{" "}
123
- {selectedWord?.text}
149
+ <span>{operationIndex + 1}</span> {operation?.original_word}
124
150
  </span>
125
151
  </div>
126
152
  <div className="correct">
127
153
  <GoodCheck />
128
- <span>{selectedWord?.correct}</span>
154
+ <span>{operation?.replacement_word}</span>
129
155
  </div>
130
156
  </div>
131
157
  )}
@@ -23,6 +23,7 @@ import { Progress } from "rsuite";
23
23
  import ClarityItem from "./ClarityItem";
24
24
  import InlineClampedText from "./InlineClampedText";
25
25
  import PlayButton from "./PlayButton";
26
+ import useReportUtils from "../../hooks/useRreportUtils";
26
27
 
27
28
  const SpeechAnalysis = ({
28
29
  Aidata,
@@ -33,6 +34,8 @@ const SpeechAnalysis = ({
33
34
  const [selectedWord, setSelectedWord] = useState(1);
34
35
  const [selectedSection, setSelectedSection] = useState(null);
35
36
 
37
+ const { getColor } = useReportUtils();
38
+
36
39
  const wordData = Aidata?.words;
37
40
  const words = wordData?.map((item) => ({
38
41
  text: item?.wordText,
@@ -63,7 +66,7 @@ const SpeechAnalysis = ({
63
66
  if (tabs?.length) {
64
67
  setSelectedSection(tabs?.[0]?.value);
65
68
  }
66
- }, [tabs?.length, selectedWord]);
69
+ }, [tabs?.length]);
67
70
 
68
71
  const selectionSelectionValue = sectionList?.find(
69
72
  (item) => item?.id === selectedSection
@@ -91,6 +94,8 @@ const SpeechAnalysis = ({
91
94
  return bg;
92
95
  }, []);
93
96
 
97
+ console.log(selectionSelectionValue?.data);
98
+
94
99
  return (
95
100
  <ModelComtainer>
96
101
  <ModelContent>
@@ -293,35 +298,28 @@ const SpeechAnalysis = ({
293
298
  <div className="progress_section center">
294
299
  <div className="progress_value">
295
300
  <Progress.Circle
296
- percent={
297
- selectionSelectionValue?.data?.score <= 45
298
- ? 100 - (selectionSelectionValue?.data?.score || 0)
299
- : selectionSelectionValue?.data?.score || 0
300
- }
301
+ percent={Math.floor(
302
+ selectionSelectionValue?.data?.score || 0
303
+ )}
301
304
  strokeWidth={10}
302
- trailWidth={8}
303
- strokeColor={
304
- selectionSelectionValue?.data?.score > 45
305
- ? "#30D468"
306
- : "#F95454"
307
- }
308
- trailColor={
309
- selectionSelectionValue?.data?.score > 45
310
- ? "#F95454"
311
- : "#30D468"
312
- }
305
+ trailWidth={4}
306
+ strokeColor={getColor(
307
+ selectionSelectionValue?.data?.score || 0
308
+ )}
309
+ trailColor="#F2F2F2"
313
310
  showInfo={false}
314
311
  className="progress-circle"
315
- gapDegree={8}
316
312
  gapPosition="bottom"
317
313
  style={{
318
314
  width: "80px",
319
315
  }}
320
316
  />
321
317
  <p
322
- className={classNames({
323
- good: selectionSelectionValue?.data?.score > 45,
324
- })}
318
+ style={{
319
+ color: getColor(
320
+ selectionSelectionValue?.data?.score || 0
321
+ ),
322
+ }}
325
323
  >
326
324
  {selectionSelectionValue?.data?.score || 0}%
327
325
  </p>
@@ -7,38 +7,38 @@ export const sampleData1 = {
7
7
  evidence: {
8
8
  score: 80,
9
9
  example:
10
- "Technology is the beginning of the end, <IMPROVEMENT>as seen in the decline of face-to-face communication skills among teenagers, with studies indicating a significant correlation between excessive technology use and increased feelings of loneliness</IMPROVEMENT>. <IMPROVEMENT>For instance, a survey by the Pew Research Center found that 60% of teenagers aged 13-17 prefer texting over talking on the phone or meeting in person</IMPROVEMENT>. <IMPROVEMENT>This trend is further supported by data from the National Center for Education Statistics, which shows a decline in students' writing and critical thinking skills since the widespread adoption of digital technology</IMPROVEMENT>. <IMPROVEMENT>Experts argue that over-reliance on technology can lead to a decline in cognitive abilities, citing research that shows a link between technology use and reduced attention span</IMPROVEMENT>. <IMPROVEMENT>argue with your keyboard lol, thank you!</IMPROVEMENT>",
10
+ "Have you heard about food? It is a fundamental aspect of human culture, with various cuisines around the world offering a diverse range of flavors and nutritional benefits <IMPROVEMENT>(for example, the Mediterranean diet is known for its health benefits, with a study by the American Journal of Medicine finding a significant reduction in heart disease among its adherents)</IMPROVEMENT>. Very delicious.. Robots can't relate <IMPROVEMENT>because they lack the sensory experiences that humans take for granted, such as taste and smell, which are crucial in appreciating the complexity of food</IMPROVEMENT>.",
11
11
  feedback:
12
- "The essay lacks any form of evidence to support its claim. There are no specific examples, data, or references to credible sources. The statement 'Technology is the beginning of the end' is unsubstantiated and the following phrase 'argue with your keyboard lol, thank you!' does not contribute to the argument or provide evidence. To strengthen the essay, relevant and convincing evidence should be incorporated.",
12
+ "The essay lacks any form of evidence to support its claims. There are no specific examples, data, or references to credible sources. The statements made are vague and do not provide any convincing argument. To improve, the author should include relevant and convincing evidence, such as statistics or expert opinions, to substantiate their claims.",
13
13
  },
14
14
  coherence: {
15
15
  score: 80,
16
16
  example:
17
- "Technology is the beginning of the end. <IMPROVEMENT>This assertion may seem provocative, but it warrants further examination.</IMPROVEMENT> To understand this claim, it's essential to consider the implications of technological advancements on society. <IMPROVEMENT>Firstly, the rapid development of technology has transformed the way we live and interact.</IMPROVEMENT> argue with your keyboard lol, <IMPROVEMENT>though this phrase may be intended to be humorous, it disrupts the flow of the argument</IMPROVEMENT>, thank you! <IMPROVEMENT>In conclusion, while the initial statement may be seen as an exaggeration, it highlights the need for a nuanced discussion about the role of technology in our lives.</IMPROVEMENT>",
17
+ "Have you heard about food? <IMPROVEMENT>It is often described as</IMPROVEMENT> very delicious.. <IMPROVEMENT>This appreciation for taste is a characteristic that distinguishes humans from robots, as</IMPROVEMENT> robots can't relate.",
18
18
  feedback:
19
- "The essay lacks coherence and logical flow as it consists of a single sentence that does not present a clear argument or claim. There are no subsequent paragraphs to develop the idea, and the transition between the initial statement and the concluding phrase is abrupt and unclear.",
19
+ "The essay lacks coherence and logical flow. It appears to be a collection of disconnected sentences. To improve coherence, a clear topic sentence and a logical connection between the ideas are needed. The transition between 'Have you heard about food?' and 'Very delicious..' is abrupt, and the sentence 'Robots can't relate.' seems unrelated to the preceding sentences.",
20
20
  },
21
21
  relevance: {
22
22
  score: 15,
23
23
  rating: "Not Relevant",
24
24
  example:
25
- "Technology is a complex and multifaceted concept that has become an integral part of modern life. <IMPROVEMENT>While some people view technology as a force that can bring about significant benefits, others argue that it has the potential to cause harm.</IMPROVEMENT> \"Technology is the beginning of the end\" is a statement that reflects a pessimistic view of technology's impact. <IMPROVEMENT>However, a more nuanced discussion is needed to understand the role of technology in society.</IMPROVEMENT> Arguing with your keyboard, as the original statement humorously suggests, is not a productive way to engage with the topic. <IMPROVEMENT>A more thoughtful analysis of technology's effects is required.</IMPROVEMENT> Thank you!",
25
+ "Have you heard about food? Very delicious.. Robots can't relate. <IMPROVEMENT>This lack of relation between robots and food highlights a significant aspect of technology, which is its limitation in replicating human experiences, such as savoring delicious food.</IMPROVEMENT>",
26
26
  feedback:
27
- "The essay does not directly address the topic 'Technology'. It starts with a vague statement about technology and then diverges into an unrelated phrase. There is no clear argument or discussion about technology.",
27
+ "The essay does not directly address the topic 'Technology'. It appears to be discussing food and its relation to robots, which is not relevant to the given topic. The essay lacks any mention or discussion about technology.",
28
28
  },
29
29
  critical_thinking: {
30
30
  score: 80,
31
31
  example:
32
- "Technology is the beginning of the end, argue with your keyboard lol, thank you! <IMPROVEMENT>On one hand, one could argue that technological advancements lead to significant improvements in our quality of life, such as increased connectivity and access to information.</IMPROVEMENT> <IMPROVEMENT>On the other hand, it can also be argued that over-reliance on technology may lead to negative consequences, such as decreased face-to-face interaction and potential job displacement due to automation.</IMPROVEMENT> <IMPROVEMENT>Considering these contrasting views, it becomes essential to analyze the statement critically and evaluate the potential implications of technological advancements on society.</IMPROVEMENT>",
32
+ "Have you heard about food? It's a universal language that humans understand, but <IMPROVEMENT>its significance extends beyond just taste, as it can evoke emotions and create cultural connections</IMPROVEMENT>. Very delicious.. <IMPROVEMENT>This subjective experience is uniquely human, as robots, lacking senses and emotions, can't truly relate to the culinary world in the way humans do</IMPROVEMENT>. Robots can't relate.",
33
33
  feedback:
34
- "The essay lacks depth and analysis, failing to present a clear argument or explore different perspectives on the given statement. It does not go beyond a superficial statement and lacks original thought.",
34
+ "The essay lacks depth of analysis and originality of thought. It does not explore different perspectives or go beyond a superficial statement. The connection between food and robots is not clearly established, and the essay does not demonstrate critical thinking.",
35
35
  },
36
36
  },
37
- char_count: 80,
38
- word_count: 14,
37
+ char_count: 64,
38
+ word_count: 10,
39
39
  overall_score: 63,
40
40
  overall_feedback:
41
- "Evidence: The essay lacks any form of evidence to support its claim. There are no specific examples, data, or references to credible sources. The statement 'Technology is the beginning of the end' is unsubstantiated and the following phrase 'argue with your keyboard lol, thank you!' does not contribute to the argument or provide evidence. To strengthen the essay, relevant and convincing evidence should be incorporated.\n\nCoherence: The essay lacks coherence and logical flow as it consists of a single sentence that does not present a clear argument or claim. There are no subsequent paragraphs to develop the idea, and the transition between the initial statement and the concluding phrase is abrupt and unclear.\n\nRelevance: The essay does not directly address the topic 'Technology'. It starts with a vague statement about technology and then diverges into an unrelated phrase. There is no clear argument or discussion about technology.\n\nCritical Thinking: The essay lacks depth and analysis, failing to present a clear argument or explore different perspectives on the given statement. It does not go beyond a superficial statement and lacks original thought.",
41
+ "Evidence: The essay lacks any form of evidence to support its claims. There are no specific examples, data, or references to credible sources. The statements made are vague and do not provide any convincing argument. To improve, the author should include relevant and convincing evidence, such as statistics or expert opinions, to substantiate their claims.\n\nCoherence: The essay lacks coherence and logical flow. It appears to be a collection of disconnected sentences. To improve coherence, a clear topic sentence and a logical connection between the ideas are needed. The transition between 'Have you heard about food?' and 'Very delicious..' is abrupt, and the sentence 'Robots can't relate.' seems unrelated to the preceding sentences.\n\nRelevance: The essay does not directly address the topic 'Technology'. It appears to be discussing food and its relation to robots, which is not relevant to the given topic. The essay lacks any mention or discussion about technology.\n\nCritical Thinking: The essay lacks depth of analysis and originality of thought. It does not explore different perspectives or go beyond a superficial statement. The connection between food and robots is not clearly established, and the essay does not demonstrate critical thinking.",
42
42
  },
43
43
  },
44
44
  ],
@@ -46,49 +46,25 @@ export const sampleData1 = {
46
46
  {
47
47
  model_data: {
48
48
  Feedback: [
49
- "Inserted '\"'",
50
- "Replaced ',' with '.\"'",
51
- "Corrected formatting for 'argue' to 'Argue'",
52
- "Inserted ','",
53
- "Corrected formatting for ',' to '.'",
54
- "Corrected formatting for 'thank' to 'Thank'",
49
+ "Inserted 'the '",
50
+ "Replaced 'Very' with 'It's very'",
51
+ "Deleted '.'",
55
52
  ],
56
53
  "Grammar Score": 85,
57
54
  "Original Speech":
58
- "Technology is the beginning of the end, argue with your keyboard lol, thank you!",
55
+ "Have you heard about food? Very delicious.. Robots can't relate.",
59
56
  "Grammatical Correct Version":
60
- '"Technology is the beginning of the end." Argue with your keyboard, lol. Thank you!',
57
+ "Have you heard about the food? It's very delicious. Robots can't relate.",
61
58
  "Correction Operations (Optional)": [
62
- { word: '"', length: 1, position: 1, operation: "inserted" },
59
+ { word: "the ", length: 4, position: 22, operation: "inserted" },
63
60
  {
64
- length: 1,
65
- position: 39,
61
+ length: 4,
62
+ position: 28,
66
63
  operation: "substituted",
67
- original_word: ",",
68
- replacement_word: '."',
69
- },
70
- {
71
- length: 5,
72
- position: 41,
73
- operation: "formatting",
74
- original_word: "argue",
75
- replacement_word: "Argue",
76
- },
77
- { word: ",", length: 1, position: 65, operation: "inserted" },
78
- {
79
- length: 1,
80
- position: 69,
81
- operation: "formatting",
82
- original_word: ",",
83
- replacement_word: ".",
84
- },
85
- {
86
- length: 5,
87
- position: 71,
88
- operation: "formatting",
89
- original_word: "thank",
90
- replacement_word: "Thank",
64
+ original_word: "Very",
65
+ replacement_word: "It's very",
91
66
  },
67
+ { word: ".", length: 1, position: 42, operation: "deleted" },
92
68
  ],
93
69
  },
94
70
  },
@@ -435,7 +435,31 @@ export const GrammarHeaderContent = styled.div`
435
435
  background: #f5f7f7;
436
436
  width: 100%;
437
437
  margin-bottom: 20px;
438
- span {
438
+ .grammar_analysis_container {
439
+ line-height: 22px;
440
+ font-size: 16px;
441
+ .issue {
442
+ display: inline-flex;
443
+ padding-right: 4px;
444
+ color: #f95454;
445
+ align-items: center;
446
+ gap: 2px;
447
+ cursor: pointer;
448
+ .number {
449
+ display: inline-flex;
450
+ justify-content: center;
451
+ align-items: center;
452
+ height: 20px;
453
+ border-radius: 100px;
454
+ padding: 0 6px;
455
+ border: 1px solid #f95454;
456
+ background: rgba(249, 84, 84, 0.2);
457
+ font-size: 12px;
458
+ font-weight: 700;
459
+ }
460
+ }
461
+ }
462
+ /* span {
439
463
  line-height: 22px;
440
464
  font-size: 16px;
441
465
 
@@ -459,7 +483,7 @@ export const GrammarHeaderContent = styled.div`
459
483
  font-weight: 700;
460
484
  }
461
485
  }
462
- }
486
+ } */
463
487
  `;
464
488
 
465
489
  export const GrammarContent = styled.div`
@@ -634,6 +634,7 @@ const useReportUtils = () => {
634
634
  grammarCorrectResult,
635
635
  grammerCorrectParagraph,
636
636
  formatNumber,
637
+ getColor,
637
638
  };
638
639
  };
639
640
 
@@ -34,7 +34,14 @@ import useApi from "../api";
34
34
  * @param {boolean} props.editMode
35
35
  * @returns {React.ReactNode}
36
36
  */
37
- const Comment = ({ editMode = false, data, testId, questionData, setData }) => {
37
+ const Comment = ({
38
+ editMode = false,
39
+ data,
40
+ testId,
41
+ questionData,
42
+ setData,
43
+ disabledAdd,
44
+ }) => {
38
45
  const { affiliateAccount } = useContext(OutletContext);
39
46
  const [toggleDelete, setToggleDelete] = useState(false);
40
47
  const [showForm, setShowForm] = useState(null);
@@ -197,6 +204,7 @@ const Comment = ({ editMode = false, data, testId, questionData, setData }) => {
197
204
  {!showForm && (
198
205
  <button
199
206
  className="sm-btn"
207
+ disabled={disabledAdd}
200
208
  onClick={() => {
201
209
  setShowForm("Text");
202
210
  }}
@@ -32,6 +32,8 @@ export const CommentContainer = styled.div`
32
32
  cursor: pointer;
33
33
  &:disabled {
34
34
  background: #c6cccc;
35
+
36
+ cursor: not-allowed;
35
37
  box-shadow: none;
36
38
  }
37
39
  }
@@ -125,6 +127,7 @@ export const CommentContentEmpty = styled.div``;
125
127
 
126
128
  export const CommentContentForm = styled.div`
127
129
  margin-bottom: 10px;
130
+
128
131
  > textarea {
129
132
  border-radius: 10px;
130
133
  border: 1px solid #dfe5e5;
@@ -35,7 +35,7 @@ import classNames from "classnames";
35
35
  import FullAnalysis from "../fullAnalysis";
36
36
  import useApi from "./api";
37
37
  import FullPageLoader from "../../fullPageLoader";
38
- import { OutletContext } from "../..";
38
+ import { ButtonComponent, OutletContext } from "../..";
39
39
  import useReportUtils from "../hooks/useRreportUtils";
40
40
  import ErrorHeader from "./components/errorHeader";
41
41
 
@@ -191,11 +191,14 @@ const ReportQuestions = ({
191
191
  {(accountType === "instructor-personal" ||
192
192
  accountType === "instructor-affiliate") && (
193
193
  <button
194
+ disabled={!hasAnswer && data}
194
195
  onClick={() => {
195
196
  setToggleGrade(true);
196
197
  }}
197
198
  >
198
- <YellowPen />
199
+ <YellowPen
200
+ color={!hasAnswer && data ? "#fff" : undefined}
201
+ />
199
202
  Edit score
200
203
  </button>
201
204
  )}
@@ -290,6 +293,7 @@ const ReportQuestions = ({
290
293
  testId={testId}
291
294
  questionData={data}
292
295
  setData={setComment}
296
+ disabledAdd={!hasAnswer}
293
297
  editMode={
294
298
  accountType === "instructor-personal" ||
295
299
  accountType === "instructor-affiliate"
@@ -38,6 +38,13 @@ export const ScoreHeader = styled.div`
38
38
  padding-bottom: 15px;
39
39
  border-bottom: 1px solid #f5f7f7;
40
40
  margin-bottom: 15px;
41
+ button {
42
+ &:disabled {
43
+ cursor: not-allowed;
44
+ background: #c6cccc;
45
+ color: white;
46
+ }
47
+ }
41
48
  `;
42
49
 
43
50
  export const ScoreRight = styled.div`