package com.qmth.teachcloud.mark.service;

import java.util.List;

import javax.servlet.http.HttpServletResponse;

import org.springframework.web.multipart.MultipartFile;

import com.baomidou.mybatisplus.extension.service.IService;
import com.qmth.teachcloud.common.entity.MarkQuestion;
import com.qmth.teachcloud.mark.dto.mark.setting.MarkQuestionDto;
import com.qmth.teachcloud.mark.params.MarkObjectiveQuestionParams;
import com.qmth.teachcloud.mark.params.MarkQuestionParams;

/**
 * <p>
 * 小题信息表 服务类
 * </p>
 *
 * @author xf
 * @since 2023-09-22
 */
public interface MarkQuestionService extends IService<MarkQuestion> {

    /**
     * 查询分组的分组题目
     *
     * @param examId      考试ID
     * @param paperNumber 试卷编号
     * @param groupNumber 分组号
     */
    String assembleGroupQuestionsByExamIdAndPaperNumberAndNumber(Long examId, String paperNumber, Integer groupNumber);

    List<MarkQuestion> listQuestionByExamIdAndPaperNumberAndPaperType(Long examId, String paperNumber, String paperType);

    void saveQuestions(MarkQuestionParams markQuestionParams);

    List<MarkQuestion> listQuestionByExamIdAndPaperNumberAndGroupNumber(Long examId, String paperNumber, Integer number,
            Boolean isObjective);

    /**
     * 客观题标答模板导出
     *
     * @param examId      考试id
     * @param paperNumber 试卷编号
     */
    void objectiveAnswerSettingModelExport(Long examId, String paperNumber, HttpServletResponse response)
            throws Exception;

    /**
     * 客观题标答导入
     *
     * @param examId      考试id
     * @param paperNumber 试卷编号
     * @param file        excel文件
     */
    void objectiveAnswerSettingImport(Long examId, String paperNumber, MultipartFile file) throws Exception;

    void saveObjectiveQuestions(MarkObjectiveQuestionParams markObjectiveQuestionParams);

    String uploadSubjectiveFile(Long examId, String paperNumber, MultipartFile file, String md5);

    String previewAnswerFileByExamIdAndPaperNumber(Long examId, String paperNumber);

    double sumTotalScoreByGroupNumber(Long examId, String paperNumber, Integer groupNumber);

    MarkQuestion getByExamIdAndPaperNumberAndMainNumberAndSubNumberAndObjective(Long examId, String paperNumber, Integer mainNumber, Integer subNumber, boolean isObjective);

    List<MarkQuestion> listByExamIdAndPaperNumberAndPaperIndexAndPageIndex(Long examId, String paperNumber, Integer paperIndex, Integer pageIndex, boolean isObjective);

    MarkQuestionDto pageQuestionsByExamIdAndPaperNumber(Long examId, String paperNumber, String paperType, boolean canCreate);

    void updateGroupNumberByExamIdAndPaperNumberAndGroupNumber(Integer newGroupNumber, Long examId, String paperNumber,
            Integer groupNumber);

    long countByExamIdAndPaperNumberAndObjectiveAndGroupNumberIsNull(Long examId, String paperNumber, boolean objective);

    List<MarkQuestion> listByExamIdAndPaperNumberAndPaperType(Long examId, String paperNumber, String paperType, Boolean objective);

    void deleteByExamIdAndPaperNumber(Long examId, String paperNumber);

    /**
     * 更新试卷总分
     *
     * @param examId      考试id
     * @param paperNumber 试卷编号
     * @param paperType   试卷类型
     */
    void updateMarkPaperScore(Long examId, String paperNumber, String paperType);
}
