Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

Rev 1 | Rev 18 | Ir a la última revisión | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 1 Rev 16
Línea 2053... Línea 2053...
2053
            $result_sync_ids = [];
2053
            $result_sync_ids = [];
Línea -... Línea 2054...
-
 
2054
            
-
 
2055
            
-
 
2056
          
-
 
2057
            
-
 
2058
            $users = [];
-
 
2059
            $companies = [];
-
 
2060
            $company_services = [];
-
 
2061
            $topics = [];
-
 
2062
            $capsules = [];
-
 
2063
            $capsule_users = [];
-
 
2064
            $slides = [];
-
 
2065
            $quizzes = [];
-
 
2066
            $questions = [];
-
 
2067
            $answers = [];
-
 
2068
            
-
 
2069
            $userMapper = UserMapper::getInstance($this->adapter);
-
 
2070
            $companyMapper = CompanyMapper::getInstance($this->adapter);
-
 
2071
            $companyServiceMapper = CompanyServiceMapper::getInstance($this->adapter);
-
 
2072
            $topicMapper = CompanyMicrolearningTopicMapper::getInstance($this->adapter);
-
 
2073
            $capsuleMapper = CompanyMicrolearningCapsuleMapper::getInstance($this->adapter);
-
 
2074
            $capsuleUserMapper = CompanyMicrolearningCapsuleUserMapper::getInstance($this->adapter);
-
 
2075
            $slideMapper = CompanyMicrolearningSlideMapper::getInstance($this->adapter);
-
 
2076
            $quizMapper = CompanyMicrolearningQuizMapper::getInstance($this->adapter);
-
 
2077
            $questionMapper = CompanyMicrolearningQuestionMapper::getInstance($this->adapter);
-
 
2078
            $answerMapper = CompanyMicrolearningAnswerMapper::getInstance($this->adapter);
-
 
2079
            
2054
            
2080
            
2055
            
2081
            $userProgressMapper = CompanyMicrolearningUserProgressMapper::getInstance($this->adapter);
2056
          
2082
            $userLogMapper = CompanyMicrolearningUserLogMapper::getInstance($this->adapter);
2057
            
2083
            
Línea 2074... Línea 2100...
2074
                }
2100
                }
Línea 2075... Línea 2101...
2075
                
2101
                
Línea 2076... Línea 2102...
2076
                /***** INICIO MICROLEARNING *****/
2102
                /***** INICIO MICROLEARNING *****/
2077
                
-
 
2078
                if($user_uuid && $device->application_id = Application::TWOGETSKILLS  && $company_uuid && in_array($sync_type, ['microlearning-progress', 'microlearning-userlog', 'microlearning-quiz'])) {
-
 
Línea -... Línea 2103...
-
 
2103
                
-
 
2104
                if($user_uuid && $device->application_id = Application::TWOGETSKILLS  && $company_uuid && in_array($sync_type, ['microlearning-progress', 'microlearning-userlog', 'microlearning-quiz'])) {
-
 
2105
                    
-
 
2106
                    
-
 
2107
                    if(isset($users[$user_uuid])) {
-
 
2108
                        $user = $users[$user_uuid];
-
 
2109
                    } else {
-
 
2110
                       
-
 
2111
                        $user = $userMapper->fetchOneByUuid($user_uuid);
-
 
2112
                        if($user) {
-
 
2113
                            $users[$user_uuid] = $user;
-
 
2114
                        }
2079
                    $userMapper = UserMapper::getInstance($this->adapter);
2115
                    }
2080
                    $user = $userMapper->fetchOneByUuid($user_uuid);
2116
                    
2081
                    
2117
 
2082
                    if(!$user) {
2118
                    if(!$user) {
2083
                        array_push($result_sync_ids, [
2119
                        array_push($result_sync_ids, [
Línea 2098... Línea 2134...
2098
                            'fatal' => true
2134
                            'fatal' => true
2099
                        ]);
2135
                        ]);
2100
                        continue;
2136
                        continue;
2101
                    }
2137
                    }
Línea -... Línea 2138...
-
 
2138
                    
-
 
2139
                    
2102
                    
2140
                    if(isset($companies[$company_uuid])) {
-
 
2141
                        $company = $companies[$company_uuid];
2103
                    $companyMapper = CompanyMapper::getInstance($this->adapter);
2142
                    } else {
-
 
2143
                        $company = $companyMapper->fetchOneByUuid($company_uuid);
-
 
2144
                        if($company) {
-
 
2145
                            $companies[$company_uuid] = $company;
-
 
2146
                        }
-
 
2147
                    }
-
 
2148
                    
-
 
2149
                    
-
 
2150
                   
2104
                    $company = $companyMapper->fetchOneByUuid($company_uuid);
2151
                    
2105
                    if(!$company) {
2152
                    if(!$company) {
2106
                        array_push($result_sync_ids, [
2153
                        array_push($result_sync_ids, [
2107
                            'success' => false,
2154
                            'success' => false,
2108
                            'sync_id' => $sync_id,
2155
                            'sync_id' => $sync_id,
Línea 2122... Línea 2169...
2122
                        continue;
2169
                        continue;
2123
                    }
2170
                    }
Línea -... Línea 2171...
-
 
2171
                    
-
 
2172
                    
-
 
2173
                    
-
 
2174
                    $key = $company->id . '-' .  Service::MICRO_LEARNING;
-
 
2175
                    if(isset($company_services[$key])) {
-
 
2176
                        $companyService = $company_services[$key];
-
 
2177
                    } else {
-
 
2178
                        $companyService = $companyServiceMapper->fetchOneByCompanyIdAndServiceId($company->id, Service::MICRO_LEARNING);
-
 
2179
                        if($companyService) {
Línea 2124... Línea -...
2124
                    
-
 
2125
                    
-
 
2126
                    
-
 
2127
                    
2180
                            $company_services[$key] = $companyService;
2128
                    
2181
                        }
2129
                    $companyServiceMapper = CompanyServiceMapper::getInstance($this->adapter);
2182
                    }
2130
                    $companyService = $companyServiceMapper->fetchOneByCompanyIdAndServiceId($company->id, Service::MICRO_LEARNING);
2183
                    
2131
                    if(!$companyService) {
2184
                    if(!$companyService) {
Línea 2158... Línea 2211...
2158
                            'fatal' => true
2211
                            'fatal' => true
2159
                        ]);
2212
                        ]);
2160
                        continue;
2213
                        continue;
2161
                    }
2214
                    }
Línea 2162... Línea -...
2162
                    
-
 
-
 
2215
                    
2163
                    $topicMapper = CompanyMicrolearningTopicMapper::getInstance($this->adapter);
2216
                   
2164
                    $topic_uuid = isset($record['topic_uuid']) ? filter_var($record['topic_uuid'], FILTER_SANITIZE_STRING) :  '';
2217
                    $topic_uuid = isset($record['topic_uuid']) ? filter_var($record['topic_uuid'], FILTER_SANITIZE_STRING) :  '';
-
 
2218
                    if($topic_uuid) {
-
 
2219
                        
-
 
2220
                        if(isset($topics[$topic_uuid])) {
-
 
2221
                            $topic = $topics[$topic_uuid];
2165
                    if($topic_uuid) {
2222
                        } else {
-
 
2223
                            $topic = $topicMapper->fetchOneByUuid($topic_uuid);
-
 
2224
                            if($topic) {
-
 
2225
                                $topics[$topic_uuid] = $topic;
-
 
2226
                            }
Línea 2166... Línea 2227...
2166
                        $topic = $topicMapper->fetchOneByUuid($topic_uuid);
2227
                        }
2167
                        
2228
                        
2168
                        if(!$topic) {
2229
                        if(!$topic) {
2169
                            array_push($result_sync_ids, [
2230
                            array_push($result_sync_ids, [
Línea 2186... Línea 2247...
2186
                    } else {
2247
                    } else {
2187
                        $topic = null;
2248
                        $topic = null;
2188
                    }
2249
                    }
Línea 2189... Línea 2250...
2189
                    
2250
                    
2190
                    $capsule_uuid     = isset($record['capsule_uuid']) ? filter_var($record['capsule_uuid'], FILTER_SANITIZE_STRING) :  '';
-
 
-
 
2251
                    $capsule_uuid     = isset($record['capsule_uuid']) ? filter_var($record['capsule_uuid'], FILTER_SANITIZE_STRING) :  '';
2191
                    $capsuleMapper = CompanyMicrolearningCapsuleMapper::getInstance($this->adapter);
2252
                    
Línea -... Línea 2253...
-
 
2253
                    if($capsule_uuid) {
-
 
2254
                        
-
 
2255
                        if(isset($capsules[$capsule_uuid])) {
2192
                    if($capsule_uuid) {
2256
                            $capsule = $capsules[$capsule_uuid];
-
 
2257
                        } else {
-
 
2258
                            $capsule = $capsuleMapper->fetchOneByUuid($capsule_uuid);
-
 
2259
                            if($capsule) {
-
 
2260
                                $capsules[$capsule_uuid] = $capsule;
2193
                        
2261
                            }
2194
                        $capsule = $capsuleMapper->fetchOneByUuid($capsule_uuid);
2262
                        }
2195
                        if(!$capsule) {
2263
                        if(!$capsule) {
2196
                            array_push($result_sync_ids, [
2264
                            array_push($result_sync_ids, [
2197
                                'success' => false,
2265
                                'success' => false,
Línea 2214... Línea 2282...
2214
                    }
2282
                    }
Línea 2215... Línea 2283...
2215
                    
2283
                    
Línea 2216... Línea 2284...
2216
                    if($capsule) {
2284
                    if($capsule) {
2217
                        
-
 
2218
                        $capsuleActive = true;
-
 
Línea -... Línea 2285...
-
 
2285
                        
-
 
2286
                        $capsuleActive = true;
-
 
2287
                        
-
 
2288
                        $key = $user->id . '-' . $capsule->id;
-
 
2289
                        
-
 
2290
                        if(isset($capsule_users[$key])) {
-
 
2291
                            $capsuleUser = $capsule_users[$key];
-
 
2292
                        } else {
-
 
2293
                        
-
 
2294
                            $capsuleUser = $capsuleUserMapper->fetchOneByUserIdAndCapsuleId($user->id, $capsule->id);
-
 
2295
                            if($capsuleUser) {
-
 
2296
                                $capsule_users[$key] = $capsuleUser;        
Línea 2219... Línea 2297...
2219
                        $capsuleMapper = CompanyMicrolearningCapsuleUserMapper::getInstance($this->adapter);
2297
                            }
2220
                        $capsuleUser = $capsuleMapper->fetchOneByUserIdAndCapsuleId($user->id, $capsule->id);
2298
                        
Línea 2243... Línea 2321...
2243
                            ]);
2321
                            ]);
2244
                            continue;
2322
                            continue;
2245
                        }
2323
                        }
2246
                    }
2324
                    }
Línea 2247... Línea -...
2247
                    
-
 
-
 
2325
                    
2248
                    $slideMapper = CompanyMicrolearningSlideMapper::getInstance($this->adapter);
2326
                    
2249
                    $slide_uuid      = isset($record['slide_uuid']) ? filter_var($record['slide_uuid'], FILTER_SANITIZE_STRING) :  '';
2327
                    $slide_uuid      = isset($record['slide_uuid']) ? filter_var($record['slide_uuid'], FILTER_SANITIZE_STRING) :  '';
-
 
2328
                    if($slide_uuid) {
-
 
2329
                        
-
 
2330
                        if(isset($slides[$slide_uuid])) {
-
 
2331
                            $slide = $slides[$slide_uuid];
-
 
2332
                        } else {
2250
                    if($slide_uuid) {
2333
                            
-
 
2334
                            $slide = $slideMapper->fetchOneByUuid($slide_uuid);
-
 
2335
                            if($slide) {
-
 
2336
                                $slides[$slide_uuid] = $slide;
-
 
2337
                            }
2251
                        $slide = $slideMapper->fetchOneByUuid($slide_uuid);
2338
                        }
2252
                        if(!$slide) {
2339
                        if(!$slide) {
2253
                            array_push($result_sync_ids, [
2340
                            array_push($result_sync_ids, [
2254
                                'success' => false,
2341
                                'success' => false,
2255
                                'sync_id' => $sync_id,
2342
                                'sync_id' => $sync_id,
Línea 2272... Línea 2359...
2272
                    
2359
                    
2273
                    if($sync_type == 'microlearning-quiz') {
2360
                    if($sync_type == 'microlearning-quiz') {
Línea 2274... Línea 2361...
2274
                        $ok = true;
2361
                        $ok = true;
2275
                        
-
 
2276
                        $quiz_uuid = isset($record['quiz_uuid']) ? $record['quiz_uuid'] : '';
2362
                        
-
 
2363
                        $quiz_uuid = isset($record['quiz_uuid']) ? $record['quiz_uuid'] : '';
-
 
2364
                       
-
 
2365
                        if(isset($quizzes[$quiz_uuid])) {
2277
                        $quizMapper = CompanyMicrolearningQuizMapper::getInstance($this->adapter);
2366
                            $quiz = $quizzes[$quiz_uuid];
-
 
2367
                        } else {
-
 
2368
                            $quiz = $quizMapper->fetchOneByUuid($quiz_uuid);
-
 
2369
                            if($quiz) {
-
 
2370
                                $quizzes[$quiz_uuid] = $quiz;
2278
                        
2371
                            }
2279
                        $quiz = $quizMapper->fetchOneByUuid($quiz_uuid);
2372
                        }
2280
                        if(!$quiz) {
2373
                        if(!$quiz) {
2281
                            array_push($result_sync_ids, [
2374
                            array_push($result_sync_ids, [
2282
                                'success' => false,
2375
                                'success' => false,
Línea 2332... Línea 2425...
2332
                            $question_uuid = isset($record["response_{$i}_question_uuid"]) ? $record["response_{$i}_question_uuid"] : '';
2425
                            $question_uuid = isset($record["response_{$i}_question_uuid"]) ? $record["response_{$i}_question_uuid"] : '';
2333
                            $answer_uuid = isset($record["response_{$i}_answer_uuid"]) ? $record["response_{$i}_answer_uuid"] : '';
2426
                            $answer_uuid = isset($record["response_{$i}_answer_uuid"]) ? $record["response_{$i}_answer_uuid"] : '';
2334
                            $value = isset($record["response_{$i}_value"]) ?  intval($record["response_{$i}_value"], 10) : 0;
2427
                            $value = isset($record["response_{$i}_value"]) ?  intval($record["response_{$i}_value"], 10) : 0;
2335
                            $points = isset($record["response_{$i}_points"]) ?  intval($record["response_{$i}_points"], 10) : 0;
2428
                            $points = isset($record["response_{$i}_points"]) ?  intval($record["response_{$i}_points"], 10) : 0;
Línea -... Línea 2429...
-
 
2429
                            
2336
                            
2430
                            
-
 
2431
                            if(isset($questions[$question_uuid])) {
2337
                            if($question_uuid && $answer_uuid)
2432
                                $question = $questions[$question_uuid];
-
 
2433
                            } else {
2338
                            {
2434
                                $question = $questionMapper->fetchOneByUuid($question_uuid);
2339
                                array_push($array_response, [
2435
                                if($question) {
-
 
2436
                                    $questions[$question_uuid] = $question;
-
 
2437
                                }
-
 
2438
                            }
-
 
2439
                            
2340
                                    'question_uuid' => $question_uuid,
2440
                            if(!$question || $question->quiz_id != $quiz->id) {
2341
                                    'answer_uuid' => $answer_uuid,
2441
                                array_push($result_sync_ids, [
2342
                                    'value' => $value,
2442
                                    'success' => false,
-
 
2443
                                    'sync_id' => $sync_id,
2343
                                    'points' => $points
2444
                                    'message' => 'ERROR_INVALID_PARAMETERS_QUIZ_QUESTION_SLIDE',
-
 
2445
                                ]);
2344
                                ]);
2446
                                continue;
-
 
2447
                            }
-
 
2448
                            
-
 
2449
                            if(isset($answers[$answer_uuid])) {
-
 
2450
                                $answer = $answers[$answer_uuid];
-
 
2451
                            } else {
-
 
2452
                                $answer = $answerMapper->fetchOneByUuid($answer_uuid);
-
 
2453
                                if($answer) {
-
 
2454
                                    $answers[$answer_uuid] = $answer;
-
 
2455
                                }
-
 
2456
                            }
-
 
2457
                            
-
 
2458
                            if($answer && $answer->question_id != $question->id) {
-
 
2459
                                array_push($result_sync_ids, [
-
 
2460
                                    'success' => false,
-
 
2461
                                    'sync_id' => $sync_id,
-
 
2462
                                    'message' => 'ERROR_INVALID_PARAMETERS_QUIZ_ANSWER_SLIDE',
-
 
2463
                                ]);
-
 
2464
                                continue;
-
 
2465
                            }
-
 
2466
                            
-
 
2467
                            array_push($array_response, [
-
 
2468
                                'question_uuid' => $question_uuid,
-
 
2469
                                'answer_uuid' => $answer_uuid,
-
 
2470
                                'value' => $value,
-
 
2471
                                'points' => $points
2345
                            } 
2472
                            ]);
Línea 2346... Línea 2473...
2346
                        }
2473
                        }
2347
                        
2474
                        
2348
                        $userQuiz = new CompanyMicrolearningUserQuiz();
2475
                        $userQuiz = new CompanyMicrolearningUserQuiz();
Línea 2434... Línea 2561...
2434
                        //$view_slides                = isset($record['view_slides'])               ? intval($record['view_slides'], 10) :  0;
2561
                        //$view_slides                = isset($record['view_slides'])               ? intval($record['view_slides'], 10) :  0;
2435
                        $returning                  = isset($record['returning'])                 ? intval($record['returning'], 10) :  0;
2562
                        $returning                  = isset($record['returning'])                 ? intval($record['returning'], 10) :  0;
2436
                        $returning_after_completed  = isset($record['returning_after_completed']) ? intval($record['returning_after_completed'], 10) :  0;
2563
                        $returning_after_completed  = isset($record['returning_after_completed']) ? intval($record['returning_after_completed'], 10) :  0;
2437
                        $completed                  = isset($record['completed'])                 ? intval($record['completed'], 10) :  0;
2564
                        $completed                  = isset($record['completed'])                 ? intval($record['completed'], 10) :  0;
Línea 2438... Línea -...
2438
                        
-
 
-
 
2565
                        
2439
                        $progressMapper = CompanyMicrolearningUserProgressMapper::getInstance($this->adapter);
2566
  
2440
                        $recordProgress = null;
2567
                        $recordProgress = null;
2441
                        switch($type) {
2568
                        switch($type) {
2442
                            case CompanyMicrolearningUserProgress::TYPE_TOPIC  :
2569
                            case CompanyMicrolearningUserProgress::TYPE_TOPIC  :
Línea 2443... Línea 2570...
2443
                                $recordProgress = $progressMapper->fetchOneByUserIdAndTopicId($user->id, $topic->id);
2570
                                $recordProgress = $userProgressMapper->fetchOneByUserIdAndTopicId($user->id, $topic->id);
Línea 2444... Línea 2571...
2444
                                
2571
                                
2445
                                break;
2572
                                break;
2446
                                
2573
                                
Línea 2447... Línea 2574...
2447
                            case CompanyMicrolearningUserProgress::TYPE_CAPSULE  :
2574
                            case CompanyMicrolearningUserProgress::TYPE_CAPSULE  :
2448
                                $recordProgress = $progressMapper->fetchOneByUseridAndCapsuleId($user->id, $capsule->id);
2575
                                $recordProgress = $userProgressMapper->fetchOneByUseridAndCapsuleId($user->id, $capsule->id);
2449
                                break;
2576
                                break;
Línea 2450... Línea 2577...
2450
                                
2577
                                
2451
                            case CompanyMicrolearningUserProgress::TYPE_SLIDE  :
2578
                            case CompanyMicrolearningUserProgress::TYPE_SLIDE  :
2452
                                $recordProgress = $progressMapper->fetchOneByUserIdAndSlideId($user->id, $slide->id);
2579
                                $recordProgress = $userProgressMapper->fetchOneByUserIdAndSlideId($user->id, $slide->id);
Línea 2465... Línea 2592...
2465
                            $recordProgress->company_id = $topic->company_id;
2592
                            $recordProgress->company_id = $topic->company_id;
2466
                            $recordProgress->topic_id   = $topic->id;
2593
                            $recordProgress->topic_id   = $topic->id;
2467
                            $recordProgress->capsule_id = $capsule ? $capsule->id : null;
2594
                            $recordProgress->capsule_id = $capsule ? $capsule->id : null;
2468
                            $recordProgress->slide_id   = $slide ? $slide->id : null;
2595
                            $recordProgress->slide_id   = $slide ? $slide->id : null;
2469
                            $recordProgress->added_on   = $added_on;
2596
                            $recordProgress->added_on   = $added_on;
-
 
2597
                        } else {
-
 
2598
                            
-
 
2599
                            if($recordProgress->updated_on > $updated_on) {
-
 
2600
                                array_push($result_sync_ids, [
-
 
2601
                                    'success' => true,
-
 
2602
                                    'sync_id' => $sync_id,
-
 
2603
                                ]);
-
 
2604
                                continue;
-
 
2605
                            }
-
 
2606
                            
-
 
2607
                            
-
 
2608
                            
2470
                        }
2609
                        }
2471
                        $recordProgress->returning                  = $returning;
2610
                        $recordProgress->returning                  = $returning;
2472
                        $recordProgress->returning_after_completed  = $returning_after_completed;
2611
                        $recordProgress->returning_after_completed  = $returning_after_completed;
2473
                        $recordProgress->completed                  = $completed;
2612
                        $recordProgress->completed                  = $completed;
Línea 2488... Línea 2627...
2488
                            
2627
                            
2489
                            $view_slides    = 0;
2628
                            $view_slides    = 0;
2490
                            $total_slides   = 0;
2629
                            $total_slides   = 0;
2491
                            foreach($capsule_ids as $capsule_id)
2630
                            foreach($capsule_ids as $capsule_id)
2492
                            {
2631
                            {
2493
                                $view_slides    += $progressMapper->fetchCountAllSlideCompletedByUserIdAndCapsuleId($user->id, $capsule_id);
2632
                                $view_slides    += $userProgressMapper->fetchCountAllSlideCompletedByUserIdAndCapsuleId($user->id, $capsule_id);
2494
                                $total_slides   += $slideMapper->fetchTotalCountByCompanyIdAndTopicIdAndCapsuleId($topic->company_id, $topic->id, $capsule_id);
2633
                                $total_slides   += $slideMapper->fetchTotalCountByCompanyIdAndTopicIdAndCapsuleId($topic->company_id, $topic->id, $capsule_id);
Línea 2495... Línea 2634...
2495
                            }
2634
                            }
2496
                            
2635
                            
2497
                            $recordProgress->progress       = $total_slides > 0 ? (($view_slides * 100) / $total_slides) : 0;
2636
                            $recordProgress->progress       = $total_slides > 0 ? (($view_slides * 100) / $total_slides) : 0;
2498
                            $recordProgress->total_slides   = $total_slides;
2637
                            $recordProgress->total_slides   = $total_slides;
2499
                            $recordProgress->view_slides    = $view_slides;
2638
                            $recordProgress->view_slides    = $view_slides;
2500
                        }
2639
                        }
2501
                        else if($type == CompanyMicrolearningUserProgress::TYPE_CAPSULE ) {
2640
                        else if($type == CompanyMicrolearningUserProgress::TYPE_CAPSULE ) {
Línea 2502... Línea 2641...
2502
                            $view_slides    = $progressMapper->fetchCountAllSlideCompletedByUserIdAndCapsuleId($user->id, $capsule->id);
2641
                            $view_slides    = $userProgressMapper->fetchCountAllSlideCompletedByUserIdAndCapsuleId($user->id, $capsule->id);
2503
                            $total_slides   = $slideMapper->fetchTotalCountByCompanyIdAndTopicIdAndCapsuleId($topic->company_id, $capsule->topic_id, $capsule->id);
2642
                            $total_slides   = $slideMapper->fetchTotalCountByCompanyIdAndTopicIdAndCapsuleId($topic->company_id, $capsule->topic_id, $capsule->id);
2504
                            
2643
                            
Línea 2515... Línea 2654...
2515
                        $recordProgress->updated_on = $updated_on;
2654
                        $recordProgress->updated_on = $updated_on;
Línea 2516... Línea 2655...
2516
                        
2655
                        
2517
                        
2656
                        
2518
                        
2657
                        
2519
                        if($recordProgress->id) {
2658
                        if($recordProgress->id) {
2520
                            $result = $progressMapper->update($recordProgress);
2659
                            $result = $userProgressMapper->update($recordProgress);
Línea 2521... Línea 2660...
2521
                        } else {
2660
                        } else {
2522
                            $result = $progressMapper->insert($recordProgress);
2661
                            $result = $userProgressMapper->insert($recordProgress);
2523
                        }
2662
                        }
Línea 2529... Línea 2668...
2529
                            ]);
2668
                            ]);
2530
                        } else {
2669
                        } else {
2531
                            array_push($result_sync_ids, [
2670
                            array_push($result_sync_ids, [
2532
                                'success' => false,
2671
                                'success' => false,
2533
                                'sync_id' => $sync_id,
2672
                                'sync_id' => $sync_id,
2534
                                'message' => $progressMapper->getError()
2673
                                'message' => $userProgressMapper->getError()
2535
                            ]);
2674
                            ]);
2536
                        }
2675
                        }
2537
                        continue;
2676
                        continue;
2538
                    }
2677
                    }
Línea 2562... Línea 2701...
2562
                                'message' => 'ERROR_INVALID_PARAMETERS',
2701
                                'message' => 'ERROR_INVALID_PARAMETERS',
2563
                            ]);
2702
                            ]);
2564
                            continue;
2703
                            continue;
2565
                        }
2704
                        }
Línea 2566... Línea -...
2566
                        
-
 
2567
                        $userLog = new CompanyMicrolearningUserLog();
-
 
2568
                        $userLog->activity      = $activity;
-
 
2569
                        $userLog->user_id       = $user->id;
-
 
2570
                        $userLog->company_id    = $topic->company_id;
-
 
2571
                        $userLog->topic_id      = $topic->id;
-
 
2572
                        $userLog->capsule_id    = $capsule ? $capsule->id : null;
-
 
2573
                        $userLog->slide_id      = $slide ? $slide->id : null;
-
 
Línea -... Línea 2705...
-
 
2705
                        
-
 
2706
                        
-
 
2707
                        
-
 
2708
                        
-
 
2709
                        $userLog = $userLogMapper->fetchLastBy($user->id);
-
 
2710
                        if($userLog) {
-
 
2711
                            $insert = $userLog->added_on <= $added_on;
-
 
2712
                        } else {
-
 
2713
                            $insert = true;
-
 
2714
                        }
2574
                        $userLog->added_on      = $added_on;
2715
            
-
 
2716
            
-
 
2717
                        if($insert) {
-
 
2718
                        
-
 
2719
                            $userLog = new CompanyMicrolearningUserLog();
-
 
2720
                            $userLog->activity      = $activity;
-
 
2721
                            $userLog->user_id       = $user->id;
-
 
2722
                            $userLog->company_id    = $topic->company_id;
-
 
2723
                            $userLog->topic_id      = $topic->id;
-
 
2724
                            $userLog->capsule_id    = $capsule ? $capsule->id : null;
-
 
2725
                            $userLog->slide_id      = $slide ? $slide->id : null;
-
 
2726
                            $userLog->added_on      = $added_on;
2575
                        
2727
                            
2576
                        
2728
                            
2577
                        
2729
                            
2578
                        $userLogMapper = CompanyMicrolearningUserLogMapper::getInstance($this->adapter);
2730
                           
-
 
2731
                            if($userLogMapper->insert($userLog)) {
-
 
2732
                                array_push($result_sync_ids, [
-
 
2733
                                    'success' => true,
-
 
2734
                                    'sync_id' => $sync_id 
-
 
2735
                                ]);
-
 
2736
                            } else {
-
 
2737
                                array_push($result_sync_ids, [
2579
                        if($userLogMapper->insert($userLog)) {
2738
                                    'success' => false,
2580
                            array_push($result_sync_ids, [
2739
                                    'sync_id' => $sync_id,
2581
                                'success' => true,
2740
                                    'message' => $userLogMapper->getError()
2582
                                'sync_id' => $sync_id 
2741
                                ]);
2583
                            ]);
2742
                            }
2584
                        } else {
-
 
2585
                            array_push($result_sync_ids, [
2743
                        } else {
2586
                                'success' => false,
2744
                            array_push($result_sync_ids, [
2587
                                'sync_id' => $sync_id,
2745
                                'success' => true,
2588
                                'message' => $userLogMapper->getError()
2746
                                'sync_id' => $sync_id
Línea 2598... Línea 2756...
2598
                
2756
                
Línea 2599... Línea 2757...
2599
                /***** INICIO LOG DE USUARIO GENERAL *****/
2757
                /***** INICIO LOG DE USUARIO GENERAL *****/
Línea -... Línea 2758...
-
 
2758
                
-
 
2759
                if($user_uuid && $sync_type == 'userlog' && $device->application_id = Application::TWOGETSKILLS) {
2600
                
2760
                    
-
 
2761
                    
2601
                if($user_uuid && $sync_type == 'userlog' && $device->application_id = Application::TWOGETSKILLS) {
2762
                    if(isset($users[$user_uuid])) {
-
 
2763
                        $user = $users[$user_uuid];
-
 
2764
                    } else {
-
 
2765
                        $user = $userMapper->fetchOneByUuid($user_uuid);
-
 
2766
                        if($user) {
-
 
2767
                            $users[$user_uuid] = $user;
-
 
2768
                        }
-
 
2769
                    }
Línea 2602... Línea 2770...
2602
                    
2770
                    
2603
                    $userMapper = UserMapper::getInstance($this->adapter);
2771
                    
2604
                    $user = $userMapper->fetchOneByUuid($user_uuid);
2772
                    
2605
                    
2773
                    
Línea 2645... Línea 2813...
2645
                            'message' => 'ERROR_INVALID_PARAMETERS',
2813
                            'message' => 'ERROR_INVALID_PARAMETERS',
2646
                        ]);
2814
                        ]);
2647
                        continue;
2815
                        continue;
2648
                    }
2816
                    }
Línea 2649... Línea -...
2649
                    
-
 
2650
                    $userLog = new CompanyMicrolearningUserLog();
-
 
2651
                    $userLog->company_id = null;
-
 
2652
                    $userLog->user_id = $user->id;
-
 
2653
                    $userLog->activity = $activity;
-
 
Línea -... Línea 2817...
-
 
2817
                    
-
 
2818
                    
-
 
2819
                    $userLog = $userLogMapper->fetchLastBy($user->id);
-
 
2820
                    if($userLog) {
-
 
2821
                        $insert = $userLog->added_on <= $added_on;
-
 
2822
                    } else {
Línea -... Línea 2823...
-
 
2823
                        $insert = true;
-
 
2824
                    }
-
 
2825
                    
-
 
2826
                    
-
 
2827
                    if($insert) {
-
 
2828
                        $userLog = new CompanyMicrolearningUserLog();
-
 
2829
                        $userLog->company_id = null;
-
 
2830
                        $userLog->user_id = $user->id;
-
 
2831
                        $userLog->activity = $activity;
2654
                    $userLog->added_on = $added_on;
2832
                        $userLog->added_on = $added_on;
2655
                    
2833
                        
-
 
2834
                        
-
 
2835
                        $userLogMapper = CompanyMicrolearningUserLogMapper::getInstance($this->adapter);
-
 
2836
                        if($userLogMapper->insert($userLog)) {
-
 
2837
                            array_push($result_sync_ids, [
-
 
2838
                                'success' => true,
-
 
2839
                                'sync_id' => $sync_id
-
 
2840
                            ]);
-
 
2841
                        } else {
-
 
2842
                            array_push($result_sync_ids, [
-
 
2843
                                'success' => false,
-
 
2844
                                'sync_id' => $sync_id,
-
 
2845
                                'message' => $userLogMapper->getError()
2656
                    
2846
                            ]);
2657
                    $userLogMapper = CompanyMicrolearningUserLogMapper::getInstance($this->adapter);
2847
                        }
2658
                    if($userLogMapper->insert($userLog)) {
2848
                    } else {
2659
                        array_push($result_sync_ids, [
2849
                        array_push($result_sync_ids, [
2660
                            'success' => true,
-
 
2661
                            'sync_id' => $sync_id
-
 
2662
                        ]);
-
 
2663
                    } else {
-
 
2664
                        array_push($result_sync_ids, [
-
 
2665
                            'success' => false,
-
 
2666
                            'sync_id' => $sync_id,
2850
                            'success' => true,
Línea -... Línea 2851...
-
 
2851
                            'sync_id' => $sync_id
-
 
2852
                        ]);
2667
                            'message' => $userLogMapper->getError()
2853
                    }
2668
                        ]);
2854
                    
Línea 2669... Línea 2855...
2669
                    }
2855
             
2670
                    
2856