using System;
using System.Collections.Generic;
using System.Text;

namespace QuestionSwapDoc.SwapWordModel
{
    /// <summary>
    /// 合并试题的项
    /// </summary>
    public class SwapWordJoinQueItem
    {
        /// <summary>
        /// 有关于这个题的数据
        /// </summary>
        public string Data { get; set; }
        /// <summary>
        /// 题型
        /// </summary>
        public string TiXinStr { get; set; }
        /// <summary>
        /// 网页中的图片的左边的路径（和图片路径拼接成绝对路径）
        /// </summary>
        public string ImgLinkLeftPath { get; set; }
        /// <summary>
        /// 是否为选择题题型（包括单选，多选）
        /// </summary>
        public bool IsXuanZhe { get; set; } = false;
        /// <summary>
        /// 是否为判断题题型
        /// </summary>
        public bool IsPanDuan { get; set; } = false;

        /// <summary>
        /// 题（题=题干+选项）
        /// </summary>
        public SwapQueContent TiRange { get; set; } = new SwapQueContent();
        /// <summary>
        /// 答案
        /// </summary>
        public SwapQueContent DaAnRange { get; set; } = new SwapQueContent();
        /// <summary>
        /// 解析
        /// </summary>
        public SwapQueContent JieXiRange { get; set; } = new SwapQueContent();

        /// <summary>
        /// html转为文件绝对路径
        /// </summary>
        public static void QueHtmlContentToFile(List<SwapWordJoinQueItem> ques)
        {
            foreach (var que in ques)
            {
                //题
                if (que.TiRange != null)
                    que.TiRange.HtmlTextToFile(que.ImgLinkLeftPath);
                //答案
                if (que.DaAnRange != null)
                    //非选择判断
                    if (!que.IsXuanZhe && !que.IsPanDuan)
                        que.DaAnRange.HtmlTextToFile(que.ImgLinkLeftPath);
                //解析
                if (que.JieXiRange != null)
                    que.JieXiRange.HtmlTextToFile(que.ImgLinkLeftPath);
            }
        }

        /// <summary>
        /// html文件转为html内容文本
        /// </summary>
        public static void QueHtmlFileToContent(List<SwapWordJoinQueItem> ques)
        {
            foreach (var que in ques)
            {
                //题
                if (que.TiRange != null)
                    que.TiRange.HtmlFileToText();
                //答案
                if (que.DaAnRange != null)
                    //非选择判断
                    if (!que.IsXuanZhe && !que.IsPanDuan)
                        que.DaAnRange.HtmlFileToText();
                //解析
                if (que.JieXiRange != null)
                    que.JieXiRange.HtmlFileToText();
            }
        }
    }
}
