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 ContentNodeMetadata model and API viewset #3930

Closed
bjester opened this issue Jan 26, 2023 · 2 comments
Closed

Add ContentNodeMetadata model and API viewset #3930

bjester opened this issue Jan 26, 2023 · 2 comments
Assignees
Labels

Comments

@bjester
Copy link
Member

bjester commented Jan 26, 2023

Parent: #3808
Depends: #3927, #3929

Desired behavior

Add a new model ContentNodeMetadata to the kolibri_public app

  • It should inherit ContentNode from the existing kolibri_content app
  • It should nominally implement the same additional fields as ContentNode from kolibri/content
  • The lang field should be overridden and made a FK to the core Language model
  • The license field should be overridden and made a FK to the core License model

Add a new ContentNodeMetadataViewset similar to Kolibri's which returns a JSON response

  • It should only accept read-only GET method requests
  • /kolibri/api/public/v2/contentnode/ should require at least one filter and return matching content nodes
  • /kolibri/api/public/v2/contentnode/<contentnode_id> should return info for the requested contentnode
  • It should use cursor based pagination for list responses, utilizing a max_results param defaulting to 25 (set an absolute maximum of 100)
  • It should support the same filtering params that Kolibri does
  • It should annotate associated files, language, and assessment metadata in the response if applicable (see response examples below)
  • It should annotate any available fields as True
  • It should make all storage URLs absolute for files or thumbnails (for example https://studio.learningequality.org/content/ or https://hotfixes.studio.learningequality.org/content/ etc. depending on the environment)
  • 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 greatest last_updated of the channel(s) 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 no associated channels in the response have a last_updated that is greater (see conditional processing)
  • It should not return any Set-cookie headers in the response

Example response: contentnode metadata

{
  "id": "cf1de634e5855069bcb135e3b6ae3545",
  "author": "",
  "available": true,
  "channel_id": "c1f2b7e6ac9f56a2bb44fa7a48b66dce",
  "coach_content": false,
  "content_id": "965bc8aa4ab75776a5a02a47f6ad8012",
  "description": "Una tabla de tallos y hojas se utiliza para mostrar datos. El 'tallo' a la izquierda muestra el primer dígito o dígitos. La 'hoja' a la derecha muestra el último dígito. Por ejemplo, 543 y 548 pueden mostrarse juntos como tallo y hoja así: 54 | 3,8.",
  "kind": "video",
  "license_description": "",
  "license_name": "CC BY-NC-SA",
  "license_owner": "Khan Academy",
  "num_coach_contents": 0,
  "options": {},
  "parent": "521113d0522d50e38fadfd6bfa29f3f4",
  "sort_order": 1,
  "title": "Los diagramas de tallo y hoja",
  "lft": 1998,
  "rght": 1999,
  "tree_id": 8,
  "learning_activities": [
    "UD5UGM0z"
  ],
  "grade_levels": [
    "BkGYi3lD"
  ],
  "resource_types": [],
  "accessibility_labels": [],
  "categories": [
    "d&WXdXWF.qs0Xlaxq.0t5msbL5"
  ],
  "duration": null,
  "ancestors": [
    {
      "id": "c1f2b7e6ac9f56a2bb44fa7a48b66dce",
      "title": "Khan Academy (Español)"
    },
    {
      "id": "5edd6eae85eb55f097cd218e45a66e8c",
      "title": "Matemáticas"
    },
    {
      "id": "cde5a643de405d07b9b04a18bc9db451",
      "title": "Preálgebra"
    },
    {
      "id": "0bb4444aa1905746a0fc193adacffdf1",
      "title": "Leer e interpretar datos"
    },
    {
      "id": "521113d0522d50e38fadfd6bfa29f3f4",
      "title": "Diagramas de tallos y hojas"
    }
  ],
  "assessmentmetadata": {...},
  "tags": ["tag1", "tag2"],
  "files": [...],
  "thumbnail": "https://studio.learningequality.org/content/storage/d/5/d521574b567a6054146e0351a293e559.png",
  "lang": {...},
  "is_leaf": true
}

Example response: contentnode.lang

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

Example response: contentnode.files[]

{
  "id": "aeb5b9cb1bb441b18a6aa305871d7836",
  "priority": 2,
  "preset": "low_res_video",
  "supplementary": false,
  "thumbnail": false,
  "lang": null,
  "checksum": "00fbaef027e5e3a7b27be50bf015cc3c",
  "available": true,
  "file_size": 2812691,
  "extension": "mp4",
  "storage_url": "https://studio.learningequality.org/content/storage/0/0/00fbaef027e5e3a7b27be50bf015cc3c.mp4"
}

Example response: contentnode.assessmentmetadata

{
    "assessment_item_ids": [
        "6006a858fd8c542788dc246a21d5df1a",
        "f19614187215539d804930300fd26ee2",
        "8e8c635433b95f62944725b9de1d3ca0",
        "8ec86ffaecc253c3b9346ae26aa3ada4"
    ],
    "number_of_assessments": 24,
    "mastery_model": {
        "type": "m_of_n",
        "n": 4,
        "m": 3
    },
    "randomize": true,
    "is_manipulable": true,
    "contentnode": "b6f8e89954665ac8bb01d92dc4bba95c"
}

Current behavior

These do not exist currently on Studio

Value add

This model and API will support remote content browsing on Studio

@bjester
Copy link
Member Author

bjester commented Feb 7, 2023

Also, ensure that there isn't a Set-cookie header in the response https://developers.cloudflare.com/cache/about/default-cache-behavior/

@bjester bjester added the P0 - critical Priority: Release blocker or regression label Feb 8, 2023
@rtibbles
Copy link
Member

Fixed in #3955

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants