maths / moodle-qtype_stack

Stack question type for Moodle
GNU General Public License v3.0
141 stars 150 forks source link

Bug when removing an input or PRT from a quiz #1102

Closed dmca-glasgow closed 7 months ago

dmca-glasgow commented 8 months ago

Versions

Moodle 4.1.6+ (Build: 20231110) Maxima 5.41.0 STACK 4.4.4 for Moodle 3.9+ (2023060500)

Issue

When removing an input or PRT from a quiz, the input or PRT remain in the XML export and impacts marking unless "Save Changes" is pressed twice.

Steps to reproduce

Create a STACK question with multiple inputs and potential response trees

The question text

[[input:ans1]][[validation:ans1]][[feedback:prt1]]

[[input:ans2]][[validation:ans2]][[feedback:prt2]]

Input: ans1

Input type: Algebraic input Model answer: 3 (random allowed input)

Input: ans2

Input type: Algebraic input Model answer: 4 (random allowed input)

Potential response tree: prt1

Question value: 1 Node 1 answer text: AlgEquiv Node 1 SAns: ans1 TAns: 3

Potential response tree: prt2

Question value: 1 Node 1 answer text: AlgEquiv Node 1 SAns: ans2 TAns: 4

Preview the question

Select 'Preview'

Then click 'Fill in correct responses'.

Verify the question has received full marks.

Edit the question and remove one of the inputs and potential response trees

The new question text

[[input:ans1]][[validation:ans1]][[feedback:prt1]]

Save changes

Click the checkbox saying "I confirm that I want to remove this input from this question."

Click the checkbox saying "I confirm that I want to remove this potential response tree from this question."

Then click 'Save changes'.

Preview the question

Select 'Preview'

Then click 'Fill in correct responses'

The question is incorrectly marked as 50% of Default mark

Then from the 'Edit' dropdown select 'Export as Moodle XML'.

When viewing the XML, you will see that the <testinput> for ans2, and the <prt> for prt2 are still there.

Workaround

Edit the question again and immediately click 'Save Changes'.

Select 'Preview' again, then click 'Fill in correct responses'

The question is now correctly marked as 100% of Default mark

A quick check of the XML shows that PRT and ans are now correctly omitted.

LukeLongworth commented 8 months ago

At a glance this looks similar to/the same as #1006 which I think has been patched by 4.4.6 (or at least I see fit to close it after we upgraded). I can have a closer look later if that seems to not be the case

sangwinc commented 7 months ago

Thanks for commenting @LukeLongworth, much appreciated. Yes, I think this is already fixed in the latest version.