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

Statement Template validation does not support keys that are IRIs #8

Closed
kelvinqian00 opened this issue Jan 26, 2021 · 1 comment
Closed

Comments

@kelvinqian00
Copy link
Collaborator

kelvinqian00 commented Jan 26, 2021

Description: Statement Templates with rules that reference keys that are IRIs will not properly validate Statements, as the validation library cannot extract values properly.

Example: The following Statement (generated by DATASIM):

{
        "actor": {
            "mbox": "mailto:bob@example.org",
            "name": "Bob Fakename"
        },
        "context": {
            "contextActivities": {
                "category": [
                    {
                        "id": "https://w3id.org/xapi/cmi5/v1.0"
                    }
                ]
            },
            "extensions": {
                "https://w3id.org/xapi/cmi5/context/extensions/launchmode": [
                    "Review",
                    "Normal",
                    "Browse"
                ],
                "https://w3id.org/xapi/cmi5/context/extensions/launchparameters": "UVzahSV5qzm5DI1IZbyFJ9g1OT2W7",
                "https://w3id.org/xapi/cmi5/context/extensions/launchurl": "8S6Z7rLwyOJ4pwBvq",
                "https://w3id.org/xapi/cmi5/context/extensions/moveon": [
                    "NotApplicable",
                    "CompletedOrPassed",
                    "Completed",
                    "CompletedAndPassed",
                    "Passed"
                ]
            },
            "registration": "f851859f-b0fe-4b36-9939-4276b96d302d"
        },
        "id": "8dfe2e4f-5644-4486-ba16-a3289a507593",
        "object": {
            "definition": {
                "type": "https://w3id.org/xapi/cmi5/activitytype/block"
            },
            "id": "https://example.org/block/1587280280"
        },
        "timestamp": "2019-11-18T13:05:34.279Z",
        "verb": {
            "id": "http://adlnet.gov/expapi/verbs/launched"
        }
    }

should conform to the following Statement Template:

{
            "id": "https://w3id.org/xapi/cmi5#launched",
            "type": "StatementTemplate",
            "prefLabel": {
                "en": "Launched"
            },
            "definition": {
                "en": "Launched some event"
            },
            "inScheme": "https://w3id.org/xapi/cmi5/v1.0",
            "verb": "http://adlnet.gov/expapi/verbs/launched",
            "rules": [
                {
                    "location": "$.result.score",
                    "presence": "excluded"
                },
                {
                    "location": "$.result.success",
                    "presence": "excluded"
                },
                {
                    "location": "$.result.completion",
                    "presence": "excluded"
                },
                {
                    "location": "$.context.contextActivities.category[*].id",
                    "none": ["https://w3id.org/xapi/cmi5/context/categories/moveon"]
                },
                {
                    "location": "$.context.extensions['https://w3id.org/xapi/cmi5/context/extensions/launchmode']",
                    "presence": "included",
                    "all": ["Normal", "Browse", "Review"]
                },
                {
                    "location": "$.context.extensions['https://w3id.org/xapi/cmi5/context/extensions/launchurl']",
                    "presence": "included",
                    "scopeNote": {"en": "Insert scope note here."}
                },
                {
                    "location": "$.context.extensions['https://w3id.org/xapi/cmi5/context/extensions/moveon']",
                    "presence": "included",
                    "all": ["Passed", "Completed", "CompletedAndPassed", "CompletedOrPassed", "NotApplicable"]
                },
                {
                    "location": "$.context.extensions['https://w3id.org/xapi/cmi5/context/extensions/launchparameters']",
                    "presence": "included"
                }
            ]
        }

but it will report errors stating that the rules involving $.context.extensions['...'] locations are not being followed.

Solution: Use a different JSONPath library, such as Pathetic (which appears to support IRI keys).

@kelvinqian00
Copy link
Collaborator Author

Duplicate of #3 (leaving this up to give another example).

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

No branches or pull requests

1 participant