Skip to content

Instantly share code, notes, and snippets.

View georgekinnear's full-sized avatar

George Kinnear georgekinnear

View GitHub Profile
@georgekinnear
georgekinnear / jsxgraph_boundingbox.js
Created March 1, 2026 12:11
Bounding box utility for JSXGraph
/* Compute a JSXGraph boundingbox [xmin, ymax, xmax, ymin]
that contains:
- all includePoints exactly
- a radius `radius` neighborhood around each point in circleCenters
Options:
- pad: extra margin on all sides
- minWidth, minHeight: enforce minimum visible span
*/
function makeBoundingBox({
The issue is that not all types of questions were asked in every lecture.
In those cases, we need to add rows that say there were 0 questions of that type.
The `complete` function provides a way to add in the "missing" rows.
```{r}
all_qs_all_lecs %>%
summarise(
num_questions = n(),
.by = c(course, session, code_name)
) %>%
@georgekinnear
georgekinnear / attempt-steps.sql
Last active January 27, 2026 16:01
Moodle SQL: All attempt steps in a quiz - not just the last for each student
SELECT
qa.*,
qas_last.*,
qas_last.timecreated AS stepdate,
u.email,
u.firstname,
u.lastname
FROM {course_modules} cm
JOIN {quiz_attempts} quiza ON quiza.quiz = cm.instance
JOIN {question_usages} qu ON qu.id = quiza.uniqueid
@georgekinnear
georgekinnear / edinburgh.js
Last active March 1, 2026 11:13
Draft of a JSXGraph style
/*
customise the CSS applied within the iframe
*/
document.addEventListener("DOMContentLoaded", (event) => {
let style = document.createElement('style');
style.type = 'text/css';
style.innerHTML = `
.jxgbox {
border-style: none;
background: none;
@georgekinnear
georgekinnear / moodle-sql.md
Created March 12, 2024 08:40
SQL queries for use with Moodle's ad-hoc database plugin

Summarising student activity

Number of times each student attempted each quiz question

For each quiz in the course, for every student who attempted it, count how many attempts they made at each question.

SELECT q.name AS quiz, MIN(qa.slot) AS slot,

@georgekinnear
georgekinnear / raw-initial-scss
Created August 8, 2023 11:22
2023-boost-mods
$activity-icon-colors: (
"administration": #004F71,
"assessment": #830065,
"collaboration": #154734,
"communication": #C25E03,
"content": #0099AB,
"interface": #61BF1A
);
@georgekinnear
georgekinnear / anon.R
Last active May 12, 2022 11:08
Simple R script to anonymise data, by reading in multiple CSV files and replacing ID fields with a hashed version
#
# Anonymise data by replacing UUN with a hashed unique ID
#
# Note - in order to prevent "rainbow table" hacking of the hashing, a salt string is added in the anonymise function
# This string must not be published.
#
library(tidyverse)
library(digest) # see https://jangorecki.github.io/blog/2014-11-07/Data-Anonymization-in-R.html
<style>
/* overall look */
body {
font-family: Arial;
}
.page-context-header {
padding: 0;
}
/* styling of course overview pages */
.topics a {