diff --git a/README.md b/README.md index 598fbf3449a5abc751a5ddcaa500d00d978dcc6b..f7c9760c9c06aba65c3517a6036d5fa66ba44c61 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,31 @@ -# coursebox +# Coursebox DTU +DTU course management software. -DTU course management \ No newline at end of file +## Installation +```terminal +pip install coursebox +``` +## What it can do + - Single semester-dependent configuration file + - Integrates with DTU Inside/DTU Learn + - Distribution/evalauation of project reports in Learn-compatible format + - Quiz-generation in DTU Learn/Beamer friendly format + - Automatic website/syllabus generation + - Automatic generation of lectures handouts/exercises (you don't have to track dynamic content like dates/lecture titles; it is all in the configuration) + - Easy compilation to 2/5 day formats (Continuous education) + +## Usage +Coursebox requires a specific directory structure. It is easier to start with an existing course and adapt to your needs. Please contact me at tuhe@dtu.dk for more information. + +## Citing +```bibtex +@online{coursebox, + title={Coursebox (0.1.1): \texttt{pip install coursebox}}, + url={https://lab.compute.dtu.dk/tuhe/coursebox}, + urldate = {2021-09-06}, + publisher={Tue Herlau}, + author={Tue Herlau}, + comments={See url{asdfsdaf} for examples}, + year={2021}, +} +``` \ No newline at end of file diff --git a/dist/coursebox-0.1.1-py3-none-any.whl b/dist/coursebox-0.1.1-py3-none-any.whl new file mode 100644 index 0000000000000000000000000000000000000000..c1c51a932f4e6547b3bd219ac400208debf80fb3 Binary files /dev/null and b/dist/coursebox-0.1.1-py3-none-any.whl differ diff --git a/dist/coursebox-0.1.1.tar.gz b/dist/coursebox-0.1.1.tar.gz new file mode 100644 index 0000000000000000000000000000000000000000..a2a4823916f9326ba40da26002f67b9cdee37df0 Binary files /dev/null and b/dist/coursebox-0.1.1.tar.gz differ diff --git a/docs/README.jinja.md b/docs/README.jinja.md new file mode 100644 index 0000000000000000000000000000000000000000..dc1a0d7aad3d5f0569fcba672d27b676e88522d2 --- /dev/null +++ b/docs/README.jinja.md @@ -0,0 +1,23 @@ +# Coursebox DTU +DTU course management software. + +## Installation +```terminal +pip install coursebox +``` +## What it can do + - Single semester-dependent configuration file + - Integrates with DTU Inside/DTU Learn + - Distribution/evalauation of project reports in Learn-compatible format + - Quiz-generation in DTU Learn/Beamer friendly format + - Automatic website/syllabus generation + - Automatic generation of lectures handouts/exercises (you don't have to track dynamic content like dates/lecture titles; it is all in the configuration) + - Easy compilation to 2/5 day formats (Continuous education) + +## Usage +Coursebox requires a specific directory structure. It is easier to start with an existing course and adapt to your needs. Please contact me at tuhe@dtu.dk for more information. + +## Citing +```bibtex +{{bibtex}} +``` \ No newline at end of file diff --git a/docs/build_docs.py b/docs/build_docs.py new file mode 100644 index 0000000000000000000000000000000000000000..0f674b25fdb1c7c029d26c072d306733a922b4b5 --- /dev/null +++ b/docs/build_docs.py @@ -0,0 +1,13 @@ + +import jinja2 +if __name__ == "__main__": + from jinjafy.bibliography_maker import make_bibliography + bib = make_bibliography("../setup.py", "./") + # bib = '' + data = {'bibtex': bib} + + with open("README.jinja.md", 'r') as f: + s = jinja2.Environment().from_string(f.read()).render(data) + with open("../README.md", 'w') as f: + f.write(s) + diff --git a/docs/coursebox.bib b/docs/coursebox.bib new file mode 100644 index 0000000000000000000000000000000000000000..c805b7981469818b74e78c9b24b1d7a1c157ec58 --- /dev/null +++ b/docs/coursebox.bib @@ -0,0 +1,9 @@ +@online{coursebox, + title={Coursebox (0.1.1): \texttt{pip install coursebox}}, + url={https://lab.compute.dtu.dk/tuhe/coursebox}, + urldate = {2021-09-06}, + publisher={Tue Herlau}, + author={Tue Herlau}, + comments={See url{asdfsdaf} for examples}, + year={2021}, +} \ No newline at end of file diff --git a/index.tex b/index.tex new file mode 100644 index 0000000000000000000000000000000000000000..37184437f44919313e4be7b19453918d364384f7 --- /dev/null +++ b/index.tex @@ -0,0 +1,22 @@ + +\documentclass[aspectratio=43]{beamer} +\usepackage{etoolbox} +\newtoggle{overlabel_includesvgs} +\newtoggle{overlabel_includelabels} + +\toggletrue{overlabel_includesvgs} +\toggletrue{overlabel_includelabels} + +\input{beamer_slider_preamble.tex} + +\begin{document} +\begin{frame} +\maketitle +\end{frame} + +\begin{frame}\osvg{myoverlay} +\title{Slide with overlay} +This is some example text! +\end{frame} + +\end{document} diff --git a/requirements.txt b/requirements.txt index 74ad859cdbbfd93ffd7073066e0eb99a63b5eb0a..6391557b63d1ab62ba736a14ee842e51fb2623a9 100644 --- a/requirements.txt +++ b/requirements.txt @@ -9,5 +9,5 @@ matplotlib numpy pycode_similar jinjafy -slider +beamer-slider tinydb diff --git a/setup.py b/setup.py index 6395f79941d10e1847d82220b494c4339ad4e206..9e5ae5f48b976686d7494fc49fc2e7f0e63d7037 100644 --- a/setup.py +++ b/setup.py @@ -11,7 +11,7 @@ with open("README.md", "r", encoding="utf-8") as fh: # beamer-slider setuptools.setup( name="coursebox", - version="0.1.0", + version="0.1.1", author="Tue Herlau", author_email="tuhe@dtu.dk", description="A course management system currently used at DTU", @@ -30,5 +30,5 @@ setuptools.setup( package_dir={"": "src"}, packages=setuptools.find_packages(where="src"), python_requires=">=3.8", - install_requires=[str(r) for r in pkg_resources.parse_requirements('requirements.txt')], + install_requires=['openpyxl', 'tika','xlwings','pybtex','langdetect','wexpect','pexpect','matplotlib','numpy','pycode_similar','jinjafy','beamer-slider','tinydb'], ) diff --git a/src/coursebox.egg-info/PKG-INFO b/src/coursebox.egg-info/PKG-INFO index e3cfb0ff0f97c63baaed2e3d9661e7667a7c685f..f983e78026a177b883847328ceb438f5008de6d7 100644 --- a/src/coursebox.egg-info/PKG-INFO +++ b/src/coursebox.egg-info/PKG-INFO @@ -1,6 +1,6 @@ Metadata-Version: 2.1 Name: coursebox -Version: 0.1.0 +Version: 0.1.1 Summary: A course management system currently used at DTU Home-page: https://lab.compute.dtu.dk/tuhe/coursebox Author: Tue Herlau @@ -15,7 +15,7 @@ Requires-Python: >=3.8 Description-Content-Type: text/markdown License-File: LICENSE -# coursebox +# Coursebox DTU -DTU course management +DTU course management software. diff --git a/src/coursebox.egg-info/SOURCES.txt b/src/coursebox.egg-info/SOURCES.txt index a3fc7c7d05742b5d062b249657a7ea33edf3cd1d..a52feee8aeb68fe04b31153f4833158250d6589b 100644 --- a/src/coursebox.egg-info/SOURCES.txt +++ b/src/coursebox.egg-info/SOURCES.txt @@ -13,7 +13,6 @@ src/coursebox.egg-info/top_level.txt src/coursebox/book/__init__.py src/coursebox/book/exam_includer.py src/coursebox/core/__init__.py -src/coursebox/core/citations.py src/coursebox/core/info.py src/coursebox/core/info_paths.py src/coursebox/core/projects.py diff --git a/src/coursebox.egg-info/requires.txt b/src/coursebox.egg-info/requires.txt index 4414fc1e28fae46b363ba747b7a921479d85ab62..6391557b63d1ab62ba736a14ee842e51fb2623a9 100644 --- a/src/coursebox.egg-info/requires.txt +++ b/src/coursebox.egg-info/requires.txt @@ -1 +1,13 @@ -requirements.txt +openpyxl +tika +xlwings +pybtex +langdetect +wexpect +pexpect +matplotlib +numpy +pycode_similar +jinjafy +beamer-slider +tinydb diff --git a/src/coursebox/core/__pycache__/citations.cpython-38.pyc b/src/coursebox/core/__pycache__/citations.cpython-38.pyc deleted file mode 100644 index 8956e2985ebe5bced649649c27a3d2352d355dc6..0000000000000000000000000000000000000000 Binary files a/src/coursebox/core/__pycache__/citations.cpython-38.pyc and /dev/null differ diff --git a/src/coursebox/core/__pycache__/info.cpython-38.pyc b/src/coursebox/core/__pycache__/info.cpython-38.pyc index 3f839d495d781a86b5672f0951019147942b043c..7776621fd24f89ac5361a6babd38177221f59a1d 100644 Binary files a/src/coursebox/core/__pycache__/info.cpython-38.pyc and b/src/coursebox/core/__pycache__/info.cpython-38.pyc differ diff --git a/src/coursebox/core/citations.py b/src/coursebox/core/citations.py deleted file mode 100644 index 7a39334a784bce7a6be8b86a23365c380bb44a67..0000000000000000000000000000000000000000 --- a/src/coursebox/core/citations.py +++ /dev/null @@ -1,127 +0,0 @@ -import os -import pybtex -import io -# import six -from coursebox.core.info_paths import get_paths -from pybtex import plugin -from pybtex.database.input import bibtex - -def get_references(bibfile, gi): - - """ - Import and convert slides dynamically. - """ - # base_dir = paths['02450public'] + "/Notes/Latex" - bibf = bibfile #base_dir + "/library.bib" - if not os.path.exists(bibf): - return None - - # pybtex.plugin - - - pybtex_style = plugin.find_plugin('pybtex.style.formatting', 'alpha')() - pybtex_html_backend = plugin.find_plugin('pybtex.backends', 'html')() - pybtex_plain_backend = plugin.find_plugin('pybtex.backends', 'plaintext')() - - pybtex_parser = bibtex.Parser() - - with open(bibf, 'r', encoding='utf8') as f: - data = pybtex_parser.parse_stream(f) - - # Tue: This used to be: - # import six - # itv = six.itervalues(data.entries) - # itv = iter(data.entries) - data_formatted = pybtex_style.format_entries(data.entries.values()) - refs = {} - - if 'auxfile' in gi: - all_references = parse_aux(gi['auxfile'], bibtex=gi['bibtex']) - else: - all_references = {} - - for entry in data_formatted: - output = io.StringIO() - output_plain = io.StringIO() - pybtex_plain_backend.output = output_plain.write - pybtex_html_backend.output = output.write - pybtex_html_backend.write_entry(entry.key, entry.label, entry.text.render(pybtex_html_backend)) - - pybtex_plain_backend.write_entry(entry.key, entry.label, entry.text.render(pybtex_plain_backend)) - - html = output.getvalue() - plain = output_plain.getvalue() - - entry.text.parts[-2].__str__() - url = "" - for i,p in enumerate(entry.text.parts): - if "\\url" in p.__str__(): - url = entry.text.parts[i+1] - break - url = url.__str__() - i1 = html.find("\\textbf") - i2 = html.find("</span>", i1) - dht = html[i1:i2] - dht = dht[dht.find(">")+1:] - html = html[:i1] + " <b>"+dht+"</b> " + html[i2+7:] - - plain = plain.replace("\\textbf ", "") - iu = plain.find("URL") - if iu > 0: - plain = plain[:iu] - - refs[entry.key] = {'html': html, - 'plain': plain, - 'label': entry.label, - 'filename': url, - 'references': all_references} - - newref = {} - ls = lambda x: x if isinstance(x, list) else [x] - if 'tex_command' in gi: - for cmd, aux, display in zip( ls(gi['tex_command']), ls(gi['tex_aux'] ), ls( gi['tex_display'] ) ): - ax = parse_aux(aux, bibtex=gi['bibtex']) - for k in ax: - ax[k]['pyref'] = display%(ax[k]['nicelabel'],) - newref[cmd] = ax - - return refs, newref - - -def parse_aux(auxfile, bibtex): - paths = get_paths() - auxfile = os.path.join(paths['02450public'], auxfile) - if not os.path.exists(auxfile): - print(auxfile) - from warnings import warn - warn("Could not find file") - return {} - - with open(auxfile, 'r') as f: - items = f.readlines() - entries = {} - for e in items: - e = e.strip() - if e.startswith("\\newlabel") and "@cref" in e: - # print(e) - i0 = e.find("{") - i1 = e.find("@cref}") - key = e[i0+1:i1] - - j0 = e.find("{{[", i0)+3 - j1 = e.find("}", j0) - - val = e[j0:j1] - - label = val[:val.find("]")] - number = val[val.rfind("]")+1:] - - if label == "equation": - nlabel = f"eq. ({number})" - else: - nlabel = label.capitalize() + " " + number - - coderef = "\\cite[%s]{%s}"%(nlabel, bibtex) if bibtex is not None else None - entries[key] = {'pyref': coderef, 'nicelabel': nlabel, 'rawlabel': label, 'number': number} - - return entries diff --git a/src/coursebox/core/info.py b/src/coursebox/core/info.py index 31693eee1acc1377ddda1d876be7fa5ddad25449..773f4c06d81e3ce87704175d930ff41ea5eb07aa 100644 --- a/src/coursebox/core/info.py +++ b/src/coursebox/core/info.py @@ -2,8 +2,6 @@ from datetime import timedelta from datetime import datetime import coursebox # import thtools -import os -import shutil from coursebox.thtools_base import list_dict2dict_list # import jinjafy import openpyxl @@ -113,20 +111,6 @@ def first_day_of_class(info): return first_day_of_class -def find_tex_cite(s, start=0, key="\\cite"): - txt = None - i = s.find(key, start) - if i < 0: - return (i,None), None, None - j = s.find("}", i) - cite = s[i:j + 1] - - if cite.find("[") > 0: - txt = cite[cite.find("[") + 1:cite.find("]")] - - reference = cite[cite.find("{") + 1:cite.find("}")] - return (i, j), reference, txt - def lectures(info, pensum=None): ow = timedelta(days=7) d = first_day_of_class(info) @@ -267,7 +251,7 @@ def class_information(): del gi['key'] del gi['value'] - from coursebox.core.citations import get_references + from snipper.load_citations import get_references if "pensum_bib" in gi: refs, nrefs = get_references(paths['02450public'] + "/" + gi['pensum_bib'], gi) d['references'], d['new_references'] = refs, nrefs diff --git a/src/coursebox/core/projects.py b/src/coursebox/core/projects.py index f8a37d0430d803023713c921dd2dec739a9f480f..3c017f22be6afd4b56218c2957d9767486fd7015 100644 --- a/src/coursebox/core/projects.py +++ b/src/coursebox/core/projects.py @@ -12,13 +12,11 @@ from openpyxl.utils import get_column_letter import matplotlib.pyplot as plt import langdetect import xlwings as xw - from coursebox.core.projects_info import get_output_file, INSTRUCTOR_ROW, STUDENT_ID_ROW, parse_column from coursebox.core.projects_info import EVALUATION_ROW_END, EVALUATION_ROW_START, WEIGHT_ROW_START, RANGE_MIN_COL, DELTA_ALLOWED_ROW from coursebox.core.info import get_paths, class_information, semester_id from coursebox.core import projects_info from coursebox.core.projects_plagiarism import plagiarism_checker - from jinjafy.cache import cache_contains_dir, cache_update_dir from jinjafy.plot.plot_helpers import get_colors import time diff --git a/src/coursebox/material/homepage_lectures_exercises.py b/src/coursebox/material/homepage_lectures_exercises.py index b225ab87b393c5be9808e71c5161213a78aadde0..f3f71f2e430da73652be54d6819c190ed148c349 100644 --- a/src/coursebox/material/homepage_lectures_exercises.py +++ b/src/coursebox/material/homepage_lectures_exercises.py @@ -10,7 +10,7 @@ from jinjafy import jinjafy_template from coursebox.core.info_paths import get_paths from slider.legacy_importer import slide_to_image from slider.legacy_importer import li_import -from slider.slider import set_svg_background_images +from slider.slide import set_svg_background_images from coursebox.book.exam_includer import HOMEWORK_PROBLEMS from coursebox.core.info import class_information from coursebox.material.lecture_questions import lecture_question_compiler diff --git a/src/coursebox/material/lecture_questions.py b/src/coursebox/material/lecture_questions.py index 5991e4f76a28995db83d09c4fbd90385e7dbfd84..1e35f27662dfece72fb631798ecb664f884ee80a 100644 --- a/src/coursebox/material/lecture_questions.py +++ b/src/coursebox/material/lecture_questions.py @@ -5,7 +5,7 @@ import glob from jinjafy import jinjafy_template from slider import latexmk from coursebox.thtools_base import execute_command -from slider.slider import slide_no_by_text, recursive_tex_apply +from slider.slide import slide_no_by_text, recursive_tex_apply from slider.legacy_importer import slide_to_image diff --git a/src/coursebox/material/snipper.py b/src/coursebox/material/snipper.py index b0bee23a70410914dca22c4856fbb19900d3b0d9..05fd862fdb482abadcc2f4873394a365714d1c33 100644 --- a/src/coursebox/material/snipper.py +++ b/src/coursebox/material/snipper.py @@ -1,4 +1,4 @@ -from coursebox.core.info import find_tex_cite +from snipper.load_citations import find_tex_cite import os import functools from jinjafy import execute_command