public static Response Clone(Response response)
        {
            var newResponse = new Response
            {
                Text = response.Text,
                Id = Guid.NewGuid(),
                DocumentHtml = string.Copy(response.DocumentHtml)
            };

            return newResponse;
        }
        public override void Execute(object @object)
        {
            if (!Enabled)
            {
                return;
            }

            var r = new Response
                        {
                            Id = Guid.NewGuid()
                        };

            if (Warehouse.Warehouse.Instance.CourseTree.CurrentNode is Question)
            {
                var q = Warehouse.Warehouse.Instance.CourseTree.CurrentNode as Question;
                r.Text = string.Concat("Ответ ", q.Responses.Count + 1);
            }

            Warehouse.Warehouse.Instance.CourseTree.CurrentNode.Nodes.Add(r);

            if (!Warehouse.Warehouse.Instance.CourseTree.CurrentNode.IsExpanded)
            {
                Warehouse.Warehouse.Instance.CourseTree.CurrentNode.Toggle();
            }

            // Создает и отображает редактор.
            r.ResponseDocument = new ResponseDocument
                                     {
                                         Response = r,
                                         Text = r.Text,
                                         HtmlEditingTool =
                                             {Mode = Utils.Controls.HtmlEditing.Enums.HtmlEditingToolMode.Design}
                                     };

            //r.ResponseDocument.VisualHtmlEditor.SetDefaultFont();
            HtmlEditingToolHelper.SetDefaultDocumentHtml(r.ResponseDocument.HtmlEditingTool);
            PreviewObserver.AddDocument(r.ResponseDocument);
            r.ResponseDocument.Show();

            Warehouse.Warehouse.Instance.CourseTree.CurrentNode = r;
            Warehouse.Warehouse.IsProjectModified = true;
        }
        /// <summary>
        /// Чтение информации из файла формата IMS QTI 2.1.
        /// </summary>
        /// <param name="qfPath">Путь к файлу.</param>
        public override bool ReadQti(string qfPath)
        {
            XmlTextReader reader = new XmlTextReader(qfPath);
            bool result = true;
            Id = Guid.NewGuid();
            string HtmlText = "<HTML>\n<HEAD>\n<BASE href=\"" + Application.StartupPath + // раньше было определено где-то там
                "\\\">\n</HEAD>\n<BODY>\n<P>";

            try
            {
                //"вынимаем" элементы ответа 
                while (reader.Read())
                {
                    if (reader.NodeType == XmlNodeType.Element)
                    {
                        if (reader.Name.Equals("simpleChoice"))
                        {
                            Response r = new Response();
                            r.DocumentHtml = "<HTML>\n<HEAD>\n<BASE href=\"" + Application.StartupPath +
                                         "\\\">\n</HEAD>\n<BODY>\n<P>";
                            if (reader.GetAttribute("identifier") != null)
                            {
                                try
                                {
                                    r.Id = Guid.NewGuid();//new Guid(reader.GetAttribute("identifier"));
                                    r.Text = reader.GetAttribute("identifier");
                                    r.Identifier = reader.GetAttribute("identifier");
                                }
                                catch
                                {
                                    r.Identifier = reader.GetAttribute("identifier");
                                    r.Id = Guid.NewGuid();
                                    r.Text = reader.GetAttribute("identifier");
                                }
                            }
                            if (reader.GetAttribute("fixed") != null)
                            {
                                r.IsFixed = bool.Parse(reader.GetAttribute("fixed"));
                            }
                            string s = reader.ReadInnerXml();
                            r.DocumentHtml += ConvertXmlStringToHtml(s, qfPath);
                            r.DocumentHtml += "</P>\n</BODY>\n</HTML>";
                            // реализовать 
                            //  r.FillImagesArray();
                            // this.Responses.Add(r);
                            Nodes.Add(r);
                            //  Responses.Add(r);
                        }
                    }
                }
                reader.Close();

                //затем "вынимаем" всё остальное
                reader = new XmlTextReader(qfPath);
                while (reader.Read())
                {
                    if (reader.NodeType == XmlNodeType.Element)
                    {
                        if (reader.Name.Equals("assessmentItem", StringComparison.OrdinalIgnoreCase))
                        {
                            if (reader.GetAttribute("timeDependent") != null)
                            {
                                bool.TryParse(reader.GetAttribute("timeDependent"), out isTimeDependent);
                            }
                            if (reader.GetAttribute("identifier") != null)
                            {
                                identifier = reader.GetAttribute("identifier"); //был с заглавной
                            }
                            if (reader.GetAttribute("adaptive") != null)
                            {
                                bool.TryParse(reader.GetAttribute("adaptive"), out isAdaptive);
                            }
                            if (reader.GetAttribute("title") != null)
                            {
                                Text = reader.GetAttribute("title");
                            }
                            else Text = reader.GetAttribute("identifier");
                        }

                        if (reader.Name.Equals("correctResponse", StringComparison.OrdinalIgnoreCase))
                        {
                            bool endCycle = false;
                            ResponseVariant rv = new ResponseVariant(this);
                            rv.Weight = 1.0;

                            while (!endCycle && reader.Read())
                            {
                                if (reader.Name.Equals("value", StringComparison.OrdinalIgnoreCase))
                                {
                                    string value = reader.ReadString();
                                    foreach (Response response in Responses)
                                    {
                                        if ((response.Id.ToString() == value) || response.Identifier == value)
                                        {
                                            rv.Responses.Add(response);
                                        }
                                    }
                                }
                                else if (reader.NodeType == XmlNodeType.EndElement)
                                {
                                    if (reader.Name.Equals("correctResponse", StringComparison.OrdinalIgnoreCase))
                                    {
                                        endCycle = true;
                                    }
                                }
                            }
                            ResponseVariants.Add(rv);
                        }

                        if (reader.Name.Equals("mapping", StringComparison.OrdinalIgnoreCase))
                        {
                            if (reader.GetAttribute("lowerBound") != null)
                                LowerBound = int.Parse(reader.GetAttribute("lowerBound"));
                            if (reader.GetAttribute("upperBound") != null)
                                Marks = int.Parse(reader.GetAttribute("upperBound"));
                            if (reader.GetAttribute("defaultValue") != null)
                                DefaultValue = int.Parse(reader.GetAttribute("defaultValue"));
                        }

                        if (reader.Name.Equals("mapEntry", StringComparison.OrdinalIgnoreCase))
                        {
                            foreach (Response response in Responses)
                            {
                                if (response.Id.ToString() == reader.GetAttribute("mapKey"))
                                {
                                    if (reader.GetAttribute("mappedValue") != null)
                                    {
                                        string s = reader.GetAttribute("mappedValue");
                                        // разделитель, используемый в системе
                                        string decimalSeparator = NumberFormatInfo.CurrentInfo.CurrencyDecimalSeparator;
                                        // подменяем точки и запятые на разделитель, используемый в системе, чтобы преобразовать строку в число без ошибок
                                        s = s.Replace(".", decimalSeparator);
                                        s = s.Replace(",", decimalSeparator);
                                        double d;
                                        Double.TryParse(s, out d);
                                        response.MappedValue = d;
                                    }
                                }
                            }
                        }

                        if (reader.Name.Equals("itemBody", StringComparison.OrdinalIgnoreCase))
                        {
                            // считываем содержимое тега itemBody
                            while (!reader.Name.Equals("choiceInteraction", StringComparison.OrdinalIgnoreCase) && reader.Read())
                            {
                                if (reader.Name.Equals("p", StringComparison.OrdinalIgnoreCase))
                                {
                                    string xml = reader.ReadInnerXml();
                                    string html = ConvertXmlStringToHtml(xml, qfPath);
                                    if (html != " ")
                                    {
                                        HtmlText += "<P>" + html + "</P>";
                                    }
                                }

                                if (reader.Name.Equals("img", StringComparison.OrdinalIgnoreCase))
                                {
                                    try
                                    {
                                        // создаём папку для картинок проекта
                                        if (!Directory.Exists(Warehouse.Warehouse.RelativeImagesDirectory))
                                        {
                                            Directory.CreateDirectory(Warehouse.Warehouse.RelativeImagesDirectory);
                                        }
                                        // копируем туда картинку
                                        var destPath = Path.Combine(Warehouse.Warehouse.AbsoluteEditorImagesDirectory, Path.GetFileName(reader.GetAttribute("src")));

                                        // var destPath = Path.Combine(Warehouse.Warehouse.AbsoluteEditorImagesDirectory, Path.GetFileName(reader.GetAttribute("src")));
                                        File.Copy(Path.GetDirectoryName(qfPath) + "\\" + reader.GetAttribute("src"), destPath, true);
                                        // var inner = TagNames.ImageTagName;
                                        string height = reader.GetAttribute("height");
                                        string width = reader.GetAttribute("width");
                                        string align = reader.GetAttribute("align");
                                        string border = reader.GetAttribute("border");
                                        string hspace = reader.GetAttribute("hspace");
                                        string sf = Path.Combine(Warehouse.Warehouse.RelativeImagesDirectory, Path.GetFileName(reader.GetAttribute("src")));
                                        HtmlText += "<IMG" + " border=\"" + border + "\" hspace=\"" + hspace + "\" align=\"" + align + "\" sdocument=\"0\" src=\"" + sf + "\" height=\"" + height + "\" width=\"" + width + "\"" + ">";
                                    }
                                    catch (FileNotFoundException)
                                    {
                                        MessageBox.Show("Изображение " + reader.GetAttribute("src") + " не найдено.",
                                                        "Visual Editor",
                                                        MessageBoxButtons.OK,
                                                        MessageBoxIcon.Error);
                                    }
                                }
                                #region самодеятельность с медиа
                                if (reader.Name.Equals("object", StringComparison.OrdinalIgnoreCase))
                                {
                                    try
                                    {
                                        if (Path.GetExtension(Path.GetFileName(reader.GetAttribute("data"))) == ".mp4" || Path.GetExtension(Path.GetFileName(reader.GetAttribute("data"))) == ".flv")
                                        {
                                            if (!Directory.Exists(Warehouse.Warehouse.RelativeVideosDirectory))
                                            {
                                                Directory.CreateDirectory(Warehouse.Warehouse.RelativeVideosDirectory);
                                            }
                                            // копируем туда картинку
                                            string data = reader.GetAttribute("data");
                                            var destPath = Path.Combine(Warehouse.Warehouse.AbsoluteEditorVideosDirectory, Path.GetFileName(data));
                                            var sourcePath = Path.Combine(Path.GetDirectoryName(qfPath), Path.GetFileName(data));

                                            File.Copy(sourcePath, destPath, true);

                                            string asf = Path.Combine(Warehouse.Warehouse.RelativeImagesDirectory, Path.GetFileName("\\Images\\Vid.png"));
                                            string sf = Path.Combine(Warehouse.Warehouse.RelativeVideosDirectory, Path.GetFileName(data));
                                            HtmlText += string.Concat("<IMG src=\"" + asf + "\" width=\"16\" height=\"16\" sdocument=\"0\" src_=\"" + sf + "\" >");
                                        }

                                        else if (Path.GetExtension(Path.GetFileName(reader.GetAttribute("data"))) == ".mp3")
                                        {
                                            if (!Directory.Exists(Warehouse.Warehouse.RelativeAudiosDirectory))
                                            {
                                                Directory.CreateDirectory(Warehouse.Warehouse.RelativeAudiosDirectory);
                                            }
                                            // копируем туда картинку
                                            var destPath = Path.Combine(Warehouse.Warehouse.AbsoluteEditorAudiosDirectory, Path.GetFileName(reader.GetAttribute("data")));
                                            var sourcePath = Path.Combine(Path.GetDirectoryName(qfPath), Path.GetFileName(reader.GetAttribute("data")));

                                            File.Copy(sourcePath, destPath, true);

                                            string asf = Path.Combine(Warehouse.Warehouse.RelativeImagesDirectory, Path.GetFileName("\\Images\\Aud.png"));
                                            string sf = Path.Combine(Warehouse.Warehouse.RelativeAudiosDirectory, Path.GetFileName(reader.GetAttribute("data")));

                                            HtmlText += string.Concat("<IMG src=\"" + asf + "\" width=\"16\" height=\"16\" sdocument=\"0\" src_=\"" + sf + "\" >");
                                        }

                                        else if (Path.GetExtension(Path.GetFileName(reader.GetAttribute("data"))) == ".swf")
                                        {
                                            if (!Directory.Exists(Warehouse.Warehouse.RelativeFlashesDirectory))
                                            {
                                                Directory.CreateDirectory(Warehouse.Warehouse.RelativeFlashesDirectory);
                                            }
                                            // копируем туда картинку
                                            string data = reader.GetAttribute("data");
                                            var destPath = Path.Combine(Warehouse.Warehouse.AbsoluteEditorFlashesDirectory, Path.GetFileName(data));
                                            var sourcePath = Path.Combine(Path.GetDirectoryName(qfPath), Path.GetFileName(data));

                                            File.Copy(sourcePath, destPath, true);

                                            string asf = Path.Combine(Warehouse.Warehouse.RelativeImagesDirectory, Path.GetFileName("\\Images\\Anim.png"));
                                            string sf = Path.Combine(Warehouse.Warehouse.RelativeFlashesDirectory, Path.GetFileName(data));
                                            HtmlText += string.Concat("<IMG src=\"" + asf + "\" width=\"16\" height=\"16\" sdocument=\"0\" src_=\"" + sf + "\" >");

                                        }
                                    }
                                    catch (FileNotFoundException)
                                    {
                                        MessageBox.Show("Изображение " + reader.GetAttribute("src") + " не найдено.",
                                                        "Visual Editor",
                                                        MessageBoxButtons.OK,
                                                        MessageBoxIcon.Error);
                                    }
                                }
                                #endregion
                            }
                        }

                        if (reader.Name.Equals("choiceInteraction", StringComparison.OrdinalIgnoreCase))
                        {
                            if (reader.GetAttribute("responseIdentifier") != null)
                            {
                                identifier = reader.GetAttribute("responseIdentifier");
                            }
                            if (reader.GetAttribute("shuffle") != null)
                            {
                                IsShuffle = bool.Parse(reader.GetAttribute("shuffle"));
                            }
                            if (reader.GetAttribute("maxChoices") != null)
                            {
                                MaxChoices = int.Parse(reader.GetAttribute("maxChoices"));
                            }
                        }

                        if (reader.Name.Equals("prompt", StringComparison.OrdinalIgnoreCase))
                        {
                            string s = reader.ReadInnerXml();
                            HtmlText += "<P>" + ConvertXmlStringToHtml(s, qfPath) + "</P>";
                        }
                        //////////////////////                     \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
                       /*
                        if (reader.Name.Equals("object", StringComparison.OrdinalIgnoreCase))
                        {
                            try
                            {
                                if (Path.GetExtension(Path.GetFileName(reader.GetAttribute("data"))) == ".mp4" || Path.GetExtension(Path.GetFileName(reader.GetAttribute("data"))) == ".flv")
                                {
                                    if (!Directory.Exists(Warehouse.Warehouse.RelativeVideosDirectory))
                                    {
                                        Directory.CreateDirectory(Warehouse.Warehouse.RelativeVideosDirectory);
                                    }
                                    // копируем туда картинку
                                    // копируем туда картинку
                                    string data = reader.GetAttribute("data");
                                    var destPath = Path.Combine(Warehouse.Warehouse.AbsoluteEditorVideosDirectory, Path.GetFileName(data));
                                    var sourcePath = Path.Combine(Path.GetDirectoryName(qfPath), Path.GetFileName(data));

                                    File.Copy(sourcePath, destPath, true);

                                    string asf = Path.Combine(Warehouse.Warehouse.RelativeImagesDirectory, Path.GetFileName("\\Images\\Vid.png"));
                                    string sf = Path.Combine(Warehouse.Warehouse.RelativeVideosDirectory, Path.GetFileName(data));
                                    HtmlText += string.Concat("<IMG src=\"" + asf + "\" width=\"16\" height=\"16\" sdocument=\"0\" src_=\"" + sf + "\" >");
                                }

                                else if (Path.GetExtension(Path.GetFileName(reader.GetAttribute("data"))) == ".mp3")
                                {
                                    if (!Directory.Exists(Warehouse.Warehouse.RelativeAudiosDirectory))
                                    {
                                        Directory.CreateDirectory(Warehouse.Warehouse.RelativeAudiosDirectory);
                                    }
                                    // копируем туда картинку
                                    var destPath = Path.Combine(Warehouse.Warehouse.AbsoluteEditorAudiosDirectory, Path.GetFileName(reader.GetAttribute("data")));
                                    var sourcePath = Path.Combine(Path.GetDirectoryName(qfPath), Path.GetFileName(reader.GetAttribute("data")));

                                    File.Copy(sourcePath, destPath, true);

                                    string asf = Path.Combine(Warehouse.Warehouse.RelativeImagesDirectory, Path.GetFileName("\\Images\\Aud.png"));
                                    string sf = Path.Combine(Warehouse.Warehouse.RelativeAudiosDirectory, Path.GetFileName(reader.GetAttribute("data")));

                                    HtmlText += string.Concat("<IMG src=\"" + asf + "\" width=\"16\" height=\"16\" sdocument=\"0\" src_=\"" + sf + "\" >");
                                }

                                else if (Path.GetExtension(Path.GetFileName(reader.GetAttribute("data"))) == ".swf")
                                {
                                    if (!Directory.Exists(Warehouse.Warehouse.RelativeFlashesDirectory))
                                    {
                                        Directory.CreateDirectory(Warehouse.Warehouse.RelativeFlashesDirectory);
                                    }
                                    // копируем туда картинку
                                    string data = reader.GetAttribute("data");
                                    var destPath = Path.Combine(Warehouse.Warehouse.AbsoluteEditorFlashesDirectory, Path.GetFileName(data));
                                    var sourcePath = Path.Combine(Path.GetDirectoryName(qfPath), Path.GetFileName(data));

                                    File.Copy(sourcePath, destPath, true);

                                    string asf = Path.Combine(Warehouse.Warehouse.RelativeImagesDirectory, Path.GetFileName("\\Images\\Anim.png"));
                                    string sf = Path.Combine(Warehouse.Warehouse.RelativeFlashesDirectory, Path.GetFileName(data));
                                    HtmlText += string.Concat("<IMG src=\"" + asf + "\" width=\"16\" height=\"16\" sdocument=\"0\" src_=\"" + sf + "\" >");

                                }
                            }
                            catch (FileNotFoundException)
                            {
                                MessageBox.Show("Изображение " + reader.GetAttribute("src") + " не найдено.",
                                                "Visual Editor",
                                                MessageBoxButtons.OK,
                                                MessageBoxIcon.Error);
                            }
                        }*/
                        ////////////////////----------------------------------------------------------------

                        if (reader.Name.Equals("responseIf", StringComparison.OrdinalIgnoreCase) ||
                            reader.Name.Equals("responseElseIf", StringComparison.OrdinalIgnoreCase) ||
                            reader.Name.Equals("responseElse", StringComparison.OrdinalIgnoreCase))
                        {
                            ArrayList list = new ArrayList(0);
                            string mark = string.Empty;
                            bool endCycle = false;
                            string name = reader.Name;

                            while (!endCycle && reader.Read())
                            {
                                if (reader.Name.Equals("baseValue", StringComparison.OrdinalIgnoreCase))
                                {
                                    if (reader.GetAttribute("baseType").Equals("identifier", StringComparison.OrdinalIgnoreCase))
                                    {
                                        string response = reader.ReadString();
                                        // разбиваем строку на слова
                                        Match match = Regex.Match(response, @"\w+");
                                        // цикл по всем словам
                                        while (match.Success)
                                        {
                                            list.Add(match.ToString());
                                            match = match.NextMatch();
                                        }
                                    }
                                    else if (reader.GetAttribute("baseType").Equals("integer", StringComparison.OrdinalIgnoreCase) ||
                                             reader.GetAttribute("baseType").Equals("float", StringComparison.OrdinalIgnoreCase))
                                    {
                                        if (name.Equals("responseIf", StringComparison.OrdinalIgnoreCase))
                                        {
                                            string m = reader.ReadString();
                                            m = m.Replace(".", NumberFormatInfo.CurrentInfo.CurrencyDecimalSeparator);
                                            m = m.Replace(",", NumberFormatInfo.CurrentInfo.CurrencyDecimalSeparator);
                                            Marks = int.Parse(m);// Double.Parse(m);
                                            mark = m;
                                        }
                                        else
                                        {
                                            mark = reader.ReadString();
                                        }
                                    }
                                }
                                else if (reader.NodeType == XmlNodeType.EndElement)
                                {
                                    if (reader.Name.Equals(name, StringComparison.OrdinalIgnoreCase))
                                    {
                                        endCycle = true;
                                    }
                                }
                            }

                            if (list.Count > 0)
                            {
                                ResponseVariant rv = new ResponseVariant(this);
                                foreach (Response r in Responses)
                                {
                                    foreach (string id in list)
                                    {
                                        if (r.Identifier == id && !rv.Responses.Contains(id))
                                        {
                                            rv.Responses.Add(r);
                                        }
                                    }
                                }
                                if (mark != string.Empty)
                                {
                                    if (!name.Equals("responseElse", StringComparison.OrdinalIgnoreCase))
                                    {
                                        mark = mark.Replace(".", NumberFormatInfo.CurrentInfo.CurrencyDecimalSeparator);
                                        mark = mark.Replace(",", NumberFormatInfo.CurrentInfo.CurrencyDecimalSeparator);
                                        if (Marks != 0)
                                            rv.Weight = Double.Parse(mark) / Marks;
                                        else rv.Weight = 0;
                                    }
                                }
                                ResponseVariants.Add(rv);
                            }
                        }
                    }
                }
            }
            catch
            {
                MessageBox.Show("При чтении файла вопроса произошла ошибка. (" + qfPath + ")",
                                "Visual Editor",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
                result = false;
            }
            finally
            {
                reader.Close();
                HtmlText += "</P>\n</BODY>\n</HTML>";
                //решить 
                //FillImagesArray();
            }

            // мои художества
            this.DocumentHtml = HtmlText;

            success = true;
            return result;
        }
 public ResponseXmlReader(Response response)
 {
     this.response = response;
 }
        public override void ReadXml(XmlTextReader xmlReader)
        {
            try
            {
                var isEndCycle = false;

                while (!isEndCycle && xmlReader.Read())
                {
                    if (xmlReader.NodeType == XmlNodeType.Element)
                    {
                        #region Контент вопроса

                        if (xmlReader.Name.Equals("html_text"))
                        {
                            var s = xmlReader.ReadElementString();
                            if (s != null)
                            {
                                question.DocumentHtml = XmlToHtml(s);
                            }
                        }

                        #endregion

                        #region Ответ

                        if (xmlReader.Name.Equals("answer"))
                        {
                            var r = new Response
                            {
                                Text = string.Concat("Ответ ", question.Responses.Count + 1)
                            };

                            r.XmlReader.ReadXml(xmlReader);
                            question.Nodes.Add(r);

                            try
                            {
                                //r.Id = new Guid(xmlReader.GetAttribute("id"));
                                r.Id = Guid.NewGuid();
                                r.NativeId = string.Concat("a", question.Responses.Count);
                            }
                            catch
                            {
                                //r.Identifier = reader.GetAttribute("id");
                            }
                        }

                        #endregion

                        #region Варианты ответа

                        if (xmlReader.Name.Equals("answer_variants"))
                        {
                            question.ResponseVariants.Add(new ResponseVariant(question));
                            //((ResponseVariant)responseVariants[responseVariants.Count - 1]).Type = reader.GetAttribute("type");
                            var weight = xmlReader.GetAttribute("weight");

                            var NQ = "";

                            
                            if (xmlReader.GetAttribute("next_question") != null)
                            {

                                NQ = xmlReader.GetAttribute("next_question");
                            }


                            // заменяем точки и запятые на действующия в системе разделитель, чтобы не было проблем с преобразованием в double
                            weight = weight.Replace(".", NumberFormatInfo.CurrentInfo.CurrencyDecimalSeparator);
                            weight = weight.Replace(",", NumberFormatInfo.CurrentInfo.CurrencyDecimalSeparator);
                            ((ResponseVariant)question.ResponseVariants[question.ResponseVariants.Count - 1]).Weight = double.Parse(weight);

                            ((ResponseVariant)question.ResponseVariants[question.ResponseVariants.Count - 1]).NextQuestion = NQ;


                            ((ResponseVariant)question.ResponseVariants[question.ResponseVariants.Count - 1]).XmlReader.ReadXml(xmlReader);
                        }

                        #endregion

                        #region Подсказка

                        if (xmlReader.Name.Equals("hint", StringComparison.OrdinalIgnoreCase))
                        {
                            try
                            {
                                var s = xmlReader.ReadString();
                                if (s != null)
                                {
                                    question.Hint = XmlToHtml(s);
                                }
                            }
                            catch { }
                        }

                        #endregion

                        if (xmlReader.Name.Equals("mark"))
                        {
                            question.Marks = int.Parse(xmlReader.GetAttribute("value"));

                            try
                            {
                                var id = new Guid(xmlReader.GetAttribute("concept_id").Substring(6, 36));

                                foreach (Concept c in Warehouse.Warehouse.Instance.ConceptTree.Nodes)
                                {
                                    if (c.Id.Equals(id))
                                    {
                                        question.Profile = c;

                                        break;
                                    }
                                }
                            }
                            catch
                            {
                                question.Profile = null;
                            }
                        }
                    }
                    else if (xmlReader.NodeType == XmlNodeType.EndElement)
                    {
                        if (xmlReader.Name.ToLower().Equals("question"))
                        {
                            isEndCycle = true;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                ExceptionManager.Instance.LogException(ex);
            }
        }
        private static ResponseDocument CreateResponseDocument(Response r)
        {
            r.ResponseDocument = new ResponseDocument
                                     {
                                         Response = r,
                                         Text = r.Text,
                                         HtmlEditingTool =
                                             {Mode = Utils.Controls.HtmlEditing.Enums.HtmlEditingToolMode.Design}
                                     };

            //r.ResponseDocument.VisualHtmlEditor.SetDefaultFont();
            HtmlEditingToolHelper.SetDefaultDocumentHtml(r.ResponseDocument.HtmlEditingTool);
            r.ResponseDocument.HtmlEditingTool.BodyInnerHtml = r.DocumentHtml;
            r.ResponseDocument.HtmlEditingTool.SetDefaultHtml();
            // Блокирует команду Undo.
            //r.ResponseDocument.HtmlEditingTool.Mode = Utils.Controls.HtmlEditing.Enums.HtmlEditingToolMode.Preview;
            r.ResponseDocument.HtmlEditingTool.Mode = Utils.Controls.HtmlEditing.Enums.HtmlEditingToolMode.Design;
            r.ResponseDocument.Show();

            if (r.Text.Length > 22)
            {
                r.ResponseDocument.Text = r.Text.Substring(0, 22) + "...";
            }
            else
            {
                r.ResponseDocument.Text = r.Text;
            }

            return r.ResponseDocument;
        }