import { Component } from '@angular/core';
import { IonicPage, NavController, NavParams } from 'ionic-angular';
import {AppService} from "../../../service/appHttpService";

/**
 * Generated class for the SurveyWritePage page.
 *
 * See https://ionicframework.com/docs/components/#navigation for more info on
 * Ionic pages and navigation.
 */

@IonicPage()
@Component({
  selector: 'page-survey-write',
  templateUrl: 'survey-write.html',
})
export class SurveyWritePage {

  item;
  temp;
  ansArr = [];
  constructor(public navCtrl: NavController, public navParams: NavParams,
              public appService:AppService) {
  }

  ionViewDidLoad() {
      this.item = this.navParams.get('item');
    this.getDetail();
  }

  getDetail(){
    const id = '';
    this.appService.ObserverHttpGetAdd('/wisdomgroup/modules/question/findQuesByQuestionId/',this.item.id)
        .subscribe((res)=>{
          this.temp = res.json().datalist;
          for(let i = 0;i < this.temp.length;i++){
              const data = {
                  'questionId':this.temp[i].questionId,
                  'questionQueId':this.temp[i].id,
                  'answerdesc':'',
                  'quesType':this.temp[i].quesType,
                  'title':this.temp[i].title,
                  'quesDesc':JSON.parse(this.temp[i].quesDesc),
                  'isans':'1'
              };
                this.ansArr.push(data);
          }
        })
  }


    mutiSelect(i,index){
      this.temp[i].answerdesc += ","+ index;
      console.log(this.temp[i]);
    }

    submit(){
      console.log(this.ansArr);
    }

}
