def __init__(self, name, id, sections=None, activities=None, version=1, **kwargs): """ Args: name: name of the course id: given ID in the system content: all course content in a list by sections **kwargs: """ self.sections = [] if sections is None else sections self.activities = [] if activities is None else activities for activity in self.activities: activity["section"] += 1 activity["digest"] = hashlib.md5( text_type(activity["id"]) + activity["type"] ).hexdigest() # Make sure sections IDs start at 1 for section in self.sections: section["id"] += 1 section["activities"] = [ activity for activity in self.activities if activity["section"] == section["id"] ] self.name = name self.slug = slugify(name) self.courseid = str(id) self.version = version self.backup_filename = kwargs.pop("backup_filename", self.default_filename) self.validate_backup_filename()
def __init__(self, name, id, sections=None, activities=None, version=1, **kwargs): """ Args: name: name of the course id: given ID in the system content: all course content in a list by sections **kwargs: """ self.sections = [] if sections is None else sections self.activities = [] if activities is None else activities for activity in self.activities: activity["section"] += 1 activity["digest"] = hashlib.md5( text_type(activity["id"]) + activity["type"]).hexdigest() # Make sure sections IDs start at 1 for section in self.sections: section["id"] += 1 section["activities"] = [ activity for activity in self.activities if activity["section"] == section["id"] ] self.name = name self.slug = slugify(name) self.courseid = str(id) self.version = version self.backup_filename = kwargs.pop("backup_filename", self.default_filename) self.validate_backup_filename()
def moodle_file_name(self): """ Returns the slugified title with an mbz extension """ return "{}.mbz".format(slugify(self.title))
def get_slug(self): return slugify(self.title)