diff --git a/src/app/components/moderator/moderator-comment-list/moderator-comment-list.component.ts b/src/app/components/moderator/moderator-comment-list/moderator-comment-list.component.ts index 969a34251aaa4f1ea45aaa1896b95fabbd7d459f..7f0c51315c61456dac24cad84e34df7354164df5 100644 --- a/src/app/components/moderator/moderator-comment-list/moderator-comment-list.component.ts +++ b/src/app/components/moderator/moderator-comment-list/moderator-comment-list.component.ts @@ -12,6 +12,7 @@ import { UserRole } from '../../../models/user-roles.enum'; import { Room } from '../../../models/room'; import { RoomService } from '../../../services/http/room.service'; import { VoteService } from '../../../services/http/vote.service'; +import { CorrectWrong } from '../../../models/correct-wrong.enum'; @Component({ selector: 'app-moderator-comment-list', @@ -142,7 +143,7 @@ export class ModeratorCommentListComponent implements OnInit { this.comments[i].read = <boolean>value; break; case this.correct: - this.comments[i].correct = <boolean>value; + this.comments[i].correct = <CorrectWrong>value; break; case this.favorite: this.comments[i].favorite = <boolean>value; diff --git a/src/app/components/shared/comment-list/comment-list.component.html b/src/app/components/shared/comment-list/comment-list.component.html index 4772cd1c7357b50b55e4a4c44e1a2846d15c2677..b3cede59f04043ddc7d98d0077d335e93eb67c52 100644 --- a/src/app/components/shared/comment-list/comment-list.component.html +++ b/src/app/components/shared/comment-list/comment-list.component.html @@ -59,6 +59,11 @@ <mat-menu #filterMenu="matMenu" xPosition="before"> <div> + <button mat-icon-button (focus)="hideCommentsList=true" matTooltip="{{ 'comment-list.wrong' | translate }}" + (click)="filterComments(wrong)"> + <mat-icon [ngClass]="{correct: 'wrong-icon'}[currentFilter]">not_interested</mat-icon> + </button> + <button mat-icon-button (focus)="hideCommentsList=true" matTooltip="{{ 'comment-list.correct' | translate }}" (click)="filterComments(correct)"> <mat-icon [ngClass]="{correct: 'correct-icon'}[currentFilter]">check_circle</mat-icon> diff --git a/src/app/components/shared/comment-list/comment-list.component.ts b/src/app/components/shared/comment-list/comment-list.component.ts index 39db2a14e9e3211844ed6d6d0cbbeccb4d9fbb9a..e6c8b65ba6e5f895d9bc042227a1f42b13b122ee 100644 --- a/src/app/components/shared/comment-list/comment-list.component.ts +++ b/src/app/components/shared/comment-list/comment-list.component.ts @@ -14,6 +14,7 @@ import { Room } from '../../../models/room'; import { RoomService } from '../../../services/http/room.service'; import { VoteService } from '../../../services/http/vote.service'; import { NotificationService } from '../../../services/util/notification.service'; +import { CorrectWrong } from '../../../models/correct-wrong.enum'; @Component({ selector: 'app-comment-list', @@ -39,6 +40,7 @@ export class CommentListComponent implements OnInit { unread = 'unread'; favorite = 'favorite'; correct = 'correct'; + wrong = 'wrong'; ack = 'ack'; currentFilter = ''; commentVoteMap = new Map<string, Vote>(); @@ -168,7 +170,7 @@ export class CommentListComponent implements OnInit { this.comments[i].read = <boolean>value; break; case this.correct: - this.comments[i].correct = <boolean>value; + this.comments[i].correct = <CorrectWrong>value; break; case this.favorite: this.comments[i].favorite = <boolean>value; @@ -256,7 +258,9 @@ export class CommentListComponent implements OnInit { this.filteredComments = this.comments.filter(c => { switch (type) { case this.correct: - return c.correct; + return c.correct === CorrectWrong.CORRECT ? 1 : 0; + case this.wrong: + return c.correct === CorrectWrong.WRONG ? 1 : 0; case this.favorite: return c.favorite; case this.read: diff --git a/src/app/components/shared/comment/comment.component.html b/src/app/components/shared/comment/comment.component.html index 099509c1c5331ec18e5cbbbb802ec39b97f3e2c4..5346e71973c885af1a35fc310b77899923f8f69c 100644 --- a/src/app/components/shared/comment/comment.component.html +++ b/src/app/components/shared/comment/comment.component.html @@ -11,15 +11,19 @@ </ng-template> </div> <span class="fill-remaining-space"></span> - <button mat-icon-button *ngIf="comment.read" [disabled]="true" (click)="setRead(comment)"> - <mat-icon [ngClass]="{'read-icon': comment.read, 'not-marked' : !comment.read}" - matTooltip="{{ 'comment-page.mark-read' | translate }}">speaker_notes + <button mat-icon-button *ngIf="!isStudent || comment.correct === 2" [disabled]="isStudent" + (click)="markCorrect(comment, 2)"> + <mat-icon [ngClass]="{'wrong-icon' : comment.correct === 2, + 'not-marked' : (comment.correct === 0 || comment.correct === 1)}" + [matTooltip]="comment.correct != 2 ? ('comment-page.mark-wrong' | translate) + : ('comment-page.mark-not-wrong' | translate)">not_interested </mat-icon> </button> - <button mat-icon-button *ngIf="!isStudent || comment.correct" [disabled]="isStudent" - (click)="setCorrect(comment)"> - <mat-icon [ngClass]="{'correct-icon' : comment.correct, 'not-marked' : !comment.correct}" - [matTooltip]="!comment.correct ? ('comment-page.mark-correct' | translate) + <button mat-icon-button *ngIf="!isStudent || comment.correct === 1" [disabled]="isStudent" + (click)="markCorrect(comment, 1)"> + <mat-icon [ngClass]="{'correct-icon' : comment.correct === 1, + 'not-marked' : (comment.correct === 0 || comment.correct === 2)}" + [matTooltip]="comment.correct !== 1 ? ('comment-page.mark-correct' | translate) : ('comment-page.mark-not-correct' | translate)">check_circle </mat-icon> </button> @@ -30,6 +34,11 @@ : ('comment-page.mark-not-favorite' | translate)">grade </mat-icon> </button> + <button mat-icon-button *ngIf="comment.read" [disabled]="true" (click)="setRead(comment)"> + <mat-icon [ngClass]="{'read-icon': comment.read, 'not-marked' : !comment.read}" + matTooltip="{{ 'comment-page.mark-read' | translate }}">speaker_notes + </mat-icon> + </button> <button mat-icon-button *ngIf="!isStudent" (click)="openDeleteCommentDialog()"> <mat-icon class="not-marked" matTooltip="{{ 'comment-page.delete' | translate }}">delete </mat-icon> diff --git a/src/app/components/shared/comment/comment.component.scss b/src/app/components/shared/comment/comment.component.scss index a483113cef580ddc9c43a0ef4f0d02772075fa76..f9b8e6242b57f6ae4c12629d7244ffe25b93e878 100644 --- a/src/app/components/shared/comment/comment.component.scss +++ b/src/app/components/shared/comment/comment.component.scss @@ -41,6 +41,10 @@ mat-card-content > :first-child { color: var(--yellow); } +.wrong-icon { + color: var(--red); +} + h2 { text-align: center; margin: 0; diff --git a/src/app/components/shared/comment/comment.component.ts b/src/app/components/shared/comment/comment.component.ts index c3d8f2f331bf0457550c9f1d37e490668cb2d92f..cc642b30df0823d6d46247099d56570fb406219f 100644 --- a/src/app/components/shared/comment/comment.component.ts +++ b/src/app/components/shared/comment/comment.component.ts @@ -11,8 +11,9 @@ import { LanguageService } from '../../../services/util/language.service'; import { WsCommentServiceService } from '../../../services/websockets/ws-comment-service.service'; import { PresentCommentComponent } from '../_dialogs/present-comment/present-comment.component'; import { MatDialog } from '@angular/material'; -import { trigger, transition, style, animate, state, keyframes } from '@angular/animations'; +import { animate, keyframes, state, style, transition, trigger } from '@angular/animations'; import { DeleteCommentComponent } from '../../creator/_dialogs/delete-comment/delete-comment.component'; +import { CorrectWrong } from '../../../models/correct-wrong.enum'; export const rubberBand = [ style({ transform: 'scale3d(1, 1, 1)', offset: 0 }), @@ -68,7 +69,7 @@ export class CommentComponent implements OnInit { } this.language = localStorage.getItem('currentLang'); this.translateService.use(this.language); - this.moderationEnabled = (localStorage.getItem('moderationEnabled') === 'true') ? true : false; + this.moderationEnabled = (localStorage.getItem('moderationEnabled') === 'true'); } startAnimation(state_: any): void { @@ -92,8 +93,13 @@ export class CommentComponent implements OnInit { this.comment = this.wsCommentService.toggleRead(comment); } - setCorrect(comment: Comment): void { - this.comment = this.wsCommentService.toggleCorrect(comment); + markCorrect(comment: Comment, type: CorrectWrong): void { + if (comment.correct === type) { + comment.correct = CorrectWrong.NULL; + } else { + comment.correct = type; + } + this.comment = this.wsCommentService.markCorrect(comment); } setFavorite(comment: Comment): void { diff --git a/src/app/models/comment.ts b/src/app/models/comment.ts index b8d4dbf21556b3166978963ff031642e9656b798..51308497b63173c3fd82e5b424ddec59f65f36d1 100644 --- a/src/app/models/comment.ts +++ b/src/app/models/comment.ts @@ -1,3 +1,5 @@ +import { CorrectWrong } from './correct-wrong.enum'; + export class Comment { id: string; roomId: string; @@ -5,7 +7,7 @@ export class Comment { revision: string; body: string; read: boolean; - correct: boolean; + correct: CorrectWrong; favorite: boolean; timestamp: Date; score: number; @@ -17,7 +19,7 @@ export class Comment { userId: string = '', body: string = '', read: boolean = false, - correct: boolean = false, + correct: CorrectWrong = CorrectWrong.NULL, favorite: boolean = false, creationTimestamp: Date = null, score: number = 0, diff --git a/src/app/models/correct-wrong.enum.ts b/src/app/models/correct-wrong.enum.ts new file mode 100644 index 0000000000000000000000000000000000000000..6448e3799c09535ed1b19239e26c5b333c252e29 --- /dev/null +++ b/src/app/models/correct-wrong.enum.ts @@ -0,0 +1,5 @@ +export enum CorrectWrong { + NULL, + CORRECT, + WRONG +} diff --git a/src/app/services/websockets/ws-comment-service.service.ts b/src/app/services/websockets/ws-comment-service.service.ts index bd9fc8144ce2df85f2cac21693369ba347be4d06..8694fe84b68c9f2452cdc89fe267f5f7aac03f6d 100644 --- a/src/app/services/websockets/ws-comment-service.service.ts +++ b/src/app/services/websockets/ws-comment-service.service.ts @@ -41,8 +41,7 @@ export class WsCommentServiceService { return comment; } - toggleCorrect(comment: Comment): Comment { - comment.correct = !comment.correct; + markCorrect(comment: Comment): Comment { const changes = new TSMap<string, any>(); changes.set('correct', comment.correct); this.patchComment(comment, changes); diff --git a/src/assets/i18n/creator/de.json b/src/assets/i18n/creator/de.json index 31dae32f5d4b0ad10740d6af4acf54a59a62e569..3438a07c8801a1d5e0559deb29e03ec4b5a45860 100644 --- a/src/assets/i18n/creator/de.json +++ b/src/assets/i18n/creator/de.json @@ -114,6 +114,8 @@ "no-comments": "Keine Fragen vorhanden", "mark-correct": "Frage bejahen", "mark-not-correct": "Frage nicht bejahen", + "mark-wrong": "Frage als falsch markieren", + "mark-not-wrong": "Frage nicht als falsch markieren", "mark-favorite": "Als besonders interessante Frage markieren", "mark-not-favorite": "Nicht als besonders interessante Frage markieren", "mark-read": "In Vollansicht am Beamer besprochen", @@ -128,6 +130,7 @@ "filter-comments": "Fragen filtern", "sort-comments": "Fragen sortieren", "add-comment": "Frage stellen", + "wrong": "Falsch", "correct": "Bejaht", "favorite": "Hervorgehoben", "read": "Besprochen", diff --git a/src/assets/i18n/creator/en.json b/src/assets/i18n/creator/en.json index 73b908255686e7fd98f1c9096da5c02993cfd886..50d526858d743133ee9147d31ddfe6417573692b 100644 --- a/src/assets/i18n/creator/en.json +++ b/src/assets/i18n/creator/en.json @@ -114,6 +114,8 @@ "no-comments": "No questions yet", "mark-correct": "Mark as correct", "mark-not-correct": "Mark not as correct", + "mark-wrong": "Mark as wrong", + "mark-not-wrong": "Mark not as wrong", "mark-favorite": "Mark as favorite", "mark-not-favorite": "Mark not as favorite", "mark-read": "Discussed by you in full screen mode on the projector", @@ -128,6 +130,7 @@ "filter-comments": "Filter questions", "sort-comments": "Sort questions", "add-comment": "Ask a question!", + "wrong": "Marked as wrong by you", "correct": "Marked as correct by you", "favorite": "Your favorites", "read": "Discussed", diff --git a/src/assets/i18n/participant/de.json b/src/assets/i18n/participant/de.json index fd73eb089acd152d4e1cb1330ca5a398ec061783..20fc8746cdadd6d286872bf3816a78cfbebd0eb2 100644 --- a/src/assets/i18n/participant/de.json +++ b/src/assets/i18n/participant/de.json @@ -25,8 +25,9 @@ "error-title": "Bitte gib einen Titel ein.", "error-both-fields": "Bitte fülle alle Felder aus.", "no-comments": "", - "mark-correct": "Dozent/in hat die Frage bejaht.", - "mark-favorite": "Dozent/in hält die Frage für besonders interessant.", + "mark-not-correct": "Dozent/in hat die Frage bejaht.", + "mark-not-wrong": "Dozent/in hat die Frage als falsch markiert", + "mark-not-favorite": "Dozent/in hält die Frage für besonders interessant.", "mark-read": "Dozent/in hat die Frage beantwortet.", "vote-up": "Hochvoten", "vote-down": "Runtervoten" @@ -36,6 +37,7 @@ "filter-comments": "Fragen filtern", "sort-comments": "Fragen sortieren", "add-comment": "Stell deine Frage!", + "wrong": "Falsch", "correct": "Bejaht", "favorite": "Hervorgehoben", "read": "Beantwortet", diff --git a/src/assets/i18n/participant/en.json b/src/assets/i18n/participant/en.json index 997bc5178cc8d6e659b2b8d2525ad1a2ebfcacf8..6f1022d8f9ad3fc67576e0c0095efa2a231d7ce7 100644 --- a/src/assets/i18n/participant/en.json +++ b/src/assets/i18n/participant/en.json @@ -25,8 +25,9 @@ "error-comment": "Please enter a question.", "error-both-fields": "Please fill in all fields.", "no-comments": "No questions yet", - "mark-correct": "Marked as correct by the professor", - "mark-favorite": "Professor's favorite", + "mark-not-correct": "Marked as correct by the professor", + "mark-not-wrong": "Marked as wrong by the professor", + "mark-not-favorite": "Professor's favorite", "mark-read": "Already discussed by the professor", "vote-up": "Vote up", "vote-down": "Vote down" @@ -36,6 +37,7 @@ "filter-comments": "Filter questions", "sort-comments": "Sort questions", "add-comment": "Ask a question!", + "wrong": "Marked as wrong by the professor", "correct": "Marked as correct by the professor", "favorite": "Professor's favorites", "read": "Discussed by the professor",