import { __decorate } from "tslib";
import { Component, Input, ChangeDetectionStrategy } from '@angular/core';
import { SharedService } from '../../../../shared/service/shared.service';
import { SummaryBase } from '../summary-base';
let MultipleResponseSummaryComponent = class MultipleResponseSummaryComponent extends SummaryBase {
    constructor(sharedService) {
        super(sharedService);
        this.sharedService = sharedService;
    }
    ngOnChanges(changes) {
        if (this.question) {
            this.getAnswers();
        }
    }
    ngOnInit() {
        this.convertedTime = this.convertTime2(this.question.questionTimeSpent, "time");
    }
    getAnswers() {
        this.correctAnswer = '';
        this.selectedAnswer = '';
        this.question.rationale = '';
        this.question.correct = false;
        const correctIds = [];
        const selectedIds = [];
        if (this.question) {
            for (const choice of this.question.choiceInteraction.simpleChoices) {
                if (choice.correct === true) {
                    correctIds.push(choice.choiceId);
                    if (this.correctAnswer !== '') {
                        this.correctAnswer = this.correctAnswer + ',' + choice.label;
                    }
                    else {
                        this.correctAnswer = choice.label;
                    }
                }
                if (this.question.userResponse.indexOf(choice.choiceId) !== -1) {
                    selectedIds.push(choice.choiceId);
                    if (this.selectedAnswer !== '') {
                        this.selectedAnswer = this.selectedAnswer + ',' + choice.label;
                    }
                    else {
                        this.selectedAnswer = choice.label;
                    }
                }
            }
            this.formattingAnswers();
            if (correctIds === selectedIds) {
                this.question.correct = true;
            }
        }
        return true;
    }
};
MultipleResponseSummaryComponent.ctorParameters = () => [
    { type: SharedService }
];
__decorate([
    Input('summaryData')
], MultipleResponseSummaryComponent.prototype, "question", void 0);
MultipleResponseSummaryComponent = __decorate([
    Component({
        selector: 'lib-multiple-response-summary',
        template: "<!-- <div *ngFor=\"let question of questionList; let i = index\"> -->\n<ng-container *ngIf=\"!question.parentDetails\">\n  <div class=\"wk-row \">\n    <ng-container *ngIf=\"!question.parentDetails\"\n      ><media-carousel\n        [imagePath]=\"question.assets[0].assetPath\"\n        [assetData]=\"question.assets\"\n        [assetsPosition]=\"question.assetsPosition\"\n        *ngIf=\"\n          question &&\n          question.assets &&\n          question.assets.length != 0 &&\n          question.assets != undefined &&\n          question.assetsPosition != AssetPositionValuesEnum.withInText &&\n          question.assetsPosition != AssetPositionValuesEnum.bottom\n        \"\n      ></media-carousel>\n    </ng-container>\n    <div\n      [ngClass]=\"{\n        'wk-col-8 asset-left-width66':\n          question &&\n          question.assets != undefined &&\n          question.assets.length != 0 &&\n          question.assetsPosition != AssetPositionValuesEnum.withInText,\n        'wk-col-12':\n          (question && question.assets == undefined) ||\n          (question && question.assets.length == 0) ||\n          (question &&\n            question.assetsPosition == AssetPositionValuesEnum.withInText),\n        'right-assets-position-question':\n          question &&\n          question.assets != undefined &&\n          question.assets.length != 0 &&\n          question.assetsPosition == AssetPositionValuesEnum.right,\n        'left-assets-position-question':\n          question &&\n          question.assets != undefined &&\n          question.assets.length != 0 &&\n          question.assetsPosition == AssetPositionValuesEnum.left,\n        'top-assets-position-question':\n          question &&\n          question.assets != undefined &&\n          question.assets.length != 0 &&\n          question.assetsPosition == AssetPositionValuesEnum.top,\n        'bottom-assets-position-question':\n          question &&\n          question.assets != undefined &&\n          question.assets.length != 0 &&\n          question.assetsPosition == AssetPositionValuesEnum.bottom\n      }\"\n    >\n      <div class=\"wkqp-layout-item mb20 summary4-mb0 common-full-width \">\n        <div class=\"wkqp-field-item summary5-mb0\">\n          <div class=\"wk-row gray-bg-result mb20\">\n            <div class=\"wk-col-8 responsive-pl15\">\n              <!--Item Sequence-->\n              <span class=\"wkqb-question-number\">\n                <strong>{{ question.sequence }}</strong>\n              </span>\n\n              <!--Prompt Text-->\n              <span\n                class=\"qp-ts-number-right\"\n                *ngIf=\"\n                  (question &&\n                    question.assetsPosition !=\n                      AssetPositionValuesEnum.withInText) ||\n                  !question.parentDetails\n                \"\n              >\n                <strong class=\"wkqp-prewrap\">{{ question.promptText }}</strong>\n              </span>\n              <span\n                *ngIf=\"\n                  question &&\n                  question.assetsPosition == AssetPositionValuesEnum.withInText\n                \"\n              >\n                <item-text-assets\n                  [promptText]=\"question.promptText\"\n                  [assetData]=\"question && question.assets\"\n                  [assetsPosition]=\"AssetPositionValuesEnum.withInText\"\n                ></item-text-assets>\n              </span>\n            </div>\n            <media-carousel\n              [imagePath]=\"question.assets[0].assetPath\"\n              [assetData]=\"question.assets\"\n              [assetsPosition]=\"question.assetsPosition\"\n              *ngIf=\"\n                question &&\n                question.assets &&\n                question.assets.length != 0 &&\n                question.assets != undefined &&\n                question.assetsPosition != AssetPositionValuesEnum.withInText &&\n                question.assetsPosition == AssetPositionValuesEnum.bottom\n              \"\n            ></media-carousel>\n            <!--Question time spent-->\n            <div class=\"wk-col-4 responsive-timespent time-qu-pt-remove\">\n              <span\n                class=\"que-mob-left mr10\"\n                [ngClass]=\"getQuestionProgressClass(question)\"\n              >\n              </span>\n              <span\n                class=\"time-mob-right wkqp-badge\"\n                [ngClass]=\"getOvertimelimitClass(question)\"\n              >\n                Time Spent -\n                {{ convertedTime }}\n              </span>\n            </div>\n          </div>\n\n          <div\n            class=\"common-full-width\"\n            *ngIf=\"question.userResponse && question.userResponse.length > 0\"\n          >\n            <!--Your response-->\n            <p\n              class=\"wkqp-prewrap mb20\"\n              [ngClass]=\"getSelectedResponseClass(question)\"\n            >\n              <strong>Your Response: </strong>\n              <label class=\"response-inline\">{{ selectedAnswer }}</label>\n            </p>\n\n            <!--Correct Response-->\n            <p\n              class=\"wkqp-alert-success wkqp-prewrap wkqp-success mb20\"\n              *ngIf=\"question.isCorrect != 1\"\n            >\n              <strong>Correct Response: </strong>\n              <label class=\"response-inline\">{{ correctAnswer }}</label>\n            </p>\n          </div>\n\n          <!--Unattempted response-->\n          <div class=\"common-full-width\" *ngIf=\"!question.userResponse[0]\">\n            <p class=\"wkqp-alert-danger\">\n              <strong>You did not answer this question</strong>\n            </p>\n          </div>\n        </div>\n      </div>\n    </div>\n    <div class=\"common-full-width mb20\">\n      <!--Rationale-->\n      <lib-rationale [itemData]=\"question.modelFeedback\"></lib-rationale>\n      <!-- remediation -->\n      <lib-remediation [itemData]=\"question.remediationLinks\"></lib-remediation>\n    </div>\n  </div>\n</ng-container>\n<!-- </div> -->\n",
        changeDetection: ChangeDetectionStrategy.OnPush,
        styles: [""]
    })
], MultipleResponseSummaryComponent);
export { MultipleResponseSummaryComponent };
//# sourceMappingURL=data:application/json;base64, 