fix: test case table issue in programming exercise form
This commit is contained in:
@@ -25,7 +25,7 @@
|
|||||||
:required="true"
|
:required="true"
|
||||||
/>
|
/>
|
||||||
<ChildTable
|
<ChildTable
|
||||||
v-model="exercise.test_cases"
|
v-model="testCases.data"
|
||||||
:label="__('Test Cases')"
|
:label="__('Test Cases')"
|
||||||
:columns="testCaseColumns"
|
:columns="testCaseColumns"
|
||||||
:required="true"
|
:required="true"
|
||||||
@@ -179,9 +179,7 @@ const testCases = createListResource({
|
|||||||
fields: ['input', 'expected_output', 'name'],
|
fields: ['input', 'expected_output', 'name'],
|
||||||
cache: ['testCases', props.exerciseID],
|
cache: ['testCases', props.exerciseID],
|
||||||
parent: 'LMS Programming Exercise',
|
parent: 'LMS Programming Exercise',
|
||||||
onSuccess(data: TestCase[]) {
|
orderBy: 'idx',
|
||||||
exercise.value.test_cases = data
|
|
||||||
},
|
|
||||||
})
|
})
|
||||||
|
|
||||||
const fetchTestCases = () => {
|
const fetchTestCases = () => {
|
||||||
@@ -200,6 +198,13 @@ const validateTitle = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const saveExercise = (close: () => void) => {
|
const saveExercise = (close: () => void) => {
|
||||||
|
exercise.value.test_cases = testCases.data.map(
|
||||||
|
(tc: TestCase, index: number) => ({
|
||||||
|
input: tc.input,
|
||||||
|
expected_output: tc.expected_output,
|
||||||
|
idx: index + 1,
|
||||||
|
})
|
||||||
|
)
|
||||||
validateTitle()
|
validateTitle()
|
||||||
if (props.exerciseID == 'new') createNewExercise(close)
|
if (props.exerciseID == 'new') createNewExercise(close)
|
||||||
else updateExercise(close)
|
else updateExercise(close)
|
||||||
|
|||||||
Reference in New Issue
Block a user