示例#1
0
 private QuestionSet(TestQuestionSetSet.QuestionSetsRow value) :
     base(value.Name,
          new QuestionType(
              new OptionalInteger(value.IsQuestionTypeIdNull() ? null : (Object)value.QuestionTypeId),
              new OptionalInteger(value.IsQuestionSubtypeIdNull() ? null : (Object)value.QuestionSubtypeId)))
 {
     this.value = value;
 }
示例#2
0
 public QuestionSet(TestQuestionSetSet.QuestionSetsRow value, Entity parent) :
     base(value.Name,
          new QuestionType(
              new OptionalInteger(value.IsQuestionTypeIdNull() ? null : (Object)value.QuestionTypeId),
              new OptionalInteger(value.IsQuestionSubtypeIdNull() ? null : (Object)value.QuestionSubtypeId)))
 {
     this.value = value;
     parent.AddNewChild(this);
     connection = ((Connection)Root);
 }
示例#3
0
 private void questionSetdataGridView_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
 {
     if (e.ColumnIndex == -1)
     {
         TestQuestionSetSet.QuestionSetsRow questionSetRow =
             ((Test)dbObject).GetTestTestQuestionSetSetQuestiomSetRow(
                 (int)questionSetdataGridView.SelectedRows[0].Cells[0].Value);
         QuestionSet qset = new QuestionSet(questionSetRow, (Test)(dbObject));
         ApplicationController.Instance.Edit(qset);
     }
 }
示例#4
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);
        }