canvas-lms/app/jsx/grading/quizzesNextSpeedGrading.js

90 lines
2.9 KiB
JavaScript
Raw Normal View History

/*
* Copyright (C) 2016 - present Instructure, Inc.
*
* This file is part of Canvas.
*
* Canvas is free software: you can redistribute it and/or modify it under
* the terms of the GNU Affero General Public License as published by the Free
* Software Foundation, version 3 of the License.
*
* Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
* details.
*
* You should have received a copy of the GNU Affero General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
// this is called by speed grader to enable communication
// between quizzesNext LTI tool and speed grader
// and modify normal speedGrader behavior to be more compatible
// with our LTI tool
// it sets up event listeners for postMessage communication
// from the LTI tool
// registerCb replaces the base speedgrader submissionChange callback
// with whatever callback is passed in as an argument
// refreshGradesCb executes the normal speedGrader refresh grades
// actions, plus whatever callback is passed in as an argument
function quizzesNextSpeedGrading (EG, $iframe_holder, registerCb, refreshGradesCb, speedGraderWindow = window) {
function quizzesNextChange (submission) {
EG.refreshSubmissionsToView();
if (submission && submission.submission_history) {
let lastIndex = submission.submission_history.length - 1;
// set submission to selected in dropdown
$("#submission_to_view option:eq(" + lastIndex + ")").attr("selected", "selected");
}
EG.showGrade();
EG.showDiscussion();
EG.showRubric();
EG.updateStatsInHeader();
EG.refreshFullRubric();
EG.setGradeReadOnly(true);
}
// gets the submission from the speed_grader.js
// function that will call this
function postChangeSubmissionMessage (submission) {
var frame = $iframe_holder.children()[0];
if (frame && frame.contentWindow) {
frame.contentWindow.postMessage(
{
submission,
subject: 'canvas.speedGraderSubmissionChange'
}, '*'
);
}
update handling quizzes next in speed grader fixes QUIZ-1588 test plan: - With a teacher, create a quizzes 2 assignment - As a student, take the quiz. - Make sure that there are students in the course who have not yet completed the assignment. - As the teacher, navigate to the assignment in speed grader. - For the student who has taken the assignment, observe that the grading view is visible. - Using the toggle in the upper right hand corner, observe that you can navigate to a student who has not yet completed the assignment, & the main window changes to show a page indicated that the student hasn't yet completed the assignment. - Complete the assignment with the second student in question. - As the teacher again navigate to the assignment in speedgrader. - Observe that the control in the upper right hand corner can navigate between users who have completed the assignment. - In the main window, update a grade or fudge points value. - After the main window has reloaded, navigate to another student. - Observe that the grading screen for the second student loads. - As a teacher viewing the grading page for a student's submitted assignment, update the grade or fudge points value. - Observe that there is now a submission version dropdown in the upper right hand corner of the screen. - Select a previous submission. - Observe that the previous submission loads. Change-Id: Ieefe3acd10db4b72cda24b27dfd9f935a2168718 Reviewed-on: https://gerrit.instructure.com/111107 Tested-by: Jenkins Reviewed-by: Matt Taylor <mtaylor@instructure.com> Reviewed-by: Keith T. Garner <kgarner@instructure.com> Reviewed-by: Omar Khan <okhan@instructure.com> QA-Review: Michael Hargiss <mhargiss@instructure.com> Product-Review: John Corrigan <jcorrigan@instructure.com>
2017-05-09 01:15:22 +08:00
EG.showSubmissionDetails();
quizzesNextChange(submission);
}
function onMessage (e) {
var message = e.data;
switch (message.subject) {
case 'quizzesNext.register':
EG.setGradeReadOnly(true);
registerCb(postChangeSubmissionMessage);
break;
case 'quizzesNext.submissionUpdate':
refreshGradesCb(quizzesNextChange);
break;
}
}
speedGraderWindow.addEventListener('message', onMessage);
// expose for testing
return {
onMessage: onMessage,
postChangeSubmissionMessage: postChangeSubmissionMessage,
quizzesNextChange: quizzesNextChange
};
}
export default quizzesNextSpeedGrading