don't clobber new quizzes submissions in SG
fixes EVAL-2055 flag=none Test plan: - Have a course with at least one student and a Quizzes.Next quiz with multiple attempts enabled - As a student, make multiple attempts on the quiz that result in distinct scores - As a teacher, open SpeedGrader and change the grade for the latter attempt (for example, by adjusting fudge points) - Check that switching attempts from the dropdown actually shows you the correct attempt, instead of them all showing the same attempt - Smoke-test that updating a grade or a late/missing status for a regular old (non-Q.N) submission with multiple attempts doesn't break anything Change-Id: I13b109eb3ae013908d864845f014fa217fdf857b Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/280798 Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com> QA-Review: Syed Hussain <shussain@instructure.com> Product-Review: Syed Hussain <shussain@instructure.com> Reviewed-by: Dustin Cowles <dustin.cowles@instructure.com> Reviewed-by: Spencer Olson <solson@instructure.com>
This commit is contained in:
parent
c11938c3ef
commit
4f72fcf0b5
|
@ -5006,6 +5006,18 @@ QUnit.module('SpeedGrader', rootHooks => {
|
||||||
const {submission} = SpeedGrader.EG.setOrUpdateSubmission(alphaSubmission)
|
const {submission} = SpeedGrader.EG.setOrUpdateSubmission(alphaSubmission)
|
||||||
deepEqual(submission.submission_history[0].versioned_attachments, versionedAttachments)
|
deepEqual(submission.submission_history[0].versioned_attachments, versionedAttachments)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
test('does not thoughtlessly alter the submission field of the first attempt of the existing submission object if the passed-in submission has no attempt field', () => {
|
||||||
|
alphaSubmission.submission_history[0].submission = {grade: 'please spare me'}
|
||||||
|
|
||||||
|
const fakeSubmission = {
|
||||||
|
...alphaSubmission,
|
||||||
|
score: '10'
|
||||||
|
}
|
||||||
|
SpeedGrader.EG.setOrUpdateSubmission(fakeSubmission)
|
||||||
|
|
||||||
|
strictEqual(alphaSubmission.submission_history[0].submission.grade, 'please spare me')
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
QUnit.module('#renderAttachment', hooks => {
|
QUnit.module('#renderAttachment', hooks => {
|
||||||
|
|
|
@ -3304,6 +3304,7 @@ EG = {
|
||||||
}
|
}
|
||||||
return historySubmission.attempt === submission.attempt
|
return historySubmission.attempt === submission.attempt
|
||||||
}) || 0
|
}) || 0
|
||||||
|
const foundMatchingSubmission = historyIndex !== -1
|
||||||
historyIndex = historyIndex === -1 ? 0 : historyIndex
|
historyIndex = historyIndex === -1 ? 0 : historyIndex
|
||||||
|
|
||||||
if (typeof submission.submission_history === 'undefined') {
|
if (typeof submission.submission_history === 'undefined') {
|
||||||
|
@ -3311,8 +3312,14 @@ EG = {
|
||||||
submission.submission_history[historyIndex] = {submission: $.extend(true, {}, submission)}
|
submission.submission_history[historyIndex] = {submission: $.extend(true, {}, submission)}
|
||||||
}
|
}
|
||||||
|
|
||||||
// update the nested submission in submission_history if needed
|
// update the nested submission in submission_history if needed, assuming we
|
||||||
if (student.submission?.submission_history?.[historyIndex]?.submission) {
|
// could map the submission we got to a specific attempt (notably, with
|
||||||
|
// Quizzes.Next submissions and possibly other LTIs we don't get an
|
||||||
|
// "attempt" field)
|
||||||
|
if (
|
||||||
|
foundMatchingSubmission &&
|
||||||
|
student.submission?.submission_history?.[historyIndex]?.submission
|
||||||
|
) {
|
||||||
const versionedAttachments =
|
const versionedAttachments =
|
||||||
submission.submission_history[historyIndex].submission?.versioned_attachments || []
|
submission.submission_history[historyIndex].submission?.versioned_attachments || []
|
||||||
submission.submission_history[historyIndex].submission = $.extend(
|
submission.submission_history[historyIndex].submission = $.extend(
|
||||||
|
|
Loading…
Reference in New Issue