Proyectos de Subversion LeadersLinked - Services

Rev

Rev 652 | Rev 654 | Ir a la última revisión | | Comparar con el anterior | Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
283 www 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\MicrolearningUserProgress;
9
use LeadersLinked\Hydrator\ObjectPropertyHydrator;
10
use Laminas\Db\Sql\Expression;
590 stevensc 11
use LeadersLinked\Mapper\MicrolearningSlideMapper;
12
use LeadersLinked\Mapper\MicrolearningTopicCapsuleMapper;
283 www 13
 
14
class MicrolearningUserProgressMapper extends MapperCommon
15
{
16
    const _TABLE = 'tbl_microlearning_user_progress';
17
 
18
    /**
19
     *
20
     * @var MicrolearningUserProgressMapper
21
     */
22
    private static $_instance;
23
 
24
    /**
25
     *
26
     * @param AdapterInterface $adapter
27
     */
28
    private function __construct($adapter)
29
    {
30
        parent::__construct($adapter);
31
    }
32
 
33
    /**
34
     *
35
     * @param AdapterInterface $adapter
36
     * @return MicrolearningUserProgressMapper
37
     */
38
    public static function getInstance($adapter)
39
    {
40
        if(self::$_instance == null) {
41
            self::$_instance = new MicrolearningUserProgressMapper($adapter);
42
        }
43
        return self::$_instance;
44
    }
45
 
46
    /**
47
     *
48
     * @param int $user_id
49
     * @return MicrolearningUserProgress[]
50
     */
51
    public function fetchAllByUserId($user_id)
52
    {
53
        $prototype = new MicrolearningUserProgress();
54
 
55
        $select = $this->sql->select(self::_TABLE);
56
        $select->where->equalTo('user_id', $user_id);
57
 
58
        return $this->executeFetchAllObject($select, $prototype);
59
    }
60
 
61
    /**
62
     *
63
     * @return int[]
64
     */
65
    public function fetchAllDistinctUserIds()
66
    {
67
        $user_ids = [];
68
 
69
        $select = $this->sql->select(self::_TABLE);
70
        $select->columns(['user_id' => new Expression('DISTINCT(user_id)')]);
71
 
72
        $records = $this->executeFetchAllArray($select);
73
        foreach ($records as $record)
74
        {
75
            array_push($user_ids, $record['user_id']);
76
        }
77
 
78
        return $user_ids;
79
 
80
    }
81
 
82
 
83
 
84
 
85
 
86
    /**
87
     *
88
     * @return MicrolearningUserProgress[]
89
     */
90
    public function fetchAllTopics()
91
    {
92
        $prototype = new MicrolearningUserProgress();
93
 
94
        $select = $this->sql->select(self::_TABLE);
95
        $select->where->equalTo('type', MicrolearningUserProgress::TYPE_TOPIC);
96
 
97
        //echo $select->getSqlString($this->adapter->platform); exit;
98
 
99
        return $this->executeFetchAllObject($select, $prototype);
100
    }
101
 
102
 
103
    /**
104
     *
105
     * @return MicrolearningUserProgress[]
106
     */
107
    public function fetchAllCapsules()
108
    {
109
        $prototype = new MicrolearningUserProgress();
110
 
111
        $select = $this->sql->select(self::_TABLE);
112
        $select->where->equalTo('type', MicrolearningUserProgress::TYPE_CAPSULE);
113
 
114
        return $this->executeFetchAllObject($select, $prototype);
115
    }
116
 
117
 
118
    /**
119
     *
120
     * @param int $user_id
121
     * @param int $slide_id
122
     * @return MicrolearningUserProgress
123
     */
124
    public function fetchOneByUserIdAndSlideId($user_id, $slide_id)
125
    {
126
        $prototype = new MicrolearningUserProgress();
127
 
128
        $select = $this->sql->select(self::_TABLE);
129
        $select->where->equalTo('user_id', $user_id);
130
        $select->where->equalTo('slide_id', $slide_id);
131
        $select->where->equalTo('type', MicrolearningUserProgress::TYPE_SLIDE);
132
 
133
        $select->limit(1);
134
 
135
        return $this->executeFetchOneObject($select, $prototype);
136
    }
590 stevensc 137
 
138
    /**
139
     * Fetch all progress data by user id and slide id
140
     * @param int $userId
141
     * @param int $slideId
142
     * @return MicrolearningUserProgress[]
143
     */
144
    public function fetchAllProgressDataByUserIdAndSlideId($userId, $slideId)
145
    {
146
        $select = $this->sql->select();
147
        $select->from(self::_TABLE);
148
        $select->where->equalTo('user_id', $userId);
149
        $select->where->equalTo('slide_id', $slideId);
150
    }
283 www 151
 
152
    /**
153
     *
154
     * @param int $user_id
155
     * @param int[] $capsule_ids
156
     * @return MicrolearningUserProgress
157
     */
158
    public function fetchOneLastCapsuleInProgressByUserIdAndCapsuleIds($user_id, $capsule_ids)
159
    {
160
        $capsule_ids = empty($capsule_ids) ? [0] : $capsule_ids;
161
 
162
        $prototype = new MicrolearningUserProgress();
163
 
164
        $select = $this->sql->select(self::_TABLE);
165
        $select->where->equalTo('user_id', $user_id);
166
        $select->where->in('capsule_id', $capsule_ids);
167
        $select->where->greaterThan('progress', 0);
168
        $select->where->lessThan('progress', 100);
169
        $select->where->equalTo('type', MicrolearningUserProgress::TYPE_CAPSULE);
170
        $select->order('updated_on');
171
        $select->limit(1);
172
 
173
 
174
        //echo $select->getSqlString($this->adapter->platform);
175
 
176
        return $this->executeFetchOneObject($select, $prototype);
177
    }
636 stevensc 178
 
179
    public function fetchOneLastCapsuleInProgressByUserIdAndTopicIds($user_id, $topic_ids)
180
    {
181
        $prototype = new MicrolearningUserProgress();
182
        $select = $this->sql->select(self::_TABLE);
183
        $select->where->equalTo('user_id', $user_id);
184
        $select->where->in('topic_id', $topic_ids);
185
        $select->where->equalTo('type', MicrolearningUserProgress::TYPE_CAPSULE);
186
        $select->where->greaterThan('progress', 0);
187
        $select->where->lessThan('progress', 100);
188
        $select->order('updated_on');
189
        $select->limit(1);
190
 
191
        return $this->executeFetchOneObject($select, $prototype);
192
    }
283 www 193
 
194
    /**
195
     *
196
     * @param int $user_id
197
     * @param int $capsule_id
198
     * @return MicrolearningUserProgress
199
     */
200
    public function fetchOneByUseridAndCapsuleId($user_id, $capsule_id)
201
    {
202
        $prototype = new MicrolearningUserProgress();
203
 
204
        $select = $this->sql->select(self::_TABLE);
205
        $select->where->equalTo('user_id', $user_id);
206
        $select->where->equalTo('capsule_id', $capsule_id);
207
        $select->where->equalTo('type', MicrolearningUserProgress::TYPE_CAPSULE);
208
        $select->limit(1);
209
 
210
 
211
        //echo $select->getSqlString($this->adapter->platform);
212
 
213
        return $this->executeFetchOneObject($select, $prototype);
214
    }
215
 
216
    /**
217
     *
218
     * @param int $user_id
219
     * @param int $topic_id
220
     * @return MicrolearningUserProgress
221
     */
222
    public function fetchOneByUserIdAndTopicId($user_id, $topic_id)
223
    {
224
        $prototype = new MicrolearningUserProgress();
225
 
226
        $select = $this->sql->select(self::_TABLE);
227
        $select->where->equalTo('user_id', $user_id);
228
        $select->where->equalTo('topic_id', $topic_id);
229
        $select->where->equalTo('type', MicrolearningUserProgress::TYPE_TOPIC);
230
        $select->limit(1);
231
 
232
        return $this->executeFetchOneObject($select, $prototype);
233
    }
234
 
235
 
236
    /**
237
     *
238
     * @param int $user_id
239
     * @param int $topic_id
240
     * @return int
241
     */
242
    public function  fetchCountCapsulesStartedByIdAndTopicId($user_id, $topic_id)
243
    {
244
        $select = $this->sql->select(self::_TABLE);
245
        $select->columns(['total' => new Expression('COUNT(*)')]);
246
        $select->where->equalTo('user_id', $user_id);
247
        $select->where->equalTo('topic_id', $topic_id);
248
        $select->where->equalTo('type', MicrolearningUserProgress::TYPE_CAPSULE);
249
        $select->where->greaterThan('progress', 0);
250
        $select->where->lessThan('progress', 100);
251
        $select->where->equalTo('completed', 0);
252
        $select->limit(1);
253
 
254
        $record = $this->executeFetchOneArray($select);
255
        return $record['total'];
256
    }
257
 
258
 
259
    /**
260
     *
261
     * @param int $user_id
262
     * @param int $topic_id
263
     * @return int
264
     */
265
    public function  fetchCountCapsulesCompletedByIdAndTopicId($user_id, $topic_id)
266
    {
267
        $select = $this->sql->select(self::_TABLE);
268
        $select->columns(['total' => new Expression('COUNT(*)')]);
269
        $select->where->equalTo('user_id', $user_id);
270
        $select->where->equalTo('topic_id', $topic_id);
271
        $select->where->equalTo('type', MicrolearningUserProgress::TYPE_CAPSULE);
272
        $select->where->equalTo('completed', 1);
273
        $select->limit(1);
274
 
275
        $record = $this->executeFetchOneArray($select);
276
        return $record['total'];
277
    }
278
 
279
 
280
 
281
 
282
    /**
283
     *
284
     * @param int $user_id
285
     * @param int $topic_id
286
     * @return int
287
     */
288
    public function fetchCountCapsulesCompletedWithReturningByIdAndTopicId($user_id, $topic_id)
289
    {
290
        $select = $this->sql->select(self::_TABLE);
291
        $select->columns(['total' => new Expression('COUNT(*)')]);
292
        $select->where->equalTo('user_id', $user_id);
293
        $select->where->equalTo('topic_id', $topic_id);
294
        $select->where->equalTo('type', MicrolearningUserProgress::TYPE_CAPSULE);
295
        $select->where->equalTo('completed', 1);
296
        $select->where->notEqualTo('returning_after_completed', 0);
297
        $select->limit(1);
298
 
299
        $record = $this->executeFetchOneArray($select);
300
        return $record['total'];
301
    }
302
 
303
    /**
304
     *
305
     * @param int $user_id
306
     * @param int $topic_id
307
     * @return int
308
     */
309
    public function fetchCountCapsulesCompletedWithoutReturningByIdAndTopicId($user_id, $topic_id)
310
    {
311
        $select = $this->sql->select(self::_TABLE);
312
        $select->columns(['total' => new Expression('COUNT(*)')]);
313
        $select->where->equalTo('user_id', $user_id);
314
        $select->where->equalTo('topic_id', $topic_id);
315
        $select->where->equalTo('type', MicrolearningUserProgress::TYPE_CAPSULE);
316
        $select->where->equalTo('completed', 1);
317
        $select->where->equalTo('returning_after_completed', 0);
318
        $select->limit(1);
319
 
320
        $record = $this->executeFetchOneArray($select);
321
        return $record['total'];
322
    }
323
 
324
 
325
    /**
326
     *
327
     * @param int $user_id
328
     * @param int $capsule_id
329
     * @return int
330
     */
331
    public function fetchCountAllSlideViewedByUserIdAndCapsuleId($user_id, $capsule_id)
332
    {
333
 
334
        $select = $this->sql->select(self::_TABLE);
335
        $select->columns(['total' => new Expression('COUNT(*)')]);
336
        $select->where->equalTo('user_id', $user_id);
337
        $select->where->equalTo('capsule_id', $capsule_id);
338
        $select->where->equalTo('type', MicrolearningUserProgress::TYPE_SLIDE);
339
        $select->limit(1);
340
 
341
        $record = $this->executeFetchOneArray($select);
342
        return $record['total'];
343
    }
344
 
345
    /**
346
     *
347
     * @param int $user_id
348
     * @param int $topic_id
349
     * @param int $capsule_id
350
     * @return int
351
     */
352
    public function fetchCountAllSlideCompletedByUserIdAndTopicIdAndCapsuleId($user_id, $topic_id, $capsule_id)
353
    {
354
 
355
        $select = $this->sql->select(self::_TABLE);
356
        $select->columns(['total' => new Expression('COUNT(*)')]);
357
        $select->where->equalTo('user_id', $user_id);
358
        $select->where->equalTo('topic_id', $topic_id);
359
        $select->where->equalTo('capsule_id', $capsule_id);
360
        $select->where->equalTo('type', MicrolearningUserProgress::TYPE_SLIDE);
361
        $select->where->equalTo('completed', 1);
362
        $select->limit(1);
363
 
364
        $record = $this->executeFetchOneArray($select);
365
        return $record['total'];
366
    }
367
 
368
 
369
    /**
370
     *
371
     * @param int $user_id
372
     * @param int $capsule_id
373
     * @return int
374
     */
375
    public function fetchCountAllSlideCompletedByUserIdAndCapsuleId($user_id, $capsule_id)
376
    {
377
 
378
        $select = $this->sql->select(self::_TABLE);
379
        $select->columns(['total' => new Expression('COUNT(*)')]);
380
        $select->where->equalTo('user_id', $user_id);
381
        $select->where->equalTo('capsule_id', $capsule_id);
382
        $select->where->equalTo('type', MicrolearningUserProgress::TYPE_SLIDE);
383
        $select->where->equalTo('completed', 1);
384
        $select->limit(1);
385
 
386
        //echo $select->getSqlString($this->adapter->platform);
387
 
388
        $record = $this->executeFetchOneArray($select);
389
        return $record['total'];
390
    }
391
 
392
    /**
393
     *
394
     * @param int $user_id
395
     * @param int $capsule_id
396
     * @return int
397
     */
398
    public function fetchCountAllSlideCompletedByUserIdAndTopicId($user_id, $topic_id)
399
    {
400
 
401
        $select = $this->sql->select(self::_TABLE);
402
        $select->columns(['total' => new Expression('COUNT(*)')]);
403
        $select->where->equalTo('user_id', $user_id);
404
        $select->where->equalTo('topic_id', $topic_id);
405
        $select->where->equalTo('type', MicrolearningUserProgress::TYPE_SLIDE);
406
        $select->where->equalTo('completed', 1);
407
        $select->limit(1);
408
 
409
       // echo $select->getSqlString($this->adapter->platform) . PHP_EOL;
410
 
411
        $record = $this->executeFetchOneArray($select);
412
        return $record['total'];
413
    }
414
 
415
    /**
416
     *
417
     * @param int $company_id
418
     * @param int $user_id
419
     * @return int
420
     */
421
    public function fetchCountAllSlideCompletedByCompanyIdAndUserId($company_id, $user_id)
422
    {
423
 
424
        $select = $this->sql->select(self::_TABLE);
425
        $select->columns(['total' => new Expression('COUNT(*)')]);
426
        $select->where->equalTo('company_id', $company_id);
427
        $select->where->equalTo('user_id', $user_id);
428
        $select->where->equalTo('type', MicrolearningUserProgress::TYPE_SLIDE);
429
        $select->where->equalTo('completed', 1);
430
        $select->limit(1);
431
 
432
        $record = $this->executeFetchOneArray($select);
433
        return $record['total'];
434
    }
435
 
436
 
437
    /**
438
     *
439
     * @param int $user_id
440
     * @param int $topic_id
441
     * @return int
442
     */
443
    public function fetchCountAllSlideViewedByUserIdAndTopicId($user_id, $topic_id)
444
    {
445
 
446
        $select = $this->sql->select(self::_TABLE);
447
        $select->columns(['total' => new Expression('COUNT(*)')]);
448
        $select->where->equalTo('user_id', $user_id);
449
        $select->where->equalTo('topic_id', $topic_id);
450
        $select->where->equalTo('type', MicrolearningUserProgress::TYPE_SLIDE);
451
        $select->limit(1);
452
 
453
        $record = $this->executeFetchOneArray($select);
454
        return $record['total'];
455
    }
456
 
457
    /**
458
     *
459
     * @param MicrolearningUserProgress $userProgress
460
     * return boolean
461
     */
462
    public function insert($userProgress)
463
    {
464
        $hydrator = new ObjectPropertyHydrator();
465
        $values = $hydrator->extract($userProgress);
466
        $values = $this->removeEmpty($values);
467
 
468
        $values['added_on'] = $userProgress->added_on;
469
        $values['updated_on'] = $userProgress->updated_on;
470
 
471
        $insert = $this->sql->insert(self::_TABLE);
472
        $insert->values($values);
473
 
474
        //echo $insert->getSqlString($this->adapter->platform); exit;
475
 
476
        $result = $this->executeInsert($insert);
477
        if($result) {
478
            $userProgress->id = $this->lastInsertId;
479
        }
480
        return $result;
481
    }
482
 
483
 
484
    /**
485
     *
486
     * @param MicrolearningUserProgress $userProgress
487
     * return boolean
488
     */
489
    public function update($userProgress)
490
    {
491
        $hydrator = new ObjectPropertyHydrator();
492
        $values = $hydrator->extract($userProgress);
493
        $values = $this->removeEmpty($values);
494
 
495
 
496
        $values['added_on'] = $userProgress->added_on;
497
        $values['updated_on'] = $userProgress->updated_on;
498
 
499
 
500
        $update = $this->sql->update(self::_TABLE);
501
        $update->set($values);
502
        $update->where->equalTo('id', $userProgress->id);
503
 
504
        //echo $update->getSqlString($this->adapter->platform) . PHP_EOL;
505
 
506
        return $this->executeUpdate($update);
507
    }
626 stevensc 508
 
509
    /**
510
     * Delete all user progress by topic id
511
     * @param int $topic_id
512
     * @return int
513
     */
514
    public function deleteAllTopicProgressByTopicId($topic_id)
515
    {
516
        $delete = $this->sql->delete(self::_TABLE);
517
        $delete->where->equalTo('topic_id', $topic_id);
518
        $delete->where->equalTo('type', MicrolearningUserProgress::TYPE_TOPIC);
519
        return $this->executeDelete($delete);
520
    }
632 stevensc 521
 
522
    /**
523
     * Deletes all user progress by capsule id
524
     * @param int $capsule_id
525
     * @return int
526
     */
527
    public function deleteAllByCapsuleId($capsule_id)
528
    {
529
        $delete = $this->sql->delete(self::_TABLE);
530
        $delete->where->equalTo('capsule_id', $capsule_id);
531
        $delete->where->equalTo('type', MicrolearningUserProgress::TYPE_SLIDE);
532
        $delete->where->equalTo('type', MicrolearningUserProgress::TYPE_CAPSULE);
533
        return $this->executeDelete($delete);
534
    }
283 www 535
 
536
 
537
    /**
538
     *
539
     * @param int $userId
540
     * @return int
541
     */
542
    public function getCountCapsulesCompletedByUserId($userId)
543
    {
544
        $select = $this->sql->select(self::_TABLE);
545
        $select->columns(['total' => new Expression('COUNT(*)')] );
546
        $select->where->equalTo('type', MicrolearningUserProgress::TYPE_CAPSULE);
547
        $select->where->equalTo('user_id', $userId);
548
        $select->where->equalTo('completed', 1);
549
 
550
        $record = $this->executeFetchOneArray($select);
551
 
552
        return $record['total'];
553
 
554
    }
555
 
590 stevensc 556
    public function markSlideViewed($user_id, $topic_id, $capsule_id, $slide_id)
557
    {
558
        // Verifica si ya existe el registro
559
        $exists = $this->fetchOneByUserIdAndSlideId($user_id, $slide_id);
560
        if ($exists) {
561
            return; // ya registrado
562
        }
283 www 563
 
652 stevensc 564
        $now = $this->getDatebaseNow();
565
        $userProgress = new \LeadersLinked\Model\MicrolearningUserProgress();
566
        $userProgress->user_id = $user_id;
567
        $userProgress->topic_id = $topic_id;
568
        $userProgress->capsule_id = $capsule_id;
569
        $userProgress->slide_id = $slide_id;
570
        $userProgress->type = MicrolearningUserProgress::TYPE_SLIDE;
571
        $userProgress->progress = 100;
572
        $userProgress->completed = 1;
573
        $userProgress->returning = 0;
574
        $userProgress->returning_after_completed = 0; // Regr
575
        $userProgress->total_slides = 0;
576
        $userProgress->view_slides = 0;
577
        $userProgress->added_on = $now;
578
        $userProgress->updated_on = $now;
579
 
580
        return $this->insert($userProgress);
590 stevensc 581
    }
582
 
583
    public function markCapsuleCompleted($user_id, $topic_id, $capsule_id)
584
    {
585
        // Verifica si ya existe algún progreso de cápsula
652 stevensc 586
        $exists = $this->fetchOneByUseridAndCapsuleId($user_id, $capsule_id);
590 stevensc 587
        if ($exists) {
588
            return; // ya registrado
589
        }
590
 
652 stevensc 591
        $now = $this->getDatebaseNow();
592
        $userProgress = new \LeadersLinked\Model\MicrolearningUserProgress();
593
        $userProgress->user_id = $user_id;
594
        $userProgress->topic_id = $topic_id;
595
        $userProgress->capsule_id = $capsule_id;
596
        $userProgress->type = \LeadersLinked\Model\MicrolearningUserProgress::TYPE_CAPSULE;
597
        $userProgress->progress = 100;
598
        $userProgress->completed = 1;
599
        $userProgress->returning = 0;
600
        $userProgress->returning_after_completed = 0;
601
        $userProgress->total_slides = 0;
602
        $userProgress->view_slides = 0;
603
        $userProgress->added_on = $now;
604
        $userProgress->updated_on = $now;
605
 
606
        return $this->insert($userProgress);
590 stevensc 607
    }
608
 
609
    public function markTopicCompleted($user_id, $topic_id)
610
    {
611
        // Verifica si ya existe algún progreso de topic
612
        $exists = $this->fetchOneByUserIdAndTopicId($user_id, $topic_id);
613
        if ($exists) {
614
            return; // ya registrado
615
        }
616
 
652 stevensc 617
        $now = $this->getDatebaseNow();
618
        $userProgress = new \LeadersLinked\Model\MicrolearningUserProgress();
619
        $userProgress->user_id = $user_id;
620
        $userProgress->topic_id = $topic_id;
621
        $userProgress->type = \LeadersLinked\Model\MicrolearningUserProgress::TYPE_TOPIC;
622
        $userProgress->progress = 100;
623
        $userProgress->completed = 1;
624
        $userProgress->returning = 0;
625
        $userProgress->returning_after_completed = 0;
626
        $userProgress->total_slides = 0;
627
        $userProgress->view_slides = 0;
628
        $userProgress->added_on = $now;
629
        $userProgress->updated_on = $now;
630
 
631
        return $this->insert($userProgress);
590 stevensc 632
    }
633
 
634
    public function hasViewedAllSlidesInCapsule($user_id, $capsule_id)
635
    {
636
        $slideMapper = MicrolearningSlideMapper::getInstance($this->adapter);
637
        $allSlides = $slideMapper->fetchAllByCapsuleId($capsule_id);
653 stevensc 638
        $totalSlides = count($allSlides);
590 stevensc 639
 
653 stevensc 640
        if ($totalSlides === 0) {
641
            return false;
642
        }
643
 
590 stevensc 644
        $select = $this->sql->select(self::_TABLE);
653 stevensc 645
        $select->columns(['total' => new Expression('COUNT(*)')]);
590 stevensc 646
        $select->where->equalTo('user_id', $user_id);
647
        $select->where->equalTo('capsule_id', $capsule_id);
648
        $select->where->equalTo('type', MicrolearningUserProgress::TYPE_SLIDE);
653 stevensc 649
        $select->where->equalTo('completed', 1);
590 stevensc 650
 
651
        $record = $this->executeFetchOneArray($select);
653 stevensc 652
        $viewedSlides = (int)$record['total'];
653
 
654
        return $viewedSlides >= $totalSlides;
590 stevensc 655
    }
656
 
657
    public function hasCompletedAllCapsulesInTopic($user_id, $topic_id)
658
    {
659
        $capsuleMapper = MicrolearningTopicCapsuleMapper::getInstance($this->adapter);
660
        $allCapsules = $capsuleMapper->fetchAllByTopicId($topic_id);
661
 
662
        $select = $this->sql->select(self::_TABLE);
663
        $select->where->equalTo('user_id', $user_id);
664
        $select->where->equalTo('topic_id', $topic_id);
665
        $select->where->equalTo('type', MicrolearningUserProgress::TYPE_CAPSULE);
666
        $select->where->equalTo('completed', 1);
667
 
668
        $record = $this->executeFetchOneArray($select);
669
        return count($record) >= count($allCapsules);
670
    }
671
 
283 www 672
}