move move frontend to progress-test

This commit is contained in:
João Geonizeli
2022-07-21 21:16:59 -03:00
parent f8d5d08447
commit 386050d4ad
129 changed files with 159374 additions and 39 deletions

View File

@@ -0,0 +1,18 @@
import { Node } from "../../__generated__/graphql-schema";
const SEPARATOR_TOKEN = "-";
type Decoded = { typeName: string; id: string };
const decode = (id: Node["id"]): Decoded => {
const raw = Buffer.from(id, "base64").toString("ascii");
const [nodeTypeName, nodeId] = raw.split(SEPARATOR_TOKEN);
return {
id: nodeId,
typeName: nodeTypeName,
};
};
export const NodeId = { decode };

View File

@@ -0,0 +1 @@
export * from "./NodeId";

View File

@@ -0,0 +1 @@
export * from "./strings";

View File

@@ -0,0 +1 @@
export * from "./range";

View File

@@ -0,0 +1,5 @@
export const range = (start: number, end: number) => {
const length = end - start;
return Array.from({ length }, (_, i) => start + i);
};

View File

@@ -0,0 +1 @@
export * from "./wiris";

View File

@@ -0,0 +1,7 @@
export const loadWIRISplugin = () => {
const script = document.createElement("script");
script.src = process.env.REACT_APP_WIRIS_PLUGIN_URL ?? "";
script.async = true;
document.body.appendChild(script);
};

View File

@@ -0,0 +1 @@
export * from "./questionValidations";

View File

@@ -0,0 +1,100 @@
import {
Question,
QuestionCreateInput,
} from "../../__generated__/graphql-schema";
export type QuestionEditForm = Question & {
subjectId: string;
reviewerId: string;
};
export const validateQuestionInputs = (inputs: QuestionCreateInput) => {
/**
* transform string with lenght 0 to undefined
*/
const tempValues: { [key: string]: any } = {};
Object.keys(inputs).forEach((key: string) => {
const value = (inputs as any)[key];
tempValues[key] = value === "" ? undefined : value;
});
const values = tempValues as QuestionCreateInput;
const errors = [];
const {
alternatives,
authorshipYear,
body,
explanation,
references,
difficulty,
bloomTaxonomy,
checkType,
subjectId,
authorship,
intention,
reviewerUserId,
} = values;
if (!body || body.length <= 5) {
errors.push(`"Enunciado" não preenchido.`);
}
const answer = alternatives?.find((a) => a.correct);
if (!answer?.text?.length) {
errors.push(`"Resposta Correta" não preenchida.`);
}
if (!explanation || explanation.length <= 5) {
errors.push(`"Explicação" não preenchida.`);
}
if (!references || references.length <= 5) {
errors.push(`"Referências" não preenchidas.`);
}
const distractors = alternatives?.filter((a) => !a.correct);
const emptyDistractores = distractors?.filter((a) => !a.text?.length);
if (emptyDistractores?.length) {
errors.push(`Um ou mais "Distratores" não preenchidos.`);
}
if (!authorship) {
errors.push(`"Fonte" não preenchida.`);
}
if (!authorshipYear) {
errors.push(`"Ano" não preenchido.`);
}
if (!difficulty) {
errors.push(`"Grau de Dificuldade" não preenchido.`);
}
if (!subjectId) {
errors.push(`"Assunto" não preenchido.`);
}
if (!checkType) {
errors.push(`"Tipo" não preenchido.`);
}
if (!bloomTaxonomy) {
errors.push(`"Habilidade" não preenchida.`);
}
if (!intention) {
errors.push(`"Intenção" não preenchido.`);
}
if (!reviewerUserId) {
errors.push(`"Revisor" não preenchido.`);
}
return errors;
};

View File

@@ -0,0 +1,2 @@
export const classNames = (...classes: string[]) =>
classes.filter(Boolean).join(" ");

View File

@@ -0,0 +1 @@
export * from "./classNames";

View File

@@ -0,0 +1,27 @@
export const CHECK_TYPE = [
{ value: "unique_answer", label: "Resposta Única" },
{ value: "incomplete_affirmation", label: "Afirmação Incompleta" },
{ value: "multiple_answer", label: "Resposta Múltipla" },
{ value: "negative_focus", label: "Foco Negativo" },
{ value: "assertion_and_reason", label: "Asserção e Razão" },
{ value: "gap", label: "Lacuna" },
{ value: "interpretation", label: "Interpretação" },
{ value: "association", label: "Associação" },
{ value: "ordering_or_ranking", label: "Ordenação ou Seriação" },
{ value: "constant_alternatives", label: "Alternativas Constantes" },
];
export const DIFFICULTY = [
{ value: "easy", label: "Fácil" },
{ value: "medium", label: "Média" },
{ value: "hard", label: "Difícil" },
];
export const BLOOM_TAXONOMY = [
{ value: "remember", label: "Recordar" },
{ value: "understand", label: "Compreender" },
{ value: "apply", label: "Aplicar" },
{ value: "analyze", label: "Analisar" },
{ value: "evaluate", label: "Avaliar" },
{ value: "create", label: "Criar" },
];