Skip to content
Snippets Groups Projects
Commit 56398a7f authored by ywb16155's avatar ywb16155
Browse files

commit #25 - updating CRUD repositories to have necessary annotation for...

commit #25 - updating CRUD repositories to have necessary annotation for delete functions, updating components to destroy themselves when navigating away
parent 2f3c5401
No related branches found
No related tags found
No related merge requests found
Showing
with 64 additions and 49 deletions
......@@ -4,6 +4,7 @@ import com.diss.omppapp.entities.AnswerEntity;
import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Repository;
import javax.transaction.Transactional;
import java.util.List;
import java.util.Optional;
......@@ -14,5 +15,6 @@ public interface AnswerEntityRepository extends CrudRepository<AnswerEntity, Int
Optional<List<AnswerEntity>> findAllByUsernameAndPaperIdOrderByAnswerIdAsc(String username, int paperId);
boolean existsByUsernameAndPaperIdAndQuestionId(String username, int paperId, int QuestionId);
Optional<AnswerEntity> findByUsernameAndPaperIdAndQuestionId(String username, int paperId, int QuestionId);
@Transactional
void deleteByPaperId(int paperId);
}
......@@ -4,6 +4,7 @@ import com.diss.omppapp.entities.MinutePaperEntity;
import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Repository;
import javax.transaction.Transactional;
import java.util.List;
import java.util.Optional;
......@@ -15,5 +16,6 @@ public interface MinutePaperEntityRepository extends CrudRepository<MinutePaperE
Optional<List<MinutePaperEntity>> findAllByUsernameAndTemplate(String classCode, Boolean isTemplate);
Optional<List<MinutePaperEntity>> findAllByUsernameAndClassCodeAndTemplate(String username, String classCode, boolean template);
boolean existsByPaperId(int paperId);
@Transactional
void deleteByPaperId(int paperId);
}
......@@ -36,34 +36,36 @@ export class LecturerDashboardComponent implements OnInit, OnDestroy {
this.isAlive = false;
}
private getClasses() {
this.lecturerInfoService.getLecturerClasses(this.lecturerId).subscribe((data: OmpClassDao[]) => {
data.forEach(c => this.classList.push(c));
});
}
public goToPaperView(classCode: String) {
this.lecturerDataService.classCode = classCode;
this.lecturerViewService.changeToDashboard(false);
this.router.navigate(['/paper-view']);
this.ngOnDestroy();
}
public goToTemplateView() {
this.lecturerViewService.changeToDashboard(false);
this.router.navigate(['/template-view']);
this.ngOnDestroy();
}
public createPaperView() {
this.lecturerDataService.isTemplate = false;
this.lecturerViewService.changeToDashboard(false);
this.router.navigate(['/creation-view']);
this.ngOnDestroy();
}
public createTemplateView() {
this.lecturerDataService.isTemplate = true;
this.lecturerViewService.changeToDashboard(false);
this.router.navigate(['/creation-view']);
this.ngOnDestroy();
}
private getClasses() {
this.lecturerInfoService.getLecturerClasses(this.lecturerId).subscribe((data: OmpClassDao[]) => {
data.forEach(c => this.classList.push(c));
});
}
}
......@@ -31,10 +31,17 @@ export class LecturerPaperViewComponent implements OnInit, OnDestroy {
this.classPapers = [];
}
private getClassesPapers(): void {
this.lecturerInfoService.getClassPapers(this.lecturerId, this.classCode).subscribe((data: MinutePaperDao[]) => {
data.forEach(p => {this.classPapers.push(p); console.log(p.paperId); });
});
}
public goToSubmissionsView(paper: MinutePaperDao) {
this.classPapers = [];
this.lecturerDataService.currentPaper = paper;
this.router.navigate(['/submissionsview']);
this.router.navigate(['/submissions-view']);
this.ngOnDestroy();
}
public deletePaper(paper: MinutePaperDao, index: number) {
......@@ -42,12 +49,4 @@ export class LecturerPaperViewComponent implements OnInit, OnDestroy {
this.lecturerInfoService.deletePaper(paper.paperId).subscribe();
}
private getClassesPapers(): void {
this.lecturerInfoService.getClassPapers(this.lecturerId, this.classCode).subscribe((data: MinutePaperDao[]) => {
data.forEach(p => {this.classPapers.push(p); console.log(p.paperId); });
});
}
}
......@@ -41,7 +41,8 @@ export class LecturerSubmissionsViewComponent implements OnInit, OnDestroy {
public goToResponse(set: AnswerSetDao): void {
this.lecturerDataService.currentAnswerSet = set;
this.lecturerDataService.currentQuestions = this.questions;
this.router.navigate(['responseview']);
this.router.navigate(['response-view']);
this.ngOnDestroy();
}
private getPaperQuestions(): void {
......
......@@ -12,8 +12,8 @@ import {LecturerEditTemplateViewComponent} from './LecturerEditTemplateView/lect
const lecturerRoutes = [
{ path: 'ldashboard', component: LecturerRootComponent },
{ path: 'paper-view', component: LecturerPaperViewComponent },
{ path: 'submissionsview', component: LecturerSubmissionsViewComponent },
{ path: 'responseview', component: LecturerResponseViewComponent },
{ path: 'submissions-view', component: LecturerSubmissionsViewComponent },
{ path: 'response-view', component: LecturerResponseViewComponent },
{ path: 'creation-view', component: LecturerCreateOmpViewComponent },
{ path: 'template-view', component: LecturerTemplateViewComponent },
{ path: 'edit-template-view', component: LecturerEditTemplateViewComponent }
......
......@@ -36,20 +36,6 @@ export class StudentClassViewComponent implements OnInit, OnDestroy {
this.openClassPapers = [];
}
private goToCompletedPage(paperId: String) {
this.studentDataService.currentPaper = this.getCurrentPaper(paperId);
this.studentViewService.changeToCompletedView(true);
this.studentViewService.changeToClassView(false);
this.router.navigate(['/completedview']);
}
private goToSubmissionView(paperId: String) {
this.studentDataService.currentPaper = this.getCurrentPaper(paperId);
this.studentViewService.changeToDashboard(false);
this.studentViewService.changeToSubmissionView(true);
this.router.navigate(['/submissionview']);
}
private getCurrentPaper(paperId: String) {
let currentPaper: MinutePaperDao = null;
......@@ -80,4 +66,20 @@ export class StudentClassViewComponent implements OnInit, OnDestroy {
}
});
}
public goToCompletedPage(paperId: String) {
this.studentDataService.currentPaper = this.getCurrentPaper(paperId);
this.studentViewService.changeToCompletedView(true);
this.studentViewService.changeToClassView(false);
this.router.navigate(['/completed-view']);
this.ngOnDestroy();
}
public goToSubmissionView(paperId: String) {
this.studentDataService.currentPaper = this.getCurrentPaper(paperId);
this.studentViewService.changeToDashboard(false);
this.studentViewService.changeToSubmissionView(true);
this.router.navigate(['/submission-view']);
this.ngOnDestroy();
}
}
......@@ -39,6 +39,9 @@ export class StudentCompletedViewComponent implements OnInit, OnDestroy {
}
ngOnDestroy(): void {
this.questionList = [];
this.answerList = [];
this.questionAnswerPairs = [];
}
private organise() {
......
......@@ -48,14 +48,16 @@ export class StudentDashboardComponent implements OnInit, OnDestroy {
this.studentDataService.classCode = classCode;
this.studentViewService.changeToDashboard(false);
this.studentViewService.changeToClassView(true);
this.router.navigate(['/classview']);
this.router.navigate(['/class-view']);
this.ngOnDestroy();
}
private goToSubmissionView(paperId: String) {
this.studentDataService.currentPaper = this.getCurrentPaper(paperId);
this.studentViewService.changeToDashboard(false);
this.studentViewService.changeToSubmissionView(true);
this.router.navigate(['/submissionview']);
this.router.navigate(['/submission-view']);
this.ngOnDestroy();
}
private getCurrentPaper(paperId: String) {
......
......@@ -7,6 +7,7 @@ import {AnswerDao} from 'src/app/dao/answer.dao';
import {MinutePaperDao} from 'src/app/dao/minute-paper.dao';
import {FormArray, FormBuilder, FormGroup} from '@angular/forms';
import {StudentResponseDao} from 'src/app/dao/student-response.dao';
import {Router} from '@angular/router';
@Component({
selector: 'app-student-submission-view',
......@@ -25,7 +26,8 @@ export class StudentSubmissionViewComponent implements OnInit, OnDestroy {
constructor(private studentViewService: StudentViewService,
private studentInfoService: StudentInfoService,
private studentDataService: StudentDataService,
private formBuilder: FormBuilder) {
private formBuilder: FormBuilder,
private router: Router) {
}
ngOnInit(): void {
......@@ -47,15 +49,6 @@ export class StudentSubmissionViewComponent implements OnInit, OnDestroy {
this.studentResponse = [];
}
public submit(): void {
this.populateAnswers();
this.studentInfoService.submitResponse(this.studentResponse).subscribe();
}
public save(): void {
this.populateAnswers();
this.studentInfoService.saveDraft(this.studentResponse).subscribe();
}
private populateAnswers(): void {
let index = 0;
......@@ -96,4 +89,13 @@ export class StudentSubmissionViewComponent implements OnInit, OnDestroy {
});
}
public submit(): void {
this.populateAnswers();
this.studentInfoService.submitResponse(this.studentResponse).subscribe();
}
public save(): void {
this.populateAnswers();
this.studentInfoService.saveDraft(this.studentResponse).subscribe();
}
}
......@@ -8,9 +8,9 @@ import {StudentSubmissionViewComponent} from './StudentSubmissionView/student-su
const studentRoutes = [
{ path: 'sdashboard', component: StudentRootComponent },
{ path: 'classview', component: StudentClassViewComponent },
{ path: 'completedview', component: StudentCompletedViewComponent },
{ path: 'submissionview', component: StudentSubmissionViewComponent },
{ path: 'class-view', component: StudentClassViewComponent },
{ path: 'completed-view', component: StudentCompletedViewComponent },
{ path: 'submission-view', component: StudentSubmissionViewComponent },
];
......
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