Socket
Socket
Sign inDemoInstall

canvas-grade-uploader

Package Overview
Dependencies
51
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.2 to 1.0.3

33

cli.js

@@ -33,7 +33,6 @@ #! /usr/bin/env node

parser.addArgument(
['-f', '--file'],
['-f', '--file' ],
{
help: 'A CSV file of grades. It must include a "SID" column and a "grade" column.',
required: true,
positional: 1
help: 'A CSV file of grades. It must include a "SID" column and a "Total Score" column.',
required: true
}

@@ -61,3 +60,3 @@ );

// TODO: Un-Berkeley-ify this option
help: 'Canvas SIS id format. This currently defaults to `sis_user_id` which is used at UC Berkeley.' +
help: 'Canvas SIS id format. This currently defaults to "sis_user_id" which is used at UC Berkeley.' +
'\nThis controls what ID options Canvas uses to find a student.',

@@ -76,3 +75,2 @@ defaultValue: 'sis_user_id',

// TODO: Header Grade
// TODO: Name -- maybe this should be a , separated list?

@@ -82,28 +80,9 @@ // Verify Args Exist

function verifyArgs() {
var ARGS = parser.parseArgs(),
errors = [];
ARG_VALS = parser.parseArgs();
// This check is necessary because CANVAS_TOKEN could be undefied.
if (!ARGS.token) {
errors.push('Please export the CANVAS_TOKEN variable or provide token with -t.');
}
if (errors.length) {
console.error('The following errors occurred:');
console.error('\t' + errors.join('\n\t'));
parser.printHelp();
process.exit(1);
}
return ARGS;
}
ARG_VALS = verifyArgs();
// Specify encoding to return a string
gradesFile = fs.readFileSync(ARG_VALS.file, { encoding: 'utf8'});
// TODO: make the callback be a more useful function.
postGrades(ARG_VALS, gradesFile, console.log);

2

package.json
{
"name": "canvas-grade-uploader",
"version": "1.0.2",
"version": "1.0.3",
"description": "Upload a CSV file of grades to Canvas",

@@ -5,0 +5,0 @@ "main": "./uploader.js",

@@ -26,2 +26,4 @@ # Canvas Grade Uploader

```
* When using the command line, you can optionally define `CANVAS_TOKEN` in your environment. This will be used if no `-t` option is provided.
2. As a module:

@@ -34,3 +36,3 @@ ```

**NOTE** The module interface is currently a work in progress.
**NOTE** The module interface is currently a work in progress. Breaking changes to this interface will be semver-minor, at least until it's fully stable.

@@ -64,9 +66,37 @@ ## Configuration

* SID
* Total Score
* "SID" -- This is the unique user ID for each student.
* "Total Score" -- This is the score that each user will receive.
* Optional "Name" -- The name column currently isn't used, but might be for debugging in the future. (Really, it's much much nicer to deal with names over IDs when possible.)
## Default Values
Currently, there are a couple default values which as "Berkeley-specific". If this tool gets enough use, I'll gladly change them…
* URL, `-u` defaults to: `https://bcourses.berkeley.edu`
* User ID format, `-uid` defaults to: `sis_user_id`. This parameter controls how Canvas interprets user IDs. See [this][sid-id].
(In the future, I'd consider supporting some means of having user-default parameters, so please submit a PR if you'd like!)
[sid-id]: http://bjc.link/canvassisid
## Options and Callback Formats
Using this as a module requires 3 parameters:
## Tips
* `options`: A JS object, with keys that mirror the command line arguments. _Note_: in this form, the only defaults that are applied are the CSV column names. The file parameter is not required.
```
{
course_id: '1268501',
assignment_id: '7148451',
url: 'https://bcourses.berkeley.edu/',
token: '<token>',
user_id_format: 'sis_user_id'
}
```
* `data`: This is the CSV data, as a string.
* `callback`: This is called with a string, updating the progress of uploading grades. Note that it will be called quite a few times in the process uploading grades.
* **WARNING** This will be updated to have a signature like `(err, resp)` very soon.
## Tips
* If you want to test things, use `http://<domain>.beta.instructure.com/`
* Instructure's beta instances have a separate DB that is supposed to be purged and refreshed each week.

@@ -35,5 +35,5 @@ // Upload a CSV of Grades to Canvas

// inspect csv.meta.truncated and csv.errors
csvObj.data.forEach(function (lineData) {
var sid, grade, name;
sid = lineData[SID];

@@ -53,2 +53,3 @@ grade = lineData[SCORE];

var course, gradesData, url;
course = new Canvas(

@@ -107,5 +108,7 @@ options.url,

function monitorProgress(course, id, callback) {
var timeoutID, delay = 100,
var timeoutID, delay = 500,
prevCompletion = null, prevState = null;
// Use a small delay to prevent killing any servers
// since the progress API leaves no choice other than polling.
setTimeout(function() {

@@ -135,3 +138,3 @@ course.get(`progress/${id}/`, {}, function(err, resp, body) {

} else {
cb(`Canvas State: ${body.workflow_state}`);
callback(`Canvas State: ${body.workflow_state}`);
}

@@ -138,0 +141,0 @@ monitorProgress(course, id, callback);

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc