@@ -3,5 +3,5 @@ |
||
3 | 3 | namespace Ijeffro\Laralocker\LearningLocker\Organisation; |
4 | 4 | |
5 | 5 | interface OrganisationInterface { |
6 | - function get(); |
|
6 | + function get(); |
|
7 | 7 | } |
@@ -3,5 +3,5 @@ |
||
3 | 3 | namespace Ijeffro\Laralocker\LearningLocker\Journeys; |
4 | 4 | |
5 | 5 | interface JourneyInterface { |
6 | - function get(); |
|
6 | + function get(); |
|
7 | 7 | } |
@@ -15,7 +15,7 @@ |
||
15 | 15 | public $journey_progress; |
16 | 16 | |
17 | 17 | protected $headers = [ |
18 | - 'Content-Type' => 'application/json' |
|
18 | + 'Content-Type' => 'application/json' |
|
19 | 19 | ]; |
20 | 20 | |
21 | 21 | function __construct($id = null) { |
@@ -30,7 +30,9 @@ |
||
30 | 30 | */ |
31 | 31 | public function progress($id = null) |
32 | 32 | { |
33 | - if ($this->journey_progress) return $this->journey_progress; |
|
33 | + if ($this->journey_progress) { |
|
34 | + return $this->journey_progress; |
|
35 | + } |
|
34 | 36 | |
35 | 37 | $this->journey_progress = new JourneyProgressHandler($id ? $id : null); |
36 | 38 | return $this->progress($id ? $id : null); |
@@ -9,44 +9,44 @@ discard block |
||
9 | 9 | |
10 | 10 | class StatementForward extends Connection { |
11 | 11 | |
12 | - private $statementForward = '/statementforwarding'; |
|
13 | - private $api = '/api'; |
|
14 | - private $v2 = '/v2'; |
|
12 | + private $statementForward = '/statementforwarding'; |
|
13 | + private $api = '/api'; |
|
14 | + private $v2 = '/v2'; |
|
15 | 15 | |
16 | - private $headers = [ |
|
16 | + private $headers = [ |
|
17 | 17 | 'content-type' => 'application/json' |
18 | - ]; |
|
19 | - |
|
20 | - /** |
|
21 | - * Generate the Query for Learning Locker's |
|
22 | - * Statement Forward. |
|
23 | - * |
|
24 | - * @return true |
|
25 | - * @return false |
|
26 | - */ |
|
27 | - public function updateStatementForwardQuery($statementForwardId, $isEnabled) { |
|
18 | + ]; |
|
19 | + |
|
20 | + /** |
|
21 | + * Generate the Query for Learning Locker's |
|
22 | + * Statement Forward. |
|
23 | + * |
|
24 | + * @return true |
|
25 | + * @return false |
|
26 | + */ |
|
27 | + public function updateStatementForwardQuery($statementForwardId, $isEnabled) { |
|
28 | 28 | $query = Query::statementForward($this->org->id); |
29 | 29 | if ($query === false || !$isEnabled) { |
30 | - $message = $query === false && $isEnabled ? '(No objects)' : null; |
|
31 | - return $this->disable($statementForwardId, $message); |
|
30 | + $message = $query === false && $isEnabled ? '(No objects)' : null; |
|
31 | + return $this->disable($statementForwardId, $message); |
|
32 | 32 | } |
33 | 33 | // pass in the query to prevent regeneration in the enable method |
34 | 34 | return $this->enable($statementForwardId, $query); |
35 | - } |
|
35 | + } |
|
36 | 36 | |
37 | - public static function getSigner() { |
|
37 | + public static function getSigner() { |
|
38 | 38 | return new Sha256; |
39 | - } |
|
39 | + } |
|
40 | 40 | |
41 | - public static function getOrgIssuer($org) { |
|
41 | + public static function getOrgIssuer($org) { |
|
42 | 42 | return \Curatr\Helper::getSubdomainURL($org->alias); |
43 | - } |
|
43 | + } |
|
44 | 44 | |
45 | - public static function getOrgSigningKey($org) { |
|
45 | + public static function getOrgSigningKey($org) { |
|
46 | 46 | return $org->jwt_secret ?? 'default_key'; |
47 | - } |
|
47 | + } |
|
48 | 48 | |
49 | - public function createSignedBearer() { |
|
49 | + public function createSignedBearer() { |
|
50 | 50 | $signer = self::getSigner(); |
51 | 51 | $issuer = self::getOrgIssuer($this->org); |
52 | 52 | $token = (new Builder())->setIssuer($issuer) // Configures the issuer (iss claim) |
@@ -55,155 +55,155 @@ discard block |
||
55 | 55 | ->sign($signer, self::getOrgSigningKey($this->org)) |
56 | 56 | ->getToken(); // Retrieves the generated token |
57 | 57 | return $token->__toString(); |
58 | - } |
|
58 | + } |
|
59 | 59 | |
60 | - private function title($message = "") { |
|
60 | + private function title($message = "") { |
|
61 | 61 | return trim($this->org->app_name . ' - ' . $this->org->name . ' - Object Completions ' . $message); |
62 | - } |
|
63 | - |
|
64 | - /** |
|
65 | - * Enable the Learning Locker Statement Forward. |
|
66 | - * |
|
67 | - * @param $statementForwardId |
|
68 | - * @return $response |
|
69 | - */ |
|
70 | - public function enable($statementForwardId, $query = null) { |
|
62 | + } |
|
63 | + |
|
64 | + /** |
|
65 | + * Enable the Learning Locker Statement Forward. |
|
66 | + * |
|
67 | + * @param $statementForwardId |
|
68 | + * @return $response |
|
69 | + */ |
|
70 | + public function enable($statementForwardId, $query = null) { |
|
71 | 71 | $data = [ |
72 | - "active" => true, |
|
73 | - "description" => $this->title(), |
|
74 | - "query" => $query ?: Query::statementForward($this->org->id), |
|
75 | - 'configuration' => [ |
|
72 | + "active" => true, |
|
73 | + "description" => $this->title(), |
|
74 | + "query" => $query ?: Query::statementForward($this->org->id), |
|
75 | + 'configuration' => [ |
|
76 | 76 | 'authType' => 'token', |
77 | 77 | 'secret' => $this->createSignedBearer() |
78 | - ] |
|
78 | + ] |
|
79 | 79 | ]; |
80 | 80 | return $this->update($statementForwardId, $data); |
81 | - } |
|
82 | - |
|
83 | - /** |
|
84 | - * Disable the Learning Locker Statement Forward. |
|
85 | - * |
|
86 | - * @param $id |
|
87 | - * @return $response |
|
88 | - */ |
|
89 | - public function disable($statementForwardId, $message) { |
|
81 | + } |
|
82 | + |
|
83 | + /** |
|
84 | + * Disable the Learning Locker Statement Forward. |
|
85 | + * |
|
86 | + * @param $id |
|
87 | + * @return $response |
|
88 | + */ |
|
89 | + public function disable($statementForwardId, $message) { |
|
90 | 90 | $message = $message ?? '(Service Disabled)'; |
91 | 91 | $data = array( |
92 | - "active" => false, |
|
93 | - "description" => $this->title($message), |
|
94 | - "query" => json_encode(['$comment' => Query::COMMENT, 'disabled' => $message]) |
|
92 | + "active" => false, |
|
93 | + "description" => $this->title($message), |
|
94 | + "query" => json_encode(['$comment' => Query::COMMENT, 'disabled' => $message]) |
|
95 | 95 | ); |
96 | 96 | return $response = $this->update($statementForwardId, $data); |
97 | - } |
|
98 | - |
|
99 | - /** |
|
100 | - * Get the Learning Locker Statement Forward by ID. |
|
101 | - * |
|
102 | - * @param $id |
|
103 | - * @return $response |
|
104 | - */ |
|
105 | - public function check($statementForwardId) { |
|
97 | + } |
|
98 | + |
|
99 | + /** |
|
100 | + * Get the Learning Locker Statement Forward by ID. |
|
101 | + * |
|
102 | + * @param $id |
|
103 | + * @return $response |
|
104 | + */ |
|
105 | + public function check($statementForwardId) { |
|
106 | 106 | if (empty($statementForwardId)) return false; |
107 | 107 | return $this->get($statementForwardId); |
108 | - } |
|
109 | - |
|
110 | - /** |
|
111 | - * Get the Learning Locker Statement Forward by ID. |
|
112 | - * |
|
113 | - * @param $statementForwardId |
|
114 | - * @return $response |
|
115 | - */ |
|
116 | - public function get($statementForwardId) { |
|
108 | + } |
|
109 | + |
|
110 | + /** |
|
111 | + * Get the Learning Locker Statement Forward by ID. |
|
112 | + * |
|
113 | + * @param $statementForwardId |
|
114 | + * @return $response |
|
115 | + */ |
|
116 | + public function get($statementForwardId) { |
|
117 | 117 | try { |
118 | - $url = $this->endpoint . $this->api . $this->v2 . $this->statementForward . '/' . $statementForwardId; |
|
119 | - $request = $this->getClient()->get($url, [ |
|
118 | + $url = $this->endpoint . $this->api . $this->v2 . $this->statementForward . '/' . $statementForwardId; |
|
119 | + $request = $this->getClient()->get($url, [ |
|
120 | 120 | 'auth' => $this->getAuth(), |
121 | 121 | 'headers' => [ |
122 | - 'content-type' => 'application/json' |
|
122 | + 'content-type' => 'application/json' |
|
123 | 123 | ], |
124 | - ]); |
|
124 | + ]); |
|
125 | 125 | |
126 | - if($request->getStatusCode() === 404) { |
|
126 | + if($request->getStatusCode() === 404) { |
|
127 | 127 | throw new GuzzleHttp\Exception\ClientException('There was a issue connecting to Learning Locker.'); |
128 | - } |
|
129 | - return $request->json(); |
|
128 | + } |
|
129 | + return $request->json(); |
|
130 | 130 | } catch (Exception $e) { |
131 | - if ($e instanceof \GuzzleHttp\Exception\ClientException) { |
|
131 | + if ($e instanceof \GuzzleHttp\Exception\ClientException) { |
|
132 | 132 | $responseBody = $e->getResponse()->getBody(true); |
133 | 133 | \Log::error('Error fetching statement forward', [ |
134 | - 'id' => $statementForwardId, |
|
135 | - 'org_id'=>$this->org->id, |
|
136 | - 'responseBody' => $responseBody |
|
134 | + 'id' => $statementForwardId, |
|
135 | + 'org_id'=>$this->org->id, |
|
136 | + 'responseBody' => $responseBody |
|
137 | 137 | ]); |
138 | - } |
|
139 | - return false; |
|
140 | - } |
|
141 | - } |
|
142 | - |
|
143 | - /** |
|
144 | - * Store the Learning Locker Statement Forward. |
|
145 | - * |
|
146 | - * @param $data |
|
147 | - * @return $response |
|
148 | - */ |
|
149 | - public function store($data, $startEnabled = true) { |
|
138 | + } |
|
139 | + return false; |
|
140 | + } |
|
141 | + } |
|
142 | + |
|
143 | + /** |
|
144 | + * Store the Learning Locker Statement Forward. |
|
145 | + * |
|
146 | + * @param $data |
|
147 | + * @return $response |
|
148 | + */ |
|
149 | + public function store($data, $startEnabled = true) { |
|
150 | 150 | $store = json_encode($data); |
151 | 151 | try { |
152 | - $url = $this->endpoint . $this->api . $this->v2 . $this->statementForward; |
|
153 | - $request = $this->getClient()->post($url, array( |
|
152 | + $url = $this->endpoint . $this->api . $this->v2 . $this->statementForward; |
|
153 | + $request = $this->getClient()->post($url, array( |
|
154 | 154 | 'auth' => $this->getAuth(), |
155 | 155 | 'headers' => $this->headers, |
156 | 156 | 'body' => $store, |
157 | - )); |
|
158 | - $request = $request->json(); |
|
159 | - if (isset($request['_id'])) { |
|
157 | + )); |
|
158 | + $request = $request->json(); |
|
159 | + if (isset($request['_id'])) { |
|
160 | 160 | return $this->updateStatementForwardQuery($request['_id'], $startEnabled); |
161 | - } |
|
162 | - return false; |
|
161 | + } |
|
162 | + return false; |
|
163 | 163 | } catch (Exception $e) { |
164 | - if ($e instanceof \GuzzleHttp\Exception\ClientException) { |
|
164 | + if ($e instanceof \GuzzleHttp\Exception\ClientException) { |
|
165 | 165 | $responseBody = $e->getResponse()->getBody(true); |
166 | 166 | \Log::error('Error creating statement forward', [ |
167 | - 'data' => $data, |
|
168 | - 'org_id'=>$this->org->id, |
|
169 | - 'responseBody' => $responseBody |
|
167 | + 'data' => $data, |
|
168 | + 'org_id'=>$this->org->id, |
|
169 | + 'responseBody' => $responseBody |
|
170 | 170 | ]); |
171 | - } |
|
172 | - return false; |
|
173 | - } |
|
174 | - } |
|
175 | - |
|
176 | - /** |
|
177 | - * Update the Learning Locker Statement Forward. |
|
178 | - * |
|
179 | - * @param $statementForwardId, $data |
|
180 | - * @return $response |
|
181 | - */ |
|
182 | - protected function update($statementForwardId, $data) { |
|
171 | + } |
|
172 | + return false; |
|
173 | + } |
|
174 | + } |
|
175 | + |
|
176 | + /** |
|
177 | + * Update the Learning Locker Statement Forward. |
|
178 | + * |
|
179 | + * @param $statementForwardId, $data |
|
180 | + * @return $response |
|
181 | + */ |
|
182 | + protected function update($statementForwardId, $data) { |
|
183 | 183 | if (empty($statementForwardId)) return false; |
184 | 184 | $update = json_encode($data); |
185 | 185 | try { |
186 | - $url = $this->endpoint . $this->api . $this->v2 . $this->statementForward . '/' . $statementForwardId; |
|
187 | - $request = $this->getClient()->patch($url, array( |
|
186 | + $url = $this->endpoint . $this->api . $this->v2 . $this->statementForward . '/' . $statementForwardId; |
|
187 | + $request = $this->getClient()->patch($url, array( |
|
188 | 188 | 'auth' => $this->getAuth(), |
189 | 189 | 'headers' => [ |
190 | - 'content-type' => 'application/json' |
|
190 | + 'content-type' => 'application/json' |
|
191 | 191 | ], |
192 | 192 | 'body' => $update, |
193 | - )); |
|
194 | - return $request->json(); |
|
193 | + )); |
|
194 | + return $request->json(); |
|
195 | 195 | } catch (Exception $e) { |
196 | - if ($e instanceof \GuzzleHttp\Exception\ClientException) { |
|
196 | + if ($e instanceof \GuzzleHttp\Exception\ClientException) { |
|
197 | 197 | $responseBody = $e->getResponse()->getBody(true); |
198 | 198 | \Log::error('Error updating statement forward', [ |
199 | - 'id' => $statementForwardId, |
|
200 | - 'data' => $data, |
|
201 | - 'org_id'=>$this->org->id, |
|
202 | - 'responseBody' => $responseBody |
|
199 | + 'id' => $statementForwardId, |
|
200 | + 'data' => $data, |
|
201 | + 'org_id'=>$this->org->id, |
|
202 | + 'responseBody' => $responseBody |
|
203 | 203 | ]); |
204 | - } |
|
205 | - return false; |
|
204 | + } |
|
205 | + return false; |
|
206 | + } |
|
206 | 207 | } |
207 | - } |
|
208 | 208 | |
209 | 209 | } |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | $data = array( |
92 | 92 | "active" => false, |
93 | 93 | "description" => $this->title($message), |
94 | - "query" => json_encode(['$comment' => Query::COMMENT, 'disabled' => $message]) |
|
94 | + "query" => json_encode([ '$comment' => Query::COMMENT, 'disabled' => $message ]) |
|
95 | 95 | ); |
96 | 96 | return $response = $this->update($statementForwardId, $data); |
97 | 97 | } |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | ], |
124 | 124 | ]); |
125 | 125 | |
126 | - if($request->getStatusCode() === 404) { |
|
126 | + if ($request->getStatusCode() === 404) { |
|
127 | 127 | throw new GuzzleHttp\Exception\ClientException('There was a issue connecting to Learning Locker.'); |
128 | 128 | } |
129 | 129 | return $request->json(); |
@@ -156,8 +156,8 @@ discard block |
||
156 | 156 | 'body' => $store, |
157 | 157 | )); |
158 | 158 | $request = $request->json(); |
159 | - if (isset($request['_id'])) { |
|
160 | - return $this->updateStatementForwardQuery($request['_id'], $startEnabled); |
|
159 | + if (isset($request[ '_id' ])) { |
|
160 | + return $this->updateStatementForwardQuery($request[ '_id' ], $startEnabled); |
|
161 | 161 | } |
162 | 162 | return false; |
163 | 163 | } catch (Exception $e) { |
@@ -103,7 +103,9 @@ discard block |
||
103 | 103 | * @return $response |
104 | 104 | */ |
105 | 105 | public function check($statementForwardId) { |
106 | - if (empty($statementForwardId)) return false; |
|
106 | + if (empty($statementForwardId)) { |
|
107 | + return false; |
|
108 | + } |
|
107 | 109 | return $this->get($statementForwardId); |
108 | 110 | } |
109 | 111 | |
@@ -180,7 +182,9 @@ discard block |
||
180 | 182 | * @return $response |
181 | 183 | */ |
182 | 184 | protected function update($statementForwardId, $data) { |
183 | - if (empty($statementForwardId)) return false; |
|
185 | + if (empty($statementForwardId)) { |
|
186 | + return false; |
|
187 | + } |
|
184 | 188 | $update = json_encode($data); |
185 | 189 | try { |
186 | 190 | $url = $this->endpoint . $this->api . $this->v2 . $this->statementForward . '/' . $statementForwardId; |
@@ -12,7 +12,7 @@ |
||
12 | 12 | private $v2 = '/v2'; |
13 | 13 | |
14 | 14 | protected $headers = [ |
15 | - 'Content-Type' => 'application/json' |
|
15 | + 'Content-Type' => 'application/json' |
|
16 | 16 | ]; |
17 | 17 | |
18 | 18 | function __construct($id = null) { |
@@ -8,28 +8,28 @@ discard block |
||
8 | 8 | |
9 | 9 | class Query { |
10 | 10 | |
11 | - const COMMENT = "AUTOGENERATED BY - DO NOT MANUALLY AMEND"; |
|
11 | + const COMMENT = "AUTOGENERATED BY - DO NOT MANUALLY AMEND"; |
|
12 | 12 | |
13 | - /** |
|
14 | - * Generate the Statement Forward Query |
|
15 | - * based on the Object Completion Criteria |
|
16 | - */ |
|
17 | - public static function statementForward($org_id) { |
|
13 | + /** |
|
14 | + * Generate the Statement Forward Query |
|
15 | + * based on the Object Completion Criteria |
|
16 | + */ |
|
17 | + public static function statementForward($org_id) { |
|
18 | 18 | $criteria = ObjectCompletionCriterion::where('org_id', $org_id)->whereHas(\Object::class, function($q){ |
19 | - $q->where("completion_type", Types::XAPI); |
|
19 | + $q->where("completion_type", Types::XAPI); |
|
20 | 20 | })->with('object')->get(); |
21 | 21 | |
22 | 22 | if (sizeof($criteria) === 0 ){ |
23 | - // if there are no criteria |
|
24 | - return false; |
|
23 | + // if there are no criteria |
|
24 | + return false; |
|
25 | 25 | } else { |
26 | - //if there is criteria |
|
27 | - $queries = []; |
|
26 | + //if there is criteria |
|
27 | + $queries = []; |
|
28 | 28 | |
29 | - foreach ($criteria as $criterion) { |
|
29 | + foreach ($criteria as $criterion) { |
|
30 | 30 | $course = $criterion->object->course; |
31 | 31 | if (empty($course) || ($course && !empty($course->deleted_at))) { |
32 | - continue; |
|
32 | + continue; |
|
33 | 33 | } |
34 | 34 | $criteriaQuery = []; |
35 | 35 | $criteriaQuery['$comment'] = 'id:' . $criterion->id . ', object_id:' . $criterion->object_id; |
@@ -42,48 +42,48 @@ discard block |
||
42 | 42 | if (is_numeric($criterion->scaled)) $criteriaQuery['statement.result.score.scaled'] = ['$gte' => floatval($criterion->scaled)]; |
43 | 43 | |
44 | 44 | if (sizeof($criteriaQuery) > 0) { |
45 | - $queries[] = $criteriaQuery; |
|
45 | + $queries[] = $criteriaQuery; |
|
46 | + } |
|
46 | 47 | } |
47 | - } |
|
48 | - if (sizeof($queries) === 0 ){ |
|
48 | + if (sizeof($queries) === 0 ){ |
|
49 | 49 | // if there are no quries |
50 | 50 | return false; |
51 | - } |
|
51 | + } |
|
52 | 52 | |
53 | - $query = [ |
|
53 | + $query = [ |
|
54 | 54 | '$comment' => self::COMMENT, |
55 | 55 | '$or'=>$queries |
56 | - ]; |
|
56 | + ]; |
|
57 | 57 | } |
58 | 58 | |
59 | 59 | return json_encode($query); |
60 | - } |
|
60 | + } |
|
61 | 61 | |
62 | - /** |
|
63 | - * Get the Learning Locker Statement Forward by ID. |
|
64 | - * |
|
65 | - * @param $id |
|
66 | - * @return $response |
|
67 | - */ |
|
68 | - protected function get() { |
|
62 | + /** |
|
63 | + * Get the Learning Locker Statement Forward by ID. |
|
64 | + * |
|
65 | + * @param $id |
|
66 | + * @return $response |
|
67 | + */ |
|
68 | + protected function get() { |
|
69 | 69 | try { |
70 | - $url = $this->endpoint . $this->api . $this->v2 . $this->query . '/'; |
|
71 | - $request = $this->getClient()->get($url, [ |
|
70 | + $url = $this->endpoint . $this->api . $this->v2 . $this->query . '/'; |
|
71 | + $request = $this->getClient()->get($url, [ |
|
72 | 72 | 'auth' => $this->getAuth(), |
73 | 73 | 'headers' => [ |
74 | - 'content-type' => 'application/json' |
|
74 | + 'content-type' => 'application/json' |
|
75 | 75 | ], |
76 | - ]); |
|
76 | + ]); |
|
77 | 77 | |
78 | - if($request->getStatusCode() === 404) { |
|
78 | + if($request->getStatusCode() === 404) { |
|
79 | 79 | throw new ClientException('There was a issue connecting to Learning Locker.'); |
80 | - } |
|
81 | - $response = $request->json(); |
|
80 | + } |
|
81 | + $response = $request->json(); |
|
82 | 82 | } catch (ClientException $e) { |
83 | - return $e; |
|
83 | + return $e; |
|
84 | 84 | } |
85 | 85 | |
86 | 86 | return $response; |
87 | - } |
|
87 | + } |
|
88 | 88 | |
89 | 89 | } |
@@ -15,37 +15,37 @@ discard block |
||
15 | 15 | * based on the Object Completion Criteria |
16 | 16 | */ |
17 | 17 | public static function statementForward($org_id) { |
18 | - $criteria = ObjectCompletionCriterion::where('org_id', $org_id)->whereHas(\Object::class, function($q){ |
|
18 | + $criteria = ObjectCompletionCriterion::where('org_id', $org_id)->whereHas(\Object::class, function($q) { |
|
19 | 19 | $q->where("completion_type", Types::XAPI); |
20 | 20 | })->with('object')->get(); |
21 | 21 | |
22 | - if (sizeof($criteria) === 0 ){ |
|
22 | + if (sizeof($criteria) === 0) { |
|
23 | 23 | // if there are no criteria |
24 | 24 | return false; |
25 | 25 | } else { |
26 | 26 | //if there is criteria |
27 | - $queries = []; |
|
27 | + $queries = [ ]; |
|
28 | 28 | |
29 | 29 | foreach ($criteria as $criterion) { |
30 | 30 | $course = $criterion->object->course; |
31 | 31 | if (empty($course) || ($course && !empty($course->deleted_at))) { |
32 | 32 | continue; |
33 | 33 | } |
34 | - $criteriaQuery = []; |
|
35 | - $criteriaQuery['$comment'] = 'id:' . $criterion->id . ', object_id:' . $criterion->object_id; |
|
34 | + $criteriaQuery = [ ]; |
|
35 | + $criteriaQuery[ '$comment' ] = 'id:' . $criterion->id . ', object_id:' . $criterion->object_id; |
|
36 | 36 | $activity_id = $criterion->use_curatr_activity ? $criterion->object->getXapiUrl(true, true) : $criterion->activity_id; |
37 | - $criteriaQuery['statement.object.id'] = $activity_id; |
|
38 | - if (!empty($criterion->verb)) $criteriaQuery['statement.verb.id'] = $criterion->verb; |
|
39 | - if (!empty($criterion->completion)) $criteriaQuery['statement.result.completion'] = true; |
|
40 | - if (!empty($criterion->success)) $criteriaQuery['statement.result.success'] = true; |
|
41 | - if (is_numeric($criterion->raw)) $criteriaQuery['statement.result.score.raw'] = ['$gte' => floatval($criterion->raw)]; |
|
42 | - if (is_numeric($criterion->scaled)) $criteriaQuery['statement.result.score.scaled'] = ['$gte' => floatval($criterion->scaled)]; |
|
37 | + $criteriaQuery[ 'statement.object.id' ] = $activity_id; |
|
38 | + if (!empty($criterion->verb)) $criteriaQuery[ 'statement.verb.id' ] = $criterion->verb; |
|
39 | + if (!empty($criterion->completion)) $criteriaQuery[ 'statement.result.completion' ] = true; |
|
40 | + if (!empty($criterion->success)) $criteriaQuery[ 'statement.result.success' ] = true; |
|
41 | + if (is_numeric($criterion->raw)) $criteriaQuery[ 'statement.result.score.raw' ] = [ '$gte' => floatval($criterion->raw) ]; |
|
42 | + if (is_numeric($criterion->scaled)) $criteriaQuery[ 'statement.result.score.scaled' ] = [ '$gte' => floatval($criterion->scaled) ]; |
|
43 | 43 | |
44 | 44 | if (sizeof($criteriaQuery) > 0) { |
45 | - $queries[] = $criteriaQuery; |
|
45 | + $queries[ ] = $criteriaQuery; |
|
46 | 46 | } |
47 | 47 | } |
48 | - if (sizeof($queries) === 0 ){ |
|
48 | + if (sizeof($queries) === 0) { |
|
49 | 49 | // if there are no quries |
50 | 50 | return false; |
51 | 51 | } |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | ], |
76 | 76 | ]); |
77 | 77 | |
78 | - if($request->getStatusCode() === 404) { |
|
78 | + if ($request->getStatusCode() === 404) { |
|
79 | 79 | throw new ClientException('There was a issue connecting to Learning Locker.'); |
80 | 80 | } |
81 | 81 | $response = $request->json(); |
@@ -35,11 +35,21 @@ |
||
35 | 35 | $criteriaQuery['$comment'] = 'id:' . $criterion->id . ', object_id:' . $criterion->object_id; |
36 | 36 | $activity_id = $criterion->use_curatr_activity ? $criterion->object->getXapiUrl(true, true) : $criterion->activity_id; |
37 | 37 | $criteriaQuery['statement.object.id'] = $activity_id; |
38 | - if (!empty($criterion->verb)) $criteriaQuery['statement.verb.id'] = $criterion->verb; |
|
39 | - if (!empty($criterion->completion)) $criteriaQuery['statement.result.completion'] = true; |
|
40 | - if (!empty($criterion->success)) $criteriaQuery['statement.result.success'] = true; |
|
41 | - if (is_numeric($criterion->raw)) $criteriaQuery['statement.result.score.raw'] = ['$gte' => floatval($criterion->raw)]; |
|
42 | - if (is_numeric($criterion->scaled)) $criteriaQuery['statement.result.score.scaled'] = ['$gte' => floatval($criterion->scaled)]; |
|
38 | + if (!empty($criterion->verb)) { |
|
39 | + $criteriaQuery['statement.verb.id'] = $criterion->verb; |
|
40 | + } |
|
41 | + if (!empty($criterion->completion)) { |
|
42 | + $criteriaQuery['statement.result.completion'] = true; |
|
43 | + } |
|
44 | + if (!empty($criterion->success)) { |
|
45 | + $criteriaQuery['statement.result.success'] = true; |
|
46 | + } |
|
47 | + if (is_numeric($criterion->raw)) { |
|
48 | + $criteriaQuery['statement.result.score.raw'] = ['$gte' => floatval($criterion->raw)]; |
|
49 | + } |
|
50 | + if (is_numeric($criterion->scaled)) { |
|
51 | + $criteriaQuery['statement.result.score.scaled'] = ['$gte' => floatval($criterion->scaled)]; |
|
52 | + } |
|
43 | 53 | |
44 | 54 | if (sizeof($criteriaQuery) > 0) { |
45 | 55 | $queries[] = $criteriaQuery; |
@@ -12,7 +12,7 @@ |
||
12 | 12 | private $v2 = '/v2'; |
13 | 13 | |
14 | 14 | protected $headers = [ |
15 | - 'content-type' => 'application/json' |
|
15 | + 'content-type' => 'application/json' |
|
16 | 16 | ]; |
17 | 17 | |
18 | 18 | function __construct($id = null) { |
@@ -12,7 +12,7 @@ |
||
12 | 12 | private $v2 = '/v2'; |
13 | 13 | |
14 | 14 | protected $headers = [ |
15 | - 'content-type' => 'application/json' |
|
15 | + 'content-type' => 'application/json' |
|
16 | 16 | ]; |
17 | 17 | |
18 | 18 | function __construct($id = null) { |
@@ -3,5 +3,5 @@ |
||
3 | 3 | namespace Ijeffro\Laralocker\LearningLocker\Visualisations; |
4 | 4 | |
5 | 5 | interface VisualisationInterface { |
6 | - function get(); |
|
6 | + function get(); |
|
7 | 7 | } |