Hi Debora,
The script at the link you’ve provided does not perform the type of request you’ll need to update your outcomes. What it contains is a script for creating a new outcome (POST request), whereas you’d like to update an existing outcome (PUT request). The API does provide an end point for updating an existing outcome:
Canvas API Documentation for Updating an Outcome
If you don’t have adequate programming experience to automate this yourself, there is a rudimentary method you can use that requires almost no coding and can be implemented right from your browser (assuming you’re an admin in your instance of Canvas). I would strongly recommend trying it out in a test instance before updating live records:
- Convert your CSV to a JSON array using a free, safe converter: http://codebeautify.org/csv-to-xml-json
- Copy the entire output of the CSV to JSON converter to your clipboard.
- Log in to the Canvas account with the outcomes you want to update.
- Open up your developer tools (in Chrome, these are located on the menu in the top right corner of the window in the ‘More tools’ sub-menu labeled as ‘Developer Tools’. If you have a Mac, you can also type CMD + SHIFT + J). A new window should pop up.
- Click the tab at the top of the labeled ‘Console’. It should be near the end of list of tabs. You should see a mostly blank word pad with a blinking cursor.
- With the JSON still on your clipboard, type ‘var outcomes = ‘ and paste the JSON array. Press Enter. What you’ve done is encapsulated all of your outcome information into a series of data objects that Javascript can read very easily.
- Paste the below script into your console:
function updateOutcomes(outcomes) {
outcomes.forEach(function(outcome){
var url = '/api/v1/outcomes/' + outcome['outcome_id'];
var outcomeData = {
title: outcome['name'],
description: outcome['description'],
mastery_points: parseInt(outcome['mastery_points'])
};
$.ajax({
url: url,
type: 'PUT',
dataType: 'json',
data: outcomeData,
})
.done(function(response) {
console.log(response);
console.log('Successfully updated Outcome #' + outcome['outcome_id'] + ': ' + outcome['name']);
})
.fail(function(response) {
console.log(response);
console.log('Error. Failed to update Outcome #' + outcome['outcome_id'] + ': ' + outcome['name']);
})
.always(function() {
console.log('Request sent to ' + url);
});
});
};
That is a Javascript function. It takes a series of information like your JSON array and for each piece of information in that series it uses a method called ‘ajax’ from a Javascript library Canvas loads called jQuery to send a PUT (update) request to your domain at the route of a given outcome. It brings data with it: the new name, description, and mastery points. If the request is successful, you’ll see a success message and and some information that Canvas sends back to you. And if it doesn’t work you’ll see an error message. Once you’ve pasted the script into you console, press Enter.
8. now type 'updateOutcomes(outcomes);’ and press Enter.
9. The output should look something like this:
Now go check on Canvas to see if your records are updated. Sometimes updating mastery points can be a little funky, so beware. Also, changing the outcome group of a outcome requires a different request. But yea, that’s pretty much how to update your outcomes from the browser. It’s easy to just pop your terminal open and shoot off a couple of requests while you’re toodle’in around the Canvas.
I hope that was helpful in some way.