Exemplo n.º 1
0
        public void loadAllTestContentFromBD(int testId)
        {
            Subject newSubject = new Subject();

            newSubject.Id = DataSetConverter.fromDsToSingle.toInt.
                            convert(SqlLiteSimpleExecute.execute(queryConfigurator.loadSubjectId(testId)));
            Test loadTest = testManipulator.load(testId, true, false);

            loadTest.IsSelected = true;

            bool testAlreadyPreLoad = false;
            int  subjectPosition    = -1;

            for (int i = 0; i < store.Count; i++)
            {
                if (store.ElementAt(i).Id == newSubject.Id)
                {
                    testAlreadyPreLoad = true;
                    subjectPosition    = i;
                    break;
                }
            }

            if (!testAlreadyPreLoad)
            {
                List <Subject> newConfig = new List <Subject>();
                newSubject.Tests.Add(loadTest);
                newSubject.Name = DataSetConverter.fromDsToSingle.toString.
                                  convert(SqlLiteSimpleExecute.execute(queryConfigurator.
                                                                       loadSubjectName(newSubject.Id)));
                newConfig.Add(newSubject);
                setConfig(newConfig);
            }
            else
            {
                for (int i = 0; i < config.ElementAt(subjectPosition).Tests.Count; i++)
                {
                    if (config.ElementAt(subjectPosition).Tests.ElementAt(i).Id == testId)
                    {
                        config.ElementAt(subjectPosition).Tests.RemoveAt(i);
                        config.ElementAt(subjectPosition).Tests.Insert(i, loadTest);
                        setConfig(config);
                        break;
                    }
                }
            }

            loadStore();
        }
Exemplo n.º 2
0
        public Subject load(string name, bool loadOnlySubjectAndTestNamesWithoutChilds,
                            bool loadAllQuestions)
        {
            Subject sub = new Subject();

            sub.Id = DataSetConverter.fromDsToSingle.toInt.convert(SqlLiteSimpleExecute.
                                                                   execute(queryConfigurator.getSubjectId(name)));
            sub.Name = EncryptWorker.getInstance().decrypt(name);
            int[] testIds = DataSetConverter.fromDsToBuf.toIntBuf.convert(SqlLiteSimpleExecute.
                                                                          execute(queryConfigurator.loadSubjectTestIds(sub.Id)));
            for (int i = 0; i < testIds.Length; i++)
            {
                sub.Tests.Add(testManipulator.load(testIds[i], loadAllQuestions,
                                                   loadOnlySubjectAndTestNamesWithoutChilds));
            }

            return(sub);
        }