Skip to content

Commit a3b0ac4

Browse files
authored
Merge pull request #264 from PROCOLLAB-github/switching-between-tasks
add switching between complted tasks from result/other pages
2 parents 0c5f9eb + 01a67c2 commit a3b0ac4

13 files changed

Lines changed: 54 additions & 5 deletions

projects/social_platform/src/app/office/courses/lesson/lesson.component.html

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,11 @@
1111
@for (task of tasks(); track task.id) {
1212
<div
1313
class="progress__task"
14+
(click)="onSelectTask(task)"
1415
[ngClass]="{
1516
'progress__task--done': isDone(task),
16-
'progress__task--current': isCurrent(task.id)
17+
'progress__task--current': isCurrent(task.id),
18+
'progress__task--clickable': isDone(task)
1719
}"
1820
>
1921
<p class="text-body-12">{{ task.order }}</p>
@@ -43,6 +45,7 @@
4345
<app-write-task
4446
[data]="task"
4547
[type]="task.answerType === 'text_and_files' ? 'text-file' : 'text'"
48+
[disabled]="isViewingCompleted()"
4649
(update)="onAnswerChange($event)"
4750
></app-write-task>
4851
}
@@ -53,6 +56,7 @@
5356
[data]="task"
5457
[success]="success()"
5558
[error]="hasError()"
59+
[disabled]="isViewingCompleted()"
5660
(update)="onAnswerChange($event)"
5761
></app-exclude-task>
5862
}
@@ -63,6 +67,7 @@
6367
[data]="task"
6468
[success]="success()"
6569
[error]="hasError()"
70+
[disabled]="isViewingCompleted()"
6671
(update)="onAnswerChange([$event.answerId])"
6772
></app-radio-select-task>
6873
}
@@ -73,6 +78,7 @@
7378
[data]="task"
7479
[success]="success()"
7580
[error]="hasError()"
81+
[disabled]="isViewingCompleted()"
7682
(update)="onAnswerChange($event)"
7783
></app-file-task>
7884
}
@@ -82,8 +88,8 @@
8288

8389
<app-button
8490
[loader]="loader()"
85-
[disabled]="isSubmitDisabled()"
86-
[style.opacity]="isSubmitDisabled() ? 0.5 : 1"
91+
[disabled]="isSubmitDisabled() || isViewingCompleted()"
92+
[style.opacity]="isSubmitDisabled() || isViewingCompleted() ? 0.5 : 1"
8793
size="big"
8894
customTypographyClass="text-body-12"
8995
class="action__button"

projects/social_platform/src/app/office/courses/lesson/lesson.component.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,10 @@
7373
border: 0 !important;
7474
}
7575

76+
&--clickable {
77+
cursor: pointer;
78+
}
79+
7680
&--current {
7781
border: 0.5px solid var(--accent);
7882
}

projects/social_platform/src/app/office/courses/lesson/lesson.component.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,24 @@ export class LessonComponent implements OnInit {
157157
return task.isCompleted || this.completedTaskIds().has(task.id);
158158
}
159159

160+
protected readonly isViewingCompleted = computed(() => {
161+
const task = this.currentTask();
162+
return task ? this.isDone(task) : false;
163+
});
164+
165+
onSelectTask(task: Task) {
166+
if (!this.isDone(task)) return;
167+
168+
this.currentTaskId.set(task.id);
169+
this.answerBody.set(null);
170+
this.success.set(false);
171+
this.hasError.set(false);
172+
173+
if (this.isComplete()) {
174+
this.router.navigate(["./"], { relativeTo: this.route });
175+
}
176+
}
177+
160178
onSubmitAnswer() {
161179
const task = this.currentTask();
162180
if (!task) return;

projects/social_platform/src/app/office/courses/lesson/shared/exclude-task/exclude-task.component.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
class="exclude__item"
4949
[class.exclude__item--success]="success && result().includes(op.id)"
5050
[class.exclude__item--error]="error"
51+
[class.exclude__item--disabled]="disabled"
5152
(click)="onSelect(op.id)"
5253
>
5354
<app-checkbox size="10" [checked]="result().includes(op.id)"></app-checkbox>

projects/social_platform/src/app/office/courses/lesson/shared/exclude-task/exclude-task.component.scss

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,11 @@
7171
}
7272
}
7373

74+
&--disabled {
75+
pointer-events: none;
76+
opacity: 0.6;
77+
}
78+
7479
label {
7580
cursor: pointer;
7681
}

projects/social_platform/src/app/office/courses/lesson/shared/exclude-task/exclude-task.component.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ export class ExcludeTaskComponent implements OnInit {
5757
@Output() update = new EventEmitter<number[]>(); // Событие обновления выбранных ответов
5858

5959
@Input() success = false; // Флаг успешного выполнения
60+
@Input() disabled = false;
6061

6162
@Input()
6263
set error(value: boolean) {
@@ -104,6 +105,7 @@ export class ExcludeTaskComponent implements OnInit {
104105
* @param id - ID варианта ответа
105106
*/
106107
onSelect(id: number) {
108+
if (this.disabled) return;
107109
if (this.result().includes(id)) {
108110
// Если вариант уже выбран, убираем его из списка
109111
this.result.set(this.result().filter(i => i !== id));

projects/social_platform/src/app/office/courses/lesson/shared/file-task/file-task.component.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@
6565
<p class="file-task__label text-body-12">ответ</p>
6666
<p class="file-task__title text-body-12-bold">{{ data.answerTitle | truncate: 80 }}</p>
6767

68+
@if (!disabled) {
6869
<div class="file-task__files">
6970
<app-upload-file [resetAfterUpload]="true" (uploaded)="onFileUploaded($event)">
7071
<div emptyPlaceholder class="file-task__upload">
@@ -85,5 +86,6 @@
8586
></app-file-item>
8687
}
8788
</div>
89+
}
8890
</div>
8991
</div>

projects/social_platform/src/app/office/courses/lesson/shared/file-task/file-task.component.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ export class FileTaskComponent implements OnInit {
4848
@Input({ required: true }) data!: Task;
4949
@Input() success = false;
5050
@Input() hint = "";
51+
@Input() disabled = false;
5152

5253
@Input()
5354
set error(value: boolean) {

projects/social_platform/src/app/office/courses/lesson/shared/radio-select-task/radio-select-task.component.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,10 @@
5555
class="radio__item"
5656
[class.radio__item--success]="success && result().answerId === op.id"
5757
[class.radio__item--error]="error && result().answerId === op.id"
58+
[class.radio__item--disabled]="disabled"
5859
(click)="onSelect(op.id)"
5960
>
60-
<input type="radio" [id]="op.id" name="radio-group" />
61+
<input type="radio" [id]="op.id" name="radio-group" [disabled]="disabled" />
6162
<label class="text-body-12" [for]="op.id">
6263
{{ op.text }}
6364
</label>

projects/social_platform/src/app/office/courses/lesson/shared/radio-select-task/radio-select-task.component.scss

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,11 @@
108108
background-color: var(--red);
109109
}
110110
}
111+
112+
&--disabled {
113+
pointer-events: none;
114+
opacity: 0.6;
115+
}
111116
}
112117

113118
&__body,

0 commit comments

Comments
 (0)