public CreateSentenceWindowVM(ControlConstructSchemeVM controlConstructScheme, Statement statement) { this.controlConstructScheme = controlConstructScheme; this.statement = new Statement() { No = statement.No, Text = statement.Text }; }
public StatementVM(Statement statement) : base(statement) { this.statement = statement; }
private void InsertStatementConstruct(Statement statementModel) { statementModel.No = ControlConstructScheme.STATEMENT_NO_PREFIX + (ConstructUtils.StatementCount(constructs) + 1); StatementVM statement = new StatementVM(statementModel); InsertConstruct(statement, true); }
public static ControlConstructScheme CreateControlConstructScheme(XElement controlConstructSchemeElem, StudyUnit studyUnit) { string id = (string)controlConstructSchemeElem.Attribute(ATTR_ID); if (id == null) { return null; } ControlConstructScheme controlConstructSchemeModel = new ControlConstructScheme(); controlConstructSchemeModel.Title = (string)controlConstructSchemeElem.Element(d + TAG_CONTROL_CONSTRUCT_SCHEME_NAME); IEnumerable<XElement> questionConstructElems = controlConstructSchemeElem.Elements(d + TAG_QUESTION_CONSTRUCT); foreach (XElement questionConstructElem in questionConstructElems) { string questionConstructId = (string)questionConstructElem.Attribute(ATTR_ID); if (questionConstructId == null) { continue; } string questionId = ReadReferenceID(questionConstructElem, d + TAG_QUESTION_REFERENCE); if (questionId == null) { continue; } string no = (string)questionConstructElem.Element(r + TAG_LABEL); if (no == null) { continue; } if (studyUnit.FindQuestion(questionId) != null) { QuestionConstruct questionConstruct = new QuestionConstruct(); questionConstruct.Id = questionConstructId; questionConstruct.No = no; questionConstruct.QuestionId = questionId; controlConstructSchemeModel.QuestionConstructs.Add(questionConstruct); } else if (studyUnit.FindQuestionGroup(questionId) != null) { QuestionGroupConstruct questionGroupConstruct = new QuestionGroupConstruct(); questionGroupConstruct.Id = questionConstructId; questionGroupConstruct.No = no; questionGroupConstruct.QuestionGroupId = questionId; controlConstructSchemeModel.QuestionGroupConstructs.Add(questionGroupConstruct); } } IEnumerable<XElement> statementItemElems = controlConstructSchemeElem.Elements(d + TAG_STATEMENT_ITEM); foreach (XElement statementItemElem in statementItemElems) { string statementId = (string)statementItemElem.Attribute(ATTR_ID); if (statementId == null) { continue; } string no = (string)statementItemElem.Attribute(r + TAG_LABEL); if (no == null) { continue; } Statement statement = new Statement(); statement.Id = statementId; statement.No = no; XElement textElem = statementItemElem.Descendants(d + TAG_TEXT).FirstOrDefault(); if (textElem != null) { statement.Text = textElem.Value; } controlConstructSchemeModel.Statements.Add(statement); } IEnumerable<XElement> ifThenElseElems = controlConstructSchemeElem.Elements(d + TAG_IF_THEN_ELSE); foreach (XElement ifThenElseElem in ifThenElseElems) { string ifThenElseId = (string)ifThenElseElem.Attribute(ATTR_ID); if (ifThenElseId == null) { continue; } XElement ifConditionElem = ifThenElseElem.Element(d + TAG_IF_CONDITION); if (ifConditionElem == null) { continue; } string thenConstructId = ReadReferenceID(ifThenElseElem, d + TAG_THEN_CONSTRUCT_REFERENCE); if (thenConstructId == null) { continue; } IfThenElse ifThenElse = new IfThenElse(); ifThenElse.Id = ifThenElseId; ifThenElse.No = ControlConstructScheme.IFTHENELSE_NO; ifThenElse.IfCondition.Code = (string)ifConditionElem.Element(r + TAG_CODE); ifThenElse.IfCondition.QuestionId = ReadReferenceID(ifConditionElem, r + TAG_SOURCE_QUESTION_REFERENCE); ifThenElse.ThenConstructId = thenConstructId; controlConstructSchemeModel.IfThenElses.Add(ifThenElse); IEnumerable<XElement> elseIfElems = ifThenElseElem.Elements(d + TAG_ELSE_IF); foreach (XElement elseIfElem in elseIfElems) { XElement ifConditionElem2 = elseIfElem.Element(d + TAG_IF_CONDITION); if (ifConditionElem2 == null) { continue; } string thenConstructId2 = ReadReferenceID(elseIfElem, d + TAG_THEN_CONSTRUCT_REFERENCE); if (thenConstructId2 == null) { continue; } ElseIf elseIf = new ElseIf(); elseIf.IfCondition.Code = (string)ifConditionElem2.Element(r + TAG_CODE); elseIf.IfCondition.QuestionId = ReadReferenceID(ifConditionElem2, r + TAG_SOURCE_QUESTION_REFERENCE); elseIf.ThenConstructId = thenConstructId2; ifThenElse.ElseIfs.Add(elseIf); } } XElement sequenceElem = controlConstructSchemeElem.Element(d + TAG_SEQUENCE); if (sequenceElem != null) { controlConstructSchemeModel.Sequence.Id = (string)sequenceElem.Attribute(ATTR_ID); IEnumerable<XElement> controlConstructReferenceElems = sequenceElem.Elements(d + TAG_CONTROL_CONSTRUCT_REFERENCE); foreach (XElement controlConstructReferenceElem in controlConstructReferenceElems) { string controlConstructId = (string)controlConstructReferenceElem.Element(r + TAG_ID); if (controlConstructId != null) { controlConstructSchemeModel.Sequence.ControlConstructIds.Add(controlConstructId); } } } return controlConstructSchemeModel; }