AnsweredAssumed Answered

When SpeedGrading an assignment, initialize points to rubric's max pts

Question asked by Phil O'Connell on Nov 20, 2018
Latest reply on Nov 28, 2018 by Phil O'Connell

Hello, All:

 

 

This is the first Tampermonkey script for me.

 

In Canvas, after manually doing this:

  1. View the assignment
  2. Click on SpeedGrader
  3. Click on View Rubric

I want to then click a button, and automatically populate each of the points with the maximum in the rubric.

 

So, I want to go from this:

to this:

 

Here's what I'm attempting:

 

Edit: Well, all my nicely-aligned code got collapsed into one.  Here's the full context:  https://pastebin.com/D52jRfZ7

(function() { 'use strict'; var D = document; function initialize() { var btn = create_button('Default Points', set_values); var submission_details = D.getElementById('submission_details'); submission_details.appendChild(btn); } function create_button(text, handler) { var btn = D.createElement('button'); btn.type = 'button'; btn.id = 'pjo_default_points'; btn.classList.add('btn', 'btn-small'); btn.appendChild(D.createTextNode(text)); btn.addEventListener('click', handler, false); return btn; } function set_values(e) { var fields=D.getElementById('rubric_full').querySelectorAll('input[type=text]'); for (var i=0; i<fields.length; i++) { var pts = fields[i]; pts.value = i+1; // just a test value for now pts.dispatchEvent(new Event('change', { 'bubbles' : true })); } }

 

It does populate the values on the screen.  (Note that I'm just using the index+1 for the value.  Later I plan on more scraping to get the real value.)

 

But it's only superficial, because the score remains at 0:

 

And if I hit Save, all the scores change to "--"

 

I'm not sure what I'm doing wrong.

 

Any thoughts?

 

Thanks,

Phil

Outcomes