Skip to content

Commit

Permalink
[frontend/task_list] Moving task access structure update to legacy up…
Browse files Browse the repository at this point in the history
…date
  • Loading branch information
AlexandreDoneux committed Apr 30, 2024
1 parent ad83ef5 commit d03a4e9
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
3 changes: 2 additions & 1 deletion inginious/frontend/pages/course_admin/task_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 2 additions & 1 deletion inginious/frontend/pages/taskset_admin/template.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
11 changes: 9 additions & 2 deletions inginious/frontend/task_dispensers/toc.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit d03a4e9

Please sign in to comment.