Proyectos de Subversion Android Microlearning

Rev

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

Rev 33 Rev 43
Línea 1757... Línea 1757...
1757
                        userLogDao.insert(userLog);
1757
                        userLogDao.insert(userLog);
1758
                    }
1758
                    }
1759
                }
1759
                }
1760
            }
1760
            }
Línea -... Línea 1761...
-
 
1761
 
-
 
1762
            String uuid;
1761
 
1763
            Company company;
-
 
1764
            if(data.has("quizzes")) {
-
 
1765
                Quiz quiz;
-
 
1766
                Question question;
-
 
1767
                Answer answer;
1762
            if(data.has("quizzes")) {
1768
 
1763
                arrayQuizzes = data.getJSONArray("quizzes");
1769
                arrayQuizzes = data.getJSONArray("quizzes");
1764
                for (i = 0; i < arrayQuizzes.length(); i++) {
1770
                for (i = 0; i < arrayQuizzes.length(); i++) {
1765
                    objQuiz = arrayQuizzes.getJSONObject(i);
-
 
1766
                    Quiz quiz = new Quiz();
-
 
1767
                    quiz.setUuid(  objQuiz.getString("uuid"));
-
 
1768
                    quiz.setCompanyUuid(  objQuiz.getString("company_uuid"));
-
 
1769
                    quiz.setFailed(  objQuiz.getString("failed"));
-
 
1770
                    quiz.setName(  objQuiz.getString("name"));
-
 
1771
                    quiz.setText(  objQuiz.getString("text"));
-
 
1772
                    quiz.setPoints(  objQuiz.getInt("points"));
-
 
1773
                    quiz.setMinimumPointsRequired(objQuiz.getInt("minimum_points_required"));
-
 
Línea -... Línea 1771...
-
 
1771
                    objQuiz = arrayQuizzes.getJSONObject(i);
-
 
1772
 
1774
                    quiz.setMaxTime( objQuiz.getInt("max_time"));
1773
 
1775
 
1774
                    uuid = objQuiz.getString("company_uuid");
1776
                    Company company = companyDao.selectByUuid(quiz.getCompanyUuid());
1775
                    company = companyDao.selectByUuid(uuid);
1777
                    if (company == null) {
1776
                    if (company == null) {
1778
                        company = new Company();
1777
                        company = new Company();
1779
                        company.setUuid(objQuiz.getString("company_uuid"));
1778
                        company.setUuid(objQuiz.getString("company_uuid"));
Línea 1780... Línea 1779...
1780
                        company.setName(objQuiz.getString("company_name"));
1779
                        company.setName(objQuiz.getString("company_name"));
-
 
1780
                        company.setImage(objQuiz.getString("company_image"));
-
 
1781
 
-
 
1782
                        companyDao.insert(company);
-
 
1783
                    } else {
-
 
1784
                        company.setName(objQuiz.getString("company_name"));
1781
                        company.setImage(objQuiz.getString("company_image"));
1785
                        company.setImage(objQuiz.getString("company_image"));
Línea -... Línea 1786...
-
 
1786
 
-
 
1787
                        companyDao.update(company);
-
 
1788
                    }
-
 
1789
 
-
 
1790
 
-
 
1791
                    uuid =  objQuiz.getString("uuid");
-
 
1792
                    quiz = quizDao.selectByUuid(uuid);
-
 
1793
 
-
 
1794
                    if(quiz == null) {
-
 
1795
                        quiz = new Quiz();
-
 
1796
                        quiz.setUuid(  objQuiz.getString("uuid"));
-
 
1797
                        quiz.setCompanyUuid(  company.getUuid() );
-
 
1798
                        quiz.setFailed(  objQuiz.getString("failed"));
-
 
1799
                        quiz.setName(  objQuiz.getString("name"));
1782
 
1800
                        quiz.setText(  objQuiz.getString("text"));
-
 
1801
                        quiz.setPoints(  objQuiz.getInt("points"));
-
 
1802
                        quiz.setMinimumPointsRequired(objQuiz.getInt("minimum_points_required"));
-
 
1803
                        quiz.setMaxTime( objQuiz.getInt("max_time"));
-
 
1804
                        quizDao.insert(quiz);
-
 
1805
 
-
 
1806
                    } else {
-
 
1807
                        quiz.setCompanyUuid(  company.getUuid() );
-
 
1808
                        quiz.setFailed(  objQuiz.getString("failed"));
-
 
1809
                        quiz.setName(  objQuiz.getString("name"));
-
 
1810
                        quiz.setText(  objQuiz.getString("text"));
-
 
1811
                        quiz.setPoints(  objQuiz.getInt("points"));
Línea 1783... Línea 1812...
1783
                        companyDao.insert(company);
1812
                        quiz.setMinimumPointsRequired(objQuiz.getInt("minimum_points_required"));
1784
                    }
1813
                        quiz.setMaxTime( objQuiz.getInt("max_time"));
1785
 
1814
                        quizDao.update(quiz);
1786
                    quizDao.insert(quiz);
-
 
1787
 
-
 
1788
                    arrayQuestions = objQuiz.getJSONArray("questions");
-
 
1789
                    for (j = 0; j < arrayQuestions.length(); j++) {
-
 
1790
                        objQuestion = arrayQuestions.getJSONObject(j);
-
 
1791
                        Question question = new Question();
-
 
1792
                        question.setQuizUuid( quiz.getUuid());
-
 
Línea -... Línea 1815...
-
 
1815
                    }
-
 
1816
 
-
 
1817
                    arrayQuestions = objQuiz.getJSONArray("questions");
-
 
1818
                    for (j = 0; j < arrayQuestions.length(); j++) {
-
 
1819
                        objQuestion = arrayQuestions.getJSONObject(j);
-
 
1820
 
-
 
1821
                        uuid = objQuestion.getString("uuid");
-
 
1822
                        question = questionDao.selectByUuid(uuid);
-
 
1823
                        if(question == null) {
-
 
1824
                            question = new Question();
-
 
1825
                            question.setQuizUuid( quiz.getUuid());
1793
                        question.setUuid( objQuestion.getString("uuid"));
1826
                            question.setUuid(uuid) ;
-
 
1827
                            question.setText( objQuestion.getString("text"));
-
 
1828
                            question.setType( objQuestion.getString("type"));
-
 
1829
                            question.setPoints( objQuestion.getInt("points"));
-
 
1830
                            question.setMaxlength( objQuestion.getInt("maxlength"));
-
 
1831
 
-
 
1832
                            questionDao.insert(question);
-
 
1833
                        } else {
-
 
1834
                            question.setQuizUuid( quiz.getUuid());
-
 
1835
                            question.setText( objQuestion.getString("text"));
-
 
1836
                            question.setType( objQuestion.getString("type"));
-
 
1837
                            question.setPoints( objQuestion.getInt("points"));
-
 
1838
                            question.setMaxlength( objQuestion.getInt("maxlength"));
Línea 1794... Línea 1839...
1794
                        question.setText( objQuestion.getString("text"));
1839
 
1795
                        question.setType( objQuestion.getString("type"));
1840
                            questionDao.update(question);
1796
                        question.setPoints( objQuestion.getInt("points"));
1841
                        }
1797
                        question.setMaxlength( objQuestion.getInt("maxlength"));
-
 
1798
 
-
 
1799
                        questionDao.insert(question);
-
 
1800
 
-
 
1801
                        arrayAnswers = objQuestion.getJSONArray("answers");
-
 
1802
                        for (x = 0; x < arrayAnswers.length(); x++) {
-
 
Línea 1803... Línea 1842...
1803
                            objAnswer = arrayAnswers.getJSONObject(x);
1842
 
1804
                            Answer answer = new Answer();
1843
 
Línea -... Línea 1844...
-
 
1844
 
Línea -... Línea 1845...
-
 
1845
 
-
 
1846
                        arrayAnswers = objQuestion.getJSONArray("answers");
-
 
1847
                        for (x = 0; x < arrayAnswers.length(); x++) {
-
 
1848
                            objAnswer = arrayAnswers.getJSONObject(x);
-
 
1849
 
-
 
1850
                            uuid = objAnswer.getString("uuid");
-
 
1851
                            answer = answerDao.selectByUuid(uuid);
-
 
1852
 
-
 
1853
                            if(answer == null) {
-
 
1854
 
-
 
1855
                                answer = new Answer();
-
 
1856
                                answer.setQuestionUuid(question.getUuid());
-
 
1857
                                answer.setUuid(uuid);
-
 
1858
                                answer.setText(objAnswer.getString("text"));
-
 
1859
                                answer.setPoints(objAnswer.getInt("points"));
-
 
1860
                                answer.setCorrect(objAnswer.getString("correct"));
1805
                            answer.setQuestionUuid(question.getUuid());
1861
 
1806
                            answer.setUuid(objAnswer.getString("uuid"));
1862
                                answerDao.insert(answer);
1807
                            answer.setText(objAnswer.getString("text"));
1863
                            } else {
Línea 1808... Línea 1864...
1808
                            answer.setPoints( objAnswer.getInt("points"));
1864
                                answer.setQuestionUuid(question.getUuid());
-
 
1865
                                answer.setText(objAnswer.getString("text"));
-
 
1866
                                answer.setPoints(objAnswer.getInt("points"));
-
 
1867
                                answer.setCorrect(objAnswer.getString("correct"));
Línea 1809... Línea 1868...
1809
                            answer.setCorrect(objAnswer.getString("correct"));
1868
                                answerDao.update(answer);
1810
 
1869
                            }
1811
                            answerDao.insert(answer);
1870
                        }
1812
                        }
-
 
1813
 
-
 
1814
 
-
 
1815
                    }
-
 
1816
                }
-
 
1817
            }
-
 
1818
 
-
 
Línea -... Línea 1871...
-
 
1871
                    }
1819
 
1872
                }
1820
 
1873
            }
