Example #1
0
        private QuestionSet AddQuestionSet(QuestionSet set)
        {
            if (set.Root != Root)
            {
                throw new NotImplementedException();
            }

            QuestionSet qs = new QuestionSet(set.Value, this);

            connection.TestQuestionSetSet.TestContents.AddTestContentsRow(Value, qs.Value, 0);

            Dataset.QuestionSetsExRow row =
                FullDataset.QuestionSetsEx.AddQuestionSetsExRow(qs.Value.Id, qs.Value.Name, qs.Value.Description,
                                                                qs.Value.NumberOfQuestionsToPick, 1, 1, 1,
                                                                qs.Value.NumberOfQuestionsInZone1,
                                                                qs.Value.NumberOfQuestionsInZone2,
                                                                qs.Value.NumberOfQuestionsInZone3,
                                                                FullDataset.Tests[0].Id, 0);
            //Check!qs.Value.Id,

            if (qs.Value.IsTimeLimitNull())
            {
                row.SetTimeLimitNull();
            }
            else
            {
                row.TimeLimit = qs.Value.TimeLimit;
            }

            if (qs.Value.IsQuestionTypeIdNull())
            {
                row.SetQuestionTypeIdNull();
            }
            else
            {
                row.QuestionTypeId = qs.Value.QuestionTypeId;
            }

            if (qs.Value.IsQuestionSubtypeIdNull())
            {
                row.SetQuestionSubtypeIdNull();
            }
            else
            {
                row.QuestionSubtypeId = qs.Value.QuestionSubtypeId;
            }

            contentIsChanged = true;

            OnStructureChangedInternally();

            return(qs);
        }
Example #2
0
        internal override bool DoCanAddNewChild(Entity entity)
        {
            bool res = entity is QuestionSet && ((QuestionSet)entity).QuestionType.IsSubsetOf(QuestionType);

            if (!res)
            {
                return(res);
            }
            QuestionSet qs = (QuestionSet)entity;

            foreach (QuestionSet set in Children)
            {
                if (set.Value.Id == qs.Value.Id)
                {
                    return(false);
                }
            }

            return(true);
        }
Example #3
0
        /*private static TestQuestionSetSet.QuestionSetsRow Convert(Dataset.QuestionSetsExRow value)
         * {
         * TestQuestionSetSet t = new TestQuestionSetSet();
         * TestQuestionSetSet.QuestionSetsRow row = t.QuestionSets.AddQuestionSetsRow(value.Name, value.Description, value.NumberOfQuestionsToPick, 0, 0, 0, value.NumberOfQuestionsInZone1, value.NumberOfQuestionsInZone2, value.NumberOfQuestionsInZone3);
         *
         * if (value.IsTimeLimitNull())
         *  row.SetTimeLimitNull();
         * else
         *  row.TimeLimit = value.TimeLimit;
         *
         * if (value.IsQuestionTypeIdNull())
         *  row.SetQuestionTypeIdNull();
         * else
         *  row.QuestionTypeId = value.QuestionTypeId;
         *
         * if (value.IsQuestionSubtypeIdNull())
         *  row.SetQuestionSubtypeIdNull();
         * else
         *  row.QuestionSubtypeId = value.QuestionSubtypeId;
         *
         * return row;
         * }*/

        public static QuestionSet Create(QuestionType questionType, Connection connection)
        {
            int setId = 0;

            for (int i = 0; i < connection.TestQuestionSetSet.QuestionSets.Count; ++i)
            {
                if (setId < connection.TestQuestionSetSet.QuestionSets[i].Id)
                {
                    setId = connection.TestQuestionSetSet.QuestionSets[i].Id;
                }
            }
            setId += 1;
            TestQuestionSetSet.QuestionSetsRow row =
                connection.TestQuestionSetSet.QuestionSets.AddQuestionSetsRow(setId, "New Question Set", "", 0, 0, 0, 0,
                                                                              0, 0, 0);
            //setId,
            row.SetTimeLimitNull();

            if (!questionType.QuestionTypeId.HasValue)
            {
                row.SetQuestionTypeIdNull();
            }
            else
            {
                row.QuestionTypeId = questionType.QuestionTypeId.Value;
            }

            if (!questionType.QuestionSubtypeId.HasValue)
            {
                row.SetQuestionSubtypeIdNull();
            }
            else
            {
                row.QuestionSubtypeId = questionType.QuestionSubtypeId.Value;
            }

            QuestionSet qs = new QuestionSet(row);

            bool added = false;

            //locate where to add the question set
            foreach (Entity entity in connection.Children)
            {
                if (entity is QuestionSets)
                {
                    foreach (Entity child in entity.Children)
                    {
                        if (child.CanAddNewChild(qs))
                        {
                            child.AddNewChild(qs);
                            qs.connection = ((Connection)qs.Root);
                            added         = true;
                            break;
                        }
                    }
                    break;
                }
            }

            if (!added)
            {
                throw new Exception("Cannot find folder for new question set");
            }

            OnStructureChangedInternally();

            return(qs);
        }
Example #4
0
        internal override bool DoCanAddNewChild(Entity entity)
        {
            QuestionSet t = entity as QuestionSet;

            return(t != null && t.Value.IsQuestionTypeIdNull());
        }