Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ImportMetadataViewset to kolibri_public app #3951

Closed
bjester opened this issue Feb 7, 2023 · 2 comments
Closed

Add ImportMetadataViewset to kolibri_public app #3951

bjester opened this issue Feb 7, 2023 · 2 comments
Assignees
Labels
DEV: backend P0 - critical Priority: Release blocker or regression TAG: new feature

Comments

@bjester
Copy link
Member

bjester commented Feb 7, 2023

Parent: #3808
Depends: #3927

Desired behavior

Add new ImportMetadataViewset to Studio's kolibri_public app

  • It should only accept read-only GET method requests
  • /kolibri/api/public/v2/importmetadata/<contentnode_id> should return a response for the requested content node-- list queries are not currently supported
  • It should return a 400 error if a schema_version integer request parameter is above 5
  • For each model ContentNode, File, LocalFile, ContentTag, AssessmentMetadata, and ContentNode.tags.through, it should return raw JSON serialized versions of the models in their corresponding fields within the response
    • Note some model fields store JSON and should return their JSON serialized content, not as nested JSON objects within the response
  • It should have a Cache-control response header with value public, stale-while-revalidate=100, max-age=300
  • It should add a Last-modified response header which is equal to the last_updated of the channel in the response
  • It should accept a If-modified-since request header and should minimally filter the request and return a 304 Not modified response if the channel's last_updated isn't greater (see conditional processing)
  • It should not return any Set-cookie headers in the response

Example API response

{
    "schema_version": "5",
    "content_channelmetadata": [],
    "content_contenttag": [],
    "content_assessmentmetadata": [],
    "content_contentnode_tags": [],
    "content_localfile": [],
    "content_file": [],
    "content_contentnode": [],
    "content_language": [],

    // Note the following will always be empty
    "content_contentnode_has_prerequisite": [],
    "content_contentnode_related": []
}

Example API objects for content_channelmetadata

{
    "last_updated": "2023-02-03 17:10:22.581962(America/Los_Angeles)",
    "description": "EENET and the Norwegian Association of the Disabled have partnered to share this collection of inclusive learning activities for parents and children, especially those with special needs. Make your own game, create crafts, learn to cook, explore the world around you, and more.",
    "author": "",
    "tagline": null,
    "root_id": "378cf4128c854c2795c100b5aca7a3ed",
    "thumbnail": "data:image/jpg;base64,...",
    "version": 3,
    "min_schema_version": "1",
    "id": "378cf4128c854c2795c100b5aca7a3ed",
    "name": "Inclusive Home Learning Activities"
}

Example API objects for content_contentnode

{
    "grade_levels": null,
    "rght": 8,
    "coach_content": false,
    "learning_activities": null,
    "sort_order": 4,
    "duration": null,
    "license_description": "The Attribution License lets others distribute, remix, tweak, and build upon your work, even commercially, as long as they credit you for the original creation. This is the most accommodating of licenses offered. Recommended for maximum dissemination and use of licensed materials.",
    "id": "7f0ccfca967340a585e010cce7dfcaf6",
    "title": "Home Learning Activities -- Printable Book and Poster",
    "license_owner": "",
    "parent_id": "77638876a1c14d40b6be2a4910151528",
    "accessibility_labels": null,
    "lang_id": "mul",
    "tree_id": 1,
    "available": true,
    "description": "",
    "license_name": "CC BY",
    "learner_needs": null,
    "level": 2,
    "categories": null,
    "kind": "topic",
    "resource_types": null,
    "lft": 3,
    "author": "",
    "channel_id": "378cf4128c854c2795c100b5aca7a3ed",
    "content_id": "d9b7a5f9b635406ab5edf6457f02ebce",
    "options": "{}"
}

Example API objects for content_file

{
    "priority": 1,
    "local_file_id": "82a790e87876718e1d1bf245f14efb84",
    "lang_id": null,
    "thumbnail": true,
    "supplementary": true,
    "preset": "topic_thumbnail",
    "contentnode_id": "77638876a1c14d40b6be2a4910151528",
    "id": "7da05529dce34fcc9de1501e09895335"
}

Example API objects for content_localfile

{
    "available": true,
    "id": "82a790e87876718e1d1bf245f14efb84",
    "extension": "png",
    "file_size": 67056
}

Example API objects for content_language

{
  "lang_code": "en",
  "lang_direction": "ltr",
  "lang_subcode": null,
  "id": "en",
  "lang_name": "English"
}

Example API objects for content_contenttag

{
  "tag_name": "test1",
  "id": "4532610bd01a4298b582cc911d2ffb17"
}

Example API objects for content_contentnode_tags

{
    "id": 3,
    "contenttag_id": "4532610bd01a4298b582cc911d2ffb17",
    "contentnode_id": "35f3a6eb56804c979e13c5327b56885e"
}

Example API objects for content_assessmentmetadata

{
    "assessment_item_ids": "[\"ff1b25cbe87858dd9d2bf96c1a240c76\",\"f8776701715e532bbdb446775688aef5\",\"0b985060caa9514faae3abd58f506e05\",\"53d5050dd411585d8fb7fe107c00b9b9\",\"bf324bcf5f0a5dce9c015bee95985f1a\",\"cdea3632e97a53fb94bfd1783c3b9f13\",\"bc633284f2235a95856fe850c9440e27\",\"655ed0c4d55c5635a803d18dbe6e7921\",\"d6ad32f8978355d89c259520c05ba123\",\"ce235b3388a957edadc7779fcfab46e5\",\"648adbf876d159fe882135626de625ac\",\"9d578d9a99be5c079bd25b25dba73de2\",\"3a7bb93f9e7b5fa0b576022d0a97904e\",\"cd37c241e5925e2c8083201900d4242f\",\"ff94066a39555a4dad171adddb7c5905\",\"ef6ad7dc214451fb9cf56e831f3ce88b\",\"1026563cec4c55e89754b139bef22ee8\",\"0352d4610a42558d8a3209199c5a768a\",\"a498826b66bf5e5792c66174f64783b6\",\"557aa88bf3585ca79612b1bd559dde98\",\"8794e316215852caaee7bd713381af75\",\"14d44a631f6e5ef9afbb8aeb39c9653c\",\"a2573b8b2d5b53908f7b700a03dcac88\",\"166194953bec56a78106ad550da72fb4\"]",
    "randomize": true,
    "contentnode_id": "30b6517001825974a2af2c945a9024fb",
    "number_of_assessments": 24,
    "is_manipulable": true,
    "mastery_model": "{\"type\":\"m_of_n\",\"m\":5,\"n\":5}",
    "id": "fe6640875d9c4a2da45924cd12a8b2b6"
}

Current behavior

No such API viewset exists in Studio currently

Value add

This API will support remote content browsing and import from Kolibri 0.16+ instances

Notes

@bjester bjester added TAG: new feature DEV: backend P0 - critical Priority: Release blocker or regression labels Feb 7, 2023
@rtibbles
Copy link
Member

rtibbles commented Feb 9, 2023

Implementation note: this can probably be mostly copy pasted from the equivalent endpoint in Kolibri - however, there are a couple of things that will need to be modified.

Firstly is that the prefix of the table names content_ will be naturally rendered as kolibri_public_ for most tables, so this should be substituted.

Secondly, because we are using the contentcuration Language model, we will have to do a field mapping for languages, in order to map from the contentcuration language fields to the kolibri_public language fields. The table name will also need to be updated to content_language.

@rtibbles
Copy link
Member

Fixed in #3987

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
DEV: backend P0 - critical Priority: Release blocker or regression TAG: new feature
Projects
None yet
Development

No branches or pull requests

2 participants