From 854eba6cd133604cb86cd0a9bb6c0c3ff093de92 Mon Sep 17 00:00:00 2001
From: Tue Herlau <tuhe@dtu.dk>
Date: Fri, 17 Jan 2025 14:49:52 +0100
Subject: [PATCH] Updates

---
 setup.py                                     |  2 +-
 src/coursebox.egg-info/PKG-INFO              | 15 +++++++++++++--
 src/coursebox/core/info.py                   | 11 ++++++++++-
 src/coursebox/material/documentation.py      |  9 +++++++--
 src/coursebox/student_files/student_files.py | 17 ++++-------------
 5 files changed, 35 insertions(+), 19 deletions(-)

diff --git a/setup.py b/setup.py
index 103b79a..9746aef 100644
--- a/setup.py
+++ b/setup.py
@@ -13,7 +13,7 @@ with open("README.md", "r", encoding="utf-8") as fh:
 
 setuptools.setup(
     name="coursebox",
-    version="0.1.20.6",
+    version="0.1.20.9",
     author="Tue Herlau",
     author_email="tuhe@dtu.dk",
     description="A course management system currently used at DTU",
diff --git a/src/coursebox.egg-info/PKG-INFO b/src/coursebox.egg-info/PKG-INFO
index e4410d9..4f9cbec 100644
--- a/src/coursebox.egg-info/PKG-INFO
+++ b/src/coursebox.egg-info/PKG-INFO
@@ -1,6 +1,6 @@
-Metadata-Version: 2.1
+Metadata-Version: 2.2
 Name: coursebox
-Version: 0.1.20.4
+Version: 0.1.20.9
 Summary: A course management system currently used at DTU
 Home-page: https://lab.compute.dtu.dk/tuhe/coursebox
 Author: Tue Herlau
@@ -23,6 +23,17 @@ Requires-Dist: langdetect
 Requires-Dist: beamer-slider
 Requires-Dist: tinydb
 Requires-Dist: python-gitlab
+Dynamic: author
+Dynamic: author-email
+Dynamic: classifier
+Dynamic: description
+Dynamic: description-content-type
+Dynamic: home-page
+Dynamic: license
+Dynamic: project-url
+Dynamic: requires-dist
+Dynamic: requires-python
+Dynamic: summary
 
 # Coursebox DTU
 DTU course management software.
diff --git a/src/coursebox/core/info.py b/src/coursebox/core/info.py
index cc92393..91618ac 100644
--- a/src/coursebox/core/info.py
+++ b/src/coursebox/core/info.py
@@ -98,7 +98,7 @@ def first_day_of_class(info):
         mo_first = datetime(year=year(), month=1 if semester() == 'spring' else 8, day=1, hour=info.get('lecture_start_hour', 13), minute=0)
         # scroll to monday
         while mo_first.weekday() != 0: #strftime('%A') is not 'Monday':
-            mo_first -= timedelta(days=1)
+            mo_first += timedelta(days=1) # Don't subtract here.
         # add 4 weeks to get into 13 week period
         for _ in range(4):
             mo_first += timedelta(days=7)
@@ -169,6 +169,7 @@ def lectures(info, pensum=None):
         l['day'] = d.day
         l['date'] = d
         l['preceded_by_holiday'] = i == holiday
+        l['followed_by_holiday'] = i+1 == holiday
         l = {**l, **date2format(d)}
 
         if not continuing_education():
@@ -469,6 +470,14 @@ def class_information(verbose=False,
 
     d['sections'] = sections
 
+    current_lecture = -2
+
+    for k, l in enumerate(d['lectures']):
+        current_lecture = k - 1
+        if l['date'] >= datetime.now():
+            break
+
+    d['current_lecture_number'] = current_lecture
     return d
 
 def _update_with_core_conf(d):
diff --git a/src/coursebox/material/documentation.py b/src/coursebox/material/documentation.py
index 400dd8a..2a04e8b 100644
--- a/src/coursebox/material/documentation.py
+++ b/src/coursebox/material/documentation.py
@@ -93,6 +93,10 @@ def build_sphinx_documentation(cut_files=False, open_browser=True, build_and_cop
         # print(">>> k class is: ")
         # print(info_paths.core_conf['projects_all'][k])
 
+        if "class" not in info_paths.core_conf['projects_all'][k]:
+            print(f"Warning: I was unable to find project with number {k}. Probably the class raise an Exception. ")
+            print(info_paths.core_conf['projects_all'][k])
+
         f = info_paths.core_conf['projects_all'][k]['class'].mfile()
         with open(f.split("_grade.py")[0], 'r') as ff:
             l = [l for l in ff.read().splitlines() if "(Report)" in l].pop().split("(")[0].split(" ")[-1]
@@ -232,12 +236,13 @@ def build_sphinx_documentation(cut_files=False, open_browser=True, build_and_cop
         my_env['PYTHONPATH'] = (paths['02450students'] + '_complete').replace("\\", "/")
         print("Running", cmd)
         process = run(cmd, print_output=True, log_output=True, check=False, env=my_env)
-
+        print("Done running sphinx build command.")
         """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':
+            print("This is windows. Building again:")
             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())
@@ -270,7 +275,7 @@ Below is a summary of the problems we found: """)
         for im in ["gb.png", "dk.png"]:
             shutil.copy(f"{paths['shared']}/figures/{im}", f"{_FINAL_BUILD_DEST}/_images/{im}")
 
-
+    print("Running and building censored version of files:")
     if build_and_copy_censored:
         verbose = False
         setup_student_files(run_files=False, cut_files=False, censor_files=True, setup_lectures=cut_files,
diff --git a/src/coursebox/student_files/student_files.py b/src/coursebox/student_files/student_files.py
index 69ada71..e8ed8d3 100644
--- a/src/coursebox/student_files/student_files.py
+++ b/src/coursebox/student_files/student_files.py
@@ -15,7 +15,8 @@ def setup_student_files(run_files=True,
                         week=None, extra_dirs=None,
                         include_solutions=None,
                         projects=None,
-                        setup_lectures=False, strict=True,
+                        setup_lectures=False,
+                        strict=True,
                         fix_shared_files=True,
                         include_exam_examples=False, # Include the directory with exam-related examples.
                         verbose=True,
@@ -33,21 +34,11 @@ def setup_student_files(run_files=True,
     from coursebox.core.info import class_information
     # info = class_information()
     from coursebox.core.info import core_conf
-    # <<<<<<< HEAD
-    # if 'package' not in core_conf:
+
     if len(core_conf['projects_all']) > 0:
         PACKAGE = list(core_conf['projects_all'].values()).pop()['module_public'].split(".")[0]
     else:
         PACKAGE = [w for w in core_conf['weeks_all'].values() if 'module_public' in w][0]['module_public'].split(".")[0]
-    # =======
-    #     try:
-    #         if len(core_conf['projects_all']) > 0:
-    #             PACKAGE = list(core_conf['projects_all'].values()).pop()['module_public'].split(".")[0]
-    #         else:
-    #             PACKAGE = list(core_conf['weeks_all'].values()).pop()['module_public'].split(".")[0]
-    #     except Exception as e:
-    #         PACKAGE = core_conf['package']
-    # >>>>>>> 5f0cf05ea2c51749713d10331847fbe062613bab
 
     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."
@@ -94,7 +85,7 @@ def setup_student_files(run_files=True,
     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]
     if not include_exam_examples:
-        exclude += ['exam_tabular_examples']
+        exclude += ['*/exam_tabular_examples/*']
     inclusion = [] # 'ex09old/cache']
     hws = []
     for m in midterms:
-- 
GitLab