Compare commits
13 Commits
264d126414
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
65a3180599 | ||
|
|
45b401eda3 | ||
|
|
5899d2ad1f | ||
| 1edd26bf1b | |||
|
|
ce7d38e95b | ||
|
|
230a59e999 | ||
|
|
147fb997d0 | ||
|
|
3d946d03ff | ||
|
|
a28b21f44e | ||
|
|
8e0111b8ea | ||
|
|
155bbddbd7 | ||
|
|
f8ff95d188 | ||
|
|
2a1883dd8e |
@@ -7,12 +7,14 @@ import { AssessmentRoutePaths, DashboardRoutePaths, QuestionRoutePaths } from ".
|
||||
import { RootState } from "../../services/store";
|
||||
import { turnOff } from "../../services/store/unsavedChanges";
|
||||
import { Dialog } from '../Dialog';
|
||||
import { useCurrentUser } from "../../contexts";
|
||||
|
||||
export const AppbarTabs = () => {
|
||||
const unsavedChanges = useSelector((state: RootState) => state.unsavedChanges)
|
||||
const dispatch = useDispatch()
|
||||
const location = useLocation()
|
||||
const history = useHistory()
|
||||
const { isOnlyTeacher } = useCurrentUser()
|
||||
|
||||
const [newPath, setNewPath] = useState<string>()
|
||||
|
||||
@@ -45,14 +47,16 @@ export const AppbarTabs = () => {
|
||||
tabel: 'Questões',
|
||||
pathname: QuestionRoutePaths.index,
|
||||
isCurrent: location.pathname.includes('question'),
|
||||
},
|
||||
{
|
||||
icon: <DocumentIcon className="w-6" />,
|
||||
tabel: 'Avaliações',
|
||||
pathname: AssessmentRoutePaths.index,
|
||||
isCurrent: false,
|
||||
}]
|
||||
|
||||
if (!isOnlyTeacher) {
|
||||
links.push({
|
||||
icon: <DocumentIcon className="w-6" />,
|
||||
tabel: 'Avaliações',
|
||||
pathname: AssessmentRoutePaths.index,
|
||||
isCurrent: false,
|
||||
})
|
||||
}
|
||||
]
|
||||
|
||||
return (
|
||||
<>
|
||||
|
||||
@@ -5,6 +5,7 @@ import { Controller, useForm } from "react-hook-form";
|
||||
|
||||
import { Axis, Query } from "../../__generated__/graphql-schema";
|
||||
import { Button, Card, Input, Navigator } from '../../components';
|
||||
import { useHistory } from "react-router";
|
||||
|
||||
type NewAssessementForm = {
|
||||
axisWeights: Record<string, any>
|
||||
@@ -47,6 +48,8 @@ export const NewAssessement = () => {
|
||||
const notSelectedAxis: Axis[] = axes.filter((axis) => !subjectsIds.includes(axis.id))
|
||||
const selectedAxis: Axis[] = axes.filter((axis) => subjectsIds.includes(axis.id))
|
||||
|
||||
const navigate = useHistory()
|
||||
|
||||
return (
|
||||
<>
|
||||
<Navigator home />
|
||||
@@ -179,9 +182,14 @@ export const NewAssessement = () => {
|
||||
</div>
|
||||
</Card>
|
||||
</div>
|
||||
<Button type="primary" className="ml-auto mr-6 mt-6">
|
||||
Gerar
|
||||
</Button>
|
||||
<div className="flex justify-end mr-6 gap-4">
|
||||
<Button type="primary" className="mt-6">
|
||||
Gerar Automaticamente
|
||||
</Button>
|
||||
<Button type="primary" className="mt-6" onClick={() => navigate.push('new-manual')}>
|
||||
Gerar Manualmente
|
||||
</Button>
|
||||
</div>
|
||||
</>
|
||||
)
|
||||
}
|
||||
@@ -1,98 +1,84 @@
|
||||
import { gql, useQuery } from "@apollo/client";
|
||||
import React, { useState } from "react";
|
||||
import { Controller, useForm } from "react-hook-form";
|
||||
|
||||
import { Axis, Query } from "../../__generated__/graphql-schema";
|
||||
import { Button, Card, Input, Navigator } from '../../components';
|
||||
import { SideBar } from "./components/SideBar";
|
||||
import { QuestionCard } from "./components/QuestionCard";
|
||||
import { Link } from "react-router-dom";
|
||||
import { Navigator } from '../../components';
|
||||
import { SelectedQuestionsSideBar } from "./components/SelectedQuestionsSideBar";
|
||||
import { FiltersSideBar } from "./components/FiltersSideBar";
|
||||
import { BottomBar } from "./components/BottomBar";
|
||||
import { QuestionArea } from "./components/QuestionArea";
|
||||
import { gql, useQuery } from "@apollo/client";
|
||||
import { Query, Question } from "../../__generated__/graphql-schema";
|
||||
|
||||
type NewAssessementManualForm = {
|
||||
axisWeights: Record<string, any>
|
||||
}
|
||||
|
||||
const NEW_ASSESSEMENT_DATA_QUERY = gql`
|
||||
query NewAssessementDataQuery {
|
||||
axes {
|
||||
nodes {
|
||||
id
|
||||
const QuestionFragments = gql`
|
||||
fragment QuestionFields on Question {
|
||||
id
|
||||
authorship
|
||||
authorshipYear
|
||||
bloomTaxonomy
|
||||
body
|
||||
checkType
|
||||
difficulty
|
||||
status
|
||||
subject {
|
||||
axis {
|
||||
name
|
||||
}
|
||||
category {
|
||||
name
|
||||
}
|
||||
name
|
||||
}
|
||||
}
|
||||
`
|
||||
|
||||
const QUESTIONS_QUERY = gql`
|
||||
${QuestionFragments}
|
||||
query {
|
||||
questions {
|
||||
nodes {
|
||||
...QuestionFields
|
||||
}
|
||||
}
|
||||
}
|
||||
`
|
||||
|
||||
export const NewAssessementManual = () => {
|
||||
const { data } = useQuery<Query>(NEW_ASSESSEMENT_DATA_QUERY)
|
||||
const axes = data?.axes.nodes
|
||||
const [questions, setQuestions] = useState<Question[]>([])
|
||||
const [selectedQuestions, setSelectedQuestions] = useState<{id: string, label: string, removeHandler: Function}[]>([])
|
||||
|
||||
const [questions, setQuestions] = useState<{id: string, label: string, removeHandler: Function}[]>([])
|
||||
|
||||
const [subjectsIds, setSubjectsIds] = useState<string[]>([])
|
||||
const { register, control, watch } = useForm<NewAssessementManualForm>({
|
||||
mode: 'onBlur'
|
||||
useQuery<Query>(QUESTIONS_QUERY, {
|
||||
onCompleted: (response) => {
|
||||
const { questions: questionConnection } = response
|
||||
setQuestions(questionConnection.nodes as Question[])
|
||||
},
|
||||
fetchPolicy: "network-only"
|
||||
})
|
||||
|
||||
|
||||
const addAxisForm = useForm<{ axisId: string }>()
|
||||
|
||||
const handleAddAxis = (formData: { axisId: string }) => {
|
||||
setSubjectsIds(prev => [...prev, formData.axisId])
|
||||
addAxisForm.reset();
|
||||
}
|
||||
|
||||
const handleRemoveAxis = (axisId: string) => {
|
||||
setSubjectsIds(prev => prev.filter((axis => axis !== axisId)))
|
||||
}
|
||||
|
||||
if (!axes?.length) return null
|
||||
|
||||
const notSelectedAxis: Axis[] = axes.filter((axis) => !subjectsIds.includes(axis.id))
|
||||
const selectedAxis: Axis[] = axes.filter((axis) => subjectsIds.includes(axis.id))
|
||||
|
||||
const addQuestion = (label: string, removeHandler: Function) => {
|
||||
const id: string = label.replace(/\s+/g, '')
|
||||
if (!questions.find(q => q.id === id)) {
|
||||
setQuestions(q => [...q, { id, label, removeHandler }])
|
||||
const id: string = label.replace(/\s+/g, '_')
|
||||
if (!selectedQuestions.find(q => q.id === id)) {
|
||||
setSelectedQuestions(q => [...q, { id, label, removeHandler }])
|
||||
}
|
||||
}
|
||||
|
||||
const removeQuestion = (id: string) => {
|
||||
setQuestions(q => q.filter(i => i.id !== id))
|
||||
setSelectedQuestions(q => q.filter(i => i.id !== id))
|
||||
}
|
||||
|
||||
const clearSelectedQuestions = () => {
|
||||
setSelectedQuestions([])
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<Navigator home />
|
||||
<div className="grid grid-cols-5 gap-4 mt-4 mx-4">
|
||||
<BottomBar/>
|
||||
<div className="grid grid-cols-5 gap-4 mt-4 mx-4 pb-20">
|
||||
<FiltersSideBar/>
|
||||
<div className="col-span-3 border-l-2 border-r-2 border-gray-300 px-6 pb-20"> {/*bg-blue-500*/}
|
||||
<QuestionCard title="Question 1"
|
||||
onAddQuestion={addQuestion}
|
||||
onRemoveQuestion={removeQuestion}/>
|
||||
<QuestionCard title="Question 2"
|
||||
onAddQuestion={addQuestion}
|
||||
onRemoveQuestion={removeQuestion}/>
|
||||
<QuestionCard title="Question 3"
|
||||
onAddQuestion={addQuestion}
|
||||
onRemoveQuestion={removeQuestion}/>
|
||||
<QuestionCard title="Question 4"
|
||||
onAddQuestion={addQuestion}
|
||||
onRemoveQuestion={removeQuestion}/>
|
||||
<QuestionCard title="Question 5"
|
||||
onAddQuestion={addQuestion}
|
||||
onRemoveQuestion={removeQuestion}/>
|
||||
<QuestionCard title="Question 6"
|
||||
onAddQuestion={addQuestion}
|
||||
onRemoveQuestion={removeQuestion}/>
|
||||
<QuestionCard title="Question 7"
|
||||
onAddQuestion={addQuestion}
|
||||
onRemoveQuestion={removeQuestion}/>
|
||||
</div>
|
||||
<SelectedQuestionsSideBar questions={questions}/>
|
||||
<QuestionArea questions={questions}
|
||||
onAddQuestion={addQuestion} onRemoveQuestion={removeQuestion}/>
|
||||
<SelectedQuestionsSideBar
|
||||
questions={selectedQuestions}
|
||||
onClearSelectedQuestions={clearSelectedQuestions}
|
||||
/>
|
||||
</div>
|
||||
</>
|
||||
)
|
||||
|
||||
21
app/javascript/pages/assessment/components/BottomBar.tsx
Normal file
21
app/javascript/pages/assessment/components/BottomBar.tsx
Normal file
@@ -0,0 +1,21 @@
|
||||
import React, { FC, } from "react";
|
||||
import { Button } from "../../../components";
|
||||
|
||||
type Props = {
|
||||
|
||||
}
|
||||
|
||||
export const BottomBar: FC<Props> = () => {
|
||||
return (
|
||||
<div className="fixed bottom-0 bg-white w-full h-16 flex items-center justify-end shadow-lg">
|
||||
<div className="flex gap-6 mx-16">
|
||||
<Button className="w-32">
|
||||
Cancelar
|
||||
</Button>
|
||||
<Button type="primary" className="w-32">
|
||||
Salvar
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -1,57 +1,83 @@
|
||||
import React, { FC, } from "react";
|
||||
import React, { FC, useState, } from "react";
|
||||
import { SideBar } from "./SideBar";
|
||||
import { SelectedQuestionCard } from "./SelectedQuestionCard";
|
||||
import { Button } from "../../../components";
|
||||
import { SelectFilterField } from "./SelectFilterField";
|
||||
import { RangeFilterField } from "./RangeFilterField";
|
||||
import { BLOOM_TAXONOMY, CHECK_TYPE, DIFFICULTY } from "../../../utils/types";
|
||||
import { gql, useQuery } from "@apollo/client";
|
||||
import { Axis, Category, Query, Subject } from "../../../__generated__/graphql-schema";
|
||||
|
||||
const FILTERS_QUERY = gql`
|
||||
query {
|
||||
categories {
|
||||
nodes {
|
||||
id
|
||||
name
|
||||
}
|
||||
}
|
||||
axes {
|
||||
nodes {
|
||||
id
|
||||
name
|
||||
}
|
||||
}
|
||||
subjects {
|
||||
nodes {
|
||||
id
|
||||
name
|
||||
}
|
||||
}
|
||||
}
|
||||
`
|
||||
|
||||
type Props = {
|
||||
questions?: {
|
||||
id: string, label: string, removeHandler: Function
|
||||
}[]
|
||||
|
||||
}
|
||||
|
||||
export const FiltersSideBar: FC<Props> = () => {
|
||||
const [categories, setCategories] = useState<Category[]>([])
|
||||
const [axis, setAxis] = useState<Axis[]>([])
|
||||
const [subjects, setSubjects] = useState<Subject[]>([])
|
||||
|
||||
const difficulties = DIFFICULTY.map(item => ({id: item.value, label: item.label}))
|
||||
const bloomTaxonomyTypes = BLOOM_TAXONOMY.map(item => ({id: item.value, label: item.label}))
|
||||
const checkTypes = CHECK_TYPE.map(item => ({id: item.value, label: item.label}))
|
||||
const authorshipTypes = [
|
||||
{id: 1, label: 'Própria'},
|
||||
{id: 2, label: 'Outro'},
|
||||
]
|
||||
|
||||
useQuery<Query>(FILTERS_QUERY, {
|
||||
onCompleted: (response) => {
|
||||
const {
|
||||
categories: categoriesConnection,
|
||||
axes: axisConnection,
|
||||
subjects: subjectConnection
|
||||
} = response
|
||||
setCategories(categoriesConnection.nodes as Category[])
|
||||
setAxis(axisConnection.nodes as Axis[])
|
||||
setSubjects(subjectConnection.nodes as Subject[])
|
||||
},
|
||||
fetchPolicy: "network-only"
|
||||
})
|
||||
|
||||
return (
|
||||
<SideBar header="Filtros">
|
||||
<div className="mt-3">
|
||||
<form className="flex flex-col gap-4"
|
||||
// onSubmit={addAxisForm.handleSubmit(handleAddAxis)}
|
||||
>
|
||||
<SelectFilterField label="Grau de Dificuldade:" options={[
|
||||
{id: 1, label: 'Fácil'},
|
||||
{id: 2, label: 'Média'},
|
||||
{id: 3, label: 'Difícil'}
|
||||
]}/>
|
||||
<SelectFilterField label="Categoria:" options={[
|
||||
{id: 1, label: 'Conhecimentos Básicos'},
|
||||
{id: 2, label: 'Redes e Sistemas Computacionais'},
|
||||
{id: 3, label: 'Modelagem e Simulacao'}
|
||||
]}/>
|
||||
<SelectFilterField label="Eixo de Formação:" options={[
|
||||
{id: 1, label: 'Infraestrutura de Sistemas Computacionais'},
|
||||
{id: 2, label: 'Sistemas de Software'},
|
||||
{id: 3, label: 'Algoritmos de Alto Desempenho'}
|
||||
]}/>
|
||||
<SelectFilterField label="Assunto:" options={[
|
||||
{id: 1, label: 'Cálculo'},
|
||||
{id: 2, label: 'Pesquisa Operacional'},
|
||||
{id: 3, label: 'Sistemas Digitais'}
|
||||
]}/>
|
||||
<SelectFilterField label="Habilidade Cognitiva:" options={[
|
||||
{id: 1, label: 'Recordar'},
|
||||
{id: 2, label: 'Compreender'},
|
||||
{id: 3, label: 'Criar'}
|
||||
]}/>
|
||||
<SelectFilterField label="Tipo:" options={[
|
||||
{id: 1, label: 'Resposta Multipla'},
|
||||
{id: 2, label: 'Lacuna'},
|
||||
{id: 3, label: 'Foco Negativo'}
|
||||
]}/>
|
||||
<SelectFilterField label="Autoria:" options={[
|
||||
{id: 1, label: 'Própria'},
|
||||
{id: 2, label: 'Outro'},
|
||||
]}/>
|
||||
<form className="flex flex-col gap-4">
|
||||
<SelectFilterField label="Grau de Dificuldade:" options={difficulties}/>
|
||||
<SelectFilterField label="Categoria:" options={
|
||||
categories.map(item => ({id: item.id, label: item.name}))
|
||||
}/>
|
||||
<SelectFilterField label="Eixo de Formação:" options={
|
||||
axis.map(item => ({id: item.id, label: item.name}))
|
||||
}/>
|
||||
<SelectFilterField label="Assunto:" options={
|
||||
subjects.map(item => ({id: item.id, label: item.name}))
|
||||
}/>
|
||||
<SelectFilterField label="Habilidade Cognitiva:" options={bloomTaxonomyTypes}/>
|
||||
<SelectFilterField label="Tipo:" options={checkTypes}/>
|
||||
<SelectFilterField label="Autoria:" options={authorshipTypes}/>
|
||||
<RangeFilterField label="Ano:"/>
|
||||
<div className="w-full flex flex-col mt-2 gap-3">
|
||||
<Button type="primary" htmlType="submit">
|
||||
@@ -61,7 +87,6 @@ export const FiltersSideBar: FC<Props> = () => {
|
||||
Limpar Filtro
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
</form>
|
||||
</div>
|
||||
</SideBar>
|
||||
|
||||
20
app/javascript/pages/assessment/components/QuestionArea.tsx
Normal file
20
app/javascript/pages/assessment/components/QuestionArea.tsx
Normal file
@@ -0,0 +1,20 @@
|
||||
import React, { FC } from "react";
|
||||
import { QuestionCard } from "./QuestionCard";
|
||||
import { Question } from "../../../__generated__/graphql-schema";
|
||||
|
||||
interface Props {
|
||||
questions: Question[]
|
||||
onAddQuestion: Function,
|
||||
onRemoveQuestion: Function
|
||||
}
|
||||
|
||||
export const QuestionArea: FC<Props> = ({ questions, onAddQuestion, onRemoveQuestion }) => {
|
||||
return (
|
||||
<div className="col-span-3 border-l-2 border-r-2 border-gray-300 px-6">
|
||||
{questions.map(question =>
|
||||
<QuestionCard key={question.id} question={question}
|
||||
onAddQuestion={onAddQuestion}
|
||||
onRemoveQuestion={onRemoveQuestion}/>)}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -1,17 +1,25 @@
|
||||
import React, { FC, useState } from "react";
|
||||
import { Button, Card } from "../../../components";
|
||||
import { QuestionCardField } from "./QuestionCardField";
|
||||
import { Question } from "../../../__generated__/graphql-schema";
|
||||
import { NodeId } from "../../../utils/graphql";
|
||||
import { BLOOM_TAXONOMY, CHECK_TYPE, DIFFICULTY } from "../../../utils/types";
|
||||
|
||||
interface Props {
|
||||
title: string
|
||||
question: Question
|
||||
onAddQuestion: Function,
|
||||
onRemoveQuestion: Function
|
||||
}
|
||||
|
||||
export const QuestionCard: FC<Props> = ({ title, onAddQuestion, onRemoveQuestion }) => {
|
||||
export const QuestionCard: FC<Props> = ({ question, onAddQuestion, onRemoveQuestion }) => {
|
||||
const [collapsed, setCollapsed] = useState(false)
|
||||
|
||||
const questionId = title.replace(/\s+/g, '')
|
||||
|
||||
const title = `Questão ${NodeId.decode(question.id).id}`
|
||||
const htmlId = title.replace(/\s+/g, '_')
|
||||
const difficulty = DIFFICULTY.find(item => item.value === question.difficulty)?.label
|
||||
const bloomTaxonomy = BLOOM_TAXONOMY.find(item => item.value === question.bloomTaxonomy)?.label
|
||||
const checkType = CHECK_TYPE.find(item => item.value === question.checkType)?.label
|
||||
|
||||
const handleAddQuestion = () => {
|
||||
setButtonState({
|
||||
bg: 'bg-red-700', label: 'Remover', method: handleRemoveQuestion
|
||||
@@ -23,7 +31,7 @@ export const QuestionCard: FC<Props> = ({ title, onAddQuestion, onRemoveQuestion
|
||||
setButtonState({
|
||||
bg: '', label: 'Adicionar', method: handleAddQuestion
|
||||
})
|
||||
onRemoveQuestion(questionId)
|
||||
onRemoveQuestion(htmlId)
|
||||
}
|
||||
|
||||
const [buttonState, setButtonState] = useState({
|
||||
@@ -31,47 +39,21 @@ export const QuestionCard: FC<Props> = ({ title, onAddQuestion, onRemoveQuestion
|
||||
})
|
||||
|
||||
return (
|
||||
<div id={questionId}>
|
||||
<div id={htmlId}>
|
||||
<Card title={title} className="mb-5">
|
||||
<div>
|
||||
{!collapsed && <div className="grid grid-cols-2 gap-2">
|
||||
<div>
|
||||
<span className="text-gray-700">Grau de Dificuldade: </span>
|
||||
<span>Média</span>
|
||||
</div>
|
||||
<div>
|
||||
<span className="text-gray-700">Categoria: </span>
|
||||
<span>Modelagem</span>
|
||||
</div>
|
||||
<div>
|
||||
<span className="text-gray-700">Eixo de Formação: </span>
|
||||
<span>Infra Sistemas</span>
|
||||
</div>
|
||||
<div>
|
||||
<span className="text-gray-700">Assunto: </span>
|
||||
<span>Fisica</span>
|
||||
</div>
|
||||
<div>
|
||||
<span className="text-gray-700">Habilidade Cognitiva: </span>
|
||||
<span>Compreender</span>
|
||||
</div>
|
||||
<div>
|
||||
<span className="text-gray-700">Tipo: </span>
|
||||
<span>Resposta Multipla</span>
|
||||
</div>
|
||||
<div>
|
||||
<span className="text-gray-700">Autoria: </span>
|
||||
<span>UNIFESO</span>
|
||||
</div>
|
||||
<div>
|
||||
<span className="text-gray-700">Ano: </span>
|
||||
<span>2023</span>
|
||||
</div>
|
||||
<QuestionCardField label="Grau de Dificuldade" value={difficulty}/>
|
||||
<QuestionCardField label="Categoria" value={question.subject?.category.name}/>
|
||||
<QuestionCardField label="Eixo de Formação" value={question.subject?.axis.name}/>
|
||||
<QuestionCardField label="Assunto" value={question.subject?.name}/>
|
||||
<QuestionCardField label="Habilidade Cognitiva" value={bloomTaxonomy}/>
|
||||
<QuestionCardField label="Tipo" value={checkType}/>
|
||||
<QuestionCardField label="Autoria" value={question.authorship} />
|
||||
<QuestionCardField label="Ano" value={question.authorshipYear}/>
|
||||
<div className="col-span-2">
|
||||
<span className="text-gray-700">Enunciado:</span>
|
||||
<div>
|
||||
ijodsjidsoifidfsiojsdfiojdsfiodfs ijdf iodsf iosd iojdf sijodsf iojdsf ioj sdfiojdf sioj dfsiojsdf iojdfs ijodsfijoidfsijodfsijdfsijo dsiofd ijosdfjiofdsidsfio
|
||||
</div>
|
||||
<div dangerouslySetInnerHTML={{__html: question.body ?? ''}}></div>
|
||||
</div>
|
||||
</div>}
|
||||
<div className="mt-6">
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
import React, { FC } from "react";
|
||||
import { Maybe } from "../../../__generated__/graphql-schema";
|
||||
|
||||
interface Props {
|
||||
label: string,
|
||||
value?: Maybe<string>
|
||||
}
|
||||
|
||||
export const QuestionCardField: FC<Props> = ({ label, value }) => {
|
||||
return (
|
||||
<div>
|
||||
<span className="text-gray-700">{`${label}: `}</span>
|
||||
<span>{value ?? ''}</span>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
import React, { FC, } from "react";
|
||||
|
||||
type Props = {
|
||||
options: {id: number, label: string,}[]
|
||||
options: {id: number | string, label: string,}[]
|
||||
label: string
|
||||
}
|
||||
|
||||
|
||||
@@ -1,24 +1,35 @@
|
||||
import React, { FC, } from "react";
|
||||
import { SideBar } from "./SideBar";
|
||||
import { SelectedQuestionCard } from "./SelectedQuestionCard";
|
||||
import { Button } from "../../../components";
|
||||
|
||||
type Props = {
|
||||
questions: {
|
||||
id: string, label: string, removeHandler: Function
|
||||
}[]
|
||||
onClearSelectedQuestions: Function
|
||||
}
|
||||
|
||||
export const SelectedQuestionsSideBar: FC<Props> = ({ questions }) => {
|
||||
export const SelectedQuestionsSideBar: FC<Props> = ({ questions, onClearSelectedQuestions }) => {
|
||||
return (
|
||||
<SideBar header="Questões Selecionadas">
|
||||
<div>
|
||||
{questions.length ?
|
||||
questions.map(q => <SelectedQuestionCard
|
||||
key={q.id} id={q.id} label={q.label}
|
||||
onRemoveQuestion={q.removeHandler}/>) :
|
||||
<h2 className="text-gray-700 mt-3">
|
||||
Nenhuma questão selecionada
|
||||
</h2>
|
||||
<>
|
||||
<div>
|
||||
{questions.map(q => <SelectedQuestionCard
|
||||
key={q.id} id={q.id} label={q.label}
|
||||
onRemoveQuestion={q.removeHandler}/>)}
|
||||
</div>
|
||||
<div className="flex justify-center mt-6">
|
||||
<Button type="primary" onClick={() => onClearSelectedQuestions()}>
|
||||
Limpar Seleção
|
||||
</Button>
|
||||
</div>
|
||||
</> :
|
||||
<h2 className="text-gray-700 mt-3">
|
||||
Nenhuma questão selecionada
|
||||
</h2>
|
||||
}
|
||||
</div>
|
||||
</SideBar>
|
||||
|
||||
@@ -3,6 +3,7 @@ import { FaArrowLeft, FaArrowRight, FaAngleDown, FaAngleUp } from 'react-icons/f
|
||||
import { MdModeEdit } from 'react-icons/md';
|
||||
import { Link } from 'react-router-dom';
|
||||
import styled from 'styled-components';
|
||||
import { useLocalStorage } from 'usehooks-ts';
|
||||
|
||||
import { Question, QuestionStatus } from '../../../__generated__/graphql-schema'
|
||||
import { useCurrentUser } from '../../../contexts';
|
||||
@@ -39,7 +40,7 @@ export const QuestionsListFragments = gql`
|
||||
export const QuestionsList: FC<Props> = ({ questions, title, pagination }) => {
|
||||
const { user } = useCurrentUser()
|
||||
const [pageCount, setPageCount] = useState(1)
|
||||
const [collapsed, setCollapsed] = useState(false)
|
||||
const [collapsed, setCollapsed] = useLocalStorage<boolean>('collapsed', false)
|
||||
|
||||
const formatDate = (stringDate: string) => new Date(stringDate).toLocaleDateString()
|
||||
|
||||
|
||||
23
app/models/assessment.rb
Normal file
23
app/models/assessment.rb
Normal file
@@ -0,0 +1,23 @@
|
||||
# == Schema Information
|
||||
#
|
||||
# Table name: assessments
|
||||
#
|
||||
# id :bigint not null, primary key
|
||||
# observations :text
|
||||
# params :jsonb
|
||||
# title :string
|
||||
# created_at :datetime not null
|
||||
# updated_at :datetime not null
|
||||
# user_id :bigint not null
|
||||
#
|
||||
# Indexes
|
||||
#
|
||||
# index_assessments_on_user_id (user_id)
|
||||
#
|
||||
# Foreign Keys
|
||||
#
|
||||
# fk_rails_... (user_id => users.id)
|
||||
#
|
||||
class Assessment < ApplicationRecord
|
||||
belongs_to :user
|
||||
end
|
||||
13
app/policies/assessment_policy.rb
Normal file
13
app/policies/assessment_policy.rb
Normal file
@@ -0,0 +1,13 @@
|
||||
class AssessmentPolicy < ApplicationPolicy
|
||||
class Scope < Scope
|
||||
def resolve
|
||||
scope.all
|
||||
end
|
||||
|
||||
def index?
|
||||
@roles.find do |role|
|
||||
admin nde coordinator center_director pro_rector teacher
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
12
db/migrate/20230705145916_create_assessments.rb
Normal file
12
db/migrate/20230705145916_create_assessments.rb
Normal file
@@ -0,0 +1,12 @@
|
||||
class CreateAssessments < ActiveRecord::Migration[7.0]
|
||||
def change
|
||||
create_table :assessments do |t|
|
||||
t.string :title
|
||||
t.text :observations
|
||||
t.jsonb :params
|
||||
t.references :user, null: false, foreign_key: true
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
end
|
||||
13
db/schema.rb
generated
13
db/schema.rb
generated
@@ -10,7 +10,7 @@
|
||||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema[7.0].define(version: 2022_08_05_233401) do
|
||||
ActiveRecord::Schema[7.0].define(version: 2023_07_05_145916) do
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "plpgsql"
|
||||
|
||||
@@ -56,6 +56,16 @@ ActiveRecord::Schema[7.0].define(version: 2022_08_05_233401) do
|
||||
t.index ["blob_id", "variation_digest"], name: "index_active_storage_variant_records_uniqueness", unique: true
|
||||
end
|
||||
|
||||
create_table "assessments", force: :cascade do |t|
|
||||
t.string "title"
|
||||
t.text "observations"
|
||||
t.jsonb "params"
|
||||
t.bigint "user_id", null: false
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.index ["user_id"], name: "index_assessments_on_user_id"
|
||||
end
|
||||
|
||||
create_table "axes", force: :cascade do |t|
|
||||
t.string "name"
|
||||
t.datetime "created_at", null: false
|
||||
@@ -155,6 +165,7 @@ ActiveRecord::Schema[7.0].define(version: 2022_08_05_233401) do
|
||||
|
||||
add_foreign_key "active_storage_attachments", "active_storage_blobs", column: "blob_id"
|
||||
add_foreign_key "active_storage_variant_records", "active_storage_blobs", column: "blob_id"
|
||||
add_foreign_key "assessments", "users"
|
||||
add_foreign_key "questions", "subjects"
|
||||
add_foreign_key "questions", "users"
|
||||
add_foreign_key "review_messages", "questions"
|
||||
|
||||
@@ -38,6 +38,7 @@
|
||||
"postcss": "^7.0.32",
|
||||
"postcss-cli": "^7.1.1",
|
||||
"postcss-import": "^12.0.1",
|
||||
"tailwindcss": "^1.5.1"
|
||||
"tailwindcss": "^1.5.1",
|
||||
"usehooks-ts": "2.6.0"
|
||||
}
|
||||
}
|
||||
|
||||
28
spec/factories/assessments.rb
Normal file
28
spec/factories/assessments.rb
Normal file
@@ -0,0 +1,28 @@
|
||||
# == Schema Information
|
||||
#
|
||||
# Table name: assessments
|
||||
#
|
||||
# id :bigint not null, primary key
|
||||
# observations :text
|
||||
# params :jsonb
|
||||
# title :string
|
||||
# created_at :datetime not null
|
||||
# updated_at :datetime not null
|
||||
# user_id :bigint not null
|
||||
#
|
||||
# Indexes
|
||||
#
|
||||
# index_assessments_on_user_id (user_id)
|
||||
#
|
||||
# Foreign Keys
|
||||
#
|
||||
# fk_rails_... (user_id => users.id)
|
||||
#
|
||||
FactoryBot.define do
|
||||
factory :assessment do
|
||||
title { "MyString" }
|
||||
observations { "MyText" }
|
||||
params { "" }
|
||||
user { nil }
|
||||
end
|
||||
end
|
||||
25
spec/models/assessment_spec.rb
Normal file
25
spec/models/assessment_spec.rb
Normal file
@@ -0,0 +1,25 @@
|
||||
# == Schema Information
|
||||
#
|
||||
# Table name: assessments
|
||||
#
|
||||
# id :bigint not null, primary key
|
||||
# observations :text
|
||||
# params :jsonb
|
||||
# title :string
|
||||
# created_at :datetime not null
|
||||
# updated_at :datetime not null
|
||||
# user_id :bigint not null
|
||||
#
|
||||
# Indexes
|
||||
#
|
||||
# index_assessments_on_user_id (user_id)
|
||||
#
|
||||
# Foreign Keys
|
||||
#
|
||||
# fk_rails_... (user_id => users.id)
|
||||
#
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe Assessment, type: :model do
|
||||
pending "add some examples to (or delete) #{__FILE__}"
|
||||
end
|
||||
Reference in New Issue
Block a user