Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion apps/ais/src/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,12 @@
@include solid-core-theme($app-theme);
@include solid-glossary-theme($app-theme);
@include solid-profile-theme($app-theme);
@include solid-quiz-theme($app-theme, $quiz-correct, $quiz-incorrect);
@include solid-quiz-theme(
$app-theme,
$quiz-correct,
$quiz-incorrect,
$quiz-partiallyIncorrect
);
@include solid-skeleton-theme($app-theme);
@include solid-slideshow-theme($app-theme);

Expand Down
1 change: 1 addition & 0 deletions apps/ais/src/theme.scss
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ $app-accent: mat.define-palette($ais-accent, 500);

$quiz-correct: mat.define-palette(mat.$light-green-palette, 600, 200, 600);
$quiz-incorrect: mat.define-palette(mat.$red-palette, 700, 200, 600);
$quiz-partiallyIncorrect: mat.define-palette(mat.$gray-palette, 400, 200, 600);

// The warn palette is optional (defaults to red).
$app-warn: mat.define-palette(mat.$red-palette);
Expand Down
7 changes: 6 additions & 1 deletion apps/dive/src/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,12 @@
@include solid-core-theme($app-theme);
@include solid-glossary-theme($app-theme);
@include solid-profile-theme($app-theme);
@include solid-quiz-theme($app-theme, $quiz-correct, $quiz-incorrect);
@include solid-quiz-theme(
$app-theme,
$quiz-correct,
$quiz-incorrect,
$quiz-partiallyIncorrect
);
@include solid-skeleton-theme($app-theme);
@include solid-slideshow-theme($app-theme);

Expand Down
1 change: 1 addition & 0 deletions apps/dive/src/theme.scss
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ $app-accent: mat.define-palette($dive-secondary, 500);

$quiz-correct: mat.define-palette(mat.$light-green-palette, 600, 200, 600);
$quiz-incorrect: mat.define-palette(mat.$red-palette, 700, 200, 600);
$quiz-partiallyIncorrect: mat.define-palette(mat.$gray-palette, 400, 200, 600);

// The warn palette is optional (defaults to red).
$app-warn: mat.define-palette(mat.$red-palette);
Expand Down
7 changes: 6 additions & 1 deletion apps/geomat/src/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,12 @@
@include solid-core-theme($app-theme);
@include solid-glossary-theme($app-theme);
@include solid-profile-theme($app-theme);
@include solid-quiz-theme($app-theme, $quiz-correct, $quiz-incorrect);
@include solid-quiz-theme(
$app-theme,
$quiz-correct,
$quiz-incorrect,
$quiz-partiallyIncorrect
);
@include solid-skeleton-theme($app-theme);
@include solid-slideshow-theme($app-theme);

Expand Down
1 change: 1 addition & 0 deletions apps/geomat/src/theme.scss
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ $app-accent: mat.define-palette($geomat-secondary, 400);

$quiz-correct: mat.define-palette(mat.$light-green-palette, 600, 200, 600);
$quiz-incorrect: mat.define-palette(mat.$red-palette, 700, 200, 600);
$quiz-partiallyIncorrect: mat.define-palette(mat.$gray-palette, 400, 200, 600);

// The warn palette is optional (defaults to red).
$app-warn: mat.define-palette(mat.$red-palette);
Expand Down
7 changes: 6 additions & 1 deletion apps/planty/src/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,12 @@
@include solid-core-theme($app-theme);
@include solid-glossary-theme($app-theme);
@include solid-profile-theme($app-theme);
@include solid-quiz-theme($app-theme, $quiz-correct, $quiz-incorrect);
@include solid-quiz-theme(
$app-theme,
$quiz-correct,
$quiz-incorrect,
$quiz-partiallyIncorrect
);
@include solid-skeleton-theme($app-theme);
@include solid-slideshow-theme($app-theme);

Expand Down
1 change: 1 addition & 0 deletions apps/planty/src/theme.scss
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ $app-accent: mat.define-palette($planty-accent, 300);

$quiz-correct: mat.define-palette(mat.$light-green-palette, 600, 200, 600);
$quiz-incorrect: mat.define-palette(mat.$red-palette, 700, 200, 600);
$quiz-partiallyIncorrect: mat.define-palette(mat.$gray-palette, 400, 200, 600);

// The warn palette is optional (defaults to red).
$app-warn: mat.define-palette(mat.$red-palette);
Expand Down
7 changes: 6 additions & 1 deletion apps/wabe/src/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,12 @@
@include solid-core-theme($app-theme);
@include solid-glossary-theme($app-theme);
@include solid-profile-theme($app-theme);
@include solid-quiz-theme($app-theme, $quiz-correct, $quiz-incorrect);
@include solid-quiz-theme(
$app-theme,
$quiz-correct,
$quiz-incorrect,
$quiz-partiallyIncorrect
);
@include solid-skeleton-theme($app-theme);
@include solid-slideshow-theme($app-theme);

Expand Down
1 change: 1 addition & 0 deletions apps/wabe/src/theme.scss
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ $app-accent: mat.define-palette($wabe-accent, 500);

$quiz-correct: mat.define-palette(mat.$light-green-palette, 600, 200, 600);
$quiz-incorrect: mat.define-palette(mat.$red-palette, 700, 200, 600);
$quiz-partiallyIncorrect: mat.define-palette(mat.$gray-palette, 400, 200, 600);

// The warn palette is optional (defaults to red).
$app-warn: mat.define-palette(mat.$red-palette);
Expand Down
66 changes: 34 additions & 32 deletions libs/solid/glossary/src/lib/components/glossary.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,35 +5,37 @@
<mat-icon>{{ Filter.value === '' ? 'search' : 'close' }}</mat-icon>
</button>
</mat-form-field>
<mat-list *ngIf="GlossaryEntries | async as state">
<ng-container *ngFor="let kvp of state.sections">
<h3 mat-subeader>{{ kvp[0] }}</h3>
<mat-list-item
*ngFor="let entryId of kvp[1]"
solidGlossaryEntry
[refId]="entryId"
>
<span class="mat-body-strong entry-header" mat-line>{{
state.entries[entryId].term
}}</span>
<div
[data]="state.entries[entryId].text"
markdown
[inline]="true"
mat-line
></div>
<span
class="links"
*ngIf="state.entries[entryId].links.length > 0"
mat-line
>&rarr;<a
(click)="followRef(refId)"
*ngFor="let refId of state.entries[entryId].links; let i = index"
>
{{ state.entries[refId].term
}}{{ i < state.entries[entryId].links.length - 1 ? ',' : '' }}</a
>
</span>
</mat-list-item>
</ng-container>
</mat-list>
<div class="scrollable-list">
<mat-list *ngIf="GlossaryEntries | async as state">
<ng-container *ngFor="let kvp of state.sections">
<h3 mat-subeader>{{ kvp[0] }}</h3>
<mat-list-item
*ngFor="let entryId of kvp[1]"
solidGlossaryEntry
[refId]="entryId"
>
<span class="mat-body-strong entry-header" mat-line>{{
state.entries[entryId].term
}}</span>
<div
[data]="state.entries[entryId].text"
markdown
[inline]="true"
mat-line
></div>
<span
class="links"
*ngIf="state.entries[entryId].links.length > 0"
mat-line
>&rarr;<a
(click)="followRef(refId)"
*ngFor="let refId of state.entries[entryId].links; let i = index"
>
{{ state.entries[refId].term
}}{{ i < state.entries[entryId].links.length - 1 ? ',' : '' }}</a
>
</span>
</mat-list-item>
</ng-container>
</mat-list>
</div>
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
mat-list {
padding: 0;
display: inline-block;
display: block;
height: calc(100vh - 119px);
width: 300px;
overflow-y: auto;
Expand Down Expand Up @@ -60,3 +60,8 @@ mat-form-field {
}
}
}

.scrollable-list {
overflow-y: auto;
scrollbar-color: #9999 #9993;
}
3 changes: 3 additions & 0 deletions libs/solid/quiz/src/lib/components/end/end.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ <h2>Selbsttest - Auswertung</h2>
<mat-icon class="correctIcon" *ngIf="question.answered === 1">
check_circle
</mat-icon>
<mat-icon class="partiallyIncorrectIcon" *ngIf="question.answered === -2">
check_circle
</mat-icon>
<mat-icon class="incorrectIcon" *ngIf="question.answered === -1">
cancel
</mat-icon>
Expand Down
5 changes: 5 additions & 0 deletions libs/solid/quiz/src/lib/components/end/end.component.scss
Original file line number Diff line number Diff line change
Expand Up @@ -184,3 +184,8 @@ mat-form-field {
margin: 2em;
text-align: center;
}

.partiallyIncorrectIcon {
transform: translateY(-3px) translateX(-5px);
opacity: 1;
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,5 @@
mat-raised-button
class="nextQuestionBtn"
>
{{ correct === 1 ? 'Richtig,' : ' Falsch,' }} nächste Frage
{{ getFeedbackResultLabel() }} nächste Frage
</button>
Original file line number Diff line number Diff line change
Expand Up @@ -60,23 +60,57 @@ export class MultipleChoiceQuestionComponent implements OnChanges {

public onShowAnswersClick() {
this.showAnswers = true;
this.correct = 1;

let correctAnswers = 0;
this.question.answers.forEach((answer) => {
if (answer.correct) {
correctAnswers++;
if (!this.selectedAnswers.includes(answer.id)) {
this.correct = -1;
}
}
});

if (this.selectedAnswers.length !== correctAnswers) {

if (this.isFullyCorrect()) {
this.correct = 1;
} else if (this.isPartiallyCorrect()) {
this.correct = -2;
} else {
this.correct = -1;
}
}

public isFullyCorrect(): boolean {
const correctIds = this.question.answers
.filter((a) => a.correct)
.map((a) => a.id)
.sort();
const selected = [...this.selectedAnswers].sort();
return JSON.stringify(correctIds) === JSON.stringify(selected);
}

public isPartiallyCorrect(): boolean {
const correctIds = this.question.answers
.filter((a) => a.correct)
.map((a) => a.id);
const incorrectIds = this.question.answers
.filter((a) => !a.correct)
.map((a) => a.id);

const selectedCorrect = this.selectedAnswers.filter((id) =>
correctIds.includes(id),
);
const selectedIncorrect = this.selectedAnswers.filter((id) =>
incorrectIds.includes(id),
);

return (
selectedCorrect.length > 0 &&
(selectedIncorrect.length > 0 ||
selectedCorrect.length < correctIds.length)
);
}

public isIncorrect(): boolean {
return !this.isFullyCorrect() && !this.isPartiallyCorrect();
}

public getFeedbackResultLabel(): string {
if (this.correct === 1) return 'Richtig,';
if (this.correct === -2) return 'Teilweise richtig,';
return 'Falsch,';
}

public onNextQuestionClick() {
if (this.selectedAnswers.length == 0) this.correct = 0;
this.nextQuestionClicked.emit(this.correct);
Expand Down
13 changes: 12 additions & 1 deletion libs/solid/quiz/src/lib/components/question/question.theme.scss
Original file line number Diff line number Diff line change
@@ -1,11 +1,22 @@
@use '@angular/material' as mat;

@mixin solid-quiz-question-theme($mat-theme, $quiz-correct, $quiz-incorrect) {
@mixin solid-quiz-question-theme(
$mat-theme,
$quiz-correct,
$quiz-incorrect,
$quiz-partiallyIncorrect
) {
$accent: map-get($mat-theme, accent);
$foreground: map-get($mat-theme, foreground);
$warn: map-get($mat-theme, warn);
$quiz-correct: mat.define-palette(mat.$green-palette, 400, 200, 600);
$quiz-wrong: mat.define-palette(mat.$red-palette, 400, 200, 600);
$quiz-partiallyIncorrect: mat.define-palette(
mat.$gray-palette,
400,
200,
600
);
solid-quiz-question {
mat-radio-group {
display: flex;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,5 +80,12 @@
mat-raised-button
class="nextQuestionBtn"
>
{{ correct === 1 ? 'Richtig,' : ' Falsch,' }} nächste Frage
{{
correct === 1
? 'Richtig,'
: hasSubsequence && correct === -1
? 'Teilweise richtig,'
: 'Falsch,'
}}
nächste Frage
</button>
4 changes: 3 additions & 1 deletion libs/solid/quiz/src/lib/state/quiz.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ export enum QuizQuestionType {
Range = 'RN',
}

export type QuizQuestionInSession = QuizQuestion & { answered: 0 | -1 | 1 };
export type QuizQuestionInSession = QuizQuestion & {
answered: 0 | -1 | 1 | -2;
};

export interface QuizSession {
progress: number;
Expand Down
2 changes: 1 addition & 1 deletion libs/solid/quiz/src/lib/state/quiz.state.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Action, Selector, State, StateContext } from '@ngxs/store';
import {
QuizAnswer,

Check warning on line 3 in libs/solid/quiz/src/lib/state/quiz.state.ts

View workflow job for this annotation

GitHub Actions / build

'QuizAnswer' is defined but never used
QuizMetadata,
QuizQuestion,
QuizQuestionApi,
Expand Down Expand Up @@ -187,7 +187,7 @@
const session = { ...(getState().session as QuizSession) };
const answeredQuestion = {
...session.questions[session.currentQuestion],
answered: correct as 0 | -1 | 1,
answered: correct as 0 | -1 | 1 | -2,
};
patchState({
session: {
Expand Down
14 changes: 12 additions & 2 deletions libs/solid/quiz/src/quiz-theme.scss
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
@import 'lib/components/question/question.theme';

@mixin solid-quiz-theme($mat-theme, $quiz-correct, $quiz-incorrect) {
@mixin solid-quiz-theme(
$mat-theme,
$quiz-correct,
$quiz-incorrect,
$quiz-partiallyIncorrect
) {
@include solid-quiz-question-theme(
$mat-theme,
$quiz-correct,
$quiz-incorrect
$quiz-incorrect,
$quiz-partiallyIncorrect
);
$accent: map-get($mat-theme, accent);

Expand Down Expand Up @@ -50,6 +56,10 @@
color: mat.get-color-from-palette($quiz-incorrect);
}

.partiallyIncorrectIcon {
color: mat.get-color-from-palette($quiz-partiallyIncorrect);
}

.unansweredIcon {
color: mat.get-color-from-palette($accent);
}
Expand Down
Loading