class Storage:
Known subclasses: luna_lms.storage.file_storage.FileStorage, luna_lms.storage.sqlite_storage.SQLiteStorage
Prototype class to handle all storage. Should be subclassed by implementations.
| Method | delete |
Delete the course identified by course. |
| Method | delete |
Delete the learning content identified by learning_content_id. |
| Method | delete |
Attempt to delete the variant identified by variant_id. Return a message in case of success. |
| Method | find |
Search for courses, and return a tuple (id_title_dict, match_dict). |
| Method | get |
Return an item from the course's cache as a dict. |
| Method | get |
Return the variant data for the content of the step as specified by variant_format, or empty data. |
| Method | get |
Return the metadata of the course as a dict. |
| Method | get |
Return a list of titles of existing courses. |
| Method | get |
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 |
Return the format identifier of the first format that matches the tag list in tags for the course. |
| Method | get |
Return the content of the first HTML file found for the step, or an empty string. |
| Method | get |
Return the URI to the first image found for the step, or an empty string. |
| Method | get |
Return a dictionary mapping step identifiers to their titles. |
| Method | get |
Return a list of step identifiers for a course in arbitrary order. |
| Method | get |
Return a list of step identifiers for a course in order. |
| Method | get |
Return the metadata of the variant as a dict. |
| Method | get |
Return a list of all variants for a learning content in a course. |
| Method | get |
Return a list of identifiers of all variants for a learning content in a course. |
| Method | write |
Create a new course. Return a message indicating success or failure. |
| Method | write |
Create a new learning content. |
| Method | write |
Write an re-ordered list of learning contents into the course. |
| Method | write |
Write a variant consisting of a single or multiple files, and create the according meta files. |
luna_lms.storage.file_storage.FileStorageDelete the course identified by course. course can be an identifier or the course title. An identifier is recommended, since titles may not be unique. Return a message in case of success.
luna_lms.storage.file_storage.FileStorageDelete the learning content identified by learning_content_id. course can be an identifier or the course title. An identifier is recommended, since titles may not be unique. Return a message in case of success.
luna_lms.storage.file_storage.FileStorageAttempt to delete the variant identified by variant_id. Return a message in case of success. course can be an identifier or the course title. An identifier is recommended, since titles may not be unique.
luna_lms.storage.file_storage.FileStorage, luna_lms.storage.sqlite_storage.SQLiteStorageSearch for courses, and return a tuple (id_title_dict, match_dict). id_title_dict maps course titles to their IDs, and IDs to titles. If term is given, only return courses that match it in any of their metadata. If term is given, match_dict will map course titles to a match ratio between 0.0 and 1.0 .
luna_lms.storage.sqlite_storage.SQLiteStorageReturn an item from the course's cache as a dict. course can be an identifier or the course title. An identifier is recommended, since titles may not be unique. Example: { "path": "square.svg", "data": bytes('<?xml version="1.0" encoding="UTF-8" standalone="no"?><svg width="512" height="512" viewBox="0 0 135.46666 135.46667" version="1.1" id="svg5" xmlns="http://www.w3.org/2000/svg" xmlns:svg="http://www.w3.org/2000/svg"><defs id="defs2" /><g id="layer1"><rect style="fill:#ba2bcd;fill-opacity:1;stroke:none;stroke-width:0.187088;stroke-linecap:square;stroke-linejoin:round" id="rect286" width="95.789398" height="95.789398" x="-47.894699" y="47.894699" transform="rotate(-45)" /></g></svg>', encoding = "utf-8"), "format": "image/svg+xml", "description": "A violet square, balancing on a corner." }
luna_lms.storage.sqlite_storage.SQLiteStorageReturn the variant data for the content of the step as specified by variant_format, or empty data. course can be an identifier or the course title. An identifier is recommended, since titles may not be unique. variant_format can be a dot-separated Luna LMS format identifier, or a prefix of its sha256 hash. If a variant of the requested format does not exist, an empty data string will be returned. If variant_format evaluates to False, this method will try to return a variant in the default format, or any HTML variant. The return value is a tuple conforming to: (data, format, {tag_id: {"title": title, "available": bool, "formats": [format_id, ...]}, ...}) format is the identifier of the format being returned. The dictionary contains all tag identifiers defined in the course, irrespective of whether the content is available with that tag. It maps them to a dict holding the title of the tag, a flag whether the tag is available, and a list of associated formats. The list may be empty. A tag is flagged as availiable when all non-empty steps of the course have a variant tagged with this tag. If even one variant is missing, the tag is flagged as not available. The dictionary is an collections.OrderedDict. The order of keys is significant, and meant to be retained when displaying a list of tags.
luna_lms.storage.sqlite_storage.SQLiteStorageReturn the metadata of the course as a dict. course can be an identifier or the course title. An identifier is recommended, since titles may not be unique. Example: { "identifier": "e0f59465-f984-45ef-9b3d-2cf29e9edcd8", "title": "Example Title", "description": "Example description.", "relation": "", "created": "2023-08-28", "modified": "2023-08-28", "dateAccepted": "", "issued": "", "contributor": "Jane", "requires": "Luna LMS 1.0.0", }
luna_lms.storage.file_storage.FileStorageReturn a list of titles of existing courses.
luna_lms.storage.file_storage.FileStorageReturn 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. course can be an identifier or the course title. An identifier is recommended, since titles may not be unique.
luna_lms.storage.sqlite_storage.SQLiteStorageReturn the format identifier of the first format that matches the tag list in tags for the course. course can be an identifier or the course title. An identifier is recommended, since titles may not be unique.
luna_lms.storage.file_storage.FileStorage, luna_lms.storage.sqlite_storage.SQLiteStorageReturn the content of the first HTML file found for the step, or an empty string. course can be an identifier or the course title. An identifier is recommended, since titles may not be unique.
luna_lms.storage.file_storage.FileStorageReturn the URI to the first image found for the step, or an empty string. course can be an identifier or the course title. An identifier is recommended, since titles may not be unique.
luna_lms.storage.file_storage.FileStorage, luna_lms.storage.sqlite_storage.SQLiteStorageReturn a dictionary mapping step identifiers to their titles. course can be an identifier or the course title. An identifier is recommended, since titles may not be unique.
luna_lms.storage.file_storage.FileStorageReturn a list of step identifiers for a course in arbitrary order. course can be an identifier or the course title. An identifier is recommended, since titles may not be unique.
luna_lms.storage.file_storage.FileStorage, luna_lms.storage.sqlite_storage.SQLiteStorageReturn a list of step identifiers for a course in order. course can be an identifier or the course title. An identifier is recommended, since titles may not be unique.
luna_lms.storage.file_storage.FileStorageReturn the metadata of the variant as a dict. course can be an identifier or the course title. An identifier is recommended, since titles may not be unique. Example: { "identifier": "aa2835f3-c3e4-495a-bea8-3e283979e6e6", "format": "text/html", "type": "variant" }
luna_lms.storage.file_storage.FileStorageReturn a list of all variants for a learning content in a course. course can be an identifier or the course title. An identifier is recommended, since titles may not be unique.
luna_lms.storage.file_storage.FileStorageReturn a list of identifiers of all variants for a learning content in a course. course can be an identifier or the course title. An identifier is recommended, since titles may not be unique.
luna_lms.storage.file_storage.FileStorage, luna_lms.storage.sqlite_storage.SQLiteStorageCreate a new course. Return a message indicating success or failure.
luna_lms.storage.file_storage.FileStorageCreate a new learning content. course can be an identifier or the course title. An identifier is recommended, since titles may not be unique. Return a message indicating success or failure.
luna_lms.storage.file_storage.FileStorageWrite an re-ordered list of learning contents into the course. course can be an identifier or the course title. An identifier is recommended, since titles may not be unique. Return a message indicating success or failure.
luna_lms.storage.file_storage.FileStorageWrite a variant consisting of a single or multiple files, and create the according meta files. course can be an identifier or the course title. An identifier is recommended, since titles may not be unique. Return the MIME type of the last file written.