Skip to content

Commit

Permalink
Merge branch 'master' into add-caching
Browse files Browse the repository at this point in the history
Resolved conflicts:
      src/canvaslms/cli/assignments.nw
      src/canvaslms/cli/submissions.nw
      src/canvaslms/hacks/canvasapi.nw
  • Loading branch information
dbosk committed Jan 17, 2025
2 parents 7342b7e + 2eadffd commit 8829371
Show file tree
Hide file tree
Showing 36 changed files with 4,301 additions and 409 deletions.
11 changes: 11 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates

version: 2
updates:
- package-ecosystem: "pip" # See documentation for possible values
directory: "/" # Location of package manifests
schedule:
interval: "weekly"
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2020--2021 Daniel Bosk
Copyright (c) 2020--2024 Daniel Bosk

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
30 changes: 13 additions & 17 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
SUBDIR_GOALS= all clean distclean

SUBDIR+= doc
SUBDIR+= src/canvaslms
SUBDIR+= doc
SUBDIR+= docker

version=$(shell sed -n 's/^ *version *= *\"\([^\"]\+\)\",/\1/p' setup.py)
dist=$(addprefix dist/canvaslms-${version}, -py3-none-any.whl .tar.gz)
version=$(shell sed -n 's/^ *version *= *\"\([^\"]\+\)\"/\1/p' pyproject.toml)


.PHONY: all
Expand All @@ -20,32 +20,28 @@ install: compile
.PHONY: compile
compile:
${MAKE} -C src/canvaslms all
poetry build

.PHONY: publish publish-github publish-canvaslms publish-docker
publish: publish-canvaslms doc/canvaslms.pdf publish-docker publish-github

.PHONY: publish publish-canvaslms publish-docker
publish: publish-canvaslms doc/canvaslms.pdf
publish-github: doc/canvaslms.pdf
git push
gh release create -t v${version} v${version} doc/canvaslms.pdf

