-
Notifications
You must be signed in to change notification settings - Fork 7
/
xapi.clj
33 lines (31 loc) · 1.06 KB
/
xapi.clj
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
(ns com.yetanalytics.datasim.util.xapi
"Misc. xAPI-oriented utilities"
(:require [clojure.spec.alpha :as s]
[xapi-schema.spec :as xs]))
(defn agent-id
"Return a string representing the id of an agent in the sim. Will be prefixed
with the ifi property and two colons ::. For accounts, the homepage will
precede the name, and they will be delimited by a comma like:
account::https://foo.bar,baz. If an IFI cannot be found, returns nil."
[{:keys [mbox
mbox_sha1sum
openid]
{:keys [name homePage]} :account
:as agent}]
(or (and mbox
(format "mbox::%s" mbox))
(and name homePage
(format "account::%s,%s"
homePage name))
(and mbox_sha1sum
(format "mbox_sha1sum::%s" mbox_sha1sum))
(and openid
(format "openid::%s" openid))))
(defn make-ifi-map
"Given an xapi group, make a map of ifis"
[{:keys [member] :as group}]
(into {}
(for [actor member
:let [id (agent-id actor)]
:when id]
[id actor])))