Generate question bank domain model from JDL
This commit is contained in:
1 parent
1d97cc4e31
commit
1d74d8f04b
160 files changed
+26900
-2
No files matched your search
@@ -0,0 +1,91 @@
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
|
||||
import { type RouteLocation } from 'vue-router';
|
||||
|
||||
import { type MountingOptions, shallowMount } from '@vue/test-utils';
|
||||
|
||||
import AlertService from '@/shared/alert/alert.service';
|
||||
|
||||
import ExamAnswerDetails from './exam-answer-details.vue';
|
||||
|
||||
type ExamAnswerDetailsComponentType = InstanceType<typeof ExamAnswerDetails>;
|
||||
|
||||
let route: Partial<RouteLocation>;
|
||||
const routerGoMock = vi.fn();
|
||||
|
||||
vi.mock('vue-router', () => ({
|
||||
useRoute: () => route,
|
||||
useRouter: () => ({ go: routerGoMock }),
|
||||
}));
|
||||
|
||||
const examAnswerSample = { id: 123 };
|
||||
|
||||
describe('Component Tests', () => {
|
||||
let alertService: AlertService;
|
||||
|
||||
afterEach(() => {
|
||||
vi.resetAllMocks();
|
||||
});
|
||||
|
||||
describe('ExamAnswer Management Detail Component', () => {
|
||||
let examAnswerServiceStub: any;
|
||||
let mountOptions: MountingOptions<ExamAnswerDetailsComponentType>['global'];
|
||||
|
||||
beforeEach(() => {
|
||||
route = {};
|
||||
examAnswerServiceStub = {
|
||||
find: vi.fn(),
|
||||
};
|
||||
|
||||
alertService = new AlertService({
|
||||
i18n: { t: vi.fn() } as any,
|
||||
toast: {
|
||||
create: vi.fn(),
|
||||
} as any,
|
||||
});
|
||||
|
||||
mountOptions = {
|
||||
stubs: {
|
||||
'font-awesome-icon': true,
|
||||
'router-link': true,
|
||||
},
|
||||
provide: {
|
||||
alertService,
|
||||
examAnswerService: () => examAnswerServiceStub,
|
||||
},
|
||||
};
|
||||
});
|
||||
|
||||
describe('Navigate to details', () => {
|
||||
it('Should call load all on init', async () => {
|
||||
// GIVEN
|
||||
examAnswerServiceStub.find.mockResolvedValue(examAnswerSample);
|
||||
route = {
|
||||
params: {
|
||||
examAnswerId: `${123}`,
|
||||
},
|
||||
};
|
||||
const wrapper = shallowMount(ExamAnswerDetails, { global: mountOptions });
|
||||
const comp = wrapper.vm;
|
||||
// WHEN
|
||||
await comp.$nextTick();
|
||||
|
||||
// THEN
|
||||
expect(comp.examAnswer).toMatchObject(examAnswerSample);
|
||||
});
|
||||
});
|
||||
|
||||
describe('Previous state', () => {
|
||||
it('Should go previous state', async () => {
|
||||
examAnswerServiceStub.find.mockResolvedValue(examAnswerSample);
|
||||
const wrapper = shallowMount(ExamAnswerDetails, { global: mountOptions });
|
||||
const comp = wrapper.vm;
|
||||
await comp.$nextTick();
|
||||
|
||||
comp.previousState();
|
||||
await comp.$nextTick();
|
||||
|
||||
expect(routerGoMock).toHaveBeenCalledWith(-1);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,42 @@
|
||||
import { type Ref, defineComponent, inject, ref } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { useRoute, useRouter } from 'vue-router';
|
||||
|
||||
import { useAlertService } from '@/shared/alert/alert.service';
|
||||
import { type IExamAnswer } from '@/shared/model/exam-answer.model';
|
||||
|
||||
import ExamAnswerService from './exam-answer.service';
|
||||
|
||||
export default defineComponent({
|
||||
name: 'ExamAnswerDetails',
|
||||
setup() {
|
||||
const examAnswerService = inject('examAnswerService', () => new ExamAnswerService());
|
||||
const alertService = inject('alertService', () => useAlertService(), true);
|
||||
|
||||
const route = useRoute();
|
||||
const router = useRouter();
|
||||
|
||||
const previousState = () => router.go(-1);
|
||||
const examAnswer: Ref<IExamAnswer> = ref({});
|
||||
|
||||
const retrieveExamAnswer = async examAnswerId => {
|
||||
try {
|
||||
const res = await examAnswerService().find(examAnswerId);
|
||||
examAnswer.value = res;
|
||||
} catch (error) {
|
||||
alertService.showHttpError(error.response);
|
||||
}
|
||||
};
|
||||
|
||||
if (route.params?.examAnswerId) {
|
||||
retrieveExamAnswer(route.params.examAnswerId);
|
||||
}
|
||||
|
||||
return {
|
||||
examAnswer,
|
||||
|
||||
previousState,
|
||||
t$: useI18n().t,
|
||||
};
|
||||
},
|
||||
});
|
||||
@@ -0,0 +1,84 @@
|
||||
<template>
|
||||
<div class="d-flex justify-content-center">
|
||||
<div class="col-8">
|
||||
<div v-if="examAnswer">
|
||||
<h2 class="jh-entity-heading" data-cy="examAnswerDetailsHeading">
|
||||
<span>{{ t$('questionBankApp.examAnswer.detail.title') }}</span> {{ examAnswer.id }}
|
||||
</h2>
|
||||
<dl class="row-md jh-entity-details">
|
||||
<dt>
|
||||
<span>{{ t$('questionBankApp.examAnswer.questionTextSnapshot') }}</span>
|
||||
</dt>
|
||||
<dd>
|
||||
<span>{{ examAnswer.questionTextSnapshot }}</span>
|
||||
</dd>
|
||||
<dt>
|
||||
<span>{{ t$('questionBankApp.examAnswer.explanationSnapshot') }}</span>
|
||||
</dt>
|
||||
<dd>
|
||||
<span>{{ examAnswer.explanationSnapshot }}</span>
|
||||
</dd>
|
||||
<dt>
|
||||
<span>{{ t$('questionBankApp.examAnswer.selectedOption') }}</span>
|
||||
</dt>
|
||||
<dd>
|
||||
<span>{{ t$('questionBankApp.OptionKey.' + examAnswer.selectedOption) }}</span>
|
||||
</dd>
|
||||
<dt>
|
||||
<span>{{ t$('questionBankApp.examAnswer.selectedContentSnapshot') }}</span>
|
||||
</dt>
|
||||
<dd>
|
||||
<span>{{ examAnswer.selectedContentSnapshot }}</span>
|
||||
</dd>
|
||||
<dt>
|
||||
<span>{{ t$('questionBankApp.examAnswer.correct') }}</span>
|
||||
</dt>
|
||||
<dd>
|
||||
<span>{{ examAnswer.correct }}</span>
|
||||
</dd>
|
||||
<dt>
|
||||
<span>{{ t$('questionBankApp.examAnswer.awardedPoints') }}</span>
|
||||
</dt>
|
||||
<dd>
|
||||
<span>{{ examAnswer.awardedPoints }}</span>
|
||||
</dd>
|
||||
<dt>
|
||||
<span>{{ t$('questionBankApp.examAnswer.question') }}</span>
|
||||
</dt>
|
||||
<dd>
|
||||
<div v-if="examAnswer.question">
|
||||
<router-link :to="{ name: 'QuestionView', params: { questionId: examAnswer.question.id } }">{{
|
||||
examAnswer.question.id
|
||||
}}</router-link>
|
||||
</div>
|
||||
</dd>
|
||||
<dt>
|
||||
<span>{{ t$('questionBankApp.examAnswer.attempt') }}</span>
|
||||
</dt>
|
||||
<dd>
|
||||
<div v-if="examAnswer.attempt">
|
||||
<router-link :to="{ name: 'ExamAttemptView', params: { examAttemptId: examAnswer.attempt.id } }">{{
|
||||
examAnswer.attempt.id
|
||||
}}</router-link>
|
||||
</div>
|
||||
</dd>
|
||||
</dl>
|
||||
<button type="submit" @click.prevent="previousState()" class="btn btn-info" data-cy="entityDetailsBackButton">
|
||||
<font-awesome-icon icon="arrow-left"></font-awesome-icon> <span>{{ t$('entity.action.back') }}</span>
|
||||
</button>
|
||||
<router-link
|
||||
v-if="examAnswer.id"
|
||||
:to="{ name: 'ExamAnswerEdit', params: { examAnswerId: examAnswer.id } }"
|
||||
custom
|
||||
v-slot="{ navigate }"
|
||||
>
|
||||
<button @click="navigate" class="btn btn-primary">
|
||||
<font-awesome-icon icon="pencil-alt"></font-awesome-icon> <span>{{ t$('entity.action.edit') }}</span>
|
||||
</button>
|
||||
</router-link>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" src="./exam-answer-details.component.ts"></script>
|
||||
@@ -0,0 +1,142 @@
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
|
||||
import { type RouteLocation } from 'vue-router';
|
||||
|
||||
import { type MountingOptions, shallowMount } from '@vue/test-utils';
|
||||
|
||||
import AlertService from '@/shared/alert/alert.service';
|
||||
|
||||
import ExamAnswerUpdate from './exam-answer-update.vue';
|
||||
|
||||
type ExamAnswerUpdateComponentType = InstanceType<typeof ExamAnswerUpdate>;
|
||||
|
||||
let route: Partial<RouteLocation>;
|
||||
const routerGoMock = vi.fn();
|
||||
|
||||
vi.mock('vue-router', () => ({
|
||||
useRoute: () => route,
|
||||
useRouter: () => ({ go: routerGoMock }),
|
||||
}));
|
||||
|
||||
const examAnswerSample = { id: 123 };
|
||||
|
||||
describe('Component Tests', () => {
|
||||
let mountOptions: MountingOptions<ExamAnswerUpdateComponentType>['global'];
|
||||
let alertService: AlertService;
|
||||
|
||||
describe('ExamAnswer Management Update Component', () => {
|
||||
let comp: ExamAnswerUpdateComponentType;
|
||||
let examAnswerServiceStub: any;
|
||||
|
||||
beforeEach(() => {
|
||||
route = {};
|
||||
examAnswerServiceStub = {
|
||||
retrieve: vi.fn(),
|
||||
find: vi.fn(),
|
||||
update: vi.fn(),
|
||||
create: vi.fn(),
|
||||
};
|
||||
examAnswerServiceStub.retrieve.mockResolvedValueOnce([]);
|
||||
|
||||
alertService = new AlertService({
|
||||
i18n: { t: vi.fn() } as any,
|
||||
toast: {
|
||||
create: vi.fn(),
|
||||
} as any,
|
||||
});
|
||||
|
||||
mountOptions = {
|
||||
stubs: {
|
||||
'font-awesome-icon': true,
|
||||
'b-input-group': true,
|
||||
'b-input-group-prepend': true,
|
||||
'b-form-datepicker': true,
|
||||
'b-form-input': true,
|
||||
},
|
||||
provide: {
|
||||
alertService,
|
||||
examAnswerService: () => examAnswerServiceStub,
|
||||
questionService: () => ({
|
||||
retrieve: vi.fn().mockResolvedValue({}),
|
||||
}),
|
||||
examAttemptService: () => ({
|
||||
retrieve: vi.fn().mockResolvedValue({}),
|
||||
}),
|
||||
},
|
||||
};
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
vi.resetAllMocks();
|
||||
});
|
||||
|
||||
describe('save', () => {
|
||||
it('Should call update service on save for existing entity', async () => {
|
||||
// GIVEN
|
||||
const wrapper = shallowMount(ExamAnswerUpdate, { global: mountOptions });
|
||||
comp = wrapper.vm;
|
||||
comp.examAnswer = examAnswerSample;
|
||||
examAnswerServiceStub.update.mockResolvedValue(examAnswerSample);
|
||||
|
||||
// WHEN
|
||||
comp.save();
|
||||
await comp.$nextTick();
|
||||
|
||||
// THEN
|
||||
expect(examAnswerServiceStub.update).toHaveBeenCalledWith(examAnswerSample);
|
||||
expect(comp.isSaving).toEqual(false);
|
||||
});
|
||||
|
||||
it('Should call create service on save for new entity', async () => {
|
||||
// GIVEN
|
||||
const entity = {};
|
||||
examAnswerServiceStub.create.mockResolvedValue(entity);
|
||||
const wrapper = shallowMount(ExamAnswerUpdate, { global: mountOptions });
|
||||
comp = wrapper.vm;
|
||||
comp.examAnswer = entity;
|
||||
|
||||
// WHEN
|
||||
comp.save();
|
||||
await comp.$nextTick();
|
||||
|
||||
// THEN
|
||||
expect(examAnswerServiceStub.create).toHaveBeenCalledWith(entity);
|
||||
expect(comp.isSaving).toEqual(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe('Before route enter', () => {
|
||||
it('Should retrieve data', async () => {
|
||||
// GIVEN
|
||||
examAnswerServiceStub.find.mockResolvedValue(examAnswerSample);
|
||||
examAnswerServiceStub.retrieve.mockResolvedValue([examAnswerSample]);
|
||||
|
||||
// WHEN
|
||||
route = {
|
||||
params: {
|
||||
examAnswerId: `${examAnswerSample.id}`,
|
||||
},
|
||||
};
|
||||
const wrapper = shallowMount(ExamAnswerUpdate, { global: mountOptions });
|
||||
comp = wrapper.vm;
|
||||
await comp.$nextTick();
|
||||
|
||||
// THEN
|
||||
expect(comp.examAnswer).toMatchObject(examAnswerSample);
|
||||
});
|
||||
});
|
||||
|
||||
describe('Previous state', () => {
|
||||
it('Should go previous state', async () => {
|
||||
examAnswerServiceStub.find.mockResolvedValue(examAnswerSample);
|
||||
const wrapper = shallowMount(ExamAnswerUpdate, { global: mountOptions });
|
||||
comp = wrapper.vm;
|
||||
await comp.$nextTick();
|
||||
|
||||
comp.previousState();
|
||||
await comp.$nextTick();
|
||||
|
||||
expect(routerGoMock).toHaveBeenCalledWith(-1);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,144 @@
|
||||
import { type Ref, computed, defineComponent, inject, ref } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { useRoute, useRouter } from 'vue-router';
|
||||
|
||||
import { useVuelidate } from '@vuelidate/core';
|
||||
|
||||
import ExamAttemptService from '@/entities/exam-attempt/exam-attempt.service';
|
||||
import QuestionService from '@/entities/question/question.service';
|
||||
import { useAlertService } from '@/shared/alert/alert.service';
|
||||
import { useValidation } from '@/shared/composables';
|
||||
import { OptionKey } from '@/shared/model/enumerations/option-key.model';
|
||||
import { ExamAnswer, type IExamAnswer } from '@/shared/model/exam-answer.model';
|
||||
import { type IExamAttempt } from '@/shared/model/exam-attempt.model';
|
||||
import { type IQuestion } from '@/shared/model/question.model';
|
||||
|
||||
import ExamAnswerService from './exam-answer.service';
|
||||
|
||||
export default defineComponent({
|
||||
name: 'ExamAnswerUpdate',
|
||||
setup() {
|
||||
const examAnswerService = inject('examAnswerService', () => new ExamAnswerService());
|
||||
const alertService = inject('alertService', () => useAlertService(), true);
|
||||
|
||||
const examAnswer: Ref<IExamAnswer> = ref(new ExamAnswer());
|
||||
|
||||
const questionService = inject('questionService', () => new QuestionService());
|
||||
|
||||
const questions: Ref<IQuestion[]> = ref([]);
|
||||
|
||||
const examAttemptService = inject('examAttemptService', () => new ExamAttemptService());
|
||||
|
||||
const examAttempts: Ref<IExamAttempt[]> = ref([]);
|
||||
const optionKeyValues: Ref<string[]> = ref(Object.keys(OptionKey));
|
||||
const isSaving = ref(false);
|
||||
const currentLanguage = inject('currentLanguage', () => computed(() => navigator.language ?? 'en'), true);
|
||||
|
||||
const route = useRoute();
|
||||
const router = useRouter();
|
||||
|
||||
const previousState = () => router.go(-1);
|
||||
|
||||
const retrieveExamAnswer = async examAnswerId => {
|
||||
try {
|
||||
const res = await examAnswerService().find(examAnswerId);
|
||||
examAnswer.value = res;
|
||||
} catch (error) {
|
||||
alertService.showHttpError(error.response);
|
||||
}
|
||||
};
|
||||
|
||||
if (route.params?.examAnswerId) {
|
||||
retrieveExamAnswer(route.params.examAnswerId);
|
||||
}
|
||||
|
||||
const initRelationships = () => {
|
||||
questionService()
|
||||
.retrieve()
|
||||
.then(res => {
|
||||
questions.value = res.data;
|
||||
});
|
||||
examAttemptService()
|
||||
.retrieve()
|
||||
.then(res => {
|
||||
examAttempts.value = res.data;
|
||||
});
|
||||
};
|
||||
|
||||
initRelationships();
|
||||
|
||||
const { t: t$ } = useI18n();
|
||||
const validations = useValidation();
|
||||
const validationRules = {
|
||||
questionTextSnapshot: {
|
||||
required: validations.required(t$('entity.validation.required').toString()),
|
||||
maxLength: validations.maxLength(t$('entity.validation.maxlength', { max: 2000 }).toString(), 2000),
|
||||
},
|
||||
explanationSnapshot: {
|
||||
maxLength: validations.maxLength(t$('entity.validation.maxlength', { max: 2000 }).toString(), 2000),
|
||||
},
|
||||
selectedOption: {},
|
||||
selectedContentSnapshot: {
|
||||
maxLength: validations.maxLength(t$('entity.validation.maxlength', { max: 500 }).toString(), 500),
|
||||
},
|
||||
correct: {},
|
||||
awardedPoints: {
|
||||
integer: validations.integer(t$('entity.validation.number').toString()),
|
||||
min: validations.minValue(t$('entity.validation.min', { min: 0 }).toString(), 0),
|
||||
},
|
||||
question: {
|
||||
required: validations.required(t$('entity.validation.required').toString()),
|
||||
},
|
||||
attempt: {
|
||||
required: validations.required(t$('entity.validation.required').toString()),
|
||||
},
|
||||
};
|
||||
const v$ = useVuelidate(validationRules, examAnswer as any);
|
||||
v$.value.$validate();
|
||||
|
||||
return {
|
||||
examAnswerService,
|
||||
alertService,
|
||||
examAnswer,
|
||||
previousState,
|
||||
optionKeyValues,
|
||||
isSaving,
|
||||
currentLanguage,
|
||||
questions,
|
||||
examAttempts,
|
||||
v$,
|
||||
t$,
|
||||
};
|
||||
},
|
||||
created(): void {},
|
||||
methods: {
|
||||
save(): void {
|
||||
this.isSaving = true;
|
||||
if (this.examAnswer.id) {
|
||||
this.examAnswerService()
|
||||
.update(this.examAnswer)
|
||||
.then(param => {
|
||||
this.isSaving = false;
|
||||
this.previousState();
|
||||
this.alertService.showInfo(this.t$('questionBankApp.examAnswer.updated', { param: param.id }));
|
||||
})
|
||||
.catch(error => {
|
||||
this.isSaving = false;
|
||||
this.alertService.showHttpError(error.response);
|
||||
});
|
||||
} else {
|
||||
this.examAnswerService()
|
||||
.create(this.examAnswer)
|
||||
.then(param => {
|
||||
this.isSaving = false;
|
||||
this.previousState();
|
||||
this.alertService.showSuccess(this.t$('questionBankApp.examAnswer.created', { param: param.id }).toString());
|
||||
})
|
||||
.catch(error => {
|
||||
this.isSaving = false;
|
||||
this.alertService.showHttpError(error.response);
|
||||
});
|
||||
}
|
||||
},
|
||||
},
|
||||
});
|
||||
@@ -0,0 +1,176 @@
|
||||
<template>
|
||||
<div class="d-flex justify-content-center">
|
||||
<div class="col-8">
|
||||
<form name="editForm" novalidate @submit.prevent="save()">
|
||||
<h2 id="questionBankApp.examAnswer.home.createOrEditLabel" data-cy="ExamAnswerCreateUpdateHeading">
|
||||
{{ t$('questionBankApp.examAnswer.home.createOrEditLabel') }}
|
||||
</h2>
|
||||
<div>
|
||||
<div class="mb-3" v-if="examAnswer.id">
|
||||
<label for="id">{{ t$('global.field.id') }}</label>
|
||||
<input type="text" class="form-control" id="id" name="id" v-model="examAnswer.id" readonly />
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label class="form-control-label" for="exam-answer-questionTextSnapshot">{{
|
||||
t$('questionBankApp.examAnswer.questionTextSnapshot')
|
||||
}}</label>
|
||||
<input
|
||||
type="text"
|
||||
class="form-control"
|
||||
name="questionTextSnapshot"
|
||||
id="exam-answer-questionTextSnapshot"
|
||||
data-cy="questionTextSnapshot"
|
||||
:class="{ valid: !v$.questionTextSnapshot.$invalid, invalid: v$.questionTextSnapshot.$invalid }"
|
||||
v-model="v$.questionTextSnapshot.$model"
|
||||
required
|
||||
/>
|
||||
<div v-if="v$.questionTextSnapshot.$anyDirty && v$.questionTextSnapshot.$invalid">
|
||||
<small class="form-text text-danger" v-for="error of v$.questionTextSnapshot.$errors" :key="error.$uid">{{
|
||||
error.$message
|
||||
}}</small>
|
||||
</div>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label class="form-control-label" for="exam-answer-explanationSnapshot">{{
|
||||
t$('questionBankApp.examAnswer.explanationSnapshot')
|
||||
}}</label>
|
||||
<input
|
||||
type="text"
|
||||
class="form-control"
|
||||
name="explanationSnapshot"
|
||||
id="exam-answer-explanationSnapshot"
|
||||
data-cy="explanationSnapshot"
|
||||
:class="{ valid: !v$.explanationSnapshot.$invalid, invalid: v$.explanationSnapshot.$invalid }"
|
||||
v-model="v$.explanationSnapshot.$model"
|
||||
/>
|
||||
<div v-if="v$.explanationSnapshot.$anyDirty && v$.explanationSnapshot.$invalid">
|
||||
<small class="form-text text-danger" v-for="error of v$.explanationSnapshot.$errors" :key="error.$uid">{{
|
||||
error.$message
|
||||
}}</small>
|
||||
</div>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label class="form-control-label" for="exam-answer-selectedOption">{{ t$('questionBankApp.examAnswer.selectedOption') }}</label>
|
||||
<select
|
||||
class="form-control"
|
||||
name="selectedOption"
|
||||
:class="{ valid: !v$.selectedOption.$invalid, invalid: v$.selectedOption.$invalid }"
|
||||
v-model="v$.selectedOption.$model"
|
||||
id="exam-answer-selectedOption"
|
||||
data-cy="selectedOption"
|
||||
>
|
||||
<option
|
||||
v-for="optionKey in optionKeyValues"
|
||||
:key="optionKey"
|
||||
:value="optionKey"
|
||||
:label="t$('questionBankApp.OptionKey.' + optionKey)"
|
||||
>
|
||||
{{ optionKey }}
|
||||
</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label class="form-control-label" for="exam-answer-selectedContentSnapshot">{{
|
||||
t$('questionBankApp.examAnswer.selectedContentSnapshot')
|
||||
}}</label>
|
||||
<input
|
||||
type="text"
|
||||
class="form-control"
|
||||
name="selectedContentSnapshot"
|
||||
id="exam-answer-selectedContentSnapshot"
|
||||
data-cy="selectedContentSnapshot"
|
||||
:class="{ valid: !v$.selectedContentSnapshot.$invalid, invalid: v$.selectedContentSnapshot.$invalid }"
|
||||
v-model="v$.selectedContentSnapshot.$model"
|
||||
/>
|
||||
<div v-if="v$.selectedContentSnapshot.$anyDirty && v$.selectedContentSnapshot.$invalid">
|
||||
<small class="form-text text-danger" v-for="error of v$.selectedContentSnapshot.$errors" :key="error.$uid">{{
|
||||
error.$message
|
||||
}}</small>
|
||||
</div>
|
||||
</div>
|
||||
<div class="mb-3 form-check">
|
||||
<input
|
||||
type="checkbox"
|
||||
class="form-check-input"
|
||||
name="correct"
|
||||
id="exam-answer-correct"
|
||||
data-cy="correct"
|
||||
:class="{ valid: !v$.correct.$invalid, invalid: v$.correct.$invalid }"
|
||||
v-model="v$.correct.$model"
|
||||
/>
|
||||
<label class="form-check-label" for="exam-answer-correct">{{ t$('questionBankApp.examAnswer.correct') }}</label>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label class="form-control-label" for="exam-answer-awardedPoints">{{ t$('questionBankApp.examAnswer.awardedPoints') }}</label>
|
||||
<input
|
||||
type="number"
|
||||
class="form-control"
|
||||
name="awardedPoints"
|
||||
id="exam-answer-awardedPoints"
|
||||
data-cy="awardedPoints"
|
||||
:class="{ valid: !v$.awardedPoints.$invalid, invalid: v$.awardedPoints.$invalid }"
|
||||
v-model.number="v$.awardedPoints.$model"
|
||||
/>
|
||||
<div v-if="v$.awardedPoints.$anyDirty && v$.awardedPoints.$invalid">
|
||||
<small class="form-text text-danger" v-for="error of v$.awardedPoints.$errors" :key="error.$uid">{{ error.$message }}</small>
|
||||
</div>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label class="form-control-label" for="exam-answer">{{ t$('questionBankApp.examAnswer.question') }}</label>
|
||||
<select
|
||||
class="form-control"
|
||||
id="exam-answer-question"
|
||||
data-cy="question"
|
||||
name="question"
|
||||
v-model="examAnswer.question"
|
||||
required
|
||||
>
|
||||
<option v-if="!examAnswer.question" :value="null" selected></option>
|
||||
<option
|
||||
:value="examAnswer.question && questionOption.id === examAnswer.question.id ? examAnswer.question : questionOption"
|
||||
v-for="questionOption in questions"
|
||||
:key="questionOption.id"
|
||||
>
|
||||
{{ questionOption.id }}
|
||||
</option>
|
||||
</select>
|
||||
</div>
|
||||
<div v-if="v$.question.$anyDirty && v$.question.$invalid">
|
||||
<small class="form-text text-danger" v-for="error of v$.question.$errors" :key="error.$uid">{{ error.$message }}</small>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label class="form-control-label" for="exam-answer">{{ t$('questionBankApp.examAnswer.attempt') }}</label>
|
||||
<select class="form-control" id="exam-answer-attempt" data-cy="attempt" name="attempt" v-model="examAnswer.attempt" required>
|
||||
<option v-if="!examAnswer.attempt" :value="null" selected></option>
|
||||
<option
|
||||
:value="examAnswer.attempt && examAttemptOption.id === examAnswer.attempt.id ? examAnswer.attempt : examAttemptOption"
|
||||
v-for="examAttemptOption in examAttempts"
|
||||
:key="examAttemptOption.id"
|
||||
>
|
||||
{{ examAttemptOption.id }}
|
||||
</option>
|
||||
</select>
|
||||
</div>
|
||||
<div v-if="v$.attempt.$anyDirty && v$.attempt.$invalid">
|
||||
<small class="form-text text-danger" v-for="error of v$.attempt.$errors" :key="error.$uid">{{ error.$message }}</small>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<button type="button" id="cancel-save" data-cy="entityCreateCancelButton" class="btn btn-secondary" @click="previousState()">
|
||||
<font-awesome-icon icon="ban"></font-awesome-icon> <span>{{ t$('entity.action.cancel') }}</span>
|
||||
</button>
|
||||
<button
|
||||
type="submit"
|
||||
id="save-entity"
|
||||
data-cy="entityCreateSaveButton"
|
||||
:disabled="v$.$invalid || isSaving"
|
||||
class="btn btn-primary"
|
||||
>
|
||||
<font-awesome-icon icon="save"></font-awesome-icon> <span>{{ t$('entity.action.save') }}</span>
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<script lang="ts" src="./exam-answer-update.component.ts"></script>
|
||||
@@ -0,0 +1,103 @@
|
||||
import { beforeEach, describe, expect, it, vi } from 'vitest';
|
||||
|
||||
import { type MountingOptions, shallowMount } from '@vue/test-utils';
|
||||
|
||||
import AlertService from '@/shared/alert/alert.service';
|
||||
|
||||
import ExamAnswer from './exam-answer.vue';
|
||||
|
||||
type ExamAnswerComponentType = InstanceType<typeof ExamAnswer>;
|
||||
|
||||
const bModalStub = {
|
||||
render: () => {},
|
||||
methods: {
|
||||
hide: () => {},
|
||||
show: () => {},
|
||||
},
|
||||
};
|
||||
|
||||
describe('Component Tests', () => {
|
||||
let alertService: AlertService;
|
||||
|
||||
describe('ExamAnswer Management Component', () => {
|
||||
let examAnswerServiceStub: any;
|
||||
let mountOptions: MountingOptions<ExamAnswerComponentType>['global'];
|
||||
|
||||
beforeEach(() => {
|
||||
examAnswerServiceStub = {
|
||||
retrieve: vi.fn(),
|
||||
delete: vi.fn(),
|
||||
};
|
||||
examAnswerServiceStub.retrieve.mockResolvedValue({ headers: {} });
|
||||
|
||||
alertService = new AlertService({
|
||||
i18n: { t: vi.fn() } as any,
|
||||
toast: {
|
||||
create: vi.fn(),
|
||||
} as any,
|
||||
});
|
||||
|
||||
mountOptions = {
|
||||
stubs: {
|
||||
bModal: bModalStub as any,
|
||||
'font-awesome-icon': true,
|
||||
'b-badge': true,
|
||||
'b-button': true,
|
||||
'router-link': true,
|
||||
},
|
||||
directives: {
|
||||
'b-modal': {},
|
||||
},
|
||||
provide: {
|
||||
alertService,
|
||||
examAnswerService: () => examAnswerServiceStub,
|
||||
},
|
||||
};
|
||||
});
|
||||
|
||||
describe('Mount', () => {
|
||||
it('Should call load all on init', async () => {
|
||||
// GIVEN
|
||||
examAnswerServiceStub.retrieve.mockResolvedValue({ headers: {}, data: [{ id: 123 }] });
|
||||
|
||||
// WHEN
|
||||
const wrapper = shallowMount(ExamAnswer, { global: mountOptions });
|
||||
const comp = wrapper.vm;
|
||||
await comp.$nextTick();
|
||||
|
||||
// THEN
|
||||
expect(examAnswerServiceStub.retrieve).toHaveBeenCalledOnce();
|
||||
expect(comp.examAnswers[0]).toEqual(expect.objectContaining({ id: 123 }));
|
||||
});
|
||||
});
|
||||
describe('Handles', () => {
|
||||
let comp: ExamAnswerComponentType;
|
||||
|
||||
beforeEach(async () => {
|
||||
const wrapper = shallowMount(ExamAnswer, { global: mountOptions });
|
||||
comp = wrapper.vm;
|
||||
await comp.$nextTick();
|
||||
examAnswerServiceStub.retrieve.mockReset();
|
||||
examAnswerServiceStub.retrieve.mockResolvedValue({ headers: {}, data: [] });
|
||||
});
|
||||
|
||||
it('Should call delete service on confirmDelete', async () => {
|
||||
// GIVEN
|
||||
examAnswerServiceStub.delete.mockResolvedValue({});
|
||||
|
||||
// WHEN
|
||||
comp.prepareRemove({ id: 123 });
|
||||
|
||||
comp.removeExamAnswer();
|
||||
await comp.$nextTick(); // clear components
|
||||
|
||||
// THEN
|
||||
expect(examAnswerServiceStub.delete).toHaveBeenCalled();
|
||||
|
||||
// THEN
|
||||
await comp.$nextTick(); // handle component clear watch
|
||||
expect(examAnswerServiceStub.retrieve).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,78 @@
|
||||
import { type Ref, defineComponent, inject, onMounted, ref } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
|
||||
import { useAlertService } from '@/shared/alert/alert.service';
|
||||
import { type IExamAnswer } from '@/shared/model/exam-answer.model';
|
||||
|
||||
import ExamAnswerService from './exam-answer.service';
|
||||
|
||||
export default defineComponent({
|
||||
name: 'ExamAnswer',
|
||||
setup() {
|
||||
const { t: t$ } = useI18n();
|
||||
const examAnswerService = inject('examAnswerService', () => new ExamAnswerService());
|
||||
const alertService = inject('alertService', () => useAlertService(), true);
|
||||
|
||||
const examAnswers: Ref<IExamAnswer[]> = ref([]);
|
||||
|
||||
const isFetching = ref(false);
|
||||
|
||||
const clear = () => {};
|
||||
|
||||
const retrieveExamAnswers = async () => {
|
||||
isFetching.value = true;
|
||||
try {
|
||||
const res = await examAnswerService().retrieve();
|
||||
examAnswers.value = res.data;
|
||||
} catch (err) {
|
||||
alertService.showHttpError(err.response);
|
||||
} finally {
|
||||
isFetching.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
const handleSyncList = () => {
|
||||
retrieveExamAnswers();
|
||||
};
|
||||
|
||||
onMounted(async () => {
|
||||
await retrieveExamAnswers();
|
||||
});
|
||||
|
||||
const removeId: Ref<number> = ref(null);
|
||||
const removeEntity = ref<any>(null);
|
||||
const prepareRemove = (instance: IExamAnswer) => {
|
||||
removeId.value = instance.id;
|
||||
removeEntity.value.show();
|
||||
};
|
||||
const closeDialog = () => {
|
||||
removeEntity.value.hide();
|
||||
};
|
||||
const removeExamAnswer = async () => {
|
||||
try {
|
||||
await examAnswerService().delete(removeId.value);
|
||||
const message = t$('questionBankApp.examAnswer.deleted', { param: removeId.value }).toString();
|
||||
alertService.showInfo(message, { variant: 'danger' });
|
||||
removeId.value = null;
|
||||
retrieveExamAnswers();
|
||||
closeDialog();
|
||||
} catch (error) {
|
||||
alertService.showHttpError(error.response);
|
||||
}
|
||||
};
|
||||
|
||||
return {
|
||||
examAnswers,
|
||||
handleSyncList,
|
||||
isFetching,
|
||||
retrieveExamAnswers,
|
||||
clear,
|
||||
removeId,
|
||||
removeEntity,
|
||||
prepareRemove,
|
||||
closeDialog,
|
||||
removeExamAnswer,
|
||||
t$,
|
||||
};
|
||||
},
|
||||
});
|
||||
@@ -0,0 +1,177 @@
|
||||
import { beforeEach, describe, expect, it, vi } from 'vitest';
|
||||
|
||||
import axios from 'axios';
|
||||
|
||||
import { ExamAnswer } from '@/shared/model/exam-answer.model';
|
||||
|
||||
import ExamAnswerService from './exam-answer.service';
|
||||
|
||||
const error = {
|
||||
response: {
|
||||
status: null,
|
||||
data: {
|
||||
type: null,
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
const axiosStub = {
|
||||
get: vi.spyOn(axios, 'get'),
|
||||
post: vi.spyOn(axios, 'post'),
|
||||
put: vi.spyOn(axios, 'put'),
|
||||
patch: vi.spyOn(axios, 'patch'),
|
||||
delete: vi.spyOn(axios, 'delete'),
|
||||
};
|
||||
|
||||
describe('Service Tests', () => {
|
||||
describe('ExamAnswer Service', () => {
|
||||
let service: ExamAnswerService;
|
||||
let elemDefault;
|
||||
|
||||
beforeEach(() => {
|
||||
service = new ExamAnswerService();
|
||||
elemDefault = new ExamAnswer(123, 'AAAAAAA', 'AAAAAAA', 'A', 'AAAAAAA', false, 0);
|
||||
});
|
||||
|
||||
describe('Service methods', () => {
|
||||
it('should find an element', async () => {
|
||||
const returnedFromService = { ...elemDefault };
|
||||
axiosStub.get.mockResolvedValue({ data: returnedFromService });
|
||||
|
||||
return service.find(123).then(res => {
|
||||
expect(res).toMatchObject(elemDefault);
|
||||
});
|
||||
});
|
||||
|
||||
it('should not find an element', async () => {
|
||||
axiosStub.get.mockRejectedValue(error);
|
||||
return service
|
||||
.find(123)
|
||||
.then()
|
||||
.catch(err => {
|
||||
expect(err).toMatchObject(error);
|
||||
});
|
||||
});
|
||||
|
||||
it('should create a ExamAnswer', async () => {
|
||||
const returnedFromService = { id: 123, ...elemDefault };
|
||||
const expected = { ...returnedFromService };
|
||||
|
||||
axiosStub.post.mockResolvedValue({ data: returnedFromService });
|
||||
return service.create({}).then(res => {
|
||||
expect(res).toMatchObject(expected);
|
||||
});
|
||||
});
|
||||
|
||||
it('should not create a ExamAnswer', async () => {
|
||||
axiosStub.post.mockRejectedValue(error);
|
||||
|
||||
return service
|
||||
.create({})
|
||||
.then()
|
||||
.catch(err => {
|
||||
expect(err).toMatchObject(error);
|
||||
});
|
||||
});
|
||||
|
||||
it('should update a ExamAnswer', async () => {
|
||||
const returnedFromService = {
|
||||
questionTextSnapshot: 'BBBBBB',
|
||||
explanationSnapshot: 'BBBBBB',
|
||||
selectedOption: 'BBBBBB',
|
||||
selectedContentSnapshot: 'BBBBBB',
|
||||
correct: true,
|
||||
awardedPoints: 1,
|
||||
...elemDefault,
|
||||
};
|
||||
|
||||
const expected = { ...returnedFromService };
|
||||
axiosStub.put.mockResolvedValue({ data: returnedFromService });
|
||||
|
||||
return service.update(expected).then(res => {
|
||||
expect(res).toMatchObject(expected);
|
||||
});
|
||||
});
|
||||
|
||||
it('should not update a ExamAnswer', async () => {
|
||||
axiosStub.put.mockRejectedValue(error);
|
||||
|
||||
return service
|
||||
.update({})
|
||||
.then()
|
||||
.catch(err => {
|
||||
expect(err).toMatchObject(error);
|
||||
});
|
||||
});
|
||||
|
||||
it('should partial update a ExamAnswer', async () => {
|
||||
const patchObject = { questionTextSnapshot: 'BBBBBB', explanationSnapshot: 'BBBBBB', ...new ExamAnswer() };
|
||||
const returnedFromService = Object.assign(patchObject, elemDefault);
|
||||
|
||||
const expected = { ...returnedFromService };
|
||||
axiosStub.patch.mockResolvedValue({ data: returnedFromService });
|
||||
|
||||
return service.partialUpdate(patchObject).then(res => {
|
||||
expect(res).toMatchObject(expected);
|
||||
});
|
||||
});
|
||||
|
||||
it('should not partial update a ExamAnswer', async () => {
|
||||
axiosStub.patch.mockRejectedValue(error);
|
||||
|
||||
return service
|
||||
.partialUpdate({})
|
||||
.then()
|
||||
.catch(err => {
|
||||
expect(err).toMatchObject(error);
|
||||
});
|
||||
});
|
||||
|
||||
it('should return a list of ExamAnswer', async () => {
|
||||
const returnedFromService = {
|
||||
questionTextSnapshot: 'BBBBBB',
|
||||
explanationSnapshot: 'BBBBBB',
|
||||
selectedOption: 'BBBBBB',
|
||||
selectedContentSnapshot: 'BBBBBB',
|
||||
correct: true,
|
||||
awardedPoints: 1,
|
||||
...elemDefault,
|
||||
};
|
||||
const expected = { ...returnedFromService };
|
||||
axiosStub.get.mockResolvedValue([returnedFromService]);
|
||||
return service.retrieve().then(res => {
|
||||
expect(res).toContainEqual(expected);
|
||||
});
|
||||
});
|
||||
|
||||
it('should not return a list of ExamAnswer', async () => {
|
||||
axiosStub.get.mockRejectedValue(error);
|
||||
|
||||
return service
|
||||
.retrieve()
|
||||
.then()
|
||||
.catch(err => {
|
||||
expect(err).toMatchObject(error);
|
||||
});
|
||||
});
|
||||
|
||||
it('should delete a ExamAnswer', async () => {
|
||||
axiosStub.delete.mockResolvedValue({ ok: true });
|
||||
return service.delete(123).then(res => {
|
||||
expect(res.ok).toBeTruthy();
|
||||
});
|
||||
});
|
||||
|
||||
it('should not delete a ExamAnswer', async () => {
|
||||
axiosStub.delete.mockRejectedValue(error);
|
||||
|
||||
return service
|
||||
.delete(123)
|
||||
.then()
|
||||
.catch(err => {
|
||||
expect(err).toMatchObject(error);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,85 @@
|
||||
import axios from 'axios';
|
||||
|
||||
import { type IExamAnswer } from '@/shared/model/exam-answer.model';
|
||||
|
||||
const baseApiUrl = 'api/exam-answers';
|
||||
|
||||
export default class ExamAnswerService {
|
||||
find(id: number): Promise<IExamAnswer> {
|
||||
return new Promise<IExamAnswer>((resolve, reject) => {
|
||||
axios
|
||||
.get(`${baseApiUrl}/${id}`)
|
||||
.then(res => {
|
||||
resolve(res.data);
|
||||
})
|
||||
.catch(err => {
|
||||
reject(err);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
retrieve(): Promise<any> {
|
||||
return new Promise<any>((resolve, reject) => {
|
||||
axios
|
||||
.get(baseApiUrl)
|
||||
.then(res => {
|
||||
resolve(res);
|
||||
})
|
||||
.catch(err => {
|
||||
reject(err);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
delete(id: number): Promise<any> {
|
||||
return new Promise<any>((resolve, reject) => {
|
||||
axios
|
||||
.delete(`${baseApiUrl}/${id}`)
|
||||
.then(res => {
|
||||
resolve(res);
|
||||
})
|
||||
.catch(err => {
|
||||
reject(err);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
create(entity: IExamAnswer): Promise<IExamAnswer> {
|
||||
return new Promise<IExamAnswer>((resolve, reject) => {
|
||||
axios
|
||||
.post(baseApiUrl, entity)
|
||||
.then(res => {
|
||||
resolve(res.data);
|
||||
})
|
||||
.catch(err => {
|
||||
reject(err);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
update(entity: IExamAnswer): Promise<IExamAnswer> {
|
||||
return new Promise<IExamAnswer>((resolve, reject) => {
|
||||
axios
|
||||
.put(`${baseApiUrl}/${entity.id}`, entity)
|
||||
.then(res => {
|
||||
resolve(res.data);
|
||||
})
|
||||
.catch(err => {
|
||||
reject(err);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
partialUpdate(entity: IExamAnswer): Promise<IExamAnswer> {
|
||||
return new Promise<IExamAnswer>((resolve, reject) => {
|
||||
axios
|
||||
.patch(`${baseApiUrl}/${entity.id}`, entity)
|
||||
.then(res => {
|
||||
resolve(res.data);
|
||||
})
|
||||
.catch(err => {
|
||||
reject(err);
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,135 @@
|
||||
<template>
|
||||
<div>
|
||||
<h2 id="page-heading" data-cy="ExamAnswerHeading">
|
||||
<span id="exam-answer">{{ t$('questionBankApp.examAnswer.home.title') }}</span>
|
||||
<div class="d-flex justify-content-end">
|
||||
<button class="btn btn-info me-2" @click="handleSyncList" :disabled="isFetching">
|
||||
<font-awesome-icon icon="sync" :spin="isFetching"></font-awesome-icon>
|
||||
<span>{{ t$('questionBankApp.examAnswer.home.refreshListLabel') }}</span>
|
||||
</button>
|
||||
<router-link :to="{ name: 'ExamAnswerCreate' }" custom v-slot="{ navigate }">
|
||||
<button
|
||||
@click="navigate"
|
||||
id="jh-create-entity"
|
||||
data-cy="entityCreateButton"
|
||||
class="btn btn-primary jh-create-entity create-exam-answer"
|
||||
>
|
||||
<font-awesome-icon icon="plus"></font-awesome-icon>
|
||||
<span>{{ t$('questionBankApp.examAnswer.home.createLabel') }}</span>
|
||||
</button>
|
||||
</router-link>
|
||||
</div>
|
||||
</h2>
|
||||
<br />
|
||||
<div class="alert alert-warning" v-if="!isFetching && examAnswers?.length === 0">
|
||||
<span>{{ t$('questionBankApp.examAnswer.home.notFound') }}</span>
|
||||
</div>
|
||||
<div class="table-responsive" v-if="examAnswers?.length > 0">
|
||||
<table class="table table-striped" aria-describedby="examAnswers">
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col">
|
||||
<span>{{ t$('global.field.id') }}</span>
|
||||
</th>
|
||||
<th scope="col">
|
||||
<span>{{ t$('questionBankApp.examAnswer.questionTextSnapshot') }}</span>
|
||||
</th>
|
||||
<th scope="col">
|
||||
<span>{{ t$('questionBankApp.examAnswer.explanationSnapshot') }}</span>
|
||||
</th>
|
||||
<th scope="col">
|
||||
<span>{{ t$('questionBankApp.examAnswer.selectedOption') }}</span>
|
||||
</th>
|
||||
<th scope="col">
|
||||
<span>{{ t$('questionBankApp.examAnswer.selectedContentSnapshot') }}</span>
|
||||
</th>
|
||||
<th scope="col">
|
||||
<span>{{ t$('questionBankApp.examAnswer.correct') }}</span>
|
||||
</th>
|
||||
<th scope="col">
|
||||
<span>{{ t$('questionBankApp.examAnswer.awardedPoints') }}</span>
|
||||
</th>
|
||||
<th scope="col">
|
||||
<span>{{ t$('questionBankApp.examAnswer.question') }}</span>
|
||||
</th>
|
||||
<th scope="col">
|
||||
<span>{{ t$('questionBankApp.examAnswer.attempt') }}</span>
|
||||
</th>
|
||||
<th scope="col"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr v-for="examAnswer in examAnswers" :key="examAnswer.id" data-cy="entityTable">
|
||||
<td>
|
||||
<router-link :to="{ name: 'ExamAnswerView', params: { examAnswerId: examAnswer.id } }">{{ examAnswer.id }}</router-link>
|
||||
</td>
|
||||
<td>{{ examAnswer.questionTextSnapshot }}</td>
|
||||
<td>{{ examAnswer.explanationSnapshot }}</td>
|
||||
<td>{{ t$('questionBankApp.OptionKey.' + examAnswer.selectedOption) }}</td>
|
||||
<td>{{ examAnswer.selectedContentSnapshot }}</td>
|
||||
<td>{{ examAnswer.correct }}</td>
|
||||
<td>{{ examAnswer.awardedPoints }}</td>
|
||||
<td>
|
||||
<div v-if="examAnswer.question">
|
||||
<router-link :to="{ name: 'QuestionView', params: { questionId: examAnswer.question.id } }">{{
|
||||
examAnswer.question.id
|
||||
}}</router-link>
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
<div v-if="examAnswer.attempt">
|
||||
<router-link :to="{ name: 'ExamAttemptView', params: { examAttemptId: examAnswer.attempt.id } }">{{
|
||||
examAnswer.attempt.id
|
||||
}}</router-link>
|
||||
</div>
|
||||
</td>
|
||||
<td class="text-end">
|
||||
<div class="btn-group">
|
||||
<router-link :to="{ name: 'ExamAnswerView', params: { examAnswerId: examAnswer.id } }" custom v-slot="{ navigate }">
|
||||
<button @click="navigate" class="btn btn-info btn-sm details" data-cy="entityDetailsButton">
|
||||
<font-awesome-icon icon="eye"></font-awesome-icon>
|
||||
<span class="d-none d-md-inline">{{ t$('entity.action.view') }}</span>
|
||||
</button>
|
||||
</router-link>
|
||||
<router-link :to="{ name: 'ExamAnswerEdit', params: { examAnswerId: examAnswer.id } }" custom v-slot="{ navigate }">
|
||||
<button @click="navigate" class="btn btn-primary btn-sm edit" data-cy="entityEditButton">
|
||||
<font-awesome-icon icon="pencil-alt"></font-awesome-icon>
|
||||
<span class="d-none d-md-inline">{{ t$('entity.action.edit') }}</span>
|
||||
</button>
|
||||
</router-link>
|
||||
<b-button @click="prepareRemove(examAnswer)" variant="danger" class="btn btn-sm" data-cy="entityDeleteButton">
|
||||
<font-awesome-icon icon="times"></font-awesome-icon>
|
||||
<span class="d-none d-md-inline">{{ t$('entity.action.delete') }}</span>
|
||||
</b-button>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<b-modal ref="removeEntity" id="removeEntity">
|
||||
<template #title>
|
||||
<span id="questionBankApp.examAnswer.delete.question" data-cy="examAnswerDeleteDialogHeading">{{ t$('entity.delete.title') }}</span>
|
||||
</template>
|
||||
<div class="modal-body">
|
||||
<p id="jhi-delete-examAnswer-heading">{{ t$('questionBankApp.examAnswer.delete.question', { id: removeId }) }}</p>
|
||||
</div>
|
||||
<template #footer>
|
||||
<div>
|
||||
<button type="button" class="btn btn-secondary" @click="closeDialog()">{{ t$('entity.action.cancel') }}</button>
|
||||
<button
|
||||
type="button"
|
||||
class="btn btn-primary"
|
||||
id="jhi-confirm-delete-examAnswer"
|
||||
data-cy="entityConfirmDeleteButton"
|
||||
@click="removeExamAnswer"
|
||||
>
|
||||
{{ t$('entity.action.delete') }}
|
||||
</button>
|
||||
</div>
|
||||
</template>
|
||||
</b-modal>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" src="./exam-answer.component.ts"></script>
|
||||
Reference in new issue
Block a user