fix: remove stale value check from OrderQuestion initial; guard wrong class in Match

This commit is contained in:
LaurensBartelds committed 2026-04-21 21:45:31 +02:00
1 parent e48e37ad87
commit 535bdb5a50
7 files changed
+42 -3

No files matched your search

+10
View File
@@ -0,0 +1,10 @@
# Default ignored files
/shelf/
/workspace.xml
# Ignored default folder with query files
/queries/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml
# Editor-based HTTP Client requests
/httpRequests/
+9
View File
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
+6
View File
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" project-jdk-name="jbr-25" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
</project>
+8
View File
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/brainwave.iml" filepath="$PROJECT_DIR$/.idea/brainwave.iml" />
</modules>
</component>
</project>
Generated
+7
View File
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="Git" />
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>
+1 -1
View File
@@ -57,7 +57,7 @@ export default function Match({ q, value, onChange, locked, graded }: Props) {
else if (current[item.id]) cls += ' paired' else if (current[item.id]) cls += ' paired'
if (graded) { if (graded) {
if (answer[item.id] && current[item.id] === answer[item.id]) cls += ' correct' if (answer[item.id] && current[item.id] === answer[item.id]) cls += ' correct'
else if (current[item.id]) cls += ' wrong' else if (current[item.id] && answer[item.id]) cls += ' wrong'
} }
const pairedRightIdx = current[item.id] const pairedRightIdx = current[item.id]
? (q.right ?? []).findIndex((x) => x.id === current[item.id]) ? (q.right ?? []).findIndex((x) => x.id === current[item.id])
@@ -14,7 +14,6 @@ export default function OrderQuestion({ q, value, onChange, locked, graded }: Pr
const items = q.items ?? [] const items = q.items ?? []
const initial = useMemo(() => { const initial = useMemo(() => {
if (Array.isArray(value) && value.length === items.length) return value
const ids = items.map((i) => i.id) const ids = items.map((i) => i.id)
const seed = q.id.split('').reduce((a, c) => a + c.charCodeAt(0), 0) const seed = q.id.split('').reduce((a, c) => a + c.charCodeAt(0), 0)
const out = [...ids] const out = [...ids]
@@ -58,7 +57,7 @@ export default function OrderQuestion({ q, value, onChange, locked, graded }: Pr
className={cls} className={cls}
draggable={!locked} draggable={!locked}
onDragStart={(e) => { setDragIdx(idx); e.dataTransfer.effectAllowed = 'move' }} onDragStart={(e) => { setDragIdx(idx); e.dataTransfer.effectAllowed = 'move' }}
onDragOver={(e) => { e.preventDefault(); setOverIdx(idx) }} onDragOver={(e) => { e.preventDefault(); if (dragIdx !== idx) setOverIdx(idx) }}
onDrop={(e) => { onDrop={(e) => {
e.preventDefault() e.preventDefault()
if (dragIdx != null && dragIdx !== idx) move(dragIdx, idx) if (dragIdx != null && dragIdx !== idx) move(dragIdx, idx)