1/33 The Canvas learning management system and L A T EXML The L A T EX workflow is still the best Will Robertson July 20, 2018
2/33 Introduction What is a learning management system? Specifications for the project The authoring interface Which ‘HTML’ tool to choose? L A T EXML overview The Canvas programming interface The generated html page Images and files Uncertainties Benefits of scripting Canvas Conclusion
3/33 T Benefits of scripting Canvas Uncertainties Images and files The generated html page The Canvas programming interface EXML overview A Introduction L Which ‘HTML’ tool to choose? The authoring interface Specifications for the project What is a learning management system? Introduction Conclusion
4/33 Introduction Background its LMS A T EXML… • The University of Adelaide recently switched to Canvas as • The LMS has an API! • I wanted to sensibly manage ‘content’ • Generate both HTML and PDF • A good excuse to learn L
5/33 Introduction What is a learning management system? This is an LMS
6/33 Introduction Specifications for the project Motivation 1. In the old days, had a monolithic (impossible) Word file 2. Care and maintenance of content 3. Re-use of content for a comprehensive PDF (for students, for supervisors, for accreditation) • Click click click • No good tools to manage content globally • ‘One stop shop’ for reference • Handy to be able to distribute
7/33 Introduction Specifications for the project A T EX based (sorry, not sorry) • One source, multiple outputs • Macros to ensure up-to-date info • Names of certain people • Due dates • Weightings of assessments • Reliable (easy setup, actively developed, etc.) • L
8/33 T Benefits of scripting Canvas Uncertainties Images and files The generated html page The Canvas programming interface EXML overview A The authoring interface L Which ‘HTML’ tool to choose? The authoring interface Specifications for the project What is a learning management system? Introduction Conclusion
9/33 The authoring interface EX Live EX Live EXML — Perl, not in T A T EX Live (951 p. manual) EX Live EX4ht — (?), in T EX to html possibilities, including: T A A number of L Which ‘HTML’ tool to choose? (Non-exhaustive list. All are actively developed.) • T • lwarp — Lua, in T • L • HEVEA — OCaml, not in T
10/33 The authoring interface Which ‘HTML’ tool to choose? A T EXML, and I’ve been happy (enough) with it to date. • Hopefully the choice is not too important! • I.e., the conversion aspect should be modular • I wanted to try L
11/33 EX scanning in Perl Anyway, the basics works well: EX 2 𝜁 , Perl, XSLT, HTML, CSS, … T A A combination of L A T The authoring interface \newcommand\honourscoord{Will Robertson} Caveat: I’m only a user! EXML A T Architecture of L EXML overview T A L • Reimplements some T • Therefore handles basic L EX2 𝜁 programming • \newcommand • \newcounter , \stepcounter • etc. • Provides Perl interfaces to emulate classes and packages
12/33 Two-phase process: latexml then latexmlpost --splitat=chapter \ --destination=html/$FILENAME.html \ --format=html5 \ --sourcedirectory=tex \ --xsltparameter=SIMPLIFY_HTML:true \ latexml tex/$FILENAME.tex | latexmlpost - \ EXML The authoring interface T A Running L EXML overview T A L --splitnaming=label
13/33 T Benefits of scripting Canvas Uncertainties Images and files The generated html page The Canvas programming interface EXML overview A The Canvas programming interface L Which ‘HTML’ tool to choose? The authoring interface Specifications for the project What is a learning management system? Introduction Conclusion
14/33 The Canvas programming interface Canvas programming Wikipedia: ‘REST-compliant web services allow the requesting systems to access and manipulate textual representations of web resources by using a uniform and predefined set of stateless operations.’ curl -X GET -H "$CANVASAUTH" $CANVASCOURSE/$1 assignments?search_term=charter etc. curl -X GET -H 'Authorization: Bearer 81...Jx' https://myuni.adelaide.edu.au/api/v1/courses/36028/assignments • A so-called rest api • Using curl : • $CANVASAUTH = secret token • $CANVASCOURSE = url to course • $1 = users or rubrics or • E.g.:
15/33 The Canvas programming interface curl -X POST -H "$CANVASAUTH" "$LOC" | jq ; LOC=${LOC%$'\r'} LOC=`sed -n -e 's/Location: \(.*\)/\1/p' response.tmp`; echo curl -D response.tmp $URL $KEYS -F file=@$1 | bash ; "to_entries | map(\"-F \(.key)=\(.value|tostring) \")|.[]"` ; KEYS=`cat tmp.json | jq '.upload_params' | jq -r -j \ URL=`cat tmp.json | jq '.upload_url'` ; -F "name=$1" -F "parent_folder_path=upload" > tmp.json ; -H "$CANVASAUTH" "$CANVASCOURSE/files"\ curl -X POST Clear as mud Uploading a file to Canvas after updating content. • I have forgotten how this works! • Allows me to, say, upload the typeset PDF automatically
16/33 The Canvas programming interface Evolution of my support scripts assignments’, say) is returned in multiple ‘pages’ so iteration is required • Started with curl • A few small-ish Bash functions and scripts • Have now started with Lua programming • Requesting data with many items (‘all submitted • Much prefer doing real programming not in Bash • Start looking into the Lua package ecosystem
17/33 The Canvas programming interface Package proliferation: not just a L A T EX problem • luajson by harningt • lunajson by grafi • rapidjson by xpol • dkjson by dhkolf • jwt-jitsi by pawelgawel88 • JSON4Lua by luarocks • jwt by olivine-labs • mjolnir._asm.data.json by _asm • ngxjsonform by rtbz • dromozoa-json by moyu • lua-cjson-ol by olivine-labs • lua-cjson2 by CriztianiX • json-lua by jiyinyiyong • …
18/33 headers = { } sink = ltn12.sink.table(canvas_result), }, = "application/json" ["content-type"] ["authorization"] = "Bearer " .. canvas_token, url = canvas_url .. req .. "?" .. opt, The Canvas programming interface method = "GET", local body, code, headers, status = http.request{ = require("ltn12") local ltn12 = require("ssl.https") local http Lua equivalent to curl • This returns json, which is ‘decoded’ into a Lua table.
19/33 T Benefits of scripting Canvas Uncertainties Images and files The generated html page The Canvas programming interface EXML overview A The generated html page L Which ‘HTML’ tool to choose? The authoring interface Specifications for the project What is a learning management system? Introduction Conclusion
20/33 \tableofcontents \input{../pages/course-schedule} \input{../pages/introduction} \label{part-intro} \part{Introduction} \input{../texdata/data-marks.tex} \input{../texdata/data-limits.tex} \maketitle The generated html page \title{...}\author{...}\date{...} \begin{document} ... \usepackage{latexml} \documentclass{report} The source \input{../pages/week-planner}
21/33 The generated html page \chapter{Introduction} \label{introduction}% same as filename! ... A T EXML does not convert file by file .tex file • Each .tex file contains one chapter: • L • Rather, output html is split by chapter • With consistent naming, this produces one .html file per • A ‘table of contents’ page is also generated
22/33 The generated html page Top matter <!DOCTYPE html> <html> <head> <title> XX Chapter title </title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <link rel="stylesheet" href="LaTeXML.css" type="text/css"> [...] </head> <body>
23/33 The generated html page Bottom matter <footer class="ltx_page_footer"> [...] </footer> </div> </body> </html>
24/33 Title of chapter goes here </section> </section> [...] ALL THE CONTENT [...] <section id="S1" class="ltx_section"> <div class="ltx_date ltx_role_creation"></div> </h1> <span class="ltx_tag ltx_tag_chapter"> Chapter X </span> The generated html page <h1 class="ltx_title ltx_title_chapter"> <section class="ltx_chapter ltx_authors_1line"> <div class="ltx_page_content"> </header> [...] <header class="ltx_page_header"> <div class="ltx_page_main"> ‘Content’ </div>
25/33 The generated html page ‘Content’ <section class="ltx_chapter ltx_authors_1line"> <h1 class="ltx_title ltx_title_chapter"> <span class="ltx_tag ltx_tag_chapter"> Chapter X </span> Title of chapter goes here </h1> <div class="ltx_date ltx_role_creation"></div> <section id="S1" class="ltx_section"> [...] ALL THE CONTENT [...] </section> </section>
26/33 The generated html page One line of awk awk '/\<section.*\>/,/\<\/section\>/' \ html/$BASE >> snip/$BASE but unnecessary for me since I want html anyway. • Snipping is done with • Possible to take the raw xml and develop own workflows,
Recommend
More recommend