1 |
efrain |
1 |
<?php
|
|
|
2 |
declare(strict_types=1);
|
|
|
3 |
|
|
|
4 |
namespace LeadersLinked\Mapper;
|
|
|
5 |
|
|
|
6 |
use LeadersLinked\Mapper\Common\MapperCommon;
|
|
|
7 |
use Laminas\Db\Adapter\AdapterInterface;
|
|
|
8 |
use LeadersLinked\Model\CompanyMicrolearningUserProgress;
|
|
|
9 |
use LeadersLinked\Hydrator\ObjectPropertyHydrator;
|
|
|
10 |
use Laminas\Db\Sql\Expression;
|
|
|
11 |
|
|
|
12 |
|
|
|
13 |
class CompanyMicrolearningUserProgressMapper extends MapperCommon
|
|
|
14 |
{
|
|
|
15 |
const _TABLE = 'tbl_company_microlearning_user_progress';
|
|
|
16 |
|
|
|
17 |
/**
|
|
|
18 |
*
|
|
|
19 |
* @var CompanyMicrolearningUserProgressMapper
|
|
|
20 |
*/
|
|
|
21 |
private static $_instance;
|
|
|
22 |
|
|
|
23 |
/**
|
|
|
24 |
*
|
|
|
25 |
* @param AdapterInterface $adapter
|
|
|
26 |
*/
|
|
|
27 |
private function __construct($adapter)
|
|
|
28 |
{
|
|
|
29 |
parent::__construct($adapter);
|
|
|
30 |
}
|
|
|
31 |
|
|
|
32 |
/**
|
|
|
33 |
*
|
|
|
34 |
* @param AdapterInterface $adapter
|
|
|
35 |
* @return CompanyMicrolearningUserProgressMapper
|
|
|
36 |
*/
|
|
|
37 |
public static function getInstance($adapter)
|
|
|
38 |
{
|
|
|
39 |
if(self::$_instance == null) {
|
|
|
40 |
self::$_instance = new CompanyMicrolearningUserProgressMapper($adapter);
|
|
|
41 |
}
|
|
|
42 |
return self::$_instance;
|
|
|
43 |
}
|
|
|
44 |
|
|
|
45 |
/**
|
|
|
46 |
*
|
|
|
47 |
* @param int $user_id
|
|
|
48 |
* @return CompanyMicrolearningUserProgress[]
|
|
|
49 |
*/
|
|
|
50 |
public function fetchAllByUserId($user_id)
|
|
|
51 |
{
|
|
|
52 |
$prototype = new CompanyMicrolearningUserProgress();
|
|
|
53 |
|
|
|
54 |
$select = $this->sql->select(self::_TABLE);
|
|
|
55 |
$select->where->equalTo('user_id', $user_id);
|
|
|
56 |
|
|
|
57 |
return $this->executeFetchAllObject($select, $prototype);
|
|
|
58 |
}
|
|
|
59 |
|
|
|
60 |
/**
|
|
|
61 |
*
|
|
|
62 |
* @return int[]
|
|
|
63 |
*/
|
|
|
64 |
public function fetchAllDistinctUserIds()
|
|
|
65 |
{
|
|
|
66 |
$user_ids = [];
|
|
|
67 |
|
|
|
68 |
$select = $this->sql->select(self::_TABLE);
|
|
|
69 |
$select->columns(['user_id' => new Expression('DISTINCT(user_id)')]);
|
|
|
70 |
|
|
|
71 |
$records = $this->executeFetchAllArray($select);
|
|
|
72 |
foreach ($records as $record)
|
|
|
73 |
{
|
|
|
74 |
array_push($user_ids, $record['user_id']);
|
|
|
75 |
}
|
|
|
76 |
|
|
|
77 |
return $user_ids;
|
|
|
78 |
|
|
|
79 |
}
|
|
|
80 |
|
|
|
81 |
|
|
|
82 |
|
|
|
83 |
|
|
|
84 |
|
|
|
85 |
/**
|
|
|
86 |
*
|
|
|
87 |
* @return CompanyMicrolearningUserProgress[]
|
|
|
88 |
*/
|
|
|
89 |
public function fetchAllTopics()
|
|
|
90 |
{
|
|
|
91 |
$prototype = new CompanyMicrolearningUserProgress();
|
|
|
92 |
|
|
|
93 |
$select = $this->sql->select(self::_TABLE);
|
|
|
94 |
$select->where->equalTo('type', CompanyMicrolearningUserProgress::TYPE_TOPIC);
|
|
|
95 |
|
|
|
96 |
//echo $select->getSqlString($this->adapter->platform); exit;
|
|
|
97 |
|
|
|
98 |
return $this->executeFetchAllObject($select, $prototype);
|
|
|
99 |
}
|
|
|
100 |
|
|
|
101 |
|
|
|
102 |
/**
|
|
|
103 |
*
|
|
|
104 |
* @return CompanyMicrolearningUserProgress[]
|
|
|
105 |
*/
|
|
|
106 |
public function fetchAllCapsules()
|
|
|
107 |
{
|
|
|
108 |
$prototype = new CompanyMicrolearningUserProgress();
|
|
|
109 |
|
|
|
110 |
$select = $this->sql->select(self::_TABLE);
|
|
|
111 |
$select->where->equalTo('type', CompanyMicrolearningUserProgress::TYPE_CAPSULE);
|
|
|
112 |
|
|
|
113 |
return $this->executeFetchAllObject($select, $prototype);
|
|
|
114 |
}
|
|
|
115 |
|
|
|
116 |
|
|
|
117 |
/**
|
|
|
118 |
*
|
|
|
119 |
* @param int $user_id
|
|
|
120 |
* @param int $slide_id
|
|
|
121 |
* @return CompanyMicrolearningUserProgress
|
|
|
122 |
*/
|
|
|
123 |
public function fetchOneByUserIdAndSlideId($user_id, $slide_id)
|
|
|
124 |
{
|
|
|
125 |
$prototype = new CompanyMicrolearningUserProgress();
|
|
|
126 |
|
|
|
127 |
$select = $this->sql->select(self::_TABLE);
|
|
|
128 |
$select->where->equalTo('user_id', $user_id);
|
|
|
129 |
$select->where->equalTo('slide_id', $slide_id);
|
|
|
130 |
$select->where->equalTo('type', CompanyMicrolearningUserProgress::TYPE_SLIDE);
|
|
|
131 |
|
|
|
132 |
$select->limit(1);
|
|
|
133 |
|
|
|
134 |
return $this->executeFetchOneObject($select, $prototype);
|
|
|
135 |
}
|
|
|
136 |
|
|
|
137 |
/**
|
|
|
138 |
*
|
|
|
139 |
* @param int $user_id
|
119 |
efrain |
140 |
* @param int[] $capsule_ids
|
|
|
141 |
* @return CompanyMicrolearningUserProgress
|
|
|
142 |
*/
|
|
|
143 |
public function fetchOneLastCapsuleInProgressByUserIdAndCapsuleIds($user_id, $capsule_ids)
|
|
|
144 |
{
|
|
|
145 |
$capsule_ids = empty($capsule_ids) ? [0] : $capsule_ids;
|
|
|
146 |
|
|
|
147 |
$prototype = new CompanyMicrolearningUserProgress();
|
|
|
148 |
|
|
|
149 |
$select = $this->sql->select(self::_TABLE);
|
|
|
150 |
$select->where->equalTo('user_id', $user_id);
|
|
|
151 |
$select->where->in('capsule_id', $capsule_ids);
|
|
|
152 |
$select->where->greaterThan('progress', 0);
|
|
|
153 |
$select->where->lessThan('progress', 100);
|
|
|
154 |
$select->where->equalTo('type', CompanyMicrolearningUserProgress::TYPE_CAPSULE);
|
|
|
155 |
$select->order('updated_on');
|
|
|
156 |
$select->limit(1);
|
|
|
157 |
|
|
|
158 |
|
|
|
159 |
//echo $select->getSqlString($this->adapter->platform);
|
|
|
160 |
|
|
|
161 |
return $this->executeFetchOneObject($select, $prototype);
|
|
|
162 |
}
|
|
|
163 |
|
|
|
164 |
/**
|
|
|
165 |
*
|
|
|
166 |
* @param int $user_id
|
1 |
efrain |
167 |
* @param int $capsule_id
|
|
|
168 |
* @return CompanyMicrolearningUserProgress
|
|
|
169 |
*/
|
|
|
170 |
public function fetchOneByUseridAndCapsuleId($user_id, $capsule_id)
|
|
|
171 |
{
|
|
|
172 |
$prototype = new CompanyMicrolearningUserProgress();
|
|
|
173 |
|
|
|
174 |
$select = $this->sql->select(self::_TABLE);
|
|
|
175 |
$select->where->equalTo('user_id', $user_id);
|
|
|
176 |
$select->where->equalTo('capsule_id', $capsule_id);
|
|
|
177 |
$select->where->equalTo('type', CompanyMicrolearningUserProgress::TYPE_CAPSULE);
|
|
|
178 |
$select->limit(1);
|
|
|
179 |
|
|
|
180 |
|
|
|
181 |
//echo $select->getSqlString($this->adapter->platform);
|
|
|
182 |
|
|
|
183 |
return $this->executeFetchOneObject($select, $prototype);
|
|
|
184 |
}
|
|
|
185 |
|
|
|
186 |
/**
|
|
|
187 |
*
|
|
|
188 |
* @param int $user_id
|
|
|
189 |
* @param int $topic_id
|
|
|
190 |
* @return CompanyMicrolearningUserProgress
|
|
|
191 |
*/
|
|
|
192 |
public function fetchOneByUserIdAndTopicId($user_id, $topic_id)
|
|
|
193 |
{
|
|
|
194 |
$prototype = new CompanyMicrolearningUserProgress();
|
|
|
195 |
|
|
|
196 |
$select = $this->sql->select(self::_TABLE);
|
|
|
197 |
$select->where->equalTo('user_id', $user_id);
|
|
|
198 |
$select->where->equalTo('topic_id', $topic_id);
|
|
|
199 |
$select->where->equalTo('type', CompanyMicrolearningUserProgress::TYPE_TOPIC);
|
|
|
200 |
$select->limit(1);
|
|
|
201 |
|
|
|
202 |
return $this->executeFetchOneObject($select, $prototype);
|
|
|
203 |
}
|
|
|
204 |
|
|
|
205 |
|
|
|
206 |
/**
|
|
|
207 |
*
|
|
|
208 |
* @param int $user_id
|
119 |
efrain |
209 |
* @param int $topic_id
|
|
|
210 |
* @return int
|
|
|
211 |
*/
|
|
|
212 |
public function fetchCountCapsulesStartedByIdAndTopicId($user_id, $topic_id)
|
|
|
213 |
{
|
|
|
214 |
$select = $this->sql->select(self::_TABLE);
|
|
|
215 |
$select->columns(['total' => new Expression('COUNT(*)')]);
|
|
|
216 |
$select->where->equalTo('user_id', $user_id);
|
|
|
217 |
$select->where->equalTo('topic_id', $topic_id);
|
|
|
218 |
$select->where->equalTo('type', CompanyMicrolearningUserProgress::TYPE_CAPSULE);
|
|
|
219 |
$select->where->greaterThan('progress', 0);
|
|
|
220 |
$select->where->lessThan('progress', 100);
|
|
|
221 |
$select->where->equalTo('completed', 0);
|
|
|
222 |
$select->limit(1);
|
|
|
223 |
|
|
|
224 |
$record = $this->executeFetchOneArray($select);
|
|
|
225 |
return $record['total'];
|
|
|
226 |
}
|
|
|
227 |
|
|
|
228 |
|
|
|
229 |
/**
|
|
|
230 |
*
|
|
|
231 |
* @param int $user_id
|
|
|
232 |
* @param int $topic_id
|
|
|
233 |
* @return int
|
|
|
234 |
*/
|
|
|
235 |
public function fetchCountCapsulesCompletedByIdAndTopicId($user_id, $topic_id)
|
|
|
236 |
{
|
|
|
237 |
$select = $this->sql->select(self::_TABLE);
|
|
|
238 |
$select->columns(['total' => new Expression('COUNT(*)')]);
|
|
|
239 |
$select->where->equalTo('user_id', $user_id);
|
|
|
240 |
$select->where->equalTo('topic_id', $topic_id);
|
|
|
241 |
$select->where->equalTo('type', CompanyMicrolearningUserProgress::TYPE_CAPSULE);
|
|
|
242 |
$select->where->equalTo('completed', 1);
|
|
|
243 |
$select->limit(1);
|
|
|
244 |
|
|
|
245 |
$record = $this->executeFetchOneArray($select);
|
|
|
246 |
return $record['total'];
|
|
|
247 |
}
|
|
|
248 |
|
|
|
249 |
|
146 |
efrain |
250 |
|
|
|
251 |
|
119 |
efrain |
252 |
/**
|
|
|
253 |
*
|
|
|
254 |
* @param int $user_id
|
|
|
255 |
* @param int $topic_id
|
|
|
256 |
* @return int
|
|
|
257 |
*/
|
|
|
258 |
public function fetchCountCapsulesCompletedWithReturningByIdAndTopicId($user_id, $topic_id)
|
|
|
259 |
{
|
|
|
260 |
$select = $this->sql->select(self::_TABLE);
|
|
|
261 |
$select->columns(['total' => new Expression('COUNT(*)')]);
|
|
|
262 |
$select->where->equalTo('user_id', $user_id);
|
|
|
263 |
$select->where->equalTo('topic_id', $topic_id);
|
|
|
264 |
$select->where->equalTo('type', CompanyMicrolearningUserProgress::TYPE_CAPSULE);
|
|
|
265 |
$select->where->equalTo('completed', 1);
|
|
|
266 |
$select->where->notEqualTo('returning_after_completed', 0);
|
|
|
267 |
$select->limit(1);
|
|
|
268 |
|
|
|
269 |
$record = $this->executeFetchOneArray($select);
|
|
|
270 |
return $record['total'];
|
|
|
271 |
}
|
|
|
272 |
|
|
|
273 |
/**
|
|
|
274 |
*
|
|
|
275 |
* @param int $user_id
|
|
|
276 |
* @param int $topic_id
|
|
|
277 |
* @return int
|
|
|
278 |
*/
|
|
|
279 |
public function fetchCountCapsulesCompletedWithoutReturningByIdAndTopicId($user_id, $topic_id)
|
|
|
280 |
{
|
|
|
281 |
$select = $this->sql->select(self::_TABLE);
|
|
|
282 |
$select->columns(['total' => new Expression('COUNT(*)')]);
|
|
|
283 |
$select->where->equalTo('user_id', $user_id);
|
|
|
284 |
$select->where->equalTo('topic_id', $topic_id);
|
|
|
285 |
$select->where->equalTo('type', CompanyMicrolearningUserProgress::TYPE_CAPSULE);
|
|
|
286 |
$select->where->equalTo('completed', 1);
|
|
|
287 |
$select->where->equalTo('returning_after_completed', 0);
|
|
|
288 |
$select->limit(1);
|
|
|
289 |
|
|
|
290 |
$record = $this->executeFetchOneArray($select);
|
|
|
291 |
return $record['total'];
|
|
|
292 |
}
|
|
|
293 |
|
|
|
294 |
|
|
|
295 |
/**
|
|
|
296 |
*
|
|
|
297 |
* @param int $user_id
|
1 |
efrain |
298 |
* @param int $capsule_id
|
|
|
299 |
* @return int
|
|
|
300 |
*/
|
|
|
301 |
public function fetchCountAllSlideViewedByUserIdAndCapsuleId($user_id, $capsule_id)
|
|
|
302 |
{
|
|
|
303 |
|
|
|
304 |
$select = $this->sql->select(self::_TABLE);
|
|
|
305 |
$select->columns(['total' => new Expression('COUNT(*)')]);
|
|
|
306 |
$select->where->equalTo('user_id', $user_id);
|
|
|
307 |
$select->where->equalTo('capsule_id', $capsule_id);
|
|
|
308 |
$select->where->equalTo('type', CompanyMicrolearningUserProgress::TYPE_SLIDE);
|
|
|
309 |
$select->limit(1);
|
|
|
310 |
|
|
|
311 |
$record = $this->executeFetchOneArray($select);
|
|
|
312 |
return $record['total'];
|
|
|
313 |
}
|
|
|
314 |
|
|
|
315 |
/**
|
|
|
316 |
*
|
|
|
317 |
* @param int $user_id
|
|
|
318 |
* @param int $topic_id
|
|
|
319 |
* @param int $capsule_id
|
|
|
320 |
* @return int
|
|
|
321 |
*/
|
|
|
322 |
public function fetchCountAllSlideCompletedByUserIdAndTopicIdAndCapsuleId($user_id, $topic_id, $capsule_id)
|
|
|
323 |
{
|
|
|
324 |
|
|
|
325 |
$select = $this->sql->select(self::_TABLE);
|
|
|
326 |
$select->columns(['total' => new Expression('COUNT(*)')]);
|
|
|
327 |
$select->where->equalTo('user_id', $user_id);
|
|
|
328 |
$select->where->equalTo('topic_id', $topic_id);
|
|
|
329 |
$select->where->equalTo('capsule_id', $capsule_id);
|
|
|
330 |
$select->where->equalTo('type', CompanyMicrolearningUserProgress::TYPE_SLIDE);
|
|
|
331 |
$select->where->equalTo('completed', 1);
|
|
|
332 |
$select->limit(1);
|
|
|
333 |
|
|
|
334 |
$record = $this->executeFetchOneArray($select);
|
|
|
335 |
return $record['total'];
|
|
|
336 |
}
|
|
|
337 |
|
|
|
338 |
|
|
|
339 |
/**
|
|
|
340 |
*
|
|
|
341 |
* @param int $user_id
|
|
|
342 |
* @param int $capsule_id
|
|
|
343 |
* @return int
|
|
|
344 |
*/
|
|
|
345 |
public function fetchCountAllSlideCompletedByUserIdAndCapsuleId($user_id, $capsule_id)
|
|
|
346 |
{
|
|
|
347 |
|
|
|
348 |
$select = $this->sql->select(self::_TABLE);
|
|
|
349 |
$select->columns(['total' => new Expression('COUNT(*)')]);
|
|
|
350 |
$select->where->equalTo('user_id', $user_id);
|
|
|
351 |
$select->where->equalTo('capsule_id', $capsule_id);
|
|
|
352 |
$select->where->equalTo('type', CompanyMicrolearningUserProgress::TYPE_SLIDE);
|
|
|
353 |
$select->where->equalTo('completed', 1);
|
|
|
354 |
$select->limit(1);
|
|
|
355 |
|
|
|
356 |
//echo $select->getSqlString($this->adapter->platform);
|
|
|
357 |
|
|
|
358 |
$record = $this->executeFetchOneArray($select);
|
|
|
359 |
return $record['total'];
|
|
|
360 |
}
|
|
|
361 |
|
|
|
362 |
/**
|
|
|
363 |
*
|
|
|
364 |
* @param int $user_id
|
|
|
365 |
* @param int $capsule_id
|
|
|
366 |
* @return int
|
|
|
367 |
*/
|
|
|
368 |
public function fetchCountAllSlideCompletedByUserIdAndTopicId($user_id, $topic_id)
|
|
|
369 |
{
|
|
|
370 |
|
|
|
371 |
$select = $this->sql->select(self::_TABLE);
|
|
|
372 |
$select->columns(['total' => new Expression('COUNT(*)')]);
|
|
|
373 |
$select->where->equalTo('user_id', $user_id);
|
|
|
374 |
$select->where->equalTo('topic_id', $topic_id);
|
|
|
375 |
$select->where->equalTo('type', CompanyMicrolearningUserProgress::TYPE_SLIDE);
|
|
|
376 |
$select->where->equalTo('completed', 1);
|
|
|
377 |
$select->limit(1);
|
|
|
378 |
|
|
|
379 |
echo $select->getSqlString($this->adapter->platform) . PHP_EOL;
|
|
|
380 |
|
|
|
381 |
$record = $this->executeFetchOneArray($select);
|
|
|
382 |
return $record['total'];
|
|
|
383 |
}
|
|
|
384 |
|
|
|
385 |
/**
|
|
|
386 |
*
|
|
|
387 |
* @param int $company_id
|
|
|
388 |
* @param int $user_id
|
|
|
389 |
* @return int
|
|
|
390 |
*/
|
|
|
391 |
public function fetchCountAllSlideCompletedByCompanyIdAndUserId($company_id, $user_id)
|
|
|
392 |
{
|
|
|
393 |
|
|
|
394 |
$select = $this->sql->select(self::_TABLE);
|
|
|
395 |
$select->columns(['total' => new Expression('COUNT(*)')]);
|
|
|
396 |
$select->where->equalTo('company_id', $company_id);
|
|
|
397 |
$select->where->equalTo('user_id', $user_id);
|
|
|
398 |
$select->where->equalTo('type', CompanyMicrolearningUserProgress::TYPE_SLIDE);
|
|
|
399 |
$select->where->equalTo('completed', 1);
|
|
|
400 |
$select->limit(1);
|
|
|
401 |
|
|
|
402 |
$record = $this->executeFetchOneArray($select);
|
|
|
403 |
return $record['total'];
|
|
|
404 |
}
|
|
|
405 |
|
|
|
406 |
|
|
|
407 |
/**
|
|
|
408 |
*
|
|
|
409 |
* @param int $user_id
|
|
|
410 |
* @param int $topic_id
|
|
|
411 |
* @return int
|
|
|
412 |
*/
|
|
|
413 |
public function fetchCountAllSlideViewedByUserIdAndTopicId($user_id, $topic_id)
|
|
|
414 |
{
|
|
|
415 |
|
|
|
416 |
$select = $this->sql->select(self::_TABLE);
|
|
|
417 |
$select->columns(['total' => new Expression('COUNT(*)')]);
|
|
|
418 |
$select->where->equalTo('user_id', $user_id);
|
|
|
419 |
$select->where->equalTo('topic_id', $topic_id);
|
|
|
420 |
$select->where->equalTo('type', CompanyMicrolearningUserProgress::TYPE_SLIDE);
|
|
|
421 |
$select->limit(1);
|
|
|
422 |
|
|
|
423 |
$record = $this->executeFetchOneArray($select);
|
|
|
424 |
return $record['total'];
|
|
|
425 |
}
|
|
|
426 |
|
|
|
427 |
/**
|
|
|
428 |
*
|
|
|
429 |
* @param CompanyMicrolearningUserProgress $userProgress
|
|
|
430 |
* return boolean
|
|
|
431 |
*/
|
|
|
432 |
public function insert($userProgress)
|
|
|
433 |
{
|
|
|
434 |
$hydrator = new ObjectPropertyHydrator();
|
|
|
435 |
$values = $hydrator->extract($userProgress);
|
|
|
436 |
$values = $this->removeEmpty($values);
|
|
|
437 |
|
|
|
438 |
$values['added_on'] = $userProgress->added_on;
|
|
|
439 |
$values['updated_on'] = $userProgress->updated_on;
|
|
|
440 |
|
|
|
441 |
$insert = $this->sql->insert(self::_TABLE);
|
|
|
442 |
$insert->values($values);
|
|
|
443 |
|
|
|
444 |
//echo $insert->getSqlString($this->adapter->platform); exit;
|
|
|
445 |
|
|
|
446 |
$result = $this->executeInsert($insert);
|
|
|
447 |
if($result) {
|
|
|
448 |
$userProgress->id = $this->lastInsertId;
|
|
|
449 |
}
|
|
|
450 |
return $result;
|
|
|
451 |
}
|
|
|
452 |
|
|
|
453 |
|
|
|
454 |
/**
|
|
|
455 |
*
|
|
|
456 |
* @param CompanyMicrolearningUserProgress $userProgress
|
|
|
457 |
* return boolean
|
|
|
458 |
*/
|
|
|
459 |
public function update($userProgress)
|
|
|
460 |
{
|
|
|
461 |
$hydrator = new ObjectPropertyHydrator();
|
|
|
462 |
$values = $hydrator->extract($userProgress);
|
|
|
463 |
$values = $this->removeEmpty($values);
|
|
|
464 |
|
|
|
465 |
|
|
|
466 |
$values['added_on'] = $userProgress->added_on;
|
|
|
467 |
$values['updated_on'] = $userProgress->updated_on;
|
|
|
468 |
|
|
|
469 |
|
|
|
470 |
$update = $this->sql->update(self::_TABLE);
|
|
|
471 |
$update->set($values);
|
|
|
472 |
$update->where->equalTo('id', $userProgress->id);
|
|
|
473 |
|
|
|
474 |
//echo $update->getSqlString($this->adapter->platform) . PHP_EOL;
|
|
|
475 |
|
|
|
476 |
return $this->executeUpdate($update);
|
|
|
477 |
}
|
|
|
478 |
|
|
|
479 |
|
|
|
480 |
/**
|
|
|
481 |
*
|
|
|
482 |
* @param int $userId
|
|
|
483 |
* @return int
|
|
|
484 |
*/
|
|
|
485 |
public function getCountCapsulesCompletedByUserId($userId)
|
|
|
486 |
{
|
|
|
487 |
$select = $this->sql->select(self::_TABLE);
|
|
|
488 |
$select->columns(['total' => new Expression('COUNT(*)')] );
|
|
|
489 |
$select->where->equalTo('type', CompanyMicrolearningUserProgress::TYPE_CAPSULE);
|
|
|
490 |
$select->where->equalTo('user_id', $userId);
|
|
|
491 |
$select->where->equalTo('completed', 1);
|
|
|
492 |
|
|
|
493 |
$record = $this->executeFetchOneArray($select);
|
|
|
494 |
|
|
|
495 |
return $record['total'];
|
|
|
496 |
|
|
|
497 |
}
|
|
|
498 |
|
146 |
efrain |
499 |
|
|
|
500 |
|
1 |
efrain |
501 |
|
|
|
502 |
|
146 |
efrain |
503 |
|
|
|
504 |
|
1 |
efrain |
505 |
}
|