Skip to content

Commit

Permalink
[frontend/settings] Changing course accessibility structure when upda…
Browse files Browse the repository at this point in the history
…ting settings instead of legacy migration
  • Loading branch information
AlexandreDoneux committed Apr 29, 2024
1 parent 99a23c2 commit 01d2937
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
6 changes: 0 additions & 6 deletions inginious/frontend/course_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

from inginious.frontend.exceptions import CourseNotFoundException, CourseAlreadyExistsException, TasksetNotFoundException
from inginious.frontend.courses import Course
from inginious.frontend.util import change_access_structure, dict_data_str_to_datetimes


class CourseFactory(object):
Expand Down Expand Up @@ -114,12 +113,7 @@ def _migrate_legacy_courses(self):
cleaned_taskset_descriptor["dispenser_data"] = taskset_descriptor.get("dispenser_data", {})
taskset_descriptor["tasksetid"] = courseid
taskset_descriptor["admins"] = taskset_descriptor.get("admins", []) + taskset_descriptor.get("tutors", [])
if "accessible" in taskset_descriptor:
taskset_descriptor["accessible"] = change_access_structure(taskset_descriptor["accessible"])
if "registration" in taskset_descriptor:
taskset_descriptor["registration"] = change_access_structure(taskset_descriptor["registration"])

taskset_descriptor = dict_data_str_to_datetimes(taskset_descriptor)
self._database.courses.update_one({"_id": courseid}, {"$set": taskset_descriptor}, upsert=True)
self._taskset_factory.update_taskset_descriptor_content(courseid, cleaned_taskset_descriptor)
except TasksetNotFoundException as e:
Expand Down
9 changes: 9 additions & 0 deletions inginious/frontend/pages/course_admin/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import re
import flask
from datetime import datetime
import copy

from inginious.common.base import dict_from_prefix, id_checker
from inginious.frontend.user_settings.field_types import FieldTypes
Expand Down Expand Up @@ -40,6 +41,14 @@ def POST_AUTH(self, courseid): # pylint: disable=arguments-differ

course_content['groups_student_choice'] = True if data["groups_student_choice"] == "true" else False

if isinstance(data["accessible"], (str, bool)):
course_content["accessible"] = {} # problème -> immutableDict -> on ne peut pas changer le type
if isinstance(data["registration"], (str, bool)):
course_content["registration"] = {}

# what if not present in data (-> None) or empty string (-> "") ?
# => problems with filling settings form and updating settings

if data["accessible"] == "custom":
course_content['accessible']["start"] = datetime.strptime(data["accessible_start"], '%Y-%m-%d %H:%M:%S') if data["accessible_start"] != "" else course._accessible.min
course_content['accessible']["end"] = datetime.strptime(data["accessible_end"], '%Y-%m-%d %H:%M:%S') if data["accessible_end"] != "" else course._accessible.max
Expand Down

0 comments on commit 01d2937

Please sign in to comment.