Skip to content
Snippets Groups Projects
Commit a7bc3fdb authored by tuhe's avatar tuhe
Browse files

Updates to handin/handout dates

parent 61ec4d14
Branches main
No related tags found
No related merge requests found
...@@ -4,18 +4,16 @@ ...@@ -4,18 +4,16 @@
""" """
Windows> py -m build && twine upload dist/* Windows> py -m build && twine upload dist/*
Linux> python -m build && python -m twine upload dist/* Linux> python -m build && python -m twine upload dist/*
""" """
import setuptools import setuptools
import pkg_resources
with open("README.md", "r", encoding="utf-8") as fh: with open("README.md", "r", encoding="utf-8") as fh:
long_description = fh.read() long_description = fh.read()
# beamer-slider
setuptools.setup( setuptools.setup(
name="coursebox", name="coursebox",
version="0.1.18.13", version="0.1.18.20",
author="Tue Herlau", author="Tue Herlau",
author_email="tuhe@dtu.dk", author_email="tuhe@dtu.dk",
description="A course management system currently used at DTU", description="A course management system currently used at DTU",
...@@ -34,5 +32,6 @@ setuptools.setup( ...@@ -34,5 +32,6 @@ setuptools.setup(
package_dir={"": "src"}, package_dir={"": "src"},
packages=setuptools.find_packages(where="src"), packages=setuptools.find_packages(where="src"),
python_requires=">=3.8", python_requires=">=3.8",
install_requires=['numpy','pycode_similar','tika','openpyxl', 'xlwings','matplotlib','langdetect','beamer-slider','tinydb'], install_requires=['numpy','pycode_similar','tika','openpyxl', 'xlwings','matplotlib','langdetect',
'beamer-slider','tinydb', 'python-gitlab'],
) )
Metadata-Version: 2.1 Metadata-Version: 2.1
Name: coursebox Name: coursebox
Version: 0.1.18.13 Version: 0.1.18.19
Summary: A course management system currently used at DTU Summary: A course management system currently used at DTU
Home-page: https://lab.compute.dtu.dk/tuhe/coursebox Home-page: https://lab.compute.dtu.dk/tuhe/coursebox
Author: Tue Herlau Author: Tue Herlau
......
...@@ -7,3 +7,4 @@ matplotlib ...@@ -7,3 +7,4 @@ matplotlib
langdetect langdetect
beamer-slider beamer-slider
tinydb tinydb
python-gitlab
import datetime
import gitlab import gitlab
import gitlab.const import gitlab.const
from urllib.parse import urlparse from urllib.parse import urlparse
...@@ -27,17 +29,24 @@ def sync_tas_with_git(): ...@@ -27,17 +29,24 @@ def sync_tas_with_git():
for i in p.invitations.list(): for i in p.invitations.list():
print("Invited", i.invite_email.split("@")) print("Invited", i.invite_email.split("@"))
if False: if True:
inv = p.invitations.create({ for i in info['instructors']:
"email": "fmry@dtu.dk", # i = info['instructors'][2]
"access_level": gitlab.const.AccessLevel.MAINTAINER, if i['email'].split("@")[0].strip() in all_tas:
}) print("TA found already", i['name'], i['email'])
inv.save() else:
import datetime
expires = datetime.datetime.now() + datetime.timedelta(days=30*5+14)
expires_str =expires.strftime('%A %b %d, %Y at %H:%M GMT')
inv = p.invitations.create({
"email": i['email'], # '"fmry@dtu.dk",
"access_level": gitlab.const.AccessLevel.MAINTAINER,
"expires_at": expires_str,
})
inv.save()
print("Inviting...", i['email'], i['name'])
#
#
#
#
# for p in gl.projects.list(iterator=True): # for p in gl.projects.list(iterator=True):
# prs.append(p) # prs.append(p)
# for p in prs: # for p in prs:
......
...@@ -429,7 +429,7 @@ def class_information(verbose=False, ...@@ -429,7 +429,7 @@ def class_information(verbose=False,
if 'id' in r: if 'id' in r:
d['reports'][r['id']] = r d['reports'][r['id']] = r
r['handin'] = get_lecture_date(r['handin'], delta_days=int(d['handin_day_delta'])) r['handin'] = get_lecture_date(r['handin'], delta_days=int(d['handin_day_delta']))
r['handout'] = get_lecture_date(r['handout'], delta_days=0) r['handout'] = get_lecture_date(r['handout'], delta_days=int(d.get('handout_day_delta', 0)))
r['exercises'] = [e.strip() for e in r['exercises'].split(",") if len(e.strip()) > 0] r['exercises'] = [e.strip() for e in r['exercises'].split(",") if len(e.strip()) > 0]
ice = xlsx_to_dicts(paths['information.xlsx'], sheet='ce', as_dict_list=True) ice = xlsx_to_dicts(paths['information.xlsx'], sheet='ce', as_dict_list=True)
...@@ -495,7 +495,7 @@ def _save_info_cache(): ...@@ -495,7 +495,7 @@ def _save_info_cache():
known[id] = f"s{len(known):6d}".replace(" ", "0") known[id] = f"s{len(known):6d}".replace(" ", "0")
d = d.replace(id, known[id]) d = d.replace(id, known[id])
elif isinstance(d, dict): elif isinstance(d, dict):
for k, v in d.items(): for k, v in d.copy().items():
d[_remove_ids(k)] = _remove_ids(v) d[_remove_ids(k)] = _remove_ids(v)
elif isinstance(d, list): elif isinstance(d, list):
d = [_remove_ids(k) for k in d] d = [_remove_ids(k) for k in d]
......
...@@ -72,6 +72,9 @@ def get_paths(): ...@@ -72,6 +72,9 @@ def get_paths():
if not os.path.isdir(paths['book']): if not os.path.isdir(paths['book']):
paths['book'] = root_02450public + "/Notes/Latex" paths['book'] = root_02450public + "/Notes/Latex"
# if 'book' in paths and os.path.isdir(paths['book']):
# pass
if os.path.exists(os.path.dirname(paths['instructor_project_evaluations'])): if os.path.exists(os.path.dirname(paths['instructor_project_evaluations'])):
if not os.path.isdir(paths['instructor_project_evaluations']): if not os.path.isdir(paths['instructor_project_evaluations']):
os.mkdir(paths['instructor_project_evaluations']) os.mkdir(paths['instructor_project_evaluations'])
......
...@@ -92,11 +92,16 @@ def make_lectures(week=None, mode=0, gather_pdf_out=True, gather_sixup=True, mak ...@@ -92,11 +92,16 @@ def make_lectures(week=None, mode=0, gather_pdf_out=True, gather_sixup=True, mak
mode = HANDOUT = 2: version handed out to students. mode = HANDOUT = 2: version handed out to students.
""" """
assert mode in [PRESENTATION, NOTES, HANDOUT] assert mode in [PRESENTATION, NOTES, HANDOUT]
paths = get_paths() paths = get_paths()
info = class_information()
if 'lecture_notes_tex' in info:
book_pdf = paths['02450public'] + "/" + info['lecture_notes_tex'][:-4] + ".pdf"
else:
book_pdf = paths['book'] + "/02002_Notes.pdf"
if os.path.exists(paths['book']): if os.path.exists(paths['book']):
book_frontpage_png = paths['shared']+"/figures/book.png" #paths['lectures']+"/static/book.png" book_frontpage_png = paths['shared']+"/figures/book.png" #paths['lectures']+"/static/book.png"
slide_to_image(paths['book'] + "/02450_Book.pdf", book_frontpage_png, page_to_take=1) slide_to_image(book_pdf, book_frontpage_png, page_to_take=1)
shutil.copy(paths['book'] + "/book_preamble.tex", paths['shared']) shutil.copy(paths['book'] + "/book_preamble.tex", paths['shared'])
info = class_information() info = class_information()
jinjafy_shared_templates_dir(paths, info) # Compile templates in shared/templates jinjafy_shared_templates_dir(paths, info) # Compile templates in shared/templates
...@@ -389,10 +394,12 @@ def fix_shared(paths, output_dir, pdf2png=False,dosvg=True,verbose=False, compil ...@@ -389,10 +394,12 @@ def fix_shared(paths, output_dir, pdf2png=False,dosvg=True,verbose=False, compil
# update_source_cache = False # update_source_cache = False
source_extra = {} source_extra = {}
for rel in source: for rel in source:
if rel.endswith(".svg") and source[rel]['modified'] and dosvg: if rel.endswith(".svg"):
pdf_file = svg2pdf(shared_base + "/"+rel, crop=True, text_to_path=True) pdf_ = shared_base + "/"+rel[:-4] + ".pdf"
rel = os.path.relpath(pdf_file, shared_base) if (source[rel]['modified'] or not os.path.isfile(pdf_)) and dosvg:
source_extra[rel] = dict(mtime=os.path.getmtime(pdf_file), hash=hash_file_(pdf_file), modified=True) pdf_file = svg2pdf(shared_base + "/"+rel, crop=True, text_to_path=True)
rel = os.path.relpath(pdf_file, shared_base)
source_extra[rel] = dict(mtime=os.path.getmtime(pdf_file), hash=hash_file_(pdf_file), modified=True)
for k, v in source_extra.items(): for k, v in source_extra.items():
source[k] = v source[k] = v
...@@ -415,12 +422,14 @@ def fix_shared(paths, output_dir, pdf2png=False,dosvg=True,verbose=False, compil ...@@ -415,12 +422,14 @@ def fix_shared(paths, output_dir, pdf2png=False,dosvg=True,verbose=False, compil
if pdf2png: if pdf2png:
for rel in target: for rel in target:
if rel.endswith(".pdf") and target[rel]['modified']: if rel.endswith(".pdf"):
# print("pdf2png: ") png_target = output_dir + "/" + rel[:-4] + ".png"
png = convert.pdf2png(output_dir + "/" + rel, verbose=True) if target[rel]['modified'] or not os.path.isfile(png_target):
target[rel]['modified'] = False # print("pdf2png: ")
target[rel]['hash'] = hash_file_(output_dir + "/" + rel) png = convert.pdf2png(output_dir + "/" + rel, verbose=True)
target[rel]['mtime'] = os.path.getmtime(output_dir + "/" + rel) target[rel]['modified'] = False
target[rel]['hash'] = hash_file_(output_dir + "/" + rel)
target[rel]['mtime'] = os.path.getmtime(output_dir + "/" + rel)
with open(shared_base + "/sharedcache.pkl", 'wb') as f: with open(shared_base + "/sharedcache.pkl", 'wb') as f:
pickle.dump(source, f) pickle.dump(source, f)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment