Skip to content

Commit

Permalink
fixes #51
Browse files Browse the repository at this point in the history
  • Loading branch information
WolfgangFahl committed Feb 5, 2024
1 parent a926ae0 commit 84c41a3
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 4 deletions.
1 change: 1 addition & 0 deletions .project
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<name>dcm</name>
<comment></comment>
<projects>
<project>nicegui</project>
<project>nicegui_widgets</project>
</projects>
<buildSpec>
Expand Down
2 changes: 1 addition & 1 deletion dcm/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.1.13"
__version__ = "0.1.15"
19 changes: 19 additions & 0 deletions dcm/dcm_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"""
import json
import os
from datetime import datetime
from dataclasses import dataclass, field
from json.decoder import JSONDecodeError
from typing import Any, Dict, List, Optional, Tuple, Union
Expand Down Expand Up @@ -474,6 +475,24 @@ def file_name(self):
self.learner_id, lowercase=False, regex_pattern=r"[^\w\s\-]"
)
return file_name

@property
def most_recent_achievement_iso_date(self) -> Optional[str]:
"""
Get the most recent achievement date in ISO format.
Returns:
Optional[str]: The ISO date string of the most recent achievement, or None if there are no achievements.
"""
if not self.achievements:
return None
dates = [achievement.date_assessed_iso for achievement in self.achievements if achievement.date_assessed_iso]
if not dates:
return None
# Parse the ISO dates and return the most recent one
most_recent_date = max(datetime.fromisoformat(date) for date in dates)
return most_recent_date.isoformat()


def get_achievement_index(self, path) -> int:
a_index = self.achievement_indices_by_path.get(path)
Expand Down
2 changes: 1 addition & 1 deletion dcm/dcm_webserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ def prepare_svg(self):
java_script = self.svg.get_java_script()

# Add the script using ui.add_head_html()
ui.add_head_html(java_script)
ui.add_head_html(java_script,shared=True)

def show_ui(self):
"""
Expand Down
2 changes: 1 addition & 1 deletion dcm/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class Version:
name = "dcm"
version = dcm.__version__
date = "2023-11-06"
updated = "2024-02-01"
updated = "2024-02-05"
description = "python based visualization of dynamic competence maps"

authors = "Wolfgang Fahl"
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ readme = "README.md"
license = {text = "Apache-2.0"}
dependencies = [
# https://github.com/WolfgangFahl/nicegui_widgets
"ngwidgets>=0.11.0",
"ngwidgets>=0.11.4",
# https://pypi.org/project/dataclasses-json/
"dataclasses-json>=0.6.1",
# https://github.com/trentm/python-markdown2
Expand Down
2 changes: 2 additions & 0 deletions tests/test_learner.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,5 @@ def test_learner_competence_trees(self):
self.assertEqual("architecture", tree_ids[0])
for achievement in learner.achievements:
self.assertTrue(achievement.path in learner.achievements_by_path)
debug=True
self.assertEqual("2023-06-20T00:00:00",learner.most_recent_achievement_iso_date)

0 comments on commit 84c41a3

Please sign in to comment.