Proyectos de Subversion LeadersLinked - Services

Rev

Rev 1 | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 1 Rev 119
Línea 135... Línea 135...
135
    }
135
    }
Línea 136... Línea 136...
136
    
136
    
137
    /**
137
    /**
138
     *
138
     *
-
 
139
     * @param int $user_id
-
 
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
     *
139
     * @param int $user_id
166
     * @param int $user_id
140
     * @param int $capsule_id
167
     * @param int $capsule_id
141
     * @return CompanyMicrolearningUserProgress
168
     * @return CompanyMicrolearningUserProgress
142
     */
169
     */
143
    public function fetchOneByUseridAndCapsuleId($user_id, $capsule_id)
170
    public function fetchOneByUseridAndCapsuleId($user_id, $capsule_id)
Línea 176... Línea 203...
176
    }
203
    }
Línea 177... Línea 204...
177
    
204
    
178
    
205
    
-
 
206
    /**
-
 
207
     *
-
 
208
     * @param int $user_id
-
 
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
    
-
 
250
    /**
-
 
251
     *
-
 
252
     * @param int $user_id
-
 
253
     * @param int $topic_id
-
 
254
     * @return int
-
 
255
     */
-
 
256
    public function fetchCountCapsulesCompletedWithReturningByIdAndTopicId($user_id, $topic_id)
-
 
257
    {
-
 
258
        $select = $this->sql->select(self::_TABLE);
-
 
259
        $select->columns(['total' => new Expression('COUNT(*)')]);
-
 
260
        $select->where->equalTo('user_id', $user_id);
-
 
261
        $select->where->equalTo('topic_id', $topic_id);
-
 
262
        $select->where->equalTo('type', CompanyMicrolearningUserProgress::TYPE_CAPSULE);
-
 
263
        $select->where->equalTo('completed', 1);
-
 
264
        $select->where->notEqualTo('returning_after_completed', 0);
-
 
265
        $select->limit(1);
-
 
266
        
-
 
267
        $record = $this->executeFetchOneArray($select);
-
 
268
        return $record['total'];
-
 
269
    }
-
 
270
    
-
 
271
    /**
-
 
272
     *
-
 
273
     * @param int $user_id
-
 
274
     * @param int $topic_id
-
 
275
     * @return int
-
 
276
     */
-
 
277
    public function fetchCountCapsulesCompletedWithoutReturningByIdAndTopicId($user_id, $topic_id)
-
 
278
    {
-
 
279
        $select = $this->sql->select(self::_TABLE);
-
 
280
        $select->columns(['total' => new Expression('COUNT(*)')]);
-
 
281
        $select->where->equalTo('user_id', $user_id);
-
 
282
        $select->where->equalTo('topic_id', $topic_id);
-
 
283
        $select->where->equalTo('type', CompanyMicrolearningUserProgress::TYPE_CAPSULE);
-
 
284
        $select->where->equalTo('completed', 1);
-
 
285
        $select->where->equalTo('returning_after_completed', 0);
-
 
286
        $select->limit(1);
-
 
287
        
-
 
288
        $record = $this->executeFetchOneArray($select);
-
 
289
        return $record['total'];
-
 
290
    }
-
 
291
    
-
 
292
    
179
    /**
293
    /**
180
     *
294
     *
181
     * @param int $user_id
295
     * @param int $user_id
182
     * @param int $capsule_id
296
     * @param int $capsule_id
183
     * @return int
297
     * @return int