Instantly share code, notes, and snippets.

@gaulinmp /Grading,js
Last active Nov 15, 2018

Embed
What would you like to do?
Canvas Javascript workarounds
// Wrap in for bookmarklet:
javascript: (function () {/* CODE HERE */})()
// Set Empty to Full Points
javascript: (function () {
$("#speedgrader_iframe").contents().find("body").find('span.question_points_holder > div').each(
function(index, elem){
var current_val = $(elem).find('input').val();
var full_val = $(elem).find('span').text().match(/\d+/)[0];
if (String(current_val) == "") {
console.log("Setting " + current_val + " to " + full_val);
$(elem).find('input').val(full_val);
}
});
$("#speedgrader_iframe").contents().find("body").find('div.update_scores button.update-scores').click();
setTimeout(function(){$('#next-student-button').click();}, 3000);
})();
// Or, put this in a bookmarklet:
// javascript:(function(){$("#speedgrader_iframe").contents().find("body").find('span.question_points_holder > div').each(function(index, elem){ var current_val = $(elem).find('input').val(); var full_val = $(elem).find('span').text().match(/\d+/)[0]; if (String(current_val) == "") { console.log("Setting " + current_val + " to " + full_val); $(elem).find('input').val(full_val); } });})();
// This one clicks update, then clicks to the next student.
// javascript:(function(){$("#speedgrader_iframe").contents().find("body").find('span.question_points_holder > div').each(function(index, elem){ var current_val = $(elem).find('input').val(); var full_val = $(elem).find('span').text().match(/\d+/)[0]; if (String(current_val) == "") { console.log("Setting " + current_val + " to " + full_val); $(elem).find('input').val(full_val); } }); $("#speedgrader_iframe").contents().find("body").find('div.update_scores button.update-scores').click();setTimeout(function(){$('#next-student-button').click();}, 3000);})();
// Add name and comment
javascript: (function () {/* CODE HERE */
function fill(n) {
var name = $('#students_selectmenu-button span .ui-selectmenu-item-header').text().trim().split(" ")[0].toLowerCase();
name = name.charAt(0).toUpperCase() + name.slice(1);
var strs = [
/*0@1* /"100% " + name + ", well done!",
/*0@2*/"Perfect score achieved " + name + ", very nice!",
/*0@4* /"Perfect score " + name + ", steak sauce!",*/
/*1*/"You only missed one " + name + ", really well done!",
/*2*/"Nicely done " + name + "!",
/*3*/name + ", I gave you partial credit based on your submitted work. After going through the solutions, let me know if I can help clarify any of the concepts.",
/*4*/name + ", I gave you partial credit based on your submitted work and directions for the multiple choice. After going through the solutions, let me know if I can help clarify any of the concepts.",
/*5*/name + ", you only missed the conceptual question in Q10. Really well done!",
/*6*/name + ", it looks like you omitted FOH for COGM, but everything after that was right, so I'll only dock you the points up front. After going through the solutions, let me know if I can help clarify any of the concepts."
];
$('#speedgrader_comment_textarea').val(strs[n]);
$("#comment_submit_button").click();
};
fill(0); /* Change 0 to fill with other strings */
})()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment