Skip to content
Snippets Groups Projects
Commit 173bcd82 authored by Benjamin Ledel's avatar Benjamin Ledel
Browse files

* xapi and debugging tools

parent 5c0b2b97
Branches
Tags
No related merge requests found
......@@ -44,6 +44,7 @@ ANALYTICS_RESULTS_RETENTION = env("ANALYTICS_RESULTS_RETENTION", default=31)
ALLOWED_HOSTS = ["*"]
IDP_ENABLED = env("IDP_ENABLED")
SHOW_XAPI_STATEMENTS = env("SHOW_XAPI_STATEMENTS", default=False)
# Application definition
......
......@@ -234,13 +234,7 @@
"$ref": "#/$defs/group"
},
"contextActivities": {
"type": "object",
"properties": {
"parent": { "type": "array", "items": { "$ref": "#/$defs/activity" } },
"category": { "type": "array", "items": { "$ref": "#/$defs/activity" } },
"grouping": { "type": "array", "items": { "$ref": "#/$defs/activity" } },
"other": { "type": "array", "items": { "$ref": "#/$defs/activity" } }
}
"type": "object"
},
"revision": {
"type": "string"
......
......@@ -126,7 +126,8 @@ def process_statement(x_api_statement, provider, latest_schema):
# has the user given consent to the object at hand?
object_consent = False
verb_objects = json.loads(user_consent.object)
if not verb_objects: # no objects defined, "consent" by default
object_statement = x_api_statement["object"]["definition"]
if not verb_objects or len(verb_objects) == 0: # no objects defined, "consent" by default
object_consent = True
else:
for obj in verb_objects:
......@@ -154,7 +155,7 @@ def process_statement(x_api_statement, provider, latest_schema):
return {
"valid": True,
"accepted": False,
"reason": "User has not given consent to this object",
"reason": f"User has not given consent to this object: {object_statement} for verb {verb}",
}
return {"valid": True, "accepted": True}
......@@ -241,10 +242,11 @@ class CreateStatement(APIView):
)
# TODO remove this actor override
# for stmt in x_api_statements:
# stmt["actor"]["account"]["name"] = "user1@polaris.com"
for stmt in x_api_statements:
stmt["actor"]["account"]["name"] = "user1@polaris.com"
#print(x_api_statements)
if settings.SHOW_XAPI_STATEMENTS:
print(x_api_statements)
result = [
process_statement(stmt, provider, latest_schema)
......@@ -254,7 +256,10 @@ class CreateStatement(APIView):
invalid_or_not_consented = (
len([e for e in result if e["valid"] == False or e["accepted"] == False])
> 0
)
)
if settings.SHOW_XAPI_STATEMENTS:
print(result)
if invalid_or_not_consented:
return JsonResponse(
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment