From 2596949096511bb0085ebd06b04684168f30cb74 Mon Sep 17 00:00:00 2001
From: kelvinqian00 <kelvinqian2@gmail.com>
Date: Fri, 19 Jan 2024 16:17:04 -0500
Subject: [PATCH 01/10] Change typo in periodic nvd scan workflow

---
 .github/workflows/nvd.yml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/.github/workflows/nvd.yml b/.github/workflows/nvd.yml
index a15c12d3..0146641a 100644
--- a/.github/workflows/nvd.yml
+++ b/.github/workflows/nvd.yml
@@ -13,4 +13,4 @@ jobs:
       nvd-config-filename: '.nvd/config.json'
       notify-slack: true
     secrets:
-      SLACK_WORKFLOW_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
+      SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}

From ba06c32b322487bd9e5c3f5164da6668d36d1b09 Mon Sep 17 00:00:00 2001
From: kelvinqian00 <kelvinqian2@gmail.com>
Date: Thu, 25 Jan 2024 14:54:45 -0500
Subject: [PATCH 02/10] Write activityDefinition in place of definition

---
 .../datasim/xapi/profile/activity.clj            | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/src/main/com/yetanalytics/datasim/xapi/profile/activity.clj b/src/main/com/yetanalytics/datasim/xapi/profile/activity.clj
index 36a1d2b5..5d067a5f 100644
--- a/src/main/com/yetanalytics/datasim/xapi/profile/activity.clj
+++ b/src/main/com/yetanalytics/datasim/xapi/profile/activity.clj
@@ -78,7 +78,9 @@
 (defn- assoc-activity
   "Associate `activity` to `activity-map`."
   [activity-map activity]
-  (let [{activity-id :id {activity-type-id :type} :definition} activity]
+  (let [{activity-id :id
+         {activity-type-id :type} :activityDefinition}
+        activity]
     (assoc-in activity-map
               [activity-type-id activity-id]
               (profile->statement-activity activity))))
@@ -158,3 +160,15 @@
     (-> {}
         (reduce-activities concept-activities)
         (reduce-act-type-ids activity-type-ids))))
+
+(comment
+  (create-activity-map
+   {"Activity"
+    {"http://profiles.afrl.af.mil/elements/airsense"
+     {:id "http://profiles.afrl.af.mil/elements/airsense"
+      :type "Activity"
+      :definition {:name {:en "Airsense"}
+                   :definition {:en "Recognizes..."}
+                   :type "http://profiles.afrl.af.mil/elements"}}}}
+   100)
+  )

From 9a724b00917cd815c3090b06e0bd3bae4c072266 Mon Sep 17 00:00:00 2001
From: kelvinqian00 <kelvinqian2@gmail.com>
Date: Thu, 25 Jan 2024 15:11:31 -0500
Subject: [PATCH 03/10] Fix activity-profile test constant

---
 src/test/com/yetanalytics/datasim/xapi/profile_test.clj | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/test/com/yetanalytics/datasim/xapi/profile_test.clj b/src/test/com/yetanalytics/datasim/xapi/profile_test.clj
index 26b28a33..7a0b8174 100644
--- a/src/test/com/yetanalytics/datasim/xapi/profile_test.clj
+++ b/src/test/com/yetanalytics/datasim/xapi/profile_test.clj
@@ -76,9 +76,9 @@
 
 (def activity-profile
   {:id "http://example.org/activity-profile"
-   :concepts [{:id         "http://example.org/activity-with-type"
-               :type       "Activity"
-               :definition {:type "http://example.org/activity-type-1"}}
+   :concepts [{:id                 "http://example.org/activity-with-type"
+               :type               "Activity"
+               :activityDefinition {:type "http://example.org/activity-type-1"}}
               {:id   "http://example.org/activity-without-type"
                :type "Activity"}
               {:id   "http://example.org/activity-type-1"

From b10a1c43521409e0304a858c2f122a052271f292 Mon Sep 17 00:00:00 2001
From: kelvinqian00 <kelvinqian2@gmail.com>
Date: Thu, 25 Jan 2024 15:49:17 -0500
Subject: [PATCH 04/10] Replace definition with activityDefinition elsewhere

---
 .../datasim/xapi/profile/activity.clj         | 21 ++++---------------
 1 file changed, 4 insertions(+), 17 deletions(-)

diff --git a/src/main/com/yetanalytics/datasim/xapi/profile/activity.clj b/src/main/com/yetanalytics/datasim/xapi/profile/activity.clj
index 5d067a5f..ed1875ad 100644
--- a/src/main/com/yetanalytics/datasim/xapi/profile/activity.clj
+++ b/src/main/com/yetanalytics/datasim/xapi/profile/activity.clj
@@ -68,12 +68,11 @@
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
 (defn- profile->statement-activity
-  [{:keys [id definition]}]
+  [{:keys [id activityDefinition]}]
   (cond-> {"id" id}
-    definition
-    (assoc "definition" (-> definition
-                            (dissoc definition :_context)
-                            w/stringify-keys))))
+    activityDefinition
+    (assoc "definition"
+           (-> activityDefinition (dissoc :_context) w/stringify-keys))))
 
 (defn- assoc-activity
   "Associate `activity` to `activity-map`."
@@ -160,15 +159,3 @@
     (-> {}
         (reduce-activities concept-activities)
         (reduce-act-type-ids activity-type-ids))))
-
-(comment
-  (create-activity-map
-   {"Activity"
-    {"http://profiles.afrl.af.mil/elements/airsense"
-     {:id "http://profiles.afrl.af.mil/elements/airsense"
-      :type "Activity"
-      :definition {:name {:en "Airsense"}
-                   :definition {:en "Recognizes..."}
-                   :type "http://profiles.afrl.af.mil/elements"}}}}
-   100)
-  )

From 683ddf1da2528646d3db47184cc8d7df63827029 Mon Sep 17 00:00:00 2001
From: kelvinqian00 <kelvinqian2@gmail.com>
Date: Thu, 25 Jan 2024 16:01:35 -0500
Subject: [PATCH 05/10] Add more content to activity-profile

---
 .../datasim/xapi/profile_test.clj             | 37 ++++++++++++++-----
 1 file changed, 27 insertions(+), 10 deletions(-)

diff --git a/src/test/com/yetanalytics/datasim/xapi/profile_test.clj b/src/test/com/yetanalytics/datasim/xapi/profile_test.clj
index 7a0b8174..f0ceb731 100644
--- a/src/test/com/yetanalytics/datasim/xapi/profile_test.clj
+++ b/src/test/com/yetanalytics/datasim/xapi/profile_test.clj
@@ -76,33 +76,46 @@
 
 (def activity-profile
   {:id "http://example.org/activity-profile"
-   :concepts [{:id                 "http://example.org/activity-with-type"
-               :type               "Activity"
-               :activityDefinition {:type "http://example.org/activity-type-1"}}
+   :concepts [{:id   "http://example.org/activity-with-type"
+               :type "Activity"
+               :activityDefinition {:name {:en "Typed Activity"}
+                                    :type "http://example.org/activity-type-1"}}
               {:id   "http://example.org/activity-without-type"
-               :type "Activity"}
+               :type "Activity"
+               :activityDefinition {:name {:en "Non-typed Activity"}}}
               {:id   "http://example.org/activity-type-1"
                :type "ActivityType"}
               {:id   "http://example.org/activity-type-2"
                :type "ActivityType"}
               {:id   "http://example.org/activity-type-3"
                :type "ActivityType"}]
-   :templates [{:id "http://example.org/template"
+   :templates [{:id "http://example.org/template-1"
                 :objectActivityType "http://example.org/activity-type-1"}
-               {:id "http://example.org/template"
+               {:id "http://example.org/template-2"
                 :rules [{:location "$.object.definition.type"
                          :all ["http://example.org/activity-type-1"]}
                         {:location "$.object.definition"
-                         :all [{:type "http://example.org/activity-type-1"}]}]}]})
+                         :all [{:type "http://example.org/activity-type-1"}]}]}
+               {:id "http://example.org/template-3"
+                :rules [{:location "$.object.id"
+                         :all ["http://example.org/activity-with-type"]}]}
+               {:id "http://example.org/template-4"
+                :rules [{:location "$.object.definition.type"
+                         :all ["http://example.org/activity-type-not-exists"]}]}
+               {:id "http://example.org/template-5" ; not added at this step
+                :rules [{:location "$.object.id"    ; added during statement healing
+                         :all ["http://example.org/activity-not-exists"]}]}]})
 
 (def expected-activity-map
   {nil
    {"http://example.org/activity-without-type"
-    {"id" "http://example.org/activity-without-type"}}
+    {"id" "http://example.org/activity-without-type"
+     "definition" {"name" {"en" "Non-typed Activity"}}}}
    "http://example.org/activity-type-1"
    {"http://example.org/activity-with-type"
     {"id" "http://example.org/activity-with-type"
-     "definition" {"type" "http://example.org/activity-type-1"}}}
+     "definition" {"name" {"en" "Typed Activity"}
+                   "type" "http://example.org/activity-type-1"}}}
    "http://example.org/activity-type-2"
    {"https://example.org/activity/418707894"
     {"id"         "https://example.org/activity/418707894"
@@ -110,7 +123,11 @@
    "http://example.org/activity-type-3"
    {"https://example.org/activity/1432714272"
     {"id" "https://example.org/activity/1432714272"
-     "definition" {"type" "http://example.org/activity-type-3"}}}})
+     "definition" {"type" "http://example.org/activity-type-3"}}}
+   "http://example.org/activity-type-not-exists"
+   {"https://example.org/activity/1671689032"
+    {"id" "https://example.org/activity/1671689032"
+     "definition" {"type" "http://example.org/activity-type-not-exists"}}}})
 
 (deftest activity-map-test
   (testing "Activity Map creation"

From 7e87485ca80a40b743ace573d8fa53c52124534d Mon Sep 17 00:00:00 2001
From: kelvinqian00 <kelvinqian2@gmail.com>
Date: Thu, 25 Jan 2024 19:31:26 -0500
Subject: [PATCH 06/10] Stringify keys for rule values

---
 src/main/com/yetanalytics/datasim/xapi/rule.clj | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/src/main/com/yetanalytics/datasim/xapi/rule.clj b/src/main/com/yetanalytics/datasim/xapi/rule.clj
index 2ee4883d..71e3797d 100644
--- a/src/main/com/yetanalytics/datasim/xapi/rule.clj
+++ b/src/main/com/yetanalytics/datasim/xapi/rule.clj
@@ -9,6 +9,7 @@
             [clojure.string                 :as cstr]
             [clojure.spec.alpha             :as s]
             [clojure.test.check.generators  :as gen]
+            [clojure.walk                   :as w]
             [xapi-schema.spec               :as xs]
             [com.yetanalytics.pathetic      :as path]
             [com.yetanalytics.pathetic.path :as jpath]
@@ -206,9 +207,9 @@
   (let [paths (cond-> (parse-json-path location)
                 selector
                 (join-location-and-selector (parse-json-path selector)))
-        ?any  (not-empty (set any))
-        ?all  (not-empty (set all))
-        ?none (not-empty (set none))]
+        ?any  (not-empty (set (map w/stringify-keys any)))
+        ?all  (not-empty (set (map w/stringify-keys all)))
+        ?none (not-empty (set (map w/stringify-keys none)))]
     (cond-> {:location paths}
       presence       (assoc :presence (keyword presence))
       (or ?any ?all) (assoc :valueset (rule-value-set ?any ?all ?none))

From ad5fe28c679c18712a37bd8531abcf57f501d539 Mon Sep 17 00:00:00 2001
From: kelvinqian00 <kelvinqian2@gmail.com>
Date: Thu, 25 Jan 2024 19:31:46 -0500
Subject: [PATCH 07/10] Test activity references within profiles

---
 dev-resources/profiles/activity.jsonld        | 153 ++++++++++++++++++
 .../datasim/input/profile_test.clj            |   4 +-
 .../yetanalytics/datasim/test_constants.clj   |  13 +-
 src/test/com/yetanalytics/datasim_test.clj    |  18 ++-
 4 files changed, 181 insertions(+), 7 deletions(-)
 create mode 100644 dev-resources/profiles/activity.jsonld

diff --git a/dev-resources/profiles/activity.jsonld b/dev-resources/profiles/activity.jsonld
new file mode 100644
index 00000000..e36a3ecd
--- /dev/null
+++ b/dev-resources/profiles/activity.jsonld
@@ -0,0 +1,153 @@
+{
+    "id": "https://xapinet.org/xapi/yet/activity-profile",
+    "type": "Profile",
+    "@context": "https://w3id.org/xapi/profiles/context",
+    "conformsTo": "https://w3id.org/xapi/profiles#1.0",
+    "prefLabel": {
+        "en": "Activity Test Profile"
+    },
+    "definition": {
+        "en": "This Profile is intended to test Activity and Activity Types"
+    },
+    "versions": [
+        {
+            "id": "https://xapinet.org/xapi/yet/activity-profile/v1",
+            "generatedAtTime": "2024-01-25T10:10:10Z"
+        }
+    ],
+    "author": {
+        "url": "https://www.yetanalytics.com/",
+        "name": "Yet Analytics",
+        "type": "Organization"
+    },
+    "concepts": [
+        {
+            "id": "https://xapinet.org/xapi/yet/activity/nontyped",
+            "type": "Activity",
+            "inScheme": "https://xapinet.org/xapi/yet/activity-profile/v1",
+            "activityDefinition": {
+                "@context": "https://w3id.org/xapi/profiles/activity-context",
+                "name": {
+                    "en": "Activity without Activity Type"
+                },
+                "description": {
+                    "en": "Activity without Activity Type"
+                }
+            }
+        },
+        {
+            "id": "https://xapinet.org/xapi/yet/activity/typed",
+            "type": "Activity",
+            "inScheme": "https://xapinet.org/xapi/yet/activity-profile/v1",
+            "activityDefinition": {
+                "@context": "https://w3id.org/xapi/profiles/activity-context",
+                "name": {
+                    "en": "Activity with Activity Type"
+                },
+                "description": {
+                    "en": "Activity with Activity Type"
+                },
+                "type": "https://xapinet.org/xapi/yet/activity-type"
+            }
+        },
+        {
+            "id": "https://xapinet.org/xapi/yet/activity-type",
+            "type": "ActivityType",
+            "inScheme": "https://xapinet.org/xapi/yet/activity-profile/v1",
+            "prefLabel": {
+                "en": "Activity Type Label"
+            },
+            "definition": {
+                "en": "Activity Type Definition"
+            }
+        }
+    ],
+    "templates": [
+        {
+            "id": "https://xapinet.org/xapi/yet/template/1",
+            "type": "StatementTemplate",
+            "inScheme": "https://xapinet.org/xapi/yet/activity-profile/v1",
+            "prefLabel": {
+                "en": "Template 1"
+            },
+            "definition": {
+                "en": "Template to test objectActivityType"
+            },
+            "objectActivityType": "https://xapinet.org/xapi/yet/activity-type"
+        },
+        {
+            "id": "https://xapinet.org/xapi/yet/template/2",
+            "type": "StatementTemplate",
+            "inScheme": "https://xapinet.org/xapi/yet/activity-profile/v1",
+            "prefLabel": {
+                "en": "Template 2"
+            },
+            "definition": {
+                "en": "Template to test activity type referenced in activity definition"
+            },
+            "rules": [
+                {
+                    "location": "$.object.definition",
+                    "presence": "included",
+                    "all": [{"type": "https://xapinet.org/xapi/yet/activity-type"}]
+                }
+            ]
+        },
+        {
+            "id": "https://xapinet.org/xapi/yet/template/3",
+            "type": "StatementTemplate",
+            "inScheme": "https://xapinet.org/xapi/yet/activity-profile/v1",
+            "prefLabel": {
+                "en": "Template 3"
+            },
+            "definition": {
+                "en": "Template to test activity type referenced by ID"
+            },
+            "rules": [
+                {
+                    "location": "$.object.definition.type",
+                    "presence": "included",
+                    "all": ["https://xapinet.org/xapi/yet/activity-type"]
+                }
+            ]
+        },
+        {
+            "id": "https://xapinet.org/xapi/yet/template/4",
+            "type": "StatementTemplate",
+            "inScheme": "https://xapinet.org/xapi/yet/activity-profile/v1",
+            "prefLabel": {
+                "en": "Template 4"
+            },
+            "definition": {
+                "en": "Template to test activity referenced by ID"
+            },
+            "rules": [
+                {
+                    "location": "$.object.id",
+                    "presence": "included",
+                    "all": ["https://xapinet.org/xapi/yet/activity/nontyped"]
+                }
+            ]
+        }
+    ],
+    "patterns": [
+        {
+            "id": "https://xapi.org/xapi/yet/pattern",
+            "type": "Pattern",
+            "inScheme": "https://xapinet.org/xapi/yet/activity-profile/v1",
+            "primary": true,
+            "prefLabel": {
+                "en": "Primary Pattern"
+            },
+            "definition": {
+                "en": "Sequence pattern for templates 1 to 4"
+            },
+            "sequence": [
+                "https://xapinet.org/xapi/yet/template/1",
+                "https://xapinet.org/xapi/yet/template/2",
+                "https://xapinet.org/xapi/yet/template/3",
+                "https://xapinet.org/xapi/yet/template/4"
+            ]
+        }
+    ]
+}
diff --git a/src/test/com/yetanalytics/datasim/input/profile_test.clj b/src/test/com/yetanalytics/datasim/input/profile_test.clj
index 183e6968..5f3cffdc 100644
--- a/src/test/com/yetanalytics/datasim/input/profile_test.clj
+++ b/src/test/com/yetanalytics/datasim/input/profile_test.clj
@@ -96,11 +96,11 @@
                   count))))
   (testing "fixed / valid profiles"
     (is (nil? (profile/validate-profiles [const/acrossx-profile])))
-    (is (nil? (profile/validate-profiles [const/activity-profile])))
+    (is (nil? (profile/validate-profiles [const/activity-streams-profile])))
     (is (nil? (profile/validate-profiles [const/tc3-profile]))))
   ;; Following tests exist to point out flaws in Profiles
   (testing "invalid profiles"
     ;; AcrossX and ActivityStreams violate spec:
     ;; "related MUST only be used on deprecated Concepts"
     (is (some? (profile/validate-profiles [const/acrossx-profile*])))
-    (is (some? (profile/validate-profiles [const/activity-profile*])))))
+    (is (some? (profile/validate-profiles [const/activity-streams-profile*])))))
diff --git a/src/test/com/yetanalytics/datasim/test_constants.clj b/src/test/com/yetanalytics/datasim/test_constants.clj
index d20a7a5a..9adcfb3d 100644
--- a/src/test/com/yetanalytics/datasim/test_constants.clj
+++ b/src/test/com/yetanalytics/datasim/test_constants.clj
@@ -22,10 +22,12 @@
   "dev-resources/profiles/acrossx/profile.jsonld")
 (def acrossx-profile-filepath
   "dev-resources/profiles/acrossx/fixed.jsonld")
-(def activity-profile-filepath*
+(def activity-streams-profile-filepath*
   "dev-resources/profiles/activity_streams/profile.jsonld")
-(def activity-profile-filepath
+(def activity-streams-profile-filepath
   "dev-resources/profiles/activity_streams/fixed.jsonld")
+(def activity-profile-filepath
+  "dev-resources/profiles/activity.jsonld")
 (def mom-profile-filepath
   "dev-resources/profiles/tla/mom.jsonld")
 (def referential-profile-filepath
@@ -108,8 +110,11 @@
 (def acrossx-profile
   (input/from-location :profile :json acrossx-profile-filepath))
 
-(def activity-profile*
-  (input/from-location :profile :json activity-profile-filepath*))
+(def activity-streams-profile*
+  (input/from-location :profile :json activity-streams-profile-filepath*))
+
+(def activity-streams-profile
+  (input/from-location :profile :json activity-streams-profile-filepath))
 
 (def activity-profile
   (input/from-location :profile :json activity-profile-filepath))
diff --git a/src/test/com/yetanalytics/datasim_test.clj b/src/test/com/yetanalytics/datasim_test.clj
index 82b602eb..8c3e85c6 100644
--- a/src/test/com/yetanalytics/datasim_test.clj
+++ b/src/test/com/yetanalytics/datasim_test.clj
@@ -205,7 +205,23 @@
                  (take-while (partial first-reg? first-fred))
                  (reduce reduce-sats [[]])
                  (every? (fn [sat-stmts]
-                           (<= (count sat-stmts) 100)))))))))
+                           (<= (count sat-stmts) 100))))))))
+  (testing "Respects activity + activity type references within profile"
+    (let [input  (assoc const/simple-input :profiles [const/activity-profile])
+          result (->> (get (generate-map input) alice-mbox) (take 4) vec)]
+      (is (= {"id" "https://xapinet.org/xapi/yet/activity/typed",
+              "definition"
+              {"name"        {"en" "Activity with Activity Type"},
+               "description" {"en" "Activity with Activity Type"},
+               "type"        "https://xapinet.org/xapi/yet/activity-type"}}
+             (-> result (get 0) (get "object"))
+             (-> result (get 1) (get "object"))
+             (-> result (get 2) (get "object"))))
+      (is (= {"id" "https://xapinet.org/xapi/yet/activity/nontyped",
+              "definition"
+              {"name"        {"en" "Activity without Activity Type"},
+               "description" {"en" "Activity without Activity Type"}}}
+             (-> result (get 3) (get "object")))))))
 
 (deftest generate-seq-test
   (testing "Returns statements"

From 3f7b1080fcc3914ac8b085a49e9cc288f463d772 Mon Sep 17 00:00:00 2001
From: kelvinqian00 <kelvinqian2@gmail.com>
Date: Thu, 25 Jan 2024 19:49:03 -0500
Subject: [PATCH 08/10] Add more tests to contextActivities

---
 dev-resources/profiles/activity.jsonld     | 53 +++++++++++++++++++++-
 src/test/com/yetanalytics/datasim_test.clj | 21 +++++++--
 2 files changed, 68 insertions(+), 6 deletions(-)

diff --git a/dev-resources/profiles/activity.jsonld b/dev-resources/profiles/activity.jsonld
index e36a3ecd..3c6e711b 100644
--- a/dev-resources/profiles/activity.jsonld
+++ b/dev-resources/profiles/activity.jsonld
@@ -71,9 +71,13 @@
                 "en": "Template 1"
             },
             "definition": {
-                "en": "Template to test objectActivityType"
+                "en": "Template to test Activity Type determining properties"
             },
-            "objectActivityType": "https://xapinet.org/xapi/yet/activity-type"
+            "objectActivityType": "https://xapinet.org/xapi/yet/activity-type",
+            "contextGroupingActivityType": ["https://xapinet.org/xapi/yet/activity-type"],
+            "contextParentActivityType": ["https://xapinet.org/xapi/yet/activity-type"],
+            "contextOtherActivityType": ["https://xapinet.org/xapi/yet/activity-type"],
+            "contextCategoryActivityType": ["https://xapinet.org/xapi/yet/activity-type"]
         },
         {
             "id": "https://xapinet.org/xapi/yet/template/2",
@@ -90,6 +94,21 @@
                     "location": "$.object.definition",
                     "presence": "included",
                     "all": [{"type": "https://xapinet.org/xapi/yet/activity-type"}]
+                },
+                {
+                    "location": "$.context.contextActivities.grouping[0].definition",
+                    "presence": "included",
+                    "all": [{"type": "https://xapinet.org/xapi/yet/activity-type"}]
+                },
+                {
+                    "location": "$.context.contextActivities.parent[0].definition",
+                    "presence": "included",
+                    "all": [{"type": "https://xapinet.org/xapi/yet/activity-type"}]
+                },
+                {
+                    "location": "$.context.contextActivities.other[0].definition",
+                    "presence": "included",
+                    "all": [{"type": "https://xapinet.org/xapi/yet/activity-type"}]
                 }
             ]
         },
@@ -108,6 +127,21 @@
                     "location": "$.object.definition.type",
                     "presence": "included",
                     "all": ["https://xapinet.org/xapi/yet/activity-type"]
+                },
+                {
+                    "location": "$.context.contextActivities.grouping[0].definition.type",
+                    "presence": "included",
+                    "all": ["https://xapinet.org/xapi/yet/activity-type"]
+                },
+                {
+                    "location": "$.context.contextActivities.parent[0].definition.type",
+                    "presence": "included",
+                    "all": ["https://xapinet.org/xapi/yet/activity-type"]
+                },
+                {
+                    "location": "$.context.contextActivities.other[0].definition.type",
+                    "presence": "included",
+                    "all": ["https://xapinet.org/xapi/yet/activity-type"]
                 }
             ]
         },
@@ -126,6 +160,21 @@
                     "location": "$.object.id",
                     "presence": "included",
                     "all": ["https://xapinet.org/xapi/yet/activity/nontyped"]
+                },
+                {
+                    "location": "$.context.contextActivities.grouping[0].id",
+                    "presence": "included",
+                    "all": ["https://xapinet.org/xapi/yet/activity/nontyped"]
+                },
+                {
+                    "location": "$.context.contextActivities.parent[0].id",
+                    "presence": "included",
+                    "all": ["https://xapinet.org/xapi/yet/activity/nontyped"]
+                },
+                {
+                    "location": "$.context.contextActivities.other[0].id",
+                    "presence": "included",
+                    "all": ["https://xapinet.org/xapi/yet/activity/nontyped"]
                 }
             ]
         }
diff --git a/src/test/com/yetanalytics/datasim_test.clj b/src/test/com/yetanalytics/datasim_test.clj
index 8c3e85c6..eea10ebe 100644
--- a/src/test/com/yetanalytics/datasim_test.clj
+++ b/src/test/com/yetanalytics/datasim_test.clj
@@ -214,14 +214,27 @@
               {"name"        {"en" "Activity with Activity Type"},
                "description" {"en" "Activity with Activity Type"},
                "type"        "https://xapinet.org/xapi/yet/activity-type"}}
-             (-> result (get 0) (get "object"))
-             (-> result (get 1) (get "object"))
-             (-> result (get 2) (get "object"))))
+             (-> result (get 0) (get-in ["object"]))
+             (-> result (get 0) (get-in ["context" "contextActivities" "category" 0]))
+             (-> result (get 0) (get-in ["context" "contextActivities" "grouping" 0]))
+             (-> result (get 0) (get-in ["context" "contextActivities" "parent" 0]))
+             (-> result (get 0) (get-in ["context" "contextActivities" "other" 0]))
+             (-> result (get 1) (get-in ["object"]))
+             (-> result (get 1) (get-in ["context" "contextActivities" "grouping" 0]))
+             (-> result (get 1) (get-in ["context" "contextActivities" "parent" 0]))
+             (-> result (get 1) (get-in ["context" "contextActivities" "other" 0]))
+             (-> result (get 2) (get-in ["object"]))
+             (-> result (get 2) (get-in ["context" "contextActivities" "grouping" 0]))
+             (-> result (get 2) (get-in ["context" "contextActivities" "parent" 0]))
+             (-> result (get 2) (get-in ["context" "contextActivities" "other" 0]))))
       (is (= {"id" "https://xapinet.org/xapi/yet/activity/nontyped",
               "definition"
               {"name"        {"en" "Activity without Activity Type"},
                "description" {"en" "Activity without Activity Type"}}}
-             (-> result (get 3) (get "object")))))))
+             (-> result (get 3) (get-in ["object"]))
+             (-> result (get 3) (get-in ["context" "contextActivities" "grouping" 0]))
+             (-> result (get 3) (get-in ["context" "contextActivities" "parent" 0]))
+             (-> result (get 3) (get-in ["context" "contextActivities" "other" 0])))))))
 
 (deftest generate-seq-test
   (testing "Returns statements"

From 2e9f5a4c4ddc04250ccd8ceae55b8da9cf8d2b45 Mon Sep 17 00:00:00 2001
From: kelvinqian00 <kelvinqian2@gmail.com>
Date: Fri, 26 Jan 2024 10:23:31 -0500
Subject: [PATCH 09/10] Update CHANGELOG

---
 CHANGELOG.md | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index e9b5b363..0fa9c134 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,10 @@
 # Change Log
 
+## [0.4.1] - 2024-01-25
+- Fix a number of bugs associated with Statement generation:
+  - Fix places where `:definition` was used when `:activityDefinition` was supposed to be used in the code, causing Activities not to be associated with their respective Activity Types.
+  - Stringify keys for map values of `any`, `all`, and `none` in Statement Template rules.
+
 ## [0.4.0] - 2024-01-03
 - Change `alignments` inputs to `models` inputs that incorporate additional temporal properties.
 - Make `models` an array in which the user can apply different `personae` to.

From b0612b26b74d226fd4d5f81cee5a03c9bf186122 Mon Sep 17 00:00:00 2001
From: kelvinqian00 <kelvinqian2@gmail.com>
Date: Fri, 26 Jan 2024 10:23:37 -0500
Subject: [PATCH 10/10] Increment version number

---
 Makefile  | 2 +-
 README.md | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/Makefile b/Makefile
index ff23d3f4..dc5fb1bf 100644
--- a/Makefile
+++ b/Makefile
@@ -2,7 +2,7 @@
 
 GROUP_ID ?= com.yetanalytics
 ARTIFACT_ID ?= datasim
-VERSION ?= 0.4.0
+VERSION ?= 0.4.1
 
 clean:
 	rm -rf target
diff --git a/README.md b/README.md
index a5009d33..a01a4a45 100644
--- a/README.md
+++ b/README.md
@@ -15,7 +15,7 @@ DATASIM is funded by the Advanced Distributed Learning Initiative at US DoD.
 To use the core DATASIM library in your project, use the following dependency in your `deps.edn` file:
 
 ```clojure
-com.yetanalytics/datasim {:mvn/version "0.4.0"}
+com.yetanalytics/datasim {:mvn/version "0.4.1"}
 ```
 
 If you wish to install DATASIM as an application with features such as CLI or the webserver, perform the following steps: