initial stab in restructuring and generating curricula
This commit is contained in:
parent
010aa5e72f
commit
4fca7c7bae
14 changed files with 172 additions and 137 deletions
|
@ -11,16 +11,17 @@ actual values are kept in YAML files in order to version them with git.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from argparse import ArgumentParser
|
from argparse import ArgumentParser
|
||||||
import yaml
|
|
||||||
import string
|
import string
|
||||||
import os,sys
|
import os,sys
|
||||||
|
import yaml
|
||||||
|
import pandas as pd
|
||||||
|
|
||||||
|
|
||||||
from tablegenerator import TableGenerator
|
from tablegenerator import TableGenerator
|
||||||
from markdowngenerator import MarkdownGenerator
|
from markdowngenerator import MarkdownGenerator
|
||||||
from templategenerator import TemplateGenerator
|
from templategenerator import TemplateGenerator
|
||||||
from metagenerator import MetaGenerator
|
from metagenerator import MetaGenerator
|
||||||
|
|
||||||
|
|
||||||
class CourseBuilder:
|
class CourseBuilder:
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
@ -39,6 +40,9 @@ class CourseBuilder:
|
||||||
parser.add_argument('--level',type=int,default=1,help="level of header tags")
|
parser.add_argument('--level',type=int,default=1,help="level of header tags")
|
||||||
parser.add_argument('--table-gen',type=str,default=None,help='runs table generator')
|
parser.add_argument('--table-gen',type=str,default=None,help='runs table generator')
|
||||||
parser.add_argument('--template',type=str,default=None,help='defines a template to be used with fields')
|
parser.add_argument('--template',type=str,default=None,help='defines a template to be used with fields')
|
||||||
|
parser.add_argument('-o','--out',type=str,default=None,help='set the output type')
|
||||||
|
|
||||||
|
parser.add_argument('--maxcol',type=int,default=28,help='maximum size of left column')
|
||||||
|
|
||||||
# get arguments
|
# get arguments
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
@ -114,14 +118,21 @@ class CourseBuilder:
|
||||||
generator = MetaGenerator()
|
generator = MetaGenerator()
|
||||||
generator.set_schema(actual_schema)
|
generator.set_schema(actual_schema)
|
||||||
|
|
||||||
table_items = generator.process(yaml.load(fm,Loader=yaml.Loader),fields=actual_fields,lang=args.lang,pagebreak=args.pagebreak,createTitle=args.title,header_level=args.level,template=args.template)
|
meta = yaml.load(fm,Loader=yaml.Loader)
|
||||||
|
|
||||||
if args.template:
|
table_items = generator.process(meta=meta,fields=actual_fields,lang=args.lang)
|
||||||
TemplateGenerator.generate(table_items)
|
|
||||||
else:
|
|
||||||
MarkdownGenerator.generate(table_items,pagebreak=args.pagebreak,title=args.title,header_level=args.level)
|
|
||||||
|
|
||||||
# print(table_items)
|
df = pd.DataFrame(table_items)
|
||||||
|
df.columns = df.iloc[0]
|
||||||
|
df = df[1:]
|
||||||
|
print(df.to_markdown(tablefmt='grid', index=False, maxcolwidths=[args.maxcol,None]))
|
||||||
|
print('\n')
|
||||||
|
|
||||||
|
if args.pagebreak:
|
||||||
|
print('\\pagebreak')
|
||||||
|
|
||||||
|
|
||||||
|
# MarkdownGenerator.generate(table_items,pagebreak=args.pagebreak,title=args.title,header_level=args.level)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
parser.print_help()
|
parser.print_help()
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
import os,string,sys
|
import os,string,sys
|
||||||
import yaml
|
|
||||||
|
|
||||||
class MetaGenerator:
|
class MetaGenerator:
|
||||||
|
|
||||||
|
@ -92,7 +91,7 @@ class MetaGenerator:
|
||||||
return [k,', '.join(parts)]
|
return [k,', '.join(parts)]
|
||||||
|
|
||||||
|
|
||||||
def process(self,meta,fields = [],lang = 'de',pagebreak = False,createTitle=False,header_level=1,template=None):
|
def process(self,meta,fields = [],lang = 'de'):
|
||||||
|
|
||||||
table_items = []
|
table_items = []
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,8 @@ import string
|
||||||
import tempfile
|
import tempfile
|
||||||
import subprocess
|
import subprocess
|
||||||
import os
|
import os
|
||||||
|
import pandas as pd
|
||||||
|
import tabulate
|
||||||
|
|
||||||
class TableGenerator:
|
class TableGenerator:
|
||||||
"""
|
"""
|
||||||
|
|
7
requirements.txt
Normal file
7
requirements.txt
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
numpy==1.26.4
|
||||||
|
pandas==2.2.2
|
||||||
|
python-dateutil==2.9.0.post0
|
||||||
|
pytz==2024.1
|
||||||
|
six==1.16.0
|
||||||
|
tabulate==0.9.0
|
||||||
|
tzdata==2024.1
|
38
test/Makefile
Normal file
38
test/Makefile
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
|
||||||
|
build_dir := build
|
||||||
|
target_en := ${build_dir}/table.en.pdf
|
||||||
|
target_de := ${build_dir}/table.de.pdf
|
||||||
|
|
||||||
|
target_flags := --template pandoc-template/eisvogel.latex
|
||||||
|
|
||||||
|
coursebuilder := ../coursebuilder
|
||||||
|
|
||||||
|
${target_en}:
|
||||||
|
@echo "creating English version ..."
|
||||||
|
mkdir -p ${build_dir}
|
||||||
|
python ${coursebuilder} -s schema.yaml -m mod.cg.yaml -l en -f fields.yaml | pandoc ${target_flags} -o ${target_en}
|
||||||
|
|
||||||
|
${target_de}:
|
||||||
|
@echo "creating German version ..."
|
||||||
|
mkdir -p ${build_dir}
|
||||||
|
python ${coursebuilder} -s schema.yaml -m mod.cg.yaml -l de -f fields.yaml | pandoc ${target_flags} -o ${target_de}
|
||||||
|
|
||||||
|
all: ${target_de} ${target_en}
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm ${target_de} ${target_en}
|
||||||
|
|
||||||
|
# debug-template:
|
||||||
|
# python ${coursebuilder} -s schema.yaml -m mod.cg.yaml mod.interactsys.yaml -l de -f name credits goal content --template "$$name | $$credits"
|
||||||
|
|
||||||
|
# debug-markdown:
|
||||||
|
# python ${coursebuilder} -s schema.yaml -m mod.cg.yaml mod.interactsys.yaml -l de -f name credits
|
||||||
|
|
||||||
|
# debug-book:
|
||||||
|
# python ${coursebuilder} -s schema.yaml -b book.yaml -l de
|
||||||
|
|
||||||
|
debug:
|
||||||
|
python ${coursebuilder} -s schema.yaml -m mod.cg.yaml mod.interactsys.yaml mod.test.yaml -l de -f name credits goal content | pandoc ${target_flags} -V lang:de -o ${target_de}
|
||||||
|
|
||||||
|
|
||||||
|
.PHONY: clean
|
|
@ -33,5 +33,6 @@ book:
|
||||||
en: "## elective courses {.unnumbered}"
|
en: "## elective courses {.unnumbered}"
|
||||||
- modules:
|
- modules:
|
||||||
- mod.interactsys.yaml
|
- mod.interactsys.yaml
|
||||||
|
- mod.test.yaml
|
||||||
|
|
||||||
|
|
103
test/mod.test.yaml
Normal file
103
test/mod.test.yaml
Normal file
|
@ -0,0 +1,103 @@
|
||||||
|
name:
|
||||||
|
de: Test Vorlesung
|
||||||
|
en: Lecture of Test
|
||||||
|
|
||||||
|
|
||||||
|
id:
|
||||||
|
value: Test
|
||||||
|
|
||||||
|
credits:
|
||||||
|
value: 5
|
||||||
|
|
||||||
|
form-of-exam:
|
||||||
|
value: written
|
||||||
|
|
||||||
|
form-of-instruction:
|
||||||
|
value: { 'lecture': 2, 'exersise': 1 }
|
||||||
|
|
||||||
|
term:
|
||||||
|
value: [1, 3]
|
||||||
|
|
||||||
|
duration:
|
||||||
|
value: 1
|
||||||
|
|
||||||
|
kind:
|
||||||
|
value: compulsory
|
||||||
|
|
||||||
|
goal:
|
||||||
|
de: |
|
||||||
|
**What is it**
|
||||||
|
|
||||||
|
Lorem Ipsum is simply dummy text of the printing and typesetting
|
||||||
|
industry. Lorem Ipsum has been the industry's standard dummy text
|
||||||
|
ever since the 1500s, when an unknown printer took a galley of type
|
||||||
|
and scrambled it to make a type specimen book. It has survived not only
|
||||||
|
five centuries, but also the leap into electronic typesetting, remaining
|
||||||
|
essentially unchanged. It was popularised in the 1960s with the release
|
||||||
|
of Letraset sheets containing Lorem Ipsum passages, and more recently with
|
||||||
|
desktop publishing software like Aldus PageMaker including versions of
|
||||||
|
Lorem Ipsum.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
en: |
|
||||||
|
|
||||||
|
|
||||||
|
content:
|
||||||
|
de: |
|
||||||
|
**Where did it come from**
|
||||||
|
|
||||||
|
Contrary to popular belief, Lorem Ipsum is not simply random text.
|
||||||
|
It has roots in a piece of classical Latin literature from 45 BC,
|
||||||
|
making it over 2000 years old. Richard McClintock, a Latin professor
|
||||||
|
at Hampden-Sydney College in Virginia, looked up one of the more
|
||||||
|
obscure Latin words, consectetur, from a Lorem Ipsum passage, and
|
||||||
|
going through the cites of the word in classical literature,
|
||||||
|
discovered the undoubtable source. Lorem Ipsum comes from sections
|
||||||
|
1.10.32 and 1.10.33 of "de Finibus Bonorum et Malorum" (The
|
||||||
|
Extremes of Good and Evil) by Cicero, written in 45 BC. This book
|
||||||
|
is a treatise on the theory of ethics, very popular during the
|
||||||
|
Renaissance. The first line of Lorem Ipsum, "Lorem ipsum dolor
|
||||||
|
sit amet..", comes from a line in section 1.10.32.
|
||||||
|
|
||||||
|
|
||||||
|
en: |
|
||||||
|
|
||||||
|
|
||||||
|
teaching-material:
|
||||||
|
de: |
|
||||||
|
|
||||||
|
en: |
|
||||||
|
|
||||||
|
|
||||||
|
prerequisites:
|
||||||
|
de: ""
|
||||||
|
en: ""
|
||||||
|
|
||||||
|
author-of-indenture:
|
||||||
|
de: ""
|
||||||
|
en: ""
|
||||||
|
|
||||||
|
used-in:
|
||||||
|
de: "Master Applied Computerscience"
|
||||||
|
en: "Master Applied Computerscience"
|
||||||
|
|
||||||
|
workload:
|
||||||
|
de: "2SWS Vorlesung 1SWS Übung"
|
||||||
|
en: "2SWS lecture 1SWS exersise"
|
||||||
|
|
||||||
|
form-of-exam:
|
||||||
|
value: written
|
||||||
|
spec:
|
||||||
|
de: "120min Klausur"
|
||||||
|
en: "120min exam"
|
||||||
|
|
||||||
|
frequency:
|
||||||
|
value: once_per_year
|
||||||
|
|
||||||
|
kind:
|
||||||
|
value: compulsory
|
||||||
|
|
||||||
|
remarks:
|
||||||
|
de:
|
||||||
|
en:
|
|
@ -1,28 +0,0 @@
|
||||||
|
|
||||||
coursebuilder := ../../coursebuilder
|
|
||||||
|
|
||||||
table.en.pdf:
|
|
||||||
@echo "creating English version ..."
|
|
||||||
python ${coursebuilder} -s schema.yaml -m mod.cg.yaml -l en -f fields.yaml | pandoc --template pandoc-template/eisvogel.latex -o table.en.pdf
|
|
||||||
|
|
||||||
table.de.pdf:
|
|
||||||
@echo "creating German version ..."
|
|
||||||
python ${coursebuilder} -s schema.yaml -m mod.cg.yaml -l de -f fields.yaml | pandoc --template pandoc-template/eisvogel.latex -o table.de.pdf
|
|
||||||
|
|
||||||
all: table.en.pdf table.de.pdf
|
|
||||||
|
|
||||||
clean:
|
|
||||||
rm -f table.en.pdf table.de.pdf
|
|
||||||
|
|
||||||
debug-template:
|
|
||||||
python ${coursebuilder} -s schema.yaml -m mod.cg.yaml mod.interactsys.yaml -l de -f name credits --template "$$name | $$credits"
|
|
||||||
|
|
||||||
debug-markdown:
|
|
||||||
python ${coursebuilder} -s schema.yaml -m mod.cg.yaml mod.interactsys.yaml -l de -f name credits
|
|
||||||
|
|
||||||
debug-book:
|
|
||||||
python ${coursebuilder} -s schema.yaml -b book.yaml -l de
|
|
||||||
|
|
||||||
debug:
|
|
||||||
python ${coursebuilder} -s schema.yaml -m mod.cg.yaml -l de -f fields.yaml
|
|
||||||
|
|
|
@ -1,98 +0,0 @@
|
||||||
|
|
||||||
name:
|
|
||||||
en: Test Course
|
|
||||||
|
|
||||||
|
|
||||||
test:
|
|
||||||
|
|
||||||
competency-table:
|
|
||||||
de:
|
|
||||||
- "Lineare Algebra": 'ABC'
|
|
||||||
- "Vector Spaces": 'A'
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#
|
|
||||||
# nested lists seem to work in Markdown only in the US style way
|
|
||||||
#
|
|
||||||
# reference here: https://meta.stackexchange.com/questions/85474/how-to-write-nested-numbered-lists
|
|
||||||
#
|
|
||||||
# note the parser actually corrects 'Tervuren' to 3 in resulting data
|
|
||||||
#
|
|
||||||
|
|
||||||
content:
|
|
||||||
en: |
|
|
||||||
1. Blah
|
|
||||||
|
|
||||||
2. Blub
|
|
||||||
|
|
||||||
1. Blah
|
|
||||||
|
|
||||||
1. Blub
|
|
||||||
|
|
||||||
1. Blah
|
|
||||||
|
|
||||||
1. Blub
|
|
||||||
|
|
||||||
1. Blah
|
|
||||||
|
|
||||||
1. Blub
|
|
||||||
|
|
||||||
1. Blah
|
|
||||||
|
|
||||||
1. Blub
|
|
||||||
|
|
||||||
3. Blah
|
|
||||||
|
|
||||||
4. Blub
|
|
||||||
|
|
||||||
<!-- break -->
|
|
||||||
|
|
||||||
5. Blah
|
|
||||||
|
|
||||||
6. Blah and Blub
|
|
||||||
|
|
||||||
1. Blah
|
|
||||||
|
|
||||||
1. Blub
|
|
||||||
|
|
||||||
7. Blah and Blub
|
|
||||||
|
|
||||||
- Blah
|
|
||||||
|
|
||||||
- Blub
|
|
||||||
|
|
||||||
- Blah
|
|
||||||
|
|
||||||
- Blub
|
|
||||||
|
|
||||||
8. Blub and Blah
|
|
||||||
|
|
||||||
- Blah
|
|
||||||
|
|
||||||
- Blub
|
|
||||||
|
|
||||||
- Blah
|
|
||||||
|
|
||||||
- Blub
|
|
||||||
|
|
||||||
- Blah
|
|
||||||
|
|
||||||
- Blub
|
|
||||||
|
|
||||||
- Blah
|
|
||||||
|
|
||||||
- Blub
|
|
||||||
|
|
||||||
9. Blah, Blub and Blub
|
|
||||||
|
|
||||||
- Blah
|
|
||||||
|
|
||||||
- Blub
|
|
||||||
|
|
||||||
- Blah
|
|
||||||
|
|
||||||
- Blub
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue