Skip to content
Snippets Groups Projects
Commit 4efc1b27 authored by Lennard Strohmeyer's avatar Lennard Strohmeyer :penguin:
Browse files

#106: Weiterleitung an weitere(s) LRS

parent 2ac7dc2b
No related branches found
No related tags found
No related merge requests found
Pipeline #1537552 failed
......@@ -186,8 +186,31 @@ Essential verbs are verbs that are always collected. The user can not disagree t
```
The configuration of the verbs is identical to that of other verbs within the schema. You can also restrict the verbs to specific verbs. That allows the essential data collection for example for specific objects using the id-based filtering approach.
### Additional LRS
Additional LRS can be supplied to forward incoming xAPI statements for the given provider to further LRS, in addition to the global LRS set for the application. Statements are forwarded without further filtering.
```json
{
"id": "h5p-0",
"name": "H5P",
"description": "Open-source content collaboration framework",
"groups": [
...
],
"essentialVerbs": [
...
],
"additionalLrs": [
{
"url": "https://other-lrs.example.com/xapi/statements",
"token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ0b2tlbl90eXBlIjoiYWNjZXNzIiwiZXhwIjoxNzMyNzE5..."
}
]
}
```
## Validate Schema
It is possible to validate the schema againts the json schema from the repository of the rights engine (`src/static/provider_schema.schema.json`). You can use multiple online tools like https://www.jsonschemavalidator.net/ to validated the schema before uploading it to Polaris.
It is possible to validate the schema againts the json schema from the repository of the rights engine (`src/static/provider_schema.schema.json`). You can use multiple online tools like https://www.jsonschemavalidator.net/ to validate the schema before uploading it to Polaris.
## Update Schema
......@@ -304,7 +327,8 @@ You have the option to retain the existing schema, translate specific properties
"isDefault": true
}
],
"essentialVerbs": []
"essentialVerbs": [],
"additionalLrs": []
}
......
......@@ -15,7 +15,7 @@ class ProviderSchemaSerializer(serializers.ModelSerializer):
"name": obj.provider.name,
"description": obj.provider.description,
"groups": obj.groups,
"essential_verbs": obj.essential_verbs,
"essential_verbs": obj.essential_verbs
}
class Meta:
......
......@@ -261,6 +261,7 @@ class CreateProviderConsentView(APIView):
provider=providerModel,
groups=provider_schema["groups"],
essential_verbs=provider_schema["essentialVerbs"],
additional_lrs=provider_schema["additionalLrs"]
)
precedingProviderSchema.superseded_by = providerSchemaModel
precedingProviderSchema.save()
......@@ -275,6 +276,7 @@ class CreateProviderConsentView(APIView):
provider=providerModel,
groups=provider_schema["groups"],
essential_verbs=provider_schema["essentialVerbs"],
additional_lrs=provider_schema["additionalLrs"]
)
return JsonResponse(
......
......@@ -4511,6 +4511,7 @@
}
],
"essential_verbs": [],
"additional_lrs": [],
"updated": "2023-03-16T09:02:08.898Z",
"created": "2023-03-16T09:02:08.898Z"
}
......
# Generated by Django 4.1.2 on 2024-11-27 15:04
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('providers', '0006_analyticstoken_description_analyticstoken_image_path'),
]
operations = [
migrations.AddField(
model_name='providerschema',
name='additional_lrs',
field=models.JSONField(default=list),
),
]
......@@ -22,6 +22,7 @@ class ProviderSchema(models.Model):
superseded_by = models.ForeignKey("self", null=True, on_delete=models.SET_NULL)
groups = models.JSONField()
essential_verbs = models.JSONField()
additional_lrs = models.JSONField(default=list)
updated = models.DateTimeField(auto_now=True)
created = models.DateTimeField(auto_now_add=True)
......
......@@ -133,6 +133,25 @@
"required": ["id", "label", "description", "defaultConsent", "objects"]
}
]
},
"additionalLrs": {
"type": "array",
"items": [
{
"type": "object",
"properties": {
"url": {
"type": "string",
"description": "URL of the store-endpoint for an additional LRS"
},
"token": {
"type": "string",
"description": "token to authenticate with"
}
},
"required": ["url", "token"]
}
]
}
},
"required": ["id", "name", "description", "groups", "essentialVerbs"]
......
......@@ -315,6 +315,17 @@ class CreateStatement(APIView):
request.data if isinstance(request.data, list) else [request.data]
)
# forward to other LRS without validation etc., if given
if latest_schema.additional_lrs and isinstance(latest_schema.additional_lrs, list) and len(latest_schema.additional_lrs) > 0:
for additional_lrs in latest_schema.additional_lrs:
headers = {"Authorization": "Bearer " + additional_lrs["token"]}
for stmt in x_api_statements:
res = requests.post(additional_lrs["url"], json=stmt, headers=headers)
if not res and settings.DEBUG:
print("Could not forward to ", additional_lrs["url"], ":", res.reason, "({})".format(res.status_code))
elif res and settings.DEBUG:
print("Forwarded statement to ", additional_lrs["url"], ":", res.reason, "({})".format(res.status_code))
if settings.SHOW_XAPI_STATEMENTS:
print(x_api_statements)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment