Skip to content

Instantly share code, notes, and snippets.

@bennettscience
bennettscience / Code.gs
Created March 20, 2024 18:38
Automatically get a bit.ly link for a Google Form from a linked Google Sheet
// Copyright 2017 Brian E. Bennett
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software
// and associated documentation files (the "Software"), to deal in the Software without restriction,
// including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
// The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
@bennettscience
bennettscience / app.py
Last active June 21, 2022 12:36
An HTMX-based dynamic form system
# other flask stuff - this is just an example
# The actual application uses blueprints to keep routes organized.
from flask import Blueprint, Flask
app = Flask(__name__)
course_blueprint = Blueprint('courses', __name__)
app.register_blueprint(course_blueprint)
# Get the form to edit the event
@bennettscience
bennettscience / Form.svelte
Last active June 21, 2022 12:06
A Svelte form wrapper to dynamically load forms based on button click
<script>
/*
This is a generic wrapper component for any forms. Pass in an array of {field} objets to be
rendered into the form.
Submissions are all converted into JSON before being passed back to the parent for handling. This allows the
parent compoenent to determine the API route the form is submitting to rather than adding those options here.
*/
import Input from './formFields/Input.svelte';
import Select from './formFields/Select.svelte';
@bennettscience
bennettscience / iterator.js
Last active September 18, 2021 22:18
Use a JS generator to create an iterator for paginated API responses
'use strict'
/**
* Objeect Oriented implementation of an iterable to handle paginated requests
*
* @param {string} requestMethod HTTP method for the request
* @param {string} firstUrl Endpoint for the request
*
*/
class PaginatedList {
constructor(requestMethod, firstUrl) {
@bennettscience
bennettscience / fixtures.gs
Last active February 24, 2021 02:45
A simple Mocking framework in Google Apps Script
/**
* Fixtures provide a conventient way to define expected data strucures from API calls. This
* works based on JSON keys and gives a flexible, namespaced access for quickly making Mocks.
*/
const fixtures = (function() {
const init = function() {
return this;
}
@bennettscience
bennettscience / assignment_rubrics.py
Created November 4, 2020 17:42
Get outcome results from a rubric on Canvas LMS assignments
"""
This script will fetch Outcome ratings from assignment rubrics and return a list of dicts.
Requires the use of UCF Open's canvasapi library. Install with `pip install canvasapi`.
Replace PROD_URL and PROD_KEY with your own Canvas URL and API key.
"""
from canvasapi import Canvas
from config import PROD_KEY, PROD_URL
from pprint import pprint
def build_assignment_rubric_results(canvas, course_id, assignment_id):
@bennettscience
bennettscience / missing_report.py
Last active May 18, 2020 12:44
Generate a report of missing assignments for all students in a Canvas course. Returns a CSV.
from canvasapi import Canvas # pip install canvasapi
import csv
import concurrent.futures
from functools import partial
KEY = '' # Your Canvas API key
URL = '' # Your Canvas API URL
COURSE = '' # Your course ID
@bennettscience
bennettscience / update_student_notifications.py
Last active September 24, 2020 22:24
Update student email notifications as an admin in Canvas LMS
import csv
import re
import requests
import concurrent.futures
import time
# pip install tqdm for progress monitoring
from tqdm import tqdm
from functools import partial
"""
@bennettscience
bennettscience / script.gs
Last active October 31, 2019 15:30
Automatically set a programmatically-created Google Doc to the correct owner.
/*********** SETUP ***************/
// Store two global variables with columns to use as references.
// These should be zero-based because they're used in a loop.
var docIdCol = 0 // Int of col to check for a document ID
var emailCol = 0 // Int of col with submitter email address
/********** END SETUP **************/
@bennettscience
bennettscience / studentOutcomes.user.js
Last active September 6, 2019 11:53
Collect and display student Outcome score averages in Canvas LMS
// ==UserScript==
// @name Student LMG Viewer
// @namespace https://gist.github.com/bennettscience/cf6a0ec2526844aa672bd3850dee85ee
// @description Show calculated Outcome socres for students in Canvas
// @author Brian Bennett
// @match https://*.instructure.com/courses/*/grades/*
// ==/UserScript==
(function() {
'use strict';