-- ----------------------------
-- 导入题目
-- ----------------------------
INSERT INTO ftb_cultivate_question (
    `F_Id`,
    `F_ClassifyId`,
    `F_Type`,
    `F_Difficulty`,
    `F_Content`,
    `F_Answer`,
    `F_EnabledMark`,
    `F_CreatorUserId`,
    `F_CreatorTime`,
    `F_LastModifyUserId`,
    `F_LastModifyTime`,
    `F_DeleteUserId`,
    `F_DeleteTime`,
    `F_TenantId`,
    `F_Analysis`
) SELECT
      q.`F_Id`,
      q.`F_ClassifyId`,
      q.`F_Type`,
      q.`F_Difficulty`,
      q.`F_Content`,
      q.`F_Answer`,
      q.`F_EnabledMark`,
      q.`F_CreatorUserId`,
      q.`F_CreatorTime`,
      q.`F_LastModifyUserId`,
      q.`F_LastModifyTime`,
      q.`F_DeleteUserId`,
      q.`F_DeleteTime`,
      q.`F_TenantId`,
      a.F_Analysis AS F_Analysis
FROM
    ftb_training_question AS q
        LEFT JOIN ftb_training_question_analysis AS a ON q.F_Id = a.F_QuestionId;


INSERT INTO ftb_cultivate_question_option (
    `F_Id`,
    `F_QuestionId`,
    `F_Content`,
    `F_Image`,
    `F_Description`,
    `F_EnabledMark`,
    `F_SortCode`,
    `F_IsRightOption`,
    `F_CreatorUserId`,
    `F_CreatorTime`,
    `F_LastModifyUserId`,
    `F_LastModifyTime`,
    `F_DeleteUserId`,
    `F_DeleteTime`,
    `F_TenantId`
) SELECT
      `F_Id`,
      `F_QuestionId`,
      `F_Content`,
      `F_Image`,
      `F_Description`,
      `F_EnabledMark`,
      `F_SortCode`,
      `F_RightAnswer` AS `F_IsRightOption`,
      `F_CreatorUserId`,
      `F_CreatorTime`,
      `F_LastModifyUserId`,
      `F_LastModifyTime`,
      `F_DeleteUserId`,
      `F_DeleteTime`,
      `F_TenantId`
FROM
    ftb_training_question_option;


INSERT ftb_cultivate_question_bank (
    `F_Id`,
    `F_ClassifyId`,
    `F_BankContent`,
    `F_EnabledMark`,
    `F_CreatorUserId`,
    `F_CreatorTime`,
    `F_LastModifyUserId`,
    `F_LastModifyTime`,
    `F_DeleteUserId`,
    `F_DeleteTime`,
    `F_TenantId` ) SELECT
      `F_Id`,
      CONCAT('TK2024', LPAD(FLOOR(RAND() * 10000000), 7, '0')) AS `F_ClassifyId`,
      `F_Name` AS `F_BankContent`,
      IFNULL( `F_EnabledMark`, 1 ) AS `F_EnabledMark`,
      `F_CreatorUserId`,
      `F_CreatorTime`,
      `F_LastModifyUserId`,
      `F_LastModifyTime`,
      `F_DeleteUserId`,
      `F_DeleteTime`,
      `F_TenantId`
FROM
  `ftb_training_question_classify`;