class documentation

class FileStorage(Storage):

Constructor: FileStorage()

View In Hierarchy

This class stores data in a folder hierarchy on disk.

Method __init__ Initialise FileStorage.
Method delete_course Delete the course identified by course_title. Return a message in case of success.
Method delete_learning_content Delete the learning content identified by learning_content_id. Return a message in case of success.
Method delete_variant Attempt to delete the variant identified by variant_id. Return a message in case of success.
Method find_courses Search for courses, and return a dict mapping their titles to their IDs, and IDs to titles.
Method get_course_titles Return a list of titles of existing courses.
Method get_directory Return a tuple (directory_name, html) with the name of the first directory found in the learning content, and the content of the first HTML file found in there. Both elements may be empty.
Method get_html Return the content of the first HTML file found in the learning content, or an empty string.
Method get_image Return the URI to the first image found in the learning content, or an empty string.
Method get_learning_contents Return a list of learning contents identifiers for a course in arbitrary order.
Method get_learning_contents_ordered Return a list of learning contents identifiers for a course in order.
Method get_learning_contents_titles Return a dictionary mapping learning contents identifiers to their titles.
Method get_variant_metadata Return the metadata of the variant as a dict.
Method get_variants Return a list of all variants for a learning content in a course.
Method get_variants_ids Return a list of identifiers of all variants for a learning content in a course.
Method write_course Create a new course. Return a message indicating success or failure.
Method write_learning_content Create a new learning content. Return a message indicating success or failure.
Method write_learning_contents_list Write an re-ordered list of learning contents into the course. Return a message indicating success or failure.
Method write_variant Write a variant consisting of a single or multiple files, and create the according meta files.

Inherited from Storage:

Method get_cached_item Return an item from the course's cache as a dict.
Method get_course_metadata Return the metadata of the course as a dict.
def __init__(self):

Initialise FileStorage.

def delete_course(self, course_title):

Delete the course identified by course_title. Return a message in case of success.

def delete_learning_content(self, course_title, learning_content_id):

Delete the learning content identified by learning_content_id. Return a message in case of success.

def delete_variant(self, course_title, learning_content_id, variant_id):

Attempt to delete the variant identified by variant_id. Return a message in case of success.

def find_courses(self):

Search for courses, and return a dict mapping their titles to their IDs, and IDs to titles.

def get_course_titles(self):

Return a list of titles of existing courses.

def get_directory(self, course_title, learning_content_id):

Return a tuple (directory_name, html) with the name of the first directory found in the learning content, and the content of the first HTML file found in there. Both elements may be empty.

def get_html(self, course_title, learning_content_id):

Return the content of the first HTML file found in the learning content, or an empty string.

def get_image(self, course_title, learning_content_id):

Return the URI to the first image found in the learning content, or an empty string.

def get_learning_contents(self, course_title):

Return a list of learning contents identifiers for a course in arbitrary order.

def get_learning_contents_ordered(self, course_title):

Return a list of learning contents identifiers for a course in order.

def get_learning_contents_titles(self, course_title):

Return a dictionary mapping learning contents identifiers to their titles.

def get_variant_metadata(self, course_title, learning_content_id, variant):

Return the metadata of the variant as a dict. Example: { "identifier": "aa2835f3-c3e4-495a-bea8-3e283979e6e6", "format": "text/html", "type": "variant" }

def get_variants(self, course_title, learning_content_id):

Return a list of all variants for a learning content in a course.

def get_variants_ids(self, course_title, learning_content_id):

Return a list of identifiers of all variants for a learning content in a course.

def write_course(self, title):

Create a new course. Return a message indicating success or failure.

def write_learning_content(self, course_title, learning_content_title):

Create a new learning content. Return a message indicating success or failure.

def write_learning_contents_list(self, course_title, learning_contents_list):

Write an re-ordered list of learning contents into the course. Return a message indicating success or failure.

def write_variant(self, course_id, learning_content_id, content, filename):

Write a variant consisting of a single or multiple files, and create the according meta files. Return the MIME type of the last file written.