Example #1
0
        public override RecordCardContent EntnehmeContent()
        {
            RecordCardAufzaehlungContent content = new RecordCardAufzaehlungContent();

            content.QuestionAufzaehlung = txtBoxTextFrage.Text;
            foreach (var item in listBoxAntwort.Items)
            {
                content.FuegeAntwortHinzu(item.ToString());
            }
            return(content);
        }
        private static void DeserialisiereRecordCards(RecordcardSet recordcardSet, XmlElement recordcardsetNode)
        {
            foreach (XmlElement recordcardnode in recordcardsetNode.GetElementsByTagName("recordcard"))
            {
                if (recordcardnode.Name == "recordcard")
                {
                    Recordcard recordcard = new Recordcard();
                    recordcard.Thema = recordcardnode.GetAttribute("topic");
                    String type = recordcardnode.GetAttribute("type");

                    if (type == "Text")
                    {
                        RecordCardTextContent recordCardContentText = new RecordCardTextContent();

                        XmlNodeList questionNodes = recordcardnode.GetElementsByTagName("questionText");
                        XmlNodeList answerNodes = recordcardnode.GetElementsByTagName("answerText");
                        XmlElement  questionNode = null, answerNode = null;

                        if (questionNodes.Count > 0)
                        {
                            questionNode = (XmlElement)questionNodes.Item(0);
                            recordCardContentText.QuestionText = questionNode.InnerText;
                        }

                        if (answerNodes.Count > 0)
                        {
                            answerNode = (XmlElement)answerNodes.Item(0);
                            recordCardContentText.AnswerText = answerNode.InnerText;
                        }

                        recordcard.content = recordCardContentText;
                    }
                    else if (type == "Abbildung")
                    {
                        RecordCardAbbildungContent content = new RecordCardAbbildungContent();

                        XmlNodeList questionNodes = recordcardnode.GetElementsByTagName("questionAbbildung");
                        XmlNodeList answerNodes = recordcardnode.GetElementsByTagName("answerAbbildung");
                        XmlElement  questionNode = null, answerNode = null;

                        if (questionNodes.Count > 0)
                        {
                            questionNode = (XmlElement)questionNodes.Item(0);
                            content.QuestionAbbildung = questionNode.InnerText;
                        }

                        if (answerNodes.Count > 0)
                        {
                            answerNode        = (XmlElement)answerNodes.Item(0);
                            content.ImagePath = answerNode.InnerText;
                        }

                        recordcard.content = content;
                    }
                    else if (type == "Aufzaehlung")
                    {
                        RecordCardAufzaehlungContent content = new RecordCardAufzaehlungContent();


                        XmlNodeList questionNodes = recordcardnode.GetElementsByTagName("questionAufzaehlung");
                        XmlNodeList answerNodes = recordcardnode.GetElementsByTagName("answerAufzaehlung");
                        XmlElement  questionNode = null, answerNode = null;

                        if (questionNodes.Count > 0)
                        {
                            questionNode = (XmlElement)questionNodes.Item(0);
                            content.QuestionAufzaehlung = questionNode.InnerText;
                        }

                        if (answerNodes.Count > 0)
                        {
                            answerNode = (XmlElement)answerNodes.Item(0);
                            foreach (XmlElement answerItem in answerNode.GetElementsByTagName("item"))
                            {
                                content.FuegeAntwortHinzu(answerItem.InnerText);
                            }
                        }

                        recordcard.content = content;
                    }
                    else if (type == "MultipleChoice")
                    {
                        RecordCardMultipleChoiceContent content = new RecordCardMultipleChoiceContent();

                        XmlNodeList questionNodes = recordcardnode.GetElementsByTagName("questionMultipleChoice");
                        XmlNodeList choicesNodes = recordcardnode.GetElementsByTagName("choicesMultipleChoice");
                        XmlNodeList answerNodes = recordcardnode.GetElementsByTagName("answerMultipleChoice");
                        XmlElement  questionNode = null, answerNode = null, choiceNode = null;

                        if (questionNodes.Count > 0)
                        {
                            questionNode = (XmlElement)questionNodes.Item(0);
                            content.QuestionMultipleChoice = questionNode.InnerText;
                        }

                        if (choicesNodes.Count > 0)
                        {
                            choiceNode = (XmlElement)choicesNodes.Item(0);
                            foreach (XmlElement choiceItem in choiceNode.GetElementsByTagName("item"))
                            {
                                content.FuegeMultipleChoiceWertHinzu(choiceItem.InnerText);
                            }
                        }

                        if (answerNodes.Count > 0)
                        {
                            answerNode = (XmlElement)answerNodes.Item(0);
                            content.AnswerMultipleChoice = answerNode.InnerText;
                        }
                        recordcard.content = content;
                    }

                    recordcardSet.RecordcardList.Add(recordcard);
                }
            }
        }