aboutsummaryrefslogtreecommitdiffstats
path: root/src/components/Question.tsx
diff options
context:
space:
mode:
authorGravatar Hassan Abouelela <[email protected]>2022-07-01 00:19:13 +0400
committerGravatar Hassan Abouelela <[email protected]>2022-07-01 01:15:35 +0400
commita378b1c9ee096388002f3b0fdc26636e9c1cd57b (patch)
treed11d64dfc393cefecd2d2523f556b78dfba0701a /src/components/Question.tsx
parentDisplay Test Names For Unittest Failures (diff)
Restructure FormPage
The main FormPage component had gotten very out of hand, with many moving parts that were hard to parse, understand, or modify. This refactors breaks things up into separate files with better defined goals. Most changes are just straight copies without much change, however some structural changes have been introduced as a foundation for improving the app. Signed-off-by: Hassan Abouelela <[email protected]>
Diffstat (limited to 'src/components/Question.tsx')
-rw-r--r--src/components/Question.tsx19
1 files changed, 6 insertions, 13 deletions
diff --git a/src/components/Question.tsx b/src/components/Question.tsx
index 2ce84b2..b42ea09 100644
--- a/src/components/Question.tsx
+++ b/src/components/Question.tsx
@@ -40,10 +40,6 @@ class RenderedQuestion extends React.Component<QuestionProp> {
"error": "",
};
- if (props.question.type === QuestionType.Code) {
- _state["unittestsFailed"] = false;
- }
-
if (!skip_normal_state.includes(props.question.type)) {
_state["value"] = "";
}
@@ -70,6 +66,10 @@ class RenderedQuestion extends React.Component<QuestionProp> {
} else {
this.setPublicState("error", "");
this.setPublicState("valid", true);
+
+ if (this.props.question.type === QuestionType.Code) {
+ this.props.public_state.set("unittestsFailed", false);
+ }
}
}
}
@@ -166,8 +166,8 @@ class RenderedQuestion extends React.Component<QuestionProp> {
}
let invalid = false;
- let unittest_failed = false;
const options: string | string[] = this.props.question.data["options"];
+
switch (this.props.question.type) {
case QuestionType.TextArea:
case QuestionType.ShortText:
@@ -175,9 +175,6 @@ class RenderedQuestion extends React.Component<QuestionProp> {
if (this.props.public_state.get("value") === "") {
invalid = true;
}
- if (this.props.public_state.get("unittestsFailed")) {
- unittest_failed = true;
- }
break;
case QuestionType.Select:
@@ -204,11 +201,7 @@ class RenderedQuestion extends React.Component<QuestionProp> {
if (invalid) {
this.setPublicState("error", "Field must be filled.");
this.setPublicState("valid", false);
- } else if (unittest_failed) {
- this.setPublicState("error", "1 or more unittests failed.");
- this.setPublicState("valid", false);
- }
- else {
+ } else {
this.setPublicState("error", "");
this.setPublicState("valid", true);
}