Beispiel #1
0
        public Question load(int id)
        {
            Question question = new Question();

            question.Id = id;
            question.QuestionsContent = EncryptWorker.getInstance().decrypt(
                DataSetConverter.fromDsToSingle.toString.convert(
                    SqlLiteSimpleExecute.execute(queryConfigurator.loadQuestionContent(id))));
            int[] unswersIds = DataSetConverter.fromDsToBuf.toIntBuf.convert(
                SqlLiteSimpleExecute.execute(queryConfigurator.loadQuestionUnswersIds(id)));

            question.Unswers = new List <Unswer>();
            for (int i = 0; i < unswersIds.Count(); i++)
            {
                question.Unswers.Add(unswerManipalator.load(unswersIds[i]));
            }

            int questionTypeId = DataSetConverter.fromDsToSingle.toInt.convert(
                SqlLiteSimpleExecute.execute(queryConfigurator.loadQuestionTypeId(id)));
            string questionType = DataSetConverter.fromDsToSingle.toString.convert(
                SqlLiteSimpleExecute.execute(queryConfigurator.getObjectName(questionTypeId)));

            if (questionType.Equals(QuestionTypes.multiplyAnswer.getType()))
            {
                question.QuestionsType = QuestionTypes.multiplyAnswer;
                return(question);
            }
            if (questionType.Equals(QuestionTypes.singleAnswer.getType()))
            {
                question.QuestionsType = QuestionTypes.singleAnswer;
                return(question);
            }

            throw new ParamsTypesExceptions();
        }
Beispiel #2
0
        public Subject getSubjectFromBD(int id)
        {
            string name = DataSetConverter.fromDsToSingle.toString.convert(SqlLiteSimpleExecute.
                                                                           execute(queryConfigurator.getObjectName(id)));

            return(subjectManipulator.load(name, true, true));
        }
Beispiel #3
0
        public Unswer load(int id)
        {
            Unswer unswer = new Unswer();

            unswer.Id = id;
            string lastQuery = "";

            try
            {
                lastQuery      = queryConfigurator.loadUnswerContent(id);
                unswer.Content = EncryptWorker.getInstance().decrypt(
                    DataSetConverter.fromDsToSingle.toString.convert(SqlLiteSimpleExecute.
                                                                     execute(queryConfigurator.loadUnswerContent(id))));
                lastQuery = queryConfigurator.loadUnswerTypeId(id);
                int typeId = DataSetConverter.fromDsToSingle.toInt.convert(SqlLiteSimpleExecute.
                                                                           execute(queryConfigurator.loadUnswerTypeId(id)));
                lastQuery = queryConfigurator.getObjectName(typeId);
                string type = DataSetConverter.fromDsToSingle.toString.convert(SqlLiteSimpleExecute.
                                                                               execute(queryConfigurator.getObjectName(typeId)));
                if (type.Equals(DbObjects.rightUnswer.getName()))
                {
                    unswer.IsRight = true;
                    return(unswer);
                }
                if (type.Equals(DbObjects.unswer.getName()))
                {
                    unswer.IsRight = false;
                    return(unswer);
                }
            }
            catch (СonversionError err)
            {
                throw new СonversionError("Ошибка при обработке запроса:" + lastQuery +
                                          ". Обратитесь к администратору");
            }
            throw new ParamsTypesExceptions();
        }