Skip to content
This repository has been archived by the owner on Mar 10, 2024. It is now read-only.

Commit

Permalink
fixing bug for results page
Browse files Browse the repository at this point in the history
  • Loading branch information
nitrotap committed Jun 9, 2023
1 parent f8a9ed0 commit ee7e6a7
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
16 changes: 14 additions & 2 deletions client/src/app/quiz/quiz.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Component, OnInit } from '@angular/core';
import { AnswerDataService } from '../services/answer-data.service';
import { TaskDataService } from '../services/task-data.service';
import { ToastController } from '@ionic/angular';
import { Router } from '@angular/router';
@Component({
selector: 'app-quiz',
templateUrl: './quiz.page.html',
Expand Down Expand Up @@ -63,11 +64,22 @@ export class QuizPage implements OnInit {

this.answerDataService.postData(this.formData).subscribe({
next: response => console.log('Response from server:', response),
error: error => console.error('Error:', error)
error: async error => {
console.error('Error:', error)
const alert = this.toastController.create({
message: 'Error saving your task! Please try logging in again.',
duration: 2000,
position: 'bottom',
color: 'danger'
});
(await alert).present();
this.router.navigateByUrl('/login')
return;
}
});
}

constructor(private answerDataService: AnswerDataService, private taskDataService: TaskDataService, private toastController: ToastController) { }
constructor(private answerDataService: AnswerDataService, private taskDataService: TaskDataService, private toastController: ToastController, private router: Router) { }


questions: any[] = [
Expand Down
2 changes: 1 addition & 1 deletion client/src/app/results/results.page.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

<div *ngIf="task.isExpanded">
<ion-title>See Your Past Results for {{ task.taskName }}</ion-title>
<ion-item *ngFor="let demoResult of answerResults" [hidden]="demoResult.taskID !== task.taskID">
<ion-item *ngFor="let demoResult of getResultsForTask(task.taskID)">
<ion-item>Mental Demand: {{ demoResult.taskAnswer_1 }}</ion-item>
<ion-item>Physical Demand: {{ demoResult.answerID }}</ion-item>
<ion-item>Time (Temporal) Demand: {{ demoResult.answerID }}</ion-item>
Expand Down
5 changes: 5 additions & 0 deletions client/src/app/results/results.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ export class ResultsPage implements OnInit {
},
]

getResultsForTask(taskID: number): any[] {
return this.answerResults.filter((result: any) => result.taskID === taskID);
}


getTaskData() {
// user specific tasks

Expand Down

0 comments on commit ee7e6a7

Please sign in to comment.