doc/canvaslms.pdf: $(wildcard src/canvaslms/cli/*.tex)
${MAKE} -C $(dir $@) $(notdir $@)

publish-canvaslms: ${dist}
python3 -m twine upload -r pypi ${dist}

${dist}: compile canvaslms.bash
python3 -m build

canvaslms.bash:
register-python-argcomplete canvaslms > $@
publish-canvaslms: compile
poetry publish

#publish-docker:
# sleep 60
# ${MAKE} -C docker publish
publish-docker:
sleep 60
${MAKE} -C docker publish


.PHONY: clean
clean:
${RM} canvaslms.bash

.PHONY: distclean
distclean:
Expand Down
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@ is `canvaslms` and it has several subcommands in the same style as Git.
`canvaslms` provides output in a format useful for POSIX tools, this
makes automating tasks much easier.

## Getting started

Start by login to your Canvas server

``` {.text}
canvaslms login
```

Let's consider how to grade students logging into the student-shell SSH
server. We store the list of students' Canvas and KTH IDs in a file.

Expand Down
5 changes: 3 additions & 2 deletions doc/Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
NOWEAVEFLAGS.tex= -n -delay -t2
NOTANGLEFLAGS.py=

LATEXFLAGS+= -shell-escape
Expand All @@ -21,8 +20,10 @@ canvaslms.pdf: ${SRC_DIR}/cli/users.tex
canvaslms.pdf: ${SRC_DIR}/cli/assignments.tex
canvaslms.pdf: ${SRC_DIR}/cli/submissions.tex
canvaslms.pdf: ${SRC_DIR}/cli/grade.tex
canvaslms.pdf: ${SRC_DIR}/cli/results.tex
canvaslms.pdf: ${SRC_DIR}/grades/grades.tex

${SRC_DIR}/%.tex:
${SRC_DIR}/%.tex: ${SRC_DIR}/%.nw
${MAKE} -C $(dir $@) $(notdir $@)


Expand Down
2 changes: 2 additions & 0 deletions doc/canvaslms.tex
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ \part{The command-line interface}
\input{../src/canvaslms/cli/assignments.tex}
\input{../src/canvaslms/cli/submissions.tex}
\input{../src/canvaslms/cli/grade.tex}
\input{../src/canvaslms/cli/results.tex}
\input{../src/canvaslms/grades/grades.tex}


\printbibliography
Expand Down
12 changes: 8 additions & 4 deletions doc/preamble.tex
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@
\usepackage[british]{babel}
\usepackage{booktabs}

\usepackage[natbib,style=alphabetic,maxbibnames=99]{biblatex}
\addbibresource{canvas.bib}

\usepackage[all]{foreign}
\renewcommand{\foreignfullfont}{}
\renewcommand{\foreignabbrfont}{}

\usepackage{newclude}
%\usepackage{newclude}
\usepackage{import}

\usepackage[strict]{csquotes}
\usepackage[single]{acro}

\usepackage[natbib,style=alphabetic,maxbibnames=99]{biblatex}
\addbibresource{canvas.bib}

\usepackage{subcaption}

\usepackage[noend]{algpseudocode}
Expand All @@ -35,11 +35,15 @@
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{mathtools}
\DeclarePairedDelimiter{\ceil}{\lceil}{\rceil}

\usepackage{amsthm}
\usepackage{thmtools}
\usepackage[unq]{unique}
\DeclareMathOperator{\powerset}{\mathcal{P}}

\usepackage{longtable}

\usepackage[binary-units]{siunitx}

\usepackage[capitalize]{cleveref}
5 changes: 5 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
FROM python:3

RUN pip3 install --no-cache-dir --upgrade canvaslms && \
activate-global-python-argcomplete && \
register-python-argcomplete canvaslms > /etc/bash_completion.d/canvaslms.bash
22 changes: 22 additions & 0 deletions docker/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
VERSION+= latest

.PHONY: all
all: docker-image

.PHONY: publish
publish: docker-image
for v in ${VERSION}; do docker push dbosk/canvaslms:$$v; done

.PHONY: docker-image
docker-image:
docker pull python:3
docker build --no-cache -t canvaslms .
for v in ${VERSION}; do docker tag canvaslms dbosk/canvaslms:$$v; done

.PHONY: clean
clean:
true

.PHONY: distclean
distclean:
-docker image rm -f canvaslms dbosk/canvaslms
65 changes: 65 additions & 0 deletions experiments/quiz-new.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
import canvasapi
import json
import os

canvas = canvasapi.Canvas(os.environ["CANVAS_SERVER"],
os.environ["CANVAS_TOKEN"])

test_course = None

for course in canvas.get_courses():
if course.name == "prgm23":
test_course = course
break

test_quiz = None

for quiz in course.get_assignments():
if quiz.name == "Exempelprov":
test_quiz = quiz
break
else:
raise ValueError("No quiz found")

test_submission = None

# There is only one in my setup
for quiz_submission in test_quiz.get_submissions():
if quiz_submission.submitted_at is not None:
test_submission = quiz_submission
break

print("\n# Quiz submission questions\n")

for subm_question in test_submission.get_submission_questions():
#print(subm_question.__dict__.keys())
#print(subm_question)
print(f"{subm_question.id} "
f"{subm_question.question_name}:\n"
f"{subm_question.question_text}")
try:
print(f"Alternatives: {subm_question.answers}")
print(f"Correct: {subm_question.correct}")
except AttributeError:
pass

print()

print("\n# Quiz submission answers\n")

quiz = None

for assignment in test_course.get_assignments():
if assignment.name == "Exempelprov":
quiz = assignment
break

for submission in quiz.get_submissions(include=["submission_history"]):
for subm in submission.submission_history:
#print(subm)
try:
for data in subm["submission_data"]:
print(json.dumps(data, indent=2))
except KeyError:
pass

61 changes: 61 additions & 0 deletions experiments/quiz.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import canvasapi
import json
import os

canvas = canvasapi.Canvas(os.environ["CANVAS_SERVER"],
os.environ["CANVAS_TOKEN"])

test_course = None

for course in canvas.get_courses():
if course.name == "Sandbox dbosk":
test_course = course
break

test_quiz = None

for quiz in course.get_quizzes():
if quiz.title == "Classic datorprov":
test_quiz = quiz
break

test_submission = None

# There is only one in my setup
for quiz_submission in test_quiz.get_submissions():
test_submission = quiz_submission

print("\n# Quiz submission questions\n")

for subm_question in test_submission.get_submission_questions():
#print(subm_question.__dict__.keys())
#print(subm_question)
print(f"{subm_question.id} "
f"{subm_question.question_name}:\n"
f"{subm_question.question_text}")
try:
print(f"Alternatives: {subm_question.answers}")
print(f"Correct: {subm_question.correct}")
except AttributeError:
pass

print()

print("\n# Quiz submission answers\n")

quiz = None

for assignment in test_course.get_assignments():
if assignment.name == "Classic datorprov":
quiz = assignment
break

for submission in quiz.get_submissions(include=["submission_history"]):
for subm in submission.submission_history:
#print(subm)
try:
for data in subm["submission_data"]:
print(json.dumps(data, indent=2))
except KeyError:
pass

2 changes: 1 addition & 1 deletion makefiles
Submodule makefiles updated 10 files
+1 −1 LICENSE
+7 −1 Makefile
+1 −1 doc.mk
+1 −1 doc.mk.nw
+16 −14 noweb.mk
+26 −14 noweb.mk.nw
+34 −18 pub.mk
+119 −69 pub.mk.nw
+2 −2 tex.mk
+2 −2 tex.mk.nw
Loading

0 comments on commit 8829371

Please sign in to comment.