herum-shared 1.0.10 → 1.0.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1409,13 +1409,13 @@ class QuizMultiAnswerQuestionComponent {
|
|
|
1409
1409
|
ngOnChanges(changes) {
|
|
1410
1410
|
if (changes['question'] && this.question) {
|
|
1411
1411
|
this.answersForm = this.fb.group({});
|
|
1412
|
-
this.question.closedContent
|
|
1412
|
+
this.question.closedContent?.answers?.forEach((answer, index) => {
|
|
1413
1413
|
const controlName = this.answerControlNamePrefix + index;
|
|
1414
1414
|
this.answersForm.addControl(controlName, new FormControl(this.getFormControlValue(index)));
|
|
1415
1415
|
if (Object.keys(this.answersForm.controls).length && changes['question'].currentValue.id !== changes['question'].previousValue?.id) {
|
|
1416
1416
|
this.answersForm.get(controlName).valueChanges
|
|
1417
1417
|
.pipe(takeUntil(this.destroySubject$))
|
|
1418
|
-
.subscribe((isChosen) => this._onAnswersChange(this.question.closedContent
|
|
1418
|
+
.subscribe((isChosen) => this._onAnswersChange(this.question.closedContent?.answers[index], isChosen));
|
|
1419
1419
|
}
|
|
1420
1420
|
else {
|
|
1421
1421
|
this.answersForm.controls[controlName].setValue(this.getFormControlValue(index), { emitEvent: false });
|
|
@@ -1425,12 +1425,12 @@ class QuizMultiAnswerQuestionComponent {
|
|
|
1425
1425
|
this.setAnswerTypeAttributes();
|
|
1426
1426
|
}
|
|
1427
1427
|
if (this.correctAnswerCount === null || this.correctAnswerCount === undefined) {
|
|
1428
|
-
this.correctAnswerCount = this.question.closedContent
|
|
1428
|
+
this.correctAnswerCount = this.question.closedContent?.answers?.filter(answer => answer.isCorrect).length;
|
|
1429
1429
|
}
|
|
1430
1430
|
}
|
|
1431
1431
|
}
|
|
1432
1432
|
setAnswerTypeAttributes() {
|
|
1433
|
-
this.answerTypeAttributes = this.question.closedContent
|
|
1433
|
+
this.answerTypeAttributes = this.question.closedContent?.answers?.map((answer, index) => {
|
|
1434
1434
|
const answerForm = this.answersForm.value[`${this.answerControlNamePrefix}` + index];
|
|
1435
1435
|
return (!answerForm.type && this.iAnswerCorrect(answer.id, this.quizData)) ?
|
|
1436
1436
|
'correct-not-selected' :
|
|
@@ -1453,7 +1453,7 @@ class QuizMultiAnswerQuestionComponent {
|
|
|
1453
1453
|
return this.iAnswerCorrect(answerId, this.quizData) ? checkboxTypes$1.checked : checkboxTypes$1.error;
|
|
1454
1454
|
}
|
|
1455
1455
|
iAnswerCorrect(answerId, quizData) {
|
|
1456
|
-
return quizData.questions.find((question) => question.closedContent
|
|
1456
|
+
return quizData.questions.find((question) => question.closedContent?.answers?.find((answer) => answer.id === answerId)?.isCorrect);
|
|
1457
1457
|
}
|
|
1458
1458
|
_onAnswersChange(answer, isChosen) {
|
|
1459
1459
|
let userAnswer = this.userAnswers.find(userAnswer => userAnswer.id == answer.id);
|
|
@@ -1468,7 +1468,7 @@ class QuizMultiAnswerQuestionComponent {
|
|
|
1468
1468
|
this.onValidationChange.emit(this.isValid);
|
|
1469
1469
|
}
|
|
1470
1470
|
getFormControlValue(index) {
|
|
1471
|
-
const id = this.question.closedContent
|
|
1471
|
+
const id = this.question.closedContent?.answers[index]?.id;
|
|
1472
1472
|
return {
|
|
1473
1473
|
type: this.getTypeCheckbox(id),
|
|
1474
1474
|
isChecked: this._isAnswerChecked(id)
|