diff options
author | 2022-03-14 14:31:38 -0400 | |
---|---|---|
committer | 2022-03-14 14:31:38 -0400 | |
commit | 5f9e3a19c2f596f92f4d0eeae7396cf5c00f3bf8 (patch) | |
tree | 381138378b2288a00d94fedbd6eca6f7fef43307 /src | |
parent | Merge pull request #351 from python-discord/dependabot/npm_and_yarn/typescrip... (diff) |
Add new unittestsFailed public_state field
New field to determine if a unittest failed and provide feedback to the
user.
Diffstat (limited to 'src')
-rw-r--r-- | src/components/Question.tsx | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src/components/Question.tsx b/src/components/Question.tsx index 2914ae6..3b63f07 100644 --- a/src/components/Question.tsx +++ b/src/components/Question.tsx @@ -37,6 +37,9 @@ class RenderedQuestion extends React.Component<QuestionProp> { this.setPublicState("valid", true); this.setPublicState("error", ""); + if (props.question.type === QuestionType.Code) { + this.setPublicState("unittestsFailed", false); + } if (!skip_normal_state.includes(props.question.type)) { this.setPublicState("value", ""); @@ -155,6 +158,7 @@ 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: @@ -163,6 +167,9 @@ 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: @@ -189,7 +196,11 @@ class RenderedQuestion extends React.Component<QuestionProp> { if (invalid) { this.setPublicState("error", "Field must be filled."); this.setPublicState("valid", false); - } else { + } else if (unittest_failed) { + this.setPublicState("error", "1 or more unittests failed."); + this.setPublicState("valid", false); + } + else { this.setPublicState("error", ""); this.setPublicState("valid", true); } |