From 3edaabb8a86aa245f900c877c7240fc2afb9c43c Mon Sep 17 00:00:00 2001 From: AlexandreDoneux <94830560+AlexandreDoneux@users.noreply.github.com> Date: Mon, 29 Apr 2024 16:35:25 +0200 Subject: [PATCH] [frontend/task_list] Moving task access structure update to legacy update --- inginious/frontend/pages/course_admin/task_list.py | 3 ++- inginious/frontend/pages/taskset_admin/template.py | 3 ++- inginious/frontend/task_dispensers/toc.py | 11 +++++++++-- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/inginious/frontend/pages/course_admin/task_list.py b/inginious/frontend/pages/course_admin/task_list.py index 983d6294c..b33939f27 100644 --- a/inginious/frontend/pages/course_admin/task_list.py +++ b/inginious/frontend/pages/course_admin/task_list.py @@ -38,7 +38,8 @@ def POST_AUTH(self, courseid): # pylint: disable=arguments-differ task_dispenser = course.get_task_dispenser() try: data = task_dispenser.import_legacy_tasks() - for taskid, task in data["config"].items(): + dispenser_data = task_dispenser.get_dispenser_data() + for task in dispenser_data["config"].values(): task["accessibility"] = dict_data_str_to_datetimes( change_access_structure(task["accessibility"], True)) self.update_dispenser(course, data) diff --git a/inginious/frontend/pages/taskset_admin/template.py b/inginious/frontend/pages/taskset_admin/template.py index 6805e7a6f..267c7c841 100644 --- a/inginious/frontend/pages/taskset_admin/template.py +++ b/inginious/frontend/pages/taskset_admin/template.py @@ -39,7 +39,8 @@ def POST_AUTH(self, tasksetid): # pylint: disable=arguments-differ task_dispenser = taskset.get_task_dispenser() try: data = task_dispenser.import_legacy_tasks() - for taskid, task in data["config"].items(): + dispenser_data = task_dispenser.get_dispenser_data() + for task in dispenser_data["config"].values(): task["accessibility"] = dict_data_str_to_datetimes( change_access_structure(task["accessibility"], True)) self.update_dispenser(taskset, data) diff --git a/inginious/frontend/task_dispensers/toc.py b/inginious/frontend/task_dispensers/toc.py index e72859b83..197983b9a 100644 --- a/inginious/frontend/task_dispensers/toc.py +++ b/inginious/frontend/task_dispensers/toc.py @@ -13,7 +13,7 @@ SubmissionLimit, Accessibility from inginious.frontend.task_dispensers import TaskDispenser from inginious.frontend.accessible_time import AccessibleTime -from inginious.frontend.util import change_access_structure, dict_data_str_to_datetimes, dict_data_datetimes_to_str +from inginious.frontend.util import dict_data_datetimes_to_str class TableOfContents(TaskDispenser): @@ -144,7 +144,14 @@ def get_ordered_tasks(self): return OrderedDict([(taskid, tasks[taskid]) for taskid in self._toc.get_tasks() if taskid in tasks]) def has_legacy_tasks(self, ignore_imported=False): - """ Checks if the task files contains dispenser settings """ + """ Checks if the task files contains dispenser settings or if the tasks have legacy structure """ + + if "config" in self._dispenser_data: + # if old accessibility structure + for task in self._dispenser_data["config"].values(): + if isinstance(task["accessibility"], str): + return True + if not ignore_imported and self._dispenser_data.get("imported", False): return False