//填空题内容HTMl生成

function getFillBlankHtml(questionItem){
  let {questionFUIData,rowExCount,rectHeight,rectWidth} = questionItem;
  
  // return str;
}


//获取当前题大题题号
export function getBigQuestionIndex(questionList){
  let bigQuestionIndex = null;
  if(questionList?.length>0){
    //弃掉题中非作答区
    let qList = questionList.filter(item=>item.type!=6)
    //如果有题，取当前最大的题号+1
    if(qList?.length>0){
      bigQuestionIndex  = qList.reduce((pre,cur)=>{ return cur.bigQuestionIndex>pre?cur.bigQuestionIndex:pre  },0);
      bigQuestionIndex ++;
    }else{
      bigQuestionIndex = 1;
    }
    
  }else{
    bigQuestionIndex = 1; 
  }
  return bigQuestionIndex;
}
//获取小题名称
export function getSmallQuestionNormalName(smallQuestionIndex,bigQuestionIndex){
  
  let smallQuestionName = null;
  if(questionList?.length&&questionList.length>0){
    //如果有题，上一个题的题号+1
    smallQuestionIndex  = questionList[questionList.length -1].smallQuestionIndex + 1;
  }else{
    smallQuestionIndex = 1; 
  }
}
//获取小题显示题号
/**
 * @param {*} bigQuestionIndex 大题题号 1，2，3
 * @param {*} smallQuestionIndex 小题题号 1，2，3， 相对于当前大题的index
*/
export function getSmallQuestionId(bigQuestionIndex, smallQuestionIndex){
    let sqId  = smallQuestionIndex.toString();
    let sQLen = sqId.length;
    //小题号格式化
    if(sQLen==1){
      sqId = '00'+sqId;
    }else if(sQLen==2){
      sqId = '0'+sqId;
    }
    //大题号格式化 俩位数 
    let bgId = bigQuestionIndex.toString();
    let smallQuestionId = bgId+sqId;
    return smallQuestionId;
  }
//获取小题显示开始序号
export function getSmallQuestionStartDisplayIndex(questionList,isEdit,bigQuestionIndex){
  questionList = questionList.filter(item=>item.type!=6);
  
  let startEqDisplayIndex = 1;
  if(!questionList || questionList.length <= 0){
    return startEqDisplayIndex;
  }

  if((questionList&&questionList.length<=0) || isEdit&&bigQuestionIndex==1)return startEqDisplayIndex;
  let key = questionList.length-1;
  if(isEdit){
    let k = questionList.findIndex(item=>{
      return item.bigQuestionIndex == bigQuestionIndex;
    })
    key = k-1;
  }
  
  let qsItem = questionList[key].questionList;
    let lastItem = qsItem[qsItem.length-1];
    startEqDisplayIndex = lastItem.eqDisplayIndex+1;
  
  return startEqDisplayIndex;
}

//获取新的页面是否有学生信息区域
export function getNewPageHasStudentInfo(questionList){
  let hasStudentInfo = false;
  if(questionList?.length&&questionList.length>0){
    //如果有题，上一个题的题号+1
    hasStudentInfo  = questionList[questionList.length -1].hasStudentInfo;
  }else{
    hasStudentInfo = false; 
  }
  return hasStudentInfo;
}

/**
 * 获取新的页面剩余高度（首页有学生信息标题等） 
 * @param {*} pageInfo 
 * @param {*} pageNum 
 * @returns 
 */
export  function getPageResiduetHeight(pageInfo,pageNum){
  let {mainHeight,studentInfoH,pageCount,printType,stInfoType} = pageInfo;
  let residueH =0;
  if(stInfoType == 1){
    if(printType == 'single'){
      residueH = pageNum % pageCount == 1 || pageCount == 1
      ? mainHeight - studentInfoH
      : 256;
    }else{
      let pageC = pageCount*2;
      residueH = pageNum % pageC == 1 || pageNum == 1
      ? mainHeight - studentInfoH
      : 256;
    }
  }else{
    if(pageNum == 1){
      residueH = mainHeight - studentInfoH;
    }else{
      residueH = mainHeight
    }
  }
  
  return residueH;
}

//考卷数据坐标转换

export function transferTemplatePosition(templatePosition,pageInfo){
  
}
