Upgrade to Pro — share decks privately, control downloads, hide ads and more …

The Cardiff Maths e-Learning Project

The Cardiff Maths e-Learning Project

Slides for talk given at DjangoCon Europe 2015

Dafydd Evans

June 02, 2015
Tweet

Other Decks in Programming

Transcript

  1. CaMEL The Cardiff Maths eLearning Project Dafydd Evans Cardiff School

    of Mathematics DjangoCon Europe 1st June 2015
  2. DjangoCon Europe 2015 Contents 1 Motivation 3 2 Typesetting 4

    3 The Cardiff Maths eLearning Project 9 4 Next steps 14 D Evans Cardiff School of Mathematics 2
  3. DjangoCon Europe 2015 1 Motivation Writing mathematics requires specific layouts

    and fonts. (1) Learning materials. • Teachers produce high-quality PDF documents using L A TEX. • PDF documents lack interactive capabilities. (2) Homework submission and feedback. • Students submit handwritten solutions to homework questions. • Teachers marks and returns the scripts Can L A TEX documents be used as the basis of an e-learning system for mathematics? D Evans Cardiff School of Mathematics 3
  4. DjangoCon Europe 2015 2 Typesetting • Basic building blocks are

    letters, numerals and symbols. These are collectively known as glyphs. • Groups of glyphs are called fonts. • Groups of fonts sharing particular design fea- tures are called typefaces. • Computer Modern typefaces for mathematics created by Donald Knuth for TEX (1978) • TEX extended to L A TEX by Leslie Lamport (1984). • L A TEX is the de-facto standard for typesetting mathematical articles and books. D Evans Cardiff School of Mathematics 4
  5. DjangoCon Europe 2015 2.1 Mark-up Languages LaTeX -> PDF HTML

    -> Web \documentclass{book} \title{My Book} \begin{document} %comment \maketitle \chapter{Introduction} Hello world. \begin{equation}\label{eq:gauss} \int_{- \infty }^{+ \infty} e^{-x^2}dx = \sqrt{\pi}. \end{equation} \end{document} <html > <head > <title >My Book </title > </head> <body > <!-- comment --> <h1>Introduction </h1> Hello world! <equation id="eq:gauss"> oops! </equation > </body> </html > • Mark-up used to define structure, styles, cross-references and citations. • L A TEX documents are not “well-formed”. D Evans Cardiff School of Mathematics 5
  6. DjangoCon Europe 2015 2.2 L A TEX Structural mark-up \chapter,\section,...

    \begin{equation}...\end{equation} Stylistic mark-up \textbf,\textit,... \alpha,\pi,\partial,... Cross-references and citations \label,\ref,\cite. Extensible \begin{homework}...\end{homework} \question \documentclass{camel} \title{Lecture Notes} \begin{document} \maketitle \chapter{Introduction}\label{ch:intro} Hello world. \begin{equation}\label{eq:gauss} \int_{-\infty }^{+ \infty} e^{-x^2}dx = \sqrt{\pi}. \end{equation} \chapter{Background} In Chapter~\ref{ch:intro} we saw ... \begin{homework} \begin{questions} \question Area of a circle? \begin{answer} $A = \pi r^2$ \end{answer} \end{questions} \end{homework} \end{document} D Evans Cardiff School of Mathematics 6
  7. DjangoCon Europe 2015 2.3 Yet Another L A TEX Parser

    • Implemented in python. • Source file processed using regular expressions and a stack (pushdown automaton). • Output is a so-called materialized path tree. • Numbering implemented using class variables. • Mathmode environments/commands left for MathJax to handle. latex_node_types = { level : ( book , chapter , section , subsection ), theorem : ( definition , theorem , lemma , remark , example , exercise ), mathmode : ( equation , eqnarray , array , align , cases ), list : ( itemize , enumerate , questions , parts , subparts , choices ), item : ( item , question , part , subpart , choice , correctchoice ), float : ( table , figure , subtable , subfigure ), box : ( proof , solution , answer , hint ), assignment : ( homework , mctest ), content : ( jax , image , reference , citation ), } D Evans Cardiff School of Mathematics 7
  8. DjangoCon Europe 2015 <book > <chapter label="ch:intro" number="1" title="Introduction"> <jax>Hello

    world. \begin{equation} \int_{-\infty }^{+\ infty} e^{-x^2}dx = \sqrt {\pi}. \end{equation}</jax> </chapter > <chapter number="2" title="Background"> <jax>In Chapter </jax> <ref target="ch:intro">1</ref> <jax>we saw ...</jax> <homework number="1"> <questions number="1"> <question number="1"> <jax>Area of a circle?</jax> <answer > <jax>$A = \pi r^2$</jax> </answer > </question > </questions > </homework > </chapter > </book > D Evans Cardiff School of Mathematics 8
  9. DjangoCon Europe 2015 3 The CaMEL project pdf xml latex

    doctree models database views templates web Models • BookNode: node_type, number, title, content, mpath • Label: label_text, target_mpath • Answer: user, question, text • Submission: user, assignment http://github.com/dimbyd/camel/ D Evans Cardiff School of Mathematics 9
  10. DjangoCon Europe 2015 3.1 django-mptt Modified Preorder Tree Traversal (MPTT)

    is a technique for storing and accessing hierarchical data in a database. • Retrieval operations are efficient. • Inserts, moves and deletions are comparatively expensive. The django-mptt app makes it very easy to use MPTT with Django models. • Models are defined as subclasses of mptt.models.MPTTModel. • Tree updated automatically when model instances are inserted/moved/deleted. • Instance methods: get_ancestors(), get_children(), etc. • Custom form fields provided by the mptt.forms package. • Template tags and filters for rendering trees recursively. http://github.com/django-mptt/django-mptt/ D Evans Cardiff School of Mathematics 10
  11. DjangoCon Europe 2015 models.py c l a s s BookNode(

    M P T T M o d e l ): parent = T r e e F o r e i g n K e y ( s e l f , null=True , related_name= children ) node_type = models. C h a r F i e l d (max_length =10) number = P o s i t i v e S m a l l I n t e g e r F i e l d (null=True) title = C h a r F i e l d (max_length =100, null=True , blank=False) content = T e x t F i e l d (null=True) mpath = C h a r F i e l d (max_length =100, null=True) views.py context[ chapter ] = BookNode.objects.get( pk=pk ) context[ subtree ] = context[ chapter ]. get_descendants(include_ s e l f =True) template.html {% load mptt_tags %} {% recursetree subtree %} {% if node.node_type == "chapter" %} <div class="chapter"> <h1 class="chapter">{{ node.number }}. {{ node.title }}</h1> {{ children }} </div> {% elif %} ... D Evans Cardiff School of Mathematics 11
  12. DjangoCon Europe 2015 3.2 Custom L A TEX environments for

    interaction The following were inspired by exam.cls (written by Phil Hirschhorn, MIT). Free-text answers \begin{homework} \begin{questions} \question First Question. \begin{solution} Solution of First Question. \end{solution} \question Second Question. \begin{solution} Solution of Second Question. \end{solution} \end{questions} \end{homework} Multiple-choice answers \begin{mctest} \begin{questions} \question Which is the odd one out? \begin{choices} \choice John \choice Paul \choice George \correctchoice Dingo \end{choices} \end{questions} \end{mctest} D Evans Cardiff School of Mathematics 12
  13. DjangoCon Europe 2015 3.3 Database schema student module book submission

    homework answer question D Evans Cardiff School of Mathematics 13
  14. DjangoCon Europe 2015 4 Next steps Django • Admin pages

    • Teacher pages • Visualisation • Partial updates using labels • PDFs of homework submissions • Beautify URLs Python • GitHub • Exception handling • Unit tests • Logging • DocBook and MathML schemas. D Evans Cardiff School of Mathematics 14