Skip to content

Instantly share code, notes, and snippets.

@erictroebs
Last active November 24, 2020 14:44
Show Gist options
  • Save erictroebs/ef3cb4db70ff8560d1721e8dac55c695 to your computer and use it in GitHub Desktop.
Save erictroebs/ef3cb4db70ff8560d1721e8dac55c695 to your computer and use it in GitHub Desktop.
extract moodle course participants by group name
$(".cell.c4") // select every table cell in fourth column (group)
.filter((k, e) => $(e).text() !== "Gruppe 2") // filter participants not in specified group
.parent().find(".c1") // select table cell in first column (name)
.filter((k, e) => $(e).text()) // filter rows with empty names
.map((k, e) => "rm -rf " + $(e).text().trim().replaceAll(" ", "\\ ") + "_*") // map to linux rm command
.toArray() // convert to javascript array
.reduce((a, v) => a + v + "\n", "") // reduce to single string
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment