1 | <?php |
||
2 | |||
3 | namespace Ijeffro\Laralocker; |
||
4 | |||
5 | use Config; |
||
6 | use TinCan\Verb; |
||
7 | use TinCan\Agent; |
||
8 | use Carbon\Carbon; |
||
9 | use Guzzle\Exception\RequestException; |
||
10 | use Ijeffro\Laralocker\xAPI\xAPIHandler; |
||
11 | use Ijeffro\Laralocker\Constants\xAPIConstants; |
||
12 | use Ijeffro\Laralocker\Statements\StatementGenerator; |
||
13 | |||
14 | class xAPI extends xAPIHandler |
||
15 | { |
||
16 | public $actor; |
||
17 | public $what; |
||
18 | public $send; |
||
19 | public $did; |
||
20 | |||
21 | |||
22 | /** |
||
23 | * Learning Locker: xAPI Statement Actor |
||
24 | * |
||
25 | * @param $actor['name'] |
||
26 | * @param $actor['email'] |
||
27 | * @param $ref = Account Actor |
||
0 ignored issues
–
show
Documentation
Bug
introduced
by
Loading history...
|
|||
28 | * @param $homepage = Account Homepage |
||
29 | * |
||
30 | */ |
||
31 | public function actor($actor = [], $ref = null, $homepage = null) |
||
32 | { |
||
33 | if (!$actor) return error('Please supply an actor'); |
||
34 | |||
35 | $this->agent = new Agent; |
||
36 | $actor_type = Config::get('laralocker.learning_locker.xapi_statements.actor_type'); |
||
37 | |||
38 | if ($actor_type === xAPIConstants::MBOX) { |
||
39 | |||
40 | if ($actor['name'] && $actor['email']) { |
||
41 | $authority = StatementGenerator::createAuthority($actor['name'], $actor['email']); |
||
0 ignored issues
–
show
|
|||
42 | $actor = StatementGenerator::createMboxActor($actor['name'], $actor['email']); |
||
43 | // dd($authority); |
||
44 | } else { |
||
45 | return error('Please supply the actor\'s name and email in the form of an array.'); |
||
46 | } |
||
47 | |||
48 | |||
49 | // $this->agent->setAuthority($authority); |
||
50 | $this->agent->setName($actor['name']); |
||
51 | $this->agent->setMbox($actor['mbox']); |
||
52 | } |
||
53 | |||
54 | // if ($actor_type === xAPIConstants::ACCOUNT && $actor) { |
||
55 | // $homepage = Config::get('laralocker.xapi_statements.actor_hompage'); |
||
56 | |||
57 | // if($homepage && $ref) { |
||
58 | // $$actor = Statemen |
||
59 | |||
60 | // dd($this->actor);tGenerator::createAccountActor($actor, $homepage, $ref); |
||
61 | // } |
||
62 | // } |
||
63 | |||
64 | // $this->actor = []; |
||
65 | $this->actor = $this->agent; |
||
66 | |||
67 | return $this; |
||
68 | } |
||
69 | |||
70 | public function did($did) |
||
71 | { |
||
72 | $verb = new Verb; |
||
73 | $did = StatementGenerator::getVerb($did); |
||
74 | |||
75 | $verb->setId($did); |
||
76 | $this->verb = $verb; |
||
77 | |||
78 | return $this; |
||
79 | } |
||
80 | |||
81 | public function what($what) |
||
82 | { |
||
83 | $obejct = StatementGenerator::createObject($what); |
||
84 | $this->object = $obejct; |
||
85 | return $this; |
||
86 | } |
||
87 | |||
88 | public function scored($result) |
||
89 | { |
||
90 | $this->result = $result; |
||
91 | return $this; |
||
92 | } |
||
93 | |||
94 | public function context($context) |
||
95 | { |
||
96 | $this->context = $context; |
||
97 | return $this; |
||
98 | } |
||
99 | |||
100 | public function make() |
||
101 | { |
||
102 | $this->timestamp = Carbon::now(); |
||
103 | |||
104 | // dd( |
||
105 | // $this->actor, |
||
106 | // $this->verb, |
||
107 | // $this->object, |
||
108 | // $this->timestamp, |
||
109 | // $this->context ? $this->context : null, |
||
110 | // $this->result ? $this->result : null |
||
111 | // ); |
||
112 | $this->statement = $this->makeStatement( |
||
113 | $this->actor, |
||
114 | $this->verb, |
||
115 | $this->object, |
||
116 | $this->timestamp, |
||
117 | isset($this->context) ? $this->context : null, |
||
118 | isset($this->result) ? $this->result : null |
||
119 | ); |
||
120 | |||
121 | $this->make = []; |
||
122 | $this->make = $this->statement; |
||
123 | return $this->make; |
||
124 | } |
||
125 | |||
126 | |||
127 | /** |
||
128 | * Store the Learning Locker Statement Forward. |
||
129 | * |
||
130 | * @param $data |
||
131 | * @return $response |
||
0 ignored issues
–
show
|
|||
132 | * |
||
133 | */ |
||
134 | public function store() |
||
135 | { |
||
136 | $this->send = $this->send( |
||
137 | $this->actor, |
||
138 | $this->verb, |
||
139 | $this->object, |
||
140 | $this->timestamp |
||
141 | // $context=null, |
||
142 | // $result=null |
||
143 | ); |
||
144 | |||
145 | // $this->send = []; |
||
146 | $this->send =$this->send; |
||
147 | return $this->send; |
||
148 | |||
149 | } |
||
150 | |||
151 | |||
152 | public function statement() |
||
153 | { |
||
154 | // return { |
||
155 | // "statement": { |
||
156 | // "authority": { |
||
157 | // "objectType": "Agent", |
||
158 | // "name": "New Client", |
||
159 | // "mbox": "mailto:[email protected]" |
||
160 | // }, |
||
161 | // "stored": "2019-05-23T10:34:59.140Z", |
||
162 | // "context": { |
||
163 | // "registration": "bd72a9fd-58d6-4c3c-b97b-04696b481a17", |
||
164 | // "contextActivities": { |
||
165 | // "grouping": [ |
||
166 | // { |
||
167 | // "objectType": "Activity", |
||
168 | // "id": "https://phil.curatr3.com/courses/linear", |
||
169 | // "definition": { |
||
170 | // "type": "http://adlnet.gov/expapi/activities/course" |
||
171 | // } |
||
172 | // }, |
||
173 | // { |
||
174 | // "objectType": "Activity", |
||
175 | // "id": "https://phil.curatr3.com", |
||
176 | // "definition": { |
||
177 | // "type": "http://curatr3.com/define/type/organisation", |
||
178 | // "name": { |
||
179 | // "en-GB": "HT2" |
||
180 | // } |
||
181 | // } |
||
182 | // } |
||
183 | // ] |
||
184 | // } |
||
185 | // }, |
||
186 | // "platform": "Curatr" |
||
187 | // }, |
||
188 | // "actor": { |
||
189 | // "objectType": "Agent", |
||
190 | // "name": "James Mullaney", |
||
191 | // "mbox": "mailto:[email protected]" |
||
192 | // }, |
||
193 | // "timestamp": "2019-05-23T10:34:57+00:00", |
||
194 | // "version": "1.0.0", |
||
195 | // "id": "357bb526-8d7a-48a9-8ab2-c9cd28a772e3", |
||
196 | // "verb": { |
||
197 | // "id": "http://activitystrea.ms/schema/1.0/access", |
||
198 | // "display": { |
||
199 | // "en-GB": "accessed" |
||
200 | // } |
||
201 | // }, |
||
202 | // "object": { |
||
203 | // "objectType": "Activity", |
||
204 | // "id": "http://phil.curatr3.com/courses/linear/learn", |
||
205 | // "definition": { |
||
206 | // "type": "http://activitystrea.ms/schema/1.0/page", |
||
207 | // "name": { |
||
208 | // "en-GB": "Linear - Learn" |
||
209 | // } |
||
210 | // } |
||
211 | // } |
||
212 | // } |
||
213 | |||
214 | // // End of statement |
||
215 | } |
||
216 | |||
217 | |||
218 | } |
||
219 |