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

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import org.apache.commons.lang3.StringUtils;

import com.ssj.service.conch.student.dto.RelateKnowledgeDto;

public class CorrectDetailDto implements Serializable {
    private static final long serialVersionUID = 1L;

    private String subject;
    private List<String> homeworkList;

    private List<String> wrongItemList;

    private List<RelateKnowledgeDto> relateKnowledgeList;

    private List<String> unfinishedList;

    public CorrectDetailDto (){
        homeworkList = new ArrayList<>();
        wrongItemList = new ArrayList<>();
        relateKnowledgeList = new ArrayList<>();
        unfinishedList = new ArrayList<>();
    }

    public String getSubject() {
        return subject;
    }

    public void setSubject(String subject) {
        this.subject = subject;
    }

    public List<String> getHomeworkList() {
        return homeworkList;
    }

    public void setHomeworkList(List<String> homeworkList) {
        this.homeworkList = homeworkList;
    }

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

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

    public void addWrongItem (String wrongItem){
        this.wrongItemList.add(wrongItem);
    }

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

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

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

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

    public List<String> getUnfinishedList() {
        return unfinishedList;
    }

    public void setUnfinishedList(List<String> unfinishedList) {
        this.unfinishedList = unfinishedList;
    }

    public void addUnfinishItem (String name){
        this.unfinishedList.add(name);
    }
}
