Exemplo n.º 1
0
        /// <summary>
        /// The replace file place holder.
        /// </summary>
        /// <param name="text">
        /// The text.
        /// </param>
        /// <param name="fileIndex">
        /// The file index.
        /// </param>
        /// <param name="file">
        /// The file.
        /// </param>
        /// <returns>
        /// The <see cref="string"/>.
        /// </returns>
        public static string ReplaceFilePlaceHolder(string text, int fileIndex, LmsQuestionFileDTO file)
        {
            var placeHolder = string.Format("[[file_id_{0}]]", fileIndex);
            var img         = string.Format(
                "<img src=\"{0}\" width=\"{1}\" height=\"{2}\" />",
                file.fileUrl,
                file.width,
                file.height);

            return(text.Replace(placeHolder, img));
        }
Exemplo n.º 2
0
        public override LmsQuestionDTO ParseQuestion(BBQuestionDTO dto)
        {
            var lmsQuestion = base.ParseQuestion(dto);

            if (!string.IsNullOrEmpty(dto.questionImageLink) && !string.IsNullOrEmpty(dto.questionImageBinary))
            {
                var fileDto = new LmsQuestionFileDTO
                {
                    fileName      = dto.questionImageLink.Split('/').Last(),
                    fileUrl       = dto.questionImageLink,
                    base64Content = dto.questionImageBinary
                };
                lmsQuestion.files.Add(0, fileDto);
            }
            return(lmsQuestion);
        }
Exemplo n.º 3
0
        public override LmsQuestionDTO ParseQuestion(BBQuestionDTO dto)
        {
            var ret = new LmsQuestionDTO()
            {
                question_text = dto.text.ClearName(),
                question_type = dto.type,
                is_single     = singleQuestionTypes.Any(
                    x => dto.type.Equals(x, StringComparison.InvariantCultureIgnoreCase)),
                question_name = dto.title.ClearName(),
                id            = int.Parse(dto.id),
                rows          = dto.rows,
                answers       = ParseAnswers(dto)
            };

            ret.answers.ForEach(
                a =>
            {
                a.text          = a.question_text;
                a.question_text = a.question_text.ClearName();
            });
            ret.caseSensitive = ret.answers.Any(x => x.caseSensitive);

            var lmsQuestion = ret;

            if (!string.IsNullOrEmpty(dto.questionImageBinary))
            {
                var fileDto = new LmsQuestionFileDTO
                {
                    fileName      = !string.IsNullOrEmpty(dto.questionImageLink) ? dto.questionImageLink.Split('/').Last() : string.Empty,
                    fileUrl       = dto.questionImageLink,
                    base64Content = dto.questionImageBinary
                };
                lmsQuestion.files.Add(0, fileDto);
            }

            return(lmsQuestion);
        }