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

updates

parent c3117f1a
No related branches found
No related tags found
1 merge request!1Devel
...@@ -13,7 +13,7 @@ with open("README.md", "r", encoding="utf-8") as fh: ...@@ -13,7 +13,7 @@ with open("README.md", "r", encoding="utf-8") as fh:
setuptools.setup( setuptools.setup(
name="coursebox", name="coursebox",
version="0.1.18.21", version="0.1.19.6",
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",
......
Metadata-Version: 2.1 Metadata-Version: 2.1
Name: coursebox Name: coursebox
Version: 0.1.18.21 Version: 0.1.19.5
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
......
...@@ -202,7 +202,7 @@ def lectures(info, pensum=None): ...@@ -202,7 +202,7 @@ def lectures(info, pensum=None):
linfo['reading_long'] = ir.replace("C", "Chapter ") if ir else "" linfo['reading_long'] = ir.replace("C", "Chapter ") if ir else ""
hwp = linfo['homework_problems'] hwp = linfo['homework_problems']
linfo['homework_problems_long'] = hwp.replace("P", "Problem ") if hwp else "" linfo['homework_problems_long'] = str(hwp) if isinstance(hwp, int) else (hwp.replace("P", "Problem ") if hwp else "")
if linfo["learning_objectives"]: if linfo["learning_objectives"]:
linfo["learning_objectives"] = [s.strip() for s in linfo["learning_objectives"].split("\n")] linfo["learning_objectives"] = [s.strip() for s in linfo["learning_objectives"].split("\n")]
linfo['reading_rst'] = bib2rst(linfo['reading']) linfo['reading_rst'] = bib2rst(linfo['reading'])
...@@ -214,15 +214,22 @@ def bib2rst(bib): ...@@ -214,15 +214,22 @@ def bib2rst(bib):
if bib is None or 'cite' not in bib: if bib is None or 'cite' not in bib:
return bib return bib
bib = bib.split("cite")[1]
bibs = bib.strip().split(r"\cite")
b_rst = []
for bib in bibs:
if '{' not in bib:
continue
# b_rst = ""
where = None where = None
if "[" in bib: if "[" in bib:
where = bib.split("[")[1].split("]")[0] where = bib.split("[")[1].split("]")[0]
what = bib.split("{")[1].split("}")[0] what = bib.split("{")[1].split("}")[0]
if where is None: if where is None:
return f":cite:p:`{what}`" b_rst.append(f":cite:p:`{what}`")
else: else:
return f"{where}, :cite:p:`{what}`" b_rst.append(f"{where}, :cite:p:`{what}`")
return ", ".join(b_rst)
# return "" # return ""
pass pass
......
...@@ -55,7 +55,7 @@ def get_paths(): ...@@ -55,7 +55,7 @@ def get_paths():
'course_number': course_number, 'course_number': course_number,
'semester': semester_path, 'semester': semester_path,
'information.xlsx': main_conf, 'information.xlsx': main_conf,
'homepage_template': "%s/WEB/index_partial.html"%root_02450public, 'homepage_template': "%s/WEB/index_partial23.html"%root_02450public,
'homepage_out': "%s/WEB/%sindex.html"%(root_02450public, sCE), 'homepage_out': "%s/WEB/%sindex.html"%(root_02450public, sCE),
'pdf_out': "%s/%spdf_out"%(root_02450public, sCE), 'pdf_out': "%s/%spdf_out"%(root_02450public, sCE),
'exercises': root_02450public + "/Exercises", # this does not seem correct. 'exercises': root_02450public + "/Exercises", # this does not seem correct.
......
...@@ -55,7 +55,6 @@ def build_sphinx_documentation(cut_files=False, open_browser=True, build_and_cop ...@@ -55,7 +55,6 @@ def build_sphinx_documentation(cut_files=False, open_browser=True, build_and_cop
# from coursebox.material.homepage_lectures_exercises import set # from coursebox.material.homepage_lectures_exercises import set
from coursebox.student_files.student_files import setup_student_files from coursebox.student_files.student_files import setup_student_files
if os.path.isfile(d_ := f"{paths['book']}/{paths['course_number']}_Notes.pdf"): if os.path.isfile(d_ := f"{paths['book']}/{paths['course_number']}_Notes.pdf"):
book_frontpage_png = paths['shared']+"/figures/book.png" book_frontpage_png = paths['shared']+"/figures/book.png"
slide_to_image(d_, book_frontpage_png, page_to_take=1) slide_to_image(d_, book_frontpage_png, page_to_take=1)
......
...@@ -325,7 +325,7 @@ def compile_simple_files(paths, info, template_file_list, verbose=False): ...@@ -325,7 +325,7 @@ def compile_simple_files(paths, info, template_file_list, verbose=False):
if file.endswith("_template.tex"): if file.endswith("_template.tex"):
file = file.replace("_template.tex", ".tex") file = file.replace("_template.tex", ".tex")
tex_out = paths['shared_latex_compilation_dir'] + "/" + file tex_out = paths['shared_latex_compilation_dir'] + "/" + file
jinjafy_template(data=d2, file_in=fname, file_out=tex_out, filters=get_filters(), template_searchpath=paths['instructor']) jinjafy_template(data=d2, file_in=fname, file_out=tex_out, filters=get_filters(), template_searchpath=paths['exercises'])
latexmk(tex_out, pdf_out= paths['pdf_out'] + "/" + os.path.basename(tex_out)[:-4]+".pdf") latexmk(tex_out, pdf_out= paths['pdf_out'] + "/" + os.path.basename(tex_out)[:-4]+".pdf")
# rec_fix_shared(shared_base=paths['shared'], output_dir=output_dir) # rec_fix_shared(shared_base=paths['shared'], output_dir=output_dir)
...@@ -333,9 +333,6 @@ def compile_simple_files(paths, info, template_file_list, verbose=False): ...@@ -333,9 +333,6 @@ def compile_simple_files(paths, info, template_file_list, verbose=False):
# import dirsync # import dirsync
# dirsync.sync(paths['shared'], output_dir, 'diff') # dirsync.sync(paths['shared'], output_dir, 'diff')
# Do smarter fixin' # Do smarter fixin'
from pathlib import Path
# @profile # @profile
def get_hash_from_base(base): def get_hash_from_base(base):
...@@ -471,11 +468,11 @@ def make_exercises_projects_tutors(week=None, only_exercises=False, make_exercis ...@@ -471,11 +468,11 @@ def make_exercises_projects_tutors(week=None, only_exercises=False, make_exercis
info['lecture_handin'] = info['lectures'][handin_week-1] info['lecture_handin'] = info['lectures'][handin_week-1]
if info['CE']: if info['CE']:
proj_base = paths['02450instructors'] + "/ExercisesShared/%sprojectCE_Base.tex"%(course_number, ) proj_base = paths['exercises'] + "/ExercisesShared/%sprojectCE_Base.tex"%(course_number, )
proj_tex_out = paths['02450instructors'] + "/Project/latex%i/%sprojectCE.tex" % (1,course_number,) proj_tex_out = paths['exercises'] + "/Project/latex%i/%sprojectCE.tex" % (1,course_number,)
else: else:
proj_base = paths['02450instructors'] + "/ExercisesShared/%sproject%i_Base.tex" % (course_number,proj+1,) proj_base = paths['exercises'] + "/ExercisesShared/%sproject%i_Base.tex" % (course_number,proj+1,)
proj_tex_out = paths['02450instructors'] + "/Project/latex%i/%sproject%i.tex" % (proj+1, course_number, proj+1) proj_tex_out = paths['exercises'] + "/Project/latex%i/%sproject%i.tex" % (proj+1, course_number, proj+1)
info['week'] = -1 info['week'] = -1
if not os.path.exists(proj_base): if not os.path.exists(proj_base):
...@@ -533,18 +530,19 @@ def make_exercises_projects_tutors(week=None, only_exercises=False, make_exercis ...@@ -533,18 +530,19 @@ def make_exercises_projects_tutors(week=None, only_exercises=False, make_exercis
} }
# get lang dir # get lang dir
if not os.path.exists("%s/Exercises%s"%(paths['instructors'], lang)): if not os.path.exists("%s/Exercises%s"%(paths['exercises'], lang)):
continue continue
info.update(tv) info.update(tv)
ex_base = "%s/ExercisesShared/%sex%i_Base.tex"%(paths['instructors'], course_number, w) ex_base = "%s/ExercisesShared/%sex%i_Base.tex"%(paths['exercises'], course_number, w)
ex_tex_out = "%s/Exercises%s/Exercise%i/latex/%sex%i_%s.tex" % ( paths['instructors'], lang, w, course_number, w, lang) ex_tex_out = "%s/Exercises%s/Exercise%i/latex/%sex%i_%s.tex" % ( paths['exercises'], lang, w, course_number, w, lang)
# fbody = os.path.dirname(ex_tex_out) +f"/ex{w}_body.tex" # fbody = os.path.dirname(ex_tex_out) +f"/ex{w}_body.tex"
if os.path.exists(ex_base): if os.path.exists(ex_base):
jinjafy_template(info, ex_base, file_out=ex_tex_out, filters=filters, template_searchpath=paths['instructor']) jinjafy_template(info, ex_base, file_out=ex_tex_out, filters=filters, template_searchpath=paths['exercises'])
fix_shared(paths, output_dir=os.path.dirname(ex_tex_out), dosvg=dosvg) fix_shared(paths, output_dir=os.path.dirname(ex_tex_out), dosvg=dosvg)
# mvfiles(shared_tex, os.path.dirname(ex_tex_out)+"/") # mvfiles(shared_tex, os.path.dirname(ex_tex_out)+"/")
# if w != 0:
latexmk(ex_tex_out, pdf_out=paths['pdf_out']+"/" + os.path.basename(ex_tex_out)[:-4] + ".pdf") latexmk(ex_tex_out, pdf_out=paths['pdf_out']+"/" + os.path.basename(ex_tex_out)[:-4] + ".pdf")
def mvfiles(source_dir, dest_dir): def mvfiles(source_dir, dest_dir):
...@@ -575,9 +573,11 @@ def make_webpage(dosvg=True, upload=True): ...@@ -575,9 +573,11 @@ def make_webpage(dosvg=True, upload=True):
if os.path.exists( blrb): if os.path.exists( blrb):
jinjafy_template(cinfo, file_in=blrb, file_out=blrb.replace("_template.html", ".html")) jinjafy_template(cinfo, file_in=blrb, file_out=blrb.replace("_template.html", ".html"))
cmd = f"cd {os.path.dirname(paths['homepage_template'] )} && rsync --delete --rsh=ssh -av ./ tuhe@thinlinc.compute.dtu.dk:/www/docs/courses/02465/"
print("> Run this command in the terminal to sync", cmd)
if upload: if upload:
import subprocess import subprocess
cmd = f"cd {os.path.dirname(paths['homepage_template'] )} && rsync --delete --rsh=ssh -av ./ tuhe@thinlinc.compute.dtu.dk:/www/docs/courses/02465/"
subprocess.run([cmd], shell=True) subprocess.run([cmd], shell=True)
# This should probably be moved into jinjafy # This should probably be moved into jinjafy
......
...@@ -36,7 +36,8 @@ def setup_student_files(run_files=True, ...@@ -36,7 +36,8 @@ def setup_student_files(run_files=True,
PACKAGE = list(core_conf['projects_all'].values()).pop()['module_public'].split(".")[0] PACKAGE = list(core_conf['projects_all'].values()).pop()['module_public'].split(".")[0]
if censor_files:
assert not run_files, "You cannot run files while you are censoring them -- your scripts will crash. Call with run_files=False."
week = [week] if isinstance(week, int) else week week = [week] if isinstance(week, int) else week
if verbose: if verbose:
...@@ -62,6 +63,9 @@ def setup_student_files(run_files=True, ...@@ -62,6 +63,9 @@ def setup_student_files(run_files=True,
init_dest = students_irlc_tools+"/__init__.py" init_dest = students_irlc_tools+"/__init__.py"
shutil.copy(public_irlc_tools + "/__init__.py", init_dest) shutil.copy(public_irlc_tools + "/__init__.py", init_dest)
for fpy in glob.glob(public_irlc_tools + "/*.py"):
shutil.copy(fpy, students_irlc_tools + "/" + os.path.basename(fpy))
if os.path.isfile(public_irlc_tools + "/../.coveragerc"): if os.path.isfile(public_irlc_tools + "/../.coveragerc"):
shutil.copy(public_irlc_tools + "/../.coveragerc", students_irlc_tools+ "/../.coveragerc") shutil.copy(public_irlc_tools + "/../.coveragerc", students_irlc_tools+ "/../.coveragerc")
# assert False # assert False
...@@ -69,7 +73,10 @@ def setup_student_files(run_files=True, ...@@ -69,7 +73,10 @@ def setup_student_files(run_files=True,
# Check for exclusion mask. # Check for exclusion mask.
exclude = info_paths.core_conf.get('student_files', {}).get('exclude', []) exclude = info_paths.core_conf.get('student_files', {}).get('exclude', [])
if extra_dirs is None:
extra_dirs = info_paths.core_conf.get('student_files', {}).get('extra_dirs', [])
print("Extra dirs are", extra_dirs)
exclude += [f'tests_week{w if w >= 10 else f"0{w}"}.py' for w in range(0,14) if w not in week] exclude += [f'tests_week{w if w >= 10 else f"0{w}"}.py' for w in range(0,14) if w not in week]
exclude = exclude + ["**/" + ex for ex in exclude] exclude = exclude + ["**/" + ex for ex in exclude]
if not include_exam_examples: if not include_exam_examples:
...@@ -84,6 +91,7 @@ def setup_student_files(run_files=True, ...@@ -84,6 +91,7 @@ def setup_student_files(run_files=True,
print(m) print(m)
if extra_dirs is None: if extra_dirs is None:
# extra_dirs = []
extra_dirs = ['utils', 'tests', 'exam/exam2023spring', 'pacman', 'gridworld', 'car'] # 'assignments', extra_dirs = ['utils', 'tests', 'exam/exam2023spring', 'pacman', 'gridworld', 'car'] # 'assignments',
for m in midterms: for m in midterms:
...@@ -154,13 +162,15 @@ def setup_student_files(run_files=True, ...@@ -154,13 +162,15 @@ def setup_student_files(run_files=True,
else: else:
info = None info = None
for hw in hws: for hw in hws:
if "ex08" in hw['out']: # if "ex08" in hw['out']:
print("ex08") # print("ex08")
print("Fixing hw", hw['out'])
n = fix_hw(paths=paths, info=info, hw=hw, out= hw['out'], output_dir=paths['shared'] +"/output", run_files=run_files, cut_files=cut_files, n = fix_hw(paths=paths, info=info, hw=hw, out= hw['out'], output_dir=paths['shared'] +"/output", run_files=run_files, cut_files=cut_files,
package_base_dir=os.path.dirname(students_irlc_tools), censor_files=censor_files, strict=strict, package_base_dir=os.path.dirname(students_irlc_tools), censor_files=censor_files, strict=strict,
include_solutions=hw.get('include_solutions', False), include_solutions=hw.get('include_solutions', False),
verbose=verbose) verbose=verbose)
if censor_files:
with open(paths['shared'] + f"/output/lines_{hw['week']}.txt", 'w') as f: with open(paths['shared'] + f"/output/lines_{hw['week']}.txt", 'w') as f:
f.write(str(n)) f.write(str(n))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment