package com.cygnusa.hyperm.wrappers;

import java.util.ArrayList;

public class AssessmentQuestion {

    private String aqid;
    private String is_mandatory;
    private String qid;
    private String supplierid;
    private String questiontypeid;
    private String questiontext;
    private String qimage;
    private String qvideo;
    private String qimage_url;
    private String qvideo_url;
    private ArrayList<QuestionOption> options = new ArrayList<>();
    private ArrayList<RatingOption> rating_options = new ArrayList<>();
    private String survey_text;

    private TrainingSupplier supplier;

    public String getAqid() {
        return aqid;
    }

    public void setAqid(String aqid) {
        this.aqid = aqid;
    }

    public String getIs_mandatory() {
        return is_mandatory;
    }

    public void setIs_mandatory(String is_mandatory) {
        this.is_mandatory = is_mandatory;
    }

    public String getQid() {
        return qid;
    }

    public void setQid(String qid) {
        this.qid = qid;
    }

    public String getSupplierid() {
        return supplierid;
    }

    public void setSupplierid(String supplierid) {
        this.supplierid = supplierid;
    }

    public String getQuestiontypeid() {
        return questiontypeid;
    }

    public void setQuestiontypeid(String questiontypeid) {
        this.questiontypeid = questiontypeid;
    }

    public String getQuestiontext() {
        return questiontext;
    }

    public void setQuestiontext(String questiontext) {
        this.questiontext = questiontext;
    }

    public String getQimage() {
        return qimage;
    }

    public void setQimage(String qimage) {
        this.qimage = qimage;
    }

    public String getQvideo() {
        return qvideo;
    }

    public void setQvideo(String qvideo) {
        this.qvideo = qvideo;
    }

    public String getQimage_url() {
        return qimage_url;
    }

    public void setQimage_url(String qimage_url) {
        this.qimage_url = qimage_url;
    }

    public String getQvideo_url() {
        return qvideo_url;
    }

    public void setQvideo_url(String qvideo_url) {
        this.qvideo_url = qvideo_url;
    }

    public ArrayList<QuestionOption> getOptions() {
        return options;
    }

    public void setOptions(ArrayList<QuestionOption> options) {
        this.options = options;
    }

    public TrainingSupplier getSupplier() {
        return supplier;
    }

    public void setSupplier(TrainingSupplier supplier) {
        this.supplier = supplier;
    }

    public ArrayList<RatingOption> getRating_options() {
        return rating_options;
    }

    public void setRating_options(ArrayList<RatingOption> rating_options) {
        this.rating_options = rating_options;
    }

    public String getSurvey_text() {
        return survey_text;
    }

    public void setSurvey_text(String survey_text) {
        this.survey_text = survey_text;
    }

    public boolean isAnswered() {
        if (options != null && options.size() > 0) {
            for (QuestionOption option : options) {
                if (option.isChecked()) {
                    return true;
                }
            }
        }
        return false;
    }

    public boolean isSurveyOptionAnswered() {
        if (options != null && options.size() > 0) {
            for (QuestionOption option : options) {
                if (option.isCheckedSurvey()) {
                    return true;
                }
            }
        }
        return false;
    }

    public boolean isSurveyAnswered() {
        if (questiontypeid != null && questiontypeid.trim().equalsIgnoreCase("3")) {
            if (rating_options != null && rating_options.size() > 0) {
                for (RatingOption option : rating_options) {
                    if (option.isChecked()) {
                        return true;
                    }
                }
            }
        } else if (questiontypeid != null && questiontypeid.trim().equalsIgnoreCase("4")) {
            return survey_text != null && !survey_text.trim().isEmpty();
        }
        return false;
    }

    public ArrayList<String> getAnswer() {
        ArrayList<String> strings = new ArrayList<>();
        for (QuestionOption option : options) {
            if (option.isChecked()) {
                strings.add(option.getOptid());
            }
        }
        return strings;
    }

    public ArrayList<String> getSurveyOptionAnswer() {
        ArrayList<String> strings = new ArrayList<>();
        for (QuestionOption option : options) {
            if (option.isCheckedSurvey()) {
                strings.add(option.getOptid());
            }
        }
        return strings;
    }

    public String getSurveyAnswer() {
        if (questiontypeid != null && questiontypeid.trim().equalsIgnoreCase("3")) {
            for (RatingOption option : rating_options) {
                if (option.isChecked()) {
                    return option.getId();
                }
            }
        } else if (questiontypeid != null && questiontypeid.trim().equalsIgnoreCase("4")) {
            return survey_text == null ? "" : survey_text;
        }
        return "";
    }
}
