Artemis
Artemis copied to clipboard
`Quiz exercises`: Quizzes with short answer questions always have 'unsaved changes' when editing
Describe the bug
When working on #9139, I noticed that the quiz edit view was always reporting unsaved changes, even when I didn't change anything in the editor. I was then able to reproduce this behavior on a test server without my changes.
Expected behavior: We should only show 'Unsaved changes' if that is actually the case.
To Reproduce
Prerequisites:
- 1 Instructor
- 1 Quiz with a short answer question
- Log in to Artemis
- Navigate to course management > your course > exercises and edit the quiz
- Look at the footer - it says 'Unsaved changes'
- Save the quiz - it still says 'Unsaved changes'
- Click "Cancel" - it will prompt you about whether you want to leave.
Expected behavior
- Initially, there should be no unsaved changes & no prompt when hitting cancel
- "Unsaved changes" should appear once the user changes something in the short answer question
- After saving, there should be no "Unsaved changes" indicator
Screenshots
Which version of Artemis are you seeing the problem on?
7.4.4
What browsers are you seeing the problem on?
Chrome
Additional context
The component checks equality via
pendingChanges(): boolean {
if (!this.quizExercise || !this.savedEntity) {
return false;
}
return JSON.stringify(this.quizExercise) !== JSON.stringify(this.savedEntity);
}
This means that any change, even if it does not affect the question, will trigger "Unsaved changes." In my case, this is due to differences in the correctMappings
and the solutions
field of the question:
From the edit view (correctMappings)
{
"invalid": false,
"solution": {
"id": 80,
"invalid": false,
"tempID": 7205749361591625,
"text": "Answer"
},
"spot": {
"id": 60,
"invalid": false,
"spotNr": 5,
"tempID": 7650125091158383,
"width": 15
}
}
From savedEntity (correctMappings)
{
"id": 213,
"invalid": false,
"shortAnswerSolutionIndex": 8,
"shortAnswerSpotIndex": 0,
"solution": {
"id": 80,
"invalid": false,
"text": "Answer"
},
"spot": {
"id": 60,
"invalid": false,
"spotNr": 5,
"width": 15
}
}
From the edit view (solutions)
{
"id": 72,
"invalid": false,
"tempID": 6291884753887507,
"text": "is"
},
From savedEntity (solutions)
"solutions": [
{
"id": 72,
"invalid": false,
"text": "is"
},
Relevant log output
No response