added new style to ask 1
This commit is contained in:
@@ -1,242 +1,129 @@
|
||||
"use client";
|
||||
import "./pregunta1.module.scss"
|
||||
import React, { useState } from "react";
|
||||
import "./pregunta1.1.css";
|
||||
|
||||
export default function Pregunta1() {
|
||||
const [datos, setDatos] = useState([
|
||||
{ nombre: "Windows", valores: ["", "", "", "", ""] },
|
||||
{ nombre: "Linux", valores: ["", "", "", "", ""] },
|
||||
{ nombre: "Mac OS", valores: ["", "", "", "", ""] },
|
||||
{ nombre: "Total", valores: ["", "", "", "", ""] },
|
||||
]);
|
||||
|
||||
const handleChange = (filaIndex: number, colIndex: number, value: string) => {
|
||||
const nuevosDatos = [...datos];
|
||||
nuevosDatos[filaIndex].valores[colIndex] = value;
|
||||
setDatos(nuevosDatos);
|
||||
};
|
||||
|
||||
const calcularTotalFila = (valores: string[]) =>
|
||||
valores.reduce((acc, val) => acc + (Number(val) || 0), 0);
|
||||
|
||||
const calcularTotalesColumnas = () => {
|
||||
const numColumnas = datos[0].valores.length;
|
||||
const totales = Array(numColumnas).fill(0);
|
||||
datos.slice(0, -1).forEach((fila) => {
|
||||
fila.valores.forEach((valor, colIndex) => {
|
||||
totales[colIndex] += Number(valor) || 0;
|
||||
});
|
||||
});
|
||||
return totales;
|
||||
};
|
||||
|
||||
const totalesColumnas = calcularTotalesColumnas();
|
||||
|
||||
// Títulos de las tablas
|
||||
const tablas = [
|
||||
"Computadoras de escritorio",
|
||||
"Tabletas",
|
||||
"Computadoras portátiles",
|
||||
"Alto rendimiento",
|
||||
];
|
||||
|
||||
// Función para renderizar una tabla
|
||||
const renderTabla = (titulo: string) => (
|
||||
<div className="tabla-contenedor">
|
||||
<table className="tabla">
|
||||
<thead>
|
||||
<tr>
|
||||
<th className="azul-marino">{titulo}</th>
|
||||
<th className="rosa-fuerte">Alumnos</th>
|
||||
<th className="rosa-fuerte">Profesores</th>
|
||||
<th className="rosa-fuerte">Técnicos Académicos</th>
|
||||
<th className="rosa-fuerte">Investigadores</th>
|
||||
<th className="rosa-fuerte">Administrativos</th>
|
||||
<th className="azul-marino">Total</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{datos.map((fila, filaIndex) => {
|
||||
if (fila.nombre === "Total") {
|
||||
const totalGeneral = calcularTotalFila(
|
||||
totalesColumnas.map(String)
|
||||
);
|
||||
return (
|
||||
<tr key={filaIndex} className="fila-total">
|
||||
<td className="negrita">{fila.nombre}</td>
|
||||
{totalesColumnas.map((colTotal, i) => (
|
||||
<td key={i}>{colTotal}</td>
|
||||
))}
|
||||
<td className="negrita">{totalGeneral}</td>
|
||||
</tr>
|
||||
);
|
||||
}
|
||||
|
||||
const totalFila = calcularTotalFila(fila.valores);
|
||||
return (
|
||||
<tr key={filaIndex}>
|
||||
<td>{fila.nombre}</td>
|
||||
{fila.valores.map((valor, colIndex) => (
|
||||
<td key={colIndex}>
|
||||
<div className="input-contenedor">
|
||||
<input
|
||||
type="number"
|
||||
value={valor}
|
||||
onChange={(e) =>
|
||||
handleChange(filaIndex, colIndex, e.target.value)
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
</td>
|
||||
))}
|
||||
<td
|
||||
className={`total-celda ${
|
||||
totalFila > 100 ? "total-error" : ""
|
||||
}`}
|
||||
>
|
||||
{totalFila}
|
||||
</td>
|
||||
</tr>
|
||||
);
|
||||
})}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
);
|
||||
|
||||
export default function Pregunta1_1() {
|
||||
return (
|
||||
<section>
|
||||
<div>
|
||||
<h1>Censo Equipos de computo</h1>
|
||||
<p className="instructions">
|
||||
Desglosa en cada renglon el número de equipos de cómputo dedicado por
|
||||
cada categoría enlistada, de acuerdo con el perfil del usuario al que
|
||||
se destina su uso primordialmente.
|
||||
</p>
|
||||
<div className="contenedor-pregunta">
|
||||
<div className="contenedor-censo">Censo de equipos de cómputo</div>
|
||||
|
||||
<div className="container">
|
||||
|
||||
{/* ===================== */}
|
||||
{/* 1. COMPUTADORAS DE ESCRITORIO */}
|
||||
{/* ===================== */}
|
||||
<div className="table-container">
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Computadoras de escritorio</th>
|
||||
<th>Alumnos</th>
|
||||
<th>Profesores</th>
|
||||
<th>Tecnicos Academicos</th>
|
||||
<th>Investigadores</th>
|
||||
<th>Administrativos</th>
|
||||
<th>Total</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
|
||||
{/* Windows */}
|
||||
<tr>
|
||||
<th>Windows</th>
|
||||
<td><input type="number" className="numero" /></td>
|
||||
<td><input type="number" className="numero" /></td>
|
||||
<td><input type="number" className="numero" /></td>
|
||||
<td><input type="number" className="numero" /></td>
|
||||
<td><input type="number" className="numero" /></td>
|
||||
<th>10</th>
|
||||
</tr>
|
||||
|
||||
{/* Linux */}
|
||||
<tr>
|
||||
<th>Linux</th>
|
||||
<td><input type="number" className="numero" /></td>
|
||||
<td><input type="number" className="numero" /></td>
|
||||
<td><input type="number" className="numero" /></td>
|
||||
<td><input type="number" className="numero" /></td>
|
||||
<td><input type="number" className="numero" /></td>
|
||||
<th>10</th>
|
||||
</tr>
|
||||
|
||||
{/* Mac OS */}
|
||||
<tr>
|
||||
<th>Mac OS</th>
|
||||
<td><input type="number" className="numero" /></td>
|
||||
<td><input type="number" className="numero" /></td>
|
||||
<td><input type="number" className="numero" /></td>
|
||||
<td><input type="number" className="numero" /></td>
|
||||
<td><input type="number" className="numero" /></td>
|
||||
<th>10</th>
|
||||
</tr>
|
||||
|
||||
{/* Totales */}
|
||||
<tr>
|
||||
<th>Total</th>
|
||||
<th>10</th>
|
||||
<th>10</th>
|
||||
<th>10</th>
|
||||
<th>10</th>
|
||||
<th>10</th>
|
||||
<th>10</th>
|
||||
</tr>
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
{/* ===================== */}
|
||||
{/* 2. COMPUTADORAS PORTÁTILES */}
|
||||
{/* ===================== */}
|
||||
<div className="table-container">
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Computadoras portátiles</th>
|
||||
<th>Alumnos</th>
|
||||
<th>Profesores</th>
|
||||
<th>Tecnicos Academicos</th>
|
||||
<th>Investigadores</th>
|
||||
<th>Administrativos</th>
|
||||
<th>Total</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
|
||||
{/* Windows */}
|
||||
<tr>
|
||||
<th>Windows</th>
|
||||
<td><input type="number" className="numero" /></td>
|
||||
<td><input type="number" className="numero" /></td>
|
||||
<td><input type="number" className="numero" /></td>
|
||||
<td><input type="number" className="numero" /></td>
|
||||
<td><input type="number" className="numero" /></td>
|
||||
<th>10</th>
|
||||
</tr>
|
||||
|
||||
{/* Chromebook */}
|
||||
<tr>
|
||||
<th>Chromebook</th>
|
||||
<td><input type="number" className="numero" /></td>
|
||||
<td><input type="number" className="numero" /></td>
|
||||
<td><input type="number" className="numero" /></td>
|
||||
<td><input type="number" className="numero" /></td>
|
||||
<td><input type="number" className="numero" /></td>
|
||||
<th>10</th>
|
||||
</tr>
|
||||
|
||||
{/* Mac OS */}
|
||||
<tr>
|
||||
<th>Mac OS</th>
|
||||
<td><input type="number" className="numero" /></td>
|
||||
<td><input type="number" className="numero" /></td>
|
||||
<td><input type="number" className="numero" /></td>
|
||||
<td><input type="number" className="numero" /></td>
|
||||
<td><input type="number" className="numero" /></td>
|
||||
<th>10</th>
|
||||
</tr>
|
||||
|
||||
{/* Totales */}
|
||||
<tr>
|
||||
<th>Total</th>
|
||||
<th>10</th><th>10</th><th>10</th><th>10</th><th>10</th>
|
||||
<th>10</th>
|
||||
</tr>
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
{/* ===================== */}
|
||||
{/* 3. TABLETAS */}
|
||||
{/* ===================== */}
|
||||
<div className="table-container">
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Tabletas</th>
|
||||
<th>Alumnos</th>
|
||||
<th>Profesores</th>
|
||||
<th>Tecnicos Academicos</th>
|
||||
<th>Investigadores</th>
|
||||
<th>Administrativos</th>
|
||||
<th>Total</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
|
||||
{/* Android */}
|
||||
<tr>
|
||||
<th>Android</th>
|
||||
<td><input type="number" className="numero" /></td>
|
||||
<td><input type="number" className="numero" /></td>
|
||||
<td><input type="number" className="numero" /></td>
|
||||
<td><input type="number" className="numero" /></td>
|
||||
<td><input type="number" className="numero" /></td>
|
||||
<th>10</th>
|
||||
</tr>
|
||||
|
||||
{/* iPad IOS */}
|
||||
<tr>
|
||||
<th>iPad iOS</th>
|
||||
<td><input type="number" className="numero" /></td>
|
||||
<td><input type="number" className="numero" /></td>
|
||||
<td><input type="number" className="numero" /></td>
|
||||
<td><input type="number" className="numero" /></td>
|
||||
<td><input type="number" className="numero" /></td>
|
||||
<th>10</th>
|
||||
</tr>
|
||||
|
||||
{/* Totales */}
|
||||
<tr>
|
||||
<th>Total</th>
|
||||
<th>10</th><th>10</th><th>10</th><th>10</th><th>10</th>
|
||||
<th>10</th>
|
||||
</tr>
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
{/* ===================== */}
|
||||
{/* 4. ALTO RENDIMIENTO */}
|
||||
{/* ===================== */}
|
||||
<div className="table-container">
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Alto Rendimiento</th>
|
||||
<th>Alumnos</th>
|
||||
<th>Profesores</th>
|
||||
<th>Tecnicos Academicos</th>
|
||||
<th>Investigadores</th>
|
||||
<th>Administrativos</th>
|
||||
<th>Total</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
|
||||
<tr>
|
||||
<th>Servidores</th>
|
||||
<td><input type="number" className="numero" /></td>
|
||||
<td><input type="number" className="numero" /></td>
|
||||
<td><input type="number" className="numero" /></td>
|
||||
<td><input type="number" className="numero" /></td>
|
||||
<td><input type="number" className="numero" /></td>
|
||||
<th>10</th>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<th>Total</th>
|
||||
<th>10</th><th>10</th><th>10</th><th>10</th><th>10</th>
|
||||
<th>10</th>
|
||||
</tr>
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div className="pregunta-cuadro">
|
||||
1. Desglose en cada renglón, el número de equipos de cómputo dedicado por cada categoría
|
||||
enlistada, de acuerdo con el perfil de usuario al que se destina su uso primordialmente. *
|
||||
</div>
|
||||
</section>
|
||||
|
||||
{/* FILA SUPERIOR */}
|
||||
<div className="contenedor-tablas">
|
||||
{renderTabla(tablas[0])}
|
||||
{renderTabla(tablas[1])}
|
||||
</div>
|
||||
|
||||
{/* FILA INFERIOR */}
|
||||
<div className="contenedor-tablas">
|
||||
{renderTabla(tablas[2])}
|
||||
{renderTabla(tablas[3])}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user