package com.ssj.service.conch.student.dto;


import org.apache.commons.lang3.StringUtils;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * @author  chchen
 */
public class WrongTopicDetailDto implements Serializable {
    private static final long serialVersionUID = 1L;

    private String workId;
    private List<Object> homeworkPictureUrlList;
    private List<String> homeworkPictureCommentUrlList;
    private Integer wrongQuestionCount = 0;
    private List<Map<String, Object>> wrongItemList = new ArrayList<>();
    private List<RelateKnowledgeDto> relateKnowledgeList;

    private List<String> correctList;

    public WrongTopicDetailDto () {
        this.homeworkPictureUrlList = new ArrayList<>();
        this.correctList = new ArrayList<>();
        this.relateKnowledgeList = new ArrayList<>();
    }


    public String getWorkId() {
        return workId;
    }

    public void setWorkId(String workId) {
        this.workId = workId;
    }

    public List<Object> getHomeworkPictureUrlList() {
        return homeworkPictureUrlList;
    }

    public void setHomeworkPictureUrlList(List<Object> homeworkPictureUrlList) {
        this.homeworkPictureUrlList = homeworkPictureUrlList;
    }

    public List<String> getHomeworkPictureCommentUrlList() {
        return homeworkPictureCommentUrlList;
    }

    public void setHomeworkPictureCommentUrlList(List<String> homeworkPictureCommentUrlList) {
        this.homeworkPictureCommentUrlList = homeworkPictureCommentUrlList;
    }

    public Integer getWrongQuestionCount() {
        return wrongQuestionCount;
    }

    public void setWrongQuestionCount(Integer wrongQuestionCount) {
        this.wrongQuestionCount = wrongQuestionCount;
    }

    public List<Map<String, Object>> getWrongItemList() {
        return wrongItemList;
    }

    public void setWrongItemList(List<Map<String, Object>> wrongItemList) {
        this.wrongItemList = wrongItemList;
    }

    public List<RelateKnowledgeDto> getRelateKnowledgeList() {
        return relateKnowledgeList;
    }

    public void setRelateKnowledgeList(List<RelateKnowledgeDto> relateKnowledgeList) {
        this.relateKnowledgeList = relateKnowledgeList;
    }

    public void addRelateKnowledge (RelateKnowledgeDto relateKnowledgeDto) {
        this.relateKnowledgeList.add(relateKnowledgeDto);
    }
    public void addRelateKnowledge (String detail, String module){
        boolean ended = true;
        RelateKnowledgeDto temp = null;
        if (StringUtils.isNotBlank(detail) && StringUtils.isNotBlank(module)){
            for (RelateKnowledgeDto know : this.relateKnowledgeList){
                if (know.getModule().equals(module)){
                    ended = false;
                    know.addDetails(detail);
                    break;
                }
            }

            if (ended){
                temp = new RelateKnowledgeDto();
                temp.setModule(module);
                temp.addDetails(detail);
                this.relateKnowledgeList.add(temp);
            }
        }
    }

    public List<String> getCorrectList() {
        return correctList;
    }

    public void setCorrectList(List<String> correctList) {
        this.correctList = correctList;
    }

    public void addCorrect (String correct) {
        this.correctList.add(correct);
    }
}
