package cn.com.qmth.examcloud.core.questions.service;

import java.util.List;
import java.util.Set;

import org.springframework.data.domain.Page;
import org.springframework.stereotype.Service;

import cn.com.qmth.examcloud.api.commons.security.bean.User;
import cn.com.qmth.examcloud.api.commons.security.bean.UserDataRule;
import cn.com.qmth.examcloud.core.questions.base.question.enums.QuesStructType;
import cn.com.qmth.examcloud.core.questions.dao.entity.Question;
import cn.com.qmth.examcloud.core.questions.dao.entity.QuestionSearchCondition;
import cn.com.qmth.examcloud.core.questions.service.bean.QuestionAnswerBean;

/**
 * Created by songyue on 16/12/28.
 */
@Service
public interface QuesService {

    /**
     * 保存试题
     *
     * @param question
     */
    public Question saveQues(Question question);

    /**
     * 批量保存试题
     *
     * @param list
     */
    public void saveQuesList(List<Question> list);

    /**
     * 查询所有试题
     *
     * @param searchCondition
     * @param curPage
     * @param pageSize
     * @param refIds
     * @param userId
     * @return
     */
    public Page<Question> findAll(QuestionSearchCondition searchCondition, int curPage, int pageSize,UserDataRule ud);

    public void formatQuesCondition(QuestionSearchCondition searchCondition);

    /**
     * 查询按ID过滤的试题
     *
     * @param idSet
     * @param curPage
     * @param pageSize
     * @return
     */
    public Page<Question> findByIdExclude(Set<String> idSet, String courseNo, QuesStructType quesType, int curPage, int pageSize, Long orgId, String quesBody,UserDataRule ud);

    /**
     * 按ID获取试题
     *
     * @param id
     * @return
     */
    public Question findById(String id);

    /**
     * 去除试题中的word
     *
     * @param question
     */
    public void formatQues(Question question);

    public void formatQuesUnit(Question question);

    /**
     * 保存后更新word
     *
     * @param question
     */
//    public void updateQuesWord(Question question);

//    public void updateQuesWordUnit(WordprocessingMLPackage wordMLPackage, Question question) throws Exception;

    /**
     * 获取试题有效文本
     *
     * @param question
     * @return
     */
    public String getExtractText(Question question);

    /**
     * 设置选择题答案
     *
     * @param question
     * @param order
     * @return
     */
    public void setSelectQuestionAnswer(Question question, String optionOrder);

    /**
     * 查询题目数量
     *
     * @param searchCondition
     * @return
     */
    public long findQuesCount(QuestionSearchCondition searchCondition);

    /**
     * 根据试卷ids集合更新试题属性
     *
     * @param paperList
     * @param difficultyDegree
     * @param publicity
     */
    public void updateProByPapers(List<String> paperList, Double difficultyDegree, Boolean publicity, User user);

    /**
     * 根据课程代码更新试题属性
     *
     * @param courseCode
     * @param difficultyDegree
     * @param publicity
     */
    public void updateProByCourse(String courseCode, Double difficultyDegree, Boolean publicity, String orgId);

    /**
     * 获取试题答案
     */
    QuestionAnswerBean findQuestionAnswer(String questionId);

}