Skip to content
Snippets Groups Projects
Commit ba1ed463 authored by MonaS8's avatar MonaS8
Browse files

update RoleType, error fixing

parent c4cc004f
No related branches found
No related tags found
No related merge requests found
......@@ -178,15 +178,15 @@ export class ActivitiesService {
const pointsArray: SessionPoints[] = [];
for (const [user, userActivities] of activitiesByUsers) {
await this.em.removeAndFlush(await this.em.find(SessionPoints, { roomSessionUser: user }));
const points = new SessionPoints(
user,
await this.calculateAudioPoints(userActivities),
await this.calculateVideoPoints(userActivities),
await this.calculateBrowserPoints(userActivities),
await this.calculateWhiteboardPoints(userActivities),
await this.calculateNotePoints(userActivities),
);
let points = await this.em.findOne(SessionPoints, { roomSessionUser: user });
if (!points) {
points = new SessionPoints(user);
}
points.audioPoints = await this.calculateAudioPoints(userActivities),
points.videoPoints = await this.calculateVideoPoints(userActivities),
points.browserPoints = await this.calculateBrowserPoints(userActivities),
points.whiteboardPoints = await this.calculateWhiteboardPoints(userActivities),
points.notePoints = await this.calculateNotePoints(userActivities),
await this.em.persistAndFlush(points);
pointsArray.push(points);
......
......@@ -178,7 +178,7 @@ export class ChannelService {
}
public async close(channel: Channel) {
await this.rooms.updateWhiteboard(channel.room.id, channel.canvasJSON);
//await this.rooms.updateWhiteboard(channel.room.id, channel.canvasJSON);
await this.browsers.closeBrowserContext(channel.id);
await this.roomSessionService.closeSession(channel.session);
......
......@@ -14,7 +14,7 @@ export class SessionPoints {
@PrimaryKey()
id!: number;
@ManyToOne(() => RoomSessionUser)
@ManyToOne(() => RoomSessionUser, { unique: true })
roomSessionUser!: RoomSessionUser;
@Property()
......@@ -32,12 +32,12 @@ export class SessionPoints {
@Property()
notePoints: number;
constructor(roomSessionUser: RoomSessionUser, audioPoints: number, videoPoints: number, browserPoints: number, whiteboardPoints: number, notePoints: number) {
constructor(roomSessionUser: RoomSessionUser) {
this.roomSessionUser = roomSessionUser;
this.audioPoints = audioPoints;
this.videoPoints = videoPoints;
this.browserPoints = browserPoints;
this.whiteboardPoints = whiteboardPoints;
this.notePoints = notePoints;
this.audioPoints = 0;
this.videoPoints = 0;
this.browserPoints = 0;
this.whiteboardPoints = 0;
this.notePoints = 0;
}
}
\ No newline at end of file
......@@ -6,9 +6,14 @@ import { RoomSessionUser } from '../room/roomSessionUser.entity';
import { EntityManager } from '@mikro-orm/mysql';
export enum RoleType {
MODERATOR = 'moderator',
NOTETAKER = 'noteTaker',
GHOST = 'ghost',
COORDINATOR = 'COORDINATOR',
DOCUMENTER = 'DOCUMENTER',
CODER_DEBUGGER = 'CODER_DEBUGGER',
VISUALIZER = 'VISUALIZER',
ACTIVE_PARTICIPANT = 'ACTIVE_PARTICIPANT',
OBSERVER = 'OBSERVER',
LURKER = 'LURKER',
DISRUPTOR = 'DISRUPTOR',
}
@Injectable()
......
......@@ -8,17 +8,18 @@ export class RoomSessionUserPointsController {
constructor(
private readonly roomSessionUser: RoomSessionUserService) {}
@UseGuards(AuthGuard)
@Get('/user/:userId')
/**
* Retrieves the total points for a specific user based on their user ID.
*
* @param userId - The unique identifier of the user whose points are being retrieved.
* @returns A promise that resolves to an object containing the user's total points and their user ID.
*/
async getPointsByRoomSessionUser(@Param('userId') userId: number): Promise<RoomSessionUserPointsResponseDto> {
const points = await this.roomSessionUser.getPointsByRoomSessionUser(userId);
return { ...points, userId };
}
*
* @param userId - The unique identifier of the user whose points are being retrieved.
* @returns A promise that resolves to an object containing the user's total points and their user ID.
*/
@UseGuards(AuthGuard)
@Get('/user/:userId')
async getPointsByRoomSessionUser(@Param('userId') userId: number): Promise<RoomSessionUserPointsResponseDto> {
const points = await this.roomSessionUser.getPointsByRoomSessionUser(userId);
return { ...points, userId };
}
}
\ No newline at end of file
export class RoomSessionUserPointsResponseDto {
// points: number;
// userId: number;
// sessionId?: number;
// audioPoints?: number;
// videoPoints?: number;
// browserPoints?: number;
// whiteboardPoints?: number;
// notePoints?: number;
allPoints: { audioPoints: number, videoPoints: number, browserPoints: number, whiteboardPoints: number, notePoints: number };
totalPoints: number;
sessionId?: number;
userId: number;
}
\ No newline at end of file
}
export class RoomSessionUserResponseDto {
id: number;
userId: number;
name: string;
points: RoomSessionUserPointsResponseDto;
}
......@@ -121,14 +121,14 @@ export class RoomSessionUserService {
const points = await this.getPointsByRoomSessionUser(roomSessionUser.id);
const sessionPoints = await this.roomSessionService.getAllPointsBySession(roomSessionUser.roomSession.id);
let roleTypes: RoleType[] = [];
if (this.shouldAssignModerator(points, sessionPoints)) {
roleTypes.push(RoleType.MODERATOR);
if (this.shouldAssignCoordinator(points, sessionPoints)) {
roleTypes.push(RoleType.COORDINATOR);
}
if (this.shouldAssignNoteTaker(points, sessionPoints)) {
roleTypes.push(RoleType.NOTETAKER);
if (this.shouldAssignDocumenter(points, sessionPoints)) {
roleTypes.push(RoleType.DOCUMENTER);
}
if (this.shouldAssignGhost(points)) {
roleTypes.push(RoleType.GHOST);
if (this.shouldAssignLurker(points)) {
roleTypes.push(RoleType.LURKER);
}
for (let role of roleTypes) {
await this.roleService.createRole(role, roomSessionUser);
......@@ -137,18 +137,18 @@ export class RoomSessionUserService {
}
/**
* Determines whether a user should be assigned as a moderator based on their audio points
* Determines whether a user should be assigned as a Coordinator based on their audio points
* relative to the total session audio points.
*
* @param points - The user's points data, including audio points.
* @param sessionPoints - The session's total points data, including audio points.
* @returns A promise that resolves to a boolean indicating whether the user should be assigned as a moderator.
* @returns A promise that resolves to a boolean indicating whether the user should be assigned as a Coordinator.
*/
private async shouldAssignModerator(points: RoomSessionUserPointsResponseDto, sessionPoints: RoomSessionPointsRequestDto): Promise<boolean> {
let shouldAssignModerator = false;
private async shouldAssignCoordinator(points: RoomSessionUserPointsResponseDto, sessionPoints: RoomSessionPointsRequestDto): Promise<boolean> {
let shouldAssignCoordinator = false;
if (points.allPoints.audioPoints/sessionPoints.allPoints.audioPoints > 0.5) {
shouldAssignModerator = true;
return shouldAssignModerator;
shouldAssignCoordinator = true;
return shouldAssignCoordinator;
}
}
......@@ -160,12 +160,12 @@ export class RoomSessionUserService {
* @param sessionPoints - An object containing the total points for the session.
* @returns A promise that resolves to a boolean indicating whether a note taker should be assigned.
*/
private async shouldAssignNoteTaker(points: RoomSessionUserPointsResponseDto, sessionPoints: RoomSessionPointsRequestDto): Promise<boolean> {
let shouldAssignNoteTaker = false;
private async shouldAssignDocumenter(points: RoomSessionUserPointsResponseDto, sessionPoints: RoomSessionPointsRequestDto): Promise<boolean> {
let shouldAssignDocumenter = false;
const userCount = await this.userRepository.count({ roomSession: points.sessionId });
if (points.allPoints.notePoints/sessionPoints.allPoints.notePoints > 1/userCount) {
shouldAssignNoteTaker = true;
return shouldAssignNoteTaker;
shouldAssignDocumenter = true;
return shouldAssignDocumenter;
//ToDo: ab wann wird der NoteTaker zugewiesen? mind. 50% der NotePoints im Vergleich zu allen NotePoints? oder wer am meisten NotePoints hat? etc.
}
}
......@@ -176,7 +176,7 @@ export class RoomSessionUserService {
* @param points - An object containing the user's activity points, including browser and whiteboard points.
* @returns A promise that resolves to `true` if both browserPoints and whiteboardPoints exceed 10, otherwise `false`.
*/
public async shouldAssignGhost(points: RoomSessionUserPointsResponseDto): Promise<boolean> {
public async shouldAssignLurker(points: RoomSessionUserPointsResponseDto): Promise<boolean> {
return points.allPoints.browserPoints > 10 && points.allPoints.whiteboardPoints > 10;
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment