ladok3 5.0__tar.gz → 5.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of ladok3 might be problematic. Click here for more details.

Files changed (35) hide show
  1. {ladok3-5.0 → ladok3-5.1}/PKG-INFO +1 -1
  2. {ladok3-5.0 → ladok3-5.1}/doc/Makefile +1 -0
  3. ladok3-5.1/doc/abstract.tex +8 -0
  4. {ladok3-5.0 → ladok3-5.1}/doc/ladok3.tex +30 -30
  5. {ladok3-5.0 → ladok3-5.1}/pyproject.toml +1 -1
  6. {ladok3-5.0 → ladok3-5.1}/src/ladok3/.gitignore +1 -0
  7. {ladok3-5.0 → ladok3-5.1}/src/ladok3/Makefile +6 -0
  8. ladok3-5.1/src/ladok3/scripts.nw +244 -0
  9. ladok3-5.0/doc/abstract.tex +0 -3
  10. {ladok3-5.0 → ladok3-5.1}/LICENSE +0 -0
  11. {ladok3-5.0 → ladok3-5.1}/README.md +0 -0
  12. {ladok3-5.0 → ladok3-5.1}/doc/preamble.tex +0 -0
  13. {ladok3-5.0 → ladok3-5.1}/makefiles/doc.mk +0 -0
  14. {ladok3-5.0 → ladok3-5.1}/makefiles/exam.mk +0 -0
  15. {ladok3-5.0 → ladok3-5.1}/makefiles/haskell.mk +0 -0
  16. {ladok3-5.0 → ladok3-5.1}/makefiles/miun.course.mk +0 -0
  17. {ladok3-5.0 → ladok3-5.1}/makefiles/miun.depend.mk +0 -0
  18. {ladok3-5.0 → ladok3-5.1}/makefiles/miun.docs.mk +0 -0
  19. {ladok3-5.0 → ladok3-5.1}/makefiles/miun.port.mk +0 -0
  20. {ladok3-5.0 → ladok3-5.1}/makefiles/miun.pub.mk +0 -0
  21. {ladok3-5.0 → ladok3-5.1}/makefiles/noweb.mk +0 -0
  22. {ladok3-5.0 → ladok3-5.1}/makefiles/pkg.mk +0 -0
  23. {ladok3-5.0 → ladok3-5.1}/makefiles/portability.mk +0 -0
  24. {ladok3-5.0 → ladok3-5.1}/makefiles/pub.mk +0 -0
  25. {ladok3-5.0 → ladok3-5.1}/makefiles/results.mk +0 -0
  26. {ladok3-5.0 → ladok3-5.1}/makefiles/subdir.mk +0 -0
  27. {ladok3-5.0 → ladok3-5.1}/makefiles/tex.mk +0 -0
  28. {ladok3-5.0 → ladok3-5.1}/makefiles/transform.mk +0 -0
  29. {ladok3-5.0 → ladok3-5.1}/src/ladok3/api.nw +0 -0
  30. {ladok3-5.0 → ladok3-5.1}/src/ladok3/cli.nw +0 -0
  31. {ladok3-5.0 → ladok3-5.1}/src/ladok3/data.nw +0 -0
  32. {ladok3-5.0 → ladok3-5.1}/src/ladok3/ladok3.nw +0 -0
  33. {ladok3-5.0 → ladok3-5.1}/src/ladok3/report.nw +0 -0
  34. {ladok3-5.0 → ladok3-5.1}/src/ladok3/student.nw +0 -0
  35. {ladok3-5.0 → ladok3-5.1}/src/ladok3/undoc.nw +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ladok3
3
- Version: 5.0
3
+ Version: 5.1
4
4
  Summary: Python wrapper and CLI for the LADOK3 REST API.
5
5
  Home-page: https://github.com/dbosk/ladok3
6
6
  License: MIT
@@ -24,6 +24,7 @@ ladok3.pdf: ../examples/example_LadokSession.py
24
24
  ladok3.pdf: ../examples/example_Student.py
25
25
  ladok3.pdf: ../examples/example_Course.py
26
26
  ladok3.pdf: ../examples/canvas2ladok.tex
27
+ ladok3.pdf: ../src/ladok3/scripts.tex
27
28
 
28
29
  ladok3.pdf: didactic.sty
29
30
 
@@ -0,0 +1,8 @@
1
+ We provide a Python wrapper for the LADOK3 REST API\@.
2
+ This wrapper provide a useful object-oriented framework for working with LADOK
3
+ and direct API calls that return the unprocessed JSON data directly from
4
+ LADOK\@.
5
+
6
+ We also provide a command-line interface (CLI) for the library.
7
+ We then construct some useful (shell) scripts using this CLI\@.
8
+ These scripts automates the reporting of results from Canvas to LADOK\@.
@@ -58,7 +58,8 @@ LADOK's web GUI export functions.
58
58
 
59
59
  You can install the \texttt{ladok3} package by running
60
60
  \begin{minted}{bash}
61
- pip3 install ladok3
61
+ python3 -m pip install ladok3 # to use it in Python, or
62
+ pipx install ladok3 # to just use the CLI
62
63
  \end{minted}
63
64
  in the terminal.
64
65
 
@@ -96,40 +97,25 @@ LADOK expires, it will automatically reauthenticate to establish a new session.
96
97
 
97
98
  You can find a quick reference by running
98
99
  \begin{minted}[firstnumber=last]{bash}
99
- pydoc ladok3
100
+ pydoc ladok3 # doesn't work if installed with pipx
100
101
  \end{minted}
101
102
 
102
103
 
103
104
 
104
- \part{A command-line interface}
105
+ \part{Example applications}
105
106
 
106
- \chapter{The base interface}
107
-
108
- \input{../src/ladok3/cli.tex}
109
-
110
- \chapter{The \texttt{course} command}
111
-
112
- \input{../src/ladok3/data.tex}
113
-
114
- \chapter{The \texttt{report} command}
107
+ \chapter{Transfer results from Canvas to LADOK}\label{SomeScripts}
115
108
 
116
- \input{../src/ladok3/report.tex}
117
-
118
- \chapter{The \texttt{student} command}
119
-
120
- \input{../src/ladok3/student.tex}
109
+ \input{../src/ladok3/scripts.tex}
121
110
 
122
-
123
-
124
- \part{Other example applications}
125
-
126
- \chapter{Transfer results from Canvas to LADOK}
111
+ \chapter{Transfer results from Canvas to LADOK in Python}
127
112
 
128
113
  Here we provide an example program~\texttt{canvas2ladok.py} which exports
129
114
  results from Canvas to LADOK for the introductory programming course~prgi
130
115
  (DD1315).
131
116
 
132
- However, a better way to do this is by using the CLI:
117
+ However, a better way to do this is by using the CLI
118
+ (see \cref{SomeScripts} for an even better version):
133
119
  \begin{minted}{bash}
134
120
  #!/bin/bash
135
121
 
@@ -143,12 +129,6 @@ canvaslms results -c "$courses" -A "$components" \
143
129
  | sed -E "s/ ?[HV]T[0-9]{2}( \(.*\))?//" \
144
130
  | ladok report -fv
145
131
  \end{minted}
146
- The advantage to using this command is that it will automatically report the
147
- correct dates and everyone who has participated in the grading of each
148
- student---as required by regulation.
149
- The official tools, like KTH Transfer to Ladok or SUNET's version of the same,
150
- don't do this---they don't set the dates correctly of each individual, but one
151
- for all, and they don't register the graders in LADOK.
152
132
 
153
133
  But now we'll have a look at how we can do this (well, a simpler version) in
154
134
  Python.
@@ -157,7 +137,27 @@ Python.
157
137
  \input{../examples/canvas2ladok.tex}
158
138
 
159
139
 
160
- \part{The library}
140
+ \part{The command-line interface}
141
+
142
+ \chapter{The base interface}
143
+
144
+ \input{../src/ladok3/cli.tex}
145
+
146
+ \chapter{The \texttt{course} command}
147
+
148
+ \input{../src/ladok3/data.tex}
149
+
150
+ \chapter{The \texttt{report} command}
151
+
152
+ \input{../src/ladok3/report.tex}
153
+
154
+ \chapter{The \texttt{student} command}
155
+
156
+ \input{../src/ladok3/student.tex}
157
+
158
+
159
+
160
+ \part{The Python library}
161
161
 
162
162
  \input{../src/ladok3/ladok3.tex}
163
163
 
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "ladok3"
3
- version = "5.0"
3
+ version = "5.1"
4
4
  description = "Python wrapper and CLI for the LADOK3 REST API."
5
5
  authors = [
6
6
  "Daniel Bosk <dbosk@kth.se>",
@@ -8,3 +8,4 @@ prgi.py
8
8
  prgi.tex
9
9
  ladok.bash
10
10
  test.bash
11
+ ladok.sh
@@ -1,9 +1,11 @@
1
1
  LIB= ladok3.nw api.nw undoc.nw
2
2
  CLI= cli.nw data.nw report.nw student.nw
3
+ SCRIPTS=$(shell noroots scripts.nw | sed -E "s/(<<|>>)//g")
3
4
 
4
5
  .PHONY: all
5
6
  all: ${LIB:.nw=.tex} __init__.py
6
7
  all: ${CLI:.nw=.tex} ${CLI:.nw=.py} ladok.bash
8
+ all: scripts.tex ${SCRIPTS}
7
9
 
8
10
  __init__.py: ladok3.py
9
11
  mv $^ $@
@@ -13,6 +15,9 @@ ladok3.py: ${LIB}
13
15
  ladok.bash: __init__.py ${CLI:.nw=.py}
14
16
  register-python-argcomplete ladok > $@
15
17
 
18
+ ${SCRIPTS}: scripts.nw
19
+ ${NOTANGLE.sh}
20
+
16
21
 
17
22
  .PHONY: clean
18
23
  clean:
@@ -20,6 +25,7 @@ clean:
20
25
  ${RM} ${LIB:.nw=.tex}
21
26
  ${RM} ${CLI:.nw=.tex}
22
27
  ${RM} ${CLI:.nw=.py} ladok.bash
28
+ ${RM} scripts.tex ${SCRIPTS}
23
29
 
24
30
  .PHONY: distclean
25
31
  distclean:
@@ -0,0 +1,244 @@
1
+ In this chapter we'll see some scripts for reporting results from Canvas to
2
+ LADOK.
3
+ These scripts are run as cronjobs.
4
+ This means that they run unattended and only produce output when they need
5
+ attention.
6
+
7
+ We want to report results for courses that are titled \enquote{DD2520 VT25},
8
+ \enquote{DD1310 HT24}, \enquote{DD1317 HT24}, and similar in Canvas.
9
+ The advantage to using this command is that it will automatically report the
10
+ correct dates and everyone who has participated in the grading of each
11
+ student---as required by regulation.
12
+ The official tools, like KTH Transfer to Ladok or SUNET's version of the same,
13
+ don't do this.
14
+ They don't set the dates correctly, meaning that each individual should have a
15
+ separate date (date of submission).
16
+ They also don't register the graders in LADOK.
17
+ For each results, everyone who participated in the grading process should be
18
+ registered in LADOK.
19
+
20
+ We'll have a script [[<<ladok.sh>>]] that is run by [[cron]].
21
+ It's useful to load our profile, so that we have our normal environment.
22
+ <<ladok.sh>>=
23
+ #!/bin/bash
24
+ . ${HOME}/.profile
25
+ @
26
+
27
+ We also want some helper functions and a main function that is only run when
28
+ the script is run.
29
+ If the script is sourced, the main function is not run.
30
+ This way we can use the helper functions in our terminal.
31
+ <<ladok.sh>>=
32
+ <<constants>>
33
+ <<helper functions>>
34
+
35
+ main() {
36
+ <<main script>>
37
+ }
38
+
39
+ # Only run if this is the main script
40
+ if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
41
+ main "$@"
42
+ fi
43
+ @
44
+
45
+ We need to report more than once for a course.
46
+ All students might not be done by the time of reporting.
47
+ When they're done, we must report the results again\footnote{%
48
+ And students have a right to do this without having to reregister on a later
49
+ course round.
50
+ }.
51
+ Sometimes a student finishes a course years after it ended.
52
+ To speed up execution it's better to report results for a sliding window of
53
+ courses, instead of all courses.
54
+ For those rare cases when a student finishes a course years after it ended, we
55
+ can report the results manually for that course again---by importing and
56
+ invoking the functions below in the terminal.
57
+
58
+ We'll let [[YEARS]] be a regex for the years that we're interested in reporting
59
+ for.
60
+ We'll use the current year and the previous year.
61
+ The advantage of this window is that when we pass new year's eve, the autumn
62
+ courses are still current for a few weeks---but the year is the wrong one.
63
+ As a side effect, during autumn we report results for any late results for the
64
+ previous year too.
65
+
66
+ To construct the regex for years, we simply take a sequence of years
67
+ ([[24 25]]) and make a regex ([[(24|25)]]) out of it.
68
+ <<constants>>=
69
+ YEAR=$(date +%y)
70
+ YEARS=$(echo -n "("; \
71
+ seq $((YEAR - 1)) $YEAR \
72
+ | sed -zE "s/\s/|/g" \
73
+ | sed "s/|$/)/")
74
+ @
75
+
76
+ \section{Reporting results on course components}
77
+
78
+ We want a script that reports the results for all courses, including all
79
+ previous years, to LADOK.
80
+ We want to do this for previous years as sometimes they finish assignments
81
+ years after the course ended.
82
+
83
+ We'll add a function that takes a course regex and a component regex and
84
+ reports the results to LADOK.
85
+ To report the modules, we sometimes need to override the default summary
86
+ function of [[canvaslms]]\footnote{\label{canvaslms-doc}%
87
+ For details on [[canvaslms results]], see Chapters 10 and 11 in its
88
+ documentation, found on
89
+ \url{https://github.com/dbosk/canvaslms/releases/tag/v4.7}.
90
+ Particularly Chapter 11 discusses the summary modules.
91
+ You can also read [[pydoc canvaslms.grades]] for a more brief summary.
92
+ }.
93
+ We want something like this:
94
+ <<main script>>=
95
+ report_components "DD1301 HT${YEARS}" \
96
+ LAB1
97
+ report_components "DD131[057] HT${YEARS}" \
98
+ "(LAB|MAT|KAL)[1-3]"
99
+ report_components "DA2215 [HV]T${YEARS}" \
100
+ INL1
101
+
102
+ report_components "DD2520 VT${YEARS}" \
103
+ INL1
104
+ report_components "DD2520 VT${YEARS}" \
105
+ LAB1 \
106
+ canvaslms.grades.tilkryLAB1
107
+ @ Note that the line reporting for DD1310 reports for \emph{all} instances as
108
+ well---that course is given five times in parallel.
109
+ But the assessment should be the same so it is sufficient that one of the
110
+ examiners run this script to report all the results.
111
+
112
+ To get the results out of Canvas we'll use the [[canvaslms results]] command.
113
+ We must install the [[canvaslms]] tool.
114
+ We can do this by running:
115
+ \begin{minted}{bash}
116
+ python3 -m pip install canvaslms # to use it with Python, or
117
+ pipx install canvaslms # to only use the CLI
118
+ canvaslms login # or read `canvaslms login --help`
119
+ \end{minted}
120
+ For details on how to extract the results, read
121
+ \mintinline{bash}{canvaslms results --help}
122
+ (also read \cref{canvaslms-doc} on page~\pageref{canvaslms-doc}).
123
+ <<helper functions>>=
124
+ report_components() {
125
+ local course="$1"
126
+ local component="$2"
127
+ local summary_module="$3"
128
+
129
+ local summary_opt=""
130
+ if [[ -n "$summary_module" ]]; then
131
+ summary_opt="-S $summary_module"
132
+ fi
133
+
134
+ # Get the course results from Canvas.
135
+ canvaslms results -c "$course" -A "$component" $summary_opt \
136
+ | sed -E "s/ ?[HV]T[0-9]{2}( \(.*\))?//" \
137
+ | <<[[tee]] the component results to use for course grades>> \
138
+ | ladok report -fv # Report them to LADOK.
139
+ }
140
+ @
141
+
142
+
143
+ \section{Reporting course grade}
144
+
145
+ Now we can set the course grades based on the reported components.
146
+ We'll have to report one course at a time since the course grade is based on
147
+ different components in different courses.
148
+ <<main script>>=
149
+ report_course "DD131[057] HT${YEARS}" \
150
+ LAB3
151
+ report_course "DD2520 VT${YEARS}" \
152
+ LAB1
153
+ @ We don't need to report the course grade for the other courses since they
154
+ have only one component.
155
+ For courses with only one component, LADOK will automatically set the course
156
+ grade based on the grade of the single component.
157
+
158
+ Setting the course grade can be done in several ways.
159
+ The first option is to look at what results are already attested in LADOK.
160
+ Unfortunately, this requires the round code---which we don't have access
161
+ to\footnote{%
162
+ For a brief period, IT included the round code in the course title in Canvas
163
+ at KTH.
164
+ That was beneficial in many ways, but unfortunately it faced a backlash from
165
+ teachers and it was undone.
166
+ }.
167
+ However, we can get this data from the [[canvaslms results]] line in
168
+ [[report_components]].
169
+ That's why we want to [[tee]] that data out of that pipeline.
170
+
171
+ When we [[tee]] the data out, we want to use the [[-a]] option to append if the
172
+ file already exists.
173
+ The reason for this is that we want all results for the course in one file.
174
+ But sometimes we might have to run the script several times---once for each
175
+ component.
176
+ <<[[tee]] the component results to use for course grades>>=
177
+ tee -a "${DATA_DIR}/${course}-results.csv"
178
+ <<constants>>=
179
+ DATA_DIR=`mktemp -d`
180
+ @
181
+
182
+ We'll provide a function that takes a course and a component and returns the
183
+ results for that course and component.
184
+ If no component is given, we use all components.
185
+ If we don't have results from before, we report those components to get the
186
+ data.
187
+ <<helper functions>>=
188
+ component_grades() {
189
+ local course="$1"
190
+ local component="${2:-[A-Z]{3}[0-9]+}"
191
+ local grades="${DATA_DIR}/${course}-results.csv"
192
+
193
+ if [[ ! -f "$grades" ]]; then
194
+ report_components "$course" "$component"
195
+ fi
196
+ cat "$grades" \
197
+ | grep -E "\s${component}\s" \
198
+ | sort -u
199
+ }
200
+ @ The data we get here has the following columns (tab separated):
201
+ \begin{minted}{text}
202
+ course component student grade date graders
203
+ \end{minted}
204
+
205
+ Now we can use this file when reporting the course grades.
206
+ If the file doesn't exist, we simply run [[report_components]].
207
+ If the results are not yet attested (certified), the [[ladok report]] command
208
+ will simply give an error that all components of the course are not yet
209
+ attested.
210
+
211
+ Now it's just to sort out the students and then for each student get the grade
212
+ of the component, get the latest grade date of all components and finally
213
+ report to LADOK.
214
+ <<helper functions>>=
215
+ report_course() {
216
+ local course="$1"
217
+ local component="$2"
218
+
219
+ for student in $(component_grades "$course" \
220
+ | cut -f 3)
221
+ do
222
+ local grade=$(component_grades "$course" "$component" \
223
+ | grep "$student" \
224
+ | cut -f 4)
225
+ local grade_date=$(component_grades "$course" \
226
+ | grep "$student" \
227
+ | cut -f 5 \
228
+ | sort \
229
+ | tail -n 1)
230
+
231
+ if [ "$grade" = "" ]; then
232
+ continue
233
+ fi
234
+
235
+ local course_code=$(component_grades "$course" "$component" \
236
+ | grep "$student" \
237
+ | cut -f 1 \
238
+ | sort -u)
239
+
240
+ # `component code = course code` yields final grade on course.
241
+ ladok report -fv "$course_code" "$course_code" \
242
+ "$student" "$grade" "$grade_date"
243
+ done
244
+ }
@@ -1,3 +0,0 @@
1
- We provide a Python wrapper for the LADOK3 REST API\@.
2
- We provide a useful object-oriented framework and direct API calls that return
3
- the unprocessed JSON data from LADOK.
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes