-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Persist marked state and notes, results table
- Loading branch information
1 parent
b62ff89
commit f004fc2
Showing
11 changed files
with
477 additions
and
90 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import { MAX_LEVEL, State } from './usePersistence'; | ||
|
||
export default function CompetenceResult({ | ||
state, | ||
}: { | ||
state: State; | ||
}): JSX.Element { | ||
const results = state.competences.map((competence, index) => { | ||
const [score, max] = state.themes.reduce( | ||
(acc, theme) => { | ||
const [score, max] = theme.experiences.reduce( | ||
(acc, exp) => { | ||
return [ | ||
acc[0] + exp.competences[index] * exp.level, | ||
acc[1] + exp.competences[index] * MAX_LEVEL, | ||
]; | ||
}, | ||
[0, 0] | ||
); | ||
return [acc[0] + score, acc[1] + max]; | ||
}, | ||
[0, 0] | ||
); | ||
|
||
return { | ||
competence, | ||
percentage: Math.round((score / max) * 100), | ||
}; | ||
}); | ||
|
||
return ( | ||
<table className="result"> | ||
<tbody> | ||
{results.map(({ competence, percentage }) => ( | ||
<tr key={competence}> | ||
<th>{competence}</th> | ||
<td>{percentage}%</td> | ||
<td className="progress"> | ||
<div | ||
className="bar" | ||
style={{ | ||
width: `${percentage}%`, | ||
}} | ||
></div> | ||
</td> | ||
</tr> | ||
))} | ||
</tbody> | ||
</table> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { Mark, State } from './usePersistence'; | ||
|
||
interface MarkedProps { | ||
state: State; | ||
mark: Mark; | ||
} | ||
|
||
export default function Marked({ state, mark }: MarkedProps): JSX.Element { | ||
const items = state.themes | ||
.map((theme, themeIndex) => | ||
theme.experiences.map((experience, index) => { | ||
if (!experience.marked) { | ||
return null; | ||
} | ||
|
||
return ( | ||
<li key={experience.name}> | ||
<input | ||
type="checkbox" | ||
name={`check-${index}`} | ||
checked={true} | ||
onChange={() => mark(themeIndex, index, false)} | ||
/> | ||
{experience.name} | ||
</li> | ||
); | ||
}) | ||
) | ||
.flat() | ||
.filter((item) => item !== null); | ||
|
||
if (items.length === 0) { | ||
return <p>Nog geen gemarkeerde ervaringen</p>; | ||
} | ||
|
||
return <ul>{items}</ul>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import CompetenceResult from './CompetenceResult'; | ||
import Marked from './Marked'; | ||
import ThemeResult from './ThemeResult'; | ||
import { Mark, State } from './usePersistence'; | ||
|
||
interface ResultProps { | ||
state: State; | ||
mark: Mark; | ||
note: (content: string) => void; | ||
} | ||
|
||
export default function Results({ | ||
state, | ||
mark, | ||
note, | ||
}: ResultProps): JSX.Element { | ||
return ( | ||
<> | ||
<h2>Ervaring</h2> | ||
<h3>Per thema/lijn</h3> | ||
<div className="result"> | ||
<ThemeResult state={state} /> | ||
</div> | ||
<h3>Per competentiegebied</h3> | ||
<div className="result"> | ||
<CompetenceResult state={state} /> | ||
</div> | ||
<p> | ||
De score zegt iets over hoe vaak je praktijkervaring hebt opgedaan in | ||
betreffende thema/lijn en competentiegebied, niet over je niveau van | ||
competentie. | ||
</p> | ||
<hr /> | ||
<h2>Remarkeerde ervaringen</h2> | ||
<Marked state={state} mark={mark} /> | ||
<hr /> | ||
<h2>Notities</h2> | ||
<textarea | ||
value={state.notes} | ||
onChange={(event) => note(event.target.value)} | ||
/> | ||
</> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,39 @@ | ||
import ThemeSection from './ThemeSection'; | ||
import { PersistenceState } from './usePersistence'; | ||
import { Mark, Select, State } from './usePersistence'; | ||
|
||
export default function Table({ state, select }: PersistenceState): JSX.Element { | ||
interface TableProps { | ||
state: State; | ||
mark: Mark; | ||
select: Select; | ||
} | ||
|
||
export default function Table({ | ||
state, | ||
select, | ||
mark, | ||
}: TableProps): JSX.Element { | ||
return ( | ||
<table> | ||
<thead> | ||
<tr> | ||
<th colSpan={2} style={{ border: 'none' }}></th> | ||
{state.levels.map((level, levelIndex) => ( | ||
<th key={level}>{levelIndex + 1}</th> | ||
))} | ||
</tr> | ||
</thead> | ||
<tbody> | ||
{state.themes.map((theme, index) => ( | ||
<ThemeSection | ||
key={theme.name} | ||
theme={theme} | ||
index={index} | ||
levels={state.levels} | ||
select={select} | ||
/> | ||
<table className="form"> | ||
<thead> | ||
<tr> | ||
<th colSpan={2} style={{ border: 'none' }}></th> | ||
{state.levels.map((level, levelIndex) => ( | ||
<th key={level}>{levelIndex + 1}</th> | ||
))} | ||
</tbody> | ||
</table> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
{state.themes.map((theme, index) => ( | ||
<ThemeSection | ||
key={theme.name} | ||
theme={theme} | ||
index={index} | ||
levels={state.levels} | ||
select={select} | ||
mark={mark} | ||
/> | ||
))} | ||
</tbody> | ||
</table> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import { MAX_LEVEL, State } from './usePersistence'; | ||
|
||
export default function ThemeResult({ state }: { state: State }): JSX.Element { | ||
let totalScore = 0; | ||
let totalMax = 0; | ||
|
||
const results = state.themes.map((theme) => { | ||
const max = theme.experiences.length * MAX_LEVEL; | ||
const score = theme.experiences.reduce((acc, exp) => acc + exp.level, 0); | ||
|
||
totalScore += score; | ||
totalMax += max; | ||
|
||
return { | ||
theme: theme.name, | ||
color: theme.color, | ||
percentage: Math.round((score / max) * 100), | ||
}; | ||
}); | ||
|
||
const totalPercentage = Math.round((totalScore / totalMax) * 100); | ||
|
||
return ( | ||
<table className="result"> | ||
<tbody> | ||
{results.map(({ theme, color, percentage }) => ( | ||
<tr key={theme}> | ||
<th>{theme}</th> | ||
<td>{percentage}%</td> | ||
<td className="progress"> | ||
<div | ||
className="bar" | ||
style={{ | ||
backgroundColor: color, | ||
width: `${percentage}%`, | ||
}} | ||
></div> | ||
</td> | ||
</tr> | ||
))} | ||
<tr> | ||
<th>Totaal</th> | ||
<td>{totalPercentage}%</td> | ||
<td className="progress"> | ||
<div | ||
className="bar" | ||
style={{ | ||
width: `${totalPercentage}%`, | ||
}} | ||
></div> | ||
</td> | ||
</tr> | ||
</tbody> | ||
</table> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.