room
This commit is contained in:
parent
d0da0012a3
commit
bdf14981c9
3 changed files with 14 additions and 6 deletions
|
|
@ -7,6 +7,7 @@ generator client {
|
|||
|
||||
datasource db {
|
||||
provider = "postgresql"
|
||||
url = env("DATABASE_URL")
|
||||
}
|
||||
|
||||
model User {
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ export class RoomPackService {
|
|||
? 'Copied from source pack'
|
||||
: 'Custom room questions';
|
||||
|
||||
let questions = [];
|
||||
let questions: any = [];
|
||||
let questionCount = 0;
|
||||
|
||||
// If source pack provided, copy questions
|
||||
|
|
@ -24,7 +24,7 @@ export class RoomPackService {
|
|||
select: { questions: true, questionCount: true },
|
||||
});
|
||||
|
||||
if (sourcePack) {
|
||||
if (sourcePack && sourcePack.questions) {
|
||||
questions = sourcePack.questions;
|
||||
questionCount = sourcePack.questionCount;
|
||||
}
|
||||
|
|
@ -78,18 +78,23 @@ export class RoomPackService {
|
|||
select: { questions: true },
|
||||
});
|
||||
|
||||
if (!sourcePack || !Array.isArray(sourcePack.questions)) {
|
||||
if (!roomPack) {
|
||||
throw new Error('Room pack not found');
|
||||
}
|
||||
|
||||
if (!sourcePack || !sourcePack.questions || !Array.isArray(sourcePack.questions)) {
|
||||
throw new Error('Source pack not found or invalid');
|
||||
}
|
||||
|
||||
// Get existing questions
|
||||
const existingQuestions = Array.isArray(roomPack.questions)
|
||||
? roomPack.questions
|
||||
? (roomPack.questions as any[])
|
||||
: [];
|
||||
|
||||
// Import selected questions (create copies)
|
||||
const sourceQuestions = sourcePack.questions as any[];
|
||||
const questionsToImport = questionIndices
|
||||
.map(idx => sourcePack.questions[idx])
|
||||
.map(idx => sourceQuestions[idx])
|
||||
.filter(Boolean)
|
||||
.map(q => ({ ...q })); // Deep copy
|
||||
|
||||
|
|
|
|||
|
|
@ -151,7 +151,9 @@ export class RoomsService {
|
|||
},
|
||||
});
|
||||
|
||||
if (room) {
|
||||
this.roomEventsService.emitRoomPackUpdated(room.code, room);
|
||||
}
|
||||
return room;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue