add score

This commit is contained in:
Firesieht 2022-08-27 17:41:59 +03:00
parent 0a3bf71358
commit b29590beb9
10 changed files with 135 additions and 47 deletions

View File

@ -56,7 +56,6 @@
font-size: 14px; font-size: 14px;
line-height: 22px; line-height: 22px;
color: rgba(0, 0, 0, 0.45); color: rgba(0, 0, 0, 0.45);
} }
.paragraphs{ .paragraphs{
@ -74,4 +73,16 @@
.correct{ .correct{
width: 110px; width: 110px;
}
.circle{
border-radius: 50%;
height: 16px;
width: 16px;
}
.num{
display: flex;
gap:5px;
align-items: center;
} }

View File

@ -14,8 +14,6 @@ interface ErrorViewerIE{
export const ErrorViewer : React.FC<ErrorViewerIE> = (props) =>{ export const ErrorViewer : React.FC<ErrorViewerIE> = (props) =>{
const [open, setOpen] = useState(false) const [open, setOpen] = useState(false)
console.log(props.paragraph)
return( return(
<div className={styles.viewer}> <div className={styles.viewer}>
<div className={styles.card}> <div className={styles.card}>
@ -41,7 +39,7 @@ export const ErrorViewer : React.FC<ErrorViewerIE> = (props) =>{
{ {
props.paragraph.map( props.paragraph.map(
(value, index)=><div className={styles.paragraph}> (value, index)=><div className={styles.paragraph}>
<div><strong>{index+1}</strong></div> <div className={styles.num}><strong>{index+1}</strong> <div className={styles.circle} style={{opacity:"0.5",background: Number(value[1])<50? "#F5222D": Number(value[1]) < 70? "#E3F32A":"#52C41A", display:props.correct? "":"none"}}></div></div>
<div className={styles.paragraph}>{value[0]}</div> <div className={styles.paragraph}>{value[0]}</div>
<div><strong>Score:{value[1]}</strong></div> <div><strong>Score:{value[1]}</strong></div>
</div> </div>

View File

@ -20,7 +20,6 @@ export const FileUploader:React.FC<FileUploaderIE> = (data) =>{
onChange(info:any) { onChange(info:any) {
if (info.file.status !== 'uploading') { if (info.file.status !== 'uploading') {
console.log(info.file, info.fileList);
} }
if (info.file.status === 'done') { if (info.file.status === 'done') {

View File

@ -1,4 +1,4 @@
import React from "react"; import React, { useState } from "react";
import styles from "./itemSelect.module.css" import styles from "./itemSelect.module.css"
export interface SelectItemIE{ export interface SelectItemIE{
@ -13,46 +13,30 @@ interface SelectIE{
} }
export const ItemSelect: React.FC<SelectIE> = (props) =>{ export const ItemSelect: React.FC<SelectIE> = (props) =>{
const [selected, setSelected] = useState(props.items[0])
const [open, setOpen] = useState(false)
let options = new Array() let options = new Array()
props.items.map((item:SelectItemIE)=>{ props.items.map((item:SelectItemIE)=>{
options.push( options.push(
<option>{item.name}</option> <div className={selected.name == item.name? styles.selected:styles.option} onClick={()=>onItemChange(item)}>{item.name}</div>
) )
}) })
const onItemChange = (item:SelectItemIE) =>{
const getValue = (name:string) =>{ setSelected(item)
let val; props.onChange(item.value)
props.items.map((item:SelectItemIE) => {
if (item.name == name){
val = item.value
}
})
return val
} }
const getName = (value:number) =>{
let name;
props.items.map((item:SelectItemIE) => {
if (item.value == value){
name = item.name
}
})
return name
}
return( return(
<div> <div >
{ <div className={styles.myselect}>
props.value == undefined? <div className={styles.head} onClick={()=>setOpen(!open)}>Выберите документ <img style={{transform: open? "rotate(180deg)":""}} src="/images/arrow.svg"></img></div>
<select className={styles.myselect} onChange={(e)=>props.onChange(getValue(e.target.value) as any)}> {
open? <div className={styles.options}>
{options} {options}
</select> </div>: ""
: }
<select value={getName(props.value)} className={styles.myselect} onChange={(e)=>props.onChange(getValue(e.target.value) as any)}> </div>
{options}
</select>
}
</div> </div>
) )
} }

View File

@ -1,25 +1,61 @@
.myselect{ .myselect{
border: none; border: none;
width: 240px;
font-size: 14px; font-size: 14px;
color: #1C85BF; color: #1890FF;
font-weight: 500; font-weight: 500;
outline: none; outline: none;
width: inherit; width: inherit;
} }
.head{
display: flex;
flex-direction: row;
justify-content: space-between;
padding: 10px;
cursor: pointer;
width: 240px ;
}
.options{
display: flex;
flex-direction: column;
gap:8px
}
.option{
display: flex;
align-items: center;
padding: 10px;
justify-content: right;
color: #0E1A33;
background: #F4F7FD;
width: 100%;
cursor: pointer;
}
.selected{
width: 100%;
display: flex;
align-items: center;
padding: 10px;
justify-content: right;
color: #1890FF;
background: #E6F7FF;
box-shadow: inset -3px 0px 0px #1890FF;
border-right: solid 3px #1890FF;
cursor: pointer;
}
@media screen and (max-width: 1300px) { @media screen and (max-width: 1300px) {
.myselect{ .myselect{
font-size: 18px; font-size: 12px;
} }
} }
@media screen and (max-width: 900px) { @media screen and (max-width: 900px) {
.myselect{ .myselect{
font-size: 14px; font-size: 12px;
} }
} }
@media screen and (max-width: 500px) { @media screen and (max-width: 500px) {
.myselect{ .myselect{
font-size: 12px; font-size: 10px;
} }
} }

View File

@ -16,6 +16,7 @@
.logo{ .logo{
cursor: pointer; cursor: pointer;
user-select: none;
} }
.itemWrapper{ .itemWrapper{
display: flex; display: flex;

38
pages/404.tsx Normal file
View File

@ -0,0 +1,38 @@
import type { NextPage } from 'next'
import { Header } from '../Components/header'
import styles from '../styles/Home.module.css'
import 'antd/dist/antd.css';
import { useState } from 'react'
import { host } from './api/consts'
import { PulseLoader } from 'react-spinners'
import axios from 'axios'
import { useRouter } from 'next/router'
import Head from 'next/head';
const History: NextPage = () => {
let router = useRouter()
return (
<div className={styles.container}>
<Head>
<title>Загрузите файл</title>
<meta name="description" content="Generated by create next app" />
<link rel="icon" href="/favicon.ico" />
</Head>
<main className={styles.main}>
<Header></Header>
<div className={styles.upload}>
<div style={{fontSize:"44px"}}>404 страница не найдена</div>
<div className={styles.btn} onClick={()=>router.push("/")}>Главная</div>
</div>
</main>
</div>
)
}
export default History

View File

@ -1 +1 @@
export const host = "http://192.168.9.152:8000" export const host = "http://192.168.9.201:8000"

View File

@ -11,27 +11,33 @@ import { get } from './api/fetch'
import { host } from './api/consts' import { host } from './api/consts'
import { PulseLoader } from 'react-spinners' import { PulseLoader } from 'react-spinners'
import axios from 'axios' import axios from 'axios'
import { Checkbox } from 'antd'
const Home: NextPage = () => { const Home: NextPage = () => {
const [correct, setCorrect] = useState(true)
const [err, setErr] = useState(true)
const [sort, setSort] = useState("alphabet")
let files = JSON.parse(localStorage.getItem("files") as string) let files = JSON.parse(localStorage.getItem("files") as string)
const [file, setFile] = useState(files[0].uuid) const [file, setFile] = useState(files[0])
const [data,setData] = useState("") const [data,setData] = useState("")
let i = 1; let i = 1;
let cards = new Array<JSX.Element>() let cards = new Array<JSX.Element>()
const getData = () =>{ const getData = () =>{
if (data == ""){ if (data == ""){
axios.get(host+"/api/site/docx/" + file).then(res => { axios.get(host+"/api/site/docx/" + file.uuid).then(res => {
setData(res.data) setData(res.data)
}) })
} }
} }
const onFileChange = (newFile:any) =>{ const onFileChange = (newFile:any) =>{
setData("") setData("")
axios.get(host+"/api/site/docx/" + newFile).then(res => { axios.get(host+"/api/site/docx/" + newFile.uuid).then(res => {
setData(res.data) setData(res.data)
}) })
setFile(newFile) setFile(newFile)
@ -40,6 +46,8 @@ const Home: NextPage = () => {
setTimeout(getData, 2000); setTimeout(getData, 2000);
if (data != ""){ if (data != ""){
for(var name in data as any) { for(var name in data as any) {
if (correct == false && (data as any)[name][0]!=undefined){continue}
if (err == false && (data as any)[name][0]==undefined){continue}
cards.push( cards.push(
<ErrorViewer <ErrorViewer
num={i} num={i}
@ -49,7 +57,7 @@ const Home: NextPage = () => {
></ErrorViewer> ></ErrorViewer>
) )
i++ i++
} }
} }
let select = new Array<SelectItemIE>() let select = new Array<SelectItemIE>()
@ -57,7 +65,7 @@ const Home: NextPage = () => {
select.push( select.push(
{ {
name: value.file.slice(48, value.uuid.lenght), name: value.file.slice(48, value.uuid.lenght),
value: value.uuid value: value
} as SelectItemIE } as SelectItemIE
) )
}); });
@ -79,6 +87,11 @@ const Home: NextPage = () => {
></ItemSelect> ></ItemSelect>
</div> </div>
<div className={styles.pagination}> <div className={styles.pagination}>
<div className={styles.tools}>
<div><a href={file.file}>Скачать файл</a></div>
<Checkbox checked={err} onChange={()=>setErr(!err)}>Есть замечания</Checkbox>
<Checkbox checked={correct} onChange={()=>setCorrect(!correct)}>Без замечаний </Checkbox>
</div>
{data == ""? <PulseLoader color={"#13377D"}></PulseLoader>:cards} {data == ""? <PulseLoader color={"#13377D"}></PulseLoader>:cards}
</div> </div>
</main> </main>

View File

@ -69,4 +69,12 @@
text-align: center; text-align: center;
color: #13377D; color: #13377D;
cursor: pointer; cursor: pointer;
}
.tools{
display: flex;
flex-direction: row;
gap:25px;
justify-content: left;
} }