1821
 
1874
 
1822
 
1875
 
1823
            if(data.has("topics")) {
1876
 
1824
 
1877
 
Línea 1825... Línea 1878...
1825
                JSONArray arrayTopics = data.getJSONArray("topics");
1878
 
-
 
1879
            if(data.has("topics")) {
-
 
1880
                Topic topic;
-
 
1881
                Capsule capsule;
-
 
1882
                Slide slide;
-
 
1883
 
1826
                for (i = 0; i < arrayTopics.length(); i++) {
1884
                JSONArray arrayTopics = data.getJSONArray("topics");
Línea -... Línea 1885...
-
 
1885
                for (i = 0; i < arrayTopics.length(); i++) {
-
 
1886
                    objTopic = arrayTopics.getJSONObject(i);
-
 
1887
 
-
 
1888
                    uuid = objTopic.getString("company_uuid");
-
 
1889
                    company = companyDao.selectByUuid(uuid);
-
 
1890
                    if (company == null) {
-
 
1891
                        company = new Company();
-
 
1892
                        company.setUuid(objTopic.getString("company_uuid"));
-
 
1893
                        company.setName(objTopic.getString("company_name"));
-
 
1894
                        company.setImage(objTopic.getString("company_image"));
-
 
1895
 
1827
                    objTopic = arrayTopics.getJSONObject(i);
1896
                        companyDao.insert(company);
-
 
1897
                    } else {
-
 
1898
                        company.setName(objTopic.getString("company_name"));
-
 
1899
                        company.setImage(objTopic.getString("company_image"));
-
 
1900
 
-
 
1901
                        companyDao.update(company);
-
 
1902
                    }
-
 
1903
 
-
 
1904
                    uuid = objTopic.getString("uuid");
-
 
1905
                    topic = topicDao.selectByUuid(uuid);
-
 
1906
 
-
 
1907
                    if (topic == null) {
-
 
1908
                        topic = new Topic();
Línea 1828... Línea 1909...
1828
                    Topic topic = new Topic();
1909
                        topic.setUuid(uuid);
1829
                    topic.setUuid(objTopic.getString("uuid"));
1910
                        topic.setCompanyUuid(company.getUuid());
1830
                    topic.setCompanyUuid(objTopic.getString("company_uuid"));
1911
                        topic.setName(objTopic.getString("name"));
-
 
1912
                        topic.setDescription(objTopic.getString("description"));
-
 
1913
                        topic.setImage(objTopic.getString("image"));
-
 
1914
                        topic.setPosition(objTopic.getInt("position"));
1831
                    topic.setName(objTopic.getString("name"));
1915
                        topicDao.insert(topic);
1832
                    topic.setDescription(objTopic.getString("description"));
1916
                    } else {
-
 
1917
                        topic.setCompanyUuid(company.getUuid());
1833
                    topic.setImage(objTopic.getString("image"));
1918
                        topic.setName(objTopic.getString("name"));
-
 
1919
                        topic.setDescription(objTopic.getString("description"));
-
 
1920
                        topic.setImage(objTopic.getString("image"));
-
 
1921
                        topic.setPosition(objTopic.getInt("position"));
-
 
1922
                        topicDao.update(topic);
-
 
1923
                    }
-
 
1924
 
-
 
1925
 
1834
                    topic.setPosition(objTopic.getInt("position"));
1926
 
1835
 
1927
 
1836
                    Company company = companyDao.selectByUuid(topic.getCompanyUuid());
1928
 
1837
                    if (company == null) {
1929
                    arrayCapsules = objTopic.getJSONArray("capsules");
1838
                        company = new Company();
1930
                    for (j = 0; j < arrayCapsules.length(); j++) {
-
 
1931
                        objCapsule = arrayCapsules.getJSONObject(j);
-
 
1932
                        uuid = objCapsule.getString("uuid");
-
 
1933
                        capsule = capsuleDao.selectByUuid(uuid);
-
 
1934
                        if(capsule == null) {
Línea 1839... Línea 1935...
1839
                        company.setUuid(objTopic.getString("company_uuid"));
1935
                            capsule = new Capsule();
1840
                        company.setName(objTopic.getString("company_name"));
1936
                            capsule.setTopicUuid(topic.getUuid());
1841
                        company.setImage(objTopic.getString("company_image"));
1937
                            capsule.setUuid(uuid);
1842
 
-
 
1843
                        companyDao.insert(company);
-
 
1844
                    }
-
 
1845
 
-
 
1846
                    topicDao.insert(topic);
-
 
1847
 
-
 
1848
                    arrayCapsules = objTopic.getJSONArray("capsules");
-
 
1849
                    for (j = 0; j < arrayCapsules.length(); j++) {
-
 
1850
                        objCapsule = arrayCapsules.getJSONObject(j);
-
 
1851
                        Capsule capsule = new Capsule();
-
 
1852
                        capsule.setTopicUuid(topic.getUuid());
-
 
Línea -... Línea 1938...
-
 
1938
                            capsule.setName(objCapsule.getString("name"));
-
 
1939
                            capsule.setDescription(objCapsule.getString("description"));
-
 
1940
                            capsule.setImage(objCapsule.getString("image"));
-
 
1941
                            capsule.setPosition(objCapsule.getInt("position"));
-
 
1942
                            capsuleDao.insert(capsule);
-
 
1943
                        } else {
-
 
1944
                            capsule = new Capsule();
-
 
1945
                            capsule.setTopicUuid(topic.getUuid());
-
 
1946
                            capsule.setName(objCapsule.getString("name"));
-
 
1947
                            capsule.setDescription(objCapsule.getString("description"));
-
 
1948
                            capsule.setImage(objCapsule.getString("image"));
-
 
1949
                            capsule.setPosition(objCapsule.getInt("position"));
-
 
1950
                            capsuleDao.update(capsule);
-
 
1951
                        }
-
 
1952
 
-
 
1953
 
-
 
1954
 
1853
                        capsule.setUuid(objCapsule.getString("uuid"));
1955
 
-
 
1956
                        arraySlides = objCapsule.getJSONArray("slides");
-
 
1957
                        for (x = 0; x < arraySlides.length(); x++) {
-
 
1958
                            objSlide = arraySlides.getJSONObject(x);
-
 
1959
 
-
 
1960
                            uuid = objSlide.getString("uuid");
-
 
1961
                            slide = slideDao.selectByUuid(uuid);
-
 
1962
 
-
 
1963
                            if(slide == null) {
-
 
1964
 
-
 
1965
                                slide = new Slide();
-
 
1966
                                slide.setUuid(uuid);
-
 
1967
                                slide.setTopicUuid(capsule.getTopicUuid());
-
 
1968
                                slide.setCapsuleUuid(capsule.getUuid());
1854
                        capsule.setName(objCapsule.getString("name"));
1969
                                slide.setQuizUuid(objSlide.getString("quiz_uuid"));
Línea 1855... Línea 1970...
1855
                        capsule.setDescription(objCapsule.getString("description"));
1970
                                slide.setName(objSlide.getString("name"));
Línea 1856... Línea 1971...
1856
                        capsule.setImage(objCapsule.getString("image"));
1971
                                slide.setDescription(objSlide.getString("description"));
1857
                        capsule.setPosition(objCapsule.getInt("position"));
1972
                                slide.setPosition(objSlide.getInt("position"));
Línea -... Línea 1973...
-
 
1973
                                slide.setType(objSlide.getString("type"));
-
 
1974
                                slide.setFile(objSlide.getString("file"));
-
 
1975
                                slide.setBackground(objSlide.getString("background"));
-
 
1976
 
-
 
1977
                                slideDao.insert(slide);
-
 
1978
                            } else {
-
 
1979
                                slide.setTopicUuid(capsule.getTopicUuid());
-
 
1980
                                slide.setCapsuleUuid(capsule.getUuid());
-
 
1981
                                slide.setQuizUuid(objSlide.getString("quiz_uuid"));
-
 
1982
                                slide.setName(objSlide.getString("name"));
-
 
1983
                                slide.setDescription(objSlide.getString("description"));
-
 
1984
                                slide.setPosition(objSlide.getInt("position"));
-
 
1985
                                slide.setType(objSlide.getString("type"));
-
 
1986
                                slide.setFile(objSlide.getString("file"));
-
 
1987
                                slide.setBackground(objSlide.getString("background"));
-
 
1988
 
-
 
1989
                                slideDao.update(slide);
-
 
1990
                            }
-
 
1991
                        }
-
 
1992
 
-
 
1993
                    }
-
 
1994
 
-
 
1995
 
-
 
1996
                }
-
 
1997
            }
-
 
1998
 
-
 
1999
            if(data.has( "extended")) {
-
 
2000
 
-
 
2001
                JSONObject objExtended;
-
 
2002
                JSONObject objItem;
-
 
2003
                JSONArray objItems;
-
 
2004
 
-
 
2005
 
-
 
2006
 
-
 
2007
                UserExtended userExtended;
-
 
2008
 
-
 
2009
                JSONArray extendedCompanies = data.getJSONArray("extended");
-
 
2010
                for(i = 0 ; i < extendedCompanies.length(); i++)
-
 
2011
                {
-
 
2012
                    objExtended = extendedCompanies.getJSONObject(i);
-
 
2013
                    if(objExtended.has("details")) {
-
 
2014
                        uuid = objExtended.getString("company_uuid");
-
 
2015
 
-
 
2016
 
-
 
2017
                        company = companyDao.selectByUuid(uuid);
-
 
2018
                        if (company == null) {
-
 
2019
                            company = new Company();
-
 
2020
                            company.setUuid(objExtended.getString("company_uuid"));
-
 
2021
                            company.setName(objExtended.getString("company_name"));
-
 
2022
                            company.setImage(objExtended.getString("company_image"));
-
 
2023
 
-
 
2024
                            companyDao.insert(company);
-
 
2025
                        } else {
-
 
2026
                            company.setName(objExtended.getString("company_name"));
-
 
2027
                            company.setImage(objExtended.getString("company_image"));
-
 
2028
 
-
 
2029
                            companyDao.update(company);
-
 
2030
                        }
-
 
2031
 
-
 
2032
                        objItems = objExtended.getJSONArray("details");
-
 
2033
                        for(j = 0 ; j < objItems.length(); j++) {
-
 
2034
                            objItem = objItems.getJSONObject(j);
-
 
2035
 
Línea 1858... Línea 2036...
1858
                        capsuleDao.insert(capsule);
2036
                            uuid =  objItem.getString("uuid");
1859
 
2037
 
1860
                        arraySlides = objCapsule.getJSONArray("slides");
2038
                            userExtended = userExtendedDao.selectByUuid(uuid);
1861
                        for (x = 0; x < arraySlides.length(); x++) {
2039
                            if(userExtended == null) {
Línea 1909... Línea 2087...
1909
                    preference.setCompanyUuidActive(companies.get(0).getUuid());
2087
                    preference.setCompanyUuidActive(companies.get(0).getUuid());
Línea 1910... Línea 2088...
1910
 
2088
 
Línea 1911... Línea 2089...
1911
                } else {
2089
                } else {
1912
 
2090
 
-
 
2091
                    boolean companyExist = false;
1913
                    boolean companyExist = false;
2092
                    for(i = 0; i < companies.size(); i++) {
1914
                    for (Company company : companies) {
2093
 
-
 
2094
                        if (companies.get(i).getUuid().equals(preference.getCompanyUuidActive())) {
1915
                        if (company.getUuid().equals(preference.getCompanyUuidActive())) {
2095
                            companyExist = true;
1916
                            companyExist = true;
2096
                            break;
Línea 1917... Línea 2097...
1917
                        }
2097
                        }
1918
                    }
2098
                    }
1919
 
2099
 
1920
                    if(!companyExist) {
2100
                    if(!companyExist && companies.size() > 0) {
Línea 1921... Línea 2101...
1921
                        preference.setCompanyUuidActive(companies.get(0).getUuid());
2101
                        preference.setCompanyUuidActive(companies.get(0).getUuid());
1922
                    }
2102
                    }
1923
                }
2103
                }
Línea 1924... Línea -...
1924
 
-
 
Línea 1925... Línea -...
1925
            } else {
-
 
1926
                preference.setCompanyUuidActive("");
-
 
1927
            }
-
 
1928
 
-
 
1929
            if(data.has( "extended")) {
-
 
1930
 
-
 
1931
                JSONObject objExtended;
-
 
1932
                JSONObject objItem;
-
 
1933
                JSONArray objItems;
-
 
1934
 
-
 
1935
                String company_uuid;
-
 
1936
 
-
 
1937
                UserExtended userExtended;
-
 
1938
 
-
 
1939
                JSONArray extendedCompanies = data.getJSONArray("extended");
-
 
1940
                for(i = 0 ; i < extendedCompanies.length(); i++)
-
 
1941
                {
-
 
1942
                    objExtended = extendedCompanies.getJSONObject(i);
-
 
1943
                    if(objExtended.has("details")) {
-
 
1944
                        company_uuid = objExtended.getString("company_uuid");
-
 
1945
 
-
 
1946
                        objItems = objExtended.getJSONArray("details");
-
 
1947
                        for(j = 0 ; j < objItems.length(); j++) {
-
 
1948
                            objItem = objItems.getJSONObject(j);
-
 
1949
                            userExtended = new UserExtended();
-
 
1950
                            userExtended.setCompanyUuid(company_uuid);
-
 
1951
                            userExtended.setUuid(objItem.getString("uuid"));
-
 
1952
                            userExtended.setLabel(objItem.getString("label"));
-
 
1953
                            userExtended.setValue(objItem.getString("value"));
-
 
1954
                            userExtendedDao.insert(userExtended);
-
 
Línea 1955... Línea 2104...
1955
 
2104
 
1956
                        }
2105
            } else {
1957
                    }
2106
                preference.setCompanyUuidActive("");