Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found
Select Git revision
Loading items

Target

Select target project
  • tuhe/coursebox
1 result
Select Git revision
Loading items
Show changes

Commits on Source 4

......@@ -8,7 +8,8 @@ pexpect
matplotlib
numpy
pycode_similar
# jinjafy
beamer-slider
tinydb
python-gitlab
sphinx>=6.0.0
docutils>=0.20.0
\ No newline at end of file
......@@ -13,7 +13,7 @@ with open("README.md", "r", encoding="utf-8") as fh:
setuptools.setup(
name="coursebox",
version="0.1.19.11",
version="0.1.20.1",
author="Tue Herlau",
author_email="tuhe@dtu.dk",
description="A course management system currently used at DTU",
......
Metadata-Version: 2.1
Name: coursebox
Version: 0.1.19.11
Version: 0.1.20.1
Summary: A course management system currently used at DTU
Home-page: https://lab.compute.dtu.dk/tuhe/coursebox
Author: Tue Herlau
......
......@@ -60,6 +60,7 @@ def xlsx_to_dicts(xlsx_file,sheet=None, as_dict_list=False, columns=None):
return dd
def get_enrolled_students():
# s224202
paths = get_paths()
students = xlsx_to_dicts(paths['information.xlsx'], sheet='students')
students2 = {}
......@@ -191,7 +192,7 @@ def lectures(info, pensum=None):
else:
d = d + timedelta(days=dd[i-0] if i > 1 else 0)
d = d + timedelta(days=(dd+[0 for _ in range(10)])[i] if i > 1 else 0)
d = d.replace(hour=ice['hour'][i-1], minute=ice['minute'][i-1])
......@@ -202,7 +203,12 @@ def lectures(info, pensum=None):
linfo['reading_long'] = ir.replace("C", "Chapter ") if ir else ""
hwp = linfo['homework_problems']
# if str(hwp).strip().endswith(","):
# hwp = hwp[:-1]
linfo['homework_problems_long'] = str(hwp) if isinstance(hwp, int) else (hwp.replace("P", "Problem ") if hwp else "")
if linfo["learning_objectives"]:
linfo["learning_objectives"] = [s.strip() for s in linfo["learning_objectives"].split("\n")]
linfo['reading_rst'] = bib2rst(linfo['reading'])
......@@ -378,6 +384,7 @@ def class_information(verbose=False,
d['CE2'] = gi.get("days", 5) == 2 if continuing_education_mode else False
d['CE5'] = gi.get("days", 5) == 5 if continuing_education_mode else False
d['CE'] = True if continuing_education_mode else False
d['freeze_report_evaluation'] = d['freeze_report_evaluation'] == 'True'
d['freeze_grades'] = d['freeze_grades'] == 'True'
......
......@@ -119,6 +119,10 @@ def handle_projects(verbose=False, gather_main_xlsx_file=True, plagiarism_check=
print("> Done gathering main .xlsx file from instructor .xlsx files")
cache_update_dir(cache_base, cache_base, pattern="*.xlsx")
info = class_information()
id = 's225785'
pid = 1
print(info['students'][id]['reports'][pid])
zip1 = instructor_path + "/zip1.zip"
zip2 = instructor_path + "/zip2.zip"
......@@ -147,7 +151,7 @@ def handle_projects(verbose=False, gather_main_xlsx_file=True, plagiarism_check=
else:
print("When available, please move downloaded copy of all reports from campusnet to destination:")
print(zf)
info['students']['s225785']['reports'][1]
mkboxplots(info['students'],paths)
if cache_changed_xlsx_files:
......@@ -168,14 +172,23 @@ def handle_projects(verbose=False, gather_main_xlsx_file=True, plagiarism_check=
ins_email = v[0]['email']
nags.append((name, ins_email, nlines))
Nerrors = sum([n[-1] for n in nags])
err = []
serrors = None
if Nerrors > 0:
print("\n> %i errors. These instructors have parse errors (.txt)" % sum([n[-1] for n in nags]))
print("; ".join([email for (_, email, _) in nags]))
print(", ".join([name.capitalize() for (name, _, _) in nags]))
print("TA/Errors: " + ", ".join(["%s:%i" % (name.capitalize(), lines) for (name, _, lines) in nags]))
print("---")
err.append("\n> %i errors. These instructors have parse errors (.txt)" % sum([n[-1] for n in nags]))
err.append("; ".join([email for (_, email, _) in nags]))
err.append(", ".join([name.capitalize() for (name, _, _) in nags]))
err.append("TA/Errors: " + ", ".join(["%s:%i" % (name.capitalize(), lines) for (name, _, lines) in nags]))
err.append("---")
serrors = "\n".join(err)
print(serrors)
else:
print("No parse errors found")
return serrors
def compute_error_files(info, paths):
......@@ -657,13 +670,50 @@ def gather_instructor_sheets(info):
ts.save(out)
ts.close()
print("Collected xlsx instructor files. Using xlwings to load main worksheet, evaluate and save it")
# 024
import xlwings
try:
# def main() -> None:
# info = class_information()
# id = 's225785'
# pid = 1
# print(info['students'][id]['reports'][pid])
# shutil.run( )
# from ooodev.loader.lo import Lo
# from ooodev.office.calc import Calc
#
# # fnm = sys.argv[1:] # get file from first args
# fnm = out
#
# loader = Lo.load_office(Lo.ConnectSocket(headless=True))
# doc = Lo.open_doc(fnm=fnm, loader=loader)
#
# # use the Office API to manipulate doc...
# Lo.save_doc(doc, out) # save as a Word file
# Lo.close_doc(doc)
# Lo.close_office()
book = xw.Book(out)
book.save(out)
book.close()
except xlwings.XlwingsError as e:
print("No xlsxwings installed. Sheets are not correctly evaluated.")
# import shutil
import subprocess
cmd = f'cd {os.path.basename(out)} && libreoffice --calc --headless --invisible --convert-to xlsx --outdir ../ {os.path.basename(out)}'
output = subprocess.run(cmd, capture_output=True, shell=True)
time.sleep(3)
od = os.path.dirname(os.path.dirname(out)) + "/" + os.path.basename(out)
while not os.path.isfile(od):
time.sleep(1)
print("Waiting for file", od)
shutil.move(od, out)
print(e)
......
......@@ -287,7 +287,12 @@ def populate_student_report_results(students, verbose=False):
# for i in range(2, wb.worksheets[repn].max_column + 1):
# print(i, wb.worksheets[repn].max_column)
# s = pd.read_excel(out, sheet_name=1)
cp = parse_column_numpy(sheet[:,i], report_number=repn, column=i)
if repn == 1 and 1 > 2:
# info['students']['s225785']['reports'][1]
pass
# cp = parse_column(wb.worksheets[repn], report_number=repn, column=i)
if not cp['student_ids']:
break
......
......@@ -54,8 +54,13 @@ def build_sphinx_documentation(cut_files=False, open_browser=True, build_and_cop
# from cp_box.material.student_files import setup_student_files
# from coursebox.material.homepage_lectures_exercises import set
from coursebox.student_files.student_files import setup_student_files
from coursebox.core.info import class_information
from coursebox.core import info_paths
info = class_information()
BOOK_PDF_NAME = os.path.basename(info.get('lecture_notes_tex', paths['course_number'] + "_Notes.pdf"))[:-4] + ".pdf"
if os.path.isfile(d_ := f"{paths['book']}/{paths['course_number']}_Notes.pdf"):
if os.path.isfile(d_ := f"{paths['book']}/{BOOK_PDF_NAME}"):
book_frontpage_png = paths['shared']+"/figures/book.png"
slide_to_image(d_, book_frontpage_png, page_to_take=1)
image = PIL.Image.open(book_frontpage_png)
......@@ -67,10 +72,7 @@ def build_sphinx_documentation(cut_files=False, open_browser=True, build_and_cop
""" Return extra information required for building the documentation.
"""
# from coursebox.core.info_paths import get_paths
from coursebox.core.info import class_information
from coursebox.core import info_paths
# paths = get_paths()
info = class_information()
# {{ (date1|to_datetime - date2|to_datetime).days < lecture['show_slides_after'] }}
# (info['lectures'][2]['date'].now() - info['lectures'][2]['date']).days < lecture['show_slides_after'] }}
source = _get_source(paths)
......@@ -144,7 +146,7 @@ def build_sphinx_documentation(cut_files=False, open_browser=True, build_and_cop
shutil.copy(g, dst)
pdfs.append(dst)
for g in [paths['pdf_out'] + "/" + paths['course_number'] + "_Notes.pdf"]:
for g in [paths['pdf_out'] + "/" + BOOK_PDF_NAME]:
dst = paths['02450public'] + "/src/docs/assets/" + os.path.basename(g)
shutil.copy(g, dst)
pdfs.append(dst)
......@@ -218,10 +220,8 @@ def build_sphinx_documentation(cut_files=False, open_browser=True, build_and_cop
# subprocess.run(cmd, shell=True)
# subprocess.run('cd "C:/Users/tuhe/Documents/02002students_complete/docs" && set PYTHONPATH="C:/Users/tuhe/Documents/02002students_complete" && sphinx-build -b html source "../../02002public/public" -a ', shell=True)
problems = []
if os.name == "nt":
# do win specific stuff here.
# >> > result = subprocess.run(['ls', '-l'], stdout=subprocess.PIPE)
# >> > result.stdout
......@@ -235,19 +235,15 @@ def build_sphinx_documentation(cut_files=False, open_browser=True, build_and_cop
"""r
cd /home/tuhe/Documents/02465students_complete/ && sphinx-build -b html docs/source ./public
cd "/home/tuhe/Documents/02465students_complete/docs" && sphinx-build -b html source "../../02465public/public" -a
"""
if os.name == 'nt':
# time.sleep(10)
process = run(cmd, print_output=True, log_output=True, check=False, env=my_env)
print("TH 2023 Juli: Running sphinx compilation job twice bc of path error on windows. This should be easy to fix but I don't know enough about windows to do so.")
print(process.stderr.getvalue())
errors = process.stderr.getvalue()
file = f"{os.path.normpath(PUBLIC_BUILD_DEST)}/log_{l}.txt"
fns.append(file)
if not os.path.isdir(d_ := os.path.dirname(file)):
os.makedirs(d_)
with open(file,'w') as f:
......
......@@ -528,15 +528,12 @@ def make_exercises_projects_tutors(week=None, only_exercises=False, make_exercis
"R": lang == "R",
'HOMEWORK_PROBLEMS': HOMEWORK_PROBLEMS,
}
# get lang dir
if not os.path.exists("%s/Exercises%s"%(paths['exercises'], lang)):
continue
info.update(tv)
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['exercises'], lang, w, course_number, w, lang)
# fbody = os.path.dirname(ex_tex_out) +f"/ex{w}_body.tex"
if os.path.exists(ex_base):
jinjafy_template(info, ex_base, file_out=ex_tex_out, filters=filters, template_searchpath=paths['exercises'])
......
......@@ -67,8 +67,13 @@ def lecture_question_compiler(paths, info, lecture_texfile):
print("png_out", png_out)
slide_to_image(lecture_pdffile, png_out, page_to_take=n)
if dex < 0:
execute_command(["pdftocairo", fout_q_pdf, fout_q_pdf[:-4], "-png"])
ls = glob.glob( fout_q_pdf[:-4] +"-*.png")
# import subprocess
# out = subprocess.run(["pdftocairo", fout_q_pdf, fout_q_pdf[:-4], "-png"], capture_output=True, encoding='utf-8')
from slider.convert import pdf2png
fout = pdf2png(fout_q_pdf)
# execute_command(["pdftocairo", fout_q_pdf, fout_q_pdf[:-4], "-png"])
ls = glob.glob( fout)
if len(ls) > 1:
print("Hacky, two files exist (bad/old png conversaion code", ls)
l2 = glob.glob(fout_q_pdf[:-4] + "-000*.png")[0]
......