import { __decorate, __extends, __values } from "tslib";
import { Component, Input, ChangeDetectionStrategy } from '@angular/core';
import { SharedService } from '../../../../shared/service/shared.service';
import { SummaryBase } from '../summary-base';
var MultipleChoiceSummaryComponent = /** @class */ (function (_super) {
    __extends(MultipleChoiceSummaryComponent, _super);
    function MultipleChoiceSummaryComponent(sharedService) {
        var _this = _super.call(this, sharedService) || this;
        _this.sharedService = sharedService;
        return _this;
    }
    MultipleChoiceSummaryComponent.prototype.ngOnChanges = function (changes) {
        if (this.question) {
            this.getAnswers();
        }
    };
    MultipleChoiceSummaryComponent.prototype.ngOnInit = function () {
        this.convertedTime = this.convertTime2(this.question.questionTimeSpent, 'time');
    };
    MultipleChoiceSummaryComponent.prototype.getAnswers = function () {
        var e_1, _a;
        this.correctAnswer = '';
        this.selectedAnswer = '';
        this.question.rationale = '';
        this.question.correct = false;
        var correctIds = [];
        var selectedIds = [];
        if (this.question) {
            if (this.question.parentDetails &&
                this.question.parentDetails.assets[0]) {
                this.question.parentDetails.assetsPosition = this.question.parentDetails.assets[0].assetsPosition;
                this.question.assetsPosition = this.question.parentDetails.assets[0].assetsPosition;
            }
            try {
                for (var _b = __values(this.question.choiceInteraction.simpleChoices), _c = _b.next(); !_c.done; _c = _b.next()) {
                    var choice = _c.value;
                    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;
                        }
                    }
                }
            }
            catch (e_1_1) { e_1 = { error: e_1_1 }; }
            finally {
                try {
                    if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
                }
                finally { if (e_1) throw e_1.error; }
            }
            this.formattingAnswers();
            if (correctIds === selectedIds) {
                this.question.correct = true;
            }
        }
        return true;
    };
    MultipleChoiceSummaryComponent.ctorParameters = function () { return [
        { type: SharedService }
    ]; };
    __decorate([
        Input('summaryData')
    ], MultipleChoiceSummaryComponent.prototype, "question", void 0);
    MultipleChoiceSummaryComponent = __decorate([
        Component({
            selector: 'lib-multiple-choice-summary',
            template: "<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.assets != undefined &&\n          question.assets.length != 0 &&\n          question.assetsPosition != AssetPositionValuesEnum.withInText,\n        'wk-col-12':\n          question.assets == undefined ||\n          question.assets.length == 0 ||\n          question.assetsPosition == AssetPositionValuesEnum.withInText,\n        'right-assets-position-question':\n          question.assets != undefined &&\n          question.assets.length != 0 &&\n          question.assetsPosition == AssetPositionValuesEnum.right,\n        'left-assets-position-question':\n          question.assets != undefined &&\n          question.assets.length != 0 &&\n          question.assetsPosition == AssetPositionValuesEnum.left,\n        'top-assets-position-question':\n          question.assets != undefined &&\n          question.assets.length != 0 &&\n          question.assetsPosition == AssetPositionValuesEnum.top,\n        'bottom-assets-position-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.assetsPosition != AssetPositionValuesEnum.withInText\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",
            changeDetection: ChangeDetectionStrategy.OnPush,
            styles: [""]
        })
    ], MultipleChoiceSummaryComponent);
    return MultipleChoiceSummaryComponent;
}(SummaryBase));
export { MultipleChoiceSummaryComponent };
//# sourceMappingURL=data:application/json;base64, 