@@ -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; |
@@ -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 | } |
@@ -3,5 +3,5 @@ |
||
3 | 3 | namespace Ijeffro\Laralocker\LearningLocker\Personas; |
4 | 4 | |
5 | 5 | interface PersonaInterface { |
6 | - function get(); |
|
6 | + function get(); |
|
7 | 7 | } |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | |
29 | 29 | if ($this->app->runningInConsole()) { |
30 | 30 | $this->publishes([ |
31 | - __DIR__.'/../../publishable/config/laralocker.php' => config_path('laralocker.php'), |
|
31 | + __DIR__ . '/../../publishable/config/laralocker.php' => config_path('laralocker.php'), |
|
32 | 32 | ], 'config'); |
33 | 33 | |
34 | 34 | // Publishing the views. |
@@ -64,21 +64,21 @@ discard block |
||
64 | 64 | |
65 | 65 | |
66 | 66 | // Automatically apply the package configuration |
67 | - $this->mergeConfigFrom(__DIR__.'/../../publishable/config/laralocker.php', 'laralocker'); |
|
67 | + $this->mergeConfigFrom(__DIR__ . '/../../publishable/config/laralocker.php', 'laralocker'); |
|
68 | 68 | |
69 | 69 | |
70 | 70 | // Register the main class to use with the facade |
71 | - $this->app->bind('laralocker', function () { |
|
71 | + $this->app->bind('laralocker', function() { |
|
72 | 72 | return new Laralocker; |
73 | 73 | }); |
74 | 74 | |
75 | 75 | // Register the main class to use with the facade |
76 | - $this->app->bind('learninglocker', function () { |
|
76 | + $this->app->bind('learninglocker', function() { |
|
77 | 77 | return new LearningLocker; |
78 | 78 | }); |
79 | 79 | |
80 | 80 | // Register the main class to use with the facade |
81 | - $this->app->bind('xapi', function () { |
|
81 | + $this->app->bind('xapi', function() { |
|
82 | 82 | return new xAPI; |
83 | 83 | }); |
84 | 84 | } |
@@ -439,7 +439,7 @@ discard block |
||
439 | 439 | */ |
440 | 440 | public function routes() |
441 | 441 | { |
442 | - require __DIR__.'/../routes/laralocker.php'; |
|
442 | + require __DIR__ . '/../routes/laralocker.php'; |
|
443 | 443 | } |
444 | 444 | |
445 | 445 | /** |
@@ -491,7 +491,7 @@ discard block |
||
491 | 491 | break; |
492 | 492 | default: |
493 | 493 | |
494 | - $message = ["error" => "Please supply a Learning Locker model", "docs" => "http://docs.learninglocker.net/"]; |
|
494 | + $message = [ "error" => "Please supply a Learning Locker model", "docs" => "http://docs.learninglocker.net/" ]; |
|
495 | 495 | |
496 | 496 | return $message->toJosn(); |
497 | 497 | } |
@@ -65,7 +65,9 @@ discard block |
||
65 | 65 | */ |
66 | 66 | public function connect($key, $secret, $url) |
67 | 67 | { |
68 | - if ($this->connection) return $this; |
|
68 | + if ($this->connection) { |
|
69 | + return $this; |
|
70 | + } |
|
69 | 71 | |
70 | 72 | $this->connection = new Connection($key, $secret, $url); |
71 | 73 | return $this->connect($key, $secret, $url); |
@@ -78,7 +80,9 @@ discard block |
||
78 | 80 | */ |
79 | 81 | public function clients() |
80 | 82 | { |
81 | - if ($this->clients) return $this->clients; |
|
83 | + if ($this->clients) { |
|
84 | + return $this->clients; |
|
85 | + } |
|
82 | 86 | |
83 | 87 | $this->clients = new ClientHandler; |
84 | 88 | return $this->clients(); |
@@ -92,7 +96,9 @@ discard block |
||
92 | 96 | */ |
93 | 97 | public function client($id = null) |
94 | 98 | { |
95 | - if ($this->client) return $this->client; |
|
99 | + if ($this->client) { |
|
100 | + return $this->client; |
|
101 | + } |
|
96 | 102 | $this->client = new ClientHandler($id ? $id : null); |
97 | 103 | return $this->client($id ? $id : null); |
98 | 104 | } |
@@ -104,7 +110,9 @@ discard block |
||
104 | 110 | */ |
105 | 111 | public function users() |
106 | 112 | { |
107 | - if ($this->users) return $this->users; |
|
113 | + if ($this->users) { |
|
114 | + return $this->users; |
|
115 | + } |
|
108 | 116 | |
109 | 117 | $this->users = new UserHandler; |
110 | 118 | return $this->users(); |
@@ -118,7 +126,9 @@ discard block |
||
118 | 126 | */ |
119 | 127 | public function user($id = null) |
120 | 128 | { |
121 | - if ($this->user) return $this->user; |
|
129 | + if ($this->user) { |
|
130 | + return $this->user; |
|
131 | + } |
|
122 | 132 | |
123 | 133 | $this->user = new UserHandler($id ? $id : null); |
124 | 134 | return $this->user($id ? $id : null); |
@@ -131,7 +141,9 @@ discard block |
||
131 | 141 | */ |
132 | 142 | public function roles() |
133 | 143 | { |
134 | - if ($this->roles) return $this->roles; |
|
144 | + if ($this->roles) { |
|
145 | + return $this->roles; |
|
146 | + } |
|
135 | 147 | |
136 | 148 | $this->roles = new RoleHandler; |
137 | 149 | return $this->roles(); |
@@ -145,7 +157,9 @@ discard block |
||
145 | 157 | */ |
146 | 158 | public function role($id = null) |
147 | 159 | { |
148 | - if ($this->role) return $this->role; |
|
160 | + if ($this->role) { |
|
161 | + return $this->role; |
|
162 | + } |
|
149 | 163 | |
150 | 164 | $this->role = new RoleHandler($id ? $id : null); |
151 | 165 | return $this->role($id ? $id : null); |
@@ -158,7 +172,9 @@ discard block |
||
158 | 172 | */ |
159 | 173 | public function stores() |
160 | 174 | { |
161 | - if ($this->stores) return $this->stores; |
|
175 | + if ($this->stores) { |
|
176 | + return $this->stores; |
|
177 | + } |
|
162 | 178 | |
163 | 179 | $this->stores = new StoreHandler; |
164 | 180 | return $this->stores(); |
@@ -172,7 +188,9 @@ discard block |
||
172 | 188 | */ |
173 | 189 | public function store($id = null) |
174 | 190 | { |
175 | - if ($this->store) return $this->store; |
|
191 | + if ($this->store) { |
|
192 | + return $this->store; |
|
193 | + } |
|
176 | 194 | |
177 | 195 | $this->store = new StoreHandler($id ? $id : null); |
178 | 196 | return $this->store($id ? $id : null); |
@@ -185,7 +203,9 @@ discard block |
||
185 | 203 | */ |
186 | 204 | public function queries() |
187 | 205 | { |
188 | - if ($this->queries) return $this->queries; |
|
206 | + if ($this->queries) { |
|
207 | + return $this->queries; |
|
208 | + } |
|
189 | 209 | |
190 | 210 | $this->queries = new QueryHandler; |
191 | 211 | return $this->queries(); |
@@ -198,7 +218,9 @@ discard block |
||
198 | 218 | */ |
199 | 219 | public function query($id = null) |
200 | 220 | { |
201 | - if ($this->query) return $this->query; |
|
221 | + if ($this->query) { |
|
222 | + return $this->query; |
|
223 | + } |
|
202 | 224 | |
203 | 225 | $this->query = new QueryHandler($id ? $id : null); |
204 | 226 | return $this->query($id ? $id : null); |
@@ -211,7 +233,9 @@ discard block |
||
211 | 233 | */ |
212 | 234 | public function exports() |
213 | 235 | { |
214 | - if ($this->exports) return $this->exports; |
|
236 | + if ($this->exports) { |
|
237 | + return $this->exports; |
|
238 | + } |
|
215 | 239 | |
216 | 240 | $this->exports = new ExportHandler; |
217 | 241 | return $this->exports(); |
@@ -224,7 +248,9 @@ discard block |
||
224 | 248 | */ |
225 | 249 | public function export($id = null) |
226 | 250 | { |
227 | - if ($this->export) return $this->export; |
|
251 | + if ($this->export) { |
|
252 | + return $this->export; |
|
253 | + } |
|
228 | 254 | |
229 | 255 | $this->export = new ExportHandler($id ? $id : null); |
230 | 256 | return $this->export($id ? $id : null); |
@@ -237,7 +263,9 @@ discard block |
||
237 | 263 | */ |
238 | 264 | public function personas() |
239 | 265 | { |
240 | - if ($this->personas) return $this->personas; |
|
266 | + if ($this->personas) { |
|
267 | + return $this->personas; |
|
268 | + } |
|
241 | 269 | |
242 | 270 | $this->personas = new PersonaHandler; |
243 | 271 | return $this->personas(); |
@@ -251,7 +279,9 @@ discard block |
||
251 | 279 | */ |
252 | 280 | public function persona($id = null) |
253 | 281 | { |
254 | - if ($this->persona) return $this->persona; |
|
282 | + if ($this->persona) { |
|
283 | + return $this->persona; |
|
284 | + } |
|
255 | 285 | |
256 | 286 | $this->persona = new PersonaHandler($id ? $id : null); |
257 | 287 | return $this->persona($id ? $id : null); |
@@ -264,7 +294,9 @@ discard block |
||
264 | 294 | */ |
265 | 295 | public function journeys() |
266 | 296 | { |
267 | - if ($this->journeys) return $this->journeys; |
|
297 | + if ($this->journeys) { |
|
298 | + return $this->journeys; |
|
299 | + } |
|
268 | 300 | |
269 | 301 | $this->journeys = new JourneyHandler; |
270 | 302 | return $this->journeys(); |
@@ -278,7 +310,9 @@ discard block |
||
278 | 310 | */ |
279 | 311 | public function journey($id = null) |
280 | 312 | { |
281 | - if ($this->journey) return $this->journey; |
|
313 | + if ($this->journey) { |
|
314 | + return $this->journey; |
|
315 | + } |
|
282 | 316 | |
283 | 317 | $this->journey = new JourneyHandler($id ? $id : null); |
284 | 318 | return $this->journey($id ? $id : null); |
@@ -292,7 +326,9 @@ discard block |
||
292 | 326 | */ |
293 | 327 | public function journeyProgress($id = null) |
294 | 328 | { |
295 | - if ($this->journey_progress) return $this->journey_progress; |
|
329 | + if ($this->journey_progress) { |
|
330 | + return $this->journey_progress; |
|
331 | + } |
|
296 | 332 | |
297 | 333 | $this->journey_progress = new JourneyProgressHandler($id ? $id : null); |
298 | 334 | return $this->journeyProgress($id ? $id : null); |
@@ -305,7 +341,9 @@ discard block |
||
305 | 341 | */ |
306 | 342 | public function dashboards() |
307 | 343 | { |
308 | - if ($this->dashboards) return $this->dashboards; |
|
344 | + if ($this->dashboards) { |
|
345 | + return $this->dashboards; |
|
346 | + } |
|
309 | 347 | |
310 | 348 | $this->dashboards = new DashboardHandler; |
311 | 349 | return $this->dashboards(); |
@@ -319,7 +357,9 @@ discard block |
||
319 | 357 | */ |
320 | 358 | public function dashboard($id = null) |
321 | 359 | { |
322 | - if ($this->dashboard) return $this->dashboard; |
|
360 | + if ($this->dashboard) { |
|
361 | + return $this->dashboard; |
|
362 | + } |
|
323 | 363 | |
324 | 364 | $this->dashboard = new DashboardHandler($id ? $id : null); |
325 | 365 | return $this->dashboard($id ? $id : null); |
@@ -332,7 +372,9 @@ discard block |
||
332 | 372 | */ |
333 | 373 | public function downloads() |
334 | 374 | { |
335 | - if ($this->downloads) return $this->downloads; |
|
375 | + if ($this->downloads) { |
|
376 | + return $this->downloads; |
|
377 | + } |
|
336 | 378 | |
337 | 379 | $this->downloads = new DownloadHandler; |
338 | 380 | return $this->downloads(); |
@@ -345,7 +387,9 @@ discard block |
||
345 | 387 | */ |
346 | 388 | public function download($id) |
347 | 389 | { |
348 | - if ($this->download) return $this->download; |
|
390 | + if ($this->download) { |
|
391 | + return $this->download; |
|
392 | + } |
|
349 | 393 | |
350 | 394 | $this->download = new DownloadHandler($id); |
351 | 395 | return $this->download($id); |
@@ -358,7 +402,9 @@ discard block |
||
358 | 402 | */ |
359 | 403 | public function statements() |
360 | 404 | { |
361 | - if ($this->statements) return $this->statements; |
|
405 | + if ($this->statements) { |
|
406 | + return $this->statements; |
|
407 | + } |
|
362 | 408 | |
363 | 409 | $this->statements = new StatementHandler; |
364 | 410 | return $this->statements(); |
@@ -372,7 +418,9 @@ discard block |
||
372 | 418 | */ |
373 | 419 | public function statement($id = null) |
374 | 420 | { |
375 | - if ($this->statement) return $this->statement; |
|
421 | + if ($this->statement) { |
|
422 | + return $this->statement; |
|
423 | + } |
|
376 | 424 | |
377 | 425 | $this->statement = new StatementHandler($id ?? $id); |
378 | 426 | return $this->statement($id ?? $id); |
@@ -385,7 +433,9 @@ discard block |
||
385 | 433 | */ |
386 | 434 | public function statementForwarding($id = null) |
387 | 435 | { |
388 | - if ($this->statement_forwarding) return $this->statement_forwarding; |
|
436 | + if ($this->statement_forwarding) { |
|
437 | + return $this->statement_forwarding; |
|
438 | + } |
|
389 | 439 | |
390 | 440 | $this->statement_forwarding = new StatementForwardingHandler($id ?? $id); |
391 | 441 | return $this->statementForwarding($id ?? $id); |
@@ -399,7 +449,9 @@ discard block |
||
399 | 449 | */ |
400 | 450 | public function organisation($id) |
401 | 451 | { |
402 | - if ($this->organisation) return $this->organisation; |
|
452 | + if ($this->organisation) { |
|
453 | + return $this->organisation; |
|
454 | + } |
|
403 | 455 | |
404 | 456 | $this->organisation = new OrganisationHandler($id); |
405 | 457 | return $this->organisation($id); |
@@ -413,7 +465,9 @@ discard block |
||
413 | 465 | */ |
414 | 466 | public function visualisations() |
415 | 467 | { |
416 | - if ($this->visualisations) return $this->visualisations; |
|
468 | + if ($this->visualisations) { |
|
469 | + return $this->visualisations; |
|
470 | + } |
|
417 | 471 | |
418 | 472 | $this->visualisations = new VisualisationHandler; |
419 | 473 | return $this->visualisations(); |
@@ -427,7 +481,9 @@ discard block |
||
427 | 481 | */ |
428 | 482 | public function visualisation($id = null) |
429 | 483 | { |
430 | - if ($this->visualisation) return $this->visualisation; |
|
484 | + if ($this->visualisation) { |
|
485 | + return $this->visualisation; |
|
486 | + } |
|
431 | 487 | |
432 | 488 | $this->visualisation = new VisualisationHandler($id ? $id : null); |
433 | 489 | return $this->visualisation($id ? $id : null); |
@@ -484,7 +484,7 @@ |
||
484 | 484 | if ($this->learning_locker_api->check()) { |
485 | 485 | $this->info('Successfully connected to Learning Locker®'); |
486 | 486 | } else { |
487 | - return $this->error(' << Could not connect to Learning Locker® '); |
|
487 | + return $this->error(' << Could not connect to Learning Locker® '); |
|
488 | 488 | } |
489 | 489 | |
490 | 490 | } |
@@ -14,8 +14,8 @@ discard block |
||
14 | 14 | class SetupClientommand extends Command |
15 | 15 | { |
16 | 16 | |
17 | - protected $seedersPath = __DIR__.'/../../publishable/database/seeds/'; |
|
18 | - protected $migrationsPath = __DIR__.'/../../publishable/database/migrations/'; |
|
17 | + protected $seedersPath = __DIR__ . '/../../publishable/database/seeds/'; |
|
18 | + protected $migrationsPath = __DIR__ . '/../../publishable/database/migrations/'; |
|
19 | 19 | |
20 | 20 | /** |
21 | 21 | * The console command name. |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | protected function getOptions() |
35 | 35 | { |
36 | 36 | return [ |
37 | - ['setup', null, InputOption::VALUE_NONE, 'Add new Learning Locker® Client', null], |
|
37 | + [ 'setup', null, InputOption::VALUE_NONE, 'Add new Learning Locker® Client', null ], |
|
38 | 38 | ]; |
39 | 39 | } |
40 | 40 | |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | |
159 | 159 | elseif ($this->confirm("Setup a single client with database?")): |
160 | 160 | |
161 | - if($this->confirm("Add new columns to an existing database table?")) { |
|
161 | + if ($this->confirm("Add new columns to an existing database table?")) { |
|
162 | 162 | |
163 | 163 | $migratedDatabaseTables = \DB::connection()->getDoctrineSchemaManager()->listTableNames(); |
164 | 164 | $selectedTable = $this->anticipate("Which database table?", $migratedDatabaseTables); echo "\n"; |
@@ -166,16 +166,16 @@ discard block |
||
166 | 166 | $tableColumns = \Schema::getColumnListing($selectedTable); |
167 | 167 | |
168 | 168 | $this->line(ucfirst($selectedTable) . " Table"); echo "\n"; |
169 | - $this->table($tableColumns, []); |
|
169 | + $this->table($tableColumns, [ ]); |
|
170 | 170 | |
171 | 171 | $keyColumn = $this->anticipate("Which column for the Learning Locker client key?", $tableColumns); echo "\n"; |
172 | 172 | $secretColumn = $this->anticipate("Which column for the Learning Locker client secret?", $tableColumns); echo "\n"; |
173 | 173 | |
174 | - $headers = [$keyColumn, $secretColumn]; |
|
174 | + $headers = [ $keyColumn, $secretColumn ]; |
|
175 | 175 | |
176 | 176 | $key = str_random(10); |
177 | 177 | $secret = str_random(10); |
178 | - $tableColumns = [$key, $secret]; |
|
178 | + $tableColumns = [ $key, $secret ]; |
|
179 | 179 | |
180 | 180 | $this->table($headers, $tableColumns); |
181 | 181 | dd($tableColumns); |
@@ -187,17 +187,17 @@ discard block |
||
187 | 187 | $migrationsDirectory = database_path("/migrations/*"); |
188 | 188 | $migrationFiles = glob($migrationsDirectory); |
189 | 189 | |
190 | - $migrationFileNames = []; |
|
191 | - $addColumnMigrations = []; |
|
190 | + $migrationFileNames = [ ]; |
|
191 | + $addColumnMigrations = [ ]; |
|
192 | 192 | |
193 | 193 | //Loop through the array that glob returned. |
194 | - foreach($migrationFiles as $migrationFile) { |
|
194 | + foreach ($migrationFiles as $migrationFile) { |
|
195 | 195 | |
196 | - if(strpos($migrationFile, "add_learning_locker_client_to_$table")) { |
|
197 | - $addColumnMigrations[] = $migrationFile; |
|
196 | + if (strpos($migrationFile, "add_learning_locker_client_to_$table")) { |
|
197 | + $addColumnMigrations[ ] = $migrationFile; |
|
198 | 198 | } |
199 | 199 | |
200 | - $migrationFileNames[] = $migrationFile; |
|
200 | + $migrationFileNames[ ] = $migrationFile; |
|
201 | 201 | } |
202 | 202 | dd($addColumnMigrations); |
203 | 203 | |
@@ -216,23 +216,23 @@ discard block |
||
216 | 216 | break; |
217 | 217 | } |
218 | 218 | |
219 | - if(isset($addColumnMigrations) && count($addColumnMigrations) > 1) { |
|
219 | + if (isset($addColumnMigrations) && count($addColumnMigrations) > 1) { |
|
220 | 220 | |
221 | 221 | $this->question(" << You have " . count($addColumnMigrations) . " migrations which will add client credential columns to the $table table "); |
222 | 222 | |
223 | - if($this->confirm("Would you like to overwrite these files with the new database migration?")) { |
|
223 | + if ($this->confirm("Would you like to overwrite these files with the new database migration?")) { |
|
224 | 224 | |
225 | 225 | |
226 | - foreach($addColumnMigrations as $addColumnMigrations) { |
|
227 | - if(is_file($addColumnMigrations)) |
|
226 | + foreach ($addColumnMigrations as $addColumnMigrations) { |
|
227 | + if (is_file($addColumnMigrations)) |
|
228 | 228 | unlink($addColumnMigrations); //delete file |
229 | 229 | } |
230 | 230 | |
231 | - $makeMigration = $this->call("make:migration", ['name' => "add_learning_locker_client_to_$table"]); |
|
231 | + $makeMigration = $this->call("make:migration", [ 'name' => "add_learning_locker_client_to_$table" ]); |
|
232 | 232 | |
233 | - } elseif($this->confirm("Would you like to save the new database migration and keep existing migrations?")) { |
|
233 | + } elseif ($this->confirm("Would you like to save the new database migration and keep existing migrations?")) { |
|
234 | 234 | |
235 | - $makeMigration = $this->call("make:migration", ['name' => "add_learning_locker_client_to_$table"]); |
|
235 | + $makeMigration = $this->call("make:migration", [ 'name' => "add_learning_locker_client_to_$table" ]); |
|
236 | 236 | |
237 | 237 | } |
238 | 238 | |
@@ -303,7 +303,7 @@ discard block |
||
303 | 303 | $this->error(" << Client Setup Failed: Laralocker requires a Learning Locker url, client key and secret "); |
304 | 304 | $this->error(" << Docs: (https://docs.learninglocker.net/http-clients/) "); |
305 | 305 | |
306 | - if($this->confirm("Attempt to conigure client details?")) { |
|
306 | + if ($this->confirm("Attempt to conigure client details?")) { |
|
307 | 307 | $this->setupClient(); |
308 | 308 | } |
309 | 309 | |
@@ -351,13 +351,13 @@ discard block |
||
351 | 351 | $domain = $this->anticipate("What's the new learning Locker url?", [ |
352 | 352 | 'https://saas.learninglocker.net', 'http://saas.learninglocker.net' |
353 | 353 | ]); |
354 | - $this->setEnv([strtoupper(LearningLockerConstants::URL) => $domain]); |
|
354 | + $this->setEnv([ strtoupper(LearningLockerConstants::URL) => $domain ]); |
|
355 | 355 | |
356 | 356 | $key = $this->ask("What's the new learning Locker client key?"); |
357 | - $this->setEnv([strtoupper(LearningLockerConstants::KEY) => $key]); |
|
357 | + $this->setEnv([ strtoupper(LearningLockerConstants::KEY) => $key ]); |
|
358 | 358 | |
359 | 359 | $secret = $this->secret("What's the new learning Locker client secret"); |
360 | - $this->setEnv([strtoupper(LearningLockerConstants::SECRET) => $secret]); |
|
360 | + $this->setEnv([ strtoupper(LearningLockerConstants::SECRET) => $secret ]); |
|
361 | 361 | } |
362 | 362 | |
363 | 363 | } else { |
@@ -370,14 +370,14 @@ discard block |
||
370 | 370 | $domain = $this->anticipate("What's the new learning Locker domain?", [ |
371 | 371 | 'https://saas.learninglocker.net', 'http://saas.learninglocker.net' |
372 | 372 | ]); |
373 | - $this->setEnv([strtoupper(LearningLockerConstants::URL) => $domain]); |
|
373 | + $this->setEnv([ strtoupper(LearningLockerConstants::URL) => $domain ]); |
|
374 | 374 | } |
375 | 375 | break; |
376 | 376 | case $url_has_variable_with_no_value: |
377 | 377 | $domain = $this->anticipate("What's your Learning Locker url?", [ |
378 | 378 | 'https://saas.learninglocker.net', 'http://saas.learninglocker.net' |
379 | 379 | ]); |
380 | - $this->setEnv([strtoupper(LearningLockerConstants::URL) => $domain]); |
|
380 | + $this->setEnv([ strtoupper(LearningLockerConstants::URL) => $domain ]); |
|
381 | 381 | break; |
382 | 382 | case $url_has_no_variable_and_no_value: |
383 | 383 | $domain = $this->anticipate("What's your Learning Locker url?", [ |
@@ -392,12 +392,12 @@ discard block |
||
392 | 392 | case $key_has_variable_and_value: |
393 | 393 | if ($this->confirm('Update Learning Locker client key?')) { |
394 | 394 | $key = $this->ask("What's the new learning Locker client key?"); |
395 | - $this->setEnv([strtoupper(LearningLockerConstants::KEY) => $key]); |
|
395 | + $this->setEnv([ strtoupper(LearningLockerConstants::KEY) => $key ]); |
|
396 | 396 | } |
397 | 397 | break; |
398 | 398 | case $key_has_variable_with_no_value: |
399 | 399 | $key = $this->ask("What's your Learning Locker client key?"); |
400 | - $this->setEnv([strtoupper(LearningLockerConstants::KEY) => $key]); |
|
400 | + $this->setEnv([ strtoupper(LearningLockerConstants::KEY) => $key ]); |
|
401 | 401 | break; |
402 | 402 | case $key_has_no_variable_and_no_value: |
403 | 403 | $key = $this->ask("What's your Learning Locker client key?"); |
@@ -410,12 +410,12 @@ discard block |
||
410 | 410 | case $secret_has_variable_and_value: |
411 | 411 | if ($this->confirm('Update Learning Locker client secret?')) { |
412 | 412 | $secret = $this->secret("What's the new learning Locker client secret"); |
413 | - $this->setEnv([strtoupper(LearningLockerConstants::KEY) => $key]); |
|
413 | + $this->setEnv([ strtoupper(LearningLockerConstants::KEY) => $key ]); |
|
414 | 414 | } |
415 | 415 | break; |
416 | 416 | case $secret_has_variable_with_no_value: |
417 | 417 | $secret = $this->secret("What's your Learning Locker client secret"); |
418 | - $this->setEnv([strtoupper(LearningLockerConstants::KEY) => $secret]); |
|
418 | + $this->setEnv([ strtoupper(LearningLockerConstants::KEY) => $secret ]); |
|
419 | 419 | break; |
420 | 420 | case $secret_has_no_variable_and_no_value: |
421 | 421 | $secret = $this->secret("What's your Learning Locker client secret"); |
@@ -450,8 +450,8 @@ discard block |
||
450 | 450 | */ |
451 | 451 | protected function findComposer() |
452 | 452 | { |
453 | - if (file_exists(getcwd().'/composer.phar')) { |
|
454 | - return '"'.PHP_BINARY.'" '.getcwd().'/composer.phar'; |
|
453 | + if (file_exists(getcwd() . '/composer.phar')) { |
|
454 | + return '"' . PHP_BINARY . '" ' . getcwd() . '/composer.phar'; |
|
455 | 455 | } |
456 | 456 | |
457 | 457 | return 'composer'; |
@@ -472,8 +472,8 @@ discard block |
||
472 | 472 | |
473 | 473 | public function publishVendor() |
474 | 474 | { |
475 | - $tags = ['config']; |
|
476 | - $this->call('vendor:publish', ['--provider' => LaraLockerServiceProvider::class, '--tag' => $tags]); |
|
475 | + $tags = [ 'config' ]; |
|
476 | + $this->call('vendor:publish', [ '--provider' => LaraLockerServiceProvider::class, '--tag' => $tags ]); |
|
477 | 477 | } |
478 | 478 | |
479 | 479 | public function checkLearningLockerConnection() |
@@ -521,7 +521,7 @@ discard block |
||
521 | 521 | foreach ($variables as $variable) { |
522 | 522 | $env_variable = $this->getEnv($variable); |
523 | 523 | $contents = file_get_contents($env); |
524 | - $contents = str_replace(strtoupper($variable) . '=' . $env_variable, strtoupper($variable) . '=' . $data[$variable], $contents); |
|
524 | + $contents = str_replace(strtoupper($variable) . '=' . $env_variable, strtoupper($variable) . '=' . $data[ $variable ], $contents); |
|
525 | 525 | file_put_contents($env, $contents); |
526 | 526 | } |
527 | 527 | } |
@@ -541,7 +541,7 @@ discard block |
||
541 | 541 | $env_contents = $filesystem->get($env); |
542 | 542 | |
543 | 543 | if (false === strpos($env_contents, $key)) { |
544 | - $filesystem->append($env, "\n" . strtoupper($key) . '=' . strtolower($value)); |
|
544 | + $filesystem->append($env, "\n" . strtoupper($key) . '=' . strtolower($value)); |
|
545 | 545 | return $this->info("Created Environment variable $value successfully."); |
546 | 546 | } |
547 | 547 | } |
@@ -87,12 +87,11 @@ discard block |
||
87 | 87 | |
88 | 88 | } else { |
89 | 89 | $this->error(" << Not sure of any other way to to setup an single client in an existing database"); |
90 | - } |
|
91 | - |
|
92 | - |
|
93 | - else: |
|
90 | + } else { |
|
91 | + : |
|
94 | 92 | |
95 | 93 | $this->error(" << Unable to setup client credentials for Learning Locker® "); |
94 | + } |
|
96 | 95 | |
97 | 96 | if ($this->confirm("Would you like to run through the client setup again?")) { |
98 | 97 | return $this->setupClient(); |
@@ -122,13 +121,7 @@ discard block |
||
122 | 121 | |
123 | 122 | } else { |
124 | 123 | $this->error(" << Not sure of any other way to to setup an single client in an existing database"); |
125 | - } |
|
126 | - |
|
127 | - |
|
128 | - |
|
129 | - |
|
130 | - |
|
131 | - elseif ($this->confirm("Setup multiply Learning Locker® clients in the database?")): |
|
124 | + } elseif ($this->confirm("Setup multiply Learning Locker® clients in the database?")): |
|
132 | 125 | |
133 | 126 | |
134 | 127 | |
@@ -141,13 +134,10 @@ discard block |
||
141 | 134 | |
142 | 135 | } else { |
143 | 136 | $this->error(" << Not sure of any other way to to setup an single client in an existing database"); |
144 | - } |
|
145 | - |
|
146 | - |
|
147 | - |
|
148 | - |
|
149 | - else: |
|
137 | + } else { |
|
138 | + : |
|
150 | 139 | $this->error(" << Not sure of any other way to to setup an single client in an existing database"); |
140 | + } |
|
151 | 141 | |
152 | 142 | if ($this->confirm("Would you like to run through the setup process again?")) { |
153 | 143 | } |
@@ -224,8 +214,10 @@ discard block |
||
224 | 214 | |
225 | 215 | |
226 | 216 | foreach($addColumnMigrations as $addColumnMigrations) { |
227 | - if(is_file($addColumnMigrations)) |
|
228 | - unlink($addColumnMigrations); //delete file |
|
217 | + if(is_file($addColumnMigrations)) { |
|
218 | + unlink($addColumnMigrations); |
|
219 | + } |
|
220 | + //delete file |
|
229 | 221 | } |
230 | 222 | |
231 | 223 | $makeMigration = $this->call("make:migration", ['name' => "add_learning_locker_client_to_$table"]); |
@@ -293,14 +285,14 @@ discard block |
||
293 | 285 | dump("Single client in the database"); |
294 | 286 | } else { |
295 | 287 | dump("Single client in the database"); |
296 | - } |
|
297 | - |
|
298 | - elseif ($this->confirm("Setup multiple Learning Locker client's with database?")): |
|
288 | + } elseif ($this->confirm("Setup multiple Learning Locker client's with database?")): |
|
299 | 289 | dump("database setup"); |
300 | 290 | |
301 | - else: |
|
291 | + else { |
|
292 | + : |
|
302 | 293 | |
303 | 294 | $this->error(" << Client Setup Failed: Laralocker requires a Learning Locker url, client key and secret "); |
295 | + } |
|
304 | 296 | $this->error(" << Docs: (https://docs.learninglocker.net/http-clients/) "); |
305 | 297 | |
306 | 298 | if($this->confirm("Attempt to conigure client details?")) { |